MNG_ALLOC (pData, pNewbuf, iNewbufsize)  pSrcline = pBuf->pImgdata; pDstline = pNewbuf;  for (iY = 0; iY < iH; iY++) { for (iX = 0; iX < iW; iX++) { iB = *pSrcline;  if ((mng_uint32)iB < pBuf->iPLTEcount) { *pDstline     = pBuf->aPLTEentries [iB].iRed; *(pDstline+1) = pBuf->aPLTEentries [iB].iGreen; *(pDstline+2) = pBuf->aPLTEentries [iB].iBlue; }  pSrcline++; pDstline += 3; } }  MNG_FREEX (pData, pBuf->pImgdata, pBuf->iImgdatasize)  pBuf->iBitdepth    = iBitdepth; pBuf->iColortype   = iColortype; pBuf->iSamplesize  = iNewsamplesize; pBuf->iRowsize     = iNewrowsize; pBuf->iImgdatasize = iNewbufsize; pBuf->pImgdata     = pNewbuf; pBuf->bHasPLTE     = MNG_FALSE; pBuf->bHasTRNS     = MNG_FALSE; } else if ((pBuf->iColortype == 3) && (iColortype == 6)) {                                     iNewsamplesize = 4; iNewrowsize    = iW * iNewsamplesize; iNewbufsize    = iH * iNewrowsize;  MNG_ALLOC (pData, pNewbuf, iNewbufsize)  pSrcline = pBuf->pImgdata; pDstline = pNewbuf;  for (iY = 0; iY < iH; iY++) { for (iX = 0; iX < iW; iX++) { iB = *pSrcline;  if ((mng_uint32)iB < pBuf->iPLTEcount) { *pDstline       = pBuf->aPLTEentries [iB].iRed; *(pDstline+1)   = pBuf->aPLTEentries [iB].iGreen; *(pDstline+2)   = pBuf->aPLTEentries [iB].iBlue;  if ((mng_uint32)iB < pBuf->iTRNScount) *(pDstline+3) = pBuf->aTRNSentries [iB]; else *(pDstline+3) = 255; }  pSrcline++; pDstline += 4; } }  MNG_FREEX (pData, pBuf->pImgdata, pBuf->iImgdatasize)  pBuf->iBitdepth    = iBitdepth; pBuf->iColortype   = iColortype; pBuf->iSamplesize  = iNewsamplesize; pBuf->iRowsize     = iNewrowsize; pBuf->iImgdatasize = iNewbufsize; pBuf->pImgdata     = pNewbuf; pBuf->bHasPLTE     = MNG_FALSE; pBuf->bHasTRNS     = MNG_FALSE; } else {    }
mng_retcode promote_imageobject (mng_datap  pData,                                 mng_imagep pImage,                                 mng_uint8  iBitdepth,                                 mng_uint8  iColortype,                                 mng_uint8  iFilltype){#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_PROMOTE_IMGOBJECT, MNG_LC_START)#endif#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_PROMOTE_IMGOBJECT, MNG_LC_END)#endif  return MNG_NOERROR;}