⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libmng_object_prc.c

📁 Linux下的基于X11的图形开发环境。
💻 C
📖 第 1 页 / 共 5 页
字号:
      MNG_ERROR (pData, MNG_OUTOFMEMORY)    }                                       /* make a copy */    MNG_COPY (pNewdata->pImgdata, pSource->pImgdata, pNewdata->iImgdatasize)  }  if (pNewdata->iProfilesize)          /* iCCP profile present ? */  {    MNG_ALLOCX (pData, pNewdata->pProfile, pNewdata->iProfilesize)    if (!pNewdata->pProfile)           /* enough memory ? */    {      MNG_FREEX (pData, pNewdata, sizeof (mng_imagedata))      MNG_ERROR (pData, MNG_OUTOFMEMORY)    }                                       /* make a copy */    MNG_COPY (pNewdata->pProfile, pSource->pProfile, pNewdata->iProfilesize)  }  *ppClone = pNewdata;                 /* return the clone */#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_CLONE_IMGDATAOBJECT, MNG_LC_END)#endif  return MNG_NOERROR;}/* ************************************************************************** *//* *                                                                        * *//* * Image-object routines                                                  * *//* *                                                                        * *//* * these handle the "object" as defined by the MNG specification          * *//* *                                                                        * *//* ************************************************************************** */mng_retcode create_imageobject (mng_datap  pData,                                mng_uint16 iId,                                mng_bool   bConcrete,                                mng_bool   bVisible,                                mng_bool   bViewable,                                mng_uint32 iWidth,                                mng_uint32 iHeight,                                mng_uint8  iBitdepth,                                mng_uint8  iColortype,                                mng_uint8  iCompression,                                mng_uint8  iFilter,                                mng_uint8  iInterlace,                                mng_int32  iPosx,                                mng_int32  iPosy,                                mng_bool   bClipped,                                mng_int32  iClipl,                                mng_int32  iClipr,                                mng_int32  iClipt,                                mng_int32  iClipb,                                mng_imagep *ppObject){  mng_imagep     pImage;  mng_imagep     pPrev, pNext;  mng_retcode    iRetcode;  mng_imagedatap pImgbuf;#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_CREATE_IMGOBJECT, MNG_LC_START)#endif                                       /* get a buffer */  MNG_ALLOC (pData, pImage, sizeof (mng_image))                                       /* now get a new "object buffer" */  iRetcode = create_imagedataobject (pData, bConcrete, bViewable,                                     iWidth, iHeight, iBitdepth, iColortype,                                     iCompression, iFilter, iInterlace,                                     &pImgbuf);  if (iRetcode)                        /* on error bail out */  {    MNG_FREEX (pData, pImage, sizeof (mng_image))    return iRetcode;  }                                       /* fill the appropriate fields */  pImage->sHeader.fCleanup = (mng_cleanupobject)free_imageobject;  pImage->sHeader.fProcess = 0;  pImage->iId              = iId;  pImage->bFrozen          = MNG_FALSE;  pImage->bVisible         = bVisible;  pImage->bViewable        = bViewable;  pImage->bValid           = (mng_bool)((pData->bDisplaying) &&                                        (pData->bRunning   ) &&                                        (!pData->bFreezing )    );   pImage->iPosx            = iPosx;  pImage->iPosy            = iPosy;  pImage->bClipped         = bClipped;  pImage->iClipl           = iClipl;  pImage->iClipr           = iClipr;  pImage->iClipt           = iClipt;  pImage->iClipb           = iClipb;  pImage->iMAGN_MethodX    = 0;  pImage->iMAGN_MethodY    = 0;  pImage->iMAGN_MX         = 0;  pImage->iMAGN_MY         = 0;  pImage->iMAGN_ML         = 0;  pImage->iMAGN_MR         = 0;  pImage->iMAGN_MT         = 0;  pImage->iMAGN_MB         = 0;  pImage->pImgbuf          = pImgbuf;  if (iId)                             /* only if not object 0 ! */  {                                    /* find previous lower object-id */    pPrev = (mng_imagep)pData->pLastimgobj;    while ((pPrev) && (pPrev->iId > iId))      pPrev = (mng_imagep)pPrev->sHeader.pPrev;    if (pPrev)                         /* found it ? */    {      pImage->sHeader.pPrev = pPrev;   /* than link it in place */      pImage->sHeader.pNext = pPrev->sHeader.pNext;      pPrev->sHeader.pNext  = pImage;    }    else                               /* if not found, it becomes the first ! */    {      pImage->sHeader.pNext = pData->pFirstimgobj;      pData->pFirstimgobj   = pImage;    }    pNext                   = (mng_imagep)pImage->sHeader.pNext;    if (pNext)      pNext->sHeader.pPrev  = pImage;    else      pData->pLastimgobj    = pImage;      }    *ppObject = pImage;                  /* and return the new buffer */#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_CREATE_IMGOBJECT, MNG_LC_END)#endif  return MNG_NOERROR;                  /* okido */}/* ************************************************************************** */mng_retcode free_imageobject (mng_datap  pData,                              mng_imagep pImage){  mng_retcode    iRetcode;  mng_imagep     pPrev   = pImage->sHeader.pPrev;  mng_imagep     pNext   = pImage->sHeader.pNext;  mng_imagedatap pImgbuf = pImage->pImgbuf;#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_FREE_IMGOBJECT, MNG_LC_START)#endif  if (pImage->iId)                     /* not for object 0 */  {    if (pPrev)                         /* unlink from the list first ! */      pPrev->sHeader.pNext = pImage->sHeader.pNext;    else      pData->pFirstimgobj  = pImage->sHeader.pNext;    if (pNext)      pNext->sHeader.pPrev = pImage->sHeader.pPrev;    else      pData->pLastimgobj   = pImage->sHeader.pPrev;  }                                       /* unlink the image-data buffer */  iRetcode = free_imagedataobject (pData, pImgbuf);                                       /* drop it's own buffer */  MNG_FREEX (pData, pImage, sizeof (mng_image))#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_FREE_IMGOBJECT, MNG_LC_END)#endif  return iRetcode;}/* ************************************************************************** */mng_imagep find_imageobject (mng_datap  pData,                             mng_uint16 iId){  mng_imagep pImage = (mng_imagep)pData->pFirstimgobj;#ifdef MNG_SUPPORT_TRACE  MNG_TRACEX (pData, MNG_FN_FIND_IMGOBJECT, MNG_LC_START)#endif                                       /* look up the right id */  while ((pImage) && (pImage->iId != iId))    pImage = (mng_imagep)pImage->sHeader.pNext;#ifdef MNG_SUPPORT_TRACE  MNG_TRACEX (pData, MNG_FN_FIND_IMGOBJECT, MNG_LC_END)#endif  return pImage;}/* ************************************************************************** */mng_retcode clone_imageobject (mng_datap  pData,                               mng_uint16 iId,                               mng_bool   bPartial,                               mng_bool   bVisible,                               mng_bool   bAbstract,                               mng_bool   bHasloca,                               mng_uint8  iLocationtype,                               mng_int32  iLocationx,                               mng_int32  iLocationy,                               mng_imagep pSource,                               mng_imagep *ppClone){  mng_imagep     pNew;  mng_imagep     pPrev, pNext;  mng_retcode    iRetcode;  mng_imagedatap pImgbuf;#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_CLONE_IMGOBJECT, MNG_LC_START)#endif  if ((pSource->iId) &&                /* needs magnification ? */      ((pSource->iMAGN_MethodX) || (pSource->iMAGN_MethodY)))  {    iRetcode = magnify_imageobject (pData, pSource);    if (iRetcode)                      /* on error bail out */      return iRetcode;  }                                       /* get a buffer */  MNG_ALLOC (pData, pNew, sizeof (mng_image))                                       /* fill or copy the appropriate fields */  pNew->sHeader.fCleanup = (mng_cleanupobject)free_imageobject;  pNew->sHeader.fProcess = 0;  pNew->iId              = iId;  pNew->bFrozen          = MNG_FALSE;  pNew->bVisible         = bVisible;  pNew->bViewable        = pSource->bViewable;  if (bHasloca)                        /* location info available ? */  {    if (iLocationtype == 0)            /* absolute position ? */    {      pNew->iPosx        = iLocationx;      pNew->iPosy        = iLocationy;    }    else                               /* relative */    {      pNew->iPosx        = pSource->iPosx + iLocationx;      pNew->iPosy        = pSource->iPosy + iLocationy;    }  }  else                                 /* copy from source */  {    pNew->iPosx          = pSource->iPosx;    pNew->iPosy          = pSource->iPosy;  }                                       /* copy clipping info */  pNew->bClipped         = pSource->bClipped;  pNew->iClipl           = pSource->iClipl;  pNew->iClipr           = pSource->iClipr;  pNew->iClipt           = pSource->iClipt;  pNew->iClipb           = pSource->iClipb;                                       /* copy magnification info */  pNew->iMAGN_MethodX    = pSource->iMAGN_MethodX;  pNew->iMAGN_MethodY    = pSource->iMAGN_MethodY;  pNew->iMAGN_MX         = pSource->iMAGN_MX;  pNew->iMAGN_MY         = pSource->iMAGN_MY;  pNew->iMAGN_ML         = pSource->iMAGN_ML;  pNew->iMAGN_MR         = pSource->iMAGN_MR;  pNew->iMAGN_MT         = pSource->iMAGN_MT;  pNew->iMAGN_MB         = pSource->iMAGN_MB;  if (iId)                             /* not for object 0 */  {                                    /* find previous lower object-id */    pPrev = (mng_imagep)pData->pLastimgobj;    while ((pPrev) && (pPrev->iId > iId))      pPrev = (mng_imagep)pPrev->sHeader.pPrev;    if (pPrev)                         /* found it ? */    {      pNew->sHeader.pPrev  = pPrev;    /* than link it in place */      pNew->sHeader.pNext  = pPrev->sHeader.pNext;      pPrev->sHeader.pNext = pNew;    }    else                               /* if not found, it becomes the first ! */    {      pNew->sHeader.pNext  = pData->pFirstimgobj;      pData->pFirstimgobj  = pNew;    }    pNext                  = (mng_imagep)pNew->sHeader.pNext;    if (pNext)      pNext->sHeader.pPrev = pNew;    else      pData->pLastimgobj   = pNew;  }  if (bPartial)                        /* partial clone ? */  {    pNew->pImgbuf = pSource->pImgbuf;  /* use the same object buffer */    pNew->pImgbuf->iRefcount++;        /* and increase the reference count */  }  else                                 /* create a full clone ! */  {    mng_bool bConcrete = MNG_FALSE;    /* it's abstract by default (?) */    if (!bAbstract)                    /* determine concreteness from source ? */      bConcrete = pSource->pImgbuf->bConcrete;                                       /* create a full clone ! */    iRetcode = clone_imagedataobject (pData, bConcrete, pSource->pImgbuf, &pImgbuf);    if (iRetcode)                      /* on error bail out */    {      MNG_FREEX (pData, pNew, sizeof (mng_image))      return iRetcode;    }    pNew->pImgbuf = pImgbuf;           /* and remember it */  }  *ppClone = pNew;                     /* return it */#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_CLONE_IMGOBJECT, MNG_LC_END)#endif  return MNG_NOERROR;}/* ************************************************************************** */mng_retcode renum_imageobject (mng_datap  pData,                               mng_imagep pSource,                               mng_uint16 iId,                               mng_bool   bVisible,                               mng_bool   bAbstract,                               mng_bool   bHasloca,                               mng_uint8  iLocationtype,                               mng_int32  iLocationx,                               mng_int32  iLocationy){  mng_imagep pPrev, pNext;#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_RENUM_IMGOBJECT, MNG_LC_START)#endif  pSource->bVisible  = bVisible;       /* store the new visibility */  if (bHasloca)                        /* location info available ? */  {    if (iLocationtype == 0)            /* absolute position ? */    {      pSource->iPosx = iLocationx;      pSource->iPosy = iLocationy;    }    else                               /* relative */    {      pSource->iPosx = pSource->iPosx + iLocationx;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -