if (pImage->iId)                      { 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; }
mng_retcode reset_object_details (mng_datap  pData,                                  mng_imagep pImage,                                  mng_uint32 iWidth,                                  mng_uint32 iHeight,                                  mng_uint8  iBitdepth,                                  mng_uint8  iColortype,                                  mng_uint8  iCompression,                                  mng_uint8  iFilter,                                  mng_uint8  iInterlace,                                  mng_bool   bResetall){  mng_imagedatap pBuf  = pImage->pImgbuf;  mng_uint32     iSamplesize = 0;  mng_uint32     iRowsize;  mng_uint32     iImgdatasize;#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_RESET_OBJECTDETAILS, MNG_LC_START)#endif  pBuf->iWidth         = iWidth;       /* set buffer characteristics */  pBuf->iHeight        = iHeight;  pBuf->iBitdepth      = iBitdepth;  pBuf->iColortype     = iColortype;  pBuf->iCompression   = iCompression;  pBuf->iFilter        = iFilter;  pBuf->iInterlace     = iInterlace;  pBuf->iAlphabitdepth = 0;                                       /* determine samplesize from color_type/bit_depth */  switch (iColortype)                  /* for < 8-bit samples we just reserve 8 bits */  {    case  0  : ;                       /* gray */    case  8  : {                       /* JPEG gray */                 if (iBitdepth > 8)                   iSamplesize = 2;                 else                   iSamplesize = 1;                 break;               }    case  2  : ;                       /* rgb */    case 10  : {                       /* JPEG rgb */                 if (iBitdepth > 8)                   iSamplesize = 6;                 else                   iSamplesize = 3;                 break;               }    case  3  : {                       /* indexed */                 iSamplesize = 1;                 break;               }    case  4  : ;                       /* gray+alpha */    case 12  : {                       /* JPEG gray+alpha */                 if (iBitdepth > 8)                   iSamplesize = 4;                 else                   iSamplesize = 2;                 break;               }    case  6  : ;                       /* rgb+alpha */    case 14  : {                       /* JPEG rgb+alpha */                 if (iBitdepth > 8)                   iSamplesize = 8;                 else                   iSamplesize = 4;                 break;               }  }  iRowsize     = iSamplesize * iWidth;  iImgdatasize = iRowsize    * iHeight;                                       /* buffer size changed ? */  if (iImgdatasize != pBuf->iImgdatasize)  {                                    /* drop the old one */    MNG_FREE (pData, pBuf->pImgdata, pBuf->iImgdatasize)    if (iImgdatasize)                  /* allocate new sample-buffer ? */      MNG_ALLOC (pData, pBuf->pImgdata, iImgdatasize)  }  pBuf->iSamplesize  = iSamplesize;    /* remember new sizes */  pBuf->iRowsize     = iRowsize;  pBuf->iImgdatasize = iImgdatasize;                                       /* dimension set and clipping not ? */  if ((iWidth) && (iHeight) && (!pImage->bClipped))  {    pImage->iClipl   = 0;              /* set clipping to dimension by default */    pImage->iClipr   = iWidth;    pImage->iClipt   = 0;    pImage->iClipb   = iHeight;  }  if (bResetall)                       /* reset the other characteristics ? */  {    pBuf->bHasPLTE = MNG_FALSE;    pBuf->bHasTRNS = MNG_FALSE;    pBuf->bHasGAMA = pData->bHasglobalGAMA;    pBuf->bHasCHRM = pData->bHasglobalCHRM;    pBuf->bHasSRGB = pData->bHasglobalSRGB;    pBuf->bHasICCP = pData->bHasglobalICCP;    pBuf->bHasBKGD = pData->bHasglobalBKGD;    if (pBuf->iProfilesize)            /* drop possibly old ICC profile */    {      MNG_FREE (pData, pBuf->pProfile, pBuf->iProfilesize)      pBuf->iProfilesize     = 0;    }      if (pData->bHasglobalGAMA)         /* global gAMA present ? */      pBuf->iGamma           = pData->iGlobalGamma;    if (pData->bHasglobalCHRM)         /* global cHRM present ? */    {      pBuf->iWhitepointx     = pData->iGlobalWhitepointx;      pBuf->iWhitepointy     = pData->iGlobalWhitepointy;      pBuf->iPrimaryredx     = pData->iGlobalPrimaryredx;      pBuf->iPrimaryredy     = pData->iGlobalPrimaryredy;      pBuf->iPrimarygreenx   = pData->iGlobalPrimarygreenx;      pBuf->iPrimarygreeny   = pData->iGlobalPrimarygreeny;      pBuf->iPrimarybluex    = pData->iGlobalPrimarybluex;      pBuf->iPrimarybluey    = pData->iGlobalPrimarybluey;    }    if (pData->bHasglobalSRGB)           /* global sRGB present ? */      pBuf->iRenderingintent = pData->iGlobalRendintent;    if (pData->bHasglobalICCP)           /* global iCCP present ? */    {      if (pData->iGlobalProfilesize)      {        MNG_ALLOC (pData, pBuf->pProfile, pData->iGlobalProfilesize)        MNG_COPY  (pBuf->pProfile, pData->pGlobalProfile, pData->iGlobalProfilesize)      }      pBuf->iProfilesize     = pData->iGlobalProfilesize;    }    if (pData->bHasglobalBKGD)           /* global bKGD present ? */    {      pBuf->iBKGDred         = pData->iGlobalBKGDred;      pBuf->iBKGDgreen       = pData->iGlobalBKGDgreen;      pBuf->iBKGDblue        = pData->iGlobalBKGDblue;    }  }#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_RESET_OBJECTDETAILS, MNG_LC_END)#endif  return MNG_NOERROR;}