📄 libmng_object_prc.c
字号:
*pTemp = 0; pTemp++; } } } pBuf->iSamplesize = iSamplesize; /* remember new sizes */ pBuf->iRowsize = iRowsize; pBuf->iImgdatasize = iImgdatasize; if (!pBuf->iPixelsampledepth) /* set delta sampledepths if empty */ pBuf->iPixelsampledepth = iBitdepth; if (!pBuf->iAlphasampledepth) pBuf->iAlphasampledepth = iBitdepth; /* dimension set and clipping not ? */ if ((iWidth) && (iHeight) && (!pImage->bClipped)) { pImage->iClipl = 0; /* set clipping to dimension by default */ pImage->iClipr = iWidth; pImage->iClipt = 0; pImage->iClipb = iHeight; }#ifndef MNG_SKIPCHUNK_MAGN if (pImage->iId) /* reset magnification info ? */ { pImage->iMAGN_MethodX = 0; pImage->iMAGN_MethodY = 0; pImage->iMAGN_MX = 0; pImage->iMAGN_MY = 0; pImage->iMAGN_ML = 0; pImage->iMAGN_MR = 0; pImage->iMAGN_MT = 0; pImage->iMAGN_MB = 0; }#endif if (bResetall) /* reset the other characteristics ? */ {#ifndef MNG_SKIPCHUNK_PAST pImage->iPastx = 0; pImage->iPasty = 0;#endif pBuf->bHasPLTE = MNG_FALSE; pBuf->bHasTRNS = MNG_FALSE; pBuf->bHasGAMA = pData->bHasglobalGAMA;#ifndef MNG_SKIPCHUNK_cHRM pBuf->bHasCHRM = pData->bHasglobalCHRM;#endif pBuf->bHasSRGB = pData->bHasglobalSRGB;#ifndef MNG_SKIPCHUNK_iCCP pBuf->bHasICCP = pData->bHasglobalICCP;#endif#ifndef MNG_SKIPCHUNK_bKGD pBuf->bHasBKGD = pData->bHasglobalBKGD;#endif#ifndef MNG_SKIPCHUNK_iCCP if (pBuf->iProfilesize) /* drop possibly old ICC profile */ { MNG_FREE (pData, pBuf->pProfile, pBuf->iProfilesize); pBuf->iProfilesize = 0; } #endif if (pData->bHasglobalGAMA) /* global gAMA present ? */ pBuf->iGamma = pData->iGlobalGamma;#ifndef MNG_SKIPCHUNK_cHRM if (pData->bHasglobalCHRM) /* global cHRM present ? */ { pBuf->iWhitepointx = pData->iGlobalWhitepointx; pBuf->iWhitepointy = pData->iGlobalWhitepointy; pBuf->iPrimaryredx = pData->iGlobalPrimaryredx; pBuf->iPrimaryredy = pData->iGlobalPrimaryredy; pBuf->iPrimarygreenx = pData->iGlobalPrimarygreenx; pBuf->iPrimarygreeny = pData->iGlobalPrimarygreeny; pBuf->iPrimarybluex = pData->iGlobalPrimarybluex; pBuf->iPrimarybluey = pData->iGlobalPrimarybluey; }#endif if (pData->bHasglobalSRGB) /* global sRGB present ? */ pBuf->iRenderingintent = pData->iGlobalRendintent;#ifndef MNG_SKIPCHUNK_iCCP if (pData->bHasglobalICCP) /* global iCCP present ? */ { if (pData->iGlobalProfilesize) { MNG_ALLOC (pData, pBuf->pProfile, pData->iGlobalProfilesize); MNG_COPY (pBuf->pProfile, pData->pGlobalProfile, pData->iGlobalProfilesize); } pBuf->iProfilesize = pData->iGlobalProfilesize; }#endif#ifndef MNG_SKIPCHUNK_bKGD if (pData->bHasglobalBKGD) /* global bKGD present ? */ { pBuf->iBKGDred = pData->iGlobalBKGDred; pBuf->iBKGDgreen = pData->iGlobalBKGDgreen; pBuf->iBKGDblue = pData->iGlobalBKGDblue; }#endif }#ifdef MNG_SUPPORT_TRACE MNG_TRACE (pData, MNG_FN_RESET_OBJECTDETAILS, MNG_LC_END);#endif return MNG_NOERROR;}/* ************************************************************************** */#if !defined(MNG_NO_DELTA_PNG) || !defined(MNG_SKIPCHUNK_PAST) || !defined(MNG_SKIPCHUNK_MAGN)mng_retcode mng_promote_imageobject (mng_datap pData, mng_imagep pImage, mng_uint8 iBitdepth, mng_uint8 iColortype, mng_uint8 iFilltype){ mng_retcode iRetcode = MNG_NOERROR; mng_imagedatap pBuf = pImage->pImgbuf; mng_uint32 iW = pBuf->iWidth; mng_uint32 iH = pBuf->iHeight; mng_uint8p pNewbuf; mng_uint32 iNewbufsize; mng_uint32 iNewrowsize; mng_uint32 iNewsamplesize = pBuf->iSamplesize; mng_uint32 iY; mng_uint8 iTempdepth;#ifdef MNG_SUPPORT_TRACE MNG_TRACE (pData, MNG_FN_PROMOTE_IMGOBJECT, MNG_LC_START);#endif#ifdef MNG_NO_1_2_4BIT_SUPPORT if (iBitdepth < 8) iBitdepth=8; if (pBuf->iBitdepth < 8) pBuf->iBitdepth=8;#endif#ifdef MNG_NO_16BIT_SUPPORT if (iBitdepth > 8) iBitdepth=8; if (pBuf->iBitdepth > 8) pBuf->iBitdepth=8;#endif pData->fPromoterow = MNG_NULL; /* init promotion fields */ pData->fPromBitdepth = MNG_NULL; pData->iPromColortype = iColortype; pData->iPromBitdepth = iBitdepth; pData->iPromFilltype = iFilltype; if (iBitdepth != pBuf->iBitdepth) /* determine bitdepth promotion */ { if (pBuf->iColortype == MNG_COLORTYPE_INDEXED) iTempdepth = 8; else iTempdepth = pBuf->iBitdepth;#ifndef MNG_NO_DELTA_PNG if (iFilltype == MNG_FILLMETHOD_ZEROFILL) { switch (iTempdepth) {#ifndef MNG_NO_1_2_4BIT_SUPPORT case 1 : { switch (iBitdepth) { case 2 : { pData->fPromBitdepth = (mng_fptr)mng_promote_zerofill_1_2; break; } case 4 : { pData->fPromBitdepth = (mng_fptr)mng_promote_zerofill_1_4; break; } case 8 : { pData->fPromBitdepth = (mng_fptr)mng_promote_zerofill_1_8; break; }#ifndef MNG_NO_16BIT_SUPPORT case 16 : { pData->fPromBitdepth = (mng_fptr)mng_promote_zerofill_1_16; break; }#endif } break; } case 2 : { switch (iBitdepth) { case 4 : { pData->fPromBitdepth = (mng_fptr)mng_promote_zerofill_2_4; break; } case 8 : { pData->fPromBitdepth = (mng_fptr)mng_promote_zerofill_2_8; break; }#ifndef MNG_NO_16BIT_SUPPORT case 16 : { pData->fPromBitdepth = (mng_fptr)mng_promote_zerofill_2_16; break; }#endif } break; } case 4 : { switch (iBitdepth) { case 8 : { pData->fPromBitdepth = (mng_fptr)mng_promote_zerofill_4_8; break; }#ifndef MNG_NO_16BIT_SUPPORT case 16 : { pData->fPromBitdepth = (mng_fptr)mng_promote_zerofill_4_16; break; }#endif } break; }#endif /* MNG_NO_1_2_4BIT_SUPPORT */ case 8 : {#ifndef MNG_NO_16BIT_SUPPORT if (iBitdepth == 16) pData->fPromBitdepth = (mng_fptr)mng_promote_zerofill_8_16;#endif break; } } } else#endif { switch (iTempdepth) {#ifndef MNG_NO_1_2_4BIT_SUPPORT case 1 : { switch (iBitdepth) { case 2 : { pData->fPromBitdepth = (mng_fptr)mng_promote_replicate_1_2; break; } case 4 : { pData->fPromBitdepth = (mng_fptr)mng_promote_replicate_1_4; break; } case 8 : { pData->fPromBitdepth = (mng_fptr)mng_promote_replicate_1_8; break; }#ifndef MNG_NO_16BIT_SUPPORT case 16 : { pData->fPromBitdepth = (mng_fptr)mng_promote_replicate_1_16; break; }#endif } break; } case 2 : { switch (iBitdepth) { case 4 : { pData->fPromBitdepth = (mng_fptr)mng_promote_replicate_2_4; break; } case 8 : { pData->fPromBitdepth = (mng_fptr)mng_promote_replicate_2_8; break; }#ifndef MNG_NO_16BIT_SUPPORT case 16 : { pData->fPromBitdepth = (mng_fptr)mng_promote_replicate_2_16; break; }#endif } break; } case 4 : { switch (iBitdepth) { case 8 : { pData->fPromBitdepth = (mng_fptr)mng_promote_replicate_4_8; break; }#ifndef MNG_NO_16BIT_SUPPORT case 16 : { pData->fPromBitdepth = (mng_fptr)mng_promote_replicate_4_16; break; }#endif } break; }#endif /* MNG_NO_1_2_4BIT_SUPPORT */ case 8 : {#ifndef MNG_NO_16BIT_SUPPORT if (iBitdepth == 16) pData->fPromBitdepth = (mng_fptr)mng_promote_replicate_8_16;#endif break; } } } } /* g -> g */ if ((pBuf->iColortype == MNG_COLORTYPE_GRAY) && (iColortype == MNG_COLORTYPE_GRAY)) { if (pBuf->iBitdepth <= 8) /* source <= 8 bits */ {#ifndef MNG_NO_16BIT_SUPPORT if (iBitdepth == 16) pData->fPromoterow = (mng_fptr)mng_promote_g8_g16; else#endif pData->fPromoterow = (mng_fptr)mng_promote_g8_g8; } iNewsamplesize = 1;#ifndef MNG_NO_16BIT_SUPPORT if (iBitdepth == 16) /* 16-bit wide ? */ iNewsamplesize = 2;#endif } else /* g -> ga */ if ((pBuf->iColortype == MNG_COLORTYPE_GRAY) && (iColortype == MNG_COLORTYPE_GRAYA)) { if (pBuf->iBitdepth <= 8) /* source <= 8 bits */ {#ifndef MNG_NO_16BIT_SUPPORT if (iBitdepth == 16) pData->fPromoterow = (mng_fptr)mng_promote_g8_ga16; else#endif pData->fPromoterow = (mng_fptr)mng_promote_g8_ga8; }#ifndef MNG_NO_16BIT_SUPPORT else /* source = 16 bits */ pData->fPromoterow = (mng_fptr)mng_promote_g16_ga16;#endif iNewsamplesize = 2;#ifndef MNG_NO_16BIT_SUPPORT if (iBitdepth == 16) /* 16-bit wide ? */ iNewsamplesize = 4;#endif } else /* g -> rgb */ if ((pBuf->iColortype == MNG_COLORTYPE_GRAY) && (iColortype == MNG_COLORTYPE_RGB)) { if (pBuf->iBitdepth <= 8) /* source <= 8 bits */ {#ifndef MNG_NO_16BIT_SUPPORT if (iBitdepth == 16) pData->fPromoterow = (mng_fptr)mng_promote_g8_rgb16; else#endif pData->fPromoterow = (mng_fptr)mng_promote_g8_rgb8; }#ifndef MNG_NO_16BIT_SUPPORT else /* source = 16 bits */ pData->fPromoterow = (mng_fptr)mng_promote_g16_rgb16;#endif iNewsamplesize = 3;#ifndef MNG_NO_16BIT_SUPPORT if (iBitdepth == 16) /* 16-bit wide ? */ iNewsamplesize = 6;#endif } else /* g -> rgba */ if ((pBuf->iColortype == MNG_COLORTYPE_GRAY) && (iColortype == MNG_COLORTYPE_RGBA)) { if (pBuf->iBitdepth <= 8) /* source <= 8 bits */ {#ifndef MNG_NO_16BIT_SUPPORT if (iBitdepth == 16) pData->fPromoterow = (mng_fptr)mng_promote_g8_rgba16; else#endif pData->fPromoterow = (mng_fptr)mng_promote_g8_rgba8; }#ifndef MNG_NO_16BIT_SUPPORT else /* source = 16 bits */ pData->fPromoterow = (mng_fptr)mng_promote_g16_rgba16;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -