pImagedata->iJHDRcompression   = 0; pImagedata->iJHDRinterlace     = 0; pImagedata->iPixelsampledepth  = iBitdepth; pImagedata->iAlphasampledepth  = iBitdepth;
mng_retcode create_imagedataobject (mng_datap      pData,                                    mng_bool       bConcrete,                                    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_imagedatap *ppObject){  mng_imagedatap pImagedata;  mng_uint32 iSamplesize = 0;#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_CREATE_IMGDATAOBJECT, MNG_LC_START)#endif                                       /* get a buffer */  MNG_ALLOC (pData, pImagedata, sizeof (mng_imagedata))                                       /* fill the appropriate fields */  pImagedata->sHeader.fCleanup   = (mng_cleanupobject)free_imagedataobject;  pImagedata->sHeader.fProcess   = 0;  pImagedata->iRefcount          = 1;  pImagedata->bFrozen            = MNG_FALSE;  pImagedata->bConcrete          = bConcrete;  pImagedata->bViewable          = bViewable;  pImagedata->iWidth             = iWidth;  pImagedata->iHeight            = iHeight;  pImagedata->iBitdepth          = iBitdepth;  pImagedata->iColortype         = iColortype;  pImagedata->iCompression       = iCompression;  pImagedata->iFilter            = iFilter;  pImagedata->iInterlace         = iInterlace;  pImagedata->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;               }  }                                       /* make sure we remember all this */  pImagedata->iSamplesize  = iSamplesize;  pImagedata->iRowsize     = iSamplesize * iWidth;  pImagedata->iImgdatasize = pImagedata->iRowsize * iHeight;  if (pImagedata->iImgdatasize)        /* need a buffer ? */  {                                    /* so allocate it */    MNG_ALLOCX (pData, pImagedata->pImgdata, pImagedata->iImgdatasize)    if (!pImagedata->pImgdata)         /* enough memory ? */    {      MNG_FREEX (pData, pImagedata, sizeof (mng_imagedata))      MNG_ERROR (pData, MNG_OUTOFMEMORY)    }  }                                       /* check global stuff */  pImagedata->bHasGAMA           = pData->bHasglobalGAMA;  pImagedata->bHasCHRM           = pData->bHasglobalCHRM;  pImagedata->bHasSRGB           = pData->bHasglobalSRGB;  pImagedata->bHasICCP           = pData->bHasglobalICCP;  pImagedata->bHasBKGD           = pData->bHasglobalBKGD;  if (pData->bHasglobalGAMA)           /* global gAMA present ? */    pImagedata->iGamma           = pData->iGlobalGamma;  if (pData->bHasglobalCHRM)           /* global cHRM present ? */  {    pImagedata->iWhitepointx     = pData->iGlobalWhitepointx;    pImagedata->iWhitepointy     = pData->iGlobalWhitepointy;    pImagedata->iPrimaryredx     = pData->iGlobalPrimaryredx;    pImagedata->iPrimaryredy     = pData->iGlobalPrimaryredy;    pImagedata->iPrimarygreenx   = pData->iGlobalPrimarygreenx;    pImagedata->iPrimarygreeny   = pData->iGlobalPrimarygreeny;    pImagedata->iPrimarybluex    = pData->iGlobalPrimarybluex;    pImagedata->iPrimarybluey    = pData->iGlobalPrimarybluey;  }  if (pData->bHasglobalSRGB)           /* glbal sRGB present ? */    pImagedata->iRenderingintent = pData->iGlobalRendintent;  if (pData->bHasglobalICCP)           /* glbal iCCP present ? */  {    pImagedata->iProfilesize     = pData->iGlobalProfilesize;    if (pImagedata->iProfilesize)    {      MNG_ALLOCX (pData, pImagedata->pProfile, pImagedata->iProfilesize)      if (!pImagedata->pProfile)       /* enough memory ? */      {        MNG_FREEX (pData, pImagedata->pImgdata, pImagedata->iImgdatasize)        MNG_FREEX (pData, pImagedata, sizeof (mng_imagedata))        MNG_ERROR (pData, MNG_OUTOFMEMORY)      }      MNG_COPY  (pImagedata->pProfile, pData->pGlobalProfile, pImagedata->iProfilesize)    }  }  if (pData->bHasglobalBKGD)           /* global bKGD present ? */  {    pImagedata->iBKGDred         = pData->iGlobalBKGDred;    pImagedata->iBKGDgreen       = pData->iGlobalBKGDgreen;    pImagedata->iBKGDblue        = pData->iGlobalBKGDblue;  }  *ppObject = pImagedata;              /* return it */#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_CREATE_IMGDATAOBJECT, MNG_LC_END)#endif  return MNG_NOERROR;}