if ((pData->bHasIDAT) || (pData->bHasPLTE) || (pData->bHasJDAT))
if ((pData->bHasIDAT) || (pData->bHasPLTE) || (pData->bHasJDAT) || (pData->bHasJDAA))
READ_CHUNK (read_chrm){#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_READ_CHRM, MNG_LC_START)#endif                                       /* sequence checks */#ifdef MNG_INCLUDE_JNG  if ((!pData->bHasMHDR) && (!pData->bHasIHDR) &&      (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR))#else  if ((!pData->bHasMHDR) && (!pData->bHasIHDR) &&      (!pData->bHasBASI) && (!pData->bHasDHDR)    )#endif    MNG_ERROR (pData, MNG_SEQUENCEERROR)#ifdef MNG_INCLUDE_JNG  if ((pData->bHasIDAT) || (pData->bHasPLTE) || (pData->bHasJDAT))#else  if ((pData->bHasIDAT) || (pData->bHasPLTE))#endif    MNG_ERROR (pData, MNG_SEQUENCEERROR)#ifdef MNG_INCLUDE_JNG  if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR))#else  if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))#endif  {                                    /* length must be exactly 32 */    if (iRawlen != 32)      MNG_ERROR (pData, MNG_INVALIDLENGTH)  }  else  {                                    /* length must be empty or exactly 32 */    if ((iRawlen != 0) && (iRawlen != 32))      MNG_ERROR (pData, MNG_INVALIDLENGTH)  }#ifdef MNG_INCLUDE_JNG  if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR))#else  if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))#endif    pData->bHasCHRM = MNG_TRUE;        /* indicate we've got it */  else    pData->bHasglobalCHRM = (mng_bool)(iRawlen != 0);#ifdef MNG_SUPPORT_DISPLAY  {    mng_uint32 iWhitepointx,   iWhitepointy;    mng_uint32 iPrimaryredx,   iPrimaryredy;    mng_uint32 iPrimarygreenx, iPrimarygreeny;    mng_uint32 iPrimarybluex,  iPrimarybluey;    iWhitepointx   = mng_get_uint32 (pRawdata);    iWhitepointy   = mng_get_uint32 (pRawdata+4);    iPrimaryredx   = mng_get_uint32 (pRawdata+8);    iPrimaryredy   = mng_get_uint32 (pRawdata+12);    iPrimarygreenx = mng_get_uint32 (pRawdata+16);    iPrimarygreeny = mng_get_uint32 (pRawdata+20);    iPrimarybluex  = mng_get_uint32 (pRawdata+24);    iPrimarybluey  = mng_get_uint32 (pRawdata+28);#ifdef MNG_INCLUDE_JNG    if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR))#else    if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))#endif    {      mng_imagep     pImage;      mng_imagedatap pBuf;      if (pData->bHasDHDR)             /* update delta image ? */      {                                /* store it in object 0 ! */        pImage = (mng_imagep)pData->pObjzero;        pBuf = pImage->pImgbuf;        /* address object buffer */        pBuf->bHasCHRM = MNG_TRUE;     /* and tell it it's got a CHRM now */                                       /* store for color-processing routines */        pBuf->iWhitepointx   = iWhitepointx;        pBuf->iWhitepointy   = iWhitepointy;        pBuf->iPrimaryredx   = iPrimaryredx;        pBuf->iPrimaryredy   = iPrimaryredy;        pBuf->iPrimarygreenx = iPrimarygreenx;        pBuf->iPrimarygreeny = iPrimarygreeny;        pBuf->iPrimarybluex  = iPrimarybluex;        pBuf->iPrimarybluey  = iPrimarybluey;      }      else      {        pImage = (mng_imagep)pData->pCurrentobj;        if (!pImage)                   /* no object then dump it in obj 0 */          pImage = (mng_imagep)pData->pObjzero;        pBuf = pImage->pImgbuf;        /* address object buffer */        pBuf->bHasCHRM = MNG_TRUE;     /* and tell it it's got a CHRM now */                                       /* store for color-processing routines */        pBuf->iWhitepointx   = iWhitepointx;        pBuf->iWhitepointy   = iWhitepointy;        pBuf->iPrimaryredx   = iPrimaryredx;        pBuf->iPrimaryredy   = iPrimaryredy;        pBuf->iPrimarygreenx = iPrimarygreenx;        pBuf->iPrimarygreeny = iPrimarygreeny;        pBuf->iPrimarybluex  = iPrimarybluex;        pBuf->iPrimarybluey  = iPrimarybluey;      }    }    else    {                                  /* store as global */      if (iRawlen != 0)      {        pData->iGlobalWhitepointx   = iWhitepointx;        pData->iGlobalWhitepointy   = iWhitepointy;        pData->iGlobalPrimaryredx   = iPrimaryredx;        pData->iGlobalPrimaryredy   = iPrimaryredy;        pData->iGlobalPrimarygreenx = iPrimarygreenx;        pData->iGlobalPrimarygreeny = iPrimarygreeny;        pData->iGlobalPrimarybluex  = iPrimarybluex;        pData->iGlobalPrimarybluey  = iPrimarybluey;      }      {                                /* create an animation object */        mng_retcode iRetcode = create_ani_chrm (pData, (mng_bool)(iRawlen == 0),                                                iWhitepointx,   iWhitepointy,                                                iPrimaryredx,   iPrimaryredy,                                                iPrimarygreenx, iPrimarygreeny,                                                iPrimarybluex,  iPrimarybluey);        if (iRetcode)                  /* on error bail out */          return iRetcode;      }    }  }#endif /* MNG_SUPPORT_DISPLAY */#ifdef MNG_STORE_CHUNKS  if (pData->bStorechunks)  {                                    /* initialize storage */    mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk);    if (iRetcode)                      /* on error bail out */      return iRetcode;                                       /* store the fields */    ((mng_chrmp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0);    if (iRawlen)    {      ((mng_chrmp)*ppChunk)->iWhitepointx = mng_get_uint32 (pRawdata);      ((mng_chrmp)*ppChunk)->iWhitepointy = mng_get_uint32 (pRawdata+4);      ((mng_chrmp)*ppChunk)->iRedx        = mng_get_uint32 (pRawdata+8);      ((mng_chrmp)*ppChunk)->iRedy        = mng_get_uint32 (pRawdata+12);      ((mng_chrmp)*ppChunk)->iGreenx      = mng_get_uint32 (pRawdata+16);      ((mng_chrmp)*ppChunk)->iGreeny      = mng_get_uint32 (pRawdata+20);      ((mng_chrmp)*ppChunk)->iBluex       = mng_get_uint32 (pRawdata+24);      ((mng_chrmp)*ppChunk)->iBluey       = mng_get_uint32 (pRawdata+28);    }    }#endif /* MNG_STORE_CHUNKS */#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_READ_CHRM, MNG_LC_END)#endif  return MNG_NOERROR;                  /* done */}