📄 libmng_object_prc.c
字号:
{
if (iLocationtype == 0) /* absolute position ? */
{
pNew->iPosx = iLocationx;
pNew->iPosy = iLocationy;
}
else /* relative */
{
pNew->iPosx = pSource->iPosx + iLocationx;
pNew->iPosy = pSource->iPosy + iLocationy;
}
}
else /* copy from source */
{
pNew->iPosx = pSource->iPosx;
pNew->iPosy = pSource->iPosy;
}
/* copy clipping info */
pNew->bClipped = pSource->bClipped;
pNew->iClipl = pSource->iClipl;
pNew->iClipr = pSource->iClipr;
pNew->iClipt = pSource->iClipt;
pNew->iClipb = pSource->iClipb;
#ifndef MNG_SKIPCHUNK_MAGN
/* copy magnification info */
/* pNew->iMAGN_MethodX = pSource->iMAGN_MethodX; LET'S NOT !!!!!!
pNew->iMAGN_MethodY = pSource->iMAGN_MethodY;
pNew->iMAGN_MX = pSource->iMAGN_MX;
pNew->iMAGN_MY = pSource->iMAGN_MY;
pNew->iMAGN_ML = pSource->iMAGN_ML;
pNew->iMAGN_MR = pSource->iMAGN_MR;
pNew->iMAGN_MT = pSource->iMAGN_MT;
pNew->iMAGN_MB = pSource->iMAGN_MB; */
#endif
#ifndef MNG_SKIPCHUNK_PAST
pNew->iPastx = 0; /* initialize PAST info */
pNew->iPasty = 0;
#endif
if (iId) /* not for object 0 */
{ /* find previous lower object-id */
pPrev = (mng_imagep)pData->pLastimgobj;
while ((pPrev) && (pPrev->iId > iId))
pPrev = (mng_imagep)pPrev->sHeader.pPrev;
if (pPrev) /* found it ? */
{
pNew->sHeader.pPrev = pPrev; /* than link it in place */
pNew->sHeader.pNext = pPrev->sHeader.pNext;
pPrev->sHeader.pNext = pNew;
}
else /* if not found, it becomes the first ! */
{
pNew->sHeader.pNext = pData->pFirstimgobj;
pData->pFirstimgobj = pNew;
}
pNext = (mng_imagep)pNew->sHeader.pNext;
if (pNext)
pNext->sHeader.pPrev = pNew;
else
pData->pLastimgobj = pNew;
}
if (bPartial) /* partial clone ? */
{
pNew->pImgbuf = pSource->pImgbuf; /* use the same object buffer */
pNew->pImgbuf->iRefcount++; /* and increase the reference count */
}
else /* create a full clone ! */
{
mng_bool bConcrete = MNG_FALSE; /* it's abstract by default (?) */
if (!bAbstract) /* determine concreteness from source ? */
bConcrete = pSource->pImgbuf->bConcrete;
/* create a full clone ! */
iRetcode = mng_clone_imagedataobject (pData, bConcrete, pSource->pImgbuf, &pImgbuf);
if (iRetcode) /* on error bail out */
{
MNG_FREEX (pData, pNew, sizeof (mng_image))
return iRetcode;
}
pNew->pImgbuf = pImgbuf; /* and remember it */
}
*ppClone = pNew; /* return it */
#ifdef MNG_SUPPORT_TRACE
MNG_TRACE (pData, MNG_FN_CLONE_IMGOBJECT, MNG_LC_END)
#endif
return MNG_NOERROR;
}
/* ************************************************************************** */
mng_retcode mng_renum_imageobject (mng_datap pData,
mng_imagep pSource,
mng_uint16 iId,
mng_bool bVisible,
mng_bool bAbstract,
mng_bool bHasloca,
mng_uint8 iLocationtype,
mng_int32 iLocationx,
mng_int32 iLocationy)
{
mng_imagep pPrev, pNext;
#ifdef MNG_SUPPORT_TRACE
MNG_TRACE (pData, MNG_FN_RENUM_IMGOBJECT, MNG_LC_START)
#endif
pSource->bVisible = bVisible; /* store the new visibility */
if (bHasloca) /* location info available ? */
{
if (iLocationtype == 0) /* absolute position ? */
{
pSource->iPosx = iLocationx;
pSource->iPosy = iLocationy;
}
else /* relative */
{
pSource->iPosx = pSource->iPosx + iLocationx;
pSource->iPosy = pSource->iPosy + iLocationy;
}
}
if (iId) /* not for object 0 */
{ /* find previous lower object-id */
pPrev = (mng_imagep)pData->pLastimgobj;
while ((pPrev) && (pPrev->iId > iId))
pPrev = (mng_imagep)pPrev->sHeader.pPrev;
/* different from current ? */
if (pPrev != (mng_imagep)pSource->sHeader.pPrev)
{
if (pSource->sHeader.pPrev) /* unlink from current position !! */
((mng_imagep)pSource->sHeader.pPrev)->sHeader.pNext = pSource->sHeader.pNext;
else
pData->pFirstimgobj = pSource->sHeader.pNext;
if (pSource->sHeader.pNext)
((mng_imagep)pSource->sHeader.pNext)->sHeader.pPrev = pSource->sHeader.pPrev;
else
pData->pLastimgobj = pSource->sHeader.pPrev;
if (pPrev) /* found the previous ? */
{ /* than link it in place */
pSource->sHeader.pPrev = pPrev;
pSource->sHeader.pNext = pPrev->sHeader.pNext;
pPrev->sHeader.pNext = pSource;
}
else /* if not found, it becomes the first ! */
{
pSource->sHeader.pNext = pData->pFirstimgobj;
pData->pFirstimgobj = pSource;
}
pNext = (mng_imagep)pSource->sHeader.pNext;
if (pNext)
pNext->sHeader.pPrev = pSource;
else
pData->pLastimgobj = pSource;
}
}
pSource->iId = iId; /* now set the new id! */
if (bAbstract) /* force it to abstract ? */
pSource->pImgbuf->bConcrete = MNG_FALSE;
#ifdef MNG_SUPPORT_TRACE
MNG_TRACE (pData, MNG_FN_RENUM_IMGOBJECT, MNG_LC_END)
#endif
return MNG_NOERROR;
}
/* ************************************************************************** */
mng_retcode mng_reset_object_details (mng_datap pData,
mng_imagep pImage,
mng_uint32 iWidth,
mng_uint32 iHeight,
mng_uint8 iBitdepth,
mng_uint8 iColortype,
mng_uint8 iCompression,
mng_uint8 iFilter,
mng_uint8 iInterlace,
mng_bool bResetall)
{
mng_imagedatap pBuf = pImage->pImgbuf;
mng_uint32 iSamplesize = 0;
mng_uint32 iRowsize;
mng_uint32 iImgdatasize;
#ifdef MNG_SUPPORT_TRACE
MNG_TRACE (pData, MNG_FN_RESET_OBJECTDETAILS, MNG_LC_START)
#endif
pBuf->iWidth = iWidth; /* set buffer characteristics */
pBuf->iHeight = iHeight;
pBuf->iBitdepth = iBitdepth;
pBuf->iColortype = iColortype;
pBuf->iCompression = iCompression;
pBuf->iFilter = iFilter;
pBuf->iInterlace = iInterlace;
pBuf->bCorrected = MNG_FALSE;
pBuf->iAlphabitdepth = 0;
/* determine samplesize from color_type/bit_depth */
switch (iColortype) /* for < 8-bit samples we just reserve 8 bits */
{
case 0 : ; /* gray */
case 8 : { /* JPEG gray */
#ifndef MNG_NO_16BIT_SUPPORT
if (iBitdepth > 8)
iSamplesize = 2;
else
#endif
iSamplesize = 1;
break;
}
case 2 : ; /* rgb */
case 10 : { /* JPEG rgb */
#ifndef MNG_NO_16BIT_SUPPORT
if (iBitdepth > 8)
iSamplesize = 6;
else
#endif
iSamplesize = 3;
break;
}
case 3 : { /* indexed */
iSamplesize = 1;
break;
}
case 4 : ; /* gray+alpha */
case 12 : { /* JPEG gray+alpha */
#ifndef MNG_NO_16BIT_SUPPORT
if (iBitdepth > 8)
iSamplesize = 4;
else
#endif
iSamplesize = 2;
break;
}
case 6 : ; /* rgb+alpha */
case 14 : { /* JPEG rgb+alpha */
#ifndef MNG_NO_16BIT_SUPPORT
if (iBitdepth > 8)
iSamplesize = 8;
else
#endif
iSamplesize = 4;
break;
}
}
iRowsize = iSamplesize * iWidth;
iImgdatasize = iRowsize * iHeight;
/* buffer size changed ? */
if (iImgdatasize != pBuf->iImgdatasize)
{ /* drop the old one */
MNG_FREE (pData, pBuf->pImgdata, pBuf->iImgdatasize)
if (iImgdatasize) /* allocate new sample-buffer ? */
MNG_ALLOC (pData, pBuf->pImgdata, iImgdatasize)
}
else
{
if (iImgdatasize) /* clear old buffer */
{
mng_uint8p pTemp = pBuf->pImgdata;
mng_uint32 iX;
for (iX = 0; iX < (iImgdatasize & (mng_uint32)(~3L)); iX += 4)
{
*((mng_uint32p)pTemp) = 0x00000000l;
pTemp += 4;
}
while (pTemp < (pBuf->pImgdata + iImgdatasize))
{
*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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -