pWorkrow = pData->pWorkrow + 1;
pWorkrow = pData->pWorkrow + pData->iPixelofs;
mng_retcode process_g2 (mng_datap pData){  mng_uint8p     pWorkrow;  mng_uint8p     pRGBArow;  mng_int32      iX;  mng_uint8      iB;  mng_uint8      iM;  mng_uint32     iS;  mng_uint8      iQ;  mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf;#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_PROCESS_G2, MNG_LC_START)#endif  if (!pBuf)                           /* no object? then use obj 0 */    pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf;  pWorkrow = pData->pWorkrow + 1;      /* temporary work pointers */  pRGBArow = pData->pRGBArow;  iM       = 0;                        /* start at pixel 0 */  iB       = 0;  iS       = 0;  if (pBuf->bHasTRNS)                  /* tRNS encountered ? */  {    for (iX = 0; iX < pData->iRowsamples; iX++)    {      if (!iM)                         /* mask underflow ? */      {        iB = *pWorkrow;                /* get next input-byte */        pWorkrow++;        iM = 0xC0;        iS = 6;      }                                       /* determine gray level */      iQ = (mng_uint8)((iB & iM) >> iS);      if (iQ == pBuf->iTRNSgray)       /* transparent ? */        mng_put_uint32 (pRGBArow, 0x00000000);      else      {        switch (iQ)                    /* determine the gray level */        {          case 0x03 : { mng_put_uint32 (pRGBArow, 0xFFFFFFFF); break; }          case 0x02 : { mng_put_uint32 (pRGBArow, 0xAAAAAAFF); break; }          case 0x01 : { mng_put_uint32 (pRGBArow, 0x555555FF); break; }          default   : { mng_put_uint32 (pRGBArow, 0x000000FF); }        }      }      pRGBArow += 4;                   /* next pixel */      iM >>= 2;      iS -= 2;    }    pData->bIsOpaque = MNG_FALSE;      /* it's not fully opaque */  }  else  {    for (iX = 0; iX < pData->iRowsamples; iX++)    {      if (!iM)                         /* mask underflow ? */      {        iB = *pWorkrow;                /* get next input-byte */        pWorkrow++;        iM = 0xC0;        iS = 6;      }      switch ((iB & iM) >> iS)         /* determine the gray level */      {        case 0x03 : { mng_put_uint32 (pRGBArow, 0xFFFFFFFF); break; }        case 0x02 : { mng_put_uint32 (pRGBArow, 0xAAAAAAFF); break; }        case 0x01 : { mng_put_uint32 (pRGBArow, 0x555555FF); break; }        default   : { mng_put_uint32 (pRGBArow, 0x000000FF); }      }      pRGBArow += 4;                   /* next pixel */      iM >>= 2;      iS -= 2;    }    pData->bIsOpaque = MNG_TRUE;       /* it's fully opaque */  }#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_PROCESS_G2, MNG_LC_END)#endif  return MNG_NOERROR;}