зеркало из https://github.com/mozilla/pjs.git
Landing libmng 0.9.2+. a=waterson
This commit is contained in:
Родитель
425685290d
Коммит
77c65fc2dd
Двоичные данные
modules/libimg/macbuild/mng.mcp
Двоичные данные
modules/libimg/macbuild/mng.mcp
Двоичный файл не отображается.
|
@ -0,0 +1,525 @@
|
|||
-----------------------------------------------------------
|
||||
|
||||
0.9.3 (xxxxxx nth 2000)
|
||||
-----------------------
|
||||
|
||||
in short:
|
||||
|
||||
Intermediate for the moment.
|
||||
|
||||
- fixed bug 111300
|
||||
|
||||
-------------------
|
||||
|
||||
bugfixes:
|
||||
- B111300 - fixup for improved portability
|
||||
|
||||
core:
|
||||
|
||||
samples:
|
||||
|
||||
contrib:
|
||||
|
||||
doc:
|
||||
|
||||
makefiles:
|
||||
|
||||
-----------------------------------------------------------
|
||||
|
||||
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.
|
|
@ -1,7 +0,0 @@
|
|||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist directory
|
||||
#
|
||||
|
||||
libmng.h
|
||||
mng_conf.h
|
||||
mng_types.h
|
|
@ -30,27 +30,27 @@ MODULE = mng
|
|||
LIBRARY_NAME = mng
|
||||
|
||||
CSRCS = \
|
||||
mng_callback_xs.c \
|
||||
mng_chunk_io.c \
|
||||
mng_chunk_prc.c \
|
||||
mng_chunk_xs.c \
|
||||
mng_cms.c \
|
||||
mng_display.c \
|
||||
mng_dither.c \
|
||||
mng_error.c \
|
||||
mng_filter.c \
|
||||
mng_hlapi.c \
|
||||
mng_jpeg.c \
|
||||
mng_object_prc.c \
|
||||
mng_pixels.c \
|
||||
mng_prop_xs.c \
|
||||
mng_read.c \
|
||||
mng_trace.c \
|
||||
mng_write.c \
|
||||
mng_zlib.c \
|
||||
libmng_callback_xs.c \
|
||||
libmng_chunk_io.c \
|
||||
libmng_chunk_prc.c \
|
||||
libmng_chunk_xs.c \
|
||||
libmng_cms.c \
|
||||
libmng_display.c \
|
||||
libmng_dither.c \
|
||||
libmng_error.c \
|
||||
libmng_filter.c \
|
||||
libmng_hlapi.c \
|
||||
libmng_jpeg.c \
|
||||
libmng_object_prc.c \
|
||||
libmng_pixels.c \
|
||||
libmng_prop_xs.c \
|
||||
libmng_read.c \
|
||||
libmng_trace.c \
|
||||
libmng_write.c \
|
||||
libmng_zlib.c \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = libmng.h mng_conf.h mng_types.h
|
||||
EXPORTS = libmng.h libmng_conf.h libmng_types.h
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
/* * is defined as the following set of individuals: * */
|
||||
/* * * */
|
||||
/* * Gerard Juyn (gerard@libmng.com) * */
|
||||
/* * Tim Rowley * */
|
||||
/* * * */
|
||||
/* * The MNG Library is supplied "AS IS". The Contributing Authors * */
|
||||
/* * disclaim all warranties, expressed or implied, including, without * */
|
||||
|
@ -101,7 +100,7 @@
|
|||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng.h copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.0 * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : main application interface * */
|
||||
/* * * */
|
||||
|
@ -158,6 +157,28 @@
|
|||
/* * 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 * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
|
@ -169,7 +190,7 @@
|
|||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "mng_conf.h" /* user-specific configuration options */
|
||||
#include "libmng_conf.h" /* user-specific configuration options */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -230,7 +251,7 @@
|
|||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "mng_types.h" /* platform-specific definitions
|
||||
#include "libmng_types.h" /* platform-specific definitions
|
||||
and other assorted stuff */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
@ -294,12 +315,12 @@ extern "C" {
|
|||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#define MNG_VERSION_TEXT "0.9.0"
|
||||
#define MNG_VERSION_SO 0 /* eg. libmng.so.0 (while in test) */
|
||||
#define MNG_VERSION_TEXT "0.9.2"
|
||||
#define MNG_VERSION_SO 0 /* eg. libmng.so.0 (while in test/beta) */
|
||||
#define MNG_VERSION_DLL 0 /* eg. libmng.dll (nb. same for version 1) */
|
||||
#define MNG_VERSION_MAJOR 0
|
||||
#define MNG_VERSION_MINOR 9
|
||||
#define MNG_VERSION_RELEASE 0
|
||||
#define MNG_VERSION_RELEASE 2
|
||||
|
||||
MNG_EXT mng_pchar MNG_DECL mng_version_text (void);
|
||||
MNG_EXT mng_uint8 MNG_DECL mng_version_so (void);
|
||||
|
@ -338,7 +359,8 @@ MNG_EXT mng_retcode MNG_DECL mng_cleanup (mng_handle* hHandle);
|
|||
"readdata" callback may return FALSE & length=0 indicating it's 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 it's read-buffer after which it must call mng_read_resume */
|
||||
the app to refill it's 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);
|
||||
|
@ -359,10 +381,11 @@ MNG_EXT mng_retcode MNG_DECL mng_create (mng_handle hHandle);
|
|||
/* 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, or to resume
|
||||
an animation after a call to mng_display_freeze */
|
||||
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 animation display of a MNG */
|
||||
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);
|
||||
|
@ -438,7 +461,7 @@ MNG_EXT mng_retcode MNG_DECL mng_setcb_errorproc (mng_handle hHandle,
|
|||
|
||||
/* trace callback */
|
||||
/* called to show the currently executing function */
|
||||
#ifdef MNG_INTERNAL_TRACE
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_EXT mng_retcode MNG_DECL mng_setcb_traceproc (mng_handle hHandle,
|
||||
mng_traceproc fProc);
|
||||
#endif
|
||||
|
@ -448,11 +471,16 @@ MNG_EXT mng_retcode MNG_DECL mng_setcb_traceproc (mng_handle hHandle,
|
|||
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) */
|
||||
/* processsave & processseek are called for a SAVE/SEEK chunks */
|
||||
#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);
|
||||
#endif
|
||||
|
||||
/* callbacks for display processing */
|
||||
|
@ -543,7 +571,7 @@ MNG_EXT mng_writedata MNG_DECL mng_getcb_writedata (mng_handle hHandle);
|
|||
MNG_EXT mng_errorproc MNG_DECL mng_getcb_errorproc (mng_handle hHandle);
|
||||
|
||||
/* see _setcb_ */
|
||||
#ifdef MNG_INTERNAL_TRACE
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_EXT mng_traceproc MNG_DECL mng_getcb_traceproc (mng_handle hHandle);
|
||||
#endif
|
||||
|
||||
|
@ -551,6 +579,8 @@ MNG_EXT mng_traceproc MNG_DECL mng_getcb_traceproc (mng_handle hHandle);
|
|||
#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);
|
||||
#endif
|
||||
|
||||
/* see _setcb_ */
|
||||
|
@ -607,6 +637,12 @@ MNG_EXT mng_retcode MNG_DECL mng_set_bgcolor (mng_handle hHandle,
|
|||
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);
|
||||
|
||||
/* Color-management necessaties */
|
||||
/* if you've defined MNG_FULL_CMS, you must specify the profile of the
|
||||
output-device and the sRGB conditions */
|
||||
|
@ -707,8 +743,17 @@ MNG_EXT mng_retcode MNG_DECL mng_set_jpeg_maxjdat (mng_handle hHandle,
|
|||
mng_uint32 iMaxJDAT);
|
||||
#endif /* MNG_INCLUDE_JNG */
|
||||
|
||||
/* Speed-setting */
|
||||
/* use this to facilitate testing of animations */
|
||||
/* 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);
|
||||
|
@ -752,6 +797,9 @@ MNG_EXT mng_retcode MNG_DECL mng_get_bgcolor (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_ */
|
||||
#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_FULL_CMS)
|
||||
MNG_EXT mng_bool MNG_DECL mng_get_srgb (mng_handle hHandle);
|
||||
|
@ -792,6 +840,11 @@ 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
|
||||
|
@ -804,6 +857,49 @@ MNG_EXT mng_speedtype
|
|||
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);
|
||||
|
||||
/* 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) */
|
||||
#if defined(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);
|
||||
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);
|
||||
#endif
|
||||
|
||||
/* Status variables */
|
||||
/* these indicate the internal state of the library */
|
||||
/* most indicate exactly what you would expect:
|
||||
status_error returns MNG_TRUE if the last function call returned an errorcode
|
||||
status_reading returns MNG_TRUE if the library is (still) reading an image
|
||||
status_suspendbreak returns MNG_TRUE if the library has suspended for "I/O"
|
||||
status_creating returns MNG_TRUE if the library is in the middle of creating an image
|
||||
status_writing returns MNG_TRUE if the library is in the middle of writing an image
|
||||
status_displaying returns MNG_TRUE if the library is displaying an image
|
||||
status_running returns MNG_TRUE if display processing is active (eg. not frozen or reset)
|
||||
status_timerbreak returns MNG_TRUE if the library has suspended for a "timer-break" */
|
||||
/* 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
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * Chunk access functions * */
|
||||
|
@ -1239,6 +1335,8 @@ MNG_EXT mng_retcode MNG_DECL mng_getchunk_unknown (mng_handle hHandle,
|
|||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#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,
|
||||
|
@ -1614,7 +1712,10 @@ MNG_EXT mng_retcode MNG_DECL mng_putchunk_unknown (mng_handle hHandle,
|
|||
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
|
||||
|
@ -1657,6 +1758,9 @@ MNG_EXT mng_retcode MNG_DECL mng_getimgdata_chunk (mng_handle hHandle,
|
|||
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
|
||||
|
@ -1694,7 +1798,23 @@ MNG_EXT mng_retcode MNG_DECL mng_putimgdata_jhdr (mng_handle hHandle,
|
|||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* mng_access_chunks */
|
||||
/* 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 */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
|
@ -1724,6 +1844,8 @@ MNG_EXT mng_retcode MNG_DECL mng_putimgdata_jhdr (mng_handle hHandle,
|
|||
#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_APPIOERROR (mng_retcode)901 /* application I/O error */
|
||||
#define MNG_APPTIMERERROR (mng_retcode)902 /* application timing error */
|
||||
|
@ -1773,6 +1895,7 @@ MNG_EXT mng_retcode MNG_DECL mng_putimgdata_jhdr (mng_handle hHandle,
|
|||
#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 */
|
||||
|
|
|
@ -0,0 +1,976 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_callback_xs.c copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : callback get/set interface (implementation) * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * 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 * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#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 */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE)
|
||||
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 /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE)
|
||||
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 /* 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
|
||||
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 /* MNG_SUPPORT_READ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_SUPPORT_READ
|
||||
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 /* MNG_SUPPORT_READ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_SUPPORT_READ
|
||||
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 /* 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)
|
||||
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 /* 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)
|
||||
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 /* 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_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)
|
||||
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 /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE)
|
||||
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 /* 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
|
||||
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 /* MNG_SUPPORT_READ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_SUPPORT_READ
|
||||
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 /* MNG_SUPPORT_READ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_SUPPORT_READ
|
||||
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 /* 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)
|
||||
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 /* 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)
|
||||
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 /* 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 * */
|
||||
/* ************************************************************************** */
|
||||
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,286 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_chunk_io.h copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : Chunk I/O routines (definition) * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : Definition of the chunk input/output routines * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/04/2000 - G.Juyn * */
|
||||
/* * - changed CRC initializtion to use dynamic structure * */
|
||||
/* * (wasn't thread-safe the old way !) * */
|
||||
/* * 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - changed write routines definition * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* force ANSI-C */
|
||||
#endif
|
||||
|
||||
#ifndef _libmng_chunk_io_h_
|
||||
#define _libmng_chunk_io_h_
|
||||
|
||||
#include "libmng.h"
|
||||
#include "libmng_data.h"
|
||||
#include "libmng_chunks.h"
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_uint32 crc (mng_datap pData,
|
||||
mng_uint8p buf,
|
||||
mng_int32 len);
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_READ_PROCS
|
||||
|
||||
#define READ_CHUNK(n) mng_retcode n (mng_datap pData, \
|
||||
mng_chunkp pHeader, \
|
||||
mng_uint32 iRawlen, \
|
||||
mng_uint8p pRawdata, \
|
||||
mng_chunkp* ppChunk)
|
||||
|
||||
READ_CHUNK (read_ihdr) ;
|
||||
READ_CHUNK (read_plte) ;
|
||||
READ_CHUNK (read_idat) ;
|
||||
READ_CHUNK (read_iend) ;
|
||||
READ_CHUNK (read_trns) ;
|
||||
READ_CHUNK (read_gama) ;
|
||||
READ_CHUNK (read_chrm) ;
|
||||
READ_CHUNK (read_srgb) ;
|
||||
READ_CHUNK (read_iccp) ;
|
||||
READ_CHUNK (read_text) ;
|
||||
READ_CHUNK (read_ztxt) ;
|
||||
READ_CHUNK (read_itxt) ;
|
||||
READ_CHUNK (read_bkgd) ;
|
||||
READ_CHUNK (read_phys) ;
|
||||
READ_CHUNK (read_sbit) ;
|
||||
READ_CHUNK (read_splt) ;
|
||||
READ_CHUNK (read_hist) ;
|
||||
READ_CHUNK (read_time) ;
|
||||
READ_CHUNK (read_mhdr) ;
|
||||
READ_CHUNK (read_mend) ;
|
||||
READ_CHUNK (read_loop) ;
|
||||
READ_CHUNK (read_endl) ;
|
||||
READ_CHUNK (read_defi) ;
|
||||
READ_CHUNK (read_basi) ;
|
||||
READ_CHUNK (read_clon) ;
|
||||
READ_CHUNK (read_past) ;
|
||||
READ_CHUNK (read_disc) ;
|
||||
READ_CHUNK (read_back) ;
|
||||
READ_CHUNK (read_fram) ;
|
||||
READ_CHUNK (read_move) ;
|
||||
READ_CHUNK (read_clip) ;
|
||||
READ_CHUNK (read_show) ;
|
||||
READ_CHUNK (read_term) ;
|
||||
READ_CHUNK (read_save) ;
|
||||
READ_CHUNK (read_seek) ;
|
||||
READ_CHUNK (read_expi) ;
|
||||
READ_CHUNK (read_fpri) ;
|
||||
READ_CHUNK (read_phyg) ;
|
||||
READ_CHUNK (read_jhdr) ;
|
||||
READ_CHUNK (read_jdat) ;
|
||||
READ_CHUNK (read_jsep) ;
|
||||
READ_CHUNK (read_dhdr) ;
|
||||
READ_CHUNK (read_prom) ;
|
||||
READ_CHUNK (read_ipng) ;
|
||||
READ_CHUNK (read_pplt) ;
|
||||
READ_CHUNK (read_ijng) ;
|
||||
READ_CHUNK (read_drop) ;
|
||||
READ_CHUNK (read_dbyk) ;
|
||||
READ_CHUNK (read_ordr) ;
|
||||
READ_CHUNK (read_need) ;
|
||||
READ_CHUNK (read_unknown) ;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#else /* MNG_INCLUDE_READ_PROCS */
|
||||
#define read_ihdr 0
|
||||
#define read_plte 0
|
||||
#define read_idat 0
|
||||
#define read_iend 0
|
||||
#define read_trns 0
|
||||
#define read_gama 0
|
||||
#define read_chrm 0
|
||||
#define read_srgb 0
|
||||
#define read_iccp 0
|
||||
#define read_text 0
|
||||
#define read_ztxt 0
|
||||
#define read_itxt 0
|
||||
#define read_bkgd 0
|
||||
#define read_phys 0
|
||||
#define read_sbit 0
|
||||
#define read_splt 0
|
||||
#define read_hist 0
|
||||
#define read_time 0
|
||||
#define read_mhdr 0
|
||||
#define read_mend 0
|
||||
#define read_loop 0
|
||||
#define read_endl 0
|
||||
#define read_defi 0
|
||||
#define read_basi 0
|
||||
#define read_clon 0
|
||||
#define read_past 0
|
||||
#define read_disc 0
|
||||
#define read_back 0
|
||||
#define read_fram 0
|
||||
#define read_move 0
|
||||
#define read_clip 0
|
||||
#define read_show 0
|
||||
#define read_term 0
|
||||
#define read_save 0
|
||||
#define read_seek 0
|
||||
#define read_expi 0
|
||||
#define read_fpri 0
|
||||
#define read_phyg 0
|
||||
#define read_jhdr 0
|
||||
#define read_jdat 0
|
||||
#define read_jsep 0
|
||||
#define read_dhdr 0
|
||||
#define read_prom 0
|
||||
#define read_ipng 0
|
||||
#define read_pplt 0
|
||||
#define read_ijng 0
|
||||
#define read_drop 0
|
||||
#define read_dbyk 0
|
||||
#define read_ordr 0
|
||||
#define read_need 0
|
||||
#define read_unknown 0
|
||||
#endif /* MNG_INCLUDE_READ_PROCS */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_WRITE_PROCS
|
||||
|
||||
#define WRITE_CHUNK(n) mng_retcode n (mng_datap pData, \
|
||||
mng_chunkp pChunk)
|
||||
|
||||
WRITE_CHUNK (write_ihdr) ;
|
||||
WRITE_CHUNK (write_plte) ;
|
||||
WRITE_CHUNK (write_idat) ;
|
||||
WRITE_CHUNK (write_iend) ;
|
||||
WRITE_CHUNK (write_trns) ;
|
||||
WRITE_CHUNK (write_gama) ;
|
||||
WRITE_CHUNK (write_chrm) ;
|
||||
WRITE_CHUNK (write_srgb) ;
|
||||
WRITE_CHUNK (write_iccp) ;
|
||||
WRITE_CHUNK (write_text) ;
|
||||
WRITE_CHUNK (write_ztxt) ;
|
||||
WRITE_CHUNK (write_itxt) ;
|
||||
WRITE_CHUNK (write_bkgd) ;
|
||||
WRITE_CHUNK (write_phys) ;
|
||||
WRITE_CHUNK (write_sbit) ;
|
||||
WRITE_CHUNK (write_splt) ;
|
||||
WRITE_CHUNK (write_hist) ;
|
||||
WRITE_CHUNK (write_time) ;
|
||||
WRITE_CHUNK (write_mhdr) ;
|
||||
WRITE_CHUNK (write_mend) ;
|
||||
WRITE_CHUNK (write_loop) ;
|
||||
WRITE_CHUNK (write_endl) ;
|
||||
WRITE_CHUNK (write_defi) ;
|
||||
WRITE_CHUNK (write_basi) ;
|
||||
WRITE_CHUNK (write_clon) ;
|
||||
WRITE_CHUNK (write_past) ;
|
||||
WRITE_CHUNK (write_disc) ;
|
||||
WRITE_CHUNK (write_back) ;
|
||||
WRITE_CHUNK (write_fram) ;
|
||||
WRITE_CHUNK (write_move) ;
|
||||
WRITE_CHUNK (write_clip) ;
|
||||
WRITE_CHUNK (write_show) ;
|
||||
WRITE_CHUNK (write_term) ;
|
||||
WRITE_CHUNK (write_save) ;
|
||||
WRITE_CHUNK (write_seek) ;
|
||||
WRITE_CHUNK (write_expi) ;
|
||||
WRITE_CHUNK (write_fpri) ;
|
||||
WRITE_CHUNK (write_phyg) ;
|
||||
WRITE_CHUNK (write_jhdr) ;
|
||||
WRITE_CHUNK (write_jdat) ;
|
||||
WRITE_CHUNK (write_jsep) ;
|
||||
WRITE_CHUNK (write_dhdr) ;
|
||||
WRITE_CHUNK (write_prom) ;
|
||||
WRITE_CHUNK (write_ipng) ;
|
||||
WRITE_CHUNK (write_pplt) ;
|
||||
WRITE_CHUNK (write_ijng) ;
|
||||
WRITE_CHUNK (write_drop) ;
|
||||
WRITE_CHUNK (write_dbyk) ;
|
||||
WRITE_CHUNK (write_ordr) ;
|
||||
WRITE_CHUNK (write_need) ;
|
||||
WRITE_CHUNK (write_unknown) ;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#else /* MNG_INCLUDE_WRITE_PROCS */
|
||||
#define write_ihdr 0
|
||||
#define write_plte 0
|
||||
#define write_idat 0
|
||||
#define write_iend 0
|
||||
#define write_trns 0
|
||||
#define write_gama 0
|
||||
#define write_chrm 0
|
||||
#define write_srgb 0
|
||||
#define write_iccp 0
|
||||
#define write_text 0
|
||||
#define write_ztxt 0
|
||||
#define write_itxt 0
|
||||
#define write_bkgd 0
|
||||
#define write_phys 0
|
||||
#define write_sbit 0
|
||||
#define write_splt 0
|
||||
#define write_hist 0
|
||||
#define write_time 0
|
||||
#define write_mhdr 0
|
||||
#define write_mend 0
|
||||
#define write_loop 0
|
||||
#define write_endl 0
|
||||
#define write_defi 0
|
||||
#define write_basi 0
|
||||
#define write_clon 0
|
||||
#define write_past 0
|
||||
#define write_disc 0
|
||||
#define write_back 0
|
||||
#define write_fram 0
|
||||
#define write_move 0
|
||||
#define write_clip 0
|
||||
#define write_show 0
|
||||
#define write_term 0
|
||||
#define write_save 0
|
||||
#define write_seek 0
|
||||
#define write_expi 0
|
||||
#define write_fpri 0
|
||||
#define write_phyg 0
|
||||
#define write_jhdr 0
|
||||
#define write_jdat 0
|
||||
#define write_jsep 0
|
||||
#define write_dhdr 0
|
||||
#define write_prom 0
|
||||
#define write_ipng 0
|
||||
#define write_pplt 0
|
||||
#define write_ijng 0
|
||||
#define write_drop 0
|
||||
#define write_dbyk 0
|
||||
#define write_ordr 0
|
||||
#define write_need 0
|
||||
#define write_unknown 0
|
||||
#endif /* MNG_INCLUDE_WRITE_PROCS */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* _libmng_chunk_io_h_ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,163 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_chunk_prc.h copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : Chunk initialization & cleanup (definition) * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : definition of the chunk initialization & cleanup routines * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* force ANSI-C */
|
||||
#endif
|
||||
|
||||
#ifndef _libmng_chunk_prc_h_
|
||||
#define _libmng_chunk_prc_h_
|
||||
|
||||
#include "libmng.h"
|
||||
#include "libmng_data.h"
|
||||
#include "libmng_chunks.h"
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
void add_chunk (mng_datap pData,
|
||||
mng_chunkp pChunk);
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#define INIT_CHUNK_HDR(n) mng_retcode n (mng_datap pData, \
|
||||
mng_chunkp pHeader, \
|
||||
mng_chunkp* ppChunk)
|
||||
|
||||
INIT_CHUNK_HDR (init_ihdr) ;
|
||||
INIT_CHUNK_HDR (init_plte) ;
|
||||
INIT_CHUNK_HDR (init_idat) ;
|
||||
INIT_CHUNK_HDR (init_iend) ;
|
||||
INIT_CHUNK_HDR (init_trns) ;
|
||||
INIT_CHUNK_HDR (init_gama) ;
|
||||
INIT_CHUNK_HDR (init_chrm) ;
|
||||
INIT_CHUNK_HDR (init_srgb) ;
|
||||
INIT_CHUNK_HDR (init_iccp) ;
|
||||
INIT_CHUNK_HDR (init_text) ;
|
||||
INIT_CHUNK_HDR (init_ztxt) ;
|
||||
INIT_CHUNK_HDR (init_itxt) ;
|
||||
INIT_CHUNK_HDR (init_bkgd) ;
|
||||
INIT_CHUNK_HDR (init_phys) ;
|
||||
INIT_CHUNK_HDR (init_sbit) ;
|
||||
INIT_CHUNK_HDR (init_splt) ;
|
||||
INIT_CHUNK_HDR (init_hist) ;
|
||||
INIT_CHUNK_HDR (init_time) ;
|
||||
INIT_CHUNK_HDR (init_mhdr) ;
|
||||
INIT_CHUNK_HDR (init_mend) ;
|
||||
INIT_CHUNK_HDR (init_loop) ;
|
||||
INIT_CHUNK_HDR (init_endl) ;
|
||||
INIT_CHUNK_HDR (init_defi) ;
|
||||
INIT_CHUNK_HDR (init_basi) ;
|
||||
INIT_CHUNK_HDR (init_clon) ;
|
||||
INIT_CHUNK_HDR (init_past) ;
|
||||
INIT_CHUNK_HDR (init_disc) ;
|
||||
INIT_CHUNK_HDR (init_back) ;
|
||||
INIT_CHUNK_HDR (init_fram) ;
|
||||
INIT_CHUNK_HDR (init_move) ;
|
||||
INIT_CHUNK_HDR (init_clip) ;
|
||||
INIT_CHUNK_HDR (init_show) ;
|
||||
INIT_CHUNK_HDR (init_term) ;
|
||||
INIT_CHUNK_HDR (init_save) ;
|
||||
INIT_CHUNK_HDR (init_seek) ;
|
||||
INIT_CHUNK_HDR (init_expi) ;
|
||||
INIT_CHUNK_HDR (init_fpri) ;
|
||||
INIT_CHUNK_HDR (init_need) ;
|
||||
INIT_CHUNK_HDR (init_phyg) ;
|
||||
INIT_CHUNK_HDR (init_jhdr) ;
|
||||
INIT_CHUNK_HDR (init_jdat) ;
|
||||
INIT_CHUNK_HDR (init_jsep) ;
|
||||
INIT_CHUNK_HDR (init_dhdr) ;
|
||||
INIT_CHUNK_HDR (init_prom) ;
|
||||
INIT_CHUNK_HDR (init_ipng) ;
|
||||
INIT_CHUNK_HDR (init_pplt) ;
|
||||
INIT_CHUNK_HDR (init_ijng) ;
|
||||
INIT_CHUNK_HDR (init_drop) ;
|
||||
INIT_CHUNK_HDR (init_dbyk) ;
|
||||
INIT_CHUNK_HDR (init_ordr) ;
|
||||
INIT_CHUNK_HDR (init_unknown) ;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#define FREE_CHUNK_HDR(n) mng_retcode n (mng_datap pData, \
|
||||
mng_chunkp pHeader)
|
||||
|
||||
FREE_CHUNK_HDR (free_ihdr) ;
|
||||
FREE_CHUNK_HDR (free_plte) ;
|
||||
FREE_CHUNK_HDR (free_idat) ;
|
||||
FREE_CHUNK_HDR (free_iend) ;
|
||||
FREE_CHUNK_HDR (free_trns) ;
|
||||
FREE_CHUNK_HDR (free_gama) ;
|
||||
FREE_CHUNK_HDR (free_chrm) ;
|
||||
FREE_CHUNK_HDR (free_srgb) ;
|
||||
FREE_CHUNK_HDR (free_iccp) ;
|
||||
FREE_CHUNK_HDR (free_text) ;
|
||||
FREE_CHUNK_HDR (free_ztxt) ;
|
||||
FREE_CHUNK_HDR (free_itxt) ;
|
||||
FREE_CHUNK_HDR (free_bkgd) ;
|
||||
FREE_CHUNK_HDR (free_phys) ;
|
||||
FREE_CHUNK_HDR (free_sbit) ;
|
||||
FREE_CHUNK_HDR (free_splt) ;
|
||||
FREE_CHUNK_HDR (free_hist) ;
|
||||
FREE_CHUNK_HDR (free_time) ;
|
||||
FREE_CHUNK_HDR (free_mhdr) ;
|
||||
FREE_CHUNK_HDR (free_mend) ;
|
||||
FREE_CHUNK_HDR (free_loop) ;
|
||||
FREE_CHUNK_HDR (free_endl) ;
|
||||
FREE_CHUNK_HDR (free_defi) ;
|
||||
FREE_CHUNK_HDR (free_basi) ;
|
||||
FREE_CHUNK_HDR (free_clon) ;
|
||||
FREE_CHUNK_HDR (free_past) ;
|
||||
FREE_CHUNK_HDR (free_disc) ;
|
||||
FREE_CHUNK_HDR (free_back) ;
|
||||
FREE_CHUNK_HDR (free_fram) ;
|
||||
FREE_CHUNK_HDR (free_move) ;
|
||||
FREE_CHUNK_HDR (free_clip) ;
|
||||
FREE_CHUNK_HDR (free_show) ;
|
||||
FREE_CHUNK_HDR (free_term) ;
|
||||
FREE_CHUNK_HDR (free_save) ;
|
||||
FREE_CHUNK_HDR (free_seek) ;
|
||||
FREE_CHUNK_HDR (free_expi) ;
|
||||
FREE_CHUNK_HDR (free_fpri) ;
|
||||
FREE_CHUNK_HDR (free_need) ;
|
||||
FREE_CHUNK_HDR (free_phyg) ;
|
||||
FREE_CHUNK_HDR (free_jhdr) ;
|
||||
FREE_CHUNK_HDR (free_jdat) ;
|
||||
FREE_CHUNK_HDR (free_jsep) ;
|
||||
FREE_CHUNK_HDR (free_dhdr) ;
|
||||
FREE_CHUNK_HDR (free_prom) ;
|
||||
FREE_CHUNK_HDR (free_ipng) ;
|
||||
FREE_CHUNK_HDR (free_pplt) ;
|
||||
FREE_CHUNK_HDR (free_ijng) ;
|
||||
FREE_CHUNK_HDR (free_drop) ;
|
||||
FREE_CHUNK_HDR (free_dbyk) ;
|
||||
FREE_CHUNK_HDR (free_ordr) ;
|
||||
FREE_CHUNK_HDR (free_unknown) ;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* _libmng_chunk_prc_h_ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,728 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_chunks.h copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : Chunk structures (definition) * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : Definition of known chunk structures * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/04/2000 - G.Juyn * */
|
||||
/* * - put in some extra comments * */
|
||||
/* * 0.5.1 - 05/06/2000 - G.Juyn * */
|
||||
/* * - fixed layout for sBIT, PPLT * */
|
||||
/* * 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - changed write callback definition * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * 0.5.1 - 05/11/2000 - G.Juyn * */
|
||||
/* * - fixed layout for PPLT again (missed deltatype ?!?) * */
|
||||
/* * * */
|
||||
/* * 0.5.2 - 05/31/2000 - G.Juyn * */
|
||||
/* * - removed useless definition (contributed by Tim Rowley) * */
|
||||
/* * 0.5.2 - 06/03/2000 - G.Juyn * */
|
||||
/* * - fixed makeup for Linux gcc compile * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* force ANSI-C */
|
||||
#endif
|
||||
|
||||
#ifndef _libmng_chunks_h_
|
||||
#define _libmng_chunks_h_
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_SWAP_ENDIAN
|
||||
#define PNG_SIG 0x474e5089L
|
||||
#define JNG_SIG 0x474e4a8bL
|
||||
#define MNG_SIG 0x474e4d8aL
|
||||
#define POST_SIG 0x0a1a0a0dL
|
||||
#else
|
||||
#define PNG_SIG 0x89504e47L
|
||||
#define JNG_SIG 0x8b4a4e47L
|
||||
#define MNG_SIG 0x8a4d4e47L
|
||||
#define POST_SIG 0x0d0a1a0aL
|
||||
#endif
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef mng_retcode (*mng_createchunk) (mng_datap pData,
|
||||
mng_chunkp pHeader,
|
||||
mng_chunkp* ppChunk);
|
||||
|
||||
typedef mng_retcode (*mng_cleanupchunk) (mng_datap pData,
|
||||
mng_chunkp pHeader);
|
||||
|
||||
typedef mng_retcode (*mng_readchunk) (mng_datap pData,
|
||||
mng_chunkp pHeader,
|
||||
mng_uint32 iRawlen,
|
||||
mng_uint8p pRawdata,
|
||||
mng_chunkp* pChunk);
|
||||
|
||||
typedef mng_retcode (*mng_writechunk) (mng_datap pData,
|
||||
mng_chunkp pChunk);
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* generic header */
|
||||
mng_chunkid iChunkname;
|
||||
mng_createchunk fCreate;
|
||||
mng_cleanupchunk fCleanup;
|
||||
mng_readchunk fRead;
|
||||
mng_writechunk fWrite;
|
||||
mng_chunkp pNext; /* for double-linked list */
|
||||
mng_chunkp pPrev;
|
||||
} mng_chunk_header;
|
||||
typedef mng_chunk_header * mng_chunk_headerp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* IHDR */
|
||||
mng_chunk_header sHeader;
|
||||
mng_uint32 iWidth;
|
||||
mng_uint32 iHeight;
|
||||
mng_uint8 iBitdepth;
|
||||
mng_uint8 iColortype;
|
||||
mng_uint8 iCompression;
|
||||
mng_uint8 iFilter;
|
||||
mng_uint8 iInterlace;
|
||||
} mng_ihdr;
|
||||
typedef mng_ihdr * mng_ihdrp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* PLTE */
|
||||
mng_chunk_header sHeader;
|
||||
mng_bool bEmpty;
|
||||
mng_uint32 iEntrycount;
|
||||
mng_rgbpaltab aEntries;
|
||||
} mng_plte;
|
||||
typedef mng_plte * mng_pltep;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* IDAT */
|
||||
mng_chunk_header sHeader;
|
||||
mng_bool bEmpty;
|
||||
mng_uint32 iDatasize;
|
||||
mng_ptr pData;
|
||||
} mng_idat;
|
||||
typedef mng_idat * mng_idatp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* IEND */
|
||||
mng_chunk_header sHeader;
|
||||
} mng_iend;
|
||||
typedef mng_iend * mng_iendp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* tRNS */
|
||||
mng_chunk_header sHeader;
|
||||
mng_bool bEmpty;
|
||||
mng_bool bGlobal;
|
||||
mng_uint8 iType; /* colortype (0,2,3) */
|
||||
mng_uint32 iCount;
|
||||
mng_uint8arr aEntries;
|
||||
mng_uint16 iGray;
|
||||
mng_uint16 iRed;
|
||||
mng_uint16 iGreen;
|
||||
mng_uint16 iBlue;
|
||||
mng_uint32 iRawlen;
|
||||
mng_uint8arr aRawdata;
|
||||
} mng_trns;
|
||||
typedef mng_trns * mng_trnsp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* gAMA */
|
||||
mng_chunk_header sHeader;
|
||||
mng_bool bEmpty;
|
||||
mng_uint32 iGamma;
|
||||
} mng_gama;
|
||||
typedef mng_gama * mng_gamap;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* cHRM */
|
||||
mng_chunk_header sHeader;
|
||||
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_chrm;
|
||||
typedef mng_chrm * mng_chrmp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* sRGB */
|
||||
mng_chunk_header sHeader;
|
||||
mng_bool bEmpty;
|
||||
mng_uint8 iRenderingintent;
|
||||
} mng_srgb;
|
||||
typedef mng_srgb * mng_srgbp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* iCCP */
|
||||
mng_chunk_header sHeader;
|
||||
mng_bool bEmpty;
|
||||
mng_uint32 iNamesize;
|
||||
mng_pchar zName;
|
||||
mng_uint8 iCompression;
|
||||
mng_uint32 iProfilesize;
|
||||
mng_ptr pProfile;
|
||||
} mng_iccp;
|
||||
typedef mng_iccp * mng_iccpp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* tEXt */
|
||||
mng_chunk_header sHeader;
|
||||
mng_uint32 iKeywordsize;
|
||||
mng_pchar zKeyword;
|
||||
mng_uint32 iTextsize;
|
||||
mng_pchar zText;
|
||||
} mng_text;
|
||||
typedef mng_text * mng_textp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* zTXt */
|
||||
mng_chunk_header sHeader;
|
||||
mng_uint32 iKeywordsize;
|
||||
mng_pchar zKeyword;
|
||||
mng_uint8 iCompression;
|
||||
mng_uint32 iTextsize;
|
||||
mng_pchar zText;
|
||||
} mng_ztxt;
|
||||
typedef mng_ztxt * mng_ztxtp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* iTXt */
|
||||
mng_chunk_header sHeader;
|
||||
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_itxt;
|
||||
typedef mng_itxt * mng_itxtp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* bKGD */
|
||||
mng_chunk_header sHeader;
|
||||
mng_bool bEmpty;
|
||||
mng_uint8 iType; /* 3=indexed, 0=gray, 2=rgb */
|
||||
mng_uint8 iIndex;
|
||||
mng_uint16 iGray;
|
||||
mng_uint16 iRed;
|
||||
mng_uint16 iGreen;
|
||||
mng_uint16 iBlue;
|
||||
} mng_bkgd;
|
||||
typedef mng_bkgd * mng_bkgdp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* pHYs */
|
||||
mng_chunk_header sHeader;
|
||||
mng_bool bEmpty;
|
||||
mng_uint32 iSizex;
|
||||
mng_uint32 iSizey;
|
||||
mng_uint8 iUnit;
|
||||
} mng_phys;
|
||||
typedef mng_phys * mng_physp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* sBIT */
|
||||
mng_chunk_header sHeader;
|
||||
mng_bool bEmpty;
|
||||
mng_uint8 iType; /* colortype (0,2,3,4,6,10,12,14,16) */
|
||||
mng_uint8arr4 aBits;
|
||||
} mng_sbit;
|
||||
typedef mng_sbit * mng_sbitp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* sPLT */
|
||||
mng_chunk_header sHeader;
|
||||
mng_bool bEmpty;
|
||||
mng_uint32 iNamesize;
|
||||
mng_pchar zName;
|
||||
mng_uint8 iSampledepth;
|
||||
mng_uint32 iEntrycount;
|
||||
mng_ptr pEntries;
|
||||
} mng_splt;
|
||||
typedef mng_splt * mng_spltp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* hIST */
|
||||
mng_chunk_header sHeader;
|
||||
mng_uint32 iEntrycount;
|
||||
mng_uint16arr aEntries;
|
||||
} mng_hist;
|
||||
typedef mng_hist * mng_histp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* tIME */
|
||||
mng_chunk_header sHeader;
|
||||
mng_uint16 iYear;
|
||||
mng_uint8 iMonth;
|
||||
mng_uint8 iDay;
|
||||
mng_uint8 iHour;
|
||||
mng_uint8 iMinute;
|
||||
mng_uint8 iSecond;
|
||||
} mng_time;
|
||||
typedef mng_time * mng_timep;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* MHDR */
|
||||
mng_chunk_header sHeader;
|
||||
mng_uint32 iWidth;
|
||||
mng_uint32 iHeight;
|
||||
mng_uint32 iTicks;
|
||||
mng_uint32 iLayercount;
|
||||
mng_uint32 iFramecount;
|
||||
mng_uint32 iPlaytime;
|
||||
mng_uint32 iSimplicity;
|
||||
} mng_mhdr;
|
||||
typedef mng_mhdr * mng_mhdrp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* MEND */
|
||||
mng_chunk_header sHeader;
|
||||
} mng_mend;
|
||||
typedef mng_mend * mng_mendp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* LOOP */
|
||||
mng_chunk_header sHeader;
|
||||
mng_uint8 iLevel;
|
||||
mng_uint32 iRepeat;
|
||||
mng_uint8 iTermination;
|
||||
mng_uint32 iItermin;
|
||||
mng_uint32 iItermax;
|
||||
mng_uint32 iCount;
|
||||
mng_uint32p pSignals;
|
||||
} mng_loop;
|
||||
typedef mng_loop * mng_loopp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* ENDL */
|
||||
mng_chunk_header sHeader;
|
||||
mng_uint8 iLevel;
|
||||
} mng_endl;
|
||||
typedef mng_endl * mng_endlp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* DEFI */
|
||||
mng_chunk_header sHeader;
|
||||
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_defi;
|
||||
typedef mng_defi * mng_defip;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* BASI */
|
||||
mng_chunk_header sHeader;
|
||||
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_basi;
|
||||
typedef mng_basi * mng_basip;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* CLON */
|
||||
mng_chunk_header sHeader;
|
||||
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;
|
||||
} mng_clon;
|
||||
typedef mng_clon * mng_clonp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* PAST source */
|
||||
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;
|
||||
} mng_past_source;
|
||||
typedef mng_past_source * mng_past_sourcep;
|
||||
|
||||
typedef struct { /* PAST */
|
||||
mng_chunk_header sHeader;
|
||||
mng_uint16 iDestid;
|
||||
mng_uint8 iTargettype;
|
||||
mng_int32 iTargetx;
|
||||
mng_int32 iTargety;
|
||||
mng_uint32 iCount;
|
||||
mng_past_sourcep pSources;
|
||||
} mng_past;
|
||||
typedef mng_past * mng_pastp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* DISC */
|
||||
mng_chunk_header sHeader;
|
||||
mng_uint32 iCount;
|
||||
mng_uint16p pObjectids;
|
||||
} mng_disc;
|
||||
typedef mng_disc * mng_discp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* BACK */
|
||||
mng_chunk_header sHeader;
|
||||
mng_uint16 iRed;
|
||||
mng_uint16 iGreen;
|
||||
mng_uint16 iBlue;
|
||||
mng_uint8 iMandatory;
|
||||
mng_uint16 iImageid;
|
||||
mng_uint8 iTile;
|
||||
} mng_back;
|
||||
typedef mng_back * mng_backp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* FRAM */
|
||||
mng_chunk_header sHeader;
|
||||
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_fram;
|
||||
typedef mng_fram * mng_framp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* MOVE */
|
||||
mng_chunk_header sHeader;
|
||||
mng_uint16 iFirstid;
|
||||
mng_uint16 iLastid;
|
||||
mng_uint8 iMovetype;
|
||||
mng_int32 iMovex;
|
||||
mng_int32 iMovey;
|
||||
} mng_move;
|
||||
typedef mng_move * mng_movep;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* CLIP */
|
||||
mng_chunk_header sHeader;
|
||||
mng_uint16 iFirstid;
|
||||
mng_uint16 iLastid;
|
||||
mng_uint8 iCliptype;
|
||||
mng_int32 iClipl;
|
||||
mng_int32 iClipr;
|
||||
mng_int32 iClipt;
|
||||
mng_int32 iClipb;
|
||||
} mng_clip;
|
||||
typedef mng_clip * mng_clipp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* SHOW */
|
||||
mng_chunk_header sHeader;
|
||||
mng_bool bEmpty;
|
||||
mng_uint16 iFirstid;
|
||||
mng_uint16 iLastid;
|
||||
mng_uint8 iMode;
|
||||
} mng_show;
|
||||
typedef mng_show * mng_showp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* TERM */
|
||||
mng_chunk_header sHeader;
|
||||
mng_uint8 iTermaction;
|
||||
mng_uint8 iIteraction;
|
||||
mng_uint32 iDelay;
|
||||
mng_uint32 iItermax;
|
||||
} mng_term;
|
||||
typedef mng_term * mng_termp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* SAVE entry */
|
||||
mng_uint8 iEntrytype;
|
||||
mng_uint32arr2 iOffset; /* 0=MSI, 1=LSI */
|
||||
mng_uint32arr2 iStarttime; /* 0=MSI, 1=LSI */
|
||||
mng_uint32 iLayernr;
|
||||
mng_uint32 iFramenr;
|
||||
mng_uint32 iNamesize;
|
||||
mng_pchar zName;
|
||||
} mng_save_entry;
|
||||
typedef mng_save_entry * mng_save_entryp;
|
||||
|
||||
typedef struct { /* SAVE */
|
||||
mng_chunk_header sHeader;
|
||||
mng_bool bEmpty;
|
||||
mng_uint8 iOffsettype;
|
||||
mng_uint32 iCount;
|
||||
mng_save_entryp pEntries;
|
||||
} mng_save;
|
||||
typedef mng_save * mng_savep;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* SEEK */
|
||||
mng_chunk_header sHeader;
|
||||
mng_uint32 iNamesize;
|
||||
mng_pchar zName;
|
||||
} mng_seek;
|
||||
typedef mng_seek * mng_seekp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* eXPI */
|
||||
mng_chunk_header sHeader;
|
||||
mng_uint16 iSnapshotid;
|
||||
mng_uint32 iNamesize;
|
||||
mng_pchar zName;
|
||||
} mng_expi;
|
||||
typedef mng_expi * mng_expip;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* fPRI */
|
||||
mng_chunk_header sHeader;
|
||||
mng_uint8 iDeltatype;
|
||||
mng_uint8 iPriority;
|
||||
} mng_fpri;
|
||||
typedef mng_fpri * mng_fprip;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* nEED */
|
||||
mng_chunk_header sHeader;
|
||||
mng_uint32 iKeywordssize;
|
||||
mng_pchar zKeywords;
|
||||
} mng_need;
|
||||
typedef mng_need * mng_needp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef mng_phys mng_phyg; /* pHYg */
|
||||
typedef mng_phyg * mng_phygp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_JNG
|
||||
|
||||
typedef struct { /* JHDR */
|
||||
mng_chunk_header sHeader;
|
||||
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_jhdr;
|
||||
typedef mng_jhdr * mng_jhdrp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef mng_idat mng_jdat; /* JDAT */
|
||||
typedef mng_jdat * mng_jdatp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* JSEP */
|
||||
mng_chunk_header sHeader;
|
||||
} mng_jsep;
|
||||
typedef mng_jsep * mng_jsepp;
|
||||
|
||||
#endif /* MNG_INCLUDE_JNG */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* DHDR */
|
||||
mng_chunk_header sHeader;
|
||||
mng_uint16 iObjectid;
|
||||
mng_uint8 iImagetype;
|
||||
mng_uint8 iDeltatype;
|
||||
mng_uint32 iBlockwidth;
|
||||
mng_uint32 iBlockheight;
|
||||
mng_uint32 iBlockx;
|
||||
mng_uint32 iBlocky;
|
||||
} mng_dhdr;
|
||||
typedef mng_dhdr * mng_dhdrp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* PROM */
|
||||
mng_chunk_header sHeader;
|
||||
mng_uint8 iColortype;
|
||||
mng_uint8 iSampledepth;
|
||||
mng_uint8 iFilltype;
|
||||
} mng_prom;
|
||||
typedef mng_prom * mng_promp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* IPNG */
|
||||
mng_chunk_header sHeader;
|
||||
} mng_ipng;
|
||||
typedef mng_ipng *mng_ipngp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* PPLT entry */
|
||||
mng_uint8 iRed;
|
||||
mng_uint8 iGreen;
|
||||
mng_uint8 iBlue;
|
||||
mng_uint8 iAlpha;
|
||||
mng_bool bUsed;
|
||||
} mng_pplt_entry;
|
||||
typedef mng_pplt_entry * mng_pplt_entryp;
|
||||
|
||||
typedef struct { /* PPLT */
|
||||
mng_chunk_header sHeader;
|
||||
mng_uint8 iDeltatype;
|
||||
mng_uint32 iCount;
|
||||
mng_pplt_entry aEntries [256];
|
||||
} mng_pplt;
|
||||
typedef mng_pplt * mng_ppltp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* IJNG */
|
||||
mng_chunk_header sHeader;
|
||||
} mng_ijng;
|
||||
typedef mng_ijng *mng_ijngp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* DROP */
|
||||
mng_chunk_header sHeader;
|
||||
mng_uint32 iCount;
|
||||
mng_chunkidp pChunknames;
|
||||
} mng_drop;
|
||||
typedef mng_drop * mng_dropp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* DBYK */
|
||||
mng_chunk_header sHeader;
|
||||
mng_chunkid iChunkname;
|
||||
mng_uint8 iPolarity;
|
||||
mng_uint32 iKeywordssize;
|
||||
mng_pchar zKeywords;
|
||||
} mng_dbyk;
|
||||
typedef mng_dbyk * mng_dbykp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* ORDR entry */
|
||||
mng_chunkid iChunkname;
|
||||
mng_uint8 iOrdertype;
|
||||
} mng_ordr_entry;
|
||||
typedef mng_ordr_entry * mng_ordr_entryp;
|
||||
|
||||
typedef struct mng_ordr_struct { /* ORDR */
|
||||
mng_chunk_header sHeader;
|
||||
mng_uint32 iCount;
|
||||
mng_ordr_entryp pEntries;
|
||||
} mng_ordr;
|
||||
typedef mng_ordr * mng_ordrp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* unknown chunk */
|
||||
mng_chunk_header sHeader;
|
||||
mng_uint32 iDatasize;
|
||||
mng_ptr pData;
|
||||
} mng_unknown_chunk;
|
||||
typedef mng_unknown_chunk * mng_unknown_chunkp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* _libmng_chunks_h_ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
|
@ -0,0 +1,819 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_cms.c copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : color management routines (implementation) * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : implementation of the color management routines * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/01/2000 - G.Juyn * */
|
||||
/* * - B001(105795) - fixed a typo and misconception about * */
|
||||
/* * freeing allocated gamma-table. (reported by Marti Maria) * */
|
||||
/* * 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * 0.5.1 - 05/09/2000 - G.Juyn * */
|
||||
/* * - filled application-based color-management routines * */
|
||||
/* * 0.5.1 - 05/11/2000 - G.Juyn * */
|
||||
/* * - added creatememprofile * */
|
||||
/* * - added callback error-reporting support * */
|
||||
/* * 0.5.1 - 05/12/2000 - G.Juyn * */
|
||||
/* * - changed trace to macro for callback error-reporting * */
|
||||
/* * * */
|
||||
/* * 0.5.2 - 06/10/2000 - G.Juyn * */
|
||||
/* * - fixed some compilation-warnings (contrib Jason Morris) * */
|
||||
/* * * */
|
||||
/* * 0.5.3 - 06/21/2000 - G.Juyn * */
|
||||
/* * - fixed problem with color-correction for stored images * */
|
||||
/* * 0.5.3 - 06/23/2000 - G.Juyn * */
|
||||
/* * - fixed problem with incorrect gamma-correction * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#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_cms.h"
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* force ANSI-C */
|
||||
#endif
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_DISPLAY_PROCS
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * Little CMS helper routines * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_LCMS
|
||||
|
||||
#define MNG_CMS_FLAGS 0
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
void mnglcms_initlibrary ()
|
||||
{
|
||||
cmsErrorAction (LCMS_ERROR_IGNORE); /* LCMS should ignore errors! */
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_cmsprof mnglcms_createfileprofile (mng_pchar zFilename)
|
||||
{
|
||||
return cmsOpenProfileFromFile (zFilename, "r");
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_cmsprof mnglcms_creatememprofile (mng_uint32 iProfilesize,
|
||||
mng_ptr pProfile)
|
||||
{
|
||||
return cmsOpenProfileFromMem (pProfile, iProfilesize);
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
void mnglcms_freeprofile (mng_cmsprof hProf)
|
||||
{
|
||||
cmsCloseProfile (hProf);
|
||||
return;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
void mnglcms_freetransform (mng_cmstrans hTrans)
|
||||
{
|
||||
/* B001 start */
|
||||
cmsDeleteTransform (hTrans);
|
||||
/* B001 end */
|
||||
return;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* MNG_INCLUDE_LCMS */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * Color-management initialization & correction routines * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_LCMS
|
||||
|
||||
mng_retcode init_full_cms (mng_datap pData)
|
||||
{
|
||||
mng_cmsprof hProf;
|
||||
mng_cmstrans hTrans;
|
||||
mng_imagep pImage = (mng_imagep)pData->pCurrentobj;
|
||||
mng_imagedatap pBuf;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_INIT_FULL_CMS, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
if (!pImage) /* no current object? then use object 0 */
|
||||
pImage = (mng_imagep)pData->pObjzero;
|
||||
|
||||
pBuf = pImage->pImgbuf; /* address the buffer */
|
||||
|
||||
if ((pBuf->bHasICCP) || (pData->bHasglobalICCP))
|
||||
{
|
||||
if (!pData->hProf2) /* output profile defined ? */
|
||||
MNG_ERROR (pData, MNG_NOOUTPUTPROFILE);
|
||||
|
||||
if (pBuf->bHasICCP) /* generate a profile handle */
|
||||
hProf = cmsOpenProfileFromMem (pBuf->pProfile, pBuf->iProfilesize);
|
||||
else
|
||||
hProf = cmsOpenProfileFromMem (pData->pGlobalProfile, pData->iGlobalProfilesize);
|
||||
|
||||
pData->hProf1 = hProf; /* save for future use */
|
||||
|
||||
if (!hProf) /* handle error ? */
|
||||
MNG_ERRORL (pData, MNG_LCMS_NOHANDLE)
|
||||
|
||||
if (pData->bIsRGBA16) /* 16-bit intermediates ? */
|
||||
hTrans = cmsCreateTransform (hProf, TYPE_RGBA_16_SE,
|
||||
pData->hProf2, TYPE_RGBA_16_SE,
|
||||
INTENT_PERCEPTUAL, MNG_CMS_FLAGS);
|
||||
else
|
||||
hTrans = cmsCreateTransform (hProf, TYPE_RGBA_8,
|
||||
pData->hProf2, TYPE_RGBA_8,
|
||||
INTENT_PERCEPTUAL, MNG_CMS_FLAGS);
|
||||
|
||||
pData->hTrans = hTrans; /* save for future use */
|
||||
|
||||
if (!hTrans) /* handle error ? */
|
||||
MNG_ERRORL (pData, MNG_LCMS_NOTRANS)
|
||||
/* load color-correction routine */
|
||||
pData->fCorrectrow = (mng_ptr)correct_full_cms;
|
||||
|
||||
return MNG_NOERROR; /* and done */
|
||||
}
|
||||
|
||||
if ((pBuf->bHasSRGB) || (pData->bHasglobalSRGB))
|
||||
{
|
||||
mng_uint8 iIntent;
|
||||
|
||||
if (pData->bIssRGB) /* sRGB system ? */
|
||||
return MNG_NOERROR; /* no conversion required */
|
||||
|
||||
if (!pData->hProf3) /* sRGB profile defined ? */
|
||||
MNG_ERROR (pData, MNG_NOSRGBPROFILE)
|
||||
|
||||
hProf = pData->hProf3; /* convert from sRGB profile */
|
||||
|
||||
if (pBuf->bHasSRGB) /* determine rendering intent */
|
||||
iIntent = pBuf->iRenderingintent;
|
||||
else
|
||||
iIntent = pData->iGlobalRendintent;
|
||||
|
||||
if (pData->bIsRGBA16) /* 16-bit intermediates ? */
|
||||
hTrans = cmsCreateTransform (hProf, TYPE_RGBA_16_SE,
|
||||
pData->hProf2, TYPE_RGBA_16_SE,
|
||||
iIntent, MNG_CMS_FLAGS);
|
||||
else
|
||||
hTrans = cmsCreateTransform (hProf, TYPE_RGBA_8,
|
||||
pData->hProf2, TYPE_RGBA_8,
|
||||
iIntent, MNG_CMS_FLAGS);
|
||||
|
||||
pData->hTrans = hTrans; /* save for future use */
|
||||
|
||||
if (!hTrans) /* handle error ? */
|
||||
MNG_ERRORL (pData, MNG_LCMS_NOTRANS)
|
||||
/* load color-correction routine */
|
||||
pData->fCorrectrow = (mng_ptr)correct_full_cms;
|
||||
|
||||
return MNG_NOERROR; /* and done */
|
||||
}
|
||||
|
||||
if ( ((pBuf->bHasCHRM) || (pData->bHasglobalCHRM)) &&
|
||||
((pBuf->bHasGAMA) || (pData->bHasglobalGAMA)) )
|
||||
{
|
||||
mng_CIExyY sWhitepoint;
|
||||
mng_CIExyYTRIPLE sPrimaries;
|
||||
mng_gammatabp pGammatable[3];
|
||||
mng_float dGamma;
|
||||
|
||||
if (pBuf->bHasCHRM) /* local cHRM ? */
|
||||
{
|
||||
sWhitepoint.x = (mng_float)pBuf->iWhitepointx / 100000;
|
||||
sWhitepoint.y = (mng_float)pBuf->iWhitepointy / 100000;
|
||||
sPrimaries.Red.x = (mng_float)pBuf->iPrimaryredx / 100000;
|
||||
sPrimaries.Red.y = (mng_float)pBuf->iPrimaryredy / 100000;
|
||||
sPrimaries.Green.x = (mng_float)pBuf->iPrimarygreenx / 100000;
|
||||
sPrimaries.Green.y = (mng_float)pBuf->iPrimarygreeny / 100000;
|
||||
sPrimaries.Blue.x = (mng_float)pBuf->iPrimarybluex / 100000;
|
||||
sPrimaries.Blue.y = (mng_float)pBuf->iPrimarybluey / 100000;
|
||||
}
|
||||
else
|
||||
{
|
||||
sWhitepoint.x = (mng_float)pData->iGlobalWhitepointx / 100000;
|
||||
sWhitepoint.y = (mng_float)pData->iGlobalWhitepointy / 100000;
|
||||
sPrimaries.Red.x = (mng_float)pData->iGlobalPrimaryredx / 100000;
|
||||
sPrimaries.Red.y = (mng_float)pData->iGlobalPrimaryredy / 100000;
|
||||
sPrimaries.Green.x = (mng_float)pData->iGlobalPrimarygreenx / 100000;
|
||||
sPrimaries.Green.y = (mng_float)pData->iGlobalPrimarygreeny / 100000;
|
||||
sPrimaries.Blue.x = (mng_float)pData->iGlobalPrimarybluex / 100000;
|
||||
sPrimaries.Blue.y = (mng_float)pData->iGlobalPrimarybluey / 100000;
|
||||
}
|
||||
|
||||
sWhitepoint.Y = /* Y component is always 1.0 */
|
||||
sPrimaries.Red.Y =
|
||||
sPrimaries.Green.Y =
|
||||
sPrimaries.Blue.Y = 1.0;
|
||||
|
||||
if (pBuf->bHasGAMA) /* get the gamma value */
|
||||
dGamma = (mng_float)pBuf->iGamma / 100000;
|
||||
else
|
||||
dGamma = (mng_float)pData->iGlobalGamma / 100000;
|
||||
|
||||
/* dGamma = pData->dViewgamma / (dGamma * pData->dDisplaygamma); ??? */
|
||||
dGamma = pData->dViewgamma / dGamma;
|
||||
|
||||
pGammatable [0] = /* and build the lookup tables */
|
||||
pGammatable [1] =
|
||||
pGammatable [2] = cmsBuildGamma (256, dGamma);
|
||||
|
||||
/* B001 start */
|
||||
if (!pGammatable [0]) /* enough memory ? */
|
||||
/* B001 end */
|
||||
MNG_ERRORL (pData, MNG_LCMS_NOMEM)
|
||||
/* create the profile */
|
||||
hProf = cmsCreateRGBProfile (&sWhitepoint, &sPrimaries, pGammatable);
|
||||
|
||||
/* B001 start */
|
||||
cmsFreeGamma (pGammatable [0]); /* free the temporary gamma tables ? */
|
||||
/* yes! but just the one! */
|
||||
/* B001 end */
|
||||
|
||||
pData->hProf1 = hProf; /* save for future use */
|
||||
|
||||
if (!hProf) /* handle error ? */
|
||||
MNG_ERRORL (pData, MNG_LCMS_NOHANDLE)
|
||||
|
||||
if (pData->bIsRGBA16) /* 16-bit intermediates ? */
|
||||
hTrans = cmsCreateTransform (hProf, TYPE_RGBA_16_SE,
|
||||
pData->hProf2, TYPE_RGBA_16_SE,
|
||||
INTENT_PERCEPTUAL, MNG_CMS_FLAGS);
|
||||
else
|
||||
hTrans = cmsCreateTransform (hProf, TYPE_RGBA_8,
|
||||
pData->hProf2, TYPE_RGBA_8,
|
||||
INTENT_PERCEPTUAL, MNG_CMS_FLAGS);
|
||||
|
||||
pData->hTrans = hTrans; /* save for future use */
|
||||
|
||||
if (!hTrans) /* handle error ? */
|
||||
MNG_ERRORL (pData, MNG_LCMS_NOTRANS)
|
||||
/* load color-correction routine */
|
||||
pData->fCorrectrow = (mng_ptr)correct_full_cms;
|
||||
|
||||
return MNG_NOERROR; /* and done */
|
||||
}
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_INIT_FULL_CMS, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return init_gamma_only (pData); /* if we get here, we'll only do gamma */
|
||||
}
|
||||
#endif /* MNG_INCLUDE_LCMS */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_LCMS
|
||||
|
||||
mng_retcode init_full_cms_object (mng_datap pData)
|
||||
{
|
||||
mng_cmsprof hProf;
|
||||
mng_cmstrans hTrans;
|
||||
mng_imagedatap pBuf;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_INIT_FULL_CMS_OBJ, MNG_LC_START)
|
||||
#endif
|
||||
/* address the object-buffer */
|
||||
pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf;
|
||||
|
||||
if (pBuf->bHasICCP)
|
||||
{
|
||||
if (!pData->hProf2) /* output profile defined ? */
|
||||
MNG_ERROR (pData, MNG_NOOUTPUTPROFILE);
|
||||
|
||||
/* generate a profile handle */
|
||||
hProf = cmsOpenProfileFromMem (pBuf->pProfile, pBuf->iProfilesize);
|
||||
|
||||
pData->hProf1 = hProf; /* save for future use */
|
||||
|
||||
if (!hProf) /* handle error ? */
|
||||
MNG_ERRORL (pData, MNG_LCMS_NOHANDLE)
|
||||
|
||||
if (pData->bIsRGBA16) /* 16-bit intermediates ? */
|
||||
hTrans = cmsCreateTransform (hProf, TYPE_RGBA_16_SE,
|
||||
pData->hProf2, TYPE_RGBA_16_SE,
|
||||
INTENT_PERCEPTUAL, MNG_CMS_FLAGS);
|
||||
else
|
||||
hTrans = cmsCreateTransform (hProf, TYPE_RGBA_8,
|
||||
pData->hProf2, TYPE_RGBA_8,
|
||||
INTENT_PERCEPTUAL, MNG_CMS_FLAGS);
|
||||
|
||||
pData->hTrans = hTrans; /* save for future use */
|
||||
|
||||
if (!hTrans) /* handle error ? */
|
||||
MNG_ERRORL (pData, MNG_LCMS_NOTRANS)
|
||||
/* load color-correction routine */
|
||||
pData->fCorrectrow = (mng_ptr)correct_full_cms;
|
||||
|
||||
return MNG_NOERROR; /* and done */
|
||||
}
|
||||
|
||||
if (pBuf->bHasSRGB)
|
||||
{
|
||||
if (pData->bIssRGB) /* sRGB system ? */
|
||||
return MNG_NOERROR; /* no conversion required */
|
||||
|
||||
if (!pData->hProf3) /* sRGB profile defined ? */
|
||||
MNG_ERROR (pData, MNG_NOSRGBPROFILE)
|
||||
|
||||
hProf = pData->hProf3; /* convert from sRGB profile */
|
||||
|
||||
if (pData->bIsRGBA16) /* 16-bit intermediates ? */
|
||||
hTrans = cmsCreateTransform (hProf, TYPE_RGBA_16_SE,
|
||||
pData->hProf2, TYPE_RGBA_16_SE,
|
||||
pBuf->iRenderingintent, MNG_CMS_FLAGS);
|
||||
else
|
||||
hTrans = cmsCreateTransform (hProf, TYPE_RGBA_8,
|
||||
pData->hProf2, TYPE_RGBA_8,
|
||||
pBuf->iRenderingintent, MNG_CMS_FLAGS);
|
||||
|
||||
pData->hTrans = hTrans; /* save for future use */
|
||||
|
||||
if (!hTrans) /* handle error ? */
|
||||
MNG_ERRORL (pData, MNG_LCMS_NOTRANS)
|
||||
/* load color-correction routine */
|
||||
pData->fCorrectrow = (mng_ptr)correct_full_cms;
|
||||
|
||||
return MNG_NOERROR; /* and done */
|
||||
}
|
||||
|
||||
if ((pBuf->bHasCHRM) && (pBuf->bHasGAMA))
|
||||
{
|
||||
mng_CIExyY sWhitepoint;
|
||||
mng_CIExyYTRIPLE sPrimaries;
|
||||
mng_gammatabp pGammatable[3];
|
||||
mng_float dGamma;
|
||||
|
||||
sWhitepoint.x = (mng_float)pBuf->iWhitepointx / 100000;
|
||||
sWhitepoint.y = (mng_float)pBuf->iWhitepointy / 100000;
|
||||
sPrimaries.Red.x = (mng_float)pBuf->iPrimaryredx / 100000;
|
||||
sPrimaries.Red.y = (mng_float)pBuf->iPrimaryredy / 100000;
|
||||
sPrimaries.Green.x = (mng_float)pBuf->iPrimarygreenx / 100000;
|
||||
sPrimaries.Green.y = (mng_float)pBuf->iPrimarygreeny / 100000;
|
||||
sPrimaries.Blue.x = (mng_float)pBuf->iPrimarybluex / 100000;
|
||||
sPrimaries.Blue.y = (mng_float)pBuf->iPrimarybluey / 100000;
|
||||
|
||||
sWhitepoint.Y = /* Y component is always 1.0 */
|
||||
sPrimaries.Red.Y =
|
||||
sPrimaries.Green.Y =
|
||||
sPrimaries.Blue.Y = 1.0;
|
||||
|
||||
dGamma = (mng_float)pBuf->iGamma / 100000;
|
||||
|
||||
/* dGamma = pData->dViewgamma / (dGamma * pData->dDisplaygamma); ??? */
|
||||
dGamma = pData->dViewgamma / dGamma;
|
||||
|
||||
pGammatable [0] = /* and build the lookup tables */
|
||||
pGammatable [1] =
|
||||
pGammatable [2] = cmsBuildGamma (256, dGamma);
|
||||
|
||||
/* B001 start */
|
||||
if (!pGammatable [0]) /* enough memory ? */
|
||||
/* B001 end */
|
||||
MNG_ERRORL (pData, MNG_LCMS_NOMEM)
|
||||
|
||||
/* create the profile */
|
||||
hProf = cmsCreateRGBProfile (&sWhitepoint, &sPrimaries, pGammatable);
|
||||
|
||||
/* B001 start */
|
||||
cmsFreeGamma (pGammatable [0]); /* free the temporary gamma tables ? */
|
||||
/* yes! but just the one! */
|
||||
/* B001 end */
|
||||
|
||||
pData->hProf1 = hProf; /* save for future use */
|
||||
|
||||
if (!hProf) /* handle error ? */
|
||||
MNG_ERRORL (pData, MNG_LCMS_NOHANDLE)
|
||||
|
||||
if (pData->bIsRGBA16) /* 16-bit intermediates ? */
|
||||
hTrans = cmsCreateTransform (hProf, TYPE_RGBA_16_SE,
|
||||
pData->hProf2, TYPE_RGBA_16_SE,
|
||||
INTENT_PERCEPTUAL, MNG_CMS_FLAGS);
|
||||
else
|
||||
hTrans = cmsCreateTransform (hProf, TYPE_RGBA_8,
|
||||
pData->hProf2, TYPE_RGBA_8,
|
||||
INTENT_PERCEPTUAL, MNG_CMS_FLAGS);
|
||||
|
||||
pData->hTrans = hTrans; /* save for future use */
|
||||
|
||||
if (!hTrans) /* handle error ? */
|
||||
MNG_ERRORL (pData, MNG_LCMS_NOTRANS)
|
||||
/* load color-correction routine */
|
||||
pData->fCorrectrow = (mng_ptr)correct_full_cms;
|
||||
|
||||
return MNG_NOERROR; /* and done */
|
||||
}
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_INIT_FULL_CMS_OBJ, MNG_LC_END)
|
||||
#endif
|
||||
/* if we get here, we'll only do gamma */
|
||||
return init_gamma_only_object (pData);
|
||||
}
|
||||
#endif /* MNG_INCLUDE_LCMS */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_LCMS
|
||||
mng_retcode correct_full_cms (mng_datap pData)
|
||||
{
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_CORRECT_FULL_CMS, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
cmsDoTransform (pData->hTrans, pData->pRGBArow, pData->pRGBArow, pData->iRowsamples);
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_CORRECT_FULL_CMS, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
#endif /* MNG_INCLUDE_LCMS */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if defined(MNG_GAMMA_ONLY) || defined(MNG_FULL_CMS)
|
||||
mng_retcode init_gamma_only (mng_datap pData)
|
||||
{
|
||||
mng_float dGamma;
|
||||
mng_imagep pImage = (mng_imagep)pData->pCurrentobj;
|
||||
mng_imagedatap pBuf;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_INIT_GAMMA_ONLY, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
if (!pImage) /* no current object? then use object 0 */
|
||||
pImage = (mng_imagep)pData->pObjzero;
|
||||
|
||||
pBuf = pImage->pImgbuf; /* address the buffer */
|
||||
|
||||
if (pBuf->bHasGAMA) /* get the gamma value */
|
||||
dGamma = (mng_float)pBuf->iGamma / 100000;
|
||||
else
|
||||
if (pData->bHasglobalGAMA)
|
||||
dGamma = (mng_float)pData->iGlobalGamma / 100000;
|
||||
else
|
||||
dGamma = pData->dDfltimggamma;
|
||||
|
||||
if (dGamma) /* lets not divide by zero, shall we... */
|
||||
dGamma = pData->dViewgamma / (dGamma * pData->dDisplaygamma);
|
||||
|
||||
if (dGamma != pData->dLastgamma) /* lookup table needs to be computed ? */
|
||||
{
|
||||
mng_int32 iX;
|
||||
|
||||
pData->aGammatab [0] = 0;
|
||||
|
||||
for (iX = 1; iX <= 255; iX++)
|
||||
pData->aGammatab [iX] = (mng_uint8)(pow (iX / 255.0, dGamma) * 255 + 0.5);
|
||||
|
||||
pData->dLastgamma = dGamma; /* keep for next time */
|
||||
}
|
||||
/* load color-correction routine */
|
||||
pData->fCorrectrow = (mng_ptr)correct_gamma_only;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_INIT_GAMMA_ONLY, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
#endif /* MNG_GAMMA_ONLY || MNG_FULL_CMS */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if defined(MNG_GAMMA_ONLY) || defined(MNG_FULL_CMS)
|
||||
mng_retcode init_gamma_only_object (mng_datap pData)
|
||||
{
|
||||
mng_float dGamma;
|
||||
mng_imagedatap pBuf;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_INIT_GAMMA_ONLY_OBJ, MNG_LC_START)
|
||||
#endif
|
||||
/* address the object-buffer */
|
||||
pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf;
|
||||
|
||||
if (pBuf->bHasGAMA) /* get the gamma value */
|
||||
dGamma = (mng_float)pBuf->iGamma / 100000;
|
||||
else
|
||||
dGamma = pData->dDfltimggamma;
|
||||
|
||||
if (dGamma) /* lets not divide by zero, shall we... */
|
||||
dGamma = pData->dViewgamma / (dGamma * pData->dDisplaygamma);
|
||||
|
||||
if (dGamma != pData->dLastgamma) /* lookup table needs to be computed ? */
|
||||
{
|
||||
mng_int32 iX;
|
||||
|
||||
pData->aGammatab [0] = 0;
|
||||
|
||||
for (iX = 1; iX <= 255; iX++)
|
||||
pData->aGammatab [iX] = (mng_uint8)(pow (iX / 255.0, dGamma) * 255 + 0.5);
|
||||
|
||||
pData->dLastgamma = dGamma; /* keep for next time */
|
||||
}
|
||||
/* load color-correction routine */
|
||||
pData->fCorrectrow = (mng_ptr)correct_gamma_only;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_INIT_GAMMA_ONLY_OBJ, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
#endif /* MNG_GAMMA_ONLY || MNG_FULL_CMS */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if defined(MNG_GAMMA_ONLY) || defined(MNG_FULL_CMS)
|
||||
mng_retcode correct_gamma_only (mng_datap pData)
|
||||
{
|
||||
mng_uint8p pWork;
|
||||
mng_int32 iX;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_CORRECT_GAMMA_ONLY, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
pWork = pData->pRGBArow; /* address intermediate row */
|
||||
|
||||
if (pData->bIsRGBA16) /* 16-bit intermediate row ? */
|
||||
{
|
||||
|
||||
|
||||
/* TODO: 16-bit precision gamma processing */
|
||||
/* we'll just do the high-order byte for now */
|
||||
|
||||
|
||||
/* convert all samples in the row */
|
||||
for (iX = 0; iX < pData->iRowsamples; iX++)
|
||||
{ /* using the precalculated gamma lookup table */
|
||||
*pWork = pData->aGammatab [*pWork];
|
||||
*(pWork+2) = pData->aGammatab [*(pWork+2)];
|
||||
*(pWork+4) = pData->aGammatab [*(pWork+4)];
|
||||
|
||||
pWork += 8;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ /* convert all samples in the row */
|
||||
for (iX = 0; iX < pData->iRowsamples; iX++)
|
||||
{ /* using the precalculated gamma lookup table */
|
||||
*pWork = pData->aGammatab [*pWork];
|
||||
*(pWork+1) = pData->aGammatab [*(pWork+1)];
|
||||
*(pWork+2) = pData->aGammatab [*(pWork+2)];
|
||||
|
||||
pWork += 4;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_CORRECT_GAMMA_ONLY, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
#endif /* MNG_GAMMA_ONLY || MNG_FULL_CMS */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_APP_CMS
|
||||
mng_retcode init_app_cms (mng_datap pData)
|
||||
{
|
||||
mng_imagedatap pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_INIT_APP_CMS, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
if ( (pData->fProcessiccp) &&
|
||||
((pBuf->bHasICCP) || (pData->bHasglobalICCP)) )
|
||||
{
|
||||
mng_uint32 iProfilesize;
|
||||
mng_ptr pProfile;
|
||||
|
||||
if (pBuf->bHasICCP) /* get the right profile */
|
||||
{
|
||||
iProfilesize = pBuf->iProfilesize;
|
||||
pProfile = pBuf->pProfile;
|
||||
}
|
||||
else
|
||||
{
|
||||
iProfilesize = pData->iGlobalProfilesize;
|
||||
pProfile = pData->pGlobalProfile;
|
||||
}
|
||||
/* inform the app */
|
||||
if (!pData->fProcessiccp ((mng_handle)pData, iProfilesize, pProfile))
|
||||
MNG_ERROR (pData, MNG_APPCMSERROR)
|
||||
/* load color-correction routine */
|
||||
pData->fCorrectrow = (mng_ptr)correct_app_cms;
|
||||
}
|
||||
|
||||
if ( (pData->fProcesssrgb) &&
|
||||
((pBuf->bHasSRGB) || (pData->bHasglobalSRGB)) )
|
||||
{
|
||||
mng_uint8 iIntent;
|
||||
|
||||
if (pBuf->bHasSRGB) /* determine rendering intent */
|
||||
iIntent = pBuf->iRenderingintent;
|
||||
else
|
||||
iIntent = pData->iGlobalRendintent;
|
||||
/* inform the app */
|
||||
if (!pData->fProcesssrgb ((mng_handle)pData, iIntent))
|
||||
MNG_ERROR (pData, MNG_APPCMSERROR)
|
||||
/* load color-correction routine */
|
||||
pData->fCorrectrow = (mng_ptr)correct_app_cms;
|
||||
}
|
||||
|
||||
if ( (pData->fProcesschroma) &&
|
||||
( ((pBuf->bHasCHRM) || (pData->bHasglobalCHRM)) ) )
|
||||
{
|
||||
mng_uint32 iWhitepointx, iWhitepointy;
|
||||
mng_uint32 iPrimaryredx, iPrimaryredy;
|
||||
mng_uint32 iPrimarygreenx, iPrimarygreeny;
|
||||
mng_uint32 iPrimarybluex, iPrimarybluey;
|
||||
|
||||
if (pBuf->bHasCHRM) /* local cHRM ? */
|
||||
{
|
||||
iWhitepointx = pBuf->iWhitepointx;
|
||||
iWhitepointy = pBuf->iWhitepointy;
|
||||
iPrimaryredx = pBuf->iPrimaryredx;
|
||||
iPrimaryredy = pBuf->iPrimaryredy;
|
||||
iPrimarygreenx = pBuf->iPrimarygreenx;
|
||||
iPrimarygreeny = pBuf->iPrimarygreeny;
|
||||
iPrimarybluex = pBuf->iPrimarybluex;
|
||||
iPrimarybluey = pBuf->iPrimarybluey;
|
||||
}
|
||||
else
|
||||
{
|
||||
iWhitepointx = pData->iGlobalWhitepointx;
|
||||
iWhitepointy = pData->iGlobalWhitepointy;
|
||||
iPrimaryredx = pData->iGlobalPrimaryredx;
|
||||
iPrimaryredy = pData->iGlobalPrimaryredy;
|
||||
iPrimarygreenx = pData->iGlobalPrimarygreenx;
|
||||
iPrimarygreeny = pData->iGlobalPrimarygreeny;
|
||||
iPrimarybluex = pData->iGlobalPrimarybluex;
|
||||
iPrimarybluey = pData->iGlobalPrimarybluey;
|
||||
}
|
||||
/* inform the app */
|
||||
if (!pData->fProcesschroma ((mng_handle)pData, iWhitepointx, iWhitepointy,
|
||||
iPrimaryredx, iPrimaryredy,
|
||||
iPrimarygreenx, iPrimarygreeny,
|
||||
iPrimarybluex, iPrimarybluey))
|
||||
MNG_ERROR (pData, MNG_APPCMSERROR)
|
||||
/* load color-correction routine */
|
||||
pData->fCorrectrow = (mng_ptr)correct_app_cms;
|
||||
}
|
||||
|
||||
if ( (pData->fProcessgamma) &&
|
||||
((pBuf->bHasGAMA) || (pData->bHasglobalGAMA)) )
|
||||
{
|
||||
mng_uint32 iGamma;
|
||||
|
||||
if (pBuf->bHasGAMA) /* get the gamma value */
|
||||
iGamma = pBuf->iGamma;
|
||||
else
|
||||
iGamma = pData->iGlobalGamma;
|
||||
/* inform the app */
|
||||
if (!pData->fProcessgamma ((mng_handle)pData, iGamma))
|
||||
MNG_ERROR (pData, MNG_APPCMSERROR)
|
||||
/* load color-correction routine */
|
||||
pData->fCorrectrow = (mng_ptr)correct_app_cms;
|
||||
}
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_INIT_APP_CMS, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
#endif /* MNG_APP_CMS */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_APP_CMS
|
||||
mng_retcode init_app_cms_object (mng_datap pData)
|
||||
{
|
||||
mng_imagedatap pBuf = ((mng_imagep)pData->pCurrentobj)->pImgbuf;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_INIT_APP_CMS_OBJ, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
if ((pData->fProcessiccp) && (pBuf->bHasICCP))
|
||||
{ /* inform the app */
|
||||
if (!pData->fProcessiccp ((mng_handle)pData, pBuf->iProfilesize, pBuf->pProfile))
|
||||
MNG_ERROR (pData, MNG_APPCMSERROR)
|
||||
/* load color-correction routine */
|
||||
pData->fCorrectrow = (mng_ptr)correct_app_cms;
|
||||
}
|
||||
|
||||
if ((pData->fProcesssrgb) && (pBuf->bHasSRGB))
|
||||
{ /* inform the app */
|
||||
if (!pData->fProcesssrgb ((mng_handle)pData, pBuf->iRenderingintent))
|
||||
MNG_ERROR (pData, MNG_APPCMSERROR)
|
||||
/* load color-correction routine */
|
||||
pData->fCorrectrow = (mng_ptr)correct_app_cms;
|
||||
}
|
||||
|
||||
if ((pData->fProcesschroma) && (pBuf->bHasCHRM))
|
||||
{ /* inform the app */
|
||||
if (!pData->fProcesschroma ((mng_handle)pData, pBuf->iWhitepointx, pBuf->iWhitepointy,
|
||||
pBuf->iPrimaryredx, pBuf->iPrimaryredy,
|
||||
pBuf->iPrimarygreenx, pBuf->iPrimarygreeny,
|
||||
pBuf->iPrimarybluex, pBuf->iPrimarybluey))
|
||||
MNG_ERROR (pData, MNG_APPCMSERROR)
|
||||
/* load color-correction routine */
|
||||
pData->fCorrectrow = (mng_ptr)correct_app_cms;
|
||||
}
|
||||
|
||||
if ((pData->fProcessgamma) && (pBuf->bHasGAMA))
|
||||
{ /* inform the app */
|
||||
if (!pData->fProcessgamma ((mng_handle)pData, pBuf->iGamma))
|
||||
MNG_ERROR (pData, MNG_APPCMSERROR)
|
||||
/* load color-correction routine */
|
||||
pData->fCorrectrow = (mng_ptr)correct_app_cms;
|
||||
}
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_INIT_APP_CMS_OBJ, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
#endif /* MNG_APP_CMS */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_APP_CMS
|
||||
mng_retcode correct_app_cms (mng_datap pData)
|
||||
{
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_CORRECT_APP_CMS, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
if (pData->fProcessarow) /* let the app do something with our row */
|
||||
if (!pData->fProcessarow ((mng_handle)pData, pData->iRowsamples,
|
||||
pData->bIsRGBA16, pData->pRGBArow))
|
||||
MNG_ERROR (pData, MNG_APPCMSERROR)
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_CORRECT_APP_CMS, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
#endif /* MNG_APP_CMS */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* MNG_INCLUDE_DISPLAY_PROCS */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_cms.h copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : color management routines (definition) * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : Definition of color management routines * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * 0.5.1 - 05/11/2000 - G.Juyn * */
|
||||
/* * - added creatememprofile * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* force ANSI-C */
|
||||
#endif
|
||||
|
||||
#ifndef _libmng_cms_h_
|
||||
#define _libmng_cms_h_
|
||||
|
||||
#include "libmng.h"
|
||||
#include "libmng_data.h"
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_LCMS
|
||||
void mnglcms_initlibrary (void);
|
||||
mng_cmsprof mnglcms_createfileprofile (mng_pchar zFilename);
|
||||
mng_cmsprof mnglcms_creatememprofile (mng_uint32 iProfilesize,
|
||||
mng_ptr pProfile );
|
||||
void mnglcms_freeprofile (mng_cmsprof hProf );
|
||||
void mnglcms_freetransform (mng_cmstrans hTrans );
|
||||
#endif
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_FULL_CMS
|
||||
mng_retcode init_full_cms (mng_datap pData);
|
||||
mng_retcode init_full_cms_object (mng_datap pData);
|
||||
mng_retcode correct_full_cms (mng_datap pData);
|
||||
#endif
|
||||
|
||||
#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY)
|
||||
mng_retcode init_gamma_only (mng_datap pData);
|
||||
mng_retcode init_gamma_only_object (mng_datap pData);
|
||||
mng_retcode correct_gamma_only (mng_datap pData);
|
||||
#endif
|
||||
|
||||
#ifdef MNG_APP_CMS
|
||||
mng_retcode init_app_cms (mng_datap pData);
|
||||
mng_retcode init_app_cms_object (mng_datap pData);
|
||||
mng_retcode correct_app_cms (mng_datap pData);
|
||||
#endif
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* _libmng_cms_h_ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
|
@ -0,0 +1,208 @@
|
|||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_conf.h copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : main configuration file * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : The configuration file. Change this to include/exclude * */
|
||||
/* * the options you want or do not want in libmng. * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.2 - 06/02/2000 - G.Juyn * */
|
||||
/* * - separated configuration-options into this file * */
|
||||
/* * - changed to most likely configuration (?) * */
|
||||
/* * 0.5.2 - 06/03/2000 - G.Juyn * */
|
||||
/* * - changed options to create a standard so-library * */
|
||||
/* * with everything enabled * */
|
||||
/* * 0.5.2 - 06/04/2000 - G.Juyn * */
|
||||
/* * - changed options to create a standard win32-dll * */
|
||||
/* * with everything enabled * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* force ANSI-C */
|
||||
#endif
|
||||
|
||||
#ifndef _libmng_conf_h_
|
||||
#define _libmng_conf_h_
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * User-selectable compile-time options * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
/* enable exactly one(1) of the MNG-(sub)set selectors */
|
||||
/* use this to select which (sub)set of the MNG specification you wish
|
||||
to support */
|
||||
/* generally you'll want full support as the library provides it automatically
|
||||
for you! if you're really strung on memory-requirements you can opt
|
||||
to enable less support (but it's just NOT a good idea!) */
|
||||
/* NOTE that this isn't actually implemented yet */
|
||||
|
||||
#if !defined(MNG_SUPPORT_FULL) && !defined(MNG_SUPPORT_LC) && !defined(MNG_SUPPORT_VLC)
|
||||
#define MNG_SUPPORT_FULL
|
||||
/* #define MNG_SUPPORT_LC */
|
||||
/* #define MNG_SUPPORT_VLC */
|
||||
#endif
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
/* enable JPEG support if required */
|
||||
/* use this to enable the JNG support routines */
|
||||
/* this requires an external jpeg package;
|
||||
currently only IJG's jpgsrc6b is supported! */
|
||||
/* NOTE that the IJG code can be either 8- or 12-bit (eg. not both);
|
||||
so choose the one you've defined in jconfig.h; if you don't know what
|
||||
the heck I'm talking about, just leave it at 8-bit support (thank you!) */
|
||||
|
||||
#ifdef MNG_SUPPORT_FULL /* full support includes JNG */
|
||||
#define MNG_SUPPORT_IJG6B
|
||||
#endif
|
||||
|
||||
#ifndef MNG_SUPPORT_IJG6B
|
||||
#if defined(MNG_BUILD_SO) || defined(MNG_USE_SO) || defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL)
|
||||
#define MNG_SUPPORT_IJG6B
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(MNG_SUPPORT_IJG6B) && !defined(MNG_SUPPORT_JPEG8) && !defined(MNG_SUPPORT_JPEG12)
|
||||
#define MNG_SUPPORT_JPEG8
|
||||
/* #define MNG_SUPPORT_JPEG12 */
|
||||
#endif
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
/* enable required high-level functions */
|
||||
/* use this to select the high-level functions you require */
|
||||
/* if you only need to display a MNG, disable write support! */
|
||||
/* if you only need to examine a MNG, disable write & display support! */
|
||||
/* if you only need to copy a MNG, disable display support! */
|
||||
/* if you only need to create a MNG, disable read & display support! */
|
||||
/* NOTE that turning all options off will be very unuseful! */
|
||||
|
||||
#if !defined(MNG_SUPPORT_READ) && !defined(MNG_SUPPORT_WRITE) && !defined(MNG_SUPPORT_DISPLAY)
|
||||
#define MNG_SUPPORT_READ
|
||||
#if defined(MNG_BUILD_SO) || defined(MNG_USE_SO) || defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL)
|
||||
#define MNG_SUPPORT_WRITE
|
||||
#endif
|
||||
#define MNG_SUPPORT_DISPLAY
|
||||
#endif
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
/* enable chunk access functions */
|
||||
/* use this to select whether you need access to the individual chunks */
|
||||
/* useful if you want to examine a read MNG (you'll also need MNG_STORE_CHUNKS !)*/
|
||||
/* required if you need to create & write a new MNG! */
|
||||
|
||||
#ifndef MNG_ACCESS_CHUNKS
|
||||
#if defined(MNG_BUILD_SO) || defined(MNG_USE_SO) || defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL)
|
||||
#define MNG_ACCESS_CHUNKS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
/* enable exactly one of the color-management-functionality selectors */
|
||||
/* use this to select the level of automatic color support */
|
||||
/* MNG_FULL_CMS requires the lcms (little cms) external package ! */
|
||||
/* if you want your own app (or the OS) to handle color-management
|
||||
select MNG_APP_CMS */
|
||||
|
||||
#if !defined(MNG_FULL_CMS) && !defined(MNG_GAMMA_ONLY) && !defined(MNG_NO_CMS) && !defined(MNG_APP_CMS)
|
||||
#if defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL)
|
||||
#define MNG_FULL_CMS
|
||||
#else
|
||||
#define MNG_GAMMA_ONLY
|
||||
#endif
|
||||
/* #define MNG_NO_CMS */
|
||||
/* #define MNG_APP_CMS */
|
||||
#endif
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
/* enable automatic dithering */
|
||||
/* use this if you need dithering support to convert high-resolution
|
||||
images to a low-resolution output-device */
|
||||
/* NOTE that this is not supported yet */
|
||||
|
||||
/* #define MNG_AUTO_DITHER */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
/* enable whether chunks should be stored for reference later */
|
||||
/* use this if you need to examine the chunks of a MNG you have read,
|
||||
or (re-)write a MNG you have read */
|
||||
/* turn this off if you want to reduce memory-consumption */
|
||||
|
||||
#ifndef MNG_STORE_CHUNKS
|
||||
#if defined(MNG_BUILD_SO) || defined(MNG_USE_SO) || defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL)
|
||||
#define MNG_STORE_CHUNKS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
/* enable internal memory management (if your compiler supports it) */
|
||||
/* use this if your compiler supports the 'standard' memory functions
|
||||
(calloc & free), and you want the library to use these functions and not
|
||||
bother your app with memory-callbacks */
|
||||
|
||||
/* #define MNG_INTERNAL_MEMMNGMT */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
/* enable internal tracing-functionality (manual debugging purposes) */
|
||||
/* use this if you have trouble location bugs or problems */
|
||||
/* NOTE that you'll need to specify the trace callback function! */
|
||||
|
||||
#ifndef MNG_SUPPORT_TRACE
|
||||
#if defined(MNG_BUILD_SO) || defined(MNG_USE_SO) || defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL)
|
||||
#define MNG_SUPPORT_TRACE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
/* enable extended error- and trace-telltaling */
|
||||
/* use this if you need explanatory messages with errors and/or tracing */
|
||||
|
||||
#if !defined(MNG_ERROR_TELLTALE) && !defined(MNG_TRACE_TELLTALE)
|
||||
#if defined(MNG_BUILD_SO) || defined(MNG_USE_SO) || defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL)
|
||||
#define MNG_ERROR_TELLTALE
|
||||
#define MNG_TRACE_TELLTALE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
/* enable big-endian support */
|
||||
/* enable this if you're on an architecture that supports big-endian reads
|
||||
and writes that aren't word-aligned */
|
||||
/* according to reliable sources this only works for PowerPC (bigendian mode)
|
||||
and 680x0 */
|
||||
|
||||
/* #define MNG_BIGENDIAN_SUPPORTED */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * End of user-selectable compile-time options * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* _libmng_conf_h_ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
||||
|
|
@ -0,0 +1,676 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_data.h copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : main data structure definition * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : Definition of the library main data structure * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/04/2000 - G.Juyn * */
|
||||
/* * - added CRC table to main structure (for thread-safety) * */
|
||||
/* * 0.5.1 - 05/06/2000 - G.Juyn * */
|
||||
/* * - added iPLTEentries for checking hIST-length * */
|
||||
/* * 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - changed palette definition to exported palette-type * */
|
||||
/* * - removed frozen indicator * */
|
||||
/* * - added create/write indicators * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * 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) * */
|
||||
/* * - added saved-data structure for SAVE/SEEK processing * */
|
||||
/* * * */
|
||||
/* * 0.5.2 - 05/18/2000 - G.Juyn * */
|
||||
/* * - added fields for JNG support (IJG-based) * */
|
||||
/* * 0.5.2 - 05/24/2000 - G.Juyn * */
|
||||
/* * - changed global tRNS definition * */
|
||||
/* * 0.5.2 - 05/30/2000 - G.Juyn * */
|
||||
/* * - added delta-image fields * */
|
||||
/* * 0.5.2 - 06/01/2000 - G.Juyn * */
|
||||
/* * - added internal delta-image processing callbacks * */
|
||||
/* * 0.5.2 - 06/02/2000 - G.Juyn * */
|
||||
/* * - changed SWAP_ENDIAN to BIGENDIAN_SUPPORTED * */
|
||||
/* * (contributed by Tim Rowley) * */
|
||||
/* * - added getalphaline callback for RGB8_A8 canvasstyle * */
|
||||
/* * 0.5.2 - 06/06/2000 - G.Juyn * */
|
||||
/* * - added parameter for delayed buffer-processing * */
|
||||
/* * * */
|
||||
/* * 0.5.3 - 06/16/2000 - G.Juyn * */
|
||||
/* * - added update-region parms for refresh calback * */
|
||||
/* * - added Needrefresh parameter * */
|
||||
/* * 0.5.3 - 06/17/2000 - G.Juyn * */
|
||||
/* * - added Deltaimmediate parm for faster delta-processing * */
|
||||
/* * 0.5.3 - 06/21/2000 - G.Juyn * */
|
||||
/* * - added Speed parameter to facilitate testing * */
|
||||
/* * - added Imagelevel parameter for processtext callback * */
|
||||
/* * 0.5.3 - 06/26/2000 - G.Juyn * */
|
||||
/* * - changed userdata variable to mng_ptr * */
|
||||
/* * * */
|
||||
/* * 0.9.1 - 07/07/2000 - G.Juyn * */
|
||||
/* * - added variables for go_xxxx processing * */
|
||||
/* * 0.9.1 - 07/08/2000 - G.Juyn * */
|
||||
/* * - added variables for improved timing support * */
|
||||
/* * 0.9.1 - 07/15/2000 - G.Juyn * */
|
||||
/* * - added callbacks for SAVE/SEEK processing * */
|
||||
/* * - added variable for NEEDSECTIONWAIT breaks * */
|
||||
/* * - added variable for freeze & reset processing * */
|
||||
/* * 0.9.1 - 07/17/2000 - G.Juyn * */
|
||||
/* * - fixed suspension-buffering for 32K+ chunks * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 07/29/2000 - G.Juyn * */
|
||||
/* * - removed Nextbackxxx fields (no longer used) * */
|
||||
/* * 0.9.2 - 07/31/2000 - G.Juyn * */
|
||||
/* * - fixed wrapping of suspension parameters * */
|
||||
/* * 0.9.2 - 08/04/2000 - G.Juyn * */
|
||||
/* * - B111096 - fixed large-buffer read-suspension * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* force ANSI-C */
|
||||
#endif
|
||||
|
||||
#ifndef _libmng_data_h_
|
||||
#define _libmng_data_h_
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#define MNG_MAGIC 0x52530a0aL
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * Internal structures * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef mng_palette8 mng_rgbpaltab;
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * The saved_data structure * */
|
||||
/* * * */
|
||||
/* * This contains the saved data after a SAVE chunk has been processed. * */
|
||||
/* * The data is saved from the main data structure during SAVE processing, * */
|
||||
/* * and restored to the main data structure during SEEK processing. * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct mng_savedata_struct {
|
||||
|
||||
#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE)
|
||||
mng_bool bHasglobalPLTE; /* global PLTE chunk processed */
|
||||
mng_bool bHasglobalTRNS; /* global tRNS chunk processed */
|
||||
mng_bool bHasglobalGAMA; /* global gAMA chunk processed */
|
||||
mng_bool bHasglobalCHRM; /* global cHRM chunk processed */
|
||||
mng_bool bHasglobalSRGB; /* global sRGB chunk processed */
|
||||
mng_bool bHasglobalICCP; /* global iCCP chunk processed */
|
||||
mng_bool bHasglobalBKGD; /* global bKGD chunk processed */
|
||||
#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */
|
||||
|
||||
#ifdef MNG_SUPPORT_DISPLAY
|
||||
mng_uint16 iDEFIobjectid; /* DEFI fields */
|
||||
mng_uint8 iDEFIdonotshow;
|
||||
mng_uint8 iDEFIconcrete;
|
||||
mng_bool bDEFIhasloca;
|
||||
mng_int32 iDEFIlocax;
|
||||
mng_int32 iDEFIlocay;
|
||||
mng_bool bDEFIhasclip;
|
||||
mng_int32 iDEFIclipl;
|
||||
mng_int32 iDEFIclipr;
|
||||
mng_int32 iDEFIclipt;
|
||||
mng_int32 iDEFIclipb;
|
||||
|
||||
mng_uint16 iBACKred; /* BACK fields */
|
||||
mng_uint16 iBACKgreen;
|
||||
mng_uint16 iBACKblue;
|
||||
mng_uint8 iBACKmandatory;
|
||||
mng_uint16 iBACKimageid;
|
||||
mng_uint8 iBACKtile;
|
||||
|
||||
mng_uint8 iFRAMmode; /* FRAM fields (global) */
|
||||
mng_uint32 iFRAMdelay;
|
||||
mng_uint32 iFRAMtimeout;
|
||||
mng_bool bFRAMclipping;
|
||||
mng_int32 iFRAMclipl;
|
||||
mng_int32 iFRAMclipr;
|
||||
mng_int32 iFRAMclipt;
|
||||
mng_int32 iFRAMclipb;
|
||||
|
||||
mng_uint32 iGlobalPLTEcount; /* global PLTE fields */
|
||||
mng_rgbpaltab aGlobalPLTEentries;
|
||||
|
||||
mng_uint32 iGlobalTRNSrawlen; /* global tRNS fields */
|
||||
mng_uint8arr aGlobalTRNSrawdata;
|
||||
|
||||
mng_uint32 iGlobalGamma; /* global gAMA fields */
|
||||
|
||||
mng_uint32 iGlobalWhitepointx; /* global cHRM fields */
|
||||
mng_uint32 iGlobalWhitepointy;
|
||||
mng_uint32 iGlobalPrimaryredx;
|
||||
mng_uint32 iGlobalPrimaryredy;
|
||||
mng_uint32 iGlobalPrimarygreenx;
|
||||
mng_uint32 iGlobalPrimarygreeny;
|
||||
mng_uint32 iGlobalPrimarybluex;
|
||||
mng_uint32 iGlobalPrimarybluey;
|
||||
|
||||
mng_uint8 iGlobalRendintent; /* global sRGB fields */
|
||||
|
||||
mng_uint32 iGlobalProfilesize; /* global iCCP fields */
|
||||
mng_ptr pGlobalProfile;
|
||||
|
||||
mng_uint16 iGlobalBKGDred; /* global bKGD fields */
|
||||
mng_uint16 iGlobalBKGDgreen;
|
||||
mng_uint16 iGlobalBKGDblue;
|
||||
#endif /* MNG_SUPPORT_DISPLAY */
|
||||
|
||||
} mng_savedata;
|
||||
|
||||
typedef mng_savedata * mng_savedatap;
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * The main libmng data structure * */
|
||||
/* * * */
|
||||
/* * The handle used in all functions points to this structure which * */
|
||||
/* * contains all volatile data necessary to process the network graphic. * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct mng_data_struct {
|
||||
|
||||
mng_uint32 iMagic; /* magic number to validate
|
||||
a given handle */
|
||||
mng_ptr pUserdata; /* application workdata */
|
||||
|
||||
mng_imgtype eSigtype; /* image information */
|
||||
mng_imgtype eImagetype; /* initially zeroed */
|
||||
mng_uint32 iWidth; /* filled after header is processed */
|
||||
mng_uint32 iHeight;
|
||||
mng_uint32 iTicks; /* these only after MHDR */
|
||||
mng_uint32 iLayercount;
|
||||
mng_uint32 iFramecount;
|
||||
mng_uint32 iPlaytime;
|
||||
mng_uint32 iSimplicity;
|
||||
|
||||
mng_uint32 iImagelevel; /* level an image inside a stream */
|
||||
|
||||
mng_uint32 iCanvasstyle; /* layout of the drawing-canvas */
|
||||
mng_uint32 iBkgdstyle; /* layout of the background-canvas */
|
||||
|
||||
mng_int8 iMagnify; /* magnification factor (not used yet) */
|
||||
mng_uint32 iOffsetx; /* x-offset for extremely large image */
|
||||
mng_uint32 iOffsety; /* y-offset for extremely large image */
|
||||
mng_uint32 iCanvaswidth; /* real canvas size */
|
||||
mng_uint32 iCanvasheight; /* must be set by processheader callback */
|
||||
|
||||
mng_uint16 iBGred; /* default background color */
|
||||
mng_uint16 iBGgreen; /* initially "black" */
|
||||
mng_uint16 iBGblue;
|
||||
|
||||
mng_bool bIssRGB; /* indicates sRGB system */
|
||||
|
||||
#ifdef MNG_FULL_CMS /* little CMS variables */
|
||||
mng_cmsprof hProf1; /* image input profile */
|
||||
mng_cmsprof hProf2; /* default output profile */
|
||||
mng_cmsprof hProf3; /* default sRGB profile */
|
||||
mng_cmstrans hTrans; /* current transformation handle */
|
||||
#endif
|
||||
|
||||
mng_float dViewgamma; /* gamma calculation variables */
|
||||
mng_float dDisplaygamma; /* initially set for sRGB conditions */
|
||||
mng_float dDfltimggamma;
|
||||
|
||||
mng_bool bStorechunks; /* switch for storing chunkdata */
|
||||
mng_bool bSectionbreaks; /* indicate NEEDSECTIONWAIT breaks */
|
||||
|
||||
mng_speedtype iSpeed; /* speed-modifier for animations */
|
||||
|
||||
mng_uint32 iMaxwidth; /* maximum canvas size */
|
||||
mng_uint32 iMaxheight; /* initially set to 1024 x 1024 */
|
||||
|
||||
mng_int32 iErrorcode; /* error reporting fields */
|
||||
mng_int8 iSeverity;
|
||||
mng_int32 iErrorx1;
|
||||
mng_int32 iErrorx2;
|
||||
mng_pchar zErrortext;
|
||||
|
||||
mng_memalloc fMemalloc; /* callback pointers */
|
||||
mng_memfree fMemfree; /* initially nulled */
|
||||
mng_openstream fOpenstream;
|
||||
mng_closestream fClosestream;
|
||||
mng_readdata fReaddata;
|
||||
mng_writedata fWritedata;
|
||||
mng_errorproc fErrorproc;
|
||||
mng_traceproc fTraceproc;
|
||||
mng_processheader fProcessheader;
|
||||
mng_processtext fProcesstext;
|
||||
mng_processsave fProcesssave;
|
||||
mng_processseek fProcessseek;
|
||||
mng_getcanvasline fGetcanvasline;
|
||||
mng_getbkgdline fGetbkgdline;
|
||||
mng_getalphaline fGetalphaline;
|
||||
mng_refresh fRefresh;
|
||||
mng_gettickcount fGettickcount;
|
||||
mng_settimer fSettimer;
|
||||
mng_processgamma fProcessgamma;
|
||||
mng_processchroma fProcesschroma;
|
||||
mng_processsrgb fProcesssrgb;
|
||||
mng_processiccp fProcessiccp;
|
||||
mng_processarow fProcessarow;
|
||||
|
||||
#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE)
|
||||
mng_bool bPreDraft48; /* flags ancient style draft */
|
||||
|
||||
mng_chunkid iChunkname; /* read/write-state variables */
|
||||
mng_uint32 iChunkseq;
|
||||
mng_chunkp pFirstchunk; /* double-linked list of */
|
||||
mng_chunkp pLastchunk; /* stored chunk-structures */
|
||||
|
||||
mng_bool bHasheader; /* first header chunk processed */
|
||||
mng_bool bHasMHDR; /* inside a MHDR-MEND sequence */
|
||||
mng_bool bHasIHDR; /* inside a IHDR-IEND sequence */
|
||||
mng_bool bHasBASI; /* inside a BASI-IEND sequence */
|
||||
mng_bool bHasDHDR; /* inside a DHDR-IEND sequence */
|
||||
#ifdef MNG_INCLUDE_JNG
|
||||
mng_bool bHasJHDR; /* inside a JHDR-IEND sequence */
|
||||
mng_bool bHasJSEP; /* passed the JSEP separator */
|
||||
mng_bool bHasJDAT; /* at least 1 JDAT processed */
|
||||
#endif
|
||||
mng_bool bHasPLTE; /* PLTE chunk processed */
|
||||
mng_bool bHasTRNS; /* tRNS chunk processed */
|
||||
mng_bool bHasGAMA; /* gAMA chunk processed */
|
||||
mng_bool bHasCHRM; /* cHRM chunk processed */
|
||||
mng_bool bHasSRGB; /* sRGB chunk processed */
|
||||
mng_bool bHasICCP; /* iCCP chunk processed */
|
||||
mng_bool bHasBKGD; /* bKGD chunk processed */
|
||||
mng_bool bHasIDAT; /* at least 1 IDAT processed */
|
||||
|
||||
mng_bool bHasSAVE; /* SAVE chunk processed */
|
||||
mng_bool bHasBACK; /* BACK chunk processed */
|
||||
mng_bool bHasFRAM; /* FRAM chunk processed */
|
||||
mng_bool bHasTERM; /* TERM chunk processed */
|
||||
mng_bool bHasLOOP; /* at least 1 LOOP open */
|
||||
|
||||
mng_bool bHasglobalPLTE; /* global PLTE chunk processed */
|
||||
mng_bool bHasglobalTRNS; /* global tRNS chunk processed */
|
||||
mng_bool bHasglobalGAMA; /* global gAMA chunk processed */
|
||||
mng_bool bHasglobalCHRM; /* global cHRM chunk processed */
|
||||
mng_bool bHasglobalSRGB; /* global sRGB chunk processed */
|
||||
mng_bool bHasglobalICCP; /* global iCCP chunk processed */
|
||||
mng_bool bHasglobalBKGD; /* global bKGD chunk processed */
|
||||
|
||||
mng_uint32 iDatawidth; /* IHDR/BASI/DHDR fields */
|
||||
mng_uint32 iDataheight; /* valid if inside IHDR-IEND, */
|
||||
mng_uint8 iBitdepth; /* BASI-IEND or DHDR-IEND */
|
||||
mng_uint8 iColortype;
|
||||
mng_uint8 iCompression;
|
||||
mng_uint8 iFilter;
|
||||
mng_uint8 iInterlace;
|
||||
|
||||
mng_uint32 iPLTEcount; /* PLTE fields */
|
||||
|
||||
mng_bool bEMNGMAhack; /* TODO: to be removed in 1.0.0 !!! */
|
||||
|
||||
#ifdef MNG_INCLUDE_JNG
|
||||
mng_uint8 iJHDRcolortype; /* JHDR fields */
|
||||
mng_uint8 iJHDRimgbitdepth; /* valid if inside JHDR-IEND */
|
||||
mng_uint8 iJHDRimgcompression;
|
||||
mng_uint8 iJHDRimginterlace;
|
||||
mng_uint8 iJHDRalphabitdepth;
|
||||
mng_uint8 iJHDRalphacompression;
|
||||
mng_uint8 iJHDRalphafilter;
|
||||
mng_uint8 iJHDRalphainterlace;
|
||||
#endif
|
||||
|
||||
#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */
|
||||
|
||||
#ifdef MNG_SUPPORT_READ
|
||||
mng_bool bReading; /* read processing variables */
|
||||
mng_bool bHavesig;
|
||||
mng_bool bEOF;
|
||||
mng_uint32 iReadbufsize;
|
||||
mng_uint8p pReadbuf;
|
||||
|
||||
mng_uint32 iLargebufsize; /* temp for very large chunks */
|
||||
mng_uint8p pLargebuf;
|
||||
|
||||
mng_uint32 iSuspendtime; /* tickcount at last suspension */
|
||||
mng_bool bSuspended; /* input-reading has been suspended;
|
||||
we're expecting a call to
|
||||
mng_read_resume! */
|
||||
mng_uint8 iSuspendpoint; /* indicates at which point the flow
|
||||
was broken to suspend input-reading */
|
||||
|
||||
mng_bool bSuspensionmode; /* I/O-suspension variables */
|
||||
mng_uint32 iSuspendbufsize;
|
||||
mng_uint8p pSuspendbuf;
|
||||
mng_uint8p pSuspendbufnext;
|
||||
mng_uint32 iSuspendbufleft;
|
||||
mng_uint32 iChunklen; /* chunk length */
|
||||
mng_uint8p pReadbufnext; /* 32K+ suspension-processing */
|
||||
#endif /* MNG_SUPPORT_READ */
|
||||
|
||||
#ifdef MNG_SUPPORT_WRITE
|
||||
mng_bool bCreating; /* create/write processing variables */
|
||||
mng_bool bWriting;
|
||||
mng_chunkid iFirstchunkadded;
|
||||
mng_uint32 iWritebufsize;
|
||||
mng_uint8p pWritebuf;
|
||||
#endif
|
||||
|
||||
#ifdef MNG_SUPPORT_DISPLAY
|
||||
mng_bool bDisplaying; /* display-state variables */
|
||||
mng_uint32 iFrameseq;
|
||||
mng_uint32 iLayerseq;
|
||||
mng_uint32 iFrametime; /* millisecs */
|
||||
|
||||
mng_uint32 iRequestframe; /* go_xxxx variables */
|
||||
mng_uint32 iRequestlayer;
|
||||
mng_uint32 iRequesttime;
|
||||
mng_bool bSearching;
|
||||
|
||||
mng_uint32 iRuntime; /* millisecs since start */
|
||||
mng_uint32 iSynctime; /* tickcount at last framesync */
|
||||
mng_uint32 iStarttime; /* tickcount at start */
|
||||
mng_uint32 iEndtime; /* tickcount at end */
|
||||
mng_bool bRunning; /* animation is active */
|
||||
mng_bool bTimerset; /* the timer has been set;
|
||||
we're expecting a call to
|
||||
mng_display_resume! */
|
||||
mng_uint8 iBreakpoint; /* indicates at which point the
|
||||
flow was broken to run the timer */
|
||||
mng_bool bSectionwait; /* indicates a section break */
|
||||
mng_bool bFreezing; /* indicates app requested a freeze */
|
||||
mng_bool bResetting; /* indicates app requested a reset */
|
||||
mng_bool bNeedrefresh; /* indicates screen-refresh is needed */
|
||||
mng_objectp pCurrentobj; /* current "object" */
|
||||
mng_objectp pCurraniobj; /* current animation object
|
||||
"to be"/"being" processed */
|
||||
mng_objectp pTermaniobj; /* TERM animation object */
|
||||
mng_objectp pObjzero; /* "on-the-fly" image (object = 0) */
|
||||
mng_objectp pLastclone; /* last clone */
|
||||
mng_objectp pStoreobj; /* current store object for row routines */
|
||||
mng_objectp pStorebuf; /* current store object-buffer for row routines */
|
||||
mng_objectp pRetrieveobj; /* current retrieve object for row routines */
|
||||
mng_savedatap pSavedata; /* pointer to saved data (after SAVE) */
|
||||
|
||||
mng_uint32 iUpdateleft; /* update region for refresh */
|
||||
mng_uint32 iUpdateright;
|
||||
mng_uint32 iUpdatetop;
|
||||
mng_uint32 iUpdatebottom;
|
||||
|
||||
mng_int8 iPass; /* current interlacing pass;
|
||||
negative value means no interlace */
|
||||
mng_int32 iRow; /* current row counter */
|
||||
mng_int32 iRowinc; /* row increment for this pass */
|
||||
mng_int32 iCol; /* current starting column */
|
||||
mng_int32 iColinc; /* column increment for this pass */
|
||||
mng_int32 iRowsamples; /* nr. of samples in current workrow */
|
||||
mng_int32 iSamplemul; /* needed to calculate rowsize */
|
||||
mng_int32 iSampleofs; /* from rowsamples */
|
||||
mng_int32 iSamplediv;
|
||||
mng_int32 iRowsize; /* size of actual data in work row */
|
||||
mng_int32 iRowmax; /* maximum size of data in work row */
|
||||
mng_uint8p pWorkrow; /* working row of pixel-data */
|
||||
mng_uint8p pPrevrow; /* previous row of pixel-data */
|
||||
mng_uint8p pRGBArow; /* intermediate row of RGBA8 or RGBA16 data */
|
||||
mng_bool bIsRGBA16; /* indicates intermediate row is RGBA16 */
|
||||
mng_bool bIsOpaque; /* indicates intermediate row is fully opaque */
|
||||
mng_int32 iFilterbpp; /* bpp index for filtering routines */
|
||||
|
||||
mng_int32 iSourcel; /* variables for showing objects */
|
||||
mng_int32 iSourcer;
|
||||
mng_int32 iSourcet;
|
||||
mng_int32 iSourceb;
|
||||
mng_int32 iDestl;
|
||||
mng_int32 iDestr;
|
||||
mng_int32 iDestt;
|
||||
mng_int32 iDestb;
|
||||
|
||||
mng_objectp pFirstimgobj; /* double-linked list of */
|
||||
mng_objectp pLastimgobj; /* image-object structures */
|
||||
mng_objectp pFirstaniobj; /* double-linked list of */
|
||||
mng_objectp pLastaniobj; /* animation-object structures */
|
||||
|
||||
#if defined(MNG_GAMMA_ONLY) || defined(MNG_FULL_CMS)
|
||||
mng_uint8 aGammatab[256]; /* precomputed gamma lookup table */
|
||||
mng_float dLastgamma; /* last gamma used to compute table */
|
||||
#endif
|
||||
|
||||
mng_ptr fDisplayrow; /* internal callback to display an
|
||||
uncompressed/unfiltered/
|
||||
color-corrected row */
|
||||
mng_ptr fRestbkgdrow; /* internal callback for restore-
|
||||
background processing of a row */
|
||||
mng_ptr fCorrectrow; /* internal callback to color-correct an
|
||||
uncompressed/unfiltered row */
|
||||
mng_ptr fRetrieverow; /* internal callback to retrieve an
|
||||
uncompressed/unfiltered row of data */
|
||||
mng_ptr fStorerow; /* internal callback to store an
|
||||
uncompressed/unfiltered row of data */
|
||||
mng_ptr fProcessrow; /* internal callback to process an
|
||||
uncompressed row of data */
|
||||
mng_ptr fInitrowproc; /* internal callback to initialize
|
||||
the row processing */
|
||||
|
||||
mng_uint16 iDEFIobjectid; /* DEFI fields */
|
||||
mng_uint8 iDEFIdonotshow;
|
||||
mng_uint8 iDEFIconcrete;
|
||||
mng_bool bDEFIhasloca;
|
||||
mng_int32 iDEFIlocax;
|
||||
mng_int32 iDEFIlocay;
|
||||
mng_bool bDEFIhasclip;
|
||||
mng_int32 iDEFIclipl;
|
||||
mng_int32 iDEFIclipr;
|
||||
mng_int32 iDEFIclipt;
|
||||
mng_int32 iDEFIclipb;
|
||||
|
||||
mng_uint16 iBACKred; /* BACK fields */
|
||||
mng_uint16 iBACKgreen;
|
||||
mng_uint16 iBACKblue;
|
||||
mng_uint8 iBACKmandatory;
|
||||
mng_uint16 iBACKimageid;
|
||||
mng_uint8 iBACKtile;
|
||||
|
||||
mng_uint8 iFRAMmode; /* FRAM fields (global) */
|
||||
mng_uint32 iFRAMdelay;
|
||||
mng_uint32 iFRAMtimeout;
|
||||
mng_bool bFRAMclipping;
|
||||
mng_int32 iFRAMclipl;
|
||||
mng_int32 iFRAMclipr;
|
||||
mng_int32 iFRAMclipt;
|
||||
mng_int32 iFRAMclipb;
|
||||
|
||||
mng_uint8 iFramemode; /* current subframe variables */
|
||||
mng_uint32 iFramedelay;
|
||||
mng_uint32 iFrametimeout;
|
||||
mng_bool bFrameclipping;
|
||||
mng_int32 iFrameclipl;
|
||||
mng_int32 iFrameclipr;
|
||||
mng_int32 iFrameclipt;
|
||||
mng_int32 iFrameclipb;
|
||||
|
||||
mng_uint32 iNextdelay; /* delay for *after* next image */
|
||||
|
||||
mng_uint8 iSHOWmode; /* SAVE fields */
|
||||
mng_uint16 iSHOWfromid;
|
||||
mng_uint16 iSHOWtoid;
|
||||
mng_uint16 iSHOWnextid;
|
||||
mng_int16 iSHOWskip;
|
||||
|
||||
mng_uint32 iGlobalPLTEcount; /* global PLTE fields */
|
||||
mng_rgbpaltab aGlobalPLTEentries;
|
||||
|
||||
mng_uint32 iGlobalTRNSrawlen; /* global tRNS fields */
|
||||
mng_uint8arr aGlobalTRNSrawdata;
|
||||
|
||||
mng_uint32 iGlobalGamma; /* global gAMA fields */
|
||||
|
||||
mng_uint32 iGlobalWhitepointx; /* global cHRM fields */
|
||||
mng_uint32 iGlobalWhitepointy;
|
||||
mng_uint32 iGlobalPrimaryredx;
|
||||
mng_uint32 iGlobalPrimaryredy;
|
||||
mng_uint32 iGlobalPrimarygreenx;
|
||||
mng_uint32 iGlobalPrimarygreeny;
|
||||
mng_uint32 iGlobalPrimarybluex;
|
||||
mng_uint32 iGlobalPrimarybluey;
|
||||
|
||||
mng_uint8 iGlobalRendintent; /* global sRGB fields */
|
||||
|
||||
mng_uint32 iGlobalProfilesize; /* global iCCP fields */
|
||||
mng_ptr pGlobalProfile;
|
||||
|
||||
mng_uint16 iGlobalBKGDred; /* global bKGD fields */
|
||||
mng_uint16 iGlobalBKGDgreen;
|
||||
mng_uint16 iGlobalBKGDblue;
|
||||
|
||||
mng_ptr pDeltaImage; /* delta-image fields */
|
||||
mng_uint8 iDeltaImagetype;
|
||||
mng_uint8 iDeltatype;
|
||||
mng_uint32 iDeltaBlockwidth;
|
||||
mng_uint32 iDeltaBlockheight;
|
||||
mng_uint32 iDeltaBlockx;
|
||||
mng_uint32 iDeltaBlocky;
|
||||
mng_bool bDeltaimmediate;
|
||||
|
||||
mng_ptr fDeltagetrow; /* internal delta-proc callbacks */
|
||||
mng_ptr fDeltaaddrow;
|
||||
mng_ptr fDeltareplacerow;
|
||||
mng_ptr fDeltaputrow;
|
||||
|
||||
#endif /* MNG_SUPPORT_DISPLAY */
|
||||
|
||||
#ifdef MNG_INCLUDE_ZLIB
|
||||
z_stream sZlib; /* zlib (de)compression variables */
|
||||
|
||||
mng_int32 iZlevel; /* zlib compression parameters */
|
||||
mng_int32 iZmethod;
|
||||
mng_int32 iZwindowbits;
|
||||
mng_int32 iZmemlevel;
|
||||
mng_int32 iZstrategy;
|
||||
|
||||
mng_uint32 iMaxIDAT; /* maximum size of IDAT data */
|
||||
|
||||
mng_bool bInflating; /* indicates "inflate" in progress */
|
||||
mng_bool bDeflating; /* indicates "deflate" in progress */
|
||||
#endif /* MNG_INCLUDE_ZLIB */
|
||||
|
||||
#ifdef MNG_INCLUDE_JNG
|
||||
mngjpeg_dctmethod eJPEGdctmethod; /* IJG compression variables */
|
||||
mng_int32 iJPEGquality;
|
||||
mng_int32 iJPEGsmoothing;
|
||||
mng_bool bJPEGcompressprogr;
|
||||
mng_bool bJPEGcompressopt;
|
||||
|
||||
mng_uint32 iMaxJDAT; /* maximum size of JDAT data */
|
||||
|
||||
mngjpeg_compp pJPEGcinfo; /* compression structure */
|
||||
mngjpeg_errorp pJPEGcerr; /* error-manager compress */
|
||||
mngjpeg_decompp pJPEGdinfo; /* decompression structure */
|
||||
mngjpeg_errorp pJPEGderr; /* error-manager decompress */
|
||||
mngjpeg_sourcep pJPEGdsrc; /* source-manager decompress */
|
||||
|
||||
mng_uint8p pJPEGbuf; /* buffer for JPEG (de)compression */
|
||||
mng_uint32 iJPEGbufmax; /* allocated space for buffer */
|
||||
mng_uint8p pJPEGcurrent; /* current pointer into buffer */
|
||||
mng_uint32 iJPEGbufremain; /* remaining bytes in buffer */
|
||||
mng_uint32 iJPEGtoskip; /* bytes to skip on next input-block */
|
||||
|
||||
mng_uint8p pJPEGrow; /* buffer for a JPEG row of samples */
|
||||
mng_uint32 iJPEGrowlen;
|
||||
|
||||
mng_bool bJPEGcompress; /* indicates "compress" initialized */
|
||||
|
||||
mng_bool bJPEGdecompress; /* indicates "decompress" ininitialized */
|
||||
mng_bool bJPEGhasheader; /* indicates "readheader" succeeded */
|
||||
mng_bool bJPEGdecostarted; /* indicates "decompress" started */
|
||||
mng_bool bJPEGscanstarted; /* indicates "first scan" started */
|
||||
mng_bool bJPEGprogressive; /* indicates a progressive image */
|
||||
|
||||
mng_ptr fStorerow2; /* internal callback to store an
|
||||
uncompressed/unfiltered row of JPEG-data */
|
||||
mng_uint32 iJPEGrow; /* row-number for current JPEG row */
|
||||
mng_uint32 iJPEGalpharow; /* nr. of rows filled with alpha */
|
||||
mng_uint32 iJPEGrgbrow; /* nr. of rows filled with 'color'-info */
|
||||
mng_uint32 iJPEGdisprow; /* nr. of rows already displayed "on-the-fly" */
|
||||
|
||||
#if defined(MNG_USE_SETJMP) && defined (MNG_INCLUDE_IJG6B)
|
||||
jmp_buf sErrorbuf; /* setjmp/longjmp buffer (error-recovery) */
|
||||
#endif
|
||||
|
||||
#endif /* MNG_INCLUDE_JNG */
|
||||
|
||||
mng_uint32 aCRCtable [256]; /* CRC prefab table */
|
||||
mng_bool bCRCcomputed; /* "has been build" indicator */
|
||||
|
||||
} mng_data;
|
||||
|
||||
typedef mng_data * mng_datap;
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * Internal Callback-Function prototypes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef mng_retcode(*mng_displayrow) (mng_datap pData);
|
||||
typedef mng_retcode(*mng_restbkgdrow) (mng_datap pData);
|
||||
typedef mng_retcode(*mng_correctrow) (mng_datap pData);
|
||||
typedef mng_retcode(*mng_retrieverow) (mng_datap pData);
|
||||
typedef mng_retcode(*mng_storerow) (mng_datap pData);
|
||||
typedef mng_retcode(*mng_processrow) (mng_datap pData);
|
||||
typedef mng_retcode(*mng_initrowproc) (mng_datap pData);
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * 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_int32 mng_get_int32 (mng_uint8p pBuf);
|
||||
mng_uint16 mng_get_uint16 (mng_uint8p pBuf);
|
||||
void mng_put_uint32 (mng_uint8p pBuf,
|
||||
mng_uint32 i);
|
||||
void mng_put_int32 (mng_uint8p pBuf,
|
||||
mng_int32 i);
|
||||
void mng_put_uint16 (mng_uint8p pBuf,
|
||||
mng_uint16 i);
|
||||
#else /* MNG_BIGENDIAN_SUPPORTED */
|
||||
#define mng_get_uint32(P) *(mng_uint32p)(P)
|
||||
#define mng_get_int32(P) *(mng_int32p)(P)
|
||||
#define mng_get_uint16(P) *(mng_uint16p)(P)
|
||||
#define mng_put_uint32(P,I) *(mng_uint32p)(P) = (I)
|
||||
#define mng_put_int32(P,I) *(mng_int32p)(P) = (I)
|
||||
#define mng_put_uint16(P,I) *(mng_uint16p)(P) = (I)
|
||||
#endif /* MNG_BIGENDIAN_SUPPORTED */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * Some handy(?) macro definitions * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#define MAX_COORD(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define MIN_COORD(a, b) (((a) < (b)) ? (a) : (b))
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* _libmng_data_h_ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,172 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_display.h copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : Display management (definition) * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : Definition of the display managament routines * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * * */
|
||||
/* * 0.5.2 - 05/20/2000 - G.Juyn * */
|
||||
/* * - added JNG support stuff * */
|
||||
/* * * */
|
||||
/* * 0.5.3 - 06/16/2000 - G.Juyn * */
|
||||
/* * - changed progressive-display processing * */
|
||||
/* * 0.5.3 - 06/22/2000 - G.Juyn * */
|
||||
/* * - added support for delta-image processing * */
|
||||
/* * - added support for PPLT chunk processing * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * 0.9.3 - 08/07/2000 - G.Juyn * */
|
||||
/* * - B111300 - fixup for improved portability * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* force ANSI-C */
|
||||
#endif
|
||||
|
||||
#ifndef _libmng_display_h_
|
||||
#define _libmng_display_h_
|
||||
|
||||
#include "libmng.h"
|
||||
#include "libmng_data.h"
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode display_progressive_refresh (mng_datap pData,
|
||||
mng_uint32 iInterval);
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode display_image (mng_datap pData,
|
||||
mng_imagep pImage,
|
||||
mng_bool bLayeradvanced);
|
||||
|
||||
mng_retcode execute_delta_image (mng_datap pData,
|
||||
mng_imagep pTarget,
|
||||
mng_imagep pDelta);
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode process_display (mng_datap pData);
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode process_display_ihdr (mng_datap pData);
|
||||
|
||||
mng_retcode process_display_idat (mng_datap pData,
|
||||
mng_uint32 iRawlen,
|
||||
mng_uint8p pRawdata);
|
||||
|
||||
mng_retcode process_display_iend (mng_datap pData);
|
||||
mng_retcode process_display_mend (mng_datap pData);
|
||||
mng_retcode process_display_defi (mng_datap pData);
|
||||
|
||||
mng_retcode process_display_basi (mng_datap pData,
|
||||
mng_uint16 iRed,
|
||||
mng_uint16 iGreen,
|
||||
mng_uint16 iBlue,
|
||||
mng_bool bHasalpha,
|
||||
mng_uint16 iAlpha,
|
||||
mng_uint8 iViewable);
|
||||
|
||||
mng_retcode process_display_clon (mng_datap pData,
|
||||
mng_uint16 iSourceid,
|
||||
mng_uint16 iCloneid,
|
||||
mng_uint8 iClonetype,
|
||||
mng_bool bHasdonotshow,
|
||||
mng_uint8 iDonotshow,
|
||||
mng_uint8 iConcrete,
|
||||
mng_bool bHasloca,
|
||||
mng_uint8 iLocationtype,
|
||||
mng_int32 iLocationx,
|
||||
mng_int32 iLocationy);
|
||||
mng_retcode process_display_clon2 (mng_datap pData);
|
||||
|
||||
mng_retcode process_display_disc (mng_datap pData,
|
||||
mng_uint32 iCount,
|
||||
mng_uint16p pIds);
|
||||
|
||||
mng_retcode process_display_fram (mng_datap pData,
|
||||
mng_uint8 iFramemode,
|
||||
mng_uint8 iChangedelay,
|
||||
mng_uint32 iDelay,
|
||||
mng_uint8 iChangetimeout,
|
||||
mng_uint32 iTimeout,
|
||||
mng_uint8 iChangeclipping,
|
||||
mng_uint8 iCliptype,
|
||||
mng_int32 iClipl,
|
||||
mng_int32 iClipr,
|
||||
mng_int32 iClipt,
|
||||
mng_int32 iClipb);
|
||||
mng_retcode process_display_fram2 (mng_datap pData);
|
||||
|
||||
mng_retcode process_display_move (mng_datap pData,
|
||||
mng_uint16 iFromid,
|
||||
mng_uint16 iToid,
|
||||
mng_uint8 iMovetype,
|
||||
mng_int32 iMovex,
|
||||
mng_int32 iMovey);
|
||||
|
||||
mng_retcode process_display_clip (mng_datap pData,
|
||||
mng_uint16 iFromid,
|
||||
mng_uint16 iToid,
|
||||
mng_uint8 iCliptype,
|
||||
mng_int32 iClipl,
|
||||
mng_int32 iClipr,
|
||||
mng_int32 iClipt,
|
||||
mng_int32 iClipb);
|
||||
|
||||
mng_retcode process_display_show (mng_datap pData);
|
||||
mng_retcode process_display_save (mng_datap pData);
|
||||
mng_retcode process_display_seek (mng_datap pData);
|
||||
mng_retcode process_display_jhdr (mng_datap pData);
|
||||
|
||||
mng_retcode process_display_jdat (mng_datap pData,
|
||||
mng_uint32 iRawlen,
|
||||
mng_uint8p pRawdata);
|
||||
|
||||
mng_retcode process_display_dhdr (mng_datap pData,
|
||||
mng_uint16 iObjectid,
|
||||
mng_uint8 iImagetype,
|
||||
mng_uint8 iDeltatype,
|
||||
mng_uint32 iBlockwidth,
|
||||
mng_uint32 iBlockheight,
|
||||
mng_uint32 iBlockx,
|
||||
mng_uint32 iBlocky);
|
||||
|
||||
mng_retcode process_display_prom (mng_datap pData,
|
||||
mng_uint8 iBitdepth,
|
||||
mng_uint8 iColortype,
|
||||
mng_uint8 iFilltype);
|
||||
|
||||
mng_retcode process_display_ipng (mng_datap pData);
|
||||
mng_retcode process_display_ijng (mng_datap pData);
|
||||
|
||||
mng_retcode process_display_pplt (mng_datap pData,
|
||||
mng_uint8 iType,
|
||||
mng_uint32 iCount,
|
||||
mng_palette8ep paIndexentries,
|
||||
mng_uint8p paAlphaentries,
|
||||
mng_uint8p paUsedentries);
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* _libmng_display_h_ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
|
@ -0,0 +1,54 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_dither.c copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : Dithering routines (implementation) * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : implementation of the dithering routines * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libmng.h"
|
||||
#include "libmng_data.h"
|
||||
#include "libmng_error.h"
|
||||
#include "libmng_trace.h"
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
#include "libmng_dither.h"
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* force ANSI-C */
|
||||
#endif
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode dither_a_row (mng_datap pData,
|
||||
mng_uint8p pRow)
|
||||
{
|
||||
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_dither.h copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : Dithering routines (definition) * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : Definition of the dithering routines * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* force ANSI-C */
|
||||
#endif
|
||||
|
||||
#ifndef _libmng_dither_h_
|
||||
#define _libmng_dither_h_
|
||||
|
||||
#include "libmng.h"
|
||||
#include "libmng_data.h"
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode dither_a_row (mng_datap pData,
|
||||
mng_uint8p pRow);
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* _libmng_dither_h_ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
|
@ -0,0 +1,251 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_error.c copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : Error routines (implementation) * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : implementation of the general error handling routines * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * * */
|
||||
/* * 0.5.2 - 05/23/2000 - G.Juyn * */
|
||||
/* * - added error telltaling * */
|
||||
/* * 0.5.2 - 05/30/2000 - G.Juyn * */
|
||||
/* * - added errorstrings for delta-image processing * */
|
||||
/* * 0.5.2 - 05/31/2000 - G.Juyn * */
|
||||
/* * - fixed up punctuation (contributed by Tim Rowley) * */
|
||||
/* * 0.5.2 - 06/06/2000 - G.Juyn * */
|
||||
/* * - added errorstring for delayed buffer-processing * */
|
||||
/* * * */
|
||||
/* * 0.9.1 - 07/06/2000 - G.Juyn * */
|
||||
/* * - added MNG_NEEDTIMERWAIT errorstring * */
|
||||
/* * 0.9.1 - 07/15/2000 - G.Juyn * */
|
||||
/* * - added NEEDSECTIONWAIT errorstring * */
|
||||
/* * - added macro + routine to set returncode without * */
|
||||
/* * calling error callback * */
|
||||
/* * 0.9.1 - 07/19/2000 - G.Juyn * */
|
||||
/* * - added errorstring for updatemngheader if not a MNG * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#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
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_ERROR_STRINGS
|
||||
mng_error_entry error_table [] =
|
||||
{
|
||||
{MNG_NOERROR, "No error"},
|
||||
{MNG_OUTOFMEMORY, "Out of memory"},
|
||||
{MNG_INVALIDHANDLE, "The handle is invalid"},
|
||||
{MNG_NOCALLBACK, "A required callback is not defined"},
|
||||
{MNG_UNEXPECTEDEOF, "Encountered unexpected end-of-file"},
|
||||
{MNG_ZLIBERROR, "zlib encountered an error"},
|
||||
{MNG_JPEGERROR, "ijgsrc6b encountered an error"},
|
||||
{MNG_LCMSERROR, "lcms encountered an error"},
|
||||
{MNG_NOOUTPUTPROFILE, "No output-profile defined for CMS"},
|
||||
{MNG_NOSRGBPROFILE, "No sRGB-profile defined for CMS"},
|
||||
{MNG_BUFOVERFLOW, "Internal buffer-overflow"},
|
||||
{MNG_FUNCTIONINVALID, "Function is invalid at this point"},
|
||||
{MNG_OUTPUTERROR, "Writing was unsuccessful; disk full?"},
|
||||
{MNG_JPEGBUFTOOSMALL, "Internal buffer for JPEG processing too small"},
|
||||
{MNG_NEEDMOREDATA, "Reading suspended; waiting for I/O to catch up"},
|
||||
{MNG_NEEDTIMERWAIT, "Timer suspension; normal animation delay"},
|
||||
{MNG_NEEDSECTIONWAIT, "SEEK suspension; application decides"},
|
||||
|
||||
{MNG_APPIOERROR, "Application signalled I/O error"},
|
||||
{MNG_APPTIMERERROR, "Application signalled timing error"},
|
||||
{MNG_APPCMSERROR, "Application signalled CMS error"},
|
||||
{MNG_APPMISCERROR, "Application signalled an error"},
|
||||
{MNG_APPTRACEABORT, "Application signalled error during trace-callback"},
|
||||
|
||||
{MNG_INTERNALERROR, "Internal error in libmng"},
|
||||
|
||||
{MNG_INVALIDSIG, "The signature is invalid"},
|
||||
{MNG_INVALIDCRC, "The CRC for this chunk is invalid"},
|
||||
{MNG_INVALIDLENGTH, "Chunk-length is invalid"},
|
||||
{MNG_SEQUENCEERROR, "Chunk out of sequence"},
|
||||
{MNG_CHUNKNOTALLOWED, "Chunk not allowed at this point"},
|
||||
{MNG_MULTIPLEERROR, "Chunk cannot occur multiple times"},
|
||||
{MNG_PLTEMISSING, "Missing PLTE chunk"},
|
||||
{MNG_IDATMISSING, "Missing IDAT chunk(s)"},
|
||||
{MNG_CANNOTBEEMPTY, "Chunk cannot be empty"},
|
||||
{MNG_GLOBALLENGTHERR, "Global data length invalid"},
|
||||
{MNG_INVALIDBITDEPTH, "The bit_depth is invalid"},
|
||||
{MNG_INVALIDCOLORTYPE, "The color_type is invalid"},
|
||||
{MNG_INVALIDCOMPRESS, "The compression_method is invalid"},
|
||||
{MNG_INVALIDFILTER, "The filter_method or filter_type is invalid"},
|
||||
{MNG_INVALIDINTERLACE, "The interlace_method is invalid"},
|
||||
{MNG_NOTENOUGHIDAT, "There is not enough data in the IDAT chunk(s)"},
|
||||
{MNG_PLTEINDEXERROR, "Palette-index out of bounds"},
|
||||
{MNG_NULLNOTFOUND, "NULL separator not found"},
|
||||
{MNG_KEYWORDNULL, "Keyword cannot be zero-length"},
|
||||
{MNG_OBJECTUNKNOWN, "Object does not exist"},
|
||||
{MNG_OBJECTEXISTS, "Object already exists"},
|
||||
{MNG_TOOMUCHIDAT, "Too much data in IDAT chunk(s)"},
|
||||
{MNG_INVSAMPLEDEPTH, "The sample_depth is invalid"},
|
||||
{MNG_INVOFFSETSIZE, "The offset_type is invalid"},
|
||||
{MNG_INVENTRYTYPE, "The entry_type is invalid"},
|
||||
{MNG_ENDWITHNULL, "Chunk must not end with NULL byte"},
|
||||
{MNG_INVIMAGETYPE, "The image_type is invalid"},
|
||||
{MNG_INVDELTATYPE, "The delta_type is invalid"},
|
||||
{MNG_INVALIDINDEX, "Index-value out of bounds"},
|
||||
{MNG_TOOMUCHJDAT, "Too much data in JDAT chunk(s)"},
|
||||
{MNG_JPEGPARMSERR, "JHDR parameters & JFIF-data do not match"},
|
||||
{MNG_INVFILLMETHOD, "The fill_method is invalid"},
|
||||
{MNG_OBJNOTCONCRETE, "Target object for DHDR must be concrete"},
|
||||
{MNG_TARGETNOALPHA, "Target object must have alpha-channel"},
|
||||
|
||||
{MNG_INVALIDCNVSTYLE, "Canvas_style is invalid"},
|
||||
{MNG_WRONGCHUNK, "Attempt to access the wrong chunk"},
|
||||
{MNG_INVALIDENTRYIX, "Attempt to access an non-existing entry"},
|
||||
{MNG_NOHEADER, "No valid header-chunk"},
|
||||
{MNG_NOCORRCHUNK, "Parent chunk not found"},
|
||||
{MNG_NOMHDR, "No MNG header (MHDR) found"},
|
||||
|
||||
{MNG_IMAGETOOLARGE, "Image is larger than defined maximum"},
|
||||
{MNG_NOTANANIMATION, "Image is not an animation"},
|
||||
{MNG_FRAMENRTOOHIGH, "Framenr out of bounds"},
|
||||
{MNG_LAYERNRTOOHIGH, "Layernr out of bounds"},
|
||||
{MNG_PLAYTIMETOOHIGH, "Playtime out of bounds"},
|
||||
{MNG_FNNOTIMPLEMENTED, "Function not yet implemented"},
|
||||
{MNG_IMAGEFROZEN, "Image is frozen"},
|
||||
|
||||
{MNG_LCMS_NOHANDLE, "Handle could not be initialized"},
|
||||
{MNG_LCMS_NOMEM, "No memory for gamma-table(s)"},
|
||||
{MNG_LCMS_NOTRANS, "Transformation could not be initialized"},
|
||||
};
|
||||
#endif /* MNG_INCLUDE_ERROR_STRINGS */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_bool mng_store_error (mng_datap pData,
|
||||
mng_retcode iError,
|
||||
mng_retcode iExtra1,
|
||||
mng_retcode iExtra2)
|
||||
{
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACEB (pData, MNG_FN_STORE_ERROR, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
if (pData != 0)
|
||||
{
|
||||
pData->iErrorcode = iError; /* save also for getlasterror */
|
||||
pData->iErrorx1 = iExtra1;
|
||||
pData->iErrorx2 = iExtra2;
|
||||
|
||||
#ifdef MNG_INCLUDE_ERROR_STRINGS
|
||||
{ /* binary search variables */
|
||||
mng_int32 iTop, iLower, iUpper, iMiddle;
|
||||
mng_error_entryp pEntry; /* pointer to found entry */
|
||||
/* determine max index of table */
|
||||
iTop = (sizeof (error_table) / sizeof (error_table [0])) - 1;
|
||||
|
||||
iLower = 0; /* initialize binary search */
|
||||
iMiddle = iTop >> 1; /* start in the middle */
|
||||
iUpper = iTop;
|
||||
pEntry = 0; /* no goods yet! */
|
||||
|
||||
do /* the binary search itself */
|
||||
{
|
||||
if (error_table [iMiddle].iError < iError)
|
||||
iLower = iMiddle + 1;
|
||||
else if (error_table [iMiddle].iError > iError)
|
||||
iUpper = iMiddle - 1;
|
||||
else
|
||||
{
|
||||
pEntry = &error_table [iMiddle];
|
||||
break;
|
||||
}
|
||||
|
||||
iMiddle = (iLower + iUpper) >> 1;
|
||||
}
|
||||
while (iLower <= iUpper);
|
||||
|
||||
if (pEntry) /* found it ? */
|
||||
pData->zErrortext = pEntry->zErrortext;
|
||||
else
|
||||
pData->zErrortext = "Unknown error";
|
||||
}
|
||||
#else
|
||||
pData->zErrortext = 0;
|
||||
#endif /* mng_error_telltale */
|
||||
|
||||
if (iError == 0) /* no error is not severe ! */
|
||||
{
|
||||
pData->iSeverity = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (iError&0x3C00) /* determine the severity */
|
||||
{
|
||||
case 0x0800 : { pData->iSeverity = 5; break; }
|
||||
case 0x1000 : { pData->iSeverity = 2; break; }
|
||||
case 0x2000 : { pData->iSeverity = 1; break; }
|
||||
default : { pData->iSeverity = 9; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACEB (pData, MNG_FN_STORE_ERROR, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_TRUE;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_bool mng_process_error (mng_datap pData,
|
||||
mng_retcode iError,
|
||||
mng_retcode iExtra1,
|
||||
mng_retcode iExtra2)
|
||||
{
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACEB (pData, MNG_FN_PROCESS_ERROR, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
mng_store_error (pData, iError, iExtra1, iExtra2);
|
||||
|
||||
if (pData != 0)
|
||||
{
|
||||
if (pData->fErrorproc) /* callback defined ? */
|
||||
return pData->fErrorproc (((mng_handle)pData), iError, pData->iSeverity,
|
||||
pData->iChunkname, pData->iChunkseq,
|
||||
pData->iErrorx1, pData->iErrorx2, pData->zErrortext);
|
||||
}
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACEB (pData, MNG_FN_PROCESS_ERROR, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_FALSE; /* automatic failure */
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_error.h copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : Error functions (definition) * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : Definition of the generic error-codes and functions * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/06/2000 - G.Juyn * */
|
||||
/* * - added some errorcodes * */
|
||||
/* * 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - added some errorcodes * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * 0.5.1 - 05/11/2000 - G.Juyn * */
|
||||
/* * - added application errorcodes (used with callbacks) * */
|
||||
/* * - moved chunk-access errorcodes to severity 5 * */
|
||||
/* * * */
|
||||
/* * 0.5.2 - 05/20/2000 - G.Juyn * */
|
||||
/* * - added JNG errorcodes * */
|
||||
/* * 0.5.2 - 05/23/2000 - G.Juyn * */
|
||||
/* * - added error tell-tale definition * */
|
||||
/* * 0.5.2 - 05/30/2000 - G.Juyn * */
|
||||
/* * - added errorcodes for delta-image processing * */
|
||||
/* * 0.5.2 - 06/06/2000 - G.Juyn * */
|
||||
/* * - added errorcode for delayed buffer-processing * */
|
||||
/* * - moved errorcodes to "libmng.h" * */
|
||||
/* * * */
|
||||
/* * 0.9.1 - 07/15/2000 - G.Juyn * */
|
||||
/* * - added macro + routine to set returncode without * */
|
||||
/* * calling error callback * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* force ANSI-C */
|
||||
#endif
|
||||
|
||||
#ifndef _libmng_error_h_
|
||||
#define _libmng_error_h_
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * Default error routines * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_bool mng_store_error (mng_datap pData,
|
||||
mng_retcode iError,
|
||||
mng_retcode iExtra1,
|
||||
mng_retcode iExtra2);
|
||||
|
||||
mng_bool mng_process_error (mng_datap pData,
|
||||
mng_retcode iError,
|
||||
mng_retcode iExtra1,
|
||||
mng_retcode iExtra2);
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * Error handling macros * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#define MNG_ERROR(D,C) { mng_process_error (D, C, 0, 0); return C; }
|
||||
#define MNG_ERRORZ(D,Z) { mng_process_error (D, MNG_ZLIBERROR, Z, 0); return MNG_ZLIBERROR; }
|
||||
#define MNG_ERRORJ(D,J) { mng_process_error (D, MNG_JPEGERROR, J, 0); return MNG_JPEGERROR; }
|
||||
#define MNG_ERRORL(D,L) { mng_process_error (D, MNG_LCMSERROR, L, 0); return MNG_LCMSERROR; }
|
||||
|
||||
#define MNG_RETURN(D,C) { mng_store_error (D, C, 0, 0); return C; }
|
||||
|
||||
#define MNG_WARNING(D,C) { if (!mng_process_error (D, C, 0, 0)) return C; }
|
||||
|
||||
#define MNG_VALIDHANDLE(H) { if ((H == 0) || (((mng_datap)H)->iMagic != MNG_MAGIC)) \
|
||||
return MNG_INVALIDHANDLE; }
|
||||
#define MNG_VALIDHANDLEX(H) { if ((H == 0) || (((mng_datap)H)->iMagic != MNG_MAGIC)) \
|
||||
return 0; }
|
||||
#define MNG_VALIDCB(D,C) { if (!((mng_datap)D)->C) \
|
||||
MNG_ERROR (((mng_datap)D), MNG_NOCALLBACK) }
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * Error string-table entry * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct {
|
||||
mng_retcode iError;
|
||||
mng_pchar zErrortext;
|
||||
} mng_error_entry;
|
||||
typedef mng_error_entry * mng_error_entryp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* _libmng_error_h_ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
|
@ -0,0 +1,255 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_filter.c copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : Filtering routines (implementation) * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : implementation of the filtering routines * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * 0.5.1 - 05/12/2000 - G.Juyn * */
|
||||
/* * - changed trace to macro for callback error-reporting * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libmng.h"
|
||||
#include "libmng_data.h"
|
||||
#include "libmng_error.h"
|
||||
#include "libmng_trace.h"
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
#include "libmng_filter.h"
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* force ANSI-C */
|
||||
#endif
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_FILTERS
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode filter_a_row (mng_datap pData)
|
||||
{
|
||||
mng_retcode iRetcode;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_FILTER_A_ROW, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
switch (pData->pWorkrow[0])
|
||||
{
|
||||
case 1 : {
|
||||
iRetcode = filter_sub (pData);
|
||||
break;
|
||||
}
|
||||
case 2 : {
|
||||
iRetcode = filter_up (pData);
|
||||
break;
|
||||
}
|
||||
case 3 : {
|
||||
iRetcode = filter_average (pData);
|
||||
break;
|
||||
}
|
||||
case 4 : {
|
||||
iRetcode = filter_paeth (pData);
|
||||
break;
|
||||
}
|
||||
|
||||
default : iRetcode = MNG_INVALIDFILTER;
|
||||
}
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_FILTER_A_ROW, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return iRetcode;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode filter_sub (mng_datap pData)
|
||||
{
|
||||
mng_uint32 iBpp;
|
||||
mng_uint8p pRawx;
|
||||
mng_uint8p pRawx_prev;
|
||||
mng_int32 iX;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_FILTER_SUB, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
iBpp = pData->iFilterbpp;
|
||||
pRawx = pData->pWorkrow + 1 + iBpp;
|
||||
pRawx_prev = pData->pWorkrow + 1;
|
||||
|
||||
for (iX = iBpp; iX < pData->iRowsize; iX++)
|
||||
{
|
||||
pRawx [0] = (mng_uint8)(pRawx [0] + pRawx_prev [0]);
|
||||
pRawx++;
|
||||
pRawx_prev++;
|
||||
}
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_FILTER_SUB, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode filter_up (mng_datap pData)
|
||||
{
|
||||
mng_uint8p pRawx;
|
||||
mng_uint8p pPriorx;
|
||||
mng_int32 iX;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_FILTER_UP, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
pRawx = pData->pWorkrow + 1;
|
||||
pPriorx = pData->pPrevrow + 1;
|
||||
|
||||
for (iX = 0; iX < pData->iRowsize; iX++)
|
||||
{
|
||||
pRawx [0] = (mng_uint8)(pRawx [0] + pPriorx [0]);
|
||||
pRawx++;
|
||||
pPriorx++;
|
||||
}
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_FILTER_UP, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode filter_average (mng_datap pData)
|
||||
{
|
||||
mng_int32 iBpp;
|
||||
mng_uint8p pRawx;
|
||||
mng_uint8p pRawx_prev;
|
||||
mng_uint8p pPriorx;
|
||||
mng_int32 iX;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_FILTER_AVERAGE, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
iBpp = pData->iFilterbpp;
|
||||
pRawx = pData->pWorkrow + 1;
|
||||
pPriorx = pData->pPrevrow + 1;
|
||||
pRawx_prev = pData->pWorkrow + 1;
|
||||
|
||||
for (iX = 0; iX < iBpp; iX++)
|
||||
{
|
||||
pRawx [0] = (mng_uint8)(pRawx [0] + (pPriorx [0] >> 1));
|
||||
pRawx++;
|
||||
pPriorx++;
|
||||
}
|
||||
|
||||
for (iX = iBpp; iX < pData->iRowsize; iX++)
|
||||
{
|
||||
pRawx [0] = (mng_uint8)(pRawx [0] + ((pRawx_prev [0] + pPriorx [0]) >> 1));
|
||||
pRawx++;
|
||||
pPriorx++;
|
||||
pRawx_prev++;
|
||||
}
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_FILTER_AVERAGE, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode filter_paeth (mng_datap pData)
|
||||
{
|
||||
mng_int32 iBpp;
|
||||
mng_uint8p pRawx;
|
||||
mng_uint8p pRawx_prev;
|
||||
mng_uint8p pPriorx;
|
||||
mng_uint8p pPriorx_prev;
|
||||
mng_int32 iX;
|
||||
mng_uint32 iA, iB, iC;
|
||||
mng_uint32 iP;
|
||||
mng_uint32 iPa, iPb, iPc;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_FILTER_PAETH, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
iBpp = pData->iFilterbpp;
|
||||
pRawx = pData->pWorkrow + 1;
|
||||
pPriorx = pData->pPrevrow + 1;
|
||||
pRawx_prev = pData->pWorkrow + 1;
|
||||
pPriorx_prev = pData->pPrevrow + 1;
|
||||
|
||||
for (iX = 0; iX < iBpp; iX++)
|
||||
{
|
||||
pRawx [0] = (mng_uint8)(pRawx [0] + pPriorx [0]);
|
||||
|
||||
pRawx++;
|
||||
pPriorx++;
|
||||
}
|
||||
|
||||
for (iX = iBpp; iX < pData->iRowsize; iX++)
|
||||
{
|
||||
iA = (mng_uint32)pRawx_prev [0];
|
||||
iB = (mng_uint32)pPriorx [0];
|
||||
iC = (mng_uint32)pPriorx_prev [0];
|
||||
iP = iA + iB - iC;
|
||||
iPa = abs (iP - iA);
|
||||
iPb = abs (iP - iB);
|
||||
iPc = abs (iP - iC);
|
||||
|
||||
if ((iPa <= iPb) && (iPa <= iPc))
|
||||
pRawx [0] = (mng_uint8)(pRawx [0] + iA);
|
||||
else
|
||||
if (iPb <= iPc)
|
||||
pRawx [0] = (mng_uint8)(pRawx [0] + iB);
|
||||
else
|
||||
pRawx [0] = (mng_uint8)(pRawx [0] + iC);
|
||||
|
||||
pRawx++;
|
||||
pPriorx++;
|
||||
pRawx_prev++;
|
||||
pPriorx_prev++;
|
||||
}
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_FILTER_PAETH, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* MNG_INCLUDE_FILTERS */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_filter.h copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : Filtering routines (definition) * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : Definition of the filtering routines * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* force ANSI-C */
|
||||
#endif
|
||||
|
||||
#ifndef _libmng_filter_h_
|
||||
#define _libmng_filter_h_
|
||||
|
||||
#include "libmng.h"
|
||||
#include "libmng_data.h"
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode filter_a_row (mng_datap pData);
|
||||
|
||||
mng_retcode filter_sub (mng_datap pData);
|
||||
mng_retcode filter_up (mng_datap pData);
|
||||
mng_retcode filter_average (mng_datap pData);
|
||||
mng_retcode filter_paeth (mng_datap pData);
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* _libmng_filter_h_ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,611 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_jpeg.c copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : JPEG library interface (implementation) * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : implementation of the JPEG library interface * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * * */
|
||||
/* * 0.5.2 - 05/22/2000 - G.Juyn * */
|
||||
/* * - implemented all the JNG routines * */
|
||||
/* * * */
|
||||
/* * 0.5.3 - 06/17/2000 - G.Juyn * */
|
||||
/* * - added tracing of JPEG calls * */
|
||||
/* * 0.5.3 - 06/24/2000 - G.Juyn * */
|
||||
/* * - fixed inclusion of IJG read/write code * */
|
||||
/* * 0.5.3 - 06/29/2000 - G.Juyn * */
|
||||
/* * - fixed some 64-bit warnings * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#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_pixels.h"
|
||||
#include "libmng_jpeg.h"
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* force ANSI-C */
|
||||
#endif
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_JNG
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * Local IJG callback routines (source-manager & error-manager) * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_IJG6B
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_JNG_READ
|
||||
void mng_init_source (j_decompress_ptr cinfo)
|
||||
{
|
||||
return; /* nothing needed */
|
||||
}
|
||||
#endif /* MNG_INCLUDE_JNG_READ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_JNG_READ
|
||||
boolean mng_fill_input_buffer (j_decompress_ptr cinfo)
|
||||
{
|
||||
return FALSE; /* force IJG routine to return to caller */
|
||||
}
|
||||
#endif /* MNG_INCLUDE_JNG_READ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_JNG_READ
|
||||
void mng_skip_input_data (j_decompress_ptr cinfo, long num_bytes)
|
||||
{
|
||||
if (num_bytes > 0) /* ignore fony calls */
|
||||
{ /* address my generic structure */
|
||||
mng_datap pData = (mng_datap)cinfo->client_data;
|
||||
/* address source manager */
|
||||
mngjpeg_sourcep pSrc = pData->pJPEGdinfo->src;
|
||||
/* problem scenario ? */
|
||||
if (pSrc->bytes_in_buffer < (size_t)num_bytes)
|
||||
{ /* tell the boss we need to skip some data! */
|
||||
pData->iJPEGtoskip = (mng_uint32)((size_t)num_bytes - pSrc->bytes_in_buffer);
|
||||
|
||||
pSrc->bytes_in_buffer = 0; /* let the JPEG lib suspend */
|
||||
pSrc->next_input_byte = MNG_NULL;
|
||||
}
|
||||
else
|
||||
{ /* simply advance in the buffer */
|
||||
pSrc->bytes_in_buffer -= num_bytes;
|
||||
pSrc->next_input_byte += num_bytes;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
#endif /* MNG_INCLUDE_JNG_READ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_JNG_READ
|
||||
void mng_term_source (j_decompress_ptr cinfo)
|
||||
{
|
||||
return; /* nothing needed */
|
||||
}
|
||||
#endif /* MNG_INCLUDE_JNG_READ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_USE_SETJMP
|
||||
void mng_error_exit (j_common_ptr cinfo)
|
||||
{ /* address my generic structure */
|
||||
mng_datap pData = (mng_datap)cinfo->client_data;
|
||||
|
||||
#ifdef MNG_ERROR_TELLTALE /* fill the message text ??? */
|
||||
(*cinfo->err->output_message) (cinfo);
|
||||
#endif
|
||||
/* return to the point of no return... */
|
||||
longjmp (pData->sErrorbuf, cinfo->err->msg_code);
|
||||
}
|
||||
#endif /* MNG_USE_SETJMP */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_USE_SETJMP
|
||||
void mng_output_message (j_common_ptr cinfo)
|
||||
{
|
||||
return; /* just do nothing ! */
|
||||
}
|
||||
#endif /* MNG_USE_SETJMP */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* MNG_INCLUDE_IJG6B */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * Global JPEG routines * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode mngjpeg_initialize (mng_datap pData)
|
||||
{
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_JPEG_INITIALIZE, MNG_LC_START)
|
||||
#endif
|
||||
/* allocate space for JPEG structures if necessary */
|
||||
#ifdef MNG_INCLUDE_JNG_READ
|
||||
if (pData->pJPEGderr == MNG_NULL)
|
||||
MNG_ALLOC (pData, pData->pJPEGderr, sizeof (mngjpeg_error ))
|
||||
if (pData->pJPEGdsrc == MNG_NULL)
|
||||
MNG_ALLOC (pData, pData->pJPEGdsrc, sizeof (mngjpeg_source))
|
||||
if (pData->pJPEGdinfo == MNG_NULL)
|
||||
MNG_ALLOC (pData, pData->pJPEGdinfo, sizeof (mngjpeg_decomp))
|
||||
/* enable reverse addressing */
|
||||
pData->pJPEGdinfo->client_data = pData;
|
||||
#endif
|
||||
|
||||
#ifdef MNG_INCLUDE_JNG_WRITE
|
||||
if (pData->pJPEGcerr == MNG_NULL)
|
||||
MNG_ALLOC (pData, pData->pJPEGcerr, sizeof (mngjpeg_error ))
|
||||
if (pData->pJPEGcinfo == MNG_NULL)
|
||||
MNG_ALLOC (pData, pData->pJPEGcinfo, sizeof (mngjpeg_comp ))
|
||||
/* enable reverse addressing */
|
||||
pData->pJPEGcinfo->client_data = pData;
|
||||
#endif
|
||||
/* initialize temporary buffer parms */
|
||||
pData->iJPEGbufmax = MNG_JPEG_MAXBUF;
|
||||
MNG_ALLOC (pData, pData->pJPEGbuf, pData->iJPEGbufmax)
|
||||
|
||||
pData->pJPEGcurrent = pData->pJPEGbuf;
|
||||
pData->iJPEGbufremain = 0;
|
||||
pData->pJPEGrow = MNG_NULL;
|
||||
pData->iJPEGrowlen = 0;
|
||||
pData->iJPEGtoskip = 0;
|
||||
|
||||
pData->bJPEGcompress = MNG_FALSE; /* not doing anything yet ! */
|
||||
pData->bJPEGdecompress = MNG_FALSE;
|
||||
pData->bJPEGhasheader = MNG_FALSE;
|
||||
pData->bJPEGdecostarted = MNG_FALSE;
|
||||
pData->bJPEGscanstarted = MNG_FALSE;
|
||||
|
||||
pData->iJPEGrow = 0; /* zero input/output lines */
|
||||
pData->iJPEGalpharow = 0;
|
||||
pData->iJPEGrgbrow = 0;
|
||||
pData->iJPEGdisprow = 0;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_JPEG_INITIALIZE, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode mngjpeg_cleanup (mng_datap pData)
|
||||
{
|
||||
#if defined(MNG_INCLUDE_IJG6B) && defined(MNG_USE_SETJMP)
|
||||
mng_retcode iRetcode;
|
||||
#endif
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_JPEG_CLEANUP, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
#ifdef MNG_INCLUDE_IJG6B
|
||||
#ifdef MNG_USE_SETJMP
|
||||
iRetcode = setjmp (pData->sErrorbuf);/* setup local JPEG error-recovery */
|
||||
if (iRetcode != 0) /* got here from longjmp ? */
|
||||
MNG_ERRORJ (pData, iRetcode) /* then IJG-lib issued an error */
|
||||
#endif
|
||||
|
||||
#ifdef MNG_INCLUDE_JNG_READ
|
||||
if (pData->bJPEGdecompress) /* still decompressing something ? */
|
||||
jpeg_destroy_decompress (pData->pJPEGdinfo);
|
||||
#endif
|
||||
|
||||
#ifdef MNG_INCLUDE_JNG_WRITE
|
||||
if (pData->bJPEGcompress) /* still compressing something ? */
|
||||
jpeg_destroy_compress (pData->pJPEGcinfo);
|
||||
#endif
|
||||
|
||||
#endif /* MNG_INCLUDE_IJG6B */
|
||||
/* cleanup temporary buffer */
|
||||
MNG_FREE (pData, pData->pJPEGbuf, pData->iJPEGbufmax)
|
||||
/* cleanup space for JPEG structures */
|
||||
#ifdef MNG_INCLUDE_JNG_READ
|
||||
MNG_FREE (pData, pData->pJPEGdinfo, sizeof (mngjpeg_decomp))
|
||||
MNG_FREE (pData, pData->pJPEGdsrc, sizeof (mngjpeg_source))
|
||||
MNG_FREE (pData, pData->pJPEGderr, sizeof (mngjpeg_error ))
|
||||
#endif
|
||||
|
||||
#ifdef MNG_INCLUDE_JNG_WRITE
|
||||
MNG_FREE (pData, pData->pJPEGcinfo, sizeof (mngjpeg_comp ))
|
||||
MNG_FREE (pData, pData->pJPEGcerr, sizeof (mngjpeg_error ))
|
||||
#endif
|
||||
|
||||
MNG_FREE (pData, pData->pJPEGrow, pData->iJPEGrowlen)
|
||||
|
||||
pData->bJPEGcompress = MNG_FALSE; /* whatever we were doing ... */
|
||||
pData->bJPEGdecompress = MNG_FALSE; /* we don't anymore ... */
|
||||
pData->bJPEGhasheader = MNG_FALSE;
|
||||
pData->bJPEGdecostarted = MNG_FALSE;
|
||||
pData->bJPEGscanstarted = MNG_FALSE;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_JPEG_CLEANUP, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_JNG_READ
|
||||
mng_retcode mngjpeg_decompressinit (mng_datap pData)
|
||||
{
|
||||
#if defined(MNG_INCLUDE_IJG6B) && defined(MNG_USE_SETJMP)
|
||||
mng_retcode iRetcode;
|
||||
#endif
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSINIT, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
#ifdef MNG_INCLUDE_IJG6B
|
||||
/* allocate and initialize a JPEG decompression object */
|
||||
pData->pJPEGdinfo->err = jpeg_std_error (pData->pJPEGderr);
|
||||
|
||||
#ifdef MNG_USE_SETJMP /* setup local JPEG error-routines */
|
||||
pData->pJPEGderr->error_exit = mng_error_exit;
|
||||
pData->pJPEGderr->output_message = mng_output_message;
|
||||
|
||||
iRetcode = setjmp (pData->sErrorbuf);/* setup local JPEG error-recovery */
|
||||
if (iRetcode != 0) /* got here from longjmp ? */
|
||||
MNG_ERRORJ (pData, iRetcode) /* then IJG-lib issued an error */
|
||||
#endif /* MNG_USE_SETJMP */
|
||||
|
||||
/* allocate and initialize a JPEG decompression object (continued) */
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSINIT, MNG_LC_JPEG_CREATE_DECOMPRESS)
|
||||
#endif
|
||||
jpeg_create_decompress (pData->pJPEGdinfo);
|
||||
|
||||
pData->bJPEGdecompress = MNG_TRUE; /* indicate it's initialized */
|
||||
|
||||
/* specify the source of the compressed data (eg, a file) */
|
||||
/* no, not a file; we have buffered input */
|
||||
pData->pJPEGdinfo->src = pData->pJPEGdsrc;
|
||||
/* use the default handler */
|
||||
pData->pJPEGdinfo->src->resync_to_restart = jpeg_resync_to_restart;
|
||||
/* setup local source routine & parms */
|
||||
pData->pJPEGdinfo->src->init_source = mng_init_source;
|
||||
pData->pJPEGdinfo->src->fill_input_buffer = mng_fill_input_buffer;
|
||||
pData->pJPEGdinfo->src->skip_input_data = mng_skip_input_data;
|
||||
pData->pJPEGdinfo->src->term_source = mng_term_source;
|
||||
pData->pJPEGdinfo->src->next_input_byte = pData->pJPEGcurrent;
|
||||
pData->pJPEGdinfo->src->bytes_in_buffer = pData->iJPEGbufremain;
|
||||
|
||||
#endif /* MNG_INCLUDE_IJG6B */
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSINIT, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
#endif /* MNG_INCLUDE_JNG_READ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_JNG_READ
|
||||
mng_retcode mngjpeg_decompressdata (mng_datap pData,
|
||||
mng_uint32 iRawsize,
|
||||
mng_uint8p pRawdata)
|
||||
{
|
||||
mng_retcode iRetcode;
|
||||
mng_uint32 iRemain;
|
||||
mng_uint8p pWork;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
#if defined (MNG_INCLUDE_IJG6B) && defined(MNG_USE_SETJMP)
|
||||
iRetcode = setjmp (pData->sErrorbuf);/* initialize local JPEG error-recovery */
|
||||
if (iRetcode != 0) /* got here from longjmp ? */
|
||||
MNG_ERRORJ (pData, iRetcode) /* then IJG-lib issued an error */
|
||||
#endif
|
||||
|
||||
pWork = pRawdata;
|
||||
iRemain = iRawsize;
|
||||
|
||||
if (pData->iJPEGtoskip) /* JPEG-lib told us to skip some more data ? */
|
||||
{
|
||||
if (iRemain > pData->iJPEGtoskip) /* enough data in this buffer ? */
|
||||
{
|
||||
iRemain -= pData->iJPEGtoskip; /* skip enough to access the next byte */
|
||||
pWork += pData->iJPEGtoskip;
|
||||
|
||||
pData->iJPEGtoskip = 0; /* no more to skip then */
|
||||
}
|
||||
else
|
||||
{
|
||||
pData->iJPEGtoskip -= iRemain; /* skip all data in the buffer */
|
||||
iRemain = 0; /* and indicate this accordingly */
|
||||
}
|
||||
/* the skip set current-pointer to NULL ! */
|
||||
pData->pJPEGcurrent = pData->pJPEGbuf;
|
||||
}
|
||||
|
||||
while (iRemain) /* repeat until no more input-bytes */
|
||||
{ /* need to shift anything ? */
|
||||
if ((pData->pJPEGcurrent > pData->pJPEGbuf) &&
|
||||
(pData->pJPEGcurrent - pData->pJPEGbuf + pData->iJPEGbufremain + iRemain > pData->iJPEGbufmax))
|
||||
{
|
||||
if (pData->iJPEGbufremain > 0) /* then do so */
|
||||
MNG_COPY (pData->pJPEGbuf, pData->pJPEGcurrent, pData->iJPEGbufremain)
|
||||
|
||||
pData->pJPEGcurrent = pData->pJPEGbuf;
|
||||
}
|
||||
/* does the remaining input fit into the buffer ? */
|
||||
if (pData->iJPEGbufremain + iRemain <= pData->iJPEGbufmax)
|
||||
{ /* move the lot */
|
||||
MNG_COPY ((pData->pJPEGcurrent + pData->iJPEGbufremain), pWork, iRemain)
|
||||
|
||||
pData->iJPEGbufremain += iRemain;/* adjust remaining_bytes counter */
|
||||
iRemain = 0; /* and indicate there's no input left */
|
||||
}
|
||||
else
|
||||
{ /* calculate what does fit */
|
||||
mng_uint32 iFits = pData->iJPEGbufmax - pData->iJPEGbufremain;
|
||||
|
||||
if (iFits <= 0) /* no space is just bugger 'm all */
|
||||
MNG_ERROR (pData, MNG_JPEGBUFTOOSMALL)
|
||||
/* move that */
|
||||
MNG_COPY ((pData->pJPEGcurrent + pData->iJPEGbufremain), pWork, iFits)
|
||||
|
||||
pData->iJPEGbufremain += iFits; /* adjust remain_bytes counter */
|
||||
iRemain -= iFits; /* and the input-parms */
|
||||
pWork += iFits;
|
||||
}
|
||||
|
||||
#ifdef MNG_INCLUDE_IJG6B
|
||||
pData->pJPEGdinfo->src->next_input_byte = pData->pJPEGcurrent;
|
||||
pData->pJPEGdinfo->src->bytes_in_buffer = pData->iJPEGbufremain;
|
||||
|
||||
if (!pData->bJPEGhasheader) /* haven't got the header yet ? */
|
||||
{
|
||||
/* call jpeg_read_header() to obtain image info */
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_READ_HEADER)
|
||||
#endif
|
||||
if (jpeg_read_header (pData->pJPEGdinfo, TRUE) != JPEG_SUSPENDED)
|
||||
{ /* indicate the header's oke */
|
||||
pData->bJPEGhasheader = MNG_TRUE;
|
||||
|
||||
if ((pData->pJPEGdinfo->image_width != pData->iDatawidth ) ||
|
||||
(pData->pJPEGdinfo->image_height != pData->iDataheight) )
|
||||
MNG_ERROR (pData, MNG_JPEGPARMSERR)
|
||||
|
||||
if ( ((pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAY ) ||
|
||||
(pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA) ) &&
|
||||
(pData->pJPEGdinfo->jpeg_color_space != JCS_GRAYSCALE ) )
|
||||
MNG_ERROR (pData, MNG_JPEGPARMSERR)
|
||||
|
||||
if ( ((pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLOR ) ||
|
||||
(pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) ) &&
|
||||
(pData->pJPEGdinfo->jpeg_color_space != JCS_YCbCr ) )
|
||||
MNG_ERROR (pData, MNG_JPEGPARMSERR)
|
||||
/* indicate whether or not it's progressive */
|
||||
pData->bJPEGprogressive = (mng_bool)jpeg_has_multiple_scans (pData->pJPEGdinfo);
|
||||
/* progressive+alpha can't display "on-the-fly"!! */
|
||||
if ((pData->bJPEGprogressive) &&
|
||||
((pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA ) ||
|
||||
(pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) ))
|
||||
pData->fDisplayrow = MNG_NULL;
|
||||
/* allocate a row of JPEG-samples */
|
||||
if (pData->pJPEGdinfo->jpeg_color_space == JCS_YCbCr)
|
||||
pData->iJPEGrowlen = pData->pJPEGdinfo->image_width * 3;
|
||||
else
|
||||
pData->iJPEGrowlen = pData->pJPEGdinfo->image_width;
|
||||
|
||||
MNG_ALLOC (pData, pData->pJPEGrow, pData->iJPEGrowlen)
|
||||
|
||||
pData->iJPEGrgbrow = 0; /* quite empty up to now */
|
||||
}
|
||||
|
||||
pData->pJPEGcurrent = (mng_uint8p)pData->pJPEGdinfo->src->next_input_byte;
|
||||
pData->iJPEGbufremain = (mng_uint32)pData->pJPEGdinfo->src->bytes_in_buffer;
|
||||
}
|
||||
/* decompress not started ? */
|
||||
if ((pData->bJPEGhasheader) && (!pData->bJPEGdecostarted))
|
||||
{
|
||||
/* set parameters for decompression */
|
||||
|
||||
if (pData->bJPEGprogressive) /* progressive display ? */
|
||||
pData->pJPEGdinfo->buffered_image = TRUE;
|
||||
|
||||
/* jpeg_start_decompress(...); */
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_START_DECOMPRESS)
|
||||
#endif
|
||||
if (jpeg_start_decompress (pData->pJPEGdinfo) == TRUE)
|
||||
/* indicate it started */
|
||||
pData->bJPEGdecostarted = MNG_TRUE;
|
||||
|
||||
pData->pJPEGcurrent = (mng_uint8p)pData->pJPEGdinfo->src->next_input_byte;
|
||||
pData->iJPEGbufremain = (mng_uint32)pData->pJPEGdinfo->src->bytes_in_buffer;
|
||||
}
|
||||
/* process some scanlines ? */
|
||||
if ((pData->bJPEGhasheader) && (pData->bJPEGdecostarted) &&
|
||||
((!jpeg_input_complete (pData->pJPEGdinfo)) ||
|
||||
(pData->pJPEGdinfo->output_scanline < pData->pJPEGdinfo->output_height)))
|
||||
{
|
||||
mng_int32 iLines;
|
||||
|
||||
/* for (each output pass) */
|
||||
do
|
||||
{ /* address the row output buffer */
|
||||
JSAMPROW pRow = (JSAMPROW)pData->pJPEGrow;
|
||||
|
||||
/* init new pass ? */
|
||||
if ((pData->bJPEGprogressive) &&
|
||||
((!pData->bJPEGscanstarted) ||
|
||||
(pData->pJPEGdinfo->output_scanline >= pData->pJPEGdinfo->output_height)))
|
||||
{
|
||||
pData->bJPEGscanstarted = MNG_TRUE;
|
||||
|
||||
/* adjust output decompression parameters if required */
|
||||
/* nop */
|
||||
|
||||
/* start a new output pass */
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_START_OUTPUT)
|
||||
#endif
|
||||
jpeg_start_output (pData->pJPEGdinfo, pData->pJPEGdinfo->input_scan_number);
|
||||
|
||||
pData->iJPEGrow = 0; /* start at row 0 in the image again */
|
||||
}
|
||||
|
||||
/* while (scan lines remain to be read) */
|
||||
do
|
||||
{
|
||||
/* jpeg_read_scanlines(...); */
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_READ_SCANLINES)
|
||||
#endif
|
||||
iLines = jpeg_read_scanlines (pData->pJPEGdinfo, (JSAMPARRAY)&pRow, 1);
|
||||
|
||||
pData->pJPEGcurrent = (mng_uint8p)pData->pJPEGdinfo->src->next_input_byte;
|
||||
pData->iJPEGbufremain = (mng_uint32)pData->pJPEGdinfo->src->bytes_in_buffer;
|
||||
|
||||
if (iLines > 0) /* got something ? */
|
||||
{
|
||||
if (pData->fStorerow2) /* store in object ? */
|
||||
{
|
||||
iRetcode = ((mng_storerow)pData->fStorerow2) (pData);
|
||||
|
||||
if (iRetcode) /* on error bail out */
|
||||
return iRetcode;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
while ((pData->pJPEGdinfo->output_scanline < pData->pJPEGdinfo->output_height) &&
|
||||
(iLines > 0)); /* until end-of-image or not enough input-data */
|
||||
|
||||
/* terminate output pass */
|
||||
if ((pData->bJPEGprogressive) &&
|
||||
(pData->pJPEGdinfo->output_scanline >= pData->pJPEGdinfo->output_height))
|
||||
{
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_FINISH_OUTPUT)
|
||||
#endif
|
||||
jpeg_finish_output (pData->pJPEGdinfo);
|
||||
/* this scan has ended */
|
||||
pData->bJPEGscanstarted = MNG_FALSE;
|
||||
}
|
||||
}
|
||||
while ((!jpeg_input_complete (pData->pJPEGdinfo)) && (iLines > 0));
|
||||
}
|
||||
/* end of image ? */
|
||||
if ((pData->bJPEGhasheader) && (pData->bJPEGdecostarted) &&
|
||||
(jpeg_input_complete (pData->pJPEGdinfo)) &&
|
||||
(pData->pJPEGdinfo->input_scan_number == pData->pJPEGdinfo->output_scan_number))
|
||||
{
|
||||
/* jpeg_finish_decompress(...); */
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_FINISH_DECOMPRESS)
|
||||
#endif
|
||||
if (jpeg_finish_decompress (pData->pJPEGdinfo) == TRUE)
|
||||
{ /* indicate it's done */
|
||||
pData->bJPEGhasheader = MNG_FALSE;
|
||||
pData->bJPEGdecostarted = MNG_FALSE;
|
||||
pData->pJPEGcurrent = (mng_uint8p)pData->pJPEGdinfo->src->next_input_byte;
|
||||
pData->iJPEGbufremain = (mng_uint32)pData->pJPEGdinfo->src->bytes_in_buffer;
|
||||
/* remaining fluff is an error ! */
|
||||
if ((pData->iJPEGbufremain > 0) || (iRemain > 0))
|
||||
MNG_ERROR (pData, MNG_TOOMUCHJDAT)
|
||||
}
|
||||
}
|
||||
#endif /* MNG_INCLUDE_IJG6B */
|
||||
}
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
#endif /* MNG_INCLUDE_JNG_READ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_JNG_READ
|
||||
mng_retcode mngjpeg_decompressfree (mng_datap pData)
|
||||
{
|
||||
#if defined(MNG_INCLUDE_IJG6B) && defined(MNG_USE_SETJMP)
|
||||
mng_retcode iRetcode;
|
||||
#endif
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSFREE, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
#ifdef MNG_INCLUDE_IJG6B
|
||||
#ifdef MNG_USE_SETJMP
|
||||
iRetcode = setjmp (pData->sErrorbuf);/* setup local JPEG error-recovery */
|
||||
if (iRetcode != 0) /* got here from longjmp ? */
|
||||
MNG_ERRORJ (pData, iRetcode) /* then IJG-lib issued an error */
|
||||
#endif
|
||||
|
||||
/* release the JPEG decompression object */
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSFREE, MNG_LC_JPEG_DESTROY_DECOMPRESS)
|
||||
#endif
|
||||
jpeg_destroy_decompress (pData->pJPEGdinfo);
|
||||
|
||||
pData->bJPEGdecompress = MNG_FALSE; /* indicate it's done */
|
||||
|
||||
#endif /* MNG_INCLUDE_IJG6B */
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSFREE, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
#endif /* MNG_INCLUDE_JNG_READ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* MNG_INCLUDE_JNG */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_jpeg.h copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : JPEG library interface (definition) * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : Definition of the JPEG library interface * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* force ANSI-C */
|
||||
#endif
|
||||
|
||||
#ifndef _libmng_jpeg_h_
|
||||
#define _libmng_jpeg_h_
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode mngjpeg_initialize (mng_datap pData);
|
||||
mng_retcode mngjpeg_cleanup (mng_datap pData);
|
||||
|
||||
mng_retcode mngjpeg_decompressinit (mng_datap pData);
|
||||
mng_retcode mngjpeg_decompressdata (mng_datap pData,
|
||||
mng_uint32 iRawsize,
|
||||
mng_uint8p pRawdata);
|
||||
mng_retcode mngjpeg_decompressfree (mng_datap pData);
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* _libmng_jpeg_h_ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
|
@ -0,0 +1,70 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_memory.h copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : Memory management (definition) * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : Definition of memory management functions * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * * */
|
||||
/* * 0.5.3 - 06/12/2000 - G.Juyn * */
|
||||
/* * - swapped MNG_COPY parameter-names * */
|
||||
/* * 0.5.3 - 06/27/2000 - G.Juyn * */
|
||||
/* * - changed size parameter to mng_size_t * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* force ANSI-C */
|
||||
#endif
|
||||
|
||||
#ifndef _libmng_memory_h_
|
||||
#define _libmng_memory_h_
|
||||
|
||||
#include "libmng.h"
|
||||
#include "libmng_data.h"
|
||||
#include "libmng_error.h"
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * Generic memory manager macros * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INTERNAL_MEMMNGMT
|
||||
#define MNG_ALLOC(H,P,L) { P = calloc (1, (mng_size_t)(L)); \
|
||||
if (P == 0) { MNG_ERROR (H, MNG_OUTOFMEMORY) } }
|
||||
#define MNG_ALLOCX(H,P,L) { P = calloc (1, (mng_size_t)(L)); }
|
||||
#define MNG_FREE(H,P,L) { if (P) { free (P); P = 0; } }
|
||||
#define MNG_FREEX(H,P,L) { if (P) free (P); }
|
||||
#else
|
||||
#define MNG_ALLOC(H,P,L) { P = H->fMemalloc ((mng_size_t)(L)); \
|
||||
if (P == 0) { MNG_ERROR (H, MNG_OUTOFMEMORY) } }
|
||||
#define MNG_ALLOCX(H,P,L) { P = H->fMemalloc ((mng_size_t)(L)); }
|
||||
#define MNG_FREE(H,P,L) { if (P) { H->fMemfree (P, (mng_size_t)(L)); P = 0; } }
|
||||
#define MNG_FREEX(H,P,L) { if (P) { H->fMemfree (P, (mng_size_t)(L)); } }
|
||||
#endif /* mng_internal_memmngmt */
|
||||
|
||||
#define MNG_COPY(D,S,L) { memcpy (D, S, (mng_size_t)(L)); }
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* _libmng_memory_h_ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,407 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_object_prc.h copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : Object processing routines (definition) * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : Definition of the internal object processing routines * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * * */
|
||||
/* * 0.5.2 - 05/24/2000 - G.Juyn * */
|
||||
/* * - added support for global color-chunks in animation * */
|
||||
/* * - added support for global PLTE,tRNS,bKGD in animation * */
|
||||
/* * - added SAVE & SEEK animation objects * */
|
||||
/* * 0.5.2 - 05/29/2000 - G.Juyn * */
|
||||
/* * - changed ani_object create routines not to return the * */
|
||||
/* * created object (wasn't necessary) * */
|
||||
/* * - added compression/filter/interlace fields to * */
|
||||
/* * object-buffer for delta-image processing * */
|
||||
/* * * */
|
||||
/* * 0.5.3 - 06/22/2000 - G.Juyn * */
|
||||
/* * - added support for PPLT chunk * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* force ANSI-C */
|
||||
#endif
|
||||
|
||||
#ifndef _libmng_object_prc_h_
|
||||
#define _libmng_object_prc_h_
|
||||
|
||||
#include "libmng.h"
|
||||
#include "libmng_data.h"
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode create_imagedataobject (mng_datap pData,
|
||||
mng_bool bConcrete,
|
||||
mng_bool bViewable,
|
||||
mng_uint32 iWidth,
|
||||
mng_uint32 iHeight,
|
||||
mng_uint8 iBitdepth,
|
||||
mng_uint8 iColortype,
|
||||
mng_uint8 iCompression,
|
||||
mng_uint8 iFilter,
|
||||
mng_uint8 iInterlace,
|
||||
mng_imagedatap *ppObject);
|
||||
|
||||
mng_retcode free_imagedataobject (mng_datap pData,
|
||||
mng_imagedatap pImagedata);
|
||||
|
||||
mng_retcode clone_imagedataobject (mng_datap pData,
|
||||
mng_bool bConcrete,
|
||||
mng_imagedatap pSource,
|
||||
mng_imagedatap *ppClone);
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode create_imageobject (mng_datap pData,
|
||||
mng_uint16 iId,
|
||||
mng_bool bConcrete,
|
||||
mng_bool bVisible,
|
||||
mng_bool bViewable,
|
||||
mng_uint32 iWidth,
|
||||
mng_uint32 iHeight,
|
||||
mng_uint8 iBitdepth,
|
||||
mng_uint8 iColortype,
|
||||
mng_uint8 iCompression,
|
||||
mng_uint8 iFilter,
|
||||
mng_uint8 iInterlace,
|
||||
mng_int32 iPosx,
|
||||
mng_int32 iPosy,
|
||||
mng_bool bClipped,
|
||||
mng_int32 iClipl,
|
||||
mng_int32 iClipr,
|
||||
mng_int32 iClipt,
|
||||
mng_int32 iClipb,
|
||||
mng_imagep *ppObject);
|
||||
|
||||
mng_retcode free_imageobject (mng_datap pData,
|
||||
mng_imagep pImage);
|
||||
|
||||
mng_imagep find_imageobject (mng_datap pData,
|
||||
mng_uint16 iId);
|
||||
|
||||
mng_retcode clone_imageobject (mng_datap pData,
|
||||
mng_uint16 iId,
|
||||
mng_bool bPartial,
|
||||
mng_bool bVisible,
|
||||
mng_bool bAbstract,
|
||||
mng_bool bHasloca,
|
||||
mng_uint8 iLocationtype,
|
||||
mng_int32 iLocationx,
|
||||
mng_int32 iLocationy,
|
||||
mng_imagep pSource,
|
||||
mng_imagep *ppClone);
|
||||
|
||||
mng_retcode renum_imageobject (mng_datap pData,
|
||||
mng_imagep pSource,
|
||||
mng_uint16 iId,
|
||||
mng_bool bVisible,
|
||||
mng_bool bAbstract,
|
||||
mng_bool bHasloca,
|
||||
mng_uint8 iLocationtype,
|
||||
mng_int32 iLocationx,
|
||||
mng_int32 iLocationy);
|
||||
|
||||
mng_retcode reset_object_details (mng_datap pData,
|
||||
mng_imagep pImage,
|
||||
mng_uint32 iWidth,
|
||||
mng_uint32 iHeight,
|
||||
mng_uint8 iBitdepth,
|
||||
mng_uint8 iColortype,
|
||||
mng_uint8 iCompression,
|
||||
mng_uint8 iFilter,
|
||||
mng_uint8 iInterlace,
|
||||
mng_bool bResetall);
|
||||
|
||||
mng_retcode promote_imageobject (mng_datap pData,
|
||||
mng_imagep pImage,
|
||||
mng_uint8 iBitdepth,
|
||||
mng_uint8 iColortype,
|
||||
mng_uint8 iFilltype);
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode create_ani_image (mng_datap pData);
|
||||
|
||||
mng_retcode create_ani_plte (mng_datap pData,
|
||||
mng_uint32 iEntrycount,
|
||||
mng_palette8ep paEntries);
|
||||
|
||||
mng_retcode create_ani_trns (mng_datap pData,
|
||||
mng_uint32 iRawlen,
|
||||
mng_uint8p pRawdata);
|
||||
|
||||
mng_retcode create_ani_gama (mng_datap pData,
|
||||
mng_bool bEmpty,
|
||||
mng_uint32 iGamma);
|
||||
|
||||
mng_retcode create_ani_chrm (mng_datap pData,
|
||||
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_retcode create_ani_srgb (mng_datap pData,
|
||||
mng_bool bEmpty,
|
||||
mng_uint8 iRenderinginent);
|
||||
|
||||
mng_retcode create_ani_iccp (mng_datap pData,
|
||||
mng_bool bEmpty,
|
||||
mng_uint32 iProfilesize,
|
||||
mng_ptr pProfile);
|
||||
|
||||
mng_retcode create_ani_bkgd (mng_datap pData,
|
||||
mng_uint16 iRed,
|
||||
mng_uint16 iGreen,
|
||||
mng_uint16 iBlue);
|
||||
|
||||
mng_retcode create_ani_loop (mng_datap pData,
|
||||
mng_uint8 iLevel,
|
||||
mng_uint32 iRepeatcount,
|
||||
mng_uint8 iTermcond,
|
||||
mng_uint32 iItermin,
|
||||
mng_uint32 iItermax,
|
||||
mng_uint32 iCount,
|
||||
mng_uint32p pSignals);
|
||||
|
||||
mng_retcode create_ani_endl (mng_datap pData,
|
||||
mng_uint8 iLevel);
|
||||
|
||||
mng_retcode create_ani_defi (mng_datap pData);
|
||||
|
||||
mng_retcode create_ani_basi (mng_datap pData,
|
||||
mng_uint16 iRed,
|
||||
mng_uint16 iGreen,
|
||||
mng_uint16 iBlue,
|
||||
mng_bool bHasalpha,
|
||||
mng_uint16 iAlpha,
|
||||
mng_uint8 iViewable);
|
||||
|
||||
mng_retcode create_ani_clon (mng_datap pData,
|
||||
mng_uint16 iCloneid,
|
||||
mng_uint16 iSourceid,
|
||||
mng_uint8 iClonetype,
|
||||
mng_bool bHasdonotshow,
|
||||
mng_uint8 iDonotshow,
|
||||
mng_uint8 iConcrete,
|
||||
mng_bool bHasloca,
|
||||
mng_uint8 iLocatype,
|
||||
mng_int32 iLocax,
|
||||
mng_int32 iLocay);
|
||||
|
||||
mng_retcode create_ani_back (mng_datap pData,
|
||||
mng_uint16 iRed,
|
||||
mng_uint16 iGreen,
|
||||
mng_uint16 iBlue,
|
||||
mng_uint8 iMandatory,
|
||||
mng_uint16 iImageid,
|
||||
mng_uint8 iTile);
|
||||
|
||||
mng_retcode create_ani_fram (mng_datap pData,
|
||||
mng_uint8 iFramemode,
|
||||
mng_uint8 iChangedelay,
|
||||
mng_uint32 iDelay,
|
||||
mng_uint8 iChangetimeout,
|
||||
mng_uint32 iTimeout,
|
||||
mng_uint8 iChangeclipping,
|
||||
mng_uint8 iCliptype,
|
||||
mng_int32 iClipl,
|
||||
mng_int32 iClipr,
|
||||
mng_int32 iClipt,
|
||||
mng_int32 iClipb);
|
||||
|
||||
mng_retcode create_ani_move (mng_datap pData,
|
||||
mng_uint16 iFirstid,
|
||||
mng_uint16 iLastid,
|
||||
mng_uint8 iType,
|
||||
mng_int32 iLocax,
|
||||
mng_int32 iLocay);
|
||||
|
||||
mng_retcode create_ani_clip (mng_datap pData,
|
||||
mng_uint16 iFirstid,
|
||||
mng_uint16 iLastid,
|
||||
mng_uint8 iType,
|
||||
mng_int32 iClipl,
|
||||
mng_int32 iClipr,
|
||||
mng_int32 iClipt,
|
||||
mng_int32 iClipb);
|
||||
|
||||
mng_retcode create_ani_show (mng_datap pData,
|
||||
mng_uint16 iFirstid,
|
||||
mng_uint16 iLastid,
|
||||
mng_uint8 iMode);
|
||||
|
||||
mng_retcode create_ani_term (mng_datap pData,
|
||||
mng_uint8 iTermaction,
|
||||
mng_uint8 iIteraction,
|
||||
mng_uint32 iDelay,
|
||||
mng_uint32 iItermax);
|
||||
|
||||
mng_retcode create_ani_save (mng_datap pData);
|
||||
mng_retcode create_ani_seek (mng_datap pData);
|
||||
|
||||
mng_retcode create_ani_dhdr (mng_datap pData,
|
||||
mng_uint16 iObjectid,
|
||||
mng_uint8 iImagetype,
|
||||
mng_uint8 iDeltatype,
|
||||
mng_uint32 iBlockwidth,
|
||||
mng_uint32 iBlockheight,
|
||||
mng_uint32 iBlockx,
|
||||
mng_uint32 iBlocky);
|
||||
|
||||
mng_retcode create_ani_prom (mng_datap pData,
|
||||
mng_uint8 iBitdepth,
|
||||
mng_uint8 iColortype,
|
||||
mng_uint8 iFilltype);
|
||||
|
||||
mng_retcode create_ani_ipng (mng_datap pData);
|
||||
mng_retcode create_ani_ijng (mng_datap pData);
|
||||
|
||||
mng_retcode create_ani_pplt (mng_datap pData,
|
||||
mng_uint8 iType,
|
||||
mng_uint32 iCount,
|
||||
mng_palette8ep paIndexentries,
|
||||
mng_uint8p paAlphaentries,
|
||||
mng_uint8p paUsedentries);
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode free_ani_image (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
|
||||
mng_retcode free_ani_plte (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode free_ani_trns (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode free_ani_gama (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode free_ani_chrm (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode free_ani_srgb (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode free_ani_iccp (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode free_ani_bkgd (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode free_ani_loop (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode free_ani_endl (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode free_ani_defi (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode free_ani_basi (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode free_ani_clon (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode free_ani_back (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode free_ani_fram (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode free_ani_move (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode free_ani_clip (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode free_ani_show (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode free_ani_term (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode free_ani_save (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode free_ani_seek (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode free_ani_dhdr (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode free_ani_prom (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode free_ani_ipng (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode free_ani_ijng (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode free_ani_pplt (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode process_ani_image (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
|
||||
mng_retcode process_ani_plte (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode process_ani_trns (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode process_ani_gama (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode process_ani_chrm (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode process_ani_srgb (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode process_ani_iccp (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode process_ani_bkgd (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode process_ani_loop (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode process_ani_endl (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode process_ani_defi (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode process_ani_basi (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode process_ani_clon (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode process_ani_back (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode process_ani_fram (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode process_ani_move (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode process_ani_clip (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode process_ani_show (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode process_ani_term (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode process_ani_save (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode process_ani_seek (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode process_ani_dhdr (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode process_ani_prom (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode process_ani_ipng (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode process_ani_ijng (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
mng_retcode process_ani_pplt (mng_datap pData,
|
||||
mng_objectp pObject);
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* _libmng_object_prc_h_ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
|
@ -0,0 +1,464 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_objects.h copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : Internal object structures (definition) * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : Definition of the internal object structures * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * * */
|
||||
/* * 0.5.2 - 05/23/2000 - G.Juyn * */
|
||||
/* * - changed inclusion to DISPLAY_PROCS * */
|
||||
/* * 0.5.2 - 05/24/2000 - G.Juyn * */
|
||||
/* * - added global color-chunks for animations * */
|
||||
/* * - added global PLTE,tRNS,bKGD chunks for animation * */
|
||||
/* * - added SAVE & SEEK animation objects * */
|
||||
/* * 0.5.2 - 05/29/2000 - G.Juyn * */
|
||||
/* * - added framenr/layernr/playtime to object header * */
|
||||
/* * 0.5.2 - 05/30/2000 - G.Juyn * */
|
||||
/* * - added ani-objects for delta-image processing * */
|
||||
/* * - added compression/filter/interlace fields to * */
|
||||
/* * object-buffer for delta-image processing * */
|
||||
/* * * */
|
||||
/* * 0.5.3 - 06/17/2000 - G.Juyn * */
|
||||
/* * - changed definition of aTRNSentries * */
|
||||
/* * 0.5.3 - 06/22/2000 - G.Juyn * */
|
||||
/* * - added definition for PPLT animation-processing * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* force ANSI-C */
|
||||
#endif
|
||||
|
||||
#ifndef _libmng_objects_h_
|
||||
#define _libmng_objects_h_
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_DISPLAY_PROCS
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef mng_retcode (*mng_cleanupobject) (mng_datap pData,
|
||||
mng_objectp pHeader);
|
||||
|
||||
typedef mng_retcode (*mng_processobject) (mng_datap pData,
|
||||
mng_objectp pHeader);
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct {
|
||||
mng_cleanupobject fCleanup;
|
||||
mng_processobject fProcess;
|
||||
mng_objectp pNext; /* for double-linked list */
|
||||
mng_objectp pPrev;
|
||||
mng_uint32 iFramenr;
|
||||
mng_uint32 iLayernr;
|
||||
mng_uint32 iPlaytime;
|
||||
} mng_object_header;
|
||||
typedef mng_object_header * mng_object_headerp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* MNG specification "object-buffer" */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
mng_uint32 iRefcount; /* reference counter */
|
||||
mng_bool bFrozen; /* frozen flag */
|
||||
mng_bool bConcrete; /* concrete flag */
|
||||
mng_bool bViewable; /* viewable flag */
|
||||
mng_uint32 iWidth; /* image specifics */
|
||||
mng_uint32 iHeight;
|
||||
mng_uint8 iBitdepth;
|
||||
mng_uint8 iColortype;
|
||||
mng_uint8 iCompression;
|
||||
mng_uint8 iFilter;
|
||||
mng_uint8 iInterlace;
|
||||
mng_uint8 iAlphabitdepth; /* used only for JNG images */
|
||||
|
||||
mng_bool bHasPLTE; /* PLTE chunk present */
|
||||
mng_bool bHasTRNS; /* tRNS chunk present */
|
||||
mng_bool bHasGAMA; /* gAMA chunk present */
|
||||
mng_bool bHasCHRM; /* cHRM chunk present */
|
||||
mng_bool bHasSRGB; /* sRGB chunk present */
|
||||
mng_bool bHasICCP; /* iCCP chunk present */
|
||||
mng_bool bHasBKGD; /* bKGD chunk present */
|
||||
|
||||
mng_uint32 iPLTEcount; /* PLTE fields */
|
||||
mng_rgbpaltab aPLTEentries;
|
||||
|
||||
mng_uint16 iTRNSgray; /* tRNS fields */
|
||||
mng_uint16 iTRNSred;
|
||||
mng_uint16 iTRNSgreen;
|
||||
mng_uint16 iTRNSblue;
|
||||
mng_uint32 iTRNScount;
|
||||
mng_uint8arr aTRNSentries;
|
||||
|
||||
mng_uint32 iGamma; /* gAMA fields */
|
||||
|
||||
mng_uint32 iWhitepointx; /* cHRM fields */
|
||||
mng_uint32 iWhitepointy;
|
||||
mng_uint32 iPrimaryredx;
|
||||
mng_uint32 iPrimaryredy;
|
||||
mng_uint32 iPrimarygreenx;
|
||||
mng_uint32 iPrimarygreeny;
|
||||
mng_uint32 iPrimarybluex;
|
||||
mng_uint32 iPrimarybluey;
|
||||
|
||||
mng_uint8 iRenderingintent; /* sRGB fields */
|
||||
|
||||
mng_uint32 iProfilesize; /* iCCP fields */
|
||||
mng_ptr pProfile;
|
||||
|
||||
mng_uint8 iBKGDindex; /* bKGD fields */
|
||||
mng_uint16 iBKGDgray;
|
||||
mng_uint16 iBKGDred;
|
||||
mng_uint16 iBKGDgreen;
|
||||
mng_uint16 iBKGDblue;
|
||||
|
||||
mng_uint32 iSamplesize; /* size of a sample */
|
||||
mng_uint32 iRowsize; /* size of a row of samples */
|
||||
mng_uint32 iImgdatasize; /* size of the sample data buffer */
|
||||
mng_uint8p pImgdata; /* actual sample data buffer */
|
||||
|
||||
} mng_imagedata;
|
||||
typedef mng_imagedata * mng_imagedatap;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* MNG specification "object" */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
mng_uint16 iId; /* object-id */
|
||||
mng_bool bFrozen; /* frozen flag */
|
||||
mng_bool bVisible; /* potential visibility flag */
|
||||
mng_bool bViewable; /* viewable flag */
|
||||
mng_int32 iPosx; /* location fields */
|
||||
mng_int32 iPosy;
|
||||
mng_bool bClipped; /* clipping fields */
|
||||
mng_int32 iClipl;
|
||||
mng_int32 iClipr;
|
||||
mng_int32 iClipt;
|
||||
mng_int32 iClipb;
|
||||
mng_imagedatap pImgbuf; /* the image-data buffer */
|
||||
} mng_image;
|
||||
typedef mng_image * mng_imagep;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
/* "on-the-fly" image (= object 0) */
|
||||
typedef mng_image mng_ani_image; /* let's (ab)use the general "object" */
|
||||
typedef mng_ani_image * mng_ani_imagep; /* that's actualy crucial, so don't change it! */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* global PLTE object */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
mng_uint32 iEntrycount;
|
||||
mng_rgbpaltab aEntries;
|
||||
} mng_ani_plte;
|
||||
typedef mng_ani_plte * mng_ani_pltep;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* global tRNS object */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
mng_uint32 iRawlen;
|
||||
mng_uint8arr aRawdata;
|
||||
} mng_ani_trns;
|
||||
typedef mng_ani_trns * mng_ani_trnsp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* global gAMA object */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
mng_bool bEmpty;
|
||||
mng_uint32 iGamma;
|
||||
} mng_ani_gama;
|
||||
typedef mng_ani_gama * mng_ani_gamap;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* global gCRM object */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
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_ani_chrm;
|
||||
typedef mng_ani_chrm * mng_ani_chrmp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* global sRGB object */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
mng_bool bEmpty;
|
||||
mng_uint8 iRenderingintent;
|
||||
} mng_ani_srgb;
|
||||
typedef mng_ani_srgb * mng_ani_srgbp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* global iCCP object */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
mng_bool bEmpty;
|
||||
mng_uint32 iProfilesize;
|
||||
mng_ptr pProfile;
|
||||
} mng_ani_iccp;
|
||||
typedef mng_ani_iccp * mng_ani_iccpp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* global bKGD object */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
mng_uint16 iRed;
|
||||
mng_uint16 iGreen;
|
||||
mng_uint16 iBlue;
|
||||
} mng_ani_bkgd;
|
||||
typedef mng_ani_bkgd * mng_ani_bkgdp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* LOOP object */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
mng_uint8 iLevel;
|
||||
mng_uint32 iRepeatcount;
|
||||
mng_uint8 iTermcond;
|
||||
mng_uint32 iItermin;
|
||||
mng_uint32 iItermax;
|
||||
mng_uint32 iCount;
|
||||
mng_uint32p pSignals;
|
||||
|
||||
mng_uint32 iRunningcount; /* running counter */
|
||||
} mng_ani_loop;
|
||||
typedef mng_ani_loop * mng_ani_loopp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* ENDL object */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
mng_uint8 iLevel;
|
||||
|
||||
mng_ani_loopp pLOOP; /* matching LOOP */
|
||||
} mng_ani_endl;
|
||||
typedef mng_ani_endl * mng_ani_endlp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* DEFI object */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
mng_uint16 iId;
|
||||
mng_uint8 iDonotshow;
|
||||
mng_uint8 iConcrete;
|
||||
mng_bool bHasloca;
|
||||
mng_int32 iLocax;
|
||||
mng_int32 iLocay;
|
||||
mng_bool bHasclip;
|
||||
mng_int32 iClipl;
|
||||
mng_int32 iClipr;
|
||||
mng_int32 iClipt;
|
||||
mng_int32 iClipb;
|
||||
} mng_ani_defi;
|
||||
typedef mng_ani_defi * mng_ani_defip;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* BASI object */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
mng_uint16 iRed;
|
||||
mng_uint16 iGreen;
|
||||
mng_uint16 iBlue;
|
||||
mng_bool bHasalpha;
|
||||
mng_uint16 iAlpha;
|
||||
mng_uint8 iViewable;
|
||||
} mng_ani_basi;
|
||||
typedef mng_ani_basi * mng_ani_basip;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* CLON object */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
mng_uint16 iCloneid;
|
||||
mng_uint16 iSourceid;
|
||||
mng_uint8 iClonetype;
|
||||
mng_bool bHasdonotshow;
|
||||
mng_uint8 iDonotshow;
|
||||
mng_uint8 iConcrete;
|
||||
mng_bool bHasloca;
|
||||
mng_uint8 iLocatype;
|
||||
mng_int32 iLocax;
|
||||
mng_int32 iLocay;
|
||||
} mng_ani_clon;
|
||||
typedef mng_ani_clon * mng_ani_clonp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* BACK object */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
mng_uint16 iRed;
|
||||
mng_uint16 iGreen;
|
||||
mng_uint16 iBlue;
|
||||
mng_uint8 iMandatory;
|
||||
mng_uint16 iImageid;
|
||||
mng_uint8 iTile;
|
||||
} mng_ani_back;
|
||||
typedef mng_ani_back * mng_ani_backp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* FRAM object */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
mng_uint8 iFramemode;
|
||||
mng_uint8 iChangedelay;
|
||||
mng_uint32 iDelay;
|
||||
mng_uint8 iChangetimeout;
|
||||
mng_uint32 iTimeout;
|
||||
mng_uint8 iChangeclipping;
|
||||
mng_uint8 iCliptype;
|
||||
mng_int32 iClipl;
|
||||
mng_int32 iClipr;
|
||||
mng_int32 iClipt;
|
||||
mng_int32 iClipb;
|
||||
} mng_ani_fram;
|
||||
typedef mng_ani_fram * mng_ani_framp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* MOVE object */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
mng_uint16 iFirstid;
|
||||
mng_uint16 iLastid;
|
||||
mng_uint8 iType;
|
||||
mng_int32 iLocax;
|
||||
mng_int32 iLocay;
|
||||
} mng_ani_move;
|
||||
typedef mng_ani_move * mng_ani_movep;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* CLIP object */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
mng_uint16 iFirstid;
|
||||
mng_uint16 iLastid;
|
||||
mng_uint8 iType;
|
||||
mng_int32 iClipl;
|
||||
mng_int32 iClipr;
|
||||
mng_int32 iClipt;
|
||||
mng_int32 iClipb;
|
||||
} mng_ani_clip;
|
||||
typedef mng_ani_clip * mng_ani_clipp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* SHOW object */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
mng_uint16 iFirstid;
|
||||
mng_uint16 iLastid;
|
||||
mng_uint8 iMode;
|
||||
} mng_ani_show;
|
||||
typedef mng_ani_show * mng_ani_showp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* TERM object */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
mng_uint8 iTermaction;
|
||||
mng_uint8 iIteraction;
|
||||
mng_uint32 iDelay;
|
||||
mng_uint32 iItermax;
|
||||
} mng_ani_term;
|
||||
typedef mng_ani_term * mng_ani_termp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* SAVE object */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
} mng_ani_save;
|
||||
typedef mng_ani_save * mng_ani_savep;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* SEEK object */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
} mng_ani_seek;
|
||||
typedef mng_ani_seek * mng_ani_seekp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* DHDR object */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
mng_uint16 iObjectid;
|
||||
mng_uint8 iImagetype;
|
||||
mng_uint8 iDeltatype;
|
||||
mng_uint32 iBlockwidth;
|
||||
mng_uint32 iBlockheight;
|
||||
mng_uint32 iBlockx;
|
||||
mng_uint32 iBlocky;
|
||||
} mng_ani_dhdr;
|
||||
typedef mng_ani_dhdr * mng_ani_dhdrp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* PROM object */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
mng_uint8 iBitdepth;
|
||||
mng_uint8 iColortype;
|
||||
mng_uint8 iFilltype;
|
||||
} mng_ani_prom;
|
||||
typedef mng_ani_prom * mng_ani_promp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* IPNG object */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
} mng_ani_ipng;
|
||||
typedef mng_ani_ipng * mng_ani_ipngp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* IJNG object */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
} mng_ani_ijng;
|
||||
typedef mng_ani_ijng * mng_ani_ijngp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef struct { /* PPLT object */
|
||||
mng_object_header sHeader; /* default header (DO NOT REMOVE) */
|
||||
mng_uint8 iType;
|
||||
mng_uint32 iCount;
|
||||
mng_rgbpaltab aIndexentries;
|
||||
mng_uint8arr aAlphaentries;
|
||||
mng_uint8arr aUsedentries;
|
||||
} mng_ani_pplt;
|
||||
typedef mng_ani_pplt * mng_ani_ppltp;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* MNG_INCLUDE_DISPLAY_PROCS */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* _libmng_objects_h_ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,282 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_pixels.h copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : Pixel-row management routines (definition) * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : Definition of the pixel-row management routines * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * * */
|
||||
/* * 0.5.2 - 05/22/2000 - G.Juyn * */
|
||||
/* * - added some JNG definitions * */
|
||||
/* * - added delta-image row-processing routines * */
|
||||
/* * 0.5.2 - 06/05/2000 - G.Juyn * */
|
||||
/* * - added support for RGB8_A8 canvasstyle * */
|
||||
/* * * */
|
||||
/* * 0.5.3 - 06/16/2000 - G.Juyn * */
|
||||
/* * - changed progressive-display processing * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* force ANSI-C */
|
||||
#endif
|
||||
|
||||
#ifndef _libmng_pixels_h_
|
||||
#define _libmng_pixels_h_
|
||||
|
||||
#include "libmng.h"
|
||||
#include "libmng_data.h"
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * Progressive display check - checks to see if progressive display is * */
|
||||
/* * in order & indicates so * */
|
||||
/* * * */
|
||||
/* * The routine is called after a call to one of the display_xxx routines * */
|
||||
/* * if appropriate * */
|
||||
/* * * */
|
||||
/* * The refresh is warrented in the read_chunk routine (mng_read.c) * */
|
||||
/* * and only during read&display processing, since there's not much point * */
|
||||
/* * doing it from memory! * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode display_progressive_check (mng_datap pData);
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * Display routines - convert rowdata (which is already color-corrected) * */
|
||||
/* * to the output canvas, respecting any transparency information * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode display_rgb8 (mng_datap pData);
|
||||
mng_retcode display_rgba8 (mng_datap pData);
|
||||
mng_retcode display_argb8 (mng_datap pData);
|
||||
mng_retcode display_rgb8_a8 (mng_datap pData);
|
||||
mng_retcode display_bgr8 (mng_datap pData);
|
||||
mng_retcode display_bgra8 (mng_datap pData);
|
||||
mng_retcode display_abgr8 (mng_datap pData);
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * Background restore routines - restore the background with info from * */
|
||||
/* * the BACK and/or bKGD chunk and/or the app's background canvas * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode restore_bkgd_backimage (mng_datap pData);
|
||||
mng_retcode restore_bkgd_backcolor (mng_datap pData);
|
||||
mng_retcode restore_bkgd_bgcolor (mng_datap pData);
|
||||
mng_retcode restore_bkgd_rgb8 (mng_datap pData);
|
||||
mng_retcode restore_bkgd_bgr8 (mng_datap pData);
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * Row retrieval routines - retrieve processed & uncompressed row-data * */
|
||||
/* * from the current "object" * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode retrieve_g8 (mng_datap pData);
|
||||
mng_retcode retrieve_g16 (mng_datap pData);
|
||||
mng_retcode retrieve_rgb8 (mng_datap pData);
|
||||
mng_retcode retrieve_rgb16 (mng_datap pData);
|
||||
mng_retcode retrieve_idx8 (mng_datap pData);
|
||||
mng_retcode retrieve_ga8 (mng_datap pData);
|
||||
mng_retcode retrieve_ga16 (mng_datap pData);
|
||||
mng_retcode retrieve_rgba8 (mng_datap pData);
|
||||
mng_retcode retrieve_rgba16 (mng_datap pData);
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * Row storage routines - store processed & uncompressed row-data * */
|
||||
/* * into the current "object" * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode store_g1 (mng_datap pData);
|
||||
mng_retcode store_g2 (mng_datap pData);
|
||||
mng_retcode store_g4 (mng_datap pData);
|
||||
mng_retcode store_g8 (mng_datap pData);
|
||||
mng_retcode store_g16 (mng_datap pData);
|
||||
mng_retcode store_rgb8 (mng_datap pData);
|
||||
mng_retcode store_rgb16 (mng_datap pData);
|
||||
mng_retcode store_idx1 (mng_datap pData);
|
||||
mng_retcode store_idx2 (mng_datap pData);
|
||||
mng_retcode store_idx4 (mng_datap pData);
|
||||
mng_retcode store_idx8 (mng_datap pData);
|
||||
mng_retcode store_ga8 (mng_datap pData);
|
||||
mng_retcode store_ga16 (mng_datap pData);
|
||||
mng_retcode store_rgba8 (mng_datap pData);
|
||||
mng_retcode store_rgba16 (mng_datap pData);
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * Row storage routines (JPEG) - store processed & uncompressed row-data * */
|
||||
/* * into the current "object" * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode store_jpeg_g8 (mng_datap pData);
|
||||
mng_retcode store_jpeg_rgb8 (mng_datap pData);
|
||||
mng_retcode store_jpeg_ga8 (mng_datap pData);
|
||||
mng_retcode store_jpeg_rgba8 (mng_datap pData);
|
||||
|
||||
mng_retcode store_jpeg_g12 (mng_datap pData);
|
||||
mng_retcode store_jpeg_rgb12 (mng_datap pData);
|
||||
mng_retcode store_jpeg_ga12 (mng_datap pData);
|
||||
mng_retcode store_jpeg_rgba12 (mng_datap pData);
|
||||
|
||||
mng_retcode store_jpeg_g8_a1 (mng_datap pData);
|
||||
mng_retcode store_jpeg_g8_a2 (mng_datap pData);
|
||||
mng_retcode store_jpeg_g8_a4 (mng_datap pData);
|
||||
mng_retcode store_jpeg_g8_a8 (mng_datap pData);
|
||||
mng_retcode store_jpeg_g8_a16 (mng_datap pData);
|
||||
|
||||
mng_retcode store_jpeg_rgb8_a1 (mng_datap pData);
|
||||
mng_retcode store_jpeg_rgb8_a2 (mng_datap pData);
|
||||
mng_retcode store_jpeg_rgb8_a4 (mng_datap pData);
|
||||
mng_retcode store_jpeg_rgb8_a8 (mng_datap pData);
|
||||
mng_retcode store_jpeg_rgb8_a16 (mng_datap pData);
|
||||
|
||||
mng_retcode store_jpeg_g12_a1 (mng_datap pData);
|
||||
mng_retcode store_jpeg_g12_a2 (mng_datap pData);
|
||||
mng_retcode store_jpeg_g12_a4 (mng_datap pData);
|
||||
mng_retcode store_jpeg_g12_a8 (mng_datap pData);
|
||||
mng_retcode store_jpeg_g12_a16 (mng_datap pData);
|
||||
|
||||
mng_retcode store_jpeg_rgb12_a1 (mng_datap pData);
|
||||
mng_retcode store_jpeg_rgb12_a2 (mng_datap pData);
|
||||
mng_retcode store_jpeg_rgb12_a4 (mng_datap pData);
|
||||
mng_retcode store_jpeg_rgb12_a8 (mng_datap pData);
|
||||
mng_retcode store_jpeg_rgb12_a16 (mng_datap pData);
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * Delta-image row routines - apply the processed & uncompressed row-data * */
|
||||
/* * onto the target "object" * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode delta_g1 (mng_datap pData);
|
||||
mng_retcode delta_g2 (mng_datap pData);
|
||||
mng_retcode delta_g4 (mng_datap pData);
|
||||
mng_retcode delta_g8 (mng_datap pData);
|
||||
mng_retcode delta_g16 (mng_datap pData);
|
||||
mng_retcode delta_rgb8 (mng_datap pData);
|
||||
mng_retcode delta_rgb16 (mng_datap pData);
|
||||
mng_retcode delta_idx1 (mng_datap pData);
|
||||
mng_retcode delta_idx2 (mng_datap pData);
|
||||
mng_retcode delta_idx4 (mng_datap pData);
|
||||
mng_retcode delta_idx8 (mng_datap pData);
|
||||
mng_retcode delta_ga8 (mng_datap pData);
|
||||
mng_retcode delta_ga16 (mng_datap pData);
|
||||
mng_retcode delta_rgba8 (mng_datap pData);
|
||||
mng_retcode delta_rgba16 (mng_datap pData);
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * Row processing routines - convert uncompressed data from zlib to * */
|
||||
/* * managable row-data which serves as input to the color-management * */
|
||||
/* * routines * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode process_g1 (mng_datap pData);
|
||||
mng_retcode process_g2 (mng_datap pData);
|
||||
mng_retcode process_g4 (mng_datap pData);
|
||||
mng_retcode process_g8 (mng_datap pData);
|
||||
mng_retcode process_g16 (mng_datap pData);
|
||||
mng_retcode process_rgb8 (mng_datap pData);
|
||||
mng_retcode process_rgb16 (mng_datap pData);
|
||||
mng_retcode process_idx1 (mng_datap pData);
|
||||
mng_retcode process_idx2 (mng_datap pData);
|
||||
mng_retcode process_idx4 (mng_datap pData);
|
||||
mng_retcode process_idx8 (mng_datap pData);
|
||||
mng_retcode process_ga8 (mng_datap pData);
|
||||
mng_retcode process_ga16 (mng_datap pData);
|
||||
mng_retcode process_rgba8 (mng_datap pData);
|
||||
mng_retcode process_rgba16 (mng_datap pData);
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * Row processing initialization routines - set up the variables needed * */
|
||||
/* * to process uncompressed row-data * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode init_g1_ni (mng_datap pData);
|
||||
mng_retcode init_g1_i (mng_datap pData);
|
||||
mng_retcode init_g2_ni (mng_datap pData);
|
||||
mng_retcode init_g2_i (mng_datap pData);
|
||||
mng_retcode init_g4_ni (mng_datap pData);
|
||||
mng_retcode init_g4_i (mng_datap pData);
|
||||
mng_retcode init_g8_ni (mng_datap pData);
|
||||
mng_retcode init_g8_i (mng_datap pData);
|
||||
mng_retcode init_g16_ni (mng_datap pData);
|
||||
mng_retcode init_g16_i (mng_datap pData);
|
||||
mng_retcode init_rgb8_ni (mng_datap pData);
|
||||
mng_retcode init_rgb8_i (mng_datap pData);
|
||||
mng_retcode init_rgb16_ni (mng_datap pData);
|
||||
mng_retcode init_rgb16_i (mng_datap pData);
|
||||
mng_retcode init_idx1_ni (mng_datap pData);
|
||||
mng_retcode init_idx1_i (mng_datap pData);
|
||||
mng_retcode init_idx2_ni (mng_datap pData);
|
||||
mng_retcode init_idx2_i (mng_datap pData);
|
||||
mng_retcode init_idx4_ni (mng_datap pData);
|
||||
mng_retcode init_idx4_i (mng_datap pData);
|
||||
mng_retcode init_idx8_ni (mng_datap pData);
|
||||
mng_retcode init_idx8_i (mng_datap pData);
|
||||
mng_retcode init_ga8_ni (mng_datap pData);
|
||||
mng_retcode init_ga8_i (mng_datap pData);
|
||||
mng_retcode init_ga16_ni (mng_datap pData);
|
||||
mng_retcode init_ga16_i (mng_datap pData);
|
||||
mng_retcode init_rgba8_ni (mng_datap pData);
|
||||
mng_retcode init_rgba8_i (mng_datap pData);
|
||||
mng_retcode init_rgba16_ni (mng_datap pData);
|
||||
mng_retcode init_rgba16_i (mng_datap pData);
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * Row processing initialization routines (JPEG) - set up the variables * */
|
||||
/* * needed to process uncompressed row-data * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode init_jpeg_a1_ni (mng_datap pData);
|
||||
mng_retcode init_jpeg_a2_ni (mng_datap pData);
|
||||
mng_retcode init_jpeg_a4_ni (mng_datap pData);
|
||||
mng_retcode init_jpeg_a8_ni (mng_datap pData);
|
||||
mng_retcode init_jpeg_a16_ni (mng_datap pData);
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode init_rowproc (mng_datap pData);
|
||||
mng_retcode next_row (mng_datap pData);
|
||||
mng_retcode next_jpeg_alpharow (mng_datap pData);
|
||||
mng_retcode next_jpeg_row (mng_datap pData);
|
||||
mng_retcode cleanup_rowproc (mng_datap pData);
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* _libmng_pixels_h_ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,679 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_read.c copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : Read logic (implementation) * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : implementation of the high-level read logic * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * 0.5.1 - 05/11/2000 - G.Juyn * */
|
||||
/* * - added callback error-reporting support * */
|
||||
/* * 0.5.1 - 05/12/2000 - G.Juyn * */
|
||||
/* * - changed trace to macro for callback error-reporting * */
|
||||
/* * * */
|
||||
/* * 0.5.2 - 05/19/2000 - G.Juyn * */
|
||||
/* * - cleaned up some code regarding mixed support * */
|
||||
/* * 0.5.2 - 05/20/2000 - G.Juyn * */
|
||||
/* * - added support for JNG * */
|
||||
/* * 0.5.2 - 05/31/2000 - G.Juyn * */
|
||||
/* * - fixed up punctuation (contribution by Tim Rowley) * */
|
||||
/* * * */
|
||||
/* * 0.5.3 - 06/16/2000 - G.Juyn * */
|
||||
/* * - changed progressive-display processing * */
|
||||
/* * * */
|
||||
/* * 0.9.1 - 07/08/2000 - G.Juyn * */
|
||||
/* * - changed read-processing for improved I/O-suspension * */
|
||||
/* * 0.9.1 - 07/14/2000 - G.Juyn * */
|
||||
/* * - changed EOF processing behavior * */
|
||||
/* * 0.9.1 - 07/14/2000 - G.Juyn * */
|
||||
/* * - changed default readbuffer size from 1024 to 4200 * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 07/27/2000 - G.Juyn * */
|
||||
/* * - B110320 - fixed GCC warning about mix-sized pointer math * */
|
||||
/* * 0.9.2 - 07/31/2000 - G.Juyn * */
|
||||
/* * - B110546 - fixed for improperly returning UNEXPECTEDEOF * */
|
||||
/* * 0.9.2 - 08/04/2000 - G.Juyn * */
|
||||
/* * - B111096 - fixed large-buffer read-suspension * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#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_object_prc.h"
|
||||
#include "libmng_chunks.h"
|
||||
#include "libmng_chunk_prc.h"
|
||||
#include "libmng_chunk_io.h"
|
||||
#include "libmng_display.h"
|
||||
#include "libmng_read.h"
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* force ANSI-C */
|
||||
#endif
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_READ_PROCS
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode process_eof (mng_datap pData)
|
||||
{
|
||||
if (!pData->bEOF) /* haven't closed the stream yet ? */
|
||||
{
|
||||
pData->bEOF = MNG_TRUE; /* now we do! */
|
||||
|
||||
if (!pData->fClosestream ((mng_handle)pData))
|
||||
MNG_ERROR (pData, MNG_APPIOERROR)
|
||||
}
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode read_databuffer (mng_datap pData,
|
||||
mng_uint8p pBuf,
|
||||
mng_uint32 iSize,
|
||||
mng_uint32 * iRead)
|
||||
{
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_READ_DATABUFFER, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
if (pData->bSuspensionmode)
|
||||
{
|
||||
mng_uint8p pTemp;
|
||||
mng_uint32 iTemp;
|
||||
|
||||
*iRead = 0; /* let's be negative about the outcome */
|
||||
|
||||
if (!pData->pSuspendbuf) /* need to create a suspension buffer ? */
|
||||
{
|
||||
pData->iSuspendbufsize = MNG_SUSPENDBUFFERSIZE;
|
||||
/* so, create it */
|
||||
MNG_ALLOC (pData, pData->pSuspendbuf, pData->iSuspendbufsize)
|
||||
|
||||
pData->iSuspendbufleft = 0; /* make sure to fill it first time */
|
||||
pData->pSuspendbufnext = pData->pSuspendbuf;
|
||||
}
|
||||
/* more than our buffer can hold ? */
|
||||
if (iSize > pData->iSuspendbufsize)
|
||||
{
|
||||
mng_uint32 iRemain;
|
||||
|
||||
if (!pData->pReadbufnext) /* first time ? */
|
||||
{
|
||||
if (pData->iSuspendbufleft) /* do we have some data left ? */
|
||||
{ /* then copy it */
|
||||
MNG_COPY (pBuf, pData->pSuspendbufnext, pData->iSuspendbufleft)
|
||||
/* fixup variables */
|
||||
pData->pReadbufnext = pBuf + pData->iSuspendbufleft;
|
||||
pData->pSuspendbufnext = pData->pSuspendbuf;
|
||||
pData->iSuspendbufleft = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pData->pReadbufnext = pBuf;
|
||||
}
|
||||
}
|
||||
/* calculate how much to get */
|
||||
iRemain = iSize - (mng_uint32)(pData->pReadbufnext - pBuf);
|
||||
/* let's go get it */
|
||||
if (!pData->fReaddata (((mng_handle)pData), pData->pReadbufnext, iRemain, &iTemp))
|
||||
MNG_ERROR (pData, MNG_APPIOERROR);
|
||||
/* first read after suspension return 0 means EOF */
|
||||
if ((pData->iSuspendpoint) && (iTemp == 0))
|
||||
{ /* that makes it final */
|
||||
mng_retcode iRetcode = process_eof (pData);
|
||||
|
||||
if (iRetcode) /* on error bail out */
|
||||
return iRetcode;
|
||||
/* indicate the source is depleted */
|
||||
*iRead = iSize - iRemain + iTemp;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (iTemp < iRemain) /* suspension required ? */
|
||||
{
|
||||
pData->pReadbufnext = pData->pReadbufnext + iTemp;
|
||||
pData->bSuspended = MNG_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
*iRead = iSize; /* got it all now ! */
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ /* need to read some more ? */
|
||||
while ((!pData->bSuspended) && (!pData->bEOF) && (iSize > pData->iSuspendbufleft))
|
||||
{ /* not enough space left in buffer ? */
|
||||
if (pData->iSuspendbufsize - pData->iSuspendbufleft -
|
||||
(mng_uint32)(pData->pSuspendbufnext - pData->pSuspendbuf) <
|
||||
MNG_SUSPENDREQUESTSIZE)
|
||||
{
|
||||
if (pData->iSuspendbufleft) /* then lets shift (if there's anything left) */
|
||||
MNG_COPY (pData->pSuspendbuf, pData->pSuspendbufnext, pData->iSuspendbufleft)
|
||||
/* adjust running pointer */
|
||||
pData->pSuspendbufnext = pData->pSuspendbuf;
|
||||
}
|
||||
/* still not enough room ? */
|
||||
if (pData->iSuspendbufsize - pData->iSuspendbufleft < MNG_SUSPENDREQUESTSIZE)
|
||||
MNG_ERROR (pData, MNG_INTERNALERROR)
|
||||
/* now read some more data */
|
||||
pTemp = pData->pSuspendbufnext + pData->iSuspendbufleft;
|
||||
|
||||
if (!pData->fReaddata (((mng_handle)pData), pTemp, MNG_SUSPENDREQUESTSIZE, &iTemp))
|
||||
MNG_ERROR (pData, MNG_APPIOERROR);
|
||||
/* adjust fill-counter */
|
||||
pData->iSuspendbufleft += iTemp;
|
||||
/* first read after suspension returning 0 means EOF */
|
||||
if ((pData->iSuspendpoint) && (iTemp == 0))
|
||||
{ /* that makes it final */
|
||||
mng_retcode iRetcode = process_eof (pData);
|
||||
|
||||
if (iRetcode) /* on error bail out */
|
||||
return iRetcode;
|
||||
|
||||
if (pData->iSuspendbufleft) /* return the leftover scraps */
|
||||
MNG_COPY (pBuf, pData->pSuspendbufnext, pData->iSuspendbufleft)
|
||||
/* and indicate so */
|
||||
*iRead = pData->iSuspendbufleft;
|
||||
pData->pSuspendbufnext = pData->pSuspendbuf;
|
||||
pData->iSuspendbufleft = 0;
|
||||
}
|
||||
else
|
||||
{ /* suspension required ? */
|
||||
if ((iSize > pData->iSuspendbufleft) && (iTemp < MNG_SUSPENDREQUESTSIZE))
|
||||
pData->bSuspended = MNG_TRUE;
|
||||
|
||||
}
|
||||
|
||||
pData->iSuspendpoint = 0; /* reset it here in case we loop back */
|
||||
}
|
||||
|
||||
if ((!pData->bSuspended) && (!pData->bEOF))
|
||||
{ /* return the data ! */
|
||||
MNG_COPY (pBuf, pData->pSuspendbufnext, iSize)
|
||||
|
||||
*iRead = iSize; /* returned it all */
|
||||
/* adjust suspension-buffer variables */
|
||||
pData->pSuspendbufnext += iSize;
|
||||
pData->iSuspendbufleft -= iSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!pData->fReaddata (((mng_handle)pData), (mng_ptr)pBuf, iSize, iRead))
|
||||
{
|
||||
if (iRead == 0) /* suspension required ? */
|
||||
pData->bSuspended = MNG_TRUE;
|
||||
else
|
||||
MNG_ERROR (pData, MNG_APPIOERROR);
|
||||
}
|
||||
}
|
||||
|
||||
pData->iSuspendpoint = 0; /* safely reset it here ! */
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_READ_DATABUFFER, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode process_raw_chunk (mng_datap pData,
|
||||
mng_uint8p pBuf,
|
||||
mng_uint32 iBuflen)
|
||||
{
|
||||
/* 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 !!! */
|
||||
/* 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_chunk_header chunk_unknown = {MNG_UINT_HUH, init_unknown, free_unknown,
|
||||
read_unknown, write_unknown, 0, 0};
|
||||
|
||||
mng_chunk_header chunk_table [] =
|
||||
{
|
||||
{MNG_UINT_BACK, init_back, free_back, read_back, write_back, 0, 0},
|
||||
{MNG_UINT_BASI, init_basi, free_basi, read_basi, write_basi, 0, 0},
|
||||
{MNG_UINT_CLIP, init_clip, free_clip, read_clip, write_clip, 0, 0},
|
||||
{MNG_UINT_CLON, init_clon, free_clon, read_clon, write_clon, 0, 0},
|
||||
{MNG_UINT_DBYK, init_dbyk, free_dbyk, read_dbyk, write_dbyk, 0, 0},
|
||||
{MNG_UINT_DEFI, init_defi, free_defi, read_defi, write_defi, 0, 0},
|
||||
{MNG_UINT_DHDR, init_dhdr, free_dhdr, read_dhdr, write_dhdr, 0, 0},
|
||||
{MNG_UINT_DISC, init_disc, free_disc, read_disc, write_disc, 0, 0},
|
||||
{MNG_UINT_DROP, init_drop, free_drop, read_drop, write_drop, 0, 0},
|
||||
{MNG_UINT_ENDL, init_endl, free_endl, read_endl, write_endl, 0, 0},
|
||||
{MNG_UINT_FRAM, init_fram, free_fram, read_fram, write_fram, 0, 0},
|
||||
{MNG_UINT_IDAT, init_idat, free_idat, read_idat, write_idat, 0, 0}, /* 12-th element! */
|
||||
{MNG_UINT_IEND, init_iend, free_iend, read_iend, write_iend, 0, 0},
|
||||
{MNG_UINT_IHDR, init_ihdr, free_ihdr, read_ihdr, write_ihdr, 0, 0},
|
||||
{MNG_UINT_IJNG, init_ijng, free_ijng, read_ijng, write_ijng, 0, 0},
|
||||
{MNG_UINT_IPNG, init_ipng, free_ipng, read_ipng, write_ipng, 0, 0},
|
||||
#ifdef MNG_INCLUDE_JNG
|
||||
{MNG_UINT_JDAT, init_jdat, free_jdat, read_jdat, write_jdat, 0, 0},
|
||||
{MNG_UINT_JHDR, init_jhdr, free_jhdr, read_jhdr, write_jhdr, 0, 0},
|
||||
{MNG_UINT_JSEP, init_jsep, free_jsep, read_jsep, write_jsep, 0, 0},
|
||||
#endif
|
||||
{MNG_UINT_LOOP, init_loop, free_loop, read_loop, write_loop, 0, 0},
|
||||
{MNG_UINT_MEND, init_mend, free_mend, read_mend, write_mend, 0, 0},
|
||||
{MNG_UINT_MHDR, init_mhdr, free_mhdr, read_mhdr, write_mhdr, 0, 0},
|
||||
{MNG_UINT_MOVE, init_move, free_move, read_move, write_move, 0, 0},
|
||||
{MNG_UINT_ORDR, init_ordr, free_ordr, read_ordr, write_ordr, 0, 0},
|
||||
{MNG_UINT_PAST, init_past, free_past, read_past, write_past, 0, 0},
|
||||
{MNG_UINT_PLTE, init_plte, free_plte, read_plte, write_plte, 0, 0},
|
||||
{MNG_UINT_PPLT, init_pplt, free_pplt, read_pplt, write_pplt, 0, 0},
|
||||
{MNG_UINT_PROM, init_prom, free_prom, read_prom, write_prom, 0, 0},
|
||||
{MNG_UINT_SAVE, init_save, free_save, read_save, write_save, 0, 0},
|
||||
{MNG_UINT_SEEK, init_seek, free_seek, read_seek, write_seek, 0, 0},
|
||||
{MNG_UINT_SHOW, init_show, free_show, read_show, write_show, 0, 0},
|
||||
{MNG_UINT_TERM, init_term, free_term, read_term, write_term, 0, 0},
|
||||
{MNG_UINT_bKGD, init_bkgd, free_bkgd, read_bkgd, write_bkgd, 0, 0},
|
||||
{MNG_UINT_cHRM, init_chrm, free_chrm, read_chrm, write_chrm, 0, 0},
|
||||
{MNG_UINT_eXPI, init_expi, free_expi, read_expi, write_expi, 0, 0},
|
||||
{MNG_UINT_fPRI, init_fpri, free_fpri, read_fpri, write_fpri, 0, 0},
|
||||
{MNG_UINT_gAMA, init_gama, free_gama, read_gama, write_gama, 0, 0},
|
||||
{MNG_UINT_hIST, init_hist, free_hist, read_hist, write_hist, 0, 0},
|
||||
{MNG_UINT_iCCP, init_iccp, free_iccp, read_iccp, write_iccp, 0, 0},
|
||||
{MNG_UINT_iTXt, init_itxt, free_itxt, read_itxt, write_itxt, 0, 0},
|
||||
{MNG_UINT_nEED, init_need, free_need, read_need, write_need, 0, 0},
|
||||
/* TODO: {MNG_UINT_oFFs, 0, 0, 0, 0, 0, 0}, */
|
||||
/* TODO: {MNG_UINT_pCAL, 0, 0, 0, 0, 0, 0}, */
|
||||
{MNG_UINT_pHYg, init_phyg, free_phyg, read_phyg, write_phyg, 0, 0},
|
||||
{MNG_UINT_pHYs, init_phys, free_phys, read_phys, write_phys, 0, 0},
|
||||
{MNG_UINT_sBIT, init_sbit, free_sbit, read_sbit, write_sbit, 0, 0},
|
||||
/* TODO: {MNG_UINT_sCAL, 0, 0, 0, 0, 0, 0}, */
|
||||
{MNG_UINT_sPLT, init_splt, free_splt, read_splt, write_splt, 0, 0},
|
||||
{MNG_UINT_sRGB, init_srgb, free_srgb, read_srgb, write_srgb, 0, 0},
|
||||
{MNG_UINT_tEXt, init_text, free_text, read_text, write_text, 0, 0},
|
||||
{MNG_UINT_tIME, init_time, free_time, read_time, write_time, 0, 0},
|
||||
{MNG_UINT_tRNS, init_trns, free_trns, read_trns, write_trns, 0, 0},
|
||||
{MNG_UINT_zTXt, init_ztxt, free_ztxt, read_ztxt, write_ztxt, 0, 0},
|
||||
};
|
||||
/* binary search variables */
|
||||
mng_int32 iTop, iLower, iUpper, iMiddle;
|
||||
mng_chunk_headerp pEntry; /* pointer to found entry */
|
||||
mng_chunkid iChunkname; /* the chunk's tag */
|
||||
mng_chunkp pChunk; /* chunk structure (if #define MNG_STORE_CHUNKS) */
|
||||
mng_retcode iRetcode; /* temporary error-code */
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_PROCESS_RAW_CHUNK, MNG_LC_START)
|
||||
#endif
|
||||
/* get the chunkname */
|
||||
iChunkname = (mng_chunkid)(mng_get_uint32 (pBuf));
|
||||
|
||||
pBuf += sizeof (mng_chunkid); /* adjust the buffer */
|
||||
iBuflen -= sizeof (mng_chunkid);
|
||||
/* determine max index of table */
|
||||
iTop = (sizeof (chunk_table) / sizeof (chunk_table [0])) - 1;
|
||||
|
||||
/* binary search; with 52 chunks, worst-case is 7 comparisons */
|
||||
iLower = 0;
|
||||
iMiddle = 11; /* start with the IDAT entry */
|
||||
iUpper = iTop;
|
||||
pEntry = 0; /* no goods yet! */
|
||||
pChunk = 0;
|
||||
|
||||
do /* the binary search itself */
|
||||
{
|
||||
if (chunk_table [iMiddle].iChunkname < iChunkname)
|
||||
iLower = iMiddle + 1;
|
||||
else if (chunk_table [iMiddle].iChunkname > iChunkname)
|
||||
iUpper = iMiddle - 1;
|
||||
else
|
||||
{
|
||||
pEntry = &chunk_table [iMiddle];
|
||||
break;
|
||||
}
|
||||
|
||||
iMiddle = (iLower + iUpper) >> 1;
|
||||
}
|
||||
while (iLower <= iUpper);
|
||||
|
||||
if (!pEntry) /* unknown chunk ? */
|
||||
pEntry = &chunk_unknown; /* make it so! */
|
||||
|
||||
pData->iChunkname = iChunkname; /* keep track of where we are */
|
||||
pData->iChunkseq++;
|
||||
|
||||
if (pEntry->fRead) /* read-callback available ? */
|
||||
{
|
||||
iRetcode = pEntry->fRead (pData, pEntry, iBuflen, (mng_ptr)pBuf, &pChunk);
|
||||
|
||||
if (!iRetcode) /* everything oke ? */
|
||||
{ /* remember unknown chunk's id */
|
||||
if ((pChunk) && (pEntry == &chunk_unknown))
|
||||
((mng_chunk_headerp)pChunk)->iChunkname = iChunkname;
|
||||
}
|
||||
}
|
||||
else
|
||||
iRetcode = MNG_NOERROR;
|
||||
|
||||
if (pChunk) /* store this chunk ? */
|
||||
add_chunk (pData, pChunk); /* do it */
|
||||
|
||||
#ifdef MNG_INCLUDE_JNG /* implicit EOF ? */
|
||||
if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && (!pData->bHasJHDR))
|
||||
#else
|
||||
if ((!pData->bHasMHDR) && (!pData->bHasIHDR))
|
||||
#endif
|
||||
iRetcode = process_eof (pData); /* then do some EOF processing */
|
||||
|
||||
if (iRetcode) /* on error bail out */
|
||||
return iRetcode;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_PROCESS_RAW_CHUNK, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode read_chunk (mng_datap pData)
|
||||
{
|
||||
mng_uint32 iBufmax = pData->iReadbufsize;
|
||||
mng_uint8p pBuf = pData->pReadbuf;
|
||||
mng_uint32 iBuflen = 0; /* number of bytes requested */
|
||||
mng_uint32 iRead = 0; /* number of bytes read */
|
||||
mng_uint32 iCrc; /* calculated CRC */
|
||||
mng_retcode iRetcode = MNG_NOERROR;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_READ_CHUNK, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
#ifdef MNG_SUPPORT_DISPLAY
|
||||
if (pData->pCurraniobj) /* processing an animation object ? */
|
||||
{
|
||||
do /* process it then */
|
||||
{
|
||||
iRetcode = ((mng_object_headerp)pData->pCurraniobj)->fProcess (pData, pData->pCurraniobj);
|
||||
/* refresh needed ? */
|
||||
/* if ((!iRetcode) && (!pData->bTimerset) && (pData->bNeedrefresh))
|
||||
iRetcode = display_progressive_refresh (pData, 1); */
|
||||
/* can we advance to next object ? */
|
||||
if ((!iRetcode) && (pData->pCurraniobj) &&
|
||||
(!pData->bTimerset) && (!pData->bSectionwait))
|
||||
{
|
||||
pData->pCurraniobj = ((mng_object_headerp)pData->pCurraniobj)->pNext;
|
||||
/* TERM processing to be done ? */
|
||||
if ((!pData->pCurraniobj) && (pData->bHasTERM) && (!pData->bHasMHDR))
|
||||
iRetcode = process_display_mend (pData);
|
||||
}
|
||||
} /* until error or a break or no more objects */
|
||||
while ((!iRetcode) && (pData->pCurraniobj) &&
|
||||
(!pData->bTimerset) && (!pData->bSectionwait) && (!pData->bFreezing));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pData->iBreakpoint) /* do we need to finish something first ? */
|
||||
{
|
||||
switch (pData->iBreakpoint) /* return to broken display routine */
|
||||
{
|
||||
case 1 : { iRetcode = process_display_fram2 (pData); break; }
|
||||
case 2 : { iRetcode = process_display_ihdr (pData); break; }
|
||||
case 3 : ; /* same as 4 !!! */
|
||||
case 4 : { iRetcode = process_display_show (pData); break; }
|
||||
case 5 : { iRetcode = process_display_clon2 (pData); break; }
|
||||
#ifdef MNG_INCLUDE_JNG
|
||||
case 7 : { iRetcode = process_display_jhdr (pData); break; }
|
||||
#endif
|
||||
case 6 : ; /* same as 8 !!! */
|
||||
case 8 : { iRetcode = process_display_iend (pData); break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (iRetcode) /* on error bail out */
|
||||
return iRetcode;
|
||||
|
||||
#endif /* MNG_SUPPORT_DISPLAY */
|
||||
/* can we continue processing now, or do we */
|
||||
/* need to wait for the timer to finish (again) ? */
|
||||
#ifdef MNG_SUPPORT_DISPLAY
|
||||
if ((!pData->bTimerset) && (!pData->bSectionwait) && (!pData->bEOF))
|
||||
#else
|
||||
if (!pData->bEOF)
|
||||
#endif
|
||||
{ /* freezing in progress ? */
|
||||
if ((pData->bFreezing) && (pData->iSuspendpoint == 0))
|
||||
pData->bRunning = MNG_FALSE; /* then this is the right moment to do it */
|
||||
|
||||
if (pData->iSuspendpoint <= 2)
|
||||
{
|
||||
iBuflen = sizeof (mng_uint32); /* read length */
|
||||
iRetcode = read_databuffer (pData, pBuf, iBuflen, &iRead);
|
||||
|
||||
if (iRetcode) /* bail on errors */
|
||||
return iRetcode;
|
||||
|
||||
if (pData->bSuspended) /* suspended ? */
|
||||
pData->iSuspendpoint = 2;
|
||||
else /* save the length */
|
||||
pData->iChunklen = mng_get_uint32 (pBuf);
|
||||
|
||||
}
|
||||
|
||||
if (!pData->bSuspended) /* still going ? */
|
||||
{ /* previously suspended or not eof ? */
|
||||
if ((pData->iSuspendpoint > 2) || (iRead == iBuflen))
|
||||
{ /* determine length chunkname + data + crc */
|
||||
iBuflen = pData->iChunklen + (mng_uint32)(sizeof (mng_chunkid) + sizeof (iCrc));
|
||||
|
||||
if (iBuflen < iBufmax) /* does it fit in default buffer ? */
|
||||
{ /* note that we don't use the full size
|
||||
so there's always a zero-byte at the
|
||||
very end !!! */
|
||||
iRetcode = read_databuffer (pData, pBuf, iBuflen, &iRead);
|
||||
|
||||
if (iRetcode) /* bail on errors */
|
||||
return iRetcode;
|
||||
|
||||
if (pData->bSuspended) /* suspended ? */
|
||||
pData->iSuspendpoint = 3;
|
||||
else
|
||||
{
|
||||
if (iRead != iBuflen) /* did we get all the data ? */
|
||||
iRetcode = MNG_UNEXPECTEDEOF;
|
||||
else
|
||||
{
|
||||
mng_uint32 iL = iBuflen - (mng_uint32)(sizeof (iCrc));
|
||||
/* calculate the crc */
|
||||
iCrc = crc (pData, pBuf, iL);
|
||||
/* and check it */
|
||||
if (!(iCrc == mng_get_uint32 (pBuf + iL)))
|
||||
iRetcode = MNG_INVALIDCRC;
|
||||
else
|
||||
iRetcode = process_raw_chunk (pData, pBuf, iL);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!pData->iSuspendpoint) /* create additional large buffer ? */
|
||||
{ /* again reserve space for the last zero-byte */
|
||||
pData->iLargebufsize = iBuflen + 1;
|
||||
MNG_ALLOC (pData, pData->pLargebuf, pData->iLargebufsize)
|
||||
}
|
||||
|
||||
iRetcode = read_databuffer (pData, pData->pLargebuf, iBuflen, &iRead);
|
||||
|
||||
if (iRetcode)
|
||||
return iRetcode;
|
||||
|
||||
if (pData->bSuspended) /* suspended ? */
|
||||
pData->iSuspendpoint = 4;
|
||||
else
|
||||
{
|
||||
if (iRead != iBuflen) /* did we get all the data ? */
|
||||
iRetcode = MNG_UNEXPECTEDEOF;
|
||||
else
|
||||
{
|
||||
mng_uint32 iL = iBuflen - (mng_uint32)(sizeof (iCrc));
|
||||
/* calculate the crc */
|
||||
iCrc = crc (pData, pData->pLargebuf, iL);
|
||||
/* and check it */
|
||||
if (!(iCrc == mng_get_uint32 (pData->pLargebuf + iL)))
|
||||
iRetcode = MNG_INVALIDCRC;
|
||||
else
|
||||
iRetcode = process_raw_chunk (pData, pData->pLargebuf, iL);
|
||||
}
|
||||
/* cleanup additional large buffer */
|
||||
MNG_FREE (pData, pData->pLargebuf, pData->iLargebufsize)
|
||||
}
|
||||
}
|
||||
|
||||
if (iRetcode) /* on error bail out */
|
||||
return iRetcode;
|
||||
|
||||
}
|
||||
else
|
||||
{ /* that's final */
|
||||
iRetcode = process_eof (pData);
|
||||
|
||||
if (iRetcode) /* on error bail out */
|
||||
return iRetcode;
|
||||
|
||||
if ((iRead != 0) || /* did we get an unexpected eof ? */
|
||||
#ifdef MNG_INCLUDE_JNG
|
||||
(pData->bHasIHDR || pData->bHasMHDR || pData->bHasJHDR))
|
||||
#else
|
||||
(pData->bHasIHDR || pData->bHasMHDR))
|
||||
#endif
|
||||
MNG_ERROR (pData, MNG_UNEXPECTEDEOF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MNG_SUPPORT_DISPLAY /* refresh needed ? */
|
||||
if ((!pData->bTimerset) && (!pData->bSuspended) && (pData->bNeedrefresh))
|
||||
{
|
||||
iRetcode = display_progressive_refresh (pData, 1);
|
||||
|
||||
if (iRetcode) /* on error bail out */
|
||||
return iRetcode;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_READ_CHUNK, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode read_graphic (mng_datap pData)
|
||||
{
|
||||
mng_uint32 iBuflen; /* number of bytes requested */
|
||||
mng_uint32 iRead; /* number of bytes read */
|
||||
mng_retcode iRetcode; /* temporary error-code */
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_READ_GRAPHIC, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
if (!pData->pReadbuf) /* buffer allocated ? */
|
||||
{
|
||||
pData->iReadbufsize = 4200; /* allocate a default read buffer */
|
||||
MNG_ALLOC (pData, pData->pReadbuf, pData->iReadbufsize)
|
||||
}
|
||||
/* haven't processed the signature ? */
|
||||
if ((!pData->bHavesig) || (pData->iSuspendpoint == 1))
|
||||
{
|
||||
iBuflen = 2 * sizeof (mng_uint32); /* read signature */
|
||||
|
||||
iRetcode = read_databuffer (pData, pData->pReadbuf, iBuflen, &iRead);
|
||||
|
||||
if (iRetcode)
|
||||
return iRetcode;
|
||||
|
||||
if (pData->bSuspended) /* input suspension ? */
|
||||
pData->iSuspendpoint = 1;
|
||||
else
|
||||
{
|
||||
if (iRead != iBuflen) /* full signature received ? */
|
||||
MNG_ERROR (pData, MNG_UNEXPECTEDEOF);
|
||||
/* is it a valid signature ? */
|
||||
if (mng_get_uint32 (pData->pReadbuf) == PNG_SIG)
|
||||
pData->eSigtype = mng_it_png;
|
||||
else
|
||||
if (mng_get_uint32 (pData->pReadbuf) == JNG_SIG)
|
||||
pData->eSigtype = mng_it_jng;
|
||||
else
|
||||
if (mng_get_uint32 (pData->pReadbuf) == MNG_SIG)
|
||||
pData->eSigtype = mng_it_mng;
|
||||
else
|
||||
MNG_ERROR (pData, MNG_INVALIDSIG);
|
||||
/* all of it ? */
|
||||
if (mng_get_uint32 (pData->pReadbuf+4) != POST_SIG)
|
||||
MNG_ERROR (pData, MNG_INVALIDSIG);
|
||||
|
||||
pData->bHavesig = MNG_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pData->bSuspended) /* still going ? */
|
||||
{
|
||||
do
|
||||
{
|
||||
iRetcode = read_chunk (pData); /* process a chunk */
|
||||
|
||||
if (iRetcode) /* on error bail out */
|
||||
return iRetcode;
|
||||
}
|
||||
#ifdef MNG_SUPPORT_DISPLAY /* until EOF or a break-request */
|
||||
while ((!pData->bEOF) && (!pData->bSuspended) &&
|
||||
(!pData->bTimerset) && (!pData->bSectionwait));
|
||||
#else
|
||||
while ((!pData->bEOF) && (!pData->bSuspended));
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_READ_GRAPHIC, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* MNG_INCLUDE_READ_PROCS */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_read.h copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : Read management (definition) * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : Definition of the read management routines * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* force ANSI-C */
|
||||
#endif
|
||||
|
||||
#ifndef _libmng_read_h_
|
||||
#define _libmng_read_h_
|
||||
|
||||
#include "libmng.h"
|
||||
#include "libmng_data.h"
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode read_graphic (mng_datap pData);
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* _libmng_read_h_ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,425 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_types.h copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : type specifications * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : Specification of the types used by the library * */
|
||||
/* * Creates platform-independant structure * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/06/2000 - G.Juyn * */
|
||||
/* * - added iteratechunk callback definition * */
|
||||
/* * 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - improved definitions for DLL support * */
|
||||
/* * - added 8-bit palette definition * */
|
||||
/* * - added general array definitions * */
|
||||
/* * - added MNG_NULL definition * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * 0.5.1 - 05/11/2000 - G.Juyn * */
|
||||
/* * - changed most callback prototypes to allow the app * */
|
||||
/* * to report errors during callback processing * */
|
||||
/* * 0.5.1 - 05/16/2000 - G.Juyn * */
|
||||
/* * - moved standard header includes into this file * */
|
||||
/* * (stdlib/mem for mem-mngmt & math for fp gamma-calc) * */
|
||||
/* * * */
|
||||
/* * 0.5.2 - 05/18/2000 - G.Juyn * */
|
||||
/* * - B003 - fixed problem with <mem.h> being proprietary * */
|
||||
/* * to Borland platform * */
|
||||
/* * - added helper definitions for JNG (IJG-based) * */
|
||||
/* * - fixed support for IJGSRC6B * */
|
||||
/* * 0.5.2 - 05/24/2000 - G.Juyn * */
|
||||
/* * - added default IJG compression parameters and such * */
|
||||
/* * 0.5.2 - 05/31/2000 - G.Juyn * */
|
||||
/* * - fixed inclusion for memcpy (contributed by Tim Rowley) * */
|
||||
/* * - added mng_int32p (contributed by Tim Rowley) * */
|
||||
/* * 0.5.2 - 06/02/2000 - G.Juyn * */
|
||||
/* * - removed SWAP_ENDIAN reference (contributed by Tim Rowley)* */
|
||||
/* * - added getalphaline callback for RGB8_A8 canvasstyle * */
|
||||
/* * * */
|
||||
/* * 0.5.3 - 06/21/2000 - G.Juyn * */
|
||||
/* * - added speedtype to facilitate testing * */
|
||||
/* * 0.5.3 - 06/27/2000 - G.Juyn * */
|
||||
/* * - added typedef for mng_size_t * */
|
||||
/* * - changed size parameter for memory callbacks to * */
|
||||
/* * mng_size_t * */
|
||||
/* * 0.5.3 - 06/28/2000 - G.Juyn * */
|
||||
/* * - changed definition of 32-bit ints (64-bit platforms) * */
|
||||
/* * - changed definition of mng_handle (64-bit platforms) * */
|
||||
/* * 0.5.3 - 06/29/2000 - G.Juyn * */
|
||||
/* * - changed definition of mng_handle (again) * */
|
||||
/* * - swapped refresh parameters * */
|
||||
/* * - added inclusion of stdlib.h for abs() * */
|
||||
/* * * */
|
||||
/* * 0.9.0 - 06/30/2000 - G.Juyn * */
|
||||
/* * - changed refresh parameters to 'x,y,width,height' * */
|
||||
/* * 0.9.1 - 07/10/2000 - G.Juyn * */
|
||||
/* * - added suspendbuffer constants * */
|
||||
/* * 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 - 08/07/2000 - G.Juyn * */
|
||||
/* * - B111300 - fixup for improved portability * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef _libmng_types_h_
|
||||
#define _libmng_types_h_
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma option -AT /* turn off strict ANSI-C for the moment */
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined(_Windows) || defined(_WINDOWS)
|
||||
#define WIN32 /* gather them into a single define */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * Here's where the external & standard libs are embedded * */
|
||||
/* * * */
|
||||
/* * (it can be a bit of a pain in the lower-back to get them to work * */
|
||||
/* * together) * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_ZLIB /* zlib by Mark Adler & Jean-loup Gailly */
|
||||
#include "zlib.h"
|
||||
#endif
|
||||
|
||||
#ifdef MNG_INCLUDE_LCMS /* little cms by Marti Maria */
|
||||
#undef FAR /* possibly defined by zlib */
|
||||
#include "lcms.h"
|
||||
#endif /* MNG_INCLUDE_LCMS */
|
||||
|
||||
#ifdef MNG_INCLUDE_IJG6B /* IJG's jpgsrc6b */
|
||||
#include <stdio.h>
|
||||
#ifdef MNG_USE_SETJMP
|
||||
#include <setjmp.h> /* needed for error-recovery (blergh) */
|
||||
#else
|
||||
#ifdef WIN32
|
||||
#define USE_WINDOWS_MESSAGEBOX /* display a messagebox under Windoze */
|
||||
#endif
|
||||
#endif /* MNG_USE_SETJMP */
|
||||
#undef FAR /* possibly defined by zlib or lcms */
|
||||
#include "jpeglib.h" /* all that for JPEG support :-) */
|
||||
#endif /* MNG_INCLUDE_IJG6B */
|
||||
|
||||
#if defined(MNG_INTERNAL_MEMMNGMT) || defined(MNG_INCLUDE_FILTERS)
|
||||
#include <stdlib.h> /* "calloc" & "free" & "abs" */
|
||||
#endif
|
||||
|
||||
#include <limits.h> /* get proper integer widths */
|
||||
|
||||
#ifdef WIN32
|
||||
/* B003 */
|
||||
#if defined __BORLANDC__
|
||||
#include <mem.h> /* defines "memcpy" for BCB */
|
||||
#else
|
||||
#include <memory.h> /* defines "memcpy" for other win32 platforms */
|
||||
#endif
|
||||
/* B003 */
|
||||
#else
|
||||
#ifdef BSD
|
||||
#include <strings.h> /* defines "memcpy" for BSD (?) */
|
||||
#else
|
||||
#include <string.h> /* defines "memcpy" for all others (???) */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY)
|
||||
#include <math.h> /* fp gamma-calculation */
|
||||
#endif
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * Platform-dependant stuff * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
/* TODO: this may require some elaboration for other platforms;
|
||||
only works with BCB for now */
|
||||
|
||||
#ifndef MNG_DLL
|
||||
#if defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL)
|
||||
#define MNG_DLL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(MNG_DLL) && defined(WIN32) /* setup DLL calling conventions */
|
||||
#define MNG_DECL __stdcall
|
||||
#if defined(MNG_BUILD_DLL)
|
||||
#define MNG_EXT __declspec(dllexport)
|
||||
#elif defined(MNG_USE_DLL)
|
||||
#define MNG_EXT __declspec(dllimport)
|
||||
#else
|
||||
#define MNG_EXT
|
||||
#endif
|
||||
#ifdef MNG_STRICT_ANSI
|
||||
#undef MNG_STRICT_ANSI /* can't do strict-ANSI with this DLL-stuff */
|
||||
#endif
|
||||
#else
|
||||
#define MNG_DECL /* dummies for non-DLL */
|
||||
#define MNG_EXT
|
||||
#endif /* MNG_DLL && WIN32 */
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* now force ANSI-C from here on */
|
||||
#endif
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if USHRT_MAX == 0xffffffffU /* get the proper 32-bit width !!! */
|
||||
typedef unsigned short mng_uint32;
|
||||
typedef signed short mng_int32;
|
||||
#elif UINT_MAX == 0xffffffffU
|
||||
typedef unsigned int mng_uint32;
|
||||
typedef signed int mng_int32;
|
||||
#elif ULONG_MAX == 0xffffffffU
|
||||
typedef unsigned long mng_uint32;
|
||||
typedef signed long mng_int32;
|
||||
#else
|
||||
#error "Sorry, I can't find any 32-bit integers on this platform."
|
||||
#endif
|
||||
|
||||
typedef signed short mng_int16; /* other basic integers */
|
||||
typedef unsigned short mng_uint16;
|
||||
typedef signed char mng_int8;
|
||||
typedef unsigned char mng_uint8;
|
||||
|
||||
typedef double mng_float; /* basic float */
|
||||
|
||||
typedef size_t mng_size_t; /* size field for memory allocation */
|
||||
|
||||
typedef char * mng_pchar; /* string */
|
||||
typedef void * mng_ptr; /* generic pointer */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * Platform-independant from here * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
typedef mng_uint32 * mng_uint32p; /* pointer to unsigned longs */
|
||||
typedef mng_int32 * mng_int32p; /* pointer to longs */
|
||||
typedef mng_uint16 * mng_uint16p; /* pointer to unsigned words */
|
||||
typedef mng_uint8 * mng_uint8p; /* pointer to unsigned bytes */
|
||||
|
||||
typedef mng_int8 mng_bool; /* booleans */
|
||||
|
||||
struct mng_data_struct;
|
||||
typedef struct mng_data_struct * mng_handle; /* generic handle */
|
||||
|
||||
typedef mng_int32 mng_retcode; /* generic return code */
|
||||
typedef mng_int32 mng_chunkid; /* 4-byte chunkname identifier */
|
||||
typedef mng_ptr mng_chunkp; /* pointer to a chunk-structure */
|
||||
typedef mng_ptr mng_objectp; /* pointer to an object-structure */
|
||||
|
||||
typedef mng_chunkid * mng_chunkidp; /* pointer to chunkid */
|
||||
|
||||
typedef struct { /* 8-bit palette element */
|
||||
mng_uint8 iRed;
|
||||
mng_uint8 iGreen;
|
||||
mng_uint8 iBlue;
|
||||
} mng_palette8e;
|
||||
typedef mng_palette8e mng_palette8[256]; /* 8-bit palette */
|
||||
typedef mng_palette8e * mng_palette8ep;
|
||||
|
||||
typedef mng_uint8 mng_uint8arr[256]; /* generic arrays */
|
||||
typedef mng_uint8 mng_uint8arr4[4];
|
||||
typedef mng_uint16 mng_uint16arr[256];
|
||||
typedef mng_uint32 mng_uint32arr2[2];
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#define MNG_FALSE 0
|
||||
#define MNG_TRUE 1
|
||||
#define MNG_NULL 0
|
||||
|
||||
#define MNG_SUSPENDBUFFERSIZE 32768
|
||||
#define MNG_SUSPENDREQUESTSIZE 1024
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_ZLIB
|
||||
|
||||
/* size of temporary zlib buffer for deflate processing */
|
||||
#define MNG_ZLIB_MAXBUF 8192
|
||||
|
||||
/* default zlib compression parameters for deflateinit2 */
|
||||
#define MNG_ZLIB_LEVEL 9 /* level */
|
||||
#define MNG_ZLIB_METHOD Z_DEFLATED /* method */
|
||||
#define MNG_ZLIB_WINDOWBITS 15 /* window size */
|
||||
#define MNG_ZLIB_MEMLEVEL 9 /* memory level */
|
||||
#define MNG_ZLIB_STRATEGY Z_DEFAULT_STRATEGY /* strategy */
|
||||
|
||||
#define MNG_MAX_IDAT_SIZE 4096 /* maximum size of IDAT data */
|
||||
|
||||
#endif /* MNG_INCLUDE_ZLIB */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_JNG
|
||||
|
||||
#ifdef MNG_INCLUDE_IJG6B /* IJG helper defs */
|
||||
typedef struct jpeg_compress_struct mngjpeg_comp;
|
||||
typedef struct jpeg_decompress_struct mngjpeg_decomp;
|
||||
typedef struct jpeg_error_mgr mngjpeg_error;
|
||||
typedef struct jpeg_source_mgr mngjpeg_source;
|
||||
|
||||
typedef mngjpeg_comp * mngjpeg_compp;
|
||||
typedef mngjpeg_decomp * mngjpeg_decompp;
|
||||
typedef mngjpeg_error * mngjpeg_errorp;
|
||||
typedef mngjpeg_source * mngjpeg_sourcep;
|
||||
|
||||
typedef J_DCT_METHOD mngjpeg_dctmethod;
|
||||
|
||||
/* default IJG parameters for compression */
|
||||
#define MNG_JPEG_DCT JDCT_DEFAULT /* DCT algorithm (JDCT_ISLOW) */
|
||||
#define MNG_JPEG_QUALITY 100 /* quality 0..100; 100=best */
|
||||
#define MNG_JPEG_SMOOTHING 0 /* default no smoothing */
|
||||
#define MNG_JPEG_PROGRESSIVE MNG_FALSE /* default is just baseline */
|
||||
#define MNG_JPEG_OPTIMIZED MNG_FALSE /* default is not optimized */
|
||||
#endif /* MNG_INCLUDE_IJG6B */
|
||||
|
||||
#define MNG_JPEG_MAXBUF 65500 /* max size of temp JPEG buffer */
|
||||
#define MNG_MAX_JDAT_SIZE 4096 /* maximum size of JDAT data */
|
||||
|
||||
#endif /* MNG_INCLUDE_JNG */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_LCMS
|
||||
typedef cmsHPROFILE mng_cmsprof; /* little CMS helper defs */
|
||||
typedef cmsHTRANSFORM mng_cmstrans;
|
||||
typedef cmsCIExyY mng_CIExyY;
|
||||
typedef cmsCIExyYTRIPLE mng_CIExyYTRIPLE;
|
||||
typedef LPGAMMATABLE mng_gammatabp;
|
||||
#endif /* MNG_INCLUDE_LCMS */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
/* enumeration of known graphics types */
|
||||
enum mng_imgtypes {mng_it_unknown, mng_it_png, mng_it_mng, mng_it_jng};
|
||||
typedef enum mng_imgtypes mng_imgtype;
|
||||
|
||||
/* enumeration of animation speed-types */
|
||||
enum mng_speedtypes {mng_st_normal, mng_st_fast, mng_st_slow, mng_st_slowest};
|
||||
typedef enum mng_speedtypes mng_speedtype;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
/* memory management callbacks */
|
||||
typedef mng_ptr MNG_DECL (*mng_memalloc) (mng_size_t iLen);
|
||||
typedef void MNG_DECL (*mng_memfree) (mng_ptr iPtr,
|
||||
mng_size_t iLen);
|
||||
|
||||
/* I/O management callbacks */
|
||||
typedef mng_bool MNG_DECL (*mng_openstream) (mng_handle hHandle);
|
||||
typedef mng_bool MNG_DECL (*mng_closestream) (mng_handle hHandle);
|
||||
typedef mng_bool MNG_DECL (*mng_readdata) (mng_handle hHandle,
|
||||
mng_ptr pBuf,
|
||||
mng_uint32 iBuflen,
|
||||
mng_uint32p pRead);
|
||||
typedef mng_bool MNG_DECL (*mng_writedata) (mng_handle hHandle,
|
||||
mng_ptr pBuf,
|
||||
mng_uint32 iBuflen,
|
||||
mng_uint32p pWritten);
|
||||
|
||||
/* error & trace processing callbacks */
|
||||
typedef mng_bool MNG_DECL (*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);
|
||||
typedef mng_bool MNG_DECL (*mng_traceproc) (mng_handle hHandle,
|
||||
mng_int32 iFuncnr,
|
||||
mng_int32 iFuncseq,
|
||||
mng_pchar zFuncname);
|
||||
|
||||
/* read processing callbacks */
|
||||
typedef mng_bool MNG_DECL (*mng_processheader) (mng_handle hHandle,
|
||||
mng_uint32 iWidth,
|
||||
mng_uint32 iHeight);
|
||||
typedef mng_bool MNG_DECL (*mng_processtext) (mng_handle hHandle,
|
||||
mng_uint8 iType,
|
||||
mng_pchar zKeyword,
|
||||
mng_pchar zText,
|
||||
mng_pchar zLanguage,
|
||||
mng_pchar zTranslation);
|
||||
typedef mng_bool MNG_DECL (*mng_processsave) (mng_handle hHandle);
|
||||
typedef mng_bool MNG_DECL (*mng_processseek) (mng_handle hHandle,
|
||||
mng_pchar zName);
|
||||
|
||||
/* display processing callbacks */
|
||||
typedef mng_ptr MNG_DECL (*mng_getcanvasline) (mng_handle hHandle,
|
||||
mng_uint32 iLinenr);
|
||||
typedef mng_ptr MNG_DECL (*mng_getbkgdline) (mng_handle hHandle,
|
||||
mng_uint32 iLinenr);
|
||||
typedef mng_ptr MNG_DECL (*mng_getalphaline) (mng_handle hHandle,
|
||||
mng_uint32 iLinenr);
|
||||
typedef mng_bool MNG_DECL (*mng_refresh) (mng_handle hHandle,
|
||||
mng_uint32 iX,
|
||||
mng_uint32 iY,
|
||||
mng_uint32 iWidth,
|
||||
mng_uint32 iHeight);
|
||||
|
||||
/* timer management callbacks */
|
||||
typedef mng_uint32 MNG_DECL (*mng_gettickcount) (mng_handle hHandle);
|
||||
typedef mng_bool MNG_DECL (*mng_settimer) (mng_handle hHandle,
|
||||
mng_uint32 iMsecs);
|
||||
|
||||
/* color management callbacks */
|
||||
typedef mng_bool MNG_DECL (*mng_processgamma) (mng_handle hHandle,
|
||||
mng_uint32 iGamma);
|
||||
typedef mng_bool MNG_DECL (*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);
|
||||
typedef mng_bool MNG_DECL (*mng_processsrgb) (mng_handle hHandle,
|
||||
mng_uint8 iRenderingintent);
|
||||
typedef mng_bool MNG_DECL (*mng_processiccp) (mng_handle hHandle,
|
||||
mng_uint32 iProfilesize,
|
||||
mng_ptr pProfile);
|
||||
typedef mng_bool MNG_DECL (*mng_processarow) (mng_handle hHandle,
|
||||
mng_uint32 iRowsamples,
|
||||
mng_bool bIsRGBA16,
|
||||
mng_ptr pRow);
|
||||
|
||||
/* chunk access callback(s) */
|
||||
typedef mng_bool MNG_DECL (*mng_iteratechunk) (mng_handle hHandle,
|
||||
mng_handle hChunk,
|
||||
mng_chunkid iChunkid,
|
||||
mng_uint32 iChunkseq);
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* _libmng_types_h_ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_write.c copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : Write management (implementation) * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : implementation of the write management routines * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * 0.5.1 - 05/12/2000 - G.Juyn * */
|
||||
/* * - changed trace to macro for callback error-reporting * */
|
||||
/* * 0.5.1 - 05/16/2000 - G.Juyn * */
|
||||
/* * - moved the actual write_graphic functionality from * */
|
||||
/* * mng_hlapi to it's appropriate function here * */
|
||||
/* * * */
|
||||
/* * 0.9.1 - 07/19/2000 - G.Juyn * */
|
||||
/* * - fixed writing of signature * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libmng.h"
|
||||
#include "libmng_data.h"
|
||||
#include "libmng_error.h"
|
||||
#include "libmng_trace.h"
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
#include "libmng_memory.h"
|
||||
#include "libmng_chunks.h"
|
||||
#include "libmng_chunk_io.h"
|
||||
#include "libmng_write.h"
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* force ANSI-C */
|
||||
#endif
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_WRITE_PROCS
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode write_graphic (mng_datap pData)
|
||||
{
|
||||
mng_chunkp pChunk;
|
||||
mng_retcode iRetcode;
|
||||
mng_uint32 iWritten;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_WRITE_GRAPHIC, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
pChunk = pData->pFirstchunk; /* we'll start with the first, thank you */
|
||||
|
||||
if (pChunk) /* is there anything to write ? */
|
||||
{ /* open the file */
|
||||
if (!pData->fOpenstream ((mng_handle)pData))
|
||||
MNG_ERROR (pData, MNG_APPIOERROR)
|
||||
else
|
||||
{
|
||||
pData->bWriting = MNG_TRUE; /* indicate writing */
|
||||
pData->iWritebufsize = 32768; /* get a temporary write buffer */
|
||||
/* reserve 12 bytes for length, chunkname & crc */
|
||||
MNG_ALLOC (pData, pData->pWritebuf, pData->iWritebufsize+12)
|
||||
/* write the signature */
|
||||
if (((mng_chunk_headerp)pChunk)->iChunkname == MNG_UINT_IHDR)
|
||||
mng_put_uint32 (pData->pWritebuf, PNG_SIG);
|
||||
else
|
||||
if (((mng_chunk_headerp)pChunk)->iChunkname == MNG_UINT_JHDR)
|
||||
mng_put_uint32 (pData->pWritebuf, JNG_SIG);
|
||||
else
|
||||
mng_put_uint32 (pData->pWritebuf, MNG_SIG);
|
||||
|
||||
mng_put_uint32 (pData->pWritebuf+4, POST_SIG);
|
||||
|
||||
if (!pData->fWritedata ((mng_handle)pData, pData->pWritebuf, 8, &iWritten))
|
||||
{
|
||||
MNG_FREE (pData, pData->pWritebuf, pData->iWritebufsize+12)
|
||||
MNG_ERROR (pData, MNG_APPIOERROR)
|
||||
}
|
||||
|
||||
if (iWritten != 8) /* disk full ? */
|
||||
{
|
||||
MNG_FREE (pData, pData->pWritebuf, pData->iWritebufsize+12)
|
||||
MNG_ERROR (pData, MNG_OUTPUTERROR)
|
||||
}
|
||||
|
||||
while (pChunk) /* so long as there's something to write */
|
||||
{ /* let's call it's output routine */
|
||||
iRetcode = ((mng_chunk_headerp)pChunk)->fWrite (pData, pChunk);
|
||||
|
||||
if (iRetcode) /* on error bail out */
|
||||
{
|
||||
MNG_FREE (pData, pData->pWritebuf, pData->iWritebufsize+12)
|
||||
return iRetcode;
|
||||
}
|
||||
/* neeeext */
|
||||
pChunk = ((mng_chunk_headerp)pChunk)->pNext;
|
||||
}
|
||||
/* free the temporary buffer */
|
||||
MNG_FREE (pData, pData->pWritebuf, pData->iWritebufsize+12)
|
||||
|
||||
pData->bWriting = MNG_FALSE; /* done writing */
|
||||
/* close the stream now */
|
||||
if (!pData->fClosestream ((mng_handle)pData))
|
||||
MNG_ERROR (pData, MNG_APPIOERROR)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_WRITE_GRAPHIC, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* MNG_INCLUDE_WRITE_PROCS */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_write.h copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : Write management (definition) * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : Definition of the write management routines * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* force ANSI-C */
|
||||
#endif
|
||||
|
||||
#ifndef _libmng_write_h_
|
||||
#define _libmng_write_h_
|
||||
|
||||
#include "libmng.h"
|
||||
#include "libmng_data.h"
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode write_graphic (mng_datap pData);
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* _libmng_write_h_ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
|
@ -0,0 +1,427 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_zlib.c copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : ZLIB library interface (implementation) * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : implementation of the ZLIB library interface * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * 0.5.1 - 05/11/2000 - G.Juyn * */
|
||||
/* * - filled the deflatedata routine * */
|
||||
/* * 0.5.1 - 05/12/2000 - G.Juyn * */
|
||||
/* * - changed trace to macro for callback error-reporting * */
|
||||
/* * * */
|
||||
/* * 0.5.2 - 05/20/2000 - G.Juyn * */
|
||||
/* * - fixed for JNG alpha handling * */
|
||||
/* * 0.5.2 - 05/24/2000 - G.Juyn * */
|
||||
/* * - moved init of default zlib parms from here to * */
|
||||
/* * "mng_hlapi.c" * */
|
||||
/* * * */
|
||||
/* * 0.5.3 - 06/16/2000 - G.Juyn * */
|
||||
/* * - changed progressive-display processing * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#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_pixels.h"
|
||||
#include "libmng_filter.h"
|
||||
#include "libmng_zlib.h"
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* force ANSI-C */
|
||||
#endif
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_INCLUDE_ZLIB
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
voidpf mngzlib_alloc (voidpf pData,
|
||||
uInt iCount,
|
||||
uInt iSize)
|
||||
{
|
||||
voidpf pPtr; /* temporary space */
|
||||
|
||||
#ifdef MNG_INTERNAL_MEMMNGMT
|
||||
pPtr = calloc (iCount, iSize); /* local allocation */
|
||||
#else
|
||||
if (((mng_datap)pData)->fMemalloc) /* callback function set ? */
|
||||
pPtr = ((mng_datap)pData)->fMemalloc (iCount * iSize);
|
||||
else
|
||||
pPtr = Z_NULL; /* can't allocate! */
|
||||
#endif
|
||||
|
||||
return pPtr; /* return the result */
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
void mngzlib_free (voidpf pData,
|
||||
voidpf pAddress)
|
||||
{
|
||||
#ifdef MNG_INTERNAL_MEMMNGMT
|
||||
free (pAddress); /* free locally */
|
||||
#else
|
||||
if (((mng_datap)pData)->fMemfree) /* callback set? */
|
||||
((mng_datap)pData)->fMemfree (pAddress, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode mngzlib_initialize (mng_datap pData)
|
||||
{
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_ZLIB_INITIALIZE, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
#ifdef MNG_INTERNAL_MEMMNGMT
|
||||
pData->sZlib.zalloc = Z_NULL; /* let zlib figure out memory management */
|
||||
pData->sZlib.zfree = Z_NULL;
|
||||
pData->sZlib.opaque = Z_NULL;
|
||||
#else /* use user-provided callbacks */
|
||||
pData->sZlib.zalloc = mngzlib_alloc;
|
||||
pData->sZlib.zfree = mngzlib_free;
|
||||
pData->sZlib.opaque = (voidpf)pData;
|
||||
#endif
|
||||
|
||||
pData->bInflating = MNG_FALSE; /* not performing any action yet */
|
||||
pData->bDeflating = MNG_FALSE;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_ZLIB_INITIALIZE, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR; /* done */
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode mngzlib_cleanup (mng_datap pData)
|
||||
{
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_ZLIB_CLEANUP, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
if (pData->bInflating) /* force zlib cleanup */
|
||||
mngzlib_inflatefree (pData);
|
||||
if (pData->bDeflating)
|
||||
mngzlib_deflatefree (pData);
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_ZLIB_CLEANUP, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR; /* done */
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode mngzlib_inflateinit (mng_datap pData)
|
||||
{
|
||||
uInt iZrslt;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_ZLIB_INFLATEINIT, MNG_LC_START)
|
||||
#endif
|
||||
/* initialize zlib structures and such */
|
||||
iZrslt = inflateInit (&pData->sZlib);
|
||||
|
||||
if (iZrslt != Z_OK) /* on error bail out */
|
||||
MNG_ERRORZ (pData, (mng_uint32)iZrslt)
|
||||
|
||||
pData->bInflating = MNG_TRUE; /* really inflating something now */
|
||||
pData->sZlib.next_out = 0; /* force JIT initialization */
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_ZLIB_INFLATEINIT, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR; /* done */
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifdef MNG_SUPPORT_DISPLAY
|
||||
mng_retcode mngzlib_inflaterows (mng_datap pData,
|
||||
mng_uint32 iInlen,
|
||||
mng_uint8p pIndata)
|
||||
{
|
||||
uInt iZrslt;
|
||||
mng_retcode iRslt;
|
||||
mng_ptr pSwap;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_ZLIB_INFLATEROWS, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
pData->sZlib.next_in = pIndata; /* let zlib know where to get stuff */
|
||||
pData->sZlib.avail_in = (uInt)iInlen;
|
||||
|
||||
if (pData->sZlib.next_out == 0) /* initialize output variables ? */
|
||||
{ /* let zlib know where to store stuff */
|
||||
pData->sZlib.next_out = pData->pWorkrow;
|
||||
pData->sZlib.avail_out = (uInt)(pData->iRowsize + 1);
|
||||
}
|
||||
|
||||
do
|
||||
{ /* now inflate a row */
|
||||
iZrslt = inflate (&pData->sZlib, Z_SYNC_FLUSH);
|
||||
/* produced a full row ? */
|
||||
if (((iZrslt == Z_OK) || (iZrslt == Z_STREAM_END)) &&
|
||||
(pData->sZlib.avail_out == 0))
|
||||
{ /* shouldn't we be at the end ? */
|
||||
if (pData->iRow >= (mng_int32)pData->iDataheight)
|
||||
/* MNG_ERROR (pData, MNG_TOOMUCHIDAT) */ ;
|
||||
else
|
||||
{ /* filter the row if necessary */
|
||||
if (pData->pWorkrow[0])
|
||||
iRslt = filter_a_row (pData);
|
||||
else
|
||||
iRslt = MNG_NOERROR;
|
||||
|
||||
if (!iRslt)
|
||||
{
|
||||
#ifdef MNG_INCLUDE_JNG
|
||||
if (pData->bHasJHDR) /* is JNG alpha-channel ? */
|
||||
{ /* just store in object ? */
|
||||
if ((!iRslt) && (pData->fStorerow))
|
||||
iRslt = ((mng_storerow)pData->fStorerow) (pData);
|
||||
}
|
||||
else
|
||||
#endif /* MNG_INCLUDE_JNG */
|
||||
{ /* process this row */
|
||||
if ((!iRslt) && (pData->fProcessrow))
|
||||
iRslt = ((mng_processrow)pData->fProcessrow) (pData);
|
||||
/* store in object ? */
|
||||
if ((!iRslt) && (pData->fStorerow))
|
||||
iRslt = ((mng_storerow)pData->fStorerow) (pData);
|
||||
/* color correction ? */
|
||||
if ((!iRslt) && (pData->fCorrectrow))
|
||||
iRslt = ((mng_correctrow)pData->fCorrectrow) (pData);
|
||||
/* slap onto canvas ? */
|
||||
if ((!iRslt) && (pData->fDisplayrow))
|
||||
{
|
||||
iRslt = ((mng_displayrow)pData->fDisplayrow) (pData);
|
||||
|
||||
if (!iRslt) /* check progressive display refresh */
|
||||
iRslt = display_progressive_check (pData);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (iRslt) /* on error bail out */
|
||||
MNG_ERROR (pData, iRslt);
|
||||
/* swap row-pointers */
|
||||
pSwap = pData->pWorkrow;
|
||||
pData->pWorkrow = pData->pPrevrow;
|
||||
pData->pPrevrow = pSwap; /* so prev points to the processed row! */
|
||||
|
||||
iRslt = next_row (pData); /* adjust variables for next row */
|
||||
|
||||
if (iRslt) /* on error bail out */
|
||||
MNG_ERROR (pData, iRslt);
|
||||
}
|
||||
/* let zlib know where to store next output */
|
||||
pData->sZlib.next_out = pData->pWorkrow;
|
||||
pData->sZlib.avail_out = (uInt)(pData->iRowsize + 1);
|
||||
}
|
||||
} /* until some error or EOI */
|
||||
while ((iZrslt == Z_OK) && (pData->sZlib.avail_in > 0));
|
||||
/* on error bail out */
|
||||
if ((iZrslt != Z_OK) && (iZrslt != Z_STREAM_END))
|
||||
MNG_ERRORZ (pData, (mng_uint32)iZrslt)
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_ZLIB_INFLATEROWS, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
#endif /* MNG_SUPPORT_DISPLAY */
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode mngzlib_inflatedata (mng_datap pData,
|
||||
mng_uint32 iInlen,
|
||||
mng_uint8p pIndata)
|
||||
{
|
||||
uInt iZrslt;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_ZLIB_INFLATEDATA, MNG_LC_START)
|
||||
#endif
|
||||
/* let zlib know where to get stuff */
|
||||
pData->sZlib.next_in = pIndata;
|
||||
pData->sZlib.avail_in = (uInt)iInlen;
|
||||
/* now inflate the data in one go! */
|
||||
iZrslt = inflate (&pData->sZlib, Z_FINISH);
|
||||
/* not enough room in output-buffer ? */
|
||||
if ((iZrslt == Z_BUF_ERROR) || (pData->sZlib.avail_in > 0))
|
||||
return MNG_BUFOVERFLOW;
|
||||
/* on error bail out */
|
||||
if ((iZrslt != Z_OK) && (iZrslt != Z_STREAM_END))
|
||||
MNG_ERRORZ (pData, (mng_uint32)iZrslt)
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_ZLIB_INFLATEDATA, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode mngzlib_inflatefree (mng_datap pData)
|
||||
{
|
||||
uInt iZrslt;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_ZLIB_INFLATEFREE, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
pData->bInflating = MNG_FALSE; /* stopped it */
|
||||
|
||||
iZrslt = inflateEnd (&pData->sZlib); /* let zlib cleanup it's own stuff */
|
||||
|
||||
if (iZrslt != Z_OK) /* on error bail out */
|
||||
MNG_ERRORZ (pData, (mng_uint32)iZrslt)
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_ZLIB_INFLATEFREE, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR; /* done */
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode mngzlib_deflateinit (mng_datap pData)
|
||||
{
|
||||
uInt iZrslt;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_ZLIB_DEFLATEINIT, MNG_LC_START)
|
||||
#endif
|
||||
/* initialize zlib structures and such */
|
||||
iZrslt = deflateInit2 (&pData->sZlib, pData->iZlevel, pData->iZmethod,
|
||||
pData->iZwindowbits, pData->iZmemlevel,
|
||||
pData->iZstrategy);
|
||||
|
||||
if (iZrslt != Z_OK) /* on error bail out */
|
||||
MNG_ERRORZ (pData, (mng_uint32)iZrslt)
|
||||
|
||||
pData->bDeflating = MNG_TRUE; /* really deflating something now */
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_ZLIB_DEFLATEINIT, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR; /* done */
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode mngzlib_deflaterows (mng_datap pData,
|
||||
mng_uint32 iInlen,
|
||||
mng_uint8p pIndata)
|
||||
{
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_ZLIB_DEFLATEROWS, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_ZLIB_DEFLATEROWS, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode mngzlib_deflatedata (mng_datap pData,
|
||||
mng_uint32 iInlen,
|
||||
mng_uint8p pIndata)
|
||||
{
|
||||
uInt iZrslt;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_ZLIB_DEFLATEDATA, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
pData->sZlib.next_in = pIndata; /* let zlib know where to get stuff */
|
||||
pData->sZlib.avail_in = (uInt)iInlen;
|
||||
/* now deflate the data in one go! */
|
||||
iZrslt = deflate (&pData->sZlib, Z_FINISH);
|
||||
/* not enough room in output-buffer ? */
|
||||
if ((iZrslt == Z_BUF_ERROR) || (pData->sZlib.avail_in > 0))
|
||||
return MNG_BUFOVERFLOW;
|
||||
/* on error bail out */
|
||||
if ((iZrslt != Z_OK) && (iZrslt != Z_STREAM_END))
|
||||
MNG_ERRORZ (pData, (mng_uint32)iZrslt)
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_ZLIB_DEFLATEDATA, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode mngzlib_deflatefree (mng_datap pData)
|
||||
{
|
||||
uInt iZrslt;
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_ZLIB_DEFLATEFREE, MNG_LC_START)
|
||||
#endif
|
||||
|
||||
iZrslt = deflateEnd (&pData->sZlib); /* let zlib cleanup it's own stuff */
|
||||
|
||||
if (iZrslt != Z_OK) /* on error bail out */
|
||||
MNG_ERRORZ (pData, (mng_uint32)iZrslt)
|
||||
|
||||
pData->bDeflating = MNG_FALSE; /* stopped it */
|
||||
|
||||
#ifdef MNG_SUPPORT_TRACE
|
||||
MNG_TRACE (pData, MNG_FN_ZLIB_DEFLATEFREE, MNG_LC_END)
|
||||
#endif
|
||||
|
||||
return MNG_NOERROR; /* done */
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* MNG_INCLUDE_ZLIB */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
/* ************************************************************************** */
|
||||
/* * For conditions of distribution and use, * */
|
||||
/* * see copyright notice in libmng.h * */
|
||||
/* ************************************************************************** */
|
||||
/* * * */
|
||||
/* * project : libmng * */
|
||||
/* * file : libmng_zlib.h copyright (c) 2000 G.Juyn * */
|
||||
/* * version : 0.9.2 * */
|
||||
/* * * */
|
||||
/* * purpose : ZLIB package interface (definition) * */
|
||||
/* * * */
|
||||
/* * author : G.Juyn * */
|
||||
/* * web : http://www.3-t.com * */
|
||||
/* * email : mailto:info@3-t.com * */
|
||||
/* * * */
|
||||
/* * comment : Definition of the ZLIB package interface * */
|
||||
/* * * */
|
||||
/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */
|
||||
/* * - changed strict-ANSI stuff * */
|
||||
/* * * */
|
||||
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
||||
/* * - changed file-prefixes * */
|
||||
/* * * */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
||||
#pragma option -A /* force ANSI-C */
|
||||
#endif
|
||||
|
||||
#ifndef _libmng_zlib_h_
|
||||
#define _libmng_zlib_h_
|
||||
|
||||
#include "libmng.h"
|
||||
#include "libmng_data.h"
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
mng_retcode mngzlib_initialize (mng_datap pData);
|
||||
mng_retcode mngzlib_cleanup (mng_datap pData);
|
||||
|
||||
mng_retcode mngzlib_inflateinit (mng_datap pData);
|
||||
mng_retcode mngzlib_inflaterows (mng_datap pData,
|
||||
mng_uint32 iInlen,
|
||||
mng_uint8p pIndata);
|
||||
mng_retcode mngzlib_inflatedata (mng_datap pData,
|
||||
mng_uint32 iInlen,
|
||||
mng_uint8p pIndata);
|
||||
mng_retcode mngzlib_inflatefree (mng_datap pData);
|
||||
|
||||
mng_retcode mngzlib_deflateinit (mng_datap pData);
|
||||
mng_retcode mngzlib_deflaterows (mng_datap pData,
|
||||
mng_uint32 iInlen,
|
||||
mng_uint8p pIndata);
|
||||
mng_retcode mngzlib_deflatedata (mng_datap pData,
|
||||
mng_uint32 iInlen,
|
||||
mng_uint8p pIndata);
|
||||
mng_retcode mngzlib_deflatefree (mng_datap pData);
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#endif /* _libmng_zlib_h_ */
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* * end of file * */
|
||||
/* ************************************************************************** */
|
|
@ -32,51 +32,51 @@ MAKE_OBJ_TYPE=LIB
|
|||
LCFLAGS = $(LCFLAGS) -DDEBUG_GC
|
||||
!endif
|
||||
|
||||
EXPORTS = libmng.h mng_conf.h mng_types.h
|
||||
EXPORTS = libmng.h libmng_conf.h libmng_types.h
|
||||
|
||||
MODULE=mng
|
||||
DEPTH=..\..\..
|
||||
LOCAL_INCLUDES=-I.
|
||||
LIBRARY_NAME=mng
|
||||
CSRCS=\
|
||||
mng_callback_xs.c \
|
||||
mng_chunk_io.c \
|
||||
mng_chunk_prc.c \
|
||||
mng_chunk_xs.c \
|
||||
mng_cms.c \
|
||||
mng_display.c \
|
||||
mng_dither.c \
|
||||
mng_error.c \
|
||||
mng_filter.c \
|
||||
mng_hlapi.c \
|
||||
mng_jpeg.c \
|
||||
mng_object_prc.c \
|
||||
mng_pixels.c \
|
||||
mng_prop_xs.c \
|
||||
mng_read.c \
|
||||
mng_trace.c \
|
||||
mng_write.c \
|
||||
mng_zlib.c \
|
||||
libmng_callback_xs.c \
|
||||
libmng_chunk_io.c \
|
||||
libmng_chunk_prc.c \
|
||||
libmng_chunk_xs.c \
|
||||
libmng_cms.c \
|
||||
libmng_display.c \
|
||||
libmng_dither.c \
|
||||
libmng_error.c \
|
||||
libmng_filter.c \
|
||||
libmng_hlapi.c \
|
||||
libmng_jpeg.c \
|
||||
libmng_object_prc.c \
|
||||
libmng_pixels.c \
|
||||
libmng_prop_xs.c \
|
||||
libmng_read.c \
|
||||
libmng_trace.c \
|
||||
libmng_write.c \
|
||||
libmng_zlib.c \
|
||||
$(NULL)
|
||||
C_OBJS=\
|
||||
.\$(OBJDIR)\mng_callback_xs.obj \
|
||||
.\$(OBJDIR)\mng_chunk_io.obj \
|
||||
.\$(OBJDIR)\mng_chunk_prc.obj \
|
||||
.\$(OBJDIR)\mng_chunk_xs.obj \
|
||||
.\$(OBJDIR)\mng_cms.obj \
|
||||
.\$(OBJDIR)\mng_display.obj \
|
||||
.\$(OBJDIR)\mng_dither.obj \
|
||||
.\$(OBJDIR)\mng_error.obj \
|
||||
.\$(OBJDIR)\mng_filter.obj \
|
||||
.\$(OBJDIR)\mng_hlapi.obj \
|
||||
.\$(OBJDIR)\mng_jpeg.obj \
|
||||
.\$(OBJDIR)\mng_object_prc.obj \
|
||||
.\$(OBJDIR)\mng_pixels.obj \
|
||||
.\$(OBJDIR)\mng_prop_xs.obj \
|
||||
.\$(OBJDIR)\mng_read.obj \
|
||||
.\$(OBJDIR)\mng_trace.obj \
|
||||
.\$(OBJDIR)\mng_write.obj \
|
||||
.\$(OBJDIR)\mng_zlib.obj \
|
||||
.\$(OBJDIR)\libmng_callback_xs.obj \
|
||||
.\$(OBJDIR)\libmng_chunk_io.obj \
|
||||
.\$(OBJDIR)\libmng_chunk_prc.obj \
|
||||
.\$(OBJDIR)\libmng_chunk_xs.obj \
|
||||
.\$(OBJDIR)\libmng_cms.obj \
|
||||
.\$(OBJDIR)\libmng_display.obj \
|
||||
.\$(OBJDIR)\libmng_dither.obj \
|
||||
.\$(OBJDIR)\libmng_error.obj \
|
||||
.\$(OBJDIR)\libmng_filter.obj \
|
||||
.\$(OBJDIR)\libmng_hlapi.obj \
|
||||
.\$(OBJDIR)\libmng_jpeg.obj \
|
||||
.\$(OBJDIR)\libmng_object_prc.obj \
|
||||
.\$(OBJDIR)\libmng_pixels.obj \
|
||||
.\$(OBJDIR)\libmng_prop_xs.obj \
|
||||
.\$(OBJDIR)\libmng_read.obj \
|
||||
.\$(OBJDIR)\libmng_trace.obj \
|
||||
.\$(OBJDIR)\libmng_write.obj \
|
||||
.\$(OBJDIR)\libmng_zlib.obj \
|
||||
$(NULL)
|
||||
!if "$(MOZ_BITS)" != "16"
|
||||
LINCS=-I$(XPDIST)\public\util -I$(XPDIST)\public\nspr \
|
||||
|
|
|
@ -36,9 +36,6 @@
|
|||
#define CHANNELS 4
|
||||
#endif
|
||||
|
||||
// Decrease this to a sane value after this bug is fixed:
|
||||
// http://bugzilla.mozilla.org/show_bug.cgi?id=41831
|
||||
#define MOZ_MNG_BUFSIZE 262144
|
||||
|
||||
typedef struct ipng_str {
|
||||
|
||||
|
@ -50,12 +47,12 @@ typedef struct ipng_str {
|
|||
|
||||
void *timer_id;
|
||||
|
||||
PRUint8 writeBuffer[MOZ_MNG_BUFSIZE]; /* Circular buffer */
|
||||
PRUint32 bytesBuffered;
|
||||
PRUint32 writeStart;
|
||||
PRUint8 *writeBuffer; /* Bugzilla 41831 */
|
||||
PRUint32 bufferSize;
|
||||
PRUint32 bufferEnd;
|
||||
PRUint32 bufferPtr;
|
||||
|
||||
PRUint32 bytesNeeded; /* number of bytes libmng wants (to know when */
|
||||
/* we can call read_resume) */
|
||||
PRBool resumeNeeded; /* need to call display_resume? */
|
||||
|
||||
il_container *ic;
|
||||
|
||||
|
@ -94,27 +91,15 @@ il_mng_readdata(mng_handle handle, mng_ptr buf,
|
|||
{
|
||||
EXTRACT_STRUCTS;
|
||||
|
||||
if (imng_p->bytesBuffered >= size) {
|
||||
PRUint32 endChunk = (MOZ_MNG_BUFSIZE-imng_p->writeStart);
|
||||
dprintf((stderr, "MNG::readdata size=%d buffered=%d\n",
|
||||
size, imng_p->bufferEnd - imng_p->bufferPtr));
|
||||
|
||||
memcpy(buf, imng_p->writeBuffer+imng_p->writeStart,
|
||||
PR_MIN(endChunk, size));
|
||||
|
||||
if (endChunk < size)
|
||||
memcpy((PRUint8 *)buf+endChunk, imng_p->writeBuffer, size-endChunk);
|
||||
|
||||
imng_p->bytesBuffered -= size;
|
||||
imng_p->writeStart = (imng_p->writeStart+size) % MOZ_MNG_BUFSIZE;
|
||||
imng_p->bytesNeeded = 0;
|
||||
size = PR_MIN(size, imng_p->bufferEnd - imng_p->bufferPtr);
|
||||
memcpy(buf, imng_p->writeBuffer+imng_p->bufferPtr, size);
|
||||
imng_p->bufferPtr += size;
|
||||
*stored = size;
|
||||
|
||||
*stored = size;
|
||||
return MNG_TRUE;
|
||||
} else {
|
||||
imng_p->bytesNeeded = size;
|
||||
|
||||
*stored = 0;
|
||||
return MNG_FALSE;
|
||||
}
|
||||
return MNG_TRUE;
|
||||
}
|
||||
|
||||
static mng_bool
|
||||
|
@ -203,7 +188,12 @@ il_mng_timeout_func(void *data)
|
|||
// dprintf((stderr, "il_mng_timeout_func\n"));
|
||||
|
||||
imng_p->timer_id = 0;
|
||||
mng_display_resume(handle);
|
||||
|
||||
int ret = mng_display_resume(handle);
|
||||
if (ret == MNG_NEEDMOREDATA)
|
||||
imng_p->resumeNeeded = PR_TRUE;
|
||||
|
||||
// dprintf((stderr, "il_mng_timeout_func display_resume returned %d\n", ret));
|
||||
}
|
||||
|
||||
static mng_bool
|
||||
|
@ -234,6 +224,22 @@ il_mng_free(mng_ptr ptr, mng_size_t size)
|
|||
nsMemory::Free(ptr);
|
||||
}
|
||||
|
||||
static mng_bool
|
||||
il_mng_trace(mng_handle handle, mng_int32 iFuncnr, mng_int32 iFuncseq,
|
||||
mng_pchar zFuncname)
|
||||
{
|
||||
dprintf((stderr, "== trace == %s %d %d\n", zFuncname, iFuncnr, iFuncseq));
|
||||
return MNG_TRUE;
|
||||
}
|
||||
|
||||
static mng_bool
|
||||
il_mng_error(mng_handle hHandle, mng_int32 iErrorcode, mng_int8 iSeverity,
|
||||
mng_chunkid iChunkname, mng_uint32 iChunkseq, mng_int32 iExtra1,
|
||||
mng_int32 iExtra2, mng_pchar zErrortext)
|
||||
{
|
||||
dprintf((stderr, "== error == %s\n", zErrortext));
|
||||
return MNG_TRUE;
|
||||
}
|
||||
|
||||
// Boilerplate methods... *yawn*
|
||||
//===========================================================
|
||||
|
@ -287,9 +293,12 @@ MNGDecoder::ImgDInit()
|
|||
if( ilContainer != NULL ) {
|
||||
imng_structp imng_p;
|
||||
imng_p = (imng_structp) nsMemory::Alloc(sizeof(imng_struct));
|
||||
memset(imng_p, 0, sizeof(imng_struct));
|
||||
if (!imng_p)
|
||||
return PR_FALSE;
|
||||
memset(imng_p, 0, sizeof(imng_struct));
|
||||
|
||||
imng_p->writeBuffer = (PRUint8 *)nsMemory::Alloc(4096);
|
||||
imng_p->bufferSize = 4096;
|
||||
|
||||
ilContainer->image->header.width = ilContainer->dest_width;
|
||||
ilContainer->image->header.height = ilContainer->dest_height;
|
||||
|
@ -351,8 +360,10 @@ MNGDecoder::ImgDInit()
|
|||
mng_setcb_settimer(imng_p->handle, il_mng_settimer);
|
||||
mng_setcb_memalloc(imng_p->handle, il_mng_alloc);
|
||||
mng_setcb_memfree(imng_p->handle, il_mng_free);
|
||||
mng_set_suspensionmode(imng_p->handle, MNG_TRUE);
|
||||
|
||||
mng_readdisplay(imng_p->handle);
|
||||
if (mng_readdisplay(imng_p->handle) == MNG_NEEDMOREDATA)
|
||||
imng_p->resumeNeeded = PR_TRUE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -365,7 +376,7 @@ MNGDecoder::ImgDWriteReady(PRUint32 *max_read)
|
|||
|
||||
imng_structp imng_p = (imng_structp)ilContainer->ds;
|
||||
|
||||
*max_read = MOZ_MNG_BUFSIZE-imng_p->bytesBuffered;
|
||||
*max_read = imng_p->bufferSize - imng_p->bufferEnd;
|
||||
|
||||
dprintf((stderr, "%d\n", *max_read));
|
||||
|
||||
|
@ -380,24 +391,24 @@ MNGDecoder::ImgDWrite(const unsigned char *buf, int32 len)
|
|||
|
||||
if (ilContainer != NULL) {
|
||||
imng_structp imng_p = (imng_structp)ilContainer->ds;
|
||||
|
||||
if (PRUint32(len)>MOZ_MNG_BUFSIZE-imng_p->bytesBuffered) {
|
||||
fprintf(stderr, "MNG too large - abort, abort!\n");
|
||||
fprintf(stderr, " http://bugzilla.mozilla.org/show_bug.cgi?id=41831\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (imng_p->bufferEnd+len > imng_p->bufferSize) {
|
||||
imng_p->bufferSize *= 2;
|
||||
imng_p->writeBuffer = (PRUint8 *)
|
||||
nsMemory::Realloc(imng_p->writeBuffer, imng_p->bufferSize);
|
||||
}
|
||||
|
||||
int32 endChunk =
|
||||
(MOZ_MNG_BUFSIZE-(imng_p->writeStart+imng_p->bytesBuffered));
|
||||
memcpy(imng_p->writeBuffer+imng_p->writeStart+imng_p->bytesBuffered,
|
||||
buf, PR_MIN(endChunk,len));
|
||||
if (endChunk < len)
|
||||
memcpy(imng_p->writeBuffer, buf+endChunk, len-endChunk);
|
||||
imng_p->bytesBuffered += len;
|
||||
memcpy(imng_p->writeBuffer+imng_p->bufferEnd, buf, len);
|
||||
imng_p->bufferEnd += len;
|
||||
|
||||
if (imng_p->bytesNeeded &&
|
||||
(imng_p->bytesBuffered >= imng_p->bytesNeeded)) {
|
||||
mng_read_resume(imng_p->handle);
|
||||
if (imng_p->resumeNeeded) {
|
||||
// dprintf((stderr, "MNG::ImgDWrite display_resume (%d)\n",
|
||||
// imng_p->bytesBuffered));
|
||||
imng_p->resumeNeeded = PR_FALSE;
|
||||
int ret = mng_display_resume(imng_p->handle);
|
||||
if (ret == MNG_NEEDMOREDATA)
|
||||
imng_p->resumeNeeded = PR_TRUE;
|
||||
// dprintf((stderr, "MNG::ImgDWrite display_resume returned %d\n", ret));
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -427,6 +438,7 @@ MNGDecoder::ImgDAbort()
|
|||
|
||||
mng_display_freeze(imng_p->handle);
|
||||
mng_cleanup(&imng_p->handle);
|
||||
nsMemory::Free(imng_p->writeBuffer);
|
||||
nsMemory::Free(imng_p->image);
|
||||
nsMemory::Free(imng_p->rowbuf);
|
||||
nsMemory::Free(imng_p);
|
||||
|
|
Загрузка…
Ссылка в новой задаче