if (pData->iJHDRalphacompression !=  MNG_COMPRESSION_DEFLATE)
if ((pData->iJHDRalphacompression != MNG_COMPRESSION_DEFLATE     ) && (pData->iJHDRalphacompression != MNG_COMPRESSION_BASELINEJPEG)    )
READ_CHUNK (read_jhdr){#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_READ_JHDR, MNG_LC_START)#endif                                       /* sequence checks */  if ((pData->eSigtype != mng_it_jng) && (pData->eSigtype != mng_it_mng))    MNG_ERROR (pData, MNG_CHUNKNOTALLOWED)  if ((pData->eSigtype == mng_it_jng) && (pData->iChunkseq > 1))    MNG_ERROR (pData, MNG_SEQUENCEERROR)  if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR))    MNG_ERROR (pData, MNG_SEQUENCEERROR)  if (iRawlen != 16)                   /* length oke ? */    MNG_ERROR (pData, MNG_INVALIDLENGTH)                                       /* inside a JHDR-IEND block now */  pData->bHasJHDR              = MNG_TRUE;                                       /* and store interesting fields */  pData->iDatawidth            = mng_get_uint32 (pRawdata);  pData->iDataheight           = mng_get_uint32 (pRawdata+4);  pData->iJHDRcolortype        = *(pRawdata+8);  pData->iJHDRimgbitdepth      = *(pRawdata+9);  pData->iJHDRimgcompression   = *(pRawdata+10);  pData->iJHDRimginterlace     = *(pRawdata+11);  pData->iJHDRalphabitdepth    = *(pRawdata+12);  pData->iJHDRalphacompression = *(pRawdata+13);  pData->iJHDRalphafilter      = *(pRawdata+14);  pData->iJHDRalphainterlace   = *(pRawdata+15);                                       /* parameter validity checks */  if ((pData->iJHDRcolortype != MNG_COLORTYPE_JPEGGRAY  ) &&      (pData->iJHDRcolortype != MNG_COLORTYPE_JPEGCOLOR ) &&      (pData->iJHDRcolortype != MNG_COLORTYPE_JPEGGRAYA ) &&      (pData->iJHDRcolortype != MNG_COLORTYPE_JPEGCOLORA)    )    MNG_ERROR (pData, MNG_INVALIDCOLORTYPE)  if ((pData->iJHDRimgbitdepth !=  8) &&      (pData->iJHDRimgbitdepth != 12) &&      (pData->iJHDRimgbitdepth != 20)    )    MNG_ERROR (pData, MNG_INVALIDBITDEPTH)  if (pData->iJHDRimgcompression !=  MNG_COMPRESSION_BASELINEJPEG)    MNG_ERROR (pData, MNG_INVALIDCOMPRESS)  if ((pData->iJHDRimginterlace !=  MNG_INTERLACE_SEQUENTIAL ) &&      (pData->iJHDRimginterlace !=  MNG_INTERLACE_PROGRESSIVE)    )    MNG_ERROR (pData, MNG_INVALIDINTERLACE)  if ((pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA ) ||      (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA)    )  {    if ((pData->iJHDRalphabitdepth !=  1) &&        (pData->iJHDRalphabitdepth !=  2) &&        (pData->iJHDRalphabitdepth !=  4) &&        (pData->iJHDRalphabitdepth !=  8) &&        (pData->iJHDRalphabitdepth != 16)    )      MNG_ERROR (pData, MNG_INVALIDBITDEPTH)    if (pData->iJHDRalphacompression !=  MNG_COMPRESSION_DEFLATE)      MNG_ERROR (pData, MNG_INVALIDCOMPRESS)    if (pData->iJHDRalphafilter !=  MNG_FILTER_ADAPTIVE)      MNG_ERROR (pData, MNG_INVALIDFILTER)    if ((pData->iJHDRalphainterlace !=  MNG_INTERLACE_NONE ) &&        (pData->iJHDRalphainterlace !=  MNG_INTERLACE_ADAM7)    )      MNG_ERROR (pData, MNG_INVALIDINTERLACE)  }  else  {    if (pData->iJHDRalphabitdepth    != 0)      MNG_ERROR (pData, MNG_INVALIDBITDEPTH)    if (pData->iJHDRalphacompression != 0)      MNG_ERROR (pData, MNG_INVALIDCOMPRESS)    if (pData->iJHDRalphafilter      != 0)      MNG_ERROR (pData, MNG_INVALIDFILTER)    if (pData->iJHDRalphainterlace   != 0)      MNG_ERROR (pData, MNG_INVALIDINTERLACE)        }  if (!pData->bHasheader)              /* first chunk ? */  {    pData->bHasheader = MNG_TRUE;      /* we've got a header */    pData->eImagetype = mng_it_jng;    /* then this must be a JNG */    pData->iWidth     = mng_get_uint32 (pRawdata);    pData->iHeight    = mng_get_uint32 (pRawdata+4);                                       /* fits on maximum canvas ? */    if ((pData->iWidth > pData->iMaxwidth) || (pData->iHeight > pData->iMaxheight))      MNG_WARNING (pData, MNG_IMAGETOOLARGE)    if (pData->fProcessheader)         /* inform the app ? */      if (!pData->fProcessheader (((mng_handle)pData), pData->iWidth, pData->iHeight))      MNG_ERROR (pData, MNG_APPMISCERROR)  }  pData->iColortype = 0;               /* fake grayscale for other routines */  pData->iImagelevel++;                /* one level deeper */#ifdef MNG_SUPPORT_DISPLAY  {    mng_retcode iRetcode = process_display_jhdr (pData);    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_jhdrp)*ppChunk)->iWidth            = mng_get_uint32 (pRawdata);    ((mng_jhdrp)*ppChunk)->iHeight           = mng_get_uint32 (pRawdata+4);    ((mng_jhdrp)*ppChunk)->iColortype        = *(pRawdata+8);    ((mng_jhdrp)*ppChunk)->iImagesampledepth = *(pRawdata+9);    ((mng_jhdrp)*ppChunk)->iImagecompression = *(pRawdata+10);    ((mng_jhdrp)*ppChunk)->iImageinterlace   = *(pRawdata+11);    ((mng_jhdrp)*ppChunk)->iAlphasampledepth = *(pRawdata+12);    ((mng_jhdrp)*ppChunk)->iAlphacompression = *(pRawdata+13);    ((mng_jhdrp)*ppChunk)->iAlphafilter      = *(pRawdata+14);    ((mng_jhdrp)*ppChunk)->iAlphainterlace   = *(pRawdata+15);  }#endif /* MNG_STORE_CHUNKS */#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_READ_JHDR, MNG_LC_END)#endif  return MNG_NOERROR;                  /* done */}