pData->iFilterofs = 0;                 if (pData->iFilter & 0x40)            { switch (pData->iColortype) { case 0 : { if (pData->iBitdepth <= 8) pData->iFilterofs = 1; else pData->iFilterofs = 2;  break; } case 2 : { if (pData->iBitdepth <= 8) pData->iFilterofs = 3; else pData->iFilterofs = 6;  break; } case 3 : { pData->iFilterofs = 1; break; } case 4 : { if (pData->iBitdepth <= 8) pData->iFilterofs = 2; else pData->iFilterofs = 4;  break; } case 6 : { if (pData->iBitdepth <= 8) pData->iPixelofs  = 5; else pData->iFilterofs = 8;  break; } } }  if (pData->iFilter & 0x01)            pData->iPixelofs = pData->iFilterofs; else pData->iPixelofs = pData->iFilterofs + 1;
mng_retcode process_display_basi (mng_datap  pData,                                  mng_uint16 iRed,                                  mng_uint16 iGreen,                                  mng_uint16 iBlue,                                  mng_bool   bHasalpha,                                  mng_uint16 iAlpha,                                  mng_uint8  iViewable){                                      /* address the current "object" if any */  mng_imagep     pImage = (mng_imagep)pData->pCurrentobj;  mng_uint8p     pWork;  mng_uint32     iX;  mng_imagedatap pBuf;  mng_retcode    iRetcode;#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_BASI, MNG_LC_START)#endif  if (!pImage)                         /* or is it an "on-the-fly" image ? */    pImage = (mng_imagep)pData->pObjzero;                                       /* address the object-buffer */  pBuf               = pImage->pImgbuf;  pData->fDisplayrow = 0;              /* do nothing by default */  pData->fCorrectrow = 0;  pData->fStorerow   = 0;  pData->fProcessrow = 0;                                       /* set parms now that they're known */  iRetcode = reset_object_details (pData, pImage, pData->iDatawidth,                                   pData->iDataheight, pData->iBitdepth,                                   pData->iColortype, pData->iCompression,                                   pData->iFilter, pData->iInterlace, MNG_FALSE);  if (iRetcode)                        /* on error bail out */    return iRetcode;                                       /* save the viewable flag */  pImage->bViewable = (mng_bool)(iViewable == 1);  pBuf->bViewable   = pImage->bViewable;  pData->pStoreobj  = pImage;          /* let row-routines know which object */  pWork = pBuf->pImgdata;              /* fill the object-buffer with the specified                                          "color" sample */  switch (pData->iColortype)           /* depending on color_type & bit_depth */  {    case 0 : {                         /* gray */               if (pData->iBitdepth == 16)               {                 for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++)                 {                   mng_put_uint16 (pWork, iRed);                   pWork += 2;                 }               }               else               {                 for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++)                 {                   *pWork = (mng_uint8)iRed;                   pWork++;                 }               }                                       /* force tRNS ? */               if ((bHasalpha) && (!iAlpha))               {                 pBuf->bHasTRNS  = MNG_TRUE;                 pBuf->iTRNSgray = iRed;               }               break;             }    case 2 : {                         /* rgb */               if (pData->iBitdepth == 16)               {                 for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++)                 {                   mng_put_uint16 (pWork,   iRed  );                   mng_put_uint16 (pWork+2, iGreen);                   mng_put_uint16 (pWork+4, iBlue );                   pWork += 6;                 }               }               else               {                 for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++)                 {                   *pWork     = (mng_uint8)iRed;                   *(pWork+1) = (mng_uint8)iGreen;                   *(pWork+2) = (mng_uint8)iBlue;                   pWork += 3;                 }               }                                       /* force tRNS ? */               if ((bHasalpha) && (!iAlpha))               {                 pBuf->bHasTRNS   = MNG_TRUE;                 pBuf->iTRNSred   = iRed;                 pBuf->iTRNSgreen = iGreen;                 pBuf->iTRNSblue  = iBlue;               }               break;             }    case 3 : {                         /* indexed */               pBuf->bHasPLTE = MNG_TRUE;               switch (pData->iBitdepth)               {                 case 1  : { pBuf->iPLTEcount =   2; break; }                 case 2  : { pBuf->iPLTEcount =   4; break; }                 case 4  : { pBuf->iPLTEcount =  16; break; }                 case 8  : { pBuf->iPLTEcount = 256; break; }                 default : { pBuf->iPLTEcount =   1; break; }               }               pBuf->aPLTEentries [0].iRed   = (mng_uint8)iRed;               pBuf->aPLTEentries [0].iGreen = (mng_uint8)iGreen;               pBuf->aPLTEentries [0].iBlue  = (mng_uint8)iBlue;               for (iX = 1; iX < pBuf->iPLTEcount; iX++)               {                 pBuf->aPLTEentries [iX].iRed   = 0;                 pBuf->aPLTEentries [iX].iGreen = 0;                 pBuf->aPLTEentries [iX].iBlue  = 0;               }                                       /* force tRNS ? */               if ((bHasalpha) && (iAlpha < 255))               {                 pBuf->bHasTRNS         = MNG_TRUE;                 pBuf->iTRNScount       = 1;                 pBuf->aTRNSentries [0] = (mng_uint8)iAlpha;               }               break;             }    case 4 : {                         /* gray+alpha */               if (pData->iBitdepth == 16)               {                 for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++)                 {                   mng_put_uint16 (pWork,   iRed);                   mng_put_uint16 (pWork+2, iAlpha);                   pWork += 4;                 }               }               else               {                 for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++)                 {                   *pWork     = (mng_uint8)iRed;                   *(pWork+1) = (mng_uint8)iAlpha;                   pWork += 2;                 }               }               break;             }    case 6 : {                         /* rgb+alpha */               if (pData->iBitdepth == 16)               {                 for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++)                 {                   mng_put_uint16 (pWork,   iRed);                   mng_put_uint16 (pWork+2, iGreen);                   mng_put_uint16 (pWork+4, iBlue);                   mng_put_uint16 (pWork+6, iAlpha);                   pWork += 8;                 }               }               else               {                 for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++)                 {                   *pWork     = (mng_uint8)iRed;                   *(pWork+1) = (mng_uint8)iGreen;                   *(pWork+2) = (mng_uint8)iBlue;                   *(pWork+3) = (mng_uint8)iAlpha;                   pWork += 4;                 }               }               break;             }  }  switch (pData->iColortype)           /* determine row initialization routine */  {                                    /* just to accomodate IDAT if it arrives */    case 0 : {                         /* gray */               switch (pData->iBitdepth)               {                 case  1 : {                             if (!pData->iInterlace)                               pData->fInitrowproc = (mng_ptr)init_g1_ni;                             else                               pData->fInitrowproc = (mng_ptr)init_g1_i;                             break;                           }                 case  2 : {                             if (!pData->iInterlace)                               pData->fInitrowproc = (mng_ptr)init_g2_ni;                             else                               pData->fInitrowproc = (mng_ptr)init_g2_i;                             break;                           }                 case  4 : {                             if (!pData->iInterlace)                               pData->fInitrowproc = (mng_ptr)init_g4_ni;                             else                               pData->fInitrowproc = (mng_ptr)init_g4_i;                             break;                           }                 case  8 : {                             if (!pData->iInterlace)                               pData->fInitrowproc = (mng_ptr)init_g8_ni;                             else                               pData->fInitrowproc = (mng_ptr)init_g8_i;                             break;                           }                 case 16 : {                             if (!pData->iInterlace)                               pData->fInitrowproc = (mng_ptr)init_g16_ni;                             else                               pData->fInitrowproc = (mng_ptr)init_g16_i;                             break;                           }               }               break;             }    case 2 : {                         /* rgb */               switch (pData->iBitdepth)               {                 case  8 : {                             if (!pData->iInterlace)                               pData->fInitrowproc = (mng_ptr)init_rgb8_ni;                             else                               pData->fInitrowproc = (mng_ptr)init_rgb8_i;                             break;                           }                 case 16 : {                             if (!pData->iInterlace)                               pData->fInitrowproc = (mng_ptr)init_rgb16_ni;                             else                               pData->fInitrowproc = (mng_ptr)init_rgb16_i;                             break;                           }               }               break;             }    case 3 : {                         /* indexed */               switch (pData->iBitdepth)               {                 case  1 : {                             if (!pData->iInterlace)                               pData->fInitrowproc = (mng_ptr)init_idx1_ni;                             else                               pData->fInitrowproc = (mng_ptr)init_idx1_i;                             break;                           }                 case  2 : {                             if (!pData->iInterlace)                               pData->fInitrowproc = (mng_ptr)init_idx2_ni;                             else                               pData->fInitrowproc = (mng_ptr)init_idx2_i;                             break;                           }                 case  4 : {                             if (!pData->iInterlace)                               pData->fInitrowproc = (mng_ptr)init_idx4_ni;                             else                               pData->fInitrowproc = (mng_ptr)init_idx4_i;                             break;                           }                 case  8 : {                             if (!pData->iInterlace)                               pData->fInitrowproc = (mng_ptr)init_idx8_ni;                             else                               pData->fInitrowproc = (mng_ptr)init_idx8_i;                             break;                           }               }               break;             }    case 4 : {                         /* gray+alpha */               switch (pData->iBitdepth)               {                 case  8 : {                             if (!pData->iInterlace)                               pData->fInitrowproc = (mng_ptr)init_ga8_ni;                             else                               pData->fInitrowproc = (mng_ptr)init_ga8_i;                             break;                           }                 case 16 : {                             if (!pData->iInterlace)                               pData->fInitrowproc = (mng_ptr)init_ga16_ni;                             else                               pData->fInitrowproc = (mng_ptr)init_ga16_i;                             break;                           }               }               break;             }    case 6 : {                         /* rgb+alpha */               switch (pData->iBitdepth)               {                 case  8 : {                             if (!pData->iInterlace)                               pData->fInitrowproc = (mng_ptr)init_rgba8_ni;                             else                               pData->fInitrowproc = (mng_ptr)init_rgba8_i;                             break;                           }                 case 16 : {                             if (!pData->iInterlace)                               pData->fInitrowproc = (mng_ptr)init_rgba16_ni;                             else                               pData->fInitrowproc = (mng_ptr)init_rgba16_i;                             break;                           }               }               break;             }  }#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_BASI, MNG_LC_END)#endif  return MNG_NOERROR;}