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

📄 libmng_object_prc.c

📁 奇趣公司比较新的qt/emd版本
💻 C
📖 第 1 页 / 共 5 页
字号:
/* ************************************************************************** *//* *             For conditions of distribution and use,                    * *//* *                see copyright notice in libmng.h                        * *//* ************************************************************************** *//* *                                                                        * *//* * project   : libmng                                                     * *//* * file      : libmng_object_prc.c       copyright (c) 2000-2004 G.Juyn   * *//* * version   : 1.0.9                                                      * *//* *                                                                        * *//* * purpose   : Object processing routines (implementation)                * *//* *                                                                        * *//* * author    : G.Juyn                                                     * *//* *                                                                        * *//* * comment   : implementation of the internal object processing routines  * *//* *                                                                        * *//* * changes   : 0.5.1 - 05/08/2000 - G.Juyn                                * *//* *             - changed strict-ANSI stuff                                * *//* *             0.5.1 - 05/12/2000 - G.Juyn                                * *//* *             - changed trace to macro for callback error-reporting      * *//* *                                                                        * *//* *             0.5.2 - 05/20/2000 - G.Juyn                                * *//* *             - fixed to support JNG objects                             * *//* *             0.5.2 - 05/24/2000 - G.Juyn                                * *//* *             - added support for global color-chunks in animation       * *//* *             - added support for global PLTE,tRNS,bKGD in animation     * *//* *             - added SAVE & SEEK animation objects                      * *//* *             0.5.2 - 05/29/2000 - G.Juyn                                * *//* *             - added initialization of framenr/layernr/playtime         * *//* *             - changed ani_object create routines not to return the     * *//* *               created object (wasn't necessary)                        * *//* *             0.5.2 - 05/30/2000 - G.Juyn                                * *//* *             - added object promotion routine (PROM handling)           * *//* *             - added ani-object routines for delta-image processing     * *//* *             - added compression/filter/interlace fields to             * *//* *               object-buffer for delta-image processing                 * *//* *                                                                        * *//* *             0.5.3 - 06/17/2000 - G.Juyn                                * *//* *             - changed support for delta-image processing               * *//* *             0.5.3 - 06/20/2000 - G.Juyn                                * *//* *             - fixed some small things (as precaution)                  * *//* *             0.5.3 - 06/21/2000 - G.Juyn                                * *//* *             - added processing of PLTE/tRNS & color-info for           * *//* *               delta-images in the ani_objects chain                    * *//* *             0.5.3 - 06/22/2000 - G.Juyn                                * *//* *             - added support for PPLT chunk                             * *//* *                                                                        * *//* *             0.9.1 - 07/07/2000 - G.Juyn                                * *//* *             - added support for freeze/restart/resume & go_xxxx        * *//* *             0.9.1 - 07/16/2000 - G.Juyn                                * *//* *             - fixed support for mng_display() after mng_read()         * *//* *                                                                        * *//* *             0.9.2 - 07/29/2000 - G.Juyn                                * *//* *             - fixed small bugs in display processing                   * *//* *             0.9.2 - 08/05/2000 - G.Juyn                                * *//* *             - changed file-prefixes                                    * *//* *                                                                        * *//* *             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 - 09/10/2000 - G.Juyn                                * *//* *             - fixed DEFI behavior                                      * *//* *             0.9.3 - 10/17/2000 - G.Juyn                                * *//* *             - added valid-flag to stored objects for read() / display()* *//* *             - added routine to discard "invalid" objects               * *//* *             0.9.3 - 10/18/2000 - G.Juyn                                * *//* *             - fixed delta-processing behavior                          * *//* *             0.9.3 - 10/19/2000 - G.Juyn                                * *//* *             - added storage for pixel-/alpha-sampledepth for delta's   * *//* *                                                                        * *//* *             0.9.4 -  1/18/2001 - G.Juyn                                * *//* *             - removed "old" MAGN methods 3 & 4                         * *//* *             - added "new" MAGN methods 3, 4 & 5                        * *//* *                                                                        * *//* *             0.9.5 -  1/22/2001 - G.Juyn                                * *//* *             - B129681 - fixed compiler warnings SGI/Irix               * *//* *                                                                        * *//* *             1.0.2 - 06/23/2001 - G.Juyn                                * *//* *             - added optimization option for MNG-video playback         * *//* *                                                                        * *//* *             1.0.5 - 08/15/2002 - G.Juyn                                * *//* *             - completed PROM support                                   * *//* *             1.0.5 - 08/16/2002 - G.Juyn                                * *//* *             - completed MAGN support (16-bit functions)                * *//* *             1.0.5 - 08/19/2002 - G.Juyn                                * *//* *             - B597134 - libmng pollutes the linker namespace           * *//* *             1.0.5 - 09/13/2002 - G.Juyn                                * *//* *             - fixed read/write of MAGN chunk                           * *//* *             1.0.5 - 09/15/2002 - G.Juyn                                * *//* *             - added event handling for dynamic MNG                     * *//* *             1.0.5 - 09/20/2002 - G.Juyn                                * *//* *             - added support for PAST                                   * *//* *             1.0.5 - 09/23/2002 - G.Juyn                                * *//* *             - fixed reset_object_detail to clear old buffer            * *//* *             - added in-memory color-correction of abstract images      * *//* *             1.0.5 - 10/05/2002 - G.Juyn                                * *//* *             - fixed problem with cloned objects marked as invalid      * *//* *             - fixed problem cloning frozen object_buffers              * *//* *             1.0.5 - 10/07/2002 - G.Juyn                                * *//* *             - fixed DISC support                                       * *//* *             1.0.5 - 11/04/2002 - G.Juyn                                * *//* *             - fixed goframe/golayer/gotime processing                  * *//* *             1.0.5 - 11/07/2002 - G.Juyn                                * *//* *             - fixed magnification bug with object 0                    * *//* *             1.0.5 - 01/19/2003 - G.Juyn                                * *//* *             - B664911 - fixed buffer overflow during init              * *//* *                                                                        * *//* *             1.0.6 - 04/19/2003 - G.Juyn                                * *//* *             - fixed problem with infinite loops during readdisplay()   * *//* *             1.0.6 - 05/25/2003 - G.R-P                                 * *//* *             - added MNG_SKIPCHUNK_cHNK footprint optimizations         * *//* *             1.0.6 - 06/09/2003 - G. R-P                                * *//* *             - added conditionals around 8-bit magn routines            * *//* *             1.0.6 - 07/07/2003 - G.R-P                                 * *//* *             - added conditionals around some JNG-supporting code       * *//* *             - removed conditionals around 8-bit magn routines          * *//* *             - added conditionals around delta-png and 16-bit code      * *//* *             1.0.6 - 07/14/2003 - G.R-P                                 * *//* *             - added MNG_NO_LOOP_SIGNALS_SUPPORTED conditional          * *//* *             1.0.6 - 07/29/2003 - G.Juyn                                * *//* *             - fixed invalid test in promote_imageobject                * *//* *             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 MAGN chunk support             * *//* *                                                                        * *//* *             1.0.7 - 03/21/2004 - G.Juyn                                * *//* *             - fixed some 64-bit platform compiler warnings             * *//* *                                                                        * *//* *             1.0.9 - 10/10/2004 - G.R-P.                                * *//* *             - added MNG_NO_1_2_4BIT_SUPPORT support                    * *//* *             1.0.9 - 12/05/2004 - G.Juyn                                * *//* *             - added conditional MNG_OPTIMIZE_OBJCLEANUP                * *//* *             1.0.9 - 12/11/2004 - G.Juyn                                * *//* *             - added conditional MNG_OPTIMIZE_DISPLAYCALLS              * *//* *             1.0.9 - 12/31/2004 - G.R-P.                                * *//* *             - fixed warnings about possible uninitialized pointers     * *//* *             1.0.9 - 01/02/2005 - G.Juyn                                * *//* *             - fixing some compiler-warnings                            * *//* *                                                                        * *//* ************************************************************************** */#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"#include "libmng_objects.h"#include "libmng_display.h"#include "libmng_pixels.h"#include "libmng_object_prc.h"#include "libmng_cms.h"#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)#pragma option -A                      /* force ANSI-C */#endif/* ************************************************************************** */#ifdef MNG_INCLUDE_DISPLAY_PROCS/* ************************************************************************** *//* *                                                                        * *//* * Generic object routines                                                * *//* *                                                                        * *//* ************************************************************************** */mng_retcode mng_drop_invalid_objects (mng_datap pData){  mng_objectp       pObject;  mng_objectp       pNext;  mng_cleanupobject fCleanup;#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_DROP_INVALID_OBJECTS, MNG_LC_START);#endif  pObject = pData->pFirstimgobj;       /* get first stored image-object (if any) */  while (pObject)                      /* more objects to check ? */  {    pNext = ((mng_object_headerp)pObject)->pNext;                                       /* invalid ? */    if (!((mng_imagep)pObject)->bValid)    {                                  /* call appropriate cleanup */      fCleanup = ((mng_object_headerp)pObject)->fCleanup;      fCleanup (pData, pObject);    }    pObject = pNext;                   /* neeeext */  }#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_DROP_INVALID_OBJECTS, MNG_LC_END);#endif  return MNG_NOERROR;}/* ************************************************************************** */#ifdef MNG_OPTIMIZE_OBJCLEANUPMNG_LOCAL mng_retcode create_obj_general (mng_datap          pData,                                          mng_size_t         iObjsize,                                          mng_cleanupobject  fCleanup,                                          mng_processobject  fProcess,                                          mng_ptr            *ppObject){  mng_object_headerp pWork;  MNG_ALLOC (pData, pWork, iObjsize);  pWork->fCleanup = fCleanup;  pWork->fProcess = fProcess;  pWork->iObjsize = iObjsize;  *ppObject       = (mng_ptr)pWork;  return MNG_NOERROR;}/* ************************************************************************** */MNG_LOCAL mng_retcode mng_free_obj_general (mng_datap   pData,                                            mng_objectp pObject){  MNG_FREEX (pData, pObject, ((mng_object_headerp)pObject)->iObjsize);  return MNG_NOERROR;}#endif/* ************************************************************************** *//* *                                                                        * *//* * Image-data-object routines                                             * *//* *                                                                        * *//* * these handle the "object buffer" as defined by the MNG specification   * *//* *                                                                        * *//* ************************************************************************** */mng_retcode mng_create_imagedataobject (mng_datap      pData,                                        mng_bool       bConcrete,                                        mng_bool       bViewable,                                        mng_uint32     iWidth,                                        mng_uint32     iHeight,                                        mng_uint8      iBitdepth,                                        mng_uint8      iColortype,                                        mng_uint8      iCompression,                                        mng_uint8      iFilter,                                        mng_uint8      iInterlace,                                        mng_imagedatap *ppObject){  mng_ptr pTemp;  mng_imagedatap pImagedata;  mng_uint32 iSamplesize = 0;#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_CREATE_IMGDATAOBJECT, MNG_LC_START);#endif                                       /* get a buffer */#ifdef MNG_OPTIMIZE_OBJCLEANUP  {    mng_retcode iRetcode = create_obj_general (pData, sizeof (mng_imagedata),                                               (mng_cleanupobject)mng_free_imagedataobject,                                               MNG_NULL, &pTemp);    if (iRetcode)      return iRetcode;    pImagedata = (mng_imagedatap)pTemp;  }#else  MNG_ALLOC (pData, pImagedata, sizeof (mng_imagedata));                                       /* fill the appropriate fields */  pImagedata->sHeader.fCleanup   = (mng_cleanupobject)mng_free_imagedataobject;  pImagedata->sHeader.fProcess   = MNG_NULL;#endif  pImagedata->iRefcount          = 1;  pImagedata->bFrozen            = MNG_FALSE;  pImagedata->bConcrete          = bConcrete;  pImagedata->bViewable          = bViewable;  pImagedata->iWidth             = iWidth;  pImagedata->iHeight            = iHeight;  pImagedata->iBitdepth          = iBitdepth;  pImagedata->iColortype         = iColortype;  pImagedata->iCompression       = iCompression;  pImagedata->iFilter            = iFilter;  pImagedata->iInterlace         = iInterlace;  pImagedata->bCorrected         = MNG_FALSE;  pImagedata->iAlphabitdepth     = 0;  pImagedata->iJHDRcompression   = 0;  pImagedata->iJHDRinterlace     = 0;  pImagedata->iPixelsampledepth  = iBitdepth;  pImagedata->iAlphasampledepth  = iBitdepth;                                       /* 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;               }  }                                       /* make sure we remember all this */  pImagedata->iSamplesize  = iSamplesize;  pImagedata->iRowsize     = iSamplesize * iWidth;  pImagedata->iImgdatasize = pImagedata->iRowsize * iHeight;  if (pImagedata->iImgdatasize)        /* need a buffer ? */

⌨️ 快捷键说明

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