⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libmng_chunk_xs.c

📁 奇趣公司比较新的qt/emd版本
💻 C
📖 第 1 页 / 共 5 页
字号:
/* ************************************************************************** *//* *             For conditions of distribution and use,                    * *//* *                see copyright notice in libmng.h                        * *//* ************************************************************************** *//* *                                                                        * *//* * project   : libmng                                                     * *//* * file      : libmng_chunk_xs.c         copyright (c) 2000-2004 G.Juyn   * *//* * version   : 1.0.9                                                      * *//* *                                                                        * *//* * purpose   : chunk access functions (implementation)                    * *//* *                                                                        * *//* * author    : G.Juyn                                                     * *//* *                                                                        * *//* * comment   : implementation of the chunk access functions               * *//* *                                                                        * *//* * changes   : 0.5.1 - 05/06/2000 - G.Juyn                                * *//* *             - changed and filled iterate-chunk function                * *//* *             0.5.1 - 05/08/2000 - G.Juyn                                * *//* *             - fixed calling convention                                 * *//* *             - added getchunk functions                                 * *//* *             - added putchunk functions                                 * *//* *             - changed strict-ANSI stuff                                * *//* *             0.5.1 - 05/11/2000 - G.Juyn                                * *//* *             - added empty-chunk put-routines                           * *//* *             0.5.1 - 05/12/2000 - G.Juyn                                * *//* *             - changed trace to macro for callback error-reporting      * *//* *             0.5.1 - 05/15/2000 - G.Juyn                                * *//* *             - added getimgdata & putimgdata functions                  * *//* *                                                                        * *//* *             0.5.2 - 05/19/2000 - G.Juyn                                * *//* *             - B004 - fixed problem with MNG_SUPPORT_WRITE not defined  * *//* *               also for MNG_SUPPORT_WRITE without MNG_INCLUDE_JNG       * *//* *             - Cleaned up some code regarding mixed support             * *//* *                                                                        * *//* *             0.9.1 - 07/19/2000 - G.Juyn                                * *//* *             - fixed creation-code                                      * *//* *                                                                        * *//* *             0.9.2 - 08/05/2000 - G.Juyn                                * *//* *             - changed file-prefixes                                    * *//* *             - added function to set simplicity field                   * *//* *             - fixed putchunk_unknown() function                        * *//* *                                                                        * *//* *             0.9.3 - 08/07/2000 - G.Juyn                                * *//* *             - B111300 - fixup for improved portability                 * *//* *             0.9.3 - 08/26/2000 - G.Juyn                                * *//* *             - added MAGN chunk                                         * *//* *             0.9.3 - 10/20/2000 - G.Juyn                                * *//* *             - fixed putchunk_plte() to set bEmpty parameter            * *//* *                                                                        * *//* *             0.9.5 - 01/25/2001 - G.Juyn                                * *//* *             - fixed some small compiler warnings (thanks Nikki)        * *//* *                                                                        * *//* *             1.0.5 - 09/07/2002 - G.Juyn                                * *//* *             - B578940 - unimplemented functions return errorcode       * *//* *             1.0.5 - 08/19/2002 - G.Juyn                                * *//* *             - B597134 - libmng pollutes the linker namespace           * *//* *             - added HLAPI function to copy chunks                      * *//* *             1.0.5 - 09/14/2002 - G.Juyn                                * *//* *             - added event handling for dynamic MNG                     * *//* *             1.0.5 - 10/07/2002 - G.Juyn                                * *//* *             - added check for TERM placement during create/write       * *//* *             1.0.5 - 11/28/2002 - G.Juyn                                * *//* *             - fixed definition of iMethodX/Y for MAGN chunk            * *//* *                                                                        * *//* *             1.0.6 - 05/25/2003 - G.R-P                                 * *//* *             - added MNG_SKIPCHUNK_cHNK footprint optimizations         * *//* *             1.0.6 - 07/07/2003 - G.R-P                                 * *//* *             - added MNG_NO_DELTA_PNG reduction and more SKIPCHUNK      * *//* *               optimizations                                            * *//* *             1.0.6 - 07/29/2003 - G.R-P                                 * *//* *             - added conditionals around PAST chunk support             * *//* *             1.0.6 - 08/17/2003 - G.R-P                                 * *//* *             - added conditionals around non-VLC chunk support          * *//* *                                                                        * *//* *             1.0.8 - 04/01/2004 - G.Juyn                                * *//* *             - added missing get-/put-chunk-jdaa                        * *//* *             1.0.8 - 08/02/2004 - G.Juyn                                * *//* *             - added conditional to allow easier writing of large MNG's * *//* *                                                                        * *//* *             1.0.9 - 09/17/2004 - G.R-P                                 * *//* *             - added two more conditionals                              * *//* *             1.0.9 - 09/25/2004 - G.Juyn                                * *//* *             - replaced MNG_TWEAK_LARGE_FILES with permanent solution   * *//* *             1.0.9 - 17/14/2004 - G.Juyn                                * *//* *             - fixed PPLT getchunk/putchunk routines                    * *//* *             1.0.9 - 12/05/2004 - G.Juyn                                * *//* *             - added conditional MNG_OPTIMIZE_CHUNKINITFREE             * *//* *             1.0.9 - 12/20/2004 - G.Juyn                                * *//* *             - cleaned up macro-invocations (thanks to D. Airlie)       * *//* *                                                                        * *//* ************************************************************************** */#include "libmng.h"#include "libmng_data.h"#include "libmng_error.h"#include "libmng_trace.h"#ifdef __BORLANDC__#pragma hdrstop#endif#include "libmng_memory.h"#include "libmng_chunks.h"#ifdef MNG_OPTIMIZE_CHUNKREADER#include "libmng_chunk_descr.h"#endif#include "libmng_chunk_prc.h"#include "libmng_chunk_io.h"#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)#pragma option -A                      /* force ANSI-C */#endif/* ************************************************************************** */#ifdef MNG_ACCESS_CHUNKS/* ************************************************************************** */mng_retcode MNG_DECL mng_iterate_chunks (mng_handle       hHandle,                                         mng_uint32       iChunkseq,                                         mng_iteratechunk fProc){  mng_uint32  iSeq;  mng_chunkid iChunkname;  mng_datap   pData;  mng_chunkp  pChunk;  mng_bool    bCont;#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (((mng_datap)hHandle), MNG_FN_ITERATE_CHUNKS, MNG_LC_START);#endif  MNG_VALIDHANDLE (hHandle)            /* check validity handle */  pData = ((mng_datap)hHandle);        /* and make it addressable */  iSeq   = 0;  bCont  = MNG_TRUE;  pChunk = pData->pFirstchunk;         /* get the first chunk */                                       /* as long as there are some more */  while ((pChunk) && (bCont))          /* and the app didn't signal a stop */  {    if (iSeq >= iChunkseq)             /* reached the first target ? */    {                                  /* then call this and next ones back in... */      iChunkname = ((mng_chunk_headerp)pChunk)->iChunkname;      bCont      = fProc (hHandle, (mng_handle)pChunk, iChunkname, iSeq);    }    iSeq++;                            /* next one */    pChunk = ((mng_chunk_headerp)pChunk)->pNext;  }#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (((mng_datap)hHandle), MNG_FN_ITERATE_CHUNKS, MNG_LC_END);#endif  return MNG_NOERROR;}/* ************************************************************************** */#ifdef MNG_SUPPORT_WRITEmng_retcode MNG_DECL mng_copy_chunk (mng_handle hHandle,                                     mng_handle hChunk,                                     mng_handle hHandleOut){  mng_datap   pDataOut;  mng_chunkp  pChunk;  mng_chunkp  pChunkOut;  mng_retcode iRetcode;#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (((mng_datap)hHandle), MNG_FN_COPY_CHUNK, MNG_LC_START);#endif  MNG_VALIDHANDLE (hHandle)            /* check validity handles */  MNG_VALIDHANDLE (hHandleOut)  pDataOut = (mng_datap)hHandleOut;    /* make outhandle addressable */  pChunk   = (mng_chunkp)hChunk;       /* address the chunk */  if (!pDataOut->bCreating)            /* aren't we creating a new file ? */    MNG_ERROR (pDataOut, MNG_FUNCTIONINVALID)                                       /* create a new chunk */  iRetcode = ((mng_createchunk)((mng_chunk_headerp)pChunk)->fCreate)                        (pDataOut, ((mng_chunk_headerp)pChunk), &pChunkOut);  if (!iRetcode)                       /* assign the chunk-specific data */    iRetcode = ((mng_assignchunk)((mng_chunk_headerp)pChunk)->fAssign)                          (pDataOut, pChunkOut, pChunk);  if (iRetcode)                        /* on error bail out */    return iRetcode;   mng_add_chunk (pDataOut, pChunkOut); /* and put it in the output-stream */                                       /* could it be the end of the chain ? */  if (((mng_chunk_headerp)pChunkOut)->iChunkname == MNG_UINT_IEND)  {#ifdef MNG_INCLUDE_JNG    if ((pDataOut->iFirstchunkadded == MNG_UINT_IHDR) ||        (pDataOut->iFirstchunkadded == MNG_UINT_JHDR)    )#else    if (pDataOut->iFirstchunkadded == MNG_UINT_IHDR)#endif      pDataOut->bCreating = MNG_FALSE; /* right; this should be the last chunk !!! */  }  if (((mng_chunk_headerp)pChunkOut)->iChunkname == MNG_UINT_MEND)    pDataOut->bCreating = MNG_FALSE;   /* definitely this should be the last !!! */#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (((mng_datap)hHandle), MNG_FN_COPY_CHUNK, MNG_LC_END);#endif  return MNG_NOERROR;}#endif /* MNG_SUPPORT_WRITE *//* ************************************************************************** */mng_retcode MNG_DECL mng_getchunk_ihdr (mng_handle hHandle,                                        mng_handle hChunk,                                        mng_uint32 *iWidth,                                        mng_uint32 *iHeight,                                        mng_uint8  *iBitdepth,                                        mng_uint8  *iColortype,                                        mng_uint8  *iCompression,                                        mng_uint8  *iFilter,                                        mng_uint8  *iInterlace){  mng_datap pData;  mng_ihdrp pChunk;#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_IHDR, MNG_LC_START);#endif  MNG_VALIDHANDLE (hHandle)            /* check validity handle */  pData  = (mng_datap)hHandle;         /* and make it addressable */  pChunk = (mng_ihdrp)hChunk;          /* address the chunk */  if (pChunk->sHeader.iChunkname != MNG_UINT_IHDR)    MNG_ERROR (pData, MNG_WRONGCHUNK)  /* ouch */  *iWidth       = pChunk->iWidth;      /* fill the fields */  *iHeight      = pChunk->iHeight;  *iBitdepth    = pChunk->iBitdepth;  *iColortype   = pChunk->iColortype;  *iCompression = pChunk->iCompression;  *iFilter      = pChunk->iFilter;  *iInterlace   = pChunk->iInterlace;                                       /* fill the chunk */#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_IHDR, MNG_LC_END);#endif  return MNG_NOERROR;}/* ************************************************************************** */mng_retcode MNG_DECL mng_getchunk_plte (mng_handle   hHandle,                                        mng_handle   hChunk,                                        mng_uint32   *iCount,                                        mng_palette8 *aPalette){  mng_datap pData;  mng_pltep pChunk;#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PLTE, MNG_LC_START);#endif  MNG_VALIDHANDLE (hHandle)            /* check validity handle */  pData  = (mng_datap)hHandle;         /* and make it addressable */  pChunk = (mng_pltep)hChunk;          /* address the chunk */  if (pChunk->sHeader.iChunkname != MNG_UINT_PLTE)    MNG_ERROR (pData, MNG_WRONGCHUNK)  /* ouch */  *iCount = pChunk->iEntrycount;       /* fill the fields */  MNG_COPY (*aPalette, pChunk->aEntries, sizeof (mng_palette8));#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PLTE, MNG_LC_END);#endif  return MNG_NOERROR;}/* ************************************************************************** */mng_retcode MNG_DECL mng_getchunk_idat (mng_handle hHandle,                                        mng_handle hChunk,                                        mng_uint32 *iRawlen,                                        mng_ptr    *pRawdata){  mng_datap pData;  mng_idatp pChunk;#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_IDAT, MNG_LC_START);#endif  MNG_VALIDHANDLE (hHandle)            /* check validity handle */  pData  = (mng_datap)hHandle;         /* and make it addressable */  pChunk = (mng_idatp)hChunk;          /* address the chunk */  if (pChunk->sHeader.iChunkname != MNG_UINT_IDAT)    MNG_ERROR (pData, MNG_WRONGCHUNK)  /* ouch */  *iRawlen  = pChunk->iDatasize;       /* fill the fields */  *pRawdata = pChunk->pData;#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_IDAT, MNG_LC_END);#endif  return MNG_NOERROR;}/* ************************************************************************** */mng_retcode MNG_DECL mng_getchunk_trns (mng_handle   hHandle,                                        mng_handle   hChunk,                                        mng_bool     *bEmpty,                                        mng_bool     *bGlobal,                                        mng_uint8    *iType,                                        mng_uint32   *iCount,                                        mng_uint8arr *aAlphas,                                        mng_uint16   *iGray,                                        mng_uint16   *iRed,                                        mng_uint16   *iGreen,                                        mng_uint16   *iBlue,                                        mng_uint32   *iRawlen,                                        mng_uint8arr *aRawdata){  mng_datap pData;  mng_trnsp pChunk;#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TRNS, MNG_LC_START);#endif  MNG_VALIDHANDLE (hHandle)            /* check validity handle */  pData  = (mng_datap)hHandle;         /* and make it addressable */  pChunk = (mng_trnsp)hChunk;          /* address the chunk */  if (pChunk->sHeader.iChunkname != MNG_UINT_tRNS)    MNG_ERROR (pData, MNG_WRONGCHUNK)  /* ouch */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -