pData->fCorrectrow = 0;                   MNG_ALLOC (pData, pData->pRGBArow, pData->iRowsize)  iY       = pData->iDestt;           iRetcode = MNG_NOERROR;              while ((!iRetcode) && (iY < pData->iDestb)) {                                   iRetcode = ((mng_restbkgdrow)pData->fRestbkgdrow) (pData);  if ((!iRetcode) && (pData->fCorrectrow)) iRetcode = ((mng_correctrow)pData->fCorrectrow) (pData);  if (!iRetcode)                    iRetcode = ((mng_displayrow)pData->fDisplayrow) (pData);  if (!iRetcode) iRetcode = next_row (pData);     iY++;                             }  MNG_FREE (pData, pData->pRGBArow, pData->iRowsize)  if (iRetcode)                       return iRetcode;
pData->iDestl      = iDestl;        pData->iDestr      = iDestr; pData->iDestt      = iDestt; pData->iDestb      = iDestb; pData->iSourcel    = iSourcel; pData->iSourcer    = iSourcer; pData->iSourcet    = iSourcet; pData->iSourceb    = iSourceb; pData->iPass       = iPass; pData->iRow        = iRow; pData->iRowinc     = iRowinc; pData->iCol        = iCol; pData->iColinc     = iColinc; pData->iRowsamples = iRowsamples; pData->iRowsize    = iRowsize; pData->bIsRGBA16   = bIsRGBA16; pData->bIsOpaque   = bIsOpaque; pData->fCorrectrow = fCorrectrow;
mng_retcode load_bkgdlayer (mng_datap pData){  mng_int32   iY;  mng_retcode iRetcode;#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_LOAD_BKGDLAYER, MNG_LC_START)#endif  pData->iDestl   = 0;                 /* determine clipping region */  pData->iDestt   = 0;  pData->iDestr   = pData->iWidth;  pData->iDestb   = pData->iHeight;  if (pData->bFrameclipping)           /* frame clipping specified ? */  {    pData->iDestl = MAX_COORD (pData->iDestl,  pData->iFrameclipl);    pData->iDestt = MAX_COORD (pData->iDestt,  pData->iFrameclipt);    pData->iDestr = MIN_COORD (pData->iDestr,  pData->iFrameclipr);    pData->iDestb = MIN_COORD (pData->iDestb,  pData->iFrameclipb);  }                                       /* anything to clear ? */  if ((pData->iDestr >= pData->iDestl) && (pData->iDestb >= pData->iDestt))  {    pData->iPass       = -1;           /* these are the object's dimensions now */    pData->iRow        = 0;    pData->iRowinc     = 1;    pData->iCol        = 0;    pData->iColinc     = 1;    pData->iRowsamples = pData->iWidth;    pData->iRowsize    = pData->iRowsamples << 2;    pData->bIsRGBA16   = MNG_FALSE;    /* let's keep it simple ! */    pData->bIsOpaque   = MNG_TRUE;    pData->iSourcel    = 0;            /* source relative to destination */    pData->iSourcer    = pData->iDestr - pData->iDestl;    pData->iSourcet    = 0;    pData->iSourceb    = pData->iDestb - pData->iDestt;    set_display_routine (pData);       /* determine display routine */                                       /* default restore using preset BG color */    pData->fRestbkgdrow = (mng_ptr)restore_bkgd_bgcolor;    if (pData->fGetbkgdline)           /* background-canvas-access callback set ? */    {      switch (pData->iBkgdstyle)      {        case MNG_CANVAS_RGB8    : { pData->fRestbkgdrow = (mng_ptr)restore_bkgd_rgb8;    break; }        case MNG_CANVAS_BGR8    : { pData->fRestbkgdrow = (mng_ptr)restore_bkgd_bgr8;    break; }/*        case MNG_CANVAS_RGB16   : { pData->fRestbkgdrow = (mng_ptr)restore_bkgd_rgb16;   break; } *//*        case MNG_CANVAS_BGR16   : { pData->fRestbkgdrow = (mng_ptr)restore_bkgd_bgr16;   break; } *//*        case MNG_CANVAS_INDEX8  : { pData->fRestbkgdrow = (mng_ptr)restore_bkgd_index8;  break; } *//*        case MNG_CANVAS_GRAY8   : { pData->fRestbkgdrow = (mng_ptr)restore_bkgd_gray8;   break; } *//*        case MNG_CANVAS_GRAY16  : { pData->fRestbkgdrow = (mng_ptr)restore_bkgd_gray16;  break; } *//*        case MNG_CANVAS_DX15    : { pData->fRestbkgdrow = (mng_ptr)restore_bkgd_dx15;    break; } *//*        case MNG_CANVAS_DX16    : { pData->fRestbkgdrow = (mng_ptr)restore_bkgd_dx16;    break; } */      }    }    if (pData->bHasBACK)    {                                  /* background image ? */      if ((pData->iBACKmandatory & 0x02) && (pData->iBACKimageid))        pData->fRestbkgdrow = (mng_ptr)restore_bkgd_backimage;      else                             /* background color ? */      if (pData->iBACKmandatory & 0x01)        pData->fRestbkgdrow = (mng_ptr)restore_bkgd_backcolor;    }    pData->fCorrectrow = 0;            /* default no color-correction */    /* TODO: determine color correction; this is tricky;       the BACK color is treated differently as the image;       it probably requires a rewrite of the logic here... */                                       /* get a temporary row-buffer */    MNG_ALLOC (pData, pData->pRGBArow, pData->iRowsize)    iY       = pData->iDestt;          /* this is where we start */    iRetcode = MNG_NOERROR;            /* so far, so good */    while ((!iRetcode) && (iY < pData->iDestb))    {                                  /* restore a background row */      iRetcode = ((mng_restbkgdrow)pData->fRestbkgdrow) (pData);                                       /* color correction ? */      if ((!iRetcode) && (pData->fCorrectrow))        iRetcode = ((mng_correctrow)pData->fCorrectrow) (pData);      if (!iRetcode)                   /* so... display it */        iRetcode = ((mng_displayrow)pData->fDisplayrow) (pData);      if (!iRetcode)        iRetcode = next_row (pData);   /* adjust variables for next row */      iY++;                            /* and next line */    }                                       /* drop the temporary row-buffer */    MNG_FREE (pData, pData->pRGBArow, pData->iRowsize)    if (iRetcode)                      /* on error bail out */      return iRetcode;  }#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_LOAD_BKGDLAYER, MNG_LC_END)#endif  return MNG_NOERROR;}