summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/libmng
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/libmng')
-rw-r--r--src/3rdparty/libmng/CHANGES1447
-rw-r--r--src/3rdparty/libmng/LICENSE57
-rw-r--r--src/3rdparty/libmng/README36
-rw-r--r--src/3rdparty/libmng/README.autoconf213
-rw-r--r--src/3rdparty/libmng/README.config104
-rw-r--r--src/3rdparty/libmng/README.contrib95
-rw-r--r--src/3rdparty/libmng/README.dll41
-rw-r--r--src/3rdparty/libmng/README.examples48
-rw-r--r--src/3rdparty/libmng/README.footprint46
-rw-r--r--src/3rdparty/libmng/README.packaging24
-rw-r--r--src/3rdparty/libmng/doc/Plan1.pngbin0 -> 9058 bytes
-rw-r--r--src/3rdparty/libmng/doc/Plan2.pngbin0 -> 8849 bytes
-rw-r--r--src/3rdparty/libmng/doc/doc.readme19
-rw-r--r--src/3rdparty/libmng/doc/libmng.txt1107
-rw-r--r--src/3rdparty/libmng/doc/man/jng.537
-rw-r--r--src/3rdparty/libmng/doc/man/libmng.31146
-rw-r--r--src/3rdparty/libmng/doc/man/mng.542
-rw-r--r--src/3rdparty/libmng/doc/misc/magic.dif30
-rw-r--r--src/3rdparty/libmng/doc/rpm/libmng-1.0.10-rhconf.patch38
-rw-r--r--src/3rdparty/libmng/doc/rpm/libmng.spec116
-rw-r--r--src/3rdparty/libmng/libmng.h2932
-rw-r--r--src/3rdparty/libmng/libmng_callback_xs.c1239
-rw-r--r--src/3rdparty/libmng/libmng_chunk_descr.c6090
-rw-r--r--src/3rdparty/libmng/libmng_chunk_descr.h146
-rw-r--r--src/3rdparty/libmng/libmng_chunk_io.c10740
-rw-r--r--src/3rdparty/libmng/libmng_chunk_io.h415
-rw-r--r--src/3rdparty/libmng/libmng_chunk_prc.c4452
-rw-r--r--src/3rdparty/libmng/libmng_chunk_prc.h381
-rw-r--r--src/3rdparty/libmng/libmng_chunk_xs.c7016
-rw-r--r--src/3rdparty/libmng/libmng_chunks.h1026
-rw-r--r--src/3rdparty/libmng/libmng_cms.c758
-rw-r--r--src/3rdparty/libmng/libmng_cms.h92
-rw-r--r--src/3rdparty/libmng/libmng_conf.h295
-rw-r--r--src/3rdparty/libmng/libmng_data.h1032
-rw-r--r--src/3rdparty/libmng/libmng_display.c7140
-rw-r--r--src/3rdparty/libmng/libmng_display.h343
-rw-r--r--src/3rdparty/libmng/libmng_dither.c58
-rw-r--r--src/3rdparty/libmng/libmng_dither.h45
-rw-r--r--src/3rdparty/libmng/libmng_error.c326
-rw-r--r--src/3rdparty/libmng/libmng_error.h119
-rw-r--r--src/3rdparty/libmng/libmng_filter.c978
-rw-r--r--src/3rdparty/libmng/libmng_filter.h69
-rw-r--r--src/3rdparty/libmng/libmng_hlapi.c3001
-rw-r--r--src/3rdparty/libmng/libmng_jpeg.c1088
-rw-r--r--src/3rdparty/libmng/libmng_jpeg.h57
-rw-r--r--src/3rdparty/libmng/libmng_memory.h64
-rw-r--r--src/3rdparty/libmng/libmng_object_prc.c6998
-rw-r--r--src/3rdparty/libmng/libmng_object_prc.h690
-rw-r--r--src/3rdparty/libmng/libmng_objects.h635
-rw-r--r--src/3rdparty/libmng/libmng_pixels.c24610
-rw-r--r--src/3rdparty/libmng/libmng_pixels.h1147
-rw-r--r--src/3rdparty/libmng/libmng_prop_xs.c2799
-rw-r--r--src/3rdparty/libmng/libmng_read.c1369
-rw-r--r--src/3rdparty/libmng/libmng_read.h53
-rw-r--r--src/3rdparty/libmng/libmng_trace.c1683
-rw-r--r--src/3rdparty/libmng/libmng_trace.h1474
-rw-r--r--src/3rdparty/libmng/libmng_types.h574
-rw-r--r--src/3rdparty/libmng/libmng_write.c198
-rw-r--r--src/3rdparty/libmng/libmng_write.h49
-rw-r--r--src/3rdparty/libmng/libmng_zlib.c607
-rw-r--r--src/3rdparty/libmng/libmng_zlib.h60
-rw-r--r--src/3rdparty/libmng/makefiles/Makefile.am29
-rw-r--r--src/3rdparty/libmng/makefiles/README27
-rw-r--r--src/3rdparty/libmng/makefiles/configure.in193
-rw-r--r--src/3rdparty/libmng/makefiles/makefile.bcb3108
-rw-r--r--src/3rdparty/libmng/makefiles/makefile.dj155
-rw-r--r--src/3rdparty/libmng/makefiles/makefile.linux180
-rw-r--r--src/3rdparty/libmng/makefiles/makefile.mingw164
-rw-r--r--src/3rdparty/libmng/makefiles/makefile.mingwdll158
-rw-r--r--src/3rdparty/libmng/makefiles/makefile.qnx160
-rw-r--r--src/3rdparty/libmng/makefiles/makefile.unix67
-rw-r--r--src/3rdparty/libmng/makefiles/makefile.vcwin3299
-rwxr-xr-xsrc/3rdparty/libmng/unmaintained/autogen.sh50
73 files changed, 98884 insertions, 0 deletions
diff --git a/src/3rdparty/libmng/CHANGES b/src/3rdparty/libmng/CHANGES
new file mode 100644
index 0000000000..eeacf33246
--- /dev/null
+++ b/src/3rdparty/libmng/CHANGES
@@ -0,0 +1,1447 @@
+-----------------------------------------------------------
+
+1.0.10 (Jul 13th 2007)
+----------------------
+
+in short:
+
+intermediate CVS
+
+-------------------
+
+bugfixes:
+
+core:
+- fixed some compiler-warnings
+- fixed display routines called twice for FULL_MNG support in mozlibmngconf.h
+- standard windows dll upgraded to zlib 1.2.3
+- fixed problem with CLON object during readdisplay() (thanks Winfried!)
+- added typecast to appease the compiler (G R-P)
+- added more SKIPCHUNK conditionals (G R-P)
+- added MORE MNG_NO_1_2_4BIT_SUPPORT (G R-P)
+- added provisional support for anIM(mpNG) proposal
+- added provisional support for ANG proposal
+
+samples:
+- xmngview upgraded to 0.6 (thanks Winfried!)
+
+contrib:
+
+doc:
+
+makefiles:
+
+autoconf:
+
+-----------------------------------------------------------
+
+1.0.9 (jan 30th 2005)
+---------------------
+
+in short:
+
+New optimizations save over 20KB on footprint.
+Also a few bugfixes and several patches.
+
+Thanks to those sending in their additions and for testing!
+
+To turn on the optimizations do:
+
+#DEFINE MNG_OPTIMIZE_CHUNKINITFREE
+#DEFINE MNG_OPTIMIZE_OBJCLEANUP
+#DEFINE MNG_OPTIMIZE_CHUNKASSIGN
+#DEFINE MNG_OPTIMIZE_CHUNKREADER
+
+(eg. they're not on by default (yet) !)
+
+-------------------
+
+bugfixes:
+- fixed chunk pushing mechanism
+- fixed bug in writing sBIT for indexed color
+- fixed PPLT getchunk/putchunk routines
+- fixed MNG_NO_1_2_4BIT_SUPPORT for TBBN1G04.PNG
+- cleaned up macro-invocations (thanks to D. Airlie)
+
+core:
+- added more SKIPCHUNK conditionals
+- replaced MNG_TWEAK_LARGE_FILES with permanent solution
+- improved handling of cheap transparency when 16-bit support is disabled
+- added some MNG_SUPPORT_WRITE conditionals
+- added function to retrieve current FRAM delay
+- added MNG_NO_1_2_4BIT_SUPPORT
+- added bgr565_a8 canvas-style (thanks to J. Elvander)
+- standard windows dll upgraded to zlib 1.2.2
+- added LITTLEENDIAN/BIGENDIAN fixtures (thanks J.Stiles)
+- inclusion of zlib/lcms/ijgsrc6b with <> instead of ""
+- added conditional MNG_OPTIMIZE_CHUNKINITFREE
+- added conditional MNG_OPTIMIZE_OBJCLEANUP
+- added conditional MNG_OPTIMIZE_CHUNKASSIGN
+- added conditional MNG_OPTIMIZE_CHUNKREADER
+- fixed problem with global PLTE/tRNS
+
+samples:
+
+contrib:
+
+doc:
+- patched jng & mng manual pages (Thanks Peter Breitenlohner)
+
+makefiles:
+
+autoconf:
+- patched makefile.am & configure.in (Thanks Peter Breitenlohner)
+
+-----------------------------------------------------------
+
+1.0.8 (aug 5th 2004)
+--------------------
+
+in short:
+
+added special data-pushing mechanisms and a few other tid-bits
+
+-------------------
+
+bugfixes:
+- fixed problem with PAST usage where source > dest
+
+core:
+- added missing get-/put-chunk-jdaa
+- added CRC existence & checking flags
+- added data-push mechanisms for specialized decoders
+- some speed optimizations (thanks to John Stiles)
+- defend against using undefined closestream function
+- defend against using undefined openstream function
+- added check for extreme chunk-lengths
+- change worst-case iAlphadepth to 1 for standalone PNGs
+- added support for 3+byte pixelsize for JPEG's
+- added conditional to allow easier writing of large MNG's
+
+samples:
+
+contrib:
+
+doc:
+
+makefiles:
+
+autoconf:
+
+-----------------------------------------------------------
+
+1.0.7 (March 21st 2004)
+-----------------------
+
+in short:
+
+A bunch of new canvas-styles, some bug-fixes, upgraded to latest zlib/lcms
+and yet more work to please the Mozilla crowd.
+Releasing beta's doesn't seem very responsive, and this one's hardly changed
+much anyway. I just wanted to bump to a regular version for Mozilla
+re-integration.
+
+-------------------
+
+bugfixes:
+- fixed inclusion of IJNG chunk for non-JNG use (J.S)
+- fixed bug in chunk-storage of SHOW chunk (where from == to)
+- fixed bug in promote_g8_g8 with 16bit support off
+
+core:
+- added CANVAS_RGB565 and CANVAS_BGR565 (big thanx to Raphael Assenat!!)
+- added CANVAS_RGBA565 and CANVAS_BGRA565 ( -- ditto -- )
+- upgraded to zlib 1.2.1
+- upgraded to lcms 1.11
+- added premultiplied alpha canvas' for RGBA, ARGB, ABGR (thx to John Stiles)
+- more optimizations with 16bit support off
+- put conditionals around openstream/closestream callbacks.
+- fixed typo (MNG_SKIPCHUNK_SAVE -> MNG_SKIPCHUNK_nEED)
+- fixed some 64-bit platform compiler warnings
+
+samples:
+
+contrib:
+- fixed mngtree sample (Raphael)
+- added 5-6-5 canvas to SDL sample (Raphael)
+
+doc:
+
+makefiles:
+
+autoconf:
+
+-----------------------------------------------------------
+
+1.0.6 (oct 19th 2003)
+---------------------
+
+in short:
+
+Final release from beta1. No feedback is good feedback I presume,
+so here's 1.0.6-final!
+
+
+-------------------
+
+bugfixes:
+
+core:
+
+samples:
+
+contrib:
+
+doc:
+
+makefiles:
+
+autoconf:
+
+-----------------------------------------------------------
+
+1.0.6-beta1 (sep 14th 2003)
+---------------------------
+
+in short:
+
+further footprint-reductions
+removing email-addresses
+
+1.0.6 (final) will be out shortly
+
+-------------------
+
+bugfixes:
+
+core:
+- added support for reducing the footprint of libmng by macros that optionally
+ skip unused chunks, remove 16-bit sample support, remove Delta support, and
+ remove JNG support, to accomodate Mozilla/Firebird.
+- further optional removal of unused functions
+- added MNG_NO_SUPPORT_FUNCQUERY conditional
+- added iPNGdepth member to pData structure
+- added conditionals around MAGN chunk support
+- added conditionals around non-VLC chunk support
+- added conditionals around "mng_display_go*" and other unused functions
+- added more conditionals around "promote" functions
+- removed email references as appropriate
+
+samples:
+
+contrib:
+
+doc:
+
+makefiles:
+
+autoconf:
+
+-----------------------------------------------------------
+
+1.0.6-alpha1 (aug 2nd 2003)
+---------------------------
+
+in short:
+
+This is mostly in the light of footprint-reduction to please the Mozilla
+crew with a leaner and meaner libmng. See bug 18574 if you're interested:
+http://bugzilla.mozilla.org/show_bug.cgi?id=18574
+
+-------------------
+
+bugfixes:
+- B719420 - fixed several MNG_APP_CMS problems
+
+core:
+- removed some compiler-warnings
+- hiding 12-bit JPEG stuff
+- fixed problem with infinite loops during readdisplay()
+- added size-optimiation COMPOSE routine usage
+- added conditionals around canvas update routines
+- added MNG_SKIPCHUNK_cHNK footprint optimizations
+- added conditionals around some JNG-supporting code
+- added conditionals around 16-bit supporting code
+- combined init functions into one function
+- replaced nested switches with simple init setup function
+- added conditionals zlib and jpeg property accessors
+- added size-optimization DIV255B8 routine usage
+- added conditionals around 8-bit magn routines
+- removed conditionals around 8-bit magn routines
+- added MNG_NO_16BIT_SUPPORT and MNG_NO_DELTA_PNG conditionals
+- reversed many loops to use decrementing counter
+- converted some switches to array references
+- removed some redundant checks for iRawlen==0
+- optionally use zlib's crc32 function instead of local mng_update_crc
+- bugfix empty "if" statement when 16-bit code is enabled
+- restored two misplaced #else/#endif blocks
+- added conditionals around "mng_display_go*" and other unused functions
+- added MNG_NO_LOOP_SIGNALS_SUPPORTED conditional
+- fixed duplicate for-loop
+- fixed invalid test in promote_imageobject
+- added conditionals around PAST chunk support
+- fixed "FOOTPRINT_COMPOSEIV" typo (now "FOOTPRINT_DIV")
+
+samples:
+
+contrib:
+- updated xmngview
+- added MSVC project for creating delta-MNGs: makemng (thanks Alex!)
+- added MSVC lib-file for use with the standard libmng.dll (again thanks Alex)
+
+doc:
+- updated readme.contrib
+
+makefiles:
+
+autoconf:
+
+-----------------------------------------------------------
+
+1.0.5 (mar 1st 2003)
+--------------------
+
+in short:
+
+Only a small fix for progressive jpeg suspension problem.
+
+This is the long-awaited final release containing the new 'dynamic MNG' feature
+and bringing MNG compliance to near 100%!
+
+-------------------
+
+bugfixes:
+- B683152 - libjpeg suspension not always honored correctly
+
+core:
+
+samples:
+
+contrib:
+
+doc:
+
+makefiles:
+
+autoconf:
+
+-----------------------------------------------------------
+
+1.0.5-rc3 (jan 20th 2003)
+-------------------------
+
+in short:
+
+Third release-candidate for the upcoming 1.0.5 version.
+
+Minor bug-fixes and finalizing the accepted proposal (by official vote) for
+the TERM/frame_delay changes on mng-list (nov-dec/2002).
+
+-------------------
+
+bugfixes:
+- B654627 - fixed SEGV when no gettickcount callback (thanks Adam!)
+- B664383 - fixed typo (thanks Dimitri)
+- B664911 - fixed buffer overflow during init (thanks Alex!)
+
+core:
+- finalized changes in TERM/final_delay to elected proposal (positive vote)
+
+samples:
+
+contrib:
+
+doc:
+
+makefiles:
+
+autoconf:
+
+-----------------------------------------------------------
+
+1.0.5-rc2 (dec 9th 2002)
+------------------------
+
+in short:
+
+Second release-candidate for the upcoming 1.0.5 version.
+This contains fixes for a few minor details reported by the loyal testers.
+It fixes some issues with the goframe/golayer/gotime processing and related
+stuff. And it adds a way to disable playback-caching from within the MNG,
+which is very useful for streaming-MNG encoders (such as gserver!).
+
+-------------------
+
+bugfixes:
+
+core:
+- fixed layer- & frame-counting during read()
+- changed FRAMECOUNT/LAYERCOUNT/PLAYTIME error to warning
+- fixed goframe/golayer/gotime processing
+- added support for nEED "MNG 1.1"
+- added support for nEED "CACHEOFF"; turn playback caching off for streaming MNG
+- fixed magnification bug with object 0
+- added support to get totals for frames/layers/playtime after mng_read()
+- fixed some issues in init_app_cms()
+- fixed goxxxxx() support for zero values
+
+samples:
+
+contrib:
+
+doc:
+
+makefiles:
+
+autoconf:
+
+-----------------------------------------------------------
+
+1.0.5-rc1 (nov 1st 2002)
+------------------------
+
+in short:
+
+First release-candidate for the upcoming 1.0.5 version.
+This fixes a few small problems and brings the TERM/MEND processing, with
+respect to interframe_delay as per the current discussion on MNG-list,
+up-to-date with the latest proposal.
+
+-------------------
+
+bugfixes:
+
+core:
+- fixed initialization of pIds in dISC read routine (Thanks Winfried!)
+- fixed issue in freeing evNT chunk (Thanks Winfried!)
+- fixed clipping-problem with BACK tiling (Thanks Sakura!)
+- fixed processing for multiple objects in MAGN (Thanks Sakura!)
+- fixed display of visible target of PAST operation (Thanks Sakura!)
+- modified TERM/MEND processing for max(1, TERM_delay, interframe_delay)
+
+samples:
+
+contrib:
+- fixed typo in Makefile for gtk-mng-view sample
+
+doc:
+
+makefiles:
+
+autoconf:
+
+-----------------------------------------------------------
+
+1.0.5-b3 (oct 15th 2002)
+------------------------
+
+in short:
+
+Fairly quick after beta2, since that introduced a couple of unfortunate
+booboo's and wasn't very workable. It also changes the standard configure
+script to build a standard shared object similar to what I intended.
+
+-------------------
+
+bugfixes:
+
+core:
+- fixed support for condition=2 in TERM chunk
+- fixed trace-constants for PAST chunk
+- added mng_status_dynamic to supports function
+
+samples:
+
+contrib:
+
+doc:
+- small cosmetic changes in man/libmng.3
+
+makefiles:
+
+autoconf:
+- fixed configure.in to build a 'standard' SO primarily
+
+-----------------------------------------------------------
+
+1.0.5-b2 (oct 9th 2002)
+------------------------
+
+in short:
+
+Second beta for next 1.0.5 release. This addresses some minor problems
+detected during testing. It adds the proposed change to the MNG spec as
+discussed on the "mng-list" recently; eg. Adam's option 4.
+And it adds a little function to check at run-time if the lib is a beta or not.
+
+-------------------
+
+bugfixes:
+
+core:
+- fixed chunk-storage for evNT chunk
+- fixed dropping mix of frozen/unfrozen objects
+- fixed problem with cloned objects marked as invalid
+- fixed problem cloning frozen object_buffers
+- fixed DISC support
+- added proposed change in handling of TERM- & interframe-delay
+- added another fix for misplaced TERM chunk
+- added check for TERM placement during create/write
+- completed support for condition=2 in TERM chunk
+- added beta version function & constant
+
+samples:
+
+contrib:
+
+doc:
+
+makefiles:
+
+autoconf:
+
+-----------------------------------------------------------
+
+1.0.5-b1 (sep 24th 2002)
+------------------------
+
+in short:
+
+First beta of a large maintenance release. This completes support of the MNG
+specification to nearly 100% (PAST, PROM, delta-images, BACK image+tile).
+It adds "dynamic" MNG and a few other neat routines as well as fixes several
+bugs reported through SourceForge or to me directly.
+
+-------------------
+
+bugfixes:
+- B575832 - library has wrong patch version number
+- B578572 - remove in 1.0.0!
+- B578940 - some functions not implemented
+- B581625 - large chunks fail with suspension reads
+- B597134 - libmng pollutes the linker namespace
+
+core:
+- added sanity check for improbable chunklengths
+- removed eMNGma hack (thanks Dimitri!)
+- unimplemented functions return an errorcode now
+- added test-option for PNG filter method 192 (= levelling)
+- added test-option for PNG filter method 193 (= no filtering)
+ (both are conditional and only for testing purposes!!!)
+- completed PROM support
+- completed delta-image support
+- completed MAGN support (16-bit functions)
+- added HLAPI function to copy a chunk from a read MNG to a newly created MNG
+- added option for soft-handling of errors (only for repair software!!!)
+- fixed some routine inclusion/exclusion for undefined conditionals
+- pre-fixed all internal routines with mng_
+- added symbol MNG_LOCAL (= static) to really local functions
+- fixed reading of FRAM with just frame_mode and name
+- fixed read/write of MAGN chunk
+- added event handling for dynamic MNG
+- added 'supports' call to check function availability
+- fixed copyright notice in the headers of all libmng modules
+- fixed LOOP iteration=0 special case
+- re-compiled standard Windows dll with lcms-1.0.9
+- added warning for too much IDAT data
+- warnings are ignored by default now
+- misplaced TERM is now treated as warning
+- fixed color-correction for restore-background handling
+- optimized restore-background for bKGD cases
+- cleaned up some old stuff
+- completed support for BACK image & tiling
+- completed support for PAST
+- added bgrx8 canvas (filler byte)
+- fixed reset_object_detail to clear old buffer
+- added in-memory color-correction of abstract images
+- added compose over/under routines for PAST processing
+- added flip & tile routines for PAST processing
+
+samples:
+- Added new BCB sample for fixing invalid JASC Animation Shop files
+ (shows new copy_chunks function; use of MNG_SOFTERRORS & static linking)
+
+contrib:
+- added xmngview by Winfried Szukalski (Vielen dank!)
+- Updated the Delphi mngview sample to handle dynamic MNGs
+- Added Kylix example (simplified port of the Delphi mngview sample)
+
+doc:
+- added diff to add MNG&JNG to a systems 'magic' file (Thanks Winfried)
+- fixed docs about using mng_display_resume after display_reset
+ (should read to use mng_display!)
+
+makefiles:
+- added makefile to build a libmng.dll for MingW
+ (makefile.mingwdll - thanks to Frank Richter!)
+
+autoconf:
+- fixing libtool version-number to be in line with what it should be
+
+-----------------------------------------------------------
+
+1.0.4 (Jun 23rd 2002)
+---------------------
+
+in short:
+
+Just some small fixes
+Standard dll now compiled with zlib 1.1.4 and lcms 1.0.8
+
+-------------------
+
+bugfixes:
+- B495442 - invalid returnvalue in mng_get_suspensionmode
+- B495443 - incorrect suspend check in read_databuffer
+- B526138 - returned IJGSRC6B calling convention to default for MSVC
+- B558212 - off by one error
+- B557677 - can't find lcms.h
+
+core:
+- fixed possible compile-problem in cleanup_rowproc
+- MNG subimage alpha composite wrong for rgba8 images
+
+samples:
+
+contrib:
+
+doc:
+
+makefiles:
+- fixed check for lcms.h in configure.in
+
+autoconf:
+
+-----------------------------------------------------------
+
+1.0.3 (Sep 18th 2001)
+---------------------
+
+in short:
+
+Small cosmetic changes. Cleaning up the contributions.
+New makefile for mingw32, and new fbcon example.
+Major thanks to Greg for helping out with the *nix stuff!
+Note that there's also a separate download for ASM programmers now.
+Check http://www.libmng.com for details (download/ports&packages page).
+
+It may be a while for the next release. I'm "off duty" for the next 8 or
+so months...
+
+Gerard
+
+-------------------
+
+bugfixes:
+- B459058 - wrong include for lcms headers
+
+core:
+- changed inclusion of lcms.h header for Linux platforms (suggested by Greg)
+- added get function for last processed BACK chunk
+
+samples:
+- replaced the gtk & sdl viewer apps with updates by Greg Roelofs
+
+contrib:
+
+doc:
+
+makefiles:
+- changed makefile.linux & makefile.unix as suggested by Greg Roelofs
+ (makefile.linux now compiles with lcms by default)
+- added makefile.mingw for mingw32 by Benoit Blanchon (thanks Mate!)
+
+autoconf:
+
+-----------------------------------------------------------
+
+1.0.2 (Jul 7th 2001)
+--------------------
+
+in short:
+
+Another maintenance release with a few added extra's.
+
+-------------------
+
+bugfixes:
+- B421427 - writes wrong format in bKGD and tRNS
+- B434583 - compiler-warning if MNG_STORE_CHUNKS undefined
+
+core:
+- added optimization option for MNG-video playback
+- added processterm callback
+- added late binding errorcode (not used internally)
+- fixed memory-leak with delta-images (Thanks Michael!)
+- added option to turn off progressive refresh for large images
+
+samples:
+
+contrib:
+
+doc:
+
+makefiles:
+
+autoconf:
+
+-----------------------------------------------------------
+
+1.0.1 (May 2nd 2001)
+--------------------
+
+in short:
+
+Maintenance release.
+Fixed several memory-leaks with the help of Gregg Kelly, added/fixed some CMS
+handling, exported JPEG functions from standard DLL, and some other minor fixes.
+
+The CMS fix now makes libmng automagically work in MNG_FULL_CMS mode as a
+sRGB compliant system. YOU WILL NEED TO CHANGE THIS IF YOU ARE NOT ON AN sRGB
+COMPLIANT SYSTEM AND WANT TO USE CMS!!!!
+(look in libmng.h for the proper function-calls)
+
+-------------------
+
+bugfixes:
+
+core:
+- added MEND processing callback
+- fixed first FRAM_MODE=4 timing problem
+- added handle status-copy function (use with care)
+- exported JPEG functions from standard DLL
+- added BGRA8 canvas with premultiplied alpha (contrib by Gregg Kelly)
+- fixed problem with display_reset/display_resume (Thanks Gregg!)
+- fixed several memory-leaks (Thanks Gregg!)
+- fixed reset_rundata to drop all objects (Thanks again, Gregg!)
+- fixed problem with cms profile being created multiple times when both
+ iCCP & cHRM/gAMA are present (And again... Gregg)
+- moved mng_clear_cms to libmng_cms
+- added "default" sRGB generation (Thanks Marti!)
+
+samples:
+
+contrib:
+
+doc:
+
+makefiles:
+
+autoconf:
+
+-----------------------------------------------------------
+
+1.0.0 (Feb 6th 2001)
+--------------------
+
+in short:
+
+First public release. Finally(!)
+
+This is the 0.9.5 CVS version, which will never be released, because I feel it
+is now ready for a public release. So apart from the version-numbers here and
+there, all other changes are listed under 0.9.5.
+
+This library will work with every MNG/JNG known and available to me. Note that
+there are still parts that need to be coded, and that MNG support is around
+90-95% (JNG at 100%). It is however compliant with the latest and greatest
+MNG 1.0 specification.
+
+I hope to dedicate a bit more time this year to finish up full support and fill
+in the remaining blanks. But this is coming out of my spare time. And extra
+help is always appreciated.
+
+Please enjoy!
+
+Gerard
+
+-----------------------------------------------------------
+
+0.9.5 (no release)
+------------------
+
+in short:
+
+intermediate CVS
+
+-------------------
+
+bugfixes:
+B129681 - fixed compiler warnings SGI/Irix (thanks Dimitri)
+
+core:
+- fixed compiler-warnings Mozilla (thanks Tim)
+- fixed timing-problem with switching framing_modes
+- fixed some small compiler warnings (thanks Nikki)
+
+samples:
+
+contrib:
+- fixed library-paths for MSVC DLL project (thanks Chad)
+
+doc:
+
+makefiles:
+- added makefile for DJGPP (thanks Silvio)
+
+autoconf:
+
+-----------------------------------------------------------
+
+0.9.4 (Jan 19th 2001)
+----------------------
+
+in short:
+
+Now that the MNG spec is at 1.0, this should be the last beta. There's a few
+small changes to make it inline with the spec, and a couple of bug-fixes.
+This is a serious release-candidate for libmng-1.0!!
+Please... test test test test!!
+
+-------------------
+
+bugfixes:
+B123314 - fixed number of TERM related problems
+B123322 - fixed unwanted repetition in mng_readdisplay()
+B123443 - fixed by Ralph
+B124910 - fixed definition for WIN32_LEAN_AND_MEAN (thanks Chad)
+B125750 - fixed by Ralph
+B125756 - fixed mixup of data- & function-pointers (thanks Dimitri)
+B127517 - changed inclusion of the lcms header file for non-windows platforms
+
+core:
+- version numbers
+- fixed possible loop in display_resume() (Thanks Vova!)
+- fixed unwanted repetition in mng_readdisplay()
+- changed inclusion of the lcms header file for non-windows platforms
+- changed IHDR filter_method check for PNGs
+- moved restore of object 0 to libmng_display
+- added restore of object 0 to TERM processing (B123314)
+- fixed TERM delay processing (B123314)
+- fixed TERM end processing when count = 0 (B123314)
+- changed callback convention for MSVC (Thanks Chad)
+- fixed mixup of data- & function-pointers (thanks Dimitri)
+- added support for "nEED MNG-1.0"
+- added errorcode for MAGN methods
+- added errorchecking for MAGN methods
+- removed "old" MAGN methods 3 & 4
+- added "new" MAGN methods 3, 4 & 5
+- removed test filter-methods 1 & 65
+- set default level-set for filtertype=64 to all zeroes
+
+samples:
+
+contrib:
+- added GTK mng-view example by Vova Babin
+- added MSVC MNGview sample by Nikolaus Brennig
+- updated Jason Summer's mngplg to version 0.9.2
+ (that's mngplg-0.9.2 based on libmng-0.9.3 !!!)
+- rearranged contrib directory slightly
+- added MSVC project to build libmng.dll by Chad Austin
+
+doc:
+- added README.dll
+- added README.config
+
+makefiles:
+- added a makefile for MS Visual C++ (Thanks to Atsushi Matsuda)
+
+autoconf:
+- fixed configure.in for lcms (FreeBSD port by Mikhail Teterin)
+- by default configure includes CMS support if lcms is present
+
+-----------------------------------------------------------
+
+0.9.3 (October 29th 2000)
+-------------------------
+
+in short:
+
+Another beta release. The number of changes in the MNG specification have
+resulted in a lot of new code and some changed code. At the same time I saw
+no need to withhold some new functionality as it was pretty clear there was
+going to be another beta-round. If things go well, I'm going to try to release
+libmng 1.0.0 very shortly after this one.
+
+Many thanks to a lot of people for helping out, sending contributions, making
+suggestions and testing this little baby. This would get nowhere without YOU!!!
+
+- fixed bug 111300/117103
+- added workaround for faulty PhotoShop iCCP chunk
+- added MAGN/JDAA chunks
+- added support for new filter_types
+- added PNG/MNG spec version indicators
+- added BCB mngview contribution by Andy Protano
+- added BCB mngdump; a GUI-based MNG dumping utility (Andy Protano)
+- implemented support for nEED "draft nn"
+- implemented app-defined support for bKGD for PNG images
+- removed trace-options from default SO/DLL builds (!!!)
+- raised initial maximum canvas size to 10000x10000 (!!!)
+ (an App that wants to protect from overly large images should call
+ mng_set_maxcanvassize() with appropriate values)
+- fixed other assorted stuff
+
+-------------------
+
+bugfixes:
+B111300 - fixup for improved portability
+B117103 - fixed compilation errors on *nix with lcms (thanks Ralph!)
+
+core:
+- fixed compiler-warnings from Mozilla
+- added check for simplicity-bits in MHDR
+- added workaround for faulty PhotoShop iCCP chunk
+- fixed app-supplied background restore
+- fixed TERM processing delay of 0 msecs
+- fixed write-code for zTXt & iTXt
+- fixed read-code for iTXt
+- added MAGN chunk
+- fixed sRGB precedence for gamma_only corection
+- added support for new filter_types
+- fixed problem with no refresh after TERM
+- fixed DEFI behavior
+- fixed inclusion parameters to make the external libs work together
+- added export of zlib functions from windows dll
+- fixed timing & refresh behavior for single PNG/JNG
+- removed trace-options from default SO/DLL builds (!!!)
+- fixed MAGN rounding errors (thanks Matthias!)
+- fixed small timing problem when FRAM delay = 0
+- fixed simplicity-check in compliance with draft 81/0.98a
+- fixed alpha-blending for all alpha-canvasstyles
+- added support for alpha-depth prediction
+- fixed processing of unknown critical chunks
+- removed test-MaGN
+- added PNG/MNG spec version indicators
+- implemented support for nEED
+- added support for JDAA
+- added functions to retrieve PNG/JNG specific header-info
+- added optional support for bKGD for PNG images
+- raised initial maximum canvas size to 10000x10000
+- added support for delta-JNG
+- added callback to process non-critical unknown chunks
+- fixed support for delta-images during read() / display()
+- added closestream() processing for mng_cleanup()
+- fixed delta-processing behavior
+- added storage for pixel-/alpha-sampledepth for delta's
+- implemented delayed delta-processing
+- fixed putchunk_plte() to set bEmpty parameter (thanks Ben!)
+- added errorcode for delayed delta-processing
+- added get/set for bKGD preference setting
+- added get function for interlace/progressive display
+- fixed bug in empty PLTE handling
+- fixed seperate read() & display() processing
+- fixed tRNS processing for gray-image < 8-bits
+
+samples:
+- added BCB mngview contribution by Andy Protano
+
+contrib:
+- added BCB mngdump; a GUI-based MNG dumping utility (Andy Protano)
+
+doc:
+- updated RPM spec-file by MATSUURA Takanori
+- updated README.contrib
+
+makefiles:
+- fixed some stuff in automake/autoconf/libtool
+- fixed auto* for bug B117103
+
+-----------------------------------------------------------
+
+0.9.2 (August 7th 2000)
+-----------------------
+
+in short:
+
+Third beta release! Last one???
+
+!!IMPORTANT!! All file-names are now prefixed with "libmng_" !!IMPORTANT!!
+
+Many thanks to Albert Chin-A-Young for his contribution of the
+autoconf/automake/libtool stuff and to Ralph Giles for helping me
+put it in the right places.
+
+There's a special README.autoconf so please read it!
+
+- fixed bug 110320/110546/110547/111096
+- added several status retrieval functions
+- fixed other small bugs in display processing
+- fixed number of small problems and documentation typos
+- added autoconf/automake/libtool
+- added latest MNG plugin (0.9.0) by Jason Summers
+
+-------------------
+
+bugfixes:
+B110320 - fixed GCC warning about mix-sized pointer math
+B110546 - fixed for improperly returning UNEXPECTEDEOF
+B110547 - fixed bug in interlace code
+B111096 - fixed large-buffer read-suspension
+
+core:
+- version numbers
+- fixed small bugs in display processing
+- removed Nextbackxxx fields (no longer used)
+- fixed problem with trace-functions improperly wrapped
+- put specific code in add_chunk() inside MNG_SUPPORT_WRITE wrapper
+- fixed documentation typos
+- fixed wrapping of suspension parameters
+- added status_xxxx functions
+- added trace-codes/-strings for status_xxxxx functions
+- changed file-prefixes
+- added function to set simplicity field
+- added trace-code/-string for updatemngsimplicity
+- fixed putchunk_unknown() function
+
+samples:
+
+contrib:
+- added latest MNG plugin (0.9.0) by Jason Summers
+
+doc:
+- version numbers
+- added autoconf readme
+- version numbers in RPM stuff
+
+makefiles:
+- fixed for new file-prefix
+- added autoconf/automake/libtool
+
+-----------------------------------------------------------
+
+0.9.1 (July 26th 2000)
+----------------------
+
+in short:
+
+Second beta release.
+
+Given the enormous amount of bug-reports (not ;-), this will most likely
+be one of the last betas. If things remain upright, the first public release
+(1.0.0) is fairly eminent in the weeks to come...
+
+- added SDL mng player by Ralph Giles to contributions
+- fixed timing and added internal buffering for I/O-suspension scenarios
+- added get routines for internal display-state variables (frame/layer/playtime)
+- changed read-processing for improved I/O-suspension (internal buffering)
+- fixed several problems with create- & write-support
+- added a load of documentation
+- lots of small stuff
+
+-------------------
+
+bugfixes:
+
+core:
+- fixed mandatory BACK color to be opaque
+- changed mng_display_resume to allow to be called after a suspension
+ return with MNG_NEEDMOREDATA
+- changed comments to indicate modified behavior for timer & suspension breaks
+- added variables for go_xxxx processing
+- implemented support for freeze/reset/resume & go_xxxx
+- added trace-codes/-strings for special display processing
+- added variables for improved timing support
+- added support for improved timing
+- added get routines for internal display variables
+- added get/set routines for suspensionmode variable
+- added trace-code/-string for get/set suspensionmode
+- added trace-codes/-strings for get/set display variables
+- added support for improved I/O-suspension
+- changed read-processing for improved I/O-suspension
+- added trace-code/-string for read_databuffer (I/O-suspension)
+- added suspendbuffer constants
+- changed EOF processing behavior
+- fixed TERM delay processing
+- changed pre-draft48 frame_mode=3 to frame_mode=1
+- added callbacks for SAVE/SEEK processing
+- added trace-codes/-strings for SAVE/SEEK callbacks
+- added variable for NEEDSECTIONWAIT breaks
+- added trace-codes/-strings for get/set sectionbreaks
+- added NEEDSECTIONWAIT error-code/-string
+- added macro + routine to set returncode without calling error callback
+- added trace-code/-string for special error routine
+- changed default readbuffer size from 1024 to 4200
+- added variable for freeze & reset processing
+- fixed storage of images during mng_read()
+- fixed support for mng_display() after mng_read()
+- added error cleanup processing
+- fixed support for mng_display_reset()
+- fixed suspension-buffering for 32K+ chunks
+- added function to set frame-/layer-count & playtime
+- added trace-code/-string for updatemngheader
+- added error-code/-string for updatemngheader if not a MNG
+- fixed creation-code
+- fixed writing of signature
+- fixed several chunk-writing routines
+
+samples:
+- fixed the libmng.pas module in line with libmng.h
+
+contrib:
+- added the SDL based mngplay viewer by Ralph Giles
+
+doc:
+- extended the RPM contribution by MATSUURA Takanori
+- added libmng.txt, a full description of the library and its usage
+- added man-pages for mng(5), jng(5) and libmng(3)
+
+makefiles:
+
+-----------------------------------------------------------
+
+0.9.0 (June 30th 2000)
+----------------------
+
+in short:
+
+This is the first beta!!! Yippee!!!
+
+Thanks to all the people who helped to guide me in the right direction.
+You know who you are!
+
+A special thanks to the guys with early implementations, who stood by and
+put up with my whims :-)
+
+changes over 0.5.3:
+
+- updated mngplg to 0.4.1 (the latest & greatest)
+- changed refresh parameters to 'x,y,width,height'
+
+-----------------------------------------------------------
+
+0.5.3 (never released)
+----------------------
+
+in short:
+
+This is a working version only; the next release will be 0.9.0 (first Beta!)
+
+There are a few incompatible changes with previous versions. The userdata
+variable has been changed from mng_uint32 to mng_ptr to accomodate 64-bit
+systems. For the same reason memory allocation size parameters have been
+changed to a mng_size_t type which is a typedef of size_t.
+
+Thanks to Aleks Jakulin for helping to iron out some 64-bit platform issues!
+
+- implemented the update-region parameters of the refresh callback
+- added support for most common delta-image options
+- added an animation-speed modifier
+- added an image-level parameter for the processtext callback
+- updated mngplg to 0.4.0 (supports JNG, full CMS, and other enhancements!)
+- fixed a lot of small things
+- added support for PPLT chunk
+- fixed to support 64-bit platforms
+
+-------------------
+
+bugfixes:
+
+core:
+- added processing of color-info on delta-image
+- fixed handling of empty SAVE chunk
+- fixed display of stored JNG images
+- fixed problem with BASI-IEND as object 0
+- changed the version parameters (obviously)
+- added update-region parms for refresh calback
+- added Needrefresh parameter
+- added initialization of update-region for refresh
+- added initialization of Needrefresh parameter
+- changed progressive-display processing
+- added tracecodes for tracing JPEG progression
+- added tracing of JPEG calls
+- added Deltaimmediate parm for faster delta-processing
+- added extra checks for delta-images
+- many changes to support delta-images
+- optimized some store_xxx routines
+- fixed some small things (as precaution)
+- fixed possible trouble if IEND display-processing got broken up
+- fixed nasty bug with embedded PNG after delta-image
+- added processing of PLTE & tRNS for delta-images
+- added processing of PLTE/tRNS & color-info for delta-images in the
+ ani_objects chain
+- fixed problem with color-correction for stored images
+- added get/set for speedtype to facilitate testing
+- added trace-codes & -strings for get/set speedtype
+- added speed-modifier to timing routine
+- added get-routine of imagelevel for processtext callback
+- added trace-code & -string for get imagelevel
+- added administration of imagelevel parameter
+- added support for PPLT chunk
+- added trace-codes & -strings for PPLT chunk processing
+- fixed problem with incorrect gamma-correction
+- fixed inclusion of IJG read/write code
+- fixed problem with 16-bit GA format
+- fixed problem with cheap transparency for 4-bit gray
+- fixed display_xxxx routines for interlaced images
+- added precaution against faulty iCCP chunks from PS
+- changed userdata variable to mng_ptr
+- added typedef for mng_size_t
+- changed size parameter for memory allocation to mng_size_t
+- fixed compiler-warning for non-initialized iB variable
+- changed definition for 32-bit ints (64-bit platforms)
+- changed definition for mng_handle (64-bit platforms)
+- swapped refresh parameters
+- fixed initialization routine for new mng_handle type
+- added inclusion of stdlib.h for abs()
+- fixed some 64-bit warnings
+- fixed incompatible return-types
+
+samples:
+
+contrib:
+- updated mngplg to 0.3.0 (supports JNG & full color-correction!)
+- updated mngplg to 0.4.0 (Jason is picking up the pace ;-)
+
+doc:
+- added rpm directory with rpm spec-file (contributed by MATSUURA Takanori)
+
+makefiles:
+- changed makefile.linux to reflect versionnr for shared-lib
+- changed makefile.linux to depend on mng_conf.h & mng_types.h
+
+-----------------------------------------------------------
+
+0.5.2 (June 10th 2000)
+----------------------
+
+in short:
+
+This is the third release for developers
+Another milestone since JNG is now fully supported
+The next release will most likely be numbered 0.9.0 as the first Beta!!
+
+Fixed bug 106017 & 106019
+Added many constants regarding chunk-property values
+Implemented full JNG support
+Added all the error- & trace-strings
+Added get/set routines for default ZLIB/IJG parameters
+Added a generic makefile for Unix platforms (contributed by Tim Rowley)
+Added canvasstyle for separate RGB + A canvas (eg. mozilla-style)
+Separated configuration-options into a separate file: "mng_conf.h"
+Fixed stuff for generic Unix compilation (contributed by Tim Rowley)
+Upgraded to lcms1.0.6 (now supports 16-bit endian-peculiarities)
+Added a makefile for Linux ELF & fixed some code-issues to go along with gcc
+Added support for suspended input-buffer processing
+Implemented the display-routines for RGBA/ARGB/BGRA/ABGR canvasstyles
+Implemented the application background-restore functionality
+Fixed & tested the mngtree Unix-sample (runs on Linux-RH6.2 with libmng.so)
+Upgraded mngplg to v0.2.2 (based on the latest code including JNG)
+Fixed a lot of other assorted stuff
+
+-------------------
+
+bugfixes:
+B003(106017) - fixed problem with <mem.h> being proprietary to BCB
+B004(106019) - fixed problem when MNG_SUPPORT_WRITE not defined
+
+core:
+- bumped version-numbers up to 0.5.2 (yeah, really)
+- fixed support for IJGSRC6B
+- cleaned up some code regarding mixed support-options
+- complemented constants for chunk-property values
+- fixed MNG_UINT_pHYg value
+- implemented JNG support
+- fixed problem with DEFI clipping
+- added error telltale strings & support
+- added trace telltale strings & support
+- added support for global color-chunks inside TERM/LOOP
+- added support for global PLTE,tRNS,bKGD inside TERM/LOOP
+- added default IJG compression parameters and such
+- moved init of default zlib parms to "mng_hlapi.c"
+- added init of default IJG parms
+- added support for get/set of zlib/IJG default parms
+- added tracestrings for global animation color-chunks
+- added tracestrings for get/set of default ZLIB/IJG parms
+- added tracestrings for global PLTE,tRNS,bKGD
+- added framenr/layernr/playtime to object header
+- added initialization of framenr/layernr/playtime
+- changed ani_create calls not returning object pointer
+- create ani objects always (not just inside TERM/LOOP)
+- fixed inconsistancy with freeing global iCCP profile
+- fixed minor bugs 16-bit pixel-handling
+- added object promotion routine (PROM handling)
+- added trace-codes & -strings for image-object promotion
+- added trace-codes & -strings for delta-image processing
+- added error-codes & -strings for delta-image processing
+- added support for delta-image processing
+- added ani-object routines for delta-image processing
+- added delta-image fields
+- added compression/filter/interlace fields to object-buffer for
+ delta-image processing
+- added delta-image row-processing routines
+- fixed up punctuation in several files (contributed by Tim Rowley)
+- removed useless definition in "mng_chunks.h" (contributed by Tim Rowley)
+- fixed pointer confusion in "mng_display.c" (contributed by Tim Rowley)
+- fixed inclusion for memcpy (contributed by Tim Rowley)
+- added mng_int32p (contributed by Tim Rowley)
+- added internal delta-image processing callbacks
+- separated configuration-options into "mng_conf.h"
+- changed to most likely configuration
+- added RGB8_A8 canvasstyle
+- added getalphaline callback for RGB8_A8 canvasstyle
+- fixed some makeup for Linux gcc compile
+- implemented app bkgd restore routines
+- implemented RGBA8, ARGB8, BGRA8 & ABGR8 display routines
+- added support for RGB8_A8 canvasstyle
+- added support for suspended input-buffer processing
+- added mng_read_resume HLAPI function to support read-suspension
+- fixed timer-handling to run with Mozilla (Tim Rowley)
+- fixed alpha-handling for alpha canvasstyles
+- fixed some compilation-warnings (contrib Jason Morris)
+
+samples:
+- fixed mngview(delphi) to work with the new core
+- synchronized libmng.pas(delphi) with the new libmng.h header
+- removed the error- & trace-strings from libmng.pas(delphi)
+- fixed mngtree(Unix) to compile on Linux (runs with libmng.so)
+- added makefile.linux for mngtree(Unix) (tested on RedHat6.2)
+
+contrib:
+- updated mngplg to 0.2.2 (based on latest code; supports JNG!)
+
+doc:
+- this file obviously
+- added Tim Rowley as contributing author
+- changed the examples.readme doc
+- updated the design-schematics in line with the current code
+
+makefiles:
+- changed the directory to "makefiles" to avoid name-conflicts
+- added generic Unix makefile (thanks to Tim Rowley)
+- added Linux ELF makefile (tested on RedHat6.2)
+
+-----------------------------------------------------------
+
+0.5.1 May 16th 2000
+-------------------
+
+in short:
+
+This is the second release for developers
+It's a bit of a milestone since all the chunk functionality is in place and
+functioning (read, examine, create & write)
+This version is incompatible with 0.5.0 since some of the callback prototypes
+have changed (should be the last time that happens!)
+There are a few more samples and even a real contribution!
+
+Fixed bug 105795 & 105797
+Fixed a mis-alignment in animation-timing
+Added chunk-access functions
+Finished all chunk-storage routine-bits
+Finished all chunk-write routines
+Changed the callback prototypes to allow error-reporting back to the library
+Fixed some routines to allow for callback error-reporting
+Added version-control functions & constants
+Added two functions to set display- & sRGB-profile from memory
+Moved CRC table to dynamic structure (for improved thread-safety)
+Added SAVE & SEEK save&restore functionality
+Finished the application-based CMS-callbacks
+Fixed a few BCB specifics
+Changed the Win32 DLL and samples to use __stdcall
+Did some more assorted little changes
+Added 2 BCB samples
+Added 1 Unix sample
+Added the MNG plugin by Jason Summers in the contrib section
+Changed some documents to reflect these changes
+
+-------------------
+
+bugfixes:
+B001(105795) - fixed wrong lcms call & memory-leak for gammatables
+B002(105797) - fixed problem with missing sRGB profile
+
+core:
+- changed chunk iteration function
+- added chunk access functions
+- added version control constants & functions
+- changed strict-ANSI stuff
+- added set_outputprofile2 & set_srgbprofile2
+- added empty-chunk put-routines
+- added version_dll & VERSION_DLL (for consistency)
+- added version control explanatory text & samples
+- added iteratechunk callback definition
+- improved definitions for DLL support
+- added 8-bit palette definition
+- added general array definitions
+- added MNG_NULL definition
+- changed most callback prototypes to allow the app
+ to report errors during callback processing
+- added CRC table to main structure (for thread-safety)
+- added iPLTEentries for checking hIST-length
+- changed palette definition to exported palette-type
+- removed frozen indicator
+- added create/write indicators
+- added eMNGma hack (will be removed in 1.0.0 !!!)
+- added TERM animation object pointer (easier reference)
+- added saved-data structure for SAVE/SEEK processing
+- added some errorcodes
+- added application errorcodes (used with callbacks)
+- moved chunk-access errorcodes to severity 5
+- added chunk-access function trace-codes
+- changed trace to macro for callback error-reporting
+- added save_state & restore_state trace-codes
+- put in some extra comments
+- fixed layout for sBIT, PPLT
+- changed write callback definition
+- fixed layout for PPLT again (missed deltatype ?!?)
+- cleaned up left-over teststuff in the BACK chunk routine
+- changed CRC initialization to use dynamic structure
+ (wasn't thread-safe the old way !)
+- filled in many missing sequence&length checks
+- filled in many missing chunk-store snippets
+- added checks for running animations
+- filled remaining write routines
+- fixed read_pplt with regard to deltatype
+- added callback error-reporting support
+- added pre-draft48 support (short MHDR, frame_mode, LOOP)
+- fixed chunk-storage bit in several routines
+- supplemented the SAVE & SEEK display processing
+- added init of iPLTEcount
+- changed calling-convention definition
+- changed status-handling of display-routines
+- added versioning-control routines
+- filled the write routine
+- fixed frame_delay misalignment
+- added sanity check for frozen status
+- changed display_mend to reset state to initial or SAVE
+- added save_state and restore_state for SAVE/SEEK/TERM
+ processing
+- added process_save & process_seek routines
+- changed and filled iterate-chunk function
+- added getchunk functions
+- added putchunk functions
+- added empty-chunk put-routines
+- filled application-based color-management routines
+- added creatememprofile
+- filled the deflatedata routine
+- added cleanup of saved-data (SAVE/SEEK processing)
+- moved the actual write_graphic functionality from mng_hlapi.c
+ to it's appropriate function in the mng_write.c module
+- moved standard header includes into mng_types.h
+ (stdlib/mem for mem-mngmt & math for fp gamma-calc)
+- added getimgdata & putimgdata functions
+
+samples:
+- fixed mngview(delphi) to work with the new core
+- synchronized libmng.pas(delphi) with the new libmng.h header
+- added mngtree(bcb) sample
+- added bogus(bcb) sample
+- added mngtree(unix) sample
+
+contrib:
+- added mngplg 0.1.0 / a MNG plugin for Win32 by Jason Summers
+
+doc:
+- added this changes.readme file
+- changed the samples.readme doc accordingly
+- changed the contrib.readme doc accordingly
+
+-----------------------------------------------------------
+
+0.5.0 May 1st 2000
+------------------
+
+in short:
+
+This is the first developers release.
+It's roughly about 60% done.
diff --git a/src/3rdparty/libmng/LICENSE b/src/3rdparty/libmng/LICENSE
new file mode 100644
index 0000000000..2b624c00a7
--- /dev/null
+++ b/src/3rdparty/libmng/LICENSE
@@ -0,0 +1,57 @@
+/* ************************************************************************** */
+/* * * */
+/* * COPYRIGHT NOTICE: * */
+/* * * */
+/* * Copyright (c) 2000-2007 Gerard Juyn (gerard@libmng.com) * */
+/* * [You may insert additional notices after this sentence if you modify * */
+/* * this source] * */
+/* * * */
+/* * For the purposes of this copyright and license, "Contributing Authors" * */
+/* * is defined as the following set of individuals: * */
+/* * * */
+/* * Gerard Juyn * */
+/* * Glenn Randers-Pehrson * */
+/* * * */
+/* * The MNG Library is supplied "AS IS". The Contributing Authors * */
+/* * disclaim all warranties, expressed or implied, including, without * */
+/* * limitation, the warranties of merchantability and of fitness for any * */
+/* * purpose. The Contributing Authors assume no liability for direct, * */
+/* * indirect, incidental, special, exemplary, or consequential damages, * */
+/* * which may result from the use of the MNG Library, even if advised of * */
+/* * the possibility of such damage. * */
+/* * * */
+/* * Permission is hereby granted to use, copy, modify, and distribute this * */
+/* * source code, or portions hereof, for any purpose, without fee, subject * */
+/* * to the following restrictions: * */
+/* * * */
+/* * 1. The origin of this source code must not be misrepresented; * */
+/* * you must not claim that you wrote the original software. * */
+/* * * */
+/* * 2. Altered versions must be plainly marked as such and must not be * */
+/* * misrepresented as being the original source. * */
+/* * * */
+/* * 3. This Copyright notice may not be removed or altered from any source * */
+/* * or altered source distribution. * */
+/* * * */
+/* * The Contributing Authors specifically permit, without fee, and * */
+/* * encourage the use of this source code as a component to supporting * */
+/* * the MNG and JNG file format in commercial products. If you use this * */
+/* * source code in a product, acknowledgment would be highly appreciated. * */
+/* * * */
+/* ************************************************************************** */
+/* * * */
+/* * Parts of this software have been adapted from the libpng package. * */
+/* * Although this library supports all features from the PNG specification * */
+/* * (as MNG descends from it) it does not require the libpng package. * */
+/* * It does require the zlib library and optionally the IJG jpeg library, * */
+/* * and/or the "little-cms" library by Marti Maria (depending on the * */
+/* * inclusion of support for JNG and Full-Color-Management respectively. * */
+/* * * */
+/* * This library's function is primarily to read and display MNG * */
+/* * animations. It is not meant as a full-featured image-editing * */
+/* * component! It does however offer creation and editing functionality * */
+/* * at the chunk level. * */
+/* * (future modifications may include some more support for creation * */
+/* * and or editing) * */
+/* * * */
+/* ************************************************************************** */
diff --git a/src/3rdparty/libmng/README b/src/3rdparty/libmng/README
new file mode 100644
index 0000000000..a8e67cad53
--- /dev/null
+++ b/src/3rdparty/libmng/README
@@ -0,0 +1,36 @@
+libmng 1.0.10
+-------------
+
+Added provisional ANG and anIM support, and made some minor bugfixes.
+
+libmng 1.0.9
+------------
+
+A number of optimizations in the chunk handling and reader/writer code.
+This saves over 20KB on binary footprint!
+
+Also several bugfixes and a couple of patches bring it another step
+closer to perfection.... :-)
+
+See CHANGELOG for details.
+
+
+Y.T.
+
+Gerard
+
+
+For more information please visit:
+
+The official libmng web-site:
+ http://www.libmng.com/
+
+Libmng's community on SourceForge:
+ https://sourceforge.net/project/?group_id=5635
+
+The official MNG homepage:
+ http://www.libpng.org/pub/mng/
+
+The official PNG homepage:
+ http://www.libpng.org/pub/png/
+
diff --git a/src/3rdparty/libmng/README.autoconf b/src/3rdparty/libmng/README.autoconf
new file mode 100644
index 0000000000..753f7b4fde
--- /dev/null
+++ b/src/3rdparty/libmng/README.autoconf
@@ -0,0 +1,213 @@
+**********************************************************************
+**********************************************************************
+
+ ***** this is unmaintained *****
+
+If you happen to find problems with autoconfiguration and building,
+I simply cannot help you. I'm looking for a maintainer that doesn't mind
+spending a few minutes every now and then on the next release to make sure
+things are still in working order.
+
+For the moment all autoconf stuff ahs been moved into unmaintained!!
+
+**********************************************************************
+**********************************************************************
+
+
+
+
+Configuration from CVS
+======================
+
+If you're using source checked out from CVS, rather than a source
+distribution tarball, please be aware that you can use ./autogen.sh in
+place of ./configure below.
+
+Because this is a cross-platform project, the source templates for
+the autoconf scripts are sequestered in the 'makefiles' directory.
+Running './autogen.sh' will copy them into their conventional places at
+the lop level. If you already see the files there, you don't need to
+worry about this step.
+
+Basic Installation
+==================
+
+ These are generic installation instructions.
+
+ The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation. It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions. Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, a file
+`config.cache' that saves the results of its tests to speed up
+reconfiguring, and a file `config.log' containing compiler output
+(useful mainly for debugging `configure').
+
+ If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release. If at some point `config.cache'
+contains results you don't want to keep, you may remove or edit it.
+
+ The file `configure.in' is used to create `configure' by a program
+called `autoconf'. You only need `configure.in' if you want to change
+it or regenerate `configure' using a newer version of `autoconf'.
+
+The simplest way to compile this package is:
+
+ 1. `cd' to the directory containing the package's source code and type
+ `./configure' to configure the package for your system. If you're
+ using `csh' on an old version of System V, you might need to type
+ `sh ./configure' instead to prevent `csh' from trying to execute
+ `configure' itself.
+
+ Running `configure' takes awhile. While running, it prints some
+ messages telling which features it is checking for.
+
+ 2. Type `make' to compile the package.
+
+ 3. Optionally, type `make check' to run any self-tests that come with
+ the package.
+
+ 4. Type `make install' to install the programs and any data files and
+ documentation.
+
+ 5. You can remove the program binaries and object files from the
+ source code directory by typing `make clean'. To also remove the
+ files that `configure' created (so you can compile the package for
+ a different kind of computer), type `make distclean'. There is
+ also a `make maintainer-clean' target, but that is intended mainly
+ for the package's developers. If you use it, you may have to get
+ all sorts of other programs in order to regenerate files that came
+ with the distribution.
+
+Compilers and Options
+=====================
+
+ Some systems require unusual options for compilation or linking that
+the `configure' script does not know about. You can give `configure'
+initial values for variables by setting them in the environment. Using
+a Bourne-compatible shell, you can do that on the command line like
+this:
+ CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
+
+Or on systems that have the `env' program, you can do it like this:
+ env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
+
+Compiling For Multiple Architectures
+====================================
+
+ You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory. To do this, you must use a version of `make' that
+supports the `VPATH' variable, such as GNU `make'. `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script. `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+ If you have to use a `make' that does not supports the `VPATH'
+variable, you have to compile the package for one architecture at a time
+in the source code directory. After you have installed the package for
+one architecture, use `make distclean' before reconfiguring for another
+architecture.
+
+Installation Names
+==================
+
+ By default, `make install' will install the package's files in
+`/usr/local/bin', `/usr/local/man', etc. You can specify an
+installation prefix other than `/usr/local' by giving `configure' the
+option `--prefix=PATH'.
+
+ You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files. If you
+give `configure' the option `--exec-prefix=PATH', the package will use
+PATH as the prefix for installing programs and libraries.
+Documentation and other data files will still use the regular prefix.
+
+ In addition, if you use an unusual directory layout you can give
+options like `--bindir=PATH' to specify different values for particular
+kinds of files. Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+ If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+ Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System). The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+ For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+ There may be some features `configure' can not figure out
+automatically, but needs to determine by the type of host the package
+will run on. Usually `configure' can figure that out, but if it prints
+a message saying it can not guess the host type, give it the
+`--host=TYPE' option. TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name with three fields:
+ CPU-COMPANY-SYSTEM
+
+See the file `config.sub' for the possible values of each field. If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the host type.
+
+ If you are building compiler tools for cross-compiling, you can also
+use the `--target=TYPE' option to select the type of system they will
+produce code for and the `--build=TYPE' option to select the type of
+system on which you are compiling the package.
+
+Sharing Defaults
+================
+
+ If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists. Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Operation Controls
+==================
+
+ `configure' recognizes the following options to control how it
+operates.
+
+`--cache-file=FILE'
+ Use and save the results of the tests in FILE instead of
+ `./config.cache'. Set FILE to `/dev/null' to disable caching, for
+ debugging `configure'.
+
+`--help'
+ Print a summary of the options to `configure', and exit.
+
+`--quiet'
+`--silent'
+`-q'
+ Do not print messages saying which checks are being made. To
+ suppress all normal output, redirect it to `/dev/null' (any error
+ messages will still be shown).
+
+`--srcdir=DIR'
+ Look for the package's source code in directory DIR. Usually
+ `configure' can determine that directory automatically.
+
+`--version'
+ Print the version of Autoconf used to generate the `configure'
+ script, and exit.
+
+`configure' also accepts some other, not widely useful, options.
diff --git a/src/3rdparty/libmng/README.config b/src/3rdparty/libmng/README.config
new file mode 100644
index 0000000000..d5cd4541d0
--- /dev/null
+++ b/src/3rdparty/libmng/README.config
@@ -0,0 +1,104 @@
+Configuration options in libmng
+===============================
+
+The library is fairly configurable through the use of a number of defines.
+Please note however that certain defines are for internal use only.
+The following list gives a summary of options that can be used externally to
+define the functionality of the library:
+
+========================================
+
+#define MNG_BUILD_DLL
+
+This is used to indicate that a "standard" DLL should result from compiling
+the library. Please note the remarks in README.dll if you intend to work
+with the library as a DLL. The purpose of this option is to ensure that
+DLL builds have the same set of functions.
+
+#define MNG_BUILD_SO
+
+This is used to indicate that a "standard" shared library (SO) should result
+from a compilation. The purpose of this option is to ensure that all
+shared libraries generated this way will have the same set of functions.
+
+#define MNG_USE_DLL / #define MNG_USE_SO
+
+These should be used when including the library header in the compilation
+of an application to indicate that the compiler/linker must take the
+necessary steps to make the binary executable to use the standard DLL
+or shared library (SO).
+
+#define MNG_SKIP_ZLIB / #define MNG_SKIP_LCMS / #define MNG_SKIP_IJG6B
+
+Use these in conjunction with MNG_USE_DLL / MNG_USE_SO. This is useful if
+you only need the external definitions of the MNG library and not the others,
+which will speed up the compilation process.
+
+#define MNG_SUPPORT_FULL / #define MNG_SUPPORT_LC / #define MNG_SUPPORT_VLC
+
+These can be used to indicate the level of MNG spec compliance required.
+Currently only full MNG compliance is supported.
+
+#define MNG_SUPPORT_IJG6B
+
+This can be used to indicate if JNG support is required. This option will
+include the IJG JPEG-library. Note that MNG_SUPPORT_FULL will automatically
+set this option. Use this only if you need JNG support with MNG-(V)LC.
+
+#define MNG_FULL_CMS / #define MNG_GAMMA_ONLY / #define MNG_NO_CMS /
+#define MNG_APP_CMS
+
+These indicate the color-correction support level of the library.
+If you are on a platform that supports lcms (Little CMS by Marti Maria Saguar)
+then it is highly recommended to define MNG_FULL_CMS.
+If your platform has it's own CMS then select MNG_APP_CMS and be sure to
+include the appropriate callbacks in your app.
+In all other cases it is recommended to define MNG_GAMMA_ONLY.
+
+#define MNG_SUPPORT_READ / #define MNG_SUPPORT_WRITE /
+#define MNG_SUPPORT_DISPLAY
+
+These indicate the high-level support for reading, writing and/or
+displaying files. Note that in order to display a file, you'll need to read
+it first. (yes, really!)
+
+#define MNG_STORE_CHUNKS
+
+This indicates that the library should store chunk-information when reading
+a file. This information can then be processed through the
+MNG_ITERATE_CHUNKS() function. Note that you must specify this option if
+you want to create and write a new file.
+
+#define MNG_ACCESS_CHUNKS
+
+This is used to indicate that the app may need access to internally stored
+chunk information. MNG_STORE_CHUNKS must be defined as well for this option
+to function properly.
+
+#define MNG_INTERNAL_MEMMNGMT
+
+You can use this to have the library handle it's own memory allocation and
+deallocation through the "standard" memory functions. This option is turned
+off by default, which means your app must define the memory callbacks.
+
+#define MNG_ERROR_TELLTALE
+
+Set this on to allow human-readable error-messages to be included in the
+library and the error function and callback.
+
+#define MNG_BIGENDIAN_SUPPORTED
+
+This option should be used to indicate the hardware is based on big endian
+integers.
+
+#define MNG_SUPPORT_TRACE / #define MNG_TRACE_TELLTALE
+
+These two can be used when debugging an app. You'll need to have the trace
+callback setup also. This allows for a rather thorough investigation of the
+libraries function paths.
+
+========================================
+
+Any other optional defines you may encounter are for internal use only.
+please do not specify them externally. In case of doubt, consult the
+support email lists. More info can be found on http://www.libmng.com
diff --git a/src/3rdparty/libmng/README.contrib b/src/3rdparty/libmng/README.contrib
new file mode 100644
index 0000000000..9b287532a4
--- /dev/null
+++ b/src/3rdparty/libmng/README.contrib
@@ -0,0 +1,95 @@
+The contrib directory contains contributions made by fellow
+enthousiasts. (Check respective web-sites for the latest version)
+
+----------------------------------------------------------------------
+
+mngplg - A Netscape plugin for MNG - by Jason Summers
+
+http://pobox.com/~jason1/imaging/mngplg/
+
+The very first contribution, and what a start!
+GIF look out, MNG is on the prowl and ready to swat you like a fly!
+
+----------------------------------------------------------------------
+
+mngplay - An SDL based MNG viewer - by Ralph Giles
+
+http://snow.ashlu.bc.ca/~giles/mng/
+
+Another nice contribution. View MNG files on practically any platform
+with this standalone viewer.
+Source-code only; Requires SDL library and libmng.so
+
+(Modified by Greg Roelofs)
+
+----------------------------------------------------------------------
+
+mngview - A BCB port of the Delphi sample - by Andy Protano
+
+I have added this nice little port to the BCB samples directory.
+It adds a nifty progressbar while reading a file. Excellent work!
+Requires libmng.dll
+(note: this is in the BCB samples directory)
+
+----------------------------------------------------------------------
+
+mngdump - A BCB GUI-based dump utility - by Andy Protano
+
+Andy has sent me this fully functional MNG dump utility, that gives
+detailed information of the contents of any MNG file.
+Requires libmng.dll
+
+----------------------------------------------------------------------
+
+mng-view - A GTK-based MNG viewer - by Vova Babin
+
+Vova has been hacking away with the libmng code and has come up with
+this nice little sample how to write a MNG viewer using GTK.
+Thanks mate!
+Source-code only
+Requires GTK+ (1.2 or higher) and libmng (0.9.2 or higher)
+
+(Modified by Greg Roelofs)
+
+----------------------------------------------------------------------
+
+mngview - Another MNG viewer; this one for MSVC - by Nicholaus Brennig
+
+A welcome contribution from Nicholaus. Author of SlowView. A very nice
+image-handling utility for Windows. A welcome contribution since there
+have been numerous questions about linking libmng with MSVC.
+Well, look no further. Here it is!
+
+----------------------------------------------------------------------
+
+MSVC libmng project - An MSVC project to build libmng.dll
+ - by Chad Austin
+
+Chad has contributed some project-files that you could use to build
+libmng.dll with MSVC. Please be sure to read the README file included.
+
+----------------------------------------------------------------------
+
+fbmngplay - A simple fbcon based mng player - by Stefan Reinauer
+
+Stefan has contributed this little example, based on Ralph's
+SDL player. It uses the kernel framebuffer device to display mng
+animations through the libmng interface.
+(currently for 16-bit buffers only)
+
+----------------------------------------------------------------------
+
+xmngview - Lesstif/Motif standalone player for MNG files
+ - by Winfried Szukalski
+
+Winfried contributed this MNG player for X-based systems.
+(recently updated)
+
+----------------------------------------------------------------------
+
+makemng - A delta-MNG creation utility for MSVC - by Alex Volkov
+
+Alex sent me this nice utility that will allow you to create highly
+optmized MNGs using the delta-PNG capabilities of MNG.
+
+----------------------------------------------------------------------
diff --git a/src/3rdparty/libmng/README.dll b/src/3rdparty/libmng/README.dll
new file mode 100644
index 0000000000..2f779e81a4
--- /dev/null
+++ b/src/3rdparty/libmng/README.dll
@@ -0,0 +1,41 @@
+Standard Windows DLL
+====================
+
+The DLL provided in the BCB/win32dll directory is meant as the sole candidate
+for distributions, based on libmng.dll, that install the DLL into the public
+Windows system-directory. The outline herein defines the requirements to
+which such a distribution must comply. If you cannot comply with these
+requirements please install the dll in the same directory as your application
+and NOT in the Windows system-directory!!!
+
+
+1) Only the DLL already assembled in the libmng distribution may be used for
+ other distributions!
+
+2) Only stable public releases are eligible for distribution! A public release
+ is one where the y-value of the x.y.z version-code is an even number.
+ Eg. 1.0.0, 1.2.1, 2.4.7, etc.
+
+3) The installation program MUST store the DLL in the Windows system-directory!
+ Eg. C:\WinNT\System32, C:\Windows98\System
+ (Note: InstallShield users can use the <SYSDIR> variable)
+
+3) The installation program MUST flag the file as a shared library!
+
+4) The installation program MUST NOT install the DLL if a newer version
+ already exists in the Windows system-directory! The standard DLL provided
+ contains the Windows-default version-numbering system. PLEASE USE IT!!
+ DO NOT rely on the date or size of the files.
+
+5) An uninstall procedure MAY NOT remove the DLL if other applications are
+ still linked to it! Proper handling as a shared library is imperitive.
+
+6) TEST IT, TEST IT, TEST IT!!! (I just can't stress this enough)
+ If you don't have enough time, let someone else test it BEFORE you
+ distribute!
+
+
+The penalty for violating these rules is inclusion of your name in the list
+of endangered but useless species (just below the GIF entry!), and on my
+blacklist. YOU HAVE BEEN FOREWARNED!
+
diff --git a/src/3rdparty/libmng/README.examples b/src/3rdparty/libmng/README.examples
new file mode 100644
index 0000000000..1ba94c1404
--- /dev/null
+++ b/src/3rdparty/libmng/README.examples
@@ -0,0 +1,48 @@
+The samples are in platform-specific directories.
+
+!!! contributions are very welcome !!!
+
+
+bcb - Borland C++ Builder (3.0) (found under bcb/xxx)
+-----------------------------------------------------
+
+win32dll - sample project to create a Windows dll. Requires zlib1.2.1,
+ IJG jpgsrc6b and lcms1.0.14. The directories containing these
+ libraries must be at the same level as the libmng directory.
+ So if you're in the directory with this file and the libmng
+ sources, they should be in ..\zlib , ..\jpgsrc6b and ..\lcms
+ respectively.
+
+!!! To run the other Win32 samples you need to copy the libmng.dll
+ file from here into the sample's directory !!!
+
+mngtree - sample project to create a little command-line tool that dumps
+ the chunk-structure of a given file onto stdout.
+
+bogus - a completely bogus example on how to create a perfectly valid
+ (though slightly biased) MNG.
+
+mngview - port of the Delphi mngview sample. contributed by Andy Protano.
+ see also README.contrib
+
+mngrepair- an example on how to fix invalid MNG files
+ uses the new mng_copy_chunks() function and MNG_SOFTERRORS to
+ 'ignore' certain input-errors. This conditional *MUST* only be used
+ for exactly this kind of software; eg. repair utilities.
+
+
+delphi - Borland Delphi (3.0+) (found under contrib/delphi/xxx)
+---------------------------------------------------------------
+
+mngview - sample project for a simple mng-viewer. The general unit in
+ the delphi directory was translated from libmng.h It can be
+ used in other projects to access libmng.dll created with the
+ win32dll example above.
+
+
+unix - Unix (found under contrib/gcc/xxx)
+-----------------------------------------
+
+mngtree - basically a copy of the BCB sample. It includes a makefile for
+ Linux and it's been tested on RedHat6.2
+
diff --git a/src/3rdparty/libmng/README.footprint b/src/3rdparty/libmng/README.footprint
new file mode 100644
index 0000000000..34dba7f180
--- /dev/null
+++ b/src/3rdparty/libmng/README.footprint
@@ -0,0 +1,46 @@
+/*
+ You can use one or more of the following defines to
+ reduce the size of the compiled library. Define the
+ SKIPCANVAS macros for any canvas configurations that
+ your application doesn't use. Define the SKIPCHUNK
+ macros for any chunks that your application doesn't
+ process. Define MNG_OPTIMIZE_FOOTPRINT to choose
+ smaller code size over faster execution and less memory
+ usage. These macros became available in version 1.0.6.
+*/
+
+/* eliminate unused features from libmng */
+#define MNG_OPTIMIZE_FOOTPRINT
+#define MNG_OPTIMIZE_OBJCLEANUP
+#define MNG_OPTIMIZE_CHUNKINITFREE
+#define MNG_OPTIMIZE_CHUNKASSIGN
+#define MNG_OPTIMIZE_CHUNKREADER
+
+#define MNG_SKIPCANVAS_ABGR8
+#define MNG_SKIPCANVAS_ARGB8
+#define MNG_SKIPCANVAS_BGR8
+#define MNG_SKIPCANVAS_BGRA8
+#define MNG_SKIPCANVAS_BGRA8_PM
+#define MNG_SKIPCANVAS_BGRX8
+#define MNG_SKIPCANVAS_RGBA8
+#define MNG_SKIPCANVAS_BGR565
+#define MNG_SKIPCANVAS_RGB565
+#define MNG_SKIPCANVAS_BGRA565
+#define MNG_SKIPCANVAS_RGBA565
+
+#define MNG_SKIPCHUNK_iCCP
+#define MNG_SKIPCHUNK_tEXt
+#define MNG_SKIPCHUNK_zTXt
+#define MNG_SKIPCHUNK_iTXt
+#define MNG_SKIPCHUNK_bKGD
+#define MNG_SKIPCHUNK_pHYs
+#define MNG_SKIPCHUNK_sBIT
+#define MNG_SKIPCHUNK_sPLT
+#define MNG_SKIPCHUNK_hIST
+#define MNG_SKIPCHUNK_tIME
+#define MNG_SKIPCHUNK_eXPI
+#define MNG_SKIPCHUNK_fPRI
+#define MNG_SKIPCHUNK_nEED
+#define MNG_SKIPCHUNK_pHYg
+
+
diff --git a/src/3rdparty/libmng/README.packaging b/src/3rdparty/libmng/README.packaging
new file mode 100644
index 0000000000..da0db3e7bb
--- /dev/null
+++ b/src/3rdparty/libmng/README.packaging
@@ -0,0 +1,24 @@
+Packaging Libmng for distribution
+---------------------------------
+
+These are some notes for those building binaries for distribution.
+
+We're interested to hear about anywhere libmng is helpful, so let us
+know if you're including it with your application or OS. Also, if your
+build is publicly accessible, we'd be happy to link to it from
+the libmng site.
+
+However, We respectfully request that you *not* distribute binaries as a
+shared library (DLL) with any of the major features disabled. While
+there is support for this in terms of #ifdef directives (in
+libmng_conf.h) and autoconf switches they are intended for embedded
+application and testing. The default compilation options support the
+full MNG specification, and we wish to avoid the confusion among
+general users that partial support would engender.
+
+
+Platform specific notes:
+
+We have a basic .spec file for generating rpms. Send us a note if you'd
+like to clean it up.
+
diff --git a/src/3rdparty/libmng/doc/Plan1.png b/src/3rdparty/libmng/doc/Plan1.png
new file mode 100644
index 0000000000..ced5517278
--- /dev/null
+++ b/src/3rdparty/libmng/doc/Plan1.png
Binary files differ
diff --git a/src/3rdparty/libmng/doc/Plan2.png b/src/3rdparty/libmng/doc/Plan2.png
new file mode 100644
index 0000000000..3619ea6631
--- /dev/null
+++ b/src/3rdparty/libmng/doc/Plan2.png
Binary files differ
diff --git a/src/3rdparty/libmng/doc/doc.readme b/src/3rdparty/libmng/doc/doc.readme
new file mode 100644
index 0000000000..e92e93cb5a
--- /dev/null
+++ b/src/3rdparty/libmng/doc/doc.readme
@@ -0,0 +1,19 @@
+This directory hosts the documentation for libmng.
+
+You will find a lot of useful info on the web-site:
+http://www.libmng.com
+
+Man-pages are in the man sub-directory
+
+RPM specification files are in the RPM sub-directory
+
+Files in this directory:
+
+- libmng.txt
+
+Description of the library proper and its usage
+
+- Plan1.png & Plan2.png
+
+Visual representation of the functional and technical
+design of the library (in PNG format of course!)
diff --git a/src/3rdparty/libmng/doc/libmng.txt b/src/3rdparty/libmng/doc/libmng.txt
new file mode 100644
index 0000000000..b9e9bc4b89
--- /dev/null
+++ b/src/3rdparty/libmng/doc/libmng.txt
@@ -0,0 +1,1107 @@
+libmng - Multiple-image Network Graphics (MNG) Reference Library 1.0.9
+
+DESCRIPTION
+The libmng library supports decoding, displaying, encoding, and various
+other manipulations of the Multiple-image Network Graphics (MNG) format
+image files. It uses the zlib compression library, and optionally the
+JPEG library by the Independant JPEG Group (IJG) and/or
+lcms (little cms), a color-management library by Marti Maria Saguer.
+
+
+I. Introduction
+
+This file describes how to use and modify the MNG reference library
+(known as libmng) for your own use. There are seven sections to this
+file: introduction, callbacks, housekeeping, reading, displaying,
+writing, and modification and configuration notes for various special
+platforms. We assume that libmng is already installed; see the
+INSTALL.README file for instructions on how to install libmng.
+
+Libmng was written to support and promote the MNG specification.
+
+The latest MNG specification (currently 1.0) is available at
+ http://www.libpng.org/pub/mng/
+
+Other information about MNG can be found at the MNG home page at
+ http://www.libpng.org/pub/mng/
+
+The latest version of libmng can be found at its own homepage at
+ http://www.libmng.com/
+
+In most cases the library will not need to be changed.
+For standardization purposes the library contains both a Windows DLL
+and a makefile for building a shared library (SO). The library is
+written in C, but an interface for Borland Delphi is also available.
+
+Libmng has been designed to handle multiple sessions at one time,
+to be easily modifiable, to be portable to the vast majority of
+machines (ANSI, K&R, 32-, and 64-bit) available, and to be easy
+to use.
+
+Libmng uses zlib for its compression and decompression of MNG files.
+Further information about zlib, and the latest version of zlib, can be
+found at the zlib home page, <http://www.zlib.org/>.
+The zlib compression utility is a general purpose utility that is
+useful for more than MNG/PNG files, and can be used without libmng.
+See the documentation delivered with zlib for more details.
+
+Libmng optionally uses the JPEG library by the Independant JPEG Group
+(IJG). This library is used for the JNG sub-format, which is part of
+the MNG specification, and allows for inclusion of JPEG decoded and
+thus highly compressed (photographic) images.
+Further information about the IJG JPEG library and the latest sources
+can be found at <http://www.ijg.org/>.
+
+Libmng can also optionally use the lcms (little CMS) library by
+Marti Maria Saguer. This library provides an excellent color-management
+system (CMS), which gives libmng the ability to provide full
+color-correction for images with the proper color-information encoded.
+Further information and the latest sources can be found at
+<http://www.littlecms.com/>.
+
+Libmng is thread safe, provided the threads are using different
+handles as returned by the initialization call.
+Each thread should have its own handle and thus its own image.
+Libmng does not protect itself against two threads using the
+same instance of a handle.
+
+The libmng.h header file is the single reference needed for programming
+with libmng:
+
+#include <libmng.h>
+
+
+II. Callbacks
+
+Libmng makes extensive use of callback functions. This is meant to
+keep the library as platform-independant and flexible as possible.
+Actually, the first call you will make to the library, already contains
+three parameters you can use to provide callback entry-points.
+
+Most functions must return a mng_bool (boolean). Returning MNG_FALSE
+indicates the library the callback failed in some way and the library
+will immediately return from whatever it was doing back to the
+application. Returning MNG_TRUE indicates there were no problems and
+processing can continue.
+
+Let's step through each of the possible callbacks. The sections on
+reading, displaying and writing will also explain which callbacks are
+needed when and where.
+
+- mng_ptr mng_memalloc (mng_size_t iLen)
+
+A very basic function which the library uses to allocate a memory-block
+with the given size. A typical implementation would be:
+
+ mng_ptr my_alloc (mng_size_t iLen) {
+ return calloc (1, iSize);
+ }
+
+Note that the library requires you to zero-out the memory-block!!!
+
+- void mng_memfree (mng_ptr pPtr,
+ mng_size_t iLen)
+
+Counterpart of the previous function. Typically:
+
+ void my_free (mng_ptr pPtr, mng_size_t iLen) {
+ free (pPtr);
+ }
+
+- mng_bool mng_openstream (mng_handle hHandle)
+- mng_bool mng_closestream (mng_handle hHandle)
+
+These are called by the library just before it starts to process
+(either read or write) a file and just after the processing stops.
+This is the recommended place to do I/O initialization & finalization.
+Whether you do or not, is up to you. The library does not put any
+meaning into the calls. They are simply provided for your convenience.
+
+- mng_bool mng_readdata (mng_handle hHandle,
+ mng_ptr pBuf,
+ mng_uint32 iBuflen,
+ mng_uint32p pRead)
+
+This function is called when the library needs some more input while
+reading an image. The reading process supports two modes:
+Suspension-mode (SMOD) and non-suspension-mode (NSMOD).
+See mng_set_suspensionmode() for a more detailed description.
+
+In NSMOD, the library requires you to return exactly the amount of bytes
+requested (= iBuflen). Any lesser amount indicates the input file
+is exhausted and the library will return a MNG_UNEXPECTEDEOF errorcode.
+
+In SMOD, you may return a smaller amount of bytes than requested.
+This tells the library it should temporarily wait for more input to
+arrive. The lib will return with MNG_NEEDMOREDATA, and will expect a
+call to mng_read_resume() or mng_display_resume() next, as soon as
+more input-data has arrived.
+
+For NSMOD this function could be as simple as:
+
+ mng_bool my_read (mng_handle hHandle,
+ mng_ptr pBuf,
+ mng_uint32 iBuflen,
+ mng_uint32p pRead) {
+ *pRead = fread (pBuf, 1, iBuflen, myfile);
+ return MNG_TRUE;
+ }
+
+- mng_bool mng_writedata (mng_handle hHandle,
+ mng_ptr pBuf,
+ mng_uint32 iBuflen,
+ mng_uint32p pWritten)
+
+This function is called during the mng_write() function to actually
+output data to the file. There is no suspension-mode during write,
+so the application must return the exact number of bytes the library
+requests to be written.
+
+A typical implementation could be:
+
+ mng_bool my_write (mng_handle hHandle,
+ mng_ptr pBuf,
+ mng_uint32 iBuflen,
+ mng_uint32p pWritten) {
+ *pWritten = fwrite (pBuf, 1, iBuflen, myfile);
+ return MNG_TRUE;
+ }
+
+- mng_bool mng_errorproc (mng_handle hHandle,
+ mng_int32 iErrorcode,
+ mng_int8 iSeverity,
+ mng_chunkid iChunkname,
+ mng_uint32 iChunkseq,
+ mng_int32 iExtra1,
+ mng_int32 iExtra2,
+ mng_pchar zErrortext)
+
+This function is called whenever an error is detected inside the
+library. This may be caused by invalid input, callbacks indicating
+failure, or wrongfully calling functions out of place.
+
+If you do not provide this callback the library will still return
+an errorcode from the called function, and the mng_getlasterror()
+function can be used to retrieve the other parameters.
+
+This function is currently only provided for convenience, but may
+at some point be used to indicate certain errors may be acceptable,
+and processing should continue.
+
+- mng_bool mng_traceproc (mng_handle hHandle,
+ mng_int32 iFuncnr,
+ mng_int32 iFuncseq,
+ mng_pchar zFuncname)
+
+This function is provided to allow a functional analysis of the
+library. This may be useful if you encounter certain errors and
+cannot determine what the problem is.
+
+Almost all functions inside the library will activate this
+callback with an appropriate function-name at the start and end
+of the function. Please note that large images may generate an
+enormous amount of calls.
+
+- mng_bool mng_processheader (mng_handle hHandle,
+ mng_uint32 iWidth,
+ mng_uint32 iHeight)
+
+This function is called once the header information of an input-
+image has been processed. At this point the image dimensions are
+available and also some other properties depending on the type
+of the image. Eg. for a MNG the frame-/layercount, playtime &
+simplicity fields are known.
+
+The primary purpose of this callback is to inform the application
+of the size of the image, and for the application to initialize
+the drawing canvas to be used by the library. This is also a good
+point to set the canvas-style. Eg. mng_set_canvasstyle().
+
+- mng_bool mng_processtext (mng_handle hHandle,
+ mng_uint8 iType,
+ mng_pchar zKeyword,
+ mng_pchar zText,
+ mng_pchar zLanguage,
+ mng_pchar zTranslation)
+
+This callback is activated for each textual chunk in the input-
+image. These are tEXt, zTXt & iTXt. It may be used to retain
+specific comments for presentation to the user.
+
+- mng_bool mng_processsave (mng_handle hHandle)
+- mng_bool mng_processseek (mng_handle hHandle,
+ mng_pchar zName)
+
+The purpose of these callbacks is to signal the processing of the
+SAVE & SEEK chunks in a MNG input-file. This may be used in the
+future to specify some special processing. At the moment these
+functions are only provided as a signal.
+
+- mng_ptr mng_getcanvasline (mng_handle hHandle,
+ mng_uint32 iLinenr)
+- mng_ptr mng_getbkgdline (mng_handle hHandle,
+ mng_uint32 iLinenr)
+- mng_ptr mng_getalphaline (mng_handle hHandle,
+ mng_uint32 iLinenr)
+
+These callbacks are used to access the drawing canvas, background
+canvas and an optional separate alpha-channel canvas. The latter is
+used only with the MNG_CANVAS_RGB8_A8 canvas-style.
+
+If the getbkgdline() callback is not supplied the library will
+composite full or partially transparent pixels in the image against
+a specified background color. See mng_set_bgcolor() for more details.
+If a chosen canvas-style includes an alpha-channel, this callback
+is very likely not needed.
+
+The application is responsible for returning a pointer to a line of
+pixels, which should be in the exact format as defined by the call
+to mng_set_canvasstyle() and mng_set_bkgdstyle(), without gaps between
+the representation of each pixel.
+
+- mng_bool mng_refresh (mng_handle hHandle,
+ mng_uint32 iX,
+ mng_uint32 iY,
+ mng_uint32 iWidth,
+ mng_uint32 iHeight)
+
+This callback is called when the library has drawn a complete frame
+onto the drawing canvas, and it is ready to be displayed.
+The application is responsible for transferring the drawing canvas
+from memory onto the actual output device.
+
+- mng_uint32 mng_gettickcount (mng_handle hHandle)
+
+This function should return the number of milliseconds on some internal
+clock. The entire animation timing depends heavily on this function,
+1and the number returned should be as accurate as possible.
+
+- mng_bool mng_settimer (mng_handle hHandle,
+ mng_uint32 iMsecs)
+
+This callback is activated every time the library requires a "pause".
+Note that the function itself should NOT execute the wait. It should
+simply store the time-field and allow the library to return. Libmng
+will return with the MNG_NEEDTIMERWAIT code, indicating the callback
+was called and it is now time to execute the pause.
+
+After the indicated number of milliseconds have elapsed, the application
+should call mng_display_resume(), to resume the animation as planned.
+
+This method allows for both a real timer or a simple wait command in the
+application. Whichever method you select, both the gettickcount() and
+settimer() callbacks are crucial for proper animation timing.
+
+- mng_bool mng_processgamma (mng_handle hHandle,
+ mng_uint32 iGamma)
+- mng_bool mng_processchroma (mng_handle hHandle,
+ mng_uint32 iWhitepointx,
+ mng_uint32 iWhitepointy,
+ mng_uint32 iRedx,
+ mng_uint32 iRedy,
+ mng_uint32 iGreenx,
+ mng_uint32 iGreeny,
+ mng_uint32 iBluex,
+ mng_uint32 iBluey)
+- mng_bool mng_processsrgb (mng_handle hHandle,
+ mng_uint8 iRenderingintent)
+- mng_bool mng_processiccp (mng_handle hHandle,
+ mng_uint32 iProfilesize,
+ mng_ptr pProfile)
+- mng_bool mng_processarow (mng_handle hHandle,
+ mng_uint32 iRowsamples,
+ mng_bool bIsRGBA16,
+ mng_ptr pRow)
+
+These callbacks are only required when you selected the MNG_APP_CMS
+directive during compilation of the library. See the configuration
+section for more details.
+
+- mng_bool mng_iteratechunk (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_chunkid iChunkid,
+ mng_uint32 iChunkseq)
+
+This callback is only used for the mng_iterate_chunks() function.
+It is called exactly once for each chunk stored.
+
+
+III. Housekeeping
+
+
+> Memory management
+
+The library can use internal memory allocation/deallocation or use
+provided callbacks for its memory management. The choice is made at
+compilation time. See the section on customization for details.
+
+If internal management has been selected, the memory callback functions
+need not be supplied. Even if you do supply them they will not be used.
+The actual code used is similar to the code discussed in the callback
+section:
+
+ pPtr = calloc (1, iSize);
+
+ free (pPtr);
+
+If your compiler does not support these functions, or you wish to monitor
+the library's use of memory for certain reasons, you can choose to
+compile the library with external memory management. In this case the
+memory callback functions MUST be supplied, and should function as if the
+above code was used.
+
+
+> Initialization
+
+The basic initialization of the library is short and swift:
+
+ myhandle = mng_initialize (myuserdata, my_alloc,
+ my_free, MNG_NULL);
+ if (myhandle == MNG_NULL)
+ /* process error */;
+
+The first field is an application-only parameter. It is saved in
+libmng's internal structures and available at all times through the
+mng_get_userdata() function. This is especially handy in callback functions
+if your program may be handling multiple files at the same time.
+
+The second and third field supply the library with the memory callback
+1function entry-points. These are described in more detail in the callback
+section and the previous paragraph.
+
+The fourth and last field may be used to supply the library with the
+entry-point of a trace callback function. For regular use you will not
+need this!
+
+The function returns a handle which will be your ticket to MNG-heaven.
+All other functions rely on this handle. It is the single fixed unique
+reference-point between your application and the library.
+
+You should call the initialization function for each image you wish to
+process simultaneously. If you are processing images consecutively, you can
+reset the internal status of the library with the mng_reset() function.
+This function will clear all internal state variables, free any stored
+chunks and/or objects, etc, etc. Your callbacks and other external parameters
+will be retained.
+
+After you successfully received the handle it is time to set the required
+callbacks. The sections on reading, displaying & writing indicate which
+callbacks are required and which are optional.
+To set the callbacks simply do:
+
+ myretcode = mng_setcb_xxxxxx (myhandle, my_xxxxxx);
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+Naturally you'd replace the x's with the name of the callback.
+
+
+> Cleanup
+
+Once you've gotten hold of that precious mng_handle, you should always,
+and I mean always, call the cleanup function when you're done.
+Just do:
+
+ mng_cleanup (myhandle);
+
+And you're done. There shouldn't be an ounce of memory spilled after
+that call.
+
+Note that if you would like to process multiple files consecutively
+you do not need to do mng_cleanup() / mng_initialize() between each file
+but simply
+
+ myretcode = mng_reset (myhandle);
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+will suffice. Saves some time and effort, that.
+
+
+> Error handling
+
+From the examples in the previous paragraphs you may have noticed a
+meticulous scheme for error handling. And yes, that's exactly what it is.
+Practically each call simply returns an errorcode, indicating success,
+eg. MNG_NOERROR or failure, anything else but MNG_NEEDMOREDATA and
+MNG_NEEDTIMERWAIT. These latter two will be discussed in more detail in
+their respective fields of interest: the reading section and displaying
+section respectively.
+
+It is the application's responsibility to check the returncode after
+each call. You can call mng_getlasterror() to receive the details of
+the last detected error. This even includes a discriptive error-message
+if you enabled that option during compilation of the library.
+
+Note that after receiving an error it is still possible to call the
+library, but it's also very likely that any following call will fail.
+The only functions deemed to work will be mng_reset() and mng_cleanup().
+Yes, if you abort your program after an error, you should still call
+mng_cleanup().
+
+
+IV. Reading
+
+Reading a MNG, JNG or PNG is fairly easy. It depends slightly on your
+ultimate goal how certain specifics are to be handled, but the basics
+are similar in all cases.
+
+For the read functioins to work you must have compiled the library with
+the MNG_READ_SUPPRT directive. The standard DLL and Shared Library
+have this on by default!
+
+
+> Setup
+
+Naturally you must have initialized the library and be the owner of
+a mng_handle. The following callbacks are essential:
+
+ mng_openstream, mng_readdata, mng_closestream
+
+You may optionally define:
+
+ mng_errorproc, mng_traceproc
+ mng_processheader, mng_processtext
+ mng_processsave, mng_processseek
+
+The reading bit will also fail if you are already creating or
+displaying a file. Seems a bit obvious, but I thought I'd mention it,
+just in case.
+
+
+> To suspend or not to suspend
+
+There is one choice you need to make before calling the read function.
+Are you in need of suspension-mode or not?
+
+If you're reading from a disk you most certainly do not need
+suspension-mode. Even the oldest and slowest of disks will be fast
+enough for straight reading.
+
+However, if your input comes from a really slow device, such as a
+dialup-line or the likes, you may opt for suspension-mode. This is done
+by calling
+
+ myretcode = mng_set_suspensionmode (myhandle,
+ MNG_TRUE);
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+Suspension-mode will force the library to use special buffering on the
+input. This allows your application to receive data of arbitrarily length
+and return this in the mng_readdata() callback, without disturbing the
+chunk processing routines of the library.
+
+Suspension-mode does require a little extra care in the main logic of the
+1application. The read function may return with MNG_NEEDMOREDATA when the
+mng_readdata() callback returns less data then it needs to process the
+next chunk. This indicates the application to wait for more data to arrive
+and then resume processing by calling mng_read_resume().
+
+
+> The read HLAPI
+
+The actual reading is just plain simple. Since all I/O is done
+1outside the library through the callbacks, the library can focus on
+its real task. Understanding, checking and labelling the input data!
+
+All you really need to do is this:
+
+ myretcode = mng_read (myhandle);
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+Of course, if you're on suspension-mode the code is a little more
+complicated:
+
+ myretcode = mng_read (myhandle);
+
+ while (myretcode == MNG_NEEDMOREDATA) {
+ /* wait for input-data to arrive */
+ myretcode = mng_read_resume (myhandle);
+ }
+
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+This is rather crude and more sophisticated programming methods may
+dictate another approach. Whatever method you decide on, it should
+act as if the above code was in its place.
+
+There is also the mng_readdisplay() function, but this is discussed
+in the displaying section. It functions pretty much as the mng_read()
+function, but also immediately starts displaying the image.
+mng_read_resume() should be replaced by mng_display_resume() in that
+case!
+
+
+> What happens inside
+
+What actually happens inside the library depends on the configuration
+options set during the compilation of the library.
+
+Basically the library will first read the 8-byte file header, to determine
+its validity and the type of image it is about to process. Then it will
+repeatedly read a 4-byte chunk-length and then the remainder of the chunk
+until it either reaches EOF (indicated by the mng_readdata() callback) or
+implicitly decides EOF as it processed the logically last chunk of the
+image.
+
+Applications that require strict conformity and do not allow superfluous
+data after the ending chunk, will need to perform this check in their
+mng_closestream() callback.
+
+Each chunk is then checked on CRC, after which it is handed over to the
+appropriate chunk processing routine. These routines will disect the
+chunk, check the validity of its contents, check its position with respect
+to other chunks, etc, etc.
+
+If everything checks out, the chunk is further processed as follows:
+
+If display support has been selected during compilation, certain pre-display
+initialization will take place.
+
+If chunk-storage support has been selected during compilation, the chunks
+data may be stored in a special internal structure and held for future
+reference.
+
+
+> Storing and accessing chunks
+
+One of the compilation options activates support for chunk storage.
+This option may be useful if you want to examine an image. The directive
+is MNG_STORE_CHUNKS. You must also turn on the MNG_ACCESS_CHUNKS
+directive.
+
+The actual storage facility can be turned on or off with the
+mng_set_storechunks() function. If set to MNG_TRUE, chunks will be
+stored as they are read.
+
+At any point you can then call the mng_iterate_chunks() function
+to iterate through the current list of chunks. This function requires
+a callback which is called for each chunk and receives a specific
+chunk-handle. This chunk-handle can be used to call the appropriate
+mng_getchunk_xxxx() function, to access the chunks properties.
+
+A typical implementation may look like this:
+
+ mng_bool my_iteratechunk (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_chunkid iChunkid,
+ mng_uint32 iChunkseq) {
+ switch (iChunkid) {
+ case MNG_UINT_MHDR : { /* process MHDR */;
+ break; }
+ case MNG_UINT_FRAM : { /* process FRAM */;
+ break; }
+
+ ...etc...
+
+ case MNG_UINT_HUH : { /* unknown chunk */;
+ break; }
+ default : { /* duh; forgot one */; }
+ }
+
+ return MNG_TRUE; /* keep'm coming */
+ }
+
+To get to the actual chunk fields of lets say a SHOW chunk you would do:
+
+ mng_bool isempty;
+ mng_uint16 firstid, lastid;
+ mng_uint8 showmode;
+
+ myretcode mng_getchunk_show (hHandle, hChunk,
+ isempty, firstid,
+ lastid, showmode);
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+
+V. Displaying
+
+
+> Setup
+
+Assuming you have initialized the library and are the owner of
+a mng_handle. The following callbacks are essential:
+
+ mng_getcanvasline, mng_refresh
+ mng_gettickcount, mng_settimer
+
+If you wish to use an application supplied background you must supply:
+
+ mng_getbkgdline
+
+If you wish to use the MNG_CANVAS_RGB8_A8 canvas style you must supply:
+
+ mng_getalphaline
+
+You may optionally define:
+
+ mng_errorproc, mng_traceproc
+ mng_processheader, mng_processtext
+ mng_processsave, mng_processseek
+
+Note that the mng_processheader() callback is optional but will
+be quite significant for proper operation!
+
+Displaying an image will fail if you are creating a file or already
+displaying one. Yes, you can't display it twice!
+
+
+> A word on canvas styles
+
+The canvas style describes how your drawing canvas is made up.
+You must set this before the library actually starts drawing, so
+the mng_processheader() callback is a pretty good place for it.
+
+Currently only 8-bit RGB canvas styles are supported, either with
+or without an alpha channel.
+
+If you like to do alpha composition yourself you can select one of
+the canvas styles that include an alpha channel. You can even have
+a separate alpha canvas by selecting the MNG_CANVAS_RGB8_A8 style.
+
+All styles require a compact model. Eg. MNG_CANVAS_BGR8 requires
+your canvas lines in bgrbgrbgr... storage, where each letter
+represents an 8-bit value of the corresponding color, and each
+threesome makes up the values of one(1) pixel.
+
+The library processes a line at a time, so the canvas lines do not
+actually need to be consecutive in memory.
+
+
+> Alpha composition and application backgrounds
+
+All Network Graphics can be partially transparent. This requires
+special processing if you need to display an image against some
+background. Note that the MNG header (MHDR chunk) contains a
+simplicity field indicating whether transparency information in
+the file is critical or not. This only applies to embedded images,
+which means the full image-frame of the MNG may still contain fully
+transparent pixels!
+
+Depending on your needs you can supply a single background color,
+a background canvas or tell the library to return the alpha-channel
+and do alpha composition yourself.
+
+This is different from the BACK chunk in a MNG, or the bKGD chunk
+in an (embedded) PNG or JNG. The BACK chunk indicates an optional or
+mandatory background color and/or image. The bKGD chunk only indicates
+an optional background color. These chunks indicate the Authors
+preferences. They may be absent in which case you need to supply
+some sort of background yourself.
+
+> Composing against a background color
+
+This is the easiest method. Call the mng_set_bgcolor() function to
+set the values of the red, green and blue component of your preferred
+background color.
+
+Use one of the canvas styles that do not have an alpha-channel, and
+which matches your output requirements.
+
+> Composing against a background canvas
+
+This is somewhat more complicated. You will need to set the
+mng_getbkgdline() callback. This will be called whenever the library
+needs to compose a partially transparent line.
+
+This canvas must hold the background against which the image should
+be composed. Its size must match exactly with the image dimensions
+and thus the drawing canvas!
+
+Use one of the canvas styles that do not have an alpha-channel, and
+which matches your output requirements. The canvas style of the
+background canvas may even differ from the drawing canvas. The library's
+composing will still function properly.
+
+> Composing within the application
+
+If you have the option in your application to draw a (partially)
+transparent canvas to the output device, this option is preferred.
+
+Select one of the canvas styles that do have an alpha-channel.
+The library will now supply the appropriate alpha information,
+allowing the application to compose the image as it sees fit.
+
+
+> Color information and CMS
+
+Network Graphics may, and usually will, contain color-correction
+information. This information is intended to compensate for the
+difference in recording and display devices used.
+
+This document does not address the specifics of color-management.
+See the PNG specification for a more detailed description.
+
+> Using little cms by Marti Maria Saguer
+
+This is the easiest method, providing you can compile the lcms package.
+Select the MNG_FULL_CMS directive during compilation, and sit back and
+relax. The library will take care of all color-correction for you.
+
+> Using an OS- or application-supplied CMS
+
+If you are so lucky to have access to CMS functionality from within
+your application, you may instruct the library to leave color-correction
+to you.
+
+Select the MNG_APP_CMS directive during compilation of the library.
+You MUST also set the following callbacks:
+
+ mng_processgamma, mng_processchroma,
+ mng_processsrgb, mng_processiccp and
+ mng_processarow
+
+The last callback is called when the library needs you to correct
+an arbitrary line of pixels. The other callbacks are called when
+the corresponding color-information is encountered in the file.
+You must store this information somewhere for use in the
+mng_processarow() callback.
+
+> Using gamma-only correction
+
+This isn't a preferred method, but it's better than no correction
+at all. Gamma-only correction will at least compensate for
+gamma-differences between the original recorder and your output device.
+
+Select the MNG_GAMMA_ONLY directive during compilation
+of the library. Your compiler MUST support fp operations.
+
+> No color correction
+
+Ouch. This is really bad. This is the least preferred method,
+but may be necessary if your system cannot use lcms, doesn't
+have its own CMS, and does not allow fp operations, ruling out
+the gamma-only option.
+
+Select the MNG_NO_CMS directive during compilation.
+Images will definitely not be displayed as seen by the Author!!!
+
+
+> Animations and timing
+
+Animations require some form of timing support. The library relies
+on two callbacks for this purpose. The mng_gettickcount() and
+mng_settimer() callbacks. mng_gettickcount() is used to determine
+the passing of time in milliseconds since the beginning of the
+animation. This is also used to compensate during suspension-mode
+if you are using the mng_readdisplay() function to read & display
+the file simultaneously.
+
+The callback may return an arbitrary number of milliseconds, but
+this number must increase proportionaly between calls. Most modern
+systems will have some tickcount() function which derives its
+input from an internal clock. The value returned from this function
+is more than adequate for libmng.
+
+The mng_settimer() callback is called when the library determines
+a little "pause" is required before rendering another frame of the
+animation. The pause interval is also expressed in milliseconds.
+Your application should store this value and return immediately.
+The library will then make appropriate arrangements to store its
+internal state and returns to your application with the
+MNG_NEEDTIMERWAIT code.
+
+At that point you should suspend processing and wait the given
+interval. Please use your OS features for this. Do not engage some
+sort of loop. That is real bad programming practice. Most modern
+systems will have some timing functions. A simple wait() function
+may suffice, but this may prevent your applications main-task from
+running, and possibly prevent the actual update of your output device.
+
+
+> The mng_refresh() callback
+
+The mng_refresh() callback is called whenever the library has
+"finished" drawing a new frame onto your canvas, and just before it
+will call the mng_settimer() callback.
+
+This allows you to perform some actions necessary to "refresh" the
+canvas onto your output device. Please do NOT suspend processing
+inside this callback. This must be handled after the mng_settimer()
+callback!
+
+
+> Displaying while reading
+
+This method is preferred if you are reading from a slow input device
+(such as a dialup-line) and you wish to start displaying something
+as quickly as possible. This functionality is provided mainly for
+browser-type applications but may be appropriate for other
+applications as well.
+
+The method is usually used in unison with the suspension-mode of
+the read module. A typical implementation would look like this:
+
+ /* initiale library and set required callbacks */
+
+ /* activate suspension-mode */
+ myretcode = mng_set_suspensionmode (myhandle,
+ MNG_TRUE);
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+ myretcode = mng_readdisplay (myhandle);
+
+ while ((myretcode == MNG_NEEDMOREDATA) ||
+ (myretcode == MNG_NEEDTIMERWAIT)) {
+ if (myretcode == MNG_NEEDMOREDATA)
+ /* wait for more input-data */;
+ else
+ /* wait for timer interval */;
+
+ myretcode = mng_display_resume (myhandle);
+ }
+
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+More advanced programming methods may require a different approach,
+but the final result should function as in the code above.
+
+
+> Displaying after reading
+
+This method is used to display a file that was previously read.
+It is primarily meant for viewers with direct file access, such as
+1a local harddisk.
+
+Once you have successfully read the file, all you need to do is:
+
+ myretcode = mng_display (myhandle);
+
+ while (myretcode == MNG_NEEDTIMERWAIT) {
+ /* wait for timer interval */;
+ myretcode = mng_display_resume (myhandle);
+ }
+
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+Again, more advanced programming methods may require a different
+approach, but the final result should function as in the code above.
+
+
+> Display manipulation
+
+Several HLAPI functions are provided to allow a user to manipulate
+the normal flow of an animation.
+
+- mng_display_freeze (mng_handle hHandle)
+
+This will "freeze" the animation in place.
+
+- mng_display_resume (mng_handle hHandle)
+
+This function can be used to resume a frozen animation, or to force
+the library to advance the animation to the next frame.
+
+- mng_display_reset (mng_handle hHandle)
+
+This function will "reset" the animation into its pristine state.
+Calling mng_display() afterwards will re-display the animation
+from the first frame.
+
+- mng_display_golayer (mng_handle hHandle,
+ mng_uint32 iLayer)
+- mng_display_goframe (mng_handle hHandle,
+ mng_uint32 iFrame)
+- mng_display_goplaytime (mng_handle hHandle,
+ mng_uint32 iPlaytime)
+
+These three functions can be used to "jump" to a specific layer, frame
+or timeslot in the animation. You must "freeze" the animation before
+using any of these functions.
+
+All above functions may only be called during a timer interval!
+It is the applications responsibility to cleanup any resources with
+respect to the timer wait.
+
+
+VI. Writing
+
+The main focus of the library lies in its displaying capabilites.
+But it does offer writing support as well.
+You can create and write a file, or you can write a file you
+have previously read, providing the storage of chunks was enabled
+and active.
+
+For this to work you must have compiled the library with the
+MNG_WRITE_SUPPO1RT and MNG_ACCESS_CHUNKS directives. The standard DLL and
+Shared Library have this on by default!
+
+
+> Setup
+
+As always you must have initialized the library and be the owner of
+a mng_handle. The following callbacks are essential:
+
+ mng_openstream, mng_writedata, mng_closestream
+
+You can optionally define:
+
+ mng_errorproc, mng_traceproc
+
+The creation and writing functions will fail if you are in the middle
+of reading, creating or writing a file.
+
+
+> Creating a new file
+
+To start a new file the library must be in its initial state.
+First you need to tell the library your intentions:
+
+ myretcode = mng_create (myhandle);
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+After that you start adding the appropriate chunks:
+
+ myretcode = mng_putchunk_mhdr (myhandle, ...);
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+And so on, and so forth. Note that the library will automatically signal
+the logical end of the file by the ending chunk. Also the first chunk
+will indicate the library the filetype (eg. PNG, JNG or MNG) and force
+the proper signature when writing the file.
+
+The code above can be simplified, as you can always get the last errorcode
+by using the mng_getlasterror() function:
+
+ if ( (mng_putchunk_xxxx (myhandle, ...)) or
+ (mng_putchunk_xxxx (myhandle, ...)) or
+ ...etc... )
+ /* process error */;
+
+Please note that you must have a pretty good understanding of the chunk
+specification. Unlike the read functions, there are virtually no checks,
+so it is quite possible to write completely wrong files.
+It is a good practice to read back your file into the library to verify
+its integrity.
+
+Once you've got all the chunks added, all you do is:
+
+ myretcode mng_write (myhandle);
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+And presto. You're done. The real work is of course carried out in
+your callbacks. Note that this is a single operation as opposed to
+the read & display functions that may return with MNG_NEEDMOREDATA
+and/or MNG_NEEDTIMERWAIT. The write function just does the job, and
+only returns after it's finished or if it encounters some
+unrecoverable error.
+
+
+> Writing a previously read file
+
+If you have already successfully read a file, you can use the library to
+write it out as a copy or something. You MUST have compiled the library
+with the MNG_STORE_CHUNKS directive, and you must have done
+mng_set_storechunks (myhandle, MNG_TRUE).
+
+This doesn't require the MNG_ACCESS_CHUNKS directive, unless you want
+to fiddle with the chunks as well.
+
+Again all you need to do is:
+
+ myretcode mng_write (myhandle);
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+
+VII. Modifying/Customizing libmng:
+
+to do
+
+> Compilation directives
+
+to do
+
+> Platform dependant modification
+
+to do
+
+
+References :
+
+libmng :
+ http://www.libmng.com/
+
+zlib :
+ http://www.info-zip.org/pub/infozip/zlib/
+
+IJG JPEG library :
+ http://www.ijg.org/
+
+lcms (little CMS) by Marti Maria Saguer :
+ http://www.littlecms.com/
+
+MNG specification:
+ http://www.libpng.org/pub/mng
+
+
+In the case of any inconsistency between the MNG specification
+and this library, the specification takes precedence.
+
+
+The contributing authors would like to thank all those who helped
+with testing, bug fixes, and patience. This wouldn't have been
+possible without all of you!!!
+
+
+COPYRIGHT NOTICE:
+
+Copyright (c) 2000,2001 Gerard Juyn
+
+For the purposes of this copyright and license, "Contributing Authors"
+is defined as the following set of individuals:
+
+ Gerard Juyn
+
+The MNG Library is supplied "AS IS". The Contributing Authors
+disclaim all warranties, expressed or implied, including, without
+limitation, the warranties of merchantability and of fitness for any
+purpose. The Contributing Authors assume no liability for direct,
+indirect, incidental, special, exemplary, or consequential damages,
+which may result from the use of the MNG Library, even if advised of
+the possibility of such damage.
+
+Permission is hereby granted to use, copy, modify, and distribute this
+source code, or portions hereof, for any purpose, without fee, subject
+to the following restrictions:
+
+1. The origin of this source code must not be misrepresented;
+you must not claim that you wrote the original software.
+
+2. Altered versions must be plainly marked as such and must not be
+misrepresented as being the original source.
+
+3. This Copyright notice may not be removed or altered from any source
+or altered source distribution.
+
+The Contributing Authors specifically permit, without fee, and
+encourage the use of this source code as a component to supporting
+the MNG and JNG file format in commercial products. If you use this
+source code in a product, acknowledgment would be highly appreciated.
+
+
+Remarks :
+
+Parts of this software have been adapted from the libpng library.
+Although this library supports all features from the PNG specification
+(as MNG descends from it) it does not require the libpng library.
+It does require the zlib library and optionally the IJG JPEG library,
+and/or the "little-cms" library by Marti Maria Saguer (depending on the
+inclusion of support for JNG and Full-Color-Management respectively.
+
+This library's function is primarily to read and display MNG
+animations. It is not meant as a full-featured image-editing
+component! It does however offer creation and editing functionality
+at the chunk level. (future modifications may include some more
+support for creation and or editing)
+
diff --git a/src/3rdparty/libmng/doc/man/jng.5 b/src/3rdparty/libmng/doc/man/jng.5
new file mode 100644
index 0000000000..0e371ad0eb
--- /dev/null
+++ b/src/3rdparty/libmng/doc/man/jng.5
@@ -0,0 +1,37 @@
+.TH JNG 5 "July 26, 2000"
+.SH NAME
+jng \- JPEG Network Graphics (JNG) sub-format
+.SH DESCRIPTION
+JNG (JPEG Network Graphics) is a sub-format of the MNG (Multiple-image
+Network Graphics) format. As with MNG it extends on the features of the
+popular PNG (Portable Network Graphics) image-format.
+.br
+
+This sub-format was designed to support a lossy compression-method.
+It is based completely on the JPEG specification. It adds the high-compression
+ratios of JPEG for photographic images.
+
+As a member of the Network Graphics family, JNG was deemed adequate as a
+stand-alone format as it extends the JPEG format with color-correction and
+transparency features.
+
+.SH "SEE ALSO"
+.IR png(5) ", " mng(5) ", " libmng(3)
+.LP
+MNG 1.00, February 9, 2001:
+.IP
+http://www.libpng.org/pub/mng
+
+.SH AUTHORS
+This man page: Gerard Juyn
+.LP
+Multiple-image Network Graphics (MNG) Specification Version 1.00 (Februari 9, 2001):
+Glenn Randers-Pehrson and others (png-list@ccrc.wustl.edu).
+.LP
+
+.SH COPYRIGHT NOTICE
+The MNG-1.00 specification is copyright (c) 1998-2001 Glenn Randers-Pehrson.
+See the specification for conditions of use and distribution.
+.LP
+.\" end of man page
+
diff --git a/src/3rdparty/libmng/doc/man/libmng.3 b/src/3rdparty/libmng/doc/man/libmng.3
new file mode 100644
index 0000000000..5321faaa17
--- /dev/null
+++ b/src/3rdparty/libmng/doc/man/libmng.3
@@ -0,0 +1,1146 @@
+.TH LIBMNG 3 "January 30th, 2005"
+.SH NAME
+libmng \- Multiple-image Network Graphics (MNG) Reference Library 1.0.9
+.SH SYNOPSIS
+\fI\fB
+
+\fB#include <libmng.h>\fP
+
+
+.SH DESCRIPTION
+The
+.I libmng
+library supports decoding, displaying, encoding, and various other
+manipulations of the Multiple-image Network Graphics (MNG) format
+image files. It uses the
+.IR zlib(3)
+compression library, and optionally the JPEG library by the Independant
+JPEG Group (IJG) and/or lcms (little cms), a color-management library
+by Marti Maria Saguer.
+
+
+.SH I. Introduction
+
+This file describes how to use and modify the MNG reference library
+(known as libmng) for your own use. There are seven sections to this
+file: introduction, callbacks, housekeeping, reading, displaying,
+writing, and modification and configuration notes for various special
+platforms. We assume that libmng is already installed; see the
+INSTALL.README file for instructions on how to install libmng.
+
+Libmng was written to support and promote the MNG specification.
+
+The MNG-1.0 specification is available at
+<http://www.libpng.org/pub/mng/spec/>.
+
+Other information about MNG can be found at the MNG home page,
+<http://www.libpng.org/pub/mng/>.
+The latest version of libmng can be found at its own homepage at
+<http://www.libmng.com/>.
+
+In most cases the library will not need to be changed.
+For standardization purposes the library contains both a Windows DLL
+and a makefile for building a shared library (SO). The library is
+written in C, but an interface for Borland Delphi is also available.
+
+Libmng has been designed to handle multiple sessions at one time,
+to be easily modifiable, to be portable to the vast majority of
+machines (ANSI, K&R, 32-, and 64-bit) available, and to be easy
+to use.
+
+Libmng uses zlib for its compression and decompression of MNG files.
+Further information about zlib, and the latest version of zlib, can be
+found at the zlib home page, <http://www.zlib.org/>.
+The zlib compression utility is a general purpose utility that is
+useful for more than MNG/PNG files, and can be used without libmng.
+See the documentation delivered with zlib for more details.
+
+Libmng optionally uses the JPEG library by the Independant JPEG Group
+(IJG). This library is used for the JNG sub-format, which is part of
+the MNG specification, and allows for inclusion of JPEG decoded and
+thus highly compressed (photographic) images.
+Further information about the IJG JPEG library and the latest sources
+can be found at <http://www.ijg.org/>.
+
+Libmng can also optionally use the lcms (little CMS) library by
+Marti Maria Saguer. This library provides an excellent color-management
+system (CMS), which gives libmng the ability to provide full
+color-correction for images with the proper color-information encoded.
+Further information and the latest sources can be found at
+<http://www.littlecms.com/>.
+
+Libmng is thread safe, provided the threads are using different
+handles as returned by the initialization call.
+Each thread should have its own handle and thus its own image.
+Libmng does not protect itself against two threads using the
+same instance of a handle.
+
+The libmng.h header file is the single reference needed for programming
+with libmng:
+
+#include <libmng.h>
+
+
+.SH II. Callbacks
+
+Libmng makes extensive use of callback functions. This is meant to
+keep the library as platform-independant and flexible as possible.
+Actually, the first call you will make to the library, already contains
+three parameters you can use to provide callback entry-points.
+
+Most functions must return a mng_bool (boolean). Returning MNG_FALSE
+indicates the library the callback failed in some way and the library
+will immediately return from whatever it was doing back to the
+application. Returning MNG_TRUE indicates there were no problems and
+processing can continue.
+
+Let's step through each of the possible callbacks. The sections on
+reading, displaying and writing will also explain which callbacks are
+needed when and where.
+
+\- mng_ptr mng_memalloc (mng_size_t iLen)
+
+A very basic function which the library uses to allocate a memory-block
+with the given size. A typical implementation would be:
+
+ mng_ptr my_alloc (mng_size_t iLen) {
+ return calloc (1, iLen);
+ }
+
+Note that the library requires you to zero-out the memory-block!!!
+
+\- void mng_memfree (mng_ptr pPtr,
+ mng_size_t iLen)
+
+Counterpart of the previous function. Typically:
+
+ void my_free (mng_ptr pPtr, mng_size_t iLen) {
+ free (pPtr);
+ }
+
+\- mng_bool mng_openstream (mng_handle hHandle)
+
+\- mng_bool mng_closestream (mng_handle hHandle)
+
+These are called by the library just before it starts to process
+(either read or write) a file and just after the processing stops.
+This is the recommended place to do I/O initialization & finalization.
+Whether you do or not, is up to you. The library does not put any
+meaning into the calls. They are simply provided for your convenience.
+
+\- mng_bool mng_readdata (mng_handle hHandle,
+ mng_ptr pBuf,
+ mng_uint32 iBuflen,
+ mng_uint32p pRead)
+
+This function is called when the library needs some more input while
+reading an image. The reading process supports two modes:
+Suspension-mode (SMOD) and non-suspension-mode (NSMOD).
+See mng_set_suspensionmode() for a more detailed description.
+
+In NSMOD, the library requires you to return exactly the amount of bytes
+requested (= iBuflen). Any lesser amount indicates the input file
+is exhausted and the library will return a MNG_UNEXPECTEDEOF errorcode.
+
+In SMOD, you may return a smaller amount of bytes than requested.
+This tells the library it should temporarily wait for more input to
+arrive. The lib will return with MNG_NEEDMOREDATA, and will expect a
+call to mng_read_resume() or mng_display_resume() next, as soon as
+more input-data has arrived.
+
+For NSMOD this function could be as simple as:
+
+ mng_bool my_read (mng_handle hHandle,
+ mng_ptr pBuf,
+ mng_uint32 iBuflen,
+ mng_uint32p pRead) {
+ *pRead = fread (pBuf, 1, iBuflen, myfile);
+ return MNG_TRUE;
+ }
+
+\- mng_bool mng_writedata (mng_handle hHandle,
+ mng_ptr pBuf,
+ mng_uint32 iBuflen,
+ mng_uint32p pWritten)
+
+This function is called during the mng_write() function to actually
+output data to the file. There is no suspension-mode during write,
+so the application must return the exact number of bytes the library
+requests to be written.
+
+A typical implementation could be:
+
+ mng_bool my_write (mng_handle hHandle,
+ mng_ptr pBuf,
+ mng_uint32 iBuflen,
+ mng_uint32p pWritten) {
+ *pWritten = fwrite (pBuf, 1, iBuflen, myfile);
+ return MNG_TRUE;
+ }
+
+\- mng_bool mng_errorproc (mng_handle hHandle,
+ mng_int32 iErrorcode,
+ mng_int8 iSeverity,
+ mng_chunkid iChunkname,
+ mng_uint32 iChunkseq,
+ mng_int32 iExtra1,
+ mng_int32 iExtra2,
+ mng_pchar zErrortext)
+
+This function is called whenever an error is detected inside the
+library. This may be caused by invalid input, callbacks indicating
+failure, or wrongfully calling functions out of place.
+
+If you do not provide this callback the library will still return
+an errorcode from the called function, and the mng_getlasterror()
+function can be used to retrieve the other parameters.
+
+This function is currently only provided for convenience, but may
+at some point be used to indicate certain errors may be acceptable,
+and processing should continue.
+
+\- mng_bool mng_traceproc (mng_handle hHandle,
+ mng_int32 iFuncnr,
+ mng_int32 iFuncseq,
+ mng_pchar zFuncname)
+
+This function is provided to allow a functional analysis of the
+library. This may be useful if you encounter certain errors and
+cannot determine what the problem is.
+
+Almost all functions inside the library will activate this
+callback with an appropriate function-name at the start and end
+of the function. Please note that large images may generate an
+enormous amount of calls.
+
+\- mng_bool mng_processheader (mng_handle hHandle,
+ mng_uint32 iWidth,
+ mng_uint32 iHeight)
+
+This function is called once the header information of an input-
+image has been processed. At this point the image dimensions are
+available and also some other properties depending on the type
+of the image. Eg. for a MNG the frame-/layercount, playtime &
+simplicity fields are known.
+
+The primary purpose of this callback is to inform the application
+of the size of the image, and for the application to initialize
+the drawing canvas to be used by the library. This is also a good
+point to set the canvas-style. Eg. mng_set_canvasstyle().
+
+\- mng_bool mng_processtext (mng_handle hHandle,
+ mng_uint8 iType,
+ mng_pchar zKeyword,
+ mng_pchar zText,
+ mng_pchar zLanguage,
+ mng_pchar zTranslation)
+
+This callback is activated for each textual chunk in the input-
+image. These are tEXt, zTXt & iTXt. It may be used to retain
+specific comments for presentation to the user.
+
+\- mng_bool mng_processsave (mng_handle hHandle)
+
+\- mng_bool mng_processseek (mng_handle hHandle,
+ mng_pchar zName)
+
+The purpose of these callbacks is to signal the processing of the
+SAVE & SEEK chunks in a MNG input-file. This may be used in the
+future to specify some special processing. At the moment these
+functions are only provided as a signal.
+
+\- mng_ptr mng_getcanvasline (mng_handle hHandle,
+ mng_uint32 iLinenr)
+
+\- mng_ptr mng_getbkgdline (mng_handle hHandle,
+ mng_uint32 iLinenr)
+
+\- mng_ptr mng_getalphaline (mng_handle hHandle,
+ mng_uint32 iLinenr)
+
+These callbacks are used to access the drawing canvas, background
+canvas and an optional separate alpha-channel canvas. The latter is
+used only with the MNG_CANVAS_RGB8_A8 canvas-style.
+
+If the getbkgdline() callback is not supplied the library will
+composite fully or partially transparent pixels in the image against
+a specified background color. See mng_set_bgcolor() for more details.
+If a chosen canvas-style includes an alpha-channel, this callback
+is very likely not needed.
+
+The application is responsible for returning a pointer to a line of
+pixels, which should be in the exact format as defined by the call
+to mng_set_canvasstyle() and mng_set_bkgdstyle(), without gaps between
+the representation of each pixel, unless specified by the canvas-style.
+
+\- mng_bool mng_refresh (mng_handle hHandle,
+ mng_uint32 iX,
+ mng_uint32 iY,
+ mng_uint32 iWidth,
+ mng_uint32 iHeight)
+
+This callback is called when the library has drawn a complete frame
+onto the drawing canvas, and it is ready to be displayed.
+The application is responsible for transferring the drawing canvas
+from memory onto the actual output device.
+
+\- mng_uint32 mng_gettickcount (mng_handle hHandle)
+
+This function should return the number of milliseconds on some internal
+clock. The entire animation timing depends heavily on this function,
+and the number returned should be as accurate as possible.
+
+\- mng_bool mng_settimer (mng_handle hHandle,
+ mng_uint32 iMsecs)
+
+This callback is activated every time the library requires a "pause".
+Note that the function itself should NOT execute the wait. It should
+simply store the time-field and allow the library to return. Libmng
+will return with the MNG_NEEDTIMERWAIT code, indicating the callback
+was called and it is now time to execute the pause.
+
+After the indicated number of milliseconds have elapsed, the application
+should call mng_display_resume(), to resume the animation as planned.
+
+This method allows for both a real timer or a simple wait command in the
+application. Whichever method you select, both the gettickcount() and
+settimer() callbacks are crucial for proper animation timing.
+
+\- mng_bool mng_processgamma (mng_handle hHandle,
+ mng_uint32 iGamma)
+
+\- mng_bool mng_processchroma (mng_handle hHandle,
+ mng_uint32 iWhitepointx,
+ mng_uint32 iWhitepointy,
+ mng_uint32 iRedx,
+ mng_uint32 iRedy,
+ mng_uint32 iGreenx,
+ mng_uint32 iGreeny,
+ mng_uint32 iBluex,
+ mng_uint32 iBluey)
+
+\- mng_bool mng_processsrgb (mng_handle hHandle,
+ mng_uint8 iRenderingintent)
+
+\- mng_bool mng_processiccp (mng_handle hHandle,
+ mng_uint32 iProfilesize,
+ mng_ptr pProfile)
+
+\- mng_bool mng_processarow (mng_handle hHandle,
+ mng_uint32 iRowsamples,
+ mng_bool bIsRGBA16,
+ mng_ptr pRow)
+
+These callbacks are only required when you selected the MNG_APP_CMS
+directive during compilation of the library. See the configuration
+section for more details.
+
+\- mng_bool mng_iteratechunk (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_chunkid iChunkid,
+ mng_uint32 iChunkseq)
+
+This callback is only used for the mng_iterate_chunks() function.
+It is called exactly once for each chunk stored.
+
+
+.SH III. Housekeeping
+
+
+.SS Memory management
+
+The library can use internal memory allocation/deallocation or use
+provided callbacks for its memory management. The choice is made at
+compilation time. See the section on customization for details.
+
+If internal management has been selected, the memory callback functions
+need not be supplied. Even if you do supply them they will not be used.
+The actual code used is similar to the code discussed in the callback
+section:
+
+ pPtr = calloc (1, iLen);
+
+ free (pPtr);
+
+If your compiler does not support these functions, or you wish to monitor
+the library's use of memory for certain reasons, you can choose to
+compile the library with external memory management. In this case the
+memory callback functions MUST be supplied, and should function as if the
+above code was used.
+
+
+.SS Initialization
+
+The basic initialization of the library is short and swift:
+
+ myhandle = mng_initialize (myuserdata, my_alloc,
+ my_free, MNG_NULL);
+ if (myhandle == MNG_NULL)
+ /* process error */;
+
+The first field is an application-only parameter. It is saved in
+libmng's internal structures and available at all times through the
+mng_get_userdata() function. This is especially handy in callback functions
+if your program may be handling multiple files at the same time.
+
+The second and third field supply the library with the memory callback
+function entry-points. These are described in more detail in the callback
+section and the previous paragraph.
+
+The fourth and last field may be used to supply the library with the
+entry-point of a trace callback function. For regular use you will not
+need this!
+
+The function returns a handle which will be your ticket to MNG-heaven.
+All other functions rely on this handle. It is the single fixed unique
+reference-point between your application and the library.
+
+You should call the initialization function for each image you wish to
+process simultaneously. If you are processing images consecutively, you can
+reset the internal status of the library with the mng_reset() function.
+This function will clear all internal state variables, free any stored
+chunks and/or objects, etc, etc. Your callbacks and other external parameters
+will be retained.
+
+After you successfully received the handle it is time to set the required
+callbacks. The sections on reading, displaying & writing indicate which
+callbacks are required and which are optional.
+To set the callbacks simply do:
+
+ myretcode = mng_setcb_xxxxxx (myhandle, my_xxxxxx);
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+Naturally you'd replace the x's with the name of the callback.
+
+
+.SS Cleanup
+
+Once you've gotten hold of that precious mng_handle, you should always,
+and I mean always, call the cleanup function when you're done.
+Just do:
+
+ mng_cleanup (myhandle);
+
+And you're done. There shouldn't be an ounce of memory spilled after
+that call.
+
+Note that if you would like to process multiple files consecutively
+you do not need to do mng_cleanup() / mng_initialize() between each file
+but simply
+
+ myretcode = mng_reset (myhandle);
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+will suffice. Saves some time and effort, that.
+
+
+.SS Error handling
+
+From the examples in the previous paragraphs you may have noticed a
+meticulous scheme for error handling. And yes, that's exactly what it is.
+Practically each call simply returns an errorcode, indicating success,
+eg. MNG_NOERROR or failure, anything else but MNG_NEEDMOREDATA and
+MNG_NEEDTIMERWAIT. These latter two will be discussed in more detail in
+their respective fields of interest: the reading section and displaying
+section respectively.
+
+It is the application's responsibility to check the returncode after
+each call. You can call mng_getlasterror() to receive the details of
+the last detected error. This even includes a discriptive error-message
+if you enabled that option during compilation of the library.
+
+Note that after receiving an error it is still possible to call the
+library, but it's also very likely that any following call will fail.
+The only functions deemed to work will be mng_reset() and mng_cleanup().
+Yes, if you abort your program after an error, you should still call
+mng_cleanup().
+
+
+.SH IV. Reading
+
+Reading a MNG, JNG or PNG is fairly easy. It depends slightly on your
+ultimate goal how certain specifics are to be handled, but the basics
+are similar in all cases.
+
+For the read functioins to work you must have compiled the library with
+the MNG_READ_SUPPRT directive. The standard DLL and Shared Library
+have this on by default!
+
+
+.SS Setup
+
+Naturally you must have initialized the library and be the owner of
+a mng_handle. The following callbacks are essential:
+
+ mng_openstream, mng_readdata, mng_closestream
+
+You may optionally define:
+
+ mng_errorproc, mng_traceproc
+ mng_processheader, mng_processtext
+ mng_processsave, mng_processseek
+
+The reading bit will also fail if you are already creating or
+displaying a file. Seems a bit obvious, but I thought I'd mention it,
+just in case.
+
+
+.SS To suspend or not to suspend
+
+There is one choice you need to make before calling the read function.
+Are you in need of suspension-mode or not?
+
+If you're reading from a disk you most certainly do not need
+suspension-mode. Even the oldest and slowest of disks will be fast
+enough for straight reading.
+
+However, if your input comes from a really slow device, such as a
+dialup-line or the likes, you may opt for suspension-mode. This is done
+by calling
+
+ myretcode = mng_set_suspensionmode (myhandle,
+ MNG_TRUE);
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+Suspension-mode will force the library to use special buffering on the
+input. This allows your application to receive data of arbitrarily length
+and return this in the mng_readdata() callback, without disturbing the
+chunk processing routines of the library.
+
+Suspension-mode does require a little extra care in the main logic of the
+application. The read function may return with MNG_NEEDMOREDATA when the
+mng_readdata() callback returns less data then it needs to process the
+next chunk. This indicates the application to wait for more data to arrive
+and then resume processing by calling mng_read_resume().
+
+
+.SS The read HLAPI
+
+The actual reading is just plain simple. Since all I/O is done
+outside the library through the callbacks, the library can focus on
+its real task. Understanding, checking and labelling the input data!
+
+All you really need to do is this:
+
+ myretcode = mng_read (myhandle);
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+Of course, if you're on suspension-mode the code is a little more
+complicated:
+
+ myretcode = mng_read (myhandle);
+
+ while (myretcode == MNG_NEEDMOREDATA) {
+ /* wait for input-data to arrive */
+ myretcode = mng_read_resume (myhandle);
+ }
+
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+This is rather crude and more sophisticated programming methods may
+dictate another approach. Whatever method you decide on, it should
+act as if the above code was in its place.
+
+There is also the mng_readdisplay() function, but this is discussed
+in the displaying section. It functions pretty much as the mng_read()
+function, but also immediately starts displaying the image.
+mng_read_resume() should be replaced by mng_display_resume() in that
+case!
+
+
+.SS What happens inside
+
+What actually happens inside the library depends on the configuration
+options set during the compilation of the library.
+
+Basically the library will first read the 8-byte file header, to determine
+its validity and the type of image it is about to process. Then it will
+repeatedly read a 4-byte chunk-length and then the remainder of the chunk
+until it either reaches EOF (indicated by the mng_readdata() callback) or
+implicitly decides EOF as it processed the logically last chunk of the
+image.
+
+Applications that require strict conformity and do not allow superfluous
+data after the ending chunk, will need to perform this check in their
+mng_closestream() callback.
+
+Each chunk is then checked on CRC, after which it is handed over to the
+appropriate chunk processing routine. These routines will disect the
+chunk, check the validity of its contents, check its position with respect
+to other chunks, etc, etc.
+
+If everything checks out, the chunk is further processed as follows:
+
+If display support has been selected during compilation, certain pre-display
+initialization will take place.
+
+If chunk-storage support has been selected during compilation, the chunks
+data may be stored in a special internal structure and held for future
+reference.
+
+
+.SS Storing and accessing chunks
+
+One of the compilation options activates support for chunk storage.
+This option may be useful if you want to examine an image. The directive
+is MNG_STORE_CHUNKS. You must also turn on the MNG_ACCESS_CHUNKS
+directive.
+
+The actual storage facility can be turned on or off with the
+mng_set_storechunks() function. If set to MNG_TRUE, chunks will be
+stored as they are read.
+
+At any point you can then call the mng_iterate_chunks() function
+to iterate through the current list of chunks. This function requires
+a callback which is called for each chunk and receives a specific
+chunk-handle. This chunk-handle can be used to call the appropriate
+mng_getchunk_xxxx() function, to access the chunks properties.
+
+A typical implementation may look like this:
+
+ mng_bool my_iteratechunk (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_chunkid iChunkid,
+ mng_uint32 iChunkseq) {
+ switch (iChunkid) {
+ case MNG_UINT_MHDR : { /* process MHDR */;
+ break; }
+ case MNG_UINT_FRAM : { /* process FRAM */;
+ break; }
+
+ ...etc...
+
+ case MNG_UINT_HUH : { /* unknown chunk */;
+ break; }
+ default : { /* duh; forgot one */; }
+ }
+
+ return MNG_TRUE; /* keep'm coming */
+ }
+
+To get to the actual chunk fields of lets say a SHOW chunk you would do:
+
+ mng_bool isempty;
+ mng_uint16 firstid, lastid;
+ mng_uint8 showmode;
+
+ myretcode mng_getchunk_show (hHandle, hChunk,
+ isempty, firstid,
+ lastid, showmode);
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+
+.SH V. Displaying
+
+
+.SS Setup
+
+Assuming you have initialized the library and are the owner of
+a mng_handle. The following callbacks are essential:
+
+ mng_getcanvasline, mng_refresh
+ mng_gettickcount, mng_settimer
+
+If you wish to use an application supplied background you must supply:
+
+ mng_getbkgdline
+
+If you wish to use the MNG_CANVAS_RGB8_A8 canvas style you must supply:
+
+ mng_getalphaline
+
+You may optionally define:
+
+ mng_errorproc, mng_traceproc
+ mng_processheader, mng_processtext
+ mng_processsave, mng_processseek
+
+Note that the mng_processheader() callback is optional but will
+be quite significant for proper operation!
+
+Displaying an image will fail if you are creating a file or already
+displaying one. Yes, you can't display it twice!
+
+
+.SS A word on canvas styles
+
+The canvas style describes how your drawing canvas is made up.
+You must set this before the library actually starts drawing, so
+the mng_processheader() callback is a pretty good place for it.
+
+Currently only 8-bit RGB canvas styles are supported, either with
+or without an alpha channel.
+
+If you like to do alpha composition yourself you can select one of
+the canvas styles that include an alpha channel. You can even have
+a separate alpha canvas by selecting the MNG_CANVAS_RGB8_A8 style.
+
+All styles require a compact model. Eg. MNG_CANVAS_BGR8 requires
+your canvas lines in bgrbgrbgr... storage, where each letter
+represents an 8-bit value of the corresponding color, and each
+threesome makes up the values of one(1) pixel.
+
+The library processes a line at a time, so the canvas lines do not
+actually need to be consecutive in memory.
+
+
+.SS Alpha composition and application backgrounds
+
+All Network Graphics can be partially transparent. This requires
+special processing if you need to display an image against some
+background. Note that the MNG header (MHDR chunk) contains a
+simplicity field indicating whether transparency information in
+the file is critical or not. This only applies to embedded images,
+which means the full image-frame of the MNG may still contain fully
+transparent pixels!
+
+Depending on your needs you can supply a single background color,
+a background canvas or tell the library to return the alpha-channel
+and do alpha composition yourself.
+
+This is different from the BACK chunk in a MNG, or the bKGD chunk
+in an (embedded) PNG or JNG. The BACK chunk indicates an optional or
+mandatory background color and/or image. The bKGD chunk only indicates
+an optional background color. These chunks indicate the Authors
+preferences. They may be absent in which case you need to supply
+some sort of background yourself.
+
+.SS Composing against a background color
+
+This is the easiest method. Call the mng_set_bgcolor() function to
+set the values of the red, green and blue component of your preferred
+background color.
+
+Use one of the canvas styles that do not have an alpha-channel, and
+which matches your output requirements.
+
+.SS Composing against a background canvas
+
+This is somewhat more complicated. You will need to set the
+mng_getbkgdline() callback. This will be called whenever the library
+needs to compose a partially transparent line.
+
+This canvas must hold the background against which the image should
+be composed. Its size must match exactly with the image dimensions
+and thus the drawing canvas!
+
+Use one of the canvas styles that do not have an alpha-channel, and
+which matches your output requirements. The canvas style of the
+background canvas may even differ from the drawing canvas. The library's
+composing will still function properly.
+
+.SS Composing within the application
+
+If you have the option in your application to draw a (partially)
+transparent canvas to the output device, this option is preferred.
+
+Select one of the canvas styles that do have an alpha-channel.
+The library will now supply the appropriate alpha information,
+allowing the application to compose the image as it sees fit.
+
+
+.SS Color information and CMS
+
+Network Graphics may, and usually will, contain color-correction
+information. This information is intended to compensate for the
+difference in recording and display devices used.
+
+This document does not address the specifics of color-management.
+See the PNG specification for a more detailed description.
+
+.SS Using little cms by Marti Maria Saguer
+
+This is the easiest method, providing you can compile the lcms package.
+Select the MNG_FULL_CMS directive during compilation, and sit back and
+relax. The library will take care of all color-correction for you.
+
+.SS Using an OS- or application-supplied CMS
+
+If you are so lucky to have access to CMS functionality from within
+your application, you may instruct the library to leave color-correction
+to you.
+
+Select the MNG_APP_CMS directive during compilation of the library.
+You MUST also set the following callbacks:
+
+ mng_processgamma, mng_processchroma,
+ mng_processsrgb, mng_processiccp and
+ mng_processarow
+
+The last callback is called when the library needs you to correct
+an arbitrary line of pixels. The other callbacks are called when
+the corresponding color-information is encountered in the file.
+You must store this information somewhere for use in the
+mng_processarow() callback.
+
+.SS Using gamma-only correction
+
+This isn't a preferred method, but it's better than no correction
+at all. Gamma-only correction will at least compensate for
+gamma-differences between the original recorder and your output device.
+
+Select the MNG_GAMMA_ONLY directive during compilation
+of the library. Your compiler MUST support fp operations.
+
+.SS No color correction
+
+Ouch. This is really bad. This is the least preferred method,
+but may be necessary if your system cannot use lcms, doesn't
+have its own CMS, and does not allow fp operations, ruling out
+the gamma-only option.
+
+Select the MNG_NO_CMS directive during compilation.
+Images will definitely not be displayed as seen by the Author!!!
+
+
+.SS Animations and timing
+
+Animations require some form of timing support. The library relies
+on two callbacks for this purpose. The mng_gettickcount() and
+mng_settimer() callbacks. mng_gettickcount() is used to determine
+the passing of time in milliseconds since the beginning of the
+animation. This is also used to compensate during suspension-mode
+if you are using the mng_readdisplay() function to read & display
+the file simultaneously.
+
+The callback may return an arbitrary number of milliseconds, but
+this number must increase proportionaly between calls. Most modern
+systems will have some tickcount() function which derives its
+input from an internal clock. The value returned from this function
+is more than adequate for libmng.
+
+The mng_settimer() callback is called when the library determines
+a little "pause" is required before rendering another frame of the
+animation. The pause interval is also expressed in milliseconds.
+Your application should store this value and return immediately.
+The library will then make appropriate arrangements to store its
+internal state and returns to your application with the
+MNG_NEEDTIMERWAIT code.
+
+At that point you should suspend processing and wait the given
+interval. Please use your OS features for this. Do not engage some
+sort of loop. That is real bad programming practice. Most modern
+systems will have some timing functions. A simple wait() function
+may suffice, but this may prevent your applications main-task from
+running, and possibly prevent the actual update of your output device.
+
+
+.SS The mng_refresh() callback
+
+The mng_refresh() callback is called whenever the library has
+"finished" drawing a new frame onto your canvas, and just before it
+will call the mng_settimer() callback.
+
+This allows you to perform some actions necessary to "refresh" the
+canvas onto your output device. Please do NOT suspend processing
+inside this callback. This must be handled after the mng_settimer()
+callback!
+
+
+.SS Displaying while reading
+
+This method is preferred if you are reading from a slow input device
+(such as a dialup-line) and you wish to start displaying something
+as quickly as possible. This functionality is provided mainly for
+browser-type applications but may be appropriate for other
+applications as well.
+
+The method is usually used in unison with the suspension-mode of
+the read module. A typical implementation would look like this:
+
+ /* initiale library and set required callbacks */
+
+ /* activate suspension-mode */
+ myretcode = mng_set_suspensionmode (myhandle,
+ MNG_TRUE);
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+ myretcode = mng_readdisplay (myhandle);
+
+ while ((myretcode == MNG_NEEDMOREDATA) ||
+ (myretcode == MNG_NEEDTIMERWAIT)) {
+ if (myretcode == MNG_NEEDMOREDATA)
+ /* wait for more input-data */;
+ else
+ /* wait for timer interval */;
+
+ myretcode = mng_display_resume (myhandle);
+ }
+
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+More advanced programming methods may require a different approach,
+but the final result should function as in the code above.
+
+
+.SS Displaying after reading
+
+This method is used to display a file that was previously read.
+It is primarily meant for viewers with direct file access, such as
+1a local harddisk.
+
+Once you have successfully read the file, all you need to do is:
+
+ myretcode = mng_display (myhandle);
+
+ while (myretcode == MNG_NEEDTIMERWAIT) {
+ /* wait for timer interval */;
+ myretcode = mng_display_resume (myhandle);
+ }
+
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+Again, more advanced programming methods may require a different
+approach, but the final result should function as in the code above.
+
+
+.SS Display manipulation
+
+Several HLAPI functions are provided to allow a user to manipulate
+the normal flow of an animation.
+
+\- mng_display_freeze (mng_handle hHandle)
+
+This will "freeze" the animation in place.
+
+\- mng_display_resume (mng_handle hHandle)
+
+This function can be used to resume a frozen animation, or to force
+the library to advance the animation to the next frame.
+
+\- mng_display_reset (mng_handle hHandle)
+
+This function will "reset" the animation into its pristine state.
+Calling mng_display() afterwards will re-display the animation
+from the first frame.
+
+\- mng_display_golayer (mng_handle hHandle,
+ mng_uint32 iLayer)
+
+\- mng_display_goframe (mng_handle hHandle,
+ mng_uint32 iFrame)
+
+\- mng_display_gotime (mng_handle hHandle,
+ mng_uint32 iPlaytime)
+
+These three functions can be used to "jump" to a specific layer, frame
+or timeslot in the animation. You must "freeze" the animation before
+using any of these functions.
+
+All above functions may only be called during a timer interval!
+It is the applications responsibility to cleanup any resources with
+respect to the timer wait.
+
+
+.SH VI. Writing
+
+The main focus of the library lies in its displaying capabilites.
+But it does offer writing support as well.
+You can create and write a file, or you can write a file you
+have previously read, providing the storage of chunks was enabled
+and active.
+
+For this to work you must have compiled the library with the
+MNG_WRITE_SUPPO1RT and MNG_ACCESS_CHUNKS directives. The standard DLL and
+Shared Library have this on by default!
+
+
+.SS Setup
+
+As always you must have initialized the library and be the owner of
+a mng_handle. The following callbacks are essential:
+
+ mng_openstream, mng_writedata, mng_closestream
+
+You can optionally define:
+
+ mng_errorproc, mng_traceproc
+
+The creation and writing functions will fail if you are in the middle
+of reading, creating or writing a file.
+
+
+.SS Creating a new file
+
+To start a new file the library must be in its initial state.
+First you need to tell the library your intentions:
+
+ myretcode = mng_create (myhandle);
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+After that you start adding the appropriate chunks:
+
+ myretcode = mng_put1chunk_mhdr (myhandle, ...);
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+And so on, and so forth. Note that the library will automatically signal
+the logical end of the file by the ending chunk. Also the first chunk
+will indicate the library the filetype (eg. PNG, JNG or MNG) and force
+the proper signature when writing the file.
+
+The code above can be simplified, as you can always get the last errorcode
+by using the mng_getlasterror() function:
+
+ if ( (mng_putchunk_xxxx (myhandle, ...)) or
+ (mng_putchunk_xxxx (myhandle, ...)) or
+ ...etc... )
+ /* process error */;
+
+Please note that you must have a pretty good understanding of the chunk
+specification. Unlike the read functions, there are virtually no checks,
+so it is quite possible to write completely wrong files.
+It is a good practice to read back your file into the library to verify
+its integrity.
+
+Once you've got all the chunks added, all you do is:
+
+ myretcode mng_write (myhandle);
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+And presto. You're done. The real work is of course carried out in
+your callbacks. Note that this is a single operation as opposed to
+the read & display functions that may return with MNG_NEEDMOREDATA
+and/or MNG_NEEDTIMERWAIT. The write function just does the job, and
+only returns after it's finished or if it encounters some
+unrecoverable error.
+
+
+.SS Writing a previously read file
+
+If you have already successfully read a file, you can use the library to
+write it out as a copy or something. You MUST have compiled the library
+with the MNG_STORE_CHUNKS directive, and you must have done
+mng_set_storechunks (myhandle, MNG_TRUE).
+
+This doesn't require the MNG_ACCESS_CHUNKS directive, unless you want
+to fiddle with the chunks as well.
+
+Again all you need to do is:
+
+ myretcode mng_write (myhandle);
+ if (myretcode != MNG_NOERROR)
+ /* process error */;
+
+
+.SH VII. Modifying/Customizing libmng:
+
+not finished yet
+
+.SS Compilation directives
+
+not finished yet
+
+.SS Platform dependant modification
+
+not finished yet
+
+.SH "SEE ALSO"
+.IR mng(5), jng(5), png(5), libpng(3)
+
+.LP
+libmng :
+.IP
+.br
+http://www.libmng.com
+
+.LP
+zlib :
+.IP
+.br
+http://www.info-zip.org/pub/infozip/zlib/
+
+.LP
+IJG JPEG library :
+.IP
+.br
+http://www.ijg.org
+
+.LP
+lcms (little CMS) by Marti Maria Saguer :
+.IP
+.br
+http://www.littlecms.com/
+
+.LP
+MNG specification:
+.IP
+.br
+http://www.libpng.org/pub/mng
+
+.LP
+In the case of any inconsistency between the MNG specification
+and this library, the specification takes precedence.
+
+
+.SH AUTHORS
+This man page: Gerard Juyn
+<gerard at libmng.com>
+
+The contributing authors would like to thank all those who helped
+with testing, bug fixes, and patience. This wouldn't have been
+possible without all of you!!!
+
+
+.SH COPYRIGHT NOTICE:
+
+Copyright (c) 2000-2002 Gerard Juyn
+
+For the purposes of this copyright and license, "Contributing Authors"
+is defined as the following set of individuals:
+
+ Gerard Juyn
+
+The MNG Library is supplied "AS IS". The Contributing Authors
+disclaim all warranties, expressed or implied, including, without
+limitation, the warranties of merchantability and of fitness for any
+purpose. The Contributing Authors assume no liability for direct,
+indirect, incidental, special, exemplary, or consequential damages,
+which may result from the use of the MNG Library, even if advised of
+the possibility of such damage.
+
+Permission is hereby granted to use, copy, modify, and distribute this
+source code, or portions hereof, for any purpose, without fee, subject
+to the following restrictions:
+
+1. The origin of this source code must not be misrepresented;
+you must not claim that you wrote the original software.
+
+2. Altered versions must be plainly marked as such and must not be
+misrepresented as being the original source.
+
+3. This Copyright notice may not be removed or altered from any source
+or altered source distribution.
+
+The Contributing Authors specifically permit, without fee, and
+encourage the use of this source code as a component to supporting
+the MNG and JNG file format in commercial products. If you use this
+source code in a product, acknowledgment would be highly appreciated.
+
+.SH Remarks
+
+Parts of this software have been adapted from the libpng library.
+Although this library supports all features from the PNG specification
+(as MNG descends from it) it does not require the libpng library.
+It does require the zlib library and optionally the IJG JPEG library,
+and/or the "little-cms" library by Marti Maria Saguer (depending on the
+inclusion of support for JNG and Full-Color-Management respectively.
+
+This library's function is primarily to read and display MNG
+animations. It is not meant as a full-featured image-editing
+component! It does however offer creation and editing functionality
+at the chunk level. (future modifications may include some more
+support for creation and or editing)
+
+.\" end of man page
diff --git a/src/3rdparty/libmng/doc/man/mng.5 b/src/3rdparty/libmng/doc/man/mng.5
new file mode 100644
index 0000000000..e40c249100
--- /dev/null
+++ b/src/3rdparty/libmng/doc/man/mng.5
@@ -0,0 +1,42 @@
+.TH MNG 5 "July 25, 2000"
+.SH NAME
+mng \- Multiple-image Network Graphics (MNG) format
+.SH DESCRIPTION
+MNG (Multiple-image Network Graphics) is the animation extension of the
+popular PNG image-format. PNG (Portable Network Graphics) is an
+extensible file format for the lossless, portable, well-compressed
+storage of raster images.
+.br
+
+MNG has advanced animation features which make it very useful as a full
+replacement for GIF animations. These features allow animations that
+are impossible with GIF or result in much smaller files as GIF.
+
+As MNG builds on the same structure as PNG, it is robust, extensible and
+free of patents. It retains the same clever file integrity checks as in PNG.
+
+MNG also embraces the lossy JPEG image-format in a sub-format named JNG,
+which allows for alpha-transparency and color-correction on highly
+compressed (photographic) images.
+
+.SH "SEE ALSO"
+.IR png(5) ", " jng(5) ", " libmng(3) ", " libpng(3) ", " zlib(3) ", "
+deflate(5) ", " zlib(5) ", " jpeg(5)
+.LP
+MNG 1.00, Februari 9, 2001:
+.IP
+.br
+http://www.libpng.org/pub/mng
+.SH AUTHORS
+This man page: Gerard Juyn
+.LP
+Multiple-image Network Graphics (MNG) Specification Version 1.00 (Februari 9, 2001):
+Glenn Randers-Pehrson and others (png-list@ccrc.wustl.edu).
+.LP
+
+.SH COPYRIGHT NOTICE
+The MNG-1.00 specification is copyright (c) 1998-2001 Glenn Randers-Pehrson.
+See the specification for conditions of use and distribution.
+.LP
+.\" end of man page
+
diff --git a/src/3rdparty/libmng/doc/misc/magic.dif b/src/3rdparty/libmng/doc/misc/magic.dif
new file mode 100644
index 0000000000..005ad5a746
--- /dev/null
+++ b/src/3rdparty/libmng/doc/misc/magic.dif
@@ -0,0 +1,30 @@
+--- magic.orig Wed Aug 14 16:48:56 2002
++++ magic Wed Aug 14 16:50:09 2002
+@@ -2544,6 +2544,27 @@
+ >>28 byte 1 interlaced
+ 1 string PNG PNG image data, CORRUPTED
+
++#MNG
++# 0x8a M N G 0x0d 0x0a 0x1a 0x0a [4-byte pad]
++# M H D R [4-byte width][4-byte height][4-byte ticks][4-byte layers]
++# [4-byte frame][4-byte time]
++#
++0 string \x8aMNG MNG image data,
++>4 belong !0x0d0a1a0a CORRUPTED
++>4 belong 0x0d0a1a0a
++>>16 belong x %ld x
++>>20 belong x %ld
++
++#JNG
++# 0x8b J N G 0x0d 0x0a 0x1a 0x0a [4-byte pad]
++# J H D R [4-byte width][4-byte height]
++#
++0 string \x8bJNG JNG image data,
++>4 belong !0x0d0a1a0a CORRUPTED
++>4 belong 0x0d0a1a0a
++>>16 belong x %ld x
++>>20 belong x %ld
++
+ # GIF
+ 0 string GIF8 GIF image data
+ >4 string 7a \b, version 8%s,
diff --git a/src/3rdparty/libmng/doc/rpm/libmng-1.0.10-rhconf.patch b/src/3rdparty/libmng/doc/rpm/libmng-1.0.10-rhconf.patch
new file mode 100644
index 0000000000..a73b79dbe5
--- /dev/null
+++ b/src/3rdparty/libmng/doc/rpm/libmng-1.0.10-rhconf.patch
@@ -0,0 +1,38 @@
+--- libmng/makefiles/makefile.linux.orig Sat Jul 1 15:10:35 2000
++++ libmng/makefiles/makefile.linux Sat Jul 1 15:14:52 2000
+@@ -13,19 +13,19 @@
+ OPTIONS = -DMNG_BUILD_SO
+
+ # where "make install" puts libmng.a,libmng.so*,libmng.h,libmng_conf.h,libmng_types.h
+-prefix=/usr/local
++prefix=/usr
+
+ # Where the zlib library and include files are located
+-ZLIBLIB=../zlib
+-ZLIBINC=../zlib
++ZLIBLIB=/usr/lib
++ZLIBINC=/usr/include
+
+ # Where the jpeg library and include files are located
+-JPEGLIB=../jpgsrc
+-JPEGINC=../jpgsrc
++JPEGLIB=/usr/lib
++JPEGINC=/usr/include
+
+ # Where the lcms library and include files are located
+-LCMSLIB=../lcms/lib
+-LCMSINC=../lcms/source
++LCMSLIB=/usr/lib
++LCMSINC=/usr/include
+
+ ALIGN=
+ # for i386:
+@@ -37,7 +37,7 @@
+
+ # for pgcc version 2.95.1, -O3 is buggy; don't use it.
+
+-CFLAGS=-I$(ZLIBINC) -I$(JPEGINC) -I$(LCMSINC) -Wall -O3 -funroll-loops \
++CFLAGS=-I$(ZLIBINC) -I$(JPEGINC) -I$(LCMSINC) -Wall $(RPM_OPT_FLAGS) \
+ $(OPTIONS) $(ALIGN) # $(WARNMORE) -g
+ LDFLAGS=-L. -Wl,-rpath,. \
+ -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
diff --git a/src/3rdparty/libmng/doc/rpm/libmng.spec b/src/3rdparty/libmng/doc/rpm/libmng.spec
new file mode 100644
index 0000000000..89908d7a97
--- /dev/null
+++ b/src/3rdparty/libmng/doc/rpm/libmng.spec
@@ -0,0 +1,116 @@
+Summary: A library of functions for manipulating MNG format files.
+Name: libmng
+Version: 1.0.10
+Release: 2.1
+Copyright: AS IS
+Group: System Environment/Libraries
+Source0: libmng-%{PACKAGE_VERSION}.tar.gz
+Patch: libmng-%{PACKAGE_VERSION}-rhconf.patch
+URL: http://www.libmng.com/
+BuildRoot: /var/tmp/libmng-root
+BuildPrereq: libjpeg-devel, zlib-devel, lcms-devel
+
+%description
+libmng - library for reading, writing, displaying and examing
+Multiple-Image Network Graphics. MNG is the animation extension to the
+popular PNG image-format.
+
+%package devel
+Summary: Development tools for programs to manipulate MNG format files.
+Group: Development/Libraries
+Requires: libmng = %{PACKAGE_VERSION}
+%description devel
+The libmng-devel package contains the header files and static
+libraries necessary for developing programs using the MNG
+(Multiple-Image Network Graphics) library.
+
+If you want to develop programs which will manipulate MNG image format
+files, you should install libmng-devel. You'll also need to install
+the libmng package.
+
+%changelog
+* Fri Jul 13 2007 Glenn Randers-Pehrson <glennrp at users.sf.net>
+- updated to 1.0.10
+
+* Thu Aug 5 2004 Gerard Juyn <gerard at libmng.com>
+* Sun Jan 30 2005 Gerard Juyn <gerard at libmng.com>
+- updated to 1.0.9
+
+* Thu Aug 5 2004 Gerard Juyn <gerard at libmng.com>
+- updated to 1.0.8
+
+* Sun Mar 21 2004 Gerard Juyn <gerard at libmng.com>
+- updated to 1.0.7
+
+* Sun Oct 19 2003 Gerard Juyn <gerard at libmng.com>
+- updated to 1.0.6
+
+* Tue Sep 24 2002 Gerard Juyn <gerard at libmng.com>
+- updated to 1.0.5
+
+* Sun Jun 23 2002 Gerard Juyn <gerard at libmng.com>
+- updated to 1.0.4
+
+* Mon Sep 18 2001 Gerard Juyn <gerard at libmng.com>
+- updated to 1.0.3
+
+* Sat Jul 7 2001 Gerard Juyn <gerard at libmng.com>
+- updated to 1.0.2
+
+* Wed May 2 2001 Gerard Juyn <gerard at libmng.com>
+- updated to 1.0.1
+
+* Mon Feb 5 2001 Gerard Juyn <gerard at libmng.com>
+- updated to 1.0.0
+
+* Fri Jan 19 2001 Gerard Juyn <gerard at libmng.com>
+- updated to 0.9.4
+
+* Sat Oct 28 2000 Gerard Juyn <gerard at libmng.com>
+- updated to 0.9.3
+
+* Tue Aug 15 2000 MATSUURA Takanori <t-matsuu at protein.osaka-u.ac.jp>
+- based on libmng-0.9.2/doc/rpm/libmng.spec
+- use %%configure and %%makeinstall
+
+* Sat Aug 5 2000 Gerard Juyn <gerard at libmng.com>
+- updated to 0.9.2
+
+* Wed Jul 26 2000 Gerard Juyn <gerard at libmng.com>
+- updated to 0.9.1
+
+* Sat Jul 1 2000 MATSUURA Takanori <t-matsuu at protein.osaka-u.ac.jp>
+- updated to 0.9.0
+
+* Sat Jun 24 2000 MATSUURA Takanori <t-matsuu at protein.osaka-u.ac.jp>
+- 1st release for RPM
+
+%prep
+%setup
+%configure
+
+%build
+make
+
+%install
+rm -rf $RPM_BUILD_ROOT
+%makeinstall
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%defattr(-,root,root)
+%doc CHANGES LICENSE README doc
+/usr/lib/libmng.so.*
+
+%files devel
+%defattr(-,root,root)
+/usr/include/*
+/usr/lib/libmng.a
+/usr/lib/libmng.so
+
diff --git a/src/3rdparty/libmng/libmng.h b/src/3rdparty/libmng/libmng.h
new file mode 100644
index 0000000000..b3b1ab1418
--- /dev/null
+++ b/src/3rdparty/libmng/libmng.h
@@ -0,0 +1,2932 @@
+/* ************************************************************************** */
+/* * * */
+/* * COPYRIGHT NOTICE: * */
+/* * * */
+/* * Copyright (c) 2000-2007 Gerard Juyn * */
+/* * [You may insert additional notices after this sentence if you modify * */
+/* * this source] * */
+/* * * */
+/* * For the purposes of this copyright and license, "Contributing Authors" * */
+/* * is defined as the following set of individuals: * */
+/* * * */
+/* * Gerard Juyn - gjuyn :at: users.sourceforge.net * */
+/* * Glenn Randers-Pehrson - glennrp :at: users.sourceforge.net * */
+/* * Raphael Assenat - raph :at: raphnet.net * */
+/* * John Stiles - * */
+/* * * */
+/* * The MNG Library is supplied "AS IS". The Contributing Authors * */
+/* * disclaim all warranties, expressed or implied, including, without * */
+/* * limitation, the warranties of merchantability and of fitness for any * */
+/* * purpose. The Contributing Authors assume no liability for direct, * */
+/* * indirect, incidental, special, exemplary, or consequential damages, * */
+/* * which may result from the use of the MNG Library, even if advised of * */
+/* * the possibility of such damage. * */
+/* * * */
+/* * Permission is hereby granted to use, copy, modify, and distribute this * */
+/* * source code, or portions hereof, for any purpose, without fee, subject * */
+/* * to the following restrictions: * */
+/* * * */
+/* * 1. The origin of this source code must not be misrepresented; * */
+/* * you must not claim that you wrote the original software. * */
+/* * * */
+/* * 2. Altered versions must be plainly marked as such and must not be * */
+/* * misrepresented as being the original source. * */
+/* * * */
+/* * 3. This Copyright notice may not be removed or altered from any source * */
+/* * or altered source distribution. * */
+/* * * */
+/* * The Contributing Authors specifically permit, without fee, and * */
+/* * encourage the use of this source code as a component to supporting * */
+/* * the MNG and JNG file format in commercial products. If you use this * */
+/* * source code in a product, acknowledgment would be highly appreciated. * */
+/* * * */
+/* ************************************************************************** */
+/* * * */
+/* * Parts of this software have been adapted from the libpng package. * */
+/* * Although this library supports all features from the PNG specification * */
+/* * (as MNG descends from it) it does not require the libpng package. * */
+/* * It does require the zlib library and optionally the IJG jpeg library, * */
+/* * and/or the "little-cms" library by Marti Maria (depending on the * */
+/* * inclusion of support for JNG and Full-Color-Management respectively. * */
+/* * * */
+/* * This library's function is primarily to read and display MNG * */
+/* * animations. It is not meant as a full-featured image-editing * */
+/* * component! It does however offer creation and editing functionality * */
+/* * at the chunk level. * */
+/* * (future modifications may include some more support for creation * */
+/* * and or editing) * */
+/* * * */
+/* ************************************************************************** */
+
+/* ************************************************************************** */
+/* * * */
+/* * Version numbering * */
+/* * * */
+/* * X.Y.Z : X = release (0 = initial build) * */
+/* * Y = major version (uneven = test; even = production) * */
+/* * Z = minor version (bugfixes; 2 is older than 10) * */
+/* * * */
+/* * production versions only appear when a test-version is extensively * */
+/* * tested and found stable or for intermediate bug-fixes (recognized by * */
+/* * a change in the Z number) * */
+/* * * */
+/* * x.1.x = test version * */
+/* * x.2.x = production version * */
+/* * x.3.x = test version * */
+/* * x.4.x = production version * */
+/* * etc. * */
+/* * * */
+/* ************************************************************************** */
+/* * * */
+/* * Identifier naming conventions throughout this library * */
+/* * * */
+/* * iXxxx = an integer * */
+/* * dXxxx = a float * */
+/* * pXxxx = a pointer * */
+/* * bXxxx = a boolean * */
+/* * eXxxx = an enumeration * */
+/* * hXxxx = a handle * */
+/* * zXxxx = a zero-terminated string (pchar) * */
+/* * fXxxx = a pointer to a function (callback) * */
+/* * aXxxx = an array * */
+/* * sXxxx = a structure * */
+/* * * */
+/* * Macros & defines are in all uppercase. * */
+/* * Functions & typedefs in all lowercase. * */
+/* * Exported stuff is prefixed with MNG_ or mng_ respectively. * */
+/* * * */
+/* * (I may have missed a couple; don't hesitate to let me know!) * */
+/* * * */
+/* ************************************************************************** */
+
+/* ************************************************************************** */
+/* * * */
+/* * project : libmng * */
+/* * file : libmng.h copyright (c) 2000-2007 G.Juyn * */
+/* * version : 1.0.10 * */
+/* * * */
+/* * purpose : main application interface * */
+/* * * */
+/* * author : G.Juyn * */
+/* * * */
+/* * comment : The main application interface. An application should not * */
+/* * need access to any of the other modules! * */
+/* * * */
+/* * changes : 0.5.1 - 05/06/2000 - G.Juyn * */
+/* * - changed chunk iteration function * */
+/* * 0.5.1 - 05/08/2000 - G.Juyn * */
+/* * - added chunk access functions * */
+/* * - added version control constants & functions * */
+/* * - changed strict-ANSI stuff * */
+/* * 0.5.1 - 05/11/2000 - G.Juyn * */
+/* * - added set_outputprofile2 & set_srgbprofile2 * */
+/* * - added empty-chunk put-routines * */
+/* * 0.5.1 - 05/12/2000 - G.Juyn * */
+/* * - added version_dll & VERSION_DLL (for consistency) * */
+/* * - added version control explanatory text & samples * */
+/* * 0.5.1 - 05/15/2000 - G.Juyn * */
+/* * - added getimgdata & putimgdata functions * */
+/* * * */
+/* * 0.5.2 - 05/16/2000 - G.Juyn * */
+/* * - changed the version parameters (obviously) * */
+/* * 0.5.2 - 05/18/2000 - G.Juyn * */
+/* * - complimented constants for chunk-property values * */
+/* * 0.5.2 - 05/23/2000 - G.Juyn * */
+/* * - fixed MNG_UINT_pHYg value * */
+/* * 0.5.2 - 05/24/2000 - G.Juyn * */
+/* * - added support for get/set default zlib/IJG parms * */
+/* * 0.5.2 - 06/02/2000 - G.Juyn * */
+/* * - added MNG_BIGENDIAN_SUPPORT (contributed by Tim Rowley) * */
+/* * - separated configuration-options into "mng_conf.h" * */
+/* * - added RGB8_A8 canvasstyle * */
+/* * - added getalphaline callback for RGB8_A8 canvasstyle * */
+/* * 0.5.2 - 06/06/2000 - G.Juyn * */
+/* * - moved errorcodes from "mng_error.h" * */
+/* * - added mng_read_resume function to support * */
+/* * read-suspension * */
+/* * * */
+/* * 0.5.3 - 06/16/2000 - G.Juyn * */
+/* * - changed the version parameters (obviously) * */
+/* * 0.5.3 - 06/21/2000 - G.Juyn * */
+/* * - added get/set for speedtype to facilitate testing * */
+/* * - added get for imagelevel during processtext callback * */
+/* * 0.5.3 - 06/24/2000 - G.Juyn * */
+/* * - fixed inclusion of IJG read/write code * */
+/* * 0.5.3 - 06/26/2000 - G.Juyn * */
+/* * - changed userdata variable to mng_ptr * */
+/* * * */
+/* * 0.9.0 - 06/30/2000 - G.Juyn * */
+/* * - changed refresh parameters to 'x,y,width,height' * */
+/* * * */
+/* * 0.9.1 - 07/06/2000 - G.Juyn * */
+/* * - added MNG_NEEDTIMERWAIT errorcode * */
+/* * - changed comments to indicate modified behavior for * */
+/* * timer & suspension breaks * */
+/* * 0.9.1 - 07/08/2000 - G.Juyn * */
+/* * - added get routines for internal display variables * */
+/* * - added get/set routines for suspensionmode variable * */
+/* * 0.9.1 - 07/15/2000 - G.Juyn * */
+/* * - added callbacks for SAVE/SEEK processing * */
+/* * - added get/set routines for sectionbreak variable * */
+/* * - added NEEDSECTIONWAIT errorcode * */
+/* * 0.9.1 - 07/19/2000 - G.Juyn * */
+/* * - added function to set frame-/layer-count & playtime * */
+/* * - added errorcode for updatemngheader if not a MNG * */
+/* * * */
+/* * 0.9.2 - 07/31/2000 - G.Juyn * */
+/* * - fixed problem with trace-functions improperly wrapped * */
+/* * - added status_xxxx functions * */
+/* * 0.9.2 - 08/05/2000 - G.Juyn * */
+/* * - changed file-prefixes * */
+/* * - added function to set simplicity field * */
+/* * * */
+/* * 0.9.3 - 08/09/2000 - G.Juyn * */
+/* * - added check for simplicity-bits in MHDR * */
+/* * 0.9.3 - 08/12/2000 - G.Juyn * */
+/* * - added workaround for faulty PhotoShop iCCP chunk * */
+/* * 0.9.3 - 08/26/2000 - G.Juyn * */
+/* * - added MAGN chunk * */
+/* * 0.9.3 - 09/07/2000 - G.Juyn * */
+/* * - added support for new filter_types * */
+/* * 0.9.3 - 10/10/2000 - G.Juyn * */
+/* * - added support for alpha-depth prediction * */
+/* * 0.9.3 - 10/11/2000 - G.Juyn * */
+/* * - fixed processing of unknown critical chunks * */
+/* * - removed test-MaGN * */
+/* * - added PNG/MNG spec version indicators * */
+/* * - added support for nEED * */
+/* * 0.9.3 - 10/16/2000 - G.Juyn * */
+/* * - added functions to retrieve PNG/JNG specific header-info * */
+/* * - added JDAA chunk * */
+/* * 0.9.3 - 10/17/2000 - G.Juyn * */
+/* * - added callback to process non-critical unknown chunks * */
+/* * 0.9.3 - 10/20/2000 - G.Juyn * */
+/* * - added errocode for delayed delta-processing * */
+/* * - added get/set for bKGD preference setting * */
+/* * 0.9.3 - 10/21/2000 - G.Juyn * */
+/* * - added get function for interlace/progressive display * */
+/* * * */
+/* * 0.9.4 - 01/18/2001 - G.Juyn * */
+/* * - added errorcode for MAGN methods * */
+/* * - removed test filter-methods 1 & 65 * */
+/* * * */
+/* * 1.0.0 - 02/05/2001 - G.Juyn * */
+/* * - version numbers (obviously) * */
+/* * * */
+/* * 1.0.1 - 02/08/2001 - G.Juyn * */
+/* * - added MEND processing callback * */
+/* * 1.0.1 - 04/21/2001 - G.Juyn (code by G.Kelly) * */
+/* * - added BGRA8 canvas with premultiplied alpha * */
+/* * 1.0.1 - 05/02/2001 - G.Juyn * */
+/* * - added "default" sRGB generation (Thanks Marti!) * */
+/* * * */
+/* * 1.0.2 - 06/23/2001 - G.Juyn * */
+/* * - added optimization option for MNG-video playback * */
+/* * - added processterm callback * */
+/* * 1.0.2 - 06/25/2001 - G.Juyn * */
+/* * - added late binding errorcode (not used internally) * */
+/* * - added option to turn off progressive refresh * */
+/* * * */
+/* * 1.0.3 - 08/06/2001 - G.Juyn * */
+/* * - added get function for last processed BACK chunk * */
+/* * * */
+/* * 1.0.5 - 07/04/2002 - G.Juyn * */
+/* * - added errorcode for extreme chunk-sizes * */
+/* * 1.0.5 - 08/07/2002 - G.Juyn * */
+/* * - added test-option for PNG filter method 193 (=no filter) * */
+/* * 1.0.5 - 08/15/2002 - G.Juyn * */
+/* * - completed PROM support * */
+/* * - completed delta-image support * */
+/* * 1.0.5 - 08/19/2002 - G.Juyn * */
+/* * - added HLAPI function to copy chunks * */
+/* * 1.0.5 - 09/14/2002 - G.Juyn * */
+/* * - added event handling for dynamic MNG * */
+/* * - added 'supports' call to check function availability * */
+/* * 1.0.5 - 09/15/2002 - G.Juyn * */
+/* * - fixed LOOP iteration=0 special case * */
+/* * 1.0.5 - 09/20/2002 - G.Juyn * */
+/* * - added support for PAST * */
+/* * 1.0.5 - 09/22/2002 - G.Juyn * */
+/* * - added bgrx8 canvas (filler byte) * */
+/* * 1.0.5 - 10/07/2002 - G.Juyn * */
+/* * - added check for TERM placement during create/write * */
+/* * - added beta version function & constant * */
+/* * 1.0.5 - 11/07/2002 - G.Juyn * */
+/* * - added support to get totals after mng_read() * */
+/* * * */
+/* * 1.0.6 - 07/07/2003 - G. Randers-Pehrson * */
+/* * - added support for reducing the footprint of libmng * */
+/* * by macros that optionally skip unused chunks, remove * */
+/* * 16-bit sample support, remove Delta support, and * */
+/* * remove JNG support, to accomodate Mozilla/Firebird. * */
+/* * 1.0.6 - 07/14/2003 - G. Randers-Pehrson * */
+/* * - further optional removal of unused functions * */
+/* * * */
+/* * 1.0.7 - 11/27/2003 - R.A * */
+/* * - added CANVAS_RGB565 and CANVAS_BGR565 * */
+/* * 1.0.7 - 12/06/2003 - R.A * */
+/* * - added CANVAS_RGBA565 and CANVAS_BGRA565 * */
+/* * 1.0.7 - 01/25/2004 - J.S * */
+/* * - added premultiplied alpha canvas' for RGBA, ARGB, ABGR * */
+/* * 1.0.7 - 03/07/2004 - G. Randers-Pehrson * */
+/* * - put gamma, cms-related declarations inside #ifdef * */
+/* * 1.0.7 - 03/10/2004 - G.R-P * */
+/* * - added conditionals around openstream/closestream * */
+/* * * */
+/* * 1.0.8 - 04/02/2004 - G.Juyn * */
+/* * - added CRC existence & checking flags * */
+/* * 1.0.8 - 04/12/2004 - G.Juyn * */
+/* * - added data-push mechanisms for specialized decoders * */
+/* * 1.0.8 - 06/05/2004 - G.R-P * */
+/* * - define MNG_INCLUDE_ZLIB when MNG_USE_ZLIB_CRC is defined * */
+/* * * */
+/* * 1.0.9 - 10/03/2004 - G.Juyn * */
+/* * - added function to retrieve current FRAM delay * */
+/* * 1.0.9 - 10/14/2004 - G.Juyn * */
+/* * - added bgr565_a8 canvas-style (thanks to J. Elvander) * */
+/* * 1.0.9 - 10/17/2004 - G.Juyn * */
+/* * - fixed PPLT getchunk/putchunk routines * */
+/* * * */
+/* * 1.0.10 - 03/07/2006 - (thanks to W. Manthey) * */
+/* * - added CANVAS_RGB555 and CANVAS_BGR555 * */
+/* * 1.0.10 - 04/08/2007 - G.Juyn * */
+/* * - added support for mPNG proposal * */
+/* * 1.0.10 - 04/12/2007 - G.Juyn * */
+/* * - added support for ANG proposal * */
+/* * * */
+/* ************************************************************************** */
+
+#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
+#pragma option -A /* force ANSI-C */
+#endif
+
+#ifndef _libmng_h_
+#define _libmng_h_
+
+/* ************************************************************************** */
+
+#include "libmng_conf.h" /* user-specific configuration options */
+
+/* ************************************************************************** */
+
+#define MNG_CHECK_BAD_ICCP /* let's catch that sucker !!! */
+
+#ifdef MNG_SUPPORT_READ /* dependencies based on user-configuration */
+#define MNG_INCLUDE_READ_PROCS
+#endif
+
+#ifdef MNG_SUPPORT_WRITE
+#define MNG_INCLUDE_WRITE_PROCS
+#endif
+
+#ifdef MNG_USE_ZLIB_CRC
+#define MNG_INCLUDE_ZLIB
+#endif
+
+#ifdef MNG_SUPPORT_DISPLAY
+#define MNG_INCLUDE_FILTERS
+#define MNG_INCLUDE_INTERLACE
+#define MNG_INCLUDE_OBJECTS
+#define MNG_INCLUDE_DISPLAY_PROCS
+#define MNG_INCLUDE_TIMING_PROCS
+#define MNG_INCLUDE_ZLIB
+#endif
+
+#ifdef MNG_STORE_CHUNKS
+#define MNG_INCLUDE_ZLIB
+#endif
+
+#ifdef MNG_SUPPORT_IJG6B
+#define MNG_INCLUDE_JNG
+#define MNG_INCLUDE_IJG6B
+#define MNG_USE_SETJMP
+#endif
+
+#ifdef MNG_INCLUDE_JNG
+#if defined(MNG_SUPPORT_DISPLAY) || defined(MNG_ACCESS_CHUNKS)
+#define MNG_INCLUDE_JNG_READ
+#endif
+#if defined(MNG_SUPPORT_WRITE) || defined(MNG_ACCESS_CHUNKS)
+#define MNG_INCLUDE_JNG_WRITE
+#endif
+#endif
+
+#ifdef MNG_FULL_CMS
+#define MNG_INCLUDE_LCMS
+#endif
+
+#ifdef MNG_AUTO_DITHER
+#define MNG_INCLUDE_DITHERING
+#endif
+
+#ifdef MNG_SUPPORT_TRACE
+#define MNG_INCLUDE_TRACE_PROCS
+#ifdef MNG_TRACE_TELLTALE
+#define MNG_INCLUDE_TRACE_STRINGS
+#endif
+#endif
+
+#ifdef MNG_ERROR_TELLTALE
+#define MNG_INCLUDE_ERROR_STRINGS
+#endif
+
+#ifdef MNG_OPTIMIZE_CHUNKINITFREE
+#ifndef MNG_OPTIMIZE_CHUNKACCESS
+#define MNG_OPTIMIZE_CHUNKACCESS
+#endif
+#else
+#ifdef MNG_OPTIMIZE_CHUNKACCESS
+#undef MNG_OPTIMIZE_CHUNKACCESS
+#endif
+#endif
+
+/* ************************************************************************** */
+
+#include "libmng_types.h" /* platform-specific definitions
+ and other assorted stuff */
+
+/* ************************************************************************** */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ************************************************************************** */
+/* * * */
+/* * Versioning control * */
+/* * * */
+/* * version_so and version_dll will NOT reflect version_major; * */
+/* * these will only change for binary incompatible changes (which will * */
+/* * hopefully never occur) * */
+/* * note: they will be set to 1 on the first public release !!! * */
+/* * * */
+/* * first public release: * */
+/* * #define MNG_VERSION_TEXT "1.0.0" * */
+/* * #define MNG_VERSION_SO 1 eg. libmng.so.1 * */
+/* * #define MNG_VERSION_DLL 1 eg. libmng.dll * */
+/* * #define MNG_VERSION_MAJOR 1 * */
+/* * #define MNG_VERSION_MINOR 0 * */
+/* * #define MNG_VERSION_RELEASE 0 * */
+/* * * */
+/* * bug fix & cosmetics : * */
+/* * #define MNG_VERSION_TEXT "1.0.1" * */
+/* * #define MNG_VERSION_SO 1 eg. libmng.so.1 * */
+/* * #define MNG_VERSION_DLL 1 eg. libmng.dll * */
+/* * #define MNG_VERSION_MAJOR 1 * */
+/* * #define MNG_VERSION_MINOR 0 * */
+/* * #define MNG_VERSION_RELEASE 1 * */
+/* * * */
+/* * feature change : * */
+/* * #define MNG_VERSION_TEXT "1.2.0" * */
+/* * #define MNG_VERSION_SO 1 eg. libmng.so.1 * */
+/* * #define MNG_VERSION_DLL 1 eg. libmng.dll * */
+/* * #define MNG_VERSION_MAJOR 1 * */
+/* * #define MNG_VERSION_MINOR 2 * */
+/* * #define MNG_VERSION_RELEASE 0 * */
+/* * * */
+/* * major rewrite (still binary compatible) : * */
+/* * #define MNG_VERSION_TEXT "2.0.0" * */
+/* * #define MNG_VERSION_SO 1 eg. libmng.so.1 * */
+/* * #define MNG_VERSION_DLL 1 eg. libmng.dll * */
+/* * #define MNG_VERSION_MAJOR 2 * */
+/* * #define MNG_VERSION_MINOR 0 * */
+/* * #define MNG_VERSION_RELEASE 0 * */
+/* * * */
+/* * binary incompatible change: * */
+/* * #define MNG_VERSION_TEXT "13.0.0" * */
+/* * #define MNG_VERSION_SO 2 eg. libmng.so.2 * */
+/* * #define MNG_VERSION_DLL 2 eg. libmng2.dll * */
+/* * #define MNG_VERSION_MAJOR 13 * */
+/* * #define MNG_VERSION_MINOR 0 * */
+/* * #define MNG_VERSION_RELEASE 0 * */
+/* * * */
+/* * note that version_so & version_dll will always remain equal so it * */
+/* * doesn't matter which one is called to do version-checking; they are * */
+/* * just provided for their target platform * */
+/* * * */
+/* ************************************************************************** */
+
+#define MNG_VERSION_TEXT "1.0.10"
+#define MNG_VERSION_SO 1 /* eg. libmng.so.1 */
+#define MNG_VERSION_DLL 1 /* but: libmng.dll (!) */
+#define MNG_VERSION_MAJOR 1
+#define MNG_VERSION_MINOR 0
+#define MNG_VERSION_RELEASE 10
+#define MNG_VERSION_BETA MNG_FALSE
+
+MNG_EXT mng_pchar MNG_DECL mng_version_text (void);
+MNG_EXT mng_uint8 MNG_DECL mng_version_so (void);
+MNG_EXT mng_uint8 MNG_DECL mng_version_dll (void);
+MNG_EXT mng_uint8 MNG_DECL mng_version_major (void);
+MNG_EXT mng_uint8 MNG_DECL mng_version_minor (void);
+MNG_EXT mng_uint8 MNG_DECL mng_version_release (void);
+MNG_EXT mng_bool MNG_DECL mng_version_beta (void);
+
+/* use the following call to check wether the version of libmng your app
+ is using supports the given function; this is useful in apps that dynamically
+ load the library to make sure a certain function will work; the result will
+ be MNG_TRUE if the given function is implemented in this version of the library;
+ Major/Minor/Version indicate the version the function became available;
+ (if these fields are zero the function is not yet implemented!) */
+#ifdef MNG_SUPPORT_FUNCQUERY
+MNG_EXT mng_bool MNG_DECL mng_supports_func (mng_pchar zFunction,
+ mng_uint8* iMajor,
+ mng_uint8* iMinor,
+ mng_uint8* iRelease);
+#endif
+
+/* ************************************************************************** */
+/* * * */
+/* * MNG/PNG specification level conformance * */
+/* * * */
+/* ************************************************************************** */
+
+#define MNG_PNG_VERSION "1.2"
+#define MNG_PNG_VERSION_MAJ 1
+#define MNG_PNG_VERSION_MIN 2
+
+#define MNG_MNG_VERSION "1.1"
+#define MNG_MNG_VERSION_MAJ 1
+#define MNG_MNG_VERSION_MIN 1
+#define MNG_MNG_DRAFT 99 /* deprecated;
+ only used for nEED "MNG DRAFT nn" */
+
+/* ************************************************************************** */
+/* * * */
+/* * High-level application functions * */
+/* * * */
+/* ************************************************************************** */
+
+/* library initialization function */
+/* must be the first called before anything can be done at all */
+/* initializes internal datastructure(s) */
+MNG_EXT mng_handle MNG_DECL mng_initialize (mng_ptr pUserdata,
+ mng_memalloc fMemalloc,
+ mng_memfree fMemfree,
+ mng_traceproc fTraceproc);
+
+/* library reset function */
+/* can be used to re-initialize the library, so another image can be
+ processed. there's absolutely no harm in calling it, even when it's not
+ really necessary */
+MNG_EXT mng_retcode MNG_DECL mng_reset (mng_handle hHandle);
+
+/* library cleanup function */
+/* must be the last called to clean up internal datastructure(s) */
+MNG_EXT mng_retcode MNG_DECL mng_cleanup (mng_handle* hHandle);
+
+/* high-level read functions */
+/* use mng_read if you simply want to read a Network Graphic */
+/* mng_read_resume is used in I/O-read-suspension scenarios, where the
+ "readdata" callback may return FALSE & length=0 indicating its buffer is
+ depleted or too short to supply the required bytes, and the buffer needs
+ to be refilled; libmng will return the errorcode MNG_NEEDMOREDATA telling
+ the app to refill its read-buffer after which it must call mng_read_resume
+ (or mng_display_resume if it also displaying the image simultaneously) */
+#ifdef MNG_SUPPORT_READ
+MNG_EXT mng_retcode MNG_DECL mng_read (mng_handle hHandle);
+MNG_EXT mng_retcode MNG_DECL mng_read_resume (mng_handle hHandle);
+#endif
+
+/* high-level "data push" functions */
+/* these functions can be used in situations where data is streaming into the
+ application and needs to be buffered by libmng before it is actually
+ requested by libmng itself. the pushing complements the normal reading
+ mechanism, but applications can decide to always return "0 bytes read" to
+ make libmng go into suspension mode with the returncode MNG_NEEDMOREDATA */
+/* mng_read_pushdata can be used to push blobs of data of arbitrary size;
+ mng_read_pushsig and mng_read_pushchunk can be used if the application
+ has already done some low-level decoding (eg. at the chunk level) */
+/* the data being pushed into libmng with mng_read_pushdata *must* contain
+ the regular 4-byte chunklength, but *must not* contain it with
+ mng_read_pushchunk!!! */
+/* mng_read_pushsig is used to prevent libmng from trying to parse the regular
+ PNG/JNG/MNG signature bytes; the application must have done this itself
+ and *must* indicate the proper type in the function call or things will
+ go amiss!!
+ also you *must* call this first, so pretty much right after mng_initialize
+ and certainly before any call to mng_read or mng_readdisplay !!!! */
+/* IMPORTANT!!! data can only be safely pushed when libmng is in a
+ "wait" state; eg. during MNG_NEEDTIMERWAIT, MNG_NEEDSECTIONWAIT or
+ MNG_NEEDMOREDATA !!! this just means you can't have one thread displaying
+ and another thread pushing data !!! */
+/* if bOwnership = MNG_TRUE, libmng will retain the supplied pointer and
+ *will* expect the buffer to remain available until libmng is finished
+ with it; what happens then depends on whether or not you have set the
+ releasedata() callback; if this is set than the supplied buffer will
+ be returned through this callback and your application can take care of
+ cleaning it up, otherwise libmng will use its internal freeing mechanism
+ (which, depending on compile-options, will be the standard C free() call,
+ or the memfree() callback */
+/* if bOwnership = MNG_FALSE, libmng will just copy the data into its own
+ buffers and dispose of it in the normal way */
+#ifdef MNG_SUPPORT_READ
+MNG_EXT mng_retcode MNG_DECL mng_read_pushdata (mng_handle hHandle,
+ mng_ptr pData,
+ mng_size_t iLength,
+ mng_bool bTakeownership);
+MNG_EXT mng_retcode MNG_DECL mng_read_pushsig (mng_handle hHandle,
+ mng_imgtype eSigtype);
+MNG_EXT mng_retcode MNG_DECL mng_read_pushchunk (mng_handle hHandle,
+ mng_ptr pChunk,
+ mng_size_t iLength,
+ mng_bool bTakeownership);
+#endif
+
+/* high-level write & create functions */
+/* use this if you want to write a previously read Network Graphic or
+ if you want to create a new graphic and write it */
+/* to write a previously read graphic you must have defined MNG_STORE_CHUNKS */
+/* to create a new graphic you'll also need access to the chunks
+ (eg. #define MNG_ACCESS_CHUNKS !) */
+#ifdef MNG_SUPPORT_WRITE
+MNG_EXT mng_retcode MNG_DECL mng_write (mng_handle hHandle);
+MNG_EXT mng_retcode MNG_DECL mng_create (mng_handle hHandle);
+#endif
+
+/* high-level display functions */
+/* use these to display a previously read or created graphic or
+ to read & display a graphic simultaneously */
+/* mng_display_resume should be called after a timer-interval
+ expires that was set through the settimer-callback, after a
+ read suspension-break, or, to resume an animation after a call
+ to mng_display_freeze/mng_display_reset */
+/* mng_display_freeze thru mng_display_gotime can be used to influence
+ the display of an image, BUT ONLY if it has been completely read! */
+#ifdef MNG_SUPPORT_DISPLAY
+#ifdef MNG_SUPPORT_READ
+MNG_EXT mng_retcode MNG_DECL mng_readdisplay (mng_handle hHandle);
+#endif
+MNG_EXT mng_retcode MNG_DECL mng_display (mng_handle hHandle);
+MNG_EXT mng_retcode MNG_DECL mng_display_resume (mng_handle hHandle);
+MNG_EXT mng_retcode MNG_DECL mng_display_freeze (mng_handle hHandle);
+MNG_EXT mng_retcode MNG_DECL mng_display_reset (mng_handle hHandle);
+#ifndef MNG_NO_DISPLAY_GO_SUPPORTED
+MNG_EXT mng_retcode MNG_DECL mng_display_goframe (mng_handle hHandle,
+ mng_uint32 iFramenr);
+MNG_EXT mng_retcode MNG_DECL mng_display_golayer (mng_handle hHandle,
+ mng_uint32 iLayernr);
+MNG_EXT mng_retcode MNG_DECL mng_display_gotime (mng_handle hHandle,
+ mng_uint32 iPlaytime);
+#endif
+#endif /* MNG_SUPPORT_DISPLAY */
+
+/* event processing function */
+/* this needs to be called by the app when dynamic MNG is enabled and
+ a specific event occurs in the user-interface */
+#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_SUPPORT_DYNAMICMNG)
+MNG_EXT mng_retcode MNG_DECL mng_trapevent (mng_handle hHandle,
+ mng_uint8 iEventtype,
+ mng_int32 iX,
+ mng_int32 iY);
+#endif
+
+/* error reporting function */
+/* use this if you need more detailed info on the last error */
+/* iExtra1 & iExtra2 may contain errorcodes from zlib, jpeg, etc... */
+/* zErrortext will only be filled if you #define MNG_ERROR_TELLTALE */
+MNG_EXT mng_retcode MNG_DECL mng_getlasterror (mng_handle hHandle,
+ mng_int8* iSeverity,
+ mng_chunkid* iChunkname,
+ mng_uint32* iChunkseq,
+ mng_int32* iExtra1,
+ mng_int32* iExtra2,
+ mng_pchar* zErrortext);
+
+/* ************************************************************************** */
+/* * * */
+/* * Callback set functions * */
+/* * * */
+/* ************************************************************************** */
+
+/* memory callbacks */
+/* called to allocate and release internal datastructures */
+#ifndef MNG_INTERNAL_MEMMNGMT
+MNG_EXT mng_retcode MNG_DECL mng_setcb_memalloc (mng_handle hHandle,
+ mng_memalloc fProc);
+MNG_EXT mng_retcode MNG_DECL mng_setcb_memfree (mng_handle hHandle,
+ mng_memfree fProc);
+#endif /* MNG_INTERNAL_MEMMNGMT */
+
+/* open- & close-stream callbacks */
+/* called to open & close streams for input or output */
+#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE)
+#ifndef MNG_NO_OPEN_CLOSE_STREAM
+MNG_EXT mng_retcode MNG_DECL mng_setcb_openstream (mng_handle hHandle,
+ mng_openstream fProc);
+MNG_EXT mng_retcode MNG_DECL mng_setcb_closestream (mng_handle hHandle,
+ mng_closestream fProc);
+#endif
+#endif
+
+/* read callback */
+/* called to get data from the inputstream */
+#ifdef MNG_SUPPORT_READ
+MNG_EXT mng_retcode MNG_DECL mng_setcb_readdata (mng_handle hHandle,
+ mng_readdata fProc);
+#endif
+
+/* write callback */
+/* called to put data into the outputstream */
+#ifdef MNG_SUPPORT_WRITE
+MNG_EXT mng_retcode MNG_DECL mng_setcb_writedata (mng_handle hHandle,
+ mng_writedata fProc);
+#endif
+
+/* error callback */
+/* called when an error occurs */
+/* the application can determine if the error is recoverable,
+ and may inform the library by setting specific returncodes */
+MNG_EXT mng_retcode MNG_DECL mng_setcb_errorproc (mng_handle hHandle,
+ mng_errorproc fProc);
+
+/* trace callback */
+/* called to show the currently executing function */
+#ifdef MNG_SUPPORT_TRACE
+MNG_EXT mng_retcode MNG_DECL mng_setcb_traceproc (mng_handle hHandle,
+ mng_traceproc fProc);
+#endif
+
+/* callbacks for read processing */
+/* processheader is called when all header information has been gathered
+ from the inputstream */
+/* processtext is called for every tEXt, zTXt and iTXt chunk in the
+ inputstream (iType=0 for tEXt, 1 for zTXt and 2 for iTXt);
+ you can call get_imagelevel to check at what nesting-level the chunk is
+ encountered (eg. tEXt inside an embedded image inside a MNG -> level == 2;
+ in most other case -> level == 1) */
+/* processsave & processseek are called for SAVE/SEEK chunks */
+/* processneed is called for the nEED chunk; you should specify a callback
+ for this as the default behavior will be to abort processing, unless
+ the requirement is one of:
+ - a supported chunk
+ - the text "draft nn" where nn is a numeric value
+ - the text "MNG-1.0" or "MNG-1.1"
+ - the text "CACHEOFF" */
+/* processmend is called at the very end of the animation-stream;
+ note that this may not be the end of the animation though! */
+/* processterm is called when a TERM chunk is encountered; there can be only
+ 1 in the stream (or none) */
+/* processunknown is called after reading each non-critical unknown chunk */
+#ifdef MNG_SUPPORT_READ
+MNG_EXT mng_retcode MNG_DECL mng_setcb_processheader (mng_handle hHandle,
+ mng_processheader fProc);
+MNG_EXT mng_retcode MNG_DECL mng_setcb_processtext (mng_handle hHandle,
+ mng_processtext fProc);
+MNG_EXT mng_retcode MNG_DECL mng_setcb_processsave (mng_handle hHandle,
+ mng_processsave fProc);
+MNG_EXT mng_retcode MNG_DECL mng_setcb_processseek (mng_handle hHandle,
+ mng_processseek fProc);
+MNG_EXT mng_retcode MNG_DECL mng_setcb_processneed (mng_handle hHandle,
+ mng_processneed fProc);
+MNG_EXT mng_retcode MNG_DECL mng_setcb_processmend (mng_handle hHandle,
+ mng_processmend fProc);
+MNG_EXT mng_retcode MNG_DECL mng_setcb_processterm (mng_handle hHandle,
+ mng_processterm fProc);
+MNG_EXT mng_retcode MNG_DECL mng_setcb_processunknown(mng_handle hHandle,
+ mng_processunknown fProc);
+#endif
+
+/* callbacks for display processing */
+/* getcanvasline is called to get an access-pointer to a line on the
+ drawing-canvas */
+/* getbkgdline is called to get an access-pointer to a line from the
+ background-canvas */
+/* refresh is called to inform the GUI to redraw the current canvas onto
+ its output device (eg. in Win32 this would mean sending an
+ invalidate message for the specified region */
+/* NOTE that the update-region is specified as x,y,width,height; eg. the
+ invalidate message for Windows requires left,top,right,bottom parameters
+ where the bottom-right is exclusive of the region!!
+ to get these correctly is as simple as:
+ left = x;
+ top = y;
+ right = x + width;
+ bottom = y + height;
+ if your implementation requires inclusive points, simply subtract 1 from
+ both the right & bottom values calculated above.
+ */
+#ifdef MNG_SUPPORT_DISPLAY
+MNG_EXT mng_retcode MNG_DECL mng_setcb_getcanvasline (mng_handle hHandle,
+ mng_getcanvasline fProc);
+MNG_EXT mng_retcode MNG_DECL mng_setcb_getbkgdline (mng_handle hHandle,
+ mng_getbkgdline fProc);
+MNG_EXT mng_retcode MNG_DECL mng_setcb_getalphaline (mng_handle hHandle,
+ mng_getalphaline fProc);
+MNG_EXT mng_retcode MNG_DECL mng_setcb_refresh (mng_handle hHandle,
+ mng_refresh fProc);
+
+/* timing callbacks */
+/* gettickcount is called to get the system tickcount (milliseconds);
+ this is used to determine the remaining interval between frames */
+/* settimer is called to inform the application that it should set a timer;
+ when the timer is triggered the app must call mng_display_resume */
+MNG_EXT mng_retcode MNG_DECL mng_setcb_gettickcount (mng_handle hHandle,
+ mng_gettickcount fProc);
+MNG_EXT mng_retcode MNG_DECL mng_setcb_settimer (mng_handle hHandle,
+ mng_settimer fProc);
+
+/* color management callbacks */
+/* called to transmit color management information to the application */
+/* these are only used when you #define MNG_APP_CMS */
+#ifdef MNG_APP_CMS
+MNG_EXT mng_retcode MNG_DECL mng_setcb_processgamma (mng_handle hHandle,
+ mng_processgamma fProc);
+MNG_EXT mng_retcode MNG_DECL mng_setcb_processchroma (mng_handle hHandle,
+ mng_processchroma fProc);
+MNG_EXT mng_retcode MNG_DECL mng_setcb_processsrgb (mng_handle hHandle,
+ mng_processsrgb fProc);
+MNG_EXT mng_retcode MNG_DECL mng_setcb_processiccp (mng_handle hHandle,
+ mng_processiccp fProc);
+MNG_EXT mng_retcode MNG_DECL mng_setcb_processarow (mng_handle hHandle,
+ mng_processarow fProc);
+#endif /* MNG_APP_CMS */
+#endif /* MNG_SUPPORT_DISPLAY */
+
+/* release push data callback */
+/* used when the app pushes data into libmng (as opposed to libmng pulling it)
+ and relinquishes ownership of the pushed data-buffer, but *does* want to
+ release (free) the buffer itself once libmng has finished processing it */
+#ifdef MNG_SUPPORT_READ
+MNG_EXT mng_retcode MNG_DECL mng_setcb_releasedata (mng_handle hHandle,
+ mng_releasedata fProc);
+#endif
+
+/* ************************************************************************** */
+/* * * */
+/* * Callback get functions * */
+/* * * */
+/* ************************************************************************** */
+
+/* see _setcb_ */
+#ifndef MNG_INTERNAL_MEMMNGMT
+MNG_EXT mng_memalloc MNG_DECL mng_getcb_memalloc (mng_handle hHandle);
+MNG_EXT mng_memfree MNG_DECL mng_getcb_memfree (mng_handle hHandle);
+#endif
+
+/* see _setcb_ */
+#ifdef MNG_SUPPORT_READ
+MNG_EXT mng_releasedata MNG_DECL mng_getcb_releasedata (mng_handle hHandle);
+#endif
+
+/* see _setcb_ */
+#if defined(MNG_SUPPORT_READ) || defined(MNG_WRITE_SUPPORT)
+#ifndef MNG_NO_OPEN_CLOSE_STREAM
+MNG_EXT mng_openstream MNG_DECL mng_getcb_openstream (mng_handle hHandle);
+MNG_EXT mng_closestream MNG_DECL mng_getcb_closestream (mng_handle hHandle);
+#endif
+#endif
+
+/* see _setcb_ */
+#ifdef MNG_SUPPORT_READ
+MNG_EXT mng_readdata MNG_DECL mng_getcb_readdata (mng_handle hHandle);
+#endif
+
+/* see _setcb_ */
+#ifdef MNG_SUPPORT_WRITE
+MNG_EXT mng_writedata MNG_DECL mng_getcb_writedata (mng_handle hHandle);
+#endif
+
+/* see _setcb_ */
+MNG_EXT mng_errorproc MNG_DECL mng_getcb_errorproc (mng_handle hHandle);
+
+/* see _setcb_ */
+#ifdef MNG_SUPPORT_TRACE
+MNG_EXT mng_traceproc MNG_DECL mng_getcb_traceproc (mng_handle hHandle);
+#endif
+
+/* see _setcb_ */
+#ifdef MNG_SUPPORT_READ
+MNG_EXT mng_processheader MNG_DECL mng_getcb_processheader (mng_handle hHandle);
+MNG_EXT mng_processtext MNG_DECL mng_getcb_processtext (mng_handle hHandle);
+MNG_EXT mng_processsave MNG_DECL mng_getcb_processsave (mng_handle hHandle);
+MNG_EXT mng_processseek MNG_DECL mng_getcb_processseek (mng_handle hHandle);
+MNG_EXT mng_processneed MNG_DECL mng_getcb_processneed (mng_handle hHandle);
+MNG_EXT mng_processunknown MNG_DECL mng_getcb_processunknown (mng_handle hHandle);
+MNG_EXT mng_processterm MNG_DECL mng_getcb_processterm (mng_handle hHandle);
+#endif
+
+/* see _setcb_ */
+#ifdef MNG_SUPPORT_DISPLAY
+MNG_EXT mng_getcanvasline MNG_DECL mng_getcb_getcanvasline (mng_handle hHandle);
+MNG_EXT mng_getbkgdline MNG_DECL mng_getcb_getbkgdline (mng_handle hHandle);
+MNG_EXT mng_getalphaline MNG_DECL mng_getcb_getalphaline (mng_handle hHandle);
+MNG_EXT mng_refresh MNG_DECL mng_getcb_refresh (mng_handle hHandle);
+
+/* see _setcb_ */
+MNG_EXT mng_gettickcount MNG_DECL mng_getcb_gettickcount (mng_handle hHandle);
+MNG_EXT mng_settimer MNG_DECL mng_getcb_settimer (mng_handle hHandle);
+
+/* see _setcb_ */
+#ifdef MNG_APP_CMS
+MNG_EXT mng_processgamma MNG_DECL mng_getcb_processgamma (mng_handle hHandle);
+MNG_EXT mng_processchroma MNG_DECL mng_getcb_processchroma (mng_handle hHandle);
+MNG_EXT mng_processsrgb MNG_DECL mng_getcb_processsrgb (mng_handle hHandle);
+MNG_EXT mng_processiccp MNG_DECL mng_getcb_processiccp (mng_handle hHandle);
+MNG_EXT mng_processarow MNG_DECL mng_getcb_processarow (mng_handle hHandle);
+#endif /* MNG_APP_CMS */
+#endif /* MNG_SUPPORT_DISPLAY */
+
+/* ************************************************************************** */
+/* * * */
+/* * Property set functions * */
+/* * * */
+/* ************************************************************************** */
+
+/* Application data pointer */
+/* provided for application use; not used by the library */
+MNG_EXT mng_retcode MNG_DECL mng_set_userdata (mng_handle hHandle,
+ mng_ptr pUserdata);
+
+/* The style of the drawing- & background-canvas */
+/* only used for displaying images */
+/* both are initially set to 24-bit RGB (eg. 8-bit per channel) */
+MNG_EXT mng_retcode MNG_DECL mng_set_canvasstyle (mng_handle hHandle,
+ mng_uint32 iStyle);
+MNG_EXT mng_retcode MNG_DECL mng_set_bkgdstyle (mng_handle hHandle,
+ mng_uint32 iStyle);
+
+/* The default background color */
+/* only used if the getbkgdline callback is not defined */
+/* for initially painting the canvas and restoring (part of) the background */
+MNG_EXT mng_retcode MNG_DECL mng_set_bgcolor (mng_handle hHandle,
+ mng_uint16 iRed,
+ mng_uint16 iGreen,
+ mng_uint16 iBlue);
+
+/* Indicates preferred use of the bKGD chunk for PNG images */
+MNG_EXT mng_retcode MNG_DECL mng_set_usebkgd (mng_handle hHandle,
+ mng_bool bUseBKGD);
+
+/* Indicates storage of read chunks */
+/* only useful if you #define mng_store_chunks */
+/* can be used to dynamically change storage management */
+MNG_EXT mng_retcode MNG_DECL mng_set_storechunks (mng_handle hHandle,
+ mng_bool bStorechunks);
+
+/* Indicates breaks requested when processing SAVE/SEEK */
+/* set this to let the app handle section breaks; the library will return
+ MNG_NEEDSECTIONWAIT return-codes for each SEEK chunk */
+MNG_EXT mng_retcode MNG_DECL mng_set_sectionbreaks (mng_handle hHandle,
+ mng_bool bSectionbreaks);
+
+/* Indicates storage of playback info (ON by default!) */
+/* can be used to turn off caching of playback info; this is useful to
+ specifically optimize MNG-video playback; note that if caching is turned off
+ LOOP chunks will be flagged as errors! TERM chunks will be ignored and only
+ passed to the processterm() callback if it is defined by the app; also, this
+ feature can only be used with mng_readdisplay(); mng_read(),
+ mng_display_reset() and mng_display_goxxxx() will return an error;
+ once this option is turned off it can't be turned on for the same stream!!! */
+MNG_EXT mng_retcode MNG_DECL mng_set_cacheplayback (mng_handle hHandle,
+ mng_bool bCacheplayback);
+
+/* Indicates automatic progressive refreshes for large images (ON by default!) */
+/* turn this off if you do not want intermittent painting while a large image
+ is being read. useful if the input-stream comes from a fast medium, such
+ as a local harddisk */
+MNG_EXT mng_retcode MNG_DECL mng_set_doprogressive (mng_handle hHandle,
+ mng_bool bDoProgressive);
+
+/* Indicates existence and required checking of the CRC in input streams,
+ and generation in output streams */
+/* !!!! Use this ONLY if you know what you are doing !!!! */
+/* The value is a combination of the following flags:
+ 0x0000001 = CRC is present in the input stream
+ 0x0000002 = CRC must be generated in the output stream
+ 0x0000010 = CRC should be checked for ancillary chunks
+ 0x0000020 = a faulty CRC for ancillary chunks generates a warning only
+ 0x0000040 = a faulty CRC for ancillary chunks generates an error
+ 0x0000100 = CRC should be checked for critical chunks
+ 0x0000200 = a faulty CRC for critical chunks generates a warning only
+ 0x0000400 = a faulty CRC for critical chunks generates an error
+
+ The default is 0x00000533 = CRC present in input streams; should be checked;
+ warning for ancillary chunks; error for critical
+ chunks; generate CRC for output streams
+
+ Note that some combinations are meaningless; eg. if the CRC is not present
+ it won't do any good to turn the checking flags on; if a checking flag
+ is off, it doesn't do any good to ask for generation of warnings or errors.
+ Also libmng will generate either an error or a warning, not both,
+ so if you specify both the default will be to generate an error!
+ The only useful combinations for input are 331, 551, 351, 531, 0, 301, 501
+ and optionally 031 and 051, but only checking ancillary chunks and not
+ critical chunks is generally not a very good idea!!!
+ If you've also writing these values should be combined with 0x02 if
+ CRC's are required in the output stream
+ */
+MNG_EXT mng_retcode MNG_DECL mng_set_crcmode (mng_handle hHandle,
+ mng_uint32 iCrcmode);
+
+/* Color-management necessaries */
+/*
+ *************************************************************************
+ !!!!!!!! THIS NEXT BIT IS IMPORTANT !!!!!!!!!
+ *************************************************************************
+
+ If you have defined MNG_FULL_CMS (and are using lcms), you will have to
+ think hard about the following routines.
+
+ lcms requires 2 profiles to work off the differences in the input-image
+ and the output-device. The ICC profile for the input-image will be
+ embedded within it to reflect its color-characteristics, but the output
+ profile depends on the output-device, which is something only *YOU* know
+ about. sRGB (standard RGB) is common for x86 compatible environments
+ (eg. Windows, Linux and some others)
+
+ If you are compiling for a sRGB compliant system you probably won't have
+ to do anything special. (unless you want to of course)
+
+ If you are compiling for a non-sRGB compliant system
+ (eg. SGI, Mac, Next, others...)
+ you *MUST* define a proper ICC profile for the generic output-device
+ associated with that platform.
+
+ In either event, you may also want to offer an option to your users to
+ set the profile manually, or, if you know how, set it from a
+ system-defined default.
+
+ TO RECAP: for sRGB systems (Windows, Linux) no action required!
+ for non-sRGB systems (SGI, Mac, Next) ACTION REQUIRED!
+
+ Please visit http://www.srgb.com, http://www.color.org and
+ http://www.littlecms.com for more info.
+
+ *************************************************************************
+ !!!!!!!! THE BIT ABOVE IS IMPORTANT !!!!!!!!!
+ *************************************************************************
+*/
+/* mng_set_srgb tells libmng if it's running on a sRGB compliant system or not
+ the default is already set to MNG_TRUE */
+/* mng_set_outputprofile, mng_set_outputprofile2, mng_set_outputsrgb
+ are used to set the default profile describing the output-device
+ by default it is already initialized with an sRGB profile */
+/* mng_set_srgbprofile, mng_set_srgbprofile2, mng_set_srgbimplicit
+ are used to set the default profile describing a standard sRGB device
+ this is used when the input-image is tagged only as being sRGB, but the
+ output-device is defined as not being sRGB compliant
+ by default it is already initialized with a standard sRGB profile */
+#if defined(MNG_SUPPORT_DISPLAY)
+MNG_EXT mng_retcode MNG_DECL mng_set_srgb (mng_handle hHandle,
+ mng_bool bIssRGB);
+MNG_EXT mng_retcode MNG_DECL mng_set_outputprofile (mng_handle hHandle,
+ mng_pchar zFilename);
+MNG_EXT mng_retcode MNG_DECL mng_set_outputprofile2 (mng_handle hHandle,
+ mng_uint32 iProfilesize,
+ mng_ptr pProfile);
+MNG_EXT mng_retcode MNG_DECL mng_set_outputsrgb (mng_handle hHandle);
+MNG_EXT mng_retcode MNG_DECL mng_set_srgbprofile (mng_handle hHandle,
+ mng_pchar zFilename);
+MNG_EXT mng_retcode MNG_DECL mng_set_srgbprofile2 (mng_handle hHandle,
+ mng_uint32 iProfilesize,
+ mng_ptr pProfile);
+MNG_EXT mng_retcode MNG_DECL mng_set_srgbimplicit (mng_handle hHandle);
+#endif
+
+#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) || defined(MNG_APP_CMS)
+/* Gamma settings */
+/* ... blabla (explain gamma processing a little; eg. formula & stuff) ... */
+MNG_EXT mng_retcode MNG_DECL mng_set_viewgamma (mng_handle hHandle,
+ mng_float dGamma);
+MNG_EXT mng_retcode MNG_DECL mng_set_displaygamma (mng_handle hHandle,
+ mng_float dGamma);
+MNG_EXT mng_retcode MNG_DECL mng_set_dfltimggamma (mng_handle hHandle,
+ mng_float dGamma);
+MNG_EXT mng_retcode MNG_DECL mng_set_viewgammaint (mng_handle hHandle,
+ mng_uint32 iGamma);
+MNG_EXT mng_retcode MNG_DECL mng_set_displaygammaint (mng_handle hHandle,
+ mng_uint32 iGamma);
+MNG_EXT mng_retcode MNG_DECL mng_set_dfltimggammaint (mng_handle hHandle,
+ mng_uint32 iGamma);
+#endif
+
+#ifndef MNG_SKIP_MAXCANVAS
+/* Ultimate clipping size */
+/* used to limit extreme graphics from overloading the system */
+/* if a graphic exceeds these limits a warning is issued, which can
+ be ignored by the app (using the errorproc callback). in that case
+ the library will use these settings to clip the input graphic, and
+ the app's canvas must account for this */
+MNG_EXT mng_retcode MNG_DECL mng_set_maxcanvaswidth (mng_handle hHandle,
+ mng_uint32 iMaxwidth);
+MNG_EXT mng_retcode MNG_DECL mng_set_maxcanvasheight (mng_handle hHandle,
+ mng_uint32 iMaxheight);
+MNG_EXT mng_retcode MNG_DECL mng_set_maxcanvassize (mng_handle hHandle,
+ mng_uint32 iMaxwidth,
+ mng_uint32 iMaxheight);
+#endif
+
+/* ZLIB default compression parameters */
+/* these are used when writing out chunks */
+/* they are also used when compressing PNG image-data or JNG alpha-data;
+ in this case you can set them just before calling mng_putimgdata_ihdr */
+/* set to your liking; usually the defaults will suffice though! */
+/* check the documentation for ZLIB for details on these parameters */
+#ifdef MNG_INCLUDE_ZLIB
+MNG_EXT mng_retcode MNG_DECL mng_set_zlib_level (mng_handle hHandle,
+ mng_int32 iZlevel);
+MNG_EXT mng_retcode MNG_DECL mng_set_zlib_method (mng_handle hHandle,
+ mng_int32 iZmethod);
+MNG_EXT mng_retcode MNG_DECL mng_set_zlib_windowbits (mng_handle hHandle,
+ mng_int32 iZwindowbits);
+MNG_EXT mng_retcode MNG_DECL mng_set_zlib_memlevel (mng_handle hHandle,
+ mng_int32 iZmemlevel);
+MNG_EXT mng_retcode MNG_DECL mng_set_zlib_strategy (mng_handle hHandle,
+ mng_int32 iZstrategy);
+
+MNG_EXT mng_retcode MNG_DECL mng_set_zlib_maxidat (mng_handle hHandle,
+ mng_uint32 iMaxIDAT);
+#endif /* MNG_INCLUDE_ZLIB */
+
+/* JNG default compression parameters (based on IJG code) */
+/* these are used when compressing JNG image-data; so you can set them
+ just before calling mng_putimgdata_jhdr */
+/* set to your liking; usually the defaults will suffice though! */
+/* check the documentation for IJGSRC6B for details on these parameters */
+#ifdef MNG_INCLUDE_JNG
+#ifdef MNG_INCLUDE_IJG6B
+MNG_EXT mng_retcode MNG_DECL mng_set_jpeg_dctmethod (mng_handle hHandle,
+ mngjpeg_dctmethod eJPEGdctmethod);
+#endif
+MNG_EXT mng_retcode MNG_DECL mng_set_jpeg_quality (mng_handle hHandle,
+ mng_int32 iJPEGquality);
+MNG_EXT mng_retcode MNG_DECL mng_set_jpeg_smoothing (mng_handle hHandle,
+ mng_int32 iJPEGsmoothing);
+MNG_EXT mng_retcode MNG_DECL mng_set_jpeg_progressive(mng_handle hHandle,
+ mng_bool bJPEGprogressive);
+MNG_EXT mng_retcode MNG_DECL mng_set_jpeg_optimized (mng_handle hHandle,
+ mng_bool bJPEGoptimized);
+
+MNG_EXT mng_retcode MNG_DECL mng_set_jpeg_maxjdat (mng_handle hHandle,
+ mng_uint32 iMaxJDAT);
+#endif /* MNG_INCLUDE_JNG */
+
+/* Suspension-mode setting */
+/* use this to activate the internal suspension-buffer to improve
+ read-suspension processing */
+/* TODO: write-suspension ??? */
+#if defined(MNG_SUPPORT_READ)
+MNG_EXT mng_retcode MNG_DECL mng_set_suspensionmode (mng_handle hHandle,
+ mng_bool bSuspensionmode);
+#endif
+
+/* Speed setting */
+/* use this to influence the display-speed of animations */
+#if defined(MNG_SUPPORT_DISPLAY)
+MNG_EXT mng_retcode MNG_DECL mng_set_speed (mng_handle hHandle,
+ mng_speedtype iSpeed);
+#endif
+
+/* ************************************************************************** */
+/* * * */
+/* * Property get functions * */
+/* * * */
+/* ************************************************************************** */
+
+/* see _set_ */
+MNG_EXT mng_ptr MNG_DECL mng_get_userdata (mng_handle hHandle);
+
+/* Network Graphic header details */
+/* these get filled once the graphics header is processed,
+ so they are available in the processheader callback; before that
+ they are zeroed out and imagetype is set to it_unknown */
+/* this might be a good point for the app to initialize the drawing-canvas! */
+/* note that some fields are only set for the first(!) header-chunk:
+ MNG/MHDR (imagetype = mng_it_mng) - ticks thru simplicity
+ PNG/IHDR (imagetype = mng_it_png) - bitdepth thru interlace
+ JNG/JHDR (imagetype = mng_it_jng) - bitdepth thru compression &
+ interlace thru alphainterlace */
+MNG_EXT mng_imgtype MNG_DECL mng_get_sigtype (mng_handle hHandle);
+MNG_EXT mng_imgtype MNG_DECL mng_get_imagetype (mng_handle hHandle);
+MNG_EXT mng_uint32 MNG_DECL mng_get_imagewidth (mng_handle hHandle);
+MNG_EXT mng_uint32 MNG_DECL mng_get_imageheight (mng_handle hHandle);
+
+MNG_EXT mng_uint32 MNG_DECL mng_get_ticks (mng_handle hHandle);
+MNG_EXT mng_uint32 MNG_DECL mng_get_framecount (mng_handle hHandle);
+MNG_EXT mng_uint32 MNG_DECL mng_get_layercount (mng_handle hHandle);
+MNG_EXT mng_uint32 MNG_DECL mng_get_playtime (mng_handle hHandle);
+MNG_EXT mng_uint32 MNG_DECL mng_get_simplicity (mng_handle hHandle);
+
+MNG_EXT mng_uint8 MNG_DECL mng_get_bitdepth (mng_handle hHandle);
+MNG_EXT mng_uint8 MNG_DECL mng_get_colortype (mng_handle hHandle);
+MNG_EXT mng_uint8 MNG_DECL mng_get_compression (mng_handle hHandle);
+MNG_EXT mng_uint8 MNG_DECL mng_get_filter (mng_handle hHandle);
+MNG_EXT mng_uint8 MNG_DECL mng_get_interlace (mng_handle hHandle);
+MNG_EXT mng_uint8 MNG_DECL mng_get_alphabitdepth (mng_handle hHandle);
+MNG_EXT mng_uint8 MNG_DECL mng_get_alphacompression(mng_handle hHandle);
+MNG_EXT mng_uint8 MNG_DECL mng_get_alphafilter (mng_handle hHandle);
+MNG_EXT mng_uint8 MNG_DECL mng_get_alphainterlace (mng_handle hHandle);
+
+/* indicates the predicted alpha-depth required to properly display the image */
+/* gets set once the graphics header is processed and is available in the
+ processheader callback for any type of input-image (PNG, JNG or MNG) */
+/* possible values are 0,1,2,4,8,16
+ 0 = no transparency required
+ 1 = on/off transparency required (alpha-values are 0 or 2^bit_depth-1)
+ 2+ = semi-transparency required (values will be scaled to the bitdepth of the
+ canvasstyle supplied by the application) */
+MNG_EXT mng_uint8 MNG_DECL mng_get_alphadepth (mng_handle hHandle);
+
+/* defines whether a refresh() callback is called for an interlace pass (PNG)
+ or progressive scan (JNG) */
+/* returns the interlace pass number for PNG or a fabricated pass number for JNG;
+ returns 0 in all other cases */
+/* only useful if the image_type = mng_it_png or mng_it_jng and if the image
+ is actually interlaced (PNG) or progressive (JNG) */
+#ifdef MNG_SUPPORT_DISPLAY
+MNG_EXT mng_uint8 MNG_DECL mng_get_refreshpass (mng_handle hHandle);
+#endif
+
+/* see _set_ */
+MNG_EXT mng_uint32 MNG_DECL mng_get_canvasstyle (mng_handle hHandle);
+MNG_EXT mng_uint32 MNG_DECL mng_get_bkgdstyle (mng_handle hHandle);
+
+/* see _set_ */
+MNG_EXT mng_retcode MNG_DECL mng_get_bgcolor (mng_handle hHandle,
+ mng_uint16* iRed,
+ mng_uint16* iGreen,
+ mng_uint16* iBlue);
+
+/* see _set_ */
+MNG_EXT mng_bool MNG_DECL mng_get_usebkgd (mng_handle hHandle);
+
+/* see _set_ */
+MNG_EXT mng_bool MNG_DECL mng_get_storechunks (mng_handle hHandle);
+
+/* see _set_ */
+MNG_EXT mng_bool MNG_DECL mng_get_sectionbreaks (mng_handle hHandle);
+
+/* see _set_ */
+MNG_EXT mng_bool MNG_DECL mng_get_cacheplayback (mng_handle hHandle);
+
+/* see _set_ */
+MNG_EXT mng_bool MNG_DECL mng_get_doprogressive (mng_handle hHandle);
+
+/* see _set_ */
+MNG_EXT mng_uint32 MNG_DECL mng_get_crcmode (mng_handle hHandle);
+
+/* see _set_ */
+#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_FULL_CMS)
+MNG_EXT mng_bool MNG_DECL mng_get_srgb (mng_handle hHandle);
+#endif
+
+/* see _set_ */
+MNG_EXT mng_float MNG_DECL mng_get_viewgamma (mng_handle hHandle);
+MNG_EXT mng_float MNG_DECL mng_get_displaygamma (mng_handle hHandle);
+MNG_EXT mng_float MNG_DECL mng_get_dfltimggamma (mng_handle hHandle);
+MNG_EXT mng_uint32 MNG_DECL mng_get_viewgammaint (mng_handle hHandle);
+MNG_EXT mng_uint32 MNG_DECL mng_get_displaygammaint (mng_handle hHandle);
+MNG_EXT mng_uint32 MNG_DECL mng_get_dfltimggammaint (mng_handle hHandle);
+
+#ifndef MNG_SKIP_MAXCANVAS
+/* see _set_ */
+MNG_EXT mng_uint32 MNG_DECL mng_get_maxcanvaswidth (mng_handle hHandle);
+MNG_EXT mng_uint32 MNG_DECL mng_get_maxcanvasheight (mng_handle hHandle);
+#endif
+
+/* see _set_ */
+#ifdef MNG_INCLUDE_ZLIB
+MNG_EXT mng_int32 MNG_DECL mng_get_zlib_level (mng_handle hHandle);
+MNG_EXT mng_int32 MNG_DECL mng_get_zlib_method (mng_handle hHandle);
+MNG_EXT mng_int32 MNG_DECL mng_get_zlib_windowbits (mng_handle hHandle);
+MNG_EXT mng_int32 MNG_DECL mng_get_zlib_memlevel (mng_handle hHandle);
+MNG_EXT mng_int32 MNG_DECL mng_get_zlib_strategy (mng_handle hHandle);
+
+MNG_EXT mng_uint32 MNG_DECL mng_get_zlib_maxidat (mng_handle hHandle);
+#endif /* MNG_INCLUDE_ZLIB */
+
+/* see _set_ */
+#ifdef MNG_INCLUDE_JNG
+#ifdef MNG_INCLUDE_IJG6B
+MNG_EXT mngjpeg_dctmethod
+ MNG_DECL mng_get_jpeg_dctmethod (mng_handle hHandle);
+#endif
+MNG_EXT mng_int32 MNG_DECL mng_get_jpeg_quality (mng_handle hHandle);
+MNG_EXT mng_int32 MNG_DECL mng_get_jpeg_smoothing (mng_handle hHandle);
+MNG_EXT mng_bool MNG_DECL mng_get_jpeg_progressive(mng_handle hHandle);
+MNG_EXT mng_bool MNG_DECL mng_get_jpeg_optimized (mng_handle hHandle);
+
+MNG_EXT mng_uint32 MNG_DECL mng_get_jpeg_maxjdat (mng_handle hHandle);
+#endif /* MNG_INCLUDE_JNG */
+
+/* see _set_ */
+#if defined(MNG_SUPPORT_READ)
+MNG_EXT mng_bool MNG_DECL mng_get_suspensionmode (mng_handle hHandle);
+#endif
+
+/* see _set_ */
+#if defined(MNG_SUPPORT_DISPLAY)
+MNG_EXT mng_speedtype
+ MNG_DECL mng_get_speed (mng_handle hHandle);
+#endif
+
+/* Image-level */
+/* this can be used inside the processtext callback to determine the level of
+ text of the image being processed; the value 1 is returned for top-level
+ texts, and the value 2 for a text inside an embedded image inside a MNG */
+MNG_EXT mng_uint32 MNG_DECL mng_get_imagelevel (mng_handle hHandle);
+
+/* BACK info */
+/* can be used to retrieve the color & mandatory values for the last processed
+ BACK chunk of a MNG (will fail for other image-types);
+ if no BACK chunk was processed yet, it will return all zeroes */
+#ifdef MNG_SUPPORT_DISPLAY
+MNG_EXT mng_retcode MNG_DECL mng_get_lastbackchunk (mng_handle hHandle,
+ mng_uint16* iRed,
+ mng_uint16* iGreen,
+ mng_uint16* iBlue,
+ mng_uint8* iMandatory);
+#endif
+
+/* SEEK info */
+/* can be used to retrieve the segmentname of the last processed SEEK chunk;
+ if no SEEK chunk was processed or its segmentname was empty, the function
+ will return an empty string; the provided buffer must be at least 80 bytes!! */
+#ifdef MNG_SUPPORT_DISPLAY
+MNG_EXT mng_retcode MNG_DECL mng_get_lastseekname (mng_handle hHandle,
+ mng_pchar zSegmentname);
+#endif
+
+/* FRAM info */
+/* can be used to retrieve the current FRAM delay; this may be useful when
+ retrieving a stream of frames with their corresponding delays by "fake"
+ reading and displaying the file */
+#ifdef MNG_SUPPORT_DISPLAY
+MNG_EXT mng_uint32 MNG_DECL mng_get_currframdelay (mng_handle hHandle);
+#endif
+
+/* Display status variables */
+/* these get filled & updated during display processing */
+/* starttime is the tickcount at the start of displaying the animation */
+/* runtime is the actual number of millisecs since the start of the animation */
+/* currentframe, currentlayer & currentplaytime indicate the current
+ frame/layer/playtime(msecs) in the animation (these keep increasing;
+ even after the animation loops back to the TERM chunk) */
+/* totalframes, totallayers & totalplaytime are filled after a complete run
+ of an animation (eg. at MEND); they are also valid after just reading the MNG */
+#ifdef MNG_SUPPORT_DISPLAY
+MNG_EXT mng_uint32 MNG_DECL mng_get_starttime (mng_handle hHandle);
+MNG_EXT mng_uint32 MNG_DECL mng_get_runtime (mng_handle hHandle);
+#ifndef MNG_NO_CURRENT_INFO
+MNG_EXT mng_uint32 MNG_DECL mng_get_currentframe (mng_handle hHandle);
+MNG_EXT mng_uint32 MNG_DECL mng_get_currentlayer (mng_handle hHandle);
+MNG_EXT mng_uint32 MNG_DECL mng_get_currentplaytime (mng_handle hHandle);
+MNG_EXT mng_uint32 MNG_DECL mng_get_totalframes (mng_handle hHandle);
+MNG_EXT mng_uint32 MNG_DECL mng_get_totallayers (mng_handle hHandle);
+MNG_EXT mng_uint32 MNG_DECL mng_get_totalplaytime (mng_handle hHandle);
+#endif
+#endif
+
+/* Status variables */
+/* these indicate the internal state of the library */
+/* most indicate exactly what you would expect -
+ status_error: true if the last function call returned an errorcode
+ status_reading: true if the library is (still) reading an image
+ status_suspendbreak: true if the library has suspended for "I/O"
+ status_creating: true if the library is in the middle of creating an image
+ status_writing: true if the library is in the middle of writing an image
+ status_displaying: true if the library is displaying an image
+ status_running: true if display processing is active (eg. not frozen or reset)
+ status_timerbreak: true if the library has suspended for a "timer-break"
+ status_dynamic: true if the library encountered an evNT chunk in the MNG
+ status_runningevent: true if the library is processing an external event */
+/* eg. mng_readdisplay() will turn the reading, displaying and running status on;
+ when EOF is reached the reading status will be turned off */
+MNG_EXT mng_bool MNG_DECL mng_status_error (mng_handle hHandle);
+#ifdef MNG_SUPPORT_READ
+MNG_EXT mng_bool MNG_DECL mng_status_reading (mng_handle hHandle);
+MNG_EXT mng_bool MNG_DECL mng_status_suspendbreak (mng_handle hHandle);
+#endif
+#ifdef MNG_SUPPORT_WRITE
+MNG_EXT mng_bool MNG_DECL mng_status_creating (mng_handle hHandle);
+MNG_EXT mng_bool MNG_DECL mng_status_writing (mng_handle hHandle);
+#endif
+#ifdef MNG_SUPPORT_DISPLAY
+MNG_EXT mng_bool MNG_DECL mng_status_displaying (mng_handle hHandle);
+MNG_EXT mng_bool MNG_DECL mng_status_running (mng_handle hHandle);
+MNG_EXT mng_bool MNG_DECL mng_status_timerbreak (mng_handle hHandle);
+#endif
+#ifdef MNG_SUPPORT_DYNAMICMNG
+MNG_EXT mng_bool MNG_DECL mng_status_dynamic (mng_handle hHandle);
+MNG_EXT mng_bool MNG_DECL mng_status_runningevent (mng_handle hHandle);
+#endif
+
+/* ************************************************************************** */
+/* * * */
+/* * Chunk access functions * */
+/* * * */
+/* ************************************************************************** */
+
+#ifdef MNG_ACCESS_CHUNKS
+
+/* ************************************************************************** */
+
+/* use this to iterate the stored chunks */
+/* requires MNG_ACCESS_CHUNKS & MNG_STORE_CHUNKS */
+/* starts from the supplied chunk-index-nr; the first chunk has index 0!! */
+MNG_EXT mng_retcode MNG_DECL mng_iterate_chunks (mng_handle hHandle,
+ mng_uint32 iChunkseq,
+ mng_iteratechunk fProc);
+
+/* use the next function inside your 'iteratechunk' callback to copy
+ the given chunk to a new mng you are creating */
+/* the 'out' handle should be in 'create' status! */
+#ifdef MNG_SUPPORT_WRITE
+MNG_EXT mng_retcode MNG_DECL mng_copy_chunk (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_handle hHandleOut);
+#endif
+
+/* ************************************************************************** */
+
+/* use these to get chunk data from within the callback in iterate_chunks */
+MNG_EXT 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_EXT mng_retcode MNG_DECL mng_getchunk_plte (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint32 *iCount,
+ mng_palette8 *aPalette);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_idat (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint32 *iRawlen,
+ mng_ptr *pRawdata);
+
+MNG_EXT 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_EXT mng_retcode MNG_DECL mng_getchunk_gama (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_bool *bEmpty,
+ mng_uint32 *iGamma);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_chrm (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_bool *bEmpty,
+ mng_uint32 *iWhitepointx,
+ mng_uint32 *iWhitepointy,
+ mng_uint32 *iRedx,
+ mng_uint32 *iRedy,
+ mng_uint32 *iGreenx,
+ mng_uint32 *iGreeny,
+ mng_uint32 *iBluex,
+ mng_uint32 *iBluey);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_srgb (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_bool *bEmpty,
+ mng_uint8 *iRenderingintent);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_iccp (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_bool *bEmpty,
+ mng_uint32 *iNamesize,
+ mng_pchar *zName,
+ mng_uint8 *iCompression,
+ mng_uint32 *iProfilesize,
+ mng_ptr *pProfile);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_text (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint32 *iKeywordsize,
+ mng_pchar *zKeyword,
+ mng_uint32 *iTextsize,
+ mng_pchar *zText);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_ztxt (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint32 *iKeywordsize,
+ mng_pchar *zKeyword,
+ mng_uint8 *iCompression,
+ mng_uint32 *iTextsize,
+ mng_pchar *zText);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_itxt (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint32 *iKeywordsize,
+ mng_pchar *zKeyword,
+ mng_uint8 *iCompressionflag,
+ mng_uint8 *iCompressionmethod,
+ mng_uint32 *iLanguagesize,
+ mng_pchar *zLanguage,
+ mng_uint32 *iTranslationsize,
+ mng_pchar *zTranslation,
+ mng_uint32 *iTextsize,
+ mng_pchar *zText);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_bkgd (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_bool *bEmpty,
+ mng_uint8 *iType,
+ mng_uint8 *iIndex,
+ mng_uint16 *iGray,
+ mng_uint16 *iRed,
+ mng_uint16 *iGreen,
+ mng_uint16 *iBlue);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_phys (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_bool *bEmpty,
+ mng_uint32 *iSizex,
+ mng_uint32 *iSizey,
+ mng_uint8 *iUnit);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_sbit (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_bool *bEmpty,
+ mng_uint8 *iType,
+ mng_uint8arr4 *aBits);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_splt (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_bool *bEmpty,
+ mng_uint32 *iNamesize,
+ mng_pchar *zName,
+ mng_uint8 *iSampledepth,
+ mng_uint32 *iEntrycount,
+ mng_ptr *pEntries);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_hist (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint32 *iEntrycount,
+ mng_uint16arr *aEntries);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_time (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint16 *iYear,
+ mng_uint8 *iMonth,
+ mng_uint8 *iDay,
+ mng_uint8 *iHour,
+ mng_uint8 *iMinute,
+ mng_uint8 *iSecond);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_mhdr (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint32 *iWidth,
+ mng_uint32 *iHeight,
+ mng_uint32 *iTicks,
+ mng_uint32 *iLayercount,
+ mng_uint32 *iFramecount,
+ mng_uint32 *iPlaytime,
+ mng_uint32 *iSimplicity);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_loop (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint8 *iLevel,
+ mng_uint32 *iRepeat,
+ mng_uint8 *iTermination,
+ mng_uint32 *iItermin,
+ mng_uint32 *iItermax,
+ mng_uint32 *iCount,
+ mng_uint32p *pSignals);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_endl (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint8 *iLevel);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_defi (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint16 *iObjectid,
+ mng_uint8 *iDonotshow,
+ mng_uint8 *iConcrete,
+ mng_bool *bHasloca,
+ mng_int32 *iXlocation,
+ mng_int32 *iYlocation,
+ mng_bool *bHasclip,
+ mng_int32 *iLeftcb,
+ mng_int32 *iRightcb,
+ mng_int32 *iTopcb,
+ mng_int32 *iBottomcb);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_basi (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_uint16 *iRed,
+ mng_uint16 *iGreen,
+ mng_uint16 *iBlue,
+ mng_uint16 *iAlpha,
+ mng_uint8 *iViewable);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_clon (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint16 *iSourceid,
+ mng_uint16 *iCloneid,
+ mng_uint8 *iClonetype,
+ mng_uint8 *iDonotshow,
+ mng_uint8 *iConcrete,
+ mng_bool *bHasloca,
+ mng_uint8 *iLocationtype,
+ mng_int32 *iLocationx,
+ mng_int32 *iLocationy);
+
+#ifndef MNG_SKIPCHUNK_PAST
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_past (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint16 *iDestid,
+ mng_uint8 *iTargettype,
+ mng_int32 *iTargetx,
+ mng_int32 *iTargety,
+ mng_uint32 *iCount);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_past_src (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint32 iEntry,
+ mng_uint16 *iSourceid,
+ mng_uint8 *iComposition,
+ mng_uint8 *iOrientation,
+ mng_uint8 *iOffsettype,
+ mng_int32 *iOffsetx,
+ mng_int32 *iOffsety,
+ mng_uint8 *iBoundarytype,
+ mng_int32 *iBoundaryl,
+ mng_int32 *iBoundaryr,
+ mng_int32 *iBoundaryt,
+ mng_int32 *iBoundaryb);
+#endif
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_disc (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint32 *iCount,
+ mng_uint16p *pObjectids);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_back (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint16 *iRed,
+ mng_uint16 *iGreen,
+ mng_uint16 *iBlue,
+ mng_uint8 *iMandatory,
+ mng_uint16 *iImageid,
+ mng_uint8 *iTile);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_fram (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_bool *bEmpty,
+ mng_uint8 *iMode,
+ mng_uint32 *iNamesize,
+ mng_pchar *zName,
+ mng_uint8 *iChangedelay,
+ mng_uint8 *iChangetimeout,
+ mng_uint8 *iChangeclipping,
+ mng_uint8 *iChangesyncid,
+ mng_uint32 *iDelay,
+ mng_uint32 *iTimeout,
+ mng_uint8 *iBoundarytype,
+ mng_int32 *iBoundaryl,
+ mng_int32 *iBoundaryr,
+ mng_int32 *iBoundaryt,
+ mng_int32 *iBoundaryb,
+ mng_uint32 *iCount,
+ mng_uint32p *pSyncids);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_move (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint16 *iFirstid,
+ mng_uint16 *iLastid,
+ mng_uint8 *iMovetype,
+ mng_int32 *iMovex,
+ mng_int32 *iMovey);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_clip (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint16 *iFirstid,
+ mng_uint16 *iLastid,
+ mng_uint8 *iCliptype,
+ mng_int32 *iClipl,
+ mng_int32 *iClipr,
+ mng_int32 *iClipt,
+ mng_int32 *iClipb);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_show (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_bool *bEmpty,
+ mng_uint16 *iFirstid,
+ mng_uint16 *iLastid,
+ mng_uint8 *iMode);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_term (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint8 *iTermaction,
+ mng_uint8 *iIteraction,
+ mng_uint32 *iDelay,
+ mng_uint32 *iItermax);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_save (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_bool *bEmpty,
+ mng_uint8 *iOffsettype,
+ mng_uint32 *iCount);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_save_entry (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint32 iEntry,
+ mng_uint8 *iEntrytype,
+ mng_uint32arr2 *iOffset,
+ mng_uint32arr2 *iStarttime,
+ mng_uint32 *iLayernr,
+ mng_uint32 *iFramenr,
+ mng_uint32 *iNamesize,
+ mng_pchar *zName);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_seek (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint32 *iNamesize,
+ mng_pchar *zName);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_expi (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint16 *iSnapshotid,
+ mng_uint32 *iNamesize,
+ mng_pchar *zName);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_fpri (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint8 *iDeltatype,
+ mng_uint8 *iPriority);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_need (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint32 *iKeywordssize,
+ mng_pchar *zKeywords);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_phyg (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_bool *bEmpty,
+ mng_uint32 *iSizex,
+ mng_uint32 *iSizey,
+ mng_uint8 *iUnit);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_jhdr (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint32 *iWidth,
+ mng_uint32 *iHeight,
+ mng_uint8 *iColortype,
+ mng_uint8 *iImagesampledepth,
+ mng_uint8 *iImagecompression,
+ mng_uint8 *iImageinterlace,
+ mng_uint8 *iAlphasampledepth,
+ mng_uint8 *iAlphacompression,
+ mng_uint8 *iAlphafilter,
+ mng_uint8 *iAlphainterlace);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_jdat (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint32 *iRawlen,
+ mng_ptr *pRawdata);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_jdaa (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint32 *iRawlen,
+ mng_ptr *pRawdata);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_dhdr (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint16 *iObjectid,
+ mng_uint8 *iImagetype,
+ mng_uint8 *iDeltatype,
+ mng_uint32 *iBlockwidth,
+ mng_uint32 *iBlockheight,
+ mng_uint32 *iBlockx,
+ mng_uint32 *iBlocky);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_prom (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint8 *iColortype,
+ mng_uint8 *iSampledepth,
+ mng_uint8 *iFilltype);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_pplt (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint8 *iDeltatype,
+ mng_uint32 *iCount);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_pplt_entry (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint32 iEntry,
+ mng_uint16 *iRed,
+ mng_uint16 *iGreen,
+ mng_uint16 *iBlue,
+ mng_uint16 *iAlpha,
+ mng_bool *bUsed);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_drop (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint32 *iCount,
+ mng_chunkidp *pChunknames);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_dbyk (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_chunkid *iChunkname,
+ mng_uint8 *iPolarity,
+ mng_uint32 *iKeywordssize,
+ mng_pchar *zKeywords);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_ordr (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint32 *iCount);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_ordr_entry (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint32 iEntry,
+ mng_chunkid *iChunkname,
+ mng_uint8 *iOrdertype);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_magn (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint16 *iFirstid,
+ mng_uint16 *iLastid,
+ mng_uint16 *iMethodX,
+ mng_uint16 *iMX,
+ mng_uint16 *iMY,
+ mng_uint16 *iML,
+ mng_uint16 *iMR,
+ mng_uint16 *iMT,
+ mng_uint16 *iMB,
+ mng_uint16 *iMethodY);
+
+#ifdef MNG_INCLUDE_MPNG_PROPOSAL
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_mpng (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint32 *iFramewidth,
+ mng_uint32 *iFrameheight,
+ mng_uint16 *iNumplays,
+ mng_uint16 *iTickspersec,
+ mng_uint8 *iCompressionmethod,
+ mng_uint32 *iCount);
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_mpng_frame (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint32 iEntry,
+ mng_uint32 *iX,
+ mng_uint32 *iY,
+ mng_uint32 *iWidth,
+ mng_uint32 *iHeight,
+ mng_int32 *iXoffset,
+ mng_int32 *iYoffset,
+ mng_uint16 *iTicks);
+#endif
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_evnt (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint32 *iCount);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_evnt_entry (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint32 iEntry,
+ mng_uint8 *iEventtype,
+ mng_uint8 *iMasktype,
+ mng_int32 *iLeft,
+ mng_int32 *iRight,
+ mng_int32 *iTop,
+ mng_int32 *iBottom,
+ mng_uint16 *iObjectid,
+ mng_uint8 *iIndex,
+ mng_uint32 *iSegmentnamesize,
+ mng_pchar *zSegmentname);
+
+MNG_EXT mng_retcode MNG_DECL mng_getchunk_unknown (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_chunkid *iChunkname,
+ mng_uint32 *iRawlen,
+ mng_ptr *pRawdata);
+
+/* ************************************************************************** */
+
+#ifdef MNG_INCLUDE_WRITE_PROCS
+
+/* use these to create new chunks at the end of the chunk-list */
+/* requires at least MNG_ACCESS_CHUNKS (MNG_SUPPORT_WRITE may be nice too) */
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_ihdr (mng_handle hHandle,
+ mng_uint32 iWidth,
+ mng_uint32 iHeight,
+ mng_uint8 iBitdepth,
+ mng_uint8 iColortype,
+ mng_uint8 iCompression,
+ mng_uint8 iFilter,
+ mng_uint8 iInterlace);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_plte (mng_handle hHandle,
+ mng_uint32 iCount,
+ mng_palette8 aPalette);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_idat (mng_handle hHandle,
+ mng_uint32 iRawlen,
+ mng_ptr pRawdata);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_iend (mng_handle hHandle);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_trns (mng_handle hHandle,
+ 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_EXT mng_retcode MNG_DECL mng_putchunk_gama (mng_handle hHandle,
+ mng_bool bEmpty,
+ mng_uint32 iGamma);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_chrm (mng_handle hHandle,
+ mng_bool bEmpty,
+ mng_uint32 iWhitepointx,
+ mng_uint32 iWhitepointy,
+ mng_uint32 iRedx,
+ mng_uint32 iRedy,
+ mng_uint32 iGreenx,
+ mng_uint32 iGreeny,
+ mng_uint32 iBluex,
+ mng_uint32 iBluey);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_srgb (mng_handle hHandle,
+ mng_bool bEmpty,
+ mng_uint8 iRenderingintent);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_iccp (mng_handle hHandle,
+ mng_bool bEmpty,
+ mng_uint32 iNamesize,
+ mng_pchar zName,
+ mng_uint8 iCompression,
+ mng_uint32 iProfilesize,
+ mng_ptr pProfile);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_text (mng_handle hHandle,
+ mng_uint32 iKeywordsize,
+ mng_pchar zKeyword,
+ mng_uint32 iTextsize,
+ mng_pchar zText);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_ztxt (mng_handle hHandle,
+ mng_uint32 iKeywordsize,
+ mng_pchar zKeyword,
+ mng_uint8 iCompression,
+ mng_uint32 iTextsize,
+ mng_pchar zText);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_itxt (mng_handle hHandle,
+ mng_uint32 iKeywordsize,
+ mng_pchar zKeyword,
+ mng_uint8 iCompressionflag,
+ mng_uint8 iCompressionmethod,
+ mng_uint32 iLanguagesize,
+ mng_pchar zLanguage,
+ mng_uint32 iTranslationsize,
+ mng_pchar zTranslation,
+ mng_uint32 iTextsize,
+ mng_pchar zText);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_bkgd (mng_handle hHandle,
+ mng_bool bEmpty,
+ mng_uint8 iType,
+ mng_uint8 iIndex,
+ mng_uint16 iGray,
+ mng_uint16 iRed,
+ mng_uint16 iGreen,
+ mng_uint16 iBlue);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_phys (mng_handle hHandle,
+ mng_bool bEmpty,
+ mng_uint32 iSizex,
+ mng_uint32 iSizey,
+ mng_uint8 iUnit);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_sbit (mng_handle hHandle,
+ mng_bool bEmpty,
+ mng_uint8 iType,
+ mng_uint8arr4 aBits);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_splt (mng_handle hHandle,
+ mng_bool bEmpty,
+ mng_uint32 iNamesize,
+ mng_pchar zName,
+ mng_uint8 iSampledepth,
+ mng_uint32 iEntrycount,
+ mng_ptr pEntries);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_hist (mng_handle hHandle,
+ mng_uint32 iEntrycount,
+ mng_uint16arr aEntries);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_time (mng_handle hHandle,
+ mng_uint16 iYear,
+ mng_uint8 iMonth,
+ mng_uint8 iDay,
+ mng_uint8 iHour,
+ mng_uint8 iMinute,
+ mng_uint8 iSecond);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_mhdr (mng_handle hHandle,
+ mng_uint32 iWidth,
+ mng_uint32 iHeight,
+ mng_uint32 iTicks,
+ mng_uint32 iLayercount,
+ mng_uint32 iFramecount,
+ mng_uint32 iPlaytime,
+ mng_uint32 iSimplicity);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_mend (mng_handle hHandle);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_loop (mng_handle hHandle,
+ mng_uint8 iLevel,
+ mng_uint32 iRepeat,
+ mng_uint8 iTermination,
+ mng_uint32 iItermin,
+ mng_uint32 iItermax,
+ mng_uint32 iCount,
+ mng_uint32p pSignals);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_endl (mng_handle hHandle,
+ mng_uint8 iLevel);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_defi (mng_handle hHandle,
+ mng_uint16 iObjectid,
+ mng_uint8 iDonotshow,
+ mng_uint8 iConcrete,
+ mng_bool bHasloca,
+ mng_int32 iXlocation,
+ mng_int32 iYlocation,
+ mng_bool bHasclip,
+ mng_int32 iLeftcb,
+ mng_int32 iRightcb,
+ mng_int32 iTopcb,
+ mng_int32 iBottomcb);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_basi (mng_handle hHandle,
+ mng_uint32 iWidth,
+ mng_uint32 iHeight,
+ mng_uint8 iBitdepth,
+ mng_uint8 iColortype,
+ mng_uint8 iCompression,
+ mng_uint8 iFilter,
+ mng_uint8 iInterlace,
+ mng_uint16 iRed,
+ mng_uint16 iGreen,
+ mng_uint16 iBlue,
+ mng_uint16 iAlpha,
+ mng_uint8 iViewable);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_clon (mng_handle hHandle,
+ mng_uint16 iSourceid,
+ mng_uint16 iCloneid,
+ mng_uint8 iClonetype,
+ mng_uint8 iDonotshow,
+ mng_uint8 iConcrete,
+ mng_bool bHasloca,
+ mng_uint8 iLocationtype,
+ mng_int32 iLocationx,
+ mng_int32 iLocationy);
+
+#ifndef MNG_SKIPCHUNK_PAST
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_past (mng_handle hHandle,
+ mng_uint16 iDestid,
+ mng_uint8 iTargettype,
+ mng_int32 iTargetx,
+ mng_int32 iTargety,
+ mng_uint32 iCount);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_past_src (mng_handle hHandle,
+ mng_uint32 iEntry,
+ mng_uint16 iSourceid,
+ mng_uint8 iComposition,
+ mng_uint8 iOrientation,
+ mng_uint8 iOffsettype,
+ mng_int32 iOffsetx,
+ mng_int32 iOffsety,
+ mng_uint8 iBoundarytype,
+ mng_int32 iBoundaryl,
+ mng_int32 iBoundaryr,
+ mng_int32 iBoundaryt,
+ mng_int32 iBoundaryb);
+#endif
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_disc (mng_handle hHandle,
+ mng_uint32 iCount,
+ mng_uint16p pObjectids);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_back (mng_handle hHandle,
+ mng_uint16 iRed,
+ mng_uint16 iGreen,
+ mng_uint16 iBlue,
+ mng_uint8 iMandatory,
+ mng_uint16 iImageid,
+ mng_uint8 iTile);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_fram (mng_handle hHandle,
+ mng_bool bEmpty,
+ mng_uint8 iMode,
+ mng_uint32 iNamesize,
+ mng_pchar zName,
+ mng_uint8 iChangedelay,
+ mng_uint8 iChangetimeout,
+ mng_uint8 iChangeclipping,
+ mng_uint8 iChangesyncid,
+ mng_uint32 iDelay,
+ mng_uint32 iTimeout,
+ mng_uint8 iBoundarytype,
+ mng_int32 iBoundaryl,
+ mng_int32 iBoundaryr,
+ mng_int32 iBoundaryt,
+ mng_int32 iBoundaryb,
+ mng_uint32 iCount,
+ mng_uint32p pSyncids);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_move (mng_handle hHandle,
+ mng_uint16 iFirstid,
+ mng_uint16 iLastid,
+ mng_uint8 iMovetype,
+ mng_int32 iMovex,
+ mng_int32 iMovey);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_clip (mng_handle hHandle,
+ mng_uint16 iFirstid,
+ mng_uint16 iLastid,
+ mng_uint8 iCliptype,
+ mng_int32 iClipl,
+ mng_int32 iClipr,
+ mng_int32 iClipt,
+ mng_int32 iClipb);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_show (mng_handle hHandle,
+ mng_bool bEmpty,
+ mng_uint16 iFirstid,
+ mng_uint16 iLastid,
+ mng_uint8 iMode);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_term (mng_handle hHandle,
+ mng_uint8 iTermaction,
+ mng_uint8 iIteraction,
+ mng_uint32 iDelay,
+ mng_uint32 iItermax);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_save (mng_handle hHandle,
+ mng_bool bEmpty,
+ mng_uint8 iOffsettype,
+ mng_uint32 iCount);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_save_entry (mng_handle hHandle,
+ mng_uint32 iEntry,
+ mng_uint8 iEntrytype,
+ mng_uint32arr2 iOffset,
+ mng_uint32arr2 iStarttime,
+ mng_uint32 iLayernr,
+ mng_uint32 iFramenr,
+ mng_uint32 iNamesize,
+ mng_pchar zName);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_seek (mng_handle hHandle,
+ mng_uint32 iNamesize,
+ mng_pchar zName);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_expi (mng_handle hHandle,
+ mng_uint16 iSnapshotid,
+ mng_uint32 iNamesize,
+ mng_pchar zName);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_fpri (mng_handle hHandle,
+ mng_uint8 iDeltatype,
+ mng_uint8 iPriority);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_need (mng_handle hHandle,
+ mng_uint32 iKeywordssize,
+ mng_pchar zKeywords);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_phyg (mng_handle hHandle,
+ mng_bool bEmpty,
+ mng_uint32 iSizex,
+ mng_uint32 iSizey,
+ mng_uint8 iUnit);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_jhdr (mng_handle hHandle,
+ mng_uint32 iWidth,
+ mng_uint32 iHeight,
+ mng_uint8 iColortype,
+ mng_uint8 iImagesampledepth,
+ mng_uint8 iImagecompression,
+ mng_uint8 iImageinterlace,
+ mng_uint8 iAlphasampledepth,
+ mng_uint8 iAlphacompression,
+ mng_uint8 iAlphafilter,
+ mng_uint8 iAlphainterlace);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_jdat (mng_handle hHandle,
+ mng_uint32 iRawlen,
+ mng_ptr pRawdata);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_jdaa (mng_handle hHandle,
+ mng_uint32 iRawlen,
+ mng_ptr pRawdata);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_jsep (mng_handle hHandle);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_dhdr (mng_handle hHandle,
+ mng_uint16 iObjectid,
+ mng_uint8 iImagetype,
+ mng_uint8 iDeltatype,
+ mng_uint32 iBlockwidth,
+ mng_uint32 iBlockheight,
+ mng_uint32 iBlockx,
+ mng_uint32 iBlocky);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_prom (mng_handle hHandle,
+ mng_uint8 iColortype,
+ mng_uint8 iSampledepth,
+ mng_uint8 iFilltype);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_ipng (mng_handle hHandle);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_pplt (mng_handle hHandle,
+ mng_uint8 iDeltatype,
+ mng_uint32 iCount);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_pplt_entry (mng_handle hHandle,
+ mng_uint32 iEntry,
+ mng_uint16 iRed,
+ mng_uint16 iGreen,
+ mng_uint16 iBlue,
+ mng_uint16 iAlpha);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_jpng (mng_handle hHandle);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_drop (mng_handle hHandle,
+ mng_uint32 iCount,
+ mng_chunkidp pChunknames);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_dbyk (mng_handle hHandle,
+ mng_chunkid iChunkname,
+ mng_uint8 iPolarity,
+ mng_uint32 iKeywordssize,
+ mng_pchar zKeywords);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_ordr (mng_handle hHandle,
+ mng_uint32 iCount);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_ordr_entry (mng_handle hHandle,
+ mng_uint32 iEntry,
+ mng_chunkid iChunkname,
+ mng_uint8 iOrdertype);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_magn (mng_handle hHandle,
+ mng_uint16 iFirstid,
+ mng_uint16 iLastid,
+ mng_uint16 iMethodX,
+ mng_uint16 iMX,
+ mng_uint16 iMY,
+ mng_uint16 iML,
+ mng_uint16 iMR,
+ mng_uint16 iMT,
+ mng_uint16 iMB,
+ mng_uint16 iMethodY);
+
+#ifdef MNG_INCLUDE_MPNG_PROPOSAL
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_mpng (mng_handle hHandle,
+ mng_uint32 iFramewidth,
+ mng_uint32 iFrameheight,
+ mng_uint16 iNumplays,
+ mng_uint16 iTickspersec,
+ mng_uint8 iCompressionmethod,
+ mng_uint32 iCount);
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_mpng_frame (mng_handle hHandle,
+ mng_uint32 iEntry,
+ mng_uint32 iX,
+ mng_uint32 iY,
+ mng_uint32 iWidth,
+ mng_uint32 iHeight,
+ mng_int32 iXoffset,
+ mng_int32 iYoffset,
+ mng_uint16 iTicks);
+#endif
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_evnt (mng_handle hHandle,
+ mng_uint32 iCount);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_evnt_entry (mng_handle hHandle,
+ mng_uint32 iEntry,
+ mng_uint8 iEventtype,
+ mng_uint8 iMasktype,
+ mng_int32 iLeft,
+ mng_int32 iRight,
+ mng_int32 iTop,
+ mng_int32 iBottom,
+ mng_uint16 iObjectid,
+ mng_uint8 iIndex,
+ mng_uint32 iSegmentnamesize,
+ mng_pchar zSegmentname);
+
+MNG_EXT mng_retcode MNG_DECL mng_putchunk_unknown (mng_handle hHandle,
+ mng_chunkid iChunkname,
+ mng_uint32 iRawlen,
+ mng_ptr pRawdata);
+
+#endif /* MNG_INCLUDE_WRITE_PROCS */
+
+/* ************************************************************************** */
+
+/* use these functions to access the actual image-data in stored chunks,
+ as opposed to the IDAT/JDAT data */
+/* to get accurate pixel-data the canvasstyle should seriously reflect the
+ bitdepth/colortype combination of the preceding IHDR/JHDR/BASI/DHDR;
+ all input can be converted to rgb(a)8 (rgb(a)16 for 16-bit images), but
+ there are only limited conversions back (see below for putimgdata) */
+
+/* call this function if you want to extract the nth image from the list;
+ the first image is designated seqnr 0! */
+/* this function finds the IHDR/JHDR/BASI/DHDR with the appropriate seqnr,
+ starting from the beginning of the chunk-list; this may tend to get a little
+ slow for animations with a large number of chunks for images near the end */
+/* supplying a seqnr past the last image in the animation will return with
+ an errorcode */
+MNG_EXT mng_retcode MNG_DECL mng_getimgdata_seq (mng_handle hHandle,
+ mng_uint32 iSeqnr,
+ mng_uint32 iCanvasstyle,
+ mng_getcanvasline fGetcanvasline);
+
+/* both the following functions will search forward to find the first IDAT/JDAT,
+ and then traverse back to find the start of the image (IHDR,JHDR,DHDR,BASI);
+ note that this is very fast compared to decoding the IDAT/JDAT, so there's
+ not really a need for optimization; either can be called from the
+ iterate_chunks callback when a IHDR/JHDR is encountered; for BASI/DHDR there
+ may not be real image-data so it's wisest to keep iterating till the IEND,
+ and then call either of these functions if necessary (remember the correct seqnr!) */
+
+/* call this function if you want to extract the image starting at or after the nth
+ position in the chunk-list; this number is returned in the iterate_chunks callback */
+MNG_EXT mng_retcode MNG_DECL mng_getimgdata_chunkseq (mng_handle hHandle,
+ mng_uint32 iSeqnr,
+ mng_uint32 iCanvasstyle,
+ mng_getcanvasline fGetcanvasline);
+
+/* call this function if you want to extract the image starting at or after the
+ indicated chunk; the handle of a chunk is returned in the iterate_chunks callback */
+MNG_EXT mng_retcode MNG_DECL mng_getimgdata_chunk (mng_handle hHandle,
+ mng_handle hChunk,
+ mng_uint32 iCanvasstyle,
+ mng_getcanvasline fGetcanvasline);
+
+/* ************************************************************************** */
+
+#ifdef MNG_INCLUDE_WRITE_PROCS
+
+/* use the following functions to add image-data to the list of stored chunks */
+/* note that this only adds the IDAT or JDAT chunks and no others; you must call
+ one of these functions after you 'put' the initial chunks of the image and
+ before you 'put' the closing chunks */
+/* the canvasstyle should seriously reflect the bitdepth/colortype combination;
+ eg. bitdepth=16 would expect a 16-bit canvasstyle,
+ colortype=g or ga would expect a gray or gray+alpha style respectively
+ and so on, and so forth ...
+ (nb. the number of conversions will be extremely limited for the moment!) */
+
+MNG_EXT mng_retcode MNG_DECL mng_putimgdata_ihdr (mng_handle hHandle,
+ mng_uint32 iWidth,
+ mng_uint32 iHeight,
+ mng_uint8 iColortype,
+ mng_uint8 iBitdepth,
+ mng_uint8 iCompression,
+ mng_uint8 iFilter,
+ mng_uint8 iInterlace,
+ mng_uint32 iCanvasstyle,
+ mng_getcanvasline fGetcanvasline);
+
+MNG_EXT mng_retcode MNG_DECL mng_putimgdata_jhdr (mng_handle hHandle,
+ mng_uint32 iWidth,
+ mng_uint32 iHeight,
+ mng_uint8 iColortype,
+ mng_uint8 iBitdepth,
+ mng_uint8 iCompression,
+ mng_uint8 iInterlace,
+ mng_uint8 iAlphaBitdepth,
+ mng_uint8 iAlphaCompression,
+ mng_uint8 iAlphaFilter,
+ mng_uint8 iAlphaInterlace,
+ mng_uint32 iCanvasstyle,
+ mng_getcanvasline fGetcanvasline);
+
+/* ************************************************************************** */
+
+/* use the following functions to set the framecount/layercount/playtime or
+ simplicity of an animation you are creating; this may be useful if these
+ variables are calculated during the creation-process */
+
+MNG_EXT mng_retcode MNG_DECL mng_updatemngheader (mng_handle hHandle,
+ mng_uint32 iFramecount,
+ mng_uint32 iLayercount,
+ mng_uint32 iPlaytime);
+
+MNG_EXT mng_retcode MNG_DECL mng_updatemngsimplicity (mng_handle hHandle,
+ mng_uint32 iSimplicity);
+
+/* ************************************************************************** */
+
+#endif /* MNG_INCLUDE_WRITE_PROCS */
+
+#endif /* MNG_ACCESS_CHUNKS */
+
+/* ************************************************************************** */
+/* * * */
+/* * Error-code structure * */
+/* * * */
+/* * 0b0000 00xx xxxx xxxx - basic errors; severity 9 (environment) * */
+/* * 0b0000 01xx xxxx xxxx - chunk errors; severity 9 (image induced) * */
+/* * 0b0000 10xx xxxx xxxx - severity 5 errors (application induced) * */
+/* * 0b0001 00xx xxxx xxxx - severity 2 warnings (recoverable) * */
+/* * 0b0010 00xx xxxx xxxx - severity 1 warnings (recoverable) * */
+/* * * */
+/* ************************************************************************** */
+
+#define MNG_NOERROR (mng_retcode)0 /* er.. indicates all's well */
+
+#define MNG_OUTOFMEMORY (mng_retcode)1 /* oops, buy some megabytes! */
+#define MNG_INVALIDHANDLE (mng_retcode)2 /* call mng_initialize first */
+#define MNG_NOCALLBACK (mng_retcode)3 /* set the callbacks please */
+#define MNG_UNEXPECTEDEOF (mng_retcode)4 /* what'd ya do with the data? */
+#define MNG_ZLIBERROR (mng_retcode)5 /* zlib burped */
+#define MNG_JPEGERROR (mng_retcode)6 /* jpglib complained */
+#define MNG_LCMSERROR (mng_retcode)7 /* little cms stressed out */
+#define MNG_NOOUTPUTPROFILE (mng_retcode)8 /* no output-profile defined */
+#define MNG_NOSRGBPROFILE (mng_retcode)9 /* no sRGB-profile defined */
+#define MNG_BUFOVERFLOW (mng_retcode)10 /* zlib output-buffer overflow */
+#define MNG_FUNCTIONINVALID (mng_retcode)11 /* ay, totally inappropriate */
+#define MNG_OUTPUTERROR (mng_retcode)12 /* disk full ? */
+#define MNG_JPEGBUFTOOSMALL (mng_retcode)13 /* can't handle buffer overflow*/
+#define MNG_NEEDMOREDATA (mng_retcode)14 /* I'm hungry, give me more */
+#define MNG_NEEDTIMERWAIT (mng_retcode)15 /* Sleep a while then wake me */
+#define MNG_NEEDSECTIONWAIT (mng_retcode)16 /* just processed a SEEK */
+#define MNG_LOOPWITHCACHEOFF (mng_retcode)17 /* LOOP when playback info off */
+
+#define MNG_DLLNOTLOADED (mng_retcode)99 /* late binding failed */
+
+#define MNG_APPIOERROR (mng_retcode)901 /* application I/O error */
+#define MNG_APPTIMERERROR (mng_retcode)902 /* application timing error */
+#define MNG_APPCMSERROR (mng_retcode)903 /* application CMS error */
+#define MNG_APPMISCERROR (mng_retcode)904 /* application other error */
+#define MNG_APPTRACEABORT (mng_retcode)905 /* application aborts on trace */
+
+#define MNG_INTERNALERROR (mng_retcode)999 /* internal inconsistancy */
+
+#define MNG_INVALIDSIG (mng_retcode)1025 /* invalid graphics file */
+#define MNG_INVALIDCRC (mng_retcode)1027 /* crc check failed */
+#define MNG_INVALIDLENGTH (mng_retcode)1028 /* chunklength mystifies me */
+#define MNG_SEQUENCEERROR (mng_retcode)1029 /* invalid chunk sequence */
+#define MNG_CHUNKNOTALLOWED (mng_retcode)1030 /* completely out-of-place */
+#define MNG_MULTIPLEERROR (mng_retcode)1031 /* only one occurence allowed */
+#define MNG_PLTEMISSING (mng_retcode)1032 /* indexed-color requires PLTE */
+#define MNG_IDATMISSING (mng_retcode)1033 /* IHDR-block requires IDAT */
+#define MNG_CANNOTBEEMPTY (mng_retcode)1034 /* must contain some data */
+#define MNG_GLOBALLENGTHERR (mng_retcode)1035 /* global data incorrect */
+#define MNG_INVALIDBITDEPTH (mng_retcode)1036 /* bitdepth out-of-range */
+#define MNG_INVALIDCOLORTYPE (mng_retcode)1037 /* colortype out-of-range */
+#define MNG_INVALIDCOMPRESS (mng_retcode)1038 /* compression method invalid */
+#define MNG_INVALIDFILTER (mng_retcode)1039 /* filter method invalid */
+#define MNG_INVALIDINTERLACE (mng_retcode)1040 /* interlace method invalid */
+#define MNG_NOTENOUGHIDAT (mng_retcode)1041 /* ran out of compressed data */
+#define MNG_PLTEINDEXERROR (mng_retcode)1042 /* palette-index out-of-range */
+#define MNG_NULLNOTFOUND (mng_retcode)1043 /* couldn't find null-separator*/
+#define MNG_KEYWORDNULL (mng_retcode)1044 /* keyword cannot be empty */
+#define MNG_OBJECTUNKNOWN (mng_retcode)1045 /* the object can't be found */
+#define MNG_OBJECTEXISTS (mng_retcode)1046 /* the object already exists */
+#define MNG_TOOMUCHIDAT (mng_retcode)1047 /* got too much compressed data*/
+#define MNG_INVSAMPLEDEPTH (mng_retcode)1048 /* sampledepth out-of-range */
+#define MNG_INVOFFSETSIZE (mng_retcode)1049 /* invalid offset-size */
+#define MNG_INVENTRYTYPE (mng_retcode)1050 /* invalid entry-type */
+#define MNG_ENDWITHNULL (mng_retcode)1051 /* may not end with NULL */
+#define MNG_INVIMAGETYPE (mng_retcode)1052 /* invalid image_type */
+#define MNG_INVDELTATYPE (mng_retcode)1053 /* invalid delta_type */
+#define MNG_INVALIDINDEX (mng_retcode)1054 /* index-value invalid */
+#define MNG_TOOMUCHJDAT (mng_retcode)1055 /* got too much compressed data*/
+#define MNG_JPEGPARMSERR (mng_retcode)1056 /* JHDR/JPEG parms do not match*/
+#define MNG_INVFILLMETHOD (mng_retcode)1057 /* invalid fill_method */
+#define MNG_OBJNOTCONCRETE (mng_retcode)1058 /* object must be concrete */
+#define MNG_TARGETNOALPHA (mng_retcode)1059 /* object has no alpha-channel */
+#define MNG_MNGTOOCOMPLEX (mng_retcode)1060 /* can't handle complexity */
+#define MNG_UNKNOWNCRITICAL (mng_retcode)1061 /* unknown critical chunk found*/
+#define MNG_UNSUPPORTEDNEED (mng_retcode)1062 /* nEED requirement unsupported*/
+#define MNG_INVALIDDELTA (mng_retcode)1063 /* Delta operation illegal */
+#define MNG_INVALIDMETHOD (mng_retcode)1064 /* invalid MAGN method */
+#define MNG_IMPROBABLELENGTH (mng_retcode)1065 /* impropable chunk length */
+#define MNG_INVALIDBLOCK (mng_retcode)1066 /* invalid delta block */
+#define MNG_INVALIDEVENT (mng_retcode)1067 /* invalid event_type */
+#define MNG_INVALIDMASK (mng_retcode)1068 /* invalid mask_type */
+#define MNG_NOMATCHINGLOOP (mng_retcode)1069 /* ENDL without matching LOOP */
+#define MNG_SEEKNOTFOUND (mng_retcode)1070 /* EvNT points to unknown SEEK */
+#define MNG_OBJNOTABSTRACT (mng_retcode)1071 /* object must be abstract */
+#define MNG_TERMSEQERROR (mng_retcode)1072 /* TERM in wrong place */
+#define MNG_INVALIDFIELDVAL (mng_retcode)1073 /* invalid fieldvalue (generic)*/
+#define MNG_INVALIDWIDTH (mng_retcode)1074 /* invalid frame/image width */
+#define MNG_INVALIDHEIGHT (mng_retcode)1075 /* invalid frame/image height */
+
+#define MNG_INVALIDCNVSTYLE (mng_retcode)2049 /* can't make anything of this */
+#define MNG_WRONGCHUNK (mng_retcode)2050 /* accessing the wrong chunk */
+#define MNG_INVALIDENTRYIX (mng_retcode)2051 /* accessing the wrong entry */
+#define MNG_NOHEADER (mng_retcode)2052 /* must have had header first */
+#define MNG_NOCORRCHUNK (mng_retcode)2053 /* can't find parent chunk */
+#define MNG_NOMHDR (mng_retcode)2054 /* no MNG header available */
+
+#define MNG_IMAGETOOLARGE (mng_retcode)4097 /* input-image way too big */
+#define MNG_NOTANANIMATION (mng_retcode)4098 /* file not a MNG */
+#define MNG_FRAMENRTOOHIGH (mng_retcode)4099 /* frame-nr out-of-range */
+#define MNG_LAYERNRTOOHIGH (mng_retcode)4100 /* layer-nr out-of-range */
+#define MNG_PLAYTIMETOOHIGH (mng_retcode)4101 /* playtime out-of-range */
+#define MNG_FNNOTIMPLEMENTED (mng_retcode)4102 /* function not yet available */
+
+#define MNG_IMAGEFROZEN (mng_retcode)8193 /* stopped displaying */
+
+#define MNG_LCMS_NOHANDLE 1 /* LCMS returned NULL handle */
+#define MNG_LCMS_NOMEM 2 /* LCMS returned NULL gammatab */
+#define MNG_LCMS_NOTRANS 3 /* LCMS returned NULL transform*/
+
+/* ************************************************************************** */
+/* * * */
+/* * Canvas styles * */
+/* * * */
+/* * Note that the intentions are pretty darn good, but that the focus * */
+/* * is currently on 8-bit color support * */
+/* * * */
+/* * The RGB8_A8 style is defined for apps that require a separate * */
+/* * canvas for the color-planes and the alpha-plane (eg. mozilla) * */
+/* * This requires for the app to supply the "getalphaline" callback!!! * */
+/* * * */
+/* ************************************************************************** */
+
+#define MNG_CANVAS_RGB8 0x00000000L
+#define MNG_CANVAS_RGBA8 0x00001000L
+#define MNG_CANVAS_RGBA8_PM 0x00009000L
+#define MNG_CANVAS_ARGB8 0x00003000L
+#define MNG_CANVAS_ARGB8_PM 0x0000B000L
+#define MNG_CANVAS_RGB8_A8 0x00005000L
+#define MNG_CANVAS_BGR8 0x00000001L
+#define MNG_CANVAS_BGRX8 0x00010001L
+#define MNG_CANVAS_BGRA8 0x00001001L
+#define MNG_CANVAS_BGRA8PM 0x00009001L /* backward compatibility */
+#define MNG_CANVAS_BGRA8_PM 0x00009001L
+#define MNG_CANVAS_ABGR8 0x00003001L
+#define MNG_CANVAS_ABGR8_PM 0x0000B001L
+#define MNG_CANVAS_RGB16 0x00000100L /* not supported yet */
+#define MNG_CANVAS_RGBA16 0x00001100L /* not supported yet */
+#define MNG_CANVAS_ARGB16 0x00003100L /* not supported yet */
+#define MNG_CANVAS_BGR16 0x00000101L /* not supported yet */
+#define MNG_CANVAS_BGRA16 0x00001101L /* not supported yet */
+#define MNG_CANVAS_ABGR16 0x00003101L /* not supported yet */
+#define MNG_CANVAS_GRAY8 0x00000002L /* not supported yet */
+#define MNG_CANVAS_GRAY16 0x00000102L /* not supported yet */
+#define MNG_CANVAS_GRAYA8 0x00001002L /* not supported yet */
+#define MNG_CANVAS_GRAYA16 0x00001102L /* not supported yet */
+#define MNG_CANVAS_AGRAY8 0x00003002L /* not supported yet */
+#define MNG_CANVAS_AGRAY16 0x00003102L /* not supported yet */
+#define MNG_CANVAS_DX15 0x00000003L /* not supported yet */
+#define MNG_CANVAS_DX16 0x00000004L /* not supported yet */
+
+#define MNG_CANVAS_RGB565 0x00000005L
+#define MNG_CANVAS_RGBA565 0x00001005L
+#define MNG_CANVAS_BGR565 0x00000006L
+#define MNG_CANVAS_BGRA565 0x00001006L
+#define MNG_CANVAS_BGR565_A8 0x00004006L
+
+#define MNG_CANVAS_RGB555 0x00000007L
+#define MNG_CANVAS_BGR555 0x00000008L
+
+#define MNG_CANVAS_PIXELTYPE(C) (C & 0x000000FFL)
+#define MNG_CANVAS_BITDEPTH(C) (C & 0x00000100L)
+#define MNG_CANVAS_HASALPHA(C) (C & 0x00001000L)
+#define MNG_CANVAS_ALPHAFIRST(C) (C & 0x00002000L)
+#define MNG_CANVAS_ALPHASEPD(C) (C & 0x00004000L)
+#define MNG_CANVAS_ALPHAPM(C) (C & 0x00008000L)
+#define MNG_CANVAS_HASFILLER(C) (C & 0x00010000L)
+
+#define MNG_CANVAS_RGB(C) (MNG_CANVAS_PIXELTYPE (C) == 0)
+#define MNG_CANVAS_BGR(C) (MNG_CANVAS_PIXELTYPE (C) == 1)
+#define MNG_CANVAS_GRAY(C) (MNG_CANVAS_PIXELTYPE (C) == 2)
+#define MNG_CANVAS_DIRECTX15(C) (MNG_CANVAS_PIXELTYPE (C) == 3)
+#define MNG_CANVAS_DIRECTX16(C) (MNG_CANVAS_PIXELTYPE (C) == 4)
+#define MNG_CANVAS_RGB_565(C) (MNG_CANVAS_PIXELTYPE (C) == 5)
+#define MNG_CANVAS_BGR_565(C) (MNG_CANVAS_PIXELTYPE (C) == 6)
+#define MNG_CANVAS_8BIT(C) (!MNG_CANVAS_BITDEPTH (C))
+#define MNG_CANVAS_16BIT(C) (MNG_CANVAS_BITDEPTH (C))
+#define MNG_CANVAS_PIXELFIRST(C) (!MNG_CANVAS_ALPHAFIRST (C))
+
+/* ************************************************************************** */
+/* * * */
+/* * Chunk names (idea adapted from libpng 1.1.0 - png.h) * */
+/* * * */
+/* ************************************************************************** */
+
+#define MNG_UINT_HUH 0x40404040L
+
+#define MNG_UINT_BACK 0x4241434bL
+#define MNG_UINT_BASI 0x42415349L
+#define MNG_UINT_CLIP 0x434c4950L
+#define MNG_UINT_CLON 0x434c4f4eL
+#define MNG_UINT_DBYK 0x4442594bL
+#define MNG_UINT_DEFI 0x44454649L
+#define MNG_UINT_DHDR 0x44484452L
+#define MNG_UINT_DISC 0x44495343L
+#define MNG_UINT_DROP 0x44524f50L
+#define MNG_UINT_ENDL 0x454e444cL
+#define MNG_UINT_FRAM 0x4652414dL
+#define MNG_UINT_IDAT 0x49444154L
+#define MNG_UINT_IEND 0x49454e44L
+#define MNG_UINT_IHDR 0x49484452L
+#define MNG_UINT_IJNG 0x494a4e47L
+#define MNG_UINT_IPNG 0x49504e47L
+#define MNG_UINT_JDAA 0x4a444141L
+#define MNG_UINT_JDAT 0x4a444154L
+#define MNG_UINT_JHDR 0x4a484452L
+#define MNG_UINT_JSEP 0x4a534550L
+#define MNG_UINT_JdAA 0x4a644141L
+#define MNG_UINT_LOOP 0x4c4f4f50L
+#define MNG_UINT_MAGN 0x4d41474eL
+#define MNG_UINT_MEND 0x4d454e44L
+#define MNG_UINT_MHDR 0x4d484452L
+#define MNG_UINT_MOVE 0x4d4f5645L
+#define MNG_UINT_ORDR 0x4f524452L
+#define MNG_UINT_PAST 0x50415354L
+#define MNG_UINT_PLTE 0x504c5445L
+#define MNG_UINT_PPLT 0x50504c54L
+#define MNG_UINT_PROM 0x50524f4dL
+#define MNG_UINT_SAVE 0x53415645L
+#define MNG_UINT_SEEK 0x5345454bL
+#define MNG_UINT_SHOW 0x53484f57L
+#define MNG_UINT_TERM 0x5445524dL
+#define MNG_UINT_adAT 0x61644154L
+#define MNG_UINT_ahDR 0x61684452L
+#define MNG_UINT_bKGD 0x624b4744L
+#define MNG_UINT_cHRM 0x6348524dL
+#define MNG_UINT_eXPI 0x65585049L
+#define MNG_UINT_evNT 0x65764e54L
+#define MNG_UINT_fPRI 0x66505249L
+#define MNG_UINT_gAMA 0x67414d41L
+#define MNG_UINT_hIST 0x68495354L
+#define MNG_UINT_iCCP 0x69434350L
+#define MNG_UINT_iTXt 0x69545874L
+#define MNG_UINT_mpNG 0x6d704e47L
+#define MNG_UINT_nEED 0x6e454544L
+#define MNG_UINT_oFFs 0x6f464673L
+#define MNG_UINT_pCAL 0x7043414cL
+#define MNG_UINT_pHYg 0x70444167L
+#define MNG_UINT_pHYs 0x70485973L
+#define MNG_UINT_sBIT 0x73424954L
+#define MNG_UINT_sCAL 0x7343414cL
+#define MNG_UINT_sPLT 0x73504c54L
+#define MNG_UINT_sRGB 0x73524742L
+#define MNG_UINT_tEXt 0x74455874L
+#define MNG_UINT_tIME 0x74494d45L
+#define MNG_UINT_tRNS 0x74524e53L
+#define MNG_UINT_zTXt 0x7a545874L
+
+/* ************************************************************************** */
+/* * * */
+/* * Chunk property values * */
+/* * * */
+/* ************************************************************************** */
+
+#define MNG_BITDEPTH_1 1 /* IHDR, BASI, JHDR, PROM */
+#define MNG_BITDEPTH_2 2
+#define MNG_BITDEPTH_4 4
+#define MNG_BITDEPTH_8 8 /* sPLT */
+#define MNG_BITDEPTH_16 16
+
+#define MNG_COLORTYPE_GRAY 0 /* IHDR, BASI, PROM */
+#define MNG_COLORTYPE_RGB 2
+#define MNG_COLORTYPE_INDEXED 3
+#define MNG_COLORTYPE_GRAYA 4
+#define MNG_COLORTYPE_RGBA 6
+
+#define MNG_COMPRESSION_DEFLATE 0 /* IHDR, zTXt, iTXt, iCCP,
+ BASI, JHDR */
+
+#define MNG_FILTER_ADAPTIVE 0 /* IHDR, BASI, JHDR */
+/* #define MNG_FILTER_NO_ADAPTIVE 1
+#define MNG_FILTER_NO_DIFFERING 0
+#define MNG_FILTER_DIFFERING 0x40
+#define MNG_FILTER_MASK (MNG_FILTER_NO_ADAPTIVE | MNG_FILTER_DIFFERING) */
+#ifdef FILTER192
+#define MNG_FILTER_DIFFERING 0xC0
+#endif
+#ifdef FILTER193
+#define MNG_FILTER_NOFILTER 0xC1
+#endif
+
+#define MNG_INTERLACE_NONE 0 /* IHDR, BASI, JHDR */
+#define MNG_INTERLACE_ADAM7 1
+
+#define MNG_FILTER_NONE 0 /* IDAT */
+#define MNG_FILTER_SUB 1
+#define MNG_FILTER_UP 2
+#define MNG_FILTER_AVERAGE 3
+#define MNG_FILTER_PAETH 4
+
+#define MNG_INTENT_PERCEPTUAL 0 /* sRGB */
+#define MNG_INTENT_RELATIVECOLORIMETRIC 1
+#define MNG_INTENT_SATURATION 2
+#define MNG_INTENT_ABSOLUTECOLORIMETRIC 3
+ /* tEXt, zTXt, iTXt */
+#define MNG_TEXT_TITLE "Title"
+#define MNG_TEXT_AUTHOR "Author"
+#define MNG_TEXT_DESCRIPTION "Description"
+#define MNG_TEXT_COPYRIGHT "Copyright"
+#define MNG_TEXT_CREATIONTIME "Creation Time"
+#define MNG_TEXT_SOFTWARE "Software"
+#define MNG_TEXT_DISCLAIMER "Disclaimer"
+#define MNG_TEXT_WARNING "Warning"
+#define MNG_TEXT_SOURCE "Source"
+#define MNG_TEXT_COMMENT "Comment"
+
+#define MNG_FLAG_UNCOMPRESSED 0 /* iTXt */
+#define MNG_FLAG_COMPRESSED 1
+
+#define MNG_UNIT_UNKNOWN 0 /* pHYs, pHYg */
+#define MNG_UNIT_METER 1
+ /* MHDR */
+#define MNG_SIMPLICITY_VALID 0x00000001
+#define MNG_SIMPLICITY_SIMPLEFEATURES 0x00000002
+#define MNG_SIMPLICITY_COMPLEXFEATURES 0x00000004
+#define MNG_SIMPLICITY_TRANSPARENCY 0x00000008
+#define MNG_SIMPLICITY_JNG 0x00000010
+#define MNG_SIMPLICITY_DELTAPNG 0x00000020
+
+#define MNG_TERMINATION_DECODER_NC 0 /* LOOP */
+#define MNG_TERMINATION_USER_NC 1
+#define MNG_TERMINATION_EXTERNAL_NC 2
+#define MNG_TERMINATION_DETERMINISTIC_NC 3
+#define MNG_TERMINATION_DECODER_C 4
+#define MNG_TERMINATION_USER_C 5
+#define MNG_TERMINATION_EXTERNAL_C 6
+#define MNG_TERMINATION_DETERMINISTIC_C 7
+
+#define MNG_DONOTSHOW_VISIBLE 0 /* DEFI */
+#define MNG_DONOTSHOW_NOTVISIBLE 1
+
+#define MNG_ABSTRACT 0 /* DEFI */
+#define MNG_CONCRETE 1
+
+#define MNG_NOTVIEWABLE 0 /* BASI */
+#define MNG_VIEWABLE 1
+
+#define MNG_FULL_CLONE 0 /* CLON */
+#define MNG_PARTIAL_CLONE 1
+#define MNG_RENUMBER 2
+
+#define MNG_CONCRETE_ASPARENT 0 /* CLON */
+#define MNG_CONCRETE_MAKEABSTRACT 1
+
+#define MNG_LOCATION_ABSOLUTE 0 /* CLON, MOVE */
+#define MNG_LOCATION_RELATIVE 1
+
+#ifndef MNG_SKIPCHUNK_PAST
+#define MNG_TARGET_ABSOLUTE 0 /* PAST */
+#define MNG_TARGET_RELATIVE_SAMEPAST 1
+#define MNG_TARGET_RELATIVE_PREVPAST 2
+
+#define MNG_COMPOSITE_OVER 0 /* PAST */
+#define MNG_COMPOSITE_REPLACE 1
+#define MNG_COMPOSITE_UNDER 2
+
+#define MNG_ORIENTATION_SAME 0 /* PAST */
+#define MNG_ORIENTATION_180DEG 2
+#define MNG_ORIENTATION_FLIPHORZ 4
+#define MNG_ORIENTATION_FLIPVERT 6
+#define MNG_ORIENTATION_TILED 8
+
+#define MNG_OFFSET_ABSOLUTE 0 /* PAST */
+#define MNG_OFFSET_RELATIVE 1
+#endif
+
+#define MNG_BOUNDARY_ABSOLUTE 0 /* PAST, FRAM */
+#define MNG_BOUNDARY_RELATIVE 1
+
+#define MNG_BACKGROUNDCOLOR_MANDATORY 0x01 /* BACK */
+#define MNG_BACKGROUNDIMAGE_MANDATORY 0x02 /* BACK */
+
+#define MNG_BACKGROUNDIMAGE_NOTILE 0 /* BACK */
+#define MNG_BACKGROUNDIMAGE_TILE 1
+
+#define MNG_FRAMINGMODE_NOCHANGE 0 /* FRAM */
+#define MNG_FRAMINGMODE_1 1
+#define MNG_FRAMINGMODE_2 2
+#define MNG_FRAMINGMODE_3 3
+#define MNG_FRAMINGMODE_4 4
+
+#define MNG_CHANGEDELAY_NO 0 /* FRAM */
+#define MNG_CHANGEDELAY_NEXTSUBFRAME 1
+#define MNG_CHANGEDELAY_DEFAULT 2
+
+#define MNG_CHANGETIMOUT_NO 0 /* FRAM */
+#define MNG_CHANGETIMOUT_DETERMINISTIC_1 1
+#define MNG_CHANGETIMOUT_DETERMINISTIC_2 2
+#define MNG_CHANGETIMOUT_DECODER_1 3
+#define MNG_CHANGETIMOUT_DECODER_2 4
+#define MNG_CHANGETIMOUT_USER_1 5
+#define MNG_CHANGETIMOUT_USER_2 6
+#define MNG_CHANGETIMOUT_EXTERNAL_1 7
+#define MNG_CHANGETIMOUT_EXTERNAL_2 8
+
+#define MNG_CHANGECLIPPING_NO 0 /* FRAM */
+#define MNG_CHANGECLIPPING_NEXTSUBFRAME 1
+#define MNG_CHANGECLIPPING_DEFAULT 2
+
+#define MNG_CHANGESYNCID_NO 0 /* FRAM */
+#define MNG_CHANGESYNCID_NEXTSUBFRAME 1
+#define MNG_CHANGESYNCID_DEFAULT 2
+
+#define MNG_CLIPPING_ABSOLUTE 0 /* CLIP */
+#define MNG_CLIPPING_RELATIVE 1
+
+#define MNG_SHOWMODE_0 0 /* SHOW */
+#define MNG_SHOWMODE_1 1
+#define MNG_SHOWMODE_2 2
+#define MNG_SHOWMODE_3 3
+#define MNG_SHOWMODE_4 4
+#define MNG_SHOWMODE_5 5
+#define MNG_SHOWMODE_6 6
+#define MNG_SHOWMODE_7 7
+
+#define MNG_TERMACTION_LASTFRAME 0 /* TERM */
+#define MNG_TERMACTION_CLEAR 1
+#define MNG_TERMACTION_FIRSTFRAME 2
+#define MNG_TERMACTION_REPEAT 3
+
+#define MNG_ITERACTION_LASTFRAME 0 /* TERM */
+#define MNG_ITERACTION_CLEAR 1
+#define MNG_ITERACTION_FIRSTFRAME 2
+
+#define MNG_SAVEOFFSET_4BYTE 4 /* SAVE */
+#define MNG_SAVEOFFSET_8BYTE 8
+
+#define MNG_SAVEENTRY_SEGMENTFULL 0 /* SAVE */
+#define MNG_SAVEENTRY_SEGMENT 1
+#define MNG_SAVEENTRY_SUBFRAME 2
+#define MNG_SAVEENTRY_EXPORTEDIMAGE 3
+
+#define MNG_PRIORITY_ABSOLUTE 0 /* fPRI */
+#define MNG_PRIORITY_RELATIVE 1
+
+#ifdef MNG_INCLUDE_JNG
+#define MNG_COLORTYPE_JPEGGRAY 8 /* JHDR */
+#define MNG_COLORTYPE_JPEGCOLOR 10
+#define MNG_COLORTYPE_JPEGGRAYA 12
+#define MNG_COLORTYPE_JPEGCOLORA 14
+
+#define MNG_BITDEPTH_JPEG8 8 /* JHDR */
+#define MNG_BITDEPTH_JPEG12 12
+#define MNG_BITDEPTH_JPEG8AND12 20
+
+#define MNG_COMPRESSION_BASELINEJPEG 8 /* JHDR */
+
+#define MNG_INTERLACE_SEQUENTIAL 0 /* JHDR */
+#define MNG_INTERLACE_PROGRESSIVE 8
+#endif /* MNG_INCLUDE_JNG */
+
+#define MNG_IMAGETYPE_UNKNOWN 0 /* DHDR */
+#define MNG_IMAGETYPE_PNG 1
+#define MNG_IMAGETYPE_JNG 2
+
+#define MNG_DELTATYPE_REPLACE 0 /* DHDR */
+#define MNG_DELTATYPE_BLOCKPIXELADD 1
+#define MNG_DELTATYPE_BLOCKALPHAADD 2
+#define MNG_DELTATYPE_BLOCKCOLORADD 3
+#define MNG_DELTATYPE_BLOCKPIXELREPLACE 4
+#define MNG_DELTATYPE_BLOCKALPHAREPLACE 5
+#define MNG_DELTATYPE_BLOCKCOLORREPLACE 6
+#define MNG_DELTATYPE_NOCHANGE 7
+
+#define MNG_FILLMETHOD_LEFTBITREPLICATE 0 /* PROM */
+#define MNG_FILLMETHOD_ZEROFILL 1
+
+#define MNG_DELTATYPE_REPLACERGB 0 /* PPLT */
+#define MNG_DELTATYPE_DELTARGB 1
+#define MNG_DELTATYPE_REPLACEALPHA 2
+#define MNG_DELTATYPE_DELTAALPHA 3
+#define MNG_DELTATYPE_REPLACERGBA 4
+#define MNG_DELTATYPE_DELTARGBA 5
+
+#define MNG_POLARITY_ONLY 0 /* DBYK */
+#define MNG_POLARITY_ALLBUT 1
+
+#define MNG_EVENT_NONE 0 /* evNT */
+#define MNG_EVENT_MOUSEENTER 1
+#define MNG_EVENT_MOUSEMOVE 2
+#define MNG_EVENT_MOUSEEXIT 3
+#define MNG_EVENT_MOUSEDOWN 4
+#define MNG_EVENT_MOUSEUP 5
+
+#define MNG_MASK_NONE 0 /* evNT */
+#define MNG_MASK_BOX 1
+#define MNG_MASK_OBJECT 2
+#define MNG_MASK_OBJECTIX 3
+#define MNG_MASK_BOXOBJECT 4
+#define MNG_MASK_BOXOBJECTIX 5
+
+/* ************************************************************************** */
+/* * * */
+/* * Processtext callback types * */
+/* * * */
+/* ************************************************************************** */
+
+#define MNG_TYPE_TEXT 0
+#define MNG_TYPE_ZTXT 1
+#define MNG_TYPE_ITXT 2
+
+/* ************************************************************************** */
+/* * * */
+/* * CRC processing masks * */
+/* * * */
+/* ************************************************************************** */
+
+#define MNG_CRC_INPUT 0x0000000f
+#define MNG_CRC_INPUT_NONE 0x00000000
+#define MNG_CRC_INPUT_PRESENT 0x00000001
+#define MNG_CRC_OUTPUT 0x000000f0
+#define MNG_CRC_OUTPUT_NONE 0x00000000
+#define MNG_CRC_OUTPUT_GENERATE 0x00000020
+#define MNG_CRC_OUTPUT_DUMMY 0x00000040
+#define MNG_CRC_ANCILLARY 0x00000f00
+#define MNG_CRC_ANCILLARY_IGNORE 0x00000000
+#define MNG_CRC_ANCILLARY_DISCARD 0x00000100
+#define MNG_CRC_ANCILLARY_WARNING 0x00000200
+#define MNG_CRC_ANCILLARY_ERROR 0x00000300
+#define MNG_CRC_CRITICAL 0x0000f000
+#define MNG_CRC_CRITICAL_IGNORE 0x00000000
+#define MNG_CRC_CRITICAL_WARNING 0x00002000
+#define MNG_CRC_CRITICAL_ERROR 0x00003000
+#define MNG_CRC_DEFAULT 0x00002121
+
+/* ************************************************************************** */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _libmng_h_ */
+
+/* ************************************************************************** */
+/* * end of file * */
+/* ************************************************************************** */
+
diff --git a/src/3rdparty/libmng/libmng_callback_xs.c b/src/3rdparty/libmng/libmng_callback_xs.c
new file mode 100644
index 0000000000..ff1a22a70b
--- /dev/null
+++ b/src/3rdparty/libmng/libmng_callback_xs.c
@@ -0,0 +1,1239 @@
+/* ************************************************************************** */
+/* * For conditions of distribution and use, * */
+/* * see copyright notice in libmng.h * */
+/* ************************************************************************** */
+/* * * */
+/* * project : libmng * */
+/* * file : libmng_callback_xs.c copyright (c) 2000-2004 G.Juyn * */
+/* * version : 1.0.9 * */
+/* * * */
+/* * purpose : callback get/set interface (implementation) * */
+/* * * */
+/* * author : G.Juyn * */
+/* * * */
+/* * comment : implementation of the callback get/set functions * */
+/* * * */
+/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */
+/* * - fixed calling convention * */
+/* * - changed strict-ANSI stuff * */
+/* * 0.5.1 - 05/12/2000 - G.Juyn * */
+/* * - changed trace to macro for callback error-reporting * */
+/* * * */
+/* * 0.5.2 - 05/31/2000 - G.Juyn * */
+/* * - fixed up punctuation (contribution by Tim Rowley) * */
+/* * 0.5.2 - 06/02/2000 - G.Juyn * */
+/* * - added getalphaline callback for RGB8_A8 canvasstyle * */
+/* * * */
+/* * 0.9.1 - 07/15/2000 - G.Juyn * */
+/* * - added callbacks for SAVE/SEEK processing * */
+/* * * */
+/* * 0.9.2 - 08/05/2000 - G.Juyn * */
+/* * - changed file-prefixes * */
+/* * * */
+/* * 0.9.3 - 10/11/2000 - G.Juyn * */
+/* * - added support for nEED * */
+/* * 0.9.3 - 10/17/2000 - G.Juyn * */
+/* * - added callback to process non-critical unknown chunks * */
+/* * * */
+/* * 1.0.1 - 02/08/2001 - G.Juyn * */
+/* * - added MEND processing callback * */
+/* * * */
+/* * 1.0.2 - 06/23/2001 - G.Juyn * */
+/* * - added processterm callback * */
+/* * * */
+/* * 1.0.6 - 07/07/2003 - G. R-P * */
+/* * - added SKIPCHUNK feature * */
+/* * * */
+/* * 1.0.7 - 03/10/2004 - G.R-P * */
+/* * - added conditionals around openstream/closestream * */
+/* * 1.0.7 - 03/19/2004 - G.R-P * */
+/* * - fixed typo (MNG_SKIPCHUNK_SAVE -> MNG_SKIPCHUNK_nEED * */
+/* * * */
+/* * 1.0.8 - 04/10/2004 - G.Juyn * */
+/* * - added data-push mechanisms for specialized decoders * */
+/* * * */
+/* * 1.0.9 - 09/18/2004 - G.R-P. * */
+/* * - added two SKIPCHUNK_TERM conditionals * */
+/* * 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
+
+#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
+#pragma option -A /* force ANSI-C */
+#endif
+
+/* ************************************************************************** */
+/* * * */
+/* * Callback set functions * */
+/* * * */
+/* ************************************************************************** */
+
+#ifndef MNG_INTERNAL_MEMMNGMT
+mng_retcode MNG_DECL mng_setcb_memalloc (mng_handle hHandle,
+ mng_memalloc fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_MEMALLOC, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fMemalloc = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_MEMALLOC, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif /* MNG_INTERNAL_MEMMNGMT */
+
+/* ************************************************************************** */
+
+#ifndef MNG_INTERNAL_MEMMNGMT
+mng_retcode MNG_DECL mng_setcb_memfree (mng_handle hHandle,
+ mng_memfree fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_MEMFREE, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fMemfree = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_MEMFREE, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif /* MNG_INTERNAL_MEMMNGMT */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_READ
+mng_retcode MNG_DECL mng_setcb_releasedata (mng_handle hHandle,
+ mng_releasedata fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_RELEASEDATA, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fReleasedata = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_RELEASEDATA, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif /* MNG_SUPPORT_READ */
+
+/* ************************************************************************** */
+
+#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE)
+#ifndef MNG_NO_OPEN_CLOSE_STREAM
+mng_retcode MNG_DECL mng_setcb_openstream (mng_handle hHandle,
+ mng_openstream fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_OPENSTREAM, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fOpenstream = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_OPENSTREAM, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif
+#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */
+
+/* ************************************************************************** */
+
+#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE)
+#ifndef MNG_NO_OPEN_CLOSE_STREAM
+mng_retcode MNG_DECL mng_setcb_closestream (mng_handle hHandle,
+ mng_closestream fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_CLOSESTREAM, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fClosestream = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_CLOSESTREAM, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif
+#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_READ
+mng_retcode MNG_DECL mng_setcb_readdata (mng_handle hHandle,
+ mng_readdata fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_READDATA, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fReaddata = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_READDATA, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif /* MNG_SUPPORT_READ */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_WRITE
+mng_retcode MNG_DECL mng_setcb_writedata (mng_handle hHandle,
+ mng_writedata fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_WRITEDATA, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fWritedata = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_WRITEDATA, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif /* MNG_SUPPORT_WRITE */
+
+/* ************************************************************************** */
+
+mng_retcode MNG_DECL mng_setcb_errorproc (mng_handle hHandle,
+ mng_errorproc fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_ERRORPROC, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fErrorproc = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_ERRORPROC, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_TRACE
+mng_retcode MNG_DECL mng_setcb_traceproc (mng_handle hHandle,
+ mng_traceproc fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_TRACEPROC, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fTraceproc = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_TRACEPROC, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif /* MNG_SUPPORT_TRACE */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_READ
+mng_retcode MNG_DECL mng_setcb_processheader (mng_handle hHandle,
+ mng_processheader fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSHEADER, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fProcessheader = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSHEADER, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif /* MNG_SUPPORT_READ */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_READ
+#ifndef MNG_SKIPCHUNK_tEXt
+mng_retcode MNG_DECL mng_setcb_processtext (mng_handle hHandle,
+ mng_processtext fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSTEXT, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fProcesstext = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSTEXT, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif
+#endif /* MNG_SUPPORT_READ */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_READ
+#ifndef MNG_SKIPCHUNK_SAVE
+mng_retcode MNG_DECL mng_setcb_processsave (mng_handle hHandle,
+ mng_processsave fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSSAVE, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fProcesssave = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSSAVE, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif
+#endif /* MNG_SUPPORT_READ */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_READ
+#ifndef MNG_SKIPCHUNK_SEEK
+mng_retcode MNG_DECL mng_setcb_processseek (mng_handle hHandle,
+ mng_processseek fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSSEEK, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fProcessseek = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSSEEK, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif
+#endif /* MNG_SUPPORT_READ */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_READ
+#ifndef MNG_SKIPCHUNK_nEED
+mng_retcode MNG_DECL mng_setcb_processneed (mng_handle hHandle,
+ mng_processneed fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSNEED, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fProcessneed = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSNEED, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif
+#endif /* MNG_SUPPORT_READ */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_READ
+mng_retcode MNG_DECL mng_setcb_processmend (mng_handle hHandle,
+ mng_processmend fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSMEND, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fProcessmend = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSMEND, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif /* MNG_SUPPORT_READ */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_READ
+mng_retcode MNG_DECL mng_setcb_processunknown (mng_handle hHandle,
+ mng_processunknown fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSUNKNOWN, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fProcessunknown = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSUNKNOWN, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif /* MNG_SUPPORT_READ */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_READ
+#ifndef MNG_SKIPCHUNK_TERM
+mng_retcode MNG_DECL mng_setcb_processterm (mng_handle hHandle,
+ mng_processterm fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSTERM, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fProcessterm = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSTERM, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif
+#endif /* MNG_SUPPORT_READ */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_DISPLAY
+mng_retcode MNG_DECL mng_setcb_getcanvasline (mng_handle hHandle,
+ mng_getcanvasline fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETCANVASLINE, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fGetcanvasline = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETCANVASLINE, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif /* MNG_SUPPORT_DISPLAY */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_DISPLAY
+mng_retcode MNG_DECL mng_setcb_getbkgdline (mng_handle hHandle,
+ mng_getbkgdline fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETBKGDLINE, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fGetbkgdline = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETBKGDLINE, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif /* MNG_SUPPORT_DISPLAY */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_DISPLAY
+mng_retcode MNG_DECL mng_setcb_getalphaline (mng_handle hHandle,
+ mng_getalphaline fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETALPHALINE, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fGetalphaline = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETALPHALINE, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif /* MNG_SUPPORT_DISPLAY */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_DISPLAY
+mng_retcode MNG_DECL mng_setcb_refresh (mng_handle hHandle,
+ mng_refresh fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_REFRESH, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fRefresh = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_REFRESH, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif /* MNG_SUPPORT_DISPLAY */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_DISPLAY
+mng_retcode MNG_DECL mng_setcb_gettickcount (mng_handle hHandle,
+ mng_gettickcount fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETTICKCOUNT, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fGettickcount = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETTICKCOUNT, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif /* MNG_SUPPORT_DISPLAY */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_DISPLAY
+mng_retcode MNG_DECL mng_setcb_settimer (mng_handle hHandle,
+ mng_settimer fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_SETTIMER, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fSettimer = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_SETTIMER, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif /* MNG_SUPPORT_DISPLAY */
+
+/* ************************************************************************** */
+
+#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS)
+mng_retcode MNG_DECL mng_setcb_processgamma (mng_handle hHandle,
+ mng_processgamma fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSGAMA, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fProcessgamma = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSGAMA, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */
+
+/* ************************************************************************** */
+
+#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS)
+#ifndef MNG_SKIPCHUNK_cHRM
+mng_retcode MNG_DECL mng_setcb_processchroma (mng_handle hHandle,
+ mng_processchroma fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSCHROMA, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fProcesschroma = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSCHROMA, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif
+#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */
+
+/* ************************************************************************** */
+
+#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS)
+mng_retcode MNG_DECL mng_setcb_processsrgb (mng_handle hHandle,
+ mng_processsrgb fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSSRGB, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fProcesssrgb = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSSRGB, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */
+
+/* ************************************************************************** */
+
+#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS)
+#ifndef MNG_SKIPCHUNK_iCCP
+mng_retcode MNG_DECL mng_setcb_processiccp (mng_handle hHandle,
+ mng_processiccp fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSICCP, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fProcessiccp = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSICCP, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif
+#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */
+
+/* ************************************************************************** */
+
+#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS)
+mng_retcode MNG_DECL mng_setcb_processarow (mng_handle hHandle,
+ mng_processarow fProc)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSAROW, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLE (hHandle)
+ ((mng_datap)hHandle)->fProcessarow = fProc;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSAROW, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */
+
+/* ************************************************************************** */
+/* * * */
+/* * Callback get functions * */
+/* * * */
+/* ************************************************************************** */
+
+#ifndef MNG_INTERNAL_MEMMNGMT
+mng_memalloc MNG_DECL mng_getcb_memalloc (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_MEMALLOC, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_MEMALLOC, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fMemalloc;
+}
+#endif /* MNG_INTERNAL_MEMMNGMT */
+
+/* ************************************************************************** */
+
+#ifndef MNG_INTERNAL_MEMMNGMT
+mng_memfree MNG_DECL mng_getcb_memfree (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_MEMFREE, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_MEMFREE, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fMemfree;
+}
+#endif /* MNG_INTERNAL_MEMMNGMT */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_READ
+mng_releasedata MNG_DECL mng_getcb_releasedata (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_RELEASEDATA, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_RELEASEDATA, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fReleasedata;
+}
+#endif /* MNG_SUPPORT_READ */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_READ
+mng_readdata MNG_DECL mng_getcb_readdata (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_READDATA, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_READDATA, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fReaddata;
+}
+#endif /* MNG_SUPPORT_READ */
+
+/* ************************************************************************** */
+
+#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE)
+#ifndef MNG_NO_OPEN_CLOSE_STREAM
+mng_openstream MNG_DECL mng_getcb_openstream (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_OPENSTREAM, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_OPENSTREAM, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fOpenstream;
+}
+#endif
+#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */
+
+/* ************************************************************************** */
+
+#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE)
+#ifndef MNG_NO_OPEN_CLOSE_STREAM
+mng_closestream MNG_DECL mng_getcb_closestream (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_CLOSESTREAM, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_CLOSESTREAM, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fClosestream;
+}
+#endif
+#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_WRITE
+mng_writedata MNG_DECL mng_getcb_writedata (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_WRITEDATA, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_WRITEDATA, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fWritedata;
+}
+#endif /* MNG_SUPPORT_WRITE */
+
+/* ************************************************************************** */
+
+mng_errorproc MNG_DECL mng_getcb_errorproc (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_ERRORPROC, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_ERRORPROC, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fErrorproc;
+}
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_TRACE
+mng_traceproc MNG_DECL mng_getcb_traceproc (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_TRACEPROC, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_TRACEPROC, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fTraceproc;
+}
+#endif /* MNG_SUPPORT_TRACE */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_READ
+mng_processheader MNG_DECL mng_getcb_processheader (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSHEADER, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSHEADER, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fProcessheader;
+}
+#endif /* MNG_SUPPORT_READ */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_READ
+#ifndef MNG_SKIPCHUNK_tEXt
+mng_processtext MNG_DECL mng_getcb_processtext (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSTEXT, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSTEXT, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fProcesstext;
+}
+#endif
+#endif /* MNG_SUPPORT_READ */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_READ
+#ifndef MNG_SKIPCHUNK_SAVE
+mng_processsave MNG_DECL mng_getcb_processsave (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSSAVE, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSSAVE, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fProcesssave;
+}
+#endif
+#endif /* MNG_SUPPORT_READ */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_READ
+#ifndef MNG_SKIPCHUNK_SEEK
+mng_processseek MNG_DECL mng_getcb_processseek (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSSEEK, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSSEEK, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fProcessseek;
+}
+#endif
+#endif /* MNG_SUPPORT_READ */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_READ
+#ifndef MNG_SKIPCHUNK_nEED
+mng_processneed MNG_DECL mng_getcb_processneed (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSNEED, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSNEED, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fProcessneed;
+}
+#endif
+#endif /* MNG_SUPPORT_READ */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_READ
+mng_processmend MNG_DECL mng_getcb_processmend (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSMEND, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSMEND, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fProcessmend;
+}
+#endif /* MNG_SUPPORT_READ */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_READ
+mng_processunknown MNG_DECL mng_getcb_processunknown (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSUNKNOWN, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSUNKNOWN, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fProcessunknown;
+}
+#endif /* MNG_SUPPORT_READ */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_READ
+#ifndef MNG_SKIPCHUNK_TERM
+mng_processterm MNG_DECL mng_getcb_processterm (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSTERM, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSTERM, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fProcessterm;
+}
+#endif
+#endif /* MNG_SUPPORT_READ */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_DISPLAY
+mng_getcanvasline MNG_DECL mng_getcb_getcanvasline (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETCANVASLINE, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETCANVASLINE, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fGetcanvasline;
+}
+#endif /* MNG_SUPPORT_DISPLAY */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_DISPLAY
+mng_getbkgdline MNG_DECL mng_getcb_getbkgdline (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETBKGDLINE, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETBKGDLINE, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fGetbkgdline;
+}
+#endif /* MNG_SUPPORT_DISPLAY */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_DISPLAY
+mng_getalphaline MNG_DECL mng_getcb_getalphaline (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETALPHALINE, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETALPHALINE, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fGetalphaline;
+}
+#endif /* MNG_SUPPORT_DISPLAY */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_DISPLAY
+mng_refresh MNG_DECL mng_getcb_refresh (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_REFRESH, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_REFRESH, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fRefresh;
+}
+#endif /* MNG_SUPPORT_DISPLAY */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_DISPLAY
+mng_gettickcount MNG_DECL mng_getcb_gettickcount (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETTICKCOUNT, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETTICKCOUNT, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fGettickcount;
+}
+#endif /* MNG_SUPPORT_DISPLAY */
+
+/* ************************************************************************** */
+
+#ifdef MNG_SUPPORT_DISPLAY
+mng_settimer MNG_DECL mng_getcb_settimer (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_SETTIMER, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_SETTIMER, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fSettimer;
+}
+#endif /* MNG_SUPPORT_DISPLAY */
+
+/* ************************************************************************** */
+
+#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS)
+mng_processgamma MNG_DECL mng_getcb_processgamma (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSGAMMA, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSGAMMA, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fProcessgamma;
+}
+#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */
+
+/* ************************************************************************** */
+
+#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS)
+#ifndef MNG_SKIPCHUNK_cHRM
+mng_processchroma MNG_DECL mng_getcb_processchroma (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSCHROMA, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSCHROMA, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fProcesschroma;
+}
+#endif
+#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */
+
+/* ************************************************************************** */
+
+#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS)
+mng_processsrgb MNG_DECL mng_getcb_processsrgb (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSSRGB, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSSRGB, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fProcesssrgb;
+}
+#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */
+
+/* ************************************************************************** */
+
+#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS)
+#ifndef MNG_SKIPCHUNK_iCCP
+mng_processiccp MNG_DECL mng_getcb_processiccp (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSICCP, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSICCP, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fProcessiccp;
+}
+#endif
+#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */
+
+/* ************************************************************************** */
+
+#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS)
+mng_processarow MNG_DECL mng_getcb_processarow (mng_handle hHandle)
+{
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSAROW, MNG_LC_START);
+#endif
+
+ MNG_VALIDHANDLEX (hHandle)
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSAROW, MNG_LC_END);
+#endif
+
+ return ((mng_datap)hHandle)->fProcessarow;
+}
+#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */
+
+/* ************************************************************************** */
+/* * end of file * */
+/* ************************************************************************** */
+
+
+
diff --git a/src/3rdparty/libmng/libmng_chunk_descr.c b/src/3rdparty/libmng/libmng_chunk_descr.c
new file mode 100644
index 0000000000..e1004a5404
--- /dev/null
+++ b/src/3rdparty/libmng/libmng_chunk_descr.c
@@ -0,0 +1,6090 @@
+/* ************************************************************************** */
+/* * For conditions of distribution and use, * */
+/* * see copyright notice in libmng.h * */
+/* ************************************************************************** */
+/* * * */
+/* * project : libmng * */
+/* * file : libmng_chunk_descr.c copyright (c) 2005-2007 G.Juyn * */
+/* * version : 1.0.10 * */
+/* * * */
+/* * purpose : Chunk descriptor functions (implementation) * */
+/* * * */
+/* * author : G.Juyn * */
+/* * * */
+/* * comment : implementation of the chunk- anf field-descriptor * */
+/* * routines * */
+/* * * */
+/* * changes : 1.0.9 - 12/06/2004 - G.Juyn * */
+/* * - added conditional MNG_OPTIMIZE_CHUNKREADER * */
+/* * 1.0.9 - 12/11/2004 - G.Juyn * */
+/* * - made all constants 'static' * */
+/* * 1.0.9 - 12/20/2004 - G.Juyn * */
+/* * - cleaned up macro-invocations (thanks to D. Airlie) * */
+/* * 1.0.9 - 01/17/2005 - G.Juyn * */
+/* * - fixed problem with global PLTE/tRNS * */
+/* * * */
+/* * 1.0.10 - 01/17/2005 - G.R-P. * */
+/* * - added typecast to appease the compiler * */
+/* * 1.0.10 - 04/08/2007 - G.Juyn * */
+/* * - added support for mPNG proposal * */
+/* * 1.0.10 - 04/12/2007 - G.Juyn * */
+/* * - added support for ANG proposal * */
+/* * * */
+/* ************************************************************************** */
+
+#include <stddef.h> /* needed for offsetof() */
+
+#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_objects.h"
+#include "libmng_chunks.h"
+#include "libmng_chunk_descr.h"
+#include "libmng_object_prc.h"
+#include "libmng_chunk_prc.h"
+#include "libmng_chunk_io.h"
+#include "libmng_display.h"
+
+#ifdef MNG_INCLUDE_ANG_PROPOSAL
+#include "libmng_pixels.h"
+#include "libmng_filter.h"
+#endif
+
+#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
+#pragma option -A /* force ANSI-C */
+#endif
+
+/* ************************************************************************** */
+
+#ifdef MNG_OPTIMIZE_CHUNKREADER
+#if defined(MNG_INCLUDE_READ_PROCS) || defined(MNG_INCLUDE_WRITE_PROCS)
+
+/* ************************************************************************** */
+/* ************************************************************************** */
+/* PNG chunks */
+
+MNG_LOCAL mng_field_descriptor mng_fields_ihdr [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_NOHIGHBIT,
+ 1, 0, 4, 4,
+ offsetof(mng_ihdr, iWidth), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_NOHIGHBIT,
+ 1, 0, 4, 4,
+ offsetof(mng_ihdr, iHeight), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 1, 16, 1, 1,
+ offsetof(mng_ihdr, iBitdepth), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 6, 1, 1,
+ offsetof(mng_ihdr, iColortype), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 1, 1,
+ offsetof(mng_ihdr, iCompression), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 1, 1,
+ offsetof(mng_ihdr, iFilter), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 1, 1, 1,
+ offsetof(mng_ihdr, iInterlace), MNG_NULL, MNG_NULL}
+ };
+
+/* ************************************************************************** */
+
+MNG_LOCAL mng_field_descriptor mng_fields_plte [] =
+ {
+ {mng_debunk_plte,
+ MNG_NULL,
+ 0, 0, 0, 0,
+ MNG_NULL, MNG_NULL, MNG_NULL}
+ };
+
+/* ************************************************************************** */
+
+MNG_LOCAL mng_field_descriptor mng_fields_idat [] =
+ {
+ {MNG_NULL,
+ MNG_NULL,
+ 0, 0, 0, 0,
+ offsetof(mng_idat, pData), MNG_NULL, offsetof(mng_idat, iDatasize)}
+ };
+
+/* ************************************************************************** */
+
+MNG_LOCAL mng_field_descriptor mng_fields_trns [] =
+ {
+ {mng_debunk_trns,
+ MNG_NULL,
+ 0, 0, 0, 0,
+ MNG_NULL, MNG_NULL, MNG_NULL}
+ };
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_gAMA
+MNG_LOCAL mng_field_descriptor mng_fields_gama [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_gama, iGamma), MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_cHRM
+MNG_LOCAL mng_field_descriptor mng_fields_chrm [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_chrm, iWhitepointx), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_chrm, iWhitepointy), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_chrm, iRedx), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_chrm, iRedy), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_chrm, iGreeny), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_chrm, iGreeny), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_chrm, iBluex), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_chrm, iBluey), MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_sRGB
+MNG_LOCAL mng_field_descriptor mng_fields_srgb [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 4, 1, 1,
+ offsetof(mng_srgb, iRenderingintent), MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_iCCP
+MNG_LOCAL mng_field_descriptor mng_fields_iccp [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_TERMINATOR,
+ 0, 0, 1, 79,
+ offsetof(mng_iccp, zName), MNG_NULL, offsetof(mng_iccp, iNamesize)},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 1, 1,
+ offsetof(mng_iccp, iCompression), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_DEFLATED,
+ 0, 0, 0, 0,
+ offsetof(mng_iccp, pProfile), MNG_NULL, offsetof(mng_iccp, iProfilesize)}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_tEXt
+MNG_LOCAL mng_field_descriptor mng_fields_text [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_TERMINATOR,
+ 0, 0, 1, 79,
+ offsetof(mng_text, zKeyword), MNG_NULL, offsetof(mng_text, iKeywordsize)},
+ {MNG_NULL,
+ MNG_NULL,
+ 0, 0, 0, 0,
+ offsetof(mng_text, zText), MNG_NULL, offsetof(mng_text, iTextsize)}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_zTXt
+MNG_LOCAL mng_field_descriptor mng_fields_ztxt [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_TERMINATOR,
+ 0, 0, 1, 79,
+ offsetof(mng_ztxt, zKeyword), MNG_NULL, offsetof(mng_ztxt, iKeywordsize)},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 1, 1,
+ offsetof(mng_ztxt, iCompression), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_DEFLATED,
+ 0, 0, 0, 0,
+ offsetof(mng_ztxt, zText), MNG_NULL, offsetof(mng_ztxt, iTextsize)}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_iTXt
+MNG_LOCAL mng_field_descriptor mng_fields_itxt [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_TERMINATOR,
+ 0, 0, 1, 79,
+ offsetof(mng_itxt, zKeyword), MNG_NULL, offsetof(mng_itxt, iKeywordsize)},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 1, 1, 1,
+ offsetof(mng_itxt, iCompressionflag), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 1, 1,
+ offsetof(mng_itxt, iCompressionmethod), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_TERMINATOR,
+ 0, 0, 0, 0,
+ offsetof(mng_itxt, zLanguage), MNG_NULL, offsetof(mng_itxt, iLanguagesize)},
+ {MNG_NULL,
+ MNG_FIELD_TERMINATOR,
+ 0, 0, 0, 0,
+ offsetof(mng_itxt, zTranslation), MNG_NULL, offsetof(mng_itxt, iTranslationsize)},
+ {mng_deflate_itxt,
+ MNG_NULL,
+ 0, 0, 0, 0,
+ MNG_NULL, MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_bKGD
+MNG_LOCAL mng_field_descriptor mng_fields_bkgd [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_PUTIMGTYPE,
+ 0, 0, 0, 0,
+ offsetof(mng_bkgd, iType), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE3,
+ 0, 0xFF, 1, 1,
+ offsetof(mng_bkgd, iIndex), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE0 | MNG_FIELD_IFIMGTYPE4,
+ 0, 0xFFFF, 2, 2,
+ offsetof(mng_bkgd, iGray), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE2 | MNG_FIELD_IFIMGTYPE6,
+ 0, 0xFFFF, 2, 2,
+ offsetof(mng_bkgd, iRed), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE2 | MNG_FIELD_IFIMGTYPE6,
+ 0, 0xFFFF, 2, 2,
+ offsetof(mng_bkgd, iGreen), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE2 | MNG_FIELD_IFIMGTYPE6,
+ 0, 0xFFFF, 2, 2,
+ offsetof(mng_bkgd, iBlue), MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_pHYs
+MNG_LOCAL mng_field_descriptor mng_fields_phys [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_phys, iSizex), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_phys, iSizey), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 1, 1, 1,
+ offsetof(mng_phys, iUnit), MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_sBIT
+MNG_LOCAL mng_field_descriptor mng_fields_sbit [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_PUTIMGTYPE,
+ 0, 0, 0, 0,
+ offsetof(mng_sbit, iType), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_IFIMGTYPES,
+ 0, 0xFF, 1, 1,
+ offsetof(mng_sbit, aBits[0]), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE2 | MNG_FIELD_IFIMGTYPE3 | MNG_FIELD_IFIMGTYPE4 | MNG_FIELD_IFIMGTYPE6,
+ 0, 0xFF, 1, 1,
+ offsetof(mng_sbit, aBits[1]), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE2 | MNG_FIELD_IFIMGTYPE3 | MNG_FIELD_IFIMGTYPE6,
+ 0, 0xFF, 1, 1,
+ offsetof(mng_sbit, aBits[2]), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE6,
+ 0, 0xFF, 1, 1,
+ offsetof(mng_sbit, aBits[3]), MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_sPLT
+MNG_LOCAL mng_field_descriptor mng_fields_splt [] =
+ {
+ {MNG_NULL,
+ MNG_NULL,
+ 0, 0, 1, 79,
+ offsetof(mng_splt, zName), MNG_NULL, offsetof(mng_splt, iNamesize)},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 8, 16, 1, 1,
+ offsetof(mng_splt, iSampledepth), MNG_NULL, MNG_NULL},
+ {mng_splt_entries,
+ MNG_NULL,
+ 0, 0, 0, 0,
+ MNG_NULL, MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_hIST
+MNG_LOCAL mng_field_descriptor mng_fields_hist [] =
+ {
+ {mng_hist_entries,
+ MNG_NULL,
+ 0, 0, 0, 0,
+ MNG_NULL, MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_tIME
+MNG_LOCAL mng_field_descriptor mng_fields_time [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0xFFFF, 2, 2,
+ offsetof(mng_time, iYear), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 1, 12, 1, 1,
+ offsetof(mng_time, iMonth), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 1, 31, 1, 1,
+ offsetof(mng_time, iDay), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 24, 1, 1,
+ offsetof(mng_time, iHour), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 60, 1, 1,
+ offsetof(mng_time, iMinute), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 60, 1, 1,
+ offsetof(mng_time, iSecond), MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+/* ************************************************************************** */
+/* JNG chunks */
+
+#ifdef MNG_INCLUDE_JNG
+MNG_LOCAL mng_field_descriptor mng_fields_jhdr [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_NOHIGHBIT,
+ 1, 0, 4, 4,
+ offsetof(mng_jhdr, iWidth), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_NOHIGHBIT,
+ 1, 0, 4, 4,
+ offsetof(mng_jhdr, iHeight), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 8, 16, 1, 1,
+ offsetof(mng_jhdr, iColortype), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 8, 20, 1, 1,
+ offsetof(mng_jhdr, iImagesampledepth), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 8, 8, 1, 1,
+ offsetof(mng_jhdr, iImagecompression), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 8, 1, 1,
+ offsetof(mng_jhdr, iImageinterlace), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 16, 1, 1,
+ offsetof(mng_jhdr, iAlphasampledepth), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 8, 1, 1,
+ offsetof(mng_jhdr, iAlphacompression), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 1, 1,
+ offsetof(mng_jhdr, iAlphafilter), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 1, 1, 1,
+ offsetof(mng_jhdr, iAlphainterlace), MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifdef MNG_INCLUDE_JNG
+#define mng_fields_jdaa mng_fields_idat
+#define mng_fields_jdat mng_fields_idat
+#endif
+
+/* ************************************************************************** */
+/* ************************************************************************** */
+/* MNG chunks */
+
+MNG_LOCAL mng_field_descriptor mng_fields_mhdr [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_mhdr, iWidth), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_mhdr, iHeight), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_mhdr, iTicks), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_mhdr, iLayercount), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_mhdr, iFramecount), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_mhdr, iPlaytime), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_mhdr, iSimplicity), MNG_NULL, MNG_NULL}
+ };
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_LOOP
+MNG_LOCAL mng_field_descriptor mng_fields_loop [] =
+ {
+ {mng_debunk_loop,
+ MNG_NULL,
+ 0, 0, 0, 0,
+ MNG_NULL, MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_LOOP
+MNG_LOCAL mng_field_descriptor mng_fields_endl [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0xFF, 1, 1,
+ offsetof(mng_endl, iLevel), MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_DEFI
+MNG_LOCAL mng_field_descriptor mng_fields_defi [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0xFFFF, 2, 2,
+ offsetof(mng_defi, iObjectid), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
+ 0, 0xFF, 1, 1,
+ offsetof(mng_defi, iDonotshow), offsetof(mng_defi, bHasdonotshow), MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
+ 0, 0xFF, 1, 1,
+ offsetof(mng_defi, iConcrete), offsetof(mng_defi, bHasconcrete), MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
+ 0, 0, 4, 4,
+ offsetof(mng_defi, iXlocation), offsetof(mng_defi, bHasloca), MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
+ 0, 0, 4, 4,
+ offsetof(mng_defi, iYlocation), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP2,
+ 0, 0, 4, 4,
+ offsetof(mng_defi, iLeftcb), offsetof(mng_defi, bHasclip), MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP2,
+ 0, 0, 4, 4,
+ offsetof(mng_defi, iRightcb), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP2,
+ 0, 0, 4, 4,
+ offsetof(mng_defi, iTopcb), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP2,
+ 0, 0, 4, 4,
+ offsetof(mng_defi, iBottomcb), MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_BASI
+MNG_LOCAL mng_field_descriptor mng_fields_basi [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_basi, iWidth), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_basi, iHeight), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 1, 16, 1, 1,
+ offsetof(mng_basi, iBitdepth), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 6, 1, 1,
+ offsetof(mng_basi, iColortype), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 1, 1,
+ offsetof(mng_basi, iCompression), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 1, 1,
+ offsetof(mng_basi, iFilter), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 1, 1, 1,
+ offsetof(mng_basi, iInterlace), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
+ 0, 0xFFFF, 2, 2,
+ offsetof(mng_basi, iRed), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
+ 0, 0xFFFF, 2, 2,
+ offsetof(mng_basi, iGreen), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
+ 0, 0xFFFF, 2, 2,
+ offsetof(mng_basi, iBlue), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
+ 0, 0xFFFF, 2, 2,
+ offsetof(mng_basi, iAlpha), offsetof(mng_basi, bHasalpha), MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
+ 0, 1, 1, 1,
+ offsetof(mng_basi, iViewable), MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_CLON
+MNG_LOCAL mng_field_descriptor mng_fields_clon [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0xFFFF, 2, 2,
+ offsetof(mng_clon, iSourceid), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0xFFFF, 2, 2,
+ offsetof(mng_clon, iCloneid), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
+ 0, 2, 1, 1,
+ offsetof(mng_clon, iClonetype), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
+ 0, 1, 1, 1,
+ offsetof(mng_clon, iDonotshow), offsetof(mng_clon, bHasdonotshow), MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
+ 0, 1, 1, 1,
+ offsetof(mng_clon, iConcrete), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
+ 0, 2, 1, 1,
+ offsetof(mng_clon, iLocationtype), offsetof(mng_clon, bHasloca), MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
+ 0, 0, 4, 4,
+ offsetof(mng_clon, iLocationx), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
+ 0, 0, 4, 4,
+ offsetof(mng_clon, iLocationy), MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_PAST
+MNG_LOCAL mng_field_descriptor mng_fields_past [] =
+ {
+ {mng_debunk_past,
+ MNG_NULL,
+ 0, 0, 0, 0,
+ MNG_NULL, MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_DISC
+MNG_LOCAL mng_field_descriptor mng_fields_disc [] =
+ {
+ {mng_disc_entries,
+ MNG_NULL,
+ 0, 0, 0, 0,
+ MNG_NULL, MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_BACK
+MNG_LOCAL mng_field_descriptor mng_fields_back [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0xFFFF, 2, 2,
+ offsetof(mng_back, iRed), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0xFFFF, 2, 2,
+ offsetof(mng_back, iGreen), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0xFFFF, 2, 2,
+ offsetof(mng_back, iBlue), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
+ 0, 3, 1, 1,
+ offsetof(mng_back, iMandatory), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
+ 0, 0xFFFF, 2, 2,
+ offsetof(mng_back, iImageid), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
+ 0, 1, 1, 1,
+ offsetof(mng_back, iTile), MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_FRAM
+MNG_LOCAL mng_field_descriptor mng_fields_fram [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
+ 0, 4, 1, 1,
+ offsetof(mng_fram, iMode), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_TERMINATOR | MNG_FIELD_OPTIONAL,
+ 0, 0, 1, 79,
+ offsetof(mng_fram, zName), MNG_NULL, offsetof(mng_fram, iNamesize)},
+ {mng_fram_remainder,
+ MNG_FIELD_OPTIONAL,
+ 0, 0, 0, 0,
+ MNG_NULL, MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_MOVE
+MNG_LOCAL mng_field_descriptor mng_fields_move [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0xFFFF, 2, 2,
+ offsetof(mng_move, iFirstid), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0xFFFF, 2, 2,
+ offsetof(mng_move, iLastid), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 1, 1, 1,
+ offsetof(mng_move, iMovetype), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_move, iMovex), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_move, iMovey), MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_CLIP
+MNG_LOCAL mng_field_descriptor mng_fields_clip [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0xFFFF, 2, 2,
+ offsetof(mng_clip, iFirstid), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0xFFFF, 2, 2,
+ offsetof(mng_clip, iLastid), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 1, 1, 1,
+ offsetof(mng_clip, iCliptype), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_clip, iClipl), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_clip, iClipr), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_clip, iClipt), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_clip, iClipb), MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_SHOW
+MNG_LOCAL mng_field_descriptor mng_fields_show [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 1, 0xFFFF, 2, 2,
+ offsetof(mng_show, iFirstid), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
+ 1, 0xFFFF, 2, 2,
+ offsetof(mng_show, iLastid), offsetof(mng_show, bHaslastid), MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
+ 0, 7, 1, 1,
+ offsetof(mng_show, iMode), MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_TERM
+MNG_LOCAL mng_field_descriptor mng_fields_term [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 3, 1, 1,
+ offsetof(mng_term, iTermaction), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
+ 0, 2, 1, 1,
+ offsetof(mng_term, iIteraction), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
+ 0, 0, 4, 4,
+ offsetof(mng_term, iDelay), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
+ 0, 0, 4, 4,
+ offsetof(mng_term, iItermax), MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_SAVE
+MNG_LOCAL mng_field_descriptor mng_fields_save [] =
+ {
+ {mng_save_entries,
+ MNG_NULL,
+ 0, 0, 0, 0,
+ MNG_NULL, MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_SEEK
+MNG_LOCAL mng_field_descriptor mng_fields_seek [] =
+ {
+ {MNG_NULL,
+ MNG_NULL,
+ 0, 0, 1, 79,
+ offsetof(mng_seek, zName), MNG_NULL, offsetof(mng_seek, iNamesize)}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_eXPI
+MNG_LOCAL mng_field_descriptor mng_fields_expi [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0xFFFF, 2, 2,
+ offsetof(mng_expi, iSnapshotid), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_NULL,
+ 0, 0, 1, 79,
+ offsetof(mng_expi, zName), MNG_NULL, offsetof(mng_expi, iNamesize)}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_fPRI
+MNG_LOCAL mng_field_descriptor mng_fields_fpri [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 1, 1, 1,
+ offsetof(mng_fpri, iDeltatype), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0xFF, 1, 1,
+ offsetof(mng_fpri, iPriority), MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_nEED
+MNG_LOCAL mng_field_descriptor mng_fields_need [] =
+ {
+ {MNG_NULL,
+ MNG_NULL,
+ 0, 0, 1, 0,
+ offsetof(mng_need, zKeywords), MNG_NULL, offsetof(mng_need, iKeywordssize)}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_pHYg
+#define mng_fields_phyg mng_fields_phys
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_NO_DELTA_PNG
+MNG_LOCAL mng_field_descriptor mng_fields_dhdr [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0xFFFF, 2, 2,
+ offsetof(mng_dhdr, iObjectid), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 2, 1, 1,
+ offsetof(mng_dhdr, iImagetype), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 7, 1, 1,
+ offsetof(mng_dhdr, iDeltatype), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
+ 0, 0, 4, 4,
+ offsetof(mng_dhdr, iBlockwidth), offsetof(mng_dhdr, bHasblocksize), MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
+ 0, 0, 4, 4,
+ offsetof(mng_dhdr, iBlockheight), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP2,
+ 0, 0, 4, 4,
+ offsetof(mng_dhdr, iBlockx), offsetof(mng_dhdr, bHasblockloc), MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP2,
+ 0, 0, 4, 4,
+ offsetof(mng_dhdr, iBlocky), MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_NO_DELTA_PNG
+MNG_LOCAL mng_field_descriptor mng_fields_prom [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 14, 1, 1,
+ offsetof(mng_prom, iColortype), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 16, 1, 1,
+ offsetof(mng_prom, iSampledepth), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 1, 1, 1,
+ offsetof(mng_prom, iFilltype), MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_NO_DELTA_PNG
+MNG_LOCAL mng_field_descriptor mng_fields_pplt [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 5, 1, 1,
+ offsetof(mng_pplt, iDeltatype), MNG_NULL, MNG_NULL},
+ {mng_pplt_entries,
+ MNG_NULL,
+ 0, 0, 0, 0,
+ MNG_NULL, MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_NO_DELTA_PNG
+MNG_LOCAL mng_field_descriptor mng_fields_drop [] =
+ {
+ {mng_drop_entries,
+ MNG_NULL,
+ 0, 0, 0, 0,
+ MNG_NULL, MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_NO_DELTA_PNG
+#ifndef MNG_SKIPCHUNK_DBYK
+MNG_LOCAL mng_field_descriptor mng_fields_dbyk [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_dbyk, iChunkname), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 1, 1, 1,
+ offsetof(mng_dbyk, iPolarity), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_NULL,
+ 0, 0, 1, 0,
+ offsetof(mng_dbyk, zKeywords), MNG_NULL, offsetof(mng_dbyk, iKeywordssize)}
+ };
+#endif
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_NO_DELTA_PNG
+#ifndef MNG_SKIPCHUNK_ORDR
+MNG_LOCAL mng_field_descriptor mng_fields_ordr [] =
+ {
+ {mng_drop_entries,
+ MNG_NULL,
+ 0, 0, 0, 0,
+ MNG_NULL, MNG_NULL, MNG_NULL}
+ };
+#endif
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_MAGN
+MNG_LOCAL mng_field_descriptor mng_fields_magn [] =
+ {
+ {mng_debunk_magn,
+ MNG_NULL,
+ 0, 0, 0, 0,
+ MNG_NULL, MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifdef MNG_INCLUDE_MPNG_PROPOSAL
+MNG_LOCAL mng_field_descriptor mng_fields_mpng [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 1, 0, 4, 4,
+ offsetof(mng_mpng, iFramewidth), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 1, 0, 4, 4,
+ offsetof(mng_mpng, iFrameheight), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0xFFFF, 2, 2,
+ offsetof(mng_mpng, iNumplays), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 1, 0xFFFF, 2, 2,
+ offsetof(mng_mpng, iTickspersec), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 1, 1,
+ offsetof(mng_mpng, iCompressionmethod), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_DEFLATED,
+ 0, 0, 1, 0,
+ offsetof(mng_mpng, pFrames), MNG_NULL, offsetof(mng_mpng, iFramessize)}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifdef MNG_INCLUDE_ANG_PROPOSAL
+MNG_LOCAL mng_field_descriptor mng_fields_ahdr [] =
+ {
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 1, 0, 4, 4,
+ offsetof(mng_ahdr, iNumframes), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_ahdr, iTickspersec), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 0, 4, 4,
+ offsetof(mng_ahdr, iNumplays), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 1, 0, 4, 4,
+ offsetof(mng_ahdr, iTilewidth), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 1, 0, 4, 4,
+ offsetof(mng_ahdr, iTileheight), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 1, 1, 1,
+ offsetof(mng_ahdr, iInterlace), MNG_NULL, MNG_NULL},
+ {MNG_NULL,
+ MNG_FIELD_INT,
+ 0, 1, 1, 1,
+ offsetof(mng_ahdr, iStillused), MNG_NULL, MNG_NULL}
+ };
+
+MNG_LOCAL mng_field_descriptor mng_fields_adat [] =
+ {
+ {mng_adat_tiles,
+ MNG_NULL,
+ 0, 0, 0, 0,
+ MNG_NULL, MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_evNT
+MNG_LOCAL mng_field_descriptor mng_fields_evnt [] =
+ {
+ {mng_evnt_entries,
+ MNG_NULL,
+ 0, 0, 0, 0,
+ MNG_NULL, MNG_NULL, MNG_NULL}
+ };
+#endif
+
+/* ************************************************************************** */
+
+MNG_LOCAL mng_field_descriptor mng_fields_unknown [] =
+ {
+ {MNG_NULL,
+ MNG_NULL,
+ 0, 0, 1, 0,
+ offsetof(mng_unknown_chunk, pData), MNG_NULL, offsetof(mng_unknown_chunk, iDatasize)}
+ };
+
+/* ************************************************************************** */
+/* ************************************************************************** */
+/* PNG chunks */
+
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_ihdr =
+ {mng_it_png, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_ihdr,
+ mng_fields_ihdr, (sizeof(mng_fields_ihdr) / sizeof(mng_field_descriptor)),
+ MNG_DESCR_GLOBAL,
+ MNG_NULL,
+ MNG_DESCR_NOIHDR | MNG_DESCR_NOJHDR | MNG_DESCR_NOBASI | MNG_DESCR_NOIDAT | MNG_DESCR_NOPLTE};
+
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_plte =
+ {mng_it_png, mng_create_none, 0, offsetof(mng_plte, bEmpty),
+ MNG_NULL, MNG_NULL, mng_special_plte,
+ mng_fields_plte, (sizeof(mng_fields_plte) / sizeof(mng_field_descriptor)),
+ MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED,
+ MNG_DESCR_GenHDR,
+ MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA};
+
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_idat =
+ {mng_it_png, mng_create_none, 0, offsetof(mng_idat, bEmpty),
+ MNG_NULL, MNG_NULL, mng_special_idat,
+ mng_fields_idat, (sizeof(mng_fields_idat) / sizeof(mng_field_descriptor)),
+ MNG_DESCR_EMPTYEMBED,
+ MNG_DESCR_GenHDR,
+ MNG_DESCR_NOJSEP};
+
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_iend =
+ {mng_it_png, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_iend,
+ MNG_NULL, 0,
+ MNG_DESCR_EMPTY | MNG_DESCR_EMPTYEMBED,
+ MNG_DESCR_GenHDR,
+ MNG_NULL};
+
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_trns =
+ {mng_it_png, mng_create_none, 0, offsetof(mng_trns, bEmpty),
+ MNG_NULL, MNG_NULL, mng_special_trns,
+ mng_fields_trns, (sizeof(mng_fields_trns) / sizeof(mng_field_descriptor)),
+ MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED,
+ MNG_DESCR_GenHDR,
+ MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA};
+
+#ifndef MNG_SKIPCHUNK_gAMA
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_gama =
+ {mng_it_png, mng_create_none, 0, offsetof(mng_gama, bEmpty),
+ MNG_NULL, MNG_NULL, mng_special_gama,
+ mng_fields_gama, (sizeof(mng_fields_gama) / sizeof(mng_field_descriptor)),
+ MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED | MNG_DESCR_EMPTYGLOBAL,
+ MNG_DESCR_GenHDR,
+ MNG_DESCR_NOPLTE | MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA};
+#endif
+
+#ifndef MNG_SKIPCHUNK_cHRM
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_chrm =
+ {mng_it_png, mng_create_none, 0, offsetof(mng_chrm, bEmpty),
+ MNG_NULL, MNG_NULL, mng_special_chrm,
+ mng_fields_chrm, (sizeof(mng_fields_chrm) / sizeof(mng_field_descriptor)),
+ MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED | MNG_DESCR_EMPTYGLOBAL,
+ MNG_DESCR_GenHDR,
+ MNG_DESCR_NOPLTE | MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA};
+#endif
+
+#ifndef MNG_SKIPCHUNK_sRGB
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_srgb =
+ {mng_it_png, mng_create_none, 0, offsetof(mng_srgb, bEmpty),
+ MNG_NULL, MNG_NULL, mng_special_srgb,
+ mng_fields_srgb, (sizeof(mng_fields_srgb) / sizeof(mng_field_descriptor)),
+ MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED | MNG_DESCR_EMPTYGLOBAL,
+ MNG_DESCR_GenHDR,
+ MNG_DESCR_NOPLTE | MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA};
+#endif
+
+#ifndef MNG_SKIPCHUNK_iCCP
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_iccp =
+ {mng_it_png, mng_create_none, 0, offsetof(mng_iccp, bEmpty),
+ MNG_NULL, MNG_NULL, mng_special_iccp,
+ mng_fields_iccp, (sizeof(mng_fields_iccp) / sizeof(mng_field_descriptor)),
+ MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED | MNG_DESCR_EMPTYGLOBAL,
+ MNG_DESCR_GenHDR,
+ MNG_DESCR_NOPLTE | MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA};
+#endif
+
+#ifndef MNG_SKIPCHUNK_tEXt
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_text =
+ {mng_it_png, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_text,
+ mng_fields_text, (sizeof(mng_fields_text) / sizeof(mng_field_descriptor)),
+ MNG_DESCR_GLOBAL,
+ MNG_DESCR_GenHDR,
+ MNG_NULL};
+#endif
+
+#ifndef MNG_SKIPCHUNK_zTXt
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_ztxt =
+ {mng_it_png, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_ztxt,
+ mng_fields_ztxt, (sizeof(mng_fields_ztxt) / sizeof(mng_field_descriptor)),
+ MNG_DESCR_GLOBAL,
+ MNG_DESCR_GenHDR,
+ MNG_NULL};
+#endif
+
+#ifndef MNG_SKIPCHUNK_iTXt
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_itxt =
+ {mng_it_png, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_itxt,
+ mng_fields_itxt, (sizeof(mng_fields_itxt) / sizeof(mng_field_descriptor)),
+ MNG_DESCR_GLOBAL,
+ MNG_DESCR_GenHDR,
+ MNG_NULL};
+#endif
+
+#ifndef MNG_SKIPCHUNK_bKGD
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_bkgd =
+ {mng_it_png, mng_create_none, 0, offsetof(mng_bkgd, bEmpty),
+ MNG_NULL, MNG_NULL, mng_special_bkgd,
+ mng_fields_bkgd, (sizeof(mng_fields_bkgd) / sizeof(mng_field_descriptor)),
+ MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED | MNG_DESCR_EMPTYGLOBAL,
+ MNG_DESCR_GenHDR,
+ MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA};
+#endif
+
+#ifndef MNG_SKIPCHUNK_pHYs
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_phys =
+ {mng_it_png, mng_create_none, 0, offsetof(mng_phys, bEmpty),
+ MNG_NULL, MNG_NULL, mng_special_phys,
+ mng_fields_phys, (sizeof(mng_fields_phys) / sizeof(mng_field_descriptor)),
+ MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED | MNG_DESCR_EMPTYGLOBAL,
+ MNG_DESCR_GenHDR,
+ MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA};
+#endif
+
+#ifndef MNG_SKIPCHUNK_sBIT
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_sbit =
+ {mng_it_png, mng_create_none, 0, offsetof(mng_sbit, bEmpty),
+ MNG_NULL, MNG_NULL, mng_special_sbit,
+ mng_fields_sbit, (sizeof(mng_fields_sbit) / sizeof(mng_field_descriptor)),
+ MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED | MNG_DESCR_EMPTYGLOBAL,
+ MNG_DESCR_GenHDR,
+ MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA};
+#endif
+
+#ifndef MNG_SKIPCHUNK_sPLT
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_splt =
+ {mng_it_png, mng_create_none, 0, offsetof(mng_splt, bEmpty),
+ MNG_NULL, MNG_NULL, mng_special_splt,
+ mng_fields_splt, (sizeof(mng_fields_splt) / sizeof(mng_field_descriptor)),
+ MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED | MNG_DESCR_EMPTYGLOBAL,
+ MNG_DESCR_GenHDR,
+ MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA};
+#endif
+
+#ifndef MNG_SKIPCHUNK_hIST
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_hist =
+ {mng_it_png, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_hist,
+ mng_fields_hist, (sizeof(mng_fields_hist) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_GenHDR | MNG_DESCR_PLTE,
+ MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA};
+#endif
+
+#ifndef MNG_SKIPCHUNK_tIME
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_time =
+ {mng_it_png, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_time,
+ mng_fields_time, (sizeof(mng_fields_time) / sizeof(mng_field_descriptor)),
+ MNG_DESCR_GLOBAL,
+ MNG_DESCR_GenHDR,
+ MNG_NULL};
+#endif
+
+/* ************************************************************************** */
+/* JNG chunks */
+
+#ifdef MNG_INCLUDE_JNG
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_jhdr =
+ {mng_it_jng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_jhdr,
+ mng_fields_jhdr, (sizeof(mng_fields_jhdr) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_NULL,
+ MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
+#endif
+
+#ifdef MNG_INCLUDE_JNG
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_jdaa =
+ {mng_it_jng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_jdaa,
+ mng_fields_jdaa, (sizeof(mng_fields_jdaa) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_JngHDR,
+ MNG_DESCR_NOJSEP};
+#endif
+
+#ifdef MNG_INCLUDE_JNG
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_jdat =
+ {mng_it_jng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_jdat,
+ mng_fields_jdat, (sizeof(mng_fields_jdat) / sizeof(mng_field_descriptor)),
+ MNG_DESCR_EMPTYEMBED,
+ MNG_DESCR_JngHDR,
+ MNG_NULL};
+#endif
+
+#ifdef MNG_INCLUDE_JNG
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_jsep =
+ {mng_it_jng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_jsep,
+ MNG_NULL, 0,
+ MNG_DESCR_EMPTY | MNG_DESCR_EMPTYEMBED,
+ MNG_DESCR_JngHDR,
+ MNG_DESCR_NOJSEP};
+#endif
+
+/* ************************************************************************** */
+/* MNG chunks */
+
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_mhdr =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_mhdr,
+ mng_fields_mhdr, (sizeof(mng_fields_mhdr) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_NULL,
+ MNG_DESCR_NOMHDR | MNG_DESCR_NOIHDR | MNG_DESCR_NOJHDR};
+
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_mend =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_mend,
+ MNG_NULL, 0,
+ MNG_DESCR_EMPTY | MNG_DESCR_EMPTYGLOBAL,
+ MNG_DESCR_MHDR,
+ MNG_NULL};
+
+#ifndef MNG_SKIPCHUNK_LOOP
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_loop =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_loop,
+ mng_fields_loop, (sizeof(mng_fields_loop) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_MHDR,
+ MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
+
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_endl =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_endl,
+ mng_fields_endl, (sizeof(mng_fields_endl) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_MHDR,
+ MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
+#endif
+
+#ifndef MNG_SKIPCHUNK_DEFI
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_defi =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_defi,
+ mng_fields_defi, (sizeof(mng_fields_defi) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_MHDR,
+ MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
+#endif
+
+#ifndef MNG_SKIPCHUNK_BASI
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_basi =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_basi,
+ mng_fields_basi, (sizeof(mng_fields_basi) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_MHDR,
+ MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
+#endif
+
+#ifndef MNG_SKIPCHUNK_CLON
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_clon =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_clon,
+ mng_fields_clon, (sizeof(mng_fields_clon) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_MHDR,
+ MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
+#endif
+
+#ifndef MNG_SKIPCHUNK_PAST
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_past =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_past,
+ mng_fields_past, (sizeof(mng_fields_past) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_MHDR,
+ MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
+#endif
+
+#ifndef MNG_SKIPCHUNK_DISC
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_disc =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_disc,
+ mng_fields_disc, (sizeof(mng_fields_disc) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_MHDR,
+ MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
+#endif
+
+#ifndef MNG_SKIPCHUNK_BACK
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_back =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_back,
+ mng_fields_back, (sizeof(mng_fields_back) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_MHDR,
+ MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
+#endif
+
+#ifndef MNG_SKIPCHUNK_FRAM
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_fram =
+ {mng_it_mng, mng_create_none, 0, offsetof(mng_fram, bEmpty),
+ MNG_NULL, MNG_NULL, mng_special_fram,
+ mng_fields_fram, (sizeof(mng_fields_fram) / sizeof(mng_field_descriptor)),
+ MNG_DESCR_EMPTY | MNG_DESCR_EMPTYGLOBAL,
+ MNG_DESCR_MHDR,
+ MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
+#endif
+
+#ifndef MNG_SKIPCHUNK_MOVE
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_move =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_move,
+ mng_fields_move, (sizeof(mng_fields_move) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_MHDR,
+ MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
+#endif
+
+#ifndef MNG_SKIPCHUNK_CLIP
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_clip =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_clip,
+ mng_fields_clip, (sizeof(mng_fields_clip) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_MHDR,
+ MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
+#endif
+
+#ifndef MNG_SKIPCHUNK_SHOW
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_show =
+ {mng_it_mng, mng_create_none, 0, offsetof(mng_show, bEmpty),
+ MNG_NULL, MNG_NULL, mng_special_show,
+ mng_fields_show, (sizeof(mng_fields_show) / sizeof(mng_field_descriptor)),
+ MNG_DESCR_EMPTY | MNG_DESCR_EMPTYGLOBAL,
+ MNG_DESCR_MHDR,
+ MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
+#endif
+
+#ifndef MNG_SKIPCHUNK_TERM
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_term =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_term,
+ mng_fields_term, (sizeof(mng_fields_term) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_MHDR,
+ MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR | MNG_DESCR_NOTERM | MNG_DESCR_NOLOOP};
+#endif
+
+#ifndef MNG_SKIPCHUNK_SAVE
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_save =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_save,
+ mng_fields_save, (sizeof(mng_fields_save) / sizeof(mng_field_descriptor)),
+ MNG_DESCR_EMPTY | MNG_DESCR_EMPTYGLOBAL,
+ MNG_DESCR_MHDR,
+ MNG_DESCR_NOSAVE | MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
+#endif
+
+#ifndef MNG_SKIPCHUNK_SEEK
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_seek =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_seek,
+ mng_fields_seek, (sizeof(mng_fields_seek) / sizeof(mng_field_descriptor)),
+ MNG_DESCR_EMPTY | MNG_DESCR_EMPTYGLOBAL,
+ MNG_DESCR_MHDR | MNG_DESCR_SAVE,
+ MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
+#endif
+
+#ifndef MNG_SKIPCHUNK_eXPI
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_expi =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_expi,
+ mng_fields_expi, (sizeof(mng_fields_expi) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_MHDR,
+ MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
+#endif
+
+#ifndef MNG_SKIPCHUNK_fPRI
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_fpri =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_fpri,
+ mng_fields_fpri, (sizeof(mng_fields_fpri) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_MHDR,
+ MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
+#endif
+
+#ifndef MNG_SKIPCHUNK_nEED
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_need =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_need,
+ mng_fields_need, (sizeof(mng_fields_need) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_MHDR,
+ MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
+#endif
+
+#ifndef MNG_SKIPCHUNK_pHYg
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_phyg =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_phyg,
+ mng_fields_phyg, (sizeof(mng_fields_phyg) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_MHDR,
+ MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
+#endif
+
+#ifndef MNG_NO_DELTA_PNG
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_dhdr =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_dhdr,
+ mng_fields_dhdr, (sizeof(mng_fields_dhdr) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_MHDR,
+ MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
+#endif
+
+#ifndef MNG_NO_DELTA_PNG
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_prom =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_prom,
+ mng_fields_prom, (sizeof(mng_fields_prom) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_MHDR | MNG_DESCR_DHDR,
+ MNG_NULL};
+#endif
+
+#ifndef MNG_NO_DELTA_PNG
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_ipng =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_ipng,
+ MNG_NULL, 0,
+ MNG_DESCR_EMPTY | MNG_DESCR_EMPTYEMBED,
+ MNG_DESCR_MHDR | MNG_DESCR_DHDR,
+ MNG_NULL};
+#endif
+
+#ifndef MNG_NO_DELTA_PNG
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_pplt =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_pplt,
+ mng_fields_pplt, (sizeof(mng_fields_pplt) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_MHDR | MNG_DESCR_DHDR,
+ MNG_NULL};
+#endif
+
+#ifndef MNG_NO_DELTA_PNG
+#ifdef MNG_INCLUDE_JNG
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_ijng =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_ijng,
+ MNG_NULL, 0,
+ MNG_DESCR_EMPTY | MNG_DESCR_EMPTYEMBED,
+ MNG_DESCR_MHDR | MNG_DESCR_DHDR,
+ MNG_NULL};
+#endif
+#endif
+
+#ifndef MNG_NO_DELTA_PNG
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_drop =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_drop,
+ mng_fields_drop, (sizeof(mng_fields_drop) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_MHDR | MNG_DESCR_DHDR,
+ MNG_NULL};
+#endif
+
+#ifndef MNG_NO_DELTA_PNG
+#ifndef MNG_SKIPCHUNK_DBYK
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_dbyk =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_dbyk,
+ mng_fields_dbyk, (sizeof(mng_fields_dbyk) / sizeof(mng_field_descriptor)),
+ MNG_DESCR_EMPTY | MNG_DESCR_EMPTYEMBED,
+ MNG_DESCR_MHDR | MNG_DESCR_DHDR,
+ MNG_NULL};
+#endif
+#endif
+
+#ifndef MNG_NO_DELTA_PNG
+#ifndef MNG_SKIPCHUNK_ORDR
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_ordr =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_ordr,
+ mng_fields_ordr, (sizeof(mng_fields_ordr) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_MHDR | MNG_DESCR_DHDR,
+ MNG_NULL};
+#endif
+#endif
+
+#ifndef MNG_SKIPCHUNK_MAGN
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_magn =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_magn,
+ mng_fields_magn, (sizeof(mng_fields_magn) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_MHDR,
+ MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
+#endif
+
+#ifndef MNG_SKIPCHUNK_evNT
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_evnt =
+ {mng_it_mng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_evnt,
+ mng_fields_evnt, (sizeof(mng_fields_evnt) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_MHDR,
+ MNG_DESCR_NOSAVE};
+#endif
+
+#ifdef MNG_INCLUDE_MPNG_PROPOSAL
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_mpng =
+ {mng_it_mpng, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_mpng,
+ mng_fields_mpng, (sizeof(mng_fields_mpng) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_NULL,
+ MNG_DESCR_NOMHDR | MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT};
+#endif
+
+#ifdef MNG_INCLUDE_ANG_PROPOSAL
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_ahdr =
+ {mng_it_ang, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_ahdr,
+ mng_fields_ahdr, (sizeof(mng_fields_ahdr) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_IHDR,
+ MNG_DESCR_NOMHDR | MNG_DESCR_NOJHDR | MNG_DESCR_NOIDAT};
+
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_adat =
+ {mng_it_ang, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_adat,
+ mng_fields_adat, (sizeof(mng_fields_adat) / sizeof(mng_field_descriptor)),
+ MNG_NULL,
+ MNG_DESCR_IHDR,
+ MNG_DESCR_NOMHDR | MNG_DESCR_NOJHDR};
+#endif
+
+/* ************************************************************************** */
+/* ************************************************************************** */
+/* the good ol' unknown babe */
+
+MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_unknown =
+ {mng_it_png, mng_create_none, 0, 0,
+ MNG_NULL, MNG_NULL, mng_special_unknown,
+ mng_fields_unknown, (sizeof(mng_fields_unknown) / sizeof(mng_field_descriptor)),
+ MNG_DESCR_EMPTY | MNG_DESCR_EMPTYEMBED,
+ MNG_NULL,
+ MNG_NULL};
+
+/* ************************************************************************** */
+/* ************************************************************************** */
+
+MNG_LOCAL mng_chunk_header mng_chunk_unknown =
+ {MNG_UINT_HUH, mng_init_general, mng_free_unknown,
+ mng_read_general, mng_write_unknown, mng_assign_unknown,
+ 0, 0, sizeof(mng_unknown_chunk), &mng_chunk_descr_unknown};
+
+/* ************************************************************************** */
+
+ /* the table-idea & binary search code was adapted from
+ libpng 1.1.0 (pngread.c) */
+ /* NOTE1: the table must remain sorted by chunkname, otherwise the binary
+ search will break !!! (ps. watch upper-/lower-case chunknames !!) */
+ /* NOTE2: the layout must remain equal to the header part of all the
+ chunk-structures (yes, that means even the pNext and pPrev fields;
+ it's wasting a bit of space, but hey, the code is a lot easier) */
+
+MNG_LOCAL mng_chunk_header mng_chunk_table [] =
+ {
+#ifndef MNG_SKIPCHUNK_BACK
+ {MNG_UINT_BACK, mng_init_general, mng_free_general, mng_read_general, mng_write_back, mng_assign_general, 0, 0, sizeof(mng_back), &mng_chunk_descr_back},
+#endif
+#ifndef MNG_SKIPCHUNK_BASI
+ {MNG_UINT_BASI, mng_init_general, mng_free_general, mng_read_general, mng_write_basi, mng_assign_general, 0, 0, sizeof(mng_basi), &mng_chunk_descr_basi},
+#endif
+#ifndef MNG_SKIPCHUNK_CLIP
+ {MNG_UINT_CLIP, mng_init_general, mng_free_general, mng_read_general, mng_write_clip, mng_assign_general, 0, 0, sizeof(mng_clip), &mng_chunk_descr_clip},
+#endif
+#ifndef MNG_SKIPCHUNK_CLON
+ {MNG_UINT_CLON, mng_init_general, mng_free_general, mng_read_general, mng_write_clon, mng_assign_general, 0, 0, sizeof(mng_clon), &mng_chunk_descr_clon},
+#endif
+#ifndef MNG_NO_DELTA_PNG
+#ifndef MNG_SKIPCHUNK_DBYK
+ {MNG_UINT_DBYK, mng_init_general, mng_free_dbyk, mng_read_general, mng_write_dbyk, mng_assign_dbyk, 0, 0, sizeof(mng_dbyk), &mng_chunk_descr_dbyk},
+#endif
+#endif
+#ifndef MNG_SKIPCHUNK_DEFI
+ {MNG_UINT_DEFI, mng_init_general, mng_free_general, mng_read_general, mng_write_defi, mng_assign_general, 0, 0, sizeof(mng_defi), &mng_chunk_descr_defi},
+#endif
+#ifndef MNG_NO_DELTA_PNG
+ {MNG_UINT_DHDR, mng_init_general, mng_free_general, mng_read_general, mng_write_dhdr, mng_assign_general, 0, 0, sizeof(mng_dhdr), &mng_chunk_descr_dhdr},
+#endif
+#ifndef MNG_SKIPCHUNK_DISC
+ {MNG_UINT_DISC, mng_init_general, mng_free_disc, mng_read_general, mng_write_disc, mng_assign_disc, 0, 0, sizeof(mng_disc), &mng_chunk_descr_disc},
+#endif
+#ifndef MNG_NO_DELTA_PNG
+#ifndef MNG_SKIPCHUNK_DROP
+ {MNG_UINT_DROP, mng_init_general, mng_free_drop, mng_read_general, mng_write_drop, mng_assign_drop, 0, 0, sizeof(mng_drop), &mng_chunk_descr_drop},
+#endif
+#endif
+#ifndef MNG_SKIPCHUNK_LOOP
+ {MNG_UINT_ENDL, mng_init_general, mng_free_general, mng_read_general, mng_write_endl, mng_assign_general, 0, 0, sizeof(mng_endl), &mng_chunk_descr_endl},
+#endif
+#ifndef MNG_SKIPCHUNK_FRAM
+ {MNG_UINT_FRAM, mng_init_general, mng_free_fram, mng_read_general, mng_write_fram, mng_assign_fram, 0, 0, sizeof(mng_fram), &mng_chunk_descr_fram},
+#endif
+ {MNG_UINT_IDAT, mng_init_general, mng_free_idat, mng_read_general, mng_write_idat, mng_assign_idat, 0, 0, sizeof(mng_idat), &mng_chunk_descr_idat}, /* 12-th element! */
+ {MNG_UINT_IEND, mng_init_general, mng_free_general, mng_read_general, mng_write_iend, mng_assign_general, 0, 0, sizeof(mng_iend), &mng_chunk_descr_iend},
+ {MNG_UINT_IHDR, mng_init_general, mng_free_general, mng_read_general, mng_write_ihdr, mng_assign_general, 0, 0, sizeof(mng_ihdr), &mng_chunk_descr_ihdr},
+#ifndef MNG_NO_DELTA_PNG
+#ifdef MNG_INCLUDE_JNG
+ {MNG_UINT_IJNG, mng_init_general, mng_free_general, mng_read_general, mng_write_ijng, mng_assign_general, 0, 0, sizeof(mng_ijng), &mng_chunk_descr_ijng},
+#endif
+ {MNG_UINT_IPNG, mng_init_general, mng_free_general, mng_read_general, mng_write_ipng, mng_assign_general, 0, 0, sizeof(mng_ipng), &mng_chunk_descr_ipng},
+#endif
+#ifdef MNG_INCLUDE_JNG
+ {MNG_UINT_JDAA, mng_init_general, mng_free_jdaa, mng_read_general, mng_write_jdaa, mng_assign_jdaa, 0, 0, sizeof(mng_jdaa), &mng_chunk_descr_jdaa},
+ {MNG_UINT_JDAT, mng_init_general, mng_free_jdat, mng_read_general, mng_write_jdat, mng_assign_jdat, 0, 0, sizeof(mng_jdat), &mng_chunk_descr_jdat},
+ {MNG_UINT_JHDR, mng_init_general, mng_free_general, mng_read_general, mng_write_jhdr, mng_assign_general, 0, 0, sizeof(mng_jhdr), &mng_chunk_descr_jhdr},
+ {MNG_UINT_JSEP, mng_init_general, mng_free_general, mng_read_general, mng_write_jsep, mng_assign_general, 0, 0, sizeof(mng_jsep), &mng_chunk_descr_jsep},
+ {MNG_UINT_JdAA, mng_init_general, mng_free_jdaa, mng_read_general, mng_write_jdaa, mng_assign_jdaa, 0, 0, sizeof(mng_jdaa), &mng_chunk_descr_jdaa},
+#endif
+#ifndef MNG_SKIPCHUNK_LOOP
+ {MNG_UINT_LOOP, mng_init_general, mng_free_loop, mng_read_general, mng_write_loop, mng_assign_loop, 0, 0, sizeof(mng_loop), &mng_chunk_descr_loop},
+#endif
+#ifndef MNG_SKIPCHUNK_MAGN
+ {MNG_UINT_MAGN, mng_init_general, mng_free_general, mng_read_general, mng_write_magn, mng_assign_general, 0, 0, sizeof(mng_magn), &mng_chunk_descr_magn},
+#endif
+ {MNG_UINT_MEND, mng_init_general, mng_free_general, mng_read_general, mng_write_mend, mng_assign_general, 0, 0, sizeof(mng_mend), &mng_chunk_descr_mend},
+ {MNG_UINT_MHDR, mng_init_general, mng_free_general, mng_read_general, mng_write_mhdr, mng_assign_general, 0, 0, sizeof(mng_mhdr), &mng_chunk_descr_mhdr},
+#ifndef MNG_SKIPCHUNK_MOVE
+ {MNG_UINT_MOVE, mng_init_general, mng_free_general, mng_read_general, mng_write_move, mng_assign_general, 0, 0, sizeof(mng_move), &mng_chunk_descr_move},
+#endif
+#ifndef MNG_NO_DELTA_PNG
+#ifndef MNG_SKIPCHUNK_ORDR
+ {MNG_UINT_ORDR, mng_init_general, mng_free_ordr, mng_read_general, mng_write_ordr, mng_assign_ordr, 0, 0, sizeof(mng_ordr), &mng_chunk_descr_ordr},
+#endif
+#endif
+#ifndef MNG_SKIPCHUNK_PAST
+ {MNG_UINT_PAST, mng_init_general, mng_free_past, mng_read_general, mng_write_past, mng_assign_past, 0, 0, sizeof(mng_past), &mng_chunk_descr_past},
+#endif
+ {MNG_UINT_PLTE, mng_init_general, mng_free_general, mng_read_general, mng_write_plte, mng_assign_general, 0, 0, sizeof(mng_plte), &mng_chunk_descr_plte},
+#ifndef MNG_NO_DELTA_PNG
+ {MNG_UINT_PPLT, mng_init_general, mng_free_general, mng_read_general, mng_write_pplt, mng_assign_general, 0, 0, sizeof(mng_pplt), &mng_chunk_descr_pplt},
+ {MNG_UINT_PROM, mng_init_general, mng_free_general, mng_read_general, mng_write_prom, mng_assign_general, 0, 0, sizeof(mng_prom), &mng_chunk_descr_prom},
+#endif
+#ifndef MNG_SKIPCHUNK_SAVE
+ {MNG_UINT_SAVE, mng_init_general, mng_free_save, mng_read_general, mng_write_save, mng_assign_save, 0, 0, sizeof(mng_save), &mng_chunk_descr_save},
+#endif
+#ifndef MNG_SKIPCHUNK_SEEK
+ {MNG_UINT_SEEK, mng_init_general, mng_free_seek, mng_read_general, mng_write_seek, mng_assign_seek, 0, 0, sizeof(mng_seek), &mng_chunk_descr_seek},
+#endif
+#ifndef MNG_SKIPCHUNK_SHOW
+ {MNG_UINT_SHOW, mng_init_general, mng_free_general, mng_read_general, mng_write_show, mng_assign_general, 0, 0, sizeof(mng_show), &mng_chunk_descr_show},
+#endif
+#ifndef MNG_SKIPCHUNK_TERM
+ {MNG_UINT_TERM, mng_init_general, mng_free_general, mng_read_general, mng_write_term, mng_assign_general, 0, 0, sizeof(mng_term), &mng_chunk_descr_term},
+#endif
+#ifdef MNG_INCLUDE_ANG_PROPOSAL
+ {MNG_UINT_adAT, mng_init_general, mng_free_adat, mng_read_general, mng_write_adat, mng_assign_adat, 0, 0, sizeof(mng_adat), &mng_chunk_descr_adat},
+ {MNG_UINT_ahDR, mng_init_general, mng_free_general, mng_read_general, mng_write_ahdr, mng_assign_ahdr, 0, 0, sizeof(mng_ahdr), &mng_chunk_descr_ahdr},
+#endif
+#ifndef MNG_SKIPCHUNK_bKGD
+ {MNG_UINT_bKGD, mng_init_general, mng_free_general, mng_read_general, mng_write_bkgd, mng_assign_general, 0, 0, sizeof(mng_bkgd), &mng_chunk_descr_bkgd},
+#endif
+#ifndef MNG_SKIPCHUNK_cHRM
+ {MNG_UINT_cHRM, mng_init_general, mng_free_general, mng_read_general, mng_write_chrm, mng_assign_general, 0, 0, sizeof(mng_chrm), &mng_chunk_descr_chrm},
+#endif
+#ifndef MNG_SKIPCHUNK_eXPI
+ {MNG_UINT_eXPI, mng_init_general, mng_free_expi, mng_read_general, mng_write_expi, mng_assign_expi, 0, 0, sizeof(mng_expi), &mng_chunk_descr_expi},
+#endif
+#ifndef MNG_SKIPCHUNK_evNT
+ {MNG_UINT_evNT, mng_init_general, mng_free_evnt, mng_read_general, mng_write_evnt, mng_assign_evnt, 0, 0, sizeof(mng_evnt), &mng_chunk_descr_evnt},
+#endif
+#ifndef MNG_SKIPCHUNK_fPRI
+ {MNG_UINT_fPRI, mng_init_general, mng_free_general, mng_read_general, mng_write_fpri, mng_assign_general, 0, 0, sizeof(mng_fpri), &mng_chunk_descr_fpri},
+#endif
+#ifndef MNG_SKIPCHUNK_gAMA
+ {MNG_UINT_gAMA, mng_init_general, mng_free_general, mng_read_general, mng_write_gama, mng_assign_general, 0, 0, sizeof(mng_gama), &mng_chunk_descr_gama},
+#endif
+#ifndef MNG_SKIPCHUNK_hIST
+ {MNG_UINT_hIST, mng_init_general, mng_free_general, mng_read_general, mng_write_hist, mng_assign_general, 0, 0, sizeof(mng_hist), &mng_chunk_descr_hist},
+#endif
+#ifndef MNG_SKIPCHUNK_iCCP
+ {MNG_UINT_iCCP, mng_init_general, mng_free_iccp, mng_read_general, mng_write_iccp, mng_assign_iccp, 0, 0, sizeof(mng_iccp), &mng_chunk_descr_iccp},
+#endif
+#ifndef MNG_SKIPCHUNK_iTXt
+ {MNG_UINT_iTXt, mng_init_general, mng_free_itxt, mng_read_general, mng_write_itxt, mng_assign_itxt, 0, 0, sizeof(mng_itxt), &mng_chunk_descr_itxt},
+#endif
+#ifdef MNG_INCLUDE_MPNG_PROPOSAL
+ {MNG_UINT_mpNG, mng_init_general, mng_free_mpng, mng_read_general, mng_write_mpng, mng_assign_mpng, 0, 0, sizeof(mng_mpng), &mng_chunk_descr_mpng},
+#endif
+#ifndef MNG_SKIPCHUNK_nEED
+ {MNG_UINT_nEED, mng_init_general, mng_free_need, mng_read_general, mng_write_need, mng_assign_need, 0, 0, sizeof(mng_need), &mng_chunk_descr_need},
+#endif
+/* TODO: {MNG_UINT_oFFs, 0, 0, 0, 0, 0, 0}, */
+/* TODO: {MNG_UINT_pCAL, 0, 0, 0, 0, 0, 0}, */
+#ifndef MNG_SKIPCHUNK_pHYg
+ {MNG_UINT_pHYg, mng_init_general, mng_free_general, mng_read_general, mng_write_phyg, mng_assign_general, 0, 0, sizeof(mng_phyg), &mng_chunk_descr_phyg},
+#endif
+#ifndef MNG_SKIPCHUNK_pHYs
+ {MNG_UINT_pHYs, mng_init_general, mng_free_general, mng_read_general, mng_write_phys, mng_assign_general, 0, 0, sizeof(mng_phys), &mng_chunk_descr_phys},
+#endif
+#ifndef MNG_SKIPCHUNK_sBIT
+ {MNG_UINT_sBIT, mng_init_general, mng_free_general, mng_read_general, mng_write_sbit, mng_assign_general, 0, 0, sizeof(mng_sbit), &mng_chunk_descr_sbit},
+#endif
+/* TODO: {MNG_UINT_sCAL, 0, 0, 0, 0, 0, 0}, */
+#ifndef MNG_SKIPCHUNK_sPLT
+ {MNG_UINT_sPLT, mng_init_general, mng_free_splt, mng_read_general, mng_write_splt, mng_assign_splt, 0, 0, sizeof(mng_splt), &mng_chunk_descr_splt},
+#endif
+ {MNG_UINT_sRGB, mng_init_general, mng_free_general, mng_read_general, mng_write_srgb, mng_assign_general, 0, 0, sizeof(mng_srgb), &mng_chunk_descr_srgb},
+#ifndef MNG_SKIPCHUNK_tEXt
+ {MNG_UINT_tEXt, mng_init_general, mng_free_text, mng_read_general, mng_write_text, mng_assign_text, 0, 0, sizeof(mng_text), &mng_chunk_descr_text},
+#endif
+#ifndef MNG_SKIPCHUNK_tIME
+ {MNG_UINT_tIME, mng_init_general, mng_free_general, mng_read_general, mng_write_time, mng_assign_general, 0, 0, sizeof(mng_time), &mng_chunk_descr_time},
+#endif
+ {MNG_UINT_tRNS, mng_init_general, mng_free_general, mng_read_general, mng_write_trns, mng_assign_general, 0, 0, sizeof(mng_trns), &mng_chunk_descr_trns},
+#ifndef MNG_SKIPCHUNK_zTXt
+ {MNG_UINT_zTXt, mng_init_general, mng_free_ztxt, mng_read_general, mng_write_ztxt, mng_assign_ztxt, 0, 0, sizeof(mng_ztxt), &mng_chunk_descr_ztxt},
+#endif
+ };
+
+/* ************************************************************************** */
+/* ************************************************************************** */
+
+void mng_get_chunkheader (mng_chunkid iChunkname,
+ mng_chunk_headerp pResult)
+{
+ /* binary search variables */
+ mng_int32 iTop, iLower, iUpper, iMiddle;
+ mng_chunk_headerp pEntry; /* pointer to found entry */
+ /* determine max index of table */
+ iTop = (sizeof (mng_chunk_table) / sizeof (mng_chunk_table [0])) - 1;
+
+ /* binary search; with 54 chunks, worst-case is 7 comparisons */
+ iLower = 0;
+#ifndef MNG_NO_DELTA_PNG
+ iMiddle = 11; /* start with the IDAT entry */
+#else
+ iMiddle = 8;
+#endif
+ iUpper = iTop;
+ pEntry = 0; /* no goods yet! */
+
+ do /* the binary search itself */
+ {
+ if (mng_chunk_table [iMiddle].iChunkname < iChunkname)
+ iLower = iMiddle + 1;
+ else if (mng_chunk_table [iMiddle].iChunkname > iChunkname)
+ iUpper = iMiddle - 1;
+ else
+ {
+ pEntry = &mng_chunk_table [iMiddle];
+ break;
+ }
+ iMiddle = (iLower + iUpper) >> 1;
+ }
+ while (iLower <= iUpper);
+
+ if (!pEntry) /* unknown chunk ? */
+ pEntry = &mng_chunk_unknown; /* make it so! */
+
+ MNG_COPY (pResult, pEntry, sizeof(mng_chunk_header));
+
+ return;
+}
+
+/* ************************************************************************** */
+/* ************************************************************************** */
+/* PNG chunks */
+
+MNG_C_SPECIALFUNC (mng_special_ihdr)
+{
+ pData->bHasIHDR = MNG_TRUE; /* indicate IHDR is present */
+ /* and store interesting fields */
+ if ((!pData->bHasDHDR) || (pData->iDeltatype == MNG_DELTATYPE_NOCHANGE))
+ {
+ pData->iDatawidth = ((mng_ihdrp)pChunk)->iWidth;
+ pData->iDataheight = ((mng_ihdrp)pChunk)->iHeight;
+ }
+
+ pData->iBitdepth = ((mng_ihdrp)pChunk)->iBitdepth;
+ pData->iColortype = ((mng_ihdrp)pChunk)->iColortype;
+ pData->iCompression = ((mng_ihdrp)pChunk)->iCompression;
+ pData->iFilter = ((mng_ihdrp)pChunk)->iFilter;
+ pData->iInterlace = ((mng_ihdrp)pChunk)->iInterlace;
+
+#if defined(MNG_NO_1_2_4BIT_SUPPORT) || defined(MNG_NO_16BIT_SUPPORT)
+ pData->iPNGmult = 1;
+ pData->iPNGdepth = pData->iBitdepth;
+#endif
+
+#ifdef MNG_NO_1_2_4BIT_SUPPORT
+ if (pData->iBitdepth < 8)
+ pData->iBitdepth = 8;
+#endif
+
+#ifdef MNG_NO_16BIT_SUPPORT
+ if (pData->iBitdepth > 8)
+ {
+ pData->iBitdepth = 8;
+ pData->iPNGmult = 2;
+ }
+#endif
+
+ if ((pData->iBitdepth != 8) /* parameter validity checks */
+#ifndef MNG_NO_1_2_4BIT_SUPPORT
+ && (pData->iBitdepth != 1) &&
+ (pData->iBitdepth != 2) &&
+ (pData->iBitdepth != 4)
+#endif
+#ifndef MNG_NO_16BIT_SUPPORT
+ && (pData->iBitdepth != 16)
+#endif
+ )
+ MNG_ERROR (pData, MNG_INVALIDBITDEPTH);
+
+ if ((pData->iColortype != MNG_COLORTYPE_GRAY ) &&
+ (pData->iColortype != MNG_COLORTYPE_RGB ) &&
+ (pData->iColortype != MNG_COLORTYPE_INDEXED) &&
+ (pData->iColortype != MNG_COLORTYPE_GRAYA ) &&
+ (pData->iColortype != MNG_COLORTYPE_RGBA ) )
+ MNG_ERROR (pData, MNG_INVALIDCOLORTYPE);
+
+ if ((pData->iColortype == MNG_COLORTYPE_INDEXED) && (pData->iBitdepth > 8))
+ MNG_ERROR (pData, MNG_INVALIDBITDEPTH);
+
+ if (((pData->iColortype == MNG_COLORTYPE_RGB ) ||
+ (pData->iColortype == MNG_COLORTYPE_GRAYA ) ||
+ (pData->iColortype == MNG_COLORTYPE_RGBA ) ) &&
+ (pData->iBitdepth < 8 ) )
+ MNG_ERROR (pData, MNG_INVALIDBITDEPTH);
+
+ if (pData->iCompression != MNG_COMPRESSION_DEFLATE)
+ MNG_ERROR (pData, MNG_INVALIDCOMPRESS);
+
+#if defined(FILTER192) || defined(FILTER193)
+ if ((pData->iFilter != MNG_FILTER_ADAPTIVE ) &&
+#if defined(FILTER192) && defined(FILTER193)
+ (pData->iFilter != MNG_FILTER_DIFFERING) &&
+ (pData->iFilter != MNG_FILTER_NOFILTER ) )
+#else
+#ifdef FILTER192
+ (pData->iFilter != MNG_FILTER_DIFFERING) )
+#else
+ (pData->iFilter != MNG_FILTER_NOFILTER ) )
+#endif
+#endif
+ MNG_ERROR (pData, MNG_INVALIDFILTER);
+#else
+ if (pData->iFilter)
+ MNG_ERROR (pData, MNG_INVALIDFILTER);
+#endif
+
+ if ((pData->iInterlace != MNG_INTERLACE_NONE ) &&
+ (pData->iInterlace != MNG_INTERLACE_ADAM7) )
+ MNG_ERROR (pData, MNG_INVALIDINTERLACE);
+
+#ifdef MNG_SUPPORT_DISPLAY
+#ifndef MNG_NO_DELTA_PNG
+ if (pData->bHasDHDR) /* check the colortype for delta-images ! */
+ {
+ mng_imagedatap pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf;
+
+ if (pData->iColortype != pBuf->iColortype)
+ {
+ if ( ( (pData->iColortype != MNG_COLORTYPE_INDEXED) ||
+ (pBuf->iColortype == MNG_COLORTYPE_GRAY ) ) &&
+ ( (pData->iColortype != MNG_COLORTYPE_GRAY ) ||
+ (pBuf->iColortype == MNG_COLORTYPE_INDEXED) ) )
+ MNG_ERROR (pData, MNG_INVALIDCOLORTYPE);
+ }
+ }
+#endif
+#endif
+
+ if (!pData->bHasheader) /* first chunk ? */
+ {
+ pData->bHasheader = MNG_TRUE; /* we've got a header */
+ pData->eImagetype = mng_it_png; /* then this must be a PNG */
+ pData->iWidth = pData->iDatawidth;
+ pData->iHeight = pData->iDataheight;
+ /* predict alpha-depth ! */
+ if ((pData->iColortype == MNG_COLORTYPE_GRAYA ) ||
+ (pData->iColortype == MNG_COLORTYPE_RGBA ) )
+ pData->iAlphadepth = pData->iBitdepth;
+ else
+ if (pData->iColortype == MNG_COLORTYPE_INDEXED)
+ pData->iAlphadepth = 8; /* worst case scenario */
+ else
+ pData->iAlphadepth = 1; /* Possible tRNS cheap binary transparency */
+ /* fits on maximum canvas ? */
+ if ((pData->iWidth > pData->iMaxwidth) || (pData->iHeight > pData->iMaxheight))
+ MNG_WARNING (pData, MNG_IMAGETOOLARGE);
+
+#if !defined(MNG_INCLUDE_MPNG_PROPOSAL) || !defined(MNG_SUPPORT_DISPLAY)
+ if (pData->fProcessheader) /* inform the app ? */
+ if (!pData->fProcessheader (((mng_handle)pData), pData->iWidth, pData->iHeight))
+ MNG_ERROR (pData, MNG_APPMISCERROR);
+#endif
+ }
+
+ if (!pData->bHasDHDR)
+ pData->iImagelevel++; /* one level deeper */
+
+#ifdef MNG_SUPPORT_DISPLAY
+ return mng_process_display_ihdr (pData);
+#else
+ return MNG_NOERROR;
+#endif /* MNG_SUPPORT_DISPLAY */
+}
+
+/* ************************************************************************** */
+
+MNG_F_SPECIALFUNC (mng_debunk_plte)
+{
+ mng_pltep pPLTE = (mng_pltep)pChunk;
+ mng_uint32 iRawlen = *piRawlen;
+ mng_uint8p pRawdata = *ppRawdata;
+ /* length must be multiple of 3 */
+ if (((iRawlen % 3) != 0) || (iRawlen > 768))
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+ /* this is the exact length */
+ pPLTE->iEntrycount = iRawlen / 3;
+
+ MNG_COPY (pPLTE->aEntries, pRawdata, iRawlen);
+
+ *piRawlen = 0;
+
+ return MNG_NOERROR;
+}
+
+/* ************************************************************************** */
+
+MNG_C_SPECIALFUNC (mng_special_plte)
+{ /* multiple PLTE only inside BASI */
+ if ((pData->bHasPLTE) && (!pData->bHasBASI))
+ MNG_ERROR (pData, MNG_MULTIPLEERROR);
+
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
+ { /* only allowed for indexed-color or
+ rgb(a)-color! */
+ if ((pData->iColortype != MNG_COLORTYPE_RGB ) &&
+ (pData->iColortype != MNG_COLORTYPE_INDEXED) &&
+ (pData->iColortype != MNG_COLORTYPE_RGBA ) )
+ MNG_ERROR (pData, MNG_CHUNKNOTALLOWED);
+ /* empty only allowed if global present */
+ if ((((mng_pltep)pChunk)->bEmpty) && (!pData->bHasglobalPLTE))
+ MNG_ERROR (pData, MNG_CANNOTBEEMPTY);
+ }
+ else
+ {
+ if (((mng_pltep)pChunk)->bEmpty) /* cannot be empty as global! */
+ MNG_ERROR (pData, MNG_CANNOTBEEMPTY);
+ }
+
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
+ pData->bHasPLTE = MNG_TRUE; /* got it! */
+ else
+ pData->bHasglobalPLTE = MNG_TRUE;
+
+ pData->iPLTEcount = ((mng_pltep)pChunk)->iEntrycount;
+
+#ifdef MNG_SUPPORT_DISPLAY
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
+ {
+ mng_imagep pImage;
+ mng_imagedatap pBuf;
+
+#ifndef MNG_NO_DELTA_PNG
+ if (pData->bHasDHDR) /* processing delta-image ? */
+ { /* store in object 0 !!! */
+ pImage = (mng_imagep)pData->pObjzero;
+ pBuf = pImage->pImgbuf;
+ pBuf->bHasPLTE = MNG_TRUE; /* it's definitely got a PLTE now */
+ pBuf->iPLTEcount = ((mng_pltep)pChunk)->iEntrycount;
+ MNG_COPY (pBuf->aPLTEentries, ((mng_pltep)pChunk)->aEntries,
+ sizeof (pBuf->aPLTEentries));
+ }
+ else
+#endif
+ { /* get the current object */
+ pImage = (mng_imagep)pData->pCurrentobj;
+ if (!pImage) /* no object then dump it in obj 0 */
+ pImage = (mng_imagep)pData->pObjzero;
+
+ pBuf = pImage->pImgbuf; /* address the object buffer */
+ pBuf->bHasPLTE = MNG_TRUE; /* and tell it it's got a PLTE now */
+
+ if (((mng_pltep)pChunk)->bEmpty) /* if empty, inherit from global */
+ {
+ pBuf->iPLTEcount = pData->iGlobalPLTEcount;
+ MNG_COPY (pBuf->aPLTEentries, pData->aGlobalPLTEentries,
+ sizeof (pBuf->aPLTEentries));
+
+ if (pData->bHasglobalTRNS) /* also copy global tRNS ? */
+ {
+ mng_uint32 iRawlen2 = pData->iGlobalTRNSrawlen;
+ mng_uint8p pRawdata2 = (mng_uint8p)(pData->aGlobalTRNSrawdata);
+ /* indicate tRNS available */
+ pBuf->bHasTRNS = MNG_TRUE;
+ /* global length oke ? */
+ if ((iRawlen2 == 0) || (iRawlen2 > pBuf->iPLTEcount))
+ MNG_ERROR (pData, MNG_GLOBALLENGTHERR);
+ /* copy it */
+ pBuf->iTRNScount = iRawlen2;
+ MNG_COPY (pBuf->aTRNSentries, pRawdata2, iRawlen2);
+ }
+ }
+ else
+ { /* store fields for future reference */
+ pBuf->iPLTEcount = ((mng_pltep)pChunk)->iEntrycount;
+ MNG_COPY (pBuf->aPLTEentries, ((mng_pltep)pChunk)->aEntries,
+ sizeof (pBuf->aPLTEentries));
+ }
+ }
+ }
+ else /* store as global */
+ {
+ pData->iGlobalPLTEcount = ((mng_pltep)pChunk)->iEntrycount;
+ MNG_COPY (pData->aGlobalPLTEentries, ((mng_pltep)pChunk)->aEntries,
+ sizeof (pData->aGlobalPLTEentries));
+ /* create an animation object */
+ return mng_create_ani_plte (pData);
+ }
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ return MNG_NOERROR; /* done */
+}
+
+/* ************************************************************************** */
+
+MNG_C_SPECIALFUNC (mng_special_idat)
+{
+#ifdef MNG_INCLUDE_JNG
+ if ((pData->bHasJHDR) &&
+ (pData->iJHDRalphacompression != MNG_COMPRESSION_DEFLATE))
+ MNG_ERROR (pData, MNG_SEQUENCEERROR);
+#endif
+ /* not allowed for deltatype NO_CHANGE */
+#ifndef MNG_NO_DELTA_PNG
+ if ((pData->bHasDHDR) && ((pData->iDeltatype == MNG_DELTATYPE_NOCHANGE)))
+ MNG_ERROR (pData, MNG_CHUNKNOTALLOWED);
+#endif
+ /* can only be empty in BASI-block! */
+ if ((((mng_idatp)pChunk)->bEmpty) && (!pData->bHasBASI))
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+ /* indexed-color requires PLTE */
+ if ((pData->bHasIHDR) && (pData->iColortype == 3) && (!pData->bHasPLTE))
+ MNG_ERROR (pData, MNG_PLTEMISSING);
+
+ pData->bHasIDAT = MNG_TRUE; /* got some IDAT now, don't we */
+
+ return MNG_NOERROR; /* done */
+}
+
+/* ************************************************************************** */
+
+MNG_C_SPECIALFUNC (mng_special_iend)
+{ /* IHDR-block requires IDAT */
+ if ((pData->bHasIHDR) && (!pData->bHasIDAT))
+ MNG_ERROR (pData, MNG_IDATMISSING);
+
+ pData->iImagelevel--; /* one level up */
+
+#ifdef MNG_SUPPORT_DISPLAY
+ { /* create an animation object */
+ mng_retcode iRetcode = mng_create_ani_image (pData);
+ if (iRetcode) /* on error bail out */
+ return iRetcode;
+ /* display processing */
+ iRetcode = mng_process_display_iend (pData);
+ if (iRetcode) /* on error bail out */
+ return iRetcode;
+ }
+#endif /* MNG_SUPPORT_DISPLAY */
+
+#ifdef MNG_SUPPORT_DISPLAY
+ if (!pData->bTimerset) /* reset only if not broken !!! */
+ {
+#endif
+ /* IEND signals the end for most ... */
+ pData->bHasIHDR = MNG_FALSE;
+ pData->bHasBASI = MNG_FALSE;
+ pData->bHasDHDR = MNG_FALSE;
+#ifdef MNG_INCLUDE_JNG
+ pData->bHasJHDR = MNG_FALSE;
+ pData->bHasJSEP = MNG_FALSE;
+ pData->bHasJDAA = MNG_FALSE;
+ pData->bHasJDAT = MNG_FALSE;
+#endif
+ pData->bHasPLTE = MNG_FALSE;
+ pData->bHasTRNS = MNG_FALSE;
+ pData->bHasGAMA = MNG_FALSE;
+ pData->bHasCHRM = MNG_FALSE;
+ pData->bHasSRGB = MNG_FALSE;
+ pData->bHasICCP = MNG_FALSE;
+ pData->bHasBKGD = MNG_FALSE;
+ pData->bHasIDAT = MNG_FALSE;
+#ifdef MNG_SUPPORT_DISPLAY
+ }
+#endif
+
+ return MNG_NOERROR; /* done */
+}
+
+/* ************************************************************************** */
+
+MNG_F_SPECIALFUNC (mng_debunk_trns)
+{
+ mng_trnsp pTRNS = (mng_trnsp)pChunk;
+ mng_uint32 iRawlen = *piRawlen;
+ mng_uint8p pRawdata = *ppRawdata;
+
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
+ { /* not global! */
+ pTRNS->bGlobal = MNG_FALSE;
+ pTRNS->iType = pData->iColortype;
+
+ if (iRawlen != 0)
+ {
+ switch (pData->iColortype) /* store fields */
+ {
+ case 0: { /* gray */
+ if (iRawlen != 2)
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+ pTRNS->iGray = mng_get_uint16 (pRawdata);
+ break;
+ }
+ case 2: { /* rgb */
+ if (iRawlen != 6)
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+ pTRNS->iRed = mng_get_uint16 (pRawdata);
+ pTRNS->iGreen = mng_get_uint16 (pRawdata+2);
+ pTRNS->iBlue = mng_get_uint16 (pRawdata+4);
+ break;
+ }
+ case 3: { /* indexed */
+ if (iRawlen > 256)
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+ pTRNS->iCount = iRawlen;
+ MNG_COPY (pTRNS->aEntries, pRawdata, iRawlen);
+ break;
+ }
+ }
+ }
+ }
+ else /* it's global! */
+ {
+ if (iRawlen == 0)
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+ pTRNS->bGlobal = MNG_TRUE;
+ pTRNS->iType = 0;
+ pTRNS->iRawlen = iRawlen;
+ MNG_COPY (pTRNS->aRawdata, pRawdata, iRawlen);
+
+ pData->iGlobalTRNSrawlen = iRawlen;
+ MNG_COPY (pData->aGlobalTRNSrawdata, pRawdata, iRawlen);
+ }
+
+ *piRawlen = 0;
+
+ return MNG_NOERROR;
+}
+
+/* ************************************************************************** */
+
+MNG_C_SPECIALFUNC (mng_special_trns)
+{ /* multiple tRNS only inside BASI */
+ if ((pData->bHasTRNS) && (!pData->bHasBASI))
+ MNG_ERROR (pData, MNG_MULTIPLEERROR);
+
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
+ { /* not allowed with full alpha-channel */
+ if ((pData->iColortype == 4) || (pData->iColortype == 6))
+ MNG_ERROR (pData, MNG_CHUNKNOTALLOWED);
+
+ if (!((mng_trnsp)pChunk)->bEmpty) /* filled ? */
+ {
+#ifdef MNG_SUPPORT_DISPLAY
+ if (pData->iColortype == 3)
+ {
+ mng_imagep pImage = (mng_imagep)pData->pCurrentobj;
+ mng_imagedatap pBuf;
+
+ if (!pImage) /* no object then check obj 0 */
+ pImage = (mng_imagep)pData->pObjzero;
+
+ pBuf = pImage->pImgbuf; /* address object buffer */
+
+ if (((mng_trnsp)pChunk)->iCount > pBuf->iPLTEcount)
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+ }
+#endif
+ }
+ else /* if empty there must be global stuff! */
+ {
+ if (!pData->bHasglobalTRNS)
+ MNG_ERROR (pData, MNG_CANNOTBEEMPTY);
+ }
+ }
+
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
+ pData->bHasTRNS = MNG_TRUE; /* indicate tRNS available */
+ else
+ pData->bHasglobalTRNS = MNG_TRUE;
+
+#ifdef MNG_SUPPORT_DISPLAY
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
+ {
+ mng_imagep pImage;
+ mng_imagedatap pBuf;
+ mng_uint8p pRawdata2;
+ mng_uint32 iRawlen2;
+
+#ifndef MNG_NO_DELTA_PNG
+ if (pData->bHasDHDR) /* processing delta-image ? */
+ { /* store in object 0 !!! */
+#if defined(MNG_NO_1_2_4BIT_SUPPORT)
+ mng_uint8 multiplier[]={0,255,85,0,17,0,0,0,1,0,0,0,0,0,0,0,1};
+#endif
+ pImage = (mng_imagep)pData->pObjzero;
+ pBuf = pImage->pImgbuf; /* address object buffer */
+ pBuf->bHasTRNS = MNG_TRUE; /* tell it it's got a tRNS now */
+ pBuf->iTRNSgray = 0;
+ pBuf->iTRNSred = 0;
+ pBuf->iTRNSgreen = 0;
+ pBuf->iTRNSblue = 0;
+ pBuf->iTRNScount = 0;
+
+ switch (pData->iColortype) /* store fields for future reference */
+ {
+ case 0: { /* gray */
+ pBuf->iTRNSgray = ((mng_trnsp)pChunk)->iGray;
+#if defined(MNG_NO_1_2_4BIT_SUPPORT)
+ pBuf->iTRNSgray *= multiplier[pData->iPNGdepth];
+#endif
+#if defined(MNG_NO_16BIT_SUPPORT)
+ if (pData->iPNGmult == 2)
+ pBuf->iTRNSgray >>= 8;
+#endif
+ break;
+ }
+ case 2: { /* rgb */
+ pBuf->iTRNSred = ((mng_trnsp)pChunk)->iRed;
+ pBuf->iTRNSgreen = ((mng_trnsp)pChunk)->iGreen;
+ pBuf->iTRNSblue = ((mng_trnsp)pChunk)->iBlue;
+#if defined(MNG_NO_16BIT_SUPPORT)
+ if (pData->iPNGmult == 2)
+ {
+ pBuf->iTRNSred >>= 8;
+ pBuf->iTRNSgreen >>= 8;
+ pBuf->iTRNSblue >>= 8;
+ }
+#endif
+ break;
+ }
+ case 3: { /* indexed */
+ pBuf->iTRNScount = ((mng_trnsp)pChunk)->iCount;
+ MNG_COPY (pBuf->aTRNSentries,
+ ((mng_trnsp)pChunk)->aEntries,
+ ((mng_trnsp)pChunk)->iCount);
+ break;
+ }
+ }
+ }
+ else
+#endif
+ { /* address current object */
+ pImage = (mng_imagep)pData->pCurrentobj;
+
+ if (!pImage) /* no object then dump it in obj 0 */
+ pImage = (mng_imagep)pData->pObjzero;
+
+ pBuf = pImage->pImgbuf; /* address object buffer */
+ pBuf->bHasTRNS = MNG_TRUE; /* and tell it it's got a tRNS now */
+ pBuf->iTRNSgray = 0;
+ pBuf->iTRNSred = 0;
+ pBuf->iTRNSgreen = 0;
+ pBuf->iTRNSblue = 0;
+ pBuf->iTRNScount = 0;
+
+ if (((mng_trnsp)pChunk)->bEmpty) /* if empty, inherit from global */
+ {
+ iRawlen2 = pData->iGlobalTRNSrawlen;
+ pRawdata2 = (mng_ptr)(pData->aGlobalTRNSrawdata);
+ /* global length oke ? */
+ if ((pData->iColortype == 0) && (iRawlen2 != 2))
+ MNG_ERROR (pData, MNG_GLOBALLENGTHERR);
+
+ if ((pData->iColortype == 2) && (iRawlen2 != 6))
+ MNG_ERROR (pData, MNG_GLOBALLENGTHERR);
+
+ if ((pData->iColortype == 3) && ((iRawlen2 == 0) || (iRawlen2 > pBuf->iPLTEcount)))
+ MNG_ERROR (pData, MNG_GLOBALLENGTHERR);
+
+ switch (pData->iColortype) /* store fields for future reference */
+ {
+ case 0: { /* gray */
+ pBuf->iTRNSgray = mng_get_uint16 (pRawdata2);
+#if defined(MNG_NO_16BIT_SUPPORT)
+ if (pData->iPNGmult == 2)
+ pBuf->iTRNSgray >>= 8;
+#endif
+ break;
+ }
+ case 2: { /* rgb */
+ pBuf->iTRNSred = mng_get_uint16 (pRawdata2);
+ pBuf->iTRNSgreen = mng_get_uint16 (pRawdata2+2);
+ pBuf->iTRNSblue = mng_get_uint16 (pRawdata2+4);
+#if defined(MNG_NO_16BIT_SUPPORT)
+ if (pData->iPNGmult == 2)
+ {
+ pBuf->iTRNSred >>= 8;
+ pBuf->iTRNSgreen >>= 8;
+ pBuf->iTRNSblue >>= 8;
+ }
+#endif
+ break;
+ }
+ case 3: { /* indexed */
+ pBuf->iTRNScount = iRawlen2;
+ MNG_COPY (pBuf->aTRNSentries, pRawdata2, iRawlen2);
+ break;
+ }
+ }
+ }
+ else
+ {
+ switch (pData->iColortype) /* store fields for future reference */
+ {
+ case 0: { /* gray */
+ pBuf->iTRNSgray = ((mng_trnsp)pChunk)->iGray;
+#if defined(MNG_NO_16BIT_SUPPORT)
+ if (pData->iPNGmult == 2)
+ pBuf->iTRNSgray >>= 8;
+#endif
+ break;
+ }
+ case 2: { /* rgb */
+ pBuf->iTRNSred = ((mng_trnsp)pChunk)->iRed;
+ pBuf->iTRNSgreen = ((mng_trnsp)pChunk)->iGreen;
+ pBuf->iTRNSblue = ((mng_trnsp)pChunk)->iBlue;
+#if defined(MNG_NO_16BIT_SUPPORT)
+ if (pData->iPNGmult == 2)
+ {
+ pBuf->iTRNSred >>= 8;
+ pBuf->iTRNSgreen >>= 8;
+ pBuf->iTRNSblue >>= 8;
+ }
+#endif
+ break;
+ }
+ case 3: { /* indexed */
+ pBuf->iTRNScount = ((mng_trnsp)pChunk)->iCount;
+ MNG_COPY (pBuf->aTRNSentries,
+ ((mng_trnsp)pChunk)->aEntries,
+ ((mng_trnsp)pChunk)->iCount);
+ break;
+ }
+ }
+ }
+ }
+ }
+ else
+ { /* create an animation object */
+ return mng_create_ani_trns (pData);
+ }
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ return MNG_NOERROR; /* done */
+}
+
+/* ************************************************************************** */
+
+MNG_C_SPECIALFUNC (mng_special_gama)
+{
+#ifdef MNG_INCLUDE_JNG
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR))
+#else
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
+#endif
+ pData->bHasGAMA = MNG_TRUE; /* indicate we've got it */
+ else
+ pData->bHasglobalGAMA = (mng_bool)!((mng_gamap)pChunk)->bEmpty;
+
+#ifdef MNG_SUPPORT_DISPLAY
+#ifdef MNG_INCLUDE_JNG
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR))
+#else
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
+#endif
+ {
+ mng_imagep pImage;
+
+#ifndef MNG_NO_DELTA_PNG
+ if (pData->bHasDHDR) /* update delta image ? */
+ pImage = (mng_imagep)pData->pObjzero;
+ else
+#endif
+ {
+ pImage = (mng_imagep)pData->pCurrentobj;
+ if (!pImage) /* no object then dump it in obj 0 */
+ pImage = (mng_imagep)pData->pObjzero;
+ }
+ /* store for color-processing routines */
+ pImage->pImgbuf->iGamma = ((mng_gamap)pChunk)->iGamma;
+ pImage->pImgbuf->bHasGAMA = MNG_TRUE;
+ }
+ else
+ { /* store as global */
+ if (!((mng_gamap)pChunk)->bEmpty)
+ pData->iGlobalGamma = ((mng_gamap)pChunk)->iGamma;
+ /* create an animation object */
+ return mng_create_ani_gama (pData, pChunk);
+ }
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ return MNG_NOERROR; /* done */
+}
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_cHRM
+MNG_C_SPECIALFUNC (mng_special_chrm)
+{
+#ifdef MNG_INCLUDE_JNG
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR))
+#else
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
+#endif
+ pData->bHasCHRM = MNG_TRUE; /* indicate we've got it */
+ else
+ pData->bHasglobalCHRM = (mng_bool)!((mng_chrmp)pChunk)->bEmpty;
+
+#ifdef MNG_SUPPORT_DISPLAY
+ {
+#ifdef MNG_INCLUDE_JNG
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR))
+#else
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
+#endif
+ {
+ mng_imagep pImage;
+ mng_imagedatap pBuf;
+
+#ifndef MNG_NO_DELTA_PNG
+ if (pData->bHasDHDR) /* update delta image ? */
+ pImage = (mng_imagep)pData->pObjzero;
+ else
+#endif
+ {
+ pImage = (mng_imagep)pData->pCurrentobj;
+ if (!pImage) /* no object then dump it in obj 0 */
+ pImage = (mng_imagep)pData->pObjzero;
+ }
+
+ pBuf = pImage->pImgbuf; /* address object buffer */
+ pBuf->bHasCHRM = MNG_TRUE; /* and tell it it's got a CHRM now */
+ /* store for color-processing routines */
+ pBuf->iWhitepointx = ((mng_chrmp)pChunk)->iWhitepointx;
+ pBuf->iWhitepointy = ((mng_chrmp)pChunk)->iWhitepointy;
+ pBuf->iPrimaryredx = ((mng_chrmp)pChunk)->iRedx;
+ pBuf->iPrimaryredy = ((mng_chrmp)pChunk)->iRedy;
+ pBuf->iPrimarygreenx = ((mng_chrmp)pChunk)->iGreenx;
+ pBuf->iPrimarygreeny = ((mng_chrmp)pChunk)->iGreeny;
+ pBuf->iPrimarybluex = ((mng_chrmp)pChunk)->iBluex;
+ pBuf->iPrimarybluey = ((mng_chrmp)pChunk)->iBluey;
+ }
+ else
+ { /* store as global */
+ if (!((mng_chrmp)pChunk)->bEmpty)
+ {
+ pData->iGlobalWhitepointx = ((mng_chrmp)pChunk)->iWhitepointx;
+ pData->iGlobalWhitepointy = ((mng_chrmp)pChunk)->iWhitepointy;
+ pData->iGlobalPrimaryredx = ((mng_chrmp)pChunk)->iRedx;
+ pData->iGlobalPrimaryredy = ((mng_chrmp)pChunk)->iRedy;
+ pData->iGlobalPrimarygreenx = ((mng_chrmp)pChunk)->iGreenx;
+ pData->iGlobalPrimarygreeny = ((mng_chrmp)pChunk)->iGreeny;
+ pData->iGlobalPrimarybluex = ((mng_chrmp)pChunk)->iBluex;
+ pData->iGlobalPrimarybluey = ((mng_chrmp)pChunk)->iBluey;
+ }
+ /* create an animation object */
+ return mng_create_ani_chrm (pData, pChunk);
+ }
+ }
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ return MNG_NOERROR; /* done */
+}
+#endif
+
+/* ************************************************************************** */
+
+MNG_C_SPECIALFUNC (mng_special_srgb)
+{
+#ifdef MNG_INCLUDE_JNG
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR))
+#else
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
+#endif
+ pData->bHasSRGB = MNG_TRUE; /* indicate we've got it */
+ else
+ pData->bHasglobalSRGB = (mng_bool)!((mng_srgbp)pChunk)->bEmpty;
+
+#ifdef MNG_SUPPORT_DISPLAY
+#ifdef MNG_INCLUDE_JNG
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR))
+#else
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
+#endif
+ {
+ mng_imagep pImage;
+
+#ifndef MNG_NO_DELTA_PNG
+ if (pData->bHasDHDR) /* update delta image ? */
+ pImage = (mng_imagep)pData->pObjzero;
+ else
+#endif
+ {
+ pImage = (mng_imagep)pData->pCurrentobj;
+ if (!pImage) /* no object then dump it in obj 0 */
+ pImage = (mng_imagep)pData->pObjzero;
+ }
+ /* store for color-processing routines */
+ pImage->pImgbuf->iRenderingintent = ((mng_srgbp)pChunk)->iRenderingintent;
+ pImage->pImgbuf->bHasSRGB = MNG_TRUE;
+ }
+ else
+ { /* store as global */
+ if (!((mng_srgbp)pChunk)->bEmpty)
+ pData->iGlobalRendintent = ((mng_srgbp)pChunk)->iRenderingintent;
+ /* create an animation object */
+ return mng_create_ani_srgb (pData, pChunk);
+ }
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ return MNG_NOERROR; /* done */
+}
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_iCCP
+MNG_C_SPECIALFUNC (mng_special_iccp)
+{
+ mng_retcode iRetcode;
+ mng_chunk_headerp pDummy;
+
+#ifdef MNG_CHECK_BAD_ICCP /* Check for bad iCCP chunk */
+ if (!strncmp (((mng_iccpp)pChunk)->zName, "Photoshop ICC profile", 21))
+ {
+ if (((mng_iccpp)pChunk)->iProfilesize == 2615) /* is it the sRGB profile ? */
+ {
+ mng_chunk_header chunk_srgb;
+ mng_get_chunkheader (MNG_UINT_sRGB, &chunk_srgb);
+ /* pretend it's an sRGB chunk then ! */
+ iRetcode = mng_read_general (pData, &chunk_srgb, 1, (mng_ptr)"0", &pDummy);
+ if (iRetcode) /* on error bail out */
+ return iRetcode;
+
+ pDummy->fCleanup (pData, pDummy);
+ }
+ }
+ else
+ {
+#endif /* MNG_CHECK_BAD_ICCP */
+
+#ifdef MNG_INCLUDE_JNG
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR))
+#else
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
+#endif
+ pData->bHasICCP = MNG_TRUE; /* indicate we've got it */
+ else
+ pData->bHasglobalICCP = (mng_bool)!((mng_iccpp)pChunk)->bEmpty;
+
+#ifdef MNG_SUPPORT_DISPLAY
+#ifdef MNG_INCLUDE_JNG
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR))
+#else
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
+#endif
+ {
+ mng_imagep pImage;
+
+#ifndef MNG_NO_DELTA_PNG
+ if (pData->bHasDHDR) /* update delta image ? */
+ { /* store in object 0 ! */
+ pImage = (mng_imagep)pData->pObjzero;
+
+ if (pImage->pImgbuf->pProfile) /* profile existed ? */
+ MNG_FREEX (pData, pImage->pImgbuf->pProfile, pImage->pImgbuf->iProfilesize);
+ /* allocate a buffer & copy it */
+ MNG_ALLOC (pData, pImage->pImgbuf->pProfile, ((mng_iccpp)pChunk)->iProfilesize);
+ MNG_COPY (pImage->pImgbuf->pProfile, ((mng_iccpp)pChunk)->pProfile, ((mng_iccpp)pChunk)->iProfilesize);
+ /* store its length as well */
+ pImage->pImgbuf->iProfilesize = ((mng_iccpp)pChunk)->iProfilesize;
+ pImage->pImgbuf->bHasICCP = MNG_TRUE;
+ }
+ else
+#endif
+ {
+ pImage = (mng_imagep)pData->pCurrentobj;
+
+ if (!pImage) /* no object then dump it in obj 0 */
+ pImage = (mng_imagep)pData->pObjzero;
+
+ if (pImage->pImgbuf->pProfile) /* profile existed ? */
+ MNG_FREEX (pData, pImage->pImgbuf->pProfile, pImage->pImgbuf->iProfilesize);
+ /* allocate a buffer & copy it */
+ MNG_ALLOC (pData, pImage->pImgbuf->pProfile, ((mng_iccpp)pChunk)->iProfilesize);
+ MNG_COPY (pImage->pImgbuf->pProfile, ((mng_iccpp)pChunk)->pProfile, ((mng_iccpp)pChunk)->iProfilesize);
+ /* store its length as well */
+ pImage->pImgbuf->iProfilesize = ((mng_iccpp)pChunk)->iProfilesize;
+ pImage->pImgbuf->bHasICCP = MNG_TRUE;
+ }
+ }
+ else
+ { /* store as global */
+ if (pData->pGlobalProfile) /* did we have a global profile ? */
+ MNG_FREEX (pData, pData->pGlobalProfile, pData->iGlobalProfilesize);
+
+ if (((mng_iccpp)pChunk)->bEmpty) /* empty chunk ? */
+ {
+ pData->iGlobalProfilesize = 0; /* reset to null */
+ pData->pGlobalProfile = MNG_NULL;
+ }
+ else
+ { /* allocate a global buffer & copy it */
+ MNG_ALLOC (pData, pData->pGlobalProfile, ((mng_iccpp)pChunk)->iProfilesize);
+ MNG_COPY (pData->pGlobalProfile, ((mng_iccpp)pChunk)->pProfile, ((mng_iccpp)pChunk)->iProfilesize);
+ /* store its length as well */
+ pData->iGlobalProfilesize = ((mng_iccpp)pChunk)->iProfilesize;
+ }
+ /* create an animation object */
+ return mng_create_ani_iccp (pData, pChunk);
+ }
+#endif /* MNG_SUPPORT_DISPLAY */
+
+#ifdef MNG_CHECK_BAD_ICCP
+ }
+#endif
+
+ return MNG_NOERROR; /* done */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_tEXt
+MNG_C_SPECIALFUNC (mng_special_text)
+{
+ if (pData->fProcesstext) /* inform the application ? */
+ {
+ mng_bool bOke = pData->fProcesstext ((mng_handle)pData, MNG_TYPE_TEXT,
+ ((mng_textp)pChunk)->zKeyword,
+ ((mng_textp)pChunk)->zText, 0, 0);
+ if (!bOke)
+ MNG_ERROR (pData, MNG_APPMISCERROR);
+ }
+
+ return MNG_NOERROR; /* done */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_zTXt
+MNG_C_SPECIALFUNC (mng_special_ztxt)
+{
+ if (pData->fProcesstext) /* inform the application ? */
+ {
+ mng_bool bOke = pData->fProcesstext ((mng_handle)pData, MNG_TYPE_ZTXT,
+ ((mng_ztxtp)pChunk)->zKeyword,
+ ((mng_ztxtp)pChunk)->zText, 0, 0);
+ if (!bOke)
+ MNG_ERROR (pData, MNG_APPMISCERROR);
+ }
+
+ return MNG_NOERROR; /* done */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_iTXt
+MNG_F_SPECIALFUNC (mng_deflate_itxt)
+{
+ mng_itxtp pITXT = (mng_itxtp)pChunk;
+ mng_uint32 iBufsize = 0;
+ mng_uint8p pBuf = 0;
+ mng_uint32 iTextlen = 0;
+
+ if (pITXT->iCompressionflag) /* decompress the text ? */
+ {
+ mng_retcode iRetcode = mng_inflate_buffer (pData, *ppRawdata, *piRawlen,
+ &pBuf, &iBufsize, &iTextlen);
+
+ if (iRetcode) /* on error bail out */
+ { /* don't forget to drop the temp buffer */
+ MNG_FREEX (pData, pBuf, iBufsize);
+ return iRetcode;
+ }
+
+ MNG_ALLOC (pData, pITXT->zText, iTextlen+1);
+ MNG_COPY (pITXT->zText, pBuf, iTextlen);
+
+ pITXT->iTextsize = iTextlen;
+
+ MNG_FREEX (pData, pBuf, iBufsize);
+
+ } else {
+
+ MNG_ALLOC (pData, pITXT->zText, (*piRawlen)+1);
+ MNG_COPY (pITXT->zText, *ppRawdata, *piRawlen);
+
+ pITXT->iTextsize = *piRawlen;
+ }
+
+ *piRawlen = 0;
+
+ return MNG_NOERROR;
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_iTXt
+MNG_C_SPECIALFUNC (mng_special_itxt)
+{
+ if (pData->fProcesstext) /* inform the application ? */
+ {
+ mng_bool bOke = pData->fProcesstext ((mng_handle)pData, MNG_TYPE_ITXT,
+ ((mng_itxtp)pChunk)->zKeyword,
+ ((mng_itxtp)pChunk)->zText,
+ ((mng_itxtp)pChunk)->zLanguage,
+ ((mng_itxtp)pChunk)->zTranslation);
+ if (!bOke)
+ MNG_ERROR (pData, MNG_APPMISCERROR);
+ }
+
+ return MNG_NOERROR; /* done */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_bKGD
+MNG_C_SPECIALFUNC (mng_special_bkgd)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ mng_imagep pImage = (mng_imagep)pData->pCurrentobj;
+ mng_imagedatap pBuf;
+#endif
+
+#ifdef MNG_INCLUDE_JNG
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR))
+#else
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
+#endif
+ pData->bHasBKGD = MNG_TRUE; /* indicate bKGD available */
+ else
+ pData->bHasglobalBKGD = (mng_bool)!(((mng_bkgdp)pChunk)->bEmpty);
+
+#ifdef MNG_SUPPORT_DISPLAY
+ if (!pImage) /* if no object dump it in obj 0 */
+ pImage = (mng_imagep)pData->pObjzero;
+ pBuf = pImage->pImgbuf; /* address object buffer */
+
+#ifdef MNG_INCLUDE_JNG
+ if (pData->bHasJHDR)
+ {
+ pBuf->bHasBKGD = MNG_TRUE; /* tell the object it's got bKGD now */
+
+ switch (pData->iJHDRcolortype) /* store fields for future reference */
+ {
+ case 8 : ; /* gray */
+ case 12 : { /* graya */
+ pBuf->iBKGDgray = ((mng_bkgdp)pChunk)->iGray;
+ break;
+ }
+ case 10 : ; /* rgb */
+ case 14 : { /* rgba */
+ pBuf->iBKGDred = ((mng_bkgdp)pChunk)->iRed;
+ pBuf->iBKGDgreen = ((mng_bkgdp)pChunk)->iGreen;
+ pBuf->iBKGDblue = ((mng_bkgdp)pChunk)->iBlue;
+ break;
+ }
+ }
+ }
+ else
+#endif /* MNG_INCLUDE_JNG */
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
+ {
+ pBuf->bHasBKGD = MNG_TRUE; /* tell the object it's got bKGD now */
+
+ switch (pData->iColortype) /* store fields for future reference */
+ {
+ case 0 : ; /* gray */
+ case 4 : { /* graya */
+ pBuf->iBKGDgray = ((mng_bkgdp)pChunk)->iGray;
+ break;
+ }
+ case 2 : ; /* rgb */
+ case 6 : { /* rgba */
+ pBuf->iBKGDred = ((mng_bkgdp)pChunk)->iRed;
+ pBuf->iBKGDgreen = ((mng_bkgdp)pChunk)->iGreen;
+ pBuf->iBKGDblue = ((mng_bkgdp)pChunk)->iBlue;
+ break;
+ }
+ case 3 : { /* indexed */
+ pBuf->iBKGDindex = ((mng_bkgdp)pChunk)->iIndex;
+ break;
+ }
+ }
+ }
+ else /* store as global */
+ {
+ if (!(((mng_bkgdp)pChunk)->bEmpty))
+ {
+ pData->iGlobalBKGDred = ((mng_bkgdp)pChunk)->iRed;
+ pData->iGlobalBKGDgreen = ((mng_bkgdp)pChunk)->iGreen;
+ pData->iGlobalBKGDblue = ((mng_bkgdp)pChunk)->iBlue;
+ }
+ /* create an animation object */
+ return mng_create_ani_bkgd (pData);
+ }
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ return MNG_NOERROR; /* done */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_pHYs
+MNG_C_SPECIALFUNC (mng_special_phys)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ {
+
+
+ /* TODO: something !!! */
+
+
+ }
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ return MNG_NOERROR; /* done */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_sBIT
+MNG_C_SPECIALFUNC (mng_special_sbit)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ {
+
+
+ /* TODO: something !!! */
+
+
+ }
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ return MNG_NOERROR; /* done */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_sPLT
+MNG_F_SPECIALFUNC (mng_splt_entries)
+{
+ mng_spltp pSPLT = (mng_spltp)pChunk;
+ mng_uint32 iRawlen = *piRawlen;
+ mng_uint8p pRawdata = *ppRawdata;
+
+ if ((pSPLT->iSampledepth != MNG_BITDEPTH_8 ) &&
+ (pSPLT->iSampledepth != MNG_BITDEPTH_16) )
+ MNG_ERROR (pData, MNG_INVSAMPLEDEPTH);
+ /* check remaining length */
+ if ( ((pSPLT->iSampledepth == MNG_BITDEPTH_8 ) && (iRawlen % 6 != 0)) ||
+ ((pSPLT->iSampledepth == MNG_BITDEPTH_16) && (iRawlen % 10 != 0)) )
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+
+ if (pSPLT->iSampledepth == MNG_BITDEPTH_8)
+ pSPLT->iEntrycount = iRawlen / 6;
+ else
+ pSPLT->iEntrycount = iRawlen / 10;
+
+ if (iRawlen)
+ {
+ MNG_ALLOC (pData, pSPLT->pEntries, iRawlen);
+ MNG_COPY (pSPLT->pEntries, pRawdata, iRawlen);
+ }
+
+ *piRawlen = 0;
+
+ return MNG_NOERROR;
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_sPLT
+MNG_C_SPECIALFUNC (mng_special_splt)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ {
+
+
+ /* TODO: something !!! */
+
+
+ }
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ return MNG_NOERROR; /* done */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_hIST
+MNG_F_SPECIALFUNC (mng_hist_entries)
+{
+ mng_histp pHIST = (mng_histp)pChunk;
+ mng_uint32 iRawlen = *piRawlen;
+ mng_uint8p pRawdata = *ppRawdata;
+ mng_uint32 iX;
+
+ if ( ((iRawlen & 0x01) != 0) || ((iRawlen >> 1) != pData->iPLTEcount) )
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+
+ pHIST->iEntrycount = iRawlen >> 1;
+
+ for (iX = 0; iX < pHIST->iEntrycount; iX++)
+ {
+ pHIST->aEntries[iX] = mng_get_uint16 (pRawdata);
+ pRawdata += 2;
+ }
+
+ *piRawlen = 0;
+
+ return MNG_NOERROR;
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_hIST
+MNG_C_SPECIALFUNC (mng_special_hist)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ {
+
+
+ /* TODO: something !!! */
+
+
+ }
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ return MNG_NOERROR; /* done */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_tIME
+MNG_C_SPECIALFUNC (mng_special_time)
+{
+/* if (pData->fProcesstime) */ /* inform the application ? */
+/* {
+
+ pData->fProcesstime ((mng_handle)pData, );
+ } */
+
+ return MNG_NOERROR; /* done */
+}
+#endif
+
+/* ************************************************************************** */
+/* ************************************************************************** */
+/* JNG chunks */
+
+#ifdef MNG_INCLUDE_JNG
+MNG_C_SPECIALFUNC (mng_special_jhdr)
+{
+ if ((pData->eSigtype == mng_it_jng) && (pData->iChunkseq > 1))
+ MNG_ERROR (pData, MNG_SEQUENCEERROR);
+ /* inside a JHDR-IEND block now */
+ pData->bHasJHDR = MNG_TRUE;
+ /* and store interesting fields */
+ pData->iDatawidth = ((mng_jhdrp)pChunk)->iWidth;
+ pData->iDataheight = ((mng_jhdrp)pChunk)->iHeight;
+ pData->iJHDRcolortype = ((mng_jhdrp)pChunk)->iColortype;
+ pData->iJHDRimgbitdepth = ((mng_jhdrp)pChunk)->iImagesampledepth;
+ pData->iJHDRimgcompression = ((mng_jhdrp)pChunk)->iImagecompression;
+ pData->iJHDRimginterlace = ((mng_jhdrp)pChunk)->iImageinterlace;
+ pData->iJHDRalphabitdepth = ((mng_jhdrp)pChunk)->iAlphasampledepth;
+ pData->iJHDRalphacompression = ((mng_jhdrp)pChunk)->iAlphacompression;
+ pData->iJHDRalphafilter = ((mng_jhdrp)pChunk)->iAlphafilter;
+ pData->iJHDRalphainterlace = ((mng_jhdrp)pChunk)->iAlphainterlace;
+
+#if defined(MNG_NO_1_2_4BIT_SUPPORT) || defined(MNG_NO_16BIT_SUPPORT)
+ pData->iPNGmult = 1;
+ pData->iPNGdepth = pData->iJHDRalphabitdepth;
+#endif
+
+#ifdef MNG_NO_1_2_4BIT_SUPPORT
+ if (pData->iJHDRalphabitdepth < 8)
+ pData->iJHDRalphabitdepth = 8;
+#endif
+
+#ifdef MNG_NO_16BIT_SUPPORT
+ if (pData->iJHDRalphabitdepth > 8)
+ {
+ pData->iPNGmult = 2;
+ pData->iJHDRalphabitdepth = 8;
+ }
+#endif
+ /* parameter validity checks */
+ if ((pData->iJHDRcolortype != MNG_COLORTYPE_JPEGGRAY ) &&
+ (pData->iJHDRcolortype != MNG_COLORTYPE_JPEGCOLOR ) &&
+ (pData->iJHDRcolortype != MNG_COLORTYPE_JPEGGRAYA ) &&
+ (pData->iJHDRcolortype != MNG_COLORTYPE_JPEGCOLORA) )
+ MNG_ERROR (pData, MNG_INVALIDCOLORTYPE);
+
+ if ((pData->iJHDRimgbitdepth != MNG_BITDEPTH_JPEG8 ) &&
+ (pData->iJHDRimgbitdepth != MNG_BITDEPTH_JPEG12 ) &&
+ (pData->iJHDRimgbitdepth != MNG_BITDEPTH_JPEG8AND12) )
+ MNG_ERROR (pData, MNG_INVALIDBITDEPTH);
+
+ if ((pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA ) ||
+ (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) )
+ {
+ if ((pData->iJHDRalphabitdepth != MNG_BITDEPTH_8 )
+#ifndef MNG_NO_1_2_4BIT_SUPPORT
+ && (pData->iJHDRalphabitdepth != MNG_BITDEPTH_1 ) &&
+ (pData->iJHDRalphabitdepth != MNG_BITDEPTH_2 ) &&
+ (pData->iJHDRalphabitdepth != MNG_BITDEPTH_4 )
+#endif
+#ifndef MNG_NO_16BIT_SUPPORT
+ && (pData->iJHDRalphabitdepth != MNG_BITDEPTH_16)
+#endif
+ )
+ MNG_ERROR (pData, MNG_INVALIDBITDEPTH);
+
+ if ((pData->iJHDRalphacompression != MNG_COMPRESSION_DEFLATE ) &&
+ (pData->iJHDRalphacompression != MNG_COMPRESSION_BASELINEJPEG) )
+ MNG_ERROR (pData, MNG_INVALIDCOMPRESS);
+
+ if ((pData->iJHDRalphacompression == MNG_COMPRESSION_BASELINEJPEG) &&
+ (pData->iJHDRalphabitdepth != MNG_BITDEPTH_8 ) )
+ MNG_ERROR (pData, MNG_INVALIDBITDEPTH);
+
+#if defined(FILTER192) || defined(FILTER193)
+ if ((pData->iJHDRalphafilter != MNG_FILTER_ADAPTIVE ) &&
+#if defined(FILTER192) && defined(FILTER193)
+ (pData->iJHDRalphafilter != MNG_FILTER_DIFFERING) &&
+ (pData->iJHDRalphafilter != MNG_FILTER_NOFILTER ) )
+#else
+#ifdef FILTER192
+ (pData->iJHDRalphafilter != MNG_FILTER_DIFFERING) )
+#else
+ (pData->iJHDRalphafilter != MNG_FILTER_NOFILTER ) )
+#endif
+#endif
+ MNG_ERROR (pData, MNG_INVALIDFILTER);
+#else
+ if (pData->iJHDRalphafilter)
+ MNG_ERROR (pData, MNG_INVALIDFILTER);
+#endif
+
+ }
+ else
+ {
+ if (pData->iJHDRalphabitdepth)
+ MNG_ERROR (pData, MNG_INVALIDBITDEPTH);
+ if (pData->iJHDRalphacompression)
+ MNG_ERROR (pData, MNG_INVALIDCOMPRESS);
+ if (pData->iJHDRalphafilter)
+ MNG_ERROR (pData, MNG_INVALIDFILTER);
+ if (pData->iJHDRalphainterlace)
+ MNG_ERROR (pData, MNG_INVALIDINTERLACE);
+ }
+
+ if (!pData->bHasheader) /* first chunk ? */
+ {
+ pData->bHasheader = MNG_TRUE; /* we've got a header */
+ pData->eImagetype = mng_it_jng; /* then this must be a JNG */
+ pData->iWidth = ((mng_jhdrp)pChunk)->iWidth;
+ pData->iHeight = ((mng_jhdrp)pChunk)->iHeight;
+ /* predict alpha-depth ! */
+ if ((pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA ) ||
+ (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) )
+ pData->iAlphadepth = pData->iJHDRalphabitdepth;
+ else
+ pData->iAlphadepth = 0;
+ /* fits on maximum canvas ? */
+ if ((pData->iWidth > pData->iMaxwidth) || (pData->iHeight > pData->iMaxheight))
+ MNG_WARNING (pData, MNG_IMAGETOOLARGE);
+
+ if (pData->fProcessheader) /* inform the app ? */
+ if (!pData->fProcessheader (((mng_handle)pData), pData->iWidth, pData->iHeight))
+ MNG_ERROR (pData, MNG_APPMISCERROR);
+
+ }
+
+ pData->iColortype = 0; /* fake grayscale for other routines */
+ pData->iImagelevel++; /* one level deeper */
+
+#ifdef MNG_SUPPORT_DISPLAY
+ {
+ mng_retcode iRetcode = mng_process_display_jhdr (pData);
+ if (iRetcode) /* on error bail out */
+ return iRetcode;
+ }
+#endif /* MNG_SUPPORT_DISPLAY */
+
+#ifdef MNG_NO_16BIT_SUPPORT
+ if (((mng_jhdrp)pChunk)->iAlphasampledepth > 8)
+ ((mng_jhdrp)pChunk)->iAlphasampledepth = 8;
+#endif
+
+ return MNG_NOERROR; /* done */
+}
+#endif /* MNG_INCLUDE_JNG */
+
+/* ************************************************************************** */
+
+#ifdef MNG_INCLUDE_JNG
+MNG_C_SPECIALFUNC (mng_special_jdaa)
+{
+ if (pData->iJHDRalphacompression != MNG_COMPRESSION_BASELINEJPEG)
+ MNG_ERROR (pData, MNG_SEQUENCEERROR);
+
+ pData->bHasJDAA = MNG_TRUE; /* got some JDAA now, don't we */
+ return MNG_NOERROR;
+}
+#endif /* MNG_INCLUDE_JNG */
+
+/* ************************************************************************** */
+
+#ifdef MNG_INCLUDE_JNG
+MNG_C_SPECIALFUNC (mng_special_jdat)
+{
+ pData->bHasJDAT = MNG_TRUE; /* got some JDAT now, don't we */
+ return MNG_NOERROR;
+}
+#endif /* MNG_INCLUDE_JNG */
+
+/* ************************************************************************** */
+
+#ifdef MNG_INCLUDE_JNG
+MNG_C_SPECIALFUNC (mng_special_jsep)
+{
+ pData->bHasJSEP = MNG_TRUE; /* indicate we've had the 8-/12-bit separator */
+ return MNG_NOERROR;
+}
+#endif /* MNG_INCLUDE_JNG */
+
+/* ************************************************************************** */
+/* ************************************************************************** */
+/* MNG chunks */
+
+MNG_C_SPECIALFUNC (mng_special_mhdr)
+{
+ if (pData->bHasheader) /* can only be the first chunk! */
+ MNG_ERROR (pData, MNG_SEQUENCEERROR);
+
+ pData->bHasMHDR = MNG_TRUE; /* oh boy, a real MNG */
+ pData->bHasheader = MNG_TRUE; /* we've got a header */
+ pData->eImagetype = mng_it_mng; /* fill header fields */
+ pData->iWidth = ((mng_mhdrp)pChunk)->iWidth;
+ pData->iHeight = ((mng_mhdrp)pChunk)->iHeight;
+ pData->iTicks = ((mng_mhdrp)pChunk)->iTicks;
+ pData->iLayercount = ((mng_mhdrp)pChunk)->iLayercount;
+ pData->iFramecount = ((mng_mhdrp)pChunk)->iFramecount;
+ pData->iPlaytime = ((mng_mhdrp)pChunk)->iPlaytime;
+ pData->iSimplicity = ((mng_mhdrp)pChunk)->iSimplicity;
+#ifndef MNG_NO_OLD_VERSIONS
+ pData->bPreDraft48 = MNG_FALSE;
+#endif
+ /* predict alpha-depth */
+ if ((pData->iSimplicity & 0x00000001) == 0)
+#ifndef MNG_NO_16BIT_SUPPORT
+ pData->iAlphadepth = 16; /* no indicators = assume the worst */
+#else
+ pData->iAlphadepth = 8; /* anything else = assume the worst */
+#endif
+ else
+ if ((pData->iSimplicity & 0x00000008) == 0)
+ pData->iAlphadepth = 0; /* no transparency at all */
+ else
+ if ((pData->iSimplicity & 0x00000140) == 0x00000040)
+ pData->iAlphadepth = 1; /* no semi-transparency guaranteed */
+ else
+#ifndef MNG_NO_16BIT_SUPPORT
+ pData->iAlphadepth = 16; /* anything else = assume the worst */
+#else
+ pData->iAlphadepth = 8; /* anything else = assume the worst */
+#endif
+
+#ifdef MNG_INCLUDE_JNG /* can we handle the complexity ? */
+ if (pData->iSimplicity & 0x0000FC00)
+#else
+ if (pData->iSimplicity & 0x0000FC10)
+#endif
+ MNG_ERROR (pData, MNG_MNGTOOCOMPLEX);
+ /* fits on maximum canvas ? */
+ if ((pData->iWidth > pData->iMaxwidth) || (pData->iHeight > pData->iMaxheight))
+ MNG_WARNING (pData, MNG_IMAGETOOLARGE);
+
+ if (pData->fProcessheader) /* inform the app ? */
+ if (!pData->fProcessheader (((mng_handle)pData), pData->iWidth, pData->iHeight))
+ MNG_ERROR (pData, MNG_APPMISCERROR);
+
+ pData->iImagelevel++; /* one level deeper */
+
+ return MNG_NOERROR; /* done */
+}
+
+/* ************************************************************************** */
+
+MNG_C_SPECIALFUNC (mng_special_mend)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ { /* do something */
+ mng_retcode iRetcode = mng_process_display_mend (pData);
+
+ if (iRetcode) /* on error bail out */
+ return iRetcode;
+
+ if (!pData->iTotalframes) /* save totals */
+ pData->iTotalframes = pData->iFrameseq;
+ if (!pData->iTotallayers)
+ pData->iTotallayers = pData->iLayerseq;
+ if (!pData->iTotalplaytime)
+ pData->iTotalplaytime = pData->iFrametime;
+ }
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ pData->bHasMHDR = MNG_FALSE; /* end of the line, bro! */
+
+ return MNG_NOERROR; /* done */
+}
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_LOOP
+MNG_F_SPECIALFUNC (mng_debunk_loop)
+{
+ mng_loopp pLOOP = (mng_loopp)pChunk;
+ mng_uint32 iRawlen = *piRawlen;
+ mng_uint8p pRawdata = *ppRawdata;
+
+ if (iRawlen >= 5) /* length checks */
+ {
+ if (iRawlen >= 6)
+ {
+ if ((iRawlen - 6) % 4 != 0)
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+ }
+ }
+ else
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+
+ if (iRawlen >= 5) /* store the fields */
+ {
+ pLOOP->iLevel = *pRawdata;
+
+#ifndef MNG_NO_OLD_VERSIONS
+ if (pData->bPreDraft48)
+ {
+ pLOOP->iTermination = *(pRawdata+1);
+ pLOOP->iRepeat = mng_get_uint32 (pRawdata+2);
+ }
+ else
+#endif
+ {
+ pLOOP->iRepeat = mng_get_uint32 (pRawdata+1);
+ }
+
+ if (iRawlen >= 6)
+ {
+#ifndef MNG_NO_OLD_VERSIONS
+ if (!pData->bPreDraft48)
+#endif
+ pLOOP->iTermination = *(pRawdata+5);
+
+ if (iRawlen >= 10)
+ {
+ pLOOP->iItermin = mng_get_uint32 (pRawdata+6);
+
+#ifndef MNG_NO_LOOP_SIGNALS_SUPPORTED
+ if (iRawlen >= 14)
+ {
+ pLOOP->iItermax = mng_get_uint32 (pRawdata+10);
+ pLOOP->iCount = (iRawlen - 14) / 4;
+
+ if (pLOOP->iCount)
+ {
+ MNG_ALLOC (pData, pLOOP->pSignals, pLOOP->iCount << 2);
+
+#ifndef MNG_BIGENDIAN_SUPPORTED
+ {
+ mng_uint32 iX;
+ mng_uint8p pIn = pRawdata + 14;
+ mng_uint32p pOut = (mng_uint32p)pLOOP->pSignals;
+
+ for (iX = 0; iX < pLOOP->iCount; iX++)
+ {
+ *pOut++ = mng_get_uint32 (pIn);
+ pIn += 4;
+ }
+ }
+#else
+ MNG_COPY (pLOOP->pSignals, pRawdata + 14, pLOOP->iCount << 2);
+#endif /* !MNG_BIGENDIAN_SUPPORTED */
+ }
+ }
+#endif
+ }
+ }
+ }
+
+ *piRawlen = 0;
+
+ return MNG_NOERROR;
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_LOOP
+MNG_C_SPECIALFUNC (mng_special_loop)
+{
+ if (!pData->bCacheplayback) /* must store playback info to work!! */
+ MNG_ERROR (pData, MNG_LOOPWITHCACHEOFF);
+
+#ifdef MNG_SUPPORT_DISPLAY
+ {
+ mng_retcode iRetcode;
+
+ pData->bHasLOOP = MNG_TRUE; /* indicate we're inside a loop */
+ /* create the LOOP ani-object */
+ iRetcode = mng_create_ani_loop (pData, pChunk);
+ if (iRetcode) /* on error bail out */
+ return iRetcode;
+ /* skip till matching ENDL if iteration=0 */
+ if ((!pData->bSkipping) && (((mng_loopp)pChunk)->iRepeat == 0))
+ pData->bSkipping = MNG_TRUE;
+ }
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ return MNG_NOERROR; /* done */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_LOOP
+MNG_C_SPECIALFUNC (mng_special_endl)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ if (pData->bHasLOOP) /* are we really processing a loop ? */
+ {
+ mng_uint8 iLevel = ((mng_endlp)pChunk)->iLevel;
+ /* create an ENDL animation object */
+ return mng_create_ani_endl (pData, iLevel);
+ }
+ else
+ MNG_ERROR (pData, MNG_NOMATCHINGLOOP);
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ return MNG_NOERROR; /* done */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_DEFI
+MNG_C_SPECIALFUNC (mng_special_defi)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ mng_retcode iRetcode;
+
+ pData->iDEFIobjectid = ((mng_defip)pChunk)->iObjectid;
+ pData->bDEFIhasdonotshow = ((mng_defip)pChunk)->bHasdonotshow;
+ pData->iDEFIdonotshow = ((mng_defip)pChunk)->iDonotshow;
+ pData->bDEFIhasconcrete = ((mng_defip)pChunk)->bHasconcrete;
+ pData->iDEFIconcrete = ((mng_defip)pChunk)->iConcrete;
+ pData->bDEFIhasloca = ((mng_defip)pChunk)->bHasloca;
+ pData->iDEFIlocax = ((mng_defip)pChunk)->iXlocation;
+ pData->iDEFIlocay = ((mng_defip)pChunk)->iYlocation;
+ pData->bDEFIhasclip = ((mng_defip)pChunk)->bHasclip;
+ pData->iDEFIclipl = ((mng_defip)pChunk)->iLeftcb;
+ pData->iDEFIclipr = ((mng_defip)pChunk)->iRightcb;
+ pData->iDEFIclipt = ((mng_defip)pChunk)->iTopcb;
+ pData->iDEFIclipb = ((mng_defip)pChunk)->iBottomcb;
+ /* create an animation object */
+ iRetcode = mng_create_ani_defi (pData);
+ if (!iRetcode) /* do display processing */
+ iRetcode = mng_process_display_defi (pData);
+ return iRetcode;
+#else
+ return MNG_NOERROR; /* done */
+#endif /* MNG_SUPPORT_DISPLAY */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_BASI
+MNG_C_SPECIALFUNC (mng_special_basi)
+{
+ pData->bHasBASI = MNG_TRUE; /* inside a BASI-IEND block now */
+ /* store interesting fields */
+ pData->iDatawidth = ((mng_basip)pChunk)->iWidth;
+ pData->iDataheight = ((mng_basip)pChunk)->iHeight;
+ pData->iBitdepth = ((mng_basip)pChunk)->iBitdepth;
+ pData->iColortype = ((mng_basip)pChunk)->iColortype;
+ pData->iCompression = ((mng_basip)pChunk)->iCompression;
+ pData->iFilter = ((mng_basip)pChunk)->iFilter;
+ pData->iInterlace = ((mng_basip)pChunk)->iInterlace;
+
+#if defined(MNG_NO_1_2_4BIT_SUPPORT) || defined(MNG_NO_16BIT_SUPPORT)
+ pData->iPNGmult = 1;
+ pData->iPNGdepth = pData->iBitdepth;
+#endif
+
+#ifdef MNG_NO_1_2_4BIT_SUPPORT
+ if (pData->iBitdepth < 8)
+ pData->iBitdepth = 8;
+#endif
+#ifdef MNG_NO_16BIT_SUPPORT
+ if (pData->iBitdepth > 8)
+ {
+ pData->iBitdepth = 8;
+ pData->iPNGmult = 2;
+ }
+#endif
+
+ if ((pData->iBitdepth != 8) /* parameter validity checks */
+#ifndef MNG_NO_1_2_4BIT_SUPPORT
+ && (pData->iBitdepth != 1) &&
+ (pData->iBitdepth != 2) &&
+ (pData->iBitdepth != 4)
+#endif
+#ifndef MNG_NO_16BIT_SUPPORT
+ && (pData->iBitdepth != 16)
+#endif
+ )
+ MNG_ERROR (pData, MNG_INVALIDBITDEPTH);
+
+ if ((pData->iColortype != MNG_COLORTYPE_GRAY ) &&
+ (pData->iColortype != MNG_COLORTYPE_RGB ) &&
+ (pData->iColortype != MNG_COLORTYPE_INDEXED) &&
+ (pData->iColortype != MNG_COLORTYPE_GRAYA ) &&
+ (pData->iColortype != MNG_COLORTYPE_RGBA ) )
+ MNG_ERROR (pData, MNG_INVALIDCOLORTYPE);
+
+ if ((pData->iColortype == MNG_COLORTYPE_INDEXED) && (pData->iBitdepth > 8))
+ MNG_ERROR (pData, MNG_INVALIDBITDEPTH);
+
+ if (((pData->iColortype == MNG_COLORTYPE_RGB ) ||
+ (pData->iColortype == MNG_COLORTYPE_GRAYA ) ||
+ (pData->iColortype == MNG_COLORTYPE_RGBA ) ) &&
+ (pData->iBitdepth < 8 ) )
+ MNG_ERROR (pData, MNG_INVALIDBITDEPTH);
+
+#if defined(FILTER192) || defined(FILTER193)
+ if ((pData->iFilter != MNG_FILTER_ADAPTIVE ) &&
+#if defined(FILTER192) && defined(FILTER193)
+ (pData->iFilter != MNG_FILTER_DIFFERING) &&
+ (pData->iFilter != MNG_FILTER_NOFILTER ) )
+#else
+#ifdef FILTER192
+ (pData->iFilter != MNG_FILTER_DIFFERING) )
+#else
+ (pData->iFilter != MNG_FILTER_NOFILTER ) )
+#endif
+#endif
+ MNG_ERROR (pData, MNG_INVALIDFILTER);
+#else
+ if (pData->iFilter)
+ MNG_ERROR (pData, MNG_INVALIDFILTER);
+#endif
+
+ pData->iImagelevel++; /* one level deeper */
+
+#ifdef MNG_SUPPORT_DISPLAY
+ { /* create an animation object */
+ mng_retcode iRetcode = mng_create_ani_basi (pData, pChunk);
+ if (iRetcode) /* on error bail out */
+ return iRetcode;
+ }
+#endif /* MNG_SUPPORT_DISPLAY */
+
+#ifdef MNG_NO_16BIT_SUPPORT
+ if (((mng_basip)pChunk)->iBitdepth > 8)
+ ((mng_basip)pChunk)->iBitdepth = 8;
+#endif
+
+ return MNG_NOERROR; /* done */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_CLON
+MNG_C_SPECIALFUNC (mng_special_clon)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ return mng_create_ani_clon (pData, pChunk);
+#else
+ return MNG_NOERROR; /* done */
+#endif /* MNG_SUPPORT_DISPLAY */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_PAST
+MNG_F_SPECIALFUNC (mng_debunk_past)
+{
+ mng_pastp pPAST = (mng_pastp)pChunk;
+ mng_uint32 iRawlen = *piRawlen;
+ mng_uint8p pRawdata = *ppRawdata;
+ mng_uint32 iSize;
+ mng_uint32 iX;
+ mng_past_sourcep pSource;
+ /* check the length */
+ if ((iRawlen < 41) || (((iRawlen - 11) % 30) != 0))
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+
+ pPAST->iDestid = mng_get_uint16 (pRawdata);
+ pPAST->iTargettype = *(pRawdata+2);
+ pPAST->iTargetx = mng_get_int32 (pRawdata+3);
+ pPAST->iTargety = mng_get_int32 (pRawdata+7);
+ pPAST->iCount = ((iRawlen - 11) / 30); /* how many entries again? */
+ iSize = pPAST->iCount * sizeof (mng_past_source);
+
+ pRawdata += 11;
+ /* get a buffer for all the source blocks */
+ MNG_ALLOC (pData, pPAST->pSources, iSize);
+
+ pSource = (mng_past_sourcep)(pPAST->pSources);
+
+ for (iX = pPAST->iCount; iX > 0; iX--)
+ { /* now copy the source blocks */
+ pSource->iSourceid = mng_get_uint16 (pRawdata);
+ pSource->iComposition = *(pRawdata+2);
+ pSource->iOrientation = *(pRawdata+3);
+ pSource->iOffsettype = *(pRawdata+4);
+ pSource->iOffsetx = mng_get_int32 (pRawdata+5);
+ pSource->iOffsety = mng_get_int32 (pRawdata+9);
+ pSource->iBoundarytype = *(pRawdata+13);
+ pSource->iBoundaryl = mng_get_int32 (pRawdata+14);
+ pSource->iBoundaryr = mng_get_int32 (pRawdata+18);
+ pSource->iBoundaryt = mng_get_int32 (pRawdata+22);
+ pSource->iBoundaryb = mng_get_int32 (pRawdata+26);
+
+ pSource++;
+ pRawdata += 30;
+ }
+
+ *piRawlen = 0;
+
+ return MNG_NOERROR;
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_PAST
+MNG_C_SPECIALFUNC (mng_special_past)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ return mng_create_ani_past (pData, pChunk);
+#else
+ return MNG_NOERROR;
+#endif /* MNG_SUPPORT_DISPLAY */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_DISC
+MNG_F_SPECIALFUNC (mng_disc_entries)
+{
+ mng_discp pDISC = (mng_discp)pChunk;
+ mng_uint32 iRawlen = *piRawlen;
+ mng_uint8p pRawdata = *ppRawdata;
+
+ if ((iRawlen % 2) != 0) /* check the length */
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+
+ pDISC->iCount = (iRawlen / sizeof (mng_uint16));
+
+ if (pDISC->iCount)
+ {
+ MNG_ALLOC (pData, pDISC->pObjectids, iRawlen);
+
+#ifndef MNG_BIGENDIAN_SUPPORTED
+ {
+ mng_uint32 iX;
+ mng_uint8p pIn = pRawdata;
+ mng_uint16p pOut = pDISC->pObjectids;
+
+ for (iX = pDISC->iCount; iX > 0; iX--)
+ {
+ *pOut++ = mng_get_uint16 (pIn);
+ pIn += 2;
+ }
+ }
+#else
+ MNG_COPY (pDISC->pObjectids, pRawdata, iRawlen);
+#endif /* !MNG_BIGENDIAN_SUPPORTED */
+ }
+
+ *piRawlen = 0;
+
+ return MNG_NOERROR;
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_DISC
+MNG_C_SPECIALFUNC (mng_special_disc)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ return mng_create_ani_disc (pData, pChunk);
+#else
+ return MNG_NOERROR;
+#endif /* MNG_SUPPORT_DISPLAY */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_BACK
+MNG_C_SPECIALFUNC (mng_special_back)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ /* retrieve the fields */
+ pData->bHasBACK = MNG_TRUE;
+ pData->iBACKred = ((mng_backp)pChunk)->iRed;
+ pData->iBACKgreen = ((mng_backp)pChunk)->iGreen;
+ pData->iBACKblue = ((mng_backp)pChunk)->iBlue;
+ pData->iBACKmandatory = ((mng_backp)pChunk)->iMandatory;
+ pData->iBACKimageid = ((mng_backp)pChunk)->iImageid;
+ pData->iBACKtile = ((mng_backp)pChunk)->iTile;
+
+ return mng_create_ani_back (pData);
+#else
+ return MNG_NOERROR;
+#endif /* MNG_SUPPORT_DISPLAY */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_FRAM
+MNG_F_SPECIALFUNC (mng_fram_remainder)
+{
+ mng_framp pFRAM = (mng_framp)pChunk;
+ mng_uint32 iRawlen = *piRawlen;
+ mng_uint8p pRawdata = *ppRawdata;
+ mng_uint32 iRequired = 0;
+
+ if (iRawlen < 4) /* must have at least 4 bytes */
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+
+ iRequired = 4; /* calculate and check required remaining length */
+
+ pFRAM->iChangedelay = *pRawdata;
+ pFRAM->iChangetimeout = *(pRawdata+1);
+ pFRAM->iChangeclipping = *(pRawdata+2);
+ pFRAM->iChangesyncid = *(pRawdata+3);
+
+ if (pFRAM->iChangedelay ) { iRequired += 4; }
+ if (pFRAM->iChangetimeout ) { iRequired += 4; }
+ if (pFRAM->iChangeclipping) { iRequired += 17; }
+
+ if (pFRAM->iChangesyncid)
+ {
+ if ((iRawlen - iRequired) % 4 != 0)
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+ }
+ else
+ {
+ if (iRawlen != iRequired)
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+ }
+
+ pRawdata += 4;
+
+ if (pFRAM->iChangedelay) /* delay changed ? */
+ {
+ pFRAM->iDelay = mng_get_uint32 (pRawdata);
+ pRawdata += 4;
+ }
+
+ if (pFRAM->iChangetimeout) /* timeout changed ? */
+ {
+ pFRAM->iTimeout = mng_get_uint32 (pRawdata);
+ pRawdata += 4;
+ }
+
+ if (pFRAM->iChangeclipping) /* clipping changed ? */
+ {
+ pFRAM->iBoundarytype = *pRawdata;
+ pFRAM->iBoundaryl = mng_get_int32 (pRawdata+1);
+ pFRAM->iBoundaryr = mng_get_int32 (pRawdata+5);
+ pFRAM->iBoundaryt = mng_get_int32 (pRawdata+9);
+ pFRAM->iBoundaryb = mng_get_int32 (pRawdata+13);
+ pRawdata += 17;
+ }
+
+ if (pFRAM->iChangesyncid)
+ {
+ pFRAM->iCount = (iRawlen - iRequired) / 4;
+
+ if (pFRAM->iCount)
+ {
+ MNG_ALLOC (pData, pFRAM->pSyncids, pFRAM->iCount * 4);
+
+#ifndef MNG_BIGENDIAN_SUPPORTED
+ {
+ mng_uint32 iX;
+ mng_uint32p pOut = pFRAM->pSyncids;
+
+ for (iX = pFRAM->iCount; iX > 0; iX--)
+ {
+ *pOut++ = mng_get_uint32 (pRawdata);
+ pRawdata += 4;
+ }
+ }
+#else
+ MNG_COPY (pFRAM->pSyncids, pRawdata, pFRAM->iCount * 4);
+#endif /* !MNG_BIGENDIAN_SUPPORTED */
+ }
+ }
+
+#ifndef MNG_NO_OLD_VERSIONS
+ if (pData->bPreDraft48) /* old style input-stream ? */
+ {
+ switch (pFRAM->iMode) /* fix the framing mode then */
+ {
+ case 0: { break; }
+ case 1: { pFRAM->iMode = 3; break; }
+ case 2: { pFRAM->iMode = 4; break; }
+ case 3: { pFRAM->iMode = 1; break; }
+ case 4: { pFRAM->iMode = 1; break; }
+ case 5: { pFRAM->iMode = 2; break; }
+ default: { pFRAM->iMode = 1; break; }
+ }
+ }
+#endif
+
+ *piRawlen = 0;
+
+ return MNG_NOERROR;
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_FRAM
+MNG_C_SPECIALFUNC (mng_special_fram)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ return mng_create_ani_fram (pData, pChunk);
+#else
+ return MNG_NOERROR;
+#endif /* MNG_SUPPORT_DISPLAY */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_MOVE
+MNG_C_SPECIALFUNC (mng_special_move)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ return mng_create_ani_move (pData, pChunk);
+#else
+ return MNG_NOERROR;
+#endif /* MNG_SUPPORT_DISPLAY */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_CLIP
+MNG_C_SPECIALFUNC (mng_special_clip)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ return mng_create_ani_clip (pData, pChunk);
+#else
+ return MNG_NOERROR;
+#endif /* MNG_SUPPORT_DISPLAY */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_SHOW
+MNG_C_SPECIALFUNC (mng_special_show)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ mng_retcode iRetcode;
+
+ if (!((mng_showp)pChunk)->bEmpty) /* any data ? */
+ {
+ if (!((mng_showp)pChunk)->bHaslastid)
+ ((mng_showp)pChunk)->iLastid = ((mng_showp)pChunk)->iFirstid;
+
+ pData->iSHOWfromid = ((mng_showp)pChunk)->iFirstid;
+ pData->iSHOWtoid = ((mng_showp)pChunk)->iLastid;
+ pData->iSHOWmode = ((mng_showp)pChunk)->iMode;
+ }
+ else /* use defaults then */
+ {
+ pData->iSHOWfromid = 1;
+ pData->iSHOWtoid = 65535;
+ pData->iSHOWmode = 2;
+ }
+ /* create a SHOW animation object */
+ iRetcode = mng_create_ani_show (pData);
+ if (!iRetcode) /* go and do it! */
+ iRetcode = mng_process_display_show (pData);
+
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ return iRetcode;
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_TERM
+MNG_C_SPECIALFUNC (mng_special_term)
+{
+ /* should be behind MHDR or SAVE !! */
+ if ((!pData->bHasSAVE) && (pData->iChunkseq > 2))
+ {
+ pData->bMisplacedTERM = MNG_TRUE; /* indicate we found a misplaced TERM */
+ /* and send a warning signal!!! */
+ MNG_WARNING (pData, MNG_SEQUENCEERROR);
+ }
+
+ pData->bHasTERM = MNG_TRUE;
+
+ if (pData->fProcessterm) /* inform the app ? */
+ if (!pData->fProcessterm (((mng_handle)pData),
+ ((mng_termp)pChunk)->iTermaction,
+ ((mng_termp)pChunk)->iIteraction,
+ ((mng_termp)pChunk)->iDelay,
+ ((mng_termp)pChunk)->iItermax))
+ MNG_ERROR (pData, MNG_APPMISCERROR);
+
+#ifdef MNG_SUPPORT_DISPLAY
+ { /* create the TERM ani-object */
+ mng_retcode iRetcode = mng_create_ani_term (pData, pChunk);
+ if (iRetcode) /* on error bail out */
+ return iRetcode;
+ /* save for future reference */
+ pData->pTermaniobj = pData->pLastaniobj;
+ }
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ return MNG_NOERROR; /* done */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_SAVE
+MNG_F_SPECIALFUNC (mng_save_entries)
+{
+ mng_savep pSAVE = (mng_savep)pChunk;
+ mng_uint32 iRawlen = *piRawlen;
+ mng_uint8p pRawdata = *ppRawdata;
+ mng_save_entryp pEntry = MNG_NULL;
+ mng_uint32 iCount = 0;
+ mng_uint8 iOtype = *pRawdata;
+ mng_uint8 iEtype;
+ mng_uint8p pTemp;
+ mng_uint8p pNull;
+ mng_uint32 iLen;
+ mng_uint32 iOffset[2];
+ mng_uint32 iStarttime[2];
+ mng_uint32 iFramenr;
+ mng_uint32 iLayernr;
+ mng_uint32 iX;
+ mng_uint32 iNamesize;
+
+ if ((iOtype != 4) && (iOtype != 8))
+ MNG_ERROR (pData, MNG_INVOFFSETSIZE);
+
+ pSAVE->iOffsettype = iOtype;
+
+ for (iX = 0; iX < 2; iX++) /* do this twice to get the count first ! */
+ {
+ pTemp = pRawdata + 1;
+ iLen = iRawlen - 1;
+
+ if (iX) /* second run ? */
+ {
+ MNG_ALLOC (pData, pEntry, (iCount * sizeof (mng_save_entry)));
+
+ pSAVE->iCount = iCount;
+ pSAVE->pEntries = pEntry;
+ }
+
+ while (iLen) /* anything left ? */
+ {
+ iEtype = *pTemp; /* entrytype */
+
+ if ((iEtype != 0) && (iEtype != 1) && (iEtype != 2) && (iEtype != 3))
+ MNG_ERROR (pData, MNG_INVENTRYTYPE);
+
+ pTemp++;
+
+ if (iEtype > 1)
+ {
+ iOffset [0] = 0;
+ iOffset [1] = 0;
+ iStarttime [0] = 0;
+ iStarttime [1] = 0;
+ iLayernr = 0;
+ iFramenr = 0;
+ }
+ else
+ {
+ if (iOtype == 4)
+ {
+ iOffset [0] = 0;
+ iOffset [1] = mng_get_uint32 (pTemp);
+
+ pTemp += 4;
+ }
+ else
+ {
+ iOffset [0] = mng_get_uint32 (pTemp);
+ iOffset [1] = mng_get_uint32 (pTemp+4);
+
+ pTemp += 8;
+ }
+
+ if (iEtype > 0)
+ {
+ iStarttime [0] = 0;
+ iStarttime [1] = 0;
+ iLayernr = 0;
+ iFramenr = 0;
+ }
+ else
+ {
+ if (iOtype == 4)
+ {
+ iStarttime [0] = 0;
+ iStarttime [1] = mng_get_uint32 (pTemp+0);
+ iLayernr = mng_get_uint32 (pTemp+4);
+ iFramenr = mng_get_uint32 (pTemp+8);
+
+ pTemp += 12;
+ }
+ else
+ {
+ iStarttime [0] = mng_get_uint32 (pTemp+0);
+ iStarttime [1] = mng_get_uint32 (pTemp+4);
+ iLayernr = mng_get_uint32 (pTemp+8);
+ iFramenr = mng_get_uint32 (pTemp+12);
+
+ pTemp += 16;
+ }
+ }
+ }
+
+ pNull = pTemp; /* get the name length */
+ while (*pNull)
+ pNull++;
+
+ if ((pNull - pRawdata) > (mng_int32)iRawlen)
+ {
+ iNamesize = iLen; /* no null found; so end of SAVE */
+ iLen = 0;
+ }
+ else
+ {
+ iNamesize = pNull - pTemp; /* should be another entry */
+ iLen -= iNamesize;
+
+ if (!iLen) /* must not end with a null ! */
+ MNG_ERROR (pData, MNG_ENDWITHNULL);
+ }
+
+ if (!pEntry)
+ {
+ iCount++;
+ }
+ else
+ {
+ pEntry->iEntrytype = iEtype;
+ pEntry->iOffset [0] = iOffset [0];
+ pEntry->iOffset [1] = iOffset [1];
+ pEntry->iStarttime [0] = iStarttime [0];
+ pEntry->iStarttime [1] = iStarttime [1];
+ pEntry->iLayernr = iLayernr;
+ pEntry->iFramenr = iFramenr;
+ pEntry->iNamesize = iNamesize;
+
+ if (iNamesize)
+ {
+ MNG_ALLOC (pData, pEntry->zName, iNamesize+1);
+ MNG_COPY (pEntry->zName, pTemp, iNamesize);
+ }
+
+ pEntry++;
+ }
+
+ pTemp += iNamesize;
+ }
+ }
+
+ *piRawlen = 0;
+
+ return MNG_NOERROR;
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_SAVE
+MNG_C_SPECIALFUNC (mng_special_save)
+{
+ pData->bHasSAVE = MNG_TRUE;
+
+ if (pData->fProcesssave) /* inform the application ? */
+ {
+ mng_bool bOke = pData->fProcesssave ((mng_handle)pData);
+ if (!bOke)
+ MNG_ERROR (pData, MNG_APPMISCERROR);
+ }
+
+#ifdef MNG_SUPPORT_DISPLAY
+ {
+ mng_retcode iRetcode;
+
+ /* TODO: something with the parameters */
+
+ /* create a SAVE animation object */
+ iRetcode = mng_create_ani_save (pData);
+ if (!iRetcode) /* process it */
+ iRetcode = mng_process_display_save (pData);
+ if (iRetcode) /* on error bail out */
+ return iRetcode;
+ }
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ return MNG_NOERROR; /* done */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_SEEK
+MNG_C_SPECIALFUNC (mng_special_seek)
+{
+ mng_retcode iRetcode;
+
+#ifdef MNG_SUPPORT_DISPLAY
+ /* create a SEEK animation object */
+ iRetcode = mng_create_ani_seek (pData, pChunk);
+ if (iRetcode) /* on error bail out */
+ return iRetcode;
+
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ if (pData->fProcessseek) /* inform the app ? */
+ if (!pData->fProcessseek ((mng_handle)pData, ((mng_seekp)pChunk)->zName))
+ MNG_ERROR (pData, MNG_APPMISCERROR);
+
+#ifdef MNG_SUPPORT_DISPLAY
+ return mng_process_display_seek (pData);
+#else
+ return MNG_NOERROR;
+#endif /* MNG_SUPPORT_DISPLAY */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_eXPI
+MNG_C_SPECIALFUNC (mng_special_expi)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ {
+
+
+ /* TODO: something !!! */
+
+
+ }
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ return MNG_NOERROR; /* done */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_fPRI
+MNG_C_SPECIALFUNC (mng_special_fpri)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ {
+
+
+ /* TODO: something !!! */
+
+
+ }
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ return MNG_NOERROR; /* done */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_nEED
+MNG_LOCAL mng_bool CheckKeyword (mng_datap pData,
+ mng_uint8p pKeyword)
+{
+ mng_chunkid handled_chunks [] =
+ {
+ MNG_UINT_BACK, /* keep it sorted !!!! */
+ MNG_UINT_BASI,
+ MNG_UINT_CLIP,
+ MNG_UINT_CLON,
+#ifndef MNG_NO_DELTA_PNG
+/* TODO: MNG_UINT_DBYK, */
+#endif
+ MNG_UINT_DEFI,
+#ifndef MNG_NO_DELTA_PNG
+ MNG_UINT_DHDR,
+#endif
+ MNG_UINT_DISC,
+#ifndef MNG_NO_DELTA_PNG
+/* TODO: MNG_UINT_DROP, */
+#endif
+ MNG_UINT_ENDL,
+ MNG_UINT_FRAM,
+ MNG_UINT_IDAT,
+ MNG_UINT_IEND,
+ MNG_UINT_IHDR,
+#ifndef MNG_NO_DELTA_PNG
+#ifdef MNG_INCLUDE_JNG
+ MNG_UINT_IJNG,
+#endif
+ MNG_UINT_IPNG,
+#endif
+#ifdef MNG_INCLUDE_JNG
+ MNG_UINT_JDAA,
+ MNG_UINT_JDAT,
+ MNG_UINT_JHDR,
+/* TODO: MNG_UINT_JSEP, */
+ MNG_UINT_JdAA,
+#endif
+ MNG_UINT_LOOP,
+ MNG_UINT_MAGN,
+ MNG_UINT_MEND,
+ MNG_UINT_MHDR,
+ MNG_UINT_MOVE,
+/* TODO: MNG_UINT_ORDR, */
+ MNG_UINT_PAST,
+ MNG_UINT_PLTE,
+#ifndef MNG_NO_DELTA_PNG
+ MNG_UINT_PPLT,
+ MNG_UINT_PROM,
+#endif
+ MNG_UINT_SAVE,
+ MNG_UINT_SEEK,
+ MNG_UINT_SHOW,
+ MNG_UINT_TERM,
+ MNG_UINT_bKGD,
+ MNG_UINT_cHRM,
+/* TODO: MNG_UINT_eXPI, */
+ MNG_UINT_evNT,
+/* TODO: MNG_UINT_fPRI, */
+ MNG_UINT_gAMA,
+/* TODO: MNG_UINT_hIST, */
+ MNG_UINT_iCCP,
+ MNG_UINT_iTXt,
+ MNG_UINT_nEED,
+/* TODO: MNG_UINT_oFFs, */
+/* TODO: MNG_UINT_pCAL, */
+/* TODO: MNG_UINT_pHYg, */
+/* TODO: MNG_UINT_pHYs, */
+/* TODO: MNG_UINT_sBIT, */
+/* TODO: MNG_UINT_sCAL, */
+/* TODO: MNG_UINT_sPLT, */
+ MNG_UINT_sRGB,
+ MNG_UINT_tEXt,
+ MNG_UINT_tIME,
+ MNG_UINT_tRNS,
+ MNG_UINT_zTXt,
+ };
+
+ mng_bool bOke = MNG_FALSE;
+
+ if (pData->fProcessneed) /* does the app handle it ? */
+ bOke = pData->fProcessneed ((mng_handle)pData, (mng_pchar)pKeyword);
+
+ if (!bOke)
+ { /* find the keyword length */
+ mng_uint8p pNull = pKeyword;
+ while (*pNull)
+ pNull++;
+
+ if ((pNull - pKeyword) == 4) /* test a chunk ? */
+ { /* get the chunk-id */
+ mng_chunkid iChunkid = (*pKeyword << 24) + (*(pKeyword+1) << 16) +
+ (*(pKeyword+2) << 8) + (*(pKeyword+3) );
+ /* binary search variables */
+ mng_int32 iTop, iLower, iUpper, iMiddle;
+ /* determine max index of table */
+ iTop = (sizeof (handled_chunks) / sizeof (handled_chunks [0])) - 1;
+
+ /* binary search; with 52 chunks, worst-case is 7 comparisons */
+ iLower = 0;
+ iMiddle = iTop >> 1;
+ iUpper = iTop;
+
+ do /* the binary search itself */
+ {
+ if (handled_chunks [iMiddle] < iChunkid)
+ iLower = iMiddle + 1;
+ else if (handled_chunks [iMiddle] > iChunkid)
+ iUpper = iMiddle - 1;
+ else
+ {
+ bOke = MNG_TRUE;
+ break;
+ }
+
+ iMiddle = (iLower + iUpper) >> 1;
+ }
+ while (iLower <= iUpper);
+ }
+ /* test draft ? */
+ if ((!bOke) && ((pNull - pKeyword) == 8) &&
+ (*pKeyword == 'd') && (*(pKeyword+1) == 'r') &&
+ (*(pKeyword+2) == 'a') && (*(pKeyword+3) == 'f') &&
+ (*(pKeyword+4) == 't') && (*(pKeyword+5) == ' '))
+ {
+ mng_uint32 iDraft;
+
+ iDraft = (*(pKeyword+6) - '0') * 10 + (*(pKeyword+7) - '0');
+ bOke = (mng_bool)(iDraft <= MNG_MNG_DRAFT);
+ }
+ /* test MNG 1.0/1.1 ? */
+ if ((!bOke) && ((pNull - pKeyword) == 7) &&
+ (*pKeyword == 'M') && (*(pKeyword+1) == 'N') &&
+ (*(pKeyword+2) == 'G') && (*(pKeyword+3) == '-') &&
+ (*(pKeyword+4) == '1') && (*(pKeyword+5) == '.') &&
+ ((*(pKeyword+6) == '0') || (*(pKeyword+6) == '1')))
+ bOke = MNG_TRUE;
+ /* test CACHEOFF ? */
+ if ((!bOke) && ((pNull - pKeyword) == 8) &&
+ (*pKeyword == 'C') && (*(pKeyword+1) == 'A') &&
+ (*(pKeyword+2) == 'C') && (*(pKeyword+3) == 'H') &&
+ (*(pKeyword+4) == 'E') && (*(pKeyword+5) == 'O') &&
+ (*(pKeyword+6) == 'F') && (*(pKeyword+7) == 'F'))
+ {
+ if (!pData->pFirstaniobj) /* only if caching hasn't started yet ! */
+ {
+ bOke = MNG_TRUE;
+ pData->bCacheplayback = MNG_FALSE;
+ pData->bStorechunks = MNG_FALSE;
+ }
+ }
+ }
+
+ return bOke;
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_nEED
+MNG_C_SPECIALFUNC (mng_special_need)
+{
+ /* let's check it */
+ mng_bool bOke = MNG_TRUE;
+ mng_uint8p pNull, pTemp, pMax;
+
+ pTemp = (mng_uint8p)((mng_needp)pChunk)->zKeywords;
+ pMax = (mng_uint8p)(pTemp + ((mng_needp)pChunk)->iKeywordssize);
+ pNull = pTemp;
+ while (*pNull)
+ pNull++;
+
+ while ((bOke) && (pNull < pMax))
+ {
+ bOke = CheckKeyword (pData, pTemp);
+ pTemp = pNull + 1;
+ pNull = pTemp;
+ while (*pNull)
+ pNull++;
+ }
+
+ if (bOke)
+ bOke = CheckKeyword (pData, pTemp);
+
+ if (!bOke)
+ MNG_ERROR (pData, MNG_UNSUPPORTEDNEED);
+
+ return MNG_NOERROR; /* done */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_pHYg
+MNG_C_SPECIALFUNC (mng_special_phyg)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ {
+
+
+ /* TODO: something !!! */
+
+
+ }
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ return MNG_NOERROR; /* done */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_NO_DELTA_PNG
+MNG_C_SPECIALFUNC (mng_special_dhdr)
+{
+ if ((((mng_dhdrp)pChunk)->iDeltatype == MNG_DELTATYPE_REPLACE) && (((mng_dhdrp)pChunk)->bHasblockloc))
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+ if ((((mng_dhdrp)pChunk)->iDeltatype == MNG_DELTATYPE_NOCHANGE) && (((mng_dhdrp)pChunk)->bHasblocksize))
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+
+ pData->bHasDHDR = MNG_TRUE; /* inside a DHDR-IEND block now */
+ pData->iDeltatype = ((mng_dhdrp)pChunk)->iDeltatype;
+
+ pData->iImagelevel++; /* one level deeper */
+
+#ifdef MNG_SUPPORT_DISPLAY
+ return mng_create_ani_dhdr (pData, pChunk);
+#else
+ return MNG_NOERROR;
+#endif /* MNG_SUPPORT_DISPLAY */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_NO_DELTA_PNG
+MNG_C_SPECIALFUNC (mng_special_prom)
+{
+ if ((((mng_promp)pChunk)->iColortype != MNG_COLORTYPE_GRAY ) &&
+ (((mng_promp)pChunk)->iColortype != MNG_COLORTYPE_RGB ) &&
+ (((mng_promp)pChunk)->iColortype != MNG_COLORTYPE_INDEXED) &&
+ (((mng_promp)pChunk)->iColortype != MNG_COLORTYPE_GRAYA ) &&
+ (((mng_promp)pChunk)->iColortype != MNG_COLORTYPE_RGBA ) )
+ MNG_ERROR (pData, MNG_INVALIDCOLORTYPE);
+
+#ifdef MNG_NO_16BIT_SUPPORT
+ if (((mng_promp)pChunk)->iSampledepth == MNG_BITDEPTH_16 )
+ ((mng_promp)pChunk)->iSampledepth = MNG_BITDEPTH_8;
+#endif
+
+ if ((((mng_promp)pChunk)->iSampledepth != MNG_BITDEPTH_1 ) &&
+ (((mng_promp)pChunk)->iSampledepth != MNG_BITDEPTH_2 ) &&
+ (((mng_promp)pChunk)->iSampledepth != MNG_BITDEPTH_4 ) &&
+ (((mng_promp)pChunk)->iSampledepth != MNG_BITDEPTH_8 )
+#ifndef MNG_NO_16BIT_SUPPORT
+ && (((mng_promp)pChunk)->iSampledepth != MNG_BITDEPTH_16)
+#endif
+ )
+ MNG_ERROR (pData, MNG_INVSAMPLEDEPTH);
+
+#ifdef MNG_SUPPORT_DISPLAY
+ {
+ mng_retcode iRetcode = mng_create_ani_prom (pData, pChunk);
+ if (iRetcode) /* on error bail out */
+ return iRetcode;
+ }
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ return MNG_NOERROR; /* done */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_NO_DELTA_PNG
+MNG_C_SPECIALFUNC (mng_special_ipng)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ mng_retcode iRetcode = mng_create_ani_ipng (pData);
+ if (!iRetcode) /* process it */
+ iRetcode = mng_process_display_ipng (pData);
+ if (iRetcode) /* on error bail out */
+ return iRetcode;
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ return MNG_NOERROR; /* done */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_NO_DELTA_PNG
+MNG_F_SPECIALFUNC (mng_pplt_entries)
+{
+ mng_ppltp pPPLT = (mng_ppltp)pChunk;
+ mng_uint32 iRawlen = *piRawlen;
+ mng_uint8p pRawdata = *ppRawdata;
+ mng_uint8 iDeltatype = pPPLT->iDeltatype;
+ mng_uint32 iMax = 0;
+ mng_int32 iX, iY, iM;
+ mng_rgbpaltab aIndexentries;
+ mng_uint8arr aAlphaentries;
+ mng_uint8arr aUsedentries;
+ /* must be indexed color ! */
+ if (pData->iColortype != MNG_COLORTYPE_INDEXED)
+ MNG_ERROR (pData, MNG_INVALIDCOLORTYPE);
+
+ for (iY = 255; iY >= 0; iY--) /* reset arrays */
+ {
+ aIndexentries [iY].iRed = 0;
+ aIndexentries [iY].iGreen = 0;
+ aIndexentries [iY].iBlue = 0;
+ aAlphaentries [iY] = 255;
+ aUsedentries [iY] = 0;
+ }
+
+ while (iRawlen) /* as long as there are entries left ... */
+ {
+ mng_uint32 iDiff;
+
+ if (iRawlen < 2)
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+
+ iX = (mng_int32)(*pRawdata); /* get start and end index */
+ iM = (mng_int32)(*(pRawdata+1));
+
+ if (iM < iX)
+ MNG_ERROR (pData, MNG_INVALIDINDEX);
+
+ if (iM >= (mng_int32) iMax) /* determine highest used index */
+ iMax = iM + 1;
+
+ pRawdata += 2;
+ iRawlen -= 2;
+ iDiff = (iM - iX + 1);
+ if ((iDeltatype == MNG_DELTATYPE_REPLACERGB ) ||
+ (iDeltatype == MNG_DELTATYPE_DELTARGB ) )
+ iDiff = iDiff * 3;
+ else
+ if ((iDeltatype == MNG_DELTATYPE_REPLACERGBA) ||
+ (iDeltatype == MNG_DELTATYPE_DELTARGBA ) )
+ iDiff = iDiff * 4;
+
+ if (iRawlen < iDiff)
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+
+ if ((iDeltatype == MNG_DELTATYPE_REPLACERGB ) ||
+ (iDeltatype == MNG_DELTATYPE_DELTARGB ) )
+ {
+ for (iY = iX; iY <= iM; iY++)
+ {
+ aIndexentries [iY].iRed = *pRawdata;
+ aIndexentries [iY].iGreen = *(pRawdata+1);
+ aIndexentries [iY].iBlue = *(pRawdata+2);
+ aUsedentries [iY] = 1;
+
+ pRawdata += 3;
+ iRawlen -= 3;
+ }
+ }
+ else
+ if ((iDeltatype == MNG_DELTATYPE_REPLACEALPHA) ||
+ (iDeltatype == MNG_DELTATYPE_DELTAALPHA ) )
+ {
+ for (iY = iX; iY <= iM; iY++)
+ {
+ aAlphaentries [iY] = *pRawdata;
+ aUsedentries [iY] = 1;
+
+ pRawdata++;
+ iRawlen--;
+ }
+ }
+ else
+ {
+ for (iY = iX; iY <= iM; iY++)
+ {
+ aIndexentries [iY].iRed = *pRawdata;
+ aIndexentries [iY].iGreen = *(pRawdata+1);
+ aIndexentries [iY].iBlue = *(pRawdata+2);
+ aAlphaentries [iY] = *(pRawdata+3);
+ aUsedentries [iY] = 1;
+
+ pRawdata += 4;
+ iRawlen -= 4;
+ }
+ }
+ }
+
+ switch (pData->iBitdepth) /* check maximum allowed entries for bitdepth */
+ {
+ case MNG_BITDEPTH_1 : {
+ if (iMax > 2)
+ MNG_ERROR (pData, MNG_INVALIDINDEX);
+ break;
+ }
+ case MNG_BITDEPTH_2 : {
+ if (iMax > 4)
+ MNG_ERROR (pData, MNG_INVALIDINDEX);
+ break;
+ }
+ case MNG_BITDEPTH_4 : {
+ if (iMax > 16)
+ MNG_ERROR (pData, MNG_INVALIDINDEX);
+ break;
+ }
+ }
+
+ pPPLT->iCount = iMax;
+
+ for (iY = 255; iY >= 0; iY--)
+ {
+ pPPLT->aEntries [iY].iRed = aIndexentries [iY].iRed;
+ pPPLT->aEntries [iY].iGreen = aIndexentries [iY].iGreen;
+ pPPLT->aEntries [iY].iBlue = aIndexentries [iY].iBlue;
+ pPPLT->aEntries [iY].iAlpha = aAlphaentries [iY];
+ pPPLT->aEntries [iY].bUsed = (mng_bool)(aUsedentries [iY]);
+ }
+
+ { /* create animation object */
+ mng_retcode iRetcode = mng_create_ani_pplt (pData, iDeltatype, iMax,
+ aIndexentries, aAlphaentries,
+ aUsedentries);
+ if (iRetcode)
+ return iRetcode;
+ }
+
+ *piRawlen = 0;
+
+ return MNG_NOERROR;
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_NO_DELTA_PNG
+MNG_C_SPECIALFUNC (mng_special_pplt)
+{
+ return MNG_NOERROR;
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_NO_DELTA_PNG
+#ifdef MNG_INCLUDE_JNG
+MNG_C_SPECIALFUNC (mng_special_ijng)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ mng_retcode iRetcode = mng_create_ani_ijng (pData);
+ if (!iRetcode) /* process it */
+ iRetcode = mng_process_display_ijng (pData);
+ return iRetcode;
+#else
+ return MNG_NOERROR; /* done */
+#endif /* MNG_SUPPORT_DISPLAY */
+}
+#endif
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_NO_DELTA_PNG
+MNG_F_SPECIALFUNC (mng_drop_entries)
+{
+ mng_dropp pDROP = (mng_dropp)pChunk;
+ mng_uint32 iRawlen = *piRawlen;
+ mng_uint8p pRawdata = *ppRawdata;
+ mng_uint32 iX;
+ mng_uint32p pEntry;
+ /* check length */
+ if ((iRawlen < 4) || ((iRawlen % 4) != 0))
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+
+ MNG_ALLOC (pData, pEntry, iRawlen);
+ pDROP->iCount = iRawlen / 4;
+ pDROP->pChunknames = (mng_ptr)pEntry;
+
+ for (iX = pDROP->iCount; iX > 0; iX--)
+ {
+ *pEntry++ = mng_get_uint32 (pRawdata);
+ pRawdata += 4;
+ }
+
+ *piRawlen = 0;
+
+ return MNG_NOERROR;
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_NO_DELTA_PNG
+MNG_C_SPECIALFUNC (mng_special_drop)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ {
+
+
+ /* TODO: something !!! */
+
+
+ }
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ return MNG_NOERROR; /* done */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_NO_DELTA_PNG
+#ifndef MNG_SKIPCHUNK_DBYK
+MNG_C_SPECIALFUNC (mng_special_dbyk)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ {
+
+
+ /* TODO: something !!! */
+
+
+ }
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ return MNG_NOERROR; /* done */
+}
+#endif
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_NO_DELTA_PNG
+#ifndef MNG_SKIPCHUNK_ORDR
+MNG_F_SPECIALFUNC (mng_ordr_entries)
+{
+ mng_ordrp pORDR = (mng_ordrp)pChunk;
+ mng_uint32 iRawlen = *piRawlen;
+ mng_uint8p pRawdata = *ppRawdata;
+ mng_uint32 iX;
+ mng_ordr_entryp pEntry;
+ /* check length */
+ if ((iRawlen < 5) || ((iRawlen % 5) != 0))
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+
+ MNG_ALLOC (pData, pEntry, iRawlen);
+ pORDR->iCount = iRawlen / 5;
+ pORDR->pEntries = (mng_ptr)pEntry;
+
+ for (iX = pORDR->iCount; iX > 0; iX--)
+ {
+ pEntry->iChunkname = mng_get_uint32 (pRawdata);
+ pEntry->iOrdertype = *(pRawdata+4);
+ pEntry++;
+ pRawdata += 5;
+ }
+
+ *piRawlen = 0;
+
+ return MNG_NOERROR;
+}
+#endif
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_NO_DELTA_PNG
+#ifndef MNG_SKIPCHUNK_ORDR
+MNG_C_SPECIALFUNC (mng_special_ordr)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ {
+
+
+ /* TODO: something !!! */
+
+
+ }
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ return MNG_NOERROR; /* done */
+}
+#endif
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_MAGN
+MNG_F_SPECIALFUNC (mng_debunk_magn)
+{
+ mng_magnp pMAGN = (mng_magnp)pChunk;
+ mng_uint32 iRawlen = *piRawlen;
+ mng_uint8p pRawdata = *ppRawdata;
+ mng_bool bFaulty;
+ /* check length */
+ if (iRawlen > 20)
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+
+ /* following is an ugly hack to allow faulty layout caused by previous
+ versions of libmng and MNGeye, which wrote MAGN with a 16-bit
+ MethodX/MethodY (as opposed to the proper 8-bit as defined in the spec!) */
+
+ if ((iRawlen == 6) || (iRawlen == 8) || (iRawlen == 10) || (iRawlen == 12) ||
+ (iRawlen == 14) || (iRawlen == 16) || (iRawlen == 20))
+ bFaulty = MNG_TRUE; /* these lengths are all wrong */
+ else /* length 18 can be right or wrong !!! */
+ if ((iRawlen == 18) && (mng_get_uint16 (pRawdata+4) <= 5) &&
+ (mng_get_uint16 (pRawdata+6) < 256) &&
+ (mng_get_uint16 (pRawdata+8) < 256) &&
+ (mng_get_uint16 (pRawdata+10) < 256) &&
+ (mng_get_uint16 (pRawdata+12) < 256) &&
+ (mng_get_uint16 (pRawdata+14) < 256) &&
+ (mng_get_uint16 (pRawdata+16) < 256))
+ bFaulty = MNG_TRUE; /* this is very likely the wrong layout */
+ else
+ bFaulty = MNG_FALSE; /* all other cases are handled as right */
+
+ if (bFaulty) /* wrong layout ? */
+ {
+ if (iRawlen > 0) /* get the fields */
+ pMAGN->iFirstid = mng_get_uint16 (pRawdata);
+ else
+ pMAGN->iFirstid = 0;
+
+ if (iRawlen > 2)
+ pMAGN->iLastid = mng_get_uint16 (pRawdata+2);
+ else
+ pMAGN->iLastid = pMAGN->iFirstid;
+
+ if (iRawlen > 4)
+ pMAGN->iMethodX = (mng_uint8)(mng_get_uint16 (pRawdata+4));
+ else
+ pMAGN->iMethodX = 0;
+
+ if (iRawlen > 6)
+ pMAGN->iMX = mng_get_uint16 (pRawdata+6);
+ else
+ pMAGN->iMX = 1;
+
+ if (iRawlen > 8)
+ pMAGN->iMY = mng_get_uint16 (pRawdata+8);
+ else
+ pMAGN->iMY = pMAGN->iMX;
+
+ if (iRawlen > 10)
+ pMAGN->iML = mng_get_uint16 (pRawdata+10);
+ else
+ pMAGN->iML = pMAGN->iMX;
+
+ if (iRawlen > 12)
+ pMAGN->iMR = mng_get_uint16 (pRawdata+12);
+ else
+ pMAGN->iMR = pMAGN->iMX;
+
+ if (iRawlen > 14)
+ pMAGN->iMT = mng_get_uint16 (pRawdata+14);
+ else
+ pMAGN->iMT = pMAGN->iMY;
+
+ if (iRawlen > 16)
+ pMAGN->iMB = mng_get_uint16 (pRawdata+16);
+ else
+ pMAGN->iMB = pMAGN->iMY;
+
+ if (iRawlen > 18)
+ pMAGN->iMethodY = (mng_uint8)(mng_get_uint16 (pRawdata+18));
+ else
+ pMAGN->iMethodY = pMAGN->iMethodX;
+ }
+ else /* proper layout !!!! */
+ {
+ if (iRawlen > 0) /* get the fields */
+ pMAGN->iFirstid = mng_get_uint16 (pRawdata);
+ else
+ pMAGN->iFirstid = 0;
+
+ if (iRawlen > 2)
+ pMAGN->iLastid = mng_get_uint16 (pRawdata+2);
+ else
+ pMAGN->iLastid = pMAGN->iFirstid;
+
+ if (iRawlen > 4)
+ pMAGN->iMethodX = *(pRawdata+4);
+ else
+ pMAGN->iMethodX = 0;
+
+ if (iRawlen > 5)
+ pMAGN->iMX = mng_get_uint16 (pRawdata+5);
+ else
+ pMAGN->iMX = 1;
+
+ if (iRawlen > 7)
+ pMAGN->iMY = mng_get_uint16 (pRawdata+7);
+ else
+ pMAGN->iMY = pMAGN->iMX;
+
+ if (iRawlen > 9)
+ pMAGN->iML = mng_get_uint16 (pRawdata+9);
+ else
+ pMAGN->iML = pMAGN->iMX;
+
+ if (iRawlen > 11)
+ pMAGN->iMR = mng_get_uint16 (pRawdata+11);
+ else
+ pMAGN->iMR = pMAGN->iMX;
+
+ if (iRawlen > 13)
+ pMAGN->iMT = mng_get_uint16 (pRawdata+13);
+ else
+ pMAGN->iMT = pMAGN->iMY;
+
+ if (iRawlen > 15)
+ pMAGN->iMB = mng_get_uint16 (pRawdata+15);
+ else
+ pMAGN->iMB = pMAGN->iMY;
+
+ if (iRawlen > 17)
+ pMAGN->iMethodY = *(pRawdata+17);
+ else
+ pMAGN->iMethodY = pMAGN->iMethodX;
+ }
+ /* check field validity */
+ if ((pMAGN->iMethodX > 5) || (pMAGN->iMethodY > 5))
+ MNG_ERROR (pData, MNG_INVALIDMETHOD);
+
+ *piRawlen = 0;
+
+ return MNG_NOERROR;
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_MAGN
+MNG_C_SPECIALFUNC (mng_special_magn)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ return mng_create_ani_magn (pData, pChunk);
+#else
+ return MNG_NOERROR;
+#endif /* MNG_SUPPORT_DISPLAY */
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_evNT
+MNG_F_SPECIALFUNC (mng_evnt_entries)
+{
+ mng_evntp pEVNT = (mng_evntp)pChunk;
+ mng_uint32 iRawlen;
+ mng_uint8p pRawdata;
+#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_SUPPORT_DYNAMICMNG)
+ mng_retcode iRetcode;
+#endif
+ mng_uint8p pNull;
+ mng_uint8 iEventtype;
+ mng_uint8 iMasktype;
+ mng_int32 iLeft;
+ mng_int32 iRight;
+ mng_int32 iTop;
+ mng_int32 iBottom;
+ mng_uint16 iObjectid;
+ mng_uint8 iIndex;
+ mng_uint32 iNamesize;
+ mng_uint32 iCount = 0;
+ mng_evnt_entryp pEntry = MNG_NULL;
+ mng_uint32 iX;
+
+ for (iX = 0; iX < 2; iX++)
+ {
+ iRawlen = *piRawlen;
+ pRawdata = *ppRawdata;
+
+ if (iX) /* second run ? */
+ {
+ MNG_ALLOC (pData, pEntry, (iCount * sizeof (mng_evnt_entry)));
+ pEVNT->iCount = iCount;
+ pEVNT->pEntries = pEntry;
+ }
+
+ while (iRawlen) /* anything left ? */
+ {
+ if (iRawlen < 2) /* must have at least 2 bytes ! */
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+
+ iEventtype = *pRawdata; /* eventtype */
+ if (iEventtype > 5)
+ MNG_ERROR (pData, MNG_INVALIDEVENT);
+
+ pRawdata++;
+
+ iMasktype = *pRawdata; /* masktype */
+ if (iMasktype > 5)
+ MNG_ERROR (pData, MNG_INVALIDMASK);
+
+ pRawdata++;
+ iRawlen -= 2;
+
+ iLeft = 0;
+ iRight = 0;
+ iTop = 0;
+ iBottom = 0;
+ iObjectid = 0;
+ iIndex = 0;
+
+ switch (iMasktype)
+ {
+ case 1 :
+ {
+ if (iRawlen > 16)
+ {
+ iLeft = mng_get_int32 (pRawdata);
+ iRight = mng_get_int32 (pRawdata+4);
+ iTop = mng_get_int32 (pRawdata+8);
+ iBottom = mng_get_int32 (pRawdata+12);
+ pRawdata += 16;
+ iRawlen -= 16;
+ }
+ else
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+ break;
+ }
+ case 2 :
+ {
+ if (iRawlen > 2)
+ {
+ iObjectid = mng_get_uint16 (pRawdata);
+ pRawdata += 2;
+ iRawlen -= 2;
+ }
+ else
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+ break;
+ }
+ case 3 :
+ {
+ if (iRawlen > 3)
+ {
+ iObjectid = mng_get_uint16 (pRawdata);
+ iIndex = *(pRawdata+2);
+ pRawdata += 3;
+ iRawlen -= 3;
+ }
+ else
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+ break;
+ }
+ case 4 :
+ {
+ if (iRawlen > 18)
+ {
+ iLeft = mng_get_int32 (pRawdata);
+ iRight = mng_get_int32 (pRawdata+4);
+ iTop = mng_get_int32 (pRawdata+8);
+ iBottom = mng_get_int32 (pRawdata+12);
+ iObjectid = mng_get_uint16 (pRawdata+16);
+ pRawdata += 18;
+ iRawlen -= 18;
+ }
+ else
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+ break;
+ }
+ case 5 :
+ {
+ if (iRawlen > 19)
+ {
+ iLeft = mng_get_int32 (pRawdata);
+ iRight = mng_get_int32 (pRawdata+4);
+ iTop = mng_get_int32 (pRawdata+8);
+ iBottom = mng_get_int32 (pRawdata+12);
+ iObjectid = mng_get_uint16 (pRawdata+16);
+ iIndex = *(pRawdata+18);
+ pRawdata += 19;
+ iRawlen -= 19;
+ }
+ else
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+ break;
+ }
+ }
+
+ pNull = pRawdata; /* get the name length */
+ while (*pNull)
+ pNull++;
+
+ if ((pNull - pRawdata) > (mng_int32)iRawlen)
+ {
+ iNamesize = iRawlen; /* no null found; so end of evNT */
+ iRawlen = 0;
+ }
+ else
+ {
+ iNamesize = pNull - pRawdata; /* should be another entry */
+ iRawlen = iRawlen - iNamesize - 1;
+
+ if (!iRawlen) /* must not end with a null ! */
+ MNG_ERROR (pData, MNG_ENDWITHNULL);
+ }
+
+ if (!iX)
+ {
+ iCount++;
+ }
+ else
+ {
+ pEntry->iEventtype = iEventtype;
+ pEntry->iMasktype = iMasktype;
+ pEntry->iLeft = iLeft;
+ pEntry->iRight = iRight;
+ pEntry->iTop = iTop;
+ pEntry->iBottom = iBottom;
+ pEntry->iObjectid = iObjectid;
+ pEntry->iIndex = iIndex;
+ pEntry->iSegmentnamesize = iNamesize;
+
+ if (iNamesize)
+ {
+ MNG_ALLOC (pData, pEntry->zSegmentname, iNamesize+1);
+ MNG_COPY (pEntry->zSegmentname, pRawdata, iNamesize);
+ }
+
+#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_SUPPORT_DYNAMICMNG)
+ iRetcode = mng_create_event (pData, (mng_ptr)pEntry);
+ if (iRetcode) /* on error bail out */
+ return iRetcode;
+#endif
+
+ pEntry++;
+ }
+
+ pRawdata = pRawdata + iNamesize + 1;
+ }
+ }
+
+ *piRawlen = 0;
+
+ return MNG_NOERROR;
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifndef MNG_SKIPCHUNK_evNT
+MNG_C_SPECIALFUNC (mng_special_evnt)
+{
+ return MNG_NOERROR;
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifdef MNG_INCLUDE_MPNG_PROPOSAL
+MNG_C_SPECIALFUNC (mng_special_mpng)
+{
+ if ((pData->eImagetype != mng_it_png) && (pData->eImagetype != mng_it_jng))
+ MNG_ERROR (pData, MNG_CHUNKNOTALLOWED);
+
+#ifdef MNG_SUPPORT_DISPLAY
+ return mng_create_mpng_obj (pData, pChunk);
+#else
+ return MNG_NOERROR;
+#endif
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifdef MNG_INCLUDE_ANG_PROPOSAL
+MNG_C_SPECIALFUNC (mng_special_ahdr)
+{
+#ifdef MNG_SUPPORT_DISPLAY
+ return mng_create_ang_obj (pData, pChunk);
+#else
+ return MNG_NOERROR;
+#endif
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifdef MNG_INCLUDE_ANG_PROPOSAL
+MNG_F_SPECIALFUNC (mng_adat_tiles)
+{
+ if ((pData->eImagetype != mng_it_ang) || (!pData->pANG))
+ MNG_ERROR (pData, MNG_CHUNKNOTALLOWED);
+
+ {
+ mng_adatp pADAT = (mng_adatp)pChunk;
+ mng_ang_objp pANG = (mng_ang_objp)pData->pANG;
+ mng_uint32 iRawlen = *piRawlen;
+ mng_uint8p pRawdata = *ppRawdata;
+ mng_retcode iRetcode;
+ mng_uint8p pBuf;
+ mng_uint32 iBufsize;
+ mng_uint32 iRealsize;
+ mng_uint8p pTemp;
+ mng_uint8p pTemp2;
+ mng_int32 iX;
+ mng_int32 iSize;
+
+#ifdef MNG_SUPPORT_DISPLAY
+ mng_imagep pImage;
+ mng_int32 iTemplen;
+ mng_uint8p pSwap;
+
+ mng_processobject pProcess;
+
+ mng_uint32 iSavedatawidth;
+ mng_uint32 iSavedataheight;
+
+ mng_fptr fSaveinitrowproc;
+ mng_fptr fSavestorerow;
+ mng_fptr fSaveprocessrow;
+ mng_fptr fSavedifferrow;
+ mng_imagep fSavestoreobj;
+ mng_imagedatap fSavestorebuf;
+
+#ifdef MNG_OPTIMIZE_FOOTPRINT_INIT
+ png_imgtype eSavepngimgtype;
+#endif
+
+ mng_uint8 iSaveinterlace;
+ mng_int8 iSavepass;
+ mng_int32 iSaverow;
+ mng_int32 iSaverowinc;
+ mng_int32 iSavecol;
+ mng_int32 iSavecolinc;
+ mng_int32 iSaverowsamples;
+ mng_int32 iSavesamplemul;
+ mng_int32 iSavesampleofs;
+ mng_int32 iSavesamplediv;
+ mng_int32 iSaverowsize;
+ mng_int32 iSaverowmax;
+ mng_int32 iSavefilterofs;
+ mng_int32 iSavepixelofs;
+ mng_uint32 iSavelevel0;
+ mng_uint32 iSavelevel1;
+ mng_uint32 iSavelevel2;
+ mng_uint32 iSavelevel3;
+ mng_uint8p pSaveworkrow;
+ mng_uint8p pSaveprevrow;
+ mng_uint8p pSaverGBArow;
+ mng_bool bSaveisRGBA16;
+ mng_bool bSaveisOpaque;
+ mng_int32 iSavefilterbpp;
+
+ mng_int32 iSavedestl;
+ mng_int32 iSavedestt;
+ mng_int32 iSavedestr;
+ mng_int32 iSavedestb;
+ mng_int32 iSavesourcel;
+ mng_int32 iSavesourcet;
+ mng_int32 iSavesourcer;
+ mng_int32 iSavesourceb;
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ iRetcode = mng_inflate_buffer (pData, pRawdata, iRawlen,
+ &pBuf, &iBufsize, &iRealsize);
+ if (iRetcode) /* on error bail out */
+ { /* don't forget to drop the temp buffer */
+ MNG_FREEX (pData, pBuf, iBufsize);
+ return iRetcode;
+ }
+ /* get buffer for tile info in ADAT chunk */
+ pADAT->iTilessize = pANG->iNumframes * sizeof(mng_adat_tile);
+ MNG_ALLOCX (pData, pADAT->pTiles, pADAT->iTilessize);
+ if (!pADAT->pTiles)
+ {
+ pADAT->iTilessize = 0;
+ MNG_FREEX (pData, pBuf, iBufsize);
+ MNG_ERROR (pData, MNG_OUTOFMEMORY);
+ }
+
+ pTemp = pBuf;
+ pTemp2 = (mng_uint8p)pADAT->pTiles;
+
+ if (!pANG->iStillused)
+ iSize = 12;
+ else
+ iSize = 13;
+
+ for (iX = 0; iX < pANG->iNumframes; iX++)
+ {
+ MNG_COPY (pTemp2, pTemp, iSize);
+ pTemp += iSize;
+ pTemp2 += sizeof(mng_adat_tile);
+ }
+
+#ifdef MNG_SUPPORT_DISPLAY
+ /* get buffer for tile info in ANG object */
+ pANG->iTilessize = pADAT->iTilessize;
+ MNG_ALLOCX (pData, pANG->pTiles, pANG->iTilessize);
+ if (!pANG->pTiles)
+ {
+ pANG->iTilessize = 0;
+ MNG_FREEX (pData, pBuf, iBufsize);
+ MNG_ERROR (pData, MNG_OUTOFMEMORY);
+ }
+ /* copy it from the ADAT object */
+ MNG_COPY (pANG->pTiles, pADAT->pTiles, pANG->iTilessize);
+
+ /* save IDAT work-parms */
+ fSaveinitrowproc = pData->fInitrowproc;
+ fSavestorerow = pData->fDisplayrow;
+ fSaveprocessrow = pData->fProcessrow;
+ fSavedifferrow = pData->fDifferrow;
+ fSavestoreobj = pData->pStoreobj;
+ fSavestorebuf = pData->pStorebuf;
+
+#ifdef MNG_OPTIMIZE_FOOTPRINT_INIT
+ eSavepngimgtype = pData->ePng_imgtype;
+#endif
+
+ iSavedatawidth = pData->iDatawidth;
+ iSavedataheight = pData->iDataheight;
+ iSaveinterlace = pData->iInterlace;
+ iSavepass = pData->iPass;
+ iSaverow = pData->iRow;
+ iSaverowinc = pData->iRowinc;
+ iSavecol = pData->iCol;
+ iSavecolinc = pData->iColinc;
+ iSaverowsamples = pData->iRowsamples;
+ iSavesamplemul = pData->iSamplemul;
+ iSavesampleofs = pData->iSampleofs;
+ iSavesamplediv = pData->iSamplediv;
+ iSaverowsize = pData->iRowsize;
+ iSaverowmax = pData->iRowmax;
+ iSavefilterofs = pData->iFilterofs;
+ iSavepixelofs = pData->iPixelofs;
+ iSavelevel0 = pData->iLevel0;
+ iSavelevel1 = pData->iLevel1;
+ iSavelevel2 = pData->iLevel2;
+ iSavelevel3 = pData->iLevel3;
+ pSaveworkrow = pData->pWorkrow;
+ pSaveprevrow = pData->pPrevrow;
+ pSaverGBArow = pData->pRGBArow;
+ bSaveisRGBA16 = pData->bIsRGBA16;
+ bSaveisOpaque = pData->bIsOpaque;
+ iSavefilterbpp = pData->iFilterbpp;
+ iSavedestl = pData->iDestl;
+ iSavedestt = pData->iDestt;
+ iSavedestr = pData->iDestr;
+ iSavedestb = pData->iDestb;
+ iSavesourcel = pData->iSourcel;
+ iSavesourcet = pData->iSourcet;
+ iSavesourcer = pData->iSourcer;
+ iSavesourceb = pData->iSourceb;
+
+ pData->iDatawidth = pANG->iTilewidth;
+ pData->iDataheight = pANG->iTileheight;
+
+ pData->iDestl = 0;
+ pData->iDestt = 0;
+ pData->iDestr = pANG->iTilewidth;
+ pData->iDestb = pANG->iTileheight;
+ pData->iSourcel = 0;
+ pData->iSourcet = 0;
+ pData->iSourcer = pANG->iTilewidth;
+ pData->iSourceb = pANG->iTileheight;
+
+ pData->fInitrowproc = MNG_NULL;
+ pData->fStorerow = MNG_NULL;
+ pData->fProcessrow = MNG_NULL;
+ pData->fDifferrow = MNG_NULL;
+
+ /* clone image object to store the pixel-data from object 0 */
+ iRetcode = mng_clone_imageobject (pData, 1, MNG_FALSE, MNG_FALSE, MNG_FALSE,
+ MNG_FALSE, 0, 0, 0, pData->pObjzero, &pImage);
+ if (iRetcode) /* on error, drop temp buffer and bail */
+ {
+ MNG_FREEX (pData, pBuf, iBufsize);
+ return iRetcode;
+ }
+
+ /* make sure we got the right dimensions and interlacing */
+ iRetcode = mng_reset_object_details (pData, pImage, pANG->iTilewidth, pANG->iTileheight,
+ pImage->pImgbuf->iBitdepth, pImage->pImgbuf->iColortype,
+ pImage->pImgbuf->iCompression, pImage->pImgbuf->iFilter,
+ pANG->iInterlace, MNG_FALSE);
+ if (iRetcode) /* on error, drop temp buffer and bail */
+ {
+ MNG_FREEX (pData, pBuf, iBufsize);
+ return iRetcode;
+ }
+
+ pData->pStoreobj = pImage;
+
+#ifdef MNG_OPTIMIZE_FOOTPRINT_INIT
+ pData->fInitrowproc = (mng_fptr)mng_init_rowproc;
+ pData->ePng_imgtype = mng_png_imgtype(pData->iColortype,pData->iBitdepth);
+#else
+ switch (pData->iColortype) /* determine row initialization routine */
+ {
+ case 0 : { /* gray */
+ switch (pData->iBitdepth)
+ {
+#ifndef MNG_NO_1_2_4BIT_SUPPORT
+ case 1 : {
+ if (!pData->iInterlace)
+ pData->fInitrowproc = (mng_fptr)mng_init_g1_ni;
+ else
+ pData->fInitrowproc = (mng_fptr)mng_init_g1_i;
+
+ break;
+ }
+ case 2 : {
+ if (!pData->iInterlace)
+ pData->fInitrowproc = (mng_fptr)mng_init_g2_ni;
+ else
+ pData->fInitrowproc = (mng_fptr)mng_init_g2_i;
+
+ break;
+ }
+ case 4 : {
+ if (!pData->iInterlace)
+ pData->fInitrowproc = (mng_fptr)mng_init_g4_ni;
+ else
+ pData->fInitrowproc = (mng_fptr)mng_init_g4_i;
+ break;
+ }
+#endif /* MNG_NO_1_2_4BIT_SUPPORT */
+ case 8 : {
+ if (!pData->iInterlace)
+ pData->fInitrowproc = (mng_fptr)mng_init_g8_ni;
+ else
+ pData->fInitrowproc = (mng_fptr)mng_init_g8_i;
+
+ break;
+ }
+#ifndef MNG_NO_16BIT_SUPPORT
+ case 16 : {
+ if (!pData->iInterlace)
+ pData->fInitrowproc = (mng_fptr)mng_init_g16_ni;
+ else
+ pData->fInitrowproc = (mng_fptr)mng_init_g16_i;
+
+ break;
+ }
+#endif
+ }
+
+ break;
+ }
+ case 2 : { /* rgb */
+ switch (pData->iBitdepth)
+ {
+ case 8 : {
+ if (!pData->iInterlace)
+ pData->fInitrowproc = (mng_fptr)mng_init_rgb8_ni;
+ else
+ pData->fInitrowproc = (mng_fptr)mng_init_rgb8_i;
+ break;
+ }
+#ifndef MNG_NO_16BIT_SUPPORT
+ case 16 : {
+ if (!pData->iInterlace)
+ pData->fInitrowproc = (mng_fptr)mng_init_rgb16_ni;
+ else
+ pData->fInitrowproc = (mng_fptr)mng_init_rgb16_i;
+
+ break;
+ }
+#endif
+ }
+
+ break;
+ }
+ case 3 : { /* indexed */
+ switch (pData->iBitdepth)
+ {
+#ifndef MNG_NO_1_2_4BIT_SUPPORT
+ case 1 : {
+ if (!pData->iInterlace)
+ pData->fInitrowproc = (mng_fptr)mng_init_idx1_ni;
+ else
+ pData->fInitrowproc = (mng_fptr)mng_init_idx1_i;
+
+ break;
+ }
+ case 2 : {
+ if (!pData->iInterlace)
+ pData->fInitrowproc = (mng_fptr)mng_init_idx2_ni;
+ else
+ pData->fInitrowproc = (mng_fptr)mng_init_idx2_i;
+
+ break;
+ }
+ case 4 : {
+ if (!pData->iInterlace)
+ pData->fInitrowproc = (mng_fptr)mng_init_idx4_ni;
+ else
+ pData->fInitrowproc = (mng_fptr)mng_init_idx4_i;
+
+ break;
+ }
+#endif /* MNG_NO_1_2_4BIT_SUPPORT */
+ case 8 : {
+ if (!pData->iInterlace)
+ pData->fInitrowproc = (mng_fptr)mng_init_idx8_ni;
+ else
+ pData->fInitrowproc = (mng_fptr)mng_init_idx8_i;
+
+ break;
+ }
+ }
+
+ break;
+ }
+ case 4 : { /* gray+alpha */
+ switch (pData->iBitdepth)
+ {
+ case 8 : {
+ if (!pData->iInterlace)
+ pData->fInitrowproc = (mng_fptr)mng_init_ga8_ni;
+ else
+ pData->fInitrowproc = (mng_fptr)mng_init_ga8_i;
+
+ break;
+ }
+#ifndef MNG_NO_16BIT_SUPPORT
+ case 16 : {
+ if (!pData->iInterlace)
+ pData->fInitrowproc = (mng_fptr)mng_init_ga16_ni;
+ else
+ pData->fInitrowproc = (mng_fptr)mng_init_ga16_i;
+ break;
+ }
+#endif
+ }
+
+ break;
+ }
+ case 6 : { /* rgb+alpha */
+ switch (pData->iBitdepth)
+ {
+ case 8 : {
+ if (!pData->iInterlace)
+ pData->fInitrowproc = (mng_fptr)mng_init_rgba8_ni;
+ else
+ pData->fInitrowproc = (mng_fptr)mng_init_rgba8_i;
+
+ break;
+ }
+#ifndef MNG_NO_16BIT_SUPPORT
+ case 16 : {
+ if (!pData->iInterlace)
+ pData->fInitrowproc = (mng_fptr)mng_init_rgba16_ni;
+ else
+ pData->fInitrowproc = (mng_fptr)mng_init_rgba16_i;
+
+ break;
+ }
+#endif
+ }
+
+ break;
+ }
+ }
+#endif /* MNG_OPTIMIZE_FOOTPRINT_INIT */
+
+ pData->iFilterofs = 0; /* determine filter characteristics */
+ pData->iLevel0 = 0; /* default levels */
+ pData->iLevel1 = 0;
+ pData->iLevel2 = 0;
+ pData->iLevel3 = 0;
+
+#ifdef FILTER192 /* leveling & differing ? */
+ if (pData->iFilter == MNG_FILTER_DIFFERING)
+ {
+ switch (pData->iColortype)
+ {
+ case 0 : {
+ if (pData->iBitdepth <= 8)
+ pData->iFilterofs = 1;
+ else
+ pData->iFilterofs = 2;
+
+ break;
+ }
+ case 2 : {
+ if (pData->iBitdepth <= 8)
+ pData->iFilterofs = 3;
+ else
+ pData->iFilterofs = 6;
+
+ break;
+ }
+ case 3 : {
+ pData->iFilterofs = 1;
+ break;
+ }
+ case 4 : {
+ if (pData->iBitdepth <= 8)
+ pData->iFilterofs = 2;
+ else
+ pData->iFilterofs = 4;
+
+ break;
+ }
+ case 6 : {
+ if (pData->iBitdepth <= 8)
+ pData->iFilterofs = 4;
+ else
+ pData->iFilterofs = 8;
+
+ break;
+ }
+ }
+ }
+#endif
+
+#ifdef FILTER193 /* no adaptive filtering ? */
+ if (pData->iFilter == MNG_FILTER_NOFILTER)
+ pData->iPixelofs = pData->iFilterofs;
+ else
+#endif
+ pData->iPixelofs = pData->iFilterofs + 1;
+
+ if (pData->fInitrowproc) /* need to initialize row processing? */
+ {
+ iRetcode = ((mng_initrowproc)pData->fInitrowproc) (pData);
+ if (iRetcode)
+ {
+ MNG_FREEX (pData, pBuf, iBufsize);
+ return iRetcode;
+ }
+ }
+ /* calculate remainder of buffer */
+ pTemp = pBuf + (mng_int32)(pANG->iNumframes * iSize);
+ iTemplen = iRealsize - (mng_int32)(pANG->iNumframes * iSize);
+
+ do
+ {
+ if (iTemplen > pData->iRowmax) /* get a pixel-row from the temp buffer */
+ {
+ MNG_COPY (pData->pWorkrow, pTemp, pData->iRowmax);
+ }
+ else
+ {
+ MNG_COPY (pData->pWorkrow, pTemp, iTemplen);
+ }
+
+ { /* image not completed yet ? */
+ if (pData->iRow < (mng_int32)pData->iDataheight)
+ {
+#ifdef MNG_NO_1_2_4BIT_SUPPORT
+ if (pData->iPNGdepth == 1)
+ {
+ /* Inflate Workrow to 8-bit */
+ mng_int32 iX;
+ mng_uint8p pSrc = pData->pWorkrow+1;
+ mng_uint8p pDest = pSrc + pData->iRowsize - (pData->iRowsize+7)/8;
+
+ for (iX = ((pData->iRowsize+7)/8) ; iX > 0 ; iX--)
+ *pDest++ = *pSrc++;
+
+ pDest = pData->pWorkrow+1;
+ pSrc = pDest + pData->iRowsize - (pData->iRowsize+7)/8;
+ for (iX = pData->iRowsize; ;)
+ {
+ *pDest++ = (((*pSrc)>>7)&1);
+ if (iX-- <= 0)
+ break;
+ *pDest++ = (((*pSrc)>>6)&1);
+ if (iX-- <= 0)
+ break;
+ *pDest++ = (((*pSrc)>>5)&1);
+ if (iX-- <= 0)
+ break;
+ *pDest++ = (((*pSrc)>>4)&1);
+ if (iX-- <= 0)
+ break;
+ *pDest++ = (((*pSrc)>>3)&1);
+ if (iX-- <= 0)
+ break;
+ *pDest++ = (((*pSrc)>>2)&1);
+ if (iX-- <= 0)
+ break;
+ *pDest++ = (((*pSrc)>>1)&1);
+ if (iX-- <= 0)
+ break;
+ *pDest++ = (((*pSrc) )&1);
+ if (iX-- <= 0)
+ break;
+ pSrc++;
+ }
+ }
+ else if (pData->iPNGdepth == 2)
+ {
+ /* Inflate Workrow to 8-bit */
+ mng_int32 iX;
+ mng_uint8p pSrc = pData->pWorkrow+1;
+ mng_uint8p pDest = pSrc + pData->iRowsize - (2*pData->iRowsize+7)/8;
+
+ for (iX = ((2*pData->iRowsize+7)/8) ; iX > 0 ; iX--)
+ *pDest++ = *pSrc++;
+
+ pDest = pData->pWorkrow+1;
+ pSrc = pDest + pData->iRowsize - (2*pData->iRowsize+7)/8;
+ for (iX = pData->iRowsize; ;)
+ {
+ *pDest++ = (((*pSrc)>>6)&3);
+ if (iX-- <= 0)
+ break;
+ *pDest++ = (((*pSrc)>>4)&3);
+ if (iX-- <= 0)
+ break;
+ *pDest++ = (((*pSrc)>>2)&3);
+ if (iX-- <= 0)
+ break;
+ *pDest++ = (((*pSrc) )&3);
+ if (iX-- <= 0)
+ break;
+ pSrc++;
+ }
+ }
+ else if (pData->iPNGdepth == 4)
+ {
+ /* Inflate Workrow to 8-bit */
+ mng_int32 iX;
+ mng_uint8p pSrc = pData->pWorkrow+1;
+ mng_uint8p pDest = pSrc + pData->iRowsize - (4*pData->iRowsize+7)/8;
+
+ for (iX = ((4*pData->iRowsize+7)/8) ; iX > 0 ; iX--)
+ *pDest++ = *pSrc++;
+
+ pDest = pData->pWorkrow+1;
+ pSrc = pDest + pData->iRowsize - (4*pData->iRowsize+7)/8;
+ for (iX = pData->iRowsize; ;)
+ {
+ *pDest++ = (((*pSrc)>>4)&0x0f);
+ if (iX-- <= 0)
+ break;
+ *pDest++ = (((*pSrc) )&0x0f);
+ if (iX-- <= 0)
+ break;
+ pSrc++;
+ }
+ }
+ if (pData->iPNGdepth < 8 && pData->iColortype == 0)
+ {
+ /* Expand samples to 8-bit by LBR */
+ mng_int32 iX;
+ mng_uint8p pSrc = pData->pWorkrow+1;
+ mng_uint8 multiplier[]={0,255,85,0,17,0,0,0,1};
+
+ for (iX = pData->iRowsize; iX > 0; iX--)
+ *pSrc++ *= multiplier[pData->iPNGdepth];
+ }
+#endif
+#ifdef MNG_NO_16BIT_SUPPORT
+ if (pData->iPNGdepth > 8)
+ {
+ /* Reduce Workrow to 8-bit */
+ mng_int32 iX;
+ mng_uint8p pSrc = pData->pWorkrow+1;
+ mng_uint8p pDest = pSrc;
+
+ for (iX = pData->iRowsize; iX > 0; iX--)
+ {
+ *pDest = *pSrc;
+ pDest++;
+ pSrc+=2;
+ }
+ }
+#endif
+
+#ifdef FILTER192 /* has leveling info ? */
+ if (pData->iFilterofs == MNG_FILTER_DIFFERING)
+ iRetcode = init_rowdiffering (pData);
+ else
+#endif
+ iRetcode = MNG_NOERROR;
+ /* filter the row if necessary */
+ if ((!iRetcode) && (pData->iFilterofs < pData->iPixelofs ) &&
+ (*(pData->pWorkrow + pData->iFilterofs)) )
+ iRetcode = mng_filter_a_row (pData);
+
+ /* additional leveling/differing ? */
+ if ((!iRetcode) && (pData->fDifferrow))
+ {
+ iRetcode = ((mng_differrow)pData->fDifferrow) (pData);
+
+ pSwap = pData->pWorkrow;
+ pData->pWorkrow = pData->pPrevrow;
+ pData->pPrevrow = pSwap; /* make sure we're processing the right data */
+ }
+
+ if (!iRetcode)
+ {
+ { /* process this row */
+ if ((!iRetcode) && (pData->fProcessrow))
+ iRetcode = ((mng_processrow)pData->fProcessrow) (pData);
+ /* store in object ? */
+ if ((!iRetcode) && (pData->fStorerow))
+ iRetcode = ((mng_storerow)pData->fStorerow) (pData);
+ }
+ }
+
+ if (iRetcode) /* on error bail out */
+ {
+ MNG_FREEX (pData, pBuf, iBufsize);
+ MNG_ERROR (pData, iRetcode);
+ }
+
+ if (!pData->fDifferrow) /* swap row-pointers */
+ {
+ pSwap = pData->pWorkrow;
+ pData->pWorkrow = pData->pPrevrow;
+ pData->pPrevrow = pSwap; /* so prev points to the processed row! */
+ }
+ /* adjust variables for next row */
+ iRetcode = mng_next_row (pData);
+
+ if (iRetcode) /* on error bail out */
+ {
+ MNG_FREEX (pData, pBuf, iBufsize);
+ MNG_ERROR (pData, iRetcode);
+ }
+ }
+ }
+
+ pTemp += pData->iRowmax;
+ iTemplen -= pData->iRowmax;
+ } /* until some error or EOI
+ or all pixels received */
+ while ( (iTemplen > 0) &&
+ ( (pData->iRow < (mng_int32)pData->iDataheight) ||
+ ( (pData->iPass >= 0) && (pData->iPass < 7) ) ) );
+
+ mng_cleanup_rowproc (pData); /* cleanup row processing buffers !! */
+
+ /* restore saved work-parms */
+ pData->iDatawidth = iSavedatawidth;
+ pData->iDataheight = iSavedataheight;
+
+ pData->fInitrowproc = fSaveinitrowproc;
+ pData->fDisplayrow = fSavestorerow;
+ pData->fProcessrow = fSaveprocessrow;
+ pData->fDifferrow = fSavedifferrow;
+ pData->pStoreobj = fSavestoreobj;
+ pData->pStorebuf = fSavestorebuf;
+
+#ifdef MNG_OPTIMIZE_FOOTPRINT_INIT
+ pData->ePng_imgtype = eSavepngimgtype;
+#endif
+
+ pData->iInterlace = iSaveinterlace;
+ pData->iPass = iSavepass;
+ pData->iRow = iSaverow;
+ pData->iRowinc = iSaverowinc;
+ pData->iCol = iSavecol;
+ pData->iColinc = iSavecolinc;
+ pData->iRowsamples = iSaverowsamples;
+ pData->iSamplemul = iSavesamplemul;
+ pData->iSampleofs = iSavesampleofs;
+ pData->iSamplediv = iSavesamplediv;
+ pData->iRowsize = iSaverowsize;
+ pData->iRowmax = iSaverowmax;
+ pData->iFilterofs = iSavefilterofs;
+ pData->iPixelofs = iSavepixelofs;
+ pData->iLevel0 = iSavelevel0;
+ pData->iLevel1 = iSavelevel1;
+ pData->iLevel2 = iSavelevel2;
+ pData->iLevel3 = iSavelevel3;
+ pData->pWorkrow = pSaveworkrow;
+ pData->pPrevrow = pSaveprevrow;
+ pData->pRGBArow = pSaverGBArow;
+ pData->bIsRGBA16 = bSaveisRGBA16;
+ pData->bIsOpaque = bSaveisOpaque;
+ pData->iFilterbpp = iSavefilterbpp;
+ pData->iDestl = iSavedestl;
+ pData->iDestt = iSavedestt;
+ pData->iDestr = iSavedestr;
+ pData->iDestb = iSavedestb;
+ pData->iSourcel = iSavesourcel;
+ pData->iSourcet = iSavesourcet;
+ pData->iSourcer = iSavesourcer;
+ pData->iSourceb = iSavesourceb;
+
+ /* create the animation directives ! */
+ pProcess = (mng_processobject)pANG->sHeader.fProcess;
+ iRetcode = pProcess (pData, (mng_objectp)pData->pANG);
+ if (iRetcode)
+ return iRetcode;
+
+#endif /* MNG_SUPPORT_DISPLAY */
+
+ MNG_FREE (pData, pBuf, iBufsize); /* always free the temp buffer ! */
+ }
+
+ *piRawlen = 0;
+
+ return MNG_NOERROR;
+}
+#endif
+
+/* ************************************************************************** */
+
+#ifdef MNG_INCLUDE_ANG_PROPOSAL
+MNG_C_SPECIALFUNC (mng_special_adat)
+{
+ return MNG_NOERROR;
+}
+#endif
+
+/* ************************************************************************** */
+
+MNG_C_SPECIALFUNC (mng_special_unknown)
+{
+ /* critical chunk ? */
+ if ((((mng_uint32)pData->iChunkname & 0x20000000) == 0)
+#ifdef MNG_SKIPCHUNK_SAVE
+ && (pData->iChunkname != MNG_UINT_SAVE)
+#endif
+#ifdef MNG_SKIPCHUNK_SEEK
+ && (pData->iChunkname != MNG_UINT_SEEK)
+#endif
+#ifdef MNG_SKIPCHUNK_DBYK
+ && (pData->iChunkname != MNG_UINT_DBYK)
+#endif
+#ifdef MNG_SKIPCHUNK_ORDR
+ && (pData->iChunkname != MNG_UINT_ORDR)
+#endif
+ )
+ MNG_ERROR (pData, MNG_UNKNOWNCRITICAL);
+
+ if (pData->fProcessunknown) /* let the app handle it ? */
+ {
+ mng_bool bOke = pData->fProcessunknown ((mng_handle)pData, pData->iChunkname,
+ ((mng_unknown_chunkp)pChunk)->iDatasize,
+ ((mng_unknown_chunkp)pChunk)->pData);
+ if (!bOke)
+ MNG_ERROR (pData, MNG_APPMISCERROR);
+ }
+
+ return MNG_NOERROR; /* done */
+}
+
+/* ************************************************************************** */
+
+#endif /* MNG_INCLUDE_READ_PROCS || MNG_INCLUDE_WRITE_PROCS */
+#endif /* MNG_OPTIMIZE_CHUNKREADER */
+
+/* ************************************************************************** */
+/* * end of file * */
+/* ************************************************************************** */
+
+
+
+
+
diff --git a/src/3rdparty/libmng/libmng_chunk_descr.h b/src/3rdparty/libmng/libmng_chunk_descr.h
new file mode 100644
index 0000000000..3781ab0525
--- /dev/null
+++ b/src/3rdparty/libmng/libmng_chunk_descr.h
@@ -0,0 +1,146 @@
+/* ************************************************************************** */
+/* * For conditions of distribution and use, * */
+/* * see copyright notice in libmng.h * */
+/* ************************************************************************** */
+/* * * */
+/* * project : libmng * */
+/* * file : libmng_chunk_descr.h copyright (c) 2007 G.Juyn * */
+/* * version : 1.0.10 * */
+/* * * */
+/* * purpose : Chunk descriptor functions (implementation) * */
+/* * * */
+/* * author : G.Juyn * */
+/* * * */
+/* * comment : definition of the chunk- anf field-descriptor routines * */
+/* * * */
+/* * changes : 1.0.9 - 12/06/2004 - G.Juyn * */
+/* * - added conditional MNG_OPTIMIZE_CHUNKREADER * */
+/* * * */
+/* * 1.0.10 - 04/08/2007 - G.Juyn * */
+/* * - added support for mPNG proposal * */
+/* * 1.0.10 - 04/12/2007 - G.Juyn * */
+/* * - added support for ANG proposal * */
+/* * * */
+/* ************************************************************************** */
+
+#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
+#pragma option -A /* force ANSI-C */
+#endif
+
+#ifndef _libmng_chunk_descr_h_
+#define _libmng_chunk_descr_h_
+
+/* ************************************************************************** */
+
+#ifdef MNG_OPTIMIZE_CHUNKREADER
+#if defined(MNG_INCLUDE_READ_PROCS) || defined(MNG_INCLUDE_WRITE_PROCS)
+
+/* ************************************************************************** */
+
+void mng_get_chunkheader (mng_chunkid iChunkname,
+ mng_chunk_headerp pResult);
+
+/* ************************************************************************** */
+
+#define MNG_F_SPECIALFUNC(n) mng_retcode n (mng_datap pData, \
+ mng_chunkp pChunk, \
+ mng_uint32* piRawlen, \
+ mng_uint8p* ppRawdata)
+
+MNG_F_SPECIALFUNC (mng_debunk_plte) ;
+MNG_F_SPECIALFUNC (mng_debunk_trns) ;
+MNG_F_SPECIALFUNC (mng_deflate_itxt) ;
+MNG_F_SPECIALFUNC (mng_splt_entries) ;
+MNG_F_SPECIALFUNC (mng_hist_entries) ;
+
+MNG_F_SPECIALFUNC (mng_debunk_loop) ;
+MNG_F_SPECIALFUNC (mng_debunk_past) ;
+MNG_F_SPECIALFUNC (mng_disc_entries) ;
+MNG_F_SPECIALFUNC (mng_fram_remainder) ;
+MNG_F_SPECIALFUNC (mng_save_entries) ;
+MNG_F_SPECIALFUNC (mng_pplt_entries) ;
+MNG_F_SPECIALFUNC (mng_drop_entries) ;
+MNG_F_SPECIALFUNC (mng_ordr_entries) ;
+MNG_F_SPECIALFUNC (mng_debunk_magn) ;
+MNG_F_SPECIALFUNC (mng_evnt_entries) ;
+MNG_F_SPECIALFUNC (mng_adat_tiles) ;
+
+/* ************************************************************************** */
+
+#define MNG_C_SPECIALFUNC(n) mng_retcode n (mng_datap pData, \
+ mng_chunkp pChunk)
+
+MNG_C_SPECIALFUNC (mng_special_ihdr) ;
+MNG_C_SPECIALFUNC (mng_special_plte) ;
+MNG_C_SPECIALFUNC (mng_special_idat) ;
+MNG_C_SPECIALFUNC (mng_special_iend) ;
+MNG_C_SPECIALFUNC (mng_special_trns) ;
+MNG_C_SPECIALFUNC (mng_special_gama) ;
+MNG_C_SPECIALFUNC (mng_special_chrm) ;
+MNG_C_SPECIALFUNC (mng_special_srgb) ;
+MNG_C_SPECIALFUNC (mng_special_iccp) ;
+MNG_C_SPECIALFUNC (mng_special_text) ;
+MNG_C_SPECIALFUNC (mng_special_ztxt) ;
+MNG_C_SPECIALFUNC (mng_special_itxt) ;
+MNG_C_SPECIALFUNC (mng_special_bkgd) ;
+MNG_C_SPECIALFUNC (mng_special_phys) ;
+MNG_C_SPECIALFUNC (mng_special_sbit) ;
+MNG_C_SPECIALFUNC (mng_special_splt) ;
+MNG_C_SPECIALFUNC (mng_special_hist) ;
+MNG_C_SPECIALFUNC (mng_special_time) ;
+
+MNG_C_SPECIALFUNC (mng_special_jhdr) ;
+MNG_C_SPECIALFUNC (mng_special_jdaa) ;
+MNG_C_SPECIALFUNC (mng_special_jdat) ;
+MNG_C_SPECIALFUNC (mng_special_jsep) ;
+
+MNG_C_SPECIALFUNC (mng_special_mhdr) ;
+MNG_C_SPECIALFUNC (mng_special_mend) ;
+MNG_C_SPECIALFUNC (mng_special_loop) ;
+MNG_C_SPECIALFUNC (mng_special_endl) ;
+MNG_C_SPECIALFUNC (mng_special_defi) ;
+MNG_C_SPECIALFUNC (mng_special_basi) ;
+MNG_C_SPECIALFUNC (mng_special_clon) ;
+MNG_C_SPECIALFUNC (mng_special_past) ;
+MNG_C_SPECIALFUNC (mng_special_disc) ;
+MNG_C_SPECIALFUNC (mng_special_back) ;
+MNG_C_SPECIALFUNC (mng_special_fram) ;
+MNG_C_SPECIALFUNC (mng_special_move) ;
+MNG_C_SPECIALFUNC (mng_special_clip) ;
+MNG_C_SPECIALFUNC (mng_special_show) ;
+MNG_C_SPECIALFUNC (mng_special_term) ;
+MNG_C_SPECIALFUNC (mng_special_save) ;
+MNG_C_SPECIALFUNC (mng_special_seek) ;
+MNG_C_SPECIALFUNC (mng_special_expi) ;
+MNG_C_SPECIALFUNC (mng_special_fpri) ;
+MNG_C_SPECIALFUNC (mng_special_need) ;
+MNG_C_SPECIALFUNC (mng_special_phyg) ;
+
+MNG_C_SPECIALFUNC (mng_special_dhdr) ;
+MNG_C_SPECIALFUNC (mng_special_prom) ;
+MNG_C_SPECIALFUNC (mng_special_ipng) ;
+MNG_C_SPECIALFUNC (mng_special_pplt) ;
+MNG_C_SPECIALFUNC (mng_special_ijng) ;
+MNG_C_SPECIALFUNC (mng_special_drop) ;
+MNG_C_SPECIALFUNC (mng_special_dbyk) ;
+MNG_C_SPECIALFUNC (mng_special_ordr) ;
+
+MNG_C_SPECIALFUNC (mng_special_magn) ;
+MNG_C_SPECIALFUNC (mng_special_evnt) ;
+MNG_C_SPECIALFUNC (mng_special_mpng) ;
+MNG_C_SPECIALFUNC (mng_special_ahdr) ;
+MNG_C_SPECIALFUNC (mng_special_adat) ;
+MNG_C_SPECIALFUNC (mng_special_unknown) ;
+
+/* ************************************************************************** */
+
+#endif /* MNG_INCLUDE_READ_PROCS) || MNG_INCLUDE_WRITE_PROCS */
+#endif /* MNG_OPTIMIZE_CHUNKREADER */
+
+/* ************************************************************************** */
+
+#endif /* _libmng_chunk_descr_h_ */
+
+/* ************************************************************************** */
+/* * end of file * */
+/* ************************************************************************** */
diff --git a/src/3rdparty/libmng/libmng_chunk_io.c b/src/3rdparty/libmng/libmng_chunk_io.c
new file mode 100644
index 0000000000..eb18099fd6
--- /dev/null
+++ b/src/3rdparty/libmng/libmng_chunk_io.c
@@ -0,0 +1,10740 @@
+/** ************************************************************************* */
+/* * For conditions of distribution and use, * */
+/* * see copyright notice in libmng.h * */
+/* ************************************************************************** */
+/* * * */
+/* * project : libmng * */
+/* * file : libmng_chunk_io.c copyright (c) 2000-2007 G.Juyn * */
+/* * version : 1.0.10 * */
+/* * * */
+/* * purpose : Chunk I/O routines (implementation) * */
+/* * * */
+/* * author : G.Juyn * */
+/* * * */
+/* * comment : implementation of chunk input/output routines * */
+/* * * */
+/* * changes : 0.5.1 - 05/01/2000 - G.Juyn * */
+/* * - cleaned up left-over teststuff in the BACK chunk routine * */
+/* * 0.5.1 - 05/04/2000 - G.Juyn * */
+/* * - changed CRC initialization to use dynamic structure * */
+/* * (wasn't thread-safe the old way !) * */
+/* * 0.5.1 - 05/06/2000 - G.Juyn * */
+/* * - filled in many missing sequence&length checks * */
+/* * - filled in many missing chunk-store snippets * */
+/* * 0.5.1 - 05/08/2000 - G.Juyn * */
+/* * - added checks for running animations * */
+/* * - filled some write routines * */
+/* * - changed strict-ANSI stuff * */
+/* * 0.5.1 - 05/10/2000 - G.Juyn * */
+/* * - filled some more write routines * */
+/* * 0.5.1 - 05/11/2000 - G.Juyn * */
+/* * - filled remaining write routines * */
+/* * - fixed read_pplt with regard to deltatype * */
+/* * - added callback error-reporting support * */
+/* * - added pre-draft48 support (short MHDR, frame_mode, LOOP) * */
+/* * 0.5.1 - 05/12/2000 - G.Juyn * */
+/* * - changed trace to macro for callback error-reporting * */
+/* * - fixed chunk-storage bit in several routines * */
+/* * 0.5.1 - 05/13/2000 - G.Juyn * */
+/* * - added eMNGma hack (will be removed in 1.0.0 !!!) * */
+/* * - added TERM animation object pointer (easier reference) * */
+/* * - supplemented the SAVE & SEEK display processing * */
+/* * * */
+/* * 0.5.2 - 05/18/2000 - G.Juyn * */
+/* * - B004 - fixed problem with MNG_SUPPORT_WRITE not defined * */
+/* * also for MNG_SUPPORT_WRITE without MNG_INCLUDE_JNG * */
+/* * 0.5.2 - 05/19/2000 - G.Juyn * */
+/* * - cleaned up some code regarding mixed support * */
+/* * 0.5.2 - 05/20/2000 - G.Juyn * */
+/* * - implemented JNG support * */
+/* * 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 support for SAVE & SEEK in animation * */
+/* * 0.5.2 - 05/29/2000 - G.Juyn * */
+/* * - changed ani_create calls not returning object pointer * */
+/* * - create ani objects always (not just inside TERM/LOOP) * */
+/* * 0.5.2 - 05/30/2000 - G.Juyn * */
+/* * - added support for delta-image processing * */
+/* * 0.5.2 - 05/31/2000 - G.Juyn * */
+/* * - fixed up punctuation (contributed by Tim Rowley) * */
+/* * 0.5.2 - 06/02/2000 - G.Juyn * */
+/* * - changed SWAP_ENDIAN to BIGENDIAN_SUPPORTED * */
+/* * 0.5.2 - 06/03/2000 - G.Juyn * */
+/* * - fixed makeup for Linux gcc compile * */
+/* * * */
+/* * 0.5.3 - 06/12/2000 - G.Juyn * */
+/* * - added processing of color-info on delta-image * */
+/* * 0.5.3 - 06/13/2000 - G.Juyn * */
+/* * - fixed handling of empty SAVE chunk * */
+/* * 0.5.3 - 06/17/2000 - G.Juyn * */
+/* * - changed to support delta-images * */
+/* * - added extra checks for delta-images * */
+/* * 0.5.3 - 06/20/2000 - G.Juyn * */
+/* * - fixed possible trouble if IEND display-process got * */
+/* * broken up * */
+/* * 0.5.3 - 06/21/2000 - G.Juyn * */
+/* * - added processing of PLTE & tRNS for delta-images * */
+/* * - added administration of imagelevel parameter * */
+/* * 0.5.3 - 06/22/2000 - G.Juyn * */
+/* * - implemented support for PPLT chunk * */
+/* * 0.5.3 - 06/26/2000 - G.Juyn * */
+/* * - added precaution against faulty iCCP chunks from PS * */
+/* * 0.5.3 - 06/29/2000 - G.Juyn * */
+/* * - fixed some 64-bit warnings * */
+/* * * */
+/* * 0.9.1 - 07/14/2000 - G.Juyn * */
+/* * - changed pre-draft48 frame_mode=3 to frame_mode=1 * */
+/* * 0.9.1 - 07/16/2000 - G.Juyn * */
+/* * - fixed storage of images during mng_read() * */
+/* * - fixed support for mng_display() after mng_read() * */
+/* * 0.9.1 - 07/19/2000 - G.Juyn * */
+/* * - fixed several chunk-writing routines * */
+/* * 0.9.1 - 07/24/2000 - G.Juyn * */
+/* * - fixed reading of still-images * */
+/* * * */
+/* * 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/08/2000 - G.Juyn * */
+/* * - fixed compiler-warnings from Mozilla * */
+/* * 0.9.3 - 08/09/2000 - G.Juyn * */
+/* * - added check for simplicity-bits in MHDR * */
+/* * 0.9.3 - 08/12/2000 - G.Juyn * */
+/* * - fixed check for simplicity-bits in MHDR (JNG) * */
+/* * 0.9.3 - 08/12/2000 - G.Juyn * */
+/* * - added workaround for faulty PhotoShop iCCP chunk * */
+/* * 0.9.3 - 08/22/2000 - G.Juyn * */
+/* * - fixed write-code for zTXt & iTXt * */
+/* * - fixed read-code for iTXt * */
+/* * 0.9.3 - 08/26/2000 - G.Juyn * */
+/* * - added MAGN chunk * */
+/* * 0.9.3 - 09/07/2000 - G.Juyn * */
+/* * - added support for new filter_types * */
+/* * 0.9.3 - 09/10/2000 - G.Juyn * */
+/* * - fixed DEFI behavior * */
+/* * 0.9.3 - 10/02/2000 - G.Juyn * */
+/* * - fixed simplicity-check in compliance with draft 81/0.98a * */
+/* * 0.9.3 - 10/10/2000 - G.Juyn * */
+/* * - added support for alpha-depth prediction * */
+/* * 0.9.3 - 10/11/2000 - G.Juyn * */
+/* * - added support for nEED * */
+/* * 0.9.3 - 10/16/2000 - G.Juyn * */
+/* * - added support for JDAA * */
+/* * 0.9.3 - 10/17/2000 - G.Juyn * */
+/* * - fixed support for MAGN * */
+/* * - implemented nEED "xxxx" (where "xxxx" is a chunkid) * */
+/* * - added callback to process non-critical unknown chunks * */
+/* * - fixed support for bKGD * */
+/* * 0.9.3 - 10/23/2000 - G.Juyn * */
+/* * - fixed bug in empty PLTE handling * */
+/* * * */
+/* * 0.9.4 - 11/20/2000 - G.Juyn * */
+/* * - changed IHDR filter_method check for PNGs * */
+/* * 0.9.4 - 1/18/2001 - G.Juyn * */
+/* * - added errorchecking for MAGN methods * */
+/* * - removed test filter-methods 1 & 65 * */
+/* * * */
+/* * 0.9.5 - 1/25/2001 - G.Juyn * */
+/* * - fixed some small compiler warnings (thanks Nikki) * */
+/* * * */
+/* * 1.0.2 - 05/05/2000 - G.Juyn * */
+/* * - B421427 - writes wrong format in bKGD and tRNS * */
+/* * 1.0.2 - 06/20/2000 - G.Juyn * */
+/* * - B434583 - compiler-warning if MNG_STORE_CHUNKS undefined * */
+/* * * */
+/* * 1.0.5 - 07/08/2002 - G.Juyn * */
+/* * - B578572 - removed eMNGma hack (thanks Dimitri!) * */
+/* * 1.0.5 - 08/07/2002 - G.Juyn * */
+/* * - added test-option for PNG filter method 193 (=no filter) * */
+/* * 1.0.5 - 08/15/2002 - G.Juyn * */
+/* * - completed PROM support * */
+/* * 1.0.5 - 08/19/2002 - G.Juyn * */
+/* * - B597134 - libmng pollutes the linker namespace * */
+/* * 1.0.5 - 09/07/2002 - G.Juyn * */
+/* * - fixed reading of FRAM with just frame_mode and name * */
+/* * 1.0.5 - 09/13/2002 - G.Juyn * */
+/* * - fixed read/write of MAGN chunk * */
+/* * 1.0.5 - 09/14/2002 - G.Juyn * */
+/* * - added event handling for dynamic MNG * */
+/* * 1.0.5 - 09/15/2002 - G.Juyn * */
+/* * - fixed LOOP iteration=0 special case * */
+/* * 1.0.5 - 09/19/2002 - G.Juyn * */
+/* * - misplaced TERM is now treated as warning * */
+/* * 1.0.5 - 09/20/2002 - G.Juyn * */
+/* * - added support for PAST * */
+/* * 1.0.5 - 10/03/2002 - G.Juyn * */
+/* * - fixed chunk-storage for evNT chunk * */
+/* * 1.0.5 - 10/07/2002 - G.Juyn * */
+/* * - fixed DISC support * */
+/* * - added another fix for misplaced TERM chunk * */
+/* * 1.0.5 - 10/17/2002 - G.Juyn * */
+/* * - fixed initializtion of pIds in dISC read routine * */
+/* * 1.0.5 - 11/06/2002 - G.Juyn * */
+/* * - added support for nEED "MNG 1.1" * */
+/* * - added support for nEED "CACHEOFF" * */
+/* * * */
+/* * 1.0.6 - 05/25/2003 - G.R-P * */
+/* * - added MNG_SKIPCHUNK_cHNK footprint optimizations * */
+/* * 1.0.6 - 06/02/2003 - G.R-P * */
+/* * - removed some redundant checks for iRawlen==0 * */
+/* * 1.0.6 - 06/22/2003 - G.R-P * */
+/* * - added MNG_NO_16BIT_SUPPORT, MNG_NO_DELTA_PNG reductions * */
+/* * - optionally use zlib's crc32 function instead of * */
+/* * local mng_update_crc * */
+/* * 1.0.6 - 07/14/2003 - G.R-P * */
+/* * - added MNG_NO_LOOP_SIGNALS_SUPPORTED conditional * */
+/* * 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.7 - 10/29/2003 - G.R-P * */
+/* * - revised JDAA and JDAT readers to avoid compiler bug * */
+/* * 1.0.7 - 01/25/2004 - J.S * */
+/* * - added premultiplied alpha canvas' for RGBA, ARGB, ABGR * */
+/* * 1.0.7 - 01/27/2004 - J.S * */
+/* * - fixed inclusion of IJNG chunk for non-JNG use * */
+/* * 1.0.7 - 02/26/2004 - G.Juyn * */
+/* * - fixed bug in chunk-storage of SHOW chunk (from == to) * */
+/* * * */
+/* * 1.0.8 - 04/02/2004 - G.Juyn * */
+/* * - added CRC existence & checking flags * */
+/* * 1.0.8 - 07/07/2004 - G.R-P * */
+/* * - change worst-case iAlphadepth to 1 for standalone PNGs * */
+/* * * */
+/* * 1.0.9 - 09/28/2004 - G.R-P * */
+/* * - improved handling of cheap transparency when 16-bit * */
+/* * support is disabled * */
+/* * 1.0.9 - 10/04/2004 - G.Juyn * */
+/* * - fixed bug in writing sBIT for indexed color * */
+/* * 1.0.9 - 10/10/2004 - G.R-P. * */
+/* * - added MNG_NO_1_2_4BIT_SUPPORT * */
+/* * 1.0.9 - 12/05/2004 - G.Juyn * */
+/* * - added conditional MNG_OPTIMIZE_CHUNKINITFREE * */
+/* * 1.0.9 - 12/06/2004 - G.Juyn * */
+/* * - added conditional MNG_OPTIMIZE_CHUNKASSIGN * */
+/* * 1.0.9 - 12/07/2004 - G.Juyn * */
+/* * - added conditional MNG_OPTIMIZE_CHUNKREADER * */
+/* * 1.0.9 - 12/11/2004 - G.Juyn * */
+/* * - added conditional MNG_OPTIMIZE_DISPLAYCALLS * */
+/* * 1.0.9 - 12/20/2004 - G.Juyn * */
+/* * - cleaned up macro-invocations (thanks to D. Airlie) * */
+/* * 1.0.9 - 01/17/2005 - G.Juyn * */
+/* * - fixed problem with global PLTE/tRNS * */
+/* * * */
+/* * 1.0.10 - 02/07/2005 - G.Juyn * */
+/* * - fixed display routines called twice for FULL_MNG * */
+/* * support in mozlibmngconf.h * */
+/* * 1.0.10 - 12/04/2005 - G.R-P. * */
+/* * - #ifdef out use of mng_inflate_buffer when it is not * */
+/* * available. * */
+/* * 1.0.10 - 04/08/2007 - G.Juyn * */
+/* * - added support for mPNG proposal * */
+/* * 1.0.10 - 04/12/2007 - G.Juyn * */
+/* * - added support for ANG proposal * */
+/* * 1.0.10 - 05/02/2007 - G.Juyn * */
+/* * - fixed inflate_buffer for extreme compression ratios * */
+/* * * */
+/* ************************************************************************** */
+
+#include "libmng.h"
+#include "libmng_data.h"
+#include "libmng_error.h"
+#include "libmng_trace.h"
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+#include "libmng_objects.h"
+#include "libmng_object_prc.h"
+#include "libmng_chunks.h"
+#ifdef MNG_CHECK_BAD_ICCP
+#include "libmng_chunk_prc.h"
+#endif
+#include "libmng_memory.h"
+#include "libmng_display.h"
+#include "libmng_zlib.h"
+#include "libmng_pixels.h"
+#include "libmng_chunk_io.h"
+
+#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
+#pragma option -A /* force ANSI-C */
+#endif
+
+/* ************************************************************************** */
+/* * * */
+/* * CRC - Cyclic Redundancy Check * */
+/* * * */
+/* * The code below is taken directly from the sample provided with the * */
+/* * PNG specification. * */
+/* * (it is only adapted to the library's internal data-definitions) * */
+/* * * */
+/* ************************************************************************** */
+/* Make the table for a fast CRC. */
+#ifndef MNG_USE_ZLIB_CRC
+MNG_LOCAL void make_crc_table (mng_datap pData)
+{
+ mng_uint32 iC;
+ mng_int32 iN, iK;
+
+ for (iN = 0; iN < 256; iN++)
+ {
+ iC = (mng_uint32) iN;
+
+ for (iK = 0; iK < 8; iK++)
+ {
+ if (iC & 1)
+ iC = 0xedb88320U ^ (iC >> 1);
+ else
+ iC = iC >> 1;
+ }
+
+ pData->aCRCtable [iN] = iC;
+ }
+
+ pData->bCRCcomputed = MNG_TRUE;
+}
+#endif
+
+/* Update a running CRC with the bytes buf[0..len-1]--the CRC
+ should be initialized to all 1's, and the transmitted value
+ is the 1's complement of the final running CRC (see the
+ crc() routine below). */
+
+MNG_LOCAL mng_uint32 update_crc (mng_datap pData,
+ mng_uint32 iCrc,
+ mng_uint8p pBuf,
+ mng_int32 iLen)
+{
+#ifdef MNG_USE_ZLIB_CRC
+ return crc32 (iCrc, pBuf, iLen);
+#else
+ mng_uint32 iC = iCrc;
+ mng_int32 iN;
+
+ if (!pData->bCRCcomputed)
+ make_crc_table (pData);
+
+ for (iN = 0; iN < iLen; iN++)
+ iC = pData->aCRCtable [(iC ^ pBuf [iN]) & 0xff] ^ (iC >> 8);
+
+ return iC;
+#endif
+}
+
+/* Return the CRC of the bytes buf[0..len-1]. */
+mng_uint32 mng_crc (mng_datap pData,
+ mng_uint8p pBuf,
+ mng_int32 iLen)
+{
+#ifdef MNG_USE_ZLIB_CRC
+ return update_crc (pData, 0, pBuf, iLen);
+#else
+ return update_crc (pData, 0xffffffffU, pBuf, iLen) ^ 0xffffffffU;
+#endif
+}
+
+/* ************************************************************************** */
+/* * * */
+/* * Routines for swapping byte-order from and to graphic files * */
+/* * (This code is adapted from the libpng package) * */
+/* * * */
+/* ************************************************************************** */
+
+#ifndef MNG_BIGENDIAN_SUPPORTED
+
+/* ************************************************************************** */
+
+mng_uint32 mng_get_uint32 (mng_uint8p pBuf)
+{
+ mng_uint32 i = ((mng_uint32)(*pBuf) << 24) +
+ ((mng_uint32)(*(pBuf + 1)) << 16) +
+ ((mng_uint32)(*(pBuf + 2)) << 8) +
+ (mng_uint32)(*(pBuf + 3));
+ return (i);
+}
+
+/* ************************************************************************** */
+
+mng_int32 mng_get_int32 (mng_uint8p pBuf)
+{
+ mng_int32 i = ((mng_int32)(*pBuf) << 24) +
+ ((mng_int32)(*(pBuf + 1)) << 16) +
+ ((mng_int32)(*(pBuf + 2)) << 8) +
+ (mng_int32)(*(pBuf + 3));
+ return (i);
+}
+
+/* ************************************************************************** */
+
+mng_uint16 mng_get_uint16 (mng_uint8p pBuf)
+{
+ mng_uint16 i = (mng_uint16)(((mng_uint16)(*pBuf) << 8) +
+ (mng_uint16)(*(pBuf + 1)));
+ return (i);
+}
+
+/* ************************************************************************** */
+
+void mng_put_uint32 (mng_uint8p pBuf,
+ mng_uint32 i)
+{
+ *pBuf = (mng_uint8)((i >> 24) & 0xff);
+ *(pBuf+1) = (mng_uint8)((i >> 16) & 0xff);
+ *(pBuf+2) = (mng_uint8)((i >> 8) & 0xff);
+ *(pBuf+3) = (mng_uint8)(i & 0xff);
+}
+
+/* ************************************************************************** */
+
+void mng_put_int32 (mng_uint8p pBuf,
+ mng_int32 i)
+{
+ *pBuf = (mng_uint8)((i >> 24) & 0xff);
+ *(pBuf+1) = (mng_uint8)((i >> 16) & 0xff);
+ *(pBuf+2) = (mng_uint8)((i >> 8) & 0xff);
+ *(pBuf+3) = (mng_uint8)(i & 0xff);
+}
+
+/* ************************************************************************** */
+
+void mng_put_uint16 (mng_uint8p pBuf,
+ mng_uint16 i)
+{
+ *pBuf = (mng_uint8)((i >> 8) & 0xff);
+ *(pBuf+1) = (mng_uint8)(i & 0xff);
+}
+
+/* ************************************************************************** */
+
+#endif /* !MNG_BIGENDIAN_SUPPORTED */
+
+/* ************************************************************************** */
+/* * * */
+/* * Helper routines to simplify chunk-data extraction * */
+/* * * */
+/* ************************************************************************** */
+
+#ifdef MNG_INCLUDE_READ_PROCS
+
+/* ************************************************************************** */
+
+#ifndef MNG_OPTIMIZE_CHUNKREADER
+MNG_LOCAL mng_uint8p find_null (mng_uint8p pIn)
+{
+ mng_uint8p pOut = pIn;
+ while (*pOut) /* the read_graphic routine has made sure there's */
+ pOut++; /* always at least 1 zero-byte in the buffer */
+ return pOut;
+}
+#endif
+
+/* ************************************************************************** */
+
+#if !defined(MNG_SKIPCHUNK_iCCP) || !defined(MNG_SKIPCHUNK_zTXt) || \
+ !defined(MNG_SKIPCHUNK_iTXt) || defined(MNG_INCLUDE_MPNG_PROPOSAL) || \
+ defined(MNG_INCLUDE_ANG_PROPOSAL)
+mng_retcode mng_inflate_buffer (mng_datap pData,
+ mng_uint8p pInbuf,
+ mng_uint32 iInsize,
+ mng_uint8p *pOutbuf,
+ mng_uint32 *iOutsize,
+ mng_uint32 *iRealsize)
+{
+ mng_retcode iRetcode = MNG_NOERROR;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (pData, MNG_FN_INFLATE_BUFFER, MNG_LC_START);
+#endif
+
+ if (iInsize) /* anything to do ? */
+ {
+ *iOutsize = iInsize * 3; /* estimate uncompressed size */
+ /* and allocate a temporary buffer */
+ MNG_ALLOC (pData, *pOutbuf, *iOutsize);
+
+ do
+ {
+ mngzlib_inflateinit (pData); /* initialize zlib */
+ /* let zlib know where to store the output */
+ pData->sZlib.next_out = *pOutbuf;
+ /* "size - 1" so we've got space for the
+ zero-termination of a possible string */
+ pData->sZlib.avail_out = *iOutsize - 1;
+ /* ok; let's inflate... */
+ iRetcode = mngzlib_inflatedata (pData, iInsize, pInbuf);
+ /* determine actual output size */
+ *iRealsize = (mng_uint32)pData->sZlib.total_out;
+
+ mngzlib_inflatefree (pData); /* zlib's done */
+
+ if (iRetcode == MNG_BUFOVERFLOW) /* not enough space ? */
+ { /* then get some more */
+ MNG_FREEX (pData, *pOutbuf, *iOutsize);
+ *iOutsize = *iOutsize + *iOutsize;
+ MNG_ALLOC (pData, *pOutbuf, *iOutsize);
+ }
+ } /* repeat if we didn't have enough space */
+ while ((iRetcode == MNG_BUFOVERFLOW) &&
+ (*iOutsize < 200 * iInsize));
+
+ if (!iRetcode) /* if oke ? */
+ *((*pOutbuf) + *iRealsize) = 0; /* then put terminator zero */
+
+ }
+ else
+ {
+ *pOutbuf = 0; /* nothing to do; then there's no output */
+ *iOutsize = 0;
+ *iRealsize = 0;
+ }
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (pData, MNG_FN_INFLATE_BUFFER, MNG_LC_END);
+#endif
+
+ return iRetcode;
+}
+#endif
+
+/* ************************************************************************** */
+
+#endif /* MNG_INCLUDE_READ_PROCS */
+
+/* ************************************************************************** */
+/* * * */
+/* * Helper routines to simplify chunk writing * */
+/* * * */
+/* ************************************************************************** */
+#ifdef MNG_INCLUDE_WRITE_PROCS
+/* ************************************************************************** */
+
+#if !defined(MNG_SKIPCHUNK_iCCP) || !defined(MNG_SKIPCHUNK_zTXt) || !defined(MNG_SKIPCHUNK_iTXt)
+MNG_LOCAL mng_retcode deflate_buffer (mng_datap pData,
+ mng_uint8p pInbuf,
+ mng_uint32 iInsize,
+ mng_uint8p *pOutbuf,
+ mng_uint32 *iOutsize,
+ mng_uint32 *iRealsize)
+{
+ mng_retcode iRetcode = MNG_NOERROR;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (pData, MNG_FN_DEFLATE_BUFFER, MNG_LC_START);
+#endif
+
+ if (iInsize) /* anything to do ? */
+ {
+ *iOutsize = (iInsize * 5) >> 2; /* estimate compressed size */
+ /* and allocate a temporary buffer */
+ MNG_ALLOC (pData, *pOutbuf, *iOutsize);
+
+ do
+ {
+ mngzlib_deflateinit (pData); /* initialize zlib */
+ /* let zlib know where to store the output */
+ pData->sZlib.next_out = *pOutbuf;
+ pData->sZlib.avail_out = *iOutsize;
+ /* ok; let's deflate... */
+ iRetcode = mngzlib_deflatedata (pData, iInsize, pInbuf);
+ /* determine actual output size */
+ *iRealsize = pData->sZlib.total_out;
+
+ mngzlib_deflatefree (pData); /* zlib's done */
+
+ if (iRetcode == MNG_BUFOVERFLOW) /* not enough space ? */
+ { /* then get some more */
+ MNG_FREEX (pData, *pOutbuf, *iOutsize);
+ *iOutsize = *iOutsize + (iInsize >> 1);
+ MNG_ALLOC (pData, *pOutbuf, *iOutsize);
+ }
+ } /* repeat if we didn't have enough space */
+ while (iRetcode == MNG_BUFOVERFLOW);
+ }
+ else
+ {
+ *pOutbuf = 0; /* nothing to do; then there's no output */
+ *iOutsize = 0;
+ *iRealsize = 0;
+ }
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (pData, MNG_FN_DEFLATE_BUFFER, MNG_LC_END);
+#endif
+
+ return iRetcode;
+}
+#endif
+
+/* ************************************************************************** */
+
+MNG_LOCAL mng_retcode write_raw_chunk (mng_datap pData,
+ mng_chunkid iChunkname,
+ mng_uint32 iRawlen,
+ mng_uint8p pRawdata)
+{
+ mng_uint32 iCrc;
+ mng_uint32 iWritten;
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (pData, MNG_FN_WRITE_RAW_CHUNK, MNG_LC_START);
+#endif
+ /* temporary buffer ? */
+ if ((pRawdata != 0) && (pRawdata != pData->pWritebuf+8))
+ { /* store length & chunktype in default buffer */
+ mng_put_uint32 (pData->pWritebuf, iRawlen);
+ mng_put_uint32 (pData->pWritebuf+4, (mng_uint32)iChunkname);
+
+ if (pData->iCrcmode & MNG_CRC_OUTPUT)
+ {
+ if ((pData->iCrcmode & MNG_CRC_OUTPUT) == MNG_CRC_OUTPUT_GENERATE)
+ { /* calculate the crc */
+ iCrc = update_crc (pData, 0xffffffffL, pData->pWritebuf+4, 4);
+ iCrc = update_crc (pData, iCrc, pRawdata, iRawlen) ^ 0xffffffffL;
+ } else {
+ iCrc = 0; /* dummy crc */
+ } /* store in default buffer */
+ mng_put_uint32 (pData->pWritebuf+8, iCrc);
+ }
+ /* write the length & chunktype */
+ if (!pData->fWritedata ((mng_handle)pData, pData->pWritebuf, 8, &iWritten))
+ MNG_ERROR (pData, MNG_APPIOERROR);
+
+ if (iWritten != 8) /* disk full ? */
+ MNG_ERROR (pData, MNG_OUTPUTERROR);
+ /* write the temporary buffer */
+ if (!pData->fWritedata ((mng_handle)pData, pRawdata, iRawlen, &iWritten))
+ MNG_ERROR (pData, MNG_APPIOERROR);
+
+ if (iWritten != iRawlen) /* disk full ? */
+ MNG_ERROR (pData, MNG_OUTPUTERROR);
+
+ if (pData->iCrcmode & MNG_CRC_OUTPUT)
+ { /* write the crc */
+ if (!pData->fWritedata ((mng_handle)pData, pData->pWritebuf+8, 4, &iWritten))
+ MNG_ERROR (pData, MNG_APPIOERROR);
+
+ if (iWritten != 4) /* disk full ? */
+ MNG_ERROR (pData, MNG_OUTPUTERROR);
+ }
+ }
+ else
+ { /* prefix with length & chunktype */
+ mng_put_uint32 (pData->pWritebuf, iRawlen);
+ mng_put_uint32 (pData->pWritebuf+4, (mng_uint32)iChunkname);
+
+ if (pData->iCrcmode & MNG_CRC_OUTPUT)
+ {
+ if ((pData->iCrcmode & MNG_CRC_OUTPUT) == MNG_CRC_OUTPUT_GENERATE)
+ /* calculate the crc */
+ iCrc = mng_crc (pData, pData->pWritebuf+4, iRawlen + 4);
+ else
+ iCrc = 0; /* dummy crc */
+ /* add it to the buffer */
+ mng_put_uint32 (pData->pWritebuf + iRawlen + 8, iCrc);
+ /* write it in a single pass */
+ if (!pData->fWritedata ((mng_handle)pData, pData->pWritebuf, iRawlen + 12, &iWritten))
+ MNG_ERROR (pData, MNG_APPIOERROR);
+
+ if (iWritten != iRawlen + 12) /* disk full ? */
+ MNG_ERROR (pData, MNG_OUTPUTERROR);
+ } else {
+ if (!pData->fWritedata ((mng_handle)pData, pData->pWritebuf, iRawlen + 8, &iWritten))
+ MNG_ERROR (pData, MNG_APPIOERROR);
+
+ if (iWritten != iRawlen + 8) /* disk full ? */
+ MNG_ERROR (pData, MNG_OUTPUTERROR);
+ }
+ }
+
+#ifdef MNG_SUPPORT_TRACE
+ MNG_TRACE (pData, MNG_FN_WRITE_RAW_CHUNK, MNG_LC_END);
+#endif
+
+ return MNG_NOERROR;
+}
+
+/* ************************************************************************** */
+/* B004 */
+#endif /* MNG_INCLUDE_WRITE_PROCS */
+/* B004 */
+/* ************************************************************************** */
+/* * * */
+/* * chunk read functions * */
+/* * * */
+/* ************************************************************************** */
+
+#ifdef MNG_INCLUDE_READ_PROCS
+
+/* ************************************************************************** */
+
+#ifdef MNG_OPTIMIZE_CHUNKREADER
+
+/* ************************************************************************** */
+
+MNG_LOCAL mng_retcode create_chunk_storage (mng_datap pData,
+ mng_chunkp pHeader,
+ mng_uint32 iRawlen,
+ mng_uint8p pRawdata,
+ mng_field_descp pField,
+ mng_uint16 iFields,
+ mng_chunkp* ppChunk,
+ mng_bool bWorkcopy)
+{
+ mng_field_descp pTempfield = pField;
+ mng_uint16 iFieldcount = iFields;
+ mng_uint8p pTempdata = pRawdata;
+ mng_uint32 iTemplen = iRawlen;
+ mng_uint16 iLastgroup = 0;
+ mng_uint8p pChunkdata;
+ mng_uint32 iDatalen;
+ mng_uint8 iColortype;
+ mng_bool bProcess;
+ /* initialize storage */
+ mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk);
+ if (iRetcode) /* on error bail out */
+ return iRetcode;
+
+ if (((mng_chunk_headerp)(*ppChunk))->iChunkname == MNG_UINT_HUH)
+ ((mng_chunk_headerp)(*ppChunk))->iChunkname = pData->iChunkname;
+
+ if ((!bWorkcopy) ||
+ ((((mng_chunk_headerp)pHeader)->iChunkname != MNG_UINT_IDAT) &&
+ (((mng_chunk_headerp)pHeader)->iChunkname != MNG_UINT_JDAT) &&
+ (((mng_chunk_headerp)pHeader)->iChunkname != MNG_UINT_JDAA) ))
+ {
+ pChunkdata = (mng_uint8p)(*ppChunk);
+
+#ifdef MNG_INCLUDE_JNG /* determine current colortype */
+ if (pData->bHasJHDR)
+ iColortype = (mng_uint8)(pData->iJHDRcolortype - 8);
+ else
+#endif /* MNG_INCLUDE_JNG */
+ if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
+ iColortype = pData->iColortype;
+ else
+ iColortype = 6;
+
+ if (iTemplen) /* not empty ? */
+ { /* then go fill the fields */
+ while ((iFieldcount) && (iTemplen))
+ {
+ if (pTempfield->iOffsetchunk)
+ {
+ if (pTempfield->iFlags & MNG_FIELD_PUTIMGTYPE)
+ {
+ *(pChunkdata+pTempfield->iOffsetchunk) = iColortype;
+ bProcess = MNG_FALSE;
+ }
+ else
+ if (pTempfield->iFlags & MNG_FIELD_IFIMGTYPES)
+ bProcess = (mng_bool)(((pTempfield->iFlags & MNG_FIELD_IFIMGTYPE0) && (iColortype == 0)) ||
+ ((pTempfield->iFlags & MNG_FIELD_IFIMGTYPE2) && (iColortype == 2)) ||
+ ((pTempfield->iFlags & MNG_FIELD_IFIMGTYPE3) && (iColortype == 3)) ||
+ ((pTempfield->iFlags & MNG_FIELD_IFIMGTYPE4) && (iColortype == 4)) ||
+ ((pTempfield->iFlags & MNG_FIELD_IFIMGTYPE6) && (iColortype == 6)) );
+ else
+ bProcess = MNG_TRUE;
+
+ if (bProcess)
+ {
+ iLastgroup = (mng_uint16)(pTempfield->iFlags & MNG_FIELD_GROUPMASK);
+ /* numeric field ? */
+ if (pTempfield->iFlags & MNG_FIELD_INT)
+ {
+ if (iTemplen < pTempfield->iLengthmax)
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+
+ switch (pTempfield->iLengthmax)
+ {
+ case 1 : { mng_uint8 iNum = *pTempdata;
+ if (((mng_uint16)iNum < pTempfield->iMinvalue) ||
+ ((mng_uint16)iNum > pTempfield->iMaxvalue) )
+ MNG_ERROR (pData, MNG_INVALIDFIELDVAL);
+ *(pChunkdata+pTempfield->iOffsetchunk) = iNum;
+ break; }
+ case 2 : { mng_uint16 iNum = mng_get_uint16 (pTempdata);
+ if ((iNum < pTempfield->iMinvalue) || (iNum > pTempfield->iMaxvalue))
+ MNG_ERROR (pData, MNG_INVALIDFIELDVAL);
+ *((mng_uint16p)(pChunkdata+pTempfield->iOffsetchunk)) = iNum;
+ break; }
+ case 4 : { mng_uint32 iNum = mng_get_uint32 (pTempdata);
+ if ((iNum < pTempfield->iMinvalue) ||
+ ((pTempfield->iFlags & MNG_FIELD_NOHIGHBIT) && (iNum & 0x80000000)) )
+ MNG_ERROR (pData, MNG_INVALIDFIELDVAL);
+ *((mng_uint32p)(pChunkdata+pTempfield->iOffsetchunk)) = iNum;
+ break; }
+ }
+
+ pTempdata += pTempfield->iLengthmax;
+ iTemplen -= pTempfield->iLengthmax;
+
+ } else { /* not numeric so it's a bunch of bytes */
+
+ if (!pTempfield->iOffsetchunklen) /* big fat NONO */
+ MNG_ERROR (pData, MNG_INTERNALERROR);
+ /* with terminating 0 ? */
+ if (pTempfield->iFlags & MNG_FIELD_TERMINATOR)
+ {
+ mng_uint8p pWork = pTempdata;
+ while (*pWork) /* find the zero */
+ pWork++;
+ iDatalen = (mng_uint32)(pWork - pTempdata);
+ } else { /* no terminator, so everything that's left ! */
+ iDatalen = iTemplen;
+ }
+
+ if ((pTempfield->iLengthmax) && (iDatalen > pTempfield->iLengthmax))
+ MNG_ERROR (pData, MNG_INVALIDLENGTH);
+#if !defined(MNG_SKIPCHUNK_iCCP) || !defined(MNG_SKIPCHUNK_zTXt) || \
+ !defined(MNG_SKIPCHUNK_iTXt) || defined(MNG_INCLUDE_MPNG_PROPOSAL) || \
+ defined(MNG_INCLUDE_ANG_PROPOSAL)
+ /* needs decompression ? */
+ if (pTempfield->iFlags & MNG_FIELD_DEFLATED)
+ {
+ mng_uint8p pBuf = 0;
+ mng_uint32 iBufsize = 0;
+ mng_uint32 iRealsize;
+ mng_ptr pWork;
+
+ iRetcode = mng_inflate_buffer (pData, pTempdata, iDatalen,
+ &pBuf, &iBufsize, &iRealsize);
+
+#ifdef MNG_CHECK_BAD_ICCP /* Check for bad iCCP chunk */
+ if ((iRetcode) && (((mng_chunk_headerp)pHeader)->iChunkname == MNG_UINT_iCCP))
+ {
+ *((mng_ptr *)(pChunkdata+pTempfield->iOffsetchunk)) = MNG_NULL;
+ *((mng_uint32p)(pChunkdata+pTempfield->iOffsetchunklen)) = iDatalen;
+ }
+ else
+#endif
+ {
+ if (iRetcode)
+ return iRetcode;
+
+#if defined(MNG_INCLUDE_MPNG_PROPOSAL) || defined(MNG_INCLUDE_ANG_PROPOSAL)
+ if ( (((mng_chunk_headerp)pHeader)->iChunkname == MNG_UINT_mpNG) ||
+ (((mng_chunk_headerp)pHeader)->iChunkname == MNG_UINT_adAT) )
+ {
+ MNG_ALLOC (pData, pWork, iRealsize);
+ }
+ else
+ {
+#endif
+ /* don't forget to generate null terminator */
+ MNG_ALLOC (pData, pWork, iRealsize+1);
+#if defined(MNG_INCLUDE_MPNG_PROPOSAL) || defined(MNG_INCLUDE_ANG_PROPOSAL)
+ }
+#endif
+ MNG_COPY (pWork, pBuf, iRealsize);
+
+ *((mng_ptr *)(pChunkdata+pTempfield->iOffsetchunk)) = pWork;
+ *((mng_uint32p)(pChunkdata+pTempfield->iOffsetchunklen)) = iRealsize;
+ }
+
+ if (pBuf) /* free the temporary buffer */
+ MNG_FREEX (pData, pBuf, iBufsize);
+
+ } else
+#endif
+ { /* no decompression, so just copy */
+
+ mng_ptr pWork;
+ /* don't forget to generate null terminator */
+ MNG_ALLOC (pData, pWork, iDatalen+1);
+ MNG_COPY (pWork, pTempdata, iDatalen);
+
+ *((mng_ptr *)(pChunkdata+pTempfield->iOffsetchunk)) = pWork;
+ *((mng_uint32p)(pChunkdata+pTempfield->iOffsetchunklen)) = iDatalen;
+ }
+
+ if (pTempfield->iFlags & MNG_FIELD_TERMINATOR)
+ iDatalen++; /* skip the terminating zero as well !!! */
+
+ iTemplen -= iDatalen;
+ pTempdata += iDatalen;
+ }
+ /* need to set an indicator ? */
+ if (pTempfield->iOffsetchunkind)
+ *((mng_uint8p)(pChunkdata+pTempfield->iOffsetchunkind)) = MNG_TRUE;
+ }
+ }
+
+ if (pTempfield->pSpecialfunc) /* special function required ? */
+ {
+ iRetcode = pTempfield->pSpecialfunc(pData, *ppChunk, &iTemplen, &pTempdata);
+ if (iRetcode) /* on error bail out */
+ return iRetcode;