📄 libmng_object_prc.c
字号:
if (iBitdepth == 16)
iNewsamplesize = 6;
#endif
}
else /* rgb -> rgba */
if ((pBuf->iColortype == MNG_COLORTYPE_RGB) &&
(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_rgb8_rgba16;
else
#endif
pData->fPromoterow = (mng_fptr)mng_promote_rgb8_rgba8;
}
#ifndef MNG_NO_16BIT_SUPPORT
else /* source = 16 bits */
pData->fPromoterow = (mng_fptr)mng_promote_rgb16_rgba16;
#endif
iNewsamplesize = 4;
#ifndef MNG_NO_16BIT_SUPPORT
if (iBitdepth == 16) /* 16-bit wide ? */
iNewsamplesize = 8;
#endif
}
else /* indexed -> rgb */
if ((pBuf->iColortype == MNG_COLORTYPE_INDEXED) &&
(iColortype == MNG_COLORTYPE_RGB))
{
#ifndef MNG_NO_16BIT_SUPPORT
if (iBitdepth == 16)
pData->fPromoterow = (mng_fptr)mng_promote_idx8_rgb16;
else
#endif
pData->fPromoterow = (mng_fptr)mng_promote_idx8_rgb8;
iNewsamplesize = 3;
#ifndef MNG_NO_16BIT_SUPPORT
if (iBitdepth == 16) /* 16-bit wide ? */
iNewsamplesize = 6;
#endif
}
else /* indexed -> rgba */
if ((pBuf->iColortype == MNG_COLORTYPE_INDEXED) &&
(iColortype == MNG_COLORTYPE_RGBA))
{
#ifndef MNG_NO_16BIT_SUPPORT
if (iBitdepth == 16)
pData->fPromoterow = (mng_fptr)mng_promote_idx8_rgba16;
else
#endif
pData->fPromoterow = (mng_fptr)mng_promote_idx8_rgba8;
iNewsamplesize = 4;
#ifndef MNG_NO_16BIT_SUPPORT
if (iBitdepth == 16) /* 16-bit wide ? */
iNewsamplesize = 8;
#endif
}
else /* rgba -> rgba */
if ((pBuf->iColortype == MNG_COLORTYPE_RGBA) &&
(iColortype == MNG_COLORTYPE_RGBA))
{
iNewsamplesize = 4;
#ifndef MNG_NO_16BIT_SUPPORT
if (pBuf->iBitdepth <= 8) /* source <= 8 bits */
{
if (iBitdepth == 16)
pData->fPromoterow = (mng_fptr)mng_promote_rgba8_rgba16;
}
if (iBitdepth == 16) /* 16-bit wide ? */
iNewsamplesize = 8;
#endif
}
#ifdef MNG_INCLUDE_JNG
else /* JPEG g -> g */
if ((pBuf->iColortype == MNG_COLORTYPE_JPEGGRAY) &&
(iColortype == MNG_COLORTYPE_JPEGGRAY))
{
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 /* JPEG g -> ga */
if ((pBuf->iColortype == MNG_COLORTYPE_JPEGGRAY) &&
(iColortype == MNG_COLORTYPE_JPEGGRAYA))
{
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 /* JPEG g -> rgb */
if ((pBuf->iColortype == MNG_COLORTYPE_JPEGGRAY) &&
(iColortype == MNG_COLORTYPE_JPEGCOLOR))
{
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 /* JPEG g -> rgba */
if ((pBuf->iColortype == MNG_COLORTYPE_JPEGGRAY) &&
(iColortype == MNG_COLORTYPE_JPEGCOLORA))
{
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;
#endif
iNewsamplesize = 4;
#ifndef MNG_NO_16BIT_SUPPORT
if (iBitdepth == 16) /* 16-bit wide ? */
iNewsamplesize = 8;
#endif
}
else /* JPEG ga -> ga */
if ((pBuf->iColortype == MNG_COLORTYPE_JPEGGRAYA) &&
(iColortype == MNG_COLORTYPE_JPEGGRAYA))
{
iNewsamplesize = 2;
#ifndef MNG_NO_16BIT_SUPPORT
if (pBuf->iBitdepth <= 8) /* source <= 8 bits */
if (iBitdepth == 16)
pData->fPromoterow = (mng_fptr)mng_promote_ga8_ga16;
if (iBitdepth == 16)
iNewsamplesize = 4;
#endif
}
else /* JPEG ga -> rgba */
if ((pBuf->iColortype == MNG_COLORTYPE_JPEGGRAYA) &&
(iColortype == MNG_COLORTYPE_JPEGCOLORA))
{
if (pBuf->iBitdepth <= 8) /* source <= 8 bits */
{
#ifndef MNG_NO_16BIT_SUPPORT
if (iBitdepth == 16)
pData->fPromoterow = (mng_fptr)mng_promote_ga8_rgba16;
else
#endif
pData->fPromoterow = (mng_fptr)mng_promote_ga8_rgba8;
}
#ifndef MNG_NO_16BIT_SUPPORT
else /* source = 16 bits */
pData->fPromoterow = (mng_fptr)mng_promote_ga16_rgba16;
#endif
iNewsamplesize = 4;
#ifndef MNG_NO_16BIT_SUPPORT
if (iBitdepth == 16) /* 16-bit wide ? */
iNewsamplesize = 8;
#endif
}
else /* JPEG rgb -> rgb */
if ((pBuf->iColortype == MNG_COLORTYPE_JPEGCOLOR) &&
(iColortype == MNG_COLORTYPE_JPEGCOLOR))
{
iNewsamplesize = 3;
#ifndef MNG_NO_16BIT_SUPPORT
if (pBuf->iBitdepth <= 8) /* source <= 8 bits */
if (iBitdepth == 16)
pData->fPromoterow = (mng_fptr)mng_promote_rgb8_rgb16;
if (iBitdepth == 16)
iNewsamplesize = 6;
#endif
}
else /* JPEG rgb -> rgba */
if ((pBuf->iColortype == MNG_COLORTYPE_JPEGCOLOR) &&
(iColortype == MNG_COLORTYPE_JPEGCOLORA))
{
if (pBuf->iBitdepth <= 8) /* source <= 8 bits */
{
#ifndef MNG_NO_16BIT_SUPPORT
if (iBitdepth == 16)
pData->fPromoterow = (mng_fptr)mng_promote_rgb8_rgba16;
else
#endif
pData->fPromoterow = (mng_fptr)mng_promote_rgb8_rgba8;
}
#ifndef MNG_NO_16BIT_SUPPORT
else /* source = 16 bits */
pData->fPromoterow = (mng_fptr)mng_promote_rgb16_rgba16;
#endif
iNewsamplesize = 4;
#ifndef MNG_NO_16BIT_SUPPORT
if (iBitdepth == 16) /* 16-bit wide ? */
iNewsamplesize = 8;
#endif
}
else /* JPEG rgba -> rgba */
if ((pBuf->iColortype == MNG_COLORTYPE_JPEGCOLORA) &&
(iColortype == MNG_COLORTYPE_JPEGCOLORA))
{
iNewsamplesize = 4;
#ifndef MNG_NO_16BIT_SUPPORT
if (pBuf->iBitdepth <= 8) /* source <= 8 bits */
if (iBitdepth == 16)
pData->fPromoterow = (mng_fptr)mng_promote_rgba8_rgba16;
if (iBitdepth == 16)
iNewsamplesize = 8;
#endif
}
#endif /* JNG */
/* found a proper promotion ? */
if (pData->fPromoterow)
{
pData->pPromBuf = (mng_ptr)pBuf;
pData->iPromWidth = pBuf->iWidth;
iNewrowsize = iW * iNewsamplesize;
iNewbufsize = iH * iNewrowsize;
MNG_ALLOC (pData, pNewbuf, iNewbufsize)
pData->pPromSrc = (mng_ptr)pBuf->pImgdata;
pData->pPromDst = (mng_ptr)pNewbuf;
iY = 0;
while ((!iRetcode) && (iY < iH))
{
iRetcode = ((mng_promoterow)pData->fPromoterow) (pData);
pData->pPromSrc = (mng_uint8p)pData->pPromSrc + pBuf->iRowsize;
pData->pPromDst = (mng_uint8p)pData->pPromDst + iNewrowsize;
/* pData->pPromSrc = (mng_ptr)((mng_uint32)pData->pPromSrc + pBuf->iRowsize); */
/* pData->pPromDst = (mng_ptr)((mng_uint32)pData->pPromDst + iNewrowsize); */
iY++;
}
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->iPLTEcount = 0;
pBuf->bHasTRNS = MNG_FALSE;
pBuf->iTRNScount = 0;
if (iRetcode) /* on error bail out */
return iRetcode;
}
#ifdef MNG_SUPPORT_TRACE
MNG_TRACE (pData, MNG_FN_PROMOTE_IMGOBJECT, MNG_LC_END)
#endif
return MNG_NOERROR;
}
#endif
/* ************************************************************************** */
#ifndef MNG_SKIPCHUNK_MAGN
mng_retcode mng_magnify_imageobject (mng_datap pData,
mng_imagep pImage)
{
mng_uint8p pNewdata;
mng_uint8p pSrcline1;
mng_uint8p pSrcline2;
mng_uint8p pTempline;
mng_uint8p pDstline;
mng_uint32 iNewrowsize;
mng_uint32 iNewsize;
mng_uint32 iY;
mng_int32 iS, iM;
mng_retcode iRetcode;
mng_imagedatap pBuf = pImage->pImgbuf;
mng_uint32 iNewW = pBuf->iWidth;
mng_uint32 iNewH = pBuf->iHeight;
mng_magnify_x fMagnifyX = MNG_NULL;
mng_magnify_y fMagnifyY = MNG_NULL;
#ifdef MNG_SUPPORT_TRACE
MNG_TRACE (pData, MNG_FN_MAGNIFY_IMGOBJECT, MNG_LC_START)
#endif
if (pBuf->iColortype == MNG_COLORTYPE_INDEXED)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -