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;
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                                       /* 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;  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;}