if (pBufdelta->bHasPLTE)
if ((pData->bRunning) && (!pData->bFreezing))
mng_retcode execute_delta_image (mng_datap  pData,                                 mng_imagep pTarget,                                 mng_imagep pDelta){  mng_imagedatap pBuftarget = pTarget->pImgbuf;  mng_imagedatap pBufdelta  = pDelta->pImgbuf;#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_EXECUTE_DELTA_IMAGE, MNG_LC_START)#endif  if (pBufdelta->bHasPLTE)             /* palette in delta ? */  {    mng_uint32 iX;                                       /* new palette larger than old one ? */    if ((!pBuftarget->bHasPLTE) || (pBuftarget->iPLTEcount < pBufdelta->iPLTEcount))      pBuftarget->iPLTEcount = pBufdelta->iPLTEcount;                                       /* it's definitely got a PLTE now */    pBuftarget->bHasPLTE = MNG_TRUE;    for (iX = 0; iX < pBufdelta->iPLTEcount; iX++)    {      pBuftarget->aPLTEentries[iX].iRed   = pBufdelta->aPLTEentries[iX].iRed;      pBuftarget->aPLTEentries[iX].iGreen = pBufdelta->aPLTEentries[iX].iGreen;      pBuftarget->aPLTEentries[iX].iBlue  = pBufdelta->aPLTEentries[iX].iBlue;    }  }  if (pBufdelta->bHasTRNS)             /* cheap transparency in delta ? */  {    switch (pData->iColortype)         /* drop it into the target */    {      case 0: {                        /* gray */                pBuftarget->iTRNSgray  = pBufdelta->iTRNSgray;                pBuftarget->iTRNSred   = 0;                pBuftarget->iTRNSgreen = 0;                pBuftarget->iTRNSblue  = 0;                pBuftarget->iTRNScount = 0;                break;              }      case 2: {                        /* rgb */                pBuftarget->iTRNSgray  = 0;                pBuftarget->iTRNSred   = pBufdelta->iTRNSred;                pBuftarget->iTRNSgreen = pBufdelta->iTRNSgreen;                pBuftarget->iTRNSblue  = pBufdelta->iTRNSblue;                pBuftarget->iTRNScount = 0;                break;              }      case 3: {                        /* indexed */                pBuftarget->iTRNSgray  = 0;                pBuftarget->iTRNSred   = 0;                pBuftarget->iTRNSgreen = 0;                pBuftarget->iTRNSblue  = 0;                                       /* existing range smaller than new one ? */                if ((!pBuftarget->bHasTRNS) || (pBuftarget->iTRNScount < pBufdelta->iTRNScount))                  pBuftarget->iTRNScount = pBufdelta->iTRNScount;                MNG_COPY (pBuftarget->aTRNSentries, pBufdelta->aTRNSentries, pBufdelta->iTRNScount)                break;              }    }    pBuftarget->bHasTRNS = MNG_TRUE;   /* tell it it's got a tRNS now */  }    /* TODO: copy bKGD (if it exists!) */  if (pBufdelta->bHasGAMA)             /* gamma in source ? */  {    pBuftarget->bHasGAMA = MNG_TRUE;   /* drop it onto the target */    pBuftarget->iGamma   = pBufdelta->iGamma;  }  if (pBufdelta->bHasCHRM)             /* chroma in delta ? */  {                                    /* drop it onto the target */    pBuftarget->bHasCHRM       = MNG_TRUE;    pBuftarget->iWhitepointx   = pBufdelta->iWhitepointx;    pBuftarget->iWhitepointy   = pBufdelta->iWhitepointy;    pBuftarget->iPrimaryredx   = pBufdelta->iPrimaryredx;    pBuftarget->iPrimaryredy   = pBufdelta->iPrimaryredy;    pBuftarget->iPrimarygreenx = pBufdelta->iPrimarygreenx;    pBuftarget->iPrimarygreeny = pBufdelta->iPrimarygreeny;    pBuftarget->iPrimarybluex  = pBufdelta->iPrimarybluex;    pBuftarget->iPrimarybluey  = pBufdelta->iPrimarybluey;  }  if (pBufdelta->bHasSRGB)             /* sRGB in delta ? */  {                                    /* drop it onto the target */    pBuftarget->bHasSRGB         = MNG_TRUE;    pBuftarget->iRenderingintent = pBufdelta->iRenderingintent;  }  if (pBufdelta->bHasICCP)             /* ICC profile in delta ? */  {    pBuftarget->bHasICCP = MNG_TRUE;   /* drop it onto the target */    if (pBuftarget->pProfile)          /* profile existed ? */      MNG_FREEX (pData, pBuftarget->pProfile, pBuftarget->iProfilesize)                                       /* allocate a buffer & copy it */    MNG_ALLOC (pData, pBuftarget->pProfile, pBufdelta->iProfilesize)    MNG_COPY  (pBuftarget->pProfile, pBufdelta->pProfile, pBufdelta->iProfilesize)                                       /* store it's length as well */    pBuftarget->iProfilesize = pBufdelta->iProfilesize;  }  if (!pData->bDeltaimmediate)         /* need to execute delta pixels ? */  {    /* TODO: execute delta pixels (if they exist!) */  }  #ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_EXECUTE_DELTA_IMAGE, MNG_LC_END)#endif  return MNG_NOERROR;}