From eb680766d56e815086397361b286fd8055fb5377 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Thu, 3 Jan 2013 14:34:48 +0000 Subject: FreeImage updated to 3.15.4 removed not used formats git-svn-id: http://svn.miranda-ng.org/main/trunk@2926 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/AdvaImg/AdvaImg_11.vcxproj | 2 +- plugins/AdvaImg/AdvaImg_11.vcxproj.filters | 20 +- plugins/AdvaImg/Docs/Dist | 1052 - plugins/AdvaImg/Docs/license-gplv2.txt | 126 + plugins/AdvaImg/Docs/license-gplv3.txt | 228 + plugins/AdvaImg/res/AdvaImg.rc | 103 - .../AdvaImg/src/DeprecationManager/Deprecated.cpp | 36 - .../src/DeprecationManager/DeprecationMgr.cpp | 103 - .../src/DeprecationManager/DeprecationMgr.h | 83 - plugins/AdvaImg/src/FreeImage.h | 13 +- plugins/AdvaImg/src/FreeImage/BitmapAccess.cpp | 265 +- plugins/AdvaImg/src/FreeImage/ColorLookup.cpp | 4 +- plugins/AdvaImg/src/FreeImage/Conversion.cpp | 14 +- plugins/AdvaImg/src/FreeImage/Conversion16_555.cpp | 2 +- plugins/AdvaImg/src/FreeImage/Conversion16_565.cpp | 2 +- plugins/AdvaImg/src/FreeImage/Conversion24.cpp | 90 +- plugins/AdvaImg/src/FreeImage/Conversion32.cpp | 4 +- plugins/AdvaImg/src/FreeImage/Conversion4.cpp | 6 +- plugins/AdvaImg/src/FreeImage/Conversion8.cpp | 212 +- plugins/AdvaImg/src/FreeImage/ConversionFloat.cpp | 8 +- plugins/AdvaImg/src/FreeImage/ConversionRGB16.cpp | 8 +- plugins/AdvaImg/src/FreeImage/ConversionRGBF.cpp | 8 +- plugins/AdvaImg/src/FreeImage/ConversionType.cpp | 10 +- plugins/AdvaImg/src/FreeImage/ConversionUINT16.cpp | 8 +- plugins/AdvaImg/src/FreeImage/FreeImage.cpp | 2 +- plugins/AdvaImg/src/FreeImage/FreeImageIO.cpp | 18 +- plugins/AdvaImg/src/FreeImage/GetType.cpp | 1 - plugins/AdvaImg/src/FreeImage/Halftoning.cpp | 6 +- plugins/AdvaImg/src/FreeImage/J2KHelper.cpp | 1000 +- plugins/AdvaImg/src/FreeImage/MultiPage.cpp | 24 +- plugins/AdvaImg/src/FreeImage/NNQuantizer.cpp | 4 +- plugins/AdvaImg/src/FreeImage/PSDParser.cpp | 24 +- plugins/AdvaImg/src/FreeImage/PixelAccess.cpp | 25 +- plugins/AdvaImg/src/FreeImage/Plugin.cpp | 114 +- plugins/AdvaImg/src/FreeImage/PluginBMP.cpp | 24 +- plugins/AdvaImg/src/FreeImage/PluginCUT.cpp | 2 +- plugins/AdvaImg/src/FreeImage/PluginDDS.cpp | 6 +- plugins/AdvaImg/src/FreeImage/PluginEXR.cpp | 44 +- plugins/AdvaImg/src/FreeImage/PluginG3.cpp | 4 +- plugins/AdvaImg/src/FreeImage/PluginGIF.cpp | 308 +- plugins/AdvaImg/src/FreeImage/PluginHDR.cpp | 46 +- plugins/AdvaImg/src/FreeImage/PluginICO.cpp | 28 +- plugins/AdvaImg/src/FreeImage/PluginIFF.cpp | 8 +- plugins/AdvaImg/src/FreeImage/PluginJ2K.cpp | 678 +- plugins/AdvaImg/src/FreeImage/PluginJNG.cpp | 162 + plugins/AdvaImg/src/FreeImage/PluginJP2.cpp | 678 +- plugins/AdvaImg/src/FreeImage/PluginJPEG.cpp | 45 +- plugins/AdvaImg/src/FreeImage/PluginPCD.cpp | 4 +- plugins/AdvaImg/src/FreeImage/PluginPCX.cpp | 16 +- plugins/AdvaImg/src/FreeImage/PluginPFM.cpp | 20 +- plugins/AdvaImg/src/FreeImage/PluginPICT.cpp | 2 +- plugins/AdvaImg/src/FreeImage/PluginPNG.cpp | 40 +- plugins/AdvaImg/src/FreeImage/PluginPNM.cpp | 14 +- plugins/AdvaImg/src/FreeImage/PluginRAS.cpp | 4 +- plugins/AdvaImg/src/FreeImage/PluginRAW.cpp | 223 +- plugins/AdvaImg/src/FreeImage/PluginSGI.cpp | 6 +- plugins/AdvaImg/src/FreeImage/PluginTARGA.cpp | 8 +- plugins/AdvaImg/src/FreeImage/PluginTIFF.cpp | 102 +- plugins/AdvaImg/src/FreeImage/PluginXBM.cpp | 32 +- plugins/AdvaImg/src/FreeImage/PluginXPM.cpp | 64 +- plugins/AdvaImg/src/FreeImage/ToneMapping.cpp | 6 +- plugins/AdvaImg/src/FreeImage/WuQuantizer.cpp | 6 +- plugins/AdvaImg/src/FreeImage/tmoColorConvert.cpp | 18 +- plugins/AdvaImg/src/FreeImage/tmoDrago03.cpp | 4 +- plugins/AdvaImg/src/FreeImage/tmoFattal02.cpp | 54 +- plugins/AdvaImg/src/FreeImage/tmoReinhard05.cpp | 18 +- .../AdvaImg/src/FreeImageToolkit/BSplineRotate.cpp | 20 +- .../AdvaImg/src/FreeImageToolkit/Background.cpp | 895 + plugins/AdvaImg/src/FreeImageToolkit/Channels.cpp | 42 +- .../AdvaImg/src/FreeImageToolkit/ClassicRotate.cpp | 38 +- plugins/AdvaImg/src/FreeImageToolkit/Colors.cpp | 16 +- plugins/AdvaImg/src/FreeImageToolkit/CopyPaste.cpp | 44 +- plugins/AdvaImg/src/FreeImageToolkit/Display.cpp | 10 +- .../AdvaImg/src/FreeImageToolkit/JPEGTransform.cpp | 14 +- .../FreeImageToolkit/MultigridPoissonSolver.cpp | 30 +- plugins/AdvaImg/src/FreeImageToolkit/Rescale.cpp | 400 +- plugins/AdvaImg/src/FreeImageToolkit/Resize.cpp | 2648 +- plugins/AdvaImg/src/FreeImageToolkit/Resize.h | 340 +- plugins/AdvaImg/src/LibJPEG/README | 351 + plugins/AdvaImg/src/LibJPEG/coderules.txt | 118 + plugins/AdvaImg/src/LibJPEG/filelist.txt | 215 + plugins/AdvaImg/src/LibJPEG/install.txt | 1096 + plugins/AdvaImg/src/LibJPEG/jcparam.c | 2 +- plugins/AdvaImg/src/LibJPEG/libjpeg.txt | 3085 +++ plugins/AdvaImg/src/LibJPEG/structure.txt | 941 + plugins/AdvaImg/src/LibJPEG/usage.txt | 637 + plugins/AdvaImg/src/LibJPEG/wizard.txt | 211 + plugins/AdvaImg/src/LibMNG/Changes | 1447 -- plugins/AdvaImg/src/LibMNG/LICENSE | 57 - plugins/AdvaImg/src/LibMNG/README | 36 - plugins/AdvaImg/src/LibMNG/README.autoconf | 213 - plugins/AdvaImg/src/LibMNG/README.config | 104 - plugins/AdvaImg/src/LibMNG/README.contrib | 95 - plugins/AdvaImg/src/LibMNG/README.examples | 48 - plugins/AdvaImg/src/LibMNG/README.footprint | 46 - plugins/AdvaImg/src/LibMNG/README.packaging | 24 - plugins/AdvaImg/src/LibMNG/libmng.h | 2932 --- plugins/AdvaImg/src/LibMNG/libmng_callback_xs.c | 1239 - plugins/AdvaImg/src/LibMNG/libmng_chunk_descr.c | 6090 ----- plugins/AdvaImg/src/LibMNG/libmng_chunk_descr.h | 146 - plugins/AdvaImg/src/LibMNG/libmng_chunk_io.c | 10740 -------- plugins/AdvaImg/src/LibMNG/libmng_chunk_io.h | 415 - plugins/AdvaImg/src/LibMNG/libmng_chunk_prc.c | 4452 ---- plugins/AdvaImg/src/LibMNG/libmng_chunk_prc.h | 381 - plugins/AdvaImg/src/LibMNG/libmng_chunk_xs.c | 7016 ------ plugins/AdvaImg/src/LibMNG/libmng_chunks.h | 1026 - plugins/AdvaImg/src/LibMNG/libmng_cms.c | 758 - plugins/AdvaImg/src/LibMNG/libmng_cms.h | 92 - plugins/AdvaImg/src/LibMNG/libmng_conf.h | 306 - plugins/AdvaImg/src/LibMNG/libmng_data.h | 1029 - plugins/AdvaImg/src/LibMNG/libmng_display.c | 7135 ------ plugins/AdvaImg/src/LibMNG/libmng_display.h | 343 - plugins/AdvaImg/src/LibMNG/libmng_dither.c | 58 - plugins/AdvaImg/src/LibMNG/libmng_dither.h | 45 - plugins/AdvaImg/src/LibMNG/libmng_error.c | 326 - plugins/AdvaImg/src/LibMNG/libmng_error.h | 119 - plugins/AdvaImg/src/LibMNG/libmng_filter.c | 978 - plugins/AdvaImg/src/LibMNG/libmng_filter.h | 69 - plugins/AdvaImg/src/LibMNG/libmng_hlapi.c | 2995 --- plugins/AdvaImg/src/LibMNG/libmng_jpeg.c | 1088 - plugins/AdvaImg/src/LibMNG/libmng_jpeg.h | 57 - plugins/AdvaImg/src/LibMNG/libmng_memory.h | 64 - plugins/AdvaImg/src/LibMNG/libmng_object_prc.c | 6998 ------ plugins/AdvaImg/src/LibMNG/libmng_object_prc.h | 690 - plugins/AdvaImg/src/LibMNG/libmng_objects.h | 635 - plugins/AdvaImg/src/LibMNG/libmng_pixels.c | 24610 ------------------- plugins/AdvaImg/src/LibMNG/libmng_pixels.h | 1147 - plugins/AdvaImg/src/LibMNG/libmng_prop_xs.c | 2799 --- plugins/AdvaImg/src/LibMNG/libmng_read.c | 1369 -- plugins/AdvaImg/src/LibMNG/libmng_read.h | 53 - plugins/AdvaImg/src/LibMNG/libmng_trace.c | 1683 -- plugins/AdvaImg/src/LibMNG/libmng_trace.h | 1474 -- plugins/AdvaImg/src/LibMNG/libmng_types.h | 574 - plugins/AdvaImg/src/LibMNG/libmng_write.c | 198 - plugins/AdvaImg/src/LibMNG/libmng_write.h | 49 - plugins/AdvaImg/src/LibMNG/libmng_zlib.c | 607 - plugins/AdvaImg/src/LibMNG/libmng_zlib.h | 60 - plugins/AdvaImg/src/LibPNG/ANNOUNCE | 41 +- plugins/AdvaImg/src/LibPNG/CHANGES | 115 +- plugins/AdvaImg/src/LibPNG/KNOWNBUG | 29 - plugins/AdvaImg/src/LibPNG/LICENSE | 6 +- plugins/AdvaImg/src/LibPNG/README | 2 +- plugins/AdvaImg/src/LibPNG/Y2KINFO | 55 - plugins/AdvaImg/src/LibPNG/configure | 10 +- plugins/AdvaImg/src/LibPNG/example.c | 879 + plugins/AdvaImg/src/LibPNG/libpng-manual.txt | 4667 ++++ plugins/AdvaImg/src/LibPNG/libpng.3 | 196 +- plugins/AdvaImg/src/LibPNG/libpng.txt | 3352 --- plugins/AdvaImg/src/LibPNG/libpngpf.3 | 4 +- plugins/AdvaImg/src/LibPNG/png.5 | 2 +- plugins/AdvaImg/src/LibPNG/png.c | 44 +- plugins/AdvaImg/src/LibPNG/png.h | 108 +- plugins/AdvaImg/src/LibPNG/pngconf.h | 46 +- plugins/AdvaImg/src/LibPNG/pngerror.c | 2 +- plugins/AdvaImg/src/LibPNG/pngmem.c | 8 +- plugins/AdvaImg/src/LibPNG/pngpread.c | 566 +- plugins/AdvaImg/src/LibPNG/pngpriv.h | 64 +- plugins/AdvaImg/src/LibPNG/pngread.c | 21 +- plugins/AdvaImg/src/LibPNG/pngrtran.c | 87 +- plugins/AdvaImg/src/LibPNG/pngrutil.c | 23 +- plugins/AdvaImg/src/LibPNG/pngset.c | 41 +- plugins/AdvaImg/src/LibPNG/pngstruct.h | 16 +- plugins/AdvaImg/src/LibPNG/pngtest.c | 2 +- plugins/AdvaImg/src/LibPNG/pngtrans.c | 107 +- plugins/AdvaImg/src/LibPNG/pngwrite.c | 17 +- plugins/AdvaImg/src/LibPNG/pngwtran.c | 20 +- plugins/AdvaImg/src/LibPNG/pngwutil.c | 22 +- plugins/AdvaImg/src/LibTIFF/ChangeLog | 4849 ---- plugins/AdvaImg/src/LibTIFF/LibTIFF.dsp | 293 - plugins/AdvaImg/src/LibTIFF/SConstruct | 73 - plugins/AdvaImg/src/LibTIFF/mkg3states.c | 451 - plugins/AdvaImg/src/LibTIFF/t4.h | 292 - plugins/AdvaImg/src/LibTIFF/tif_acorn.c | 526 - plugins/AdvaImg/src/LibTIFF/tif_apple.c | 281 - plugins/AdvaImg/src/LibTIFF/tif_atari.c | 250 - plugins/AdvaImg/src/LibTIFF/tif_aux.c | 290 - plugins/AdvaImg/src/LibTIFF/tif_close.c | 126 - plugins/AdvaImg/src/LibTIFF/tif_codec.c | 160 - plugins/AdvaImg/src/LibTIFF/tif_color.c | 287 - plugins/AdvaImg/src/LibTIFF/tif_compress.c | 295 - plugins/AdvaImg/src/LibTIFF/tif_config.h | 266 - plugins/AdvaImg/src/LibTIFF/tif_config.h-vms | 46 - plugins/AdvaImg/src/LibTIFF/tif_config.h.in | 309 - plugins/AdvaImg/src/LibTIFF/tif_config.vc.h | 63 - plugins/AdvaImg/src/LibTIFF/tif_dir.c | 1391 -- plugins/AdvaImg/src/LibTIFF/tif_dir.h | 211 - plugins/AdvaImg/src/LibTIFF/tif_dirinfo.c | 884 - plugins/AdvaImg/src/LibTIFF/tif_dirread.c | 2117 -- plugins/AdvaImg/src/LibTIFF/tif_dirwrite.c | 1436 -- plugins/AdvaImg/src/LibTIFF/tif_dumpmode.c | 126 - plugins/AdvaImg/src/LibTIFF/tif_error.c | 80 - plugins/AdvaImg/src/LibTIFF/tif_extension.c | 118 - plugins/AdvaImg/src/LibTIFF/tif_fax3.c | 1626 -- plugins/AdvaImg/src/LibTIFF/tif_fax3.h | 538 - plugins/AdvaImg/src/LibTIFF/tif_fax3sm.c | 1260 - plugins/AdvaImg/src/LibTIFF/tif_flush.c | 74 - plugins/AdvaImg/src/LibTIFF/tif_getimage.c | 2678 -- plugins/AdvaImg/src/LibTIFF/tif_jbig.c | 385 - plugins/AdvaImg/src/LibTIFF/tif_jpeg.c | 2078 -- plugins/AdvaImg/src/LibTIFF/tif_luv.c | 1629 -- plugins/AdvaImg/src/LibTIFF/tif_lzw.c | 1129 - plugins/AdvaImg/src/LibTIFF/tif_msdos.c | 193 - plugins/AdvaImg/src/LibTIFF/tif_next.c | 154 - plugins/AdvaImg/src/LibTIFF/tif_ojpeg.c | 2448 -- plugins/AdvaImg/src/LibTIFF/tif_open.c | 695 - plugins/AdvaImg/src/LibTIFF/tif_packbits.c | 300 - plugins/AdvaImg/src/LibTIFF/tif_pixarlog.c | 1371 -- plugins/AdvaImg/src/LibTIFF/tif_predict.c | 736 - plugins/AdvaImg/src/LibTIFF/tif_predict.h | 77 - plugins/AdvaImg/src/LibTIFF/tif_print.c | 642 - plugins/AdvaImg/src/LibTIFF/tif_read.c | 750 - plugins/AdvaImg/src/LibTIFF/tif_stream.cxx | 295 - plugins/AdvaImg/src/LibTIFF/tif_strip.c | 366 - plugins/AdvaImg/src/LibTIFF/tif_swab.c | 242 - plugins/AdvaImg/src/LibTIFF/tif_thunder.c | 189 - plugins/AdvaImg/src/LibTIFF/tif_tile.c | 280 - plugins/AdvaImg/src/LibTIFF/tif_unix.c | 300 - plugins/AdvaImg/src/LibTIFF/tif_version.c | 40 - plugins/AdvaImg/src/LibTIFF/tif_vms.c | 595 - plugins/AdvaImg/src/LibTIFF/tif_warning.c | 81 - plugins/AdvaImg/src/LibTIFF/tif_win3.c | 232 - plugins/AdvaImg/src/LibTIFF/tif_win32.c | 408 - plugins/AdvaImg/src/LibTIFF/tif_write.c | 718 - plugins/AdvaImg/src/LibTIFF/tif_zip.c | 419 - plugins/AdvaImg/src/LibTIFF/tiff.h | 654 - plugins/AdvaImg/src/LibTIFF/tiffconf.h-vms | 99 - plugins/AdvaImg/src/LibTIFF/tiffconf.vc.h | 116 - plugins/AdvaImg/src/LibTIFF/tiffio.h | 526 - plugins/AdvaImg/src/LibTIFF/tiffio.hxx | 49 - plugins/AdvaImg/src/LibTIFF/tiffiop.h | 353 - plugins/AdvaImg/src/LibTIFF/tiffvers.h | 9 - plugins/AdvaImg/src/LibTIFF/uvcode.h | 180 - plugins/AdvaImg/src/Metadata/Exif.cpp | 26 +- plugins/AdvaImg/src/Metadata/FreeImageTag.cpp | 14 +- plugins/AdvaImg/src/Metadata/FreeImageTag.h | 26 +- plugins/AdvaImg/src/Metadata/IPTC.cpp | 23 +- plugins/AdvaImg/src/Metadata/TagConversion.cpp | 12 +- plugins/AdvaImg/src/Metadata/TagLib.cpp | 7 +- plugins/AdvaImg/src/Metadata/XTIFF.cpp | 22 +- plugins/AdvaImg/src/Utilities.h | 14 +- plugins/AdvaImg/src/Zlib/zconf.h | 974 +- plugins/AdvaImg/src/Zlib/zlib.h | 62 +- plugins/AdvaImg/src/Zlib/zutil.h | 500 +- plugins/AdvaImg/src/main.cpp | 2 +- plugins/AdvaImg/src/version.h | 8 +- 245 files changed, 19998 insertions(+), 144745 deletions(-) delete mode 100644 plugins/AdvaImg/Docs/Dist create mode 100644 plugins/AdvaImg/Docs/license-gplv2.txt create mode 100644 plugins/AdvaImg/Docs/license-gplv3.txt delete mode 100644 plugins/AdvaImg/res/AdvaImg.rc delete mode 100644 plugins/AdvaImg/src/DeprecationManager/Deprecated.cpp delete mode 100644 plugins/AdvaImg/src/DeprecationManager/DeprecationMgr.cpp delete mode 100644 plugins/AdvaImg/src/DeprecationManager/DeprecationMgr.h create mode 100644 plugins/AdvaImg/src/FreeImage/PluginJNG.cpp create mode 100644 plugins/AdvaImg/src/FreeImageToolkit/Background.cpp create mode 100644 plugins/AdvaImg/src/LibJPEG/README create mode 100644 plugins/AdvaImg/src/LibJPEG/coderules.txt create mode 100644 plugins/AdvaImg/src/LibJPEG/filelist.txt create mode 100644 plugins/AdvaImg/src/LibJPEG/install.txt create mode 100644 plugins/AdvaImg/src/LibJPEG/libjpeg.txt create mode 100644 plugins/AdvaImg/src/LibJPEG/structure.txt create mode 100644 plugins/AdvaImg/src/LibJPEG/usage.txt create mode 100644 plugins/AdvaImg/src/LibJPEG/wizard.txt delete mode 100644 plugins/AdvaImg/src/LibMNG/Changes delete mode 100644 plugins/AdvaImg/src/LibMNG/LICENSE delete mode 100644 plugins/AdvaImg/src/LibMNG/README delete mode 100644 plugins/AdvaImg/src/LibMNG/README.autoconf delete mode 100644 plugins/AdvaImg/src/LibMNG/README.config delete mode 100644 plugins/AdvaImg/src/LibMNG/README.contrib delete mode 100644 plugins/AdvaImg/src/LibMNG/README.examples delete mode 100644 plugins/AdvaImg/src/LibMNG/README.footprint delete mode 100644 plugins/AdvaImg/src/LibMNG/README.packaging delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng.h delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_callback_xs.c delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_chunk_descr.c delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_chunk_descr.h delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_chunk_io.c delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_chunk_io.h delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_chunk_prc.c delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_chunk_prc.h delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_chunk_xs.c delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_chunks.h delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_cms.c delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_cms.h delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_conf.h delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_data.h delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_display.c delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_display.h delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_dither.c delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_dither.h delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_error.c delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_error.h delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_filter.c delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_filter.h delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_hlapi.c delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_jpeg.c delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_jpeg.h delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_memory.h delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_object_prc.c delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_object_prc.h delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_objects.h delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_pixels.c delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_pixels.h delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_prop_xs.c delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_read.c delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_read.h delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_trace.c delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_trace.h delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_types.h delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_write.c delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_write.h delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_zlib.c delete mode 100644 plugins/AdvaImg/src/LibMNG/libmng_zlib.h delete mode 100644 plugins/AdvaImg/src/LibPNG/KNOWNBUG delete mode 100644 plugins/AdvaImg/src/LibPNG/Y2KINFO create mode 100644 plugins/AdvaImg/src/LibPNG/example.c create mode 100644 plugins/AdvaImg/src/LibPNG/libpng-manual.txt delete mode 100644 plugins/AdvaImg/src/LibPNG/libpng.txt delete mode 100644 plugins/AdvaImg/src/LibTIFF/ChangeLog delete mode 100644 plugins/AdvaImg/src/LibTIFF/LibTIFF.dsp delete mode 100644 plugins/AdvaImg/src/LibTIFF/SConstruct delete mode 100644 plugins/AdvaImg/src/LibTIFF/mkg3states.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/t4.h delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_acorn.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_apple.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_atari.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_aux.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_close.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_codec.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_color.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_compress.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_config.h delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_config.h-vms delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_config.h.in delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_config.vc.h delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_dir.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_dir.h delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_dirinfo.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_dirread.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_dirwrite.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_dumpmode.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_error.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_extension.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_fax3.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_fax3.h delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_fax3sm.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_flush.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_getimage.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_jbig.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_jpeg.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_luv.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_lzw.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_msdos.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_next.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_ojpeg.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_open.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_packbits.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_pixarlog.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_predict.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_predict.h delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_print.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_read.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_stream.cxx delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_strip.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_swab.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_thunder.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_tile.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_unix.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_version.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_vms.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_warning.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_win3.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_win32.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_write.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tif_zip.c delete mode 100644 plugins/AdvaImg/src/LibTIFF/tiff.h delete mode 100644 plugins/AdvaImg/src/LibTIFF/tiffconf.h-vms delete mode 100644 plugins/AdvaImg/src/LibTIFF/tiffconf.vc.h delete mode 100644 plugins/AdvaImg/src/LibTIFF/tiffio.h delete mode 100644 plugins/AdvaImg/src/LibTIFF/tiffio.hxx delete mode 100644 plugins/AdvaImg/src/LibTIFF/tiffiop.h delete mode 100644 plugins/AdvaImg/src/LibTIFF/tiffvers.h delete mode 100644 plugins/AdvaImg/src/LibTIFF/uvcode.h diff --git a/plugins/AdvaImg/AdvaImg_11.vcxproj b/plugins/AdvaImg/AdvaImg_11.vcxproj index 3d35126027..0018f6e412 100644 --- a/plugins/AdvaImg/AdvaImg_11.vcxproj +++ b/plugins/AdvaImg/AdvaImg_11.vcxproj @@ -189,6 +189,7 @@ + @@ -321,7 +322,6 @@ - diff --git a/plugins/AdvaImg/AdvaImg_11.vcxproj.filters b/plugins/AdvaImg/AdvaImg_11.vcxproj.filters index 1c7911cb7b..a8736aaefd 100644 --- a/plugins/AdvaImg/AdvaImg_11.vcxproj.filters +++ b/plugins/AdvaImg/AdvaImg_11.vcxproj.filters @@ -45,6 +45,12 @@ {8a30217b-8369-4504-a6b0-5cd09f8b95a1} + + {e2db5718-8b21-4fb0-967d-d19bddf27c1f} + + + {066db7d3-0d3c-4ca7-b3dc-20f052f3aa4f} + @@ -437,13 +443,13 @@ Source Files\Conversion + + Toolkit Files + - - Source Files - - Source Files + Resource Files @@ -519,9 +525,6 @@ Toolkit Files - - Source Files\LibJPEG\Header Files - Source Files\LibPNG\Header Files @@ -534,5 +537,8 @@ Source Files\LibPNG\Header Files + + Header Files + \ No newline at end of file diff --git a/plugins/AdvaImg/Docs/Dist b/plugins/AdvaImg/Docs/Dist deleted file mode 100644 index fafca0060e..0000000000 --- a/plugins/AdvaImg/Docs/Dist +++ /dev/null @@ -1,1052 +0,0 @@ -// ========================================================== -// FreeImage 3 -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// - Hervé Drolon (drolon@infonie.fr) -// -// Contributors: -// - Adam Gates (radad@xoasis.com) -// - Alex Kwak -// - Alexander Dymerets (sashad@te.net.ua) -// - Detlev Vendt (detlev.vendt@brillit.de) -// - Jan L. Nauta (jln@magentammt.com) -// - Jani Kajala (janik@remedy.fi) -// - Juergen Riecker (j.riecker@gmx.de) -// - Karl-Heinz Bussian (khbussian@moss.de) -// - Laurent Rocher (rocherl@club-internet.fr) -// - Luca Piergentili (l.pierge@terra.es) -// - Machiel ten Brinke (brinkem@uni-one.nl) -// - Markus Loibl (markus.loibl@epost.de) -// - Martin Weber (martweb@gmx.net) -// - Matthias Wandel (mwandel@rim.net) -// - Michal Novotny (michal@etc.cz) -// - Petr Pytelka (pyta@lightcomp.com) -// - Riley McNiff (rmcniff@marexgroup.com) -// - Ryan Rubley (ryan@lostreality.org) -// - Volker Gärtner (volkerg@gmx.at) -// -// This file is part of FreeImage 3 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#ifndef FREEIMAGE_H -#define FREEIMAGE_H - -// Version information ------------------------------------------------------ - -#define FREEIMAGE_MAJOR_VERSION 3 -#define FREEIMAGE_MINOR_VERSION 10 -#define FREEIMAGE_RELEASE_SERIAL 0 - -// Compiler options --------------------------------------------------------- - -#include // needed for UNICODE functions - -#if defined(FREEIMAGE_LIB) - #define DLL_API - #define DLL_CALLCONV -#else - #if defined(_WIN32) || defined(__WIN32__) - #define DLL_CALLCONV __stdcall - // The following ifdef block is the standard way of creating macros which make exporting - // from a DLL simpler. All files within this DLL are compiled with the FREEIMAGE_EXPORTS - // symbol defined on the command line. this symbol should not be defined on any project - // that uses this DLL. This way any other project whose source files include this file see - // DLL_API functions as being imported from a DLL, wheras this DLL sees symbols - // defined with this macro as being exported. - #ifdef FREEIMAGE_EXPORTS - #define DLL_API __declspec(dllexport) - #else - #define DLL_API __declspec(dllimport) - #endif // FREEIMAGE_EXPORTS - #else - // try the gcc visibility support (see http://gcc.gnu.org/wiki/Visibility) - #if defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) - #ifndef GCC_HASCLASSVISIBILITY - #define GCC_HASCLASSVISIBILITY - #endif - #endif // __GNUC__ - #define DLL_CALLCONV - #if defined(GCC_HASCLASSVISIBILITY) - #define DLL_API __attribute__ ((visibility("default"))) - #else - #define DLL_API - #endif - #endif // WIN32 / !WIN32 -#endif // FREEIMAGE_LIB - -// Some versions of gcc may have BYTE_ORDER or __BYTE_ORDER defined -// If your big endian system isn't being detected, add an OS specific check -#if (defined(BYTE_ORDER) && BYTE_ORDER==BIG_ENDIAN) || \ - (defined(__BYTE_ORDER) && __BYTE_ORDER==__BIG_ENDIAN) || \ - defined(__BIG_ENDIAN__) -#define FREEIMAGE_BIGENDIAN -#endif // BYTE_ORDER - -// This really only affects 24 and 32 bit formats, the rest are always RGB order. -#define FREEIMAGE_COLORORDER_BGR 0 -#define FREEIMAGE_COLORORDER_RGB 1 -#if defined(__APPLE__) || defined(FREEIMAGE_BIGENDIAN) -#define FREEIMAGE_COLORORDER FREEIMAGE_COLORORDER_RGB -#else -#define FREEIMAGE_COLORORDER FREEIMAGE_COLORORDER_BGR -#endif - -// Ensure 4-byte enums if we're using Borland C++ compilers -#if defined(__BORLANDC__) -#pragma option push -b -#endif - -// For C compatibility -------------------------------------------------------- - -#ifdef __cplusplus -#define FI_DEFAULT(x) = x -#define FI_ENUM(x) enum x -#define FI_STRUCT(x) struct x -#else -#define FI_DEFAULT(x) -#define FI_ENUM(x) typedef int x; enum x -#define FI_STRUCT(x) typedef struct x x; struct x -#endif - -// Bitmap types ------------------------------------------------------------- - -FI_STRUCT (FIBITMAP) { void *data; }; -FI_STRUCT (FIMULTIBITMAP) { void *data; }; - -// Types used in the library (directly copied from Windows) ----------------- - -#ifndef _WINDOWS_ -#define _WINDOWS_ - -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif -#ifndef NULL -#define NULL 0 -#endif - -#ifndef SEEK_SET -#define SEEK_SET 0 -#define SEEK_CUR 1 -#define SEEK_END 2 -#endif - -#ifndef _MSC_VER -// define portable types for 32-bit / 64-bit OS -#include -#ifndef _WINDEF_H -typedef int32_t BOOL; -typedef uint8_t BYTE; -typedef uint16_t WORD; -typedef uint32_t DWORD; -typedef int32_t LONG; -#endif -#else -// MS is not C99 ISO compliant -typedef long BOOL; -typedef unsigned char BYTE; -typedef unsigned short WORD; -typedef unsigned long DWORD; -typedef long LONG; -#endif // _MSC_VER - -#ifndef _WINGDI_H - -#if (defined(_WIN32) || defined(__WIN32__)) -#pragma pack(push, 1) -#else -#pragma pack(1) -#endif // WIN32 - -typedef struct tagRGBQUAD { -#if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR - BYTE rgbBlue; - BYTE rgbGreen; - BYTE rgbRed; -#else - BYTE rgbRed; - BYTE rgbGreen; - BYTE rgbBlue; -#endif // FREEIMAGE_COLORORDER - BYTE rgbReserved; -} RGBQUAD; - -typedef struct tagRGBTRIPLE { -#if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR - BYTE rgbtBlue; - BYTE rgbtGreen; - BYTE rgbtRed; -#else - BYTE rgbtRed; - BYTE rgbtGreen; - BYTE rgbtBlue; -#endif // FREEIMAGE_COLORORDER -} RGBTRIPLE; - -#if (defined(_WIN32) || defined(__WIN32__)) -#pragma pack(pop) -#else -#pragma pack() -#endif // WIN32 - -typedef struct tagBITMAPINFOHEADER{ - DWORD biSize; - LONG biWidth; - LONG biHeight; - WORD biPlanes; - WORD biBitCount; - DWORD biCompression; - DWORD biSizeImage; - LONG biXPelsPerMeter; - LONG biYPelsPerMeter; - DWORD biClrUsed; - DWORD biClrImportant; -} BITMAPINFOHEADER, *PBITMAPINFOHEADER; - -typedef struct tagBITMAPINFO { - BITMAPINFOHEADER bmiHeader; - RGBQUAD bmiColors[1]; -} BITMAPINFO, *PBITMAPINFO; - -#endif // _WINDOWS_ - -#endif // _WINGDI_H - -// Types used in the library (specific to FreeImage) ------------------------ - -#if (defined(_WIN32) || defined(__WIN32__)) -#pragma pack(push, 1) -#else -#pragma pack(1) -#endif // WIN32 - -/** 48-bit RGB -*/ -typedef struct tagFIRGB16 { - WORD red; - WORD green; - WORD blue; -} FIRGB16; - -/** 64-bit RGBA -*/ -typedef struct tagFIRGBA16 { - WORD red; - WORD green; - WORD blue; - WORD alpha; -} FIRGBA16; - -/** 96-bit RGB Float -*/ -typedef struct tagFIRGBF { - float red; - float green; - float blue; -} FIRGBF; - -/** 128-bit RGBA Float -*/ -typedef struct tagFIRGBAF { - float red; - float green; - float blue; - float alpha; -} FIRGBAF; - -/** Data structure for COMPLEX type (complex number) -*/ -typedef struct tagFICOMPLEX { - /// real part - double r; - /// imaginary part - double i; -} FICOMPLEX; - -#if (defined(_WIN32) || defined(__WIN32__)) -#pragma pack(pop) -#else -#pragma pack() -#endif // WIN32 - -// Indexes for byte arrays, masks and shifts for treating pixels as words --- -// These coincide with the order of RGBQUAD and RGBTRIPLE ------------------- - -#ifndef FREEIMAGE_BIGENDIAN -#if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR -// Little Endian (x86 / MS Windows, Linux) : BGR(A) order -#define FI_RGBA_RED 2 -#define FI_RGBA_GREEN 1 -#define FI_RGBA_BLUE 0 -#define FI_RGBA_ALPHA 3 -#define FI_RGBA_RED_MASK 0x00FF0000 -#define FI_RGBA_GREEN_MASK 0x0000FF00 -#define FI_RGBA_BLUE_MASK 0x000000FF -#define FI_RGBA_ALPHA_MASK 0xFF000000 -#define FI_RGBA_RED_SHIFT 16 -#define FI_RGBA_GREEN_SHIFT 8 -#define FI_RGBA_BLUE_SHIFT 0 -#define FI_RGBA_ALPHA_SHIFT 24 -#else -// Little Endian (x86 / MaxOSX) : RGB(A) order -#define FI_RGBA_RED 0 -#define FI_RGBA_GREEN 1 -#define FI_RGBA_BLUE 2 -#define FI_RGBA_ALPHA 3 -#define FI_RGBA_RED_MASK 0x000000FF -#define FI_RGBA_GREEN_MASK 0x0000FF00 -#define FI_RGBA_BLUE_MASK 0x00FF0000 -#define FI_RGBA_ALPHA_MASK 0xFF000000 -#define FI_RGBA_RED_SHIFT 0 -#define FI_RGBA_GREEN_SHIFT 8 -#define FI_RGBA_BLUE_SHIFT 16 -#define FI_RGBA_ALPHA_SHIFT 24 -#endif // FREEIMAGE_COLORORDER -#else -#if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR -// Big Endian (PPC / none) : BGR(A) order -#define FI_RGBA_RED 2 -#define FI_RGBA_GREEN 1 -#define FI_RGBA_BLUE 0 -#define FI_RGBA_ALPHA 3 -#define FI_RGBA_RED_MASK 0x0000FF00 -#define FI_RGBA_GREEN_MASK 0x00FF0000 -#define FI_RGBA_BLUE_MASK 0xFF000000 -#define FI_RGBA_ALPHA_MASK 0x000000FF -#define FI_RGBA_RED_SHIFT 8 -#define FI_RGBA_GREEN_SHIFT 16 -#define FI_RGBA_BLUE_SHIFT 24 -#define FI_RGBA_ALPHA_SHIFT 0 -#else -// Big Endian (PPC / Linux, MaxOSX) : RGB(A) order -#define FI_RGBA_RED 0 -#define FI_RGBA_GREEN 1 -#define FI_RGBA_BLUE 2 -#define FI_RGBA_ALPHA 3 -#define FI_RGBA_RED_MASK 0xFF000000 -#define FI_RGBA_GREEN_MASK 0x00FF0000 -#define FI_RGBA_BLUE_MASK 0x0000FF00 -#define FI_RGBA_ALPHA_MASK 0x000000FF -#define FI_RGBA_RED_SHIFT 24 -#define FI_RGBA_GREEN_SHIFT 16 -#define FI_RGBA_BLUE_SHIFT 8 -#define FI_RGBA_ALPHA_SHIFT 0 -#endif // FREEIMAGE_COLORORDER -#endif // FREEIMAGE_BIGENDIAN - -#define FI_RGBA_RGB_MASK (FI_RGBA_RED_MASK|FI_RGBA_GREEN_MASK|FI_RGBA_BLUE_MASK) - -// The 16bit macros only include masks and shifts, since each color element is not byte aligned - -#define FI16_555_RED_MASK 0x7C00 -#define FI16_555_GREEN_MASK 0x03E0 -#define FI16_555_BLUE_MASK 0x001F -#define FI16_555_RED_SHIFT 10 -#define FI16_555_GREEN_SHIFT 5 -#define FI16_555_BLUE_SHIFT 0 -#define FI16_565_RED_MASK 0xF800 -#define FI16_565_GREEN_MASK 0x07E0 -#define FI16_565_BLUE_MASK 0x001F -#define FI16_565_RED_SHIFT 11 -#define FI16_565_GREEN_SHIFT 5 -#define FI16_565_BLUE_SHIFT 0 - -// ICC profile support ------------------------------------------------------ - -#define FIICC_DEFAULT 0x00 -#define FIICC_COLOR_IS_CMYK 0x01 - -FI_STRUCT (FIICCPROFILE) { - WORD flags; // info flag - DWORD size; // profile's size measured in bytes - void *data; // points to a block of contiguous memory containing the profile -}; - -// Important enums ---------------------------------------------------------- - -/** I/O image format identifiers. -*/ -FI_ENUM(FREE_IMAGE_FORMAT) { - FIF_UNKNOWN = -1, - FIF_BMP = 0, - FIF_ICO = 1, - FIF_JPEG = 2, - FIF_JNG = 3, - FIF_KOALA = 4, - FIF_LBM = 5, - FIF_IFF = FIF_LBM, - FIF_MNG = 6, - FIF_PBM = 7, - FIF_PBMRAW = 8, - FIF_PCD = 9, - FIF_PCX = 10, - FIF_PGM = 11, - FIF_PGMRAW = 12, - FIF_PNG = 13, - FIF_PPM = 14, - FIF_PPMRAW = 15, - FIF_RAS = 16, - FIF_TARGA = 17, - FIF_TIFF = 18, - FIF_WBMP = 19, - FIF_PSD = 20, - FIF_CUT = 21, - FIF_XBM = 22, - FIF_XPM = 23, - FIF_DDS = 24, - FIF_GIF = 25, - FIF_HDR = 26, - FIF_FAXG3 = 27, - FIF_SGI = 28, - FIF_EXR = 29, - FIF_J2K = 30, - FIF_JP2 = 31 -}; - -/** Image type used in FreeImage. -*/ -FI_ENUM(FREE_IMAGE_TYPE) { - FIT_UNKNOWN = 0, // unknown type - FIT_BITMAP = 1, // standard image : 1-, 4-, 8-, 16-, 24-, 32-bit - FIT_UINT16 = 2, // array of unsigned short : unsigned 16-bit - FIT_INT16 = 3, // array of short : signed 16-bit - FIT_UINT32 = 4, // array of unsigned long : unsigned 32-bit - FIT_INT32 = 5, // array of long : signed 32-bit - FIT_FLOAT = 6, // array of float : 32-bit IEEE floating point - FIT_DOUBLE = 7, // array of double : 64-bit IEEE floating point - FIT_COMPLEX = 8, // array of FICOMPLEX : 2 x 64-bit IEEE floating point - FIT_RGB16 = 9, // 48-bit RGB image : 3 x 16-bit - FIT_RGBA16 = 10, // 64-bit RGBA image : 4 x 16-bit - FIT_RGBF = 11, // 96-bit RGB float image : 3 x 32-bit IEEE floating point - FIT_RGBAF = 12 // 128-bit RGBA float image : 4 x 32-bit IEEE floating point -}; - -/** Image color type used in FreeImage. -*/ -FI_ENUM(FREE_IMAGE_COLOR_TYPE) { - FIC_MINISWHITE = 0, // min value is white - FIC_MINISBLACK = 1, // min value is black - FIC_RGB = 2, // RGB color model - FIC_PALETTE = 3, // color map indexed - FIC_RGBALPHA = 4, // RGB color model with alpha channel - FIC_CMYK = 5 // CMYK color model -}; - -/** Color quantization algorithms. -Constants used in FreeImage_ColorQuantize. -*/ -FI_ENUM(FREE_IMAGE_QUANTIZE) { - FIQ_WUQUANT = 0, // Xiaolin Wu color quantization algorithm - FIQ_NNQUANT = 1 // NeuQuant neural-net quantization algorithm by Anthony Dekker -}; - -/** Dithering algorithms. -Constants used in FreeImage_Dither. -*/ -FI_ENUM(FREE_IMAGE_DITHER) { - FID_FS = 0, // Floyd & Steinberg error diffusion - FID_BAYER4x4 = 1, // Bayer ordered dispersed dot dithering (order 2 dithering matrix) - FID_BAYER8x8 = 2, // Bayer ordered dispersed dot dithering (order 3 dithering matrix) - FID_CLUSTER6x6 = 3, // Ordered clustered dot dithering (order 3 - 6x6 matrix) - FID_CLUSTER8x8 = 4, // Ordered clustered dot dithering (order 4 - 8x8 matrix) - FID_CLUSTER16x16= 5, // Ordered clustered dot dithering (order 8 - 16x16 matrix) - FID_BAYER16x16 = 6 // Bayer ordered dispersed dot dithering (order 4 dithering matrix) -}; - -/** Lossless JPEG transformations -Constants used in FreeImage_JPEGTransform -*/ -FI_ENUM(FREE_IMAGE_JPEG_OPERATION) { - FIJPEG_OP_NONE = 0, // no transformation - FIJPEG_OP_FLIP_H = 1, // horizontal flip - FIJPEG_OP_FLIP_V = 2, // vertical flip - FIJPEG_OP_TRANSPOSE = 3, // transpose across UL-to-LR axis - FIJPEG_OP_TRANSVERSE = 4, // transpose across UR-to-LL axis - FIJPEG_OP_ROTATE_90 = 5, // 90-degree clockwise rotation - FIJPEG_OP_ROTATE_180 = 6, // 180-degree rotation - FIJPEG_OP_ROTATE_270 = 7 // 270-degree clockwise (or 90 ccw) -}; - -/** Tone mapping operators. -Constants used in FreeImage_ToneMapping. -*/ -FI_ENUM(FREE_IMAGE_TMO) { - FITMO_DRAGO03 = 0, // Adaptive logarithmic mapping (F. Drago, 2003) - FITMO_REINHARD05 = 1, // Dynamic range reduction inspired by photoreceptor physiology (E. Reinhard, 2005) - FITMO_FATTAL02 = 2 // Gradient domain high dynamic range compression (R. Fattal, 2002) -}; - -/** Upsampling / downsampling filters. -Constants used in FreeImage_Rescale. -*/ -FI_ENUM(FREE_IMAGE_FILTER) { - FILTER_BOX = 0, // Box, pulse, Fourier window, 1st order (constant) b-spline - FILTER_BICUBIC = 1, // Mitchell & Netravali's two-param cubic filter - FILTER_BILINEAR = 2, // Bilinear filter - FILTER_BSPLINE = 3, // 4th order (cubic) b-spline - FILTER_CATMULLROM = 4, // Catmull-Rom spline, Overhauser spline - FILTER_LANCZOS3 = 5 // Lanczos3 filter -}; - -/** Color channels. -Constants used in color manipulation routines. -*/ -FI_ENUM(FREE_IMAGE_COLOR_CHANNEL) { - FICC_RGB = 0, // Use red, green and blue channels - FICC_RED = 1, // Use red channel - FICC_GREEN = 2, // Use green channel - FICC_BLUE = 3, // Use blue channel - FICC_ALPHA = 4, // Use alpha channel - FICC_BLACK = 5, // Use black channel - FICC_REAL = 6, // Complex images: use real part - FICC_IMAG = 7, // Complex images: use imaginary part - FICC_MAG = 8, // Complex images: use magnitude - FICC_PHASE = 9 // Complex images: use phase -}; - -// Metadata support --------------------------------------------------------- - -/** - Tag data type information (based on TIFF specifications) - - Note: RATIONALs are the ratio of two 32-bit integer values. -*/ -FI_ENUM(FREE_IMAGE_MDTYPE) { - FIDT_NOTYPE = 0, // placeholder - FIDT_BYTE = 1, // 8-bit unsigned integer - FIDT_ASCII = 2, // 8-bit bytes w/ last byte null - FIDT_SHORT = 3, // 16-bit unsigned integer - FIDT_LONG = 4, // 32-bit unsigned integer - FIDT_RATIONAL = 5, // 64-bit unsigned fraction - FIDT_SBYTE = 6, // 8-bit signed integer - FIDT_UNDEFINED = 7, // 8-bit untyped data - FIDT_SSHORT = 8, // 16-bit signed integer - FIDT_SLONG = 9, // 32-bit signed integer - FIDT_SRATIONAL = 10, // 64-bit signed fraction - FIDT_FLOAT = 11, // 32-bit IEEE floating point - FIDT_DOUBLE = 12, // 64-bit IEEE floating point - FIDT_IFD = 13, // 32-bit unsigned integer (offset) - FIDT_PALETTE = 14 // 32-bit RGBQUAD -}; - -/** - Metadata models supported by FreeImage -*/ -FI_ENUM(FREE_IMAGE_MDMODEL) { - FIMD_NODATA = -1, - FIMD_COMMENTS = 0, // single comment or keywords - FIMD_EXIF_MAIN = 1, // Exif-TIFF metadata - FIMD_EXIF_EXIF = 2, // Exif-specific metadata - FIMD_EXIF_GPS = 3, // Exif GPS metadata - FIMD_EXIF_MAKERNOTE = 4, // Exif maker note metadata - FIMD_EXIF_INTEROP = 5, // Exif interoperability metadata - FIMD_IPTC = 6, // IPTC/NAA metadata - FIMD_XMP = 7, // Abobe XMP metadata - FIMD_GEOTIFF = 8, // GeoTIFF metadata - FIMD_ANIMATION = 9, // Animation metadata - FIMD_CUSTOM = 10 // Used to attach other metadata types to a dib -}; - -/** - Handle to a metadata model -*/ -FI_STRUCT (FIMETADATA) { void *data; }; - -/** - Handle to a FreeImage tag -*/ -FI_STRUCT (FITAG) { void *data; }; - -// File IO routines --------------------------------------------------------- - -#ifndef FREEIMAGE_IO -#define FREEIMAGE_IO - -typedef void* fi_handle; -typedef unsigned (DLL_CALLCONV *FI_ReadProc) (void *buffer, unsigned size, unsigned count, fi_handle handle); -typedef unsigned (DLL_CALLCONV *FI_WriteProc) (void *buffer, unsigned size, unsigned count, fi_handle handle); -typedef int (DLL_CALLCONV *FI_SeekProc) (fi_handle handle, long offset, int origin); -typedef long (DLL_CALLCONV *FI_TellProc) (fi_handle handle); - -#if (defined(_WIN32) || defined(__WIN32__)) -#pragma pack(push, 1) -#else -#pragma pack(1) -#endif // WIN32 - -FI_STRUCT(FreeImageIO) { - FI_ReadProc read_proc; // pointer to the function used to read data - FI_WriteProc write_proc; // pointer to the function used to write data - FI_SeekProc seek_proc; // pointer to the function used to seek - FI_TellProc tell_proc; // pointer to the function used to aquire the current position -}; - -#if (defined(_WIN32) || defined(__WIN32__)) -#pragma pack(pop) -#else -#pragma pack() -#endif // WIN32 - -/** -Handle to a memory I/O stream -*/ -FI_STRUCT (FIMEMORY) { void *data; }; - -#endif // FREEIMAGE_IO - -// Plugin routines ---------------------------------------------------------- - -#ifndef PLUGINS -#define PLUGINS - -typedef const char *(DLL_CALLCONV *FI_FormatProc) (); -typedef const char *(DLL_CALLCONV *FI_DescriptionProc) (); -typedef const char *(DLL_CALLCONV *FI_ExtensionListProc) (); -typedef const char *(DLL_CALLCONV *FI_RegExprProc) (); -typedef void *(DLL_CALLCONV *FI_OpenProc)(FreeImageIO *io, fi_handle handle, BOOL read); -typedef void (DLL_CALLCONV *FI_CloseProc)(FreeImageIO *io, fi_handle handle, void *data); -typedef int (DLL_CALLCONV *FI_PageCountProc)(FreeImageIO *io, fi_handle handle, void *data); -typedef int (DLL_CALLCONV *FI_PageCapabilityProc)(FreeImageIO *io, fi_handle handle, void *data); -typedef FIBITMAP *(DLL_CALLCONV *FI_LoadProc)(FreeImageIO *io, fi_handle handle, int page, int flags, void *data); -typedef BOOL (DLL_CALLCONV *FI_SaveProc)(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data); -typedef BOOL (DLL_CALLCONV *FI_ValidateProc)(FreeImageIO *io, fi_handle handle); -typedef const char *(DLL_CALLCONV *FI_MimeProc) (); -typedef BOOL (DLL_CALLCONV *FI_SupportsExportBPPProc)(int bpp); -typedef BOOL (DLL_CALLCONV *FI_SupportsExportTypeProc)(FREE_IMAGE_TYPE type); -typedef BOOL (DLL_CALLCONV *FI_SupportsICCProfilesProc)(); - -FI_STRUCT (Plugin) { - FI_FormatProc format_proc; - FI_DescriptionProc description_proc; - FI_ExtensionListProc extension_proc; - FI_RegExprProc regexpr_proc; - FI_OpenProc open_proc; - FI_CloseProc close_proc; - FI_PageCountProc pagecount_proc; - FI_PageCapabilityProc pagecapability_proc; - FI_LoadProc load_proc; - FI_SaveProc save_proc; - FI_ValidateProc validate_proc; - FI_MimeProc mime_proc; - FI_SupportsExportBPPProc supports_export_bpp_proc; - FI_SupportsExportTypeProc supports_export_type_proc; - FI_SupportsICCProfilesProc supports_icc_profiles_proc; -}; - -typedef void (DLL_CALLCONV *FI_InitProc)(Plugin *plugin, int format_id); - -#endif // PLUGINS - - -// Load / Save flag constants ----------------------------------------------- - -#define BMP_DEFAULT 0 -#define BMP_SAVE_RLE 1 -#define CUT_DEFAULT 0 -#define DDS_DEFAULT 0 -#define EXR_DEFAULT 0 // save data as half with piz-based wavelet compression -#define EXR_FLOAT 0x0001 // save data as float instead of as half (not recommended) -#define EXR_NONE 0x0002 // save with no compression -#define EXR_ZIP 0x0004 // save with zlib compression, in blocks of 16 scan lines -#define EXR_PIZ 0x0008 // save with piz-based wavelet compression -#define EXR_PXR24 0x0010 // save with lossy 24-bit float compression -#define EXR_B44 0x0020 // save with lossy 44% float compression - goes to 22% when combined with EXR_LC -#define EXR_LC 0x0040 // save images with one luminance and two chroma channels, rather than as RGB (lossy compression) -#define FAXG3_DEFAULT 0 -#define GIF_DEFAULT 0 -#define GIF_LOAD256 1 // Load the image as a 256 color image with ununsed palette entries, if it's 16 or 2 color -#define GIF_PLAYBACK 2 // 'Play' the GIF to generate each frame (as 32bpp) instead of returning raw frame data when loading -#define HDR_DEFAULT 0 -#define ICO_DEFAULT 0 -#define ICO_MAKEALPHA 1 // convert to 32bpp and create an alpha channel from the AND-mask when loading -#define IFF_DEFAULT 0 -#define J2K_DEFAULT 0 // save with a 16:1 rate -#define JP2_DEFAULT 0 // save with a 16:1 rate -#define JPEG_DEFAULT 0 // loading (see JPEG_FAST); saving (see JPEG_QUALITYGOOD) -#define JPEG_FAST 0x0001 // load the file as fast as possible, sacrificing some quality -#define JPEG_ACCURATE 0x0002 // load the file with the best quality, sacrificing some speed -#define JPEG_CMYK 0x0004 // load separated CMYK "as is" (use | to combine with other load flags) -#define JPEG_QUALITYSUPERB 0x80 // save with superb quality (100:1) -#define JPEG_QUALITYGOOD 0x0100 // save with good quality (75:1) -#define JPEG_QUALITYNORMAL 0x0200 // save with normal quality (50:1) -#define JPEG_QUALITYAVERAGE 0x0400 // save with average quality (25:1) -#define JPEG_QUALITYBAD 0x0800 // save with bad quality (10:1) -#define JPEG_PROGRESSIVE 0x2000 // save as a progressive-JPEG (use | to combine with other save flags) -#define KOALA_DEFAULT 0 -#define LBM_DEFAULT 0 -#define MNG_DEFAULT 0 -#define PCD_DEFAULT 0 -#define PCD_BASE 1 // load the bitmap sized 768 x 512 -#define PCD_BASEDIV4 2 // load the bitmap sized 384 x 256 -#define PCD_BASEDIV16 3 // load the bitmap sized 192 x 128 -#define PCX_DEFAULT 0 -#define PNG_DEFAULT 0 -#define PNG_IGNOREGAMMA 1 // avoid gamma correction -#define PNM_DEFAULT 0 -#define PNM_SAVE_RAW 0 // If set the writer saves in RAW format (i.e. P4, P5 or P6) -#define PNM_SAVE_ASCII 1 // If set the writer saves in ASCII format (i.e. P1, P2 or P3) -#define PSD_DEFAULT 0 -#define RAS_DEFAULT 0 -#define SGI_DEFAULT 0 -#define TARGA_DEFAULT 0 -#define TARGA_LOAD_RGB888 1 // If set the loader converts RGB555 and ARGB8888 -> RGB888. -#define TIFF_DEFAULT 0 -#define TIFF_CMYK 0x0001 // reads/stores tags for separated CMYK (use | to combine with compression flags) -#define TIFF_PACKBITS 0x0100 // save using PACKBITS compression -#define TIFF_DEFLATE 0x0200 // save using DEFLATE compression (a.k.a. ZLIB compression) -#define TIFF_ADOBE_DEFLATE 0x0400 // save using ADOBE DEFLATE compression -#define TIFF_NONE 0x0800 // save without any compression -#define TIFF_CCITTFAX3 0x1000 // save using CCITT Group 3 fax encoding -#define TIFF_CCITTFAX4 0x2000 // save using CCITT Group 4 fax encoding -#define TIFF_LZW 0x4000 // save using LZW compression -#define TIFF_JPEG 0x8000 // save using JPEG compression -#define WBMP_DEFAULT 0 -#define XBM_DEFAULT 0 -#define XPM_DEFAULT 0 - - -#ifdef __cplusplus -extern "C" { -#endif - -// Init / Error routines ---------------------------------------------------- - -DLL_API void DLL_CALLCONV FreeImage_Initialise(BOOL load_local_plugins_only FI_DEFAULT(FALSE)); -DLL_API void DLL_CALLCONV FreeImage_DeInitialise(void); - -// Version routines --------------------------------------------------------- - -DLL_API const char *DLL_CALLCONV FreeImage_GetVersion(void); -DLL_API const char *DLL_CALLCONV FreeImage_GetCopyrightMessage(void); - -// Message output functions ------------------------------------------------- - -typedef void (*FreeImage_OutputMessageFunction)(FREE_IMAGE_FORMAT fif, const char *msg); -typedef void (DLL_CALLCONV *FreeImage_OutputMessageFunctionStdCall)(FREE_IMAGE_FORMAT fif, const char *msg); - -DLL_API void DLL_CALLCONV FreeImage_SetOutputMessageStdCall(FreeImage_OutputMessageFunctionStdCall omf); -DLL_API void DLL_CALLCONV FreeImage_SetOutputMessage(FreeImage_OutputMessageFunction omf); -DLL_API void DLL_CALLCONV FreeImage_OutputMessageProc(int fif, const char *fmt, ...); - -// Allocate / Clone / Unload routines --------------------------------------- - -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Allocate(int width, int height, int bpp, unsigned red_mask FI_DEFAULT(0), unsigned green_mask FI_DEFAULT(0), unsigned blue_mask FI_DEFAULT(0)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_AllocateT(FREE_IMAGE_TYPE type, int width, int height, int bpp FI_DEFAULT(8), unsigned red_mask FI_DEFAULT(0), unsigned green_mask FI_DEFAULT(0), unsigned blue_mask FI_DEFAULT(0)); -DLL_API FIBITMAP * DLL_CALLCONV FreeImage_Clone(FIBITMAP *dib); -DLL_API void DLL_CALLCONV FreeImage_Unload(FIBITMAP *dib); - -// Load / Save routines ----------------------------------------------------- - -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Load(FREE_IMAGE_FORMAT fif, const char *filename, int flags FI_DEFAULT(0)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadU(FREE_IMAGE_FORMAT fif, const wchar_t *filename, int flags FI_DEFAULT(0)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadFromHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(0)); -DLL_API BOOL DLL_CALLCONV FreeImage_Save(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, const char *filename, int flags FI_DEFAULT(0)); -DLL_API BOOL DLL_CALLCONV FreeImage_SaveU(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, const wchar_t *filename, int flags FI_DEFAULT(0)); -DLL_API BOOL DLL_CALLCONV FreeImage_SaveToHandle(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(0)); - -// Memory I/O stream routines ----------------------------------------------- - -DLL_API FIMEMORY *DLL_CALLCONV FreeImage_OpenMemory(BYTE *data FI_DEFAULT(0), DWORD size_in_bytes FI_DEFAULT(0)); -DLL_API void DLL_CALLCONV FreeImage_CloseMemory(FIMEMORY *stream); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadFromMemory(FREE_IMAGE_FORMAT fif, FIMEMORY *stream, int flags FI_DEFAULT(0)); -DLL_API BOOL DLL_CALLCONV FreeImage_SaveToMemory(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, FIMEMORY *stream, int flags FI_DEFAULT(0)); -DLL_API long DLL_CALLCONV FreeImage_TellMemory(FIMEMORY *stream); -DLL_API BOOL DLL_CALLCONV FreeImage_SeekMemory(FIMEMORY *stream, long offset, int origin); -DLL_API BOOL DLL_CALLCONV FreeImage_AcquireMemory(FIMEMORY *stream, BYTE **data, DWORD *size_in_bytes); -DLL_API unsigned DLL_CALLCONV FreeImage_ReadMemory(void *buffer, unsigned size, unsigned count, FIMEMORY *stream); -DLL_API unsigned DLL_CALLCONV FreeImage_WriteMemory(const void *buffer, unsigned size, unsigned count, FIMEMORY *stream); -DLL_API FIMULTIBITMAP *DLL_CALLCONV FreeImage_LoadMultiBitmapFromMemory(FREE_IMAGE_FORMAT fif, FIMEMORY *stream, int flags FI_DEFAULT(0)); - -// Plugin Interface --------------------------------------------------------- - -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_RegisterLocalPlugin(FI_InitProc proc_address, const char *format FI_DEFAULT(0), const char *description FI_DEFAULT(0), const char *extension FI_DEFAULT(0), const char *regexpr FI_DEFAULT(0)); -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_RegisterExternalPlugin(const char *path, const char *format FI_DEFAULT(0), const char *description FI_DEFAULT(0), const char *extension FI_DEFAULT(0), const char *regexpr FI_DEFAULT(0)); -DLL_API int DLL_CALLCONV FreeImage_GetFIFCount(void); -DLL_API int DLL_CALLCONV FreeImage_SetPluginEnabled(FREE_IMAGE_FORMAT fif, BOOL enable); -DLL_API int DLL_CALLCONV FreeImage_IsPluginEnabled(FREE_IMAGE_FORMAT fif); -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFIFFromFormat(const char *format); -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFIFFromMime(const char *mime); -DLL_API const char *DLL_CALLCONV FreeImage_GetFormatFromFIF(FREE_IMAGE_FORMAT fif); -DLL_API const char *DLL_CALLCONV FreeImage_GetFIFExtensionList(FREE_IMAGE_FORMAT fif); -DLL_API const char *DLL_CALLCONV FreeImage_GetFIFDescription(FREE_IMAGE_FORMAT fif); -DLL_API const char *DLL_CALLCONV FreeImage_GetFIFRegExpr(FREE_IMAGE_FORMAT fif); -DLL_API const char *DLL_CALLCONV FreeImage_GetFIFMimeType(FREE_IMAGE_FORMAT fif); -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFIFFromFilename(const char *filename); -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFIFFromFilenameU(const wchar_t *filename); -DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsReading(FREE_IMAGE_FORMAT fif); -DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsWriting(FREE_IMAGE_FORMAT fif); -DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsExportBPP(FREE_IMAGE_FORMAT fif, int bpp); -DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsExportType(FREE_IMAGE_FORMAT fif, FREE_IMAGE_TYPE type); -DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsICCProfiles(FREE_IMAGE_FORMAT fif); - -// Multipaging interface ---------------------------------------------------- - -DLL_API FIMULTIBITMAP * DLL_CALLCONV FreeImage_OpenMultiBitmap(FREE_IMAGE_FORMAT fif, const char *filename, BOOL create_new, BOOL read_only, BOOL keep_cache_in_memory FI_DEFAULT(FALSE), int flags FI_DEFAULT(0)); -DLL_API BOOL DLL_CALLCONV FreeImage_CloseMultiBitmap(FIMULTIBITMAP *bitmap, int flags FI_DEFAULT(0)); -DLL_API int DLL_CALLCONV FreeImage_GetPageCount(FIMULTIBITMAP *bitmap); -DLL_API void DLL_CALLCONV FreeImage_AppendPage(FIMULTIBITMAP *bitmap, FIBITMAP *data); -DLL_API void DLL_CALLCONV FreeImage_InsertPage(FIMULTIBITMAP *bitmap, int page, FIBITMAP *data); -DLL_API void DLL_CALLCONV FreeImage_DeletePage(FIMULTIBITMAP *bitmap, int page); -DLL_API FIBITMAP * DLL_CALLCONV FreeImage_LockPage(FIMULTIBITMAP *bitmap, int page); -DLL_API void DLL_CALLCONV FreeImage_UnlockPage(FIMULTIBITMAP *bitmap, FIBITMAP *data, BOOL changed); -DLL_API BOOL DLL_CALLCONV FreeImage_MovePage(FIMULTIBITMAP *bitmap, int target, int source); -DLL_API BOOL DLL_CALLCONV FreeImage_GetLockedPageNumbers(FIMULTIBITMAP *bitmap, int *pages, int *count); - -// Filetype request routines ------------------------------------------------ - -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFileType(const char *filename, int size FI_DEFAULT(0)); -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFileTypeU(const wchar_t *filename, int size FI_DEFAULT(0)); -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFileTypeFromHandle(FreeImageIO *io, fi_handle handle, int size FI_DEFAULT(0)); -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFileTypeFromMemory(FIMEMORY *stream, int size FI_DEFAULT(0)); - -// Image type request routine ----------------------------------------------- - -DLL_API FREE_IMAGE_TYPE DLL_CALLCONV FreeImage_GetImageType(FIBITMAP *dib); - -// FreeImage helper routines ------------------------------------------------ - -DLL_API BOOL DLL_CALLCONV FreeImage_IsLittleEndian(void); -DLL_API BOOL DLL_CALLCONV FreeImage_LookupX11Color(const char *szColor, BYTE *nRed, BYTE *nGreen, BYTE *nBlue); -DLL_API BOOL DLL_CALLCONV FreeImage_LookupSVGColor(const char *szColor, BYTE *nRed, BYTE *nGreen, BYTE *nBlue); - - -// Pixel access routines ---------------------------------------------------- - -DLL_API BYTE *DLL_CALLCONV FreeImage_GetBits(FIBITMAP *dib); -DLL_API BYTE *DLL_CALLCONV FreeImage_GetScanLine(FIBITMAP *dib, int scanline); - -DLL_API BOOL DLL_CALLCONV FreeImage_GetPixelIndex(FIBITMAP *dib, unsigned x, unsigned y, BYTE *value); -DLL_API BOOL DLL_CALLCONV FreeImage_GetPixelColor(FIBITMAP *dib, unsigned x, unsigned y, RGBQUAD *value); -DLL_API BOOL DLL_CALLCONV FreeImage_SetPixelIndex(FIBITMAP *dib, unsigned x, unsigned y, BYTE *value); -DLL_API BOOL DLL_CALLCONV FreeImage_SetPixelColor(FIBITMAP *dib, unsigned x, unsigned y, RGBQUAD *value); - -// DIB info routines -------------------------------------------------------- - -DLL_API unsigned DLL_CALLCONV FreeImage_GetColorsUsed(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetBPP(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetWidth(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetHeight(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetLine(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetPitch(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetDIBSize(FIBITMAP *dib); -DLL_API RGBQUAD *DLL_CALLCONV FreeImage_GetPalette(FIBITMAP *dib); - -DLL_API unsigned DLL_CALLCONV FreeImage_GetDotsPerMeterX(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetDotsPerMeterY(FIBITMAP *dib); -DLL_API void DLL_CALLCONV FreeImage_SetDotsPerMeterX(FIBITMAP *dib, unsigned res); -DLL_API void DLL_CALLCONV FreeImage_SetDotsPerMeterY(FIBITMAP *dib, unsigned res); - -DLL_API BITMAPINFOHEADER *DLL_CALLCONV FreeImage_GetInfoHeader(FIBITMAP *dib); -DLL_API BITMAPINFO *DLL_CALLCONV FreeImage_GetInfo(FIBITMAP *dib); -DLL_API FREE_IMAGE_COLOR_TYPE DLL_CALLCONV FreeImage_GetColorType(FIBITMAP *dib); - -DLL_API unsigned DLL_CALLCONV FreeImage_GetRedMask(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetGreenMask(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetBlueMask(FIBITMAP *dib); - -DLL_API unsigned DLL_CALLCONV FreeImage_GetTransparencyCount(FIBITMAP *dib); -DLL_API BYTE * DLL_CALLCONV FreeImage_GetTransparencyTable(FIBITMAP *dib); -DLL_API void DLL_CALLCONV FreeImage_SetTransparent(FIBITMAP *dib, BOOL enabled); -DLL_API void DLL_CALLCONV FreeImage_SetTransparencyTable(FIBITMAP *dib, BYTE *table, int count); -DLL_API BOOL DLL_CALLCONV FreeImage_IsTransparent(FIBITMAP *dib); -DLL_API void DLL_CALLCONV FreeImage_SetTransparentIndex(FIBITMAP *dib, int index); -DLL_API int DLL_CALLCONV FreeImage_GetTransparentIndex(FIBITMAP *dib); - -DLL_API BOOL DLL_CALLCONV FreeImage_HasBackgroundColor(FIBITMAP *dib); -DLL_API BOOL DLL_CALLCONV FreeImage_GetBackgroundColor(FIBITMAP *dib, RGBQUAD *bkcolor); -DLL_API BOOL DLL_CALLCONV FreeImage_SetBackgroundColor(FIBITMAP *dib, RGBQUAD *bkcolor); - - -// ICC profile routines ----------------------------------------------------- - -DLL_API FIICCPROFILE *DLL_CALLCONV FreeImage_GetICCProfile(FIBITMAP *dib); -DLL_API FIICCPROFILE *DLL_CALLCONV FreeImage_CreateICCProfile(FIBITMAP *dib, void *data, long size); -DLL_API void DLL_CALLCONV FreeImage_DestroyICCProfile(FIBITMAP *dib); - -// Line conversion routines ------------------------------------------------- - -DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To4(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To4(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To4_555(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To4_565(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To4(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To4(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To8(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To8(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To8_555(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To8_565(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To8(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To8(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To16_555(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To16_555(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To16_555(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16_565_To16_555(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To16_555(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To16_555(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To16_565(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To16_565(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To16_565(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16_555_To16_565(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To16_565(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To16_565(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To24(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To24(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To24(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To24_555(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To24_565(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To24(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To32(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To32(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To32(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To32_555(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To32_565(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To32(BYTE *target, BYTE *source, int width_in_pixels); - -// Smart conversion routines ------------------------------------------------ - -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo4Bits(FIBITMAP *dib); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo8Bits(FIBITMAP *dib); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToGreyscale(FIBITMAP *dib); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo16Bits555(FIBITMAP *dib); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo16Bits565(FIBITMAP *dib); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo24Bits(FIBITMAP *dib); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo32Bits(FIBITMAP *dib); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ColorQuantize(FIBITMAP *dib, FREE_IMAGE_QUANTIZE quantize); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ColorQuantizeEx(FIBITMAP *dib, FREE_IMAGE_QUANTIZE quantize FI_DEFAULT(FIQ_WUQUANT), int PaletteSize FI_DEFAULT(256), int ReserveSize FI_DEFAULT(0), RGBQUAD *ReservePalette FI_DEFAULT(NULL)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Threshold(FIBITMAP *dib, BYTE T); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Dither(FIBITMAP *dib, FREE_IMAGE_DITHER algorithm); - -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertFromRawBits(BYTE *bits, int width, int height, int pitch, unsigned bpp, unsigned red_mask, unsigned green_mask, unsigned blue_mask, BOOL topdown FI_DEFAULT(FALSE)); -DLL_API void DLL_CALLCONV FreeImage_ConvertToRawBits(BYTE *bits, FIBITMAP *dib, int pitch, unsigned bpp, unsigned red_mask, unsigned green_mask, unsigned blue_mask, BOOL topdown FI_DEFAULT(FALSE)); - -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToRGBF(FIBITMAP *dib); - -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToStandardType(FIBITMAP *src, BOOL scale_linear FI_DEFAULT(TRUE)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToType(FIBITMAP *src, FREE_IMAGE_TYPE dst_type, BOOL scale_linear FI_DEFAULT(TRUE)); - -// tone mapping operators -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ToneMapping(FIBITMAP *dib, FREE_IMAGE_TMO tmo, double first_param FI_DEFAULT(0), double second_param FI_DEFAULT(0)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_TmoDrago03(FIBITMAP *src, double gamma FI_DEFAULT(2.2), double exposure FI_DEFAULT(0)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_TmoReinhard05(FIBITMAP *src, double intensity FI_DEFAULT(0), double contrast FI_DEFAULT(0)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_TmoFattal02(FIBITMAP *src, double color_saturation FI_DEFAULT(0.5), double attenuation FI_DEFAULT(0.85)); - -// ZLib interface ----------------------------------------------------------- - -DLL_API DWORD DLL_CALLCONV FreeImage_ZLibCompress(BYTE *target, DWORD target_size, BYTE *source, DWORD source_size); -DLL_API DWORD DLL_CALLCONV FreeImage_ZLibUncompress(BYTE *target, DWORD target_size, BYTE *source, DWORD source_size); -DLL_API DWORD DLL_CALLCONV FreeImage_ZLibGZip(BYTE *target, DWORD target_size, BYTE *source, DWORD source_size); -DLL_API DWORD DLL_CALLCONV FreeImage_ZLibGUnzip(BYTE *target, DWORD target_size, BYTE *source, DWORD source_size); -DLL_API DWORD DLL_CALLCONV FreeImage_ZLibCRC32(DWORD crc, BYTE *source, DWORD source_size); - -// -------------------------------------------------------------------------- -// Metadata routines -------------------------------------------------------- -// -------------------------------------------------------------------------- - -// tag creation / destruction -DLL_API FITAG *DLL_CALLCONV FreeImage_CreateTag(); -DLL_API void DLL_CALLCONV FreeImage_DeleteTag(FITAG *tag); -DLL_API FITAG *DLL_CALLCONV FreeImage_CloneTag(FITAG *tag); - -// tag getters and setters -DLL_API const char *DLL_CALLCONV FreeImage_GetTagKey(FITAG *tag); -DLL_API const char *DLL_CALLCONV FreeImage_GetTagDescription(FITAG *tag); -DLL_API WORD DLL_CALLCONV FreeImage_GetTagID(FITAG *tag); -DLL_API FREE_IMAGE_MDTYPE DLL_CALLCONV FreeImage_GetTagType(FITAG *tag); -DLL_API DWORD DLL_CALLCONV FreeImage_GetTagCount(FITAG *tag); -DLL_API DWORD DLL_CALLCONV FreeImage_GetTagLength(FITAG *tag); -DLL_API const void *DLL_CALLCONV FreeImage_GetTagValue(FITAG *tag); - -DLL_API BOOL DLL_CALLCONV FreeImage_SetTagKey(FITAG *tag, const char *key); -DLL_API BOOL DLL_CALLCONV FreeImage_SetTagDescription(FITAG *tag, const char *description); -DLL_API BOOL DLL_CALLCONV FreeImage_SetTagID(FITAG *tag, WORD id); -DLL_API BOOL DLL_CALLCONV FreeImage_SetTagType(FITAG *tag, FREE_IMAGE_MDTYPE type); -DLL_API BOOL DLL_CALLCONV FreeImage_SetTagCount(FITAG *tag, DWORD count); -DLL_API BOOL DLL_CALLCONV FreeImage_SetTagLength(FITAG *tag, DWORD length); -DLL_API BOOL DLL_CALLCONV FreeImage_SetTagValue(FITAG *tag, const void *value); - -// iterator -DLL_API FIMETADATA *DLL_CALLCONV FreeImage_FindFirstMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, FITAG **tag); -DLL_API BOOL DLL_CALLCONV FreeImage_FindNextMetadata(FIMETADATA *mdhandle, FITAG **tag); -DLL_API void DLL_CALLCONV FreeImage_FindCloseMetadata(FIMETADATA *mdhandle); - -// metadata setter and getter -DLL_API BOOL DLL_CALLCONV FreeImage_SetMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, const char *key, FITAG *tag); -DLL_API BOOL DLL_CALLCONV FreeImage_GetMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, const char *key, FITAG **tag); - -// helpers -DLL_API unsigned DLL_CALLCONV FreeImage_GetMetadataCount(FREE_IMAGE_MDMODEL model, FIBITMAP *dib); - -// tag to C string conversion -DLL_API const char* DLL_CALLCONV FreeImage_TagToString(FREE_IMAGE_MDMODEL model, FITAG *tag, char *Make FI_DEFAULT(NULL)); - -// -------------------------------------------------------------------------- -// Image manipulation toolkit ----------------------------------------------- -// -------------------------------------------------------------------------- - -// rotation and flipping -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_RotateClassic(FIBITMAP *dib, double angle); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_RotateEx(FIBITMAP *dib, double angle, double x_shift, double y_shift, double x_origin, double y_origin, BOOL use_mask); -DLL_API BOOL DLL_CALLCONV FreeImage_FlipHorizontal(FIBITMAP *dib); -DLL_API BOOL DLL_CALLCONV FreeImage_FlipVertical(FIBITMAP *dib); -DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransform(const char *src_file, const char *dst_file, FREE_IMAGE_JPEG_OPERATION operation, BOOL perfect FI_DEFAULT(FALSE)); - -// upsampling / downsampling -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Rescale(FIBITMAP *dib, int dst_width, int dst_height, FREE_IMAGE_FILTER filter); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_MakeThumbnail(FIBITMAP *dib, int max_pixel_size, BOOL convert FI_DEFAULT(TRUE)); - -// color manipulation routines (point operations) -DLL_API BOOL DLL_CALLCONV FreeImage_AdjustCurve(FIBITMAP *dib, BYTE *LUT, FREE_IMAGE_COLOR_CHANNEL channel); -DLL_API BOOL DLL_CALLCONV FreeImage_AdjustGamma(FIBITMAP *dib, double gamma); -DLL_API BOOL DLL_CALLCONV FreeImage_AdjustBrightness(FIBITMAP *dib, double percentage); -DLL_API BOOL DLL_CALLCONV FreeImage_AdjustContrast(FIBITMAP *dib, double percentage); -DLL_API BOOL DLL_CALLCONV FreeImage_Invert(FIBITMAP *dib); -DLL_API BOOL DLL_CALLCONV FreeImage_GetHistogram(FIBITMAP *dib, DWORD *histo, FREE_IMAGE_COLOR_CHANNEL channel FI_DEFAULT(FICC_BLACK)); -DLL_API int DLL_CALLCONV FreeImage_GetAdjustColorsLookupTable(BYTE *LUT, double brightness, double contrast, double gamma, BOOL invert); -DLL_API BOOL DLL_CALLCONV FreeImage_AdjustColors(FIBITMAP *dib, double brightness, double contrast, double gamma, BOOL invert FI_DEFAULT(FALSE)); -DLL_API unsigned DLL_CALLCONV FreeImage_ApplyColorMapping(FIBITMAP *dib, RGBQUAD *srccolors, RGBQUAD *dstcolors, unsigned count, BOOL ignore_alpha, BOOL swap); -DLL_API unsigned DLL_CALLCONV FreeImage_SwapColors(FIBITMAP *dib, RGBQUAD *color_a, RGBQUAD *color_b, BOOL ignore_alpha); -DLL_API unsigned DLL_CALLCONV FreeImage_ApplyPaletteIndexMapping(FIBITMAP *dib, BYTE *srcindices, BYTE *dstindices, unsigned count, BOOL swap); -DLL_API unsigned DLL_CALLCONV FreeImage_SwapPaletteIndices(FIBITMAP *dib, BYTE *index_a, BYTE *index_b); - -// channel processing routines -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_GetChannel(FIBITMAP *dib, FREE_IMAGE_COLOR_CHANNEL channel); -DLL_API BOOL DLL_CALLCONV FreeImage_SetChannel(FIBITMAP *dib, FIBITMAP *dib8, FREE_IMAGE_COLOR_CHANNEL channel); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_GetComplexChannel(FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL channel); -DLL_API BOOL DLL_CALLCONV FreeImage_SetComplexChannel(FIBITMAP *dst, FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL channel); - -// copy / paste / composite routines -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Copy(FIBITMAP *dib, int left, int top, int right, int bottom); -DLL_API BOOL DLL_CALLCONV FreeImage_Paste(FIBITMAP *dst, FIBITMAP *src, int left, int top, int alpha); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Composite(FIBITMAP *fg, BOOL useFileBkg FI_DEFAULT(FALSE), RGBQUAD *appBkColor FI_DEFAULT(NULL), FIBITMAP *bg FI_DEFAULT(NULL)); -DLL_API BOOL DLL_CALLCONV FreeImage_JPEGCrop(const char *src_file, const char *dst_file, int left, int top, int right, int bottom); -DLL_API BOOL DLL_CALLCONV FreeImage_PreMultiplyWithAlpha(FIBITMAP *dib); - -// miscellaneous algorithms -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_MultigridPoissonSolver(FIBITMAP *Laplacian, int ncycle FI_DEFAULT(3)); - -// restore the borland-specific enum size option -#if defined(__BORLANDC__) -#pragma option pop -#endif - -#ifdef __cplusplus -} -#endif - -#endif // FREEIMAGE_H diff --git a/plugins/AdvaImg/Docs/license-gplv2.txt b/plugins/AdvaImg/Docs/license-gplv2.txt new file mode 100644 index 0000000000..6020906a93 --- /dev/null +++ b/plugins/AdvaImg/Docs/license-gplv2.txt @@ -0,0 +1,126 @@ +GNU General Public License, version 2 (GPL-2.0) +[OSI Approved License] +The GNU General Public License (GPL-2.0) +Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. +59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification follow. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. + + c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + + One line to give the program's name and a brief idea of what it does. + Copyright (C) + + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. + + signature of Ty Coon, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. diff --git a/plugins/AdvaImg/Docs/license-gplv3.txt b/plugins/AdvaImg/Docs/license-gplv3.txt new file mode 100644 index 0000000000..5ec7b1aefc --- /dev/null +++ b/plugins/AdvaImg/Docs/license-gplv3.txt @@ -0,0 +1,228 @@ +GNU General Public License, version 3 (GPL-3.0) +[OSI Approved License] +GNU GENERAL PUBLIC LICENSE + +Version 3, 29 June 2007 + +Copyright (C) 2007 Free Software Foundation, Inc. + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. +Preamble + +The GNU General Public License is a free, copyleft license for software and other kinds of works. + +The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. + +To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. + +For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. + +Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. + +Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. + +The precise terms and conditions for copying, distribution and modification follow. +TERMS AND CONDITIONS +0. Definitions. + +“This License” refers to version 3 of the GNU General Public License. + +“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. + +“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations. + +To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work. + +A “covered work” means either the unmodified Program or a work based on the Program. + +To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. + +To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. + +An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. +1. Source Code. + +The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work. + +A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. + +The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. + +The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. + +The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. + +The Corresponding Source for a work in source code form is that same work. +2. Basic Permissions. + +All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. + +Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. +3. Protecting Users' Legal Rights From Anti-Circumvention Law. + +No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. + +When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. +4. Conveying Verbatim Copies. + +You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. + +You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. +5. Conveying Modified Source Versions. + +You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified it, and giving a relevant date. + b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”. + c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. + d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. + +A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. +6. Conveying Non-Source Forms. + +You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: + + a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. + b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. + c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. + d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. + e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. + +A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. + +A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. + +“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. + +If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). + +The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. + +Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. +7. Additional Terms. + +“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or + b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or + c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or + d) Limiting the use for publicity purposes of names of licensors or authors of the material; or + e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or + f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. + +All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. + +If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. +8. Termination. + +You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). + +However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. + +Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. + +Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. +9. Acceptance Not Required for Having Copies. + +You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. +10. Automatic Licensing of Downstream Recipients. + +Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. + +An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. +11. Patents. + +A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”. + +A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. + +In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. + +If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. + +A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. +12. No Surrender of Others' Freedom. + +If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. +13. Use with the GNU Affero General Public License. + +Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. +14. Revised Versions of this License. + +The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. + +If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. + +Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. +15. Disclaimer of Warranty. + +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. +16. Limitation of Liability. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +17. Interpretation of Sections 15 and 16. + +If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. + +END OF TERMS AND CONDITIONS +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + +If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: + + Copyright (C) + + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”. + +You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . + +The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . diff --git a/plugins/AdvaImg/res/AdvaImg.rc b/plugins/AdvaImg/res/AdvaImg.rc deleted file mode 100644 index 28b78c7627..0000000000 --- a/plugins/AdvaImg/res/AdvaImg.rc +++ /dev/null @@ -1,103 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "winres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Neutral resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) -#ifdef _WIN32 -LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_OPENSUBCLASS, DIALOG - BEGIN - RIGHTMARGIN, 208 - TOPMARGIN, 7 - END - - IDD_AVATAROPTIONS, DIALOG - BEGIN - RIGHTMARGIN, 207 - BOTTOMMARGIN, 211 - END - - IDD_USER_AVATAR, DIALOG - BEGIN - LEFTMARGIN, 3 - RIGHTMARGIN, 218 - TOPMARGIN, 4 - BOTTOMMARGIN, 148 - END -END -#endif // APSTUDIO_INVOKED - -#endif // Neutral resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// German (Germany) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) -#ifdef _WIN32 -LANGUAGE LANG_GERMAN, SUBLANG_GERMAN -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "\r\n" -END - -2 TEXTINCLUDE -BEGIN - "#include ""winres.h""\r\n" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" -END - -#endif // APSTUDIO_INVOKED - -#endif // German (Germany) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/plugins/AdvaImg/src/DeprecationManager/Deprecated.cpp b/plugins/AdvaImg/src/DeprecationManager/Deprecated.cpp deleted file mode 100644 index 8ca5e71c5c..0000000000 --- a/plugins/AdvaImg/src/DeprecationManager/Deprecated.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// ========================================================== -// Deprecated functions -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// - Hervé Drolon (drolon@infonie.fr) -// -// This file is part of FreeImage 3 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include "FreeImage.h" - -#include "../DeprecationManager/DeprecationMgr.h" - -// ---------------------------------------------------------- - -FIBITMAP *DLL_CALLCONV -FreeImage_RotateClassic(FIBITMAP *dib, double angle) { -#ifdef _WIN32 - DEPRECATE("FreeImage_RotateClassic()", "FreeImage_Rotate()") -#endif // _WIN32 - return FreeImage_Rotate(dib, angle, NULL); -} - diff --git a/plugins/AdvaImg/src/DeprecationManager/DeprecationMgr.cpp b/plugins/AdvaImg/src/DeprecationManager/DeprecationMgr.cpp deleted file mode 100644 index bf82dfa33b..0000000000 --- a/plugins/AdvaImg/src/DeprecationManager/DeprecationMgr.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// ========================================================== -// Deprecation Manager -// -// Design and implementation by -// - Noel Llopis (Game Programming Gems II) -// -// This file is part of FreeImage 3 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#ifdef _MSC_VER -#pragma warning (disable : 4786) // identifier was truncated to 'number' characters -#endif - -#ifdef _WIN32 -#include -#endif // _WIN32 -#include "FreeImage.h" -#include "Utilities.h" -#include "DeprecationMgr.h" - -// ========================================================== - -DeprecationMgr::DeprecationMgr() { -} - -DeprecationMgr::~DeprecationMgr() { -#ifdef _WIN32 - if (!m_functions.empty()) { - OutputDebugString( "*************************************************************************************\n" ); - OutputDebugString( "This is a warning, because you use one or more deprecated functions.\nContinuing to use these functions might eventually render your program uncompilable.\nThe following functions are deprecated:\n\n" ); - - for (std::map::iterator i = m_functions.begin(); i != m_functions.end(); ++i) { - DeprecatedFunction *function = &((*i).second); - - char txt[255]; - - sprintf(txt, " * %s called from %i different places. Instead use %s.\n", function->old_function_name, function->called_from.size(), function->new_function_name); - - OutputDebugString(txt); - } - - OutputDebugString( "*************************************************************************************\n" ); - - m_functions.clear(); - } -#endif // _WIN32 -} - -// ========================================================== - -DeprecationMgr * -DeprecationMgr::GetInstance() { - static DeprecationMgr Instance; - return &Instance; -} - -// ========================================================== - -void -DeprecationMgr::AddDeprecatedFunction(const char *old_function_name, const char *new_function_name, const void *frame_ptr) { -#ifdef _WIN32 - int *preturn = (int *)frame_ptr + 1; // usual return address @ [ebp+4] - int called_from = IsBadReadPtr(preturn, 4) ? 0 : *preturn; - - // check if this function was already listed as deprecated - // if it wasn't, make a new entry for it - // if it was, keep track of where it's called from. - - std::map::iterator existing_function = m_functions.find(old_function_name); - - if (existing_function == m_functions.end()) { - DeprecatedFunction function; - - function.old_function_name = old_function_name; - function.new_function_name = new_function_name; - function.called_from.insert(called_from); - - m_functions[old_function_name] = function; - } else { - // since we're keeping track of the addresses this function - // was called from in a set, we don't need to check whether we've - // already added the address. - - DeprecatedFunction *function = &((*existing_function).second); - - function->called_from.insert(called_from); - } -#endif // _WIN32 -} - - diff --git a/plugins/AdvaImg/src/DeprecationManager/DeprecationMgr.h b/plugins/AdvaImg/src/DeprecationManager/DeprecationMgr.h deleted file mode 100644 index 9141f23a05..0000000000 --- a/plugins/AdvaImg/src/DeprecationManager/DeprecationMgr.h +++ /dev/null @@ -1,83 +0,0 @@ -// ========================================================== -// Deprecation Manager -// -// Design and implementation by -// - Noel Llopis (Game Programming Gems II) -// -// This file is part of FreeImage 3 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#ifndef DEPRECATIONMGR_H -#define DEPRECATIONMGR_H - -#ifdef _MSC_VER -#pragma warning(disable : 4786 ) // identifier was truncated to 'number' characters -#endif - -#include "Utilities.h" - -// ========================================================== - -#if !defined(_M_X64) && defined(_MSC_VER) - #define DEPRECATE(a,b) \ - { \ - void *fptr; \ - _asm { mov fptr, ebp } \ - DeprecationMgr::GetInstance()->AddDeprecatedFunction(a, b, fptr); \ - } - -#elif defined(__i386__) && defined(__GNUC__) - #define DEPRECATE(a,b) \ - { \ - void *fptr; \ - __asm__("movl %%ebp, %0" : "=m" (fptr)); \ - DeprecationMgr::GetInstance()->AddDeprecatedFunction(a, b, fptr); \ - } - -#else - // default fallback case, which does not use the ebp register's content - #define DEPRECATE(a,b) \ - { \ - void *fptr = NULL; \ - DeprecationMgr::GetInstance()->AddDeprecatedFunction(a, b, fptr); \ - } -#endif - -// ========================================================== - -class DeprecationMgr { -#if (_MSC_VER == 1100) // VC 5.0 need to look into the docs for the compiler for the value of each version -public: -#else -private: -#endif - - struct DeprecatedFunction { - const char *old_function_name; - const char *new_function_name; - std::set called_from; - }; - - std::map m_functions; - -public: - DeprecationMgr(); - ~DeprecationMgr(); - - static DeprecationMgr * GetInstance ( void ); - void AddDeprecatedFunction(const char *old_function_name, const char *new_function_name, const void *frame_ptr); -}; - -#endif //DEPRECATIONMGR_H diff --git a/plugins/AdvaImg/src/FreeImage.h b/plugins/AdvaImg/src/FreeImage.h index a7090adf59..532efc88d8 100644 --- a/plugins/AdvaImg/src/FreeImage.h +++ b/plugins/AdvaImg/src/FreeImage.h @@ -30,7 +30,7 @@ #define FREEIMAGE_MAJOR_VERSION 3 #define FREEIMAGE_MINOR_VERSION 15 -#define FREEIMAGE_RELEASE_SERIAL 3 +#define FREEIMAGE_RELEASE_SERIAL 4 // Compiler options --------------------------------------------------------- @@ -141,8 +141,8 @@ typedef uint8_t BYTE; typedef uint16_t WORD; typedef uint32_t DWORD; typedef int32_t LONG; -typedef int64_t FIINT64; -typedef uint64_t FIUINT64; +typedef int64_t INT64; +typedef uint64_t UINT64; #else // MS is not C99 ISO compliant typedef long BOOL; @@ -150,8 +150,8 @@ typedef unsigned char BYTE; typedef unsigned short WORD; typedef unsigned long DWORD; typedef long LONG; -typedef signed __int64 FIINT64; -typedef unsigned __int64 FIUINT64; +typedef signed __int64 INT64; +typedef unsigned __int64 UINT64; #endif // _MSC_VER #if (defined(_WIN32) || defined(__WIN32__)) @@ -649,7 +649,7 @@ typedef void (DLL_CALLCONV *FI_InitProc)(Plugin *plugin, int format_id); // Load / Save flag constants ----------------------------------------------- -#define FIF_LOAD_NOPIXELS 0x8000 // loading: load the image header only (not supported by all plugins) +#define FIF_LOAD_NOPIXELS 0x8000 // loading: load the image header only (not supported by all plugins, default to full loading) #define BMP_DEFAULT 0 #define BMP_SAVE_RLE 1 @@ -678,6 +678,7 @@ typedef void (DLL_CALLCONV *FI_InitProc)(Plugin *plugin, int format_id); #define JPEG_ACCURATE 0x0002 // load the file with the best quality, sacrificing some speed #define JPEG_CMYK 0x0004 // load separated CMYK "as is" (use | to combine with other load flags) #define JPEG_EXIFROTATE 0x0008 // load and rotate according to Exif 'Orientation' tag if available +#define JPEG_GREYSCALE 0x0010 // load and convert to a 8-bit greyscale image #define JPEG_QUALITYSUPERB 0x80 // save with superb quality (100:1) #define JPEG_QUALITYGOOD 0x0100 // save with good quality (75:1) #define JPEG_QUALITYNORMAL 0x0200 // save with normal quality (50:1) diff --git a/plugins/AdvaImg/src/FreeImage/BitmapAccess.cpp b/plugins/AdvaImg/src/FreeImage/BitmapAccess.cpp index 584870f359..5b90ed8607 100644 --- a/plugins/AdvaImg/src/FreeImage/BitmapAccess.cpp +++ b/plugins/AdvaImg/src/FreeImage/BitmapAccess.cpp @@ -39,6 +39,12 @@ #include "../Metadata/FreeImageTag.h" +/** Constants for the BITMAPINFOHEADER::biCompression field */ +#ifndef _WINGDI_ +#define BI_RGB 0L +#define BI_BITFIELDS 3L +#endif // _WINGDI_ + // ---------------------------------------------------------- // Metadata definitions // ---------------------------------------------------------- @@ -62,10 +68,6 @@ FI_STRUCT (METADATAHEADER) { FI_STRUCT (FREEIMAGEHEADER) { FREE_IMAGE_TYPE type; // data type - bitmap, array of long, double, complex, etc - unsigned red_mask; // bit layout of the red components - unsigned green_mask; // bit layout of the green components - unsigned blue_mask; // bit layout of the blue components - RGBQUAD bkgnd_color; // background color used for RGB transparency BOOL transparent; // why another table? for easy transparency table retrieval! @@ -83,11 +85,21 @@ FI_STRUCT (FREEIMAGEHEADER) { //BYTE filler[1]; // fill to 32-bit alignment }; +// ---------------------------------------------------------- +// FREEIMAGERGBMASKS definition +// ---------------------------------------------------------- + +FI_STRUCT (FREEIMAGERGBMASKS) { + unsigned red_mask; // bit layout of the red components + unsigned green_mask; // bit layout of the green components + unsigned blue_mask; // bit layout of the blue components +}; + // ---------------------------------------------------------- // Memory allocation on a specified alignment boundary // ---------------------------------------------------------- -#if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__) && (!defined(_MSC_VER) || _MSC_VER >= 1300) +#if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__) void* FreeImage_Aligned_Malloc(size_t amount, size_t alignment) { assert(alignment == FIBITMAP_ALIGNMENT); @@ -130,7 +142,7 @@ void* FreeImage_Aligned_Malloc(size_t amount, size_t alignment) { That's why the code below allocates *two* alignments instead of one. */ void* mem_real = malloc(amount + 2 * alignment); - if (!mem_real) return NULL; + if(!mem_real) return NULL; char* mem_align = (char*)((unsigned long)(2 * alignment - (unsigned long)mem_real % (unsigned long)alignment) + (unsigned long)mem_real); *((long*)mem_align - 1) = (long)mem_real; return mem_align; @@ -154,18 +166,22 @@ Align the palette and the pixels on a FIBITMAP_ALIGNMENT bytes alignment boundar @param width @param height @param bpp +@param need_masks @see FreeImage_AllocateHeaderT */ static size_t -FreeImage_GetImageSizeHeader(BOOL header_only, unsigned width, unsigned height, unsigned bpp) { +FreeImage_GetImageSizeHeader(BOOL header_only, unsigned width, unsigned height, unsigned bpp, BOOL need_masks) { size_t dib_size = sizeof(FREEIMAGEHEADER); dib_size += (dib_size % FIBITMAP_ALIGNMENT ? FIBITMAP_ALIGNMENT - dib_size % FIBITMAP_ALIGNMENT : 0); dib_size += FIBITMAP_ALIGNMENT - sizeof(BITMAPINFOHEADER) % FIBITMAP_ALIGNMENT; dib_size += sizeof(BITMAPINFOHEADER); // palette is aligned on a 16 bytes boundary - dib_size += sizeof(RGBQUAD) * CalculateUsedPaletteEntries(bpp); + dib_size += sizeof(RGBQUAD) * CalculateUsedPaletteEntries(bpp); + // we both add palette size and masks size if need_masks is true, since CalculateUsedPaletteEntries + // always returns 0 if need_masks is true (which is only true for 16 bit images). + dib_size += need_masks ? sizeof(DWORD) * 3 : 0; dib_size += (dib_size % FIBITMAP_ALIGNMENT ? FIBITMAP_ALIGNMENT - dib_size % FIBITMAP_ALIGNMENT : 0); - if (!header_only) { + if(!header_only) { const size_t header_size = dib_size; // pixels are aligned on a 16 bytes boundary @@ -196,74 +212,98 @@ FreeImage_GetImageSizeHeader(BOOL header_only, unsigned width, unsigned height, return dib_size; } +/** +Helper for 16-bit FIT_BITMAP +Returns a pointer to the bitmap's red-, green- and blue masks. +@param dib The bitmap to obtain masks from. +@return Returns a pointer to the bitmap's red-, green- and blue masks +or NULL, if no masks are present (e.g. for 24 bit images). +*/ +static FREEIMAGERGBMASKS * +FreeImage_GetRGBMasks(FIBITMAP *dib) { + return FreeImage_HasRGBMasks(dib) ? (FREEIMAGERGBMASKS *)(((BYTE *)FreeImage_GetInfoHeader(dib)) + sizeof(BITMAPINFOHEADER)) : NULL; +} + FIBITMAP * DLL_CALLCONV FreeImage_AllocateHeaderT(BOOL header_only, FREE_IMAGE_TYPE type, int width, int height, int bpp, unsigned red_mask, unsigned green_mask, unsigned blue_mask) { + + // check input variables + width = abs(width); + height = abs(height); + if(!((width > 0) && (height > 0))) { + return NULL; + } + + // we only store the masks (and allocate memory for + // them) for 16 images of type FIT_BITMAP + BOOL need_masks = FALSE; + + // check pixel bit depth + switch(type) { + case FIT_BITMAP: + switch(bpp) { + case 1: + case 4: + case 8: + break; + case 16: + need_masks = TRUE; + break; + case 24: + case 32: + break; + default: + bpp = 8; + break; + } + break; + case FIT_UINT16: + bpp = 8 * sizeof(unsigned short); + break; + case FIT_INT16: + bpp = 8 * sizeof(short); + break; + case FIT_UINT32: + bpp = 8 * sizeof(DWORD); + break; + case FIT_INT32: + bpp = 8 * sizeof(LONG); + break; + case FIT_FLOAT: + bpp = 8 * sizeof(float); + break; + case FIT_DOUBLE: + bpp = 8 * sizeof(double); + break; + case FIT_COMPLEX: + bpp = 8 * sizeof(FICOMPLEX); + break; + case FIT_RGB16: + bpp = 8 * sizeof(FIRGB16); + break; + case FIT_RGBA16: + bpp = 8 * sizeof(FIRGBA16); + break; + case FIT_RGBF: + bpp = 8 * sizeof(FIRGBF); + break; + case FIT_RGBAF: + bpp = 8 * sizeof(FIRGBAF); + break; + default: + return NULL; + } + FIBITMAP *bitmap = (FIBITMAP *)malloc(sizeof(FIBITMAP)); if (bitmap != NULL) { - width = abs(width); - height = abs(height); - - // check pixel bit depth - switch(type) { - case FIT_BITMAP: - switch(bpp) { - case 1: - case 4: - case 8: - case 16: - case 24: - case 32: - break; - default: - bpp = 8; - break; - } - break; - case FIT_UINT16: - bpp = 8 * sizeof(unsigned short); - break; - case FIT_INT16: - bpp = 8 * sizeof(short); - break; - case FIT_UINT32: - bpp = 8 * sizeof(DWORD); - break; - case FIT_INT32: - bpp = 8 * sizeof(LONG); - break; - case FIT_FLOAT: - bpp = 8 * sizeof(float); - break; - case FIT_DOUBLE: - bpp = 8 * sizeof(double); - break; - case FIT_COMPLEX: - bpp = 8 * sizeof(FICOMPLEX); - break; - case FIT_RGB16: - bpp = 8 * sizeof(FIRGB16); - break; - case FIT_RGBA16: - bpp = 8 * sizeof(FIRGBA16); - break; - case FIT_RGBF: - bpp = 8 * sizeof(FIRGBF); - break; - case FIT_RGBAF: - bpp = 8 * sizeof(FIRGBAF); - break; - default: - free(bitmap); - return NULL; - } // calculate the size of a FreeImage image // align the palette and the pixels on a FIBITMAP_ALIGNMENT bytes alignment boundary // palette is aligned on a 16 bytes boundary // pixels are aligned on a 16 bytes boundary - size_t dib_size = FreeImage_GetImageSizeHeader(header_only, width, height, bpp); + size_t dib_size = FreeImage_GetImageSizeHeader(header_only, width, height, bpp, need_masks); if(dib_size == 0) { // memory allocation will fail (probably a malloc overflow) @@ -281,10 +321,6 @@ FreeImage_AllocateHeaderT(BOOL header_only, FREE_IMAGE_TYPE type, int width, int FREEIMAGEHEADER *fih = (FREEIMAGEHEADER *)bitmap->data; fih->type = type; - fih->red_mask = red_mask; - fih->green_mask = green_mask; - fih->blue_mask = blue_mask; - memset(&fih->bkgnd_color, 0, sizeof(RGBQUAD)); fih->transparent = FALSE; @@ -315,7 +351,7 @@ FreeImage_AllocateHeaderT(BOOL header_only, FREE_IMAGE_TYPE type, int width, int bih->biWidth = width; bih->biHeight = height; bih->biPlanes = 1; - bih->biCompression = 0; + bih->biCompression = need_masks ? BI_BITFIELDS : BI_RGB; bih->biBitCount = (WORD)bpp; bih->biClrUsed = CalculateUsedPaletteEntries(bpp); bih->biClrImportant = bih->biClrUsed; @@ -332,6 +368,14 @@ FreeImage_AllocateHeaderT(BOOL header_only, FREE_IMAGE_TYPE type, int width, int } } + // just setting the masks (only if needed) just like the palette. + if (need_masks) { + FREEIMAGERGBMASKS *masks = FreeImage_GetRGBMasks(bitmap); + masks->red_mask = red_mask; + masks->green_mask = green_mask; + masks->blue_mask = blue_mask; + } + return bitmap; } @@ -396,17 +440,20 @@ FreeImage_Unload(FIBITMAP *dib) { FIBITMAP * DLL_CALLCONV FreeImage_Clone(FIBITMAP *dib) { - if (!dib) return NULL; + if(!dib) return NULL; - unsigned width = FreeImage_GetWidth(dib); - unsigned height = FreeImage_GetHeight(dib); - unsigned bpp = FreeImage_GetBPP(dib); + FREE_IMAGE_TYPE type = FreeImage_GetImageType(dib); + unsigned width = FreeImage_GetWidth(dib); + unsigned height = FreeImage_GetHeight(dib); + unsigned bpp = FreeImage_GetBPP(dib); // check for pixel availability ... BOOL header_only = FreeImage_HasPixels(dib) ? FALSE : TRUE; + // check whether this image has masks defined ... + BOOL need_masks = (bpp == 16 && type == FIT_BITMAP) ? TRUE : FALSE; // allocate a new dib - FIBITMAP *new_dib = FreeImage_AllocateHeaderT(header_only, FreeImage_GetImageType(dib), width, height, bpp, + FIBITMAP *new_dib = FreeImage_AllocateHeaderT(header_only, type, width, height, bpp, FreeImage_GetRedMask(dib), FreeImage_GetGreenMask(dib), FreeImage_GetBlueMask(dib)); if (new_dib) { @@ -423,7 +470,7 @@ FreeImage_Clone(FIBITMAP *dib) { // palette is aligned on a 16 bytes boundary // pixels are aligned on a 16 bytes boundary - size_t dib_size = FreeImage_GetImageSizeHeader(header_only, width, height, bpp); + size_t dib_size = FreeImage_GetImageSizeHeader(header_only, width, height, bpp, need_masks); // copy the bitmap + internal pointers (remember to restore new_dib internal pointers later) memcpy(new_dib->data, dib->data, dib_size); @@ -578,15 +625,19 @@ FreeImage_GetColorType(FIBITMAP *dib) { if (FreeImage_GetICCProfile(dib)->flags & FIICC_COLOR_IS_CMYK) return FIC_CMYK; - for (unsigned y = 0; y < FreeImage_GetHeight(dib); y++) { - rgb = (RGBQUAD *)FreeImage_GetScanLine(dib, y); + if( FreeImage_HasPixels(dib) ) { + // check for fully opaque alpha layer + for (unsigned y = 0; y < FreeImage_GetHeight(dib); y++) { + rgb = (RGBQUAD *)FreeImage_GetScanLine(dib, y); - for (unsigned x = 0; x < FreeImage_GetWidth(dib); x++) - if (rgb[x].rgbReserved != 0xFF) - return FIC_RGBALPHA; + for (unsigned x = 0; x < FreeImage_GetWidth(dib); x++) + if (rgb[x].rgbReserved != 0xFF) + return FIC_RGBALPHA; + } + return FIC_RGB; } - return FIC_RGB; + return FIC_RGBALPHA; } default : @@ -610,19 +661,27 @@ FreeImage_HasPixels(FIBITMAP *dib) { // ---------------------------------------------------------- +BOOL DLL_CALLCONV +FreeImage_HasRGBMasks(FIBITMAP *dib) { + return dib && FreeImage_GetInfoHeader(dib)->biCompression == BI_BITFIELDS; +} + unsigned DLL_CALLCONV FreeImage_GetRedMask(FIBITMAP *dib) { - return dib ? ((FREEIMAGEHEADER *)dib->data)->red_mask : 0; + FREEIMAGERGBMASKS *masks = FreeImage_GetRGBMasks(dib); + return masks ? masks->red_mask : 0; } unsigned DLL_CALLCONV FreeImage_GetGreenMask(FIBITMAP *dib) { - return dib ? ((FREEIMAGEHEADER *)dib->data)->green_mask : 0; + FREEIMAGERGBMASKS *masks = FreeImage_GetRGBMasks(dib); + return masks ? masks->green_mask : 0; } unsigned DLL_CALLCONV FreeImage_GetBlueMask(FIBITMAP *dib) { - return dib ? ((FREEIMAGEHEADER *)dib->data)->blue_mask : 0; + FREEIMAGERGBMASKS *masks = FreeImage_GetRGBMasks(dib); + return masks ? masks->blue_mask : 0; } // ---------------------------------------------------------- @@ -736,9 +795,9 @@ FreeImage_GetTransparencyCount(FIBITMAP *dib) { void DLL_CALLCONV FreeImage_SetTransparencyTable(FIBITMAP *dib, BYTE *table, int count) { if (dib) { - count = MIN(count, 256); + count = MAX(0, MIN(count, 256)); if (FreeImage_GetBPP(dib) <= 8) { - ((FREEIMAGEHEADER *)dib->data)->transparent = TRUE; + ((FREEIMAGEHEADER *)dib->data)->transparent = (count > 0) ? TRUE : FALSE; ((FREEIMAGEHEADER *)dib->data)->transparency_count = count; if (table) { @@ -915,7 +974,7 @@ FreeImage_SetDotsPerMeterY(FIBITMAP *dib, unsigned res) { BITMAPINFOHEADER * DLL_CALLCONV FreeImage_GetInfoHeader(FIBITMAP *dib) { - if (!dib) return NULL; + if(!dib) return NULL; size_t lp = (size_t)dib->data + sizeof(FREEIMAGEHEADER); lp += (lp % FIBITMAP_ALIGNMENT ? FIBITMAP_ALIGNMENT - lp % FIBITMAP_ALIGNMENT : 0); lp += FIBITMAP_ALIGNMENT - sizeof(BITMAPINFOHEADER) % FIBITMAP_ALIGNMENT; @@ -933,13 +992,13 @@ FreeImage_GetInfo(FIBITMAP *dib) { FIMETADATA * DLL_CALLCONV FreeImage_FindFirstMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, FITAG **tag) { - if (!dib) + if(!dib) return NULL; // get the metadata model METADATAMAP *metadata = ((FREEIMAGEHEADER *)dib->data)->metadata; TAGMAP *tagmap = NULL; - if ( (*metadata).find(model) != (*metadata).end()) { + if( (*metadata).find(model) != (*metadata).end() ) { tagmap = (*metadata)[model]; } if(tagmap) { @@ -976,7 +1035,7 @@ FreeImage_FindFirstMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, FITAG **tag BOOL DLL_CALLCONV FreeImage_FindNextMetadata(FIMETADATA *mdhandle, FITAG **tag) { - if (!mdhandle) + if(!mdhandle) return FALSE; METADATAHEADER *mdh = (METADATAHEADER *)mdhandle->data; @@ -1019,7 +1078,7 @@ FreeImage_FindCloseMetadata(FIMETADATA *mdhandle) { BOOL DLL_CALLCONV FreeImage_CloneMetadata(FIBITMAP *dst, FIBITMAP *src) { - if (!src || !dst) return FALSE; + if(!src || !dst) return FALSE; // get metadata links METADATAMAP *src_metadata = ((FREEIMAGEHEADER *)src->data)->metadata; @@ -1034,7 +1093,7 @@ FreeImage_CloneMetadata(FIBITMAP *dst, FIBITMAP *src) { TAGMAP *src_tagmap = (*i).second; if(src_tagmap) { - if ( dst_metadata->find(model) != dst_metadata->end()) { + if( dst_metadata->find(model) != dst_metadata->end() ) { // destroy dst model FreeImage_SetMetadata((FREE_IMAGE_MDMODEL)model, dst, NULL, NULL); } @@ -1069,7 +1128,7 @@ FreeImage_CloneMetadata(FIBITMAP *dst, FIBITMAP *src) { BOOL DLL_CALLCONV FreeImage_SetMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, const char *key, FITAG *tag) { - if (!dib) + if(!dib) return FALSE; TAGMAP *tagmap = NULL; @@ -1083,7 +1142,7 @@ FreeImage_SetMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, const char *key, if(key != NULL) { - if (!tagmap) { + if(!tagmap) { // this model, doesn't exist: create it tagmap = new(std::nothrow) TAGMAP(); (*metadata)[model] = tagmap; @@ -1158,7 +1217,7 @@ FreeImage_SetMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, const char *key, BOOL DLL_CALLCONV FreeImage_GetMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, const char *key, FITAG **tag) { - if (!dib || !key || !tag) + if(!dib || !key || !tag) return FALSE; TAGMAP *tagmap = NULL; @@ -1166,13 +1225,13 @@ FreeImage_GetMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, const char *key, // get the metadata model METADATAMAP *metadata = ((FREEIMAGEHEADER *)dib->data)->metadata; - if (!(*metadata).empty()) { + if(!(*metadata).empty()) { METADATAMAP::iterator model_iterator = metadata->find(model); - if (model_iterator != metadata->end()) { + if (model_iterator != metadata->end() ) { // this model exists : try to get the requested tag tagmap = model_iterator->second; TAGMAP::iterator tag_iterator = tagmap->find(key); - if (tag_iterator != tagmap->end()) { + if (tag_iterator != tagmap->end() ) { // get the requested tag *tag = tag_iterator->second; } @@ -1186,17 +1245,17 @@ FreeImage_GetMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, const char *key, unsigned DLL_CALLCONV FreeImage_GetMetadataCount(FREE_IMAGE_MDMODEL model, FIBITMAP *dib) { - if (!dib) + if(!dib) return FALSE; TAGMAP *tagmap = NULL; // get the metadata model METADATAMAP *metadata = ((FREEIMAGEHEADER *)dib->data)->metadata; - if ( (*metadata).find(model) != (*metadata).end()) { + if( (*metadata).find(model) != (*metadata).end() ) { tagmap = (*metadata)[model]; } - if (!tagmap) { + if(!tagmap) { // this model, doesn't exist: return return 0; } diff --git a/plugins/AdvaImg/src/FreeImage/ColorLookup.cpp b/plugins/AdvaImg/src/FreeImage/ColorLookup.cpp index 3e81abdb95..5f677eee5c 100644 --- a/plugins/AdvaImg/src/FreeImage/ColorLookup.cpp +++ b/plugins/AdvaImg/src/FreeImage/ColorLookup.cpp @@ -568,7 +568,7 @@ FreeImage_LookupX11Color(const char *szColor, BYTE *nRed, BYTE *nGreen, BYTE *nB if ( (szColor[0] == 'g' || szColor[0] == 'G') && (szColor[1] == 'r' || szColor[1] == 'R') && (szColor[2] == 'e' || szColor[2] == 'E' || szColor[2] == 'a' || szColor[2] == 'A' ) && - (szColor[3] == 'y' || szColor[3] == 'Y' )) { + (szColor[3] == 'y' || szColor[3] == 'Y' ) ) { // grey, or gray, num 1...100 i = strtol(szColor+4, NULL, 10); @@ -762,7 +762,7 @@ FreeImage_LookupSVGColor(const char *szColor, BYTE *nRed, BYTE *nGreen, BYTE *nB if ( (szColor[0] == 'g' || szColor[0] == 'G') && (szColor[1] == 'r' || szColor[1] == 'R') && (szColor[2] == 'e' || szColor[2] == 'E' || szColor[2] == 'a' || szColor[2] == 'A' ) && - (szColor[3] == 'y' || szColor[3] == 'Y' )) { + (szColor[3] == 'y' || szColor[3] == 'Y' ) ) { // grey, or gray, num 1...100 i = strtol(szColor+4, NULL, 10); diff --git a/plugins/AdvaImg/src/FreeImage/Conversion.cpp b/plugins/AdvaImg/src/FreeImage/Conversion.cpp index 3c14bab9dd..04cec65ab5 100644 --- a/plugins/AdvaImg/src/FreeImage/Conversion.cpp +++ b/plugins/AdvaImg/src/FreeImage/Conversion.cpp @@ -145,7 +145,7 @@ _convertCMYKtoRGBA(unsigned width, unsigned height, BYTE* line_start, unsigned p BOOL ConvertCMYKtoRGBA(FIBITMAP* dib) { - if (!FreeImage_HasPixels(dib)) { + if(!FreeImage_HasPixels(dib)) { return FALSE; } @@ -294,7 +294,7 @@ _convertLABtoRGB(unsigned width, unsigned height, BYTE* line_start, unsigned pit BOOL ConvertLABtoRGB(FIBITMAP* dib) { - if (!FreeImage_HasPixels(dib)) { + if(!FreeImage_HasPixels(dib)) { return FALSE; } @@ -330,7 +330,7 @@ ConvertLABtoRGB(FIBITMAP* dib) { FIBITMAP* RemoveAlphaChannel(FIBITMAP* src) { - if (!FreeImage_HasPixels(src)) { + if(!FreeImage_HasPixels(src)) { return NULL; } @@ -367,10 +367,10 @@ FreeImage_ColorQuantize(FIBITMAP *dib, FREE_IMAGE_QUANTIZE quantize) { FIBITMAP * DLL_CALLCONV FreeImage_ColorQuantizeEx(FIBITMAP *dib, FREE_IMAGE_QUANTIZE quantize, int PaletteSize, int ReserveSize, RGBQUAD *ReservePalette) { - if ( PaletteSize < 2 ) PaletteSize = 2; - if ( PaletteSize > 256 ) PaletteSize = 256; - if ( ReserveSize < 0 ) ReserveSize = 0; - if ( ReserveSize > PaletteSize ) ReserveSize = PaletteSize; + if( PaletteSize < 2 ) PaletteSize = 2; + if( PaletteSize > 256 ) PaletteSize = 256; + if( ReserveSize < 0 ) ReserveSize = 0; + if( ReserveSize > PaletteSize ) ReserveSize = PaletteSize; if (FreeImage_HasPixels(dib)) { if (FreeImage_GetBPP(dib) == 24) { switch(quantize) { diff --git a/plugins/AdvaImg/src/FreeImage/Conversion16_555.cpp b/plugins/AdvaImg/src/FreeImage/Conversion16_555.cpp index c0c4785704..abaf2f1824 100644 --- a/plugins/AdvaImg/src/FreeImage/Conversion16_555.cpp +++ b/plugins/AdvaImg/src/FreeImage/Conversion16_555.cpp @@ -115,7 +115,7 @@ FreeImage_ConvertLine32To16_555(BYTE *target, BYTE *source, int width_in_pixels) FIBITMAP * DLL_CALLCONV FreeImage_ConvertTo16Bits555(FIBITMAP *dib) { - if (!FreeImage_HasPixels(dib) || (FreeImage_GetImageType(dib) != FIT_BITMAP)) return NULL; + if(!FreeImage_HasPixels(dib) || (FreeImage_GetImageType(dib) != FIT_BITMAP)) return NULL; const int width = FreeImage_GetWidth(dib); const int height = FreeImage_GetHeight(dib); diff --git a/plugins/AdvaImg/src/FreeImage/Conversion16_565.cpp b/plugins/AdvaImg/src/FreeImage/Conversion16_565.cpp index 28e8255b4e..eb3dd9de3f 100644 --- a/plugins/AdvaImg/src/FreeImage/Conversion16_565.cpp +++ b/plugins/AdvaImg/src/FreeImage/Conversion16_565.cpp @@ -111,7 +111,7 @@ FreeImage_ConvertLine32To16_565(BYTE *target, BYTE *source, int width_in_pixels) FIBITMAP * DLL_CALLCONV FreeImage_ConvertTo16Bits565(FIBITMAP *dib) { - if (!FreeImage_HasPixels(dib) || (FreeImage_GetImageType(dib) != FIT_BITMAP)) return NULL; + if(!FreeImage_HasPixels(dib) || (FreeImage_GetImageType(dib) != FIT_BITMAP)) return NULL; const int width = FreeImage_GetWidth(dib); const int height = FreeImage_GetHeight(dib); diff --git a/plugins/AdvaImg/src/FreeImage/Conversion24.cpp b/plugins/AdvaImg/src/FreeImage/Conversion24.cpp index f04b946ef0..1d5bba7f02 100644 --- a/plugins/AdvaImg/src/FreeImage/Conversion24.cpp +++ b/plugins/AdvaImg/src/FreeImage/Conversion24.cpp @@ -121,20 +121,24 @@ FreeImage_ConvertLine32To24(BYTE *target, BYTE *source, int width_in_pixels) { FIBITMAP * DLL_CALLCONV FreeImage_ConvertTo24Bits(FIBITMAP *dib) { - if (!FreeImage_HasPixels(dib)) return NULL; + if(!FreeImage_HasPixels(dib)) return NULL; const unsigned bpp = FreeImage_GetBPP(dib); - const FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(dib); - if ((image_type != FIT_BITMAP) && (image_type != FIT_RGB16)) { + + if((image_type != FIT_BITMAP) && (image_type != FIT_RGB16) && (image_type != FIT_RGBA16)) { return NULL; } + + const int width = FreeImage_GetWidth(dib); + const int height = FreeImage_GetHeight(dib); - if (bpp != 24) { - const int width = FreeImage_GetWidth(dib); - const int height = FreeImage_GetHeight(dib); - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); + if(image_type == FIT_BITMAP) { + if(bpp == 24) { + return FreeImage_Clone(dib); + } + FIBITMAP *new_dib = FreeImage_Allocate(width, height, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); if(new_dib == NULL) { return NULL; } @@ -187,28 +191,62 @@ FreeImage_ConvertTo24Bits(FIBITMAP *dib) { } return new_dib; } + } + + } else if(image_type == FIT_RGB16) { + FIBITMAP *new_dib = FreeImage_Allocate(width, height, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); + if(new_dib == NULL) { + return NULL; + } - case 48: - { - const unsigned src_pitch = FreeImage_GetPitch(dib); - const unsigned dst_pitch = FreeImage_GetPitch(new_dib); - const BYTE *src_bits = FreeImage_GetBits(dib); - BYTE *dst_bits = FreeImage_GetBits(new_dib); - for (int rows = 0; rows < height; rows++) { - const FIRGB16 *src_pixel = (FIRGB16*)src_bits; - RGBTRIPLE *dst_pixel = (RGBTRIPLE*)dst_bits; - for(int cols = 0; cols < width; cols++) { - dst_pixel[cols].rgbtRed = (BYTE)(src_pixel[cols].red >> 8); - dst_pixel[cols].rgbtGreen = (BYTE)(src_pixel[cols].green >> 8); - dst_pixel[cols].rgbtBlue = (BYTE)(src_pixel[cols].blue >> 8); - } - src_bits += src_pitch; - dst_bits += dst_pitch; - } - return new_dib; + // copy metadata from src to dst + FreeImage_CloneMetadata(new_dib, dib); + + const unsigned src_pitch = FreeImage_GetPitch(dib); + const unsigned dst_pitch = FreeImage_GetPitch(new_dib); + const BYTE *src_bits = FreeImage_GetBits(dib); + BYTE *dst_bits = FreeImage_GetBits(new_dib); + for (int rows = 0; rows < height; rows++) { + const FIRGB16 *src_pixel = (FIRGB16*)src_bits; + RGBTRIPLE *dst_pixel = (RGBTRIPLE*)dst_bits; + for(int cols = 0; cols < width; cols++) { + dst_pixel[cols].rgbtRed = (BYTE)(src_pixel[cols].red >> 8); + dst_pixel[cols].rgbtGreen = (BYTE)(src_pixel[cols].green >> 8); + dst_pixel[cols].rgbtBlue = (BYTE)(src_pixel[cols].blue >> 8); } + src_bits += src_pitch; + dst_bits += dst_pitch; } + + return new_dib; + + } else if(image_type == FIT_RGBA16) { + FIBITMAP *new_dib = FreeImage_Allocate(width, height, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); + if(new_dib == NULL) { + return NULL; + } + + // copy metadata from src to dst + FreeImage_CloneMetadata(new_dib, dib); + + const unsigned src_pitch = FreeImage_GetPitch(dib); + const unsigned dst_pitch = FreeImage_GetPitch(new_dib); + const BYTE *src_bits = FreeImage_GetBits(dib); + BYTE *dst_bits = FreeImage_GetBits(new_dib); + for (int rows = 0; rows < height; rows++) { + const FIRGBA16 *src_pixel = (FIRGBA16*)src_bits; + RGBTRIPLE *dst_pixel = (RGBTRIPLE*)dst_bits; + for(int cols = 0; cols < width; cols++) { + dst_pixel[cols].rgbtRed = (BYTE)(src_pixel[cols].red >> 8); + dst_pixel[cols].rgbtGreen = (BYTE)(src_pixel[cols].green >> 8); + dst_pixel[cols].rgbtBlue = (BYTE)(src_pixel[cols].blue >> 8); + } + src_bits += src_pitch; + dst_bits += dst_pitch; + } + + return new_dib; } - return FreeImage_Clone(dib); + return NULL; } diff --git a/plugins/AdvaImg/src/FreeImage/Conversion32.cpp b/plugins/AdvaImg/src/FreeImage/Conversion32.cpp index fad74671cd..b8bd518471 100644 --- a/plugins/AdvaImg/src/FreeImage/Conversion32.cpp +++ b/plugins/AdvaImg/src/FreeImage/Conversion32.cpp @@ -186,12 +186,12 @@ FreeImage_ConvertLine8To32MapTransparency(BYTE *target, BYTE *source, int width_ FIBITMAP * DLL_CALLCONV FreeImage_ConvertTo32Bits(FIBITMAP *dib) { - if (!FreeImage_HasPixels(dib)) return NULL; + if(!FreeImage_HasPixels(dib)) return NULL; const int bpp = FreeImage_GetBPP(dib); const FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(dib); - if ((image_type != FIT_BITMAP) && (image_type != FIT_RGB16) && (image_type != FIT_RGBA16)) { + if((image_type != FIT_BITMAP) && (image_type != FIT_RGB16) && (image_type != FIT_RGBA16)) { return NULL; } diff --git a/plugins/AdvaImg/src/FreeImage/Conversion4.cpp b/plugins/AdvaImg/src/FreeImage/Conversion4.cpp index 7c09ac824a..13048b6d3f 100644 --- a/plugins/AdvaImg/src/FreeImage/Conversion4.cpp +++ b/plugins/AdvaImg/src/FreeImage/Conversion4.cpp @@ -29,7 +29,7 @@ void DLL_CALLCONV FreeImage_ConvertLine1To4(BYTE *target, BYTE *source, int width_in_pixels) { BOOL hinibble = TRUE; - for (int cols = 0; cols < width_in_pixels; cols++) { + for (int cols = 0; cols < width_in_pixels; cols++){ if (hinibble == TRUE){ target[cols >> 1] = ((source[cols >> 3] & (0x80 >> (cols & 0x07))) != 0 ? 15 : 0) << 4; } @@ -46,7 +46,7 @@ FreeImage_ConvertLine8To4(BYTE *target, BYTE *source, int width_in_pixels, RGBQU BOOL hinibble = TRUE; BYTE index; - for (int cols = 0; cols < width_in_pixels; cols++) { + for (int cols = 0; cols < width_in_pixels; cols++){ index = GREY(palette[source[cols]].rgbRed, palette[source[cols]].rgbGreen, palette[source[cols]].rgbBlue); if (hinibble) { target[cols >> 1] = (index & 0xF0); @@ -140,7 +140,7 @@ FreeImage_ConvertLine32To4(BYTE *target, BYTE *source, int width_in_pixels) { FIBITMAP * DLL_CALLCONV FreeImage_ConvertTo4Bits(FIBITMAP *dib) { - if (!FreeImage_HasPixels(dib)) return NULL; + if(!FreeImage_HasPixels(dib)) return NULL; const int bpp = FreeImage_GetBPP(dib); diff --git a/plugins/AdvaImg/src/FreeImage/Conversion8.cpp b/plugins/AdvaImg/src/FreeImage/Conversion8.cpp index 867cf756ed..1c331a6552 100644 --- a/plugins/AdvaImg/src/FreeImage/Conversion8.cpp +++ b/plugins/AdvaImg/src/FreeImage/Conversion8.cpp @@ -6,6 +6,7 @@ // - Hervé Drolon (drolon@infonie.fr) // - Jani Kajala (janik@remedy.fi) // - Karl-Heinz Bussian (khbussian@moss.de) +// - Carsten Klein (cklein05@users.sourceforge.net) // // This file is part of FreeImage 3 // @@ -31,36 +32,32 @@ void DLL_CALLCONV FreeImage_ConvertLine1To8(BYTE *target, BYTE *source, int width_in_pixels) { - for (int cols = 0; cols < width_in_pixels; cols++) + for (unsigned cols = 0; cols < (unsigned)width_in_pixels; cols++) target[cols] = (source[cols >> 3] & (0x80 >> (cols & 0x07))) != 0 ? 255 : 0; } void DLL_CALLCONV FreeImage_ConvertLine4To8(BYTE *target, BYTE *source, int width_in_pixels) { - int count_new = 0; - int count_org = 0; + unsigned count_new = 0; + unsigned count_org = 0; BOOL hinibble = TRUE; - while (count_new < width_in_pixels) { + while (count_new < (unsigned)width_in_pixels) { if (hinibble) { - target[count_new] = (source[count_org] & 0xF0) >> 4; + target[count_new] = (source[count_org] >> 4); } else { target[count_new] = (source[count_org] & 0x0F); - count_org++; } - hinibble = !hinibble; - count_new++; } } void DLL_CALLCONV FreeImage_ConvertLine16To8_555(BYTE *target, BYTE *source, int width_in_pixels) { - WORD *bits = (WORD *)source; - - for (int cols = 0; cols < width_in_pixels; cols++) { + const WORD *const bits = (WORD *)source; + for (unsigned cols = 0; cols < (unsigned)width_in_pixels; cols++) { target[cols] = GREY((((bits[cols] & FI16_555_RED_MASK) >> FI16_555_RED_SHIFT) * 0xFF) / 0x1F, (((bits[cols] & FI16_555_GREEN_MASK) >> FI16_555_GREEN_SHIFT) * 0xFF) / 0x1F, (((bits[cols] & FI16_555_BLUE_MASK) >> FI16_555_BLUE_SHIFT) * 0xFF) / 0x1F); @@ -69,28 +66,26 @@ FreeImage_ConvertLine16To8_555(BYTE *target, BYTE *source, int width_in_pixels) void DLL_CALLCONV FreeImage_ConvertLine16To8_565(BYTE *target, BYTE *source, int width_in_pixels) { - WORD *bits = (WORD *)source; - - for (int cols = 0; cols < width_in_pixels; cols++) + const WORD *const bits = (WORD *)source; + for (unsigned cols = 0; cols < (unsigned)width_in_pixels; cols++) { target[cols] = GREY((((bits[cols] & FI16_565_RED_MASK) >> FI16_565_RED_SHIFT) * 0xFF) / 0x1F, (((bits[cols] & FI16_565_GREEN_MASK) >> FI16_565_GREEN_SHIFT) * 0xFF) / 0x3F, - (((bits[cols] & FI16_565_BLUE_MASK) >> FI16_565_BLUE_SHIFT) * 0xFF) / 0x1F); + (((bits[cols] & FI16_565_BLUE_MASK) >> FI16_565_BLUE_SHIFT) * 0xFF) / 0x1F); + } } void DLL_CALLCONV FreeImage_ConvertLine24To8(BYTE *target, BYTE *source, int width_in_pixels) { - for (int cols = 0; cols < width_in_pixels; cols++) { + for (unsigned cols = 0; cols < (unsigned)width_in_pixels; cols++) { target[cols] = GREY(source[FI_RGBA_RED], source[FI_RGBA_GREEN], source[FI_RGBA_BLUE]); - source += 3; } } void DLL_CALLCONV FreeImage_ConvertLine32To8(BYTE *target, BYTE *source, int width_in_pixels) { - for (int cols = 0; cols < width_in_pixels; cols++) { + for (unsigned cols = 0; cols < (unsigned)width_in_pixels; cols++) { target[cols] = GREY(source[FI_RGBA_RED], source[FI_RGBA_GREEN], source[FI_RGBA_BLUE]); - source += 4; } } @@ -101,64 +96,54 @@ FreeImage_ConvertLine32To8(BYTE *target, BYTE *source, int width_in_pixels) { FIBITMAP * DLL_CALLCONV FreeImage_ConvertTo8Bits(FIBITMAP *dib) { - if (!FreeImage_HasPixels(dib)) return NULL; - - const int bpp = FreeImage_GetBPP(dib); + if (!FreeImage_HasPixels(dib)) { + return NULL; + } const FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(dib); - if ((image_type != FIT_BITMAP) && (image_type != FIT_UINT16)) { + if (image_type != FIT_BITMAP && image_type != FIT_UINT16) { return NULL; } - if(bpp != 8) { - const int width = FreeImage_GetWidth(dib); - const int height = FreeImage_GetHeight(dib); - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 8); + const unsigned bpp = FreeImage_GetBPP(dib); + + if (bpp != 8) { + + const unsigned width = FreeImage_GetWidth(dib); + const unsigned height = FreeImage_GetHeight(dib); - if(new_dib == NULL) { + // Allocate a destination image + FIBITMAP *new_dib = FreeImage_Allocate(width, height, 8); + if (new_dib == NULL) { return NULL; } - // copy metadata from src to dst + // Copy metadata from src to dst FreeImage_CloneMetadata(new_dib, dib); - // Build a greyscale palette (*always* needed for image processing) - + // Palette of destination image has already been initialized RGBQUAD *new_pal = FreeImage_GetPalette(new_dib); - for(int i = 0; i < 256; i++) { - new_pal[i].rgbRed = (BYTE)i; - new_pal[i].rgbGreen = (BYTE)i; - new_pal[i].rgbBlue = (BYTE)i; - } + const FREE_IMAGE_COLOR_TYPE color_type = FreeImage_GetColorType(dib); - if(image_type == FIT_BITMAP) { + if (image_type == FIT_BITMAP) { switch(bpp) { case 1: { - if(FreeImage_GetColorType(dib) == FIC_PALETTE) { - + if (color_type == FIC_PALETTE) { // Copy the palette - RGBQUAD *old_pal = FreeImage_GetPalette(dib); - memcpy(&new_pal[0], &old_pal[0], sizeof(RGBQUAD)); - memcpy(&new_pal[255], &old_pal[1], sizeof(RGBQUAD)); + new_pal[0] = old_pal[0]; + new_pal[255] = old_pal[1]; + } else if (color_type == FIC_MINISWHITE) { + // Create a reverse grayscale palette + CREATE_GREYSCALE_PALETTE_REVERSE(new_pal, 256); } - else if(FreeImage_GetColorType(dib) == FIC_MINISWHITE) { - - // Reverse the grayscale palette - - for(int i = 0; i < 256; i++) { - new_pal[i].rgbRed = new_pal[i].rgbGreen = new_pal[i].rgbBlue = (BYTE)(255 - i); - } - } - // Expand and copy the bitmap data - - for (int rows = 0; rows < height; rows++) { + for (unsigned rows = 0; rows < height; rows++) { FreeImage_ConvertLine1To8(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width); } return new_dib; @@ -166,22 +151,13 @@ FreeImage_ConvertTo8Bits(FIBITMAP *dib) { case 4 : { - if(FreeImage_GetColorType(dib) == FIC_PALETTE) { - + if (color_type == FIC_PALETTE) { // Copy the palette - - RGBQUAD *old_pal = FreeImage_GetPalette(dib); - - for (int i = 0; i < 16; i++) { - new_pal[i].rgbRed = old_pal[i].rgbRed; - new_pal[i].rgbGreen = old_pal[i].rgbGreen; - new_pal[i].rgbBlue = old_pal[i].rgbBlue; - } + memcpy(new_pal, FreeImage_GetPalette(dib), 16 * sizeof(RGBQUAD)); } // Expand and copy the bitmap data - - for (int rows = 0; rows < height; rows++) { + for (unsigned rows = 0; rows < height; rows++) { FreeImage_ConvertLine4To8(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width); } return new_dib; @@ -190,23 +166,22 @@ FreeImage_ConvertTo8Bits(FIBITMAP *dib) { case 16 : { // Expand and copy the bitmap data - - for (int rows = 0; rows < height; rows++) { - if ((FreeImage_GetRedMask(dib) == FI16_565_RED_MASK) && (FreeImage_GetGreenMask(dib) == FI16_565_GREEN_MASK) && (FreeImage_GetBlueMask(dib) == FI16_565_BLUE_MASK)) { + if (IS_FORMAT_RGB565(dib)) { + for (unsigned rows = 0; rows < height; rows++) { FreeImage_ConvertLine16To8_565(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width); - } else { + } + } else { + for (unsigned rows = 0; rows < height; rows++) { FreeImage_ConvertLine16To8_555(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width); } } - return new_dib; } case 24 : { // Expand and copy the bitmap data - - for (int rows = 0; rows < height; rows++) { + for (unsigned rows = 0; rows < height; rows++) { FreeImage_ConvertLine24To8(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width); } return new_dib; @@ -215,32 +190,30 @@ FreeImage_ConvertTo8Bits(FIBITMAP *dib) { case 32 : { // Expand and copy the bitmap data - - for (int rows = 0; rows < height; rows++) { + for (unsigned rows = 0; rows < height; rows++) { FreeImage_ConvertLine32To8(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width); } return new_dib; } } - } else if(image_type == FIT_UINT16) { + } else if (image_type == FIT_UINT16) { const unsigned src_pitch = FreeImage_GetPitch(dib); const unsigned dst_pitch = FreeImage_GetPitch(new_dib); const BYTE *src_bits = FreeImage_GetBits(dib); BYTE *dst_bits = FreeImage_GetBits(new_dib); - for (int rows = 0; rows < height; rows++) { - const WORD *src_pixel = (WORD*)src_bits; + + for (unsigned rows = 0; rows < height; rows++) { + const WORD *const src_pixel = (WORD*)src_bits; BYTE *dst_pixel = (BYTE*)dst_bits; - for(int cols = 0; cols < width; cols++) { + for(unsigned cols = 0; cols < width; cols++) { dst_pixel[cols] = (BYTE)(src_pixel[cols] >> 8); } src_bits += src_pitch; dst_bits += dst_pitch; } - return new_dib; - } } // bpp != 8 @@ -250,76 +223,81 @@ FreeImage_ConvertTo8Bits(FIBITMAP *dib) { FIBITMAP * DLL_CALLCONV FreeImage_ConvertToGreyscale(FIBITMAP *dib) { - if (!FreeImage_HasPixels(dib)) return NULL; + if (!FreeImage_HasPixels(dib)) { + return NULL; + } const FREE_IMAGE_COLOR_TYPE color_type = FreeImage_GetColorType(dib); - const int bpp = FreeImage_GetBPP(dib); - if ((color_type == FIC_PALETTE) || (color_type == FIC_MINISWHITE)) { - const int width = FreeImage_GetWidth(dib); - const int height = FreeImage_GetHeight(dib); - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 8); + if (color_type == FIC_PALETTE || color_type == FIC_MINISWHITE) { + + const unsigned bpp = FreeImage_GetBPP(dib); + const unsigned width = FreeImage_GetWidth(dib); + const unsigned height = FreeImage_GetHeight(dib); - if(new_dib == NULL) { + FIBITMAP *new_dib = FreeImage_Allocate(width, height, 8); + if (new_dib == NULL) { return NULL; } - // copy metadata from src to dst + // Copy metadata from src to dst FreeImage_CloneMetadata(new_dib, dib); - // Build a greyscale palette - - RGBQUAD *new_pal = FreeImage_GetPalette(new_dib); - - for(int i = 0; i < 256; i++) { - new_pal[i].rgbRed = (BYTE)i; - new_pal[i].rgbGreen = (BYTE)i; - new_pal[i].rgbBlue = (BYTE)i; + // Create a greyscale palette + BYTE grey_pal[256]; + const RGBQUAD *pal = FreeImage_GetPalette(dib); + const unsigned size = CalculateUsedPaletteEntries(bpp); + for (unsigned i = 0; i < size; i++) { + grey_pal[i] = GREY(pal->rgbRed, pal->rgbGreen, pal->rgbBlue); + pal++; } - // allocate a 24-bit buffer - - BYTE *buffer = (BYTE*)malloc( CalculatePitch(CalculateLine(width, 24)) * sizeof(BYTE)); - if(NULL == buffer) { - FreeImage_Unload(new_dib); - return NULL; - } + const BYTE *src_bits = FreeImage_GetBits(dib); + BYTE *dst_bits = FreeImage_GetBits(new_dib); - // Convert the palette to 24-bit, then to 8-bit + const unsigned src_pitch = FreeImage_GetPitch(dib); + const unsigned dst_pitch = FreeImage_GetPitch(new_dib); switch(bpp) { case 1: { - for (int rows = 0; rows < height; rows++) { - FreeImage_ConvertLine1To24(buffer, FreeImage_GetScanLine(dib, rows), width, FreeImage_GetPalette(dib)); - FreeImage_ConvertLine24To8(FreeImage_GetScanLine(new_dib, rows), buffer, width); + for (unsigned y = 0; y < height; y++) { + for (unsigned x = 0; x < width; x++) { + const unsigned pixel = (src_bits[x >> 3] & (0x80 >> (x & 0x07))) != 0; + dst_bits[x] = grey_pal[pixel]; + } + src_bits += src_pitch; + dst_bits += dst_pitch; } } break; case 4: { - for (int rows = 0; rows < height; rows++) { - FreeImage_ConvertLine4To24(buffer, FreeImage_GetScanLine(dib, rows), width, FreeImage_GetPalette(dib)); - FreeImage_ConvertLine24To8(FreeImage_GetScanLine(new_dib, rows), buffer, width); + for (unsigned y = 0; y < height; y++) { + for (unsigned x = 0; x < width; x++) { + const unsigned pixel = x & 0x01 ? src_bits[x >> 1] & 0x0F : src_bits[x >> 1] >> 4; + dst_bits[x] = grey_pal[pixel]; + } + src_bits += src_pitch; + dst_bits += dst_pitch; } } break; case 8: { - for (int rows = 0; rows < height; rows++) { - FreeImage_ConvertLine8To24(buffer, FreeImage_GetScanLine(dib, rows), width, FreeImage_GetPalette(dib)); - FreeImage_ConvertLine24To8(FreeImage_GetScanLine(new_dib, rows), buffer, width); + for (unsigned y = 0; y < height; y++) { + for (unsigned x = 0; x < width; x++) { + dst_bits[x] = grey_pal[src_bits[x]]; + } + src_bits += src_pitch; + dst_bits += dst_pitch; } } break; - } - free(buffer); - return new_dib; - } // Convert the bitmap to 8-bit greyscale diff --git a/plugins/AdvaImg/src/FreeImage/ConversionFloat.cpp b/plugins/AdvaImg/src/FreeImage/ConversionFloat.cpp index 181ff396e1..e72d14cb83 100644 --- a/plugins/AdvaImg/src/FreeImage/ConversionFloat.cpp +++ b/plugins/AdvaImg/src/FreeImage/ConversionFloat.cpp @@ -31,7 +31,7 @@ FreeImage_ConvertToFloat(FIBITMAP *dib) { FIBITMAP *src = NULL; FIBITMAP *dst = NULL; - if (!FreeImage_HasPixels(dib)) return NULL; + if(!FreeImage_HasPixels(dib)) return NULL; FREE_IMAGE_TYPE src_type = FreeImage_GetImageType(dib); @@ -40,11 +40,11 @@ FreeImage_ConvertToFloat(FIBITMAP *dib) { case FIT_BITMAP: { // allow conversion from 8-bit - if ((FreeImage_GetBPP(dib) == 8) && (FreeImage_GetColorType(dib) == FIC_MINISBLACK)) { + if((FreeImage_GetBPP(dib) == 8) && (FreeImage_GetColorType(dib) == FIC_MINISBLACK)) { src = dib; } else { src = FreeImage_ConvertToGreyscale(dib); - if (!src) return NULL; + if(!src) return NULL; } break; } @@ -68,7 +68,7 @@ FreeImage_ConvertToFloat(FIBITMAP *dib) { const unsigned height = FreeImage_GetHeight(src); dst = FreeImage_AllocateT(FIT_FLOAT, width, height); - if (!dst) { + if(!dst) { if(src != dib) { FreeImage_Unload(src); } diff --git a/plugins/AdvaImg/src/FreeImage/ConversionRGB16.cpp b/plugins/AdvaImg/src/FreeImage/ConversionRGB16.cpp index 6b9d17fbed..bd38504a1e 100644 --- a/plugins/AdvaImg/src/FreeImage/ConversionRGB16.cpp +++ b/plugins/AdvaImg/src/FreeImage/ConversionRGB16.cpp @@ -31,7 +31,7 @@ FreeImage_ConvertToRGB16(FIBITMAP *dib) { FIBITMAP *src = NULL; FIBITMAP *dst = NULL; - if (!FreeImage_HasPixels(dib)) return NULL; + if(!FreeImage_HasPixels(dib)) return NULL; const FREE_IMAGE_TYPE src_type = FreeImage_GetImageType(dib); @@ -40,11 +40,11 @@ FreeImage_ConvertToRGB16(FIBITMAP *dib) { case FIT_BITMAP: { // convert to 24-bit if needed - if ((FreeImage_GetBPP(dib) == 24) || (FreeImage_GetBPP(dib) == 32)) { + if((FreeImage_GetBPP(dib) == 24) || (FreeImage_GetBPP(dib) == 32)) { src = dib; } else { src = FreeImage_ConvertTo24Bits(dib); - if (!src) return NULL; + if(!src) return NULL; } break; } @@ -70,7 +70,7 @@ FreeImage_ConvertToRGB16(FIBITMAP *dib) { const unsigned height = FreeImage_GetHeight(src); dst = FreeImage_AllocateT(FIT_RGB16, width, height); - if (!dst) { + if(!dst) { if(src != dib) { FreeImage_Unload(src); } diff --git a/plugins/AdvaImg/src/FreeImage/ConversionRGBF.cpp b/plugins/AdvaImg/src/FreeImage/ConversionRGBF.cpp index 6b8739532f..b5161d566d 100644 --- a/plugins/AdvaImg/src/FreeImage/ConversionRGBF.cpp +++ b/plugins/AdvaImg/src/FreeImage/ConversionRGBF.cpp @@ -31,7 +31,7 @@ FreeImage_ConvertToRGBF(FIBITMAP *dib) { FIBITMAP *src = NULL; FIBITMAP *dst = NULL; - if (!FreeImage_HasPixels(dib)) return NULL; + if(!FreeImage_HasPixels(dib)) return NULL; const FREE_IMAGE_TYPE src_type = FreeImage_GetImageType(dib); @@ -41,9 +41,9 @@ FreeImage_ConvertToRGBF(FIBITMAP *dib) { { // allow conversion from 24- and 32-bit const FREE_IMAGE_COLOR_TYPE color_type = FreeImage_GetColorType(dib); - if ((color_type != FIC_RGB) && (color_type != FIC_RGBALPHA)) { + if((color_type != FIC_RGB) && (color_type != FIC_RGBALPHA)) { src = FreeImage_ConvertTo24Bits(dib); - if (!src) return NULL; + if(!src) return NULL; } else { src = dib; } @@ -83,7 +83,7 @@ FreeImage_ConvertToRGBF(FIBITMAP *dib) { const unsigned height = FreeImage_GetHeight(src); dst = FreeImage_AllocateT(FIT_RGBF, width, height); - if (!dst) { + if(!dst) { if(src != dib) { FreeImage_Unload(src); } diff --git a/plugins/AdvaImg/src/FreeImage/ConversionType.cpp b/plugins/AdvaImg/src/FreeImage/ConversionType.cpp index 23528b60fe..b537f72814 100644 --- a/plugins/AdvaImg/src/FreeImage/ConversionType.cpp +++ b/plugins/AdvaImg/src/FreeImage/ConversionType.cpp @@ -47,7 +47,7 @@ CONVERT_TYPE::convert(FIBITMAP *src, FREE_IMAGE_TYPE dst_type) { dst = FreeImage_AllocateT(dst_type, width, height, bpp, FreeImage_GetRedMask(src), FreeImage_GetGreenMask(src), FreeImage_GetBlueMask(src)); - if (!dst) return NULL; + if(!dst) return NULL; // convert from src_type to dst_type @@ -86,7 +86,7 @@ CONVERT_TO_BYTE::convert(FIBITMAP *src, BOOL scale_linear) { // allocate a 8-bit dib dst = FreeImage_AllocateT(FIT_BITMAP, width, height, 8, 0, 0, 0); - if (!dst) return NULL; + if(!dst) return NULL; // build a greyscale palette RGBQUAD *pal = FreeImage_GetPalette(dst); @@ -160,7 +160,7 @@ CONVERT_TO_COMPLEX::convert(FIBITMAP *src) { // allocate dst image dst = FreeImage_AllocateT(FIT_COMPLEX, width, height); - if (!dst) return NULL; + if(!dst) return NULL; // convert from src_type to FIT_COMPLEX @@ -236,7 +236,7 @@ FIBITMAP* DLL_CALLCONV FreeImage_ConvertToStandardType(FIBITMAP *src, BOOL scale_linear) { FIBITMAP *dst = NULL; - if (!src) return NULL; + if(!src) return NULL; // convert from src_type to FIT_BITMAP @@ -306,7 +306,7 @@ FIBITMAP* DLL_CALLCONV FreeImage_ConvertToType(FIBITMAP *src, FREE_IMAGE_TYPE dst_type, BOOL scale_linear) { FIBITMAP *dst = NULL; - if (!FreeImage_HasPixels(src)) return NULL; + if(!FreeImage_HasPixels(src)) return NULL; // convert from src_type to dst_type diff --git a/plugins/AdvaImg/src/FreeImage/ConversionUINT16.cpp b/plugins/AdvaImg/src/FreeImage/ConversionUINT16.cpp index 3744cfe3b4..ed4691f3a2 100644 --- a/plugins/AdvaImg/src/FreeImage/ConversionUINT16.cpp +++ b/plugins/AdvaImg/src/FreeImage/ConversionUINT16.cpp @@ -31,7 +31,7 @@ FreeImage_ConvertToUINT16(FIBITMAP *dib) { FIBITMAP *src = NULL; FIBITMAP *dst = NULL; - if (!FreeImage_HasPixels(dib)) return NULL; + if(!FreeImage_HasPixels(dib)) return NULL; const FREE_IMAGE_TYPE src_type = FreeImage_GetImageType(dib); @@ -40,11 +40,11 @@ FreeImage_ConvertToUINT16(FIBITMAP *dib) { case FIT_BITMAP: { // convert to greyscale if needed - if ((FreeImage_GetBPP(dib) == 8) && (FreeImage_GetColorType(dib) == FIC_MINISBLACK)) { + if((FreeImage_GetBPP(dib) == 8) && (FreeImage_GetColorType(dib) == FIC_MINISBLACK)) { src = dib; } else { src = FreeImage_ConvertToGreyscale(dib); - if (!src) return NULL; + if(!src) return NULL; } break; } @@ -70,7 +70,7 @@ FreeImage_ConvertToUINT16(FIBITMAP *dib) { const unsigned height = FreeImage_GetHeight(src); dst = FreeImage_AllocateT(FIT_UINT16, width, height); - if (!dst) { + if(!dst) { if(src != dib) { FreeImage_Unload(src); } diff --git a/plugins/AdvaImg/src/FreeImage/FreeImage.cpp b/plugins/AdvaImg/src/FreeImage/FreeImage.cpp index b36f10aca1..2de6077eed 100644 --- a/plugins/AdvaImg/src/FreeImage/FreeImage.cpp +++ b/plugins/AdvaImg/src/FreeImage/FreeImage.cpp @@ -132,7 +132,7 @@ FreeImage_OutputMessageProc(int fif, const char *fmt, ...) { // check the length of the format string - int str_length = (int)( (strlen(fmt) > MSG_SIZE) ? MSG_SIZE : strlen(fmt)); + int str_length = (int)( (strlen(fmt) > MSG_SIZE) ? MSG_SIZE : strlen(fmt) ); // parse the format string and put the result in 'message' diff --git a/plugins/AdvaImg/src/FreeImage/FreeImageIO.cpp b/plugins/AdvaImg/src/FreeImage/FreeImageIO.cpp index b289530be7..f8cf7604eb 100644 --- a/plugins/AdvaImg/src/FreeImage/FreeImageIO.cpp +++ b/plugins/AdvaImg/src/FreeImage/FreeImageIO.cpp @@ -69,7 +69,7 @@ _MemoryReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle) { for(x = 0; x < count; x++) { //if there isnt size bytes left to read, set pos to eof and return a short count - if ( (mem_header->filelen - mem_header->curpos) < (long)size ) { + if( (mem_header->filelen - mem_header->curpos) < (long)size ) { mem_header->curpos = mem_header->filelen; break; } @@ -91,13 +91,13 @@ _MemoryWriteProc(void *buffer, unsigned size, unsigned count, fi_handle handle) //double the data block size if we need to while( (mem_header->curpos + (long)(size*count)) >= mem_header->datalen ) { //if we are at or above 1G, we cant double without going negative - if ( mem_header->datalen & 0x40000000 ) { + if( mem_header->datalen & 0x40000000 ) { //max 2G - if ( mem_header->datalen == 0x7FFFFFFF ) { + if( mem_header->datalen == 0x7FFFFFFF ) { return 0; } newdatalen = 0x7FFFFFFF; - } else if ( mem_header->datalen == 0 ) { + } else if( mem_header->datalen == 0 ) { //default to 4K if nothing yet newdatalen = 4096; } else { @@ -105,7 +105,7 @@ _MemoryWriteProc(void *buffer, unsigned size, unsigned count, fi_handle handle) newdatalen = mem_header->datalen << 1; } newdata = realloc( mem_header->data, newdatalen ); - if ( !newdata ) { + if( !newdata ) { return 0; } mem_header->data = newdata; @@ -113,7 +113,7 @@ _MemoryWriteProc(void *buffer, unsigned size, unsigned count, fi_handle handle) } memcpy( (char *)mem_header->data + mem_header->curpos, buffer, size*count ); mem_header->curpos += size*count; - if ( mem_header->curpos > mem_header->filelen ) { + if( mem_header->curpos > mem_header->filelen ) { mem_header->filelen = mem_header->curpos; } return count; @@ -126,21 +126,21 @@ _MemorySeekProc(fi_handle handle, long offset, int origin) { switch(origin) { //0 to filelen-1 are 'inside' the file default: case SEEK_SET: //can fseek() to 0-7FFFFFFF always - if ( offset >= 0 ) { + if( offset >= 0 ) { mem_header->curpos = offset; return 0; } break; case SEEK_CUR: - if ( mem_header->curpos + offset >= 0 ) { + if( mem_header->curpos + offset >= 0 ) { mem_header->curpos += offset; return 0; } break; case SEEK_END: - if ( mem_header->filelen + offset >= 0 ) { + if( mem_header->filelen + offset >= 0 ) { mem_header->curpos = mem_header->filelen + offset; return 0; } diff --git a/plugins/AdvaImg/src/FreeImage/GetType.cpp b/plugins/AdvaImg/src/FreeImage/GetType.cpp index 76edc7f3f9..0ac15fc2e6 100644 --- a/plugins/AdvaImg/src/FreeImage/GetType.cpp +++ b/plugins/AdvaImg/src/FreeImage/GetType.cpp @@ -27,7 +27,6 @@ #include "Utilities.h" #include "FreeImageIO.h" #include "Plugin.h" -#include "../DeprecationManager/DeprecationMgr.h" // ---------------------------------------------------------- diff --git a/plugins/AdvaImg/src/FreeImage/Halftoning.cpp b/plugins/AdvaImg/src/FreeImage/Halftoning.cpp index 1542fc9268..313cc26e15 100644 --- a/plugins/AdvaImg/src/FreeImage/Halftoning.cpp +++ b/plugins/AdvaImg/src/FreeImage/Halftoning.cpp @@ -176,7 +176,7 @@ static FIBITMAP* OrderedDispersedDot(FIBITMAP *dib, int order) { BYTE *matrix = (BYTE*)malloc(l*l * sizeof(BYTE)); for(int i = 0; i < l*l; i++) { // according to "Purdue University: Digital Image Processing Laboratory: Image Halftoning, April 30th, 2006 - matrix[i] = (BYTE)( 255 * (((double)dithervalue(i / l, i % l, order) + 0.5) / (l*l))); + matrix[i] = (BYTE)( 255 * (((double)dithervalue(i / l, i % l, order) + 0.5) / (l*l)) ); } // perform the dithering @@ -312,7 +312,7 @@ FIBITMAP * DLL_CALLCONV FreeImage_Dither(FIBITMAP *dib, FREE_IMAGE_DITHER algorithm) { FIBITMAP *input = NULL, *dib8 = NULL; - if (!FreeImage_HasPixels(dib)) return NULL; + if(!FreeImage_HasPixels(dib)) return NULL; const unsigned bpp = FreeImage_GetBPP(dib); @@ -401,7 +401,7 @@ FIBITMAP * DLL_CALLCONV FreeImage_Threshold(FIBITMAP *dib, BYTE T) { FIBITMAP *dib8 = NULL; - if (!FreeImage_HasPixels(dib)) return NULL; + if(!FreeImage_HasPixels(dib)) return NULL; const unsigned bpp = FreeImage_GetBPP(dib); diff --git a/plugins/AdvaImg/src/FreeImage/J2KHelper.cpp b/plugins/AdvaImg/src/FreeImage/J2KHelper.cpp index 44b210aca0..c9f8fa57af 100644 --- a/plugins/AdvaImg/src/FreeImage/J2KHelper.cpp +++ b/plugins/AdvaImg/src/FreeImage/J2KHelper.cpp @@ -1,500 +1,500 @@ -// ========================================================== -// JPEG2000 helpers -// -// Design and implementation by -// - Hervé Drolon (drolon@infonie.fr) -// -// This file is part of FreeImage 3 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include "FreeImage.h" -#include "Utilities.h" -#include "../LibOpenJPEG/openjpeg.h" - -/** -Divide an integer by a power of 2 and round upwards -@return Returns a divided by 2^b -*/ -static int int_ceildivpow2(int a, int b) { - return (a + (1 << b) - 1) >> b; -} - -/** -Convert a OpenJPEG image to a FIBITMAP -@param format_id Plugin ID -@param image OpenJPEG image -@return Returns the converted image if successful, returns NULL otherwise -*/ -FIBITMAP* J2KImageToFIBITMAP(int format_id, const opj_image_t *image) { - FIBITMAP *dib = NULL; - - try { - // compute image width and height - - //int w = int_ceildiv(image->x1 - image->x0, image->comps[0].dx); - int wr = image->comps[0].w; - int wrr = int_ceildivpow2(image->comps[0].w, image->comps[0].factor); - - //int h = int_ceildiv(image->y1 - image->y0, image->comps[0].dy); - //int hr = image->comps[0].h; - int hrr = int_ceildivpow2(image->comps[0].h, image->comps[0].factor); - - // check the number of components - - int numcomps = image->numcomps; - - BOOL bIsValid = TRUE; - for(int c = 0; c < numcomps - 1; c++) { - if ( (image->comps[c].dx == image->comps[c+1].dx) && - (image->comps[c].dy == image->comps[c+1].dy) && - (image->comps[c].prec == image->comps[c+1].prec) ) { - continue; - } else { - bIsValid = FALSE; - break; - } - } - bIsValid &= ((numcomps == 1) || (numcomps == 3) || (numcomps == 4)); - if (!bIsValid) { - if(numcomps) { - FreeImage_OutputMessageProc(format_id, "Warning: image contains %d greyscale components. Only the first will be loaded.\n", numcomps); - numcomps = 1; - } else { - // unknown type - throw FI_MSG_ERROR_UNSUPPORTED_FORMAT; - } - } - - // create a new DIB - - if(image->comps[0].prec <= 8) { - switch(numcomps) { - case 1: - dib = FreeImage_Allocate(wrr, hrr, 8); - break; - case 3: - dib = FreeImage_Allocate(wrr, hrr, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); - break; - case 4: - dib = FreeImage_Allocate(wrr, hrr, 32, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); - break; - } - } else if(image->comps[0].prec <= 16) { - switch(numcomps) { - case 1: - dib = FreeImage_AllocateT(FIT_UINT16, wrr, hrr); - break; - case 3: - dib = FreeImage_AllocateT(FIT_RGB16, wrr, hrr); - break; - case 4: - dib = FreeImage_AllocateT(FIT_RGBA16, wrr, hrr); - break; - } - } else { - throw FI_MSG_ERROR_UNSUPPORTED_FORMAT; - } - if (!dib) { - throw FI_MSG_ERROR_DIB_MEMORY; - } - - if(image->comps[0].prec <= 8) { - if(numcomps == 1) { - // 8-bit greyscale - // ---------------------------------------------------------- - - // build a greyscale palette - - RGBQUAD *pal = FreeImage_GetPalette(dib); - for (int i = 0; i < 256; i++) { - pal[i].rgbRed = (BYTE)i; - pal[i].rgbGreen = (BYTE)i; - pal[i].rgbBlue = (BYTE)i; - } - - // load pixel data - - unsigned pixel_count = 0; - - for(int y = 0; y < hrr; y++) { - BYTE *bits = FreeImage_GetScanLine(dib, hrr - 1 - y); - - for(int x = 0; x < wrr; x++) { - const unsigned pixel_pos = pixel_count / wrr * wr + pixel_count % wrr; - - int index = image->comps[0].data[pixel_pos]; - index += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0); - - bits[x] = (BYTE)index; - - pixel_count++; - } - } - } - else if(numcomps == 3) { - - // 24-bit RGB - // ---------------------------------------------------------- - - // load pixel data - - unsigned pixel_count = 0; - - for(int y = 0; y < hrr; y++) { - BYTE *bits = FreeImage_GetScanLine(dib, hrr - 1 - y); - - for(int x = 0; x < wrr; x++) { - const unsigned pixel_pos = pixel_count / wrr * wr + pixel_count % wrr; - - int r = image->comps[0].data[pixel_pos]; - r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0); - - int g = image->comps[1].data[pixel_pos]; - g += (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0); - - int b = image->comps[2].data[pixel_pos]; - b += (image->comps[2].sgnd ? 1 << (image->comps[2].prec - 1) : 0); - - bits[FI_RGBA_RED] = (BYTE)r; - bits[FI_RGBA_GREEN] = (BYTE)g; - bits[FI_RGBA_BLUE] = (BYTE)b; - bits += 3; - - pixel_count++; - } - } - } - else if(numcomps == 4) { - - // 32-bit RGBA - // ---------------------------------------------------------- - - // load pixel data - - unsigned pixel_count = 0; - - for(int y = 0; y < hrr; y++) { - BYTE *bits = FreeImage_GetScanLine(dib, hrr - 1 - y); - - for(int x = 0; x < wrr; x++) { - const unsigned pixel_pos = pixel_count / wrr * wr + pixel_count % wrr; - - int r = image->comps[0].data[pixel_pos]; - r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0); - - int g = image->comps[1].data[pixel_pos]; - g += (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0); - - int b = image->comps[2].data[pixel_pos]; - b += (image->comps[2].sgnd ? 1 << (image->comps[2].prec - 1) : 0); - - int a = image->comps[3].data[pixel_pos]; - a += (image->comps[3].sgnd ? 1 << (image->comps[3].prec - 1) : 0); - - bits[FI_RGBA_RED] = (BYTE)r; - bits[FI_RGBA_GREEN] = (BYTE)g; - bits[FI_RGBA_BLUE] = (BYTE)b; - bits[FI_RGBA_ALPHA] = (BYTE)a; - bits += 4; - - pixel_count++; - } - } - } - } - else if(image->comps[0].prec <= 16) { - if(numcomps == 1) { - // 16-bit greyscale - // ---------------------------------------------------------- - - // load pixel data - - unsigned pixel_count = 0; - - for(int y = 0; y < hrr; y++) { - unsigned short *bits = (unsigned short*)FreeImage_GetScanLine(dib, hrr - 1 - y); - - for(int x = 0; x < wrr; x++) { - const unsigned pixel_pos = pixel_count / wrr * wr + pixel_count % wrr; - - int index = image->comps[0].data[pixel_pos]; - index += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0); - - bits[x] = (unsigned short)index; - - pixel_count++; - } - } - } - else if(numcomps == 3) { - - // 48-bit RGB - // ---------------------------------------------------------- - - // load pixel data - - unsigned pixel_count = 0; - - for(int y = 0; y < hrr; y++) { - FIRGB16 *bits = (FIRGB16*)FreeImage_GetScanLine(dib, hrr - 1 - y); - - for(int x = 0; x < wrr; x++) { - const unsigned pixel_pos = pixel_count / wrr * wr + pixel_count % wrr; - - int r = image->comps[0].data[pixel_pos]; - r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0); - - int g = image->comps[1].data[pixel_pos]; - g += (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0); - - int b = image->comps[2].data[pixel_pos]; - b += (image->comps[2].sgnd ? 1 << (image->comps[2].prec - 1) : 0); - - bits[x].red = (WORD)r; - bits[x].green = (WORD)g; - bits[x].blue = (WORD)b; - - pixel_count++; - } - } - } - else if(numcomps == 4) { - - // 64-bit RGBA - // ---------------------------------------------------------- - - // load pixel data - - unsigned pixel_count = 0; - - for(int y = 0; y < hrr; y++) { - FIRGBA16 *bits = (FIRGBA16*)FreeImage_GetScanLine(dib, hrr - 1 - y); - - for(int x = 0; x < wrr; x++) { - const unsigned pixel_pos = pixel_count / wrr * wr + pixel_count % wrr; - - int r = image->comps[0].data[pixel_pos]; - r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0); - - int g = image->comps[1].data[pixel_pos]; - g += (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0); - - int b = image->comps[2].data[pixel_pos]; - b += (image->comps[2].sgnd ? 1 << (image->comps[2].prec - 1) : 0); - - int a = image->comps[3].data[pixel_pos]; - a += (image->comps[3].sgnd ? 1 << (image->comps[3].prec - 1) : 0); - - bits[x].red = (WORD)r; - bits[x].green = (WORD)g; - bits[x].blue = (WORD)b; - bits[x].alpha = (WORD)a; - - pixel_count++; - } - } - } - } - - return dib; - - } catch(const char *text) { - if(dib) FreeImage_Unload(dib); - FreeImage_OutputMessageProc(format_id, text); - return NULL; - } - -} - -/** -Convert a FIBITMAP to a OpenJPEG image -@param format_id Plugin ID -@param dib FreeImage image -@param parameters Compression parameters -@return Returns the converted image if successful, returns NULL otherwise -*/ -opj_image_t* FIBITMAPToJ2KImage(int format_id, FIBITMAP *dib, const opj_cparameters_t *parameters) { - int prec, numcomps, x, y, index; - OPJ_COLOR_SPACE color_space; - opj_image_cmptparm_t cmptparm[4]; // maximum of 4 components - opj_image_t *image = NULL; // image to encode - - try { - int w = FreeImage_GetWidth(dib); - int h = FreeImage_GetHeight(dib); - - // get image characteristics - FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(dib); - - if(image_type == FIT_BITMAP) { - // standard image ... - prec = 8; - switch(FreeImage_GetColorType(dib)) { - case FIC_MINISBLACK: - numcomps = 1; - color_space = CLRSPC_GRAY; - break; - case FIC_RGB: - if(FreeImage_GetBPP(dib) == 32) { - // 32-bit image with a fully opaque layer - numcomps = 4; - color_space = CLRSPC_SRGB; - } else { - // 24-bit image - numcomps = 3; - color_space = CLRSPC_SRGB; - } - break; - case FIC_RGBALPHA: - numcomps = 4; - color_space = CLRSPC_SRGB; - break; - default: - return NULL; - } - } else { - // HDR image ... - prec = 16; - switch(image_type) { - case FIT_UINT16: - numcomps = 1; - color_space = CLRSPC_GRAY; - break; - case FIT_RGB16: - numcomps = 3; - color_space = CLRSPC_SRGB; - break; - case FIT_RGBA16: - numcomps = 4; - color_space = CLRSPC_SRGB; - break; - default: - return NULL; - } - } - - // initialize image components - memset(&cmptparm[0], 0, 4 * sizeof(opj_image_cmptparm_t)); - for(int i = 0; i < numcomps; i++) { - cmptparm[i].dx = parameters->subsampling_dx; - cmptparm[i].dy = parameters->subsampling_dy; - cmptparm[i].w = w; - cmptparm[i].h = h; - cmptparm[i].prec = prec; - cmptparm[i].bpp = prec; - cmptparm[i].sgnd = 0; - } - // create the image - image = opj_image_create(numcomps, &cmptparm[0], color_space); - if (!image) { - throw FI_MSG_ERROR_DIB_MEMORY; - } - - // set image offset and reference grid - image->x0 = parameters->image_offset_x0; - image->y0 = parameters->image_offset_y0; - image->x1 = parameters->image_offset_x0 + (w - 1) * parameters->subsampling_dx + 1; - image->y1 = parameters->image_offset_y0 + (h - 1) * parameters->subsampling_dy + 1; - - // set image data - if(prec == 8) { - switch(numcomps) { - case 1: - index = 0; - for(y = 0; y < h; y++) { - BYTE *bits = FreeImage_GetScanLine(dib, h - 1 - y); - for(x = 0; x < w; x++) { - image->comps[0].data[index] = bits[x]; - index++; - } - } - break; - case 3: - index = 0; - for(y = 0; y < h; y++) { - BYTE *bits = FreeImage_GetScanLine(dib, h - 1 - y); - for(x = 0; x < w; x++) { - image->comps[0].data[index] = bits[FI_RGBA_RED]; - image->comps[1].data[index] = bits[FI_RGBA_GREEN]; - image->comps[2].data[index] = bits[FI_RGBA_BLUE]; - bits += 3; - index++; - } - } - break; - case 4: - index = 0; - for(y = 0; y < h; y++) { - BYTE *bits = FreeImage_GetScanLine(dib, h - 1 - y); - for(x = 0; x < w; x++) { - image->comps[0].data[index] = bits[FI_RGBA_RED]; - image->comps[1].data[index] = bits[FI_RGBA_GREEN]; - image->comps[2].data[index] = bits[FI_RGBA_BLUE]; - image->comps[3].data[index] = bits[FI_RGBA_ALPHA]; - bits += 4; - index++; - } - } - break; - } - } - else if(prec == 16) { - switch(numcomps) { - case 1: - index = 0; - for(y = 0; y < h; y++) { - WORD *bits = (WORD*)FreeImage_GetScanLine(dib, h - 1 - y); - for(x = 0; x < w; x++) { - image->comps[0].data[index] = bits[x]; - index++; - } - } - break; - case 3: - index = 0; - for(y = 0; y < h; y++) { - FIRGB16 *bits = (FIRGB16*)FreeImage_GetScanLine(dib, h - 1 - y); - for(x = 0; x < w; x++) { - image->comps[0].data[index] = bits[x].red; - image->comps[1].data[index] = bits[x].green; - image->comps[2].data[index] = bits[x].blue; - index++; - } - } - break; - case 4: - index = 0; - for(y = 0; y < h; y++) { - FIRGBA16 *bits = (FIRGBA16*)FreeImage_GetScanLine(dib, h - 1 - y); - for(x = 0; x < w; x++) { - image->comps[0].data[index] = bits[x].red; - image->comps[1].data[index] = bits[x].green; - image->comps[2].data[index] = bits[x].blue; - image->comps[3].data[index] = bits[x].alpha; - index++; - } - } - break; - } - } - - return image; - - } catch (const char *text) { - if(image) opj_image_destroy(image); - FreeImage_OutputMessageProc(format_id, text); - return NULL; - } -} +// ========================================================== +// JPEG2000 helpers +// +// Design and implementation by +// - Hervé Drolon (drolon@infonie.fr) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +#include "FreeImage.h" +#include "Utilities.h" +#include "../LibOpenJPEG/openjpeg.h" + +/** +Divide an integer by a power of 2 and round upwards +@return Returns a divided by 2^b +*/ +static int int_ceildivpow2(int a, int b) { + return (a + (1 << b) - 1) >> b; +} + +/** +Convert a OpenJPEG image to a FIBITMAP +@param format_id Plugin ID +@param image OpenJPEG image +@return Returns the converted image if successful, returns NULL otherwise +*/ +FIBITMAP* J2KImageToFIBITMAP(int format_id, const opj_image_t *image) { + FIBITMAP *dib = NULL; + + try { + // compute image width and height + + //int w = int_ceildiv(image->x1 - image->x0, image->comps[0].dx); + int wr = image->comps[0].w; + int wrr = int_ceildivpow2(image->comps[0].w, image->comps[0].factor); + + //int h = int_ceildiv(image->y1 - image->y0, image->comps[0].dy); + //int hr = image->comps[0].h; + int hrr = int_ceildivpow2(image->comps[0].h, image->comps[0].factor); + + // check the number of components + + int numcomps = image->numcomps; + + BOOL bIsValid = TRUE; + for(int c = 0; c < numcomps - 1; c++) { + if( (image->comps[c].dx == image->comps[c+1].dx) && + (image->comps[c].dy == image->comps[c+1].dy) && + (image->comps[c].prec == image->comps[c+1].prec) ) { + continue; + } else { + bIsValid = FALSE; + break; + } + } + bIsValid &= ((numcomps == 1) || (numcomps == 3) || (numcomps == 4)); + if(!bIsValid) { + if(numcomps) { + FreeImage_OutputMessageProc(format_id, "Warning: image contains %d greyscale components. Only the first will be loaded.\n", numcomps); + numcomps = 1; + } else { + // unknown type + throw FI_MSG_ERROR_UNSUPPORTED_FORMAT; + } + } + + // create a new DIB + + if(image->comps[0].prec <= 8) { + switch(numcomps) { + case 1: + dib = FreeImage_Allocate(wrr, hrr, 8); + break; + case 3: + dib = FreeImage_Allocate(wrr, hrr, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); + break; + case 4: + dib = FreeImage_Allocate(wrr, hrr, 32, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); + break; + } + } else if(image->comps[0].prec <= 16) { + switch(numcomps) { + case 1: + dib = FreeImage_AllocateT(FIT_UINT16, wrr, hrr); + break; + case 3: + dib = FreeImage_AllocateT(FIT_RGB16, wrr, hrr); + break; + case 4: + dib = FreeImage_AllocateT(FIT_RGBA16, wrr, hrr); + break; + } + } else { + throw FI_MSG_ERROR_UNSUPPORTED_FORMAT; + } + if(!dib) { + throw FI_MSG_ERROR_DIB_MEMORY; + } + + if(image->comps[0].prec <= 8) { + if(numcomps == 1) { + // 8-bit greyscale + // ---------------------------------------------------------- + + // build a greyscale palette + + RGBQUAD *pal = FreeImage_GetPalette(dib); + for (int i = 0; i < 256; i++) { + pal[i].rgbRed = (BYTE)i; + pal[i].rgbGreen = (BYTE)i; + pal[i].rgbBlue = (BYTE)i; + } + + // load pixel data + + unsigned pixel_count = 0; + + for(int y = 0; y < hrr; y++) { + BYTE *bits = FreeImage_GetScanLine(dib, hrr - 1 - y); + + for(int x = 0; x < wrr; x++) { + const unsigned pixel_pos = pixel_count / wrr * wr + pixel_count % wrr; + + int index = image->comps[0].data[pixel_pos]; + index += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0); + + bits[x] = (BYTE)index; + + pixel_count++; + } + } + } + else if(numcomps == 3) { + + // 24-bit RGB + // ---------------------------------------------------------- + + // load pixel data + + unsigned pixel_count = 0; + + for(int y = 0; y < hrr; y++) { + BYTE *bits = FreeImage_GetScanLine(dib, hrr - 1 - y); + + for(int x = 0; x < wrr; x++) { + const unsigned pixel_pos = pixel_count / wrr * wr + pixel_count % wrr; + + int r = image->comps[0].data[pixel_pos]; + r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0); + + int g = image->comps[1].data[pixel_pos]; + g += (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0); + + int b = image->comps[2].data[pixel_pos]; + b += (image->comps[2].sgnd ? 1 << (image->comps[2].prec - 1) : 0); + + bits[FI_RGBA_RED] = (BYTE)r; + bits[FI_RGBA_GREEN] = (BYTE)g; + bits[FI_RGBA_BLUE] = (BYTE)b; + bits += 3; + + pixel_count++; + } + } + } + else if(numcomps == 4) { + + // 32-bit RGBA + // ---------------------------------------------------------- + + // load pixel data + + unsigned pixel_count = 0; + + for(int y = 0; y < hrr; y++) { + BYTE *bits = FreeImage_GetScanLine(dib, hrr - 1 - y); + + for(int x = 0; x < wrr; x++) { + const unsigned pixel_pos = pixel_count / wrr * wr + pixel_count % wrr; + + int r = image->comps[0].data[pixel_pos]; + r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0); + + int g = image->comps[1].data[pixel_pos]; + g += (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0); + + int b = image->comps[2].data[pixel_pos]; + b += (image->comps[2].sgnd ? 1 << (image->comps[2].prec - 1) : 0); + + int a = image->comps[3].data[pixel_pos]; + a += (image->comps[3].sgnd ? 1 << (image->comps[3].prec - 1) : 0); + + bits[FI_RGBA_RED] = (BYTE)r; + bits[FI_RGBA_GREEN] = (BYTE)g; + bits[FI_RGBA_BLUE] = (BYTE)b; + bits[FI_RGBA_ALPHA] = (BYTE)a; + bits += 4; + + pixel_count++; + } + } + } + } + else if(image->comps[0].prec <= 16) { + if(numcomps == 1) { + // 16-bit greyscale + // ---------------------------------------------------------- + + // load pixel data + + unsigned pixel_count = 0; + + for(int y = 0; y < hrr; y++) { + unsigned short *bits = (unsigned short*)FreeImage_GetScanLine(dib, hrr - 1 - y); + + for(int x = 0; x < wrr; x++) { + const unsigned pixel_pos = pixel_count / wrr * wr + pixel_count % wrr; + + int index = image->comps[0].data[pixel_pos]; + index += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0); + + bits[x] = (unsigned short)index; + + pixel_count++; + } + } + } + else if(numcomps == 3) { + + // 48-bit RGB + // ---------------------------------------------------------- + + // load pixel data + + unsigned pixel_count = 0; + + for(int y = 0; y < hrr; y++) { + FIRGB16 *bits = (FIRGB16*)FreeImage_GetScanLine(dib, hrr - 1 - y); + + for(int x = 0; x < wrr; x++) { + const unsigned pixel_pos = pixel_count / wrr * wr + pixel_count % wrr; + + int r = image->comps[0].data[pixel_pos]; + r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0); + + int g = image->comps[1].data[pixel_pos]; + g += (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0); + + int b = image->comps[2].data[pixel_pos]; + b += (image->comps[2].sgnd ? 1 << (image->comps[2].prec - 1) : 0); + + bits[x].red = (WORD)r; + bits[x].green = (WORD)g; + bits[x].blue = (WORD)b; + + pixel_count++; + } + } + } + else if(numcomps == 4) { + + // 64-bit RGBA + // ---------------------------------------------------------- + + // load pixel data + + unsigned pixel_count = 0; + + for(int y = 0; y < hrr; y++) { + FIRGBA16 *bits = (FIRGBA16*)FreeImage_GetScanLine(dib, hrr - 1 - y); + + for(int x = 0; x < wrr; x++) { + const unsigned pixel_pos = pixel_count / wrr * wr + pixel_count % wrr; + + int r = image->comps[0].data[pixel_pos]; + r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0); + + int g = image->comps[1].data[pixel_pos]; + g += (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0); + + int b = image->comps[2].data[pixel_pos]; + b += (image->comps[2].sgnd ? 1 << (image->comps[2].prec - 1) : 0); + + int a = image->comps[3].data[pixel_pos]; + a += (image->comps[3].sgnd ? 1 << (image->comps[3].prec - 1) : 0); + + bits[x].red = (WORD)r; + bits[x].green = (WORD)g; + bits[x].blue = (WORD)b; + bits[x].alpha = (WORD)a; + + pixel_count++; + } + } + } + } + + return dib; + + } catch(const char *text) { + if(dib) FreeImage_Unload(dib); + FreeImage_OutputMessageProc(format_id, text); + return NULL; + } + +} + +/** +Convert a FIBITMAP to a OpenJPEG image +@param format_id Plugin ID +@param dib FreeImage image +@param parameters Compression parameters +@return Returns the converted image if successful, returns NULL otherwise +*/ +opj_image_t* FIBITMAPToJ2KImage(int format_id, FIBITMAP *dib, const opj_cparameters_t *parameters) { + int prec, numcomps, x, y, index; + OPJ_COLOR_SPACE color_space; + opj_image_cmptparm_t cmptparm[4]; // maximum of 4 components + opj_image_t *image = NULL; // image to encode + + try { + int w = FreeImage_GetWidth(dib); + int h = FreeImage_GetHeight(dib); + + // get image characteristics + FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(dib); + + if(image_type == FIT_BITMAP) { + // standard image ... + prec = 8; + switch(FreeImage_GetColorType(dib)) { + case FIC_MINISBLACK: + numcomps = 1; + color_space = CLRSPC_GRAY; + break; + case FIC_RGB: + if(FreeImage_GetBPP(dib) == 32) { + // 32-bit image with a fully opaque layer + numcomps = 4; + color_space = CLRSPC_SRGB; + } else { + // 24-bit image + numcomps = 3; + color_space = CLRSPC_SRGB; + } + break; + case FIC_RGBALPHA: + numcomps = 4; + color_space = CLRSPC_SRGB; + break; + default: + return NULL; + } + } else { + // HDR image ... + prec = 16; + switch(image_type) { + case FIT_UINT16: + numcomps = 1; + color_space = CLRSPC_GRAY; + break; + case FIT_RGB16: + numcomps = 3; + color_space = CLRSPC_SRGB; + break; + case FIT_RGBA16: + numcomps = 4; + color_space = CLRSPC_SRGB; + break; + default: + return NULL; + } + } + + // initialize image components + memset(&cmptparm[0], 0, 4 * sizeof(opj_image_cmptparm_t)); + for(int i = 0; i < numcomps; i++) { + cmptparm[i].dx = parameters->subsampling_dx; + cmptparm[i].dy = parameters->subsampling_dy; + cmptparm[i].w = w; + cmptparm[i].h = h; + cmptparm[i].prec = prec; + cmptparm[i].bpp = prec; + cmptparm[i].sgnd = 0; + } + // create the image + image = opj_image_create(numcomps, &cmptparm[0], color_space); + if(!image) { + throw FI_MSG_ERROR_DIB_MEMORY; + } + + // set image offset and reference grid + image->x0 = parameters->image_offset_x0; + image->y0 = parameters->image_offset_y0; + image->x1 = parameters->image_offset_x0 + (w - 1) * parameters->subsampling_dx + 1; + image->y1 = parameters->image_offset_y0 + (h - 1) * parameters->subsampling_dy + 1; + + // set image data + if(prec == 8) { + switch(numcomps) { + case 1: + index = 0; + for(y = 0; y < h; y++) { + BYTE *bits = FreeImage_GetScanLine(dib, h - 1 - y); + for(x = 0; x < w; x++) { + image->comps[0].data[index] = bits[x]; + index++; + } + } + break; + case 3: + index = 0; + for(y = 0; y < h; y++) { + BYTE *bits = FreeImage_GetScanLine(dib, h - 1 - y); + for(x = 0; x < w; x++) { + image->comps[0].data[index] = bits[FI_RGBA_RED]; + image->comps[1].data[index] = bits[FI_RGBA_GREEN]; + image->comps[2].data[index] = bits[FI_RGBA_BLUE]; + bits += 3; + index++; + } + } + break; + case 4: + index = 0; + for(y = 0; y < h; y++) { + BYTE *bits = FreeImage_GetScanLine(dib, h - 1 - y); + for(x = 0; x < w; x++) { + image->comps[0].data[index] = bits[FI_RGBA_RED]; + image->comps[1].data[index] = bits[FI_RGBA_GREEN]; + image->comps[2].data[index] = bits[FI_RGBA_BLUE]; + image->comps[3].data[index] = bits[FI_RGBA_ALPHA]; + bits += 4; + index++; + } + } + break; + } + } + else if(prec == 16) { + switch(numcomps) { + case 1: + index = 0; + for(y = 0; y < h; y++) { + WORD *bits = (WORD*)FreeImage_GetScanLine(dib, h - 1 - y); + for(x = 0; x < w; x++) { + image->comps[0].data[index] = bits[x]; + index++; + } + } + break; + case 3: + index = 0; + for(y = 0; y < h; y++) { + FIRGB16 *bits = (FIRGB16*)FreeImage_GetScanLine(dib, h - 1 - y); + for(x = 0; x < w; x++) { + image->comps[0].data[index] = bits[x].red; + image->comps[1].data[index] = bits[x].green; + image->comps[2].data[index] = bits[x].blue; + index++; + } + } + break; + case 4: + index = 0; + for(y = 0; y < h; y++) { + FIRGBA16 *bits = (FIRGBA16*)FreeImage_GetScanLine(dib, h - 1 - y); + for(x = 0; x < w; x++) { + image->comps[0].data[index] = bits[x].red; + image->comps[1].data[index] = bits[x].green; + image->comps[2].data[index] = bits[x].blue; + image->comps[3].data[index] = bits[x].alpha; + index++; + } + } + break; + } + } + + return image; + + } catch (const char *text) { + if(image) opj_image_destroy(image); + FreeImage_OutputMessageProc(format_id, text); + return NULL; + } +} diff --git a/plugins/AdvaImg/src/FreeImage/MultiPage.cpp b/plugins/AdvaImg/src/FreeImage/MultiPage.cpp index e5bcee3ded..60ce85eb10 100644 --- a/plugins/AdvaImg/src/FreeImage/MultiPage.cpp +++ b/plugins/AdvaImg/src/FreeImage/MultiPage.cpp @@ -269,8 +269,8 @@ FreeImage_OpenMultiBitmap(FREE_IMAGE_FORMAT fif, const char *filename, BOOL crea header->node = node; header->fif = fif; header->io = io.get (); - header->handle = handle; - header->changed = FALSE; + header->handle = handle; + header->changed = FALSE; header->read_only = read_only; header->m_cachefile = NULL; header->cache_fif = fif; @@ -344,13 +344,13 @@ FreeImage_OpenMultiBitmapFromHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_h BOOL read_only = FALSE; // modifications (if any) will be stored into the memory cache if (io && handle) { - + // retrieve the plugin list to find the node belonging to this plugin PluginList *list = FreeImage_GetPluginList(); - + if (list) { PluginNode *node = list->FindNodeFromFIF(fif); - + if (node) { std::auto_ptr bitmap (new FIMULTIBITMAP); std::auto_ptr header (new MULTIBITMAPHEADER); @@ -359,13 +359,13 @@ FreeImage_OpenMultiBitmapFromHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_h header->m_filename = NULL; header->node = node; header->fif = fif; - header->handle = handle; - header->changed = FALSE; + header->handle = handle; + header->changed = FALSE; header->read_only = read_only; header->m_cachefile = NULL; header->cache_fif = fif; header->load_flags = flags; - + // store the MULTIBITMAPHEADER in the surrounding FIMULTIBITMAP structure bitmap->data = header.get(); @@ -400,7 +400,7 @@ FreeImage_OpenMultiBitmapFromHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_h BOOL DLL_CALLCONV FreeImage_SaveMultiBitmapToHandle(FREE_IMAGE_FORMAT fif, FIMULTIBITMAP *bitmap, FreeImageIO *io, fi_handle handle, int flags) { - if (!bitmap || !bitmap->data || !io || !handle) { + if(!bitmap || !bitmap->data || !io || !handle) { return FALSE; } @@ -546,7 +546,7 @@ FreeImage_CloseMultiBitmap(FIMULTIBITMAP *bitmap, int flags) { if (success) { remove(header->m_filename); success = (rename(spool_name.c_str(), header->m_filename) == 0) ? TRUE:FALSE; - if (!success) { + if(!success) { FreeImage_OutputMessageProc(header->fif, "Failed to rename %s to %s", spool_name.c_str(), header->m_filename); } } else { @@ -647,12 +647,12 @@ FreeImage_SavePageToBlock(MULTIBITMAPHEADER *header, FIBITMAP *data) { FIMEMORY *hmem = FreeImage_OpenMemory(); if(hmem==NULL) return NULL; // save the file to memory - if (!FreeImage_SaveToMemory(header->cache_fif, data, hmem, 0)) { + if(!FreeImage_SaveToMemory(header->cache_fif, data, hmem, 0)) { FreeImage_CloseMemory(hmem); return NULL; } // get the buffer from the memory stream - if (!FreeImage_AcquireMemory(hmem, &compressed_data, &compressed_size)) { + if(!FreeImage_AcquireMemory(hmem, &compressed_data, &compressed_size)) { FreeImage_CloseMemory(hmem); return NULL; } diff --git a/plugins/AdvaImg/src/FreeImage/NNQuantizer.cpp b/plugins/AdvaImg/src/FreeImage/NNQuantizer.cpp index 6eb9aeaf48..f907c41d55 100644 --- a/plugins/AdvaImg/src/FreeImage/NNQuantizer.cpp +++ b/plugins/AdvaImg/src/FreeImage/NNQuantizer.cpp @@ -60,7 +60,7 @@ NNQuantizer::NNQuantizer(int PaletteSize) freq = (int *)malloc(netsize * sizeof(int)); radpower = (int *)malloc(initrad * sizeof(int)); - if ( !network || !bias || !freq || !radpower ) { + if( !network || !bias || !freq || !radpower ) { if(network) free(network); if(bias) free(bias); if(freq) free(freq); @@ -455,7 +455,7 @@ FIBITMAP* NNQuantizer::Quantize(FIBITMAP *dib, int ReserveSize, RGBQUAD *Reserve // 3) Initialize the network and apply the learning algorithm - if ( netsize > ReserveSize ) { + if( netsize > ReserveSize ) { netsize -= ReserveSize; initnet(); learn(sampling); diff --git a/plugins/AdvaImg/src/FreeImage/PSDParser.cpp b/plugins/AdvaImg/src/FreeImage/PSDParser.cpp index 93573d01c0..57c703a06f 100644 --- a/plugins/AdvaImg/src/FreeImage/PSDParser.cpp +++ b/plugins/AdvaImg/src/FreeImage/PSDParser.cpp @@ -72,7 +72,7 @@ bool psdHeaderInfo::Read(FreeImageIO *io, fi_handle handle) { psdHeader header; const int n = (int)io->read_proc(&header, sizeof(header), 1, handle); - if (!n) { + if(!n) { return false; } @@ -282,7 +282,7 @@ int psdDisplayInfo::Read(FreeImageIO *io, fi_handle handle) { n = (int)io->read_proc(&ShortValue, sizeof(ShortValue), 1, handle); nBytes += n * sizeof(ShortValue); _Opacity = (short)psdGetValue(ShortValue, sizeof(_Opacity) ); - if ((_Opacity < 0) || (_Opacity > 100)) { + if((_Opacity < 0) || (_Opacity > 100)) { throw "Invalid DisplayInfo::Opacity value"; } @@ -418,7 +418,7 @@ BOOL invertColor(FIBITMAP* dib) { FREE_IMAGE_TYPE type = FreeImage_GetImageType(dib); const unsigned Bpp = FreeImage_GetBPP(dib)/8; - if ((type == FIT_BITMAP && Bpp == 4) || type == FIT_RGBA16) { + if((type == FIT_BITMAP && Bpp == 4) || type == FIT_RGBA16) { const unsigned width = FreeImage_GetWidth(dib); const unsigned height = FreeImage_GetHeight(dib); BYTE *line_start = FreeImage_GetScanLine(dib, 0); @@ -508,7 +508,7 @@ bool psdParser::ReadImageResources(FreeImageIO *io, fi_handle handle, LONG lengt n = (int)io->read_proc(&oResource._OSType, sizeof(oResource._OSType), 1, handle); nBytes += n * sizeof(oResource._OSType); - if ( (nBytes % 2) != 0 ) { + if( (nBytes % 2) != 0 ) { return false; } @@ -653,7 +653,7 @@ FIBITMAP* psdParser::ReadImageData(FreeImageIO *io, fi_handle handle) { SwapShort(&nCompression); #endif - if ((nCompression != PSDP_COMPRESSION_NONE && nCompression != PSDP_COMPRESSION_RLE)) { + if((nCompression != PSDP_COMPRESSION_NONE && nCompression != PSDP_COMPRESSION_RLE)) { FreeImage_OutputMessageProc(_fi_format_id, "Unsupported compression %d", nCompression); return NULL; } @@ -730,7 +730,7 @@ FIBITMAP* psdParser::ReadImageData(FreeImageIO *io, fi_handle handle) { throw "Unsupported color mode"; break; } - if (!bitmap) { + if(!bitmap) { throw FI_MSG_ERROR_DIB_MEMORY; } @@ -797,7 +797,7 @@ FIBITMAP* psdParser::ReadImageData(FreeImageIO *io, fi_handle handle) { // later use this array as WORD rleLineSizeList[nChannels][nHeight]; WORD *rleLineSizeList = new (std::nothrow) WORD[nChannels*nHeight]; - if (!rleLineSizeList) { + if(!rleLineSizeList) { FreeImage_Unload(bitmap); SAFE_DELETE_ARRAY(line_start); throw std::bad_alloc(); @@ -820,7 +820,7 @@ FIBITMAP* psdParser::ReadImageData(FreeImageIO *io, fi_handle handle) { } BYTE* rle_line_start = new (std::nothrow) BYTE[largestRLELine]; - if (!rle_line_start) { + if(!rle_line_start) { FreeImage_Unload(bitmap); SAFE_DELETE_ARRAY(line_start); SAFE_DELETE_ARRAY(rleLineSizeList); @@ -924,7 +924,7 @@ FIBITMAP* psdParser::ReadImageData(FreeImageIO *io, fi_handle handle) { // --- Further process the bitmap --- - if ((mode == PSDP_CMYK || mode == PSDP_MULTICHANNEL)) { + if((mode == PSDP_CMYK || mode == PSDP_MULTICHANNEL)) { // CMYK values are "inverted", invert them back if(mode == PSDP_MULTICHANNEL) { @@ -933,7 +933,7 @@ FIBITMAP* psdParser::ReadImageData(FreeImageIO *io, fi_handle handle) { FreeImage_Invert(bitmap); } - if ((_fi_flags & PSD_CMYK) == PSD_CMYK) { + if((_fi_flags & PSD_CMYK) == PSD_CMYK) { // keep as CMYK if(mode == PSDP_MULTICHANNEL) { @@ -971,7 +971,7 @@ FIBITMAP* psdParser::ReadImageData(FreeImageIO *io, fi_handle handle) { CREATE_GREYSCALE_PALETTE_REVERSE(FreeImage_GetPalette(bitmap), 2); } else if(mode == PSDP_INDEXED) { - if (!_colourModeData._plColourData || _colourModeData._Length != 768 || _ColourCount < 0) { + if(!_colourModeData._plColourData || _colourModeData._Length != 768 || _ColourCount < 0) { FreeImage_OutputMessageProc(_fi_format_id, "Indexed image has no palette. Using the default grayscale one."); } else { _colourModeData.FillPalette(bitmap); @@ -1037,7 +1037,7 @@ FIBITMAP* psdParser::Load(FreeImageIO *io, fi_handle handle, int s_format_id, in FreeImage_CreateICCProfile(Bitmap, _iccProfile._ProfileData, _iccProfile._ProfileSize); if ((flags & PSD_CMYK) == PSD_CMYK) { short mode = _headerInfo._ColourMode; - if ((mode == PSDP_CMYK) || (mode == PSDP_MULTICHANNEL)) { + if((mode == PSDP_CMYK) || (mode == PSDP_MULTICHANNEL)) { FreeImage_GetICCProfile(Bitmap)->flags |= FIICC_COLOR_IS_CMYK; } } diff --git a/plugins/AdvaImg/src/FreeImage/PixelAccess.cpp b/plugins/AdvaImg/src/FreeImage/PixelAccess.cpp index 158f9997b2..e3dccfe1c9 100644 --- a/plugins/AdvaImg/src/FreeImage/PixelAccess.cpp +++ b/plugins/AdvaImg/src/FreeImage/PixelAccess.cpp @@ -29,19 +29,20 @@ BYTE * DLL_CALLCONV FreeImage_GetBits(FIBITMAP *dib) { - if (!FreeImage_HasPixels(dib)) { + if(!FreeImage_HasPixels(dib)) { return NULL; } // returns the pixels aligned on a FIBITMAP_ALIGNMENT bytes alignment boundary size_t lp = (size_t)FreeImage_GetInfoHeader(dib); lp += sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * FreeImage_GetColorsUsed(dib); + lp += FreeImage_HasRGBMasks(dib) ? sizeof(DWORD) * 3 : 0; lp += (lp % FIBITMAP_ALIGNMENT ? FIBITMAP_ALIGNMENT - lp % FIBITMAP_ALIGNMENT : 0); return (BYTE *)lp; } BYTE * DLL_CALLCONV FreeImage_GetScanLine(FIBITMAP *dib, int scanline) { - if (!FreeImage_HasPixels(dib)) { + if(!FreeImage_HasPixels(dib)) { return NULL; } return CalculateScanLine(FreeImage_GetBits(dib), FreeImage_GetPitch(dib), scanline); @@ -51,10 +52,10 @@ BOOL DLL_CALLCONV FreeImage_GetPixelIndex(FIBITMAP *dib, unsigned x, unsigned y, BYTE *value) { BYTE shift; - if (!FreeImage_HasPixels(dib) || (FreeImage_GetImageType(dib) != FIT_BITMAP)) + if(!FreeImage_HasPixels(dib) || (FreeImage_GetImageType(dib) != FIT_BITMAP)) return FALSE; - if ((x < FreeImage_GetWidth(dib)) && (y < FreeImage_GetHeight(dib))) { + if((x < FreeImage_GetWidth(dib)) && (y < FreeImage_GetHeight(dib))) { BYTE *bits = FreeImage_GetScanLine(dib, y); switch(FreeImage_GetBPP(dib)) { @@ -80,10 +81,10 @@ FreeImage_GetPixelIndex(FIBITMAP *dib, unsigned x, unsigned y, BYTE *value) { BOOL DLL_CALLCONV FreeImage_GetPixelColor(FIBITMAP *dib, unsigned x, unsigned y, RGBQUAD *value) { - if (!FreeImage_HasPixels(dib) || (FreeImage_GetImageType(dib) != FIT_BITMAP)) + if(!FreeImage_HasPixels(dib) || (FreeImage_GetImageType(dib) != FIT_BITMAP)) return FALSE; - if ((x < FreeImage_GetWidth(dib)) && (y < FreeImage_GetHeight(dib))) { + if((x < FreeImage_GetWidth(dib)) && (y < FreeImage_GetHeight(dib))) { BYTE *bits = FreeImage_GetScanLine(dib, y); switch(FreeImage_GetBPP(dib)) { @@ -91,7 +92,7 @@ FreeImage_GetPixelColor(FIBITMAP *dib, unsigned x, unsigned y, RGBQUAD *value) { { bits += 2*x; WORD *pixel = (WORD *)bits; - if ((FreeImage_GetRedMask(dib) == FI16_565_RED_MASK) && (FreeImage_GetGreenMask(dib) == FI16_565_GREEN_MASK) && (FreeImage_GetBlueMask(dib) == FI16_565_BLUE_MASK)) { + if((FreeImage_GetRedMask(dib) == FI16_565_RED_MASK) && (FreeImage_GetGreenMask(dib) == FI16_565_GREEN_MASK) && (FreeImage_GetBlueMask(dib) == FI16_565_BLUE_MASK)) { value->rgbBlue = (BYTE)((((*pixel & FI16_565_BLUE_MASK) >> FI16_565_BLUE_SHIFT) * 0xFF) / 0x1F); value->rgbGreen = (BYTE)((((*pixel & FI16_565_GREEN_MASK) >> FI16_565_GREEN_SHIFT) * 0xFF) / 0x3F); value->rgbRed = (BYTE)((((*pixel & FI16_565_RED_MASK) >> FI16_565_RED_SHIFT) * 0xFF) / 0x1F); @@ -132,10 +133,10 @@ BOOL DLL_CALLCONV FreeImage_SetPixelIndex(FIBITMAP *dib, unsigned x, unsigned y, BYTE *value) { BYTE shift; - if (!FreeImage_HasPixels(dib) || (FreeImage_GetImageType(dib) != FIT_BITMAP)) + if(!FreeImage_HasPixels(dib) || (FreeImage_GetImageType(dib) != FIT_BITMAP)) return FALSE; - if ((x < FreeImage_GetWidth(dib)) && (y < FreeImage_GetHeight(dib))) { + if((x < FreeImage_GetWidth(dib)) && (y < FreeImage_GetHeight(dib))) { BYTE *bits = FreeImage_GetScanLine(dib, y); switch(FreeImage_GetBPP(dib)) { @@ -162,10 +163,10 @@ FreeImage_SetPixelIndex(FIBITMAP *dib, unsigned x, unsigned y, BYTE *value) { BOOL DLL_CALLCONV FreeImage_SetPixelColor(FIBITMAP *dib, unsigned x, unsigned y, RGBQUAD *value) { - if (!FreeImage_HasPixels(dib) || (FreeImage_GetImageType(dib) != FIT_BITMAP)) + if(!FreeImage_HasPixels(dib) || (FreeImage_GetImageType(dib) != FIT_BITMAP)) return FALSE; - if ((x < FreeImage_GetWidth(dib)) && (y < FreeImage_GetHeight(dib))) { + if((x < FreeImage_GetWidth(dib)) && (y < FreeImage_GetHeight(dib))) { BYTE *bits = FreeImage_GetScanLine(dib, y); switch(FreeImage_GetBPP(dib)) { @@ -173,7 +174,7 @@ FreeImage_SetPixelColor(FIBITMAP *dib, unsigned x, unsigned y, RGBQUAD *value) { { bits += 2*x; WORD *pixel = (WORD *)bits; - if ((FreeImage_GetRedMask(dib) == FI16_565_RED_MASK) && (FreeImage_GetGreenMask(dib) == FI16_565_GREEN_MASK) && (FreeImage_GetBlueMask(dib) == FI16_565_BLUE_MASK)) { + if((FreeImage_GetRedMask(dib) == FI16_565_RED_MASK) && (FreeImage_GetGreenMask(dib) == FI16_565_GREEN_MASK) && (FreeImage_GetBlueMask(dib) == FI16_565_BLUE_MASK)) { *pixel = ((value->rgbBlue >> 3) << FI16_565_BLUE_SHIFT) | ((value->rgbGreen >> 2) << FI16_565_GREEN_SHIFT) | ((value->rgbRed >> 3) << FI16_565_RED_SHIFT); diff --git a/plugins/AdvaImg/src/FreeImage/Plugin.cpp b/plugins/AdvaImg/src/FreeImage/Plugin.cpp index ce2863a72e..7ded36ebc2 100644 --- a/plugins/AdvaImg/src/FreeImage/Plugin.cpp +++ b/plugins/AdvaImg/src/FreeImage/Plugin.cpp @@ -2,7 +2,7 @@ // FreeImage Plugin Interface // // Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) +// - Floris van den Berg (floris@geekhq.nl) // - Rui Lopes (ruiglopes@yahoo.com) // - Detlev Vendt (detlev.vendt@brillit.de) // - Petr Pytelka (pyta@lightcomp.com) @@ -38,6 +38,8 @@ #include "FreeImageIO.h" #include "Plugin.h" +#include "../Metadata/FreeImageTag.h" + // ===================================================================== using namespace std; @@ -85,12 +87,18 @@ m_node_count(0) { FREE_IMAGE_FORMAT PluginList::AddNode(FI_InitProc init_proc, void *instance, const char *format, const char *description, const char *extension, const char *regexpr) { if (init_proc != NULL) { - PluginNode *node = new PluginNode; - Plugin *plugin = new Plugin; + PluginNode *node = new(std::nothrow) PluginNode; + Plugin *plugin = new(std::nothrow) Plugin; + if(!node || !plugin) { + if(node) delete node; + if(plugin) delete plugin; + FreeImage_OutputMessageProc(FIF_UNKNOWN, FI_MSG_ERROR_MEMORY); + return FIF_UNKNOWN; + } memset(plugin, 0, sizeof(Plugin)); - // fill-in the plugin structure + // fill-in the plugin structure // note we have memset to 0, so all unset pointers should be NULL) init_proc(plugin, (int)m_plugin_map.size()); @@ -99,28 +107,27 @@ PluginList::AddNode(FI_InitProc init_proc, void *instance, const char *format, c const char *the_format = NULL; - if (format != NULL) + if (format != NULL) { the_format = format; - else if (plugin->format_proc != NULL) + } else if (plugin->format_proc != NULL) { the_format = plugin->format_proc(); + } // add the node if it wasn't there already if (the_format != NULL) { - if (FindNodeFromFormat(the_format) == NULL) { - node->m_id = (int)m_plugin_map.size(); - node->m_instance = instance; - node->m_plugin = plugin; - node->m_format = format; - node->m_description = description; - node->m_extension = extension; - node->m_regexpr = regexpr; - node->m_enabled = TRUE; - - m_plugin_map[(const int)m_plugin_map.size()] = node; - - return (FREE_IMAGE_FORMAT)node->m_id; - } + node->m_id = (int)m_plugin_map.size(); + node->m_instance = instance; + node->m_plugin = plugin; + node->m_format = format; + node->m_description = description; + node->m_extension = extension; + node->m_regexpr = regexpr; + node->m_enabled = TRUE; + + m_plugin_map[(const int)m_plugin_map.size()] = node; + + return (FREE_IMAGE_FORMAT)node->m_id; } // something went wrong while allocating the plugin... cleanup @@ -134,15 +141,14 @@ PluginList::AddNode(FI_InitProc init_proc, void *instance, const char *format, c PluginNode * PluginList::FindNodeFromFormat(const char *format) { - int count = 0; - for (map::iterator i = m_plugin_map.begin(); i != m_plugin_map.end(); ++i) { const char *the_format = ((*i).second->m_format != NULL) ? (*i).second->m_format : (*i).second->m_plugin->format_proc(); - if (FreeImage_stricmp(the_format, format) == 0) - return (*i).second; - - count++; + if ((*i).second->m_enabled) { + if (FreeImage_stricmp(the_format, format) == 0) { + return (*i).second; + } + } } return NULL; @@ -150,15 +156,14 @@ PluginList::FindNodeFromFormat(const char *format) { PluginNode * PluginList::FindNodeFromMime(const char *mime) { - int count = 0; - for (map::iterator i = m_plugin_map.begin(); i != m_plugin_map.end(); ++i) { const char *the_mime = ((*i).second->m_plugin->mime_proc != NULL) ? (*i).second->m_plugin->mime_proc() : ""; - if ((the_mime != NULL) && (strcmp(the_mime, mime) == 0)) - return (*i).second; - - count++; + if ((*i).second->m_enabled) { + if ((the_mime != NULL) && (strcmp(the_mime, mime) == 0)) { + return (*i).second; + } + } } return NULL; @@ -168,8 +173,9 @@ PluginNode * PluginList::FindNodeFromFIF(int node_id) { map::iterator i = m_plugin_map.find(node_id); - if (i != m_plugin_map.end()) + if (i != m_plugin_map.end()) { return (*i).second; + } return NULL; } @@ -187,8 +193,9 @@ PluginList::IsEmpty() const { PluginList::~PluginList() { for (map::iterator i = m_plugin_map.begin(); i != m_plugin_map.end(); ++i) { #ifdef _WIN32 - if ((*i).second->m_instance != NULL) + if ((*i).second->m_instance != NULL) { FreeLibrary((HINSTANCE)(*i).second->m_instance); + } #endif delete (*i).second->m_plugin; delete ((*i).second); @@ -211,6 +218,9 @@ FreeImage_GetPluginList() { void DLL_CALLCONV FreeImage_Initialise(BOOL load_local_plugins_only) { if (s_plugin_reference_count++ == 0) { + + // initialise the TagLib singleton + TagLib& s = TagLib::instance(); // internal plugin initialization @@ -246,7 +256,7 @@ FreeImage_Initialise(BOOL load_local_plugins_only) { //s_plugins->AddNode(InitXBM); //s_plugins->AddNode(InitXPM); //s_plugins->AddNode(InitDDS); - s_plugins->AddNode(InitGIF); + s_plugins->AddNode(InitGIF); //s_plugins->AddNode(InitHDR); //s_plugins->AddNode(InitG3); //s_plugins->AddNode(InitSGI); @@ -299,18 +309,14 @@ FreeImage_LoadFromHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handl PluginNode *node = s_plugins->FindNodeFromFIF(fif); if (node != NULL) { - if (node->m_enabled) { - if(node->m_plugin->load_proc != NULL) { - FIBITMAP *bitmap = NULL; + if(node->m_plugin->load_proc != NULL) { + void *data = FreeImage_Open(node, io, handle, TRUE); - void *data = FreeImage_Open(node, io, handle, TRUE); + FIBITMAP *bitmap = node->m_plugin->load_proc(io, handle, -1, flags, data); - bitmap = node->m_plugin->load_proc(io, handle, -1, flags, data); + FreeImage_Close(node, io, handle, data); - FreeImage_Close(node, io, handle, data); - - return bitmap; - } + return bitmap; } } } @@ -370,18 +376,14 @@ FreeImage_SaveToHandle(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, FreeImageIO *io, fi PluginNode *node = s_plugins->FindNodeFromFIF(fif); if (node) { - if (node->m_enabled) { - if(node->m_plugin->save_proc != NULL) { - BOOL result = FALSE; - - void *data = FreeImage_Open(node, io, handle, FALSE); + if(node->m_plugin->save_proc != NULL) { + void *data = FreeImage_Open(node, io, handle, FALSE); - result = node->m_plugin->save_proc(io, dib, handle, -1, flags, data); + BOOL result = node->m_plugin->save_proc(io, dib, handle, -1, flags, data); - FreeImage_Close(node, io, handle, data); + FreeImage_Close(node, io, handle, data); - return result; - } + return result; } } } @@ -503,7 +505,7 @@ FreeImage_GetFIFFromFormat(const char *format) { if (s_plugins != NULL) { PluginNode *node = s_plugins->FindNodeFromFormat(format); - return (node != NULL) ? (node->m_enabled) ? (FREE_IMAGE_FORMAT)node->m_id : FIF_UNKNOWN : FIF_UNKNOWN; + return (node != NULL) ? (FREE_IMAGE_FORMAT)node->m_id : FIF_UNKNOWN; } return FIF_UNKNOWN; @@ -514,7 +516,7 @@ FreeImage_GetFIFFromMime(const char *mime) { if (s_plugins != NULL) { PluginNode *node = s_plugins->FindNodeFromMime(mime); - return (node != NULL) ? (node->m_enabled) ? (FREE_IMAGE_FORMAT)node->m_id : FIF_UNKNOWN : FIF_UNKNOWN; + return (node != NULL) ? (FREE_IMAGE_FORMAT)node->m_id : FIF_UNKNOWN; } return FIF_UNKNOWN; @@ -712,7 +714,7 @@ FreeImage_GetFIFFromFilenameU(const wchar_t *filename) { // convert to single character - no national chars in extensions char *extension = (char *)malloc(wcslen(place)+1); unsigned int i=0; - for (; i < wcslen(place); i++) // convert 16-bit to 8-bit + for(; i < wcslen(place); i++) // convert 16-bit to 8-bit extension[i] = (char)(place[i] & 0x00FF); // set terminating 0 extension[i]=0; diff --git a/plugins/AdvaImg/src/FreeImage/PluginBMP.cpp b/plugins/AdvaImg/src/FreeImage/PluginBMP.cpp index d69336f3f5..4041d859fa 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginBMP.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginBMP.cpp @@ -213,7 +213,7 @@ LoadPixelDataRLE4(FreeImageIO *io, fi_handle handle, int width, int height, FIBI height = abs(height); pixels = (BYTE*)malloc(width * height * sizeof(BYTE)); - if (!pixels) throw(1); + if(!pixels) throw(1); memset(pixels, 0, width * height * sizeof(BYTE)); BYTE *q = pixels; @@ -313,7 +313,7 @@ LoadPixelDataRLE4(FreeImageIO *io, fi_handle handle, int width, int height, FIBI BOOL hinibble = TRUE; - for (int cols = 0; cols < width; cols++) { + for (int cols = 0; cols < width; cols++){ if (hinibble) { dst[cols >> 1] = (src[cols] << 4); } else { @@ -352,7 +352,7 @@ LoadPixelDataRLE8(FreeImageIO *io, fi_handle handle, int width, int height, FIBI int bits = 0; for (;;) { - if ( io->read_proc(&status_byte, sizeof(BYTE), 1, handle) != 1) { + if( io->read_proc(&status_byte, sizeof(BYTE), 1, handle) != 1) { return FALSE; } @@ -520,7 +520,7 @@ LoadWindowsBMP(FreeImageIO *io, fi_handle handle, int flags, unsigned bitmap_bit switch (compression) { case BI_RGB : - if ( LoadPixelData(io, handle, dib, height, pitch, bit_count)) { + if( LoadPixelData(io, handle, dib, height, pitch, bit_count) ) { return dib; } else { throw "Error encountered while decoding BMP data"; @@ -528,7 +528,7 @@ LoadWindowsBMP(FreeImageIO *io, fi_handle handle, int flags, unsigned bitmap_bit break; case BI_RLE4 : - if ( LoadPixelDataRLE4(io, handle, width, height, dib)) { + if( LoadPixelDataRLE4(io, handle, width, height, dib) ) { return dib; } else { throw "Error encountered while decoding RLE4 BMP data"; @@ -536,7 +536,7 @@ LoadWindowsBMP(FreeImageIO *io, fi_handle handle, int flags, unsigned bitmap_bit break; case BI_RLE8 : - if ( LoadPixelDataRLE8(io, handle, width, height, dib)) { + if( LoadPixelDataRLE8(io, handle, width, height, dib) ) { return dib; } else { throw "Error encountered while decoding RLE8 BMP data"; @@ -597,7 +597,7 @@ LoadWindowsBMP(FreeImageIO *io, fi_handle handle, int flags, unsigned bitmap_bit dib = FreeImage_AllocateHeader(header_only, width, height, bit_count, bitfields[0], bitfields[1], bitfields[2]); } else { - if ( bit_count == 32 ) { + if( bit_count == 32 ) { dib = FreeImage_AllocateHeader(header_only, width, height, bit_count, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); } else { dib = FreeImage_AllocateHeader(header_only, width, height, bit_count, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); @@ -747,7 +747,7 @@ LoadOS22XBMP(FreeImageIO *io, fi_handle handle, int flags, unsigned bitmap_bits_ return dib; case BI_RLE4 : - if ( LoadPixelDataRLE4(io, handle, width, height, dib)) { + if( LoadPixelDataRLE4(io, handle, width, height, dib) ) { return dib; } else { throw "Error encountered while decoding RLE4 BMP data"; @@ -755,7 +755,7 @@ LoadOS22XBMP(FreeImageIO *io, fi_handle handle, int flags, unsigned bitmap_bits_ break; case BI_RLE8 : - if ( LoadPixelDataRLE8(io, handle, width, height, dib)) { + if( LoadPixelDataRLE8(io, handle, width, height, dib) ) { return dib; } else { throw "Error encountered while decoding RLE8 BMP data"; @@ -805,7 +805,7 @@ LoadOS22XBMP(FreeImageIO *io, fi_handle handle, int flags, unsigned bitmap_bits_ case 24 : case 32 : { - if ( bit_count == 32 ) { + if( bit_count == 32 ) { dib = FreeImage_AllocateHeader(header_only, width, height, bit_count, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); } else { dib = FreeImage_AllocateHeader(header_only, width, height, bit_count, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); @@ -951,7 +951,7 @@ LoadOS21XBMP(FreeImageIO *io, fi_handle handle, int flags, unsigned bitmap_bits_ case 24 : case 32 : { - if ( bit_count == 32 ) { + if( bit_count == 32 ) { dib = FreeImage_AllocateHeader(header_only, width, height, bit_count, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); } else { dib = FreeImage_AllocateHeader(header_only, width, height, bit_count, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); @@ -1082,7 +1082,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { // check the signature - if ((bitmapfileheader.bfType != 0x4D42) && (bitmapfileheader.bfType != 0x4142)) { + if((bitmapfileheader.bfType != 0x4D42) && (bitmapfileheader.bfType != 0x4142)) { FreeImage_OutputMessageProc(s_format_id, FI_MSG_ERROR_MAGIC_NUMBER); return NULL; } diff --git a/plugins/AdvaImg/src/FreeImage/PluginCUT.cpp b/plugins/AdvaImg/src/FreeImage/PluginCUT.cpp index 746fa034a6..5dcd16b84f 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginCUT.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginCUT.cpp @@ -105,7 +105,7 @@ static FIBITMAP * DLL_CALLCONV Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { FIBITMAP *dib = NULL; - if (!handle) { + if(!handle) { return NULL; } diff --git a/plugins/AdvaImg/src/FreeImage/PluginDDS.cpp b/plugins/AdvaImg/src/FreeImage/PluginDDS.cpp index 0a1667d7f1..639942388f 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginDDS.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginDDS.cpp @@ -378,6 +378,10 @@ template void DecodeDXTBlock (BYTE *dstData, const BYTE *srcBloc decoder.SetY (y); for (int x = 0; x < bw; x++) { decoder.GetColor (x, y, (Color8888 &)*dst); + +#if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_RGB + INPLACESWAP(dst[FI_RGBA_RED], dst[FI_RGBA_BLUE]); +#endif dst += 4; } } @@ -444,7 +448,7 @@ LoadDXT_Helper (FreeImageIO *io, fi_handle handle, int page, int flags, void *da typedef typename INFO::Block Block; Block *input_buffer = new(std::nothrow) Block[(width + 3) / 4]; - if (!input_buffer) return; + if(!input_buffer) return; int widthRest = (int) width & 3; int heightRest = (int) height & 3; diff --git a/plugins/AdvaImg/src/FreeImage/PluginEXR.cpp b/plugins/AdvaImg/src/FreeImage/PluginEXR.cpp index b9963a11b2..4a19b8b56f 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginEXR.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginEXR.cpp @@ -96,7 +96,7 @@ C_IStream::seekg (Imf::Int64 pos) { void C_OStream::write (const char c[/*n*/], int n) { - if ((unsigned)n != _io->write_proc((void*)&c[0], 1, n, _handle)) { + if((unsigned)n != _io->write_proc((void*)&c[0], 1, n, _handle)) { Iex::throwErrnoExc(); } } @@ -178,7 +178,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { bool bUseRgbaInterface = false; FIBITMAP *dib = NULL; - if (!handle) { + if(!handle) { return NULL; } @@ -242,7 +242,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { bHandled = true; } } - if (!bHandled) { + if(!bHandled) { THROW (Iex::InputExc, "Unable to handle mixed component types (color model = " << exr_color_model << ")"); } } @@ -260,9 +260,9 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { // check for supported image color models // -------------------------------------------------------------- - if ((components == 1) || (components == 2)) { + if((components == 1) || (components == 2)) { // if the image is gray-alpha (YA), ignore the alpha channel - if ((components == 1) && channels.findChannel("Y")) { + if((components == 1) && channels.findChannel("Y")) { image_type = FIT_FLOAT; components = 1; } else { @@ -307,7 +307,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { // allocate a new dib dib = FreeImage_AllocateHeaderT(header_only, image_type, width, height, 0); - if (!dib) THROW (Iex::NullExc, FI_MSG_ERROR_MEMORY); + if(!dib) THROW (Iex::NullExc, FI_MSG_ERROR_MEMORY); // try to load the preview image // -------------------------------------------------------------- @@ -410,7 +410,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { pitch, // yStride 1, 1, // x/y sampling 0.0)); // fillValue - } else if ((components == 3) || (components == 4)) { + } else if((components == 3) || (components == 4)) { const char *channel_name[4] = { "R", "G", "B", "A" }; for(int c = 0; c < components; c++) { @@ -450,12 +450,12 @@ Set the preview image using the dib embedded thumbnail */ static BOOL SetPreviewImage(FIBITMAP *dib, Imf::Header& header) { - if (!FreeImage_GetThumbnail(dib)) { + if(!FreeImage_GetThumbnail(dib)) { return FALSE; } FIBITMAP* thumbnail = FreeImage_GetThumbnail(dib); - if ((FreeImage_GetImageType(thumbnail) != FIT_BITMAP) || (FreeImage_GetBPP(thumbnail) != 32)) { + if((FreeImage_GetImageType(thumbnail) != FIT_BITMAP) || (FreeImage_GetBPP(thumbnail) != 32)) { // invalid thumbnail - ignore it FreeImage_OutputMessageProc(s_format_id, FI_MSG_WARNING_INVALID_THUMBNAIL); } else { @@ -560,16 +560,16 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void BOOL bIsFlipped = FALSE; half *halfData = NULL; - if (!dib || !handle) return FALSE; + if(!dib || !handle) return FALSE; try { // check for EXR_LC compression and verify that the format is RGB - if ((flags & EXR_LC) == EXR_LC) { + if((flags & EXR_LC) == EXR_LC) { FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(dib); - if (((image_type != FIT_RGBF) && (image_type != FIT_RGBAF)) || ((flags & EXR_FLOAT) == EXR_FLOAT)) { + if(((image_type != FIT_RGBF) && (image_type != FIT_RGBAF)) || ((flags & EXR_FLOAT) == EXR_FLOAT)) { THROW (Iex::IoExc, "EXR_LC compression is only available with RGB[A]F images"); } - if ((FreeImage_GetWidth(dib) % 2) || (FreeImage_GetHeight(dib) % 2)) { + if((FreeImage_GetWidth(dib) % 2) || (FreeImage_GetHeight(dib) % 2)) { THROW (Iex::IoExc, "EXR_LC compression only works when the width and height are a multiple of 2"); } } @@ -579,19 +579,19 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void // compression Imf::Compression compress; - if ((flags & EXR_NONE) == EXR_NONE) { + if((flags & EXR_NONE) == EXR_NONE) { // no compression compress = Imf::NO_COMPRESSION; - } else if ((flags & EXR_ZIP) == EXR_ZIP) { + } else if((flags & EXR_ZIP) == EXR_ZIP) { // zlib compression, in blocks of 16 scan lines compress = Imf::ZIP_COMPRESSION; - } else if ((flags & EXR_PIZ) == EXR_PIZ) { + } else if((flags & EXR_PIZ) == EXR_PIZ) { // piz-based wavelet compression compress = Imf::PIZ_COMPRESSION; - } else if ((flags & EXR_PXR24) == EXR_PXR24) { + } else if((flags & EXR_PXR24) == EXR_PXR24) { // lossy 24-bit float compression compress = Imf::PXR24_COMPRESSION; - } else if ((flags & EXR_B44) == EXR_B44) { + } else if((flags & EXR_B44) == EXR_B44) { // lossy 44% float compression compress = Imf::B44_COMPRESSION; } else { @@ -615,13 +615,13 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void SetPreviewImage(dib, header); // check for EXR_LC compression - if ((flags & EXR_LC) == EXR_LC) { + if((flags & EXR_LC) == EXR_LC) { return SaveAsEXR_LC(ostream, dib, header, width, height); } // output pixel type Imf::PixelType pixelType; - if ((flags & EXR_FLOAT) == EXR_FLOAT) { + if((flags & EXR_FLOAT) == EXR_FLOAT) { pixelType = Imf::FLOAT; // save as float data type } else { // default value @@ -667,7 +667,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void if(pixelType == Imf::HALF) { // convert from float to half halfData = new(std::nothrow) half[width * height * components]; - if (!halfData) THROW (Iex::NullExc, FI_MSG_ERROR_MEMORY); + if(!halfData) THROW (Iex::NullExc, FI_MSG_ERROR_MEMORY); for(int y = 0; y < height; y++) { float *src_bits = (float*)FreeImage_GetScanLine(dib, height - 1 - y); @@ -700,7 +700,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void (char*)(bits), // base bytespp, // xStride pitch)); // yStride - } else if ((image_type == FIT_RGBF) || (image_type == FIT_RGBAF)) { + } else if((image_type == FIT_RGBF) || (image_type == FIT_RGBAF)) { for(int c = 0; c < components; c++) { char *channel_base = (char*)(bits) + c*bytespc; frameBuffer.insert (channel_name[c],// name diff --git a/plugins/AdvaImg/src/FreeImage/PluginG3.cpp b/plugins/AdvaImg/src/FreeImage/PluginG3.cpp index c383a455b7..d5c08b36e6 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginG3.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginG3.cpp @@ -124,7 +124,7 @@ copyFaxFile(FreeImageIO *io, fi_handle handle, TIFF* tifin, uint32 xsize, int st throw FI_MSG_ERROR_MEMORY; } - if (!G3ReadFile(io, handle, tifin->tif_rawdata, tifin->tif_rawdatasize)) { + if(!G3ReadFile(io, handle, tifin->tif_rawdata, tifin->tif_rawdatasize)) { throw "Read error at scanline 0"; } tifin->tif_rawcp = tifin->tif_rawdata; @@ -319,7 +319,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { // open a temporary memory buffer to save decoded scanlines memory = FreeImage_OpenMemory(); - if (!memory) throw FI_MSG_ERROR_MEMORY; + if(!memory) throw FI_MSG_ERROR_MEMORY; // wrap the raw fax file faxTIFF = TIFFClientOpen("(FakeInput)", "w", diff --git a/plugins/AdvaImg/src/FreeImage/PluginGIF.cpp b/plugins/AdvaImg/src/FreeImage/PluginGIF.cpp index 7af1d821d8..e8d84afac4 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginGIF.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginGIF.cpp @@ -167,8 +167,8 @@ FreeImage_SetMetadataEx(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, const char *key static BOOL FreeImage_GetMetadataEx(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, const char *key, FREE_IMAGE_MDTYPE type, FITAG **tag) { - if ( FreeImage_GetMetadata(model, dib, key, tag)) { - if ( FreeImage_GetTagType(*tag) == type ) { + if( FreeImage_GetMetadata(model, dib, key, tag) ) { + if( FreeImage_GetTagType(*tag) == type ) { return TRUE; } } @@ -187,10 +187,10 @@ StringTable::StringTable() StringTable::~StringTable() { - if ( m_buffer != NULL ) { + if( m_buffer != NULL ) { delete [] m_buffer; } - if ( m_strmap != NULL ) { + if( m_strmap != NULL ) { delete [] m_strmap; m_strmap = NULL; } @@ -218,10 +218,10 @@ void StringTable::Initialize(int minCodeSize) BYTE *StringTable::FillInputBuffer(int len) { - if ( m_buffer == NULL ) { + if( m_buffer == NULL ) { m_buffer = new(std::nothrow) BYTE[len]; m_bufferRealSize = len; - } else if ( len > m_bufferRealSize ) { + } else if( len > m_bufferRealSize ) { delete [] m_buffer; m_buffer = new(std::nothrow) BYTE[len]; m_bufferRealSize = len; @@ -273,7 +273,7 @@ int StringTable::CompressEnd(BYTE *buf) bool StringTable::Compress(BYTE *buf, int *len) { - if ( m_bufferSize == 0 || m_done ) { + if( m_bufferSize == 0 || m_done ) { return false; } @@ -288,7 +288,7 @@ bool StringTable::Compress(BYTE *buf, int *len) int nextprefix = (((m_prefix)<<8)&0xFFF00) + (ch & 0x000FF); if(firstPixelPassed) { - if ( m_strmap[nextprefix] > 0) { + if( m_strmap[nextprefix] > 0) { m_prefix = m_strmap[nextprefix]; } else { m_partial |= m_prefix << m_partialSize; @@ -304,13 +304,13 @@ bool StringTable::Compress(BYTE *buf, int *len) m_strmap[nextprefix] = m_nextCode; //increment the next highest valid code, increase the code size - if ( m_nextCode == (1 << m_codeSize)) { + if( m_nextCode == (1 << m_codeSize) ) { m_codeSize++; } m_nextCode++; //if we're out of codes, restart the string table - if ( m_nextCode == MAX_LZW_CODE ) { + if( m_nextCode == MAX_LZW_CODE ) { m_partial |= m_clearCode << m_partialSize; m_partialSize += m_codeSize; ClearCompressorTable(); @@ -321,7 +321,7 @@ bool StringTable::Compress(BYTE *buf, int *len) } //increment to the next pixel - if ( m_bufferShift > 0 && !(m_bufferPos + 1 == m_bufferSize && m_bufferShift <= m_slack)) { + if( m_bufferShift > 0 && !(m_bufferPos + 1 == m_bufferSize && m_bufferShift <= m_slack) ) { m_bufferShift -= m_bpp; } else { m_bufferPos++; @@ -329,7 +329,7 @@ bool StringTable::Compress(BYTE *buf, int *len) } //jump out here if the output buffer is full - if ( bufpos - buf == *len ) { + if( bufpos - buf == *len ) { return true; } @@ -341,7 +341,7 @@ bool StringTable::Compress(BYTE *buf, int *len) m_prefix = ch & 0x000FF; //increment to the next pixel - if ( m_bufferShift > 0 && !(m_bufferPos + 1 == m_bufferSize && m_bufferShift <= m_slack)) { + if( m_bufferShift > 0 && !(m_bufferPos + 1 == m_bufferSize && m_bufferShift <= m_slack) ) { m_bufferShift -= m_bpp; } else { m_bufferPos++; @@ -349,7 +349,7 @@ bool StringTable::Compress(BYTE *buf, int *len) } //jump out here if the output buffer is full - if ( bufpos - buf == *len ) { + if( bufpos - buf == *len ) { return true; } } @@ -363,12 +363,12 @@ bool StringTable::Compress(BYTE *buf, int *len) bool StringTable::Decompress(BYTE *buf, int *len) { - if ( m_bufferSize == 0 || m_done ) { + if( m_bufferSize == 0 || m_done ) { return false; } BYTE *bufpos = buf; - for ( ; m_bufferPos < m_bufferSize; m_bufferPos++ ) { + for( ; m_bufferPos < m_bufferSize; m_bufferPos++ ) { m_partial |= (int)m_buffer[m_bufferPos] << m_partialSize; m_partialSize += 8; while( m_partialSize >= m_codeSize ) { @@ -376,22 +376,22 @@ bool StringTable::Decompress(BYTE *buf, int *len) m_partial >>= m_codeSize; m_partialSize -= m_codeSize; - if ( code > m_nextCode || (m_nextCode == MAX_LZW_CODE && code != m_clearCode) || code == m_endCode ) { + if( code > m_nextCode || (m_nextCode == MAX_LZW_CODE && code != m_clearCode) || code == m_endCode ) { m_done = true; *len = (int)(bufpos - buf); return true; } - if ( code == m_clearCode ) { + if( code == m_clearCode ) { ClearDecompressorTable(); continue; } //add new string to string table, if not the first pass since a clear code - if ( m_oldCode != MAX_LZW_CODE ) { + if( m_oldCode != MAX_LZW_CODE ) { m_strings[m_nextCode] = m_strings[m_oldCode] + m_strings[code == m_nextCode ? m_oldCode : code][0]; } - if ( (int)m_strings[code].size() > *len - (bufpos - buf)) { + if( (int)m_strings[code].size() > *len - (bufpos - buf) ) { //out of space, stuff the code back in for next time m_partial <<= m_codeSize; m_partialSize += m_codeSize; @@ -406,9 +406,9 @@ bool StringTable::Decompress(BYTE *buf, int *len) bufpos += m_strings[code].size(); //increment the next highest valid code, add a bit to the mask if we need to increase the code size - if ( m_oldCode != MAX_LZW_CODE && m_nextCode < MAX_LZW_CODE ) { - if ( ++m_nextCode < MAX_LZW_CODE ) { - if ( (m_nextCode & m_codeMask) == 0 ) { + if( m_oldCode != MAX_LZW_CODE && m_nextCode < MAX_LZW_CODE ) { + if( ++m_nextCode < MAX_LZW_CODE ) { + if( (m_nextCode & m_codeMask) == 0 ) { m_codeSize++; m_codeMask |= m_nextCode; } @@ -443,7 +443,7 @@ void StringTable::ClearCompressorTable(void) void StringTable::ClearDecompressorTable(void) { - for ( int i = 0; i < m_clearCode; i++ ) { + for( int i = 0; i < m_clearCode; i++ ) { m_strings[i].resize(1); m_strings[i][0] = (char)i; } @@ -492,13 +492,13 @@ MimeType() { static BOOL DLL_CALLCONV Validate(FreeImageIO *io, fi_handle handle) { char buf[6]; - if ( io->read_proc(buf, 6, 1, handle) < 1 ) { + if( io->read_proc(buf, 6, 1, handle) < 1 ) { return FALSE; } BOOL bResult = FALSE; - if ( !strncmp(buf, "GIF", 3)) { - if ( buf[3] >= '0' && buf[3] <= '9' && buf[4] >= '0' && buf[4] <= '9' && buf[5] >= 'a' && buf[5] <= 'z' ) { + if( !strncmp(buf, "GIF", 3) ) { + if( buf[3] >= '0' && buf[3] <= '9' && buf[4] >= '0' && buf[4] <= '9' && buf[5] >= 'a' && buf[5] <= 'z' ) { bResult = TRUE; } } @@ -525,7 +525,7 @@ SupportsExportType(FREE_IMAGE_TYPE type) { static void *DLL_CALLCONV Open(FreeImageIO *io, fi_handle handle, BOOL read) { GIFinfo *info = new(std::nothrow) GIFinfo; - if ( info == NULL ) { + if( info == NULL ) { return NULL; } @@ -534,10 +534,10 @@ Open(FreeImageIO *io, fi_handle handle, BOOL read) { // memset(info, 0, sizeof(GIFinfo)); info->read = read; - if ( read ) { + if( read ) { try { //Header - if ( !Validate(io, handle)) { + if( !Validate(io, handle) ) { throw FI_MSG_ERROR_MAGIC_NUMBER; } io->seek_proc(handle, 6, SEEK_CUR); @@ -545,16 +545,16 @@ Open(FreeImageIO *io, fi_handle handle, BOOL read) { //Logical Screen Descriptor io->seek_proc(handle, 4, SEEK_CUR); BYTE packed; - if ( io->read_proc(&packed, 1, 1, handle) < 1 ) { + if( io->read_proc(&packed, 1, 1, handle) < 1 ) { throw "EOF reading Logical Screen Descriptor"; } - if ( io->read_proc(&info->background_color, 1, 1, handle) < 1 ) { + if( io->read_proc(&info->background_color, 1, 1, handle) < 1 ) { throw "EOF reading Logical Screen Descriptor"; } io->seek_proc(handle, 1, SEEK_CUR); //Global Color Table - if ( packed & GIF_PACKED_LSD_HAVEGCT ) { + if( packed & GIF_PACKED_LSD_HAVEGCT ) { info->global_color_table_offset = io->tell_proc(handle); info->global_color_table_size = 2 << (packed & GIF_PACKED_LSD_GCTSIZE); io->seek_proc(handle, 3 * info->global_color_table_size, SEEK_CUR); @@ -564,42 +564,42 @@ Open(FreeImageIO *io, fi_handle handle, BOOL read) { size_t gce_offset = 0; BYTE block = 0; while( block != GIF_BLOCK_TRAILER ) { - if ( io->read_proc(&block, 1, 1, handle) < 1 ) { + if( io->read_proc(&block, 1, 1, handle) < 1 ) { throw "EOF reading blocks"; } - if ( block == GIF_BLOCK_IMAGE_DESCRIPTOR ) { + if( block == GIF_BLOCK_IMAGE_DESCRIPTOR ) { info->image_descriptor_offsets.push_back(io->tell_proc(handle)); //GCE may be 0, meaning no GCE preceded this ID info->graphic_control_extension_offsets.push_back(gce_offset); gce_offset = 0; io->seek_proc(handle, 8, SEEK_CUR); - if ( io->read_proc(&packed, 1, 1, handle) < 1 ) { + if( io->read_proc(&packed, 1, 1, handle) < 1 ) { throw "EOF reading Image Descriptor"; } //Local Color Table - if ( packed & GIF_PACKED_ID_HAVELCT ) { + if( packed & GIF_PACKED_ID_HAVELCT ) { io->seek_proc(handle, 3 * (2 << (packed & GIF_PACKED_ID_LCTSIZE)), SEEK_CUR); } //LZW Minimum Code Size io->seek_proc(handle, 1, SEEK_CUR); - } else if ( block == GIF_BLOCK_EXTENSION ) { + } else if( block == GIF_BLOCK_EXTENSION ) { BYTE ext; - if ( io->read_proc(&ext, 1, 1, handle) < 1 ) { + if( io->read_proc(&ext, 1, 1, handle) < 1 ) { throw "EOF reading extension"; } - if ( ext == GIF_EXT_GRAPHIC_CONTROL ) { + if( ext == GIF_EXT_GRAPHIC_CONTROL ) { //overwrite previous offset if more than one GCE found before an ID gce_offset = io->tell_proc(handle); - } else if ( ext == GIF_EXT_COMMENT ) { + } else if( ext == GIF_EXT_COMMENT ) { info->comment_extension_offsets.push_back(io->tell_proc(handle)); - } else if ( ext == GIF_EXT_APPLICATION ) { + } else if( ext == GIF_EXT_APPLICATION ) { info->application_extension_offsets.push_back(io->tell_proc(handle)); } - } else if ( block == GIF_BLOCK_TRAILER ) { + } else if( block == GIF_BLOCK_TRAILER ) { continue; } else { throw "Invalid GIF block found"; @@ -607,12 +607,12 @@ Open(FreeImageIO *io, fi_handle handle, BOOL read) { //Data Sub-blocks BYTE len; - if ( io->read_proc(&len, 1, 1, handle) < 1 ) { + if( io->read_proc(&len, 1, 1, handle) < 1 ) { throw "EOF reading sub-block"; } while( len != 0 ) { io->seek_proc(handle, len, SEEK_CUR); - if ( io->read_proc(&len, 1, 1, handle) < 1 ) { + if( io->read_proc(&len, 1, 1, handle) < 1 ) { throw "EOF reading sub-block"; } } @@ -632,12 +632,12 @@ Open(FreeImageIO *io, fi_handle handle, BOOL read) { static void DLL_CALLCONV Close(FreeImageIO *io, fi_handle handle, void *data) { - if ( data == NULL ) { + if( data == NULL ) { return; } GIFinfo *info = (GIFinfo *)data; - if ( !info->read ) { + if( !info->read ) { //Trailer BYTE b = GIF_BLOCK_TRAILER; io->write_proc(&b, 1, 1, handle); @@ -648,7 +648,7 @@ Close(FreeImageIO *io, fi_handle handle, void *data) { static int DLL_CALLCONV PageCount(FreeImageIO *io, fi_handle handle, void *data) { - if ( data == NULL ) { + if( data == NULL ) { return 0; } GIFinfo *info = (GIFinfo *)data; @@ -658,15 +658,15 @@ PageCount(FreeImageIO *io, fi_handle handle, void *data) { static FIBITMAP * DLL_CALLCONV Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { - if ( data == NULL ) { + if( data == NULL ) { return NULL; } GIFinfo *info = (GIFinfo *)data; - if ( page == -1 ) { + if( page == -1 ) { page = 0; } - if ( page < 0 || page >= (int)info->image_descriptor_offsets.size()) { + if( page < 0 || page >= (int)info->image_descriptor_offsets.size() ) { return NULL; } @@ -679,7 +679,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { WORD w; //playback pages to generate what the user would see for this frame - if ( (flags & GIF_PLAYBACK) == GIF_PLAYBACK ) { + if( (flags & GIF_PLAYBACK) == GIF_PLAYBACK ) { //Logical Screen Descriptor io->seek_proc(handle, 6, SEEK_SET); WORD logicalwidth, logicalheight; @@ -691,7 +691,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { #endif //set the background color with 0 alpha RGBQUAD background; - if ( info->global_color_table_offset != 0 && info->background_color < info->global_color_table_size ) { + if( info->global_color_table_offset != 0 && info->background_color < info->global_color_table_size ) { io->seek_proc(handle, (long)(info->global_color_table_offset + (info->background_color * 3)), SEEK_SET); io->read_proc(&background.rgbRed, 1, 1, handle); io->read_proc(&background.rgbGreen, 1, 1, handle); @@ -705,16 +705,16 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { //allocate entire logical area dib = FreeImage_Allocate(logicalwidth, logicalheight, 32); - if ( dib == NULL ) { + if( dib == NULL ) { throw FI_MSG_ERROR_DIB_MEMORY; } //fill with background color to start int x, y; RGBQUAD *scanline; - for ( y = 0; y < logicalheight; y++ ) { + for( y = 0; y < logicalheight; y++ ) { scanline = (RGBQUAD *)FreeImage_GetScanLine(dib, y); - for ( x = 0; x < logicalwidth; x++ ) { + for( x = 0; x < logicalwidth; x++ ) { *scanline++ = background; } } @@ -743,14 +743,14 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { pageinfo.push_back(PageInfo(disposal_method, left, top, width, height)); - if ( start != end ) { - if ( left == 0 && top == 0 && width == logicalwidth && height == logicalheight ) { - if ( disposal_method == GIF_DISPOSAL_BACKGROUND ) { + if( start != end ) { + if( left == 0 && top == 0 && width == logicalwidth && height == logicalheight ) { + if( disposal_method == GIF_DISPOSAL_BACKGROUND ) { pageinfo.pop_back(); start++; break; - } else if ( disposal_method != GIF_DISPOSAL_PREVIOUS ) { - if ( !have_transparent ) { + } else if( disposal_method != GIF_DISPOSAL_PREVIOUS ) { + if( !have_transparent ) { break; } } @@ -758,23 +758,23 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { } start--; } - if ( start < 0 ) { + if( start < 0 ) { start = 0; } //draw each page into the logical area delay_time = 0; - for ( page = start; page <= end; page++ ) { + for( page = start; page <= end; page++ ) { PageInfo &info = pageinfo[end - page]; //things we can skip having to decode - if ( page != end ) { - if ( info.disposal_method == GIF_DISPOSAL_PREVIOUS ) { + if( page != end ) { + if( info.disposal_method == GIF_DISPOSAL_PREVIOUS ) { continue; } - if ( info.disposal_method == GIF_DISPOSAL_BACKGROUND ) { - for ( y = 0; y < info.height; y++ ) { + if( info.disposal_method == GIF_DISPOSAL_BACKGROUND ) { + for( y = 0; y < info.height; y++ ) { scanline = (RGBQUAD *)FreeImage_GetScanLine(dib, logicalheight - (y + info.top) - 1) + info.left; - for ( x = 0; x < info.width; x++ ) { + for( x = 0; x < info.width; x++ ) { *scanline++ = background; } } @@ -784,14 +784,14 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { //decode page FIBITMAP *pagedib = Load(io, handle, page, GIF_LOAD256, data); - if ( pagedib != NULL ) { + if( pagedib != NULL ) { RGBQUAD *pal = FreeImage_GetPalette(pagedib); have_transparent = false; - if ( FreeImage_IsTransparent(pagedib)) { + if( FreeImage_IsTransparent(pagedib) ) { int count = FreeImage_GetTransparencyCount(pagedib); BYTE *table = FreeImage_GetTransparencyTable(pagedib); - for ( int i = 0; i < count; i++ ) { - if ( table[i] == 0 ) { + for( int i = 0; i < count; i++ ) { + if( table[i] == 0 ) { have_transparent = true; transparent_color = i; break; @@ -799,11 +799,11 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { } } //copy page data into logical buffer, with full alpha opaqueness - for ( y = 0; y < info.height; y++ ) { + for( y = 0; y < info.height; y++ ) { scanline = (RGBQUAD *)FreeImage_GetScanLine(dib, logicalheight - (y + info.top) - 1) + info.left; BYTE *pageline = FreeImage_GetScanLine(pagedib, info.height - y - 1); - for ( x = 0; x < info.width; x++ ) { - if ( !have_transparent || *pageline != transparent_color ) { + for( x = 0; x < info.width; x++ ) { + if( !have_transparent || *pageline != transparent_color ) { *scanline = pal[*pageline]; scanline->rgbReserved = 255; } @@ -812,9 +812,9 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { } } //copy frame time - if ( page == end ) { + if( page == end ) { FITAG *tag; - if ( FreeImage_GetMetadataEx(FIMD_ANIMATION, pagedib, "FrameTime", FIDT_LONG, &tag)) { + if( FreeImage_GetMetadataEx(FIMD_ANIMATION, pagedib, "FrameTime", FIDT_LONG, &tag) ) { delay_time = *(LONG *)FreeImage_GetTagValue(tag); } } @@ -846,18 +846,18 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { no_local_palette = (packed & GIF_PACKED_ID_HAVELCT) ? false : true; int bpp = 8; - if ( (flags & GIF_LOAD256) == 0 ) { - if ( !no_local_palette ) { + if( (flags & GIF_LOAD256) == 0 ) { + if( !no_local_palette ) { int size = 2 << (packed & GIF_PACKED_ID_LCTSIZE); - if ( size <= 2 ) bpp = 1; - else if ( size <= 16 ) bpp = 4; - } else if ( info->global_color_table_offset != 0 ) { - if ( info->global_color_table_size <= 2 ) bpp = 1; - else if ( info->global_color_table_size <= 16 ) bpp = 4; + if( size <= 2 ) bpp = 1; + else if( size <= 16 ) bpp = 4; + } else if( info->global_color_table_offset != 0 ) { + if( info->global_color_table_size <= 2 ) bpp = 1; + else if( info->global_color_table_size <= 16 ) bpp = 4; } } dib = FreeImage_Allocate(width, height, bpp); - if ( dib == NULL ) { + if( dib == NULL ) { throw FI_MSG_ERROR_DIB_MEMORY; } @@ -870,7 +870,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { //Palette RGBQUAD *pal = FreeImage_GetPalette(dib); - if ( !no_local_palette ) { + if( !no_local_palette ) { int size = 2 << (packed & GIF_PACKED_ID_LCTSIZE); int i = 0; @@ -880,7 +880,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { io->read_proc(&pal[i].rgbBlue, 1, 1, handle); i++; } - } else if ( info->global_color_table_offset != 0 ) { + } else if( info->global_color_table_offset != 0 ) { long pos = io->tell_proc(handle); io->seek_proc(handle, (long)info->global_color_table_offset, SEEK_SET); @@ -895,7 +895,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { io->seek_proc(handle, pos, SEEK_SET); } else { //its legal to have no palette, but we're going to generate *something* - for ( int i = 0; i < 256; i++ ) { + for( int i = 0; i < 256; i++ ) { pal[i].rgbRed = (BYTE)i; pal[i].rgbGreen = (BYTE)i; pal[i].rgbBlue = (BYTE)i; @@ -915,25 +915,25 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { while( b ) { io->read_proc(stringtable->FillInputBuffer(b), b, 1, handle); int size = sizeof(buf); - while( stringtable->Decompress(buf, &size)) { - for ( int i = 0; i < size; i++ ) { + while( stringtable->Decompress(buf, &size) ) { + for( int i = 0; i < size; i++ ) { scanline[xpos] |= (buf[i] & mask) << shift; - if ( shift > 0 ) { + if( shift > 0 ) { shift -= bpp; } else { xpos++; shift = 8 - bpp; } - if ( ++x >= width ) { - if ( interlaced ) { + if( ++x >= width ) { + if( interlaced ) { y += g_GifInterlaceIncrement[interlacepass]; - if ( y >= height && ++interlacepass < GIF_INTERLACE_PASSES ) { + if( y >= height && ++interlacepass < GIF_INTERLACE_PASSES ) { y = g_GifInterlaceOffset[interlacepass]; } } else { y++; } - if ( y >= height ) { + if( y >= height ) { stringtable->Done(); break; } @@ -947,7 +947,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { io->read_proc(&b, 1, 1, handle); } - if ( page == 0 ) { + if( page == 0 ) { size_t idx; //Logical Screen Descriptor @@ -963,7 +963,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { FreeImage_SetMetadataEx(FIMD_ANIMATION, dib, "LogicalHeight", ANIMTAG_LOGICALHEIGHT, FIDT_SHORT, 1, 2, &logicalheight); //Global Color Table - if ( info->global_color_table_offset != 0 ) { + if( info->global_color_table_offset != 0 ) { RGBQUAD globalpalette[256]; io->seek_proc(handle, (long)info->global_color_table_offset, SEEK_SET); int i = 0; @@ -976,29 +976,29 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { } FreeImage_SetMetadataEx(FIMD_ANIMATION, dib, "GlobalPalette", ANIMTAG_GLOBALPALETTE, FIDT_PALETTE, info->global_color_table_size, info->global_color_table_size * 4, globalpalette); //background color - if ( info->background_color < info->global_color_table_size ) { + if( info->background_color < info->global_color_table_size ) { FreeImage_SetBackgroundColor(dib, &globalpalette[info->background_color]); } } //Application Extension LONG loop = 1; //If no AE with a loop count is found, the default must be 1 - for ( idx = 0; idx < info->application_extension_offsets.size(); idx++ ) { + for( idx = 0; idx < info->application_extension_offsets.size(); idx++ ) { io->seek_proc(handle, (long)info->application_extension_offsets[idx], SEEK_SET); io->read_proc(&b, 1, 1, handle); - if ( b == 11 ) { //All AEs start with an 11 byte sub-block to determine what type of AE it is + if( b == 11 ) { //All AEs start with an 11 byte sub-block to determine what type of AE it is char buf[11]; io->read_proc(buf, 11, 1, handle); - if ( !memcmp(buf, "NETSCAPE2.0", 11) || !memcmp(buf, "ANIMEXTS1.0", 11)) { //Not everybody recognizes ANIMEXTS1.0 but it is valid + if( !memcmp(buf, "NETSCAPE2.0", 11) || !memcmp(buf, "ANIMEXTS1.0", 11) ) { //Not everybody recognizes ANIMEXTS1.0 but it is valid io->read_proc(&b, 1, 1, handle); - if ( b == 3 ) { //we're supposed to have a 3 byte sub-block now + if( b == 3 ) { //we're supposed to have a 3 byte sub-block now io->read_proc(&b, 1, 1, handle); //this should be 0x01 but isn't really important io->read_proc(&w, 2, 1, handle); #ifdef FREEIMAGE_BIGENDIAN SwapShort(&w); #endif loop = w; - if ( loop > 0 ) loop++; + if( loop > 0 ) loop++; break; } } @@ -1007,7 +1007,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { FreeImage_SetMetadataEx(FIMD_ANIMATION, dib, "Loop", ANIMTAG_LOOP, FIDT_LONG, 1, 4, &loop); //Comment Extension - for ( idx = 0; idx < info->comment_extension_offsets.size(); idx++ ) { + for( idx = 0; idx < info->comment_extension_offsets.size(); idx++ ) { io->seek_proc(handle, (long)info->comment_extension_offsets[idx], SEEK_SET); std::string comment; char buf[255]; @@ -1025,7 +1025,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { } //Graphic Control Extension - if ( info->graphic_control_extension_offsets[page] != 0 ) { + if( info->graphic_control_extension_offsets[page] != 0 ) { io->seek_proc(handle, (long)(info->graphic_control_extension_offsets[page] + 1), SEEK_SET); io->read_proc(&packed, 1, 1, handle); io->read_proc(&w, 2, 1, handle); @@ -1037,9 +1037,9 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { disposal_method = (packed & GIF_PACKED_GCE_DISPOSAL) >> 2; delay_time = w * 10; //convert cs to ms transparent_color = b; - if ( have_transparent ) { + if( have_transparent ) { int size = 1 << bpp; - if ( transparent_color <= size ) { + if( transparent_color <= size ) { BYTE table[256]; memset(table, 0xFF, size); table[transparent_color] = 0; @@ -1054,7 +1054,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { delete stringtable; } catch (const char *msg) { - if ( dib != NULL ) { + if( dib != NULL ) { FreeImage_Unload(dib); } FreeImage_OutputMessageProc(s_format_id, msg); @@ -1066,12 +1066,12 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { static BOOL DLL_CALLCONV Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data) { - if ( data == NULL ) { + if( data == NULL ) { return FALSE; } //GIFinfo *info = (GIFinfo *)data; - if ( page == -1 ) { + if( page == -1 ) { page = 0; } @@ -1081,7 +1081,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void FITAG *tag; int bpp = FreeImage_GetBPP(dib); - if ( bpp != 1 && bpp != 4 && bpp != 8 ) { + if( bpp != 1 && bpp != 4 && bpp != 8 ) { throw "Only 1, 4, or 8 bpp images supported"; } @@ -1089,22 +1089,22 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void int disposal_method = GIF_DISPOSAL_BACKGROUND, delay_time = 100, transparent_color = 0; WORD left = 0, top = 0, width = (WORD)FreeImage_GetWidth(dib), height = (WORD)FreeImage_GetHeight(dib); WORD output_height = height; - if ( FreeImage_GetMetadataEx(FIMD_ANIMATION, dib, "FrameLeft", FIDT_SHORT, &tag)) { + if( FreeImage_GetMetadataEx(FIMD_ANIMATION, dib, "FrameLeft", FIDT_SHORT, &tag) ) { left = *(WORD *)FreeImage_GetTagValue(tag); } - if ( FreeImage_GetMetadataEx(FIMD_ANIMATION, dib, "FrameTop", FIDT_SHORT, &tag)) { + if( FreeImage_GetMetadataEx(FIMD_ANIMATION, dib, "FrameTop", FIDT_SHORT, &tag) ) { top = *(WORD *)FreeImage_GetTagValue(tag); } - if ( FreeImage_GetMetadataEx(FIMD_ANIMATION, dib, "NoLocalPalette", FIDT_BYTE, &tag)) { + if( FreeImage_GetMetadataEx(FIMD_ANIMATION, dib, "NoLocalPalette", FIDT_BYTE, &tag) ) { no_local_palette = *(BYTE *)FreeImage_GetTagValue(tag) ? true : false; } - if ( FreeImage_GetMetadataEx(FIMD_ANIMATION, dib, "Interlaced", FIDT_BYTE, &tag)) { + if( FreeImage_GetMetadataEx(FIMD_ANIMATION, dib, "Interlaced", FIDT_BYTE, &tag) ) { interlaced = *(BYTE *)FreeImage_GetTagValue(tag) ? true : false; } - if ( FreeImage_GetMetadataEx(FIMD_ANIMATION, dib, "FrameTime", FIDT_LONG, &tag)) { + if( FreeImage_GetMetadataEx(FIMD_ANIMATION, dib, "FrameTime", FIDT_LONG, &tag) ) { delay_time = *(LONG *)FreeImage_GetTagValue(tag); } - if ( FreeImage_GetMetadataEx(FIMD_ANIMATION, dib, "DisposalMethod", FIDT_BYTE, &tag)) { + if( FreeImage_GetMetadataEx(FIMD_ANIMATION, dib, "DisposalMethod", FIDT_BYTE, &tag) ) { disposal_method = *(BYTE *)FreeImage_GetTagValue(tag); } @@ -1116,17 +1116,17 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void SwapShort(&height); #endif - if ( page == 0 ) { + if( page == 0 ) { //gather some info WORD logicalwidth = width; // width has already been swapped... - if ( FreeImage_GetMetadataEx(FIMD_ANIMATION, dib, "LogicalWidth", FIDT_SHORT, &tag)) { + if( FreeImage_GetMetadataEx(FIMD_ANIMATION, dib, "LogicalWidth", FIDT_SHORT, &tag) ) { logicalwidth = *(WORD *)FreeImage_GetTagValue(tag); #ifdef FREEIMAGE_BIGENDIAN SwapShort(&logicalwidth); #endif } WORD logicalheight = height; // height has already been swapped... - if ( FreeImage_GetMetadataEx(FIMD_ANIMATION, dib, "LogicalHeight", FIDT_SHORT, &tag)) { + if( FreeImage_GetMetadataEx(FIMD_ANIMATION, dib, "LogicalHeight", FIDT_SHORT, &tag) ) { logicalheight = *(WORD *)FreeImage_GetTagValue(tag); #ifdef FREEIMAGE_BIGENDIAN SwapShort(&logicalheight); @@ -1134,9 +1134,9 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void } RGBQUAD *globalpalette = NULL; int globalpalette_size = 0; - if ( FreeImage_GetMetadataEx(FIMD_ANIMATION, dib, "GlobalPalette", FIDT_PALETTE, &tag)) { + if( FreeImage_GetMetadataEx(FIMD_ANIMATION, dib, "GlobalPalette", FIDT_PALETTE, &tag) ) { globalpalette_size = FreeImage_GetTagCount(tag); - if ( globalpalette_size >= 2 ) { + if( globalpalette_size >= 2 ) { globalpalette = (RGBQUAD *)FreeImage_GetTagValue(tag); } } @@ -1147,36 +1147,36 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void packed = GIF_PACKED_LSD_COLORRES; b = 0; RGBQUAD background_color; - if ( globalpalette != NULL ) { + if( globalpalette != NULL ) { packed |= GIF_PACKED_LSD_HAVEGCT; - if ( globalpalette_size < 4 ) { + if( globalpalette_size < 4 ) { globalpalette_size = 2; packed |= 0 & GIF_PACKED_LSD_GCTSIZE; - } else if ( globalpalette_size < 8 ) { + } else if( globalpalette_size < 8 ) { globalpalette_size = 4; packed |= 1 & GIF_PACKED_LSD_GCTSIZE; - } else if ( globalpalette_size < 16 ) { + } else if( globalpalette_size < 16 ) { globalpalette_size = 8; packed |= 2 & GIF_PACKED_LSD_GCTSIZE; - } else if ( globalpalette_size < 32 ) { + } else if( globalpalette_size < 32 ) { globalpalette_size = 16; packed |= 3 & GIF_PACKED_LSD_GCTSIZE; - } else if ( globalpalette_size < 64 ) { + } else if( globalpalette_size < 64 ) { globalpalette_size = 32; packed |= 4 & GIF_PACKED_LSD_GCTSIZE; - } else if ( globalpalette_size < 128 ) { + } else if( globalpalette_size < 128 ) { globalpalette_size = 64; packed |= 5 & GIF_PACKED_LSD_GCTSIZE; - } else if ( globalpalette_size < 256 ) { + } else if( globalpalette_size < 256 ) { globalpalette_size = 128; packed |= 6 & GIF_PACKED_LSD_GCTSIZE; } else { globalpalette_size = 256; packed |= 7 & GIF_PACKED_LSD_GCTSIZE; } - if ( FreeImage_GetBackgroundColor(dib, &background_color)) { - for ( int i = 0; i < globalpalette_size; i++ ) { - if ( background_color.rgbRed == globalpalette[i].rgbRed && + if( FreeImage_GetBackgroundColor(dib, &background_color) ) { + for( int i = 0; i < globalpalette_size; i++ ) { + if( background_color.rgbRed == globalpalette[i].rgbRed && background_color.rgbGreen == globalpalette[i].rgbGreen && background_color.rgbBlue == globalpalette[i].rgbBlue ) { @@ -1194,7 +1194,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void io->write_proc(&b, 1, 1, handle); //Global Color Table - if ( globalpalette != NULL ) { + if( globalpalette != NULL ) { int i = 0; while( i < globalpalette_size ) { io->write_proc(&globalpalette[i].rgbRed, 1, 1, handle); @@ -1206,13 +1206,13 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void //Application Extension LONG loop = 0; - if ( FreeImage_GetMetadataEx(FIMD_ANIMATION, dib, "Loop", FIDT_LONG, &tag)) { + if( FreeImage_GetMetadataEx(FIMD_ANIMATION, dib, "Loop", FIDT_LONG, &tag) ) { loop = *(LONG *)FreeImage_GetTagValue(tag); } - if ( loop != 1 ) { + if( loop != 1 ) { //the Netscape extension is really "repeats" not "loops" - if ( loop > 1 ) loop--; - if ( loop > 0xFFFF ) loop = 0xFFFF; + if( loop > 1 ) loop--; + if( loop > 0xFFFF ) loop = 0xFFFF; w = (WORD)loop; #ifdef FREEIMAGE_BIGENDIAN SwapShort(&w); @@ -1227,9 +1227,9 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void FIMETADATA *mdhandle = NULL; FITAG *tag = NULL; mdhandle = FreeImage_FindFirstMetadata(FIMD_COMMENTS, dib, &tag); - if ( mdhandle ) { + if( mdhandle ) { do { - if ( FreeImage_GetTagType(tag) == FIDT_ASCII ) { + if( FreeImage_GetTagType(tag) == FIDT_ASCII ) { int length = FreeImage_GetTagLength(tag) - 1; char *value = (char *)FreeImage_GetTagValue(tag); io->write_proc((void *)"\x21\xFE", 2, 1, handle); @@ -1250,11 +1250,11 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void } //Graphic Control Extension - if ( FreeImage_IsTransparent(dib)) { + if( FreeImage_IsTransparent(dib) ) { int count = FreeImage_GetTransparencyCount(dib); BYTE *table = FreeImage_GetTransparencyTable(dib); - for ( int i = 0; i < count; i++ ) { - if ( table[i] == 0 ) { + for( int i = 0; i < count; i++ ) { + if( table[i] == 0 ) { have_transparent = true; transparent_color = i; break; @@ -1263,7 +1263,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void } io->write_proc((void *)"\x21\xF9\x04", 3, 1, handle); b = (BYTE)((disposal_method << 2) & GIF_PACKED_GCE_DISPOSAL); - if ( have_transparent ) b |= GIF_PACKED_GCE_HAVETRANS; + if( have_transparent ) b |= GIF_PACKED_GCE_HAVETRANS; io->write_proc(&b, 1, 1, handle); //Notes about delay time for GIFs: //IE5/IE6 have a minimum and default of 100ms @@ -1287,14 +1287,14 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void io->write_proc(&width, 2, 1, handle); io->write_proc(&height, 2, 1, handle); packed = 0; - if ( !no_local_palette ) packed |= GIF_PACKED_ID_HAVELCT | ((bpp - 1) & GIF_PACKED_ID_LCTSIZE); - if ( interlaced ) packed |= GIF_PACKED_ID_INTERLACED; + if( !no_local_palette ) packed |= GIF_PACKED_ID_HAVELCT | ((bpp - 1) & GIF_PACKED_ID_LCTSIZE); + if( interlaced ) packed |= GIF_PACKED_ID_INTERLACED; io->write_proc(&packed, 1, 1, handle); //Local Color Table - if ( !no_local_palette ) { + if( !no_local_palette ) { int palsize = 1 << bpp; - for ( int i = 0; i < palsize; i++ ) { + for( int i = 0; i < palsize; i++ ) { io->write_proc(&pal[i].rgbRed, 1, 1, handle); io->write_proc(&pal[i].rgbGreen, 1, 1, handle); io->write_proc(&pal[i].rgbBlue, 1, 1, handle); @@ -1316,9 +1316,9 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void b = sizeof(buf); while( y < output_height ) { memcpy(stringtable->FillInputBuffer(line), FreeImage_GetScanLine(dib, output_height - y - 1), line); - while( stringtable->Compress(bufptr, &size)) { + while( stringtable->Compress(bufptr, &size) ) { bufptr += size; - if ( bufptr - buf == sizeof(buf)) { + if( bufptr - buf == sizeof(buf) ) { io->write_proc(&b, 1, 1, handle); io->write_proc(buf, sizeof(buf), 1, handle); size = sizeof(buf); @@ -1327,9 +1327,9 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void size = (int)(sizeof(buf) - (bufptr - buf)); } } - if ( interlaced ) { + if( interlaced ) { y += g_GifInterlaceIncrement[interlacepass]; - if ( y >= output_height && ++interlacepass < GIF_INTERLACE_PASSES ) { + if( y >= output_height && ++interlacepass < GIF_INTERLACE_PASSES ) { y = g_GifInterlaceOffset[interlacepass]; } } else { @@ -1339,14 +1339,14 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void size = (int)(bufptr - buf); BYTE last[4]; w = (WORD)stringtable->CompressEnd(last); - if ( size + w >= sizeof(buf)) { + if( size + w >= sizeof(buf) ) { //one last full size sub-block io->write_proc(&b, 1, 1, handle); io->write_proc(buf, size, 1, handle); io->write_proc(last, sizeof(buf) - size, 1, handle); //and possibly a tiny additional sub-block b = (BYTE)(w - (sizeof(buf) - size)); - if ( b > 0 ) { + if( b > 0 ) { io->write_proc(&b, 1, 1, handle); io->write_proc(last + w - b, b, 1, handle); } diff --git a/plugins/AdvaImg/src/FreeImage/PluginHDR.cpp b/plugins/AdvaImg/src/FreeImage/PluginHDR.cpp index a0334e1143..d8c24adc31 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginHDR.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginHDR.cpp @@ -127,7 +127,7 @@ rgbe_GetLine(FreeImageIO *io, fi_handle handle, char *buffer, int length) { int i; memset(buffer, 0, length); for(i = 0; i < length; i++) { - if (!io->read_proc(&buffer[i], 1, 1, handle)) + if(!io->read_proc(&buffer[i], 1, 1, handle)) return FALSE; if(buffer[i] == 0x0A) break; @@ -196,7 +196,7 @@ rgbe_ReadHeader(FreeImageIO *io, fi_handle handle, unsigned *width, unsigned *he header_info->exposure = 1.0; // get the first line - if (!rgbe_GetLine(io, handle, buf, HDR_MAXLINE)) + if(!rgbe_GetLine(io, handle, buf, HDR_MAXLINE)) return rgbe_Error(rgbe_read_error, NULL); // check the signature @@ -208,19 +208,19 @@ rgbe_ReadHeader(FreeImageIO *io, fi_handle handle, unsigned *width, unsigned *he else { header_info->valid |= RGBE_VALID_PROGRAMTYPE; for(i = 0; i < sizeof(header_info->programtype) - 1; i++) { - if ((buf[i+2] == 0) || isspace(buf[i+2])) + if((buf[i+2] == 0) || isspace(buf[i+2])) break; header_info->programtype[i] = buf[i+2]; } header_info->programtype[i] = 0; } - for (;;) { + for(;;) { // get next line - if (!rgbe_GetLine(io, handle, buf, HDR_MAXLINE)) + if(!rgbe_GetLine(io, handle, buf, HDR_MAXLINE)) return rgbe_Error(rgbe_read_error, NULL); - if ((buf[0] == 0) || (buf[0] == '\n')) { + if((buf[0] == 0) || (buf[0] == '\n')) { // end of header so break out of loop bHeaderFound = TRUE; break; @@ -236,17 +236,17 @@ rgbe_ReadHeader(FreeImageIO *io, fi_handle handle, unsigned *width, unsigned *he header_info->exposure = tempf; header_info->valid |= RGBE_VALID_EXPOSURE; } - else if ((buf[0] == '#') && (buf[1] == 0x20)) { + else if((buf[0] == '#') && (buf[1] == 0x20)) { header_info->valid |= RGBE_VALID_COMMENT; strcpy(header_info->comment, buf); } } - if (!bHeaderFound || !bFormatFound) { + if(!bHeaderFound || !bFormatFound) { return rgbe_Error(rgbe_format_error, "invalid header"); } // get next line - if (!rgbe_GetLine(io, handle, buf, HDR_MAXLINE)) + if(!rgbe_GetLine(io, handle, buf, HDR_MAXLINE)) return rgbe_Error(rgbe_read_error, NULL); // get the image width & height @@ -364,14 +364,14 @@ rgbe_ReadPixels_RLE(FreeImageIO *io, fi_handle handle, FIRGBF *data, int scanlin free(scanline_buffer); return rgbe_Error(rgbe_read_error,NULL); } - if ((rgbe[0] != 2) || (rgbe[1] != 2) || (rgbe[2] & 0x80)) { + if((rgbe[0] != 2) || (rgbe[1] != 2) || (rgbe[2] & 0x80)) { // this file is not run length encoded rgbe_RGBEToFloat(data, rgbe); data ++; free(scanline_buffer); return rgbe_ReadPixels(io, handle, data, scanline_width * num_scanlines - 1); } - if ((((int)rgbe[2]) << 8 | rgbe[3]) != scanline_width) { + if((((int)rgbe[2]) << 8 | rgbe[3]) != scanline_width) { free(scanline_buffer); return rgbe_Error(rgbe_format_error,"wrong scanline width"); } @@ -394,7 +394,7 @@ rgbe_ReadPixels_RLE(FreeImageIO *io, fi_handle handle, FIRGBF *data, int scanlin if(buf[0] > 128) { // a run of the same value count = buf[0] - 128; - if ((count == 0) || (count > ptr_end - ptr)) { + if((count == 0) || (count > ptr_end - ptr)) { free(scanline_buffer); return rgbe_Error(rgbe_format_error, "bad scanline data"); } @@ -404,12 +404,12 @@ rgbe_ReadPixels_RLE(FreeImageIO *io, fi_handle handle, FIRGBF *data, int scanlin else { // a non-run count = buf[0]; - if ((count == 0) || (count > ptr_end - ptr)) { + if((count == 0) || (count > ptr_end - ptr)) { free(scanline_buffer); return rgbe_Error(rgbe_format_error, "bad scanline data"); } *ptr++ = buf[1]; - if (--count > 0) { + if(--count > 0) { if(io->read_proc(ptr, 1, sizeof(BYTE) * count, handle) < 1) { free(scanline_buffer); return rgbe_Error(rgbe_read_error, NULL); @@ -530,7 +530,7 @@ rgbe_WritePixels_RLE(FreeImageIO *io, fi_handle handle, FIRGBF *data, unsigned s // first red, then green, then blue, then exponent for(int i = 0; i < 4; i++) { BOOL bOK = rgbe_WriteBytes_RLE(io, handle, &buffer[i*scanline_width], scanline_width); - if (!bOK) { + if(!bOK) { free(buffer); return bOK; } @@ -606,7 +606,7 @@ static FIBITMAP * DLL_CALLCONV Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { FIBITMAP *dib = NULL; - if (!handle) { + if(!handle) { return NULL; } @@ -624,7 +624,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { // allocate a RGBF image dib = FreeImage_AllocateHeaderT(header_only, FIT_RGBF, width, height); - if (!dib) { + if(!dib) { throw FI_MSG_ERROR_MEMORY; } @@ -640,7 +640,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { for(unsigned y = 0; y < height; y++) { FIRGBF *scanline = (FIRGBF*)FreeImage_GetScanLine(dib, height - 1 - y); - if (!rgbe_ReadPixels_RLE(io, handle, scanline, width, 1)) { + if(!rgbe_ReadPixels_RLE(io, handle, scanline, width, 1)) { FreeImage_Unload(dib); return NULL; } @@ -659,9 +659,11 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { static BOOL DLL_CALLCONV Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data) { - if (!dib) return FALSE; + if(!dib) return FALSE; - if(FreeImage_GetImageType(dib) != FIT_RGBF) { + FREE_IMAGE_TYPE src_type = FreeImage_GetImageType(dib); + if(src_type != FIT_RGBF) { + FreeImage_OutputMessageProc(s_format_id, "FREE_IMAGE_TYPE: Unable to convert from type %d to type %d.\n No such conversion exists.", src_type, FIT_RGBF); return FALSE; } @@ -676,7 +678,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void rgbe_WriteMetadata(dib, &header_info); // fill a comment sprintf(header_info.comment, "# Made with FreeImage %s", FreeImage_GetVersion()); - if (!rgbe_WriteHeader(io, handle, width, height, &header_info)) { + if(!rgbe_WriteHeader(io, handle, width, height, &header_info)) { return FALSE; } @@ -684,7 +686,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void for(unsigned y = 0; y < height; y++) { FIRGBF *scanline = (FIRGBF*)FreeImage_GetScanLine(dib, height - 1 - y); - if (!rgbe_WritePixels_RLE(io, handle, scanline, width, 1)) { + if(!rgbe_WritePixels_RLE(io, handle, scanline, width, 1)) { return FALSE; } } diff --git a/plugins/AdvaImg/src/FreeImage/PluginICO.cpp b/plugins/AdvaImg/src/FreeImage/PluginICO.cpp index d0ece3514c..7f41a0d841 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginICO.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginICO.cpp @@ -100,7 +100,7 @@ CalculateImageOffset(std::vector& vPages, int nIndex ) { // calculate the ICO header size dwSize = sizeof(ICONHEADER); // add the ICONDIRENTRY's - dwSize += (DWORD)( vPages.size() * sizeof(ICONDIRENTRY)); + dwSize += (DWORD)( vPages.size() * sizeof(ICONDIRENTRY) ); // add the sizes of the previous images for(int k = 0; k < nIndex; k++) { FIBITMAP *icon_dib = (FIBITMAP*)vPages[k]; @@ -232,7 +232,7 @@ Open(FreeImageIO *io, fi_handle handle, BOOL read) { SwapIconHeader(lpIH); #endif - if (!(lpIH->idReserved == 0) || !(lpIH->idType == 1)) { + if(!(lpIH->idReserved == 0) || !(lpIH->idType == 1)) { // Not an ICO file free(lpIH); return NULL; @@ -295,7 +295,7 @@ LoadStandardIcon(FreeImageIO *io, fi_handle handle, int flags, BOOL header_only) return NULL; } - if ( bmih.biBitCount <= 8 ) { + if( bmih.biBitCount <= 8 ) { // read the palette data io->read_proc(FreeImage_GetPalette(dib), CalculateUsedPaletteEntries(bit_count) * sizeof(RGBQUAD), 1, handle); #if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_RGB @@ -339,7 +339,7 @@ LoadStandardIcon(FreeImageIO *io, fi_handle handle, int flags, BOOL header_only) // bitmap has been loaded successfully! // convert to 32bpp and generate an alpha channel - if ((flags & ICO_MAKEALPHA) == ICO_MAKEALPHA) { + if((flags & ICO_MAKEALPHA) == ICO_MAKEALPHA) { FIBITMAP *dib32 = FreeImage_ConvertTo32Bits(dib); FreeImage_Unload(dib); @@ -350,7 +350,7 @@ LoadStandardIcon(FreeImageIO *io, fi_handle handle, int flags, BOOL header_only) int width_and = WidthBytes(width); BYTE *line_and = (BYTE *)malloc(width_and); - if ( line_and == NULL ) { + if( line_and == NULL ) { FreeImage_Unload(dib32); return NULL; } @@ -361,7 +361,7 @@ LoadStandardIcon(FreeImageIO *io, fi_handle handle, int flags, BOOL header_only) io->read_proc(line_and, width_and, 1, handle); for(int x = 0; x < width; x++) { quad->rgbReserved = (line_and[x>>3] & (0x80 >> (x & 0x07))) != 0 ? 0 : 0xFF; - if ( quad->rgbReserved == 0 ) { + if( quad->rgbReserved == 0 ) { quad->rgbBlue ^= 0xFF; quad->rgbGreen ^= 0xFF; quad->rgbRed ^= 0xFF; @@ -409,7 +409,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { io->seek_proc(handle, 0, SEEK_SET); io->seek_proc(handle, icon_list[page].dwImageOffset, SEEK_CUR); - if ((icon_list[page].bWidth == 0) && (icon_list[page].bHeight == 0)) { + if((icon_list[page].bWidth == 0) && (icon_list[page].bHeight == 0)) { // Vista icon support dib = FreeImage_LoadFromHandle(FIF_PNG, io, handle, header_only ? FIF_LOAD_NOPIXELS : PNG_DEFAULT); } @@ -530,7 +530,7 @@ SaveStandardIcon(FreeImageIO *io, FIBITMAP *dib, fi_handle handle) { #endif // AND mask BYTE *and_mask = (BYTE*)malloc(size_and); - if (!and_mask) { + if(!and_mask) { return FALSE; } @@ -642,14 +642,14 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void std::vector vPages; int k; - if (!dib || !handle || !data) { + if(!dib || !handle || !data) { return FALSE; } // check format limits unsigned w = FreeImage_GetWidth(dib); unsigned h = FreeImage_GetHeight(dib); - if ((w < 16) || (w > 256) || (h < 16) || (h > 256) || (w != h)) { + if((w < 16) || (w > 256) || (h < 16) || (h > 256) || (w != h)) { FreeImage_OutputMessageProc(s_format_id, "Unsupported icon size: width x height = %d x %d", w, h); return FALSE; } @@ -667,7 +667,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void // load all icons for(k = 0; k < icon_header->idCount; k++) { icon_dib = Load(io, handle, k, flags, data); - if (!icon_dib) { + if(!icon_dib) { throw FI_MSG_ERROR_DIB_MEMORY; } vPages.push_back(icon_dib); @@ -694,7 +694,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void // save the icon descriptions ICONDIRENTRY *icon_list = (ICONDIRENTRY *)malloc(icon_header->idCount * sizeof(ICONDIRENTRY)); - if (!icon_list) { + if(!icon_list) { throw FI_MSG_ERROR_MEMORY; } memset(icon_list, 0, icon_header->idCount * sizeof(ICONDIRENTRY)); @@ -710,7 +710,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void icon_list[k].bReserved = 0; icon_list[k].wPlanes = bmih->biPlanes; icon_list[k].wBitCount = bmih->biBitCount; - if ( (icon_list[k].wPlanes * icon_list[k].wBitCount) >= 8 ) { + if( (icon_list[k].wPlanes * icon_list[k].wBitCount) >= 8 ) { icon_list[k].bColorCount = 0; } else { icon_list[k].bColorCount = (BYTE)(1 << (icon_list[k].wPlanes * icon_list[k].wBitCount)); @@ -731,7 +731,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void for(k = 0; k < icon_header->idCount; k++) { icon_dib = (FIBITMAP*)vPages[k]; - if ((icon_list[k].bWidth == 0) && (icon_list[k].bHeight == 0)) { + if((icon_list[k].bWidth == 0) && (icon_list[k].bHeight == 0)) { // Vista icon support FreeImage_SaveToHandle(FIF_PNG, icon_dib, io, handle, PNG_DEFAULT); } diff --git a/plugins/AdvaImg/src/FreeImage/PluginIFF.cpp b/plugins/AdvaImg/src/FreeImage/PluginIFF.cpp index b6cd45d6db..ae1f903f82 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginIFF.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginIFF.cpp @@ -220,7 +220,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { SwapLong(&type); #endif - if ((type != ID_ILBM) && (type != ID_PBM)) + if((type != ID_ILBM) && (type != ID_PBM)) return NULL; size -= 4; @@ -266,7 +266,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { depth = planes > 8 ? 24 : 8; - if ( depth == 24 ) { + if( depth == 24 ) { dib = FreeImage_Allocate(width, height, depth, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); } else { dib = FreeImage_Allocate(width, height, depth); @@ -358,7 +358,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { // t = [0..127] => copy the next t+1 bytes literally unsigned size_to_read = t + 1; - if ((size_to_read + x) > src_size) { + if((size_to_read + x) > src_size) { // sanity check for buffer overruns size_to_read = src_size - x; io->read_proc(src + x, size_to_read, 1, handle); @@ -373,7 +373,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { io->read_proc(&b, 1, 1, handle); unsigned size_to_copy = (unsigned)(-(int)t + 1); - if ((size_to_copy + x) > src_size) { + if((size_to_copy + x) > src_size) { // sanity check for buffer overruns size_to_copy = src_size - x; memset(src + x, b, size_to_copy); diff --git a/plugins/AdvaImg/src/FreeImage/PluginJ2K.cpp b/plugins/AdvaImg/src/FreeImage/PluginJ2K.cpp index 6e772afdaa..ae8a6ae88a 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginJ2K.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginJ2K.cpp @@ -1,339 +1,339 @@ -// ========================================================== -// JPEG2000 J2K codestream Loader and Writer -// -// Design and implementation by -// - Hervé Drolon (drolon@infonie.fr) -// -// This file is part of FreeImage 3 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include "FreeImage.h" -#include "Utilities.h" -#include "../LibOpenJPEG/openjpeg.h" - -// ========================================================== -// Plugin Interface -// ========================================================== - -static int s_format_id; - -// ========================================================== -// Helper functions (see J2KHelper.cpp) -// ========================================================== - -FIBITMAP* J2KImageToFIBITMAP(int format_id, const opj_image_t *image); -opj_image_t* FIBITMAPToJ2KImage(int format_id, FIBITMAP *dib, const opj_cparameters_t *parameters); - -// ========================================================== -// Internal functions -// ========================================================== - -/** -OpenJPEG Error callback -*/ -static void j2k_error_callback(const char *msg, void *client_data) { - FreeImage_OutputMessageProc(s_format_id, "Error: %s", msg); -} -/** -OpenJPEG Warning callback -*/ -static void j2k_warning_callback(const char *msg, void *client_data) { - FreeImage_OutputMessageProc(s_format_id, "Warning: %s", msg); -} - -// ========================================================== -// Plugin Implementation -// ========================================================== - -static const char * DLL_CALLCONV -Format() { - return "J2K"; -} - -static const char * DLL_CALLCONV -Description() { - return "JPEG-2000 codestream"; -} - -static const char * DLL_CALLCONV -Extension() { - return "j2k,j2c"; -} - -static const char * DLL_CALLCONV -RegExpr() { - return NULL; -} - -static const char * DLL_CALLCONV -MimeType() { - return "image/j2k"; -} - -static BOOL DLL_CALLCONV -Validate(FreeImageIO *io, fi_handle handle) { - BYTE jpc_signature[] = { 0xFF, 0x4F }; - BYTE signature[2] = { 0, 0 }; - - long tell = io->tell_proc(handle); - io->read_proc(signature, 1, sizeof(jpc_signature), handle); - io->seek_proc(handle, tell, SEEK_SET); - - return (memcmp(jpc_signature, signature, sizeof(jpc_signature)) == 0); -} - -static BOOL DLL_CALLCONV -SupportsExportDepth(int depth) { - return ( - (depth == 8) || - (depth == 24) || - (depth == 32) - ); -} - -static BOOL DLL_CALLCONV -SupportsExportType(FREE_IMAGE_TYPE type) { - return ( - (type == FIT_BITMAP) || - (type == FIT_UINT16) || - (type == FIT_RGB16) || - (type == FIT_RGBA16) - ); -} - -// ---------------------------------------------------------- - -static void * DLL_CALLCONV -Open(FreeImageIO *io, fi_handle handle, BOOL read) { - return NULL; -} - -static void DLL_CALLCONV -Close(FreeImageIO *io, fi_handle handle, void *data) { -} - -// ---------------------------------------------------------- - -static FIBITMAP * DLL_CALLCONV -Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { - if (handle) { - opj_dparameters_t parameters; // decompression parameters - opj_event_mgr_t event_mgr; // event manager - opj_image_t *image = NULL; // decoded image - - BYTE *src = NULL; - long file_length; - - opj_dinfo_t* dinfo = NULL; // handle to a decompressor - opj_cio_t *cio = NULL; - - FIBITMAP *dib = NULL; - - // check the file format - if (!Validate(io, handle)) { - return NULL; - } - - // configure the event callbacks - memset(&event_mgr, 0, sizeof(opj_event_mgr_t)); - event_mgr.error_handler = j2k_error_callback; - event_mgr.warning_handler = j2k_warning_callback; - event_mgr.info_handler = NULL; - - // set decoding parameters to default values - opj_set_default_decoder_parameters(¶meters); - - try { - // read the input file and put it in memory - - long start_pos = io->tell_proc(handle); - io->seek_proc(handle, 0, SEEK_END); - file_length = io->tell_proc(handle) - start_pos; - io->seek_proc(handle, start_pos, SEEK_SET); - src = (BYTE*)malloc(file_length * sizeof(BYTE)); - if (!src) { - throw FI_MSG_ERROR_MEMORY; - } - if(io->read_proc(src, 1, file_length, handle) < 1) { - throw "Error while reading input stream"; - } - - // decode the JPEG-2000 codestream - - // get a decoder handle - dinfo = opj_create_decompress(CODEC_J2K); - - // catch events using our callbacks - opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, NULL); - - // setup the decoder decoding parameters using user parameters - opj_setup_decoder(dinfo, ¶meters); - - // open a byte stream - cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length); - - // decode the stream and fill the image structure - image = opj_decode(dinfo, cio); - if (!image) { - throw "Failed to decode image!\n"; - } - - // close the byte stream - opj_cio_close(cio); - cio = NULL; - - // free the memory containing the code-stream - free(src); - src = NULL; - - // free the codec context - opj_destroy_decompress(dinfo); - - // create output image - dib = J2KImageToFIBITMAP(s_format_id, image); - if (!dib) throw "Failed to import JPEG2000 image"; - - // free image data structure - opj_image_destroy(image); - - return dib; - - } catch (const char *text) { - if(src) free(src); - if(dib) FreeImage_Unload(dib); - // free remaining structures - opj_destroy_decompress(dinfo); - opj_image_destroy(image); - // close the byte stream - if(cio) opj_cio_close(cio); - - FreeImage_OutputMessageProc(s_format_id, text); - - return NULL; - } - } - - return NULL; -} - -static BOOL DLL_CALLCONV -Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data) { - if ((dib) && (handle)) { - BOOL bSuccess; - opj_cparameters_t parameters; // compression parameters - opj_event_mgr_t event_mgr; // event manager - opj_image_t *image = NULL; // image to encode - opj_cinfo_t* cinfo = NULL; // codec context - opj_cio_t *cio = NULL; // memory byte stream - - // configure the event callbacks - memset(&event_mgr, 0, sizeof(opj_event_mgr_t)); - event_mgr.error_handler = j2k_error_callback; - event_mgr.warning_handler = j2k_warning_callback; - event_mgr.info_handler = NULL; - - // set encoding parameters to default values - opj_set_default_encoder_parameters(¶meters); - - parameters.tcp_numlayers = 0; - // if no rate entered, apply a 16:1 rate by default - if(flags == J2K_DEFAULT) { - parameters.tcp_rates[0] = (float)16; - } else { - // for now, the flags parameter is only used to specify the rate - parameters.tcp_rates[0] = (float)flags; - } - parameters.tcp_numlayers++; - parameters.cp_disto_alloc = 1; - - try { - // convert the dib to a OpenJPEG image - image = FIBITMAPToJ2KImage(s_format_id, dib, ¶meters); - if (!image) return FALSE; - - // decide if MCT should be used - parameters.tcp_mct = (image->numcomps == 3) ? 1 : 0; - - // encode the destination image - - // get a J2K compressor handle - cinfo = opj_create_compress(CODEC_J2K); - - // catch events using our callbacks - opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, NULL); - - // setup the encoder parameters using the current image and using user parameters - opj_setup_encoder(cinfo, ¶meters, image); - - // open a byte stream for writing, allocate memory for all tiles - cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0); - - // encode the image - bSuccess = opj_encode(cinfo, cio, image, NULL/*parameters.index*/); - if (!bSuccess) { - throw "Failed to encode image"; - } - int codestream_length = cio_tell(cio); - - // write the buffer to user's IO handle - io->write_proc(cio->buffer, 1, codestream_length, handle); - - // close and free the byte stream - opj_cio_close(cio); - - // free remaining compression structures - opj_destroy_compress(cinfo); - - // free image data - opj_image_destroy(image); - - return TRUE; - - } catch (const char *text) { - if(cio) opj_cio_close(cio); - if(cinfo) opj_destroy_compress(cinfo); - if(image) opj_image_destroy(image); - FreeImage_OutputMessageProc(s_format_id, text); - return FALSE; - } - } - - return FALSE; -} - -// ========================================================== -// Init -// ========================================================== - -void DLL_CALLCONV -InitJ2K(Plugin *plugin, int format_id) { - s_format_id = format_id; - - plugin->format_proc = Format; - plugin->description_proc = Description; - plugin->extension_proc = Extension; - plugin->regexpr_proc = RegExpr; - plugin->open_proc = Open; - plugin->close_proc = Close; - plugin->pagecount_proc = NULL; - plugin->pagecapability_proc = NULL; - plugin->load_proc = Load; - plugin->save_proc = Save; - plugin->validate_proc = Validate; - plugin->mime_proc = MimeType; - plugin->supports_export_bpp_proc = SupportsExportDepth; - plugin->supports_export_type_proc = SupportsExportType; - plugin->supports_icc_profiles_proc = NULL; -} +// ========================================================== +// JPEG2000 J2K codestream Loader and Writer +// +// Design and implementation by +// - Hervé Drolon (drolon@infonie.fr) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +#include "FreeImage.h" +#include "Utilities.h" +#include "../LibOpenJPEG/openjpeg.h" + +// ========================================================== +// Plugin Interface +// ========================================================== + +static int s_format_id; + +// ========================================================== +// Helper functions (see J2KHelper.cpp) +// ========================================================== + +FIBITMAP* J2KImageToFIBITMAP(int format_id, const opj_image_t *image); +opj_image_t* FIBITMAPToJ2KImage(int format_id, FIBITMAP *dib, const opj_cparameters_t *parameters); + +// ========================================================== +// Internal functions +// ========================================================== + +/** +OpenJPEG Error callback +*/ +static void j2k_error_callback(const char *msg, void *client_data) { + FreeImage_OutputMessageProc(s_format_id, "Error: %s", msg); +} +/** +OpenJPEG Warning callback +*/ +static void j2k_warning_callback(const char *msg, void *client_data) { + FreeImage_OutputMessageProc(s_format_id, "Warning: %s", msg); +} + +// ========================================================== +// Plugin Implementation +// ========================================================== + +static const char * DLL_CALLCONV +Format() { + return "J2K"; +} + +static const char * DLL_CALLCONV +Description() { + return "JPEG-2000 codestream"; +} + +static const char * DLL_CALLCONV +Extension() { + return "j2k,j2c"; +} + +static const char * DLL_CALLCONV +RegExpr() { + return NULL; +} + +static const char * DLL_CALLCONV +MimeType() { + return "image/j2k"; +} + +static BOOL DLL_CALLCONV +Validate(FreeImageIO *io, fi_handle handle) { + BYTE jpc_signature[] = { 0xFF, 0x4F }; + BYTE signature[2] = { 0, 0 }; + + long tell = io->tell_proc(handle); + io->read_proc(signature, 1, sizeof(jpc_signature), handle); + io->seek_proc(handle, tell, SEEK_SET); + + return (memcmp(jpc_signature, signature, sizeof(jpc_signature)) == 0); +} + +static BOOL DLL_CALLCONV +SupportsExportDepth(int depth) { + return ( + (depth == 8) || + (depth == 24) || + (depth == 32) + ); +} + +static BOOL DLL_CALLCONV +SupportsExportType(FREE_IMAGE_TYPE type) { + return ( + (type == FIT_BITMAP) || + (type == FIT_UINT16) || + (type == FIT_RGB16) || + (type == FIT_RGBA16) + ); +} + +// ---------------------------------------------------------- + +static void * DLL_CALLCONV +Open(FreeImageIO *io, fi_handle handle, BOOL read) { + return NULL; +} + +static void DLL_CALLCONV +Close(FreeImageIO *io, fi_handle handle, void *data) { +} + +// ---------------------------------------------------------- + +static FIBITMAP * DLL_CALLCONV +Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { + if (handle) { + opj_dparameters_t parameters; // decompression parameters + opj_event_mgr_t event_mgr; // event manager + opj_image_t *image = NULL; // decoded image + + BYTE *src = NULL; + long file_length; + + opj_dinfo_t* dinfo = NULL; // handle to a decompressor + opj_cio_t *cio = NULL; + + FIBITMAP *dib = NULL; + + // check the file format + if(!Validate(io, handle)) { + return NULL; + } + + // configure the event callbacks + memset(&event_mgr, 0, sizeof(opj_event_mgr_t)); + event_mgr.error_handler = j2k_error_callback; + event_mgr.warning_handler = j2k_warning_callback; + event_mgr.info_handler = NULL; + + // set decoding parameters to default values + opj_set_default_decoder_parameters(¶meters); + + try { + // read the input file and put it in memory + + long start_pos = io->tell_proc(handle); + io->seek_proc(handle, 0, SEEK_END); + file_length = io->tell_proc(handle) - start_pos; + io->seek_proc(handle, start_pos, SEEK_SET); + src = (BYTE*)malloc(file_length * sizeof(BYTE)); + if(!src) { + throw FI_MSG_ERROR_MEMORY; + } + if(io->read_proc(src, 1, file_length, handle) < 1) { + throw "Error while reading input stream"; + } + + // decode the JPEG-2000 codestream + + // get a decoder handle + dinfo = opj_create_decompress(CODEC_J2K); + + // catch events using our callbacks + opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, NULL); + + // setup the decoder decoding parameters using user parameters + opj_setup_decoder(dinfo, ¶meters); + + // open a byte stream + cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length); + + // decode the stream and fill the image structure + image = opj_decode(dinfo, cio); + if(!image) { + throw "Failed to decode image!\n"; + } + + // close the byte stream + opj_cio_close(cio); + cio = NULL; + + // free the memory containing the code-stream + free(src); + src = NULL; + + // free the codec context + opj_destroy_decompress(dinfo); + + // create output image + dib = J2KImageToFIBITMAP(s_format_id, image); + if(!dib) throw "Failed to import JPEG2000 image"; + + // free image data structure + opj_image_destroy(image); + + return dib; + + } catch (const char *text) { + if(src) free(src); + if(dib) FreeImage_Unload(dib); + // free remaining structures + opj_destroy_decompress(dinfo); + opj_image_destroy(image); + // close the byte stream + if(cio) opj_cio_close(cio); + + FreeImage_OutputMessageProc(s_format_id, text); + + return NULL; + } + } + + return NULL; +} + +static BOOL DLL_CALLCONV +Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data) { + if ((dib) && (handle)) { + BOOL bSuccess; + opj_cparameters_t parameters; // compression parameters + opj_event_mgr_t event_mgr; // event manager + opj_image_t *image = NULL; // image to encode + opj_cinfo_t* cinfo = NULL; // codec context + opj_cio_t *cio = NULL; // memory byte stream + + // configure the event callbacks + memset(&event_mgr, 0, sizeof(opj_event_mgr_t)); + event_mgr.error_handler = j2k_error_callback; + event_mgr.warning_handler = j2k_warning_callback; + event_mgr.info_handler = NULL; + + // set encoding parameters to default values + opj_set_default_encoder_parameters(¶meters); + + parameters.tcp_numlayers = 0; + // if no rate entered, apply a 16:1 rate by default + if(flags == J2K_DEFAULT) { + parameters.tcp_rates[0] = (float)16; + } else { + // for now, the flags parameter is only used to specify the rate + parameters.tcp_rates[0] = (float)flags; + } + parameters.tcp_numlayers++; + parameters.cp_disto_alloc = 1; + + try { + // convert the dib to a OpenJPEG image + image = FIBITMAPToJ2KImage(s_format_id, dib, ¶meters); + if(!image) return FALSE; + + // decide if MCT should be used + parameters.tcp_mct = (image->numcomps == 3) ? 1 : 0; + + // encode the destination image + + // get a J2K compressor handle + cinfo = opj_create_compress(CODEC_J2K); + + // catch events using our callbacks + opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, NULL); + + // setup the encoder parameters using the current image and using user parameters + opj_setup_encoder(cinfo, ¶meters, image); + + // open a byte stream for writing, allocate memory for all tiles + cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0); + + // encode the image + bSuccess = opj_encode(cinfo, cio, image, NULL/*parameters.index*/); + if (!bSuccess) { + throw "Failed to encode image"; + } + int codestream_length = cio_tell(cio); + + // write the buffer to user's IO handle + io->write_proc(cio->buffer, 1, codestream_length, handle); + + // close and free the byte stream + opj_cio_close(cio); + + // free remaining compression structures + opj_destroy_compress(cinfo); + + // free image data + opj_image_destroy(image); + + return TRUE; + + } catch (const char *text) { + if(cio) opj_cio_close(cio); + if(cinfo) opj_destroy_compress(cinfo); + if(image) opj_image_destroy(image); + FreeImage_OutputMessageProc(s_format_id, text); + return FALSE; + } + } + + return FALSE; +} + +// ========================================================== +// Init +// ========================================================== + +void DLL_CALLCONV +InitJ2K(Plugin *plugin, int format_id) { + s_format_id = format_id; + + plugin->format_proc = Format; + plugin->description_proc = Description; + plugin->extension_proc = Extension; + plugin->regexpr_proc = RegExpr; + plugin->open_proc = Open; + plugin->close_proc = Close; + plugin->pagecount_proc = NULL; + plugin->pagecapability_proc = NULL; + plugin->load_proc = Load; + plugin->save_proc = Save; + plugin->validate_proc = Validate; + plugin->mime_proc = MimeType; + plugin->supports_export_bpp_proc = SupportsExportDepth; + plugin->supports_export_type_proc = SupportsExportType; + plugin->supports_icc_profiles_proc = NULL; +} diff --git a/plugins/AdvaImg/src/FreeImage/PluginJNG.cpp b/plugins/AdvaImg/src/FreeImage/PluginJNG.cpp new file mode 100644 index 0000000000..817e731168 --- /dev/null +++ b/plugins/AdvaImg/src/FreeImage/PluginJNG.cpp @@ -0,0 +1,162 @@ +// ========================================================== +// JNG loader +// +// Design and implementation by +// - Herve Drolon (drolon@infonie.fr) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +#include "FreeImage.h" +#include "Utilities.h" + +// ========================================================== +// Plugin Interface +// ========================================================== + +static int s_format_id; + +// ---------------------------------------------------------- + +#define JNG_SIGNATURE_SIZE 8 // size of the signature + +// ---------------------------------------------------------- + +// ---------------------------------------------------------- +// mng interface (see MNGHelper.cpp) +// ---------------------------------------------------------- + +FIBITMAP* mng_ReadChunks(int format_id, FreeImageIO *io, fi_handle handle, long Offset, int flags = 0); +BOOL mng_WriteJNG(int format_id, FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int flags); + +// ========================================================== +// Plugin Implementation +// ========================================================== + +static const char * DLL_CALLCONV +Format() { + return "JNG"; +} + +static const char * DLL_CALLCONV +Description() { + return "JPEG Network Graphics"; +} + +static const char * DLL_CALLCONV +Extension() { + return "jng"; +} + +static const char * DLL_CALLCONV +RegExpr() { + return NULL; +} + +static const char * DLL_CALLCONV +MimeType() { + return "image/x-mng"; +} + +static BOOL DLL_CALLCONV +Validate(FreeImageIO *io, fi_handle handle) { + BYTE jng_signature[8] = { 139, 74, 78, 71, 13, 10, 26, 10 }; + BYTE signature[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + + io->read_proc(&signature, 1, JNG_SIGNATURE_SIZE, handle); + + return (memcmp(jng_signature, signature, JNG_SIGNATURE_SIZE) == 0) ? TRUE : FALSE; +} + +static BOOL DLL_CALLCONV +SupportsExportDepth(int depth) { + return ( + (depth == 8) || + (depth == 24) || + (depth == 32) + ); +} + +static BOOL DLL_CALLCONV +SupportsExportType(FREE_IMAGE_TYPE type) { + return (type == FIT_BITMAP) ? TRUE : FALSE; +} + +static BOOL DLL_CALLCONV +SupportsICCProfiles() { + return TRUE; +} + +static BOOL DLL_CALLCONV +SupportsNoPixels() { + return TRUE; +} + + +// ---------------------------------------------------------- + +static void * DLL_CALLCONV +Open(FreeImageIO *io, fi_handle handle, BOOL read) { + return NULL; +} + +static void DLL_CALLCONV +Close(FreeImageIO *io, fi_handle handle, void *data) { +} + +static FIBITMAP * DLL_CALLCONV +Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { + long offset = JNG_SIGNATURE_SIZE; // move to skip first 8 bytes of signature + + // check the signature (8 bytes) + if(Validate(io, handle) == FALSE) { + return NULL; + } + + // parse chunks and decode a jng or mng bitmap + return mng_ReadChunks(s_format_id, io, handle, offset, flags); +} + +static BOOL DLL_CALLCONV +Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data) { + + return mng_WriteJNG(s_format_id, io, dib, handle, flags); +} + +// ========================================================== +// Init +// ========================================================== + +void DLL_CALLCONV +InitJNG(Plugin *plugin, int format_id) { + s_format_id = format_id; + + plugin->format_proc = Format; + plugin->description_proc = Description; + plugin->extension_proc = Extension; + plugin->regexpr_proc = RegExpr; + plugin->open_proc = Open; + plugin->close_proc = Close; + plugin->pagecount_proc = NULL; + plugin->pagecapability_proc = NULL; + plugin->load_proc = Load; + plugin->save_proc = Save; + plugin->validate_proc = Validate; + plugin->mime_proc = MimeType; + plugin->supports_export_bpp_proc = SupportsExportDepth; + plugin->supports_export_type_proc = SupportsExportType; + plugin->supports_icc_profiles_proc = SupportsICCProfiles; + plugin->supports_no_pixels_proc = SupportsNoPixels; +} diff --git a/plugins/AdvaImg/src/FreeImage/PluginJP2.cpp b/plugins/AdvaImg/src/FreeImage/PluginJP2.cpp index ed1cb267bb..261697fb5c 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginJP2.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginJP2.cpp @@ -1,339 +1,339 @@ -// ========================================================== -// JPEG2000 JP2 file format Loader and Writer -// -// Design and implementation by -// - Hervé Drolon (drolon@infonie.fr) -// -// This file is part of FreeImage 3 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include "FreeImage.h" -#include "Utilities.h" -#include "../LibOpenJPEG/openjpeg.h" - -// ========================================================== -// Plugin Interface -// ========================================================== - -static int s_format_id; - -// ========================================================== -// Helper functions (see J2KHelper.cpp) -// ========================================================== - -FIBITMAP* J2KImageToFIBITMAP(int format_id, const opj_image_t *image); -opj_image_t* FIBITMAPToJ2KImage(int format_id, FIBITMAP *dib, const opj_cparameters_t *parameters); - -// ========================================================== -// Internal functions -// ========================================================== - -/** -OpenJPEG Error callback -*/ -static void jp2_error_callback(const char *msg, void *client_data) { - FreeImage_OutputMessageProc(s_format_id, "Error: %s", msg); -} -/** -OpenJPEG Warning callback -*/ -static void jp2_warning_callback(const char *msg, void *client_data) { - FreeImage_OutputMessageProc(s_format_id, "Warning: %s", msg); -} - -// ========================================================== -// Plugin Implementation -// ========================================================== - -static const char * DLL_CALLCONV -Format() { - return "JP2"; -} - -static const char * DLL_CALLCONV -Description() { - return "JPEG-2000 File Format"; -} - -static const char * DLL_CALLCONV -Extension() { - return "jp2"; -} - -static const char * DLL_CALLCONV -RegExpr() { - return NULL; -} - -static const char * DLL_CALLCONV -MimeType() { - return "image/jp2"; -} - -static BOOL DLL_CALLCONV -Validate(FreeImageIO *io, fi_handle handle) { - BYTE jp2_signature[] = { 0x00, 0x00, 0x00, 0x0C, 0x6A, 0x50, 0x20, 0x20, 0x0D, 0x0A, 0x87, 0x0A }; - BYTE signature[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - - long tell = io->tell_proc(handle); - io->read_proc(signature, 1, sizeof(jp2_signature), handle); - io->seek_proc(handle, tell, SEEK_SET); - - return (memcmp(jp2_signature, signature, sizeof(jp2_signature)) == 0); -} - -static BOOL DLL_CALLCONV -SupportsExportDepth(int depth) { - return ( - (depth == 8) || - (depth == 24) || - (depth == 32) - ); -} - -static BOOL DLL_CALLCONV -SupportsExportType(FREE_IMAGE_TYPE type) { - return ( - (type == FIT_BITMAP) || - (type == FIT_UINT16) || - (type == FIT_RGB16) || - (type == FIT_RGBA16) - ); -} - -// ---------------------------------------------------------- - -static void * DLL_CALLCONV -Open(FreeImageIO *io, fi_handle handle, BOOL read) { - return NULL; -} - -static void DLL_CALLCONV -Close(FreeImageIO *io, fi_handle handle, void *data) { -} - -// ---------------------------------------------------------- - -static FIBITMAP * DLL_CALLCONV -Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { - if (handle) { - opj_dparameters_t parameters; // decompression parameters - opj_event_mgr_t event_mgr; // event manager - opj_image_t *image = NULL; // decoded image - - BYTE *src = NULL; - long file_length; - - opj_dinfo_t* dinfo = NULL; // handle to a decompressor - opj_cio_t *cio = NULL; - - FIBITMAP *dib = NULL; - - // check the file format - if (!Validate(io, handle)) { - return NULL; - } - - // configure the event callbacks - memset(&event_mgr, 0, sizeof(opj_event_mgr_t)); - event_mgr.error_handler = jp2_error_callback; - event_mgr.warning_handler = jp2_warning_callback; - event_mgr.info_handler = NULL; - - // set decoding parameters to default values - opj_set_default_decoder_parameters(¶meters); - - try { - // read the input file and put it in memory - - long start_pos = io->tell_proc(handle); - io->seek_proc(handle, 0, SEEK_END); - file_length = io->tell_proc(handle) - start_pos; - io->seek_proc(handle, start_pos, SEEK_SET); - src = (BYTE*)malloc(file_length * sizeof(BYTE)); - if (!src) { - throw FI_MSG_ERROR_MEMORY; - } - if(io->read_proc(src, 1, file_length, handle) < 1) { - throw "Error while reading input stream"; - } - - // decode the JPEG-2000 file - - // get a decoder handle - dinfo = opj_create_decompress(CODEC_JP2); - - // catch events using our callbacks - opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, NULL); - - // setup the decoder decoding parameters using user parameters - opj_setup_decoder(dinfo, ¶meters); - - // open a byte stream - cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length); - - // decode the stream and fill the image structure - image = opj_decode(dinfo, cio); - if (!image) { - throw "Failed to decode image!\n"; - } - - // close the byte stream - opj_cio_close(cio); - cio = NULL; - - // free the memory containing the code-stream - free(src); - src = NULL; - - // free the codec context - opj_destroy_decompress(dinfo); - - // create output image - dib = J2KImageToFIBITMAP(s_format_id, image); - if (!dib) throw "Failed to import JPEG2000 image"; - - // free image data structure - opj_image_destroy(image); - - return dib; - - } catch (const char *text) { - if(src) free(src); - if(dib) FreeImage_Unload(dib); - // free remaining structures - opj_destroy_decompress(dinfo); - opj_image_destroy(image); - // close the byte stream - if(cio) opj_cio_close(cio); - - FreeImage_OutputMessageProc(s_format_id, text); - - return NULL; - } - } - - return NULL; -} - -static BOOL DLL_CALLCONV -Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data) { - if ((dib) && (handle)) { - BOOL bSuccess; - opj_cparameters_t parameters; // compression parameters - opj_event_mgr_t event_mgr; // event manager - opj_image_t *image = NULL; // image to encode - opj_cinfo_t* cinfo = NULL; // codec context - opj_cio_t *cio = NULL; // memory byte stream - - // configure the event callbacks - memset(&event_mgr, 0, sizeof(opj_event_mgr_t)); - event_mgr.error_handler = jp2_error_callback; - event_mgr.warning_handler = jp2_warning_callback; - event_mgr.info_handler = NULL; - - // set encoding parameters to default values - opj_set_default_encoder_parameters(¶meters); - - parameters.tcp_numlayers = 0; - // if no rate entered, apply a 16:1 rate by default - if(flags == JP2_DEFAULT) { - parameters.tcp_rates[0] = (float)16; - } else { - // for now, the flags parameter is only used to specify the rate - parameters.tcp_rates[0] = (float)flags; - } - parameters.tcp_numlayers++; - parameters.cp_disto_alloc = 1; - - try { - // convert the dib to a OpenJPEG image - image = FIBITMAPToJ2KImage(s_format_id, dib, ¶meters); - if (!image) return FALSE; - - // decide if MCT should be used - parameters.tcp_mct = (image->numcomps == 3) ? 1 : 0; - - // encode the destination image - - // get a J2K compressor handle - cinfo = opj_create_compress(CODEC_JP2); - - // catch events using our callbacks - opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, NULL); - - // setup the encoder parameters using the current image and using user parameters - opj_setup_encoder(cinfo, ¶meters, image); - - // open a byte stream for writing, allocate memory for all tiles - cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0); - - // encode the image - bSuccess = opj_encode(cinfo, cio, image, NULL/*parameters.index*/); - if (!bSuccess) { - throw "Failed to encode image"; - } - int codestream_length = cio_tell(cio); - - // write the buffer to user's IO handle - io->write_proc(cio->buffer, 1, codestream_length, handle); - - // close and free the byte stream - opj_cio_close(cio); - - // free remaining compression structures - opj_destroy_compress(cinfo); - - // free image data - opj_image_destroy(image); - - return TRUE; - - } catch (const char *text) { - if(cio) opj_cio_close(cio); - if(cinfo) opj_destroy_compress(cinfo); - if(image) opj_image_destroy(image); - FreeImage_OutputMessageProc(s_format_id, text); - return FALSE; - } - } - - return FALSE; -} - -// ========================================================== -// Init -// ========================================================== - -void DLL_CALLCONV -InitJP2(Plugin *plugin, int format_id) { - s_format_id = format_id; - - plugin->format_proc = Format; - plugin->description_proc = Description; - plugin->extension_proc = Extension; - plugin->regexpr_proc = RegExpr; - plugin->open_proc = Open; - plugin->close_proc = Close; - plugin->pagecount_proc = NULL; - plugin->pagecapability_proc = NULL; - plugin->load_proc = Load; - plugin->save_proc = Save; - plugin->validate_proc = Validate; - plugin->mime_proc = MimeType; - plugin->supports_export_bpp_proc = SupportsExportDepth; - plugin->supports_export_type_proc = SupportsExportType; - plugin->supports_icc_profiles_proc = NULL; -} +// ========================================================== +// JPEG2000 JP2 file format Loader and Writer +// +// Design and implementation by +// - Hervé Drolon (drolon@infonie.fr) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +#include "FreeImage.h" +#include "Utilities.h" +#include "../LibOpenJPEG/openjpeg.h" + +// ========================================================== +// Plugin Interface +// ========================================================== + +static int s_format_id; + +// ========================================================== +// Helper functions (see J2KHelper.cpp) +// ========================================================== + +FIBITMAP* J2KImageToFIBITMAP(int format_id, const opj_image_t *image); +opj_image_t* FIBITMAPToJ2KImage(int format_id, FIBITMAP *dib, const opj_cparameters_t *parameters); + +// ========================================================== +// Internal functions +// ========================================================== + +/** +OpenJPEG Error callback +*/ +static void jp2_error_callback(const char *msg, void *client_data) { + FreeImage_OutputMessageProc(s_format_id, "Error: %s", msg); +} +/** +OpenJPEG Warning callback +*/ +static void jp2_warning_callback(const char *msg, void *client_data) { + FreeImage_OutputMessageProc(s_format_id, "Warning: %s", msg); +} + +// ========================================================== +// Plugin Implementation +// ========================================================== + +static const char * DLL_CALLCONV +Format() { + return "JP2"; +} + +static const char * DLL_CALLCONV +Description() { + return "JPEG-2000 File Format"; +} + +static const char * DLL_CALLCONV +Extension() { + return "jp2"; +} + +static const char * DLL_CALLCONV +RegExpr() { + return NULL; +} + +static const char * DLL_CALLCONV +MimeType() { + return "image/jp2"; +} + +static BOOL DLL_CALLCONV +Validate(FreeImageIO *io, fi_handle handle) { + BYTE jp2_signature[] = { 0x00, 0x00, 0x00, 0x0C, 0x6A, 0x50, 0x20, 0x20, 0x0D, 0x0A, 0x87, 0x0A }; + BYTE signature[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + + long tell = io->tell_proc(handle); + io->read_proc(signature, 1, sizeof(jp2_signature), handle); + io->seek_proc(handle, tell, SEEK_SET); + + return (memcmp(jp2_signature, signature, sizeof(jp2_signature)) == 0); +} + +static BOOL DLL_CALLCONV +SupportsExportDepth(int depth) { + return ( + (depth == 8) || + (depth == 24) || + (depth == 32) + ); +} + +static BOOL DLL_CALLCONV +SupportsExportType(FREE_IMAGE_TYPE type) { + return ( + (type == FIT_BITMAP) || + (type == FIT_UINT16) || + (type == FIT_RGB16) || + (type == FIT_RGBA16) + ); +} + +// ---------------------------------------------------------- + +static void * DLL_CALLCONV +Open(FreeImageIO *io, fi_handle handle, BOOL read) { + return NULL; +} + +static void DLL_CALLCONV +Close(FreeImageIO *io, fi_handle handle, void *data) { +} + +// ---------------------------------------------------------- + +static FIBITMAP * DLL_CALLCONV +Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { + if (handle) { + opj_dparameters_t parameters; // decompression parameters + opj_event_mgr_t event_mgr; // event manager + opj_image_t *image = NULL; // decoded image + + BYTE *src = NULL; + long file_length; + + opj_dinfo_t* dinfo = NULL; // handle to a decompressor + opj_cio_t *cio = NULL; + + FIBITMAP *dib = NULL; + + // check the file format + if(!Validate(io, handle)) { + return NULL; + } + + // configure the event callbacks + memset(&event_mgr, 0, sizeof(opj_event_mgr_t)); + event_mgr.error_handler = jp2_error_callback; + event_mgr.warning_handler = jp2_warning_callback; + event_mgr.info_handler = NULL; + + // set decoding parameters to default values + opj_set_default_decoder_parameters(¶meters); + + try { + // read the input file and put it in memory + + long start_pos = io->tell_proc(handle); + io->seek_proc(handle, 0, SEEK_END); + file_length = io->tell_proc(handle) - start_pos; + io->seek_proc(handle, start_pos, SEEK_SET); + src = (BYTE*)malloc(file_length * sizeof(BYTE)); + if(!src) { + throw FI_MSG_ERROR_MEMORY; + } + if(io->read_proc(src, 1, file_length, handle) < 1) { + throw "Error while reading input stream"; + } + + // decode the JPEG-2000 file + + // get a decoder handle + dinfo = opj_create_decompress(CODEC_JP2); + + // catch events using our callbacks + opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, NULL); + + // setup the decoder decoding parameters using user parameters + opj_setup_decoder(dinfo, ¶meters); + + // open a byte stream + cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length); + + // decode the stream and fill the image structure + image = opj_decode(dinfo, cio); + if(!image) { + throw "Failed to decode image!\n"; + } + + // close the byte stream + opj_cio_close(cio); + cio = NULL; + + // free the memory containing the code-stream + free(src); + src = NULL; + + // free the codec context + opj_destroy_decompress(dinfo); + + // create output image + dib = J2KImageToFIBITMAP(s_format_id, image); + if(!dib) throw "Failed to import JPEG2000 image"; + + // free image data structure + opj_image_destroy(image); + + return dib; + + } catch (const char *text) { + if(src) free(src); + if(dib) FreeImage_Unload(dib); + // free remaining structures + opj_destroy_decompress(dinfo); + opj_image_destroy(image); + // close the byte stream + if(cio) opj_cio_close(cio); + + FreeImage_OutputMessageProc(s_format_id, text); + + return NULL; + } + } + + return NULL; +} + +static BOOL DLL_CALLCONV +Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data) { + if ((dib) && (handle)) { + BOOL bSuccess; + opj_cparameters_t parameters; // compression parameters + opj_event_mgr_t event_mgr; // event manager + opj_image_t *image = NULL; // image to encode + opj_cinfo_t* cinfo = NULL; // codec context + opj_cio_t *cio = NULL; // memory byte stream + + // configure the event callbacks + memset(&event_mgr, 0, sizeof(opj_event_mgr_t)); + event_mgr.error_handler = jp2_error_callback; + event_mgr.warning_handler = jp2_warning_callback; + event_mgr.info_handler = NULL; + + // set encoding parameters to default values + opj_set_default_encoder_parameters(¶meters); + + parameters.tcp_numlayers = 0; + // if no rate entered, apply a 16:1 rate by default + if(flags == JP2_DEFAULT) { + parameters.tcp_rates[0] = (float)16; + } else { + // for now, the flags parameter is only used to specify the rate + parameters.tcp_rates[0] = (float)flags; + } + parameters.tcp_numlayers++; + parameters.cp_disto_alloc = 1; + + try { + // convert the dib to a OpenJPEG image + image = FIBITMAPToJ2KImage(s_format_id, dib, ¶meters); + if(!image) return FALSE; + + // decide if MCT should be used + parameters.tcp_mct = (image->numcomps == 3) ? 1 : 0; + + // encode the destination image + + // get a J2K compressor handle + cinfo = opj_create_compress(CODEC_JP2); + + // catch events using our callbacks + opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, NULL); + + // setup the encoder parameters using the current image and using user parameters + opj_setup_encoder(cinfo, ¶meters, image); + + // open a byte stream for writing, allocate memory for all tiles + cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0); + + // encode the image + bSuccess = opj_encode(cinfo, cio, image, NULL/*parameters.index*/); + if (!bSuccess) { + throw "Failed to encode image"; + } + int codestream_length = cio_tell(cio); + + // write the buffer to user's IO handle + io->write_proc(cio->buffer, 1, codestream_length, handle); + + // close and free the byte stream + opj_cio_close(cio); + + // free remaining compression structures + opj_destroy_compress(cinfo); + + // free image data + opj_image_destroy(image); + + return TRUE; + + } catch (const char *text) { + if(cio) opj_cio_close(cio); + if(cinfo) opj_destroy_compress(cinfo); + if(image) opj_image_destroy(image); + FreeImage_OutputMessageProc(s_format_id, text); + return FALSE; + } + } + + return FALSE; +} + +// ========================================================== +// Init +// ========================================================== + +void DLL_CALLCONV +InitJP2(Plugin *plugin, int format_id) { + s_format_id = format_id; + + plugin->format_proc = Format; + plugin->description_proc = Description; + plugin->extension_proc = Extension; + plugin->regexpr_proc = RegExpr; + plugin->open_proc = Open; + plugin->close_proc = Close; + plugin->pagecount_proc = NULL; + plugin->pagecapability_proc = NULL; + plugin->load_proc = Load; + plugin->save_proc = Save; + plugin->validate_proc = Validate; + plugin->mime_proc = MimeType; + plugin->supports_export_bpp_proc = SupportsExportDepth; + plugin->supports_export_type_proc = SupportsExportType; + plugin->supports_icc_profiles_proc = NULL; +} diff --git a/plugins/AdvaImg/src/FreeImage/PluginJPEG.cpp b/plugins/AdvaImg/src/FreeImage/PluginJPEG.cpp index b69ace95bc..b3bc9f27f3 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginJPEG.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginJPEG.cpp @@ -757,7 +757,7 @@ read_markers(j_decompress_ptr cinfo, FIBITMAP *dib) { continue; } if(memcmp(marker->data, "JFXX" , 5) == 0) { - if (!cinfo->saw_JFIF_marker || cinfo->JFIF_minor_version < 2) { + if(!cinfo->saw_JFIF_marker || cinfo->JFIF_minor_version < 2) { FreeImage_OutputMessageProc(s_format_id, "Warning: non-standard JFXX segment"); } jpeg_read_jfxx(dib, marker->data, marker->data_length); @@ -785,7 +785,7 @@ read_markers(j_decompress_ptr cinfo, FIBITMAP *dib) { BYTE *icc_profile = NULL; unsigned icc_length = 0; - if ( jpeg_read_icc_profile(cinfo, &icc_profile, &icc_length)) { + if( jpeg_read_icc_profile(cinfo, &icc_profile, &icc_length) ) { // copy ICC profile data FreeImage_CreateICCProfile(dib, icc_profile, icc_length); // clean up @@ -995,11 +995,11 @@ static BOOL jpeg_write_jfxx(j_compress_ptr cinfo, FIBITMAP *dib) { // get the thumbnail to be stored FIBITMAP* thumbnail = FreeImage_GetThumbnail(dib); - if (!thumbnail) { + if(!thumbnail) { return TRUE; } // check for a compatible output format - if ((FreeImage_GetImageType(thumbnail) != FIT_BITMAP) || (FreeImage_GetBPP(thumbnail) != 8) && (FreeImage_GetBPP(thumbnail) != 24)) { + if((FreeImage_GetImageType(thumbnail) != FIT_BITMAP) || (FreeImage_GetBPP(thumbnail) != 8) && (FreeImage_GetBPP(thumbnail) != 24)) { FreeImage_OutputMessageProc(s_format_id, FI_MSG_WARNING_INVALID_THUMBNAIL); return FALSE; } @@ -1319,30 +1319,35 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { cinfo.do_fancy_upsampling = FALSE; } + if ((flags & JPEG_GREYSCALE) == JPEG_GREYSCALE) { + // force loading as a 8-bit greyscale image + cinfo.out_color_space = JCS_GRAYSCALE; + } + // step 5a: start decompressor and calculate output width and height jpeg_start_decompress(&cinfo); // step 5b: allocate dib and init header - if ((cinfo.num_components == 4) && (cinfo.out_color_space == JCS_CMYK)) { + if((cinfo.output_components == 4) && (cinfo.out_color_space == JCS_CMYK)) { // CMYK image - if ((flags & JPEG_CMYK) == JPEG_CMYK) { + if((flags & JPEG_CMYK) == JPEG_CMYK) { // load as CMYK dib = FreeImage_AllocateHeader(header_only, cinfo.output_width, cinfo.output_height, 32, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); - if (!dib) throw FI_MSG_ERROR_DIB_MEMORY; + if(!dib) throw FI_MSG_ERROR_DIB_MEMORY; FreeImage_GetICCProfile(dib)->flags |= FIICC_COLOR_IS_CMYK; } else { // load as CMYK and convert to RGB dib = FreeImage_AllocateHeader(header_only, cinfo.output_width, cinfo.output_height, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); - if (!dib) throw FI_MSG_ERROR_DIB_MEMORY; + if(!dib) throw FI_MSG_ERROR_DIB_MEMORY; } } else { // RGB or greyscale image - dib = FreeImage_AllocateHeader(header_only, cinfo.output_width, cinfo.output_height, 8 * cinfo.num_components, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); - if (!dib) throw FI_MSG_ERROR_DIB_MEMORY; + dib = FreeImage_AllocateHeader(header_only, cinfo.output_width, cinfo.output_height, 8 * cinfo.output_components, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); + if(!dib) throw FI_MSG_ERROR_DIB_MEMORY; - if (cinfo.num_components == 1) { + if (cinfo.output_components == 1) { // build a greyscale palette RGBQUAD *colors = FreeImage_GetPalette(dib); @@ -1385,7 +1390,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { // step 7a: while (scan lines remain to be read) jpeg_read_scanlines(...); - if ((cinfo.out_color_space == JCS_CMYK) && ((flags & JPEG_CMYK) != JPEG_CMYK)) { + if((cinfo.out_color_space == JCS_CMYK) && ((flags & JPEG_CMYK) != JPEG_CMYK)) { // convert from CMYK to RGB JSAMPARRAY buffer; // output row buffer @@ -1411,7 +1416,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { dst += 3; } } - } else if ((cinfo.out_color_space == JCS_CMYK) && ((flags & JPEG_CMYK) == JPEG_CMYK)) { + } else if((cinfo.out_color_space == JCS_CMYK) && ((flags & JPEG_CMYK) == JPEG_CMYK)) { // convert from LibJPEG CMYK to standard CMYK JSAMPARRAY buffer; // output row buffer @@ -1466,7 +1471,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { jpeg_destroy_decompress(&cinfo); // check for automatic Exif rotation - if (!header_only && ((flags & JPEG_EXIFROTATE) == JPEG_EXIFROTATE)) { + if(!header_only && ((flags & JPEG_EXIFROTATE) == JPEG_EXIFROTATE)) { rotate_exif(&dib); } @@ -1560,12 +1565,12 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void jpeg_set_defaults(&cinfo); // progressive-JPEG support - if ((flags & JPEG_PROGRESSIVE) == JPEG_PROGRESSIVE) { + if((flags & JPEG_PROGRESSIVE) == JPEG_PROGRESSIVE) { jpeg_simple_progression(&cinfo); } // compute optimal Huffman coding tables for the image - if ((flags & JPEG_OPTIMIZE) == JPEG_OPTIMIZE) { + if((flags & JPEG_OPTIMIZE) == JPEG_OPTIMIZE) { cinfo.optimize_coding = TRUE; } @@ -1590,7 +1595,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void // set subsampling options if required if(cinfo.in_color_space == JCS_RGB) { - if ((flags & JPEG_SUBSAMPLING_411) == JPEG_SUBSAMPLING_411) { + if((flags & JPEG_SUBSAMPLING_411) == JPEG_SUBSAMPLING_411) { // 4:1:1 (4x1 1x1 1x1) - CrH 25% - CbH 25% - CrV 100% - CbV 100% // the horizontal color resolution is quartered cinfo.comp_info[0].h_samp_factor = 4; // Y @@ -1599,7 +1604,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void cinfo.comp_info[1].v_samp_factor = 1; cinfo.comp_info[2].h_samp_factor = 1; // Cr cinfo.comp_info[2].v_samp_factor = 1; - } else if ((flags & JPEG_SUBSAMPLING_420) == JPEG_SUBSAMPLING_420) { + } else if((flags & JPEG_SUBSAMPLING_420) == JPEG_SUBSAMPLING_420) { // 4:2:0 (2x2 1x1 1x1) - CrH 50% - CbH 50% - CrV 50% - CbV 50% // the chrominance resolution in both the horizontal and vertical directions is cut in half cinfo.comp_info[0].h_samp_factor = 2; // Y @@ -1608,7 +1613,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void cinfo.comp_info[1].v_samp_factor = 1; cinfo.comp_info[2].h_samp_factor = 1; // Cr cinfo.comp_info[2].v_samp_factor = 1; - } else if ((flags & JPEG_SUBSAMPLING_422) == JPEG_SUBSAMPLING_422){ //2x1 (low) + } else if((flags & JPEG_SUBSAMPLING_422) == JPEG_SUBSAMPLING_422){ //2x1 (low) // 4:2:2 (2x1 1x1 1x1) - CrH 50% - CbH 50% - CrV 100% - CbV 100% // half of the horizontal resolution in the chrominance is dropped (Cb & Cr), // while the full resolution is retained in the vertical direction, with respect to the luminance @@ -1619,7 +1624,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void cinfo.comp_info[2].h_samp_factor = 1; // Cr cinfo.comp_info[2].v_samp_factor = 1; } - else if ((flags & JPEG_SUBSAMPLING_444) == JPEG_SUBSAMPLING_444){ //1x1 (no subsampling) + else if((flags & JPEG_SUBSAMPLING_444) == JPEG_SUBSAMPLING_444){ //1x1 (no subsampling) // 4:4:4 (1x1 1x1 1x1) - CrH 100% - CbH 100% - CrV 100% - CbV 100% // the resolution of chrominance information (Cb & Cr) is preserved // at the same rate as the luminance (Y) information diff --git a/plugins/AdvaImg/src/FreeImage/PluginPCD.cpp b/plugins/AdvaImg/src/FreeImage/PluginPCD.cpp index 87cbe967b2..ff0c5b8679 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginPCD.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginPCD.cpp @@ -155,7 +155,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { try { // allocate the dib and write out the header dib = FreeImage_AllocateHeader(header_only, width, height, bpp, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); - if (!dib) throw FI_MSG_ERROR_DIB_MEMORY; + if(!dib) throw FI_MSG_ERROR_DIB_MEMORY; if(header_only) { return dib; @@ -173,7 +173,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { BYTE *y1 = (BYTE*)malloc(width * sizeof(BYTE)); BYTE *y2 = (BYTE*)malloc(width * sizeof(BYTE)); BYTE *cbcr = (BYTE*)malloc(width * sizeof(BYTE)); - if (!y1 || !y2 || !cbcr) throw FI_MSG_ERROR_MEMORY; + if(!y1 || !y2 || !cbcr) throw FI_MSG_ERROR_MEMORY; BYTE *yl[] = { y1, y2 }; diff --git a/plugins/AdvaImg/src/FreeImage/PluginPCX.cpp b/plugins/AdvaImg/src/FreeImage/PluginPCX.cpp index a6feb5fea7..cd75629ddc 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginPCX.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginPCX.cpp @@ -84,9 +84,9 @@ pcx_validate(FreeImageIO *io, fi_handle handle) { // version if(signature[1] <= 5) { // encoding - if ((signature[2] == 0) || (signature[2] == 1)) { + if((signature[2] == 0) || (signature[2] == 1)) { // bits per pixel per plane - if ((signature[3] == 1) || (signature[3] == 8)) { + if((signature[3] == 1) || (signature[3] == 8)) { return TRUE; } } @@ -339,7 +339,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { BYTE *ReadBuf = NULL; // buffer; BOOL bIsRLE; // True if the file is run-length encoded - if (!handle) { + if(!handle) { return NULL; } @@ -351,7 +351,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { long start_pos = io->tell_proc(handle); BOOL validated = pcx_validate(io, handle); io->seek_proc(handle, start_pos, SEEK_SET); - if (!validated) { + if(!validated) { throw FI_MSG_ERROR_MAGIC_NUMBER; } @@ -478,10 +478,10 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { // --------------- line = (BYTE*)malloc(linelength * sizeof(BYTE)); - if (!line) throw FI_MSG_ERROR_MEMORY; + if(!line) throw FI_MSG_ERROR_MEMORY; ReadBuf = (BYTE*)malloc(IO_BUF_SIZE * sizeof(BYTE)); - if (!ReadBuf) throw FI_MSG_ERROR_MEMORY; + if(!ReadBuf) throw FI_MSG_ERROR_MEMORY; bits = FreeImage_GetScanLine(dib, height - 1); @@ -513,7 +513,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { unsigned x, y, written; buffer = (BYTE*)malloc(width * sizeof(BYTE)); - if (!buffer) throw FI_MSG_ERROR_MEMORY; + if(!buffer) throw FI_MSG_ERROR_MEMORY; for (y = 0; y < height; y++) { written = readline(*io, handle, line, linelength, bIsRLE, ReadBuf, &ReadPos); @@ -553,7 +553,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { free(buffer); - } else if ((header.planes == 3) && (header.bpp == 8)) { + } else if((header.planes == 3) && (header.bpp == 8)) { BYTE *pline; for (unsigned y = 0; y < height; y++) { diff --git a/plugins/AdvaImg/src/FreeImage/PluginPFM.cpp b/plugins/AdvaImg/src/FreeImage/PluginPFM.cpp index 8ccbd48ba5..231e8baa22 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginPFM.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginPFM.cpp @@ -48,7 +48,7 @@ pfm_get_line(FreeImageIO *io, fi_handle handle, char *buffer, int length) { int i; memset(buffer, 0, length); for(i = 0; i < length; i++) { - if (!io->read_proc(&buffer[i], 1, 1, handle)) + if(!io->read_proc(&buffer[i], 1, 1, handle)) return FALSE; if(buffer[i] == 0x0A) break; @@ -67,7 +67,7 @@ pfm_get_int(FreeImageIO *io, fi_handle handle) { // skip forward to start of next number - if (!io->read_proc(&c, 1, 1, handle)) throw FI_MSG_ERROR_PARSING; + if(!io->read_proc(&c, 1, 1, handle)) throw FI_MSG_ERROR_PARSING; while (1) { // eat comments @@ -78,7 +78,7 @@ pfm_get_int(FreeImageIO *io, fi_handle handle) { firstchar = TRUE; while (1) { - if (!io->read_proc(&c, 1, 1, handle)) throw FI_MSG_ERROR_PARSING; + if(!io->read_proc(&c, 1, 1, handle)) throw FI_MSG_ERROR_PARSING; if (firstchar && c == ' ') { // loop off 1 sp after # @@ -96,7 +96,7 @@ pfm_get_int(FreeImageIO *io, fi_handle handle) { break; } - if (!io->read_proc(&c, 1, 1, handle)) throw FI_MSG_ERROR_PARSING; + if(!io->read_proc(&c, 1, 1, handle)) throw FI_MSG_ERROR_PARSING; } // we're at the start of a number, continue until we hit a non-number @@ -106,7 +106,7 @@ pfm_get_int(FreeImageIO *io, fi_handle handle) { while (1) { i = (i * 10) + (c - '0'); - if (!io->read_proc(&c, 1, 1, handle)) throw FI_MSG_ERROR_PARSING; + if(!io->read_proc(&c, 1, 1, handle)) throw FI_MSG_ERROR_PARSING; if (c < '0' || c > '9') break; @@ -231,7 +231,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { if(bResult) { bResult = (sscanf(line_buffer, "%f", &scalefactor) == 1) ? TRUE : FALSE; } - if (!bResult) { + if(!bResult) { throw "Read error: invalid PFM header"; } @@ -251,7 +251,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { if(image_type == FIT_RGBF) { const unsigned lineWidth = 3 * width; lineBuffer = (float*)malloc(lineWidth * sizeof(float)); - if (!lineBuffer) { + if(!lineBuffer) { throw FI_MSG_ERROR_MEMORY; } @@ -285,7 +285,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { } else if(image_type == FIT_FLOAT) { const unsigned lineWidth = width; lineBuffer = (float*)malloc(lineWidth * sizeof(float)); - if (!lineBuffer) { + if(!lineBuffer) { throw FI_MSG_ERROR_MEMORY; } @@ -330,10 +330,10 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { static BOOL DLL_CALLCONV Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data) { - if (!dib || !handle) return FALSE; + if(!dib || !handle) return FALSE; FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(dib); - if ((image_type != FIT_RGBF) && (image_type != FIT_FLOAT)) { + if((image_type != FIT_RGBF) && (image_type != FIT_FLOAT)) { return FALSE; } diff --git a/plugins/AdvaImg/src/FreeImage/PluginPICT.cpp b/plugins/AdvaImg/src/FreeImage/PluginPICT.cpp index 0c44cb2d1f..99958a489c 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginPICT.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginPICT.cpp @@ -1168,7 +1168,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { // io->seek_proc( handle, 122, SEEK_CUR ); // found = TRUE; BYTE data[ 2 ]; - if ( io->read_proc( data, 2, 1, handle ) ) { + if( io->read_proc( data, 2, 1, handle ) ) { io->seek_proc( handle, -2, SEEK_CUR ); if ( data[0] == 0xFF && data[1] == 0xD8 ) { diff --git a/plugins/AdvaImg/src/FreeImage/PluginPNG.cpp b/plugins/AdvaImg/src/FreeImage/PluginPNG.cpp index ad398a87e8..27fb545161 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginPNG.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginPNG.cpp @@ -104,7 +104,7 @@ ReadMetadata(png_structp png_ptr, png_infop info_ptr, FIBITMAP *dib) { for(int i = 0; i < num_text; i++) { // create a tag tag = FreeImage_CreateTag(); - if (!tag) return FALSE; + if(!tag) return FALSE; DWORD tag_length = (DWORD) MAX(text_ptr[i].text_length, text_ptr[i].itxt_length); @@ -354,7 +354,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { } #ifndef FREEIMAGE_BIGENDIAN - if ((image_type == FIT_UINT16) || (image_type == FIT_RGB16) || (image_type == FIT_RGBA16)) { + if((image_type == FIT_UINT16) || (image_type == FIT_RGB16) || (image_type == FIT_RGBA16)) { // turn on 16 bit byte swapping png_set_swap(png_ptr); } @@ -503,7 +503,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { png_get_tRNS(png_ptr, info_ptr, &trans_alpha, &num_trans, &trans_color); - if ((color_type == PNG_COLOR_TYPE_GRAY) && trans_color) { + if((color_type == PNG_COLOR_TYPE_GRAY) && trans_color) { // single transparent color if (trans_color->gray < palette_entries) { BYTE table[256]; @@ -511,7 +511,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { table[trans_color->gray] = 0; FreeImage_SetTransparencyTable(dib, table, palette_entries); } - } else if ((color_type == PNG_COLOR_TYPE_PALETTE) && trans_alpha) { + } else if((color_type == PNG_COLOR_TYPE_PALETTE) && trans_alpha) { // transparency table FreeImage_SetTransparencyTable(dib, (BYTE *)trans_alpha, num_trans); } @@ -726,7 +726,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void pixel_depth = FreeImage_GetBPP(dib); BOOL bInterlaced = FALSE; - if ( (flags & PNG_INTERLACED) == PNG_INTERLACED) { + if( (flags & PNG_INTERLACED) == PNG_INTERLACED) { interlace_type = PNG_INTERLACE_ADAM7; bInterlaced = TRUE; } else { @@ -735,9 +735,9 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void // set the ZLIB compression level or default to PNG default compression level (ZLIB level = 6) int zlib_level = flags & 0x0F; - if ((zlib_level >= 1) && (zlib_level <= 9)) { + if((zlib_level >= 1) && (zlib_level <= 9)) { png_set_compression_level(png_ptr, zlib_level); - } else if ((flags & PNG_Z_NO_COMPRESSION) == PNG_Z_NO_COMPRESSION) { + } else if((flags & PNG_Z_NO_COMPRESSION) == PNG_Z_NO_COMPRESSION) { png_set_compression_level(png_ptr, Z_NO_COMPRESSION); } @@ -758,17 +758,27 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void bit_depth = 16; } + // check for transparent images + BOOL bIsTransparent = + (image_type == FIT_BITMAP) && FreeImage_IsTransparent(dib) && (FreeImage_GetTransparencyCount(dib) > 0) ? TRUE : FALSE; + switch (FreeImage_GetColorType(dib)) { case FIC_MINISWHITE: - // Invert monochrome files to have 0 as black and 1 as white (no break here) - png_set_invert_mono(png_ptr); + if(!bIsTransparent) { + // Invert monochrome files to have 0 as black and 1 as white (no break here) + png_set_invert_mono(png_ptr); + } + // (fall through) case FIC_MINISBLACK: - png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, - PNG_COLOR_TYPE_GRAY, interlace_type, - PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - - break; + if(!bIsTransparent) { + png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, + PNG_COLOR_TYPE_GRAY, interlace_type, + PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + break; + } + // If a monochrome image is transparent, save it with a palette + // (fall through) case FIC_PALETTE: { @@ -846,7 +856,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void // set the transparency table - if (FreeImage_IsTransparent(dib) && (FreeImage_GetTransparencyCount(dib) > 0)) { + if (bIsTransparent) { png_set_tRNS(png_ptr, info_ptr, FreeImage_GetTransparencyTable(dib), FreeImage_GetTransparencyCount(dib), NULL); } diff --git a/plugins/AdvaImg/src/FreeImage/PluginPNM.cpp b/plugins/AdvaImg/src/FreeImage/PluginPNM.cpp index a30f858851..3155315559 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginPNM.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginPNM.cpp @@ -37,7 +37,7 @@ GetInt(FreeImageIO *io, fi_handle handle) { // skip forward to start of next number - if (!io->read_proc(&c, 1, 1, handle)) throw FI_MSG_ERROR_PARSING; + if(!io->read_proc(&c, 1, 1, handle)) throw FI_MSG_ERROR_PARSING; while (1) { // eat comments @@ -48,7 +48,7 @@ GetInt(FreeImageIO *io, fi_handle handle) { firstchar = TRUE; while (1) { - if (!io->read_proc(&c, 1, 1, handle)) throw FI_MSG_ERROR_PARSING; + if(!io->read_proc(&c, 1, 1, handle)) throw FI_MSG_ERROR_PARSING; if (firstchar && c == ' ') { // loop off 1 sp after # @@ -66,7 +66,7 @@ GetInt(FreeImageIO *io, fi_handle handle) { break; } - if (!io->read_proc(&c, 1, 1, handle)) throw FI_MSG_ERROR_PARSING; + if(!io->read_proc(&c, 1, 1, handle)) throw FI_MSG_ERROR_PARSING; } // we're at the start of a number, continue until we hit a non-number @@ -76,7 +76,7 @@ GetInt(FreeImageIO *io, fi_handle handle) { while (1) { i = (i * 10) + (c - '0'); - if (!io->read_proc(&c, 1, 1, handle)) throw FI_MSG_ERROR_PARSING; + if(!io->read_proc(&c, 1, 1, handle)) throw FI_MSG_ERROR_PARSING; if (c < '0' || c > '9') break; @@ -239,9 +239,9 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { int height = GetInt(io, handle); int maxval = 1; - if ((id_two == '2') || (id_two == '5') || (id_two == '3') || (id_two == '6')) { + if((id_two == '2') || (id_two == '5') || (id_two == '3') || (id_two == '6')) { maxval = GetInt(io, handle); - if ((maxval <= 0) || (maxval > 65535)) { + if((maxval <= 0) || (maxval > 65535)) { FreeImage_OutputMessageProc(s_format_id, "Invalid max value : %d", maxval); throw (const char*)NULL; } @@ -539,7 +539,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void char buffer[256]; // temporary buffer whose size should be enough for what we need - if (!dib || !handle) return FALSE; + if(!dib || !handle) return FALSE; FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(dib); diff --git a/plugins/AdvaImg/src/FreeImage/PluginRAS.cpp b/plugins/AdvaImg/src/FreeImage/PluginRAS.cpp index 08fc0c9e17..08fd558450 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginRAS.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginRAS.cpp @@ -203,7 +203,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { BYTE *bits; // Pointer to dib data WORD x, y; - if (!handle) { + if(!handle) { return NULL; } @@ -309,7 +309,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { // Read SUN raster colormap int numcolors = 1 << header.depth; - if ((DWORD)(3 * numcolors) > header.maplength) { + if((DWORD)(3 * numcolors) > header.maplength) { // some RAS may have less colors than the full palette numcolors = header.maplength / 3; } else { diff --git a/plugins/AdvaImg/src/FreeImage/PluginRAW.cpp b/plugins/AdvaImg/src/FreeImage/PluginRAW.cpp index 4611824f4d..bf5d82169c 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginRAW.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginRAW.cpp @@ -44,56 +44,63 @@ private: FreeImageIO *_io; fi_handle _handle; long _eof; + INT64 _fsize; public: LibRaw_freeimage_datastream(FreeImageIO *io, fi_handle handle) : _io(io), _handle(handle) { long start_pos = io->tell_proc(handle); io->seek_proc(handle, 0, SEEK_END); _eof = io->tell_proc(handle); + _fsize = _eof - start_pos; io->seek_proc(handle, start_pos, SEEK_SET); } + ~LibRaw_freeimage_datastream() { } - virtual void * make_jas_stream() { - return NULL; - } - virtual int valid() { + + int valid() { return (_io && _handle); } - virtual int read(void *buffer, size_t size, size_t count) { + + int read(void *buffer, size_t size, size_t count) { if(substream) return substream->read(buffer, size, count); return _io->read_proc(buffer, (unsigned)size, (unsigned)count, _handle); - } - virtual int eof() { - if(substream) return substream->eof(); - return (_io->tell_proc(_handle) >= _eof); - } - virtual int seek(INT64 offset, int origin) { + } + + int seek(INT64 offset, int origin) { if(substream) return substream->seek(offset, origin); return _io->seek_proc(_handle, (long)offset, origin); - } - virtual INT64 tell() { + } + + INT64 tell() { if(substream) return substream->tell(); return _io->tell_proc(_handle); } - virtual int get_char() { + + INT64 size() { + return _fsize; + } + + int get_char() { int c = 0; if(substream) return substream->get_char(); - if (!_io->read_proc(&c, 1, 1, _handle)) return -1; + if(!_io->read_proc(&c, 1, 1, _handle)) return -1; return c; } - virtual char* gets(char *buffer, int length) { + + char* gets(char *buffer, int length) { if (substream) return substream->gets(buffer, length); memset(buffer, 0, length); for(int i = 0; i < length; i++) { - if (!_io->read_proc(&buffer[i], 1, 1, _handle)) + if(!_io->read_proc(&buffer[i], 1, 1, _handle)) return NULL; if(buffer[i] == 0x0A) break; } return buffer; } - virtual int scanf_one(const char *fmt, void* val) { + + int scanf_one(const char *fmt, void* val) { std::string buffer; char element = 0; bool bDone = false; @@ -118,6 +125,15 @@ public: return sscanf(buffer.c_str(), fmt, val); } + + int eof() { + if(substream) return substream->eof(); + return (_io->tell_proc(_handle) >= _eof); + } + + void * make_jas_stream() { + return NULL; + } }; // ---------------------------------------------------------- @@ -137,7 +153,7 @@ libraw_ConvertToDib(libraw_processed_image_t *image) { if(bpp == 16) { // allocate output dib dib = FreeImage_AllocateT(FIT_RGB16, width, height); - if (!dib) { + if(!dib) { throw FI_MSG_ERROR_DIB_MEMORY; } // write data @@ -154,7 +170,7 @@ libraw_ConvertToDib(libraw_processed_image_t *image) { } else if(bpp == 8) { // allocate output dib dib = FreeImage_AllocateT(FIT_BITMAP, width, height, 24); - if (!dib) { + if(!dib) { throw FI_MSG_ERROR_DIB_MEMORY; } // write data @@ -184,20 +200,20 @@ Get the embedded JPEG preview image from RAW picture with included Exif Data. @return Returns the loaded dib if successfull, returns NULL otherwise */ static FIBITMAP * -libraw_LoadEmbeddedPreview(LibRaw& RawProcessor, int flags) { +libraw_LoadEmbeddedPreview(LibRaw *RawProcessor, int flags) { FIBITMAP *dib = NULL; libraw_processed_image_t *thumb_image = NULL; try { // unpack data - if(RawProcessor.unpack_thumb() != LIBRAW_SUCCESS) { + if(RawProcessor->unpack_thumb() != LIBRAW_SUCCESS) { // run silently "LibRaw : failed to run unpack_thumb" return NULL; } // retrieve thumb image int error_code = 0; - thumb_image = RawProcessor.dcraw_make_mem_thumb(&error_code); + thumb_image = RawProcessor->dcraw_make_mem_thumb(&error_code); if(thumb_image) { if(thumb_image->type != LIBRAW_IMAGE_BITMAP) { // attach the binary data to a memory stream @@ -221,14 +237,14 @@ libraw_LoadEmbeddedPreview(LibRaw& RawProcessor, int flags) { } // clean-up and return - RawProcessor.dcraw_clear_mem(thumb_image); + RawProcessor->dcraw_clear_mem(thumb_image); return dib; } catch(const char *text) { // clean-up and return if(thumb_image) { - RawProcessor.dcraw_clear_mem(thumb_image); + RawProcessor->dcraw_clear_mem(thumb_image); } if(text != NULL) { FreeImage_OutputMessageProc(s_format_id, text); @@ -244,7 +260,7 @@ Load raw data and convert to FIBITMAP @return Returns the loaded dib if successfull, returns NULL otherwise */ static FIBITMAP * -libraw_LoadRawData(LibRaw& RawProcessor, int bitspersample) { +libraw_LoadRawData(LibRaw *RawProcessor, int bitspersample) { FIBITMAP *dib = NULL; libraw_processed_image_t *processed_image = NULL; @@ -253,39 +269,39 @@ libraw_LoadRawData(LibRaw& RawProcessor, int bitspersample) { // ----------------------- // (-6) 16-bit or 8-bit - RawProcessor.imgdata.params.output_bps = bitspersample; + RawProcessor->imgdata.params.output_bps = bitspersample; // (-g power toe_slope) if(bitspersample == 16) { // set -g 1 1 for linear curve - RawProcessor.imgdata.params.gamm[0] = 1; - RawProcessor.imgdata.params.gamm[1] = 1; + RawProcessor->imgdata.params.gamm[0] = 1; + RawProcessor->imgdata.params.gamm[1] = 1; } else if(bitspersample == 8) { // by default settings for rec. BT.709 are used: power 2.222 (i.e. gamm[0]=1/2.222) and slope 4.5 - RawProcessor.imgdata.params.gamm[0] = 1/2.222; - RawProcessor.imgdata.params.gamm[1] = 4.5; + RawProcessor->imgdata.params.gamm[0] = 1/2.222; + RawProcessor->imgdata.params.gamm[1] = 4.5; } // (-W) Don't use automatic increase of brightness by histogram - RawProcessor.imgdata.params.no_auto_bright = 1; + RawProcessor->imgdata.params.no_auto_bright = 1; // (-a) Use automatic white balance obtained after averaging over the entire image - RawProcessor.imgdata.params.use_auto_wb = 1; + RawProcessor->imgdata.params.use_auto_wb = 1; // (-q 3) Adaptive homogeneity-directed demosaicing algorithm (AHD) - RawProcessor.imgdata.params.user_qual = 3; + RawProcessor->imgdata.params.user_qual = 3; // ----------------------- // unpack data - if(RawProcessor.unpack() != LIBRAW_SUCCESS) { + if(RawProcessor->unpack() != LIBRAW_SUCCESS) { throw "LibRaw : failed to unpack data"; } // process data (... most consuming task ...) - if(RawProcessor.dcraw_process() != LIBRAW_SUCCESS) { + if(RawProcessor->dcraw_process() != LIBRAW_SUCCESS) { throw "LibRaw : failed to process data"; } // retrieve processed image int error_code = 0; - processed_image = RawProcessor.dcraw_make_mem_image(&error_code); + processed_image = RawProcessor->dcraw_make_mem_image(&error_code); if(processed_image) { // type SHOULD be LIBRAW_IMAGE_BITMAP, but we'll check if(processed_image->type != LIBRAW_IMAGE_BITMAP) { @@ -303,14 +319,14 @@ libraw_LoadRawData(LibRaw& RawProcessor, int bitspersample) { dib = libraw_ConvertToDib(processed_image); // clean-up and return - RawProcessor.dcraw_clear_mem(processed_image); + RawProcessor->dcraw_clear_mem(processed_image); return dib; } catch(const char *text) { // clean-up and return if(processed_image) { - RawProcessor.dcraw_clear_mem(processed_image); + RawProcessor->dcraw_clear_mem(processed_image); } FreeImage_OutputMessageProc(s_format_id, text); } @@ -396,23 +412,92 @@ MimeType() { return "image/x-dcraw"; } +static BOOL +HasMagicHeader(FreeImageIO *io, fi_handle handle) { + const unsigned signature_size = 32; + BYTE signature[signature_size] = { 0 }; + + // Canon (CR2), Intel byte order + const BYTE CR2_II[] = { 0x49, 0x49, 0x2A, 0x00, 0x10, 0x00, 0x00, 0x00, 0x43, 0x52, 0x02, 0x00 }; + // Canon (CR2), Motorola byte order + const BYTE CR2_MM[] = { 0x4D, 0x4D, 0x2A, 0x00, 0x10, 0x00, 0x00, 0x00, 0x43, 0x52, 0x02, 0x00 }; + // Canon (CRW), Intel byte order + const BYTE CRW_II[] = { 0x49, 0x49, 0x1A, 0x00, 0x00, 0x00, 0x48, 0x45, 0x41, 0x50, 0x43, 0x43, 0x44, 0x52, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + // Minolta (MRW) + const BYTE MRW[] = { 0x00, 0x4D, 0x52, 0x4D, 0x00 }; + // Olympus (ORF), Intel byte order + const BYTE ORF_IIRS[] = { 0x49, 0x49, 0x52, 0x53, 0x08, 0x00, 0x00, 0x00 }; + const BYTE ORF_IIRO[] = { 0x49, 0x49, 0x52, 0x4F, 0x08, 0x00, 0x00, 0x00 }; + // Olympus (ORF), Motorola byte order + const BYTE ORF_MMOR[] = { 0x4D, 0x4D, 0x4F, 0x52, 0x00, 0x00, 0x00, 0x08 }; + // Fujifilm (RAF) + const BYTE RAF[] = { 0x46, 0x55, 0x4A, 0x49, 0x46, 0x49, 0x4C, 0x4D, 0x43, 0x43, 0x44, 0x2D, 0x52, 0x41, 0x57, 0x20, 0x30, 0x32, 0x30, 0x31 }; + // Panasonic (RW2) or Leica (RWL) + const BYTE RW2_II[] = { 0x49, 0x49, 0x55, 0x00, 0x18, 0x00, 0x00, 0x00, 0x88, 0xE7, 0x74, 0xD8, 0xF8, 0x25, 0x1D, 0x4D, 0x94, 0x7A, 0x6E, 0x77, 0x82, 0x2B, 0x5D, 0x6A }; + + if(io->read_proc(signature, 1, signature_size, handle) != signature_size) { + return FALSE; + } + if(memcmp(CR2_II, signature, 12) == 0) + return TRUE; + if(memcmp(CR2_MM, signature, 12) == 0) + return TRUE; + if(memcmp(CRW_II, signature, 26) == 0) + return TRUE; + if(memcmp(MRW, signature, 5) == 0) + return TRUE; + if(memcmp(ORF_IIRS, signature, 8) == 0) + return TRUE; + if(memcmp(ORF_IIRO, signature, 8) == 0) + return TRUE; + if(memcmp(ORF_MMOR, signature, 8) == 0) + return TRUE; + if(memcmp(RAF, signature, 20) == 0) + return TRUE; + if(memcmp(RW2_II, signature, 24) == 0) + return TRUE; + + return FALSE; +} + static BOOL DLL_CALLCONV Validate(FreeImageIO *io, fi_handle handle) { - LibRaw RawProcessor; - BOOL bSuccess = TRUE; - - // wrap the input datastream - LibRaw_freeimage_datastream datastream(io, handle); - - // open the datastream - if(RawProcessor.open_datastream(&datastream) != LIBRAW_SUCCESS) { - bSuccess = FALSE; // LibRaw : failed to open input stream (unknown format) + // some RAW files have a magic signature (most of them have a TIFF signature) + // try to check this in order to speed up the file identification + { + long tell = io->tell_proc(handle); + if( HasMagicHeader(io, handle) ) { + return TRUE; + } else { + io->seek_proc(handle, tell, SEEK_SET); + } } - // clean-up internal memory allocations - RawProcessor.recycle(); + // no magic signature : we need to open the file (it will take more time to identify it) + // do not declare RawProcessor on the stack as it may be huge (300 KB) + { + LibRaw *RawProcessor = new(std::nothrow) LibRaw; + + if(RawProcessor) { + BOOL bSuccess = TRUE; + + // wrap the input datastream + LibRaw_freeimage_datastream datastream(io, handle); - return bSuccess; + // open the datastream + if(RawProcessor->open_datastream(&datastream) != LIBRAW_SUCCESS) { + bSuccess = FALSE; // LibRaw : failed to open input stream (unknown format) + } + + // clean-up internal memory allocations + RawProcessor->recycle(); + delete RawProcessor; + + return bSuccess; + } + } + + return FALSE; } static BOOL DLL_CALLCONV @@ -440,11 +525,17 @@ SupportsNoPixels() { static FIBITMAP * DLL_CALLCONV Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { FIBITMAP *dib = NULL; - LibRaw RawProcessor; + LibRaw *RawProcessor = NULL; BOOL header_only = (flags & FIF_LOAD_NOPIXELS) == FIF_LOAD_NOPIXELS; try { + // do not declare RawProcessor on the stack as it may be huge (300 KB) + RawProcessor = new(std::nothrow) LibRaw; + if(!RawProcessor) { + throw FI_MSG_ERROR_MEMORY; + } + // wrap the input datastream LibRaw_freeimage_datastream datastream(io, handle); @@ -453,30 +544,30 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { // -------------------------------------------- // (-s [0..N-1]) Select one raw image from input file - RawProcessor.imgdata.params.shot_select = 0; + RawProcessor->imgdata.params.shot_select = 0; // (-w) Use camera white balance, if possible (otherwise, fallback to auto_wb) - RawProcessor.imgdata.params.use_camera_wb = 1; + RawProcessor->imgdata.params.use_camera_wb = 1; // (-h) outputs the image in 50% size - RawProcessor.imgdata.params.half_size = ((flags & RAW_HALFSIZE) == RAW_HALFSIZE) ? 1 : 0; + RawProcessor->imgdata.params.half_size = ((flags & RAW_HALFSIZE) == RAW_HALFSIZE) ? 1 : 0; // open the datastream - if(RawProcessor.open_datastream(&datastream) != LIBRAW_SUCCESS) { + if(RawProcessor->open_datastream(&datastream) != LIBRAW_SUCCESS) { throw "LibRaw : failed to open input stream (unknown format)"; } if(header_only) { // header only mode - dib = FreeImage_AllocateHeaderT(header_only, FIT_RGB16, RawProcessor.imgdata.sizes.width, RawProcessor.imgdata.sizes.height); + dib = FreeImage_AllocateHeaderT(header_only, FIT_RGB16, RawProcessor->imgdata.sizes.width, RawProcessor->imgdata.sizes.height); } - else if ((flags & RAW_PREVIEW) == RAW_PREVIEW) { + else if((flags & RAW_PREVIEW) == RAW_PREVIEW) { // try to get the embedded JPEG dib = libraw_LoadEmbeddedPreview(RawProcessor, 0); - if (!dib) { + if(!dib) { // no JPEG preview: try to load as 8-bit/sample (i.e. RGB 24-bit) dib = libraw_LoadRawData(RawProcessor, 8); } } - else if ((flags & RAW_DISPLAY) == RAW_DISPLAY) { + else if((flags & RAW_DISPLAY) == RAW_DISPLAY) { // load raw data as 8-bit/sample (i.e. RGB 24-bit) dib = libraw_LoadRawData(RawProcessor, 8); } @@ -486,8 +577,8 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { } // save ICC profile if present - if(dib && (NULL != RawProcessor.imgdata.color.profile)) { - FreeImage_CreateICCProfile(dib, RawProcessor.imgdata.color.profile, RawProcessor.imgdata.color.profile_length); + if(dib && (NULL != RawProcessor->imgdata.color.profile)) { + FreeImage_CreateICCProfile(dib, RawProcessor->imgdata.color.profile, RawProcessor->imgdata.color.profile_length); } // try to get JPEG embedded Exif metadata @@ -500,15 +591,19 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { } // clean-up internal memory allocations - RawProcessor.recycle(); + RawProcessor->recycle(); + delete RawProcessor; return dib; } catch(const char *text) { + if(RawProcessor) { + RawProcessor->recycle(); + delete RawProcessor; + } if(dib) { FreeImage_Unload(dib); } - RawProcessor.recycle(); FreeImage_OutputMessageProc(s_format_id, text); } diff --git a/plugins/AdvaImg/src/FreeImage/PluginSGI.cpp b/plugins/AdvaImg/src/FreeImage/PluginSGI.cpp index 3ac189e0ef..0fd162b1d4 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginSGI.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginSGI.cpp @@ -265,7 +265,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { // read the Offset Tables int index_len = height * zsize; pRowIndex = (LONG*)malloc(index_len * sizeof(LONG)); - if (!pRowIndex) { + if(!pRowIndex) { throw FI_MSG_ERROR_MEMORY; } @@ -282,7 +282,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { // Discard row size index for (i = 0; i < (int)(index_len * sizeof(LONG)); i++) { BYTE packed = 0; - if ( io->read_proc(&packed, sizeof(BYTE), 1, handle) < 1 ) { + if( io->read_proc(&packed, sizeof(BYTE), 1, handle) < 1 ) { throw SGI_EOF_IN_RLE_INDEX; } } @@ -307,7 +307,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { } dib = FreeImage_Allocate(width, height, bitcount); - if (!dib) { + if(!dib) { throw FI_MSG_ERROR_DIB_MEMORY; } diff --git a/plugins/AdvaImg/src/FreeImage/PluginTARGA.cpp b/plugins/AdvaImg/src/FreeImage/PluginTARGA.cpp index 4e3f1a720a..5fb1f53ee0 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginTARGA.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginTARGA.cpp @@ -176,7 +176,7 @@ FIBITMAP* TargaThumbnail::toFIBITMAP() { const unsigned line_size = _depth * _w / 8; FIBITMAP* dib = FreeImage_Allocate(_w, _h, _depth); - if (!dib) { + if(!dib) { return NULL; } @@ -1203,14 +1203,14 @@ saveRLE(FIBITMAP* dib, FreeImageIO* io, fi_handle handle) { // read next pixel from dib - if ( x + 1*pixel_size < line_size) { + if( x + 1*pixel_size < line_size) { AssignPixel(next, (bits + x + 1*pixel_size), pixel_size); } else { // last pixel in line // include current pixel and flush - if (!has_rle) { + if(!has_rle) { writeToPacket(packet, current, pixel_size); packet += pixel_size; @@ -1231,7 +1231,7 @@ saveRLE(FIBITMAP* dib, FreeImageIO* io, fi_handle handle) { // has rle - if (!has_rle) { + if(!has_rle) { // flush non rle packet flushPacket(line, pixel_size, packet_begin, packet, packet_count, has_rle); diff --git a/plugins/AdvaImg/src/FreeImage/PluginTIFF.cpp b/plugins/AdvaImg/src/FreeImage/PluginTIFF.cpp index 54f81e0938..72218a2564 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginTIFF.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginTIFF.cpp @@ -153,7 +153,7 @@ _tiffWriteProc(thandle_t handle, void *buf, tmsize_t size) { static toff_t _tiffSeekProc(thandle_t handle, toff_t off, int whence) { fi_TIFFIO *fio = (fi_TIFFIO*)handle; - fio->io->seek_proc(fio->handle, off, whence); + fio->io->seek_proc(fio->handle, (long)off, whence); return fio->io->tell_proc(fio->handle); } @@ -450,7 +450,7 @@ static FIBITMAP* CreateImageType(BOOL header_only, FREE_IMAGE_TYPE fit, int width, int height, uint16 bitspersample, uint16 samplesperpixel) { FIBITMAP *dib = NULL; - if ((width < 0) || (height < 0)) { + if((width < 0) || (height < 0)) { // check for malicious images return NULL; } @@ -462,7 +462,7 @@ CreateImageType(BOOL header_only, FREE_IMAGE_TYPE fit, int width, int height, ui if(bpp == 16) { - if ((samplesperpixel == 2) && (bitspersample == 8)) { + if((samplesperpixel == 2) && (bitspersample == 8)) { // 8-bit indexed + 8-bit alpha channel -> convert to 8-bit transparent dib = FreeImage_AllocateHeader(header_only, width, height, 8); } else { @@ -562,7 +562,7 @@ ReadImageType(TIFF *tiff, uint16 bitspersample, uint16 samplesperpixel) { break; case 48: // 3 x half float => convert to RGBF - if ((samplesperpixel == 3) && (bitspersample == 16)) { + if((samplesperpixel == 3) && (bitspersample == 16)) { fit = FIT_RGBF; } break; @@ -683,7 +683,7 @@ WriteCompression(TIFF *tiff, uint16 bitspersample, uint16 samplesperpixel, uint1 } else if ((flags & TIFF_LZW) == TIFF_LZW) { compression = COMPRESSION_LZW; } else if ((flags & TIFF_JPEG) == TIFF_JPEG) { - if (((bitsperpixel == 8) && (photometric != PHOTOMETRIC_PALETTE)) || (bitsperpixel == 24)) { + if(((bitsperpixel == 8) && (photometric != PHOTOMETRIC_PALETTE)) || (bitsperpixel == 24)) { compression = COMPRESSION_JPEG; // RowsPerStrip must be multiple of 8 for JPEG uint32 rowsperstrip = (uint32) -1; @@ -736,7 +736,7 @@ WriteCompression(TIFF *tiff, uint16 bitspersample, uint16 samplesperpixel, uint1 // and many palette-color images. But natural 24-bit color images and some 8-bit // grayscale images do much better with differencing. - if ((bitspersample == 8) || (bitspersample == 16)) { + if((bitspersample == 8) || (bitspersample == 16)) { if ((bitsperpixel >= 8) && (photometric != PHOTOMETRIC_PALETTE)) { TIFFSetField(tiff, TIFFTAG_PREDICTOR, 2); } else { @@ -746,13 +746,20 @@ WriteCompression(TIFF *tiff, uint16 bitspersample, uint16 samplesperpixel, uint1 TIFFSetField(tiff, TIFFTAG_PREDICTOR, 1); } } - else if(compression == COMPRESSION_CCITTFAX3) { - // try to be compliant with the TIFF Class F specification - // that documents the TIFF tags specific to FAX applications - // see http://palimpsest.stanford.edu/bytopic/imaging/std/tiff-f.html - uint32 group3options = GROUP3OPT_2DENCODING | GROUP3OPT_FILLBITS; - TIFFSetField(tiff, TIFFTAG_GROUP3OPTIONS, group3options); // 2d-encoded, has aligned EOL - TIFFSetField(tiff, TIFFTAG_FILLORDER, FILLORDER_LSB2MSB); // lsb-to-msb fillorder + else if((compression == COMPRESSION_CCITTFAX3) || (compression == COMPRESSION_CCITTFAX4)) { + uint32 imageLength = 0; + TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &imageLength); + // overwrite previous RowsPerStrip + TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, imageLength); + + if(compression == COMPRESSION_CCITTFAX3) { + // try to be compliant with the TIFF Class F specification + // that documents the TIFF tags specific to FAX applications + // see http://palimpsest.stanford.edu/bytopic/imaging/std/tiff-f.html + uint32 group3options = GROUP3OPT_2DENCODING | GROUP3OPT_FILLBITS; + TIFFSetField(tiff, TIFFTAG_GROUP3OPTIONS, group3options); // 2d-encoded, has aligned EOL + TIFFSetField(tiff, TIFFTAG_FILLORDER, FILLORDER_LSB2MSB); // lsb-to-msb fillorder + } } } @@ -793,7 +800,7 @@ tiff_read_xmp_profile(TIFF *tiff, FIBITMAP *dib) { if (TIFFGetField(tiff, TIFFTAG_XMLPACKET, &profile_size, &profile) == 1) { // create a tag FITAG *tag = FreeImage_CreateTag(); - if (!tag) return FALSE; + if(!tag) return FALSE; FreeImage_SetTagID(tag, TIFFTAG_XMLPACKET); // 700 FreeImage_SetTagKey(tag, g_TagLib_XMPFieldName); @@ -832,7 +839,7 @@ tiff_read_exif_profile(TIFF *tiff, FIBITMAP *dib) { if(TIFFGetField(tiff, TIFFTAG_EXIFIFD, &exif_offset)) { // read EXIF tags - if (!TIFFReadEXIFDirectory(tiff, exif_offset)) { + if(!TIFFReadEXIFDirectory(tiff, exif_offset)) { return FALSE; } @@ -877,7 +884,7 @@ tiff_write_iptc_profile(TIFF *tiff, FIBITMAP *dib) { uint32 iptc_size = profile_size; iptc_size += (4-(iptc_size & 0x03)); // Round up for long word alignment BYTE *iptc_profile = (BYTE*)malloc(iptc_size); - if (!iptc_profile) { + if(!iptc_profile) { free(profile); return FALSE; } @@ -986,17 +993,22 @@ MimeType() { static BOOL DLL_CALLCONV Validate(FreeImageIO *io, fi_handle handle) { - BYTE tiff_id1[] = { 0x49, 0x49, 0x2A, 0x00 }; - BYTE tiff_id2[] = { 0x4D, 0x4D, 0x00, 0x2A }; + BYTE tiff_id1[] = { 0x49, 0x49, 0x2A, 0x00 }; // Classic TIFF, little-endian + BYTE tiff_id2[] = { 0x4D, 0x4D, 0x00, 0x2A }; // Classic TIFF, big-endian + BYTE tiff_id3[] = { 0x49, 0x49, 0x2B, 0x00 }; // Big TIFF, little-endian + BYTE tiff_id4[] = { 0x4D, 0x4D, 0x00, 0x2B }; // Big TIFF, big-endian BYTE signature[4] = { 0, 0, 0, 0 }; io->read_proc(signature, 1, 4, handle); if(memcmp(tiff_id1, signature, 4) == 0) return TRUE; - if(memcmp(tiff_id2, signature, 4) == 0) return TRUE; + if(memcmp(tiff_id3, signature, 4) == 0) + return TRUE; + if(memcmp(tiff_id4, signature, 4) == 0) + return TRUE; return FALSE; } @@ -1046,7 +1058,7 @@ static void * DLL_CALLCONV Open(FreeImageIO *io, fi_handle handle, BOOL read) { // wrapper for TIFF I/O fi_TIFFIO *fio = (fi_TIFFIO*)malloc(sizeof(fi_TIFFIO)); - if (!fio) return NULL; + if(!fio) return NULL; fio->io = io; fio->handle = handle; @@ -1106,7 +1118,7 @@ IsValidBitsPerSample(uint16 photometric, uint16 bitspersample, uint16 samplesper switch(bitspersample) { case 1: case 4: - if ((photometric == PHOTOMETRIC_MINISWHITE) || (photometric == PHOTOMETRIC_MINISBLACK) || (photometric == PHOTOMETRIC_PALETTE)) { + if((photometric == PHOTOMETRIC_MINISWHITE) || (photometric == PHOTOMETRIC_MINISBLACK) || (photometric == PHOTOMETRIC_PALETTE)) { return TRUE; } else { return FALSE; @@ -1155,12 +1167,12 @@ FindLoadMethod(TIFF *tif, FREE_IMAGE_TYPE image_type, int flags) { switch(photometric) { // convert to 24 or 32 bits RGB if the image is full color case PHOTOMETRIC_RGB: - if ((image_type == FIT_RGB16) || (image_type == FIT_RGBA16)) { + if((image_type == FIT_RGB16) || (image_type == FIT_RGBA16)) { // load 48-bit RGB and 64-bit RGBA without conversion loadMethod = LoadAsGenericStrip; } else if(image_type == FIT_RGBF) { - if ((samplesperpixel == 3) && (bitspersample == 16)) { + if((samplesperpixel == 3) && (bitspersample == 16)) { // load 3 x 16-bit half as RGBF loadMethod = LoadAsHalfFloat; } @@ -1182,7 +1194,7 @@ FindLoadMethod(TIFF *tif, FREE_IMAGE_TYPE image_type, int flags) { // to avoid multiple conversions. Conversion can be done by changing // the profile from it's original CMYK to an RGB profile with an // apropriate color management system. Works with non-tiled TIFFs. - if (!bIsTiled) { + if(!bIsTiled) { loadMethod = LoadAsCMYK; } break; @@ -1192,7 +1204,7 @@ FindLoadMethod(TIFF *tif, FREE_IMAGE_TYPE image_type, int flags) { // When samplesperpixel = 2 and bitspersample = 8, set the image as a // 8-bit indexed image + 8-bit alpha layer image // and convert to a 8-bit image with a transparency table - if ((samplesperpixel > 1) && (bitspersample == 8)) { + if((samplesperpixel > 1) && (bitspersample == 8)) { loadMethod = LoadAs8BitTrns; } else { loadMethod = LoadAsGenericStrip; @@ -1203,7 +1215,7 @@ FindLoadMethod(TIFF *tif, FREE_IMAGE_TYPE image_type, int flags) { break; } - if ((loadMethod == LoadAsGenericStrip) && bIsTiled) { + if((loadMethod == LoadAsGenericStrip) && bIsTiled) { loadMethod = LoadAsTiled; } @@ -1249,7 +1261,7 @@ ReadThumbnail(FreeImageIO *io, fi_handle handle, void *data, TIFF *tiff, FIBITMA // ... or read the first subIFD - if (!thumbnail) { + if(!thumbnail) { uint16 subIFD_count = 0; uint64* subIFD_offsets = NULL; // ### Theoretically this should also read the first subIFD from a Photoshop-created file with "pyramid". @@ -1276,7 +1288,7 @@ ReadThumbnail(FreeImageIO *io, fi_handle handle, void *data, TIFF *tiff, FIBITMA // ... or read Photoshop thumbnail - if (!thumbnail) { + if(!thumbnail) { uint32 ps_size = 0; void *ps_data = NULL; @@ -1399,7 +1411,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { uint32 *raster = NULL; - if (!header_only) { + if(!header_only) { raster = (uint32*)_TIFFmalloc(width * height * sizeof(uint32)); if (raster == NULL) { @@ -1443,7 +1455,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { ReadResolution(tif, dib); - if (!header_only) { + if(!header_only) { // read the raster lines and save them in the DIB // with RGB mode, we have to change the order of the 3 samples RGB @@ -1636,7 +1648,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { alpha = FreeImage_Allocate(width, height, 8); } - if (!alpha) { + if(!alpha) { FreeImage_OutputMessageProc(s_format_id, "Failed to allocate temporary alpha channel"); } else { alpha_bits = FreeImage_GetScanLine(alpha, height - 1); @@ -1658,7 +1670,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { ReadResolution(tif, dib); - if (!header_only) { + if(!header_only) { // calculate the line + pitch (separate for scr & dest) @@ -1706,7 +1718,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { for(BYTE *pixel = bits, *al_pixel = alpha_bits, *src_pixel = buf + l * src_line; pixel < bits + dib_pitch; pixel += dibBpp, al_pixel += alpha_Bpp, src_pixel += srcBpp) { // copy pixel byte by byte BYTE b = 0; - for ( ; b < dibBpp; ++b) { + for( ; b < dibBpp; ++b) { pixel[b] = src_pixel[b]; } // TODO write the remaining bytes to extra channel(s) @@ -1814,7 +1826,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { free(buf); - if (!asCMYK) { + if(!asCMYK) { ConvertCMYKtoRGBA(dib); // The ICC Profile is invalid, clear it @@ -1862,7 +1874,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { ReadPalette(tif, photometric, bitspersample, dib); - if (!header_only) { + if(!header_only) { // calculate the line + pitch (separate for scr & dest) const tmsize_t src_line = TIFFScanlineSize(tif); @@ -2000,7 +2012,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { ReadPalette(tif, photometric, bitspersample, dib); // get the tile geometry - if (!TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tileWidth) || !TIFFGetField(tif, TIFFTAG_TILELENGTH, &tileHeight)) { + if(!TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tileWidth) || !TIFFGetField(tif, TIFFTAG_TILELENGTH, &tileHeight)) { throw "Invalid tiled TIFF image"; } @@ -2142,7 +2154,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { ReadResolution(tif, dib); - if (!header_only) { + if(!header_only) { // calculate the line + pitch (separate for scr & dest) @@ -2268,7 +2280,7 @@ SaveOneTIFF(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flag bitspersample = bitsperpixel / samplesperpixel; photometric = GetPhotometric(dib); - if ((bitsperpixel == 8) && FreeImage_IsTransparent(dib)) { + if((bitsperpixel == 8) && FreeImage_IsTransparent(dib)) { // 8-bit transparent picture : convert later to 8-bit + 8-bit alpha samplesperpixel = 2; bitspersample = 8; @@ -2276,7 +2288,7 @@ SaveOneTIFF(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flag else if(bitsperpixel == 32) { // 32-bit images : check for CMYK or alpha transparency - if ((((iccProfile->flags & FIICC_COLOR_IS_CMYK) == FIICC_COLOR_IS_CMYK) || ((flags & TIFF_CMYK) == TIFF_CMYK))) { + if((((iccProfile->flags & FIICC_COLOR_IS_CMYK) == FIICC_COLOR_IS_CMYK) || ((flags & TIFF_CMYK) == TIFF_CMYK))) { // CMYK support photometric = PHOTOMETRIC_SEPARATED; TIFFSetField(out, TIFFTAG_INKSET, INKSET_CMYK); @@ -2301,7 +2313,7 @@ SaveOneTIFF(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flag samplesperpixel = 4; bitspersample = bitsperpixel / samplesperpixel; - if ((((iccProfile->flags & FIICC_COLOR_IS_CMYK) == FIICC_COLOR_IS_CMYK) || ((flags & TIFF_CMYK) == TIFF_CMYK))) { + if((((iccProfile->flags & FIICC_COLOR_IS_CMYK) == FIICC_COLOR_IS_CMYK) || ((flags & TIFF_CMYK) == TIFF_CMYK))) { // CMYK support photometric = PHOTOMETRIC_SEPARATED; TIFFSetField(out, TIFFTAG_INKSET, INKSET_CMYK); @@ -2321,7 +2333,7 @@ SaveOneTIFF(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flag samplesperpixel = 3; bitspersample = bitsperpixel / samplesperpixel; // the library converts to and from floating-point XYZ CIE values - if ((flags & TIFF_LOGLUV) == TIFF_LOGLUV) { + if((flags & TIFF_LOGLUV) == TIFF_LOGLUV) { photometric = PHOTOMETRIC_LOGLUV; TIFFSetField(out, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_FLOAT); // TIFFSetField(out, TIFFTAG_STONITS, 1.0); // assume unknown @@ -2421,7 +2433,7 @@ SaveOneTIFF(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flag // thumbnail tag - if ((ifd == 0) && (ifdCount > 1)) { + if((ifd == 0) && (ifdCount > 1)) { uint16 nsubifd = 1; uint64 subifd[1]; subifd[0] = 0; @@ -2442,7 +2454,7 @@ SaveOneTIFF(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flag case 4 : case 8 : { - if ((bitsperpixel == 8) && FreeImage_IsTransparent(dib)) { + if((bitsperpixel == 8) && FreeImage_IsTransparent(dib)) { // 8-bit transparent picture : convert to 8-bit + 8-bit alpha // get the transparency table @@ -2564,7 +2576,7 @@ SaveOneTIFF(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flag // write out the directory tag if we wrote a page other than -1 or if we have a thumbnail to write later - if ( (page >= 0) || ((ifd == 0) && (ifdCount > 1)) ) { + if( (page >= 0) || ((ifd == 0) && (ifdCount > 1)) ) { TIFFWriteDirectory(out); // else: TIFFClose will WriteDirectory } @@ -2594,7 +2606,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void } bResult = SaveOneTIFF(io, bitmap, handle, page, flags, data, ifd, ifdCount); - if (!bResult) { + if(!bResult) { return FALSE; } } diff --git a/plugins/AdvaImg/src/FreeImage/PluginXBM.cpp b/plugins/AdvaImg/src/FreeImage/PluginXBM.cpp index 140029e862..0aac48ca27 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginXBM.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginXBM.cpp @@ -109,14 +109,14 @@ readXBMFile(FreeImageIO *io, fi_handle handle, int *widthP, int *heightP, char * while(!found_declaration && !eof) { - if ( readLine(line, MAX_LINE, io, handle) == NULL) { + if( readLine(line, MAX_LINE, io, handle) == NULL) { eof = TRUE; } else { - if ( strlen( line ) == MAX_LINE - 1 ) + if( strlen( line ) == MAX_LINE - 1 ) return( ERR_XBM_LINE ); - if ( sscanf(line, "#define %s %d", name_and_type, &v) == 2 ) { - if ( ( t = strrchr( name_and_type, '_' ) ) == NULL ) + if( sscanf(line, "#define %s %d", name_and_type, &v) == 2 ) { + if( ( t = strrchr( name_and_type, '_' ) ) == NULL ) t = name_and_type; else t++; @@ -127,11 +127,11 @@ readXBMFile(FreeImageIO *io, fi_handle handle, int *widthP, int *heightP, char * continue; } - if ( sscanf( line, "static short %s = {", name_and_type ) == 1 ) { + if( sscanf( line, "static short %s = {", name_and_type ) == 1 ) { version = 10; found_declaration = TRUE; } - else if ( sscanf( line, "static char %s = {", name_and_type ) == 1 ) { + else if( sscanf( line, "static char %s = {", name_and_type ) == 1 ) { version = 11; found_declaration = TRUE; } @@ -142,12 +142,12 @@ readXBMFile(FreeImageIO *io, fi_handle handle, int *widthP, int *heightP, char * } } - if (!found_declaration) + if(!found_declaration) return( ERR_XBM_DECL ); - if (*widthP == -1 ) + if(*widthP == -1 ) return( ERR_XBM_WIDTH ); - if ( *heightP == -1 ) + if( *heightP == -1 ) return( ERR_XBM_HEIGHT ); padding = 0; @@ -189,7 +189,7 @@ readXBMFile(FreeImageIO *io, fi_handle handle, int *widthP, int *heightP, char * hex_table['f'] = 15; if(version == 10) { - for ( bytes = 0, ptr = *dataP; bytes < raster_length; bytes += 2 ) { + for( bytes = 0, ptr = *dataP; bytes < raster_length; bytes += 2 ) { while( ( c1 = readChar(io, handle) ) != 'x' ) { if ( c1 == EOF ) return( ERR_XBM_EOFREAD ); @@ -197,14 +197,14 @@ readXBMFile(FreeImageIO *io, fi_handle handle, int *widthP, int *heightP, char * c1 = readChar(io, handle); c2 = readChar(io, handle); - if ( c1 == EOF || c2 == EOF ) + if( c1 == EOF || c2 == EOF ) return( ERR_XBM_EOFREAD ); value1 = ( hex_table[c1] << 4 ) + hex_table[c2]; if ( value1 >= 256 ) return( ERR_XBM_SYNTAX ); c1 = readChar(io, handle); c2 = readChar(io, handle); - if ( c1 == EOF || c2 == EOF ) + if( c1 == EOF || c2 == EOF ) return( ERR_XBM_EOFREAD ); value2 = ( hex_table[c1] << 4 ) + hex_table[c2]; if ( value2 >= 256 ) @@ -219,7 +219,7 @@ readXBMFile(FreeImageIO *io, fi_handle handle, int *widthP, int *heightP, char * /* ** skip until digit is found */ - for ( ; ; ) { + for( ; ; ) { c1 = readChar(io, handle); if ( c1 == EOF ) return( ERR_XBM_EOFREAD ); @@ -230,7 +230,7 @@ readXBMFile(FreeImageIO *io, fi_handle handle, int *widthP, int *heightP, char * /* ** loop on digits */ - for ( ; ; ) { + for( ; ; ) { c2 = readChar(io, handle); if ( c2 == EOF ) return( ERR_XBM_EOFREAD ); @@ -327,7 +327,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { // allocate a new dib dib = FreeImage_Allocate(width, height, 1); - if (!dib) throw (char*)ERR_XBM_MEMORY; + if(!dib) throw (char*)ERR_XBM_MEMORY; // write the palette data RGBQUAD *pal = FreeImage_GetPalette(dib); @@ -347,7 +347,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { count = 0; mask = 1; } - if (*bP & mask) { + if(*bP & mask) { // Set bit(x, y) to 0 bits[x >> 3] &= (0xFF7F >> (x & 0x7)); } else { diff --git a/plugins/AdvaImg/src/FreeImage/PluginXPM.cpp b/plugins/AdvaImg/src/FreeImage/PluginXPM.cpp index 16db443c47..a698321958 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginXPM.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginXPM.cpp @@ -53,7 +53,7 @@ FindChar(FreeImageIO *io, fi_handle handle, BYTE look_for) { BYTE c; io->read_proc(&c, sizeof(BYTE), 1, handle); while(c != look_for) { - if ( io->read_proc(&c, sizeof(BYTE), 1, handle) != 1 ) + if( io->read_proc(&c, sizeof(BYTE), 1, handle) != 1 ) return FALSE; } return TRUE; @@ -62,14 +62,14 @@ FindChar(FreeImageIO *io, fi_handle handle, BYTE look_for) { // find start of string, read data until ending quote found, allocate memory and return a string static char * ReadString(FreeImageIO *io, fi_handle handle) { - if ( !FindChar(io, handle,'"') ) + if( !FindChar(io, handle,'"') ) return NULL; BYTE c; std::string s; io->read_proc(&c, sizeof(BYTE), 1, handle); while(c != '"') { s += c; - if ( io->read_proc(&c, sizeof(BYTE), 1, handle) != 1 ) + if( io->read_proc(&c, sizeof(BYTE), 1, handle) != 1 ) return NULL; } char *cstr = (char *)malloc(s.length()+1); @@ -166,16 +166,16 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { BOOL header_only = (flags & FIF_LOAD_NOPIXELS) == FIF_LOAD_NOPIXELS; //find the starting brace - if ( !FindChar(io, handle,'{') ) + if( !FindChar(io, handle,'{') ) throw "Could not find starting brace"; //read info string str = ReadString(io, handle); - if (!str) + if(!str) throw "Error reading info string"; int width, height, colors, cpp; - if ( sscanf(str, "%d %d %d %d", &width, &height, &colors, &cpp) != 4 ) { + if( sscanf(str, "%d %d %d %d", &width, &height, &colors, &cpp) != 4 ) { free(str); throw "Improperly formed info string"; } @@ -193,7 +193,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { FILE_RGBA rgba; str = ReadString(io, handle); - if (!str) + if(!str) throw "Error reading color strings"; std::string chrs(str,cpp); //create a string for the color chars using the first cpp chars @@ -207,14 +207,14 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { } //prefer the color visual - if ( strstr(keys," c ") ) { + if( strstr(keys," c ") ) { char *clr = strstr(keys," c ") + 3; while( *clr == ' ' ) clr++; //find the start of the hex rgb value - if ( *clr == '#' ) { + if( *clr == '#' ) { int red = 0, green = 0, blue = 0, n; clr++; //end string at first space, if any found - if ( strchr(clr,' ') ) + if( strchr(clr,' ') ) *(strchr(clr,' ')) = '\0'; //parse hex color, it can be #rgb #rrggbb #rrrgggbbb or #rrrrggggbbbb switch( strlen(clr) ) { @@ -239,14 +239,14 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { n = 0; break; } - if ( n != 3 ) { + if( n != 3 ) { free(str); throw "Improperly formed hex color value"; } rgba.r = (BYTE)red; rgba.g = (BYTE)green; rgba.b = (BYTE)blue; - } else if ( !strncmp(clr,"None",4) || !strncmp(clr,"none",4) ) { + } else if( !strncmp(clr,"None",4) || !strncmp(clr,"none",4) ) { rgba.r = rgba.g = rgba.b = 0xFF; } else { char *tmp = clr; @@ -256,8 +256,8 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { //part of the color name. How many named color end with a 1 or 2 character //word? Probably none in our list at least. while( (tmp = strchr(tmp,' ')) != NULL ) { - if ( tmp[1] != ' ' ) { - if ( (tmp[2] == ' ') || (tmp[2] != ' ' && tmp[3] == ' ') ) { + if( tmp[1] != ' ' ) { + if( (tmp[2] == ' ') || (tmp[2] != ' ' && tmp[3] == ' ') ) { tmp[0] = '\0'; break; } @@ -288,7 +288,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { rawpal[chrs] = rgba; //build palette if needed - if ( colors <= 256 ) { + if( colors <= 256 ) { RGBQUAD *pal = FreeImage_GetPalette(dib); pal[i].rgbBlue = rgba.b; pal[i].rgbGreen = rgba.g; @@ -308,7 +308,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { for(int y = 0; y < height; y++ ) { BYTE *line = FreeImage_GetScanLine(dib, height - y - 1); str = ReadString(io, handle); - if (!str) + if(!str) throw "Error reading pixel strings"; char *pixel_ptr = str; @@ -317,7 +317,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { std::string chrs(pixel_ptr,cpp); FILE_RGBA rgba = rawpal[chrs]; - if ( colors > 256 ) { + if( colors > 256 ) { line[FI_RGBA_BLUE] = rgba.b; line[FI_RGBA_GREEN] = rgba.g; line[FI_RGBA_RED] = rgba.r; @@ -338,7 +338,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { } catch(const char *text) { FreeImage_OutputMessageProc(s_format_id, text); - if ( dib != NULL ) + if( dib != NULL ) FreeImage_Unload(dib); return NULL; @@ -355,7 +355,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void footer[] = "\"\n};\n", buf[256]; //256 is more then enough to sprintf 4 ints into, or the base-92 chars and #rrggbb line - if ( io->write_proc(header, (unsigned int)strlen(header), 1, handle) != 1 ) + if( io->write_proc(header, (unsigned int)strlen(header), 1, handle) != 1 ) return FALSE; int width = FreeImage_GetWidth(dib), height = FreeImage_GetHeight(dib), bpp = FreeImage_GetBPP(dib); @@ -378,7 +378,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void for(x = 0; x < width; x++ ) { FILE_RGB rgb; DWORDRGBA u; - if ( bpp > 8 ) { + if( bpp > 8 ) { u.rgba.b = rgb.b = line[FI_RGBA_BLUE]; u.rgba.g = rgb.g = line[FI_RGBA_GREEN]; u.rgba.r = rgb.r = line[FI_RGBA_RED]; @@ -391,7 +391,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void rgb.r = pal[u.index].rgbRed; line++; } - if ( color2chrs.find(u.index) == color2chrs.end() ) { //new color + if( color2chrs.find(u.index) == color2chrs.end() ) { //new color std::string chrs(Base92(num_colors)); color2chrs[u.index] = chrs; chrs2color[num_colors] = rgb; @@ -403,22 +403,22 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void int cpp = (int)(log((double)num_colors)/log(92.0)) + 1; sprintf(buf, "%d %d %d %d", FreeImage_GetWidth(dib), FreeImage_GetHeight(dib), num_colors, cpp ); - if ( io->write_proc(buf, (unsigned int)strlen(buf), 1, handle) != 1 ) + if( io->write_proc(buf, (unsigned int)strlen(buf), 1, handle) != 1 ) return FALSE; - if ( io->write_proc(start_colors, (unsigned int)strlen(start_colors), 1, handle) != 1 ) + if( io->write_proc(start_colors, (unsigned int)strlen(start_colors), 1, handle) != 1 ) return FALSE; //write colors, using map of chrs->rgb for(x = 0; x < num_colors; x++ ) { sprintf(buf, "%*s c #%02x%02x%02x", cpp, Base92(x), chrs2color[x].r, chrs2color[x].g, chrs2color[x].b ); - if ( io->write_proc(buf, (unsigned int)strlen(buf), 1, handle) != 1 ) + if( io->write_proc(buf, (unsigned int)strlen(buf), 1, handle) != 1 ) return FALSE; - if ( x == num_colors - 1 ) { - if ( io->write_proc(start_pixels, (unsigned int)strlen(start_pixels), 1, handle) != 1 ) + if( x == num_colors - 1 ) { + if( io->write_proc(start_pixels, (unsigned int)strlen(start_pixels), 1, handle) != 1 ) return FALSE; } else { - if ( io->write_proc(new_line, (unsigned int)strlen(new_line), 1, handle) != 1 ) + if( io->write_proc(new_line, (unsigned int)strlen(new_line), 1, handle) != 1 ) return FALSE; } } @@ -429,7 +429,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void BYTE *line = FreeImage_GetScanLine(dib, height - y - 1); for(x = 0; x < width; x++ ) { DWORDRGBA u; - if ( bpp > 8 ) { + if( bpp > 8 ) { u.rgba.b = line[FI_RGBA_BLUE]; u.rgba.g = line[FI_RGBA_GREEN]; u.rgba.r = line[FI_RGBA_RED]; @@ -440,14 +440,14 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void line++; } sprintf(buf, "%*s", cpp, (char *)color2chrs[u.index].c_str()); - if ( io->write_proc(buf, cpp, 1, handle) != 1 ) + if( io->write_proc(buf, cpp, 1, handle) != 1 ) return FALSE; } - if ( y == height - 1 ) { - if ( io->write_proc(footer, (unsigned int)strlen(footer), 1, handle) != 1 ) + if( y == height - 1 ) { + if( io->write_proc(footer, (unsigned int)strlen(footer), 1, handle) != 1 ) return FALSE; } else { - if ( io->write_proc(new_line, (unsigned int)strlen(new_line), 1, handle) != 1 ) + if( io->write_proc(new_line, (unsigned int)strlen(new_line), 1, handle) != 1 ) return FALSE; } } diff --git a/plugins/AdvaImg/src/FreeImage/ToneMapping.cpp b/plugins/AdvaImg/src/FreeImage/ToneMapping.cpp index 33ae08ea59..27f8c95a07 100644 --- a/plugins/AdvaImg/src/FreeImage/ToneMapping.cpp +++ b/plugins/AdvaImg/src/FreeImage/ToneMapping.cpp @@ -38,7 +38,7 @@ FreeImage_ToneMapping(FIBITMAP *dib, FREE_IMAGE_TMO tmo, double first_param, dou switch(tmo) { // Adaptive logarithmic mapping (F. Drago, 2003) case FITMO_DRAGO03: - if ((first_param == 0) && (second_param == 0)) { + if((first_param == 0) && (second_param == 0)) { // use default values (gamma = 2.2, exposure = 0) return FreeImage_TmoDrago03(dib, 2.2, 0); } else { @@ -48,7 +48,7 @@ FreeImage_ToneMapping(FIBITMAP *dib, FREE_IMAGE_TMO tmo, double first_param, dou break; // Dynamic range reduction inspired by photoreceptor phhysiology (E. Reinhard, 2005) case FITMO_REINHARD05: - if ((first_param == 0) && (second_param == 0)) { + if((first_param == 0) && (second_param == 0)) { // use default values by setting intensity to 0 and contrast to 0 return FreeImage_TmoReinhard05(dib, 0, 0); } else { @@ -58,7 +58,7 @@ FreeImage_ToneMapping(FIBITMAP *dib, FREE_IMAGE_TMO tmo, double first_param, dou break; // Gradient Domain HDR Compression (R. Fattal, 2002) case FITMO_FATTAL02: - if ((first_param == 0) && (second_param == 0)) { + if((first_param == 0) && (second_param == 0)) { // use default values by setting color saturation to 0.5 and attenuation to 0.85 return FreeImage_TmoFattal02(dib, 0.5, 0.85); } else { diff --git a/plugins/AdvaImg/src/FreeImage/WuQuantizer.cpp b/plugins/AdvaImg/src/FreeImage/WuQuantizer.cpp index 532fbfc3e6..041eae368b 100644 --- a/plugins/AdvaImg/src/FreeImage/WuQuantizer.cpp +++ b/plugins/AdvaImg/src/FreeImage/WuQuantizer.cpp @@ -66,7 +66,7 @@ WuQuantizer::WuQuantizer(FIBITMAP *dib) { // Allocate Qadd Qadd = (WORD *)malloc(sizeof(WORD) * width * height); - if (!gm2 || !wt || !mr || !mg || !mb || !Qadd) { + if(!gm2 || !wt || !mr || !mg || !mb || !Qadd) { if(gm2) free(gm2); if(wt) free(wt); if(mr) free(mr); @@ -127,10 +127,10 @@ WuQuantizer::Hist3D(LONG *vwt, LONG *vmr, LONG *vmg, LONG *vmb, float *m2, int R } } - if ( ReserveSize > 0 ) { + if( ReserveSize > 0 ) { int max = 0; for(i = 0; i < SIZE_3D; i++) { - if ( vwt[i] > max ) max = vwt[i]; + if( vwt[i] > max ) max = vwt[i]; } max++; for(i = 0; i < ReserveSize; i++) { diff --git a/plugins/AdvaImg/src/FreeImage/tmoColorConvert.cpp b/plugins/AdvaImg/src/FreeImage/tmoColorConvert.cpp index 367cb13c96..66869b2806 100644 --- a/plugins/AdvaImg/src/FreeImage/tmoColorConvert.cpp +++ b/plugins/AdvaImg/src/FreeImage/tmoColorConvert.cpp @@ -61,10 +61,10 @@ static const float CIE_y_b = 0.060F; static const float CIE_x_w = 0.3127F; // Illuminant D65 static const float CIE_y_w = 0.3290F; -static const float CIE_D = ( CIE_x_r*(CIE_y_g - CIE_y_b) + CIE_x_g*(CIE_y_b - CIE_y_r) + CIE_x_b*(CIE_y_r - CIE_y_g)); -static const float CIE_C_rD = ( (1/CIE_y_w) * ( CIE_x_w*(CIE_y_g - CIE_y_b) - CIE_y_w*(CIE_x_g - CIE_x_b) + CIE_x_g*CIE_y_b - CIE_x_b*CIE_y_g)); -static const float CIE_C_gD = ( (1/CIE_y_w) * ( CIE_x_w*(CIE_y_b - CIE_y_r) - CIE_y_w*(CIE_x_b - CIE_x_r) - CIE_x_r*CIE_y_b + CIE_x_b*CIE_y_r)); -static const float CIE_C_bD = ( (1/CIE_y_w) * ( CIE_x_w*(CIE_y_r - CIE_y_g) - CIE_y_w*(CIE_x_r - CIE_x_g) + CIE_x_r*CIE_y_g - CIE_x_g*CIE_y_r)); +static const float CIE_D = ( CIE_x_r*(CIE_y_g - CIE_y_b) + CIE_x_g*(CIE_y_b - CIE_y_r) + CIE_x_b*(CIE_y_r - CIE_y_g) ); +static const float CIE_C_rD = ( (1/CIE_y_w) * ( CIE_x_w*(CIE_y_g - CIE_y_b) - CIE_y_w*(CIE_x_g - CIE_x_b) + CIE_x_g*CIE_y_b - CIE_x_b*CIE_y_g) ); +static const float CIE_C_gD = ( (1/CIE_y_w) * ( CIE_x_w*(CIE_y_b - CIE_y_r) - CIE_y_w*(CIE_x_b - CIE_x_r) - CIE_x_r*CIE_y_b + CIE_x_b*CIE_y_r) ); +static const float CIE_C_bD = ( (1/CIE_y_w) * ( CIE_x_w*(CIE_y_r - CIE_y_g) - CIE_y_w*(CIE_x_r - CIE_x_g) + CIE_x_r*CIE_y_g - CIE_x_g*CIE_y_r) ); /** RGB to XYZ (no white balance) @@ -275,7 +275,7 @@ ClampConvertRGBFTo24(FIBITMAP *src) { const unsigned height = FreeImage_GetHeight(src); FIBITMAP *dst = FreeImage_Allocate(width, height, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); - if (!dst) return NULL; + if(!dst) return NULL; const unsigned src_pitch = FreeImage_GetPitch(src); const unsigned dst_pitch = FreeImage_GetPitch(dst); @@ -321,7 +321,7 @@ ConvertRGBFToY(FIBITMAP *src) { const unsigned height = FreeImage_GetHeight(src); FIBITMAP *dst = FreeImage_AllocateT(FIT_FLOAT, width, height); - if (!dst) return NULL; + if(!dst) return NULL; const unsigned src_pitch = FreeImage_GetPitch(src); const unsigned dst_pitch = FreeImage_GetPitch(dst); @@ -415,8 +415,8 @@ static void findMaxMinPercentile(FIBITMAP *Y, float minPrct, float *minLum, floa std::sort(vY.begin(), vY.end()); - *minLum = vY.at( int(minPrct * vY.size())); - *maxLum = vY.at( int(maxPrct * vY.size())); + *minLum = vY.at( int(minPrct * vY.size()) ); + *maxLum = vY.at( int(maxPrct * vY.size()) ); } /** @@ -444,7 +444,7 @@ NormalizeY(FIBITMAP *Y, float minPrct, float maxPrct) { int pitch = FreeImage_GetPitch(Y); // find max & min luminance values - if ((minPrct > 0) || (maxPrct < 1)) { + if((minPrct > 0) || (maxPrct < 1)) { maxLum = 0, minLum = 0; findMaxMinPercentile(Y, minPrct, &minLum, maxPrct, &maxLum); } else { diff --git a/plugins/AdvaImg/src/FreeImage/tmoDrago03.cpp b/plugins/AdvaImg/src/FreeImage/tmoDrago03.cpp index b820bb3577..a61534474d 100644 --- a/plugins/AdvaImg/src/FreeImage/tmoDrago03.cpp +++ b/plugins/AdvaImg/src/FreeImage/tmoDrago03.cpp @@ -258,13 +258,13 @@ FIBITMAP* DLL_CALLCONV FreeImage_TmoDrago03(FIBITMAP *src, double gamma, double exposure) { float maxLum, minLum, avgLum; - if (!FreeImage_HasPixels(src)) return NULL; + if(!FreeImage_HasPixels(src)) return NULL; // working RGBF variable FIBITMAP *dib = NULL; dib = FreeImage_ConvertToRGBF(src); - if (!dib) return NULL; + if(!dib) return NULL; // default algorithm parameters const float biasParam = 0.85F; diff --git a/plugins/AdvaImg/src/FreeImage/tmoFattal02.cpp b/plugins/AdvaImg/src/FreeImage/tmoFattal02.cpp index bcd4524523..88f054412a 100644 --- a/plugins/AdvaImg/src/FreeImage/tmoFattal02.cpp +++ b/plugins/AdvaImg/src/FreeImage/tmoFattal02.cpp @@ -54,7 +54,7 @@ static FIBITMAP* GaussianLevel5x5(FIBITMAP *dib) { h_dib = FreeImage_AllocateT(image_type, width, height); v_dib = FreeImage_AllocateT(image_type, width, height); - if (!h_dib || !v_dib) throw(1); + if(!h_dib || !v_dib) throw(1); const unsigned pitch = FreeImage_GetPitch(dib) / sizeof(float); @@ -166,7 +166,7 @@ static FIBITMAP* GradientLevel(FIBITMAP *H, float *avgGrad, int k) { const unsigned height = FreeImage_GetHeight(H); G = FreeImage_AllocateT(image_type, width, height); - if (!G) throw(1); + if(!G) throw(1); const unsigned pitch = FreeImage_GetPitch(H) / sizeof(float); @@ -246,7 +246,7 @@ static FIBITMAP* PhiMatrix(FIBITMAP **gradients, float *avgGrad, int nlevels, fl try { phi = (FIBITMAP**)malloc(nlevels * sizeof(FIBITMAP*)); - if (!phi) throw(1); + if(!phi) throw(1); memset(phi, 0, nlevels * sizeof(FIBITMAP*)); for(int k = nlevels-1; k >= 0; k--) { @@ -266,7 +266,7 @@ static FIBITMAP* PhiMatrix(FIBITMAP **gradients, float *avgGrad, int nlevels, fl if(ALPHA == 0) ALPHA = EPSILON; phi[k] = FreeImage_AllocateT(FIT_FLOAT, width, height); - if (!phi[k]) throw(1); + if(!phi[k]) throw(1); src_pixel = (float*)FreeImage_GetBits(Gk); dst_pixel = (float*)FreeImage_GetBits(phi[k]); @@ -283,9 +283,9 @@ static FIBITMAP* PhiMatrix(FIBITMAP **gradients, float *avgGrad, int nlevels, fl } if(k < nlevels-1) { - // compute PHI(k) = L( PHI(k+1)) * phi(k) + // compute PHI(k) = L( PHI(k+1) ) * phi(k) FIBITMAP *L = FreeImage_Rescale(phi[k+1], width, height, FILTER_BILINEAR); - if (!L) throw(1); + if(!L) throw(1); src_pixel = (float*)FreeImage_GetBits(L); dst_pixel = (float*)FreeImage_GetBits(phi[k]); @@ -345,9 +345,9 @@ static FIBITMAP* Divergence(FIBITMAP *H, FIBITMAP *PHI) { const unsigned height = FreeImage_GetHeight(H); Gx = FreeImage_AllocateT(image_type, width, height); - if (!Gx) throw(1); + if(!Gx) throw(1); Gy = FreeImage_AllocateT(image_type, width, height); - if (!Gy) throw(1); + if(!Gy) throw(1); const unsigned pitch = FreeImage_GetPitch(H) / sizeof(float); @@ -377,20 +377,20 @@ static FIBITMAP* Divergence(FIBITMAP *H, FIBITMAP *PHI) { // calculate the divergence divG = FreeImage_AllocateT(image_type, width, height); - if (!divG) throw(1); + if(!divG) throw(1); gx = (float*)FreeImage_GetBits(Gx); gy = (float*)FreeImage_GetBits(Gy); divg = (float*)FreeImage_GetBits(divG); - for(unsigned y0 = 0; y0 < height; y0++) { + for(unsigned y = 0; y < height; y++) { for(unsigned x = 0; x < width; x++) { // backward difference approximation // divG = Gx(x, y) - Gx(x-1, y) + Gy(x, y) - Gy(x, y-1) - const unsigned index = y0*pitch + x; + const unsigned index = y*pitch + x; divg[index] = gx[index] + gy[index]; if(x > 0) divg[index] -= gx[index-1]; - if(y0 > 0) divg[index] -= gy[index-pitch]; + if(y > 0) divg[index] -= gy[index-pitch]; } } @@ -421,7 +421,7 @@ static FIBITMAP* LogLuminance(FIBITMAP *Y) { try { // get the luminance channel FIBITMAP *H = FreeImage_Clone(Y); - if (!H) throw(1); + if(!H) throw(1); const unsigned width = FreeImage_GetWidth(H); const unsigned height = FreeImage_GetHeight(H); @@ -446,7 +446,7 @@ static FIBITMAP* LogLuminance(FIBITMAP *Y) { // normalize to range 0..100 and take the logarithm const float scale = 100.F / (maxLum - minLum); bits = (BYTE*)FreeImage_GetBits(H); - for(unsigned y0 = 0; y0 < height; y0++) { + for(unsigned y = 0; y < height; y++) { float *pixel = (float*)bits; for(unsigned x = 0; x < width; x++) { const float value = (pixel[x] - minLum) * scale; @@ -509,7 +509,7 @@ static FIBITMAP* tmoFattal02(FIBITMAP *Y, float alpha, float beta) { try { // get the normalized luminance FIBITMAP *H = LogLuminance(Y); - if (!H) throw(1); + if(!H) throw(1); // get the number of levels for the pyramid const unsigned width = FreeImage_GetWidth(H); @@ -522,19 +522,19 @@ static FIBITMAP* tmoFattal02(FIBITMAP *Y, float alpha, float beta) { // create the Gaussian pyramid pyramid = (FIBITMAP**)malloc(nlevels * sizeof(FIBITMAP*)); - if (!pyramid) throw(1); + if(!pyramid) throw(1); memset(pyramid, 0, nlevels * sizeof(FIBITMAP*)); - if (!GaussianPyramid(H, pyramid, nlevels)) throw(1); + if(!GaussianPyramid(H, pyramid, nlevels)) throw(1); // calculate gradient magnitude and its average value on each pyramid level gradients = (FIBITMAP**)malloc(nlevels * sizeof(FIBITMAP*)); - if (!gradients) throw(1); + if(!gradients) throw(1); memset(gradients, 0, nlevels * sizeof(FIBITMAP*)); avgGrad = (float*)malloc(nlevels * sizeof(float)); - if (!avgGrad) throw(1); + if(!avgGrad) throw(1); - if (!GradientPyramid(pyramid, nlevels, gradients, avgGrad)) throw(1); + if(!GradientPyramid(pyramid, nlevels, gradients, avgGrad)) throw(1); // free the Gaussian pyramid for(k = 0; k < nlevels; k++) { @@ -544,7 +544,7 @@ static FIBITMAP* tmoFattal02(FIBITMAP *Y, float alpha, float beta) { // compute the gradient attenuation function PHI(x, y) phy = PhiMatrix(gradients, avgGrad, nlevels, alpha, beta); - if (!phy) throw(1); + if(!phy) throw(1); // free the gradient pyramid for(k = 0; k < nlevels; k++) { @@ -556,7 +556,7 @@ static FIBITMAP* tmoFattal02(FIBITMAP *Y, float alpha, float beta) { // compute gradients in x and y directions, attenuate them with the attenuation matrix, // then compute the divergence div G from the attenuated gradient. divG = Divergence(H, phy); - if (!divG) throw(1); + if(!divG) throw(1); // H & phy no longer needed FreeImage_Unload(H); H = NULL; @@ -564,7 +564,7 @@ static FIBITMAP* tmoFattal02(FIBITMAP *Y, float alpha, float beta) { // solve the PDE (Poisson equation) using a multigrid solver and 3 cycles FIBITMAP *U = FreeImage_MultigridPoissonSolver(divG, 3); - if (!U) throw(1); + if(!U) throw(1); FreeImage_Unload(divG); @@ -618,21 +618,21 @@ FreeImage_TmoFattal02(FIBITMAP *dib, double color_saturation, double attenuation FIBITMAP *Yout = NULL; FIBITMAP *dst = NULL; - if (!FreeImage_HasPixels(dib)) return NULL; + if(!FreeImage_HasPixels(dib)) return NULL; try { // convert to RGBF src = FreeImage_ConvertToRGBF(dib); - if (!src) throw(1); + if(!src) throw(1); // get the luminance channel Yin = ConvertRGBFToY(src); - if (!Yin) throw(1); + if(!Yin) throw(1); // perform the tone mapping Yout = tmoFattal02(Yin, alpha, beta); - if (!Yout) throw(1); + if(!Yout) throw(1); // clip low and high values and normalize to [0..1] //NormalizeY(Yout, 0.001F, 0.995F); diff --git a/plugins/AdvaImg/src/FreeImage/tmoReinhard05.cpp b/plugins/AdvaImg/src/FreeImage/tmoReinhard05.cpp index 969aa4c950..f91b41c062 100644 --- a/plugins/AdvaImg/src/FreeImage/tmoReinhard05.cpp +++ b/plugins/AdvaImg/src/FreeImage/tmoReinhard05.cpp @@ -59,7 +59,7 @@ ToneMappingReinhard05(FIBITMAP *dib, FIBITMAP *Y, float f, float m, float a, flo // check input parameters - if ((FreeImage_GetImageType(dib) != FIT_RGBF) || (FreeImage_GetImageType(Y) != FIT_FLOAT)) { + if((FreeImage_GetImageType(dib) != FIT_RGBF) || (FreeImage_GetImageType(Y) != FIT_FLOAT)) { return FALSE; } @@ -81,7 +81,7 @@ ToneMappingReinhard05(FIBITMAP *dib, FIBITMAP *Y, float f, float m, float a, flo // get statistics about the data (but only if its really needed) f = exp(-f); - if ((m == 0) || (a != 1) && (c != 1)) { + if((m == 0) || (a != 1) && (c != 1)) { // avoid these calculations if its not needed after ... LuminanceFromY(Y, &maxLum, &minLum, &Lav, &Llav); k = (log(maxLum) - Llav) / (log(maxLum) - log(minLum)); @@ -103,7 +103,7 @@ ToneMappingReinhard05(FIBITMAP *dib, FIBITMAP *Y, float f, float m, float a, flo bits = (BYTE*)FreeImage_GetBits(dib); Ybits = (BYTE*)FreeImage_GetBits(Y); - if ((a == 1) && (c == 0)) { + if((a == 1) && (c == 0)) { // when using default values, use a fastest code for(y = 0; y < height; y++) { @@ -113,7 +113,7 @@ ToneMappingReinhard05(FIBITMAP *dib, FIBITMAP *Y, float f, float m, float a, flo for(x = 0; x < width; x++) { I_a = Y[x]; // luminance(x, y) for (i = 0; i < 3; i++) { - *color /= ( *color + pow(f * I_a, m)); + *color /= ( *color + pow(f * I_a, m) ); max_color = (*color > max_color) ? *color : max_color; min_color = (*color < min_color) ? *color : min_color; @@ -131,7 +131,7 @@ ToneMappingReinhard05(FIBITMAP *dib, FIBITMAP *Y, float f, float m, float a, flo // channel averages Cav[0] = Cav[1] = Cav[2] = 0; - if ((a != 1) && (c != 0)) { + if((a != 1) && (c != 0)) { // channel averages are not needed when (a == 1) or (c == 0) bits = (BYTE*)FreeImage_GetBits(dib); for(y = 0; y < height; y++) { @@ -164,7 +164,7 @@ ToneMappingReinhard05(FIBITMAP *dib, FIBITMAP *Y, float f, float m, float a, flo I_l = c * *color + (1-c) * L; I_g = c * Cav[i] + (1-c) * Lav; I_a = a * I_l + (1-a) * I_g; - *color /= ( *color + pow(f * I_a, m)); + *color /= ( *color + pow(f * I_a, m) ); max_color = (*color > max_color) ? *color : max_color; min_color = (*color < min_color) ? *color : min_color; @@ -215,17 +215,17 @@ User parameters control intensity, contrast, and level of adaptation */ FIBITMAP* DLL_CALLCONV FreeImage_TmoReinhard05Ex(FIBITMAP *src, double intensity, double contrast, double adaptation, double color_correction) { - if (!FreeImage_HasPixels(src)) return NULL; + if(!FreeImage_HasPixels(src)) return NULL; // working RGBF variable FIBITMAP *dib = NULL, *Y = NULL; dib = FreeImage_ConvertToRGBF(src); - if (!dib) return NULL; + if(!dib) return NULL; // get the Luminance channel Y = ConvertRGBFToY(dib); - if (!Y) { + if(!Y) { FreeImage_Unload(dib); return NULL; } diff --git a/plugins/AdvaImg/src/FreeImageToolkit/BSplineRotate.cpp b/plugins/AdvaImg/src/FreeImageToolkit/BSplineRotate.cpp index e4be1d0bd2..690db87d8c 100644 --- a/plugins/AdvaImg/src/FreeImageToolkit/BSplineRotate.cpp +++ b/plugins/AdvaImg/src/FreeImageToolkit/BSplineRotate.cpp @@ -556,7 +556,7 @@ Rotate8Bit(FIBITMAP *dib, double angle, double x_shift, double y_shift, double x // allocate output image FIBITMAP *dst = FreeImage_Allocate(width, height, bpp); - if (!dst) + if(!dst) return NULL; // buid a grey scale palette RGBQUAD *pal = FreeImage_GetPalette(dst); @@ -566,7 +566,7 @@ Rotate8Bit(FIBITMAP *dib, double angle, double x_shift, double y_shift, double x // allocate a temporary array ImageRasterArray = (double*)malloc(width * height * sizeof(double)); - if (!ImageRasterArray) { + if(!ImageRasterArray) { FreeImage_Unload(dst); return NULL; } @@ -583,7 +583,7 @@ Rotate8Bit(FIBITMAP *dib, double angle, double x_shift, double y_shift, double x // convert between a representation based on image samples // and a representation based on image B-spline coefficients bResult = SamplesToCoefficients(ImageRasterArray, width, height, spline); - if (!bResult) { + if(!bResult) { FreeImage_Unload(dst); free(ImageRasterArray); return NULL; @@ -611,7 +611,7 @@ Rotate8Bit(FIBITMAP *dib, double angle, double x_shift, double y_shift, double x x1 = x0 + a11 * (double)x; y1 = y0 + a21 * (double)x; if(use_mask) { - if ((x1 <= -0.5) || (((double)width - 0.5) <= x1) || (y1 <= -0.5) || (((double)height - 0.5) <= y1)) { + if((x1 <= -0.5) || (((double)width - 0.5) <= x1) || (y1 <= -0.5) || (((double)height - 0.5) <= y1)) { p = 0; } else { @@ -652,7 +652,7 @@ FreeImage_RotateEx(FIBITMAP *dib, double angle, double x_shift, double y_shift, BYTE *src_bits, *dst_bits; FIBITMAP *src8 = NULL, *dst8 = NULL, *dst = NULL; - if (!FreeImage_HasPixels(dib)) return NULL; + if(!FreeImage_HasPixels(dib)) return NULL; try { @@ -666,20 +666,20 @@ FreeImage_RotateEx(FIBITMAP *dib, double angle, double x_shift, double y_shift, } return dst_8; } - if ((bpp == 24) || (bpp == 32)) { + if((bpp == 24) || (bpp == 32)) { // allocate dst image int width = FreeImage_GetWidth(dib); int height = FreeImage_GetHeight(dib); - if ( bpp == 24 ) { + if( bpp == 24 ) { dst = FreeImage_Allocate(width, height, bpp, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); } else { dst = FreeImage_Allocate(width, height, bpp, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); } - if (!dst) throw(1); + if(!dst) throw(1); // allocate a temporary 8-bit dib (no need to build a palette) src8 = FreeImage_Allocate(width, height, 8); - if (!src8) throw(1); + if(!src8) throw(1); // process each channel separately // ------------------------------- @@ -698,7 +698,7 @@ FreeImage_RotateEx(FIBITMAP *dib, double angle, double x_shift, double y_shift, // process channel dst8 = Rotate8Bit(src8, angle, x_shift, y_shift, x_origin, y_origin, ROTATE_CUBIC, use_mask); - if (!dst8) throw(1); + if(!dst8) throw(1); // insert channel to destination dib for(y = 0; y < height; y++) { diff --git a/plugins/AdvaImg/src/FreeImageToolkit/Background.cpp b/plugins/AdvaImg/src/FreeImageToolkit/Background.cpp new file mode 100644 index 0000000000..06b31aa332 --- /dev/null +++ b/plugins/AdvaImg/src/FreeImageToolkit/Background.cpp @@ -0,0 +1,895 @@ +// ========================================================== +// Background filling routines +// +// Design and implementation by +// - Carsten Klein (c.klein@datagis.com) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +#include "FreeImage.h" +#include "Utilities.h" + +/** @brief Determines, whether a palletized image is visually greyscale or not. + + Unlike with FreeImage_GetColorType, which returns either FIC_MINISBLACK or + FIC_MINISWHITE for a greyscale image with a linear ramp palette, the return + value of this function does not depend on the palette's order, but only on the + palette's individual colors. + @param dib The image to be tested. + @return Returns TRUE if the palette of the image specified contains only + greyscales, FALSE otherwise. + */ +static BOOL +IsVisualGreyscaleImage(FIBITMAP *dib) { + + switch (FreeImage_GetBPP(dib)) { + case 1: + case 4: + case 8: { + unsigned ncolors = FreeImage_GetColorsUsed(dib); + RGBQUAD *rgb = FreeImage_GetPalette(dib); + for (unsigned i = 0; i< ncolors; i++) { + if ((rgb->rgbRed != rgb->rgbGreen) || (rgb->rgbRed != rgb->rgbBlue)) { + return FALSE; + } + } + return TRUE; + } + default: { + return (FreeImage_GetColorType(dib) == FIC_MINISBLACK); + } + } +} + +/** @brief Looks up a specified color in a FIBITMAP's palette and returns the color's + palette index or -1 if the color was not found. + + Unlike with FreeImage_GetColorType, which returns either FIC_MINISBLACK or + FIC_MINISWHITE for a greyscale image with a linear ramp palette, the return + value of this function does not depend on the palette's order, but only on the + palette's individual colors. + @param dib The image, whose palette should be searched through. + @param color The color to be searched in the palette. + @param options Options that affect the color search process. + @param color_type A pointer, that optionally specifies the image's color type as + returned by FreeImage_GetColorType. If invalid or NULL, this function determines the + color type with FreeImage_GetColorType. + @return Returns the specified color's palette index, the color's rgbReserved member + if option FI_COLOR_ALPHA_IS_INDEX was specified or -1, if the color was not found + in the image's palette or if the specified image is non-palletized. + */ +static int +GetPaletteIndex(FIBITMAP *dib, const RGBQUAD *color, int options, FREE_IMAGE_COLOR_TYPE *color_type) { + + int result = -1; + + if ((!dib) || (!color)) { + return result; + } + + int bpp = FreeImage_GetBPP(dib); + + // First check trivial case: return color->rgbReserved if only + // FI_COLOR_ALPHA_IS_INDEX is set. + if ((options & FI_COLOR_ALPHA_IS_INDEX) == FI_COLOR_ALPHA_IS_INDEX) { + if (bpp == 1) { + return color->rgbReserved & 0x01; + } else if (bpp == 4) { + return color->rgbReserved & 0x0F; + } + return color->rgbReserved; + } + + if (bpp == 8) { + FREE_IMAGE_COLOR_TYPE ct = + (color_type == NULL || *color_type < 0) ? + FreeImage_GetColorType(dib) : *color_type; + if (ct == FIC_MINISBLACK) { + return GREY(color->rgbRed, color->rgbGreen, color->rgbBlue); + } + if (ct == FIC_MINISWHITE) { + return 255 - GREY(color->rgbRed, color->rgbGreen, color->rgbBlue); + } + } else if (bpp > 8) { + // for palettized images only + return result; + } + + if (options & FI_COLOR_FIND_EQUAL_COLOR) { + + // Option FI_COLOR_ALPHA_IS_INDEX is implicit here so, set + // index to color->rgbReserved + result = color->rgbReserved; + if (bpp == 1) { + result &= 0x01; + } else if (bpp == 4) { + result &= 0x0F; + } + + unsigned ucolor; + if (!IsVisualGreyscaleImage(dib)) { + ucolor = (*((unsigned *)color)) & 0xFFFFFF; + } else { + ucolor = GREY(color->rgbRed, color->rgbGreen, color->rgbBlue) * 0x010101; + //ucolor = (ucolor | (ucolor << 8) | (ucolor << 16)); + } + unsigned ncolors = FreeImage_GetColorsUsed(dib); + unsigned *palette = (unsigned *)FreeImage_GetPalette(dib); + for (unsigned i = 0; i < ncolors; i++) { + if ((palette[i] & 0xFFFFFF) == ucolor) { + result = i; + break; + } + } + } else { + unsigned minimum = UINT_MAX; + unsigned ncolors = FreeImage_GetColorsUsed(dib); + BYTE *palette = (BYTE *)FreeImage_GetPalette(dib); + BYTE red, green, blue; + if (!IsVisualGreyscaleImage(dib)) { + red = color->rgbRed; + green = color->rgbGreen; + blue = color->rgbBlue; + } else { + red = GREY(color->rgbRed, color->rgbGreen, color->rgbBlue); + green = blue = red; + } + for (unsigned i = 0; i < ncolors; i++) { + unsigned m = abs(palette[FI_RGBA_BLUE] - blue) + + abs(palette[FI_RGBA_GREEN] - green) + + abs(palette[FI_RGBA_RED] - red); + if (m < minimum) { + minimum = m; + result = i; + if (m == 0) { + break; + } + } + palette += sizeof(RGBQUAD); + } + } + return result; +} + +/** @brief Blends an alpha-transparent foreground color over an opaque background + color. + + This function blends the alpha-transparent foreground color fgcolor over the + background color bgcolor. The background color is considered fully opaque, + whatever it's alpha value contains, whereas the foreground color is considered + to be a real RGBA color with an alpha value, which is used for the blend + operation. The resulting color is returned through the blended parameter. + @param bgcolor The background color for the blend operation. + @param fgcolor The foreground color for the blend operation. This color's alpha + value, stored in the rgbReserved member, is the alpha value used for the blend + operation. + @param blended This out parameter takes the blended color and so, returns it to + the caller. This color's alpha value will be 0xFF (255) so, the blended color + itself has no transparency. The this argument is not changed, if the function + fails. + @return Returns TRUE on success, FALSE otherwise. This function fails if any of + the color arguments is a null pointer. + */ +static BOOL +GetAlphaBlendedColor(const RGBQUAD *bgcolor, const RGBQUAD *fgcolor, RGBQUAD *blended) { + + if ((!bgcolor) || (!fgcolor) || (!blended)) { + return FALSE; + } + + BYTE alpha = fgcolor->rgbReserved; + BYTE not_alpha = ~alpha; + + blended->rgbRed = (BYTE)( ((WORD)fgcolor->rgbRed * alpha + not_alpha * (WORD)bgcolor->rgbRed) >> 8 ); + blended->rgbGreen = (BYTE)( ((WORD)fgcolor->rgbGreen * alpha + not_alpha * (WORD)bgcolor->rgbGreen) >> 8) ; + blended->rgbBlue = (BYTE)( ((WORD)fgcolor->rgbRed * alpha + not_alpha * (WORD)bgcolor->rgbBlue) >> 8 ); + blended->rgbReserved = 0xFF; + + return TRUE; +} + +/** @brief Fills a FIT_BITMAP image with the specified color. + + This function does the dirty work for FreeImage_FillBackground for FIT_BITMAP + images. + @param dib The image to be filled. + @param color The color, the specified image should be filled with. + @param options Options that affect the color search process for palletized images. + @return Returns TRUE on success, FALSE otherwise. This function fails if any of + the dib and color is NULL or the provided image is not a FIT_BITMAP image. + */ +static BOOL +FillBackgroundBitmap(FIBITMAP *dib, const RGBQUAD *color, int options) { + + if ((!dib) || (FreeImage_GetImageType(dib) != FIT_BITMAP)) { + return FALSE;; + } + + if (!color) { + return FALSE; + } + + const RGBQUAD *color_intl = color; + unsigned bpp = FreeImage_GetBPP(dib); + unsigned width = FreeImage_GetWidth(dib); + unsigned height = FreeImage_GetHeight(dib); + + FREE_IMAGE_COLOR_TYPE color_type = FreeImage_GetColorType(dib); + + // get a pointer to the first scanline (bottom line) + BYTE *src_bits = FreeImage_GetScanLine(dib, 0); + BYTE *dst_bits = src_bits; + + BOOL supports_alpha = ((bpp >= 24) || ((bpp == 8) && (color_type != FIC_PALETTE))); + + // Check for RGBA case if bitmap supports alpha + // blending (8-bit greyscale, 24- or 32-bit images) + if (supports_alpha && (options & FI_COLOR_IS_RGBA_COLOR)) { + + if (color->rgbReserved == 0) { + // the fill color is fully transparent; we are done + return TRUE; + } + + // Only if the fill color is NOT fully opaque, draw it with + // the (much) slower FreeImage_DrawLine function and return. + // Since we do not have the FreeImage_DrawLine function in this + // release, just assume to have an unicolor background and fill + // all with an 'alpha-blended' color. + if (color->rgbReserved < 255) { + + // If we will draw on an unicolor background, it's + // faster to draw opaque with an alpha blended color. + // So, first get the color from the first pixel in the + // image (bottom-left pixel). + RGBQUAD bgcolor; + if (bpp == 8) { + bgcolor = FreeImage_GetPalette(dib)[*src_bits]; + } else { + bgcolor.rgbBlue = src_bits[FI_RGBA_BLUE]; + bgcolor.rgbGreen = src_bits[FI_RGBA_GREEN]; + bgcolor.rgbRed = src_bits[FI_RGBA_RED]; + bgcolor.rgbReserved = 0xFF; + } + RGBQUAD blend; + GetAlphaBlendedColor(&bgcolor, color_intl, &blend); + color_intl = &blend; + } + } + + int index = (bpp <= 8) ? GetPaletteIndex(dib, color_intl, options, &color_type) : 0; + if (index == -1) { + // No palette index found for a palletized + // image. This should never happen... + return FALSE; + } + + // first, build the first scanline (line 0) + switch (bpp) { + case 1: { + unsigned bytes = (width / 8); + memset(dst_bits, ((index == 1) ? 0xFF : 0x00), bytes); + //int n = width % 8; + int n = width & 7; + if (n) { + if (index == 1) { + // set n leftmost bits + dst_bits[bytes] |= (0xFF << (8 - n)); + } else { + // clear n leftmost bits + dst_bits[bytes] &= (0xFF >> n); + } + } + break; + } + case 4: { + unsigned bytes = (width / 2); + memset(dst_bits, (index | (index << 4)), bytes); + //if (bytes % 2) { + if (bytes & 1) { + dst_bits[bytes] &= 0x0F; + dst_bits[bytes] |= (index << 4); + } + break; + } + case 8: { + memset(dst_bits, index, FreeImage_GetLine(dib)); + break; + } + case 16: { + WORD wcolor = RGBQUAD_TO_WORD(dib, color_intl); + for (unsigned x = 0; x < width; x++) { + ((WORD *)dst_bits)[x] = wcolor; + } + break; + } + case 24: { + RGBTRIPLE rgbt = *((RGBTRIPLE *)color_intl); + for (unsigned x = 0; x < width; x++) { + ((RGBTRIPLE *)dst_bits)[x] = rgbt; + } + break; + } + case 32: { + RGBQUAD rgbq; + rgbq.rgbBlue = ((RGBTRIPLE *)color_intl)->rgbtBlue; + rgbq.rgbGreen = ((RGBTRIPLE *)color_intl)->rgbtGreen; + rgbq.rgbRed = ((RGBTRIPLE *)color_intl)->rgbtRed; + rgbq.rgbReserved = 0xFF; + for (unsigned x = 0; x < width; x++) { + ((RGBQUAD *)dst_bits)[x] = rgbq; + } + break; + } + default: + return FALSE; + } + + // Then, copy the first scanline into all following scanlines. + // 'src_bits' is a pointer to the first scanline and is already + // set up correctly. + if (src_bits) { + unsigned pitch = FreeImage_GetPitch(dib); + unsigned bytes = FreeImage_GetLine(dib); + dst_bits = src_bits + pitch; + for (unsigned y = 1; y < height; y++) { + memcpy(dst_bits, src_bits, bytes); + dst_bits += pitch; + } + } + return TRUE; +} + +/** @brief Fills an image with the specified color. + + This function sets all pixels of an image to the color provided through the color + parameter. Since this should work for all image types supported by FreeImage, the + pointer color must point to a memory location, which is at least as large as the + image's color value, if this size is greater than 4 bytes. As the color is specified + by an RGBQUAD structure for all images of type FIT_BITMAP (including all palletized + images), the smallest possible size of this memory is the size of the RGBQUAD structure, + which uses 4 bytes. + + So, color must point to a double, if the image to be filled is of type FIT_DOUBLE and + point to a RGBF structure if the image is of type FIT_RGBF and so on. + + However, the fill color is always specified through a RGBQUAD structure for all images + of type FIT_BITMAP. So, for 32- and 24-bit images, the red, green and blue members of + the RGBQUAD structure are directly used for the image's red, green and blue channel + respectively. Although alpha transparent RGBQUAD colors are supported, the alpha channel + of a 32-bit image never gets modified by this function. A fill color with an alpha value + smaller than 255 gets blended with the image's actual background color, which is determined + from the image's bottom-left pixel. So, currently using alpha enabled colors, assumes the + image to be unicolor before the fill operation. However, the RGBQUAD's rgbReserved member is + only taken into account, if option FI_COLOR_IS_RGBA_COLOR has been specified. + + For 16-bit images, the red-, green- and blue components of the specified color are + transparently translated into either the 16-bit 555 or 565 representation. This depends + on the image's actual red- green- and blue masks. + + Special attention must be payed for palletized images. Generally, the RGB color specified + is looked up in the image's palette. The found palette index is then used to fill the image. + There are some option flags, that affect this lookup process: + + no option specified (0x00) Uses the color, that is nearest to the specified color. + This is the default behavior and should always find a + color in the palette. However, the visual result may + far from what was expected and mainly depends on the + image's palette. + + FI_COLOR_FIND_EQUAL_COLOR (0x02) Searches the image's palette for the specified color + but only uses the returned palette index, if the specified + color exactly matches the palette entry. Of course, + depending on the image's actual palette entries, this + operation may fail. In this case, the function falls back + to option FI_COLOR_ALPHA_IS_INDEX and uses the RGBQUAD's + rgbReserved member (or its low nibble for 4-bit images + or its least significant bit (LSB) for 1-bit images) as + the palette index used for the fill operation. + + FI_COLOR_ALPHA_IS_INDEX (0x04) Does not perform any color lookup from the palette, but + uses the RGBQUAD's alpha channel member rgbReserved as + the palette index to be used for the fill operation. + However, for 4-bit images, only the low nibble of the + rgbReserved member are used and for 1-bit images, only + the least significant bit (LSB) is used. + + This function fails if any of dib and color is NULL. + + @param dib The image to be filled. + @param color A pointer to the color value to be used for filling the image. The + memory pointed to by this pointer is always assumed to be at least as large as the + image's color value, but never smaller than the size of an RGBQUAD structure. + @param options Options that affect the color search process for palletized images. + @return Returns TRUE on success, FALSE otherwise. This function fails if any of + dib and color is NULL. + */ +BOOL DLL_CALLCONV +FreeImage_FillBackground(FIBITMAP *dib, const void *color, int options) { + + if (!FreeImage_HasPixels(dib)) { + return FALSE; + } + + if (!color) { + return FALSE; + } + + // handle FIT_BITMAP images with FreeImage_FillBackground() + if (FreeImage_GetImageType(dib) == FIT_BITMAP) { + return FillBackgroundBitmap(dib, (RGBQUAD *)color, options); + } + + // first, construct the first scanline (bottom line) + unsigned bytespp = (FreeImage_GetBPP(dib) / 8); + BYTE *src_bits = FreeImage_GetScanLine(dib, 0); + BYTE *dst_bits = src_bits; + for (unsigned x = 0; x < FreeImage_GetWidth(dib); x++) { + memcpy(dst_bits, color, bytespp); + dst_bits += bytespp; + } + + // then, copy the first scanline into all following scanlines + unsigned height = FreeImage_GetHeight(dib); + unsigned pitch = FreeImage_GetPitch(dib); + unsigned bytes = FreeImage_GetLine(dib); + dst_bits = src_bits + pitch; + for (unsigned y = 1; y < height; y++) { + memcpy(dst_bits, src_bits, bytes); + dst_bits += pitch; + } + return TRUE; +} + +/** @brief Allocates a new image of the specified type, width, height and bit depth and + optionally fills it with the specified color. + + This function is an extension to FreeImage_AllocateT, which additionally supports specifying + a palette to be set for the newly create image, as well as specifying a background color, + the newly created image should initially be filled with. + + Basically, this function internally relies on function FreeImage_AllocateT, followed by a + call to FreeImage_FillBackground. This is why both parameters color and options behave the + same as it is documented for function FreeImage_FillBackground. So, please refer to the + documentation of FreeImage_FillBackground to learn more about parameters color and options. + + The palette specified through parameter palette is only copied to the newly created + image, if its image type is FIT_BITMAP and the desired bit depth is smaller than or equal + to 8 bits per pixel. In other words, the palette parameter is only taken into account for + palletized images. However, if the preceding conditions match and if palette is not NULL, + the memory pointed to by the palette pointer is assumed to be at least as large as size + of a fully populated palette for the desired bit depth. So, for an 8-bit image, this size + is 256 x sizeof(RGBQUAD), for an 4-bit image it is 16 x sizeof(RGBQUAD) and it is + 2 x sizeof(RGBQUAD) for a 1-bit image. In other words, this function does not support + partial palettes. + + However, specifying a palette is not necessarily needed, even for palletized images. This + function is capable of implicitly creating a palette, if parameter palette is NULL. If the + specified background color is a greyscale value (red = green = blue) or if option + FI_COLOR_ALPHA_IS_INDEX is specified, a greyscale palette is created. For a 1-bit image, only + if the specified background color is either black or white, a monochrome palette, consisting + of black and white only is created. In any case, the darker colors are stored at the smaller + palette indices. + + If the specified background color is not a greyscale value, or is neither black nor white + for a 1-bit image, solely this single color is injected into the otherwise black-initialized + palette. For this operation, option FI_COLOR_ALPHA_IS_INDEX is implicit, so the specified + color is applied to the palette entry, specified by the background color's rgbReserved + member. The image is then filled with this palette index. + + This function returns a newly created image as function FreeImage_AllocateT does, if both + parameters color and palette are NULL. If only color is NULL, the palette pointed to by + parameter palette is initially set for the new image, if a palletized image of type + FIT_BITMAP is created. However, in the latter case, this function returns an image, whose + pixels are all initialized with zeros so, the image will be filled with the color of the + first palette entry. + + @param type Specifies the image type of the new image. + @param width The desired width in pixels of the new image. + @param height The desired height in pixels of the new image. + @param bpp The desired bit depth of the new image. + @param color A pointer to the color value to be used for filling the image. The + memory pointed to by this pointer is always assumed to be at least as large as the + image's color value but never smaller than the size of an RGBQUAD structure. + @param options Options that affect the color search process for palletized images. + @param red_mask Specifies the bits used to store the red components of a pixel. + @param green_mask Specifies the bits used to store the green components of a pixel. + @param blue_mask Specifies the bits used to store the blue components of a pixel. + @return Returns a pointer to a newly allocated image on success, NULL otherwise. + */ +FIBITMAP * DLL_CALLCONV +FreeImage_AllocateExT(FREE_IMAGE_TYPE type, int width, int height, int bpp, const void *color, int options, const RGBQUAD *palette, unsigned red_mask, unsigned green_mask, unsigned blue_mask) { + + FIBITMAP *bitmap = FreeImage_AllocateT(type, width, height, bpp, red_mask, green_mask, blue_mask); + + if (!color) { + if ((palette) && (type == FIT_BITMAP) && (bpp <= 8)) { + memcpy(FreeImage_GetPalette(bitmap), palette, FreeImage_GetColorsUsed(bitmap) * sizeof(RGBQUAD)); + } + return bitmap; + } + + if (bitmap != NULL) { + + // Only fill the new bitmap if the specified color + // differs from "black", that is not all bytes of the + // color are equal to zero. + switch (bpp) { + case 1: { + // although 1-bit implies FIT_BITMAP, better get an unsigned + // color and palette + unsigned *urgb = (unsigned *)color; + unsigned *upal = (unsigned *)FreeImage_GetPalette(bitmap); + RGBQUAD rgbq = RGBQUAD(); + + if (palette != NULL) { + // clone the specified palette + memcpy(FreeImage_GetPalette(bitmap), palette, 2 * sizeof(RGBQUAD)); + } else if (options & FI_COLOR_ALPHA_IS_INDEX) { + CREATE_GREYSCALE_PALETTE(upal, 2); + } else { + // check, whether the specified color is either black or white + if ((*urgb & 0xFFFFFF) == 0x000000) { + // in any case build a FIC_MINISBLACK palette + CREATE_GREYSCALE_PALETTE(upal, 2); + color = &rgbq; + } else if ((*urgb & 0xFFFFFF) == 0xFFFFFF) { + // in any case build a FIC_MINISBLACK palette + CREATE_GREYSCALE_PALETTE(upal, 2); + rgbq.rgbReserved = 1; + color = &rgbq; + } else { + // Otherwise inject the specified color into the so far + // black-only palette. We use color->rgbReserved as the + // desired palette index. + BYTE index = ((RGBQUAD *)color)->rgbReserved & 0x01; + upal[index] = *urgb & 0x00FFFFFF; + } + options |= FI_COLOR_ALPHA_IS_INDEX; + } + // and defer to FreeImage_FillBackground + FreeImage_FillBackground(bitmap, color, options); + break; + } + case 4: { + // 4-bit implies FIT_BITMAP so, get a RGBQUAD color + RGBQUAD *rgb = (RGBQUAD *)color; + RGBQUAD *pal = FreeImage_GetPalette(bitmap); + RGBQUAD rgbq = RGBQUAD(); + + if (palette != NULL) { + // clone the specified palette + memcpy(pal, palette, 16 * sizeof(RGBQUAD)); + } else if (options & FI_COLOR_ALPHA_IS_INDEX) { + CREATE_GREYSCALE_PALETTE(pal, 16); + } else { + // check, whether the specified color is a grey one + if ((rgb->rgbRed == rgb->rgbGreen) && (rgb->rgbRed == rgb->rgbBlue)) { + // if so, build a greyscale palette + CREATE_GREYSCALE_PALETTE(pal, 16); + rgbq.rgbReserved = rgb->rgbRed >> 4; + color = &rgbq; + } else { + // Otherwise inject the specified color into the so far + // black-only palette. We use color->rgbReserved as the + // desired palette index. + BYTE index = (rgb->rgbReserved & 0x0F); + ((unsigned *)pal)[index] = *((unsigned *)rgb) & 0x00FFFFFF; + } + options |= FI_COLOR_ALPHA_IS_INDEX; + } + // and defer to FreeImage_FillBackground + FreeImage_FillBackground(bitmap, color, options); + break; + } + case 8: { + // 8-bit implies FIT_BITMAP so, get a RGBQUAD color + RGBQUAD *rgb = (RGBQUAD *)color; + RGBQUAD *pal = FreeImage_GetPalette(bitmap); + RGBQUAD rgbq; + + if (palette != NULL) { + // clone the specified palette + memcpy(pal, palette, 256 * sizeof(RGBQUAD)); + } else if (options & FI_COLOR_ALPHA_IS_INDEX) { + CREATE_GREYSCALE_PALETTE(pal, 256); + } else { + // check, whether the specified color is a grey one + if ((rgb->rgbRed == rgb->rgbGreen) && (rgb->rgbRed == rgb->rgbBlue)) { + // if so, build a greyscale palette + CREATE_GREYSCALE_PALETTE(pal, 256); + rgbq.rgbReserved = rgb->rgbRed; + color = &rgbq; + } else { + // Otherwise inject the specified color into the so far + // black-only palette. We use color->rgbReserved as the + // desired palette index. + BYTE index = rgb->rgbReserved; + ((unsigned *)pal)[index] = *((unsigned *)rgb) & 0x00FFFFFF; + } + options |= FI_COLOR_ALPHA_IS_INDEX; + } + // and defer to FreeImage_FillBackground + FreeImage_FillBackground(bitmap, color, options); + break; + } + case 16: { + WORD wcolor = (type == FIT_BITMAP) ? + RGBQUAD_TO_WORD(bitmap, ((RGBQUAD *)color)) : *((WORD *)color); + if (wcolor != 0) { + FreeImage_FillBackground(bitmap, color, options); + } + break; + } + default: { + int bytespp = bpp / 8; + for (int i = 0; i < bytespp; i++) { + if (((BYTE *)color)[i] != 0) { + FreeImage_FillBackground(bitmap, color, options); + break; + } + } + break; + } + } + } + return bitmap; +} + +/** @brief Allocates a new image of the specified width, height and bit depth and optionally + fills it with the specified color. + + This function is an extension to FreeImage_Allocate, which additionally supports specifying + a palette to be set for the newly create image, as well as specifying a background color, + the newly created image should initially be filled with. + + Basically, this function internally relies on function FreeImage_Allocate, followed by a + call to FreeImage_FillBackground. This is why both parameters color and options behave the + same as it is documented for function FreeImage_FillBackground. So, please refer to the + documentation of FreeImage_FillBackground to learn more about parameters color and options. + + The palette specified through parameter palette is only copied to the newly created + image, if the desired bit depth is smaller than or equal to 8 bits per pixel. In other words, + the palette parameter is only taken into account for palletized images. However, if the + image to be created is a palletized image and if palette is not NULL, the memory pointed to + by the palette pointer is assumed to be at least as large as size of a fully populated + palette for the desired bit depth. So, for an 8-bit image, this size is 256 x sizeof(RGBQUAD), + for an 4-bit image it is 16 x sizeof(RGBQUAD) and it is 2 x sizeof(RGBQUAD) for a 1-bit + image. In other words, this function does not support partial palettes. + + However, specifying a palette is not necessarily needed, even for palletized images. This + function is capable of implicitly creating a palette, if parameter palette is NULL. If the + specified background color is a greyscale value (red = green = blue) or if option + FI_COLOR_ALPHA_IS_INDEX is specified, a greyscale palette is created. For a 1-bit image, only + if the specified background color is either black or white, a monochrome palette, consisting + of black and white only is created. In any case, the darker colors are stored at the smaller + palette indices. + + If the specified background color is not a greyscale value, or is neither black nor white + for a 1-bit image, solely this single color is injected into the otherwise black-initialized + palette. For this operation, option FI_COLOR_ALPHA_IS_INDEX is implicit, so the specified + color is applied to the palette entry, specified by the background color's rgbReserved + member. The image is then filled with this palette index. + + This function returns a newly created image as function FreeImage_Allocate does, if both + parameters color and palette are NULL. If only color is NULL, the palette pointed to by + parameter palette is initially set for the new image, if a palletized image of type + FIT_BITMAP is created. However, in the latter case, this function returns an image, whose + pixels are all initialized with zeros so, the image will be filled with the color of the + first palette entry. + + @param width The desired width in pixels of the new image. + @param height The desired height in pixels of the new image. + @param bpp The desired bit depth of the new image. + @param color A pointer to an RGBQUAD structure, that provides the color to be used for + filling the image. + @param options Options that affect the color search process for palletized images. + @param red_mask Specifies the bits used to store the red components of a pixel. + @param green_mask Specifies the bits used to store the green components of a pixel. + @param blue_mask Specifies the bits used to store the blue components of a pixel. + @return Returns a pointer to a newly allocated image on success, NULL otherwise. + */ +FIBITMAP * DLL_CALLCONV +FreeImage_AllocateEx(int width, int height, int bpp, const RGBQUAD *color, int options, const RGBQUAD *palette, unsigned red_mask, unsigned green_mask, unsigned blue_mask) { + return FreeImage_AllocateExT(FIT_BITMAP, width, height, bpp, ((void *)color), options, palette, red_mask, green_mask, blue_mask); +} + +/** @brief Enlarges or shrinks an image selectively per side and fills newly added areas + with the specified background color. + + This function enlarges or shrinks an image selectively per side. The main purpose of this + function is to add borders to an image. To add a border to any of the image's sides, a + positive integer value must be passed in any of the parameters left, top, right or bottom. + This value represents the border's width in pixels. Newly created parts of the image (the + border areas) are filled with the specified color. Specifying a negative integer value for + a certain side, will shrink or crop the image on this side. Consequently, specifying zero + for a certain side will not change the image's extension on that side. + + So, calling this function with all parameters left, top, right and bottom set to zero, is + effectively the same as calling function FreeImage_Clone; setting all parameters left, top, + right and bottom to value equal to or smaller than zero, my easily be substituted by a call + to function FreeImage_Copy. Both these cases produce a new image, which is guaranteed not to + be larger than the input image. Thus, since the specified color is not needed in these cases, + the pointer color may be NULL. + + Both parameters color and options work according to function FreeImage_FillBackground. So, + please refer to the documentation of FreeImage_FillBackground to learn more about parameters + color and options. For palletized images, the palette of the input image src is + transparently copied to the newly created enlarged or shrunken image, so any color + look-ups are performed on this palette. + + Here are some examples, that illustrate, how to use the parameters left, top, right and + bottom: + + // create a white color + RGBQUAD c; + c.rgbRed = 0xFF; + c.rgbGreen = 0xFF; + c.rgbBlue = 0xFF; + c.rgbReserved = 0x00; + + // add a white, symmetric 10 pixel wide border to the image + dib2 = FreeImage_EnlargeCanvas(dib, 10, 10, 10, 10, &c, FI_COLOR_IS_RGB_COLOR); + + // add white, 20 pixel wide stripes to the top and bottom side of the image + dib3 = FreeImage_EnlargeCanvas(dib, 0, 20, 0, 20, &c, FI_COLOR_IS_RGB_COLOR); + + // add white, 30 pixel wide stripes to the right side of the image and + // cut off the 40 leftmost pixel columns + dib3 = FreeImage_EnlargeCanvas(dib, -40, 0, 30, 0, &c, FI_COLOR_IS_RGB_COLOR); + + This function fails if either the input image is NULL or the pointer to the color is + NULL, while at least on of left, top, right and bottom is greater than zero. This + function also returns NULL, if the new image's size will be negative in either x- or + y-direction. + + @param dib The image to be enlarged or shrunken. + @param left The number of pixels, the image should be enlarged on its left side. Negative + values shrink the image on its left side. + @param top The number of pixels, the image should be enlarged on its top side. Negative + values shrink the image on its top side. + @param right The number of pixels, the image should be enlarged on its right side. Negative + values shrink the image on its right side. + @param bottom The number of pixels, the image should be enlarged on its bottom side. Negative + values shrink the image on its bottom side. + @param color The color, the enlarged sides of the image should be filled with. + @param options Options that affect the color search process for palletized images. + @return Returns a pointer to a newly allocated enlarged or shrunken image on success, + NULL otherwise. This function fails if either the input image is NULL or the pointer to the + color is NULL, while at least on of left, top, right and bottom is greater than zero. This + function also returns NULL, if the new image's size will be negative in either x- or + y-direction. + */ +FIBITMAP * DLL_CALLCONV +FreeImage_EnlargeCanvas(FIBITMAP *src, int left, int top, int right, int bottom, const void *color, int options) { + + if(!FreeImage_HasPixels(src)) return NULL; + + // Just return a clone of the image, if left, top, right and bottom are + // all zero. + if ((left == 0) && (right == 0) && (top == 0) && (bottom == 0)) { + return FreeImage_Clone(src); + } + + int width = FreeImage_GetWidth(src); + int height = FreeImage_GetHeight(src); + + // Relay on FreeImage_Copy, if all parameters left, top, right and + // bottom are smaller than or equal zero. The color pointer may be + // NULL in this case. + if ((left <= 0) && (right <= 0) && (top <= 0) && (bottom <= 0)) { + return FreeImage_Copy(src, -left, -top, width + right, height + bottom); + } + + // From here, we need a valid color, since the image will be enlarged on + // at least one side. So, fail if we don't have a valid color pointer. + if (!color) { + return NULL; + } + + if (((left < 0) && (-left >= width)) || ((right < 0) && (-right >= width)) || + ((top < 0) && (-top >= height)) || ((bottom < 0) && (-bottom >= height))) { + return NULL; + } + + unsigned newWidth = width + left + right; + unsigned newHeight = height + top + bottom; + + FREE_IMAGE_TYPE type = FreeImage_GetImageType(src); + unsigned bpp = FreeImage_GetBPP(src); + + FIBITMAP *dst = FreeImage_AllocateExT( + type, newWidth, newHeight, bpp, color, options, + FreeImage_GetPalette(src), + FreeImage_GetRedMask(src), + FreeImage_GetGreenMask(src), + FreeImage_GetBlueMask(src)); + + if (!dst) { + return NULL; + } + + if ((type == FIT_BITMAP) && (bpp <= 4)) { + FIBITMAP *copy = FreeImage_Copy(src, + ((left >= 0) ? 0 : -left), + ((top >= 0) ? 0 : -top), + ((width+right)>width)?width:(width+right), + ((height+bottom)>height)?height:(height+bottom)); + + if (!copy) { + FreeImage_Unload(dst); + return NULL; + } + + if (!FreeImage_Paste(dst, copy, + ((left <= 0) ? 0 : left), + ((top <= 0) ? 0 : top), 256)) { + FreeImage_Unload(copy); + FreeImage_Unload(dst); + return NULL; + } + + FreeImage_Unload(copy); + + } else { + + int bytespp = bpp / 8; + BYTE *srcPtr = FreeImage_GetScanLine(src, height - 1 - ((top >= 0) ? 0 : -top)); + BYTE *dstPtr = FreeImage_GetScanLine(dst, newHeight - 1 - ((top <= 0) ? 0 : top)); + + unsigned srcPitch = FreeImage_GetPitch(src); + unsigned dstPitch = FreeImage_GetPitch(dst); + + int lineWidth = bytespp * (width + MIN(0, left) + MIN(0, right)); + int lines = height + MIN(0, top) + MIN(0, bottom); + + if (left <= 0) { + srcPtr += (-left * bytespp); + } else { + dstPtr += (left * bytespp); + } + + for (int i = 0; i < lines; i++) { + memcpy(dstPtr, srcPtr, lineWidth); + srcPtr -= srcPitch; + dstPtr -= dstPitch; + } + } + + // copy metadata from src to dst + FreeImage_CloneMetadata(dst, src); + + // copy transparency table + FreeImage_SetTransparencyTable(dst, FreeImage_GetTransparencyTable(src), FreeImage_GetTransparencyCount(src)); + + // copy background color + RGBQUAD bkcolor; + if( FreeImage_GetBackgroundColor(src, &bkcolor) ) { + FreeImage_SetBackgroundColor(dst, &bkcolor); + } + + // clone resolution + FreeImage_SetDotsPerMeterX(dst, FreeImage_GetDotsPerMeterX(src)); + FreeImage_SetDotsPerMeterY(dst, FreeImage_GetDotsPerMeterY(src)); + + // clone ICC profile + FIICCPROFILE *src_profile = FreeImage_GetICCProfile(src); + FIICCPROFILE *dst_profile = FreeImage_CreateICCProfile(dst, src_profile->data, src_profile->size); + dst_profile->flags = src_profile->flags; + + return dst; +} + diff --git a/plugins/AdvaImg/src/FreeImageToolkit/Channels.cpp b/plugins/AdvaImg/src/FreeImageToolkit/Channels.cpp index f6e6c5509c..5f01ad815f 100644 --- a/plugins/AdvaImg/src/FreeImageToolkit/Channels.cpp +++ b/plugins/AdvaImg/src/FreeImageToolkit/Channels.cpp @@ -31,7 +31,7 @@ FIBITMAP * DLL_CALLCONV FreeImage_GetChannel(FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL channel) { - if (!FreeImage_HasPixels(src)) return NULL; + if(!FreeImage_HasPixels(src)) return NULL; FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(src); unsigned bpp = FreeImage_GetBPP(src); @@ -63,7 +63,7 @@ FreeImage_GetChannel(FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL channel) { unsigned width = FreeImage_GetWidth(src); unsigned height = FreeImage_GetHeight(src); FIBITMAP *dst = FreeImage_Allocate(width, height, 8) ; - if (!dst) return NULL; + if(!dst) return NULL; // build a greyscale palette RGBQUAD *pal = FreeImage_GetPalette(dst); for(int i = 0; i < 256; i++) { @@ -90,7 +90,7 @@ FreeImage_GetChannel(FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL channel) { } // 48-bit RGB or 64-bit RGBA images - if ((image_type == FIT_RGB16) || (image_type == FIT_RGBA16)) { + if((image_type == FIT_RGB16) || (image_type == FIT_RGBA16)) { int c; // select the channel to extract (always RGB[A]) @@ -116,7 +116,7 @@ FreeImage_GetChannel(FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL channel) { unsigned width = FreeImage_GetWidth(src); unsigned height = FreeImage_GetHeight(src); FIBITMAP *dst = FreeImage_AllocateT(FIT_UINT16, width, height) ; - if (!dst) return NULL; + if(!dst) return NULL; // perform extraction @@ -138,7 +138,7 @@ FreeImage_GetChannel(FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL channel) { } // 96-bit RGBF or 128-bit RGBAF images - if ((image_type == FIT_RGBF) || (image_type == FIT_RGBAF)) { + if((image_type == FIT_RGBF) || (image_type == FIT_RGBAF)) { int c; // select the channel to extract (always RGB[A]) @@ -164,7 +164,7 @@ FreeImage_GetChannel(FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL channel) { unsigned width = FreeImage_GetWidth(src); unsigned height = FreeImage_GetHeight(src); FIBITMAP *dst = FreeImage_AllocateT(FIT_FLOAT, width, height) ; - if (!dst) return NULL; + if(!dst) return NULL; // perform extraction @@ -199,32 +199,32 @@ BOOL DLL_CALLCONV FreeImage_SetChannel(FIBITMAP *dst, FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL channel) { int c; - if (!FreeImage_HasPixels(src) || !FreeImage_HasPixels(dst)) return FALSE; + if(!FreeImage_HasPixels(src) || !FreeImage_HasPixels(dst)) return FALSE; // src and dst images should have the same width and height unsigned src_width = FreeImage_GetWidth(src); unsigned src_height = FreeImage_GetHeight(src); unsigned dst_width = FreeImage_GetWidth(dst); unsigned dst_height = FreeImage_GetHeight(dst); - if ((src_width != dst_width) || (src_height != dst_height)) + if((src_width != dst_width) || (src_height != dst_height)) return FALSE; // src image should be grayscale, dst image should be RGB or RGBA FREE_IMAGE_COLOR_TYPE src_type = FreeImage_GetColorType(src); FREE_IMAGE_COLOR_TYPE dst_type = FreeImage_GetColorType(dst); - if ((dst_type != FIC_RGB) && (dst_type != FIC_RGBALPHA) || (src_type != FIC_MINISBLACK)) { + if((dst_type != FIC_RGB) && (dst_type != FIC_RGBALPHA) || (src_type != FIC_MINISBLACK)) { return FALSE; } FREE_IMAGE_TYPE src_image_type = FreeImage_GetImageType(src); FREE_IMAGE_TYPE dst_image_type = FreeImage_GetImageType(dst); - if ((dst_image_type == FIT_BITMAP) && (src_image_type == FIT_BITMAP)) { + if((dst_image_type == FIT_BITMAP) && (src_image_type == FIT_BITMAP)) { // src image should be grayscale, dst image should be 24- or 32-bit unsigned src_bpp = FreeImage_GetBPP(src); unsigned dst_bpp = FreeImage_GetBPP(dst); - if ((src_bpp != 8) || (dst_bpp != 24) && (dst_bpp != 32)) + if((src_bpp != 8) || (dst_bpp != 24) && (dst_bpp != 32)) return FALSE; @@ -263,12 +263,12 @@ FreeImage_SetChannel(FIBITMAP *dst, FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL chan return TRUE; } - if (((dst_image_type == FIT_RGB16) || (dst_image_type == FIT_RGBA16)) && (src_image_type == FIT_UINT16)) { + if(((dst_image_type == FIT_RGB16) || (dst_image_type == FIT_RGBA16)) && (src_image_type == FIT_UINT16)) { // src image should be grayscale, dst image should be 48- or 64-bit unsigned src_bpp = FreeImage_GetBPP(src); unsigned dst_bpp = FreeImage_GetBPP(dst); - if ((src_bpp != 16) || (dst_bpp != 48) && (dst_bpp != 64)) + if((src_bpp != 16) || (dst_bpp != 48) && (dst_bpp != 64)) return FALSE; @@ -307,12 +307,12 @@ FreeImage_SetChannel(FIBITMAP *dst, FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL chan return TRUE; } - if (((dst_image_type == FIT_RGBF) || (dst_image_type == FIT_RGBAF)) && (src_image_type == FIT_FLOAT)) { + if(((dst_image_type == FIT_RGBF) || (dst_image_type == FIT_RGBAF)) && (src_image_type == FIT_FLOAT)) { // src image should be grayscale, dst image should be 96- or 128-bit unsigned src_bpp = FreeImage_GetBPP(src); unsigned dst_bpp = FreeImage_GetBPP(dst); - if ((src_bpp != 32) || (dst_bpp != 96) && (dst_bpp != 128)) + if((src_bpp != 32) || (dst_bpp != 96) && (dst_bpp != 128)) return FALSE; @@ -367,14 +367,14 @@ FreeImage_GetComplexChannel(FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL channel) { double *dst_bits = NULL; FIBITMAP *dst = NULL; - if (!FreeImage_HasPixels(src)) return NULL; + if(!FreeImage_HasPixels(src)) return NULL; if(FreeImage_GetImageType(src) == FIT_COMPLEX) { // allocate a dib of type FIT_DOUBLE unsigned width = FreeImage_GetWidth(src); unsigned height = FreeImage_GetHeight(src); dst = FreeImage_AllocateT(FIT_DOUBLE, width, height) ; - if (!dst) return NULL; + if(!dst) return NULL; // perform extraction @@ -415,7 +415,7 @@ FreeImage_GetComplexChannel(FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL channel) { src_bits = (FICOMPLEX *)FreeImage_GetScanLine(src, y); dst_bits = (double *)FreeImage_GetScanLine(dst, y); for(x = 0; x < width; x++) { - if ((src_bits[x].r == 0) && (src_bits[x].i == 0)) { + if((src_bits[x].r == 0) && (src_bits[x].i == 0)) { phase = 0; } else { phase = atan2(src_bits[x].i, src_bits[x].r); @@ -446,12 +446,12 @@ FreeImage_SetComplexChannel(FIBITMAP *dst, FIBITMAP *src, FREE_IMAGE_COLOR_CHANN double *src_bits = NULL; FICOMPLEX *dst_bits = NULL; - if (!FreeImage_HasPixels(src) || !FreeImage_HasPixels(dst)) return FALSE; + if(!FreeImage_HasPixels(src) || !FreeImage_HasPixels(dst)) return FALSE; // src image should be of type FIT_DOUBLE, dst image should be of type FIT_COMPLEX const FREE_IMAGE_TYPE src_type = FreeImage_GetImageType(src); const FREE_IMAGE_TYPE dst_type = FreeImage_GetImageType(dst); - if ((src_type != FIT_DOUBLE) || (dst_type != FIT_COMPLEX)) + if((src_type != FIT_DOUBLE) || (dst_type != FIT_COMPLEX)) return FALSE; // src and dst images should have the same width and height @@ -459,7 +459,7 @@ FreeImage_SetComplexChannel(FIBITMAP *dst, FIBITMAP *src, FREE_IMAGE_COLOR_CHANN unsigned src_height = FreeImage_GetHeight(src); unsigned dst_width = FreeImage_GetWidth(dst); unsigned dst_height = FreeImage_GetHeight(dst); - if ((src_width != dst_width) || (src_height != dst_height)) + if((src_width != dst_width) || (src_height != dst_height)) return FALSE; // select the channel to modify diff --git a/plugins/AdvaImg/src/FreeImageToolkit/ClassicRotate.cpp b/plugins/AdvaImg/src/FreeImageToolkit/ClassicRotate.cpp index d38d8c1bcd..83c2f92123 100644 --- a/plugins/AdvaImg/src/FreeImageToolkit/ClassicRotate.cpp +++ b/plugins/AdvaImg/src/FreeImageToolkit/ClassicRotate.cpp @@ -63,7 +63,7 @@ HorizontalSkewT(FIBITMAP *src, FIBITMAP *dst, int row, int iOffset, double weigh // background const T pxlBlack[4] = {0, 0, 0, 0 }; const T *pxlBkg = static_cast(bkcolor); // assume at least bytespp and 4*sizeof(T) max - if (!pxlBkg) { + if(!pxlBkg) { // default background color is black pxlBkg = pxlBlack; } @@ -98,7 +98,7 @@ HorizontalSkewT(FIBITMAP *src, FIBITMAP *dst, int row, int iOffset, double weigh } // check boundaries iXPos = i + iOffset; - if ((iXPos >= 0) && (iXPos < (int)dst_width)) { + if((iXPos >= 0) && (iXPos < (int)dst_width)) { // update left over on source for(unsigned j = 0; j < samples; j++) { pxlSrc[j] = pxlSrc[j] - (pxlLeft[j] - pxlOldLeft[j]); @@ -115,7 +115,7 @@ HorizontalSkewT(FIBITMAP *src, FIBITMAP *dst, int row, int iOffset, double weigh // go to rightmost point of skew iXPos = src_width + iOffset; - if ((iXPos >= 0) && (iXPos < (int)dst_width)) { + if((iXPos >= 0) && (iXPos < (int)dst_width)) { dst_bits = FreeImage_GetScanLine(dst, row) + iXPos * bytespp; // If still in image bounds, put leftovers there @@ -194,7 +194,7 @@ VerticalSkewT(FIBITMAP *src, FIBITMAP *dst, int col, int iOffset, double weight, // background const T pxlBlack[4] = {0, 0, 0, 0 }; const T *pxlBkg = static_cast(bkcolor); // assume at least bytespp and 4*sizeof(T) max - if (!pxlBkg) { + if(!pxlBkg) { // default background color is black pxlBkg = pxlBlack; } @@ -235,7 +235,7 @@ VerticalSkewT(FIBITMAP *src, FIBITMAP *dst, int col, int iOffset, double weight, } // check boundaries iYPos = i + iOffset; - if ((iYPos >= 0) && (iYPos < (int)dst_height)) { + if((iYPos >= 0) && (iYPos < (int)dst_height)) { // update left over on source for(unsigned j = 0; j < samples; j++) { pxlSrc[j] = pxlSrc[j] - (pxlLeft[j] - pxlOldLeft[j]); @@ -252,7 +252,7 @@ VerticalSkewT(FIBITMAP *src, FIBITMAP *dst, int col, int iOffset, double weight, // go to bottom point of skew iYPos = src_height + iOffset; - if ((iYPos >= 0) && (iYPos < (int)dst_height)) { + if((iYPos >= 0) && (iYPos < (int)dst_height)) { dst_bits = FreeImage_GetScanLine(dst, iYPos) + index; // if still in image bounds, put leftovers there @@ -367,7 +367,7 @@ Rotate90(FIBITMAP *src) { } } } - else if ((bpp == 8) || (bpp == 24) || (bpp == 32)) { + else if((bpp == 8) || (bpp == 24) || (bpp == 32)) { // anything other than BW : // This optimized version of rotation rotates image by smaller blocks. It is quite // a bit faster than obvious algorithm, because it produces much less CPU cache misses. @@ -472,7 +472,7 @@ Rotate180(FIBITMAP *src) { } break; } - // else if ((bpp == 8) || (bpp == 24) || (bpp == 32)) FALL TROUGH + // else if((bpp == 8) || (bpp == 24) || (bpp == 32)) FALL TROUGH case FIT_UINT16: case FIT_RGB16: case FIT_RGBA16: @@ -559,7 +559,7 @@ Rotate270(FIBITMAP *src) { } } } - else if ((bpp == 8) || (bpp == 24) || (bpp == 32)) { + else if((bpp == 8) || (bpp == 24) || (bpp == 32)) { // anything other than BW : // This optimized version of rotation rotates image by smaller blocks. It is quite // a bit faster than obvious algorithm, because it produces much less CPU cache misses. @@ -730,7 +730,7 @@ Rotate45(FIBITMAP *src, double dAngle, const void *bkcolor) { } else { // Negative angle - dOffset = dTan * ( (src_width - 1.0) * -dSinE + (1.0 - height_3)); + dOffset = dTan * ( (src_width - 1.0) * -dSinE + (1.0 - height_3) ); } for(u = 0; u < height_3; u++, dOffset += dTan) { int iShear = int(floor(dOffset)); @@ -767,7 +767,7 @@ RotateAny(FIBITMAP *src, double dAngle, const void *bkcolor) { // Bring angle to range of [0 .. 360) dAngle += 360; } - if ((dAngle > 45) && (dAngle <= 135)) { + if((dAngle > 45) && (dAngle <= 135)) { // Angle in (45 .. 135] // Rotate image by 90 degrees into temporary image, // so it requires only an extra rotation angle @@ -775,7 +775,7 @@ RotateAny(FIBITMAP *src, double dAngle, const void *bkcolor) { image = Rotate90(src); dAngle -= 90; } - else if ((dAngle > 135) && (dAngle <= 225)) { + else if((dAngle > 135) && (dAngle <= 225)) { // Angle in (135 .. 225] // Rotate image by 180 degrees into temporary image, // so it requires only an extra rotation angle @@ -783,7 +783,7 @@ RotateAny(FIBITMAP *src, double dAngle, const void *bkcolor) { image = Rotate180(src); dAngle -= 180; } - else if ((dAngle > 225) && (dAngle <= 315)) { + else if((dAngle > 225) && (dAngle <= 315)) { // Angle in (225 .. 315] // Rotate image by 270 degrees into temporary image, // so it requires only an extra rotation angle @@ -825,7 +825,7 @@ RotateAny(FIBITMAP *src, double dAngle, const void *bkcolor) { FIBITMAP *DLL_CALLCONV FreeImage_Rotate(FIBITMAP *dib, double angle, const void *bkcolor) { - if (!FreeImage_HasPixels(dib)) return NULL; + if(!FreeImage_HasPixels(dib)) return NULL; if(0 == angle) { return FreeImage_Clone(dib); @@ -846,7 +846,7 @@ FreeImage_Rotate(FIBITMAP *dib, double angle, const void *bkcolor) { // perform the rotation FIBITMAP *dst = RotateAny(dib, angle, bkcolor); - if (!dst) throw(1); + if(!dst) throw(1); // build a greyscale palette RGBQUAD *dst_pal = FreeImage_GetPalette(dst); @@ -863,9 +863,9 @@ FreeImage_Rotate(FIBITMAP *dib, double angle, const void *bkcolor) { return dst; } - else if ((bpp == 8) || (bpp == 24) || (bpp == 32)) { + else if((bpp == 8) || (bpp == 24) || (bpp == 32)) { FIBITMAP *dst = RotateAny(dib, angle, bkcolor); - if (!dst) throw(1); + if(!dst) throw(1); if(bpp == 8) { // copy original palette to rotated bitmap @@ -878,7 +878,7 @@ FreeImage_Rotate(FIBITMAP *dib, double angle, const void *bkcolor) { // copy background color RGBQUAD bkcolor; - if ( FreeImage_GetBackgroundColor(dib, &bkcolor)) { + if( FreeImage_GetBackgroundColor(dib, &bkcolor) ) { FreeImage_SetBackgroundColor(dst, &bkcolor); } @@ -898,7 +898,7 @@ FreeImage_Rotate(FIBITMAP *dib, double angle, const void *bkcolor) { case FIT_RGBAF: { FIBITMAP *dst = RotateAny(dib, angle, bkcolor); - if (!dst) throw(1); + if(!dst) throw(1); // copy metadata from src to dst FreeImage_CloneMetadata(dst, dib); diff --git a/plugins/AdvaImg/src/FreeImageToolkit/Colors.cpp b/plugins/AdvaImg/src/FreeImageToolkit/Colors.cpp index 8b9bbd6482..67191768bb 100644 --- a/plugins/AdvaImg/src/FreeImageToolkit/Colors.cpp +++ b/plugins/AdvaImg/src/FreeImageToolkit/Colors.cpp @@ -108,7 +108,7 @@ FreeImage_Invert(FIBITMAP *src) { return FALSE; } } - else if ((image_type == FIT_UINT16) || (image_type == FIT_RGB16) || (image_type == FIT_RGBA16)) { + else if((image_type == FIT_UINT16) || (image_type == FIT_RGB16) || (image_type == FIT_RGBA16)) { // Calculate the number of words per pixel (1 for 16-bit, 3 for 48-bit or 4 for 64-bit) const unsigned wordspp = (FreeImage_GetLine(src) / width) / sizeof(WORD); @@ -149,11 +149,11 @@ FreeImage_AdjustCurve(FIBITMAP *src, BYTE *LUT, FREE_IMAGE_COLOR_CHANNEL channel unsigned x, y; BYTE *bits = NULL; - if (!FreeImage_HasPixels(src) || !LUT || (FreeImage_GetImageType(src) != FIT_BITMAP)) + if(!FreeImage_HasPixels(src) || !LUT || (FreeImage_GetImageType(src) != FIT_BITMAP)) return FALSE; int bpp = FreeImage_GetBPP(src); - if ((bpp != 8) && (bpp != 24) && (bpp != 32)) + if((bpp != 8) && (bpp != 24) && (bpp != 32)) return FALSE; // apply the LUT @@ -271,7 +271,7 @@ BOOL DLL_CALLCONV FreeImage_AdjustGamma(FIBITMAP *src, double gamma) { BYTE LUT[256]; // Lookup table - if (!FreeImage_HasPixels(src) || (gamma <= 0)) + if(!FreeImage_HasPixels(src) || (gamma <= 0)) return FALSE; // Build the lookup table @@ -302,7 +302,7 @@ FreeImage_AdjustBrightness(FIBITMAP *src, double percentage) { BYTE LUT[256]; // Lookup table double value; - if (!FreeImage_HasPixels(src)) + if(!FreeImage_HasPixels(src)) return FALSE; // Build the lookup table @@ -328,7 +328,7 @@ FreeImage_AdjustContrast(FIBITMAP *src, double percentage) { BYTE LUT[256]; // Lookup table double value; - if (!FreeImage_HasPixels(src)) + if(!FreeImage_HasPixels(src)) return FALSE; // Build the lookup table @@ -357,7 +357,7 @@ FreeImage_GetHistogram(FIBITMAP *src, DWORD *histo, FREE_IMAGE_COLOR_CHANNEL cha BYTE *bits = NULL; unsigned x, y; - if (!FreeImage_HasPixels(src) || !histo) return FALSE; + if(!FreeImage_HasPixels(src) || !histo) return FALSE; unsigned width = FreeImage_GetWidth(src); unsigned height = FreeImage_GetHeight(src); @@ -377,7 +377,7 @@ FreeImage_GetHistogram(FIBITMAP *src, DWORD *histo, FREE_IMAGE_COLOR_CHANNEL cha } return TRUE; } - else if ((bpp == 24) || (bpp == 32)) { + else if((bpp == 24) || (bpp == 32)) { int bytespp = bpp / 8; // bytes / pixel // clear histogram array diff --git a/plugins/AdvaImg/src/FreeImageToolkit/CopyPaste.cpp b/plugins/AdvaImg/src/FreeImageToolkit/CopyPaste.cpp index 753fdc736e..e4b8155739 100644 --- a/plugins/AdvaImg/src/FreeImageToolkit/CopyPaste.cpp +++ b/plugins/AdvaImg/src/FreeImageToolkit/CopyPaste.cpp @@ -58,12 +58,12 @@ Combine1(FIBITMAP *dst_dib, FIBITMAP *src_dib, unsigned x, unsigned y, unsigned BOOL value; // check the bit depth of src and dst images - if ((FreeImage_GetBPP(dst_dib) != 1) || (FreeImage_GetBPP(src_dib) != 1)) { + if((FreeImage_GetBPP(dst_dib) != 1) || (FreeImage_GetBPP(src_dib) != 1)) { return FALSE; } // check the size of src image - if ((x + FreeImage_GetWidth(src_dib) > FreeImage_GetWidth(dst_dib)) || (y + FreeImage_GetHeight(src_dib) > FreeImage_GetHeight(dst_dib))) { + if((x + FreeImage_GetWidth(src_dib) > FreeImage_GetWidth(dst_dib)) || (y + FreeImage_GetHeight(src_dib) > FreeImage_GetHeight(dst_dib))) { return FALSE; } @@ -97,12 +97,12 @@ Combine4(FIBITMAP *dst_dib, FIBITMAP *src_dib, unsigned x, unsigned y, unsigned BOOL bOddStart, bOddEnd; // check the bit depth of src and dst images - if ((FreeImage_GetBPP(dst_dib) != 4) || (FreeImage_GetBPP(src_dib) != 4)) { + if((FreeImage_GetBPP(dst_dib) != 4) || (FreeImage_GetBPP(src_dib) != 4)) { return FALSE; } // check the size of src image - if ((x + FreeImage_GetWidth(src_dib) > FreeImage_GetWidth(dst_dib)) || (y + FreeImage_GetHeight(src_dib) > FreeImage_GetHeight(dst_dib))) { + if((x + FreeImage_GetWidth(src_dib) > FreeImage_GetWidth(dst_dib)) || (y + FreeImage_GetHeight(src_dib) > FreeImage_GetHeight(dst_dib))) { return FALSE; } @@ -196,12 +196,12 @@ Combine4(FIBITMAP *dst_dib, FIBITMAP *src_dib, unsigned x, unsigned y, unsigned static BOOL Combine8(FIBITMAP *dst_dib, FIBITMAP *src_dib, unsigned x, unsigned y, unsigned alpha) { // check the bit depth of src and dst images - if ((FreeImage_GetBPP(dst_dib) != 8) || (FreeImage_GetBPP(src_dib) != 8)) { + if((FreeImage_GetBPP(dst_dib) != 8) || (FreeImage_GetBPP(src_dib) != 8)) { return FALSE; } // check the size of src image - if ((x + FreeImage_GetWidth(src_dib) > FreeImage_GetWidth(dst_dib)) || (y + FreeImage_GetHeight(src_dib) > FreeImage_GetHeight(dst_dib))) { + if((x + FreeImage_GetWidth(src_dib) > FreeImage_GetWidth(dst_dib)) || (y + FreeImage_GetHeight(src_dib) > FreeImage_GetHeight(dst_dib))) { return FALSE; } @@ -238,12 +238,12 @@ Combine8(FIBITMAP *dst_dib, FIBITMAP *src_dib, unsigned x, unsigned y, unsigned static BOOL Combine16_555(FIBITMAP *dst_dib, FIBITMAP *src_dib, unsigned x, unsigned y, unsigned alpha) { // check the bit depth of src and dst images - if ((FreeImage_GetBPP(dst_dib) != 16) || (FreeImage_GetBPP(src_dib) != 16)) { + if((FreeImage_GetBPP(dst_dib) != 16) || (FreeImage_GetBPP(src_dib) != 16)) { return FALSE; } // check the size of src image - if ((x + FreeImage_GetWidth(src_dib) > FreeImage_GetWidth(dst_dib)) || (y + FreeImage_GetHeight(src_dib) > FreeImage_GetHeight(dst_dib))) { + if((x + FreeImage_GetWidth(src_dib) > FreeImage_GetWidth(dst_dib)) || (y + FreeImage_GetHeight(src_dib) > FreeImage_GetHeight(dst_dib))) { return FALSE; } @@ -298,12 +298,12 @@ Combine16_555(FIBITMAP *dst_dib, FIBITMAP *src_dib, unsigned x, unsigned y, unsi static BOOL Combine16_565(FIBITMAP *dst_dib, FIBITMAP *src_dib, unsigned x, unsigned y, unsigned alpha) { // check the bit depth of src and dst images - if ((FreeImage_GetBPP(dst_dib) != 16) || (FreeImage_GetBPP(src_dib) != 16)) { + if((FreeImage_GetBPP(dst_dib) != 16) || (FreeImage_GetBPP(src_dib) != 16)) { return FALSE; } // check the size of src image - if ((x + FreeImage_GetWidth(src_dib) > FreeImage_GetWidth(dst_dib)) || (y + FreeImage_GetHeight(src_dib) > FreeImage_GetHeight(dst_dib))) { + if((x + FreeImage_GetWidth(src_dib) > FreeImage_GetWidth(dst_dib)) || (y + FreeImage_GetHeight(src_dib) > FreeImage_GetHeight(dst_dib))) { return FALSE; } @@ -362,12 +362,12 @@ Combine16_565(FIBITMAP *dst_dib, FIBITMAP *src_dib, unsigned x, unsigned y, unsi static BOOL Combine24(FIBITMAP *dst_dib, FIBITMAP *src_dib, unsigned x, unsigned y, unsigned alpha) { // check the bit depth of src and dst images - if ((FreeImage_GetBPP(dst_dib) != 24) || (FreeImage_GetBPP(src_dib) != 24)) { + if((FreeImage_GetBPP(dst_dib) != 24) || (FreeImage_GetBPP(src_dib) != 24)) { return FALSE; } // check the size of src image - if ((x + FreeImage_GetWidth(src_dib) > FreeImage_GetWidth(dst_dib)) || (y + FreeImage_GetHeight(src_dib) > FreeImage_GetHeight(dst_dib))) { + if((x + FreeImage_GetWidth(src_dib) > FreeImage_GetWidth(dst_dib)) || (y + FreeImage_GetHeight(src_dib) > FreeImage_GetHeight(dst_dib))) { return FALSE; } @@ -404,12 +404,12 @@ Combine24(FIBITMAP *dst_dib, FIBITMAP *src_dib, unsigned x, unsigned y, unsigned static BOOL Combine32(FIBITMAP *dst_dib, FIBITMAP *src_dib, unsigned x, unsigned y, unsigned alpha) { // check the bit depth of src and dst images - if ((FreeImage_GetBPP(dst_dib) != 32) || (FreeImage_GetBPP(src_dib) != 32)) { + if((FreeImage_GetBPP(dst_dib) != 32) || (FreeImage_GetBPP(src_dib) != 32)) { return FALSE; } // check the size of src image - if ((x + FreeImage_GetWidth(src_dib) > FreeImage_GetWidth(dst_dib)) || (y + FreeImage_GetHeight(src_dib) > FreeImage_GetHeight(dst_dib))) { + if((x + FreeImage_GetWidth(src_dib) > FreeImage_GetWidth(dst_dib)) || (y + FreeImage_GetHeight(src_dib) > FreeImage_GetHeight(dst_dib))) { return FALSE; } @@ -459,7 +459,7 @@ CombineSameType(FIBITMAP *dst_dib, FIBITMAP *src_dib, unsigned x, unsigned y) { unsigned dst_pitch = FreeImage_GetPitch(dst_dib); // check the size of src image - if ((x + src_width > dst_width) || (y + src_height > dst_height)) { + if((x + src_width > dst_width) || (y + src_height > dst_height)) { return FALSE; } @@ -493,7 +493,7 @@ Works with any bitmap type. FIBITMAP * DLL_CALLCONV FreeImage_Copy(FIBITMAP *src, int left, int top, int right, int bottom) { - if (!FreeImage_HasPixels(src)) + if(!FreeImage_HasPixels(src)) return NULL; // normalize the rectangle @@ -506,7 +506,7 @@ FreeImage_Copy(FIBITMAP *src, int left, int top, int right, int bottom) { // check the size of the sub image int src_width = FreeImage_GetWidth(src); int src_height = FreeImage_GetHeight(src); - if ((left < 0) || (right > src_width) || (top < 0) || (bottom > src_height)) { + if((left < 0) || (right > src_width) || (top < 0) || (bottom > src_height)) { return NULL; } @@ -608,7 +608,7 @@ FreeImage_Copy(FIBITMAP *src, int left, int top, int right, int bottom) { // copy background color RGBQUAD bkcolor; - if ( FreeImage_GetBackgroundColor(src, &bkcolor)) { + if( FreeImage_GetBackgroundColor(src, &bkcolor) ) { FreeImage_SetBackgroundColor(dst, &bkcolor); } @@ -639,13 +639,13 @@ BOOL DLL_CALLCONV FreeImage_Paste(FIBITMAP *dst, FIBITMAP *src, int left, int top, int alpha) { BOOL bResult = FALSE; - if (!FreeImage_HasPixels(src) || !FreeImage_HasPixels(dst)) return FALSE; + if(!FreeImage_HasPixels(src) || !FreeImage_HasPixels(dst)) return FALSE; // check the size of src image - if ((left < 0) || (top < 0)) { + if((left < 0) || (top < 0)) { return FALSE; } - if ((left + FreeImage_GetWidth(src) > FreeImage_GetWidth(dst)) || (top + FreeImage_GetHeight(src) > FreeImage_GetHeight(dst))) { + if((left + FreeImage_GetWidth(src) > FreeImage_GetWidth(dst)) || (top + FreeImage_GetHeight(src) > FreeImage_GetHeight(dst))) { return FALSE; } @@ -704,7 +704,7 @@ FreeImage_Paste(FIBITMAP *dst, FIBITMAP *src, int left, int top, int alpha) { return FALSE; } - if (!clone) return FALSE; + if(!clone) return FALSE; // paste src to dst switch(FreeImage_GetBPP(dst)) { diff --git a/plugins/AdvaImg/src/FreeImageToolkit/Display.cpp b/plugins/AdvaImg/src/FreeImageToolkit/Display.cpp index 3e4807042d..245c5c3a18 100644 --- a/plugins/AdvaImg/src/FreeImageToolkit/Display.cpp +++ b/plugins/AdvaImg/src/FreeImageToolkit/Display.cpp @@ -40,20 +40,20 @@ For colour images, the computation is done separately for R, G, and B samples. */ FIBITMAP * DLL_CALLCONV FreeImage_Composite(FIBITMAP *fg, BOOL useFileBkg, RGBQUAD *appBkColor, FIBITMAP *bg) { - if (!FreeImage_HasPixels(fg)) return NULL; + if(!FreeImage_HasPixels(fg)) return NULL; int width = FreeImage_GetWidth(fg); int height = FreeImage_GetHeight(fg); int bpp = FreeImage_GetBPP(fg); - if ((bpp != 8) && (bpp != 32)) + if((bpp != 8) && (bpp != 32)) return NULL; if(bg) { int bg_width = FreeImage_GetWidth(bg); int bg_height = FreeImage_GetHeight(bg); int bg_bpp = FreeImage_GetBPP(bg); - if ((bg_width != width) || (bg_height != height) || (bg_bpp != 24)) + if((bg_width != width) || (bg_height != height) || (bg_bpp != 24)) return NULL; } @@ -71,7 +71,7 @@ FreeImage_Composite(FIBITMAP *fg, BOOL useFileBkg, RGBQUAD *appBkColor, FIBITMAP // allocate the composite image FIBITMAP *composite = FreeImage_Allocate(width, height, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); - if (!composite) return NULL; + if(!composite) return NULL; // get the palette RGBQUAD *pal = FreeImage_GetPalette(fg); @@ -133,7 +133,7 @@ FreeImage_Composite(FIBITMAP *fg, BOOL useFileBkg, RGBQUAD *appBkColor, FIBITMAP // background color - if (!bHasBkColor) { + if(!bHasBkColor) { if(bg) { // get the background color from the background image bkc.rgbBlue = bg_bits[FI_RGBA_BLUE]; diff --git a/plugins/AdvaImg/src/FreeImageToolkit/JPEGTransform.cpp b/plugins/AdvaImg/src/FreeImageToolkit/JPEGTransform.cpp index 2d7399dcb2..5822f748a6 100644 --- a/plugins/AdvaImg/src/FreeImageToolkit/JPEGTransform.cpp +++ b/plugins/AdvaImg/src/FreeImageToolkit/JPEGTransform.cpp @@ -61,7 +61,7 @@ ls_jpeg_error_exit (j_common_ptr cinfo) { (*cinfo->err->output_message)(cinfo); // allow JPEG with a premature end of file - if ((cinfo)->err->msg_parm.i[0] != 13) { + if((cinfo)->err->msg_parm.i[0] != 13) { // let the memory manager delete any temp files before we die jpeg_destroy(cinfo); @@ -171,7 +171,7 @@ LosslessTransform(const FilenameIO *filenameIO, FREE_IMAGE_JPEG_OPERATION operat // crop option if(crop != NULL) { - if (!jtransform_parse_crop_spec(&transfoptions, crop)) { + if(!jtransform_parse_crop_spec(&transfoptions, crop)) { FreeImage_OutputMessageProc(FIF_JPEG, "Bogus crop argument %s", crop); throw(1); } @@ -180,14 +180,14 @@ LosslessTransform(const FilenameIO *filenameIO, FREE_IMAGE_JPEG_OPERATION operat // Open the input file if(bUseUnicode) { #ifdef _WIN32 - if ((fp = _wfopen(filenameIO->wsrc_file, L"rb")) == NULL) { + if((fp = _wfopen(filenameIO->wsrc_file, L"rb")) == NULL) { FreeImage_OutputMessageProc(FIF_JPEG, "Cannot open input file for reading"); } #else fp = NULL; #endif // _WIN32 } else { - if ((fp = fopen(filenameIO->src_file, "rb")) == NULL) { + if((fp = fopen(filenameIO->src_file, "rb")) == NULL) { FreeImage_OutputMessageProc(FIF_JPEG, "Cannot open %s for reading", filenameIO->src_file); } } @@ -211,7 +211,7 @@ LosslessTransform(const FilenameIO *filenameIO, FREE_IMAGE_JPEG_OPERATION operat // Prepare transformation workspace // Fails right away if perfect flag is TRUE and transformation is not perfect - if ( !jtransform_request_workspace(&srcinfo, &transfoptions)) { + if( !jtransform_request_workspace(&srcinfo, &transfoptions) ) { FreeImage_OutputMessageProc(FIF_JPEG, "Transformation is not perfect"); throw(1); } @@ -237,14 +237,14 @@ LosslessTransform(const FilenameIO *filenameIO, FREE_IMAGE_JPEG_OPERATION operat // Open the output file if(bUseUnicode) { #ifdef _WIN32 - if ((fp = _wfopen(filenameIO->wdst_file, L"wb")) == NULL) { + if((fp = _wfopen(filenameIO->wdst_file, L"wb")) == NULL) { FreeImage_OutputMessageProc(FIF_JPEG, "Cannot open output file for writing"); } #else fp = NULL; #endif // _WIN32 } else { - if ((fp = fopen(filenameIO->dst_file, "wb")) == NULL) { + if((fp = fopen(filenameIO->dst_file, "wb")) == NULL) { FreeImage_OutputMessageProc(FIF_JPEG, "Cannot open %s for writing", filenameIO->dst_file); } } diff --git a/plugins/AdvaImg/src/FreeImageToolkit/MultigridPoissonSolver.cpp b/plugins/AdvaImg/src/FreeImageToolkit/MultigridPoissonSolver.cpp index a31961447a..3b577cbd0a 100644 --- a/plugins/AdvaImg/src/FreeImageToolkit/MultigridPoissonSolver.cpp +++ b/plugins/AdvaImg/src/FreeImageToolkit/MultigridPoissonSolver.cpp @@ -68,7 +68,7 @@ static void fmg_restrict(FIBITMAP *UC, FIBITMAP *UF, int nc) { // 0.5 * UF(row_uf, col_uf) + 0.125 * [ UF(row_uf+1, col_uf) + UF(row_uf-1, col_uf) + UF(row_uf, col_uf+1) + UF(row_uf, col_uf-1) ] float *uc_pixel = uc_scan + col_uc; const float *uf_center = uf_scan + col_uf; - *uc_pixel = 0.5F * *uf_center + 0.125F * ( *(uf_center + uf_pitch) + *(uf_center - uf_pitch) + *(uf_center + 1) + *(uf_center - 1)); + *uc_pixel = 0.5F * *uf_center + 0.125F * ( *(uf_center + uf_pitch) + *(uf_center - uf_pitch) + *(uf_center + 1) + *(uf_center - 1) ); } uc_scan += uc_pitch; } @@ -158,8 +158,8 @@ static void fmg_prolongate(FIBITMAP *UF, FIBITMAP *UC, int nf) { for(row_uf = 1; row_uf < nf-1; row_uf += 2) { float *uf_scan = uf_bits + row_uf * uf_pitch; for (col_uf = 0; col_uf < nf; col_uf += 2) { - // calculate UF(row_uf, col_uf) = 0.5 * ( UF(row_uf+1, col_uf) + UF(row_uf-1, col_uf)) - uf_scan[col_uf] = 0.5F * ( *(uf_scan + uf_pitch + col_uf) + *(uf_scan - uf_pitch + col_uf)); + // calculate UF(row_uf, col_uf) = 0.5 * ( UF(row_uf+1, col_uf) + UF(row_uf-1, col_uf) ) + uf_scan[col_uf] = 0.5F * ( *(uf_scan + uf_pitch + col_uf) + *(uf_scan - uf_pitch + col_uf) ); } } } @@ -168,7 +168,7 @@ static void fmg_prolongate(FIBITMAP *UF, FIBITMAP *UC, int nf) { float *uf_scan = uf_bits; for(row_uf = 0; row_uf < nf; row_uf++) { for (col_uf = 1; col_uf < nf-1; col_uf += 2) { - // calculate UF(row_uf, col_uf) = 0.5 * ( UF(row_uf, col_uf+1) + UF(row_uf, col_uf-1)) + // calculate UF(row_uf, col_uf) = 0.5 * ( UF(row_uf, col_uf+1) + UF(row_uf, col_uf-1) ) uf_scan[col_uf] = 0.5F * ( uf_scan[col_uf + 1] + uf_scan[col_uf - 1] ); } uf_scan += uf_pitch; @@ -311,7 +311,7 @@ static BOOL fmg_mglin(FIBITMAP *U, int n, int ncycle) { #define _CREATE_ARRAY_GRID_(array, array_size) \ array = (FIBITMAP**)malloc(array_size * sizeof(FIBITMAP*));\ - if (!array) throw(1);\ + if(!array) throw(1);\ memset(array, 0, array_size * sizeof(FIBITMAP*)) #define _FREE_ARRAY_GRID_(array, array_size) \ @@ -351,7 +351,7 @@ static BOOL fmg_mglin(FIBITMAP *U, int n, int ncycle) { // allocate storage for r.h.s. on grid (ng - 2) ... IRHO[ngrid] = FreeImage_AllocateT(FIT_FLOAT, nn, nn); - if (!IRHO[ngrid]) throw(1); + if(!IRHO[ngrid]) throw(1); // ... and fill it by restricting from the fine grid fmg_restrict(IRHO[ngrid], U, nn); @@ -361,16 +361,16 @@ static BOOL fmg_mglin(FIBITMAP *U, int n, int ncycle) { nn = nn/2 + 1; ngrid--; IRHO[ngrid] = FreeImage_AllocateT(FIT_FLOAT, nn, nn); - if (!IRHO[ngrid]) throw(1); + if(!IRHO[ngrid]) throw(1); fmg_restrict(IRHO[ngrid], IRHO[ngrid+1], nn); } nn = 3; IU[0] = FreeImage_AllocateT(FIT_FLOAT, nn, nn); - if (!IU[0]) throw(1); + if(!IU[0]) throw(1); IRHS[0] = FreeImage_AllocateT(FIT_FLOAT, nn, nn); - if (!IRHS[0]) throw(1); + if(!IRHS[0]) throw(1); // initial solution on coarsest grid fmg_solve(IU[0], IRHO[0]); @@ -384,11 +384,11 @@ static BOOL fmg_mglin(FIBITMAP *U, int n, int ncycle) { nn = 2*nn - 1; IU[j] = FreeImage_AllocateT(FIT_FLOAT, nn, nn); - if (!IU[j]) throw(1); + if(!IU[j]) throw(1); IRHS[j] = FreeImage_AllocateT(FIT_FLOAT, nn, nn); - if (!IRHS[j]) throw(1); + if(!IRHS[j]) throw(1); IRES[j] = FreeImage_AllocateT(FIT_FLOAT, nn, nn); - if (!IRES[j]) throw(1); + if(!IRES[j]) throw(1); fmg_prolongate(IU[j], IU[j-1], nn); @@ -464,7 +464,7 @@ where j is such that 2^j is the nearest larger dimension corresponding to MAX(im */ FIBITMAP* DLL_CALLCONV FreeImage_MultigridPoissonSolver(FIBITMAP *Laplacian, int ncycle) { - if (!FreeImage_HasPixels(Laplacian)) return NULL; + if(!FreeImage_HasPixels(Laplacian)) return NULL; int width = FreeImage_GetWidth(Laplacian); int height = FreeImage_GetHeight(Laplacian); @@ -473,7 +473,7 @@ FreeImage_MultigridPoissonSolver(FIBITMAP *Laplacian, int ncycle) { int n = MAX(width, height); int size = 0; while((n >>= 1) > 0) size++; - if ((1 << size) < MAX(width, height)) { + if((1 << size) < MAX(width, height)) { size++; } // size must be of the form 2^j + 1 for some integer j @@ -481,7 +481,7 @@ FreeImage_MultigridPoissonSolver(FIBITMAP *Laplacian, int ncycle) { // allocate a temporary square image I FIBITMAP *I = FreeImage_AllocateT(FIT_FLOAT, size, size); - if (!I) return NULL; + if(!I) return NULL; // copy Laplacian into I and shift pixels to create a boundary FreeImage_Paste(I, Laplacian, 1, 1, 255); diff --git a/plugins/AdvaImg/src/FreeImageToolkit/Rescale.cpp b/plugins/AdvaImg/src/FreeImageToolkit/Rescale.cpp index e79e5f456c..ffe667e7d4 100644 --- a/plugins/AdvaImg/src/FreeImageToolkit/Rescale.cpp +++ b/plugins/AdvaImg/src/FreeImageToolkit/Rescale.cpp @@ -1,231 +1,169 @@ -// ========================================================== -// Upsampling / downsampling routine -// -// Design and implementation by -// - Hervé Drolon (drolon@infonie.fr) -// -// This file is part of FreeImage 3 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include "Resize.h" - -FIBITMAP * DLL_CALLCONV -FreeImage_Rescale(FIBITMAP *src, int dst_width, int dst_height, FREE_IMAGE_FILTER filter) { - FIBITMAP *dst = NULL; - - if (!FreeImage_HasPixels(src) || (dst_width <= 0) || (dst_height <= 0) || (FreeImage_GetWidth(src) <= 0) || (FreeImage_GetHeight(src) <= 0)) { - return NULL; - } - - // select the filter - CGenericFilter *pFilter = NULL; - switch(filter) { - case FILTER_BOX: - pFilter = new(std::nothrow) CBoxFilter(); - break; - case FILTER_BICUBIC: - pFilter = new(std::nothrow) CBicubicFilter(); - break; - case FILTER_BILINEAR: - pFilter = new(std::nothrow) CBilinearFilter(); - break; - case FILTER_BSPLINE: - pFilter = new(std::nothrow) CBSplineFilter(); - break; - case FILTER_CATMULLROM: - pFilter = new(std::nothrow) CCatmullRomFilter(); - break; - case FILTER_LANCZOS3: - pFilter = new(std::nothrow) CLanczos3Filter(); - break; - } - - if (!pFilter) { - return NULL; - } - - CResizeEngine Engine(pFilter); - - // perform upsampling or downsampling - - if ((FreeImage_GetBPP(src) == 4) || (FreeImage_GetColorType(src) == FIC_PALETTE)) { - // special case for 4-bit images or color map indexed images ... - if(FreeImage_IsTransparent(src) == FALSE) { - FIBITMAP *src24 = NULL; - FIBITMAP *dst24 = NULL; - try { - // transparent conversion to 24-bit (any transparency table will be destroyed) - src24 = FreeImage_ConvertTo24Bits(src); - if (!src24) throw(1); - // perform upsampling or downsampling - dst24 = Engine.scale(src24, dst_width, dst_height); - if (!dst24) throw(1); - FreeImage_Unload(src24); src24 = NULL; - // color quantize to 8-bit - dst = FreeImage_ColorQuantize(dst24, FIQ_NNQUANT); - // free and return - FreeImage_Unload(dst24); - } catch(int) { - if(src24) FreeImage_Unload(src24); - if(dst24) FreeImage_Unload(dst24); - } - } else { - FIBITMAP *src32 = NULL; - try { - // transparent conversion to 32-bit (keep transparency) - src32 = FreeImage_ConvertTo32Bits(src); - if (!src32) throw(1); - // perform upsampling or downsampling - dst = Engine.scale(src32, dst_width, dst_height); - if (!dst) throw(1); - // free and return - FreeImage_Unload(src32); - } catch(int) { - if(src32) FreeImage_Unload(src32); - if(dst) FreeImage_Unload(dst); - } - } - } - else if ((FreeImage_GetBPP(src) == 16) && (FreeImage_GetImageType(src) == FIT_BITMAP)) { - // convert 16-bit RGB to 24-bit - FIBITMAP *src24 = NULL; - try { - // transparent conversion to 24-bit (any transparency table will be destroyed) - src24 = FreeImage_ConvertTo24Bits(src); - if (!src24) throw(1); - // perform upsampling or downsampling - dst = Engine.scale(src24, dst_width, dst_height); - if (!dst) throw(1); - // free and return - FreeImage_Unload(src24); - } catch(int) { - if(src24) FreeImage_Unload(src24); - if(dst) FreeImage_Unload(dst); - } - } - else { - // normal case : - // 1- or 8-bit greyscale, 24- or 32-bit RGB(A) images - // 16-bit greyscale, 48- or 64-bit RGB(A) images - // 32-bit float, 96- or 128-bit RGB(A) float images - dst = Engine.scale(src, dst_width, dst_height); - } - - - delete pFilter; - - // copy metadata from src to dst - FreeImage_CloneMetadata(dst, src); - - return dst; -} - -FIBITMAP * DLL_CALLCONV -FreeImage_MakeThumbnail(FIBITMAP *dib, int max_pixel_size, BOOL convert) { - FIBITMAP *thumbnail = NULL; - int new_width, new_height; - - if (!FreeImage_HasPixels(dib) || (max_pixel_size <= 0)) return NULL; - - int width = FreeImage_GetWidth(dib); - int height = FreeImage_GetHeight(dib); - - if(max_pixel_size == 0) max_pixel_size = 1; - - if ((width < max_pixel_size) && (height < max_pixel_size)) { - // image is smaller than the requested thumbnail - return FreeImage_Clone(dib); - } - - if(width > height) { - new_width = max_pixel_size; - // change image height with the same ratio - double ratio = ((double)new_width / (double)width); - new_height = (int)(height * ratio + 0.5); - if(new_height == 0) new_height = 1; - } else { - new_height = max_pixel_size; - // change image width with the same ratio - double ratio = ((double)new_height / (double)height); - new_width = (int)(width * ratio + 0.5); - if(new_width == 0) new_width = 1; - } - - const FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(dib); - - // perform downsampling using a bilinear interpolation - - switch(image_type) { - case FIT_BITMAP: - case FIT_UINT16: - case FIT_RGB16: - case FIT_RGBA16: - case FIT_FLOAT: - case FIT_RGBF: - case FIT_RGBAF: - { - FREE_IMAGE_FILTER filter = FILTER_BILINEAR; - thumbnail = FreeImage_Rescale(dib, new_width, new_height, filter); - } - break; - - case FIT_INT16: - case FIT_UINT32: - case FIT_INT32: - case FIT_DOUBLE: - case FIT_COMPLEX: - default: - // cannot rescale this kind of image - thumbnail = NULL; - break; - } - - if ((thumbnail != NULL) && (image_type != FIT_BITMAP) && convert) { - // convert to a standard bitmap - FIBITMAP *bitmap = NULL; - switch(image_type) { - case FIT_UINT16: - bitmap = FreeImage_ConvertTo8Bits(thumbnail); - break; - case FIT_RGB16: - bitmap = FreeImage_ConvertTo24Bits(thumbnail); - break; - case FIT_RGBA16: - bitmap = FreeImage_ConvertTo32Bits(thumbnail); - break; - case FIT_FLOAT: - bitmap = FreeImage_ConvertToStandardType(thumbnail, TRUE); - break; - case FIT_RGBF: - bitmap = FreeImage_ToneMapping(thumbnail, FITMO_DRAGO03); - break; - case FIT_RGBAF: - // no way to keep the transparency yet ... - FIBITMAP *rgbf = FreeImage_ConvertToRGBF(thumbnail); - bitmap = FreeImage_ToneMapping(rgbf, FITMO_DRAGO03); - FreeImage_Unload(rgbf); - break; - } - if(bitmap != NULL) { - FreeImage_Unload(thumbnail); - thumbnail = bitmap; - } - } - - // copy metadata from src to dst - FreeImage_CloneMetadata(thumbnail, dib); - - return thumbnail; -} +// ========================================================== +// Upsampling / downsampling routine +// +// Design and implementation by +// - Hervé Drolon (drolon@infonie.fr) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +#include "Resize.h" + +FIBITMAP * DLL_CALLCONV +FreeImage_Rescale(FIBITMAP *src, int dst_width, int dst_height, FREE_IMAGE_FILTER filter) { + FIBITMAP *dst = NULL; + + if (!FreeImage_HasPixels(src) || (dst_width <= 0) || (dst_height <= 0) || (FreeImage_GetWidth(src) <= 0) || (FreeImage_GetHeight(src) <= 0)) { + return NULL; + } + + // select the filter + CGenericFilter *pFilter = NULL; + switch (filter) { + case FILTER_BOX: + pFilter = new(std::nothrow) CBoxFilter(); + break; + case FILTER_BICUBIC: + pFilter = new(std::nothrow) CBicubicFilter(); + break; + case FILTER_BILINEAR: + pFilter = new(std::nothrow) CBilinearFilter(); + break; + case FILTER_BSPLINE: + pFilter = new(std::nothrow) CBSplineFilter(); + break; + case FILTER_CATMULLROM: + pFilter = new(std::nothrow) CCatmullRomFilter(); + break; + case FILTER_LANCZOS3: + pFilter = new(std::nothrow) CLanczos3Filter(); + break; + } + + if (!pFilter) { + return NULL; + } + + CResizeEngine Engine(pFilter); + + dst = Engine.scale(src, dst_width, dst_height, 0, 0, + FreeImage_GetWidth(src), FreeImage_GetHeight(src)); + + delete pFilter; + + // copy metadata from src to dst + FreeImage_CloneMetadata(dst, src); + + return dst; +} + +FIBITMAP * DLL_CALLCONV +FreeImage_MakeThumbnail(FIBITMAP *dib, int max_pixel_size, BOOL convert) { + FIBITMAP *thumbnail = NULL; + int new_width, new_height; + + if(!FreeImage_HasPixels(dib) || (max_pixel_size <= 0)) return NULL; + + int width = FreeImage_GetWidth(dib); + int height = FreeImage_GetHeight(dib); + + if(max_pixel_size == 0) max_pixel_size = 1; + + if((width < max_pixel_size) && (height < max_pixel_size)) { + // image is smaller than the requested thumbnail + return FreeImage_Clone(dib); + } + + if(width > height) { + new_width = max_pixel_size; + // change image height with the same ratio + double ratio = ((double)new_width / (double)width); + new_height = (int)(height * ratio + 0.5); + if(new_height == 0) new_height = 1; + } else { + new_height = max_pixel_size; + // change image width with the same ratio + double ratio = ((double)new_height / (double)height); + new_width = (int)(width * ratio + 0.5); + if(new_width == 0) new_width = 1; + } + + const FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(dib); + + // perform downsampling using a bilinear interpolation + + switch(image_type) { + case FIT_BITMAP: + case FIT_UINT16: + case FIT_RGB16: + case FIT_RGBA16: + case FIT_FLOAT: + case FIT_RGBF: + case FIT_RGBAF: + { + FREE_IMAGE_FILTER filter = FILTER_BILINEAR; + thumbnail = FreeImage_Rescale(dib, new_width, new_height, filter); + } + break; + + case FIT_INT16: + case FIT_UINT32: + case FIT_INT32: + case FIT_DOUBLE: + case FIT_COMPLEX: + default: + // cannot rescale this kind of image + thumbnail = NULL; + break; + } + + if((thumbnail != NULL) && (image_type != FIT_BITMAP) && convert) { + // convert to a standard bitmap + FIBITMAP *bitmap = NULL; + switch(image_type) { + case FIT_UINT16: + bitmap = FreeImage_ConvertTo8Bits(thumbnail); + break; + case FIT_RGB16: + bitmap = FreeImage_ConvertTo24Bits(thumbnail); + break; + case FIT_RGBA16: + bitmap = FreeImage_ConvertTo32Bits(thumbnail); + break; + case FIT_FLOAT: + bitmap = FreeImage_ConvertToStandardType(thumbnail, TRUE); + break; + case FIT_RGBF: + bitmap = FreeImage_ToneMapping(thumbnail, FITMO_DRAGO03); + break; + case FIT_RGBAF: + // no way to keep the transparency yet ... + FIBITMAP *rgbf = FreeImage_ConvertToRGBF(thumbnail); + bitmap = FreeImage_ToneMapping(rgbf, FITMO_DRAGO03); + FreeImage_Unload(rgbf); + break; + } + if(bitmap != NULL) { + FreeImage_Unload(thumbnail); + thumbnail = bitmap; + } + } + + // copy metadata from src to dst + FreeImage_CloneMetadata(thumbnail, dib); + + return thumbnail; +} diff --git a/plugins/AdvaImg/src/FreeImageToolkit/Resize.cpp b/plugins/AdvaImg/src/FreeImageToolkit/Resize.cpp index 5421bd47ab..f342bb794e 100644 --- a/plugins/AdvaImg/src/FreeImageToolkit/Resize.cpp +++ b/plugins/AdvaImg/src/FreeImageToolkit/Resize.cpp @@ -1,656 +1,1992 @@ -// ========================================================== -// Upsampling / downsampling classes -// -// Design and implementation by -// - Hervé Drolon (drolon@infonie.fr) -// - Detlev Vendt (detlev.vendt@brillit.de) -// -// This file is part of FreeImage 3 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include "Resize.h" - -/** - Filter weights table. - This class stores contribution information for an entire line (row or column). -*/ -CWeightsTable::CWeightsTable(CGenericFilter *pFilter, unsigned uDstSize, unsigned uSrcSize) { - unsigned u; - double dWidth; - double dFScale = 1.0; - const double dFilterWidth = pFilter->GetWidth(); - - // scale factor - const double dScale = double(uDstSize) / double(uSrcSize); - - if(dScale < 1.0) { - // minification - dWidth = dFilterWidth / dScale; - dFScale = dScale; - } else { - // magnification - dWidth= dFilterWidth; - } - - // allocate a new line contributions structure - // - // window size is the number of sampled pixels - m_WindowSize = 2 * (int)ceil(dWidth) + 1; - m_LineLength = uDstSize; - // allocate list of contributions - m_WeightTable = (Contribution*)malloc(m_LineLength * sizeof(Contribution)); - for(u = 0 ; u < m_LineLength ; u++) { - // allocate contributions for every pixel - m_WeightTable[u].Weights = (double*)malloc(m_WindowSize * sizeof(double)); - } - - // offset for discrete to continuous coordinate conversion - const double dOffset = (0.5 / dScale) - 0.5; - - - for(u = 0; u < m_LineLength; u++) { - // scan through line of contributions - const double dCenter = (double)u / dScale + dOffset; // reverse mapping - // find the significant edge points that affect the pixel - int iLeft = MAX (0, (int)floor (dCenter - dWidth)); - int iRight = MIN ((int)ceil (dCenter + dWidth), int(uSrcSize) - 1); - - // cut edge points to fit in filter window in case of spill-off - if ((iRight - iLeft + 1) > int(m_WindowSize)) { - if(iLeft < (int(uSrcSize) - 1 / 2)) { - iLeft++; - } else { - iRight--; - } - } - - m_WeightTable[u].Left = iLeft; - m_WeightTable[u].Right = iRight; - - int iSrc = 0; - double dTotalWeight = 0; // zero sum of weights - for(iSrc = iLeft; iSrc <= iRight; iSrc++) { - // calculate weights - const double weight = dFScale * pFilter->Filter(dFScale * (dCenter - (double)iSrc)); - m_WeightTable[u].Weights[iSrc-iLeft] = weight; - dTotalWeight += weight; - } - if ((dTotalWeight > 0) && (dTotalWeight != 1)) { - // normalize weight of neighbouring points - for(iSrc = iLeft; iSrc <= iRight; iSrc++) { - // normalize point - m_WeightTable[u].Weights[iSrc-iLeft] /= dTotalWeight; - } - // simplify the filter, discarding null weights at the right - iSrc = iRight - iLeft; - while(m_WeightTable[u].Weights[iSrc] == 0){ - m_WeightTable[u].Right--; - iSrc--; - if(m_WeightTable[u].Right == m_WeightTable[u].Left) - break; - } - - } - } -} - -CWeightsTable::~CWeightsTable() { - for(unsigned u = 0; u < m_LineLength; u++) { - // free contributions for every pixel - free(m_WeightTable[u].Weights); - } - // free list of pixels contributions - free(m_WeightTable); -} - -// --------------------------------------------- - -/** - CResizeEngine
- This class performs filtered zoom. It scales an image to the desired dimensions with - any of the CGenericFilter derived filter class.
- It works with 8-, 24- and 32-bit buffers.

- - References :
- [1] Paul Heckbert, C code to zoom raster images up or down, with nice filtering. - UC Berkeley, August 1989. [online] http://www-2.cs.cmu.edu/afs/cs.cmu.edu/Web/People/ph/heckbert.html - [2] Eran Yariv, Two Pass Scaling using Filters. The Code Project, December 1999. - [online] http://www.codeproject.com/bitmap/2_pass_scaling.asp - -*/ - -FIBITMAP* CResizeEngine::scale(FIBITMAP *src, unsigned dst_width, unsigned dst_height) { - unsigned src_width = FreeImage_GetWidth(src); - unsigned src_height = FreeImage_GetHeight(src); - - unsigned redMask = FreeImage_GetRedMask(src); - unsigned greenMask = FreeImage_GetGreenMask(src); - unsigned blueMask = FreeImage_GetBlueMask(src); - - unsigned bpp = FreeImage_GetBPP(src); - if(bpp == 1) { - // convert output to 8-bit - bpp = 8; - } - - FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(src); - - // allocate the dst image - FIBITMAP *dst = FreeImage_AllocateT(image_type, dst_width, dst_height, bpp, redMask, greenMask, blueMask); - if (!dst) return NULL; - - if(bpp == 8) { - if(FreeImage_GetColorType(src) == FIC_MINISWHITE) { - // build an inverted greyscale palette - RGBQUAD *dst_pal = FreeImage_GetPalette(dst); - for(unsigned i = 0; i < 256; i++) { - dst_pal[i].rgbRed = dst_pal[i].rgbGreen = dst_pal[i].rgbBlue = (BYTE)(255 - i); - } - } else { - // build a greyscale palette - RGBQUAD *dst_pal = FreeImage_GetPalette(dst); - for(unsigned i = 0; i < 256; i++) { - dst_pal[i].rgbRed = dst_pal[i].rgbGreen = dst_pal[i].rgbBlue = (BYTE)i; - } - } - } - - /** - Decide which filtering order (xy or yx) is faster for this mapping. - --- The theory --- - Try to minimize calculations by counting the number of convolution multiplies - if(dst_width*src_height <= src_width*dst_height) { - // xy filtering - } else { - // yx filtering - } - --- The practice --- - Try to minimize calculations by counting the number of vertical convolutions (the most time consuming task) - if(dst_width*dst_height <= src_width*dst_height) { - // xy filtering - } else { - // yx filtering - } - */ - - if(dst_width <= src_width) { - // xy filtering - // ------------- - - // allocate a temporary image - FIBITMAP *tmp = FreeImage_AllocateT(image_type, dst_width, src_height, bpp, redMask, greenMask, blueMask); - if (!tmp) { - FreeImage_Unload(dst); - return NULL; - } - - // scale source image horizontally into temporary image - horizontalFilter(src, src_width, src_height, tmp, dst_width, src_height); - - // scale temporary image vertically into result image - verticalFilter(tmp, dst_width, src_height, dst, dst_width, dst_height); - - // free temporary image - FreeImage_Unload(tmp); - - } else { - // yx filtering - // ------------- - - // allocate a temporary image - FIBITMAP *tmp = FreeImage_AllocateT(image_type, src_width, dst_height, bpp, redMask, greenMask, blueMask); - if (!tmp) { - FreeImage_Unload(dst); - return NULL; - } - - // scale source image vertically into temporary image - verticalFilter(src, src_width, src_height, tmp, src_width, dst_height); - - // scale temporary image horizontally into result image - horizontalFilter(tmp, src_width, dst_height, dst, dst_width, dst_height); - - // free temporary image - FreeImage_Unload(tmp); - } - - return dst; -} - - -/// Performs horizontal image filtering -void CResizeEngine::horizontalFilter(FIBITMAP *src, unsigned src_width, unsigned src_height, FIBITMAP *dst, unsigned dst_width, unsigned dst_height) { - if(dst_width == src_width) { - // no scaling required, just copy - switch(FreeImage_GetBPP(src)) { - case 1: - { - if(FreeImage_GetBPP(dst) != 8) break; - for(unsigned y = 0; y < dst_height; y++) { - // convert each row - BYTE *src_bits = FreeImage_GetScanLine(src, y); - BYTE *dst_bits = FreeImage_GetScanLine(dst, y); - FreeImage_ConvertLine1To8(dst_bits, src_bits, dst_width); - } - } - break; - - default: - { - const BYTE *src_bits = FreeImage_GetBits(src); - BYTE *dst_bits = FreeImage_GetBits(dst); - memcpy(dst_bits, src_bits, dst_height * FreeImage_GetPitch(dst)); - } - break; - } - } - else { - - // allocate and calculate the contributions - CWeightsTable weightsTable(m_pFilter, dst_width, src_width); - - // step through rows - switch(FreeImage_GetImageType(src)) { - case FIT_BITMAP: - { - switch(FreeImage_GetBPP(src)) { - case 1: - { - // scale and convert to 8-bit - if(FreeImage_GetBPP(dst) != 8) break; - - for(unsigned y = 0; y < dst_height; y++) { - // scale each row - const BYTE *src_bits = FreeImage_GetScanLine(src, y); - BYTE *dst_bits = FreeImage_GetScanLine(dst, y); - - for(unsigned x = 0; x < dst_width; x++) { - // loop through row - double value = 0; - const unsigned iLeft = weightsTable.getLeftBoundary(x); // retrieve left boundary - const unsigned iRight = weightsTable.getRightBoundary(x); // retrieve right boundary - - for(unsigned i = iLeft; i <= iRight; i++) { - // scan between boundaries - // accumulate weighted effect of each neighboring pixel - const double weight = weightsTable.getWeight(x, i-iLeft); - - const BYTE pixel = (src_bits[i >> 3] & (0x80 >> (i & 0x07))) != 0; - value += (weight * (double)pixel); - } - value *= 255; - - // clamp and place result in destination pixel - dst_bits[x] = (BYTE)CLAMP((int)(value + 0.5), 0, 255); - } - } - } - break; - - case 8: - case 24: - case 32: - { - // Calculate the number of bytes per pixel (1 for 8-bit, 3 for 24-bit or 4 for 32-bit) - const unsigned bytespp = FreeImage_GetLine(src) / FreeImage_GetWidth(src); - - for(unsigned y = 0; y < dst_height; y++) { - // scale each row - const BYTE *src_bits = FreeImage_GetScanLine(src, y); - BYTE *dst_bits = FreeImage_GetScanLine(dst, y); - - for(unsigned x = 0; x < dst_width; x++) { - // loop through row - double value[4] = {0, 0, 0, 0}; // 4 = 32 bpp max - const unsigned iLeft = weightsTable.getLeftBoundary(x); // retrieve left boundary - const unsigned iRight = weightsTable.getRightBoundary(x); // retrieve right boundary - - for(unsigned i = iLeft; i <= iRight; i++) { - // scan between boundaries - // accumulate weighted effect of each neighboring pixel - const double weight = weightsTable.getWeight(x, i-iLeft); - - unsigned index = i * bytespp; // pixel index - for (unsigned j = 0; j < bytespp; j++) { - value[j] += (weight * (double)src_bits[index++]); - } - } - - // clamp and place result in destination pixel - for (unsigned j = 0; j < bytespp; j++) { - dst_bits[j] = (BYTE)CLAMP((int)(value[j] + 0.5), 0, 0xFF); - } - - dst_bits += bytespp; - } - } - } - break; - } - } - break; - - case FIT_UINT16: - case FIT_RGB16: - case FIT_RGBA16: - { - // Calculate the number of words per pixel (1 for 16-bit, 3 for 48-bit or 4 for 64-bit) - const unsigned wordspp = (FreeImage_GetLine(src) / FreeImage_GetWidth(src)) / sizeof(WORD); - - for(unsigned y = 0; y < dst_height; y++) { - // scale each row - const WORD *src_bits = (WORD*)FreeImage_GetScanLine(src, y); - WORD *dst_bits = (WORD*)FreeImage_GetScanLine(dst, y); - - for(unsigned x = 0; x < dst_width; x++) { - // loop through row - double value[4] = {0, 0, 0, 0}; // 4 = 64 bpp max - const unsigned iLeft = weightsTable.getLeftBoundary(x); // retrieve left boundary - const unsigned iRight = weightsTable.getRightBoundary(x); // retrieve right boundary - - for(unsigned i = iLeft; i <= iRight; i++) { - // scan between boundaries - // accumulate weighted effect of each neighboring pixel - const double weight = weightsTable.getWeight(x, i-iLeft); - - unsigned index = i * wordspp; // pixel index - for (unsigned j = 0; j < wordspp; j++) { - value[j] += (weight * (double)src_bits[index++]); - } - } - - // clamp and place result in destination pixel - for (unsigned j = 0; j < wordspp; j++) { - dst_bits[j] = (WORD)CLAMP((int)(value[j] + 0.5), 0, 0xFFFF); - } - - dst_bits += wordspp; - } - } - } - break; - - case FIT_FLOAT: - case FIT_RGBF: - case FIT_RGBAF: - { - // Calculate the number of floats per pixel (1 for 32-bit, 3 for 96-bit or 4 for 128-bit) - const unsigned floatspp = (FreeImage_GetLine(src) / FreeImage_GetWidth(src)) / sizeof(float); - - for(unsigned y = 0; y < dst_height; y++) { - // scale each row - const float *src_bits = (float*)FreeImage_GetScanLine(src, y); - float *dst_bits = (float*)FreeImage_GetScanLine(dst, y); - - for(unsigned x = 0; x < dst_width; x++) { - // loop through row - double value[4] = {0, 0, 0, 0}; // 4 = 128 bpp max - const unsigned iLeft = weightsTable.getLeftBoundary(x); // retrieve left boundary - const unsigned iRight = weightsTable.getRightBoundary(x); // retrieve right boundary - - for(unsigned i = iLeft; i <= iRight; i++) { - // scan between boundaries - // accumulate weighted effect of each neighboring pixel - const double weight = weightsTable.getWeight(x, i-iLeft); - - unsigned index = i * floatspp; // pixel index - for (unsigned j = 0; j < floatspp; j++) { - value[j] += (weight * (double)src_bits[index++]); - } - } - - // place result in destination pixel - for (unsigned j = 0; j < floatspp; j++) { - dst_bits[j] = (float)value[j]; - } - - dst_bits += floatspp; - } - } - } - break; - - } - } -} - -/// Performs vertical image filtering -void CResizeEngine::verticalFilter(FIBITMAP *src, unsigned src_width, unsigned src_height, FIBITMAP *dst, unsigned dst_width, unsigned dst_height) { - if(src_height == dst_height) { - // no scaling required, just copy - switch(FreeImage_GetBPP(src)) { - case 1: - { - if(FreeImage_GetBPP(dst) != 8) break; - for(unsigned y = 0; y < dst_height; y++) { - // convert each row - BYTE *src_bits = FreeImage_GetScanLine(src, y); - BYTE *dst_bits = FreeImage_GetScanLine(dst, y); - FreeImage_ConvertLine1To8(dst_bits, src_bits, dst_width); - } - } - break; - - default: - { - const BYTE *src_bits = FreeImage_GetBits(src); - BYTE *dst_bits = FreeImage_GetBits(dst); - memcpy(dst_bits, src_bits, dst_height * FreeImage_GetPitch(dst)); - } - break; - } - - } - else { - - // allocate and calculate the contributions - CWeightsTable weightsTable(m_pFilter, dst_height, src_height); - - // step through columns - switch(FreeImage_GetImageType(src)) { - case FIT_BITMAP: - { - switch(FreeImage_GetBPP(src)) { - case 1: - { - // scale and convert to 8-bit - if(FreeImage_GetBPP(dst) != 8) break; - - const unsigned src_pitch = FreeImage_GetPitch(src); - const unsigned dst_pitch = FreeImage_GetPitch(dst); - - for(unsigned x = 0; x < dst_width; x++) { - - // work on column x in dst - BYTE *dst_bits = FreeImage_GetBits(dst) + x; - - // scale each column - for(unsigned y = 0; y < dst_height; y++) { - // loop through column - double value = 0; - const unsigned iLeft = weightsTable.getLeftBoundary(y); // retrieve left boundary - const unsigned iRight = weightsTable.getRightBoundary(y); // retrieve right boundary - - BYTE *src_bits = FreeImage_GetScanLine(src, iLeft); - - for(unsigned i = iLeft; i <= iRight; i++) { - // scan between boundaries - // accumulate weighted effect of each neighboring pixel - const double weight = weightsTable.getWeight(y, i-iLeft); - - const BYTE pixel = (src_bits[x >> 3] & (0x80 >> (x & 0x07))) != 0; - value += (weight * (double)pixel); - - src_bits += src_pitch; - } - value *= 255; - - // clamp and place result in destination pixel - *dst_bits = (BYTE)CLAMP((int)(value + 0.5), 0, 0xFF); - - dst_bits += dst_pitch; - } - } - } - break; - - case 8: - case 24: - case 32: - { - // Calculate the number of bytes per pixel (1 for 8-bit, 3 for 24-bit or 4 for 32-bit) - const unsigned bytespp = FreeImage_GetLine(src) / FreeImage_GetWidth(src); - - const unsigned src_pitch = FreeImage_GetPitch(src); - const unsigned dst_pitch = FreeImage_GetPitch(dst); - - for(unsigned x = 0; x < dst_width; x++) { - const unsigned index = x * bytespp; // pixel index - - // work on column x in dst - BYTE *dst_bits = FreeImage_GetBits(dst) + index; - - // scale each column - for(unsigned y = 0; y < dst_height; y++) { - // loop through column - double value[4] = {0, 0, 0, 0}; // 4 = 32 bpp max - const unsigned iLeft = weightsTable.getLeftBoundary(y); // retrieve left boundary - const unsigned iRight = weightsTable.getRightBoundary(y); // retrieve right boundary - - const BYTE *src_bits = FreeImage_GetScanLine(src, iLeft) + index; - - for(unsigned i = iLeft; i <= iRight; i++) { - // scan between boundaries - // accumulate weighted effect of each neighboring pixel - const double weight = weightsTable.getWeight(y, i-iLeft); - for (unsigned j = 0; j < bytespp; j++) { - value[j] += (weight * (double)src_bits[j]); - } - - src_bits += src_pitch; - } - - // clamp and place result in destination pixel - for (unsigned j = 0; j < bytespp; j++) { - dst_bits[j] = (BYTE)CLAMP((int)(value[j] + 0.5), 0, 0xFF); - } - - dst_bits += dst_pitch; - } - } - } - break; - } - } - break; - - case FIT_UINT16: - case FIT_RGB16: - case FIT_RGBA16: - { - // Calculate the number of words per pixel (1 for 16-bit, 3 for 48-bit or 4 for 64-bit) - const unsigned wordspp = (FreeImage_GetLine(src) / FreeImage_GetWidth(src)) / sizeof(WORD); - - const unsigned src_pitch = FreeImage_GetPitch(src) / sizeof(WORD); - const unsigned dst_pitch = FreeImage_GetPitch(dst) / sizeof(WORD); - - for(unsigned x = 0; x < dst_width; x++) { - const unsigned index = x * wordspp; // pixel index - - // work on column x in dst - WORD *dst_bits = (WORD*)FreeImage_GetBits(dst) + index; - - // scale each column - for(unsigned y = 0; y < dst_height; y++) { - // loop through column - double value[4] = {0, 0, 0, 0}; // 4 = 64 bpp max - const unsigned iLeft = weightsTable.getLeftBoundary(y); // retrieve left boundary - const unsigned iRight = weightsTable.getRightBoundary(y); // retrieve right boundary - - const WORD *src_bits = (WORD*)FreeImage_GetScanLine(src, iLeft) + index; - - for(unsigned i = iLeft; i <= iRight; i++) { - // scan between boundaries - // accumulate weighted effect of each neighboring pixel - const double weight = weightsTable.getWeight(y, i-iLeft); - for (unsigned j = 0; j < wordspp; j++) { - value[j] += (weight * (double)src_bits[j]); - } - - src_bits += src_pitch; - } - - // clamp and place result in destination pixel - for (unsigned j = 0; j < wordspp; j++) { - dst_bits[j] = (WORD)CLAMP((int)(value[j] + 0.5), 0, 0xFFFF); - } - - dst_bits += dst_pitch; - } - } - } - break; - - case FIT_FLOAT: - case FIT_RGBF: - case FIT_RGBAF: - { - // Calculate the number of floats per pixel (1 for 32-bit, 3 for 96-bit or 4 for 128-bit) - const unsigned floatspp = (FreeImage_GetLine(src) / FreeImage_GetWidth(src)) / sizeof(float); - - const unsigned src_pitch = FreeImage_GetPitch(src) / sizeof(float); - const unsigned dst_pitch = FreeImage_GetPitch(dst) / sizeof(float); - - for(unsigned x = 0; x < dst_width; x++) { - const unsigned index = x * floatspp; // pixel index - - // work on column x in dst - float *dst_bits = (float*)FreeImage_GetBits(dst) + index; - - // scale each column - for(unsigned y = 0; y < dst_height; y++) { - // loop through column - double value[4] = {0, 0, 0, 0}; // 4 = 128 bpp max - const unsigned iLeft = weightsTable.getLeftBoundary(y); // retrieve left boundary - const unsigned iRight = weightsTable.getRightBoundary(y); // retrieve right boundary - - const float *src_bits = (float*)FreeImage_GetScanLine(src, iLeft) + index; - - for(unsigned i = iLeft; i <= iRight; i++) { - // scan between boundaries - // accumulate weighted effect of each neighboring pixel - const double weight = weightsTable.getWeight(y, i-iLeft); - for (unsigned j = 0; j < floatspp; j++) { - value[j] += (weight * (double)src_bits[j]); - } - - src_bits += src_pitch; - } - - // clamp and place result in destination pixel - for (unsigned j = 0; j < floatspp; j++) { - dst_bits[j] = (float)value[j]; - } - - dst_bits += dst_pitch; - } - } - } - break; - - } - } -} - +// ========================================================== +// Upsampling / downsampling classes +// +// Design and implementation by +// - Hervé Drolon (drolon@infonie.fr) +// - Detlev Vendt (detlev.vendt@brillit.de) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +#include "Resize.h" + +/** +Returns the color type of a bitmap. In contrast to FreeImage_GetColorType, +this function optionally supports a boolean OUT parameter, that receives TRUE, +if the specified bitmap is greyscale, that is, it consists of grey colors only. +Although it returns the same value as returned by FreeImage_GetColorType for all +image types, this extended function primarily is intended for palletized images, +since the boolean pointed to by 'bIsGreyscale' remains unchanged for RGB(A/F) +images. However, the outgoing boolean is properly maintained for palletized images, +as well as for any non-RGB image type, like FIT_UINTxx and FIT_DOUBLE, for example. +@param dib A pointer to a FreeImage bitmap to calculate the extended color type for +@param bIsGreyscale A pointer to a boolean, that receives TRUE, if the specified bitmap +is greyscale, that is, it consists of grey colors only. This parameter can be NULL. +@return the color type of the specified bitmap +*/ +static FREE_IMAGE_COLOR_TYPE +GetExtendedColorType(FIBITMAP *dib, BOOL *bIsGreyscale) { + const unsigned bpp = FreeImage_GetBPP(dib); + const unsigned size = CalculateUsedPaletteEntries(bpp); + const RGBQUAD * const pal = FreeImage_GetPalette(dib); + FREE_IMAGE_COLOR_TYPE color_type = FIC_MINISBLACK; + BOOL bIsGrey = TRUE; + + switch (bpp) { + case 1: + { + for (unsigned i = 0; i < size; i++) { + if ((pal[i].rgbRed != pal[i].rgbGreen) || (pal[i].rgbRed != pal[i].rgbBlue)) { + color_type = FIC_PALETTE; + bIsGrey = FALSE; + break; + } + } + if (bIsGrey) { + if (pal[0].rgbBlue == 255 && pal[1].rgbBlue == 0) { + color_type = FIC_MINISWHITE; + } else if (pal[0].rgbBlue != 0 || pal[1].rgbBlue != 255) { + color_type = FIC_PALETTE; + } + } + break; + } + + case 4: + case 8: + { + for (unsigned i = 0; i < size; i++) { + if ((pal[i].rgbRed != pal[i].rgbGreen) || (pal[i].rgbRed != pal[i].rgbBlue)) { + color_type = FIC_PALETTE; + bIsGrey = FALSE; + break; + } + if (color_type != FIC_PALETTE && pal[i].rgbBlue != i) { + if ((size - i - 1) != pal[i].rgbBlue) { + color_type = FIC_PALETTE; + if (!bIsGreyscale) { + // exit loop if we're not setting + // bIsGreyscale parameter + break; + } + } else { + color_type = FIC_MINISWHITE; + } + } + } + break; + } + + default: + { + color_type = FreeImage_GetColorType(dib); + bIsGrey = (color_type == FIC_MINISBLACK) ? TRUE : FALSE; + break; + } + + } + if (bIsGreyscale) { + *bIsGreyscale = bIsGrey; + } + + return color_type; +} + +/** +Returns a pointer to an RGBA palette, created from the specified bitmap. +The RGBA palette is a copy of the specified bitmap's palette, that, additionally +contains the bitmap's transparency information in the rgbReserved member +of the palette's RGBQUAD elements. +@param dib A pointer to a FreeImage bitmap to create the RGBA palette from. +@param buffer A pointer to the buffer to store the RGBA palette. +@return A pointer to the newly created RGBA palette or NULL, if the specified +bitmap is no palletized standard bitmap. If non-NULL, the returned value is +actually the pointer passed in parameter 'buffer'. +*/ +static inline RGBQUAD * +GetRGBAPalette(FIBITMAP *dib, RGBQUAD * const buffer) { + // clone the palette + const unsigned ncolors = FreeImage_GetColorsUsed(dib); + if (ncolors == 0) { + return NULL; + } + memcpy(buffer, FreeImage_GetPalette(dib), ncolors * sizeof(RGBQUAD)); + // merge the transparency table + const unsigned ntransp = MIN(ncolors, FreeImage_GetTransparencyCount(dib)); + const BYTE * const tt = FreeImage_GetTransparencyTable(dib); + for (unsigned i = 0; i < ntransp; i++) { + buffer[i].rgbReserved = tt[i]; + } + for (unsigned i = ntransp; i < ncolors; i++) { + buffer[i].rgbReserved = 255; + } + return buffer; +} + +// -------------------------------------------------------------------------- + +CWeightsTable::CWeightsTable(CGenericFilter *pFilter, unsigned uDstSize, unsigned uSrcSize) { + unsigned u; + double dWidth; + double dFScale = 1.0; + const double dFilterWidth = pFilter->GetWidth(); + + // scale factor + const double dScale = double(uDstSize) / double(uSrcSize); + + if(dScale < 1.0) { + // minification + dWidth = dFilterWidth / dScale; + dFScale = dScale; + } else { + // magnification + dWidth= dFilterWidth; + } + + // allocate a new line contributions structure + // + // window size is the number of sampled pixels + m_WindowSize = 2 * (int)ceil(dWidth) + 1; + m_LineLength = uDstSize; + // allocate list of contributions + m_WeightTable = (Contribution*)malloc(m_LineLength * sizeof(Contribution)); + for(u = 0 ; u < m_LineLength ; u++) { + // allocate contributions for every pixel + m_WeightTable[u].Weights = (double*)malloc(m_WindowSize * sizeof(double)); + } + + // offset for discrete to continuous coordinate conversion + const double dOffset = (0.5 / dScale) - 0.5; + + for(u = 0; u < m_LineLength; u++) { + // scan through line of contributions + const double dCenter = (double)u / dScale + dOffset; // reverse mapping + // find the significant edge points that affect the pixel + int iLeft = MAX (0, (int)floor (dCenter - dWidth)); + int iRight = MIN ((int)ceil (dCenter + dWidth), int(uSrcSize) - 1); + + // cut edge points to fit in filter window in case of spill-off + if((iRight - iLeft + 1) > int(m_WindowSize)) { + if(iLeft < (int(uSrcSize) - 1 / 2)) { + iLeft++; + } else { + iRight--; + } + } + + m_WeightTable[u].Left = iLeft; + m_WeightTable[u].Right = iRight; + + int iSrc = 0; + double dTotalWeight = 0; // zero sum of weights + for(iSrc = iLeft; iSrc <= iRight; iSrc++) { + // calculate weights + const double weight = dFScale * pFilter->Filter(dFScale * (dCenter - (double)iSrc)); + m_WeightTable[u].Weights[iSrc-iLeft] = weight; + dTotalWeight += weight; + } + if((dTotalWeight > 0) && (dTotalWeight != 1)) { + // normalize weight of neighbouring points + for(iSrc = iLeft; iSrc <= iRight; iSrc++) { + // normalize point + m_WeightTable[u].Weights[iSrc-iLeft] /= dTotalWeight; + } + // simplify the filter, discarding null weights at the right + iSrc = iRight - iLeft; + while(m_WeightTable[u].Weights[iSrc] == 0) { + m_WeightTable[u].Right--; + iSrc--; + if(m_WeightTable[u].Right == m_WeightTable[u].Left) { + break; + } + } + + } + } +} + +CWeightsTable::~CWeightsTable() { + for(unsigned u = 0; u < m_LineLength; u++) { + // free contributions for every pixel + free(m_WeightTable[u].Weights); + } + // free list of pixels contributions + free(m_WeightTable); +} + +// -------------------------------------------------------------------------- + +FIBITMAP* CResizeEngine::scale(FIBITMAP *src, unsigned dst_width, unsigned dst_height, unsigned src_left, unsigned src_top, unsigned src_width, unsigned src_height) { + + const FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(src); + const unsigned src_bpp = FreeImage_GetBPP(src); + + // determine the image's color type + BOOL bIsGreyscale = FALSE; + FREE_IMAGE_COLOR_TYPE color_type; + if (src_bpp <= 8) { + color_type = GetExtendedColorType(src, &bIsGreyscale); + } else { + color_type = FIC_RGB; + } + + // determine the required bit depth of the destination image + unsigned dst_bpp; + if (color_type == FIC_PALETTE && !bIsGreyscale) { + // non greyscale FIC_PALETTE images require a high-color destination + // image (24- or 32-bits depending on the image's transparent state) + dst_bpp = FreeImage_IsTransparent(src) ? 32 : 24; + } else if (src_bpp <= 8) { + // greyscale images require an 8-bit destination image + // (or a 32-bit image if the image is transparent) + dst_bpp = FreeImage_IsTransparent(src) ? 32 : 8; + } else if (src_bpp == 16 && image_type == FIT_BITMAP) { + // 16-bit 555 and 565 RGB images require a high-color destination image + // (fixed to 24 bits, since 16-bit RGBs don't support transparency in FreeImage) + dst_bpp = 24; + } else { + // bit depth remains unchanged for all other images + dst_bpp = src_bpp; + } + + // early exit if destination size is equal to source size + if ((src_width == dst_width) && (src_height == dst_height)) { + FIBITMAP *out = src; + FIBITMAP *tmp = src; + if ((src_width != FreeImage_GetWidth(src)) || (src_height != FreeImage_GetHeight(src))) { + out = FreeImage_Copy(tmp, src_left, src_top, src_left + src_width, src_top + src_height); + tmp = out; + } + if (src_bpp != dst_bpp) { + switch (dst_bpp) { + case 8: + out = FreeImage_ConvertToGreyscale(tmp); + if (tmp != src) { + FreeImage_Unload(tmp); + } + break; + + case 24: + out = FreeImage_ConvertTo24Bits(tmp); + if (tmp != src) { + FreeImage_Unload(tmp); + } + break; + + case 32: + out = FreeImage_ConvertTo32Bits(tmp); + if (tmp != src) { + FreeImage_Unload(tmp); + } + break; + } + } + + return (out != src) ? out : FreeImage_Clone(src); + } + + RGBQUAD pal_buffer[256]; + RGBQUAD *src_pal = NULL; + + // provide the source image's palette to the rescaler for + // FIC_PALETTE type images (this includes palletized greyscale + // images with an unordered palette) + if (color_type == FIC_PALETTE) { + if (dst_bpp == 32) { + // a 32 bit destination image signals transparency, so + // create an RGBA palette from the source palette + src_pal = GetRGBAPalette(src, pal_buffer); + } else { + src_pal = FreeImage_GetPalette(src); + } + } + + // allocate the dst image + FIBITMAP *dst = FreeImage_AllocateT(image_type, dst_width, dst_height, dst_bpp, 0, 0, 0); + if (!dst) { + return NULL; + } + + if (dst_bpp == 8) { + RGBQUAD * const dst_pal = FreeImage_GetPalette(dst); + if (color_type == FIC_MINISWHITE) { + // build an inverted greyscale palette + CREATE_GREYSCALE_PALETTE_REVERSE(dst_pal, 256); + } + /* + else { + // build a default greyscale palette + // Currently, FreeImage_AllocateT already creates a default + // greyscale palette for 8 bpp images, so we can skip this here. + CREATE_GREYSCALE_PALETTE(dst_pal, 256); + } + */ + } + + // calculate x and y offsets; since FreeImage uses bottom-up bitmaps, the + // value of src_offset_y is measured from the bottom of the image + unsigned src_offset_x = src_left; + unsigned src_offset_y; + if (src_top > 0) { + src_offset_y = FreeImage_GetHeight(src) - src_height - src_top; + } else { + src_offset_y = 0; + } + + /* + Decide which filtering order (xy or yx) is faster for this mapping. + --- The theory --- + Try to minimize calculations by counting the number of convolution multiplies + if(dst_width*src_height <= src_width*dst_height) { + // xy filtering + } else { + // yx filtering + } + --- The practice --- + Try to minimize calculations by counting the number of vertical convolutions (the most time consuming task) + if(dst_width*dst_height <= src_width*dst_height) { + // xy filtering + } else { + // yx filtering + } + */ + + if (dst_width <= src_width) { + // xy filtering + // ------------- + + FIBITMAP *tmp = NULL; + + if (src_width != dst_width) { + // source and destination widths are different so, we must + // filter horizontally + if (src_height != dst_height) { + // source and destination heights are also different so, we need + // a temporary image + tmp = FreeImage_AllocateT(image_type, dst_width, src_height, dst_bpp, 0, 0, 0); + if (!tmp) { + FreeImage_Unload(dst); + return NULL; + } + } else { + // source and destination heights are equal so, we can directly + // scale into destination image (second filter method will not + // be invoked) + tmp = dst; + } + + // scale source image horizontally into temporary (or destination) image + horizontalFilter(src, src_height, src_width, src_offset_x, src_offset_y, src_pal, tmp, dst_width); + + // set x and y offsets to zero for the second filter method + // invocation (the temporary image only contains the portion of + // the image to be rescaled with no offsets) + src_offset_x = 0; + src_offset_y = 0; + + // also ensure, that the second filter method gets no source + // palette (the temporary image is palletized only, if it is + // greyscale; in that case, it is an 8-bit image with a linear + // palette so, the source palette is not needed or will even be + // mismatching, if the source palette is unordered) + src_pal = NULL; + } else { + // source and destination widths are equal so, just copy the + // image pointer + tmp = src; + } + + if (src_height != dst_height) { + // source and destination heights are different so, scale + // temporary (or source) image vertically into destination image + verticalFilter(tmp, dst_width, src_height, src_offset_x, src_offset_y, src_pal, dst, dst_height); + } + + // free temporary image, if not pointing to either src or dst + if (tmp != src && tmp != dst) { + FreeImage_Unload(tmp); + } + + } else { + // yx filtering + // ------------- + + // Remark: + // The yx filtering branch could be more optimized by taking into, + // account that (src_width != dst_width) is always true, which + // follows from the above condition, which selects filtering order. + // Since (dst_width <= src_width) == TRUE selects xy filtering, + // both widths must be different when performing yx filtering. + // However, to make the code more robust, not depending on that + // condition and more symmetric to the xy filtering case, these + // (src_width != dst_width) conditions are still in place. + + FIBITMAP *tmp = NULL; + + if (src_height != dst_height) { + // source and destination heights are different so, we must + // filter vertically + if (src_width != dst_width) { + // source and destination widths are also different so, we need + // a temporary image + tmp = FreeImage_AllocateT(image_type, src_width, dst_height, dst_bpp, 0, 0, 0); + if (!tmp) { + FreeImage_Unload(dst); + return NULL; + } + } else { + // source and destination widths are equal so, we can directly + // scale into destination image (second filter method will not + // be invoked) + tmp = dst; + } + + // scale source image vertically into temporary (or destination) image + verticalFilter(src, src_width, src_height, src_offset_x, src_offset_y, src_pal, tmp, dst_height); + + // set x and y offsets to zero for the second filter method + // invocation (the temporary image only contains the portion of + // the image to be rescaled with no offsets) + src_offset_x = 0; + src_offset_y = 0; + + // also ensure, that the second filter method gets no source + // palette (the temporary image is palletized only, if it is + // greyscale; in that case, it is an 8-bit image with a linear + // palette so, the source palette is not needed or will even be + // mismatching, if the source palette is unordered) + src_pal = NULL; + + } else { + // source and destination heights are equal so, just copy the + // image pointer + tmp = src; + } + + if (src_width != dst_width) { + // source and destination heights are different so, scale + // temporary (or source) image horizontally into destination image + horizontalFilter(tmp, dst_height, src_width, src_offset_x, src_offset_y, src_pal, dst, dst_width); + } + + // free temporary image, if not pointing to either src or dst + if (tmp != src && tmp != dst) { + FreeImage_Unload(tmp); + } + } + + return dst; +} + +void CResizeEngine::horizontalFilter(FIBITMAP *const src, unsigned height, unsigned src_width, unsigned src_offset_x, unsigned src_offset_y, const RGBQUAD *const src_pal, FIBITMAP *const dst, unsigned dst_width) { + + // allocate and calculate the contributions + CWeightsTable weightsTable(m_pFilter, dst_width, src_width); + + // step through rows + switch(FreeImage_GetImageType(src)) { + case FIT_BITMAP: + { + switch(FreeImage_GetBPP(src)) { + case 1: + { + switch(FreeImage_GetBPP(dst)) { + case 8: + { + // transparently convert the 1-bit non-transparent greyscale + // image to 8 bpp + src_offset_x >>= 3; + if (src_pal) { + // we have got a palette + for (unsigned y = 0; y < height; y++) { + // scale each row + const BYTE * const src_bits = FreeImage_GetScanLine(src, y + src_offset_y) + src_offset_x; + BYTE * const dst_bits = FreeImage_GetScanLine(dst, y); + + for (unsigned x = 0; x < dst_width; x++) { + // loop through row + const unsigned iLeft = weightsTable.getLeftBoundary(x); // retrieve left boundary + const unsigned iRight = weightsTable.getRightBoundary(x); // retrieve right boundary + double value = 0; + + for (unsigned i = iLeft; i <= iRight; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const unsigned pixel = (src_bits[i >> 3] & (0x80 >> (i & 0x07))) != 0; + value += (weightsTable.getWeight(x, i - iLeft) * (double)*(BYTE *)&src_pal[pixel]); + } + + // clamp and place result in destination pixel + dst_bits[x] = (BYTE)CLAMP((int)(value + 0.5), 0, 0xFF); + } + } + } else { + // we do not have a palette + for (unsigned y = 0; y < height; y++) { + // scale each row + const BYTE * const src_bits = FreeImage_GetScanLine(src, y + src_offset_y) + src_offset_x; + BYTE * const dst_bits = FreeImage_GetScanLine(dst, y); + + for (unsigned x = 0; x < dst_width; x++) { + // loop through row + const unsigned iLeft = weightsTable.getLeftBoundary(x); // retrieve left boundary + const unsigned iRight = weightsTable.getRightBoundary(x); // retrieve right boundary + double value = 0; + + for (unsigned i = iLeft; i <= iRight; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const unsigned pixel = (src_bits[i >> 3] & (0x80 >> (i & 0x07))) != 0; + value += (weightsTable.getWeight(x, i - iLeft) * (double)pixel); + } + value *= 0xFF; + + // clamp and place result in destination pixel + dst_bits[x] = (BYTE)CLAMP((int)(value + 0.5), 0, 0xFF); + } + } + } + } + break; + + case 24: + { + // transparently convert the non-transparent 1-bit image + // to 24 bpp; we always have got a palette here + src_offset_x >>= 3; + + for (unsigned y = 0; y < height; y++) { + // scale each row + const BYTE * const src_bits = FreeImage_GetScanLine(src, y + src_offset_y) + src_offset_x; + BYTE *dst_bits = FreeImage_GetScanLine(dst, y); + + for (unsigned x = 0; x < dst_width; x++) { + // loop through row + const unsigned iLeft = weightsTable.getLeftBoundary(x); // retrieve left boundary + const unsigned iRight = weightsTable.getRightBoundary(x); // retrieve right boundary + double r = 0, g = 0, b = 0; + + for (unsigned i = iLeft; i <= iRight; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(x, i - iLeft); + const unsigned pixel = (src_bits[i >> 3] & (0x80 >> (i & 0x07))) != 0; + const BYTE * const entry = (BYTE *)&src_pal[pixel]; + r += (weight * (double)entry[FI_RGBA_RED]); + g += (weight * (double)entry[FI_RGBA_GREEN]); + b += (weight * (double)entry[FI_RGBA_BLUE]); + } + + // clamp and place result in destination pixel + dst_bits[FI_RGBA_RED] = (BYTE)CLAMP((int)(r + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_GREEN] = (BYTE)CLAMP((int)(g + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_BLUE] = (BYTE)CLAMP((int)(b + 0.5), 0, 0xFF); + dst_bits += 3; + } + } + } + break; + + case 32: + { + // transparently convert the transparent 1-bit image + // to 32 bpp; we always have got a palette here + src_offset_x >>= 3; + + for (unsigned y = 0; y < height; y++) { + // scale each row + const BYTE * const src_bits = FreeImage_GetScanLine(src, y + src_offset_y) + src_offset_x; + BYTE *dst_bits = FreeImage_GetScanLine(dst, y); + + for (unsigned x = 0; x < dst_width; x++) { + // loop through row + const unsigned iLeft = weightsTable.getLeftBoundary(x); // retrieve left boundary + const unsigned iRight = weightsTable.getRightBoundary(x); // retrieve right boundary + double r = 0, g = 0, b = 0, a = 0; + + for (unsigned i = iLeft; i <= iRight; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(x, i - iLeft); + const unsigned pixel = (src_bits[i >> 3] & (0x80 >> (i & 0x07))) != 0; + const BYTE * const entry = (BYTE *)&src_pal[pixel]; + r += (weight * (double)entry[FI_RGBA_RED]); + g += (weight * (double)entry[FI_RGBA_GREEN]); + b += (weight * (double)entry[FI_RGBA_BLUE]); + a += (weight * (double)entry[FI_RGBA_ALPHA]); + } + + // clamp and place result in destination pixel + dst_bits[FI_RGBA_RED] = (BYTE)CLAMP((int)(r + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_GREEN] = (BYTE)CLAMP((int)(g + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_BLUE] = (BYTE)CLAMP((int)(b + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_ALPHA] = (BYTE)CLAMP((int)(a + 0.5), 0, 0xFF); + dst_bits += 4; + } + } + } + break; + } + } + break; + + case 4: + { + switch(FreeImage_GetBPP(dst)) { + case 8: + { + // transparently convert the non-transparent 4-bit greyscale image + // to 8 bpp; we always have got a palette for 4-bit images + src_offset_x >>= 1; + + for (unsigned y = 0; y < height; y++) { + // scale each row + const BYTE * const src_bits = FreeImage_GetScanLine(src, y + src_offset_y) + src_offset_x; + BYTE * const dst_bits = FreeImage_GetScanLine(dst, y); + + for (unsigned x = 0; x < dst_width; x++) { + // loop through row + const unsigned iLeft = weightsTable.getLeftBoundary(x); // retrieve left boundary + const unsigned iRight = weightsTable.getRightBoundary(x); // retrieve right boundary + double value = 0; + + for (unsigned i = iLeft; i <= iRight; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const unsigned pixel = i & 0x01 ? src_bits[i >> 1] & 0x0F : src_bits[i >> 1] >> 4; + value += (weightsTable.getWeight(x, i - iLeft) + * (double)*(BYTE *)&src_pal[pixel]); + } + + // clamp and place result in destination pixel + dst_bits[x] = (BYTE)CLAMP((int)(value + 0.5), 0, 0xFF); + } + } + } + break; + + case 24: + { + // transparently convert the non-transparent 4-bit image + // to 24 bpp; we always have got a palette for 4-bit images + src_offset_x >>= 1; + + for (unsigned y = 0; y < height; y++) { + // scale each row + const BYTE * const src_bits = FreeImage_GetScanLine(src, y + src_offset_y) + src_offset_x; + BYTE *dst_bits = FreeImage_GetScanLine(dst, y); + + for (unsigned x = 0; x < dst_width; x++) { + // loop through row + const unsigned iLeft = weightsTable.getLeftBoundary(x); // retrieve left boundary + const unsigned iRight = weightsTable.getRightBoundary(x); // retrieve right boundary + double r = 0, g = 0, b = 0; + + for (unsigned i = iLeft; i <= iRight; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(x, i - iLeft); + const unsigned pixel = i & 0x01 ? src_bits[i >> 1] & 0x0F : src_bits[i >> 1] >> 4; + const BYTE * const entry = (BYTE *)&src_pal[pixel]; + r += (weight * (double)entry[FI_RGBA_RED]); + g += (weight * (double)entry[FI_RGBA_GREEN]); + b += (weight * (double)entry[FI_RGBA_BLUE]); + } + + // clamp and place result in destination pixel + dst_bits[FI_RGBA_RED] = (BYTE)CLAMP((int)(r + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_GREEN] = (BYTE)CLAMP((int)(g + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_BLUE] = (BYTE)CLAMP((int)(b + 0.5), 0, 0xFF); + dst_bits += 3; + } + } + } + break; + + case 32: + { + // transparently convert the transparent 4-bit image + // to 32 bpp; we always have got a palette for 4-bit images + src_offset_x >>= 1; + + for (unsigned y = 0; y < height; y++) { + // scale each row + const BYTE * const src_bits = FreeImage_GetScanLine(src, y + src_offset_y) + src_offset_x; + BYTE *dst_bits = FreeImage_GetScanLine(dst, y); + + for (unsigned x = 0; x < dst_width; x++) { + // loop through row + const unsigned iLeft = weightsTable.getLeftBoundary(x); // retrieve left boundary + const unsigned iRight = weightsTable.getRightBoundary(x); // retrieve right boundary + double r = 0, g = 0, b = 0, a = 0; + + for (unsigned i = iLeft; i <= iRight; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(x, i - iLeft); + const unsigned pixel = i & 0x01 ? src_bits[i >> 1] & 0x0F : src_bits[i >> 1] >> 4; + const BYTE * const entry = (BYTE *)&src_pal[pixel]; + r += (weight * (double)entry[FI_RGBA_RED]); + g += (weight * (double)entry[FI_RGBA_GREEN]); + b += (weight * (double)entry[FI_RGBA_BLUE]); + a += (weight * (double)entry[FI_RGBA_ALPHA]); + } + + // clamp and place result in destination pixel + dst_bits[FI_RGBA_RED] = (BYTE)CLAMP((int)(r + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_GREEN] = (BYTE)CLAMP((int)(g + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_BLUE] = (BYTE)CLAMP((int)(b + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_ALPHA] = (BYTE)CLAMP((int)(a + 0.5), 0, 0xFF); + dst_bits += 4; + } + } + } + break; + } + } + break; + + case 8: + { + switch(FreeImage_GetBPP(dst)) { + case 8: + { + // scale the 8-bit non-transparent greyscale image + // into an 8 bpp destination image + if (src_pal) { + // we have got a palette + for (unsigned y = 0; y < height; y++) { + // scale each row + const BYTE * const src_bits = FreeImage_GetScanLine(src, y + src_offset_y) + src_offset_x; + BYTE * const dst_bits = FreeImage_GetScanLine(dst, y); + + for (unsigned x = 0; x < dst_width; x++) { + // loop through row + const unsigned iLeft = weightsTable.getLeftBoundary(x); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(x) - iLeft; // retrieve right boundary + const BYTE * const pixel = src_bits + iLeft; + double value = 0; + + // for(i = iLeft to iRight) + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + value += (weightsTable.getWeight(x, i) + * (double)*(BYTE *)&src_pal[pixel[i]]); + } + + // clamp and place result in destination pixel + dst_bits[x] = (BYTE)CLAMP((int)(value + 0.5), 0, 0xFF); + } + } + } else { + // we do not have a palette + for (unsigned y = 0; y < height; y++) { + // scale each row + const BYTE * const src_bits = FreeImage_GetScanLine(src, y + src_offset_y) + src_offset_x; + BYTE * const dst_bits = FreeImage_GetScanLine(dst, y); + + for (unsigned x = 0; x < dst_width; x++) { + // loop through row + const unsigned iLeft = weightsTable.getLeftBoundary(x); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(x) - iLeft; // retrieve right boundary + const BYTE * const pixel = src_bits + iLeft; + double value = 0; + + // for(i = iLeft to iRight) + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + value += (weightsTable.getWeight(x, i) * (double)pixel[i]); + } + + // clamp and place result in destination pixel + dst_bits[x] = (BYTE)CLAMP((int)(value + 0.5), 0, 0xFF); + } + } + } + } + break; + + case 24: + { + // transparently convert the non-transparent 8-bit image + // to 24 bpp; we always have got a palette here + for (unsigned y = 0; y < height; y++) { + // scale each row + const BYTE * const src_bits = FreeImage_GetScanLine(src, y + src_offset_y) + src_offset_x; + BYTE *dst_bits = FreeImage_GetScanLine(dst, y); + + for (unsigned x = 0; x < dst_width; x++) { + // loop through row + const unsigned iLeft = weightsTable.getLeftBoundary(x); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(x) - iLeft; // retrieve right boundary + const BYTE * const pixel = src_bits + iLeft; + double r = 0, g = 0, b = 0; + + // for(i = iLeft to iRight) + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(x, i); + const BYTE *const entry = (BYTE *)&src_pal[pixel[i]]; + r += (weight * (double)entry[FI_RGBA_RED]); + g += (weight * (double)entry[FI_RGBA_GREEN]); + b += (weight * (double)entry[FI_RGBA_BLUE]); + } + + // clamp and place result in destination pixel + dst_bits[FI_RGBA_RED] = (BYTE)CLAMP((int)(r + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_GREEN] = (BYTE)CLAMP((int)(g + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_BLUE] = (BYTE)CLAMP((int)(b + 0.5), 0, 0xFF); + dst_bits += 3; + } + } + } + break; + + case 32: + { + // transparently convert the transparent 8-bit image + // to 32 bpp; we always have got a palette here + for (unsigned y = 0; y < height; y++) { + // scale each row + const BYTE * const src_bits = FreeImage_GetScanLine(src, y + src_offset_y) + src_offset_x; + BYTE *dst_bits = FreeImage_GetScanLine(dst, y); + + for (unsigned x = 0; x < dst_width; x++) { + // loop through row + const unsigned iLeft = weightsTable.getLeftBoundary(x); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(x) - iLeft; // retrieve right boundary + const BYTE * const pixel = src_bits + iLeft; + double r = 0, g = 0, b = 0, a = 0; + + // for(i = iLeft to iRight) + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(x, i); + const BYTE * const entry = (BYTE *)&src_pal[pixel[i]]; + r += (weight * (double)entry[FI_RGBA_RED]); + g += (weight * (double)entry[FI_RGBA_GREEN]); + b += (weight * (double)entry[FI_RGBA_BLUE]); + a += (weight * (double)entry[FI_RGBA_ALPHA]); + } + + // clamp and place result in destination pixel + dst_bits[FI_RGBA_RED] = (BYTE)CLAMP((int)(r + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_GREEN] = (BYTE)CLAMP((int)(g + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_BLUE] = (BYTE)CLAMP((int)(b + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_ALPHA] = (BYTE)CLAMP((int)(a + 0.5), 0, 0xFF); + dst_bits += 4; + } + } + } + break; + } + } + break; + + case 16: + { + // transparently convert the 16-bit non-transparent image + // to 24 bpp + if (IS_FORMAT_RGB565(src)) { + // image has 565 format + for (unsigned y = 0; y < height; y++) { + // scale each row + const WORD * const src_bits = (WORD *)FreeImage_GetScanLine(src, y + src_offset_y) + src_offset_x / sizeof(WORD); + BYTE *dst_bits = FreeImage_GetScanLine(dst, y); + + for (unsigned x = 0; x < dst_width; x++) { + // loop through row + const unsigned iLeft = weightsTable.getLeftBoundary(x); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(x) - iLeft; // retrieve right boundary + const WORD *pixel = src_bits + iLeft; + double r = 0, g = 0, b = 0; + + // for(i = iLeft to iRight) + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(x, i); + r += (weight * (double)((*pixel & FI16_565_RED_MASK) >> FI16_565_RED_SHIFT)); + g += (weight * (double)((*pixel & FI16_565_GREEN_MASK) >> FI16_565_GREEN_SHIFT)); + b += (weight * (double)((*pixel & FI16_565_BLUE_MASK) >> FI16_565_BLUE_SHIFT)); + pixel++; + } + + // clamp and place result in destination pixel + dst_bits[FI_RGBA_RED] = (BYTE)CLAMP((int)(((r * 0xFF) / 0x1F) + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_GREEN] = (BYTE)CLAMP((int)(((g * 0xFF) / 0x3F) + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_BLUE] = (BYTE)CLAMP((int)(((b * 0xFF) / 0x1F) + 0.5), 0, 0xFF); + dst_bits += 3; + } + } + } else { + // image has 555 format + for (unsigned y = 0; y < height; y++) { + // scale each row + const WORD * const src_bits = (WORD *)FreeImage_GetScanLine(src, y + src_offset_y) + src_offset_x; + BYTE *dst_bits = FreeImage_GetScanLine(dst, y); + + for (unsigned x = 0; x < dst_width; x++) { + // loop through row + const unsigned iLeft = weightsTable.getLeftBoundary(x); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(x) - iLeft; // retrieve right boundary + const WORD *pixel = src_bits + iLeft; + double r = 0, g = 0, b = 0; + + // for(i = iLeft to iRight) + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(x, i); + r += (weight * (double)((*pixel & FI16_555_RED_MASK) >> FI16_555_RED_SHIFT)); + g += (weight * (double)((*pixel & FI16_555_GREEN_MASK) >> FI16_555_GREEN_SHIFT)); + b += (weight * (double)((*pixel & FI16_555_BLUE_MASK) >> FI16_555_BLUE_SHIFT)); + pixel++; + } + + // clamp and place result in destination pixel + dst_bits[FI_RGBA_RED] = (BYTE)CLAMP((int)(((r * 0xFF) / 0x1F) + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_GREEN] = (BYTE)CLAMP((int)(((g * 0xFF) / 0x1F) + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_BLUE] = (BYTE)CLAMP((int)(((b * 0xFF) / 0x1F) + 0.5), 0, 0xFF); + dst_bits += 3; + } + } + } + } + break; + + case 24: + { + // scale the 24-bit non-transparent image + // into a 24 bpp destination image + for (unsigned y = 0; y < height; y++) { + // scale each row + const BYTE * const src_bits = FreeImage_GetScanLine(src, y + src_offset_y) + src_offset_x * 3; + BYTE *dst_bits = FreeImage_GetScanLine(dst, y); + + for (unsigned x = 0; x < dst_width; x++) { + // loop through row + const unsigned iLeft = weightsTable.getLeftBoundary(x); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(x) - iLeft; // retrieve right boundary + const BYTE * pixel = src_bits + iLeft * 3; + double r = 0, g = 0, b = 0; + + // for(i = iLeft to iRight) + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(x, i); + r += (weight * (double)pixel[FI_RGBA_RED]); + g += (weight * (double)pixel[FI_RGBA_GREEN]); + b += (weight * (double)pixel[FI_RGBA_BLUE]); + pixel += 3; + } + + // clamp and place result in destination pixel + dst_bits[FI_RGBA_RED] = (BYTE)CLAMP((int)(r + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_GREEN] = (BYTE)CLAMP((int)(g + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_BLUE] = (BYTE)CLAMP((int)(b + 0.5), 0, 0xFF); + dst_bits += 3; + } + } + } + break; + + case 32: + { + // scale the 32-bit transparent image + // into a 32 bpp destination image + for (unsigned y = 0; y < height; y++) { + // scale each row + const BYTE * const src_bits = FreeImage_GetScanLine(src, y + src_offset_y) + src_offset_x * 4; + BYTE *dst_bits = FreeImage_GetScanLine(dst, y); + + for (unsigned x = 0; x < dst_width; x++) { + // loop through row + const unsigned iLeft = weightsTable.getLeftBoundary(x); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(x) - iLeft; // retrieve right boundary + const BYTE *pixel = src_bits + iLeft * 4; + double r = 0, g = 0, b = 0, a = 0; + + // for(i = iLeft to iRight) + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(x, i); + r += (weight * (double)pixel[FI_RGBA_RED]); + g += (weight * (double)pixel[FI_RGBA_GREEN]); + b += (weight * (double)pixel[FI_RGBA_BLUE]); + a += (weight * (double)pixel[FI_RGBA_ALPHA]); + pixel += 4; + } + + // clamp and place result in destination pixel + dst_bits[FI_RGBA_RED] = (BYTE)CLAMP((int)(r + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_GREEN] = (BYTE)CLAMP((int)(g + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_BLUE] = (BYTE)CLAMP((int)(b + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_ALPHA] = (BYTE)CLAMP((int)(a + 0.5), 0, 0xFF); + dst_bits += 4; + } + } + } + break; + } + } + break; + + case FIT_UINT16: + { + // Calculate the number of words per pixel (1 for 16-bit, 3 for 48-bit or 4 for 64-bit) + const unsigned wordspp = (FreeImage_GetLine(src) / src_width) / sizeof(WORD); + + for (unsigned y = 0; y < height; y++) { + // scale each row + const WORD *src_bits = (WORD*)FreeImage_GetScanLine(src, y + src_offset_y) + src_offset_x / sizeof(WORD); + WORD *dst_bits = (WORD*)FreeImage_GetScanLine(dst, y); + + for (unsigned x = 0; x < dst_width; x++) { + // loop through row + const unsigned iLeft = weightsTable.getLeftBoundary(x); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(x) - iLeft; // retrieve right boundary + const WORD *pixel = src_bits + iLeft * wordspp; + double value = 0; + + // for(i = iLeft to iRight) + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(x, i); + value += (weight * (double)pixel[0]); + pixel++; + } + + // clamp and place result in destination pixel + dst_bits[0] = (WORD)CLAMP((int)(value + 0.5), 0, 0xFFFF); + dst_bits += wordspp; + } + } + } + break; + + case FIT_RGB16: + { + // Calculate the number of words per pixel (1 for 16-bit, 3 for 48-bit or 4 for 64-bit) + const unsigned wordspp = (FreeImage_GetLine(src) / src_width) / sizeof(WORD); + + for (unsigned y = 0; y < height; y++) { + // scale each row + const WORD *src_bits = (WORD*)FreeImage_GetScanLine(src, y + src_offset_y) + src_offset_x / sizeof(WORD); + WORD *dst_bits = (WORD*)FreeImage_GetScanLine(dst, y); + + for (unsigned x = 0; x < dst_width; x++) { + // loop through row + const unsigned iLeft = weightsTable.getLeftBoundary(x); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(x) - iLeft; // retrieve right boundary + const WORD *pixel = src_bits + iLeft * wordspp; + double r = 0, g = 0, b = 0; + + // for(i = iLeft to iRight) + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(x, i); + r += (weight * (double)pixel[0]); + g += (weight * (double)pixel[1]); + b += (weight * (double)pixel[2]); + pixel += wordspp; + } + + // clamp and place result in destination pixel + dst_bits[0] = (WORD)CLAMP((int)(r + 0.5), 0, 0xFFFF); + dst_bits[1] = (WORD)CLAMP((int)(g + 0.5), 0, 0xFFFF); + dst_bits[2] = (WORD)CLAMP((int)(b + 0.5), 0, 0xFFFF); + dst_bits += wordspp; + } + } + } + break; + + case FIT_RGBA16: + { + // Calculate the number of words per pixel (1 for 16-bit, 3 for 48-bit or 4 for 64-bit) + const unsigned wordspp = (FreeImage_GetLine(src) / src_width) / sizeof(WORD); + + for (unsigned y = 0; y < height; y++) { + // scale each row + const WORD *src_bits = (WORD*)FreeImage_GetScanLine(src, y + src_offset_y) + src_offset_x / sizeof(WORD); + WORD *dst_bits = (WORD*)FreeImage_GetScanLine(dst, y); + + for (unsigned x = 0; x < dst_width; x++) { + // loop through row + const unsigned iLeft = weightsTable.getLeftBoundary(x); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(x) - iLeft; // retrieve right boundary + const WORD *pixel = src_bits + iLeft * wordspp; + double r = 0, g = 0, b = 0, a = 0; + + // for(i = iLeft to iRight) + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(x, i); + r += (weight * (double)pixel[0]); + g += (weight * (double)pixel[1]); + b += (weight * (double)pixel[2]); + a += (weight * (double)pixel[3]); + pixel += wordspp; + } + + // clamp and place result in destination pixel + dst_bits[0] = (WORD)CLAMP((int)(r + 0.5), 0, 0xFFFF); + dst_bits[1] = (WORD)CLAMP((int)(g + 0.5), 0, 0xFFFF); + dst_bits[2] = (WORD)CLAMP((int)(b + 0.5), 0, 0xFFFF); + dst_bits[3] = (WORD)CLAMP((int)(a + 0.5), 0, 0xFFFF); + dst_bits += wordspp; + } + } + } + break; + + case FIT_FLOAT: + case FIT_RGBF: + case FIT_RGBAF: + { + // Calculate the number of floats per pixel (1 for 32-bit, 3 for 96-bit or 4 for 128-bit) + const unsigned floatspp = (FreeImage_GetLine(src) / src_width) / sizeof(float); + + for(unsigned y = 0; y < height; y++) { + // scale each row + const float *src_bits = (float*)FreeImage_GetScanLine(src, y + src_offset_y) + src_offset_x / sizeof(float); + float *dst_bits = (float*)FreeImage_GetScanLine(dst, y); + + for(unsigned x = 0; x < dst_width; x++) { + // loop through row + const unsigned iLeft = weightsTable.getLeftBoundary(x); // retrieve left boundary + const unsigned iRight = weightsTable.getRightBoundary(x); // retrieve right boundary + double value[4] = {0, 0, 0, 0}; // 4 = 128 bpp max + + for(unsigned i = iLeft; i <= iRight; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(x, i-iLeft); + + unsigned index = i * floatspp; // pixel index + for (unsigned j = 0; j < floatspp; j++) { + value[j] += (weight * (double)src_bits[index++]); + } + } + + // place result in destination pixel + for (unsigned j = 0; j < floatspp; j++) { + dst_bits[j] = (float)value[j]; + } + + dst_bits += floatspp; + } + } + } + break; + } +} + +/// Performs vertical image filtering +void CResizeEngine::verticalFilter(FIBITMAP *const src, unsigned width, unsigned src_height, unsigned src_offset_x, unsigned src_offset_y, const RGBQUAD *const src_pal, FIBITMAP *const dst, unsigned dst_height) { + + // allocate and calculate the contributions + CWeightsTable weightsTable(m_pFilter, dst_height, src_height); + + // step through columns + switch(FreeImage_GetImageType(src)) { + case FIT_BITMAP: + { + const unsigned dst_pitch = FreeImage_GetPitch(dst); + BYTE * const dst_base = FreeImage_GetBits(dst); + + switch(FreeImage_GetBPP(src)) { + case 1: + { + const unsigned src_pitch = FreeImage_GetPitch(src); + const BYTE * const src_base = FreeImage_GetBits(src) + + src_offset_y * src_pitch + (src_offset_x >> 3); + + switch(FreeImage_GetBPP(dst)) { + case 8: + { + // transparently convert the 1-bit non-transparent greyscale + // image to 8 bpp + if (src_pal) { + // we have got a palette + for (unsigned x = 0; x < width; x++) { + // work on column x in dst + BYTE *dst_bits = dst_base + x; + const unsigned index = x >> 3; + const unsigned mask = 0x80 >> (x & 0x07); + + // scale each column + for (unsigned y = 0; y < dst_height; y++) { + // loop through column + const unsigned iLeft = weightsTable.getLeftBoundary(y); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(y) - iLeft; // retrieve right boundary + const BYTE *src_bits = src_base + iLeft * src_pitch + index; + double value = 0; + + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const unsigned pixel = (*src_bits & mask) != 0; + value += (weightsTable.getWeight(y, i) + * (double)*(BYTE *)&src_pal[pixel]); + src_bits += src_pitch; + } + value *= 0xFF; + + // clamp and place result in destination pixel + *dst_bits = (BYTE)CLAMP((int)(value + 0.5), 0, 0xFF); + dst_bits += dst_pitch; + } + } + } else { + // we do not have a palette + for (unsigned x = 0; x < width; x++) { + // work on column x in dst + BYTE *dst_bits = dst_base + x; + const unsigned index = x >> 3; + const unsigned mask = 0x80 >> (x & 0x07); + + // scale each column + for (unsigned y = 0; y < dst_height; y++) { + // loop through column + const unsigned iLeft = weightsTable.getLeftBoundary(y); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(y) - iLeft; // retrieve right boundary + const BYTE *src_bits = src_base + iLeft * src_pitch + index; + double value = 0; + + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + value += (weightsTable.getWeight(y, i) + * (double)((*src_bits & mask) != 0)); + src_bits += src_pitch; + } + value *= 0xFF; + + // clamp and place result in destination pixel + *dst_bits = (BYTE)CLAMP((int)(value + 0.5), 0, 0xFF); + dst_bits += dst_pitch; + } + } + } + } + break; + + case 24: + { + // transparently convert the non-transparent 1-bit image + // to 24 bpp; we always have got a palette here + for (unsigned x = 0; x < width; x++) { + // work on column x in dst + BYTE *dst_bits = dst_base + x * 3; + const unsigned index = x >> 3; + const unsigned mask = 0x80 >> (x & 0x07); + + // scale each column + for (unsigned y = 0; y < dst_height; y++) { + // loop through column + const unsigned iLeft = weightsTable.getLeftBoundary(y); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(y) - iLeft; // retrieve right boundary + const BYTE *src_bits = src_base + iLeft * src_pitch + index; + double r = 0, g = 0, b = 0; + + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(y, i); + const unsigned pixel = (*src_bits & mask) != 0; + const BYTE * const entry = (BYTE *)&src_pal[pixel]; + r += (weight * (double)entry[FI_RGBA_RED]); + g += (weight * (double)entry[FI_RGBA_GREEN]); + b += (weight * (double)entry[FI_RGBA_BLUE]); + src_bits += src_pitch; + } + + // clamp and place result in destination pixel + dst_bits[FI_RGBA_RED] = (BYTE)CLAMP((int)(r + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_GREEN] = (BYTE)CLAMP((int)(g + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_BLUE] = (BYTE)CLAMP((int)(b + 0.5), 0, 0xFF); + dst_bits += dst_pitch; + } + } + } + break; + + case 32: + { + // transparently convert the transparent 1-bit image + // to 32 bpp; we always have got a palette here + for (unsigned x = 0; x < width; x++) { + // work on column x in dst + BYTE *dst_bits = dst_base + x * 4; + const unsigned index = x >> 3; + const unsigned mask = 0x80 >> (x & 0x07); + + // scale each column + for (unsigned y = 0; y < dst_height; y++) { + // loop through column + const unsigned iLeft = weightsTable.getLeftBoundary(y); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(y) - iLeft; // retrieve right boundary + const BYTE *src_bits = src_base + iLeft * src_pitch + index; + double r = 0, g = 0, b = 0, a = 0; + + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(y, i); + const unsigned pixel = (*src_bits & mask) != 0; + const BYTE * const entry = (BYTE *)&src_pal[pixel]; + r += (weight * (double)entry[FI_RGBA_RED]); + g += (weight * (double)entry[FI_RGBA_GREEN]); + b += (weight * (double)entry[FI_RGBA_BLUE]); + a += (weight * (double)entry[FI_RGBA_ALPHA]); + src_bits += src_pitch; + } + + // clamp and place result in destination pixel + dst_bits[FI_RGBA_RED] = (BYTE)CLAMP((int)(r + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_GREEN] = (BYTE)CLAMP((int)(g + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_BLUE] = (BYTE)CLAMP((int)(b + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_ALPHA] = (BYTE)CLAMP((int)(a + 0.5), 0, 0xFF); + dst_bits += dst_pitch; + } + } + } + break; + } + } + break; + + case 4: + { + const unsigned src_pitch = FreeImage_GetPitch(src); + const BYTE *const src_base = FreeImage_GetBits(src) + src_offset_y * src_pitch + (src_offset_x >> 1); + + switch(FreeImage_GetBPP(dst)) { + case 8: + { + // transparently convert the non-transparent 4-bit greyscale image + // to 8 bpp; we always have got a palette for 4-bit images + for (unsigned x = 0; x < width; x++) { + // work on column x in dst + BYTE *dst_bits = dst_base + x; + const unsigned index = x >> 1; + + // scale each column + for (unsigned y = 0; y < dst_height; y++) { + // loop through column + const unsigned iLeft = weightsTable.getLeftBoundary(y); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(y) - iLeft; // retrieve right boundary + const BYTE *src_bits = src_base + iLeft * src_pitch + index; + double value = 0; + + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const unsigned pixel = x & 0x01 ? *src_bits & 0x0F : *src_bits >> 4; + value += (weightsTable.getWeight(y, i) + * (double)*(BYTE *)&src_pal[pixel]); + src_bits += src_pitch; + } + + // clamp and place result in destination pixel + *dst_bits = (BYTE)CLAMP((int)(value + 0.5), 0, 0xFF); + dst_bits += dst_pitch; + } + } + } + break; + + case 24: + { + // transparently convert the non-transparent 4-bit image + // to 24 bpp; we always have got a palette for 4-bit images + for (unsigned x = 0; x < width; x++) { + // work on column x in dst + BYTE *dst_bits = dst_base + x * 3; + const unsigned index = x >> 1; + + // scale each column + for (unsigned y = 0; y < dst_height; y++) { + // loop through column + const unsigned iLeft = weightsTable.getLeftBoundary(y); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(y) - iLeft; // retrieve right boundary + const BYTE *src_bits = src_base + iLeft * src_pitch + index; + double r = 0, g = 0, b = 0; + + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(y, i); + const unsigned pixel = x & 0x01 ? *src_bits & 0x0F : *src_bits >> 4; + const BYTE *const entry = (BYTE *)&src_pal[pixel]; + r += (weight * (double)entry[FI_RGBA_RED]); + g += (weight * (double)entry[FI_RGBA_GREEN]); + b += (weight * (double)entry[FI_RGBA_BLUE]); + src_bits += src_pitch; + } + + // clamp and place result in destination pixel + dst_bits[FI_RGBA_RED] = (BYTE)CLAMP((int)(r + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_GREEN] = (BYTE)CLAMP((int)(g + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_BLUE] = (BYTE)CLAMP((int)(b + 0.5), 0, 0xFF); + dst_bits += dst_pitch; + } + } + } + break; + + case 32: + { + // transparently convert the transparent 4-bit image + // to 32 bpp; we always have got a palette for 4-bit images + for (unsigned x = 0; x < width; x++) { + // work on column x in dst + BYTE *dst_bits = dst_base + x * 4; + const unsigned index = x >> 1; + + // scale each column + for (unsigned y = 0; y < dst_height; y++) { + // loop through column + const unsigned iLeft = weightsTable.getLeftBoundary(y); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(y) - iLeft; // retrieve right boundary + const BYTE *src_bits = src_base + iLeft * src_pitch + index; + double r = 0, g = 0, b = 0, a = 0; + + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(y, i); + const unsigned pixel = x & 0x01 ? *src_bits & 0x0F : *src_bits >> 4; + const BYTE *const entry = (BYTE *)&src_pal[pixel]; + r += (weight * (double)entry[FI_RGBA_RED]); + g += (weight * (double)entry[FI_RGBA_GREEN]); + b += (weight * (double)entry[FI_RGBA_BLUE]); + a += (weight * (double)entry[FI_RGBA_ALPHA]); + src_bits += src_pitch; + } + + // clamp and place result in destination pixel + dst_bits[FI_RGBA_RED] = (BYTE)CLAMP((int)(r + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_GREEN] = (BYTE)CLAMP((int)(g + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_BLUE] = (BYTE)CLAMP((int)(b + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_ALPHA] = (BYTE)CLAMP((int)(a + 0.5), 0, 0xFF); + dst_bits += dst_pitch; + } + } + } + break; + } + } + break; + + case 8: + { + const unsigned src_pitch = FreeImage_GetPitch(src); + const BYTE *const src_base = FreeImage_GetBits(src) + src_offset_y * src_pitch + src_offset_x; + + switch(FreeImage_GetBPP(dst)) { + case 8: + { + // scale the 8-bit non-transparent greyscale image + // into an 8 bpp destination image + if (src_pal) { + // we have got a palette + for (unsigned x = 0; x < width; x++) { + // work on column x in dst + BYTE *dst_bits = dst_base + x; + + // scale each column + for (unsigned y = 0; y < dst_height; y++) { + // loop through column + const unsigned iLeft = weightsTable.getLeftBoundary(y); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(y) - iLeft; // retrieve right boundary + const BYTE *src_bits = src_base + iLeft * src_pitch + x; + double value = 0; + + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + value += (weightsTable.getWeight(y, i) + * (double)*(BYTE *)&src_pal[*src_bits]); + src_bits += src_pitch; + } + + // clamp and place result in destination pixel + *dst_bits = (BYTE)CLAMP((int)(value + 0.5), 0, 0xFF); + dst_bits += dst_pitch; + } + } + } else { + // we do not have a palette + for (unsigned x = 0; x < width; x++) { + // work on column x in dst + BYTE *dst_bits = dst_base + x; + + // scale each column + for (unsigned y = 0; y < dst_height; y++) { + // loop through column + const unsigned iLeft = weightsTable.getLeftBoundary(y); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(y) - iLeft; // retrieve right boundary + const BYTE *src_bits = src_base + iLeft * src_pitch + x; + double value = 0; + + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + value += (weightsTable.getWeight(y, i) + * (double)*src_bits); + src_bits += src_pitch; + } + + // clamp and place result in destination pixel + *dst_bits = (BYTE)CLAMP((int)(value + 0.5), 0, 0xFF); + dst_bits += dst_pitch; + } + } + } + } + break; + + case 24: + { + // transparently convert the non-transparent 8-bit image + // to 24 bpp; we always have got a palette here + for (unsigned x = 0; x < width; x++) { + // work on column x in dst + BYTE *dst_bits = dst_base + x * 3; + + // scale each column + for (unsigned y = 0; y < dst_height; y++) { + // loop through column + const unsigned iLeft = weightsTable.getLeftBoundary(y); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(y) - iLeft; // retrieve right boundary + const BYTE *src_bits = src_base + iLeft * src_pitch + x; + double r = 0, g = 0, b = 0; + + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(y, i); + const BYTE * const entry = (BYTE *)&src_pal[*src_bits]; + r += (weight * (double)entry[FI_RGBA_RED]); + g += (weight * (double)entry[FI_RGBA_GREEN]); + b += (weight * (double)entry[FI_RGBA_BLUE]); + src_bits += src_pitch; + } + + // clamp and place result in destination pixel + dst_bits[FI_RGBA_RED] = (BYTE)CLAMP((int)(r + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_GREEN] = (BYTE)CLAMP((int)(g + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_BLUE] = (BYTE)CLAMP((int)(b + 0.5), 0, 0xFF); + dst_bits += dst_pitch; + } + } + } + break; + + case 32: + { + // transparently convert the transparent 8-bit image + // to 32 bpp; we always have got a palette here + for (unsigned x = 0; x < width; x++) { + // work on column x in dst + BYTE *dst_bits = dst_base + x * 4; + + // scale each column + for (unsigned y = 0; y < dst_height; y++) { + // loop through column + const unsigned iLeft = weightsTable.getLeftBoundary(y); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(y) - iLeft; // retrieve right boundary + const BYTE *src_bits = src_base + iLeft * src_pitch + x; + double r = 0, g = 0, b = 0, a = 0; + + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(y, i); + const BYTE * const entry = (BYTE *)&src_pal[*src_bits]; + r += (weight * (double)entry[FI_RGBA_RED]); + g += (weight * (double)entry[FI_RGBA_GREEN]); + b += (weight * (double)entry[FI_RGBA_BLUE]); + a += (weight * (double)entry[FI_RGBA_ALPHA]); + src_bits += src_pitch; + } + + // clamp and place result in destination pixel + dst_bits[FI_RGBA_RED] = (BYTE)CLAMP((int)(r + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_GREEN] = (BYTE)CLAMP((int)(g + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_BLUE] = (BYTE)CLAMP((int)(b + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_ALPHA] = (BYTE)CLAMP((int)(a + 0.5), 0, 0xFF); + dst_bits += dst_pitch; + } + } + } + break; + } + } + break; + + case 16: + { + // transparently convert the 16-bit non-transparent image + // to 24 bpp + const unsigned src_pitch = FreeImage_GetPitch(src) / sizeof(WORD); + const WORD *const src_base = (WORD *)FreeImage_GetBits(src) + src_offset_y * src_pitch + src_offset_x; + + if (IS_FORMAT_RGB565(src)) { + // image has 565 format + for (unsigned x = 0; x < width; x++) { + // work on column x in dst + BYTE *dst_bits = dst_base + x * 3; + + // scale each column + for (unsigned y = 0; y < dst_height; y++) { + // loop through column + const unsigned iLeft = weightsTable.getLeftBoundary(y); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(y) - iLeft; // retrieve right boundary + const WORD *src_bits = src_base + iLeft * src_pitch + x; + double r = 0, g = 0, b = 0; + + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(y, i); + r += (weight * (double)((*src_bits & FI16_565_RED_MASK) >> FI16_565_RED_SHIFT)); + g += (weight * (double)((*src_bits & FI16_565_GREEN_MASK) >> FI16_565_GREEN_SHIFT)); + b += (weight * (double)((*src_bits & FI16_565_BLUE_MASK) >> FI16_565_BLUE_SHIFT)); + src_bits += src_pitch; + } + + // clamp and place result in destination pixel + dst_bits[FI_RGBA_RED] = (BYTE)CLAMP((int)(((r * 0xFF) / 0x1F) + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_GREEN] = (BYTE)CLAMP((int)(((g * 0xFF) / 0x3F) + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_BLUE] = (BYTE)CLAMP((int)(((b * 0xFF) / 0x1F) + 0.5), 0, 0xFF); + dst_bits += dst_pitch; + } + } + } else { + // image has 555 format + for (unsigned x = 0; x < width; x++) { + // work on column x in dst + BYTE *dst_bits = dst_base + x * 3; + + // scale each column + for (unsigned y = 0; y < dst_height; y++) { + // loop through column + const unsigned iLeft = weightsTable.getLeftBoundary(y); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(y) - iLeft; // retrieve right boundary + const WORD *src_bits = src_base + iLeft * src_pitch + x; + double r = 0, g = 0, b = 0; + + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(y, i); + r += (weight * (double)((*src_bits & FI16_555_RED_MASK) >> FI16_555_RED_SHIFT)); + g += (weight * (double)((*src_bits & FI16_555_GREEN_MASK) >> FI16_555_GREEN_SHIFT)); + b += (weight * (double)((*src_bits & FI16_555_BLUE_MASK) >> FI16_555_BLUE_SHIFT)); + src_bits += src_pitch; + } + + // clamp and place result in destination pixel + dst_bits[FI_RGBA_RED] = (BYTE)CLAMP((int)(((r * 0xFF) / 0x1F) + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_GREEN] = (BYTE)CLAMP((int)(((g * 0xFF) / 0x1F) + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_BLUE] = (BYTE)CLAMP((int)(((b * 0xFF) / 0x1F) + 0.5), 0, 0xFF); + dst_bits += dst_pitch; + } + } + } + } + break; + + case 24: + { + // scale the 24-bit transparent image + // into a 24 bpp destination image + const unsigned src_pitch = FreeImage_GetPitch(src); + const BYTE *const src_base = FreeImage_GetBits(src) + src_offset_y * src_pitch + src_offset_x * 3; + + for (unsigned x = 0; x < width; x++) { + // work on column x in dst + const unsigned index = x * 3; + BYTE *dst_bits = dst_base + index; + + // scale each column + for (unsigned y = 0; y < dst_height; y++) { + // loop through column + const unsigned iLeft = weightsTable.getLeftBoundary(y); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(y) - iLeft; // retrieve right boundary + const BYTE *src_bits = src_base + iLeft * src_pitch + index; + double r = 0, g = 0, b = 0; + + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(y, i); + r += (weight * (double)src_bits[FI_RGBA_RED]); + g += (weight * (double)src_bits[FI_RGBA_GREEN]); + b += (weight * (double)src_bits[FI_RGBA_BLUE]); + src_bits += src_pitch; + } + + // clamp and place result in destination pixel + dst_bits[FI_RGBA_RED] = (BYTE)CLAMP((int) (r + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_GREEN] = (BYTE)CLAMP((int) (g + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_BLUE] = (BYTE)CLAMP((int) (b + 0.5), 0, 0xFF); + dst_bits += dst_pitch; + } + } + } + break; + + case 32: + { + // scale the 32-bit transparent image + // into a 32 bpp destination image + const unsigned src_pitch = FreeImage_GetPitch(src); + const BYTE *const src_base = FreeImage_GetBits(src) + src_offset_y * src_pitch + src_offset_x * 4; + + for (unsigned x = 0; x < width; x++) { + // work on column x in dst + const unsigned index = x * 4; + BYTE *dst_bits = dst_base + index; + + // scale each column + for (unsigned y = 0; y < dst_height; y++) { + // loop through column + const unsigned iLeft = weightsTable.getLeftBoundary(y); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(y) - iLeft; // retrieve right boundary + const BYTE *src_bits = src_base + iLeft * src_pitch + index; + double r = 0, g = 0, b = 0, a = 0; + + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(y, i); + r += (weight * (double)src_bits[FI_RGBA_RED]); + g += (weight * (double)src_bits[FI_RGBA_GREEN]); + b += (weight * (double)src_bits[FI_RGBA_BLUE]); + a += (weight * (double)src_bits[FI_RGBA_ALPHA]); + src_bits += src_pitch; + } + + // clamp and place result in destination pixel + dst_bits[FI_RGBA_RED] = (BYTE)CLAMP((int) (r + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_GREEN] = (BYTE)CLAMP((int) (g + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_BLUE] = (BYTE)CLAMP((int) (b + 0.5), 0, 0xFF); + dst_bits[FI_RGBA_ALPHA] = (BYTE)CLAMP((int) (a + 0.5), 0, 0xFF); + dst_bits += dst_pitch; + } + } + } + break; + } + } + break; + + case FIT_UINT16: + { + // Calculate the number of words per pixel (1 for 16-bit, 3 for 48-bit or 4 for 64-bit) + const unsigned wordspp = (FreeImage_GetLine(src) / width) / sizeof(WORD); + + const unsigned dst_pitch = FreeImage_GetPitch(dst) / sizeof(WORD); + WORD *const dst_base = (WORD *)FreeImage_GetBits(dst); + + const unsigned src_pitch = FreeImage_GetPitch(src) / sizeof(WORD); + const WORD *const src_base = (WORD *)FreeImage_GetBits(src) + src_offset_y * src_pitch + src_offset_x * wordspp; + + for (unsigned x = 0; x < width; x++) { + // work on column x in dst + const unsigned index = x * wordspp; // pixel index + WORD *dst_bits = dst_base + index; + + // scale each column + for (unsigned y = 0; y < dst_height; y++) { + // loop through column + const unsigned iLeft = weightsTable.getLeftBoundary(y); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(y) - iLeft; // retrieve right boundary + const WORD *src_bits = src_base + iLeft * src_pitch + index; + double value = 0; + + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(y, i); + value += (weight * (double)src_bits[0]); + src_bits += src_pitch; + } + + // clamp and place result in destination pixel + dst_bits[0] = (WORD)CLAMP((int)(value + 0.5), 0, 0xFFFF); + + dst_bits += dst_pitch; + } + } + } + break; + + case FIT_RGB16: + { + // Calculate the number of words per pixel (1 for 16-bit, 3 for 48-bit or 4 for 64-bit) + const unsigned wordspp = (FreeImage_GetLine(src) / width) / sizeof(WORD); + + const unsigned dst_pitch = FreeImage_GetPitch(dst) / sizeof(WORD); + WORD *const dst_base = (WORD *)FreeImage_GetBits(dst); + + const unsigned src_pitch = FreeImage_GetPitch(src) / sizeof(WORD); + const WORD *const src_base = (WORD *)FreeImage_GetBits(src) + src_offset_y * src_pitch + src_offset_x * wordspp; + + for (unsigned x = 0; x < width; x++) { + // work on column x in dst + const unsigned index = x * wordspp; // pixel index + WORD *dst_bits = dst_base + index; + + // scale each column + for (unsigned y = 0; y < dst_height; y++) { + // loop through column + const unsigned iLeft = weightsTable.getLeftBoundary(y); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(y) - iLeft; // retrieve right boundary + const WORD *src_bits = src_base + iLeft * src_pitch + index; + double r = 0, g = 0, b = 0; + + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(y, i); + r += (weight * (double)src_bits[0]); + g += (weight * (double)src_bits[1]); + b += (weight * (double)src_bits[2]); + + src_bits += src_pitch; + } + + // clamp and place result in destination pixel + dst_bits[0] = (WORD)CLAMP((int)(r + 0.5), 0, 0xFFFF); + dst_bits[1] = (WORD)CLAMP((int)(g + 0.5), 0, 0xFFFF); + dst_bits[2] = (WORD)CLAMP((int)(b + 0.5), 0, 0xFFFF); + + dst_bits += dst_pitch; + } + } + } + break; + + case FIT_RGBA16: + { + // Calculate the number of words per pixel (1 for 16-bit, 3 for 48-bit or 4 for 64-bit) + const unsigned wordspp = (FreeImage_GetLine(src) / width) / sizeof(WORD); + + const unsigned dst_pitch = FreeImage_GetPitch(dst) / sizeof(WORD); + WORD *const dst_base = (WORD *)FreeImage_GetBits(dst); + + const unsigned src_pitch = FreeImage_GetPitch(src) / sizeof(WORD); + const WORD *const src_base = (WORD *)FreeImage_GetBits(src) + src_offset_y * src_pitch + src_offset_x * wordspp; + + for (unsigned x = 0; x < width; x++) { + // work on column x in dst + const unsigned index = x * wordspp; // pixel index + WORD *dst_bits = dst_base + index; + + // scale each column + for (unsigned y = 0; y < dst_height; y++) { + // loop through column + const unsigned iLeft = weightsTable.getLeftBoundary(y); // retrieve left boundary + const unsigned iLimit = weightsTable.getRightBoundary(y) - iLeft; // retrieve right boundary + const WORD *src_bits = src_base + iLeft * src_pitch + index; + double r = 0, g = 0, b = 0, a = 0; + + for (unsigned i = 0; i <= iLimit; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(y, i); + r += (weight * (double)src_bits[0]); + g += (weight * (double)src_bits[1]); + b += (weight * (double)src_bits[2]); + a += (weight * (double)src_bits[3]); + + src_bits += src_pitch; + } + + // clamp and place result in destination pixel + dst_bits[0] = (WORD)CLAMP((int)(r + 0.5), 0, 0xFFFF); + dst_bits[1] = (WORD)CLAMP((int)(g + 0.5), 0, 0xFFFF); + dst_bits[2] = (WORD)CLAMP((int)(b + 0.5), 0, 0xFFFF); + dst_bits[3] = (WORD)CLAMP((int)(a + 0.5), 0, 0xFFFF); + + dst_bits += dst_pitch; + } + } + } + break; + + case FIT_FLOAT: + case FIT_RGBF: + case FIT_RGBAF: + { + // Calculate the number of floats per pixel (1 for 32-bit, 3 for 96-bit or 4 for 128-bit) + const unsigned floatspp = (FreeImage_GetLine(src) / width) / sizeof(float); + + const unsigned dst_pitch = FreeImage_GetPitch(dst) / sizeof(float); + float *const dst_base = (float *)FreeImage_GetBits(dst); + + const unsigned src_pitch = FreeImage_GetPitch(src) / sizeof(float); + const float *const src_base = (float *)FreeImage_GetBits(src) + src_offset_y * src_pitch + src_offset_x * floatspp; + + for (unsigned x = 0; x < width; x++) { + // work on column x in dst + const unsigned index = x * floatspp; // pixel index + float *dst_bits = (float *)dst_base + index; + + // scale each column + for (unsigned y = 0; y < dst_height; y++) { + // loop through column + const unsigned iLeft = weightsTable.getLeftBoundary(y); // retrieve left boundary + const unsigned iRight = weightsTable.getRightBoundary(y); // retrieve right boundary + const float *src_bits = src_base + iLeft * src_pitch + index; + double value[4] = {0, 0, 0, 0}; // 4 = 128 bpp max + + for (unsigned i = iLeft; i <= iRight; i++) { + // scan between boundaries + // accumulate weighted effect of each neighboring pixel + const double weight = weightsTable.getWeight(y, i - iLeft); + for (unsigned j = 0; j < floatspp; j++) { + value[j] += (weight * (double)src_bits[j]); + } + src_bits += src_pitch; + } + + // place result in destination pixel + for (unsigned j = 0; j < floatspp; j++) { + dst_bits[j] = (float)value[j]; + } + dst_bits += dst_pitch; + } + } + } + break; + } +} diff --git a/plugins/AdvaImg/src/FreeImageToolkit/Resize.h b/plugins/AdvaImg/src/FreeImageToolkit/Resize.h index 0d5d0b451a..7fe1cdb112 100644 --- a/plugins/AdvaImg/src/FreeImageToolkit/Resize.h +++ b/plugins/AdvaImg/src/FreeImageToolkit/Resize.h @@ -1,145 +1,195 @@ -// ========================================================== -// Upsampling / downsampling classes -// -// Design and implementation by -// - Hervé Drolon (drolon@infonie.fr) -// - Detlev Vendt (detlev.vendt@brillit.de) -// -// This file is part of FreeImage 3 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#ifndef _RESIZE_H_ -#define _RESIZE_H_ - -#include "FreeImage.h" -#include "Utilities.h" -#include "Filters.h" - -/** - Filter weights table.
- This class stores contribution information for an entire line (row or column). -*/ -class CWeightsTable -{ -/** - Sampled filter weight table.
- Contribution information for a single pixel -*/ -typedef struct { - /// Normalized weights of neighboring pixels - double *Weights; - /// Bounds of source pixels window - unsigned Left, Right; -} Contribution; - -private: - /// Row (or column) of contribution weights - Contribution *m_WeightTable; - /// Filter window size (of affecting source pixels) - unsigned m_WindowSize; - /// Length of line (no. of rows / cols) - unsigned m_LineLength; - -public: - /** - Constructor
- Allocate and compute the weights table - @param pFilter Filter used for upsampling or downsampling - @param uDstSize Length (in pixels) of the destination line buffer - @param uSrcSize Length (in pixels) of the source line buffer - */ - CWeightsTable(CGenericFilter *pFilter, unsigned uDstSize, unsigned uSrcSize); - - /** - Destructor
- Destroy the weights table - */ - ~CWeightsTable(); - - /** Retrieve a filter weight, given source and destination positions - @param dst_pos Pixel position in destination line buffer - @param src_pos Pixel position in source line buffer - @return Returns the filter weight - */ - double getWeight(unsigned dst_pos, unsigned src_pos) { - return m_WeightTable[dst_pos].Weights[src_pos]; - } - - /** Retrieve left boundary of source line buffer - @param dst_pos Pixel position in destination line buffer - @return Returns the left boundary of source line buffer - */ - unsigned getLeftBoundary(unsigned dst_pos) { - return m_WeightTable[dst_pos].Left; - } - - /** Retrieve right boundary of source line buffer - @param dst_pos Pixel position in destination line buffer - @return Returns the right boundary of source line buffer - */ - unsigned getRightBoundary(unsigned dst_pos) { - return m_WeightTable[dst_pos].Right; - } -}; - -// --------------------------------------------- - -/** - CResizeEngine
- This class performs filtered zoom. It scales an image to the desired dimensions with - any of the CGenericFilter derived filter class.
- It works with 8-, 24- and 32-bit buffers.

- - References :
- [1] Paul Heckbert, C code to zoom raster images up or down, with nice filtering. - UC Berkeley, August 1989. [online] http://www-2.cs.cmu.edu/afs/cs.cmu.edu/Web/People/ph/heckbert.html - [2] Eran Yariv, Two Pass Scaling using Filters. The Code Project, December 1999. - [online] http://www.codeproject.com/bitmap/2_pass_scaling.asp - -*/ -class CResizeEngine -{ -private: - /// Pointer to the FIR / IIR filter - CGenericFilter* m_pFilter; - -public: - - /// Constructor - CResizeEngine(CGenericFilter* filter):m_pFilter(filter) {} - - /// Destructor - virtual ~CResizeEngine() {} - - /** Scale an image to the desired dimensions - @param src Pointer to the source image - @param dst_width Destination image width - @param dst_height Destination image height - @return Returns the scaled image if successful, returns NULL otherwise - */ - FIBITMAP* scale(FIBITMAP *src, unsigned dst_width, unsigned dst_height); - -private: - - /// Performs horizontal image filtering - void horizontalFilter(FIBITMAP *src, unsigned src_width, unsigned src_height, FIBITMAP *dst, unsigned dst_width, unsigned dst_height); - - /// Performs vertical image filtering - void verticalFilter(FIBITMAP *src, unsigned src_width, unsigned src_height, FIBITMAP *dst, unsigned dst_width, unsigned dst_height); -}; - - - -#endif // _RESIZE_H_ +// ========================================================== +// Upsampling / downsampling classes +// +// Design and implementation by +// - Hervé Drolon (drolon@infonie.fr) +// - Detlev Vendt (detlev.vendt@brillit.de) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +#ifndef _RESIZE_H_ +#define _RESIZE_H_ + +#include "FreeImage.h" +#include "Utilities.h" +#include "Filters.h" + +/** + Filter weights table.
+ This class stores contribution information for an entire line (row or column). +*/ +class CWeightsTable +{ +/** + Sampled filter weight table.
+ Contribution information for a single pixel +*/ +typedef struct { + /// Normalized weights of neighboring pixels + double *Weights; + /// Bounds of source pixels window + unsigned Left, Right; +} Contribution; + +private: + /// Row (or column) of contribution weights + Contribution *m_WeightTable; + /// Filter window size (of affecting source pixels) + unsigned m_WindowSize; + /// Length of line (no. of rows / cols) + unsigned m_LineLength; + +public: + /** + Constructor
+ Allocate and compute the weights table + @param pFilter Filter used for upsampling or downsampling + @param uDstSize Length (in pixels) of the destination line buffer + @param uSrcSize Length (in pixels) of the source line buffer + */ + CWeightsTable(CGenericFilter *pFilter, unsigned uDstSize, unsigned uSrcSize); + + /** + Destructor
+ Destroy the weights table + */ + ~CWeightsTable(); + + /** Retrieve a filter weight, given source and destination positions + @param dst_pos Pixel position in destination line buffer + @param src_pos Pixel position in source line buffer + @return Returns the filter weight + */ + double getWeight(unsigned dst_pos, unsigned src_pos) { + return m_WeightTable[dst_pos].Weights[src_pos]; + } + + /** Retrieve left boundary of source line buffer + @param dst_pos Pixel position in destination line buffer + @return Returns the left boundary of source line buffer + */ + unsigned getLeftBoundary(unsigned dst_pos) { + return m_WeightTable[dst_pos].Left; + } + + /** Retrieve right boundary of source line buffer + @param dst_pos Pixel position in destination line buffer + @return Returns the right boundary of source line buffer + */ + unsigned getRightBoundary(unsigned dst_pos) { + return m_WeightTable[dst_pos].Right; + } +}; + +// --------------------------------------------- + +/** + CResizeEngine
+ This class performs filtered zoom. It scales an image to the desired dimensions with + any of the CGenericFilter derived filter class.
+ It works with FIT_BITMAP buffers, WORD buffers (FIT_UINT16, FIT_RGB16, FIT_RGBA16) + and float buffers (FIT_FLOAT, FIT_RGBF, FIT_RGBAF).

+ + References :
+ [1] Paul Heckbert, C code to zoom raster images up or down, with nice filtering. + UC Berkeley, August 1989. [online] http://www-2.cs.cmu.edu/afs/cs.cmu.edu/Web/People/ph/heckbert.html + [2] Eran Yariv, Two Pass Scaling using Filters. The Code Project, December 1999. + [online] http://www.codeproject.com/bitmap/2_pass_scaling.asp + +*/ +class CResizeEngine +{ +private: + /// Pointer to the FIR / IIR filter + CGenericFilter* m_pFilter; + +public: + + /** + Constructor + @param filter FIR /IIR filter to be used + */ + CResizeEngine(CGenericFilter* filter):m_pFilter(filter) {} + + /// Destructor + virtual ~CResizeEngine() {} + + /** Scale an image to the desired dimensions. + + Method CResizeEngine::scale, as well as the two filtering methods + CResizeEngine::horizontalFilter and CResizeEngine::verticalFilter take + four additional parameters, that define a rectangle in the source + image to be rescaled. + + These are src_left, src_top, src_width and src_height and should work + like these of function FreeImage_Copy. However, src_left and src_top are + actually named src_offset_x and src_offset_y in the filtering methods. + + Additionally, since src_height and dst_height are always the same for + method horizontalFilter as src_width and dst_width are always the same + for verticalFilter, these have been stripped down to a single parameter + height and width for horizontalFilter and verticalFilter respectively. + + Currently, method scale is called with the actual size of the source + image. However, in a future version, we could provide a new function + called FreeImage_RescaleRect that rescales only part of an image. + + @param src Pointer to the source image + @param dst_width Destination image width + @param dst_height Destination image height + @param src_left Left boundary of the source rectangle to be scaled + @param src_top Top boundary of the source rectangle to be scaled + @param src_width Width of the source rectangle to be scaled + @param src_height Height of the source rectangle to be scaled + @return Returns the scaled image if successful, returns NULL otherwise + */ + FIBITMAP* scale(FIBITMAP *src, unsigned dst_width, unsigned dst_height, unsigned src_left, unsigned src_top, unsigned src_width, unsigned src_height); + +private: + + /** + Performs horizontal image filtering + @param src + @param height + @param src_width + @param src_offset_x + @param src_offset_y + @param src_pal + @param dst + @param dst_width + */ + void horizontalFilter(FIBITMAP * const src, const unsigned height, const unsigned src_width, + const unsigned src_offset_x, const unsigned src_offset_y, const RGBQUAD * const src_pal, + FIBITMAP * const dst, const unsigned dst_width); + + /** + Performs vertical image filtering + @param src + @param width + @param src_height + @param src_offset_x + @param src_offset_y + @param src_pal + @param dst + @param dst_height + */ + void verticalFilter(FIBITMAP * const src, const unsigned width, const unsigned src_height, + const unsigned src_offset_x, const unsigned src_offset_y, const RGBQUAD * const src_pal, + FIBITMAP * const dst, const unsigned dst_height); +}; + +#endif // _RESIZE_H_ diff --git a/plugins/AdvaImg/src/LibJPEG/README b/plugins/AdvaImg/src/LibJPEG/README new file mode 100644 index 0000000000..07bb50b20d --- /dev/null +++ b/plugins/AdvaImg/src/LibJPEG/README @@ -0,0 +1,351 @@ +The Independent JPEG Group's JPEG software +========================================== + +README for release 8d of 15-Jan-2012 +==================================== + +This distribution contains the eighth public release of the Independent JPEG +Group's free JPEG software. You are welcome to redistribute this software and +to use it for any purpose, subject to the conditions under LEGAL ISSUES, below. + +This software is the work of Tom Lane, Guido Vollbeding, Philip Gladstone, +Bill Allombert, Jim Boucher, Lee Crocker, Bob Friesenhahn, Ben Jackson, +Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi, Ge' Weijers, +and other members of the Independent JPEG Group. + +IJG is not affiliated with the ISO/IEC JTC1/SC29/WG1 standards committee +(also known as JPEG, together with ITU-T SG16). + + +DOCUMENTATION ROADMAP +===================== + +This file contains the following sections: + +OVERVIEW General description of JPEG and the IJG software. +LEGAL ISSUES Copyright, lack of warranty, terms of distribution. +REFERENCES Where to learn more about JPEG. +ARCHIVE LOCATIONS Where to find newer versions of this software. +ACKNOWLEDGMENTS Special thanks. +FILE FORMAT WARS Software *not* to get. +TO DO Plans for future IJG releases. + +Other documentation files in the distribution are: + +User documentation: + install.txt How to configure and install the IJG software. + usage.txt Usage instructions for cjpeg, djpeg, jpegtran, + rdjpgcom, and wrjpgcom. + *.1 Unix-style man pages for programs (same info as usage.txt). + wizard.txt Advanced usage instructions for JPEG wizards only. + change.log Version-to-version change highlights. +Programmer and internal documentation: + libjpeg.txt How to use the JPEG library in your own programs. + example.c Sample code for calling the JPEG library. + structure.txt Overview of the JPEG library's internal structure. + filelist.txt Road map of IJG files. + coderules.txt Coding style rules --- please read if you contribute code. + +Please read at least the files install.txt and usage.txt. Some information +can also be found in the JPEG FAQ (Frequently Asked Questions) article. See +ARCHIVE LOCATIONS below to find out where to obtain the FAQ article. + +If you want to understand how the JPEG code works, we suggest reading one or +more of the REFERENCES, then looking at the documentation files (in roughly +the order listed) before diving into the code. + + +OVERVIEW +======== + +This package contains C software to implement JPEG image encoding, decoding, +and transcoding. JPEG (pronounced "jay-peg") is a standardized compression +method for full-color and gray-scale images. + +This software implements JPEG baseline, extended-sequential, and progressive +compression processes. Provision is made for supporting all variants of these +processes, although some uncommon parameter settings aren't implemented yet. +We have made no provision for supporting the hierarchical or lossless +processes defined in the standard. + +We provide a set of library routines for reading and writing JPEG image files, +plus two sample applications "cjpeg" and "djpeg", which use the library to +perform conversion between JPEG and some other popular image file formats. +The library is intended to be reused in other applications. + +In order to support file conversion and viewing software, we have included +considerable functionality beyond the bare JPEG coding/decoding capability; +for example, the color quantization modules are not strictly part of JPEG +decoding, but they are essential for output to colormapped file formats or +colormapped displays. These extra functions can be compiled out of the +library if not required for a particular application. + +We have also included "jpegtran", a utility for lossless transcoding between +different JPEG processes, and "rdjpgcom" and "wrjpgcom", two simple +applications for inserting and extracting textual comments in JFIF files. + +The emphasis in designing this software has been on achieving portability and +flexibility, while also making it fast enough to be useful. In particular, +the software is not intended to be read as a tutorial on JPEG. (See the +REFERENCES section for introductory material.) Rather, it is intended to +be reliable, portable, industrial-strength code. We do not claim to have +achieved that goal in every aspect of the software, but we strive for it. + +We welcome the use of this software as a component of commercial products. +No royalty is required, but we do ask for an acknowledgement in product +documentation, as described under LEGAL ISSUES. + + +LEGAL ISSUES +============ + +In plain English: + +1. We don't promise that this software works. (But if you find any bugs, + please let us know!) +2. You can use this software for whatever you want. You don't have to pay us. +3. You may not pretend that you wrote this software. If you use it in a + program, you must acknowledge somewhere in your documentation that + you've used the IJG code. + +In legalese: + +The authors make NO WARRANTY or representation, either express or implied, +with respect to this software, its quality, accuracy, merchantability, or +fitness for a particular purpose. This software is provided "AS IS", and you, +its user, assume the entire risk as to its quality and accuracy. + +This software is copyright (C) 1991-2012, Thomas G. Lane, Guido Vollbeding. +All Rights Reserved except as specified below. + +Permission is hereby granted to use, copy, modify, and distribute this +software (or portions thereof) for any purpose, without fee, subject to these +conditions: +(1) If any part of the source code for this software is distributed, then this +README file must be included, with this copyright and no-warranty notice +unaltered; and any additions, deletions, or changes to the original files +must be clearly indicated in accompanying documentation. +(2) If only executable code is distributed, then the accompanying +documentation must state that "this software is based in part on the work of +the Independent JPEG Group". +(3) Permission for use of this software is granted only if the user accepts +full responsibility for any undesirable consequences; the authors accept +NO LIABILITY for damages of any kind. + +These conditions apply to any software derived from or based on the IJG code, +not just to the unmodified library. If you use our work, you ought to +acknowledge us. + +Permission is NOT granted for the use of any IJG author's name or company name +in advertising or publicity relating to this software or products derived from +it. This software may be referred to only as "the Independent JPEG Group's +software". + +We specifically permit and encourage the use of this software as the basis of +commercial products, provided that all warranty or liability claims are +assumed by the product vendor. + + +ansi2knr.c is included in this distribution by permission of L. Peter Deutsch, +sole proprietor of its copyright holder, Aladdin Enterprises of Menlo Park, CA. +ansi2knr.c is NOT covered by the above copyright and conditions, but instead +by the usual distribution terms of the Free Software Foundation; principally, +that you must include source code if you redistribute it. (See the file +ansi2knr.c for full details.) However, since ansi2knr.c is not needed as part +of any program generated from the IJG code, this does not limit you more than +the foregoing paragraphs do. + +The Unix configuration script "configure" was produced with GNU Autoconf. +It is copyright by the Free Software Foundation but is freely distributable. +The same holds for its supporting scripts (config.guess, config.sub, +ltmain.sh). Another support script, install-sh, is copyright by X Consortium +but is also freely distributable. + +The IJG distribution formerly included code to read and write GIF files. +To avoid entanglement with the Unisys LZW patent, GIF reading support has +been removed altogether, and the GIF writer has been simplified to produce +"uncompressed GIFs". This technique does not use the LZW algorithm; the +resulting GIF files are larger than usual, but are readable by all standard +GIF decoders. + +We are required to state that + "The Graphics Interchange Format(c) is the Copyright property of + CompuServe Incorporated. GIF(sm) is a Service Mark property of + CompuServe Incorporated." + + +REFERENCES +========== + +We recommend reading one or more of these references before trying to +understand the innards of the JPEG software. + +The best short technical introduction to the JPEG compression algorithm is + Wallace, Gregory K. "The JPEG Still Picture Compression Standard", + Communications of the ACM, April 1991 (vol. 34 no. 4), pp. 30-44. +(Adjacent articles in that issue discuss MPEG motion picture compression, +applications of JPEG, and related topics.) If you don't have the CACM issue +handy, a PostScript file containing a revised version of Wallace's article is +available at http://www.ijg.org/files/wallace.ps.gz. The file (actually +a preprint for an article that appeared in IEEE Trans. Consumer Electronics) +omits the sample images that appeared in CACM, but it includes corrections +and some added material. Note: the Wallace article is copyright ACM and IEEE, +and it may not be used for commercial purposes. + +A somewhat less technical, more leisurely introduction to JPEG can be found in +"The Data Compression Book" by Mark Nelson and Jean-loup Gailly, published by +M&T Books (New York), 2nd ed. 1996, ISBN 1-55851-434-1. This book provides +good explanations and example C code for a multitude of compression methods +including JPEG. It is an excellent source if you are comfortable reading C +code but don't know much about data compression in general. The book's JPEG +sample code is far from industrial-strength, but when you are ready to look +at a full implementation, you've got one here... + +The best currently available description of JPEG is the textbook "JPEG Still +Image Data Compression Standard" by William B. Pennebaker and Joan L. +Mitchell, published by Van Nostrand Reinhold, 1993, ISBN 0-442-01272-1. +Price US$59.95, 638 pp. The book includes the complete text of the ISO JPEG +standards (DIS 10918-1 and draft DIS 10918-2). +Although this is by far the most detailed and comprehensive exposition of +JPEG publicly available, we point out that it is still missing an explanation +of the most essential properties and algorithms of the underlying DCT +technology. +If you think that you know about DCT-based JPEG after reading this book, +then you are in delusion. The real fundamentals and corresponding potential +of DCT-based JPEG are not publicly known so far, and that is the reason for +all the mistaken developments taking place in the image coding domain. + +The original JPEG standard is divided into two parts, Part 1 being the actual +specification, while Part 2 covers compliance testing methods. Part 1 is +titled "Digital Compression and Coding of Continuous-tone Still Images, +Part 1: Requirements and guidelines" and has document numbers ISO/IEC IS +10918-1, ITU-T T.81. Part 2 is titled "Digital Compression and Coding of +Continuous-tone Still Images, Part 2: Compliance testing" and has document +numbers ISO/IEC IS 10918-2, ITU-T T.83. +IJG JPEG 8 introduces an implementation of the JPEG SmartScale extension +which is specified in two documents: A contributed document at ITU and ISO +with title "ITU-T JPEG-Plus Proposal for Extending ITU-T T.81 for Advanced +Image Coding", April 2006, Geneva, Switzerland. The latest version of this +document is Revision 3. And a contributed document ISO/IEC JTC1/SC29/WG1 N +5799 with title "Evolution of JPEG", June/July 2011, Berlin, Germany. + +The JPEG standard does not specify all details of an interchangeable file +format. For the omitted details we follow the "JFIF" conventions, revision +1.02. JFIF 1.02 has been adopted as an Ecma International Technical Report +and thus received a formal publication status. It is available as a free +download in PDF format from +http://www.ecma-international.org/publications/techreports/E-TR-098.htm. +A PostScript version of the JFIF document is available at +http://www.ijg.org/files/jfif.ps.gz. There is also a plain text version at +http://www.ijg.org/files/jfif.txt.gz, but it is missing the figures. + +The TIFF 6.0 file format specification can be obtained by FTP from +ftp://ftp.sgi.com/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation scheme +found in the TIFF 6.0 spec of 3-June-92 has a number of serious problems. +IJG does not recommend use of the TIFF 6.0 design (TIFF Compression tag 6). +Instead, we recommend the JPEG design proposed by TIFF Technical Note #2 +(Compression tag 7). Copies of this Note can be obtained from +http://www.ijg.org/files/. It is expected that the next revision +of the TIFF spec will replace the 6.0 JPEG design with the Note's design. +Although IJG's own code does not support TIFF/JPEG, the free libtiff library +uses our library to implement TIFF/JPEG per the Note. + + +ARCHIVE LOCATIONS +================= + +The "official" archive site for this software is www.ijg.org. +The most recent released version can always be found there in +directory "files". This particular version will be archived as +http://www.ijg.org/files/jpegsrc.v8d.tar.gz, and in Windows-compatible +"zip" archive format as http://www.ijg.org/files/jpegsr8d.zip. + +The JPEG FAQ (Frequently Asked Questions) article is a source of some +general information about JPEG. +It is available on the World Wide Web at http://www.faqs.org/faqs/jpeg-faq/ +and other news.answers archive sites, including the official news.answers +archive at rtfm.mit.edu: ftp://rtfm.mit.edu/pub/usenet/news.answers/jpeg-faq/. +If you don't have Web or FTP access, send e-mail to mail-server@rtfm.mit.edu +with body + send usenet/news.answers/jpeg-faq/part1 + send usenet/news.answers/jpeg-faq/part2 + + +ACKNOWLEDGMENTS +=============== + +Thank to Juergen Bruder for providing me with a copy of the common DCT +algorithm article, only to find out that I had come to the same result +in a more direct and comprehensible way with a more generative approach. + +Thank to Istvan Sebestyen and Joan L. Mitchell for inviting me to the +ITU JPEG (Study Group 16) meeting in Geneva, Switzerland. + +Thank to Thomas Wiegand and Gary Sullivan for inviting me to the +Joint Video Team (MPEG & ITU) meeting in Geneva, Switzerland. + +Thank to Thomas Richter and Daniel Lee for inviting me to the +ISO/IEC JTC1/SC29/WG1 (also known as JPEG, together with ITU-T SG16) +meeting in Berlin, Germany. + +Thank to John Korejwa and Massimo Ballerini for inviting me to +fruitful consultations in Boston, MA and Milan, Italy. + +Thank to Hendrik Elstner, Roland Fassauer, Simone Zuck, Guenther +Maier-Gerber, Walter Stoeber, Fred Schmitz, and Norbert Braunagel +for corresponding business development. + +Thank to Nico Zschach and Dirk Stelling of the technical support team +at the Digital Images company in Halle for providing me with extra +equipment for configuration tests. + +Thank to Richard F. Lyon (then of Foveon Inc.) for fruitful +communication about JPEG configuration in Sigma Photo Pro software. + +Thank to Andrew Finkenstadt for hosting the ijg.org site. + +Last but not least special thank to Thomas G. Lane for the original +design and development of this singular software package. + + +FILE FORMAT WARS +================ + +The ISO/IEC JTC1/SC29/WG1 standards committee (also known as JPEG, together +with ITU-T SG16) currently promotes different formats containing the name +"JPEG" which is misleading because these formats are incompatible with +original DCT-based JPEG and are based on faulty technologies. +IJG therefore does not and will not support such momentary mistakes +(see REFERENCES). +There exist also distributions under the name "OpenJPEG" promoting such +kind of formats which is misleading because they don't support original +JPEG images. +We have no sympathy for the promotion of inferior formats. Indeed, one of +the original reasons for developing this free software was to help force +convergence on common, interoperable format standards for JPEG files. +Don't use an incompatible file format! +(In any case, our decoder will remain capable of reading existing JPEG +image files indefinitely.) + +Furthermore, the ISO committee pretends to be "responsible for the popular +JPEG" in their public reports which is not true because they don't respond to +actual requirements for the maintenance of the original JPEG specification. + +There are currently distributions in circulation containing the name +"libjpeg" which claim to be a "derivative" or "fork" of the original +libjpeg, but don't have the features and are incompatible with formats +supported by actual IJG libjpeg distributions. Furthermore, they +violate the license conditions as described under LEGAL ISSUES above. +We have no sympathy for the release of misleading and illegal +distributions derived from obsolete code bases. +Don't use an obsolete code base! + + +TO DO +===== + +Version 8 is the first release of a new generation JPEG standard +to overcome the limitations of the original JPEG specification. +More features are being prepared for coming releases... + +Please send bug reports, offers of help, etc. to jpeg-info@jpegclub.org. diff --git a/plugins/AdvaImg/src/LibJPEG/coderules.txt b/plugins/AdvaImg/src/LibJPEG/coderules.txt new file mode 100644 index 0000000000..382efad3a9 --- /dev/null +++ b/plugins/AdvaImg/src/LibJPEG/coderules.txt @@ -0,0 +1,118 @@ +IJG JPEG LIBRARY: CODING RULES + +Copyright (C) 1991-1996, Thomas G. Lane. +This file is part of the Independent JPEG Group's software. +For conditions of distribution and use, see the accompanying README file. + + +Since numerous people will be contributing code and bug fixes, it's important +to establish a common coding style. The goal of using similar coding styles +is much more important than the details of just what that style is. + +In general we follow the recommendations of "Recommended C Style and Coding +Standards" revision 6.1 (Cannon et al. as modified by Spencer, Keppel and +Brader). This document is available in the IJG FTP archive (see +jpeg/doc/cstyle.ms.tbl.Z, or cstyle.txt.Z for those without nroff/tbl). + +Block comments should be laid out thusly: + +/* + * Block comments in this style. + */ + +We indent statements in K&R style, e.g., + if (test) { + then-part; + } else { + else-part; + } +with two spaces per indentation level. (This indentation convention is +handled automatically by GNU Emacs and many other text editors.) + +Multi-word names should be written in lower case with underscores, e.g., +multi_word_name (not multiWordName). Preprocessor symbols and enum constants +are similar but upper case (MULTI_WORD_NAME). Names should be unique within +the first fifteen characters. (On some older systems, global names must be +unique within six characters. We accommodate this without cluttering the +source code by using macros to substitute shorter names.) + +We use function prototypes everywhere; we rely on automatic source code +transformation to feed prototype-less C compilers. Transformation is done +by the simple and portable tool 'ansi2knr.c' (courtesy of Ghostscript). +ansi2knr is not very bright, so it imposes a format requirement on function +declarations: the function name MUST BEGIN IN COLUMN 1. Thus all functions +should be written in the following style: + +LOCAL(int *) +function_name (int a, char *b) +{ + code... +} + +Note that each function definition must begin with GLOBAL(type), LOCAL(type), +or METHODDEF(type). These macros expand to "static type" or just "type" as +appropriate. They provide a readable indication of the routine's usage and +can readily be changed for special needs. (For instance, special linkage +keywords can be inserted for use in Windows DLLs.) + +ansi2knr does not transform method declarations (function pointers in +structs). We handle these with a macro JMETHOD, defined as + #ifdef HAVE_PROTOTYPES + #define JMETHOD(type,methodname,arglist) type (*methodname) arglist + #else + #define JMETHOD(type,methodname,arglist) type (*methodname) () + #endif +which is used like this: + struct function_pointers { + JMETHOD(void, init_entropy_encoder, (int somearg, jparms *jp)); + JMETHOD(void, term_entropy_encoder, (void)); + }; +Note the set of parentheses surrounding the parameter list. + +A similar solution is used for forward and external function declarations +(see the EXTERN and JPP macros). + +If the code is to work on non-ANSI compilers, we cannot rely on a prototype +declaration to coerce actual parameters into the right types. Therefore, use +explicit casts on actual parameters whenever the actual parameter type is not +identical to the formal parameter. Beware of implicit conversions to "int". + +It seems there are some non-ANSI compilers in which the sizeof() operator +is defined to return int, yet size_t is defined as long. Needless to say, +this is brain-damaged. Always use the SIZEOF() macro in place of sizeof(), +so that the result is guaranteed to be of type size_t. + + +The JPEG library is intended to be used within larger programs. Furthermore, +we want it to be reentrant so that it can be used by applications that process +multiple images concurrently. The following rules support these requirements: + +1. Avoid direct use of file I/O, "malloc", error report printouts, etc; +pass these through the common routines provided. + +2. Minimize global namespace pollution. Functions should be declared static +wherever possible. (Note that our method-based calling conventions help this +a lot: in many modules only the initialization function will ever need to be +called directly, so only that function need be externally visible.) All +global function names should begin with "jpeg_", and should have an +abbreviated name (unique in the first six characters) substituted by macro +when NEED_SHORT_EXTERNAL_NAMES is set. + +3. Don't use global variables; anything that must be used in another module +should be in the common data structures. + +4. Don't use static variables except for read-only constant tables. Variables +that should be private to a module can be placed into private structures (see +the system architecture document, structure.txt). + +5. Source file names should begin with "j" for files that are part of the +library proper; source files that are not part of the library, such as cjpeg.c +and djpeg.c, do not begin with "j". Keep source file names to eight +characters (plus ".c" or ".h", etc) to make life easy for MS-DOSers. Keep +compression and decompression code in separate source files --- some +applications may want only one half of the library. + +Note: these rules (particularly #4) are not followed religiously in the +modules that are used in cjpeg/djpeg but are not part of the JPEG library +proper. Those modules are not really intended to be used in other +applications. diff --git a/plugins/AdvaImg/src/LibJPEG/filelist.txt b/plugins/AdvaImg/src/LibJPEG/filelist.txt new file mode 100644 index 0000000000..040abffc8d --- /dev/null +++ b/plugins/AdvaImg/src/LibJPEG/filelist.txt @@ -0,0 +1,215 @@ +IJG JPEG LIBRARY: FILE LIST + +Copyright (C) 1994-2009, Thomas G. Lane, Guido Vollbeding. +This file is part of the Independent JPEG Group's software. +For conditions of distribution and use, see the accompanying README file. + + +Here is a road map to the files in the IJG JPEG distribution. The +distribution includes the JPEG library proper, plus two application +programs ("cjpeg" and "djpeg") which use the library to convert JPEG +files to and from some other popular image formats. A third application +"jpegtran" uses the library to do lossless conversion between different +variants of JPEG. There are also two stand-alone applications, +"rdjpgcom" and "wrjpgcom". + + +THE JPEG LIBRARY +================ + +Include files: + +jpeglib.h JPEG library's exported data and function declarations. +jconfig.h Configuration declarations. Note: this file is not present + in the distribution; it is generated during installation. +jmorecfg.h Additional configuration declarations; need not be changed + for a standard installation. +jerror.h Declares JPEG library's error and trace message codes. +jinclude.h Central include file used by all IJG .c files to reference + system include files. +jpegint.h JPEG library's internal data structures. +jdct.h Private declarations for forward & reverse DCT subsystems. +jmemsys.h Private declarations for memory management subsystem. +jversion.h Version information. + +Applications using the library should include jpeglib.h (which in turn +includes jconfig.h and jmorecfg.h). Optionally, jerror.h may be included +if the application needs to reference individual JPEG error codes. The +other include files are intended for internal use and would not normally +be included by an application program. (cjpeg/djpeg/etc do use jinclude.h, +since its function is to improve portability of the whole IJG distribution. +Most other applications will directly include the system include files they +want, and hence won't need jinclude.h.) + + +C source code files: + +These files contain most of the functions intended to be called directly by +an application program: + +jcapimin.c Application program interface: core routines for compression. +jcapistd.c Application program interface: standard compression. +jdapimin.c Application program interface: core routines for decompression. +jdapistd.c Application program interface: standard decompression. +jcomapi.c Application program interface routines common to compression + and decompression. +jcparam.c Compression parameter setting helper routines. +jctrans.c API and library routines for transcoding compression. +jdtrans.c API and library routines for transcoding decompression. + +Compression side of the library: + +jcinit.c Initialization: determines which other modules to use. +jcmaster.c Master control: setup and inter-pass sequencing logic. +jcmainct.c Main buffer controller (preprocessor => JPEG compressor). +jcprepct.c Preprocessor buffer controller. +jccoefct.c Buffer controller for DCT coefficient buffer. +jccolor.c Color space conversion. +jcsample.c Downsampling. +jcdctmgr.c DCT manager (DCT implementation selection & control). +jfdctint.c Forward DCT using slow-but-accurate integer method. +jfdctfst.c Forward DCT using faster, less accurate integer method. +jfdctflt.c Forward DCT using floating-point arithmetic. +jchuff.c Huffman entropy coding. +jcarith.c Arithmetic entropy coding. +jcmarker.c JPEG marker writing. +jdatadst.c Data destination managers for memory and stdio output. + +Decompression side of the library: + +jdmaster.c Master control: determines which other modules to use. +jdinput.c Input controller: controls input processing modules. +jdmainct.c Main buffer controller (JPEG decompressor => postprocessor). +jdcoefct.c Buffer controller for DCT coefficient buffer. +jdpostct.c Postprocessor buffer controller. +jdmarker.c JPEG marker reading. +jdhuff.c Huffman entropy decoding. +jdarith.c Arithmetic entropy decoding. +jddctmgr.c IDCT manager (IDCT implementation selection & control). +jidctint.c Inverse DCT using slow-but-accurate integer method. +jidctfst.c Inverse DCT using faster, less accurate integer method. +jidctflt.c Inverse DCT using floating-point arithmetic. +jdsample.c Upsampling. +jdcolor.c Color space conversion. +jdmerge.c Merged upsampling/color conversion (faster, lower quality). +jquant1.c One-pass color quantization using a fixed-spacing colormap. +jquant2.c Two-pass color quantization using a custom-generated colormap. + Also handles one-pass quantization to an externally given map. +jdatasrc.c Data source managers for memory and stdio input. + +Support files for both compression and decompression: + +jaricom.c Tables for common use in arithmetic entropy encoding and + decoding routines. +jerror.c Standard error handling routines (application replaceable). +jmemmgr.c System-independent (more or less) memory management code. +jutils.c Miscellaneous utility routines. + +jmemmgr.c relies on a system-dependent memory management module. The IJG +distribution includes the following implementations of the system-dependent +module: + +jmemnobs.c "No backing store": assumes adequate virtual memory exists. +jmemansi.c Makes temporary files with ANSI-standard routine tmpfile(). +jmemname.c Makes temporary files with program-generated file names. +jmemdos.c Custom implementation for MS-DOS (16-bit environment only): + can use extended and expanded memory as well as temp files. +jmemmac.c Custom implementation for Apple Macintosh. + +Exactly one of the system-dependent modules should be configured into an +installed JPEG library (see install.txt for hints about which one to use). +On unusual systems you may find it worthwhile to make a special +system-dependent memory manager. + + +Non-C source code files: + +jmemdosa.asm 80x86 assembly code support for jmemdos.c; used only in + MS-DOS-specific configurations of the JPEG library. + + +CJPEG/DJPEG/JPEGTRAN +==================== + +Include files: + +cdjpeg.h Declarations shared by cjpeg/djpeg/jpegtran modules. +cderror.h Additional error and trace message codes for cjpeg et al. +transupp.h Declarations for jpegtran support routines in transupp.c. + +C source code files: + +cjpeg.c Main program for cjpeg. +djpeg.c Main program for djpeg. +jpegtran.c Main program for jpegtran. +cdjpeg.c Utility routines used by all three programs. +rdcolmap.c Code to read a colormap file for djpeg's "-map" switch. +rdswitch.c Code to process some of cjpeg's more complex switches. + Also used by jpegtran. +transupp.c Support code for jpegtran: lossless image manipulations. + +Image file reader modules for cjpeg: + +rdbmp.c BMP file input. +rdgif.c GIF file input (now just a stub). +rdppm.c PPM/PGM file input. +rdrle.c Utah RLE file input. +rdtarga.c Targa file input. + +Image file writer modules for djpeg: + +wrbmp.c BMP file output. +wrgif.c GIF file output (a mere shadow of its former self). +wrppm.c PPM/PGM file output. +wrrle.c Utah RLE file output. +wrtarga.c Targa file output. + + +RDJPGCOM/WRJPGCOM +================= + +C source code files: + +rdjpgcom.c Stand-alone rdjpgcom application. +wrjpgcom.c Stand-alone wrjpgcom application. + +These programs do not depend on the IJG library. They do use +jconfig.h and jinclude.h, only to improve portability. + + +ADDITIONAL FILES +================ + +Documentation (see README for a guide to the documentation files): + +README Master documentation file. +*.txt Other documentation files. +*.1 Documentation in Unix man page format. +change.log Version-to-version change highlights. +example.c Sample code for calling JPEG library. + +Configuration/installation files and programs (see install.txt for more info): + +configure Unix shell script to perform automatic configuration. +configure.ac Source file for use with Autoconf to generate configure. +ltmain.sh Support scripts for configure (from GNU libtool). +config.guess +config.sub +depcomp +missing +install-sh Install shell script for those Unix systems lacking one. +Makefile.in Makefile input for configure. +Makefile.am Source file for use with Automake to generate Makefile.in. +ckconfig.c Program to generate jconfig.h on non-Unix systems. +jconfig.txt Template for making jconfig.h by hand. +mak*.* Sample makefiles for particular systems. +jconfig.* Sample jconfig.h for particular systems. +libjpeg.map Script to generate shared library with versioned symbols. +aclocal.m4 M4 macro definitions for use with Autoconf. +ansi2knr.c De-ANSIfier for pre-ANSI C compilers (courtesy of + L. Peter Deutsch and Aladdin Enterprises). + +Test files (see install.txt for test procedure): + +test*.* Source and comparison files for confidence test. + These are binary image files, NOT text files. diff --git a/plugins/AdvaImg/src/LibJPEG/install.txt b/plugins/AdvaImg/src/LibJPEG/install.txt new file mode 100644 index 0000000000..d8f24952fb --- /dev/null +++ b/plugins/AdvaImg/src/LibJPEG/install.txt @@ -0,0 +1,1096 @@ +INSTALLATION INSTRUCTIONS for the Independent JPEG Group's JPEG software + +Copyright (C) 1991-2011, Thomas G. Lane, Guido Vollbeding. +This file is part of the Independent JPEG Group's software. +For conditions of distribution and use, see the accompanying README file. + + +This file explains how to configure and install the IJG software. We have +tried to make this software extremely portable and flexible, so that it can be +adapted to almost any environment. The downside of this decision is that the +installation process is complicated. We have provided shortcuts to simplify +the task on common systems. But in any case, you will need at least a little +familiarity with C programming and program build procedures for your system. + +If you are only using this software as part of a larger program, the larger +program's installation procedure may take care of configuring the IJG code. +For example, Ghostscript's installation script will configure the IJG code. +You don't need to read this file if you just want to compile Ghostscript. + +If you are on a Unix machine, you may not need to read this file at all. +Try doing + ./configure + make + make test +If that doesn't complain, do + make install +(better do "make -n install" first to see if the makefile will put the files +where you want them). Read further if you run into snags or want to customize +the code for your system. + + +TABLE OF CONTENTS +----------------- + +Before you start +Configuring the software: + using the automatic "configure" script + using one of the supplied jconfig and makefile files + by hand +Building the software +Testing the software +Installing the software +Optional stuff +Optimization +Hints for specific systems + + +BEFORE YOU START +================ + +Before installing the software you must unpack the distributed source code. +Since you are reading this file, you have probably already succeeded in this +task. However, there is a potential for error if you needed to convert the +files to the local standard text file format (for example, if you are on +MS-DOS you may have converted LF end-of-line to CR/LF). You must apply +such conversion to all the files EXCEPT those whose names begin with "test". +The test files contain binary data; if you change them in any way then the +self-test will give bad results. + +Please check the last section of this file to see if there are hints for the +specific machine or compiler you are using. + + +CONFIGURING THE SOFTWARE +======================== + +To configure the IJG code for your system, you need to create two files: + * jconfig.h: contains values for system-dependent #define symbols. + * Makefile: controls the compilation process. +(On a non-Unix machine, you may create "project files" or some other +substitute for a Makefile. jconfig.h is needed in any environment.) + +We provide three different ways to generate these files: + * On a Unix system, you can just run the "configure" script. + * We provide sample jconfig files and makefiles for popular machines; + if your machine matches one of the samples, just copy the right sample + files to jconfig.h and Makefile. + * If all else fails, read the instructions below and make your own files. + + +Configuring the software using the automatic "configure" script +--------------------------------------------------------------- + +If you are on a Unix machine, you can just type + ./configure +and let the configure script construct appropriate configuration files. +If you're using "csh" on an old version of System V, you might need to type + sh configure +instead to prevent csh from trying to execute configure itself. +Expect configure to run for a few minutes, particularly on slower machines; +it works by compiling a series of test programs. + +Configure was created with GNU Autoconf and it follows the usual conventions +for GNU configure scripts. It makes a few assumptions that you may want to +override. You can do this by providing optional switches to configure: + +* Configure will build both static and shared libraries, if possible. +If you want to build libjpeg only as a static library, say + ./configure --disable-shared +If you want to build libjpeg only as a shared library, say + ./configure --disable-static +Configure uses GNU libtool to take care of system-dependent shared library +building methods. + +* Configure will use gcc (GNU C compiler) if it's available, otherwise cc. +To force a particular compiler to be selected, use the CC option, for example + ./configure CC='cc' +The same method can be used to include any unusual compiler switches. +For example, on HP-UX you probably want to say + ./configure CC='cc -Aa' +to get HP's compiler to run in ANSI mode. + +* The default CFLAGS setting is "-g" for non-gcc compilers, "-g -O2" for gcc. +You can override this by saying, for example, + ./configure CFLAGS='-O2' +if you want to compile without debugging support. + +* Configure will set up the makefile so that "make install" will install files +into /usr/local/bin, /usr/local/man, etc. You can specify an installation +prefix other than "/usr/local" by giving configure the option "--prefix=PATH". + +* If you don't have a lot of swap space, you may need to enable the IJG +software's internal virtual memory mechanism. To do this, give the option +"--enable-maxmem=N" where N is the default maxmemory limit in megabytes. +This is discussed in more detail under "Selecting a memory manager", below. +You probably don't need to worry about this on reasonably-sized Unix machines, +unless you plan to process very large images. + +Configure has some other features that are useful if you are cross-compiling +or working in a network of multiple machine types; but if you need those +features, you probably already know how to use them. + + +Configuring the software using one of the supplied jconfig and makefile files +----------------------------------------------------------------------------- + +If you have one of these systems, you can just use the provided configuration +files: + +Makefile jconfig file System and/or compiler + +makefile.manx jconfig.manx Amiga, Manx Aztec C +makefile.sas jconfig.sas Amiga, SAS C +makeproj.mac jconfig.mac Apple Macintosh, Metrowerks CodeWarrior +mak*jpeg.st jconfig.st Atari ST/STE/TT, Pure C or Turbo C +makefile.bcc jconfig.bcc MS-DOS or OS/2, Borland C +makefile.dj jconfig.dj MS-DOS, DJGPP (Delorie's port of GNU C) +makefile.mc6 jconfig.mc6 MS-DOS, Microsoft C (16-bit only) +makefile.wat jconfig.wat MS-DOS, OS/2, or Windows NT, Watcom C +makefile.vc jconfig.vc Windows NT/95, MS Visual C++ +make*.vc6 jconfig.vc Windows NT/95, MS Visual C++ 6 +make*.v10 jconfig.vc Windows NT/95, MS Visual C++ 2010 (v10) +makefile.mms jconfig.vms Digital VMS, with MMS software +makefile.vms jconfig.vms Digital VMS, without MMS software + +Copy the proper jconfig file to jconfig.h and the makefile to Makefile (or +whatever your system uses as the standard makefile name). For more info see +the appropriate system-specific hints section near the end of this file. + + +Configuring the software by hand +-------------------------------- + +First, generate a jconfig.h file. If you are moderately familiar with C, +the comments in jconfig.txt should be enough information to do this; just +copy jconfig.txt to jconfig.h and edit it appropriately. Otherwise, you may +prefer to use the ckconfig.c program. You will need to compile and execute +ckconfig.c by hand --- we hope you know at least enough to do that. +ckconfig.c may not compile the first try (in fact, the whole idea is for it +to fail if anything is going to). If you get compile errors, fix them by +editing ckconfig.c according to the directions given in ckconfig.c. Once +you get it to run, it will write a suitable jconfig.h file, and will also +print out some advice about which makefile to use. + +You may also want to look at the canned jconfig files, if there is one for a +system similar to yours. + +Second, select a makefile and copy it to Makefile (or whatever your system +uses as the standard makefile name). The most generic makefiles we provide +are + makefile.ansi: if your C compiler supports function prototypes + makefile.unix: if not. +(You have function prototypes if ckconfig.c put "#define HAVE_PROTOTYPES" +in jconfig.h.) You may want to start from one of the other makefiles if +there is one for a system similar to yours. + +Look over the selected Makefile and adjust options as needed. In particular +you may want to change the CC and CFLAGS definitions. For instance, if you +are using GCC, set CC=gcc. If you had to use any compiler switches to get +ckconfig.c to work, make sure the same switches are in CFLAGS. + +If you are on a system that doesn't use makefiles, you'll need to set up +project files (or whatever you do use) to compile all the source files and +link them into executable files cjpeg, djpeg, jpegtran, rdjpgcom, and wrjpgcom. +See the file lists in any of the makefiles to find out which files go into +each program. Note that the provided makefiles all make a "library" file +libjpeg first, but you don't have to do that if you don't want to; the file +lists identify which source files are actually needed for compression, +decompression, or both. As a last resort, you can make a batch script that +just compiles everything and links it all together; makefile.vms is an example +of this (it's for VMS systems that have no make-like utility). + +Here are comments about some specific configuration decisions you'll +need to make: + +Command line style +------------------ + +These programs can use a Unix-like command line style which supports +redirection and piping, like this: + cjpeg inputfile >outputfile + cjpeg outputfile + source program | cjpeg >outputfile +The simpler "two file" command line style is just + cjpeg inputfile outputfile +You may prefer the two-file style, particularly if you don't have pipes. + +You MUST use two-file style on any system that doesn't cope well with binary +data fed through stdin/stdout; this is true for some MS-DOS compilers, for +example. If you're not on a Unix system, it's safest to assume you need +two-file style. (But if your compiler provides either the Posix-standard +fdopen() library routine or a Microsoft-compatible setmode() routine, you +can safely use the Unix command line style, by defining USE_FDOPEN or +USE_SETMODE respectively.) + +To use the two-file style, make jconfig.h say "#define TWO_FILE_COMMANDLINE". + +Selecting a memory manager +-------------------------- + +The IJG code is capable of working on images that are too big to fit in main +memory; data is swapped out to temporary files as necessary. However, the +code to do this is rather system-dependent. We provide five different +memory managers: + +* jmemansi.c This version uses the ANSI-standard library routine tmpfile(), + which not all non-ANSI systems have. On some systems + tmpfile() may put the temporary file in a non-optimal + location; if you don't like what it does, use jmemname.c. + +* jmemname.c This version creates named temporary files. For anything + except a Unix machine, you'll need to configure the + select_file_name() routine appropriately; see the comments + near the head of jmemname.c. If you use this version, define + NEED_SIGNAL_CATCHER in jconfig.h to make sure the temp files + are removed if the program is aborted. + +* jmemnobs.c (That stands for No Backing Store :-).) This will compile on + almost any system, but it assumes you have enough main memory + or virtual memory to hold the biggest images you work with. + +* jmemdos.c This should be used with most 16-bit MS-DOS compilers. + See the system-specific notes about MS-DOS for more info. + IMPORTANT: if you use this, define USE_MSDOS_MEMMGR in + jconfig.h, and include the assembly file jmemdosa.asm in the + programs. The supplied makefiles and jconfig files for + 16-bit MS-DOS compilers already do both. + +* jmemmac.c Custom version for Apple Macintosh; see the system-specific + notes for Macintosh for more info. + +To use a particular memory manager, change the SYSDEPMEM variable in your +makefile to equal the corresponding object file name (for example, jmemansi.o +or jmemansi.obj for jmemansi.c). + +If you have plenty of (real or virtual) main memory, just use jmemnobs.c. +"Plenty" means about ten bytes for every pixel in the largest images +you plan to process, so a lot of systems don't meet this criterion. +If yours doesn't, try jmemansi.c first. If that doesn't compile, you'll have +to use jmemname.c; be sure to adjust select_file_name() for local conditions. +You may also need to change unlink() to remove() in close_backing_store(). + +Except with jmemnobs.c or jmemmac.c, you need to adjust the DEFAULT_MAX_MEM +setting to a reasonable value for your system (either by adding a #define for +DEFAULT_MAX_MEM to jconfig.h, or by adding a -D switch to the Makefile). +This value limits the amount of data space the program will attempt to +allocate. Code and static data space isn't counted, so the actual memory +needs for cjpeg or djpeg are typically 100 to 150Kb more than the max-memory +setting. Larger max-memory settings reduce the amount of I/O needed to +process a large image, but too large a value can result in "insufficient +memory" failures. On most Unix machines (and other systems with virtual +memory), just set DEFAULT_MAX_MEM to several million and forget it. At the +other end of the spectrum, for MS-DOS machines you probably can't go much +above 300K to 400K. (On MS-DOS the value refers to conventional memory only. +Extended/expanded memory is handled separately by jmemdos.c.) + + +BUILDING THE SOFTWARE +===================== + +Now you should be able to compile the software. Just say "make" (or +whatever's necessary to start the compilation). Have a cup of coffee. + +Here are some things that could go wrong: + +If your compiler complains about undefined structures, you should be able to +shut it up by putting "#define INCOMPLETE_TYPES_BROKEN" in jconfig.h. + +If you have trouble with missing system include files or inclusion of the +wrong ones, read jinclude.h. This shouldn't happen if you used configure +or ckconfig.c to set up jconfig.h. + +There are a fair number of routines that do not use all of their parameters; +some compilers will issue warnings about this, which you can ignore. There +are also a few configuration checks that may give "unreachable code" warnings. +Any other warning deserves investigation. + +If you don't have a getenv() library routine, define NO_GETENV. + +Also see the system-specific hints, below. + + +TESTING THE SOFTWARE +==================== + +As a quick test of functionality we've included a small sample image in +several forms: + testorig.jpg Starting point for the djpeg tests. + testimg.ppm The output of djpeg testorig.jpg + testimg.bmp The output of djpeg -bmp -colors 256 testorig.jpg + testimg.jpg The output of cjpeg testimg.ppm + testprog.jpg Progressive-mode equivalent of testorig.jpg. + testimgp.jpg The output of cjpeg -progressive -optimize testimg.ppm +(The first- and second-generation .jpg files aren't identical since the +default compression parameters are lossy.) If you can generate duplicates +of the testimg* files then you probably have working programs. + +With most of the makefiles, "make test" will perform the necessary +comparisons. + +If you're using a makefile that doesn't provide the test option, run djpeg +and cjpeg by hand and compare the output files to testimg* with whatever +binary file comparison tool you have. The files should be bit-for-bit +identical. + +If the programs complain "MAX_ALLOC_CHUNK is wrong, please fix", then you +need to reduce MAX_ALLOC_CHUNK to a value that fits in type size_t. +Try adding "#define MAX_ALLOC_CHUNK 65520L" to jconfig.h. A less likely +configuration error is "ALIGN_TYPE is wrong, please fix": defining ALIGN_TYPE +as long should take care of that one. + +If the cjpeg test run fails with "Missing Huffman code table entry", it's a +good bet that you needed to define RIGHT_SHIFT_IS_UNSIGNED. Go back to the +configuration step and run ckconfig.c. (This is a good plan for any other +test failure, too.) + +If you are using Unix (one-file) command line style on a non-Unix system, +it's a good idea to check that binary I/O through stdin/stdout actually +works. You should get the same results from "djpeg out.ppm" +as from "djpeg -outfile out.ppm testorig.jpg". Note that the makefiles all +use the latter style and therefore do not exercise stdin/stdout! If this +check fails, try recompiling with USE_SETMODE or USE_FDOPEN defined. +If it still doesn't work, better use two-file style. + +If you chose a memory manager other than jmemnobs.c, you should test that +temporary-file usage works. Try "djpeg -bmp -colors 256 -max 0 testorig.jpg" +and make sure its output matches testimg.bmp. If you have any really large +images handy, try compressing them with -optimize and/or decompressing with +-colors 256 to make sure your DEFAULT_MAX_MEM setting is not too large. + +NOTE: this is far from an exhaustive test of the JPEG software; some modules, +such as 1-pass color quantization, are not exercised at all. It's just a +quick test to give you some confidence that you haven't missed something +major. + + +INSTALLING THE SOFTWARE +======================= + +Once you're done with the above steps, you can install the software by +copying the executable files (cjpeg, djpeg, jpegtran, rdjpgcom, and wrjpgcom) +to wherever you normally install programs. On Unix systems, you'll also want +to put the man pages (cjpeg.1, djpeg.1, jpegtran.1, rdjpgcom.1, wrjpgcom.1) +in the man-page directory. The pre-fab makefiles don't support this step +since there's such a wide variety of installation procedures on different +systems. + +If you generated a Makefile with the "configure" script, you can just say + make install +to install the programs and their man pages into the standard places. +(You'll probably need to be root to do this.) We recommend first saying + make -n install +to see where configure thought the files should go. You may need to edit +the Makefile, particularly if your system's conventions for man page +filenames don't match what configure expects. + +If you want to install the IJG library itself, for use in compiling other +programs besides ours, then you need to put the four include files + jpeglib.h jerror.h jconfig.h jmorecfg.h +into your include-file directory, and put the library file libjpeg.a +(extension may vary depending on system) wherever library files go. +If you generated a Makefile with "configure", it will do what it thinks +is the right thing if you say + make install-lib + + +OPTIONAL STUFF +============== + +Progress monitor: + +If you like, you can #define PROGRESS_REPORT (in jconfig.h) to enable display +of percent-done progress reports. The routine provided in cdjpeg.c merely +prints percentages to stderr, but you can customize it to do something +fancier. + +Utah RLE file format support: + +We distribute the software with support for RLE image files (Utah Raster +Toolkit format) disabled, because the RLE support won't compile without the +Utah library. If you have URT version 3.1 or later, you can enable RLE +support as follows: + 1. #define RLE_SUPPORTED in jconfig.h. + 2. Add a -I option to CFLAGS in the Makefile for the directory + containing the URT .h files (typically the "include" + subdirectory of the URT distribution). + 3. Add -L... -lrle to LDLIBS in the Makefile, where ... specifies + the directory containing the URT "librle.a" file (typically the + "lib" subdirectory of the URT distribution). + +Support for 12-bit-deep pixel data: + +The JPEG standard allows either 8-bit or 12-bit data precision. (For color, +this means 8 or 12 bits per channel, of course.) If you need to work with +deeper than 8-bit data, you can compile the IJG code for 12-bit operation. +To do so: + 1. In jmorecfg.h, define BITS_IN_JSAMPLE as 12 rather than 8. + 2. In jconfig.h, undefine BMP_SUPPORTED, RLE_SUPPORTED, and TARGA_SUPPORTED, + because the code for those formats doesn't handle 12-bit data and won't + even compile. (The PPM code does work, as explained below. The GIF + code works too; it scales 8-bit GIF data to and from 12-bit depth + automatically.) + 3. Compile. Don't expect "make test" to pass, since the supplied test + files are for 8-bit data. + +Currently, 12-bit support does not work on 16-bit-int machines. + +Note that a 12-bit version will not read 8-bit JPEG files, nor vice versa; +so you'll want to keep around a regular 8-bit compilation as well. +(Run-time selection of data depth, to allow a single copy that does both, +is possible but would probably slow things down considerably; it's very low +on our to-do list.) + +The PPM reader (rdppm.c) can read 12-bit data from either text-format or +binary-format PPM and PGM files. Binary-format PPM/PGM files which have a +maxval greater than 255 are assumed to use 2 bytes per sample, MSB first +(big-endian order). As of early 1995, 2-byte binary format is not +officially supported by the PBMPLUS library, but it is expected that a +future release of PBMPLUS will support it. Note that the PPM reader will +read files of any maxval regardless of the BITS_IN_JSAMPLE setting; incoming +data is automatically rescaled to either maxval=255 or maxval=4095 as +appropriate for the cjpeg bit depth. + +The PPM writer (wrppm.c) will normally write 2-byte binary PPM or PGM +format, maxval 4095, when compiled with BITS_IN_JSAMPLE=12. Since this +format is not yet widely supported, you can disable it by compiling wrppm.c +with PPM_NORAWWORD defined; then the data is scaled down to 8 bits to make a +standard 1-byte/sample PPM or PGM file. (Yes, this means still another copy +of djpeg to keep around. But hopefully you won't need it for very long. +Poskanzer's supposed to get that new PBMPLUS release out Real Soon Now.) + +Of course, if you are working with 12-bit data, you probably have it stored +in some other, nonstandard format. In that case you'll probably want to +write your own I/O modules to read and write your format. + +Note that a 12-bit version of cjpeg always runs in "-optimize" mode, in +order to generate valid Huffman tables. This is necessary because our +default Huffman tables only cover 8-bit data. + +Removing code: + +If you need to make a smaller version of the JPEG software, some optional +functions can be removed at compile time. See the xxx_SUPPORTED #defines in +jconfig.h and jmorecfg.h. If at all possible, we recommend that you leave in +decoder support for all valid JPEG files, to ensure that you can read anyone's +output. Taking out support for image file formats that you don't use is the +most painless way to make the programs smaller. Another possibility is to +remove some of the DCT methods: in particular, the "IFAST" method may not be +enough faster than the others to be worth keeping on your machine. (If you +do remove ISLOW or IFAST, be sure to redefine JDCT_DEFAULT or JDCT_FASTEST +to a supported method, by adding a #define in jconfig.h.) + + +OPTIMIZATION +============ + +Unless you own a Cray, you'll probably be interested in making the JPEG +software go as fast as possible. This section covers some machine-dependent +optimizations you may want to try. We suggest that before trying any of +this, you first get the basic installation to pass the self-test step. +Repeat the self-test after any optimization to make sure that you haven't +broken anything. + +The integer DCT routines perform a lot of multiplications. These +multiplications must yield 32-bit results, but none of their input values +are more than 16 bits wide. On many machines, notably the 680x0 and 80x86 +CPUs, a 16x16=>32 bit multiply instruction is faster than a full 32x32=>32 +bit multiply. Unfortunately there is no portable way to specify such a +multiplication in C, but some compilers can generate one when you use the +right combination of casts. See the MULTIPLYxxx macro definitions in +jdct.h. If your compiler makes "int" be 32 bits and "short" be 16 bits, +defining SHORTxSHORT_32 is fairly likely to work. When experimenting with +alternate definitions, be sure to test not only whether the code still works +(use the self-test), but also whether it is actually faster --- on some +compilers, alternate definitions may compute the right answer, yet be slower +than the default. Timing cjpeg on a large PGM (grayscale) input file is the +best way to check this, as the DCT will be the largest fraction of the runtime +in that mode. (Note: some of the distributed compiler-specific jconfig files +already contain #define switches to select appropriate MULTIPLYxxx +definitions.) + +If your machine has sufficiently fast floating point hardware, you may find +that the float DCT method is faster than the integer DCT methods, even +after tweaking the integer multiply macros. In that case you may want to +make the float DCT be the default method. (The only objection to this is +that float DCT results may vary slightly across machines.) To do that, add +"#define JDCT_DEFAULT JDCT_FLOAT" to jconfig.h. Even if you don't change +the default, you should redefine JDCT_FASTEST, which is the method selected +by djpeg's -fast switch. Don't forget to update the documentation files +(usage.txt and/or cjpeg.1, djpeg.1) to agree with what you've done. + +If access to "short" arrays is slow on your machine, it may be a win to +define type JCOEF as int rather than short. This will cost a good deal of +memory though, particularly in some multi-pass modes, so don't do it unless +you have memory to burn and short is REALLY slow. + +If your compiler can compile function calls in-line, make sure the INLINE +macro in jmorecfg.h is defined as the keyword that marks a function +inline-able. Some compilers have a switch that tells the compiler to inline +any function it thinks is profitable (e.g., -finline-functions for gcc). +Enabling such a switch is likely to make the compiled code bigger but faster. + +In general, it's worth trying the maximum optimization level of your compiler, +and experimenting with any optional optimizations such as loop unrolling. +(Unfortunately, far too many compilers have optimizer bugs ... be prepared to +back off if the code fails self-test.) If you do any experimentation along +these lines, please report the optimal settings to jpeg-info@jpegclub.org so +we can mention them in future releases. Be sure to specify your machine and +compiler version. + + +HINTS FOR SPECIFIC SYSTEMS +========================== + +We welcome reports on changes needed for systems not mentioned here. Submit +'em to jpeg-info@jpegclub.org. Also, if configure or ckconfig.c is wrong +about how to configure the JPEG software for your system, please let us know. + + +Acorn RISC OS: + +(Thanks to Simon Middleton for these hints on compiling with Desktop C.) +After renaming the files according to Acorn conventions, take a copy of +makefile.ansi, change all occurrences of 'libjpeg.a' to 'libjpeg.o' and +change these definitions as indicated: + +CFLAGS= -throwback -IC: -Wn +LDLIBS=C:o.Stubs +SYSDEPMEM=jmemansi.o +LN=Link +AR=LibFile -c -o + +Also add a new line '.c.o:; $(cc) $< $(cflags) -c -o $@'. Remove the +lines '$(RM) libjpeg.o' and '$(AR2) libjpeg.o' and the 'jconfig.h' +dependency section. + +Copy jconfig.txt to jconfig.h. Edit jconfig.h to define TWO_FILE_COMMANDLINE +and CHAR_IS_UNSIGNED. + +Run the makefile using !AMU not !Make. If you want to use the 'clean' and +'test' makefile entries then you will have to fiddle with the syntax a bit +and rename the test files. + + +Amiga: + +SAS C 6.50 reportedly is too buggy to compile the IJG code properly. +A patch to update to 6.51 is available from SAS or AmiNet FTP sites. + +The supplied config files are set up to use jmemname.c as the memory +manager, with temporary files being created on the device named by +"JPEGTMP:". + + +Atari ST/STE/TT: + +Copy the project files makcjpeg.st, makdjpeg.st, maktjpeg.st, and makljpeg.st +to cjpeg.prj, djpeg.prj, jpegtran.prj, and libjpeg.prj respectively. The +project files should work as-is with Pure C. For Turbo C, change library +filenames "pc..." to "tc..." in each project file. Note that libjpeg.prj +selects jmemansi.c as the recommended memory manager. You'll probably want to +adjust the DEFAULT_MAX_MEM setting --- you want it to be a couple hundred K +less than your normal free memory. Put "#define DEFAULT_MAX_MEM nnnn" into +jconfig.h to do this. + +To use the 68881/68882 coprocessor for the floating point DCT, add the +compiler option "-8" to the project files and replace pcfltlib.lib with +pc881lib.lib in cjpeg.prj and djpeg.prj. Or if you don't have a +coprocessor, you may prefer to remove the float DCT code by undefining +DCT_FLOAT_SUPPORTED in jmorecfg.h (since without a coprocessor, the float +code will be too slow to be useful). In that case, you can delete +pcfltlib.lib from the project files. + +Note that you must make libjpeg.lib before making cjpeg.ttp, djpeg.ttp, +or jpegtran.ttp. You'll have to perform the self-test by hand. + +We haven't bothered to include project files for rdjpgcom and wrjpgcom. +Those source files should just be compiled by themselves; they don't +depend on the JPEG library. You can use the default.prj project file +of the Pure C distribution to make the programs. + +There is a bug in some older versions of the Turbo C library which causes the +space used by temporary files created with "tmpfile()" not to be freed after +an abnormal program exit. If you check your disk afterwards, you will find +cluster chains that are allocated but not used by a file. This should not +happen in cjpeg/djpeg/jpegtran, since we enable a signal catcher to explicitly +close temp files before exiting. But if you use the JPEG library with your +own code, be sure to supply a signal catcher, or else use a different +system-dependent memory manager. + + +Cray: + +Should you be so fortunate as to be running JPEG on a Cray YMP, there is a +compiler bug in old versions of Cray's Standard C (prior to 3.1). If you +still have an old compiler, you'll need to insert a line reading +"#pragma novector" just before the loop + for (i = 1; i <= (int) htbl->bits[l]; i++) + huffsize[p++] = (char) l; +in fix_huff_tbl (in V5beta1, line 204 of jchuff.c and line 176 of jdhuff.c). +[This bug may or may not still occur with the current IJG code, but it's +probably a dead issue anyway...] + + +HP-UX: + +If you have HP-UX 7.05 or later with the "software development" C compiler, +you should run the compiler in ANSI mode. If using the configure script, +say + ./configure CC='cc -Aa' +(or -Ae if you prefer). If configuring by hand, use makefile.ansi and add +"-Aa" to the CFLAGS line in the makefile. + +If you have a pre-7.05 system, or if you are using the non-ANSI C compiler +delivered with a minimum HP-UX system, then you must use makefile.unix +(and do NOT add -Aa); or just run configure without the CC option. + +On HP 9000 series 800 machines, the HP C compiler is buggy in revisions prior +to A.08.07. If you get complaints about "not a typedef name", you'll have to +use makefile.unix, or run configure without the CC option. + + +Macintosh, generic comments: + +The supplied user-interface files (cjpeg.c, djpeg.c, etc) are set up to +provide a Unix-style command line interface. You can use this interface on +the Mac by means of the ccommand() library routine provided by Metrowerks +CodeWarrior or Think C. This is only appropriate for testing the library, +however; to make a user-friendly equivalent of cjpeg/djpeg you'd really want +to develop a Mac-style user interface. There isn't a complete example +available at the moment, but there are some helpful starting points: +1. Sam Bushell's free "To JPEG" applet provides drag-and-drop conversion to +JPEG under System 7 and later. This only illustrates how to use the +compression half of the library, but it does a very nice job of that part. +The CodeWarrior source code is available from http://www.pobox.com/~jsam. +2. Jim Brunner prepared a Mac-style user interface for both compression and +decompression. Unfortunately, it hasn't been updated since IJG v4, and +the library's API has changed considerably since then. Still it may be of +some help, particularly as a guide to compiling the IJG code under Think C. +Jim's code is available from the Info-Mac archives, at sumex-aim.stanford.edu +or mirrors thereof; see file /info-mac/dev/src/jpeg-convert-c.hqx. + +jmemmac.c is the recommended memory manager back end for Macintosh. It uses +NewPtr/DisposePtr instead of malloc/free, and has a Mac-specific +implementation of jpeg_mem_available(). It also creates temporary files that +follow Mac conventions. (That part of the code relies on System-7-or-later OS +functions. See the comments in jmemmac.c if you need to run it on System 6.) +NOTE that USE_MAC_MEMMGR must be defined in jconfig.h to use jmemmac.c. + +You can also use jmemnobs.c, if you don't care about handling images larger +than available memory. If you use any memory manager back end other than +jmemmac.c, we recommend replacing "malloc" and "free" by "NewPtr" and +"DisposePtr", because Mac C libraries often have peculiar implementations of +malloc/free. (For instance, free() may not return the freed space to the +Mac Memory Manager. This is undesirable for the IJG code because jmemmgr.c +already clumps space requests.) + + +Macintosh, Metrowerks CodeWarrior: + +The Unix-command-line-style interface can be used by defining USE_CCOMMAND. +You'll also need to define TWO_FILE_COMMANDLINE to avoid stdin/stdout. +This means that when using the cjpeg/djpeg programs, you'll have to type the +input and output file names in the "Arguments" text-edit box, rather than +using the file radio buttons. (Perhaps USE_FDOPEN or USE_SETMODE would +eliminate the problem, but I haven't heard from anyone who's tried it.) + +On 680x0 Macs, Metrowerks defines type "double" as a 10-byte IEEE extended +float. jmemmgr.c won't like this: it wants sizeof(ALIGN_TYPE) to be a power +of 2. Add "#define ALIGN_TYPE long" to jconfig.h to eliminate the complaint. + +The supplied configuration file jconfig.mac can be used for your jconfig.h; +it includes all the recommended symbol definitions. If you have AppleScript +installed, you can run the supplied script makeproj.mac to create CodeWarrior +project files for the library and the testbed applications, then build the +library and applications. (Thanks to Dan Sears and Don Agro for this nifty +hack, which saves us from trying to maintain CodeWarrior project files as part +of the IJG distribution...) + + +Macintosh, Think C: + +The documentation in Jim Brunner's "JPEG Convert" source code (see above) +includes detailed build instructions for Think C; it's probably somewhat +out of date for the current release, but may be helpful. + +If you want to build the minimal command line version, proceed as follows. +You'll have to prepare project files for the programs; we don't include any +in the distribution since they are not text files. Use the file lists in +any of the supplied makefiles as a guide. Also add the ANSI and Unix C +libraries in a separate segment. You may need to divide the JPEG files into +more than one segment; we recommend dividing compression and decompression +modules. Define USE_CCOMMAND in jconfig.h so that the ccommand() routine is +called. You must also define TWO_FILE_COMMANDLINE because stdin/stdout +don't handle binary data correctly. + +On 680x0 Macs, Think C defines type "double" as a 12-byte IEEE extended float. +jmemmgr.c won't like this: it wants sizeof(ALIGN_TYPE) to be a power of 2. +Add "#define ALIGN_TYPE long" to jconfig.h to eliminate the complaint. + +jconfig.mac should work as a jconfig.h configuration file for Think C, +but the makeproj.mac AppleScript script is specific to CodeWarrior. Sorry. + + +MIPS R3000: + +MIPS's cc version 1.31 has a rather nasty optimization bug. Don't use -O +if you have that compiler version. (Use "cc -V" to check the version.) +Note that the R3000 chip is found in workstations from DEC and others. + + +MS-DOS, generic comments for 16-bit compilers: + +The IJG code is designed to work well in 80x86 "small" or "medium" memory +models (i.e., data pointers are 16 bits unless explicitly declared "far"; +code pointers can be either size). You may be able to use small model to +compile cjpeg or djpeg by itself, but you will probably have to use medium +model for any larger application. This won't make much difference in +performance. You *will* take a noticeable performance hit if you use a +large-data memory model, and you should avoid "huge" model if at all +possible. Be sure that NEED_FAR_POINTERS is defined in jconfig.h if you use +a small-data memory model; be sure it is NOT defined if you use a large-data +model. (The supplied makefiles and jconfig files for Borland and Microsoft C +compile in medium model and define NEED_FAR_POINTERS.) + +The DOS-specific memory manager, jmemdos.c, should be used if possible. +It needs some assembly-code routines which are in jmemdosa.asm; make sure +your makefile assembles that file and includes it in the library. If you +don't have a suitable assembler, you can get pre-assembled object files for +jmemdosa by FTP from ftp.uu.net:/graphics/jpeg/jdosaobj.zip. (DOS-oriented +distributions of the IJG source code often include these object files.) + +When using jmemdos.c, jconfig.h must define USE_MSDOS_MEMMGR and must set +MAX_ALLOC_CHUNK to less than 64K (65520L is a typical value). If your +C library's far-heap malloc() can't allocate blocks that large, reduce +MAX_ALLOC_CHUNK to whatever it can handle. + +If you can't use jmemdos.c for some reason --- for example, because you +don't have an assembler to assemble jmemdosa.asm --- you'll have to fall +back to jmemansi.c or jmemname.c. You'll probably still need to set +MAX_ALLOC_CHUNK in jconfig.h, because most DOS C libraries won't malloc() +more than 64K at a time. IMPORTANT: if you use jmemansi.c or jmemname.c, +you will have to compile in a large-data memory model in order to get the +right stdio library. Too bad. + +wrjpgcom needs to be compiled in large model, because it malloc()s a 64KB +work area to hold the comment text. If your C library's malloc can't +handle that, reduce MAX_COM_LENGTH as necessary in wrjpgcom.c. + +Most MS-DOS compilers treat stdin/stdout as text files, so you must use +two-file command line style. But if your compiler has either fdopen() or +setmode(), you can use one-file style if you like. To do this, define +USE_SETMODE or USE_FDOPEN so that stdin/stdout will be set to binary mode. +(USE_SETMODE seems to work with more DOS compilers than USE_FDOPEN.) You +should test that I/O through stdin/stdout produces the same results as I/O +to explicitly named files... the "make test" procedures in the supplied +makefiles do NOT use stdin/stdout. + + +MS-DOS, generic comments for 32-bit compilers: + +None of the above comments about memory models apply if you are using a +32-bit flat-memory-space environment, such as DJGPP or Watcom C. (And you +should use one if you have it, as performance will be much better than +8086-compatible code!) For flat-memory-space compilers, do NOT define +NEED_FAR_POINTERS, and do NOT use jmemdos.c. Use jmemnobs.c if the +environment supplies adequate virtual memory, otherwise use jmemansi.c or +jmemname.c. + +You'll still need to be careful about binary I/O through stdin/stdout. +See the last paragraph of the previous section. + + +MS-DOS, Borland C: + +Be sure to convert all the source files to DOS text format (CR/LF newlines). +Although Borland C will often work OK with unmodified Unix (LF newlines) +source files, sometimes it will give bogus compile errors. +"Illegal character '#'" is the most common such error. (This is true with +Borland C 3.1, but perhaps is fixed in newer releases.) + +If you want one-file command line style, just undefine TWO_FILE_COMMANDLINE. +jconfig.bcc already includes #define USE_SETMODE to make this work. +(fdopen does not work correctly.) + + +MS-DOS, Microsoft C: + +makefile.mc6 works with Microsoft C, DOS Visual C++, etc. It should only +be used if you want to build a 16-bit (small or medium memory model) program. + +If you want one-file command line style, just undefine TWO_FILE_COMMANDLINE. +jconfig.mc6 already includes #define USE_SETMODE to make this work. +(fdopen does not work correctly.) + +Note that this makefile assumes that the working copy of itself is called +"makefile". If you want to call it something else, say "makefile.mak", +be sure to adjust the dependency line that reads "$(RFILE) : makefile". +Otherwise the make will fail because it doesn't know how to create "makefile". +Worse, some releases of Microsoft's make utilities give an incorrect error +message in this situation. + +Old versions of MS C fail with an "out of macro expansion space" error +because they can't cope with the macro TRACEMS8 (defined in jerror.h). +If this happens to you, the easiest solution is to change TRACEMS8 to +expand to nothing. You'll lose the ability to dump out JPEG coefficient +tables with djpeg -debug -debug, but at least you can compile. + +Original MS C 6.0 is very buggy; it compiles incorrect code unless you turn +off optimization entirely (remove -O from CFLAGS). 6.00A is better, but it +still generates bad code if you enable loop optimizations (-Ol or -Ox). + +MS C 8.0 crashes when compiling jquant1.c with optimization switch /Oo ... +which is on by default. To work around this bug, compile that one file +with /Oo-. + + +Microsoft Windows (all versions), generic comments: + +Some Windows system include files define typedef boolean as "unsigned char". +The IJG code also defines typedef boolean, but we make it "int" by default. +This doesn't affect the IJG programs because we don't import those Windows +include files. But if you use the JPEG library in your own program, and some +of your program's files import one definition of boolean while some import the +other, you can get all sorts of mysterious problems. A good preventive step +is to make the IJG library use "unsigned char" for boolean. To do that, +add something like this to your jconfig.h file: + /* Define "boolean" as unsigned char, not int, per Windows custom */ + #ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ + typedef unsigned char boolean; + #endif + #define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ +(This is already in jconfig.vc, by the way.) + +windef.h contains the declarations + #define far + #define FAR far +Since jmorecfg.h tries to define FAR as empty, you may get a compiler +warning if you include both jpeglib.h and windef.h (which windows.h +includes). To suppress the warning, you can put "#ifndef FAR"/"#endif" +around the line "#define FAR" in jmorecfg.h. +(Something like this is already in jmorecfg.h, by the way.) + +When using the library in a Windows application, you will almost certainly +want to modify or replace the error handler module jerror.c, since our +default error handler does a couple of inappropriate things: + 1. it tries to write error and warning messages on stderr; + 2. in event of a fatal error, it exits by calling exit(). + +A simple stopgap solution for problem 1 is to replace the line + fprintf(stderr, "%s\n", buffer); +(in output_message in jerror.c) with + MessageBox(GetActiveWindow(),buffer,"JPEG Error",MB_OK|MB_ICONERROR); +It's highly recommended that you at least do that much, since otherwise +error messages will disappear into nowhere. (Beginning with IJG v6b, this +code is already present in jerror.c; just define USE_WINDOWS_MESSAGEBOX in +jconfig.h to enable it.) + +The proper solution for problem 2 is to return control to your calling +application after a library error. This can be done with the setjmp/longjmp +technique discussed in libjpeg.txt and illustrated in example.c. (NOTE: +some older Windows C compilers provide versions of setjmp/longjmp that +don't actually work under Windows. You may need to use the Windows system +functions Catch and Throw instead.) + +The recommended memory manager under Windows is jmemnobs.c; in other words, +let Windows do any virtual memory management needed. You should NOT use +jmemdos.c nor jmemdosa.asm under Windows. + +For Windows 3.1, we recommend compiling in medium or large memory model; +for newer Windows versions, use a 32-bit flat memory model. (See the MS-DOS +sections above for more info about memory models.) In the 16-bit memory +models only, you'll need to put + #define MAX_ALLOC_CHUNK 65520L /* Maximum request to malloc() */ +into jconfig.h to limit allocation chunks to 64Kb. (Without that, you'd +have to use huge memory model, which slows things down unnecessarily.) +jmemnobs.c works without modification in large or flat memory models, but to +use medium model, you need to modify its jpeg_get_large and jpeg_free_large +routines to allocate far memory. In any case, you might like to replace +its calls to malloc and free with direct calls on Windows memory allocation +functions. + +You may also want to modify jdatasrc.c and jdatadst.c to use Windows file +operations rather than fread/fwrite. This is only necessary if your C +compiler doesn't provide a competent implementation of C stdio functions. + +You might want to tweak the RGB_xxx macros in jmorecfg.h so that the library +will accept or deliver color pixels in BGR sample order, not RGB; BGR order +is usually more convenient under Windows. Note that this change will break +the sample applications cjpeg/djpeg, but the library itself works fine. + + +Many people want to convert the IJG library into a DLL. This is reasonably +straightforward, but watch out for the following: + + 1. Don't try to compile as a DLL in small or medium memory model; use +large model, or even better, 32-bit flat model. Many places in the IJG code +assume the address of a local variable is an ordinary (not FAR) pointer; +that isn't true in a medium-model DLL. + + 2. Microsoft C cannot pass file pointers between applications and DLLs. +(See Microsoft Knowledge Base, PSS ID Number Q50336.) So jdatasrc.c and +jdatadst.c don't work if you open a file in your application and then pass +the pointer to the DLL. One workaround is to make jdatasrc.c/jdatadst.c +part of your main application rather than part of the DLL. + + 3. You'll probably need to modify the macros GLOBAL() and EXTERN() to +attach suitable linkage keywords to the exported routine names. Similarly, +you'll want to modify METHODDEF() and JMETHOD() to ensure function pointers +are declared in a way that lets application routines be called back through +the function pointers. These macros are in jmorecfg.h. Typical definitions +for a 16-bit DLL are: + #define GLOBAL(type) type _far _pascal _loadds _export + #define EXTERN(type) extern type _far _pascal _loadds + #define METHODDEF(type) static type _far _pascal + #define JMETHOD(type,methodname,arglist) \ + type (_far _pascal *methodname) arglist +For a 32-bit DLL you may want something like + #define GLOBAL(type) __declspec(dllexport) type + #define EXTERN(type) extern __declspec(dllexport) type +Although not all the GLOBAL routines are actually intended to be called by +the application, the performance cost of making them all DLL entry points is +negligible. + +The unmodified IJG library presents a very C-specific application interface, +so the resulting DLL is only usable from C or C++ applications. There has +been some talk of writing wrapper code that would present a simpler interface +usable from other languages, such as Visual Basic. This is on our to-do list +but hasn't been very high priority --- any volunteers out there? + + +Microsoft Windows, Borland C: + +The provided jconfig.bcc should work OK in a 32-bit Windows environment, +but you'll need to tweak it in a 16-bit environment (you'd need to define +NEED_FAR_POINTERS and MAX_ALLOC_CHUNK). Beware that makefile.bcc will need +alteration if you want to use it for Windows --- in particular, you should +use jmemnobs.c not jmemdos.c under Windows. + +Borland C++ 4.5 fails with an internal compiler error when trying to compile +jdmerge.c in 32-bit mode. If enough people complain, perhaps Borland will fix +it. In the meantime, the simplest known workaround is to add a redundant +definition of the variable range_limit in h2v1_merged_upsample(), at the head +of the block that handles odd image width (about line 268 in v6 jdmerge.c): + /* If image width is odd, do the last output column separately */ + if (cinfo->output_width & 1) { + register JSAMPLE * range_limit = cinfo->sample_range_limit; /* ADD THIS */ + cb = GETJSAMPLE(*inptr1); +Pretty bizarre, especially since the very similar routine h2v2_merged_upsample +doesn't trigger the bug. +Recent reports suggest that this bug does not occur with "bcc32a" (the +Pentium-optimized version of the compiler). + +Another report from a user of Borland C 4.5 was that incorrect code (leading +to a color shift in processed images) was produced if any of the following +optimization switch combinations were used: + -Ot -Og + -Ot -Op + -Ot -Om +So try backing off on optimization if you see such a problem. (Are there +several different releases all numbered "4.5"??) + + +Microsoft Windows, Microsoft Visual C++: + +jconfig.vc should work OK with any Microsoft compiler for a 32-bit memory +model. makefile.vc is intended for command-line use. (If you are using +the Developer Studio environment, you may prefer the DevStudio project +files; see below.) + +IJG JPEG 7 adds extern "C" to jpeglib.h. This avoids the need to put +extern "C" { ... } around #include "jpeglib.h" in your C++ application. +You can also force VC++ to treat the library as C++ code by renaming +all the *.c files to *.cpp (and adjusting the makefile to match). +In this case you also need to define the symbol DONT_USE_EXTERN_C in +the configuration to prevent jpeglib.h from using extern "C". + + +Microsoft Windows, Microsoft Visual C++ 6 Developer Studio: + +We include makefiles that should work as project files in DevStudio 6.0 or +later. There is a library makefile that builds the IJG library as a static +Win32 library, and application makefiles that build the sample applications +as Win32 console applications. (Even if you only want the library, we +recommend building the applications so that you can run the self-test.) + +To use: +1. Open the command prompt, change to the main directory and execute the + command line + NMAKE /f makefile.vc setup-vc6 + This will move jconfig.vc to jconfig.h and makefiles to project files. + (Note that the renaming is critical!) +2. Open the workspace file jpeg.dsw, build the library project. + (If you are using DevStudio more recent than 6.0, you'll probably + get a message saying that the project files are being updated.) +3. Open the workspace file apps.dsw, build the application projects. +4. To perform the self-test, execute the command line + NMAKE /f makefile.vc test-build +5. Move the application .exe files from `app`\Release to an + appropriate location on your path. + + +Microsoft Windows, Microsoft Visual C++ 2010 Developer Studio (v10): + +We include makefiles that should work as project files in Visual Studio +2010 or later. There is a library makefile that builds the IJG library +as a static Win32 library, and application makefiles that build the sample +applications as Win32 console applications. (Even if you only want the +library, we recommend building the applications so that you can run the +self-test.) + +To use: +1. Open the command prompt, change to the main directory and execute the + command line + NMAKE /f makefile.vc setup-v10 + This will move jconfig.vc to jconfig.h and makefiles to project files. + (Note that the renaming is critical!) +2. Open the solution file jpeg.sln, build the library project. + (If you are using Visual Studio more recent than 2010 (v10), you'll + probably get a message saying that the project files are being updated.) +3. Open the solution file apps.sln, build the application projects. +4. To perform the self-test, execute the command line + NMAKE /f makefile.vc test-build +5. Move the application .exe files from `app`\Release to an + appropriate location on your path. + +Note: +There seems to be an optimization bug in the compiler which causes the +self-test to fail with the color quantization option. +We have disabled optimization for the file jquant2.c in the library +project file which causes the self-test to pass properly. + + +OS/2, Borland C++: + +Watch out for optimization bugs in older Borland compilers; you may need +to back off the optimization switch settings. See the comments in +makefile.bcc. + + +SGI: + +On some SGI systems, you may need to set "AR2= ar -ts" in the Makefile. +If you are using configure, you can do this by saying + ./configure RANLIB='ar -ts' +This change is not needed on all SGIs. Use it only if the make fails at the +stage of linking the completed programs. + +On the MIPS R4000 architecture (Indy, etc.), the compiler option "-mips2" +reportedly speeds up the float DCT method substantially, enough to make it +faster than the default int method (but still slower than the fast int +method). If you use -mips2, you may want to alter the default DCT method to +be float. To do this, put "#define JDCT_DEFAULT JDCT_FLOAT" in jconfig.h. + + +VMS: + +On an Alpha/VMS system with MMS, be sure to use the "/Marco=Alpha=1" +qualifier with MMS when building the JPEG package. + +VAX/VMS v5.5-1 may have problems with the test step of the build procedure +reporting differences when it compares the original and test images. If the +error points to the last block of the files, it is most likely bogus and may +be safely ignored. It seems to be because the files are Stream_LF and +Backup/Compare has difficulty with the (presumably) null padded files. +This problem was not observed on VAX/VMS v6.1 or AXP/VMS v6.1. diff --git a/plugins/AdvaImg/src/LibJPEG/jcparam.c b/plugins/AdvaImg/src/LibJPEG/jcparam.c index 1c81d2ec59..c5e85dda55 100644 --- a/plugins/AdvaImg/src/LibJPEG/jcparam.c +++ b/plugins/AdvaImg/src/LibJPEG/jcparam.c @@ -422,7 +422,7 @@ jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace) compptr->v_samp_factor = (vsamp), \ compptr->quant_tbl_no = (quant), \ compptr->dc_tbl_no = (dctbl), \ - compptr->ac_tbl_no = (actbl)) + compptr->ac_tbl_no = (actbl) ) /* Safety check to ensure start_compress not called yet. */ if (cinfo->global_state != CSTATE_START) diff --git a/plugins/AdvaImg/src/LibJPEG/libjpeg.txt b/plugins/AdvaImg/src/LibJPEG/libjpeg.txt new file mode 100644 index 0000000000..98394c8e18 --- /dev/null +++ b/plugins/AdvaImg/src/LibJPEG/libjpeg.txt @@ -0,0 +1,3085 @@ +USING THE IJG JPEG LIBRARY + +Copyright (C) 1994-2011, Thomas G. Lane, Guido Vollbeding. +This file is part of the Independent JPEG Group's software. +For conditions of distribution and use, see the accompanying README file. + + +This file describes how to use the IJG JPEG library within an application +program. Read it if you want to write a program that uses the library. + +The file example.c provides heavily commented skeleton code for calling the +JPEG library. Also see jpeglib.h (the include file to be used by application +programs) for full details about data structures and function parameter lists. +The library source code, of course, is the ultimate reference. + +Note that there have been *major* changes from the application interface +presented by IJG version 4 and earlier versions. The old design had several +inherent limitations, and it had accumulated a lot of cruft as we added +features while trying to minimize application-interface changes. We have +sacrificed backward compatibility in the version 5 rewrite, but we think the +improvements justify this. + + +TABLE OF CONTENTS +----------------- + +Overview: + Functions provided by the library + Outline of typical usage +Basic library usage: + Data formats + Compression details + Decompression details + Mechanics of usage: include files, linking, etc +Advanced features: + Compression parameter selection + Decompression parameter selection + Special color spaces + Error handling + Compressed data handling (source and destination managers) + I/O suspension + Progressive JPEG support + Buffered-image mode + Abbreviated datastreams and multiple images + Special markers + Raw (downsampled) image data + Really raw data: DCT coefficients + Progress monitoring + Memory management + Memory usage + Library compile-time options + Portability considerations + Notes for MS-DOS implementors + +You should read at least the overview and basic usage sections before trying +to program with the library. The sections on advanced features can be read +if and when you need them. + + +OVERVIEW +======== + +Functions provided by the library +--------------------------------- + +The IJG JPEG library provides C code to read and write JPEG-compressed image +files. The surrounding application program receives or supplies image data a +scanline at a time, using a straightforward uncompressed image format. All +details of color conversion and other preprocessing/postprocessing can be +handled by the library. + +The library includes a substantial amount of code that is not covered by the +JPEG standard but is necessary for typical applications of JPEG. These +functions preprocess the image before JPEG compression or postprocess it after +decompression. They include colorspace conversion, downsampling/upsampling, +and color quantization. The application indirectly selects use of this code +by specifying the format in which it wishes to supply or receive image data. +For example, if colormapped output is requested, then the decompression +library automatically invokes color quantization. + +A wide range of quality vs. speed tradeoffs are possible in JPEG processing, +and even more so in decompression postprocessing. The decompression library +provides multiple implementations that cover most of the useful tradeoffs, +ranging from very-high-quality down to fast-preview operation. On the +compression side we have generally not provided low-quality choices, since +compression is normally less time-critical. It should be understood that the +low-quality modes may not meet the JPEG standard's accuracy requirements; +nonetheless, they are useful for viewers. + +A word about functions *not* provided by the library. We handle a subset of +the ISO JPEG standard; most baseline, extended-sequential, and progressive +JPEG processes are supported. (Our subset includes all features now in common +use.) Unsupported ISO options include: + * Hierarchical storage + * Lossless JPEG + * DNL marker + * Nonintegral subsampling ratios +We support both 8- and 12-bit data precision, but this is a compile-time +choice rather than a run-time choice; hence it is difficult to use both +precisions in a single application. + +By itself, the library handles only interchange JPEG datastreams --- in +particular the widely used JFIF file format. The library can be used by +surrounding code to process interchange or abbreviated JPEG datastreams that +are embedded in more complex file formats. (For example, this library is +used by the free LIBTIFF library to support JPEG compression in TIFF.) + + +Outline of typical usage +------------------------ + +The rough outline of a JPEG compression operation is: + + Allocate and initialize a JPEG compression object + Specify the destination for the compressed data (eg, a file) + Set parameters for compression, including image size & colorspace + jpeg_start_compress(...); + while (scan lines remain to be written) + jpeg_write_scanlines(...); + jpeg_finish_compress(...); + Release the JPEG compression object + +A JPEG compression object holds parameters and working state for the JPEG +library. We make creation/destruction of the object separate from starting +or finishing compression of an image; the same object can be re-used for a +series of image compression operations. This makes it easy to re-use the +same parameter settings for a sequence of images. Re-use of a JPEG object +also has important implications for processing abbreviated JPEG datastreams, +as discussed later. + +The image data to be compressed is supplied to jpeg_write_scanlines() from +in-memory buffers. If the application is doing file-to-file compression, +reading image data from the source file is the application's responsibility. +The library emits compressed data by calling a "data destination manager", +which typically will write the data into a file; but the application can +provide its own destination manager to do something else. + +Similarly, the rough outline of a JPEG decompression operation is: + + Allocate and initialize a JPEG decompression object + Specify the source of the compressed data (eg, a file) + Call jpeg_read_header() to obtain image info + Set parameters for decompression + jpeg_start_decompress(...); + while (scan lines remain to be read) + jpeg_read_scanlines(...); + jpeg_finish_decompress(...); + Release the JPEG decompression object + +This is comparable to the compression outline except that reading the +datastream header is a separate step. This is helpful because information +about the image's size, colorspace, etc is available when the application +selects decompression parameters. For example, the application can choose an +output scaling ratio that will fit the image into the available screen size. + +The decompression library obtains compressed data by calling a data source +manager, which typically will read the data from a file; but other behaviors +can be obtained with a custom source manager. Decompressed data is delivered +into in-memory buffers passed to jpeg_read_scanlines(). + +It is possible to abort an incomplete compression or decompression operation +by calling jpeg_abort(); or, if you do not need to retain the JPEG object, +simply release it by calling jpeg_destroy(). + +JPEG compression and decompression objects are two separate struct types. +However, they share some common fields, and certain routines such as +jpeg_destroy() can work on either type of object. + +The JPEG library has no static variables: all state is in the compression +or decompression object. Therefore it is possible to process multiple +compression and decompression operations concurrently, using multiple JPEG +objects. + +Both compression and decompression can be done in an incremental memory-to- +memory fashion, if suitable source/destination managers are used. See the +section on "I/O suspension" for more details. + + +BASIC LIBRARY USAGE +=================== + +Data formats +------------ + +Before diving into procedural details, it is helpful to understand the +image data format that the JPEG library expects or returns. + +The standard input image format is a rectangular array of pixels, with each +pixel having the same number of "component" or "sample" values (color +channels). You must specify how many components there are and the colorspace +interpretation of the components. Most applications will use RGB data +(three components per pixel) or grayscale data (one component per pixel). +PLEASE NOTE THAT RGB DATA IS THREE SAMPLES PER PIXEL, GRAYSCALE ONLY ONE. +A remarkable number of people manage to miss this, only to find that their +programs don't work with grayscale JPEG files. + +There is no provision for colormapped input. JPEG files are always full-color +or full grayscale (or sometimes another colorspace such as CMYK). You can +feed in a colormapped image by expanding it to full-color format. However +JPEG often doesn't work very well with source data that has been colormapped, +because of dithering noise. This is discussed in more detail in the JPEG FAQ +and the other references mentioned in the README file. + +Pixels are stored by scanlines, with each scanline running from left to +right. The component values for each pixel are adjacent in the row; for +example, R,G,B,R,G,B,R,G,B,... for 24-bit RGB color. Each scanline is an +array of data type JSAMPLE --- which is typically "unsigned char", unless +you've changed jmorecfg.h. (You can also change the RGB pixel layout, say +to B,G,R order, by modifying jmorecfg.h. But see the restrictions listed in +that file before doing so.) + +A 2-D array of pixels is formed by making a list of pointers to the starts of +scanlines; so the scanlines need not be physically adjacent in memory. Even +if you process just one scanline at a time, you must make a one-element +pointer array to conform to this structure. Pointers to JSAMPLE rows are of +type JSAMPROW, and the pointer to the pointer array is of type JSAMPARRAY. + +The library accepts or supplies one or more complete scanlines per call. +It is not possible to process part of a row at a time. Scanlines are always +processed top-to-bottom. You can process an entire image in one call if you +have it all in memory, but usually it's simplest to process one scanline at +a time. + +For best results, source data values should have the precision specified by +BITS_IN_JSAMPLE (normally 8 bits). For instance, if you choose to compress +data that's only 6 bits/channel, you should left-justify each value in a +byte before passing it to the compressor. If you need to compress data +that has more than 8 bits/channel, compile with BITS_IN_JSAMPLE = 12. +(See "Library compile-time options", later.) + + +The data format returned by the decompressor is the same in all details, +except that colormapped output is supported. (Again, a JPEG file is never +colormapped. But you can ask the decompressor to perform on-the-fly color +quantization to deliver colormapped output.) If you request colormapped +output then the returned data array contains a single JSAMPLE per pixel; +its value is an index into a color map. The color map is represented as +a 2-D JSAMPARRAY in which each row holds the values of one color component, +that is, colormap[i][j] is the value of the i'th color component for pixel +value (map index) j. Note that since the colormap indexes are stored in +JSAMPLEs, the maximum number of colors is limited by the size of JSAMPLE +(ie, at most 256 colors for an 8-bit JPEG library). + + +Compression details +------------------- + +Here we revisit the JPEG compression outline given in the overview. + +1. Allocate and initialize a JPEG compression object. + +A JPEG compression object is a "struct jpeg_compress_struct". (It also has +a bunch of subsidiary structures which are allocated via malloc(), but the +application doesn't control those directly.) This struct can be just a local +variable in the calling routine, if a single routine is going to execute the +whole JPEG compression sequence. Otherwise it can be static or allocated +from malloc(). + +You will also need a structure representing a JPEG error handler. The part +of this that the library cares about is a "struct jpeg_error_mgr". If you +are providing your own error handler, you'll typically want to embed the +jpeg_error_mgr struct in a larger structure; this is discussed later under +"Error handling". For now we'll assume you are just using the default error +handler. The default error handler will print JPEG error/warning messages +on stderr, and it will call exit() if a fatal error occurs. + +You must initialize the error handler structure, store a pointer to it into +the JPEG object's "err" field, and then call jpeg_create_compress() to +initialize the rest of the JPEG object. + +Typical code for this step, if you are using the default error handler, is + + struct jpeg_compress_struct cinfo; + struct jpeg_error_mgr jerr; + ... + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_compress(&cinfo); + +jpeg_create_compress allocates a small amount of memory, so it could fail +if you are out of memory. In that case it will exit via the error handler; +that's why the error handler must be initialized first. + + +2. Specify the destination for the compressed data (eg, a file). + +As previously mentioned, the JPEG library delivers compressed data to a +"data destination" module. The library includes one data destination +module which knows how to write to a stdio stream. You can use your own +destination module if you want to do something else, as discussed later. + +If you use the standard destination module, you must open the target stdio +stream beforehand. Typical code for this step looks like: + + FILE * outfile; + ... + if ((outfile = fopen(filename, "wb")) == NULL) { + fprintf(stderr, "can't open %s\n", filename); + exit(1); + } + jpeg_stdio_dest(&cinfo, outfile); + +where the last line invokes the standard destination module. + +WARNING: it is critical that the binary compressed data be delivered to the +output file unchanged. On non-Unix systems the stdio library may perform +newline translation or otherwise corrupt binary data. To suppress this +behavior, you may need to use a "b" option to fopen (as shown above), or use +setmode() or another routine to put the stdio stream in binary mode. See +cjpeg.c and djpeg.c for code that has been found to work on many systems. + +You can select the data destination after setting other parameters (step 3), +if that's more convenient. You may not change the destination between +calling jpeg_start_compress() and jpeg_finish_compress(). + + +3. Set parameters for compression, including image size & colorspace. + +You must supply information about the source image by setting the following +fields in the JPEG object (cinfo structure): + + image_width Width of image, in pixels + image_height Height of image, in pixels + input_components Number of color channels (samples per pixel) + in_color_space Color space of source image + +The image dimensions are, hopefully, obvious. JPEG supports image dimensions +of 1 to 64K pixels in either direction. The input color space is typically +RGB or grayscale, and input_components is 3 or 1 accordingly. (See "Special +color spaces", later, for more info.) The in_color_space field must be +assigned one of the J_COLOR_SPACE enum constants, typically JCS_RGB or +JCS_GRAYSCALE. + +JPEG has a large number of compression parameters that determine how the +image is encoded. Most applications don't need or want to know about all +these parameters. You can set all the parameters to reasonable defaults by +calling jpeg_set_defaults(); then, if there are particular values you want +to change, you can do so after that. The "Compression parameter selection" +section tells about all the parameters. + +You must set in_color_space correctly before calling jpeg_set_defaults(), +because the defaults depend on the source image colorspace. However the +other three source image parameters need not be valid until you call +jpeg_start_compress(). There's no harm in calling jpeg_set_defaults() more +than once, if that happens to be convenient. + +Typical code for a 24-bit RGB source image is + + cinfo.image_width = Width; /* image width and height, in pixels */ + cinfo.image_height = Height; + cinfo.input_components = 3; /* # of color components per pixel */ + cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ + + jpeg_set_defaults(&cinfo); + /* Make optional parameter settings here */ + + +4. jpeg_start_compress(...); + +After you have established the data destination and set all the necessary +source image info and other parameters, call jpeg_start_compress() to begin +a compression cycle. This will initialize internal state, allocate working +storage, and emit the first few bytes of the JPEG datastream header. + +Typical code: + + jpeg_start_compress(&cinfo, TRUE); + +The "TRUE" parameter ensures that a complete JPEG interchange datastream +will be written. This is appropriate in most cases. If you think you might +want to use an abbreviated datastream, read the section on abbreviated +datastreams, below. + +Once you have called jpeg_start_compress(), you may not alter any JPEG +parameters or other fields of the JPEG object until you have completed +the compression cycle. + + +5. while (scan lines remain to be written) + jpeg_write_scanlines(...); + +Now write all the required image data by calling jpeg_write_scanlines() +one or more times. You can pass one or more scanlines in each call, up +to the total image height. In most applications it is convenient to pass +just one or a few scanlines at a time. The expected format for the passed +data is discussed under "Data formats", above. + +Image data should be written in top-to-bottom scanline order. The JPEG spec +contains some weasel wording about how top and bottom are application-defined +terms (a curious interpretation of the English language...) but if you want +your files to be compatible with everyone else's, you WILL use top-to-bottom +order. If the source data must be read in bottom-to-top order, you can use +the JPEG library's virtual array mechanism to invert the data efficiently. +Examples of this can be found in the sample application cjpeg. + +The library maintains a count of the number of scanlines written so far +in the next_scanline field of the JPEG object. Usually you can just use +this variable as the loop counter, so that the loop test looks like +"while (cinfo.next_scanline < cinfo.image_height)". + +Code for this step depends heavily on the way that you store the source data. +example.c shows the following code for the case of a full-size 2-D source +array containing 3-byte RGB pixels: + + JSAMPROW row_pointer[1]; /* pointer to a single row */ + int row_stride; /* physical row width in buffer */ + + row_stride = image_width * 3; /* JSAMPLEs per row in image_buffer */ + + while (cinfo.next_scanline < cinfo.image_height) { + row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride]; + jpeg_write_scanlines(&cinfo, row_pointer, 1); + } + +jpeg_write_scanlines() returns the number of scanlines actually written. +This will normally be equal to the number passed in, so you can usually +ignore the return value. It is different in just two cases: + * If you try to write more scanlines than the declared image height, + the additional scanlines are ignored. + * If you use a suspending data destination manager, output buffer overrun + will cause the compressor to return before accepting all the passed lines. + This feature is discussed under "I/O suspension", below. The normal + stdio destination manager will NOT cause this to happen. +In any case, the return value is the same as the change in the value of +next_scanline. + + +6. jpeg_finish_compress(...); + +After all the image data has been written, call jpeg_finish_compress() to +complete the compression cycle. This step is ESSENTIAL to ensure that the +last bufferload of data is written to the data destination. +jpeg_finish_compress() also releases working memory associated with the JPEG +object. + +Typical code: + + jpeg_finish_compress(&cinfo); + +If using the stdio destination manager, don't forget to close the output +stdio stream (if necessary) afterwards. + +If you have requested a multi-pass operating mode, such as Huffman code +optimization, jpeg_finish_compress() will perform the additional passes using +data buffered by the first pass. In this case jpeg_finish_compress() may take +quite a while to complete. With the default compression parameters, this will +not happen. + +It is an error to call jpeg_finish_compress() before writing the necessary +total number of scanlines. If you wish to abort compression, call +jpeg_abort() as discussed below. + +After completing a compression cycle, you may dispose of the JPEG object +as discussed next, or you may use it to compress another image. In that case +return to step 2, 3, or 4 as appropriate. If you do not change the +destination manager, the new datastream will be written to the same target. +If you do not change any JPEG parameters, the new datastream will be written +with the same parameters as before. Note that you can change the input image +dimensions freely between cycles, but if you change the input colorspace, you +should call jpeg_set_defaults() to adjust for the new colorspace; and then +you'll need to repeat all of step 3. + + +7. Release the JPEG compression object. + +When you are done with a JPEG compression object, destroy it by calling +jpeg_destroy_compress(). This will free all subsidiary memory (regardless of +the previous state of the object). Or you can call jpeg_destroy(), which +works for either compression or decompression objects --- this may be more +convenient if you are sharing code between compression and decompression +cases. (Actually, these routines are equivalent except for the declared type +of the passed pointer. To avoid gripes from ANSI C compilers, jpeg_destroy() +should be passed a j_common_ptr.) + +If you allocated the jpeg_compress_struct structure from malloc(), freeing +it is your responsibility --- jpeg_destroy() won't. Ditto for the error +handler structure. + +Typical code: + + jpeg_destroy_compress(&cinfo); + + +8. Aborting. + +If you decide to abort a compression cycle before finishing, you can clean up +in either of two ways: + +* If you don't need the JPEG object any more, just call + jpeg_destroy_compress() or jpeg_destroy() to release memory. This is + legitimate at any point after calling jpeg_create_compress() --- in fact, + it's safe even if jpeg_create_compress() fails. + +* If you want to re-use the JPEG object, call jpeg_abort_compress(), or call + jpeg_abort() which works on both compression and decompression objects. + This will return the object to an idle state, releasing any working memory. + jpeg_abort() is allowed at any time after successful object creation. + +Note that cleaning up the data destination, if required, is your +responsibility; neither of these routines will call term_destination(). +(See "Compressed data handling", below, for more about that.) + +jpeg_destroy() and jpeg_abort() are the only safe calls to make on a JPEG +object that has reported an error by calling error_exit (see "Error handling" +for more info). The internal state of such an object is likely to be out of +whack. Either of these two routines will return the object to a known state. + + +Decompression details +--------------------- + +Here we revisit the JPEG decompression outline given in the overview. + +1. Allocate and initialize a JPEG decompression object. + +This is just like initialization for compression, as discussed above, +except that the object is a "struct jpeg_decompress_struct" and you +call jpeg_create_decompress(). Error handling is exactly the same. + +Typical code: + + struct jpeg_decompress_struct cinfo; + struct jpeg_error_mgr jerr; + ... + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_decompress(&cinfo); + +(Both here and in the IJG code, we usually use variable name "cinfo" for +both compression and decompression objects.) + + +2. Specify the source of the compressed data (eg, a file). + +As previously mentioned, the JPEG library reads compressed data from a "data +source" module. The library includes one data source module which knows how +to read from a stdio stream. You can use your own source module if you want +to do something else, as discussed later. + +If you use the standard source module, you must open the source stdio stream +beforehand. Typical code for this step looks like: + + FILE * infile; + ... + if ((infile = fopen(filename, "rb")) == NULL) { + fprintf(stderr, "can't open %s\n", filename); + exit(1); + } + jpeg_stdio_src(&cinfo, infile); + +where the last line invokes the standard source module. + +WARNING: it is critical that the binary compressed data be read unchanged. +On non-Unix systems the stdio library may perform newline translation or +otherwise corrupt binary data. To suppress this behavior, you may need to use +a "b" option to fopen (as shown above), or use setmode() or another routine to +put the stdio stream in binary mode. See cjpeg.c and djpeg.c for code that +has been found to work on many systems. + +You may not change the data source between calling jpeg_read_header() and +jpeg_finish_decompress(). If you wish to read a series of JPEG images from +a single source file, you should repeat the jpeg_read_header() to +jpeg_finish_decompress() sequence without reinitializing either the JPEG +object or the data source module; this prevents buffered input data from +being discarded. + + +3. Call jpeg_read_header() to obtain image info. + +Typical code for this step is just + + jpeg_read_header(&cinfo, TRUE); + +This will read the source datastream header markers, up to the beginning +of the compressed data proper. On return, the image dimensions and other +info have been stored in the JPEG object. The application may wish to +consult this information before selecting decompression parameters. + +More complex code is necessary if + * A suspending data source is used --- in that case jpeg_read_header() + may return before it has read all the header data. See "I/O suspension", + below. The normal stdio source manager will NOT cause this to happen. + * Abbreviated JPEG files are to be processed --- see the section on + abbreviated datastreams. Standard applications that deal only in + interchange JPEG files need not be concerned with this case either. + +It is permissible to stop at this point if you just wanted to find out the +image dimensions and other header info for a JPEG file. In that case, +call jpeg_destroy() when you are done with the JPEG object, or call +jpeg_abort() to return it to an idle state before selecting a new data +source and reading another header. + + +4. Set parameters for decompression. + +jpeg_read_header() sets appropriate default decompression parameters based on +the properties of the image (in particular, its colorspace). However, you +may well want to alter these defaults before beginning the decompression. +For example, the default is to produce full color output from a color file. +If you want colormapped output you must ask for it. Other options allow the +returned image to be scaled and allow various speed/quality tradeoffs to be +selected. "Decompression parameter selection", below, gives details. + +If the defaults are appropriate, nothing need be done at this step. + +Note that all default values are set by each call to jpeg_read_header(). +If you reuse a decompression object, you cannot expect your parameter +settings to be preserved across cycles, as you can for compression. +You must set desired parameter values each time. + + +5. jpeg_start_decompress(...); + +Once the parameter values are satisfactory, call jpeg_start_decompress() to +begin decompression. This will initialize internal state, allocate working +memory, and prepare for returning data. + +Typical code is just + + jpeg_start_decompress(&cinfo); + +If you have requested a multi-pass operating mode, such as 2-pass color +quantization, jpeg_start_decompress() will do everything needed before data +output can begin. In this case jpeg_start_decompress() may take quite a while +to complete. With a single-scan (non progressive) JPEG file and default +decompression parameters, this will not happen; jpeg_start_decompress() will +return quickly. + +After this call, the final output image dimensions, including any requested +scaling, are available in the JPEG object; so is the selected colormap, if +colormapped output has been requested. Useful fields include + + output_width image width and height, as scaled + output_height + out_color_components # of color components in out_color_space + output_components # of color components returned per pixel + colormap the selected colormap, if any + actual_number_of_colors number of entries in colormap + +output_components is 1 (a colormap index) when quantizing colors; otherwise it +equals out_color_components. It is the number of JSAMPLE values that will be +emitted per pixel in the output arrays. + +Typically you will need to allocate data buffers to hold the incoming image. +You will need output_width * output_components JSAMPLEs per scanline in your +output buffer, and a total of output_height scanlines will be returned. + +Note: if you are using the JPEG library's internal memory manager to allocate +data buffers (as djpeg does), then the manager's protocol requires that you +request large buffers *before* calling jpeg_start_decompress(). This is a +little tricky since the output_XXX fields are not normally valid then. You +can make them valid by calling jpeg_calc_output_dimensions() after setting the +relevant parameters (scaling, output color space, and quantization flag). + + +6. while (scan lines remain to be read) + jpeg_read_scanlines(...); + +Now you can read the decompressed image data by calling jpeg_read_scanlines() +one or more times. At each call, you pass in the maximum number of scanlines +to be read (ie, the height of your working buffer); jpeg_read_scanlines() +will return up to that many lines. The return value is the number of lines +actually read. The format of the returned data is discussed under "Data +formats", above. Don't forget that grayscale and color JPEGs will return +different data formats! + +Image data is returned in top-to-bottom scanline order. If you must write +out the image in bottom-to-top order, you can use the JPEG library's virtual +array mechanism to invert the data efficiently. Examples of this can be +found in the sample application djpeg. + +The library maintains a count of the number of scanlines returned so far +in the output_scanline field of the JPEG object. Usually you can just use +this variable as the loop counter, so that the loop test looks like +"while (cinfo.output_scanline < cinfo.output_height)". (Note that the test +should NOT be against image_height, unless you never use scaling. The +image_height field is the height of the original unscaled image.) +The return value always equals the change in the value of output_scanline. + +If you don't use a suspending data source, it is safe to assume that +jpeg_read_scanlines() reads at least one scanline per call, until the +bottom of the image has been reached. + +If you use a buffer larger than one scanline, it is NOT safe to assume that +jpeg_read_scanlines() fills it. (The current implementation returns only a +few scanlines per call, no matter how large a buffer you pass.) So you must +always provide a loop that calls jpeg_read_scanlines() repeatedly until the +whole image has been read. + + +7. jpeg_finish_decompress(...); + +After all the image data has been read, call jpeg_finish_decompress() to +complete the decompression cycle. This causes working memory associated +with the JPEG object to be released. + +Typical code: + + jpeg_finish_decompress(&cinfo); + +If using the stdio source manager, don't forget to close the source stdio +stream if necessary. + +It is an error to call jpeg_finish_decompress() before reading the correct +total number of scanlines. If you wish to abort decompression, call +jpeg_abort() as discussed below. + +After completing a decompression cycle, you may dispose of the JPEG object as +discussed next, or you may use it to decompress another image. In that case +return to step 2 or 3 as appropriate. If you do not change the source +manager, the next image will be read from the same source. + + +8. Release the JPEG decompression object. + +When you are done with a JPEG decompression object, destroy it by calling +jpeg_destroy_decompress() or jpeg_destroy(). The previous discussion of +destroying compression objects applies here too. + +Typical code: + + jpeg_destroy_decompress(&cinfo); + + +9. Aborting. + +You can abort a decompression cycle by calling jpeg_destroy_decompress() or +jpeg_destroy() if you don't need the JPEG object any more, or +jpeg_abort_decompress() or jpeg_abort() if you want to reuse the object. +The previous discussion of aborting compression cycles applies here too. + + +Mechanics of usage: include files, linking, etc +----------------------------------------------- + +Applications using the JPEG library should include the header file jpeglib.h +to obtain declarations of data types and routines. Before including +jpeglib.h, include system headers that define at least the typedefs FILE and +size_t. On ANSI-conforming systems, including is sufficient; on +older Unix systems, you may need to define size_t. + +If the application needs to refer to individual JPEG library error codes, also +include jerror.h to define those symbols. + +jpeglib.h indirectly includes the files jconfig.h and jmorecfg.h. If you are +installing the JPEG header files in a system directory, you will want to +install all four files: jpeglib.h, jerror.h, jconfig.h, jmorecfg.h. + +The most convenient way to include the JPEG code into your executable program +is to prepare a library file ("libjpeg.a", or a corresponding name on non-Unix +machines) and reference it at your link step. If you use only half of the +library (only compression or only decompression), only that much code will be +included from the library, unless your linker is hopelessly brain-damaged. +The supplied makefiles build libjpeg.a automatically (see install.txt). + +While you can build the JPEG library as a shared library if the whim strikes +you, we don't really recommend it. The trouble with shared libraries is that +at some point you'll probably try to substitute a new version of the library +without recompiling the calling applications. That generally doesn't work +because the parameter struct declarations usually change with each new +version. In other words, the library's API is *not* guaranteed binary +compatible across versions; we only try to ensure source-code compatibility. +(In hindsight, it might have been smarter to hide the parameter structs from +applications and introduce a ton of access functions instead. Too late now, +however.) + +On some systems your application may need to set up a signal handler to ensure +that temporary files are deleted if the program is interrupted. This is most +critical if you are on MS-DOS and use the jmemdos.c memory manager back end; +it will try to grab extended memory for temp files, and that space will NOT be +freed automatically. See cjpeg.c or djpeg.c for an example signal handler. + +It may be worth pointing out that the core JPEG library does not actually +require the stdio library: only the default source/destination managers and +error handler need it. You can use the library in a stdio-less environment +if you replace those modules and use jmemnobs.c (or another memory manager of +your own devising). More info about the minimum system library requirements +may be found in jinclude.h. + + +ADVANCED FEATURES +================= + +Compression parameter selection +------------------------------- + +This section describes all the optional parameters you can set for JPEG +compression, as well as the "helper" routines provided to assist in this +task. Proper setting of some parameters requires detailed understanding +of the JPEG standard; if you don't know what a parameter is for, it's best +not to mess with it! See REFERENCES in the README file for pointers to +more info about JPEG. + +It's a good idea to call jpeg_set_defaults() first, even if you plan to set +all the parameters; that way your code is more likely to work with future JPEG +libraries that have additional parameters. For the same reason, we recommend +you use a helper routine where one is provided, in preference to twiddling +cinfo fields directly. + +The helper routines are: + +jpeg_set_defaults (j_compress_ptr cinfo) + This routine sets all JPEG parameters to reasonable defaults, using + only the input image's color space (field in_color_space, which must + already be set in cinfo). Many applications will only need to use + this routine and perhaps jpeg_set_quality(). + +jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace) + Sets the JPEG file's colorspace (field jpeg_color_space) as specified, + and sets other color-space-dependent parameters appropriately. See + "Special color spaces", below, before using this. A large number of + parameters, including all per-component parameters, are set by this + routine; if you want to twiddle individual parameters you should call + jpeg_set_colorspace() before rather than after. + +jpeg_default_colorspace (j_compress_ptr cinfo) + Selects an appropriate JPEG colorspace based on cinfo->in_color_space, + and calls jpeg_set_colorspace(). This is actually a subroutine of + jpeg_set_defaults(). It's broken out in case you want to change + just the colorspace-dependent JPEG parameters. + +jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline) + Constructs JPEG quantization tables appropriate for the indicated + quality setting. The quality value is expressed on the 0..100 scale + recommended by IJG (cjpeg's "-quality" switch uses this routine). + Note that the exact mapping from quality values to tables may change + in future IJG releases as more is learned about DCT quantization. + If the force_baseline parameter is TRUE, then the quantization table + entries are constrained to the range 1..255 for full JPEG baseline + compatibility. In the current implementation, this only makes a + difference for quality settings below 25, and it effectively prevents + very small/low quality files from being generated. The IJG decoder + is capable of reading the non-baseline files generated at low quality + settings when force_baseline is FALSE, but other decoders may not be. + +jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor, + boolean force_baseline) + Same as jpeg_set_quality() except that the generated tables are the + sample tables given in the JPEC spec section K.1, multiplied by the + specified scale factor (which is expressed as a percentage; thus + scale_factor = 100 reproduces the spec's tables). Note that larger + scale factors give lower quality. This entry point is useful for + conforming to the Adobe PostScript DCT conventions, but we do not + recommend linear scaling as a user-visible quality scale otherwise. + force_baseline again constrains the computed table entries to 1..255. + +int jpeg_quality_scaling (int quality) + Converts a value on the IJG-recommended quality scale to a linear + scaling percentage. Note that this routine may change or go away + in future releases --- IJG may choose to adopt a scaling method that + can't be expressed as a simple scalar multiplier, in which case the + premise of this routine collapses. Caveat user. + +jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline) + Set default quantization tables with linear q_scale_factor[] values + (see below). + +jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl, + const unsigned int *basic_table, + int scale_factor, boolean force_baseline) + Allows an arbitrary quantization table to be created. which_tbl + indicates which table slot to fill. basic_table points to an array + of 64 unsigned ints given in normal array order. These values are + multiplied by scale_factor/100 and then clamped to the range 1..65535 + (or to 1..255 if force_baseline is TRUE). + CAUTION: prior to library version 6a, jpeg_add_quant_table expected + the basic table to be given in JPEG zigzag order. If you need to + write code that works with either older or newer versions of this + routine, you must check the library version number. Something like + "#if JPEG_LIB_VERSION >= 61" is the right test. + +jpeg_simple_progression (j_compress_ptr cinfo) + Generates a default scan script for writing a progressive-JPEG file. + This is the recommended method of creating a progressive file, + unless you want to make a custom scan sequence. You must ensure that + the JPEG color space is set correctly before calling this routine. + + +Compression parameters (cinfo fields) include: + +int block_size + Set DCT block size. All N from 1 to 16 are possible. + Default is 8 (baseline format). + Larger values produce higher compression, + smaller values produce higher quality. + An exact DCT stage is possible with 1 or 2. + With the default quality of 75 and default Luminance qtable + the DCT+Quantization stage is lossless for value 1. + Note that values other than 8 require a SmartScale capable decoder, + introduced with IJG JPEG 8. Setting the block_size parameter for + compression works with version 8c and later. + +J_DCT_METHOD dct_method + Selects the algorithm used for the DCT step. Choices are: + JDCT_ISLOW: slow but accurate integer algorithm + JDCT_IFAST: faster, less accurate integer method + JDCT_FLOAT: floating-point method + JDCT_DEFAULT: default method (normally JDCT_ISLOW) + JDCT_FASTEST: fastest method (normally JDCT_IFAST) + The FLOAT method is very slightly more accurate than the ISLOW method, + but may give different results on different machines due to varying + roundoff behavior. The integer methods should give the same results + on all machines. On machines with sufficiently fast FP hardware, the + floating-point method may also be the fastest. The IFAST method is + considerably less accurate than the other two; its use is not + recommended if high quality is a concern. JDCT_DEFAULT and + JDCT_FASTEST are macros configurable by each installation. + +unsigned int scale_num, scale_denom + Scale the image by the fraction scale_num/scale_denom. Default is + 1/1, or no scaling. Currently, the supported scaling ratios are + M/N with all N from 1 to 16, where M is the destination DCT size, + which is 8 by default (see block_size parameter above). + (The library design allows for arbitrary scaling ratios but this + is not likely to be implemented any time soon.) + +J_COLOR_SPACE jpeg_color_space +int num_components + The JPEG color space and corresponding number of components; see + "Special color spaces", below, for more info. We recommend using + jpeg_set_color_space() if you want to change these. + +boolean optimize_coding + TRUE causes the compressor to compute optimal Huffman coding tables + for the image. This requires an extra pass over the data and + therefore costs a good deal of space and time. The default is + FALSE, which tells the compressor to use the supplied or default + Huffman tables. In most cases optimal tables save only a few percent + of file size compared to the default tables. Note that when this is + TRUE, you need not supply Huffman tables at all, and any you do + supply will be overwritten. + +unsigned int restart_interval +int restart_in_rows + To emit restart markers in the JPEG file, set one of these nonzero. + Set restart_interval to specify the exact interval in MCU blocks. + Set restart_in_rows to specify the interval in MCU rows. (If + restart_in_rows is not 0, then restart_interval is set after the + image width in MCUs is computed.) Defaults are zero (no restarts). + One restart marker per MCU row is often a good choice. + NOTE: the overhead of restart markers is higher in grayscale JPEG + files than in color files, and MUCH higher in progressive JPEGs. + If you use restarts, you may want to use larger intervals in those + cases. + +const jpeg_scan_info * scan_info +int num_scans + By default, scan_info is NULL; this causes the compressor to write a + single-scan sequential JPEG file. If not NULL, scan_info points to + an array of scan definition records of length num_scans. The + compressor will then write a JPEG file having one scan for each scan + definition record. This is used to generate noninterleaved or + progressive JPEG files. The library checks that the scan array + defines a valid JPEG scan sequence. (jpeg_simple_progression creates + a suitable scan definition array for progressive JPEG.) This is + discussed further under "Progressive JPEG support". + +boolean do_fancy_downsampling + If TRUE, use direct DCT scaling with DCT size > 8 for downsampling + of chroma components. + If FALSE, use only DCT size <= 8 and simple separate downsampling. + Default is TRUE. + For better image stability in multiple generation compression cycles + it is preferable that this value matches the corresponding + do_fancy_upsampling value in decompression. + +int smoothing_factor + If non-zero, the input image is smoothed; the value should be 1 for + minimal smoothing to 100 for maximum smoothing. Consult jcsample.c + for details of the smoothing algorithm. The default is zero. + +boolean write_JFIF_header + If TRUE, a JFIF APP0 marker is emitted. jpeg_set_defaults() and + jpeg_set_colorspace() set this TRUE if a JFIF-legal JPEG color space + (ie, YCbCr or grayscale) is selected, otherwise FALSE. + +UINT8 JFIF_major_version +UINT8 JFIF_minor_version + The version number to be written into the JFIF marker. + jpeg_set_defaults() initializes the version to 1.01 (major=minor=1). + You should set it to 1.02 (major=1, minor=2) if you plan to write + any JFIF 1.02 extension markers. + +UINT8 density_unit +UINT16 X_density +UINT16 Y_density + The resolution information to be written into the JFIF marker; + not used otherwise. density_unit may be 0 for unknown, + 1 for dots/inch, or 2 for dots/cm. The default values are 0,1,1 + indicating square pixels of unknown size. + +boolean write_Adobe_marker + If TRUE, an Adobe APP14 marker is emitted. jpeg_set_defaults() and + jpeg_set_colorspace() set this TRUE if JPEG color space RGB, CMYK, + or YCCK is selected, otherwise FALSE. It is generally a bad idea + to set both write_JFIF_header and write_Adobe_marker. In fact, + you probably shouldn't change the default settings at all --- the + default behavior ensures that the JPEG file's color space can be + recognized by the decoder. + +JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS] + Pointers to coefficient quantization tables, one per table slot, + or NULL if no table is defined for a slot. Usually these should + be set via one of the above helper routines; jpeg_add_quant_table() + is general enough to define any quantization table. The other + routines will set up table slot 0 for luminance quality and table + slot 1 for chrominance. + +int q_scale_factor[NUM_QUANT_TBLS] + Linear quantization scaling factors (percentage, initialized 100) + for use with jpeg_default_qtables(). + See rdswitch.c and cjpeg.c for an example of usage. + Note that the q_scale_factor[] fields are the "linear" scales, so you + have to convert from user-defined ratings via jpeg_quality_scaling(). + Here is an example code which corresponds to cjpeg -quality 90,70: + + jpeg_set_defaults(cinfo); + + /* Set luminance quality 90. */ + cinfo->q_scale_factor[0] = jpeg_quality_scaling(90); + /* Set chrominance quality 70. */ + cinfo->q_scale_factor[1] = jpeg_quality_scaling(70); + + jpeg_default_qtables(cinfo, force_baseline); + + CAUTION: You must also set 1x1 subsampling for efficient separate + color quality selection, since the default value used by library + is 2x2: + + cinfo->comp_info[0].v_samp_factor = 1; + cinfo->comp_info[0].h_samp_factor = 1; + +JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS] +JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS] + Pointers to Huffman coding tables, one per table slot, or NULL if + no table is defined for a slot. Slots 0 and 1 are filled with the + JPEG sample tables by jpeg_set_defaults(). If you need to allocate + more table structures, jpeg_alloc_huff_table() may be used. + Note that optimal Huffman tables can be computed for an image + by setting optimize_coding, as discussed above; there's seldom + any need to mess with providing your own Huffman tables. + + +The actual dimensions of the JPEG image that will be written to the file are +given by the following fields. These are computed from the input image +dimensions and the compression parameters by jpeg_start_compress(). You can +also call jpeg_calc_jpeg_dimensions() to obtain the values that will result +from the current parameter settings. This can be useful if you are trying +to pick a scaling ratio that will get close to a desired target size. + +JDIMENSION jpeg_width Actual dimensions of output image. +JDIMENSION jpeg_height + + +Per-component parameters are stored in the struct cinfo.comp_info[i] for +component number i. Note that components here refer to components of the +JPEG color space, *not* the source image color space. A suitably large +comp_info[] array is allocated by jpeg_set_defaults(); if you choose not +to use that routine, it's up to you to allocate the array. + +int component_id + The one-byte identifier code to be recorded in the JPEG file for + this component. For the standard color spaces, we recommend you + leave the default values alone. + +int h_samp_factor +int v_samp_factor + Horizontal and vertical sampling factors for the component; must + be 1..4 according to the JPEG standard. Note that larger sampling + factors indicate a higher-resolution component; many people find + this behavior quite unintuitive. The default values are 2,2 for + luminance components and 1,1 for chrominance components, except + for grayscale where 1,1 is used. + +int quant_tbl_no + Quantization table number for component. The default value is + 0 for luminance components and 1 for chrominance components. + +int dc_tbl_no +int ac_tbl_no + DC and AC entropy coding table numbers. The default values are + 0 for luminance components and 1 for chrominance components. + +int component_index + Must equal the component's index in comp_info[]. (Beginning in + release v6, the compressor library will fill this in automatically; + you don't have to.) + + +Decompression parameter selection +--------------------------------- + +Decompression parameter selection is somewhat simpler than compression +parameter selection, since all of the JPEG internal parameters are +recorded in the source file and need not be supplied by the application. +(Unless you are working with abbreviated files, in which case see +"Abbreviated datastreams", below.) Decompression parameters control +the postprocessing done on the image to deliver it in a format suitable +for the application's use. Many of the parameters control speed/quality +tradeoffs, in which faster decompression may be obtained at the price of +a poorer-quality image. The defaults select the highest quality (slowest) +processing. + +The following fields in the JPEG object are set by jpeg_read_header() and +may be useful to the application in choosing decompression parameters: + +JDIMENSION image_width Width and height of image +JDIMENSION image_height +int num_components Number of color components +J_COLOR_SPACE jpeg_color_space Colorspace of image +boolean saw_JFIF_marker TRUE if a JFIF APP0 marker was seen + UINT8 JFIF_major_version Version information from JFIF marker + UINT8 JFIF_minor_version + UINT8 density_unit Resolution data from JFIF marker + UINT16 X_density + UINT16 Y_density +boolean saw_Adobe_marker TRUE if an Adobe APP14 marker was seen + UINT8 Adobe_transform Color transform code from Adobe marker + +The JPEG color space, unfortunately, is something of a guess since the JPEG +standard proper does not provide a way to record it. In practice most files +adhere to the JFIF or Adobe conventions, and the decoder will recognize these +correctly. See "Special color spaces", below, for more info. + + +The decompression parameters that determine the basic properties of the +returned image are: + +J_COLOR_SPACE out_color_space + Output color space. jpeg_read_header() sets an appropriate default + based on jpeg_color_space; typically it will be RGB or grayscale. + The application can change this field to request output in a different + colorspace. For example, set it to JCS_GRAYSCALE to get grayscale + output from a color file. (This is useful for previewing: grayscale + output is faster than full color since the color components need not + be processed.) Note that not all possible color space transforms are + currently implemented; you may need to extend jdcolor.c if you want an + unusual conversion. + +unsigned int scale_num, scale_denom + Scale the image by the fraction scale_num/scale_denom. Currently, + the supported scaling ratios are M/N with all M from 1 to 16, where + N is the source DCT size, which is 8 for baseline JPEG. (The library + design allows for arbitrary scaling ratios but this is not likely + to be implemented any time soon.) The values are initialized by + jpeg_read_header() with the source DCT size. For baseline JPEG + this is 8/8. If you change only the scale_num value while leaving + the other unchanged, then this specifies the DCT scaled size to be + applied on the given input. For baseline JPEG this is equivalent + to M/8 scaling, since the source DCT size for baseline JPEG is 8. + Smaller scaling ratios permit significantly faster decoding since + fewer pixels need be processed and a simpler IDCT method can be used. + +boolean quantize_colors + If set TRUE, colormapped output will be delivered. Default is FALSE, + meaning that full-color output will be delivered. + +The next three parameters are relevant only if quantize_colors is TRUE. + +int desired_number_of_colors + Maximum number of colors to use in generating a library-supplied color + map (the actual number of colors is returned in a different field). + Default 256. Ignored when the application supplies its own color map. + +boolean two_pass_quantize + If TRUE, an extra pass over the image is made to select a custom color + map for the image. This usually looks a lot better than the one-size- + fits-all colormap that is used otherwise. Default is TRUE. Ignored + when the application supplies its own color map. + +J_DITHER_MODE dither_mode + Selects color dithering method. Supported values are: + JDITHER_NONE no dithering: fast, very low quality + JDITHER_ORDERED ordered dither: moderate speed and quality + JDITHER_FS Floyd-Steinberg dither: slow, high quality + Default is JDITHER_FS. (At present, ordered dither is implemented + only in the single-pass, standard-colormap case. If you ask for + ordered dither when two_pass_quantize is TRUE or when you supply + an external color map, you'll get F-S dithering.) + +When quantize_colors is TRUE, the target color map is described by the next +two fields. colormap is set to NULL by jpeg_read_header(). The application +can supply a color map by setting colormap non-NULL and setting +actual_number_of_colors to the map size. Otherwise, jpeg_start_decompress() +selects a suitable color map and sets these two fields itself. +[Implementation restriction: at present, an externally supplied colormap is +only accepted for 3-component output color spaces.] + +JSAMPARRAY colormap + The color map, represented as a 2-D pixel array of out_color_components + rows and actual_number_of_colors columns. Ignored if not quantizing. + CAUTION: if the JPEG library creates its own colormap, the storage + pointed to by this field is released by jpeg_finish_decompress(). + Copy the colormap somewhere else first, if you want to save it. + +int actual_number_of_colors + The number of colors in the color map. + +Additional decompression parameters that the application may set include: + +J_DCT_METHOD dct_method + Selects the algorithm used for the DCT step. Choices are the same + as described above for compression. + +boolean do_fancy_upsampling + If TRUE, use direct DCT scaling with DCT size > 8 for upsampling + of chroma components. + If FALSE, use only DCT size <= 8 and simple separate upsampling. + Default is TRUE. + For better image stability in multiple generation compression cycles + it is preferable that this value matches the corresponding + do_fancy_downsampling value in compression. + +boolean do_block_smoothing + If TRUE, interblock smoothing is applied in early stages of decoding + progressive JPEG files; if FALSE, not. Default is TRUE. Early + progression stages look "fuzzy" with smoothing, "blocky" without. + In any case, block smoothing ceases to be applied after the first few + AC coefficients are known to full accuracy, so it is relevant only + when using buffered-image mode for progressive images. + +boolean enable_1pass_quant +boolean enable_external_quant +boolean enable_2pass_quant + These are significant only in buffered-image mode, which is + described in its own section below. + + +The output image dimensions are given by the following fields. These are +computed from the source image dimensions and the decompression parameters +by jpeg_start_decompress(). You can also call jpeg_calc_output_dimensions() +to obtain the values that will result from the current parameter settings. +This can be useful if you are trying to pick a scaling ratio that will get +close to a desired target size. It's also important if you are using the +JPEG library's memory manager to allocate output buffer space, because you +are supposed to request such buffers *before* jpeg_start_decompress(). + +JDIMENSION output_width Actual dimensions of output image. +JDIMENSION output_height +int out_color_components Number of color components in out_color_space. +int output_components Number of color components returned. +int rec_outbuf_height Recommended height of scanline buffer. + +When quantizing colors, output_components is 1, indicating a single color map +index per pixel. Otherwise it equals out_color_components. The output arrays +are required to be output_width * output_components JSAMPLEs wide. + +rec_outbuf_height is the recommended minimum height (in scanlines) of the +buffer passed to jpeg_read_scanlines(). If the buffer is smaller, the +library will still work, but time will be wasted due to unnecessary data +copying. In high-quality modes, rec_outbuf_height is always 1, but some +faster, lower-quality modes set it to larger values (typically 2 to 4). +If you are going to ask for a high-speed processing mode, you may as well +go to the trouble of honoring rec_outbuf_height so as to avoid data copying. +(An output buffer larger than rec_outbuf_height lines is OK, but won't +provide any material speed improvement over that height.) + + +Special color spaces +-------------------- + +The JPEG standard itself is "color blind" and doesn't specify any particular +color space. It is customary to convert color data to a luminance/chrominance +color space before compressing, since this permits greater compression. The +existing de-facto JPEG file format standards specify YCbCr or grayscale data +(JFIF), or grayscale, RGB, YCbCr, CMYK, or YCCK (Adobe). For special +applications such as multispectral images, other color spaces can be used, +but it must be understood that such files will be unportable. + +The JPEG library can handle the most common colorspace conversions (namely +RGB <=> YCbCr and CMYK <=> YCCK). It can also deal with data of an unknown +color space, passing it through without conversion. If you deal extensively +with an unusual color space, you can easily extend the library to understand +additional color spaces and perform appropriate conversions. + +For compression, the source data's color space is specified by field +in_color_space. This is transformed to the JPEG file's color space given +by jpeg_color_space. jpeg_set_defaults() chooses a reasonable JPEG color +space depending on in_color_space, but you can override this by calling +jpeg_set_colorspace(). Of course you must select a supported transformation. +jccolor.c currently supports the following transformations: + RGB => YCbCr + RGB => GRAYSCALE + YCbCr => GRAYSCALE + CMYK => YCCK +plus the null transforms: GRAYSCALE => GRAYSCALE, RGB => RGB, +YCbCr => YCbCr, CMYK => CMYK, YCCK => YCCK, and UNKNOWN => UNKNOWN. + +The de-facto file format standards (JFIF and Adobe) specify APPn markers that +indicate the color space of the JPEG file. It is important to ensure that +these are written correctly, or omitted if the JPEG file's color space is not +one of the ones supported by the de-facto standards. jpeg_set_colorspace() +will set the compression parameters to include or omit the APPn markers +properly, so long as it is told the truth about the JPEG color space. +For example, if you are writing some random 3-component color space without +conversion, don't try to fake out the library by setting in_color_space and +jpeg_color_space to JCS_YCbCr; use JCS_UNKNOWN. You may want to write an +APPn marker of your own devising to identify the colorspace --- see "Special +markers", below. + +When told that the color space is UNKNOWN, the library will default to using +luminance-quality compression parameters for all color components. You may +well want to change these parameters. See the source code for +jpeg_set_colorspace(), in jcparam.c, for details. + +For decompression, the JPEG file's color space is given in jpeg_color_space, +and this is transformed to the output color space out_color_space. +jpeg_read_header's setting of jpeg_color_space can be relied on if the file +conforms to JFIF or Adobe conventions, but otherwise it is no better than a +guess. If you know the JPEG file's color space for certain, you can override +jpeg_read_header's guess by setting jpeg_color_space. jpeg_read_header also +selects a default output color space based on (its guess of) jpeg_color_space; +set out_color_space to override this. Again, you must select a supported +transformation. jdcolor.c currently supports + YCbCr => RGB + YCbCr => GRAYSCALE + RGB => GRAYSCALE + GRAYSCALE => RGB + YCCK => CMYK +as well as the null transforms. (Since GRAYSCALE=>RGB is provided, an +application can force grayscale JPEGs to look like color JPEGs if it only +wants to handle one case.) + +The two-pass color quantizer, jquant2.c, is specialized to handle RGB data +(it weights distances appropriately for RGB colors). You'll need to modify +the code if you want to use it for non-RGB output color spaces. Note that +jquant2.c is used to map to an application-supplied colormap as well as for +the normal two-pass colormap selection process. + +CAUTION: it appears that Adobe Photoshop writes inverted data in CMYK JPEG +files: 0 represents 100% ink coverage, rather than 0% ink as you'd expect. +This is arguably a bug in Photoshop, but if you need to work with Photoshop +CMYK files, you will have to deal with it in your application. We cannot +"fix" this in the library by inverting the data during the CMYK<=>YCCK +transform, because that would break other applications, notably Ghostscript. +Photoshop versions prior to 3.0 write EPS files containing JPEG-encoded CMYK +data in the same inverted-YCCK representation used in bare JPEG files, but +the surrounding PostScript code performs an inversion using the PS image +operator. I am told that Photoshop 3.0 will write uninverted YCCK in +EPS/JPEG files, and will omit the PS-level inversion. (But the data +polarity used in bare JPEG files will not change in 3.0.) In either case, +the JPEG library must not invert the data itself, or else Ghostscript would +read these EPS files incorrectly. + + +Error handling +-------------- + +When the default error handler is used, any error detected inside the JPEG +routines will cause a message to be printed on stderr, followed by exit(). +You can supply your own error handling routines to override this behavior +and to control the treatment of nonfatal warnings and trace/debug messages. +The file example.c illustrates the most common case, which is to have the +application regain control after an error rather than exiting. + +The JPEG library never writes any message directly; it always goes through +the error handling routines. Three classes of messages are recognized: + * Fatal errors: the library cannot continue. + * Warnings: the library can continue, but the data is corrupt, and a + damaged output image is likely to result. + * Trace/informational messages. These come with a trace level indicating + the importance of the message; you can control the verbosity of the + program by adjusting the maximum trace level that will be displayed. + +You may, if you wish, simply replace the entire JPEG error handling module +(jerror.c) with your own code. However, you can avoid code duplication by +only replacing some of the routines depending on the behavior you need. +This is accomplished by calling jpeg_std_error() as usual, but then overriding +some of the method pointers in the jpeg_error_mgr struct, as illustrated by +example.c. + +All of the error handling routines will receive a pointer to the JPEG object +(a j_common_ptr which points to either a jpeg_compress_struct or a +jpeg_decompress_struct; if you need to tell which, test the is_decompressor +field). This struct includes a pointer to the error manager struct in its +"err" field. Frequently, custom error handler routines will need to access +additional data which is not known to the JPEG library or the standard error +handler. The most convenient way to do this is to embed either the JPEG +object or the jpeg_error_mgr struct in a larger structure that contains +additional fields; then casting the passed pointer provides access to the +additional fields. Again, see example.c for one way to do it. (Beginning +with IJG version 6b, there is also a void pointer "client_data" in each +JPEG object, which the application can also use to find related data. +The library does not touch client_data at all.) + +The individual methods that you might wish to override are: + +error_exit (j_common_ptr cinfo) + Receives control for a fatal error. Information sufficient to + generate the error message has been stored in cinfo->err; call + output_message to display it. Control must NOT return to the caller; + generally this routine will exit() or longjmp() somewhere. + Typically you would override this routine to get rid of the exit() + default behavior. Note that if you continue processing, you should + clean up the JPEG object with jpeg_abort() or jpeg_destroy(). + +output_message (j_common_ptr cinfo) + Actual output of any JPEG message. Override this to send messages + somewhere other than stderr. Note that this method does not know + how to generate a message, only where to send it. + +format_message (j_common_ptr cinfo, char * buffer) + Constructs a readable error message string based on the error info + stored in cinfo->err. This method is called by output_message. Few + applications should need to override this method. One possible + reason for doing so is to implement dynamic switching of error message + language. + +emit_message (j_common_ptr cinfo, int msg_level) + Decide whether or not to emit a warning or trace message; if so, + calls output_message. The main reason for overriding this method + would be to abort on warnings. msg_level is -1 for warnings, + 0 and up for trace messages. + +Only error_exit() and emit_message() are called from the rest of the JPEG +library; the other two are internal to the error handler. + +The actual message texts are stored in an array of strings which is pointed to +by the field err->jpeg_message_table. The messages are numbered from 0 to +err->last_jpeg_message, and it is these code numbers that are used in the +JPEG library code. You could replace the message texts (for instance, with +messages in French or German) by changing the message table pointer. See +jerror.h for the default texts. CAUTION: this table will almost certainly +change or grow from one library version to the next. + +It may be useful for an application to add its own message texts that are +handled by the same mechanism. The error handler supports a second "add-on" +message table for this purpose. To define an addon table, set the pointer +err->addon_message_table and the message numbers err->first_addon_message and +err->last_addon_message. If you number the addon messages beginning at 1000 +or so, you won't have to worry about conflicts with the library's built-in +messages. See the sample applications cjpeg/djpeg for an example of using +addon messages (the addon messages are defined in cderror.h). + +Actual invocation of the error handler is done via macros defined in jerror.h: + ERREXITn(...) for fatal errors + WARNMSn(...) for corrupt-data warnings + TRACEMSn(...) for trace and informational messages. +These macros store the message code and any additional parameters into the +error handler struct, then invoke the error_exit() or emit_message() method. +The variants of each macro are for varying numbers of additional parameters. +The additional parameters are inserted into the generated message using +standard printf() format codes. + +See jerror.h and jerror.c for further details. + + +Compressed data handling (source and destination managers) +---------------------------------------------------------- + +The JPEG compression library sends its compressed data to a "destination +manager" module. The default destination manager just writes the data to a +memory buffer or to a stdio stream, but you can provide your own manager to +do something else. Similarly, the decompression library calls a "source +manager" to obtain the compressed data; you can provide your own source +manager if you want the data to come from somewhere other than a memory +buffer or a stdio stream. + +In both cases, compressed data is processed a bufferload at a time: the +destination or source manager provides a work buffer, and the library invokes +the manager only when the buffer is filled or emptied. (You could define a +one-character buffer to force the manager to be invoked for each byte, but +that would be rather inefficient.) The buffer's size and location are +controlled by the manager, not by the library. For example, the memory +source manager just makes the buffer pointer and length point to the original +data in memory. In this case the buffer-reload procedure will be invoked +only if the decompressor ran off the end of the datastream, which would +indicate an erroneous datastream. + +The work buffer is defined as an array of datatype JOCTET, which is generally +"char" or "unsigned char". On a machine where char is not exactly 8 bits +wide, you must define JOCTET as a wider data type and then modify the data +source and destination modules to transcribe the work arrays into 8-bit units +on external storage. + +A data destination manager struct contains a pointer and count defining the +next byte to write in the work buffer and the remaining free space: + + JOCTET * next_output_byte; /* => next byte to write in buffer */ + size_t free_in_buffer; /* # of byte spaces remaining in buffer */ + +The library increments the pointer and decrements the count until the buffer +is filled. The manager's empty_output_buffer method must reset the pointer +and count. The manager is expected to remember the buffer's starting address +and total size in private fields not visible to the library. + +A data destination manager provides three methods: + +init_destination (j_compress_ptr cinfo) + Initialize destination. This is called by jpeg_start_compress() + before any data is actually written. It must initialize + next_output_byte and free_in_buffer. free_in_buffer must be + initialized to a positive value. + +empty_output_buffer (j_compress_ptr cinfo) + This is called whenever the buffer has filled (free_in_buffer + reaches zero). In typical applications, it should write out the + *entire* buffer (use the saved start address and buffer length; + ignore the current state of next_output_byte and free_in_buffer). + Then reset the pointer & count to the start of the buffer, and + return TRUE indicating that the buffer has been dumped. + free_in_buffer must be set to a positive value when TRUE is + returned. A FALSE return should only be used when I/O suspension is + desired (this operating mode is discussed in the next section). + +term_destination (j_compress_ptr cinfo) + Terminate destination --- called by jpeg_finish_compress() after all + data has been written. In most applications, this must flush any + data remaining in the buffer. Use either next_output_byte or + free_in_buffer to determine how much data is in the buffer. + +term_destination() is NOT called by jpeg_abort() or jpeg_destroy(). If you +want the destination manager to be cleaned up during an abort, you must do it +yourself. + +You will also need code to create a jpeg_destination_mgr struct, fill in its +method pointers, and insert a pointer to the struct into the "dest" field of +the JPEG compression object. This can be done in-line in your setup code if +you like, but it's probably cleaner to provide a separate routine similar to +the jpeg_stdio_dest() or jpeg_mem_dest() routines of the supplied destination +managers. + +Decompression source managers follow a parallel design, but with some +additional frammishes. The source manager struct contains a pointer and count +defining the next byte to read from the work buffer and the number of bytes +remaining: + + const JOCTET * next_input_byte; /* => next byte to read from buffer */ + size_t bytes_in_buffer; /* # of bytes remaining in buffer */ + +The library increments the pointer and decrements the count until the buffer +is emptied. The manager's fill_input_buffer method must reset the pointer and +count. In most applications, the manager must remember the buffer's starting +address and total size in private fields not visible to the library. + +A data source manager provides five methods: + +init_source (j_decompress_ptr cinfo) + Initialize source. This is called by jpeg_read_header() before any + data is actually read. Unlike init_destination(), it may leave + bytes_in_buffer set to 0 (in which case a fill_input_buffer() call + will occur immediately). + +fill_input_buffer (j_decompress_ptr cinfo) + This is called whenever bytes_in_buffer has reached zero and more + data is wanted. In typical applications, it should read fresh data + into the buffer (ignoring the current state of next_input_byte and + bytes_in_buffer), reset the pointer & count to the start of the + buffer, and return TRUE indicating that the buffer has been reloaded. + It is not necessary to fill the buffer entirely, only to obtain at + least one more byte. bytes_in_buffer MUST be set to a positive value + if TRUE is returned. A FALSE return should only be used when I/O + suspension is desired (this mode is discussed in the next section). + +skip_input_data (j_decompress_ptr cinfo, long num_bytes) + Skip num_bytes worth of data. The buffer pointer and count should + be advanced over num_bytes input bytes, refilling the buffer as + needed. This is used to skip over a potentially large amount of + uninteresting data (such as an APPn marker). In some applications + it may be possible to optimize away the reading of the skipped data, + but it's not clear that being smart is worth much trouble; large + skips are uncommon. bytes_in_buffer may be zero on return. + A zero or negative skip count should be treated as a no-op. + +resync_to_restart (j_decompress_ptr cinfo, int desired) + This routine is called only when the decompressor has failed to find + a restart (RSTn) marker where one is expected. Its mission is to + find a suitable point for resuming decompression. For most + applications, we recommend that you just use the default resync + procedure, jpeg_resync_to_restart(). However, if you are able to back + up in the input data stream, or if you have a-priori knowledge about + the likely location of restart markers, you may be able to do better. + Read the read_restart_marker() and jpeg_resync_to_restart() routines + in jdmarker.c if you think you'd like to implement your own resync + procedure. + +term_source (j_decompress_ptr cinfo) + Terminate source --- called by jpeg_finish_decompress() after all + data has been read. Often a no-op. + +For both fill_input_buffer() and skip_input_data(), there is no such thing +as an EOF return. If the end of the file has been reached, the routine has +a choice of exiting via ERREXIT() or inserting fake data into the buffer. +In most cases, generating a warning message and inserting a fake EOI marker +is the best course of action --- this will allow the decompressor to output +however much of the image is there. In pathological cases, the decompressor +may swallow the EOI and again demand data ... just keep feeding it fake EOIs. +jdatasrc.c illustrates the recommended error recovery behavior. + +term_source() is NOT called by jpeg_abort() or jpeg_destroy(). If you want +the source manager to be cleaned up during an abort, you must do it yourself. + +You will also need code to create a jpeg_source_mgr struct, fill in its method +pointers, and insert a pointer to the struct into the "src" field of the JPEG +decompression object. This can be done in-line in your setup code if you +like, but it's probably cleaner to provide a separate routine similar to the +jpeg_stdio_src() or jpeg_mem_src() routines of the supplied source managers. + +For more information, consult the memory and stdio source and destination +managers in jdatasrc.c and jdatadst.c. + + +I/O suspension +-------------- + +Some applications need to use the JPEG library as an incremental memory-to- +memory filter: when the compressed data buffer is filled or emptied, they want +control to return to the outer loop, rather than expecting that the buffer can +be emptied or reloaded within the data source/destination manager subroutine. +The library supports this need by providing an "I/O suspension" mode, which we +describe in this section. + +The I/O suspension mode is not a panacea: nothing is guaranteed about the +maximum amount of time spent in any one call to the library, so it will not +eliminate response-time problems in single-threaded applications. If you +need guaranteed response time, we suggest you "bite the bullet" and implement +a real multi-tasking capability. + +To use I/O suspension, cooperation is needed between the calling application +and the data source or destination manager; you will always need a custom +source/destination manager. (Please read the previous section if you haven't +already.) The basic idea is that the empty_output_buffer() or +fill_input_buffer() routine is a no-op, merely returning FALSE to indicate +that it has done nothing. Upon seeing this, the JPEG library suspends +operation and returns to its caller. The surrounding application is +responsible for emptying or refilling the work buffer before calling the +JPEG library again. + +Compression suspension: + +For compression suspension, use an empty_output_buffer() routine that returns +FALSE; typically it will not do anything else. This will cause the +compressor to return to the caller of jpeg_write_scanlines(), with the return +value indicating that not all the supplied scanlines have been accepted. +The application must make more room in the output buffer, adjust the output +buffer pointer/count appropriately, and then call jpeg_write_scanlines() +again, pointing to the first unconsumed scanline. + +When forced to suspend, the compressor will backtrack to a convenient stopping +point (usually the start of the current MCU); it will regenerate some output +data when restarted. Therefore, although empty_output_buffer() is only +called when the buffer is filled, you should NOT write out the entire buffer +after a suspension. Write only the data up to the current position of +next_output_byte/free_in_buffer. The data beyond that point will be +regenerated after resumption. + +Because of the backtracking behavior, a good-size output buffer is essential +for efficiency; you don't want the compressor to suspend often. (In fact, an +overly small buffer could lead to infinite looping, if a single MCU required +more data than would fit in the buffer.) We recommend a buffer of at least +several Kbytes. You may want to insert explicit code to ensure that you don't +call jpeg_write_scanlines() unless there is a reasonable amount of space in +the output buffer; in other words, flush the buffer before trying to compress +more data. + +The compressor does not allow suspension while it is trying to write JPEG +markers at the beginning and end of the file. This means that: + * At the beginning of a compression operation, there must be enough free + space in the output buffer to hold the header markers (typically 600 or + so bytes). The recommended buffer size is bigger than this anyway, so + this is not a problem as long as you start with an empty buffer. However, + this restriction might catch you if you insert large special markers, such + as a JFIF thumbnail image, without flushing the buffer afterwards. + * When you call jpeg_finish_compress(), there must be enough space in the + output buffer to emit any buffered data and the final EOI marker. In the + current implementation, half a dozen bytes should suffice for this, but + for safety's sake we recommend ensuring that at least 100 bytes are free + before calling jpeg_finish_compress(). + +A more significant restriction is that jpeg_finish_compress() cannot suspend. +This means you cannot use suspension with multi-pass operating modes, namely +Huffman code optimization and multiple-scan output. Those modes write the +whole file during jpeg_finish_compress(), which will certainly result in +buffer overrun. (Note that this restriction applies only to compression, +not decompression. The decompressor supports input suspension in all of its +operating modes.) + +Decompression suspension: + +For decompression suspension, use a fill_input_buffer() routine that simply +returns FALSE (except perhaps during error recovery, as discussed below). +This will cause the decompressor to return to its caller with an indication +that suspension has occurred. This can happen at four places: + * jpeg_read_header(): will return JPEG_SUSPENDED. + * jpeg_start_decompress(): will return FALSE, rather than its usual TRUE. + * jpeg_read_scanlines(): will return the number of scanlines already + completed (possibly 0). + * jpeg_finish_decompress(): will return FALSE, rather than its usual TRUE. +The surrounding application must recognize these cases, load more data into +the input buffer, and repeat the call. In the case of jpeg_read_scanlines(), +increment the passed pointers past any scanlines successfully read. + +Just as with compression, the decompressor will typically backtrack to a +convenient restart point before suspending. When fill_input_buffer() is +called, next_input_byte/bytes_in_buffer point to the current restart point, +which is where the decompressor will backtrack to if FALSE is returned. +The data beyond that position must NOT be discarded if you suspend; it needs +to be re-read upon resumption. In most implementations, you'll need to shift +this data down to the start of your work buffer and then load more data after +it. Again, this behavior means that a several-Kbyte work buffer is essential +for decent performance; furthermore, you should load a reasonable amount of +new data before resuming decompression. (If you loaded, say, only one new +byte each time around, you could waste a LOT of cycles.) + +The skip_input_data() source manager routine requires special care in a +suspension scenario. This routine is NOT granted the ability to suspend the +decompressor; it can decrement bytes_in_buffer to zero, but no more. If the +requested skip distance exceeds the amount of data currently in the input +buffer, then skip_input_data() must set bytes_in_buffer to zero and record the +additional skip distance somewhere else. The decompressor will immediately +call fill_input_buffer(), which should return FALSE, which will cause a +suspension return. The surrounding application must then arrange to discard +the recorded number of bytes before it resumes loading the input buffer. +(Yes, this design is rather baroque, but it avoids complexity in the far more +common case where a non-suspending source manager is used.) + +If the input data has been exhausted, we recommend that you emit a warning +and insert dummy EOI markers just as a non-suspending data source manager +would do. This can be handled either in the surrounding application logic or +within fill_input_buffer(); the latter is probably more efficient. If +fill_input_buffer() knows that no more data is available, it can set the +pointer/count to point to a dummy EOI marker and then return TRUE just as +though it had read more data in a non-suspending situation. + +The decompressor does not attempt to suspend within standard JPEG markers; +instead it will backtrack to the start of the marker and reprocess the whole +marker next time. Hence the input buffer must be large enough to hold the +longest standard marker in the file. Standard JPEG markers should normally +not exceed a few hundred bytes each (DHT tables are typically the longest). +We recommend at least a 2K buffer for performance reasons, which is much +larger than any correct marker is likely to be. For robustness against +damaged marker length counts, you may wish to insert a test in your +application for the case that the input buffer is completely full and yet +the decoder has suspended without consuming any data --- otherwise, if this +situation did occur, it would lead to an endless loop. (The library can't +provide this test since it has no idea whether "the buffer is full", or +even whether there is a fixed-size input buffer.) + +The input buffer would need to be 64K to allow for arbitrary COM or APPn +markers, but these are handled specially: they are either saved into allocated +memory, or skipped over by calling skip_input_data(). In the former case, +suspension is handled correctly, and in the latter case, the problem of +buffer overrun is placed on skip_input_data's shoulders, as explained above. +Note that if you provide your own marker handling routine for large markers, +you should consider how to deal with buffer overflow. + +Multiple-buffer management: + +In some applications it is desirable to store the compressed data in a linked +list of buffer areas, so as to avoid data copying. This can be handled by +having empty_output_buffer() or fill_input_buffer() set the pointer and count +to reference the next available buffer; FALSE is returned only if no more +buffers are available. Although seemingly straightforward, there is a +pitfall in this approach: the backtrack that occurs when FALSE is returned +could back up into an earlier buffer. For example, when fill_input_buffer() +is called, the current pointer & count indicate the backtrack restart point. +Since fill_input_buffer() will set the pointer and count to refer to a new +buffer, the restart position must be saved somewhere else. Suppose a second +call to fill_input_buffer() occurs in the same library call, and no +additional input data is available, so fill_input_buffer must return FALSE. +If the JPEG library has not moved the pointer/count forward in the current +buffer, then *the correct restart point is the saved position in the prior +buffer*. Prior buffers may be discarded only after the library establishes +a restart point within a later buffer. Similar remarks apply for output into +a chain of buffers. + +The library will never attempt to backtrack over a skip_input_data() call, +so any skipped data can be permanently discarded. You still have to deal +with the case of skipping not-yet-received data, however. + +It's much simpler to use only a single buffer; when fill_input_buffer() is +called, move any unconsumed data (beyond the current pointer/count) down to +the beginning of this buffer and then load new data into the remaining buffer +space. This approach requires a little more data copying but is far easier +to get right. + + +Progressive JPEG support +------------------------ + +Progressive JPEG rearranges the stored data into a series of scans of +increasing quality. In situations where a JPEG file is transmitted across a +slow communications link, a decoder can generate a low-quality image very +quickly from the first scan, then gradually improve the displayed quality as +more scans are received. The final image after all scans are complete is +identical to that of a regular (sequential) JPEG file of the same quality +setting. Progressive JPEG files are often slightly smaller than equivalent +sequential JPEG files, but the possibility of incremental display is the main +reason for using progressive JPEG. + +The IJG encoder library generates progressive JPEG files when given a +suitable "scan script" defining how to divide the data into scans. +Creation of progressive JPEG files is otherwise transparent to the encoder. +Progressive JPEG files can also be read transparently by the decoder library. +If the decoding application simply uses the library as defined above, it +will receive a final decoded image without any indication that the file was +progressive. Of course, this approach does not allow incremental display. +To perform incremental display, an application needs to use the decoder +library's "buffered-image" mode, in which it receives a decoded image +multiple times. + +Each displayed scan requires about as much work to decode as a full JPEG +image of the same size, so the decoder must be fairly fast in relation to the +data transmission rate in order to make incremental display useful. However, +it is possible to skip displaying the image and simply add the incoming bits +to the decoder's coefficient buffer. This is fast because only Huffman +decoding need be done, not IDCT, upsampling, colorspace conversion, etc. +The IJG decoder library allows the application to switch dynamically between +displaying the image and simply absorbing the incoming bits. A properly +coded application can automatically adapt the number of display passes to +suit the time available as the image is received. Also, a final +higher-quality display cycle can be performed from the buffered data after +the end of the file is reached. + +Progressive compression: + +To create a progressive JPEG file (or a multiple-scan sequential JPEG file), +set the scan_info cinfo field to point to an array of scan descriptors, and +perform compression as usual. Instead of constructing your own scan list, +you can call the jpeg_simple_progression() helper routine to create a +recommended progression sequence; this method should be used by all +applications that don't want to get involved in the nitty-gritty of +progressive scan sequence design. (If you want to provide user control of +scan sequences, you may wish to borrow the scan script reading code found +in rdswitch.c, so that you can read scan script files just like cjpeg's.) +When scan_info is not NULL, the compression library will store DCT'd data +into a buffer array as jpeg_write_scanlines() is called, and will emit all +the requested scans during jpeg_finish_compress(). This implies that +multiple-scan output cannot be created with a suspending data destination +manager, since jpeg_finish_compress() does not support suspension. We +should also note that the compressor currently forces Huffman optimization +mode when creating a progressive JPEG file, because the default Huffman +tables are unsuitable for progressive files. + +Progressive decompression: + +When buffered-image mode is not used, the decoder library will read all of +a multi-scan file during jpeg_start_decompress(), so that it can provide a +final decoded image. (Here "multi-scan" means either progressive or +multi-scan sequential.) This makes multi-scan files transparent to the +decoding application. However, existing applications that used suspending +input with version 5 of the IJG library will need to be modified to check +for a suspension return from jpeg_start_decompress(). + +To perform incremental display, an application must use the library's +buffered-image mode. This is described in the next section. + + +Buffered-image mode +------------------- + +In buffered-image mode, the library stores the partially decoded image in a +coefficient buffer, from which it can be read out as many times as desired. +This mode is typically used for incremental display of progressive JPEG files, +but it can be used with any JPEG file. Each scan of a progressive JPEG file +adds more data (more detail) to the buffered image. The application can +display in lockstep with the source file (one display pass per input scan), +or it can allow input processing to outrun display processing. By making +input and display processing run independently, it is possible for the +application to adapt progressive display to a wide range of data transmission +rates. + +The basic control flow for buffered-image decoding is + + jpeg_create_decompress() + set data source + jpeg_read_header() + set overall decompression parameters + cinfo.buffered_image = TRUE; /* select buffered-image mode */ + jpeg_start_decompress() + for (each output pass) { + adjust output decompression parameters if required + jpeg_start_output() /* start a new output pass */ + for (all scanlines in image) { + jpeg_read_scanlines() + display scanlines + } + jpeg_finish_output() /* terminate output pass */ + } + jpeg_finish_decompress() + jpeg_destroy_decompress() + +This differs from ordinary unbuffered decoding in that there is an additional +level of looping. The application can choose how many output passes to make +and how to display each pass. + +The simplest approach to displaying progressive images is to do one display +pass for each scan appearing in the input file. In this case the outer loop +condition is typically + while (! jpeg_input_complete(&cinfo)) +and the start-output call should read + jpeg_start_output(&cinfo, cinfo.input_scan_number); +The second parameter to jpeg_start_output() indicates which scan of the input +file is to be displayed; the scans are numbered starting at 1 for this +purpose. (You can use a loop counter starting at 1 if you like, but using +the library's input scan counter is easier.) The library automatically reads +data as necessary to complete each requested scan, and jpeg_finish_output() +advances to the next scan or end-of-image marker (hence input_scan_number +will be incremented by the time control arrives back at jpeg_start_output()). +With this technique, data is read from the input file only as needed, and +input and output processing run in lockstep. + +After reading the final scan and reaching the end of the input file, the +buffered image remains available; it can be read additional times by +repeating the jpeg_start_output()/jpeg_read_scanlines()/jpeg_finish_output() +sequence. For example, a useful technique is to use fast one-pass color +quantization for display passes made while the image is arriving, followed by +a final display pass using two-pass quantization for highest quality. This +is done by changing the library parameters before the final output pass. +Changing parameters between passes is discussed in detail below. + +In general the last scan of a progressive file cannot be recognized as such +until after it is read, so a post-input display pass is the best approach if +you want special processing in the final pass. + +When done with the image, be sure to call jpeg_finish_decompress() to release +the buffered image (or just use jpeg_destroy_decompress()). + +If input data arrives faster than it can be displayed, the application can +cause the library to decode input data in advance of what's needed to produce +output. This is done by calling the routine jpeg_consume_input(). +The return value is one of the following: + JPEG_REACHED_SOS: reached an SOS marker (the start of a new scan) + JPEG_REACHED_EOI: reached the EOI marker (end of image) + JPEG_ROW_COMPLETED: completed reading one MCU row of compressed data + JPEG_SCAN_COMPLETED: completed reading last MCU row of current scan + JPEG_SUSPENDED: suspended before completing any of the above +(JPEG_SUSPENDED can occur only if a suspending data source is used.) This +routine can be called at any time after initializing the JPEG object. It +reads some additional data and returns when one of the indicated significant +events occurs. (If called after the EOI marker is reached, it will +immediately return JPEG_REACHED_EOI without attempting to read more data.) + +The library's output processing will automatically call jpeg_consume_input() +whenever the output processing overtakes the input; thus, simple lockstep +display requires no direct calls to jpeg_consume_input(). But by adding +calls to jpeg_consume_input(), you can absorb data in advance of what is +being displayed. This has two benefits: + * You can limit buildup of unprocessed data in your input buffer. + * You can eliminate extra display passes by paying attention to the + state of the library's input processing. + +The first of these benefits only requires interspersing calls to +jpeg_consume_input() with your display operations and any other processing +you may be doing. To avoid wasting cycles due to backtracking, it's best to +call jpeg_consume_input() only after a hundred or so new bytes have arrived. +This is discussed further under "I/O suspension", above. (Note: the JPEG +library currently is not thread-safe. You must not call jpeg_consume_input() +from one thread of control if a different library routine is working on the +same JPEG object in another thread.) + +When input arrives fast enough that more than one new scan is available +before you start a new output pass, you may as well skip the output pass +corresponding to the completed scan. This occurs for free if you pass +cinfo.input_scan_number as the target scan number to jpeg_start_output(). +The input_scan_number field is simply the index of the scan currently being +consumed by the input processor. You can ensure that this is up-to-date by +emptying the input buffer just before calling jpeg_start_output(): call +jpeg_consume_input() repeatedly until it returns JPEG_SUSPENDED or +JPEG_REACHED_EOI. + +The target scan number passed to jpeg_start_output() is saved in the +cinfo.output_scan_number field. The library's output processing calls +jpeg_consume_input() whenever the current input scan number and row within +that scan is less than or equal to the current output scan number and row. +Thus, input processing can "get ahead" of the output processing but is not +allowed to "fall behind". You can achieve several different effects by +manipulating this interlock rule. For example, if you pass a target scan +number greater than the current input scan number, the output processor will +wait until that scan starts to arrive before producing any output. (To avoid +an infinite loop, the target scan number is automatically reset to the last +scan number when the end of image is reached. Thus, if you specify a large +target scan number, the library will just absorb the entire input file and +then perform an output pass. This is effectively the same as what +jpeg_start_decompress() does when you don't select buffered-image mode.) +When you pass a target scan number equal to the current input scan number, +the image is displayed no faster than the current input scan arrives. The +final possibility is to pass a target scan number less than the current input +scan number; this disables the input/output interlock and causes the output +processor to simply display whatever it finds in the image buffer, without +waiting for input. (However, the library will not accept a target scan +number less than one, so you can't avoid waiting for the first scan.) + +When data is arriving faster than the output display processing can advance +through the image, jpeg_consume_input() will store data into the buffered +image beyond the point at which the output processing is reading data out +again. If the input arrives fast enough, it may "wrap around" the buffer to +the point where the input is more than one whole scan ahead of the output. +If the output processing simply proceeds through its display pass without +paying attention to the input, the effect seen on-screen is that the lower +part of the image is one or more scans better in quality than the upper part. +Then, when the next output scan is started, you have a choice of what target +scan number to use. The recommended choice is to use the current input scan +number at that time, which implies that you've skipped the output scans +corresponding to the input scans that were completed while you processed the +previous output scan. In this way, the decoder automatically adapts its +speed to the arriving data, by skipping output scans as necessary to keep up +with the arriving data. + +When using this strategy, you'll want to be sure that you perform a final +output pass after receiving all the data; otherwise your last display may not +be full quality across the whole screen. So the right outer loop logic is +something like this: + do { + absorb any waiting input by calling jpeg_consume_input() + final_pass = jpeg_input_complete(&cinfo); + adjust output decompression parameters if required + jpeg_start_output(&cinfo, cinfo.input_scan_number); + ... + jpeg_finish_output() + } while (! final_pass); +rather than quitting as soon as jpeg_input_complete() returns TRUE. This +arrangement makes it simple to use higher-quality decoding parameters +for the final pass. But if you don't want to use special parameters for +the final pass, the right loop logic is like this: + for (;;) { + absorb any waiting input by calling jpeg_consume_input() + jpeg_start_output(&cinfo, cinfo.input_scan_number); + ... + jpeg_finish_output() + if (jpeg_input_complete(&cinfo) && + cinfo.input_scan_number == cinfo.output_scan_number) + break; + } +In this case you don't need to know in advance whether an output pass is to +be the last one, so it's not necessary to have reached EOF before starting +the final output pass; rather, what you want to test is whether the output +pass was performed in sync with the final input scan. This form of the loop +will avoid an extra output pass whenever the decoder is able (or nearly able) +to keep up with the incoming data. + +When the data transmission speed is high, you might begin a display pass, +then find that much or all of the file has arrived before you can complete +the pass. (You can detect this by noting the JPEG_REACHED_EOI return code +from jpeg_consume_input(), or equivalently by testing jpeg_input_complete().) +In this situation you may wish to abort the current display pass and start a +new one using the newly arrived information. To do so, just call +jpeg_finish_output() and then start a new pass with jpeg_start_output(). + +A variant strategy is to abort and restart display if more than one complete +scan arrives during an output pass; this can be detected by noting +JPEG_REACHED_SOS returns and/or examining cinfo.input_scan_number. This +idea should be employed with caution, however, since the display process +might never get to the bottom of the image before being aborted, resulting +in the lower part of the screen being several passes worse than the upper. +In most cases it's probably best to abort an output pass only if the whole +file has arrived and you want to begin the final output pass immediately. + +When receiving data across a communication link, we recommend always using +the current input scan number for the output target scan number; if a +higher-quality final pass is to be done, it should be started (aborting any +incomplete output pass) as soon as the end of file is received. However, +many other strategies are possible. For example, the application can examine +the parameters of the current input scan and decide whether to display it or +not. If the scan contains only chroma data, one might choose not to use it +as the target scan, expecting that the scan will be small and will arrive +quickly. To skip to the next scan, call jpeg_consume_input() until it +returns JPEG_REACHED_SOS or JPEG_REACHED_EOI. Or just use the next higher +number as the target scan for jpeg_start_output(); but that method doesn't +let you inspect the next scan's parameters before deciding to display it. + + +In buffered-image mode, jpeg_start_decompress() never performs input and +thus never suspends. An application that uses input suspension with +buffered-image mode must be prepared for suspension returns from these +routines: +* jpeg_start_output() performs input only if you request 2-pass quantization + and the target scan isn't fully read yet. (This is discussed below.) +* jpeg_read_scanlines(), as always, returns the number of scanlines that it + was able to produce before suspending. +* jpeg_finish_output() will read any markers following the target scan, + up to the end of the file or the SOS marker that begins another scan. + (But it reads no input if jpeg_consume_input() has already reached the + end of the file or a SOS marker beyond the target output scan.) +* jpeg_finish_decompress() will read until the end of file, and thus can + suspend if the end hasn't already been reached (as can be tested by + calling jpeg_input_complete()). +jpeg_start_output(), jpeg_finish_output(), and jpeg_finish_decompress() +all return TRUE if they completed their tasks, FALSE if they had to suspend. +In the event of a FALSE return, the application must load more input data +and repeat the call. Applications that use non-suspending data sources need +not check the return values of these three routines. + + +It is possible to change decoding parameters between output passes in the +buffered-image mode. The decoder library currently supports only very +limited changes of parameters. ONLY THE FOLLOWING parameter changes are +allowed after jpeg_start_decompress() is called: +* dct_method can be changed before each call to jpeg_start_output(). + For example, one could use a fast DCT method for early scans, changing + to a higher quality method for the final scan. +* dither_mode can be changed before each call to jpeg_start_output(); + of course this has no impact if not using color quantization. Typically + one would use ordered dither for initial passes, then switch to + Floyd-Steinberg dither for the final pass. Caution: changing dither mode + can cause more memory to be allocated by the library. Although the amount + of memory involved is not large (a scanline or so), it may cause the + initial max_memory_to_use specification to be exceeded, which in the worst + case would result in an out-of-memory failure. +* do_block_smoothing can be changed before each call to jpeg_start_output(). + This setting is relevant only when decoding a progressive JPEG image. + During the first DC-only scan, block smoothing provides a very "fuzzy" look + instead of the very "blocky" look seen without it; which is better seems a + matter of personal taste. But block smoothing is nearly always a win + during later stages, especially when decoding a successive-approximation + image: smoothing helps to hide the slight blockiness that otherwise shows + up on smooth gradients until the lowest coefficient bits are sent. +* Color quantization mode can be changed under the rules described below. + You *cannot* change between full-color and quantized output (because that + would alter the required I/O buffer sizes), but you can change which + quantization method is used. + +When generating color-quantized output, changing quantization method is a +very useful way of switching between high-speed and high-quality display. +The library allows you to change among its three quantization methods: +1. Single-pass quantization to a fixed color cube. + Selected by cinfo.two_pass_quantize = FALSE and cinfo.colormap = NULL. +2. Single-pass quantization to an application-supplied colormap. + Selected by setting cinfo.colormap to point to the colormap (the value of + two_pass_quantize is ignored); also set cinfo.actual_number_of_colors. +3. Two-pass quantization to a colormap chosen specifically for the image. + Selected by cinfo.two_pass_quantize = TRUE and cinfo.colormap = NULL. + (This is the default setting selected by jpeg_read_header, but it is + probably NOT what you want for the first pass of progressive display!) +These methods offer successively better quality and lesser speed. However, +only the first method is available for quantizing in non-RGB color spaces. + +IMPORTANT: because the different quantizer methods have very different +working-storage requirements, the library requires you to indicate which +one(s) you intend to use before you call jpeg_start_decompress(). (If we did +not require this, the max_memory_to_use setting would be a complete fiction.) +You do this by setting one or more of these three cinfo fields to TRUE: + enable_1pass_quant Fixed color cube colormap + enable_external_quant Externally-supplied colormap + enable_2pass_quant Two-pass custom colormap +All three are initialized FALSE by jpeg_read_header(). But +jpeg_start_decompress() automatically sets TRUE the one selected by the +current two_pass_quantize and colormap settings, so you only need to set the +enable flags for any other quantization methods you plan to change to later. + +After setting the enable flags correctly at jpeg_start_decompress() time, you +can change to any enabled quantization method by setting two_pass_quantize +and colormap properly just before calling jpeg_start_output(). The following +special rules apply: +1. You must explicitly set cinfo.colormap to NULL when switching to 1-pass + or 2-pass mode from a different mode, or when you want the 2-pass + quantizer to be re-run to generate a new colormap. +2. To switch to an external colormap, or to change to a different external + colormap than was used on the prior pass, you must call + jpeg_new_colormap() after setting cinfo.colormap. +NOTE: if you want to use the same colormap as was used in the prior pass, +you should not do either of these things. This will save some nontrivial +switchover costs. +(These requirements exist because cinfo.colormap will always be non-NULL +after completing a prior output pass, since both the 1-pass and 2-pass +quantizers set it to point to their output colormaps. Thus you have to +do one of these two things to notify the library that something has changed. +Yup, it's a bit klugy, but it's necessary to do it this way for backwards +compatibility.) + +Note that in buffered-image mode, the library generates any requested colormap +during jpeg_start_output(), not during jpeg_start_decompress(). + +When using two-pass quantization, jpeg_start_output() makes a pass over the +buffered image to determine the optimum color map; it therefore may take a +significant amount of time, whereas ordinarily it does little work. The +progress monitor hook is called during this pass, if defined. It is also +important to realize that if the specified target scan number is greater than +or equal to the current input scan number, jpeg_start_output() will attempt +to consume input as it makes this pass. If you use a suspending data source, +you need to check for a FALSE return from jpeg_start_output() under these +conditions. The combination of 2-pass quantization and a not-yet-fully-read +target scan is the only case in which jpeg_start_output() will consume input. + + +Application authors who support buffered-image mode may be tempted to use it +for all JPEG images, even single-scan ones. This will work, but it is +inefficient: there is no need to create an image-sized coefficient buffer for +single-scan images. Requesting buffered-image mode for such an image wastes +memory. Worse, it can cost time on large images, since the buffered data has +to be swapped out or written to a temporary file. If you are concerned about +maximum performance on baseline JPEG files, you should use buffered-image +mode only when the incoming file actually has multiple scans. This can be +tested by calling jpeg_has_multiple_scans(), which will return a correct +result at any time after jpeg_read_header() completes. + +It is also worth noting that when you use jpeg_consume_input() to let input +processing get ahead of output processing, the resulting pattern of access to +the coefficient buffer is quite nonsequential. It's best to use the memory +manager jmemnobs.c if you can (ie, if you have enough real or virtual main +memory). If not, at least make sure that max_memory_to_use is set as high as +possible. If the JPEG memory manager has to use a temporary file, you will +probably see a lot of disk traffic and poor performance. (This could be +improved with additional work on the memory manager, but we haven't gotten +around to it yet.) + +In some applications it may be convenient to use jpeg_consume_input() for all +input processing, including reading the initial markers; that is, you may +wish to call jpeg_consume_input() instead of jpeg_read_header() during +startup. This works, but note that you must check for JPEG_REACHED_SOS and +JPEG_REACHED_EOI return codes as the equivalent of jpeg_read_header's codes. +Once the first SOS marker has been reached, you must call +jpeg_start_decompress() before jpeg_consume_input() will consume more input; +it'll just keep returning JPEG_REACHED_SOS until you do. If you read a +tables-only file this way, jpeg_consume_input() will return JPEG_REACHED_EOI +without ever returning JPEG_REACHED_SOS; be sure to check for this case. +If this happens, the decompressor will not read any more input until you call +jpeg_abort() to reset it. It is OK to call jpeg_consume_input() even when not +using buffered-image mode, but in that case it's basically a no-op after the +initial markers have been read: it will just return JPEG_SUSPENDED. + + +Abbreviated datastreams and multiple images +------------------------------------------- + +A JPEG compression or decompression object can be reused to process multiple +images. This saves a small amount of time per image by eliminating the +"create" and "destroy" operations, but that isn't the real purpose of the +feature. Rather, reuse of an object provides support for abbreviated JPEG +datastreams. Object reuse can also simplify processing a series of images in +a single input or output file. This section explains these features. + +A JPEG file normally contains several hundred bytes worth of quantization +and Huffman tables. In a situation where many images will be stored or +transmitted with identical tables, this may represent an annoying overhead. +The JPEG standard therefore permits tables to be omitted. The standard +defines three classes of JPEG datastreams: + * "Interchange" datastreams contain an image and all tables needed to decode + the image. These are the usual kind of JPEG file. + * "Abbreviated image" datastreams contain an image, but are missing some or + all of the tables needed to decode that image. + * "Abbreviated table specification" (henceforth "tables-only") datastreams + contain only table specifications. +To decode an abbreviated image, it is necessary to load the missing table(s) +into the decoder beforehand. This can be accomplished by reading a separate +tables-only file. A variant scheme uses a series of images in which the first +image is an interchange (complete) datastream, while subsequent ones are +abbreviated and rely on the tables loaded by the first image. It is assumed +that once the decoder has read a table, it will remember that table until a +new definition for the same table number is encountered. + +It is the application designer's responsibility to figure out how to associate +the correct tables with an abbreviated image. While abbreviated datastreams +can be useful in a closed environment, their use is strongly discouraged in +any situation where data exchange with other applications might be needed. +Caveat designer. + +The JPEG library provides support for reading and writing any combination of +tables-only datastreams and abbreviated images. In both compression and +decompression objects, a quantization or Huffman table will be retained for +the lifetime of the object, unless it is overwritten by a new table definition. + + +To create abbreviated image datastreams, it is only necessary to tell the +compressor not to emit some or all of the tables it is using. Each +quantization and Huffman table struct contains a boolean field "sent_table", +which normally is initialized to FALSE. For each table used by the image, the +header-writing process emits the table and sets sent_table = TRUE unless it is +already TRUE. (In normal usage, this prevents outputting the same table +definition multiple times, as would otherwise occur because the chroma +components typically share tables.) Thus, setting this field to TRUE before +calling jpeg_start_compress() will prevent the table from being written at +all. + +If you want to create a "pure" abbreviated image file containing no tables, +just call "jpeg_suppress_tables(&cinfo, TRUE)" after constructing all the +tables. If you want to emit some but not all tables, you'll need to set the +individual sent_table fields directly. + +To create an abbreviated image, you must also call jpeg_start_compress() +with a second parameter of FALSE, not TRUE. Otherwise jpeg_start_compress() +will force all the sent_table fields to FALSE. (This is a safety feature to +prevent abbreviated images from being created accidentally.) + +To create a tables-only file, perform the same parameter setup that you +normally would, but instead of calling jpeg_start_compress() and so on, call +jpeg_write_tables(&cinfo). This will write an abbreviated datastream +containing only SOI, DQT and/or DHT markers, and EOI. All the quantization +and Huffman tables that are currently defined in the compression object will +be emitted unless their sent_tables flag is already TRUE, and then all the +sent_tables flags will be set TRUE. + +A sure-fire way to create matching tables-only and abbreviated image files +is to proceed as follows: + + create JPEG compression object + set JPEG parameters + set destination to tables-only file + jpeg_write_tables(&cinfo); + set destination to image file + jpeg_start_compress(&cinfo, FALSE); + write data... + jpeg_finish_compress(&cinfo); + +Since the JPEG parameters are not altered between writing the table file and +the abbreviated image file, the same tables are sure to be used. Of course, +you can repeat the jpeg_start_compress() ... jpeg_finish_compress() sequence +many times to produce many abbreviated image files matching the table file. + +You cannot suppress output of the computed Huffman tables when Huffman +optimization is selected. (If you could, there'd be no way to decode the +image...) Generally, you don't want to set optimize_coding = TRUE when +you are trying to produce abbreviated files. + +In some cases you might want to compress an image using tables which are +not stored in the application, but are defined in an interchange or +tables-only file readable by the application. This can be done by setting up +a JPEG decompression object to read the specification file, then copying the +tables into your compression object. See jpeg_copy_critical_parameters() +for an example of copying quantization tables. + + +To read abbreviated image files, you simply need to load the proper tables +into the decompression object before trying to read the abbreviated image. +If the proper tables are stored in the application program, you can just +allocate the table structs and fill in their contents directly. For example, +to load a fixed quantization table into table slot "n": + + if (cinfo.quant_tbl_ptrs[n] == NULL) + cinfo.quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) &cinfo); + quant_ptr = cinfo.quant_tbl_ptrs[n]; /* quant_ptr is JQUANT_TBL* */ + for (i = 0; i < 64; i++) { + /* Qtable[] is desired quantization table, in natural array order */ + quant_ptr->quantval[i] = Qtable[i]; + } + +Code to load a fixed Huffman table is typically (for AC table "n"): + + if (cinfo.ac_huff_tbl_ptrs[n] == NULL) + cinfo.ac_huff_tbl_ptrs[n] = jpeg_alloc_huff_table((j_common_ptr) &cinfo); + huff_ptr = cinfo.ac_huff_tbl_ptrs[n]; /* huff_ptr is JHUFF_TBL* */ + for (i = 1; i <= 16; i++) { + /* counts[i] is number of Huffman codes of length i bits, i=1..16 */ + huff_ptr->bits[i] = counts[i]; + } + for (i = 0; i < 256; i++) { + /* symbols[] is the list of Huffman symbols, in code-length order */ + huff_ptr->huffval[i] = symbols[i]; + } + +(Note that trying to set cinfo.quant_tbl_ptrs[n] to point directly at a +constant JQUANT_TBL object is not safe. If the incoming file happened to +contain a quantization table definition, your master table would get +overwritten! Instead allocate a working table copy and copy the master table +into it, as illustrated above. Ditto for Huffman tables, of course.) + +You might want to read the tables from a tables-only file, rather than +hard-wiring them into your application. The jpeg_read_header() call is +sufficient to read a tables-only file. You must pass a second parameter of +FALSE to indicate that you do not require an image to be present. Thus, the +typical scenario is + + create JPEG decompression object + set source to tables-only file + jpeg_read_header(&cinfo, FALSE); + set source to abbreviated image file + jpeg_read_header(&cinfo, TRUE); + set decompression parameters + jpeg_start_decompress(&cinfo); + read data... + jpeg_finish_decompress(&cinfo); + +In some cases, you may want to read a file without knowing whether it contains +an image or just tables. In that case, pass FALSE and check the return value +from jpeg_read_header(): it will be JPEG_HEADER_OK if an image was found, +JPEG_HEADER_TABLES_ONLY if only tables were found. (A third return value, +JPEG_SUSPENDED, is possible when using a suspending data source manager.) +Note that jpeg_read_header() will not complain if you read an abbreviated +image for which you haven't loaded the missing tables; the missing-table check +occurs later, in jpeg_start_decompress(). + + +It is possible to read a series of images from a single source file by +repeating the jpeg_read_header() ... jpeg_finish_decompress() sequence, +without releasing/recreating the JPEG object or the data source module. +(If you did reinitialize, any partial bufferload left in the data source +buffer at the end of one image would be discarded, causing you to lose the +start of the next image.) When you use this method, stored tables are +automatically carried forward, so some of the images can be abbreviated images +that depend on tables from earlier images. + +If you intend to write a series of images into a single destination file, +you might want to make a specialized data destination module that doesn't +flush the output buffer at term_destination() time. This would speed things +up by some trifling amount. Of course, you'd need to remember to flush the +buffer after the last image. You can make the later images be abbreviated +ones by passing FALSE to jpeg_start_compress(). + + +Special markers +--------------- + +Some applications may need to insert or extract special data in the JPEG +datastream. The JPEG standard provides marker types "COM" (comment) and +"APP0" through "APP15" (application) to hold application-specific data. +Unfortunately, the use of these markers is not specified by the standard. +COM markers are fairly widely used to hold user-supplied text. The JFIF file +format spec uses APP0 markers with specified initial strings to hold certain +data. Adobe applications use APP14 markers beginning with the string "Adobe" +for miscellaneous data. Other APPn markers are rarely seen, but might +contain almost anything. + +If you wish to store user-supplied text, we recommend you use COM markers +and place readable 7-bit ASCII text in them. Newline conventions are not +standardized --- expect to find LF (Unix style), CR/LF (DOS style), or CR +(Mac style). A robust COM reader should be able to cope with random binary +garbage, including nulls, since some applications generate COM markers +containing non-ASCII junk. (But yours should not be one of them.) + +For program-supplied data, use an APPn marker, and be sure to begin it with an +identifying string so that you can tell whether the marker is actually yours. +It's probably best to avoid using APP0 or APP14 for any private markers. +(NOTE: the upcoming SPIFF standard will use APP8 markers; we recommend you +not use APP8 markers for any private purposes, either.) + +Keep in mind that at most 65533 bytes can be put into one marker, but you +can have as many markers as you like. + +By default, the IJG compression library will write a JFIF APP0 marker if the +selected JPEG colorspace is grayscale or YCbCr, or an Adobe APP14 marker if +the selected colorspace is RGB, CMYK, or YCCK. You can disable this, but +we don't recommend it. The decompression library will recognize JFIF and +Adobe markers and will set the JPEG colorspace properly when one is found. + + +You can write special markers immediately following the datastream header by +calling jpeg_write_marker() after jpeg_start_compress() and before the first +call to jpeg_write_scanlines(). When you do this, the markers appear after +the SOI and the JFIF APP0 and Adobe APP14 markers (if written), but before +all else. Specify the marker type parameter as "JPEG_COM" for COM or +"JPEG_APP0 + n" for APPn. (Actually, jpeg_write_marker will let you write +any marker type, but we don't recommend writing any other kinds of marker.) +For example, to write a user comment string pointed to by comment_text: + jpeg_write_marker(cinfo, JPEG_COM, comment_text, strlen(comment_text)); + +If it's not convenient to store all the marker data in memory at once, +you can instead call jpeg_write_m_header() followed by multiple calls to +jpeg_write_m_byte(). If you do it this way, it's your responsibility to +call jpeg_write_m_byte() exactly the number of times given in the length +parameter to jpeg_write_m_header(). (This method lets you empty the +output buffer partway through a marker, which might be important when +using a suspending data destination module. In any case, if you are using +a suspending destination, you should flush its buffer after inserting +any special markers. See "I/O suspension".) + +Or, if you prefer to synthesize the marker byte sequence yourself, +you can just cram it straight into the data destination module. + +If you are writing JFIF 1.02 extension markers (thumbnail images), don't +forget to set cinfo.JFIF_minor_version = 2 so that the encoder will write the +correct JFIF version number in the JFIF header marker. The library's default +is to write version 1.01, but that's wrong if you insert any 1.02 extension +markers. (We could probably get away with just defaulting to 1.02, but there +used to be broken decoders that would complain about unknown minor version +numbers. To reduce compatibility risks it's safest not to write 1.02 unless +you are actually using 1.02 extensions.) + + +When reading, two methods of handling special markers are available: +1. You can ask the library to save the contents of COM and/or APPn markers +into memory, and then examine them at your leisure afterwards. +2. You can supply your own routine to process COM and/or APPn markers +on-the-fly as they are read. +The first method is simpler to use, especially if you are using a suspending +data source; writing a marker processor that copes with input suspension is +not easy (consider what happens if the marker is longer than your available +input buffer). However, the second method conserves memory since the marker +data need not be kept around after it's been processed. + +For either method, you'd normally set up marker handling after creating a +decompression object and before calling jpeg_read_header(), because the +markers of interest will typically be near the head of the file and so will +be scanned by jpeg_read_header. Once you've established a marker handling +method, it will be used for the life of that decompression object +(potentially many datastreams), unless you change it. Marker handling is +determined separately for COM markers and for each APPn marker code. + + +To save the contents of special markers in memory, call + jpeg_save_markers(cinfo, marker_code, length_limit) +where marker_code is the marker type to save, JPEG_COM or JPEG_APP0+n. +(To arrange to save all the special marker types, you need to call this +routine 17 times, for COM and APP0-APP15.) If the incoming marker is longer +than length_limit data bytes, only length_limit bytes will be saved; this +parameter allows you to avoid chewing up memory when you only need to see the +first few bytes of a potentially large marker. If you want to save all the +data, set length_limit to 0xFFFF; that is enough since marker lengths are only +16 bits. As a special case, setting length_limit to 0 prevents that marker +type from being saved at all. (That is the default behavior, in fact.) + +After jpeg_read_header() completes, you can examine the special markers by +following the cinfo->marker_list pointer chain. All the special markers in +the file appear in this list, in order of their occurrence in the file (but +omitting any markers of types you didn't ask for). Both the original data +length and the saved data length are recorded for each list entry; the latter +will not exceed length_limit for the particular marker type. Note that these +lengths exclude the marker length word, whereas the stored representation +within the JPEG file includes it. (Hence the maximum data length is really +only 65533.) + +It is possible that additional special markers appear in the file beyond the +SOS marker at which jpeg_read_header stops; if so, the marker list will be +extended during reading of the rest of the file. This is not expected to be +common, however. If you are short on memory you may want to reset the length +limit to zero for all marker types after finishing jpeg_read_header, to +ensure that the max_memory_to_use setting cannot be exceeded due to addition +of later markers. + +The marker list remains stored until you call jpeg_finish_decompress or +jpeg_abort, at which point the memory is freed and the list is set to empty. +(jpeg_destroy also releases the storage, of course.) + +Note that the library is internally interested in APP0 and APP14 markers; +if you try to set a small nonzero length limit on these types, the library +will silently force the length up to the minimum it wants. (But you can set +a zero length limit to prevent them from being saved at all.) Also, in a +16-bit environment, the maximum length limit may be constrained to less than +65533 by malloc() limitations. It is therefore best not to assume that the +effective length limit is exactly what you set it to be. + + +If you want to supply your own marker-reading routine, you do it by calling +jpeg_set_marker_processor(). A marker processor routine must have the +signature + boolean jpeg_marker_parser_method (j_decompress_ptr cinfo) +Although the marker code is not explicitly passed, the routine can find it +in cinfo->unread_marker. At the time of call, the marker proper has been +read from the data source module. The processor routine is responsible for +reading the marker length word and the remaining parameter bytes, if any. +Return TRUE to indicate success. (FALSE should be returned only if you are +using a suspending data source and it tells you to suspend. See the standard +marker processors in jdmarker.c for appropriate coding methods if you need to +use a suspending data source.) + +If you override the default APP0 or APP14 processors, it is up to you to +recognize JFIF and Adobe markers if you want colorspace recognition to occur +properly. We recommend copying and extending the default processors if you +want to do that. (A better idea is to save these marker types for later +examination by calling jpeg_save_markers(); that method doesn't interfere +with the library's own processing of these markers.) + +jpeg_set_marker_processor() and jpeg_save_markers() are mutually exclusive +--- if you call one it overrides any previous call to the other, for the +particular marker type specified. + +A simple example of an external COM processor can be found in djpeg.c. +Also, see jpegtran.c for an example of using jpeg_save_markers. + + +Raw (downsampled) image data +---------------------------- + +Some applications need to supply already-downsampled image data to the JPEG +compressor, or to receive raw downsampled data from the decompressor. The +library supports this requirement by allowing the application to write or +read raw data, bypassing the normal preprocessing or postprocessing steps. +The interface is different from the standard one and is somewhat harder to +use. If your interest is merely in bypassing color conversion, we recommend +that you use the standard interface and simply set jpeg_color_space = +in_color_space (or jpeg_color_space = out_color_space for decompression). +The mechanism described in this section is necessary only to supply or +receive downsampled image data, in which not all components have the same +dimensions. + + +To compress raw data, you must supply the data in the colorspace to be used +in the JPEG file (please read the earlier section on Special color spaces) +and downsampled to the sampling factors specified in the JPEG parameters. +You must supply the data in the format used internally by the JPEG library, +namely a JSAMPIMAGE array. This is an array of pointers to two-dimensional +arrays, each of type JSAMPARRAY. Each 2-D array holds the values for one +color component. This structure is necessary since the components are of +different sizes. If the image dimensions are not a multiple of the MCU size, +you must also pad the data correctly (usually, this is done by replicating +the last column and/or row). The data must be padded to a multiple of a DCT +block in each component: that is, each downsampled row must contain a +multiple of 8 valid samples, and there must be a multiple of 8 sample rows +for each component. (For applications such as conversion of digital TV +images, the standard image size is usually a multiple of the DCT block size, +so that no padding need actually be done.) + +The procedure for compression of raw data is basically the same as normal +compression, except that you call jpeg_write_raw_data() in place of +jpeg_write_scanlines(). Before calling jpeg_start_compress(), you must do +the following: + * Set cinfo->raw_data_in to TRUE. (It is set FALSE by jpeg_set_defaults().) + This notifies the library that you will be supplying raw data. + Furthermore, set cinfo->do_fancy_downsampling to FALSE if you want to use + real downsampled data. (It is set TRUE by jpeg_set_defaults().) + * Ensure jpeg_color_space is correct --- an explicit jpeg_set_colorspace() + call is a good idea. Note that since color conversion is bypassed, + in_color_space is ignored, except that jpeg_set_defaults() uses it to + choose the default jpeg_color_space setting. + * Ensure the sampling factors, cinfo->comp_info[i].h_samp_factor and + cinfo->comp_info[i].v_samp_factor, are correct. Since these indicate the + dimensions of the data you are supplying, it's wise to set them + explicitly, rather than assuming the library's defaults are what you want. + +To pass raw data to the library, call jpeg_write_raw_data() in place of +jpeg_write_scanlines(). The two routines work similarly except that +jpeg_write_raw_data takes a JSAMPIMAGE data array rather than JSAMPARRAY. +The scanlines count passed to and returned from jpeg_write_raw_data is +measured in terms of the component with the largest v_samp_factor. + +jpeg_write_raw_data() processes one MCU row per call, which is to say +v_samp_factor*DCTSIZE sample rows of each component. The passed num_lines +value must be at least max_v_samp_factor*DCTSIZE, and the return value will +be exactly that amount (or possibly some multiple of that amount, in future +library versions). This is true even on the last call at the bottom of the +image; don't forget to pad your data as necessary. + +The required dimensions of the supplied data can be computed for each +component as + cinfo->comp_info[i].width_in_blocks*DCTSIZE samples per row + cinfo->comp_info[i].height_in_blocks*DCTSIZE rows in image +after jpeg_start_compress() has initialized those fields. If the valid data +is smaller than this, it must be padded appropriately. For some sampling +factors and image sizes, additional dummy DCT blocks are inserted to make +the image a multiple of the MCU dimensions. The library creates such dummy +blocks itself; it does not read them from your supplied data. Therefore you +need never pad by more than DCTSIZE samples. An example may help here. +Assume 2h2v downsampling of YCbCr data, that is + cinfo->comp_info[0].h_samp_factor = 2 for Y + cinfo->comp_info[0].v_samp_factor = 2 + cinfo->comp_info[1].h_samp_factor = 1 for Cb + cinfo->comp_info[1].v_samp_factor = 1 + cinfo->comp_info[2].h_samp_factor = 1 for Cr + cinfo->comp_info[2].v_samp_factor = 1 +and suppose that the nominal image dimensions (cinfo->image_width and +cinfo->image_height) are 101x101 pixels. Then jpeg_start_compress() will +compute downsampled_width = 101 and width_in_blocks = 13 for Y, +downsampled_width = 51 and width_in_blocks = 7 for Cb and Cr (and the same +for the height fields). You must pad the Y data to at least 13*8 = 104 +columns and rows, the Cb/Cr data to at least 7*8 = 56 columns and rows. The +MCU height is max_v_samp_factor = 2 DCT rows so you must pass at least 16 +scanlines on each call to jpeg_write_raw_data(), which is to say 16 actual +sample rows of Y and 8 each of Cb and Cr. A total of 7 MCU rows are needed, +so you must pass a total of 7*16 = 112 "scanlines". The last DCT block row +of Y data is dummy, so it doesn't matter what you pass for it in the data +arrays, but the scanlines count must total up to 112 so that all of the Cb +and Cr data gets passed. + +Output suspension is supported with raw-data compression: if the data +destination module suspends, jpeg_write_raw_data() will return 0. +In this case the same data rows must be passed again on the next call. + + +Decompression with raw data output implies bypassing all postprocessing. +You must deal with the color space and sampling factors present in the +incoming file. If your application only handles, say, 2h1v YCbCr data, +you must check for and fail on other color spaces or other sampling factors. +The library will not convert to a different color space for you. + +To obtain raw data output, set cinfo->raw_data_out = TRUE before +jpeg_start_decompress() (it is set FALSE by jpeg_read_header()). Be sure to +verify that the color space and sampling factors are ones you can handle. +Furthermore, set cinfo->do_fancy_upsampling = FALSE if you want to get real +downsampled data (it is set TRUE by jpeg_read_header()). +Then call jpeg_read_raw_data() in place of jpeg_read_scanlines(). The +decompression process is otherwise the same as usual. + +jpeg_read_raw_data() returns one MCU row per call, and thus you must pass a +buffer of at least max_v_samp_factor*DCTSIZE scanlines (scanline counting is +the same as for raw-data compression). The buffer you pass must be large +enough to hold the actual data plus padding to DCT-block boundaries. As with +compression, any entirely dummy DCT blocks are not processed so you need not +allocate space for them, but the total scanline count includes them. The +above example of computing buffer dimensions for raw-data compression is +equally valid for decompression. + +Input suspension is supported with raw-data decompression: if the data source +module suspends, jpeg_read_raw_data() will return 0. You can also use +buffered-image mode to read raw data in multiple passes. + + +Really raw data: DCT coefficients +--------------------------------- + +It is possible to read or write the contents of a JPEG file as raw DCT +coefficients. This facility is mainly intended for use in lossless +transcoding between different JPEG file formats. Other possible applications +include lossless cropping of a JPEG image, lossless reassembly of a +multi-strip or multi-tile TIFF/JPEG file into a single JPEG datastream, etc. + +To read the contents of a JPEG file as DCT coefficients, open the file and do +jpeg_read_header() as usual. But instead of calling jpeg_start_decompress() +and jpeg_read_scanlines(), call jpeg_read_coefficients(). This will read the +entire image into a set of virtual coefficient-block arrays, one array per +component. The return value is a pointer to an array of virtual-array +descriptors. Each virtual array can be accessed directly using the JPEG +memory manager's access_virt_barray method (see Memory management, below, +and also read structure.txt's discussion of virtual array handling). Or, +for simple transcoding to a different JPEG file format, the array list can +just be handed directly to jpeg_write_coefficients(). + +Each block in the block arrays contains quantized coefficient values in +normal array order (not JPEG zigzag order). The block arrays contain only +DCT blocks containing real data; any entirely-dummy blocks added to fill out +interleaved MCUs at the right or bottom edges of the image are discarded +during reading and are not stored in the block arrays. (The size of each +block array can be determined from the width_in_blocks and height_in_blocks +fields of the component's comp_info entry.) This is also the data format +expected by jpeg_write_coefficients(). + +When you are done using the virtual arrays, call jpeg_finish_decompress() +to release the array storage and return the decompression object to an idle +state; or just call jpeg_destroy() if you don't need to reuse the object. + +If you use a suspending data source, jpeg_read_coefficients() will return +NULL if it is forced to suspend; a non-NULL return value indicates successful +completion. You need not test for a NULL return value when using a +non-suspending data source. + +It is also possible to call jpeg_read_coefficients() to obtain access to the +decoder's coefficient arrays during a normal decode cycle in buffered-image +mode. This frammish might be useful for progressively displaying an incoming +image and then re-encoding it without loss. To do this, decode in buffered- +image mode as discussed previously, then call jpeg_read_coefficients() after +the last jpeg_finish_output() call. The arrays will be available for your use +until you call jpeg_finish_decompress(). + + +To write the contents of a JPEG file as DCT coefficients, you must provide +the DCT coefficients stored in virtual block arrays. You can either pass +block arrays read from an input JPEG file by jpeg_read_coefficients(), or +allocate virtual arrays from the JPEG compression object and fill them +yourself. In either case, jpeg_write_coefficients() is substituted for +jpeg_start_compress() and jpeg_write_scanlines(). Thus the sequence is + * Create compression object + * Set all compression parameters as necessary + * Request virtual arrays if needed + * jpeg_write_coefficients() + * jpeg_finish_compress() + * Destroy or re-use compression object +jpeg_write_coefficients() is passed a pointer to an array of virtual block +array descriptors; the number of arrays is equal to cinfo.num_components. + +The virtual arrays need only have been requested, not realized, before +jpeg_write_coefficients() is called. A side-effect of +jpeg_write_coefficients() is to realize any virtual arrays that have been +requested from the compression object's memory manager. Thus, when obtaining +the virtual arrays from the compression object, you should fill the arrays +after calling jpeg_write_coefficients(). The data is actually written out +when you call jpeg_finish_compress(); jpeg_write_coefficients() only writes +the file header. + +When writing raw DCT coefficients, it is crucial that the JPEG quantization +tables and sampling factors match the way the data was encoded, or the +resulting file will be invalid. For transcoding from an existing JPEG file, +we recommend using jpeg_copy_critical_parameters(). This routine initializes +all the compression parameters to default values (like jpeg_set_defaults()), +then copies the critical information from a source decompression object. +The decompression object should have just been used to read the entire +JPEG input file --- that is, it should be awaiting jpeg_finish_decompress(). + +jpeg_write_coefficients() marks all tables stored in the compression object +as needing to be written to the output file (thus, it acts like +jpeg_start_compress(cinfo, TRUE)). This is for safety's sake, to avoid +emitting abbreviated JPEG files by accident. If you really want to emit an +abbreviated JPEG file, call jpeg_suppress_tables(), or set the tables' +individual sent_table flags, between calling jpeg_write_coefficients() and +jpeg_finish_compress(). + + +Progress monitoring +------------------- + +Some applications may need to regain control from the JPEG library every so +often. The typical use of this feature is to produce a percent-done bar or +other progress display. (For a simple example, see cjpeg.c or djpeg.c.) +Although you do get control back frequently during the data-transferring pass +(the jpeg_read_scanlines or jpeg_write_scanlines loop), any additional passes +will occur inside jpeg_finish_compress or jpeg_start_decompress; those +routines may take a long time to execute, and you don't get control back +until they are done. + +You can define a progress-monitor routine which will be called periodically +by the library. No guarantees are made about how often this call will occur, +so we don't recommend you use it for mouse tracking or anything like that. +At present, a call will occur once per MCU row, scanline, or sample row +group, whichever unit is convenient for the current processing mode; so the +wider the image, the longer the time between calls. During the data +transferring pass, only one call occurs per call of jpeg_read_scanlines or +jpeg_write_scanlines, so don't pass a large number of scanlines at once if +you want fine resolution in the progress count. (If you really need to use +the callback mechanism for time-critical tasks like mouse tracking, you could +insert additional calls inside some of the library's inner loops.) + +To establish a progress-monitor callback, create a struct jpeg_progress_mgr, +fill in its progress_monitor field with a pointer to your callback routine, +and set cinfo->progress to point to the struct. The callback will be called +whenever cinfo->progress is non-NULL. (This pointer is set to NULL by +jpeg_create_compress or jpeg_create_decompress; the library will not change +it thereafter. So if you allocate dynamic storage for the progress struct, +make sure it will live as long as the JPEG object does. Allocating from the +JPEG memory manager with lifetime JPOOL_PERMANENT will work nicely.) You +can use the same callback routine for both compression and decompression. + +The jpeg_progress_mgr struct contains four fields which are set by the library: + long pass_counter; /* work units completed in this pass */ + long pass_limit; /* total number of work units in this pass */ + int completed_passes; /* passes completed so far */ + int total_passes; /* total number of passes expected */ +During any one pass, pass_counter increases from 0 up to (not including) +pass_limit; the step size is usually but not necessarily 1. The pass_limit +value may change from one pass to another. The expected total number of +passes is in total_passes, and the number of passes already completed is in +completed_passes. Thus the fraction of work completed may be estimated as + completed_passes + (pass_counter/pass_limit) + -------------------------------------------- + total_passes +ignoring the fact that the passes may not be equal amounts of work. + +When decompressing, pass_limit can even change within a pass, because it +depends on the number of scans in the JPEG file, which isn't always known in +advance. The computed fraction-of-work-done may jump suddenly (if the library +discovers it has overestimated the number of scans) or even decrease (in the +opposite case). It is not wise to put great faith in the work estimate. + +When using the decompressor's buffered-image mode, the progress monitor work +estimate is likely to be completely unhelpful, because the library has no way +to know how many output passes will be demanded of it. Currently, the library +sets total_passes based on the assumption that there will be one more output +pass if the input file end hasn't yet been read (jpeg_input_complete() isn't +TRUE), but no more output passes if the file end has been reached when the +output pass is started. This means that total_passes will rise as additional +output passes are requested. If you have a way of determining the input file +size, estimating progress based on the fraction of the file that's been read +will probably be more useful than using the library's value. + + +Memory management +----------------- + +This section covers some key facts about the JPEG library's built-in memory +manager. For more info, please read structure.txt's section about the memory +manager, and consult the source code if necessary. + +All memory and temporary file allocation within the library is done via the +memory manager. If necessary, you can replace the "back end" of the memory +manager to control allocation yourself (for example, if you don't want the +library to use malloc() and free() for some reason). + +Some data is allocated "permanently" and will not be freed until the JPEG +object is destroyed. Most data is allocated "per image" and is freed by +jpeg_finish_compress, jpeg_finish_decompress, or jpeg_abort. You can call the +memory manager yourself to allocate structures that will automatically be +freed at these times. Typical code for this is + ptr = (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, size); +Use JPOOL_PERMANENT to get storage that lasts as long as the JPEG object. +Use alloc_large instead of alloc_small for anything bigger than a few Kbytes. +There are also alloc_sarray and alloc_barray routines that automatically +build 2-D sample or block arrays. + +The library's minimum space requirements to process an image depend on the +image's width, but not on its height, because the library ordinarily works +with "strip" buffers that are as wide as the image but just a few rows high. +Some operating modes (eg, two-pass color quantization) require full-image +buffers. Such buffers are treated as "virtual arrays": only the current strip +need be in memory, and the rest can be swapped out to a temporary file. + +If you use the simplest memory manager back end (jmemnobs.c), then no +temporary files are used; virtual arrays are simply malloc()'d. Images bigger +than memory can be processed only if your system supports virtual memory. +The other memory manager back ends support temporary files of various flavors +and thus work in machines without virtual memory. They may also be useful on +Unix machines if you need to process images that exceed available swap space. + +When using temporary files, the library will make the in-memory buffers for +its virtual arrays just big enough to stay within a "maximum memory" setting. +Your application can set this limit by setting cinfo->mem->max_memory_to_use +after creating the JPEG object. (Of course, there is still a minimum size for +the buffers, so the max-memory setting is effective only if it is bigger than +the minimum space needed.) If you allocate any large structures yourself, you +must allocate them before jpeg_start_compress() or jpeg_start_decompress() in +order to have them counted against the max memory limit. Also keep in mind +that space allocated with alloc_small() is ignored, on the assumption that +it's too small to be worth worrying about; so a reasonable safety margin +should be left when setting max_memory_to_use. + +If you use the jmemname.c or jmemdos.c memory manager back end, it is +important to clean up the JPEG object properly to ensure that the temporary +files get deleted. (This is especially crucial with jmemdos.c, where the +"temporary files" may be extended-memory segments; if they are not freed, +DOS will require a reboot to recover the memory.) Thus, with these memory +managers, it's a good idea to provide a signal handler that will trap any +early exit from your program. The handler should call either jpeg_abort() +or jpeg_destroy() for any active JPEG objects. A handler is not needed with +jmemnobs.c, and shouldn't be necessary with jmemansi.c or jmemmac.c either, +since the C library is supposed to take care of deleting files made with +tmpfile(). + + +Memory usage +------------ + +Working memory requirements while performing compression or decompression +depend on image dimensions, image characteristics (such as colorspace and +JPEG process), and operating mode (application-selected options). + +As of v6b, the decompressor requires: + 1. About 24K in more-or-less-fixed-size data. This varies a bit depending + on operating mode and image characteristics (particularly color vs. + grayscale), but it doesn't depend on image dimensions. + 2. Strip buffers (of size proportional to the image width) for IDCT and + upsampling results. The worst case for commonly used sampling factors + is about 34 bytes * width in pixels for a color image. A grayscale image + only needs about 8 bytes per pixel column. + 3. A full-image DCT coefficient buffer is needed to decode a multi-scan JPEG + file (including progressive JPEGs), or whenever you select buffered-image + mode. This takes 2 bytes/coefficient. At typical 2x2 sampling, that's + 3 bytes per pixel for a color image. Worst case (1x1 sampling) requires + 6 bytes/pixel. For grayscale, figure 2 bytes/pixel. + 4. To perform 2-pass color quantization, the decompressor also needs a + 128K color lookup table and a full-image pixel buffer (3 bytes/pixel). +This does not count any memory allocated by the application, such as a +buffer to hold the final output image. + +The above figures are valid for 8-bit JPEG data precision and a machine with +32-bit ints. For 12-bit JPEG data, double the size of the strip buffers and +quantization pixel buffer. The "fixed-size" data will be somewhat smaller +with 16-bit ints, larger with 64-bit ints. Also, CMYK or other unusual +color spaces will require different amounts of space. + +The full-image coefficient and pixel buffers, if needed at all, do not +have to be fully RAM resident; you can have the library use temporary +files instead when the total memory usage would exceed a limit you set. +(But if your OS supports virtual memory, it's probably better to just use +jmemnobs and let the OS do the swapping.) + +The compressor's memory requirements are similar, except that it has no need +for color quantization. Also, it needs a full-image DCT coefficient buffer +if Huffman-table optimization is asked for, even if progressive mode is not +requested. + +If you need more detailed information about memory usage in a particular +situation, you can enable the MEM_STATS code in jmemmgr.c. + + +Library compile-time options +---------------------------- + +A number of compile-time options are available by modifying jmorecfg.h. + +The JPEG standard provides for both the baseline 8-bit DCT process and +a 12-bit DCT process. The IJG code supports 12-bit JPEG if you define +BITS_IN_JSAMPLE as 12 rather than 8. Note that this causes JSAMPLE to be +larger than a char, so it affects the surrounding application's image data. +The sample applications cjpeg and djpeg can support 12-bit mode only for PPM +and GIF file formats; you must disable the other file formats to compile a +12-bit cjpeg or djpeg. (install.txt has more information about that.) +At present, a 12-bit library can handle *only* 12-bit images, not both +precisions. (If you need to include both 8- and 12-bit libraries in a single +application, you could probably do it by defining NEED_SHORT_EXTERNAL_NAMES +for just one of the copies. You'd have to access the 8-bit and 12-bit copies +from separate application source files. This is untested ... if you try it, +we'd like to hear whether it works!) + +Note that a 12-bit library always compresses in Huffman optimization mode, +in order to generate valid Huffman tables. This is necessary because our +default Huffman tables only cover 8-bit data. If you need to output 12-bit +files in one pass, you'll have to supply suitable default Huffman tables. +You may also want to supply your own DCT quantization tables; the existing +quality-scaling code has been developed for 8-bit use, and probably doesn't +generate especially good tables for 12-bit. + +The maximum number of components (color channels) in the image is determined +by MAX_COMPONENTS. The JPEG standard allows up to 255 components, but we +expect that few applications will need more than four or so. + +On machines with unusual data type sizes, you may be able to improve +performance or reduce memory space by tweaking the various typedefs in +jmorecfg.h. In particular, on some RISC CPUs, access to arrays of "short"s +is quite slow; consider trading memory for speed by making JCOEF, INT16, and +UINT16 be "int" or "unsigned int". UINT8 is also a candidate to become int. +You probably don't want to make JSAMPLE be int unless you have lots of memory +to burn. + +You can reduce the size of the library by compiling out various optional +functions. To do this, undefine xxx_SUPPORTED symbols as necessary. + +You can also save a few K by not having text error messages in the library; +the standard error message table occupies about 5Kb. This is particularly +reasonable for embedded applications where there's no good way to display +a message anyway. To do this, remove the creation of the message table +(jpeg_std_message_table[]) from jerror.c, and alter format_message to do +something reasonable without it. You could output the numeric value of the +message code number, for example. If you do this, you can also save a couple +more K by modifying the TRACEMSn() macros in jerror.h to expand to nothing; +you don't need trace capability anyway, right? + + +Portability considerations +-------------------------- + +The JPEG library has been written to be extremely portable; the sample +applications cjpeg and djpeg are slightly less so. This section summarizes +the design goals in this area. (If you encounter any bugs that cause the +library to be less portable than is claimed here, we'd appreciate hearing +about them.) + +The code works fine on ANSI C, C++, and pre-ANSI C compilers, using any of +the popular system include file setups, and some not-so-popular ones too. +See install.txt for configuration procedures. + +The code is not dependent on the exact sizes of the C data types. As +distributed, we make the assumptions that + char is at least 8 bits wide + short is at least 16 bits wide + int is at least 16 bits wide + long is at least 32 bits wide +(These are the minimum requirements of the ANSI C standard.) Wider types will +work fine, although memory may be used inefficiently if char is much larger +than 8 bits or short is much bigger than 16 bits. The code should work +equally well with 16- or 32-bit ints. + +In a system where these assumptions are not met, you may be able to make the +code work by modifying the typedefs in jmorecfg.h. However, you will probably +have difficulty if int is less than 16 bits wide, since references to plain +int abound in the code. + +char can be either signed or unsigned, although the code runs faster if an +unsigned char type is available. If char is wider than 8 bits, you will need +to redefine JOCTET and/or provide custom data source/destination managers so +that JOCTET represents exactly 8 bits of data on external storage. + +The JPEG library proper does not assume ASCII representation of characters. +But some of the image file I/O modules in cjpeg/djpeg do have ASCII +dependencies in file-header manipulation; so does cjpeg's select_file_type() +routine. + +The JPEG library does not rely heavily on the C library. In particular, C +stdio is used only by the data source/destination modules and the error +handler, all of which are application-replaceable. (cjpeg/djpeg are more +heavily dependent on stdio.) malloc and free are called only from the memory +manager "back end" module, so you can use a different memory allocator by +replacing that one file. + +The code generally assumes that C names must be unique in the first 15 +characters. However, global function names can be made unique in the +first 6 characters by defining NEED_SHORT_EXTERNAL_NAMES. + +More info about porting the code may be gleaned by reading jconfig.txt, +jmorecfg.h, and jinclude.h. + + +Notes for MS-DOS implementors +----------------------------- + +The IJG code is designed to work efficiently in 80x86 "small" or "medium" +memory models (i.e., data pointers are 16 bits unless explicitly declared +"far"; code pointers can be either size). You may be able to use small +model to compile cjpeg or djpeg by itself, but you will probably have to use +medium model for any larger application. This won't make much difference in +performance. You *will* take a noticeable performance hit if you use a +large-data memory model (perhaps 10%-25%), and you should avoid "huge" model +if at all possible. + +The JPEG library typically needs 2Kb-3Kb of stack space. It will also +malloc about 20K-30K of near heap space while executing (and lots of far +heap, but that doesn't count in this calculation). This figure will vary +depending on selected operating mode, and to a lesser extent on image size. +There is also about 5Kb-6Kb of constant data which will be allocated in the +near data segment (about 4Kb of this is the error message table). +Thus you have perhaps 20K available for other modules' static data and near +heap space before you need to go to a larger memory model. The C library's +static data will account for several K of this, but that still leaves a good +deal for your needs. (If you are tight on space, you could reduce the sizes +of the I/O buffers allocated by jdatasrc.c and jdatadst.c, say from 4K to +1K. Another possibility is to move the error message table to far memory; +this should be doable with only localized hacking on jerror.c.) + +About 2K of the near heap space is "permanent" memory that will not be +released until you destroy the JPEG object. This is only an issue if you +save a JPEG object between compression or decompression operations. + +Far data space may also be a tight resource when you are dealing with large +images. The most memory-intensive case is decompression with two-pass color +quantization, or single-pass quantization to an externally supplied color +map. This requires a 128Kb color lookup table plus strip buffers amounting +to about 40 bytes per column for typical sampling ratios (eg, about 25600 +bytes for a 640-pixel-wide image). You may not be able to process wide +images if you have large data structures of your own. + +Of course, all of these concerns vanish if you use a 32-bit flat-memory-model +compiler, such as DJGPP or Watcom C. We highly recommend flat model if you +can use it; the JPEG library is significantly faster in flat model. diff --git a/plugins/AdvaImg/src/LibJPEG/structure.txt b/plugins/AdvaImg/src/LibJPEG/structure.txt new file mode 100644 index 0000000000..ae9f89f6df --- /dev/null +++ b/plugins/AdvaImg/src/LibJPEG/structure.txt @@ -0,0 +1,941 @@ +IJG JPEG LIBRARY: SYSTEM ARCHITECTURE + +Copyright (C) 1991-2012, Thomas G. Lane, Guido Vollbeding. +This file is part of the Independent JPEG Group's software. +For conditions of distribution and use, see the accompanying README file. + + +This file provides an overview of the architecture of the IJG JPEG software; +that is, the functions of the various modules in the system and the interfaces +between modules. For more precise details about any data structure or calling +convention, see the include files and comments in the source code. + +We assume that the reader is already somewhat familiar with the JPEG standard. +The README file includes references for learning about JPEG. The file +libjpeg.txt describes the library from the viewpoint of an application +programmer using the library; it's best to read that file before this one. +Also, the file coderules.txt describes the coding style conventions we use. + +In this document, JPEG-specific terminology follows the JPEG standard: + A "component" means a color channel, e.g., Red or Luminance. + A "sample" is a single component value (i.e., one number in the image data). + A "coefficient" is a frequency coefficient (a DCT transform output number). + A "block" is an array of samples or coefficients. + An "MCU" (minimum coded unit) is an interleaved set of blocks of size + determined by the sampling factors, or a single block in a + noninterleaved scan. +We do not use the terms "pixel" and "sample" interchangeably. When we say +pixel, we mean an element of the full-size image, while a sample is an element +of the downsampled image. Thus the number of samples may vary across +components while the number of pixels does not. (This terminology is not used +rigorously throughout the code, but it is used in places where confusion would +otherwise result.) + + +*** System features *** + +The IJG distribution contains two parts: + * A subroutine library for JPEG compression and decompression. + * cjpeg/djpeg, two sample applications that use the library to transform + JFIF JPEG files to and from several other image formats. +cjpeg/djpeg are of no great intellectual complexity: they merely add a simple +command-line user interface and I/O routines for several uncompressed image +formats. This document concentrates on the library itself. + +We desire the library to be capable of supporting all JPEG baseline, extended +sequential, and progressive DCT processes. The library does not support the +hierarchical or lossless processes defined in the standard. + +Within these limits, any set of compression parameters allowed by the JPEG +spec should be readable for decompression. (We can be more restrictive about +what formats we can generate.) Although the system design allows for all +parameter values, some uncommon settings are not yet implemented and may +never be; nonintegral sampling ratios are the prime example. Furthermore, +we treat 8-bit vs. 12-bit data precision as a compile-time switch, not a +run-time option, because most machines can store 8-bit pixels much more +compactly than 12-bit. + +By itself, the library handles only interchange JPEG datastreams --- in +particular the widely used JFIF file format. The library can be used by +surrounding code to process interchange or abbreviated JPEG datastreams that +are embedded in more complex file formats. (For example, libtiff uses this +library to implement JPEG compression within the TIFF file format.) + +The library includes a substantial amount of code that is not covered by the +JPEG standard but is necessary for typical applications of JPEG. These +functions preprocess the image before JPEG compression or postprocess it after +decompression. They include colorspace conversion, downsampling/upsampling, +and color quantization. This code can be omitted if not needed. + +A wide range of quality vs. speed tradeoffs are possible in JPEG processing, +and even more so in decompression postprocessing. The decompression library +provides multiple implementations that cover most of the useful tradeoffs, +ranging from very-high-quality down to fast-preview operation. On the +compression side we have generally not provided low-quality choices, since +compression is normally less time-critical. It should be understood that the +low-quality modes may not meet the JPEG standard's accuracy requirements; +nonetheless, they are useful for viewers. + + +*** Portability issues *** + +Portability is an essential requirement for the library. The key portability +issues that show up at the level of system architecture are: + +1. Memory usage. We want the code to be able to run on PC-class machines +with limited memory. Images should therefore be processed sequentially (in +strips), to avoid holding the whole image in memory at once. Where a +full-image buffer is necessary, we should be able to use either virtual memory +or temporary files. + +2. Near/far pointer distinction. To run efficiently on 80x86 machines, the +code should distinguish "small" objects (kept in near data space) from +"large" ones (kept in far data space). This is an annoying restriction, but +fortunately it does not impact code quality for less brain-damaged machines, +and the source code clutter turns out to be minimal with sufficient use of +pointer typedefs. + +3. Data precision. We assume that "char" is at least 8 bits, "short" and +"int" at least 16, "long" at least 32. The code will work fine with larger +data sizes, although memory may be used inefficiently in some cases. However, +the JPEG compressed datastream must ultimately appear on external storage as a +sequence of 8-bit bytes if it is to conform to the standard. This may pose a +problem on machines where char is wider than 8 bits. The library represents +compressed data as an array of values of typedef JOCTET. If no data type +exactly 8 bits wide is available, custom data source and data destination +modules must be written to unpack and pack the chosen JOCTET datatype into +8-bit external representation. + + +*** System overview *** + +The compressor and decompressor are each divided into two main sections: +the JPEG compressor or decompressor proper, and the preprocessing or +postprocessing functions. The interface between these two sections is the +image data that the official JPEG spec regards as its input or output: this +data is in the colorspace to be used for compression, and it is downsampled +to the sampling factors to be used. The preprocessing and postprocessing +steps are responsible for converting a normal image representation to or from +this form. (Those few applications that want to deal with YCbCr downsampled +data can skip the preprocessing or postprocessing step.) + +Looking more closely, the compressor library contains the following main +elements: + + Preprocessing: + * Color space conversion (e.g., RGB to YCbCr). + * Edge expansion and downsampling. Optionally, this step can do simple + smoothing --- this is often helpful for low-quality source data. + JPEG proper: + * MCU assembly, DCT, quantization. + * Entropy coding (sequential or progressive, Huffman or arithmetic). + +In addition to these modules we need overall control, marker generation, +and support code (memory management & error handling). There is also a +module responsible for physically writing the output data --- typically +this is just an interface to fwrite(), but some applications may need to +do something else with the data. + +The decompressor library contains the following main elements: + + JPEG proper: + * Entropy decoding (sequential or progressive, Huffman or arithmetic). + * Dequantization, inverse DCT, MCU disassembly. + Postprocessing: + * Upsampling. Optionally, this step may be able to do more general + rescaling of the image. + * Color space conversion (e.g., YCbCr to RGB). This step may also + provide gamma adjustment [ currently it does not ]. + * Optional color quantization (e.g., reduction to 256 colors). + * Optional color precision reduction (e.g., 24-bit to 15-bit color). + [This feature is not currently implemented.] + +We also need overall control, marker parsing, and a data source module. +The support code (memory management & error handling) can be shared with +the compression half of the library. + +There may be several implementations of each of these elements, particularly +in the decompressor, where a wide range of speed/quality tradeoffs is very +useful. It must be understood that some of the best speedups involve +merging adjacent steps in the pipeline. For example, upsampling, color space +conversion, and color quantization might all be done at once when using a +low-quality ordered-dither technique. The system architecture is designed to +allow such merging where appropriate. + + +Note: it is convenient to regard edge expansion (padding to block boundaries) +as a preprocessing/postprocessing function, even though the JPEG spec includes +it in compression/decompression. We do this because downsampling/upsampling +can be simplified a little if they work on padded data: it's not necessary to +have special cases at the right and bottom edges. Therefore the interface +buffer is always an integral number of blocks wide and high, and we expect +compression preprocessing to pad the source data properly. Padding will occur +only to the next block (N-sample) boundary. In an interleaved-scan situation, +additional dummy blocks may be used to fill out MCUs, but the MCU assembly and +disassembly logic will create or discard these blocks internally. (This is +advantageous for speed reasons, since we avoid DCTing the dummy blocks. +It also permits a small reduction in file size, because the compressor can +choose dummy block contents so as to minimize their size in compressed form. +Finally, it makes the interface buffer specification independent of whether +the file is actually interleaved or not.) Applications that wish to deal +directly with the downsampled data must provide similar buffering and padding +for odd-sized images. + + +*** Poor man's object-oriented programming *** + +It should be clear by now that we have a lot of quasi-independent processing +steps, many of which have several possible behaviors. To avoid cluttering the +code with lots of switch statements, we use a simple form of object-style +programming to separate out the different possibilities. + +For example, two different color quantization algorithms could be implemented +as two separate modules that present the same external interface; at runtime, +the calling code will access the proper module indirectly through an "object". + +We can get the limited features we need while staying within portable C. +The basic tool is a function pointer. An "object" is just a struct +containing one or more function pointer fields, each of which corresponds to +a method name in real object-oriented languages. During initialization we +fill in the function pointers with references to whichever module we have +determined we need to use in this run. Then invocation of the module is done +by indirecting through a function pointer; on most machines this is no more +expensive than a switch statement, which would be the only other way of +making the required run-time choice. The really significant benefit, of +course, is keeping the source code clean and well structured. + +We can also arrange to have private storage that varies between different +implementations of the same kind of object. We do this by making all the +module-specific object structs be separately allocated entities, which will +be accessed via pointers in the master compression or decompression struct. +The "public" fields or methods for a given kind of object are specified by +a commonly known struct. But a module's initialization code can allocate +a larger struct that contains the common struct as its first member, plus +additional private fields. With appropriate pointer casting, the module's +internal functions can access these private fields. (For a simple example, +see jdatadst.c, which implements the external interface specified by struct +jpeg_destination_mgr, but adds extra fields.) + +(Of course this would all be a lot easier if we were using C++, but we are +not yet prepared to assume that everyone has a C++ compiler.) + +An important benefit of this scheme is that it is easy to provide multiple +versions of any method, each tuned to a particular case. While a lot of +precalculation might be done to select an optimal implementation of a method, +the cost per invocation is constant. For example, the upsampling step might +have a "generic" method, plus one or more "hardwired" methods for the most +popular sampling factors; the hardwired methods would be faster because they'd +use straight-line code instead of for-loops. The cost to determine which +method to use is paid only once, at startup, and the selection criteria are +hidden from the callers of the method. + +This plan differs a little bit from usual object-oriented structures, in that +only one instance of each object class will exist during execution. The +reason for having the class structure is that on different runs we may create +different instances (choose to execute different modules). You can think of +the term "method" as denoting the common interface presented by a particular +set of interchangeable functions, and "object" as denoting a group of related +methods, or the total shared interface behavior of a group of modules. + + +*** Overall control structure *** + +We previously mentioned the need for overall control logic in the compression +and decompression libraries. In IJG implementations prior to v5, overall +control was mostly provided by "pipeline control" modules, which proved to be +large, unwieldy, and hard to understand. To improve the situation, the +control logic has been subdivided into multiple modules. The control modules +consist of: + +1. Master control for module selection and initialization. This has two +responsibilities: + + 1A. Startup initialization at the beginning of image processing. + The individual processing modules to be used in this run are selected + and given initialization calls. + + 1B. Per-pass control. This determines how many passes will be performed + and calls each active processing module to configure itself + appropriately at the beginning of each pass. End-of-pass processing, + where necessary, is also invoked from the master control module. + + Method selection is partially distributed, in that a particular processing + module may contain several possible implementations of a particular method, + which it will select among when given its initialization call. The master + control code need only be concerned with decisions that affect more than + one module. + +2. Data buffering control. A separate control module exists for each + inter-processing-step data buffer. This module is responsible for + invoking the processing steps that write or read that data buffer. + +Each buffer controller sees the world as follows: + +input data => processing step A => buffer => processing step B => output data + | | | + ------------------ controller ------------------ + +The controller knows the dataflow requirements of steps A and B: how much data +they want to accept in one chunk and how much they output in one chunk. Its +function is to manage its buffer and call A and B at the proper times. + +A data buffer control module may itself be viewed as a processing step by a +higher-level control module; thus the control modules form a binary tree with +elementary processing steps at the leaves of the tree. + +The control modules are objects. A considerable amount of flexibility can +be had by replacing implementations of a control module. For example: +* Merging of adjacent steps in the pipeline is done by replacing a control + module and its pair of processing-step modules with a single processing- + step module. (Hence the possible merges are determined by the tree of + control modules.) +* In some processing modes, a given interstep buffer need only be a "strip" + buffer large enough to accommodate the desired data chunk sizes. In other + modes, a full-image buffer is needed and several passes are required. + The control module determines which kind of buffer is used and manipulates + virtual array buffers as needed. One or both processing steps may be + unaware of the multi-pass behavior. + +In theory, we might be able to make all of the data buffer controllers +interchangeable and provide just one set of implementations for all. In +practice, each one contains considerable special-case processing for its +particular job. The buffer controller concept should be regarded as an +overall system structuring principle, not as a complete description of the +task performed by any one controller. + + +*** Compression object structure *** + +Here is a sketch of the logical structure of the JPEG compression library: + + |-- Colorspace conversion + |-- Preprocessing controller --| + | |-- Downsampling +Main controller --| + | |-- Forward DCT, quantize + |-- Coefficient controller --| + |-- Entropy encoding + +This sketch also describes the flow of control (subroutine calls) during +typical image data processing. Each of the components shown in the diagram is +an "object" which may have several different implementations available. One +or more source code files contain the actual implementation(s) of each object. + +The objects shown above are: + +* Main controller: buffer controller for the subsampled-data buffer, which + holds the preprocessed input data. This controller invokes preprocessing to + fill the subsampled-data buffer, and JPEG compression to empty it. There is + usually no need for a full-image buffer here; a strip buffer is adequate. + +* Preprocessing controller: buffer controller for the downsampling input data + buffer, which lies between colorspace conversion and downsampling. Note + that a unified conversion/downsampling module would probably replace this + controller entirely. + +* Colorspace conversion: converts application image data into the desired + JPEG color space; also changes the data from pixel-interleaved layout to + separate component planes. Processes one pixel row at a time. + +* Downsampling: performs reduction of chroma components as required. + Optionally may perform pixel-level smoothing as well. Processes a "row + group" at a time, where a row group is defined as Vmax pixel rows of each + component before downsampling, and Vk sample rows afterwards (remember Vk + differs across components). Some downsampling or smoothing algorithms may + require context rows above and below the current row group; the + preprocessing controller is responsible for supplying these rows via proper + buffering. The downsampler is responsible for edge expansion at the right + edge (i.e., extending each sample row to a multiple of N samples); but the + preprocessing controller is responsible for vertical edge expansion (i.e., + duplicating the bottom sample row as needed to make a multiple of N rows). + +* Coefficient controller: buffer controller for the DCT-coefficient data. + This controller handles MCU assembly, including insertion of dummy DCT + blocks when needed at the right or bottom edge. When performing + Huffman-code optimization or emitting a multiscan JPEG file, this + controller is responsible for buffering the full image. The equivalent of + one fully interleaved MCU row of subsampled data is processed per call, + even when the JPEG file is noninterleaved. + +* Forward DCT and quantization: Perform DCT, quantize, and emit coefficients. + Works on one or more DCT blocks at a time. (Note: the coefficients are now + emitted in normal array order, which the entropy encoder is expected to + convert to zigzag order as necessary. Prior versions of the IJG code did + the conversion to zigzag order within the quantization step.) + +* Entropy encoding: Perform Huffman or arithmetic entropy coding and emit the + coded data to the data destination module. Works on one MCU per call. + For progressive JPEG, the same DCT blocks are fed to the entropy coder + during each pass, and the coder must emit the appropriate subset of + coefficients. + +In addition to the above objects, the compression library includes these +objects: + +* Master control: determines the number of passes required, controls overall + and per-pass initialization of the other modules. + +* Marker writing: generates JPEG markers (except for RSTn, which is emitted + by the entropy encoder when needed). + +* Data destination manager: writes the output JPEG datastream to its final + destination (e.g., a file). The destination manager supplied with the + library knows how to write to a stdio stream or to a memory buffer; + for other behaviors, the surrounding application may provide its own + destination manager. + +* Memory manager: allocates and releases memory, controls virtual arrays + (with backing store management, where required). + +* Error handler: performs formatting and output of error and trace messages; + determines handling of nonfatal errors. The surrounding application may + override some or all of this object's methods to change error handling. + +* Progress monitor: supports output of "percent-done" progress reports. + This object represents an optional callback to the surrounding application: + if wanted, it must be supplied by the application. + +The error handler, destination manager, and progress monitor objects are +defined as separate objects in order to simplify application-specific +customization of the JPEG library. A surrounding application may override +individual methods or supply its own all-new implementation of one of these +objects. The object interfaces for these objects are therefore treated as +part of the application interface of the library, whereas the other objects +are internal to the library. + +The error handler and memory manager are shared by JPEG compression and +decompression; the progress monitor, if used, may be shared as well. + + +*** Decompression object structure *** + +Here is a sketch of the logical structure of the JPEG decompression library: + + |-- Entropy decoding + |-- Coefficient controller --| + | |-- Dequantize, Inverse DCT +Main controller --| + | |-- Upsampling + |-- Postprocessing controller --| |-- Colorspace conversion + |-- Color quantization + |-- Color precision reduction + +As before, this diagram also represents typical control flow. The objects +shown are: + +* Main controller: buffer controller for the subsampled-data buffer, which + holds the output of JPEG decompression proper. This controller's primary + task is to feed the postprocessing procedure. Some upsampling algorithms + may require context rows above and below the current row group; when this + is true, the main controller is responsible for managing its buffer so as + to make context rows available. In the current design, the main buffer is + always a strip buffer; a full-image buffer is never required. + +* Coefficient controller: buffer controller for the DCT-coefficient data. + This controller handles MCU disassembly, including deletion of any dummy + DCT blocks at the right or bottom edge. When reading a multiscan JPEG + file, this controller is responsible for buffering the full image. + (Buffering DCT coefficients, rather than samples, is necessary to support + progressive JPEG.) The equivalent of one fully interleaved MCU row of + subsampled data is processed per call, even when the source JPEG file is + noninterleaved. + +* Entropy decoding: Read coded data from the data source module and perform + Huffman or arithmetic entropy decoding. Works on one MCU per call. + For progressive JPEG decoding, the coefficient controller supplies the prior + coefficients of each MCU (initially all zeroes), which the entropy decoder + modifies in each scan. + +* Dequantization and inverse DCT: like it says. Note that the coefficients + buffered by the coefficient controller have NOT been dequantized; we + merge dequantization and inverse DCT into a single step for speed reasons. + When scaled-down output is asked for, simplified DCT algorithms may be used + that need fewer coefficients and emit fewer samples per DCT block, not the + full 8x8. Works on one DCT block at a time. + +* Postprocessing controller: buffer controller for the color quantization + input buffer, when quantization is in use. (Without quantization, this + controller just calls the upsampler.) For two-pass quantization, this + controller is responsible for buffering the full-image data. + +* Upsampling: restores chroma components to full size. (May support more + general output rescaling, too. Note that if undersized DCT outputs have + been emitted by the DCT module, this module must adjust so that properly + sized outputs are created.) Works on one row group at a time. This module + also calls the color conversion module, so its top level is effectively a + buffer controller for the upsampling->color conversion buffer. However, in + all but the highest-quality operating modes, upsampling and color + conversion are likely to be merged into a single step. + +* Colorspace conversion: convert from JPEG color space to output color space, + and change data layout from separate component planes to pixel-interleaved. + Works on one pixel row at a time. + +* Color quantization: reduce the data to colormapped form, using either an + externally specified colormap or an internally generated one. This module + is not used for full-color output. Works on one pixel row at a time; may + require two passes to generate a color map. Note that the output will + always be a single component representing colormap indexes. In the current + design, the output values are JSAMPLEs, so an 8-bit compilation cannot + quantize to more than 256 colors. This is unlikely to be a problem in + practice. + +* Color reduction: this module handles color precision reduction, e.g., + generating 15-bit color (5 bits/primary) from JPEG's 24-bit output. + Not quite clear yet how this should be handled... should we merge it with + colorspace conversion??? + +Note that some high-speed operating modes might condense the entire +postprocessing sequence to a single module (upsample, color convert, and +quantize in one step). + +In addition to the above objects, the decompression library includes these +objects: + +* Master control: determines the number of passes required, controls overall + and per-pass initialization of the other modules. This is subdivided into + input and output control: jdinput.c controls only input-side processing, + while jdmaster.c handles overall initialization and output-side control. + +* Marker reading: decodes JPEG markers (except for RSTn). + +* Data source manager: supplies the input JPEG datastream. The source + manager supplied with the library knows how to read from a stdio stream + or from a memory buffer; for other behaviors, the surrounding application + may provide its own source manager. + +* Memory manager: same as for compression library. + +* Error handler: same as for compression library. + +* Progress monitor: same as for compression library. + +As with compression, the data source manager, error handler, and progress +monitor are candidates for replacement by a surrounding application. + + +*** Decompression input and output separation *** + +To support efficient incremental display of progressive JPEG files, the +decompressor is divided into two sections that can run independently: + +1. Data input includes marker parsing, entropy decoding, and input into the + coefficient controller's DCT coefficient buffer. Note that this + processing is relatively cheap and fast. + +2. Data output reads from the DCT coefficient buffer and performs the IDCT + and all postprocessing steps. + +For a progressive JPEG file, the data input processing is allowed to get +arbitrarily far ahead of the data output processing. (This occurs only +if the application calls jpeg_consume_input(); otherwise input and output +run in lockstep, since the input section is called only when the output +section needs more data.) In this way the application can avoid making +extra display passes when data is arriving faster than the display pass +can run. Furthermore, it is possible to abort an output pass without +losing anything, since the coefficient buffer is read-only as far as the +output section is concerned. See libjpeg.txt for more detail. + +A full-image coefficient array is only created if the JPEG file has multiple +scans (or if the application specifies buffered-image mode anyway). When +reading a single-scan file, the coefficient controller normally creates only +a one-MCU buffer, so input and output processing must run in lockstep in this +case. jpeg_consume_input() is effectively a no-op in this situation. + +The main impact of dividing the decompressor in this fashion is that we must +be very careful with shared variables in the cinfo data structure. Each +variable that can change during the course of decompression must be +classified as belonging to data input or data output, and each section must +look only at its own variables. For example, the data output section may not +depend on any of the variables that describe the current scan in the JPEG +file, because these may change as the data input section advances into a new +scan. + +The progress monitor is (somewhat arbitrarily) defined to treat input of the +file as one pass when buffered-image mode is not used, and to ignore data +input work completely when buffered-image mode is used. Note that the +library has no reliable way to predict the number of passes when dealing +with a progressive JPEG file, nor can it predict the number of output passes +in buffered-image mode. So the work estimate is inherently bogus anyway. + +No comparable division is currently made in the compression library, because +there isn't any real need for it. + + +*** Data formats *** + +Arrays of pixel sample values use the following data structure: + + typedef something JSAMPLE; a pixel component value, 0..MAXJSAMPLE + typedef JSAMPLE *JSAMPROW; ptr to a row of samples + typedef JSAMPROW *JSAMPARRAY; ptr to a list of rows + typedef JSAMPARRAY *JSAMPIMAGE; ptr to a list of color-component arrays + +The basic element type JSAMPLE will typically be one of unsigned char, +(signed) char, or short. Short will be used if samples wider than 8 bits are +to be supported (this is a compile-time option). Otherwise, unsigned char is +used if possible. If the compiler only supports signed chars, then it is +necessary to mask off the value when reading. Thus, all reads of JSAMPLE +values must be coded as "GETJSAMPLE(value)", where the macro will be defined +as "((value) & 0xFF)" on signed-char machines and "((int) (value))" elsewhere. + +With these conventions, JSAMPLE values can be assumed to be >= 0. This helps +simplify correct rounding during downsampling, etc. The JPEG standard's +specification that sample values run from -128..127 is accommodated by +subtracting 128 from the sample value in the DCT step. Similarly, during +decompression the output of the IDCT step will be immediately shifted back to +0..255. (NB: different values are required when 12-bit samples are in use. +The code is written in terms of MAXJSAMPLE and CENTERJSAMPLE, which will be +defined as 255 and 128 respectively in an 8-bit implementation, and as 4095 +and 2048 in a 12-bit implementation.) + +We use a pointer per row, rather than a two-dimensional JSAMPLE array. This +choice costs only a small amount of memory and has several benefits: +* Code using the data structure doesn't need to know the allocated width of + the rows. This simplifies edge expansion/compression, since we can work + in an array that's wider than the logical picture width. +* Indexing doesn't require multiplication; this is a performance win on many + machines. +* Arrays with more than 64K total elements can be supported even on machines + where malloc() cannot allocate chunks larger than 64K. +* The rows forming a component array may be allocated at different times + without extra copying. This trick allows some speedups in smoothing steps + that need access to the previous and next rows. + +Note that each color component is stored in a separate array; we don't use the +traditional layout in which the components of a pixel are stored together. +This simplifies coding of modules that work on each component independently, +because they don't need to know how many components there are. Furthermore, +we can read or write each component to a temporary file independently, which +is helpful when dealing with noninterleaved JPEG files. + +In general, a specific sample value is accessed by code such as + GETJSAMPLE(image[colorcomponent][row][col]) +where col is measured from the image left edge, but row is measured from the +first sample row currently in memory. Either of the first two indexings can +be precomputed by copying the relevant pointer. + + +Since most image-processing applications prefer to work on images in which +the components of a pixel are stored together, the data passed to or from the +surrounding application uses the traditional convention: a single pixel is +represented by N consecutive JSAMPLE values, and an image row is an array of +(# of color components)*(image width) JSAMPLEs. One or more rows of data can +be represented by a pointer of type JSAMPARRAY in this scheme. This scheme is +converted to component-wise storage inside the JPEG library. (Applications +that want to skip JPEG preprocessing or postprocessing will have to contend +with component-wise storage.) + + +Arrays of DCT-coefficient values use the following data structure: + + typedef short JCOEF; a 16-bit signed integer + typedef JCOEF JBLOCK[DCTSIZE2]; an 8x8 block of coefficients + typedef JBLOCK *JBLOCKROW; ptr to one horizontal row of 8x8 blocks + typedef JBLOCKROW *JBLOCKARRAY; ptr to a list of such rows + typedef JBLOCKARRAY *JBLOCKIMAGE; ptr to a list of color component arrays + +The underlying type is at least a 16-bit signed integer; while "short" is big +enough on all machines of interest, on some machines it is preferable to use +"int" for speed reasons, despite the storage cost. Coefficients are grouped +into 8x8 blocks (but we always use #defines DCTSIZE and DCTSIZE2 rather than +"8" and "64"). + +The contents of a coefficient block may be in either "natural" or zigzagged +order, and may be true values or divided by the quantization coefficients, +depending on where the block is in the processing pipeline. In the current +library, coefficient blocks are kept in natural order everywhere; the entropy +codecs zigzag or dezigzag the data as it is written or read. The blocks +contain quantized coefficients everywhere outside the DCT/IDCT subsystems. +(This latter decision may need to be revisited to support variable +quantization a la JPEG Part 3.) + +Notice that the allocation unit is now a row of 8x8 coefficient blocks, +corresponding to N rows of samples. Otherwise the structure is much the same +as for samples, and for the same reasons. + +On machines where malloc() can't handle a request bigger than 64Kb, this data +structure limits us to rows of less than 512 JBLOCKs, or a picture width of +4000+ pixels. This seems an acceptable restriction. + + +On 80x86 machines, the bottom-level pointer types (JSAMPROW and JBLOCKROW) +must be declared as "far" pointers, but the upper levels can be "near" +(implying that the pointer lists are allocated in the DS segment). +We use a #define symbol FAR, which expands to the "far" keyword when +compiling on 80x86 machines and to nothing elsewhere. + + +*** Suspendable processing *** + +In some applications it is desirable to use the JPEG library as an +incremental, memory-to-memory filter. In this situation the data source or +destination may be a limited-size buffer, and we can't rely on being able to +empty or refill the buffer at arbitrary times. Instead the application would +like to have control return from the library at buffer overflow/underrun, and +then resume compression or decompression at a later time. + +This scenario is supported for simple cases. (For anything more complex, we +recommend that the application "bite the bullet" and develop real multitasking +capability.) The libjpeg.txt file goes into more detail about the usage and +limitations of this capability; here we address the implications for library +structure. + +The essence of the problem is that the entropy codec (coder or decoder) must +be prepared to stop at arbitrary times. In turn, the controllers that call +the entropy codec must be able to stop before having produced or consumed all +the data that they normally would handle in one call. That part is reasonably +straightforward: we make the controller call interfaces include "progress +counters" which indicate the number of data chunks successfully processed, and +we require callers to test the counter rather than just assume all of the data +was processed. + +Rather than trying to restart at an arbitrary point, the current Huffman +codecs are designed to restart at the beginning of the current MCU after a +suspension due to buffer overflow/underrun. At the start of each call, the +codec's internal state is loaded from permanent storage (in the JPEG object +structures) into local variables. On successful completion of the MCU, the +permanent state is updated. (This copying is not very expensive, and may even +lead to *improved* performance if the local variables can be registerized.) +If a suspension occurs, the codec simply returns without updating the state, +thus effectively reverting to the start of the MCU. Note that this implies +leaving some data unprocessed in the source/destination buffer (ie, the +compressed partial MCU). The data source/destination module interfaces are +specified so as to make this possible. This also implies that the data buffer +must be large enough to hold a worst-case compressed MCU; a couple thousand +bytes should be enough. + +In a successive-approximation AC refinement scan, the progressive Huffman +decoder has to be able to undo assignments of newly nonzero coefficients if it +suspends before the MCU is complete, since decoding requires distinguishing +previously-zero and previously-nonzero coefficients. This is a bit tedious +but probably won't have much effect on performance. Other variants of Huffman +decoding need not worry about this, since they will just store the same values +again if forced to repeat the MCU. + +This approach would probably not work for an arithmetic codec, since its +modifiable state is quite large and couldn't be copied cheaply. Instead it +would have to suspend and resume exactly at the point of the buffer end. + +The JPEG marker reader is designed to cope with suspension at an arbitrary +point. It does so by backing up to the start of the marker parameter segment, +so the data buffer must be big enough to hold the largest marker of interest. +Again, a couple KB should be adequate. (A special "skip" convention is used +to bypass COM and APPn markers, so these can be larger than the buffer size +without causing problems; otherwise a 64K buffer would be needed in the worst +case.) + +The JPEG marker writer currently does *not* cope with suspension. +We feel that this is not necessary; it is much easier simply to require +the application to ensure there is enough buffer space before starting. (An +empty 2K buffer is more than sufficient for the header markers; and ensuring +there are a dozen or two bytes available before calling jpeg_finish_compress() +will suffice for the trailer.) This would not work for writing multi-scan +JPEG files, but we simply do not intend to support that capability with +suspension. + + +*** Memory manager services *** + +The JPEG library's memory manager controls allocation and deallocation of +memory, and it manages large "virtual" data arrays on machines where the +operating system does not provide virtual memory. Note that the same +memory manager serves both compression and decompression operations. + +In all cases, allocated objects are tied to a particular compression or +decompression master record, and they will be released when that master +record is destroyed. + +The memory manager does not provide explicit deallocation of objects. +Instead, objects are created in "pools" of free storage, and a whole pool +can be freed at once. This approach helps prevent storage-leak bugs, and +it speeds up operations whenever malloc/free are slow (as they often are). +The pools can be regarded as lifetime identifiers for objects. Two +pools/lifetimes are defined: + * JPOOL_PERMANENT lasts until master record is destroyed + * JPOOL_IMAGE lasts until done with image (JPEG datastream) +Permanent lifetime is used for parameters and tables that should be carried +across from one datastream to another; this includes all application-visible +parameters. Image lifetime is used for everything else. (A third lifetime, +JPOOL_PASS = one processing pass, was originally planned. However it was +dropped as not being worthwhile. The actual usage patterns are such that the +peak memory usage would be about the same anyway; and having per-pass storage +substantially complicates the virtual memory allocation rules --- see below.) + +The memory manager deals with three kinds of object: +1. "Small" objects. Typically these require no more than 10K-20K total. +2. "Large" objects. These may require tens to hundreds of K depending on + image size. Semantically they behave the same as small objects, but we + distinguish them for two reasons: + * On MS-DOS machines, large objects are referenced by FAR pointers, + small objects by NEAR pointers. + * Pool allocation heuristics may differ for large and small objects. + Note that individual "large" objects cannot exceed the size allowed by + type size_t, which may be 64K or less on some machines. +3. "Virtual" objects. These are large 2-D arrays of JSAMPLEs or JBLOCKs + (typically large enough for the entire image being processed). The + memory manager provides stripwise access to these arrays. On machines + without virtual memory, the rest of the array may be swapped out to a + temporary file. + +(Note: JSAMPARRAY and JBLOCKARRAY data structures are a combination of large +objects for the data proper and small objects for the row pointers. For +convenience and speed, the memory manager provides single routines to create +these structures. Similarly, virtual arrays include a small control block +and a JSAMPARRAY or JBLOCKARRAY working buffer, all created with one call.) + +In the present implementation, virtual arrays are only permitted to have image +lifespan. (Permanent lifespan would not be reasonable, and pass lifespan is +not very useful since a virtual array's raison d'etre is to store data for +multiple passes through the image.) We also expect that only "small" objects +will be given permanent lifespan, though this restriction is not required by +the memory manager. + +In a non-virtual-memory machine, some performance benefit can be gained by +making the in-memory buffers for virtual arrays be as large as possible. +(For small images, the buffers might fit entirely in memory, so blind +swapping would be very wasteful.) The memory manager will adjust the height +of the buffers to fit within a prespecified maximum memory usage. In order +to do this in a reasonably optimal fashion, the manager needs to allocate all +of the virtual arrays at once. Therefore, there isn't a one-step allocation +routine for virtual arrays; instead, there is a "request" routine that simply +allocates the control block, and a "realize" routine (called just once) that +determines space allocation and creates all of the actual buffers. The +realize routine must allow for space occupied by non-virtual large objects. +(We don't bother to factor in the space needed for small objects, on the +grounds that it isn't worth the trouble.) + +To support all this, we establish the following protocol for doing business +with the memory manager: + 1. Modules must request virtual arrays (which may have only image lifespan) + during the initial setup phase, i.e., in their jinit_xxx routines. + 2. All "large" objects (including JSAMPARRAYs and JBLOCKARRAYs) must also be + allocated during initial setup. + 3. realize_virt_arrays will be called at the completion of initial setup. + The above conventions ensure that sufficient information is available + for it to choose a good size for virtual array buffers. +Small objects of any lifespan may be allocated at any time. We expect that +the total space used for small objects will be small enough to be negligible +in the realize_virt_arrays computation. + +In a virtual-memory machine, we simply pretend that the available space is +infinite, thus causing realize_virt_arrays to decide that it can allocate all +the virtual arrays as full-size in-memory buffers. The overhead of the +virtual-array access protocol is very small when no swapping occurs. + +A virtual array can be specified to be "pre-zeroed"; when this flag is set, +never-yet-written sections of the array are set to zero before being made +available to the caller. If this flag is not set, never-written sections +of the array contain garbage. (This feature exists primarily because the +equivalent logic would otherwise be needed in jdcoefct.c for progressive +JPEG mode; we may as well make it available for possible other uses.) + +The first write pass on a virtual array is required to occur in top-to-bottom +order; read passes, as well as any write passes after the first one, may +access the array in any order. This restriction exists partly to simplify +the virtual array control logic, and partly because some file systems may not +support seeking beyond the current end-of-file in a temporary file. The main +implication of this restriction is that rearrangement of rows (such as +converting top-to-bottom data order to bottom-to-top) must be handled while +reading data out of the virtual array, not while putting it in. + + +*** Memory manager internal structure *** + +To isolate system dependencies as much as possible, we have broken the +memory manager into two parts. There is a reasonably system-independent +"front end" (jmemmgr.c) and a "back end" that contains only the code +likely to change across systems. All of the memory management methods +outlined above are implemented by the front end. The back end provides +the following routines for use by the front end (none of these routines +are known to the rest of the JPEG code): + +jpeg_mem_init, jpeg_mem_term system-dependent initialization/shutdown + +jpeg_get_small, jpeg_free_small interface to malloc and free library routines + (or their equivalents) + +jpeg_get_large, jpeg_free_large interface to FAR malloc/free in MSDOS machines; + else usually the same as + jpeg_get_small/jpeg_free_small + +jpeg_mem_available estimate available memory + +jpeg_open_backing_store create a backing-store object + +read_backing_store, manipulate a backing-store object +write_backing_store, +close_backing_store + +On some systems there will be more than one type of backing-store object +(specifically, in MS-DOS a backing store file might be an area of extended +memory as well as a disk file). jpeg_open_backing_store is responsible for +choosing how to implement a given object. The read/write/close routines +are method pointers in the structure that describes a given object; this +lets them be different for different object types. + +It may be necessary to ensure that backing store objects are explicitly +released upon abnormal program termination. For example, MS-DOS won't free +extended memory by itself. To support this, we will expect the main program +or surrounding application to arrange to call self_destruct (typically via +jpeg_destroy) upon abnormal termination. This may require a SIGINT signal +handler or equivalent. We don't want to have the back end module install its +own signal handler, because that would pre-empt the surrounding application's +ability to control signal handling. + +The IJG distribution includes several memory manager back end implementations. +Usually the same back end should be suitable for all applications on a given +system, but it is possible for an application to supply its own back end at +need. + + +*** Implications of DNL marker *** + +Some JPEG files may use a DNL marker to postpone definition of the image +height (this would be useful for a fax-like scanner's output, for instance). +In these files the SOF marker claims the image height is 0, and you only +find out the true image height at the end of the first scan. + +We could read these files as follows: +1. Upon seeing zero image height, replace it by 65535 (the maximum allowed). +2. When the DNL is found, update the image height in the global image + descriptor. +This implies that control modules must avoid making copies of the image +height, and must re-test for termination after each MCU row. This would +be easy enough to do. + +In cases where image-size data structures are allocated, this approach will +result in very inefficient use of virtual memory or much-larger-than-necessary +temporary files. This seems acceptable for something that probably won't be a +mainstream usage. People might have to forgo use of memory-hogging options +(such as two-pass color quantization or noninterleaved JPEG files) if they +want efficient conversion of such files. (One could improve efficiency by +demanding a user-supplied upper bound for the height, less than 65536; in most +cases it could be much less.) + +The standard also permits the SOF marker to overestimate the image height, +with a DNL to give the true, smaller height at the end of the first scan. +This would solve the space problems if the overestimate wasn't too great. +However, it implies that you don't even know whether DNL will be used. + +This leads to a couple of very serious objections: +1. Testing for a DNL marker must occur in the inner loop of the decompressor's + Huffman decoder; this implies a speed penalty whether the feature is used + or not. +2. There is no way to hide the last-minute change in image height from an + application using the decoder. Thus *every* application using the IJG + library would suffer a complexity penalty whether it cared about DNL or + not. +We currently do not support DNL because of these problems. + +A different approach is to insist that DNL-using files be preprocessed by a +separate program that reads ahead to the DNL, then goes back and fixes the SOF +marker. This is a much simpler solution and is probably far more efficient. +Even if one wants piped input, buffering the first scan of the JPEG file needs +a lot smaller temp file than is implied by the maximum-height method. For +this approach we'd simply treat DNL as a no-op in the decompressor (at most, +check that it matches the SOF image height). + +We will not worry about making the compressor capable of outputting DNL. +Something similar to the first scheme above could be applied if anyone ever +wants to make that work. diff --git a/plugins/AdvaImg/src/LibJPEG/usage.txt b/plugins/AdvaImg/src/LibJPEG/usage.txt new file mode 100644 index 0000000000..c91ddff288 --- /dev/null +++ b/plugins/AdvaImg/src/LibJPEG/usage.txt @@ -0,0 +1,637 @@ +USAGE instructions for the Independent JPEG Group's JPEG software +================================================================= + +This file describes usage of the JPEG conversion programs cjpeg and djpeg, +as well as the utility programs jpegtran, rdjpgcom and wrjpgcom. (See +the other documentation files if you wish to use the JPEG library within +your own programs.) + +If you are on a Unix machine you may prefer to read the Unix-style manual +pages in files cjpeg.1, djpeg.1, jpegtran.1, rdjpgcom.1, wrjpgcom.1. + + +INTRODUCTION + +These programs implement JPEG image encoding, decoding, and transcoding. +JPEG (pronounced "jay-peg") is a standardized compression method for +full-color and gray-scale images. + + +GENERAL USAGE + +We provide two programs, cjpeg to compress an image file into JPEG format, +and djpeg to decompress a JPEG file back into a conventional image format. + +On Unix-like systems, you say: + cjpeg [switches] [imagefile] >jpegfile +or + djpeg [switches] [jpegfile] >imagefile +The programs read the specified input file, or standard input if none is +named. They always write to standard output (with trace/error messages to +standard error). These conventions are handy for piping images between +programs. + +On most non-Unix systems, you say: + cjpeg [switches] imagefile jpegfile +or + djpeg [switches] jpegfile imagefile +i.e., both the input and output files are named on the command line. This +style is a little more foolproof, and it loses no functionality if you don't +have pipes. (You can get this style on Unix too, if you prefer, by defining +TWO_FILE_COMMANDLINE when you compile the programs; see install.txt.) + +You can also say: + cjpeg [switches] -outfile jpegfile imagefile +or + djpeg [switches] -outfile imagefile jpegfile +This syntax works on all systems, so it is useful for scripts. + +The currently supported image file formats are: PPM (PBMPLUS color format), +PGM (PBMPLUS gray-scale format), BMP, Targa, and RLE (Utah Raster Toolkit +format). (RLE is supported only if the URT library is available.) +cjpeg recognizes the input image format automatically, with the exception +of some Targa-format files. You have to tell djpeg which format to generate. + +JPEG files are in the defacto standard JFIF file format. There are other, +less widely used JPEG-based file formats, but we don't support them. + +All switch names may be abbreviated; for example, -grayscale may be written +-gray or -gr. Most of the "basic" switches can be abbreviated to as little as +one letter. Upper and lower case are equivalent (-BMP is the same as -bmp). +British spellings are also accepted (e.g., -greyscale), though for brevity +these are not mentioned below. + + +CJPEG DETAILS + +The basic command line switches for cjpeg are: + + -quality N[,...] Scale quantization tables to adjust image quality. + Quality is 0 (worst) to 100 (best); default is 75. + (See below for more info.) + + -grayscale Create monochrome JPEG file from color input. + Be sure to use this switch when compressing a grayscale + BMP file, because cjpeg isn't bright enough to notice + whether a BMP file uses only shades of gray. By + saying -grayscale, you'll get a smaller JPEG file that + takes less time to process. + + -rgb Create RGB JPEG file. + Using this switch suppresses the conversion from RGB + colorspace input to the default YCbCr JPEG colorspace. + Use this switch in combination with the -block N + switch (see below) for lossless JPEG coding. + + -optimize Perform optimization of entropy encoding parameters. + Without this, default encoding parameters are used. + -optimize usually makes the JPEG file a little smaller, + but cjpeg runs somewhat slower and needs much more + memory. Image quality and speed of decompression are + unaffected by -optimize. + + -progressive Create progressive JPEG file (see below). + + -scale M/N Scale the output image by a factor M/N. Currently + supported scale factors are M/N with all N from 1 to + 16, where M is the destination DCT size, which is 8 by + default (see -block N switch below). + + -targa Input file is Targa format. Targa files that contain + an "identification" field will not be automatically + recognized by cjpeg; for such files you must specify + -targa to make cjpeg treat the input as Targa format. + For most Targa files, you won't need this switch. + +The -quality switch lets you trade off compressed file size against quality of +the reconstructed image: the higher the quality setting, the larger the JPEG +file, and the closer the output image will be to the original input. Normally +you want to use the lowest quality setting (smallest file) that decompresses +into something visually indistinguishable from the original image. For this +purpose the quality setting should be between 50 and 95; the default of 75 is +often about right. If you see defects at -quality 75, then go up 5 or 10 +counts at a time until you are happy with the output image. (The optimal +setting will vary from one image to another.) + +-quality 100 will generate a quantization table of all 1's, minimizing loss +in the quantization step (but there is still information loss in subsampling, +as well as roundoff error). This setting is mainly of interest for +experimental purposes. Quality values above about 95 are NOT recommended for +normal use; the compressed file size goes up dramatically for hardly any gain +in output image quality. + +In the other direction, quality values below 50 will produce very small files +of low image quality. Settings around 5 to 10 might be useful in preparing an +index of a large image library, for example. Try -quality 2 (or so) for some +amusing Cubist effects. (Note: quality values below about 25 generate 2-byte +quantization tables, which are considered optional in the JPEG standard. +cjpeg emits a warning message when you give such a quality value, because some +other JPEG programs may be unable to decode the resulting file. Use -baseline +if you need to ensure compatibility at low quality values.) + +The -quality option has been extended in IJG version 7 for support of separate +quality settings for luminance and chrominance (or in general, for every +provided quantization table slot). This feature is useful for high-quality +applications which cannot accept the damage of color data by coarse +subsampling settings. You can now easily reduce the color data amount more +smoothly with finer control without separate subsampling. The resulting file +is fully compliant with standard JPEG decoders. +Note that the -quality ratings refer to the quantization table slots, and that +the last value is replicated if there are more q-table slots than parameters. +The default q-table slots are 0 for luminance and 1 for chrominance with +default tables as given in the JPEG standard. This is compatible with the old +behaviour in case that only one parameter is given, which is then used for +both luminance and chrominance (slots 0 and 1). More or custom quantization +tables can be set with -qtables and assigned to components with -qslots +parameter (see the "wizard" switches below). +CAUTION: You must explicitly add -sample 1x1 for efficient separate color +quality selection, since the default value used by library is 2x2! + +The -progressive switch creates a "progressive JPEG" file. In this type of +JPEG file, the data is stored in multiple scans of increasing quality. If the +file is being transmitted over a slow communications link, the decoder can use +the first scan to display a low-quality image very quickly, and can then +improve the display with each subsequent scan. The final image is exactly +equivalent to a standard JPEG file of the same quality setting, and the total +file size is about the same --- often a little smaller. + +Switches for advanced users: + + -arithmetic Use arithmetic coding. CAUTION: arithmetic coded JPEG + is not yet widely implemented, so many decoders will + be unable to view an arithmetic coded JPEG file at + all. + + -block N Set DCT block size. All N from 1 to 16 are possible. + Default is 8 (baseline format). + Larger values produce higher compression, + smaller values produce higher quality + (exact DCT stage possible with 1 or 2; with the + default quality of 75 and default Luminance qtable + the DCT+Quantization stage is lossless for N=1). + CAUTION: An implementation of the JPEG SmartScale + extension is required for this feature. SmartScale + enabled JPEG is not yet widely implemented, so many + decoders will be unable to view a SmartScale extended + JPEG file at all. + + -dct int Use integer DCT method (default). + -dct fast Use fast integer DCT (less accurate). + -dct float Use floating-point DCT method. + The float method is very slightly more accurate than + the int method, but is much slower unless your machine + has very fast floating-point hardware. Also note that + results of the floating-point method may vary slightly + across machines, while the integer methods should give + the same results everywhere. The fast integer method + is much less accurate than the other two. + + -nosmooth Don't use high-quality downsampling. + + -restart N Emit a JPEG restart marker every N MCU rows, or every + N MCU blocks if "B" is attached to the number. + -restart 0 (the default) means no restart markers. + + -smooth N Smooth the input image to eliminate dithering noise. + N, ranging from 1 to 100, indicates the strength of + smoothing. 0 (the default) means no smoothing. + + -maxmemory N Set limit for amount of memory to use in processing + large images. Value is in thousands of bytes, or + millions of bytes if "M" is attached to the number. + For example, -max 4m selects 4000000 bytes. If more + space is needed, temporary files will be used. + + -verbose Enable debug printout. More -v's give more printout. + or -debug Also, version information is printed at startup. + +The -restart option inserts extra markers that allow a JPEG decoder to +resynchronize after a transmission error. Without restart markers, any damage +to a compressed file will usually ruin the image from the point of the error +to the end of the image; with restart markers, the damage is usually confined +to the portion of the image up to the next restart marker. Of course, the +restart markers occupy extra space. We recommend -restart 1 for images that +will be transmitted across unreliable networks such as Usenet. + +The -smooth option filters the input to eliminate fine-scale noise. This is +often useful when converting dithered images to JPEG: a moderate smoothing +factor of 10 to 50 gets rid of dithering patterns in the input file, resulting +in a smaller JPEG file and a better-looking image. Too large a smoothing +factor will visibly blur the image, however. + +Switches for wizards: + + -baseline Force baseline-compatible quantization tables to be + generated. This clamps quantization values to 8 bits + even at low quality settings. (This switch is poorly + named, since it does not ensure that the output is + actually baseline JPEG. For example, you can use + -baseline and -progressive together.) + + -qtables file Use the quantization tables given in the specified + text file. + + -qslots N[,...] Select which quantization table to use for each color + component. + + -sample HxV[,...] Set JPEG sampling factors for each color component. + + -scans file Use the scan script given in the specified text file. + +The "wizard" switches are intended for experimentation with JPEG. If you +don't know what you are doing, DON'T USE THEM. These switches are documented +further in the file wizard.txt. + + +DJPEG DETAILS + +The basic command line switches for djpeg are: + + -colors N Reduce image to at most N colors. This reduces the + or -quantize N number of colors used in the output image, so that it + can be displayed on a colormapped display or stored in + a colormapped file format. For example, if you have + an 8-bit display, you'd need to reduce to 256 or fewer + colors. (-colors is the recommended name, -quantize + is provided only for backwards compatibility.) + + -fast Select recommended processing options for fast, low + quality output. (The default options are chosen for + highest quality output.) Currently, this is equivalent + to "-dct fast -nosmooth -onepass -dither ordered". + + -grayscale Force gray-scale output even if JPEG file is color. + Useful for viewing on monochrome displays; also, + djpeg runs noticeably faster in this mode. + + -scale M/N Scale the output image by a factor M/N. Currently + supported scale factors are M/N with all M from 1 to + 16, where N is the source DCT size, which is 8 for + baseline JPEG. If the /N part is omitted, then M + specifies the DCT scaled size to be applied on the + given input. For baseline JPEG this is equivalent to + M/8 scaling, since the source DCT size for baseline + JPEG is 8. Scaling is handy if the image is larger + than your screen; also, djpeg runs much faster when + scaling down the output. + + -bmp Select BMP output format (Windows flavor). 8-bit + colormapped format is emitted if -colors or -grayscale + is specified, or if the JPEG file is gray-scale; + otherwise, 24-bit full-color format is emitted. + + -gif Select GIF output format. Since GIF does not support + more than 256 colors, -colors 256 is assumed (unless + you specify a smaller number of colors). If you + specify -fast, the default number of colors is 216. + + -os2 Select BMP output format (OS/2 1.x flavor). 8-bit + colormapped format is emitted if -colors or -grayscale + is specified, or if the JPEG file is gray-scale; + otherwise, 24-bit full-color format is emitted. + + -pnm Select PBMPLUS (PPM/PGM) output format (this is the + default format). PGM is emitted if the JPEG file is + gray-scale or if -grayscale is specified; otherwise + PPM is emitted. + + -rle Select RLE output format. (Requires URT library.) + + -targa Select Targa output format. Gray-scale format is + emitted if the JPEG file is gray-scale or if + -grayscale is specified; otherwise, colormapped format + is emitted if -colors is specified; otherwise, 24-bit + full-color format is emitted. + +Switches for advanced users: + + -dct int Use integer DCT method (default). + -dct fast Use fast integer DCT (less accurate). + -dct float Use floating-point DCT method. + The float method is very slightly more accurate than + the int method, but is much slower unless your machine + has very fast floating-point hardware. Also note that + results of the floating-point method may vary slightly + across machines, while the integer methods should give + the same results everywhere. The fast integer method + is much less accurate than the other two. + + -dither fs Use Floyd-Steinberg dithering in color quantization. + -dither ordered Use ordered dithering in color quantization. + -dither none Do not use dithering in color quantization. + By default, Floyd-Steinberg dithering is applied when + quantizing colors; this is slow but usually produces + the best results. Ordered dither is a compromise + between speed and quality; no dithering is fast but + usually looks awful. Note that these switches have + no effect unless color quantization is being done. + Ordered dither is only available in -onepass mode. + + -map FILE Quantize to the colors used in the specified image + file. This is useful for producing multiple files + with identical color maps, or for forcing a predefined + set of colors to be used. The FILE must be a GIF + or PPM file. This option overrides -colors and + -onepass. + + -nosmooth Don't use high-quality upsampling. + + -onepass Use one-pass instead of two-pass color quantization. + The one-pass method is faster and needs less memory, + but it produces a lower-quality image. -onepass is + ignored unless you also say -colors N. Also, + the one-pass method is always used for gray-scale + output (the two-pass method is no improvement then). + + -maxmemory N Set limit for amount of memory to use in processing + large images. Value is in thousands of bytes, or + millions of bytes if "M" is attached to the number. + For example, -max 4m selects 4000000 bytes. If more + space is needed, temporary files will be used. + + -verbose Enable debug printout. More -v's give more printout. + or -debug Also, version information is printed at startup. + + +HINTS FOR CJPEG + +Color GIF files are not the ideal input for JPEG; JPEG is really intended for +compressing full-color (24-bit) images. In particular, don't try to convert +cartoons, line drawings, and other images that have only a few distinct +colors. GIF works great on these, JPEG does not. If you want to convert a +GIF to JPEG, you should experiment with cjpeg's -quality and -smooth options +to get a satisfactory conversion. -smooth 10 or so is often helpful. + +Avoid running an image through a series of JPEG compression/decompression +cycles. Image quality loss will accumulate; after ten or so cycles the image +may be noticeably worse than it was after one cycle. It's best to use a +lossless format while manipulating an image, then convert to JPEG format when +you are ready to file the image away. + +The -optimize option to cjpeg is worth using when you are making a "final" +version for posting or archiving. It's also a win when you are using low +quality settings to make very small JPEG files; the percentage improvement +is often a lot more than it is on larger files. (At present, -optimize +mode is always selected when generating progressive JPEG files.) + +GIF input files are no longer supported, to avoid the Unisys LZW patent. +(Conversion of GIF files to JPEG is usually a bad idea anyway.) + + +HINTS FOR DJPEG + +To get a quick preview of an image, use the -grayscale and/or -scale switches. +"-grayscale -scale 1/8" is the fastest case. + +Several options are available that trade off image quality to gain speed. +"-fast" turns on the recommended settings. + +"-dct fast" and/or "-nosmooth" gain speed at a small sacrifice in quality. +When producing a color-quantized image, "-onepass -dither ordered" is fast but +much lower quality than the default behavior. "-dither none" may give +acceptable results in two-pass mode, but is seldom tolerable in one-pass mode. + +If you are fortunate enough to have very fast floating point hardware, +"-dct float" may be even faster than "-dct fast". But on most machines +"-dct float" is slower than "-dct int"; in this case it is not worth using, +because its theoretical accuracy advantage is too small to be significant +in practice. + +Two-pass color quantization requires a good deal of memory; on MS-DOS machines +it may run out of memory even with -maxmemory 0. In that case you can still +decompress, with some loss of image quality, by specifying -onepass for +one-pass quantization. + +To avoid the Unisys LZW patent, djpeg produces uncompressed GIF files. These +are larger than they should be, but are readable by standard GIF decoders. + + +HINTS FOR BOTH PROGRAMS + +If more space is needed than will fit in the available main memory (as +determined by -maxmemory), temporary files will be used. (MS-DOS versions +will try to get extended or expanded memory first.) The temporary files are +often rather large: in typical cases they occupy three bytes per pixel, for +example 3*800*600 = 1.44Mb for an 800x600 image. If you don't have enough +free disk space, leave out -progressive and -optimize (for cjpeg) or specify +-onepass (for djpeg). + +On MS-DOS, the temporary files are created in the directory named by the TMP +or TEMP environment variable, or in the current directory if neither of those +exist. Amiga implementations put the temp files in the directory named by +JPEGTMP:, so be sure to assign JPEGTMP: to a disk partition with adequate free +space. + +The default memory usage limit (-maxmemory) is set when the software is +compiled. If you get an "insufficient memory" error, try specifying a smaller +-maxmemory value, even -maxmemory 0 to use the absolute minimum space. You +may want to recompile with a smaller default value if this happens often. + +On machines that have "environment" variables, you can define the environment +variable JPEGMEM to set the default memory limit. The value is specified as +described for the -maxmemory switch. JPEGMEM overrides the default value +specified when the program was compiled, and itself is overridden by an +explicit -maxmemory switch. + +On MS-DOS machines, -maxmemory is the amount of main (conventional) memory to +use. (Extended or expanded memory is also used if available.) Most +DOS-specific versions of this software do their own memory space estimation +and do not need you to specify -maxmemory. + + +JPEGTRAN + +jpegtran performs various useful transformations of JPEG files. +It can translate the coded representation from one variant of JPEG to another, +for example from baseline JPEG to progressive JPEG or vice versa. It can also +perform some rearrangements of the image data, for example turning an image +from landscape to portrait format by rotation. + +jpegtran works by rearranging the compressed data (DCT coefficients), without +ever fully decoding the image. Therefore, its transformations are lossless: +there is no image degradation at all, which would not be true if you used +djpeg followed by cjpeg to accomplish the same conversion. But by the same +token, jpegtran cannot perform lossy operations such as changing the image +quality. + +jpegtran uses a command line syntax similar to cjpeg or djpeg. +On Unix-like systems, you say: + jpegtran [switches] [inputfile] >outputfile +On most non-Unix systems, you say: + jpegtran [switches] inputfile outputfile +where both the input and output files are JPEG files. + +To specify the coded JPEG representation used in the output file, +jpegtran accepts a subset of the switches recognized by cjpeg: + -optimize Perform optimization of entropy encoding parameters. + -progressive Create progressive JPEG file. + -arithmetic Use arithmetic coding. + -restart N Emit a JPEG restart marker every N MCU rows, or every + N MCU blocks if "B" is attached to the number. + -scans file Use the scan script given in the specified text file. +See the previous discussion of cjpeg for more details about these switches. +If you specify none of these switches, you get a plain baseline-JPEG output +file. The quality setting and so forth are determined by the input file. + +The image can be losslessly transformed by giving one of these switches: + -flip horizontal Mirror image horizontally (left-right). + -flip vertical Mirror image vertically (top-bottom). + -rotate 90 Rotate image 90 degrees clockwise. + -rotate 180 Rotate image 180 degrees. + -rotate 270 Rotate image 270 degrees clockwise (or 90 ccw). + -transpose Transpose image (across UL-to-LR axis). + -transverse Transverse transpose (across UR-to-LL axis). + +The transpose transformation has no restrictions regarding image dimensions. +The other transformations operate rather oddly if the image dimensions are not +a multiple of the iMCU size (usually 8 or 16 pixels), because they can only +transform complete blocks of DCT coefficient data in the desired way. + +jpegtran's default behavior when transforming an odd-size image is designed +to preserve exact reversibility and mathematical consistency of the +transformation set. As stated, transpose is able to flip the entire image +area. Horizontal mirroring leaves any partial iMCU column at the right edge +untouched, but is able to flip all rows of the image. Similarly, vertical +mirroring leaves any partial iMCU row at the bottom edge untouched, but is +able to flip all columns. The other transforms can be built up as sequences +of transpose and flip operations; for consistency, their actions on edge +pixels are defined to be the same as the end result of the corresponding +transpose-and-flip sequence. + +For practical use, you may prefer to discard any untransformable edge pixels +rather than having a strange-looking strip along the right and/or bottom edges +of a transformed image. To do this, add the -trim switch: + -trim Drop non-transformable edge blocks. +Obviously, a transformation with -trim is not reversible, so strictly speaking +jpegtran with this switch is not lossless. Also, the expected mathematical +equivalences between the transformations no longer hold. For example, +"-rot 270 -trim" trims only the bottom edge, but "-rot 90 -trim" followed by +"-rot 180 -trim" trims both edges. + +If you are only interested in perfect transformation, add the -perfect switch: + -perfect Fails with an error if the transformation is not + perfect. +For example you may want to do + jpegtran -rot 90 -perfect foo.jpg || djpeg foo.jpg | pnmflip -r90 | cjpeg +to do a perfect rotation if available or an approximated one if not. + +We also offer a lossless-crop option, which discards data outside a given +image region but losslessly preserves what is inside. Like the rotate and +flip transforms, lossless crop is restricted by the current JPEG format: the +upper left corner of the selected region must fall on an iMCU boundary. If +this does not hold for the given crop parameters, we silently move the upper +left corner up and/or left to make it so, simultaneously increasing the region +dimensions to keep the lower right crop corner unchanged. (Thus, the output +image covers at least the requested region, but may cover more.) + +The image can be losslessly cropped by giving the switch: + -crop WxH+X+Y Crop to a rectangular subarea of width W, height H + starting at point X,Y. + +Other not-strictly-lossless transformation switches are: + + -grayscale Force grayscale output. +This option discards the chrominance channels if the input image is YCbCr +(ie, a standard color JPEG), resulting in a grayscale JPEG file. The +luminance channel is preserved exactly, so this is a better method of reducing +to grayscale than decompression, conversion, and recompression. This switch +is particularly handy for fixing a monochrome picture that was mistakenly +encoded as a color JPEG. (In such a case, the space savings from getting rid +of the near-empty chroma channels won't be large; but the decoding time for +a grayscale JPEG is substantially less than that for a color JPEG.) + + -scale M/N Scale the output image by a factor M/N. +Currently supported scale factors are M/N with all M from 1 to 16, where N is +the source DCT size, which is 8 for baseline JPEG. If the /N part is omitted, +then M specifies the DCT scaled size to be applied on the given input. For +baseline JPEG this is equivalent to M/8 scaling, since the source DCT size +for baseline JPEG is 8. CAUTION: An implementation of the JPEG SmartScale +extension is required for this feature. SmartScale enabled JPEG is not yet +widely implemented, so many decoders will be unable to view a SmartScale +extended JPEG file at all. + +jpegtran also recognizes these switches that control what to do with "extra" +markers, such as comment blocks: + -copy none Copy no extra markers from source file. This setting + suppresses all comments and other excess baggage + present in the source file. + -copy comments Copy only comment markers. This setting copies + comments from the source file, but discards + any other inessential (for image display) data. + -copy all Copy all extra markers. This setting preserves + miscellaneous markers found in the source file, such + as JFIF thumbnails, Exif data, and Photoshop settings. + In some files these extra markers can be sizable. +The default behavior is -copy comments. (Note: in IJG releases v6 and v6a, +jpegtran always did the equivalent of -copy none.) + +Additional switches recognized by jpegtran are: + -outfile filename + -maxmemory N + -verbose + -debug +These work the same as in cjpeg or djpeg. + + +THE COMMENT UTILITIES + +The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file. +Although the standard doesn't actually define what COM blocks are for, they +are widely used to hold user-supplied text strings. This lets you add +annotations, titles, index terms, etc to your JPEG files, and later retrieve +them as text. COM blocks do not interfere with the image stored in the JPEG +file. The maximum size of a COM block is 64K, but you can have as many of +them as you like in one JPEG file. + +We provide two utility programs to display COM block contents and add COM +blocks to a JPEG file. + +rdjpgcom searches a JPEG file and prints the contents of any COM blocks on +standard output. The command line syntax is + rdjpgcom [-raw] [-verbose] [inputfilename] +The switch "-raw" (or just "-r") causes rdjpgcom to also output non-printable +characters in comments, which are normally escaped for security reasons. +The switch "-verbose" (or just "-v") causes rdjpgcom to also display the JPEG +image dimensions. If you omit the input file name from the command line, +the JPEG file is read from standard input. (This may not work on some +operating systems, if binary data can't be read from stdin.) + +wrjpgcom adds a COM block, containing text you provide, to a JPEG file. +Ordinarily, the COM block is added after any existing COM blocks, but you +can delete the old COM blocks if you wish. wrjpgcom produces a new JPEG +file; it does not modify the input file. DO NOT try to overwrite the input +file by directing wrjpgcom's output back into it; on most systems this will +just destroy your file. + +The command line syntax for wrjpgcom is similar to cjpeg's. On Unix-like +systems, it is + wrjpgcom [switches] [inputfilename] +The output file is written to standard output. The input file comes from +the named file, or from standard input if no input file is named. + +On most non-Unix systems, the syntax is + wrjpgcom [switches] inputfilename outputfilename +where both input and output file names must be given explicitly. + +wrjpgcom understands three switches: + -replace Delete any existing COM blocks from the file. + -comment "Comment text" Supply new COM text on command line. + -cfile name Read text for new COM block from named file. +(Switch names can be abbreviated.) If you have only one line of comment text +to add, you can provide it on the command line with -comment. The comment +text must be surrounded with quotes so that it is treated as a single +argument. Longer comments can be read from a text file. + +If you give neither -comment nor -cfile, then wrjpgcom will read the comment +text from standard input. (In this case an input image file name MUST be +supplied, so that the source JPEG file comes from somewhere else.) You can +enter multiple lines, up to 64KB worth. Type an end-of-file indicator +(usually control-D or control-Z) to terminate the comment text entry. + +wrjpgcom will not add a COM block if the provided comment string is empty. +Therefore -replace -comment "" can be used to delete all COM blocks from a +file. + +These utility programs do not depend on the IJG JPEG library. In +particular, the source code for rdjpgcom is intended as an illustration of +the minimum amount of code required to parse a JPEG file header correctly. diff --git a/plugins/AdvaImg/src/LibJPEG/wizard.txt b/plugins/AdvaImg/src/LibJPEG/wizard.txt new file mode 100644 index 0000000000..02418ba2b2 --- /dev/null +++ b/plugins/AdvaImg/src/LibJPEG/wizard.txt @@ -0,0 +1,211 @@ +Advanced usage instructions for the Independent JPEG Group's JPEG software +========================================================================== + +This file describes cjpeg's "switches for wizards". + +The "wizard" switches are intended for experimentation with JPEG by persons +who are reasonably knowledgeable about the JPEG standard. If you don't know +what you are doing, DON'T USE THESE SWITCHES. You'll likely produce files +with worse image quality and/or poorer compression than you'd get from the +default settings. Furthermore, these switches must be used with caution +when making files intended for general use, because not all JPEG decoders +will support unusual JPEG parameter settings. + + +Quantization Table Adjustment +----------------------------- + +Ordinarily, cjpeg starts with a default set of tables (the same ones given +as examples in the JPEG standard) and scales them up or down according to +the -quality setting. The details of the scaling algorithm can be found in +jcparam.c. At very low quality settings, some quantization table entries +can get scaled up to values exceeding 255. Although 2-byte quantization +values are supported by the IJG software, this feature is not in baseline +JPEG and is not supported by all implementations. If you need to ensure +wide compatibility of low-quality files, you can constrain the scaled +quantization values to no more than 255 by giving the -baseline switch. +Note that use of -baseline will result in poorer quality for the same file +size, since more bits than necessary are expended on higher AC coefficients. + +You can substitute a different set of quantization values by using the +-qtables switch: + + -qtables file Use the quantization tables given in the named file. + +The specified file should be a text file containing decimal quantization +values. The file should contain one to four tables, each of 64 elements. +The tables are implicitly numbered 0,1,etc. in order of appearance. Table +entries appear in normal array order (NOT in the zigzag order in which they +will be stored in the JPEG file). + +Quantization table files are free format, in that arbitrary whitespace can +appear between numbers. Also, comments can be included: a comment starts +with '#' and extends to the end of the line. Here is an example file that +duplicates the default quantization tables: + + # Quantization tables given in JPEG spec, section K.1 + + # This is table 0 (the luminance table): + 16 11 10 16 24 40 51 61 + 12 12 14 19 26 58 60 55 + 14 13 16 24 40 57 69 56 + 14 17 22 29 51 87 80 62 + 18 22 37 56 68 109 103 77 + 24 35 55 64 81 104 113 92 + 49 64 78 87 103 121 120 101 + 72 92 95 98 112 100 103 99 + + # This is table 1 (the chrominance table): + 17 18 24 47 99 99 99 99 + 18 21 26 66 99 99 99 99 + 24 26 56 99 99 99 99 99 + 47 66 99 99 99 99 99 99 + 99 99 99 99 99 99 99 99 + 99 99 99 99 99 99 99 99 + 99 99 99 99 99 99 99 99 + 99 99 99 99 99 99 99 99 + +If the -qtables switch is used without -quality, then the specified tables +are used exactly as-is. If both -qtables and -quality are used, then the +tables taken from the file are scaled in the same fashion that the default +tables would be scaled for that quality setting. If -baseline appears, then +the quantization values are constrained to the range 1-255. + +By default, cjpeg will use quantization table 0 for luminance components and +table 1 for chrominance components. To override this choice, use the -qslots +switch: + + -qslots N[,...] Select which quantization table to use for + each color component. + +The -qslots switch specifies a quantization table number for each color +component, in the order in which the components appear in the JPEG SOF marker. +For example, to create a separate table for each of Y,Cb,Cr, you could +provide a -qtables file that defines three quantization tables and say +"-qslots 0,1,2". If -qslots gives fewer table numbers than there are color +components, then the last table number is repeated as necessary. + + +Sampling Factor Adjustment +-------------------------- + +By default, cjpeg uses 2:1 horizontal and vertical downsampling when +compressing YCbCr data, and no downsampling for all other color spaces. +You can override this default with the -sample switch: + + -sample HxV[,...] Set JPEG sampling factors for each color + component. + +The -sample switch specifies the JPEG sampling factors for each color +component, in the order in which they appear in the JPEG SOF marker. +If you specify fewer HxV pairs than there are components, the remaining +components are set to 1x1 sampling. For example, the default YCbCr setting +is equivalent to "-sample 2x2,1x1,1x1", which can be abbreviated to +"-sample 2x2". + +There are still some JPEG decoders in existence that support only 2x1 +sampling (also called 4:2:2 sampling). Compatibility with such decoders can +be achieved by specifying "-sample 2x1". This is not recommended unless +really necessary, since it increases file size and encoding/decoding time +with very little quality gain. + + +Multiple Scan / Progression Control +----------------------------------- + +By default, cjpeg emits a single-scan sequential JPEG file. The +-progressive switch generates a progressive JPEG file using a default series +of progression parameters. You can create multiple-scan sequential JPEG +files or progressive JPEG files with custom progression parameters by using +the -scans switch: + + -scans file Use the scan sequence given in the named file. + +The specified file should be a text file containing a "scan script". +The script specifies the contents and ordering of the scans to be emitted. +Each entry in the script defines one scan. A scan definition specifies +the components to be included in the scan, and for progressive JPEG it also +specifies the progression parameters Ss,Se,Ah,Al for the scan. Scan +definitions are separated by semicolons (';'). A semicolon after the last +scan definition is optional. + +Each scan definition contains one to four component indexes, optionally +followed by a colon (':') and the four progressive-JPEG parameters. The +component indexes denote which color component(s) are to be transmitted in +the scan. Components are numbered in the order in which they appear in the +JPEG SOF marker, with the first component being numbered 0. (Note that these +indexes are not the "component ID" codes assigned to the components, just +positional indexes.) + +The progression parameters for each scan are: + Ss Zigzag index of first coefficient included in scan + Se Zigzag index of last coefficient included in scan + Ah Zero for first scan of a coefficient, else Al of prior scan + Al Successive approximation low bit position for scan +If the progression parameters are omitted, the values 0,63,0,0 are used, +producing a sequential JPEG file. cjpeg automatically determines whether +the script represents a progressive or sequential file, by observing whether +Ss and Se values other than 0 and 63 appear. (The -progressive switch is +not needed to specify this; in fact, it is ignored when -scans appears.) +The scan script must meet the JPEG restrictions on progression sequences. +(cjpeg checks that the spec's requirements are obeyed.) + +Scan script files are free format, in that arbitrary whitespace can appear +between numbers and around punctuation. Also, comments can be included: a +comment starts with '#' and extends to the end of the line. For additional +legibility, commas or dashes can be placed between values. (Actually, any +single punctuation character other than ':' or ';' can be inserted.) For +example, the following two scan definitions are equivalent: + 0 1 2: 0 63 0 0; + 0,1,2 : 0-63, 0,0 ; + +Here is an example of a scan script that generates a partially interleaved +sequential JPEG file: + + 0; # Y only in first scan + 1 2; # Cb and Cr in second scan + +Here is an example of a progressive scan script using only spectral selection +(no successive approximation): + + # Interleaved DC scan for Y,Cb,Cr: + 0,1,2: 0-0, 0, 0 ; + # AC scans: + 0: 1-2, 0, 0 ; # First two Y AC coefficients + 0: 3-5, 0, 0 ; # Three more + 1: 1-63, 0, 0 ; # All AC coefficients for Cb + 2: 1-63, 0, 0 ; # All AC coefficients for Cr + 0: 6-9, 0, 0 ; # More Y coefficients + 0: 10-63, 0, 0 ; # Remaining Y coefficients + +Here is an example of a successive-approximation script. This is equivalent +to the default script used by "cjpeg -progressive" for YCbCr images: + + # Initial DC scan for Y,Cb,Cr (lowest bit not sent) + 0,1,2: 0-0, 0, 1 ; + # First AC scan: send first 5 Y AC coefficients, minus 2 lowest bits: + 0: 1-5, 0, 2 ; + # Send all Cr,Cb AC coefficients, minus lowest bit: + # (chroma data is usually too small to be worth subdividing further; + # but note we send Cr first since eye is least sensitive to Cb) + 2: 1-63, 0, 1 ; + 1: 1-63, 0, 1 ; + # Send remaining Y AC coefficients, minus 2 lowest bits: + 0: 6-63, 0, 2 ; + # Send next-to-lowest bit of all Y AC coefficients: + 0: 1-63, 2, 1 ; + # At this point we've sent all but the lowest bit of all coefficients. + # Send lowest bit of DC coefficients + 0,1,2: 0-0, 1, 0 ; + # Send lowest bit of AC coefficients + 2: 1-63, 1, 0 ; + 1: 1-63, 1, 0 ; + # Y AC lowest bit scan is last; it's usually the largest scan + 0: 1-63, 1, 0 ; + +It may be worth pointing out that this script is tuned for quality settings +of around 50 to 75. For lower quality settings, you'd probably want to use +a script with fewer stages of successive approximation (otherwise the +initial scans will be really bad). For higher quality settings, you might +want to use more stages of successive approximation (so that the initial +scans are not too large). diff --git a/plugins/AdvaImg/src/LibMNG/Changes b/plugins/AdvaImg/src/LibMNG/Changes deleted file mode 100644 index fbf2ac572f..0000000000 --- a/plugins/AdvaImg/src/LibMNG/Changes +++ /dev/null @@ -1,1447 +0,0 @@ ------------------------------------------------------------ - -1.0.10 (Jul 13th 2007) ----------------------- - -in short: - -intermediate CVS - -------------------- - -bugfixes: - -core: -- fixed some compiler-warnings -- fixed display routines called twice for FULL_MNG support in mozlibmngconf.h -- standard windows dll upgraded to zlib 1.2.3 -- fixed problem with CLON object during readdisplay() (thanks Winfried!) -- added typecast to appease the compiler (G R-P) -- added more SKIPCHUNK conditionals (G R-P) -- added MORE MNG_NO_1_2_4BIT_SUPPORT (G R-P) -- added provisional support for anIM(mpNG) proposal -- added provisional support for ANG proposal - -samples: -- xmngview upgraded to 0.6 (thanks Winfried!) - -contrib: - -doc: - -makefiles: - -autoconf: - ------------------------------------------------------------ - -1.0.9 (jan 30th 2005) ---------------------- - -in short: - -New optimizations save over 20KB on footprint. -Also a few bugfixes and several patches. - -Thanks to those sending in their additions and for testing! - -To turn on the optimizations do: - -#DEFINE MNG_OPTIMIZE_CHUNKINITFREE -#DEFINE MNG_OPTIMIZE_OBJCLEANUP -#DEFINE MNG_OPTIMIZE_CHUNKASSIGN -#DEFINE MNG_OPTIMIZE_CHUNKREADER - -(eg. they're not on by default (yet) !) - -------------------- - -bugfixes: -- fixed chunk pushing mechanism -- fixed bug in writing sBIT for indexed color -- fixed PPLT getchunk/putchunk routines -- fixed MNG_NO_1_2_4BIT_SUPPORT for TBBN1G04.PNG -- cleaned up macro-invocations (thanks to D. Airlie) - -core: -- added more SKIPCHUNK conditionals -- replaced MNG_TWEAK_LARGE_FILES with permanent solution -- improved handling of cheap transparency when 16-bit support is disabled -- added some MNG_SUPPORT_WRITE conditionals -- added function to retrieve current FRAM delay -- added MNG_NO_1_2_4BIT_SUPPORT -- added bgr565_a8 canvas-style (thanks to J. Elvander) -- standard windows dll upgraded to zlib 1.2.2 -- added LITTLEENDIAN/BIGENDIAN fixtures (thanks J.Stiles) -- inclusion of zlib/lcms/ijgsrc6b with <> instead of "" -- added conditional MNG_OPTIMIZE_CHUNKINITFREE -- added conditional MNG_OPTIMIZE_OBJCLEANUP -- added conditional MNG_OPTIMIZE_CHUNKASSIGN -- added conditional MNG_OPTIMIZE_CHUNKREADER -- fixed problem with global PLTE/tRNS - -samples: - -contrib: - -doc: -- patched jng & mng manual pages (Thanks Peter Breitenlohner) - -makefiles: - -autoconf: -- patched makefile.am & configure.in (Thanks Peter Breitenlohner) - ------------------------------------------------------------ - -1.0.8 (aug 5th 2004) --------------------- - -in short: - -added special data-pushing mechanisms and a few other tid-bits - -------------------- - -bugfixes: -- fixed problem with PAST usage where source > dest - -core: -- added missing get-/put-chunk-jdaa -- added CRC existence & checking flags -- added data-push mechanisms for specialized decoders -- some speed optimizations (thanks to John Stiles) -- defend against using undefined closestream function -- defend against using undefined openstream function -- added check for extreme chunk-lengths -- change worst-case iAlphadepth to 1 for standalone PNGs -- added support for 3+byte pixelsize for JPEG's -- added conditional to allow easier writing of large MNG's - -samples: - -contrib: - -doc: - -makefiles: - -autoconf: - ------------------------------------------------------------ - -1.0.7 (March 21st 2004) ------------------------ - -in short: - -A bunch of new canvas-styles, some bug-fixes, upgraded to latest zlib/lcms -and yet more work to please the Mozilla crowd. -Releasing beta's doesn't seem very responsive, and this one's hardly changed -much anyway. I just wanted to bump to a regular version for Mozilla -re-integration. - -------------------- - -bugfixes: -- fixed inclusion of IJNG chunk for non-JNG use (J.S) -- fixed bug in chunk-storage of SHOW chunk (where from == to) -- fixed bug in promote_g8_g8 with 16bit support off - -core: -- added CANVAS_RGB565 and CANVAS_BGR565 (big thanx to Raphael Assenat!!) -- added CANVAS_RGBA565 and CANVAS_BGRA565 ( -- ditto -- ) -- upgraded to zlib 1.2.1 -- upgraded to lcms 1.11 -- added premultiplied alpha canvas' for RGBA, ARGB, ABGR (thx to John Stiles) -- more optimizations with 16bit support off -- put conditionals around openstream/closestream callbacks. -- fixed typo (MNG_SKIPCHUNK_SAVE -> MNG_SKIPCHUNK_nEED) -- fixed some 64-bit platform compiler warnings - -samples: - -contrib: -- fixed mngtree sample (Raphael) -- added 5-6-5 canvas to SDL sample (Raphael) - -doc: - -makefiles: - -autoconf: - ------------------------------------------------------------ - -1.0.6 (oct 19th 2003) ---------------------- - -in short: - -Final release from beta1. No feedback is good feedback I presume, -so here's 1.0.6-final! - - -------------------- - -bugfixes: - -core: - -samples: - -contrib: - -doc: - -makefiles: - -autoconf: - ------------------------------------------------------------ - -1.0.6-beta1 (sep 14th 2003) ---------------------------- - -in short: - -further footprint-reductions -removing email-addresses - -1.0.6 (final) will be out shortly - -------------------- - -bugfixes: - -core: -- added support for reducing the footprint of libmng by macros that optionally - skip unused chunks, remove 16-bit sample support, remove Delta support, and - remove JNG support, to accomodate Mozilla/Firebird. -- further optional removal of unused functions -- added MNG_NO_SUPPORT_FUNCQUERY conditional -- added iPNGdepth member to pData structure -- added conditionals around MAGN chunk support -- added conditionals around non-VLC chunk support -- added conditionals around "mng_display_go*" and other unused functions -- added more conditionals around "promote" functions -- removed email references as appropriate - -samples: - -contrib: - -doc: - -makefiles: - -autoconf: - ------------------------------------------------------------ - -1.0.6-alpha1 (aug 2nd 2003) ---------------------------- - -in short: - -This is mostly in the light of footprint-reduction to please the Mozilla -crew with a leaner and meaner libmng. See bug 18574 if you're interested: -http://bugzilla.mozilla.org/show_bug.cgi?id=18574 - -------------------- - -bugfixes: -- B719420 - fixed several MNG_APP_CMS problems - -core: -- removed some compiler-warnings -- hiding 12-bit JPEG stuff -- fixed problem with infinite loops during readdisplay() -- added size-optimiation COMPOSE routine usage -- added conditionals around canvas update routines -- added MNG_SKIPCHUNK_cHNK footprint optimizations -- added conditionals around some JNG-supporting code -- added conditionals around 16-bit supporting code -- combined init functions into one function -- replaced nested switches with simple init setup function -- added conditionals zlib and jpeg property accessors -- added size-optimization DIV255B8 routine usage -- added conditionals around 8-bit magn routines -- removed conditionals around 8-bit magn routines -- added MNG_NO_16BIT_SUPPORT and MNG_NO_DELTA_PNG conditionals -- reversed many loops to use decrementing counter -- converted some switches to array references -- removed some redundant checks for iRawlen==0 -- optionally use zlib's crc32 function instead of local mng_update_crc -- bugfix empty "if" statement when 16-bit code is enabled -- restored two misplaced #else/#endif blocks -- added conditionals around "mng_display_go*" and other unused functions -- added MNG_NO_LOOP_SIGNALS_SUPPORTED conditional -- fixed duplicate for-loop -- fixed invalid test in promote_imageobject -- added conditionals around PAST chunk support -- fixed "FOOTPRINT_COMPOSEIV" typo (now "FOOTPRINT_DIV") - -samples: - -contrib: -- updated xmngview -- added MSVC project for creating delta-MNGs: makemng (thanks Alex!) -- added MSVC lib-file for use with the standard libmng.dll (again thanks Alex) - -doc: -- updated readme.contrib - -makefiles: - -autoconf: - ------------------------------------------------------------ - -1.0.5 (mar 1st 2003) --------------------- - -in short: - -Only a small fix for progressive jpeg suspension problem. - -This is the long-awaited final release containing the new 'dynamic MNG' feature -and bringing MNG compliance to near 100%! - -------------------- - -bugfixes: -- B683152 - libjpeg suspension not always honored correctly - -core: - -samples: - -contrib: - -doc: - -makefiles: - -autoconf: - ------------------------------------------------------------ - -1.0.5-rc3 (jan 20th 2003) -------------------------- - -in short: - -Third release-candidate for the upcoming 1.0.5 version. - -Minor bug-fixes and finalizing the accepted proposal (by official vote) for -the TERM/frame_delay changes on mng-list (nov-dec/2002). - -------------------- - -bugfixes: -- B654627 - fixed SEGV when no gettickcount callback (thanks Adam!) -- B664383 - fixed typo (thanks Dimitri) -- B664911 - fixed buffer overflow during init (thanks Alex!) - -core: -- finalized changes in TERM/final_delay to elected proposal (positive vote) - -samples: - -contrib: - -doc: - -makefiles: - -autoconf: - ------------------------------------------------------------ - -1.0.5-rc2 (dec 9th 2002) ------------------------- - -in short: - -Second release-candidate for the upcoming 1.0.5 version. -This contains fixes for a few minor details reported by the loyal testers. -It fixes some issues with the goframe/golayer/gotime processing and related -stuff. And it adds a way to disable playback-caching from within the MNG, -which is very useful for streaming-MNG encoders (such as gserver!). - -------------------- - -bugfixes: - -core: -- fixed layer- & frame-counting during read() -- changed FRAMECOUNT/LAYERCOUNT/PLAYTIME error to warning -- fixed goframe/golayer/gotime processing -- added support for nEED "MNG 1.1" -- added support for nEED "CACHEOFF"; turn playback caching off for streaming MNG -- fixed magnification bug with object 0 -- added support to get totals for frames/layers/playtime after mng_read() -- fixed some issues in init_app_cms() -- fixed goxxxxx() support for zero values - -samples: - -contrib: - -doc: - -makefiles: - -autoconf: - ------------------------------------------------------------ - -1.0.5-rc1 (nov 1st 2002) ------------------------- - -in short: - -First release-candidate for the upcoming 1.0.5 version. -This fixes a few small problems and brings the TERM/MEND processing, with -respect to interframe_delay as per the current discussion on MNG-list, -up-to-date with the latest proposal. - -------------------- - -bugfixes: - -core: -- fixed initialization of pIds in dISC read routine (Thanks Winfried!) -- fixed issue in freeing evNT chunk (Thanks Winfried!) -- fixed clipping-problem with BACK tiling (Thanks Sakura!) -- fixed processing for multiple objects in MAGN (Thanks Sakura!) -- fixed display of visible target of PAST operation (Thanks Sakura!) -- modified TERM/MEND processing for max(1, TERM_delay, interframe_delay) - -samples: - -contrib: -- fixed typo in Makefile for gtk-mng-view sample - -doc: - -makefiles: - -autoconf: - ------------------------------------------------------------ - -1.0.5-b3 (oct 15th 2002) ------------------------- - -in short: - -Fairly quick after beta2, since that introduced a couple of unfortunate -booboo's and wasn't very workable. It also changes the standard configure -script to build a standard shared object similar to what I intended. - -------------------- - -bugfixes: - -core: -- fixed support for condition=2 in TERM chunk -- fixed trace-constants for PAST chunk -- added mng_status_dynamic to supports function - -samples: - -contrib: - -doc: -- small cosmetic changes in man/libmng.3 - -makefiles: - -autoconf: -- fixed configure.in to build a 'standard' SO primarily - ------------------------------------------------------------ - -1.0.5-b2 (oct 9th 2002) ------------------------- - -in short: - -Second beta for next 1.0.5 release. This addresses some minor problems -detected during testing. It adds the proposed change to the MNG spec as -discussed on the "mng-list" recently; eg. Adam's option 4. -And it adds a little function to check at run-time if the lib is a beta or not. - -------------------- - -bugfixes: - -core: -- fixed chunk-storage for evNT chunk -- fixed dropping mix of frozen/unfrozen objects -- fixed problem with cloned objects marked as invalid -- fixed problem cloning frozen object_buffers -- fixed DISC support -- added proposed change in handling of TERM- & interframe-delay -- added another fix for misplaced TERM chunk -- added check for TERM placement during create/write -- completed support for condition=2 in TERM chunk -- added beta version function & constant - -samples: - -contrib: - -doc: - -makefiles: - -autoconf: - ------------------------------------------------------------ - -1.0.5-b1 (sep 24th 2002) ------------------------- - -in short: - -First beta of a large maintenance release. This completes support of the MNG -specification to nearly 100% (PAST, PROM, delta-images, BACK image+tile). -It adds "dynamic" MNG and a few other neat routines as well as fixes several -bugs reported through SourceForge or to me directly. - -------------------- - -bugfixes: -- B575832 - library has wrong patch version number -- B578572 - remove in 1.0.0! -- B578940 - some functions not implemented -- B581625 - large chunks fail with suspension reads -- B597134 - libmng pollutes the linker namespace - -core: -- added sanity check for improbable chunklengths -- removed eMNGma hack (thanks Dimitri!) -- unimplemented functions return an errorcode now -- added test-option for PNG filter method 192 (= levelling) -- added test-option for PNG filter method 193 (= no filtering) - (both are conditional and only for testing purposes!!!) -- completed PROM support -- completed delta-image support -- completed MAGN support (16-bit functions) -- added HLAPI function to copy a chunk from a read MNG to a newly created MNG -- added option for soft-handling of errors (only for repair software!!!) -- fixed some routine inclusion/exclusion for undefined conditionals -- pre-fixed all internal routines with mng_ -- added symbol MNG_LOCAL (= static) to really local functions -- fixed reading of FRAM with just frame_mode and name -- fixed read/write of MAGN chunk -- added event handling for dynamic MNG -- added 'supports' call to check function availability -- fixed copyright notice in the headers of all libmng modules -- fixed LOOP iteration=0 special case -- re-compiled standard Windows dll with lcms-1.0.9 -- added warning for too much IDAT data -- warnings are ignored by default now -- misplaced TERM is now treated as warning -- fixed color-correction for restore-background handling -- optimized restore-background for bKGD cases -- cleaned up some old stuff -- completed support for BACK image & tiling -- completed support for PAST -- added bgrx8 canvas (filler byte) -- fixed reset_object_detail to clear old buffer -- added in-memory color-correction of abstract images -- added compose over/under routines for PAST processing -- added flip & tile routines for PAST processing - -samples: -- Added new BCB sample for fixing invalid JASC Animation Shop files - (shows new copy_chunks function; use of MNG_SOFTERRORS & static linking) - -contrib: -- added xmngview by Winfried Szukalski (Vielen dank!) -- Updated the Delphi mngview sample to handle dynamic MNGs -- Added Kylix example (simplified port of the Delphi mngview sample) - -doc: -- added diff to add MNG&JNG to a systems 'magic' file (Thanks Winfried) -- fixed docs about using mng_display_resume after display_reset - (should read to use mng_display!) - -makefiles: -- added makefile to build a libmng.dll for MingW - (makefile.mingwdll - thanks to Frank Richter!) - -autoconf: -- fixing libtool version-number to be in line with what it should be - ------------------------------------------------------------ - -1.0.4 (Jun 23rd 2002) ---------------------- - -in short: - -Just some small fixes -Standard dll now compiled with zlib 1.1.4 and lcms 1.0.8 - -------------------- - -bugfixes: -- B495442 - invalid returnvalue in mng_get_suspensionmode -- B495443 - incorrect suspend check in read_databuffer -- B526138 - returned IJGSRC6B calling convention to default for MSVC -- B558212 - off by one error -- B557677 - can't find lcms.h - -core: -- fixed possible compile-problem in cleanup_rowproc -- MNG subimage alpha composite wrong for rgba8 images - -samples: - -contrib: - -doc: - -makefiles: -- fixed check for lcms.h in configure.in - -autoconf: - ------------------------------------------------------------ - -1.0.3 (Sep 18th 2001) ---------------------- - -in short: - -Small cosmetic changes. Cleaning up the contributions. -New makefile for mingw32, and new fbcon example. -Major thanks to Greg for helping out with the *nix stuff! -Note that there's also a separate download for ASM programmers now. -Check http://www.libmng.com for details (download/ports&packages page). - -It may be a while for the next release. I'm "off duty" for the next 8 or -so months... - -Gerard - -------------------- - -bugfixes: -- B459058 - wrong include for lcms headers - -core: -- changed inclusion of lcms.h header for Linux platforms (suggested by Greg) -- added get function for last processed BACK chunk - -samples: -- replaced the gtk & sdl viewer apps with updates by Greg Roelofs - -contrib: - -doc: - -makefiles: -- changed makefile.linux & makefile.unix as suggested by Greg Roelofs - (makefile.linux now compiles with lcms by default) -- added makefile.mingw for mingw32 by Benoit Blanchon (thanks Mate!) - -autoconf: - ------------------------------------------------------------ - -1.0.2 (Jul 7th 2001) --------------------- - -in short: - -Another maintenance release with a few added extra's. - -------------------- - -bugfixes: -- B421427 - writes wrong format in bKGD and tRNS -- B434583 - compiler-warning if MNG_STORE_CHUNKS undefined - -core: -- added optimization option for MNG-video playback -- added processterm callback -- added late binding errorcode (not used internally) -- fixed memory-leak with delta-images (Thanks Michael!) -- added option to turn off progressive refresh for large images - -samples: - -contrib: - -doc: - -makefiles: - -autoconf: - ------------------------------------------------------------ - -1.0.1 (May 2nd 2001) --------------------- - -in short: - -Maintenance release. -Fixed several memory-leaks with the help of Gregg Kelly, added/fixed some CMS -handling, exported JPEG functions from standard DLL, and some other minor fixes. - -The CMS fix now makes libmng automagically work in MNG_FULL_CMS mode as a -sRGB compliant system. YOU WILL NEED TO CHANGE THIS IF YOU ARE NOT ON AN sRGB -COMPLIANT SYSTEM AND WANT TO USE CMS!!!! -(look in libmng.h for the proper function-calls) - -------------------- - -bugfixes: - -core: -- added MEND processing callback -- fixed first FRAM_MODE=4 timing problem -- added handle status-copy function (use with care) -- exported JPEG functions from standard DLL -- added BGRA8 canvas with premultiplied alpha (contrib by Gregg Kelly) -- fixed problem with display_reset/display_resume (Thanks Gregg!) -- fixed several memory-leaks (Thanks Gregg!) -- fixed reset_rundata to drop all objects (Thanks again, Gregg!) -- fixed problem with cms profile being created multiple times when both - iCCP & cHRM/gAMA are present (And again... Gregg) -- moved mng_clear_cms to libmng_cms -- added "default" sRGB generation (Thanks Marti!) - -samples: - -contrib: - -doc: - -makefiles: - -autoconf: - ------------------------------------------------------------ - -1.0.0 (Feb 6th 2001) --------------------- - -in short: - -First public release. Finally(!) - -This is the 0.9.5 CVS version, which will never be released, because I feel it -is now ready for a public release. So apart from the version-numbers here and -there, all other changes are listed under 0.9.5. - -This library will work with every MNG/JNG known and available to me. Note that -there are still parts that need to be coded, and that MNG support is around -90-95% (JNG at 100%). It is however compliant with the latest and greatest -MNG 1.0 specification. - -I hope to dedicate a bit more time this year to finish up full support and fill -in the remaining blanks. But this is coming out of my spare time. And extra -help is always appreciated. - -Please enjoy! - -Gerard - ------------------------------------------------------------ - -0.9.5 (no release) ------------------- - -in short: - -intermediate CVS - -------------------- - -bugfixes: -B129681 - fixed compiler warnings SGI/Irix (thanks Dimitri) - -core: -- fixed compiler-warnings Mozilla (thanks Tim) -- fixed timing-problem with switching framing_modes -- fixed some small compiler warnings (thanks Nikki) - -samples: - -contrib: -- fixed library-paths for MSVC DLL project (thanks Chad) - -doc: - -makefiles: -- added makefile for DJGPP (thanks Silvio) - -autoconf: - ------------------------------------------------------------ - -0.9.4 (Jan 19th 2001) ----------------------- - -in short: - -Now that the MNG spec is at 1.0, this should be the last beta. There's a few -small changes to make it inline with the spec, and a couple of bug-fixes. -This is a serious release-candidate for libmng-1.0!! -Please... test test test test!! - -------------------- - -bugfixes: -B123314 - fixed number of TERM related problems -B123322 - fixed unwanted repetition in mng_readdisplay() -B123443 - fixed by Ralph -B124910 - fixed definition for WIN32_LEAN_AND_MEAN (thanks Chad) -B125750 - fixed by Ralph -B125756 - fixed mixup of data- & function-pointers (thanks Dimitri) -B127517 - changed inclusion of the lcms header file for non-windows platforms - -core: -- version numbers -- fixed possible loop in display_resume() (Thanks Vova!) -- fixed unwanted repetition in mng_readdisplay() -- changed inclusion of the lcms header file for non-windows platforms -- changed IHDR filter_method check for PNGs -- moved restore of object 0 to libmng_display -- added restore of object 0 to TERM processing (B123314) -- fixed TERM delay processing (B123314) -- fixed TERM end processing when count = 0 (B123314) -- changed callback convention for MSVC (Thanks Chad) -- fixed mixup of data- & function-pointers (thanks Dimitri) -- added support for "nEED MNG-1.0" -- added errorcode for MAGN methods -- added errorchecking for MAGN methods -- removed "old" MAGN methods 3 & 4 -- added "new" MAGN methods 3, 4 & 5 -- removed test filter-methods 1 & 65 -- set default level-set for filtertype=64 to all zeroes - -samples: - -contrib: -- added GTK mng-view example by Vova Babin -- added MSVC MNGview sample by Nikolaus Brennig -- updated Jason Summer's mngplg to version 0.9.2 - (that's mngplg-0.9.2 based on libmng-0.9.3 !!!) -- rearranged contrib directory slightly -- added MSVC project to build libmng.dll by Chad Austin - -doc: -- added README.dll -- added README.config - -makefiles: -- added a makefile for MS Visual C++ (Thanks to Atsushi Matsuda) - -autoconf: -- fixed configure.in for lcms (FreeBSD port by Mikhail Teterin) -- by default configure includes CMS support if lcms is present - ------------------------------------------------------------ - -0.9.3 (October 29th 2000) -------------------------- - -in short: - -Another beta release. The number of changes in the MNG specification have -resulted in a lot of new code and some changed code. At the same time I saw -no need to withhold some new functionality as it was pretty clear there was -going to be another beta-round. If things go well, I'm going to try to release -libmng 1.0.0 very shortly after this one. - -Many thanks to a lot of people for helping out, sending contributions, making -suggestions and testing this little baby. This would get nowhere without YOU!!! - -- fixed bug 111300/117103 -- added workaround for faulty PhotoShop iCCP chunk -- added MAGN/JDAA chunks -- added support for new filter_types -- added PNG/MNG spec version indicators -- added BCB mngview contribution by Andy Protano -- added BCB mngdump; a GUI-based MNG dumping utility (Andy Protano) -- implemented support for nEED "draft nn" -- implemented app-defined support for bKGD for PNG images -- removed trace-options from default SO/DLL builds (!!!) -- raised initial maximum canvas size to 10000x10000 (!!!) - (an App that wants to protect from overly large images should call - mng_set_maxcanvassize() with appropriate values) -- fixed other assorted stuff - -------------------- - -bugfixes: -B111300 - fixup for improved portability -B117103 - fixed compilation errors on *nix with lcms (thanks Ralph!) - -core: -- fixed compiler-warnings from Mozilla -- added check for simplicity-bits in MHDR -- added workaround for faulty PhotoShop iCCP chunk -- fixed app-supplied background restore -- fixed TERM processing delay of 0 msecs -- fixed write-code for zTXt & iTXt -- fixed read-code for iTXt -- added MAGN chunk -- fixed sRGB precedence for gamma_only corection -- added support for new filter_types -- fixed problem with no refresh after TERM -- fixed DEFI behavior -- fixed inclusion parameters to make the external libs work together -- added export of zlib functions from windows dll -- fixed timing & refresh behavior for single PNG/JNG -- removed trace-options from default SO/DLL builds (!!!) -- fixed MAGN rounding errors (thanks Matthias!) -- fixed small timing problem when FRAM delay = 0 -- fixed simplicity-check in compliance with draft 81/0.98a -- fixed alpha-blending for all alpha-canvasstyles -- added support for alpha-depth prediction -- fixed processing of unknown critical chunks -- removed test-MaGN -- added PNG/MNG spec version indicators -- implemented support for nEED -- added support for JDAA -- added functions to retrieve PNG/JNG specific header-info -- added optional support for bKGD for PNG images -- raised initial maximum canvas size to 10000x10000 -- added support for delta-JNG -- added callback to process non-critical unknown chunks -- fixed support for delta-images during read() / display() -- added closestream() processing for mng_cleanup() -- fixed delta-processing behavior -- added storage for pixel-/alpha-sampledepth for delta's -- implemented delayed delta-processing -- fixed putchunk_plte() to set bEmpty parameter (thanks Ben!) -- added errorcode for delayed delta-processing -- added get/set for bKGD preference setting -- added get function for interlace/progressive display -- fixed bug in empty PLTE handling -- fixed seperate read() & display() processing -- fixed tRNS processing for gray-image < 8-bits - -samples: -- added BCB mngview contribution by Andy Protano - -contrib: -- added BCB mngdump; a GUI-based MNG dumping utility (Andy Protano) - -doc: -- updated RPM spec-file by MATSUURA Takanori -- updated README.contrib - -makefiles: -- fixed some stuff in automake/autoconf/libtool -- fixed auto* for bug B117103 - ------------------------------------------------------------ - -0.9.2 (August 7th 2000) ------------------------ - -in short: - -Third beta release! Last one??? - -!!IMPORTANT!! All file-names are now prefixed with "libmng_" !!IMPORTANT!! - -Many thanks to Albert Chin-A-Young for his contribution of the -autoconf/automake/libtool stuff and to Ralph Giles for helping me -put it in the right places. - -There's a special README.autoconf so please read it! - -- fixed bug 110320/110546/110547/111096 -- added several status retrieval functions -- fixed other small bugs in display processing -- fixed number of small problems and documentation typos -- added autoconf/automake/libtool -- added latest MNG plugin (0.9.0) by Jason Summers - -------------------- - -bugfixes: -B110320 - fixed GCC warning about mix-sized pointer math -B110546 - fixed for improperly returning UNEXPECTEDEOF -B110547 - fixed bug in interlace code -B111096 - fixed large-buffer read-suspension - -core: -- version numbers -- fixed small bugs in display processing -- removed Nextbackxxx fields (no longer used) -- fixed problem with trace-functions improperly wrapped -- put specific code in add_chunk() inside MNG_SUPPORT_WRITE wrapper -- fixed documentation typos -- fixed wrapping of suspension parameters -- added status_xxxx functions -- added trace-codes/-strings for status_xxxxx functions -- changed file-prefixes -- added function to set simplicity field -- added trace-code/-string for updatemngsimplicity -- fixed putchunk_unknown() function - -samples: - -contrib: -- added latest MNG plugin (0.9.0) by Jason Summers - -doc: -- version numbers -- added autoconf readme -- version numbers in RPM stuff - -makefiles: -- fixed for new file-prefix -- added autoconf/automake/libtool - ------------------------------------------------------------ - -0.9.1 (July 26th 2000) ----------------------- - -in short: - -Second beta release. - -Given the enormous amount of bug-reports (not ;-), this will most likely -be one of the last betas. If things remain upright, the first public release -(1.0.0) is fairly eminent in the weeks to come... - -- added SDL mng player by Ralph Giles to contributions -- fixed timing and added internal buffering for I/O-suspension scenarios -- added get routines for internal display-state variables (frame/layer/playtime) -- changed read-processing for improved I/O-suspension (internal buffering) -- fixed several problems with create- & write-support -- added a load of documentation -- lots of small stuff - -------------------- - -bugfixes: - -core: -- fixed mandatory BACK color to be opaque -- changed mng_display_resume to allow to be called after a suspension - return with MNG_NEEDMOREDATA -- changed comments to indicate modified behavior for timer & suspension breaks -- added variables for go_xxxx processing -- implemented support for freeze/reset/resume & go_xxxx -- added trace-codes/-strings for special display processing -- added variables for improved timing support -- added support for improved timing -- added get routines for internal display variables -- added get/set routines for suspensionmode variable -- added trace-code/-string for get/set suspensionmode -- added trace-codes/-strings for get/set display variables -- added support for improved I/O-suspension -- changed read-processing for improved I/O-suspension -- added trace-code/-string for read_databuffer (I/O-suspension) -- added suspendbuffer constants -- changed EOF processing behavior -- fixed TERM delay processing -- changed pre-draft48 frame_mode=3 to frame_mode=1 -- added callbacks for SAVE/SEEK processing -- added trace-codes/-strings for SAVE/SEEK callbacks -- added variable for NEEDSECTIONWAIT breaks -- added trace-codes/-strings for get/set sectionbreaks -- added NEEDSECTIONWAIT error-code/-string -- added macro + routine to set returncode without calling error callback -- added trace-code/-string for special error routine -- changed default readbuffer size from 1024 to 4200 -- added variable for freeze & reset processing -- fixed storage of images during mng_read() -- fixed support for mng_display() after mng_read() -- added error cleanup processing -- fixed support for mng_display_reset() -- fixed suspension-buffering for 32K+ chunks -- added function to set frame-/layer-count & playtime -- added trace-code/-string for updatemngheader -- added error-code/-string for updatemngheader if not a MNG -- fixed creation-code -- fixed writing of signature -- fixed several chunk-writing routines - -samples: -- fixed the libmng.pas module in line with libmng.h - -contrib: -- added the SDL based mngplay viewer by Ralph Giles - -doc: -- extended the RPM contribution by MATSUURA Takanori -- added libmng.txt, a full description of the library and its usage -- added man-pages for mng(5), jng(5) and libmng(3) - -makefiles: - ------------------------------------------------------------ - -0.9.0 (June 30th 2000) ----------------------- - -in short: - -This is the first beta!!! Yippee!!! - -Thanks to all the people who helped to guide me in the right direction. -You know who you are! - -A special thanks to the guys with early implementations, who stood by and -put up with my whims :-) - -changes over 0.5.3: - -- updated mngplg to 0.4.1 (the latest & greatest) -- changed refresh parameters to 'x,y,width,height' - ------------------------------------------------------------ - -0.5.3 (never released) ----------------------- - -in short: - -This is a working version only; the next release will be 0.9.0 (first Beta!) - -There are a few incompatible changes with previous versions. The userdata -variable has been changed from mng_uint32 to mng_ptr to accomodate 64-bit -systems. For the same reason memory allocation size parameters have been -changed to a mng_size_t type which is a typedef of size_t. - -Thanks to Aleks Jakulin for helping to iron out some 64-bit platform issues! - -- implemented the update-region parameters of the refresh callback -- added support for most common delta-image options -- added an animation-speed modifier -- added an image-level parameter for the processtext callback -- updated mngplg to 0.4.0 (supports JNG, full CMS, and other enhancements!) -- fixed a lot of small things -- added support for PPLT chunk -- fixed to support 64-bit platforms - -------------------- - -bugfixes: - -core: -- added processing of color-info on delta-image -- fixed handling of empty SAVE chunk -- fixed display of stored JNG images -- fixed problem with BASI-IEND as object 0 -- changed the version parameters (obviously) -- added update-region parms for refresh calback -- added Needrefresh parameter -- added initialization of update-region for refresh -- added initialization of Needrefresh parameter -- changed progressive-display processing -- added tracecodes for tracing JPEG progression -- added tracing of JPEG calls -- added Deltaimmediate parm for faster delta-processing -- added extra checks for delta-images -- many changes to support delta-images -- optimized some store_xxx routines -- fixed some small things (as precaution) -- fixed possible trouble if IEND display-processing got broken up -- fixed nasty bug with embedded PNG after delta-image -- added processing of PLTE & tRNS for delta-images -- added processing of PLTE/tRNS & color-info for delta-images in the - ani_objects chain -- fixed problem with color-correction for stored images -- added get/set for speedtype to facilitate testing -- added trace-codes & -strings for get/set speedtype -- added speed-modifier to timing routine -- added get-routine of imagelevel for processtext callback -- added trace-code & -string for get imagelevel -- added administration of imagelevel parameter -- added support for PPLT chunk -- added trace-codes & -strings for PPLT chunk processing -- fixed problem with incorrect gamma-correction -- fixed inclusion of IJG read/write code -- fixed problem with 16-bit GA format -- fixed problem with cheap transparency for 4-bit gray -- fixed display_xxxx routines for interlaced images -- added precaution against faulty iCCP chunks from PS -- changed userdata variable to mng_ptr -- added typedef for mng_size_t -- changed size parameter for memory allocation to mng_size_t -- fixed compiler-warning for non-initialized iB variable -- changed definition for 32-bit ints (64-bit platforms) -- changed definition for mng_handle (64-bit platforms) -- swapped refresh parameters -- fixed initialization routine for new mng_handle type -- added inclusion of stdlib.h for abs() -- fixed some 64-bit warnings -- fixed incompatible return-types - -samples: - -contrib: -- updated mngplg to 0.3.0 (supports JNG & full color-correction!) -- updated mngplg to 0.4.0 (Jason is picking up the pace ;-) - -doc: -- added rpm directory with rpm spec-file (contributed by MATSUURA Takanori) - -makefiles: -- changed makefile.linux to reflect versionnr for shared-lib -- changed makefile.linux to depend on mng_conf.h & mng_types.h - ------------------------------------------------------------ - -0.5.2 (June 10th 2000) ----------------------- - -in short: - -This is the third release for developers -Another milestone since JNG is now fully supported -The next release will most likely be numbered 0.9.0 as the first Beta!! - -Fixed bug 106017 & 106019 -Added many constants regarding chunk-property values -Implemented full JNG support -Added all the error- & trace-strings -Added get/set routines for default ZLIB/IJG parameters -Added a generic makefile for Unix platforms (contributed by Tim Rowley) -Added canvasstyle for separate RGB + A canvas (eg. mozilla-style) -Separated configuration-options into a separate file: "mng_conf.h" -Fixed stuff for generic Unix compilation (contributed by Tim Rowley) -Upgraded to lcms1.0.6 (now supports 16-bit endian-peculiarities) -Added a makefile for Linux ELF & fixed some code-issues to go along with gcc -Added support for suspended input-buffer processing -Implemented the display-routines for RGBA/ARGB/BGRA/ABGR canvasstyles -Implemented the application background-restore functionality -Fixed & tested the mngtree Unix-sample (runs on Linux-RH6.2 with libmng.so) -Upgraded mngplg to v0.2.2 (based on the latest code including JNG) -Fixed a lot of other assorted stuff - -------------------- - -bugfixes: -B003(106017) - fixed problem with being proprietary to BCB -B004(106019) - fixed problem when MNG_SUPPORT_WRITE not defined - -core: -- bumped version-numbers up to 0.5.2 (yeah, really) -- fixed support for IJGSRC6B -- cleaned up some code regarding mixed support-options -- complemented constants for chunk-property values -- fixed MNG_UINT_pHYg value -- implemented JNG support -- fixed problem with DEFI clipping -- added error telltale strings & support -- added trace telltale strings & support -- added support for global color-chunks inside TERM/LOOP -- added support for global PLTE,tRNS,bKGD inside TERM/LOOP -- added default IJG compression parameters and such -- moved init of default zlib parms to "mng_hlapi.c" -- added init of default IJG parms -- added support for get/set of zlib/IJG default parms -- added tracestrings for global animation color-chunks -- added tracestrings for get/set of default ZLIB/IJG parms -- added tracestrings for global PLTE,tRNS,bKGD -- added framenr/layernr/playtime to object header -- added initialization of framenr/layernr/playtime -- changed ani_create calls not returning object pointer -- create ani objects always (not just inside TERM/LOOP) -- fixed inconsistancy with freeing global iCCP profile -- fixed minor bugs 16-bit pixel-handling -- added object promotion routine (PROM handling) -- added trace-codes & -strings for image-object promotion -- added trace-codes & -strings for delta-image processing -- added error-codes & -strings for delta-image processing -- added support for delta-image processing -- added ani-object routines for delta-image processing -- added delta-image fields -- added compression/filter/interlace fields to object-buffer for - delta-image processing -- added delta-image row-processing routines -- fixed up punctuation in several files (contributed by Tim Rowley) -- removed useless definition in "mng_chunks.h" (contributed by Tim Rowley) -- fixed pointer confusion in "mng_display.c" (contributed by Tim Rowley) -- fixed inclusion for memcpy (contributed by Tim Rowley) -- added mng_int32p (contributed by Tim Rowley) -- added internal delta-image processing callbacks -- separated configuration-options into "mng_conf.h" -- changed to most likely configuration -- added RGB8_A8 canvasstyle -- added getalphaline callback for RGB8_A8 canvasstyle -- fixed some makeup for Linux gcc compile -- implemented app bkgd restore routines -- implemented RGBA8, ARGB8, BGRA8 & ABGR8 display routines -- added support for RGB8_A8 canvasstyle -- added support for suspended input-buffer processing -- added mng_read_resume HLAPI function to support read-suspension -- fixed timer-handling to run with Mozilla (Tim Rowley) -- fixed alpha-handling for alpha canvasstyles -- fixed some compilation-warnings (contrib Jason Morris) - -samples: -- fixed mngview(delphi) to work with the new core -- synchronized libmng.pas(delphi) with the new libmng.h header -- removed the error- & trace-strings from libmng.pas(delphi) -- fixed mngtree(Unix) to compile on Linux (runs with libmng.so) -- added makefile.linux for mngtree(Unix) (tested on RedHat6.2) - -contrib: -- updated mngplg to 0.2.2 (based on latest code; supports JNG!) - -doc: -- this file obviously -- added Tim Rowley as contributing author -- changed the examples.readme doc -- updated the design-schematics in line with the current code - -makefiles: -- changed the directory to "makefiles" to avoid name-conflicts -- added generic Unix makefile (thanks to Tim Rowley) -- added Linux ELF makefile (tested on RedHat6.2) - ------------------------------------------------------------ - -0.5.1 May 16th 2000 -------------------- - -in short: - -This is the second release for developers -It's a bit of a milestone since all the chunk functionality is in place and -functioning (read, examine, create & write) -This version is incompatible with 0.5.0 since some of the callback prototypes -have changed (should be the last time that happens!) -There are a few more samples and even a real contribution! - -Fixed bug 105795 & 105797 -Fixed a mis-alignment in animation-timing -Added chunk-access functions -Finished all chunk-storage routine-bits -Finished all chunk-write routines -Changed the callback prototypes to allow error-reporting back to the library -Fixed some routines to allow for callback error-reporting -Added version-control functions & constants -Added two functions to set display- & sRGB-profile from memory -Moved CRC table to dynamic structure (for improved thread-safety) -Added SAVE & SEEK save&restore functionality -Finished the application-based CMS-callbacks -Fixed a few BCB specifics -Changed the Win32 DLL and samples to use __stdcall -Did some more assorted little changes -Added 2 BCB samples -Added 1 Unix sample -Added the MNG plugin by Jason Summers in the contrib section -Changed some documents to reflect these changes - -------------------- - -bugfixes: -B001(105795) - fixed wrong lcms call & memory-leak for gammatables -B002(105797) - fixed problem with missing sRGB profile - -core: -- changed chunk iteration function -- added chunk access functions -- added version control constants & functions -- changed strict-ANSI stuff -- added set_outputprofile2 & set_srgbprofile2 -- added empty-chunk put-routines -- added version_dll & VERSION_DLL (for consistency) -- added version control explanatory text & samples -- added iteratechunk callback definition -- improved definitions for DLL support -- added 8-bit palette definition -- added general array definitions -- added MNG_NULL definition -- changed most callback prototypes to allow the app - to report errors during callback processing -- added CRC table to main structure (for thread-safety) -- added iPLTEentries for checking hIST-length -- changed palette definition to exported palette-type -- removed frozen indicator -- added create/write indicators -- added eMNGma hack (will be removed in 1.0.0 !!!) -- added TERM animation object pointer (easier reference) -- added saved-data structure for SAVE/SEEK processing -- added some errorcodes -- added application errorcodes (used with callbacks) -- moved chunk-access errorcodes to severity 5 -- added chunk-access function trace-codes -- changed trace to macro for callback error-reporting -- added save_state & restore_state trace-codes -- put in some extra comments -- fixed layout for sBIT, PPLT -- changed write callback definition -- fixed layout for PPLT again (missed deltatype ?!?) -- cleaned up left-over teststuff in the BACK chunk routine -- changed CRC initialization to use dynamic structure - (wasn't thread-safe the old way !) -- filled in many missing sequence&length checks -- filled in many missing chunk-store snippets -- added checks for running animations -- filled remaining write routines -- fixed read_pplt with regard to deltatype -- added callback error-reporting support -- added pre-draft48 support (short MHDR, frame_mode, LOOP) -- fixed chunk-storage bit in several routines -- supplemented the SAVE & SEEK display processing -- added init of iPLTEcount -- changed calling-convention definition -- changed status-handling of display-routines -- added versioning-control routines -- filled the write routine -- fixed frame_delay misalignment -- added sanity check for frozen status -- changed display_mend to reset state to initial or SAVE -- added save_state and restore_state for SAVE/SEEK/TERM - processing -- added process_save & process_seek routines -- changed and filled iterate-chunk function -- added getchunk functions -- added putchunk functions -- added empty-chunk put-routines -- filled application-based color-management routines -- added creatememprofile -- filled the deflatedata routine -- added cleanup of saved-data (SAVE/SEEK processing) -- moved the actual write_graphic functionality from mng_hlapi.c - to it's appropriate function in the mng_write.c module -- moved standard header includes into mng_types.h - (stdlib/mem for mem-mngmt & math for fp gamma-calc) -- added getimgdata & putimgdata functions - -samples: -- fixed mngview(delphi) to work with the new core -- synchronized libmng.pas(delphi) with the new libmng.h header -- added mngtree(bcb) sample -- added bogus(bcb) sample -- added mngtree(unix) sample - -contrib: -- added mngplg 0.1.0 / a MNG plugin for Win32 by Jason Summers - -doc: -- added this changes.readme file -- changed the samples.readme doc accordingly -- changed the contrib.readme doc accordingly - ------------------------------------------------------------ - -0.5.0 May 1st 2000 ------------------- - -in short: - -This is the first developers release. -It's roughly about 60% done. diff --git a/plugins/AdvaImg/src/LibMNG/LICENSE b/plugins/AdvaImg/src/LibMNG/LICENSE deleted file mode 100644 index 5878e32a2a..0000000000 --- a/plugins/AdvaImg/src/LibMNG/LICENSE +++ /dev/null @@ -1,57 +0,0 @@ -/* ************************************************************************** */ -/* * * */ -/* * COPYRIGHT NOTICE: * */ -/* * * */ -/* * Copyright (c) 2000-2007 Gerard Juyn (gerard@libmng.com) * */ -/* * [You may insert additional notices after this sentence if you modify * */ -/* * this source] * */ -/* * * */ -/* * For the purposes of this copyright and license, "Contributing Authors" * */ -/* * is defined as the following set of individuals: * */ -/* * * */ -/* * Gerard Juyn * */ -/* * Glenn Randers-Pehrson * */ -/* * * */ -/* * The MNG Library is supplied "AS IS". The Contributing Authors * */ -/* * disclaim all warranties, expressed or implied, including, without * */ -/* * limitation, the warranties of merchantability and of fitness for any * */ -/* * purpose. The Contributing Authors assume no liability for direct, * */ -/* * indirect, incidental, special, exemplary, or consequential damages, * */ -/* * which may result from the use of the MNG Library, even if advised of * */ -/* * the possibility of such damage. * */ -/* * * */ -/* * Permission is hereby granted to use, copy, modify, and distribute this * */ -/* * source code, or portions hereof, for any purpose, without fee, subject * */ -/* * to the following restrictions: * */ -/* * * */ -/* * 1. The origin of this source code must not be misrepresented; * */ -/* * you must not claim that you wrote the original software. * */ -/* * * */ -/* * 2. Altered versions must be plainly marked as such and must not be * */ -/* * misrepresented as being the original source. * */ -/* * * */ -/* * 3. This Copyright notice may not be removed or altered from any source * */ -/* * or altered source distribution. * */ -/* * * */ -/* * The Contributing Authors specifically permit, without fee, and * */ -/* * encourage the use of this source code as a component to supporting * */ -/* * the MNG and JNG file format in commercial products. If you use this * */ -/* * source code in a product, acknowledgment would be highly appreciated. * */ -/* * * */ -/* ************************************************************************** */ -/* * * */ -/* * Parts of this software have been adapted from the libpng package. * */ -/* * Although this library supports all features from the PNG specification * */ -/* * (as MNG descends from it) it does not require the libpng package. * */ -/* * It does require the zlib library and optionally the IJG jpeg library, * */ -/* * and/or the "little-cms" library by Marti Maria (depending on the * */ -/* * inclusion of support for JNG and Full-Color-Management respectively. * */ -/* * * */ -/* * This library's function is primarily to read and display MNG * */ -/* * animations. It is not meant as a full-featured image-editing * */ -/* * component! It does however offer creation and editing functionality * */ -/* * at the chunk level. * */ -/* * (future modifications may include some more support for creation * */ -/* * and or editing) * */ -/* * * */ -/* ************************************************************************** */ diff --git a/plugins/AdvaImg/src/LibMNG/README b/plugins/AdvaImg/src/LibMNG/README deleted file mode 100644 index 35b12596f1..0000000000 --- a/plugins/AdvaImg/src/LibMNG/README +++ /dev/null @@ -1,36 +0,0 @@ -libmng 1.0.10 -------------- - -Added provisional ANG and anIM support, and made some minor bugfixes. - -libmng 1.0.9 ------------- - -A number of optimizations in the chunk handling and reader/writer code. -This saves over 20KB on binary footprint! - -Also several bugfixes and a couple of patches bring it another step -closer to perfection.... :-) - -See CHANGELOG for details. - - -Y.T. - -Gerard - - -For more information please visit: - -The official libmng web-site: - http://www.libmng.com/ - -Libmng's community on SourceForge: - https://sourceforge.net/project/?group_id=5635 - -The official MNG homepage: - http://www.libpng.org/pub/mng/ - -The official PNG homepage: - http://www.libpng.org/pub/png/ - diff --git a/plugins/AdvaImg/src/LibMNG/README.autoconf b/plugins/AdvaImg/src/LibMNG/README.autoconf deleted file mode 100644 index 97167b7d74..0000000000 --- a/plugins/AdvaImg/src/LibMNG/README.autoconf +++ /dev/null @@ -1,213 +0,0 @@ -********************************************************************** -********************************************************************** - - ***** this is unmaintained ***** - -If you happen to find problems with autoconfiguration and building, -I simply cannot help you. I'm looking for a maintainer that doesn't mind -spending a few minutes every now and then on the next release to make sure -things are still in working order. - -For the moment all autoconf stuff ahs been moved into unmaintained!! - -********************************************************************** -********************************************************************** - - - - -Configuration from CVS -====================== - -If you're using source checked out from CVS, rather than a source -distribution tarball, please be aware that you can use ./autogen.sh in -place of ./configure below. - -Because this is a cross-platform project, the source templates for -the autoconf scripts are sequestered in the 'makefiles' directory. -Running './autogen.sh' will copy them into their conventional places at -the lop level. If you already see the files there, you don't need to -worry about this step. - -Basic Installation -================== - - These are generic installation instructions. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, a file -`config.cache' that saves the results of its tests to speed up -reconfiguring, and a file `config.log' containing compiler output -(useful mainly for debugging `configure'). - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If at some point `config.cache' -contains results you don't want to keep, you may remove or edit it. - - The file `configure.in' is used to create `configure' by a program -called `autoconf'. You only need `configure.in' if you want to change -it or regenerate `configure' using a newer version of `autoconf'. - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. - - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - -Compilers and Options -===================== - - Some systems require unusual options for compilation or linking that -the `configure' script does not know about. You can give `configure' -initial values for variables by setting them in the environment. Using -a Bourne-compatible shell, you can do that on the command line like -this: - CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure - -Or on systems that have the `env' program, you can do it like this: - env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure - -Compiling For Multiple Architectures -==================================== - - You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - If you have to use a `make' that does not supports the `VPATH' -variable, you have to compile the package for one architecture at a time -in the source code directory. After you have installed the package for -one architecture, use `make distclean' before reconfiguring for another -architecture. - -Installation Names -================== - - By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PATH'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PATH', the package will use -PATH as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=PATH' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Specifying the System Type -========================== - - There may be some features `configure' can not figure out -automatically, but needs to determine by the type of host the package -will run on. Usually `configure' can figure that out, but if it prints -a message saying it can not guess the host type, give it the -`--host=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name with three fields: - CPU-COMPANY-SYSTEM - -See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the host type. - - If you are building compiler tools for cross-compiling, you can also -use the `--target=TYPE' option to select the type of system they will -produce code for and the `--build=TYPE' option to select the type of -system on which you are compiling the package. - -Sharing Defaults -================ - - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Operation Controls -================== - - `configure' recognizes the following options to control how it -operates. - -`--cache-file=FILE' - Use and save the results of the tests in FILE instead of - `./config.cache'. Set FILE to `/dev/null' to disable caching, for - debugging `configure'. - -`--help' - Print a summary of the options to `configure', and exit. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`--version' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`configure' also accepts some other, not widely useful, options. diff --git a/plugins/AdvaImg/src/LibMNG/README.config b/plugins/AdvaImg/src/LibMNG/README.config deleted file mode 100644 index 97fcb31606..0000000000 --- a/plugins/AdvaImg/src/LibMNG/README.config +++ /dev/null @@ -1,104 +0,0 @@ -Configuration options in libmng -=============================== - -The library is fairly configurable through the use of a number of defines. -Please note however that certain defines are for internal use only. -The following list gives a summary of options that can be used externally to -define the functionality of the library: - -======================================== - -#define MNG_BUILD_DLL - -This is used to indicate that a "standard" DLL should result from compiling -the library. Please note the remarks in README.dll if you intend to work -with the library as a DLL. The purpose of this option is to ensure that -DLL builds have the same set of functions. - -#define MNG_BUILD_SO - -This is used to indicate that a "standard" shared library (SO) should result -from a compilation. The purpose of this option is to ensure that all -shared libraries generated this way will have the same set of functions. - -#define MNG_USE_DLL / #define MNG_USE_SO - -These should be used when including the library header in the compilation -of an application to indicate that the compiler/linker must take the -necessary steps to make the binary executable to use the standard DLL -or shared library (SO). - -#define MNG_SKIP_ZLIB / #define MNG_SKIP_LCMS / #define MNG_SKIP_IJG6B - -Use these in conjunction with MNG_USE_DLL / MNG_USE_SO. This is useful if -you only need the external definitions of the MNG library and not the others, -which will speed up the compilation process. - -#define MNG_SUPPORT_FULL / #define MNG_SUPPORT_LC / #define MNG_SUPPORT_VLC - -These can be used to indicate the level of MNG spec compliance required. -Currently only full MNG compliance is supported. - -#define MNG_SUPPORT_IJG6B - -This can be used to indicate if JNG support is required. This option will -include the IJG JPEG-library. Note that MNG_SUPPORT_FULL will automatically -set this option. Use this only if you need JNG support with MNG-(V)LC. - -#define MNG_FULL_CMS / #define MNG_GAMMA_ONLY / #define MNG_NO_CMS / -#define MNG_APP_CMS - -These indicate the color-correction support level of the library. -If you are on a platform that supports lcms (Little CMS by Marti Maria Saguar) -then it is highly recommended to define MNG_FULL_CMS. -If your platform has it's own CMS then select MNG_APP_CMS and be sure to -include the appropriate callbacks in your app. -In all other cases it is recommended to define MNG_GAMMA_ONLY. - -#define MNG_SUPPORT_READ / #define MNG_SUPPORT_WRITE / -#define MNG_SUPPORT_DISPLAY - -These indicate the high-level support for reading, writing and/or -displaying files. Note that in order to display a file, you'll need to read -it first. (yes, really!) - -#define MNG_STORE_CHUNKS - -This indicates that the library should store chunk-information when reading -a file. This information can then be processed through the -MNG_ITERATE_CHUNKS() function. Note that you must specify this option if -you want to create and write a new file. - -#define MNG_ACCESS_CHUNKS - -This is used to indicate that the app may need access to internally stored -chunk information. MNG_STORE_CHUNKS must be defined as well for this option -to function properly. - -#define MNG_INTERNAL_MEMMNGMT - -You can use this to have the library handle it's own memory allocation and -deallocation through the "standard" memory functions. This option is turned -off by default, which means your app must define the memory callbacks. - -#define MNG_ERROR_TELLTALE - -Set this on to allow human-readable error-messages to be included in the -library and the error function and callback. - -#define MNG_BIGENDIAN_SUPPORTED - -This option should be used to indicate the hardware is based on big endian -integers. - -#define MNG_SUPPORT_TRACE / #define MNG_TRACE_TELLTALE - -These two can be used when debugging an app. You'll need to have the trace -callback setup also. This allows for a rather thorough investigation of the -libraries function paths. - -======================================== - -Any other optional defines you may encounter are for internal use only. -please do not specify them externally. In case of doubt, consult the -support email lists. More info can be found on http://www.libmng.com diff --git a/plugins/AdvaImg/src/LibMNG/README.contrib b/plugins/AdvaImg/src/LibMNG/README.contrib deleted file mode 100644 index 2d51ac50a1..0000000000 --- a/plugins/AdvaImg/src/LibMNG/README.contrib +++ /dev/null @@ -1,95 +0,0 @@ -The contrib directory contains contributions made by fellow -enthousiasts. (Check respective web-sites for the latest version) - ----------------------------------------------------------------------- - -mngplg - A Netscape plugin for MNG - by Jason Summers - -http://pobox.com/~jason1/imaging/mngplg/ - -The very first contribution, and what a start! -GIF look out, MNG is on the prowl and ready to swat you like a fly! - ----------------------------------------------------------------------- - -mngplay - An SDL based MNG viewer - by Ralph Giles - -http://snow.ashlu.bc.ca/~giles/mng/ - -Another nice contribution. View MNG files on practically any platform -with this standalone viewer. -Source-code only; Requires SDL library and libmng.so - -(Modified by Greg Roelofs) - ----------------------------------------------------------------------- - -mngview - A BCB port of the Delphi sample - by Andy Protano - -I have added this nice little port to the BCB samples directory. -It adds a nifty progressbar while reading a file. Excellent work! -Requires libmng.dll -(note: this is in the BCB samples directory) - ----------------------------------------------------------------------- - -mngdump - A BCB GUI-based dump utility - by Andy Protano - -Andy has sent me this fully functional MNG dump utility, that gives -detailed information of the contents of any MNG file. -Requires libmng.dll - ----------------------------------------------------------------------- - -mng-view - A GTK-based MNG viewer - by Vova Babin - -Vova has been hacking away with the libmng code and has come up with -this nice little sample how to write a MNG viewer using GTK. -Thanks mate! -Source-code only -Requires GTK+ (1.2 or higher) and libmng (0.9.2 or higher) - -(Modified by Greg Roelofs) - ----------------------------------------------------------------------- - -mngview - Another MNG viewer; this one for MSVC - by Nicholaus Brennig - -A welcome contribution from Nicholaus. Author of SlowView. A very nice -image-handling utility for Windows. A welcome contribution since there -have been numerous questions about linking libmng with MSVC. -Well, look no further. Here it is! - ----------------------------------------------------------------------- - -MSVC libmng project - An MSVC project to build libmng.dll - - by Chad Austin - -Chad has contributed some project-files that you could use to build -libmng.dll with MSVC. Please be sure to read the README file included. - ----------------------------------------------------------------------- - -fbmngplay - A simple fbcon based mng player - by Stefan Reinauer - -Stefan has contributed this little example, based on Ralph's -SDL player. It uses the kernel framebuffer device to display mng -animations through the libmng interface. -(currently for 16-bit buffers only) - ----------------------------------------------------------------------- - -xmngview - Lesstif/Motif standalone player for MNG files - - by Winfried Szukalski - -Winfried contributed this MNG player for X-based systems. -(recently updated) - ----------------------------------------------------------------------- - -makemng - A delta-MNG creation utility for MSVC - by Alex Volkov - -Alex sent me this nice utility that will allow you to create highly -optmized MNGs using the delta-PNG capabilities of MNG. - ----------------------------------------------------------------------- diff --git a/plugins/AdvaImg/src/LibMNG/README.examples b/plugins/AdvaImg/src/LibMNG/README.examples deleted file mode 100644 index 9f23b5077b..0000000000 --- a/plugins/AdvaImg/src/LibMNG/README.examples +++ /dev/null @@ -1,48 +0,0 @@ -The samples are in platform-specific directories. - -!!! contributions are very welcome !!! - - -bcb - Borland C++ Builder (3.0) (found under bcb/xxx) ------------------------------------------------------ - -win32dll - sample project to create a Windows dll. Requires zlib1.2.1, - IJG jpgsrc6b and lcms1.0.14. The directories containing these - libraries must be at the same level as the libmng directory. - So if you're in the directory with this file and the libmng - sources, they should be in ..\zlib , ..\jpgsrc6b and ..\lcms - respectively. - -!!! To run the other Win32 samples you need to copy the libmng.dll - file from here into the sample's directory !!! - -mngtree - sample project to create a little command-line tool that dumps - the chunk-structure of a given file onto stdout. - -bogus - a completely bogus example on how to create a perfectly valid - (though slightly biased) MNG. - -mngview - port of the Delphi mngview sample. contributed by Andy Protano. - see also README.contrib - -mngrepair- an example on how to fix invalid MNG files - uses the new mng_copy_chunks() function and MNG_SOFTERRORS to - 'ignore' certain input-errors. This conditional *MUST* only be used - for exactly this kind of software; eg. repair utilities. - - -delphi - Borland Delphi (3.0+) (found under contrib/delphi/xxx) ---------------------------------------------------------------- - -mngview - sample project for a simple mng-viewer. The general unit in - the delphi directory was translated from libmng.h It can be - used in other projects to access libmng.dll created with the - win32dll example above. - - -unix - Unix (found under contrib/gcc/xxx) ------------------------------------------ - -mngtree - basically a copy of the BCB sample. It includes a makefile for - Linux and it's been tested on RedHat6.2 - diff --git a/plugins/AdvaImg/src/LibMNG/README.footprint b/plugins/AdvaImg/src/LibMNG/README.footprint deleted file mode 100644 index ae47da2c1a..0000000000 --- a/plugins/AdvaImg/src/LibMNG/README.footprint +++ /dev/null @@ -1,46 +0,0 @@ -/* - You can use one or more of the following defines to - reduce the size of the compiled library. Define the - SKIPCANVAS macros for any canvas configurations that - your application doesn't use. Define the SKIPCHUNK - macros for any chunks that your application doesn't - process. Define MNG_OPTIMIZE_FOOTPRINT to choose - smaller code size over faster execution and less memory - usage. These macros became available in version 1.0.6. -*/ - -/* eliminate unused features from libmng */ -#define MNG_OPTIMIZE_FOOTPRINT -#define MNG_OPTIMIZE_OBJCLEANUP -#define MNG_OPTIMIZE_CHUNKINITFREE -#define MNG_OPTIMIZE_CHUNKASSIGN -#define MNG_OPTIMIZE_CHUNKREADER - -#define MNG_SKIPCANVAS_ABGR8 -#define MNG_SKIPCANVAS_ARGB8 -#define MNG_SKIPCANVAS_BGR8 -#define MNG_SKIPCANVAS_BGRA8 -#define MNG_SKIPCANVAS_BGRA8_PM -#define MNG_SKIPCANVAS_BGRX8 -#define MNG_SKIPCANVAS_RGBA8 -#define MNG_SKIPCANVAS_BGR565 -#define MNG_SKIPCANVAS_RGB565 -#define MNG_SKIPCANVAS_BGRA565 -#define MNG_SKIPCANVAS_RGBA565 - -#define MNG_SKIPCHUNK_iCCP -#define MNG_SKIPCHUNK_tEXt -#define MNG_SKIPCHUNK_zTXt -#define MNG_SKIPCHUNK_iTXt -#define MNG_SKIPCHUNK_bKGD -#define MNG_SKIPCHUNK_pHYs -#define MNG_SKIPCHUNK_sBIT -#define MNG_SKIPCHUNK_sPLT -#define MNG_SKIPCHUNK_hIST -#define MNG_SKIPCHUNK_tIME -#define MNG_SKIPCHUNK_eXPI -#define MNG_SKIPCHUNK_fPRI -#define MNG_SKIPCHUNK_nEED -#define MNG_SKIPCHUNK_pHYg - - diff --git a/plugins/AdvaImg/src/LibMNG/README.packaging b/plugins/AdvaImg/src/LibMNG/README.packaging deleted file mode 100644 index 32fb2da8be..0000000000 --- a/plugins/AdvaImg/src/LibMNG/README.packaging +++ /dev/null @@ -1,24 +0,0 @@ -Packaging Libmng for distribution ---------------------------------- - -These are some notes for those building binaries for distribution. - -We're interested to hear about anywhere libmng is helpful, so let us -know if you're including it with your application or OS. Also, if your -build is publicly accessible, we'd be happy to link to it from -the libmng site. - -However, We respectfully request that you *not* distribute binaries as a -shared library (DLL) with any of the major features disabled. While -there is support for this in terms of #ifdef directives (in -libmng_conf.h) and autoconf switches they are intended for embedded -application and testing. The default compilation options support the -full MNG specification, and we wish to avoid the confusion among -general users that partial support would engender. - - -Platform specific notes: - -We have a basic .spec file for generating rpms. Send us a note if you'd -like to clean it up. - diff --git a/plugins/AdvaImg/src/LibMNG/libmng.h b/plugins/AdvaImg/src/LibMNG/libmng.h deleted file mode 100644 index 8513bf1127..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng.h +++ /dev/null @@ -1,2932 +0,0 @@ -/* ************************************************************************** */ -/* * * */ -/* * COPYRIGHT NOTICE: * */ -/* * * */ -/* * Copyright (c) 2000-2007 Gerard Juyn * */ -/* * [You may insert additional notices after this sentence if you modify * */ -/* * this source] * */ -/* * * */ -/* * For the purposes of this copyright and license, "Contributing Authors" * */ -/* * is defined as the following set of individuals: * */ -/* * * */ -/* * Gerard Juyn - gjuyn :at: users.sourceforge.net * */ -/* * Glenn Randers-Pehrson - glennrp :at: users.sourceforge.net * */ -/* * Raphael Assenat - raph :at: raphnet.net * */ -/* * John Stiles - * */ -/* * * */ -/* * The MNG Library is supplied "AS IS". The Contributing Authors * */ -/* * disclaim all warranties, expressed or implied, including, without * */ -/* * limitation, the warranties of merchantability and of fitness for any * */ -/* * purpose. The Contributing Authors assume no liability for direct, * */ -/* * indirect, incidental, special, exemplary, or consequential damages, * */ -/* * which may result from the use of the MNG Library, even if advised of * */ -/* * the possibility of such damage. * */ -/* * * */ -/* * Permission is hereby granted to use, copy, modify, and distribute this * */ -/* * source code, or portions hereof, for any purpose, without fee, subject * */ -/* * to the following restrictions: * */ -/* * * */ -/* * 1. The origin of this source code must not be misrepresented; * */ -/* * you must not claim that you wrote the original software. * */ -/* * * */ -/* * 2. Altered versions must be plainly marked as such and must not be * */ -/* * misrepresented as being the original source. * */ -/* * * */ -/* * 3. This Copyright notice may not be removed or altered from any source * */ -/* * or altered source distribution. * */ -/* * * */ -/* * The Contributing Authors specifically permit, without fee, and * */ -/* * encourage the use of this source code as a component to supporting * */ -/* * the MNG and JNG file format in commercial products. If you use this * */ -/* * source code in a product, acknowledgment would be highly appreciated. * */ -/* * * */ -/* ************************************************************************** */ -/* * * */ -/* * Parts of this software have been adapted from the libpng package. * */ -/* * Although this library supports all features from the PNG specification * */ -/* * (as MNG descends from it) it does not require the libpng package. * */ -/* * It does require the zlib library and optionally the IJG jpeg library, * */ -/* * and/or the "little-cms" library by Marti Maria (depending on the * */ -/* * inclusion of support for JNG and Full-Color-Management respectively. * */ -/* * * */ -/* * This library's function is primarily to read and display MNG * */ -/* * animations. It is not meant as a full-featured image-editing * */ -/* * component! It does however offer creation and editing functionality * */ -/* * at the chunk level. * */ -/* * (future modifications may include some more support for creation * */ -/* * and or editing) * */ -/* * * */ -/* ************************************************************************** */ - -/* ************************************************************************** */ -/* * * */ -/* * Version numbering * */ -/* * * */ -/* * X.Y.Z : X = release (0 = initial build) * */ -/* * Y = major version (uneven = test; even = production) * */ -/* * Z = minor version (bugfixes; 2 is older than 10) * */ -/* * * */ -/* * production versions only appear when a test-version is extensively * */ -/* * tested and found stable or for intermediate bug-fixes (recognized by * */ -/* * a change in the Z number) * */ -/* * * */ -/* * x.1.x = test version * */ -/* * x.2.x = production version * */ -/* * x.3.x = test version * */ -/* * x.4.x = production version * */ -/* * etc. * */ -/* * * */ -/* ************************************************************************** */ -/* * * */ -/* * Identifier naming conventions throughout this library * */ -/* * * */ -/* * iXxxx = an integer * */ -/* * dXxxx = a float * */ -/* * pXxxx = a pointer * */ -/* * bXxxx = a boolean * */ -/* * eXxxx = an enumeration * */ -/* * hXxxx = a handle * */ -/* * zXxxx = a zero-terminated string (pchar) * */ -/* * fXxxx = a pointer to a function (callback) * */ -/* * aXxxx = an array * */ -/* * sXxxx = a structure * */ -/* * * */ -/* * Macros & defines are in all uppercase. * */ -/* * Functions & typedefs in all lowercase. * */ -/* * Exported stuff is prefixed with MNG_ or mng_ respectively. * */ -/* * * */ -/* * (I may have missed a couple; don't hesitate to let me know!) * */ -/* * * */ -/* ************************************************************************** */ - -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng.h copyright (c) 2000-2007 G.Juyn * */ -/* * version : 1.0.10 * */ -/* * * */ -/* * purpose : main application interface * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * comment : The main application interface. An application should not * */ -/* * need access to any of the other modules! * */ -/* * * */ -/* * changes : 0.5.1 - 05/06/2000 - G.Juyn * */ -/* * - changed chunk iteration function * */ -/* * 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - added chunk access functions * */ -/* * - added version control constants & functions * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - added set_outputprofile2 & set_srgbprofile2 * */ -/* * - added empty-chunk put-routines * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - added version_dll & VERSION_DLL (for consistency) * */ -/* * - added version control explanatory text & samples * */ -/* * 0.5.1 - 05/15/2000 - G.Juyn * */ -/* * - added getimgdata & putimgdata functions * */ -/* * * */ -/* * 0.5.2 - 05/16/2000 - G.Juyn * */ -/* * - changed the version parameters (obviously) * */ -/* * 0.5.2 - 05/18/2000 - G.Juyn * */ -/* * - complimented constants for chunk-property values * */ -/* * 0.5.2 - 05/23/2000 - G.Juyn * */ -/* * - fixed MNG_UINT_pHYg value * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - added support for get/set default zlib/IJG parms * */ -/* * 0.5.2 - 06/02/2000 - G.Juyn * */ -/* * - added MNG_BIGENDIAN_SUPPORT (contributed by Tim Rowley) * */ -/* * - separated configuration-options into "mng_conf.h" * */ -/* * - added RGB8_A8 canvasstyle * */ -/* * - added getalphaline callback for RGB8_A8 canvasstyle * */ -/* * 0.5.2 - 06/06/2000 - G.Juyn * */ -/* * - moved errorcodes from "mng_error.h" * */ -/* * - added mng_read_resume function to support * */ -/* * read-suspension * */ -/* * * */ -/* * 0.5.3 - 06/16/2000 - G.Juyn * */ -/* * - changed the version parameters (obviously) * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added get/set for speedtype to facilitate testing * */ -/* * - added get for imagelevel during processtext callback * */ -/* * 0.5.3 - 06/24/2000 - G.Juyn * */ -/* * - fixed inclusion of IJG read/write code * */ -/* * 0.5.3 - 06/26/2000 - G.Juyn * */ -/* * - changed userdata variable to mng_ptr * */ -/* * * */ -/* * 0.9.0 - 06/30/2000 - G.Juyn * */ -/* * - changed refresh parameters to 'x,y,width,height' * */ -/* * * */ -/* * 0.9.1 - 07/06/2000 - G.Juyn * */ -/* * - added MNG_NEEDTIMERWAIT errorcode * */ -/* * - changed comments to indicate modified behavior for * */ -/* * timer & suspension breaks * */ -/* * 0.9.1 - 07/08/2000 - G.Juyn * */ -/* * - added get routines for internal display variables * */ -/* * - added get/set routines for suspensionmode variable * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - added callbacks for SAVE/SEEK processing * */ -/* * - added get/set routines for sectionbreak variable * */ -/* * - added NEEDSECTIONWAIT errorcode * */ -/* * 0.9.1 - 07/19/2000 - G.Juyn * */ -/* * - added function to set frame-/layer-count & playtime * */ -/* * - added errorcode for updatemngheader if not a MNG * */ -/* * * */ -/* * 0.9.2 - 07/31/2000 - G.Juyn * */ -/* * - fixed problem with trace-functions improperly wrapped * */ -/* * - added status_xxxx functions * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * - added function to set simplicity field * */ -/* * * */ -/* * 0.9.3 - 08/09/2000 - G.Juyn * */ -/* * - added check for simplicity-bits in MHDR * */ -/* * 0.9.3 - 08/12/2000 - G.Juyn * */ -/* * - added workaround for faulty PhotoShop iCCP chunk * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * 0.9.3 - 10/10/2000 - G.Juyn * */ -/* * - added support for alpha-depth prediction * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - fixed processing of unknown critical chunks * */ -/* * - removed test-MaGN * */ -/* * - added PNG/MNG spec version indicators * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added functions to retrieve PNG/JNG specific header-info * */ -/* * - added JDAA chunk * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added callback to process non-critical unknown chunks * */ -/* * 0.9.3 - 10/20/2000 - G.Juyn * */ -/* * - added errocode for delayed delta-processing * */ -/* * - added get/set for bKGD preference setting * */ -/* * 0.9.3 - 10/21/2000 - G.Juyn * */ -/* * - added get function for interlace/progressive display * */ -/* * * */ -/* * 0.9.4 - 01/18/2001 - G.Juyn * */ -/* * - added errorcode for MAGN methods * */ -/* * - removed test filter-methods 1 & 65 * */ -/* * * */ -/* * 1.0.0 - 02/05/2001 - G.Juyn * */ -/* * - version numbers (obviously) * */ -/* * * */ -/* * 1.0.1 - 02/08/2001 - G.Juyn * */ -/* * - added MEND processing callback * */ -/* * 1.0.1 - 04/21/2001 - G.Juyn (code by G.Kelly) * */ -/* * - added BGRA8 canvas with premultiplied alpha * */ -/* * 1.0.1 - 05/02/2001 - G.Juyn * */ -/* * - added "default" sRGB generation (Thanks Marti!) * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added optimization option for MNG-video playback * */ -/* * - added processterm callback * */ -/* * 1.0.2 - 06/25/2001 - G.Juyn * */ -/* * - added late binding errorcode (not used internally) * */ -/* * - added option to turn off progressive refresh * */ -/* * * */ -/* * 1.0.3 - 08/06/2001 - G.Juyn * */ -/* * - added get function for last processed BACK chunk * */ -/* * * */ -/* * 1.0.5 - 07/04/2002 - G.Juyn * */ -/* * - added errorcode for extreme chunk-sizes * */ -/* * 1.0.5 - 08/07/2002 - G.Juyn * */ -/* * - added test-option for PNG filter method 193 (=no filter) * */ -/* * 1.0.5 - 08/15/2002 - G.Juyn * */ -/* * - completed PROM support * */ -/* * - completed delta-image support * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - added HLAPI function to copy chunks * */ -/* * 1.0.5 - 09/14/2002 - G.Juyn * */ -/* * - added event handling for dynamic MNG * */ -/* * - added 'supports' call to check function availability * */ -/* * 1.0.5 - 09/15/2002 - G.Juyn * */ -/* * - fixed LOOP iteration=0 special case * */ -/* * 1.0.5 - 09/20/2002 - G.Juyn * */ -/* * - added support for PAST * */ -/* * 1.0.5 - 09/22/2002 - G.Juyn * */ -/* * - added bgrx8 canvas (filler byte) * */ -/* * 1.0.5 - 10/07/2002 - G.Juyn * */ -/* * - added check for TERM placement during create/write * */ -/* * - added beta version function & constant * */ -/* * 1.0.5 - 11/07/2002 - G.Juyn * */ -/* * - added support to get totals after mng_read() * */ -/* * * */ -/* * 1.0.6 - 07/07/2003 - G. Randers-Pehrson * */ -/* * - added support for reducing the footprint of libmng * */ -/* * by macros that optionally skip unused chunks, remove * */ -/* * 16-bit sample support, remove Delta support, and * */ -/* * remove JNG support, to accomodate Mozilla/Firebird. * */ -/* * 1.0.6 - 07/14/2003 - G. Randers-Pehrson * */ -/* * - further optional removal of unused functions * */ -/* * * */ -/* * 1.0.7 - 11/27/2003 - R.A * */ -/* * - added CANVAS_RGB565 and CANVAS_BGR565 * */ -/* * 1.0.7 - 12/06/2003 - R.A * */ -/* * - added CANVAS_RGBA565 and CANVAS_BGRA565 * */ -/* * 1.0.7 - 01/25/2004 - J.S * */ -/* * - added premultiplied alpha canvas' for RGBA, ARGB, ABGR * */ -/* * 1.0.7 - 03/07/2004 - G. Randers-Pehrson * */ -/* * - put gamma, cms-related declarations inside #ifdef * */ -/* * 1.0.7 - 03/10/2004 - G.R-P * */ -/* * - added conditionals around openstream/closestream * */ -/* * * */ -/* * 1.0.8 - 04/02/2004 - G.Juyn * */ -/* * - added CRC existence & checking flags * */ -/* * 1.0.8 - 04/12/2004 - G.Juyn * */ -/* * - added data-push mechanisms for specialized decoders * */ -/* * 1.0.8 - 06/05/2004 - G.R-P * */ -/* * - define MNG_INCLUDE_ZLIB when MNG_USE_ZLIB_CRC is defined * */ -/* * * */ -/* * 1.0.9 - 10/03/2004 - G.Juyn * */ -/* * - added function to retrieve current FRAM delay * */ -/* * 1.0.9 - 10/14/2004 - G.Juyn * */ -/* * - added bgr565_a8 canvas-style (thanks to J. Elvander) * */ -/* * 1.0.9 - 10/17/2004 - G.Juyn * */ -/* * - fixed PPLT getchunk/putchunk routines * */ -/* * * */ -/* * 1.0.10 - 03/07/2006 - (thanks to W. Manthey) * */ -/* * - added CANVAS_RGB555 and CANVAS_BGR555 * */ -/* * 1.0.10 - 04/08/2007 - G.Juyn * */ -/* * - added support for mPNG proposal * */ -/* * 1.0.10 - 04/12/2007 - G.Juyn * */ -/* * - added support for ANG proposal * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_h_ -#define _libmng_h_ - -/* ************************************************************************** */ - -#include "libmng_conf.h" /* user-specific configuration options */ - -/* ************************************************************************** */ - -#define MNG_CHECK_BAD_ICCP /* let's catch that sucker !!! */ - -#ifdef MNG_SUPPORT_READ /* dependencies based on user-configuration */ -#define MNG_INCLUDE_READ_PROCS -#endif - -#ifdef MNG_SUPPORT_WRITE -#define MNG_INCLUDE_WRITE_PROCS -#endif - -#ifdef MNG_USE_ZLIB_CRC -#define MNG_INCLUDE_ZLIB -#endif - -#ifdef MNG_SUPPORT_DISPLAY -#define MNG_INCLUDE_FILTERS -#define MNG_INCLUDE_INTERLACE -#define MNG_INCLUDE_OBJECTS -#define MNG_INCLUDE_DISPLAY_PROCS -#define MNG_INCLUDE_TIMING_PROCS -#define MNG_INCLUDE_ZLIB -#endif - -#ifdef MNG_STORE_CHUNKS -#define MNG_INCLUDE_ZLIB -#endif - -#ifdef MNG_SUPPORT_IJG6B -#define MNG_INCLUDE_JNG -#define MNG_INCLUDE_IJG6B -#define MNG_USE_SETJMP -#endif - -#ifdef MNG_INCLUDE_JNG -#if defined(MNG_SUPPORT_DISPLAY) || defined(MNG_ACCESS_CHUNKS) -#define MNG_INCLUDE_JNG_READ -#endif -#if defined(MNG_SUPPORT_WRITE) || defined(MNG_ACCESS_CHUNKS) -#define MNG_INCLUDE_JNG_WRITE -#endif -#endif - -#ifdef MNG_FULL_CMS -#define MNG_INCLUDE_LCMS -#endif - -#ifdef MNG_AUTO_DITHER -#define MNG_INCLUDE_DITHERING -#endif - -#ifdef MNG_SUPPORT_TRACE -#define MNG_INCLUDE_TRACE_PROCS -#ifdef MNG_TRACE_TELLTALE -#define MNG_INCLUDE_TRACE_STRINGS -#endif -#endif - -#ifdef MNG_ERROR_TELLTALE -#define MNG_INCLUDE_ERROR_STRINGS -#endif - -#ifdef MNG_OPTIMIZE_CHUNKINITFREE -#ifndef MNG_OPTIMIZE_CHUNKACCESS -#define MNG_OPTIMIZE_CHUNKACCESS -#endif -#else -#ifdef MNG_OPTIMIZE_CHUNKACCESS -#undef MNG_OPTIMIZE_CHUNKACCESS -#endif -#endif - -/* ************************************************************************** */ - -#include "libmng_types.h" /* platform-specific definitions - and other assorted stuff */ - -/* ************************************************************************** */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Versioning control * */ -/* * * */ -/* * version_so and version_dll will NOT reflect version_major; * */ -/* * these will only change for binary incompatible changes (which will * */ -/* * hopefully never occur) * */ -/* * note: they will be set to 1 on the first public release !!! * */ -/* * * */ -/* * first public release: * */ -/* * #define MNG_VERSION_TEXT "1.0.0" * */ -/* * #define MNG_VERSION_SO 1 eg. libmng.so.1 * */ -/* * #define MNG_VERSION_DLL 1 eg. libmng.dll * */ -/* * #define MNG_VERSION_MAJOR 1 * */ -/* * #define MNG_VERSION_MINOR 0 * */ -/* * #define MNG_VERSION_RELEASE 0 * */ -/* * * */ -/* * bug fix & cosmetics : * */ -/* * #define MNG_VERSION_TEXT "1.0.1" * */ -/* * #define MNG_VERSION_SO 1 eg. libmng.so.1 * */ -/* * #define MNG_VERSION_DLL 1 eg. libmng.dll * */ -/* * #define MNG_VERSION_MAJOR 1 * */ -/* * #define MNG_VERSION_MINOR 0 * */ -/* * #define MNG_VERSION_RELEASE 1 * */ -/* * * */ -/* * feature change : * */ -/* * #define MNG_VERSION_TEXT "1.2.0" * */ -/* * #define MNG_VERSION_SO 1 eg. libmng.so.1 * */ -/* * #define MNG_VERSION_DLL 1 eg. libmng.dll * */ -/* * #define MNG_VERSION_MAJOR 1 * */ -/* * #define MNG_VERSION_MINOR 2 * */ -/* * #define MNG_VERSION_RELEASE 0 * */ -/* * * */ -/* * major rewrite (still binary compatible) : * */ -/* * #define MNG_VERSION_TEXT "2.0.0" * */ -/* * #define MNG_VERSION_SO 1 eg. libmng.so.1 * */ -/* * #define MNG_VERSION_DLL 1 eg. libmng.dll * */ -/* * #define MNG_VERSION_MAJOR 2 * */ -/* * #define MNG_VERSION_MINOR 0 * */ -/* * #define MNG_VERSION_RELEASE 0 * */ -/* * * */ -/* * binary incompatible change: * */ -/* * #define MNG_VERSION_TEXT "13.0.0" * */ -/* * #define MNG_VERSION_SO 2 eg. libmng.so.2 * */ -/* * #define MNG_VERSION_DLL 2 eg. libmng2.dll * */ -/* * #define MNG_VERSION_MAJOR 13 * */ -/* * #define MNG_VERSION_MINOR 0 * */ -/* * #define MNG_VERSION_RELEASE 0 * */ -/* * * */ -/* * note that version_so & version_dll will always remain equal so it * */ -/* * doesn't matter which one is called to do version-checking; they are * */ -/* * just provided for their target platform * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_VERSION_TEXT "1.0.10" -#define MNG_VERSION_SO 1 /* eg. libmng.so.1 */ -#define MNG_VERSION_DLL 1 /* but: libmng.dll (!) */ -#define MNG_VERSION_MAJOR 1 -#define MNG_VERSION_MINOR 0 -#define MNG_VERSION_RELEASE 10 -#define MNG_VERSION_BETA MNG_FALSE - -MNG_EXT mng_pchar MNG_DECL mng_version_text (void); -MNG_EXT mng_uint8 MNG_DECL mng_version_so (void); -MNG_EXT mng_uint8 MNG_DECL mng_version_dll (void); -MNG_EXT mng_uint8 MNG_DECL mng_version_major (void); -MNG_EXT mng_uint8 MNG_DECL mng_version_minor (void); -MNG_EXT mng_uint8 MNG_DECL mng_version_release (void); -MNG_EXT mng_bool MNG_DECL mng_version_beta (void); - -/* use the following call to check wether the version of libmng your app - is using supports the given function; this is useful in apps that dynamically - load the library to make sure a certain function will work; the result will - be MNG_TRUE if the given function is implemented in this version of the library; - Major/Minor/Version indicate the version the function became available; - (if these fields are zero the function is not yet implemented!) */ -#ifdef MNG_SUPPORT_FUNCQUERY -MNG_EXT mng_bool MNG_DECL mng_supports_func (mng_pchar zFunction, - mng_uint8* iMajor, - mng_uint8* iMinor, - mng_uint8* iRelease); -#endif - -/* ************************************************************************** */ -/* * * */ -/* * MNG/PNG specification level conformance * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_PNG_VERSION "1.2" -#define MNG_PNG_VERSION_MAJ 1 -#define MNG_PNG_VERSION_MIN 2 - -#define MNG_MNG_VERSION "1.1" -#define MNG_MNG_VERSION_MAJ 1 -#define MNG_MNG_VERSION_MIN 1 -#define MNG_MNG_DRAFT 99 /* deprecated; - only used for nEED "MNG DRAFT nn" */ - -/* ************************************************************************** */ -/* * * */ -/* * High-level application functions * */ -/* * * */ -/* ************************************************************************** */ - -/* library initialization function */ -/* must be the first called before anything can be done at all */ -/* initializes internal datastructure(s) */ -MNG_EXT mng_handle MNG_DECL mng_initialize (mng_ptr pUserdata, - mng_memalloc fMemalloc, - mng_memfree fMemfree, - mng_traceproc fTraceproc); - -/* library reset function */ -/* can be used to re-initialize the library, so another image can be - processed. there's absolutely no harm in calling it, even when it's not - really necessary */ -MNG_EXT mng_retcode MNG_DECL mng_reset (mng_handle hHandle); - -/* library cleanup function */ -/* must be the last called to clean up internal datastructure(s) */ -MNG_EXT mng_retcode MNG_DECL mng_cleanup (mng_handle* hHandle); - -/* high-level read functions */ -/* use mng_read if you simply want to read a Network Graphic */ -/* mng_read_resume is used in I/O-read-suspension scenarios, where the - "readdata" callback may return FALSE & length=0 indicating its buffer is - depleted or too short to supply the required bytes, and the buffer needs - to be refilled; libmng will return the errorcode MNG_NEEDMOREDATA telling - the app to refill its read-buffer after which it must call mng_read_resume - (or mng_display_resume if it also displaying the image simultaneously) */ -#ifdef MNG_SUPPORT_READ -MNG_EXT mng_retcode MNG_DECL mng_read (mng_handle hHandle); -MNG_EXT mng_retcode MNG_DECL mng_read_resume (mng_handle hHandle); -#endif - -/* high-level "data push" functions */ -/* these functions can be used in situations where data is streaming into the - application and needs to be buffered by libmng before it is actually - requested by libmng itself. the pushing complements the normal reading - mechanism, but applications can decide to always return "0 bytes read" to - make libmng go into suspension mode with the returncode MNG_NEEDMOREDATA */ -/* mng_read_pushdata can be used to push blobs of data of arbitrary size; - mng_read_pushsig and mng_read_pushchunk can be used if the application - has already done some low-level decoding (eg. at the chunk level) */ -/* the data being pushed into libmng with mng_read_pushdata *must* contain - the regular 4-byte chunklength, but *must not* contain it with - mng_read_pushchunk!!! */ -/* mng_read_pushsig is used to prevent libmng from trying to parse the regular - PNG/JNG/MNG signature bytes; the application must have done this itself - and *must* indicate the proper type in the function call or things will - go amiss!! - also you *must* call this first, so pretty much right after mng_initialize - and certainly before any call to mng_read or mng_readdisplay !!!! */ -/* IMPORTANT!!! data can only be safely pushed when libmng is in a - "wait" state; eg. during MNG_NEEDTIMERWAIT, MNG_NEEDSECTIONWAIT or - MNG_NEEDMOREDATA !!! this just means you can't have one thread displaying - and another thread pushing data !!! */ -/* if bOwnership = MNG_TRUE, libmng will retain the supplied pointer and - *will* expect the buffer to remain available until libmng is finished - with it; what happens then depends on whether or not you have set the - releasedata() callback; if this is set than the supplied buffer will - be returned through this callback and your application can take care of - cleaning it up, otherwise libmng will use its internal freeing mechanism - (which, depending on compile-options, will be the standard C free() call, - or the memfree() callback */ -/* if bOwnership = MNG_FALSE, libmng will just copy the data into its own - buffers and dispose of it in the normal way */ -#ifdef MNG_SUPPORT_READ -MNG_EXT mng_retcode MNG_DECL mng_read_pushdata (mng_handle hHandle, - mng_ptr pData, - mng_size_t iLength, - mng_bool bTakeownership); -MNG_EXT mng_retcode MNG_DECL mng_read_pushsig (mng_handle hHandle, - mng_imgtype eSigtype); -MNG_EXT mng_retcode MNG_DECL mng_read_pushchunk (mng_handle hHandle, - mng_ptr pChunk, - mng_size_t iLength, - mng_bool bTakeownership); -#endif - -/* high-level write & create functions */ -/* use this if you want to write a previously read Network Graphic or - if you want to create a new graphic and write it */ -/* to write a previously read graphic you must have defined MNG_STORE_CHUNKS */ -/* to create a new graphic you'll also need access to the chunks - (eg. #define MNG_ACCESS_CHUNKS !) */ -#ifdef MNG_SUPPORT_WRITE -MNG_EXT mng_retcode MNG_DECL mng_write (mng_handle hHandle); -MNG_EXT mng_retcode MNG_DECL mng_create (mng_handle hHandle); -#endif - -/* high-level display functions */ -/* use these to display a previously read or created graphic or - to read & display a graphic simultaneously */ -/* mng_display_resume should be called after a timer-interval - expires that was set through the settimer-callback, after a - read suspension-break, or, to resume an animation after a call - to mng_display_freeze/mng_display_reset */ -/* mng_display_freeze thru mng_display_gotime can be used to influence - the display of an image, BUT ONLY if it has been completely read! */ -#ifdef MNG_SUPPORT_DISPLAY -#ifdef MNG_SUPPORT_READ -MNG_EXT mng_retcode MNG_DECL mng_readdisplay (mng_handle hHandle); -#endif -MNG_EXT mng_retcode MNG_DECL mng_display (mng_handle hHandle); -MNG_EXT mng_retcode MNG_DECL mng_display_resume (mng_handle hHandle); -MNG_EXT mng_retcode MNG_DECL mng_display_freeze (mng_handle hHandle); -MNG_EXT mng_retcode MNG_DECL mng_display_reset (mng_handle hHandle); -#ifndef MNG_NO_DISPLAY_GO_SUPPORTED -MNG_EXT mng_retcode MNG_DECL mng_display_goframe (mng_handle hHandle, - mng_uint32 iFramenr); -MNG_EXT mng_retcode MNG_DECL mng_display_golayer (mng_handle hHandle, - mng_uint32 iLayernr); -MNG_EXT mng_retcode MNG_DECL mng_display_gotime (mng_handle hHandle, - mng_uint32 iPlaytime); -#endif -#endif /* MNG_SUPPORT_DISPLAY */ - -/* event processing function */ -/* this needs to be called by the app when dynamic MNG is enabled and - a specific event occurs in the user-interface */ -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_SUPPORT_DYNAMICMNG) -MNG_EXT mng_retcode MNG_DECL mng_trapevent (mng_handle hHandle, - mng_uint8 iEventtype, - mng_int32 iX, - mng_int32 iY); -#endif - -/* error reporting function */ -/* use this if you need more detailed info on the last error */ -/* iExtra1 & iExtra2 may contain errorcodes from zlib, jpeg, etc... */ -/* zErrortext will only be filled if you #define MNG_ERROR_TELLTALE */ -MNG_EXT mng_retcode MNG_DECL mng_getlasterror (mng_handle hHandle, - mng_int8* iSeverity, - mng_chunkid* iChunkname, - mng_uint32* iChunkseq, - mng_int32* iExtra1, - mng_int32* iExtra2, - mng_pchar* zErrortext); - -/* ************************************************************************** */ -/* * * */ -/* * Callback set functions * */ -/* * * */ -/* ************************************************************************** */ - -/* memory callbacks */ -/* called to allocate and release internal datastructures */ -#ifndef MNG_INTERNAL_MEMMNGMT -MNG_EXT mng_retcode MNG_DECL mng_setcb_memalloc (mng_handle hHandle, - mng_memalloc fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_memfree (mng_handle hHandle, - mng_memfree fProc); -#endif /* MNG_INTERNAL_MEMMNGMT */ - -/* open- & close-stream callbacks */ -/* called to open & close streams for input or output */ -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) -#ifndef MNG_NO_OPEN_CLOSE_STREAM -MNG_EXT mng_retcode MNG_DECL mng_setcb_openstream (mng_handle hHandle, - mng_openstream fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_closestream (mng_handle hHandle, - mng_closestream fProc); -#endif -#endif - -/* read callback */ -/* called to get data from the inputstream */ -#ifdef MNG_SUPPORT_READ -MNG_EXT mng_retcode MNG_DECL mng_setcb_readdata (mng_handle hHandle, - mng_readdata fProc); -#endif - -/* write callback */ -/* called to put data into the outputstream */ -#ifdef MNG_SUPPORT_WRITE -MNG_EXT mng_retcode MNG_DECL mng_setcb_writedata (mng_handle hHandle, - mng_writedata fProc); -#endif - -/* error callback */ -/* called when an error occurs */ -/* the application can determine if the error is recoverable, - and may inform the library by setting specific returncodes */ -MNG_EXT mng_retcode MNG_DECL mng_setcb_errorproc (mng_handle hHandle, - mng_errorproc fProc); - -/* trace callback */ -/* called to show the currently executing function */ -#ifdef MNG_SUPPORT_TRACE -MNG_EXT mng_retcode MNG_DECL mng_setcb_traceproc (mng_handle hHandle, - mng_traceproc fProc); -#endif - -/* callbacks for read processing */ -/* processheader is called when all header information has been gathered - from the inputstream */ -/* processtext is called for every tEXt, zTXt and iTXt chunk in the - inputstream (iType=0 for tEXt, 1 for zTXt and 2 for iTXt); - you can call get_imagelevel to check at what nesting-level the chunk is - encountered (eg. tEXt inside an embedded image inside a MNG -> level == 2; - in most other case -> level == 1) */ -/* processsave & processseek are called for SAVE/SEEK chunks */ -/* processneed is called for the nEED chunk; you should specify a callback - for this as the default behavior will be to abort processing, unless - the requirement is one of: - - a supported chunk - - the text "draft nn" where nn is a numeric value - - the text "MNG-1.0" or "MNG-1.1" - - the text "CACHEOFF" */ -/* processmend is called at the very end of the animation-stream; - note that this may not be the end of the animation though! */ -/* processterm is called when a TERM chunk is encountered; there can be only - 1 in the stream (or none) */ -/* processunknown is called after reading each non-critical unknown chunk */ -#ifdef MNG_SUPPORT_READ -MNG_EXT mng_retcode MNG_DECL mng_setcb_processheader (mng_handle hHandle, - mng_processheader fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processtext (mng_handle hHandle, - mng_processtext fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processsave (mng_handle hHandle, - mng_processsave fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processseek (mng_handle hHandle, - mng_processseek fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processneed (mng_handle hHandle, - mng_processneed fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processmend (mng_handle hHandle, - mng_processmend fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processterm (mng_handle hHandle, - mng_processterm fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processunknown(mng_handle hHandle, - mng_processunknown fProc); -#endif - -/* callbacks for display processing */ -/* getcanvasline is called to get an access-pointer to a line on the - drawing-canvas */ -/* getbkgdline is called to get an access-pointer to a line from the - background-canvas */ -/* refresh is called to inform the GUI to redraw the current canvas onto - its output device (eg. in Win32 this would mean sending an - invalidate message for the specified region */ -/* NOTE that the update-region is specified as x,y,width,height; eg. the - invalidate message for Windows requires left,top,right,bottom parameters - where the bottom-right is exclusive of the region!! - to get these correctly is as simple as: - left = x; - top = y; - right = x + width; - bottom = y + height; - if your implementation requires inclusive points, simply subtract 1 from - both the right & bottom values calculated above. - */ -#ifdef MNG_SUPPORT_DISPLAY -MNG_EXT mng_retcode MNG_DECL mng_setcb_getcanvasline (mng_handle hHandle, - mng_getcanvasline fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_getbkgdline (mng_handle hHandle, - mng_getbkgdline fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_getalphaline (mng_handle hHandle, - mng_getalphaline fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_refresh (mng_handle hHandle, - mng_refresh fProc); - -/* timing callbacks */ -/* gettickcount is called to get the system tickcount (milliseconds); - this is used to determine the remaining interval between frames */ -/* settimer is called to inform the application that it should set a timer; - when the timer is triggered the app must call mng_display_resume */ -MNG_EXT mng_retcode MNG_DECL mng_setcb_gettickcount (mng_handle hHandle, - mng_gettickcount fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_settimer (mng_handle hHandle, - mng_settimer fProc); - -/* color management callbacks */ -/* called to transmit color management information to the application */ -/* these are only used when you #define MNG_APP_CMS */ -#ifdef MNG_APP_CMS -MNG_EXT mng_retcode MNG_DECL mng_setcb_processgamma (mng_handle hHandle, - mng_processgamma fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processchroma (mng_handle hHandle, - mng_processchroma fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processsrgb (mng_handle hHandle, - mng_processsrgb fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processiccp (mng_handle hHandle, - mng_processiccp fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processarow (mng_handle hHandle, - mng_processarow fProc); -#endif /* MNG_APP_CMS */ -#endif /* MNG_SUPPORT_DISPLAY */ - -/* release push data callback */ -/* used when the app pushes data into libmng (as opposed to libmng pulling it) - and relinquishes ownership of the pushed data-buffer, but *does* want to - release (free) the buffer itself once libmng has finished processing it */ -#ifdef MNG_SUPPORT_READ -MNG_EXT mng_retcode MNG_DECL mng_setcb_releasedata (mng_handle hHandle, - mng_releasedata fProc); -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Callback get functions * */ -/* * * */ -/* ************************************************************************** */ - -/* see _setcb_ */ -#ifndef MNG_INTERNAL_MEMMNGMT -MNG_EXT mng_memalloc MNG_DECL mng_getcb_memalloc (mng_handle hHandle); -MNG_EXT mng_memfree MNG_DECL mng_getcb_memfree (mng_handle hHandle); -#endif - -/* see _setcb_ */ -#ifdef MNG_SUPPORT_READ -MNG_EXT mng_releasedata MNG_DECL mng_getcb_releasedata (mng_handle hHandle); -#endif - -/* see _setcb_ */ -#if defined(MNG_SUPPORT_READ) || defined(MNG_WRITE_SUPPORT) -#ifndef MNG_NO_OPEN_CLOSE_STREAM -MNG_EXT mng_openstream MNG_DECL mng_getcb_openstream (mng_handle hHandle); -MNG_EXT mng_closestream MNG_DECL mng_getcb_closestream (mng_handle hHandle); -#endif -#endif - -/* see _setcb_ */ -#ifdef MNG_SUPPORT_READ -MNG_EXT mng_readdata MNG_DECL mng_getcb_readdata (mng_handle hHandle); -#endif - -/* see _setcb_ */ -#ifdef MNG_SUPPORT_WRITE -MNG_EXT mng_writedata MNG_DECL mng_getcb_writedata (mng_handle hHandle); -#endif - -/* see _setcb_ */ -MNG_EXT mng_errorproc MNG_DECL mng_getcb_errorproc (mng_handle hHandle); - -/* see _setcb_ */ -#ifdef MNG_SUPPORT_TRACE -MNG_EXT mng_traceproc MNG_DECL mng_getcb_traceproc (mng_handle hHandle); -#endif - -/* see _setcb_ */ -#ifdef MNG_SUPPORT_READ -MNG_EXT mng_processheader MNG_DECL mng_getcb_processheader (mng_handle hHandle); -MNG_EXT mng_processtext MNG_DECL mng_getcb_processtext (mng_handle hHandle); -MNG_EXT mng_processsave MNG_DECL mng_getcb_processsave (mng_handle hHandle); -MNG_EXT mng_processseek MNG_DECL mng_getcb_processseek (mng_handle hHandle); -MNG_EXT mng_processneed MNG_DECL mng_getcb_processneed (mng_handle hHandle); -MNG_EXT mng_processunknown MNG_DECL mng_getcb_processunknown (mng_handle hHandle); -MNG_EXT mng_processterm MNG_DECL mng_getcb_processterm (mng_handle hHandle); -#endif - -/* see _setcb_ */ -#ifdef MNG_SUPPORT_DISPLAY -MNG_EXT mng_getcanvasline MNG_DECL mng_getcb_getcanvasline (mng_handle hHandle); -MNG_EXT mng_getbkgdline MNG_DECL mng_getcb_getbkgdline (mng_handle hHandle); -MNG_EXT mng_getalphaline MNG_DECL mng_getcb_getalphaline (mng_handle hHandle); -MNG_EXT mng_refresh MNG_DECL mng_getcb_refresh (mng_handle hHandle); - -/* see _setcb_ */ -MNG_EXT mng_gettickcount MNG_DECL mng_getcb_gettickcount (mng_handle hHandle); -MNG_EXT mng_settimer MNG_DECL mng_getcb_settimer (mng_handle hHandle); - -/* see _setcb_ */ -#ifdef MNG_APP_CMS -MNG_EXT mng_processgamma MNG_DECL mng_getcb_processgamma (mng_handle hHandle); -MNG_EXT mng_processchroma MNG_DECL mng_getcb_processchroma (mng_handle hHandle); -MNG_EXT mng_processsrgb MNG_DECL mng_getcb_processsrgb (mng_handle hHandle); -MNG_EXT mng_processiccp MNG_DECL mng_getcb_processiccp (mng_handle hHandle); -MNG_EXT mng_processarow MNG_DECL mng_getcb_processarow (mng_handle hHandle); -#endif /* MNG_APP_CMS */ -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ -/* * * */ -/* * Property set functions * */ -/* * * */ -/* ************************************************************************** */ - -/* Application data pointer */ -/* provided for application use; not used by the library */ -MNG_EXT mng_retcode MNG_DECL mng_set_userdata (mng_handle hHandle, - mng_ptr pUserdata); - -/* The style of the drawing- & background-canvas */ -/* only used for displaying images */ -/* both are initially set to 24-bit RGB (eg. 8-bit per channel) */ -MNG_EXT mng_retcode MNG_DECL mng_set_canvasstyle (mng_handle hHandle, - mng_uint32 iStyle); -MNG_EXT mng_retcode MNG_DECL mng_set_bkgdstyle (mng_handle hHandle, - mng_uint32 iStyle); - -/* The default background color */ -/* only used if the getbkgdline callback is not defined */ -/* for initially painting the canvas and restoring (part of) the background */ -MNG_EXT mng_retcode MNG_DECL mng_set_bgcolor (mng_handle hHandle, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue); - -/* Indicates preferred use of the bKGD chunk for PNG images */ -MNG_EXT mng_retcode MNG_DECL mng_set_usebkgd (mng_handle hHandle, - mng_bool bUseBKGD); - -/* Indicates storage of read chunks */ -/* only useful if you #define mng_store_chunks */ -/* can be used to dynamically change storage management */ -MNG_EXT mng_retcode MNG_DECL mng_set_storechunks (mng_handle hHandle, - mng_bool bStorechunks); - -/* Indicates breaks requested when processing SAVE/SEEK */ -/* set this to let the app handle section breaks; the library will return - MNG_NEEDSECTIONWAIT return-codes for each SEEK chunk */ -MNG_EXT mng_retcode MNG_DECL mng_set_sectionbreaks (mng_handle hHandle, - mng_bool bSectionbreaks); - -/* Indicates storage of playback info (ON by default!) */ -/* can be used to turn off caching of playback info; this is useful to - specifically optimize MNG-video playback; note that if caching is turned off - LOOP chunks will be flagged as errors! TERM chunks will be ignored and only - passed to the processterm() callback if it is defined by the app; also, this - feature can only be used with mng_readdisplay(); mng_read(), - mng_display_reset() and mng_display_goxxxx() will return an error; - once this option is turned off it can't be turned on for the same stream!!! */ -MNG_EXT mng_retcode MNG_DECL mng_set_cacheplayback (mng_handle hHandle, - mng_bool bCacheplayback); - -/* Indicates automatic progressive refreshes for large images (ON by default!) */ -/* turn this off if you do not want intermittent painting while a large image - is being read. useful if the input-stream comes from a fast medium, such - as a local harddisk */ -MNG_EXT mng_retcode MNG_DECL mng_set_doprogressive (mng_handle hHandle, - mng_bool bDoProgressive); - -/* Indicates existence and required checking of the CRC in input streams, - and generation in output streams */ -/* !!!! Use this ONLY if you know what you are doing !!!! */ -/* The value is a combination of the following flags: - 0x0000001 = CRC is present in the input stream - 0x0000002 = CRC must be generated in the output stream - 0x0000010 = CRC should be checked for ancillary chunks - 0x0000020 = a faulty CRC for ancillary chunks generates a warning only - 0x0000040 = a faulty CRC for ancillary chunks generates an error - 0x0000100 = CRC should be checked for critical chunks - 0x0000200 = a faulty CRC for critical chunks generates a warning only - 0x0000400 = a faulty CRC for critical chunks generates an error - - The default is 0x00000533 = CRC present in input streams; should be checked; - warning for ancillary chunks; error for critical - chunks; generate CRC for output streams - - Note that some combinations are meaningless; eg. if the CRC is not present - it won't do any good to turn the checking flags on; if a checking flag - is off, it doesn't do any good to ask for generation of warnings or errors. - Also libmng will generate either an error or a warning, not both, - so if you specify both the default will be to generate an error! - The only useful combinations for input are 331, 551, 351, 531, 0, 301, 501 - and optionally 031 and 051, but only checking ancillary chunks and not - critical chunks is generally not a very good idea!!! - If you've also writing these values should be combined with 0x02 if - CRC's are required in the output stream - */ -MNG_EXT mng_retcode MNG_DECL mng_set_crcmode (mng_handle hHandle, - mng_uint32 iCrcmode); - -/* Color-management necessaries */ -/* - ************************************************************************* - !!!!!!!! THIS NEXT BIT IS IMPORTANT !!!!!!!!! - ************************************************************************* - - If you have defined MNG_FULL_CMS (and are using lcms), you will have to - think hard about the following routines. - - lcms requires 2 profiles to work off the differences in the input-image - and the output-device. The ICC profile for the input-image will be - embedded within it to reflect its color-characteristics, but the output - profile depends on the output-device, which is something only *YOU* know - about. sRGB (standard RGB) is common for x86 compatible environments - (eg. Windows, Linux and some others) - - If you are compiling for a sRGB compliant system you probably won't have - to do anything special. (unless you want to of course) - - If you are compiling for a non-sRGB compliant system - (eg. SGI, Mac, Next, others...) - you *MUST* define a proper ICC profile for the generic output-device - associated with that platform. - - In either event, you may also want to offer an option to your users to - set the profile manually, or, if you know how, set it from a - system-defined default. - - TO RECAP: for sRGB systems (Windows, Linux) no action required! - for non-sRGB systems (SGI, Mac, Next) ACTION REQUIRED! - - Please visit http://www.srgb.com, http://www.color.org and - http://www.littlecms.com for more info. - - ************************************************************************* - !!!!!!!! THE BIT ABOVE IS IMPORTANT !!!!!!!!! - ************************************************************************* -*/ -/* mng_set_srgb tells libmng if it's running on a sRGB compliant system or not - the default is already set to MNG_TRUE */ -/* mng_set_outputprofile, mng_set_outputprofile2, mng_set_outputsrgb - are used to set the default profile describing the output-device - by default it is already initialized with an sRGB profile */ -/* mng_set_srgbprofile, mng_set_srgbprofile2, mng_set_srgbimplicit - are used to set the default profile describing a standard sRGB device - this is used when the input-image is tagged only as being sRGB, but the - output-device is defined as not being sRGB compliant - by default it is already initialized with a standard sRGB profile */ -#if defined(MNG_SUPPORT_DISPLAY) -MNG_EXT mng_retcode MNG_DECL mng_set_srgb (mng_handle hHandle, - mng_bool bIssRGB); -MNG_EXT mng_retcode MNG_DECL mng_set_outputprofile (mng_handle hHandle, - mng_pchar zFilename); -MNG_EXT mng_retcode MNG_DECL mng_set_outputprofile2 (mng_handle hHandle, - mng_uint32 iProfilesize, - mng_ptr pProfile); -MNG_EXT mng_retcode MNG_DECL mng_set_outputsrgb (mng_handle hHandle); -MNG_EXT mng_retcode MNG_DECL mng_set_srgbprofile (mng_handle hHandle, - mng_pchar zFilename); -MNG_EXT mng_retcode MNG_DECL mng_set_srgbprofile2 (mng_handle hHandle, - mng_uint32 iProfilesize, - mng_ptr pProfile); -MNG_EXT mng_retcode MNG_DECL mng_set_srgbimplicit (mng_handle hHandle); -#endif - -#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) || defined(MNG_APP_CMS) -/* Gamma settings */ -/* ... blabla (explain gamma processing a little; eg. formula & stuff) ... */ -MNG_EXT mng_retcode MNG_DECL mng_set_viewgamma (mng_handle hHandle, - mng_float dGamma); -MNG_EXT mng_retcode MNG_DECL mng_set_displaygamma (mng_handle hHandle, - mng_float dGamma); -MNG_EXT mng_retcode MNG_DECL mng_set_dfltimggamma (mng_handle hHandle, - mng_float dGamma); -MNG_EXT mng_retcode MNG_DECL mng_set_viewgammaint (mng_handle hHandle, - mng_uint32 iGamma); -MNG_EXT mng_retcode MNG_DECL mng_set_displaygammaint (mng_handle hHandle, - mng_uint32 iGamma); -MNG_EXT mng_retcode MNG_DECL mng_set_dfltimggammaint (mng_handle hHandle, - mng_uint32 iGamma); -#endif - -#ifndef MNG_SKIP_MAXCANVAS -/* Ultimate clipping size */ -/* used to limit extreme graphics from overloading the system */ -/* if a graphic exceeds these limits a warning is issued, which can - be ignored by the app (using the errorproc callback). in that case - the library will use these settings to clip the input graphic, and - the app's canvas must account for this */ -MNG_EXT mng_retcode MNG_DECL mng_set_maxcanvaswidth (mng_handle hHandle, - mng_uint32 iMaxwidth); -MNG_EXT mng_retcode MNG_DECL mng_set_maxcanvasheight (mng_handle hHandle, - mng_uint32 iMaxheight); -MNG_EXT mng_retcode MNG_DECL mng_set_maxcanvassize (mng_handle hHandle, - mng_uint32 iMaxwidth, - mng_uint32 iMaxheight); -#endif - -/* ZLIB default compression parameters */ -/* these are used when writing out chunks */ -/* they are also used when compressing PNG image-data or JNG alpha-data; - in this case you can set them just before calling mng_putimgdata_ihdr */ -/* set to your liking; usually the defaults will suffice though! */ -/* check the documentation for ZLIB for details on these parameters */ -#ifdef MNG_INCLUDE_ZLIB -MNG_EXT mng_retcode MNG_DECL mng_set_zlib_level (mng_handle hHandle, - mng_int32 iZlevel); -MNG_EXT mng_retcode MNG_DECL mng_set_zlib_method (mng_handle hHandle, - mng_int32 iZmethod); -MNG_EXT mng_retcode MNG_DECL mng_set_zlib_windowbits (mng_handle hHandle, - mng_int32 iZwindowbits); -MNG_EXT mng_retcode MNG_DECL mng_set_zlib_memlevel (mng_handle hHandle, - mng_int32 iZmemlevel); -MNG_EXT mng_retcode MNG_DECL mng_set_zlib_strategy (mng_handle hHandle, - mng_int32 iZstrategy); - -MNG_EXT mng_retcode MNG_DECL mng_set_zlib_maxidat (mng_handle hHandle, - mng_uint32 iMaxIDAT); -#endif /* MNG_INCLUDE_ZLIB */ - -/* JNG default compression parameters (based on IJG code) */ -/* these are used when compressing JNG image-data; so you can set them - just before calling mng_putimgdata_jhdr */ -/* set to your liking; usually the defaults will suffice though! */ -/* check the documentation for IJGSRC6B for details on these parameters */ -#ifdef MNG_INCLUDE_JNG -#ifdef MNG_INCLUDE_IJG6B -MNG_EXT mng_retcode MNG_DECL mng_set_jpeg_dctmethod (mng_handle hHandle, - mngjpeg_dctmethod eJPEGdctmethod); -#endif -MNG_EXT mng_retcode MNG_DECL mng_set_jpeg_quality (mng_handle hHandle, - mng_int32 iJPEGquality); -MNG_EXT mng_retcode MNG_DECL mng_set_jpeg_smoothing (mng_handle hHandle, - mng_int32 iJPEGsmoothing); -MNG_EXT mng_retcode MNG_DECL mng_set_jpeg_progressive(mng_handle hHandle, - mng_bool bJPEGprogressive); -MNG_EXT mng_retcode MNG_DECL mng_set_jpeg_optimized (mng_handle hHandle, - mng_bool bJPEGoptimized); - -MNG_EXT mng_retcode MNG_DECL mng_set_jpeg_maxjdat (mng_handle hHandle, - mng_uint32 iMaxJDAT); -#endif /* MNG_INCLUDE_JNG */ - -/* Suspension-mode setting */ -/* use this to activate the internal suspension-buffer to improve - read-suspension processing */ -/* TODO: write-suspension ??? */ -#if defined(MNG_SUPPORT_READ) -MNG_EXT mng_retcode MNG_DECL mng_set_suspensionmode (mng_handle hHandle, - mng_bool bSuspensionmode); -#endif - -/* Speed setting */ -/* use this to influence the display-speed of animations */ -#if defined(MNG_SUPPORT_DISPLAY) -MNG_EXT mng_retcode MNG_DECL mng_set_speed (mng_handle hHandle, - mng_speedtype iSpeed); -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Property get functions * */ -/* * * */ -/* ************************************************************************** */ - -/* see _set_ */ -MNG_EXT mng_ptr MNG_DECL mng_get_userdata (mng_handle hHandle); - -/* Network Graphic header details */ -/* these get filled once the graphics header is processed, - so they are available in the processheader callback; before that - they are zeroed out and imagetype is set to it_unknown */ -/* this might be a good point for the app to initialize the drawing-canvas! */ -/* note that some fields are only set for the first(!) header-chunk: - MNG/MHDR (imagetype = mng_it_mng) - ticks thru simplicity - PNG/IHDR (imagetype = mng_it_png) - bitdepth thru interlace - JNG/JHDR (imagetype = mng_it_jng) - bitdepth thru compression & - interlace thru alphainterlace */ -MNG_EXT mng_imgtype MNG_DECL mng_get_sigtype (mng_handle hHandle); -MNG_EXT mng_imgtype MNG_DECL mng_get_imagetype (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_imagewidth (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_imageheight (mng_handle hHandle); - -MNG_EXT mng_uint32 MNG_DECL mng_get_ticks (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_framecount (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_layercount (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_playtime (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_simplicity (mng_handle hHandle); - -MNG_EXT mng_uint8 MNG_DECL mng_get_bitdepth (mng_handle hHandle); -MNG_EXT mng_uint8 MNG_DECL mng_get_colortype (mng_handle hHandle); -MNG_EXT mng_uint8 MNG_DECL mng_get_compression (mng_handle hHandle); -MNG_EXT mng_uint8 MNG_DECL mng_get_filter (mng_handle hHandle); -MNG_EXT mng_uint8 MNG_DECL mng_get_interlace (mng_handle hHandle); -MNG_EXT mng_uint8 MNG_DECL mng_get_alphabitdepth (mng_handle hHandle); -MNG_EXT mng_uint8 MNG_DECL mng_get_alphacompression(mng_handle hHandle); -MNG_EXT mng_uint8 MNG_DECL mng_get_alphafilter (mng_handle hHandle); -MNG_EXT mng_uint8 MNG_DECL mng_get_alphainterlace (mng_handle hHandle); - -/* indicates the predicted alpha-depth required to properly display the image */ -/* gets set once the graphics header is processed and is available in the - processheader callback for any type of input-image (PNG, JNG or MNG) */ -/* possible values are 0,1,2,4,8,16 - 0 = no transparency required - 1 = on/off transparency required (alpha-values are 0 or 2^bit_depth-1) - 2+ = semi-transparency required (values will be scaled to the bitdepth of the - canvasstyle supplied by the application) */ -MNG_EXT mng_uint8 MNG_DECL mng_get_alphadepth (mng_handle hHandle); - -/* defines whether a refresh() callback is called for an interlace pass (PNG) - or progressive scan (JNG) */ -/* returns the interlace pass number for PNG or a fabricated pass number for JNG; - returns 0 in all other cases */ -/* only useful if the image_type = mng_it_png or mng_it_jng and if the image - is actually interlaced (PNG) or progressive (JNG) */ -#ifdef MNG_SUPPORT_DISPLAY -MNG_EXT mng_uint8 MNG_DECL mng_get_refreshpass (mng_handle hHandle); -#endif - -/* see _set_ */ -MNG_EXT mng_uint32 MNG_DECL mng_get_canvasstyle (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_bkgdstyle (mng_handle hHandle); - -/* see _set_ */ -MNG_EXT mng_retcode MNG_DECL mng_get_bgcolor (mng_handle hHandle, - mng_uint16* iRed, - mng_uint16* iGreen, - mng_uint16* iBlue); - -/* see _set_ */ -MNG_EXT mng_bool MNG_DECL mng_get_usebkgd (mng_handle hHandle); - -/* see _set_ */ -MNG_EXT mng_bool MNG_DECL mng_get_storechunks (mng_handle hHandle); - -/* see _set_ */ -MNG_EXT mng_bool MNG_DECL mng_get_sectionbreaks (mng_handle hHandle); - -/* see _set_ */ -MNG_EXT mng_bool MNG_DECL mng_get_cacheplayback (mng_handle hHandle); - -/* see _set_ */ -MNG_EXT mng_bool MNG_DECL mng_get_doprogressive (mng_handle hHandle); - -/* see _set_ */ -MNG_EXT mng_uint32 MNG_DECL mng_get_crcmode (mng_handle hHandle); - -/* see _set_ */ -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_FULL_CMS) -MNG_EXT mng_bool MNG_DECL mng_get_srgb (mng_handle hHandle); -#endif - -/* see _set_ */ -MNG_EXT mng_float MNG_DECL mng_get_viewgamma (mng_handle hHandle); -MNG_EXT mng_float MNG_DECL mng_get_displaygamma (mng_handle hHandle); -MNG_EXT mng_float MNG_DECL mng_get_dfltimggamma (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_viewgammaint (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_displaygammaint (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_dfltimggammaint (mng_handle hHandle); - -#ifndef MNG_SKIP_MAXCANVAS -/* see _set_ */ -MNG_EXT mng_uint32 MNG_DECL mng_get_maxcanvaswidth (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_maxcanvasheight (mng_handle hHandle); -#endif - -/* see _set_ */ -#ifdef MNG_INCLUDE_ZLIB -MNG_EXT mng_int32 MNG_DECL mng_get_zlib_level (mng_handle hHandle); -MNG_EXT mng_int32 MNG_DECL mng_get_zlib_method (mng_handle hHandle); -MNG_EXT mng_int32 MNG_DECL mng_get_zlib_windowbits (mng_handle hHandle); -MNG_EXT mng_int32 MNG_DECL mng_get_zlib_memlevel (mng_handle hHandle); -MNG_EXT mng_int32 MNG_DECL mng_get_zlib_strategy (mng_handle hHandle); - -MNG_EXT mng_uint32 MNG_DECL mng_get_zlib_maxidat (mng_handle hHandle); -#endif /* MNG_INCLUDE_ZLIB */ - -/* see _set_ */ -#ifdef MNG_INCLUDE_JNG -#ifdef MNG_INCLUDE_IJG6B -MNG_EXT mngjpeg_dctmethod - MNG_DECL mng_get_jpeg_dctmethod (mng_handle hHandle); -#endif -MNG_EXT mng_int32 MNG_DECL mng_get_jpeg_quality (mng_handle hHandle); -MNG_EXT mng_int32 MNG_DECL mng_get_jpeg_smoothing (mng_handle hHandle); -MNG_EXT mng_bool MNG_DECL mng_get_jpeg_progressive(mng_handle hHandle); -MNG_EXT mng_bool MNG_DECL mng_get_jpeg_optimized (mng_handle hHandle); - -MNG_EXT mng_uint32 MNG_DECL mng_get_jpeg_maxjdat (mng_handle hHandle); -#endif /* MNG_INCLUDE_JNG */ - -/* see _set_ */ -#if defined(MNG_SUPPORT_READ) -MNG_EXT mng_bool MNG_DECL mng_get_suspensionmode (mng_handle hHandle); -#endif - -/* see _set_ */ -#if defined(MNG_SUPPORT_DISPLAY) -MNG_EXT mng_speedtype - MNG_DECL mng_get_speed (mng_handle hHandle); -#endif - -/* Image-level */ -/* this can be used inside the processtext callback to determine the level of - text of the image being processed; the value 1 is returned for top-level - texts, and the value 2 for a text inside an embedded image inside a MNG */ -MNG_EXT mng_uint32 MNG_DECL mng_get_imagelevel (mng_handle hHandle); - -/* BACK info */ -/* can be used to retrieve the color & mandatory values for the last processed - BACK chunk of a MNG (will fail for other image-types); - if no BACK chunk was processed yet, it will return all zeroes */ -#ifdef MNG_SUPPORT_DISPLAY -MNG_EXT mng_retcode MNG_DECL mng_get_lastbackchunk (mng_handle hHandle, - mng_uint16* iRed, - mng_uint16* iGreen, - mng_uint16* iBlue, - mng_uint8* iMandatory); -#endif - -/* SEEK info */ -/* can be used to retrieve the segmentname of the last processed SEEK chunk; - if no SEEK chunk was processed or its segmentname was empty, the function - will return an empty string; the provided buffer must be at least 80 bytes!! */ -#ifdef MNG_SUPPORT_DISPLAY -MNG_EXT mng_retcode MNG_DECL mng_get_lastseekname (mng_handle hHandle, - mng_pchar zSegmentname); -#endif - -/* FRAM info */ -/* can be used to retrieve the current FRAM delay; this may be useful when - retrieving a stream of frames with their corresponding delays by "fake" - reading and displaying the file */ -#ifdef MNG_SUPPORT_DISPLAY -MNG_EXT mng_uint32 MNG_DECL mng_get_currframdelay (mng_handle hHandle); -#endif - -/* Display status variables */ -/* these get filled & updated during display processing */ -/* starttime is the tickcount at the start of displaying the animation */ -/* runtime is the actual number of millisecs since the start of the animation */ -/* currentframe, currentlayer & currentplaytime indicate the current - frame/layer/playtime(msecs) in the animation (these keep increasing; - even after the animation loops back to the TERM chunk) */ -/* totalframes, totallayers & totalplaytime are filled after a complete run - of an animation (eg. at MEND); they are also valid after just reading the MNG */ -#ifdef MNG_SUPPORT_DISPLAY -MNG_EXT mng_uint32 MNG_DECL mng_get_starttime (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_runtime (mng_handle hHandle); -#ifndef MNG_NO_CURRENT_INFO -MNG_EXT mng_uint32 MNG_DECL mng_get_currentframe (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_currentlayer (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_currentplaytime (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_totalframes (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_totallayers (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_totalplaytime (mng_handle hHandle); -#endif -#endif - -/* Status variables */ -/* these indicate the internal state of the library */ -/* most indicate exactly what you would expect - - status_error: true if the last function call returned an errorcode - status_reading: true if the library is (still) reading an image - status_suspendbreak: true if the library has suspended for "I/O" - status_creating: true if the library is in the middle of creating an image - status_writing: true if the library is in the middle of writing an image - status_displaying: true if the library is displaying an image - status_running: true if display processing is active (eg. not frozen or reset) - status_timerbreak: true if the library has suspended for a "timer-break" - status_dynamic: true if the library encountered an evNT chunk in the MNG - status_runningevent: true if the library is processing an external event */ -/* eg. mng_readdisplay() will turn the reading, displaying and running status on; - when EOF is reached the reading status will be turned off */ -MNG_EXT mng_bool MNG_DECL mng_status_error (mng_handle hHandle); -#ifdef MNG_SUPPORT_READ -MNG_EXT mng_bool MNG_DECL mng_status_reading (mng_handle hHandle); -MNG_EXT mng_bool MNG_DECL mng_status_suspendbreak (mng_handle hHandle); -#endif -#ifdef MNG_SUPPORT_WRITE -MNG_EXT mng_bool MNG_DECL mng_status_creating (mng_handle hHandle); -MNG_EXT mng_bool MNG_DECL mng_status_writing (mng_handle hHandle); -#endif -#ifdef MNG_SUPPORT_DISPLAY -MNG_EXT mng_bool MNG_DECL mng_status_displaying (mng_handle hHandle); -MNG_EXT mng_bool MNG_DECL mng_status_running (mng_handle hHandle); -MNG_EXT mng_bool MNG_DECL mng_status_timerbreak (mng_handle hHandle); -#endif -#ifdef MNG_SUPPORT_DYNAMICMNG -MNG_EXT mng_bool MNG_DECL mng_status_dynamic (mng_handle hHandle); -MNG_EXT mng_bool MNG_DECL mng_status_runningevent (mng_handle hHandle); -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Chunk access functions * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_ACCESS_CHUNKS - -/* ************************************************************************** */ - -/* use this to iterate the stored chunks */ -/* requires MNG_ACCESS_CHUNKS & MNG_STORE_CHUNKS */ -/* starts from the supplied chunk-index-nr; the first chunk has index 0!! */ -MNG_EXT mng_retcode MNG_DECL mng_iterate_chunks (mng_handle hHandle, - mng_uint32 iChunkseq, - mng_iteratechunk fProc); - -/* use the next function inside your 'iteratechunk' callback to copy - the given chunk to a new mng you are creating */ -/* the 'out' handle should be in 'create' status! */ -#ifdef MNG_SUPPORT_WRITE -MNG_EXT mng_retcode MNG_DECL mng_copy_chunk (mng_handle hHandle, - mng_handle hChunk, - mng_handle hHandleOut); -#endif - -/* ************************************************************************** */ - -/* use these to get chunk data from within the callback in iterate_chunks */ -MNG_EXT mng_retcode MNG_DECL mng_getchunk_ihdr (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_uint8 *iBitdepth, - mng_uint8 *iColortype, - mng_uint8 *iCompression, - mng_uint8 *iFilter, - mng_uint8 *iInterlace); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_plte (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount, - mng_palette8 *aPalette); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_idat (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iRawlen, - mng_ptr *pRawdata); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_trns (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_bool *bGlobal, - mng_uint8 *iType, - mng_uint32 *iCount, - mng_uint8arr *aAlphas, - mng_uint16 *iGray, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue, - mng_uint32 *iRawlen, - mng_uint8arr *aRawdata); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_gama (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iGamma); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_chrm (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iWhitepointx, - mng_uint32 *iWhitepointy, - mng_uint32 *iRedx, - mng_uint32 *iRedy, - mng_uint32 *iGreenx, - mng_uint32 *iGreeny, - mng_uint32 *iBluex, - mng_uint32 *iBluey); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_srgb (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iRenderingintent); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_iccp (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iNamesize, - mng_pchar *zName, - mng_uint8 *iCompression, - mng_uint32 *iProfilesize, - mng_ptr *pProfile); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_text (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iKeywordsize, - mng_pchar *zKeyword, - mng_uint32 *iTextsize, - mng_pchar *zText); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_ztxt (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iKeywordsize, - mng_pchar *zKeyword, - mng_uint8 *iCompression, - mng_uint32 *iTextsize, - mng_pchar *zText); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_itxt (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iKeywordsize, - mng_pchar *zKeyword, - mng_uint8 *iCompressionflag, - mng_uint8 *iCompressionmethod, - mng_uint32 *iLanguagesize, - mng_pchar *zLanguage, - mng_uint32 *iTranslationsize, - mng_pchar *zTranslation, - mng_uint32 *iTextsize, - mng_pchar *zText); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_bkgd (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iType, - mng_uint8 *iIndex, - mng_uint16 *iGray, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_phys (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iSizex, - mng_uint32 *iSizey, - mng_uint8 *iUnit); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_sbit (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iType, - mng_uint8arr4 *aBits); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_splt (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iNamesize, - mng_pchar *zName, - mng_uint8 *iSampledepth, - mng_uint32 *iEntrycount, - mng_ptr *pEntries); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_hist (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iEntrycount, - mng_uint16arr *aEntries); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_time (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iYear, - mng_uint8 *iMonth, - mng_uint8 *iDay, - mng_uint8 *iHour, - mng_uint8 *iMinute, - mng_uint8 *iSecond); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_mhdr (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_uint32 *iTicks, - mng_uint32 *iLayercount, - mng_uint32 *iFramecount, - mng_uint32 *iPlaytime, - mng_uint32 *iSimplicity); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_loop (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iLevel, - mng_uint32 *iRepeat, - mng_uint8 *iTermination, - mng_uint32 *iItermin, - mng_uint32 *iItermax, - mng_uint32 *iCount, - mng_uint32p *pSignals); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_endl (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iLevel); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_defi (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iObjectid, - mng_uint8 *iDonotshow, - mng_uint8 *iConcrete, - mng_bool *bHasloca, - mng_int32 *iXlocation, - mng_int32 *iYlocation, - mng_bool *bHasclip, - mng_int32 *iLeftcb, - mng_int32 *iRightcb, - mng_int32 *iTopcb, - mng_int32 *iBottomcb); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_basi (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_uint8 *iBitdepth, - mng_uint8 *iColortype, - mng_uint8 *iCompression, - mng_uint8 *iFilter, - mng_uint8 *iInterlace, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue, - mng_uint16 *iAlpha, - mng_uint8 *iViewable); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_clon (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iSourceid, - mng_uint16 *iCloneid, - mng_uint8 *iClonetype, - mng_uint8 *iDonotshow, - mng_uint8 *iConcrete, - mng_bool *bHasloca, - mng_uint8 *iLocationtype, - mng_int32 *iLocationx, - mng_int32 *iLocationy); - -#ifndef MNG_SKIPCHUNK_PAST -MNG_EXT mng_retcode MNG_DECL mng_getchunk_past (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iDestid, - mng_uint8 *iTargettype, - mng_int32 *iTargetx, - mng_int32 *iTargety, - mng_uint32 *iCount); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_past_src (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_uint16 *iSourceid, - mng_uint8 *iComposition, - mng_uint8 *iOrientation, - mng_uint8 *iOffsettype, - mng_int32 *iOffsetx, - mng_int32 *iOffsety, - mng_uint8 *iBoundarytype, - mng_int32 *iBoundaryl, - mng_int32 *iBoundaryr, - mng_int32 *iBoundaryt, - mng_int32 *iBoundaryb); -#endif - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_disc (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount, - mng_uint16p *pObjectids); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_back (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue, - mng_uint8 *iMandatory, - mng_uint16 *iImageid, - mng_uint8 *iTile); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_fram (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iMode, - mng_uint32 *iNamesize, - mng_pchar *zName, - mng_uint8 *iChangedelay, - mng_uint8 *iChangetimeout, - mng_uint8 *iChangeclipping, - mng_uint8 *iChangesyncid, - mng_uint32 *iDelay, - mng_uint32 *iTimeout, - mng_uint8 *iBoundarytype, - mng_int32 *iBoundaryl, - mng_int32 *iBoundaryr, - mng_int32 *iBoundaryt, - mng_int32 *iBoundaryb, - mng_uint32 *iCount, - mng_uint32p *pSyncids); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_move (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iFirstid, - mng_uint16 *iLastid, - mng_uint8 *iMovetype, - mng_int32 *iMovex, - mng_int32 *iMovey); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_clip (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iFirstid, - mng_uint16 *iLastid, - mng_uint8 *iCliptype, - mng_int32 *iClipl, - mng_int32 *iClipr, - mng_int32 *iClipt, - mng_int32 *iClipb); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_show (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint16 *iFirstid, - mng_uint16 *iLastid, - mng_uint8 *iMode); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_term (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iTermaction, - mng_uint8 *iIteraction, - mng_uint32 *iDelay, - mng_uint32 *iItermax); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_save (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iOffsettype, - mng_uint32 *iCount); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_save_entry (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_uint8 *iEntrytype, - mng_uint32arr2 *iOffset, - mng_uint32arr2 *iStarttime, - mng_uint32 *iLayernr, - mng_uint32 *iFramenr, - mng_uint32 *iNamesize, - mng_pchar *zName); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_seek (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iNamesize, - mng_pchar *zName); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_expi (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iSnapshotid, - mng_uint32 *iNamesize, - mng_pchar *zName); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_fpri (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iDeltatype, - mng_uint8 *iPriority); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_need (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iKeywordssize, - mng_pchar *zKeywords); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_phyg (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iSizex, - mng_uint32 *iSizey, - mng_uint8 *iUnit); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_jhdr (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_uint8 *iColortype, - mng_uint8 *iImagesampledepth, - mng_uint8 *iImagecompression, - mng_uint8 *iImageinterlace, - mng_uint8 *iAlphasampledepth, - mng_uint8 *iAlphacompression, - mng_uint8 *iAlphafilter, - mng_uint8 *iAlphainterlace); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_jdat (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iRawlen, - mng_ptr *pRawdata); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_jdaa (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iRawlen, - mng_ptr *pRawdata); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_dhdr (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iObjectid, - mng_uint8 *iImagetype, - mng_uint8 *iDeltatype, - mng_uint32 *iBlockwidth, - mng_uint32 *iBlockheight, - mng_uint32 *iBlockx, - mng_uint32 *iBlocky); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_prom (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iColortype, - mng_uint8 *iSampledepth, - mng_uint8 *iFilltype); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_pplt (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iDeltatype, - mng_uint32 *iCount); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_pplt_entry (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue, - mng_uint16 *iAlpha, - mng_bool *bUsed); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_drop (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount, - mng_chunkidp *pChunknames); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_dbyk (mng_handle hHandle, - mng_handle hChunk, - mng_chunkid *iChunkname, - mng_uint8 *iPolarity, - mng_uint32 *iKeywordssize, - mng_pchar *zKeywords); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_ordr (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_ordr_entry (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_chunkid *iChunkname, - mng_uint8 *iOrdertype); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_magn (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iFirstid, - mng_uint16 *iLastid, - mng_uint16 *iMethodX, - mng_uint16 *iMX, - mng_uint16 *iMY, - mng_uint16 *iML, - mng_uint16 *iMR, - mng_uint16 *iMT, - mng_uint16 *iMB, - mng_uint16 *iMethodY); - -#ifdef MNG_INCLUDE_MPNG_PROPOSAL -MNG_EXT mng_retcode MNG_DECL mng_getchunk_mpng (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iFramewidth, - mng_uint32 *iFrameheight, - mng_uint16 *iNumplays, - mng_uint16 *iTickspersec, - mng_uint8 *iCompressionmethod, - mng_uint32 *iCount); -MNG_EXT mng_retcode MNG_DECL mng_getchunk_mpng_frame (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_uint32 *iX, - mng_uint32 *iY, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_int32 *iXoffset, - mng_int32 *iYoffset, - mng_uint16 *iTicks); -#endif - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_evnt (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_evnt_entry (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_uint8 *iEventtype, - mng_uint8 *iMasktype, - mng_int32 *iLeft, - mng_int32 *iRight, - mng_int32 *iTop, - mng_int32 *iBottom, - mng_uint16 *iObjectid, - mng_uint8 *iIndex, - mng_uint32 *iSegmentnamesize, - mng_pchar *zSegmentname); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_unknown (mng_handle hHandle, - mng_handle hChunk, - mng_chunkid *iChunkname, - mng_uint32 *iRawlen, - mng_ptr *pRawdata); - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_WRITE_PROCS - -/* use these to create new chunks at the end of the chunk-list */ -/* requires at least MNG_ACCESS_CHUNKS (MNG_SUPPORT_WRITE may be nice too) */ -MNG_EXT mng_retcode MNG_DECL mng_putchunk_ihdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_plte (mng_handle hHandle, - mng_uint32 iCount, - mng_palette8 aPalette); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_idat (mng_handle hHandle, - mng_uint32 iRawlen, - mng_ptr pRawdata); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_iend (mng_handle hHandle); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_trns (mng_handle hHandle, - mng_bool bEmpty, - mng_bool bGlobal, - mng_uint8 iType, - mng_uint32 iCount, - mng_uint8arr aAlphas, - mng_uint16 iGray, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint32 iRawlen, - mng_uint8arr aRawdata); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_gama (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iGamma); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_chrm (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iWhitepointx, - mng_uint32 iWhitepointy, - mng_uint32 iRedx, - mng_uint32 iRedy, - mng_uint32 iGreenx, - mng_uint32 iGreeny, - mng_uint32 iBluex, - mng_uint32 iBluey); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_srgb (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iRenderingintent); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_iccp (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iNamesize, - mng_pchar zName, - mng_uint8 iCompression, - mng_uint32 iProfilesize, - mng_ptr pProfile); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_text (mng_handle hHandle, - mng_uint32 iKeywordsize, - mng_pchar zKeyword, - mng_uint32 iTextsize, - mng_pchar zText); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_ztxt (mng_handle hHandle, - mng_uint32 iKeywordsize, - mng_pchar zKeyword, - mng_uint8 iCompression, - mng_uint32 iTextsize, - mng_pchar zText); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_itxt (mng_handle hHandle, - mng_uint32 iKeywordsize, - mng_pchar zKeyword, - mng_uint8 iCompressionflag, - mng_uint8 iCompressionmethod, - mng_uint32 iLanguagesize, - mng_pchar zLanguage, - mng_uint32 iTranslationsize, - mng_pchar zTranslation, - mng_uint32 iTextsize, - mng_pchar zText); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_bkgd (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iType, - mng_uint8 iIndex, - mng_uint16 iGray, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_phys (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iSizex, - mng_uint32 iSizey, - mng_uint8 iUnit); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_sbit (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iType, - mng_uint8arr4 aBits); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_splt (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iNamesize, - mng_pchar zName, - mng_uint8 iSampledepth, - mng_uint32 iEntrycount, - mng_ptr pEntries); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_hist (mng_handle hHandle, - mng_uint32 iEntrycount, - mng_uint16arr aEntries); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_time (mng_handle hHandle, - mng_uint16 iYear, - mng_uint8 iMonth, - mng_uint8 iDay, - mng_uint8 iHour, - mng_uint8 iMinute, - mng_uint8 iSecond); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_mhdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint32 iTicks, - mng_uint32 iLayercount, - mng_uint32 iFramecount, - mng_uint32 iPlaytime, - mng_uint32 iSimplicity); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_mend (mng_handle hHandle); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_loop (mng_handle hHandle, - mng_uint8 iLevel, - mng_uint32 iRepeat, - mng_uint8 iTermination, - mng_uint32 iItermin, - mng_uint32 iItermax, - mng_uint32 iCount, - mng_uint32p pSignals); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_endl (mng_handle hHandle, - mng_uint8 iLevel); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_defi (mng_handle hHandle, - mng_uint16 iObjectid, - mng_uint8 iDonotshow, - mng_uint8 iConcrete, - mng_bool bHasloca, - mng_int32 iXlocation, - mng_int32 iYlocation, - mng_bool bHasclip, - mng_int32 iLeftcb, - mng_int32 iRightcb, - mng_int32 iTopcb, - mng_int32 iBottomcb); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_basi (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint16 iAlpha, - mng_uint8 iViewable); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_clon (mng_handle hHandle, - mng_uint16 iSourceid, - mng_uint16 iCloneid, - mng_uint8 iClonetype, - mng_uint8 iDonotshow, - mng_uint8 iConcrete, - mng_bool bHasloca, - mng_uint8 iLocationtype, - mng_int32 iLocationx, - mng_int32 iLocationy); - -#ifndef MNG_SKIPCHUNK_PAST -MNG_EXT mng_retcode MNG_DECL mng_putchunk_past (mng_handle hHandle, - mng_uint16 iDestid, - mng_uint8 iTargettype, - mng_int32 iTargetx, - mng_int32 iTargety, - mng_uint32 iCount); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_past_src (mng_handle hHandle, - mng_uint32 iEntry, - mng_uint16 iSourceid, - mng_uint8 iComposition, - mng_uint8 iOrientation, - mng_uint8 iOffsettype, - mng_int32 iOffsetx, - mng_int32 iOffsety, - mng_uint8 iBoundarytype, - mng_int32 iBoundaryl, - mng_int32 iBoundaryr, - mng_int32 iBoundaryt, - mng_int32 iBoundaryb); -#endif - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_disc (mng_handle hHandle, - mng_uint32 iCount, - mng_uint16p pObjectids); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_back (mng_handle hHandle, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint8 iMandatory, - mng_uint16 iImageid, - mng_uint8 iTile); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_fram (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iMode, - mng_uint32 iNamesize, - mng_pchar zName, - mng_uint8 iChangedelay, - mng_uint8 iChangetimeout, - mng_uint8 iChangeclipping, - mng_uint8 iChangesyncid, - mng_uint32 iDelay, - mng_uint32 iTimeout, - mng_uint8 iBoundarytype, - mng_int32 iBoundaryl, - mng_int32 iBoundaryr, - mng_int32 iBoundaryt, - mng_int32 iBoundaryb, - mng_uint32 iCount, - mng_uint32p pSyncids); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_move (mng_handle hHandle, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iMovetype, - mng_int32 iMovex, - mng_int32 iMovey); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_clip (mng_handle hHandle, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iCliptype, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_show (mng_handle hHandle, - mng_bool bEmpty, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iMode); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_term (mng_handle hHandle, - mng_uint8 iTermaction, - mng_uint8 iIteraction, - mng_uint32 iDelay, - mng_uint32 iItermax); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_save (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iOffsettype, - mng_uint32 iCount); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_save_entry (mng_handle hHandle, - mng_uint32 iEntry, - mng_uint8 iEntrytype, - mng_uint32arr2 iOffset, - mng_uint32arr2 iStarttime, - mng_uint32 iLayernr, - mng_uint32 iFramenr, - mng_uint32 iNamesize, - mng_pchar zName); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_seek (mng_handle hHandle, - mng_uint32 iNamesize, - mng_pchar zName); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_expi (mng_handle hHandle, - mng_uint16 iSnapshotid, - mng_uint32 iNamesize, - mng_pchar zName); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_fpri (mng_handle hHandle, - mng_uint8 iDeltatype, - mng_uint8 iPriority); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_need (mng_handle hHandle, - mng_uint32 iKeywordssize, - mng_pchar zKeywords); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_phyg (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iSizex, - mng_uint32 iSizey, - mng_uint8 iUnit); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_jhdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iColortype, - mng_uint8 iImagesampledepth, - mng_uint8 iImagecompression, - mng_uint8 iImageinterlace, - mng_uint8 iAlphasampledepth, - mng_uint8 iAlphacompression, - mng_uint8 iAlphafilter, - mng_uint8 iAlphainterlace); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_jdat (mng_handle hHandle, - mng_uint32 iRawlen, - mng_ptr pRawdata); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_jdaa (mng_handle hHandle, - mng_uint32 iRawlen, - mng_ptr pRawdata); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_jsep (mng_handle hHandle); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_dhdr (mng_handle hHandle, - mng_uint16 iObjectid, - mng_uint8 iImagetype, - mng_uint8 iDeltatype, - mng_uint32 iBlockwidth, - mng_uint32 iBlockheight, - mng_uint32 iBlockx, - mng_uint32 iBlocky); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_prom (mng_handle hHandle, - mng_uint8 iColortype, - mng_uint8 iSampledepth, - mng_uint8 iFilltype); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_ipng (mng_handle hHandle); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_pplt (mng_handle hHandle, - mng_uint8 iDeltatype, - mng_uint32 iCount); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_pplt_entry (mng_handle hHandle, - mng_uint32 iEntry, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint16 iAlpha); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_jpng (mng_handle hHandle); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_drop (mng_handle hHandle, - mng_uint32 iCount, - mng_chunkidp pChunknames); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_dbyk (mng_handle hHandle, - mng_chunkid iChunkname, - mng_uint8 iPolarity, - mng_uint32 iKeywordssize, - mng_pchar zKeywords); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_ordr (mng_handle hHandle, - mng_uint32 iCount); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_ordr_entry (mng_handle hHandle, - mng_uint32 iEntry, - mng_chunkid iChunkname, - mng_uint8 iOrdertype); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_magn (mng_handle hHandle, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint16 iMethodX, - mng_uint16 iMX, - mng_uint16 iMY, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint16 iMT, - mng_uint16 iMB, - mng_uint16 iMethodY); - -#ifdef MNG_INCLUDE_MPNG_PROPOSAL -MNG_EXT mng_retcode MNG_DECL mng_putchunk_mpng (mng_handle hHandle, - mng_uint32 iFramewidth, - mng_uint32 iFrameheight, - mng_uint16 iNumplays, - mng_uint16 iTickspersec, - mng_uint8 iCompressionmethod, - mng_uint32 iCount); -MNG_EXT mng_retcode MNG_DECL mng_putchunk_mpng_frame (mng_handle hHandle, - mng_uint32 iEntry, - mng_uint32 iX, - mng_uint32 iY, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_int32 iXoffset, - mng_int32 iYoffset, - mng_uint16 iTicks); -#endif - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_evnt (mng_handle hHandle, - mng_uint32 iCount); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_evnt_entry (mng_handle hHandle, - mng_uint32 iEntry, - mng_uint8 iEventtype, - mng_uint8 iMasktype, - mng_int32 iLeft, - mng_int32 iRight, - mng_int32 iTop, - mng_int32 iBottom, - mng_uint16 iObjectid, - mng_uint8 iIndex, - mng_uint32 iSegmentnamesize, - mng_pchar zSegmentname); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_unknown (mng_handle hHandle, - mng_chunkid iChunkname, - mng_uint32 iRawlen, - mng_ptr pRawdata); - -#endif /* MNG_INCLUDE_WRITE_PROCS */ - -/* ************************************************************************** */ - -/* use these functions to access the actual image-data in stored chunks, - as opposed to the IDAT/JDAT data */ -/* to get accurate pixel-data the canvasstyle should seriously reflect the - bitdepth/colortype combination of the preceding IHDR/JHDR/BASI/DHDR; - all input can be converted to rgb(a)8 (rgb(a)16 for 16-bit images), but - there are only limited conversions back (see below for putimgdata) */ - -/* call this function if you want to extract the nth image from the list; - the first image is designated seqnr 0! */ -/* this function finds the IHDR/JHDR/BASI/DHDR with the appropriate seqnr, - starting from the beginning of the chunk-list; this may tend to get a little - slow for animations with a large number of chunks for images near the end */ -/* supplying a seqnr past the last image in the animation will return with - an errorcode */ -MNG_EXT mng_retcode MNG_DECL mng_getimgdata_seq (mng_handle hHandle, - mng_uint32 iSeqnr, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline); - -/* both the following functions will search forward to find the first IDAT/JDAT, - and then traverse back to find the start of the image (IHDR,JHDR,DHDR,BASI); - note that this is very fast compared to decoding the IDAT/JDAT, so there's - not really a need for optimization; either can be called from the - iterate_chunks callback when a IHDR/JHDR is encountered; for BASI/DHDR there - may not be real image-data so it's wisest to keep iterating till the IEND, - and then call either of these functions if necessary (remember the correct seqnr!) */ - -/* call this function if you want to extract the image starting at or after the nth - position in the chunk-list; this number is returned in the iterate_chunks callback */ -MNG_EXT mng_retcode MNG_DECL mng_getimgdata_chunkseq (mng_handle hHandle, - mng_uint32 iSeqnr, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline); - -/* call this function if you want to extract the image starting at or after the - indicated chunk; the handle of a chunk is returned in the iterate_chunks callback */ -MNG_EXT mng_retcode MNG_DECL mng_getimgdata_chunk (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline); - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_WRITE_PROCS - -/* use the following functions to add image-data to the list of stored chunks */ -/* note that this only adds the IDAT or JDAT chunks and no others; you must call - one of these functions after you 'put' the initial chunks of the image and - before you 'put' the closing chunks */ -/* the canvasstyle should seriously reflect the bitdepth/colortype combination; - eg. bitdepth=16 would expect a 16-bit canvasstyle, - colortype=g or ga would expect a gray or gray+alpha style respectively - and so on, and so forth ... - (nb. the number of conversions will be extremely limited for the moment!) */ - -MNG_EXT mng_retcode MNG_DECL mng_putimgdata_ihdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iColortype, - mng_uint8 iBitdepth, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline); - -MNG_EXT mng_retcode MNG_DECL mng_putimgdata_jhdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iColortype, - mng_uint8 iBitdepth, - mng_uint8 iCompression, - mng_uint8 iInterlace, - mng_uint8 iAlphaBitdepth, - mng_uint8 iAlphaCompression, - mng_uint8 iAlphaFilter, - mng_uint8 iAlphaInterlace, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline); - -/* ************************************************************************** */ - -/* use the following functions to set the framecount/layercount/playtime or - simplicity of an animation you are creating; this may be useful if these - variables are calculated during the creation-process */ - -MNG_EXT mng_retcode MNG_DECL mng_updatemngheader (mng_handle hHandle, - mng_uint32 iFramecount, - mng_uint32 iLayercount, - mng_uint32 iPlaytime); - -MNG_EXT mng_retcode MNG_DECL mng_updatemngsimplicity (mng_handle hHandle, - mng_uint32 iSimplicity); - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_WRITE_PROCS */ - -#endif /* MNG_ACCESS_CHUNKS */ - -/* ************************************************************************** */ -/* * * */ -/* * Error-code structure * */ -/* * * */ -/* * 0b0000 00xx xxxx xxxx - basic errors; severity 9 (environment) * */ -/* * 0b0000 01xx xxxx xxxx - chunk errors; severity 9 (image induced) * */ -/* * 0b0000 10xx xxxx xxxx - severity 5 errors (application induced) * */ -/* * 0b0001 00xx xxxx xxxx - severity 2 warnings (recoverable) * */ -/* * 0b0010 00xx xxxx xxxx - severity 1 warnings (recoverable) * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_NOERROR (mng_retcode)0 /* er.. indicates all's well */ - -#define MNG_OUTOFMEMORY (mng_retcode)1 /* oops, buy some megabytes! */ -#define MNG_INVALIDHANDLE (mng_retcode)2 /* call mng_initialize first */ -#define MNG_NOCALLBACK (mng_retcode)3 /* set the callbacks please */ -#define MNG_UNEXPECTEDEOF (mng_retcode)4 /* what'd ya do with the data? */ -#define MNG_ZLIBERROR (mng_retcode)5 /* zlib burped */ -#define MNG_JPEGERROR (mng_retcode)6 /* jpglib complained */ -#define MNG_LCMSERROR (mng_retcode)7 /* little cms stressed out */ -#define MNG_NOOUTPUTPROFILE (mng_retcode)8 /* no output-profile defined */ -#define MNG_NOSRGBPROFILE (mng_retcode)9 /* no sRGB-profile defined */ -#define MNG_BUFOVERFLOW (mng_retcode)10 /* zlib output-buffer overflow */ -#define MNG_FUNCTIONINVALID (mng_retcode)11 /* ay, totally inappropriate */ -#define MNG_OUTPUTERROR (mng_retcode)12 /* disk full ? */ -#define MNG_JPEGBUFTOOSMALL (mng_retcode)13 /* can't handle buffer overflow*/ -#define MNG_NEEDMOREDATA (mng_retcode)14 /* I'm hungry, give me more */ -#define MNG_NEEDTIMERWAIT (mng_retcode)15 /* Sleep a while then wake me */ -#define MNG_NEEDSECTIONWAIT (mng_retcode)16 /* just processed a SEEK */ -#define MNG_LOOPWITHCACHEOFF (mng_retcode)17 /* LOOP when playback info off */ - -#define MNG_DLLNOTLOADED (mng_retcode)99 /* late binding failed */ - -#define MNG_APPIOERROR (mng_retcode)901 /* application I/O error */ -#define MNG_APPTIMERERROR (mng_retcode)902 /* application timing error */ -#define MNG_APPCMSERROR (mng_retcode)903 /* application CMS error */ -#define MNG_APPMISCERROR (mng_retcode)904 /* application other error */ -#define MNG_APPTRACEABORT (mng_retcode)905 /* application aborts on trace */ - -#define MNG_INTERNALERROR (mng_retcode)999 /* internal inconsistancy */ - -#define MNG_INVALIDSIG (mng_retcode)1025 /* invalid graphics file */ -#define MNG_INVALIDCRC (mng_retcode)1027 /* crc check failed */ -#define MNG_INVALIDLENGTH (mng_retcode)1028 /* chunklength mystifies me */ -#define MNG_SEQUENCEERROR (mng_retcode)1029 /* invalid chunk sequence */ -#define MNG_CHUNKNOTALLOWED (mng_retcode)1030 /* completely out-of-place */ -#define MNG_MULTIPLEERROR (mng_retcode)1031 /* only one occurence allowed */ -#define MNG_PLTEMISSING (mng_retcode)1032 /* indexed-color requires PLTE */ -#define MNG_IDATMISSING (mng_retcode)1033 /* IHDR-block requires IDAT */ -#define MNG_CANNOTBEEMPTY (mng_retcode)1034 /* must contain some data */ -#define MNG_GLOBALLENGTHERR (mng_retcode)1035 /* global data incorrect */ -#define MNG_INVALIDBITDEPTH (mng_retcode)1036 /* bitdepth out-of-range */ -#define MNG_INVALIDCOLORTYPE (mng_retcode)1037 /* colortype out-of-range */ -#define MNG_INVALIDCOMPRESS (mng_retcode)1038 /* compression method invalid */ -#define MNG_INVALIDFILTER (mng_retcode)1039 /* filter method invalid */ -#define MNG_INVALIDINTERLACE (mng_retcode)1040 /* interlace method invalid */ -#define MNG_NOTENOUGHIDAT (mng_retcode)1041 /* ran out of compressed data */ -#define MNG_PLTEINDEXERROR (mng_retcode)1042 /* palette-index out-of-range */ -#define MNG_NULLNOTFOUND (mng_retcode)1043 /* couldn't find null-separator*/ -#define MNG_KEYWORDNULL (mng_retcode)1044 /* keyword cannot be empty */ -#define MNG_OBJECTUNKNOWN (mng_retcode)1045 /* the object can't be found */ -#define MNG_OBJECTEXISTS (mng_retcode)1046 /* the object already exists */ -#define MNG_TOOMUCHIDAT (mng_retcode)1047 /* got too much compressed data*/ -#define MNG_INVSAMPLEDEPTH (mng_retcode)1048 /* sampledepth out-of-range */ -#define MNG_INVOFFSETSIZE (mng_retcode)1049 /* invalid offset-size */ -#define MNG_INVENTRYTYPE (mng_retcode)1050 /* invalid entry-type */ -#define MNG_ENDWITHNULL (mng_retcode)1051 /* may not end with NULL */ -#define MNG_INVIMAGETYPE (mng_retcode)1052 /* invalid image_type */ -#define MNG_INVDELTATYPE (mng_retcode)1053 /* invalid delta_type */ -#define MNG_INVALIDINDEX (mng_retcode)1054 /* index-value invalid */ -#define MNG_TOOMUCHJDAT (mng_retcode)1055 /* got too much compressed data*/ -#define MNG_JPEGPARMSERR (mng_retcode)1056 /* JHDR/JPEG parms do not match*/ -#define MNG_INVFILLMETHOD (mng_retcode)1057 /* invalid fill_method */ -#define MNG_OBJNOTCONCRETE (mng_retcode)1058 /* object must be concrete */ -#define MNG_TARGETNOALPHA (mng_retcode)1059 /* object has no alpha-channel */ -#define MNG_MNGTOOCOMPLEX (mng_retcode)1060 /* can't handle complexity */ -#define MNG_UNKNOWNCRITICAL (mng_retcode)1061 /* unknown critical chunk found*/ -#define MNG_UNSUPPORTEDNEED (mng_retcode)1062 /* nEED requirement unsupported*/ -#define MNG_INVALIDDELTA (mng_retcode)1063 /* Delta operation illegal */ -#define MNG_INVALIDMETHOD (mng_retcode)1064 /* invalid MAGN method */ -#define MNG_IMPROBABLELENGTH (mng_retcode)1065 /* impropable chunk length */ -#define MNG_INVALIDBLOCK (mng_retcode)1066 /* invalid delta block */ -#define MNG_INVALIDEVENT (mng_retcode)1067 /* invalid event_type */ -#define MNG_INVALIDMASK (mng_retcode)1068 /* invalid mask_type */ -#define MNG_NOMATCHINGLOOP (mng_retcode)1069 /* ENDL without matching LOOP */ -#define MNG_SEEKNOTFOUND (mng_retcode)1070 /* EvNT points to unknown SEEK */ -#define MNG_OBJNOTABSTRACT (mng_retcode)1071 /* object must be abstract */ -#define MNG_TERMSEQERROR (mng_retcode)1072 /* TERM in wrong place */ -#define MNG_INVALIDFIELDVAL (mng_retcode)1073 /* invalid fieldvalue (generic)*/ -#define MNG_INVALIDWIDTH (mng_retcode)1074 /* invalid frame/image width */ -#define MNG_INVALIDHEIGHT (mng_retcode)1075 /* invalid frame/image height */ - -#define MNG_INVALIDCNVSTYLE (mng_retcode)2049 /* can't make anything of this */ -#define MNG_WRONGCHUNK (mng_retcode)2050 /* accessing the wrong chunk */ -#define MNG_INVALIDENTRYIX (mng_retcode)2051 /* accessing the wrong entry */ -#define MNG_NOHEADER (mng_retcode)2052 /* must have had header first */ -#define MNG_NOCORRCHUNK (mng_retcode)2053 /* can't find parent chunk */ -#define MNG_NOMHDR (mng_retcode)2054 /* no MNG header available */ - -#define MNG_IMAGETOOLARGE (mng_retcode)4097 /* input-image way too big */ -#define MNG_NOTANANIMATION (mng_retcode)4098 /* file not a MNG */ -#define MNG_FRAMENRTOOHIGH (mng_retcode)4099 /* frame-nr out-of-range */ -#define MNG_LAYERNRTOOHIGH (mng_retcode)4100 /* layer-nr out-of-range */ -#define MNG_PLAYTIMETOOHIGH (mng_retcode)4101 /* playtime out-of-range */ -#define MNG_FNNOTIMPLEMENTED (mng_retcode)4102 /* function not yet available */ - -#define MNG_IMAGEFROZEN (mng_retcode)8193 /* stopped displaying */ - -#define MNG_LCMS_NOHANDLE 1 /* LCMS returned NULL handle */ -#define MNG_LCMS_NOMEM 2 /* LCMS returned NULL gammatab */ -#define MNG_LCMS_NOTRANS 3 /* LCMS returned NULL transform*/ - -/* ************************************************************************** */ -/* * * */ -/* * Canvas styles * */ -/* * * */ -/* * Note that the intentions are pretty darn good, but that the focus * */ -/* * is currently on 8-bit color support * */ -/* * * */ -/* * The RGB8_A8 style is defined for apps that require a separate * */ -/* * canvas for the color-planes and the alpha-plane (eg. mozilla) * */ -/* * This requires for the app to supply the "getalphaline" callback!!! * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_CANVAS_RGB8 0x00000000L -#define MNG_CANVAS_RGBA8 0x00001000L -#define MNG_CANVAS_RGBA8_PM 0x00009000L -#define MNG_CANVAS_ARGB8 0x00003000L -#define MNG_CANVAS_ARGB8_PM 0x0000B000L -#define MNG_CANVAS_RGB8_A8 0x00005000L -#define MNG_CANVAS_BGR8 0x00000001L -#define MNG_CANVAS_BGRX8 0x00010001L -#define MNG_CANVAS_BGRA8 0x00001001L -#define MNG_CANVAS_BGRA8PM 0x00009001L /* backward compatibility */ -#define MNG_CANVAS_BGRA8_PM 0x00009001L -#define MNG_CANVAS_ABGR8 0x00003001L -#define MNG_CANVAS_ABGR8_PM 0x0000B001L -#define MNG_CANVAS_RGB16 0x00000100L /* not supported yet */ -#define MNG_CANVAS_RGBA16 0x00001100L /* not supported yet */ -#define MNG_CANVAS_ARGB16 0x00003100L /* not supported yet */ -#define MNG_CANVAS_BGR16 0x00000101L /* not supported yet */ -#define MNG_CANVAS_BGRA16 0x00001101L /* not supported yet */ -#define MNG_CANVAS_ABGR16 0x00003101L /* not supported yet */ -#define MNG_CANVAS_GRAY8 0x00000002L /* not supported yet */ -#define MNG_CANVAS_GRAY16 0x00000102L /* not supported yet */ -#define MNG_CANVAS_GRAYA8 0x00001002L /* not supported yet */ -#define MNG_CANVAS_GRAYA16 0x00001102L /* not supported yet */ -#define MNG_CANVAS_AGRAY8 0x00003002L /* not supported yet */ -#define MNG_CANVAS_AGRAY16 0x00003102L /* not supported yet */ -#define MNG_CANVAS_DX15 0x00000003L /* not supported yet */ -#define MNG_CANVAS_DX16 0x00000004L /* not supported yet */ - -#define MNG_CANVAS_RGB565 0x00000005L -#define MNG_CANVAS_RGBA565 0x00001005L -#define MNG_CANVAS_BGR565 0x00000006L -#define MNG_CANVAS_BGRA565 0x00001006L -#define MNG_CANVAS_BGR565_A8 0x00004006L - -#define MNG_CANVAS_RGB555 0x00000007L -#define MNG_CANVAS_BGR555 0x00000008L - -#define MNG_CANVAS_PIXELTYPE(C) (C & 0x000000FFL) -#define MNG_CANVAS_BITDEPTH(C) (C & 0x00000100L) -#define MNG_CANVAS_HASALPHA(C) (C & 0x00001000L) -#define MNG_CANVAS_ALPHAFIRST(C) (C & 0x00002000L) -#define MNG_CANVAS_ALPHASEPD(C) (C & 0x00004000L) -#define MNG_CANVAS_ALPHAPM(C) (C & 0x00008000L) -#define MNG_CANVAS_HASFILLER(C) (C & 0x00010000L) - -#define MNG_CANVAS_RGB(C) (MNG_CANVAS_PIXELTYPE (C) == 0) -#define MNG_CANVAS_BGR(C) (MNG_CANVAS_PIXELTYPE (C) == 1) -#define MNG_CANVAS_GRAY(C) (MNG_CANVAS_PIXELTYPE (C) == 2) -#define MNG_CANVAS_DIRECTX15(C) (MNG_CANVAS_PIXELTYPE (C) == 3) -#define MNG_CANVAS_DIRECTX16(C) (MNG_CANVAS_PIXELTYPE (C) == 4) -#define MNG_CANVAS_RGB_565(C) (MNG_CANVAS_PIXELTYPE (C) == 5) -#define MNG_CANVAS_BGR_565(C) (MNG_CANVAS_PIXELTYPE (C) == 6) -#define MNG_CANVAS_8BIT(C) (!MNG_CANVAS_BITDEPTH (C)) -#define MNG_CANVAS_16BIT(C) (MNG_CANVAS_BITDEPTH (C)) -#define MNG_CANVAS_PIXELFIRST(C) (!MNG_CANVAS_ALPHAFIRST (C)) - -/* ************************************************************************** */ -/* * * */ -/* * Chunk names (idea adapted from libpng 1.1.0 - png.h) * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_UINT_HUH 0x40404040L - -#define MNG_UINT_BACK 0x4241434bL -#define MNG_UINT_BASI 0x42415349L -#define MNG_UINT_CLIP 0x434c4950L -#define MNG_UINT_CLON 0x434c4f4eL -#define MNG_UINT_DBYK 0x4442594bL -#define MNG_UINT_DEFI 0x44454649L -#define MNG_UINT_DHDR 0x44484452L -#define MNG_UINT_DISC 0x44495343L -#define MNG_UINT_DROP 0x44524f50L -#define MNG_UINT_ENDL 0x454e444cL -#define MNG_UINT_FRAM 0x4652414dL -#define MNG_UINT_IDAT 0x49444154L -#define MNG_UINT_IEND 0x49454e44L -#define MNG_UINT_IHDR 0x49484452L -#define MNG_UINT_IJNG 0x494a4e47L -#define MNG_UINT_IPNG 0x49504e47L -#define MNG_UINT_JDAA 0x4a444141L -#define MNG_UINT_JDAT 0x4a444154L -#define MNG_UINT_JHDR 0x4a484452L -#define MNG_UINT_JSEP 0x4a534550L -#define MNG_UINT_JdAA 0x4a644141L -#define MNG_UINT_LOOP 0x4c4f4f50L -#define MNG_UINT_MAGN 0x4d41474eL -#define MNG_UINT_MEND 0x4d454e44L -#define MNG_UINT_MHDR 0x4d484452L -#define MNG_UINT_MOVE 0x4d4f5645L -#define MNG_UINT_ORDR 0x4f524452L -#define MNG_UINT_PAST 0x50415354L -#define MNG_UINT_PLTE 0x504c5445L -#define MNG_UINT_PPLT 0x50504c54L -#define MNG_UINT_PROM 0x50524f4dL -#define MNG_UINT_SAVE 0x53415645L -#define MNG_UINT_SEEK 0x5345454bL -#define MNG_UINT_SHOW 0x53484f57L -#define MNG_UINT_TERM 0x5445524dL -#define MNG_UINT_adAT 0x61644154L -#define MNG_UINT_ahDR 0x61684452L -#define MNG_UINT_bKGD 0x624b4744L -#define MNG_UINT_cHRM 0x6348524dL -#define MNG_UINT_eXPI 0x65585049L -#define MNG_UINT_evNT 0x65764e54L -#define MNG_UINT_fPRI 0x66505249L -#define MNG_UINT_gAMA 0x67414d41L -#define MNG_UINT_hIST 0x68495354L -#define MNG_UINT_iCCP 0x69434350L -#define MNG_UINT_iTXt 0x69545874L -#define MNG_UINT_mpNG 0x6d704e47L -#define MNG_UINT_nEED 0x6e454544L -#define MNG_UINT_oFFs 0x6f464673L -#define MNG_UINT_pCAL 0x7043414cL -#define MNG_UINT_pHYg 0x70444167L -#define MNG_UINT_pHYs 0x70485973L -#define MNG_UINT_sBIT 0x73424954L -#define MNG_UINT_sCAL 0x7343414cL -#define MNG_UINT_sPLT 0x73504c54L -#define MNG_UINT_sRGB 0x73524742L -#define MNG_UINT_tEXt 0x74455874L -#define MNG_UINT_tIME 0x74494d45L -#define MNG_UINT_tRNS 0x74524e53L -#define MNG_UINT_zTXt 0x7a545874L - -/* ************************************************************************** */ -/* * * */ -/* * Chunk property values * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_BITDEPTH_1 1 /* IHDR, BASI, JHDR, PROM */ -#define MNG_BITDEPTH_2 2 -#define MNG_BITDEPTH_4 4 -#define MNG_BITDEPTH_8 8 /* sPLT */ -#define MNG_BITDEPTH_16 16 - -#define MNG_COLORTYPE_GRAY 0 /* IHDR, BASI, PROM */ -#define MNG_COLORTYPE_RGB 2 -#define MNG_COLORTYPE_INDEXED 3 -#define MNG_COLORTYPE_GRAYA 4 -#define MNG_COLORTYPE_RGBA 6 - -#define MNG_COMPRESSION_DEFLATE 0 /* IHDR, zTXt, iTXt, iCCP, - BASI, JHDR */ - -#define MNG_FILTER_ADAPTIVE 0 /* IHDR, BASI, JHDR */ -/* #define MNG_FILTER_NO_ADAPTIVE 1 -#define MNG_FILTER_NO_DIFFERING 0 -#define MNG_FILTER_DIFFERING 0x40 -#define MNG_FILTER_MASK (MNG_FILTER_NO_ADAPTIVE | MNG_FILTER_DIFFERING) */ -#ifdef FILTER192 -#define MNG_FILTER_DIFFERING 0xC0 -#endif -#ifdef FILTER193 -#define MNG_FILTER_NOFILTER 0xC1 -#endif - -#define MNG_INTERLACE_NONE 0 /* IHDR, BASI, JHDR */ -#define MNG_INTERLACE_ADAM7 1 - -#define MNG_FILTER_NONE 0 /* IDAT */ -#define MNG_FILTER_SUB 1 -#define MNG_FILTER_UP 2 -#define MNG_FILTER_AVERAGE 3 -#define MNG_FILTER_PAETH 4 - -#define MNG_INTENT_PERCEPTUAL 0 /* sRGB */ -#define MNG_INTENT_RELATIVECOLORIMETRIC 1 -#define MNG_INTENT_SATURATION 2 -#define MNG_INTENT_ABSOLUTECOLORIMETRIC 3 - /* tEXt, zTXt, iTXt */ -#define MNG_TEXT_TITLE "Title" -#define MNG_TEXT_AUTHOR "Author" -#define MNG_TEXT_DESCRIPTION "Description" -#define MNG_TEXT_COPYRIGHT "Copyright" -#define MNG_TEXT_CREATIONTIME "Creation Time" -#define MNG_TEXT_SOFTWARE "Software" -#define MNG_TEXT_DISCLAIMER "Disclaimer" -#define MNG_TEXT_WARNING "Warning" -#define MNG_TEXT_SOURCE "Source" -#define MNG_TEXT_COMMENT "Comment" - -#define MNG_FLAG_UNCOMPRESSED 0 /* iTXt */ -#define MNG_FLAG_COMPRESSED 1 - -#define MNG_UNIT_UNKNOWN 0 /* pHYs, pHYg */ -#define MNG_UNIT_METER 1 - /* MHDR */ -#define MNG_SIMPLICITY_VALID 0x00000001 -#define MNG_SIMPLICITY_SIMPLEFEATURES 0x00000002 -#define MNG_SIMPLICITY_COMPLEXFEATURES 0x00000004 -#define MNG_SIMPLICITY_TRANSPARENCY 0x00000008 -#define MNG_SIMPLICITY_JNG 0x00000010 -#define MNG_SIMPLICITY_DELTAPNG 0x00000020 - -#define MNG_TERMINATION_DECODER_NC 0 /* LOOP */ -#define MNG_TERMINATION_USER_NC 1 -#define MNG_TERMINATION_EXTERNAL_NC 2 -#define MNG_TERMINATION_DETERMINISTIC_NC 3 -#define MNG_TERMINATION_DECODER_C 4 -#define MNG_TERMINATION_USER_C 5 -#define MNG_TERMINATION_EXTERNAL_C 6 -#define MNG_TERMINATION_DETERMINISTIC_C 7 - -#define MNG_DONOTSHOW_VISIBLE 0 /* DEFI */ -#define MNG_DONOTSHOW_NOTVISIBLE 1 - -#define MNG_ABSTRACT 0 /* DEFI */ -#define MNG_CONCRETE 1 - -#define MNG_NOTVIEWABLE 0 /* BASI */ -#define MNG_VIEWABLE 1 - -#define MNG_FULL_CLONE 0 /* CLON */ -#define MNG_PARTIAL_CLONE 1 -#define MNG_RENUMBER 2 - -#define MNG_CONCRETE_ASPARENT 0 /* CLON */ -#define MNG_CONCRETE_MAKEABSTRACT 1 - -#define MNG_LOCATION_ABSOLUTE 0 /* CLON, MOVE */ -#define MNG_LOCATION_RELATIVE 1 - -#ifndef MNG_SKIPCHUNK_PAST -#define MNG_TARGET_ABSOLUTE 0 /* PAST */ -#define MNG_TARGET_RELATIVE_SAMEPAST 1 -#define MNG_TARGET_RELATIVE_PREVPAST 2 - -#define MNG_COMPOSITE_OVER 0 /* PAST */ -#define MNG_COMPOSITE_REPLACE 1 -#define MNG_COMPOSITE_UNDER 2 - -#define MNG_ORIENTATION_SAME 0 /* PAST */ -#define MNG_ORIENTATION_180DEG 2 -#define MNG_ORIENTATION_FLIPHORZ 4 -#define MNG_ORIENTATION_FLIPVERT 6 -#define MNG_ORIENTATION_TILED 8 - -#define MNG_OFFSET_ABSOLUTE 0 /* PAST */ -#define MNG_OFFSET_RELATIVE 1 -#endif - -#define MNG_BOUNDARY_ABSOLUTE 0 /* PAST, FRAM */ -#define MNG_BOUNDARY_RELATIVE 1 - -#define MNG_BACKGROUNDCOLOR_MANDATORY 0x01 /* BACK */ -#define MNG_BACKGROUNDIMAGE_MANDATORY 0x02 /* BACK */ - -#define MNG_BACKGROUNDIMAGE_NOTILE 0 /* BACK */ -#define MNG_BACKGROUNDIMAGE_TILE 1 - -#define MNG_FRAMINGMODE_NOCHANGE 0 /* FRAM */ -#define MNG_FRAMINGMODE_1 1 -#define MNG_FRAMINGMODE_2 2 -#define MNG_FRAMINGMODE_3 3 -#define MNG_FRAMINGMODE_4 4 - -#define MNG_CHANGEDELAY_NO 0 /* FRAM */ -#define MNG_CHANGEDELAY_NEXTSUBFRAME 1 -#define MNG_CHANGEDELAY_DEFAULT 2 - -#define MNG_CHANGETIMOUT_NO 0 /* FRAM */ -#define MNG_CHANGETIMOUT_DETERMINISTIC_1 1 -#define MNG_CHANGETIMOUT_DETERMINISTIC_2 2 -#define MNG_CHANGETIMOUT_DECODER_1 3 -#define MNG_CHANGETIMOUT_DECODER_2 4 -#define MNG_CHANGETIMOUT_USER_1 5 -#define MNG_CHANGETIMOUT_USER_2 6 -#define MNG_CHANGETIMOUT_EXTERNAL_1 7 -#define MNG_CHANGETIMOUT_EXTERNAL_2 8 - -#define MNG_CHANGECLIPPING_NO 0 /* FRAM */ -#define MNG_CHANGECLIPPING_NEXTSUBFRAME 1 -#define MNG_CHANGECLIPPING_DEFAULT 2 - -#define MNG_CHANGESYNCID_NO 0 /* FRAM */ -#define MNG_CHANGESYNCID_NEXTSUBFRAME 1 -#define MNG_CHANGESYNCID_DEFAULT 2 - -#define MNG_CLIPPING_ABSOLUTE 0 /* CLIP */ -#define MNG_CLIPPING_RELATIVE 1 - -#define MNG_SHOWMODE_0 0 /* SHOW */ -#define MNG_SHOWMODE_1 1 -#define MNG_SHOWMODE_2 2 -#define MNG_SHOWMODE_3 3 -#define MNG_SHOWMODE_4 4 -#define MNG_SHOWMODE_5 5 -#define MNG_SHOWMODE_6 6 -#define MNG_SHOWMODE_7 7 - -#define MNG_TERMACTION_LASTFRAME 0 /* TERM */ -#define MNG_TERMACTION_CLEAR 1 -#define MNG_TERMACTION_FIRSTFRAME 2 -#define MNG_TERMACTION_REPEAT 3 - -#define MNG_ITERACTION_LASTFRAME 0 /* TERM */ -#define MNG_ITERACTION_CLEAR 1 -#define MNG_ITERACTION_FIRSTFRAME 2 - -#define MNG_SAVEOFFSET_4BYTE 4 /* SAVE */ -#define MNG_SAVEOFFSET_8BYTE 8 - -#define MNG_SAVEENTRY_SEGMENTFULL 0 /* SAVE */ -#define MNG_SAVEENTRY_SEGMENT 1 -#define MNG_SAVEENTRY_SUBFRAME 2 -#define MNG_SAVEENTRY_EXPORTEDIMAGE 3 - -#define MNG_PRIORITY_ABSOLUTE 0 /* fPRI */ -#define MNG_PRIORITY_RELATIVE 1 - -#ifdef MNG_INCLUDE_JNG -#define MNG_COLORTYPE_JPEGGRAY 8 /* JHDR */ -#define MNG_COLORTYPE_JPEGCOLOR 10 -#define MNG_COLORTYPE_JPEGGRAYA 12 -#define MNG_COLORTYPE_JPEGCOLORA 14 - -#define MNG_BITDEPTH_JPEG8 8 /* JHDR */ -#define MNG_BITDEPTH_JPEG12 12 -#define MNG_BITDEPTH_JPEG8AND12 20 - -#define MNG_COMPRESSION_BASELINEJPEG 8 /* JHDR */ - -#define MNG_INTERLACE_SEQUENTIAL 0 /* JHDR */ -#define MNG_INTERLACE_PROGRESSIVE 8 -#endif /* MNG_INCLUDE_JNG */ - -#define MNG_IMAGETYPE_UNKNOWN 0 /* DHDR */ -#define MNG_IMAGETYPE_PNG 1 -#define MNG_IMAGETYPE_JNG 2 - -#define MNG_DELTATYPE_REPLACE 0 /* DHDR */ -#define MNG_DELTATYPE_BLOCKPIXELADD 1 -#define MNG_DELTATYPE_BLOCKALPHAADD 2 -#define MNG_DELTATYPE_BLOCKCOLORADD 3 -#define MNG_DELTATYPE_BLOCKPIXELREPLACE 4 -#define MNG_DELTATYPE_BLOCKALPHAREPLACE 5 -#define MNG_DELTATYPE_BLOCKCOLORREPLACE 6 -#define MNG_DELTATYPE_NOCHANGE 7 - -#define MNG_FILLMETHOD_LEFTBITREPLICATE 0 /* PROM */ -#define MNG_FILLMETHOD_ZEROFILL 1 - -#define MNG_DELTATYPE_REPLACERGB 0 /* PPLT */ -#define MNG_DELTATYPE_DELTARGB 1 -#define MNG_DELTATYPE_REPLACEALPHA 2 -#define MNG_DELTATYPE_DELTAALPHA 3 -#define MNG_DELTATYPE_REPLACERGBA 4 -#define MNG_DELTATYPE_DELTARGBA 5 - -#define MNG_POLARITY_ONLY 0 /* DBYK */ -#define MNG_POLARITY_ALLBUT 1 - -#define MNG_EVENT_NONE 0 /* evNT */ -#define MNG_EVENT_MOUSEENTER 1 -#define MNG_EVENT_MOUSEMOVE 2 -#define MNG_EVENT_MOUSEEXIT 3 -#define MNG_EVENT_MOUSEDOWN 4 -#define MNG_EVENT_MOUSEUP 5 - -#define MNG_MASK_NONE 0 /* evNT */ -#define MNG_MASK_BOX 1 -#define MNG_MASK_OBJECT 2 -#define MNG_MASK_OBJECTIX 3 -#define MNG_MASK_BOXOBJECT 4 -#define MNG_MASK_BOXOBJECTIX 5 - -/* ************************************************************************** */ -/* * * */ -/* * Processtext callback types * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_TYPE_TEXT 0 -#define MNG_TYPE_ZTXT 1 -#define MNG_TYPE_ITXT 2 - -/* ************************************************************************** */ -/* * * */ -/* * CRC processing masks * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_CRC_INPUT 0x0000000f -#define MNG_CRC_INPUT_NONE 0x00000000 -#define MNG_CRC_INPUT_PRESENT 0x00000001 -#define MNG_CRC_OUTPUT 0x000000f0 -#define MNG_CRC_OUTPUT_NONE 0x00000000 -#define MNG_CRC_OUTPUT_GENERATE 0x00000020 -#define MNG_CRC_OUTPUT_DUMMY 0x00000040 -#define MNG_CRC_ANCILLARY 0x00000f00 -#define MNG_CRC_ANCILLARY_IGNORE 0x00000000 -#define MNG_CRC_ANCILLARY_DISCARD 0x00000100 -#define MNG_CRC_ANCILLARY_WARNING 0x00000200 -#define MNG_CRC_ANCILLARY_ERROR 0x00000300 -#define MNG_CRC_CRITICAL 0x0000f000 -#define MNG_CRC_CRITICAL_IGNORE 0x00000000 -#define MNG_CRC_CRITICAL_WARNING 0x00002000 -#define MNG_CRC_CRITICAL_ERROR 0x00003000 -#define MNG_CRC_DEFAULT 0x00002121 - -/* ************************************************************************** */ - -#ifdef __cplusplus -} -#endif - -#endif /* _libmng_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/plugins/AdvaImg/src/LibMNG/libmng_callback_xs.c b/plugins/AdvaImg/src/LibMNG/libmng_callback_xs.c deleted file mode 100644 index e8f1efeb66..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_callback_xs.c +++ /dev/null @@ -1,1239 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_callback_xs.c copyright (c) 2000-2004 G.Juyn * */ -/* * version : 1.0.9 * */ -/* * * */ -/* * purpose : callback get/set interface (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * comment : implementation of the callback get/set functions * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - fixed calling convention * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * * */ -/* * 0.5.2 - 05/31/2000 - G.Juyn * */ -/* * - fixed up punctuation (contribution by Tim Rowley) * */ -/* * 0.5.2 - 06/02/2000 - G.Juyn * */ -/* * - added getalphaline callback for RGB8_A8 canvasstyle * */ -/* * * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - added callbacks for SAVE/SEEK processing * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added callback to process non-critical unknown chunks * */ -/* * * */ -/* * 1.0.1 - 02/08/2001 - G.Juyn * */ -/* * - added MEND processing callback * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added processterm callback * */ -/* * * */ -/* * 1.0.6 - 07/07/2003 - G. R-P * */ -/* * - added SKIPCHUNK feature * */ -/* * * */ -/* * 1.0.7 - 03/10/2004 - G.R-P * */ -/* * - added conditionals around openstream/closestream * */ -/* * 1.0.7 - 03/19/2004 - G.R-P * */ -/* * - fixed typo (MNG_SKIPCHUNK_SAVE -> MNG_SKIPCHUNK_nEED * */ -/* * * */ -/* * 1.0.8 - 04/10/2004 - G.Juyn * */ -/* * - added data-push mechanisms for specialized decoders * */ -/* * * */ -/* * 1.0.9 - 09/18/2004 - G.R-P. * */ -/* * - added two SKIPCHUNK_TERM conditionals * */ -/* * 1.0.9 - 12/20/2004 - G.Juyn * */ -/* * - cleaned up macro-invocations (thanks to D. Airlie) * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Callback set functions * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_INTERNAL_MEMMNGMT -mng_retcode MNG_DECL mng_setcb_memalloc (mng_handle hHandle, - mng_memalloc fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_MEMALLOC, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fMemalloc = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_MEMALLOC, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INTERNAL_MEMMNGMT */ - -/* ************************************************************************** */ - -#ifndef MNG_INTERNAL_MEMMNGMT -mng_retcode MNG_DECL mng_setcb_memfree (mng_handle hHandle, - mng_memfree fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_MEMFREE, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fMemfree = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_MEMFREE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INTERNAL_MEMMNGMT */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_setcb_releasedata (mng_handle hHandle, - mng_releasedata fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_RELEASEDATA, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fReleasedata = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_RELEASEDATA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) -#ifndef MNG_NO_OPEN_CLOSE_STREAM -mng_retcode MNG_DECL mng_setcb_openstream (mng_handle hHandle, - mng_openstream fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_OPENSTREAM, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fOpenstream = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_OPENSTREAM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) -#ifndef MNG_NO_OPEN_CLOSE_STREAM -mng_retcode MNG_DECL mng_setcb_closestream (mng_handle hHandle, - mng_closestream fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_CLOSESTREAM, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fClosestream = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_CLOSESTREAM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_setcb_readdata (mng_handle hHandle, - mng_readdata fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_READDATA, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fReaddata = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_READDATA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_WRITE -mng_retcode MNG_DECL mng_setcb_writedata (mng_handle hHandle, - mng_writedata fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_WRITEDATA, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fWritedata = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_WRITEDATA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_setcb_errorproc (mng_handle hHandle, - mng_errorproc fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_ERRORPROC, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fErrorproc = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_ERRORPROC, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_TRACE -mng_retcode MNG_DECL mng_setcb_traceproc (mng_handle hHandle, - mng_traceproc fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_TRACEPROC, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fTraceproc = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_TRACEPROC, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_TRACE */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_setcb_processheader (mng_handle hHandle, - mng_processheader fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSHEADER, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessheader = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSHEADER, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -#ifndef MNG_SKIPCHUNK_tEXt -mng_retcode MNG_DECL mng_setcb_processtext (mng_handle hHandle, - mng_processtext fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSTEXT, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcesstext = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSTEXT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -#ifndef MNG_SKIPCHUNK_SAVE -mng_retcode MNG_DECL mng_setcb_processsave (mng_handle hHandle, - mng_processsave fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSSAVE, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcesssave = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSSAVE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -#ifndef MNG_SKIPCHUNK_SEEK -mng_retcode MNG_DECL mng_setcb_processseek (mng_handle hHandle, - mng_processseek fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSSEEK, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessseek = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSSEEK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -#ifndef MNG_SKIPCHUNK_nEED -mng_retcode MNG_DECL mng_setcb_processneed (mng_handle hHandle, - mng_processneed fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSNEED, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessneed = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSNEED, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_setcb_processmend (mng_handle hHandle, - mng_processmend fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSMEND, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessmend = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSMEND, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_setcb_processunknown (mng_handle hHandle, - mng_processunknown fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSUNKNOWN, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessunknown = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSUNKNOWN, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -#ifndef MNG_SKIPCHUNK_TERM -mng_retcode MNG_DECL mng_setcb_processterm (mng_handle hHandle, - mng_processterm fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSTERM, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessterm = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSTERM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_setcb_getcanvasline (mng_handle hHandle, - mng_getcanvasline fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETCANVASLINE, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fGetcanvasline = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETCANVASLINE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_setcb_getbkgdline (mng_handle hHandle, - mng_getbkgdline fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETBKGDLINE, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fGetbkgdline = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETBKGDLINE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_setcb_getalphaline (mng_handle hHandle, - mng_getalphaline fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETALPHALINE, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fGetalphaline = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETALPHALINE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_setcb_refresh (mng_handle hHandle, - mng_refresh fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_REFRESH, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fRefresh = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_REFRESH, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_setcb_gettickcount (mng_handle hHandle, - mng_gettickcount fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETTICKCOUNT, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fGettickcount = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETTICKCOUNT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_setcb_settimer (mng_handle hHandle, - mng_settimer fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_SETTIMER, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fSettimer = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_SETTIMER, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_retcode MNG_DECL mng_setcb_processgamma (mng_handle hHandle, - mng_processgamma fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSGAMA, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessgamma = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSGAMA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -#ifndef MNG_SKIPCHUNK_cHRM -mng_retcode MNG_DECL mng_setcb_processchroma (mng_handle hHandle, - mng_processchroma fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSCHROMA, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcesschroma = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSCHROMA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_retcode MNG_DECL mng_setcb_processsrgb (mng_handle hHandle, - mng_processsrgb fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSSRGB, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcesssrgb = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSSRGB, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -#ifndef MNG_SKIPCHUNK_iCCP -mng_retcode MNG_DECL mng_setcb_processiccp (mng_handle hHandle, - mng_processiccp fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSICCP, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessiccp = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSICCP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_retcode MNG_DECL mng_setcb_processarow (mng_handle hHandle, - mng_processarow fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSAROW, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessarow = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSAROW, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ -/* * * */ -/* * Callback get functions * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_INTERNAL_MEMMNGMT -mng_memalloc MNG_DECL mng_getcb_memalloc (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_MEMALLOC, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_MEMALLOC, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fMemalloc; -} -#endif /* MNG_INTERNAL_MEMMNGMT */ - -/* ************************************************************************** */ - -#ifndef MNG_INTERNAL_MEMMNGMT -mng_memfree MNG_DECL mng_getcb_memfree (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_MEMFREE, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_MEMFREE, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fMemfree; -} -#endif /* MNG_INTERNAL_MEMMNGMT */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_releasedata MNG_DECL mng_getcb_releasedata (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_RELEASEDATA, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_RELEASEDATA, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fReleasedata; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_readdata MNG_DECL mng_getcb_readdata (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_READDATA, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_READDATA, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fReaddata; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) -#ifndef MNG_NO_OPEN_CLOSE_STREAM -mng_openstream MNG_DECL mng_getcb_openstream (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_OPENSTREAM, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_OPENSTREAM, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fOpenstream; -} -#endif -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) -#ifndef MNG_NO_OPEN_CLOSE_STREAM -mng_closestream MNG_DECL mng_getcb_closestream (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_CLOSESTREAM, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_CLOSESTREAM, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fClosestream; -} -#endif -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_WRITE -mng_writedata MNG_DECL mng_getcb_writedata (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_WRITEDATA, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_WRITEDATA, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fWritedata; -} -#endif /* MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -mng_errorproc MNG_DECL mng_getcb_errorproc (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_ERRORPROC, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_ERRORPROC, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fErrorproc; -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_TRACE -mng_traceproc MNG_DECL mng_getcb_traceproc (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_TRACEPROC, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_TRACEPROC, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fTraceproc; -} -#endif /* MNG_SUPPORT_TRACE */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_processheader MNG_DECL mng_getcb_processheader (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSHEADER, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSHEADER, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fProcessheader; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -#ifndef MNG_SKIPCHUNK_tEXt -mng_processtext MNG_DECL mng_getcb_processtext (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSTEXT, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSTEXT, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fProcesstext; -} -#endif -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -#ifndef MNG_SKIPCHUNK_SAVE -mng_processsave MNG_DECL mng_getcb_processsave (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSSAVE, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSSAVE, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fProcesssave; -} -#endif -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -#ifndef MNG_SKIPCHUNK_SEEK -mng_processseek MNG_DECL mng_getcb_processseek (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSSEEK, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSSEEK, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fProcessseek; -} -#endif -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -#ifndef MNG_SKIPCHUNK_nEED -mng_processneed MNG_DECL mng_getcb_processneed (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSNEED, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSNEED, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fProcessneed; -} -#endif -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_processmend MNG_DECL mng_getcb_processmend (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSMEND, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSMEND, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fProcessmend; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_processunknown MNG_DECL mng_getcb_processunknown (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSUNKNOWN, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSUNKNOWN, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fProcessunknown; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -#ifndef MNG_SKIPCHUNK_TERM -mng_processterm MNG_DECL mng_getcb_processterm (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSTERM, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSTERM, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fProcessterm; -} -#endif -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_getcanvasline MNG_DECL mng_getcb_getcanvasline (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETCANVASLINE, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETCANVASLINE, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fGetcanvasline; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_getbkgdline MNG_DECL mng_getcb_getbkgdline (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETBKGDLINE, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETBKGDLINE, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fGetbkgdline; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_getalphaline MNG_DECL mng_getcb_getalphaline (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETALPHALINE, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETALPHALINE, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fGetalphaline; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_refresh MNG_DECL mng_getcb_refresh (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_REFRESH, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_REFRESH, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fRefresh; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_gettickcount MNG_DECL mng_getcb_gettickcount (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETTICKCOUNT, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETTICKCOUNT, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fGettickcount; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_settimer MNG_DECL mng_getcb_settimer (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_SETTIMER, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_SETTIMER, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fSettimer; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_processgamma MNG_DECL mng_getcb_processgamma (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSGAMMA, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSGAMMA, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fProcessgamma; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -#ifndef MNG_SKIPCHUNK_cHRM -mng_processchroma MNG_DECL mng_getcb_processchroma (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSCHROMA, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSCHROMA, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fProcesschroma; -} -#endif -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_processsrgb MNG_DECL mng_getcb_processsrgb (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSSRGB, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSSRGB, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fProcesssrgb; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -#ifndef MNG_SKIPCHUNK_iCCP -mng_processiccp MNG_DECL mng_getcb_processiccp (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSICCP, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSICCP, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fProcessiccp; -} -#endif -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_processarow MNG_DECL mng_getcb_processarow (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSAROW, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSAROW, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->fProcessarow; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - - - diff --git a/plugins/AdvaImg/src/LibMNG/libmng_chunk_descr.c b/plugins/AdvaImg/src/LibMNG/libmng_chunk_descr.c deleted file mode 100644 index 5a4bfa0381..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_chunk_descr.c +++ /dev/null @@ -1,6090 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_chunk_descr.c copyright (c) 2005-2007 G.Juyn * */ -/* * version : 1.0.10 * */ -/* * * */ -/* * purpose : Chunk descriptor functions (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * comment : implementation of the chunk- anf field-descriptor * */ -/* * routines * */ -/* * * */ -/* * changes : 1.0.9 - 12/06/2004 - G.Juyn * */ -/* * - added conditional MNG_OPTIMIZE_CHUNKREADER * */ -/* * 1.0.9 - 12/11/2004 - G.Juyn * */ -/* * - made all constants 'static' * */ -/* * 1.0.9 - 12/20/2004 - G.Juyn * */ -/* * - cleaned up macro-invocations (thanks to D. Airlie) * */ -/* * 1.0.9 - 01/17/2005 - G.Juyn * */ -/* * - fixed problem with global PLTE/tRNS * */ -/* * * */ -/* * 1.0.10 - 01/17/2005 - G.R-P. * */ -/* * - added typecast to appease the compiler * */ -/* * 1.0.10 - 04/08/2007 - G.Juyn * */ -/* * - added support for mPNG proposal * */ -/* * 1.0.10 - 04/12/2007 - G.Juyn * */ -/* * - added support for ANG proposal * */ -/* * * */ -/* ************************************************************************** */ - -#include /* needed for offsetof() */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_memory.h" -#include "libmng_objects.h" -#include "libmng_chunks.h" -#include "libmng_chunk_descr.h" -#include "libmng_object_prc.h" -#include "libmng_chunk_prc.h" -#include "libmng_chunk_io.h" -#include "libmng_display.h" - -#ifdef MNG_INCLUDE_ANG_PROPOSAL -#include "libmng_pixels.h" -#include "libmng_filter.h" -#endif - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_OPTIMIZE_CHUNKREADER -#if defined(MNG_INCLUDE_READ_PROCS) || defined(MNG_INCLUDE_WRITE_PROCS) - -/* ************************************************************************** */ -/* ************************************************************************** */ -/* PNG chunks */ - -MNG_LOCAL mng_field_descriptor mng_fields_ihdr [] = - { - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_NOHIGHBIT, - 1, 0, 4, 4, - offsetof(mng_ihdr, iWidth), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_NOHIGHBIT, - 1, 0, 4, 4, - offsetof(mng_ihdr, iHeight), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 1, 16, 1, 1, - offsetof(mng_ihdr, iBitdepth), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 6, 1, 1, - offsetof(mng_ihdr, iColortype), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 1, 1, - offsetof(mng_ihdr, iCompression), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 1, 1, - offsetof(mng_ihdr, iFilter), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 1, 1, 1, - offsetof(mng_ihdr, iInterlace), MNG_NULL, MNG_NULL} - }; - -/* ************************************************************************** */ - -MNG_LOCAL mng_field_descriptor mng_fields_plte [] = - { - {mng_debunk_plte, - MNG_NULL, - 0, 0, 0, 0, - MNG_NULL, MNG_NULL, MNG_NULL} - }; - -/* ************************************************************************** */ - -MNG_LOCAL mng_field_descriptor mng_fields_idat [] = - { - {MNG_NULL, - MNG_NULL, - 0, 0, 0, 0, - offsetof(mng_idat, pData), MNG_NULL, offsetof(mng_idat, iDatasize)} - }; - -/* ************************************************************************** */ - -MNG_LOCAL mng_field_descriptor mng_fields_trns [] = - { - {mng_debunk_trns, - MNG_NULL, - 0, 0, 0, 0, - MNG_NULL, MNG_NULL, MNG_NULL} - }; - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_gAMA -MNG_LOCAL mng_field_descriptor mng_fields_gama [] = - { - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_gama, iGamma), MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_cHRM -MNG_LOCAL mng_field_descriptor mng_fields_chrm [] = - { - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_chrm, iWhitepointx), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_chrm, iWhitepointy), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_chrm, iRedx), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_chrm, iRedy), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_chrm, iGreeny), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_chrm, iGreeny), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_chrm, iBluex), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_chrm, iBluey), MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_sRGB -MNG_LOCAL mng_field_descriptor mng_fields_srgb [] = - { - {MNG_NULL, - MNG_FIELD_INT, - 0, 4, 1, 1, - offsetof(mng_srgb, iRenderingintent), MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_iCCP -MNG_LOCAL mng_field_descriptor mng_fields_iccp [] = - { - {MNG_NULL, - MNG_FIELD_TERMINATOR, - 0, 0, 1, 79, - offsetof(mng_iccp, zName), MNG_NULL, offsetof(mng_iccp, iNamesize)}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 1, 1, - offsetof(mng_iccp, iCompression), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_DEFLATED, - 0, 0, 0, 0, - offsetof(mng_iccp, pProfile), MNG_NULL, offsetof(mng_iccp, iProfilesize)} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_tEXt -MNG_LOCAL mng_field_descriptor mng_fields_text [] = - { - {MNG_NULL, - MNG_FIELD_TERMINATOR, - 0, 0, 1, 79, - offsetof(mng_text, zKeyword), MNG_NULL, offsetof(mng_text, iKeywordsize)}, - {MNG_NULL, - MNG_NULL, - 0, 0, 0, 0, - offsetof(mng_text, zText), MNG_NULL, offsetof(mng_text, iTextsize)} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_zTXt -MNG_LOCAL mng_field_descriptor mng_fields_ztxt [] = - { - {MNG_NULL, - MNG_FIELD_TERMINATOR, - 0, 0, 1, 79, - offsetof(mng_ztxt, zKeyword), MNG_NULL, offsetof(mng_ztxt, iKeywordsize)}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 1, 1, - offsetof(mng_ztxt, iCompression), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_DEFLATED, - 0, 0, 0, 0, - offsetof(mng_ztxt, zText), MNG_NULL, offsetof(mng_ztxt, iTextsize)} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_iTXt -MNG_LOCAL mng_field_descriptor mng_fields_itxt [] = - { - {MNG_NULL, - MNG_FIELD_TERMINATOR, - 0, 0, 1, 79, - offsetof(mng_itxt, zKeyword), MNG_NULL, offsetof(mng_itxt, iKeywordsize)}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 1, 1, 1, - offsetof(mng_itxt, iCompressionflag), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 1, 1, - offsetof(mng_itxt, iCompressionmethod), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_TERMINATOR, - 0, 0, 0, 0, - offsetof(mng_itxt, zLanguage), MNG_NULL, offsetof(mng_itxt, iLanguagesize)}, - {MNG_NULL, - MNG_FIELD_TERMINATOR, - 0, 0, 0, 0, - offsetof(mng_itxt, zTranslation), MNG_NULL, offsetof(mng_itxt, iTranslationsize)}, - {mng_deflate_itxt, - MNG_NULL, - 0, 0, 0, 0, - MNG_NULL, MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_bKGD -MNG_LOCAL mng_field_descriptor mng_fields_bkgd [] = - { - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_PUTIMGTYPE, - 0, 0, 0, 0, - offsetof(mng_bkgd, iType), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE3, - 0, 0xFF, 1, 1, - offsetof(mng_bkgd, iIndex), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE0 | MNG_FIELD_IFIMGTYPE4, - 0, 0xFFFF, 2, 2, - offsetof(mng_bkgd, iGray), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE2 | MNG_FIELD_IFIMGTYPE6, - 0, 0xFFFF, 2, 2, - offsetof(mng_bkgd, iRed), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE2 | MNG_FIELD_IFIMGTYPE6, - 0, 0xFFFF, 2, 2, - offsetof(mng_bkgd, iGreen), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE2 | MNG_FIELD_IFIMGTYPE6, - 0, 0xFFFF, 2, 2, - offsetof(mng_bkgd, iBlue), MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_pHYs -MNG_LOCAL mng_field_descriptor mng_fields_phys [] = - { - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_phys, iSizex), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_phys, iSizey), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 1, 1, 1, - offsetof(mng_phys, iUnit), MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_sBIT -MNG_LOCAL mng_field_descriptor mng_fields_sbit [] = - { - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_PUTIMGTYPE, - 0, 0, 0, 0, - offsetof(mng_sbit, iType), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_IFIMGTYPES, - 0, 0xFF, 1, 1, - offsetof(mng_sbit, aBits[0]), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE2 | MNG_FIELD_IFIMGTYPE3 | MNG_FIELD_IFIMGTYPE4 | MNG_FIELD_IFIMGTYPE6, - 0, 0xFF, 1, 1, - offsetof(mng_sbit, aBits[1]), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE2 | MNG_FIELD_IFIMGTYPE3 | MNG_FIELD_IFIMGTYPE6, - 0, 0xFF, 1, 1, - offsetof(mng_sbit, aBits[2]), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE6, - 0, 0xFF, 1, 1, - offsetof(mng_sbit, aBits[3]), MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_sPLT -MNG_LOCAL mng_field_descriptor mng_fields_splt [] = - { - {MNG_NULL, - MNG_NULL, - 0, 0, 1, 79, - offsetof(mng_splt, zName), MNG_NULL, offsetof(mng_splt, iNamesize)}, - {MNG_NULL, - MNG_FIELD_INT, - 8, 16, 1, 1, - offsetof(mng_splt, iSampledepth), MNG_NULL, MNG_NULL}, - {mng_splt_entries, - MNG_NULL, - 0, 0, 0, 0, - MNG_NULL, MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_hIST -MNG_LOCAL mng_field_descriptor mng_fields_hist [] = - { - {mng_hist_entries, - MNG_NULL, - 0, 0, 0, 0, - MNG_NULL, MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_tIME -MNG_LOCAL mng_field_descriptor mng_fields_time [] = - { - {MNG_NULL, - MNG_FIELD_INT, - 0, 0xFFFF, 2, 2, - offsetof(mng_time, iYear), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 1, 12, 1, 1, - offsetof(mng_time, iMonth), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 1, 31, 1, 1, - offsetof(mng_time, iDay), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 24, 1, 1, - offsetof(mng_time, iHour), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 60, 1, 1, - offsetof(mng_time, iMinute), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 60, 1, 1, - offsetof(mng_time, iSecond), MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ -/* ************************************************************************** */ -/* JNG chunks */ - -#ifdef MNG_INCLUDE_JNG -MNG_LOCAL mng_field_descriptor mng_fields_jhdr [] = - { - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_NOHIGHBIT, - 1, 0, 4, 4, - offsetof(mng_jhdr, iWidth), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_NOHIGHBIT, - 1, 0, 4, 4, - offsetof(mng_jhdr, iHeight), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 8, 16, 1, 1, - offsetof(mng_jhdr, iColortype), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 8, 20, 1, 1, - offsetof(mng_jhdr, iImagesampledepth), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 8, 8, 1, 1, - offsetof(mng_jhdr, iImagecompression), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 8, 1, 1, - offsetof(mng_jhdr, iImageinterlace), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 16, 1, 1, - offsetof(mng_jhdr, iAlphasampledepth), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 8, 1, 1, - offsetof(mng_jhdr, iAlphacompression), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 1, 1, - offsetof(mng_jhdr, iAlphafilter), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 1, 1, 1, - offsetof(mng_jhdr, iAlphainterlace), MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -#define mng_fields_jdaa mng_fields_idat -#define mng_fields_jdat mng_fields_idat -#endif - -/* ************************************************************************** */ -/* ************************************************************************** */ -/* MNG chunks */ - -MNG_LOCAL mng_field_descriptor mng_fields_mhdr [] = - { - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_mhdr, iWidth), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_mhdr, iHeight), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_mhdr, iTicks), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_mhdr, iLayercount), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_mhdr, iFramecount), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_mhdr, iPlaytime), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_mhdr, iSimplicity), MNG_NULL, MNG_NULL} - }; - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_LOOP -MNG_LOCAL mng_field_descriptor mng_fields_loop [] = - { - {mng_debunk_loop, - MNG_NULL, - 0, 0, 0, 0, - MNG_NULL, MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_LOOP -MNG_LOCAL mng_field_descriptor mng_fields_endl [] = - { - {MNG_NULL, - MNG_FIELD_INT, - 0, 0xFF, 1, 1, - offsetof(mng_endl, iLevel), MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_DEFI -MNG_LOCAL mng_field_descriptor mng_fields_defi [] = - { - {MNG_NULL, - MNG_FIELD_INT, - 0, 0xFFFF, 2, 2, - offsetof(mng_defi, iObjectid), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL, - 0, 0xFF, 1, 1, - offsetof(mng_defi, iDonotshow), offsetof(mng_defi, bHasdonotshow), MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL, - 0, 0xFF, 1, 1, - offsetof(mng_defi, iConcrete), offsetof(mng_defi, bHasconcrete), MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1, - 0, 0, 4, 4, - offsetof(mng_defi, iXlocation), offsetof(mng_defi, bHasloca), MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1, - 0, 0, 4, 4, - offsetof(mng_defi, iYlocation), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP2, - 0, 0, 4, 4, - offsetof(mng_defi, iLeftcb), offsetof(mng_defi, bHasclip), MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP2, - 0, 0, 4, 4, - offsetof(mng_defi, iRightcb), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP2, - 0, 0, 4, 4, - offsetof(mng_defi, iTopcb), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP2, - 0, 0, 4, 4, - offsetof(mng_defi, iBottomcb), MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_BASI -MNG_LOCAL mng_field_descriptor mng_fields_basi [] = - { - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_basi, iWidth), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_basi, iHeight), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 1, 16, 1, 1, - offsetof(mng_basi, iBitdepth), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 6, 1, 1, - offsetof(mng_basi, iColortype), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 1, 1, - offsetof(mng_basi, iCompression), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 1, 1, - offsetof(mng_basi, iFilter), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 1, 1, 1, - offsetof(mng_basi, iInterlace), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1, - 0, 0xFFFF, 2, 2, - offsetof(mng_basi, iRed), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1, - 0, 0xFFFF, 2, 2, - offsetof(mng_basi, iGreen), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1, - 0, 0xFFFF, 2, 2, - offsetof(mng_basi, iBlue), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL, - 0, 0xFFFF, 2, 2, - offsetof(mng_basi, iAlpha), offsetof(mng_basi, bHasalpha), MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL, - 0, 1, 1, 1, - offsetof(mng_basi, iViewable), MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_CLON -MNG_LOCAL mng_field_descriptor mng_fields_clon [] = - { - {MNG_NULL, - MNG_FIELD_INT, - 0, 0xFFFF, 2, 2, - offsetof(mng_clon, iSourceid), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0xFFFF, 2, 2, - offsetof(mng_clon, iCloneid), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL, - 0, 2, 1, 1, - offsetof(mng_clon, iClonetype), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL, - 0, 1, 1, 1, - offsetof(mng_clon, iDonotshow), offsetof(mng_clon, bHasdonotshow), MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL, - 0, 1, 1, 1, - offsetof(mng_clon, iConcrete), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1, - 0, 2, 1, 1, - offsetof(mng_clon, iLocationtype), offsetof(mng_clon, bHasloca), MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1, - 0, 0, 4, 4, - offsetof(mng_clon, iLocationx), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1, - 0, 0, 4, 4, - offsetof(mng_clon, iLocationy), MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_PAST -MNG_LOCAL mng_field_descriptor mng_fields_past [] = - { - {mng_debunk_past, - MNG_NULL, - 0, 0, 0, 0, - MNG_NULL, MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_DISC -MNG_LOCAL mng_field_descriptor mng_fields_disc [] = - { - {mng_disc_entries, - MNG_NULL, - 0, 0, 0, 0, - MNG_NULL, MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_BACK -MNG_LOCAL mng_field_descriptor mng_fields_back [] = - { - {MNG_NULL, - MNG_FIELD_INT, - 0, 0xFFFF, 2, 2, - offsetof(mng_back, iRed), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0xFFFF, 2, 2, - offsetof(mng_back, iGreen), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0xFFFF, 2, 2, - offsetof(mng_back, iBlue), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL, - 0, 3, 1, 1, - offsetof(mng_back, iMandatory), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL, - 0, 0xFFFF, 2, 2, - offsetof(mng_back, iImageid), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL, - 0, 1, 1, 1, - offsetof(mng_back, iTile), MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_FRAM -MNG_LOCAL mng_field_descriptor mng_fields_fram [] = - { - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL, - 0, 4, 1, 1, - offsetof(mng_fram, iMode), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_TERMINATOR | MNG_FIELD_OPTIONAL, - 0, 0, 1, 79, - offsetof(mng_fram, zName), MNG_NULL, offsetof(mng_fram, iNamesize)}, - {mng_fram_remainder, - MNG_FIELD_OPTIONAL, - 0, 0, 0, 0, - MNG_NULL, MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_MOVE -MNG_LOCAL mng_field_descriptor mng_fields_move [] = - { - {MNG_NULL, - MNG_FIELD_INT, - 0, 0xFFFF, 2, 2, - offsetof(mng_move, iFirstid), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0xFFFF, 2, 2, - offsetof(mng_move, iLastid), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 1, 1, 1, - offsetof(mng_move, iMovetype), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_move, iMovex), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_move, iMovey), MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_CLIP -MNG_LOCAL mng_field_descriptor mng_fields_clip [] = - { - {MNG_NULL, - MNG_FIELD_INT, - 0, 0xFFFF, 2, 2, - offsetof(mng_clip, iFirstid), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0xFFFF, 2, 2, - offsetof(mng_clip, iLastid), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 1, 1, 1, - offsetof(mng_clip, iCliptype), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_clip, iClipl), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_clip, iClipr), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_clip, iClipt), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_clip, iClipb), MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SHOW -MNG_LOCAL mng_field_descriptor mng_fields_show [] = - { - {MNG_NULL, - MNG_FIELD_INT, - 1, 0xFFFF, 2, 2, - offsetof(mng_show, iFirstid), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL, - 1, 0xFFFF, 2, 2, - offsetof(mng_show, iLastid), offsetof(mng_show, bHaslastid), MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL, - 0, 7, 1, 1, - offsetof(mng_show, iMode), MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_TERM -MNG_LOCAL mng_field_descriptor mng_fields_term [] = - { - {MNG_NULL, - MNG_FIELD_INT, - 0, 3, 1, 1, - offsetof(mng_term, iTermaction), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1, - 0, 2, 1, 1, - offsetof(mng_term, iIteraction), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1, - 0, 0, 4, 4, - offsetof(mng_term, iDelay), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1, - 0, 0, 4, 4, - offsetof(mng_term, iItermax), MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SAVE -MNG_LOCAL mng_field_descriptor mng_fields_save [] = - { - {mng_save_entries, - MNG_NULL, - 0, 0, 0, 0, - MNG_NULL, MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SEEK -MNG_LOCAL mng_field_descriptor mng_fields_seek [] = - { - {MNG_NULL, - MNG_NULL, - 0, 0, 1, 79, - offsetof(mng_seek, zName), MNG_NULL, offsetof(mng_seek, iNamesize)} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_eXPI -MNG_LOCAL mng_field_descriptor mng_fields_expi [] = - { - {MNG_NULL, - MNG_FIELD_INT, - 0, 0xFFFF, 2, 2, - offsetof(mng_expi, iSnapshotid), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_NULL, - 0, 0, 1, 79, - offsetof(mng_expi, zName), MNG_NULL, offsetof(mng_expi, iNamesize)} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_fPRI -MNG_LOCAL mng_field_descriptor mng_fields_fpri [] = - { - {MNG_NULL, - MNG_FIELD_INT, - 0, 1, 1, 1, - offsetof(mng_fpri, iDeltatype), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0xFF, 1, 1, - offsetof(mng_fpri, iPriority), MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_nEED -MNG_LOCAL mng_field_descriptor mng_fields_need [] = - { - {MNG_NULL, - MNG_NULL, - 0, 0, 1, 0, - offsetof(mng_need, zKeywords), MNG_NULL, offsetof(mng_need, iKeywordssize)} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_pHYg -#define mng_fields_phyg mng_fields_phys -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -MNG_LOCAL mng_field_descriptor mng_fields_dhdr [] = - { - {MNG_NULL, - MNG_FIELD_INT, - 0, 0xFFFF, 2, 2, - offsetof(mng_dhdr, iObjectid), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 2, 1, 1, - offsetof(mng_dhdr, iImagetype), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 7, 1, 1, - offsetof(mng_dhdr, iDeltatype), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1, - 0, 0, 4, 4, - offsetof(mng_dhdr, iBlockwidth), offsetof(mng_dhdr, bHasblocksize), MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1, - 0, 0, 4, 4, - offsetof(mng_dhdr, iBlockheight), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP2, - 0, 0, 4, 4, - offsetof(mng_dhdr, iBlockx), offsetof(mng_dhdr, bHasblockloc), MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP2, - 0, 0, 4, 4, - offsetof(mng_dhdr, iBlocky), MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -MNG_LOCAL mng_field_descriptor mng_fields_prom [] = - { - {MNG_NULL, - MNG_FIELD_INT, - 0, 14, 1, 1, - offsetof(mng_prom, iColortype), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 16, 1, 1, - offsetof(mng_prom, iSampledepth), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 1, 1, 1, - offsetof(mng_prom, iFilltype), MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -MNG_LOCAL mng_field_descriptor mng_fields_pplt [] = - { - {MNG_NULL, - MNG_FIELD_INT, - 0, 5, 1, 1, - offsetof(mng_pplt, iDeltatype), MNG_NULL, MNG_NULL}, - {mng_pplt_entries, - MNG_NULL, - 0, 0, 0, 0, - MNG_NULL, MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -MNG_LOCAL mng_field_descriptor mng_fields_drop [] = - { - {mng_drop_entries, - MNG_NULL, - 0, 0, 0, 0, - MNG_NULL, MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_DBYK -MNG_LOCAL mng_field_descriptor mng_fields_dbyk [] = - { - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_dbyk, iChunkname), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 1, 1, 1, - offsetof(mng_dbyk, iPolarity), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_NULL, - 0, 0, 1, 0, - offsetof(mng_dbyk, zKeywords), MNG_NULL, offsetof(mng_dbyk, iKeywordssize)} - }; -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_ORDR -MNG_LOCAL mng_field_descriptor mng_fields_ordr [] = - { - {mng_drop_entries, - MNG_NULL, - 0, 0, 0, 0, - MNG_NULL, MNG_NULL, MNG_NULL} - }; -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_MAGN -MNG_LOCAL mng_field_descriptor mng_fields_magn [] = - { - {mng_debunk_magn, - MNG_NULL, - 0, 0, 0, 0, - MNG_NULL, MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_MPNG_PROPOSAL -MNG_LOCAL mng_field_descriptor mng_fields_mpng [] = - { - {MNG_NULL, - MNG_FIELD_INT, - 1, 0, 4, 4, - offsetof(mng_mpng, iFramewidth), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 1, 0, 4, 4, - offsetof(mng_mpng, iFrameheight), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0xFFFF, 2, 2, - offsetof(mng_mpng, iNumplays), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 1, 0xFFFF, 2, 2, - offsetof(mng_mpng, iTickspersec), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 1, 1, - offsetof(mng_mpng, iCompressionmethod), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_DEFLATED, - 0, 0, 1, 0, - offsetof(mng_mpng, pFrames), MNG_NULL, offsetof(mng_mpng, iFramessize)} - }; -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ANG_PROPOSAL -MNG_LOCAL mng_field_descriptor mng_fields_ahdr [] = - { - {MNG_NULL, - MNG_FIELD_INT, - 1, 0, 4, 4, - offsetof(mng_ahdr, iNumframes), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_ahdr, iTickspersec), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 0, 4, 4, - offsetof(mng_ahdr, iNumplays), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 1, 0, 4, 4, - offsetof(mng_ahdr, iTilewidth), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 1, 0, 4, 4, - offsetof(mng_ahdr, iTileheight), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 1, 1, 1, - offsetof(mng_ahdr, iInterlace), MNG_NULL, MNG_NULL}, - {MNG_NULL, - MNG_FIELD_INT, - 0, 1, 1, 1, - offsetof(mng_ahdr, iStillused), MNG_NULL, MNG_NULL} - }; - -MNG_LOCAL mng_field_descriptor mng_fields_adat [] = - { - {mng_adat_tiles, - MNG_NULL, - 0, 0, 0, 0, - MNG_NULL, MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_evNT -MNG_LOCAL mng_field_descriptor mng_fields_evnt [] = - { - {mng_evnt_entries, - MNG_NULL, - 0, 0, 0, 0, - MNG_NULL, MNG_NULL, MNG_NULL} - }; -#endif - -/* ************************************************************************** */ - -MNG_LOCAL mng_field_descriptor mng_fields_unknown [] = - { - {MNG_NULL, - MNG_NULL, - 0, 0, 1, 0, - offsetof(mng_unknown_chunk, pData), MNG_NULL, offsetof(mng_unknown_chunk, iDatasize)} - }; - -/* ************************************************************************** */ -/* ************************************************************************** */ -/* PNG chunks */ - -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_ihdr = - {mng_it_png, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_ihdr, - mng_fields_ihdr, (sizeof(mng_fields_ihdr) / sizeof(mng_field_descriptor)), - MNG_DESCR_GLOBAL, - MNG_NULL, - MNG_DESCR_NOIHDR | MNG_DESCR_NOJHDR | MNG_DESCR_NOBASI | MNG_DESCR_NOIDAT | MNG_DESCR_NOPLTE}; - -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_plte = - {mng_it_png, mng_create_none, 0, offsetof(mng_plte, bEmpty), - MNG_NULL, MNG_NULL, mng_special_plte, - mng_fields_plte, (sizeof(mng_fields_plte) / sizeof(mng_field_descriptor)), - MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED, - MNG_DESCR_GenHDR, - MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA}; - -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_idat = - {mng_it_png, mng_create_none, 0, offsetof(mng_idat, bEmpty), - MNG_NULL, MNG_NULL, mng_special_idat, - mng_fields_idat, (sizeof(mng_fields_idat) / sizeof(mng_field_descriptor)), - MNG_DESCR_EMPTYEMBED, - MNG_DESCR_GenHDR, - MNG_DESCR_NOJSEP}; - -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_iend = - {mng_it_png, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_iend, - MNG_NULL, 0, - MNG_DESCR_EMPTY | MNG_DESCR_EMPTYEMBED, - MNG_DESCR_GenHDR, - MNG_NULL}; - -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_trns = - {mng_it_png, mng_create_none, 0, offsetof(mng_trns, bEmpty), - MNG_NULL, MNG_NULL, mng_special_trns, - mng_fields_trns, (sizeof(mng_fields_trns) / sizeof(mng_field_descriptor)), - MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED, - MNG_DESCR_GenHDR, - MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA}; - -#ifndef MNG_SKIPCHUNK_gAMA -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_gama = - {mng_it_png, mng_create_none, 0, offsetof(mng_gama, bEmpty), - MNG_NULL, MNG_NULL, mng_special_gama, - mng_fields_gama, (sizeof(mng_fields_gama) / sizeof(mng_field_descriptor)), - MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED | MNG_DESCR_EMPTYGLOBAL, - MNG_DESCR_GenHDR, - MNG_DESCR_NOPLTE | MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA}; -#endif - -#ifndef MNG_SKIPCHUNK_cHRM -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_chrm = - {mng_it_png, mng_create_none, 0, offsetof(mng_chrm, bEmpty), - MNG_NULL, MNG_NULL, mng_special_chrm, - mng_fields_chrm, (sizeof(mng_fields_chrm) / sizeof(mng_field_descriptor)), - MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED | MNG_DESCR_EMPTYGLOBAL, - MNG_DESCR_GenHDR, - MNG_DESCR_NOPLTE | MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA}; -#endif - -#ifndef MNG_SKIPCHUNK_sRGB -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_srgb = - {mng_it_png, mng_create_none, 0, offsetof(mng_srgb, bEmpty), - MNG_NULL, MNG_NULL, mng_special_srgb, - mng_fields_srgb, (sizeof(mng_fields_srgb) / sizeof(mng_field_descriptor)), - MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED | MNG_DESCR_EMPTYGLOBAL, - MNG_DESCR_GenHDR, - MNG_DESCR_NOPLTE | MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA}; -#endif - -#ifndef MNG_SKIPCHUNK_iCCP -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_iccp = - {mng_it_png, mng_create_none, 0, offsetof(mng_iccp, bEmpty), - MNG_NULL, MNG_NULL, mng_special_iccp, - mng_fields_iccp, (sizeof(mng_fields_iccp) / sizeof(mng_field_descriptor)), - MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED | MNG_DESCR_EMPTYGLOBAL, - MNG_DESCR_GenHDR, - MNG_DESCR_NOPLTE | MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA}; -#endif - -#ifndef MNG_SKIPCHUNK_tEXt -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_text = - {mng_it_png, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_text, - mng_fields_text, (sizeof(mng_fields_text) / sizeof(mng_field_descriptor)), - MNG_DESCR_GLOBAL, - MNG_DESCR_GenHDR, - MNG_NULL}; -#endif - -#ifndef MNG_SKIPCHUNK_zTXt -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_ztxt = - {mng_it_png, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_ztxt, - mng_fields_ztxt, (sizeof(mng_fields_ztxt) / sizeof(mng_field_descriptor)), - MNG_DESCR_GLOBAL, - MNG_DESCR_GenHDR, - MNG_NULL}; -#endif - -#ifndef MNG_SKIPCHUNK_iTXt -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_itxt = - {mng_it_png, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_itxt, - mng_fields_itxt, (sizeof(mng_fields_itxt) / sizeof(mng_field_descriptor)), - MNG_DESCR_GLOBAL, - MNG_DESCR_GenHDR, - MNG_NULL}; -#endif - -#ifndef MNG_SKIPCHUNK_bKGD -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_bkgd = - {mng_it_png, mng_create_none, 0, offsetof(mng_bkgd, bEmpty), - MNG_NULL, MNG_NULL, mng_special_bkgd, - mng_fields_bkgd, (sizeof(mng_fields_bkgd) / sizeof(mng_field_descriptor)), - MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED | MNG_DESCR_EMPTYGLOBAL, - MNG_DESCR_GenHDR, - MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA}; -#endif - -#ifndef MNG_SKIPCHUNK_pHYs -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_phys = - {mng_it_png, mng_create_none, 0, offsetof(mng_phys, bEmpty), - MNG_NULL, MNG_NULL, mng_special_phys, - mng_fields_phys, (sizeof(mng_fields_phys) / sizeof(mng_field_descriptor)), - MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED | MNG_DESCR_EMPTYGLOBAL, - MNG_DESCR_GenHDR, - MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA}; -#endif - -#ifndef MNG_SKIPCHUNK_sBIT -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_sbit = - {mng_it_png, mng_create_none, 0, offsetof(mng_sbit, bEmpty), - MNG_NULL, MNG_NULL, mng_special_sbit, - mng_fields_sbit, (sizeof(mng_fields_sbit) / sizeof(mng_field_descriptor)), - MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED | MNG_DESCR_EMPTYGLOBAL, - MNG_DESCR_GenHDR, - MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA}; -#endif - -#ifndef MNG_SKIPCHUNK_sPLT -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_splt = - {mng_it_png, mng_create_none, 0, offsetof(mng_splt, bEmpty), - MNG_NULL, MNG_NULL, mng_special_splt, - mng_fields_splt, (sizeof(mng_fields_splt) / sizeof(mng_field_descriptor)), - MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED | MNG_DESCR_EMPTYGLOBAL, - MNG_DESCR_GenHDR, - MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA}; -#endif - -#ifndef MNG_SKIPCHUNK_hIST -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_hist = - {mng_it_png, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_hist, - mng_fields_hist, (sizeof(mng_fields_hist) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_GenHDR | MNG_DESCR_PLTE, - MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA}; -#endif - -#ifndef MNG_SKIPCHUNK_tIME -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_time = - {mng_it_png, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_time, - mng_fields_time, (sizeof(mng_fields_time) / sizeof(mng_field_descriptor)), - MNG_DESCR_GLOBAL, - MNG_DESCR_GenHDR, - MNG_NULL}; -#endif - -/* ************************************************************************** */ -/* JNG chunks */ - -#ifdef MNG_INCLUDE_JNG -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_jhdr = - {mng_it_jng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_jhdr, - mng_fields_jhdr, (sizeof(mng_fields_jhdr) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_NULL, - MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR}; -#endif - -#ifdef MNG_INCLUDE_JNG -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_jdaa = - {mng_it_jng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_jdaa, - mng_fields_jdaa, (sizeof(mng_fields_jdaa) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_JngHDR, - MNG_DESCR_NOJSEP}; -#endif - -#ifdef MNG_INCLUDE_JNG -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_jdat = - {mng_it_jng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_jdat, - mng_fields_jdat, (sizeof(mng_fields_jdat) / sizeof(mng_field_descriptor)), - MNG_DESCR_EMPTYEMBED, - MNG_DESCR_JngHDR, - MNG_NULL}; -#endif - -#ifdef MNG_INCLUDE_JNG -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_jsep = - {mng_it_jng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_jsep, - MNG_NULL, 0, - MNG_DESCR_EMPTY | MNG_DESCR_EMPTYEMBED, - MNG_DESCR_JngHDR, - MNG_DESCR_NOJSEP}; -#endif - -/* ************************************************************************** */ -/* MNG chunks */ - -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_mhdr = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_mhdr, - mng_fields_mhdr, (sizeof(mng_fields_mhdr) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_NULL, - MNG_DESCR_NOMHDR | MNG_DESCR_NOIHDR | MNG_DESCR_NOJHDR}; - -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_mend = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_mend, - MNG_NULL, 0, - MNG_DESCR_EMPTY | MNG_DESCR_EMPTYGLOBAL, - MNG_DESCR_MHDR, - MNG_NULL}; - -#ifndef MNG_SKIPCHUNK_LOOP -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_loop = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_loop, - mng_fields_loop, (sizeof(mng_fields_loop) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_MHDR, - MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR}; - -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_endl = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_endl, - mng_fields_endl, (sizeof(mng_fields_endl) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_MHDR, - MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR}; -#endif - -#ifndef MNG_SKIPCHUNK_DEFI -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_defi = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_defi, - mng_fields_defi, (sizeof(mng_fields_defi) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_MHDR, - MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR}; -#endif - -#ifndef MNG_SKIPCHUNK_BASI -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_basi = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_basi, - mng_fields_basi, (sizeof(mng_fields_basi) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_MHDR, - MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR}; -#endif - -#ifndef MNG_SKIPCHUNK_CLON -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_clon = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_clon, - mng_fields_clon, (sizeof(mng_fields_clon) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_MHDR, - MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR}; -#endif - -#ifndef MNG_SKIPCHUNK_PAST -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_past = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_past, - mng_fields_past, (sizeof(mng_fields_past) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_MHDR, - MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR}; -#endif - -#ifndef MNG_SKIPCHUNK_DISC -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_disc = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_disc, - mng_fields_disc, (sizeof(mng_fields_disc) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_MHDR, - MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR}; -#endif - -#ifndef MNG_SKIPCHUNK_BACK -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_back = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_back, - mng_fields_back, (sizeof(mng_fields_back) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_MHDR, - MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR}; -#endif - -#ifndef MNG_SKIPCHUNK_FRAM -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_fram = - {mng_it_mng, mng_create_none, 0, offsetof(mng_fram, bEmpty), - MNG_NULL, MNG_NULL, mng_special_fram, - mng_fields_fram, (sizeof(mng_fields_fram) / sizeof(mng_field_descriptor)), - MNG_DESCR_EMPTY | MNG_DESCR_EMPTYGLOBAL, - MNG_DESCR_MHDR, - MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR}; -#endif - -#ifndef MNG_SKIPCHUNK_MOVE -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_move = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_move, - mng_fields_move, (sizeof(mng_fields_move) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_MHDR, - MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR}; -#endif - -#ifndef MNG_SKIPCHUNK_CLIP -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_clip = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_clip, - mng_fields_clip, (sizeof(mng_fields_clip) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_MHDR, - MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR}; -#endif - -#ifndef MNG_SKIPCHUNK_SHOW -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_show = - {mng_it_mng, mng_create_none, 0, offsetof(mng_show, bEmpty), - MNG_NULL, MNG_NULL, mng_special_show, - mng_fields_show, (sizeof(mng_fields_show) / sizeof(mng_field_descriptor)), - MNG_DESCR_EMPTY | MNG_DESCR_EMPTYGLOBAL, - MNG_DESCR_MHDR, - MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR}; -#endif - -#ifndef MNG_SKIPCHUNK_TERM -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_term = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_term, - mng_fields_term, (sizeof(mng_fields_term) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_MHDR, - MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR | MNG_DESCR_NOTERM | MNG_DESCR_NOLOOP}; -#endif - -#ifndef MNG_SKIPCHUNK_SAVE -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_save = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_save, - mng_fields_save, (sizeof(mng_fields_save) / sizeof(mng_field_descriptor)), - MNG_DESCR_EMPTY | MNG_DESCR_EMPTYGLOBAL, - MNG_DESCR_MHDR, - MNG_DESCR_NOSAVE | MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR}; -#endif - -#ifndef MNG_SKIPCHUNK_SEEK -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_seek = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_seek, - mng_fields_seek, (sizeof(mng_fields_seek) / sizeof(mng_field_descriptor)), - MNG_DESCR_EMPTY | MNG_DESCR_EMPTYGLOBAL, - MNG_DESCR_MHDR | MNG_DESCR_SAVE, - MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR}; -#endif - -#ifndef MNG_SKIPCHUNK_eXPI -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_expi = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_expi, - mng_fields_expi, (sizeof(mng_fields_expi) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_MHDR, - MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR}; -#endif - -#ifndef MNG_SKIPCHUNK_fPRI -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_fpri = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_fpri, - mng_fields_fpri, (sizeof(mng_fields_fpri) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_MHDR, - MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR}; -#endif - -#ifndef MNG_SKIPCHUNK_nEED -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_need = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_need, - mng_fields_need, (sizeof(mng_fields_need) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_MHDR, - MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR}; -#endif - -#ifndef MNG_SKIPCHUNK_pHYg -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_phyg = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_phyg, - mng_fields_phyg, (sizeof(mng_fields_phyg) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_MHDR, - MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR}; -#endif - -#ifndef MNG_NO_DELTA_PNG -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_dhdr = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_dhdr, - mng_fields_dhdr, (sizeof(mng_fields_dhdr) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_MHDR, - MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR}; -#endif - -#ifndef MNG_NO_DELTA_PNG -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_prom = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_prom, - mng_fields_prom, (sizeof(mng_fields_prom) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_MHDR | MNG_DESCR_DHDR, - MNG_NULL}; -#endif - -#ifndef MNG_NO_DELTA_PNG -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_ipng = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_ipng, - MNG_NULL, 0, - MNG_DESCR_EMPTY | MNG_DESCR_EMPTYEMBED, - MNG_DESCR_MHDR | MNG_DESCR_DHDR, - MNG_NULL}; -#endif - -#ifndef MNG_NO_DELTA_PNG -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_pplt = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_pplt, - mng_fields_pplt, (sizeof(mng_fields_pplt) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_MHDR | MNG_DESCR_DHDR, - MNG_NULL}; -#endif - -#ifndef MNG_NO_DELTA_PNG -#ifdef MNG_INCLUDE_JNG -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_ijng = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_ijng, - MNG_NULL, 0, - MNG_DESCR_EMPTY | MNG_DESCR_EMPTYEMBED, - MNG_DESCR_MHDR | MNG_DESCR_DHDR, - MNG_NULL}; -#endif -#endif - -#ifndef MNG_NO_DELTA_PNG -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_drop = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_drop, - mng_fields_drop, (sizeof(mng_fields_drop) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_MHDR | MNG_DESCR_DHDR, - MNG_NULL}; -#endif - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_DBYK -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_dbyk = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_dbyk, - mng_fields_dbyk, (sizeof(mng_fields_dbyk) / sizeof(mng_field_descriptor)), - MNG_DESCR_EMPTY | MNG_DESCR_EMPTYEMBED, - MNG_DESCR_MHDR | MNG_DESCR_DHDR, - MNG_NULL}; -#endif -#endif - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_ORDR -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_ordr = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_ordr, - mng_fields_ordr, (sizeof(mng_fields_ordr) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_MHDR | MNG_DESCR_DHDR, - MNG_NULL}; -#endif -#endif - -#ifndef MNG_SKIPCHUNK_MAGN -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_magn = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_magn, - mng_fields_magn, (sizeof(mng_fields_magn) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_MHDR, - MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR}; -#endif - -#ifndef MNG_SKIPCHUNK_evNT -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_evnt = - {mng_it_mng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_evnt, - mng_fields_evnt, (sizeof(mng_fields_evnt) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_MHDR, - MNG_DESCR_NOSAVE}; -#endif - -#ifdef MNG_INCLUDE_MPNG_PROPOSAL -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_mpng = - {mng_it_mpng, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_mpng, - mng_fields_mpng, (sizeof(mng_fields_mpng) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_NULL, - MNG_DESCR_NOMHDR | MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT}; -#endif - -#ifdef MNG_INCLUDE_ANG_PROPOSAL -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_ahdr = - {mng_it_ang, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_ahdr, - mng_fields_ahdr, (sizeof(mng_fields_ahdr) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_IHDR, - MNG_DESCR_NOMHDR | MNG_DESCR_NOJHDR | MNG_DESCR_NOIDAT}; - -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_adat = - {mng_it_ang, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_adat, - mng_fields_adat, (sizeof(mng_fields_adat) / sizeof(mng_field_descriptor)), - MNG_NULL, - MNG_DESCR_IHDR, - MNG_DESCR_NOMHDR | MNG_DESCR_NOJHDR}; -#endif - -/* ************************************************************************** */ -/* ************************************************************************** */ -/* the good ol' unknown babe */ - -MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_unknown = - {mng_it_png, mng_create_none, 0, 0, - MNG_NULL, MNG_NULL, mng_special_unknown, - mng_fields_unknown, (sizeof(mng_fields_unknown) / sizeof(mng_field_descriptor)), - MNG_DESCR_EMPTY | MNG_DESCR_EMPTYEMBED, - MNG_NULL, - MNG_NULL}; - -/* ************************************************************************** */ -/* ************************************************************************** */ - -MNG_LOCAL mng_chunk_header mng_chunk_unknown = - {MNG_UINT_HUH, mng_init_general, mng_free_unknown, - mng_read_general, mng_write_unknown, mng_assign_unknown, - 0, 0, sizeof(mng_unknown_chunk), &mng_chunk_descr_unknown}; - -/* ************************************************************************** */ - - /* the table-idea & binary search code was adapted from - libpng 1.1.0 (pngread.c) */ - /* NOTE1: the table must remain sorted by chunkname, otherwise the binary - search will break !!! (ps. watch upper-/lower-case chunknames !!) */ - /* NOTE2: the layout must remain equal to the header part of all the - chunk-structures (yes, that means even the pNext and pPrev fields; - it's wasting a bit of space, but hey, the code is a lot easier) */ - -MNG_LOCAL mng_chunk_header mng_chunk_table [] = - { -#ifndef MNG_SKIPCHUNK_BACK - {MNG_UINT_BACK, mng_init_general, mng_free_general, mng_read_general, mng_write_back, mng_assign_general, 0, 0, sizeof(mng_back), &mng_chunk_descr_back}, -#endif -#ifndef MNG_SKIPCHUNK_BASI - {MNG_UINT_BASI, mng_init_general, mng_free_general, mng_read_general, mng_write_basi, mng_assign_general, 0, 0, sizeof(mng_basi), &mng_chunk_descr_basi}, -#endif -#ifndef MNG_SKIPCHUNK_CLIP - {MNG_UINT_CLIP, mng_init_general, mng_free_general, mng_read_general, mng_write_clip, mng_assign_general, 0, 0, sizeof(mng_clip), &mng_chunk_descr_clip}, -#endif -#ifndef MNG_SKIPCHUNK_CLON - {MNG_UINT_CLON, mng_init_general, mng_free_general, mng_read_general, mng_write_clon, mng_assign_general, 0, 0, sizeof(mng_clon), &mng_chunk_descr_clon}, -#endif -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_DBYK - {MNG_UINT_DBYK, mng_init_general, mng_free_dbyk, mng_read_general, mng_write_dbyk, mng_assign_dbyk, 0, 0, sizeof(mng_dbyk), &mng_chunk_descr_dbyk}, -#endif -#endif -#ifndef MNG_SKIPCHUNK_DEFI - {MNG_UINT_DEFI, mng_init_general, mng_free_general, mng_read_general, mng_write_defi, mng_assign_general, 0, 0, sizeof(mng_defi), &mng_chunk_descr_defi}, -#endif -#ifndef MNG_NO_DELTA_PNG - {MNG_UINT_DHDR, mng_init_general, mng_free_general, mng_read_general, mng_write_dhdr, mng_assign_general, 0, 0, sizeof(mng_dhdr), &mng_chunk_descr_dhdr}, -#endif -#ifndef MNG_SKIPCHUNK_DISC - {MNG_UINT_DISC, mng_init_general, mng_free_disc, mng_read_general, mng_write_disc, mng_assign_disc, 0, 0, sizeof(mng_disc), &mng_chunk_descr_disc}, -#endif -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_DROP - {MNG_UINT_DROP, mng_init_general, mng_free_drop, mng_read_general, mng_write_drop, mng_assign_drop, 0, 0, sizeof(mng_drop), &mng_chunk_descr_drop}, -#endif -#endif -#ifndef MNG_SKIPCHUNK_LOOP - {MNG_UINT_ENDL, mng_init_general, mng_free_general, mng_read_general, mng_write_endl, mng_assign_general, 0, 0, sizeof(mng_endl), &mng_chunk_descr_endl}, -#endif -#ifndef MNG_SKIPCHUNK_FRAM - {MNG_UINT_FRAM, mng_init_general, mng_free_fram, mng_read_general, mng_write_fram, mng_assign_fram, 0, 0, sizeof(mng_fram), &mng_chunk_descr_fram}, -#endif - {MNG_UINT_IDAT, mng_init_general, mng_free_idat, mng_read_general, mng_write_idat, mng_assign_idat, 0, 0, sizeof(mng_idat), &mng_chunk_descr_idat}, /* 12-th element! */ - {MNG_UINT_IEND, mng_init_general, mng_free_general, mng_read_general, mng_write_iend, mng_assign_general, 0, 0, sizeof(mng_iend), &mng_chunk_descr_iend}, - {MNG_UINT_IHDR, mng_init_general, mng_free_general, mng_read_general, mng_write_ihdr, mng_assign_general, 0, 0, sizeof(mng_ihdr), &mng_chunk_descr_ihdr}, -#ifndef MNG_NO_DELTA_PNG -#ifdef MNG_INCLUDE_JNG - {MNG_UINT_IJNG, mng_init_general, mng_free_general, mng_read_general, mng_write_ijng, mng_assign_general, 0, 0, sizeof(mng_ijng), &mng_chunk_descr_ijng}, -#endif - {MNG_UINT_IPNG, mng_init_general, mng_free_general, mng_read_general, mng_write_ipng, mng_assign_general, 0, 0, sizeof(mng_ipng), &mng_chunk_descr_ipng}, -#endif -#ifdef MNG_INCLUDE_JNG - {MNG_UINT_JDAA, mng_init_general, mng_free_jdaa, mng_read_general, mng_write_jdaa, mng_assign_jdaa, 0, 0, sizeof(mng_jdaa), &mng_chunk_descr_jdaa}, - {MNG_UINT_JDAT, mng_init_general, mng_free_jdat, mng_read_general, mng_write_jdat, mng_assign_jdat, 0, 0, sizeof(mng_jdat), &mng_chunk_descr_jdat}, - {MNG_UINT_JHDR, mng_init_general, mng_free_general, mng_read_general, mng_write_jhdr, mng_assign_general, 0, 0, sizeof(mng_jhdr), &mng_chunk_descr_jhdr}, - {MNG_UINT_JSEP, mng_init_general, mng_free_general, mng_read_general, mng_write_jsep, mng_assign_general, 0, 0, sizeof(mng_jsep), &mng_chunk_descr_jsep}, - {MNG_UINT_JdAA, mng_init_general, mng_free_jdaa, mng_read_general, mng_write_jdaa, mng_assign_jdaa, 0, 0, sizeof(mng_jdaa), &mng_chunk_descr_jdaa}, -#endif -#ifndef MNG_SKIPCHUNK_LOOP - {MNG_UINT_LOOP, mng_init_general, mng_free_loop, mng_read_general, mng_write_loop, mng_assign_loop, 0, 0, sizeof(mng_loop), &mng_chunk_descr_loop}, -#endif -#ifndef MNG_SKIPCHUNK_MAGN - {MNG_UINT_MAGN, mng_init_general, mng_free_general, mng_read_general, mng_write_magn, mng_assign_general, 0, 0, sizeof(mng_magn), &mng_chunk_descr_magn}, -#endif - {MNG_UINT_MEND, mng_init_general, mng_free_general, mng_read_general, mng_write_mend, mng_assign_general, 0, 0, sizeof(mng_mend), &mng_chunk_descr_mend}, - {MNG_UINT_MHDR, mng_init_general, mng_free_general, mng_read_general, mng_write_mhdr, mng_assign_general, 0, 0, sizeof(mng_mhdr), &mng_chunk_descr_mhdr}, -#ifndef MNG_SKIPCHUNK_MOVE - {MNG_UINT_MOVE, mng_init_general, mng_free_general, mng_read_general, mng_write_move, mng_assign_general, 0, 0, sizeof(mng_move), &mng_chunk_descr_move}, -#endif -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_ORDR - {MNG_UINT_ORDR, mng_init_general, mng_free_ordr, mng_read_general, mng_write_ordr, mng_assign_ordr, 0, 0, sizeof(mng_ordr), &mng_chunk_descr_ordr}, -#endif -#endif -#ifndef MNG_SKIPCHUNK_PAST - {MNG_UINT_PAST, mng_init_general, mng_free_past, mng_read_general, mng_write_past, mng_assign_past, 0, 0, sizeof(mng_past), &mng_chunk_descr_past}, -#endif - {MNG_UINT_PLTE, mng_init_general, mng_free_general, mng_read_general, mng_write_plte, mng_assign_general, 0, 0, sizeof(mng_plte), &mng_chunk_descr_plte}, -#ifndef MNG_NO_DELTA_PNG - {MNG_UINT_PPLT, mng_init_general, mng_free_general, mng_read_general, mng_write_pplt, mng_assign_general, 0, 0, sizeof(mng_pplt), &mng_chunk_descr_pplt}, - {MNG_UINT_PROM, mng_init_general, mng_free_general, mng_read_general, mng_write_prom, mng_assign_general, 0, 0, sizeof(mng_prom), &mng_chunk_descr_prom}, -#endif -#ifndef MNG_SKIPCHUNK_SAVE - {MNG_UINT_SAVE, mng_init_general, mng_free_save, mng_read_general, mng_write_save, mng_assign_save, 0, 0, sizeof(mng_save), &mng_chunk_descr_save}, -#endif -#ifndef MNG_SKIPCHUNK_SEEK - {MNG_UINT_SEEK, mng_init_general, mng_free_seek, mng_read_general, mng_write_seek, mng_assign_seek, 0, 0, sizeof(mng_seek), &mng_chunk_descr_seek}, -#endif -#ifndef MNG_SKIPCHUNK_SHOW - {MNG_UINT_SHOW, mng_init_general, mng_free_general, mng_read_general, mng_write_show, mng_assign_general, 0, 0, sizeof(mng_show), &mng_chunk_descr_show}, -#endif -#ifndef MNG_SKIPCHUNK_TERM - {MNG_UINT_TERM, mng_init_general, mng_free_general, mng_read_general, mng_write_term, mng_assign_general, 0, 0, sizeof(mng_term), &mng_chunk_descr_term}, -#endif -#ifdef MNG_INCLUDE_ANG_PROPOSAL - {MNG_UINT_adAT, mng_init_general, mng_free_adat, mng_read_general, mng_write_adat, mng_assign_adat, 0, 0, sizeof(mng_adat), &mng_chunk_descr_adat}, - {MNG_UINT_ahDR, mng_init_general, mng_free_general, mng_read_general, mng_write_ahdr, mng_assign_ahdr, 0, 0, sizeof(mng_ahdr), &mng_chunk_descr_ahdr}, -#endif -#ifndef MNG_SKIPCHUNK_bKGD - {MNG_UINT_bKGD, mng_init_general, mng_free_general, mng_read_general, mng_write_bkgd, mng_assign_general, 0, 0, sizeof(mng_bkgd), &mng_chunk_descr_bkgd}, -#endif -#ifndef MNG_SKIPCHUNK_cHRM - {MNG_UINT_cHRM, mng_init_general, mng_free_general, mng_read_general, mng_write_chrm, mng_assign_general, 0, 0, sizeof(mng_chrm), &mng_chunk_descr_chrm}, -#endif -#ifndef MNG_SKIPCHUNK_eXPI - {MNG_UINT_eXPI, mng_init_general, mng_free_expi, mng_read_general, mng_write_expi, mng_assign_expi, 0, 0, sizeof(mng_expi), &mng_chunk_descr_expi}, -#endif -#ifndef MNG_SKIPCHUNK_evNT - {MNG_UINT_evNT, mng_init_general, mng_free_evnt, mng_read_general, mng_write_evnt, mng_assign_evnt, 0, 0, sizeof(mng_evnt), &mng_chunk_descr_evnt}, -#endif -#ifndef MNG_SKIPCHUNK_fPRI - {MNG_UINT_fPRI, mng_init_general, mng_free_general, mng_read_general, mng_write_fpri, mng_assign_general, 0, 0, sizeof(mng_fpri), &mng_chunk_descr_fpri}, -#endif -#ifndef MNG_SKIPCHUNK_gAMA - {MNG_UINT_gAMA, mng_init_general, mng_free_general, mng_read_general, mng_write_gama, mng_assign_general, 0, 0, sizeof(mng_gama), &mng_chunk_descr_gama}, -#endif -#ifndef MNG_SKIPCHUNK_hIST - {MNG_UINT_hIST, mng_init_general, mng_free_general, mng_read_general, mng_write_hist, mng_assign_general, 0, 0, sizeof(mng_hist), &mng_chunk_descr_hist}, -#endif -#ifndef MNG_SKIPCHUNK_iCCP - {MNG_UINT_iCCP, mng_init_general, mng_free_iccp, mng_read_general, mng_write_iccp, mng_assign_iccp, 0, 0, sizeof(mng_iccp), &mng_chunk_descr_iccp}, -#endif -#ifndef MNG_SKIPCHUNK_iTXt - {MNG_UINT_iTXt, mng_init_general, mng_free_itxt, mng_read_general, mng_write_itxt, mng_assign_itxt, 0, 0, sizeof(mng_itxt), &mng_chunk_descr_itxt}, -#endif -#ifdef MNG_INCLUDE_MPNG_PROPOSAL - {MNG_UINT_mpNG, mng_init_general, mng_free_mpng, mng_read_general, mng_write_mpng, mng_assign_mpng, 0, 0, sizeof(mng_mpng), &mng_chunk_descr_mpng}, -#endif -#ifndef MNG_SKIPCHUNK_nEED - {MNG_UINT_nEED, mng_init_general, mng_free_need, mng_read_general, mng_write_need, mng_assign_need, 0, 0, sizeof(mng_need), &mng_chunk_descr_need}, -#endif -/* TODO: {MNG_UINT_oFFs, 0, 0, 0, 0, 0, 0}, */ -/* TODO: {MNG_UINT_pCAL, 0, 0, 0, 0, 0, 0}, */ -#ifndef MNG_SKIPCHUNK_pHYg - {MNG_UINT_pHYg, mng_init_general, mng_free_general, mng_read_general, mng_write_phyg, mng_assign_general, 0, 0, sizeof(mng_phyg), &mng_chunk_descr_phyg}, -#endif -#ifndef MNG_SKIPCHUNK_pHYs - {MNG_UINT_pHYs, mng_init_general, mng_free_general, mng_read_general, mng_write_phys, mng_assign_general, 0, 0, sizeof(mng_phys), &mng_chunk_descr_phys}, -#endif -#ifndef MNG_SKIPCHUNK_sBIT - {MNG_UINT_sBIT, mng_init_general, mng_free_general, mng_read_general, mng_write_sbit, mng_assign_general, 0, 0, sizeof(mng_sbit), &mng_chunk_descr_sbit}, -#endif -/* TODO: {MNG_UINT_sCAL, 0, 0, 0, 0, 0, 0}, */ -#ifndef MNG_SKIPCHUNK_sPLT - {MNG_UINT_sPLT, mng_init_general, mng_free_splt, mng_read_general, mng_write_splt, mng_assign_splt, 0, 0, sizeof(mng_splt), &mng_chunk_descr_splt}, -#endif - {MNG_UINT_sRGB, mng_init_general, mng_free_general, mng_read_general, mng_write_srgb, mng_assign_general, 0, 0, sizeof(mng_srgb), &mng_chunk_descr_srgb}, -#ifndef MNG_SKIPCHUNK_tEXt - {MNG_UINT_tEXt, mng_init_general, mng_free_text, mng_read_general, mng_write_text, mng_assign_text, 0, 0, sizeof(mng_text), &mng_chunk_descr_text}, -#endif -#ifndef MNG_SKIPCHUNK_tIME - {MNG_UINT_tIME, mng_init_general, mng_free_general, mng_read_general, mng_write_time, mng_assign_general, 0, 0, sizeof(mng_time), &mng_chunk_descr_time}, -#endif - {MNG_UINT_tRNS, mng_init_general, mng_free_general, mng_read_general, mng_write_trns, mng_assign_general, 0, 0, sizeof(mng_trns), &mng_chunk_descr_trns}, -#ifndef MNG_SKIPCHUNK_zTXt - {MNG_UINT_zTXt, mng_init_general, mng_free_ztxt, mng_read_general, mng_write_ztxt, mng_assign_ztxt, 0, 0, sizeof(mng_ztxt), &mng_chunk_descr_ztxt}, -#endif - }; - -/* ************************************************************************** */ -/* ************************************************************************** */ - -void mng_get_chunkheader (mng_chunkid iChunkname, - mng_chunk_headerp pResult) -{ - /* binary search variables */ - mng_int32 iTop, iLower, iUpper, iMiddle; - mng_chunk_headerp pEntry; /* pointer to found entry */ - /* determine max index of table */ - iTop = (sizeof (mng_chunk_table) / sizeof (mng_chunk_table [0])) - 1; - - /* binary search; with 54 chunks, worst-case is 7 comparisons */ - iLower = 0; -#ifndef MNG_NO_DELTA_PNG - iMiddle = 11; /* start with the IDAT entry */ -#else - iMiddle = 8; -#endif - iUpper = iTop; - pEntry = 0; /* no goods yet! */ - - do /* the binary search itself */ - { - if (mng_chunk_table [iMiddle].iChunkname < iChunkname) - iLower = iMiddle + 1; - else if (mng_chunk_table [iMiddle].iChunkname > iChunkname) - iUpper = iMiddle - 1; - else - { - pEntry = &mng_chunk_table [iMiddle]; - break; - } - iMiddle = (iLower + iUpper) >> 1; - } - while (iLower <= iUpper); - - if (!pEntry) /* unknown chunk ? */ - pEntry = &mng_chunk_unknown; /* make it so! */ - - MNG_COPY (pResult, pEntry, sizeof(mng_chunk_header)); - - return; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ -/* PNG chunks */ - -MNG_C_SPECIALFUNC (mng_special_ihdr) -{ - pData->bHasIHDR = MNG_TRUE; /* indicate IHDR is present */ - /* and store interesting fields */ - if ((!pData->bHasDHDR) || (pData->iDeltatype == MNG_DELTATYPE_NOCHANGE)) - { - pData->iDatawidth = ((mng_ihdrp)pChunk)->iWidth; - pData->iDataheight = ((mng_ihdrp)pChunk)->iHeight; - } - - pData->iBitdepth = ((mng_ihdrp)pChunk)->iBitdepth; - pData->iColortype = ((mng_ihdrp)pChunk)->iColortype; - pData->iCompression = ((mng_ihdrp)pChunk)->iCompression; - pData->iFilter = ((mng_ihdrp)pChunk)->iFilter; - pData->iInterlace = ((mng_ihdrp)pChunk)->iInterlace; - -#if defined(MNG_NO_1_2_4BIT_SUPPORT) || defined(MNG_NO_16BIT_SUPPORT) - pData->iPNGmult = 1; - pData->iPNGdepth = pData->iBitdepth; -#endif - -#ifdef MNG_NO_1_2_4BIT_SUPPORT - if (pData->iBitdepth < 8) - pData->iBitdepth = 8; -#endif - -#ifdef MNG_NO_16BIT_SUPPORT - if (pData->iBitdepth > 8) - { - pData->iBitdepth = 8; - pData->iPNGmult = 2; - } -#endif - - if ((pData->iBitdepth != 8) /* parameter validity checks */ -#ifndef MNG_NO_1_2_4BIT_SUPPORT - && (pData->iBitdepth != 1) && - (pData->iBitdepth != 2) && - (pData->iBitdepth != 4) -#endif -#ifndef MNG_NO_16BIT_SUPPORT - && (pData->iBitdepth != 16) -#endif - ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH); - - if ((pData->iColortype != MNG_COLORTYPE_GRAY ) && - (pData->iColortype != MNG_COLORTYPE_RGB ) && - (pData->iColortype != MNG_COLORTYPE_INDEXED) && - (pData->iColortype != MNG_COLORTYPE_GRAYA ) && - (pData->iColortype != MNG_COLORTYPE_RGBA ) ) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE); - - if ((pData->iColortype == MNG_COLORTYPE_INDEXED) && (pData->iBitdepth > 8)) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH); - - if (((pData->iColortype == MNG_COLORTYPE_RGB ) || - (pData->iColortype == MNG_COLORTYPE_GRAYA ) || - (pData->iColortype == MNG_COLORTYPE_RGBA ) ) && - (pData->iBitdepth < 8 ) ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH); - - if (pData->iCompression != MNG_COMPRESSION_DEFLATE) - MNG_ERROR (pData, MNG_INVALIDCOMPRESS); - -#if defined(FILTER192) || defined(FILTER193) - if ((pData->iFilter != MNG_FILTER_ADAPTIVE ) && -#if defined(FILTER192) && defined(FILTER193) - (pData->iFilter != MNG_FILTER_DIFFERING) && - (pData->iFilter != MNG_FILTER_NOFILTER ) ) -#else -#ifdef FILTER192 - (pData->iFilter != MNG_FILTER_DIFFERING) ) -#else - (pData->iFilter != MNG_FILTER_NOFILTER ) ) -#endif -#endif - MNG_ERROR (pData, MNG_INVALIDFILTER); -#else - if (pData->iFilter) - MNG_ERROR (pData, MNG_INVALIDFILTER); -#endif - - if ((pData->iInterlace != MNG_INTERLACE_NONE ) && - (pData->iInterlace != MNG_INTERLACE_ADAM7) ) - MNG_ERROR (pData, MNG_INVALIDINTERLACE); - -#ifdef MNG_SUPPORT_DISPLAY -#ifndef MNG_NO_DELTA_PNG - if (pData->bHasDHDR) /* check the colortype for delta-images ! */ - { - mng_imagedatap pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - - if (pData->iColortype != pBuf->iColortype) - { - if ( ( (pData->iColortype != MNG_COLORTYPE_INDEXED) || - (pBuf->iColortype == MNG_COLORTYPE_GRAY ) ) && - ( (pData->iColortype != MNG_COLORTYPE_GRAY ) || - (pBuf->iColortype == MNG_COLORTYPE_INDEXED) ) ) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE); - } - } -#endif -#endif - - if (!pData->bHasheader) /* first chunk ? */ - { - pData->bHasheader = MNG_TRUE; /* we've got a header */ - pData->eImagetype = mng_it_png; /* then this must be a PNG */ - pData->iWidth = pData->iDatawidth; - pData->iHeight = pData->iDataheight; - /* predict alpha-depth ! */ - if ((pData->iColortype == MNG_COLORTYPE_GRAYA ) || - (pData->iColortype == MNG_COLORTYPE_RGBA ) ) - pData->iAlphadepth = pData->iBitdepth; - else - if (pData->iColortype == MNG_COLORTYPE_INDEXED) - pData->iAlphadepth = 8; /* worst case scenario */ - else - pData->iAlphadepth = 1; /* Possible tRNS cheap binary transparency */ - /* fits on maximum canvas ? */ - if ((pData->iWidth > pData->iMaxwidth) || (pData->iHeight > pData->iMaxheight)) - MNG_WARNING (pData, MNG_IMAGETOOLARGE); - -#if !defined(MNG_INCLUDE_MPNG_PROPOSAL) || !defined(MNG_SUPPORT_DISPLAY) - if (pData->fProcessheader) /* inform the app ? */ - if (!pData->fProcessheader (((mng_handle)pData), pData->iWidth, pData->iHeight)) - MNG_ERROR (pData, MNG_APPMISCERROR); -#endif - } - - if (!pData->bHasDHDR) - pData->iImagelevel++; /* one level deeper */ - -#ifdef MNG_SUPPORT_DISPLAY - return mng_process_display_ihdr (pData); -#else - return MNG_NOERROR; -#endif /* MNG_SUPPORT_DISPLAY */ -} - -/* ************************************************************************** */ - -MNG_F_SPECIALFUNC (mng_debunk_plte) -{ - mng_pltep pPLTE = (mng_pltep)pChunk; - mng_uint32 iRawlen = *piRawlen; - mng_uint8p pRawdata = *ppRawdata; - /* length must be multiple of 3 */ - if (((iRawlen % 3) != 0) || (iRawlen > 768)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - /* this is the exact length */ - pPLTE->iEntrycount = iRawlen / 3; - - MNG_COPY (pPLTE->aEntries, pRawdata, iRawlen); - - *piRawlen = 0; - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -MNG_C_SPECIALFUNC (mng_special_plte) -{ /* multiple PLTE only inside BASI */ - if ((pData->bHasPLTE) && (!pData->bHasBASI)) - MNG_ERROR (pData, MNG_MULTIPLEERROR); - - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { /* only allowed for indexed-color or - rgb(a)-color! */ - if ((pData->iColortype != MNG_COLORTYPE_RGB ) && - (pData->iColortype != MNG_COLORTYPE_INDEXED) && - (pData->iColortype != MNG_COLORTYPE_RGBA ) ) - MNG_ERROR (pData, MNG_CHUNKNOTALLOWED); - /* empty only allowed if global present */ - if ((((mng_pltep)pChunk)->bEmpty) && (!pData->bHasglobalPLTE)) - MNG_ERROR (pData, MNG_CANNOTBEEMPTY); - } - else - { - if (((mng_pltep)pChunk)->bEmpty) /* cannot be empty as global! */ - MNG_ERROR (pData, MNG_CANNOTBEEMPTY); - } - - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - pData->bHasPLTE = MNG_TRUE; /* got it! */ - else - pData->bHasglobalPLTE = MNG_TRUE; - - pData->iPLTEcount = ((mng_pltep)pChunk)->iEntrycount; - -#ifdef MNG_SUPPORT_DISPLAY - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { - mng_imagep pImage; - mng_imagedatap pBuf; - -#ifndef MNG_NO_DELTA_PNG - if (pData->bHasDHDR) /* processing delta-image ? */ - { /* store in object 0 !!! */ - pImage = (mng_imagep)pData->pObjzero; - pBuf = pImage->pImgbuf; - pBuf->bHasPLTE = MNG_TRUE; /* it's definitely got a PLTE now */ - pBuf->iPLTEcount = ((mng_pltep)pChunk)->iEntrycount; - MNG_COPY (pBuf->aPLTEentries, ((mng_pltep)pChunk)->aEntries, - sizeof (pBuf->aPLTEentries)); - } - else -#endif - { /* get the current object */ - pImage = (mng_imagep)pData->pCurrentobj; - if (!pImage) /* no object then dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; /* address the object buffer */ - pBuf->bHasPLTE = MNG_TRUE; /* and tell it it's got a PLTE now */ - - if (((mng_pltep)pChunk)->bEmpty) /* if empty, inherit from global */ - { - pBuf->iPLTEcount = pData->iGlobalPLTEcount; - MNG_COPY (pBuf->aPLTEentries, pData->aGlobalPLTEentries, - sizeof (pBuf->aPLTEentries)); - - if (pData->bHasglobalTRNS) /* also copy global tRNS ? */ - { - mng_uint32 iRawlen2 = pData->iGlobalTRNSrawlen; - mng_uint8p pRawdata2 = (mng_uint8p)(pData->aGlobalTRNSrawdata); - /* indicate tRNS available */ - pBuf->bHasTRNS = MNG_TRUE; - /* global length oke ? */ - if ((iRawlen2 == 0) || (iRawlen2 > pBuf->iPLTEcount)) - MNG_ERROR (pData, MNG_GLOBALLENGTHERR); - /* copy it */ - pBuf->iTRNScount = iRawlen2; - MNG_COPY (pBuf->aTRNSentries, pRawdata2, iRawlen2); - } - } - else - { /* store fields for future reference */ - pBuf->iPLTEcount = ((mng_pltep)pChunk)->iEntrycount; - MNG_COPY (pBuf->aPLTEentries, ((mng_pltep)pChunk)->aEntries, - sizeof (pBuf->aPLTEentries)); - } - } - } - else /* store as global */ - { - pData->iGlobalPLTEcount = ((mng_pltep)pChunk)->iEntrycount; - MNG_COPY (pData->aGlobalPLTEentries, ((mng_pltep)pChunk)->aEntries, - sizeof (pData->aGlobalPLTEentries)); - /* create an animation object */ - return mng_create_ani_plte (pData); - } -#endif /* MNG_SUPPORT_DISPLAY */ - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -MNG_C_SPECIALFUNC (mng_special_idat) -{ -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasJHDR) && - (pData->iJHDRalphacompression != MNG_COMPRESSION_DEFLATE)) - MNG_ERROR (pData, MNG_SEQUENCEERROR); -#endif - /* not allowed for deltatype NO_CHANGE */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && ((pData->iDeltatype == MNG_DELTATYPE_NOCHANGE))) - MNG_ERROR (pData, MNG_CHUNKNOTALLOWED); -#endif - /* can only be empty in BASI-block! */ - if ((((mng_idatp)pChunk)->bEmpty) && (!pData->bHasBASI)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - /* indexed-color requires PLTE */ - if ((pData->bHasIHDR) && (pData->iColortype == 3) && (!pData->bHasPLTE)) - MNG_ERROR (pData, MNG_PLTEMISSING); - - pData->bHasIDAT = MNG_TRUE; /* got some IDAT now, don't we */ - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -MNG_C_SPECIALFUNC (mng_special_iend) -{ /* IHDR-block requires IDAT */ - if ((pData->bHasIHDR) && (!pData->bHasIDAT)) - MNG_ERROR (pData, MNG_IDATMISSING); - - pData->iImagelevel--; /* one level up */ - -#ifdef MNG_SUPPORT_DISPLAY - { /* create an animation object */ - mng_retcode iRetcode = mng_create_ani_image (pData); - if (iRetcode) /* on error bail out */ - return iRetcode; - /* display processing */ - iRetcode = mng_process_display_iend (pData); - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_SUPPORT_DISPLAY - if (!pData->bTimerset) /* reset only if not broken !!! */ - { -#endif - /* IEND signals the end for most ... */ - pData->bHasIHDR = MNG_FALSE; - pData->bHasBASI = MNG_FALSE; - pData->bHasDHDR = MNG_FALSE; -#ifdef MNG_INCLUDE_JNG - pData->bHasJHDR = MNG_FALSE; - pData->bHasJSEP = MNG_FALSE; - pData->bHasJDAA = MNG_FALSE; - pData->bHasJDAT = MNG_FALSE; -#endif - pData->bHasPLTE = MNG_FALSE; - pData->bHasTRNS = MNG_FALSE; - pData->bHasGAMA = MNG_FALSE; - pData->bHasCHRM = MNG_FALSE; - pData->bHasSRGB = MNG_FALSE; - pData->bHasICCP = MNG_FALSE; - pData->bHasBKGD = MNG_FALSE; - pData->bHasIDAT = MNG_FALSE; -#ifdef MNG_SUPPORT_DISPLAY - } -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -MNG_F_SPECIALFUNC (mng_debunk_trns) -{ - mng_trnsp pTRNS = (mng_trnsp)pChunk; - mng_uint32 iRawlen = *piRawlen; - mng_uint8p pRawdata = *ppRawdata; - - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { /* not global! */ - pTRNS->bGlobal = MNG_FALSE; - pTRNS->iType = pData->iColortype; - - if (iRawlen != 0) - { - switch (pData->iColortype) /* store fields */ - { - case 0: { /* gray */ - if (iRawlen != 2) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - pTRNS->iGray = mng_get_uint16 (pRawdata); - break; - } - case 2: { /* rgb */ - if (iRawlen != 6) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - pTRNS->iRed = mng_get_uint16 (pRawdata); - pTRNS->iGreen = mng_get_uint16 (pRawdata+2); - pTRNS->iBlue = mng_get_uint16 (pRawdata+4); - break; - } - case 3: { /* indexed */ - if (iRawlen > 256) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - pTRNS->iCount = iRawlen; - MNG_COPY (pTRNS->aEntries, pRawdata, iRawlen); - break; - } - } - } - } - else /* it's global! */ - { - if (iRawlen == 0) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - pTRNS->bGlobal = MNG_TRUE; - pTRNS->iType = 0; - pTRNS->iRawlen = iRawlen; - MNG_COPY (pTRNS->aRawdata, pRawdata, iRawlen); - - pData->iGlobalTRNSrawlen = iRawlen; - MNG_COPY (pData->aGlobalTRNSrawdata, pRawdata, iRawlen); - } - - *piRawlen = 0; - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -MNG_C_SPECIALFUNC (mng_special_trns) -{ /* multiple tRNS only inside BASI */ - if ((pData->bHasTRNS) && (!pData->bHasBASI)) - MNG_ERROR (pData, MNG_MULTIPLEERROR); - - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { /* not allowed with full alpha-channel */ - if ((pData->iColortype == 4) || (pData->iColortype == 6)) - MNG_ERROR (pData, MNG_CHUNKNOTALLOWED); - - if (!((mng_trnsp)pChunk)->bEmpty) /* filled ? */ - { -#ifdef MNG_SUPPORT_DISPLAY - if (pData->iColortype == 3) - { - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - mng_imagedatap pBuf; - - if (!pImage) /* no object then check obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; /* address object buffer */ - - if (((mng_trnsp)pChunk)->iCount > pBuf->iPLTEcount) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } -#endif - } - else /* if empty there must be global stuff! */ - { - if (!pData->bHasglobalTRNS) - MNG_ERROR (pData, MNG_CANNOTBEEMPTY); - } - } - - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - pData->bHasTRNS = MNG_TRUE; /* indicate tRNS available */ - else - pData->bHasglobalTRNS = MNG_TRUE; - -#ifdef MNG_SUPPORT_DISPLAY - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { - mng_imagep pImage; - mng_imagedatap pBuf; - mng_uint8p pRawdata2; - mng_uint32 iRawlen2; - -#ifndef MNG_NO_DELTA_PNG - if (pData->bHasDHDR) /* processing delta-image ? */ - { /* store in object 0 !!! */ -#if defined(MNG_NO_1_2_4BIT_SUPPORT) - mng_uint8 multiplier[]={0,255,85,0,17,0,0,0,1,0,0,0,0,0,0,0,1}; -#endif - pImage = (mng_imagep)pData->pObjzero; - pBuf = pImage->pImgbuf; /* address object buffer */ - pBuf->bHasTRNS = MNG_TRUE; /* tell it it's got a tRNS now */ - pBuf->iTRNSgray = 0; - pBuf->iTRNSred = 0; - pBuf->iTRNSgreen = 0; - pBuf->iTRNSblue = 0; - pBuf->iTRNScount = 0; - - switch (pData->iColortype) /* store fields for future reference */ - { - case 0: { /* gray */ - pBuf->iTRNSgray = ((mng_trnsp)pChunk)->iGray; -#if defined(MNG_NO_1_2_4BIT_SUPPORT) - pBuf->iTRNSgray *= multiplier[pData->iPNGdepth]; -#endif -#if defined(MNG_NO_16BIT_SUPPORT) - if (pData->iPNGmult == 2) - pBuf->iTRNSgray >>= 8; -#endif - break; - } - case 2: { /* rgb */ - pBuf->iTRNSred = ((mng_trnsp)pChunk)->iRed; - pBuf->iTRNSgreen = ((mng_trnsp)pChunk)->iGreen; - pBuf->iTRNSblue = ((mng_trnsp)pChunk)->iBlue; -#if defined(MNG_NO_16BIT_SUPPORT) - if (pData->iPNGmult == 2) - { - pBuf->iTRNSred >>= 8; - pBuf->iTRNSgreen >>= 8; - pBuf->iTRNSblue >>= 8; - } -#endif - break; - } - case 3: { /* indexed */ - pBuf->iTRNScount = ((mng_trnsp)pChunk)->iCount; - MNG_COPY (pBuf->aTRNSentries, - ((mng_trnsp)pChunk)->aEntries, - ((mng_trnsp)pChunk)->iCount); - break; - } - } - } - else -#endif - { /* address current object */ - pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* no object then dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; /* address object buffer */ - pBuf->bHasTRNS = MNG_TRUE; /* and tell it it's got a tRNS now */ - pBuf->iTRNSgray = 0; - pBuf->iTRNSred = 0; - pBuf->iTRNSgreen = 0; - pBuf->iTRNSblue = 0; - pBuf->iTRNScount = 0; - - if (((mng_trnsp)pChunk)->bEmpty) /* if empty, inherit from global */ - { - iRawlen2 = pData->iGlobalTRNSrawlen; - pRawdata2 = (mng_ptr)(pData->aGlobalTRNSrawdata); - /* global length oke ? */ - if ((pData->iColortype == 0) && (iRawlen2 != 2)) - MNG_ERROR (pData, MNG_GLOBALLENGTHERR); - - if ((pData->iColortype == 2) && (iRawlen2 != 6)) - MNG_ERROR (pData, MNG_GLOBALLENGTHERR); - - if ((pData->iColortype == 3) && ((iRawlen2 == 0) || (iRawlen2 > pBuf->iPLTEcount))) - MNG_ERROR (pData, MNG_GLOBALLENGTHERR); - - switch (pData->iColortype) /* store fields for future reference */ - { - case 0: { /* gray */ - pBuf->iTRNSgray = mng_get_uint16 (pRawdata2); -#if defined(MNG_NO_16BIT_SUPPORT) - if (pData->iPNGmult == 2) - pBuf->iTRNSgray >>= 8; -#endif - break; - } - case 2: { /* rgb */ - pBuf->iTRNSred = mng_get_uint16 (pRawdata2); - pBuf->iTRNSgreen = mng_get_uint16 (pRawdata2+2); - pBuf->iTRNSblue = mng_get_uint16 (pRawdata2+4); -#if defined(MNG_NO_16BIT_SUPPORT) - if (pData->iPNGmult == 2) - { - pBuf->iTRNSred >>= 8; - pBuf->iTRNSgreen >>= 8; - pBuf->iTRNSblue >>= 8; - } -#endif - break; - } - case 3: { /* indexed */ - pBuf->iTRNScount = iRawlen2; - MNG_COPY (pBuf->aTRNSentries, pRawdata2, iRawlen2); - break; - } - } - } - else - { - switch (pData->iColortype) /* store fields for future reference */ - { - case 0: { /* gray */ - pBuf->iTRNSgray = ((mng_trnsp)pChunk)->iGray; -#if defined(MNG_NO_16BIT_SUPPORT) - if (pData->iPNGmult == 2) - pBuf->iTRNSgray >>= 8; -#endif - break; - } - case 2: { /* rgb */ - pBuf->iTRNSred = ((mng_trnsp)pChunk)->iRed; - pBuf->iTRNSgreen = ((mng_trnsp)pChunk)->iGreen; - pBuf->iTRNSblue = ((mng_trnsp)pChunk)->iBlue; -#if defined(MNG_NO_16BIT_SUPPORT) - if (pData->iPNGmult == 2) - { - pBuf->iTRNSred >>= 8; - pBuf->iTRNSgreen >>= 8; - pBuf->iTRNSblue >>= 8; - } -#endif - break; - } - case 3: { /* indexed */ - pBuf->iTRNScount = ((mng_trnsp)pChunk)->iCount; - MNG_COPY (pBuf->aTRNSentries, - ((mng_trnsp)pChunk)->aEntries, - ((mng_trnsp)pChunk)->iCount); - break; - } - } - } - } - } - else - { /* create an animation object */ - return mng_create_ani_trns (pData); - } -#endif /* MNG_SUPPORT_DISPLAY */ - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -MNG_C_SPECIALFUNC (mng_special_gama) -{ -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - pData->bHasGAMA = MNG_TRUE; /* indicate we've got it */ - else - pData->bHasglobalGAMA = (mng_bool)!((mng_gamap)pChunk)->bEmpty; - -#ifdef MNG_SUPPORT_DISPLAY -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { - mng_imagep pImage; - -#ifndef MNG_NO_DELTA_PNG - if (pData->bHasDHDR) /* update delta image ? */ - pImage = (mng_imagep)pData->pObjzero; - else -#endif - { - pImage = (mng_imagep)pData->pCurrentobj; - if (!pImage) /* no object then dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - } - /* store for color-processing routines */ - pImage->pImgbuf->iGamma = ((mng_gamap)pChunk)->iGamma; - pImage->pImgbuf->bHasGAMA = MNG_TRUE; - } - else - { /* store as global */ - if (!((mng_gamap)pChunk)->bEmpty) - pData->iGlobalGamma = ((mng_gamap)pChunk)->iGamma; - /* create an animation object */ - return mng_create_ani_gama (pData, pChunk); - } -#endif /* MNG_SUPPORT_DISPLAY */ - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_cHRM -MNG_C_SPECIALFUNC (mng_special_chrm) -{ -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - pData->bHasCHRM = MNG_TRUE; /* indicate we've got it */ - else - pData->bHasglobalCHRM = (mng_bool)!((mng_chrmp)pChunk)->bEmpty; - -#ifdef MNG_SUPPORT_DISPLAY - { -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { - mng_imagep pImage; - mng_imagedatap pBuf; - -#ifndef MNG_NO_DELTA_PNG - if (pData->bHasDHDR) /* update delta image ? */ - pImage = (mng_imagep)pData->pObjzero; - else -#endif - { - pImage = (mng_imagep)pData->pCurrentobj; - if (!pImage) /* no object then dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - } - - pBuf = pImage->pImgbuf; /* address object buffer */ - pBuf->bHasCHRM = MNG_TRUE; /* and tell it it's got a CHRM now */ - /* store for color-processing routines */ - pBuf->iWhitepointx = ((mng_chrmp)pChunk)->iWhitepointx; - pBuf->iWhitepointy = ((mng_chrmp)pChunk)->iWhitepointy; - pBuf->iPrimaryredx = ((mng_chrmp)pChunk)->iRedx; - pBuf->iPrimaryredy = ((mng_chrmp)pChunk)->iRedy; - pBuf->iPrimarygreenx = ((mng_chrmp)pChunk)->iGreenx; - pBuf->iPrimarygreeny = ((mng_chrmp)pChunk)->iGreeny; - pBuf->iPrimarybluex = ((mng_chrmp)pChunk)->iBluex; - pBuf->iPrimarybluey = ((mng_chrmp)pChunk)->iBluey; - } - else - { /* store as global */ - if (!((mng_chrmp)pChunk)->bEmpty) - { - pData->iGlobalWhitepointx = ((mng_chrmp)pChunk)->iWhitepointx; - pData->iGlobalWhitepointy = ((mng_chrmp)pChunk)->iWhitepointy; - pData->iGlobalPrimaryredx = ((mng_chrmp)pChunk)->iRedx; - pData->iGlobalPrimaryredy = ((mng_chrmp)pChunk)->iRedy; - pData->iGlobalPrimarygreenx = ((mng_chrmp)pChunk)->iGreenx; - pData->iGlobalPrimarygreeny = ((mng_chrmp)pChunk)->iGreeny; - pData->iGlobalPrimarybluex = ((mng_chrmp)pChunk)->iBluex; - pData->iGlobalPrimarybluey = ((mng_chrmp)pChunk)->iBluey; - } - /* create an animation object */ - return mng_create_ani_chrm (pData, pChunk); - } - } -#endif /* MNG_SUPPORT_DISPLAY */ - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -MNG_C_SPECIALFUNC (mng_special_srgb) -{ -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - pData->bHasSRGB = MNG_TRUE; /* indicate we've got it */ - else - pData->bHasglobalSRGB = (mng_bool)!((mng_srgbp)pChunk)->bEmpty; - -#ifdef MNG_SUPPORT_DISPLAY -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { - mng_imagep pImage; - -#ifndef MNG_NO_DELTA_PNG - if (pData->bHasDHDR) /* update delta image ? */ - pImage = (mng_imagep)pData->pObjzero; - else -#endif - { - pImage = (mng_imagep)pData->pCurrentobj; - if (!pImage) /* no object then dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - } - /* store for color-processing routines */ - pImage->pImgbuf->iRenderingintent = ((mng_srgbp)pChunk)->iRenderingintent; - pImage->pImgbuf->bHasSRGB = MNG_TRUE; - } - else - { /* store as global */ - if (!((mng_srgbp)pChunk)->bEmpty) - pData->iGlobalRendintent = ((mng_srgbp)pChunk)->iRenderingintent; - /* create an animation object */ - return mng_create_ani_srgb (pData, pChunk); - } -#endif /* MNG_SUPPORT_DISPLAY */ - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_iCCP -MNG_C_SPECIALFUNC (mng_special_iccp) -{ - mng_retcode iRetcode; - mng_chunk_headerp pDummy; - -#ifdef MNG_CHECK_BAD_ICCP /* Check for bad iCCP chunk */ - if (!strncmp (((mng_iccpp)pChunk)->zName, "Photoshop ICC profile", 21)) - { - if (((mng_iccpp)pChunk)->iProfilesize == 2615) /* is it the sRGB profile ? */ - { - mng_chunk_header chunk_srgb; - mng_get_chunkheader (MNG_UINT_sRGB, &chunk_srgb); - /* pretend it's an sRGB chunk then ! */ - iRetcode = mng_read_general (pData, &chunk_srgb, 1, (mng_ptr)"0", &pDummy); - if (iRetcode) /* on error bail out */ - return iRetcode; - - pDummy->fCleanup (pData, pDummy); - } - } - else - { -#endif /* MNG_CHECK_BAD_ICCP */ - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - pData->bHasICCP = MNG_TRUE; /* indicate we've got it */ - else - pData->bHasglobalICCP = (mng_bool)!((mng_iccpp)pChunk)->bEmpty; - -#ifdef MNG_SUPPORT_DISPLAY -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { - mng_imagep pImage; - -#ifndef MNG_NO_DELTA_PNG - if (pData->bHasDHDR) /* update delta image ? */ - { /* store in object 0 ! */ - pImage = (mng_imagep)pData->pObjzero; - - if (pImage->pImgbuf->pProfile) /* profile existed ? */ - MNG_FREEX (pData, pImage->pImgbuf->pProfile, pImage->pImgbuf->iProfilesize); - /* allocate a buffer & copy it */ - MNG_ALLOC (pData, pImage->pImgbuf->pProfile, ((mng_iccpp)pChunk)->iProfilesize); - MNG_COPY (pImage->pImgbuf->pProfile, ((mng_iccpp)pChunk)->pProfile, ((mng_iccpp)pChunk)->iProfilesize); - /* store its length as well */ - pImage->pImgbuf->iProfilesize = ((mng_iccpp)pChunk)->iProfilesize; - pImage->pImgbuf->bHasICCP = MNG_TRUE; - } - else -#endif - { - pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* no object then dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - - if (pImage->pImgbuf->pProfile) /* profile existed ? */ - MNG_FREEX (pData, pImage->pImgbuf->pProfile, pImage->pImgbuf->iProfilesize); - /* allocate a buffer & copy it */ - MNG_ALLOC (pData, pImage->pImgbuf->pProfile, ((mng_iccpp)pChunk)->iProfilesize); - MNG_COPY (pImage->pImgbuf->pProfile, ((mng_iccpp)pChunk)->pProfile, ((mng_iccpp)pChunk)->iProfilesize); - /* store its length as well */ - pImage->pImgbuf->iProfilesize = ((mng_iccpp)pChunk)->iProfilesize; - pImage->pImgbuf->bHasICCP = MNG_TRUE; - } - } - else - { /* store as global */ - if (pData->pGlobalProfile) /* did we have a global profile ? */ - MNG_FREEX (pData, pData->pGlobalProfile, pData->iGlobalProfilesize); - - if (((mng_iccpp)pChunk)->bEmpty) /* empty chunk ? */ - { - pData->iGlobalProfilesize = 0; /* reset to null */ - pData->pGlobalProfile = MNG_NULL; - } - else - { /* allocate a global buffer & copy it */ - MNG_ALLOC (pData, pData->pGlobalProfile, ((mng_iccpp)pChunk)->iProfilesize); - MNG_COPY (pData->pGlobalProfile, ((mng_iccpp)pChunk)->pProfile, ((mng_iccpp)pChunk)->iProfilesize); - /* store its length as well */ - pData->iGlobalProfilesize = ((mng_iccpp)pChunk)->iProfilesize; - } - /* create an animation object */ - return mng_create_ani_iccp (pData, pChunk); - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_CHECK_BAD_ICCP - } -#endif - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_tEXt -MNG_C_SPECIALFUNC (mng_special_text) -{ - if (pData->fProcesstext) /* inform the application ? */ - { - mng_bool bOke = pData->fProcesstext ((mng_handle)pData, MNG_TYPE_TEXT, - ((mng_textp)pChunk)->zKeyword, - ((mng_textp)pChunk)->zText, 0, 0); - if (!bOke) - MNG_ERROR (pData, MNG_APPMISCERROR); - } - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_zTXt -MNG_C_SPECIALFUNC (mng_special_ztxt) -{ - if (pData->fProcesstext) /* inform the application ? */ - { - mng_bool bOke = pData->fProcesstext ((mng_handle)pData, MNG_TYPE_ZTXT, - ((mng_ztxtp)pChunk)->zKeyword, - ((mng_ztxtp)pChunk)->zText, 0, 0); - if (!bOke) - MNG_ERROR (pData, MNG_APPMISCERROR); - } - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_iTXt -MNG_F_SPECIALFUNC (mng_deflate_itxt) -{ - mng_itxtp pITXT = (mng_itxtp)pChunk; - mng_uint32 iBufsize = 0; - mng_uint8p pBuf = 0; - mng_uint32 iTextlen = 0; - - if (pITXT->iCompressionflag) /* decompress the text ? */ - { - mng_retcode iRetcode = mng_inflate_buffer (pData, *ppRawdata, *piRawlen, - &pBuf, &iBufsize, &iTextlen); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffer */ - MNG_FREEX (pData, pBuf, iBufsize); - return iRetcode; - } - - MNG_ALLOC (pData, pITXT->zText, iTextlen+1); - MNG_COPY (pITXT->zText, pBuf, iTextlen); - - pITXT->iTextsize = iTextlen; - - MNG_FREEX (pData, pBuf, iBufsize); - - } else { - - MNG_ALLOC (pData, pITXT->zText, (*piRawlen)+1); - MNG_COPY (pITXT->zText, *ppRawdata, *piRawlen); - - pITXT->iTextsize = *piRawlen; - } - - *piRawlen = 0; - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_iTXt -MNG_C_SPECIALFUNC (mng_special_itxt) -{ - if (pData->fProcesstext) /* inform the application ? */ - { - mng_bool bOke = pData->fProcesstext ((mng_handle)pData, MNG_TYPE_ITXT, - ((mng_itxtp)pChunk)->zKeyword, - ((mng_itxtp)pChunk)->zText, - ((mng_itxtp)pChunk)->zLanguage, - ((mng_itxtp)pChunk)->zTranslation); - if (!bOke) - MNG_ERROR (pData, MNG_APPMISCERROR); - } - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_bKGD -MNG_C_SPECIALFUNC (mng_special_bkgd) -{ -#ifdef MNG_SUPPORT_DISPLAY - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - mng_imagedatap pBuf; -#endif - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - pData->bHasBKGD = MNG_TRUE; /* indicate bKGD available */ - else - pData->bHasglobalBKGD = (mng_bool)!(((mng_bkgdp)pChunk)->bEmpty); - -#ifdef MNG_SUPPORT_DISPLAY - if (!pImage) /* if no object dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - pBuf = pImage->pImgbuf; /* address object buffer */ - -#ifdef MNG_INCLUDE_JNG - if (pData->bHasJHDR) - { - pBuf->bHasBKGD = MNG_TRUE; /* tell the object it's got bKGD now */ - - switch (pData->iJHDRcolortype) /* store fields for future reference */ - { - case 8 : ; /* gray */ - case 12 : { /* graya */ - pBuf->iBKGDgray = ((mng_bkgdp)pChunk)->iGray; - break; - } - case 10 : ; /* rgb */ - case 14 : { /* rgba */ - pBuf->iBKGDred = ((mng_bkgdp)pChunk)->iRed; - pBuf->iBKGDgreen = ((mng_bkgdp)pChunk)->iGreen; - pBuf->iBKGDblue = ((mng_bkgdp)pChunk)->iBlue; - break; - } - } - } - else -#endif /* MNG_INCLUDE_JNG */ - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { - pBuf->bHasBKGD = MNG_TRUE; /* tell the object it's got bKGD now */ - - switch (pData->iColortype) /* store fields for future reference */ - { - case 0 : ; /* gray */ - case 4 : { /* graya */ - pBuf->iBKGDgray = ((mng_bkgdp)pChunk)->iGray; - break; - } - case 2 : ; /* rgb */ - case 6 : { /* rgba */ - pBuf->iBKGDred = ((mng_bkgdp)pChunk)->iRed; - pBuf->iBKGDgreen = ((mng_bkgdp)pChunk)->iGreen; - pBuf->iBKGDblue = ((mng_bkgdp)pChunk)->iBlue; - break; - } - case 3 : { /* indexed */ - pBuf->iBKGDindex = ((mng_bkgdp)pChunk)->iIndex; - break; - } - } - } - else /* store as global */ - { - if (!(((mng_bkgdp)pChunk)->bEmpty)) - { - pData->iGlobalBKGDred = ((mng_bkgdp)pChunk)->iRed; - pData->iGlobalBKGDgreen = ((mng_bkgdp)pChunk)->iGreen; - pData->iGlobalBKGDblue = ((mng_bkgdp)pChunk)->iBlue; - } - /* create an animation object */ - return mng_create_ani_bkgd (pData); - } -#endif /* MNG_SUPPORT_DISPLAY */ - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_pHYs -MNG_C_SPECIALFUNC (mng_special_phys) -{ -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_sBIT -MNG_C_SPECIALFUNC (mng_special_sbit) -{ -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_sPLT -MNG_F_SPECIALFUNC (mng_splt_entries) -{ - mng_spltp pSPLT = (mng_spltp)pChunk; - mng_uint32 iRawlen = *piRawlen; - mng_uint8p pRawdata = *ppRawdata; - - if ((pSPLT->iSampledepth != MNG_BITDEPTH_8 ) && - (pSPLT->iSampledepth != MNG_BITDEPTH_16) ) - MNG_ERROR (pData, MNG_INVSAMPLEDEPTH); - /* check remaining length */ - if ( ((pSPLT->iSampledepth == MNG_BITDEPTH_8 ) && (iRawlen % 6 != 0)) || - ((pSPLT->iSampledepth == MNG_BITDEPTH_16) && (iRawlen % 10 != 0)) ) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - if (pSPLT->iSampledepth == MNG_BITDEPTH_8) - pSPLT->iEntrycount = iRawlen / 6; - else - pSPLT->iEntrycount = iRawlen / 10; - - if (iRawlen) - { - MNG_ALLOC (pData, pSPLT->pEntries, iRawlen); - MNG_COPY (pSPLT->pEntries, pRawdata, iRawlen); - } - - *piRawlen = 0; - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_sPLT -MNG_C_SPECIALFUNC (mng_special_splt) -{ -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_hIST -MNG_F_SPECIALFUNC (mng_hist_entries) -{ - mng_histp pHIST = (mng_histp)pChunk; - mng_uint32 iRawlen = *piRawlen; - mng_uint8p pRawdata = *ppRawdata; - mng_uint32 iX; - - if ( ((iRawlen & 0x01) != 0) || ((iRawlen >> 1) != pData->iPLTEcount) ) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - pHIST->iEntrycount = iRawlen >> 1; - - for (iX = 0; iX < pHIST->iEntrycount; iX++) - { - pHIST->aEntries[iX] = mng_get_uint16 (pRawdata); - pRawdata += 2; - } - - *piRawlen = 0; - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_hIST -MNG_C_SPECIALFUNC (mng_special_hist) -{ -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_tIME -MNG_C_SPECIALFUNC (mng_special_time) -{ -/* if (pData->fProcesstime) */ /* inform the application ? */ -/* { - - pData->fProcesstime ((mng_handle)pData, ); - } */ - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ -/* ************************************************************************** */ -/* JNG chunks */ - -#ifdef MNG_INCLUDE_JNG -MNG_C_SPECIALFUNC (mng_special_jhdr) -{ - if ((pData->eSigtype == mng_it_jng) && (pData->iChunkseq > 1)) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - /* inside a JHDR-IEND block now */ - pData->bHasJHDR = MNG_TRUE; - /* and store interesting fields */ - pData->iDatawidth = ((mng_jhdrp)pChunk)->iWidth; - pData->iDataheight = ((mng_jhdrp)pChunk)->iHeight; - pData->iJHDRcolortype = ((mng_jhdrp)pChunk)->iColortype; - pData->iJHDRimgbitdepth = ((mng_jhdrp)pChunk)->iImagesampledepth; - pData->iJHDRimgcompression = ((mng_jhdrp)pChunk)->iImagecompression; - pData->iJHDRimginterlace = ((mng_jhdrp)pChunk)->iImageinterlace; - pData->iJHDRalphabitdepth = ((mng_jhdrp)pChunk)->iAlphasampledepth; - pData->iJHDRalphacompression = ((mng_jhdrp)pChunk)->iAlphacompression; - pData->iJHDRalphafilter = ((mng_jhdrp)pChunk)->iAlphafilter; - pData->iJHDRalphainterlace = ((mng_jhdrp)pChunk)->iAlphainterlace; - -#if defined(MNG_NO_1_2_4BIT_SUPPORT) || defined(MNG_NO_16BIT_SUPPORT) - pData->iPNGmult = 1; - pData->iPNGdepth = pData->iJHDRalphabitdepth; -#endif - -#ifdef MNG_NO_1_2_4BIT_SUPPORT - if (pData->iJHDRalphabitdepth < 8) - pData->iJHDRalphabitdepth = 8; -#endif - -#ifdef MNG_NO_16BIT_SUPPORT - if (pData->iJHDRalphabitdepth > 8) - { - pData->iPNGmult = 2; - pData->iJHDRalphabitdepth = 8; - } -#endif - /* parameter validity checks */ - if ((pData->iJHDRcolortype != MNG_COLORTYPE_JPEGGRAY ) && - (pData->iJHDRcolortype != MNG_COLORTYPE_JPEGCOLOR ) && - (pData->iJHDRcolortype != MNG_COLORTYPE_JPEGGRAYA ) && - (pData->iJHDRcolortype != MNG_COLORTYPE_JPEGCOLORA) ) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE); - - if ((pData->iJHDRimgbitdepth != MNG_BITDEPTH_JPEG8 ) && - (pData->iJHDRimgbitdepth != MNG_BITDEPTH_JPEG12 ) && - (pData->iJHDRimgbitdepth != MNG_BITDEPTH_JPEG8AND12) ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH); - - if ((pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) ) - { - if ((pData->iJHDRalphabitdepth != MNG_BITDEPTH_8 ) -#ifndef MNG_NO_1_2_4BIT_SUPPORT - && (pData->iJHDRalphabitdepth != MNG_BITDEPTH_1 ) && - (pData->iJHDRalphabitdepth != MNG_BITDEPTH_2 ) && - (pData->iJHDRalphabitdepth != MNG_BITDEPTH_4 ) -#endif -#ifndef MNG_NO_16BIT_SUPPORT - && (pData->iJHDRalphabitdepth != MNG_BITDEPTH_16) -#endif - ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH); - - if ((pData->iJHDRalphacompression != MNG_COMPRESSION_DEFLATE ) && - (pData->iJHDRalphacompression != MNG_COMPRESSION_BASELINEJPEG) ) - MNG_ERROR (pData, MNG_INVALIDCOMPRESS); - - if ((pData->iJHDRalphacompression == MNG_COMPRESSION_BASELINEJPEG) && - (pData->iJHDRalphabitdepth != MNG_BITDEPTH_8 ) ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH); - -#if defined(FILTER192) || defined(FILTER193) - if ((pData->iJHDRalphafilter != MNG_FILTER_ADAPTIVE ) && -#if defined(FILTER192) && defined(FILTER193) - (pData->iJHDRalphafilter != MNG_FILTER_DIFFERING) && - (pData->iJHDRalphafilter != MNG_FILTER_NOFILTER ) ) -#else -#ifdef FILTER192 - (pData->iJHDRalphafilter != MNG_FILTER_DIFFERING) ) -#else - (pData->iJHDRalphafilter != MNG_FILTER_NOFILTER ) ) -#endif -#endif - MNG_ERROR (pData, MNG_INVALIDFILTER); -#else - if (pData->iJHDRalphafilter) - MNG_ERROR (pData, MNG_INVALIDFILTER); -#endif - - } - else - { - if (pData->iJHDRalphabitdepth) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH); - if (pData->iJHDRalphacompression) - MNG_ERROR (pData, MNG_INVALIDCOMPRESS); - if (pData->iJHDRalphafilter) - MNG_ERROR (pData, MNG_INVALIDFILTER); - if (pData->iJHDRalphainterlace) - MNG_ERROR (pData, MNG_INVALIDINTERLACE); - } - - if (!pData->bHasheader) /* first chunk ? */ - { - pData->bHasheader = MNG_TRUE; /* we've got a header */ - pData->eImagetype = mng_it_jng; /* then this must be a JNG */ - pData->iWidth = ((mng_jhdrp)pChunk)->iWidth; - pData->iHeight = ((mng_jhdrp)pChunk)->iHeight; - /* predict alpha-depth ! */ - if ((pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) ) - pData->iAlphadepth = pData->iJHDRalphabitdepth; - else - pData->iAlphadepth = 0; - /* fits on maximum canvas ? */ - if ((pData->iWidth > pData->iMaxwidth) || (pData->iHeight > pData->iMaxheight)) - MNG_WARNING (pData, MNG_IMAGETOOLARGE); - - if (pData->fProcessheader) /* inform the app ? */ - if (!pData->fProcessheader (((mng_handle)pData), pData->iWidth, pData->iHeight)) - MNG_ERROR (pData, MNG_APPMISCERROR); - - } - - pData->iColortype = 0; /* fake grayscale for other routines */ - pData->iImagelevel++; /* one level deeper */ - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode = mng_process_display_jhdr (pData); - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_NO_16BIT_SUPPORT - if (((mng_jhdrp)pChunk)->iAlphasampledepth > 8) - ((mng_jhdrp)pChunk)->iAlphasampledepth = 8; -#endif - - return MNG_NOERROR; /* done */ -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -MNG_C_SPECIALFUNC (mng_special_jdaa) -{ - if (pData->iJHDRalphacompression != MNG_COMPRESSION_BASELINEJPEG) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - pData->bHasJDAA = MNG_TRUE; /* got some JDAA now, don't we */ - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -MNG_C_SPECIALFUNC (mng_special_jdat) -{ - pData->bHasJDAT = MNG_TRUE; /* got some JDAT now, don't we */ - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -MNG_C_SPECIALFUNC (mng_special_jsep) -{ - pData->bHasJSEP = MNG_TRUE; /* indicate we've had the 8-/12-bit separator */ - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ -/* ************************************************************************** */ -/* MNG chunks */ - -MNG_C_SPECIALFUNC (mng_special_mhdr) -{ - if (pData->bHasheader) /* can only be the first chunk! */ - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - pData->bHasMHDR = MNG_TRUE; /* oh boy, a real MNG */ - pData->bHasheader = MNG_TRUE; /* we've got a header */ - pData->eImagetype = mng_it_mng; /* fill header fields */ - pData->iWidth = ((mng_mhdrp)pChunk)->iWidth; - pData->iHeight = ((mng_mhdrp)pChunk)->iHeight; - pData->iTicks = ((mng_mhdrp)pChunk)->iTicks; - pData->iLayercount = ((mng_mhdrp)pChunk)->iLayercount; - pData->iFramecount = ((mng_mhdrp)pChunk)->iFramecount; - pData->iPlaytime = ((mng_mhdrp)pChunk)->iPlaytime; - pData->iSimplicity = ((mng_mhdrp)pChunk)->iSimplicity; -#ifndef MNG_NO_OLD_VERSIONS - pData->bPreDraft48 = MNG_FALSE; -#endif - /* predict alpha-depth */ - if ((pData->iSimplicity & 0x00000001) == 0) -#ifndef MNG_NO_16BIT_SUPPORT - pData->iAlphadepth = 16; /* no indicators = assume the worst */ -#else - pData->iAlphadepth = 8; /* anything else = assume the worst */ -#endif - else - if ((pData->iSimplicity & 0x00000008) == 0) - pData->iAlphadepth = 0; /* no transparency at all */ - else - if ((pData->iSimplicity & 0x00000140) == 0x00000040) - pData->iAlphadepth = 1; /* no semi-transparency guaranteed */ - else -#ifndef MNG_NO_16BIT_SUPPORT - pData->iAlphadepth = 16; /* anything else = assume the worst */ -#else - pData->iAlphadepth = 8; /* anything else = assume the worst */ -#endif - -#ifdef MNG_INCLUDE_JNG /* can we handle the complexity ? */ - if (pData->iSimplicity & 0x0000FC00) -#else - if (pData->iSimplicity & 0x0000FC10) -#endif - MNG_ERROR (pData, MNG_MNGTOOCOMPLEX); - /* fits on maximum canvas ? */ - if ((pData->iWidth > pData->iMaxwidth) || (pData->iHeight > pData->iMaxheight)) - MNG_WARNING (pData, MNG_IMAGETOOLARGE); - - if (pData->fProcessheader) /* inform the app ? */ - if (!pData->fProcessheader (((mng_handle)pData), pData->iWidth, pData->iHeight)) - MNG_ERROR (pData, MNG_APPMISCERROR); - - pData->iImagelevel++; /* one level deeper */ - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -MNG_C_SPECIALFUNC (mng_special_mend) -{ -#ifdef MNG_SUPPORT_DISPLAY - { /* do something */ - mng_retcode iRetcode = mng_process_display_mend (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (!pData->iTotalframes) /* save totals */ - pData->iTotalframes = pData->iFrameseq; - if (!pData->iTotallayers) - pData->iTotallayers = pData->iLayerseq; - if (!pData->iTotalplaytime) - pData->iTotalplaytime = pData->iFrametime; - } -#endif /* MNG_SUPPORT_DISPLAY */ - - pData->bHasMHDR = MNG_FALSE; /* end of the line, bro! */ - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_LOOP -MNG_F_SPECIALFUNC (mng_debunk_loop) -{ - mng_loopp pLOOP = (mng_loopp)pChunk; - mng_uint32 iRawlen = *piRawlen; - mng_uint8p pRawdata = *ppRawdata; - - if (iRawlen >= 5) /* length checks */ - { - if (iRawlen >= 6) - { - if ((iRawlen - 6) % 4 != 0) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } - } - else - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - if (iRawlen >= 5) /* store the fields */ - { - pLOOP->iLevel = *pRawdata; - -#ifndef MNG_NO_OLD_VERSIONS - if (pData->bPreDraft48) - { - pLOOP->iTermination = *(pRawdata+1); - pLOOP->iRepeat = mng_get_uint32 (pRawdata+2); - } - else -#endif - { - pLOOP->iRepeat = mng_get_uint32 (pRawdata+1); - } - - if (iRawlen >= 6) - { -#ifndef MNG_NO_OLD_VERSIONS - if (!pData->bPreDraft48) -#endif - pLOOP->iTermination = *(pRawdata+5); - - if (iRawlen >= 10) - { - pLOOP->iItermin = mng_get_uint32 (pRawdata+6); - -#ifndef MNG_NO_LOOP_SIGNALS_SUPPORTED - if (iRawlen >= 14) - { - pLOOP->iItermax = mng_get_uint32 (pRawdata+10); - pLOOP->iCount = (iRawlen - 14) / 4; - - if (pLOOP->iCount) - { - MNG_ALLOC (pData, pLOOP->pSignals, pLOOP->iCount << 2); - -#ifndef MNG_BIGENDIAN_SUPPORTED - { - mng_uint32 iX; - mng_uint8p pIn = pRawdata + 14; - mng_uint32p pOut = (mng_uint32p)pLOOP->pSignals; - - for (iX = 0; iX < pLOOP->iCount; iX++) - { - *pOut++ = mng_get_uint32 (pIn); - pIn += 4; - } - } -#else - MNG_COPY (pLOOP->pSignals, pRawdata + 14, pLOOP->iCount << 2); -#endif /* !MNG_BIGENDIAN_SUPPORTED */ - } - } -#endif - } - } - } - - *piRawlen = 0; - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_LOOP -MNG_C_SPECIALFUNC (mng_special_loop) -{ - if (!pData->bCacheplayback) /* must store playback info to work!! */ - MNG_ERROR (pData, MNG_LOOPWITHCACHEOFF); - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode; - - pData->bHasLOOP = MNG_TRUE; /* indicate we're inside a loop */ - /* create the LOOP ani-object */ - iRetcode = mng_create_ani_loop (pData, pChunk); - if (iRetcode) /* on error bail out */ - return iRetcode; - /* skip till matching ENDL if iteration=0 */ - if ((!pData->bSkipping) && (((mng_loopp)pChunk)->iRepeat == 0)) - pData->bSkipping = MNG_TRUE; - } -#endif /* MNG_SUPPORT_DISPLAY */ - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_LOOP -MNG_C_SPECIALFUNC (mng_special_endl) -{ -#ifdef MNG_SUPPORT_DISPLAY - if (pData->bHasLOOP) /* are we really processing a loop ? */ - { - mng_uint8 iLevel = ((mng_endlp)pChunk)->iLevel; - /* create an ENDL animation object */ - return mng_create_ani_endl (pData, iLevel); - } - else - MNG_ERROR (pData, MNG_NOMATCHINGLOOP); -#endif /* MNG_SUPPORT_DISPLAY */ - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_DEFI -MNG_C_SPECIALFUNC (mng_special_defi) -{ -#ifdef MNG_SUPPORT_DISPLAY - mng_retcode iRetcode; - - pData->iDEFIobjectid = ((mng_defip)pChunk)->iObjectid; - pData->bDEFIhasdonotshow = ((mng_defip)pChunk)->bHasdonotshow; - pData->iDEFIdonotshow = ((mng_defip)pChunk)->iDonotshow; - pData->bDEFIhasconcrete = ((mng_defip)pChunk)->bHasconcrete; - pData->iDEFIconcrete = ((mng_defip)pChunk)->iConcrete; - pData->bDEFIhasloca = ((mng_defip)pChunk)->bHasloca; - pData->iDEFIlocax = ((mng_defip)pChunk)->iXlocation; - pData->iDEFIlocay = ((mng_defip)pChunk)->iYlocation; - pData->bDEFIhasclip = ((mng_defip)pChunk)->bHasclip; - pData->iDEFIclipl = ((mng_defip)pChunk)->iLeftcb; - pData->iDEFIclipr = ((mng_defip)pChunk)->iRightcb; - pData->iDEFIclipt = ((mng_defip)pChunk)->iTopcb; - pData->iDEFIclipb = ((mng_defip)pChunk)->iBottomcb; - /* create an animation object */ - iRetcode = mng_create_ani_defi (pData); - if (!iRetcode) /* do display processing */ - iRetcode = mng_process_display_defi (pData); - return iRetcode; -#else - return MNG_NOERROR; /* done */ -#endif /* MNG_SUPPORT_DISPLAY */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_BASI -MNG_C_SPECIALFUNC (mng_special_basi) -{ - pData->bHasBASI = MNG_TRUE; /* inside a BASI-IEND block now */ - /* store interesting fields */ - pData->iDatawidth = ((mng_basip)pChunk)->iWidth; - pData->iDataheight = ((mng_basip)pChunk)->iHeight; - pData->iBitdepth = ((mng_basip)pChunk)->iBitdepth; - pData->iColortype = ((mng_basip)pChunk)->iColortype; - pData->iCompression = ((mng_basip)pChunk)->iCompression; - pData->iFilter = ((mng_basip)pChunk)->iFilter; - pData->iInterlace = ((mng_basip)pChunk)->iInterlace; - -#if defined(MNG_NO_1_2_4BIT_SUPPORT) || defined(MNG_NO_16BIT_SUPPORT) - pData->iPNGmult = 1; - pData->iPNGdepth = pData->iBitdepth; -#endif - -#ifdef MNG_NO_1_2_4BIT_SUPPORT - if (pData->iBitdepth < 8) - pData->iBitdepth = 8; -#endif -#ifdef MNG_NO_16BIT_SUPPORT - if (pData->iBitdepth > 8) - { - pData->iBitdepth = 8; - pData->iPNGmult = 2; - } -#endif - - if ((pData->iBitdepth != 8) /* parameter validity checks */ -#ifndef MNG_NO_1_2_4BIT_SUPPORT - && (pData->iBitdepth != 1) && - (pData->iBitdepth != 2) && - (pData->iBitdepth != 4) -#endif -#ifndef MNG_NO_16BIT_SUPPORT - && (pData->iBitdepth != 16) -#endif - ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH); - - if ((pData->iColortype != MNG_COLORTYPE_GRAY ) && - (pData->iColortype != MNG_COLORTYPE_RGB ) && - (pData->iColortype != MNG_COLORTYPE_INDEXED) && - (pData->iColortype != MNG_COLORTYPE_GRAYA ) && - (pData->iColortype != MNG_COLORTYPE_RGBA ) ) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE); - - if ((pData->iColortype == MNG_COLORTYPE_INDEXED) && (pData->iBitdepth > 8)) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH); - - if (((pData->iColortype == MNG_COLORTYPE_RGB ) || - (pData->iColortype == MNG_COLORTYPE_GRAYA ) || - (pData->iColortype == MNG_COLORTYPE_RGBA ) ) && - (pData->iBitdepth < 8 ) ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH); - -#if defined(FILTER192) || defined(FILTER193) - if ((pData->iFilter != MNG_FILTER_ADAPTIVE ) && -#if defined(FILTER192) && defined(FILTER193) - (pData->iFilter != MNG_FILTER_DIFFERING) && - (pData->iFilter != MNG_FILTER_NOFILTER ) ) -#else -#ifdef FILTER192 - (pData->iFilter != MNG_FILTER_DIFFERING) ) -#else - (pData->iFilter != MNG_FILTER_NOFILTER ) ) -#endif -#endif - MNG_ERROR (pData, MNG_INVALIDFILTER); -#else - if (pData->iFilter) - MNG_ERROR (pData, MNG_INVALIDFILTER); -#endif - - pData->iImagelevel++; /* one level deeper */ - -#ifdef MNG_SUPPORT_DISPLAY - { /* create an animation object */ - mng_retcode iRetcode = mng_create_ani_basi (pData, pChunk); - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_NO_16BIT_SUPPORT - if (((mng_basip)pChunk)->iBitdepth > 8) - ((mng_basip)pChunk)->iBitdepth = 8; -#endif - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_CLON -MNG_C_SPECIALFUNC (mng_special_clon) -{ -#ifdef MNG_SUPPORT_DISPLAY - return mng_create_ani_clon (pData, pChunk); -#else - return MNG_NOERROR; /* done */ -#endif /* MNG_SUPPORT_DISPLAY */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_PAST -MNG_F_SPECIALFUNC (mng_debunk_past) -{ - mng_pastp pPAST = (mng_pastp)pChunk; - mng_uint32 iRawlen = *piRawlen; - mng_uint8p pRawdata = *ppRawdata; - mng_uint32 iSize; - mng_uint32 iX; - mng_past_sourcep pSource; - /* check the length */ - if ((iRawlen < 41) || (((iRawlen - 11) % 30) != 0)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - pPAST->iDestid = mng_get_uint16 (pRawdata); - pPAST->iTargettype = *(pRawdata+2); - pPAST->iTargetx = mng_get_int32 (pRawdata+3); - pPAST->iTargety = mng_get_int32 (pRawdata+7); - pPAST->iCount = ((iRawlen - 11) / 30); /* how many entries again? */ - iSize = pPAST->iCount * sizeof (mng_past_source); - - pRawdata += 11; - /* get a buffer for all the source blocks */ - MNG_ALLOC (pData, pPAST->pSources, iSize); - - pSource = (mng_past_sourcep)(pPAST->pSources); - - for (iX = pPAST->iCount; iX > 0; iX--) - { /* now copy the source blocks */ - pSource->iSourceid = mng_get_uint16 (pRawdata); - pSource->iComposition = *(pRawdata+2); - pSource->iOrientation = *(pRawdata+3); - pSource->iOffsettype = *(pRawdata+4); - pSource->iOffsetx = mng_get_int32 (pRawdata+5); - pSource->iOffsety = mng_get_int32 (pRawdata+9); - pSource->iBoundarytype = *(pRawdata+13); - pSource->iBoundaryl = mng_get_int32 (pRawdata+14); - pSource->iBoundaryr = mng_get_int32 (pRawdata+18); - pSource->iBoundaryt = mng_get_int32 (pRawdata+22); - pSource->iBoundaryb = mng_get_int32 (pRawdata+26); - - pSource++; - pRawdata += 30; - } - - *piRawlen = 0; - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_PAST -MNG_C_SPECIALFUNC (mng_special_past) -{ -#ifdef MNG_SUPPORT_DISPLAY - return mng_create_ani_past (pData, pChunk); -#else - return MNG_NOERROR; -#endif /* MNG_SUPPORT_DISPLAY */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_DISC -MNG_F_SPECIALFUNC (mng_disc_entries) -{ - mng_discp pDISC = (mng_discp)pChunk; - mng_uint32 iRawlen = *piRawlen; - mng_uint8p pRawdata = *ppRawdata; - - if ((iRawlen % 2) != 0) /* check the length */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - pDISC->iCount = (iRawlen / sizeof (mng_uint16)); - - if (pDISC->iCount) - { - MNG_ALLOC (pData, pDISC->pObjectids, iRawlen); - -#ifndef MNG_BIGENDIAN_SUPPORTED - { - mng_uint32 iX; - mng_uint8p pIn = pRawdata; - mng_uint16p pOut = pDISC->pObjectids; - - for (iX = pDISC->iCount; iX > 0; iX--) - { - *pOut++ = mng_get_uint16 (pIn); - pIn += 2; - } - } -#else - MNG_COPY (pDISC->pObjectids, pRawdata, iRawlen); -#endif /* !MNG_BIGENDIAN_SUPPORTED */ - } - - *piRawlen = 0; - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_DISC -MNG_C_SPECIALFUNC (mng_special_disc) -{ -#ifdef MNG_SUPPORT_DISPLAY - return mng_create_ani_disc (pData, pChunk); -#else - return MNG_NOERROR; -#endif /* MNG_SUPPORT_DISPLAY */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_BACK -MNG_C_SPECIALFUNC (mng_special_back) -{ -#ifdef MNG_SUPPORT_DISPLAY - /* retrieve the fields */ - pData->bHasBACK = MNG_TRUE; - pData->iBACKred = ((mng_backp)pChunk)->iRed; - pData->iBACKgreen = ((mng_backp)pChunk)->iGreen; - pData->iBACKblue = ((mng_backp)pChunk)->iBlue; - pData->iBACKmandatory = ((mng_backp)pChunk)->iMandatory; - pData->iBACKimageid = ((mng_backp)pChunk)->iImageid; - pData->iBACKtile = ((mng_backp)pChunk)->iTile; - - return mng_create_ani_back (pData); -#else - return MNG_NOERROR; -#endif /* MNG_SUPPORT_DISPLAY */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_FRAM -MNG_F_SPECIALFUNC (mng_fram_remainder) -{ - mng_framp pFRAM = (mng_framp)pChunk; - mng_uint32 iRawlen = *piRawlen; - mng_uint8p pRawdata = *ppRawdata; - mng_uint32 iRequired = 0; - - if (iRawlen < 4) /* must have at least 4 bytes */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - iRequired = 4; /* calculate and check required remaining length */ - - pFRAM->iChangedelay = *pRawdata; - pFRAM->iChangetimeout = *(pRawdata+1); - pFRAM->iChangeclipping = *(pRawdata+2); - pFRAM->iChangesyncid = *(pRawdata+3); - - if (pFRAM->iChangedelay ) { iRequired += 4; } - if (pFRAM->iChangetimeout ) { iRequired += 4; } - if (pFRAM->iChangeclipping) { iRequired += 17; } - - if (pFRAM->iChangesyncid) - { - if ((iRawlen - iRequired) % 4 != 0) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } - else - { - if (iRawlen != iRequired) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } - - pRawdata += 4; - - if (pFRAM->iChangedelay) /* delay changed ? */ - { - pFRAM->iDelay = mng_get_uint32 (pRawdata); - pRawdata += 4; - } - - if (pFRAM->iChangetimeout) /* timeout changed ? */ - { - pFRAM->iTimeout = mng_get_uint32 (pRawdata); - pRawdata += 4; - } - - if (pFRAM->iChangeclipping) /* clipping changed ? */ - { - pFRAM->iBoundarytype = *pRawdata; - pFRAM->iBoundaryl = mng_get_int32 (pRawdata+1); - pFRAM->iBoundaryr = mng_get_int32 (pRawdata+5); - pFRAM->iBoundaryt = mng_get_int32 (pRawdata+9); - pFRAM->iBoundaryb = mng_get_int32 (pRawdata+13); - pRawdata += 17; - } - - if (pFRAM->iChangesyncid) - { - pFRAM->iCount = (iRawlen - iRequired) / 4; - - if (pFRAM->iCount) - { - MNG_ALLOC (pData, pFRAM->pSyncids, pFRAM->iCount * 4); - -#ifndef MNG_BIGENDIAN_SUPPORTED - { - mng_uint32 iX; - mng_uint32p pOut = pFRAM->pSyncids; - - for (iX = pFRAM->iCount; iX > 0; iX--) - { - *pOut++ = mng_get_uint32 (pRawdata); - pRawdata += 4; - } - } -#else - MNG_COPY (pFRAM->pSyncids, pRawdata, pFRAM->iCount * 4); -#endif /* !MNG_BIGENDIAN_SUPPORTED */ - } - } - -#ifndef MNG_NO_OLD_VERSIONS - if (pData->bPreDraft48) /* old style input-stream ? */ - { - switch (pFRAM->iMode) /* fix the framing mode then */ - { - case 0: { break; } - case 1: { pFRAM->iMode = 3; break; } - case 2: { pFRAM->iMode = 4; break; } - case 3: { pFRAM->iMode = 1; break; } - case 4: { pFRAM->iMode = 1; break; } - case 5: { pFRAM->iMode = 2; break; } - default: { pFRAM->iMode = 1; break; } - } - } -#endif - - *piRawlen = 0; - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_FRAM -MNG_C_SPECIALFUNC (mng_special_fram) -{ -#ifdef MNG_SUPPORT_DISPLAY - return mng_create_ani_fram (pData, pChunk); -#else - return MNG_NOERROR; -#endif /* MNG_SUPPORT_DISPLAY */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_MOVE -MNG_C_SPECIALFUNC (mng_special_move) -{ -#ifdef MNG_SUPPORT_DISPLAY - return mng_create_ani_move (pData, pChunk); -#else - return MNG_NOERROR; -#endif /* MNG_SUPPORT_DISPLAY */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_CLIP -MNG_C_SPECIALFUNC (mng_special_clip) -{ -#ifdef MNG_SUPPORT_DISPLAY - return mng_create_ani_clip (pData, pChunk); -#else - return MNG_NOERROR; -#endif /* MNG_SUPPORT_DISPLAY */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SHOW -MNG_C_SPECIALFUNC (mng_special_show) -{ -#ifdef MNG_SUPPORT_DISPLAY - mng_retcode iRetcode; - - if (!((mng_showp)pChunk)->bEmpty) /* any data ? */ - { - if (!((mng_showp)pChunk)->bHaslastid) - ((mng_showp)pChunk)->iLastid = ((mng_showp)pChunk)->iFirstid; - - pData->iSHOWfromid = ((mng_showp)pChunk)->iFirstid; - pData->iSHOWtoid = ((mng_showp)pChunk)->iLastid; - pData->iSHOWmode = ((mng_showp)pChunk)->iMode; - } - else /* use defaults then */ - { - pData->iSHOWfromid = 1; - pData->iSHOWtoid = 65535; - pData->iSHOWmode = 2; - } - /* create a SHOW animation object */ - iRetcode = mng_create_ani_show (pData); - if (!iRetcode) /* go and do it! */ - iRetcode = mng_process_display_show (pData); - -#endif /* MNG_SUPPORT_DISPLAY */ - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_TERM -MNG_C_SPECIALFUNC (mng_special_term) -{ - /* should be behind MHDR or SAVE !! */ - if ((!pData->bHasSAVE) && (pData->iChunkseq > 2)) - { - pData->bMisplacedTERM = MNG_TRUE; /* indicate we found a misplaced TERM */ - /* and send a warning signal!!! */ - MNG_WARNING (pData, MNG_SEQUENCEERROR); - } - - pData->bHasTERM = MNG_TRUE; - - if (pData->fProcessterm) /* inform the app ? */ - if (!pData->fProcessterm (((mng_handle)pData), - ((mng_termp)pChunk)->iTermaction, - ((mng_termp)pChunk)->iIteraction, - ((mng_termp)pChunk)->iDelay, - ((mng_termp)pChunk)->iItermax)) - MNG_ERROR (pData, MNG_APPMISCERROR); - -#ifdef MNG_SUPPORT_DISPLAY - { /* create the TERM ani-object */ - mng_retcode iRetcode = mng_create_ani_term (pData, pChunk); - if (iRetcode) /* on error bail out */ - return iRetcode; - /* save for future reference */ - pData->pTermaniobj = pData->pLastaniobj; - } -#endif /* MNG_SUPPORT_DISPLAY */ - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SAVE -MNG_F_SPECIALFUNC (mng_save_entries) -{ - mng_savep pSAVE = (mng_savep)pChunk; - mng_uint32 iRawlen = *piRawlen; - mng_uint8p pRawdata = *ppRawdata; - mng_save_entryp pEntry = MNG_NULL; - mng_uint32 iCount = 0; - mng_uint8 iOtype = *pRawdata; - mng_uint8 iEtype; - mng_uint8p pTemp; - mng_uint8p pNull; - mng_uint32 iLen; - mng_uint32 iOffset[2]; - mng_uint32 iStarttime[2]; - mng_uint32 iFramenr; - mng_uint32 iLayernr; - mng_uint32 iX; - mng_uint32 iNamesize; - - if ((iOtype != 4) && (iOtype != 8)) - MNG_ERROR (pData, MNG_INVOFFSETSIZE); - - pSAVE->iOffsettype = iOtype; - - for (iX = 0; iX < 2; iX++) /* do this twice to get the count first ! */ - { - pTemp = pRawdata + 1; - iLen = iRawlen - 1; - - if (iX) /* second run ? */ - { - MNG_ALLOC (pData, pEntry, (iCount * sizeof (mng_save_entry))); - - pSAVE->iCount = iCount; - pSAVE->pEntries = pEntry; - } - - while (iLen) /* anything left ? */ - { - iEtype = *pTemp; /* entrytype */ - - if ((iEtype != 0) && (iEtype != 1) && (iEtype != 2) && (iEtype != 3)) - MNG_ERROR (pData, MNG_INVENTRYTYPE); - - pTemp++; - - if (iEtype > 1) - { - iOffset [0] = 0; - iOffset [1] = 0; - iStarttime [0] = 0; - iStarttime [1] = 0; - iLayernr = 0; - iFramenr = 0; - } - else - { - if (iOtype == 4) - { - iOffset [0] = 0; - iOffset [1] = mng_get_uint32 (pTemp); - - pTemp += 4; - } - else - { - iOffset [0] = mng_get_uint32 (pTemp); - iOffset [1] = mng_get_uint32 (pTemp+4); - - pTemp += 8; - } - - if (iEtype > 0) - { - iStarttime [0] = 0; - iStarttime [1] = 0; - iLayernr = 0; - iFramenr = 0; - } - else - { - if (iOtype == 4) - { - iStarttime [0] = 0; - iStarttime [1] = mng_get_uint32 (pTemp+0); - iLayernr = mng_get_uint32 (pTemp+4); - iFramenr = mng_get_uint32 (pTemp+8); - - pTemp += 12; - } - else - { - iStarttime [0] = mng_get_uint32 (pTemp+0); - iStarttime [1] = mng_get_uint32 (pTemp+4); - iLayernr = mng_get_uint32 (pTemp+8); - iFramenr = mng_get_uint32 (pTemp+12); - - pTemp += 16; - } - } - } - - pNull = pTemp; /* get the name length */ - while (*pNull) - pNull++; - - if ((pNull - pRawdata) > (mng_int32)iRawlen) - { - iNamesize = iLen; /* no null found; so end of SAVE */ - iLen = 0; - } - else - { - iNamesize = pNull - pTemp; /* should be another entry */ - iLen -= iNamesize; - - if (!iLen) /* must not end with a null ! */ - MNG_ERROR (pData, MNG_ENDWITHNULL); - } - - if (!pEntry) - { - iCount++; - } - else - { - pEntry->iEntrytype = iEtype; - pEntry->iOffset [0] = iOffset [0]; - pEntry->iOffset [1] = iOffset [1]; - pEntry->iStarttime [0] = iStarttime [0]; - pEntry->iStarttime [1] = iStarttime [1]; - pEntry->iLayernr = iLayernr; - pEntry->iFramenr = iFramenr; - pEntry->iNamesize = iNamesize; - - if (iNamesize) - { - MNG_ALLOC (pData, pEntry->zName, iNamesize+1); - MNG_COPY (pEntry->zName, pTemp, iNamesize); - } - - pEntry++; - } - - pTemp += iNamesize; - } - } - - *piRawlen = 0; - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SAVE -MNG_C_SPECIALFUNC (mng_special_save) -{ - pData->bHasSAVE = MNG_TRUE; - - if (pData->fProcesssave) /* inform the application ? */ - { - mng_bool bOke = pData->fProcesssave ((mng_handle)pData); - if (!bOke) - MNG_ERROR (pData, MNG_APPMISCERROR); - } - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode; - - /* TODO: something with the parameters */ - - /* create a SAVE animation object */ - iRetcode = mng_create_ani_save (pData); - if (!iRetcode) /* process it */ - iRetcode = mng_process_display_save (pData); - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SEEK -MNG_C_SPECIALFUNC (mng_special_seek) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_DISPLAY - /* create a SEEK animation object */ - iRetcode = mng_create_ani_seek (pData, pChunk); - if (iRetcode) /* on error bail out */ - return iRetcode; - -#endif /* MNG_SUPPORT_DISPLAY */ - - if (pData->fProcessseek) /* inform the app ? */ - if (!pData->fProcessseek ((mng_handle)pData, ((mng_seekp)pChunk)->zName)) - MNG_ERROR (pData, MNG_APPMISCERROR); - -#ifdef MNG_SUPPORT_DISPLAY - return mng_process_display_seek (pData); -#else - return MNG_NOERROR; -#endif /* MNG_SUPPORT_DISPLAY */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_eXPI -MNG_C_SPECIALFUNC (mng_special_expi) -{ -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_fPRI -MNG_C_SPECIALFUNC (mng_special_fpri) -{ -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_nEED -MNG_LOCAL mng_bool CheckKeyword (mng_datap pData, - mng_uint8p pKeyword) -{ - mng_chunkid handled_chunks [] = - { - MNG_UINT_BACK, /* keep it sorted !!!! */ - MNG_UINT_BASI, - MNG_UINT_CLIP, - MNG_UINT_CLON, -#ifndef MNG_NO_DELTA_PNG -/* TODO: MNG_UINT_DBYK, */ -#endif - MNG_UINT_DEFI, -#ifndef MNG_NO_DELTA_PNG - MNG_UINT_DHDR, -#endif - MNG_UINT_DISC, -#ifndef MNG_NO_DELTA_PNG -/* TODO: MNG_UINT_DROP, */ -#endif - MNG_UINT_ENDL, - MNG_UINT_FRAM, - MNG_UINT_IDAT, - MNG_UINT_IEND, - MNG_UINT_IHDR, -#ifndef MNG_NO_DELTA_PNG -#ifdef MNG_INCLUDE_JNG - MNG_UINT_IJNG, -#endif - MNG_UINT_IPNG, -#endif -#ifdef MNG_INCLUDE_JNG - MNG_UINT_JDAA, - MNG_UINT_JDAT, - MNG_UINT_JHDR, -/* TODO: MNG_UINT_JSEP, */ - MNG_UINT_JdAA, -#endif - MNG_UINT_LOOP, - MNG_UINT_MAGN, - MNG_UINT_MEND, - MNG_UINT_MHDR, - MNG_UINT_MOVE, -/* TODO: MNG_UINT_ORDR, */ - MNG_UINT_PAST, - MNG_UINT_PLTE, -#ifndef MNG_NO_DELTA_PNG - MNG_UINT_PPLT, - MNG_UINT_PROM, -#endif - MNG_UINT_SAVE, - MNG_UINT_SEEK, - MNG_UINT_SHOW, - MNG_UINT_TERM, - MNG_UINT_bKGD, - MNG_UINT_cHRM, -/* TODO: MNG_UINT_eXPI, */ - MNG_UINT_evNT, -/* TODO: MNG_UINT_fPRI, */ - MNG_UINT_gAMA, -/* TODO: MNG_UINT_hIST, */ - MNG_UINT_iCCP, - MNG_UINT_iTXt, - MNG_UINT_nEED, -/* TODO: MNG_UINT_oFFs, */ -/* TODO: MNG_UINT_pCAL, */ -/* TODO: MNG_UINT_pHYg, */ -/* TODO: MNG_UINT_pHYs, */ -/* TODO: MNG_UINT_sBIT, */ -/* TODO: MNG_UINT_sCAL, */ -/* TODO: MNG_UINT_sPLT, */ - MNG_UINT_sRGB, - MNG_UINT_tEXt, - MNG_UINT_tIME, - MNG_UINT_tRNS, - MNG_UINT_zTXt, - }; - - mng_bool bOke = MNG_FALSE; - - if (pData->fProcessneed) /* does the app handle it ? */ - bOke = pData->fProcessneed ((mng_handle)pData, (mng_pchar)pKeyword); - - if (!bOke) - { /* find the keyword length */ - mng_uint8p pNull = pKeyword; - while (*pNull) - pNull++; - - if ((pNull - pKeyword) == 4) /* test a chunk ? */ - { /* get the chunk-id */ - mng_chunkid iChunkid = (*pKeyword << 24) + (*(pKeyword+1) << 16) + - (*(pKeyword+2) << 8) + (*(pKeyword+3) ); - /* binary search variables */ - mng_int32 iTop, iLower, iUpper, iMiddle; - /* determine max index of table */ - iTop = (sizeof (handled_chunks) / sizeof (handled_chunks [0])) - 1; - - /* binary search; with 52 chunks, worst-case is 7 comparisons */ - iLower = 0; - iMiddle = iTop >> 1; - iUpper = iTop; - - do /* the binary search itself */ - { - if (handled_chunks [iMiddle] < iChunkid) - iLower = iMiddle + 1; - else if (handled_chunks [iMiddle] > iChunkid) - iUpper = iMiddle - 1; - else - { - bOke = MNG_TRUE; - break; - } - - iMiddle = (iLower + iUpper) >> 1; - } - while (iLower <= iUpper); - } - /* test draft ? */ - if ((!bOke) && ((pNull - pKeyword) == 8) && - (*pKeyword == 'd') && (*(pKeyword+1) == 'r') && - (*(pKeyword+2) == 'a') && (*(pKeyword+3) == 'f') && - (*(pKeyword+4) == 't') && (*(pKeyword+5) == ' ')) - { - mng_uint32 iDraft; - - iDraft = (*(pKeyword+6) - '0') * 10 + (*(pKeyword+7) - '0'); - bOke = (mng_bool)(iDraft <= MNG_MNG_DRAFT); - } - /* test MNG 1.0/1.1 ? */ - if ((!bOke) && ((pNull - pKeyword) == 7) && - (*pKeyword == 'M') && (*(pKeyword+1) == 'N') && - (*(pKeyword+2) == 'G') && (*(pKeyword+3) == '-') && - (*(pKeyword+4) == '1') && (*(pKeyword+5) == '.') && - ((*(pKeyword+6) == '0') || (*(pKeyword+6) == '1'))) - bOke = MNG_TRUE; - /* test CACHEOFF ? */ - if ((!bOke) && ((pNull - pKeyword) == 8) && - (*pKeyword == 'C') && (*(pKeyword+1) == 'A') && - (*(pKeyword+2) == 'C') && (*(pKeyword+3) == 'H') && - (*(pKeyword+4) == 'E') && (*(pKeyword+5) == 'O') && - (*(pKeyword+6) == 'F') && (*(pKeyword+7) == 'F')) - { - if (!pData->pFirstaniobj) /* only if caching hasn't started yet ! */ - { - bOke = MNG_TRUE; - pData->bCacheplayback = MNG_FALSE; - pData->bStorechunks = MNG_FALSE; - } - } - } - - return bOke; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_nEED -MNG_C_SPECIALFUNC (mng_special_need) -{ - /* let's check it */ - mng_bool bOke = MNG_TRUE; - mng_uint8p pNull, pTemp, pMax; - - pTemp = (mng_uint8p)((mng_needp)pChunk)->zKeywords; - pMax = (mng_uint8p)(pTemp + ((mng_needp)pChunk)->iKeywordssize); - pNull = pTemp; - while (*pNull) - pNull++; - - while ((bOke) && (pNull < pMax)) - { - bOke = CheckKeyword (pData, pTemp); - pTemp = pNull + 1; - pNull = pTemp; - while (*pNull) - pNull++; - } - - if (bOke) - bOke = CheckKeyword (pData, pTemp); - - if (!bOke) - MNG_ERROR (pData, MNG_UNSUPPORTEDNEED); - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_pHYg -MNG_C_SPECIALFUNC (mng_special_phyg) -{ -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -MNG_C_SPECIALFUNC (mng_special_dhdr) -{ - if ((((mng_dhdrp)pChunk)->iDeltatype == MNG_DELTATYPE_REPLACE) && (((mng_dhdrp)pChunk)->bHasblockloc)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - if ((((mng_dhdrp)pChunk)->iDeltatype == MNG_DELTATYPE_NOCHANGE) && (((mng_dhdrp)pChunk)->bHasblocksize)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - pData->bHasDHDR = MNG_TRUE; /* inside a DHDR-IEND block now */ - pData->iDeltatype = ((mng_dhdrp)pChunk)->iDeltatype; - - pData->iImagelevel++; /* one level deeper */ - -#ifdef MNG_SUPPORT_DISPLAY - return mng_create_ani_dhdr (pData, pChunk); -#else - return MNG_NOERROR; -#endif /* MNG_SUPPORT_DISPLAY */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -MNG_C_SPECIALFUNC (mng_special_prom) -{ - if ((((mng_promp)pChunk)->iColortype != MNG_COLORTYPE_GRAY ) && - (((mng_promp)pChunk)->iColortype != MNG_COLORTYPE_RGB ) && - (((mng_promp)pChunk)->iColortype != MNG_COLORTYPE_INDEXED) && - (((mng_promp)pChunk)->iColortype != MNG_COLORTYPE_GRAYA ) && - (((mng_promp)pChunk)->iColortype != MNG_COLORTYPE_RGBA ) ) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE); - -#ifdef MNG_NO_16BIT_SUPPORT - if (((mng_promp)pChunk)->iSampledepth == MNG_BITDEPTH_16 ) - ((mng_promp)pChunk)->iSampledepth = MNG_BITDEPTH_8; -#endif - - if ((((mng_promp)pChunk)->iSampledepth != MNG_BITDEPTH_1 ) && - (((mng_promp)pChunk)->iSampledepth != MNG_BITDEPTH_2 ) && - (((mng_promp)pChunk)->iSampledepth != MNG_BITDEPTH_4 ) && - (((mng_promp)pChunk)->iSampledepth != MNG_BITDEPTH_8 ) -#ifndef MNG_NO_16BIT_SUPPORT - && (((mng_promp)pChunk)->iSampledepth != MNG_BITDEPTH_16) -#endif - ) - MNG_ERROR (pData, MNG_INVSAMPLEDEPTH); - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode = mng_create_ani_prom (pData, pChunk); - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -MNG_C_SPECIALFUNC (mng_special_ipng) -{ -#ifdef MNG_SUPPORT_DISPLAY - mng_retcode iRetcode = mng_create_ani_ipng (pData); - if (!iRetcode) /* process it */ - iRetcode = mng_process_display_ipng (pData); - if (iRetcode) /* on error bail out */ - return iRetcode; -#endif /* MNG_SUPPORT_DISPLAY */ - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -MNG_F_SPECIALFUNC (mng_pplt_entries) -{ - mng_ppltp pPPLT = (mng_ppltp)pChunk; - mng_uint32 iRawlen = *piRawlen; - mng_uint8p pRawdata = *ppRawdata; - mng_uint8 iDeltatype = pPPLT->iDeltatype; - mng_uint32 iMax = 0; - mng_int32 iX, iY, iM; - mng_rgbpaltab aIndexentries; - mng_uint8arr aAlphaentries; - mng_uint8arr aUsedentries; - /* must be indexed color ! */ - if (pData->iColortype != MNG_COLORTYPE_INDEXED) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE); - - for (iY = 255; iY >= 0; iY--) /* reset arrays */ - { - aIndexentries [iY].iRed = 0; - aIndexentries [iY].iGreen = 0; - aIndexentries [iY].iBlue = 0; - aAlphaentries [iY] = 255; - aUsedentries [iY] = 0; - } - - while (iRawlen) /* as long as there are entries left ... */ - { - mng_uint32 iDiff; - - if (iRawlen < 2) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - iX = (mng_int32)(*pRawdata); /* get start and end index */ - iM = (mng_int32)(*(pRawdata+1)); - - if (iM < iX) - MNG_ERROR (pData, MNG_INVALIDINDEX); - - if (iM >= (mng_int32) iMax) /* determine highest used index */ - iMax = iM + 1; - - pRawdata += 2; - iRawlen -= 2; - iDiff = (iM - iX + 1); - if ((iDeltatype == MNG_DELTATYPE_REPLACERGB ) || - (iDeltatype == MNG_DELTATYPE_DELTARGB ) ) - iDiff = iDiff * 3; - else - if ((iDeltatype == MNG_DELTATYPE_REPLACERGBA) || - (iDeltatype == MNG_DELTATYPE_DELTARGBA ) ) - iDiff = iDiff * 4; - - if (iRawlen < iDiff) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - if ((iDeltatype == MNG_DELTATYPE_REPLACERGB ) || - (iDeltatype == MNG_DELTATYPE_DELTARGB ) ) - { - for (iY = iX; iY <= iM; iY++) - { - aIndexentries [iY].iRed = *pRawdata; - aIndexentries [iY].iGreen = *(pRawdata+1); - aIndexentries [iY].iBlue = *(pRawdata+2); - aUsedentries [iY] = 1; - - pRawdata += 3; - iRawlen -= 3; - } - } - else - if ((iDeltatype == MNG_DELTATYPE_REPLACEALPHA) || - (iDeltatype == MNG_DELTATYPE_DELTAALPHA ) ) - { - for (iY = iX; iY <= iM; iY++) - { - aAlphaentries [iY] = *pRawdata; - aUsedentries [iY] = 1; - - pRawdata++; - iRawlen--; - } - } - else - { - for (iY = iX; iY <= iM; iY++) - { - aIndexentries [iY].iRed = *pRawdata; - aIndexentries [iY].iGreen = *(pRawdata+1); - aIndexentries [iY].iBlue = *(pRawdata+2); - aAlphaentries [iY] = *(pRawdata+3); - aUsedentries [iY] = 1; - - pRawdata += 4; - iRawlen -= 4; - } - } - } - - switch (pData->iBitdepth) /* check maximum allowed entries for bitdepth */ - { - case MNG_BITDEPTH_1 : { - if (iMax > 2) - MNG_ERROR (pData, MNG_INVALIDINDEX); - break; - } - case MNG_BITDEPTH_2 : { - if (iMax > 4) - MNG_ERROR (pData, MNG_INVALIDINDEX); - break; - } - case MNG_BITDEPTH_4 : { - if (iMax > 16) - MNG_ERROR (pData, MNG_INVALIDINDEX); - break; - } - } - - pPPLT->iCount = iMax; - - for (iY = 255; iY >= 0; iY--) - { - pPPLT->aEntries [iY].iRed = aIndexentries [iY].iRed; - pPPLT->aEntries [iY].iGreen = aIndexentries [iY].iGreen; - pPPLT->aEntries [iY].iBlue = aIndexentries [iY].iBlue; - pPPLT->aEntries [iY].iAlpha = aAlphaentries [iY]; - pPPLT->aEntries [iY].bUsed = (mng_bool)(aUsedentries [iY]); - } - - { /* create animation object */ - mng_retcode iRetcode = mng_create_ani_pplt (pData, iDeltatype, iMax, - aIndexentries, aAlphaentries, - aUsedentries); - if (iRetcode) - return iRetcode; - } - - *piRawlen = 0; - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -MNG_C_SPECIALFUNC (mng_special_pplt) -{ - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifdef MNG_INCLUDE_JNG -MNG_C_SPECIALFUNC (mng_special_ijng) -{ -#ifdef MNG_SUPPORT_DISPLAY - mng_retcode iRetcode = mng_create_ani_ijng (pData); - if (!iRetcode) /* process it */ - iRetcode = mng_process_display_ijng (pData); - return iRetcode; -#else - return MNG_NOERROR; /* done */ -#endif /* MNG_SUPPORT_DISPLAY */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -MNG_F_SPECIALFUNC (mng_drop_entries) -{ - mng_dropp pDROP = (mng_dropp)pChunk; - mng_uint32 iRawlen = *piRawlen; - mng_uint8p pRawdata = *ppRawdata; - mng_uint32 iX; - mng_uint32p pEntry; - /* check length */ - if ((iRawlen < 4) || ((iRawlen % 4) != 0)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - MNG_ALLOC (pData, pEntry, iRawlen); - pDROP->iCount = iRawlen / 4; - pDROP->pChunknames = (mng_ptr)pEntry; - - for (iX = pDROP->iCount; iX > 0; iX--) - { - *pEntry++ = mng_get_uint32 (pRawdata); - pRawdata += 4; - } - - *piRawlen = 0; - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -MNG_C_SPECIALFUNC (mng_special_drop) -{ -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_DBYK -MNG_C_SPECIALFUNC (mng_special_dbyk) -{ -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_ORDR -MNG_F_SPECIALFUNC (mng_ordr_entries) -{ - mng_ordrp pORDR = (mng_ordrp)pChunk; - mng_uint32 iRawlen = *piRawlen; - mng_uint8p pRawdata = *ppRawdata; - mng_uint32 iX; - mng_ordr_entryp pEntry; - /* check length */ - if ((iRawlen < 5) || ((iRawlen % 5) != 0)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - MNG_ALLOC (pData, pEntry, iRawlen); - pORDR->iCount = iRawlen / 5; - pORDR->pEntries = (mng_ptr)pEntry; - - for (iX = pORDR->iCount; iX > 0; iX--) - { - pEntry->iChunkname = mng_get_uint32 (pRawdata); - pEntry->iOrdertype = *(pRawdata+4); - pEntry++; - pRawdata += 5; - } - - *piRawlen = 0; - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_ORDR -MNG_C_SPECIALFUNC (mng_special_ordr) -{ -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_MAGN -MNG_F_SPECIALFUNC (mng_debunk_magn) -{ - mng_magnp pMAGN = (mng_magnp)pChunk; - mng_uint32 iRawlen = *piRawlen; - mng_uint8p pRawdata = *ppRawdata; - mng_bool bFaulty; - /* check length */ - if (iRawlen > 20) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - /* following is an ugly hack to allow faulty layout caused by previous - versions of libmng and MNGeye, which wrote MAGN with a 16-bit - MethodX/MethodY (as opposed to the proper 8-bit as defined in the spec!) */ - - if ((iRawlen == 6) || (iRawlen == 8) || (iRawlen == 10) || (iRawlen == 12) || - (iRawlen == 14) || (iRawlen == 16) || (iRawlen == 20)) - bFaulty = MNG_TRUE; /* these lengths are all wrong */ - else /* length 18 can be right or wrong !!! */ - if ((iRawlen == 18) && (mng_get_uint16 (pRawdata+4) <= 5) && - (mng_get_uint16 (pRawdata+6) < 256) && - (mng_get_uint16 (pRawdata+8) < 256) && - (mng_get_uint16 (pRawdata+10) < 256) && - (mng_get_uint16 (pRawdata+12) < 256) && - (mng_get_uint16 (pRawdata+14) < 256) && - (mng_get_uint16 (pRawdata+16) < 256)) - bFaulty = MNG_TRUE; /* this is very likely the wrong layout */ - else - bFaulty = MNG_FALSE; /* all other cases are handled as right */ - - if (bFaulty) /* wrong layout ? */ - { - if (iRawlen > 0) /* get the fields */ - pMAGN->iFirstid = mng_get_uint16 (pRawdata); - else - pMAGN->iFirstid = 0; - - if (iRawlen > 2) - pMAGN->iLastid = mng_get_uint16 (pRawdata+2); - else - pMAGN->iLastid = pMAGN->iFirstid; - - if (iRawlen > 4) - pMAGN->iMethodX = (mng_uint8)(mng_get_uint16 (pRawdata+4)); - else - pMAGN->iMethodX = 0; - - if (iRawlen > 6) - pMAGN->iMX = mng_get_uint16 (pRawdata+6); - else - pMAGN->iMX = 1; - - if (iRawlen > 8) - pMAGN->iMY = mng_get_uint16 (pRawdata+8); - else - pMAGN->iMY = pMAGN->iMX; - - if (iRawlen > 10) - pMAGN->iML = mng_get_uint16 (pRawdata+10); - else - pMAGN->iML = pMAGN->iMX; - - if (iRawlen > 12) - pMAGN->iMR = mng_get_uint16 (pRawdata+12); - else - pMAGN->iMR = pMAGN->iMX; - - if (iRawlen > 14) - pMAGN->iMT = mng_get_uint16 (pRawdata+14); - else - pMAGN->iMT = pMAGN->iMY; - - if (iRawlen > 16) - pMAGN->iMB = mng_get_uint16 (pRawdata+16); - else - pMAGN->iMB = pMAGN->iMY; - - if (iRawlen > 18) - pMAGN->iMethodY = (mng_uint8)(mng_get_uint16 (pRawdata+18)); - else - pMAGN->iMethodY = pMAGN->iMethodX; - } - else /* proper layout !!!! */ - { - if (iRawlen > 0) /* get the fields */ - pMAGN->iFirstid = mng_get_uint16 (pRawdata); - else - pMAGN->iFirstid = 0; - - if (iRawlen > 2) - pMAGN->iLastid = mng_get_uint16 (pRawdata+2); - else - pMAGN->iLastid = pMAGN->iFirstid; - - if (iRawlen > 4) - pMAGN->iMethodX = *(pRawdata+4); - else - pMAGN->iMethodX = 0; - - if (iRawlen > 5) - pMAGN->iMX = mng_get_uint16 (pRawdata+5); - else - pMAGN->iMX = 1; - - if (iRawlen > 7) - pMAGN->iMY = mng_get_uint16 (pRawdata+7); - else - pMAGN->iMY = pMAGN->iMX; - - if (iRawlen > 9) - pMAGN->iML = mng_get_uint16 (pRawdata+9); - else - pMAGN->iML = pMAGN->iMX; - - if (iRawlen > 11) - pMAGN->iMR = mng_get_uint16 (pRawdata+11); - else - pMAGN->iMR = pMAGN->iMX; - - if (iRawlen > 13) - pMAGN->iMT = mng_get_uint16 (pRawdata+13); - else - pMAGN->iMT = pMAGN->iMY; - - if (iRawlen > 15) - pMAGN->iMB = mng_get_uint16 (pRawdata+15); - else - pMAGN->iMB = pMAGN->iMY; - - if (iRawlen > 17) - pMAGN->iMethodY = *(pRawdata+17); - else - pMAGN->iMethodY = pMAGN->iMethodX; - } - /* check field validity */ - if ((pMAGN->iMethodX > 5) || (pMAGN->iMethodY > 5)) - MNG_ERROR (pData, MNG_INVALIDMETHOD); - - *piRawlen = 0; - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_MAGN -MNG_C_SPECIALFUNC (mng_special_magn) -{ -#ifdef MNG_SUPPORT_DISPLAY - return mng_create_ani_magn (pData, pChunk); -#else - return MNG_NOERROR; -#endif /* MNG_SUPPORT_DISPLAY */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_evNT -MNG_F_SPECIALFUNC (mng_evnt_entries) -{ - mng_evntp pEVNT = (mng_evntp)pChunk; - mng_uint32 iRawlen; - mng_uint8p pRawdata; -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_SUPPORT_DYNAMICMNG) - mng_retcode iRetcode; -#endif - mng_uint8p pNull; - mng_uint8 iEventtype; - mng_uint8 iMasktype; - mng_int32 iLeft; - mng_int32 iRight; - mng_int32 iTop; - mng_int32 iBottom; - mng_uint16 iObjectid; - mng_uint8 iIndex; - mng_uint32 iNamesize; - mng_uint32 iCount = 0; - mng_evnt_entryp pEntry = MNG_NULL; - mng_uint32 iX; - - for (iX = 0; iX < 2; iX++) - { - iRawlen = *piRawlen; - pRawdata = *ppRawdata; - - if (iX) /* second run ? */ - { - MNG_ALLOC (pData, pEntry, (iCount * sizeof (mng_evnt_entry))); - pEVNT->iCount = iCount; - pEVNT->pEntries = pEntry; - } - - while (iRawlen) /* anything left ? */ - { - if (iRawlen < 2) /* must have at least 2 bytes ! */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - iEventtype = *pRawdata; /* eventtype */ - if (iEventtype > 5) - MNG_ERROR (pData, MNG_INVALIDEVENT); - - pRawdata++; - - iMasktype = *pRawdata; /* masktype */ - if (iMasktype > 5) - MNG_ERROR (pData, MNG_INVALIDMASK); - - pRawdata++; - iRawlen -= 2; - - iLeft = 0; - iRight = 0; - iTop = 0; - iBottom = 0; - iObjectid = 0; - iIndex = 0; - - switch (iMasktype) - { - case 1 : - { - if (iRawlen > 16) - { - iLeft = mng_get_int32 (pRawdata); - iRight = mng_get_int32 (pRawdata+4); - iTop = mng_get_int32 (pRawdata+8); - iBottom = mng_get_int32 (pRawdata+12); - pRawdata += 16; - iRawlen -= 16; - } - else - MNG_ERROR (pData, MNG_INVALIDLENGTH); - break; - } - case 2 : - { - if (iRawlen > 2) - { - iObjectid = mng_get_uint16 (pRawdata); - pRawdata += 2; - iRawlen -= 2; - } - else - MNG_ERROR (pData, MNG_INVALIDLENGTH); - break; - } - case 3 : - { - if (iRawlen > 3) - { - iObjectid = mng_get_uint16 (pRawdata); - iIndex = *(pRawdata+2); - pRawdata += 3; - iRawlen -= 3; - } - else - MNG_ERROR (pData, MNG_INVALIDLENGTH); - break; - } - case 4 : - { - if (iRawlen > 18) - { - iLeft = mng_get_int32 (pRawdata); - iRight = mng_get_int32 (pRawdata+4); - iTop = mng_get_int32 (pRawdata+8); - iBottom = mng_get_int32 (pRawdata+12); - iObjectid = mng_get_uint16 (pRawdata+16); - pRawdata += 18; - iRawlen -= 18; - } - else - MNG_ERROR (pData, MNG_INVALIDLENGTH); - break; - } - case 5 : - { - if (iRawlen > 19) - { - iLeft = mng_get_int32 (pRawdata); - iRight = mng_get_int32 (pRawdata+4); - iTop = mng_get_int32 (pRawdata+8); - iBottom = mng_get_int32 (pRawdata+12); - iObjectid = mng_get_uint16 (pRawdata+16); - iIndex = *(pRawdata+18); - pRawdata += 19; - iRawlen -= 19; - } - else - MNG_ERROR (pData, MNG_INVALIDLENGTH); - break; - } - } - - pNull = pRawdata; /* get the name length */ - while (*pNull) - pNull++; - - if ((pNull - pRawdata) > (mng_int32)iRawlen) - { - iNamesize = iRawlen; /* no null found; so end of evNT */ - iRawlen = 0; - } - else - { - iNamesize = pNull - pRawdata; /* should be another entry */ - iRawlen = iRawlen - iNamesize - 1; - - if (!iRawlen) /* must not end with a null ! */ - MNG_ERROR (pData, MNG_ENDWITHNULL); - } - - if (!iX) - { - iCount++; - } - else - { - pEntry->iEventtype = iEventtype; - pEntry->iMasktype = iMasktype; - pEntry->iLeft = iLeft; - pEntry->iRight = iRight; - pEntry->iTop = iTop; - pEntry->iBottom = iBottom; - pEntry->iObjectid = iObjectid; - pEntry->iIndex = iIndex; - pEntry->iSegmentnamesize = iNamesize; - - if (iNamesize) - { - MNG_ALLOC (pData, pEntry->zSegmentname, iNamesize+1); - MNG_COPY (pEntry->zSegmentname, pRawdata, iNamesize); - } - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_SUPPORT_DYNAMICMNG) - iRetcode = mng_create_event (pData, (mng_ptr)pEntry); - if (iRetcode) /* on error bail out */ - return iRetcode; -#endif - - pEntry++; - } - - pRawdata = pRawdata + iNamesize + 1; - } - } - - *piRawlen = 0; - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_evNT -MNG_C_SPECIALFUNC (mng_special_evnt) -{ - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_MPNG_PROPOSAL -MNG_C_SPECIALFUNC (mng_special_mpng) -{ - if ((pData->eImagetype != mng_it_png) && (pData->eImagetype != mng_it_jng)) - MNG_ERROR (pData, MNG_CHUNKNOTALLOWED); - -#ifdef MNG_SUPPORT_DISPLAY - return mng_create_mpng_obj (pData, pChunk); -#else - return MNG_NOERROR; -#endif -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ANG_PROPOSAL -MNG_C_SPECIALFUNC (mng_special_ahdr) -{ -#ifdef MNG_SUPPORT_DISPLAY - return mng_create_ang_obj (pData, pChunk); -#else - return MNG_NOERROR; -#endif -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ANG_PROPOSAL -MNG_F_SPECIALFUNC (mng_adat_tiles) -{ - if ((pData->eImagetype != mng_it_ang) || (!pData->pANG)) - MNG_ERROR (pData, MNG_CHUNKNOTALLOWED); - - { - mng_adatp pADAT = (mng_adatp)pChunk; - mng_ang_objp pANG = (mng_ang_objp)pData->pANG; - mng_uint32 iRawlen = *piRawlen; - mng_uint8p pRawdata = *ppRawdata; - mng_retcode iRetcode; - mng_uint8p pBuf; - mng_uint32 iBufsize; - mng_uint32 iRealsize; - mng_uint8p pTemp; - mng_uint8p pTemp2; - mng_int32 iX; - mng_int32 iSize; - -#ifdef MNG_SUPPORT_DISPLAY - mng_imagep pImage; - mng_int32 iTemplen; - mng_uint8p pSwap; - - mng_processobject pProcess; - - mng_uint32 iSavedatawidth; - mng_uint32 iSavedataheight; - - mng_fptr fSaveinitrowproc; - mng_fptr fSavestorerow; - mng_fptr fSaveprocessrow; - mng_fptr fSavedifferrow; - mng_imagep fSavestoreobj; - mng_imagedatap fSavestorebuf; - -#ifdef MNG_OPTIMIZE_FOOTPRINT_INIT - png_imgtype eSavepngimgtype; -#endif - - mng_uint8 iSaveinterlace; - mng_int8 iSavepass; - mng_int32 iSaverow; - mng_int32 iSaverowinc; - mng_int32 iSavecol; - mng_int32 iSavecolinc; - mng_int32 iSaverowsamples; - mng_int32 iSavesamplemul; - mng_int32 iSavesampleofs; - mng_int32 iSavesamplediv; - mng_int32 iSaverowsize; - mng_int32 iSaverowmax; - mng_int32 iSavefilterofs; - mng_int32 iSavepixelofs; - mng_uint32 iSavelevel0; - mng_uint32 iSavelevel1; - mng_uint32 iSavelevel2; - mng_uint32 iSavelevel3; - mng_uint8p pSaveworkrow; - mng_uint8p pSaveprevrow; - mng_uint8p pSaverGBArow; - mng_bool bSaveisRGBA16; - mng_bool bSaveisOpaque; - mng_int32 iSavefilterbpp; - - mng_int32 iSavedestl; - mng_int32 iSavedestt; - mng_int32 iSavedestr; - mng_int32 iSavedestb; - mng_int32 iSavesourcel; - mng_int32 iSavesourcet; - mng_int32 iSavesourcer; - mng_int32 iSavesourceb; -#endif /* MNG_SUPPORT_DISPLAY */ - - iRetcode = mng_inflate_buffer (pData, pRawdata, iRawlen, - &pBuf, &iBufsize, &iRealsize); - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffer */ - MNG_FREEX (pData, pBuf, iBufsize); - return iRetcode; - } - /* get buffer for tile info in ADAT chunk */ - pADAT->iTilessize = pANG->iNumframes * sizeof(mng_adat_tile); - MNG_ALLOCX (pData, pADAT->pTiles, pADAT->iTilessize); - if (!pADAT->pTiles) - { - pADAT->iTilessize = 0; - MNG_FREEX (pData, pBuf, iBufsize); - MNG_ERROR (pData, MNG_OUTOFMEMORY); - } - - pTemp = pBuf; - pTemp2 = (mng_uint8p)pADAT->pTiles; - - if (!pANG->iStillused) - iSize = 12; - else - iSize = 13; - - for (iX = 0; iX < pANG->iNumframes; iX++) - { - MNG_COPY (pTemp2, pTemp, iSize); - pTemp += iSize; - pTemp2 += sizeof(mng_adat_tile); - } - -#ifdef MNG_SUPPORT_DISPLAY - /* get buffer for tile info in ANG object */ - pANG->iTilessize = pADAT->iTilessize; - MNG_ALLOCX (pData, pANG->pTiles, pANG->iTilessize); - if (!pANG->pTiles) - { - pANG->iTilessize = 0; - MNG_FREEX (pData, pBuf, iBufsize); - MNG_ERROR (pData, MNG_OUTOFMEMORY); - } - /* copy it from the ADAT object */ - MNG_COPY (pANG->pTiles, pADAT->pTiles, pANG->iTilessize); - - /* save IDAT work-parms */ - fSaveinitrowproc = pData->fInitrowproc; - fSavestorerow = pData->fDisplayrow; - fSaveprocessrow = pData->fProcessrow; - fSavedifferrow = pData->fDifferrow; - fSavestoreobj = pData->pStoreobj; - fSavestorebuf = pData->pStorebuf; - -#ifdef MNG_OPTIMIZE_FOOTPRINT_INIT - eSavepngimgtype = pData->ePng_imgtype; -#endif - - iSavedatawidth = pData->iDatawidth; - iSavedataheight = pData->iDataheight; - iSaveinterlace = pData->iInterlace; - iSavepass = pData->iPass; - iSaverow = pData->iRow; - iSaverowinc = pData->iRowinc; - iSavecol = pData->iCol; - iSavecolinc = pData->iColinc; - iSaverowsamples = pData->iRowsamples; - iSavesamplemul = pData->iSamplemul; - iSavesampleofs = pData->iSampleofs; - iSavesamplediv = pData->iSamplediv; - iSaverowsize = pData->iRowsize; - iSaverowmax = pData->iRowmax; - iSavefilterofs = pData->iFilterofs; - iSavepixelofs = pData->iPixelofs; - iSavelevel0 = pData->iLevel0; - iSavelevel1 = pData->iLevel1; - iSavelevel2 = pData->iLevel2; - iSavelevel3 = pData->iLevel3; - pSaveworkrow = pData->pWorkrow; - pSaveprevrow = pData->pPrevrow; - pSaverGBArow = pData->pRGBArow; - bSaveisRGBA16 = pData->bIsRGBA16; - bSaveisOpaque = pData->bIsOpaque; - iSavefilterbpp = pData->iFilterbpp; - iSavedestl = pData->iDestl; - iSavedestt = pData->iDestt; - iSavedestr = pData->iDestr; - iSavedestb = pData->iDestb; - iSavesourcel = pData->iSourcel; - iSavesourcet = pData->iSourcet; - iSavesourcer = pData->iSourcer; - iSavesourceb = pData->iSourceb; - - pData->iDatawidth = pANG->iTilewidth; - pData->iDataheight = pANG->iTileheight; - - pData->iDestl = 0; - pData->iDestt = 0; - pData->iDestr = pANG->iTilewidth; - pData->iDestb = pANG->iTileheight; - pData->iSourcel = 0; - pData->iSourcet = 0; - pData->iSourcer = pANG->iTilewidth; - pData->iSourceb = pANG->iTileheight; - - pData->fInitrowproc = MNG_NULL; - pData->fStorerow = MNG_NULL; - pData->fProcessrow = MNG_NULL; - pData->fDifferrow = MNG_NULL; - - /* clone image object to store the pixel-data from object 0 */ - iRetcode = mng_clone_imageobject (pData, 1, MNG_FALSE, MNG_FALSE, MNG_FALSE, - MNG_FALSE, 0, 0, 0, pData->pObjzero, &pImage); - if (iRetcode) /* on error, drop temp buffer and bail */ - { - MNG_FREEX (pData, pBuf, iBufsize); - return iRetcode; - } - - /* make sure we got the right dimensions and interlacing */ - iRetcode = mng_reset_object_details (pData, pImage, pANG->iTilewidth, pANG->iTileheight, - pImage->pImgbuf->iBitdepth, pImage->pImgbuf->iColortype, - pImage->pImgbuf->iCompression, pImage->pImgbuf->iFilter, - pANG->iInterlace, MNG_FALSE); - if (iRetcode) /* on error, drop temp buffer and bail */ - { - MNG_FREEX (pData, pBuf, iBufsize); - return iRetcode; - } - - pData->pStoreobj = pImage; - -#ifdef MNG_OPTIMIZE_FOOTPRINT_INIT - pData->fInitrowproc = (mng_fptr)mng_init_rowproc; - pData->ePng_imgtype = mng_png_imgtype(pData->iColortype,pData->iBitdepth); -#else - switch (pData->iColortype) /* determine row initialization routine */ - { - case 0 : { /* gray */ - switch (pData->iBitdepth) - { -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case 1 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_g1_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_g1_i; - - break; - } - case 2 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_g2_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_g2_i; - - break; - } - case 4 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_g4_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_g4_i; - break; - } -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_g8_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_g8_i; - - break; - } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_g16_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_g16_i; - - break; - } -#endif - } - - break; - } - case 2 : { /* rgb */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_rgb8_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_rgb8_i; - break; - } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_rgb16_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_rgb16_i; - - break; - } -#endif - } - - break; - } - case 3 : { /* indexed */ - switch (pData->iBitdepth) - { -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case 1 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_idx1_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_idx1_i; - - break; - } - case 2 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_idx2_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_idx2_i; - - break; - } - case 4 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_idx4_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_idx4_i; - - break; - } -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_idx8_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_idx8_i; - - break; - } - } - - break; - } - case 4 : { /* gray+alpha */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_ga8_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_ga8_i; - - break; - } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_ga16_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_ga16_i; - break; - } -#endif - } - - break; - } - case 6 : { /* rgb+alpha */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_rgba8_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_rgba8_i; - - break; - } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_rgba16_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_rgba16_i; - - break; - } -#endif - } - - break; - } - } -#endif /* MNG_OPTIMIZE_FOOTPRINT_INIT */ - - pData->iFilterofs = 0; /* determine filter characteristics */ - pData->iLevel0 = 0; /* default levels */ - pData->iLevel1 = 0; - pData->iLevel2 = 0; - pData->iLevel3 = 0; - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - { - switch (pData->iColortype) - { - case 0 : { - if (pData->iBitdepth <= 8) - pData->iFilterofs = 1; - else - pData->iFilterofs = 2; - - break; - } - case 2 : { - if (pData->iBitdepth <= 8) - pData->iFilterofs = 3; - else - pData->iFilterofs = 6; - - break; - } - case 3 : { - pData->iFilterofs = 1; - break; - } - case 4 : { - if (pData->iBitdepth <= 8) - pData->iFilterofs = 2; - else - pData->iFilterofs = 4; - - break; - } - case 6 : { - if (pData->iBitdepth <= 8) - pData->iFilterofs = 4; - else - pData->iFilterofs = 8; - - break; - } - } - } -#endif - -#ifdef FILTER193 /* no adaptive filtering ? */ - if (pData->iFilter == MNG_FILTER_NOFILTER) - pData->iPixelofs = pData->iFilterofs; - else -#endif - pData->iPixelofs = pData->iFilterofs + 1; - - if (pData->fInitrowproc) /* need to initialize row processing? */ - { - iRetcode = ((mng_initrowproc)pData->fInitrowproc) (pData); - if (iRetcode) - { - MNG_FREEX (pData, pBuf, iBufsize); - return iRetcode; - } - } - /* calculate remainder of buffer */ - pTemp = pBuf + (mng_int32)(pANG->iNumframes * iSize); - iTemplen = iRealsize - (mng_int32)(pANG->iNumframes * iSize); - - do - { - if (iTemplen > pData->iRowmax) /* get a pixel-row from the temp buffer */ - { - MNG_COPY (pData->pWorkrow, pTemp, pData->iRowmax); - } - else - { - MNG_COPY (pData->pWorkrow, pTemp, iTemplen); - } - - { /* image not completed yet ? */ - if (pData->iRow < (mng_int32)pData->iDataheight) - { -#ifdef MNG_NO_1_2_4BIT_SUPPORT - if (pData->iPNGdepth == 1) - { - /* Inflate Workrow to 8-bit */ - mng_int32 iX; - mng_uint8p pSrc = pData->pWorkrow+1; - mng_uint8p pDest = pSrc + pData->iRowsize - (pData->iRowsize+7)/8; - - for (iX = ((pData->iRowsize+7)/8) ; iX > 0 ; iX--) - *pDest++ = *pSrc++; - - pDest = pData->pWorkrow+1; - pSrc = pDest + pData->iRowsize - (pData->iRowsize+7)/8; - for (iX = pData->iRowsize; ;) - { - *pDest++ = (((*pSrc)>>7)&1); - if (iX-- <= 0) - break; - *pDest++ = (((*pSrc)>>6)&1); - if (iX-- <= 0) - break; - *pDest++ = (((*pSrc)>>5)&1); - if (iX-- <= 0) - break; - *pDest++ = (((*pSrc)>>4)&1); - if (iX-- <= 0) - break; - *pDest++ = (((*pSrc)>>3)&1); - if (iX-- <= 0) - break; - *pDest++ = (((*pSrc)>>2)&1); - if (iX-- <= 0) - break; - *pDest++ = (((*pSrc)>>1)&1); - if (iX-- <= 0) - break; - *pDest++ = (((*pSrc) )&1); - if (iX-- <= 0) - break; - pSrc++; - } - } - else if (pData->iPNGdepth == 2) - { - /* Inflate Workrow to 8-bit */ - mng_int32 iX; - mng_uint8p pSrc = pData->pWorkrow+1; - mng_uint8p pDest = pSrc + pData->iRowsize - (2*pData->iRowsize+7)/8; - - for (iX = ((2*pData->iRowsize+7)/8) ; iX > 0 ; iX--) - *pDest++ = *pSrc++; - - pDest = pData->pWorkrow+1; - pSrc = pDest + pData->iRowsize - (2*pData->iRowsize+7)/8; - for (iX = pData->iRowsize; ;) - { - *pDest++ = (((*pSrc)>>6)&3); - if (iX-- <= 0) - break; - *pDest++ = (((*pSrc)>>4)&3); - if (iX-- <= 0) - break; - *pDest++ = (((*pSrc)>>2)&3); - if (iX-- <= 0) - break; - *pDest++ = (((*pSrc) )&3); - if (iX-- <= 0) - break; - pSrc++; - } - } - else if (pData->iPNGdepth == 4) - { - /* Inflate Workrow to 8-bit */ - mng_int32 iX; - mng_uint8p pSrc = pData->pWorkrow+1; - mng_uint8p pDest = pSrc + pData->iRowsize - (4*pData->iRowsize+7)/8; - - for (iX = ((4*pData->iRowsize+7)/8) ; iX > 0 ; iX--) - *pDest++ = *pSrc++; - - pDest = pData->pWorkrow+1; - pSrc = pDest + pData->iRowsize - (4*pData->iRowsize+7)/8; - for (iX = pData->iRowsize; ;) - { - *pDest++ = (((*pSrc)>>4)&0x0f); - if (iX-- <= 0) - break; - *pDest++ = (((*pSrc) )&0x0f); - if (iX-- <= 0) - break; - pSrc++; - } - } - if (pData->iPNGdepth < 8 && pData->iColortype == 0) - { - /* Expand samples to 8-bit by LBR */ - mng_int32 iX; - mng_uint8p pSrc = pData->pWorkrow+1; - mng_uint8 multiplier[]={0,255,85,0,17,0,0,0,1}; - - for (iX = pData->iRowsize; iX > 0; iX--) - *pSrc++ *= multiplier[pData->iPNGdepth]; - } -#endif -#ifdef MNG_NO_16BIT_SUPPORT - if (pData->iPNGdepth > 8) - { - /* Reduce Workrow to 8-bit */ - mng_int32 iX; - mng_uint8p pSrc = pData->pWorkrow+1; - mng_uint8p pDest = pSrc; - - for (iX = pData->iRowsize; iX > 0; iX--) - { - *pDest = *pSrc; - pDest++; - pSrc+=2; - } - } -#endif - -#ifdef FILTER192 /* has leveling info ? */ - if (pData->iFilterofs == MNG_FILTER_DIFFERING) - iRetcode = init_rowdiffering (pData); - else -#endif - iRetcode = MNG_NOERROR; - /* filter the row if necessary */ - if ((!iRetcode) && (pData->iFilterofs < pData->iPixelofs ) && - (*(pData->pWorkrow + pData->iFilterofs)) ) - iRetcode = mng_filter_a_row (pData); - - /* additional leveling/differing ? */ - if ((!iRetcode) && (pData->fDifferrow)) - { - iRetcode = ((mng_differrow)pData->fDifferrow) (pData); - - pSwap = pData->pWorkrow; - pData->pWorkrow = pData->pPrevrow; - pData->pPrevrow = pSwap; /* make sure we're processing the right data */ - } - - if (!iRetcode) - { - { /* process this row */ - if ((!iRetcode) && (pData->fProcessrow)) - iRetcode = ((mng_processrow)pData->fProcessrow) (pData); - /* store in object ? */ - if ((!iRetcode) && (pData->fStorerow)) - iRetcode = ((mng_storerow)pData->fStorerow) (pData); - } - } - - if (iRetcode) /* on error bail out */ - { - MNG_FREEX (pData, pBuf, iBufsize); - MNG_ERROR (pData, iRetcode); - } - - if (!pData->fDifferrow) /* swap row-pointers */ - { - pSwap = pData->pWorkrow; - pData->pWorkrow = pData->pPrevrow; - pData->pPrevrow = pSwap; /* so prev points to the processed row! */ - } - /* adjust variables for next row */ - iRetcode = mng_next_row (pData); - - if (iRetcode) /* on error bail out */ - { - MNG_FREEX (pData, pBuf, iBufsize); - MNG_ERROR (pData, iRetcode); - } - } - } - - pTemp += pData->iRowmax; - iTemplen -= pData->iRowmax; - } /* until some error or EOI - or all pixels received */ - while ( (iTemplen > 0) && - ( (pData->iRow < (mng_int32)pData->iDataheight) || - ( (pData->iPass >= 0) && (pData->iPass < 7) ) ) ); - - mng_cleanup_rowproc (pData); /* cleanup row processing buffers !! */ - - /* restore saved work-parms */ - pData->iDatawidth = iSavedatawidth; - pData->iDataheight = iSavedataheight; - - pData->fInitrowproc = fSaveinitrowproc; - pData->fDisplayrow = fSavestorerow; - pData->fProcessrow = fSaveprocessrow; - pData->fDifferrow = fSavedifferrow; - pData->pStoreobj = fSavestoreobj; - pData->pStorebuf = fSavestorebuf; - -#ifdef MNG_OPTIMIZE_FOOTPRINT_INIT - pData->ePng_imgtype = eSavepngimgtype; -#endif - - pData->iInterlace = iSaveinterlace; - pData->iPass = iSavepass; - pData->iRow = iSaverow; - pData->iRowinc = iSaverowinc; - pData->iCol = iSavecol; - pData->iColinc = iSavecolinc; - pData->iRowsamples = iSaverowsamples; - pData->iSamplemul = iSavesamplemul; - pData->iSampleofs = iSavesampleofs; - pData->iSamplediv = iSavesamplediv; - pData->iRowsize = iSaverowsize; - pData->iRowmax = iSaverowmax; - pData->iFilterofs = iSavefilterofs; - pData->iPixelofs = iSavepixelofs; - pData->iLevel0 = iSavelevel0; - pData->iLevel1 = iSavelevel1; - pData->iLevel2 = iSavelevel2; - pData->iLevel3 = iSavelevel3; - pData->pWorkrow = pSaveworkrow; - pData->pPrevrow = pSaveprevrow; - pData->pRGBArow = pSaverGBArow; - pData->bIsRGBA16 = bSaveisRGBA16; - pData->bIsOpaque = bSaveisOpaque; - pData->iFilterbpp = iSavefilterbpp; - pData->iDestl = iSavedestl; - pData->iDestt = iSavedestt; - pData->iDestr = iSavedestr; - pData->iDestb = iSavedestb; - pData->iSourcel = iSavesourcel; - pData->iSourcet = iSavesourcet; - pData->iSourcer = iSavesourcer; - pData->iSourceb = iSavesourceb; - - /* create the animation directives ! */ - pProcess = (mng_processobject)pANG->sHeader.fProcess; - iRetcode = pProcess (pData, (mng_objectp)pData->pANG); - if (iRetcode) - return iRetcode; - -#endif /* MNG_SUPPORT_DISPLAY */ - - MNG_FREE (pData, pBuf, iBufsize); /* always free the temp buffer ! */ - } - - *piRawlen = 0; - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ANG_PROPOSAL -MNG_C_SPECIALFUNC (mng_special_adat) -{ - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -MNG_C_SPECIALFUNC (mng_special_unknown) -{ - /* critical chunk ? */ - if ((((mng_uint32)pData->iChunkname & 0x20000000) == 0) -#ifdef MNG_SKIPCHUNK_SAVE - && (pData->iChunkname != MNG_UINT_SAVE) -#endif -#ifdef MNG_SKIPCHUNK_SEEK - && (pData->iChunkname != MNG_UINT_SEEK) -#endif -#ifdef MNG_SKIPCHUNK_DBYK - && (pData->iChunkname != MNG_UINT_DBYK) -#endif -#ifdef MNG_SKIPCHUNK_ORDR - && (pData->iChunkname != MNG_UINT_ORDR) -#endif - ) - MNG_ERROR (pData, MNG_UNKNOWNCRITICAL); - - if (pData->fProcessunknown) /* let the app handle it ? */ - { - mng_bool bOke = pData->fProcessunknown ((mng_handle)pData, pData->iChunkname, - ((mng_unknown_chunkp)pChunk)->iDatasize, - ((mng_unknown_chunkp)pChunk)->pData); - if (!bOke) - MNG_ERROR (pData, MNG_APPMISCERROR); - } - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_READ_PROCS || MNG_INCLUDE_WRITE_PROCS */ -#endif /* MNG_OPTIMIZE_CHUNKREADER */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - - - - - diff --git a/plugins/AdvaImg/src/LibMNG/libmng_chunk_descr.h b/plugins/AdvaImg/src/LibMNG/libmng_chunk_descr.h deleted file mode 100644 index 5126cb2775..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_chunk_descr.h +++ /dev/null @@ -1,146 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_chunk_descr.h copyright (c) 2007 G.Juyn * */ -/* * version : 1.0.10 * */ -/* * * */ -/* * purpose : Chunk descriptor functions (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * comment : definition of the chunk- anf field-descriptor routines * */ -/* * * */ -/* * changes : 1.0.9 - 12/06/2004 - G.Juyn * */ -/* * - added conditional MNG_OPTIMIZE_CHUNKREADER * */ -/* * * */ -/* * 1.0.10 - 04/08/2007 - G.Juyn * */ -/* * - added support for mPNG proposal * */ -/* * 1.0.10 - 04/12/2007 - G.Juyn * */ -/* * - added support for ANG proposal * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_chunk_descr_h_ -#define _libmng_chunk_descr_h_ - -/* ************************************************************************** */ - -#ifdef MNG_OPTIMIZE_CHUNKREADER -#if defined(MNG_INCLUDE_READ_PROCS) || defined(MNG_INCLUDE_WRITE_PROCS) - -/* ************************************************************************** */ - -void mng_get_chunkheader (mng_chunkid iChunkname, - mng_chunk_headerp pResult); - -/* ************************************************************************** */ - -#define MNG_F_SPECIALFUNC(n) mng_retcode n (mng_datap pData, \ - mng_chunkp pChunk, \ - mng_uint32* piRawlen, \ - mng_uint8p* ppRawdata) - -MNG_F_SPECIALFUNC (mng_debunk_plte) ; -MNG_F_SPECIALFUNC (mng_debunk_trns) ; -MNG_F_SPECIALFUNC (mng_deflate_itxt) ; -MNG_F_SPECIALFUNC (mng_splt_entries) ; -MNG_F_SPECIALFUNC (mng_hist_entries) ; - -MNG_F_SPECIALFUNC (mng_debunk_loop) ; -MNG_F_SPECIALFUNC (mng_debunk_past) ; -MNG_F_SPECIALFUNC (mng_disc_entries) ; -MNG_F_SPECIALFUNC (mng_fram_remainder) ; -MNG_F_SPECIALFUNC (mng_save_entries) ; -MNG_F_SPECIALFUNC (mng_pplt_entries) ; -MNG_F_SPECIALFUNC (mng_drop_entries) ; -MNG_F_SPECIALFUNC (mng_ordr_entries) ; -MNG_F_SPECIALFUNC (mng_debunk_magn) ; -MNG_F_SPECIALFUNC (mng_evnt_entries) ; -MNG_F_SPECIALFUNC (mng_adat_tiles) ; - -/* ************************************************************************** */ - -#define MNG_C_SPECIALFUNC(n) mng_retcode n (mng_datap pData, \ - mng_chunkp pChunk) - -MNG_C_SPECIALFUNC (mng_special_ihdr) ; -MNG_C_SPECIALFUNC (mng_special_plte) ; -MNG_C_SPECIALFUNC (mng_special_idat) ; -MNG_C_SPECIALFUNC (mng_special_iend) ; -MNG_C_SPECIALFUNC (mng_special_trns) ; -MNG_C_SPECIALFUNC (mng_special_gama) ; -MNG_C_SPECIALFUNC (mng_special_chrm) ; -MNG_C_SPECIALFUNC (mng_special_srgb) ; -MNG_C_SPECIALFUNC (mng_special_iccp) ; -MNG_C_SPECIALFUNC (mng_special_text) ; -MNG_C_SPECIALFUNC (mng_special_ztxt) ; -MNG_C_SPECIALFUNC (mng_special_itxt) ; -MNG_C_SPECIALFUNC (mng_special_bkgd) ; -MNG_C_SPECIALFUNC (mng_special_phys) ; -MNG_C_SPECIALFUNC (mng_special_sbit) ; -MNG_C_SPECIALFUNC (mng_special_splt) ; -MNG_C_SPECIALFUNC (mng_special_hist) ; -MNG_C_SPECIALFUNC (mng_special_time) ; - -MNG_C_SPECIALFUNC (mng_special_jhdr) ; -MNG_C_SPECIALFUNC (mng_special_jdaa) ; -MNG_C_SPECIALFUNC (mng_special_jdat) ; -MNG_C_SPECIALFUNC (mng_special_jsep) ; - -MNG_C_SPECIALFUNC (mng_special_mhdr) ; -MNG_C_SPECIALFUNC (mng_special_mend) ; -MNG_C_SPECIALFUNC (mng_special_loop) ; -MNG_C_SPECIALFUNC (mng_special_endl) ; -MNG_C_SPECIALFUNC (mng_special_defi) ; -MNG_C_SPECIALFUNC (mng_special_basi) ; -MNG_C_SPECIALFUNC (mng_special_clon) ; -MNG_C_SPECIALFUNC (mng_special_past) ; -MNG_C_SPECIALFUNC (mng_special_disc) ; -MNG_C_SPECIALFUNC (mng_special_back) ; -MNG_C_SPECIALFUNC (mng_special_fram) ; -MNG_C_SPECIALFUNC (mng_special_move) ; -MNG_C_SPECIALFUNC (mng_special_clip) ; -MNG_C_SPECIALFUNC (mng_special_show) ; -MNG_C_SPECIALFUNC (mng_special_term) ; -MNG_C_SPECIALFUNC (mng_special_save) ; -MNG_C_SPECIALFUNC (mng_special_seek) ; -MNG_C_SPECIALFUNC (mng_special_expi) ; -MNG_C_SPECIALFUNC (mng_special_fpri) ; -MNG_C_SPECIALFUNC (mng_special_need) ; -MNG_C_SPECIALFUNC (mng_special_phyg) ; - -MNG_C_SPECIALFUNC (mng_special_dhdr) ; -MNG_C_SPECIALFUNC (mng_special_prom) ; -MNG_C_SPECIALFUNC (mng_special_ipng) ; -MNG_C_SPECIALFUNC (mng_special_pplt) ; -MNG_C_SPECIALFUNC (mng_special_ijng) ; -MNG_C_SPECIALFUNC (mng_special_drop) ; -MNG_C_SPECIALFUNC (mng_special_dbyk) ; -MNG_C_SPECIALFUNC (mng_special_ordr) ; - -MNG_C_SPECIALFUNC (mng_special_magn) ; -MNG_C_SPECIALFUNC (mng_special_evnt) ; -MNG_C_SPECIALFUNC (mng_special_mpng) ; -MNG_C_SPECIALFUNC (mng_special_ahdr) ; -MNG_C_SPECIALFUNC (mng_special_adat) ; -MNG_C_SPECIALFUNC (mng_special_unknown) ; - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_READ_PROCS) || MNG_INCLUDE_WRITE_PROCS */ -#endif /* MNG_OPTIMIZE_CHUNKREADER */ - -/* ************************************************************************** */ - -#endif /* _libmng_chunk_descr_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/plugins/AdvaImg/src/LibMNG/libmng_chunk_io.c b/plugins/AdvaImg/src/LibMNG/libmng_chunk_io.c deleted file mode 100644 index a75945f063..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_chunk_io.c +++ /dev/null @@ -1,10740 +0,0 @@ -/** ************************************************************************* */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_chunk_io.c copyright (c) 2000-2007 G.Juyn * */ -/* * version : 1.0.10 * */ -/* * * */ -/* * purpose : Chunk I/O routines (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * comment : implementation of chunk input/output routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/01/2000 - G.Juyn * */ -/* * - cleaned up left-over teststuff in the BACK chunk routine * */ -/* * 0.5.1 - 05/04/2000 - G.Juyn * */ -/* * - changed CRC initialization to use dynamic structure * */ -/* * (wasn't thread-safe the old way !) * */ -/* * 0.5.1 - 05/06/2000 - G.Juyn * */ -/* * - filled in many missing sequence&length checks * */ -/* * - filled in many missing chunk-store snippets * */ -/* * 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - added checks for running animations * */ -/* * - filled some write routines * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/10/2000 - G.Juyn * */ -/* * - filled some more write routines * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - filled remaining write routines * */ -/* * - fixed read_pplt with regard to deltatype * */ -/* * - added callback error-reporting support * */ -/* * - added pre-draft48 support (short MHDR, frame_mode, LOOP) * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * - fixed chunk-storage bit in several routines * */ -/* * 0.5.1 - 05/13/2000 - G.Juyn * */ -/* * - added eMNGma hack (will be removed in 1.0.0 !!!) * */ -/* * - added TERM animation object pointer (easier reference) * */ -/* * - supplemented the SAVE & SEEK display processing * */ -/* * * */ -/* * 0.5.2 - 05/18/2000 - G.Juyn * */ -/* * - B004 - fixed problem with MNG_SUPPORT_WRITE not defined * */ -/* * also for MNG_SUPPORT_WRITE without MNG_INCLUDE_JNG * */ -/* * 0.5.2 - 05/19/2000 - G.Juyn * */ -/* * - cleaned up some code regarding mixed support * */ -/* * 0.5.2 - 05/20/2000 - G.Juyn * */ -/* * - implemented JNG support * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - added support for global color-chunks in animation * */ -/* * - added support for global PLTE,tRNS,bKGD in animation * */ -/* * - added support for SAVE & SEEK in animation * */ -/* * 0.5.2 - 05/29/2000 - G.Juyn * */ -/* * - changed ani_create calls not returning object pointer * */ -/* * - create ani objects always (not just inside TERM/LOOP) * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added support for delta-image processing * */ -/* * 0.5.2 - 05/31/2000 - G.Juyn * */ -/* * - fixed up punctuation (contributed by Tim Rowley) * */ -/* * 0.5.2 - 06/02/2000 - G.Juyn * */ -/* * - changed SWAP_ENDIAN to BIGENDIAN_SUPPORTED * */ -/* * 0.5.2 - 06/03/2000 - G.Juyn * */ -/* * - fixed makeup for Linux gcc compile * */ -/* * * */ -/* * 0.5.3 - 06/12/2000 - G.Juyn * */ -/* * - added processing of color-info on delta-image * */ -/* * 0.5.3 - 06/13/2000 - G.Juyn * */ -/* * - fixed handling of empty SAVE chunk * */ -/* * 0.5.3 - 06/17/2000 - G.Juyn * */ -/* * - changed to support delta-images * */ -/* * - added extra checks for delta-images * */ -/* * 0.5.3 - 06/20/2000 - G.Juyn * */ -/* * - fixed possible trouble if IEND display-process got * */ -/* * broken up * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added processing of PLTE & tRNS for delta-images * */ -/* * - added administration of imagelevel parameter * */ -/* * 0.5.3 - 06/22/2000 - G.Juyn * */ -/* * - implemented support for PPLT chunk * */ -/* * 0.5.3 - 06/26/2000 - G.Juyn * */ -/* * - added precaution against faulty iCCP chunks from PS * */ -/* * 0.5.3 - 06/29/2000 - G.Juyn * */ -/* * - fixed some 64-bit warnings * */ -/* * * */ -/* * 0.9.1 - 07/14/2000 - G.Juyn * */ -/* * - changed pre-draft48 frame_mode=3 to frame_mode=1 * */ -/* * 0.9.1 - 07/16/2000 - G.Juyn * */ -/* * - fixed storage of images during mng_read() * */ -/* * - fixed support for mng_display() after mng_read() * */ -/* * 0.9.1 - 07/19/2000 - G.Juyn * */ -/* * - fixed several chunk-writing routines * */ -/* * 0.9.1 - 07/24/2000 - G.Juyn * */ -/* * - fixed reading of still-images * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/07/2000 - G.Juyn * */ -/* * - B111300 - fixup for improved portability * */ -/* * 0.9.3 - 08/08/2000 - G.Juyn * */ -/* * - fixed compiler-warnings from Mozilla * */ -/* * 0.9.3 - 08/09/2000 - G.Juyn * */ -/* * - added check for simplicity-bits in MHDR * */ -/* * 0.9.3 - 08/12/2000 - G.Juyn * */ -/* * - fixed check for simplicity-bits in MHDR (JNG) * */ -/* * 0.9.3 - 08/12/2000 - G.Juyn * */ -/* * - added workaround for faulty PhotoShop iCCP chunk * */ -/* * 0.9.3 - 08/22/2000 - G.Juyn * */ -/* * - fixed write-code for zTXt & iTXt * */ -/* * - fixed read-code for iTXt * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * 0.9.3 - 09/10/2000 - G.Juyn * */ -/* * - fixed DEFI behavior * */ -/* * 0.9.3 - 10/02/2000 - G.Juyn * */ -/* * - fixed simplicity-check in compliance with draft 81/0.98a * */ -/* * 0.9.3 - 10/10/2000 - G.Juyn * */ -/* * - added support for alpha-depth prediction * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added support for JDAA * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - fixed support for MAGN * */ -/* * - implemented nEED "xxxx" (where "xxxx" is a chunkid) * */ -/* * - added callback to process non-critical unknown chunks * */ -/* * - fixed support for bKGD * */ -/* * 0.9.3 - 10/23/2000 - G.Juyn * */ -/* * - fixed bug in empty PLTE handling * */ -/* * * */ -/* * 0.9.4 - 11/20/2000 - G.Juyn * */ -/* * - changed IHDR filter_method check for PNGs * */ -/* * 0.9.4 - 1/18/2001 - G.Juyn * */ -/* * - added errorchecking for MAGN methods * */ -/* * - removed test filter-methods 1 & 65 * */ -/* * * */ -/* * 0.9.5 - 1/25/2001 - G.Juyn * */ -/* * - fixed some small compiler warnings (thanks Nikki) * */ -/* * * */ -/* * 1.0.2 - 05/05/2000 - G.Juyn * */ -/* * - B421427 - writes wrong format in bKGD and tRNS * */ -/* * 1.0.2 - 06/20/2000 - G.Juyn * */ -/* * - B434583 - compiler-warning if MNG_STORE_CHUNKS undefined * */ -/* * * */ -/* * 1.0.5 - 07/08/2002 - G.Juyn * */ -/* * - B578572 - removed eMNGma hack (thanks Dimitri!) * */ -/* * 1.0.5 - 08/07/2002 - G.Juyn * */ -/* * - added test-option for PNG filter method 193 (=no filter) * */ -/* * 1.0.5 - 08/15/2002 - G.Juyn * */ -/* * - completed PROM support * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * 1.0.5 - 09/07/2002 - G.Juyn * */ -/* * - fixed reading of FRAM with just frame_mode and name * */ -/* * 1.0.5 - 09/13/2002 - G.Juyn * */ -/* * - fixed read/write of MAGN chunk * */ -/* * 1.0.5 - 09/14/2002 - G.Juyn * */ -/* * - added event handling for dynamic MNG * */ -/* * 1.0.5 - 09/15/2002 - G.Juyn * */ -/* * - fixed LOOP iteration=0 special case * */ -/* * 1.0.5 - 09/19/2002 - G.Juyn * */ -/* * - misplaced TERM is now treated as warning * */ -/* * 1.0.5 - 09/20/2002 - G.Juyn * */ -/* * - added support for PAST * */ -/* * 1.0.5 - 10/03/2002 - G.Juyn * */ -/* * - fixed chunk-storage for evNT chunk * */ -/* * 1.0.5 - 10/07/2002 - G.Juyn * */ -/* * - fixed DISC support * */ -/* * - added another fix for misplaced TERM chunk * */ -/* * 1.0.5 - 10/17/2002 - G.Juyn * */ -/* * - fixed initializtion of pIds in dISC read routine * */ -/* * 1.0.5 - 11/06/2002 - G.Juyn * */ -/* * - added support for nEED "MNG 1.1" * */ -/* * - added support for nEED "CACHEOFF" * */ -/* * * */ -/* * 1.0.6 - 05/25/2003 - G.R-P * */ -/* * - added MNG_SKIPCHUNK_cHNK footprint optimizations * */ -/* * 1.0.6 - 06/02/2003 - G.R-P * */ -/* * - removed some redundant checks for iRawlen==0 * */ -/* * 1.0.6 - 06/22/2003 - G.R-P * */ -/* * - added MNG_NO_16BIT_SUPPORT, MNG_NO_DELTA_PNG reductions * */ -/* * - optionally use zlib's crc32 function instead of * */ -/* * local mng_update_crc * */ -/* * 1.0.6 - 07/14/2003 - G.R-P * */ -/* * - added MNG_NO_LOOP_SIGNALS_SUPPORTED conditional * */ -/* * 1.0.6 - 07/29/2003 - G.R-P * */ -/* * - added conditionals around PAST chunk support * */ -/* * 1.0.6 - 08/17/2003 - G.R-P * */ -/* * - added conditionals around non-VLC chunk support * */ -/* * * */ -/* * 1.0.7 - 10/29/2003 - G.R-P * */ -/* * - revised JDAA and JDAT readers to avoid compiler bug * */ -/* * 1.0.7 - 01/25/2004 - J.S * */ -/* * - added premultiplied alpha canvas' for RGBA, ARGB, ABGR * */ -/* * 1.0.7 - 01/27/2004 - J.S * */ -/* * - fixed inclusion of IJNG chunk for non-JNG use * */ -/* * 1.0.7 - 02/26/2004 - G.Juyn * */ -/* * - fixed bug in chunk-storage of SHOW chunk (from == to) * */ -/* * * */ -/* * 1.0.8 - 04/02/2004 - G.Juyn * */ -/* * - added CRC existence & checking flags * */ -/* * 1.0.8 - 07/07/2004 - G.R-P * */ -/* * - change worst-case iAlphadepth to 1 for standalone PNGs * */ -/* * * */ -/* * 1.0.9 - 09/28/2004 - G.R-P * */ -/* * - improved handling of cheap transparency when 16-bit * */ -/* * support is disabled * */ -/* * 1.0.9 - 10/04/2004 - G.Juyn * */ -/* * - fixed bug in writing sBIT for indexed color * */ -/* * 1.0.9 - 10/10/2004 - G.R-P. * */ -/* * - added MNG_NO_1_2_4BIT_SUPPORT * */ -/* * 1.0.9 - 12/05/2004 - G.Juyn * */ -/* * - added conditional MNG_OPTIMIZE_CHUNKINITFREE * */ -/* * 1.0.9 - 12/06/2004 - G.Juyn * */ -/* * - added conditional MNG_OPTIMIZE_CHUNKASSIGN * */ -/* * 1.0.9 - 12/07/2004 - G.Juyn * */ -/* * - added conditional MNG_OPTIMIZE_CHUNKREADER * */ -/* * 1.0.9 - 12/11/2004 - G.Juyn * */ -/* * - added conditional MNG_OPTIMIZE_DISPLAYCALLS * */ -/* * 1.0.9 - 12/20/2004 - G.Juyn * */ -/* * - cleaned up macro-invocations (thanks to D. Airlie) * */ -/* * 1.0.9 - 01/17/2005 - G.Juyn * */ -/* * - fixed problem with global PLTE/tRNS * */ -/* * * */ -/* * 1.0.10 - 02/07/2005 - G.Juyn * */ -/* * - fixed display routines called twice for FULL_MNG * */ -/* * support in mozlibmngconf.h * */ -/* * 1.0.10 - 12/04/2005 - G.R-P. * */ -/* * - #ifdef out use of mng_inflate_buffer when it is not * */ -/* * available. * */ -/* * 1.0.10 - 04/08/2007 - G.Juyn * */ -/* * - added support for mPNG proposal * */ -/* * 1.0.10 - 04/12/2007 - G.Juyn * */ -/* * - added support for ANG proposal * */ -/* * 1.0.10 - 05/02/2007 - G.Juyn * */ -/* * - fixed inflate_buffer for extreme compression ratios * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_objects.h" -#include "libmng_object_prc.h" -#include "libmng_chunks.h" -#ifdef MNG_CHECK_BAD_ICCP -#include "libmng_chunk_prc.h" -#endif -#include "libmng_memory.h" -#include "libmng_display.h" -#include "libmng_zlib.h" -#include "libmng_pixels.h" -#include "libmng_chunk_io.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ -/* * * */ -/* * CRC - Cyclic Redundancy Check * */ -/* * * */ -/* * The code below is taken directly from the sample provided with the * */ -/* * PNG specification. * */ -/* * (it is only adapted to the library's internal data-definitions) * */ -/* * * */ -/* ************************************************************************** */ -/* Make the table for a fast CRC. */ -#ifndef MNG_USE_ZLIB_CRC -MNG_LOCAL void make_crc_table (mng_datap pData) -{ - mng_uint32 iC; - mng_int32 iN, iK; - - for (iN = 0; iN < 256; iN++) - { - iC = (mng_uint32) iN; - - for (iK = 0; iK < 8; iK++) - { - if (iC & 1) - iC = 0xedb88320U ^ (iC >> 1); - else - iC = iC >> 1; - } - - pData->aCRCtable [iN] = iC; - } - - pData->bCRCcomputed = MNG_TRUE; -} -#endif - -/* Update a running CRC with the bytes buf[0..len-1]--the CRC - should be initialized to all 1's, and the transmitted value - is the 1's complement of the final running CRC (see the - crc() routine below). */ - -MNG_LOCAL mng_uint32 update_crc (mng_datap pData, - mng_uint32 iCrc, - mng_uint8p pBuf, - mng_int32 iLen) -{ -#ifdef MNG_USE_ZLIB_CRC - return crc32 (iCrc, pBuf, iLen); -#else - mng_uint32 iC = iCrc; - mng_int32 iN; - - if (!pData->bCRCcomputed) - make_crc_table (pData); - - for (iN = 0; iN < iLen; iN++) - iC = pData->aCRCtable [(iC ^ pBuf [iN]) & 0xff] ^ (iC >> 8); - - return iC; -#endif -} - -/* Return the CRC of the bytes buf[0..len-1]. */ -mng_uint32 mng_crc (mng_datap pData, - mng_uint8p pBuf, - mng_int32 iLen) -{ -#ifdef MNG_USE_ZLIB_CRC - return update_crc (pData, 0, pBuf, iLen); -#else - return update_crc (pData, 0xffffffffU, pBuf, iLen) ^ 0xffffffffU; -#endif -} - -/* ************************************************************************** */ -/* * * */ -/* * Routines for swapping byte-order from and to graphic files * */ -/* * (This code is adapted from the libpng package) * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_BIGENDIAN_SUPPORTED - -/* ************************************************************************** */ - -mng_uint32 mng_get_uint32 (mng_uint8p pBuf) -{ - mng_uint32 i = ((mng_uint32)(*pBuf) << 24) + - ((mng_uint32)(*(pBuf + 1)) << 16) + - ((mng_uint32)(*(pBuf + 2)) << 8) + - (mng_uint32)(*(pBuf + 3)); - return (i); -} - -/* ************************************************************************** */ - -mng_int32 mng_get_int32 (mng_uint8p pBuf) -{ - mng_int32 i = ((mng_int32)(*pBuf) << 24) + - ((mng_int32)(*(pBuf + 1)) << 16) + - ((mng_int32)(*(pBuf + 2)) << 8) + - (mng_int32)(*(pBuf + 3)); - return (i); -} - -/* ************************************************************************** */ - -mng_uint16 mng_get_uint16 (mng_uint8p pBuf) -{ - mng_uint16 i = (mng_uint16)(((mng_uint16)(*pBuf) << 8) + - (mng_uint16)(*(pBuf + 1))); - return (i); -} - -/* ************************************************************************** */ - -void mng_put_uint32 (mng_uint8p pBuf, - mng_uint32 i) -{ - *pBuf = (mng_uint8)((i >> 24) & 0xff); - *(pBuf+1) = (mng_uint8)((i >> 16) & 0xff); - *(pBuf+2) = (mng_uint8)((i >> 8) & 0xff); - *(pBuf+3) = (mng_uint8)(i & 0xff); -} - -/* ************************************************************************** */ - -void mng_put_int32 (mng_uint8p pBuf, - mng_int32 i) -{ - *pBuf = (mng_uint8)((i >> 24) & 0xff); - *(pBuf+1) = (mng_uint8)((i >> 16) & 0xff); - *(pBuf+2) = (mng_uint8)((i >> 8) & 0xff); - *(pBuf+3) = (mng_uint8)(i & 0xff); -} - -/* ************************************************************************** */ - -void mng_put_uint16 (mng_uint8p pBuf, - mng_uint16 i) -{ - *pBuf = (mng_uint8)((i >> 8) & 0xff); - *(pBuf+1) = (mng_uint8)(i & 0xff); -} - -/* ************************************************************************** */ - -#endif /* !MNG_BIGENDIAN_SUPPORTED */ - -/* ************************************************************************** */ -/* * * */ -/* * Helper routines to simplify chunk-data extraction * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_READ_PROCS - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -MNG_LOCAL mng_uint8p find_null (mng_uint8p pIn) -{ - mng_uint8p pOut = pIn; - while (*pOut) /* the read_graphic routine has made sure there's */ - pOut++; /* always at least 1 zero-byte in the buffer */ - return pOut; -} -#endif - -/* ************************************************************************** */ - -#if !defined(MNG_SKIPCHUNK_iCCP) || !defined(MNG_SKIPCHUNK_zTXt) || \ - !defined(MNG_SKIPCHUNK_iTXt) || defined(MNG_INCLUDE_MPNG_PROPOSAL) || \ - defined(MNG_INCLUDE_ANG_PROPOSAL) -mng_retcode mng_inflate_buffer (mng_datap pData, - mng_uint8p pInbuf, - mng_uint32 iInsize, - mng_uint8p *pOutbuf, - mng_uint32 *iOutsize, - mng_uint32 *iRealsize) -{ - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INFLATE_BUFFER, MNG_LC_START); -#endif - - if (iInsize) /* anything to do ? */ - { - *iOutsize = iInsize * 3; /* estimate uncompressed size */ - /* and allocate a temporary buffer */ - MNG_ALLOC (pData, *pOutbuf, *iOutsize); - - do - { - mngzlib_inflateinit (pData); /* initialize zlib */ - /* let zlib know where to store the output */ - pData->sZlib.next_out = *pOutbuf; - /* "size - 1" so we've got space for the - zero-termination of a possible string */ - pData->sZlib.avail_out = *iOutsize - 1; - /* ok; let's inflate... */ - iRetcode = mngzlib_inflatedata (pData, iInsize, pInbuf); - /* determine actual output size */ - *iRealsize = (mng_uint32)pData->sZlib.total_out; - - mngzlib_inflatefree (pData); /* zlib's done */ - - if (iRetcode == MNG_BUFOVERFLOW) /* not enough space ? */ - { /* then get some more */ - MNG_FREEX (pData, *pOutbuf, *iOutsize); - *iOutsize = *iOutsize + *iOutsize; - MNG_ALLOC (pData, *pOutbuf, *iOutsize); - } - } /* repeat if we didn't have enough space */ - while ((iRetcode == MNG_BUFOVERFLOW) && - (*iOutsize < 200 * iInsize)); - - if (!iRetcode) /* if oke ? */ - *((*pOutbuf) + *iRealsize) = 0; /* then put terminator zero */ - - } - else - { - *pOutbuf = 0; /* nothing to do; then there's no output */ - *iOutsize = 0; - *iRealsize = 0; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INFLATE_BUFFER, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_READ_PROCS */ - -/* ************************************************************************** */ -/* * * */ -/* * Helper routines to simplify chunk writing * */ -/* * * */ -/* ************************************************************************** */ -#ifdef MNG_INCLUDE_WRITE_PROCS -/* ************************************************************************** */ - -#if !defined(MNG_SKIPCHUNK_iCCP) || !defined(MNG_SKIPCHUNK_zTXt) || !defined(MNG_SKIPCHUNK_iTXt) -MNG_LOCAL mng_retcode deflate_buffer (mng_datap pData, - mng_uint8p pInbuf, - mng_uint32 iInsize, - mng_uint8p *pOutbuf, - mng_uint32 *iOutsize, - mng_uint32 *iRealsize) -{ - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DEFLATE_BUFFER, MNG_LC_START); -#endif - - if (iInsize) /* anything to do ? */ - { - *iOutsize = (iInsize * 5) >> 2; /* estimate compressed size */ - /* and allocate a temporary buffer */ - MNG_ALLOC (pData, *pOutbuf, *iOutsize); - - do - { - mngzlib_deflateinit (pData); /* initialize zlib */ - /* let zlib know where to store the output */ - pData->sZlib.next_out = *pOutbuf; - pData->sZlib.avail_out = *iOutsize; - /* ok; let's deflate... */ - iRetcode = mngzlib_deflatedata (pData, iInsize, pInbuf); - /* determine actual output size */ - *iRealsize = pData->sZlib.total_out; - - mngzlib_deflatefree (pData); /* zlib's done */ - - if (iRetcode == MNG_BUFOVERFLOW) /* not enough space ? */ - { /* then get some more */ - MNG_FREEX (pData, *pOutbuf, *iOutsize); - *iOutsize = *iOutsize + (iInsize >> 1); - MNG_ALLOC (pData, *pOutbuf, *iOutsize); - } - } /* repeat if we didn't have enough space */ - while (iRetcode == MNG_BUFOVERFLOW); - } - else - { - *pOutbuf = 0; /* nothing to do; then there's no output */ - *iOutsize = 0; - *iRealsize = 0; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DEFLATE_BUFFER, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -MNG_LOCAL mng_retcode write_raw_chunk (mng_datap pData, - mng_chunkid iChunkname, - mng_uint32 iRawlen, - mng_uint8p pRawdata) -{ - mng_uint32 iCrc; - mng_uint32 iWritten; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_RAW_CHUNK, MNG_LC_START); -#endif - /* temporary buffer ? */ - if ((pRawdata != 0) && (pRawdata != pData->pWritebuf+8)) - { /* store length & chunktype in default buffer */ - mng_put_uint32 (pData->pWritebuf, iRawlen); - mng_put_uint32 (pData->pWritebuf+4, (mng_uint32)iChunkname); - - if (pData->iCrcmode & MNG_CRC_OUTPUT) - { - if ((pData->iCrcmode & MNG_CRC_OUTPUT) == MNG_CRC_OUTPUT_GENERATE) - { /* calculate the crc */ - iCrc = update_crc (pData, 0xffffffffL, pData->pWritebuf+4, 4); - iCrc = update_crc (pData, iCrc, pRawdata, iRawlen) ^ 0xffffffffL; - } else { - iCrc = 0; /* dummy crc */ - } /* store in default buffer */ - mng_put_uint32 (pData->pWritebuf+8, iCrc); - } - /* write the length & chunktype */ - if (!pData->fWritedata ((mng_handle)pData, pData->pWritebuf, 8, &iWritten)) - MNG_ERROR (pData, MNG_APPIOERROR); - - if (iWritten != 8) /* disk full ? */ - MNG_ERROR (pData, MNG_OUTPUTERROR); - /* write the temporary buffer */ - if (!pData->fWritedata ((mng_handle)pData, pRawdata, iRawlen, &iWritten)) - MNG_ERROR (pData, MNG_APPIOERROR); - - if (iWritten != iRawlen) /* disk full ? */ - MNG_ERROR (pData, MNG_OUTPUTERROR); - - if (pData->iCrcmode & MNG_CRC_OUTPUT) - { /* write the crc */ - if (!pData->fWritedata ((mng_handle)pData, pData->pWritebuf+8, 4, &iWritten)) - MNG_ERROR (pData, MNG_APPIOERROR); - - if (iWritten != 4) /* disk full ? */ - MNG_ERROR (pData, MNG_OUTPUTERROR); - } - } - else - { /* prefix with length & chunktype */ - mng_put_uint32 (pData->pWritebuf, iRawlen); - mng_put_uint32 (pData->pWritebuf+4, (mng_uint32)iChunkname); - - if (pData->iCrcmode & MNG_CRC_OUTPUT) - { - if ((pData->iCrcmode & MNG_CRC_OUTPUT) == MNG_CRC_OUTPUT_GENERATE) - /* calculate the crc */ - iCrc = mng_crc (pData, pData->pWritebuf+4, iRawlen + 4); - else - iCrc = 0; /* dummy crc */ - /* add it to the buffer */ - mng_put_uint32 (pData->pWritebuf + iRawlen + 8, iCrc); - /* write it in a single pass */ - if (!pData->fWritedata ((mng_handle)pData, pData->pWritebuf, iRawlen + 12, &iWritten)) - MNG_ERROR (pData, MNG_APPIOERROR); - - if (iWritten != iRawlen + 12) /* disk full ? */ - MNG_ERROR (pData, MNG_OUTPUTERROR); - } else { - if (!pData->fWritedata ((mng_handle)pData, pData->pWritebuf, iRawlen + 8, &iWritten)) - MNG_ERROR (pData, MNG_APPIOERROR); - - if (iWritten != iRawlen + 8) /* disk full ? */ - MNG_ERROR (pData, MNG_OUTPUTERROR); - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_RAW_CHUNK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* B004 */ -#endif /* MNG_INCLUDE_WRITE_PROCS */ -/* B004 */ -/* ************************************************************************** */ -/* * * */ -/* * chunk read functions * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_READ_PROCS - -/* ************************************************************************** */ - -#ifdef MNG_OPTIMIZE_CHUNKREADER - -/* ************************************************************************** */ - -MNG_LOCAL mng_retcode create_chunk_storage (mng_datap pData, - mng_chunkp pHeader, - mng_uint32 iRawlen, - mng_uint8p pRawdata, - mng_field_descp pField, - mng_uint16 iFields, - mng_chunkp* ppChunk, - mng_bool bWorkcopy) -{ - mng_field_descp pTempfield = pField; - mng_uint16 iFieldcount = iFields; - mng_uint8p pTempdata = pRawdata; - mng_uint32 iTemplen = iRawlen; - mng_uint16 iLastgroup = 0; - mng_uint8p pChunkdata; - mng_uint32 iDatalen; - mng_uint8 iColortype; - mng_bool bProcess; - /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (((mng_chunk_headerp)(*ppChunk))->iChunkname == MNG_UINT_HUH) - ((mng_chunk_headerp)(*ppChunk))->iChunkname = pData->iChunkname; - - if ((!bWorkcopy) || - ((((mng_chunk_headerp)pHeader)->iChunkname != MNG_UINT_IDAT) && - (((mng_chunk_headerp)pHeader)->iChunkname != MNG_UINT_JDAT) && - (((mng_chunk_headerp)pHeader)->iChunkname != MNG_UINT_JDAA) )) - { - pChunkdata = (mng_uint8p)(*ppChunk); - -#ifdef MNG_INCLUDE_JNG /* determine current colortype */ - if (pData->bHasJHDR) - iColortype = (mng_uint8)(pData->iJHDRcolortype - 8); - else -#endif /* MNG_INCLUDE_JNG */ - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - iColortype = pData->iColortype; - else - iColortype = 6; - - if (iTemplen) /* not empty ? */ - { /* then go fill the fields */ - while ((iFieldcount) && (iTemplen)) - { - if (pTempfield->iOffsetchunk) - { - if (pTempfield->iFlags & MNG_FIELD_PUTIMGTYPE) - { - *(pChunkdata+pTempfield->iOffsetchunk) = iColortype; - bProcess = MNG_FALSE; - } - else - if (pTempfield->iFlags & MNG_FIELD_IFIMGTYPES) - bProcess = (mng_bool)(((pTempfield->iFlags & MNG_FIELD_IFIMGTYPE0) && (iColortype == 0)) || - ((pTempfield->iFlags & MNG_FIELD_IFIMGTYPE2) && (iColortype == 2)) || - ((pTempfield->iFlags & MNG_FIELD_IFIMGTYPE3) && (iColortype == 3)) || - ((pTempfield->iFlags & MNG_FIELD_IFIMGTYPE4) && (iColortype == 4)) || - ((pTempfield->iFlags & MNG_FIELD_IFIMGTYPE6) && (iColortype == 6)) ); - else - bProcess = MNG_TRUE; - - if (bProcess) - { - iLastgroup = (mng_uint16)(pTempfield->iFlags & MNG_FIELD_GROUPMASK); - /* numeric field ? */ - if (pTempfield->iFlags & MNG_FIELD_INT) - { - if (iTemplen < pTempfield->iLengthmax) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - switch (pTempfield->iLengthmax) - { - case 1 : { mng_uint8 iNum = *pTempdata; - if (((mng_uint16)iNum < pTempfield->iMinvalue) || - ((mng_uint16)iNum > pTempfield->iMaxvalue) ) - MNG_ERROR (pData, MNG_INVALIDFIELDVAL); - *(pChunkdata+pTempfield->iOffsetchunk) = iNum; - break; } - case 2 : { mng_uint16 iNum = mng_get_uint16 (pTempdata); - if ((iNum < pTempfield->iMinvalue) || (iNum > pTempfield->iMaxvalue)) - MNG_ERROR (pData, MNG_INVALIDFIELDVAL); - *((mng_uint16p)(pChunkdata+pTempfield->iOffsetchunk)) = iNum; - break; } - case 4 : { mng_uint32 iNum = mng_get_uint32 (pTempdata); - if ((iNum < pTempfield->iMinvalue) || - ((pTempfield->iFlags & MNG_FIELD_NOHIGHBIT) && (iNum & 0x80000000)) ) - MNG_ERROR (pData, MNG_INVALIDFIELDVAL); - *((mng_uint32p)(pChunkdata+pTempfield->iOffsetchunk)) = iNum; - break; } - } - - pTempdata += pTempfield->iLengthmax; - iTemplen -= pTempfield->iLengthmax; - - } else { /* not numeric so it's a bunch of bytes */ - - if (!pTempfield->iOffsetchunklen) /* big fat NONO */ - MNG_ERROR (pData, MNG_INTERNALERROR); - /* with terminating 0 ? */ - if (pTempfield->iFlags & MNG_FIELD_TERMINATOR) - { - mng_uint8p pWork = pTempdata; - while (*pWork) /* find the zero */ - pWork++; - iDatalen = (mng_uint32)(pWork - pTempdata); - } else { /* no terminator, so everything that's left ! */ - iDatalen = iTemplen; - } - - if ((pTempfield->iLengthmax) && (iDatalen > pTempfield->iLengthmax)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); -#if !defined(MNG_SKIPCHUNK_iCCP) || !defined(MNG_SKIPCHUNK_zTXt) || \ - !defined(MNG_SKIPCHUNK_iTXt) || defined(MNG_INCLUDE_MPNG_PROPOSAL) || \ - defined(MNG_INCLUDE_ANG_PROPOSAL) - /* needs decompression ? */ - if (pTempfield->iFlags & MNG_FIELD_DEFLATED) - { - mng_uint8p pBuf = 0; - mng_uint32 iBufsize = 0; - mng_uint32 iRealsize; - mng_ptr pWork; - - iRetcode = mng_inflate_buffer (pData, pTempdata, iDatalen, - &pBuf, &iBufsize, &iRealsize); - -#ifdef MNG_CHECK_BAD_ICCP /* Check for bad iCCP chunk */ - if ((iRetcode) && (((mng_chunk_headerp)pHeader)->iChunkname == MNG_UINT_iCCP)) - { - *((mng_ptr *)(pChunkdata+pTempfield->iOffsetchunk)) = MNG_NULL; - *((mng_uint32p)(pChunkdata+pTempfield->iOffsetchunklen)) = iDatalen; - } - else -#endif - { - if (iRetcode) - return iRetcode; - -#if defined(MNG_INCLUDE_MPNG_PROPOSAL) || defined(MNG_INCLUDE_ANG_PROPOSAL) - if ( (((mng_chunk_headerp)pHeader)->iChunkname == MNG_UINT_mpNG) || - (((mng_chunk_headerp)pHeader)->iChunkname == MNG_UINT_adAT) ) - { - MNG_ALLOC (pData, pWork, iRealsize); - } - else - { -#endif - /* don't forget to generate null terminator */ - MNG_ALLOC (pData, pWork, iRealsize+1); -#if defined(MNG_INCLUDE_MPNG_PROPOSAL) || defined(MNG_INCLUDE_ANG_PROPOSAL) - } -#endif - MNG_COPY (pWork, pBuf, iRealsize); - - *((mng_ptr *)(pChunkdata+pTempfield->iOffsetchunk)) = pWork; - *((mng_uint32p)(pChunkdata+pTempfield->iOffsetchunklen)) = iRealsize; - } - - if (pBuf) /* free the temporary buffer */ - MNG_FREEX (pData, pBuf, iBufsize); - - } else -#endif - { /* no decompression, so just copy */ - - mng_ptr pWork; - /* don't forget to generate null terminator */ - MNG_ALLOC (pData, pWork, iDatalen+1); - MNG_COPY (pWork, pTempdata, iDatalen); - - *((mng_ptr *)(pChunkdata+pTempfield->iOffsetchunk)) = pWork; - *((mng_uint32p)(pChunkdata+pTempfield->iOffsetchunklen)) = iDatalen; - } - - if (pTempfield->iFlags & MNG_FIELD_TERMINATOR) - iDatalen++; /* skip the terminating zero as well !!! */ - - iTemplen -= iDatalen; - pTempdata += iDatalen; - } - /* need to set an indicator ? */ - if (pTempfield->iOffsetchunkind) - *((mng_uint8p)(pChunkdata+pTempfield->iOffsetchunkind)) = MNG_TRUE; - } - } - - if (pTempfield->pSpecialfunc) /* special function required ? */ - { - iRetcode = pTempfield->pSpecialfunc(pData, *ppChunk, &iTemplen, &pTempdata); - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - pTempfield++; /* Neeeeeeexxxtt */ - iFieldcount--; - } - - if (iTemplen) /* extra data ??? */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - while (iFieldcount) /* not enough data ??? */ - { - if (pTempfield->iFlags & MNG_FIELD_IFIMGTYPES) - bProcess = (mng_bool)(((pTempfield->iFlags & MNG_FIELD_IFIMGTYPE0) && (iColortype == 0)) || - ((pTempfield->iFlags & MNG_FIELD_IFIMGTYPE2) && (iColortype == 2)) || - ((pTempfield->iFlags & MNG_FIELD_IFIMGTYPE3) && (iColortype == 3)) || - ((pTempfield->iFlags & MNG_FIELD_IFIMGTYPE4) && (iColortype == 4)) || - ((pTempfield->iFlags & MNG_FIELD_IFIMGTYPE6) && (iColortype == 6)) ); - else - bProcess = MNG_TRUE; - - if (bProcess) - { - if (!(pTempfield->iFlags & MNG_FIELD_OPTIONAL)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - if ((pTempfield->iFlags & MNG_FIELD_GROUPMASK) && - ((mng_uint16)(pTempfield->iFlags & MNG_FIELD_GROUPMASK) == iLastgroup)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } - - pTempfield++; - iFieldcount--; - } - } - } - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -READ_CHUNK (mng_read_general) -{ - mng_retcode iRetcode = MNG_NOERROR; - mng_chunk_descp pDescr = ((mng_chunk_headerp)pHeader)->pChunkdescr; - mng_field_descp pField; - mng_uint16 iFields; - - if (!pDescr) /* this is a bad booboo !!! */ - MNG_ERROR (pData, MNG_INTERNALERROR); - - pField = pDescr->pFielddesc; - iFields = pDescr->iFielddesc; - /* check chunk against signature */ - if ((pDescr->eImgtype == mng_it_mng) && (pData->eSigtype != mng_it_mng)) - MNG_ERROR (pData, MNG_CHUNKNOTALLOWED); - - if ((pDescr->eImgtype == mng_it_jng) && (pData->eSigtype == mng_it_png)) - MNG_ERROR (pData, MNG_CHUNKNOTALLOWED); - /* empties allowed ? */ - if ((iRawlen == 0) && (!(pDescr->iAllowed & MNG_DESCR_EMPTY))) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - if ((pData->eImagetype != mng_it_mng) || (!(pDescr->iAllowed & MNG_DESCR_GLOBAL))) - { /* *a* header required ? */ - if ((pDescr->iMusthaves & MNG_DESCR_GenHDR) && -#ifdef MNG_INCLUDE_JNG - (!pData->bHasIHDR) && (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - (!pData->bHasIHDR) && (!pData->bHasBASI) && (!pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pDescr->iMusthaves & MNG_DESCR_JngHDR) && - (!pData->bHasDHDR) && (!pData->bHasJHDR)) - MNG_ERROR (pData, MNG_SEQUENCEERROR); -#endif - } - /* specific chunk pre-requisite ? */ - if (((pDescr->iMusthaves & MNG_DESCR_IHDR) && (!pData->bHasIHDR)) || -#ifdef MNG_INCLUDE_JNG - ((pDescr->iMusthaves & MNG_DESCR_JHDR) && (!pData->bHasJHDR)) || -#endif - ((pDescr->iMusthaves & MNG_DESCR_DHDR) && (!pData->bHasDHDR)) || - ((pDescr->iMusthaves & MNG_DESCR_LOOP) && (!pData->bHasLOOP)) || - ((pDescr->iMusthaves & MNG_DESCR_PLTE) && (!pData->bHasPLTE)) || - ((pDescr->iMusthaves & MNG_DESCR_MHDR) && (!pData->bHasMHDR)) || - ((pDescr->iMusthaves & MNG_DESCR_SAVE) && (!pData->bHasSAVE)) ) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - /* specific chunk undesired ? */ - if (((pDescr->iMustNOThaves & MNG_DESCR_NOIHDR) && (pData->bHasIHDR)) || - ((pDescr->iMustNOThaves & MNG_DESCR_NOBASI) && (pData->bHasBASI)) || - ((pDescr->iMustNOThaves & MNG_DESCR_NODHDR) && (pData->bHasDHDR)) || - ((pDescr->iMustNOThaves & MNG_DESCR_NOIDAT) && (pData->bHasIDAT)) || - ((pDescr->iMustNOThaves & MNG_DESCR_NOPLTE) && (pData->bHasPLTE)) || -#ifdef MNG_INCLUDE_JNG - ((pDescr->iMustNOThaves & MNG_DESCR_NOJHDR) && (pData->bHasJHDR)) || - ((pDescr->iMustNOThaves & MNG_DESCR_NOJDAT) && (pData->bHasJDAT)) || - ((pDescr->iMustNOThaves & MNG_DESCR_NOJDAA) && (pData->bHasJDAA)) || - ((pDescr->iMustNOThaves & MNG_DESCR_NOJSEP) && (pData->bHasJSEP)) || -#endif - ((pDescr->iMustNOThaves & MNG_DESCR_NOMHDR) && (pData->bHasMHDR)) || - ((pDescr->iMustNOThaves & MNG_DESCR_NOLOOP) && (pData->bHasLOOP)) || - ((pDescr->iMustNOThaves & MNG_DESCR_NOTERM) && (pData->bHasTERM)) || - ((pDescr->iMustNOThaves & MNG_DESCR_NOSAVE) && (pData->bHasSAVE)) ) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (pData->eSigtype == mng_it_mng) /* check global and embedded empty chunks */ - { -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { - if ((iRawlen == 0) && (!(pDescr->iAllowed & MNG_DESCR_EMPTYEMBED))) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } else { - if ((iRawlen == 0) && (!(pDescr->iAllowed & MNG_DESCR_EMPTYGLOBAL))) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } - } - - if (pDescr->pSpecialfunc) /* need special processing ? */ - { - iRetcode = create_chunk_storage (pData, pHeader, iRawlen, pRawdata, - pField, iFields, ppChunk, MNG_TRUE); - if (iRetcode) /* on error bail out */ - return iRetcode; - /* empty indicator ? */ - if ((!iRawlen) && (pDescr->iOffsetempty)) - *(((mng_uint8p)*ppChunk)+pDescr->iOffsetempty) = MNG_TRUE; - - iRetcode = pDescr->pSpecialfunc(pData, *ppChunk); - if (iRetcode) /* on error bail out */ - return iRetcode; - - if ((((mng_chunk_headerp)pHeader)->iChunkname == MNG_UINT_IDAT) || - (((mng_chunk_headerp)pHeader)->iChunkname == MNG_UINT_JDAT) || - (((mng_chunk_headerp)pHeader)->iChunkname == MNG_UINT_JDAA) ) - { - iRetcode = ((mng_chunk_headerp)*ppChunk)->fCleanup (pData, *ppChunk); - if (iRetcode) /* on error bail out */ - return iRetcode; - *ppChunk = MNG_NULL; - } else { -#ifdef MNG_STORE_CHUNKS - if (!pData->bStorechunks) -#endif - { - iRetcode = ((mng_chunk_headerp)*ppChunk)->fCleanup (pData, *ppChunk); - if (iRetcode) /* on error bail out */ - return iRetcode; - *ppChunk = MNG_NULL; - } - } - } - -#ifdef MNG_SUPPORT_DISPLAY - if (iRawlen) - { -#ifdef MNG_OPTIMIZE_DISPLAYCALLS - pData->iRawlen = iRawlen; - pData->pRawdata = pRawdata; -#endif - - /* display processing */ -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - if (((mng_chunk_headerp)pHeader)->iChunkname == MNG_UINT_IDAT) - iRetcode = mng_process_display_idat (pData, iRawlen, pRawdata); -#ifdef MNG_INCLUDE_JNG - else - if (((mng_chunk_headerp)pHeader)->iChunkname == MNG_UINT_JDAT) - iRetcode = mng_process_display_jdat (pData, iRawlen, pRawdata); - else - if (((mng_chunk_headerp)pHeader)->iChunkname == MNG_UINT_JDAA) - iRetcode = mng_process_display_jdaa (pData, iRawlen, pRawdata); -#endif -#else - if (((mng_chunk_headerp)pHeader)->iChunkname == MNG_UINT_IDAT) - iRetcode = mng_process_display_idat (pData); -#ifdef MNG_INCLUDE_JNG - else - if (((mng_chunk_headerp)pHeader)->iChunkname == MNG_UINT_JDAT) - iRetcode = mng_process_display_jdat (pData); - else - if (((mng_chunk_headerp)pHeader)->iChunkname == MNG_UINT_JDAA) - iRetcode = mng_process_display_jdaa (pData); -#endif -#endif - - if (iRetcode) - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if ((pData->bStorechunks) && (!(*ppChunk))) - { - iRetcode = create_chunk_storage (pData, pHeader, iRawlen, pRawdata, - pField, iFields, ppChunk, MNG_FALSE); - if (iRetcode) /* on error bail out */ - return iRetcode; - /* empty indicator ? */ - if ((!iRawlen) && (pDescr->iOffsetempty)) - *(((mng_uint8p)*ppChunk)+pDescr->iOffsetempty) = MNG_TRUE; - } -#endif /* MNG_STORE_CHUNKS */ - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_OPTIMIZE_CHUNKREADER */ - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -READ_CHUNK (mng_read_ihdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IHDR, MNG_LC_START); -#endif - - if (iRawlen != 13) /* length oke ? */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - /* only allowed inside PNG or MNG */ - if ((pData->eSigtype != mng_it_png) && (pData->eSigtype != mng_it_mng)) - MNG_ERROR (pData, MNG_CHUNKNOTALLOWED); - /* sequence checks */ - if ((pData->eSigtype == mng_it_png) && (pData->iChunkseq > 1)) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasIDAT) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasIDAT)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - pData->bHasIHDR = MNG_TRUE; /* indicate IHDR is present */ - /* and store interesting fields */ - if ((!pData->bHasDHDR) || (pData->iDeltatype == MNG_DELTATYPE_NOCHANGE)) - { - pData->iDatawidth = mng_get_uint32 (pRawdata); - pData->iDataheight = mng_get_uint32 (pRawdata+4); - } - - pData->iBitdepth = *(pRawdata+8); - pData->iColortype = *(pRawdata+9); - pData->iCompression = *(pRawdata+10); - pData->iFilter = *(pRawdata+11); - pData->iInterlace = *(pRawdata+12); - -#if defined(MNG_NO_1_2_4BIT_SUPPORT) || defined(MNG_NO_16BIT_SUPPORT) - pData->iPNGmult = 1; - pData->iPNGdepth = pData->iBitdepth; -#endif - -#ifdef MNG_NO_1_2_4BIT_SUPPORT - if (pData->iBitdepth < 8) - pData->iBitdepth = 8; -#endif - -#ifdef MNG_NO_16BIT_SUPPORT - if (pData->iBitdepth > 8) - { - pData->iBitdepth = 8; - pData->iPNGmult = 2; - } -#endif - - if ((pData->iBitdepth != 8) /* parameter validity checks */ -#ifndef MNG_NO_1_2_4BIT_SUPPORT - && (pData->iBitdepth != 1) && - (pData->iBitdepth != 2) && - (pData->iBitdepth != 4) -#endif -#ifndef MNG_NO_16BIT_SUPPORT - && (pData->iBitdepth != 16) -#endif - ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH); - - if ((pData->iColortype != MNG_COLORTYPE_GRAY ) && - (pData->iColortype != MNG_COLORTYPE_RGB ) && - (pData->iColortype != MNG_COLORTYPE_INDEXED) && - (pData->iColortype != MNG_COLORTYPE_GRAYA ) && - (pData->iColortype != MNG_COLORTYPE_RGBA ) ) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE); - - if ((pData->iColortype == MNG_COLORTYPE_INDEXED) && (pData->iBitdepth > 8)) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH); - - if (((pData->iColortype == MNG_COLORTYPE_RGB ) || - (pData->iColortype == MNG_COLORTYPE_GRAYA ) || - (pData->iColortype == MNG_COLORTYPE_RGBA ) ) && - (pData->iBitdepth < 8 ) ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH); - - if (pData->iCompression != MNG_COMPRESSION_DEFLATE) - MNG_ERROR (pData, MNG_INVALIDCOMPRESS); - -#if defined(FILTER192) || defined(FILTER193) - if ((pData->iFilter != MNG_FILTER_ADAPTIVE ) && -#if defined(FILTER192) && defined(FILTER193) - (pData->iFilter != MNG_FILTER_DIFFERING) && - (pData->iFilter != MNG_FILTER_NOFILTER ) ) -#else -#ifdef FILTER192 - (pData->iFilter != MNG_FILTER_DIFFERING) ) -#else - (pData->iFilter != MNG_FILTER_NOFILTER ) ) -#endif -#endif - MNG_ERROR (pData, MNG_INVALIDFILTER); -#else - if (pData->iFilter) - MNG_ERROR (pData, MNG_INVALIDFILTER); -#endif - - if ((pData->iInterlace != MNG_INTERLACE_NONE ) && - (pData->iInterlace != MNG_INTERLACE_ADAM7) ) - MNG_ERROR (pData, MNG_INVALIDINTERLACE); - -#ifdef MNG_SUPPORT_DISPLAY -#ifndef MNG_NO_DELTA_PNG - if (pData->bHasDHDR) /* check the colortype for delta-images ! */ - { - mng_imagedatap pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - - if (pData->iColortype != pBuf->iColortype) - { - if ( ( (pData->iColortype != MNG_COLORTYPE_INDEXED) || - (pBuf->iColortype == MNG_COLORTYPE_GRAY ) ) && - ( (pData->iColortype != MNG_COLORTYPE_GRAY ) || - (pBuf->iColortype == MNG_COLORTYPE_INDEXED) ) ) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE); - } - } -#endif -#endif - - if (!pData->bHasheader) /* first chunk ? */ - { - pData->bHasheader = MNG_TRUE; /* we've got a header */ - pData->eImagetype = mng_it_png; /* then this must be a PNG */ - pData->iWidth = pData->iDatawidth; - pData->iHeight = pData->iDataheight; - /* predict alpha-depth ! */ - if ((pData->iColortype == MNG_COLORTYPE_GRAYA ) || - (pData->iColortype == MNG_COLORTYPE_RGBA ) ) - pData->iAlphadepth = pData->iBitdepth; - else - if (pData->iColortype == MNG_COLORTYPE_INDEXED) - pData->iAlphadepth = 8; /* worst case scenario */ - else - pData->iAlphadepth = 1; /* Possible tRNS cheap binary transparency */ - /* fits on maximum canvas ? */ - if ((pData->iWidth > pData->iMaxwidth) || (pData->iHeight > pData->iMaxheight)) - MNG_WARNING (pData, MNG_IMAGETOOLARGE); - -#if !defined(MNG_INCLUDE_MPNG_PROPOSAL) || !defined(MNG_SUPPORT_DISPLAY) - if (pData->fProcessheader) /* inform the app ? */ - if (!pData->fProcessheader (((mng_handle)pData), pData->iWidth, pData->iHeight)) - MNG_ERROR (pData, MNG_APPMISCERROR); -#endif - } - - if (!pData->bHasDHDR) - pData->iImagelevel++; /* one level deeper */ - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode = mng_process_display_ihdr (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the fields */ - ((mng_ihdrp)*ppChunk)->iWidth = mng_get_uint32 (pRawdata); - ((mng_ihdrp)*ppChunk)->iHeight = mng_get_uint32 (pRawdata+4); - ((mng_ihdrp)*ppChunk)->iBitdepth = pData->iBitdepth; - ((mng_ihdrp)*ppChunk)->iColortype = pData->iColortype; - ((mng_ihdrp)*ppChunk)->iCompression = pData->iCompression; - ((mng_ihdrp)*ppChunk)->iFilter = pData->iFilter; - ((mng_ihdrp)*ppChunk)->iInterlace = pData->iInterlace; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif /* MNG_OPTIMIZE_CHUNKREADER */ - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -READ_CHUNK (mng_read_plte) -{ -#if defined(MNG_SUPPORT_DISPLAY) || defined(MNG_STORE_CHUNKS) - mng_uint32 iX; - mng_uint8p pRawdata2; -#endif -#ifdef MNG_SUPPORT_DISPLAY - mng_uint32 iRawlen2; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PLTE, MNG_LC_START); -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIDAT) || (pData->bHasJHDR)) -#else - if (pData->bHasIDAT) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - /* multiple PLTE only inside BASI */ - if ((pData->bHasPLTE) && (!pData->bHasBASI)) - MNG_ERROR (pData, MNG_MULTIPLEERROR); - /* length must be multiple of 3 */ - if (((iRawlen % 3) != 0) || (iRawlen > 768)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { /* only allowed for indexed-color or - rgb(a)-color! */ - if ((pData->iColortype != 2) && (pData->iColortype != 3) && (pData->iColortype != 6)) - MNG_ERROR (pData, MNG_CHUNKNOTALLOWED); - /* empty only allowed if global present */ - if ((iRawlen == 0) && (!pData->bHasglobalPLTE)) - MNG_ERROR (pData, MNG_CANNOTBEEMPTY); - } - else - { - if (iRawlen == 0) /* cannot be empty as global! */ - MNG_ERROR (pData, MNG_CANNOTBEEMPTY); - } - - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - pData->bHasPLTE = MNG_TRUE; /* got it! */ - else - pData->bHasglobalPLTE = MNG_TRUE; - - pData->iPLTEcount = iRawlen / 3; - -#ifdef MNG_SUPPORT_DISPLAY - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { - mng_imagep pImage; - mng_imagedatap pBuf; - -#ifndef MNG_NO_DELTA_PNG - if (pData->bHasDHDR) /* processing delta-image ? */ - { /* store in object 0 !!! */ - pImage = (mng_imagep)pData->pObjzero; - pBuf = pImage->pImgbuf; - pBuf->bHasPLTE = MNG_TRUE; /* it's definitely got a PLTE now */ - pBuf->iPLTEcount = iRawlen / 3; /* this is the exact length */ - pRawdata2 = pRawdata; /* copy the entries */ - - for (iX = 0; iX < iRawlen / 3; iX++) - { - pBuf->aPLTEentries[iX].iRed = *pRawdata2; - pBuf->aPLTEentries[iX].iGreen = *(pRawdata2+1); - pBuf->aPLTEentries[iX].iBlue = *(pRawdata2+2); - - pRawdata2 += 3; - } - } - else -#endif - { /* get the current object */ - pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* no object then dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; /* address the object buffer */ - pBuf->bHasPLTE = MNG_TRUE; /* and tell it it's got a PLTE now */ - - if (!iRawlen) /* if empty, inherit from global */ - { - pBuf->iPLTEcount = pData->iGlobalPLTEcount; - MNG_COPY (pBuf->aPLTEentries, pData->aGlobalPLTEentries, - sizeof (pBuf->aPLTEentries)); - - if (pData->bHasglobalTRNS) /* also copy global tRNS ? */ - { /* indicate tRNS available */ - pBuf->bHasTRNS = MNG_TRUE; - - iRawlen2 = pData->iGlobalTRNSrawlen; - pRawdata2 = (mng_uint8p)(pData->aGlobalTRNSrawdata); - /* global length oke ? */ - if ((iRawlen2 == 0) || (iRawlen2 > pBuf->iPLTEcount)) - MNG_ERROR (pData, MNG_GLOBALLENGTHERR); - /* copy it */ - pBuf->iTRNScount = iRawlen2; - MNG_COPY (pBuf->aTRNSentries, pRawdata2, iRawlen2); - } - } - else - { /* store fields for future reference */ - pBuf->iPLTEcount = iRawlen / 3; - pRawdata2 = pRawdata; - - for (iX = 0; iX < pBuf->iPLTEcount; iX++) - { - pBuf->aPLTEentries[iX].iRed = *pRawdata2; - pBuf->aPLTEentries[iX].iGreen = *(pRawdata2+1); - pBuf->aPLTEentries[iX].iBlue = *(pRawdata2+2); - - pRawdata2 += 3; - } - } - } - } - else /* store as global */ - { - pData->iGlobalPLTEcount = iRawlen / 3; - pRawdata2 = pRawdata; - - for (iX = 0; iX < pData->iGlobalPLTEcount; iX++) - { - pData->aGlobalPLTEentries[iX].iRed = *pRawdata2; - pData->aGlobalPLTEentries[iX].iGreen = *(pRawdata2+1); - pData->aGlobalPLTEentries[iX].iBlue = *(pRawdata2+2); - - pRawdata2 += 3; - } - - { /* create an animation object */ - mng_retcode iRetcode = mng_create_ani_plte (pData, pData->iGlobalPLTEcount, - pData->aGlobalPLTEentries); - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_pltep)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - ((mng_pltep)*ppChunk)->iEntrycount = iRawlen / 3; - pRawdata2 = pRawdata; - - for (iX = 0; iX < ((mng_pltep)*ppChunk)->iEntrycount; iX++) - { - ((mng_pltep)*ppChunk)->aEntries[iX].iRed = *pRawdata2; - ((mng_pltep)*ppChunk)->aEntries[iX].iGreen = *(pRawdata2+1); - ((mng_pltep)*ppChunk)->aEntries[iX].iBlue = *(pRawdata2+2); - - pRawdata2 += 3; - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PLTE, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif /* MNG_OPTIMIZE_CHUNKREADER */ - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -READ_CHUNK (mng_read_idat) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IDAT, MNG_LC_START); -#endif - -#ifdef MNG_INCLUDE_JNG /* sequence checks */ - if ((!pData->bHasIHDR) && (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasIHDR) && (!pData->bHasBASI) && (!pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasJHDR) && - (pData->iJHDRalphacompression != MNG_COMPRESSION_DEFLATE)) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (pData->bHasJSEP) - MNG_ERROR (pData, MNG_SEQUENCEERROR); -#endif - /* not allowed for deltatype NO_CHANGE */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && ((pData->iDeltatype == MNG_DELTATYPE_NOCHANGE))) - MNG_ERROR (pData, MNG_CHUNKNOTALLOWED); -#endif - /* can only be empty in BASI-block! */ - if ((iRawlen == 0) && (!pData->bHasBASI)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - /* indexed-color requires PLTE */ - if ((pData->bHasIHDR) && (pData->iColortype == 3) && (!pData->bHasPLTE)) - MNG_ERROR (pData, MNG_PLTEMISSING); - - pData->bHasIDAT = MNG_TRUE; /* got some IDAT now, don't we */ - -#ifdef MNG_SUPPORT_DISPLAY - if (iRawlen) - { /* display processing */ - mng_retcode iRetcode = mng_process_display_idat (pData, iRawlen, pRawdata); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_idatp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - ((mng_idatp)*ppChunk)->iDatasize = iRawlen; - - if (iRawlen != 0) /* is there any data ? */ - { - MNG_ALLOC (pData, ((mng_idatp)*ppChunk)->pData, iRawlen); - MNG_COPY (((mng_idatp)*ppChunk)->pData, pRawdata, iRawlen); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IDAT, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -READ_CHUNK (mng_read_iend) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IEND, MNG_LC_START); -#endif - - if (iRawlen > 0) /* must not contain data! */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#ifdef MNG_INCLUDE_JNG /* sequence checks */ - if ((!pData->bHasIHDR) && (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasIHDR) && (!pData->bHasBASI) && (!pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - /* IHDR-block requires IDAT */ - if ((pData->bHasIHDR) && (!pData->bHasIDAT)) - MNG_ERROR (pData, MNG_IDATMISSING); - - pData->iImagelevel--; /* one level up */ - -#ifdef MNG_SUPPORT_DISPLAY - { /* create an animation object */ - mng_retcode iRetcode = mng_create_ani_image (pData); - if (iRetcode) /* on error bail out */ - return iRetcode; - /* display processing */ - iRetcode = mng_process_display_iend (pData); - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_SUPPORT_DISPLAY - if (!pData->bTimerset) /* reset only if not broken !!! */ - { -#endif - /* IEND signals the end for most ... */ - pData->bHasIHDR = MNG_FALSE; - pData->bHasBASI = MNG_FALSE; - pData->bHasDHDR = MNG_FALSE; -#ifdef MNG_INCLUDE_JNG - pData->bHasJHDR = MNG_FALSE; - pData->bHasJSEP = MNG_FALSE; - pData->bHasJDAA = MNG_FALSE; - pData->bHasJDAT = MNG_FALSE; -#endif - pData->bHasPLTE = MNG_FALSE; - pData->bHasTRNS = MNG_FALSE; - pData->bHasGAMA = MNG_FALSE; - pData->bHasCHRM = MNG_FALSE; - pData->bHasSRGB = MNG_FALSE; - pData->bHasICCP = MNG_FALSE; - pData->bHasBKGD = MNG_FALSE; - pData->bHasIDAT = MNG_FALSE; -#ifdef MNG_SUPPORT_DISPLAY - } -#endif - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IEND, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -READ_CHUNK (mng_read_trns) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_TRNS, MNG_LC_START); -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIDAT) || (pData->bHasJHDR)) -#else - if (pData->bHasIDAT) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - /* multiple tRNS only inside BASI */ - if ((pData->bHasTRNS) && (!pData->bHasBASI)) - MNG_ERROR (pData, MNG_MULTIPLEERROR); - - if (iRawlen > 256) /* it just can't be bigger than that! */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { /* not allowed with full alpha-channel */ - if ((pData->iColortype == 4) || (pData->iColortype == 6)) - MNG_ERROR (pData, MNG_CHUNKNOTALLOWED); - - if (iRawlen != 0) /* filled ? */ - { /* length checks */ - if ((pData->iColortype == 0) && (iRawlen != 2)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - if ((pData->iColortype == 2) && (iRawlen != 6)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#ifdef MNG_SUPPORT_DISPLAY - if (pData->iColortype == 3) - { - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - mng_imagedatap pBuf; - - if (!pImage) /* no object then check obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; /* address object buffer */ - - if (iRawlen > pBuf->iPLTEcount) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } -#endif - } - else /* if empty there must be global stuff! */ - { - if (!pData->bHasglobalTRNS) - MNG_ERROR (pData, MNG_CANNOTBEEMPTY); - } - } - - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - pData->bHasTRNS = MNG_TRUE; /* indicate tRNS available */ - else - pData->bHasglobalTRNS = MNG_TRUE; - -#ifdef MNG_SUPPORT_DISPLAY - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { - mng_imagep pImage; - mng_imagedatap pBuf; - mng_uint8p pRawdata2; - mng_uint32 iRawlen2; - -#ifndef MNG_NO_DELTA_PNG - if (pData->bHasDHDR) /* processing delta-image ? */ - { /* store in object 0 !!! */ - pImage = (mng_imagep)pData->pObjzero; - pBuf = pImage->pImgbuf; /* address object buffer */ - - switch (pData->iColortype) /* store fields for future reference */ - { - case 0: { /* gray */ -#if defined(MNG_NO_1_2_4BIT_SUPPORT) - mng_uint8 multiplier[]={0,255,85,0,17,0,0,0,1, - 0,0,0,0,0,0,0,1}; -#endif - pBuf->iTRNSgray = mng_get_uint16 (pRawdata); - pBuf->iTRNSred = 0; - pBuf->iTRNSgreen = 0; - pBuf->iTRNSblue = 0; - pBuf->iTRNScount = 0; -#if defined(MNG_NO_1_2_4BIT_SUPPORT) - pBuf->iTRNSgray *= multiplier[pData->iPNGdepth]; -#endif -#if defined(MNG_NO_16BIT_SUPPORT) - if (pData->iPNGmult == 2) - pBuf->iTRNSgray >>= 8; -#endif - break; - } - case 2: { /* rgb */ - pBuf->iTRNSgray = 0; - pBuf->iTRNSred = mng_get_uint16 (pRawdata); - pBuf->iTRNSgreen = mng_get_uint16 (pRawdata+2); - pBuf->iTRNSblue = mng_get_uint16 (pRawdata+4); - pBuf->iTRNScount = 0; -#if defined(MNG_NO_16BIT_SUPPORT) - if (pData->iPNGmult == 2) - { - pBuf->iTRNSred >>= 8; - pBuf->iTRNSgreen >>= 8; - pBuf->iTRNSblue >>= 8; - } -#endif - break; - } - case 3: { /* indexed */ - pBuf->iTRNSgray = 0; - pBuf->iTRNSred = 0; - pBuf->iTRNSgreen = 0; - pBuf->iTRNSblue = 0; - pBuf->iTRNScount = iRawlen; - MNG_COPY (pBuf->aTRNSentries, pRawdata, iRawlen); - break; - } - } - - pBuf->bHasTRNS = MNG_TRUE; /* tell it it's got a tRNS now */ - } - else -#endif - { /* address current object */ - pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* no object then dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; /* address object buffer */ - pBuf->bHasTRNS = MNG_TRUE; /* and tell it it's got a tRNS now */ - - if (iRawlen == 0) /* if empty, inherit from global */ - { - iRawlen2 = pData->iGlobalTRNSrawlen; - pRawdata2 = (mng_ptr)(pData->aGlobalTRNSrawdata); - /* global length oke ? */ - if ((pData->iColortype == 0) && (iRawlen2 != 2)) - MNG_ERROR (pData, MNG_GLOBALLENGTHERR); - - if ((pData->iColortype == 2) && (iRawlen2 != 6)) - MNG_ERROR (pData, MNG_GLOBALLENGTHERR); - - if ((pData->iColortype == 3) && ((iRawlen2 == 0) || (iRawlen2 > pBuf->iPLTEcount))) - MNG_ERROR (pData, MNG_GLOBALLENGTHERR); - } - else - { - iRawlen2 = iRawlen; - pRawdata2 = pRawdata; - } - - switch (pData->iColortype) /* store fields for future reference */ - { - case 0: { /* gray */ - pBuf->iTRNSgray = mng_get_uint16 (pRawdata2); - pBuf->iTRNSred = 0; - pBuf->iTRNSgreen = 0; - pBuf->iTRNSblue = 0; - pBuf->iTRNScount = 0; -#if defined(MNG_NO_16BIT_SUPPORT) - if (pData->iPNGmult == 2) - pBuf->iTRNSgray >>= 8; -#endif - break; - } - case 2: { /* rgb */ - pBuf->iTRNSgray = 0; - pBuf->iTRNSred = mng_get_uint16 (pRawdata2); - pBuf->iTRNSgreen = mng_get_uint16 (pRawdata2+2); - pBuf->iTRNSblue = mng_get_uint16 (pRawdata2+4); - pBuf->iTRNScount = 0; -#if defined(MNG_NO_16BIT_SUPPORT) - if (pData->iPNGmult == 2) - { - pBuf->iTRNSred >>= 8; - pBuf->iTRNSgreen >>= 8; - pBuf->iTRNSblue >>= 8; - } -#endif - break; - } - case 3: { /* indexed */ - pBuf->iTRNSgray = 0; - pBuf->iTRNSred = 0; - pBuf->iTRNSgreen = 0; - pBuf->iTRNSblue = 0; - pBuf->iTRNScount = iRawlen2; - MNG_COPY (pBuf->aTRNSentries, pRawdata2, iRawlen2); - break; - } - } - } - } - else /* store as global */ - { - pData->iGlobalTRNSrawlen = iRawlen; - MNG_COPY (pData->aGlobalTRNSrawdata, pRawdata, iRawlen); - - { /* create an animation object */ - mng_retcode iRetcode = mng_create_ani_trns (pData, pData->iGlobalTRNSrawlen, - pData->aGlobalTRNSrawdata); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { /* not global! */ - ((mng_trnsp)*ppChunk)->bGlobal = MNG_FALSE; - ((mng_trnsp)*ppChunk)->iType = pData->iColortype; - - if (iRawlen == 0) /* if empty, indicate so */ - ((mng_trnsp)*ppChunk)->bEmpty = MNG_TRUE; - else - { - ((mng_trnsp)*ppChunk)->bEmpty = MNG_FALSE; - - switch (pData->iColortype) /* store fields */ - { - case 0: { /* gray */ - ((mng_trnsp)*ppChunk)->iGray = mng_get_uint16 (pRawdata); - break; - } - case 2: { /* rgb */ - ((mng_trnsp)*ppChunk)->iRed = mng_get_uint16 (pRawdata); - ((mng_trnsp)*ppChunk)->iGreen = mng_get_uint16 (pRawdata+2); - ((mng_trnsp)*ppChunk)->iBlue = mng_get_uint16 (pRawdata+4); - break; - } - case 3: { /* indexed */ - ((mng_trnsp)*ppChunk)->iCount = iRawlen; - MNG_COPY (((mng_trnsp)*ppChunk)->aEntries, pRawdata, iRawlen); - break; - } - } - } - } - else /* it's global! */ - { - ((mng_trnsp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - ((mng_trnsp)*ppChunk)->bGlobal = MNG_TRUE; - ((mng_trnsp)*ppChunk)->iType = 0; - ((mng_trnsp)*ppChunk)->iRawlen = iRawlen; - - MNG_COPY (((mng_trnsp)*ppChunk)->aRawdata, pRawdata, iRawlen); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_TRNS, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -READ_CHUNK (mng_read_gama) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_GAMA, MNG_LC_START); -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIDAT) || (pData->bHasPLTE) || (pData->bHasJDAT) || (pData->bHasJDAA)) -#else - if ((pData->bHasIDAT) || (pData->bHasPLTE)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { /* length must be exactly 4 */ - if (iRawlen != 4) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } - else - { /* length must be empty or exactly 4 */ - if ((iRawlen != 0) && (iRawlen != 4)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - pData->bHasGAMA = MNG_TRUE; /* indicate we've got it */ - else - pData->bHasglobalGAMA = (mng_bool)(iRawlen != 0); - -#ifdef MNG_SUPPORT_DISPLAY -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { - mng_imagep pImage; - -#ifndef MNG_NO_DELTA_PNG - if (pData->bHasDHDR) /* update delta image ? */ - { /* store in object 0 ! */ - pImage = (mng_imagep)pData->pObjzero; - /* store for color-processing routines */ - pImage->pImgbuf->iGamma = mng_get_uint32 (pRawdata); - pImage->pImgbuf->bHasGAMA = MNG_TRUE; - } - else -#endif - { - pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* no object then dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - /* store for color-processing routines */ - pImage->pImgbuf->iGamma = mng_get_uint32 (pRawdata); - pImage->pImgbuf->bHasGAMA = MNG_TRUE; - } - } - else - { /* store as global */ - if (iRawlen != 0) - pData->iGlobalGamma = mng_get_uint32 (pRawdata); - - { /* create an animation object */ - mng_retcode iRetcode = mng_create_ani_gama (pData, (mng_bool)(iRawlen == 0), - pData->iGlobalGamma); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_gamap)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - ((mng_gamap)*ppChunk)->iGamma = mng_get_uint32 (pRawdata); - - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_GAMA, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_cHRM -READ_CHUNK (mng_read_chrm) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_CHRM, MNG_LC_START); -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIDAT) || (pData->bHasPLTE) || (pData->bHasJDAT) || (pData->bHasJDAA)) -#else - if ((pData->bHasIDAT) || (pData->bHasPLTE)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { /* length must be exactly 32 */ - if (iRawlen != 32) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } - else - { /* length must be empty or exactly 32 */ - if ((iRawlen != 0) && (iRawlen != 32)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - pData->bHasCHRM = MNG_TRUE; /* indicate we've got it */ - else - pData->bHasglobalCHRM = (mng_bool)(iRawlen != 0); - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_uint32 iWhitepointx, iWhitepointy; - mng_uint32 iPrimaryredx, iPrimaryredy; - mng_uint32 iPrimarygreenx, iPrimarygreeny; - mng_uint32 iPrimarybluex, iPrimarybluey; - - iWhitepointx = mng_get_uint32 (pRawdata); - iWhitepointy = mng_get_uint32 (pRawdata+4); - iPrimaryredx = mng_get_uint32 (pRawdata+8); - iPrimaryredy = mng_get_uint32 (pRawdata+12); - iPrimarygreenx = mng_get_uint32 (pRawdata+16); - iPrimarygreeny = mng_get_uint32 (pRawdata+20); - iPrimarybluex = mng_get_uint32 (pRawdata+24); - iPrimarybluey = mng_get_uint32 (pRawdata+28); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { - mng_imagep pImage; - mng_imagedatap pBuf; - -#ifndef MNG_NO_DELTA_PNG - if (pData->bHasDHDR) /* update delta image ? */ - { /* store it in object 0 ! */ - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; /* address object buffer */ - pBuf->bHasCHRM = MNG_TRUE; /* and tell it it's got a CHRM now */ - /* store for color-processing routines */ - pBuf->iWhitepointx = iWhitepointx; - pBuf->iWhitepointy = iWhitepointy; - pBuf->iPrimaryredx = iPrimaryredx; - pBuf->iPrimaryredy = iPrimaryredy; - pBuf->iPrimarygreenx = iPrimarygreenx; - pBuf->iPrimarygreeny = iPrimarygreeny; - pBuf->iPrimarybluex = iPrimarybluex; - pBuf->iPrimarybluey = iPrimarybluey; - } - else -#endif - { - pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* no object then dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; /* address object buffer */ - pBuf->bHasCHRM = MNG_TRUE; /* and tell it it's got a CHRM now */ - /* store for color-processing routines */ - pBuf->iWhitepointx = iWhitepointx; - pBuf->iWhitepointy = iWhitepointy; - pBuf->iPrimaryredx = iPrimaryredx; - pBuf->iPrimaryredy = iPrimaryredy; - pBuf->iPrimarygreenx = iPrimarygreenx; - pBuf->iPrimarygreeny = iPrimarygreeny; - pBuf->iPrimarybluex = iPrimarybluex; - pBuf->iPrimarybluey = iPrimarybluey; - } - } - else - { /* store as global */ - if (iRawlen != 0) - { - pData->iGlobalWhitepointx = iWhitepointx; - pData->iGlobalWhitepointy = iWhitepointy; - pData->iGlobalPrimaryredx = iPrimaryredx; - pData->iGlobalPrimaryredy = iPrimaryredy; - pData->iGlobalPrimarygreenx = iPrimarygreenx; - pData->iGlobalPrimarygreeny = iPrimarygreeny; - pData->iGlobalPrimarybluex = iPrimarybluex; - pData->iGlobalPrimarybluey = iPrimarybluey; - } - - { /* create an animation object */ - mng_retcode iRetcode = mng_create_ani_chrm (pData, (mng_bool)(iRawlen == 0), - iWhitepointx, iWhitepointy, - iPrimaryredx, iPrimaryredy, - iPrimarygreenx, iPrimarygreeny, - iPrimarybluex, iPrimarybluey); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_chrmp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - { - ((mng_chrmp)*ppChunk)->iWhitepointx = mng_get_uint32 (pRawdata); - ((mng_chrmp)*ppChunk)->iWhitepointy = mng_get_uint32 (pRawdata+4); - ((mng_chrmp)*ppChunk)->iRedx = mng_get_uint32 (pRawdata+8); - ((mng_chrmp)*ppChunk)->iRedy = mng_get_uint32 (pRawdata+12); - ((mng_chrmp)*ppChunk)->iGreenx = mng_get_uint32 (pRawdata+16); - ((mng_chrmp)*ppChunk)->iGreeny = mng_get_uint32 (pRawdata+20); - ((mng_chrmp)*ppChunk)->iBluex = mng_get_uint32 (pRawdata+24); - ((mng_chrmp)*ppChunk)->iBluey = mng_get_uint32 (pRawdata+28); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_CHRM, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -READ_CHUNK (mng_read_srgb) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SRGB, MNG_LC_START); -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIDAT) || (pData->bHasPLTE) || (pData->bHasJDAT) || (pData->bHasJDAA)) -#else - if ((pData->bHasIDAT) || (pData->bHasPLTE)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { /* length must be exactly 1 */ - if (iRawlen != 1) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } - else - { /* length must be empty or exactly 1 */ - if ((iRawlen != 0) && (iRawlen != 1)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - pData->bHasSRGB = MNG_TRUE; /* indicate we've got it */ - else - pData->bHasglobalSRGB = (mng_bool)(iRawlen != 0); - -#ifdef MNG_SUPPORT_DISPLAY -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { - mng_imagep pImage; - -#ifndef MNG_NO_DELTA_PNG - if (pData->bHasDHDR) /* update delta image ? */ - { /* store in object 0 ! */ - pImage = (mng_imagep)pData->pObjzero; - /* store for color-processing routines */ - pImage->pImgbuf->iRenderingintent = *pRawdata; - pImage->pImgbuf->bHasSRGB = MNG_TRUE; - } - else -#endif - { - pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* no object then dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - /* store for color-processing routines */ - pImage->pImgbuf->iRenderingintent = *pRawdata; - pImage->pImgbuf->bHasSRGB = MNG_TRUE; - } - } - else - { /* store as global */ - if (iRawlen != 0) - pData->iGlobalRendintent = *pRawdata; - - { /* create an animation object */ - mng_retcode iRetcode = mng_create_ani_srgb (pData, (mng_bool)(iRawlen == 0), - pData->iGlobalRendintent); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_srgbp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - ((mng_srgbp)*ppChunk)->iRenderingintent = *pRawdata; - - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SRGB, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_iCCP -READ_CHUNK (mng_read_iccp) -{ - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_uint32 iCompressedsize; - mng_uint32 iProfilesize; - mng_uint32 iBufsize = 0; - mng_uint8p pBuf = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ICCP, MNG_LC_START); -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIDAT) || (pData->bHasPLTE) || (pData->bHasJDAT) || (pData->bHasJDAA)) -#else - if ((pData->bHasIDAT) || (pData->bHasPLTE)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { /* length must be at least 2 */ - if (iRawlen < 2) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } - else - { /* length must be empty or at least 2 */ - if ((iRawlen != 0) && (iRawlen < 2)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } - - pTemp = find_null (pRawdata); /* find null-separator */ - /* not found inside input-data ? */ - if ((pTemp - pRawdata) > (mng_int32)iRawlen) - MNG_ERROR (pData, MNG_NULLNOTFOUND); - /* determine size of compressed profile */ - iCompressedsize = (mng_uint32)(iRawlen - (pTemp - pRawdata) - 2); - /* decompress the profile */ - iRetcode = mng_inflate_buffer (pData, pTemp+2, iCompressedsize, - &pBuf, &iBufsize, &iProfilesize); - -#ifdef MNG_CHECK_BAD_ICCP /* Check for bad iCCP chunk */ - if ((iRetcode) && (!strncmp ((char *)pRawdata, "Photoshop ICC profile", 21))) - { - if (iRawlen == 2615) /* is it the sRGB profile ? */ - { - mng_chunk_header chunk_srgb = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_sRGB, mng_init_general, mng_free_general, mng_read_srgb, mng_write_srgb, mng_assign_general, 0, 0, sizeof(mng_srgb)}; -#else - {MNG_UINT_sRGB, mng_init_srgb, mng_free_srgb, mng_read_srgb, mng_write_srgb, mng_assign_srgb, 0, 0}; -#endif - /* pretend it's an sRGB chunk then ! */ - iRetcode = mng_read_srgb (pData, &chunk_srgb, 1, (mng_ptr)"0", ppChunk); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffer */ - MNG_FREEX (pData, pBuf, iBufsize); - return iRetcode; - } - } - } - else - { -#endif /* MNG_CHECK_BAD_ICCP */ - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffer */ - MNG_FREEX (pData, pBuf, iBufsize); - return iRetcode; - } - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - pData->bHasICCP = MNG_TRUE; /* indicate we've got it */ - else - pData->bHasglobalICCP = (mng_bool)(iRawlen != 0); - -#ifdef MNG_SUPPORT_DISPLAY -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { - mng_imagep pImage; - -#ifndef MNG_NO_DELTA_PNG - if (pData->bHasDHDR) /* update delta image ? */ - { /* store in object 0 ! */ - pImage = (mng_imagep)pData->pObjzero; - - if (pImage->pImgbuf->pProfile) /* profile existed ? */ - MNG_FREEX (pData, pImage->pImgbuf->pProfile, pImage->pImgbuf->iProfilesize); - /* allocate a buffer & copy it */ - MNG_ALLOC (pData, pImage->pImgbuf->pProfile, iProfilesize); - MNG_COPY (pImage->pImgbuf->pProfile, pBuf, iProfilesize); - /* store its length as well */ - pImage->pImgbuf->iProfilesize = iProfilesize; - pImage->pImgbuf->bHasICCP = MNG_TRUE; - } - else -#endif - { - pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* no object then dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - - if (pImage->pImgbuf->pProfile) /* profile existed ? */ - MNG_FREEX (pData, pImage->pImgbuf->pProfile, pImage->pImgbuf->iProfilesize); - /* allocate a buffer & copy it */ - MNG_ALLOC (pData, pImage->pImgbuf->pProfile, iProfilesize); - MNG_COPY (pImage->pImgbuf->pProfile, pBuf, iProfilesize); - /* store its length as well */ - pImage->pImgbuf->iProfilesize = iProfilesize; - pImage->pImgbuf->bHasICCP = MNG_TRUE; - } - } - else - { /* store as global */ - if (iRawlen == 0) /* empty chunk ? */ - { - if (pData->pGlobalProfile) /* did we have a global profile ? */ - MNG_FREEX (pData, pData->pGlobalProfile, pData->iGlobalProfilesize); - - pData->iGlobalProfilesize = 0; /* reset to null */ - pData->pGlobalProfile = MNG_NULL; - } - else - { /* allocate a global buffer & copy it */ - MNG_ALLOC (pData, pData->pGlobalProfile, iProfilesize); - MNG_COPY (pData->pGlobalProfile, pBuf, iProfilesize); - /* store its length as well */ - pData->iGlobalProfilesize = iProfilesize; - } - - /* create an animation object */ - iRetcode = mng_create_ani_iccp (pData, (mng_bool)(iRawlen == 0), - pData->iGlobalProfilesize, - pData->pGlobalProfile); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffer */ - MNG_FREEX (pData, pBuf, iBufsize); - return iRetcode; - } - /* store the fields */ - ((mng_iccpp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) /* not empty ? */ - { - if (!pBuf) /* hasn't been unpuzzled it yet ? */ - { /* find null-separator */ - pTemp = find_null (pRawdata); - /* not found inside input-data ? */ - if ((pTemp - pRawdata) > (mng_int32)iRawlen) - MNG_ERROR (pData, MNG_NULLNOTFOUND); - /* determine size of compressed profile */ - iCompressedsize = iRawlen - (pTemp - pRawdata) - 2; - /* decompress the profile */ - iRetcode = mng_inflate_buffer (pData, pTemp+2, iCompressedsize, - &pBuf, &iBufsize, &iProfilesize); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffer */ - MNG_FREEX (pData, pBuf, iBufsize); - return iRetcode; - } - } - - ((mng_iccpp)*ppChunk)->iNamesize = (mng_uint32)(pTemp - pRawdata); - - if (((mng_iccpp)*ppChunk)->iNamesize) - { - MNG_ALLOC (pData, ((mng_iccpp)*ppChunk)->zName, - ((mng_iccpp)*ppChunk)->iNamesize + 1); - MNG_COPY (((mng_iccpp)*ppChunk)->zName, pRawdata, - ((mng_iccpp)*ppChunk)->iNamesize); - } - - ((mng_iccpp)*ppChunk)->iCompression = *(pTemp+1); - ((mng_iccpp)*ppChunk)->iProfilesize = iProfilesize; - - MNG_ALLOC (pData, ((mng_iccpp)*ppChunk)->pProfile, iProfilesize); - MNG_COPY (((mng_iccpp)*ppChunk)->pProfile, pBuf, iProfilesize); - } - } -#endif /* MNG_STORE_CHUNKS */ - - if (pBuf) /* free the temporary buffer */ - MNG_FREEX (pData, pBuf, iBufsize); - -#ifdef MNG_CHECK_BAD_ICCP - } -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ICCP, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_tEXt -READ_CHUNK (mng_read_text) -{ - mng_uint32 iKeywordlen, iTextlen; - mng_pchar zKeyword, zText; - mng_uint8p pTemp; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_TEXT, MNG_LC_START); -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen < 2) /* length must be at least 2 */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - pTemp = find_null (pRawdata); /* find the null separator */ - /* not found inside input-data ? */ - if ((pTemp - pRawdata) > (mng_int32)iRawlen) - MNG_ERROR (pData, MNG_NULLNOTFOUND); - - if (pTemp == pRawdata) /* there must be at least 1 char for keyword */ - MNG_ERROR (pData, MNG_KEYWORDNULL); - - iKeywordlen = (mng_uint32)(pTemp - pRawdata); - iTextlen = iRawlen - iKeywordlen - 1; - - if (pData->fProcesstext) /* inform the application ? */ - { - mng_bool bOke; - - MNG_ALLOC (pData, zKeyword, iKeywordlen + 1); - MNG_COPY (zKeyword, pRawdata, iKeywordlen); - - MNG_ALLOCX (pData, zText, iTextlen + 1); - - if (!zText) /* on error bail out */ - { - MNG_FREEX (pData, zKeyword, iKeywordlen + 1); - MNG_ERROR (pData, MNG_OUTOFMEMORY); - } - - if (iTextlen) - MNG_COPY (zText, pTemp+1, iTextlen); - - bOke = pData->fProcesstext ((mng_handle)pData, MNG_TYPE_TEXT, zKeyword, zText, 0, 0); - - MNG_FREEX (pData, zText, iTextlen + 1); - MNG_FREEX (pData, zKeyword, iKeywordlen + 1); - - if (!bOke) - MNG_ERROR (pData, MNG_APPMISCERROR); - - } - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_textp)*ppChunk)->iKeywordsize = iKeywordlen; - ((mng_textp)*ppChunk)->iTextsize = iTextlen; - - if (iKeywordlen) - { - MNG_ALLOC (pData, ((mng_textp)*ppChunk)->zKeyword, iKeywordlen+1); - MNG_COPY (((mng_textp)*ppChunk)->zKeyword, pRawdata, iKeywordlen); - } - - if (iTextlen) - { - MNG_ALLOC (pData, ((mng_textp)*ppChunk)->zText, iTextlen+1); - MNG_COPY (((mng_textp)*ppChunk)->zText, pTemp+1, iTextlen); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_TEXT, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_zTXt -READ_CHUNK (mng_read_ztxt) -{ - mng_retcode iRetcode; - mng_uint32 iKeywordlen, iTextlen; - mng_pchar zKeyword; - mng_uint8p pTemp; - mng_uint32 iCompressedsize; - mng_uint32 iBufsize; - mng_uint8p pBuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ZTXT, MNG_LC_START); -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen < 3) /* length must be at least 3 */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - pTemp = find_null (pRawdata); /* find the null separator */ - /* not found inside input-data ? */ - if ((pTemp - pRawdata) > (mng_int32)iRawlen) - MNG_ERROR (pData, MNG_NULLNOTFOUND); - - if (pTemp == pRawdata) /* there must be at least 1 char for keyword */ - MNG_ERROR (pData, MNG_KEYWORDNULL); - - if (*(pTemp+1) != 0) /* only deflate compression-method allowed */ - MNG_ERROR (pData, MNG_INVALIDCOMPRESS); - - iKeywordlen = (mng_uint32)(pTemp - pRawdata); - iCompressedsize = (mng_uint32)(iRawlen - iKeywordlen - 2); - - zKeyword = 0; /* there's no keyword buffer yet */ - pBuf = 0; /* or a temporary buffer ! */ - - if (pData->fProcesstext) /* inform the application ? */ - { /* decompress the text */ - iRetcode = mng_inflate_buffer (pData, pTemp+2, iCompressedsize, - &pBuf, &iBufsize, &iTextlen); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, pBuf, iBufsize); - return iRetcode; - } - - MNG_ALLOCX (pData, zKeyword, iKeywordlen+1); - - if (!zKeyword) /* on error bail out */ - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, pBuf, iBufsize); - MNG_ERROR (pData, MNG_OUTOFMEMORY); - } - - MNG_COPY (zKeyword, pRawdata, iKeywordlen); - - if (!pData->fProcesstext ((mng_handle)pData, MNG_TYPE_ZTXT, zKeyword, (mng_pchar)pBuf, 0, 0)) - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, pBuf, iBufsize); - MNG_FREEX (pData, zKeyword, iKeywordlen+1); - MNG_ERROR (pData, MNG_APPMISCERROR); - } - } - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, pBuf, iBufsize); - MNG_FREEX (pData, zKeyword, iKeywordlen+1); - return iRetcode; - } - /* store the fields */ - ((mng_ztxtp)*ppChunk)->iKeywordsize = iKeywordlen; - ((mng_ztxtp)*ppChunk)->iCompression = *(pTemp+1); - - if ((!pBuf) && (iCompressedsize)) /* did we not get a text-buffer yet ? */ - { /* decompress the text */ - iRetcode = mng_inflate_buffer (pData, pTemp+2, iCompressedsize, - &pBuf, &iBufsize, &iTextlen); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, pBuf, iBufsize); - MNG_FREEX (pData, zKeyword, iKeywordlen+1); - return iRetcode; - } - } - - MNG_ALLOCX (pData, ((mng_ztxtp)*ppChunk)->zKeyword, iKeywordlen + 1); - /* on error bail out */ - if (!((mng_ztxtp)*ppChunk)->zKeyword) - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, pBuf, iBufsize); - MNG_FREEX (pData, zKeyword, iKeywordlen+1); - MNG_ERROR (pData, MNG_OUTOFMEMORY); - } - - MNG_COPY (((mng_ztxtp)*ppChunk)->zKeyword, pRawdata, iKeywordlen); - - ((mng_ztxtp)*ppChunk)->iTextsize = iTextlen; - - if (iCompressedsize) - { - MNG_ALLOCX (pData, ((mng_ztxtp)*ppChunk)->zText, iTextlen + 1); - /* on error bail out */ - if (!((mng_ztxtp)*ppChunk)->zText) - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, pBuf, iBufsize); - MNG_FREEX (pData, zKeyword, iKeywordlen+1); - MNG_ERROR (pData, MNG_OUTOFMEMORY); - } - - MNG_COPY (((mng_ztxtp)*ppChunk)->zText, pBuf, iTextlen); - } - } -#endif /* MNG_STORE_CHUNKS */ - - MNG_FREEX (pData, pBuf, iBufsize); /* free the temporary buffers */ - MNG_FREEX (pData, zKeyword, iKeywordlen+1); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ZTXT, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_iTXt -READ_CHUNK (mng_read_itxt) -{ - mng_retcode iRetcode; - mng_uint32 iKeywordlen, iTextlen, iLanguagelen, iTranslationlen; - mng_pchar zKeyword, zLanguage, zTranslation; - mng_uint8p pNull1, pNull2, pNull3; - mng_uint32 iCompressedsize; - mng_uint8 iCompressionflag; - mng_uint32 iBufsize; - mng_uint8p pBuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ITXT, MNG_LC_START); -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen < 6) /* length must be at least 6 */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - pNull1 = find_null (pRawdata); /* find the null separators */ - pNull2 = find_null (pNull1+3); - pNull3 = find_null (pNull2+1); - /* not found inside input-data ? */ - if (((pNull1 - pRawdata) > (mng_int32)iRawlen) || - ((pNull2 - pRawdata) > (mng_int32)iRawlen) || - ((pNull3 - pRawdata) > (mng_int32)iRawlen) ) - MNG_ERROR (pData, MNG_NULLNOTFOUND); - - if (pNull1 == pRawdata) /* there must be at least 1 char for keyword */ - MNG_ERROR (pData, MNG_KEYWORDNULL); - /* compression or not ? */ - if ((*(pNull1+1) != 0) && (*(pNull1+1) != 1)) - MNG_ERROR (pData, MNG_INVALIDCOMPRESS); - - if (*(pNull1+2) != 0) /* only deflate compression-method allowed */ - MNG_ERROR (pData, MNG_INVALIDCOMPRESS); - - iKeywordlen = (mng_uint32)(pNull1 - pRawdata); - iLanguagelen = (mng_uint32)(pNull2 - pNull1 - 3); - iTranslationlen = (mng_uint32)(pNull3 - pNull2 - 1); - iCompressedsize = (mng_uint32)(iRawlen - iKeywordlen - iLanguagelen - iTranslationlen - 5); - iCompressionflag = *(pNull1+1); - - zKeyword = 0; /* no buffers acquired yet */ - zLanguage = 0; - zTranslation = 0; - pBuf = 0; - iTextlen = 0; - - if (pData->fProcesstext) /* inform the application ? */ - { - if (iCompressionflag) /* decompress the text ? */ - { - iRetcode = mng_inflate_buffer (pData, pNull3+1, iCompressedsize, - &pBuf, &iBufsize, &iTextlen); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffer */ - MNG_FREEX (pData, pBuf, iBufsize); - return iRetcode; - } - } - else - { - iTextlen = iCompressedsize; - iBufsize = iTextlen+1; /* plus 1 for terminator byte!!! */ - - MNG_ALLOC (pData, pBuf, iBufsize); - MNG_COPY (pBuf, pNull3+1, iTextlen); - } - - MNG_ALLOCX (pData, zKeyword, iKeywordlen + 1); - MNG_ALLOCX (pData, zLanguage, iLanguagelen + 1); - MNG_ALLOCX (pData, zTranslation, iTranslationlen + 1); - /* on error bail out */ - if ((!zKeyword) || (!zLanguage) || (!zTranslation)) - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, zTranslation, iTranslationlen + 1); - MNG_FREEX (pData, zLanguage, iLanguagelen + 1); - MNG_FREEX (pData, zKeyword, iKeywordlen + 1); - MNG_FREEX (pData, pBuf, iBufsize); - MNG_ERROR (pData, MNG_OUTOFMEMORY); - } - - MNG_COPY (zKeyword, pRawdata, iKeywordlen); - MNG_COPY (zLanguage, pNull1+3, iLanguagelen); - MNG_COPY (zTranslation, pNull2+1, iTranslationlen); - - if (!pData->fProcesstext ((mng_handle)pData, MNG_TYPE_ITXT, zKeyword, (mng_pchar)pBuf, - zLanguage, zTranslation)) - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, zTranslation, iTranslationlen + 1); - MNG_FREEX (pData, zLanguage, iLanguagelen + 1); - MNG_FREEX (pData, zKeyword, iKeywordlen + 1); - MNG_FREEX (pData, pBuf, iBufsize); - - MNG_ERROR (pData, MNG_APPMISCERROR); - } - } - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, zTranslation, iTranslationlen + 1); - MNG_FREEX (pData, zLanguage, iLanguagelen + 1); - MNG_FREEX (pData, zKeyword, iKeywordlen + 1); - MNG_FREEX (pData, pBuf, iBufsize); - return iRetcode; - } - /* store the fields */ - ((mng_itxtp)*ppChunk)->iKeywordsize = iKeywordlen; - ((mng_itxtp)*ppChunk)->iLanguagesize = iLanguagelen; - ((mng_itxtp)*ppChunk)->iTranslationsize = iTranslationlen; - ((mng_itxtp)*ppChunk)->iCompressionflag = *(pNull1+1); - ((mng_itxtp)*ppChunk)->iCompressionmethod = *(pNull1+2); - - if ((!pBuf) && (iCompressedsize)) /* did we not get a text-buffer yet ? */ - { - if (iCompressionflag) /* decompress the text ? */ - { - iRetcode = mng_inflate_buffer (pData, pNull3+1, iCompressedsize, - &pBuf, &iBufsize, &iTextlen); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, zTranslation, iTranslationlen + 1); - MNG_FREEX (pData, zLanguage, iLanguagelen + 1); - MNG_FREEX (pData, zKeyword, iKeywordlen + 1); - MNG_FREEX (pData, pBuf, iBufsize); - return iRetcode; - } - } - else - { - iTextlen = iCompressedsize; - iBufsize = iTextlen+1; /* plus 1 for terminator byte!!! */ - - MNG_ALLOC (pData, pBuf, iBufsize); - MNG_COPY (pBuf, pNull3+1, iTextlen); - } - } - - MNG_ALLOCX (pData, ((mng_itxtp)*ppChunk)->zKeyword, iKeywordlen + 1); - MNG_ALLOCX (pData, ((mng_itxtp)*ppChunk)->zLanguage, iLanguagelen + 1); - MNG_ALLOCX (pData, ((mng_itxtp)*ppChunk)->zTranslation, iTranslationlen + 1); - /* on error bail out */ - if ((!((mng_itxtp)*ppChunk)->zKeyword ) || - (!((mng_itxtp)*ppChunk)->zLanguage ) || - (!((mng_itxtp)*ppChunk)->zTranslation) ) - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, zTranslation, iTranslationlen + 1); - MNG_FREEX (pData, zLanguage, iLanguagelen + 1); - MNG_FREEX (pData, zKeyword, iKeywordlen + 1); - MNG_FREEX (pData, pBuf, iBufsize); - MNG_ERROR (pData, MNG_OUTOFMEMORY); - } - - MNG_COPY (((mng_itxtp)*ppChunk)->zKeyword, pRawdata, iKeywordlen); - MNG_COPY (((mng_itxtp)*ppChunk)->zLanguage, pNull1+3, iLanguagelen); - MNG_COPY (((mng_itxtp)*ppChunk)->zTranslation, pNull2+1, iTranslationlen); - - ((mng_itxtp)*ppChunk)->iTextsize = iTextlen; - - if (iTextlen) - { - MNG_ALLOCX (pData, ((mng_itxtp)*ppChunk)->zText, iTextlen + 1); - - if (!((mng_itxtp)*ppChunk)->zText) - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, zTranslation, iTranslationlen + 1); - MNG_FREEX (pData, zLanguage, iLanguagelen + 1); - MNG_FREEX (pData, zKeyword, iKeywordlen + 1); - MNG_FREEX (pData, pBuf, iBufsize); - MNG_ERROR (pData, MNG_OUTOFMEMORY); - } - - MNG_COPY (((mng_itxtp)*ppChunk)->zText, pBuf, iTextlen); - } - } -#endif /* MNG_STORE_CHUNKS */ - /* free the temporary buffers */ - MNG_FREEX (pData, zTranslation, iTranslationlen + 1); - MNG_FREEX (pData, zLanguage, iLanguagelen + 1); - MNG_FREEX (pData, zKeyword, iKeywordlen + 1); - MNG_FREEX (pData, pBuf, iBufsize); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ITXT, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_bKGD -READ_CHUNK (mng_read_bkgd) -{ -#ifdef MNG_SUPPORT_DISPLAY - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - mng_imagedatap pBuf; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_BKGD, MNG_LC_START); -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIDAT) || (pData->bHasJDAT) || (pData->bHasJDAA)) -#else - if (pData->bHasIDAT) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen > 6) /* it just can't be bigger than that! */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#ifdef MNG_INCLUDE_JNG /* length checks */ - if (pData->bHasJHDR) - { - if (((pData->iJHDRcolortype == 8) || (pData->iJHDRcolortype == 12)) && (iRawlen != 2)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - if (((pData->iJHDRcolortype == 10) || (pData->iJHDRcolortype == 14)) && (iRawlen != 6)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } - else -#endif /* MNG_INCLUDE_JNG */ - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { - if (((pData->iColortype == 0) || (pData->iColortype == 4)) && (iRawlen != 2)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - if (((pData->iColortype == 2) || (pData->iColortype == 6)) && (iRawlen != 6)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - if ((pData->iColortype == 3) && (iRawlen != 1)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } - else - { - if (iRawlen != 6) /* global is always 16-bit RGB ! */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - pData->bHasBKGD = MNG_TRUE; /* indicate bKGD available */ - else - pData->bHasglobalBKGD = (mng_bool)(iRawlen != 0); - -#ifdef MNG_SUPPORT_DISPLAY - if (!pImage) /* if no object dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; /* address object buffer */ - -#ifdef MNG_INCLUDE_JNG - if (pData->bHasJHDR) - { - pBuf->bHasBKGD = MNG_TRUE; /* tell the object it's got bKGD now */ - - switch (pData->iJHDRcolortype) /* store fields for future reference */ - { - case 8 : ; /* gray */ - case 12 : { /* graya */ - pBuf->iBKGDgray = mng_get_uint16 (pRawdata); - break; - } - case 10 : ; /* rgb */ - case 14 : { /* rgba */ - pBuf->iBKGDred = mng_get_uint16 (pRawdata); - pBuf->iBKGDgreen = mng_get_uint16 (pRawdata+2); - pBuf->iBKGDblue = mng_get_uint16 (pRawdata+4); - break; - } - } - } - else -#endif /* MNG_INCLUDE_JNG */ - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { - pBuf->bHasBKGD = MNG_TRUE; /* tell the object it's got bKGD now */ - - switch (pData->iColortype) /* store fields for future reference */ - { - case 0 : ; /* gray */ - case 4 : { /* graya */ - pBuf->iBKGDgray = mng_get_uint16 (pRawdata); - break; - } - case 2 : ; /* rgb */ - case 6 : { /* rgba */ - pBuf->iBKGDred = mng_get_uint16 (pRawdata); - pBuf->iBKGDgreen = mng_get_uint16 (pRawdata+2); - pBuf->iBKGDblue = mng_get_uint16 (pRawdata+4); - break; - } - case 3 : { /* indexed */ - pBuf->iBKGDindex = *pRawdata; - break; - } - } - } - else /* store as global */ - { - if (iRawlen) - { - pData->iGlobalBKGDred = mng_get_uint16 (pRawdata); - pData->iGlobalBKGDgreen = mng_get_uint16 (pRawdata+2); - pData->iGlobalBKGDblue = mng_get_uint16 (pRawdata+4); - } - - { /* create an animation object */ - mng_retcode iRetcode = mng_create_ani_bkgd (pData, pData->iGlobalBKGDred, - pData->iGlobalBKGDgreen, - pData->iGlobalBKGDblue); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_bkgdp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - ((mng_bkgdp)*ppChunk)->iType = pData->iColortype; - - if (iRawlen) - { - switch (iRawlen) /* guess from length */ - { - case 1 : { /* indexed */ - ((mng_bkgdp)*ppChunk)->iType = 3; - ((mng_bkgdp)*ppChunk)->iIndex = *pRawdata; - break; - } - case 2 : { /* gray */ - ((mng_bkgdp)*ppChunk)->iType = 0; - ((mng_bkgdp)*ppChunk)->iGray = mng_get_uint16 (pRawdata); - break; - } - case 6 : { /* rgb */ - ((mng_bkgdp)*ppChunk)->iType = 2; - ((mng_bkgdp)*ppChunk)->iRed = mng_get_uint16 (pRawdata); - ((mng_bkgdp)*ppChunk)->iGreen = mng_get_uint16 (pRawdata+2); - ((mng_bkgdp)*ppChunk)->iBlue = mng_get_uint16 (pRawdata+4); - break; - } - } - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_BKGD, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_pHYs -READ_CHUNK (mng_read_phys) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PHYS, MNG_LC_START); -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIDAT) || (pData->bHasJDAT) || (pData->bHasJDAA)) -#else - if (pData->bHasIDAT) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - /* it's 9 bytes or empty; no more, no less! */ - if ((iRawlen != 9) && (iRawlen != 0)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_physp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - { - ((mng_physp)*ppChunk)->iSizex = mng_get_uint32 (pRawdata); - ((mng_physp)*ppChunk)->iSizey = mng_get_uint32 (pRawdata+4); - ((mng_physp)*ppChunk)->iUnit = *(pRawdata+8); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PHYS, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_sBIT -READ_CHUNK (mng_read_sbit) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SBIT, MNG_LC_START); -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasPLTE) || (pData->bHasIDAT) || (pData->bHasJDAT) || (pData->bHasJDAA)) -#else - if ((pData->bHasPLTE) || (pData->bHasIDAT)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen > 4) /* it just can't be bigger than that! */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#ifdef MNG_INCLUDE_JNG /* length checks */ - if (pData->bHasJHDR) - { - if ((pData->iJHDRcolortype == 8) && (iRawlen != 1)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - if ((pData->iJHDRcolortype == 10) && (iRawlen != 3)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - if ((pData->iJHDRcolortype == 12) && (iRawlen != 2)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - if ((pData->iJHDRcolortype == 14) && (iRawlen != 4)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } - else -#endif /* MNG_INCLUDE_JNG */ - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { - if ((pData->iColortype == 0) && (iRawlen != 1)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - if ((pData->iColortype == 2) && (iRawlen != 3)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - if ((pData->iColortype == 3) && (iRawlen != 3)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - if ((pData->iColortype == 4) && (iRawlen != 2)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - if ((pData->iColortype == 6) && (iRawlen != 4)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } - else - { /* global = empty or RGBA */ - if ((iRawlen != 0) && (iRawlen != 4)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_sbitp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - { -#ifdef MNG_INCLUDE_JNG - if (pData->bHasJHDR) - ((mng_sbitp)*ppChunk)->iType = pData->iJHDRcolortype; - else -#endif - if (pData->bHasIHDR) - ((mng_sbitp)*ppChunk)->iType = pData->iColortype; - else /* global ! */ - ((mng_sbitp)*ppChunk)->iType = 6; - - if (iRawlen > 0) - ((mng_sbitp)*ppChunk)->aBits [0] = *pRawdata; - if (iRawlen > 1) - ((mng_sbitp)*ppChunk)->aBits [1] = *(pRawdata+1); - if (iRawlen > 2) - ((mng_sbitp)*ppChunk)->aBits [2] = *(pRawdata+2); - if (iRawlen > 3) - ((mng_sbitp)*ppChunk)->aBits [3] = *(pRawdata+3); - - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SBIT, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_sPLT -READ_CHUNK (mng_read_splt) -{ - mng_uint8p pTemp; - mng_uint32 iNamelen; - mng_uint8 iSampledepth; - mng_uint32 iRemain; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SPLT, MNG_LC_START); -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (pData->bHasIDAT) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen) - { - pTemp = find_null (pRawdata); /* find null-separator */ - /* not found inside input-data ? */ - if ((pTemp - pRawdata) > (mng_int32)iRawlen) - MNG_ERROR (pData, MNG_NULLNOTFOUND); - - iNamelen = (mng_uint32)(pTemp - pRawdata); - iSampledepth = *(pTemp+1); - iRemain = (iRawlen - 2 - iNamelen); - - if ((iSampledepth != 1) && (iSampledepth != 2)) - MNG_ERROR (pData, MNG_INVSAMPLEDEPTH); - /* check remaining length */ - if ( ((iSampledepth == 1) && (iRemain % 6 != 0)) || - ((iSampledepth == 2) && (iRemain % 10 != 0)) ) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - } - else - { - pTemp = MNG_NULL; - iNamelen = 0; - iSampledepth = 0; - iRemain = 0; - } - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_spltp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - { - ((mng_spltp)*ppChunk)->iNamesize = iNamelen; - ((mng_spltp)*ppChunk)->iSampledepth = iSampledepth; - - if (iSampledepth == 1) - ((mng_spltp)*ppChunk)->iEntrycount = iRemain / 6; - else - ((mng_spltp)*ppChunk)->iEntrycount = iRemain / 10; - - if (iNamelen) - { - MNG_ALLOC (pData, ((mng_spltp)*ppChunk)->zName, iNamelen+1); - MNG_COPY (((mng_spltp)*ppChunk)->zName, pRawdata, iNamelen); - } - - if (iRemain) - { - MNG_ALLOC (pData, ((mng_spltp)*ppChunk)->pEntries, iRemain); - MNG_COPY (((mng_spltp)*ppChunk)->pEntries, pTemp+2, iRemain); - } - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SPLT, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_hIST -READ_CHUNK (mng_read_hist) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_HIST, MNG_LC_START); -#endif - /* sequence checks */ - if ((!pData->bHasIHDR) && (!pData->bHasBASI) && (!pData->bHasDHDR) ) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if ((!pData->bHasPLTE) || (pData->bHasIDAT)) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - /* length oke ? */ - if ( ((iRawlen & 0x01) != 0) || ((iRawlen >> 1) != pData->iPLTEcount) ) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { - mng_uint32 iX; - /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_histp)*ppChunk)->iEntrycount = iRawlen >> 1; - - for (iX = 0; iX < (iRawlen >> 1); iX++) - { - ((mng_histp)*ppChunk)->aEntries [iX] = mng_get_uint16 (pRawdata); - pRawdata += 2; - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_HIST, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_tIME -READ_CHUNK (mng_read_time) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_TIME, MNG_LC_START); -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen != 7) /* length must be exactly 7 */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -/* if (pData->fProcesstime) */ /* inform the application ? */ -/* { - - pData->fProcesstime ((mng_handle)pData, ); - } */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_timep)*ppChunk)->iYear = mng_get_uint16 (pRawdata); - ((mng_timep)*ppChunk)->iMonth = *(pRawdata+2); - ((mng_timep)*ppChunk)->iDay = *(pRawdata+3); - ((mng_timep)*ppChunk)->iHour = *(pRawdata+4); - ((mng_timep)*ppChunk)->iMinute = *(pRawdata+5); - ((mng_timep)*ppChunk)->iSecond = *(pRawdata+6); - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_TIME, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -READ_CHUNK (mng_read_mhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MHDR, MNG_LC_START); -#endif - - if (pData->eSigtype != mng_it_mng) /* sequence checks */ - MNG_ERROR (pData, MNG_CHUNKNOTALLOWED); - - if (pData->bHasheader) /* can only be the first chunk! */ - MNG_ERROR (pData, MNG_SEQUENCEERROR); - /* correct length ? */ -#ifndef MNG_NO_OLD_VERSIONS - if ((iRawlen != 28) && (iRawlen != 12)) -#else - if ((iRawlen != 28)) -#endif - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - pData->bHasMHDR = MNG_TRUE; /* oh boy, a real MNG */ - pData->bHasheader = MNG_TRUE; /* we've got a header */ - pData->eImagetype = mng_it_mng; /* fill header fields */ - pData->iWidth = mng_get_uint32 (pRawdata); - pData->iHeight = mng_get_uint32 (pRawdata+4); - pData->iTicks = mng_get_uint32 (pRawdata+8); - -#ifndef MNG_NO_OLD_VERSIONS - if (iRawlen == 28) /* proper MHDR ? */ - { -#endif - pData->iLayercount = mng_get_uint32 (pRawdata+12); - pData->iFramecount = mng_get_uint32 (pRawdata+16); - pData->iPlaytime = mng_get_uint32 (pRawdata+20); - pData->iSimplicity = mng_get_uint32 (pRawdata+24); - -#ifndef MNG_NO_OLD_VERSIONS - pData->bPreDraft48 = MNG_FALSE; - } - else /* probably pre-draft48 then */ - { - pData->iLayercount = 0; - pData->iFramecount = 0; - pData->iPlaytime = 0; - pData->iSimplicity = 0; - - pData->bPreDraft48 = MNG_TRUE; - } -#endif - /* predict alpha-depth */ - if ((pData->iSimplicity & 0x00000001) == 0) -#ifndef MNG_NO_16BIT_SUPPORT - pData->iAlphadepth = 16; /* no indicators = assume the worst */ -#else - pData->iAlphadepth = 8; /* anything else = assume the worst */ -#endif - else - if ((pData->iSimplicity & 0x00000008) == 0) - pData->iAlphadepth = 0; /* no transparency at all */ - else - if ((pData->iSimplicity & 0x00000140) == 0x00000040) - pData->iAlphadepth = 1; /* no semi-transparency guaranteed */ - else -#ifndef MNG_NO_16BIT_SUPPORT - pData->iAlphadepth = 16; /* anything else = assume the worst */ -#else - pData->iAlphadepth = 8; /* anything else = assume the worst */ -#endif - -#ifdef MNG_INCLUDE_JNG /* can we handle the complexity ? */ - if (pData->iSimplicity & 0x0000FC00) -#else - if (pData->iSimplicity & 0x0000FC10) -#endif - MNG_ERROR (pData, MNG_MNGTOOCOMPLEX); - /* fits on maximum canvas ? */ - if ((pData->iWidth > pData->iMaxwidth) || (pData->iHeight > pData->iMaxheight)) - MNG_WARNING (pData, MNG_IMAGETOOLARGE); - - if (pData->fProcessheader) /* inform the app ? */ - if (!pData->fProcessheader (((mng_handle)pData), pData->iWidth, pData->iHeight)) - MNG_ERROR (pData, MNG_APPMISCERROR); - - pData->iImagelevel++; /* one level deeper */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_mhdrp)*ppChunk)->iWidth = pData->iWidth; - ((mng_mhdrp)*ppChunk)->iHeight = pData->iHeight; - ((mng_mhdrp)*ppChunk)->iTicks = pData->iTicks; - ((mng_mhdrp)*ppChunk)->iLayercount = pData->iLayercount; - ((mng_mhdrp)*ppChunk)->iFramecount = pData->iFramecount; - ((mng_mhdrp)*ppChunk)->iPlaytime = pData->iPlaytime; - ((mng_mhdrp)*ppChunk)->iSimplicity = pData->iSimplicity; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -READ_CHUNK (mng_read_mend) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MEND, MNG_LC_START); -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen > 0) /* must not contain data! */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#ifdef MNG_SUPPORT_DISPLAY - { /* do something */ - mng_retcode iRetcode = mng_process_display_mend (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (!pData->iTotalframes) /* save totals */ - pData->iTotalframes = pData->iFrameseq; - if (!pData->iTotallayers) - pData->iTotallayers = pData->iLayerseq; - if (!pData->iTotalplaytime) - pData->iTotalplaytime = pData->iFrametime; - } -#endif /* MNG_SUPPORT_DISPLAY */ - - pData->bHasMHDR = MNG_FALSE; /* end of the line, bro! */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MEND, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_LOOP -READ_CHUNK (mng_read_loop) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_LOOP, MNG_LC_START); -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (!pData->bCacheplayback) /* must store playback info to work!! */ - MNG_ERROR (pData, MNG_LOOPWITHCACHEOFF); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen >= 5) /* length checks */ - { - if (iRawlen >= 6) - { - if ((iRawlen - 6) % 4 != 0) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } - } - else - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_uint8 iLevel; - mng_uint32 iRepeat; - mng_uint8 iTermination = 0; - mng_uint32 iItermin = 1; - mng_uint32 iItermax = 0x7fffffffL; - mng_retcode iRetcode; - - pData->bHasLOOP = MNG_TRUE; /* indicate we're inside a loop */ - - iLevel = *pRawdata; /* determine the fields for processing */ - -#ifndef MNG_NO_OLD_VERSIONS - if (pData->bPreDraft48) - { - iTermination = *(pRawdata+1); - - iRepeat = mng_get_uint32 (pRawdata+2); - } - else -#endif - iRepeat = mng_get_uint32 (pRawdata+1); - - if (iRawlen >= 6) - { -#ifndef MNG_NO_OLD_VERSIONS - if (!pData->bPreDraft48) -#endif - iTermination = *(pRawdata+5); - - if (iRawlen >= 10) - { - iItermin = mng_get_uint32 (pRawdata+6); - - if (iRawlen >= 14) - { - iItermax = mng_get_uint32 (pRawdata+10); - - /* TODO: process signals */ - - } - } - } - /* create the LOOP ani-object */ - iRetcode = mng_create_ani_loop (pData, iLevel, iRepeat, iTermination, - iItermin, iItermax, 0, 0); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* skip till matching ENDL if iteration=0 */ - if ((!pData->bSkipping) && (iRepeat == 0)) - pData->bSkipping = MNG_TRUE; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (iRawlen >= 5) /* store the fields */ - { - ((mng_loopp)*ppChunk)->iLevel = *pRawdata; - -#ifndef MNG_NO_OLD_VERSIONS - if (pData->bPreDraft48) - { - ((mng_loopp)*ppChunk)->iTermination = *(pRawdata+1); - ((mng_loopp)*ppChunk)->iRepeat = mng_get_uint32 (pRawdata+2); - } - else -#endif - { - ((mng_loopp)*ppChunk)->iRepeat = mng_get_uint32 (pRawdata+1); - } - - if (iRawlen >= 6) - { -#ifndef MNG_NO_OLD_VERSIONS - if (!pData->bPreDraft48) -#endif - ((mng_loopp)*ppChunk)->iTermination = *(pRawdata+5); - - if (iRawlen >= 10) - { - ((mng_loopp)*ppChunk)->iItermin = mng_get_uint32 (pRawdata+6); - -#ifndef MNG_NO_LOOP_SIGNALS_SUPPORTED - if (iRawlen >= 14) - { - ((mng_loopp)*ppChunk)->iItermax = mng_get_uint32 (pRawdata+10); - ((mng_loopp)*ppChunk)->iCount = (iRawlen - 14) / 4; - - if (((mng_loopp)*ppChunk)->iCount) - { - MNG_ALLOC (pData, ((mng_loopp)*ppChunk)->pSignals, - ((mng_loopp)*ppChunk)->iCount << 2); - -#ifndef MNG_BIGENDIAN_SUPPORTED - { - mng_uint32 iX; - mng_uint8p pIn = pRawdata + 14; - mng_uint32p pOut = (mng_uint32p)((mng_loopp)*ppChunk)->pSignals; - - for (iX = 0; iX < ((mng_loopp)*ppChunk)->iCount; iX++) - { - *pOut++ = mng_get_uint32 (pIn); - pIn += 4; - } - } -#else - MNG_COPY (((mng_loopp)*ppChunk)->pSignals, pRawdata + 14, - ((mng_loopp)*ppChunk)->iCount << 2); -#endif /* !MNG_BIGENDIAN_SUPPORTED */ - } - } -#endif - } - } - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_LOOP, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_LOOP -READ_CHUNK (mng_read_endl) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ENDL, MNG_LC_START); -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen != 1) /* length must be exactly 1 */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#ifdef MNG_SUPPORT_DISPLAY - { - if (pData->bHasLOOP) /* are we really processing a loop ? */ - { - mng_uint8 iLevel = *pRawdata; /* get the nest level */ - /* create an ENDL animation object */ - mng_retcode iRetcode = mng_create_ani_endl (pData, iLevel); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -/* { - mng_ani_endlp pENDL = (mng_ani_endlp)pData->pLastaniobj; - - iRetcode = pENDL->sHeader.fProcess (pData, pENDL); - - if (iRetcode) - return iRetcode; - } */ - } - else - MNG_ERROR (pData, MNG_NOMATCHINGLOOP); - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_endlp)*ppChunk)->iLevel = *pRawdata; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ENDL, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_DEFI -READ_CHUNK (mng_read_defi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DEFI, MNG_LC_START); -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - /* check the length */ - if ((iRawlen != 2) && (iRawlen != 3) && (iRawlen != 4) && - (iRawlen != 12) && (iRawlen != 28)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode; - - pData->iDEFIobjectid = mng_get_uint16 (pRawdata); - - if (iRawlen > 2) - { - pData->bDEFIhasdonotshow = MNG_TRUE; - pData->iDEFIdonotshow = *(pRawdata+2); - } - else - { - pData->bDEFIhasdonotshow = MNG_FALSE; - pData->iDEFIdonotshow = 0; - } - - if (iRawlen > 3) - { - pData->bDEFIhasconcrete = MNG_TRUE; - pData->iDEFIconcrete = *(pRawdata+3); - } - else - { - pData->bDEFIhasconcrete = MNG_FALSE; - pData->iDEFIconcrete = 0; - } - - if (iRawlen > 4) - { - pData->bDEFIhasloca = MNG_TRUE; - pData->iDEFIlocax = mng_get_int32 (pRawdata+4); - pData->iDEFIlocay = mng_get_int32 (pRawdata+8); - } - else - { - pData->bDEFIhasloca = MNG_FALSE; - pData->iDEFIlocax = 0; - pData->iDEFIlocay = 0; - } - - if (iRawlen > 12) - { - pData->bDEFIhasclip = MNG_TRUE; - pData->iDEFIclipl = mng_get_int32 (pRawdata+12); - pData->iDEFIclipr = mng_get_int32 (pRawdata+16); - pData->iDEFIclipt = mng_get_int32 (pRawdata+20); - pData->iDEFIclipb = mng_get_int32 (pRawdata+24); - } - else - { - pData->bDEFIhasclip = MNG_FALSE; - pData->iDEFIclipl = 0; - pData->iDEFIclipr = 0; - pData->iDEFIclipt = 0; - pData->iDEFIclipb = 0; - } - /* create an animation object */ - iRetcode = mng_create_ani_defi (pData); - - if (!iRetcode) /* do display processing */ - iRetcode = mng_process_display_defi (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_defip)*ppChunk)->iObjectid = mng_get_uint16 (pRawdata); - - if (iRawlen > 2) - { - ((mng_defip)*ppChunk)->bHasdonotshow = MNG_TRUE; - ((mng_defip)*ppChunk)->iDonotshow = *(pRawdata+2); - } - else - ((mng_defip)*ppChunk)->bHasdonotshow = MNG_FALSE; - - if (iRawlen > 3) - { - ((mng_defip)*ppChunk)->bHasconcrete = MNG_TRUE; - ((mng_defip)*ppChunk)->iConcrete = *(pRawdata+3); - } - else - ((mng_defip)*ppChunk)->bHasconcrete = MNG_FALSE; - - if (iRawlen > 4) - { - ((mng_defip)*ppChunk)->bHasloca = MNG_TRUE; - ((mng_defip)*ppChunk)->iXlocation = mng_get_int32 (pRawdata+4); - ((mng_defip)*ppChunk)->iYlocation = mng_get_int32 (pRawdata+8); - } - else - ((mng_defip)*ppChunk)->bHasloca = MNG_FALSE; - - if (iRawlen > 12) - { - ((mng_defip)*ppChunk)->bHasclip = MNG_TRUE; - ((mng_defip)*ppChunk)->iLeftcb = mng_get_int32 (pRawdata+12); - ((mng_defip)*ppChunk)->iRightcb = mng_get_int32 (pRawdata+16); - ((mng_defip)*ppChunk)->iTopcb = mng_get_int32 (pRawdata+20); - ((mng_defip)*ppChunk)->iBottomcb = mng_get_int32 (pRawdata+24); - } - else - ((mng_defip)*ppChunk)->bHasclip = MNG_FALSE; - - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DEFI, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_BASI -READ_CHUNK (mng_read_basi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_BASI, MNG_LC_START); -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - /* check the length */ - if ((iRawlen != 13) && (iRawlen != 19) && (iRawlen != 21) && (iRawlen != 22)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - pData->bHasBASI = MNG_TRUE; /* inside a BASI-IEND block now */ - /* store interesting fields */ - pData->iDatawidth = mng_get_uint32 (pRawdata); - pData->iDataheight = mng_get_uint32 (pRawdata+4); - pData->iBitdepth = *(pRawdata+8); - pData->iColortype = *(pRawdata+9); - pData->iCompression = *(pRawdata+10); - pData->iFilter = *(pRawdata+11); - pData->iInterlace = *(pRawdata+12); - - -#if defined(MNG_NO_1_2_4BIT_SUPPORT) || defined(MNG_NO_16BIT_SUPPORT) - pData->iPNGmult = 1; - pData->iPNGdepth = pData->iBitdepth; -#endif - -#ifdef MNG_NO_1_2_4BIT_SUPPORT - if (pData->iBitdepth < 8) - pData->iBitdepth = 8; -#endif -#ifdef MNG_NO_16BIT_SUPPORT - if (pData->iBitdepth > 8) - { - pData->iBitdepth = 8; - pData->iPNGmult = 2; - } -#endif - - if ((pData->iBitdepth != 8) /* parameter validity checks */ -#ifndef MNG_NO_1_2_4BIT_SUPPORT - && (pData->iBitdepth != 1) && - (pData->iBitdepth != 2) && - (pData->iBitdepth != 4) -#endif -#ifndef MNG_NO_16BIT_SUPPORT - && (pData->iBitdepth != 16) -#endif - ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH); - - if ((pData->iColortype != MNG_COLORTYPE_GRAY ) && - (pData->iColortype != MNG_COLORTYPE_RGB ) && - (pData->iColortype != MNG_COLORTYPE_INDEXED) && - (pData->iColortype != MNG_COLORTYPE_GRAYA ) && - (pData->iColortype != MNG_COLORTYPE_RGBA ) ) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE); - - if ((pData->iColortype == MNG_COLORTYPE_INDEXED) && (pData->iBitdepth > 8)) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH); - - if (((pData->iColortype == MNG_COLORTYPE_RGB ) || - (pData->iColortype == MNG_COLORTYPE_GRAYA ) || - (pData->iColortype == MNG_COLORTYPE_RGBA ) ) && - (pData->iBitdepth < 8 ) ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH); - - if (pData->iCompression != MNG_COMPRESSION_DEFLATE) - MNG_ERROR (pData, MNG_INVALIDCOMPRESS); - -#if defined(FILTER192) || defined(FILTER193) - if ((pData->iFilter != MNG_FILTER_ADAPTIVE ) && -#if defined(FILTER192) && defined(FILTER193) - (pData->iFilter != MNG_FILTER_DIFFERING) && - (pData->iFilter != MNG_FILTER_NOFILTER ) ) -#else -#ifdef FILTER192 - (pData->iFilter != MNG_FILTER_DIFFERING) ) -#else - (pData->iFilter != MNG_FILTER_NOFILTER ) ) -#endif -#endif - MNG_ERROR (pData, MNG_INVALIDFILTER); -#else - if (pData->iFilter) - MNG_ERROR (pData, MNG_INVALIDFILTER); -#endif - - if ((pData->iInterlace != MNG_INTERLACE_NONE ) && - (pData->iInterlace != MNG_INTERLACE_ADAM7) ) - MNG_ERROR (pData, MNG_INVALIDINTERLACE); - - pData->iImagelevel++; /* one level deeper */ - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_uint16 iRed = 0; - mng_uint16 iGreen = 0; - mng_uint16 iBlue = 0; - mng_bool bHasalpha = MNG_FALSE; - mng_uint16 iAlpha = 0xFFFF; - mng_uint8 iViewable = 0; - mng_retcode iRetcode; - - if (iRawlen > 13) /* get remaining fields, if any */ - { - iRed = mng_get_uint16 (pRawdata+13); - iGreen = mng_get_uint16 (pRawdata+15); - iBlue = mng_get_uint16 (pRawdata+17); - } - - if (iRawlen > 19) - { - bHasalpha = MNG_TRUE; - iAlpha = mng_get_uint16 (pRawdata+19); - } - - if (iRawlen > 21) - iViewable = *(pRawdata+21); - /* create an animation object */ - iRetcode = mng_create_ani_basi (pData, iRed, iGreen, iBlue, - bHasalpha, iAlpha, iViewable); - -/* if (!iRetcode) - iRetcode = mng_process_display_basi (pData, iRed, iGreen, iBlue, - bHasalpha, iAlpha, iViewable); */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_basip)*ppChunk)->iWidth = mng_get_uint32 (pRawdata); - ((mng_basip)*ppChunk)->iHeight = mng_get_uint32 (pRawdata+4); -#ifdef MNG_NO_16BIT_SUPPORT - if (*(pRawdata+8) > 8) - ((mng_basip)*ppChunk)->iBitdepth = 8; - else -#endif - ((mng_basip)*ppChunk)->iBitdepth = *(pRawdata+8); - ((mng_basip)*ppChunk)->iColortype = *(pRawdata+9); - ((mng_basip)*ppChunk)->iCompression = *(pRawdata+10); - ((mng_basip)*ppChunk)->iFilter = *(pRawdata+11); - ((mng_basip)*ppChunk)->iInterlace = *(pRawdata+12); - - if (iRawlen > 13) - { - ((mng_basip)*ppChunk)->iRed = mng_get_uint16 (pRawdata+13); - ((mng_basip)*ppChunk)->iGreen = mng_get_uint16 (pRawdata+15); - ((mng_basip)*ppChunk)->iBlue = mng_get_uint16 (pRawdata+17); - } - - if (iRawlen > 19) - ((mng_basip)*ppChunk)->iAlpha = mng_get_uint16 (pRawdata+19); - - if (iRawlen > 21) - ((mng_basip)*ppChunk)->iViewable = *(pRawdata+21); - - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_BASI, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_CLON -READ_CHUNK (mng_read_clon) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_CLON, MNG_LC_START); -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - /* check the length */ - if ((iRawlen != 4) && (iRawlen != 5) && (iRawlen != 6) && - (iRawlen != 7) && (iRawlen != 16)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_uint16 iSourceid, iCloneid; - mng_uint8 iClonetype = 0; - mng_bool bHasdonotshow = MNG_FALSE; - mng_uint8 iDonotshow = 0; - mng_uint8 iConcrete = 0; - mng_bool bHasloca = MNG_FALSE; - mng_uint8 iLocationtype = 0; - mng_int32 iLocationx = 0; - mng_int32 iLocationy = 0; - mng_retcode iRetcode; - - iSourceid = mng_get_uint16 (pRawdata); - iCloneid = mng_get_uint16 (pRawdata+2); - - if (iRawlen > 4) - iClonetype = *(pRawdata+4); - - if (iRawlen > 5) - { - bHasdonotshow = MNG_TRUE; - iDonotshow = *(pRawdata+5); - } - - if (iRawlen > 6) - iConcrete = *(pRawdata+6); - - if (iRawlen > 7) - { - bHasloca = MNG_TRUE; - iLocationtype = *(pRawdata+7); - iLocationx = mng_get_int32 (pRawdata+8); - iLocationy = mng_get_int32 (pRawdata+12); - } - - iRetcode = mng_create_ani_clon (pData, iSourceid, iCloneid, iClonetype, - bHasdonotshow, iDonotshow, iConcrete, - bHasloca, iLocationtype, iLocationx, iLocationy); - -/* if (!iRetcode) - iRetcode = mng_process_display_clon (pData, iSourceid, iCloneid, iClonetype, - bHasdonotshow, iDonotshow, iConcrete, - bHasloca, iLocationtype, iLocationx, - iLocationy); */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_clonp)*ppChunk)->iSourceid = mng_get_uint16 (pRawdata); - ((mng_clonp)*ppChunk)->iCloneid = mng_get_uint16 (pRawdata+2); - - if (iRawlen > 4) - ((mng_clonp)*ppChunk)->iClonetype = *(pRawdata+4); - - if (iRawlen > 5) - ((mng_clonp)*ppChunk)->iDonotshow = *(pRawdata+5); - - if (iRawlen > 6) - ((mng_clonp)*ppChunk)->iConcrete = *(pRawdata+6); - - if (iRawlen > 7) - { - ((mng_clonp)*ppChunk)->bHasloca = MNG_TRUE; - ((mng_clonp)*ppChunk)->iLocationtype = *(pRawdata+7); - ((mng_clonp)*ppChunk)->iLocationx = mng_get_int32 (pRawdata+8); - ((mng_clonp)*ppChunk)->iLocationy = mng_get_int32 (pRawdata+12); - } - else - { - ((mng_clonp)*ppChunk)->bHasloca = MNG_FALSE; - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_CLON, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_PAST -READ_CHUNK (mng_read_past) -{ -#if defined(MNG_STORE_CHUNKS) || defined(MNG_SUPPORT_DISPLAY) - mng_retcode iRetcode; - mng_uint16 iTargetid; - mng_uint8 iTargettype; - mng_int32 iTargetx; - mng_int32 iTargety; - mng_uint32 iCount; - mng_uint32 iSize; - mng_ptr pSources; - mng_uint32 iX; - mng_past_sourcep pSource; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PAST, MNG_LC_START); -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - /* check the length */ - if ((iRawlen < 41) || (((iRawlen - 11) % 30) != 0)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#if defined(MNG_STORE_CHUNKS) || defined(MNG_SUPPORT_DISPLAY) - iTargetid = mng_get_uint16 (pRawdata); - iTargettype = *(pRawdata+2); - iTargetx = mng_get_int32 (pRawdata+3); - iTargety = mng_get_int32 (pRawdata+7); - iCount = ((iRawlen - 11) / 30); /* how many entries again? */ - iSize = iCount * sizeof (mng_past_source); - - pRawdata += 11; - /* get a buffer for all the source blocks */ - MNG_ALLOC (pData, pSources, iSize); - - pSource = (mng_past_sourcep)pSources; - - for (iX = 0; iX < iCount; iX++) /* now copy the source blocks */ - { - pSource->iSourceid = mng_get_uint16 (pRawdata); - pSource->iComposition = *(pRawdata+2); - pSource->iOrientation = *(pRawdata+3); - pSource->iOffsettype = *(pRawdata+4); - pSource->iOffsetx = mng_get_int32 (pRawdata+5); - pSource->iOffsety = mng_get_int32 (pRawdata+9); - pSource->iBoundarytype = *(pRawdata+13); - pSource->iBoundaryl = mng_get_int32 (pRawdata+14); - pSource->iBoundaryr = mng_get_int32 (pRawdata+18); - pSource->iBoundaryt = mng_get_int32 (pRawdata+22); - pSource->iBoundaryb = mng_get_int32 (pRawdata+26); - - pSource++; - pRawdata += 30; - } -#endif - -#ifdef MNG_SUPPORT_DISPLAY - { /* create playback object */ - iRetcode = mng_create_ani_past (pData, iTargetid, iTargettype, iTargetx, - iTargety, iCount, pSources); - -/* if (!iRetcode) - iRetcode = mng_process_display_past (pData, iTargetid, iTargettype, iTargetx, - iTargety, iCount, pSources); */ - - if (iRetcode) /* on error bail out */ - { - MNG_FREEX (pData, pSources, iSize); - return iRetcode; - } - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - { - MNG_FREEX (pData, pSources, iSize); - return iRetcode; - } - /* store the fields */ - ((mng_pastp)*ppChunk)->iDestid = iTargetid; - ((mng_pastp)*ppChunk)->iTargettype = iTargettype; - ((mng_pastp)*ppChunk)->iTargetx = iTargetx; - ((mng_pastp)*ppChunk)->iTargety = iTargety; - ((mng_pastp)*ppChunk)->iCount = iCount; - /* get a buffer & copy the source blocks */ - MNG_ALLOC (pData, ((mng_pastp)*ppChunk)->pSources, iSize); - MNG_COPY (((mng_pastp)*ppChunk)->pSources, pSources, iSize); - } -#endif /* MNG_STORE_CHUNKS */ - -#if defined(MNG_STORE_CHUNKS) || defined(MNG_SUPPORT_DISPLAY) - /* free the source block buffer */ - MNG_FREEX (pData, pSources, iSize); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PAST, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_DISC -READ_CHUNK (mng_read_disc) -{ -#if defined(MNG_SUPPORT_DISPLAY) || defined(MNG_STORE_CHUNKS) - mng_uint32 iCount; - mng_uint16p pIds = MNG_NULL; - mng_retcode iRetcode; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DISC, MNG_LC_START); -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if ((iRawlen % 2) != 0) /* check the length */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#if defined(MNG_SUPPORT_DISPLAY) || defined(MNG_STORE_CHUNKS) - iCount = (iRawlen / sizeof (mng_uint16)); - - if (iCount) - { - MNG_ALLOC (pData, pIds, iRawlen); - -#ifndef MNG_BIGENDIAN_SUPPORTED - { - mng_uint32 iX; - mng_uint8p pIn = pRawdata; - mng_uint16p pOut = pIds; - - for (iX = 0; iX < iCount; iX++) - { - *pOut++ = mng_get_uint16 (pIn); - pIn += 2; - } - } -#else - MNG_COPY (pIds, pRawdata, iRawlen); -#endif /* !MNG_BIGENDIAN_SUPPORTED */ - } -#endif - -#ifdef MNG_SUPPORT_DISPLAY - { /* create playback object */ - iRetcode = mng_create_ani_disc (pData, iCount, pIds); - -/* if (!iRetcode) - iRetcode = mng_process_display_disc (pData, iCount, pIds); */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_discp)*ppChunk)->iCount = iCount; - - if (iRawlen) - { - MNG_ALLOC (pData, ((mng_discp)*ppChunk)->pObjectids, iRawlen); - MNG_COPY (((mng_discp)*ppChunk)->pObjectids, pIds, iRawlen); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#if defined(MNG_SUPPORT_DISPLAY) || defined(MNG_STORE_CHUNKS) - if (iRawlen) - MNG_FREEX (pData, pIds, iRawlen); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DISC, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_BACK -READ_CHUNK (mng_read_back) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_BACK, MNG_LC_START); -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - /* check the length */ - if ((iRawlen != 6) && (iRawlen != 7) && (iRawlen != 9) && (iRawlen != 10)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode; - /* retrieve the fields */ - pData->bHasBACK = MNG_TRUE; - pData->iBACKred = mng_get_uint16 (pRawdata); - pData->iBACKgreen = mng_get_uint16 (pRawdata+2); - pData->iBACKblue = mng_get_uint16 (pRawdata+4); - - if (iRawlen > 6) - pData->iBACKmandatory = *(pRawdata+6); - else - pData->iBACKmandatory = 0; - - if (iRawlen > 7) - pData->iBACKimageid = mng_get_uint16 (pRawdata+7); - else - pData->iBACKimageid = 0; - - if (iRawlen > 9) - pData->iBACKtile = *(pRawdata+9); - else - pData->iBACKtile = 0; - - iRetcode = mng_create_ani_back (pData, pData->iBACKred, pData->iBACKgreen, - pData->iBACKblue, pData->iBACKmandatory, - pData->iBACKimageid, pData->iBACKtile); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_backp)*ppChunk)->iRed = mng_get_uint16 (pRawdata); - ((mng_backp)*ppChunk)->iGreen = mng_get_uint16 (pRawdata+2); - ((mng_backp)*ppChunk)->iBlue = mng_get_uint16 (pRawdata+4); - - if (iRawlen > 6) - ((mng_backp)*ppChunk)->iMandatory = *(pRawdata+6); - - if (iRawlen > 7) - ((mng_backp)*ppChunk)->iImageid = mng_get_uint16 (pRawdata+7); - - if (iRawlen > 9) - ((mng_backp)*ppChunk)->iTile = *(pRawdata+9); - - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_BACK, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_FRAM -READ_CHUNK (mng_read_fram) -{ - mng_uint8p pTemp; -#ifdef MNG_STORE_CHUNKS - mng_uint32 iNamelen; -#endif - mng_uint32 iRemain; - mng_uint32 iRequired = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_FRAM, MNG_LC_START); -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen <= 1) /* only framing-mode ? */ - { -#ifdef MNG_STORE_CHUNKS - iNamelen = 0; /* indicate so */ -#endif - iRemain = 0; - pTemp = MNG_NULL; - } - else - { - pTemp = find_null (pRawdata+1); /* find null-separator */ - /* not found inside input-data ? */ - if ((pTemp - pRawdata) > (mng_int32)iRawlen) - pTemp = pRawdata + iRawlen; /* than remainder is name */ - -#ifdef MNG_STORE_CHUNKS - iNamelen = (mng_uint32)((pTemp - pRawdata) - 1); -#endif - iRemain = (mng_uint32)(iRawlen - (pTemp - pRawdata)); - - if (iRemain) /* if there is remaining data it's less 1 byte */ - iRemain--; - - if ((iRemain) && (iRemain < 4)) /* remains must be empty or at least 4 bytes */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - if (iRemain) - { - iRequired = 4; /* calculate and check required remaining length */ - - if (*(pTemp+1)) { iRequired += 4; } - if (*(pTemp+2)) { iRequired += 4; } - if (*(pTemp+3)) { iRequired += 17; } - - if (*(pTemp+4)) - { - if ((iRemain - iRequired) % 4 != 0) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } - else - { - if (iRemain != iRequired) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } - } - } - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_uint8p pWork = pTemp; - mng_uint8 iFramemode = 0; - mng_uint8 iChangedelay = 0; - mng_uint32 iDelay = 0; - mng_uint8 iChangetimeout = 0; - mng_uint32 iTimeout = 0; - mng_uint8 iChangeclipping = 0; - mng_uint8 iCliptype = 0; - mng_int32 iClipl = 0; - mng_int32 iClipr = 0; - mng_int32 iClipt = 0; - mng_int32 iClipb = 0; - mng_retcode iRetcode; - - if (iRawlen) /* any data specified ? */ - { - if (*(pRawdata)) /* save the new framing mode ? */ - { - iFramemode = *(pRawdata); - -#ifndef MNG_NO_OLD_VERSIONS - if (pData->bPreDraft48) /* old style input-stream ? */ - { - switch (iFramemode) - { - case 0: { break; } - case 1: { iFramemode = 3; break; } - case 2: { iFramemode = 4; break; } - case 3: { iFramemode = 1; break; } - case 4: { iFramemode = 1; break; } - case 5: { iFramemode = 2; break; } - default: { iFramemode = 1; break; } - } - } -#endif - } - - if (iRemain) - { - iChangedelay = *(pWork+1); - iChangetimeout = *(pWork+2); - iChangeclipping = *(pWork+3); - pWork += 5; - - if (iChangedelay) /* delay changed ? */ - { - iDelay = mng_get_uint32 (pWork); - pWork += 4; - } - - if (iChangetimeout) /* timeout changed ? */ - { - iTimeout = mng_get_uint32 (pWork); - pWork += 4; - } - - if (iChangeclipping) /* clipping changed ? */ - { - iCliptype = *pWork; - iClipl = mng_get_int32 (pWork+1); - iClipr = mng_get_int32 (pWork+5); - iClipt = mng_get_int32 (pWork+9); - iClipb = mng_get_int32 (pWork+13); - } - } - } - - iRetcode = mng_create_ani_fram (pData, iFramemode, iChangedelay, iDelay, - iChangetimeout, iTimeout, - iChangeclipping, iCliptype, - iClipl, iClipr, iClipt, iClipb); - -/* if (!iRetcode) - iRetcode = mng_process_display_fram (pData, iFramemode, iChangedelay, iDelay, - iChangetimeout, iTimeout, - iChangeclipping, iCliptype, - iClipl, iClipr, iClipt, iClipb); */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_framp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - { - mng_uint8 iFramemode = *(pRawdata); - -#ifndef MNG_NO_OLD_VERSIONS - if (pData->bPreDraft48) /* old style input-stream ? */ - { - switch (iFramemode) - { - case 1: { iFramemode = 3; break; } - case 2: { iFramemode = 4; break; } - case 3: { iFramemode = 5; break; } /* TODO: provision for mode=5 ??? */ - case 4: { iFramemode = 1; break; } - case 5: { iFramemode = 2; break; } - default: { iFramemode = 1; break; } - } - } -#endif - - ((mng_framp)*ppChunk)->iMode = iFramemode; - ((mng_framp)*ppChunk)->iNamesize = iNamelen; - - if (iNamelen) - { - MNG_ALLOC (pData, ((mng_framp)*ppChunk)->zName, iNamelen+1); - MNG_COPY (((mng_framp)*ppChunk)->zName, pRawdata+1, iNamelen); - } - - if (iRemain) - { - ((mng_framp)*ppChunk)->iChangedelay = *(pTemp+1); - ((mng_framp)*ppChunk)->iChangetimeout = *(pTemp+2); - ((mng_framp)*ppChunk)->iChangeclipping = *(pTemp+3); - ((mng_framp)*ppChunk)->iChangesyncid = *(pTemp+4); - - pTemp += 5; - - if (((mng_framp)*ppChunk)->iChangedelay) - { - ((mng_framp)*ppChunk)->iDelay = mng_get_uint32 (pTemp); - pTemp += 4; - } - - if (((mng_framp)*ppChunk)->iChangetimeout) - { - ((mng_framp)*ppChunk)->iTimeout = mng_get_uint32 (pTemp); - pTemp += 4; - } - - if (((mng_framp)*ppChunk)->iChangeclipping) - { - ((mng_framp)*ppChunk)->iBoundarytype = *pTemp; - ((mng_framp)*ppChunk)->iBoundaryl = mng_get_int32 (pTemp+1); - ((mng_framp)*ppChunk)->iBoundaryr = mng_get_int32 (pTemp+5); - ((mng_framp)*ppChunk)->iBoundaryt = mng_get_int32 (pTemp+9); - ((mng_framp)*ppChunk)->iBoundaryb = mng_get_int32 (pTemp+13); - pTemp += 17; - } - - if (((mng_framp)*ppChunk)->iChangesyncid) - { - ((mng_framp)*ppChunk)->iCount = (iRemain - iRequired) / 4; - - if (((mng_framp)*ppChunk)->iCount) - { - MNG_ALLOC (pData, ((mng_framp)*ppChunk)->pSyncids, - ((mng_framp)*ppChunk)->iCount * 4); - -#ifndef MNG_BIGENDIAN_SUPPORTED - { - mng_uint32 iX; - mng_uint32p pOut = ((mng_framp)*ppChunk)->pSyncids; - - for (iX = 0; iX < ((mng_framp)*ppChunk)->iCount; iX++) - { - *pOut++ = mng_get_uint32 (pTemp); - pTemp += 4; - } - } -#else - MNG_COPY (((mng_framp)*ppChunk)->pSyncids, pTemp, - ((mng_framp)*ppChunk)->iCount * 4); -#endif /* !MNG_BIGENDIAN_SUPPORTED */ - } - } - } - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_FRAM, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_MOVE -READ_CHUNK (mng_read_move) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MOVE, MNG_LC_START); -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen != 13) /* check the length */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode; - /* create a MOVE animation object */ - iRetcode = mng_create_ani_move (pData, mng_get_uint16 (pRawdata), - mng_get_uint16 (pRawdata+2), - *(pRawdata+4), - mng_get_int32 (pRawdata+5), - mng_get_int32 (pRawdata+9)); - -/* if (!iRetcode) - iRetcode = mng_process_display_move (pData, - mng_get_uint16 (pRawdata), - mng_get_uint16 (pRawdata+2), - *(pRawdata+4), - mng_get_int32 (pRawdata+5), - mng_get_int32 (pRawdata+9)); */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_movep)*ppChunk)->iFirstid = mng_get_uint16 (pRawdata); - ((mng_movep)*ppChunk)->iLastid = mng_get_uint16 (pRawdata+2); - ((mng_movep)*ppChunk)->iMovetype = *(pRawdata+4); - ((mng_movep)*ppChunk)->iMovex = mng_get_int32 (pRawdata+5); - ((mng_movep)*ppChunk)->iMovey = mng_get_int32 (pRawdata+9); - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MOVE, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_CLIP -READ_CHUNK (mng_read_clip) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_CLIP, MNG_LC_START); -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen != 21) /* check the length */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode; - /* create a CLIP animation object */ - iRetcode = mng_create_ani_clip (pData, mng_get_uint16 (pRawdata), - mng_get_uint16 (pRawdata+2), - *(pRawdata+4), - mng_get_int32 (pRawdata+5), - mng_get_int32 (pRawdata+9), - mng_get_int32 (pRawdata+13), - mng_get_int32 (pRawdata+17)); - -/* if (!iRetcode) - iRetcode = mng_process_display_clip (pData, - mng_get_uint16 (pRawdata), - mng_get_uint16 (pRawdata+2), - *(pRawdata+4), - mng_get_int32 (pRawdata+5), - mng_get_int32 (pRawdata+9), - mng_get_int32 (pRawdata+13), - mng_get_int32 (pRawdata+17)); */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_clipp)*ppChunk)->iFirstid = mng_get_uint16 (pRawdata); - ((mng_clipp)*ppChunk)->iLastid = mng_get_uint16 (pRawdata+2); - ((mng_clipp)*ppChunk)->iCliptype = *(pRawdata+4); - ((mng_clipp)*ppChunk)->iClipl = mng_get_int32 (pRawdata+5); - ((mng_clipp)*ppChunk)->iClipr = mng_get_int32 (pRawdata+9); - ((mng_clipp)*ppChunk)->iClipt = mng_get_int32 (pRawdata+13); - ((mng_clipp)*ppChunk)->iClipb = mng_get_int32 (pRawdata+17); - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_CLIP, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_SHOW -READ_CHUNK (mng_read_show) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SHOW, MNG_LC_START); -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - /* check the length */ - if ((iRawlen != 0) && (iRawlen != 2) && (iRawlen != 4) && (iRawlen != 5)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode; - - if (iRawlen) /* determine parameters if any */ - { - pData->iSHOWfromid = mng_get_uint16 (pRawdata); - - if (iRawlen > 2) - pData->iSHOWtoid = mng_get_uint16 (pRawdata+2); - else - pData->iSHOWtoid = pData->iSHOWfromid; - - if (iRawlen > 4) - pData->iSHOWmode = *(pRawdata+4); - else - pData->iSHOWmode = 0; - } - else /* use defaults then */ - { - pData->iSHOWmode = 2; - pData->iSHOWfromid = 1; - pData->iSHOWtoid = 65535; - } - /* create a SHOW animation object */ - iRetcode = mng_create_ani_show (pData, pData->iSHOWfromid, - pData->iSHOWtoid, pData->iSHOWmode); - - if (!iRetcode) - iRetcode = mng_process_display_show (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_showp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - { - ((mng_showp)*ppChunk)->iFirstid = mng_get_uint16 (pRawdata); - - if (iRawlen > 2) - ((mng_showp)*ppChunk)->iLastid = mng_get_uint16 (pRawdata+2); - else - ((mng_showp)*ppChunk)->iLastid = ((mng_showp)*ppChunk)->iFirstid; - - if (iRawlen > 4) - ((mng_showp)*ppChunk)->iMode = *(pRawdata+4); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SHOW, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_TERM -READ_CHUNK (mng_read_term) -{ - mng_uint8 iTermaction; - mng_uint8 iIteraction = 0; - mng_uint32 iDelay = 0; - mng_uint32 iItermax = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_TERM, MNG_LC_START); -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - /* should be behind MHDR or SAVE !! */ - if ((!pData->bHasSAVE) && (pData->iChunkseq > 2)) - { - pData->bMisplacedTERM = MNG_TRUE; /* indicate we found a misplaced TERM */ - /* and send a warning signal!!! */ - MNG_WARNING (pData, MNG_SEQUENCEERROR); - } - - if (pData->bHasLOOP) /* no way, jose! */ - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (pData->bHasTERM) /* only 1 allowed! */ - MNG_ERROR (pData, MNG_MULTIPLEERROR); - /* check the length */ - if ((iRawlen != 1) && (iRawlen != 10)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - pData->bHasTERM = MNG_TRUE; - - iTermaction = *pRawdata; /* get the fields */ - - if (iRawlen > 1) - { - iIteraction = *(pRawdata+1); - iDelay = mng_get_uint32 (pRawdata+2); - iItermax = mng_get_uint32 (pRawdata+6); - } - - if (pData->fProcessterm) /* inform the app ? */ - if (!pData->fProcessterm (((mng_handle)pData), iTermaction, iIteraction, - iDelay, iItermax)) - MNG_ERROR (pData, MNG_APPMISCERROR); - -#ifdef MNG_SUPPORT_DISPLAY - { /* create the TERM ani-object */ - mng_retcode iRetcode = mng_create_ani_term (pData, iTermaction, iIteraction, - iDelay, iItermax); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* save for future reference */ - pData->pTermaniobj = pData->pLastaniobj; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_termp)*ppChunk)->iTermaction = iTermaction; - ((mng_termp)*ppChunk)->iIteraction = iIteraction; - ((mng_termp)*ppChunk)->iDelay = iDelay; - ((mng_termp)*ppChunk)->iItermax = iItermax; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_TERM, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_SAVE -READ_CHUNK (mng_read_save) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SAVE, MNG_LC_START); -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) || (pData->bHasSAVE)) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - pData->bHasSAVE = MNG_TRUE; - - if (pData->fProcesssave) /* inform the application ? */ - { - mng_bool bOke = pData->fProcesssave ((mng_handle)pData); - - if (!bOke) - MNG_ERROR (pData, MNG_APPMISCERROR); - } - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode; - - - /* TODO: something with the parameters */ - - - /* create a SAVE animation object */ - iRetcode = mng_create_ani_save (pData); - - if (!iRetcode) - iRetcode = mng_process_display_save (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_savep)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) /* not empty ? */ - { - mng_uint8 iOtype = *pRawdata; - mng_uint8 iEtype; - mng_uint32 iCount = 0; - mng_uint8p pTemp; - mng_uint8p pNull; - mng_uint32 iLen; - mng_uint32 iOffset[2]; - mng_uint32 iStarttime[2]; - mng_uint32 iFramenr; - mng_uint32 iLayernr; - mng_uint32 iX; - mng_save_entryp pEntry = MNG_NULL; - mng_uint32 iNamesize; - - if ((iOtype != 4) && (iOtype != 8)) - MNG_ERROR (pData, MNG_INVOFFSETSIZE); - - ((mng_savep)*ppChunk)->iOffsettype = iOtype; - - for (iX = 0; iX < 2; iX++) /* do this twice to get the count first ! */ - { - pTemp = pRawdata + 1; - iLen = iRawlen - 1; - - if (iX) /* second run ? */ - { - MNG_ALLOC (pData, pEntry, (iCount * sizeof (mng_save_entry))); - - ((mng_savep)*ppChunk)->iCount = iCount; - ((mng_savep)*ppChunk)->pEntries = pEntry; - } - - while (iLen) /* anything left ? */ - { - iEtype = *pTemp; /* entrytype */ - - if ((iEtype != 0) && (iEtype != 1) && (iEtype != 2) && (iEtype != 3)) - MNG_ERROR (pData, MNG_INVENTRYTYPE); - - pTemp++; - - if (iEtype > 1) - { - iOffset [0] = 0; - iOffset [1] = 0; - iStarttime [0] = 0; - iStarttime [1] = 0; - iLayernr = 0; - iFramenr = 0; - } - else - { - if (iOtype == 4) - { - iOffset [0] = 0; - iOffset [1] = mng_get_uint32 (pTemp); - - pTemp += 4; - } - else - { - iOffset [0] = mng_get_uint32 (pTemp); - iOffset [1] = mng_get_uint32 (pTemp+4); - - pTemp += 8; - } - - if (iEtype > 0) - { - iStarttime [0] = 0; - iStarttime [1] = 0; - iLayernr = 0; - iFramenr = 0; - } - else - { - if (iOtype == 4) - { - iStarttime [0] = 0; - iStarttime [1] = mng_get_uint32 (pTemp+0); - iLayernr = mng_get_uint32 (pTemp+4); - iFramenr = mng_get_uint32 (pTemp+8); - - pTemp += 12; - } - else - { - iStarttime [0] = mng_get_uint32 (pTemp+0); - iStarttime [1] = mng_get_uint32 (pTemp+4); - iLayernr = mng_get_uint32 (pTemp+8); - iFramenr = mng_get_uint32 (pTemp+12); - - pTemp += 16; - } - } - } - - pNull = find_null (pTemp); /* get the name length */ - - if ((pNull - pRawdata) > (mng_int32)iRawlen) - { - iNamesize = iLen; /* no null found; so end of SAVE */ - iLen = 0; - } - else - { - iNamesize = pNull - pTemp; /* should be another entry */ - iLen -= iNamesize; - - if (!iLen) /* must not end with a null ! */ - MNG_ERROR (pData, MNG_ENDWITHNULL); - } - - if (!pEntry) - { - iCount++; - } - else - { - pEntry->iEntrytype = iEtype; - pEntry->iOffset [0] = iOffset [0]; - pEntry->iOffset [1] = iOffset [1]; - pEntry->iStarttime [0] = iStarttime [0]; - pEntry->iStarttime [1] = iStarttime [1]; - pEntry->iLayernr = iLayernr; - pEntry->iFramenr = iFramenr; - pEntry->iNamesize = iNamesize; - - if (iNamesize) - { - MNG_ALLOC (pData, pEntry->zName, iNamesize+1); - MNG_COPY (pEntry->zName, pTemp, iNamesize); - } - - pEntry++; - } - - pTemp += iNamesize; - } - } - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SAVE, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_SEEK -READ_CHUNK (mng_read_seek) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SEEK, MNG_LC_START); -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) || (!pData->bHasSAVE)) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_SUPPORT_DISPLAY - /* create a SEEK animation object */ - iRetcode = mng_create_ani_seek (pData, iRawlen, (mng_pchar)pRawdata); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#endif /* MNG_SUPPORT_DISPLAY */ - - if (pData->fProcessseek) /* inform the app ? */ - { - mng_bool bOke; - mng_pchar zName; - - MNG_ALLOC (pData, zName, iRawlen + 1); - - if (iRawlen) - MNG_COPY (zName, pRawdata, iRawlen); - - bOke = pData->fProcessseek ((mng_handle)pData, zName); - - MNG_FREEX (pData, zName, iRawlen + 1); - - if (!bOke) - MNG_ERROR (pData, MNG_APPMISCERROR); - } - -#ifdef MNG_SUPPORT_DISPLAY - /* do display processing of the SEEK */ - iRetcode = mng_process_display_seek (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_seekp)*ppChunk)->iNamesize = iRawlen; - - if (iRawlen) - { - MNG_ALLOC (pData, ((mng_seekp)*ppChunk)->zName, iRawlen+1); - MNG_COPY (((mng_seekp)*ppChunk)->zName, pRawdata, iRawlen); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SEEK, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_eXPI -READ_CHUNK (mng_read_expi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_EXPI, MNG_LC_START); -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen < 3) /* check the length */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_expip)*ppChunk)->iSnapshotid = mng_get_uint16 (pRawdata); - ((mng_expip)*ppChunk)->iNamesize = iRawlen - 2; - - if (((mng_expip)*ppChunk)->iNamesize) - { - MNG_ALLOC (pData, ((mng_expip)*ppChunk)->zName, - ((mng_expip)*ppChunk)->iNamesize + 1); - MNG_COPY (((mng_expip)*ppChunk)->zName, pRawdata+2, - ((mng_expip)*ppChunk)->iNamesize); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_EXPI, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_fPRI -READ_CHUNK (mng_read_fpri) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_FPRI, MNG_LC_START); -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen != 2) /* must be two bytes long */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_fprip)*ppChunk)->iDeltatype = *pRawdata; - ((mng_fprip)*ppChunk)->iPriority = *(pRawdata+1); - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_FPRI, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_nEED -MNG_LOCAL mng_bool CheckKeyword (mng_datap pData, - mng_uint8p pKeyword) -{ - mng_chunkid handled_chunks [] = - { - MNG_UINT_BACK, /* keep it sorted !!!! */ - MNG_UINT_BASI, - MNG_UINT_CLIP, - MNG_UINT_CLON, -#ifndef MNG_NO_DELTA_PNG -/* TODO: MNG_UINT_DBYK, */ -#endif - MNG_UINT_DEFI, -#ifndef MNG_NO_DELTA_PNG - MNG_UINT_DHDR, -#endif - MNG_UINT_DISC, -#ifndef MNG_NO_DELTA_PNG -/* TODO: MNG_UINT_DROP, */ -#endif - MNG_UINT_ENDL, - MNG_UINT_FRAM, - MNG_UINT_IDAT, - MNG_UINT_IEND, - MNG_UINT_IHDR, -#ifndef MNG_NO_DELTA_PNG -#ifdef MNG_INCLUDE_JNG - MNG_UINT_IJNG, -#endif - MNG_UINT_IPNG, -#endif -#ifdef MNG_INCLUDE_JNG - MNG_UINT_JDAA, - MNG_UINT_JDAT, - MNG_UINT_JHDR, -/* TODO: MNG_UINT_JSEP, */ - MNG_UINT_JdAA, -#endif - MNG_UINT_LOOP, - MNG_UINT_MAGN, - MNG_UINT_MEND, - MNG_UINT_MHDR, - MNG_UINT_MOVE, -/* TODO: MNG_UINT_ORDR, */ - MNG_UINT_PAST, - MNG_UINT_PLTE, -#ifndef MNG_NO_DELTA_PNG - MNG_UINT_PPLT, - MNG_UINT_PROM, -#endif - MNG_UINT_SAVE, - MNG_UINT_SEEK, - MNG_UINT_SHOW, - MNG_UINT_TERM, -#ifdef MNG_INCLUDE_ANG_PROPOSAL - MNG_UINT_adAT, - MNG_UINT_ahDR, -#endif - MNG_UINT_bKGD, - MNG_UINT_cHRM, -/* TODO: MNG_UINT_eXPI, */ - MNG_UINT_evNT, -/* TODO: MNG_UINT_fPRI, */ - MNG_UINT_gAMA, -/* TODO: MNG_UINT_hIST, */ - MNG_UINT_iCCP, - MNG_UINT_iTXt, -#ifdef MNG_INCLUDE_MPNG_PROPOSAL - MNG_UINT_mpNG, -#endif - MNG_UINT_nEED, -/* TODO: MNG_UINT_oFFs, */ -/* TODO: MNG_UINT_pCAL, */ -/* TODO: MNG_UINT_pHYg, */ -/* TODO: MNG_UINT_pHYs, */ -/* TODO: MNG_UINT_sBIT, */ -/* TODO: MNG_UINT_sCAL, */ -/* TODO: MNG_UINT_sPLT, */ - MNG_UINT_sRGB, - MNG_UINT_tEXt, - MNG_UINT_tIME, - MNG_UINT_tRNS, - MNG_UINT_zTXt, - }; - - mng_bool bOke = MNG_FALSE; - - if (pData->fProcessneed) /* does the app handle it ? */ - bOke = pData->fProcessneed ((mng_handle)pData, (mng_pchar)pKeyword); - - if (!bOke) - { /* find the keyword length */ - mng_uint8p pNull = find_null (pKeyword); - - if (pNull - pKeyword == 4) /* test a chunk ? */ - { /* get the chunk-id */ - mng_chunkid iChunkid = (*pKeyword << 24) + (*(pKeyword+1) << 16) + - (*(pKeyword+2) << 8) + (*(pKeyword+3) ); - /* binary search variables */ - mng_int32 iTop, iLower, iUpper, iMiddle; - /* determine max index of table */ - iTop = (sizeof (handled_chunks) / sizeof (handled_chunks [0])) - 1; - - /* binary search; with 52 chunks, worst-case is 7 comparisons */ - iLower = 0; - iMiddle = iTop >> 1; - iUpper = iTop; - - do /* the binary search itself */ - { - if (handled_chunks [iMiddle] < iChunkid) - iLower = iMiddle + 1; - else if (handled_chunks [iMiddle] > iChunkid) - iUpper = iMiddle - 1; - else - { - bOke = MNG_TRUE; - break; - } - - iMiddle = (iLower + iUpper) >> 1; - } - while (iLower <= iUpper); - } - /* test draft ? */ - if ((!bOke) && (pNull - pKeyword == 8) && - (*pKeyword == 'd') && (*(pKeyword+1) == 'r') && - (*(pKeyword+2) == 'a') && (*(pKeyword+3) == 'f') && - (*(pKeyword+4) == 't') && (*(pKeyword+5) == ' ')) - { - mng_uint32 iDraft; - - iDraft = (*(pKeyword+6) - '0') * 10 + (*(pKeyword+7) - '0'); - bOke = (mng_bool)(iDraft <= MNG_MNG_DRAFT); - } - /* test MNG 1.0/1.1 ? */ - if ((!bOke) && (pNull - pKeyword == 7) && - (*pKeyword == 'M') && (*(pKeyword+1) == 'N') && - (*(pKeyword+2) == 'G') && (*(pKeyword+3) == '-') && - (*(pKeyword+4) == '1') && (*(pKeyword+5) == '.') && - ((*(pKeyword+6) == '0') || (*(pKeyword+6) == '1'))) - bOke = MNG_TRUE; - /* test CACHEOFF ? */ - if ((!bOke) && (pNull - pKeyword == 8) && - (*pKeyword == 'C') && (*(pKeyword+1) == 'A') && - (*(pKeyword+2) == 'C') && (*(pKeyword+3) == 'H') && - (*(pKeyword+4) == 'E') && (*(pKeyword+5) == 'O') && - (*(pKeyword+6) == 'F') && (*(pKeyword+7) == 'F')) - { - if (!pData->pFirstaniobj) /* only if caching hasn't started yet ! */ - { - bOke = MNG_TRUE; - pData->bCacheplayback = MNG_FALSE; - pData->bStorechunks = MNG_FALSE; - } - } - } - - return bOke; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_nEED -READ_CHUNK (mng_read_need) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_NEED, MNG_LC_START); -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen < 1) /* check the length */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - { /* let's check it */ - mng_bool bOke = MNG_TRUE; - mng_pchar zKeywords; - mng_uint8p pNull, pTemp; - - MNG_ALLOC (pData, zKeywords, iRawlen + 1); - - if (iRawlen) - MNG_COPY (zKeywords, pRawdata, iRawlen); - - pTemp = (mng_uint8p)zKeywords; - pNull = find_null (pTemp); - - while ((bOke) && (pNull < (mng_uint8p)zKeywords + iRawlen)) - { - bOke = CheckKeyword (pData, pTemp); - pTemp = pNull + 1; - pNull = find_null (pTemp); - } - - if (bOke) - bOke = CheckKeyword (pData, pTemp); - - MNG_FREEX (pData, zKeywords, iRawlen + 1); - - if (!bOke) - MNG_ERROR (pData, MNG_UNSUPPORTEDNEED); - } - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_needp)*ppChunk)->iKeywordssize = iRawlen; - - if (iRawlen) - { - MNG_ALLOC (pData, ((mng_needp)*ppChunk)->zKeywords, iRawlen+1); - MNG_COPY (((mng_needp)*ppChunk)->zKeywords, pRawdata, iRawlen); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_NEED, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_pHYg -READ_CHUNK (mng_read_phyg) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PHYG, MNG_LC_START); -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - /* it's 9 bytes or empty; no more, no less! */ - if ((iRawlen != 9) && (iRawlen != 0)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_phygp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - { - ((mng_phygp)*ppChunk)->iSizex = mng_get_uint32 (pRawdata); - ((mng_phygp)*ppChunk)->iSizey = mng_get_uint32 (pRawdata+4); - ((mng_phygp)*ppChunk)->iUnit = *(pRawdata+8); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PHYG, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_INCLUDE_JNG -READ_CHUNK (mng_read_jhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_JHDR, MNG_LC_START); -#endif - /* sequence checks */ - if ((pData->eSigtype != mng_it_jng) && (pData->eSigtype != mng_it_mng)) - MNG_ERROR (pData, MNG_CHUNKNOTALLOWED); - - if ((pData->eSigtype == mng_it_jng) && (pData->iChunkseq > 1)) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen != 16) /* length oke ? */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - /* inside a JHDR-IEND block now */ - pData->bHasJHDR = MNG_TRUE; - /* and store interesting fields */ - pData->iDatawidth = mng_get_uint32 (pRawdata); - pData->iDataheight = mng_get_uint32 (pRawdata+4); - pData->iJHDRcolortype = *(pRawdata+8); - pData->iJHDRimgbitdepth = *(pRawdata+9); - pData->iJHDRimgcompression = *(pRawdata+10); - pData->iJHDRimginterlace = *(pRawdata+11); - pData->iJHDRalphabitdepth = *(pRawdata+12); - pData->iJHDRalphacompression = *(pRawdata+13); - pData->iJHDRalphafilter = *(pRawdata+14); - pData->iJHDRalphainterlace = *(pRawdata+15); - - -#if defined(MNG_NO_1_2_4BIT_SUPPORT) || defined(MNG_NO_16BIT_SUPPORT) - pData->iPNGmult = 1; - pData->iPNGdepth = pData->iJHDRalphabitdepth; -#endif - -#ifdef MNG_NO_1_2_4BIT_SUPPORT - if (pData->iJHDRalphabitdepth < 8) - pData->iJHDRalphabitdepth = 8; -#endif - -#ifdef MNG_NO_16BIT_SUPPORT - if (pData->iJHDRalphabitdepth > 8) - { - pData->iPNGmult = 2; - pData->iJHDRalphabitdepth = 8; - } -#endif - /* parameter validity checks */ - if ((pData->iJHDRcolortype != MNG_COLORTYPE_JPEGGRAY ) && - (pData->iJHDRcolortype != MNG_COLORTYPE_JPEGCOLOR ) && - (pData->iJHDRcolortype != MNG_COLORTYPE_JPEGGRAYA ) && - (pData->iJHDRcolortype != MNG_COLORTYPE_JPEGCOLORA) ) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE); - - if ((pData->iJHDRimgbitdepth != MNG_BITDEPTH_JPEG8 ) && - (pData->iJHDRimgbitdepth != MNG_BITDEPTH_JPEG12 ) && - (pData->iJHDRimgbitdepth != MNG_BITDEPTH_JPEG8AND12) ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH); - - if (pData->iJHDRimgcompression != MNG_COMPRESSION_BASELINEJPEG) - MNG_ERROR (pData, MNG_INVALIDCOMPRESS); - - if ((pData->iJHDRimginterlace != MNG_INTERLACE_SEQUENTIAL ) && - (pData->iJHDRimginterlace != MNG_INTERLACE_PROGRESSIVE) ) - MNG_ERROR (pData, MNG_INVALIDINTERLACE); - - if ((pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) ) - { - if ((pData->iJHDRalphabitdepth != MNG_BITDEPTH_8 ) -#ifndef MNG_NO_1_2_4BIT_SUPPORT - && (pData->iJHDRalphabitdepth != MNG_BITDEPTH_1 ) && - (pData->iJHDRalphabitdepth != MNG_BITDEPTH_2 ) && - (pData->iJHDRalphabitdepth != MNG_BITDEPTH_4 ) -#endif -#ifndef MNG_NO_16BIT_SUPPORT - && (pData->iJHDRalphabitdepth != MNG_BITDEPTH_16) -#endif - ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH); - - if ((pData->iJHDRalphacompression != MNG_COMPRESSION_DEFLATE ) && - (pData->iJHDRalphacompression != MNG_COMPRESSION_BASELINEJPEG) ) - MNG_ERROR (pData, MNG_INVALIDCOMPRESS); - - if ((pData->iJHDRalphacompression == MNG_COMPRESSION_BASELINEJPEG) && - (pData->iJHDRalphabitdepth != MNG_BITDEPTH_8 ) ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH); - -#if defined(FILTER192) || defined(FILTER193) - if ((pData->iJHDRalphafilter != MNG_FILTER_ADAPTIVE ) && -#if defined(FILTER192) && defined(FILTER193) - (pData->iJHDRalphafilter != MNG_FILTER_DIFFERING) && - (pData->iJHDRalphafilter != MNG_FILTER_NOFILTER ) ) -#else -#ifdef FILTER192 - (pData->iJHDRalphafilter != MNG_FILTER_DIFFERING) ) -#else - (pData->iJHDRalphafilter != MNG_FILTER_NOFILTER ) ) -#endif -#endif - MNG_ERROR (pData, MNG_INVALIDFILTER); -#else - if (pData->iJHDRalphafilter) - MNG_ERROR (pData, MNG_INVALIDFILTER); -#endif - - if ((pData->iJHDRalphainterlace != MNG_INTERLACE_NONE ) && - (pData->iJHDRalphainterlace != MNG_INTERLACE_ADAM7) ) - MNG_ERROR (pData, MNG_INVALIDINTERLACE); - - } - else - { - if (pData->iJHDRalphabitdepth) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH); - - if (pData->iJHDRalphacompression) - MNG_ERROR (pData, MNG_INVALIDCOMPRESS); - - if (pData->iJHDRalphafilter) - MNG_ERROR (pData, MNG_INVALIDFILTER); - - if (pData->iJHDRalphainterlace) - MNG_ERROR (pData, MNG_INVALIDINTERLACE); - - } - - if (!pData->bHasheader) /* first chunk ? */ - { - pData->bHasheader = MNG_TRUE; /* we've got a header */ - pData->eImagetype = mng_it_jng; /* then this must be a JNG */ - pData->iWidth = mng_get_uint32 (pRawdata); - pData->iHeight = mng_get_uint32 (pRawdata+4); - /* predict alpha-depth ! */ - if ((pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) ) - pData->iAlphadepth = pData->iJHDRalphabitdepth; - else - pData->iAlphadepth = 0; - /* fits on maximum canvas ? */ - if ((pData->iWidth > pData->iMaxwidth) || (pData->iHeight > pData->iMaxheight)) - MNG_WARNING (pData, MNG_IMAGETOOLARGE); - - if (pData->fProcessheader) /* inform the app ? */ - if (!pData->fProcessheader (((mng_handle)pData), pData->iWidth, pData->iHeight)) - MNG_ERROR (pData, MNG_APPMISCERROR); - - } - - pData->iColortype = 0; /* fake grayscale for other routines */ - pData->iImagelevel++; /* one level deeper */ - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode = mng_process_display_jhdr (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_jhdrp)*ppChunk)->iWidth = mng_get_uint32 (pRawdata); - ((mng_jhdrp)*ppChunk)->iHeight = mng_get_uint32 (pRawdata+4); - ((mng_jhdrp)*ppChunk)->iColortype = *(pRawdata+8); - ((mng_jhdrp)*ppChunk)->iImagesampledepth = *(pRawdata+9); - ((mng_jhdrp)*ppChunk)->iImagecompression = *(pRawdata+10); - ((mng_jhdrp)*ppChunk)->iImageinterlace = *(pRawdata+11); - ((mng_jhdrp)*ppChunk)->iAlphasampledepth = *(pRawdata+12); -#ifdef MNG_NO_16BIT_SUPPORT - if (*(pRawdata+12) > 8) - ((mng_jhdrp)*ppChunk)->iAlphasampledepth = 8; -#endif - ((mng_jhdrp)*ppChunk)->iAlphacompression = *(pRawdata+13); - ((mng_jhdrp)*ppChunk)->iAlphafilter = *(pRawdata+14); - ((mng_jhdrp)*ppChunk)->iAlphainterlace = *(pRawdata+15); - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_JHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#else -#define read_jhdr 0 -#endif /* MNG_INCLUDE_JNG */ -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_INCLUDE_JNG -READ_CHUNK (mng_read_jdaa) -{ -#if defined(MNG_SUPPORT_DISPLAY) || defined(MNG_STORE_CHUNKS) - volatile mng_retcode iRetcode; - - iRetcode=MNG_NOERROR; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_JDAA, MNG_LC_START); -#endif - /* sequence checks */ - if ((!pData->bHasJHDR) && (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (pData->bHasJSEP) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (pData->iJHDRalphacompression != MNG_COMPRESSION_BASELINEJPEG) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen == 0) /* can never be empty */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - pData->bHasJDAA = MNG_TRUE; /* got some JDAA now, don't we */ - -#ifdef MNG_SUPPORT_DISPLAY - iRetcode = mng_process_display_jdaa (pData, iRawlen, pRawdata); - - if (iRetcode) /* on error bail out */ - return iRetcode; -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_jdaap)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - ((mng_jdaap)*ppChunk)->iDatasize = iRawlen; - - if (iRawlen != 0) /* is there any data ? */ - { - MNG_ALLOC (pData, ((mng_jdaap)*ppChunk)->pData, iRawlen); - MNG_COPY (((mng_jdaap)*ppChunk)->pData, pRawdata, iRawlen); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_JDAA, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#else -#define read_jdaa 0 -#endif /* MNG_INCLUDE_JNG */ -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_INCLUDE_JNG -READ_CHUNK (mng_read_jdat) -{ -#if defined(MNG_SUPPORT_DISPLAY) || defined(MNG_STORE_CHUNKS) - volatile mng_retcode iRetcode; - - iRetcode=MNG_NOERROR; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_JDAT, MNG_LC_START); -#endif - /* sequence checks */ - if ((!pData->bHasJHDR) && (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen == 0) /* can never be empty */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - pData->bHasJDAT = MNG_TRUE; /* got some JDAT now, don't we */ - -#ifdef MNG_SUPPORT_DISPLAY - iRetcode = mng_process_display_jdat (pData, iRawlen, pRawdata); - - if (iRetcode) /* on error bail out */ - return iRetcode; -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_jdatp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - ((mng_jdatp)*ppChunk)->iDatasize = iRawlen; - - if (iRawlen != 0) /* is there any data ? */ - { - MNG_ALLOC (pData, ((mng_jdatp)*ppChunk)->pData, iRawlen); - MNG_COPY (((mng_jdatp)*ppChunk)->pData, pRawdata, iRawlen); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_JDAT, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#else -#define read_jdat 0 -#endif /* MNG_INCLUDE_JNG */ -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_INCLUDE_JNG -READ_CHUNK (mng_read_jsep) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_JSEP, MNG_LC_START); -#endif - - if (!pData->bHasJHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen != 0) /* must be empty ! */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - pData->bHasJSEP = MNG_TRUE; /* indicate we've had the 8-/12-bit separator */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_JSEP, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#else -#define read_jsep 0 -#endif /* MNG_INCLUDE_JNG */ -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_NO_DELTA_PNG -READ_CHUNK (mng_read_dhdr) -{ - mng_uint8 iImagetype, iDeltatype; -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DHDR, MNG_LC_START); -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - /* check for valid length */ - if ((iRawlen != 4) && (iRawlen != 12) && (iRawlen != 20)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - iImagetype = *(pRawdata+2); /* check fields for validity */ - iDeltatype = *(pRawdata+3); - - if (iImagetype > MNG_IMAGETYPE_JNG) - MNG_ERROR (pData, MNG_INVIMAGETYPE); - - if (iDeltatype > MNG_DELTATYPE_NOCHANGE) - MNG_ERROR (pData, MNG_INVDELTATYPE); - - if ((iDeltatype == MNG_DELTATYPE_REPLACE) && (iRawlen > 12)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - if ((iDeltatype == MNG_DELTATYPE_NOCHANGE) && (iRawlen > 4)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - pData->bHasDHDR = MNG_TRUE; /* inside a DHDR-IEND block now */ - pData->iDeltatype = iDeltatype; - - pData->iImagelevel++; /* one level deeper */ - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_uint16 iObjectid = mng_get_uint16 (pRawdata); - mng_uint32 iBlockwidth = 0; - mng_uint32 iBlockheight = 0; - mng_uint32 iBlockx = 0; - mng_uint32 iBlocky = 0; - mng_retcode iRetcode; - - if (iRawlen > 4) - { - iBlockwidth = mng_get_uint32 (pRawdata+4); - iBlockheight = mng_get_uint32 (pRawdata+8); - } - - if (iRawlen > 12) - { - iBlockx = mng_get_uint32 (pRawdata+12); - iBlocky = mng_get_uint32 (pRawdata+16); - } - - iRetcode = mng_create_ani_dhdr (pData, iObjectid, iImagetype, iDeltatype, - iBlockwidth, iBlockheight, iBlockx, iBlocky); - -/* if (!iRetcode) - iRetcode = mng_process_display_dhdr (pData, iObjectid, iImagetype, iDeltatype, - iBlockwidth, iBlockheight, iBlockx, iBlocky); */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_dhdrp)*ppChunk)->iObjectid = mng_get_uint16 (pRawdata); - ((mng_dhdrp)*ppChunk)->iImagetype = iImagetype; - ((mng_dhdrp)*ppChunk)->iDeltatype = iDeltatype; - - if (iRawlen > 4) - { - ((mng_dhdrp)*ppChunk)->iBlockwidth = mng_get_uint32 (pRawdata+4); - ((mng_dhdrp)*ppChunk)->iBlockheight = mng_get_uint32 (pRawdata+8); - } - - if (iRawlen > 12) - { - ((mng_dhdrp)*ppChunk)->iBlockx = mng_get_uint32 (pRawdata+12); - ((mng_dhdrp)*ppChunk)->iBlocky = mng_get_uint32 (pRawdata+16); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_NO_DELTA_PNG -READ_CHUNK (mng_read_prom) -{ - mng_uint8 iColortype; - mng_uint8 iSampledepth; - mng_uint8 iFilltype; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PROM, MNG_LC_START); -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) || (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen != 3) /* gotta be exactly 3 bytes */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - iColortype = *pRawdata; /* check fields for validity */ - iSampledepth = *(pRawdata+1); - iFilltype = *(pRawdata+2); - - if ((iColortype != MNG_COLORTYPE_GRAY ) && - (iColortype != MNG_COLORTYPE_RGB ) && - (iColortype != MNG_COLORTYPE_INDEXED) && - (iColortype != MNG_COLORTYPE_GRAYA ) && - (iColortype != MNG_COLORTYPE_RGBA ) ) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE); - -#ifdef MNG_NO_16BIT_SUPPORT - if (iSampledepth == MNG_BITDEPTH_16 ) - iSampledepth = MNG_BITDEPTH_8; -#endif - - if ((iSampledepth != MNG_BITDEPTH_1 ) && - (iSampledepth != MNG_BITDEPTH_2 ) && - (iSampledepth != MNG_BITDEPTH_4 ) && - (iSampledepth != MNG_BITDEPTH_8 ) -#ifndef MNG_NO_16BIT_SUPPORT - && (iSampledepth != MNG_BITDEPTH_16) -#endif - ) - MNG_ERROR (pData, MNG_INVSAMPLEDEPTH); - - if ((iFilltype != MNG_FILLMETHOD_LEFTBITREPLICATE) && - (iFilltype != MNG_FILLMETHOD_ZEROFILL ) ) - MNG_ERROR (pData, MNG_INVFILLMETHOD); - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode = mng_create_ani_prom (pData, iSampledepth, - iColortype, iFilltype); - -/* if (!iRetcode) - iRetcode = mng_process_display_prom (pData, iSampledepth, - iColortype, iFilltype); */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_promp)*ppChunk)->iColortype = iColortype; - ((mng_promp)*ppChunk)->iSampledepth = iSampledepth; - ((mng_promp)*ppChunk)->iFilltype = iFilltype; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PROM, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_NO_DELTA_PNG -READ_CHUNK (mng_read_ipng) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IPNG, MNG_LC_START); -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) || (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen != 0) /* gotta be empty */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode = mng_create_ani_ipng (pData); - - if (!iRetcode) - iRetcode = mng_process_display_ipng (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IPNG, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_NO_DELTA_PNG -READ_CHUNK (mng_read_pplt) -{ - mng_uint8 iDeltatype; - mng_uint8p pTemp; - mng_uint32 iLen; - mng_uint8 iX, iM; - mng_uint32 iY; - mng_uint32 iMax; - mng_rgbpaltab aIndexentries; - mng_uint8arr aAlphaentries; - mng_uint8arr aUsedentries; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PPLT, MNG_LC_START); -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) && (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen < 1) /* must have at least 1 byte */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - iDeltatype = *pRawdata; - /* valid ? */ - if (iDeltatype > MNG_DELTATYPE_DELTARGBA) - MNG_ERROR (pData, MNG_INVDELTATYPE); - /* must be indexed color ! */ - if (pData->iColortype != MNG_COLORTYPE_INDEXED) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE); - - pTemp = pRawdata + 1; - iLen = iRawlen - 1; - iMax = 0; - - for (iY = 0; iY < 256; iY++) /* reset arrays */ - { - aIndexentries [iY].iRed = 0; - aIndexentries [iY].iGreen = 0; - aIndexentries [iY].iBlue = 0; - aAlphaentries [iY] = 255; - aUsedentries [iY] = 0; - } - - while (iLen) /* as long as there are entries left ... */ - { - mng_uint32 iDiff; - - if (iLen < 2) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - iX = *pTemp; /* get start and end index */ - iM = *(pTemp+1); - - if (iM < iX) - MNG_ERROR (pData, MNG_INVALIDINDEX); - - if ((mng_uint32)iM >= iMax) /* determine highest used index */ - iMax = (mng_uint32)iM + 1; - - pTemp += 2; - iLen -= 2; - iDiff = (iM - iX + 1); - if ((iDeltatype == MNG_DELTATYPE_REPLACERGB ) || - (iDeltatype == MNG_DELTATYPE_DELTARGB ) ) - iDiff = iDiff * 3; - else - if ((iDeltatype == MNG_DELTATYPE_REPLACERGBA) || - (iDeltatype == MNG_DELTATYPE_DELTARGBA ) ) - iDiff = iDiff * 4; - - if (iLen < iDiff) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - if ((iDeltatype == MNG_DELTATYPE_REPLACERGB ) || - (iDeltatype == MNG_DELTATYPE_DELTARGB ) ) - { - for (iY = (mng_uint32)iX; iY <= (mng_uint32)iM; iY++) - { - aIndexentries [iY].iRed = *pTemp; - aIndexentries [iY].iGreen = *(pTemp+1); - aIndexentries [iY].iBlue = *(pTemp+2); - aUsedentries [iY] = 1; - - pTemp += 3; - iLen -= 3; - } - } - else - if ((iDeltatype == MNG_DELTATYPE_REPLACEALPHA) || - (iDeltatype == MNG_DELTATYPE_DELTAALPHA ) ) - { - for (iY = (mng_uint32)iX; iY <= (mng_uint32)iM; iY++) - { - aAlphaentries [iY] = *pTemp; - aUsedentries [iY] = 1; - - pTemp++; - iLen--; - } - } - else - { - for (iY = (mng_uint32)iX; iY <= (mng_uint32)iM; iY++) - { - aIndexentries [iY].iRed = *pTemp; - aIndexentries [iY].iGreen = *(pTemp+1); - aIndexentries [iY].iBlue = *(pTemp+2); - aAlphaentries [iY] = *(pTemp+3); - aUsedentries [iY] = 1; - - pTemp += 4; - iLen -= 4; - } - } - } - - switch (pData->iBitdepth) /* check maximum allowed entries for bitdepth */ - { - case MNG_BITDEPTH_1 : { - if (iMax > 2) - MNG_ERROR (pData, MNG_INVALIDINDEX); - break; - } - case MNG_BITDEPTH_2 : { - if (iMax > 4) - MNG_ERROR (pData, MNG_INVALIDINDEX); - break; - } - case MNG_BITDEPTH_4 : { - if (iMax > 16) - MNG_ERROR (pData, MNG_INVALIDINDEX); - break; - } - } - -#ifdef MNG_SUPPORT_DISPLAY - { /* create animation object */ - mng_retcode iRetcode = mng_create_ani_pplt (pData, iDeltatype, iMax, - aIndexentries, aAlphaentries, - aUsedentries); - -/* if (!iRetcode) - iRetcode = mng_process_display_pplt (pData, iDeltatype, iMax, aIndexentries, - aAlphaentries, aUsedentries); */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_ppltp)*ppChunk)->iDeltatype = iDeltatype; - ((mng_ppltp)*ppChunk)->iCount = iMax; - - for (iY = 0; iY < 256; iY++) - { - ((mng_ppltp)*ppChunk)->aEntries [iY].iRed = aIndexentries [iY].iRed; - ((mng_ppltp)*ppChunk)->aEntries [iY].iGreen = aIndexentries [iY].iGreen; - ((mng_ppltp)*ppChunk)->aEntries [iY].iBlue = aIndexentries [iY].iBlue; - ((mng_ppltp)*ppChunk)->aEntries [iY].iAlpha = aAlphaentries [iY]; - ((mng_ppltp)*ppChunk)->aEntries [iY].bUsed = (mng_bool)(aUsedentries [iY]); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PPLT, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_NO_DELTA_PNG -#ifdef MNG_INCLUDE_JNG -READ_CHUNK (mng_read_ijng) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IJNG, MNG_LC_START); -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) || (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen != 0) /* gotta be empty */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode = mng_create_ani_ijng (pData); - - if (!iRetcode) - iRetcode = mng_process_display_ijng (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IJNG, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_NO_DELTA_PNG -READ_CHUNK (mng_read_drop) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DROP, MNG_LC_START); -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) || (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - /* check length */ - if ((iRawlen < 4) || ((iRawlen % 4) != 0)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_dropp)*ppChunk)->iCount = iRawlen / 4; - - if (iRawlen) - { - mng_uint32 iX; - mng_uint8p pTemp = pRawdata; - mng_uint32p pEntry; - - MNG_ALLOC (pData, pEntry, iRawlen); - - ((mng_dropp)*ppChunk)->pChunknames = (mng_ptr)pEntry; - - for (iX = 0; iX < iRawlen / 4; iX++) - { - *pEntry = mng_get_uint32 (pTemp); - - pTemp += 4; - pEntry++; - } - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DROP, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_DBYK -READ_CHUNK (mng_read_dbyk) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DBYK, MNG_LC_START); -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) || (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen < 6) /* must be at least 6 long */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_dbykp)*ppChunk)->iChunkname = mng_get_uint32 (pRawdata); - ((mng_dbykp)*ppChunk)->iPolarity = *(pRawdata+4); - ((mng_dbykp)*ppChunk)->iKeywordssize = iRawlen - 5; - - if (iRawlen > 5) - { - MNG_ALLOC (pData, ((mng_dbykp)*ppChunk)->zKeywords, iRawlen-4); - MNG_COPY (((mng_dbykp)*ppChunk)->zKeywords, pRawdata+5, iRawlen-5); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DBYK, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_ORDR -READ_CHUNK (mng_read_ordr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ORDR, MNG_LC_START); -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) || (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - /* check length */ - if ((iRawlen < 5) || ((iRawlen % 5) != 0)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_ordrp)*ppChunk)->iCount = iRawlen / 5; - - if (iRawlen) - { - mng_uint32 iX; - mng_ordr_entryp pEntry; - mng_uint8p pTemp = pRawdata; - - MNG_ALLOC (pData, pEntry, iRawlen); - - ((mng_ordrp)*ppChunk)->pEntries = pEntry; - - for (iX = 0; iX < iRawlen / 5; iX++) - { - pEntry->iChunkname = mng_get_uint32 (pTemp); - pEntry->iOrdertype = *(pTemp+4); - - pTemp += 5; - pEntry++; - } - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ORDR, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_MAGN -READ_CHUNK (mng_read_magn) -{ - mng_uint16 iFirstid, iLastid; - mng_uint8 iMethodX, iMethodY; - mng_uint16 iMX, iMY, iML, iMR, iMT, iMB; - mng_bool bFaulty; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MAGN, MNG_LC_START); -#endif - /* sequence checks */ -#ifdef MNG_SUPPORT_JNG - if ((!pData->bHasMHDR) || (pData->bHasIHDR) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) || (pData->bHasIHDR) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - /* check length */ - if (iRawlen > 20) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - /* following is an ugly hack to allow faulty layout caused by previous - versions of libmng and MNGeye, which wrote MAGN with a 16-bit - MethodX/MethodY (as opposed to the proper 8-bit as defined in the spec!) */ - - if ((iRawlen == 6) || (iRawlen == 8) || (iRawlen == 10) || (iRawlen == 12) || - (iRawlen == 14) || (iRawlen == 16) || (iRawlen == 20)) - bFaulty = MNG_TRUE; /* these lengths are all wrong */ - else /* length 18 can be right or wrong !!! */ - if ((iRawlen == 18) && (mng_get_uint16 (pRawdata+4) <= 5) && - (mng_get_uint16 (pRawdata+6) < 256) && - (mng_get_uint16 (pRawdata+8) < 256) && - (mng_get_uint16 (pRawdata+10) < 256) && - (mng_get_uint16 (pRawdata+12) < 256) && - (mng_get_uint16 (pRawdata+14) < 256) && - (mng_get_uint16 (pRawdata+16) < 256)) - bFaulty = MNG_TRUE; /* this is very likely the wrong layout */ - else - bFaulty = MNG_FALSE; /* all other cases are handled as right */ - - if (bFaulty) /* wrong layout ? */ - { - if (iRawlen > 0) /* get the fields */ - iFirstid = mng_get_uint16 (pRawdata); - else - iFirstid = 0; - - if (iRawlen > 2) - iLastid = mng_get_uint16 (pRawdata+2); - else - iLastid = iFirstid; - - if (iRawlen > 4) - iMethodX = (mng_uint8)(mng_get_uint16 (pRawdata+4)); - else - iMethodX = 0; - - if (iRawlen > 6) - iMX = mng_get_uint16 (pRawdata+6); - else - iMX = 1; - - if (iRawlen > 8) - iMY = mng_get_uint16 (pRawdata+8); - else - iMY = iMX; - - if (iRawlen > 10) - iML = mng_get_uint16 (pRawdata+10); - else - iML = iMX; - - if (iRawlen > 12) - iMR = mng_get_uint16 (pRawdata+12); - else - iMR = iMX; - - if (iRawlen > 14) - iMT = mng_get_uint16 (pRawdata+14); - else - iMT = iMY; - - if (iRawlen > 16) - iMB = mng_get_uint16 (pRawdata+16); - else - iMB = iMY; - - if (iRawlen > 18) - iMethodY = (mng_uint8)(mng_get_uint16 (pRawdata+18)); - else - iMethodY = iMethodX; - } - else /* proper layout !!!! */ - { - if (iRawlen > 0) /* get the fields */ - iFirstid = mng_get_uint16 (pRawdata); - else - iFirstid = 0; - - if (iRawlen > 2) - iLastid = mng_get_uint16 (pRawdata+2); - else - iLastid = iFirstid; - - if (iRawlen > 4) - iMethodX = *(pRawdata+4); - else - iMethodX = 0; - - if (iRawlen > 5) - iMX = mng_get_uint16 (pRawdata+5); - else - iMX = 1; - - if (iRawlen > 7) - iMY = mng_get_uint16 (pRawdata+7); - else - iMY = iMX; - - if (iRawlen > 9) - iML = mng_get_uint16 (pRawdata+9); - else - iML = iMX; - - if (iRawlen > 11) - iMR = mng_get_uint16 (pRawdata+11); - else - iMR = iMX; - - if (iRawlen > 13) - iMT = mng_get_uint16 (pRawdata+13); - else - iMT = iMY; - - if (iRawlen > 15) - iMB = mng_get_uint16 (pRawdata+15); - else - iMB = iMY; - - if (iRawlen > 17) - iMethodY = *(pRawdata+17); - else - iMethodY = iMethodX; - } - /* check field validity */ - if ((iMethodX > 5) || (iMethodY > 5)) - MNG_ERROR (pData, MNG_INVALIDMETHOD); - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode; - - iRetcode = mng_create_ani_magn (pData, iFirstid, iLastid, iMethodX, - iMX, iMY, iML, iMR, iMT, iMB, iMethodY); - -/* if (!iRetcode) - iRetcode = mng_process_display_magn (pData, iFirstid, iLastid, iMethodX, - iMX, iMY, iML, iMR, iMT, iMB, iMethodY); */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_magnp)*ppChunk)->iFirstid = iFirstid; - ((mng_magnp)*ppChunk)->iLastid = iLastid; - ((mng_magnp)*ppChunk)->iMethodX = iMethodX; - ((mng_magnp)*ppChunk)->iMX = iMX; - ((mng_magnp)*ppChunk)->iMY = iMY; - ((mng_magnp)*ppChunk)->iML = iML; - ((mng_magnp)*ppChunk)->iMR = iMR; - ((mng_magnp)*ppChunk)->iMT = iMT; - ((mng_magnp)*ppChunk)->iMB = iMB; - ((mng_magnp)*ppChunk)->iMethodY = iMethodY; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MAGN, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_INCLUDE_MPNG_PROPOSAL -READ_CHUNK (mng_read_mpng) -{ - mng_uint32 iFramewidth; - mng_uint32 iFrameheight; - mng_uint16 iTickspersec; - mng_uint32 iFramessize; - mng_uint32 iCompressedsize; -#if defined(MNG_SUPPORT_DISPLAY) || defined(MNG_STORE_CHUNKS) - mng_retcode iRetcode; - mng_uint16 iNumplays; - mng_uint32 iBufsize; - mng_uint8p pBuf = 0; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MPNG, MNG_LC_START); -#endif - /* sequence checks */ - if (!pData->bHasIHDR) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen < 41) /* length must be at least 41 */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - iFramewidth = mng_get_int32 (pRawdata); - if (iFramewidth == 0) /* frame_width must not be zero */ - MNG_ERROR (pData, MNG_INVALIDWIDTH); - - iFrameheight = mng_get_int32 (pRawdata+4); - if (iFrameheight == 0) /* frame_height must not be zero */ - MNG_ERROR (pData, MNG_INVALIDHEIGHT); - - iTickspersec = mng_get_uint16 (pRawdata+10); - if (iTickspersec == 0) /* delay_den must not be zero */ - MNG_ERROR (pData, MNG_INVALIDFIELDVAL); - - if (*(pRawdata+12) != 0) /* only deflate compression-method allowed */ - MNG_ERROR (pData, MNG_INVALIDCOMPRESS); - -#if defined(MNG_SUPPORT_DISPLAY) || defined(MNG_STORE_CHUNKS) - iNumplays = mng_get_uint16 (pRawdata+8); - iCompressedsize = (mng_uint32)(iRawlen - 13); -#endif - -#ifdef MNG_SUPPORT_DISPLAY - { - iRetcode = mng_inflate_buffer (pData, pRawdata+13, iCompressedsize, - &pBuf, &iBufsize, &iFramessize); - if (iRetcode) /* on error bail out */ - { - MNG_FREEX (pData, pBuf, iBufsize); - return iRetcode; - } - - if (iFramessize % 26) - { - MNG_FREEX (pData, pBuf, iBufsize); - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } - - iRetcode = mng_create_mpng_obj (pData, iFramewidth, iFrameheight, iNumplays, - iTickspersec, iFramessize, pBuf); - if (iRetcode) /* on error bail out */ - { - MNG_FREEX (pData, pBuf, iBufsize); - return iRetcode; - } - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_mpngp)*ppChunk)->iFramewidth = iFramewidth; - ((mng_mpngp)*ppChunk)->iFrameheight = iFrameheight; - ((mng_mpngp)*ppChunk)->iNumplays = iNumplays; - ((mng_mpngp)*ppChunk)->iTickspersec = iTickspersec; - ((mng_mpngp)*ppChunk)->iCompressionmethod = *(pRawdata+14); - -#ifndef MNG_SUPPORT_DISPLAY - iRetcode = mng_inflate_buffer (pData, pRawdata+13, iCompressedsize, - &pBuf, &iBufsize, &iFramessize); - if (iRetcode) /* on error bail out */ - { - MNG_FREEX (pData, pBuf, iBufsize); - return iRetcode; - } - - if (iFramessize % 26) - { - MNG_FREEX (pData, pBuf, iBufsize); - MNG_ERROR (pData, MNG_INVALIDLENGTH); - } -#endif - - if (iFramessize) - { - MNG_ALLOCX (pData, ((mng_mpngp)*ppChunk)->pFrames, iFramessize); - if (((mng_mpngp)*ppChunk)->pFrames == 0) - { - MNG_FREEX (pData, pBuf, iBufsize); - MNG_ERROR (pData, MNG_OUTOFMEMORY); - } - - ((mng_mpngp)*ppChunk)->iFramessize = iFramessize; - MNG_COPY (((mng_mpngp)*ppChunk)->pFrames, pBuf, iFramessize); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#if defined(MNG_SUPPORT_DISPLAY) || defined(MNG_STORE_CHUNKS) - MNG_FREEX (pData, pBuf, iBufsize); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MPNG, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifndef MNG_SKIPCHUNK_evNT -READ_CHUNK (mng_read_evnt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_EVNT, MNG_LC_START); -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) || (pData->bHasSAVE)) - MNG_ERROR (pData, MNG_SEQUENCEERROR); - - if (iRawlen < 2) /* must have at least 1 entry ! */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_SUPPORT_DYNAMICMNG) - { - if (iRawlen) /* not empty ? */ - { - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_uint8p pNull; - mng_uint32 iLen; - mng_uint8 iEventtype; - mng_uint8 iMasktype; - mng_int32 iLeft; - mng_int32 iRight; - mng_int32 iTop; - mng_int32 iBottom; - mng_uint16 iObjectid; - mng_uint8 iIndex; - mng_uint32 iNamesize; - - pTemp = pRawdata; - iLen = iRawlen; - - while (iLen) /* anything left ? */ - { - iEventtype = *pTemp; /* eventtype */ - if (iEventtype > 5) - MNG_ERROR (pData, MNG_INVALIDEVENT); - - pTemp++; - - iMasktype = *pTemp; /* masktype */ - if (iMasktype > 5) - MNG_ERROR (pData, MNG_INVALIDMASK); - - pTemp++; - iLen -= 2; - - iLeft = 0; - iRight = 0; - iTop = 0; - iBottom = 0; - iObjectid = 0; - iIndex = 0; - - switch (iMasktype) - { - case 1 : - { - if (iLen > 16) - { - iLeft = mng_get_int32 (pTemp); - iRight = mng_get_int32 (pTemp+4); - iTop = mng_get_int32 (pTemp+8); - iBottom = mng_get_int32 (pTemp+12); - pTemp += 16; - iLen -= 16; - } - else - MNG_ERROR (pData, MNG_INVALIDLENGTH); - break; - } - case 2 : - { - if (iLen > 2) - { - iObjectid = mng_get_uint16 (pTemp); - pTemp += 2; - iLen -= 2; - } - else - MNG_ERROR (pData, MNG_INVALIDLENGTH); - break; - } - case 3 : - { - if (iLen > 3) - { - iObjectid = mng_get_uint16 (pTemp); - iIndex = *(pTemp+2); - pTemp += 3; - iLen -= 3; - } - else - MNG_ERROR (pData, MNG_INVALIDLENGTH); - break; - } - case 4 : - { - if (iLen > 18) - { - iLeft = mng_get_int32 (pTemp); - iRight = mng_get_int32 (pTemp+4); - iTop = mng_get_int32 (pTemp+8); - iBottom = mng_get_int32 (pTemp+12); - iObjectid = mng_get_uint16 (pTemp+16); - pTemp += 18; - iLen -= 18; - } - else - MNG_ERROR (pData, MNG_INVALIDLENGTH); - break; - } - case 5 : - { - if (iLen > 19) - { - iLeft = mng_get_int32 (pTemp); - iRight = mng_get_int32 (pTemp+4); - iTop = mng_get_int32 (pTemp+8); - iBottom = mng_get_int32 (pTemp+12); - iObjectid = mng_get_uint16 (pTemp+16); - iIndex = *(pTemp+18); - pTemp += 19; - iLen -= 19; - } - else - MNG_ERROR (pData, MNG_INVALIDLENGTH); - break; - } - } - - pNull = find_null (pTemp); /* get the name length */ - - if ((pNull - pTemp) > (mng_int32)iLen) - { - iNamesize = iLen; /* no null found; so end of evNT */ - iLen = 0; - } - else - { - iNamesize = pNull - pTemp; /* should be another entry */ - iLen = iLen - iNamesize - 1; - - if (!iLen) /* must not end with a null ! */ - MNG_ERROR (pData, MNG_ENDWITHNULL); - } - - iRetcode = mng_create_event (pData, iEventtype, iMasktype, iLeft, iRight, - iTop, iBottom, iObjectid, iIndex, - iNamesize, (mng_pchar)pTemp); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - pTemp = pTemp + iNamesize + 1; - } - } - } -#endif /* MNG_SUPPORT_DISPLAY && MNG_SUPPORT_DYNAMICMNG */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (iRawlen) /* not empty ? */ - { - mng_uint32 iX; - mng_uint32 iCount = 0; - mng_uint8p pTemp; - mng_uint8p pNull; - mng_uint32 iLen; - mng_uint8 iEventtype; - mng_uint8 iMasktype; - mng_int32 iLeft; - mng_int32 iRight; - mng_int32 iTop; - mng_int32 iBottom; - mng_uint16 iObjectid; - mng_uint8 iIndex; - mng_uint32 iNamesize; - mng_evnt_entryp pEntry = MNG_NULL; - - for (iX = 0; iX < 2; iX++) /* do this twice to get the count first ! */ - { - pTemp = pRawdata; - iLen = iRawlen; - - if (iX) /* second run ? */ - { - MNG_ALLOC (pData, pEntry, (iCount * sizeof (mng_evnt_entry))); - - ((mng_evntp)*ppChunk)->iCount = iCount; - ((mng_evntp)*ppChunk)->pEntries = pEntry; - } - - while (iLen) /* anything left ? */ - { - iEventtype = *pTemp; /* eventtype */ - if (iEventtype > 5) - MNG_ERROR (pData, MNG_INVALIDEVENT); - - pTemp++; - - iMasktype = *pTemp; /* masktype */ - if (iMasktype > 5) - MNG_ERROR (pData, MNG_INVALIDMASK); - - pTemp++; - iLen -= 2; - - iLeft = 0; - iRight = 0; - iTop = 0; - iBottom = 0; - iObjectid = 0; - iIndex = 0; - - switch (iMasktype) - { - case 1 : - { - if (iLen > 16) - { - iLeft = mng_get_int32 (pTemp); - iRight = mng_get_int32 (pTemp+4); - iTop = mng_get_int32 (pTemp+8); - iBottom = mng_get_int32 (pTemp+12); - pTemp += 16; - iLen -= 16; - } - else - MNG_ERROR (pData, MNG_INVALIDLENGTH); - break; - } - case 2 : - { - if (iLen > 2) - { - iObjectid = mng_get_uint16 (pTemp); - pTemp += 2; - iLen -= 2; - } - else - MNG_ERROR (pData, MNG_INVALIDLENGTH); - break; - } - case 3 : - { - if (iLen > 3) - { - iObjectid = mng_get_uint16 (pTemp); - iIndex = *(pTemp+2); - pTemp += 3; - iLen -= 3; - } - else - MNG_ERROR (pData, MNG_INVALIDLENGTH); - break; - } - case 4 : - { - if (iLen > 18) - { - iLeft = mng_get_int32 (pTemp); - iRight = mng_get_int32 (pTemp+4); - iTop = mng_get_int32 (pTemp+8); - iBottom = mng_get_int32 (pTemp+12); - iObjectid = mng_get_uint16 (pTemp+16); - pTemp += 18; - iLen -= 18; - } - else - MNG_ERROR (pData, MNG_INVALIDLENGTH); - break; - } - case 5 : - { - if (iLen > 19) - { - iLeft = mng_get_int32 (pTemp); - iRight = mng_get_int32 (pTemp+4); - iTop = mng_get_int32 (pTemp+8); - iBottom = mng_get_int32 (pTemp+12); - iObjectid = mng_get_uint16 (pTemp+16); - iIndex = *(pTemp+18); - pTemp += 19; - iLen -= 19; - } - else - MNG_ERROR (pData, MNG_INVALIDLENGTH); - break; - } - } - - pNull = find_null (pTemp); /* get the name length */ - - if ((pNull - pTemp) > (mng_int32)iLen) - { - iNamesize = iLen; /* no null found; so end of evNT */ - iLen = 0; - } - else - { - iNamesize = pNull - pTemp; /* should be another entry */ - iLen = iLen - iNamesize - 1; - - if (!iLen) /* must not end with a null ! */ - MNG_ERROR (pData, MNG_ENDWITHNULL); - } - - if (!iX) - { - iCount++; - } - else - { - pEntry->iEventtype = iEventtype; - pEntry->iMasktype = iMasktype; - pEntry->iLeft = iLeft; - pEntry->iRight = iRight; - pEntry->iTop = iTop; - pEntry->iBottom = iBottom; - pEntry->iObjectid = iObjectid; - pEntry->iIndex = iIndex; - pEntry->iSegmentnamesize = iNamesize; - - if (iNamesize) - { - MNG_ALLOC (pData, pEntry->zSegmentname, iNamesize+1); - MNG_COPY (pEntry->zSegmentname, pTemp, iNamesize); - } - - pEntry++; - } - - pTemp = pTemp + iNamesize + 1; - } - } - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_EVNT, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -READ_CHUNK (mng_read_unknown) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_UNKNOWN, MNG_LC_START); -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR); - /* critical chunk ? */ - if ((((mng_uint32)pData->iChunkname & 0x20000000) == 0) -#ifdef MNG_SKIPCHUNK_SAVE - && (pData->iChunkname != MNG_UINT_SAVE) -#endif -#ifdef MNG_SKIPCHUNK_SEEK - && (pData->iChunkname != MNG_UINT_SEEK) -#endif -#ifdef MNG_SKIPCHUNK_DBYK - && (pData->iChunkname != MNG_UINT_DBYK) -#endif -#ifdef MNG_SKIPCHUNK_ORDR - && (pData->iChunkname != MNG_UINT_ORDR) -#endif - ) - MNG_ERROR (pData, MNG_UNKNOWNCRITICAL); - - if (pData->fProcessunknown) /* let the app handle it ? */ - { - mng_bool bOke = pData->fProcessunknown ((mng_handle)pData, pData->iChunkname, - iRawlen, (mng_ptr)pRawdata); - - if (!bOke) - MNG_ERROR (pData, MNG_APPMISCERROR); - } - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the length */ - ((mng_chunk_headerp)*ppChunk)->iChunkname = pData->iChunkname; - ((mng_unknown_chunkp)*ppChunk)->iDatasize = iRawlen; - - if (iRawlen == 0) /* any data at all ? */ - ((mng_unknown_chunkp)*ppChunk)->pData = 0; - else - { /* then store it */ - MNG_ALLOC (pData, ((mng_unknown_chunkp)*ppChunk)->pData, iRawlen); - MNG_COPY (((mng_unknown_chunkp)*ppChunk)->pData, pRawdata, iRawlen); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_UNKNOWN, MNG_LC_END); -#endif - - return MNG_NOERROR; /* done */ -} -#endif - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_READ_PROCS */ - -/* ************************************************************************** */ -/* * * */ -/* * chunk write functions * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_WRITE_PROCS - -/* ************************************************************************** */ - -WRITE_CHUNK (mng_write_ihdr) -{ - mng_ihdrp pIHDR; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IHDR, MNG_LC_START); -#endif - - pIHDR = (mng_ihdrp)pChunk; /* address the proper chunk */ - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 13; - /* fill the output buffer */ - mng_put_uint32 (pRawdata, pIHDR->iWidth); - mng_put_uint32 (pRawdata+4, pIHDR->iHeight); - - *(pRawdata+8) = pIHDR->iBitdepth; - *(pRawdata+9) = pIHDR->iColortype; - *(pRawdata+10) = pIHDR->iCompression; - *(pRawdata+11) = pIHDR->iFilter; - *(pRawdata+12) = pIHDR->iInterlace; - /* and write it */ - iRetcode = write_raw_chunk (pData, pIHDR->sHeader.iChunkname, iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IHDR, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (mng_write_plte) -{ - mng_pltep pPLTE; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PLTE, MNG_LC_START); -#endif - - pPLTE = (mng_pltep)pChunk; /* address the proper chunk */ - - if (pPLTE->bEmpty) /* write empty chunk ? */ - iRetcode = write_raw_chunk (pData, pPLTE->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pPLTE->iEntrycount * 3; - /* fill the output buffer */ - pTemp = pRawdata; - - for (iX = 0; iX < pPLTE->iEntrycount; iX++) - { - *pTemp = pPLTE->aEntries [iX].iRed; - *(pTemp+1) = pPLTE->aEntries [iX].iGreen; - *(pTemp+2) = pPLTE->aEntries [iX].iBlue; - - pTemp += 3; - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pPLTE->sHeader.iChunkname, iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PLTE, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (mng_write_idat) -{ - mng_idatp pIDAT; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IDAT, MNG_LC_START); -#endif - - pIDAT = (mng_idatp)pChunk; /* address the proper chunk */ - - if (pIDAT->bEmpty) /* and write it */ - iRetcode = write_raw_chunk (pData, pIDAT->sHeader.iChunkname, 0, 0); - else - iRetcode = write_raw_chunk (pData, pIDAT->sHeader.iChunkname, - pIDAT->iDatasize, pIDAT->pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IDAT, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (mng_write_iend) -{ - mng_iendp pIEND; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IEND, MNG_LC_START); -#endif - - pIEND = (mng_iendp)pChunk; /* address the proper chunk */ - /* and write it */ - iRetcode = write_raw_chunk (pData, pIEND->sHeader.iChunkname, 0, 0); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IEND, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (mng_write_trns) -{ - mng_trnsp pTRNS; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_TRNS, MNG_LC_START); -#endif - - pTRNS = (mng_trnsp)pChunk; /* address the proper chunk */ - - if (pTRNS->bEmpty) /* write empty chunk ? */ - iRetcode = write_raw_chunk (pData, pTRNS->sHeader.iChunkname, 0, 0); - else - if (pTRNS->bGlobal) /* write global chunk ? */ - iRetcode = write_raw_chunk (pData, pTRNS->sHeader.iChunkname, - pTRNS->iRawlen, (mng_uint8p)pTRNS->aRawdata); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer */ - iRawlen = 0; /* and default size */ - - switch (pTRNS->iType) - { - case 0: { - iRawlen = 2; /* fill the size & output buffer */ - mng_put_uint16 (pRawdata, pTRNS->iGray); - - break; - } - case 2: { - iRawlen = 6; /* fill the size & output buffer */ - mng_put_uint16 (pRawdata, pTRNS->iRed); - mng_put_uint16 (pRawdata+2, pTRNS->iGreen); - mng_put_uint16 (pRawdata+4, pTRNS->iBlue); - - break; - } - case 3: { /* init output buffer size */ - iRawlen = pTRNS->iCount; - - pTemp = pRawdata; /* fill the output buffer */ - - for (iX = 0; iX < pTRNS->iCount; iX++) - { - *pTemp = pTRNS->aEntries[iX]; - pTemp++; - } - - break; - } - } - /* write the chunk */ - iRetcode = write_raw_chunk (pData, pTRNS->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_TRNS, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (mng_write_gama) -{ - mng_gamap pGAMA; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_GAMA, MNG_LC_START); -#endif - - pGAMA = (mng_gamap)pChunk; /* address the proper chunk */ - - if (pGAMA->bEmpty) /* write empty ? */ - iRetcode = write_raw_chunk (pData, pGAMA->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 4; - /* fill the buffer */ - mng_put_uint32 (pRawdata, pGAMA->iGamma); - /* and write it */ - iRetcode = write_raw_chunk (pData, pGAMA->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_GAMA, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_cHRM -WRITE_CHUNK (mng_write_chrm) -{ - mng_chrmp pCHRM; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_CHRM, MNG_LC_START); -#endif - - pCHRM = (mng_chrmp)pChunk; /* address the proper chunk */ - - if (pCHRM->bEmpty) /* write empty ? */ - iRetcode = write_raw_chunk (pData, pCHRM->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 32; - /* fill the buffer */ - mng_put_uint32 (pRawdata, pCHRM->iWhitepointx); - mng_put_uint32 (pRawdata+4, pCHRM->iWhitepointy); - mng_put_uint32 (pRawdata+8, pCHRM->iRedx); - mng_put_uint32 (pRawdata+12, pCHRM->iRedy); - mng_put_uint32 (pRawdata+16, pCHRM->iGreenx); - mng_put_uint32 (pRawdata+20, pCHRM->iGreeny); - mng_put_uint32 (pRawdata+24, pCHRM->iBluex); - mng_put_uint32 (pRawdata+28, pCHRM->iBluey); - /* and write it */ - iRetcode = write_raw_chunk (pData, pCHRM->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_CHRM, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -WRITE_CHUNK (mng_write_srgb) -{ - mng_srgbp pSRGB; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SRGB, MNG_LC_START); -#endif - - pSRGB = (mng_srgbp)pChunk; /* address the proper chunk */ - - if (pSRGB->bEmpty) /* write empty ? */ - iRetcode = write_raw_chunk (pData, pSRGB->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 1; - /* fill the buffer */ - *pRawdata = pSRGB->iRenderingintent; - /* and write it */ - iRetcode = write_raw_chunk (pData, pSRGB->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SRGB, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_iCCP -WRITE_CHUNK (mng_write_iccp) -{ - mng_iccpp pICCP; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_uint8p pBuf = 0; - mng_uint32 iBuflen; - mng_uint32 iReallen; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ICCP, MNG_LC_START); -#endif - - pICCP = (mng_iccpp)pChunk; /* address the proper chunk */ - - if (pICCP->bEmpty) /* write empty ? */ - iRetcode = write_raw_chunk (pData, pICCP->sHeader.iChunkname, 0, 0); - else - { /* compress the profile */ - iRetcode = deflate_buffer (pData, pICCP->pProfile, pICCP->iProfilesize, - &pBuf, &iBuflen, &iReallen); - - if (!iRetcode) /* still oke ? */ - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pICCP->iNamesize + 2 + iReallen; - /* requires large buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_ALLOC (pData, pRawdata, iRawlen); - - pTemp = pRawdata; /* fill the buffer */ - - if (pICCP->iNamesize) - { - MNG_COPY (pTemp, pICCP->zName, pICCP->iNamesize); - pTemp += pICCP->iNamesize; - } - - *pTemp = 0; - *(pTemp+1) = pICCP->iCompression; - pTemp += 2; - - if (iReallen) - MNG_COPY (pTemp, pBuf, iReallen); - /* and write it */ - iRetcode = write_raw_chunk (pData, pICCP->sHeader.iChunkname, - iRawlen, pRawdata); - /* drop the temp buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_FREEX (pData, pRawdata, iRawlen); - - } - - MNG_FREEX (pData, pBuf, iBuflen); /* always drop the extra buffer */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ICCP, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_tEXt -WRITE_CHUNK (mng_write_text) -{ - mng_textp pTEXT; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_TEXT, MNG_LC_START); -#endif - - pTEXT = (mng_textp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pTEXT->iKeywordsize + 1 + pTEXT->iTextsize; - /* requires large buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_ALLOC (pData, pRawdata, iRawlen); - - pTemp = pRawdata; /* fill the buffer */ - - if (pTEXT->iKeywordsize) - { - MNG_COPY (pTemp, pTEXT->zKeyword, pTEXT->iKeywordsize); - pTemp += pTEXT->iKeywordsize; - } - - *pTemp = 0; - pTemp += 1; - - if (pTEXT->iTextsize) - MNG_COPY (pTemp, pTEXT->zText, pTEXT->iTextsize); - /* and write it */ - iRetcode = write_raw_chunk (pData, pTEXT->sHeader.iChunkname, - iRawlen, pRawdata); - - if (iRawlen > pData->iWritebufsize) /* drop the temp buffer ? */ - MNG_FREEX (pData, pRawdata, iRawlen); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_TEXT, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_zTXt -WRITE_CHUNK (mng_write_ztxt) -{ - mng_ztxtp pZTXT; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_uint8p pBuf = 0; - mng_uint32 iBuflen; - mng_uint32 iReallen; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ZTXT, MNG_LC_START); -#endif - - pZTXT = (mng_ztxtp)pChunk; /* address the proper chunk */ - /* compress the text */ - iRetcode = deflate_buffer (pData, (mng_uint8p)pZTXT->zText, pZTXT->iTextsize, - &pBuf, &iBuflen, &iReallen); - - if (!iRetcode) /* all ok ? */ - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pZTXT->iKeywordsize + 2 + iReallen; - /* requires large buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_ALLOC (pData, pRawdata, iRawlen); - - pTemp = pRawdata; /* fill the buffer */ - - if (pZTXT->iKeywordsize) - { - MNG_COPY (pTemp, pZTXT->zKeyword, pZTXT->iKeywordsize); - pTemp += pZTXT->iKeywordsize; - } - - *pTemp = 0; /* terminator zero */ - pTemp++; - *pTemp = 0; /* compression type */ - pTemp++; - - if (iReallen) - MNG_COPY (pTemp, pBuf, iReallen); - /* and write it */ - iRetcode = write_raw_chunk (pData, pZTXT->sHeader.iChunkname, - iRawlen, pRawdata); - /* drop the temp buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_FREEX (pData, pRawdata, iRawlen); - - } - - MNG_FREEX (pData, pBuf, iBuflen); /* always drop the compression buffer */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ZTXT, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_iTXt -WRITE_CHUNK (mng_write_itxt) -{ - mng_itxtp pITXT; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_uint8p pBuf = 0; - mng_uint32 iBuflen; - mng_uint32 iReallen; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ITXT, MNG_LC_START); -#endif - - pITXT = (mng_itxtp)pChunk; /* address the proper chunk */ - - if (pITXT->iCompressionflag) /* compress the text */ - iRetcode = deflate_buffer (pData, (mng_uint8p)pITXT->zText, pITXT->iTextsize, - &pBuf, &iBuflen, &iReallen); - else - iRetcode = MNG_NOERROR; - - if (!iRetcode) /* all ok ? */ - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pITXT->iKeywordsize + pITXT->iLanguagesize + - pITXT->iTranslationsize + 5; - - if (pITXT->iCompressionflag) - iRawlen = iRawlen + iReallen; - else - iRawlen = iRawlen + pITXT->iTextsize; - /* requires large buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_ALLOC (pData, pRawdata, iRawlen); - - pTemp = pRawdata; /* fill the buffer */ - - if (pITXT->iKeywordsize) - { - MNG_COPY (pTemp, pITXT->zKeyword, pITXT->iKeywordsize); - pTemp += pITXT->iKeywordsize; - } - - *pTemp = 0; - pTemp++; - *pTemp = pITXT->iCompressionflag; - pTemp++; - *pTemp = pITXT->iCompressionmethod; - pTemp++; - - if (pITXT->iLanguagesize) - { - MNG_COPY (pTemp, pITXT->zLanguage, pITXT->iLanguagesize); - pTemp += pITXT->iLanguagesize; - } - - *pTemp = 0; - pTemp++; - - if (pITXT->iTranslationsize) - { - MNG_COPY (pTemp, pITXT->zTranslation, pITXT->iTranslationsize); - pTemp += pITXT->iTranslationsize; - } - - *pTemp = 0; - pTemp++; - - if (pITXT->iCompressionflag) - { - if (iReallen) - MNG_COPY (pTemp, pBuf, iReallen); - } - else - { - if (pITXT->iTextsize) - MNG_COPY (pTemp, pITXT->zText, pITXT->iTextsize); - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pITXT->sHeader.iChunkname, - iRawlen, pRawdata); - /* drop the temp buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_FREEX (pData, pRawdata, iRawlen); - - } - - MNG_FREEX (pData, pBuf, iBuflen); /* always drop the compression buffer */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ITXT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_bKGD -WRITE_CHUNK (mng_write_bkgd) -{ - mng_bkgdp pBKGD; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_BKGD, MNG_LC_START); -#endif - - pBKGD = (mng_bkgdp)pChunk; /* address the proper chunk */ - - if (pBKGD->bEmpty) /* write empty ? */ - iRetcode = write_raw_chunk (pData, pBKGD->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 0; /* and default size */ - - switch (pBKGD->iType) - { - case 0: { /* gray */ - iRawlen = 2; /* fill the size & output buffer */ - mng_put_uint16 (pRawdata, pBKGD->iGray); - - break; - } - case 2: { /* rgb */ - iRawlen = 6; /* fill the size & output buffer */ - mng_put_uint16 (pRawdata, pBKGD->iRed); - mng_put_uint16 (pRawdata+2, pBKGD->iGreen); - mng_put_uint16 (pRawdata+4, pBKGD->iBlue); - - break; - } - case 3: { /* indexed */ - iRawlen = 1; /* fill the size & output buffer */ - *pRawdata = pBKGD->iIndex; - - break; - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pBKGD->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_BKGD, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_pHYs -WRITE_CHUNK (mng_write_phys) -{ - mng_physp pPHYS; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PHYS, MNG_LC_START); -#endif - - pPHYS = (mng_physp)pChunk; /* address the proper chunk */ - - if (pPHYS->bEmpty) /* write empty ? */ - iRetcode = write_raw_chunk (pData, pPHYS->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 9; - /* fill the output buffer */ - mng_put_uint32 (pRawdata, pPHYS->iSizex); - mng_put_uint32 (pRawdata+4, pPHYS->iSizey); - - *(pRawdata+8) = pPHYS->iUnit; - /* and write it */ - iRetcode = write_raw_chunk (pData, pPHYS->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PHYS, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_sBIT -WRITE_CHUNK (mng_write_sbit) -{ - mng_sbitp pSBIT; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SBIT, MNG_LC_START); -#endif - - pSBIT = (mng_sbitp)pChunk; /* address the proper chunk */ - - if (pSBIT->bEmpty) /* write empty ? */ - iRetcode = write_raw_chunk (pData, pSBIT->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 0; /* and default size */ - - switch (pSBIT->iType) - { - case 0: { /* gray */ - iRawlen = 1; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - - break; - } - case 2: { /* rgb */ - iRawlen = 3; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - *(pRawdata+1) = pSBIT->aBits[1]; - *(pRawdata+2) = pSBIT->aBits[2]; - - break; - } - case 3: { /* indexed */ - iRawlen = 3; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - *pRawdata = pSBIT->aBits[1]; - *pRawdata = pSBIT->aBits[2]; - - break; - } - case 4: { /* gray + alpha */ - iRawlen = 2; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - *(pRawdata+1) = pSBIT->aBits[1]; - - break; - } - case 6: { /* rgb + alpha */ - iRawlen = 4; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - *(pRawdata+1) = pSBIT->aBits[1]; - *(pRawdata+2) = pSBIT->aBits[2]; - *(pRawdata+3) = pSBIT->aBits[3]; - - break; - } - case 10: { /* jpeg gray */ - iRawlen = 1; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - - break; - } - case 12: { /* jpeg rgb */ - iRawlen = 3; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - *(pRawdata+1) = pSBIT->aBits[1]; - *(pRawdata+2) = pSBIT->aBits[2]; - - break; - } - case 14: { /* jpeg gray + alpha */ - iRawlen = 2; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - *(pRawdata+1) = pSBIT->aBits[1]; - - break; - } - case 16: { /* jpeg rgb + alpha */ - iRawlen = 4; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - *(pRawdata+1) = pSBIT->aBits[1]; - *(pRawdata+2) = pSBIT->aBits[2]; - *(pRawdata+3) = pSBIT->aBits[3]; - - break; - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pSBIT->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SBIT, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_sPLT -WRITE_CHUNK (mng_write_splt) -{ - mng_spltp pSPLT; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint32 iEntrieslen; - mng_uint8p pTemp; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SPLT, MNG_LC_START); -#endif - - pSPLT = (mng_spltp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iEntrieslen = ((pSPLT->iSampledepth >> 3) * 4 + 2) * pSPLT->iEntrycount; - iRawlen = pSPLT->iNamesize + 2 + iEntrieslen; - /* requires large buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_ALLOC (pData, pRawdata, iRawlen); - - pTemp = pRawdata; /* fill the buffer */ - - if (pSPLT->iNamesize) - { - MNG_COPY (pTemp, pSPLT->zName, pSPLT->iNamesize); - pTemp += pSPLT->iNamesize; - } - - *pTemp = 0; - *(pTemp+1) = pSPLT->iSampledepth; - pTemp += 2; - - if (pSPLT->iEntrycount) - MNG_COPY (pTemp, pSPLT->pEntries, iEntrieslen); - /* and write it */ - iRetcode = write_raw_chunk (pData, pSPLT->sHeader.iChunkname, - iRawlen, pRawdata); - - if (iRawlen > pData->iWritebufsize) /* drop the temp buffer ? */ - MNG_FREEX (pData, pRawdata, iRawlen); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SPLT, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_hIST -WRITE_CHUNK (mng_write_hist) -{ - mng_histp pHIST; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_HIST, MNG_LC_START); -#endif - - pHIST = (mng_histp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pHIST->iEntrycount << 1; - - pTemp = pRawdata; /* fill the output buffer */ - - for (iX = 0; iX < pHIST->iEntrycount; iX++) - { - mng_put_uint16 (pTemp, pHIST->aEntries [iX]); - pTemp += 2; - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pHIST->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_HIST, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_tIME -WRITE_CHUNK (mng_write_time) -{ - mng_timep pTIME; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_TIME, MNG_LC_START); -#endif - - pTIME = (mng_timep)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 7; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pTIME->iYear); - - *(pRawdata+2) = pTIME->iMonth; - *(pRawdata+3) = pTIME->iDay; - *(pRawdata+4) = pTIME->iHour; - *(pRawdata+5) = pTIME->iMinute; - *(pRawdata+6) = pTIME->iSecond; - /* and write it */ - iRetcode = write_raw_chunk (pData, pTIME->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_TIME, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -WRITE_CHUNK (mng_write_mhdr) -{ - mng_mhdrp pMHDR; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MHDR, MNG_LC_START); -#endif - - pMHDR = (mng_mhdrp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 28; - /* fill the output buffer */ - mng_put_uint32 (pRawdata, pMHDR->iWidth); - mng_put_uint32 (pRawdata+4, pMHDR->iHeight); - mng_put_uint32 (pRawdata+8, pMHDR->iTicks); - mng_put_uint32 (pRawdata+12, pMHDR->iLayercount); - mng_put_uint32 (pRawdata+16, pMHDR->iFramecount); - mng_put_uint32 (pRawdata+20, pMHDR->iPlaytime); - mng_put_uint32 (pRawdata+24, pMHDR->iSimplicity); - - /* and write it */ - iRetcode = write_raw_chunk (pData, pMHDR->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MHDR, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (mng_write_mend) -{ - mng_mendp pMEND; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MEND, MNG_LC_START); -#endif - - pMEND = (mng_mendp)pChunk; /* address the proper chunk */ - /* and write it */ - iRetcode = write_raw_chunk (pData, pMEND->sHeader.iChunkname, 0, 0); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MEND, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (mng_write_loop) -{ - mng_loopp pLOOP; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; -#ifndef MNG_NO_LOOP_SIGNALS_SUPPORTED - mng_uint8p pTemp1; - mng_uint32p pTemp2; - mng_uint32 iX; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_LOOP, MNG_LC_START); -#endif - - pLOOP = (mng_loopp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 5; - /* fill the output buffer */ - *pRawdata = pLOOP->iLevel; - mng_put_uint32 (pRawdata+1, pLOOP->iRepeat); - - if (pLOOP->iTermination) - { - iRawlen++; - *(pRawdata+5) = pLOOP->iTermination; - - if ((pLOOP->iCount) || - (pLOOP->iItermin != 1) || (pLOOP->iItermax != 0x7FFFFFFFL)) - { - iRawlen += 8; - - mng_put_uint32 (pRawdata+6, pLOOP->iItermin); - mng_put_uint32 (pRawdata+10, pLOOP->iItermax); - -#ifndef MNG_NO_LOOP_SIGNALS_SUPPORTED - if (pLOOP->iCount) - { - iRawlen += pLOOP->iCount * 4; - - pTemp1 = pRawdata+14; - pTemp2 = pLOOP->pSignals; - - for (iX = 0; iX < pLOOP->iCount; iX++) - { - mng_put_uint32 (pTemp1, *pTemp2); - - pTemp1 += 4; - pTemp2++; - } - } -#endif - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pLOOP->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_LOOP, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (mng_write_endl) -{ - mng_endlp pENDL; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ENDL, MNG_LC_START); -#endif - - pENDL = (mng_endlp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 1; - - *pRawdata = pENDL->iLevel; /* fill the output buffer */ - /* and write it */ - iRetcode = write_raw_chunk (pData, pENDL->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ENDL, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (mng_write_defi) -{ - mng_defip pDEFI; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DEFI, MNG_LC_START); -#endif - - pDEFI = (mng_defip)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 2; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pDEFI->iObjectid); - - if ((pDEFI->iDonotshow) || (pDEFI->iConcrete) || (pDEFI->bHasloca) || (pDEFI->bHasclip)) - { - iRawlen++; - *(pRawdata+2) = pDEFI->iDonotshow; - - if ((pDEFI->iConcrete) || (pDEFI->bHasloca) || (pDEFI->bHasclip)) - { - iRawlen++; - *(pRawdata+3) = pDEFI->iConcrete; - - if ((pDEFI->bHasloca) || (pDEFI->bHasclip)) - { - iRawlen += 8; - - mng_put_uint32 (pRawdata+4, pDEFI->iXlocation); - mng_put_uint32 (pRawdata+8, pDEFI->iYlocation); - - if (pDEFI->bHasclip) - { - iRawlen += 16; - - mng_put_uint32 (pRawdata+12, pDEFI->iLeftcb); - mng_put_uint32 (pRawdata+16, pDEFI->iRightcb); - mng_put_uint32 (pRawdata+20, pDEFI->iTopcb); - mng_put_uint32 (pRawdata+24, pDEFI->iBottomcb); - } - } - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pDEFI->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DEFI, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (mng_write_basi) -{ - mng_basip pBASI; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_bool bOpaque; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_BASI, MNG_LC_START); -#endif - - pBASI = (mng_basip)pChunk; /* address the proper chunk */ - -#ifndef MNG_NO_16BIT_SUPPORT - if (pBASI->iBitdepth <= 8) /* determine opacity alpha-field */ -#endif - bOpaque = (mng_bool)(pBASI->iAlpha == 0xFF); -#ifndef MNG_NO_16BIT_SUPPORT - else - bOpaque = (mng_bool)(pBASI->iAlpha == 0xFFFF); -#endif - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 13; - /* fill the output buffer */ - mng_put_uint32 (pRawdata, pBASI->iWidth); - mng_put_uint32 (pRawdata+4, pBASI->iHeight); - - *(pRawdata+8) = pBASI->iBitdepth; - *(pRawdata+9) = pBASI->iColortype; - *(pRawdata+10) = pBASI->iCompression; - *(pRawdata+11) = pBASI->iFilter; - *(pRawdata+12) = pBASI->iInterlace; - - if ((pBASI->iRed) || (pBASI->iGreen) || (pBASI->iBlue) || - (!bOpaque) || (pBASI->iViewable)) - { - iRawlen += 6; - mng_put_uint16 (pRawdata+13, pBASI->iRed); - mng_put_uint16 (pRawdata+15, pBASI->iGreen); - mng_put_uint16 (pRawdata+17, pBASI->iBlue); - - if ((!bOpaque) || (pBASI->iViewable)) - { - iRawlen += 2; - mng_put_uint16 (pRawdata+19, pBASI->iAlpha); - - if (pBASI->iViewable) - { - iRawlen++; - *(pRawdata+21) = pBASI->iViewable; - } - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pBASI->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_BASI, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (mng_write_clon) -{ - mng_clonp pCLON; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_CLON, MNG_LC_START); -#endif - - pCLON = (mng_clonp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 4; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pCLON->iSourceid); - mng_put_uint16 (pRawdata+2, pCLON->iCloneid); - - if ((pCLON->iClonetype) || (pCLON->iDonotshow) || (pCLON->iConcrete) || (pCLON->bHasloca)) - { - iRawlen++; - *(pRawdata+4) = pCLON->iClonetype; - - if ((pCLON->iDonotshow) || (pCLON->iConcrete) || (pCLON->bHasloca)) - { - iRawlen++; - *(pRawdata+5) = pCLON->iDonotshow; - - if ((pCLON->iConcrete) || (pCLON->bHasloca)) - { - iRawlen++; - *(pRawdata+6) = pCLON->iConcrete; - - if (pCLON->bHasloca) - { - iRawlen += 9; - *(pRawdata+7) = pCLON->iLocationtype; - mng_put_int32 (pRawdata+8, pCLON->iLocationx); - mng_put_int32 (pRawdata+12, pCLON->iLocationy); - } - } - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pCLON->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_CLON, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_PAST -WRITE_CHUNK (mng_write_past) -{ - mng_pastp pPAST; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_past_sourcep pSource; - mng_uint32 iX; - mng_uint8p pTemp; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PAST, MNG_LC_START); -#endif - - pPAST = (mng_pastp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 11 + (30 * pPAST->iCount); - /* requires large buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_ALLOC (pData, pRawdata, iRawlen); - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pPAST->iDestid); - - *(pRawdata+2) = pPAST->iTargettype; - - mng_put_int32 (pRawdata+3, pPAST->iTargetx); - mng_put_int32 (pRawdata+7, pPAST->iTargety); - - pTemp = pRawdata+11; - pSource = pPAST->pSources; - - for (iX = 0; iX < pPAST->iCount; iX++) - { - mng_put_uint16 (pTemp, pSource->iSourceid); - - *(pTemp+2) = pSource->iComposition; - *(pTemp+3) = pSource->iOrientation; - *(pTemp+4) = pSource->iOffsettype; - - mng_put_int32 (pTemp+5, pSource->iOffsetx); - mng_put_int32 (pTemp+9, pSource->iOffsety); - - *(pTemp+13) = pSource->iBoundarytype; - - mng_put_int32 (pTemp+14, pSource->iBoundaryl); - mng_put_int32 (pTemp+18, pSource->iBoundaryr); - mng_put_int32 (pTemp+22, pSource->iBoundaryt); - mng_put_int32 (pTemp+26, pSource->iBoundaryb); - - pSource++; - pTemp += 30; - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pPAST->sHeader.iChunkname, - iRawlen, pRawdata); - /* free temporary buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_FREEX (pData, pRawdata, iRawlen); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PAST, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -WRITE_CHUNK (mng_write_disc) -{ - mng_discp pDISC; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint32 iX; - mng_uint8p pTemp1; - mng_uint16p pTemp2; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DISC, MNG_LC_START); -#endif - - pDISC = (mng_discp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pDISC->iCount << 1; - - pTemp1 = pRawdata; /* fill the output buffer */ - pTemp2 = pDISC->pObjectids; - - for (iX = 0; iX < pDISC->iCount; iX++) - { - mng_put_uint16 (pTemp1, *pTemp2); - - pTemp2++; - pTemp1 += 2; - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pDISC->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DISC, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (mng_write_back) -{ - mng_backp pBACK; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_BACK, MNG_LC_START); -#endif - - pBACK = (mng_backp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 6; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pBACK->iRed); - mng_put_uint16 (pRawdata+2, pBACK->iGreen); - mng_put_uint16 (pRawdata+4, pBACK->iBlue); - - if ((pBACK->iMandatory) || (pBACK->iImageid) || (pBACK->iTile)) - { - iRawlen++; - *(pRawdata+6) = pBACK->iMandatory; - - if ((pBACK->iImageid) || (pBACK->iTile)) - { - iRawlen += 2; - mng_put_uint16 (pRawdata+7, pBACK->iImageid); - - if (pBACK->iTile) - { - iRawlen++; - *(pRawdata+9) = pBACK->iTile; - } - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pBACK->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_BACK, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (mng_write_fram) -{ - mng_framp pFRAM; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_uint32p pTemp2; - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_FRAM, MNG_LC_START); -#endif - - pFRAM = (mng_framp)pChunk; /* address the proper chunk */ - - if (pFRAM->bEmpty) /* empty ? */ - iRetcode = write_raw_chunk (pData, pFRAM->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 1; - /* fill the output buffer */ - *pRawdata = pFRAM->iMode; - - if ((pFRAM->iNamesize ) || - (pFRAM->iChangedelay ) || (pFRAM->iChangetimeout) || - (pFRAM->iChangeclipping) || (pFRAM->iChangesyncid ) ) - { - if (pFRAM->iNamesize) - MNG_COPY (pRawdata+1, pFRAM->zName, pFRAM->iNamesize); - - iRawlen += pFRAM->iNamesize; - pTemp = pRawdata + pFRAM->iNamesize + 1; - - if ((pFRAM->iChangedelay ) || (pFRAM->iChangetimeout) || - (pFRAM->iChangeclipping) || (pFRAM->iChangesyncid ) ) - { - *pTemp = 0; - *(pTemp+1) = pFRAM->iChangedelay; - *(pTemp+2) = pFRAM->iChangetimeout; - *(pTemp+3) = pFRAM->iChangeclipping; - *(pTemp+4) = pFRAM->iChangesyncid; - - iRawlen += 5; - pTemp += 5; - - if (pFRAM->iChangedelay) - { - mng_put_uint32 (pTemp, pFRAM->iDelay); - iRawlen += 4; - pTemp += 4; - } - - if (pFRAM->iChangetimeout) - { - mng_put_uint32 (pTemp, pFRAM->iTimeout); - iRawlen += 4; - pTemp += 4; - } - - if (pFRAM->iChangeclipping) - { - *pTemp = pFRAM->iBoundarytype; - - mng_put_uint32 (pTemp+1, pFRAM->iBoundaryl); - mng_put_uint32 (pTemp+5, pFRAM->iBoundaryr); - mng_put_uint32 (pTemp+9, pFRAM->iBoundaryt); - mng_put_uint32 (pTemp+13, pFRAM->iBoundaryb); - - iRawlen += 17; - pTemp += 17; - } - - if (pFRAM->iChangesyncid) - { - iRawlen += pFRAM->iCount * 4; - pTemp2 = pFRAM->pSyncids; - - for (iX = 0; iX < pFRAM->iCount; iX++) - { - mng_put_uint32 (pTemp, *pTemp2); - - pTemp2++; - pTemp += 4; - } - } - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pFRAM->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_FRAM, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (mng_write_move) -{ - mng_movep pMOVE; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MOVE, MNG_LC_START); -#endif - - pMOVE = (mng_movep)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 13; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pMOVE->iFirstid); - mng_put_uint16 (pRawdata+2, pMOVE->iLastid); - - *(pRawdata+4) = pMOVE->iMovetype; - - mng_put_int32 (pRawdata+5, pMOVE->iMovex); - mng_put_int32 (pRawdata+9, pMOVE->iMovey); - /* and write it */ - iRetcode = write_raw_chunk (pData, pMOVE->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MOVE, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (mng_write_clip) -{ - mng_clipp pCLIP; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_CLIP, MNG_LC_START); -#endif - - pCLIP = (mng_clipp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 21; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pCLIP->iFirstid); - mng_put_uint16 (pRawdata+2, pCLIP->iLastid); - - *(pRawdata+4) = pCLIP->iCliptype; - - mng_put_int32 (pRawdata+5, pCLIP->iClipl); - mng_put_int32 (pRawdata+9, pCLIP->iClipr); - mng_put_int32 (pRawdata+13, pCLIP->iClipt); - mng_put_int32 (pRawdata+17, pCLIP->iClipb); - /* and write it */ - iRetcode = write_raw_chunk (pData, pCLIP->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_CLIP, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (mng_write_show) -{ - mng_showp pSHOW; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SHOW, MNG_LC_START); -#endif - - pSHOW = (mng_showp)pChunk; /* address the proper chunk */ - - if (pSHOW->bEmpty) /* empty ? */ - iRetcode = write_raw_chunk (pData, pSHOW->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 2; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pSHOW->iFirstid); - - if ((pSHOW->iLastid != pSHOW->iFirstid) || (pSHOW->iMode)) - { - iRawlen += 2; - mng_put_uint16 (pRawdata+2, pSHOW->iLastid); - - if (pSHOW->iMode) - { - iRawlen++; - *(pRawdata+4) = pSHOW->iMode; - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pSHOW->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SHOW, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (mng_write_term) -{ - mng_termp pTERM; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_TERM, MNG_LC_START); -#endif - - pTERM = (mng_termp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 1; - - *pRawdata = pTERM->iTermaction; /* fill the output buffer */ - - if (pTERM->iTermaction == 3) - { - iRawlen = 10; - *(pRawdata+1) = pTERM->iIteraction; - - mng_put_uint32 (pRawdata+2, pTERM->iDelay); - mng_put_uint32 (pRawdata+6, pTERM->iItermax); - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pTERM->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_TERM, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SAVE -WRITE_CHUNK (mng_write_save) -{ - mng_savep pSAVE; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_save_entryp pEntry; - mng_uint32 iEntrysize; - mng_uint8p pTemp; - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SAVE, MNG_LC_START); -#endif - - pSAVE = (mng_savep)pChunk; /* address the proper chunk */ - - if (pSAVE->bEmpty) /* empty ? */ - iRetcode = write_raw_chunk (pData, pSAVE->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 1; - - *pRawdata = pSAVE->iOffsettype; /* fill the output buffer */ - - if (pSAVE->iOffsettype == 16) - iEntrysize = 25; - else - iEntrysize = 17; - - pTemp = pRawdata+1; - pEntry = pSAVE->pEntries; - - for (iX = 0; iX < pSAVE->iCount; iX++) - { - if (iX) /* put separator null-byte, except the first */ - { - *pTemp = 0; - pTemp++; - iRawlen++; - } - - iRawlen += iEntrysize + pEntry->iNamesize; - *pTemp = pEntry->iEntrytype; - - if (pSAVE->iOffsettype == 16) - { - mng_put_uint32 (pTemp+1, pEntry->iOffset[0]); - mng_put_uint32 (pTemp+5, pEntry->iOffset[1]); - mng_put_uint32 (pTemp+9, pEntry->iStarttime[0]); - mng_put_uint32 (pTemp+13, pEntry->iStarttime[1]); - mng_put_uint32 (pTemp+17, pEntry->iLayernr); - mng_put_uint32 (pTemp+21, pEntry->iFramenr); - - pTemp += 25; - } - else - { - mng_put_uint32 (pTemp+1, pEntry->iOffset[1]); - mng_put_uint32 (pTemp+5, pEntry->iStarttime[1]); - mng_put_uint32 (pTemp+9, pEntry->iLayernr); - mng_put_uint32 (pTemp+13, pEntry->iFramenr); - - pTemp += 17; - } - - if (pEntry->iNamesize) - { - MNG_COPY (pTemp, pEntry->zName, pEntry->iNamesize); - pTemp += pEntry->iNamesize; - } - - pEntry++; - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pSAVE->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SAVE, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SEEK -WRITE_CHUNK (mng_write_seek) -{ - mng_seekp pSEEK; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SEEK, MNG_LC_START); -#endif - - pSEEK = (mng_seekp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pSEEK->iNamesize; - - if (iRawlen) /* fill the output buffer */ - MNG_COPY (pRawdata, pSEEK->zName, iRawlen); - /* and write it */ - iRetcode = write_raw_chunk (pData, pSEEK->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SEEK, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_eXPI -WRITE_CHUNK (mng_write_expi) -{ - mng_expip pEXPI; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_EXPI, MNG_LC_START); -#endif - - pEXPI = (mng_expip)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 2 + pEXPI->iNamesize; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pEXPI->iSnapshotid); - - if (pEXPI->iNamesize) - MNG_COPY (pRawdata+2, pEXPI->zName, pEXPI->iNamesize); - /* and write it */ - iRetcode = write_raw_chunk (pData, pEXPI->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_EXPI, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_fPRI -WRITE_CHUNK (mng_write_fpri) -{ - mng_fprip pFPRI; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_FPRI, MNG_LC_START); -#endif - - pFPRI = (mng_fprip)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 2; - - *pRawdata = pFPRI->iDeltatype; /* fill the output buffer */ - *(pRawdata+1) = pFPRI->iPriority; - /* and write it */ - iRetcode = write_raw_chunk (pData, pFPRI->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_FPRI, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_nEED -WRITE_CHUNK (mng_write_need) -{ - mng_needp pNEED; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_NEED, MNG_LC_START); -#endif - - pNEED = (mng_needp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pNEED->iKeywordssize; - /* fill the output buffer */ - if (pNEED->iKeywordssize) - MNG_COPY (pRawdata, pNEED->zKeywords, pNEED->iKeywordssize); - /* and write it */ - iRetcode = write_raw_chunk (pData, pNEED->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_NEED, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_pHYg -WRITE_CHUNK (mng_write_phyg) -{ - mng_phygp pPHYG; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PHYG, MNG_LC_START); -#endif - - pPHYG = (mng_phygp)pChunk; /* address the proper chunk */ - - if (pPHYG->bEmpty) /* write empty ? */ - iRetcode = write_raw_chunk (pData, pPHYG->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 9; - /* fill the output buffer */ - mng_put_uint32 (pRawdata, pPHYG->iSizex); - mng_put_uint32 (pRawdata+4, pPHYG->iSizey); - - *(pRawdata+8) = pPHYG->iUnit; - /* and write it */ - iRetcode = write_raw_chunk (pData, pPHYG->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PHYG, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -/* B004 */ -#ifdef MNG_INCLUDE_JNG -/* B004 */ -WRITE_CHUNK (mng_write_jhdr) -{ - mng_jhdrp pJHDR; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_JHDR, MNG_LC_START); -#endif - - pJHDR = (mng_jhdrp)pChunk; /* address the proper chunk */ - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 16; - /* fill the output buffer */ - mng_put_uint32 (pRawdata, pJHDR->iWidth); - mng_put_uint32 (pRawdata+4, pJHDR->iHeight); - - *(pRawdata+8) = pJHDR->iColortype; - *(pRawdata+9) = pJHDR->iImagesampledepth; - *(pRawdata+10) = pJHDR->iImagecompression; - *(pRawdata+11) = pJHDR->iImageinterlace; - *(pRawdata+12) = pJHDR->iAlphasampledepth; - *(pRawdata+13) = pJHDR->iAlphacompression; - *(pRawdata+14) = pJHDR->iAlphafilter; - *(pRawdata+15) = pJHDR->iAlphainterlace; - /* and write it */ - iRetcode = write_raw_chunk (pData, pJHDR->sHeader.iChunkname, iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_JHDR, MNG_LC_END); -#endif - - return iRetcode; -} -#else -#define write_jhdr 0 -/* B004 */ -#endif /* MNG_INCLUDE_JNG */ -/* B004 */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -WRITE_CHUNK (mng_write_jdaa) -{ - mng_jdatp pJDAA; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_JDAA, MNG_LC_START); -#endif - - pJDAA = (mng_jdaap)pChunk; /* address the proper chunk */ - - if (pJDAA->bEmpty) /* and write it */ - iRetcode = write_raw_chunk (pData, pJDAA->sHeader.iChunkname, 0, 0); - else - iRetcode = write_raw_chunk (pData, pJDAA->sHeader.iChunkname, - pJDAA->iDatasize, pJDAA->pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_JDAA, MNG_LC_END); -#endif - - return iRetcode; -} -#else -#define write_jdaa 0 -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -/* B004 */ -#ifdef MNG_INCLUDE_JNG -/* B004 */ -WRITE_CHUNK (mng_write_jdat) -{ - mng_jdatp pJDAT; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_JDAT, MNG_LC_START); -#endif - - pJDAT = (mng_jdatp)pChunk; /* address the proper chunk */ - - if (pJDAT->bEmpty) /* and write it */ - iRetcode = write_raw_chunk (pData, pJDAT->sHeader.iChunkname, 0, 0); - else - iRetcode = write_raw_chunk (pData, pJDAT->sHeader.iChunkname, - pJDAT->iDatasize, pJDAT->pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_JDAT, MNG_LC_END); -#endif - - return iRetcode; -} -#else -#define write_jdat 0 -/* B004 */ -#endif /* MNG_INCLUDE_JNG */ -/* B004 */ - -/* ************************************************************************** */ - -/* B004 */ -#ifdef MNG_INCLUDE_JNG -/* B004 */ -WRITE_CHUNK (mng_write_jsep) -{ - mng_jsepp pJSEP; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_JSEP, MNG_LC_START); -#endif - - pJSEP = (mng_jsepp)pChunk; /* address the proper chunk */ - /* and write it */ - iRetcode = write_raw_chunk (pData, pJSEP->sHeader.iChunkname, 0, 0); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_JSEP, MNG_LC_END); -#endif - - return iRetcode; -} -#else -#define write_jsep 0 -/* B004 */ -#endif /* MNG_INCLUDE_JNG */ -/* B004 */ - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -WRITE_CHUNK (mng_write_dhdr) -{ - mng_dhdrp pDHDR; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DHDR, MNG_LC_START); -#endif - - pDHDR = (mng_dhdrp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 4; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pDHDR->iObjectid); - - *(pRawdata+2) = pDHDR->iImagetype; - *(pRawdata+3) = pDHDR->iDeltatype; - - if (pDHDR->iDeltatype != 7) - { - iRawlen += 8; - mng_put_uint32 (pRawdata+4, pDHDR->iBlockwidth); - mng_put_uint32 (pRawdata+8, pDHDR->iBlockheight); - - if (pDHDR->iDeltatype != 0) - { - iRawlen += 8; - mng_put_uint32 (pRawdata+12, pDHDR->iBlockx); - mng_put_uint32 (pRawdata+16, pDHDR->iBlocky); - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pDHDR->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DHDR, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -WRITE_CHUNK (mng_write_prom) -{ - mng_promp pPROM; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PROM, MNG_LC_START); -#endif - - pPROM = (mng_promp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 3; - - *pRawdata = pPROM->iColortype; /* fill the output buffer */ - *(pRawdata+1) = pPROM->iSampledepth; - *(pRawdata+2) = pPROM->iFilltype; - /* and write it */ - iRetcode = write_raw_chunk (pData, pPROM->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PROM, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -WRITE_CHUNK (mng_write_ipng) -{ - mng_ipngp pIPNG; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IPNG, MNG_LC_START); -#endif - - pIPNG = (mng_ipngp)pChunk; /* address the proper chunk */ - /* and write it */ - iRetcode = write_raw_chunk (pData, pIPNG->sHeader.iChunkname, 0, 0); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IPNG, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -WRITE_CHUNK (mng_write_pplt) -{ - mng_ppltp pPPLT; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_pplt_entryp pEntry; - mng_uint8p pTemp; - mng_uint32 iX; - mng_bool bHasgroup; - mng_uint8p pLastid = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PPLT, MNG_LC_START); -#endif - - pPPLT = (mng_ppltp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 1; - - *pRawdata = pPPLT->iDeltatype; /* fill the output buffer */ - - pTemp = pRawdata+1; - bHasgroup = MNG_FALSE; - - for (iX = 0; iX < pPPLT->iCount; iX++) - { - pEntry = &pPPLT->aEntries[iX]; - - if (pEntry->bUsed) /* valid entry ? */ - { - if (!bHasgroup) /* start a new group ? */ - { - bHasgroup = MNG_TRUE; - pLastid = pTemp+1; - - *pTemp = (mng_uint8)iX; - *(pTemp+1) = 0; - - pTemp += 2; - iRawlen += 2; - } - - switch (pPPLT->iDeltatype) /* add group-entry depending on type */ - { - case 0: ; - case 1: { - *pTemp = pEntry->iRed; - *(pTemp+1) = pEntry->iGreen; - *(pTemp+2) = pEntry->iBlue; - - pTemp += 3; - iRawlen += 3; - - break; - } - - case 2: ; - case 3: { - *pTemp = pEntry->iAlpha; - - pTemp++; - iRawlen++; - - break; - } - - case 4: ; - case 5: { - *pTemp = pEntry->iRed; - *(pTemp+1) = pEntry->iGreen; - *(pTemp+2) = pEntry->iBlue; - *(pTemp+3) = pEntry->iAlpha; - - pTemp += 4; - iRawlen += 4; - - break; - } - - } - } - else - { - if (bHasgroup) /* finish off a group ? */ - *pLastid = (mng_uint8)(iX-1); - - bHasgroup = MNG_FALSE; - } - } - - if (bHasgroup) /* last group unfinished ? */ - *pLastid = (mng_uint8)(pPPLT->iCount-1); - /* write the output buffer */ - iRetcode = write_raw_chunk (pData, pPPLT->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PPLT, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifdef MNG_INCLUDE_JNG -WRITE_CHUNK (mng_write_ijng) -{ - mng_ijngp pIJNG; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IJNG, MNG_LC_START); -#endif - - pIJNG = (mng_ijngp)pChunk; /* address the proper chunk */ - /* and write it */ - iRetcode = write_raw_chunk (pData, pIJNG->sHeader.iChunkname, 0, 0); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IJNG, MNG_LC_END); -#endif - - return iRetcode; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -WRITE_CHUNK (mng_write_drop) -{ - mng_dropp pDROP; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint32 iX; - mng_uint8p pTemp1; - mng_chunkidp pTemp2; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DROP, MNG_LC_START); -#endif - - pDROP = (mng_dropp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pDROP->iCount << 2; - - pTemp1 = pRawdata; /* fill the output buffer */ - pTemp2 = pDROP->pChunknames; - - for (iX = 0; iX < pDROP->iCount; iX++) - { - mng_put_uint32 (pTemp1, (mng_uint32)*pTemp2); - - pTemp2++; - pTemp1 += 4; - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pDROP->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DROP, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_DBYK -WRITE_CHUNK (mng_write_dbyk) -{ - mng_dbykp pDBYK; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DBYK, MNG_LC_START); -#endif - - pDBYK = (mng_dbykp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 5 + pDBYK->iKeywordssize; - /* fill the output buffer */ - mng_put_uint32 (pRawdata, pDBYK->iChunkname); - *(pRawdata+4) = pDBYK->iPolarity; - - if (pDBYK->iKeywordssize) - MNG_COPY (pRawdata+5, pDBYK->zKeywords, pDBYK->iKeywordssize); - /* and write it */ - iRetcode = write_raw_chunk (pData, pDBYK->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DBYK, MNG_LC_END); -#endif - - return iRetcode; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_ORDR -WRITE_CHUNK (mng_write_ordr) -{ - mng_ordrp pORDR; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_ordr_entryp pEntry; - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ORDR, MNG_LC_START); -#endif - - pORDR = (mng_ordrp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pORDR->iCount * 5; - - pTemp = pRawdata; /* fill the output buffer */ - pEntry = pORDR->pEntries; - - for (iX = 0; iX < pORDR->iCount; iX++) - { - mng_put_uint32 (pTemp, pEntry->iChunkname); - *(pTemp+4) = pEntry->iOrdertype; - pTemp += 5; - pEntry++; - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pORDR->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ORDR, MNG_LC_END); -#endif - - return iRetcode; -} -#endif -#endif - -/* ************************************************************************** */ - -WRITE_CHUNK (mng_write_magn) -{ - mng_magnp pMAGN; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MAGN, MNG_LC_START); -#endif - - pMAGN = (mng_magnp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 18; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pMAGN->iFirstid); - mng_put_uint16 (pRawdata+2, pMAGN->iLastid); - *(pRawdata+4) = pMAGN->iMethodX; - mng_put_uint16 (pRawdata+5, pMAGN->iMX); - mng_put_uint16 (pRawdata+7, pMAGN->iMY); - mng_put_uint16 (pRawdata+9, pMAGN->iML); - mng_put_uint16 (pRawdata+11, pMAGN->iMR); - mng_put_uint16 (pRawdata+13, pMAGN->iMT); - mng_put_uint16 (pRawdata+15, pMAGN->iMB); - *(pRawdata+17) = pMAGN->iMethodY; - /* optimize length */ - if (pMAGN->iMethodY == pMAGN->iMethodX) - { - iRawlen--; - - if (pMAGN->iMB == pMAGN->iMY) - { - iRawlen -= 2; - - if (pMAGN->iMT == pMAGN->iMY) - { - iRawlen -= 2; - - if (pMAGN->iMR == pMAGN->iMX) - { - iRawlen -= 2; - - if (pMAGN->iML == pMAGN->iMX) - { - iRawlen -= 2; - - if (pMAGN->iMY == pMAGN->iMX) - { - iRawlen -= 2; - - if (pMAGN->iMX == 1) - { - iRawlen -= 2; - - if (pMAGN->iMethodX == 0) - { - iRawlen--; - - if (pMAGN->iLastid == pMAGN->iFirstid) - { - iRawlen -= 2; - - if (pMAGN->iFirstid == 0) - iRawlen = 0; - - } - } - } - } - } - } - } - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pMAGN->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MAGN, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_MPNG_PROPOSAL -WRITE_CHUNK (mng_write_mpng) -{ - mng_mpngp pMPNG; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pBuf = 0; - mng_uint32 iBuflen; - mng_uint32 iReallen; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MPNG, MNG_LC_START); -#endif - - pMPNG = (mng_mpngp)pChunk; /* address the proper chunk */ - /* compress the frame structures */ - iRetcode = deflate_buffer (pData, (mng_uint8p)pMPNG->pFrames, pMPNG->iFramessize, - &pBuf, &iBuflen, &iReallen); - - if (!iRetcode) /* all ok ? */ - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 15 + iReallen; - /* requires large buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_ALLOC (pData, pRawdata, iRawlen); - /* fill the buffer */ - mng_put_uint32 (pRawdata, pMPNG->iFramewidth); - mng_put_uint32 (pRawdata+4, pMPNG->iFrameheight); - mng_put_uint16 (pRawdata+8, pMPNG->iNumplays); - mng_put_uint16 (pRawdata+10, pMPNG->iTickspersec); - *(pRawdata+12) = pMPNG->iCompressionmethod; - - if (iReallen) - MNG_COPY (pRawdata+13, pBuf, iReallen); - /* and write it */ - iRetcode = write_raw_chunk (pData, pMPNG->sHeader.iChunkname, - iRawlen, pRawdata); - /* drop the temp buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_FREEX (pData, pRawdata, iRawlen); - } - - MNG_FREEX (pData, pBuf, iBuflen); /* always drop the compression buffer */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MPNG, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ANG_PROPOSAL -WRITE_CHUNK (mng_write_ahdr) -{ - mng_ahdrp pAHDR; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_AHDR, MNG_LC_START); -#endif - - pAHDR = (mng_ahdrp)pChunk; /* address the proper chunk */ - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 22; - /* fill the buffer */ - mng_put_uint32 (pRawdata, pAHDR->iNumframes); - mng_put_uint32 (pRawdata+4, pAHDR->iTickspersec); - mng_put_uint32 (pRawdata+8, pAHDR->iNumplays); - mng_put_uint32 (pRawdata+12, pAHDR->iTilewidth); - mng_put_uint32 (pRawdata+16, pAHDR->iTileheight); - *(pRawdata+20) = pAHDR->iInterlace; - *(pRawdata+21) = pAHDR->iStillused; - /* and write it */ - iRetcode = write_raw_chunk (pData, pAHDR->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_AHDR, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ANG_PROPOSAL -WRITE_CHUNK (mng_write_adat) -{ - - /* TODO: something */ - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_evNT -WRITE_CHUNK (mng_write_evnt) -{ - mng_evntp pEVNT; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_evnt_entryp pEntry; - mng_uint8p pTemp; - mng_uint32 iX; - mng_uint32 iNamesize; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_EVNT, MNG_LC_START); -#endif - - pEVNT = (mng_evntp)pChunk; /* address the proper chunk */ - - if (!pEVNT->iCount) /* empty ? */ - iRetcode = write_raw_chunk (pData, pEVNT->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 0; - pTemp = pRawdata; - pEntry = pEVNT->pEntries; - - for (iX = 0; iX < pEVNT->iCount; iX++) - { - if (iX) /* put separator null-byte, except the first */ - { - *pTemp = 0; - pTemp++; - iRawlen++; - } - - *pTemp = pEntry->iEventtype; - *(pTemp+1) = pEntry->iMasktype; - pTemp += 2; - iRawlen += 2; - - switch (pEntry->iMasktype) - { - case 1 : - { - mng_put_int32 (pTemp, pEntry->iLeft); - mng_put_int32 (pTemp+4, pEntry->iRight); - mng_put_int32 (pTemp+8, pEntry->iTop); - mng_put_int32 (pTemp+12, pEntry->iBottom); - pTemp += 16; - iRawlen += 16; - break; - } - case 2 : - { - mng_put_uint16 (pTemp, pEntry->iObjectid); - pTemp += 2; - iRawlen += 2; - break; - } - case 3 : - { - mng_put_uint16 (pTemp, pEntry->iObjectid); - *(pTemp+2) = pEntry->iIndex; - pTemp += 3; - iRawlen += 3; - break; - } - case 4 : - { - mng_put_int32 (pTemp, pEntry->iLeft); - mng_put_int32 (pTemp+4, pEntry->iRight); - mng_put_int32 (pTemp+8, pEntry->iTop); - mng_put_int32 (pTemp+12, pEntry->iBottom); - mng_put_uint16 (pTemp+16, pEntry->iObjectid); - pTemp += 18; - iRawlen += 18; - break; - } - case 5 : - { - mng_put_int32 (pTemp, pEntry->iLeft); - mng_put_int32 (pTemp+4, pEntry->iRight); - mng_put_int32 (pTemp+8, pEntry->iTop); - mng_put_int32 (pTemp+12, pEntry->iBottom); - mng_put_uint16 (pTemp+16, pEntry->iObjectid); - *(pTemp+18) = pEntry->iIndex; - pTemp += 19; - iRawlen += 19; - break; - } - } - - iNamesize = pEntry->iSegmentnamesize; - - if (iNamesize) - { - MNG_COPY (pTemp, pEntry->zSegmentname, iNamesize); - pTemp += iNamesize; - iRawlen += iNamesize; - } - - pEntry++; - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pEVNT->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_EVNT, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -WRITE_CHUNK (mng_write_unknown) -{ - mng_unknown_chunkp pUnknown; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_UNKNOWN, MNG_LC_START); -#endif - /* address the proper chunk */ - pUnknown = (mng_unknown_chunkp)pChunk; - /* and write it */ - iRetcode = write_raw_chunk (pData, pUnknown->sHeader.iChunkname, - pUnknown->iDatasize, pUnknown->pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_UNKNOWN, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_WRITE_PROCS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/plugins/AdvaImg/src/LibMNG/libmng_chunk_io.h b/plugins/AdvaImg/src/LibMNG/libmng_chunk_io.h deleted file mode 100644 index b47f8639b9..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_chunk_io.h +++ /dev/null @@ -1,415 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_chunk_io.h copyright (c) 2000-2007 G.Juyn * */ -/* * version : 1.0.109 * */ -/* * * */ -/* * purpose : Chunk I/O routines (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * comment : Definition of the chunk input/output routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/04/2000 - G.Juyn * */ -/* * - changed CRC initialization to use dynamic structure * */ -/* * (wasn't thread-safe the old way !) * */ -/* * 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed write routines definition * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added support for JDAA * */ -/* * * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * 1.0.5 - 09/14/2002 - G.Juyn * */ -/* * - added event handling for dynamic MNG * */ -/* * * */ -/* * 1.0.6 - 07/07/2003 - G.R-P * */ -/* * - added SKIP_CHUNK and NO_DELTA_PNG support * */ -/* * 1.0.6 - 07/29/2003 - G.R-P * */ -/* * - added conditionals around PAST chunk support * */ -/* * * */ -/* * 1.0.7 - 03/24/2004 - G.R-P * */ -/* * - fixed SKIPCHUNK_itXT and SKIPCHUNK_ztXT typos * */ -/* * * */ -/* * 1.0.9 - 12/07/2004 - G.Juyn * */ -/* * - added conditional MNG_OPTIMIZE_CHUNKREADER * */ -/* * * */ -/* * 1.0.10 - 04/08/2007 - G.Juyn * */ -/* * - added support for mPNG proposal * */ -/* * 1.0.10 - 04/12/2007 - G.Juyn * */ -/* * - added support for ANG proposal * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_chunk_io_h_ -#define _libmng_chunk_io_h_ - -/* ************************************************************************** */ - -mng_uint32 mng_crc (mng_datap pData, - mng_uint8p buf, - mng_int32 len); - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_READ_PROCS - -/* ************************************************************************** */ - -mng_retcode mng_inflate_buffer (mng_datap pData, - mng_uint8p pInbuf, - mng_uint32 iInsize, - mng_uint8p *pOutbuf, - mng_uint32 *iOutsize, - mng_uint32 *iRealsize); - -/* ************************************************************************** */ - -#define READ_CHUNK(n) mng_retcode n (mng_datap pData, \ - mng_chunkp pHeader, \ - mng_uint32 iRawlen, \ - mng_uint8p pRawdata, \ - mng_chunkp* ppChunk) - -#ifdef MNG_OPTIMIZE_CHUNKREADER -READ_CHUNK (mng_read_general) ; -#endif - -READ_CHUNK (mng_read_ihdr) ; -READ_CHUNK (mng_read_plte) ; -READ_CHUNK (mng_read_idat) ; -READ_CHUNK (mng_read_iend) ; -READ_CHUNK (mng_read_trns) ; -READ_CHUNK (mng_read_gama) ; -READ_CHUNK (mng_read_chrm) ; -READ_CHUNK (mng_read_srgb) ; -#ifndef MNG_SKIPCHUNK_iCCP -READ_CHUNK (mng_read_iccp) ; -#endif -#ifndef MNG_SKIPCHUNK_tEXt -READ_CHUNK (mng_read_text) ; -#endif -#ifndef MNG_SKIPCHUNK_zTXt -READ_CHUNK (mng_read_ztxt) ; -#endif -#ifndef MNG_SKIPCHUNK_iTXt -READ_CHUNK (mng_read_itxt) ; -#endif -#ifndef MNG_SKIPCHUNK_bKGD -READ_CHUNK (mng_read_bkgd) ; -#endif -#ifndef MNG_SKIPCHUNK_pHYs -READ_CHUNK (mng_read_phys) ; -#endif -#ifndef MNG_SKIPCHUNK_sBIT -READ_CHUNK (mng_read_sbit) ; -#endif -#ifndef MNG_SKIPCHUNK_sPLT -READ_CHUNK (mng_read_splt) ; -#endif -#ifndef MNG_SKIPCHUNK_hIST -READ_CHUNK (mng_read_hist) ; -#endif -#ifndef MNG_SKIPCHUNK_tIME -READ_CHUNK (mng_read_time) ; -#endif -READ_CHUNK (mng_read_mhdr) ; -READ_CHUNK (mng_read_mend) ; -READ_CHUNK (mng_read_loop) ; -READ_CHUNK (mng_read_endl) ; -READ_CHUNK (mng_read_defi) ; -READ_CHUNK (mng_read_basi) ; -READ_CHUNK (mng_read_clon) ; -#ifndef MNG_SKIPCHUNK_PAST -READ_CHUNK (mng_read_past) ; -#endif -READ_CHUNK (mng_read_disc) ; -READ_CHUNK (mng_read_back) ; -READ_CHUNK (mng_read_fram) ; -READ_CHUNK (mng_read_move) ; -READ_CHUNK (mng_read_clip) ; -READ_CHUNK (mng_read_show) ; -READ_CHUNK (mng_read_term) ; -READ_CHUNK (mng_read_save) ; -READ_CHUNK (mng_read_seek) ; -#ifndef MNG_SKIPCHUNK_eXPI -READ_CHUNK (mng_read_expi) ; -#endif -#ifndef MNG_SKIPCHUNK_fPRI -READ_CHUNK (mng_read_fpri) ; -#endif -#ifndef MNG_SKIPCHUNK_pHYg -READ_CHUNK (mng_read_phyg) ; -#endif -#ifdef MNG_INCLUDE_JNG -READ_CHUNK (mng_read_jhdr) ; -READ_CHUNK (mng_read_jdaa) ; -READ_CHUNK (mng_read_jdat) ; -READ_CHUNK (mng_read_jsep) ; -#endif -#ifndef MNG_NO_DELTA_PNG -READ_CHUNK (mng_read_dhdr) ; -READ_CHUNK (mng_read_prom) ; -READ_CHUNK (mng_read_ipng) ; -READ_CHUNK (mng_read_pplt) ; -#ifdef MNG_INCLUDE_JNG -READ_CHUNK (mng_read_ijng) ; -#endif -READ_CHUNK (mng_read_drop) ; -READ_CHUNK (mng_read_dbyk) ; -READ_CHUNK (mng_read_ordr) ; -#endif -READ_CHUNK (mng_read_magn) ; -#ifndef MNG_SKIPCHUNK_nEED -READ_CHUNK (mng_read_need) ; -#endif -#ifdef MNG_INCLUDE_MPNG_PROPOSAL -READ_CHUNK (mng_read_mpng) ; -#endif -#ifndef MNG_SKIPCHUNK_evNT -READ_CHUNK (mng_read_evnt) ; -#endif -READ_CHUNK (mng_read_unknown) ; - -/* ************************************************************************** */ - -#else /* MNG_INCLUDE_READ_PROCS */ -#define mng_read_ihdr 0 -#define mng_read_plte 0 -#define mng_read_idat 0 -#define mng_read_iend 0 -#define mng_read_trns 0 -#define mng_read_gama 0 -#define mng_read_chrm 0 -#define mng_read_srgb 0 -#define mng_read_iccp 0 -#define mng_read_text 0 -#define mng_read_ztxt 0 -#define mng_read_itxt 0 -#define mng_read_bkgd 0 -#define mng_read_phys 0 -#define mng_read_sbit 0 -#define mng_read_splt 0 -#define mng_read_hist 0 -#define mng_read_time 0 -#define mng_read_mhdr 0 -#define mng_read_mend 0 -#define mng_read_loop 0 -#define mng_read_endl 0 -#define mng_read_defi 0 -#define mng_read_basi 0 -#define mng_read_clon 0 -#ifndef MNG_SKIPCHUNK_PAST -#define mng_read_past 0 -#endif -#define mng_read_disc 0 -#define mng_read_back 0 -#define mng_read_fram 0 -#define mng_read_move 0 -#define mng_read_clip 0 -#define mng_read_show 0 -#define mng_read_term 0 -#define mng_read_save 0 -#define mng_read_seek 0 -#define mng_read_expi 0 -#define mng_read_fpri 0 -#define mng_read_phyg 0 -#ifdef MNG_INCLUDE_JNG -#define mng_read_jhdr 0 -#define mng_read_jdaa 0 -#define mng_read_jdat 0 -#define mng_read_jsep 0 -#endif -#ifndef MNG_NO_DELTA_PNG -#define mng_read_dhdr 0 -#define mng_read_prom 0 -#define mng_read_ipng 0 -#define mng_read_pplt 0 -#ifdef MNG_INCLUDE_JNG -#define mng_read_ijng 0 -#endif -#define mng_read_drop 0 -#define mng_read_dbyk 0 -#define mng_read_ordr 0 -#endif -#define mng_read_magn 0 -#define mng_read_need 0 -#ifdef MNG_INCLUDE_MPNG_PROPOSAL -#define mng_read_mpng 0 -#endif -#define mng_read_evnt 0 -#define mng_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 (mng_write_ihdr) ; -WRITE_CHUNK (mng_write_plte) ; -WRITE_CHUNK (mng_write_idat) ; -WRITE_CHUNK (mng_write_iend) ; -WRITE_CHUNK (mng_write_trns) ; -WRITE_CHUNK (mng_write_gama) ; -WRITE_CHUNK (mng_write_chrm) ; -WRITE_CHUNK (mng_write_srgb) ; -WRITE_CHUNK (mng_write_iccp) ; -WRITE_CHUNK (mng_write_text) ; -WRITE_CHUNK (mng_write_ztxt) ; -WRITE_CHUNK (mng_write_itxt) ; -WRITE_CHUNK (mng_write_bkgd) ; -WRITE_CHUNK (mng_write_phys) ; -WRITE_CHUNK (mng_write_sbit) ; -WRITE_CHUNK (mng_write_splt) ; -WRITE_CHUNK (mng_write_hist) ; -WRITE_CHUNK (mng_write_time) ; -WRITE_CHUNK (mng_write_mhdr) ; -WRITE_CHUNK (mng_write_mend) ; -WRITE_CHUNK (mng_write_loop) ; -WRITE_CHUNK (mng_write_endl) ; -WRITE_CHUNK (mng_write_defi) ; -WRITE_CHUNK (mng_write_basi) ; -WRITE_CHUNK (mng_write_clon) ; -#ifndef MNG_SKIPCHUNK_PAST -WRITE_CHUNK (mng_write_past) ; -#endif -WRITE_CHUNK (mng_write_disc) ; -WRITE_CHUNK (mng_write_back) ; -WRITE_CHUNK (mng_write_fram) ; -WRITE_CHUNK (mng_write_move) ; -WRITE_CHUNK (mng_write_clip) ; -WRITE_CHUNK (mng_write_show) ; -WRITE_CHUNK (mng_write_term) ; -WRITE_CHUNK (mng_write_save) ; -WRITE_CHUNK (mng_write_seek) ; -WRITE_CHUNK (mng_write_expi) ; -WRITE_CHUNK (mng_write_fpri) ; -WRITE_CHUNK (mng_write_phyg) ; -#ifdef MNG_INCLUDE_JNG -WRITE_CHUNK (mng_write_jhdr) ; -WRITE_CHUNK (mng_write_jdaa) ; -WRITE_CHUNK (mng_write_jdat) ; -WRITE_CHUNK (mng_write_jsep) ; -#endif -#ifndef MNG_NO_DELTA_PNG -WRITE_CHUNK (mng_write_dhdr) ; -WRITE_CHUNK (mng_write_prom) ; -WRITE_CHUNK (mng_write_ipng) ; -WRITE_CHUNK (mng_write_pplt) ; -#ifdef MNG_INCLUDE_JNG -WRITE_CHUNK (mng_write_ijng) ; -#endif -WRITE_CHUNK (mng_write_drop) ; -WRITE_CHUNK (mng_write_dbyk) ; -WRITE_CHUNK (mng_write_ordr) ; -#endif -WRITE_CHUNK (mng_write_magn) ; -WRITE_CHUNK (mng_write_need) ; -#ifdef MNG_INCLUDE_MPNG_PROPOSAL -WRITE_CHUNK (mng_write_mpng) ; -#endif -#ifdef MNG_INCLUDE_ANG_PROPOSAL -WRITE_CHUNK (mng_write_ahdr) ; -WRITE_CHUNK (mng_write_adat) ; -#endif -WRITE_CHUNK (mng_write_evnt) ; -WRITE_CHUNK (mng_write_unknown) ; - -/* ************************************************************************** */ - -#else /* MNG_INCLUDE_WRITE_PROCS */ -#define mng_write_ihdr 0 -#define mng_write_plte 0 -#define mng_write_idat 0 -#define mng_write_iend 0 -#define mng_write_trns 0 -#define mng_write_gama 0 -#define mng_write_chrm 0 -#define mng_write_srgb 0 -#define mng_write_iccp 0 -#define mng_write_text 0 -#define mng_write_ztxt 0 -#define mng_write_itxt 0 -#define mng_write_bkgd 0 -#define mng_write_phys 0 -#define mng_write_sbit 0 -#define mng_write_splt 0 -#define mng_write_hist 0 -#define mng_write_time 0 -#define mng_write_mhdr 0 -#define mng_write_mend 0 -#define mng_write_loop 0 -#define mng_write_endl 0 -#define mng_write_defi 0 -#define mng_write_basi 0 -#define mng_write_clon 0 -#ifndef MNG_SKIPCHUNK_PAST -#define mng_write_past 0 -#endif -#define mng_write_disc 0 -#define mng_write_back 0 -#define mng_write_fram 0 -#define mng_write_move 0 -#define mng_write_clip 0 -#define mng_write_show 0 -#define mng_write_term 0 -#define mng_write_save 0 -#define mng_write_seek 0 -#define mng_write_expi 0 -#define mng_write_fpri 0 -#define mng_write_phyg 0 -#ifdef MNG_INCLUDE_JNG -#define mng_write_jhdr 0 -#define mng_write_jdaa 0 -#define mng_write_jdat 0 -#define mng_write_jsep 0 -#endif -#ifndef MNG_NO_DELTA_PNG -#define mng_write_dhdr 0 -#define mng_write_prom 0 -#define mng_write_ipng 0 -#define mng_write_pplt 0 -#ifdef MNG_INCLUDE_JNG -#define mng_write_ijng 0 -#endif -#define mng_write_drop 0 -#define mng_write_dbyk 0 -#define mng_write_ordr 0 -#endif -#define mng_write_magn 0 -#define mng_write_need 0 -#ifdef MNG_INCLUDE_MPNG_PROPOSAL -#define mng_write_mpng 0 -#endif -#ifdef MNG_INCLUDE_ANG_PROPOSAL -#define mng_write_adat 0 -#define mng_write_ahdr 0 -#endif -#define mng_write_evnt 0 -#define mng_write_unknown 0 -#endif /* MNG_INCLUDE_WRITE_PROCS */ - -/* ************************************************************************** */ - -#endif /* _libmng_chunk_io_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/plugins/AdvaImg/src/LibMNG/libmng_chunk_prc.c b/plugins/AdvaImg/src/LibMNG/libmng_chunk_prc.c deleted file mode 100644 index 6c8e5897f5..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_chunk_prc.c +++ /dev/null @@ -1,4452 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_chunk_prc.c copyright (c) 2000-2005 G.Juyn * */ -/* * version : 1.0.10 * */ -/* * * */ -/* * purpose : Chunk initialization & cleanup (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * comment : implementation of the chunk initialization & cleanup * */ -/* * 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.1 - 07/19/2000 - G.Juyn * */ -/* * - fixed creation-code * */ -/* * * */ -/* * 0.9.2 - 07/31/2000 - G.Juyn * */ -/* * - put add_chunk() inside MNG_INCLUDE_WRITE_PROCS wrapper * */ -/* * 0.9.2 - 08/01/2000 - G.Juyn * */ -/* * - wrapper for add_chunk() changed * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added support for JDAA * */ -/* * * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * - added HLAPI function to copy chunks * */ -/* * 1.0.5 - 09/14/2002 - G.Juyn * */ -/* * - added event handling for dynamic MNG * */ -/* * 1.0.5 - 10/04/2002 - G.Juyn * */ -/* * - fixed chunk-storage for evNT chunk * */ -/* * 1.0.5 - 10/17/2002 - G.Juyn * */ -/* * - fixed issue in freeing evNT chunk * */ -/* * * */ -/* * 1.0.6 - 07/07/2003 - G.R-P * */ -/* * - added MNG_SKIPCHUNK_cHNK footprint optimizations * */ -/* * - added MNG_NO_DELTA_PNG reduction feature * */ -/* * 1.0.6 - 07/14/2003 - G.R-P * */ -/* * - added MNG_NO_LOOP_SIGNALS_SUPPORTED conditional * */ -/* * 1.0.6 - 07/29/2003 - G.R-P * */ -/* * - added conditionals around PAST chunk support * */ -/* * 1.0.6 - 08/17/2003 - G.R-P * */ -/* * - added conditionals around non-VLC chunk support * */ -/* * * */ -/* * 1.0.7 - 03/24/2004 - G.R-P * */ -/* * - fixed SKIPCHUNK_eXPI -> fPRI typo * */ -/* * * */ -/* * 1.0.9 - 09/25/2004 - G.Juyn * */ -/* * - replaced MNG_TWEAK_LARGE_FILES with permanent solution * */ -/* * 1.0.9 - 12/05/2004 - G.Juyn * */ -/* * - added conditional MNG_OPTIMIZE_CHUNKINITFREE * */ -/* * 1.0.9 - 12/06/2004 - G.Juyn * */ -/* * - added conditional MNG_OPTIMIZE_CHUNKASSIGN * */ -/* * 1.0.9 - 12/20/2004 - G.Juyn * */ -/* * - cleaned up macro-invocations (thanks to D. Airlie) * */ -/* * * */ -/* * 1.0.10 - 07/30/2005 - G.Juyn * */ -/* * - fixed problem with CLON object during readdisplay() * */ -/* * 1.0.10 - 04/08/2007 - G.Juyn * */ -/* * - added support for mPNG proposal * */ -/* * 1.0.10 - 04/12/2007 - G.Juyn * */ -/* * - added support for ANG proposal * */ -/* * * */ -/* ************************************************************************** */ - -#include "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_prc.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ -/* * * */ -/* * General chunk routines * */ -/* * * */ -/* ************************************************************************** */ - -void mng_add_chunk (mng_datap pData, - mng_chunkp pChunk) -{ - if (!pData->pFirstchunk) /* list is still empty ? */ - { - pData->pFirstchunk = pChunk; /* then this becomes the first */ - -#ifdef MNG_SUPPORT_WRITE - if (!pData->iFirstchunkadded) - { - pData->iFirstchunkadded = ((mng_chunk_headerp)pChunk)->iChunkname; -#endif - - if (((mng_chunk_headerp)pChunk)->iChunkname == MNG_UINT_IHDR) - pData->eImagetype = mng_it_png; - else -#ifdef MNG_INCLUDE_JNG - if (((mng_chunk_headerp)pChunk)->iChunkname == MNG_UINT_JHDR) - pData->eImagetype = mng_it_jng; - else -#endif - pData->eImagetype = mng_it_mng; - - pData->eSigtype = pData->eImagetype; -#ifdef MNG_SUPPORT_WRITE - } -#endif - } - else - { /* else we make appropriate links */ - ((mng_chunk_headerp)pChunk)->pPrev = pData->pLastchunk; - ((mng_chunk_headerp)pData->pLastchunk)->pNext = pChunk; - } - - pData->pLastchunk = pChunk; /* and it's always the last */ - - return; -} - -/* ************************************************************************** */ -/* * * */ -/* * Chunk specific initialization routines * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_OPTIMIZE_CHUNKINITFREE -INIT_CHUNK_HDR (mng_init_general) -{ - MNG_ALLOC (pData, *ppChunk, ((mng_chunk_headerp)pHeader)->iChunksize); - MNG_COPY (*ppChunk, pHeader, sizeof (mng_chunk_header)); - return MNG_NOERROR; -} - -#else /* MNG_OPTIMIZE_CHUNKINITFREE */ - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (mng_init_ihdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IHDR, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_ihdr)); - ((mng_ihdrp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (mng_init_plte) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PLTE, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_plte)); - ((mng_pltep)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PLTE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (mng_init_idat) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDAT, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_idat)); - ((mng_idatp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDAT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (mng_init_iend) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IEND, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_iend)); - ((mng_iendp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IEND, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (mng_init_trns) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_TRNS, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_trns)); - ((mng_trnsp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_TRNS, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_gAMA -INIT_CHUNK_HDR (mng_init_gama) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GAMA, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_gama)); - ((mng_gamap)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GAMA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_cHRM -INIT_CHUNK_HDR (mng_init_chrm) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_CHRM, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_chrm)); - ((mng_chrmp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_CHRM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_sRGB -INIT_CHUNK_HDR (mng_init_srgb) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SRGB, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_srgb)); - ((mng_srgbp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SRGB, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_iCCP -INIT_CHUNK_HDR (mng_init_iccp) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ICCP, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_iccp)); - ((mng_iccpp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ICCP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_tEXt -INIT_CHUNK_HDR (mng_init_text) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_TEXT, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_text)); - ((mng_textp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_TEXT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_zTXt -INIT_CHUNK_HDR (mng_init_ztxt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ZTXT, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_ztxt)); - ((mng_ztxtp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ZTXT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_iTXt -INIT_CHUNK_HDR (mng_init_itxt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ITXT, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_itxt)); - ((mng_itxtp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ITXT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_bKGD -INIT_CHUNK_HDR (mng_init_bkgd) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_BKGD, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_bkgd)); - ((mng_bkgdp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_BKGD, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_pHYs -INIT_CHUNK_HDR (mng_init_phys) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PHYS, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_phys)); - ((mng_physp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PHYS, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_sBIT -INIT_CHUNK_HDR (mng_init_sbit) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SBIT, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_sbit)); - ((mng_sbitp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SBIT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_sPLT -INIT_CHUNK_HDR (mng_init_splt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SPLT, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_splt)); - ((mng_spltp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SPLT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_hIST -INIT_CHUNK_HDR (mng_init_hist) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_HIST, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_hist)); - ((mng_histp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_HIST, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_tIME -INIT_CHUNK_HDR (mng_init_time) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_TIME, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_time)); - ((mng_timep)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_TIME, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (mng_init_mhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_MHDR, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_mhdr)); - ((mng_mhdrp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_MHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (mng_init_mend) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_MEND, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_mend)); - ((mng_mendp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_MEND, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_LOOP -INIT_CHUNK_HDR (mng_init_loop) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_LOOP, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_loop)); - ((mng_loopp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_LOOP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (mng_init_endl) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ENDL, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_endl)); - ((mng_endlp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ENDL, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_DEFI -INIT_CHUNK_HDR (mng_init_defi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DEFI, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_defi)); - ((mng_defip)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DEFI, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_BASI -INIT_CHUNK_HDR (mng_init_basi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_BASI, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_basi)); - ((mng_basip)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_BASI, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_CLON -INIT_CHUNK_HDR (mng_init_clon) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_CLON, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_clon)); - ((mng_clonp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_CLON, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_PAST -INIT_CHUNK_HDR (mng_init_past) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PAST, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_past)); - ((mng_pastp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PAST, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_DISC -INIT_CHUNK_HDR (mng_init_disc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DISC, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_disc)); - ((mng_discp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DISC, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_BACK -INIT_CHUNK_HDR (mng_init_back) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_BACK, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_back)); - ((mng_backp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_BACK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_FRAM -INIT_CHUNK_HDR (mng_init_fram) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_FRAM, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_fram)); - ((mng_framp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_FRAM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_MOVE -INIT_CHUNK_HDR (mng_init_move) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_MOVE, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_move)); - ((mng_movep)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_MOVE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_CLIP -INIT_CHUNK_HDR (mng_init_clip) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_CLIP, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_clip)); - ((mng_clipp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_CLIP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SHOW -INIT_CHUNK_HDR (mng_init_show) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SHOW, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_show)); - ((mng_showp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SHOW, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_TERM -INIT_CHUNK_HDR (mng_init_term) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_TERM, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_term)); - ((mng_termp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_TERM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SAVE -INIT_CHUNK_HDR (mng_init_save) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SAVE, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_save)); - ((mng_savep)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SAVE, MNG_LC_END); -#endif - - return MNG_NOERROR; - -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SEEK -INIT_CHUNK_HDR (mng_init_seek) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SEEK, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_seek)); - ((mng_seekp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SEEK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_eXPI -INIT_CHUNK_HDR (mng_init_expi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_EXPI, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_expi)); - ((mng_expip)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_EXPI, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_fPRI -INIT_CHUNK_HDR (mng_init_fpri) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_FPRI, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_fpri)); - ((mng_fprip)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_FPRI, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_nEED -INIT_CHUNK_HDR (mng_init_need) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_NEED, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_need)); - ((mng_needp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_NEED, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_pHYg -INIT_CHUNK_HDR (mng_init_phyg) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PHYG, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_phyg)); - ((mng_phygp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PHYG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -INIT_CHUNK_HDR (mng_init_jhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JHDR, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_jhdr)); - ((mng_jhdrp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -INIT_CHUNK_HDR (mng_init_jdaa) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JDAA, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_jdaa)); - ((mng_jdaap)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JDAA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -INIT_CHUNK_HDR (mng_init_jdat) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JDAT, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_jdat)); - ((mng_jdatp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JDAT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -INIT_CHUNK_HDR (mng_init_jsep) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JSEP, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_jsep)); - ((mng_jsepp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JSEP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -INIT_CHUNK_HDR (mng_init_dhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DHDR, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_dhdr)); - ((mng_dhdrp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -INIT_CHUNK_HDR (mng_init_prom) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PROM, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_prom)); - ((mng_promp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PROM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -INIT_CHUNK_HDR (mng_init_ipng) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IPNG, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_ipng)); - ((mng_ipngp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IPNG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -INIT_CHUNK_HDR (mng_init_pplt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PPLT, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_pplt)); - ((mng_ppltp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PPLT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifdef MNG_INCLUDE_JNG -INIT_CHUNK_HDR (mng_init_ijng) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IJNG, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_ijng)); - ((mng_ijngp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IJNG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -INIT_CHUNK_HDR (mng_init_drop) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DROP, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_drop)); - ((mng_dropp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DROP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_DBYK -INIT_CHUNK_HDR (mng_init_dbyk) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DBYK, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_dbyk)); - ((mng_dbykp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DBYK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_ORDR -INIT_CHUNK_HDR (mng_init_ordr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ORDR, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_ordr)); - ((mng_ordrp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ORDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_MAGN -INIT_CHUNK_HDR (mng_init_magn) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_MAGN, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_magn)); - ((mng_magnp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_MAGN, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_evNT -INIT_CHUNK_HDR (mng_init_evnt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_EVNT, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_evnt)); - ((mng_evntp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_EVNT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (mng_init_unknown) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_UNKNOWN, MNG_LC_START); -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_unknown_chunk)); - ((mng_unknown_chunkp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_UNKNOWN, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_OPTIMIZE_CHUNKINITFREE */ - -/* ************************************************************************** */ -/* * * */ -/* * Chunk specific cleanup routines * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_OPTIMIZE_CHUNKINITFREE -FREE_CHUNK_HDR (mng_free_general) -{ - MNG_FREEX (pData, pHeader, ((mng_chunk_headerp)pHeader)->iChunksize); - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -FREE_CHUNK_HDR (mng_free_ihdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IHDR, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_ihdr)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -FREE_CHUNK_HDR (mng_free_plte) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PLTE, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_plte)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PLTE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (mng_free_idat) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IDAT, MNG_LC_START); -#endif - - if (((mng_idatp)pHeader)->iDatasize) - MNG_FREEX (pData, ((mng_idatp)pHeader)->pData, - ((mng_idatp)pHeader)->iDatasize); - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - MNG_FREEX (pData, pHeader, sizeof (mng_idat)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IDAT, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - return MNG_NOERROR; -#else - return mng_free_general(pData, pHeader); -#endif -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -FREE_CHUNK_HDR (mng_free_iend) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IEND, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_iend)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IEND, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -FREE_CHUNK_HDR (mng_free_trns) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_TRNS, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_trns)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_TRNS, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifndef MNG_SKIPCHUNK_gAMA -FREE_CHUNK_HDR (mng_free_gama) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_GAMA, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_gama)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_GAMA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifndef MNG_SKIPCHUNK_cHRM -FREE_CHUNK_HDR (mng_free_chrm) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_CHRM, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_chrm)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_CHRM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifndef MNG_SKIPCHUNK_sRGB -FREE_CHUNK_HDR (mng_free_srgb) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SRGB, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_srgb)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SRGB, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_iCCP -FREE_CHUNK_HDR (mng_free_iccp) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ICCP, MNG_LC_START); -#endif - - if (((mng_iccpp)pHeader)->iNamesize) - MNG_FREEX (pData, ((mng_iccpp)pHeader)->zName, - ((mng_iccpp)pHeader)->iNamesize + 1); - - if (((mng_iccpp)pHeader)->iProfilesize) - MNG_FREEX (pData, ((mng_iccpp)pHeader)->pProfile, - ((mng_iccpp)pHeader)->iProfilesize); - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - MNG_FREEX (pData, pHeader, sizeof (mng_iccp)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ICCP, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - return MNG_NOERROR; -#else - return mng_free_general(pData, pHeader); -#endif -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_tEXt -FREE_CHUNK_HDR (mng_free_text) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_TEXT, MNG_LC_START); -#endif - - if (((mng_textp)pHeader)->iKeywordsize) - MNG_FREEX (pData, ((mng_textp)pHeader)->zKeyword, - ((mng_textp)pHeader)->iKeywordsize + 1); - - if (((mng_textp)pHeader)->iTextsize) - MNG_FREEX (pData, ((mng_textp)pHeader)->zText, - ((mng_textp)pHeader)->iTextsize + 1); - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - MNG_FREEX (pData, pHeader, sizeof (mng_text)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_TEXT, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - return MNG_NOERROR; -#else - return mng_free_general(pData, pHeader); -#endif -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_zTXt -FREE_CHUNK_HDR (mng_free_ztxt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ZTXT, MNG_LC_START); -#endif - - if (((mng_ztxtp)pHeader)->iKeywordsize) - MNG_FREEX (pData, ((mng_ztxtp)pHeader)->zKeyword, - ((mng_ztxtp)pHeader)->iKeywordsize + 1); - - if (((mng_ztxtp)pHeader)->iTextsize) - MNG_FREEX (pData, ((mng_ztxtp)pHeader)->zText, - ((mng_ztxtp)pHeader)->iTextsize); - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - MNG_FREEX (pData, pHeader, sizeof (mng_ztxt)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ZTXT, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - return MNG_NOERROR; -#else - return mng_free_general(pData, pHeader); -#endif -} -#endif - -/* ************************************************************************** */ -#ifndef MNG_SKIPCHUNK_iTXt -FREE_CHUNK_HDR (mng_free_itxt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ITXT, MNG_LC_START); -#endif - - if (((mng_itxtp)pHeader)->iKeywordsize) - MNG_FREEX (pData, ((mng_itxtp)pHeader)->zKeyword, - ((mng_itxtp)pHeader)->iKeywordsize + 1); - - if (((mng_itxtp)pHeader)->iLanguagesize) - MNG_FREEX (pData, ((mng_itxtp)pHeader)->zLanguage, - ((mng_itxtp)pHeader)->iLanguagesize + 1); - - if (((mng_itxtp)pHeader)->iTranslationsize) - MNG_FREEX (pData, ((mng_itxtp)pHeader)->zTranslation, - ((mng_itxtp)pHeader)->iTranslationsize + 1); - - if (((mng_itxtp)pHeader)->iTextsize) - MNG_FREEX (pData, ((mng_itxtp)pHeader)->zText, - ((mng_itxtp)pHeader)->iTextsize); - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - MNG_FREEX (pData, pHeader, sizeof (mng_itxt)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ITXT, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - return MNG_NOERROR; -#else - return mng_free_general(pData, pHeader); -#endif -} -#endif - -/* ************************************************************************** */ -#ifdef MNG_INCLUDE_MPNG_PROPOSAL -FREE_CHUNK_HDR (mng_free_mpng) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MPNG, MNG_LC_START); -#endif - - if (((mng_mpngp)pHeader)->iFramessize) - MNG_FREEX (pData, ((mng_mpngp)pHeader)->pFrames, - ((mng_mpngp)pHeader)->iFramessize); - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - MNG_FREEX (pData, pHeader, sizeof (mng_mpng)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MPNG, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - return MNG_NOERROR; -#else - return mng_free_general(pData, pHeader); -#endif -} -#endif - -/* ************************************************************************** */ -#ifdef MNG_INCLUDE_ANG_PROPOSAL -FREE_CHUNK_HDR (mng_free_adat) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ADAT, MNG_LC_START); -#endif - - if (((mng_adatp)pHeader)->iTilessize) - MNG_FREEX (pData, ((mng_adatp)pHeader)->pTiles, ((mng_adatp)pHeader)->iTilessize); - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - MNG_FREEX (pData, pHeader, sizeof (mng_adat)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ADAT, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - return MNG_NOERROR; -#else - return mng_free_general(pData, pHeader); -#endif -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifndef MNG_SKIPCHUNK_bKGD -FREE_CHUNK_HDR (mng_free_bkgd) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_BKGD, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_bkgd)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_BKGD, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifndef MNG_SKIPCHUNK_pHYs -FREE_CHUNK_HDR (mng_free_phys) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PHYS, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_phys)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PHYS, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifndef MNG_SKIPCHUNK_sBIT -FREE_CHUNK_HDR (mng_free_sbit) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SBIT, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_sbit)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SBIT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_sPLT -FREE_CHUNK_HDR (mng_free_splt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SPLT, MNG_LC_START); -#endif - - if (((mng_spltp)pHeader)->iNamesize) - MNG_FREEX (pData, ((mng_spltp)pHeader)->zName, - ((mng_spltp)pHeader)->iNamesize + 1); - - if (((mng_spltp)pHeader)->iEntrycount) - MNG_FREEX (pData, ((mng_spltp)pHeader)->pEntries, - ((mng_spltp)pHeader)->iEntrycount * - (((mng_spltp)pHeader)->iSampledepth * 3 + sizeof (mng_uint16)) ); - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - MNG_FREEX (pData, pHeader, sizeof (mng_splt)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SPLT, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - return MNG_NOERROR; -#else - return mng_free_general(pData, pHeader); -#endif -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifndef MNG_SKIPCHUNK_hIST -FREE_CHUNK_HDR (mng_free_hist) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_HIST, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_hist)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_HIST, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifndef MNG_SKIPCHUNK_tIME -FREE_CHUNK_HDR (mng_free_time) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_TIME, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_time)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_TIME, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -FREE_CHUNK_HDR (mng_free_mhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MHDR, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_mhdr)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -FREE_CHUNK_HDR (mng_free_mend) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MEND, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_mend)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MEND, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_LOOP -FREE_CHUNK_HDR (mng_free_loop) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_LOOP, MNG_LC_START); -#endif - -#ifndef MNG_NO_LOOP_SIGNALS_SUPPORTED - if (((mng_loopp)pHeader)->iCount) - MNG_FREEX (pData, ((mng_loopp)pHeader)->pSignals, - ((mng_loopp)pHeader)->iCount * sizeof (mng_uint32) ); -#endif - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - MNG_FREEX (pData, pHeader, sizeof (mng_loop)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_LOOP, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - return MNG_NOERROR; -#else - return mng_free_general(pData, pHeader); -#endif -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -FREE_CHUNK_HDR (mng_free_endl) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ENDL, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_endl)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ENDL, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifndef MNG_SKIPCHUNK_DEFI -FREE_CHUNK_HDR (mng_free_defi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DEFI, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_defi)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DEFI, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifndef MNG_SKIPCHUNK_BASI -FREE_CHUNK_HDR (mng_free_basi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_BASI, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_basi)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_BASI, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifndef MNG_SKIPCHUNK_CLON -FREE_CHUNK_HDR (mng_free_clon) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_CLON, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_clon)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_CLON, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_PAST -FREE_CHUNK_HDR (mng_free_past) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PAST, MNG_LC_START); -#endif - - if (((mng_pastp)pHeader)->iCount) - MNG_FREEX (pData, ((mng_pastp)pHeader)->pSources, - ((mng_pastp)pHeader)->iCount * sizeof (mng_past_source) ); - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - MNG_FREEX (pData, pHeader, sizeof (mng_past)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PAST, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - return MNG_NOERROR; -#else - return mng_free_general(pData, pHeader); -#endif -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_DISC -FREE_CHUNK_HDR (mng_free_disc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DISC, MNG_LC_START); -#endif - - if (((mng_discp)pHeader)->iCount) - MNG_FREEX (pData, ((mng_discp)pHeader)->pObjectids, - ((mng_discp)pHeader)->iCount * sizeof (mng_uint16) ); - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - MNG_FREEX (pData, pHeader, sizeof (mng_disc)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DISC, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - return MNG_NOERROR; -#else - return mng_free_general(pData, pHeader); -#endif -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifndef MNG_SKIPCHUNK_BACK -FREE_CHUNK_HDR (mng_free_back) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_BACK, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_back)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_BACK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_FRAM -FREE_CHUNK_HDR (mng_free_fram) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_FRAM, MNG_LC_START); -#endif - - if (((mng_framp)pHeader)->iNamesize) - MNG_FREEX (pData, ((mng_framp)pHeader)->zName, - ((mng_framp)pHeader)->iNamesize + 1); - - if (((mng_framp)pHeader)->iCount) - MNG_FREEX (pData, ((mng_framp)pHeader)->pSyncids, - ((mng_framp)pHeader)->iCount * sizeof (mng_uint32) ); - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - MNG_FREEX (pData, pHeader, sizeof (mng_fram)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_FRAM, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - return MNG_NOERROR; -#else - return mng_free_general(pData, pHeader); -#endif -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifndef MNG_SKIPCHUNK_MOVE -FREE_CHUNK_HDR (mng_free_move) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MOVE, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_move)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MOVE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifndef MNG_SKIPCHUNK_CLIP -FREE_CHUNK_HDR (mng_free_clip) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_CLIP, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_clip)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_CLIP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifndef MNG_SKIPCHUNK_SHOW -FREE_CHUNK_HDR (mng_free_show) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SHOW, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_show)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SHOW, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifndef MNG_SKIPCHUNK_TERM -FREE_CHUNK_HDR (mng_free_term) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_TERM, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_term)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_TERM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SAVE -FREE_CHUNK_HDR (mng_free_save) -{ - mng_save_entryp pEntry = ((mng_savep)pHeader)->pEntries; - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SAVE, MNG_LC_START); -#endif - - for (iX = 0; iX < ((mng_savep)pHeader)->iCount; iX++) - { - if (pEntry->iNamesize) - MNG_FREEX (pData, pEntry->zName, pEntry->iNamesize); - - pEntry = pEntry + sizeof (mng_save_entry); - } - - if (((mng_savep)pHeader)->iCount) - MNG_FREEX (pData, ((mng_savep)pHeader)->pEntries, - ((mng_savep)pHeader)->iCount * sizeof (mng_save_entry) ); - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - MNG_FREEX (pData, pHeader, sizeof (mng_save)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SAVE, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - return MNG_NOERROR; -#else - return mng_free_general(pData, pHeader); -#endif -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SEEK -FREE_CHUNK_HDR (mng_free_seek) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SEEK, MNG_LC_START); -#endif - - if (((mng_seekp)pHeader)->iNamesize) - MNG_FREEX (pData, ((mng_seekp)pHeader)->zName, - ((mng_seekp)pHeader)->iNamesize + 1); - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - MNG_FREEX (pData, pHeader, sizeof (mng_seek)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SEEK, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - return MNG_NOERROR; -#else - return mng_free_general(pData, pHeader); -#endif -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_eXPI -FREE_CHUNK_HDR (mng_free_expi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_EXPI, MNG_LC_START); -#endif - - if (((mng_expip)pHeader)->iNamesize) - MNG_FREEX (pData, ((mng_expip)pHeader)->zName, - ((mng_expip)pHeader)->iNamesize + 1); - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - MNG_FREEX (pData, pHeader, sizeof (mng_expi)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_EXPI, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - return MNG_NOERROR; -#else - return mng_free_general(pData, pHeader); -#endif -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifndef MNG_SKIPCHUNK_fPRI -FREE_CHUNK_HDR (mng_free_fpri) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_FPRI, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_fpri)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_FPRI, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_nEED -FREE_CHUNK_HDR (mng_free_need) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_NEED, MNG_LC_START); -#endif - - if (((mng_needp)pHeader)->iKeywordssize) - MNG_FREEX (pData, ((mng_needp)pHeader)->zKeywords, - ((mng_needp)pHeader)->iKeywordssize + 1); - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - MNG_FREEX (pData, pHeader, sizeof (mng_need)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_NEED, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - return MNG_NOERROR; -#else - return mng_free_general(pData, pHeader); -#endif -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifndef MNG_SKIPCHUNK_pHYg -FREE_CHUNK_HDR (mng_free_phyg) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PHYG, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_phyg)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PHYG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifdef MNG_INCLUDE_JNG -FREE_CHUNK_HDR (mng_free_jhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_JHDR, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_jhdr)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_JHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -FREE_CHUNK_HDR (mng_free_jdaa) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_JDAA, MNG_LC_START); -#endif - - if (((mng_jdaap)pHeader)->iDatasize) - MNG_FREEX (pData, ((mng_jdaap)pHeader)->pData, - ((mng_jdaap)pHeader)->iDatasize); - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - MNG_FREEX (pData, pHeader, sizeof (mng_jdaa)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_JDAA, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - return MNG_NOERROR; -#else - return mng_free_general(pData, pHeader); -#endif -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -FREE_CHUNK_HDR (mng_free_jdat) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_JDAT, MNG_LC_START); -#endif - - if (((mng_jdatp)pHeader)->iDatasize) - MNG_FREEX (pData, ((mng_jdatp)pHeader)->pData, - ((mng_jdatp)pHeader)->iDatasize); - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - MNG_FREEX (pData, pHeader, sizeof (mng_jdat)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_JDAT, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - return MNG_NOERROR; -#else - return mng_free_general(pData, pHeader); -#endif -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifdef MNG_INCLUDE_JNG -FREE_CHUNK_HDR (mng_free_jsep) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_JSEP, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_jsep)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_JSEP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifndef MNG_NO_DELTA_PNG -FREE_CHUNK_HDR (mng_free_dhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DHDR, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_dhdr)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifndef MNG_NO_DELTA_PNG -FREE_CHUNK_HDR (mng_free_prom) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PROM, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_prom)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PROM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifndef MNG_NO_DELTA_PNG -FREE_CHUNK_HDR (mng_free_ipng) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IPNG, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_ipng)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IPNG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifndef MNG_NO_DELTA_PNG -FREE_CHUNK_HDR (mng_free_pplt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PPLT, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_pplt)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PPLT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifndef MNG_NO_DELTA_PNG -#ifdef MNG_INCLUDE_JNG -FREE_CHUNK_HDR (mng_free_ijng) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IJNG, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_ijng)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IJNG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -FREE_CHUNK_HDR (mng_free_drop) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DROP, MNG_LC_START); -#endif - - if (((mng_dropp)pHeader)->iCount) - MNG_FREEX (pData, ((mng_dropp)pHeader)->pChunknames, - ((mng_dropp)pHeader)->iCount * sizeof (mng_chunkid) ); - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - MNG_FREEX (pData, pHeader, sizeof (mng_drop)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DROP, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - return MNG_NOERROR; -#else - return mng_free_general(pData, pHeader); -#endif -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_DBYK -FREE_CHUNK_HDR (mng_free_dbyk) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DBYK, MNG_LC_START); -#endif - - if (((mng_dbykp)pHeader)->iKeywordssize) - MNG_FREEX (pData, ((mng_dbykp)pHeader)->zKeywords, - ((mng_dbykp)pHeader)->iKeywordssize); - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - MNG_FREEX (pData, pHeader, sizeof (mng_dbyk)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DBYK, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - return MNG_NOERROR; -#else - return mng_free_general(pData, pHeader); -#endif -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_ORDR -FREE_CHUNK_HDR (mng_free_ordr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ORDR, MNG_LC_START); -#endif - - if (((mng_ordrp)pHeader)->iCount) - MNG_FREEX (pData, ((mng_ordrp)pHeader)->pEntries, - ((mng_ordrp)pHeader)->iCount * sizeof (mng_ordr_entry) ); - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - MNG_FREEX (pData, pHeader, sizeof (mng_ordr)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ORDR, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - return MNG_NOERROR; -#else - return mng_free_general(pData, pHeader); -#endif -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE -#ifndef MNG_SKIPCHUNK_MAGN -FREE_CHUNK_HDR (mng_free_magn) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MAGN, MNG_LC_START); -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_magn)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MAGN, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_evNT -FREE_CHUNK_HDR (mng_free_evnt) -{ - mng_evnt_entryp pEntry = ((mng_evntp)pHeader)->pEntries; - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_EVNT, MNG_LC_START); -#endif - - for (iX = 0; iX < ((mng_evntp)pHeader)->iCount; iX++) - { - if (pEntry->iSegmentnamesize) - MNG_FREEX (pData, pEntry->zSegmentname, pEntry->iSegmentnamesize+1); - - pEntry++; - } - - if (((mng_evntp)pHeader)->iCount) - MNG_FREEX (pData, ((mng_evntp)pHeader)->pEntries, - ((mng_evntp)pHeader)->iCount * sizeof (mng_evnt_entry) ); - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - MNG_FREEX (pData, pHeader, sizeof (mng_evnt)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_EVNT, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - return MNG_NOERROR; -#else - return mng_free_general(pData, pHeader); -#endif -} -#endif - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (mng_free_unknown) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_UNKNOWN, MNG_LC_START); -#endif - - if (((mng_unknown_chunkp)pHeader)->iDatasize) - MNG_FREEX (pData, ((mng_unknown_chunkp)pHeader)->pData, - ((mng_unknown_chunkp)pHeader)->iDatasize); - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - MNG_FREEX (pData, pHeader, sizeof (mng_unknown_chunk)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_UNKNOWN, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_CHUNKINITFREE - return MNG_NOERROR; -#else - return mng_free_general(pData, pHeader); -#endif -} - -/* ************************************************************************** */ -/* * * */ -/* * Chunk specific copy routines * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_WRITE_PROCS - -/* ************************************************************************** */ - -#ifdef MNG_OPTIMIZE_CHUNKASSIGN -ASSIGN_CHUNK_HDR (mng_assign_general) -{ - mng_ptr pSrc = (mng_uint8p)pChunkfrom + sizeof (mng_chunk_header); - mng_ptr pDst = (mng_uint8p)pChunkto + sizeof (mng_chunk_header); - mng_size_t iLen = ((mng_chunk_headerp)pChunkfrom)->iChunksize - sizeof (mng_chunk_header); - - MNG_COPY (pDst, pSrc, iLen); - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -ASSIGN_CHUNK_HDR (mng_assign_ihdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_IHDR, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_IHDR) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_ihdrp)pChunkto)->iWidth = ((mng_ihdrp)pChunkfrom)->iWidth; - ((mng_ihdrp)pChunkto)->iHeight = ((mng_ihdrp)pChunkfrom)->iHeight; - ((mng_ihdrp)pChunkto)->iBitdepth = ((mng_ihdrp)pChunkfrom)->iBitdepth; - ((mng_ihdrp)pChunkto)->iColortype = ((mng_ihdrp)pChunkfrom)->iColortype; - ((mng_ihdrp)pChunkto)->iCompression = ((mng_ihdrp)pChunkfrom)->iCompression; - ((mng_ihdrp)pChunkto)->iFilter = ((mng_ihdrp)pChunkfrom)->iFilter; - ((mng_ihdrp)pChunkto)->iInterlace = ((mng_ihdrp)pChunkfrom)->iInterlace; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_IHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -ASSIGN_CHUNK_HDR (mng_assign_plte) -{ - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_PLTE, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_PLTE) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_pltep)pChunkto)->bEmpty = ((mng_pltep)pChunkfrom)->bEmpty; - ((mng_pltep)pChunkto)->iEntrycount = ((mng_pltep)pChunkfrom)->iEntrycount; - - for (iX = 0; iX < ((mng_pltep)pChunkto)->iEntrycount; iX++) - ((mng_pltep)pChunkto)->aEntries [iX] = ((mng_pltep)pChunkfrom)->aEntries [iX]; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_PLTE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -ASSIGN_CHUNK_HDR (mng_assign_idat) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_IDAT, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_IDAT) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_idatp)pChunkto)->bEmpty = ((mng_idatp)pChunkfrom)->bEmpty; - ((mng_idatp)pChunkto)->iDatasize = ((mng_idatp)pChunkfrom)->iDatasize; - - if (((mng_idatp)pChunkto)->iDatasize) - { - MNG_ALLOC (pData, ((mng_idatp)pChunkto)->pData, ((mng_idatp)pChunkto)->iDatasize); - MNG_COPY (((mng_idatp)pChunkto)->pData, ((mng_idatp)pChunkfrom)->pData, - ((mng_idatp)pChunkto)->iDatasize); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_IDAT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -ASSIGN_CHUNK_HDR (mng_assign_iend) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_IEND, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_IEND) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_IEND, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -ASSIGN_CHUNK_HDR (mng_assign_trns) -{ - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_TRNS, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_tRNS) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_trnsp)pChunkto)->bEmpty = ((mng_trnsp)pChunkfrom)->bEmpty; - ((mng_trnsp)pChunkto)->bGlobal = ((mng_trnsp)pChunkfrom)->bGlobal; - ((mng_trnsp)pChunkto)->iType = ((mng_trnsp)pChunkfrom)->iType; - ((mng_trnsp)pChunkto)->iCount = ((mng_trnsp)pChunkfrom)->iCount; - ((mng_trnsp)pChunkto)->iGray = ((mng_trnsp)pChunkfrom)->iGray; - ((mng_trnsp)pChunkto)->iRed = ((mng_trnsp)pChunkfrom)->iRed; - ((mng_trnsp)pChunkto)->iGreen = ((mng_trnsp)pChunkfrom)->iGreen; - ((mng_trnsp)pChunkto)->iBlue = ((mng_trnsp)pChunkfrom)->iBlue; - ((mng_trnsp)pChunkto)->iRawlen = ((mng_trnsp)pChunkfrom)->iRawlen; - - for (iX = 0; iX < ((mng_trnsp)pChunkto)->iCount; iX++) - ((mng_trnsp)pChunkto)->aEntries [iX] = ((mng_trnsp)pChunkfrom)->aEntries [iX]; - - for (iX = 0; iX < ((mng_trnsp)pChunkto)->iRawlen; iX++) - ((mng_trnsp)pChunkto)->aRawdata [iX] = ((mng_trnsp)pChunkfrom)->aRawdata [iX]; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_TRNS, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifndef MNG_SKIPCHUNK_gAMA -ASSIGN_CHUNK_HDR (mng_assign_gama) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_GAMA, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_gAMA) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_gamap)pChunkto)->bEmpty = ((mng_gamap)pChunkfrom)->bEmpty; - ((mng_gamap)pChunkto)->iGamma = ((mng_gamap)pChunkfrom)->iGamma; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_GAMA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifndef MNG_SKIPCHUNK_cHRM -ASSIGN_CHUNK_HDR (mng_assign_chrm) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_CHRM, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_cHRM) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_chrmp)pChunkto)->bEmpty = ((mng_chrmp)pChunkfrom)->bEmpty; - ((mng_chrmp)pChunkto)->iWhitepointx = ((mng_chrmp)pChunkfrom)->iWhitepointx; - ((mng_chrmp)pChunkto)->iWhitepointy = ((mng_chrmp)pChunkfrom)->iWhitepointy; - ((mng_chrmp)pChunkto)->iRedx = ((mng_chrmp)pChunkfrom)->iRedx; - ((mng_chrmp)pChunkto)->iRedy = ((mng_chrmp)pChunkfrom)->iRedy; - ((mng_chrmp)pChunkto)->iGreenx = ((mng_chrmp)pChunkfrom)->iGreenx; - ((mng_chrmp)pChunkto)->iGreeny = ((mng_chrmp)pChunkfrom)->iGreeny; - ((mng_chrmp)pChunkto)->iBluex = ((mng_chrmp)pChunkfrom)->iBluex; - ((mng_chrmp)pChunkto)->iBluey = ((mng_chrmp)pChunkfrom)->iBluey; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_CHRM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifndef MNG_SKIPCHUNK_sRGB -ASSIGN_CHUNK_HDR (mng_assign_srgb) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_SRGB, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_sRGB) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_srgbp)pChunkto)->iRenderingintent = ((mng_srgbp)pChunkfrom)->iRenderingintent; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_SRGB, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_iCCP -ASSIGN_CHUNK_HDR (mng_assign_iccp) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_ICCP, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_iCCP) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_iccpp)pChunkto)->bEmpty = ((mng_iccpp)pChunkfrom)->bEmpty; - ((mng_iccpp)pChunkto)->iNamesize = ((mng_iccpp)pChunkfrom)->iNamesize; - ((mng_iccpp)pChunkto)->iCompression = ((mng_iccpp)pChunkfrom)->iCompression; - ((mng_iccpp)pChunkto)->iProfilesize = ((mng_iccpp)pChunkfrom)->iProfilesize; - - if (((mng_iccpp)pChunkto)->iNamesize) - { - MNG_ALLOC (pData, ((mng_iccpp)pChunkto)->zName, ((mng_iccpp)pChunkto)->iNamesize); - MNG_COPY (((mng_iccpp)pChunkto)->zName, ((mng_iccpp)pChunkfrom)->zName, - ((mng_iccpp)pChunkto)->iNamesize); - } - - if (((mng_iccpp)pChunkto)->iProfilesize) - { - MNG_ALLOC (pData, ((mng_iccpp)pChunkto)->pProfile, ((mng_iccpp)pChunkto)->iProfilesize); - MNG_COPY (((mng_iccpp)pChunkto)->pProfile, ((mng_iccpp)pChunkfrom)->pProfile, - ((mng_iccpp)pChunkto)->iProfilesize); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_ICCP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_tEXt -ASSIGN_CHUNK_HDR (mng_assign_text) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_TEXT, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_tEXt) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_textp)pChunkto)->iKeywordsize = ((mng_textp)pChunkfrom)->iKeywordsize; - ((mng_textp)pChunkto)->iTextsize = ((mng_textp)pChunkfrom)->iTextsize; - - if (((mng_textp)pChunkto)->iKeywordsize) - { - MNG_ALLOC (pData, ((mng_itxtp)pChunkto)->zKeyword, ((mng_textp)pChunkto)->iKeywordsize); - MNG_COPY (((mng_itxtp)pChunkto)->zKeyword, ((mng_textp)pChunkfrom)->zKeyword, - ((mng_itxtp)pChunkto)->iKeywordsize); - } - - if (((mng_textp)pChunkto)->iTextsize) - { - MNG_ALLOC (pData, ((mng_textp)pChunkto)->zText, ((mng_textp)pChunkto)->iTextsize); - MNG_COPY (((mng_textp)pChunkto)->zText, ((mng_textp)pChunkfrom)->zText, - ((mng_textp)pChunkto)->iTextsize); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_TEXT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_zTXt -ASSIGN_CHUNK_HDR (mng_assign_ztxt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_ZTXT, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_zTXt) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_ztxtp)pChunkto)->iKeywordsize = ((mng_ztxtp)pChunkfrom)->iKeywordsize; - ((mng_ztxtp)pChunkto)->iCompression = ((mng_ztxtp)pChunkfrom)->iCompression; - ((mng_ztxtp)pChunkto)->iTextsize = ((mng_ztxtp)pChunkfrom)->iTextsize; - - if (((mng_ztxtp)pChunkto)->iKeywordsize) - { - MNG_ALLOC (pData, ((mng_ztxtp)pChunkto)->zKeyword, ((mng_ztxtp)pChunkto)->iKeywordsize); - MNG_COPY (((mng_ztxtp)pChunkto)->zKeyword, ((mng_ztxtp)pChunkfrom)->zKeyword, - ((mng_ztxtp)pChunkto)->iKeywordsize); - } - - if (((mng_ztxtp)pChunkto)->iTextsize) - { - MNG_ALLOC (pData, ((mng_ztxtp)pChunkto)->zText, ((mng_ztxtp)pChunkto)->iTextsize); - MNG_COPY (((mng_ztxtp)pChunkto)->zText, ((mng_ztxtp)pChunkfrom)->zText, - ((mng_ztxtp)pChunkto)->iTextsize); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_ZTXT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_iTXt -ASSIGN_CHUNK_HDR (mng_assign_itxt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_ITXT, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_iTXt) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_itxtp)pChunkto)->iKeywordsize = ((mng_itxtp)pChunkfrom)->iKeywordsize; - ((mng_itxtp)pChunkto)->iCompressionflag = ((mng_itxtp)pChunkfrom)->iCompressionflag; - ((mng_itxtp)pChunkto)->iCompressionmethod = ((mng_itxtp)pChunkfrom)->iCompressionmethod; - ((mng_itxtp)pChunkto)->iLanguagesize = ((mng_itxtp)pChunkfrom)->iLanguagesize; - ((mng_itxtp)pChunkto)->iTranslationsize = ((mng_itxtp)pChunkfrom)->iTranslationsize; - ((mng_itxtp)pChunkto)->iTextsize = ((mng_itxtp)pChunkfrom)->iTextsize; - - if (((mng_itxtp)pChunkto)->iKeywordsize) - { - MNG_ALLOC (pData, ((mng_itxtp)pChunkto)->zKeyword, ((mng_itxtp)pChunkto)->iKeywordsize); - MNG_COPY (((mng_itxtp)pChunkto)->zKeyword, ((mng_itxtp)pChunkfrom)->zKeyword, - ((mng_itxtp)pChunkto)->iKeywordsize); - } - - if (((mng_itxtp)pChunkto)->iTextsize) - { - MNG_ALLOC (pData, ((mng_itxtp)pChunkto)->zLanguage, ((mng_itxtp)pChunkto)->iLanguagesize); - MNG_COPY (((mng_itxtp)pChunkto)->zLanguage, ((mng_itxtp)pChunkfrom)->zLanguage, - ((mng_itxtp)pChunkto)->iLanguagesize); - } - - if (((mng_itxtp)pChunkto)->iTextsize) - { - MNG_ALLOC (pData, ((mng_itxtp)pChunkto)->zTranslation, ((mng_itxtp)pChunkto)->iTranslationsize); - MNG_COPY (((mng_itxtp)pChunkto)->zTranslation, ((mng_itxtp)pChunkfrom)->zTranslation, - ((mng_itxtp)pChunkto)->iTranslationsize); - } - - if (((mng_itxtp)pChunkto)->iTextsize) - { - MNG_ALLOC (pData, ((mng_itxtp)pChunkto)->zText, ((mng_itxtp)pChunkto)->iTextsize); - MNG_COPY (((mng_itxtp)pChunkto)->zText, ((mng_itxtp)pChunkfrom)->zText, - ((mng_itxtp)pChunkto)->iTextsize); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_ITXT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifndef MNG_SKIPCHUNK_bKGD -ASSIGN_CHUNK_HDR (mng_assign_bkgd) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_BKGD, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_bKGD) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_bkgdp)pChunkto)->bEmpty = ((mng_bkgdp)pChunkfrom)->bEmpty; - ((mng_bkgdp)pChunkto)->iType = ((mng_bkgdp)pChunkfrom)->iType; - ((mng_bkgdp)pChunkto)->iIndex = ((mng_bkgdp)pChunkfrom)->iIndex; - ((mng_bkgdp)pChunkto)->iGray = ((mng_bkgdp)pChunkfrom)->iGray; - ((mng_bkgdp)pChunkto)->iRed = ((mng_bkgdp)pChunkfrom)->iRed; - ((mng_bkgdp)pChunkto)->iGreen = ((mng_bkgdp)pChunkfrom)->iGreen; - ((mng_bkgdp)pChunkto)->iBlue = ((mng_bkgdp)pChunkfrom)->iBlue; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_BKGD, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifndef MNG_SKIPCHUNK_pHYs -ASSIGN_CHUNK_HDR (mng_assign_phys) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_PHYS, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_pHYs) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_physp)pChunkto)->bEmpty = ((mng_physp)pChunkfrom)->bEmpty; - ((mng_physp)pChunkto)->iSizex = ((mng_physp)pChunkfrom)->iSizex; - ((mng_physp)pChunkto)->iSizey = ((mng_physp)pChunkfrom)->iSizey; - ((mng_physp)pChunkto)->iUnit = ((mng_physp)pChunkfrom)->iUnit; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_PHYS, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifndef MNG_SKIPCHUNK_sBIT -ASSIGN_CHUNK_HDR (mng_assign_sbit) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_SBIT, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_sBIT) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_sbitp)pChunkto)->bEmpty = ((mng_sbitp)pChunkfrom)->bEmpty; - ((mng_sbitp)pChunkto)->iType = ((mng_sbitp)pChunkfrom)->iType; - ((mng_sbitp)pChunkto)->aBits [0] = ((mng_sbitp)pChunkfrom)->aBits [0]; - ((mng_sbitp)pChunkto)->aBits [1] = ((mng_sbitp)pChunkfrom)->aBits [1]; - ((mng_sbitp)pChunkto)->aBits [2] = ((mng_sbitp)pChunkfrom)->aBits [2]; - ((mng_sbitp)pChunkto)->aBits [3] = ((mng_sbitp)pChunkfrom)->aBits [3]; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_SBIT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_sPLT -ASSIGN_CHUNK_HDR (mng_assign_splt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_SPLT, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_sPLT) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_spltp)pChunkto)->bEmpty = ((mng_spltp)pChunkfrom)->bEmpty; - ((mng_spltp)pChunkto)->iNamesize = ((mng_spltp)pChunkfrom)->iNamesize; - ((mng_spltp)pChunkto)->iSampledepth = ((mng_spltp)pChunkfrom)->iSampledepth; - ((mng_spltp)pChunkto)->iEntrycount = ((mng_spltp)pChunkfrom)->iEntrycount; - ((mng_spltp)pChunkto)->pEntries = ((mng_spltp)pChunkfrom)->pEntries; - - if (((mng_spltp)pChunkto)->iNamesize) - { - MNG_ALLOC (pData, ((mng_spltp)pChunkto)->zName, ((mng_spltp)pChunkto)->iNamesize); - MNG_COPY (((mng_spltp)pChunkto)->zName, ((mng_spltp)pChunkfrom)->zName, - ((mng_spltp)pChunkto)->iNamesize); - } - - if (((mng_spltp)pChunkto)->iEntrycount) - { - mng_uint32 iLen = ((mng_spltp)pChunkto)->iEntrycount * - (((mng_spltp)pChunkto)->iSampledepth * 3 + sizeof (mng_uint16)); - - MNG_ALLOC (pData, ((mng_spltp)pChunkto)->pEntries, iLen); - MNG_COPY (((mng_spltp)pChunkto)->pEntries, ((mng_spltp)pChunkfrom)->pEntries, iLen); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_SPLT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifndef MNG_SKIPCHUNK_hIST -ASSIGN_CHUNK_HDR (mng_assign_hist) -{ - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_HIST, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_hIST) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_histp)pChunkto)->iEntrycount = ((mng_histp)pChunkfrom)->iEntrycount; - - for (iX = 0; iX < ((mng_histp)pChunkto)->iEntrycount; iX++) - ((mng_histp)pChunkto)->aEntries [iX] = ((mng_histp)pChunkfrom)->aEntries [iX]; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_HIST, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifndef MNG_SKIPCHUNK_tIME -ASSIGN_CHUNK_HDR (mng_assign_time) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_TIME, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_tIME) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_timep)pChunkto)->iYear = ((mng_timep)pChunkfrom)->iYear; - ((mng_timep)pChunkto)->iMonth = ((mng_timep)pChunkfrom)->iMonth; - ((mng_timep)pChunkto)->iDay = ((mng_timep)pChunkfrom)->iDay; - ((mng_timep)pChunkto)->iHour = ((mng_timep)pChunkfrom)->iHour; - ((mng_timep)pChunkto)->iMinute = ((mng_timep)pChunkfrom)->iMinute; - ((mng_timep)pChunkto)->iSecond = ((mng_timep)pChunkfrom)->iSecond; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_TIME, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -ASSIGN_CHUNK_HDR (mng_assign_mhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_MHDR, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_mhdrp)pChunkto)->iWidth = ((mng_mhdrp)pChunkfrom)->iWidth; - ((mng_mhdrp)pChunkto)->iHeight = ((mng_mhdrp)pChunkfrom)->iHeight; - ((mng_mhdrp)pChunkto)->iTicks = ((mng_mhdrp)pChunkfrom)->iTicks; - ((mng_mhdrp)pChunkto)->iLayercount = ((mng_mhdrp)pChunkfrom)->iLayercount; - ((mng_mhdrp)pChunkto)->iFramecount = ((mng_mhdrp)pChunkfrom)->iFramecount; - ((mng_mhdrp)pChunkto)->iPlaytime = ((mng_mhdrp)pChunkfrom)->iPlaytime; - ((mng_mhdrp)pChunkto)->iSimplicity = ((mng_mhdrp)pChunkfrom)->iSimplicity; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_MHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -ASSIGN_CHUNK_HDR (mng_assign_mend) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_MEND, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_MEND) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_MEND, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_LOOP -ASSIGN_CHUNK_HDR (mng_assign_loop) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_LOOP, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_LOOP) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_loopp)pChunkto)->iLevel = ((mng_loopp)pChunkfrom)->iLevel; - ((mng_loopp)pChunkto)->iRepeat = ((mng_loopp)pChunkfrom)->iRepeat; - ((mng_loopp)pChunkto)->iTermination = ((mng_loopp)pChunkfrom)->iTermination; - ((mng_loopp)pChunkto)->iItermin = ((mng_loopp)pChunkfrom)->iItermin; - ((mng_loopp)pChunkto)->iItermax = ((mng_loopp)pChunkfrom)->iItermax; - ((mng_loopp)pChunkto)->iCount = ((mng_loopp)pChunkfrom)->iCount; - -#ifndef MNG_NO_LOOP_SIGNALS_SUPPORTED - if (((mng_loopp)pChunkto)->iCount) - { - mng_uint32 iLen = ((mng_loopp)pChunkto)->iCount * sizeof (mng_uint32); - MNG_ALLOC (pData, ((mng_loopp)pChunkto)->pSignals, iLen); - MNG_COPY (((mng_loopp)pChunkto)->pSignals, ((mng_loopp)pChunkfrom)->pSignals, iLen); - } -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_LOOP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -ASSIGN_CHUNK_HDR (mng_assign_endl) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_ENDL, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_ENDL) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_endlp)pChunkto)->iLevel = ((mng_endlp)pChunkfrom)->iLevel; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_ENDL, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifndef MNG_SKIPCHUNK_DEFI -ASSIGN_CHUNK_HDR (mng_assign_defi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_DEFI, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_DEFI) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_defip)pChunkto)->iObjectid = ((mng_defip)pChunkfrom)->iObjectid; - ((mng_defip)pChunkto)->bHasdonotshow = ((mng_defip)pChunkfrom)->bHasdonotshow; - ((mng_defip)pChunkto)->iDonotshow = ((mng_defip)pChunkfrom)->iDonotshow; - ((mng_defip)pChunkto)->bHasconcrete = ((mng_defip)pChunkfrom)->bHasconcrete; - ((mng_defip)pChunkto)->iConcrete = ((mng_defip)pChunkfrom)->iConcrete; - ((mng_defip)pChunkto)->bHasloca = ((mng_defip)pChunkfrom)->bHasloca; - ((mng_defip)pChunkto)->iXlocation = ((mng_defip)pChunkfrom)->iXlocation; - ((mng_defip)pChunkto)->iYlocation = ((mng_defip)pChunkfrom)->iYlocation; - ((mng_defip)pChunkto)->bHasclip = ((mng_defip)pChunkfrom)->bHasclip; - ((mng_defip)pChunkto)->iLeftcb = ((mng_defip)pChunkfrom)->iLeftcb; - ((mng_defip)pChunkto)->iRightcb = ((mng_defip)pChunkfrom)->iRightcb; - ((mng_defip)pChunkto)->iTopcb = ((mng_defip)pChunkfrom)->iTopcb; - ((mng_defip)pChunkto)->iBottomcb = ((mng_defip)pChunkfrom)->iBottomcb; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_DEFI, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifndef MNG_SKIPCHUNK_BASI -ASSIGN_CHUNK_HDR (mng_assign_basi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_BASI, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_BASI) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_basip)pChunkto)->iWidth = ((mng_basip)pChunkfrom)->iWidth; - ((mng_basip)pChunkto)->iHeight = ((mng_basip)pChunkfrom)->iHeight; - ((mng_basip)pChunkto)->iBitdepth = ((mng_basip)pChunkfrom)->iBitdepth; - ((mng_basip)pChunkto)->iColortype = ((mng_basip)pChunkfrom)->iColortype; - ((mng_basip)pChunkto)->iCompression = ((mng_basip)pChunkfrom)->iCompression; - ((mng_basip)pChunkto)->iFilter = ((mng_basip)pChunkfrom)->iFilter; - ((mng_basip)pChunkto)->iInterlace = ((mng_basip)pChunkfrom)->iInterlace; - ((mng_basip)pChunkto)->iRed = ((mng_basip)pChunkfrom)->iRed; - ((mng_basip)pChunkto)->iGreen = ((mng_basip)pChunkfrom)->iGreen; - ((mng_basip)pChunkto)->iBlue = ((mng_basip)pChunkfrom)->iBlue; - ((mng_basip)pChunkto)->iAlpha = ((mng_basip)pChunkfrom)->iAlpha; - ((mng_basip)pChunkto)->iViewable = ((mng_basip)pChunkfrom)->iViewable; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_BASI, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifndef MNG_SKIPCHUNK_CLON -ASSIGN_CHUNK_HDR (mng_assign_clon) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_CLON, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_CLON) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_clonp)pChunkto)->iSourceid = ((mng_clonp)pChunkfrom)->iSourceid; - ((mng_clonp)pChunkto)->iCloneid = ((mng_clonp)pChunkfrom)->iCloneid; - ((mng_clonp)pChunkto)->iClonetype = ((mng_clonp)pChunkfrom)->iClonetype; -#ifdef MNG_OPTIMIZE_CHUNKREADER - ((mng_clonp)pChunkto)->bHasdonotshow = ((mng_clonp)pChunkfrom)->bHasdonotshow; -#endif - ((mng_clonp)pChunkto)->iDonotshow = ((mng_clonp)pChunkfrom)->iDonotshow; - ((mng_clonp)pChunkto)->iConcrete = ((mng_clonp)pChunkfrom)->iConcrete; - ((mng_clonp)pChunkto)->bHasloca = ((mng_clonp)pChunkfrom)->bHasloca; - ((mng_clonp)pChunkto)->iLocationtype = ((mng_clonp)pChunkfrom)->iLocationtype; - ((mng_clonp)pChunkto)->iLocationx = ((mng_clonp)pChunkfrom)->iLocationx; - ((mng_clonp)pChunkto)->iLocationy = ((mng_clonp)pChunkfrom)->iLocationy; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_CLON, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_PAST -ASSIGN_CHUNK_HDR (mng_assign_past) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_PAST, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_PAST) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_pastp)pChunkto)->iDestid = ((mng_pastp)pChunkfrom)->iDestid; - ((mng_pastp)pChunkto)->iTargettype = ((mng_pastp)pChunkfrom)->iTargettype; - ((mng_pastp)pChunkto)->iTargetx = ((mng_pastp)pChunkfrom)->iTargetx; - ((mng_pastp)pChunkto)->iTargety = ((mng_pastp)pChunkfrom)->iTargety; - ((mng_pastp)pChunkto)->iCount = ((mng_pastp)pChunkfrom)->iCount; - - if (((mng_pastp)pChunkto)->iCount) - { - mng_uint32 iLen = ((mng_pastp)pChunkto)->iCount * sizeof (mng_past_source); - - MNG_ALLOC (pData, ((mng_pastp)pChunkto)->pSources, iLen); - MNG_COPY (((mng_pastp)pChunkto)->pSources, ((mng_pastp)pChunkfrom)->pSources, iLen); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_PAST, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_DISC -ASSIGN_CHUNK_HDR (mng_assign_disc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_DISC, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_DISC) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_discp)pChunkto)->iCount = ((mng_discp)pChunkfrom)->iCount; - - if (((mng_discp)pChunkto)->iCount) - { - mng_uint32 iLen = ((mng_discp)pChunkto)->iCount * sizeof (mng_uint16); - - MNG_ALLOC (pData, ((mng_discp)pChunkto)->pObjectids, iLen); - MNG_COPY (((mng_discp)pChunkto)->pObjectids, ((mng_discp)pChunkfrom)->pObjectids, iLen); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_DISC, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifndef MNG_SKIPCHUNK_BACK -ASSIGN_CHUNK_HDR (mng_assign_back) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_BACK, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_BACK) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_backp)pChunkto)->iRed = ((mng_backp)pChunkfrom)->iRed; - ((mng_backp)pChunkto)->iGreen = ((mng_backp)pChunkfrom)->iGreen; - ((mng_backp)pChunkto)->iBlue = ((mng_backp)pChunkfrom)->iBlue; - ((mng_backp)pChunkto)->iMandatory = ((mng_backp)pChunkfrom)->iMandatory; - ((mng_backp)pChunkto)->iImageid = ((mng_backp)pChunkfrom)->iImageid; - ((mng_backp)pChunkto)->iTile = ((mng_backp)pChunkfrom)->iTile; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_BACK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_FRAM -ASSIGN_CHUNK_HDR (mng_assign_fram) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_FRAM, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_FRAM) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_framp)pChunkto)->bEmpty = ((mng_framp)pChunkfrom)->bEmpty; - ((mng_framp)pChunkto)->iMode = ((mng_framp)pChunkfrom)->iMode; - ((mng_framp)pChunkto)->iNamesize = ((mng_framp)pChunkfrom)->iNamesize; - ((mng_framp)pChunkto)->iChangedelay = ((mng_framp)pChunkfrom)->iChangedelay; - ((mng_framp)pChunkto)->iChangetimeout = ((mng_framp)pChunkfrom)->iChangetimeout; - ((mng_framp)pChunkto)->iChangeclipping = ((mng_framp)pChunkfrom)->iChangeclipping; - ((mng_framp)pChunkto)->iChangesyncid = ((mng_framp)pChunkfrom)->iChangesyncid; - ((mng_framp)pChunkto)->iDelay = ((mng_framp)pChunkfrom)->iDelay; - ((mng_framp)pChunkto)->iTimeout = ((mng_framp)pChunkfrom)->iTimeout; - ((mng_framp)pChunkto)->iBoundarytype = ((mng_framp)pChunkfrom)->iBoundarytype; - ((mng_framp)pChunkto)->iBoundaryl = ((mng_framp)pChunkfrom)->iBoundaryl; - ((mng_framp)pChunkto)->iBoundaryr = ((mng_framp)pChunkfrom)->iBoundaryr; - ((mng_framp)pChunkto)->iBoundaryt = ((mng_framp)pChunkfrom)->iBoundaryt; - ((mng_framp)pChunkto)->iBoundaryb = ((mng_framp)pChunkfrom)->iBoundaryb; - ((mng_framp)pChunkto)->iCount = ((mng_framp)pChunkfrom)->iCount; - - if (((mng_framp)pChunkto)->iNamesize) - { - MNG_ALLOC (pData, ((mng_framp)pChunkto)->zName, ((mng_framp)pChunkto)->iNamesize); - MNG_COPY (((mng_framp)pChunkto)->zName, ((mng_framp)pChunkfrom)->zName, - ((mng_framp)pChunkto)->iNamesize); - } - - if (((mng_framp)pChunkto)->iCount) - { - mng_uint32 iLen = ((mng_framp)pChunkto)->iCount * sizeof (mng_uint32); - - MNG_ALLOC (pData, ((mng_framp)pChunkto)->pSyncids, iLen); - MNG_COPY (((mng_framp)pChunkto)->pSyncids, ((mng_framp)pChunkfrom)->pSyncids, iLen); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_FRAM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifndef MNG_SKIPCHUNK_MOVE -ASSIGN_CHUNK_HDR (mng_assign_move) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_MOVE, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_MOVE) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_movep)pChunkto)->iFirstid = ((mng_movep)pChunkfrom)->iFirstid; - ((mng_movep)pChunkto)->iLastid = ((mng_movep)pChunkfrom)->iLastid; - ((mng_movep)pChunkto)->iMovetype = ((mng_movep)pChunkfrom)->iMovetype; - ((mng_movep)pChunkto)->iMovex = ((mng_movep)pChunkfrom)->iMovex; - ((mng_movep)pChunkto)->iMovey = ((mng_movep)pChunkfrom)->iMovey; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_MOVE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifndef MNG_SKIPCHUNK_CLIP -ASSIGN_CHUNK_HDR (mng_assign_clip) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_CLIP, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_CLIP) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_clipp)pChunkto)->iFirstid = ((mng_clipp)pChunkfrom)->iFirstid; - ((mng_clipp)pChunkto)->iLastid = ((mng_clipp)pChunkfrom)->iLastid; - ((mng_clipp)pChunkto)->iCliptype = ((mng_clipp)pChunkfrom)->iCliptype; - ((mng_clipp)pChunkto)->iClipl = ((mng_clipp)pChunkfrom)->iClipl; - ((mng_clipp)pChunkto)->iClipr = ((mng_clipp)pChunkfrom)->iClipr; - ((mng_clipp)pChunkto)->iClipt = ((mng_clipp)pChunkfrom)->iClipt; - ((mng_clipp)pChunkto)->iClipb = ((mng_clipp)pChunkfrom)->iClipb; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_CLIP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifndef MNG_SKIPCHUNK_SHOW -ASSIGN_CHUNK_HDR (mng_assign_show) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_SHOW, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_SHOW) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_showp)pChunkto)->bEmpty = ((mng_showp)pChunkfrom)->bEmpty; - ((mng_showp)pChunkto)->iFirstid = ((mng_showp)pChunkfrom)->iFirstid; - ((mng_showp)pChunkto)->iLastid = ((mng_showp)pChunkfrom)->iLastid; - ((mng_showp)pChunkto)->iMode = ((mng_showp)pChunkfrom)->iMode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_SHOW, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifndef MNG_SKIPCHUNK_TERM -ASSIGN_CHUNK_HDR (mng_assign_term) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_TERM, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_TERM) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_termp)pChunkto)->iTermaction = ((mng_termp)pChunkfrom)->iTermaction; - ((mng_termp)pChunkto)->iIteraction = ((mng_termp)pChunkfrom)->iIteraction; - ((mng_termp)pChunkto)->iDelay = ((mng_termp)pChunkfrom)->iDelay; - ((mng_termp)pChunkto)->iItermax = ((mng_termp)pChunkfrom)->iItermax; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_TERM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SAVE -ASSIGN_CHUNK_HDR (mng_assign_save) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_SAVE, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_SAVE) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_savep)pChunkto)->bEmpty = ((mng_savep)pChunkfrom)->bEmpty; - ((mng_savep)pChunkto)->iOffsettype = ((mng_savep)pChunkfrom)->iOffsettype; - ((mng_savep)pChunkto)->iCount = ((mng_savep)pChunkfrom)->iCount; - - if (((mng_savep)pChunkto)->iCount) - { - mng_uint32 iX; - mng_save_entryp pEntry; - mng_uint32 iLen = ((mng_savep)pChunkto)->iCount * sizeof (mng_save_entry); - - MNG_ALLOC (pData, ((mng_savep)pChunkto)->pEntries, iLen); - MNG_COPY (((mng_savep)pChunkto)->pEntries, ((mng_savep)pChunkfrom)->pEntries, iLen); - - pEntry = ((mng_savep)pChunkto)->pEntries; - - for (iX = 0; iX < ((mng_savep)pChunkto)->iCount; iX++) - { - if (pEntry->iNamesize) - { - mng_pchar pTemp = pEntry->zName; - - MNG_ALLOC (pData, pEntry->zName, pEntry->iNamesize); - MNG_COPY (pEntry->zName, pTemp, pEntry->iNamesize); - } - else - { - pEntry->zName = MNG_NULL; - } - - pEntry++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_SAVE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SEEK -ASSIGN_CHUNK_HDR (mng_assign_seek) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_SEEK, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_SEEK) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_seekp)pChunkto)->iNamesize = ((mng_seekp)pChunkfrom)->iNamesize; - - if (((mng_seekp)pChunkto)->iNamesize) - { - MNG_ALLOC (pData, ((mng_seekp)pChunkto)->zName, ((mng_seekp)pChunkto)->iNamesize); - MNG_COPY (((mng_seekp)pChunkto)->zName, ((mng_seekp)pChunkfrom)->zName, - ((mng_seekp)pChunkto)->iNamesize); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_SEEK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_eXPI -ASSIGN_CHUNK_HDR (mng_assign_expi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_EXPI, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_eXPI) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_expip)pChunkto)->iSnapshotid = ((mng_expip)pChunkfrom)->iSnapshotid; - ((mng_expip)pChunkto)->iNamesize = ((mng_expip)pChunkfrom)->iNamesize; - - if (((mng_expip)pChunkto)->iNamesize) - { - MNG_ALLOC (pData, ((mng_expip)pChunkto)->zName, ((mng_expip)pChunkto)->iNamesize); - MNG_COPY (((mng_expip)pChunkto)->zName, ((mng_expip)pChunkfrom)->zName, - ((mng_expip)pChunkto)->iNamesize); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_EXPI, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifndef MNG_SKIPCHUNK_fPRI -ASSIGN_CHUNK_HDR (mng_assign_fpri) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_FPRI, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_fPRI) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_fprip)pChunkto)->iDeltatype = ((mng_fprip)pChunkfrom)->iDeltatype; - ((mng_fprip)pChunkto)->iPriority = ((mng_fprip)pChunkfrom)->iPriority; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_FPRI, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_nEED -ASSIGN_CHUNK_HDR (mng_assign_need) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_NEED, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_nEED) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_needp)pChunkto)->iKeywordssize = ((mng_needp)pChunkfrom)->iKeywordssize; - - if (((mng_needp)pChunkto)->iKeywordssize) - { - MNG_ALLOC (pData, ((mng_needp)pChunkto)->zKeywords, ((mng_needp)pChunkto)->iKeywordssize); - MNG_COPY (((mng_needp)pChunkto)->zKeywords, ((mng_needp)pChunkfrom)->zKeywords, - ((mng_needp)pChunkto)->iKeywordssize); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_NEED, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifndef MNG_SKIPCHUNK_pHYg -ASSIGN_CHUNK_HDR (mng_assign_phyg) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_PHYG, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_pHYg) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_phygp)pChunkto)->bEmpty = ((mng_phygp)pChunkfrom)->bEmpty; - ((mng_phygp)pChunkto)->iSizex = ((mng_phygp)pChunkfrom)->iSizex; - ((mng_phygp)pChunkto)->iSizey = ((mng_phygp)pChunkfrom)->iSizey; - ((mng_phygp)pChunkto)->iUnit = ((mng_phygp)pChunkfrom)->iUnit; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_PHYG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifdef MNG_INCLUDE_JNG -ASSIGN_CHUNK_HDR (mng_assign_jhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_JHDR, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_JHDR) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_jhdrp)pChunkto)->iWidth = ((mng_jhdrp)pChunkfrom)->iWidth; - ((mng_jhdrp)pChunkto)->iHeight = ((mng_jhdrp)pChunkfrom)->iHeight; - ((mng_jhdrp)pChunkto)->iColortype = ((mng_jhdrp)pChunkfrom)->iColortype; - ((mng_jhdrp)pChunkto)->iImagesampledepth = ((mng_jhdrp)pChunkfrom)->iImagesampledepth; - ((mng_jhdrp)pChunkto)->iImagecompression = ((mng_jhdrp)pChunkfrom)->iImagecompression; - ((mng_jhdrp)pChunkto)->iImageinterlace = ((mng_jhdrp)pChunkfrom)->iImageinterlace; - ((mng_jhdrp)pChunkto)->iAlphasampledepth = ((mng_jhdrp)pChunkfrom)->iAlphasampledepth; - ((mng_jhdrp)pChunkto)->iAlphacompression = ((mng_jhdrp)pChunkfrom)->iAlphacompression; - ((mng_jhdrp)pChunkto)->iAlphafilter = ((mng_jhdrp)pChunkfrom)->iAlphafilter; - ((mng_jhdrp)pChunkto)->iAlphainterlace = ((mng_jhdrp)pChunkfrom)->iAlphainterlace; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_JHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -ASSIGN_CHUNK_HDR (mng_assign_jdaa) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_JDAA, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_JDAA) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_jdaap)pChunkto)->bEmpty = ((mng_jdaap)pChunkfrom)->bEmpty; - ((mng_jdaap)pChunkto)->iDatasize = ((mng_jdaap)pChunkfrom)->iDatasize; - - if (((mng_jdaap)pChunkto)->iDatasize) - { - MNG_ALLOC (pData, ((mng_jdaap)pChunkto)->pData, ((mng_jdaap)pChunkto)->iDatasize); - MNG_COPY (((mng_jdaap)pChunkto)->pData, ((mng_jdaap)pChunkfrom)->pData, - ((mng_jdaap)pChunkto)->iDatasize); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_JDAA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -ASSIGN_CHUNK_HDR (mng_assign_jdat) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_JDAT, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_JDAT) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_jdatp)pChunkto)->bEmpty = ((mng_jdatp)pChunkfrom)->bEmpty; - ((mng_jdatp)pChunkto)->iDatasize = ((mng_jdatp)pChunkfrom)->iDatasize; - - if (((mng_jdatp)pChunkto)->iDatasize) - { - MNG_ALLOC (pData, ((mng_jdatp)pChunkto)->pData, ((mng_jdatp)pChunkto)->iDatasize); - MNG_COPY (((mng_jdatp)pChunkto)->pData, ((mng_jdatp)pChunkfrom)->pData, - ((mng_jdatp)pChunkto)->iDatasize); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_JDAT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifdef MNG_INCLUDE_JNG -ASSIGN_CHUNK_HDR (mng_assign_jsep) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_JSEP, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_JSEP) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_JSEP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifndef MNG_NO_DELTA_PNG -ASSIGN_CHUNK_HDR (mng_assign_dhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_DHDR, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_DHDR) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_dhdrp)pChunkto)->iObjectid = ((mng_dhdrp)pChunkfrom)->iObjectid; - ((mng_dhdrp)pChunkto)->iImagetype = ((mng_dhdrp)pChunkfrom)->iImagetype; - ((mng_dhdrp)pChunkto)->iDeltatype = ((mng_dhdrp)pChunkfrom)->iDeltatype; - ((mng_dhdrp)pChunkto)->iBlockwidth = ((mng_dhdrp)pChunkfrom)->iBlockwidth; - ((mng_dhdrp)pChunkto)->iBlockheight = ((mng_dhdrp)pChunkfrom)->iBlockheight; - ((mng_dhdrp)pChunkto)->iBlockx = ((mng_dhdrp)pChunkfrom)->iBlockx; - ((mng_dhdrp)pChunkto)->iBlocky = ((mng_dhdrp)pChunkfrom)->iBlocky; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_DHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifndef MNG_NO_DELTA_PNG -ASSIGN_CHUNK_HDR (mng_assign_prom) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_PROM, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_PROM) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_promp)pChunkto)->iColortype = ((mng_promp)pChunkfrom)->iColortype; - ((mng_promp)pChunkto)->iSampledepth = ((mng_promp)pChunkfrom)->iSampledepth; - ((mng_promp)pChunkto)->iFilltype = ((mng_promp)pChunkfrom)->iFilltype; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_PROM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifndef MNG_NO_DELTA_PNG -ASSIGN_CHUNK_HDR (mng_assign_ipng) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_IPNG, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_IPNG) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_IPNG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifndef MNG_NO_DELTA_PNG -ASSIGN_CHUNK_HDR (mng_assign_pplt) -{ - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_PPLT, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_PPLT) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_ppltp)pChunkto)->iDeltatype = ((mng_ppltp)pChunkfrom)->iDeltatype; - ((mng_ppltp)pChunkto)->iCount = ((mng_ppltp)pChunkfrom)->iCount; - - for (iX = 0; iX < ((mng_ppltp)pChunkto)->iCount; iX++) - ((mng_ppltp)pChunkto)->aEntries [iX] = ((mng_ppltp)pChunkfrom)->aEntries [iX]; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_PPLT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifndef MNG_NO_DELTA_PNG -#ifdef MNG_INCLUDE_JNG -ASSIGN_CHUNK_HDR (mng_assign_ijng) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_IJNG, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_IJNG) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_IJNG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -ASSIGN_CHUNK_HDR (mng_assign_drop) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_DROP, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_DROP) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_dropp)pChunkto)->iCount = ((mng_dropp)pChunkfrom)->iCount; - - if (((mng_dropp)pChunkto)->iCount) - { - mng_uint32 iLen = ((mng_dropp)pChunkto)->iCount * sizeof (mng_uint32); - - MNG_ALLOC (pData, ((mng_dropp)pChunkto)->pChunknames, iLen); - MNG_COPY (((mng_dropp)pChunkto)->pChunknames, ((mng_dropp)pChunkfrom)->pChunknames, iLen); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_DROP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_DBYK -ASSIGN_CHUNK_HDR (mng_assign_dbyk) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_DBYK, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_DBYK) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_dbykp)pChunkto)->iChunkname = ((mng_dbykp)pChunkfrom)->iChunkname; - ((mng_dbykp)pChunkto)->iPolarity = ((mng_dbykp)pChunkfrom)->iPolarity; - ((mng_dbykp)pChunkto)->iKeywordssize = ((mng_dbykp)pChunkfrom)->iKeywordssize; - - if (((mng_dbykp)pChunkto)->iKeywordssize) - { - MNG_ALLOC (pData, ((mng_dbykp)pChunkto)->zKeywords, ((mng_dbykp)pChunkto)->iKeywordssize); - MNG_COPY (((mng_dbykp)pChunkto)->zKeywords, ((mng_dbykp)pChunkfrom)->zKeywords, - ((mng_dbykp)pChunkto)->iKeywordssize); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_DBYK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_ORDR -ASSIGN_CHUNK_HDR (mng_assign_ordr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_ORDR, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_ORDR) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_ordrp)pChunkto)->iCount = ((mng_ordrp)pChunkfrom)->iCount; - - if (((mng_ordrp)pChunkto)->iCount) - { - mng_uint32 iLen = ((mng_ordrp)pChunkto)->iCount * sizeof (mng_ordr_entry); - - MNG_ALLOC (pData, ((mng_ordrp)pChunkto)->pEntries, iLen); - MNG_COPY (((mng_ordrp)pChunkto)->pEntries, ((mng_ordrp)pChunkfrom)->pEntries, iLen); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_ORDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKASSIGN -#ifndef MNG_SKIPCHUNK_MAGN -ASSIGN_CHUNK_HDR (mng_assign_magn) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_MAGN, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_MAGN) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_magnp)pChunkto)->iFirstid = ((mng_magnp)pChunkfrom)->iFirstid; - ((mng_magnp)pChunkto)->iLastid = ((mng_magnp)pChunkfrom)->iLastid; - ((mng_magnp)pChunkto)->iMethodX = ((mng_magnp)pChunkfrom)->iMethodX; - ((mng_magnp)pChunkto)->iMX = ((mng_magnp)pChunkfrom)->iMX; - ((mng_magnp)pChunkto)->iMY = ((mng_magnp)pChunkfrom)->iMY; - ((mng_magnp)pChunkto)->iML = ((mng_magnp)pChunkfrom)->iML; - ((mng_magnp)pChunkto)->iMR = ((mng_magnp)pChunkfrom)->iMR; - ((mng_magnp)pChunkto)->iMT = ((mng_magnp)pChunkfrom)->iMT; - ((mng_magnp)pChunkto)->iMB = ((mng_magnp)pChunkfrom)->iMB; - ((mng_magnp)pChunkto)->iMethodY = ((mng_magnp)pChunkfrom)->iMethodY; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_MAGN, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_MPNG_PROPOSAL -ASSIGN_CHUNK_HDR (mng_assign_mpng) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_MPNG, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_mpNG) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_mpngp)pChunkto)->iFramewidth = ((mng_mpngp)pChunkfrom)->iFramewidth; - ((mng_mpngp)pChunkto)->iFrameheight = ((mng_mpngp)pChunkfrom)->iFrameheight; - ((mng_mpngp)pChunkto)->iNumplays = ((mng_mpngp)pChunkfrom)->iNumplays; - ((mng_mpngp)pChunkto)->iTickspersec = ((mng_mpngp)pChunkfrom)->iTickspersec; - ((mng_mpngp)pChunkto)->iCompressionmethod = ((mng_mpngp)pChunkfrom)->iCompressionmethod; - ((mng_mpngp)pChunkto)->iFramessize = ((mng_mpngp)pChunkfrom)->iFramessize; - - if (((mng_mpngp)pChunkto)->iFramessize) - { - MNG_ALLOC (pData, ((mng_mpngp)pChunkto)->pFrames, ((mng_mpngp)pChunkto)->iFramessize); - MNG_COPY (((mng_mpngp)pChunkto)->pFrames, ((mng_mpngp)pChunkfrom)->pFrames, - ((mng_mpngp)pChunkto)->iFramessize); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_MPNG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ANG_PROPOSAL -ASSIGN_CHUNK_HDR (mng_assign_ahdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_AHDR, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_ahDR) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_ahdrp)pChunkto)->iNumframes = ((mng_ahdrp)pChunkfrom)->iNumframes; - ((mng_ahdrp)pChunkto)->iTickspersec = ((mng_ahdrp)pChunkfrom)->iTickspersec; - ((mng_ahdrp)pChunkto)->iNumplays = ((mng_ahdrp)pChunkfrom)->iNumplays; - ((mng_ahdrp)pChunkto)->iTilewidth = ((mng_ahdrp)pChunkfrom)->iTilewidth; - ((mng_ahdrp)pChunkto)->iTileheight = ((mng_ahdrp)pChunkfrom)->iTileheight; - ((mng_ahdrp)pChunkto)->iInterlace = ((mng_ahdrp)pChunkfrom)->iInterlace; - ((mng_ahdrp)pChunkto)->iStillused = ((mng_ahdrp)pChunkfrom)->iStillused; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_AHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ANG_PROPOSAL -ASSIGN_CHUNK_HDR (mng_assign_adat) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_ADAT, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_adAT) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_adatp)pChunkto)->iTilessize = ((mng_adatp)pChunkfrom)->iTilessize; - - if (((mng_adatp)pChunkto)->iTilessize) - { - MNG_ALLOC (pData, ((mng_adatp)pChunkto)->pTiles, ((mng_adatp)pChunkto)->iTilessize); - MNG_COPY (((mng_adatp)pChunkto)->pTiles, ((mng_adatp)pChunkfrom)->pTiles, - ((mng_adatp)pChunkto)->iTilessize); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_ADAT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_evNT -ASSIGN_CHUNK_HDR (mng_assign_evnt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_EVNT, MNG_LC_START); -#endif - - if (((mng_chunk_headerp)pChunkfrom)->iChunkname != MNG_UINT_evNT) - MNG_ERROR (pData, MNG_WRONGCHUNK); /* ouch */ - - ((mng_evntp)pChunkto)->iCount = ((mng_evntp)pChunkfrom)->iCount; - - if (((mng_evntp)pChunkto)->iCount) - { - mng_uint32 iX; - mng_evnt_entryp pEntry; - mng_uint32 iLen = ((mng_evntp)pChunkto)->iCount * sizeof (mng_evnt_entry); - - MNG_ALLOC (pData, ((mng_evntp)pChunkto)->pEntries, iLen); - MNG_COPY (((mng_evntp)pChunkto)->pEntries, ((mng_evntp)pChunkfrom)->pEntries, iLen); - - pEntry = ((mng_evntp)pChunkto)->pEntries; - - for (iX = 0; iX < ((mng_evntp)pChunkto)->iCount; iX++) - { - if (pEntry->iSegmentnamesize) - { - mng_pchar pTemp = pEntry->zSegmentname; - - MNG_ALLOC (pData, pEntry->zSegmentname, pEntry->iSegmentnamesize+1); - MNG_COPY (pEntry->zSegmentname, pTemp, pEntry->iSegmentnamesize); - } - else - { - pEntry->zSegmentname = MNG_NULL; - } - - pEntry++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_EVNT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -ASSIGN_CHUNK_HDR (mng_assign_unknown) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_UNKNOWN, MNG_LC_START); -#endif - - ((mng_unknown_chunkp)pChunkto)->iDatasize = ((mng_unknown_chunkp)pChunkfrom)->iDatasize; - - if (((mng_unknown_chunkp)pChunkto)->iDatasize) - { - MNG_ALLOC (pData, ((mng_unknown_chunkp)pChunkto)->pData, ((mng_unknown_chunkp)pChunkto)->iDatasize); - MNG_COPY (((mng_unknown_chunkp)pChunkto)->pData, ((mng_unknown_chunkp)pChunkfrom)->pData, - ((mng_unknown_chunkp)pChunkto)->iDatasize); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ASSIGN_UNKNOWN, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_WRITE_PROCS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/plugins/AdvaImg/src/LibMNG/libmng_chunk_prc.h b/plugins/AdvaImg/src/LibMNG/libmng_chunk_prc.h deleted file mode 100644 index 96db17498e..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_chunk_prc.h +++ /dev/null @@ -1,381 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_chunk_prc.h copyright (c) 2000-2007 G.Juyn * */ -/* * version : 1.0.10 * */ -/* * * */ -/* * purpose : Chunk initialization & cleanup (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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 * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added support for JDAA * */ -/* * * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * 1.0.5 - 09/14/2002 - G.Juyn * */ -/* * - added event handling for dynamic MNG * */ -/* * * */ -/* * 1.0.6 - 07/07/2003 - G.R-P * */ -/* * - added NO_DELTA_PNG support * */ -/* * 1.0.6 - 07/29/2003 - G.R-P * */ -/* * - added conditionals around PAST chunk support * */ -/* * * */ -/* * 1.0.9 - 12/05/2004 - G.Juyn * */ -/* * - added conditional MNG_OPTIMIZE_CHUNKINITFREE * */ -/* * 1.0.9 - 12/06/2004 - G.Juyn * */ -/* * - added conditional MNG_OPTIMIZE_CHUNKASSIGN * */ -/* * * */ -/* * 1.0.10 - 04/08/2007 - G.Juyn * */ -/* * - added support for mPNG proposal * */ -/* * 1.0.10 - 04/12/2007 - G.Juyn * */ -/* * - added support for ANG proposal * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_chunk_prc_h_ -#define _libmng_chunk_prc_h_ - -/* ************************************************************************** */ - -void mng_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) - -#ifdef MNG_OPTIMIZE_CHUNKINITFREE -INIT_CHUNK_HDR (mng_init_general) ; -#else -INIT_CHUNK_HDR (mng_init_ihdr) ; -INIT_CHUNK_HDR (mng_init_plte) ; -INIT_CHUNK_HDR (mng_init_idat) ; -INIT_CHUNK_HDR (mng_init_iend) ; -INIT_CHUNK_HDR (mng_init_trns) ; -INIT_CHUNK_HDR (mng_init_gama) ; -INIT_CHUNK_HDR (mng_init_chrm) ; -INIT_CHUNK_HDR (mng_init_srgb) ; -INIT_CHUNK_HDR (mng_init_iccp) ; -INIT_CHUNK_HDR (mng_init_text) ; -INIT_CHUNK_HDR (mng_init_ztxt) ; -INIT_CHUNK_HDR (mng_init_itxt) ; -INIT_CHUNK_HDR (mng_init_bkgd) ; -INIT_CHUNK_HDR (mng_init_phys) ; -INIT_CHUNK_HDR (mng_init_sbit) ; -INIT_CHUNK_HDR (mng_init_splt) ; -INIT_CHUNK_HDR (mng_init_hist) ; -INIT_CHUNK_HDR (mng_init_time) ; -INIT_CHUNK_HDR (mng_init_mhdr) ; -INIT_CHUNK_HDR (mng_init_mend) ; -INIT_CHUNK_HDR (mng_init_loop) ; -INIT_CHUNK_HDR (mng_init_endl) ; -INIT_CHUNK_HDR (mng_init_defi) ; -INIT_CHUNK_HDR (mng_init_basi) ; -INIT_CHUNK_HDR (mng_init_clon) ; -#ifndef MNG_SKIPCHUNK_PAST -INIT_CHUNK_HDR (mng_init_past) ; -#endif -INIT_CHUNK_HDR (mng_init_disc) ; -INIT_CHUNK_HDR (mng_init_back) ; -INIT_CHUNK_HDR (mng_init_fram) ; -INIT_CHUNK_HDR (mng_init_move) ; -INIT_CHUNK_HDR (mng_init_clip) ; -INIT_CHUNK_HDR (mng_init_show) ; -INIT_CHUNK_HDR (mng_init_term) ; -INIT_CHUNK_HDR (mng_init_save) ; -INIT_CHUNK_HDR (mng_init_seek) ; -INIT_CHUNK_HDR (mng_init_expi) ; -INIT_CHUNK_HDR (mng_init_fpri) ; -INIT_CHUNK_HDR (mng_init_need) ; -INIT_CHUNK_HDR (mng_init_phyg) ; -#ifdef MNG_INCLUDE_JNG -INIT_CHUNK_HDR (mng_init_jhdr) ; -INIT_CHUNK_HDR (mng_init_jdaa) ; -INIT_CHUNK_HDR (mng_init_jdat) ; -INIT_CHUNK_HDR (mng_init_jsep) ; -#endif -#ifndef MNG_NO_DELTA_PNG -INIT_CHUNK_HDR (mng_init_dhdr) ; -INIT_CHUNK_HDR (mng_init_prom) ; -INIT_CHUNK_HDR (mng_init_ipng) ; -INIT_CHUNK_HDR (mng_init_pplt) ; -#ifdef MNG_INCLUDE_JNG -INIT_CHUNK_HDR (mng_init_ijng) ; -#endif -INIT_CHUNK_HDR (mng_init_drop) ; -INIT_CHUNK_HDR (mng_init_dbyk) ; -INIT_CHUNK_HDR (mng_init_ordr) ; -#endif -INIT_CHUNK_HDR (mng_init_magn) ; -INIT_CHUNK_HDR (mng_init_evnt) ; -INIT_CHUNK_HDR (mng_init_unknown) ; -#endif /* MNG_OPTIMIZE_CHUNKINITFREE */ - -/* ************************************************************************** */ - -#define FREE_CHUNK_HDR(n) mng_retcode n (mng_datap pData, \ - mng_chunkp pHeader) - -#ifdef MNG_OPTIMIZE_CHUNKINITFREE -FREE_CHUNK_HDR (mng_free_general) ; -#else /* MNG_OPTIMIZE_CHUNKINITFREE */ -FREE_CHUNK_HDR (mng_free_ihdr) ; -FREE_CHUNK_HDR (mng_free_plte) ; -FREE_CHUNK_HDR (mng_free_iend) ; -FREE_CHUNK_HDR (mng_free_trns) ; -FREE_CHUNK_HDR (mng_free_gama) ; -FREE_CHUNK_HDR (mng_free_chrm) ; -FREE_CHUNK_HDR (mng_free_srgb) ; -FREE_CHUNK_HDR (mng_free_bkgd) ; -FREE_CHUNK_HDR (mng_free_phys) ; -FREE_CHUNK_HDR (mng_free_sbit) ; -FREE_CHUNK_HDR (mng_free_hist) ; -FREE_CHUNK_HDR (mng_free_time) ; -FREE_CHUNK_HDR (mng_free_mhdr) ; -FREE_CHUNK_HDR (mng_free_mend) ; -FREE_CHUNK_HDR (mng_free_endl) ; -FREE_CHUNK_HDR (mng_free_defi) ; -FREE_CHUNK_HDR (mng_free_basi) ; -FREE_CHUNK_HDR (mng_free_clon) ; -FREE_CHUNK_HDR (mng_free_back) ; -FREE_CHUNK_HDR (mng_free_move) ; -FREE_CHUNK_HDR (mng_free_clip) ; -FREE_CHUNK_HDR (mng_free_show) ; -FREE_CHUNK_HDR (mng_free_term) ; -FREE_CHUNK_HDR (mng_free_fpri) ; -FREE_CHUNK_HDR (mng_free_phyg) ; -#ifdef MNG_INCLUDE_JNG -FREE_CHUNK_HDR (mng_free_jhdr) ; -FREE_CHUNK_HDR (mng_free_jsep) ; -#endif -#ifndef MNG_NO_DELTA_PNG -FREE_CHUNK_HDR (mng_free_dhdr) ; -FREE_CHUNK_HDR (mng_free_prom) ; -FREE_CHUNK_HDR (mng_free_ipng) ; -FREE_CHUNK_HDR (mng_free_pplt) ; -#ifdef MNG_INCLUDE_JNG -FREE_CHUNK_HDR (mng_free_ijng) ; -#endif -#endif -FREE_CHUNK_HDR (mng_free_magn) ; -#endif /* MNG_OPTIMIZE_CHUNKINITFREE */ - -FREE_CHUNK_HDR (mng_free_idat) ; -FREE_CHUNK_HDR (mng_free_iccp) ; -FREE_CHUNK_HDR (mng_free_text) ; -FREE_CHUNK_HDR (mng_free_ztxt) ; -FREE_CHUNK_HDR (mng_free_itxt) ; -FREE_CHUNK_HDR (mng_free_splt) ; -FREE_CHUNK_HDR (mng_free_loop) ; -#ifndef MNG_SKIPCHUNK_PAST -FREE_CHUNK_HDR (mng_free_past) ; -#endif -FREE_CHUNK_HDR (mng_free_disc) ; -FREE_CHUNK_HDR (mng_free_fram) ; -FREE_CHUNK_HDR (mng_free_save) ; -FREE_CHUNK_HDR (mng_free_seek) ; -FREE_CHUNK_HDR (mng_free_expi) ; -FREE_CHUNK_HDR (mng_free_need) ; -#ifdef MNG_INCLUDE_JNG -FREE_CHUNK_HDR (mng_free_jdaa) ; -FREE_CHUNK_HDR (mng_free_jdat) ; -#endif -#ifndef MNG_NO_DELTA_PNG -FREE_CHUNK_HDR (mng_free_drop) ; -FREE_CHUNK_HDR (mng_free_dbyk) ; -FREE_CHUNK_HDR (mng_free_ordr) ; -#endif -#ifdef MNG_INCLUDE_MPNG_PROPOSAL -FREE_CHUNK_HDR (mng_free_mpng) ; -#endif -#ifdef MNG_INCLUDE_ANG_PROPOSAL -FREE_CHUNK_HDR (mng_free_adat) ; -#endif -FREE_CHUNK_HDR (mng_free_evnt) ; -FREE_CHUNK_HDR (mng_free_unknown) ; - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_WRITE_PROCS - -#define ASSIGN_CHUNK_HDR(n) mng_retcode n (mng_datap pData, \ - mng_chunkp pChunkto, \ - mng_chunkp pChunkfrom) - -#ifdef MNG_OPTIMIZE_CHUNKASSIGN -ASSIGN_CHUNK_HDR (mng_assign_general) ; -#else /* MNG_OPTIMIZE_CHUNKASSIGN */ -ASSIGN_CHUNK_HDR (mng_assign_ihdr) ; -ASSIGN_CHUNK_HDR (mng_assign_plte) ; -ASSIGN_CHUNK_HDR (mng_assign_iend) ; -ASSIGN_CHUNK_HDR (mng_assign_trns) ; -ASSIGN_CHUNK_HDR (mng_assign_gama) ; -ASSIGN_CHUNK_HDR (mng_assign_chrm) ; -ASSIGN_CHUNK_HDR (mng_assign_srgb) ; -ASSIGN_CHUNK_HDR (mng_assign_bkgd) ; -ASSIGN_CHUNK_HDR (mng_assign_phys) ; -ASSIGN_CHUNK_HDR (mng_assign_sbit) ; -ASSIGN_CHUNK_HDR (mng_assign_hist) ; -ASSIGN_CHUNK_HDR (mng_assign_time) ; -ASSIGN_CHUNK_HDR (mng_assign_mhdr) ; -ASSIGN_CHUNK_HDR (mng_assign_mend) ; -ASSIGN_CHUNK_HDR (mng_assign_endl) ; -ASSIGN_CHUNK_HDR (mng_assign_defi) ; -ASSIGN_CHUNK_HDR (mng_assign_basi) ; -ASSIGN_CHUNK_HDR (mng_assign_clon) ; -ASSIGN_CHUNK_HDR (mng_assign_back) ; -ASSIGN_CHUNK_HDR (mng_assign_move) ; -ASSIGN_CHUNK_HDR (mng_assign_clip) ; -ASSIGN_CHUNK_HDR (mng_assign_show) ; -ASSIGN_CHUNK_HDR (mng_assign_term) ; -ASSIGN_CHUNK_HDR (mng_assign_fpri) ; -ASSIGN_CHUNK_HDR (mng_assign_phyg) ; -#ifdef MNG_INCLUDE_JNG -ASSIGN_CHUNK_HDR (mng_assign_jhdr) ; -ASSIGN_CHUNK_HDR (mng_assign_jsep) ; -#endif -#ifndef MNG_NO_DELTA_PNG -ASSIGN_CHUNK_HDR (mng_assign_dhdr) ; -ASSIGN_CHUNK_HDR (mng_assign_prom) ; -ASSIGN_CHUNK_HDR (mng_assign_ipng) ; -ASSIGN_CHUNK_HDR (mng_assign_pplt) ; -#ifdef MNG_INCLUDE_JNG -ASSIGN_CHUNK_HDR (mng_assign_ijng) ; -#endif -#endif -ASSIGN_CHUNK_HDR (mng_assign_magn) ; -#endif /* MNG_OPTIMIZE_CHUNKASSIGN */ - -ASSIGN_CHUNK_HDR (mng_assign_idat) ; -ASSIGN_CHUNK_HDR (mng_assign_iccp) ; -ASSIGN_CHUNK_HDR (mng_assign_text) ; -ASSIGN_CHUNK_HDR (mng_assign_ztxt) ; -ASSIGN_CHUNK_HDR (mng_assign_itxt) ; -ASSIGN_CHUNK_HDR (mng_assign_splt) ; -ASSIGN_CHUNK_HDR (mng_assign_loop) ; -#ifndef MNG_SKIPCHUNK_PAST -ASSIGN_CHUNK_HDR (mng_assign_past) ; -#endif -ASSIGN_CHUNK_HDR (mng_assign_disc) ; -ASSIGN_CHUNK_HDR (mng_assign_fram) ; -ASSIGN_CHUNK_HDR (mng_assign_save) ; -ASSIGN_CHUNK_HDR (mng_assign_seek) ; -ASSIGN_CHUNK_HDR (mng_assign_need) ; -ASSIGN_CHUNK_HDR (mng_assign_expi) ; -#ifdef MNG_INCLUDE_JNG -ASSIGN_CHUNK_HDR (mng_assign_jdaa) ; -ASSIGN_CHUNK_HDR (mng_assign_jdat) ; -#endif -#ifndef MNG_NO_DELTA_PNG -ASSIGN_CHUNK_HDR (mng_assign_drop) ; -ASSIGN_CHUNK_HDR (mng_assign_dbyk) ; -ASSIGN_CHUNK_HDR (mng_assign_ordr) ; -#endif -#ifdef MNG_INCLUDE_MPNG_PROPOSAL -ASSIGN_CHUNK_HDR (mng_assign_mpng) ; -#endif -#ifdef MNG_INCLUDE_ANG_PROPOSAL -ASSIGN_CHUNK_HDR (mng_assign_ahdr) ; -ASSIGN_CHUNK_HDR (mng_assign_adat) ; -#endif -ASSIGN_CHUNK_HDR (mng_assign_evnt) ; -ASSIGN_CHUNK_HDR (mng_assign_unknown) ; - -/* ************************************************************************** */ - -#else /* MNG_INCLUDE_WRITE_PROCS */ -#define mng_assign_general 0 -#define mng_assign_ihdr 0 -#define mng_assign_plte 0 -#define mng_assign_idat 0 -#define mng_assign_iend 0 -#define mng_assign_trns 0 -#define mng_assign_gama 0 -#define mng_assign_chrm 0 -#define mng_assign_srgb 0 -#define mng_assign_iccp 0 -#define mng_assign_text 0 -#define mng_assign_ztxt 0 -#define mng_assign_itxt 0 -#define mng_assign_bkgd 0 -#define mng_assign_phys 0 -#define mng_assign_sbit 0 -#define mng_assign_splt 0 -#define mng_assign_hist 0 -#define mng_assign_time 0 -#define mng_assign_mhdr 0 -#define mng_assign_mend 0 -#define mng_assign_loop 0 -#define mng_assign_endl 0 -#define mng_assign_defi 0 -#define mng_assign_basi 0 -#define mng_assign_clon 0 -#ifndef MNG_SKIPCHUNK_PAST -#define mng_assign_past 0 -#endif -#define mng_assign_disc 0 -#define mng_assign_back 0 -#define mng_assign_fram 0 -#define mng_assign_move 0 -#define mng_assign_clip 0 -#define mng_assign_show 0 -#define mng_assign_term 0 -#define mng_assign_save 0 -#define mng_assign_seek 0 -#define mng_assign_expi 0 -#define mng_assign_fpri 0 -#define mng_assign_phyg 0 -#ifdef MNG_INCLUDE_JNG -#define mng_assign_jhdr 0 -#define mng_assign_jdaa 0 -#define mng_assign_jdat 0 -#define mng_assign_jsep 0 -#endif -#ifndef MNG_NO_DELTA_PNG -#define mng_assign_dhdr 0 -#define mng_assign_prom 0 -#define mng_assign_ipng 0 -#define mng_assign_pplt 0 -#ifdef MNG_INCLUDE_JNG -#define mng_assign_ijng 0 -#endif -#define mng_assign_drop 0 -#define mng_assign_dbyk 0 -#define mng_assign_ordr 0 -#endif -#define mng_assign_magn 0 -#define mng_assign_need 0 -#define mng_assign_mpng 0 -#define mng_assign_ahdr 0 -#define mng_assign_adat 0 -#define mng_assign_evnt 0 -#define mng_assign_unknown 0 -#endif /* MNG_INCLUDE_WRITE_PROCS */ - -/* ************************************************************************** */ - -#endif /* _libmng_chunk_prc_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/plugins/AdvaImg/src/LibMNG/libmng_chunk_xs.c b/plugins/AdvaImg/src/LibMNG/libmng_chunk_xs.c deleted file mode 100644 index 1c4ec2e50d..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_chunk_xs.c +++ /dev/null @@ -1,7016 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_chunk_xs.c copyright (c) 2000-2007 G.Juyn * */ -/* * version : 1.0.10 * */ -/* * * */ -/* * purpose : chunk access functions (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * comment : implementation of the chunk access functions * */ -/* * * */ -/* * changes : 0.5.1 - 05/06/2000 - G.Juyn * */ -/* * - changed and filled iterate-chunk function * */ -/* * 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - fixed calling convention * */ -/* * - added getchunk functions * */ -/* * - added putchunk functions * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - added empty-chunk put-routines * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * 0.5.1 - 05/15/2000 - G.Juyn * */ -/* * - added getimgdata & putimgdata functions * */ -/* * * */ -/* * 0.5.2 - 05/19/2000 - G.Juyn * */ -/* * - B004 - fixed problem with MNG_SUPPORT_WRITE not defined * */ -/* * also for MNG_SUPPORT_WRITE without MNG_INCLUDE_JNG * */ -/* * - Cleaned up some code regarding mixed support * */ -/* * * */ -/* * 0.9.1 - 07/19/2000 - G.Juyn * */ -/* * - fixed creation-code * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * - added function to set simplicity field * */ -/* * - fixed putchunk_unknown() function * */ -/* * * */ -/* * 0.9.3 - 08/07/2000 - G.Juyn * */ -/* * - B111300 - fixup for improved portability * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 10/20/2000 - G.Juyn * */ -/* * - fixed putchunk_plte() to set bEmpty parameter * */ -/* * * */ -/* * 0.9.5 - 01/25/2001 - G.Juyn * */ -/* * - fixed some small compiler warnings (thanks Nikki) * */ -/* * * */ -/* * 1.0.5 - 09/07/2002 - G.Juyn * */ -/* * - B578940 - unimplemented functions return errorcode * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * - added HLAPI function to copy chunks * */ -/* * 1.0.5 - 09/14/2002 - G.Juyn * */ -/* * - added event handling for dynamic MNG * */ -/* * 1.0.5 - 10/07/2002 - G.Juyn * */ -/* * - added check for TERM placement during create/write * */ -/* * 1.0.5 - 11/28/2002 - G.Juyn * */ -/* * - fixed definition of iMethodX/Y for MAGN chunk * */ -/* * * */ -/* * 1.0.6 - 05/25/2003 - G.R-P * */ -/* * - added MNG_SKIPCHUNK_cHNK footprint optimizations * */ -/* * 1.0.6 - 07/07/2003 - G.R-P * */ -/* * - added MNG_NO_DELTA_PNG reduction and more SKIPCHUNK * */ -/* * optimizations * */ -/* * 1.0.6 - 07/29/2003 - G.R-P * */ -/* * - added conditionals around PAST chunk support * */ -/* * 1.0.6 - 08/17/2003 - G.R-P * */ -/* * - added conditionals around non-VLC chunk support * */ -/* * * */ -/* * 1.0.8 - 04/01/2004 - G.Juyn * */ -/* * - added missing get-/put-chunk-jdaa * */ -/* * 1.0.8 - 08/02/2004 - G.Juyn * */ -/* * - added conditional to allow easier writing of large MNG's * */ -/* * * */ -/* * 1.0.9 - 09/17/2004 - G.R-P * */ -/* * - added two more conditionals * */ -/* * 1.0.9 - 09/25/2004 - G.Juyn * */ -/* * - replaced MNG_TWEAK_LARGE_FILES with permanent solution * */ -/* * 1.0.9 - 17/14/2004 - G.Juyn * */ -/* * - fixed PPLT getchunk/putchunk routines * */ -/* * 1.0.9 - 12/05/2004 - G.Juyn * */ -/* * - added conditional MNG_OPTIMIZE_CHUNKINITFREE * */ -/* * 1.0.9 - 12/20/2004 - G.Juyn * */ -/* * - cleaned up macro-invocations (thanks to D. Airlie) * */ -/* * * */ -/* * 1.0.10 - 04/08/2007 - G.Juyn * */ -/* * - added support for mPNG proposal * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_memory.h" -#include "libmng_chunks.h" -#ifdef MNG_OPTIMIZE_CHUNKREADER -#include "libmng_chunk_descr.h" -#endif -#include "libmng_chunk_prc.h" -#include "libmng_chunk_io.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_ACCESS_CHUNKS - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_iterate_chunks (mng_handle hHandle, - mng_uint32 iChunkseq, - mng_iteratechunk fProc) -{ - mng_uint32 iSeq; - mng_chunkid iChunkname; - mng_datap pData; - mng_chunkp pChunk; - mng_bool bCont; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_ITERATE_CHUNKS, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - - iSeq = 0; - bCont = MNG_TRUE; - pChunk = pData->pFirstchunk; /* get the first chunk */ - /* as long as there are some more */ - while ((pChunk) && (bCont)) /* and the app didn't signal a stop */ - { - if (iSeq >= iChunkseq) /* reached the first target ? */ - { /* then call this and next ones back in... */ - iChunkname = ((mng_chunk_headerp)pChunk)->iChunkname; - bCont = fProc (hHandle, (mng_handle)pChunk, iChunkname, iSeq); - } - - iSeq++; /* next one */ - pChunk = ((mng_chunk_headerp)pChunk)->pNext; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_ITERATE_CHUNKS, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_WRITE -mng_retcode MNG_DECL mng_copy_chunk (mng_handle hHandle, - mng_handle hChunk, - mng_handle hHandleOut) -{ - mng_datap pDataOut; - mng_chunkp pChunk; - mng_chunkp pChunkOut; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_COPY_CHUNK, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handles */ - MNG_VALIDHANDLE (hHandleOut) - - pDataOut = (mng_datap)hHandleOut; /* make outhandle addressable */ - pChunk = (mng_chunkp)hChunk; /* address the chunk */ - - if (!pDataOut->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pDataOut, MNG_FUNCTIONINVALID) - /* create a new chunk */ - iRetcode = ((mng_createchunk)((mng_chunk_headerp)pChunk)->fCreate) - (pDataOut, ((mng_chunk_headerp)pChunk), &pChunkOut); - if (!iRetcode) /* assign the chunk-specific data */ - iRetcode = ((mng_assignchunk)((mng_chunk_headerp)pChunk)->fAssign) - (pDataOut, pChunkOut, pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - mng_add_chunk (pDataOut, pChunkOut); /* and put it in the output-stream */ - - /* could it be the end of the chain ? */ - if (((mng_chunk_headerp)pChunkOut)->iChunkname == MNG_UINT_IEND) - { -#ifdef MNG_INCLUDE_JNG - if ((pDataOut->iFirstchunkadded == MNG_UINT_IHDR) || - (pDataOut->iFirstchunkadded == MNG_UINT_JHDR) ) -#else - if (pDataOut->iFirstchunkadded == MNG_UINT_IHDR) -#endif - pDataOut->bCreating = MNG_FALSE; /* right; this should be the last chunk !!! */ - } - - if (((mng_chunk_headerp)pChunkOut)->iChunkname == MNG_UINT_MEND) - pDataOut->bCreating = MNG_FALSE; /* definitely this should be the last !!! */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_COPY_CHUNK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_ihdr (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_uint8 *iBitdepth, - mng_uint8 *iColortype, - mng_uint8 *iCompression, - mng_uint8 *iFilter, - mng_uint8 *iInterlace) -{ - mng_datap pData; - mng_ihdrp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_IHDR, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_ihdrp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_IHDR) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iWidth = pChunk->iWidth; /* fill the fields */ - *iHeight = pChunk->iHeight; - *iBitdepth = pChunk->iBitdepth; - *iColortype = pChunk->iColortype; - *iCompression = pChunk->iCompression; - *iFilter = pChunk->iFilter; - *iInterlace = pChunk->iInterlace; - - /* fill the chunk */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_IHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_plte (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount, - mng_palette8 *aPalette) -{ - mng_datap pData; - mng_pltep pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PLTE, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_pltep)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_PLTE) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iCount = pChunk->iEntrycount; /* fill the fields */ - - MNG_COPY (*aPalette, pChunk->aEntries, sizeof (mng_palette8)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PLTE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_idat (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iRawlen, - mng_ptr *pRawdata) -{ - mng_datap pData; - mng_idatp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_IDAT, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_idatp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_IDAT) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iRawlen = pChunk->iDatasize; /* fill the fields */ - *pRawdata = pChunk->pData; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_IDAT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_trns (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_bool *bGlobal, - mng_uint8 *iType, - mng_uint32 *iCount, - mng_uint8arr *aAlphas, - mng_uint16 *iGray, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue, - mng_uint32 *iRawlen, - mng_uint8arr *aRawdata) -{ - mng_datap pData; - mng_trnsp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TRNS, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_trnsp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_tRNS) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *bGlobal = pChunk->bGlobal; - *iType = pChunk->iType; - *iCount = pChunk->iCount; - *iGray = pChunk->iGray; - *iRed = pChunk->iRed; - *iGreen = pChunk->iGreen; - *iBlue = pChunk->iBlue; - *iRawlen = pChunk->iRawlen; - - MNG_COPY (*aAlphas, pChunk->aEntries, sizeof (mng_uint8arr)); - MNG_COPY (*aRawdata, pChunk->aRawdata, sizeof (mng_uint8arr)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TRNS, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_gAMA -mng_retcode MNG_DECL mng_getchunk_gama (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iGamma) -{ - mng_datap pData; - mng_gamap pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_GAMA, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_gamap)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_gAMA) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iGamma = pChunk->iGamma; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_GAMA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_cHRM -mng_retcode MNG_DECL mng_getchunk_chrm (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iWhitepointx, - mng_uint32 *iWhitepointy, - mng_uint32 *iRedx, - mng_uint32 *iRedy, - mng_uint32 *iGreenx, - mng_uint32 *iGreeny, - mng_uint32 *iBluex, - mng_uint32 *iBluey) -{ - mng_datap pData; - mng_chrmp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_CHRM, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_chrmp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_cHRM) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iWhitepointx = pChunk->iWhitepointx; - *iWhitepointy = pChunk->iWhitepointy; - *iRedx = pChunk->iRedx; - *iRedy = pChunk->iRedy; - *iGreenx = pChunk->iGreenx; - *iGreeny = pChunk->iGreeny; - *iBluex = pChunk->iBluex; - *iBluey = pChunk->iBluey; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_CHRM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_sRGB -mng_retcode MNG_DECL mng_getchunk_srgb (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iRenderingintent) -{ - mng_datap pData; - mng_srgbp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SRGB, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_srgbp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_sRGB) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iRenderingintent = pChunk->iRenderingintent; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SRGB, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_iCCP -mng_retcode MNG_DECL mng_getchunk_iccp (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iNamesize, - mng_pchar *zName, - mng_uint8 *iCompression, - mng_uint32 *iProfilesize, - mng_ptr *pProfile) -{ - mng_datap pData; - mng_iccpp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ICCP, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_iccpp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_iCCP) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iNamesize = pChunk->iNamesize; - *zName = pChunk->zName; - *iCompression = pChunk->iCompression; - *iProfilesize = pChunk->iProfilesize; - *pProfile = pChunk->pProfile; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ICCP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_tEXt -mng_retcode MNG_DECL mng_getchunk_text (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iKeywordsize, - mng_pchar *zKeyword, - mng_uint32 *iTextsize, - mng_pchar *zText) -{ - mng_datap pData; - mng_textp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TEXT, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_textp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_tEXt) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - /* fill the fields */ - *iKeywordsize = pChunk->iKeywordsize; - *zKeyword = pChunk->zKeyword; - *iTextsize = pChunk->iTextsize; - *zText = pChunk->zText; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TEXT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_zTXt -mng_retcode MNG_DECL mng_getchunk_ztxt (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iKeywordsize, - mng_pchar *zKeyword, - mng_uint8 *iCompression, - mng_uint32 *iTextsize, - mng_pchar *zText) -{ - mng_datap pData; - mng_ztxtp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ZTXT, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_ztxtp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_zTXt) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - /* fill the fields */ - *iKeywordsize = pChunk->iKeywordsize; - *zKeyword = pChunk->zKeyword; - *iCompression = pChunk->iCompression; - *iTextsize = pChunk->iTextsize; - *zText = pChunk->zText; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ZTXT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_iTXt -mng_retcode MNG_DECL mng_getchunk_itxt (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iKeywordsize, - mng_pchar *zKeyword, - mng_uint8 *iCompressionflag, - mng_uint8 *iCompressionmethod, - mng_uint32 *iLanguagesize, - mng_pchar *zLanguage, - mng_uint32 *iTranslationsize, - mng_pchar *zTranslation, - mng_uint32 *iTextsize, - mng_pchar *zText) -{ - mng_datap pData; - mng_itxtp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ITXT, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_itxtp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_iTXt) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - /* fill the fields */ - *iKeywordsize = pChunk->iKeywordsize; - *zKeyword = pChunk->zKeyword; - *iCompressionflag = pChunk->iCompressionflag; - *iCompressionmethod = pChunk->iCompressionmethod; - *iLanguagesize = pChunk->iLanguagesize; - *zLanguage = pChunk->zLanguage; - *iTranslationsize = pChunk->iTranslationsize; - *zTranslation = pChunk->zTranslation; - *iTextsize = pChunk->iTextsize; - *zText = pChunk->zText; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ITXT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_bKGD -mng_retcode MNG_DECL mng_getchunk_bkgd (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iType, - mng_uint8 *iIndex, - mng_uint16 *iGray, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue) -{ - mng_datap pData; - mng_bkgdp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_BKGD, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_bkgdp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_bKGD) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iType = pChunk->iType; - *iIndex = pChunk->iIndex; - *iGray = pChunk->iGray; - *iRed = pChunk->iRed; - *iGreen = pChunk->iGreen; - *iBlue = pChunk->iBlue; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_BKGD, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_pHYs -mng_retcode MNG_DECL mng_getchunk_phys (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iSizex, - mng_uint32 *iSizey, - mng_uint8 *iUnit) -{ - mng_datap pData; - mng_physp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PHYS, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_physp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_pHYs) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iSizex = pChunk->iSizex; - *iSizey = pChunk->iSizey; - *iUnit = pChunk->iUnit; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PHYS, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_sBIT -mng_retcode MNG_DECL mng_getchunk_sbit (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iType, - mng_uint8arr4 *aBits) -{ - mng_datap pData; - mng_sbitp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SBIT, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_sbitp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_sBIT) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; - *iType = pChunk->iType; - (*aBits)[0] = pChunk->aBits[0]; - (*aBits)[1] = pChunk->aBits[1]; - (*aBits)[2] = pChunk->aBits[2]; - (*aBits)[3] = pChunk->aBits[3]; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SBIT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_sPLT -mng_retcode MNG_DECL mng_getchunk_splt (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iNamesize, - mng_pchar *zName, - mng_uint8 *iSampledepth, - mng_uint32 *iEntrycount, - mng_ptr *pEntries) -{ - mng_datap pData; - mng_spltp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SPLT, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_spltp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_sPLT) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iNamesize = pChunk->iNamesize; - *zName = pChunk->zName; - *iSampledepth = pChunk->iSampledepth; - *iEntrycount = pChunk->iEntrycount; - *pEntries = pChunk->pEntries; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SPLT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_hIST -mng_retcode MNG_DECL mng_getchunk_hist (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iEntrycount, - mng_uint16arr *aEntries) -{ - mng_datap pData; - mng_histp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_HIST, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_histp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_hIST) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iEntrycount = pChunk->iEntrycount; /* fill the fields */ - - MNG_COPY (*aEntries, pChunk->aEntries, sizeof (mng_uint16arr)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_HIST, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_tIME -mng_retcode MNG_DECL mng_getchunk_time (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iYear, - mng_uint8 *iMonth, - mng_uint8 *iDay, - mng_uint8 *iHour, - mng_uint8 *iMinute, - mng_uint8 *iSecond) -{ - mng_datap pData; - mng_timep pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TIME, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_timep)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_tIME) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iYear = pChunk->iYear; /* fill the fields */ - *iMonth = pChunk->iMonth; - *iDay = pChunk->iDay; - *iHour = pChunk->iHour; - *iMinute = pChunk->iMinute; - *iSecond = pChunk->iSecond; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TIME, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_mhdr (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_uint32 *iTicks, - mng_uint32 *iLayercount, - mng_uint32 *iFramecount, - mng_uint32 *iPlaytime, - mng_uint32 *iSimplicity) -{ - mng_datap pData; - mng_mhdrp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MHDR, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_mhdrp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iWidth = pChunk->iWidth; /* fill the fields */ - *iHeight = pChunk->iHeight; - *iTicks = pChunk->iTicks; - *iLayercount = pChunk->iLayercount; - *iFramecount = pChunk->iFramecount; - *iPlaytime = pChunk->iPlaytime; - *iSimplicity = pChunk->iSimplicity; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_LOOP -mng_retcode MNG_DECL mng_getchunk_loop (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iLevel, - mng_uint32 *iRepeat, - mng_uint8 *iTermination, - mng_uint32 *iItermin, - mng_uint32 *iItermax, - mng_uint32 *iCount, - mng_uint32p *pSignals) -{ - mng_datap pData; - mng_loopp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_LOOP, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_loopp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_LOOP) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iLevel = pChunk->iLevel; /* fill teh fields */ - *iRepeat = pChunk->iRepeat; - *iTermination = pChunk->iTermination; - *iItermin = pChunk->iItermin; - *iItermax = pChunk->iItermax; - *iCount = pChunk->iCount; - *pSignals = pChunk->pSignals; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_LOOP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_endl (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iLevel) -{ - mng_datap pData; - mng_endlp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ENDL, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_endlp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_ENDL) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iLevel = pChunk->iLevel; /* fill the field */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ENDL, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_DEFI -mng_retcode MNG_DECL mng_getchunk_defi (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iObjectid, - mng_uint8 *iDonotshow, - mng_uint8 *iConcrete, - mng_bool *bHasloca, - mng_int32 *iXlocation, - mng_int32 *iYlocation, - mng_bool *bHasclip, - mng_int32 *iLeftcb, - mng_int32 *iRightcb, - mng_int32 *iTopcb, - mng_int32 *iBottomcb) -{ - mng_datap pData; - mng_defip pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DEFI, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_defip)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_DEFI) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iObjectid = pChunk->iObjectid; /* fill the fields */ - *iDonotshow = pChunk->iDonotshow; - *iConcrete = pChunk->iConcrete; - *bHasloca = pChunk->bHasloca; - *iXlocation = pChunk->iXlocation; - *iYlocation = pChunk->iYlocation; - *bHasclip = pChunk->bHasclip; - *iLeftcb = pChunk->iLeftcb; - *iRightcb = pChunk->iRightcb; - *iTopcb = pChunk->iTopcb; - *iBottomcb = pChunk->iBottomcb; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DEFI, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_BASI -mng_retcode MNG_DECL mng_getchunk_basi (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_uint8 *iBitdepth, - mng_uint8 *iColortype, - mng_uint8 *iCompression, - mng_uint8 *iFilter, - mng_uint8 *iInterlace, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue, - mng_uint16 *iAlpha, - mng_uint8 *iViewable) -{ - mng_datap pData; - mng_basip pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_BASI, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_basip)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_BASI) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iWidth = pChunk->iWidth; /* fill the fields */ - *iHeight = pChunk->iHeight; - *iBitdepth = pChunk->iBitdepth; - *iColortype = pChunk->iColortype; - *iCompression = pChunk->iCompression; - *iFilter = pChunk->iFilter; - *iInterlace = pChunk->iInterlace; - *iRed = pChunk->iRed; - *iGreen = pChunk->iGreen; - *iBlue = pChunk->iBlue; - *iAlpha = pChunk->iAlpha; - *iViewable = pChunk->iViewable; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_BASI, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_CLON -mng_retcode MNG_DECL mng_getchunk_clon (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iSourceid, - mng_uint16 *iCloneid, - mng_uint8 *iClonetype, - mng_uint8 *iDonotshow, - mng_uint8 *iConcrete, - mng_bool *bHasloca, - mng_uint8 *iLocationtype, - mng_int32 *iLocationx, - mng_int32 *iLocationy) -{ - mng_datap pData; - mng_clonp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_CLON, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_clonp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_CLON) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iSourceid = pChunk->iSourceid; /* fill the fields */ - *iCloneid = pChunk->iCloneid; - *iClonetype = pChunk->iClonetype; - *iDonotshow = pChunk->iDonotshow; - *iConcrete = pChunk->iConcrete; - *bHasloca = pChunk->bHasloca; - *iLocationtype = pChunk->iLocationtype; - *iLocationx = pChunk->iLocationx; - *iLocationy = pChunk->iLocationy; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_CLON, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_PAST -mng_retcode MNG_DECL mng_getchunk_past (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iDestid, - mng_uint8 *iTargettype, - mng_int32 *iTargetx, - mng_int32 *iTargety, - mng_uint32 *iCount) -{ - mng_datap pData; - mng_pastp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PAST, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_pastp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_PAST) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iDestid = pChunk->iDestid; /* fill the fields */ - *iTargettype = pChunk->iTargettype; - *iTargetx = pChunk->iTargetx; - *iTargety = pChunk->iTargety; - *iCount = pChunk->iCount; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PAST, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_PAST -mng_retcode MNG_DECL mng_getchunk_past_src (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_uint16 *iSourceid, - mng_uint8 *iComposition, - mng_uint8 *iOrientation, - mng_uint8 *iOffsettype, - mng_int32 *iOffsetx, - mng_int32 *iOffsety, - mng_uint8 *iBoundarytype, - mng_int32 *iBoundaryl, - mng_int32 *iBoundaryr, - mng_int32 *iBoundaryt, - mng_int32 *iBoundaryb) -{ - mng_datap pData; - mng_pastp pChunk; - mng_past_sourcep pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PAST_SRC, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_pastp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_PAST) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - if (iEntry >= pChunk->iCount) /* valid index ? */ - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - /* address the entry */ - pEntry = pChunk->pSources + iEntry; - - *iSourceid = pEntry->iSourceid; /* fill the fields */ - *iComposition = pEntry->iComposition; - *iOrientation = pEntry->iOrientation; - *iOffsettype = pEntry->iOffsettype; - *iOffsetx = pEntry->iOffsetx; - *iOffsety = pEntry->iOffsety; - *iBoundarytype = pEntry->iBoundarytype; - *iBoundaryl = pEntry->iBoundaryl; - *iBoundaryr = pEntry->iBoundaryr; - *iBoundaryt = pEntry->iBoundaryt; - *iBoundaryb = pEntry->iBoundaryb; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PAST_SRC, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_DISC -mng_retcode MNG_DECL mng_getchunk_disc (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount, - mng_uint16p *pObjectids) -{ - mng_datap pData; - mng_discp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DISC, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_discp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_DISC) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iCount = pChunk->iCount; /* fill the fields */ - *pObjectids = pChunk->pObjectids; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DISC, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_BACK -mng_retcode MNG_DECL mng_getchunk_back (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue, - mng_uint8 *iMandatory, - mng_uint16 *iImageid, - mng_uint8 *iTile) -{ - mng_datap pData; - mng_backp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_BACK, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_backp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_BACK) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iRed = pChunk->iRed; /* fill the fields */ - *iGreen = pChunk->iGreen; - *iBlue = pChunk->iBlue; - *iMandatory = pChunk->iMandatory; - *iImageid = pChunk->iImageid; - *iTile = pChunk->iTile; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_BACK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_FRAM -mng_retcode MNG_DECL mng_getchunk_fram (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iMode, - mng_uint32 *iNamesize, - mng_pchar *zName, - mng_uint8 *iChangedelay, - mng_uint8 *iChangetimeout, - mng_uint8 *iChangeclipping, - mng_uint8 *iChangesyncid, - mng_uint32 *iDelay, - mng_uint32 *iTimeout, - mng_uint8 *iBoundarytype, - mng_int32 *iBoundaryl, - mng_int32 *iBoundaryr, - mng_int32 *iBoundaryt, - mng_int32 *iBoundaryb, - mng_uint32 *iCount, - mng_uint32p *pSyncids) -{ - mng_datap pData; - mng_framp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_FRAM, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_framp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_FRAM) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iMode = pChunk->iMode; - *iNamesize = pChunk->iNamesize; - *zName = pChunk->zName; - *iChangedelay = pChunk->iChangedelay; - *iChangetimeout = pChunk->iChangetimeout; - *iChangeclipping = pChunk->iChangeclipping; - *iChangesyncid = pChunk->iChangesyncid; - *iDelay = pChunk->iDelay; - *iTimeout = pChunk->iTimeout; - *iBoundarytype = pChunk->iBoundarytype; - *iBoundaryl = pChunk->iBoundaryl; - *iBoundaryr = pChunk->iBoundaryr; - *iBoundaryt = pChunk->iBoundaryt; - *iBoundaryb = pChunk->iBoundaryb; - *iCount = pChunk->iCount; - *pSyncids = pChunk->pSyncids; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_FRAM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_MOVE -mng_retcode MNG_DECL mng_getchunk_move (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iFirstid, - mng_uint16 *iLastid, - mng_uint8 *iMovetype, - mng_int32 *iMovex, - mng_int32 *iMovey) -{ - mng_datap pData; - mng_movep pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MOVE, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_movep)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_MOVE) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iFirstid = pChunk->iFirstid; /* fill the fields */ - *iLastid = pChunk->iLastid; - *iMovetype = pChunk->iMovetype; - *iMovex = pChunk->iMovex; - *iMovey = pChunk->iMovey; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MOVE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_CLIP -mng_retcode MNG_DECL mng_getchunk_clip (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iFirstid, - mng_uint16 *iLastid, - mng_uint8 *iCliptype, - mng_int32 *iClipl, - mng_int32 *iClipr, - mng_int32 *iClipt, - mng_int32 *iClipb) -{ - mng_datap pData; - mng_clipp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_CLIP, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_clipp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_CLIP) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iFirstid = pChunk->iFirstid; /* fill the fields */ - *iLastid = pChunk->iLastid; - *iCliptype = pChunk->iCliptype; - *iClipl = pChunk->iClipl; - *iClipr = pChunk->iClipr; - *iClipt = pChunk->iClipt; - *iClipb = pChunk->iClipb; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_CLIP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SHOW -mng_retcode MNG_DECL mng_getchunk_show (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint16 *iFirstid, - mng_uint16 *iLastid, - mng_uint8 *iMode) -{ - mng_datap pData; - mng_showp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SHOW, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_showp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_SHOW) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iFirstid = pChunk->iFirstid; - *iLastid = pChunk->iLastid; - *iMode = pChunk->iMode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SHOW, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_TERM -mng_retcode MNG_DECL mng_getchunk_term (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iTermaction, - mng_uint8 *iIteraction, - mng_uint32 *iDelay, - mng_uint32 *iItermax) -{ - mng_datap pData; - mng_termp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TERM, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_termp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_TERM) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iTermaction = pChunk->iTermaction; /* fill the fields */ - *iIteraction = pChunk->iIteraction; - *iDelay = pChunk->iDelay; - *iItermax = pChunk->iItermax; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TERM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SAVE -mng_retcode MNG_DECL mng_getchunk_save (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iOffsettype, - mng_uint32 *iCount) -{ - mng_datap pData; - mng_savep pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SAVE, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_savep)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_SAVE) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iOffsettype = pChunk->iOffsettype; - *iCount = pChunk->iCount; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SAVE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_save_entry (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_uint8 *iEntrytype, - mng_uint32arr2 *iOffset, - mng_uint32arr2 *iStarttime, - mng_uint32 *iLayernr, - mng_uint32 *iFramenr, - mng_uint32 *iNamesize, - mng_pchar *zName) -{ - mng_datap pData; - mng_savep pChunk; - mng_save_entryp pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SAVE_ENTRY, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_savep)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_SAVE) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - if (iEntry >= pChunk->iCount) /* valid index ? */ - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - - pEntry = pChunk->pEntries + iEntry; /* address the entry */ - /* fill the fields */ - *iEntrytype = pEntry->iEntrytype; - (*iOffset)[0] = pEntry->iOffset[0]; - (*iOffset)[1] = pEntry->iOffset[1]; - (*iStarttime)[0] = pEntry->iStarttime[0]; - (*iStarttime)[1] = pEntry->iStarttime[1]; - *iLayernr = pEntry->iLayernr; - *iFramenr = pEntry->iFramenr; - *iNamesize = pEntry->iNamesize; - *zName = pEntry->zName; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SAVE_ENTRY, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SEEK -mng_retcode MNG_DECL mng_getchunk_seek (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iNamesize, - mng_pchar *zName) -{ - mng_datap pData; - mng_seekp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SEEK, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_seekp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_SEEK) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iNamesize = pChunk->iNamesize; /* fill the fields */ - *zName = pChunk->zName; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SEEK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_eXPI -mng_retcode MNG_DECL mng_getchunk_expi (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iSnapshotid, - mng_uint32 *iNamesize, - mng_pchar *zName) -{ - mng_datap pData; - mng_expip pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_EXPI, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_expip)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_eXPI) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iSnapshotid = pChunk->iSnapshotid; /* fill the fields */ - *iNamesize = pChunk->iNamesize; - *zName = pChunk->zName; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_EXPI, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_fPRI -mng_retcode MNG_DECL mng_getchunk_fpri (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iDeltatype, - mng_uint8 *iPriority) -{ - mng_datap pData; - mng_fprip pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_FPRI, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_fprip)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_fPRI) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iDeltatype = pChunk->iDeltatype; /* fill the fields */ - *iPriority = pChunk->iPriority; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_FPRI, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_nEED -mng_retcode MNG_DECL mng_getchunk_need (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iKeywordssize, - mng_pchar *zKeywords) -{ - mng_datap pData; - mng_needp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_NEED, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_needp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_nEED) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - /* fill the fields */ - *iKeywordssize = pChunk->iKeywordssize; - *zKeywords = pChunk->zKeywords; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_NEED, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_pHYg -mng_retcode MNG_DECL mng_getchunk_phyg (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iSizex, - mng_uint32 *iSizey, - mng_uint8 *iUnit) -{ - mng_datap pData; - mng_phygp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PHYG, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_phygp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_pHYg) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iSizex = pChunk->iSizex; - *iSizey = pChunk->iSizey; - *iUnit = pChunk->iUnit; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PHYG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG - -mng_retcode MNG_DECL mng_getchunk_jhdr (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_uint8 *iColortype, - mng_uint8 *iImagesampledepth, - mng_uint8 *iImagecompression, - mng_uint8 *iImageinterlace, - mng_uint8 *iAlphasampledepth, - mng_uint8 *iAlphacompression, - mng_uint8 *iAlphafilter, - mng_uint8 *iAlphainterlace) -{ - mng_datap pData; - mng_jhdrp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_JHDR, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_jhdrp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_JHDR) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iWidth = pChunk->iWidth; /* fill the fields */ - *iHeight = pChunk->iHeight; - *iColortype = pChunk->iColortype; - *iImagesampledepth = pChunk->iImagesampledepth; - *iImagecompression = pChunk->iImagecompression; - *iImageinterlace = pChunk->iImageinterlace; - *iAlphasampledepth = pChunk->iAlphasampledepth; - *iAlphacompression = pChunk->iAlphacompression; - *iAlphafilter = pChunk->iAlphafilter; - *iAlphainterlace = pChunk->iAlphainterlace; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_JHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG - -mng_retcode MNG_DECL mng_getchunk_jdat (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iRawlen, - mng_ptr *pRawdata) -{ - mng_datap pData; - mng_jdatp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_JDAT, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_jdatp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_JDAT) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iRawlen = pChunk->iDatasize; /* fill the fields */ - *pRawdata = pChunk->pData; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_JDAT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG - -mng_retcode MNG_DECL mng_getchunk_jdaa (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iRawlen, - mng_ptr *pRawdata) -{ - mng_datap pData; - mng_jdaap pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_JDAA, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_jdaap)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_JDAA) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iRawlen = pChunk->iDatasize; /* fill the fields */ - *pRawdata = pChunk->pData; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_JDAA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -mng_retcode MNG_DECL mng_getchunk_dhdr (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iObjectid, - mng_uint8 *iImagetype, - mng_uint8 *iDeltatype, - mng_uint32 *iBlockwidth, - mng_uint32 *iBlockheight, - mng_uint32 *iBlockx, - mng_uint32 *iBlocky) -{ - mng_datap pData; - mng_dhdrp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DHDR, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_dhdrp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_DHDR) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iObjectid = pChunk->iObjectid; /* fill the fields */ - *iImagetype = pChunk->iImagetype; - *iDeltatype = pChunk->iDeltatype; - *iBlockwidth = pChunk->iBlockwidth; - *iBlockheight = pChunk->iBlockheight; - *iBlockx = pChunk->iBlockx; - *iBlocky = pChunk->iBlocky; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -mng_retcode MNG_DECL mng_getchunk_prom (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iColortype, - mng_uint8 *iSampledepth, - mng_uint8 *iFilltype) -{ - mng_datap pData; - mng_promp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PROM, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_promp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_PROM) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iColortype = pChunk->iColortype; /* fill the fields */ - *iSampledepth = pChunk->iSampledepth; - *iFilltype = pChunk->iFilltype; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PROM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -mng_retcode MNG_DECL mng_getchunk_pplt (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iDeltatype, - mng_uint32 *iCount) -{ - mng_datap pData; - mng_ppltp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PPLT, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_ppltp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_PPLT) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iDeltatype = pChunk->iDeltatype; /* fill the fields */ - *iCount = pChunk->iCount; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PPLT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -mng_retcode MNG_DECL mng_getchunk_pplt_entry (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue, - mng_uint16 *iAlpha, - mng_bool *bUsed) -{ - mng_datap pData; - mng_ppltp pChunk; - mng_pplt_entryp pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PPLT_ENTRY, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_ppltp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_PPLT) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - if (iEntry >= pChunk->iCount) /* valid index ? */ - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - - pEntry = &pChunk->aEntries[iEntry]; /* address the entry */ - - *iRed = pEntry->iRed; /* fill the fields */ - *iGreen = pEntry->iGreen; - *iBlue = pEntry->iBlue; - *iAlpha = pEntry->iAlpha; - *bUsed = pEntry->bUsed; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PPLT_ENTRY, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -mng_retcode MNG_DECL mng_getchunk_drop (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount, - mng_chunkidp *pChunknames) -{ - mng_datap pData; - mng_dropp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DROP, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_dropp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_DROP) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iCount = pChunk->iCount; /* fill the fields */ - *pChunknames = pChunk->pChunknames; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DROP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_DBYK -mng_retcode MNG_DECL mng_getchunk_dbyk (mng_handle hHandle, - mng_handle hChunk, - mng_chunkid *iChunkname, - mng_uint8 *iPolarity, - mng_uint32 *iKeywordssize, - mng_pchar *zKeywords) -{ - mng_datap pData; - mng_dbykp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DBYK, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_dbykp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_DBYK) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iChunkname = pChunk->iChunkname; /* fill the fields */ - *iPolarity = pChunk->iPolarity; - *iKeywordssize = pChunk->iKeywordssize; - *zKeywords = pChunk->zKeywords; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DBYK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_ORDR -mng_retcode MNG_DECL mng_getchunk_ordr (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount) -{ - mng_datap pData; - mng_ordrp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ORDR, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_ordrp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_ORDR) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iCount = pChunk->iCount; /* fill the field */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ORDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_ORDR -mng_retcode MNG_DECL mng_getchunk_ordr_entry (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_chunkid *iChunkname, - mng_uint8 *iOrdertype) -{ - mng_datap pData; - mng_ordrp pChunk; - mng_ordr_entryp pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ORDR_ENTRY, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_ordrp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_ORDR) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - if (iEntry >= pChunk->iCount) /* valid index ? */ - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - - pEntry = pChunk->pEntries + iEntry; /* address the proper entry */ - - *iChunkname = pEntry->iChunkname; /* fill the fields */ - *iOrdertype = pEntry->iOrdertype; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ORDR_ENTRY, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_MAGN -mng_retcode MNG_DECL mng_getchunk_magn (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iFirstid, - mng_uint16 *iLastid, - mng_uint16 *iMethodX, - mng_uint16 *iMX, - mng_uint16 *iMY, - mng_uint16 *iML, - mng_uint16 *iMR, - mng_uint16 *iMT, - mng_uint16 *iMB, - mng_uint16 *iMethodY) -{ - mng_datap pData; - mng_magnp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MAGN, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_magnp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_MAGN) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iFirstid = pChunk->iFirstid; /* fill the fields */ - *iLastid = pChunk->iLastid; - *iMethodX = (mng_uint16)pChunk->iMethodX; - *iMX = pChunk->iMX; - *iMY = pChunk->iMY; - *iML = pChunk->iML; - *iMR = pChunk->iMR; - *iMT = pChunk->iMT; - *iMB = pChunk->iMB; - *iMethodY = (mng_uint16)pChunk->iMethodY; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MAGN, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_MPNG_PROPOSAL -MNG_EXT mng_retcode MNG_DECL mng_getchunk_mpng (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iFramewidth, - mng_uint32 *iFrameheight, - mng_uint16 *iNumplays, - mng_uint16 *iTickspersec, - mng_uint8 *iCompressionmethod, - mng_uint32 *iCount) -{ - mng_datap pData; - mng_mpngp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MPNG, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_mpngp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_mpNG) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - /* fill the fields */ - *iFramewidth = pChunk->iFramewidth; - *iFrameheight = pChunk->iFrameheight; - *iNumplays = pChunk->iNumplays; - *iTickspersec = pChunk->iTickspersec; - *iCompressionmethod = pChunk->iCompressionmethod; - *iCount = pChunk->iFramessize / sizeof (mng_mpng_frame); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MPNG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_MPNG_PROPOSAL -MNG_EXT mng_retcode MNG_DECL mng_getchunk_mpng_frame (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_uint32 *iX, - mng_uint32 *iY, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_int32 *iXoffset, - mng_int32 *iYoffset, - mng_uint16 *iTicks) -{ - mng_datap pData; - mng_mpngp pChunk; - mng_mpng_framep pFrame; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MPNG_FRAME, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_mpngp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_mpNG) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - /* valid index ? */ - if (iEntry >= (pChunk->iFramessize / sizeof (mng_mpng_frame))) - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - - pFrame = pChunk->pFrames + iEntry; /* address the entry */ - /* fill the fields */ - *iX = pFrame->iX; - *iY = pFrame->iY; - *iWidth = pFrame->iWidth; - *iHeight = pFrame->iHeight; - *iXoffset = pFrame->iXoffset; - *iYoffset = pFrame->iYoffset; - *iTicks = pFrame->iTicks; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MPNG_FRAME, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_evNT -mng_retcode MNG_DECL mng_getchunk_evnt (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount) -{ - mng_datap pData; - mng_evntp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_EVNT, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_evntp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_evNT) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iCount = pChunk->iCount; /* fill the fields */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_EVNT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_evnt_entry (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_uint8 *iEventtype, - mng_uint8 *iMasktype, - mng_int32 *iLeft, - mng_int32 *iRight, - mng_int32 *iTop, - mng_int32 *iBottom, - mng_uint16 *iObjectid, - mng_uint8 *iIndex, - mng_uint32 *iSegmentnamesize, - mng_pchar *zSegmentname) -{ - mng_datap pData; - mng_evntp pChunk; - mng_evnt_entryp pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_EVNT_ENTRY, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_evntp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_evNT) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - if (iEntry >= pChunk->iCount) /* valid index ? */ - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - - pEntry = pChunk->pEntries + iEntry; /* address the entry */ - /* fill the fields */ - *iEventtype = pEntry->iEventtype; - *iMasktype = pEntry->iMasktype; - *iLeft = pEntry->iLeft; - *iRight = pEntry->iRight; - *iTop = pEntry->iTop; - *iBottom = pEntry->iBottom; - *iObjectid = pEntry->iObjectid; - *iIndex = pEntry->iIndex; - *iSegmentnamesize = pEntry->iSegmentnamesize; - *zSegmentname = pEntry->zSegmentname; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_EVNT_ENTRY, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_unknown (mng_handle hHandle, - mng_handle hChunk, - mng_chunkid *iChunkname, - mng_uint32 *iRawlen, - mng_ptr *pRawdata) -{ - mng_datap pData; - mng_unknown_chunkp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_UNKNOWN, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_unknown_chunkp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.fCleanup != mng_free_unknown) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - /* fill the fields */ - *iChunkname = pChunk->sHeader.iChunkname; - *iRawlen = pChunk->iDatasize; - *pRawdata = pChunk->pData; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_UNKNOWN, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_WRITE_PROCS - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_TERM -MNG_LOCAL mng_bool check_term (mng_datap pData, - mng_chunkid iChunkname) -{ - mng_chunk_headerp pChunk = (mng_chunk_headerp)pData->pLastchunk; - - if (!pChunk) /* nothing added yet ? */ - return MNG_TRUE; - /* last added chunk is TERM ? */ - if (pChunk->iChunkname != MNG_UINT_TERM) - return MNG_TRUE; - /* previous to last is MHDR ? */ - if ((pChunk->pPrev) && (((mng_chunk_headerp)pChunk->pPrev)->iChunkname == MNG_UINT_MHDR)) - return MNG_TRUE; - - if (iChunkname == MNG_UINT_SEEK) /* new chunk to be added is SEEK ? */ - return MNG_TRUE; - - return MNG_FALSE; -} -#endif - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_ihdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_IHDR, mng_init_general, mng_free_general, mng_read_ihdr, mng_write_ihdr, mng_assign_general, 0, 0, sizeof(mng_ihdr)}; -#else - {MNG_UINT_IHDR, mng_init_ihdr, mng_free_ihdr, mng_read_ihdr, mng_write_ihdr, mng_assign_ihdr, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IHDR, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_IHDR)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_ihdr (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_IHDR, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - ((mng_ihdrp)pChunk)->iWidth = iWidth; - ((mng_ihdrp)pChunk)->iHeight = iHeight; - ((mng_ihdrp)pChunk)->iBitdepth = iBitdepth; - ((mng_ihdrp)pChunk)->iColortype = iColortype; - ((mng_ihdrp)pChunk)->iCompression = iCompression; - ((mng_ihdrp)pChunk)->iFilter = iFilter; - ((mng_ihdrp)pChunk)->iInterlace = iInterlace; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_plte (mng_handle hHandle, - mng_uint32 iCount, - mng_palette8 aPalette) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_PLTE, mng_init_general, mng_free_general, mng_read_plte, mng_write_plte, mng_assign_general, 0, 0, sizeof(mng_plte)}; -#else - {MNG_UINT_PLTE, mng_init_plte, mng_free_plte, mng_read_plte, mng_write_plte, mng_assign_plte, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PLTE, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_PLTE)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_plte (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_PLTE, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_pltep)pChunk)->iEntrycount = iCount; - ((mng_pltep)pChunk)->bEmpty = (mng_bool)(iCount == 0); - - MNG_COPY (((mng_pltep)pChunk)->aEntries, aPalette, sizeof (mng_palette8)); - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PLTE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_idat (mng_handle hHandle, - mng_uint32 iRawlen, - mng_ptr pRawdata) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_IDAT, mng_init_general, mng_free_idat, mng_read_idat, mng_write_idat, mng_assign_idat, 0, 0, sizeof(mng_idat)}; -#else - {MNG_UINT_IDAT, mng_init_idat, mng_free_idat, mng_read_idat, mng_write_idat, mng_assign_idat, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IDAT, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_IDAT)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_idat (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_IDAT, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_idatp)pChunk)->bEmpty = (mng_bool)(iRawlen == 0); - ((mng_idatp)pChunk)->iDatasize = iRawlen; - - if (iRawlen) - { - MNG_ALLOC (pData, ((mng_idatp)pChunk)->pData, iRawlen); - MNG_COPY (((mng_idatp)pChunk)->pData, pRawdata, iRawlen); - } - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IDAT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_iend (mng_handle hHandle) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_IEND, mng_init_general, mng_free_general, mng_read_iend, mng_write_iend, mng_assign_general, 0, 0, sizeof(mng_iend)}; -#else - {MNG_UINT_IEND, mng_init_iend, mng_free_iend, mng_read_iend, mng_write_iend, mng_assign_iend, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IEND, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_IEND)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_iend (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_IEND, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_INCLUDE_JNG - if ((pData->iFirstchunkadded == MNG_UINT_IHDR) || - (pData->iFirstchunkadded == MNG_UINT_JHDR) ) -#else - if (pData->iFirstchunkadded == MNG_UINT_IHDR) -#endif - pData->bCreating = MNG_FALSE; /* should be last chunk !!! */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IEND, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_trns (mng_handle hHandle, - mng_bool bEmpty, - mng_bool bGlobal, - mng_uint8 iType, - mng_uint32 iCount, - mng_uint8arr aAlphas, - mng_uint16 iGray, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint32 iRawlen, - mng_uint8arr aRawdata) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_tRNS, mng_init_general, mng_free_general, mng_read_trns, mng_write_trns, mng_assign_general, 0, 0, sizeof(mng_trns)}; -#else - {MNG_UINT_tRNS, mng_init_trns, mng_free_trns, mng_read_trns, mng_write_trns, mng_assign_trns, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TRNS, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_tRNS)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_trns (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_tRNS, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_trnsp)pChunk)->bEmpty = bEmpty; - ((mng_trnsp)pChunk)->bGlobal = bGlobal; - ((mng_trnsp)pChunk)->iType = iType; - ((mng_trnsp)pChunk)->iCount = iCount; - ((mng_trnsp)pChunk)->iGray = iGray; - ((mng_trnsp)pChunk)->iRed = iRed; - ((mng_trnsp)pChunk)->iGreen = iGreen; - ((mng_trnsp)pChunk)->iBlue = iBlue; - ((mng_trnsp)pChunk)->iRawlen = iRawlen; - - MNG_COPY (((mng_trnsp)pChunk)->aEntries, aAlphas, sizeof (mng_uint8arr)); - MNG_COPY (((mng_trnsp)pChunk)->aRawdata, aRawdata, sizeof (mng_uint8arr)); - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TRNS, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_gAMA -mng_retcode MNG_DECL mng_putchunk_gama (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iGamma) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_gAMA, mng_init_general, mng_free_general, mng_read_gama, mng_write_gama, mng_assign_general, 0, 0, sizeof(mng_gama)}; -#else - {MNG_UINT_gAMA, mng_init_gama, mng_free_gama, mng_read_gama, mng_write_gama, mng_assign_gama, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_GAMA, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_gAMA)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_gama (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_gAMA, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_gamap)pChunk)->bEmpty = bEmpty; - ((mng_gamap)pChunk)->iGamma = iGamma; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_GAMA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_cHRM -mng_retcode MNG_DECL mng_putchunk_chrm (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iWhitepointx, - mng_uint32 iWhitepointy, - mng_uint32 iRedx, - mng_uint32 iRedy, - mng_uint32 iGreenx, - mng_uint32 iGreeny, - mng_uint32 iBluex, - mng_uint32 iBluey) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_cHRM, mng_init_general, mng_free_general, mng_read_chrm, mng_write_chrm, mng_assign_general, 0, 0, sizeof(mng_chrm)}; -#else - {MNG_UINT_cHRM, mng_init_chrm, mng_free_chrm, mng_read_chrm, mng_write_chrm, mng_assign_chrm, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_CHRM, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_cHRM)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_chrm (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_cHRM, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_chrmp)pChunk)->bEmpty = bEmpty; - ((mng_chrmp)pChunk)->iWhitepointx = iWhitepointx; - ((mng_chrmp)pChunk)->iWhitepointy = iWhitepointy; - ((mng_chrmp)pChunk)->iRedx = iRedx; - ((mng_chrmp)pChunk)->iRedy = iRedy; - ((mng_chrmp)pChunk)->iGreenx = iGreenx; - ((mng_chrmp)pChunk)->iGreeny = iGreeny; - ((mng_chrmp)pChunk)->iBluex = iBluex; - ((mng_chrmp)pChunk)->iBluey = iBluey; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_CHRM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_sRGB -mng_retcode MNG_DECL mng_putchunk_srgb (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iRenderingintent) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_sRGB, mng_init_general, mng_free_general, mng_read_srgb, mng_write_srgb, mng_assign_general, 0, 0, sizeof(mng_srgb)}; -#else - {MNG_UINT_sRGB, mng_init_srgb, mng_free_srgb, mng_read_srgb, mng_write_srgb, mng_assign_srgb, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SRGB, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_sRGB)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_srgb (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_sRGB, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_srgbp)pChunk)->bEmpty = bEmpty; - ((mng_srgbp)pChunk)->iRenderingintent = iRenderingintent; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SRGB, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_iCCP -mng_retcode MNG_DECL mng_putchunk_iccp (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iNamesize, - mng_pchar zName, - mng_uint8 iCompression, - mng_uint32 iProfilesize, - mng_ptr pProfile) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_iCCP, mng_init_general, mng_free_iccp, mng_read_iccp, mng_write_iccp, mng_assign_iccp, 0, 0, sizeof(mng_iccp)}; -#else - {MNG_UINT_iCCP, mng_init_iccp, mng_free_iccp, mng_read_iccp, mng_write_iccp, mng_assign_iccp, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ICCP, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_iCCP)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_iccp (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_iCCP, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_iccpp)pChunk)->bEmpty = bEmpty; - ((mng_iccpp)pChunk)->iNamesize = iNamesize; - ((mng_iccpp)pChunk)->iCompression = iCompression; - ((mng_iccpp)pChunk)->iProfilesize = iProfilesize; - - if (iNamesize) - { - MNG_ALLOC (pData, ((mng_iccpp)pChunk)->zName, iNamesize + 1); - MNG_COPY (((mng_iccpp)pChunk)->zName, zName, iNamesize); - } - - if (iProfilesize) - { - MNG_ALLOC (pData, ((mng_iccpp)pChunk)->pProfile, iProfilesize); - MNG_COPY (((mng_iccpp)pChunk)->pProfile, pProfile, iProfilesize); - } - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ICCP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_tEXt -mng_retcode MNG_DECL mng_putchunk_text (mng_handle hHandle, - mng_uint32 iKeywordsize, - mng_pchar zKeyword, - mng_uint32 iTextsize, - mng_pchar zText) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_tEXt, mng_init_general, mng_free_text, mng_read_text, mng_write_text, mng_assign_text, 0, 0, sizeof(mng_text)}; -#else - {MNG_UINT_tEXt, mng_init_text, mng_free_text, mng_read_text, mng_write_text, mng_assign_text, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TEXT, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_tEXt)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_text (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_tEXt, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_textp)pChunk)->iKeywordsize = iKeywordsize; - ((mng_textp)pChunk)->iTextsize = iTextsize; - - if (iKeywordsize) - { - MNG_ALLOC (pData, ((mng_textp)pChunk)->zKeyword, iKeywordsize + 1); - MNG_COPY (((mng_textp)pChunk)->zKeyword, zKeyword, iKeywordsize); - } - - if (iTextsize) - { - MNG_ALLOC (pData, ((mng_textp)pChunk)->zText, iTextsize + 1); - MNG_COPY (((mng_textp)pChunk)->zText, zText, iTextsize); - } - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TEXT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_zTXt -mng_retcode MNG_DECL mng_putchunk_ztxt (mng_handle hHandle, - mng_uint32 iKeywordsize, - mng_pchar zKeyword, - mng_uint8 iCompression, - mng_uint32 iTextsize, - mng_pchar zText) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_zTXt, mng_init_general, mng_free_ztxt, mng_read_ztxt, mng_write_ztxt, mng_assign_ztxt, 0, 0, sizeof(mng_ztxt)}; -#else - {MNG_UINT_zTXt, mng_init_ztxt, mng_free_ztxt, mng_read_ztxt, mng_write_ztxt, mng_assign_ztxt, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ZTXT, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_zTXt)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_ztxt (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_zTXt, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_ztxtp)pChunk)->iKeywordsize = iKeywordsize; - ((mng_ztxtp)pChunk)->iCompression = iCompression; - ((mng_ztxtp)pChunk)->iTextsize = iTextsize; - - if (iKeywordsize) - { - MNG_ALLOC (pData, ((mng_ztxtp)pChunk)->zKeyword, iKeywordsize + 1); - MNG_COPY (((mng_ztxtp)pChunk)->zKeyword, zKeyword, iKeywordsize); - } - - if (iTextsize) - { - MNG_ALLOC (pData, ((mng_ztxtp)pChunk)->zText, iTextsize + 1); - MNG_COPY (((mng_ztxtp)pChunk)->zText, zText, iTextsize); - } - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ZTXT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_iTXt -mng_retcode MNG_DECL mng_putchunk_itxt (mng_handle hHandle, - mng_uint32 iKeywordsize, - mng_pchar zKeyword, - mng_uint8 iCompressionflag, - mng_uint8 iCompressionmethod, - mng_uint32 iLanguagesize, - mng_pchar zLanguage, - mng_uint32 iTranslationsize, - mng_pchar zTranslation, - mng_uint32 iTextsize, - mng_pchar zText) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_iTXt, mng_init_general, mng_free_itxt, mng_read_itxt, mng_write_itxt, mng_assign_itxt, 0, 0, sizeof(mng_itxt)}; -#else - {MNG_UINT_iTXt, mng_init_itxt, mng_free_itxt, mng_read_itxt, mng_write_itxt, mng_assign_itxt, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ITXT, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_iTXt)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_itxt (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_iTXt, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_itxtp)pChunk)->iKeywordsize = iKeywordsize; - ((mng_itxtp)pChunk)->iCompressionflag = iCompressionflag; - ((mng_itxtp)pChunk)->iCompressionmethod = iCompressionmethod; - ((mng_itxtp)pChunk)->iLanguagesize = iLanguagesize; - ((mng_itxtp)pChunk)->iTranslationsize = iTranslationsize; - ((mng_itxtp)pChunk)->iTextsize = iTextsize; - - if (iKeywordsize) - { - MNG_ALLOC (pData, ((mng_itxtp)pChunk)->zKeyword, iKeywordsize + 1); - MNG_COPY (((mng_itxtp)pChunk)->zKeyword, zKeyword, iKeywordsize); - } - - if (iLanguagesize) - { - MNG_ALLOC (pData, ((mng_itxtp)pChunk)->zLanguage, iLanguagesize + 1); - MNG_COPY (((mng_itxtp)pChunk)->zLanguage, zLanguage, iLanguagesize); - } - - if (iTranslationsize) - { - MNG_ALLOC (pData, ((mng_itxtp)pChunk)->zTranslation, iTranslationsize + 1); - MNG_COPY (((mng_itxtp)pChunk)->zTranslation, zTranslation, iTranslationsize); - } - - if (iTextsize) - { - MNG_ALLOC (pData, ((mng_itxtp)pChunk)->zText, iTextsize + 1); - MNG_COPY (((mng_itxtp)pChunk)->zText, zText, iTextsize); - } - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ITXT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_bKGD -mng_retcode MNG_DECL mng_putchunk_bkgd (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iType, - mng_uint8 iIndex, - mng_uint16 iGray, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_bKGD, mng_init_general, mng_free_general, mng_read_bkgd, mng_write_bkgd, mng_assign_general, 0, 0, sizeof(mng_bkgd)}; -#else - {MNG_UINT_bKGD, mng_init_bkgd, mng_free_bkgd, mng_read_bkgd, mng_write_bkgd, mng_assign_bkgd, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_BKGD, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_bKGD)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_bkgd (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_bKGD, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_bkgdp)pChunk)->bEmpty = bEmpty; - ((mng_bkgdp)pChunk)->iType = iType; - ((mng_bkgdp)pChunk)->iIndex = iIndex; - ((mng_bkgdp)pChunk)->iGray = iGray; - ((mng_bkgdp)pChunk)->iRed = iRed; - ((mng_bkgdp)pChunk)->iGreen = iGreen; - ((mng_bkgdp)pChunk)->iBlue = iBlue; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_BKGD, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_pHYs -mng_retcode MNG_DECL mng_putchunk_phys (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iSizex, - mng_uint32 iSizey, - mng_uint8 iUnit) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_pHYs, mng_init_general, mng_free_general, mng_read_phys, mng_write_phys, mng_assign_general, 0, 0, sizeof(mng_phys)}; -#else - {MNG_UINT_pHYs, mng_init_phys, mng_free_phys, mng_read_phys, mng_write_phys, mng_assign_phys, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PHYS, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_pHYs)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_phys (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_pHYs, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_physp)pChunk)->bEmpty = bEmpty; - ((mng_physp)pChunk)->iSizex = iSizex; - ((mng_physp)pChunk)->iSizey = iSizey; - ((mng_physp)pChunk)->iUnit = iUnit; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PHYS, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_sBIT -mng_retcode MNG_DECL mng_putchunk_sbit (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iType, - mng_uint8arr4 aBits) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_sBIT, mng_init_general, mng_free_general, mng_read_sbit, mng_write_sbit, mng_assign_general, 0, 0, sizeof(mng_sbit)}; -#else - {MNG_UINT_sBIT, mng_init_sbit, mng_free_sbit, mng_read_sbit, mng_write_sbit, mng_assign_sbit, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SBIT, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_sBIT)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_sbit (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_sBIT, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_sbitp)pChunk)->bEmpty = bEmpty; - ((mng_sbitp)pChunk)->iType = iType; - ((mng_sbitp)pChunk)->aBits[0] = aBits[0]; - ((mng_sbitp)pChunk)->aBits[1] = aBits[1]; - ((mng_sbitp)pChunk)->aBits[2] = aBits[2]; - ((mng_sbitp)pChunk)->aBits[3] = aBits[3]; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SBIT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_sPLT -mng_retcode MNG_DECL mng_putchunk_splt (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iNamesize, - mng_pchar zName, - mng_uint8 iSampledepth, - mng_uint32 iEntrycount, - mng_ptr pEntries) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_sPLT, mng_init_general, mng_free_splt, mng_read_splt, mng_write_splt, mng_assign_splt, 0, 0, sizeof(mng_splt)}; -#else - {MNG_UINT_sPLT, mng_init_splt, mng_free_splt, mng_read_splt, mng_write_splt, mng_assign_splt, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SPLT, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_sPLT)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_splt (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_sPLT, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_spltp)pChunk)->bEmpty = bEmpty; - ((mng_spltp)pChunk)->iNamesize = iNamesize; - ((mng_spltp)pChunk)->iSampledepth = iSampledepth; - ((mng_spltp)pChunk)->iEntrycount = iEntrycount; - - if (iNamesize) - { - MNG_ALLOC (pData, ((mng_spltp)pChunk)->zName, iNamesize + 1); - MNG_COPY (((mng_spltp)pChunk)->zName, zName, iNamesize); - } - - if (iEntrycount) - { - mng_uint32 iSize = iEntrycount * ((iSampledepth >> 1) + 2); - - MNG_ALLOC (pData, ((mng_spltp)pChunk)->pEntries, iSize); - MNG_COPY (((mng_spltp)pChunk)->pEntries, pEntries, iSize); - } - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SPLT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_hIST -mng_retcode MNG_DECL mng_putchunk_hist (mng_handle hHandle, - mng_uint32 iEntrycount, - mng_uint16arr aEntries) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_hIST, mng_init_general, mng_free_general, mng_read_hist, mng_write_hist, mng_assign_general, 0, 0, sizeof(mng_hist)}; -#else - {MNG_UINT_hIST, mng_init_hist, mng_free_hist, mng_read_hist, mng_write_hist, mng_assign_hist, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_HIST, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_hIST)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_hist (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_hIST, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_histp)pChunk)->iEntrycount = iEntrycount; - - MNG_COPY (((mng_histp)pChunk)->aEntries, aEntries, sizeof (mng_uint16arr)); - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_HIST, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_tIME -mng_retcode MNG_DECL mng_putchunk_time (mng_handle hHandle, - mng_uint16 iYear, - mng_uint8 iMonth, - mng_uint8 iDay, - mng_uint8 iHour, - mng_uint8 iMinute, - mng_uint8 iSecond) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_tIME, mng_init_general, mng_free_general, mng_read_time, mng_write_time, mng_assign_general, 0, 0, sizeof(mng_time)}; -#else - {MNG_UINT_tIME, mng_init_time, mng_free_time, mng_read_time, mng_write_time, mng_assign_time, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TIME, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_tIME)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_time (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_tIME, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_timep)pChunk)->iYear = iYear; - ((mng_timep)pChunk)->iMonth = iMonth; - ((mng_timep)pChunk)->iDay = iDay; - ((mng_timep)pChunk)->iHour = iHour; - ((mng_timep)pChunk)->iMinute = iMinute; - ((mng_timep)pChunk)->iSecond = iSecond; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TIME, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_mhdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint32 iTicks, - mng_uint32 iLayercount, - mng_uint32 iFramecount, - mng_uint32 iPlaytime, - mng_uint32 iSimplicity) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_MHDR, mng_init_general, mng_free_general, mng_read_mhdr, mng_write_mhdr, mng_assign_general, 0, 0, sizeof(mng_mhdr)}; -#else - {MNG_UINT_MHDR, mng_init_mhdr, mng_free_mhdr, mng_read_mhdr, mng_write_mhdr, mng_assign_mhdr, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MHDR, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must be very first! */ - if (pData->iFirstchunkadded != 0) - MNG_ERROR (pData, MNG_SEQUENCEERROR) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_MHDR)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_mhdr (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_MHDR, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_mhdrp)pChunk)->iWidth = iWidth; - ((mng_mhdrp)pChunk)->iHeight = iHeight; - ((mng_mhdrp)pChunk)->iTicks = iTicks; - ((mng_mhdrp)pChunk)->iLayercount = iLayercount; - ((mng_mhdrp)pChunk)->iFramecount = iFramecount; - ((mng_mhdrp)pChunk)->iPlaytime = iPlaytime; - ((mng_mhdrp)pChunk)->iSimplicity = iSimplicity; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_mend (mng_handle hHandle) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_MEND, mng_init_general, mng_free_general, mng_read_mend, mng_write_mend, mng_assign_general, 0, 0, sizeof(mng_mend)}; -#else - {MNG_UINT_MEND, mng_init_mend, mng_free_mend, mng_read_mend, mng_write_mend, mng_assign_mend, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MEND, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_MEND)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_mend (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_MEND, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - - pData->bCreating = MNG_FALSE; /* should be last chunk !!! */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MEND, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_LOOP -mng_retcode MNG_DECL mng_putchunk_loop (mng_handle hHandle, - mng_uint8 iLevel, - mng_uint32 iRepeat, - mng_uint8 iTermination, - mng_uint32 iItermin, - mng_uint32 iItermax, - mng_uint32 iCount, - mng_uint32p pSignals) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_LOOP, mng_init_general, mng_free_loop, mng_read_loop, mng_write_loop, mng_assign_loop, 0, 0, sizeof(mng_loop)}; -#else - {MNG_UINT_LOOP, mng_init_loop, mng_free_loop, mng_read_loop, mng_write_loop, mng_assign_loop, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_LOOP, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_LOOP)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_loop (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_LOOP, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_loopp)pChunk)->iLevel = iLevel; - ((mng_loopp)pChunk)->iRepeat = iRepeat; - ((mng_loopp)pChunk)->iTermination = iTermination; - ((mng_loopp)pChunk)->iItermin = iItermin; - ((mng_loopp)pChunk)->iItermax = iItermax; - ((mng_loopp)pChunk)->iCount = iCount; - ((mng_loopp)pChunk)->pSignals = pSignals; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_LOOP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_endl (mng_handle hHandle, - mng_uint8 iLevel) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_ENDL, mng_init_general, mng_free_general, mng_read_endl, mng_write_endl, mng_assign_general, 0, 0, sizeof(mng_endl)}; -#else - {MNG_UINT_ENDL, mng_init_endl, mng_free_endl, mng_read_endl, mng_write_endl, mng_assign_endl, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ENDL, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_ENDL)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_endl (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_ENDL, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_endlp)pChunk)->iLevel = iLevel; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ENDL, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_DEFI -mng_retcode MNG_DECL mng_putchunk_defi (mng_handle hHandle, - mng_uint16 iObjectid, - mng_uint8 iDonotshow, - mng_uint8 iConcrete, - mng_bool bHasloca, - mng_int32 iXlocation, - mng_int32 iYlocation, - mng_bool bHasclip, - mng_int32 iLeftcb, - mng_int32 iRightcb, - mng_int32 iTopcb, - mng_int32 iBottomcb) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_DEFI, mng_init_general, mng_free_general, mng_read_defi, mng_write_defi, mng_assign_general, 0, 0, sizeof(mng_defi)}; -#else - {MNG_UINT_DEFI, mng_init_defi, mng_free_defi, mng_read_defi, mng_write_defi, mng_assign_defi, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DEFI, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_DEFI)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_defi (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_DEFI, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_defip)pChunk)->iObjectid = iObjectid; - ((mng_defip)pChunk)->iDonotshow = iDonotshow; - ((mng_defip)pChunk)->iConcrete = iConcrete; - ((mng_defip)pChunk)->bHasloca = bHasloca; - ((mng_defip)pChunk)->iXlocation = iXlocation; - ((mng_defip)pChunk)->iYlocation = iYlocation; - ((mng_defip)pChunk)->bHasclip = bHasclip; - ((mng_defip)pChunk)->iLeftcb = iLeftcb; - ((mng_defip)pChunk)->iRightcb = iRightcb; - ((mng_defip)pChunk)->iTopcb = iTopcb; - ((mng_defip)pChunk)->iBottomcb = iBottomcb; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DEFI, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_BASI -mng_retcode MNG_DECL mng_putchunk_basi (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint16 iAlpha, - mng_uint8 iViewable) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_BASI, mng_init_general, mng_free_general, mng_read_basi, mng_write_basi, mng_assign_general, 0, 0, sizeof(mng_basi)}; -#else - {MNG_UINT_BASI, mng_init_basi, mng_free_basi, mng_read_basi, mng_write_basi, mng_assign_basi, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_BASI, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_BASI)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_basi (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_BASI, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_basip)pChunk)->iWidth = iWidth; - ((mng_basip)pChunk)->iHeight = iHeight; - ((mng_basip)pChunk)->iBitdepth = iBitdepth; - ((mng_basip)pChunk)->iColortype = iColortype; - ((mng_basip)pChunk)->iCompression = iCompression; - ((mng_basip)pChunk)->iFilter = iFilter; - ((mng_basip)pChunk)->iInterlace = iInterlace; - ((mng_basip)pChunk)->iRed = iRed; - ((mng_basip)pChunk)->iGreen = iGreen; - ((mng_basip)pChunk)->iBlue = iBlue; - ((mng_basip)pChunk)->iAlpha = iAlpha; - ((mng_basip)pChunk)->iViewable = iViewable; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_BASI, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_CLON -mng_retcode MNG_DECL mng_putchunk_clon (mng_handle hHandle, - mng_uint16 iSourceid, - mng_uint16 iCloneid, - mng_uint8 iClonetype, - mng_uint8 iDonotshow, - mng_uint8 iConcrete, - mng_bool bHasloca, - mng_uint8 iLocationtype, - mng_int32 iLocationx, - mng_int32 iLocationy) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_CLON, mng_init_general, mng_free_general, mng_read_clon, mng_write_clon, mng_assign_general, 0, 0, sizeof(mng_clon)}; -#else - {MNG_UINT_CLON, mng_init_clon, mng_free_clon, mng_read_clon, mng_write_clon, mng_assign_clon, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_CLON, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_CLON)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_clon (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_CLON, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_clonp)pChunk)->iSourceid = iSourceid; - ((mng_clonp)pChunk)->iCloneid = iCloneid; - ((mng_clonp)pChunk)->iClonetype = iClonetype; - ((mng_clonp)pChunk)->iDonotshow = iDonotshow; - ((mng_clonp)pChunk)->iConcrete = iConcrete; - ((mng_clonp)pChunk)->bHasloca = bHasloca; - ((mng_clonp)pChunk)->iLocationtype = iLocationtype; - ((mng_clonp)pChunk)->iLocationx = iLocationx; - ((mng_clonp)pChunk)->iLocationy = iLocationy; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_CLON, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_PAST -mng_retcode MNG_DECL mng_putchunk_past (mng_handle hHandle, - mng_uint16 iDestid, - mng_uint8 iTargettype, - mng_int32 iTargetx, - mng_int32 iTargety, - mng_uint32 iCount) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_PAST, mng_init_general, mng_free_past, mng_read_past, mng_write_past, mng_assign_past, 0, 0, sizeof(mng_past)}; -#else - {MNG_UINT_PAST, mng_init_past, mng_free_past, mng_read_past, mng_write_past, mng_assign_past, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PAST, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_PAST)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_past (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_PAST, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_pastp)pChunk)->iDestid = iDestid; - ((mng_pastp)pChunk)->iTargettype = iTargettype; - ((mng_pastp)pChunk)->iTargetx = iTargetx; - ((mng_pastp)pChunk)->iTargety = iTargety; - ((mng_pastp)pChunk)->iCount = iCount; - - if (iCount) - MNG_ALLOC (pData, ((mng_pastp)pChunk)->pSources, iCount * sizeof (mng_past_source)); - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PAST, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_PAST -mng_retcode MNG_DECL mng_putchunk_past_src (mng_handle hHandle, - mng_uint32 iEntry, - mng_uint16 iSourceid, - mng_uint8 iComposition, - mng_uint8 iOrientation, - mng_uint8 iOffsettype, - mng_int32 iOffsetx, - mng_int32 iOffsety, - mng_uint8 iBoundarytype, - mng_int32 iBoundaryl, - mng_int32 iBoundaryr, - mng_int32 iBoundaryt, - mng_int32 iBoundaryb) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_past_sourcep pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PAST_SRC, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - - pChunk = pData->pLastchunk; /* last one must have been PAST ! */ - - if (((mng_chunk_headerp)pChunk)->iChunkname != MNG_UINT_PAST) - MNG_ERROR (pData, MNG_NOCORRCHUNK) - /* index out of bounds ? */ - if (iEntry >= ((mng_pastp)pChunk)->iCount) - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - /* address proper entry */ - pEntry = ((mng_pastp)pChunk)->pSources + iEntry; - - pEntry->iSourceid = iSourceid; /* fill entry */ - pEntry->iComposition = iComposition; - pEntry->iOrientation = iOrientation; - pEntry->iOffsettype = iOffsettype; - pEntry->iOffsetx = iOffsetx; - pEntry->iOffsety = iOffsety; - pEntry->iBoundarytype = iBoundarytype; - pEntry->iBoundaryl = iBoundaryl; - pEntry->iBoundaryr = iBoundaryr; - pEntry->iBoundaryt = iBoundaryt; - pEntry->iBoundaryb = iBoundaryb; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PAST_SRC, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_DISC -mng_retcode MNG_DECL mng_putchunk_disc (mng_handle hHandle, - mng_uint32 iCount, - mng_uint16p pObjectids) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_DISC, mng_init_general, mng_free_disc, mng_read_disc, mng_write_disc, mng_assign_disc, 0, 0, sizeof(mng_disc)}; -#else - {MNG_UINT_DISC, mng_init_disc, mng_free_disc, mng_read_disc, mng_write_disc, mng_assign_disc, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DISC, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_DISC)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_disc (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_DISC, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_discp)pChunk)->iCount = iCount; - - if (iCount) - { - mng_uint32 iSize = iCount * sizeof (mng_uint32); - - MNG_ALLOC (pData, ((mng_discp)pChunk)->pObjectids, iSize); - MNG_COPY (((mng_discp)pChunk)->pObjectids, pObjectids, iSize); - } - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DISC, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_BACK -mng_retcode MNG_DECL mng_putchunk_back (mng_handle hHandle, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint8 iMandatory, - mng_uint16 iImageid, - mng_uint8 iTile) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_BACK, mng_init_general, mng_free_general, mng_read_back, mng_write_back, mng_assign_general, 0, 0, sizeof(mng_back)}; -#else - {MNG_UINT_BACK, mng_init_back, mng_free_back, mng_read_back, mng_write_back, mng_assign_back, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_BACK, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_BACK)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_back (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_BACK, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_backp)pChunk)->iRed = iRed; - ((mng_backp)pChunk)->iGreen = iGreen; - ((mng_backp)pChunk)->iBlue = iBlue; - ((mng_backp)pChunk)->iMandatory = iMandatory; - ((mng_backp)pChunk)->iImageid = iImageid; - ((mng_backp)pChunk)->iTile = iTile; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_BACK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_FRAM -mng_retcode MNG_DECL mng_putchunk_fram (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iMode, - mng_uint32 iNamesize, - mng_pchar zName, - mng_uint8 iChangedelay, - mng_uint8 iChangetimeout, - mng_uint8 iChangeclipping, - mng_uint8 iChangesyncid, - mng_uint32 iDelay, - mng_uint32 iTimeout, - mng_uint8 iBoundarytype, - mng_int32 iBoundaryl, - mng_int32 iBoundaryr, - mng_int32 iBoundaryt, - mng_int32 iBoundaryb, - mng_uint32 iCount, - mng_uint32p pSyncids) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_FRAM, mng_init_general, mng_free_fram, mng_read_fram, mng_write_fram, mng_assign_fram, 0, 0, sizeof(mng_fram)}; -#else - {MNG_UINT_FRAM, mng_init_fram, mng_free_fram, mng_read_fram, mng_write_fram, mng_assign_fram, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_FRAM, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_FRAM)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_fram (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_FRAM, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_framp)pChunk)->bEmpty = bEmpty; - ((mng_framp)pChunk)->iMode = iMode; - ((mng_framp)pChunk)->iNamesize = iNamesize; - ((mng_framp)pChunk)->iChangedelay = iChangedelay; - ((mng_framp)pChunk)->iChangetimeout = iChangetimeout; - ((mng_framp)pChunk)->iChangeclipping = iChangeclipping; - ((mng_framp)pChunk)->iChangesyncid = iChangesyncid; - ((mng_framp)pChunk)->iDelay = iDelay; - ((mng_framp)pChunk)->iTimeout = iTimeout; - ((mng_framp)pChunk)->iBoundarytype = iBoundarytype; - ((mng_framp)pChunk)->iBoundaryl = iBoundaryl; - ((mng_framp)pChunk)->iBoundaryr = iBoundaryr; - ((mng_framp)pChunk)->iBoundaryt = iBoundaryt; - ((mng_framp)pChunk)->iBoundaryb = iBoundaryb; - ((mng_framp)pChunk)->iCount = iCount; - - if (iNamesize) - { - MNG_ALLOC (pData, ((mng_framp)pChunk)->zName, iNamesize + 1); - MNG_COPY (((mng_framp)pChunk)->zName, zName, iNamesize); - } - - if (iCount) - { - mng_uint32 iSize = iCount * sizeof (mng_uint32); - - MNG_ALLOC (pData, ((mng_framp)pChunk)->pSyncids, iSize); - MNG_COPY (((mng_framp)pChunk)->pSyncids, pSyncids, iSize); - } - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_FRAM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_MOVE -mng_retcode MNG_DECL mng_putchunk_move (mng_handle hHandle, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iMovetype, - mng_int32 iMovex, - mng_int32 iMovey) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_MOVE, mng_init_general, mng_free_general, mng_read_move, mng_write_move, mng_assign_general, 0, 0, sizeof(mng_move)}; -#else - {MNG_UINT_MOVE, mng_init_move, mng_free_move, mng_read_move, mng_write_move, mng_assign_move, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MOVE, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_MOVE)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_move (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_MOVE, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_movep)pChunk)->iFirstid = iFirstid; - ((mng_movep)pChunk)->iLastid = iLastid; - ((mng_movep)pChunk)->iMovetype = iMovetype; - ((mng_movep)pChunk)->iMovex = iMovex; - ((mng_movep)pChunk)->iMovey = iMovey; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MOVE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_CLIP -mng_retcode MNG_DECL mng_putchunk_clip (mng_handle hHandle, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iCliptype, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_CLIP, mng_init_general, mng_free_general, mng_read_clip, mng_write_clip, mng_assign_general, 0, 0, sizeof(mng_clip)}; -#else - {MNG_UINT_CLIP, mng_init_clip, mng_free_clip, mng_read_clip, mng_write_clip, mng_assign_clip, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_CLIP, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_CLIP)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_clip (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_CLIP, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_clipp)pChunk)->iFirstid = iFirstid; - ((mng_clipp)pChunk)->iLastid = iLastid; - ((mng_clipp)pChunk)->iCliptype = iCliptype; - ((mng_clipp)pChunk)->iClipl = iClipl; - ((mng_clipp)pChunk)->iClipr = iClipr; - ((mng_clipp)pChunk)->iClipt = iClipt; - ((mng_clipp)pChunk)->iClipb = iClipb; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_CLIP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SHOW -mng_retcode MNG_DECL mng_putchunk_show (mng_handle hHandle, - mng_bool bEmpty, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iMode) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_SHOW, mng_init_general, mng_free_general, mng_read_show, mng_write_show, mng_assign_general, 0, 0, sizeof(mng_show)}; -#else - {MNG_UINT_SHOW, mng_init_show, mng_free_show, mng_read_show, mng_write_show, mng_assign_show, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SHOW, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_SHOW)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_show (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_SHOW, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_showp)pChunk)->bEmpty = bEmpty; - ((mng_showp)pChunk)->iFirstid = iFirstid; - ((mng_showp)pChunk)->iLastid = iLastid; - ((mng_showp)pChunk)->iMode = iMode; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SHOW, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_TERM -mng_retcode MNG_DECL mng_putchunk_term (mng_handle hHandle, - mng_uint8 iTermaction, - mng_uint8 iIteraction, - mng_uint32 iDelay, - mng_uint32 iItermax) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_TERM, mng_init_general, mng_free_general, mng_read_term, mng_write_term, mng_assign_general, 0, 0, sizeof(mng_term)}; -#else - {MNG_UINT_TERM, mng_init_term, mng_free_term, mng_read_term, mng_write_term, mng_assign_term, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TERM, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_term (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_TERM, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_termp)pChunk)->iTermaction = iTermaction; - ((mng_termp)pChunk)->iIteraction = iIteraction; - ((mng_termp)pChunk)->iDelay = iDelay; - ((mng_termp)pChunk)->iItermax = iItermax; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TERM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SAVE -mng_retcode MNG_DECL mng_putchunk_save (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iOffsettype, - mng_uint32 iCount) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_SAVE, mng_init_general, mng_free_save, mng_read_save, mng_write_save, mng_assign_save, 0, 0, sizeof(mng_save)}; -#else - {MNG_UINT_SAVE, mng_init_save, mng_free_save, mng_read_save, mng_write_save, mng_assign_save, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SAVE, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_SAVE)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_save (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_SAVE, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_savep)pChunk)->bEmpty = bEmpty; - ((mng_savep)pChunk)->iOffsettype = iOffsettype; - ((mng_savep)pChunk)->iCount = iCount; - - if (iCount) - MNG_ALLOC (pData, ((mng_savep)pChunk)->pEntries, iCount * sizeof (mng_save_entry)); - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SAVE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_save_entry (mng_handle hHandle, - mng_uint32 iEntry, - mng_uint8 iEntrytype, - mng_uint32arr2 iOffset, - mng_uint32arr2 iStarttime, - mng_uint32 iLayernr, - mng_uint32 iFramenr, - mng_uint32 iNamesize, - mng_pchar zName) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_save_entryp pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SAVE_ENTRY, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - - pChunk = pData->pLastchunk; /* last one must have been SAVE ! */ - - if (((mng_chunk_headerp)pChunk)->iChunkname != MNG_UINT_SAVE) - MNG_ERROR (pData, MNG_NOCORRCHUNK) - /* index out of bounds ? */ - if (iEntry >= ((mng_savep)pChunk)->iCount) - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - /* address proper entry */ - pEntry = ((mng_savep)pChunk)->pEntries + iEntry; - - pEntry->iEntrytype = iEntrytype; /* fill entry */ - pEntry->iOffset[0] = iOffset[0]; - pEntry->iOffset[1] = iOffset[1]; - pEntry->iStarttime[0] = iStarttime[0]; - pEntry->iStarttime[1] = iStarttime[1]; - pEntry->iLayernr = iLayernr; - pEntry->iFramenr = iFramenr; - pEntry->iNamesize = iNamesize; - - if (iNamesize) - { - MNG_ALLOC (pData, pEntry->zName, iNamesize + 1); - MNG_COPY (pEntry->zName, zName, iNamesize); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SAVE_ENTRY, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SEEK -mng_retcode MNG_DECL mng_putchunk_seek (mng_handle hHandle, - mng_uint32 iNamesize, - mng_pchar zName) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_SEEK, mng_init_general, mng_free_seek, mng_read_seek, mng_write_seek, mng_assign_seek, 0, 0, sizeof(mng_seek)}; -#else - {MNG_UINT_SEEK, mng_init_seek, mng_free_seek, mng_read_seek, mng_write_seek, mng_assign_seek, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SEEK, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_SEEK)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_seek (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_SEEK, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_seekp)pChunk)->iNamesize = iNamesize; - - if (iNamesize) - { - MNG_ALLOC (pData, ((mng_seekp)pChunk)->zName, iNamesize + 1); - MNG_COPY (((mng_seekp)pChunk)->zName, zName, iNamesize); - } - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SEEK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_eXPI -mng_retcode MNG_DECL mng_putchunk_expi (mng_handle hHandle, - mng_uint16 iSnapshotid, - mng_uint32 iNamesize, - mng_pchar zName) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_eXPI, mng_init_general, mng_free_expi, mng_read_expi, mng_write_expi, mng_assign_general, 0, 0, sizeof(mng_expi)}; -#else - {MNG_UINT_eXPI, mng_init_expi, mng_free_expi, mng_read_expi, mng_write_expi, mng_assign_expi, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_EXPI, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_eXPI)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_expi (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_eXPI, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_expip)pChunk)->iSnapshotid = iSnapshotid; - ((mng_expip)pChunk)->iNamesize = iNamesize; - - if (iNamesize) - { - MNG_ALLOC (pData, ((mng_expip)pChunk)->zName, iNamesize + 1); - MNG_COPY (((mng_expip)pChunk)->zName, zName, iNamesize); - } - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_EXPI, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_fPRI -mng_retcode MNG_DECL mng_putchunk_fpri (mng_handle hHandle, - mng_uint8 iDeltatype, - mng_uint8 iPriority) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_fPRI, mng_init_general, mng_free_general, mng_read_fpri, mng_write_fpri, mng_assign_general, 0, 0, sizeof(mng_fpri)}; -#else - {MNG_UINT_fPRI, mng_init_fpri, mng_free_fpri, mng_read_fpri, mng_write_fpri, mng_assign_fpri, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_FPRI, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_fPRI)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_fpri (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_fPRI, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_fprip)pChunk)->iDeltatype = iDeltatype; - ((mng_fprip)pChunk)->iPriority = iPriority; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_FPRI, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_nEED -mng_retcode MNG_DECL mng_putchunk_need (mng_handle hHandle, - mng_uint32 iKeywordssize, - mng_pchar zKeywords) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_nEED, mng_init_general, mng_free_need, mng_read_need, mng_write_need, mng_assign_need, 0, 0, sizeof(mng_need)}; -#else - {MNG_UINT_nEED, mng_init_need, mng_free_need, mng_read_need, mng_write_need, mng_assign_need, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_NEED, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_nEED)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_need (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_nEED, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_needp)pChunk)->iKeywordssize = iKeywordssize; - - if (iKeywordssize) - { - MNG_ALLOC (pData, ((mng_needp)pChunk)->zKeywords, iKeywordssize + 1); - MNG_COPY (((mng_needp)pChunk)->zKeywords, zKeywords, iKeywordssize); - } - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_NEED, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_pHYg -mng_retcode MNG_DECL mng_putchunk_phyg (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iSizex, - mng_uint32 iSizey, - mng_uint8 iUnit) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_pHYg, mng_init_general, mng_free_general, mng_read_phyg, mng_write_phyg, mng_assign_general, 0, 0, sizeof(mng_phyg)}; -#else - {MNG_UINT_pHYg, mng_init_phyg, mng_free_phyg, mng_read_phyg, mng_write_phyg, mng_assign_phyg, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PHYG, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_pHYg)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_phyg (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_pHYg, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_phygp)pChunk)->bEmpty = bEmpty; - ((mng_phygp)pChunk)->iSizex = iSizex; - ((mng_phygp)pChunk)->iSizey = iSizey; - ((mng_phygp)pChunk)->iUnit = iUnit; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PHYG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG - -mng_retcode MNG_DECL mng_putchunk_jhdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iColortype, - mng_uint8 iImagesampledepth, - mng_uint8 iImagecompression, - mng_uint8 iImageinterlace, - mng_uint8 iAlphasampledepth, - mng_uint8 iAlphacompression, - mng_uint8 iAlphafilter, - mng_uint8 iAlphainterlace) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_JHDR, mng_init_general, mng_free_general, mng_read_jhdr, mng_write_jhdr, mng_assign_general, 0, 0, sizeof(mng_jhdr)}; -#else - {MNG_UINT_JHDR, mng_init_jhdr, mng_free_jhdr, mng_read_jhdr, mng_write_jhdr, mng_assign_jhdr, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JHDR, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_JHDR)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_jhdr (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_JHDR, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_jhdrp)pChunk)->iWidth = iWidth; - ((mng_jhdrp)pChunk)->iHeight = iHeight; - ((mng_jhdrp)pChunk)->iColortype = iColortype; - ((mng_jhdrp)pChunk)->iImagesampledepth = iImagesampledepth; - ((mng_jhdrp)pChunk)->iImagecompression = iImagecompression; - ((mng_jhdrp)pChunk)->iImageinterlace = iImageinterlace; - ((mng_jhdrp)pChunk)->iAlphasampledepth = iAlphasampledepth; - ((mng_jhdrp)pChunk)->iAlphacompression = iAlphacompression; - ((mng_jhdrp)pChunk)->iAlphafilter = iAlphafilter; - ((mng_jhdrp)pChunk)->iAlphainterlace = iAlphainterlace; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG - -mng_retcode MNG_DECL mng_putchunk_jdat (mng_handle hHandle, - mng_uint32 iRawlen, - mng_ptr pRawdata) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_JDAT, mng_init_general, mng_free_jdat, mng_read_jdat, mng_write_jdat, mng_assign_jdat, 0, 0, sizeof(mng_jdat)}; -#else - {MNG_UINT_JDAT, mng_init_jdat, mng_free_jdat, mng_read_jdat, mng_write_jdat, mng_assign_jdat, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JDAT, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR or JHDR first! */ - if ((pData->iFirstchunkadded != MNG_UINT_MHDR) && - (pData->iFirstchunkadded != MNG_UINT_JHDR) ) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_JDAT)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_jdat (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_JDAT, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_jdatp)pChunk)->iDatasize = iRawlen; - - if (iRawlen) - { - MNG_ALLOC (pData, ((mng_jdatp)pChunk)->pData, iRawlen); - MNG_COPY (((mng_jdatp)pChunk)->pData, pRawdata, iRawlen); - } - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JDAT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG - -mng_retcode MNG_DECL mng_putchunk_jdaa (mng_handle hHandle, - mng_uint32 iRawlen, - mng_ptr pRawdata) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_JDAA, mng_init_general, mng_free_jdaa, mng_read_jdaa, mng_write_jdaa, mng_assign_jdaa, 0, 0, sizeof(mng_jdaa)}; -#else - {MNG_UINT_JDAA, mng_init_jdaa, mng_free_jdaa, mng_read_jdaa, mng_write_jdaa, mng_assign_jdaa, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JDAA, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR or JHDR first! */ - if ((pData->iFirstchunkadded != MNG_UINT_MHDR) && - (pData->iFirstchunkadded != MNG_UINT_JHDR) ) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_JDAA)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_jdaa (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_JDAA, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_jdaap)pChunk)->iDatasize = iRawlen; - - if (iRawlen) - { - MNG_ALLOC (pData, ((mng_jdaap)pChunk)->pData, iRawlen); - MNG_COPY (((mng_jdaap)pChunk)->pData, pRawdata, iRawlen); - } - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JDAA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG - -mng_retcode MNG_DECL mng_putchunk_jsep (mng_handle hHandle) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_JSEP, mng_init_general, mng_free_general, mng_read_jsep, mng_write_jsep, mng_assign_general, 0, 0, sizeof(mng_jsep)}; -#else - {MNG_UINT_JSEP, mng_init_jsep, mng_free_jsep, mng_read_jsep, mng_write_jsep, mng_assign_jsep, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JSEP, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR or JHDR first! */ - if ((pData->iFirstchunkadded != MNG_UINT_MHDR) && - (pData->iFirstchunkadded != MNG_UINT_JHDR) ) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_JSEP)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_jsep (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_JSEP, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JSEP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -mng_retcode MNG_DECL mng_putchunk_dhdr (mng_handle hHandle, - mng_uint16 iObjectid, - mng_uint8 iImagetype, - mng_uint8 iDeltatype, - mng_uint32 iBlockwidth, - mng_uint32 iBlockheight, - mng_uint32 iBlockx, - mng_uint32 iBlocky) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_DHDR, mng_init_general, mng_free_general, mng_read_dhdr, mng_write_dhdr, mng_assign_general, 0, 0, sizeof(mng_dhdr)}; -#else - {MNG_UINT_DHDR, mng_init_dhdr, mng_free_dhdr, mng_read_dhdr, mng_write_dhdr, mng_assign_dhdr, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DHDR, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_DHDR)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_dhdr (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_DHDR, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_dhdrp)pChunk)->iObjectid = iObjectid; - ((mng_dhdrp)pChunk)->iImagetype = iImagetype; - ((mng_dhdrp)pChunk)->iDeltatype = iDeltatype; - ((mng_dhdrp)pChunk)->iBlockwidth = iBlockwidth; - ((mng_dhdrp)pChunk)->iBlockheight = iBlockheight; - ((mng_dhdrp)pChunk)->iBlockx = iBlockx; - ((mng_dhdrp)pChunk)->iBlocky = iBlocky; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -mng_retcode MNG_DECL mng_putchunk_prom (mng_handle hHandle, - mng_uint8 iColortype, - mng_uint8 iSampledepth, - mng_uint8 iFilltype) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_PROM, mng_init_general, mng_free_general, mng_read_prom, mng_write_prom, mng_assign_general, 0, 0, sizeof(mng_prom)}; -#else - {MNG_UINT_PROM, mng_init_prom, mng_free_prom, mng_read_prom, mng_write_prom, mng_assign_prom, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PROM, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_PROM)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_prom (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_PROM, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_promp)pChunk)->iColortype = iColortype; - ((mng_promp)pChunk)->iSampledepth = iSampledepth; - ((mng_promp)pChunk)->iFilltype = iFilltype; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PROM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -mng_retcode MNG_DECL mng_putchunk_ipng (mng_handle hHandle) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_IPNG, mng_init_general, mng_free_general, mng_read_ipng, mng_write_ipng, mng_assign_general, 0, 0, sizeof(mng_ipng)}; -#else - {MNG_UINT_IPNG, mng_init_ipng, mng_free_ipng, mng_read_ipng, mng_write_ipng, mng_assign_ipng, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IPNG, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_IPNG)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_ipng (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_IPNG, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IPNG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -mng_retcode MNG_DECL mng_putchunk_pplt (mng_handle hHandle, - mng_uint8 iDeltatype, - mng_uint32 iCount) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_PPLT, mng_init_general, mng_free_general, mng_read_pplt, mng_write_pplt, mng_assign_general, 0, 0, sizeof(mng_pplt)}; -#else - {MNG_UINT_PPLT, mng_init_pplt, mng_free_pplt, mng_read_pplt, mng_write_pplt, mng_assign_pplt, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PPLT, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_PPLT)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_pplt (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_PPLT, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_ppltp)pChunk)->iDeltatype = iDeltatype; - ((mng_ppltp)pChunk)->iCount = iCount; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PPLT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -mng_retcode MNG_DECL mng_putchunk_pplt_entry (mng_handle hHandle, - mng_uint32 iEntry, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint16 iAlpha) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_pplt_entryp pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PPLT_ENTRY, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - - pChunk = pData->pLastchunk; /* last one must have been PPLT ! */ - - if (((mng_chunk_headerp)pChunk)->iChunkname != MNG_UINT_PPLT) - MNG_ERROR (pData, MNG_NOCORRCHUNK) - - /* index out of bounds ? */ - if (iEntry >= ((mng_ppltp)pChunk)->iCount) - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - /* address proper entry */ - pEntry = (mng_pplt_entryp)(((mng_ppltp)pChunk)->aEntries) + iEntry; - - pEntry->iRed = (mng_uint8)iRed; /* fill the entry */ - pEntry->iGreen = (mng_uint8)iGreen; - pEntry->iBlue = (mng_uint8)iBlue; - pEntry->iAlpha = (mng_uint8)iAlpha; - pEntry->bUsed = MNG_TRUE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PPLT_ENTRY, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifdef MNG_INCLUDE_JNG -mng_retcode MNG_DECL mng_putchunk_ijng (mng_handle hHandle) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_IJNG, mng_init_general, mng_free_general, mng_read_ijng, mng_write_ijng, mng_assign_general, 0, 0, sizeof(mng_ijng)}; -#else - {MNG_UINT_IJNG, mng_init_ijng, mng_free_ijng, mng_read_ijng, mng_write_ijng, mng_assign_ijng, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IJNG, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_IJNG)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_ijng (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_IJNG, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IJNG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -mng_retcode MNG_DECL mng_putchunk_drop (mng_handle hHandle, - mng_uint32 iCount, - mng_chunkidp pChunknames) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_DROP, mng_init_general, mng_free_drop, mng_read_drop, mng_write_drop, mng_assign_drop, 0, 0, sizeof(mng_drop)}; -#else - {MNG_UINT_DROP, mng_init_drop, mng_free_drop, mng_read_drop, mng_write_drop, mng_assign_drop, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DROP, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_DROP)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_drop (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_DROP, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_dropp)pChunk)->iCount = iCount; - - if (iCount) - { - mng_uint32 iSize = iCount * sizeof (mng_chunkid); - - MNG_ALLOC (pData, ((mng_dropp)pChunk)->pChunknames, iSize); - MNG_COPY (((mng_dropp)pChunk)->pChunknames, pChunknames, iSize); - } - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DROP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_DBYK -mng_retcode MNG_DECL mng_putchunk_dbyk (mng_handle hHandle, - mng_chunkid iChunkname, - mng_uint8 iPolarity, - mng_uint32 iKeywordssize, - mng_pchar zKeywords) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_DBYK, mng_init_general, mng_free_dbyk, mng_read_dbyk, mng_write_dbyk, mng_assign_dbyk, 0, 0, sizeof(mng_dbyk)}; -#else - {MNG_UINT_DBYK, mng_init_dbyk, mng_free_dbyk, mng_read_dbyk, mng_write_dbyk, mng_assign_dbyk, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DBYK, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_DBYK)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_dbyk (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_DBYK, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_dbykp)pChunk)->iChunkname = iChunkname; - ((mng_dbykp)pChunk)->iPolarity = iPolarity; - ((mng_dbykp)pChunk)->iKeywordssize = iKeywordssize; - - if (iKeywordssize) - { - MNG_ALLOC (pData, ((mng_dbykp)pChunk)->zKeywords, iKeywordssize + 1); - MNG_COPY (((mng_dbykp)pChunk)->zKeywords, zKeywords, iKeywordssize); - } - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DBYK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_ORDR -mng_retcode MNG_DECL mng_putchunk_ordr (mng_handle hHandle, - mng_uint32 iCount) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_ORDR, mng_init_general, mng_free_ordr, mng_read_ordr, mng_write_ordr, mng_assign_ordr, 0, 0, sizeof(mng_ordr)}; -#else - {MNG_UINT_ORDR, mng_init_ordr, mng_free_ordr, mng_read_ordr, mng_write_ordr, mng_assign_ordr, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ORDR, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_ORDR)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_ordr (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_ORDR, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_ordrp)pChunk)->iCount = iCount; - - if (iCount) - MNG_ALLOC (pData, ((mng_ordrp)pChunk)->pEntries, iCount * sizeof (mng_ordr_entry)); - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ORDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_ORDR -mng_retcode MNG_DECL mng_putchunk_ordr_entry (mng_handle hHandle, - mng_uint32 iEntry, - mng_chunkid iChunkname, - mng_uint8 iOrdertype) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_ordr_entryp pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ORDR_ENTRY, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - - pChunk = pData->pLastchunk; /* last one must have been ORDR ! */ - - if (((mng_chunk_headerp)pChunk)->iChunkname != MNG_UINT_ORDR) - MNG_ERROR (pData, MNG_NOCORRCHUNK) - /* index out of bounds ? */ - if (iEntry >= ((mng_ordrp)pChunk)->iCount) - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - /* address proper entry */ - pEntry = ((mng_ordrp)pChunk)->pEntries + iEntry; - - pEntry->iChunkname = iChunkname; /* fill the entry */ - pEntry->iOrdertype = iOrdertype; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ORDR_ENTRY, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_MAGN -mng_retcode MNG_DECL mng_putchunk_magn (mng_handle hHandle, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint16 iMethodX, - mng_uint16 iMX, - mng_uint16 iMY, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint16 iMT, - mng_uint16 iMB, - mng_uint16 iMethodY) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_MAGN, mng_init_general, mng_free_general, mng_read_magn, mng_write_magn, mng_assign_general, 0, 0, sizeof(mng_magn)}; -#else - {MNG_UINT_MAGN, mng_init_magn, mng_free_magn, mng_read_magn, mng_write_magn, mng_assign_magn, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MAGN, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_MAGN)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_magn (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_MAGN, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_magnp)pChunk)->iFirstid = iFirstid; - ((mng_magnp)pChunk)->iLastid = iLastid; - ((mng_magnp)pChunk)->iMethodX = (mng_uint8)iMethodX; - ((mng_magnp)pChunk)->iMX = iMX; - ((mng_magnp)pChunk)->iMY = iMY; - ((mng_magnp)pChunk)->iML = iML; - ((mng_magnp)pChunk)->iMR = iMR; - ((mng_magnp)pChunk)->iMT = iMT; - ((mng_magnp)pChunk)->iMB = iMB; - ((mng_magnp)pChunk)->iMethodY = (mng_uint8)iMethodY; - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MAGN, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_MPNG_PROPOSAL -MNG_EXT mng_retcode MNG_DECL mng_putchunk_mpng (mng_handle hHandle, - mng_uint32 iFramewidth, - mng_uint32 iFrameheight, - mng_uint16 iNumplays, - mng_uint16 iTickspersec, - mng_uint8 iCompressionmethod, - mng_uint32 iCount) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_mpNG, mng_init_general, mng_free_mpng, mng_read_mpng, mng_write_mpng, mng_assign_mpng, 0, 0, sizeof(mng_mpng)}; -#else - {MNG_UINT_mpNG, mng_init_mpng, mng_free_mpng, mng_read_mpng, mng_write_mpng, mng_assign_mpng, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MPNG, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a IHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_IHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_mpng (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_mpNG, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_mpngp)pChunk)->iFramewidth = iFramewidth; - ((mng_mpngp)pChunk)->iFrameheight = iFrameheight; - ((mng_mpngp)pChunk)->iNumplays = iNumplays; - ((mng_mpngp)pChunk)->iTickspersec = iTickspersec; - ((mng_mpngp)pChunk)->iCompressionmethod = iCompressionmethod; - ((mng_mpngp)pChunk)->iFramessize = iCount * sizeof (mng_mpng_frame); - - if (iCount) - MNG_ALLOC (pData, ((mng_mpngp)pChunk)->pFrames, ((mng_mpngp)pChunk)->iFramessize); - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MPNG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_MPNG_PROPOSAL -MNG_EXT mng_retcode MNG_DECL mng_putchunk_mpng_frame (mng_handle hHandle, - mng_uint32 iEntry, - mng_uint32 iX, - mng_uint32 iY, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_int32 iXoffset, - mng_int32 iYoffset, - mng_uint16 iTicks) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_mpng_framep pFrame; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MPNG_FRAME, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a IHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_IHDR) - MNG_ERROR (pData, MNG_NOHEADER) - - pChunk = pData->pLastchunk; /* last one must have been mpNG ! */ - - if (((mng_chunk_headerp)pChunk)->iChunkname != MNG_UINT_mpNG) - MNG_ERROR (pData, MNG_NOCORRCHUNK) - /* index out of bounds ? */ - if (iEntry >= (((mng_mpngp)pChunk)->iFramessize / sizeof (mng_mpng_frame))) - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - /* address proper entry */ - pFrame = ((mng_mpngp)pChunk)->pFrames + iEntry; - /* fill entry */ - pFrame->iX = iX; - pFrame->iY = iY; - pFrame->iWidth = iWidth; - pFrame->iHeight = iHeight; - pFrame->iXoffset = iXoffset; - pFrame->iYoffset = iYoffset; - pFrame->iTicks = iTicks; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MPNG_FRAME, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_evNT -mng_retcode MNG_DECL mng_putchunk_evnt (mng_handle hHandle, - mng_uint32 iCount) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_evNT, mng_init_general, mng_free_evnt, mng_read_evnt, mng_write_evnt, mng_assign_evnt, 0, 0, sizeof(mng_evnt)}; -#else - {MNG_UINT_evNT, mng_init_evnt, mng_free_evnt, mng_read_evnt, mng_write_evnt, mng_assign_evnt, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_EVNT, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, MNG_UINT_evNT)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_evnt (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_evNT, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_evntp)pChunk)->iCount = iCount; - - if (iCount) - MNG_ALLOC (pData, ((mng_evntp)pChunk)->pEntries, iCount * sizeof (mng_evnt_entry)); - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_EVNT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_evnt_entry (mng_handle hHandle, - mng_uint32 iEntry, - mng_uint8 iEventtype, - mng_uint8 iMasktype, - mng_int32 iLeft, - mng_int32 iRight, - mng_int32 iTop, - mng_int32 iBottom, - mng_uint16 iObjectid, - mng_uint8 iIndex, - mng_uint32 iSegmentnamesize, - mng_pchar zSegmentname) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_evnt_entryp pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_EVNT_ENTRY, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - - pChunk = pData->pLastchunk; /* last one must have been evNT ! */ - - if (((mng_chunk_headerp)pChunk)->iChunkname != MNG_UINT_evNT) - MNG_ERROR (pData, MNG_NOCORRCHUNK) - /* index out of bounds ? */ - if (iEntry >= ((mng_evntp)pChunk)->iCount) - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - /* address proper entry */ - pEntry = ((mng_evntp)pChunk)->pEntries + iEntry; - /* fill entry */ - pEntry->iEventtype = iEventtype; - pEntry->iMasktype = iMasktype; - pEntry->iLeft = iLeft; - pEntry->iRight = iRight; - pEntry->iTop = iTop; - pEntry->iBottom = iBottom; - pEntry->iObjectid = iObjectid; - pEntry->iIndex = iIndex; - pEntry->iSegmentnamesize = iSegmentnamesize; - - if (iSegmentnamesize) - { - MNG_ALLOC (pData, pEntry->zSegmentname, iSegmentnamesize + 1); - MNG_COPY (pEntry->zSegmentname, zSegmentname, iSegmentnamesize); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_EVNT_ENTRY, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_unknown (mng_handle hHandle, - mng_chunkid iChunkname, - mng_uint32 iRawlen, - mng_ptr pRawdata) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; -#ifndef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_header sChunkheader = -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - {MNG_UINT_HUH, mng_init_general, mng_free_unknown, mng_read_unknown, mng_write_unknown, mng_assign_unknown, 0, 0, sizeof(mng_unknown_chunk)}; -#else - {MNG_UINT_HUH, mng_init_unknown, mng_free_unknown, mng_read_unknown, mng_write_unknown, mng_assign_unknown, 0, 0}; -#endif -#else - mng_chunk_header sChunkheader; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_UNKNOWN, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* prevent misplaced TERM ! */ - if (!check_term (pData, iChunkname)) - MNG_ERROR (pData, MNG_TERMSEQERROR) - /* create the chunk */ -#ifndef MNG_OPTIMIZE_CHUNKREADER -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#else - iRetcode = mng_init_unknown (pData, &sChunkheader, &pChunk); -#endif -#else - mng_get_chunkheader(MNG_UINT_HUH, &sChunkheader); - iRetcode = mng_init_general (pData, &sChunkheader, &pChunk); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_unknown_chunkp)pChunk)->sHeader.iChunkname = iChunkname; - ((mng_unknown_chunkp)pChunk)->iDatasize = iRawlen; - - if (iRawlen) - { - MNG_ALLOC (pData, ((mng_unknown_chunkp)pChunk)->pData, iRawlen); - MNG_COPY (((mng_unknown_chunkp)pChunk)->pData, pRawdata, iRawlen); - } - - mng_add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_UNKNOWN, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_WRITE_PROCS */ - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getimgdata_seq (mng_handle hHandle, - mng_uint32 iSeqnr, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETIMGDATA_SEQ, MNG_LC_START); -#endif - - - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETIMGDATA_SEQ, MNG_LC_END); -#endif - - return MNG_FNNOTIMPLEMENTED; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getimgdata_chunkseq (mng_handle hHandle, - mng_uint32 iSeqnr, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETIMGDATA_CHUNKSEQ, MNG_LC_START); -#endif - - - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETIMGDATA_CHUNKSEQ, MNG_LC_END); -#endif - - return MNG_FNNOTIMPLEMENTED; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getimgdata_chunk (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETIMGDATA_CHUNK, MNG_LC_START); -#endif - - - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETIMGDATA_CHUNK, MNG_LC_END); -#endif - - return MNG_FNNOTIMPLEMENTED; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_WRITE_PROCS - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putimgdata_ihdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iColortype, - mng_uint8 iBitdepth, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTIMGDATA_IHDR, MNG_LC_START); -#endif - - - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTIMGDATA_IHDR, MNG_LC_END); -#endif - - return MNG_FNNOTIMPLEMENTED; -} - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_retcode MNG_DECL mng_putimgdata_jhdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iColortype, - mng_uint8 iBitdepth, - mng_uint8 iCompression, - mng_uint8 iInterlace, - mng_uint8 iAlphaBitdepth, - mng_uint8 iAlphaCompression, - mng_uint8 iAlphaFilter, - mng_uint8 iAlphaInterlace, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTIMGDATA_JHDR, MNG_LC_START); -#endif - - - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTIMGDATA_JHDR, MNG_LC_END); -#endif - - return MNG_FNNOTIMPLEMENTED; -} -#endif - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_updatemngheader (mng_handle hHandle, - mng_uint32 iFramecount, - mng_uint32 iLayercount, - mng_uint32 iPlaytime) -{ - mng_datap pData; - mng_chunkp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_UPDATEMNGHEADER, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must be a MNG animation! */ - if ((pData->eImagetype != mng_it_mng) || (pData->iFirstchunkadded != MNG_UINT_MHDR)) - MNG_ERROR (pData, MNG_NOMHDR) - - pChunk = pData->pFirstchunk; /* get the first chunk */ - /* and update the variables */ - ((mng_mhdrp)pChunk)->iFramecount = iFramecount; - ((mng_mhdrp)pChunk)->iLayercount = iLayercount; - ((mng_mhdrp)pChunk)->iPlaytime = iPlaytime; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_UPDATEMNGHEADER, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_updatemngsimplicity (mng_handle hHandle, - mng_uint32 iSimplicity) -{ - mng_datap pData; - mng_chunkp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_UPDATEMNGSIMPLICITY, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must be a MNG animation! */ - if ((pData->eImagetype != mng_it_mng) || (pData->iFirstchunkadded != MNG_UINT_MHDR)) - MNG_ERROR (pData, MNG_NOMHDR) - - pChunk = pData->pFirstchunk; /* get the first chunk */ - /* and update the variable */ - ((mng_mhdrp)pChunk)->iSimplicity = iSimplicity; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_UPDATEMNGSIMPLICITY, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_WRITE_PROCS */ - -/* ************************************************************************** */ - -#endif /* MNG_ACCESS_CHUNKS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - - - diff --git a/plugins/AdvaImg/src/LibMNG/libmng_chunks.h b/plugins/AdvaImg/src/LibMNG/libmng_chunks.h deleted file mode 100644 index 6c50d8b867..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_chunks.h +++ /dev/null @@ -1,1026 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_chunks.h copyright (c) 2000-2007 G.Juyn * */ -/* * version : 1.0.10 * */ -/* * * */ -/* * purpose : Chunk structures (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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 * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/10/2000 - G.Juyn * */ -/* * - fixed DEFI behavior * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added JDAA chunk * */ -/* * * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - added HLAPI function to copy chunks * */ -/* * 1.0.5 - 09/14/2002 - G.Juyn * */ -/* * - added event handling for dynamic MNG * */ -/* * 1.0.5 - 11/28/2002 - G.Juyn * */ -/* * - fixed definition of iMethodX/Y for MAGN chunk * */ -/* * * */ -/* * 1.0.6 - 05/25/2003 - G.R-P * */ -/* * added MNG_SKIPCHUNK_cHNK footprint optimizations * */ -/* * 1.0.6 - 07/29/2003 - G.R-P * */ -/* * - added conditionals around PAST chunk support * */ -/* * * */ -/* * 1.0.7 - 03/24/2004 - G.R-P * */ -/* * - added conditional around MNG_NO_DELTA_PNG support * */ -/* * * */ -/* * 1.0.9 - 12/05/2004 - G.Juyn * */ -/* * - added conditional MNG_OPTIMIZE_CHUNKINITFREE * */ -/* * 1.0.9 - 12/06/2004 - G.Juyn * */ -/* * - added conditional MNG_OPTIMIZE_CHUNKREADER * */ -/* * * */ -/* * 1.0.10 - 04/08/2007 - G.Juyn * */ -/* * - added support for mPNG proposal * */ -/* * 1.0.10 - 04/12/2007 - G.Juyn * */ -/* * - added support for ANG proposal * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_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 - -/* ************************************************************************** */ - -#ifdef MNG_OPTIMIZE_CHUNKREADER - -typedef mng_retcode (*mng_f_specialfunc) (mng_datap pData, - mng_chunkp pChunk, - mng_uint32* piRawlen, - mng_uint8p* ppRawdata); - -typedef mng_retcode (*mng_c_specialfunc) (mng_datap pData, - mng_chunkp pChunk); - -#define MNG_FIELD_OPTIONAL 0x0001 -#define MNG_FIELD_TERMINATOR 0x0002 -#define MNG_FIELD_REPETITIVE 0x0004 -#define MNG_FIELD_DEFLATED 0x0008 -#define MNG_FIELD_IFIMGTYPES 0x01F0 /* image-type mask */ -#define MNG_FIELD_IFIMGTYPE0 0x0010 -#define MNG_FIELD_IFIMGTYPE2 0x0020 -#define MNG_FIELD_IFIMGTYPE3 0x0040 -#define MNG_FIELD_IFIMGTYPE4 0x0080 -#define MNG_FIELD_IFIMGTYPE6 0x0100 -#define MNG_FIELD_PUTIMGTYPE 0x0200 -#define MNG_FIELD_NOHIGHBIT 0x0400 -#define MNG_FIELD_GROUPMASK 0x7000 -#define MNG_FIELD_GROUP1 0x1000 -#define MNG_FIELD_GROUP2 0x2000 -#define MNG_FIELD_GROUP3 0x3000 -#define MNG_FIELD_GROUP4 0x4000 -#define MNG_FIELD_GROUP5 0x5000 -#define MNG_FIELD_GROUP6 0x6000 -#define MNG_FIELD_GROUP7 0x7000 -#define MNG_FIELD_INT 0x8000 - -typedef struct { /* chunk-field descriptor */ - mng_f_specialfunc pSpecialfunc; - mng_uint16 iFlags; - mng_uint16 iMinvalue; - mng_uint16 iMaxvalue; - mng_uint16 iLengthmin; - mng_uint16 iLengthmax; - mng_uint16 iOffsetchunk; - mng_uint16 iOffsetchunkind; - mng_uint16 iOffsetchunklen; - } mng_field_descriptor; -typedef mng_field_descriptor * mng_field_descp; - -#define MNG_DESCR_GLOBAL 0x0001 -#define MNG_DESCR_EMPTY 0x0002 -#define MNG_DESCR_EMPTYEMBED 0x0006 -#define MNG_DESCR_EMPTYGLOBAL 0x000A - -#define MNG_DESCR_GenHDR 0x0001 /* IHDR/JHDR/BASI/DHDR */ -#define MNG_DESCR_JngHDR 0x0002 /* JHDR/DHDR */ -#define MNG_DESCR_MHDR 0x0004 -#define MNG_DESCR_IHDR 0x0008 -#define MNG_DESCR_JHDR 0x0010 -#define MNG_DESCR_DHDR 0x0020 -#define MNG_DESCR_LOOP 0x0040 -#define MNG_DESCR_PLTE 0x0080 -#define MNG_DESCR_SAVE 0x0100 - -#define MNG_DESCR_NOIHDR 0x0001 -#define MNG_DESCR_NOJHDR 0x0002 -#define MNG_DESCR_NOBASI 0x0004 -#define MNG_DESCR_NODHDR 0x0008 -#define MNG_DESCR_NOIDAT 0x0010 -#define MNG_DESCR_NOJDAT 0x0020 -#define MNG_DESCR_NOJDAA 0x0040 -#define MNG_DESCR_NOPLTE 0x0080 -#define MNG_DESCR_NOJSEP 0x0100 -#define MNG_DESCR_NOMHDR 0x0200 -#define MNG_DESCR_NOTERM 0x0400 -#define MNG_DESCR_NOLOOP 0x0800 -#define MNG_DESCR_NOSAVE 0x1000 - -typedef struct { /* chunk descriptor */ - mng_imgtype eImgtype; - mng_createobjtype eCreateobject; - mng_uint16 iObjsize; - mng_uint16 iOffsetempty; - mng_ptr pObjcleanup; - mng_ptr pObjprocess; - mng_c_specialfunc pSpecialfunc; - mng_field_descp pFielddesc; - mng_uint16 iFielddesc; - mng_uint16 iAllowed; - mng_uint16 iMusthaves; - mng_uint16 iMustNOThaves; - } mng_chunk_descriptor; -typedef mng_chunk_descriptor * mng_chunk_descp; - -#endif /* MNG_OPTIMIZE_CHUNKREADER */ - -/* ************************************************************************** */ - -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 mng_retcode (*mng_assignchunk) (mng_datap pData, - mng_chunkp pChunkto, - mng_chunkp pChunkfrom); - -/* ************************************************************************** */ - -typedef struct { /* generic header */ - mng_chunkid iChunkname; - mng_createchunk fCreate; - mng_cleanupchunk fCleanup; - mng_readchunk fRead; - mng_writechunk fWrite; - mng_assignchunk fAssign; - mng_chunkp pNext; /* for double-linked list */ - mng_chunkp pPrev; -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - mng_size_t iChunksize; -#endif -#ifdef MNG_OPTIMIZE_CHUNKREADER - mng_chunk_descp pChunkdescr; -#endif - } 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; - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_cHRM -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; -#endif - -/* ************************************************************************** */ - -typedef struct { /* sRGB */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint8 iRenderingintent; - } mng_srgb; -typedef mng_srgb * mng_srgbp; - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_iCCP -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; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_tEXt -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; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_zTXt -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; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_iTXt -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; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_bKGD -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; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_pHYs -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; -#endif - -/* ************************************************************************** */ -#ifndef MNG_SKIPCHUNK_sBIT - -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; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_sPLT -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; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_hIST -typedef struct { /* hIST */ - mng_chunk_header sHeader; - mng_uint32 iEntrycount; - mng_uint16arr aEntries; - } mng_hist; -typedef mng_hist * mng_histp; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_tIME -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; -#endif - -/* ************************************************************************** */ - -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_bool bHasdonotshow; - mng_uint8 iDonotshow; - mng_bool bHasconcrete; - 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; -#ifdef MNG_OPTIMIZE_CHUNKREADER - mng_bool bHasalpha; -#endif - 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; -#ifdef MNG_OPTIMIZE_CHUNKREADER - mng_bool bHasdonotshow; -#endif - 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; - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_PAST -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; -#endif - -/* ************************************************************************** */ - -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; -#ifdef MNG_OPTIMIZE_CHUNKREADER - mng_bool bHaslastid; -#endif - 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; - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SAVE -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; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SEEK -typedef struct { /* SEEK */ - mng_chunk_header sHeader; - mng_uint32 iNamesize; - mng_pchar zName; - } mng_seek; -typedef mng_seek * mng_seekp; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_eXPI -typedef struct { /* eXPI */ - mng_chunk_header sHeader; - mng_uint16 iSnapshotid; - mng_uint32 iNamesize; - mng_pchar zName; - } mng_expi; -typedef mng_expi * mng_expip; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_fPRI -typedef struct { /* fPRI */ - mng_chunk_header sHeader; - mng_uint8 iDeltatype; - mng_uint8 iPriority; - } mng_fpri; -typedef mng_fpri * mng_fprip; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_nEED -typedef struct { /* nEED */ - mng_chunk_header sHeader; - mng_uint32 iKeywordssize; - mng_pchar zKeywords; - } mng_need; -typedef mng_need * mng_needp; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_pHYg -typedef mng_phys mng_phyg; /* pHYg */ -typedef mng_phyg * mng_phygp; -#endif - -/* ************************************************************************** */ - -#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_jdaa; /* JDAA */ -typedef mng_jdaa * mng_jdaap; - -/* ************************************************************************** */ - -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 */ - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG - -typedef struct { /* DHDR */ - mng_chunk_header sHeader; - mng_uint16 iObjectid; - mng_uint8 iImagetype; - mng_uint8 iDeltatype; -#ifdef MNG_OPTIMIZE_CHUNKREADER - mng_bool bHasblocksize; -#endif - mng_uint32 iBlockwidth; - mng_uint32 iBlockheight; -#ifdef MNG_OPTIMIZE_CHUNKREADER - mng_bool bHasblockloc; -#endif - 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; - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_DBYK -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; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_ORDR -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; -#endif -#endif /* MNG_NO_DELTA_PNG */ - -/* ************************************************************************** */ - -typedef struct { /* MAGN */ - mng_chunk_header sHeader; - mng_uint16 iFirstid; - mng_uint16 iLastid; - mng_uint8 iMethodX; - mng_uint16 iMX; - mng_uint16 iMY; - mng_uint16 iML; - mng_uint16 iMR; - mng_uint16 iMT; - mng_uint16 iMB; - mng_uint8 iMethodY; - } mng_magn; -typedef mng_magn * mng_magnp; - -/* ************************************************************************** */ - -typedef struct { /* evNT entry */ - mng_uint8 iEventtype; - mng_uint8 iMasktype; - mng_int32 iLeft; - mng_int32 iRight; - mng_int32 iTop; - mng_int32 iBottom; - mng_uint16 iObjectid; - mng_uint8 iIndex; - mng_uint32 iSegmentnamesize; - mng_pchar zSegmentname; - } mng_evnt_entry; -typedef mng_evnt_entry * mng_evnt_entryp; - -typedef struct { /* evNT */ - mng_chunk_header sHeader; - mng_uint32 iCount; - mng_evnt_entryp pEntries; - } mng_evnt; -typedef mng_evnt * mng_evntp; - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_MPNG_PROPOSAL -typedef struct { /* mpNG frame */ - mng_uint32 iX; - mng_uint32 iY; - mng_uint32 iWidth; - mng_uint32 iHeight; - mng_int32 iXoffset; - mng_int32 iYoffset; - mng_uint16 iTicks; - } mng_mpng_frame; -typedef mng_mpng_frame * mng_mpng_framep; - -typedef struct { /* mpNG */ - mng_chunk_header sHeader; - mng_uint32 iFramewidth; - mng_uint32 iFrameheight; - mng_uint16 iNumplays; - mng_uint16 iTickspersec; - mng_uint8 iCompressionmethod; - mng_uint32 iFramessize; - mng_mpng_framep pFrames; - } mng_mpng; -typedef mng_mpng * mng_mpngp; -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ANG_PROPOSAL -typedef struct { /* ahDR */ - mng_chunk_header sHeader; - mng_uint32 iNumframes; - mng_uint32 iTickspersec; - mng_uint32 iNumplays; - mng_uint32 iTilewidth; - mng_uint32 iTileheight; - mng_uint8 iInterlace; - mng_uint8 iStillused; - } mng_ahdr; -typedef mng_ahdr * mng_ahdrp; - -typedef struct { /* adAT tile */ - mng_uint32 iTicks; - mng_int32 iXoffset; - mng_int32 iYoffset; - mng_uint8 iTilesource; - } mng_adat_tile; -typedef mng_adat_tile * mng_adat_tilep; - -typedef struct { /* adAT */ - mng_chunk_header sHeader; - mng_uint32 iTilessize; - mng_adat_tilep pTiles; - } mng_adat; -typedef mng_adat * mng_adatp; -#endif - -/* ************************************************************************** */ - -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 * */ -/* ************************************************************************** */ diff --git a/plugins/AdvaImg/src/LibMNG/libmng_cms.c b/plugins/AdvaImg/src/LibMNG/libmng_cms.c deleted file mode 100644 index f215271f2a..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_cms.c +++ /dev/null @@ -1,758 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_cms.c copyright (c) 2000-2004 G.Juyn * */ -/* * version : 1.0.9 * */ -/* * * */ -/* * purpose : color management routines (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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 * */ -/* * * */ -/* * 0.9.3 - 08/31/2000 - G.Juyn * */ -/* * - fixed sRGB precedence for gamma_only corection * */ -/* * * */ -/* * 0.9.4 - 12/16/2000 - G.Juyn * */ -/* * - fixed mixup of data- & function-pointers (thanks Dimitri)* */ -/* * * */ -/* * 1.0.1 - 03/31/2001 - G.Juyn * */ -/* * - ignore gamma=0 (see png-list for more info) * */ -/* * 1.0.1 - 04/25/2001 - G.Juyn (reported by Gregg Kelly) * */ -/* * - fixed problem with cms profile being created multiple * */ -/* * times when both iCCP & cHRM/gAMA are present * */ -/* * 1.0.1 - 04/25/2001 - G.Juyn * */ -/* * - moved mng_clear_cms to libmng_cms * */ -/* * 1.0.1 - 05/02/2001 - G.Juyn * */ -/* * - added "default" sRGB generation (Thanks Marti!) * */ -/* * * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * 1.0.5 - 09/19/2002 - G.Juyn * */ -/* * - optimized color-correction routines * */ -/* * 1.0.5 - 09/23/2002 - G.Juyn * */ -/* * - added in-memory color-correction of abstract images * */ -/* * 1.0.5 - 11/08/2002 - G.Juyn * */ -/* * - fixed issues in init_app_cms() * */ -/* * * */ -/* * 1.0.6 - 04/11/2003 - G.Juyn * */ -/* * - B719420 - fixed several MNG_APP_CMS problems * */ -/* * 1.0.6 - 07/11/2003 - G. R-P * */ -/* * - added conditional MNG_SKIPCHUNK_cHRM/iCCP * */ -/* * * */ -/* * 1.0.9 - 12/20/2004 - G.Juyn * */ -/* * - cleaned up macro-invocations (thanks to D. Airlie) * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_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); -} - -/* ************************************************************************** */ - -mng_cmsprof mnglcms_createsrgbprofile (void) -{ - cmsCIExyY D65; - cmsCIExyYTRIPLE Rec709Primaries = { - {0.6400, 0.3300, 1.0}, - {0.3000, 0.6000, 1.0}, - {0.1500, 0.0600, 1.0} - }; - LPGAMMATABLE Gamma24[3]; - mng_cmsprof hsRGB; - - cmsWhitePointFromTemp(6504, &D65); - Gamma24[0] = Gamma24[1] = Gamma24[2] = cmsBuildGamma(256, 2.4); - hsRGB = cmsCreateRGBProfile(&D65, &Rec709Primaries, Gamma24); - cmsFreeGamma(Gamma24[0]); - - return hsRGB; -} - -/* ************************************************************************** */ - -void mnglcms_freeprofile (mng_cmsprof hProf) -{ - cmsCloseProfile (hProf); - return; -} - -/* ************************************************************************** */ - -void mnglcms_freetransform (mng_cmstrans hTrans) -{ -/* B001 start */ - cmsDeleteTransform (hTrans); -/* B001 end */ - return; -} - -/* ************************************************************************** */ - -mng_retcode mng_clear_cms (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLEAR_CMS, MNG_LC_START); -#endif - - if (pData->hTrans) /* transformation still active ? */ - mnglcms_freetransform (pData->hTrans); - - pData->hTrans = 0; - - if (pData->hProf1) /* file profile still active ? */ - mnglcms_freeprofile (pData->hProf1); - - pData->hProf1 = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLEAR_CMS, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_LCMS */ - -/* ************************************************************************** */ -/* * * */ -/* * Color-management initialization & correction routines * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_LCMS - -mng_retcode mng_init_full_cms (mng_datap pData, - mng_bool bGlobal, - mng_bool bObject, - mng_bool bRetrobj) -{ - mng_cmsprof hProf; - mng_cmstrans hTrans; - mng_imagep pImage = MNG_NULL; - mng_imagedatap pBuf = MNG_NULL; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_FULL_CMS, MNG_LC_START); -#endif - - if (bObject) /* use object if present ? */ - { /* current object ? */ - if ((mng_imagep)pData->pCurrentobj) - pImage = (mng_imagep)pData->pCurrentobj; - else /* if not; use object 0 */ - pImage = (mng_imagep)pData->pObjzero; - } - - if (bRetrobj) /* retrieving from an object ? */ - pImage = (mng_imagep)pData->pRetrieveobj; - - if (pImage) /* are we using an object ? */ - pBuf = pImage->pImgbuf; /* then address the buffer */ - - if ((!pBuf) || (!pBuf->bCorrected)) /* is the buffer already corrected ? */ - { -#ifndef MNG_SKIPCHUNK_iCCP - if (((pBuf) && (pBuf->bHasICCP)) || ((bGlobal) && (pData->bHasglobalICCP))) - { - if (!pData->hProf2) /* output profile not defined ? */ - { /* then assume sRGB !! */ - pData->hProf2 = mnglcms_createsrgbprofile (); - - if (!pData->hProf2) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE); - } - - if ((pBuf) && (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); - -#ifndef MNG_NO_16BIT_SUPPORT - 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 -#endif - 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_fptr)mng_correct_full_cms; - - return MNG_NOERROR; /* and done */ - } - else -#endif - if (((pBuf) && (pBuf->bHasSRGB)) || ((bGlobal) && (pData->bHasglobalSRGB))) - { - mng_uint8 iIntent; - - if (pData->bIssRGB) /* sRGB system ? */ - return MNG_NOERROR; /* no conversion required */ - - if (!pData->hProf3) /* sRGB profile not defined ? */ - { /* then create it implicitly !! */ - pData->hProf3 = mnglcms_createsrgbprofile (); - - if (!pData->hProf3) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE); - } - - hProf = pData->hProf3; /* convert from sRGB profile */ - - if ((pBuf) && (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_fptr)mng_correct_full_cms; - - return MNG_NOERROR; /* and done */ - } - else - if ( (((pBuf) && (pBuf->bHasCHRM)) || ((bGlobal) && (pData->bHasglobalCHRM))) && - ( ((pBuf) && (pBuf->bHasGAMA) && (pBuf->iGamma > 0)) || - ((bGlobal) && (pData->bHasglobalGAMA) && (pData->iGlobalGamma > 0)) ) ) - { - mng_CIExyY sWhitepoint; - mng_CIExyYTRIPLE sPrimaries; - mng_gammatabp pGammatable[3]; - mng_float dGamma; - - if (!pData->hProf2) /* output profile not defined ? */ - { /* then assume sRGB !! */ - pData->hProf2 = mnglcms_createsrgbprofile (); - - if (!pData->hProf2) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE); - } - -#ifndef MNG_SKIPCHUNK_cHRM - if ((pBuf) && (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; - } -#endif - - sWhitepoint.Y = /* Y component is always 1.0 */ - sPrimaries.Red.Y = - sPrimaries.Green.Y = - sPrimaries.Blue.Y = 1.0; - - if ((pBuf) && (pBuf->bHasGAMA)) /* get the gamma value */ - dGamma = (mng_float)pBuf->iGamma / 100000; - else - dGamma = (mng_float)pData->iGlobalGamma / 100000; - - dGamma = pData->dViewgamma / dGamma; - - pGammatable [0] = /* and build the lookup tables */ - pGammatable [1] = - pGammatable [2] = cmsBuildGamma (256, dGamma); - - if (!pGammatable [0]) /* enough memory ? */ - MNG_ERRORL (pData, MNG_LCMS_NOMEM); - /* create the profile */ - hProf = cmsCreateRGBProfile (&sWhitepoint, &sPrimaries, pGammatable); - - cmsFreeGamma (pGammatable [0]); /* free the temporary gamma tables ? */ - /* yes! but just the one! */ - - 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_fptr)mng_correct_full_cms; - - return MNG_NOERROR; /* and done */ - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_FULL_CMS, MNG_LC_END); -#endif - /* if we get here, we'll only do gamma */ - return mng_init_gamma_only (pData, bGlobal, bObject, bRetrobj); -} -#endif /* MNG_INCLUDE_LCMS */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_LCMS -mng_retcode mng_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) || defined(MNG_APP_CMS) -mng_retcode mng_init_gamma_only (mng_datap pData, - mng_bool bGlobal, - mng_bool bObject, - mng_bool bRetrobj) -{ - mng_float dGamma; - mng_imagep pImage = MNG_NULL; - mng_imagedatap pBuf = MNG_NULL; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GAMMA_ONLY, MNG_LC_START); -#endif - - if (bObject) /* use object if present ? */ - { /* current object ? */ - if ((mng_imagep)pData->pCurrentobj) - pImage = (mng_imagep)pData->pCurrentobj; - else /* if not; use object 0 */ - pImage = (mng_imagep)pData->pObjzero; - } - - if (bRetrobj) /* retrieving from an object ? */ - pImage = (mng_imagep)pData->pRetrieveobj; - - if (pImage) /* are we using an object ? */ - pBuf = pImage->pImgbuf; /* then address the buffer */ - - if ((!pBuf) || (!pBuf->bCorrected)) /* is the buffer already corrected ? */ - { - if ((pBuf) && (pBuf->bHasSRGB)) /* get the gamma value */ - dGamma = 0.45455; - else - if ((pBuf) && (pBuf->bHasGAMA)) - dGamma = (mng_float)pBuf->iGamma / 100000; - else - if ((bGlobal) && (pData->bHasglobalSRGB)) - dGamma = 0.45455; - else - if ((bGlobal) && (pData->bHasglobalGAMA)) - dGamma = (mng_float)pData->iGlobalGamma / 100000; - else - dGamma = pData->dDfltimggamma; - - if (dGamma > 0) /* ignore gamma=0 */ - { - 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_fptr)mng_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 || MNG_APP_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_GAMMA_ONLY) || defined(MNG_FULL_CMS) || defined(MNG_APP_CMS) -mng_retcode mng_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 || MNG_APP_CMS */ - -/* ************************************************************************** */ - -#ifdef MNG_APP_CMS -mng_retcode mng_init_app_cms (mng_datap pData, - mng_bool bGlobal, - mng_bool bObject, - mng_bool bRetrobj) -{ - mng_imagep pImage = MNG_NULL; - mng_imagedatap pBuf = MNG_NULL; - mng_bool bDone = MNG_FALSE; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_APP_CMS, MNG_LC_START); -#endif - - if (bObject) /* use object if present ? */ - { /* current object ? */ - if ((mng_imagep)pData->pCurrentobj) - pImage = (mng_imagep)pData->pCurrentobj; - else /* if not; use object 0 */ - pImage = (mng_imagep)pData->pObjzero; - } - - if (bRetrobj) /* retrieving from an object ? */ - pImage = (mng_imagep)pData->pRetrieveobj; - - if (pImage) /* are we using an object ? */ - pBuf = pImage->pImgbuf; /* then address the buffer */ - - if ((!pBuf) || (!pBuf->bCorrected)) /* is the buffer already corrected ? */ - { -#ifndef MNG_SKIPCHUNK_iCCP - if ( (pData->fProcessiccp) && - (((pBuf) && (pBuf->bHasICCP)) || ((bGlobal) && (pData->bHasglobalICCP))) ) - { - mng_uint32 iProfilesize; - mng_ptr pProfile; - - if ((pBuf) && (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_fptr)mng_correct_app_cms; - bDone = MNG_TRUE; - } -#endif - - if ( (pData->fProcesssrgb) && - (((pBuf) && (pBuf->bHasSRGB)) || ((bGlobal) && (pData->bHasglobalSRGB))) ) - { - mng_uint8 iIntent; - - if ((pBuf) && (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_fptr)mng_correct_app_cms; - bDone = MNG_TRUE; - } - -#ifndef MNG_SKIPCHUNK_cHRM - if ( (pData->fProcesschroma) && - (((pBuf) && (pBuf->bHasCHRM)) || ((bGlobal) && (pData->bHasglobalCHRM))) ) - { - mng_uint32 iWhitepointx, iWhitepointy; - mng_uint32 iPrimaryredx, iPrimaryredy; - mng_uint32 iPrimarygreenx, iPrimarygreeny; - mng_uint32 iPrimarybluex, iPrimarybluey; - - if ((pBuf) && (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_fptr)mng_correct_app_cms; - bDone = MNG_TRUE; - } -#endif - - if ( (pData->fProcessgamma) && - (((pBuf) && (pBuf->bHasGAMA)) || ((bGlobal) && (pData->bHasglobalGAMA))) ) - { - mng_uint32 iGamma; - - if ((pBuf) && (pBuf->bHasGAMA)) /* get the gamma value */ - iGamma = pBuf->iGamma; - else - iGamma = pData->iGlobalGamma; - /* inform the app */ - if (!pData->fProcessgamma ((mng_handle)pData, iGamma)) - { /* app wants us to use internal routines ! */ - iRetcode = mng_init_gamma_only (pData, bGlobal, bObject, bRetrobj); - if (iRetcode) /* on error bail out */ - return iRetcode; - } - else - { /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)mng_correct_app_cms; - } - - bDone = MNG_TRUE; - } - - if (!bDone) /* no color-info at all ? */ - { - /* then use default image gamma ! */ - if (!pData->fProcessgamma ((mng_handle)pData, - (mng_uint32)((pData->dDfltimggamma * 100000) + 0.5))) - { /* app wants us to use internal routines ! */ - iRetcode = mng_init_gamma_only (pData, bGlobal, bObject, bRetrobj); - if (iRetcode) /* on error bail out */ - return iRetcode; - } - else - { /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)mng_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 mng_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 * */ -/* ************************************************************************** */ - - - diff --git a/plugins/AdvaImg/src/LibMNG/libmng_cms.h b/plugins/AdvaImg/src/LibMNG/libmng_cms.h deleted file mode 100644 index d442a3fa6a..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_cms.h +++ /dev/null @@ -1,92 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_cms.h copyright (c) 2000-2003 G.Juyn * */ -/* * version : 1.0.6 * */ -/* * * */ -/* * purpose : color management routines (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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 * */ -/* * * */ -/* * 1.0.1 - 04/25/2001 - G.Juyn * */ -/* * - moved mng_clear_cms to libmng_cms * */ -/* * 1.0.1 - 05/02/2001 - G.Juyn * */ -/* * - added "default" sRGB generation (Thanks Marti!) * */ -/* * * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * 1.0.5 - 09/19/2002 - G.Juyn * */ -/* * - optimized color-correction routines * */ -/* * * */ -/* * 1.0.6 - 04/11/2003 - G.Juyn * */ -/* * - B719420 - fixed several MNG_APP_CMS problems * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_cms_h_ -#define _libmng_cms_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 ); -mng_cmsprof mnglcms_createsrgbprofile (void); -void mnglcms_freeprofile (mng_cmsprof hProf ); -void mnglcms_freetransform (mng_cmstrans hTrans ); - -mng_retcode mng_clear_cms (mng_datap pData ); -#endif - -/* ************************************************************************** */ - -#ifdef MNG_FULL_CMS -mng_retcode mng_init_full_cms (mng_datap pData, - mng_bool bGlobal, - mng_bool bObject, - mng_bool bRetrobj); -mng_retcode mng_correct_full_cms (mng_datap pData); -#endif - -#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) || defined(MNG_APP_CMS) -mng_retcode mng_init_gamma_only (mng_datap pData, - mng_bool bGlobal, - mng_bool bObject, - mng_bool bRetrobj); -mng_retcode mng_correct_gamma_only (mng_datap pData); -#endif - -#ifdef MNG_APP_CMS -mng_retcode mng_init_app_cms (mng_datap pData, - mng_bool bGlobal, - mng_bool bObject, - mng_bool bRetrobj); -mng_retcode mng_correct_app_cms (mng_datap pData); -#endif - -/* ************************************************************************** */ - -#endif /* _libmng_cms_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/plugins/AdvaImg/src/LibMNG/libmng_conf.h b/plugins/AdvaImg/src/LibMNG/libmng_conf.h deleted file mode 100644 index 5f6fdb91a5..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_conf.h +++ /dev/null @@ -1,306 +0,0 @@ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_conf.h copyright (c) G.Juyn 2000-2004 * */ -/* * version : 1.0.9 * */ -/* * * */ -/* * purpose : main configuration file * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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 * */ -/* * * */ -/* * 0.9.3 - 08/12/2000 - G.Juyn * */ -/* * - added workaround for faulty PhotoShop iCCP chunk * */ -/* * 0.9.3 - 09/16/2000 - G.Juyn * */ -/* * - removed trace-options from default SO/DLL builds * */ -/* * * */ -/* * 1.0.4 - 06/22/2002 - G.Juyn * */ -/* * - B526138 - returned IJGSRC6B calling convention to * */ -/* * default for MSVC * */ -/* * * */ -/* * 1.0.5 - 09/14/2002 - G.Juyn * */ -/* * - added event handling for dynamic MNG * */ -/* * - added 'supports' call to check function availability * */ -/* * * */ -/* * 1.0.6 - 06/22/2002 - G.R-P * */ -/* * - added MNG_NO_INCLUDE_JNG conditional * */ -/* * - added MNG_SKIPCHUNK_evNT conditional * */ -/* * 1.0.6 - 07/14/2002 - G.R-P * */ -/* * - added MNG_NO_SUPPORT_FUNCQUERY conditional * */ -/* * * */ -/* * 1.0.7 - 03/07/2004 - G.R-P * */ -/* * - added MNG_VERSION_QUERY_SUPPORT_ conditional * */ -/* * * */ -/* * 1.0.9 - 05/12/2004 - G.Juyn * */ -/* * - clearified MNG_BIGENDIAN_SUPPORTED conditional * */ -/* * - added MNG_LITTLEENDIAN_SUPPORTED conditional * */ -/* * * */ -/* ************************************************************************** */ - - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_conf_h_ -#define _libmng_conf_h_ - -#ifdef MNG_MOZILLA_CFG -#include "special\mozcfg\mozlibmngconf.h" -#endif - -/* ************************************************************************** */ -/* * * */ -/* * User-selectable compile-time options * */ -/* * * */ -/* ************************************************************************** */ - -/* ************************************************************************** */ -/* added by FreeImage */ -/* ************************************************************************** */ - -#define MNG_OPTIMIZE_CHUNKINITFREE -#define MNG_OPTIMIZE_OBJCLEANUP -#define MNG_OPTIMIZE_CHUNKASSIGN -#define MNG_OPTIMIZE_CHUNKREADER - -/* ************************************************************************** */ - -/* 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!) */ - -#ifndef MNG_NO_INCLUDE_JNG -#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 - -/* The following is required to export the IJG routines from the DLL in - the Windows-standard calling convention; - currently this only works for Borland C++ !!! */ - -#if defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL) -#if defined(MNG_SUPPORT_IJG6B) && defined(__BORLANDC__) -#define MNG_DEFINE_JPEG_STDCALL -#endif -#endif -#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(1) 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 */ - -#define MNG_GAMMA_ONLY -/* #define MNG_FULL_CMS */ -/* #define MNG_APP_CMS */ - -/* ************************************************************************** */ - -/* 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! */ - -/* #define MNG_SUPPORT_TRACE */ - -/* ************************************************************************** */ - -/* 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/LITTLE endian optimizations */ -/* enable BIG 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 */ -/* enable LITTLE if you're on an architecture that supports little-endian */ -/* when in doubt leave both off !!! */ - -/* #define MNG_BIGENDIAN_SUPPORTED */ -/* #define MNG_LITTLEENDIAN_SUPPORTED */ - -/* ************************************************************************** */ -/* enable 'version' functions */ -#if !defined(MNG_VERSION_QUERY_SUPPORT) && \ - !defined(MNG_NO_VERSION_QUERY_SUPPORT) -#define MNG_VERSION_QUERY_SUPPORT -#endif - -/* enable 'supports' function */ -/* use this if you need to query the availability of functions at runtime; - useful for apps that dynamically load the library and that need specific - functions */ - -#if !defined(MNG_NO_SUPPORT_FUNCQUERY) && !defined(MNG_SUPPORT_FUNCQUERY) -#if defined(MNG_BUILD_SO) || defined(MNG_USE_SO) || \ - defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL) -#define MNG_SUPPORT_FUNCQUERY -#endif -#endif - -/* ************************************************************************** */ - -/* enable dynamic MNG features */ -/* use this if you would like to have dynamic support for specifically - designed MNGs; eg. this is useful for 'rollover' effects such as common - on the world wide web */ - -#ifndef MNG_SUPPORT_DYNAMICMNG -#if defined(MNG_BUILD_SO) || defined(MNG_USE_SO) || defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL) -#define MNG_SUPPORT_DYNAMICMNG -#endif -#endif -#ifndef MNG_SUPPORT_DYNAMICMNG -#ifndef MNG_SKIPCHUNK_evNT -#define MNG_SKIPCHUNK_evNT -#endif -#endif - -#ifdef MNG_INCLUDE_JNG -#ifndef MNG_NO_ACCESS_JPEG -#ifndef MNG_ACCESS_JPEG -#define MNG_ACCESS_JPEG -#endif -#endif -#endif - -#ifdef MNG_INCLUDE_ZLIB -#ifndef MNG_NO_ACCESS_ZLIB -#ifndef MNG_ACCESS_ZLIB -#define MNG_ACCESS_ZLIB -#endif -#endif -#endif - -/* ************************************************************************** */ -/* * * */ -/* * End of user-selectable compile-time options * */ -/* * * */ -/* ************************************************************************** */ - -#endif /* _libmng_conf_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/plugins/AdvaImg/src/LibMNG/libmng_data.h b/plugins/AdvaImg/src/LibMNG/libmng_data.h deleted file mode 100644 index dd715b0989..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_data.h +++ /dev/null @@ -1,1029 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_data.h copyright (c) 2000-2007 G.Juyn * */ -/* * version : 1.0.10 * */ -/* * * */ -/* * purpose : main data structure definition * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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 * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * 0.9.3 - 09/10/2000 - G.Juyn * */ -/* * - fixed DEFI behavior * */ -/* * 0.9.3 - 10/10/2000 - G.Juyn * */ -/* * - added support for alpha-depth prediction * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added optional support for bKGD for PNG images * */ -/* * - added support for JDAA * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added callback to process non-critical unknown chunks * */ -/* * - fixed support for bKGD * */ -/* * 0.9.3 - 10/19/2000 - G.Juyn * */ -/* * - implemented delayed delta-processing * */ -/* * 0.9.4 - 12/16/2000 - G.Juyn * */ -/* * - fixed mixup of data- & function-pointers (thanks Dimitri)* */ -/* * * */ -/* * 1.0.1 - 02/08/2001 - G.Juyn * */ -/* * - added MEND processing callback * */ -/* * 1.0.1 - 02/13/2001 - G.Juyn * */ -/* * - fixed first FRAM_MODE=4 timing problem * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added optimization option for MNG-video playback * */ -/* * - added processterm callback * */ -/* * 1.0.2 - 06/25/2001 - G.Juyn * */ -/* * - added option to turn off progressive refresh * */ -/* * * */ -/* * 1.0.5 - 07/08/2002 - G.Juyn * */ -/* * - B578572 - removed eMNGma hack (thanks Dimitri!) * */ -/* * 1.0.5 - 07/16/2002 - G.Juyn * */ -/* * - B581625 - large chunks fail with suspension reads * */ -/* * 1.0.5 - 08/15/2002 - G.Juyn * */ -/* * - completed PROM support * */ -/* * 1.0.5 - 09/15/2002 - G.Juyn * */ -/* * - fixed LOOP iteration=0 special case * */ -/* * 1.0.5 - 09/20/2002 - G.Juyn * */ -/* * - finished support for BACK image & tiling * */ -/* * 1.0.5 - 10/07/2002 - G.Juyn * */ -/* * - added another fix for misplaced TERM chunk * */ -/* * - completed support for condition=2 in TERM chunk * */ -/* * 1.0.5 - 10/20/2002 - G.Juyn * */ -/* * - fixed processing for multiple objects in MAGN * */ -/* * - fixed display of visible target of PAST operation * */ -/* * 1.0.5 - 11/07/2002 - G.Juyn * */ -/* * - added support to get totals after mng_read() * */ -/* * 1.0.5 - 24/02/2003 - G.Juyn * */ -/* * - B683152 - libjpeg suspension not always honored correctly* */ -/* * * */ -/* * 1.0.6 - 04/11/2003 - G.Juyn * */ -/* * - B719420 - fixed several MNG_APP_CMS problems * */ -/* * 1.0.6 - 07/05/2003 - G. R-P * */ -/* * - optionally use zlib's crc32() function * */ -/* * 1.0.6 - 07/29/2003 - G.R-P * */ -/* * - added SKIPCHUNK conditionals around PAST chunk support * */ -/* * 1.0.6 - 08/17/2003 - G.R-P * */ -/* * - added iPNGdepth member to pData structure * */ -/* * * */ -/* * 1.0.7 - 03/10/2004 - G.R-P * */ -/* * - added conditionals around openstream/closestream * */ -/* * 1.0.7 - 03/24/2004 - G.R-P * */ -/* * - added more SKIPCHUNK conditionals * */ -/* * * */ -/* * 1.0.8 - 04/02/2004 - G.Juyn * */ -/* * - added CRC existence & checking flags * */ -/* * 1.0.8 - 04/10/2004 - G.Juyn * */ -/* * - added data-push mechanisms for specialized decoders * */ -/* * * */ -/* * 1.0.9 - 12/11/2004 - G.Juyn * */ -/* * - added conditional MNG_OPTIMIZE_DISPLAYCALLS * */ -/* * * */ -/* * 1.0.10 - 04/08/2007 - G.Juyn * */ -/* * - added support for mPNG proposal * */ -/* * 1.0.10 - 04/12/2007 - G.Juyn * */ -/* * - added support for ANG proposal * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_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 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 */ - -#ifndef MNG_SKIPCHUNK_cHRM - 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; -#endif - - 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; - -/* ************************************************************************** */ -/* * * */ -/* * Internal buffer structure for data push mechanisms * */ -/* * * */ -/* ************************************************************************** */ - -typedef struct { - mng_ptr pNext; /* for linked list */ - mng_ptr pData; /* used for chunks & data */ - mng_uint32 iLength; - mng_bool bOwned; - mng_uint8p pDatanext; /* only used for data */ - mng_uint32 iRemaining; - } mng_pushdata; -typedef mng_pushdata * mng_pushdatap; - -/* ************************************************************************** */ -/* * * */ -/* * 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_uint8 iAlphadepth; /* indicates expected alpha-depth */ - - mng_uint32 iImagelevel; /* level of 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 bUseBKGD; /* preferred use of bKGD for PNG */ - - 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_bool bCacheplayback; /* switch to cache playback info */ - mng_bool bDoProgressive; /* progressive refresh for large images */ - mng_uint32 iCrcmode; /* CRC existence & checking flags */ - - 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_releasedata fReleasedata; -#ifndef MNG_NO_OPEN_CLOSE_STREAM - mng_openstream fOpenstream; - mng_closestream fClosestream; -#endif - 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_processneed fProcessneed; - mng_processmend fProcessmend; - mng_processunknown fProcessunknown; - mng_processterm fProcessterm; - 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) -#ifndef MNG_NO_OLD_VERSIONS - mng_bool bPreDraft48; /* flags ancient style draft */ -#endif - - 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 bHasJDAA; /* at least 1 JDAA processed */ - 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 */ - -#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 */ - mng_uint8p pLargebufnext; - - mng_pushdatap pFirstpushchunk; /* variables for push mechanisms */ - mng_pushdatap pLastpushchunk; - mng_pushdatap pFirstpushdata; - mng_pushdatap pLastpushdata; -#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_bool bFramedone; - mng_uint32 iFrameseq; - mng_uint32 iLayerseq; - mng_uint32 iFrametime; /* millisecs */ - - mng_uint32 iTotalframes; /* end-totals after mng_read() */ - mng_uint32 iTotallayers; - mng_uint32 iTotalplaytime; /* millisecs */ - - mng_bool bSkipping; /* LOOP iteration=0 */ - -#ifdef MNG_SUPPORT_DYNAMICMNG - mng_bool bDynamic; /* MNG is dynamic (eg. has events) */ - mng_bool bRunningevent; /* currently processing an event */ - mng_bool bStopafterseek; /* stop after next SEEK */ - mng_int32 iEventx; /* X/Y of current event */ - mng_int32 iEventy; - mng_objectp pLastmousemove; /* last event triggered */ -#endif - - mng_uint32 iRequestframe; /* go_xxxx variables */ - mng_uint32 iRequestlayer; - mng_uint32 iRequesttime; - mng_bool bSearching; - - mng_bool bRestorebkgd; /* flags restore required before IDAT/JDAT */ - - 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_bool bMisplacedTERM; /* indicates TERM is out of place */ - mng_bool bOnlyfirstframe; /* show first frame after TERM and stop */ - mng_uint32 iFramesafterTERM; /* determines frame-count after TERM */ - mng_objectp pCurrentobj; /* current "object" */ - mng_objectp pCurraniobj; /* current animation object - "to be"/"being" processed */ - mng_objectp pTermaniobj; /* TERM animation object */ - mng_uint32 iIterations; /* TERM/MEND iteration count */ - 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_int32 iFilterofs; /* offset to filter-byte in work row */ - mng_int32 iPixelofs; /* offset to pixel-bytes in work row */ - mng_uint32 iLevel0; /* leveling variables */ - mng_uint32 iLevel1; - mng_uint32 iLevel2; - mng_uint32 iLevel3; - 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 */ -#ifdef MNG_SUPPORT_DYNAMICMNG - mng_objectp pFirstevent; /* double-linked list of */ - mng_objectp pLastevent; /* event-object structures */ -#endif - -#if defined(MNG_GAMMA_ONLY) || defined(MNG_FULL_CMS) || defined(MNG_APP_CMS) - mng_uint8 aGammatab[256]; /* precomputed gamma lookup table */ - mng_float dLastgamma; /* last gamma used to compute table */ -#endif - - mng_fptr fDisplayrow; /* internal callback to display an - uncompressed/unfiltered/ - color-corrected row */ - mng_fptr fRestbkgdrow; /* internal callback for restore- - background processing of a row */ - mng_fptr fCorrectrow; /* internal callback to color-correct an - uncompressed/unfiltered row */ - mng_fptr fRetrieverow; /* internal callback to retrieve an - uncompressed/unfiltered row of data */ - mng_fptr fStorerow; /* internal callback to store an - uncompressed/unfiltered row of data */ - mng_fptr fProcessrow; /* internal callback to process an - uncompressed row of data */ - mng_fptr fDifferrow; /* internal callback to perform - added filter leveling and - differing on an unfiltered row */ - mng_fptr fScalerow; /* internal callback to scale a - delta-row to the bitdepth of its target */ - mng_fptr fDeltarow; /* internal callback to execute a - delta-row onto a target */ -#ifndef MNG_SKIPCHUNK_PAST - mng_fptr fFliprow; /* internal callback to flip a row of pixels - left<->right for a PAST operation */ - mng_fptr fTilerow; /* internal callback to tile a row of pixels - during a PAST operation */ -#endif - mng_fptr fInitrowproc; /* internal callback to initialize - the row processing */ - - mng_uint16 iDEFIobjectid; /* DEFI fields */ - mng_bool bDEFIhasdonotshow; - mng_uint8 iDEFIdonotshow; - mng_bool bDEFIhasconcrete; - 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_int32 iBackimgoffsx; /* temp variables for restore_bkgd */ - mng_int32 iBackimgoffsy; - mng_uint32 iBackimgwidth; - mng_uint32 iBackimgheight; - -#ifndef MNG_SKIPCHUNK_FRAM - 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 *after* next image */ -#endif - -#ifndef MNG_SKIPCHUNK_SHOW - mng_uint8 iSHOWmode; /* SHOW fields */ - mng_uint16 iSHOWfromid; - mng_uint16 iSHOWtoid; - mng_uint16 iSHOWnextid; - mng_int16 iSHOWskip; -#endif - - mng_uint32 iGlobalPLTEcount; /* global PLTE fields */ - mng_rgbpaltab aGlobalPLTEentries; - - mng_uint32 iGlobalTRNSrawlen; /* global tRNS fields */ - mng_uint8arr aGlobalTRNSrawdata; - - mng_uint32 iGlobalGamma; /* global gAMA fields */ - -#ifndef MNG_SKIPCHUNK_cHRM - 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; -#endif - - mng_uint8 iGlobalRendintent; /* global sRGB fields */ - -#ifndef MNG_SKIPCHUNK_iCCP - mng_uint32 iGlobalProfilesize; /* global iCCP fields */ - mng_ptr pGlobalProfile; -#endif - - mng_uint16 iGlobalBKGDred; /* global bKGD fields */ - mng_uint16 iGlobalBKGDgreen; - mng_uint16 iGlobalBKGDblue; - - mng_ptr pDeltaImage; /* delta-image fields */ - mng_uint8 iDeltaImagetype; -#endif /* MNG_SUPPORT_DISPLAY */ - mng_uint8 iDeltatype; /* need this one in read processing !! */ -#ifdef MNG_SUPPORT_DISPLAY - mng_uint32 iDeltaBlockwidth; - mng_uint32 iDeltaBlockheight; - mng_uint32 iDeltaBlockx; - mng_uint32 iDeltaBlocky; - mng_bool bDeltaimmediate; - - mng_fptr fDeltagetrow; /* internal delta-proc callbacks */ - mng_fptr fDeltaaddrow; - mng_fptr fDeltareplacerow; - mng_fptr fDeltaputrow; - -#ifndef MNG_SKIPCHUNK_PROM - mng_fptr fPromoterow; /* internal PROM fields */ - mng_fptr fPromBitdepth; - mng_ptr pPromBuf; - mng_uint8 iPromColortype; - mng_uint8 iPromBitdepth; - mng_uint8 iPromFilltype; - mng_uint32 iPromWidth; - mng_ptr pPromSrc; - mng_ptr pPromDst; -#endif - -#ifndef MNG_SKIPCHUNK_MAGN - mng_uint16 iMAGNfromid; - mng_uint16 iMAGNcurrentid; - mng_uint16 iMAGNtoid; -#endif - -#ifndef MNG_SKIPCHUNK_PAST - mng_uint16 iPASTid; - mng_int32 iPastx; /* target x/y of last PAST */ - mng_int32 iPasty; -#endif - - mng_objectp pLastseek; /* last processed ani_seek object */ - -#ifdef MNG_INCLUDE_MPNG_PROPOSAL - mng_objectp pMPNG; /* mpNG object if available */ -#endif -#ifdef MNG_INCLUDE_ANG_PROPOSAL - mng_objectp pANG; /* ANG object if available */ -#endif - -#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/JDAA data */ - - mngjpeg_compp pJPEGcinfo; /* compression structure */ - mngjpeg_errorp pJPEGcerr; /* error-manager compress */ - - mngjpeg_decompp pJPEGdinfo; /* decompression structure (JDAT) */ - mngjpeg_errorp pJPEGderr; /* error-manager decompress (JDAT) */ - mngjpeg_sourcep pJPEGdsrc; /* source-manager decompress (JDAT) */ - - mngjpeg_decompp pJPEGdinfo2; /* decompression structure (JDAA) */ - mngjpeg_errorp pJPEGderr2; /* error-manager decompress (JDAA) */ - mngjpeg_sourcep pJPEGdsrc2; /* source-manager decompress (JDAA) */ - - mng_uint8p pJPEGbuf; /* buffer for JPEG (de)compression (JDAT) */ - mng_uint32 iJPEGbufmax; /* allocated space for buffer (JDAT) */ - mng_uint8p pJPEGcurrent; /* current pointer into buffer (JDAT) */ - mng_uint32 iJPEGbufremain; /* remaining bytes in buffer (JDAT) */ - mng_uint32 iJPEGtoskip; /* bytes to skip on next input-block (JDAT) */ - - mng_uint8p pJPEGbuf2; /* buffer for JPEG (de)compression (JDAA) */ - mng_uint32 iJPEGbufmax2; /* allocated space for buffer (JDAA) */ - mng_uint8p pJPEGcurrent2; /* current pointer into buffer (JDAA) */ - mng_uint32 iJPEGbufremain2; /* remaining bytes in buffer (JDAA) */ - mng_uint32 iJPEGtoskip2; /* bytes to skip on next input-block (JDAA) */ - - mng_uint8p pJPEGrow; /* buffer for a JPEG row of samples (JDAT) */ - mng_uint32 iJPEGrowlen; - - mng_uint8p pJPEGrow2; /* buffer for a JPEG row of samples (JDAA) */ - mng_uint32 iJPEGrowlen2; - - mng_bool bJPEGcompress; /* indicates "compress" initialized */ - - mng_bool bJPEGdecompress; /* indicates "decompress" initialized (JDAT) */ - mng_bool bJPEGhasheader; /* indicates "readheader" succeeded (JDAT) */ - mng_bool bJPEGdecostarted; /* indicates "decompress" started (JDAT) */ - mng_bool bJPEGscanstarted; /* indicates "first scan" started (JDAT) */ - mng_bool bJPEGscanending; /* indicates "finish_output" suspended (JDAT) */ - mng_bool bJPEGprogressive; /* indicates a progressive image (JDAT) */ - - mng_bool bJPEGdecompress2; /* indicates "decompress" initialized (JDAA) */ - mng_bool bJPEGhasheader2; /* indicates "readheader" succeeded (JDAA) */ - mng_bool bJPEGdecostarted2; /* indicates "decompress" started (JDAA) */ - mng_bool bJPEGscanstarted2; /* indicates "first scan" started (JDAA) */ - mng_bool bJPEGprogressive2; /* indicates a progressive image (JDAA) */ - - mng_fptr fStorerow2; /* internal callback to store an - uncompressed/unfiltered row of JPEG-data (JDAT) */ - - mng_fptr fStorerow3; /* internal callback to store an - uncompressed/unfiltered row of JPEG-data (JDAA) */ - - 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 */ - -#ifndef MNG_USE_ZLIB_CRC - mng_uint32 aCRCtable [256]; /* CRC prefab table */ - mng_bool bCRCcomputed; /* "has been built" indicator */ -#endif - -#ifdef MNG_OPTIMIZE_FOOTPRINT_INIT - png_imgtype ePng_imgtype; -#endif - -#if defined(MNG_NO_1_2_4BIT_SUPPORT) || defined(MNG_NO_16BIT_SUPPORT) - mng_uint8 iPNGdepth; /* Real input depth */ - mng_uint8 iPNGmult; -#endif - -#ifdef MNG_OPTIMIZE_DISPLAYCALLS - mng_uint32 iRawlen; /* temp vars for display processing */ - mng_uint8p pRawdata; -#ifndef MNG_SKIPCHUNK_BASI - mng_uint16 iBASIred; - mng_uint16 iBASIgreen; - mng_uint16 iBASIblue; - mng_bool bBASIhasalpha; - mng_uint16 iBASIalpha; - mng_uint8 iBASIviewable; -#endif -#ifndef MNG_SKIPCHUNK_CLON - mng_uint16 iCLONsourceid; - mng_uint16 iCLONcloneid; - mng_uint8 iCLONclonetype; - mng_bool bCLONhasdonotshow; - mng_uint8 iCLONdonotshow; - mng_uint8 iCLONconcrete; - mng_bool bCLONhasloca; - mng_uint8 iCLONlocationtype; - mng_int32 iCLONlocationx; - mng_int32 iCLONlocationy; -#endif -#ifndef MNG_SKIPCHUNK_DISC - mng_uint32 iDISCcount; - mng_uint16p pDISCids; -#endif -#ifndef MNG_SKIPCHUNK_FRAM - mng_uint8 iTempFramemode; - mng_uint8 iTempChangedelay; - mng_uint32 iTempDelay; - mng_uint8 iTempChangetimeout; - mng_uint32 iTempTimeout; - mng_uint8 iTempChangeclipping; - mng_uint8 iTempCliptype; - mng_int32 iTempClipl; - mng_int32 iTempClipr; - mng_int32 iTempClipt; - mng_int32 iTempClipb; -#endif -#ifndef MNG_SKIPCHUNK_MOVE - mng_uint16 iMOVEfromid; - mng_uint16 iMOVEtoid; - mng_uint8 iMOVEmovetype; - mng_int32 iMOVEmovex; - mng_int32 iMOVEmovey; -#endif -#ifndef MNG_SKIPCHUNK_CLIP - mng_uint16 iCLIPfromid; - mng_uint16 iCLIPtoid; - mng_uint8 iCLIPcliptype; - mng_int32 iCLIPclipl; - mng_int32 iCLIPclipr; - mng_int32 iCLIPclipt; - mng_int32 iCLIPclipb; -#endif -#ifndef MNG_NO_DELTA_PNG - mng_uint16 iDHDRobjectid; - mng_uint8 iDHDRimagetype; - mng_uint8 iDHDRdeltatype; - mng_uint32 iDHDRblockwidth; - mng_uint32 iDHDRblockheight; - mng_uint32 iDHDRblockx; - mng_uint32 iDHDRblocky; - mng_uint8 iPROMbitdepth; - mng_uint8 iPROMcolortype; - mng_uint8 iPROMfilltype; - mng_uint8 iPPLTtype; - mng_uint32 iPPLTcount; - mng_palette8ep paPPLTindexentries; - mng_uint8p paPPLTalphaentries; - mng_uint8p paPPLTusedentries; -#endif -#ifndef MNG_SKIPCHUNK_MAGN - mng_uint16 iMAGNfirstid; - mng_uint16 iMAGNlastid; - mng_uint8 iMAGNmethodX; - mng_uint16 iMAGNmX; - mng_uint16 iMAGNmY; - mng_uint16 iMAGNmL; - mng_uint16 iMAGNmR; - mng_uint16 iMAGNmT; - mng_uint16 iMAGNmB; - mng_uint8 iMAGNmethodY; -#endif -#ifndef MNG_SKIPCHUNK_PAST - mng_uint16 iPASTtargetid; - mng_uint8 iPASTtargettype; - mng_int32 iPASTtargetx; - mng_int32 iPASTtargety; - mng_uint32 iPASTcount; - mng_ptr pPASTsources; -#endif -#endif /* MNG_OPTIMIZE_DISPLAYCALLS */ - - } 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); -typedef mng_retcode(*mng_differrow) (mng_datap pData); -typedef mng_retcode(*mng_scalerow) (mng_datap pData); -typedef mng_retcode(*mng_deltarow) (mng_datap pData); -typedef mng_retcode(*mng_promoterow) (mng_datap pData); -typedef mng_retcode(*mng_fliprow) (mng_datap pData); -typedef mng_retcode(*mng_tilerow) (mng_datap pData); - -typedef mng_uint8 (*mng_bitdepth_8) (mng_uint8 iB); -typedef mng_uint16 (*mng_bitdepth_16) (mng_uint8 iB); - -typedef mng_retcode(*mng_magnify_x) (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p iSrcline, - mng_uint8p iDstline); -typedef mng_retcode(*mng_magnify_y) (mng_datap pData, - mng_int32 iM, - mng_int32 iS, - mng_uint32 iWidth, - mng_uint8p iSrcline1, - mng_uint8p iSrcline2, - mng_uint8p iDstline); - -/* ************************************************************************** */ -/* * * */ -/* * 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 * */ -/* ************************************************************************** */ diff --git a/plugins/AdvaImg/src/LibMNG/libmng_display.c b/plugins/AdvaImg/src/LibMNG/libmng_display.c deleted file mode 100644 index 65a5c31d95..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_display.c +++ /dev/null @@ -1,7135 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_display.c copyright (c) 2000-2007 G.Juyn * */ -/* * version : 1.0.10 * */ -/* * * */ -/* * purpose : Display management (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * comment : implementation of the display management routines * */ -/* * * */ -/* * 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 * */ -/* * - fixed frame_delay misalignment * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - added sanity check for frozen status * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * 0.5.1 - 05/13/2000 - G.Juyn * */ -/* * - changed display_mend to reset state to initial or SAVE * */ -/* * - added eMNGma hack (will be removed in 1.0.0 !!!) * */ -/* * - added TERM animation object pointer (easier reference) * */ -/* * - added process_save & process_seek routines * */ -/* * 0.5.1 - 05/14/2000 - G.Juyn * */ -/* * - added save_state and restore_state for SAVE/SEEK/TERM * */ -/* * processing * */ -/* * * */ -/* * 0.5.2 - 05/20/2000 - G.Juyn * */ -/* * - added JNG support (JHDR/JDAT) * */ -/* * 0.5.2 - 05/23/2000 - G.Juyn * */ -/* * - fixed problem with DEFI clipping * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added delta-image support (DHDR,PROM,IPNG,IJNG) * */ -/* * 0.5.2 - 05/31/2000 - G.Juyn * */ -/* * - fixed pointer confusion (contributed by Tim Rowley) * */ -/* * 0.5.2 - 06/03/2000 - G.Juyn * */ -/* * - fixed makeup for Linux gcc compile * */ -/* * 0.5.2 - 06/05/2000 - G.Juyn * */ -/* * - added support for RGB8_A8 canvasstyle * */ -/* * 0.5.2 - 06/09/2000 - G.Juyn * */ -/* * - fixed timer-handling to run with Mozilla (Tim Rowley) * */ -/* * 0.5.2 - 06/10/2000 - G.Juyn * */ -/* * - fixed some compilation-warnings (contrib Jason Morris) * */ -/* * * */ -/* * 0.5.3 - 06/12/2000 - G.Juyn * */ -/* * - fixed display of stored JNG images * */ -/* * 0.5.3 - 06/13/2000 - G.Juyn * */ -/* * - fixed problem with BASI-IEND as object 0 * */ -/* * 0.5.3 - 06/16/2000 - G.Juyn * */ -/* * - changed progressive-display processing * */ -/* * 0.5.3 - 06/17/2000 - G.Juyn * */ -/* * - changed delta-image processing * */ -/* * 0.5.3 - 06/20/2000 - G.Juyn * */ -/* * - fixed some minor stuff * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added speed-modifier to timing routine * */ -/* * 0.5.3 - 06/22/2000 - G.Juyn * */ -/* * - added support for PPLT chunk processing * */ -/* * 0.5.3 - 06/29/2000 - G.Juyn * */ -/* * - swapped refresh parameters * */ -/* * * */ -/* * 0.9.0 - 06/30/2000 - G.Juyn * */ -/* * - changed refresh parameters to 'x,y,width,height' * */ -/* * * */ -/* * 0.9.1 - 07/07/2000 - G.Juyn * */ -/* * - implemented support for freeze/reset/resume & go_xxxx * */ -/* * 0.9.1 - 07/08/2000 - G.Juyn * */ -/* * - added support for improved timing * */ -/* * 0.9.1 - 07/14/2000 - G.Juyn * */ -/* * - changed EOF processing behavior * */ -/* * - fixed TERM delay processing * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - fixed freeze & reset processing * */ -/* * 0.9.1 - 07/16/2000 - G.Juyn * */ -/* * - fixed storage of images during mng_read() * */ -/* * - fixed support for mng_display() after mng_read() * */ -/* * 0.9.1 - 07/24/2000 - G.Juyn * */ -/* * - fixed reading of still-images * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/07/2000 - G.Juyn * */ -/* * - B111300 - fixup for improved portability * */ -/* * 0.9.3 - 08/21/2000 - G.Juyn * */ -/* * - fixed TERM processing delay of 0 msecs * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/10/2000 - G.Juyn * */ -/* * - fixed problem with no refresh after TERM * */ -/* * - fixed DEFI behavior * */ -/* * 0.9.3 - 09/16/2000 - G.Juyn * */ -/* * - fixed timing & refresh behavior for single PNG/JNG * */ -/* * 0.9.3 - 09/19/2000 - G.Juyn * */ -/* * - refixed timing & refresh behavior for single PNG/JNG * */ -/* * 0.9.3 - 10/02/2000 - G.Juyn * */ -/* * - fixed timing again (this is getting boring...) * */ -/* * - refixed problem with no refresh after TERM * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added JDAA chunk * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - fixed support for bKGD * */ -/* * 0.9.3 - 10/18/2000 - G.Juyn * */ -/* * - fixed delta-processing behavior * */ -/* * 0.9.3 - 10/19/2000 - G.Juyn * */ -/* * - added storage for pixel-/alpha-sampledepth for delta's * */ -/* * 0.9.3 - 10/27/2000 - G.Juyn * */ -/* * - fixed separate read() & display() processing * */ -/* * * */ -/* * 0.9.4 - 10/31/2000 - G.Juyn * */ -/* * - fixed possible loop in display_resume() (Thanks Vova!) * */ -/* * 0.9.4 - 11/20/2000 - G.Juyn * */ -/* * - fixed unwanted repetition in mng_readdisplay() * */ -/* * 0.9.4 - 11/24/2000 - G.Juyn * */ -/* * - moved restore of object 0 to libmng_display * */ -/* * - added restore of object 0 to TERM processing !!! * */ -/* * - fixed TERM delay processing * */ -/* * - fixed TERM end processing (count = 0) * */ -/* * 0.9.4 - 12/16/2000 - G.Juyn * */ -/* * - fixed mixup of data- & function-pointers (thanks Dimitri)* */ -/* * 0.9.4 - 1/18/2001 - G.Juyn * */ -/* * - removed test filter-methods 1 & 65 * */ -/* * - set default level-set for filtertype=64 to all zeroes * */ -/* * * */ -/* * 0.9.5 - 1/20/2001 - G.Juyn * */ -/* * - fixed compiler-warnings Mozilla (thanks Tim) * */ -/* * 0.9.5 - 1/23/2001 - G.Juyn * */ -/* * - fixed timing-problem with switching framing_modes * */ -/* * * */ -/* * 1.0.1 - 02/08/2001 - G.Juyn * */ -/* * - added MEND processing callback * */ -/* * 1.0.1 - 02/13/2001 - G.Juyn * */ -/* * - fixed first FRAM_MODE=4 timing problem * */ -/* * 1.0.1 - 04/21/2001 - G.Juyn * */ -/* * - fixed memory-leak for JNGs with alpha (Thanks Gregg!) * */ -/* * - added BGRA8 canvas with premultiplied alpha * */ -/* * * */ -/* * 1.0.2 - 06/25/2001 - G.Juyn * */ -/* * - fixed memory-leak with delta-images (Thanks Michael!) * */ -/* * * */ -/* * 1.0.5 - 08/15/2002 - G.Juyn * */ -/* * - completed PROM support * */ -/* * - completed delta-image support * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * 1.0.5 - 09/13/2002 - G.Juyn * */ -/* * - fixed read/write of MAGN chunk * */ -/* * 1.0.5 - 09/15/2002 - G.Juyn * */ -/* * - fixed LOOP iteration=0 special case * */ -/* * 1.0.5 - 09/19/2002 - G.Juyn * */ -/* * - fixed color-correction for restore-background handling * */ -/* * - optimized restore-background for bKGD cases * */ -/* * - cleaned up some old stuff * */ -/* * 1.0.5 - 09/20/2002 - G.Juyn * */ -/* * - finished support for BACK image & tiling * */ -/* * - added support for PAST * */ -/* * 1.0.5 - 09/22/2002 - G.Juyn * */ -/* * - added bgrx8 canvas (filler byte) * */ -/* * 1.0.5 - 10/05/2002 - G.Juyn * */ -/* * - fixed dropping mix of frozen/unfrozen objects * */ -/* * 1.0.5 - 10/07/2002 - G.Juyn * */ -/* * - added proposed change in handling of TERM- & if-delay * */ -/* * - added another fix for misplaced TERM chunk * */ -/* * - completed support for condition=2 in TERM chunk * */ -/* * 1.0.5 - 10/18/2002 - G.Juyn * */ -/* * - fixed clipping-problem with BACK tiling (Thanks Sakura!) * */ -/* * 1.0.5 - 10/20/2002 - G.Juyn * */ -/* * - fixed processing for multiple objects in MAGN * */ -/* * - fixed display of visible target of PAST operation * */ -/* * 1.0.5 - 10/30/2002 - G.Juyn * */ -/* * - modified TERM/MEND processing for max(1, TERM_delay, * */ -/* * interframe_delay) * */ -/* * 1.0.5 - 11/04/2002 - G.Juyn * */ -/* * - fixed layer- & frame-counting during read() * */ -/* * - fixed goframe/golayer/gotime processing * */ -/* * 1.0.5 - 01/19/2003 - G.Juyn * */ -/* * - B654627 - fixed SEGV when no gettickcount callback * */ -/* * - B664383 - fixed typo * */ -/* * - finalized changes in TERM/final_delay to elected proposal* */ -/* * * */ -/* * 1.0.6 - 05/11/2003 - G. Juyn * */ -/* * - added conditionals around canvas update routines * */ -/* * 1.0.6 - 05/25/2003 - G.R-P * */ -/* * - added MNG_SKIPCHUNK_cHNK footprint optimizations * */ -/* * 1.0.6 - 07/07/2003 - G.R-P * */ -/* * - added conditionals around some JNG-supporting code * */ -/* * - added conditionals around 16-bit supporting code * */ -/* * - reversed some loops to use decrementing counter * */ -/* * - combined init functions into one function * */ -/* * 1.0.6 - 07/10/2003 - G.R-P * */ -/* * - replaced nested switches with simple init setup function * */ -/* * 1.0.6 - 07/29/2003 - G.R-P * */ -/* * - added conditionals around PAST chunk support * */ -/* * 1.0.6 - 08/17/2003 - G.R-P * */ -/* * - added conditionals around non-VLC chunk support * */ -/* * * */ -/* * 1.0.7 - 11/27/2003 - R.A * */ -/* * - added CANVAS_RGB565 and CANVAS_BGR565 * */ -/* * 1.0.7 - 12/06/2003 - R.A * */ -/* * - added CANVAS_RGBA565 and CANVAS_BGRA565 * */ -/* * 1.0.7 - 01/25/2004 - J.S * */ -/* * - added premultiplied alpha canvas' for RGBA, ARGB, ABGR * */ -/* * * */ -/* * 1.0.8 - 03/31/2004 - G.Juyn * */ -/* * - fixed problem with PAST usage where source > dest * */ -/* * 1.0.8 - 05/04/2004 - G.R-P. * */ -/* * - fixed misplaced 16-bit conditionals * */ -/* * * */ -/* * 1.0.9 - 09/18/2004 - G.R-P. * */ -/* * - revised some SKIPCHUNK conditionals * */ -/* * 1.0.9 - 10/10/2004 - G.R-P. * */ -/* * - added MNG_NO_1_2_4BIT_SUPPORT * */ -/* * 1.0.9 - 10/14/2004 - G.Juyn * */ -/* * - added bgr565_a8 canvas-style (thanks to J. Elvander) * */ -/* * 1.0.9 - 12/11/2004 - G.Juyn * */ -/* * - added conditional MNG_OPTIMIZE_DISPLAYCALLS * */ -/* * 1.0.9 - 12/20/2004 - G.Juyn * */ -/* * - cleaned up macro-invocations (thanks to D. Airlie) * */ -/* * * */ -/* * 1.0.10 - 07/06/2005 - G.R-P. * */ -/* * - added more SKIPCHUNK conditionals * */ -/* * 1.0.10 - 12/28/2005 - G.R-P. * */ -/* * - added missing SKIPCHUNK_MAGN conditional * */ -/* * 1.0.10 - 03/07/2006 - (thanks to W. Manthey) * */ -/* * - added CANVAS_RGB555 and CANVAS_BGR555 * */ -/* * 1.0.10 - 04/08/2007 - G.Juyn * */ -/* * - fixed several compiler warnings * */ -/* * 1.0.10 - 04/08/2007 - G.Juyn * */ -/* * - added support for mPNG proposal * */ -/* * 1.0.10 - 04/12/2007 - G.Juyn * */ -/* * - added support for ANG proposal * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_chunks.h" -#include "libmng_objects.h" -#include "libmng_object_prc.h" -#include "libmng_memory.h" -#include "libmng_zlib.h" -#include "libmng_jpeg.h" -#include "libmng_cms.h" -#include "libmng_pixels.h" -#include "libmng_display.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_DISPLAY_PROCS - -/* ************************************************************************** */ - -MNG_LOCAL mng_retcode set_delay (mng_datap pData, - mng_uint32 iInterval) -{ - if (!iInterval) /* at least 1 msec please! */ - iInterval = 1; - - if (pData->bRunning) /* only when really displaying */ - if (!pData->fSettimer ((mng_handle)pData, iInterval)) - MNG_ERROR (pData, MNG_APPTIMERERROR); - -#ifdef MNG_SUPPORT_DYNAMICMNG - if ((!pData->bDynamic) || (pData->bRunning)) -#else - if (pData->bRunning) -#endif - pData->bTimerset = MNG_TRUE; /* and indicate so */ - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -MNG_LOCAL mng_uint32 calculate_delay (mng_datap pData, - mng_uint32 iDelay) -{ - mng_uint32 iTicks = pData->iTicks; - mng_uint32 iWaitfor = 1; /* default non-MNG delay */ - - if (!iTicks) /* tick_count not specified ? */ - if (pData->eImagetype == mng_it_mng) - iTicks = 1000; - - if (iTicks) - { - switch (pData->iSpeed) /* honor speed modifier */ - { - case mng_st_fast : - { - iWaitfor = (mng_uint32)(( 500 * iDelay) / iTicks); - break; - } - case mng_st_slow : - { - iWaitfor = (mng_uint32)((3000 * iDelay) / iTicks); - break; - } - case mng_st_slowest : - { - iWaitfor = (mng_uint32)((8000 * iDelay) / iTicks); - break; - } - default : - { - iWaitfor = (mng_uint32)((1000 * iDelay) / iTicks); - } - } - } - - return iWaitfor; -} - -/* ************************************************************************** */ -/* * * */ -/* * Progressive display refresh - does the call to the refresh callback * */ -/* * and sets the timer to allow the app to perform the actual refresh to * */ -/* * the screen (eg. process its main message-loop) * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode mng_display_progressive_refresh (mng_datap pData, - mng_uint32 iInterval) -{ - { /* let the app refresh first ? */ - if ((pData->bRunning) && (!pData->bSkipping) && - (pData->iUpdatetop < pData->iUpdatebottom) && (pData->iUpdateleft < pData->iUpdateright)) - { - if (!pData->fRefresh (((mng_handle)pData), - pData->iUpdateleft, pData->iUpdatetop, - pData->iUpdateright - pData->iUpdateleft, - pData->iUpdatebottom - pData->iUpdatetop)) - MNG_ERROR (pData, MNG_APPMISCERROR); - - pData->iUpdateleft = 0; /* reset update-region */ - pData->iUpdateright = 0; - pData->iUpdatetop = 0; - pData->iUpdatebottom = 0; /* reset refreshneeded indicator */ - pData->bNeedrefresh = MNG_FALSE; - /* interval requested ? */ - if ((!pData->bFreezing) && (iInterval)) - { /* setup the timer */ - mng_retcode iRetcode = set_delay (pData, iInterval); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - } - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Generic display routines * */ -/* * * */ -/* ************************************************************************** */ - -MNG_LOCAL mng_retcode interframe_delay (mng_datap pData) -{ - mng_uint32 iWaitfor = 0; - mng_uint32 iInterval; - mng_uint32 iRuninterval; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INTERFRAME_DELAY, MNG_LC_START); -#endif - - { -#ifndef MNG_SKIPCHUNK_FRAM - if (pData->iFramedelay > 0) /* real delay ? */ - { /* let the app refresh first ? */ - if ((pData->bRunning) && (!pData->bSkipping) && - (pData->iUpdatetop < pData->iUpdatebottom) && (pData->iUpdateleft < pData->iUpdateright)) - if (!pData->fRefresh (((mng_handle)pData), - pData->iUpdateleft, pData->iUpdatetop, - pData->iUpdateright - pData->iUpdateleft, - pData->iUpdatebottom - pData->iUpdatetop)) - MNG_ERROR (pData, MNG_APPMISCERROR); - - pData->iUpdateleft = 0; /* reset update-region */ - pData->iUpdateright = 0; - pData->iUpdatetop = 0; - pData->iUpdatebottom = 0; /* reset refreshneeded indicator */ - pData->bNeedrefresh = MNG_FALSE; - -#ifndef MNG_SKIPCHUNK_TERM - if (pData->bOnlyfirstframe) /* only processing first frame after TERM ? */ - { - pData->iFramesafterTERM++; - /* did we do a frame yet ? */ - if (pData->iFramesafterTERM > 1) - { /* then that's it; just stop right here ! */ - pData->pCurraniobj = MNG_NULL; - pData->bRunning = MNG_FALSE; - - return MNG_NOERROR; - } - } -#endif - - if (pData->fGettickcount) - { /* get current tickcount */ - pData->iRuntime = pData->fGettickcount ((mng_handle)pData); - /* calculate interval since last sync-point */ - if (pData->iRuntime < pData->iSynctime) - iRuninterval = pData->iRuntime + ~pData->iSynctime + 1; - else - iRuninterval = pData->iRuntime - pData->iSynctime; - /* calculate actual run-time */ - if (pData->iRuntime < pData->iStarttime) - pData->iRuntime = pData->iRuntime + ~pData->iStarttime + 1; - else - pData->iRuntime = pData->iRuntime - pData->iStarttime; - } - else - { - iRuninterval = 0; - } - - iWaitfor = calculate_delay (pData, pData->iFramedelay); - - if (iWaitfor > iRuninterval) /* delay necessary ? */ - iInterval = iWaitfor - iRuninterval; - else - iInterval = 1; /* force app to process messageloop */ - /* set the timer ? */ - if (((pData->bRunning) || (pData->bSearching) || (pData->bReading)) && - (!pData->bSkipping)) - { - iRetcode = set_delay (pData, iInterval); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - - if (!pData->bSkipping) /* increase frametime in advance */ - pData->iFrametime = pData->iFrametime + iWaitfor; - /* setup for next delay */ - pData->iFramedelay = pData->iNextdelay; -#endif - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INTERFRAME_DELAY, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -MNG_LOCAL void set_display_routine (mng_datap pData) -{ /* actively running ? */ - if (((pData->bRunning) || (pData->bSearching)) && (!pData->bSkipping)) - { - switch (pData->iCanvasstyle) /* determine display routine */ - { -#ifndef MNG_SKIPCANVAS_RGB8 - case MNG_CANVAS_RGB8 : { pData->fDisplayrow = (mng_fptr)mng_display_rgb8; break; } -#endif -#ifndef MNG_SKIPCANVAS_RGBA8 - case MNG_CANVAS_RGBA8 : { pData->fDisplayrow = (mng_fptr)mng_display_rgba8; break; } -#endif -#ifndef MNG_SKIPCANVAS_RGBA8_PM - case MNG_CANVAS_RGBA8_PM: { pData->fDisplayrow = (mng_fptr)mng_display_rgba8_pm; break; } -#endif -#ifndef MNG_SKIPCANVAS_ARGB8 - case MNG_CANVAS_ARGB8 : { pData->fDisplayrow = (mng_fptr)mng_display_argb8; break; } -#endif -#ifndef MNG_SKIPCANVAS_ARGB8_PM - case MNG_CANVAS_ARGB8_PM: { pData->fDisplayrow = (mng_fptr)mng_display_argb8_pm; break; } -#endif -#ifndef MNG_SKIPCANVAS_RGB8_A8 - case MNG_CANVAS_RGB8_A8 : { pData->fDisplayrow = (mng_fptr)mng_display_rgb8_a8; break; } -#endif -#ifndef MNG_SKIPCANVAS_BGR8 - case MNG_CANVAS_BGR8 : { pData->fDisplayrow = (mng_fptr)mng_display_bgr8; break; } -#endif -#ifndef MNG_SKIPCANVAS_BGRX8 - case MNG_CANVAS_BGRX8 : { pData->fDisplayrow = (mng_fptr)mng_display_bgrx8; break; } -#endif -#ifndef MNG_SKIPCANVAS_BGRA8 - case MNG_CANVAS_BGRA8 : { pData->fDisplayrow = (mng_fptr)mng_display_bgra8; break; } -#endif -#ifndef MNG_SKIPCANVAS_BGRA8_PM - case MNG_CANVAS_BGRA8_PM: { pData->fDisplayrow = (mng_fptr)mng_display_bgra8_pm; break; } -#endif -#ifndef MNG_SKIPCANVAS_ABGR8 - case MNG_CANVAS_ABGR8 : { pData->fDisplayrow = (mng_fptr)mng_display_abgr8; break; } -#endif -#ifndef MNG_SKIPCANVAS_ABGR8_PM - case MNG_CANVAS_ABGR8_PM: { pData->fDisplayrow = (mng_fptr)mng_display_abgr8_pm; break; } -#endif -#ifndef MNG_SKIPCANVAS_RGB565 - case MNG_CANVAS_RGB565 : { pData->fDisplayrow = (mng_fptr)mng_display_rgb565; break; } -#endif -#ifndef MNG_SKIPCANVAS_RGBA565 - case MNG_CANVAS_RGBA565 : { pData->fDisplayrow = (mng_fptr)mng_display_rgba565; break; } -#endif -#ifndef MNG_SKIPCANVAS_BGR565 - case MNG_CANVAS_BGR565 : { pData->fDisplayrow = (mng_fptr)mng_display_bgr565; break; } -#endif -#ifndef MNG_SKIPCANVAS_BGRA565 - case MNG_CANVAS_BGRA565 : { pData->fDisplayrow = (mng_fptr)mng_display_bgra565; break; } -#endif -#ifndef MNG_SKIPCANVAS_BGR565_A8 - case MNG_CANVAS_BGR565_A8 : { pData->fDisplayrow = (mng_fptr)mng_display_bgr565_a8; break; } -#endif -#ifndef MNG_SKIPCANVAS_RGB555 - case MNG_CANVAS_RGB555 : { pData->fDisplayrow = (mng_fptr)mng_display_rgb555; break; } -#endif -#ifndef MNG_SKIPCANVAS_BGR555 - case MNG_CANVAS_BGR555 : { pData->fDisplayrow = (mng_fptr)mng_display_bgr555; break; } -#endif - -#ifndef MNG_NO_16BIT_SUPPORT -/* case MNG_CANVAS_RGB16 : { pData->fDisplayrow = (mng_fptr)mng_display_rgb16; break; } */ -/* case MNG_CANVAS_RGBA16 : { pData->fDisplayrow = (mng_fptr)mng_display_rgba16; break; } */ -/* case MNG_CANVAS_ARGB16 : { pData->fDisplayrow = (mng_fptr)mng_display_argb16; break; } */ -/* case MNG_CANVAS_BGR16 : { pData->fDisplayrow = (mng_fptr)mng_display_bgr16; break; } */ -/* case MNG_CANVAS_BGRA16 : { pData->fDisplayrow = (mng_fptr)mng_display_bgra16; break; } */ -/* case MNG_CANVAS_ABGR16 : { pData->fDisplayrow = (mng_fptr)mng_display_abgr16; break; } */ -#endif -/* case MNG_CANVAS_INDEX8 : { pData->fDisplayrow = (mng_fptr)mng_display_index8; break; } */ -/* case MNG_CANVAS_INDEXA8 : { pData->fDisplayrow = (mng_fptr)mng_display_indexa8; break; } */ -/* case MNG_CANVAS_AINDEX8 : { pData->fDisplayrow = (mng_fptr)mng_display_aindex8; break; } */ -/* case MNG_CANVAS_GRAY8 : { pData->fDisplayrow = (mng_fptr)mng_display_gray8; break; } */ -/* case MNG_CANVAS_AGRAY8 : { pData->fDisplayrow = (mng_fptr)mng_display_agray8; break; } */ -/* case MNG_CANVAS_GRAYA8 : { pData->fDisplayrow = (mng_fptr)mng_display_graya8; break; } */ -#ifndef MNG_NO_16BIT_SUPPORT -/* case MNG_CANVAS_GRAY16 : { pData->fDisplayrow = (mng_fptr)mng_display_gray16; break; } */ -/* case MNG_CANVAS_GRAYA16 : { pData->fDisplayrow = (mng_fptr)mng_display_graya16; break; } */ -/* case MNG_CANVAS_AGRAY16 : { pData->fDisplayrow = (mng_fptr)mng_display_agray16; break; } */ -#endif -/* case MNG_CANVAS_DX15 : { pData->fDisplayrow = (mng_fptr)mng_display_dx15; break; } */ -/* case MNG_CANVAS_DX16 : { pData->fDisplayrow = (mng_fptr)mng_display_dx16; break; } */ - } - } - - return; -} - -/* ************************************************************************** */ - -MNG_LOCAL mng_retcode load_bkgdlayer (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_LOAD_BKGDLAYER, MNG_LC_START); -#endif - /* actively running ? */ - if (((pData->bRunning) || (pData->bSearching)) && (!pData->bSkipping)) - { - mng_int32 iY; - mng_retcode iRetcode; - mng_bool bColorcorr = MNG_FALSE; - /* save values */ - mng_int32 iDestl = pData->iDestl; - mng_int32 iDestr = pData->iDestr; - mng_int32 iDestt = pData->iDestt; - mng_int32 iDestb = pData->iDestb; - mng_int32 iSourcel = pData->iSourcel; - mng_int32 iSourcer = pData->iSourcer; - mng_int32 iSourcet = pData->iSourcet; - mng_int32 iSourceb = pData->iSourceb; - mng_int8 iPass = pData->iPass; - mng_int32 iRow = pData->iRow; - mng_int32 iRowinc = pData->iRowinc; - mng_int32 iCol = pData->iCol; - mng_int32 iColinc = pData->iColinc; - mng_int32 iRowsamples = pData->iRowsamples; - mng_int32 iRowsize = pData->iRowsize; - mng_uint8p pPrevrow = pData->pPrevrow; - mng_uint8p pRGBArow = pData->pRGBArow; - mng_bool bIsRGBA16 = pData->bIsRGBA16; - mng_bool bIsOpaque = pData->bIsOpaque; - mng_fptr fCorrectrow = pData->fCorrectrow; - mng_fptr fDisplayrow = pData->fDisplayrow; - mng_fptr fRetrieverow = pData->fRetrieverow; - mng_objectp pCurrentobj = pData->pCurrentobj; - mng_objectp pRetrieveobj = pData->pRetrieveobj; - - pData->iDestl = 0; /* determine clipping region */ - pData->iDestt = 0; - pData->iDestr = pData->iWidth; - pData->iDestb = pData->iHeight; - -#ifndef MNG_SKIPCHUNK_FRAM - if (pData->bFrameclipping) /* frame clipping specified ? */ - { - pData->iDestl = MAX_COORD (pData->iDestl, pData->iFrameclipl); - pData->iDestt = MAX_COORD (pData->iDestt, pData->iFrameclipt); - pData->iDestr = MIN_COORD (pData->iDestr, pData->iFrameclipr); - pData->iDestb = MIN_COORD (pData->iDestb, pData->iFrameclipb); - } -#endif - /* anything to clear ? */ - if ((pData->iDestr >= pData->iDestl) && (pData->iDestb >= pData->iDestt)) - { - pData->iPass = -1; /* these are the object's dimensions now */ - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iWidth; - pData->iRowsize = pData->iRowsamples << 2; - pData->bIsRGBA16 = MNG_FALSE; /* let's keep it simple ! */ - pData->bIsOpaque = MNG_TRUE; - - pData->iSourcel = 0; /* source relative to destination */ - pData->iSourcer = pData->iDestr - pData->iDestl; - pData->iSourcet = 0; - pData->iSourceb = pData->iDestb - pData->iDestt; - - set_display_routine (pData); /* determine display routine */ - /* default restore using preset BG color */ - pData->fRestbkgdrow = (mng_fptr)mng_restore_bkgd_bgcolor; - -#ifndef MNG_SKIPCHUNK_bKGD - if (((pData->eImagetype == mng_it_png) || (pData->eImagetype == mng_it_jng)) && - (pData->bUseBKGD)) - { /* prefer bKGD in PNG/JNG */ - if (!pData->pCurrentobj) - pData->pCurrentobj = pData->pObjzero; - - if (((mng_imagep)pData->pCurrentobj)->pImgbuf->bHasBKGD) - { - pData->fRestbkgdrow = (mng_fptr)mng_restore_bkgd_bkgd; - bColorcorr = MNG_TRUE; - } - } -#endif - - if (pData->fGetbkgdline) /* background-canvas-access callback set ? */ - { - switch (pData->iBkgdstyle) - { -#ifndef MNG_SKIPCANVAS_RGB8 - case MNG_CANVAS_RGB8 : { pData->fRestbkgdrow = (mng_fptr)mng_restore_bkgd_rgb8; break; } -#endif -#ifndef MNG_SKIPCANVAS_BGR8 - case MNG_CANVAS_BGR8 : { pData->fRestbkgdrow = (mng_fptr)mng_restore_bkgd_bgr8; break; } -#endif -#ifndef MNG_SKIPCANVAS_BGRX8 - case MNG_CANVAS_BGRX8 : { pData->fRestbkgdrow = (mng_fptr)mng_restore_bkgd_bgrx8; break; } -#endif -#ifndef MNG_SKIPCANVAS_BGR565 - case MNG_CANVAS_BGR565 : { pData->fRestbkgdrow = (mng_fptr)mng_restore_bkgd_bgr565; break; } -#endif -#ifndef MNG_SKIPCANVAS_RGB565 - case MNG_CANVAS_RGB565 : { pData->fRestbkgdrow = (mng_fptr)mng_restore_bkgd_rgb565; break; } -#endif -#ifndef MNG_NO_16BIT_SUPPORT - /* case MNG_CANVAS_RGB16 : { pData->fRestbkgdrow = (mng_fptr)mng_restore_bkgd_rgb16; break; } */ - /* case MNG_CANVAS_BGR16 : { pData->fRestbkgdrow = (mng_fptr)mng_restore_bkgd_bgr16; break; } */ -#endif - /* case MNG_CANVAS_INDEX8 : { pData->fRestbkgdrow = (mng_fptr)mng_restore_bkgd_index8; break; } */ - /* case MNG_CANVAS_GRAY8 : { pData->fRestbkgdrow = (mng_fptr)mng_restore_bkgd_gray8; break; } */ -#ifndef MNG_NO_16BIT_SUPPORT - /* case MNG_CANVAS_GRAY16 : { pData->fRestbkgdrow = (mng_fptr)mng_restore_bkgd_gray16; break; } */ -#endif - /* case MNG_CANVAS_DX15 : { pData->fRestbkgdrow = (mng_fptr)mng_restore_bkgd_dx15; break; } */ - /* case MNG_CANVAS_DX16 : { pData->fRestbkgdrow = (mng_fptr)mng_restore_bkgd_dx16; break; } */ - } - } - -#ifndef MNG_SKIPCHUNK_BACK - if (pData->bHasBACK) - { /* background image ? */ - if ((pData->iBACKmandatory & 0x02) && (pData->iBACKimageid)) - { - pData->fRestbkgdrow = (mng_fptr)mng_restore_bkgd_backcolor; - bColorcorr = MNG_TRUE; - } - else /* background color ? */ - if (pData->iBACKmandatory & 0x01) - { - pData->fRestbkgdrow = (mng_fptr)mng_restore_bkgd_backcolor; - bColorcorr = MNG_TRUE; - } - } -#endif - - pData->fCorrectrow = MNG_NULL; /* default no color-correction */ - - if (bColorcorr) /* do we have to do color-correction ? */ - { -#ifdef MNG_NO_CMS - iRetcode = MNG_NOERROR; -#else -#if defined(MNG_FULL_CMS) /* determine color-management routine */ - iRetcode = mng_init_full_cms (pData, MNG_TRUE, MNG_FALSE, MNG_FALSE); -#elif defined(MNG_GAMMA_ONLY) - iRetcode = mng_init_gamma_only (pData, MNG_TRUE, MNG_FALSE, MNG_FALSE); -#elif defined(MNG_APP_CMS) - iRetcode = mng_init_app_cms (pData, MNG_TRUE, MNG_FALSE, MNG_FALSE); -#endif - if (iRetcode) /* on error bail out */ - return iRetcode; -#endif /* MNG_NO_CMS */ - } - /* get a temporary row-buffer */ - MNG_ALLOC (pData, pData->pRGBArow, pData->iRowsize); - - iY = pData->iDestt; /* this is where we start */ - iRetcode = MNG_NOERROR; /* so far, so good */ - - while ((!iRetcode) && (iY < pData->iDestb)) - { /* restore a background row */ - iRetcode = ((mng_restbkgdrow)pData->fRestbkgdrow) (pData); - /* color correction ? */ - if ((!iRetcode) && (pData->fCorrectrow)) - iRetcode = ((mng_correctrow)pData->fCorrectrow) (pData); - - if (!iRetcode) /* so... display it */ - iRetcode = ((mng_displayrow)pData->fDisplayrow) (pData); - - if (!iRetcode) - iRetcode = mng_next_row (pData); - - iY++; /* and next line */ - } - /* drop the temporary row-buffer */ - MNG_FREE (pData, pData->pRGBArow, pData->iRowsize); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#if defined(MNG_FULL_CMS) /* cleanup cms stuff */ - if (bColorcorr) /* did we do color-correction ? */ - { - iRetcode = mng_clear_cms (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif -#ifndef MNG_SKIPCHUNK_BACK - /* background image ? */ - if ((pData->bHasBACK) && (pData->iBACKmandatory & 0x02) && (pData->iBACKimageid)) - { - mng_imagep pImage; - /* let's find that object then */ - pData->pRetrieveobj = mng_find_imageobject (pData, pData->iBACKimageid); - pImage = (mng_imagep)pData->pRetrieveobj; - /* exists, viewable and visible ? */ - if ((pImage) && (pImage->bViewable) && (pImage->bVisible)) - { /* will it fall within the target region ? */ - if ((pImage->iPosx < pData->iDestr) && (pImage->iPosy < pData->iDestb) && - ((pData->iBACKtile) || - ((pImage->iPosx + (mng_int32)pImage->pImgbuf->iWidth >= pData->iDestl) && - (pImage->iPosy + (mng_int32)pImage->pImgbuf->iHeight >= pData->iDestt) )) && - ((!pImage->bClipped) || - ((pImage->iClipl <= pImage->iClipr) && (pImage->iClipt <= pImage->iClipb) && - (pImage->iClipl < pData->iDestr) && (pImage->iClipr >= pData->iDestl) && - (pImage->iClipt < pData->iDestb) && (pImage->iClipb >= pData->iDestt) ))) - { /* right; we've got ourselves something to do */ - if (pImage->bClipped) /* clip output region with image's clipping region ? */ - { - if (pImage->iClipl > pData->iDestl) - pData->iDestl = pImage->iClipl; - if (pImage->iClipr < pData->iDestr) - pData->iDestr = pImage->iClipr; - if (pImage->iClipt > pData->iDestt) - pData->iDestt = pImage->iClipt; - if (pImage->iClipb < pData->iDestb) - pData->iDestb = pImage->iClipb; - } - /* image offset does some extra clipping too ! */ - if (pImage->iPosx > pData->iDestl) - pData->iDestl = pImage->iPosx; - if (pImage->iPosy > pData->iDestt) - pData->iDestt = pImage->iPosy; - - if (!pData->iBACKtile) /* without tiling further clipping is needed */ - { - if (pImage->iPosx + (mng_int32)pImage->pImgbuf->iWidth < pData->iDestr) - pData->iDestr = pImage->iPosx + (mng_int32)pImage->pImgbuf->iWidth; - if (pImage->iPosy + (mng_int32)pImage->pImgbuf->iHeight < pData->iDestb) - pData->iDestb = pImage->iPosy + (mng_int32)pImage->pImgbuf->iHeight; - } - - pData->iSourcel = 0; /* source relative to destination */ - pData->iSourcer = pData->iDestr - pData->iDestl; - pData->iSourcet = 0; - pData->iSourceb = pData->iDestb - pData->iDestt; - /* 16-bit background ? */ - -#ifdef MNG_NO_16BIT_SUPPORT - pData->bIsRGBA16 = MNG_FALSE; -#else - pData->bIsRGBA16 = (mng_bool)(pImage->pImgbuf->iBitdepth > 8); -#endif - /* let restore routine know the offsets !!! */ - pData->iBackimgoffsx = pImage->iPosx; - pData->iBackimgoffsy = pImage->iPosy; - pData->iBackimgwidth = pImage->pImgbuf->iWidth; - pData->iBackimgheight = pImage->pImgbuf->iHeight; - pData->iRow = 0; /* start at the top again !! */ - /* determine background object retrieval routine */ - switch (pImage->pImgbuf->iColortype) - { - case 0 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)mng_retrieve_g16; - else -#endif - pData->fRetrieverow = (mng_fptr)mng_retrieve_g8; - - pData->bIsOpaque = (mng_bool)(!pImage->pImgbuf->bHasTRNS); - break; - } - - case 2 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgb16; - else -#endif - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgb8; - - pData->bIsOpaque = (mng_bool)(!pImage->pImgbuf->bHasTRNS); - break; - } - - case 3 : { pData->fRetrieverow = (mng_fptr)mng_retrieve_idx8; - pData->bIsOpaque = (mng_bool)(!pImage->pImgbuf->bHasTRNS); - break; - } - - case 4 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)mng_retrieve_ga16; - else -#endif - pData->fRetrieverow = (mng_fptr)mng_retrieve_ga8; - - pData->bIsOpaque = MNG_FALSE; - break; - } - - case 6 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgba16; - else -#endif - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgba8; - - pData->bIsOpaque = MNG_FALSE; - break; - } - - case 8 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)mng_retrieve_g16; - else -#endif - pData->fRetrieverow = (mng_fptr)mng_retrieve_g8; - - pData->bIsOpaque = MNG_TRUE; - break; - } - - case 10 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgb16; - else -#endif - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgb8; - - pData->bIsOpaque = MNG_TRUE; - break; - } - - case 12 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)mng_retrieve_ga16; - else -#endif - pData->fRetrieverow = (mng_fptr)mng_retrieve_ga8; - - pData->bIsOpaque = MNG_FALSE; - break; - } - - case 14 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgba16; - else -#endif - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgba8; - - pData->bIsOpaque = MNG_FALSE; - break; - } - } - -#ifdef MNG_NO_CMS - iRetcode = MNG_NOERROR; -#else -#if defined(MNG_FULL_CMS) /* determine color-management routine */ - iRetcode = mng_init_full_cms (pData, MNG_FALSE, MNG_FALSE, MNG_TRUE); -#elif defined(MNG_GAMMA_ONLY) - iRetcode = mng_init_gamma_only (pData, MNG_FALSE, MNG_FALSE, MNG_TRUE); -#elif defined(MNG_APP_CMS) - iRetcode = mng_init_app_cms (pData, MNG_FALSE, MNG_FALSE, MNG_TRUE); -#endif - if (iRetcode) /* on error bail out */ - return iRetcode; -#endif /* MNG_NO_CMS */ - /* get temporary row-buffers */ - MNG_ALLOC (pData, pData->pPrevrow, pData->iRowsize); - MNG_ALLOC (pData, pData->pRGBArow, pData->iRowsize); - - iY = pData->iDestt; /* this is where we start */ - iRetcode = MNG_NOERROR; /* so far, so good */ - - while ((!iRetcode) && (iY < pData->iDestb)) - { /* restore a background row */ - iRetcode = mng_restore_bkgd_backimage (pData); - /* color correction ? */ - if ((!iRetcode) && (pData->fCorrectrow)) - iRetcode = ((mng_correctrow)pData->fCorrectrow) (pData); - - if (!iRetcode) /* so... display it */ - iRetcode = ((mng_displayrow)pData->fDisplayrow) (pData); - - if (!iRetcode) - iRetcode = mng_next_row (pData); - - iY++; /* and next line */ - } - /* drop temporary row-buffers */ - MNG_FREE (pData, pData->pRGBArow, pData->iRowsize); - MNG_FREE (pData, pData->pPrevrow, pData->iRowsize); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#if defined(MNG_FULL_CMS) /* cleanup cms stuff */ - iRetcode = mng_clear_cms (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; -#endif - } - } - } -#endif - } - - pData->iDestl = iDestl; /* restore values */ - pData->iDestr = iDestr; - pData->iDestt = iDestt; - pData->iDestb = iDestb; - pData->iSourcel = iSourcel; - pData->iSourcer = iSourcer; - pData->iSourcet = iSourcet; - pData->iSourceb = iSourceb; - pData->iPass = iPass; - pData->iRow = iRow; - pData->iRowinc = iRowinc; - pData->iCol = iCol; - pData->iColinc = iColinc; - pData->iRowsamples = iRowsamples; - pData->iRowsize = iRowsize; - pData->pPrevrow = pPrevrow; - pData->pRGBArow = pRGBArow; - pData->bIsRGBA16 = bIsRGBA16; - pData->bIsOpaque = bIsOpaque; - pData->fCorrectrow = fCorrectrow; - pData->fDisplayrow = fDisplayrow; - pData->fRetrieverow = fRetrieverow; - pData->pCurrentobj = pCurrentobj; - pData->pRetrieveobj = pRetrieveobj; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_LOAD_BKGDLAYER, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -MNG_LOCAL mng_retcode clear_canvas (mng_datap pData) -{ - mng_int32 iY; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLEAR_CANVAS, MNG_LC_START); -#endif - - pData->iDestl = 0; /* clipping region is full canvas! */ - pData->iDestt = 0; - pData->iDestr = pData->iWidth; - pData->iDestb = pData->iHeight; - - pData->iSourcel = 0; /* source is same as destination */ - pData->iSourcer = pData->iWidth; - pData->iSourcet = 0; - pData->iSourceb = pData->iHeight; - - pData->iPass = -1; /* these are the object's dimensions now */ - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iWidth; - pData->iRowsize = pData->iRowsamples << 2; - pData->bIsRGBA16 = MNG_FALSE; /* let's keep it simple ! */ - pData->bIsOpaque = MNG_TRUE; - - set_display_routine (pData); /* determine display routine */ - /* get a temporary row-buffer */ - /* it's transparent black by default!! */ - MNG_ALLOC (pData, pData->pRGBArow, pData->iRowsize); - - iY = pData->iDestt; /* this is where we start */ - iRetcode = MNG_NOERROR; /* so far, so good */ - - while ((!iRetcode) && (iY < pData->iDestb)) - { /* clear a row then */ - iRetcode = ((mng_displayrow)pData->fDisplayrow) (pData); - - if (!iRetcode) - iRetcode = mng_next_row (pData); /* adjust variables for next row */ - - iY++; /* and next line */ - } - /* drop the temporary row-buffer */ - MNG_FREE (pData, pData->pRGBArow, pData->iRowsize); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLEAR_CANVAS, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -MNG_LOCAL mng_retcode next_frame (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 iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_FRAME, MNG_LC_START); -#endif - - if (!pData->iBreakpoint) /* no previous break here ? */ - { -#ifndef MNG_SKIPCHUNK_FRAM - mng_uint8 iOldmode = pData->iFramemode; - /* interframe delay required ? */ - if ((iOldmode == 2) || (iOldmode == 4)) - { - if ((pData->iFrameseq) && (iFramemode != 1) && (iFramemode != 3)) - iRetcode = interframe_delay (pData); - else - pData->iFramedelay = pData->iNextdelay; - } - else - { /* delay before inserting background layer? */ - if ((pData->bFramedone) && (iFramemode == 4)) - iRetcode = interframe_delay (pData); - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* now we'll assume we're in the next frame! */ - if (iFramemode) /* save the new framing mode ? */ - { - pData->iFRAMmode = iFramemode; - pData->iFramemode = iFramemode; - } - else /* reload default */ - pData->iFramemode = pData->iFRAMmode; - - if (iChangedelay) /* delay changed ? */ - { - pData->iNextdelay = iDelay; /* for *after* next subframe */ - - if ((iOldmode == 2) || (iOldmode == 4)) - pData->iFramedelay = pData->iFRAMdelay; - - if (iChangedelay == 2) /* also overall ? */ - pData->iFRAMdelay = iDelay; - } - else - { /* reload default */ - pData->iNextdelay = pData->iFRAMdelay; - } - - if (iChangetimeout) /* timeout changed ? */ - { /* for next subframe */ - pData->iFrametimeout = iTimeout; - - if ((iChangetimeout == 2) || /* also overall ? */ - (iChangetimeout == 4) || - (iChangetimeout == 6) || - (iChangetimeout == 8)) - pData->iFRAMtimeout = iTimeout; - } - else /* reload default */ - pData->iFrametimeout = pData->iFRAMtimeout; - - if (iChangeclipping) /* clipping changed ? */ - { - pData->bFrameclipping = MNG_TRUE; - - if (!iCliptype) /* absolute ? */ - { - pData->iFrameclipl = iClipl; - pData->iFrameclipr = iClipr; - pData->iFrameclipt = iClipt; - pData->iFrameclipb = iClipb; - } - else /* relative */ - { - pData->iFrameclipl = pData->iFrameclipl + iClipl; - pData->iFrameclipr = pData->iFrameclipr + iClipr; - pData->iFrameclipt = pData->iFrameclipt + iClipt; - pData->iFrameclipb = pData->iFrameclipb + iClipb; - } - - if (iChangeclipping == 2) /* also overall ? */ - { - pData->bFRAMclipping = MNG_TRUE; - - if (!iCliptype) /* absolute ? */ - { - pData->iFRAMclipl = iClipl; - pData->iFRAMclipr = iClipr; - pData->iFRAMclipt = iClipt; - pData->iFRAMclipb = iClipb; - } - else /* relative */ - { - pData->iFRAMclipl = pData->iFRAMclipl + iClipl; - pData->iFRAMclipr = pData->iFRAMclipr + iClipr; - pData->iFRAMclipt = pData->iFRAMclipt + iClipt; - pData->iFRAMclipb = pData->iFRAMclipb + iClipb; - } - } - } - else - { /* reload defaults */ - pData->bFrameclipping = pData->bFRAMclipping; - pData->iFrameclipl = pData->iFRAMclipl; - pData->iFrameclipr = pData->iFRAMclipr; - pData->iFrameclipt = pData->iFRAMclipt; - pData->iFrameclipb = pData->iFRAMclipb; - } -#endif - } - - if (!pData->bTimerset) /* timer still off ? */ - { - if ( -#ifndef MNG_SKIPCHUNK_FRAM - (pData->iFramemode == 4) || /* insert background layer after a new frame */ -#endif - (!pData->iLayerseq)) /* and certainly before the very first layer */ - iRetcode = load_bkgdlayer (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - pData->iFrameseq++; /* count the frame ! */ - pData->bFramedone = MNG_TRUE; /* and indicate we've done one */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_FRAME, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -MNG_LOCAL mng_retcode next_layer (mng_datap pData) -{ - mng_imagep pImage; - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_LAYER, MNG_LC_START); -#endif - -#ifndef MNG_SKIPCHUNK_FRAM - if (!pData->iBreakpoint) /* no previous break here ? */ - { /* interframe delay required ? */ - if ((pData->eImagetype == mng_it_mng) && (pData->iLayerseq) && - ((pData->iFramemode == 1) || (pData->iFramemode == 3))) - iRetcode = interframe_delay (pData); - else - pData->iFramedelay = pData->iNextdelay; - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif - - if (!pData->bTimerset) /* timer still off ? */ - { - if (!pData->iLayerseq) /* restore background for the very first layer ? */ - { /* wait till IDAT/JDAT for PNGs & JNGs !!! */ - if ((pData->eImagetype == mng_it_png) || (pData->eImagetype == mng_it_jng)) - pData->bRestorebkgd = MNG_TRUE; - else - { /* for MNG we do it right away */ - iRetcode = load_bkgdlayer (pData); - pData->iLayerseq++; /* and it counts as a layer then ! */ - } - } -#ifndef MNG_SKIPCHUNK_FRAM - else - if (pData->iFramemode == 3) /* restore background for each layer ? */ - iRetcode = load_bkgdlayer (pData); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifndef MNG_NO_DELTA_PNG - if (pData->bHasDHDR) /* processing a delta-image ? */ - pImage = (mng_imagep)pData->pDeltaImage; - else -#endif - pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* not an active object ? */ - pImage = (mng_imagep)pData->pObjzero; - /* determine display rectangle */ - pData->iDestl = MAX_COORD ((mng_int32)0, pImage->iPosx); - pData->iDestt = MAX_COORD ((mng_int32)0, pImage->iPosy); - /* is it a valid buffer ? */ - if ((pImage->pImgbuf->iWidth) && (pImage->pImgbuf->iHeight)) - { - pData->iDestr = MIN_COORD ((mng_int32)pData->iWidth, - pImage->iPosx + (mng_int32)pImage->pImgbuf->iWidth ); - pData->iDestb = MIN_COORD ((mng_int32)pData->iHeight, - pImage->iPosy + (mng_int32)pImage->pImgbuf->iHeight); - } - else /* it's a single image ! */ - { - pData->iDestr = MIN_COORD ((mng_int32)pData->iWidth, - (mng_int32)pData->iDatawidth ); - pData->iDestb = MIN_COORD ((mng_int32)pData->iHeight, - (mng_int32)pData->iDataheight); - } - -#ifndef MNG_SKIPCHUNK_FRAM - if (pData->bFrameclipping) /* frame clipping specified ? */ - { - pData->iDestl = MAX_COORD (pData->iDestl, pData->iFrameclipl); - pData->iDestt = MAX_COORD (pData->iDestt, pData->iFrameclipt); - pData->iDestr = MIN_COORD (pData->iDestr, pData->iFrameclipr); - pData->iDestb = MIN_COORD (pData->iDestb, pData->iFrameclipb); - } -#endif - - if (pImage->bClipped) /* is the image clipped itself ? */ - { - pData->iDestl = MAX_COORD (pData->iDestl, pImage->iClipl); - pData->iDestt = MAX_COORD (pData->iDestt, pImage->iClipt); - pData->iDestr = MIN_COORD (pData->iDestr, pImage->iClipr); - pData->iDestb = MIN_COORD (pData->iDestb, pImage->iClipb); - } - /* determine source starting point */ - pData->iSourcel = MAX_COORD ((mng_int32)0, pData->iDestl - pImage->iPosx); - pData->iSourcet = MAX_COORD ((mng_int32)0, pData->iDestt - pImage->iPosy); - - if ((pImage->pImgbuf->iWidth) && (pImage->pImgbuf->iHeight)) - { /* and maximum size */ - pData->iSourcer = MIN_COORD ((mng_int32)pImage->pImgbuf->iWidth, - pData->iSourcel + pData->iDestr - pData->iDestl); - pData->iSourceb = MIN_COORD ((mng_int32)pImage->pImgbuf->iHeight, - pData->iSourcet + pData->iDestb - pData->iDestt); - } - else /* it's a single image ! */ - { - pData->iSourcer = pData->iSourcel + pData->iDestr - pData->iDestl; - pData->iSourceb = pData->iSourcet + pData->iDestb - pData->iDestt; - } - - pData->iLayerseq++; /* count the layer ! */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_LAYER, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_display_image (mng_datap pData, - mng_imagep pImage, - mng_bool bLayeradvanced) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_IMAGE, MNG_LC_START); -#endif - /* actively running ? */ -#ifndef MNG_SKIPCHUNK_MAGN - if (((pData->bRunning) || (pData->bSearching)) && (!pData->bSkipping)) - { - if ( (!pData->iBreakpoint) && /* needs magnification ? */ - ( (pImage->iMAGN_MethodX) || (pImage->iMAGN_MethodY) ) ) - { - iRetcode = mng_magnify_imageobject (pData, pImage); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } -#endif - - pData->pRetrieveobj = pImage; /* so retrieve-row and color-correction can find it */ - - if (!bLayeradvanced) /* need to advance the layer ? */ - { - mng_imagep pSave = pData->pCurrentobj; - pData->pCurrentobj = pImage; - next_layer (pData); /* advance to next layer */ - pData->pCurrentobj = pSave; - } - /* need to restore the background ? */ - if ((!pData->bTimerset) && (pData->bRestorebkgd)) - { - mng_imagep pSave = pData->pCurrentobj; - pData->pCurrentobj = pImage; - pData->bRestorebkgd = MNG_FALSE; - iRetcode = load_bkgdlayer (pData); - pData->pCurrentobj = pSave; - - if (iRetcode) /* on error bail out */ - return iRetcode; - - pData->iLayerseq++; /* and it counts as a layer then ! */ - } - /* actively running ? */ - if (((pData->bRunning) || (pData->bSearching)) && (!pData->bSkipping)) - { - if (!pData->bTimerset) /* all systems still go ? */ - { - pData->iBreakpoint = 0; /* let's make absolutely sure... */ - /* anything to display ? */ - if ((pData->iDestr >= pData->iDestl) && (pData->iDestb >= pData->iDestt)) - { - mng_int32 iY; - - set_display_routine (pData); /* determine display routine */ - /* and image-buffer retrieval routine */ - switch (pImage->pImgbuf->iColortype) - { - case 0 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)mng_retrieve_g16; - else -#endif - pData->fRetrieverow = (mng_fptr)mng_retrieve_g8; - - pData->bIsOpaque = (mng_bool)(!pImage->pImgbuf->bHasTRNS); - break; - } - - case 2 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgb16; - else -#endif - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgb8; - - pData->bIsOpaque = (mng_bool)(!pImage->pImgbuf->bHasTRNS); - break; - } - - - case 3 : { pData->fRetrieverow = (mng_fptr)mng_retrieve_idx8; - pData->bIsOpaque = (mng_bool)(!pImage->pImgbuf->bHasTRNS); - break; - } - - - case 4 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)mng_retrieve_ga16; - else -#endif - pData->fRetrieverow = (mng_fptr)mng_retrieve_ga8; - - pData->bIsOpaque = MNG_FALSE; - break; - } - - - case 6 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgba16; - else -#endif - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgba8; - - pData->bIsOpaque = MNG_FALSE; - break; - } - - case 8 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)mng_retrieve_g16; - else -#endif - pData->fRetrieverow = (mng_fptr)mng_retrieve_g8; - - pData->bIsOpaque = MNG_TRUE; - break; - } - - case 10 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgb16; - else -#endif - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgb8; - - pData->bIsOpaque = MNG_TRUE; - break; - } - - - case 12 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)mng_retrieve_ga16; - else -#endif - pData->fRetrieverow = (mng_fptr)mng_retrieve_ga8; - - pData->bIsOpaque = MNG_FALSE; - break; - } - - - case 14 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgba16; - else -#endif - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgba8; - - pData->bIsOpaque = MNG_FALSE; - break; - } - - } - - pData->iPass = -1; /* these are the object's dimensions now */ - pData->iRow = pData->iSourcet; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pImage->pImgbuf->iWidth; - pData->iRowsize = pData->iRowsamples << 2; - pData->bIsRGBA16 = MNG_FALSE; - /* adjust for 16-bit object ? */ -#ifndef MNG_NO_16BIT_SUPPORT - if (pImage->pImgbuf->iBitdepth > 8) - { - pData->bIsRGBA16 = MNG_TRUE; - pData->iRowsize = pData->iRowsamples << 3; - } -#endif - - pData->fCorrectrow = MNG_NULL; /* default no color-correction */ - -#ifdef MNG_NO_CMS - iRetcode = MNG_NOERROR; -#else -#if defined(MNG_FULL_CMS) /* determine color-management routine */ - iRetcode = mng_init_full_cms (pData, MNG_FALSE, MNG_FALSE, MNG_TRUE); -#elif defined(MNG_GAMMA_ONLY) - iRetcode = mng_init_gamma_only (pData, MNG_FALSE, MNG_FALSE, MNG_TRUE); -#elif defined(MNG_APP_CMS) - iRetcode = mng_init_app_cms (pData, MNG_FALSE, MNG_FALSE, MNG_TRUE); -#endif - if (iRetcode) /* on error bail out */ - return iRetcode; -#endif /* MNG_NO_CMS */ - /* get a temporary row-buffer */ - MNG_ALLOC (pData, pData->pRGBArow, pData->iRowsize); - - iY = pData->iSourcet; /* this is where we start */ - - while ((!iRetcode) && (iY < pData->iSourceb)) - { /* get a row */ - iRetcode = ((mng_retrieverow)pData->fRetrieverow) (pData); - /* color correction ? */ - if ((!iRetcode) && (pData->fCorrectrow)) - iRetcode = ((mng_correctrow)pData->fCorrectrow) (pData); - - if (!iRetcode) /* so... display it */ - iRetcode = ((mng_displayrow)pData->fDisplayrow) (pData); - - if (!iRetcode) /* adjust variables for next row */ - iRetcode = mng_next_row (pData); - - iY++; /* and next line */ - } - /* drop the temporary row-buffer */ - MNG_FREE (pData, pData->pRGBArow, pData->iRowsize); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#if defined(MNG_FULL_CMS) /* cleanup cms stuff */ - iRetcode = mng_clear_cms (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; -#endif - } - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_IMAGE, MNG_LC_END); -#endif - - return MNG_NOERROR; /* whehehe, this is good ! */ -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -mng_retcode mng_execute_delta_image (mng_datap pData, - mng_imagep pTarget, - mng_imagep pDelta) -{ - mng_imagedatap pBuftarget = pTarget->pImgbuf; - mng_imagedatap pBufdelta = pDelta->pImgbuf; - mng_uint32 iY; - mng_retcode iRetcode; - mng_ptr pSaveRGBA; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_EXECUTE_DELTA_IMAGE, MNG_LC_START); -#endif - /* actively running ? */ - if (((pData->bRunning) || (pData->bSearching)) && (!pData->bSkipping)) - { - if (pBufdelta->bHasPLTE) /* palette in delta ? */ - { - mng_uint32 iX; - /* new palette larger than old one ? */ - if ((!pBuftarget->bHasPLTE) || (pBuftarget->iPLTEcount < pBufdelta->iPLTEcount)) - pBuftarget->iPLTEcount = pBufdelta->iPLTEcount; - /* it's definitely got a PLTE now */ - pBuftarget->bHasPLTE = MNG_TRUE; - - for (iX = 0; iX < pBufdelta->iPLTEcount; iX++) - { - pBuftarget->aPLTEentries[iX].iRed = pBufdelta->aPLTEentries[iX].iRed; - pBuftarget->aPLTEentries[iX].iGreen = pBufdelta->aPLTEentries[iX].iGreen; - pBuftarget->aPLTEentries[iX].iBlue = pBufdelta->aPLTEentries[iX].iBlue; - } - } - - if (pBufdelta->bHasTRNS) /* cheap transparency in delta ? */ - { - switch (pData->iColortype) /* drop it into the target */ - { - case 0: { /* gray */ - pBuftarget->iTRNSgray = pBufdelta->iTRNSgray; - pBuftarget->iTRNSred = 0; - pBuftarget->iTRNSgreen = 0; - pBuftarget->iTRNSblue = 0; - pBuftarget->iTRNScount = 0; - break; - } - case 2: { /* rgb */ - pBuftarget->iTRNSgray = 0; - pBuftarget->iTRNSred = pBufdelta->iTRNSred; - pBuftarget->iTRNSgreen = pBufdelta->iTRNSgreen; - pBuftarget->iTRNSblue = pBufdelta->iTRNSblue; - pBuftarget->iTRNScount = 0; - break; - } - case 3: { /* indexed */ - pBuftarget->iTRNSgray = 0; - pBuftarget->iTRNSred = 0; - pBuftarget->iTRNSgreen = 0; - pBuftarget->iTRNSblue = 0; - /* existing range smaller than new one ? */ - if ((!pBuftarget->bHasTRNS) || (pBuftarget->iTRNScount < pBufdelta->iTRNScount)) - pBuftarget->iTRNScount = pBufdelta->iTRNScount; - - MNG_COPY (pBuftarget->aTRNSentries, pBufdelta->aTRNSentries, pBufdelta->iTRNScount); - break; - } - } - - pBuftarget->bHasTRNS = MNG_TRUE; /* tell it it's got a tRNS now */ - } - -#ifndef MNG_SKIPCHUNK_bKGD - if (pBufdelta->bHasBKGD) /* bkgd in source ? */ - { /* drop it onto the target */ - pBuftarget->bHasBKGD = MNG_TRUE; - pBuftarget->iBKGDindex = pBufdelta->iBKGDindex; - pBuftarget->iBKGDgray = pBufdelta->iBKGDgray; - pBuftarget->iBKGDred = pBufdelta->iBKGDred; - pBuftarget->iBKGDgreen = pBufdelta->iBKGDgreen; - pBuftarget->iBKGDblue = pBufdelta->iBKGDblue; - } -#endif - - if (pBufdelta->bHasGAMA) /* gamma in source ? */ - { - pBuftarget->bHasGAMA = MNG_TRUE; /* drop it onto the target */ - pBuftarget->iGamma = pBufdelta->iGamma; - } - -#ifndef MNG_SKIPCHUNK_cHRM - if (pBufdelta->bHasCHRM) /* chroma in delta ? */ - { /* drop it onto the target */ - pBuftarget->bHasCHRM = MNG_TRUE; - pBuftarget->iWhitepointx = pBufdelta->iWhitepointx; - pBuftarget->iWhitepointy = pBufdelta->iWhitepointy; - pBuftarget->iPrimaryredx = pBufdelta->iPrimaryredx; - pBuftarget->iPrimaryredy = pBufdelta->iPrimaryredy; - pBuftarget->iPrimarygreenx = pBufdelta->iPrimarygreenx; - pBuftarget->iPrimarygreeny = pBufdelta->iPrimarygreeny; - pBuftarget->iPrimarybluex = pBufdelta->iPrimarybluex; - pBuftarget->iPrimarybluey = pBufdelta->iPrimarybluey; - } -#endif - -#ifndef MNG_SKIPCHUNK_sRGB - if (pBufdelta->bHasSRGB) /* sRGB in delta ? */ - { /* drop it onto the target */ - pBuftarget->bHasSRGB = MNG_TRUE; - pBuftarget->iRenderingintent = pBufdelta->iRenderingintent; - } -#endif - -#ifndef MNG_SKIPCHUNK_iCCP - if (pBufdelta->bHasICCP) /* ICC profile in delta ? */ - { - pBuftarget->bHasICCP = MNG_TRUE; /* drop it onto the target */ - - if (pBuftarget->pProfile) /* profile existed ? */ - MNG_FREEX (pData, pBuftarget->pProfile, pBuftarget->iProfilesize); - /* allocate a buffer & copy it */ - MNG_ALLOC (pData, pBuftarget->pProfile, pBufdelta->iProfilesize); - MNG_COPY (pBuftarget->pProfile, pBufdelta->pProfile, pBufdelta->iProfilesize); - /* store its length as well */ - pBuftarget->iProfilesize = pBufdelta->iProfilesize; - } -#endif - /* need to execute delta pixels ? */ - if ((!pData->bDeltaimmediate) && (pData->iDeltatype != MNG_DELTATYPE_NOCHANGE)) - { - pData->fScalerow = MNG_NULL; /* not needed by default */ - - switch (pBufdelta->iBitdepth) /* determine scaling routine */ - { -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case 1 : { - switch (pBuftarget->iBitdepth) - { - case 2 : { pData->fScalerow = (mng_fptr)mng_scale_g1_g2; break; } - case 4 : { pData->fScalerow = (mng_fptr)mng_scale_g1_g4; break; } - - case 8 : { pData->fScalerow = (mng_fptr)mng_scale_g1_g8; break; } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { pData->fScalerow = (mng_fptr)mng_scale_g1_g16; break; } -#endif - } - break; - } - - case 2 : { - switch (pBuftarget->iBitdepth) - { - case 1 : { pData->fScalerow = (mng_fptr)mng_scale_g2_g1; break; } - case 4 : { pData->fScalerow = (mng_fptr)mng_scale_g2_g4; break; } - case 8 : { pData->fScalerow = (mng_fptr)mng_scale_g2_g8; break; } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { pData->fScalerow = (mng_fptr)mng_scale_g2_g16; break; } -#endif - } - break; - } - - case 4 : { - switch (pBuftarget->iBitdepth) - { - case 1 : { pData->fScalerow = (mng_fptr)mng_scale_g4_g1; break; } - case 2 : { pData->fScalerow = (mng_fptr)mng_scale_g4_g2; break; } - case 8 : { pData->fScalerow = (mng_fptr)mng_scale_g4_g8; break; } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { pData->fScalerow = (mng_fptr)mng_scale_g4_g16; break; } -#endif - } - break; - } -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - - case 8 : { - switch (pBufdelta->iColortype) - { - case 0 : ; - case 3 : ; - case 8 : { - switch (pBuftarget->iBitdepth) - { -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case 1 : { pData->fScalerow = (mng_fptr)mng_scale_g8_g1; break; } - case 2 : { pData->fScalerow = (mng_fptr)mng_scale_g8_g2; break; } - case 4 : { pData->fScalerow = (mng_fptr)mng_scale_g8_g4; break; } -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { pData->fScalerow = (mng_fptr)mng_scale_g8_g16; break; } -#endif - } - break; - } - case 2 : ; - case 10 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (pBuftarget->iBitdepth == 16) - pData->fScalerow = (mng_fptr)mng_scale_rgb8_rgb16; -#endif - break; - } - case 4 : ; - case 12 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (pBuftarget->iBitdepth == 16) - pData->fScalerow = (mng_fptr)mng_scale_ga8_ga16; -#endif - break; - } - case 6 : ; - case 14 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (pBuftarget->iBitdepth == 16) - pData->fScalerow = (mng_fptr)mng_scale_rgba8_rgba16; -#endif - break; - } - } - break; - } - -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { - switch (pBufdelta->iColortype) - { - case 0 : ; - case 3 : ; - case 8 : { - switch (pBuftarget->iBitdepth) - { -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case 1 : { pData->fScalerow = (mng_fptr)mng_scale_g16_g1; break; } - case 2 : { pData->fScalerow = (mng_fptr)mng_scale_g16_g2; break; } - case 4 : { pData->fScalerow = (mng_fptr)mng_scale_g16_g4; break; } -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case 8 : { pData->fScalerow = (mng_fptr)mng_scale_g16_g8; break; } - } - break; - } - case 2 : ; - case 10 : { - if (pBuftarget->iBitdepth == 8) - pData->fScalerow = (mng_fptr)mng_scale_rgb16_rgb8; - break; - } - case 4 : ; - case 12 : { - if (pBuftarget->iBitdepth == 8) - pData->fScalerow = (mng_fptr)mng_scale_ga16_ga8; - break; - } - case 6 : ; - case 14 : { - if (pBuftarget->iBitdepth == 8) - pData->fScalerow = (mng_fptr)mng_scale_rgba16_rgba8; - break; - } - } - break; - } -#endif - - } - - pData->fDeltarow = MNG_NULL; /* let's assume there's nothing to do */ - - switch (pBuftarget->iColortype) /* determine delta processing routine */ - { - case 0 : ; - case 8 : { /* gray */ - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - if ((pBufdelta->iColortype == 0) || (pBufdelta->iColortype == 3) || - (pBufdelta->iColortype == 8)) - { - switch (pBuftarget->iBitdepth) - { -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case 1 : { pData->fDeltarow = (mng_fptr)mng_delta_g1_g1; break; } - case 2 : { pData->fDeltarow = (mng_fptr)mng_delta_g2_g2; break; } - case 4 : { pData->fDeltarow = (mng_fptr)mng_delta_g4_g4; break; } -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case 8 : { pData->fDeltarow = (mng_fptr)mng_delta_g8_g8; break; } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { pData->fDeltarow = (mng_fptr)mng_delta_g16_g16; break; } -#endif - } - } - } - - break; - } - - case 2 : ; - case 10 : { /* rgb */ - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - if ((pBufdelta->iColortype == 2) || (pBufdelta->iColortype == 10)) - { - switch (pBuftarget->iBitdepth) - { - case 8 : { pData->fDeltarow = (mng_fptr)mng_delta_rgb8_rgb8; break; } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { pData->fDeltarow = (mng_fptr)mng_delta_rgb16_rgb16; break; } -#endif - } - } - } - - break; - } - - case 3 : { /* indexed; abuse gray routines */ - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - if ((pBufdelta->iColortype == 0) || (pBufdelta->iColortype == 3)) - { - switch (pBuftarget->iBitdepth) - { -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case 1 : { pData->fDeltarow = (mng_fptr)mng_delta_g1_g1; break; } - case 2 : { pData->fDeltarow = (mng_fptr)mng_delta_g2_g2; break; } - case 4 : { pData->fDeltarow = (mng_fptr)mng_delta_g4_g4; break; } -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case 8 : { pData->fDeltarow = (mng_fptr)mng_delta_g8_g8; break; } - } - } - } - - break; - } - - case 4 : ; - case 12 : { /* gray + alpha */ - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - if ((pBufdelta->iColortype == 4) || (pBufdelta->iColortype == 12)) - { - switch (pBuftarget->iBitdepth) - { - case 8 : { pData->fDeltarow = (mng_fptr)mng_delta_ga8_ga8; break; } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { pData->fDeltarow = (mng_fptr)mng_delta_ga16_ga16; break; } -#endif - } - } - } - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORREPLACE) ) - { - if ((pBufdelta->iColortype == 0) || (pBufdelta->iColortype == 3) || - (pBufdelta->iColortype == 8)) - { - switch (pBuftarget->iBitdepth) - { - case 8 : { pData->fDeltarow = (mng_fptr)mng_delta_ga8_g8; break; } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { pData->fDeltarow = (mng_fptr)mng_delta_ga16_g16; break; } -#endif - } - } - } - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAREPLACE) ) - { - if ((pBufdelta->iColortype == 0) || (pBufdelta->iColortype == 3)) - { - switch (pBuftarget->iBitdepth) - { - case 8 : { pData->fDeltarow = (mng_fptr)mng_delta_ga8_a8; break; } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { pData->fDeltarow = (mng_fptr)mng_delta_ga16_a16; break; } -#endif - } - } - } - - break; - } - - case 6 : ; - case 14 : { /* rgb + alpha */ - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - if ((pBufdelta->iColortype == 6) || (pBufdelta->iColortype == 14)) - { - switch (pBuftarget->iBitdepth) - { - case 8 : { pData->fDeltarow = (mng_fptr)mng_delta_rgba8_rgba8; break; } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { pData->fDeltarow = (mng_fptr)mng_delta_rgba16_rgba16; break; } -#endif - } - } - } - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORREPLACE) ) - { - if ((pBufdelta->iColortype == 2) || (pBufdelta->iColortype == 10)) - { - switch (pBuftarget->iBitdepth) - { - case 8 : { pData->fDeltarow = (mng_fptr)mng_delta_rgba8_rgb8; break; } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { pData->fDeltarow = (mng_fptr)mng_delta_rgba16_rgb16; break; } -#endif - } - } - } - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAREPLACE) ) - { - if ((pBufdelta->iColortype == 0) || (pBufdelta->iColortype == 3)) - { - switch (pBuftarget->iBitdepth) - { - case 8 : { pData->fDeltarow = (mng_fptr)mng_delta_rgba8_a8; break; } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { pData->fDeltarow = (mng_fptr)mng_delta_rgba16_a16; break; } -#endif - } - } - } - - break; - } - - } - - if (pData->fDeltarow) /* do we need to take action ? */ - { - pData->iPass = -1; /* setup row dimensions and stuff */ - pData->iRow = pData->iDeltaBlocky; - pData->iRowinc = 1; - pData->iCol = pData->iDeltaBlockx; - pData->iColinc = 1; - pData->iRowsamples = pBufdelta->iWidth; - pData->iRowsize = pBuftarget->iRowsize; - /* indicate where to retrieve & where to store */ - pData->pRetrieveobj = (mng_objectp)pDelta; - pData->pStoreobj = (mng_objectp)pTarget; - - pSaveRGBA = pData->pRGBArow; /* save current temp-buffer! */ - /* get a temporary row-buffer */ - MNG_ALLOC (pData, pData->pRGBArow, (pBufdelta->iRowsize << 1)); - - iY = 0; /* this is where we start */ - iRetcode = MNG_NOERROR; /* still oke for now */ - - while ((!iRetcode) && (iY < pBufdelta->iHeight)) - { /* get a row */ - mng_uint8p pWork = pBufdelta->pImgdata + (iY * pBufdelta->iRowsize); - - MNG_COPY (pData->pRGBArow, pWork, pBufdelta->iRowsize); - - if (pData->fScalerow) /* scale it (if necessary) */ - iRetcode = ((mng_scalerow)pData->fScalerow) (pData); - - if (!iRetcode) /* and... execute it */ - iRetcode = ((mng_deltarow)pData->fDeltarow) (pData); - - if (!iRetcode) /* adjust variables for next row */ - iRetcode = mng_next_row (pData); - - iY++; /* and next line */ - } - /* drop the temporary row-buffer */ - MNG_FREE (pData, pData->pRGBArow, (pBufdelta->iRowsize << 1)); - pData->pRGBArow = pSaveRGBA; /* restore saved temp-buffer! */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } - else - MNG_ERROR (pData, MNG_INVALIDDELTA); - - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_EXECUTE_DELTA_IMAGE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_DELTA_PNG */ - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SAVE -MNG_LOCAL mng_retcode save_state (mng_datap pData) -{ - mng_savedatap pSave; - mng_imagep pImage; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SAVE_STATE, MNG_LC_START); -#endif - - if (pData->pSavedata) /* sanity check */ - MNG_ERROR (pData, MNG_INTERNALERROR); - /* get a buffer for saving */ - MNG_ALLOC (pData, pData->pSavedata, sizeof (mng_savedata)); - - pSave = pData->pSavedata; /* address it more directly */ - /* and copy global data from the main struct */ -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) - pSave->bHasglobalPLTE = pData->bHasglobalPLTE; - pSave->bHasglobalTRNS = pData->bHasglobalTRNS; - pSave->bHasglobalGAMA = pData->bHasglobalGAMA; - pSave->bHasglobalCHRM = pData->bHasglobalCHRM; - pSave->bHasglobalSRGB = pData->bHasglobalSRGB; - pSave->bHasglobalICCP = pData->bHasglobalICCP; - pSave->bHasglobalBKGD = pData->bHasglobalBKGD; -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - -#ifndef MNG_SKIPCHUNK_BACK - pSave->iBACKred = pData->iBACKred; - pSave->iBACKgreen = pData->iBACKgreen; - pSave->iBACKblue = pData->iBACKblue; - pSave->iBACKmandatory = pData->iBACKmandatory; - pSave->iBACKimageid = pData->iBACKimageid; - pSave->iBACKtile = pData->iBACKtile; -#endif - -#ifndef MNG_SKIPCHUNK_FRAM - pSave->iFRAMmode = pData->iFRAMmode; - pSave->iFRAMdelay = pData->iFRAMdelay; - pSave->iFRAMtimeout = pData->iFRAMtimeout; - pSave->bFRAMclipping = pData->bFRAMclipping; - pSave->iFRAMclipl = pData->iFRAMclipl; - pSave->iFRAMclipr = pData->iFRAMclipr; - pSave->iFRAMclipt = pData->iFRAMclipt; - pSave->iFRAMclipb = pData->iFRAMclipb; -#endif - - pSave->iGlobalPLTEcount = pData->iGlobalPLTEcount; - - MNG_COPY (pSave->aGlobalPLTEentries, pData->aGlobalPLTEentries, sizeof (mng_rgbpaltab)); - - pSave->iGlobalTRNSrawlen = pData->iGlobalTRNSrawlen; - MNG_COPY (pSave->aGlobalTRNSrawdata, pData->aGlobalTRNSrawdata, 256); - - pSave->iGlobalGamma = pData->iGlobalGamma; - -#ifndef MNG_SKIPCHUNK_cHRM - pSave->iGlobalWhitepointx = pData->iGlobalWhitepointx; - pSave->iGlobalWhitepointy = pData->iGlobalWhitepointy; - pSave->iGlobalPrimaryredx = pData->iGlobalPrimaryredx; - pSave->iGlobalPrimaryredy = pData->iGlobalPrimaryredy; - pSave->iGlobalPrimarygreenx = pData->iGlobalPrimarygreenx; - pSave->iGlobalPrimarygreeny = pData->iGlobalPrimarygreeny; - pSave->iGlobalPrimarybluex = pData->iGlobalPrimarybluex; - pSave->iGlobalPrimarybluey = pData->iGlobalPrimarybluey; -#endif - -#ifndef MNG_SKIPCHUNK_sRGB - pSave->iGlobalRendintent = pData->iGlobalRendintent; -#endif - -#ifndef MNG_SKIPCHUNK_iCCP - pSave->iGlobalProfilesize = pData->iGlobalProfilesize; - - if (pSave->iGlobalProfilesize) /* has a profile ? */ - { /* then copy that ! */ - MNG_ALLOC (pData, pSave->pGlobalProfile, pSave->iGlobalProfilesize); - MNG_COPY (pSave->pGlobalProfile, pData->pGlobalProfile, pSave->iGlobalProfilesize); - } -#endif - -#ifndef MNG_SKIPCHUNK_bKGD - pSave->iGlobalBKGDred = pData->iGlobalBKGDred; - pSave->iGlobalBKGDgreen = pData->iGlobalBKGDgreen; - pSave->iGlobalBKGDblue = pData->iGlobalBKGDblue; -#endif - - /* freeze current image objects */ - pImage = (mng_imagep)pData->pFirstimgobj; - - while (pImage) - { /* freeze the object AND its buffer */ - pImage->bFrozen = MNG_TRUE; - pImage->pImgbuf->bFrozen = MNG_TRUE; - /* neeeext */ - pImage = (mng_imagep)pImage->sHeader.pNext; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SAVE_STATE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_reset_objzero (mng_datap pData) -{ - mng_imagep pImage = (mng_imagep)pData->pObjzero; - mng_retcode iRetcode = mng_reset_object_details (pData, pImage, 0, 0, 0, - 0, 0, 0, 0, MNG_TRUE); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - pImage->bVisible = MNG_TRUE; - pImage->bViewable = MNG_TRUE; - pImage->iPosx = 0; - pImage->iPosy = 0; - pImage->bClipped = MNG_FALSE; - pImage->iClipl = 0; - pImage->iClipr = 0; - pImage->iClipt = 0; - pImage->iClipb = 0; -#ifndef MNG_SKIPCHUNK_MAGN - pImage->iMAGN_MethodX = 0; - pImage->iMAGN_MethodY = 0; - pImage->iMAGN_MX = 0; - pImage->iMAGN_MY = 0; - pImage->iMAGN_ML = 0; - pImage->iMAGN_MR = 0; - pImage->iMAGN_MT = 0; - pImage->iMAGN_MB = 0; -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -MNG_LOCAL mng_retcode restore_state (mng_datap pData) -{ -#ifndef MNG_SKIPCHUNK_SAVE - mng_savedatap pSave; -#endif - mng_imagep pImage; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_STATE, MNG_LC_START); -#endif - /* restore object 0 status !!! */ - iRetcode = mng_reset_objzero (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fresh cycle; fake no frames done yet */ - pData->bFramedone = MNG_FALSE; - -#ifndef MNG_SKIPCHUNK_SAVE - if (pData->pSavedata) /* do we have a saved state ? */ - { - pSave = pData->pSavedata; /* address it more directly */ - /* and copy it back to the main struct */ -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) - pData->bHasglobalPLTE = pSave->bHasglobalPLTE; - pData->bHasglobalTRNS = pSave->bHasglobalTRNS; - pData->bHasglobalGAMA = pSave->bHasglobalGAMA; - pData->bHasglobalCHRM = pSave->bHasglobalCHRM; - pData->bHasglobalSRGB = pSave->bHasglobalSRGB; - pData->bHasglobalICCP = pSave->bHasglobalICCP; - pData->bHasglobalBKGD = pSave->bHasglobalBKGD; -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - -#ifndef MNG_SKIPCHUNK_BACK - pData->iBACKred = pSave->iBACKred; - pData->iBACKgreen = pSave->iBACKgreen; - pData->iBACKblue = pSave->iBACKblue; - pData->iBACKmandatory = pSave->iBACKmandatory; - pData->iBACKimageid = pSave->iBACKimageid; - pData->iBACKtile = pSave->iBACKtile; -#endif - -#ifndef MNG_SKIPCHUNK_FRAM - pData->iFRAMmode = pSave->iFRAMmode; -/* pData->iFRAMdelay = pSave->iFRAMdelay; */ - pData->iFRAMtimeout = pSave->iFRAMtimeout; - pData->bFRAMclipping = pSave->bFRAMclipping; - pData->iFRAMclipl = pSave->iFRAMclipl; - pData->iFRAMclipr = pSave->iFRAMclipr; - pData->iFRAMclipt = pSave->iFRAMclipt; - pData->iFRAMclipb = pSave->iFRAMclipb; - /* NOOOOOOOOOOOO */ -/* pData->iFramemode = pSave->iFRAMmode; - pData->iFramedelay = pSave->iFRAMdelay; - pData->iFrametimeout = pSave->iFRAMtimeout; - pData->bFrameclipping = pSave->bFRAMclipping; - pData->iFrameclipl = pSave->iFRAMclipl; - pData->iFrameclipr = pSave->iFRAMclipr; - pData->iFrameclipt = pSave->iFRAMclipt; - pData->iFrameclipb = pSave->iFRAMclipb; */ - -/* pData->iNextdelay = pSave->iFRAMdelay; */ - pData->iNextdelay = pData->iFramedelay; -#endif - - pData->iGlobalPLTEcount = pSave->iGlobalPLTEcount; - MNG_COPY (pData->aGlobalPLTEentries, pSave->aGlobalPLTEentries, sizeof (mng_rgbpaltab)); - - pData->iGlobalTRNSrawlen = pSave->iGlobalTRNSrawlen; - MNG_COPY (pData->aGlobalTRNSrawdata, pSave->aGlobalTRNSrawdata, 256); - - pData->iGlobalGamma = pSave->iGlobalGamma; - -#ifndef MNG_SKIPCHUNK_cHRM - pData->iGlobalWhitepointx = pSave->iGlobalWhitepointx; - pData->iGlobalWhitepointy = pSave->iGlobalWhitepointy; - pData->iGlobalPrimaryredx = pSave->iGlobalPrimaryredx; - pData->iGlobalPrimaryredy = pSave->iGlobalPrimaryredy; - pData->iGlobalPrimarygreenx = pSave->iGlobalPrimarygreenx; - pData->iGlobalPrimarygreeny = pSave->iGlobalPrimarygreeny; - pData->iGlobalPrimarybluex = pSave->iGlobalPrimarybluex; - pData->iGlobalPrimarybluey = pSave->iGlobalPrimarybluey; -#endif - - pData->iGlobalRendintent = pSave->iGlobalRendintent; - -#ifndef MNG_SKIPCHUNK_iCCP - pData->iGlobalProfilesize = pSave->iGlobalProfilesize; - - if (pData->iGlobalProfilesize) /* has a profile ? */ - { /* then copy that ! */ - MNG_ALLOC (pData, pData->pGlobalProfile, pData->iGlobalProfilesize); - MNG_COPY (pData->pGlobalProfile, pSave->pGlobalProfile, pData->iGlobalProfilesize); - } -#endif - -#ifndef MNG_SKIPCHUNK_bKGD - pData->iGlobalBKGDred = pSave->iGlobalBKGDred; - pData->iGlobalBKGDgreen = pSave->iGlobalBKGDgreen; - pData->iGlobalBKGDblue = pSave->iGlobalBKGDblue; -#endif - } - else /* no saved-data; so reset the lot */ -#endif /* SKIPCHUNK_SAVE */ - { -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) - pData->bHasglobalPLTE = MNG_FALSE; - pData->bHasglobalTRNS = MNG_FALSE; - pData->bHasglobalGAMA = MNG_FALSE; - pData->bHasglobalCHRM = MNG_FALSE; - pData->bHasglobalSRGB = MNG_FALSE; - pData->bHasglobalICCP = MNG_FALSE; - pData->bHasglobalBKGD = MNG_FALSE; -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - -#ifndef MNG_SKIPCHUNK_TERM - if (!pData->bMisplacedTERM) /* backward compatible ugliness !!! */ - { - pData->iBACKred = 0; - pData->iBACKgreen = 0; - pData->iBACKblue = 0; - pData->iBACKmandatory = 0; - pData->iBACKimageid = 0; - pData->iBACKtile = 0; - } -#endif - -#ifndef MNG_SKIPCHUNK_FRAM - pData->iFRAMmode = 1; -/* pData->iFRAMdelay = 1; */ - pData->iFRAMtimeout = 0x7fffffffl; - pData->bFRAMclipping = MNG_FALSE; - pData->iFRAMclipl = 0; - pData->iFRAMclipr = 0; - pData->iFRAMclipt = 0; - pData->iFRAMclipb = 0; - /* NOOOOOOOOOOOO */ -/* pData->iFramemode = 1; - pData->iFramedelay = 1; - pData->iFrametimeout = 0x7fffffffl; - pData->bFrameclipping = MNG_FALSE; - pData->iFrameclipl = 0; - pData->iFrameclipr = 0; - pData->iFrameclipt = 0; - pData->iFrameclipb = 0; */ - -/* pData->iNextdelay = 1; */ - pData->iNextdelay = pData->iFramedelay; -#endif - - pData->iGlobalPLTEcount = 0; - - pData->iGlobalTRNSrawlen = 0; - - pData->iGlobalGamma = 0; - -#ifndef MNG_SKIPCHUNK_cHRM - pData->iGlobalWhitepointx = 0; - pData->iGlobalWhitepointy = 0; - pData->iGlobalPrimaryredx = 0; - pData->iGlobalPrimaryredy = 0; - pData->iGlobalPrimarygreenx = 0; - pData->iGlobalPrimarygreeny = 0; - pData->iGlobalPrimarybluex = 0; - pData->iGlobalPrimarybluey = 0; -#endif - - pData->iGlobalRendintent = 0; - -#ifndef MNG_SKIPCHUNK_iCCP - if (pData->iGlobalProfilesize) /* free a previous profile ? */ - MNG_FREE (pData, pData->pGlobalProfile, pData->iGlobalProfilesize); - - pData->iGlobalProfilesize = 0; -#endif - -#ifndef MNG_SKIPCHUNK_bKGD - pData->iGlobalBKGDred = 0; - pData->iGlobalBKGDgreen = 0; - pData->iGlobalBKGDblue = 0; -#endif - } - -#ifndef MNG_SKIPCHUNK_TERM - if (!pData->bMisplacedTERM) /* backward compatible ugliness !!! */ - { - pImage = (mng_imagep)pData->pFirstimgobj; - /* drop un-frozen image objects */ - while (pImage) - { - mng_imagep pNext = (mng_imagep)pImage->sHeader.pNext; - - if (!pImage->bFrozen) /* is it un-frozen ? */ - { - mng_imagep pPrev = (mng_imagep)pImage->sHeader.pPrev; - - if (pPrev) /* unlink it */ - pPrev->sHeader.pNext = pNext; - else - pData->pFirstimgobj = pNext; - - if (pNext) - pNext->sHeader.pPrev = pPrev; - else - pData->pLastimgobj = pPrev; - - if (pImage->pImgbuf->bFrozen) /* buffer frozen ? */ - { - if (pImage->pImgbuf->iRefcount < 2) - MNG_ERROR (pData, MNG_INTERNALERROR); - /* decrease ref counter */ - pImage->pImgbuf->iRefcount--; - /* just cleanup the object then */ - MNG_FREEX (pData, pImage, sizeof (mng_image)); - } - else - { /* free the image buffer */ - iRetcode = mng_free_imagedataobject (pData, pImage->pImgbuf); - /* and cleanup the object */ - MNG_FREEX (pData, pImage, sizeof (mng_image)); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - - pImage = pNext; /* neeeext */ - } - } -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_STATE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * General display processing routine * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode mng_process_display (mng_datap pData) -{ - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY, MNG_LC_START); -#endif - - if (!pData->iBreakpoint) /* not broken previously ? */ - { - if ((pData->iRequestframe) || (pData->iRequestlayer) || (pData->iRequesttime)) - { - pData->bSearching = MNG_TRUE; /* indicate we're searching */ - - iRetcode = clear_canvas (pData); /* make the canvas virgin black ?!? */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* let's start from the top, shall we */ - pData->pCurraniobj = pData->pFirstaniobj; - } - } - - do /* process the objects */ - { - if (pData->bSearching) /* clear timer-flag when searching !!! */ - pData->bTimerset = MNG_FALSE; - /* do we need to finish something first ? */ - if ((pData->iBreakpoint) && (pData->iBreakpoint < 99)) - { - switch (pData->iBreakpoint) /* return to broken display routine */ - { -#ifndef MNG_SKIPCHUNK_FRAM - case 1 : { iRetcode = mng_process_display_fram2 (pData); break; } -#endif -#ifndef MNG_SKIPCHUNK_SHOW - case 3 : ; /* same as 4 !!! */ - case 4 : { iRetcode = mng_process_display_show (pData); break; } -#endif -#ifndef MNG_SKIPCHUNK_CLON - case 5 : { iRetcode = mng_process_display_clon2 (pData); break; } -#endif -#ifndef MNG_SKIPCHUNK_MAGN - case 9 : { iRetcode = mng_process_display_magn2 (pData); break; } - case 10 : { iRetcode = mng_process_display_mend2 (pData); break; } -#endif -#ifndef MNG_SKIPCHUNK_PAST - case 11 : { iRetcode = mng_process_display_past2 (pData); break; } -#endif - default : MNG_ERROR (pData, MNG_INTERNALERROR); - } - } - else - { - if (pData->pCurraniobj) - iRetcode = ((mng_object_headerp)pData->pCurraniobj)->fProcess (pData, pData->pCurraniobj); - } - - if (!pData->bTimerset) /* reset breakpoint flag ? */ - pData->iBreakpoint = 0; - /* can we advance to next object ? */ - if ((!iRetcode) && (pData->pCurraniobj) && - (!pData->bTimerset) && (!pData->bSectionwait)) - { - pData->pCurraniobj = ((mng_object_headerp)pData->pCurraniobj)->pNext; - /* MEND processing to be done ? */ - if ((pData->eImagetype == mng_it_mng) && (!pData->pCurraniobj)) - iRetcode = mng_process_display_mend (pData); - - if (!pData->pCurraniobj) /* refresh after last image ? */ - pData->bNeedrefresh = MNG_TRUE; - } - - if (pData->bSearching) /* are we looking for something ? */ - { - if ((pData->iRequestframe) && (pData->iRequestframe <= pData->iFrameseq)) - { - pData->iRequestframe = 0; /* found the frame ! */ - pData->bSearching = MNG_FALSE; - } - else - if ((pData->iRequestlayer) && (pData->iRequestlayer <= pData->iLayerseq)) - { - pData->iRequestlayer = 0; /* found the layer ! */ - pData->bSearching = MNG_FALSE; - } - else - if ((pData->iRequesttime) && (pData->iRequesttime <= pData->iFrametime)) - { - pData->iRequesttime = 0; /* found the playtime ! */ - pData->bSearching = MNG_FALSE; - } - } - } /* until error or a break or no more objects */ - while ((!iRetcode) && (pData->pCurraniobj) && - (((pData->bRunning) && (!pData->bTimerset)) || (pData->bSearching)) && - (!pData->bSectionwait) && (!pData->bFreezing)); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* refresh needed ? */ - if ((!pData->bTimerset) && (pData->bNeedrefresh)) - { - iRetcode = mng_display_progressive_refresh (pData, 1); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - /* timer break ? */ - if ((pData->bTimerset) && (!pData->iBreakpoint)) - pData->iBreakpoint = 99; - else - if (!pData->bTimerset) - pData->iBreakpoint = 0; /* reset if no timer break */ - - if ((!pData->bTimerset) && (!pData->pCurraniobj)) - pData->bRunning = MNG_FALSE; /* all done now ! */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Chunk display processing routines * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_OPTIMIZE_FOOTPRINT_INIT -png_imgtype mng_png_imgtype(mng_uint8 colortype, mng_uint8 bitdepth) -{ - png_imgtype ret; - switch (bitdepth) - { -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case 1: - { - png_imgtype imgtype[]={png_g1,png_none,png_none,png_idx1}; - ret=imgtype[colortype]; - break; - } - case 2: - { - png_imgtype imgtype[]={png_g2,png_none,png_none,png_idx2}; - ret=imgtype[colortype]; - break; - } - case 4: - { - png_imgtype imgtype[]={png_g4,png_none,png_none,png_idx4}; - ret=imgtype[colortype]; - break; - } -#endif - case 8: - { - png_imgtype imgtype[]={png_g8,png_none,png_rgb8,png_idx8,png_ga8, - png_none,png_rgba8}; - ret=imgtype[colortype]; - break; - } -#ifndef MNG_NO_16BIT_SUPPORT - case 16: - { - png_imgtype imgtype[]={png_g16,png_none,png_rgb16,png_none,png_ga16, - png_none,png_rgba16}; - ret=imgtype[colortype]; - break; - } -#endif - default: - ret=png_none; - break; - } - return (ret); -} -#endif /* MNG_OPTIMIZE_FOOTPRINT_INIT */ - -/* ************************************************************************** */ - -mng_retcode mng_process_display_ihdr (mng_datap pData) -{ /* address the current "object" if any */ - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IHDR, MNG_LC_START); -#endif - - if (!pData->bHasDHDR) - { - pData->fInitrowproc = MNG_NULL; /* do nothing by default */ - pData->fDisplayrow = MNG_NULL; - pData->fCorrectrow = MNG_NULL; - pData->fStorerow = MNG_NULL; - pData->fProcessrow = MNG_NULL; - pData->fDifferrow = MNG_NULL; - pData->pStoreobj = MNG_NULL; - } - - if (!pData->iBreakpoint) /* not previously broken ? */ - { - mng_retcode iRetcode = MNG_NOERROR; - -#ifndef MNG_NO_DELTA_PNG - if (pData->bHasDHDR) /* is a delta-image ? */ - { - if (pData->iDeltatype == MNG_DELTATYPE_REPLACE) - iRetcode = mng_reset_object_details (pData, (mng_imagep)pData->pDeltaImage, - pData->iDatawidth, pData->iDataheight, - pData->iBitdepth, pData->iColortype, - pData->iCompression, pData->iFilter, - pData->iInterlace, MNG_TRUE); - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iPixelsampledepth = pData->iBitdepth; - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iAlphasampledepth = pData->iBitdepth; - } - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAREPLACE) ) - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iAlphasampledepth = pData->iBitdepth; - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORREPLACE) ) - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iPixelsampledepth = pData->iBitdepth; - - if (!iRetcode) - { /* process immediately if bitdepth & colortype are equal */ - pData->bDeltaimmediate = - (mng_bool)((pData->iBitdepth == ((mng_imagep)pData->pDeltaImage)->pImgbuf->iBitdepth ) && - (pData->iColortype == ((mng_imagep)pData->pDeltaImage)->pImgbuf->iColortype) ); - /* be sure to reset object 0 */ - iRetcode = mng_reset_object_details (pData, (mng_imagep)pData->pObjzero, - pData->iDatawidth, pData->iDataheight, - pData->iBitdepth, pData->iColortype, - pData->iCompression, pData->iFilter, - pData->iInterlace, MNG_TRUE); - } - } - else -#endif - { - if (pImage) /* update object buffer ? */ - iRetcode = mng_reset_object_details (pData, pImage, - pData->iDatawidth, pData->iDataheight, - pData->iBitdepth, pData->iColortype, - pData->iCompression, pData->iFilter, - pData->iInterlace, MNG_TRUE); - else - iRetcode = mng_reset_object_details (pData, (mng_imagep)pData->pObjzero, - pData->iDatawidth, pData->iDataheight, - pData->iBitdepth, pData->iColortype, - pData->iCompression, pData->iFilter, - pData->iInterlace, MNG_TRUE); - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - -#ifndef MNG_NO_DELTA_PNG - if (!pData->bHasDHDR) -#endif - { - if (pImage) /* real object ? */ - pData->pStoreobj = pImage; /* tell the row routines */ - else /* otherwise use object 0 */ - pData->pStoreobj = pData->pObjzero; - -#if !defined(MNG_INCLUDE_MPNG_PROPOSAL) && !defined(MNG_INCLUDE_ANG_PROPOSAL) - if ( /* display "on-the-fly" ? */ -#ifndef MNG_SKIPCHUNK_MAGN - (((mng_imagep)pData->pStoreobj)->iMAGN_MethodX == 0) && - (((mng_imagep)pData->pStoreobj)->iMAGN_MethodY == 0) && -#endif - ( (pData->eImagetype == mng_it_png ) || - (((mng_imagep)pData->pStoreobj)->bVisible) ) ) - { - next_layer (pData); /* that's a new layer then ! */ - - if (pData->bTimerset) /* timer break ? */ - pData->iBreakpoint = 2; - else - { - pData->iBreakpoint = 0; - /* anything to display ? */ - if ((pData->iDestr > pData->iDestl) && (pData->iDestb > pData->iDestt)) - set_display_routine (pData); /* then determine display routine */ - } - } -#endif - } - - if (!pData->bTimerset) /* no timer break ? */ - { -#ifdef MNG_OPTIMIZE_FOOTPRINT_INIT - pData->fInitrowproc = (mng_fptr)mng_init_rowproc; - pData->ePng_imgtype=mng_png_imgtype(pData->iColortype,pData->iBitdepth); -#else - switch (pData->iColortype) /* determine row initialization routine */ - { - case 0 : { /* gray */ - switch (pData->iBitdepth) - { -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case 1 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_g1_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_g1_i; - - break; - } - case 2 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_g2_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_g2_i; - - break; - } - case 4 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_g4_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_g4_i; - break; - } -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_g8_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_g8_i; - - break; - } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_g16_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_g16_i; - - break; - } -#endif - } - - break; - } - case 2 : { /* rgb */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_rgb8_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_rgb8_i; - break; - } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_rgb16_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_rgb16_i; - - break; - } -#endif - } - - break; - } - case 3 : { /* indexed */ - switch (pData->iBitdepth) - { -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case 1 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_idx1_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_idx1_i; - - break; - } - case 2 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_idx2_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_idx2_i; - - break; - } - case 4 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_idx4_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_idx4_i; - - break; - } -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_idx8_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_idx8_i; - - break; - } - } - - break; - } - case 4 : { /* gray+alpha */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_ga8_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_ga8_i; - - break; - } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_ga16_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_ga16_i; - break; - } -#endif - } - - break; - } - case 6 : { /* rgb+alpha */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_rgba8_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_rgba8_i; - - break; - } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_rgba16_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_rgba16_i; - - break; - } -#endif - } - - break; - } - } -#endif /* MNG_OPTIMIZE_FOOTPRINT_INIT */ - - pData->iFilterofs = 0; /* determine filter characteristics */ - pData->iLevel0 = 0; /* default levels */ - pData->iLevel1 = 0; - pData->iLevel2 = 0; - pData->iLevel3 = 0; - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - { - switch (pData->iColortype) - { - case 0 : { - if (pData->iBitdepth <= 8) - pData->iFilterofs = 1; - else - pData->iFilterofs = 2; - - break; - } - case 2 : { - if (pData->iBitdepth <= 8) - pData->iFilterofs = 3; - else - pData->iFilterofs = 6; - - break; - } - case 3 : { - pData->iFilterofs = 1; - break; - } - case 4 : { - if (pData->iBitdepth <= 8) - pData->iFilterofs = 2; - else - pData->iFilterofs = 4; - - break; - } - case 6 : { - if (pData->iBitdepth <= 8) - pData->iFilterofs = 4; - else - pData->iFilterofs = 8; - - break; - } - } - } -#endif - -#ifdef FILTER193 /* no adaptive filtering ? */ - if (pData->iFilter == MNG_FILTER_NOFILTER) - pData->iPixelofs = pData->iFilterofs; - else -#endif - pData->iPixelofs = pData->iFilterofs + 1; - - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_MPNG_PROPOSAL -mng_retcode mng_process_display_mpng (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MPNG, MNG_LC_START); -#endif - - pData->iAlphadepth = 8; /* assume transparency !! */ - - if (pData->fProcessheader) /* inform the app (creating the output canvas) ? */ - { - pData->iWidth = ((mng_mpng_objp)pData->pMPNG)->iFramewidth; - pData->iHeight = ((mng_mpng_objp)pData->pMPNG)->iFrameheight; - - if (!pData->fProcessheader (((mng_handle)pData), pData->iWidth, pData->iHeight)) - MNG_ERROR (pData, MNG_APPMISCERROR); - } - - next_layer (pData); /* first mPNG layer then ! */ - pData->bTimerset = MNG_FALSE; - pData->iBreakpoint = 0; - - if ((pData->iDestr > pData->iDestl) && (pData->iDestb > pData->iDestt)) - set_display_routine (pData); /* then determine display routine */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MPNG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ANG_PROPOSAL -mng_retcode mng_process_display_ang (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_ANG, MNG_LC_START); -#endif - - if (pData->fProcessheader) /* inform the app (creating the output canvas) ? */ - { - if (!pData->fProcessheader (((mng_handle)pData), pData->iWidth, pData->iHeight)) - MNG_ERROR (pData, MNG_APPMISCERROR); - } - - next_layer (pData); /* first mPNG layer then ! */ - pData->bTimerset = MNG_FALSE; - pData->iBreakpoint = 0; - - if ((pData->iDestr > pData->iDestl) && (pData->iDestb > pData->iDestt)) - set_display_routine (pData); /* then determine display routine */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_ANG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS -mng_retcode mng_process_display_idat (mng_datap pData, - mng_uint32 iRawlen, - mng_uint8p pRawdata) -#else -mng_retcode mng_process_display_idat (mng_datap pData) -#endif -{ - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IDAT, MNG_LC_START); -#endif - -#if defined(MNG_INCLUDE_MPNG_PROPOSAL) || defined(MNG_INCLUDE_ANG_PROPOSAL) - if ((pData->eImagetype == mng_it_png) && (pData->iLayerseq <= 0)) - { - if (pData->fProcessheader) /* inform the app (creating the output canvas) ? */ - if (!pData->fProcessheader (((mng_handle)pData), pData->iWidth, pData->iHeight)) - MNG_ERROR (pData, MNG_APPMISCERROR); - - next_layer (pData); /* first regular PNG layer then ! */ - pData->bTimerset = MNG_FALSE; - pData->iBreakpoint = 0; - - if ((pData->iDestr > pData->iDestl) && (pData->iDestb > pData->iDestt)) - set_display_routine (pData); /* then determine display routine */ - } -#endif - - if (pData->bRestorebkgd) /* need to restore the background ? */ - { - pData->bRestorebkgd = MNG_FALSE; - iRetcode = load_bkgdlayer (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - pData->iLayerseq++; /* and it counts as a layer then ! */ - } - - if (pData->fInitrowproc) /* need to initialize row processing? */ - { - iRetcode = ((mng_initrowproc)pData->fInitrowproc) (pData); - pData->fInitrowproc = MNG_NULL; /* only call this once !!! */ - } - - if ((!iRetcode) && (!pData->bInflating)) - /* initialize inflate */ - iRetcode = mngzlib_inflateinit (pData); - - if (!iRetcode) /* all ok? then inflate, my man */ -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - iRetcode = mngzlib_inflaterows (pData, iRawlen, pRawdata); -#else - iRetcode = mngzlib_inflaterows (pData, pData->iRawlen, pData->pRawdata); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IDAT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_process_display_iend (mng_datap pData) -{ - mng_retcode iRetcode, iRetcode2; - mng_bool bDodisplay = MNG_FALSE; - mng_bool bMagnify = MNG_FALSE; - mng_bool bCleanup = (mng_bool)(pData->iBreakpoint != 0); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IEND, MNG_LC_START); -#endif - -#ifdef MNG_INCLUDE_JNG /* progressive+alpha JNG can be displayed now */ - if ( (pData->bHasJHDR ) && - ( (pData->bJPEGprogressive) || (pData->bJPEGprogressive2)) && - ( (pData->eImagetype == mng_it_jng ) || - (((mng_imagep)pData->pStoreobj)->bVisible) ) && - ( (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) ) ) - bDodisplay = MNG_TRUE; -#endif - -#ifndef MNG_SKIPCHUNK_MAGN - if ( (pData->pStoreobj) && /* on-the-fly magnification ? */ - ( (((mng_imagep)pData->pStoreobj)->iMAGN_MethodX) || - (((mng_imagep)pData->pStoreobj)->iMAGN_MethodY) ) ) - bMagnify = MNG_TRUE; -#endif - - if ((pData->bHasBASI) || /* was it a BASI stream */ - (bDodisplay) || /* or should we display the JNG */ -#ifndef MNG_SKIPCHUNK_MAGN - (bMagnify) || /* or should we magnify it */ -#endif - /* or did we get broken here last time ? */ - ((pData->iBreakpoint) && (pData->iBreakpoint != 8))) - { - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* or was it object 0 ? */ - pImage = (mng_imagep)pData->pObjzero; - /* display it now then ? */ - if ((pImage->bVisible) && (pImage->bViewable)) - { /* ok, so do it */ - iRetcode = mng_display_image (pData, pImage, bDodisplay); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->bTimerset) /* timer break ? */ - pData->iBreakpoint = 6; - } - } -#ifndef MNG_NO_DELTA_PNG - else - if ((pData->bHasDHDR) || /* was it a DHDR stream */ - (pData->iBreakpoint == 8)) /* or did we get broken here last time ? */ - { - mng_imagep pImage = (mng_imagep)pData->pDeltaImage; - - if (!pData->iBreakpoint) - { /* perform the delta operations needed */ - iRetcode = mng_execute_delta_image (pData, pImage, (mng_imagep)pData->pObjzero); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - /* display it now then ? */ - if ((pImage->bVisible) && (pImage->bViewable)) - { /* ok, so do it */ - iRetcode = mng_display_image (pData, pImage, MNG_FALSE); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->bTimerset) /* timer break ? */ - pData->iBreakpoint = 8; - } - } -#endif - - if (!pData->bTimerset) /* can we continue ? */ - { - pData->iBreakpoint = 0; /* clear this flag now ! */ - - -#ifdef MNG_INCLUDE_MPNG_PROPOSAL - if (pData->eImagetype == mng_it_mpng) - { - pData->pCurraniobj = pData->pFirstaniobj; - } else -#endif -#ifdef MNG_INCLUDE_ANG_PROPOSAL - if (pData->eImagetype == mng_it_ang) - { - pData->pCurraniobj = pData->pFirstaniobj; - } else -#endif - { /* cleanup object 0 */ - mng_reset_object_details (pData, (mng_imagep)pData->pObjzero, - 0, 0, 0, 0, 0, 0, 0, MNG_TRUE); - } - - if (pData->bInflating) /* if we've been inflating */ - { /* cleanup row-processing, */ - iRetcode = mng_cleanup_rowproc (pData); - /* also cleanup inflate! */ - iRetcode2 = mngzlib_inflatefree (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - if (iRetcode2) - return iRetcode2; - } - -#ifdef MNG_INCLUDE_JNG - if (pData->bJPEGdecompress) /* if we've been decompressing JDAT */ - { /* cleanup row-processing, */ - iRetcode = mng_cleanup_rowproc (pData); - /* also cleanup decompress! */ - iRetcode2 = mngjpeg_decompressfree (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - if (iRetcode2) - return iRetcode2; - } - - if (pData->bJPEGdecompress2) /* if we've been decompressing JDAA */ - { /* cleanup row-processing, */ - iRetcode = mng_cleanup_rowproc (pData); - /* also cleanup decompress! */ - iRetcode2 = mngjpeg_decompressfree2 (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - if (iRetcode2) - return iRetcode2; - } -#endif - - if (bCleanup) /* if we got broken last time we need to cleanup */ - { - pData->bHasIHDR = MNG_FALSE; /* IEND signals the end for most ... */ - pData->bHasBASI = MNG_FALSE; - pData->bHasDHDR = MNG_FALSE; -#ifdef MNG_INCLUDE_JNG - pData->bHasJHDR = MNG_FALSE; - pData->bHasJSEP = MNG_FALSE; - pData->bHasJDAA = MNG_FALSE; - pData->bHasJDAT = MNG_FALSE; -#endif - pData->bHasPLTE = MNG_FALSE; - pData->bHasTRNS = MNG_FALSE; - pData->bHasGAMA = MNG_FALSE; - pData->bHasCHRM = MNG_FALSE; - pData->bHasSRGB = MNG_FALSE; - pData->bHasICCP = MNG_FALSE; - pData->bHasBKGD = MNG_FALSE; - pData->bHasIDAT = MNG_FALSE; - } - /* if the image was displayed on the fly, */ - /* we'll have to make the app refresh */ - if ((pData->eImagetype != mng_it_mng) && (pData->fDisplayrow)) - pData->bNeedrefresh = MNG_TRUE; - - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IEND, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -/* change in the MNG spec with regards to TERM delay & interframe_delay - as proposed by Adam M. Costello (option 4) and finalized by official vote - during december 2002 / check the 'mng-list' archives for more details */ - -mng_retcode mng_process_display_mend (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MEND, MNG_LC_START); -#endif - -#ifdef MNG_SUPPORT_DYNAMICMNG - if (pData->bStopafterseek) /* need to stop after this ? */ - { - pData->bFreezing = MNG_TRUE; /* stop processing on this one */ - pData->bRunningevent = MNG_FALSE; - pData->bStopafterseek = MNG_FALSE; - pData->bNeedrefresh = MNG_TRUE; /* make sure the last bit is displayed ! */ - } -#endif - -#ifndef MNG_SKIPCHUNK_TERM - /* TERM processed ? */ - if ((pData->bDisplaying) && (pData->bRunning) && - (pData->bHasTERM) && (pData->pTermaniobj)) - { - mng_retcode iRetcode; - mng_ani_termp pTERM; - /* get the right animation object ! */ - pTERM = (mng_ani_termp)pData->pTermaniobj; - - pData->iIterations++; /* increase iteration count */ - - switch (pTERM->iTermaction) /* determine what to do! */ - { - case 0 : { /* show last frame indefinitly */ - break; /* piece of cake, that is... */ - } - - case 1 : { /* cease displaying anything */ - /* max(1, TERM delay, interframe_delay) */ -#ifndef MNG_SKIPCHUNK_FRAM - if (pTERM->iDelay > pData->iFramedelay) - pData->iFramedelay = pTERM->iDelay; - if (!pData->iFramedelay) - pData->iFramedelay = 1; -#endif - - iRetcode = interframe_delay (pData); - /* no interframe_delay? then fake it */ - if ((!iRetcode) && (!pData->bTimerset)) - iRetcode = set_delay (pData, 1); - - if (iRetcode) - return iRetcode; - - pData->iBreakpoint = 10; - break; - } - - case 2 : { /* show first image after TERM */ - iRetcode = restore_state (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* notify the app ? */ - if (pData->fProcessmend) - if (!pData->fProcessmend ((mng_handle)pData, pData->iIterations, 0)) - MNG_ERROR (pData, MNG_APPMISCERROR); - - /* show first frame after TERM chunk */ - pData->pCurraniobj = pTERM; - pData->bOnlyfirstframe = MNG_TRUE; - pData->iFramesafterTERM = 0; - - /* max(1, TERM delay, interframe_delay) */ -#ifndef MNG_SKIPCHUNK_FRAM - if (pTERM->iDelay > pData->iFramedelay) - pData->iFramedelay = pTERM->iDelay; - if (!pData->iFramedelay) - pData->iFramedelay = 1; -#endif - - break; - } - - case 3 : { /* repeat */ - if ((pTERM->iItermax) && (pTERM->iItermax < 0x7FFFFFFF)) - pTERM->iItermax--; - - if (pTERM->iItermax) /* go back to TERM ? */ - { /* restore to initial or SAVE state */ - iRetcode = restore_state (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* notify the app ? */ - if (pData->fProcessmend) - if (!pData->fProcessmend ((mng_handle)pData, - pData->iIterations, pTERM->iItermax)) - MNG_ERROR (pData, MNG_APPMISCERROR); - - /* restart from TERM chunk */ - pData->pCurraniobj = pTERM; - - if (pTERM->iDelay) /* set the delay (?) */ - { - /* max(1, TERM delay, interframe_delay) */ -#ifndef MNG_SKIPCHUNK_FRAM - if (pTERM->iDelay > pData->iFramedelay) - pData->iFramedelay = pTERM->iDelay; - if (!pData->iFramedelay) - pData->iFramedelay = 1; -#endif - - pData->bNeedrefresh = MNG_TRUE; - } - } - else - { - switch (pTERM->iIteraction) - { - case 0 : { /* show last frame indefinitly */ - break; /* piece of cake, that is... */ - } - - case 1 : { /* cease displaying anything */ - /* max(1, TERM delay, interframe_delay) */ -#ifndef MNG_SKIPCHUNK_FRAM - if (pTERM->iDelay > pData->iFramedelay) - pData->iFramedelay = pTERM->iDelay; - if (!pData->iFramedelay) - pData->iFramedelay = 1; -#endif - - iRetcode = interframe_delay (pData); - /* no interframe_delay? then fake it */ - if ((!iRetcode) && (!pData->bTimerset)) - iRetcode = set_delay (pData, 1); - - if (iRetcode) - return iRetcode; - - pData->iBreakpoint = 10; - break; - } - - case 2 : { /* show first image after TERM */ - iRetcode = restore_state (pData); - /* on error bail out */ - if (iRetcode) - return iRetcode; - /* notify the app ? */ - if (pData->fProcessmend) - if (!pData->fProcessmend ((mng_handle)pData, - pData->iIterations, 0)) - MNG_ERROR (pData, MNG_APPMISCERROR); - - /* show first frame after TERM chunk */ - pData->pCurraniobj = pTERM; - pData->bOnlyfirstframe = MNG_TRUE; - pData->iFramesafterTERM = 0; - /* max(1, TERM delay, interframe_delay) */ -#ifndef MNG_SKIPCHUNK_FRAM - if (pTERM->iDelay > pData->iFramedelay) - pData->iFramedelay = pTERM->iDelay; - if (!pData->iFramedelay) - pData->iFramedelay = 1; -#endif - - break; - } - } - } - - break; - } - } - } -#endif /* MNG_SKIPCHUNK_TERM */ - /* just reading ? */ - if ((!pData->bDisplaying) && (pData->bReading)) - if (pData->fProcessmend) /* inform the app ? */ - if (!pData->fProcessmend ((mng_handle)pData, 0, 0)) - MNG_ERROR (pData, MNG_APPMISCERROR); - - if (!pData->pCurraniobj) /* always let the app refresh at the end ! */ - pData->bNeedrefresh = MNG_TRUE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MEND, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_process_display_mend2 (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MEND, MNG_LC_START); -#endif - -#ifndef MNG_SKIPCHUNK_FRAM - pData->bFrameclipping = MNG_FALSE; /* nothing to do but restore the app background */ -#endif - load_bkgdlayer (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MEND, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_DEFI -mng_retcode mng_process_display_defi (mng_datap pData) -{ - mng_imagep pImage; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_DEFI, MNG_LC_START); -#endif - - if (!pData->iDEFIobjectid) /* object id=0 ? */ - { - pImage = (mng_imagep)pData->pObjzero; - - if (pData->bDEFIhasdonotshow) - pImage->bVisible = (mng_bool)(pData->iDEFIdonotshow == 0); - - if (pData->bDEFIhasloca) - { - pImage->iPosx = pData->iDEFIlocax; - pImage->iPosy = pData->iDEFIlocay; - } - - if (pData->bDEFIhasclip) - { - pImage->bClipped = pData->bDEFIhasclip; - pImage->iClipl = pData->iDEFIclipl; - pImage->iClipr = pData->iDEFIclipr; - pImage->iClipt = pData->iDEFIclipt; - pImage->iClipb = pData->iDEFIclipb; - } - - pData->pCurrentobj = 0; /* not a real object ! */ - } - else - { /* already exists ? */ - pImage = (mng_imagep)mng_find_imageobject (pData, pData->iDEFIobjectid); - - if (!pImage) /* if not; create new */ - { - mng_retcode iRetcode = mng_create_imageobject (pData, pData->iDEFIobjectid, - (mng_bool)(pData->iDEFIconcrete == 1), - (mng_bool)(pData->iDEFIdonotshow == 0), - MNG_FALSE, 0, 0, 0, 0, 0, 0, 0, - pData->iDEFIlocax, pData->iDEFIlocay, - pData->bDEFIhasclip, - pData->iDEFIclipl, pData->iDEFIclipr, - pData->iDEFIclipt, pData->iDEFIclipb, - &pImage); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - else - { /* exists; then set new info */ - if (pData->bDEFIhasdonotshow) - pImage->bVisible = (mng_bool)(pData->iDEFIdonotshow == 0); - - pImage->bViewable = MNG_FALSE; - - if (pData->bDEFIhasloca) - { - pImage->iPosx = pData->iDEFIlocax; - pImage->iPosy = pData->iDEFIlocay; - } - - if (pData->bDEFIhasclip) - { - pImage->bClipped = pData->bDEFIhasclip; - pImage->iClipl = pData->iDEFIclipl; - pImage->iClipr = pData->iDEFIclipr; - pImage->iClipt = pData->iDEFIclipt; - pImage->iClipb = pData->iDEFIclipb; - } - - if (pData->bDEFIhasconcrete) - pImage->pImgbuf->bConcrete = (mng_bool)(pData->iDEFIconcrete == 1); - } - - pData->pCurrentobj = pImage; /* others may want to know this */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_DEFI, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_BASI -#ifndef MNG_OPTIMIZE_DISPLAYCALLS -mng_retcode mng_process_display_basi (mng_datap pData, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_bool bHasalpha, - mng_uint16 iAlpha, - mng_uint8 iViewable) -#else -mng_retcode mng_process_display_basi (mng_datap pData) -#endif -{ /* address the current "object" if any */ - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - mng_uint8p pWork; - mng_uint32 iX; - mng_imagedatap pBuf; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_BASI, MNG_LC_START); -#endif - - if (!pImage) /* or is it an "on-the-fly" image ? */ - pImage = (mng_imagep)pData->pObjzero; - /* address the object-buffer */ - pBuf = pImage->pImgbuf; - - pData->fDisplayrow = MNG_NULL; /* do nothing by default */ - pData->fCorrectrow = MNG_NULL; - pData->fStorerow = MNG_NULL; - pData->fProcessrow = MNG_NULL; - /* set parms now that they're known */ - iRetcode = mng_reset_object_details (pData, pImage, pData->iDatawidth, - pData->iDataheight, pData->iBitdepth, - pData->iColortype, pData->iCompression, - pData->iFilter, pData->iInterlace, MNG_FALSE); - if (iRetcode) /* on error bail out */ - return iRetcode; - /* save the viewable flag */ -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - pImage->bViewable = (mng_bool)(iViewable == 1); -#else - pImage->bViewable = (mng_bool)(pData->iBASIviewable == 1); -#endif - pBuf->bViewable = pImage->bViewable; - pData->pStoreobj = pImage; /* let row-routines know which object */ - - pWork = pBuf->pImgdata; /* fill the object-buffer with the specified - "color" sample */ - switch (pData->iColortype) /* depending on color_type & bit_depth */ - { - case 0 : { /* gray */ -#ifndef MNG_NO_16BIT_SUPPORT - if (pData->iBitdepth == 16) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iDatawidth * pData->iDataheight; - iX > 0;iX--) -#else - for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++) -#endif - { -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - mng_put_uint16 (pWork, iRed); -#else - mng_put_uint16 (pWork, pData->iBASIred); -#endif - pWork += 2; - } - } - else -#endif - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iDatawidth * pData->iDataheight; - iX > 0;iX--) -#else - for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++) -#endif - { -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - *pWork = (mng_uint8)iRed; -#else - *pWork = (mng_uint8)pData->iBASIred; -#endif - pWork++; - } - } - /* force tRNS ? */ -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - if ((bHasalpha) && (!iAlpha)) -#else - if ((pData->bBASIhasalpha) && (!pData->iBASIalpha)) -#endif - { - pBuf->bHasTRNS = MNG_TRUE; -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - pBuf->iTRNSgray = iRed; -#else - pBuf->iTRNSgray = pData->iBASIred; -#endif - } - - break; - } - - case 2 : { /* rgb */ -#ifndef MNG_NO_16BIT_SUPPORT - if (pData->iBitdepth == 16) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iDatawidth * pData->iDataheight; - iX > 0;iX--) -#else - for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++) -#endif - { -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - mng_put_uint16 (pWork, iRed ); - mng_put_uint16 (pWork+2, iGreen); - mng_put_uint16 (pWork+4, iBlue ); -#else - mng_put_uint16 (pWork, pData->iBASIred ); - mng_put_uint16 (pWork+2, pData->iBASIgreen); - mng_put_uint16 (pWork+4, pData->iBASIblue ); -#endif - pWork += 6; - } - } - else -#endif - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iDatawidth * pData->iDataheight; - iX > 0;iX--) -#else - for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++) -#endif - { -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - *pWork = (mng_uint8)iRed; - *(pWork+1) = (mng_uint8)iGreen; - *(pWork+2) = (mng_uint8)iBlue; -#else - *pWork = (mng_uint8)pData->iBASIred; - *(pWork+1) = (mng_uint8)pData->iBASIgreen; - *(pWork+2) = (mng_uint8)pData->iBASIblue; -#endif - pWork += 3; - } - } - /* force tRNS ? */ -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - if ((bHasalpha) && (!iAlpha)) -#else - if ((pData->bBASIhasalpha) && (!pData->iBASIalpha)) -#endif - { - pBuf->bHasTRNS = MNG_TRUE; -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - pBuf->iTRNSred = iRed; - pBuf->iTRNSgreen = iGreen; - pBuf->iTRNSblue = iBlue; -#else - pBuf->iTRNSred = pData->iBASIred; - pBuf->iTRNSgreen = pData->iBASIgreen; - pBuf->iTRNSblue = pData->iBASIblue; -#endif - } - - break; - } - - case 3 : { /* indexed */ - pBuf->bHasPLTE = MNG_TRUE; - - switch (pData->iBitdepth) - { - case 1 : { pBuf->iPLTEcount = 2; break; } - case 2 : { pBuf->iPLTEcount = 4; break; } - case 4 : { pBuf->iPLTEcount = 16; break; } - case 8 : { pBuf->iPLTEcount = 256; break; } - default : { pBuf->iPLTEcount = 1; break; } - } - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - pBuf->aPLTEentries [0].iRed = (mng_uint8)iRed; - pBuf->aPLTEentries [0].iGreen = (mng_uint8)iGreen; - pBuf->aPLTEentries [0].iBlue = (mng_uint8)iBlue; -#else - pBuf->aPLTEentries [0].iRed = (mng_uint8)pData->iBASIred; - pBuf->aPLTEentries [0].iGreen = (mng_uint8)pData->iBASIgreen; - pBuf->aPLTEentries [0].iBlue = (mng_uint8)pData->iBASIblue; -#endif - - for (iX = 1; iX < pBuf->iPLTEcount; iX++) - { - pBuf->aPLTEentries [iX].iRed = 0; - pBuf->aPLTEentries [iX].iGreen = 0; - pBuf->aPLTEentries [iX].iBlue = 0; - } - /* force tRNS ? */ -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - if ((bHasalpha) && (iAlpha < 255)) -#else - if ((pData->bBASIhasalpha) && (pData->iBASIalpha < 255)) -#endif - { - pBuf->bHasTRNS = MNG_TRUE; - pBuf->iTRNScount = 1; -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - pBuf->aTRNSentries [0] = (mng_uint8)iAlpha; -#else - pBuf->aTRNSentries [0] = (mng_uint8)pData->iBASIalpha; -#endif - } - - break; - } - - case 4 : { /* gray+alpha */ -#ifndef MNG_NO_16BIT_SUPPORT - if (pData->iBitdepth == 16) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iDatawidth * pData->iDataheight; - iX > 0;iX--) -#else - for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++) -#endif - { -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - mng_put_uint16 (pWork, iRed); - mng_put_uint16 (pWork+2, iAlpha); -#else - mng_put_uint16 (pWork, pData->iBASIred); - mng_put_uint16 (pWork+2, pData->iBASIalpha); -#endif - pWork += 4; - } - } - else -#endif - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iDatawidth * pData->iDataheight; - iX > 0;iX--) -#else - for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++) -#endif - { -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - *pWork = (mng_uint8)iRed; - *(pWork+1) = (mng_uint8)iAlpha; -#else - *pWork = (mng_uint8)pData->iBASIred; - *(pWork+1) = (mng_uint8)pData->iBASIalpha; -#endif - pWork += 2; - } - } - - break; - } - - case 6 : { /* rgb+alpha */ -#ifndef MNG_NO_16BIT_SUPPORT - if (pData->iBitdepth == 16) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iDatawidth * pData->iDataheight; - iX > 0;iX--) -#else - for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++) -#endif - { -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - mng_put_uint16 (pWork, iRed); - mng_put_uint16 (pWork+2, iGreen); - mng_put_uint16 (pWork+4, iBlue); - mng_put_uint16 (pWork+6, iAlpha); -#else - mng_put_uint16 (pWork, pData->iBASIred); - mng_put_uint16 (pWork+2, pData->iBASIgreen); - mng_put_uint16 (pWork+4, pData->iBASIblue); - mng_put_uint16 (pWork+6, pData->iBASIalpha); -#endif - pWork += 8; - } - } - else -#endif - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iDatawidth * pData->iDataheight; - iX > 0;iX--) -#else - for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++) -#endif - { -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - *pWork = (mng_uint8)iRed; - *(pWork+1) = (mng_uint8)iGreen; - *(pWork+2) = (mng_uint8)iBlue; - *(pWork+3) = (mng_uint8)iAlpha; -#else - *pWork = (mng_uint8)pData->iBASIred; - *(pWork+1) = (mng_uint8)pData->iBASIgreen; - *(pWork+2) = (mng_uint8)pData->iBASIblue; - *(pWork+3) = (mng_uint8)pData->iBASIalpha; -#endif - pWork += 4; - } - } - - break; - } - - } - -#ifdef MNG_OPTIMIZE_FOOTPRINT_INIT - pData->fInitrowproc = (mng_fptr)mng_init_rowproc; - pData->ePng_imgtype=mng_png_imgtype(pData->iColortype,pData->iBitdepth); -#else - switch (pData->iColortype) /* determine row initialization routine */ - { /* just to accomodate IDAT if it arrives */ - case 0 : { /* gray */ - switch (pData->iBitdepth) - { -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case 1 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_g1_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_g1_i; - - break; - } - case 2 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_g2_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_g2_i; - - break; - } - case 4 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_g4_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_g4_i; - - break; - } -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_g8_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_g8_i; - - break; - } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_g16_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_g16_i; - - break; - } -#endif - } - - break; - } - case 2 : { /* rgb */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_rgb8_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_rgb8_i; - - break; - } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_rgb16_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_rgb16_i; - - break; - } -#endif - } - - break; - } - case 3 : { /* indexed */ - switch (pData->iBitdepth) - { -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case 1 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_idx1_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_idx1_i; - - break; - } - case 2 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_idx2_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_idx2_i; - - break; - } - case 4 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_idx4_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_idx4_i; - - break; - } -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_idx8_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_idx8_i; - - break; - } - } - - break; - } - case 4 : { /* gray+alpha */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_ga8_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_ga8_i; - - break; - } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_ga16_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_ga16_i; - - break; - } -#endif - } - - break; - } - case 6 : { /* rgb+alpha */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_rgba8_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_rgba8_i; - - break; - } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_rgba16_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_rgba16_i; - - break; - } -#endif - } - - break; - } - } -#endif /* MNG_OPTIMIZE_FOOTPRINT_INIT */ - - pData->iFilterofs = 0; /* determine filter characteristics */ - pData->iLevel0 = 0; /* default levels */ - pData->iLevel1 = 0; - pData->iLevel2 = 0; - pData->iLevel3 = 0; - -#ifdef FILTER192 - if (pData->iFilter == 0xC0) /* leveling & differing ? */ - { - switch (pData->iColortype) - { - case 0 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (pData->iBitdepth <= 8) -#endif - pData->iFilterofs = 1; -#ifndef MNG_NO_16BIT_SUPPORT - else - pData->iFilterofs = 2; -#endif - - break; - } - case 2 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (pData->iBitdepth <= 8) -#endif - pData->iFilterofs = 3; -#ifndef MNG_NO_16BIT_SUPPORT - else - pData->iFilterofs = 6; -#endif - - break; - } - case 3 : { - pData->iFilterofs = 1; - break; - } - case 4 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (pData->iBitdepth <= 8) -#endif - pData->iFilterofs = 2; -#ifndef MNG_NO_16BIT_SUPPORT - else - pData->iFilterofs = 4; -#endif - - break; - } - case 6 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (pData->iBitdepth <= 8) -#endif - pData->iFilterofs = 4; -#ifndef MNG_NO_16BIT_SUPPORT - else - pData->iFilterofs = 8; -#endif - - break; - } - } - } -#endif - -#ifdef FILTER193 - if (pData->iFilter == 0xC1) /* no adaptive filtering ? */ - pData->iPixelofs = pData->iFilterofs; - else -#endif - pData->iPixelofs = pData->iFilterofs + 1; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_BASI, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_CLON -#ifndef MNG_OPTIMIZE_DISPLAYCALLS -mng_retcode mng_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) -#else -mng_retcode mng_process_display_clon (mng_datap pData) -#endif -{ - mng_imagep pSource, pClone; - mng_bool bVisible, bAbstract; - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_CLON, MNG_LC_START); -#endif -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - /* locate the source object first */ - pSource = mng_find_imageobject (pData, iSourceid); - /* check if the clone exists */ - pClone = mng_find_imageobject (pData, iCloneid); -#else - /* locate the source object first */ - pSource = mng_find_imageobject (pData, pData->iCLONsourceid); - /* check if the clone exists */ - pClone = mng_find_imageobject (pData, pData->iCLONcloneid); -#endif - - if (!pSource) /* source must exist ! */ - MNG_ERROR (pData, MNG_OBJECTUNKNOWN); - - if (pClone) /* clone must not exist ! */ - MNG_ERROR (pData, MNG_OBJECTEXISTS); - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - if (bHasdonotshow) /* DoNotShow flag filled ? */ - bVisible = (mng_bool)(iDonotshow == 0); - else - bVisible = pSource->bVisible; -#else - if (pData->bCLONhasdonotshow) /* DoNotShow flag filled ? */ - bVisible = (mng_bool)(pData->iCLONdonotshow == 0); - else - bVisible = pSource->bVisible; -#endif - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - bAbstract = (mng_bool)(iConcrete == 1); -#else - bAbstract = (mng_bool)(pData->iCLONconcrete == 1); -#endif - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - switch (iClonetype) /* determine action to take */ - { - case 0 : { /* full clone */ - iRetcode = mng_clone_imageobject (pData, iCloneid, MNG_FALSE, - bVisible, bAbstract, bHasloca, - iLocationtype, iLocationx, iLocationy, - pSource, &pClone); - break; - } - - case 1 : { /* partial clone */ - iRetcode = mng_clone_imageobject (pData, iCloneid, MNG_TRUE, - bVisible, bAbstract, bHasloca, - iLocationtype, iLocationx, iLocationy, - pSource, &pClone); - break; - } - - case 2 : { /* renumber object */ - iRetcode = mng_renum_imageobject (pData, pSource, iCloneid, - bVisible, bAbstract, bHasloca, - iLocationtype, iLocationx, iLocationy); - pClone = pSource; - break; - } - - } -#else - switch (pData->iCLONclonetype) /* determine action to take */ - { - case 0 : { /* full clone */ - iRetcode = mng_clone_imageobject (pData, pData->iCLONcloneid, MNG_FALSE, - bVisible, bAbstract, - pData->bCLONhasloca, pData->iCLONlocationtype, - pData->iCLONlocationx, pData->iCLONlocationy, - pSource, &pClone); - break; - } - - case 1 : { /* partial clone */ - iRetcode = mng_clone_imageobject (pData, pData->iCLONcloneid, MNG_TRUE, - bVisible, bAbstract, - pData->bCLONhasloca, pData->iCLONlocationtype, - pData->iCLONlocationx, pData->iCLONlocationy, - pSource, &pClone); - break; - } - - case 2 : { /* renumber object */ - iRetcode = mng_renum_imageobject (pData, pSource, pData->iCLONcloneid, - bVisible, bAbstract, - pData->bCLONhasloca, pData->iCLONlocationtype, - pData->iCLONlocationx, pData->iCLONlocationy); - pClone = pSource; - break; - } - - } -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - - /* display on the fly ? */ - if ((pClone->bViewable) && (pClone->bVisible)) - { - pData->pLastclone = pClone; /* remember in case of timer break ! */ - /* display it */ - mng_display_image (pData, pClone, MNG_FALSE); - - if (pData->bTimerset) /* timer break ? */ - pData->iBreakpoint = 5; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_CLON, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_process_display_clon2 (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_CLON, MNG_LC_START); -#endif - /* only called after timer break ! */ - mng_display_image (pData, (mng_imagep)pData->pLastclone, MNG_FALSE); - pData->iBreakpoint = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_CLON, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_DISC -#ifndef MNG_OPTIMIZE_DISPLAYCALLS -mng_retcode mng_process_display_disc (mng_datap pData, - mng_uint32 iCount, - mng_uint16p pIds) -#else -mng_retcode mng_process_display_disc (mng_datap pData) -#endif -{ - mng_uint32 iX; - mng_imagep pImage; - mng_uint32 iRetcode; -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_DISC, MNG_LC_START); -#endif - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - if (iCount) /* specific list ? */ -#else - if (pData->iDISCcount) /* specific list ? */ -#endif - { -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - mng_uint16p pWork = pIds; -#else - mng_uint16p pWork = pData->pDISCids; -#endif - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS -#ifdef MNG_DECREMENT_LOOPS /* iterate the list */ - for (iX = iCount; iX > 0; iX--) -#else - for (iX = 0; iX < iCount; iX++) -#endif -#else -#ifdef MNG_DECREMENT_LOOPS /* iterate the list */ - for (iX = pData->iDISCcount; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iDISCcount; iX++) -#endif -#endif - { - pImage = mng_find_imageobject (pData, *pWork++); - - if (pImage) /* found the object ? */ - { /* then drop it */ - iRetcode = mng_free_imageobject (pData, pImage); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - } - else /* empty: drop all un-frozen objects */ - { - mng_imagep pNext = (mng_imagep)pData->pFirstimgobj; - - while (pNext) /* any left ? */ - { - pImage = pNext; - pNext = pImage->sHeader.pNext; - - if (!pImage->bFrozen) /* not frozen ? */ - { /* then drop it */ - iRetcode = mng_free_imageobject (pData, pImage); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_DISC, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_FRAM -#ifndef MNG_OPTIMIZE_DISPLAYCALLS -mng_retcode mng_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) -#else -mng_retcode mng_process_display_fram (mng_datap pData) -#endif -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_FRAM, MNG_LC_START); -#endif - /* advance a frame then */ -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - iRetcode = next_frame (pData, iFramemode, iChangedelay, iDelay, - iChangetimeout, iTimeout, iChangeclipping, - iCliptype, iClipl, iClipr, iClipt, iClipb); -#else - iRetcode = next_frame (pData, pData->iTempFramemode, pData->iTempChangedelay, - pData->iTempDelay, pData->iTempChangetimeout, - pData->iTempTimeout, pData->iTempChangeclipping, - pData->iTempCliptype, pData->iTempClipl, pData->iTempClipr, - pData->iTempClipt, pData->iTempClipb); -#endif - - if (pData->bTimerset) /* timer break ? */ - pData->iBreakpoint = 1; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_FRAM, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -mng_retcode mng_process_display_fram2 (mng_datap pData) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_FRAM, MNG_LC_START); -#endif - /* again; after the break */ - iRetcode = next_frame (pData, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - pData->iBreakpoint = 0; /* not again! */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_FRAM, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_MOVE -#ifndef MNG_OPTIMIZE_DISPLAYCALLS -mng_retcode mng_process_display_move (mng_datap pData, - mng_uint16 iFromid, - mng_uint16 iToid, - mng_uint8 iMovetype, - mng_int32 iMovex, - mng_int32 iMovey) -#else -mng_retcode mng_process_display_move (mng_datap pData) -#endif -{ - mng_uint16 iX; - mng_imagep pImage; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MOVE, MNG_LC_START); -#endif - /* iterate the list */ -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - for (iX = iFromid; iX <= iToid; iX++) -#else - for (iX = pData->iMOVEfromid; iX <= pData->iMOVEtoid; iX++) -#endif - { - if (!iX) /* object id=0 ? */ - pImage = (mng_imagep)pData->pObjzero; - else - pImage = mng_find_imageobject (pData, iX); - - if (pImage) /* object exists ? */ - { -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - switch (iMovetype) -#else - switch (pData->iMOVEmovetype) -#endif - { - case 0 : { /* absolute */ -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - pImage->iPosx = iMovex; - pImage->iPosy = iMovey; -#else - pImage->iPosx = pData->iMOVEmovex; - pImage->iPosy = pData->iMOVEmovey; -#endif - break; - } - case 1 : { /* relative */ -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - pImage->iPosx = pImage->iPosx + iMovex; - pImage->iPosy = pImage->iPosy + iMovey; -#else - pImage->iPosx = pImage->iPosx + pData->iMOVEmovex; - pImage->iPosy = pImage->iPosy + pData->iMOVEmovey; -#endif - break; - } - } - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MOVE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_CLIP -#ifndef MNG_OPTIMIZE_DISPLAYCALLS -mng_retcode mng_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) -#else -mng_retcode mng_process_display_clip (mng_datap pData) -#endif -{ - mng_uint16 iX; - mng_imagep pImage; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_CLIP, MNG_LC_START); -#endif - /* iterate the list */ -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - for (iX = iFromid; iX <= iToid; iX++) -#else - for (iX = pData->iCLIPfromid; iX <= pData->iCLIPtoid; iX++) -#endif - { - if (!iX) /* object id=0 ? */ - pImage = (mng_imagep)pData->pObjzero; - else - pImage = mng_find_imageobject (pData, iX); - - if (pImage) /* object exists ? */ - { -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - switch (iCliptype) -#else - switch (pData->iCLIPcliptype) -#endif - { - case 0 : { /* absolute */ - pImage->bClipped = MNG_TRUE; -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - pImage->iClipl = iClipl; - pImage->iClipr = iClipr; - pImage->iClipt = iClipt; - pImage->iClipb = iClipb; -#else - pImage->iClipl = pData->iCLIPclipl; - pImage->iClipr = pData->iCLIPclipr; - pImage->iClipt = pData->iCLIPclipt; - pImage->iClipb = pData->iCLIPclipb; -#endif - break; - } - case 1 : { /* relative */ - pImage->bClipped = MNG_TRUE; -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - pImage->iClipl = pImage->iClipl + iClipl; - pImage->iClipr = pImage->iClipr + iClipr; - pImage->iClipt = pImage->iClipt + iClipt; - pImage->iClipb = pImage->iClipb + iClipb; -#else - pImage->iClipl = pImage->iClipl + pData->iCLIPclipl; - pImage->iClipr = pImage->iClipr + pData->iCLIPclipr; - pImage->iClipt = pImage->iClipt + pData->iCLIPclipt; - pImage->iClipb = pImage->iClipb + pData->iCLIPclipb; -#endif - break; - } - } - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_CLIP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SHOW -mng_retcode mng_process_display_show (mng_datap pData) -{ - mng_int16 iX, iS, iFrom, iTo; - mng_imagep pImage; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_SHOW, MNG_LC_START); -#endif - - /* TODO: optimization for the cases where "abs (iTo - iFrom)" is rather high; - especially where ((iFrom==1) && (iTo==65535)); eg. an empty SHOW !!! */ - - if (pData->iBreakpoint == 3) /* previously broken during cycle-mode ? */ - { - pImage = mng_find_imageobject (pData, pData->iSHOWnextid); - - if (pImage) /* still there ? */ - mng_display_image (pData, pImage, MNG_FALSE); - - pData->iBreakpoint = 0; /* let's not go through this again! */ - } - else - { - if (pData->iBreakpoint) /* previously broken at other point ? */ - { /* restore last parms */ - iFrom = (mng_int16)pData->iSHOWfromid; - iTo = (mng_int16)pData->iSHOWtoid; - iX = (mng_int16)pData->iSHOWnextid; - iS = (mng_int16)pData->iSHOWskip; - } - else - { /* regular sequence ? */ - if (pData->iSHOWtoid >= pData->iSHOWfromid) - iS = 1; - else /* reverse sequence ! */ - iS = -1; - - iFrom = (mng_int16)pData->iSHOWfromid; - iTo = (mng_int16)pData->iSHOWtoid; - iX = iFrom; - - pData->iSHOWfromid = (mng_uint16)iFrom; - pData->iSHOWtoid = (mng_uint16)iTo; - pData->iSHOWskip = iS; - } - /* cycle mode ? */ - if ((pData->iSHOWmode == 6) || (pData->iSHOWmode == 7)) - { - mng_uint16 iTrigger = 0; - mng_uint16 iFound = 0; - mng_uint16 iPass = 0; - mng_imagep pFound = 0; - - do - { - iPass++; /* lets prevent endless loops when there - are no potential candidates in the list! */ - - if (iS > 0) /* forward ? */ - { - for (iX = iFrom; iX <= iTo; iX += iS) - { - pImage = mng_find_imageobject (pData, (mng_uint16)iX); - - if (pImage) /* object exists ? */ - { - if (iFound) /* already found a candidate ? */ - pImage->bVisible = MNG_FALSE; - else - if (iTrigger) /* found the trigger ? */ - { - pImage->bVisible = MNG_TRUE; - iFound = iX; - pFound = pImage; - } - else - if (pImage->bVisible) /* ok, this is the trigger */ - { - pImage->bVisible = MNG_FALSE; - iTrigger = iX; - } - } - } - } - else - { - for (iX = iFrom; iX >= iTo; iX += iS) - { - pImage = mng_find_imageobject (pData, (mng_uint16)iX); - - if (pImage) /* object exists ? */ - { - if (iFound) /* already found a candidate ? */ - pImage->bVisible = MNG_FALSE; - else - if (iTrigger) /* found the trigger ? */ - { - pImage->bVisible = MNG_TRUE; - iFound = iX; - pFound = pImage; - } - else - if (pImage->bVisible) /* ok, this is the trigger */ - { - pImage->bVisible = MNG_FALSE; - iTrigger = iX; - } - } - } - } - - if (!iTrigger) /* did not find a trigger ? */ - iTrigger = 1; /* then fake it so the first image - gets nominated */ - } /* cycle back to beginning ? */ - while ((iPass < 2) && (iTrigger) && (!iFound)); - - pData->iBreakpoint = 0; /* just a sanity precaution */ - /* display it ? */ - if ((pData->iSHOWmode == 6) && (pFound)) - { - mng_display_image (pData, pFound, MNG_FALSE); - - if (pData->bTimerset) /* timer set ? */ - { - pData->iBreakpoint = 3; - pData->iSHOWnextid = iFound; /* save it for after the break */ - } - } - } - else - { - do - { - pImage = mng_find_imageobject (pData, iX); - - if (pImage) /* object exists ? */ - { - if (pData->iBreakpoint) /* did we get broken last time ? */ - { /* could only happen in the display routine */ - mng_display_image (pData, pImage, MNG_FALSE); - pData->iBreakpoint = 0; /* only once inside this loop please ! */ - } - else - { - switch (pData->iSHOWmode) /* do what ? */ - { - case 0 : { - pImage->bVisible = MNG_TRUE; - mng_display_image (pData, pImage, MNG_FALSE); - break; - } - case 1 : { - pImage->bVisible = MNG_FALSE; - break; - } - case 2 : { - if (pImage->bVisible) - mng_display_image (pData, pImage, MNG_FALSE); - break; - } - case 3 : { - pImage->bVisible = MNG_TRUE; - break; - } - case 4 : { - pImage->bVisible = (mng_bool)(!pImage->bVisible); - if (pImage->bVisible) - mng_display_image (pData, pImage, MNG_FALSE); - break; - } - case 5 : { - pImage->bVisible = (mng_bool)(!pImage->bVisible); - } - } - } - } - - if (!pData->bTimerset) /* next ? */ - iX += iS; - - } /* continue ? */ - while ((!pData->bTimerset) && (((iS > 0) && (iX <= iTo)) || - ((iS < 0) && (iX >= iTo)) )); - - if (pData->bTimerset) /* timer set ? */ - { - pData->iBreakpoint = 4; - pData->iSHOWnextid = iX; /* save for next time */ - } - else - pData->iBreakpoint = 0; - - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_SHOW, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SAVE -mng_retcode mng_process_display_save (mng_datap pData) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_SAVE, MNG_LC_START); -#endif - - iRetcode = save_state (pData); /* save the current state */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_SAVE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SEEK -mng_retcode mng_process_display_seek (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_SEEK, MNG_LC_START); -#endif - -#ifdef MNG_SUPPORT_DYNAMICMNG - if (pData->bStopafterseek) /* need to stop after this SEEK ? */ - { - pData->bFreezing = MNG_TRUE; /* stop processing on this one */ - pData->bRunningevent = MNG_FALSE; - pData->bStopafterseek = MNG_FALSE; - pData->bNeedrefresh = MNG_TRUE; /* make sure the last bit is displayed ! */ - } - else -#endif - { /* restore the initial or SAVE state */ - mng_retcode iRetcode = restore_state (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_DYNAMICMNG - /* stop after next SEEK ? */ - if ((pData->bDynamic) || (pData->bRunningevent)) - pData->bStopafterseek = MNG_TRUE; -#endif - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_SEEK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_retcode mng_process_display_jhdr (mng_datap pData) -{ /* address the current "object" if any */ - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_JHDR, MNG_LC_START); -#endif - - if (!pData->bHasDHDR) - { - pData->fInitrowproc = MNG_NULL; /* do nothing by default */ - pData->fDisplayrow = MNG_NULL; - pData->fCorrectrow = MNG_NULL; - pData->fStorerow = MNG_NULL; - pData->fProcessrow = MNG_NULL; - pData->fDifferrow = MNG_NULL; - pData->fStorerow2 = MNG_NULL; - pData->fStorerow3 = MNG_NULL; - - pData->pStoreobj = MNG_NULL; /* initialize important work-parms */ - - pData->iJPEGrow = 0; - pData->iJPEGalpharow = 0; - pData->iJPEGrgbrow = 0; - pData->iRowmax = 0; /* so init_rowproc does the right thing ! */ - } - - if (!pData->iBreakpoint) /* not previously broken ? */ - { -#ifndef MNG_NO_DELTA_PNG - if (pData->bHasDHDR) /* delta-image ? */ - { - if (pData->iDeltatype == MNG_DELTATYPE_REPLACE) - { - iRetcode = mng_reset_object_details (pData, (mng_imagep)pData->pDeltaImage, - pData->iDatawidth, pData->iDataheight, - pData->iJHDRimgbitdepth, pData->iJHDRcolortype, - pData->iJHDRalphacompression, pData->iJHDRalphafilter, - pData->iJHDRalphainterlace, MNG_TRUE); - - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iAlphabitdepth = pData->iJHDRalphabitdepth; - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iJHDRcompression = pData->iJHDRimgcompression; - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iJHDRinterlace = pData->iJHDRimginterlace; - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iAlphasampledepth = pData->iJHDRalphabitdepth; - } - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iPixelsampledepth = pData->iJHDRimgbitdepth; - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iAlphasampledepth = pData->iJHDRalphabitdepth; - } - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAREPLACE) ) - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iAlphasampledepth = pData->iJHDRalphabitdepth; - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORREPLACE) ) - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iPixelsampledepth = pData->iJHDRimgbitdepth; - - } - else -#endif /* MNG_NO_DELTA_PNG */ - { - if (pImage) /* update object buffer ? */ - { - iRetcode = mng_reset_object_details (pData, pImage, - pData->iDatawidth, pData->iDataheight, - pData->iJHDRimgbitdepth, pData->iJHDRcolortype, - pData->iJHDRalphacompression, pData->iJHDRalphafilter, - pData->iJHDRalphainterlace, MNG_TRUE); - - pImage->pImgbuf->iAlphabitdepth = pData->iJHDRalphabitdepth; - pImage->pImgbuf->iJHDRcompression = pData->iJHDRimgcompression; - pImage->pImgbuf->iJHDRinterlace = pData->iJHDRimginterlace; - pImage->pImgbuf->iAlphasampledepth = pData->iJHDRalphabitdepth; - } - else /* update object 0 */ - { - iRetcode = mng_reset_object_details (pData, (mng_imagep)pData->pObjzero, - pData->iDatawidth, pData->iDataheight, - pData->iJHDRimgbitdepth, pData->iJHDRcolortype, - pData->iJHDRalphacompression, pData->iJHDRalphafilter, - pData->iJHDRalphainterlace, MNG_TRUE); - - ((mng_imagep)pData->pObjzero)->pImgbuf->iAlphabitdepth = pData->iJHDRalphabitdepth; - ((mng_imagep)pData->pObjzero)->pImgbuf->iJHDRcompression = pData->iJHDRimgcompression; - ((mng_imagep)pData->pObjzero)->pImgbuf->iJHDRinterlace = pData->iJHDRimginterlace; - ((mng_imagep)pData->pObjzero)->pImgbuf->iAlphasampledepth = pData->iJHDRalphabitdepth; - } - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - if (!pData->bHasDHDR) - { /* we're always storing a JPEG */ - if (pImage) /* real object ? */ - pData->pStoreobj = pImage; /* tell the row routines */ - else /* otherwise use object 0 */ - pData->pStoreobj = pData->pObjzero; - /* display "on-the-fly" ? */ - if ( -#ifndef MNG_SKIPCHUNK_MAGN - ( ((mng_imagep)pData->pStoreobj)->iMAGN_MethodX == 0) && - ( ((mng_imagep)pData->pStoreobj)->iMAGN_MethodY == 0) && -#endif - ( (pData->eImagetype == mng_it_jng ) || - (((mng_imagep)pData->pStoreobj)->bVisible) ) ) - { - next_layer (pData); /* that's a new layer then ! */ - - pData->iBreakpoint = 0; - - if (pData->bTimerset) /* timer break ? */ - pData->iBreakpoint = 7; - else - if (pData->bRunning) /* still running ? */ - { /* anything to display ? */ - if ((pData->iDestr > pData->iDestl) && (pData->iDestb > pData->iDestt)) - { - set_display_routine (pData); /* then determine display routine */ - /* display from the object we store in */ - pData->pRetrieveobj = pData->pStoreobj; - } - } - } - } - - if (!pData->bTimerset) /* no timer break ? */ - { /* default row initialization ! */ -#ifdef MNG_OPTIMIZE_FOOTPRINT_INIT - pData->ePng_imgtype=png_none; -#endif - pData->fInitrowproc = (mng_fptr)mng_init_rowproc; - - if ((!pData->bHasDHDR) || (pData->iDeltatype == MNG_DELTATYPE_REPLACE)) - { /* 8-bit JPEG ? */ - if (pData->iJHDRimgbitdepth == 8) - { /* intermediate row is 8-bit deep */ - pData->bIsRGBA16 = MNG_FALSE; - pData->iRowsamples = pData->iDatawidth; - - switch (pData->iJHDRcolortype) /* determine pixel processing routines */ - { - case MNG_COLORTYPE_JPEGGRAY : - { - pData->fStorerow2 = (mng_fptr)mng_store_jpeg_g8; - pData->fRetrieverow = (mng_fptr)mng_retrieve_g8; - pData->bIsOpaque = MNG_TRUE; - break; - } - case MNG_COLORTYPE_JPEGCOLOR : - { - pData->fStorerow2 = (mng_fptr)mng_store_jpeg_rgb8; - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgb8; - pData->bIsOpaque = MNG_TRUE; - break; - } - case MNG_COLORTYPE_JPEGGRAYA : - { - pData->fStorerow2 = (mng_fptr)mng_store_jpeg_ga8; - pData->fRetrieverow = (mng_fptr)mng_retrieve_ga8; - pData->bIsOpaque = MNG_FALSE; - break; - } - case MNG_COLORTYPE_JPEGCOLORA : - { - pData->fStorerow2 = (mng_fptr)mng_store_jpeg_rgba8; - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgba8; - pData->bIsOpaque = MNG_FALSE; - break; - } - } - } -#ifndef MNG_NO_16BIT_SUPPORT - else - { - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - - /* TODO: 12-bit JPEG */ - /* TODO: 8- + 12-bit JPEG (eg. type=20) */ - - } -#endif - /* possible IDAT alpha-channel ? */ - if (pData->iJHDRalphacompression == MNG_COMPRESSION_DEFLATE) - { - /* determine alpha processing routine */ -#ifdef MNG_OPTIMIZE_FOOTPRINT_INIT - pData->fInitrowproc = (mng_fptr)mng_init_rowproc; -#endif - switch (pData->iJHDRalphabitdepth) - { -#ifndef MNG_OPTIMIZE_FOOTPRINT_INIT -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case 1 : { pData->fInitrowproc = (mng_fptr)mng_init_jpeg_a1_ni; break; } - case 2 : { pData->fInitrowproc = (mng_fptr)mng_init_jpeg_a2_ni; break; } - case 4 : { pData->fInitrowproc = (mng_fptr)mng_init_jpeg_a4_ni; break; } -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case 8 : { pData->fInitrowproc = (mng_fptr)mng_init_jpeg_a8_ni; break; } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { pData->fInitrowproc = (mng_fptr)mng_init_jpeg_a16_ni; break; } -#endif -#else -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case 1 : { pData->ePng_imgtype = png_jpeg_a1; break; } - case 2 : { pData->ePng_imgtype = png_jpeg_a2; break; } - case 4 : { pData->ePng_imgtype = png_jpeg_a4; break; } -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case 8 : { pData->ePng_imgtype = png_jpeg_a8; break; } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { pData->ePng_imgtype = png_jpeg_a16; break; } -#endif -#endif - } - } - else /* possible JDAA alpha-channel ? */ - if (pData->iJHDRalphacompression == MNG_COMPRESSION_BASELINEJPEG) - { /* 8-bit JPEG ? */ - if (pData->iJHDRimgbitdepth == 8) - { - if (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA) - pData->fStorerow3 = (mng_fptr)mng_store_jpeg_g8_alpha; - else - if (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) - pData->fStorerow3 = (mng_fptr)mng_store_jpeg_rgb8_alpha; - } - else - { - /* TODO: 12-bit JPEG with 8-bit JDAA */ - } - } - /* initialize JPEG library */ - iRetcode = mngjpeg_initialize (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - else - { /* must be alpha add/replace !! */ - if ((pData->iDeltatype != MNG_DELTATYPE_BLOCKALPHAADD ) && - (pData->iDeltatype != MNG_DELTATYPE_BLOCKALPHAREPLACE) ) - MNG_ERROR (pData, MNG_INVDELTATYPE); - /* determine alpha processing routine */ -#ifdef MNG_OPTIMIZE_FOOTPRINT_INIT - pData->fInitrowproc = (mng_fptr)mng_init_rowproc; -#endif - switch (pData->iJHDRalphabitdepth) - { -#ifndef MNG_OPTIMIZE_FOOTPRINT_INIT -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case 1 : { pData->fInitrowproc = (mng_fptr)mng_init_g1_ni; break; } - case 2 : { pData->fInitrowproc = (mng_fptr)mng_init_g2_ni; break; } - case 4 : { pData->fInitrowproc = (mng_fptr)mng_init_g4_ni; break; } -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case 8 : { pData->fInitrowproc = (mng_fptr)mng_init_g8_ni; break; } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { pData->fInitrowproc = (mng_fptr)mng_init_g16_ni; break; } -#endif -#else -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case 1 : { pData->ePng_imgtype = png_jpeg_a1; break; } - case 2 : { pData->ePng_imgtype = png_jpeg_a2; break; } - case 4 : { pData->ePng_imgtype = png_jpeg_a4; break; } -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case 8 : { pData->ePng_imgtype = png_jpeg_a8; break; } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { pData->ePng_imgtype = png_jpeg_a16; break; } -#endif -#endif /* MNG_OPTIMIZE_FOOTPRINT_INIT */ - } - } - - pData->iFilterofs = 0; /* determine filter characteristics */ - pData->iLevel0 = 0; /* default levels */ - pData->iLevel1 = 0; - pData->iLevel2 = 0; - pData->iLevel3 = 0; - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iJHDRalphafilter == 0xC0) - { - if (pData->iJHDRalphabitdepth <= 8) - pData->iFilterofs = 1; - else - pData->iFilterofs = 2; - - } -#endif -#ifdef FILTER193 /* no adaptive filtering ? */ - if (pData->iJHDRalphafilter == 0xC1) - pData->iPixelofs = pData->iFilterofs; - else -#endif - pData->iPixelofs = pData->iFilterofs + 1; - - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_JHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -#ifndef MNG_OPTIMIZE_DISPLAYCALLS -mng_retcode mng_process_display_jdaa (mng_datap pData, - mng_uint32 iRawlen, - mng_uint8p pRawdata) -#else -mng_retcode mng_process_display_jdaa (mng_datap pData) -#endif -{ - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_JDAA, MNG_LC_START); -#endif - - if (!pData->bJPEGdecompress2) /* if we're not decompressing already */ - { - if (pData->fInitrowproc) /* initialize row-processing? */ - { - iRetcode = ((mng_initrowproc)pData->fInitrowproc) (pData); - pData->fInitrowproc = MNG_NULL; /* only call this once !!! */ - } - - if (!iRetcode) /* initialize decompress */ - iRetcode = mngjpeg_decompressinit2 (pData); - } - - if (!iRetcode) /* all ok? then decompress, my man */ -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - iRetcode = mngjpeg_decompressdata2 (pData, iRawlen, pRawdata); -#else - iRetcode = mngjpeg_decompressdata2 (pData, pData->iRawlen, pData->pRawdata); -#endif - - if (iRetcode) - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_JDAA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -#ifndef MNG_OPTIMIZE_DISPLAYCALLS -mng_retcode mng_process_display_jdat (mng_datap pData, - mng_uint32 iRawlen, - mng_uint8p pRawdata) -#else -mng_retcode mng_process_display_jdat (mng_datap pData) -#endif -{ - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_JDAT, MNG_LC_START); -#endif - - if (pData->bRestorebkgd) /* need to restore the background ? */ - { - pData->bRestorebkgd = MNG_FALSE; - iRetcode = load_bkgdlayer (pData); - - pData->iLayerseq++; /* and it counts as a layer then ! */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - if (!pData->bJPEGdecompress) /* if we're not decompressing already */ - { - if (pData->fInitrowproc) /* initialize row-processing? */ - { - iRetcode = ((mng_initrowproc)pData->fInitrowproc) (pData); - pData->fInitrowproc = MNG_NULL; /* only call this once !!! */ - } - - if (!iRetcode) /* initialize decompress */ - iRetcode = mngjpeg_decompressinit (pData); - } - - if (!iRetcode) /* all ok? then decompress, my man */ -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - iRetcode = mngjpeg_decompressdata (pData, iRawlen, pRawdata); -#else - iRetcode = mngjpeg_decompressdata (pData, pData->iRawlen, pData->pRawdata); -#endif - - if (iRetcode) - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_JDAT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_OPTIMIZE_DISPLAYCALLS -mng_retcode mng_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) -#else -mng_retcode mng_process_display_dhdr (mng_datap pData) -#endif -{ - mng_imagep pImage; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_DHDR, MNG_LC_START); -#endif - - pData->fInitrowproc = MNG_NULL; /* do nothing by default */ - pData->fDisplayrow = MNG_NULL; - pData->fCorrectrow = MNG_NULL; - pData->fStorerow = MNG_NULL; - pData->fProcessrow = MNG_NULL; - pData->pStoreobj = MNG_NULL; - - pData->fDeltagetrow = MNG_NULL; - pData->fDeltaaddrow = MNG_NULL; - pData->fDeltareplacerow = MNG_NULL; - pData->fDeltaputrow = MNG_NULL; - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - pImage = mng_find_imageobject (pData, iObjectid); -#else - pImage = mng_find_imageobject (pData, pData->iDHDRobjectid); -#endif - - if (pImage) /* object exists ? */ - { - if (pImage->pImgbuf->bConcrete) /* is it concrete ? */ - { /* previous magnification to be done ? */ -#ifndef MNG_SKIPCHUNK_MAGN - if ((pImage->iMAGN_MethodX) || (pImage->iMAGN_MethodY)) - { - iRetcode = mng_magnify_imageobject (pData, pImage); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif - /* save delta fields */ - pData->pDeltaImage = (mng_ptr)pImage; -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - pData->iDeltaImagetype = iImagetype; - pData->iDeltatype = iDeltatype; - pData->iDeltaBlockwidth = iBlockwidth; - pData->iDeltaBlockheight = iBlockheight; - pData->iDeltaBlockx = iBlockx; - pData->iDeltaBlocky = iBlocky; -#else - pData->iDeltaImagetype = pData->iDHDRimagetype; - pData->iDeltatype = pData->iDHDRdeltatype; - pData->iDeltaBlockwidth = pData->iDHDRblockwidth; - pData->iDeltaBlockheight = pData->iDHDRblockheight; - pData->iDeltaBlockx = pData->iDHDRblockx; - pData->iDeltaBlocky = pData->iDHDRblocky; -#endif - /* restore target-object fields */ - pData->iDatawidth = pImage->pImgbuf->iWidth; - pData->iDataheight = pImage->pImgbuf->iHeight; - pData->iBitdepth = pImage->pImgbuf->iBitdepth; - pData->iColortype = pImage->pImgbuf->iColortype; - pData->iCompression = pImage->pImgbuf->iCompression; - pData->iFilter = pImage->pImgbuf->iFilter; - pData->iInterlace = pImage->pImgbuf->iInterlace; - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - if ((iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD ) || - (iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - pData->iBitdepth = pImage->pImgbuf->iPixelsampledepth; - else - if ((iDeltatype == MNG_DELTATYPE_BLOCKALPHAADD ) || - (iDeltatype == MNG_DELTATYPE_BLOCKALPHAREPLACE) ) - pData->iBitdepth = pImage->pImgbuf->iAlphasampledepth; - else - if ((iDeltatype == MNG_DELTATYPE_BLOCKCOLORADD ) || - (iDeltatype == MNG_DELTATYPE_BLOCKCOLORREPLACE) ) - pData->iBitdepth = pImage->pImgbuf->iPixelsampledepth; -#else - if ((pData->iDHDRdeltatype == MNG_DELTATYPE_BLOCKPIXELADD ) || - (pData->iDHDRdeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - pData->iBitdepth = pImage->pImgbuf->iPixelsampledepth; - else - if ((pData->iDHDRdeltatype == MNG_DELTATYPE_BLOCKALPHAADD ) || - (pData->iDHDRdeltatype == MNG_DELTATYPE_BLOCKALPHAREPLACE) ) - pData->iBitdepth = pImage->pImgbuf->iAlphasampledepth; - else - if ((pData->iDHDRdeltatype == MNG_DELTATYPE_BLOCKCOLORADD ) || - (pData->iDHDRdeltatype == MNG_DELTATYPE_BLOCKCOLORREPLACE) ) - pData->iBitdepth = pImage->pImgbuf->iPixelsampledepth; -#endif - -#ifdef MNG_INCLUDE_JNG - pData->iJHDRimgbitdepth = pImage->pImgbuf->iBitdepth; - pData->iJHDRcolortype = pImage->pImgbuf->iColortype; - pData->iJHDRimgcompression = pImage->pImgbuf->iJHDRcompression; - pData->iJHDRimginterlace = pImage->pImgbuf->iJHDRinterlace; - pData->iJHDRalphacompression = pImage->pImgbuf->iCompression; - pData->iJHDRalphafilter = pImage->pImgbuf->iFilter; - pData->iJHDRalphainterlace = pImage->pImgbuf->iInterlace; - pData->iJHDRalphabitdepth = pImage->pImgbuf->iAlphabitdepth; -#endif - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - /* block size specified ? */ - if (iDeltatype != MNG_DELTATYPE_NOCHANGE) - { /* block entirely within target ? */ - if (iDeltatype != MNG_DELTATYPE_REPLACE) - { - if (((iBlockx + iBlockwidth ) > pData->iDatawidth ) || - ((iBlocky + iBlockheight) > pData->iDataheight) ) - MNG_ERROR (pData, MNG_INVALIDBLOCK); - } - - pData->iDatawidth = iBlockwidth; - pData->iDataheight = iBlockheight; - } -#else - /* block size specified ? */ - if (pData->iDHDRdeltatype != MNG_DELTATYPE_NOCHANGE) - { /* block entirely within target ? */ - if (pData->iDHDRdeltatype != MNG_DELTATYPE_REPLACE) - { - if (((pData->iDHDRblockx + pData->iDHDRblockwidth ) > pData->iDatawidth ) || - ((pData->iDHDRblocky + pData->iDHDRblockheight) > pData->iDataheight) ) - MNG_ERROR (pData, MNG_INVALIDBLOCK); - } - - pData->iDatawidth = pData->iDHDRblockwidth; - pData->iDataheight = pData->iDHDRblockheight; - } -#endif - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - switch (iDeltatype) /* determine nr of delta-channels */ -#else - switch (pData->iDHDRdeltatype) /* determine nr of delta-channels */ -#endif - { - case MNG_DELTATYPE_BLOCKALPHAADD : ; - case MNG_DELTATYPE_BLOCKALPHAREPLACE : - { -#ifdef MNG_INCLUDE_JNG - if ((pData->iColortype == MNG_COLORTYPE_GRAYA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA) ) - { - pData->iColortype = MNG_COLORTYPE_GRAY; - pData->iJHDRcolortype = MNG_COLORTYPE_JPEGGRAY; - } - else - if ((pData->iColortype == MNG_COLORTYPE_RGBA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) ) - { - pData->iColortype = MNG_COLORTYPE_GRAY; - pData->iJHDRcolortype = MNG_COLORTYPE_JPEGGRAY; - } -#else - if (pData->iColortype == MNG_COLORTYPE_GRAYA) - pData->iColortype = MNG_COLORTYPE_GRAY; - else - if (pData->iColortype == MNG_COLORTYPE_RGBA) - pData->iColortype = MNG_COLORTYPE_GRAY; -#endif - else /* target has no alpha; that sucks! */ - MNG_ERROR (pData, MNG_TARGETNOALPHA); - - break; - } - - case MNG_DELTATYPE_BLOCKCOLORADD : ; - case MNG_DELTATYPE_BLOCKCOLORREPLACE : - { -#ifdef MNG_INCLUDE_JNG - if ((pData->iColortype == MNG_COLORTYPE_GRAYA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA) ) - { - pData->iColortype = MNG_COLORTYPE_GRAY; - pData->iJHDRcolortype = MNG_COLORTYPE_JPEGGRAY; - } - else - if ((pData->iColortype == MNG_COLORTYPE_RGBA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) ) - { - pData->iColortype = MNG_COLORTYPE_RGB; - pData->iJHDRcolortype = MNG_COLORTYPE_JPEGCOLOR; - } -#else - if (pData->iColortype == MNG_COLORTYPE_GRAYA) - pData->iColortype = MNG_COLORTYPE_GRAY; - else - if (pData->iColortype == MNG_COLORTYPE_RGBA) - pData->iColortype = MNG_COLORTYPE_RGB; -#endif - else /* target has no alpha; that sucks! */ - MNG_ERROR (pData, MNG_TARGETNOALPHA); - - break; - } - - } - /* full image replace ? */ -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - if (iDeltatype == MNG_DELTATYPE_REPLACE) -#else - if (pData->iDHDRdeltatype == MNG_DELTATYPE_REPLACE) -#endif - { - iRetcode = mng_reset_object_details (pData, pImage, - pData->iDatawidth, pData->iDataheight, - pData->iBitdepth, pData->iColortype, - pData->iCompression, pData->iFilter, - pData->iInterlace, MNG_FALSE); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - pData->pStoreobj = pImage; /* and store straight into this object */ - } - else - { - mng_imagedatap pBufzero, pBuf; - /* we store in object 0 and process it later */ - pData->pStoreobj = pData->pObjzero; - /* make sure to initialize object 0 then */ - iRetcode = mng_reset_object_details (pData, (mng_imagep)pData->pObjzero, - pData->iDatawidth, pData->iDataheight, - pData->iBitdepth, pData->iColortype, - pData->iCompression, pData->iFilter, - pData->iInterlace, MNG_TRUE); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - pBuf = pImage->pImgbuf; /* copy possible palette & cheap transparency */ - pBufzero = ((mng_imagep)pData->pObjzero)->pImgbuf; - - pBufzero->bHasPLTE = pBuf->bHasPLTE; - pBufzero->bHasTRNS = pBuf->bHasTRNS; - - if (pBufzero->bHasPLTE) /* copy palette ? */ - { - mng_uint32 iX; - - pBufzero->iPLTEcount = pBuf->iPLTEcount; - - for (iX = 0; iX < pBuf->iPLTEcount; iX++) - { - pBufzero->aPLTEentries [iX].iRed = pBuf->aPLTEentries [iX].iRed; - pBufzero->aPLTEentries [iX].iGreen = pBuf->aPLTEentries [iX].iGreen; - pBufzero->aPLTEentries [iX].iBlue = pBuf->aPLTEentries [iX].iBlue; - } - } - - if (pBufzero->bHasTRNS) /* copy cheap transparency ? */ - { - pBufzero->iTRNSgray = pBuf->iTRNSgray; - pBufzero->iTRNSred = pBuf->iTRNSred; - pBufzero->iTRNSgreen = pBuf->iTRNSgreen; - pBufzero->iTRNSblue = pBuf->iTRNSblue; - pBufzero->iTRNScount = pBuf->iTRNScount; - - MNG_COPY (pBufzero->aTRNSentries, pBuf->aTRNSentries, - sizeof (pBufzero->aTRNSentries)); - } - /* process immediately if bitdepth & colortype are equal */ - pData->bDeltaimmediate = - (mng_bool)((pData->bDisplaying) && (!pData->bSkipping) && - ((pData->bRunning) || (pData->bSearching)) && - (pData->iBitdepth == ((mng_imagep)pData->pDeltaImage)->pImgbuf->iBitdepth ) && - (pData->iColortype == ((mng_imagep)pData->pDeltaImage)->pImgbuf->iColortype) ); - } - -#ifdef MNG_OPTIMIZE_FOOTPRINT_INIT - pData->fInitrowproc = (mng_fptr)mng_init_rowproc; - pData->ePng_imgtype = mng_png_imgtype (pData->iColortype, pData->iBitdepth); -#else - switch (pData->iColortype) /* determine row initialization routine */ - { - case 0 : { /* gray */ - switch (pData->iBitdepth) - { -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case 1 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_g1_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_g1_i; - - break; - } - case 2 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_g2_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_g2_i; - - break; - } - case 4 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_g4_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_g4_i; - - break; - } -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_g8_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_g8_i; - - break; - } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_g16_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_g16_i; - - break; - } -#endif - } - - break; - } - case 2 : { /* rgb */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_rgb8_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_rgb8_i; - - break; - } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_rgb16_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_rgb16_i; - - break; - } -#endif - } - - break; - } - case 3 : { /* indexed */ - switch (pData->iBitdepth) - { -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case 1 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_idx1_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_idx1_i; - - break; - } - case 2 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_idx2_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_idx2_i; - - break; - } - case 4 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_idx4_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_idx4_i; - - break; - } -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_idx8_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_idx8_i; - - break; - } - } - - break; - } - case 4 : { /* gray+alpha */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_ga8_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_ga8_i; - - break; - } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_ga16_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_ga16_i; - - break; - } -#endif - } - - break; - } - case 6 : { /* rgb+alpha */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_rgba8_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_rgba8_i; - - break; - } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)mng_init_rgba16_ni; - else - pData->fInitrowproc = (mng_fptr)mng_init_rgba16_i; - - break; - } -#endif - } - - break; - } - } -#endif /* MNG_OPTIMIZE_FOOTPRINT_INIT */ - } - else - MNG_ERROR (pData, MNG_OBJNOTCONCRETE); - - } - else - MNG_ERROR (pData, MNG_OBJECTUNKNOWN); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_DHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_OPTIMIZE_DISPLAYCALLS -mng_retcode mng_process_display_prom (mng_datap pData, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iFilltype) -#else -mng_retcode mng_process_display_prom (mng_datap pData) -#endif -{ - mng_imagep pImage; - mng_imagedatap pBuf; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_PROM, MNG_LC_START); -#endif - - if (!pData->pDeltaImage) /* gotta have this now! */ - MNG_ERROR (pData, MNG_INVALIDDELTA); - - pImage = (mng_imagep)pData->pDeltaImage; - pBuf = pImage->pImgbuf; - /* can't demote bitdepth! */ -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - if (iBitdepth < pBuf->iBitdepth) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH); - - if ( ((pBuf->iColortype == MNG_COLORTYPE_GRAY ) && - (iColortype != MNG_COLORTYPE_GRAY ) && - (iColortype != MNG_COLORTYPE_GRAYA ) && - (iColortype != MNG_COLORTYPE_RGB ) && - (iColortype != MNG_COLORTYPE_RGBA ) ) || - ((pBuf->iColortype == MNG_COLORTYPE_GRAYA ) && - (iColortype != MNG_COLORTYPE_GRAYA ) && - (iColortype != MNG_COLORTYPE_RGBA ) ) || - ((pBuf->iColortype == MNG_COLORTYPE_RGB ) && - (iColortype != MNG_COLORTYPE_RGB ) && - (iColortype != MNG_COLORTYPE_RGBA ) ) || - ((pBuf->iColortype == MNG_COLORTYPE_RGBA ) && - (iColortype != MNG_COLORTYPE_RGBA ) ) || -#ifdef MNG_INCLUDE_JNG - ((pBuf->iColortype == MNG_COLORTYPE_JPEGGRAY ) && - (iColortype != MNG_COLORTYPE_JPEGGRAY ) && - (iColortype != MNG_COLORTYPE_JPEGCOLOR ) && - (iColortype != MNG_COLORTYPE_JPEGGRAYA ) && - (iColortype != MNG_COLORTYPE_JPEGCOLORA) ) || - ((pBuf->iColortype == MNG_COLORTYPE_JPEGCOLOR ) && - (iColortype != MNG_COLORTYPE_JPEGCOLOR ) && - (iColortype != MNG_COLORTYPE_JPEGCOLORA) ) || - ((pBuf->iColortype == MNG_COLORTYPE_JPEGGRAYA ) && - (iColortype != MNG_COLORTYPE_JPEGGRAYA ) && - (iColortype != MNG_COLORTYPE_JPEGCOLORA) ) || - ((pBuf->iColortype == MNG_COLORTYPE_JPEGCOLORA) && - (iColortype != MNG_COLORTYPE_JPEGCOLORA) ) || -#endif - ((pBuf->iColortype == MNG_COLORTYPE_INDEXED ) && - (iColortype != MNG_COLORTYPE_INDEXED ) && - (iColortype != MNG_COLORTYPE_RGB ) && - (iColortype != MNG_COLORTYPE_RGBA ) ) ) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE); - - iRetcode = mng_promote_imageobject (pData, pImage, iBitdepth, iColortype, iFilltype); -#else - if (pData->iPROMbitdepth < pBuf->iBitdepth) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH); - - if ( ((pBuf->iColortype == MNG_COLORTYPE_GRAY ) && - (pData->iPROMcolortype != MNG_COLORTYPE_GRAY ) && - (pData->iPROMcolortype != MNG_COLORTYPE_GRAYA ) && - (pData->iPROMcolortype != MNG_COLORTYPE_RGB ) && - (pData->iPROMcolortype != MNG_COLORTYPE_RGBA ) ) || - ((pBuf->iColortype == MNG_COLORTYPE_GRAYA ) && - (pData->iPROMcolortype != MNG_COLORTYPE_GRAYA ) && - (pData->iPROMcolortype != MNG_COLORTYPE_RGBA ) ) || - ((pBuf->iColortype == MNG_COLORTYPE_RGB ) && - (pData->iPROMcolortype != MNG_COLORTYPE_RGB ) && - (pData->iPROMcolortype != MNG_COLORTYPE_RGBA ) ) || - ((pBuf->iColortype == MNG_COLORTYPE_RGBA ) && - (pData->iPROMcolortype != MNG_COLORTYPE_RGBA ) ) || -#ifdef MNG_INCLUDE_JNG - ((pBuf->iColortype == MNG_COLORTYPE_JPEGGRAY ) && - (pData->iPROMcolortype != MNG_COLORTYPE_JPEGGRAY ) && - (pData->iPROMcolortype != MNG_COLORTYPE_JPEGCOLOR ) && - (pData->iPROMcolortype != MNG_COLORTYPE_JPEGGRAYA ) && - (pData->iPROMcolortype != MNG_COLORTYPE_JPEGCOLORA) ) || - ((pBuf->iColortype == MNG_COLORTYPE_JPEGCOLOR ) && - (pData->iPROMcolortype != MNG_COLORTYPE_JPEGCOLOR ) && - (pData->iPROMcolortype != MNG_COLORTYPE_JPEGCOLORA) ) || - ((pBuf->iColortype == MNG_COLORTYPE_JPEGGRAYA ) && - (pData->iPROMcolortype != MNG_COLORTYPE_JPEGGRAYA ) && - (pData->iPROMcolortype != MNG_COLORTYPE_JPEGCOLORA) ) || - ((pBuf->iColortype == MNG_COLORTYPE_JPEGCOLORA) && - (pData->iPROMcolortype != MNG_COLORTYPE_JPEGCOLORA) ) || -#endif - ((pBuf->iColortype == MNG_COLORTYPE_INDEXED ) && - (pData->iPROMcolortype != MNG_COLORTYPE_INDEXED ) && - (pData->iPROMcolortype != MNG_COLORTYPE_RGB ) && - (pData->iPROMcolortype != MNG_COLORTYPE_RGBA ) ) ) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE); - - iRetcode = mng_promote_imageobject (pData, pImage, pData->iPROMbitdepth, - pData->iPROMcolortype, pData->iPROMfilltype); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_PROM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -mng_retcode mng_process_display_ipng (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IPNG, MNG_LC_START); -#endif - /* indicate it for what it is now */ - pData->iDeltaImagetype = MNG_IMAGETYPE_PNG; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IPNG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifdef MNG_INCLUDE_JNG -mng_retcode mng_process_display_ijng (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IJNG, MNG_LC_START); -#endif - /* indicate it for what it is now */ - pData->iDeltaImagetype = MNG_IMAGETYPE_JNG; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IJNG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_OPTIMIZE_DISPLAYCALLS -mng_retcode mng_process_display_pplt (mng_datap pData, - mng_uint8 iType, - mng_uint32 iCount, - mng_palette8ep paIndexentries, - mng_uint8p paAlphaentries, - mng_uint8p paUsedentries) -#else -mng_retcode mng_process_display_pplt (mng_datap pData) -#endif -{ - mng_uint32 iX; - mng_imagep pImage = (mng_imagep)pData->pObjzero; - mng_imagedatap pBuf = pImage->pImgbuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_PPLT, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - iX = iCount; -#else - iX = pData->iPPLTcount; -#endif -#endif - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - switch (iType) -#else - switch (pData->iPPLTtype) -#endif - { - case MNG_DELTATYPE_REPLACERGB : - { -#ifdef MNG_DECREMENT_LOOPS - for (; iX > 0;iX--) -#else -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - for (iX = 0; iX < iCount; iX++) -#else - for (iX = 0; iX < pData->iPPLTcount; iX++) -#endif -#endif - { -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - if (paUsedentries [iX]) - { - pBuf->aPLTEentries [iX].iRed = paIndexentries [iX].iRed; - pBuf->aPLTEentries [iX].iGreen = paIndexentries [iX].iGreen; - pBuf->aPLTEentries [iX].iBlue = paIndexentries [iX].iBlue; - } -#else - if (pData->paPPLTusedentries [iX]) - { - pBuf->aPLTEentries [iX].iRed = pData->paPPLTindexentries [iX].iRed; - pBuf->aPLTEentries [iX].iGreen = pData->paPPLTindexentries [iX].iGreen; - pBuf->aPLTEentries [iX].iBlue = pData->paPPLTindexentries [iX].iBlue; - } -#endif - } - - break; - } - case MNG_DELTATYPE_DELTARGB : - { -#ifdef MNG_DECREMENT_LOOPS - for (; iX > 0;iX--) -#else -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - for (iX = 0; iX < iCount; iX++) -#else - for (iX = 0; iX < pData->iPPLTcount; iX++) -#endif -#endif - { -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - if (paUsedentries [iX]) - { - pBuf->aPLTEentries [iX].iRed = - (mng_uint8)(pBuf->aPLTEentries [iX].iRed + - paIndexentries [iX].iRed ); - pBuf->aPLTEentries [iX].iGreen = - (mng_uint8)(pBuf->aPLTEentries [iX].iGreen + - paIndexentries [iX].iGreen); - pBuf->aPLTEentries [iX].iBlue = - (mng_uint8)(pBuf->aPLTEentries [iX].iBlue + - paIndexentries [iX].iBlue ); - } -#else - if (pData->paPPLTusedentries [iX]) - { - pBuf->aPLTEentries [iX].iRed = - (mng_uint8)(pBuf->aPLTEentries [iX].iRed + - pData->paPPLTindexentries [iX].iRed ); - pBuf->aPLTEentries [iX].iGreen = - (mng_uint8)(pBuf->aPLTEentries [iX].iGreen + - pData->paPPLTindexentries [iX].iGreen); - pBuf->aPLTEentries [iX].iBlue = - (mng_uint8)(pBuf->aPLTEentries [iX].iBlue + - pData->paPPLTindexentries [iX].iBlue ); - } -#endif - } - - break; - } - case MNG_DELTATYPE_REPLACEALPHA : - { -#ifdef MNG_DECREMENT_LOOPS - for (; iX > 0;iX--) -#else -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - for (iX = 0; iX < iCount; iX++) -#else - for (iX = 0; iX < pData->iPPLTcount; iX++) -#endif -#endif - { -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - if (paUsedentries [iX]) - pBuf->aTRNSentries [iX] = paAlphaentries [iX]; - } -#else - if (pData->paPPLTusedentries [iX]) - pBuf->aTRNSentries [iX] = pData->paPPLTalphaentries [iX]; - } -#endif - - break; - } - case MNG_DELTATYPE_DELTAALPHA : - { -#ifdef MNG_DECREMENT_LOOPS - for (; iX > 0;iX--) -#else -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - for (iX = 0; iX < iCount; iX++) -#else - for (iX = 0; iX < pData->iPPLTcount; iX++) -#endif -#endif - { -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - if (paUsedentries [iX]) - pBuf->aTRNSentries [iX] = - (mng_uint8)(pBuf->aTRNSentries [iX] + - paAlphaentries [iX]); -#else - if (pData->paPPLTusedentries [iX]) - pBuf->aTRNSentries [iX] = - (mng_uint8)(pBuf->aTRNSentries [iX] + - pData->paPPLTalphaentries [iX]); -#endif - } - - break; - } - case MNG_DELTATYPE_REPLACERGBA : - { -#ifdef MNG_DECREMENT_LOOPS - for (; iX > 0;iX--) -#else -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - for (iX = 0; iX < iCount; iX++) -#else - for (iX = 0; iX < pData->iPPLTcount; iX++) -#endif -#endif - { -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - if (paUsedentries [iX]) - { - pBuf->aPLTEentries [iX].iRed = paIndexentries [iX].iRed; - pBuf->aPLTEentries [iX].iGreen = paIndexentries [iX].iGreen; - pBuf->aPLTEentries [iX].iBlue = paIndexentries [iX].iBlue; - pBuf->aTRNSentries [iX] = paAlphaentries [iX]; - } -#else - if (pData->paPPLTusedentries [iX]) - { - pBuf->aPLTEentries [iX].iRed = pData->paPPLTindexentries [iX].iRed; - pBuf->aPLTEentries [iX].iGreen = pData->paPPLTindexentries [iX].iGreen; - pBuf->aPLTEentries [iX].iBlue = pData->paPPLTindexentries [iX].iBlue; - pBuf->aTRNSentries [iX] = pData->paPPLTalphaentries [iX]; - } -#endif - } - - break; - } - case MNG_DELTATYPE_DELTARGBA : - { -#ifdef MNG_DECREMENT_LOOPS - for (; iX > 0;iX--) -#else -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - for (iX = 0; iX < iCount; iX++) -#else - for (iX = 0; iX < pData->iPPLTcount; iX++) -#endif -#endif - { -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - if (paUsedentries [iX]) - { - pBuf->aPLTEentries [iX].iRed = - (mng_uint8)(pBuf->aPLTEentries [iX].iRed + - paIndexentries [iX].iRed ); - pBuf->aPLTEentries [iX].iGreen = - (mng_uint8)(pBuf->aPLTEentries [iX].iGreen + - paIndexentries [iX].iGreen); - pBuf->aPLTEentries [iX].iBlue = - (mng_uint8)(pBuf->aPLTEentries [iX].iBlue + - paIndexentries [iX].iBlue ); - pBuf->aTRNSentries [iX] = - (mng_uint8)(pBuf->aTRNSentries [iX] + - paAlphaentries [iX]); - } -#else - if (pData->paPPLTusedentries [iX]) - { - pBuf->aPLTEentries [iX].iRed = - (mng_uint8)(pBuf->aPLTEentries [iX].iRed + - pData->paPPLTindexentries [iX].iRed ); - pBuf->aPLTEentries [iX].iGreen = - (mng_uint8)(pBuf->aPLTEentries [iX].iGreen + - pData->paPPLTindexentries [iX].iGreen); - pBuf->aPLTEentries [iX].iBlue = - (mng_uint8)(pBuf->aPLTEentries [iX].iBlue + - pData->paPPLTindexentries [iX].iBlue ); - pBuf->aTRNSentries [iX] = - (mng_uint8)(pBuf->aTRNSentries [iX] + - pData->paPPLTalphaentries [iX]); - } -#endif - } - - break; - } - } - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - if ((iType != MNG_DELTATYPE_REPLACERGB) && (iType != MNG_DELTATYPE_DELTARGB)) -#else - if ((pData->iPPLTtype != MNG_DELTATYPE_REPLACERGB) && - (pData->iPPLTtype != MNG_DELTATYPE_DELTARGB ) ) -#endif - { - if (pBuf->bHasTRNS) - { -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - if (iCount > pBuf->iTRNScount) - pBuf->iTRNScount = iCount; -#else - if (pData->iPPLTcount > pBuf->iTRNScount) - pBuf->iTRNScount = pData->iPPLTcount; -#endif - } - else - { -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - pBuf->iTRNScount = iCount; - pBuf->bHasTRNS = MNG_TRUE; -#else - pBuf->iTRNScount = pData->iPPLTcount; - pBuf->bHasTRNS = MNG_TRUE; -#endif - } - } - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - if ((iType != MNG_DELTATYPE_REPLACEALPHA) && (iType != MNG_DELTATYPE_DELTAALPHA)) -#else - if ((pData->iPPLTtype != MNG_DELTATYPE_REPLACEALPHA) && - (pData->iPPLTtype != MNG_DELTATYPE_DELTAALPHA ) ) -#endif - { -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - if (iCount > pBuf->iPLTEcount) - pBuf->iPLTEcount = iCount; -#else - if (pData->iPPLTcount > pBuf->iPLTEcount) - pBuf->iPLTEcount = pData->iPPLTcount; -#endif - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_PPLT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_MAGN -#ifndef MNG_OPTIMIZE_DISPLAYCALLS -mng_retcode mng_process_display_magn (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iMethodX, - mng_uint16 iMX, - mng_uint16 iMY, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint16 iMT, - mng_uint16 iMB, - mng_uint8 iMethodY) -#else -mng_retcode mng_process_display_magn (mng_datap pData) -#endif -{ - mng_uint16 iX; - mng_imagep pImage; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MAGN, MNG_LC_START); -#endif - /* iterate the object-ids */ -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - for (iX = iFirstid; iX <= iLastid; iX++) -#else - for (iX = pData->iMAGNfirstid; iX <= pData->iMAGNlastid; iX++) -#endif - { - if (iX == 0) /* process object 0 ? */ - { - pImage = (mng_imagep)pData->pObjzero; - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - pImage->iMAGN_MethodX = iMethodX; - pImage->iMAGN_MethodY = iMethodY; - pImage->iMAGN_MX = iMX; - pImage->iMAGN_MY = iMY; - pImage->iMAGN_ML = iML; - pImage->iMAGN_MR = iMR; - pImage->iMAGN_MT = iMT; - pImage->iMAGN_MB = iMB; -#else - pImage->iMAGN_MethodX = pData->iMAGNmethodX; - pImage->iMAGN_MethodY = pData->iMAGNmethodY; - pImage->iMAGN_MX = pData->iMAGNmX; - pImage->iMAGN_MY = pData->iMAGNmY; - pImage->iMAGN_ML = pData->iMAGNmL; - pImage->iMAGN_MR = pData->iMAGNmR; - pImage->iMAGN_MT = pData->iMAGNmT; - pImage->iMAGN_MB = pData->iMAGNmB; -#endif - } - else - { - pImage = mng_find_imageobject (pData, iX); - /* object exists & is not frozen ? */ - if ((pImage) && (!pImage->bFrozen)) - { /* previous magnification to be done ? */ - if ((pImage->iMAGN_MethodX) || (pImage->iMAGN_MethodY)) - { - mng_retcode iRetcode = mng_magnify_imageobject (pData, pImage); - if (iRetcode) /* on error bail out */ - return iRetcode; - } - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - pImage->iMAGN_MethodX = iMethodX; - pImage->iMAGN_MethodY = iMethodY; - pImage->iMAGN_MX = iMX; - pImage->iMAGN_MY = iMY; - pImage->iMAGN_ML = iML; - pImage->iMAGN_MR = iMR; - pImage->iMAGN_MT = iMT; - pImage->iMAGN_MB = iMB; -#else - pImage->iMAGN_MethodX = pData->iMAGNmethodX; - pImage->iMAGN_MethodY = pData->iMAGNmethodY; - pImage->iMAGN_MX = pData->iMAGNmX; - pImage->iMAGN_MY = pData->iMAGNmY; - pImage->iMAGN_ML = pData->iMAGNmL; - pImage->iMAGN_MR = pData->iMAGNmR; - pImage->iMAGN_MT = pData->iMAGNmT; - pImage->iMAGN_MB = pData->iMAGNmB; -#endif - } - } - } - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - pData->iMAGNfromid = iFirstid; - pData->iMAGNtoid = iLastid; - iX = iFirstid; -#else - pData->iMAGNfromid = pData->iMAGNfirstid; - pData->iMAGNtoid = pData->iMAGNlastid; - iX = pData->iMAGNfirstid; -#endif - /* iterate again for showing */ -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - while ((iX <= iLastid) && (!pData->bTimerset)) -#else - while ((iX <= pData->iMAGNlastid) && (!pData->bTimerset)) -#endif - { - pData->iMAGNcurrentid = iX; - - if (iX) /* only real objects ! */ - { - pImage = mng_find_imageobject (pData, iX); - /* object exists & is not frozen & - is visible & is viewable ? */ - if ((pImage) && (!pImage->bFrozen) && - (pImage->bVisible) && (pImage->bViewable)) - { - mng_retcode iRetcode = mng_display_image (pData, pImage, MNG_FALSE); - if (iRetcode) - return iRetcode; - } - } - - iX++; - } - - if (pData->bTimerset) /* broken ? */ - pData->iBreakpoint = 9; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MAGN, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_process_display_magn2 (mng_datap pData) -{ - mng_uint16 iX; - mng_imagep pImage; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MAGN, MNG_LC_START); -#endif - - iX = pData->iMAGNcurrentid; - /* iterate again for showing */ - while ((iX <= pData->iMAGNtoid) && (!pData->bTimerset)) - { - pData->iMAGNcurrentid = iX; - - if (iX) /* only real objects ! */ - { - pImage = mng_find_imageobject (pData, iX); - /* object exists & is not frozen & - is visible & is viewable ? */ - if ((pImage) && (!pImage->bFrozen) && - (pImage->bVisible) && (pImage->bViewable)) - { - mng_retcode iRetcode = mng_display_image (pData, pImage, MNG_FALSE); - if (iRetcode) - return iRetcode; - } - } - - iX++; - } - - if (pData->bTimerset) /* broken ? */ - pData->iBreakpoint = 9; - else - pData->iBreakpoint = 0; /* not again ! */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MAGN, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_PAST -#ifndef MNG_OPTIMIZE_DISPLAYCALLS -mng_retcode mng_process_display_past (mng_datap pData, - mng_uint16 iTargetid, - mng_uint8 iTargettype, - mng_int32 iTargetx, - mng_int32 iTargety, - mng_uint32 iCount, - mng_ptr pSources) -#else -mng_retcode mng_process_display_past (mng_datap pData) -#endif -{ - mng_retcode iRetcode = MNG_NOERROR; - mng_imagep pTargetimg; - mng_imagep pSourceimg; -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - mng_past_sourcep pSource = (mng_past_sourcep)pSources; -#else - mng_past_sourcep pSource = (mng_past_sourcep)pData->pPASTsources; -#endif - mng_uint32 iX = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_PAST, MNG_LC_START); -#endif - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - if (iTargetid) /* a real destination object ? */ -#else - if (pData->iPASTtargetid) /* a real destination object ? */ -#endif - { /* let's find it then */ -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - pTargetimg = (mng_imagep)mng_find_imageobject (pData, iTargetid); -#else - pTargetimg = (mng_imagep)mng_find_imageobject (pData, pData->iPASTtargetid); -#endif - - if (!pTargetimg) /* if it doesn't exists; do a barf */ - MNG_ERROR (pData, MNG_OBJECTUNKNOWN); - /* it's gotta be abstract !!! */ - if (pTargetimg->pImgbuf->bConcrete) - MNG_ERROR (pData, MNG_OBJNOTABSTRACT); - /* we want 32-/64-bit RGBA to play with ! */ - if ((pTargetimg->pImgbuf->iBitdepth <= MNG_BITDEPTH_8) || - (pTargetimg->pImgbuf->iColortype == MNG_COLORTYPE_GRAY) || - (pTargetimg->pImgbuf->iColortype == MNG_COLORTYPE_RGB) || - (pTargetimg->pImgbuf->iColortype == MNG_COLORTYPE_INDEXED) || - (pTargetimg->pImgbuf->iColortype == MNG_COLORTYPE_GRAYA) ) - iRetcode = mng_promote_imageobject (pData, pTargetimg, MNG_BITDEPTH_8, - MNG_COLORTYPE_RGBA, - MNG_FILLMETHOD_LEFTBITREPLICATE); - else - if ((pTargetimg->pImgbuf->iBitdepth > MNG_BITDEPTH_8) && - ((pTargetimg->pImgbuf->iColortype == MNG_COLORTYPE_GRAY) || - (pTargetimg->pImgbuf->iColortype == MNG_COLORTYPE_RGB) || - (pTargetimg->pImgbuf->iColortype == MNG_COLORTYPE_GRAYA) ) ) - iRetcode = mng_promote_imageobject (pData, pTargetimg, MNG_BITDEPTH_16, - MNG_COLORTYPE_RGBA, - MNG_FILLMETHOD_LEFTBITREPLICATE); -#ifdef MNG_INCLUDE_JNG - else - if ((pTargetimg->pImgbuf->iColortype == MNG_COLORTYPE_JPEGGRAY) || - (pTargetimg->pImgbuf->iColortype == MNG_COLORTYPE_JPEGCOLOR) || - (pTargetimg->pImgbuf->iColortype == MNG_COLORTYPE_JPEGGRAYA) ) - iRetcode = mng_promote_imageobject (pData, pTargetimg, - pTargetimg->pImgbuf->iBitdepth, - MNG_COLORTYPE_JPEGCOLORA, - MNG_FILLMETHOD_LEFTBITREPLICATE); -#endif - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* make it really abstract ? */ - if (!pTargetimg->pImgbuf->bCorrected) - { - iRetcode = mng_colorcorrect_object (pData, pTargetimg); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - else - { /* pasting into object 0 !!! */ - pTargetimg = (mng_imagep)pData->pObjzero; - /* is it usable ??? */ - if ((pTargetimg->bClipped) && - (pTargetimg->iClipr > pTargetimg->iPosx) && - (pTargetimg->iClipb > pTargetimg->iPosy)) - { - /* make it 32-bit RGBA please !!! */ - iRetcode = mng_reset_object_details (pData, pTargetimg, - pTargetimg->iClipr - pTargetimg->iPosx, - pTargetimg->iClipb - pTargetimg->iPosy, - MNG_BITDEPTH_8, MNG_COLORTYPE_RGBA, - 0, 0, 0, MNG_FALSE); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - else - pTargetimg = MNG_NULL; /* clipped beyond visibility ! */ - } - - if (pTargetimg) /* usable destination ? */ - { - mng_int32 iSourceY; - mng_int32 iSourceYinc; - mng_int32 iSourcerowsize; - mng_int32 iSourcesamples; - mng_bool bSourceRGBA16; - mng_int32 iTargetY; - mng_int32 iTargetrowsize; - mng_int32 iTargetsamples; - mng_bool bTargetRGBA16 = MNG_FALSE; - mng_int32 iTemprowsize; - mng_imagedatap pBuf; -#ifndef MNG_SKIPCHUNK_MAGN - /* needs magnification ? */ - if ((pTargetimg->iMAGN_MethodX) || (pTargetimg->iMAGN_MethodY)) - iRetcode = mng_magnify_imageobject (pData, pTargetimg); -#endif - - if (!iRetcode) /* still ok ? */ - { - bTargetRGBA16 = (mng_bool)(pTargetimg->pImgbuf->iBitdepth > 8); - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - switch (iTargettype) /* determine target x/y */ -#else - switch (pData->iPASTtargettype) /* determine target x/y */ -#endif - { - case 0 : { -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - pData->iPastx = iTargetx; - pData->iPasty = iTargety; -#else - pData->iPastx = pData->iPASTtargetx; - pData->iPasty = pData->iPASTtargety; -#endif - break; - } - - case 1 : { -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - pData->iPastx = pTargetimg->iPastx + iTargetx; - pData->iPasty = pTargetimg->iPasty + iTargety; -#else - pData->iPastx = pTargetimg->iPastx + pData->iPASTtargetx; - pData->iPasty = pTargetimg->iPasty + pData->iPASTtargety; -#endif - break; - } - - case 2 : { -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - pData->iPastx += iTargetx; - pData->iPasty += iTargety; -#else - pData->iPastx += pData->iPASTtargetx; - pData->iPasty += pData->iPASTtargety; -#endif - break; - } - } - /* save for next time ... */ - pTargetimg->iPastx = pData->iPastx; - pTargetimg->iPasty = pData->iPasty; - /* address destination for row-routines */ - pData->pStoreobj = (mng_objectp)pTargetimg; - pData->pStorebuf = (mng_objectp)pTargetimg->pImgbuf; - } - /* process the sources one by one */ -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - while ((!iRetcode) && (iX < iCount)) -#else - while ((!iRetcode) && (iX < pData->iPASTcount)) -#endif - { /* find the little bastards first */ - pSourceimg = (mng_imagep)mng_find_imageobject (pData, pSource->iSourceid); - /* exists and viewable? */ - if ((pSourceimg) && (pSourceimg->bViewable)) - { /* needs magnification ? */ -#ifndef MNG_SKIPCHUNK_MAGN - if ((pSourceimg->iMAGN_MethodX) || (pSourceimg->iMAGN_MethodY)) - iRetcode = mng_magnify_imageobject (pData, pSourceimg); -#endif - - if (!iRetcode) /* still ok ? */ - { - pBuf = (mng_imagedatap)pSourceimg->pImgbuf; - /* address source for row-routines */ - pData->pRetrieveobj = (mng_objectp)pSourceimg; - - pData->iPass = -1; /* init row-processing variables */ - pData->iRowinc = 1; - pData->iColinc = 1; - pData->iPixelofs = 0; - iSourcesamples = (mng_int32)pBuf->iWidth; - iSourcerowsize = pBuf->iRowsize; - bSourceRGBA16 = (mng_bool)(pBuf->iBitdepth > 8); - /* make sure the delta-routines do the right thing */ - pData->iDeltatype = MNG_DELTATYPE_BLOCKPIXELREPLACE; - - switch (pBuf->iColortype) - { - case 0 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (bSourceRGBA16) - pData->fRetrieverow = (mng_fptr)mng_retrieve_g16; - else -#endif - pData->fRetrieverow = (mng_fptr)mng_retrieve_g8; - - pData->bIsOpaque = (mng_bool)(!pBuf->bHasTRNS); - break; - } - - case 2 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (bSourceRGBA16) - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgb16; - else -#endif - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgb8; - - pData->bIsOpaque = (mng_bool)(!pBuf->bHasTRNS); - break; - } - - - case 3 : { pData->fRetrieverow = (mng_fptr)mng_retrieve_idx8; - pData->bIsOpaque = (mng_bool)(!pBuf->bHasTRNS); - break; - } - - - case 4 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (bSourceRGBA16) - pData->fRetrieverow = (mng_fptr)mng_retrieve_ga16; - else -#endif - pData->fRetrieverow = (mng_fptr)mng_retrieve_ga8; - - pData->bIsOpaque = MNG_FALSE; - break; - } - - - case 6 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (bSourceRGBA16) - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgba16; - else -#endif - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgba8; - - pData->bIsOpaque = MNG_FALSE; - break; - } - - case 8 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (bSourceRGBA16) - pData->fRetrieverow = (mng_fptr)mng_retrieve_g16; - else -#endif - pData->fRetrieverow = (mng_fptr)mng_retrieve_g8; - - pData->bIsOpaque = MNG_TRUE; - break; - } - - case 10 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (bSourceRGBA16) - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgb16; - else -#endif - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgb8; - - pData->bIsOpaque = MNG_TRUE; - break; - } - - - case 12 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (bSourceRGBA16) - pData->fRetrieverow = (mng_fptr)mng_retrieve_ga16; - else -#endif - pData->fRetrieverow = (mng_fptr)mng_retrieve_ga8; - - pData->bIsOpaque = MNG_FALSE; - break; - } - - - case 14 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (bSourceRGBA16) - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgba16; - else -#endif - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgba8; - - pData->bIsOpaque = MNG_FALSE; - break; - } - } - /* determine scaling */ -#ifndef MNG_NO_16BIT_SUPPORT -#ifndef MNG_NO_DELTA_PNG - if ((!bSourceRGBA16) && (bTargetRGBA16)) - pData->fScalerow = (mng_fptr)mng_scale_rgba8_rgba16; - else - if ((bSourceRGBA16) && (!bTargetRGBA16)) - pData->fScalerow = (mng_fptr)mng_scale_rgba16_rgba8; - else -#endif -#endif - pData->fScalerow = MNG_NULL; - - /* default no color-correction */ - pData->fCorrectrow = MNG_NULL; - -#if defined(MNG_FULL_CMS) /* determine color-management routine */ - iRetcode = mng_init_full_cms (pData, MNG_FALSE, MNG_FALSE, MNG_TRUE); -#elif defined(MNG_GAMMA_ONLY) - iRetcode = mng_init_gamma_only (pData, MNG_FALSE, MNG_FALSE, MNG_TRUE); -#elif defined(MNG_APP_CMS) - iRetcode = mng_init_app_cms (pData, MNG_FALSE, MNG_FALSE, MNG_TRUE); -#endif - } - - if (!iRetcode) /* still ok ? */ - { - pData->fFliprow = MNG_NULL; /* no flipping or tiling by default */ - pData->fTilerow = MNG_NULL; - /* but perhaps we do have to ... */ - switch (pSource->iOrientation) - { - case 2 : ; - case 4 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (bTargetRGBA16) - pData->fFliprow = (mng_fptr)mng_flip_rgba16; - else -#endif - pData->fFliprow = (mng_fptr)mng_flip_rgba8; - break; - } - - case 8 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (bTargetRGBA16) - pData->fTilerow = (mng_fptr)mng_tile_rgba16; - else -#endif - pData->fTilerow = (mng_fptr)mng_tile_rgba8; - break; - } - } - /* determine composition routine */ - /* note that we're abusing the delta-routine setup !!! */ - switch (pSource->iComposition) - { - case 0 : { /* composite over */ -#ifndef MNG_NO_16BIT_SUPPORT - if (bTargetRGBA16) - pData->fDeltarow = (mng_fptr)mng_composeover_rgba16; - else -#endif - pData->fDeltarow = (mng_fptr)mng_composeover_rgba8; - break; - } - - case 1 : { /* replace */ -#ifndef MNG_NO_16BIT_SUPPORT - if (bTargetRGBA16) - pData->fDeltarow = (mng_fptr)mng_delta_rgba16_rgba16; - else -#endif - pData->fDeltarow = (mng_fptr)mng_delta_rgba8_rgba8; - break; - } - - case 2 : { /* composite under */ -#ifndef MNG_NO_16BIT_SUPPORT - if (bTargetRGBA16) - pData->fDeltarow = (mng_fptr)mng_composeunder_rgba16; - else -#endif - pData->fDeltarow = (mng_fptr)mng_composeunder_rgba8; - break; - } - } - /* determine offsets & clipping */ - if (pSource->iOffsettype == 1) - { - pData->iDestl = pData->iPastx + pSource->iOffsetx; - pData->iDestt = pData->iPasty + pSource->iOffsety; - } - else - { - pData->iDestl = pSource->iOffsetx; - pData->iDestt = pSource->iOffsety; - } - - pData->iDestr = (mng_int32)pTargetimg->pImgbuf->iWidth; - pData->iDestb = (mng_int32)pTargetimg->pImgbuf->iHeight; - /* take the source dimension into account ? */ - if (pSource->iOrientation != 8) - { - pData->iDestr = MIN_COORD (pData->iDestr, pData->iDestl + (mng_int32)pBuf->iWidth); - pData->iDestb = MIN_COORD (pData->iDestb, pData->iDestt + (mng_int32)pBuf->iHeight); - } - /* source clipping */ - if (pSource->iBoundarytype == 1) - { - if (pData->iDestl < pData->iPastx + pSource->iBoundaryl) - pData->iSourcel = pData->iPastx + pSource->iBoundaryl - pData->iDestl; - else - pData->iSourcel = 0; - - if (pData->iDestt < pData->iPasty + pSource->iBoundaryt) - pData->iSourcet = pData->iPasty + pSource->iBoundaryt - pData->iDestt; - else - pData->iSourcet = 0; - - pData->iDestl = MAX_COORD (pData->iDestl, pData->iPastx + pSource->iBoundaryl); - pData->iDestt = MAX_COORD (pData->iDestt, pData->iPasty + pSource->iBoundaryt); - pData->iDestr = MIN_COORD (pData->iDestr, pData->iPastx + pSource->iBoundaryr); - pData->iDestb = MIN_COORD (pData->iDestb, pData->iPasty + pSource->iBoundaryb); - } - else - { - if (pData->iDestl < pSource->iBoundaryl) - pData->iSourcel = pSource->iBoundaryl - pData->iDestl; - else - pData->iSourcel = 0; - - if (pData->iDestt < pSource->iBoundaryt) - pData->iSourcet = pSource->iBoundaryt - pData->iDestt; - else - pData->iSourcet = 0; - - pData->iDestl = MAX_COORD (pData->iDestl, pSource->iBoundaryl); - pData->iDestt = MAX_COORD (pData->iDestt, pSource->iBoundaryt); - pData->iDestr = MIN_COORD (pData->iDestr, pSource->iBoundaryr); - pData->iDestb = MIN_COORD (pData->iDestb, pSource->iBoundaryb); - } - - if (pData->iSourcel) /* indent source ? */ - { -#ifndef MNG_NO_16BIT_SUPPORT - if (bTargetRGBA16) /* abuse tiling routine to shift source-pixels */ - pData->fTilerow = (mng_fptr)mng_tile_rgba16; - else -#endif - pData->fTilerow = (mng_fptr)mng_tile_rgba8; - } - /* anything to display ? */ - if ((pData->iDestl <= pData->iDestr) && (pData->iDestt <= pData->iDestb)) - { /* init variables for the loop */ - if ((pSource->iOrientation == 2) || (pSource->iOrientation == 6)) - { - iSourceY = (mng_int32)pBuf->iHeight - 1 - pData->iSourcet; - iSourceYinc = -1; - } - else - { - iSourceY = pData->iSourcet; - iSourceYinc = 1; - } - - iTargetY = pData->iDestt; - pData->iCol = pData->iDestl; - - iTargetsamples = pData->iDestr - pData->iDestl; - -#ifndef MNG_NO_16BIT_SUPPORT - if (bTargetRGBA16) - iTargetrowsize = (iTargetsamples << 3); - else -#endif - iTargetrowsize = (iTargetsamples << 2); - - /* get temporary work-buffers */ - if (iSourcerowsize > iTargetrowsize) - iTemprowsize = iSourcerowsize << 1; - else - iTemprowsize = iTargetrowsize << 1; - MNG_ALLOC (pData, pData->pRGBArow, iTemprowsize); - MNG_ALLOC (pData, pData->pWorkrow, iTemprowsize); - - while ((!iRetcode) && (iTargetY < pData->iDestb)) - { /* get a row */ - pData->iRow = iSourceY; - pData->iRowsamples = iSourcesamples; - pData->iRowsize = iSourcerowsize; - pData->bIsRGBA16 = bSourceRGBA16; - iRetcode = ((mng_retrieverow)pData->fRetrieverow) (pData); - /* scale it (if necessary) */ - if ((!iRetcode) && (pData->fScalerow)) - iRetcode = ((mng_scalerow)pData->fScalerow) (pData); - - pData->bIsRGBA16 = bTargetRGBA16; - /* color correction (if necessary) */ - if ((!iRetcode) && (pData->fCorrectrow)) - iRetcode = ((mng_correctrow)pData->fCorrectrow) (pData); - /* flipping (if necessary) */ - if ((!iRetcode) && (pData->fFliprow)) - iRetcode = ((mng_fliprow)pData->fFliprow) (pData); - /* tiling (if necessary) */ - if ((!iRetcode) && (pData->fTilerow)) - iRetcode = ((mng_tilerow)pData->fTilerow) (pData); - - if (!iRetcode) /* and paste..... */ - { - pData->iRow = iTargetY; - pData->iRowsamples = iTargetsamples; - pData->iRowsize = iTargetrowsize; - iRetcode = ((mng_deltarow)pData->fDeltarow) (pData); - } - - iSourceY += iSourceYinc; /* and next line */ - - if (iSourceY < 0) - iSourceY = (mng_int32)pBuf->iHeight - 1; - else - if (iSourceY >= (mng_int32)pBuf->iHeight) - iSourceY = 0; - - iTargetY++; - } - /* drop the temporary row-buffer */ - MNG_FREEX (pData, pData->pWorkrow, iTemprowsize); - MNG_FREEX (pData, pData->pRGBArow, iTemprowsize); - } - -#if defined(MNG_FULL_CMS) /* cleanup cms stuff */ - if (!iRetcode) - iRetcode = mng_clear_cms (pData); -#endif - } - - pSource++; /* neeeeext */ - iX++; - } - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - if (!iTargetid) /* did we paste into object 0 ? */ -#else - if (!pData->iPASTtargetid) /* did we paste into object 0 ? */ -#endif - { /* display it then ! */ - iRetcode = mng_display_image (pData, pTargetimg, MNG_FALSE); - if (iRetcode) /* on error bail out */ - return iRetcode; - } - else - { /* target is visible & viewable ? */ - if ((pTargetimg->bVisible) && (pTargetimg->bViewable)) - { - iRetcode = mng_display_image (pData, pTargetimg, MNG_FALSE); - if (iRetcode) - return iRetcode; - } - } - } - - if (pData->bTimerset) /* broken ? */ - { -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - pData->iPASTid = iTargetid; -#else - pData->iPASTid = pData->iPASTtargetid; -#endif - pData->iBreakpoint = 11; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_PAST, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SKIPCHUNK_PAST */ - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_PAST -mng_retcode mng_process_display_past2 (mng_datap pData) -{ - mng_retcode iRetcode; - mng_imagep pTargetimg; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_PAST, MNG_LC_START); -#endif - - if (pData->iPASTid) /* a real destination object ? */ - pTargetimg = (mng_imagep)mng_find_imageobject (pData, pData->iPASTid); - else /* otherwise object 0 */ - pTargetimg = (mng_imagep)pData->pObjzero; - - iRetcode = mng_display_image (pData, pTargetimg, MNG_FALSE); - if (iRetcode) - return iRetcode; - - pData->iBreakpoint = 0; /* only once */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_PAST, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SKIPCHUNK_PAST */ - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_DISPLAY_PROCS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - - diff --git a/plugins/AdvaImg/src/LibMNG/libmng_display.h b/plugins/AdvaImg/src/LibMNG/libmng_display.h deleted file mode 100644 index 3dc6ca2d91..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_display.h +++ /dev/null @@ -1,343 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_display.h copyright (c) 2000-2007 G.Juyn * */ -/* * version : 1.0.10 * */ -/* * * */ -/* * purpose : Display management (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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 * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added JDAA chunk * */ -/* * * */ -/* * 0.9.4 - 11/24/2000 - G.Juyn * */ -/* * - moved restore of object 0 to libmng_display * */ -/* * * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * 1.0.5 - 09/13/2002 - G.Juyn * */ -/* * - fixed read/write of MAGN chunk * */ -/* * 1.0.5 - 09/20/2002 - G.Juyn * */ -/* * - added support for PAST * */ -/* * 1.0.5 - 10/07/2002 - G.Juyn * */ -/* * - added proposed change in handling of TERM- & if-delay * */ -/* * 1.0.5 - 10/20/2002 - G.Juyn * */ -/* * - fixed display of visible target of PAST operation * */ -/* * * */ -/* * 1.0.7 - 03/24/2004 - G.R-P. * */ -/* * - added some SKIPCHUNK conditionals * */ -/* * * */ -/* * 1.0.9 - 12/11/2004 - G.Juyn * */ -/* * - added conditional MNG_OPTIMIZE_DISPLAYCALLS * */ -/* * * */ -/* * 1.0.10 - 04/08/2007 - G.Juyn * */ -/* * - added support for mPNG proposal * */ -/* * 1.0.10 - 04/12/2007 - G.Juyn * */ -/* * - added support for ANG proposal * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_display_h_ -#define _libmng_display_h_ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_DISPLAY_PROCS - -/* ************************************************************************** */ - -mng_retcode mng_display_progressive_refresh (mng_datap pData, - mng_uint32 iInterval); - -/* ************************************************************************** */ - -mng_retcode mng_reset_objzero (mng_datap pData); - -mng_retcode mng_display_image (mng_datap pData, - mng_imagep pImage, - mng_bool bLayeradvanced); - -mng_retcode mng_execute_delta_image (mng_datap pData, - mng_imagep pTarget, - mng_imagep pDelta); - -/* ************************************************************************** */ - -mng_retcode mng_process_display (mng_datap pData); - -/* ************************************************************************** */ - -#ifdef MNG_OPTIMIZE_FOOTPRINT_INIT -png_imgtype mng_png_imgtype (mng_uint8 colortype, - mng_uint8 bitdepth); -#endif - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - -mng_retcode mng_process_display_ihdr (mng_datap pData); - -#ifdef MNG_INCLUDE_MPNG_PROPOSAL -mng_retcode mng_process_display_mpng (mng_datap pData); -#endif - -#ifdef MNG_INCLUDE_ANG_PROPOSAL -mng_retcode mng_process_display_ang (mng_datap pData); -#endif - -mng_retcode mng_process_display_idat (mng_datap pData, - mng_uint32 iRawlen, - mng_uint8p pRawdata); - -mng_retcode mng_process_display_iend (mng_datap pData); -mng_retcode mng_process_display_mend (mng_datap pData); -mng_retcode mng_process_display_mend2 (mng_datap pData); -mng_retcode mng_process_display_defi (mng_datap pData); - -#ifndef MNG_SKIPCHUNK_BASI -mng_retcode mng_process_display_basi (mng_datap pData, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_bool bHasalpha, - mng_uint16 iAlpha, - mng_uint8 iViewable); -#endif - -#ifndef MNG_SKIPCHUNK_CLON -mng_retcode mng_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 mng_process_display_clon2 (mng_datap pData); -#endif - -#ifndef MNG_SKIPCHUNK_DISC -mng_retcode mng_process_display_disc (mng_datap pData, - mng_uint32 iCount, - mng_uint16p pIds); -#endif - -#ifndef MNG_SKIPCHUNK_FRAM -mng_retcode mng_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 mng_process_display_fram2 (mng_datap pData); -#endif - -#ifndef MNG_SKIPCHUNK_MOVE -mng_retcode mng_process_display_move (mng_datap pData, - mng_uint16 iFromid, - mng_uint16 iToid, - mng_uint8 iMovetype, - mng_int32 iMovex, - mng_int32 iMovey); -#endif - -#ifndef MNG_SKIPCHUNK_CLIP -mng_retcode mng_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); -#endif - -#ifndef MNG_SKIPCHUNK_SHOW -mng_retcode mng_process_display_show (mng_datap pData); -#endif -#ifndef MNG_SKIPCHUNK_SAVE -mng_retcode mng_process_display_save (mng_datap pData); -#endif -#ifndef MNG_SKIPCHUNK_SEEK -mng_retcode mng_process_display_seek (mng_datap pData); -#endif -#ifdef MNG_INCLUDE_JNG -mng_retcode mng_process_display_jhdr (mng_datap pData); - -mng_retcode mng_process_display_jdaa (mng_datap pData, - mng_uint32 iRawlen, - mng_uint8p pRawdata); - -mng_retcode mng_process_display_jdat (mng_datap pData, - mng_uint32 iRawlen, - mng_uint8p pRawdata); - -#endif -#ifndef MNG_NO_DELTA_PNG -mng_retcode mng_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 mng_process_display_prom (mng_datap pData, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iFilltype); - -mng_retcode mng_process_display_ipng (mng_datap pData); -#ifdef MNG_INCLUDE_JNG -mng_retcode mng_process_display_ijng (mng_datap pData); -#endif - -mng_retcode mng_process_display_pplt (mng_datap pData, - mng_uint8 iType, - mng_uint32 iCount, - mng_palette8ep paIndexentries, - mng_uint8p paAlphaentries, - mng_uint8p paUsedentries); -#endif - -#ifndef MNG_SKIPCHUNK_MAGN -mng_retcode mng_process_display_magn (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iMethodX, - mng_uint16 iMX, - mng_uint16 iMY, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint16 iMT, - mng_uint16 iMB, - mng_uint8 iMethodY); -mng_retcode mng_process_display_magn2 (mng_datap pData); -#endif - -#ifndef MNG_SKIPCHUNK_PAST -mng_retcode mng_process_display_past (mng_datap pData, - mng_uint16 iTargetid, - mng_uint8 iTargettype, - mng_int32 iTargetx, - mng_int32 iTargety, - mng_uint32 iCount, - mng_ptr pSources); -mng_retcode mng_process_display_past2 (mng_datap pData); -#endif - -#else /* MNG_OPTIMIZE_DISPLAYCALLS */ - -mng_retcode mng_process_display_ihdr (mng_datap pData); -#ifdef MNG_INCLUDE_MPNG_PROPOSAL -mng_retcode mng_process_display_mpng (mng_datap pData); -#endif -mng_retcode mng_process_display_idat (mng_datap pData); -mng_retcode mng_process_display_iend (mng_datap pData); -mng_retcode mng_process_display_mend (mng_datap pData); -mng_retcode mng_process_display_mend2 (mng_datap pData); -mng_retcode mng_process_display_defi (mng_datap pData); -#ifndef MNG_SKIPCHUNK_BASI -mng_retcode mng_process_display_basi (mng_datap pData); -#endif -#ifndef MNG_SKIPCHUNK_CLON -mng_retcode mng_process_display_clon (mng_datap pData); -mng_retcode mng_process_display_clon2 (mng_datap pData); -#endif -#ifndef MNG_SKIPCHUNK_DISC -mng_retcode mng_process_display_disc (mng_datap pData); -#endif -#ifndef MNG_SKIPCHUNK_FRAM -mng_retcode mng_process_display_fram (mng_datap pData); -mng_retcode mng_process_display_fram2 (mng_datap pData); -#endif -#ifndef MNG_SKIPCHUNK_MOVE -mng_retcode mng_process_display_move (mng_datap pData); -#endif -#ifndef MNG_SKIPCHUNK_CLIP -mng_retcode mng_process_display_clip (mng_datap pData); -#endif -#ifndef MNG_SKIPCHUNK_SHOW -mng_retcode mng_process_display_show (mng_datap pData); -#endif -#ifndef MNG_SKIPCHUNK_SAVE -mng_retcode mng_process_display_save (mng_datap pData); -#endif -#ifndef MNG_SKIPCHUNK_SEEK -mng_retcode mng_process_display_seek (mng_datap pData); -#endif -#ifdef MNG_INCLUDE_JNG -mng_retcode mng_process_display_jhdr (mng_datap pData); -mng_retcode mng_process_display_jdaa (mng_datap pData); -mng_retcode mng_process_display_jdat (mng_datap pData); -#endif -#ifndef MNG_NO_DELTA_PNG -mng_retcode mng_process_display_dhdr (mng_datap pData); -mng_retcode mng_process_display_prom (mng_datap pData); -mng_retcode mng_process_display_ipng (mng_datap pData); -#ifdef MNG_INCLUDE_JNG -mng_retcode mng_process_display_ijng (mng_datap pData); -#endif -mng_retcode mng_process_display_pplt (mng_datap pData); -#endif -#ifndef MNG_SKIPCHUNK_MAGN -mng_retcode mng_process_display_magn (mng_datap pData); -mng_retcode mng_process_display_magn2 (mng_datap pData); -#endif -#ifndef MNG_SKIPCHUNK_PAST -mng_retcode mng_process_display_past (mng_datap pData); -mng_retcode mng_process_display_past2 (mng_datap pData); -#endif - -#endif /* MNG_OPTIMIZE_DISPLAYCALLS */ - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_DISPLAY_PROCS */ - -/* ************************************************************************** */ - -#endif /* _libmng_display_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/plugins/AdvaImg/src/LibMNG/libmng_dither.c b/plugins/AdvaImg/src/LibMNG/libmng_dither.c deleted file mode 100644 index 3ba2a7069c..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_dither.c +++ /dev/null @@ -1,58 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_dither.c copyright (c) 2000-2004 G.Juyn * */ -/* * version : 1.0.9 * */ -/* * * */ -/* * purpose : Dithering routines (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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 * */ -/* * * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * * */ -/* * 1.0.9 - 12/20/2004 - G.Juyn * */ -/* * - cleaned up macro-invocations (thanks to D. Airlie) * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_dither.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -mng_retcode mng_dither_a_row (mng_datap pData, - mng_uint8p pRow) -{ - - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - - - diff --git a/plugins/AdvaImg/src/LibMNG/libmng_dither.h b/plugins/AdvaImg/src/LibMNG/libmng_dither.h deleted file mode 100644 index 250c0b9d28..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_dither.h +++ /dev/null @@ -1,45 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_dither.h copyright (c) 2000-2002 G.Juyn * */ -/* * version : 1.0.5 * */ -/* * * */ -/* * purpose : Dithering routines (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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 * */ -/* * * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_dither_h_ -#define _libmng_dither_h_ - -/* ************************************************************************** */ - -mng_retcode mng_dither_a_row (mng_datap pData, - mng_uint8p pRow); - -/* ************************************************************************** */ - -#endif /* _libmng_dither_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/plugins/AdvaImg/src/LibMNG/libmng_error.c b/plugins/AdvaImg/src/LibMNG/libmng_error.c deleted file mode 100644 index 89501a2eae..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_error.c +++ /dev/null @@ -1,326 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_error.c copyright (c) 2000-2007 G.Juyn * */ -/* * version : 1.0.10 * */ -/* * * */ -/* * purpose : Error routines (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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 * */ -/* * * */ -/* * 0.9.3 - 08/09/2000 - G.Juyn * */ -/* * - added check for simplicity-bits in MHDR * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - fixed processing of unknown critical chunks * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/20/2000 - G.Juyn * */ -/* * - added errorcode for delayed delta-processing * */ -/* * * */ -/* * 0.9.4 - 01/18/2001 - G.Juyn * */ -/* * - added errorcode for MAGN methods * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added optimization option for MNG-video playback * */ -/* * * */ -/* * 1.0.5 - 07/04/2002 - G.Juyn * */ -/* * - added errorcode for extreme chunk-sizes * */ -/* * 1.0.5 - 08/15/2002 - G.Juyn * */ -/* * - completed delta-image support * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * 1.0.5 - 09/14/2002 - G.Juyn * */ -/* * - added event handling for dynamic MNG * */ -/* * 1.0.5 - 09/15/2002 - G.Juyn * */ -/* * - fixed LOOP iteration=0 special case * */ -/* * 1.0.5 - 09/19/2002 - G.Juyn * */ -/* * - warnings are ignored by default now! * */ -/* * 1.0.5 - 09/20/2002 - G.Juyn * */ -/* * - added support for PAST * */ -/* * 1.0.5 - 10/07/2002 - G.Juyn * */ -/* * - added check for TERM placement during create/write * */ -/* * * */ -/* * 1.0.6 - 07/07/2003 - G. R-P * */ -/* * - added MNG_SKIPCHUNK_CHNK, MNG_NO_DELTA_PNG reductions. * */ -/* * - skipped more code when MNG_INCLUDE_JNG is not enabled. * */ -/* * 1.0.6 - 07/29/2003 - G.R-P * */ -/* * - added conditional around evNT chunk support * */ -/* * * */ -/* * 1.0.7 - 03/24/2004 - G.R-P * */ -/* * - fixed typo on SKIPCHUNK_evNT (->PAST) * */ -/* * * */ -/* * 1.0.9 - 12/20/2004 - G.Juyn * */ -/* * - cleaned up macro-invocations (thanks to D. Airlie) * */ -/* * * */ -/* * 1.0.10 - 04/08/2007 - G.Juyn * */ -/* * - added support for mPNG proposal * */ -/* * * */ -/* ************************************************************************** */ - -#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_LOCAL mng_error_entry const 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"}, -#ifdef MNG_INCLUDE_JNG - {MNG_JPEGERROR, "ijgsrc6b encountered an error"}, -#endif - {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_LOOPWITHCACHEOFF, "LOOP encountered when playback cache is turned off"}, - - {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"}, -#ifndef MNG_NO_DELTA_PNG - {MNG_INVDELTATYPE, "The delta_type is invalid"}, -#endif - {MNG_INVALIDINDEX, "Index-value out of bounds"}, -#ifdef MNG_INCLUDE_JNG - {MNG_TOOMUCHJDAT, "Too much data in JDAT chunk(s)"}, - {MNG_JPEGPARMSERR, "JHDR parameters & JFIF-data do not match"}, -#endif - {MNG_INVFILLMETHOD, "The fill_method is invalid"}, -#ifndef MNG_NO_DELTA_PNG - {MNG_OBJNOTCONCRETE, "Target object for DHDR must be concrete"}, -#endif - {MNG_TARGETNOALPHA, "Target object must have alpha-channel"}, - {MNG_MNGTOOCOMPLEX, "MHDR simplicity indicates unsupported feature(s)"}, - {MNG_UNKNOWNCRITICAL, "Unknown critical chunk encountered"}, -#ifndef MNG_SKIPCHUNK_nEED - {MNG_UNSUPPORTEDNEED, "Requested nEED resources are not supported"}, -#endif - {MNG_INVALIDDELTA, "The delta operation is invalid (mismatched color_types?)"}, - {MNG_INVALIDMETHOD, "Method is invalid"}, - {MNG_IMPROBABLELENGTH, "Chunklength is incredibly large"}, - {MNG_INVALIDBLOCK, "Delta block width and or height invalid"}, - {MNG_INVALIDEVENT, "Event type is invalid"}, - {MNG_INVALIDMASK, "Mask type is invalid"}, - {MNG_NOMATCHINGLOOP, "ENDL without matching LOOP"}, -#ifndef MNG_SKIPCHUNK_evNT - {MNG_SEEKNOTFOUND, "evNT points to unknown SEEK"}, -#endif -#ifndef MNG_SKIPCHUNK_PAST - {MNG_OBJNOTABSTRACT, "Destination object for PAST must be abstract"}, -#endif - {MNG_TERMSEQERROR, "TERM misplaced during creation of MNG stream"}, - {MNG_INVALIDFIELDVAL, "invalid fieldvalue (generic)"}, - {MNG_INVALIDWIDTH, "invalid frame/image width"}, - {MNG_INVALIDHEIGHT, "invalid frame/image height"}, - - {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 /* MNG_INCLUDE_ERROR_STRINGS */ - pData->zErrortext = 0; -#endif /* MNG_INCLUDE_ERROR_STRINGS */ - - 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 != MNG_NULL) && (pData->iMagic == MNG_MAGIC)) - { - 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_TRUE; /* warnings are ignored by default ! */ -} - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/plugins/AdvaImg/src/LibMNG/libmng_error.h b/plugins/AdvaImg/src/LibMNG/libmng_error.h deleted file mode 100644 index 14eb450a28..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_error.h +++ /dev/null @@ -1,119 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_error.h copyright (c) 2000-2002 G.Juyn * */ -/* * version : 1.0.5 * */ -/* * * */ -/* * purpose : Error functions (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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 * */ -/* * * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * 1.0.5 - 08/20/2002 - G.Juyn * */ -/* * - added option for soft-handling of errors * */ -/* * * */ -/* ************************************************************************** */ - -#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 * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_SOFTERRORS -#define MNG_ERROR(D,C) { if (!mng_process_error (D, C, 0, 0)) return C; } -#define MNG_ERRORZ(D,Z) { if (!mng_process_error (D, MNG_ZLIBERROR, Z, 0)) return MNG_ZLIBERROR; } -#define MNG_ERRORJ(D,J) { if (!mng_process_error (D, MNG_JPEGERROR, J, 0)) return MNG_JPEGERROR; } -#define MNG_ERRORL(D,L) { if (!mng_process_error (D, MNG_LCMSERROR, L, 0)) return MNG_LCMSERROR; } -#else -#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; } -#endif - -#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 const * mng_error_entryp; - -/* ************************************************************************** */ - -#endif /* _libmng_error_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/plugins/AdvaImg/src/LibMNG/libmng_filter.c b/plugins/AdvaImg/src/LibMNG/libmng_filter.c deleted file mode 100644 index ad57a3be90..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_filter.c +++ /dev/null @@ -1,978 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_filter.c copyright (c) 2000-2004 G.Juyn * */ -/* * version : 1.0.9 * */ -/* * * */ -/* * purpose : Filtering routines (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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 * */ -/* * * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * * */ -/* * 1.0.5 - 08/07/2002 - G.Juyn * */ -/* * - added test-option for PNG filter method 193 (=no filter) * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * * */ -/* * 1.0.6 - 07/07/2003 - G.R-P * */ -/* * - reversed some loops to use decrementing counter * */ -/* * * */ -/* * 1.0.9 - 12/20/2004 - G.Juyn * */ -/* * - cleaned up macro-invocations (thanks to D. Airlie) * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_filter.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_FILTERS - -/* ************************************************************************** */ - -MNG_LOCAL 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 + pData->iPixelofs + iBpp; - pRawx_prev = pData->pWorkrow + pData->iPixelofs; - - for (iX = iBpp; iX < pData->iRowsize; iX++) - { - *pRawx = (mng_uint8)(*pRawx + *pRawx_prev); - pRawx++; - pRawx_prev++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FILTER_SUB, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -MNG_LOCAL 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 + pData->iPixelofs; - pPriorx = pData->pPrevrow + pData->iPixelofs; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsize - 1; iX >= 0; iX--) -#else - for (iX = 0; iX < pData->iRowsize; iX++) -#endif - { - *pRawx = (mng_uint8)(*pRawx + *pPriorx); - pRawx++; - pPriorx++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FILTER_UP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -MNG_LOCAL 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 + pData->iPixelofs; - pPriorx = pData->pPrevrow + pData->iPixelofs; - pRawx_prev = pData->pWorkrow + pData->iPixelofs; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = iBpp - 1; iX >= 0; iX--) -#else - for (iX = 0; iX < iBpp; iX++) -#endif - { - *pRawx = (mng_uint8)(*pRawx + ((*pPriorx) >> 1)); - pRawx++; - pPriorx++; - } - - for (iX = iBpp; iX < pData->iRowsize; iX++) - { - *pRawx = (mng_uint8)(*pRawx + ((*pRawx_prev + *pPriorx) >> 1)); - pRawx++; - pPriorx++; - pRawx_prev++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FILTER_AVERAGE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -MNG_LOCAL 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 + pData->iPixelofs; - pPriorx = pData->pPrevrow + pData->iPixelofs; - pRawx_prev = pData->pWorkrow + pData->iPixelofs; - pPriorx_prev = pData->pPrevrow + pData->iPixelofs; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = iBpp - 1; iX >= 0; iX--) -#else - for (iX = 0; iX < iBpp; iX++) -#endif - { - *pRawx = (mng_uint8)(*pRawx + *pPriorx); - - pRawx++; - pPriorx++; - } - - for (iX = iBpp; iX < pData->iRowsize; iX++) - { - iA = (mng_uint32)*pRawx_prev; - iB = (mng_uint32)*pPriorx; - iC = (mng_uint32)*pPriorx_prev; - iP = iA + iB - iC; - iPa = abs (iP - iA); - iPb = abs (iP - iB); - iPc = abs (iP - iC); - - if ((iPa <= iPb) && (iPa <= iPc)) - *pRawx = (mng_uint8)(*pRawx + iA); - else - if (iPb <= iPc) - *pRawx = (mng_uint8)(*pRawx + iB); - else - *pRawx = (mng_uint8)(*pRawx + 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; -} - -/* ************************************************************************** */ - -mng_retcode mng_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 + pData->iFilterofs)) - { - 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; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -#ifdef FILTER192 -mng_retcode mng_init_rowdiffering (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ROWDIFFERING, MNG_LC_START); -#endif - - if (pData->iFilter == 0xC0) /* has leveling parameters ? */ - { - switch (pData->iColortype) /* salvage leveling parameters */ - { - case 0 : { /* gray */ - if (pData->iBitdepth <= 8) - pData->iLevel0 = (mng_uint16)*pData->pWorkrow; - else - pData->iLevel0 = mng_get_uint16 (pData->pWorkrow); - - break; - } - case 2 : { /* rgb */ - if (pData->iBitdepth <= 8) - { - pData->iLevel0 = (mng_uint16)*pData->pWorkrow; - pData->iLevel1 = (mng_uint16)*(pData->pWorkrow+1); - pData->iLevel2 = (mng_uint16)*(pData->pWorkrow+2); - } - else - { - pData->iLevel0 = mng_get_uint16 (pData->pWorkrow); - pData->iLevel1 = mng_get_uint16 (pData->pWorkrow+2); - pData->iLevel2 = mng_get_uint16 (pData->pWorkrow+4); - } - - break; - } - case 3 : { /* indexed */ - pData->iLevel0 = (mng_uint16)*pData->pWorkrow; - break; - } - case 4 : { /* gray+alpha */ - if (pData->iBitdepth <= 8) - { - pData->iLevel0 = (mng_uint16)*pData->pWorkrow; - pData->iLevel1 = (mng_uint16)*(pData->pWorkrow+1); - } - else - { - pData->iLevel0 = mng_get_uint16 (pData->pWorkrow); - pData->iLevel1 = mng_get_uint16 (pData->pWorkrow+2); - } - - break; - } - case 6 : { /* rgb+alpha */ - if (pData->iBitdepth <= 8) - { - pData->iLevel0 = (mng_uint16)*pData->pWorkrow; - pData->iLevel1 = (mng_uint16)*(pData->pWorkrow+1); - pData->iLevel2 = (mng_uint16)*(pData->pWorkrow+2); - pData->iLevel3 = (mng_uint16)*(pData->pWorkrow+3); - } - else - { - pData->iLevel0 = mng_get_uint16 (pData->pWorkrow); - pData->iLevel1 = mng_get_uint16 (pData->pWorkrow+2); - pData->iLevel2 = mng_get_uint16 (pData->pWorkrow+4); - pData->iLevel3 = mng_get_uint16 (pData->pWorkrow+6); - } - - break; - } - } - } - /* shift the entire row back in place */ - pRawi = pData->pWorkrow + pData->iFilterofs; - pRawo = pData->pWorkrow; - - for (iX = 0; iX < pData->iRowsize + pData->iPixelofs - pData->iFilterofs; iX++) - *pRawo++ = *pRawi++; - - pData->iFilterofs = 0; /* indicate so ! */ - -#ifdef FILTER193 - if (pData->iFilter == 0xC1) /* no adaptive filtering ? */ - pData->iPixelofs = pData->iFilterofs; - else -#endif - pData->iPixelofs = pData->iFilterofs + 1; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ROWDIFFERING, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_differ_g1 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G1, MNG_LC_START); -#endif - - if (pData->iLevel0 & 0x01) /* is it uneven level ? */ - { - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - /* just invert every bit */ -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsize - 1; iX >= 0; iX--) -#else - for (iX = 0; iX < pData->iRowsize; iX++) -#endif - *pRawo++ = (mng_uint8)(~(*pRawi++)); - - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_differ_g2 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - mng_int32 iC, iS; - mng_uint8 iB, iN, iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G2, MNG_LC_START); -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - iC = 0; - iB = 0; - iN = 0; - iS = 0; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples - 1; iX >= 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iC) - { - iC = 4; - iB = *pRawi++; - iN = 0; - iS = 8; - } - - iS -= 2; - iQ = (mng_uint8)(((iB >> iS) + pData->iLevel0) & 0x03); - iN = (mng_uint8)((iN << 2) + iQ); - iC--; - - if (!iC) - *pRawo++ = iN; - - } - - if (iC) - *pRawo = (mng_uint8)(iN << iS); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_differ_g4 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - mng_int32 iC, iS; - mng_uint8 iB, iN, iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G4, MNG_LC_START); -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - iC = 0; - iB = 0; - iN = 0; - iS = 0; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples - 1; iX >= 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iC) - { - iC = 2; - iB = *pRawi++; - iN = 0; - iS = 8; - } - - iS -= 4; - iQ = (mng_uint8)(((iB >> iS) + pData->iLevel0) & 0x0F); - iN = (mng_uint8)((iN << 4) + iQ); - iC--; - - if (!iC) - *pRawo++ = iN; - - } - - if (iC) - *pRawo = (mng_uint8)(iN << iS); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G4, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_differ_g8 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G8, MNG_LC_START); -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples - 1; iX >= 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pRawo++ = (mng_uint8)(((mng_uint16)*pRawi + pData->iLevel0) & 0xFF); - - pRawi++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_differ_g16 (mng_datap pData) -{ - mng_uint16p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G16, MNG_LC_START); -#endif - - pRawi = (mng_uint16p)(pData->pWorkrow + pData->iPixelofs); - pRawo = (mng_uint16p)(pData->pPrevrow + pData->iPixelofs); - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples - 1; iX >= 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pRawo++ = (mng_uint16)(((mng_uint32)*pRawi + (mng_uint32)pData->iLevel0) & 0xFFFF); - - pRawi++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_differ_rgb8 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_RGB8, MNG_LC_START); -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples - 1; iX >= 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *(pRawo+1) = (mng_uint8)(((mng_uint16)*(pRawi+1) + pData->iLevel1) & 0xFF); - *pRawo = (mng_uint8)(((mng_uint16)*pRawi + pData->iLevel0 + - (mng_uint16)*(pRawo+1)) & 0xFF); - *(pRawo+2) = (mng_uint8)(((mng_uint16)*(pRawi+2) + pData->iLevel2 + - (mng_uint16)*(pRawo+1)) & 0xFF); - - pRawi += 3; - pRawo += 3; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_RGB8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_differ_rgb16 (mng_datap pData) -{ - mng_uint16p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_RGB16, MNG_LC_START); -#endif - - pRawi = (mng_uint16p)(pData->pWorkrow + pData->iPixelofs); - pRawo = (mng_uint16p)(pData->pPrevrow + pData->iPixelofs); - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples - 1; iX >= 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *(pRawo+1) = (mng_uint16)(((mng_uint32)*(pRawi+1) + (mng_uint32)pData->iLevel1) & 0xFFFF); - *pRawo = (mng_uint16)(((mng_uint32)*pRawi + (mng_uint32)pData->iLevel0 + - (mng_uint32)*(pRawo+1)) & 0xFFFF); - *(pRawo+2) = (mng_uint16)(((mng_uint32)*(pRawi+2) + (mng_uint32)pData->iLevel2 + - (mng_uint32)*(pRawo+1)) & 0xFFFF); - - pRawi += 3; - pRawo += 3; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_RGB16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_differ_idx1 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_IDX1, MNG_LC_START); -#endif - - if (pData->iLevel0 & 0x01) /* is it uneven level ? */ - { - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - /* just invert every bit */ -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsize - 1; iX >= 0; iX--) -#else - for (iX = 0; iX < pData->iRowsize; iX++) -#endif - *pRawo++ = (mng_uint8)(~(*pRawi++)); - - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_IDX1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_differ_idx2 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - mng_int32 iC, iS; - mng_uint8 iB, iN, iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_IDX2, MNG_LC_START); -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - iC = 0; - iB = 0; - iN = 0; - iS = 0; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples - 1; iX >= 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iC) - { - iC = 4; - iB = *pRawi++; - iN = 0; - iS = 8; - } - - iS -= 2; - iQ = (mng_uint8)(((iB >> iS) + pData->iLevel0) & 0x03); - iN = (mng_uint8)((iN << 2) + iQ); - iC--; - - if (!iC) - *pRawo++ = iN; - - } - - if (iC) - *pRawo = (mng_uint8)(iN << iS); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_IDX2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_differ_idx4 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - mng_int32 iC, iS; - mng_uint8 iB, iN, iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_IDX4, MNG_LC_START); -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - iC = 0; - iB = 0; - iN = 0; - iS = 0; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples - 1; iX >= 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iC) - { - iC = 2; - iB = *pRawi++; - iN = 0; - iS = 8; - } - - iS -= 4; - iQ = (mng_uint8)(((iB >> iS) + pData->iLevel0) & 0x0F); - iN = (mng_uint8)((iN << 4) + iQ); - iC--; - - if (!iC) - *pRawo++ = iN; - - } - - if (iC) - *pRawo = (mng_uint8)(iN << iS); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_IDX4, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_differ_idx8 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_IDX8, MNG_LC_START); -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples - 1; iX >= 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pRawo++ = (mng_uint8)(((mng_uint16)*pRawi + pData->iLevel0) & 0xFF); - - pRawi++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_IDX8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_differ_ga8 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_GA8, MNG_LC_START); -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples - 1; iX >= 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pRawo = (mng_uint8)(((mng_uint16)*pRawi + pData->iLevel0) & 0xFF); - *(pRawo+1) = (mng_uint8)(((mng_uint16)*(pRawi+1) + pData->iLevel1) & 0xFF); - - pRawi += 2; - pRawo += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_GA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_differ_ga16 (mng_datap pData) -{ - mng_uint16p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_GA16, MNG_LC_START); -#endif - - pRawi = (mng_uint16p)(pData->pWorkrow + pData->iPixelofs); - pRawo = (mng_uint16p)(pData->pPrevrow + pData->iPixelofs); - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples - 1; iX >= 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pRawo = (mng_uint16)(((mng_uint32)*pRawi + (mng_uint32)pData->iLevel0) & 0xFFFF); - *(pRawo+1) = (mng_uint16)(((mng_uint32)*(pRawi+1) + (mng_uint32)pData->iLevel1) & 0xFFFF); - - pRawi += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_GA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_differ_rgba8 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_RGBA8, MNG_LC_START); -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples - 1; iX >= 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *(pRawo+1) = (mng_uint8)(((mng_uint16)*(pRawi+1) + pData->iLevel1) & 0xFF); - *pRawo = (mng_uint8)(((mng_uint16)*pRawi + pData->iLevel0 + - (mng_uint16)*(pRawo+1)) & 0xFF); - *(pRawo+2) = (mng_uint8)(((mng_uint16)*(pRawi+2) + pData->iLevel2 + - (mng_uint16)*(pRawo+1)) & 0xFF); - *(pRawo+3) = (mng_uint8)(((mng_uint16)*(pRawi+3) + pData->iLevel3) & 0xFF); - - pRawi += 4; - pRawo += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_RGBA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_differ_rgba16 (mng_datap pData) -{ - mng_uint16p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_RGBA16, MNG_LC_START); -#endif - - pRawi = (mng_uint16p)(pData->pWorkrow + pData->iPixelofs); - pRawo = (mng_uint16p)(pData->pPrevrow + pData->iPixelofs); - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples - 1; iX >= 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *(pRawo+1) = (mng_uint16)(((mng_uint32)*(pRawi+1) + (mng_uint32)pData->iLevel1) & 0xFFFF); - *pRawo = (mng_uint16)(((mng_uint32)*pRawi + (mng_uint32)pData->iLevel0 + - (mng_uint32)*(pRawo+1)) & 0xFFFF); - *(pRawo+2) = (mng_uint16)(((mng_uint32)*(pRawi+2) + (mng_uint32)pData->iLevel2 + - (mng_uint32)*(pRawo+1)) & 0xFFFF); - *(pRawo+3) = (mng_uint16)(((mng_uint32)*(pRawi+3) + (mng_uint32)pData->iLevel3) & 0xFFFF); - - pRawi += 4; - pRawo += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_RGBA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* FILTER192 */ - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_FILTERS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/plugins/AdvaImg/src/LibMNG/libmng_filter.h b/plugins/AdvaImg/src/LibMNG/libmng_filter.h deleted file mode 100644 index 5ff4cb609b..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_filter.h +++ /dev/null @@ -1,69 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_filter.h copyright (c) 2000-2002 G.Juyn * */ -/* * version : 1.0.5 * */ -/* * * */ -/* * purpose : Filtering routines (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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 * */ -/* * * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_filter_h_ -#define _libmng_filter_h_ - -/* ************************************************************************** */ - -mng_retcode mng_filter_a_row (mng_datap pData); - -/* ************************************************************************** */ - -#ifdef FILTER192 -mng_retcode mng_init_rowdiffering (mng_datap pData); - -mng_retcode mng_differ_g1 (mng_datap pData); -mng_retcode mng_differ_g2 (mng_datap pData); -mng_retcode mng_differ_g4 (mng_datap pData); -mng_retcode mng_differ_g8 (mng_datap pData); -mng_retcode mng_differ_g16 (mng_datap pData); -mng_retcode mng_differ_rgb8 (mng_datap pData); -mng_retcode mng_differ_rgb16 (mng_datap pData); -mng_retcode mng_differ_idx1 (mng_datap pData); -mng_retcode mng_differ_idx2 (mng_datap pData); -mng_retcode mng_differ_idx4 (mng_datap pData); -mng_retcode mng_differ_idx8 (mng_datap pData); -mng_retcode mng_differ_ga8 (mng_datap pData); -mng_retcode mng_differ_ga16 (mng_datap pData); -mng_retcode mng_differ_rgba8 (mng_datap pData); -mng_retcode mng_differ_rgba16 (mng_datap pData); -#endif - -/* ************************************************************************** */ - -#endif /* _libmng_filter_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/plugins/AdvaImg/src/LibMNG/libmng_hlapi.c b/plugins/AdvaImg/src/LibMNG/libmng_hlapi.c deleted file mode 100644 index ef0c2e1484..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_hlapi.c +++ /dev/null @@ -1,2995 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_hlapi.c copyright (c) 2000-2007 G.Juyn * */ -/* * version : 1.0.10 * */ -/* * * */ -/* * purpose : high-level application API (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * comment : implementation of the high-level function interface * */ -/* * for applications. * */ -/* * * */ -/* * changes : 0.5.1 - 05/06/2000 - G.Juyn * */ -/* * - added init of iPLTEcount * */ -/* * 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed calling-convention definition * */ -/* * - changed status-handling of display-routines * */ -/* * - added versioning-control routines * */ -/* * - filled the write routine * */ -/* * - 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.1 - 05/13/2000 - G.Juyn * */ -/* * - added eMNGma hack (will be removed in 1.0.0 !!!) * */ -/* * - added TERM animation object pointer (easier reference) * */ -/* * 0.5.1 - 05/14/2000 - G.Juyn * */ -/* * - added cleanup of saved-data (SAVE/SEEK processing) * */ -/* * 0.5.1 - 05/16/2000 - G.Juyn * */ -/* * - moved the actual write_graphic functionality from here * */ -/* * to its appropriate function in the mng_write module * */ -/* * * */ -/* * 0.5.2 - 05/19/2000 - G.Juyn * */ -/* * - cleaned up some code regarding mixed support * */ -/* * - added JNG support * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - moved init of default zlib parms here from "mng_zlib.c" * */ -/* * - added init of default IJG parms * */ -/* * 0.5.2 - 05/29/2000 - G.Juyn * */ -/* * - fixed inconsistancy with freeing global iCCP profile * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added delta-image field initialization * */ -/* * 0.5.2 - 06/06/2000 - G.Juyn * */ -/* * - added initialization of the buffer-suspend parameter * */ -/* * * */ -/* * 0.5.3 - 06/16/2000 - G.Juyn * */ -/* * - added initialization of update-region for refresh * */ -/* * - added initialization of Needrefresh parameter * */ -/* * 0.5.3 - 06/17/2000 - G.Juyn * */ -/* * - added initialization of Deltaimmediate * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added initialization of Speed * */ -/* * - added initialization of Imagelevel * */ -/* * 0.5.3 - 06/26/2000 - G.Juyn * */ -/* * - changed userdata variable to mng_ptr * */ -/* * 0.5.3 - 06/29/2000 - G.Juyn * */ -/* * - fixed initialization routine for new mng_handle type * */ -/* * * */ -/* * 0.9.1 - 07/06/2000 - G.Juyn * */ -/* * - changed mng_display_resume to allow to be called after * */ -/* * a suspension return with MNG_NEEDMOREDATA * */ -/* * - added returncode MNG_NEEDTIMERWAIT for timer breaks * */ -/* * 0.9.1 - 07/07/2000 - G.Juyn * */ -/* * - implemented support for freeze/reset/resume & go_xxxx * */ -/* * 0.9.1 - 07/08/2000 - G.Juyn * */ -/* * - added support for improved timing * */ -/* * - added support for improved I/O-suspension * */ -/* * 0.9.1 - 07/14/2000 - G.Juyn * */ -/* * - changed EOF processing behavior * */ -/* * 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 * */ -/* * - added error cleanup processing * */ -/* * - fixed support for mng_display_reset() * */ -/* * - fixed suspension-buffering for 32K+ chunks * */ -/* * * */ -/* * 0.9.2 - 07/29/2000 - G.Juyn * */ -/* * - fixed small bugs in display processing * */ -/* * 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 * */ -/* * * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * 0.9.3 - 09/10/2000 - G.Juyn * */ -/* * - fixed DEFI behavior * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added optional support for bKGD for PNG images * */ -/* * - raised initial maximum canvas size * */ -/* * - added support for JDAA * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added callback to process non-critical unknown chunks * */ -/* * - fixed support for delta-images during read() / display() * */ -/* * 0.9.3 - 10/18/2000 - G.Juyn * */ -/* * - added closestream() processing for mng_cleanup() * */ -/* * 0.9.3 - 10/27/2000 - G.Juyn * */ -/* * - fixed separate read() & display() processing * */ -/* * * */ -/* * 0.9.4 - 11/20/2000 - G.Juyn * */ -/* * - fixed unwanted repetition in mng_readdisplay() * */ -/* * 0.9.4 - 11/24/2000 - G.Juyn * */ -/* * - moved restore of object 0 to libmng_display * */ -/* * * */ -/* * 1.0.1 - 02/08/2001 - G.Juyn * */ -/* * - added MEND processing callback * */ -/* * 1.0.1 - 02/13/2001 - G.Juyn * */ -/* * - fixed first FRAM_MODE=4 timing problem * */ -/* * 1.0.1 - 04/21/2001 - G.Juyn * */ -/* * - fixed bug with display_reset/display_resume (Thanks G!) * */ -/* * 1.0.1 - 04/22/2001 - G.Juyn * */ -/* * - fixed memory-leak (Thanks Gregg!) * */ -/* * 1.0.1 - 04/23/2001 - G.Juyn * */ -/* * - fixed reset_rundata to drop all objects * */ -/* * 1.0.1 - 04/25/2001 - G.Juyn * */ -/* * - moved mng_clear_cms to libmng_cms * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added optimization option for MNG-video playback * */ -/* * - added processterm callback * */ -/* * 1.0.2 - 06/25/2001 - G.Juyn * */ -/* * - added option to turn off progressive refresh * */ -/* * * */ -/* * 1.0.5 - 07/08/2002 - G.Juyn * */ -/* * - B578572 - removed eMNGma hack (thanks Dimitri!) * */ -/* * 1.0.5 - 07/16/2002 - G.Juyn * */ -/* * - B581625 - large chunks fail with suspension reads * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * 1.0.5 - 09/15/2002 - G.Juyn * */ -/* * - fixed LOOP iteration=0 special case * */ -/* * 1.0.5 - 10/07/2002 - G.Juyn * */ -/* * - added another fix for misplaced TERM chunk * */ -/* * - completed support for condition=2 in TERM chunk * */ -/* * - added beta version function & constant * */ -/* * 1.0.5 - 10/11/2002 - G.Juyn * */ -/* * - added mng_status_dynamic to supports function * */ -/* * 1.0.5 - 11/04/2002 - G.Juyn * */ -/* * - changed FRAMECOUNT/LAYERCOUNT/PLAYTIME error to warning * */ -/* * 1.0.5 - 11/07/2002 - G.Juyn * */ -/* * - added support to get totals after mng_read() * */ -/* * 1.0.5 - 11/29/2002 - G.Juyn * */ -/* * - fixed goxxxxx() support for zero values * */ -/* * * */ -/* * 1.0.6 - 05/25/2003 - G.R-P * */ -/* * - added MNG_SKIPCHUNK_cHNK footprint optimizations * */ -/* * 1.0.6 - 07/11/2003 - G.R-P * */ -/* * - added conditionals zlib and jpeg property accessors * */ -/* * 1.0.6 - 07/14/2003 - G.R-P * */ -/* * - added conditionals around "mng_display_go*" and other * */ -/* * unused functions * */ -/* * 1.0.6 - 07/29/2003 - G.R-P * */ -/* * - added conditionals around PAST chunk support * */ -/* * * */ -/* * 1.0.7 - 03/07/2004 - G. Randers-Pehrson * */ -/* * - put gamma, cms-related declarations inside #ifdef * */ -/* * 1.0.7 - 03/10/2004 - G.R-P * */ -/* * - added conditionals around openstream/closestream * */ -/* * 1.0.7 - 03/24/2004 - G.R-P * */ -/* * - fixed zTXT -> zTXt typo * */ -/* * * */ -/* * 1.0.8 - 04/02/2004 - G.Juyn * */ -/* * - added CRC existence & checking flags * */ -/* * 1.0.8 - 04/10/2004 - G.Juyn * */ -/* * - added data-push mechanisms for specialized decoders * */ -/* * 1.0.8 - 07/06/2004 - G.R-P * */ -/* * - defend against using undefined openstream function * */ -/* * 1.0.8 - 08/02/2004 - G.Juyn * */ -/* * - added conditional to allow easier writing of large MNG's * */ -/* * * */ -/* * 1.0.9 - 08/17/2004 - G.R-P * */ -/* * - added more SKIPCHUNK conditionals * */ -/* * 1.0.9 - 09/25/2004 - G.Juyn * */ -/* * - replaced MNG_TWEAK_LARGE_FILES with permanent solution * */ -/* * 1.0.9 - 10/03/2004 - G.Juyn * */ -/* * - added function to retrieve current FRAM delay * */ -/* * 1.0.9 - 12/20/2004 - G.Juyn * */ -/* * - cleaned up macro-invocations (thanks to D. Airlie) * */ -/* * * */ -/* * 1.0.10 - 07/06/2005 - G.R-P * */ -/* * - added more SKIPCHUNK conditionals * */ -/* * 1.0.10 - 04/08/2007 - G.Juyn * */ -/* * - added support for mPNG proposal * */ -/* * 1.0.10 - 04/12/2007 - G.Juyn * */ -/* * - added support for ANG proposal * */ -/* * 1.0.10 - 07/06/2007 - G.R-P bugfix by Lucas Quintana * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_objects.h" -#include "libmng_object_prc.h" -#include "libmng_chunks.h" -#include "libmng_memory.h" -#include "libmng_read.h" -#include "libmng_write.h" -#include "libmng_display.h" -#include "libmng_zlib.h" -#include "libmng_jpeg.h" -#include "libmng_cms.h" -#include "libmng_pixels.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ -/* * * */ -/* * local routines * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -MNG_LOCAL mng_retcode mng_drop_objects (mng_datap pData, - mng_bool bDropaniobj) -{ - mng_objectp pObject; - mng_objectp pNext; - mng_cleanupobject fCleanup; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DROP_OBJECTS, MNG_LC_START); -#endif - - pObject = pData->pFirstimgobj; /* get first stored image-object (if any) */ - - while (pObject) /* more objects to discard ? */ - { - pNext = ((mng_object_headerp)pObject)->pNext; - /* call appropriate cleanup */ - fCleanup = ((mng_object_headerp)pObject)->fCleanup; - fCleanup (pData, pObject); - - pObject = pNext; /* neeeext */ - } - - pData->pFirstimgobj = MNG_NULL; /* clean this up!!! */ - pData->pLastimgobj = MNG_NULL; - - if (bDropaniobj) /* drop animation objects ? */ - { - pObject = pData->pFirstaniobj; /* get first stored animation-object (if any) */ - - while (pObject) /* more objects to discard ? */ - { - pNext = ((mng_object_headerp)pObject)->pNext; - /* call appropriate cleanup */ - fCleanup = ((mng_object_headerp)pObject)->fCleanup; - fCleanup (pData, pObject); - - pObject = pNext; /* neeeext */ - } - - pData->pFirstaniobj = MNG_NULL; /* clean this up!!! */ - pData->pLastaniobj = MNG_NULL; - -#ifdef MNG_SUPPORT_DYNAMICMNG - pObject = pData->pFirstevent; /* get first event-object (if any) */ - - while (pObject) /* more objects to discard ? */ - { - pNext = ((mng_object_headerp)pObject)->pNext; - /* call appropriate cleanup */ - fCleanup = ((mng_object_headerp)pObject)->fCleanup; - fCleanup (pData, pObject); - - pObject = pNext; /* neeeext */ - } - - pData->pFirstevent = MNG_NULL; /* clean this up!!! */ - pData->pLastevent = MNG_NULL; -#endif - } - -#ifdef MNG_INCLUDE_MPNG_PROPOSAL - if (pData->pMPNG) /* drop MPNG data (if any) */ - { - fCleanup = ((mng_object_headerp)pData->pMPNG)->fCleanup; - fCleanup (pData, pData->pMPNG); - pData->pMPNG = MNG_NULL; - } -#endif - -#ifdef MNG_INCLUDE_ANG_PROPOSAL - if (pData->pANG) /* drop ANG data (if any) */ - { - fCleanup = ((mng_object_headerp)pData->pANG)->fCleanup; - fCleanup (pData, pData->pANG); - pData->pANG = MNG_NULL; - } -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DROP_OBJECTS, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -#ifndef MNG_SKIPCHUNK_SAVE -MNG_LOCAL mng_retcode mng_drop_savedata (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DROP_SAVEDATA, MNG_LC_START); -#endif - - if (pData->pSavedata) /* sanity check */ - { /* address it more directly */ - mng_savedatap pSave = pData->pSavedata; - - if (pSave->iGlobalProfilesize) /* cleanup the profile ? */ - MNG_FREEX (pData, pSave->pGlobalProfile, pSave->iGlobalProfilesize); - /* cleanup the save structure */ - MNG_FREE (pData, pData->pSavedata, sizeof (mng_savedata)); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DROP_SAVEDATA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -MNG_LOCAL mng_retcode mng_reset_rundata (mng_datap pData) -{ - mng_drop_invalid_objects (pData); /* drop invalidly stored objects */ -#ifndef MNG_SKIPCHUNK_SAVE - mng_drop_savedata (pData); /* drop stored savedata */ -#endif - mng_reset_objzero (pData); /* reset object 0 */ - /* drop stored objects (if any) */ - mng_drop_objects (pData, MNG_FALSE); - - pData->bFramedone = MNG_FALSE; - pData->iFrameseq = 0; /* reset counters & stuff */ - pData->iLayerseq = 0; - pData->iFrametime = 0; - - pData->bSkipping = MNG_FALSE; - -#ifdef MNG_SUPPORT_DYNAMICMNG - pData->bRunningevent = MNG_FALSE; - pData->bStopafterseek = MNG_FALSE; - pData->iEventx = 0; - pData->iEventy = 0; - pData->pLastmousemove = MNG_NULL; -#endif - - pData->iRequestframe = 0; - pData->iRequestlayer = 0; - pData->iRequesttime = 0; - pData->bSearching = MNG_FALSE; - - pData->iRuntime = 0; - pData->iSynctime = 0; - pData->iStarttime = 0; - pData->iEndtime = 0; - pData->bRunning = MNG_FALSE; - pData->bTimerset = MNG_FALSE; - pData->iBreakpoint = 0; - pData->bSectionwait = MNG_FALSE; - pData->bFreezing = MNG_FALSE; - pData->bResetting = MNG_FALSE; - pData->bNeedrefresh = MNG_FALSE; - pData->bOnlyfirstframe = MNG_FALSE; - pData->iFramesafterTERM = 0; - - pData->iIterations = 0; - /* start of animation objects! */ - pData->pCurraniobj = MNG_NULL; - - pData->iUpdateleft = 0; /* reset region */ - pData->iUpdateright = 0; - pData->iUpdatetop = 0; - pData->iUpdatebottom = 0; - pData->iPLTEcount = 0; /* reset PLTE data */ - -#ifndef MNG_SKIPCHUNK_DEFI - pData->iDEFIobjectid = 0; /* reset DEFI data */ - pData->bDEFIhasdonotshow = MNG_FALSE; - pData->iDEFIdonotshow = 0; - pData->bDEFIhasconcrete = MNG_FALSE; - pData->iDEFIconcrete = 0; - pData->bDEFIhasloca = MNG_FALSE; - pData->iDEFIlocax = 0; - pData->iDEFIlocay = 0; - pData->bDEFIhasclip = MNG_FALSE; - pData->iDEFIclipl = 0; - pData->iDEFIclipr = 0; - pData->iDEFIclipt = 0; - pData->iDEFIclipb = 0; -#endif - -#ifndef MNG_SKIPCHUNK_BACK - pData->iBACKred = 0; /* reset BACK data */ - pData->iBACKgreen = 0; - pData->iBACKblue = 0; - pData->iBACKmandatory = 0; - pData->iBACKimageid = 0; - pData->iBACKtile = 0; -#endif - -#ifndef MNG_SKIPCHUNK_FRAM - pData->iFRAMmode = 1; /* default global FRAM variables */ - pData->iFRAMdelay = 1; - pData->iFRAMtimeout = 0x7fffffffl; - pData->bFRAMclipping = MNG_FALSE; - pData->iFRAMclipl = 0; - pData->iFRAMclipr = 0; - pData->iFRAMclipt = 0; - pData->iFRAMclipb = 0; - - pData->iFramemode = 1; /* again for the current frame */ - pData->iFramedelay = 1; - pData->iFrametimeout = 0x7fffffffl; - pData->bFrameclipping = MNG_FALSE; - pData->iFrameclipl = 0; - pData->iFrameclipr = 0; - pData->iFrameclipt = 0; - pData->iFrameclipb = 0; - - pData->iNextdelay = 1; -#endif - -#ifndef MNG_SKIPCHUNK_SHOW - pData->iSHOWmode = 0; /* reset SHOW data */ - pData->iSHOWfromid = 0; - pData->iSHOWtoid = 0; - pData->iSHOWnextid = 0; - pData->iSHOWskip = 0; -#endif - - pData->iGlobalPLTEcount = 0; /* reset global PLTE data */ - - pData->iGlobalTRNSrawlen = 0; /* reset global tRNS data */ - - pData->iGlobalGamma = 0; /* reset global gAMA data */ - -#ifndef MNG_SKIPCHUNK_cHRM - pData->iGlobalWhitepointx = 0; /* reset global cHRM data */ - pData->iGlobalWhitepointy = 0; - pData->iGlobalPrimaryredx = 0; - pData->iGlobalPrimaryredy = 0; - pData->iGlobalPrimarygreenx = 0; - pData->iGlobalPrimarygreeny = 0; - pData->iGlobalPrimarybluex = 0; - pData->iGlobalPrimarybluey = 0; -#endif - -#ifndef MNG_SKIPCHUNK_sRGB - pData->iGlobalRendintent = 0; /* reset global sRGB data */ -#endif - -#ifndef MNG_SKIPCHUNK_iCCP - if (pData->iGlobalProfilesize) /* drop global profile (if any) */ - MNG_FREE (pData, pData->pGlobalProfile, pData->iGlobalProfilesize); - - pData->iGlobalProfilesize = 0; -#endif - -#ifndef MNG_SKIPCHUNK_bKGD - pData->iGlobalBKGDred = 0; /* reset global bKGD data */ - pData->iGlobalBKGDgreen = 0; - pData->iGlobalBKGDblue = 0; -#endif -#ifndef MNG_NO_DELTA_PNG - /* reset delta-image */ - pData->pDeltaImage = MNG_NULL; - pData->iDeltaImagetype = 0; - pData->iDeltatype = 0; - pData->iDeltaBlockwidth = 0; - pData->iDeltaBlockheight = 0; - pData->iDeltaBlockx = 0; - pData->iDeltaBlocky = 0; - pData->bDeltaimmediate = MNG_FALSE; - - pData->fDeltagetrow = MNG_NULL; - pData->fDeltaaddrow = MNG_NULL; - pData->fDeltareplacerow = MNG_NULL; - pData->fDeltaputrow = MNG_NULL; - - pData->fPromoterow = MNG_NULL; - pData->fPromBitdepth = MNG_NULL; - pData->pPromBuf = MNG_NULL; - pData->iPromColortype = 0; - pData->iPromBitdepth = 0; - pData->iPromFilltype = 0; - pData->iPromWidth = 0; - pData->pPromSrc = MNG_NULL; - pData->pPromDst = MNG_NULL; -#endif - -#ifndef MNG_SKIPCHUNK_MAGN - pData->iMAGNfromid = 0; - pData->iMAGNtoid = 0; -#endif - -#ifndef MNG_SKIPCHUNK_PAST - pData->iPastx = 0; - pData->iPasty = 0; -#endif - - pData->pLastseek = MNG_NULL; - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -MNG_LOCAL void cleanup_errors (mng_datap pData) -{ - pData->iErrorcode = MNG_NOERROR; - pData->iSeverity = 0; - pData->iErrorx1 = 0; - pData->iErrorx2 = 0; - pData->zErrortext = MNG_NULL; - - return; -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -MNG_LOCAL mng_retcode make_pushbuffer (mng_datap pData, - mng_ptr pPushdata, - mng_size_t iLength, - mng_bool bTakeownership, - mng_pushdatap * pPush) -{ - mng_pushdatap pTemp; - - MNG_ALLOC (pData, pTemp, sizeof(mng_pushdata)); - - pTemp->pNext = MNG_NULL; - - if (bTakeownership) /* are we going to own the buffer? */ - { /* then just copy the pointer */ - pTemp->pData = (mng_uint8p)pPushdata; - } - else - { /* otherwise create new buffer */ - MNG_ALLOCX (pData, pTemp->pData, iLength); - if (!pTemp->pData) /* succeeded? */ - { - MNG_FREEX (pData, pTemp, sizeof(mng_pushdata)); - MNG_ERROR (pData, MNG_OUTOFMEMORY); - } - /* and copy the bytes across */ - MNG_COPY (pTemp->pData, pPushdata, iLength); - } - - pTemp->iLength = iLength; - pTemp->bOwned = bTakeownership; - pTemp->pDatanext = pTemp->pData; - pTemp->iRemaining = iLength; - - *pPush = pTemp; /* return it */ - - return MNG_NOERROR; /* and all's well */ -} -#endif - -#ifdef MNG_VERSION_QUERY_SUPPORT -/* ************************************************************************** */ -/* * * */ -/* * Versioning control * */ -/* * * */ -/* ************************************************************************** */ - -mng_pchar MNG_DECL mng_version_text (void) -{ - return MNG_VERSION_TEXT; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_version_so (void) -{ - return MNG_VERSION_SO; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_version_dll (void) -{ - return MNG_VERSION_DLL; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_version_major (void) -{ - return MNG_VERSION_MAJOR; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_version_minor (void) -{ - return MNG_VERSION_MINOR; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_version_release (void) -{ - return MNG_VERSION_RELEASE; -} - -/* ************************************************************************** */ - -mng_bool MNG_DECL mng_version_beta (void) -{ - return MNG_VERSION_BETA; -} -#endif - -/* ************************************************************************** */ -/* * * */ -/* * 'supports' function * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_FUNCQUERY -typedef struct { - mng_pchar zFunction; - mng_uint8 iMajor; /* Major == 0 means not implemented ! */ - mng_uint8 iMinor; - mng_uint8 iRelease; - } mng_func_entry; -typedef mng_func_entry const * mng_func_entryp; - -MNG_LOCAL mng_func_entry const func_table [] = - { /* keep it alphabetically sorted !!!!! */ - {"mng_cleanup", 1, 0, 0}, - {"mng_copy_chunk", 1, 0, 5}, - {"mng_create", 1, 0, 0}, - {"mng_display", 1, 0, 0}, - {"mng_display_freeze", 1, 0, 0}, -#ifndef MNG_NO_DISPLAY_GO_SUPPORTED - {"mng_display_goframe", 1, 0, 0}, - {"mng_display_golayer", 1, 0, 0}, - {"mng_display_gotime", 1, 0, 0}, -#endif - {"mng_display_reset", 1, 0, 0}, - {"mng_display_resume", 1, 0, 0}, - {"mng_get_alphabitdepth", 1, 0, 0}, - {"mng_get_alphacompression", 1, 0, 0}, - {"mng_get_alphadepth", 1, 0, 0}, - {"mng_get_alphafilter", 1, 0, 0}, - {"mng_get_alphainterlace", 1, 0, 0}, - {"mng_get_bgcolor", 1, 0, 0}, - {"mng_get_bitdepth", 1, 0, 0}, - {"mng_get_bkgdstyle", 1, 0, 0}, - {"mng_get_cacheplayback", 1, 0, 2}, - {"mng_get_canvasstyle", 1, 0, 0}, - {"mng_get_colortype", 1, 0, 0}, - {"mng_get_compression", 1, 0, 0}, -#ifndef MNG_NO_CURRENT_INFO - {"mng_get_currentframe", 1, 0, 0}, - {"mng_get_currentlayer", 1, 0, 0}, - {"mng_get_currentplaytime", 1, 0, 0}, -#endif - {"mng_get_currframdelay", 1, 0, 9}, -#ifndef MNG_NO_DFLT_INFO - {"mng_get_dfltimggamma", 1, 0, 0}, - {"mng_get_dfltimggammaint", 1, 0, 0}, -#endif - {"mng_get_displaygamma", 1, 0, 0}, - {"mng_get_displaygammaint", 1, 0, 0}, - {"mng_get_doprogressive", 1, 0, 2}, - {"mng_get_filter", 1, 0, 0}, - {"mng_get_framecount", 1, 0, 0}, - {"mng_get_imageheight", 1, 0, 0}, - {"mng_get_imagelevel", 1, 0, 0}, - {"mng_get_imagetype", 1, 0, 0}, - {"mng_get_imagewidth", 1, 0, 0}, - {"mng_get_interlace", 1, 0, 0}, -#ifdef MNG_ACCESS_JPEG - {"mng_get_jpeg_dctmethod", 1, 0, 0}, - {"mng_get_jpeg_maxjdat", 1, 0, 0}, - {"mng_get_jpeg_optimized", 1, 0, 0}, - {"mng_get_jpeg_progressive", 1, 0, 0}, - {"mng_get_jpeg_quality", 1, 0, 0}, - {"mng_get_jpeg_smoothing", 1, 0, 0}, -#endif - {"mng_get_lastbackchunk", 1, 0, 3}, - {"mng_get_lastseekname", 1, 0, 5}, - {"mng_get_layercount", 1, 0, 0}, -#ifndef MNG_SKIP_MAXCANVAS - {"mng_get_maxcanvasheight", 1, 0, 0}, - {"mng_get_maxcanvaswidth", 1, 0, 0}, -#endif - {"mng_get_playtime", 1, 0, 0}, - {"mng_get_refreshpass", 1, 0, 0}, - {"mng_get_runtime", 1, 0, 0}, - {"mng_get_sectionbreaks", 1, 0, 0}, - {"mng_get_sigtype", 1, 0, 0}, - {"mng_get_simplicity", 1, 0, 0}, - {"mng_get_speed", 1, 0, 0}, - {"mng_get_srgb", 1, 0, 0}, - {"mng_get_starttime", 1, 0, 0}, - {"mng_get_storechunks", 1, 0, 0}, - {"mng_get_suspensionmode", 1, 0, 0}, - {"mng_get_ticks", 1, 0, 0}, -#ifndef MNG_NO_CURRENT_INFO - {"mng_get_totalframes", 1, 0, 5}, - {"mng_get_totallayers", 1, 0, 5}, - {"mng_get_totalplaytime", 1, 0, 5}, -#endif - {"mng_get_usebkgd", 1, 0, 0}, - {"mng_get_userdata", 1, 0, 0}, -#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) || defined(MNG_APP_CMS) - {"mng_get_viewgamma", 1, 0, 0}, - {"mng_get_viewgammaint", 1, 0, 0}, -#endif -#ifdef MNG_ACCESS_ZLIB - {"mng_get_zlib_level", 1, 0, 0}, - {"mng_get_zlib_maxidat", 1, 0, 0}, - {"mng_get_zlib_memlevel", 1, 0, 0}, - {"mng_get_zlib_method", 1, 0, 0}, - {"mng_get_zlib_strategy", 1, 0, 0}, - {"mng_get_zlib_windowbits", 1, 0, 0}, -#endif -#ifndef MNG_NO_OPEN_CLOSE_STREAM - {"mng_getcb_closestream", 1, 0, 0}, -#endif - {"mng_getcb_errorproc", 1, 0, 0}, - {"mng_getcb_getalphaline", 1, 0, 0}, - {"mng_getcb_getbkgdline", 1, 0, 0}, - {"mng_getcb_getcanvasline", 1, 0, 0}, - {"mng_getcb_gettickcount", 1, 0, 0}, - {"mng_getcb_memalloc", 1, 0, 0}, - {"mng_getcb_memfree", 1, 0, 0}, -#ifndef MNG_NO_OPEN_CLOSE_STREAM - {"mng_getcb_openstream", 1, 0, 0}, -#endif - {"mng_getcb_processarow", 1, 0, 0}, - {"mng_getcb_processchroma", 1, 0, 0}, - {"mng_getcb_processgamma", 1, 0, 0}, - {"mng_getcb_processheader", 1, 0, 0}, - {"mng_getcb_processiccp", 1, 0, 0}, - {"mng_getcb_processmend", 1, 0, 1}, - {"mng_getcb_processneed", 1, 0, 0}, - {"mng_getcb_processsave", 1, 0, 0}, - {"mng_getcb_processseek", 1, 0, 0}, - {"mng_getcb_processsrgb", 1, 0, 0}, - {"mng_getcb_processterm", 1, 0, 2}, - {"mng_getcb_processtext", 1, 0, 0}, - {"mng_getcb_processunknown", 1, 0, 0}, - {"mng_getcb_readdata", 1, 0, 0}, - {"mng_getcb_refresh", 1, 0, 0}, - {"mng_getcb_releasedata", 1, 0, 8}, - {"mng_getcb_settimer", 1, 0, 0}, - {"mng_getcb_traceproc", 1, 0, 0}, - {"mng_getcb_writedata", 1, 0, 0}, - {"mng_getchunk_back", 1, 0, 0}, - {"mng_getchunk_basi", 1, 0, 0}, -#ifndef MNG_SKIPCHUNK_bKGD - {"mng_getchunk_bkgd", 1, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_cHRM - {"mng_getchunk_chrm", 1, 0, 0}, -#endif - {"mng_getchunk_clip", 1, 0, 0}, - {"mng_getchunk_clon", 1, 0, 0}, -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_dBYK - {"mng_getchunk_dbyk", 1, 0, 0}, -#endif -#endif - {"mng_getchunk_defi", 1, 0, 0}, -#ifndef MNG_NO_DELTA_PNG - {"mng_getchunk_dhdr", 1, 0, 0}, -#endif - {"mng_getchunk_disc", 1, 0, 0}, -#ifndef MNG_NO_DELTA_PNG - {"mng_getchunk_drop", 1, 0, 0}, -#endif - {"mng_getchunk_endl", 1, 0, 0}, -#ifdef MNG_INCLUDE_MPNG_PROPOSAL - {"mng_getchunk_mpng", 1, 0, 10}, - {"mng_getchunk_mpng_frame", 1, 0, 10}, -#endif -#ifndef MNG_SKIPCHUNK_evNT - {"mng_getchunk_evnt", 1, 0, 5}, - {"mng_getchunk_evnt_entry", 1, 0, 5}, -#endif -#ifndef MNG_SKIPCHUNK_eXPI - {"mng_getchunk_expi", 1, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_fPRI - {"mng_getchunk_fpri", 1, 0, 0}, -#endif - {"mng_getchunk_fram", 1, 0, 0}, - {"mng_getchunk_gama", 1, 0, 0}, -#ifndef MNG_SKIPCHUNK_hIST - {"mng_getchunk_hist", 1, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_iCCP - {"mng_getchunk_iccp", 1, 0, 0}, -#endif - {"mng_getchunk_idat", 1, 0, 0}, - {"mng_getchunk_iend", 1, 0, 0}, - {"mng_getchunk_ihdr", 1, 0, 0}, -#ifndef MNG_NO_DELTA_PNG -#ifdef MNG_INCLUDE_JNG - {"mng_getchunk_ijng", 1, 0, 0}, -#endif - {"mng_getchunk_ipng", 1, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_iTXt - {"mng_getchunk_itxt", 1, 0, 0}, -#endif -#ifdef MNG_INCLUDE_JNG - {"mng_getchunk_jdaa", 1, 0, 0}, - {"mng_getchunk_jdat", 1, 0, 0}, - {"mng_getchunk_jhdr", 1, 0, 0}, - {"mng_getchunk_jsep", 1, 0, 0}, -#endif - {"mng_getchunk_loop", 1, 0, 0}, -#ifndef MNG_SKIPCHUNK_MAGN - {"mng_getchunk_magn", 1, 0, 0}, -#endif - {"mng_getchunk_mend", 1, 0, 0}, - {"mng_getchunk_mhdr", 1, 0, 0}, - {"mng_getchunk_move", 1, 0, 0}, -#ifndef MNG_SKIPCHUNK_nEED - {"mng_getchunk_need", 1, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_ORDR -#ifndef MNG_NO_DELTA_PNG - {"mng_getchunk_ordr", 1, 0, 0}, - {"mng_getchunk_ordr_entry", 1, 0, 0}, -#endif -#endif -#ifndef MNG_SKIPCHUNK_PAST - {"mng_getchunk_past", 1, 0, 0}, - {"mng_getchunk_past_src", 1, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_pHYg - {"mng_getchunk_phyg", 1, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_pHYs - {"mng_getchunk_phys", 1, 0, 0}, -#endif -#ifndef MNG_NO_DELTA_PNG - {"mng_getchunk_plte", 1, 0, 0}, - {"mng_getchunk_pplt", 1, 0, 0}, - {"mng_getchunk_pplt_entry", 1, 0, 0}, - {"mng_getchunk_prom", 1, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_SAVE - {"mng_getchunk_save", 1, 0, 0}, - {"mng_getchunk_save_entry", 1, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_sBIT - {"mng_getchunk_sbit", 1, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_SEEK - {"mng_getchunk_seek", 1, 0, 0}, -#endif - {"mng_getchunk_show", 1, 0, 0}, -#ifndef MNG_SKIPCHUNK_sPLT - {"mng_getchunk_splt", 1, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_sRGB - {"mng_getchunk_srgb", 1, 0, 0}, -#endif - {"mng_getchunk_term", 1, 0, 0}, -#ifndef MNG_SKIPCHUNK_tEXt - {"mng_getchunk_text", 1, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_tIME - {"mng_getchunk_time", 1, 0, 0}, -#endif - {"mng_getchunk_trns", 1, 0, 0}, - {"mng_getchunk_unkown", 1, 0, 0}, -#ifndef MNG_SKIPCHUNK_zTXt - {"mng_getchunk_ztxt", 1, 0, 0}, -#endif - {"mng_getimgdata_chunk", 0, 0, 0}, - {"mng_getimgdata_chunkseq", 0, 0, 0}, - {"mng_getimgdata_seq", 0, 0, 0}, - {"mng_getlasterror", 1, 0, 0}, - {"mng_initialize", 1, 0, 0}, - {"mng_iterate_chunks", 1, 0, 0}, - {"mng_putchunk_back", 1, 0, 0}, -#ifndef MNG_SKIPCHUNK_BASI - {"mng_putchunk_basi", 1, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_bKGD - {"mng_putchunk_bkgd", 1, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_cHRM - {"mng_putchunk_chrm", 1, 0, 0}, -#endif - {"mng_putchunk_clip", 1, 0, 0}, - {"mng_putchunk_clon", 1, 0, 0}, -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_DBYK - {"mng_putchunk_dbyk", 1, 0, 0}, -#endif -#endif - {"mng_putchunk_defi", 1, 0, 0}, -#ifndef MNG_NO_DELTA_PNG - {"mng_putchunk_dhdr", 1, 0, 0}, -#endif - {"mng_putchunk_disc", 1, 0, 0}, -#ifndef MNG_NO_DELTA_PNG - {"mng_putchunk_drop", 1, 0, 0}, -#endif - {"mng_putchunk_endl", 1, 0, 0}, -#ifdef MNG_INCLUDE_MPNG_PROPOSAL - {"mng_putchunk_mpng", 1, 0, 10}, - {"mng_putchunk_mpng_frame", 1, 0, 10}, -#endif -#ifndef MNG_SKIPCHUNK_evNT - {"mng_putchunk_evnt", 1, 0, 5}, - {"mng_putchunk_evnt_entry", 1, 0, 5}, -#endif -#ifndef MNG_SKIPCHUNK_eXPI - {"mng_putchunk_expi", 1, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_fPRI - {"mng_putchunk_fpri", 1, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_FRAM - {"mng_putchunk_fram", 1, 0, 0}, -#endif - {"mng_putchunk_gama", 1, 0, 0}, -#ifndef MNG_SKIPCHUNK_hIST - {"mng_putchunk_hist", 1, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_iCCP - {"mng_putchunk_iccp", 1, 0, 0}, -#endif - {"mng_putchunk_idat", 1, 0, 0}, - {"mng_putchunk_iend", 1, 0, 0}, - {"mng_putchunk_ihdr", 1, 0, 0}, -#ifndef MNG_NO_DELTA_PNG -#ifdef MNG_INCLUDE_JNG - {"mng_putchunk_ijng", 1, 0, 0}, -#endif - {"mng_putchunk_ipng", 1, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_iTXt - {"mng_putchunk_itxt", 1, 0, 0}, -#endif -#ifdef MNG_INCLUDE_JNG - {"mng_putchunk_jdaa", 1, 0, 0}, - {"mng_putchunk_jdat", 1, 0, 0}, - {"mng_putchunk_jhdr", 1, 0, 0}, - {"mng_putchunk_jsep", 1, 0, 0}, -#endif - {"mng_putchunk_loop", 1, 0, 0}, -#ifndef MNG_SKIPCHUNK_MAGN - {"mng_putchunk_magn", 1, 0, 0}, -#endif - {"mng_putchunk_mend", 1, 0, 0}, - {"mng_putchunk_mhdr", 1, 0, 0}, - {"mng_putchunk_move", 1, 0, 0}, -#ifndef MNG_SKIPCHUNK_nEED - {"mng_putchunk_need", 1, 0, 0}, -#endif -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_ORDR - {"mng_putchunk_ordr", 1, 0, 0}, - {"mng_putchunk_ordr_entry", 1, 0, 0}, -#endif -#endif -#ifndef MNG_SKIPCHUNK_PAST - {"mng_putchunk_past", 1, 0, 0}, - {"mng_putchunk_past_src", 1, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_pHYg - {"mng_putchunk_phyg", 1, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_pHYs - {"mng_putchunk_phys", 1, 0, 0}, -#endif -#ifndef MNG_NO_DELTA_PNG - {"mng_putchunk_plte", 1, 0, 0}, - {"mng_putchunk_pplt", 1, 0, 0}, - {"mng_putchunk_pplt_entry", 1, 0, 0}, - {"mng_putchunk_prom", 1, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_SAVE - {"mng_putchunk_save", 1, 0, 0}, - {"mng_putchunk_save_entry", 1, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_sBIT - {"mng_putchunk_sbit", 1, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_SEEK - {"mng_putchunk_seek", 1, 0, 0}, -#endif - {"mng_putchunk_show", 1, 0, 0}, -#ifndef MNG_SKIPCHUNK_sPLT - {"mng_putchunk_splt", 1, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_sRGB - {"mng_putchunk_srgb", 1, 0, 0}, -#endif - {"mng_putchunk_term", 1, 0, 0}, -#ifndef MNG_SKIPCHUNK_tEXt - {"mng_putchunk_text", 1, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_tIME - {"mng_putchunk_time", 1, 0, 0}, -#endif - {"mng_putchunk_trns", 1, 0, 0}, - {"mng_putchunk_unkown", 1, 0, 0}, -#ifndef MNG_SKIPCHUNK_zTXt - {"mng_putchunk_ztxt", 1, 0, 0}, -#endif - {"mng_putimgdata_ihdr", 0, 0, 0}, - {"mng_putimgdata_jhdr", 0, 0, 0}, - {"mng_reset", 1, 0, 0}, - {"mng_read", 1, 0, 0}, - {"mng_read_pushchunk", 1, 0, 8}, - {"mng_read_pushdata", 1, 0, 8}, - {"mng_read_pushsig", 1, 0, 8}, - {"mng_read_resume", 1, 0, 0}, - {"mng_readdisplay", 1, 0, 0}, - {"mng_set_bgcolor", 1, 0, 0}, - {"mng_set_bkgdstyle", 1, 0, 0}, - {"mng_set_cacheplayback", 1, 0, 2}, - {"mng_set_canvasstyle", 1, 0, 0}, - {"mng_set_dfltimggamma", 1, 0, 0}, -#ifndef MNG_NO_DFLT_INFO - {"mng_set_dfltimggammaint", 1, 0, 0}, -#endif - {"mng_set_displaygamma", 1, 0, 0}, - {"mng_set_displaygammaint", 1, 0, 0}, - {"mng_set_doprogressive", 1, 0, 2}, -#ifdef MNG_ACCESS_JPEG - {"mng_set_jpeg_dctmethod", 1, 0, 0}, - {"mng_set_jpeg_maxjdat", 1, 0, 0}, - {"mng_set_jpeg_optimized", 1, 0, 0}, - {"mng_set_jpeg_progressive", 1, 0, 0}, - {"mng_set_jpeg_quality", 1, 0, 0}, - {"mng_set_jpeg_smoothing", 1, 0, 0}, -#endif -#ifndef MNG_SKIP_MAXCANVAS - {"mng_set_maxcanvasheight", 1, 0, 0}, - {"mng_set_maxcanvassize", 1, 0, 0}, - {"mng_set_maxcanvaswidth", 1, 0, 0}, -#endif - {"mng_set_outputprofile", 1, 0, 0}, - {"mng_set_outputprofile2", 1, 0, 0}, - {"mng_set_outputsrgb", 1, 0, 1}, - {"mng_set_sectionbreaks", 1, 0, 0}, - {"mng_set_speed", 1, 0, 0}, - {"mng_set_srgb", 1, 0, 0}, - {"mng_set_srgbimplicit", 1, 0, 1}, - {"mng_set_srgbprofile", 1, 0, 0}, - {"mng_set_srgbprofile2", 1, 0, 0}, - {"mng_set_storechunks", 1, 0, 0}, - {"mng_set_suspensionmode", 1, 0, 0}, - {"mng_set_usebkgd", 1, 0, 0}, - {"mng_set_userdata", 1, 0, 0}, -#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) || defined(MNG_APP_CMS) - {"mng_set_viewgamma", 1, 0, 0}, - {"mng_set_viewgammaint", 1, 0, 0}, -#endif -#ifdef MNG_ACCESS_ZLIB - {"mng_set_zlib_level", 1, 0, 0}, - {"mng_set_zlib_maxidat", 1, 0, 0}, - {"mng_set_zlib_memlevel", 1, 0, 0}, - {"mng_set_zlib_method", 1, 0, 0}, - {"mng_set_zlib_strategy", 1, 0, 0}, - {"mng_set_zlib_windowbits", 1, 0, 0}, -#endif -#ifndef MNG_NO_OPEN_CLOSE_STREAM - {"mng_setcb_closestream", 1, 0, 0}, -#endif - {"mng_setcb_errorproc", 1, 0, 0}, - {"mng_setcb_getalphaline", 1, 0, 0}, - {"mng_setcb_getbkgdline", 1, 0, 0}, - {"mng_setcb_getcanvasline", 1, 0, 0}, - {"mng_setcb_gettickcount", 1, 0, 0}, - {"mng_setcb_memalloc", 1, 0, 0}, - {"mng_setcb_memfree", 1, 0, 0}, -#ifndef MNG_NO_OPEN_CLOSE_STREAM - {"mng_setcb_openstream", 1, 0, 0}, -#endif - {"mng_setcb_processarow", 1, 0, 0}, - {"mng_setcb_processchroma", 1, 0, 0}, - {"mng_setcb_processgamma", 1, 0, 0}, - {"mng_setcb_processheader", 1, 0, 0}, - {"mng_setcb_processiccp", 1, 0, 0}, - {"mng_setcb_processmend", 1, 0, 1}, - {"mng_setcb_processneed", 1, 0, 0}, - {"mng_setcb_processsave", 1, 0, 0}, - {"mng_setcb_processseek", 1, 0, 0}, - {"mng_setcb_processsrgb", 1, 0, 0}, - {"mng_setcb_processterm", 1, 0, 2}, - {"mng_setcb_processtext", 1, 0, 0}, - {"mng_setcb_processunknown", 1, 0, 0}, - {"mng_setcb_readdata", 1, 0, 0}, - {"mng_setcb_refresh", 1, 0, 0}, - {"mng_setcb_releasedata", 1, 0, 8}, - {"mng_setcb_settimer", 1, 0, 0}, - {"mng_setcb_traceproc", 1, 0, 0}, - {"mng_setcb_writedata", 1, 0, 0}, - {"mng_status_creating", 1, 0, 0}, - {"mng_status_displaying", 1, 0, 0}, - {"mng_status_dynamic", 1, 0, 5}, - {"mng_status_error", 1, 0, 0}, - {"mng_status_reading", 1, 0, 0}, - {"mng_status_running", 1, 0, 0}, - {"mng_status_runningevent", 1, 0, 5}, - {"mng_status_suspendbreak", 1, 0, 0}, - {"mng_status_timerbreak", 1, 0, 0}, - {"mng_status_writing", 1, 0, 0}, - {"mng_supports_func", 1, 0, 5}, - {"mng_trapevent", 1, 0, 5}, - {"mng_updatemngheader", 1, 0, 0}, - {"mng_updatemngsimplicity", 1, 0, 0}, - {"mng_version_beta", 1, 0, 5}, - {"mng_version_dll", 1, 0, 0}, - {"mng_version_major", 1, 0, 0}, - {"mng_version_minor", 1, 0, 0}, - {"mng_version_release", 1, 0, 0}, - {"mng_version_so", 1, 0, 0}, - {"mng_version_text", 1, 0, 0}, - {"mng_write", 1, 0, 0}, - }; - -mng_bool MNG_DECL mng_supports_func (mng_pchar zFunction, - mng_uint8* iMajor, - mng_uint8* iMinor, - mng_uint8* iRelease) -{ - mng_int32 iTop, iLower, iUpper, iMiddle; - mng_func_entryp pEntry; /* pointer to found entry */ - /* determine max index of table */ - iTop = (sizeof (func_table) / sizeof (func_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 */ - { - mng_int32 iRslt = strcmp(func_table [iMiddle].zFunction, zFunction); - if (iRslt < 0) - iLower = iMiddle + 1; - else if (iRslt > 0) - iUpper = iMiddle - 1; - else - { - pEntry = &func_table [iMiddle]; - break; - }; - - iMiddle = (iLower + iUpper) >> 1; - } - while (iLower <= iUpper); - - if (pEntry) /* found it ? */ - { - *iMajor = pEntry->iMajor; - *iMinor = pEntry->iMinor; - *iRelease = pEntry->iRelease; - return MNG_TRUE; - } - else - { - *iMajor = 0; - *iMinor = 0; - *iRelease = 0; - return MNG_FALSE; - } -} -#endif - -/* ************************************************************************** */ -/* * * */ -/* * HLAPI routines * */ -/* * * */ -/* ************************************************************************** */ - -mng_handle MNG_DECL mng_initialize (mng_ptr pUserdata, - mng_memalloc fMemalloc, - mng_memfree fMemfree, - mng_traceproc fTraceproc) -{ - mng_datap pData; -#ifdef MNG_SUPPORT_DISPLAY - mng_retcode iRetcode; - mng_imagep pImage; -#endif - -#ifdef MNG_INTERNAL_MEMMNGMT /* allocate the main datastruc */ - pData = (mng_datap)calloc (1, sizeof (mng_data)); -#else - pData = (mng_datap)fMemalloc (sizeof (mng_data)); -#endif - - if (!pData) - return MNG_NULL; /* error: out of memory?? */ - /* validate the structure */ - pData->iMagic = MNG_MAGIC; - /* save userdata field */ - pData->pUserdata = pUserdata; - /* remember trace callback */ - pData->fTraceproc = fTraceproc; - -#ifdef MNG_SUPPORT_TRACE - if (mng_trace (pData, MNG_FN_INITIALIZE, MNG_LC_INITIALIZE)) - { - MNG_FREEX (pData, pData, sizeof (mng_data)); - return MNG_NULL; - } -#endif - /* default canvas styles are 8-bit RGB */ - pData->iCanvasstyle = MNG_CANVAS_RGB8; - pData->iBkgdstyle = MNG_CANVAS_RGB8; - - pData->iBGred = 0; /* black */ - pData->iBGgreen = 0; - pData->iBGblue = 0; - - pData->bUseBKGD = MNG_TRUE; - -#ifdef MNG_FULL_CMS - pData->bIssRGB = MNG_TRUE; - pData->hProf1 = 0; /* no profiles yet */ - pData->hProf2 = 0; - pData->hProf3 = 0; - pData->hTrans = 0; -#endif - - pData->dViewgamma = 1.0; - pData->dDisplaygamma = 2.2; - pData->dDfltimggamma = 0.45455; - /* initially remember chunks */ - pData->bStorechunks = MNG_TRUE; - /* no breaks at section-borders */ - pData->bSectionbreaks = MNG_FALSE; - /* initially cache playback info */ - pData->bCacheplayback = MNG_TRUE; - /* progressive refresh for large images */ - pData->bDoProgressive = MNG_TRUE; - /* crc exists; should check; error for - critical chunks; warning for ancillery; - generate crc for output */ - pData->iCrcmode = MNG_CRC_DEFAULT; - /* normal animation-speed ! */ - pData->iSpeed = mng_st_normal; - /* initial image limits */ - pData->iMaxwidth = 10000; - pData->iMaxheight = 10000; - -#ifdef MNG_INTERNAL_MEMMNGMT /* internal management */ - pData->fMemalloc = MNG_NULL; - pData->fMemfree = MNG_NULL; -#else /* keep callbacks */ - pData->fMemalloc = fMemalloc; - pData->fMemfree = fMemfree; -#endif - /* no value (yet) */ - pData->fReleasedata = MNG_NULL; -#ifndef MNG_NO_OPEN_CLOSE_STREAM - pData->fOpenstream = MNG_NULL; - pData->fClosestream = MNG_NULL; -#endif - pData->fReaddata = MNG_NULL; - pData->fWritedata = MNG_NULL; - pData->fErrorproc = MNG_NULL; - pData->fProcessheader = MNG_NULL; - pData->fProcesstext = MNG_NULL; - pData->fProcesssave = MNG_NULL; - pData->fProcessseek = MNG_NULL; - pData->fProcessneed = MNG_NULL; - pData->fProcessmend = MNG_NULL; - pData->fProcessunknown = MNG_NULL; - pData->fProcessterm = MNG_NULL; - pData->fGetcanvasline = MNG_NULL; - pData->fGetbkgdline = MNG_NULL; - pData->fGetalphaline = MNG_NULL; - pData->fRefresh = MNG_NULL; - pData->fGettickcount = MNG_NULL; - pData->fSettimer = MNG_NULL; - pData->fProcessgamma = MNG_NULL; - pData->fProcesschroma = MNG_NULL; - pData->fProcesssrgb = MNG_NULL; - pData->fProcessiccp = MNG_NULL; - pData->fProcessarow = MNG_NULL; - -#if defined(MNG_SUPPORT_DISPLAY) && (defined(MNG_GAMMA_ONLY) || defined(MNG_FULL_CMS)) - pData->dLastgamma = 0; /* lookup table needs first-time calc */ -#endif - -#ifdef MNG_SUPPORT_DISPLAY /* create object 0 */ - iRetcode = mng_create_imageobject (pData, 0, MNG_TRUE, MNG_TRUE, MNG_TRUE, - 0, 0, 0, 0, 0, 0, 0, 0, 0, MNG_FALSE, - 0, 0, 0, 0, &pImage); - - if (iRetcode) /* on error drop out */ - { - MNG_FREEX (pData, pData, sizeof (mng_data)); - return MNG_NULL; - } - - pData->pObjzero = pImage; -#endif - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_INCLUDE_LCMS) - mnglcms_initlibrary (); /* init lcms particulars */ -#endif - -#ifdef MNG_SUPPORT_READ - pData->bSuspensionmode = MNG_FALSE; - pData->iSuspendbufsize = 0; - pData->pSuspendbuf = MNG_NULL; - pData->pSuspendbufnext = MNG_NULL; - pData->iSuspendbufleft = 0; - pData->iChunklen = 0; - pData->pReadbufnext = MNG_NULL; - pData->pLargebufnext = MNG_NULL; - - pData->pFirstpushchunk = MNG_NULL; - pData->pLastpushchunk = MNG_NULL; - pData->pFirstpushdata = MNG_NULL; - pData->pLastpushdata = MNG_NULL; -#endif - -#ifdef MNG_INCLUDE_ZLIB - mngzlib_initialize (pData); /* initialize zlib structures and such */ - /* default zlib compression parameters */ - pData->iZlevel = MNG_ZLIB_LEVEL; - pData->iZmethod = MNG_ZLIB_METHOD; - pData->iZwindowbits = MNG_ZLIB_WINDOWBITS; - pData->iZmemlevel = MNG_ZLIB_MEMLEVEL; - pData->iZstrategy = MNG_ZLIB_STRATEGY; - /* default maximum IDAT data size */ - pData->iMaxIDAT = MNG_MAX_IDAT_SIZE; -#endif - -#ifdef MNG_INCLUDE_JNG /* default IJG compression parameters */ - pData->eJPEGdctmethod = MNG_JPEG_DCT; - pData->iJPEGquality = MNG_JPEG_QUALITY; - pData->iJPEGsmoothing = MNG_JPEG_SMOOTHING; - pData->bJPEGcompressprogr = MNG_JPEG_PROGRESSIVE; - pData->bJPEGcompressopt = MNG_JPEG_OPTIMIZED; - /* default maximum JDAT data size */ - pData->iMaxJDAT = MNG_MAX_JDAT_SIZE; -#endif - - mng_reset ((mng_handle)pData); - -#ifdef MNG_SUPPORT_TRACE - if (mng_trace (pData, MNG_FN_INITIALIZE, MNG_LC_END)) - { - MNG_FREEX (pData, pData, sizeof (mng_data)); - return MNG_NULL; - } -#endif - - return (mng_handle)pData; /* if we get here, we're in business */ -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_reset (mng_handle hHandle) -{ - mng_datap pData; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_RESET, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)(hHandle)); /* address main structure */ - -#ifdef MNG_SUPPORT_DISPLAY -#ifndef MNG_SKIPCHUNK_SAVE - mng_drop_savedata (pData); /* cleanup saved-data from SAVE/SEEK */ -#endif -#endif - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_FULL_CMS) - mng_clear_cms (pData); /* cleanup left-over cms stuff if any */ -#endif - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_INCLUDE_JNG) - mngjpeg_cleanup (pData); /* cleanup jpeg stuff */ -#endif - -#ifdef MNG_INCLUDE_ZLIB - if (pData->bInflating) /* if we've been inflating */ - { -#ifdef MNG_INCLUDE_DISPLAY_PROCS - mng_cleanup_rowproc (pData); /* cleanup row-processing, */ -#endif - mngzlib_inflatefree (pData); /* cleanup inflate! */ - } -#endif /* MNG_INCLUDE_ZLIB */ - -#ifdef MNG_SUPPORT_READ - if ((pData->bReading) && (!pData->bEOF)) - mng_process_eof (pData); /* cleanup app streaming */ - /* cleanup default read buffers */ - MNG_FREE (pData, pData->pReadbuf, pData->iReadbufsize); - MNG_FREE (pData, pData->pLargebuf, pData->iLargebufsize); - MNG_FREE (pData, pData->pSuspendbuf, pData->iSuspendbufsize); - - while (pData->pFirstpushdata) /* release any pushed data & chunks */ - mng_release_pushdata (pData); - while (pData->pFirstpushchunk) - mng_release_pushchunk (pData); -#endif - -#ifdef MNG_SUPPORT_WRITE /* cleanup default write buffer */ - MNG_FREE (pData, pData->pWritebuf, pData->iWritebufsize); -#endif - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) - mng_drop_chunks (pData); /* drop stored chunks (if any) */ -#endif - -#ifdef MNG_SUPPORT_DISPLAY - mng_drop_objects (pData, MNG_TRUE); /* drop stored objects (if any) */ - -#ifndef MNG_SKIPCHUNK_iCCP - if (pData->iGlobalProfilesize) /* drop global profile (if any) */ - MNG_FREEX (pData, pData->pGlobalProfile, pData->iGlobalProfilesize); -#endif -#endif - - pData->eSigtype = mng_it_unknown; - pData->eImagetype = mng_it_unknown; - pData->iWidth = 0; /* these are unknown yet */ - pData->iHeight = 0; - pData->iTicks = 0; - pData->iLayercount = 0; - pData->iFramecount = 0; - pData->iPlaytime = 0; - pData->iSimplicity = 0; - pData->iAlphadepth = 16; /* assume the worst! */ - - pData->iImagelevel = 0; /* no image encountered */ - - pData->iMagnify = 0; /* 1-to-1 display */ - pData->iOffsetx = 0; /* no offsets */ - pData->iOffsety = 0; - pData->iCanvaswidth = 0; /* let the app decide during processheader */ - pData->iCanvasheight = 0; - /* so far, so good */ - pData->iErrorcode = MNG_NOERROR; - pData->iSeverity = 0; - pData->iErrorx1 = 0; - pData->iErrorx2 = 0; - pData->zErrortext = MNG_NULL; - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) - /* let's assume the best scenario */ -#ifndef MNG_NO_OLD_VERSIONS - pData->bPreDraft48 = MNG_FALSE; -#endif - /* the unknown chunk */ - pData->iChunkname = MNG_UINT_HUH; - pData->iChunkseq = 0; - pData->pFirstchunk = MNG_NULL; - pData->pLastchunk = MNG_NULL; - /* nothing processed yet */ - pData->bHasheader = MNG_FALSE; - pData->bHasMHDR = MNG_FALSE; - pData->bHasIHDR = MNG_FALSE; - pData->bHasBASI = MNG_FALSE; - pData->bHasDHDR = MNG_FALSE; -#ifdef MNG_INCLUDE_JNG - pData->bHasJHDR = MNG_FALSE; - pData->bHasJSEP = MNG_FALSE; - pData->bHasJDAA = MNG_FALSE; - pData->bHasJDAT = MNG_FALSE; -#endif - pData->bHasPLTE = MNG_FALSE; - pData->bHasTRNS = MNG_FALSE; - pData->bHasGAMA = MNG_FALSE; - pData->bHasCHRM = MNG_FALSE; - pData->bHasSRGB = MNG_FALSE; - pData->bHasICCP = MNG_FALSE; - pData->bHasBKGD = MNG_FALSE; - pData->bHasIDAT = MNG_FALSE; - - pData->bHasSAVE = MNG_FALSE; - pData->bHasBACK = MNG_FALSE; - pData->bHasFRAM = MNG_FALSE; - pData->bHasTERM = MNG_FALSE; - pData->bHasLOOP = MNG_FALSE; - /* there's no global stuff yet either */ - pData->bHasglobalPLTE = MNG_FALSE; - pData->bHasglobalTRNS = MNG_FALSE; - pData->bHasglobalGAMA = MNG_FALSE; - pData->bHasglobalCHRM = MNG_FALSE; - pData->bHasglobalSRGB = MNG_FALSE; - pData->bHasglobalICCP = MNG_FALSE; - - pData->iDatawidth = 0; /* no IHDR/BASI/DHDR done yet */ - pData->iDataheight = 0; - pData->iBitdepth = 0; - pData->iColortype = 0; - pData->iCompression = 0; - pData->iFilter = 0; - pData->iInterlace = 0; - -#ifdef MNG_INCLUDE_JNG - pData->iJHDRcolortype = 0; /* no JHDR data */ - pData->iJHDRimgbitdepth = 0; - pData->iJHDRimgcompression = 0; - pData->iJHDRimginterlace = 0; - pData->iJHDRalphabitdepth = 0; - pData->iJHDRalphacompression = 0; - pData->iJHDRalphafilter = 0; - pData->iJHDRalphainterlace = 0; -#endif - -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - -#ifdef MNG_SUPPORT_READ /* no reading done */ - pData->bReading = MNG_FALSE; - pData->bHavesig = MNG_FALSE; - pData->bEOF = MNG_FALSE; - pData->iReadbufsize = 0; - pData->pReadbuf = MNG_NULL; - - pData->iLargebufsize = 0; - pData->pLargebuf = MNG_NULL; - - pData->iSuspendtime = 0; - pData->bSuspended = MNG_FALSE; - pData->iSuspendpoint = 0; - - pData->pSuspendbufnext = pData->pSuspendbuf; - pData->iSuspendbufleft = 0; -#endif /* MNG_SUPPORT_READ */ - -#ifdef MNG_SUPPORT_WRITE /* no creating/writing done */ - pData->bCreating = MNG_FALSE; - pData->bWriting = MNG_FALSE; - pData->iFirstchunkadded = 0; - pData->iWritebufsize = 0; - pData->pWritebuf = MNG_NULL; -#endif /* MNG_SUPPORT_WRITE */ - -#ifdef MNG_SUPPORT_DISPLAY /* done nuttin' yet */ - pData->bDisplaying = MNG_FALSE; - pData->iFrameseq = 0; - pData->iLayerseq = 0; - pData->iFrametime = 0; - - pData->iTotallayers = 0; - pData->iTotalframes = 0; - pData->iTotalplaytime = 0; - - pData->bSkipping = MNG_FALSE; - -#ifdef MNG_SUPPORT_DYNAMICMNG - pData->bDynamic = MNG_FALSE; - pData->bRunningevent = MNG_FALSE; - pData->bStopafterseek = MNG_FALSE; - pData->iEventx = 0; - pData->iEventy = 0; - pData->pLastmousemove = MNG_NULL; -#endif - - pData->iRequestframe = 0; - pData->iRequestlayer = 0; - pData->iRequesttime = 0; - pData->bSearching = MNG_FALSE; - - pData->bRestorebkgd = MNG_FALSE; - - pData->iRuntime = 0; - pData->iSynctime = 0; - pData->iStarttime = 0; - pData->iEndtime = 0; - pData->bRunning = MNG_FALSE; - pData->bTimerset = MNG_FALSE; - pData->iBreakpoint = 0; - pData->bSectionwait = MNG_FALSE; - pData->bFreezing = MNG_FALSE; - pData->bResetting = MNG_FALSE; - pData->bNeedrefresh = MNG_FALSE; - pData->bMisplacedTERM = MNG_FALSE; - pData->bOnlyfirstframe = MNG_FALSE; - pData->iFramesafterTERM = 0; - /* these don't exist yet */ - pData->pCurrentobj = MNG_NULL; - pData->pCurraniobj = MNG_NULL; - pData->pTermaniobj = MNG_NULL; - pData->pLastclone = MNG_NULL; - pData->pStoreobj = MNG_NULL; - pData->pStorebuf = MNG_NULL; - pData->pRetrieveobj = MNG_NULL; - /* no saved data ! */ - pData->pSavedata = MNG_NULL; - - pData->iUpdateleft = 0; /* no region updated yet */ - pData->iUpdateright = 0; - pData->iUpdatetop = 0; - pData->iUpdatebottom = 0; - - pData->iPass = -1; /* interlacing stuff and temp buffers */ - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = 0; - pData->iSamplemul = 0; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = 0; - pData->iRowmax = 0; - pData->iFilterofs = 0; - pData->iPixelofs = 1; - pData->iLevel0 = 0; - pData->iLevel1 = 0; - pData->iLevel2 = 0; - pData->iLevel3 = 0; - pData->pWorkrow = MNG_NULL; - pData->pPrevrow = MNG_NULL; - pData->pRGBArow = MNG_NULL; - pData->bIsRGBA16 = MNG_TRUE; - pData->bIsOpaque = MNG_TRUE; - pData->iFilterbpp = 1; - - pData->iSourcel = 0; /* always initialized just before */ - pData->iSourcer = 0; /* compositing the next layer */ - pData->iSourcet = 0; - pData->iSourceb = 0; - pData->iDestl = 0; - pData->iDestr = 0; - pData->iDestt = 0; - pData->iDestb = 0; - /* lists are empty */ - pData->pFirstimgobj = MNG_NULL; - pData->pLastimgobj = MNG_NULL; - pData->pFirstaniobj = MNG_NULL; - pData->pLastaniobj = MNG_NULL; -#ifdef MNG_SUPPORT_DYNAMICMNG - pData->pFirstevent = MNG_NULL; - pData->pLastevent = MNG_NULL; -#endif - /* no processing callbacks */ - pData->fDisplayrow = MNG_NULL; - pData->fRestbkgdrow = MNG_NULL; - pData->fCorrectrow = MNG_NULL; - pData->fRetrieverow = MNG_NULL; - pData->fStorerow = MNG_NULL; - pData->fProcessrow = MNG_NULL; - pData->fDifferrow = MNG_NULL; - pData->fScalerow = MNG_NULL; - pData->fDeltarow = MNG_NULL; -#ifndef MNG_SKIPCHUNK_PAST - pData->fFliprow = MNG_NULL; - pData->fTilerow = MNG_NULL; -#endif - pData->fInitrowproc = MNG_NULL; - - pData->iPLTEcount = 0; /* no PLTE data */ - -#ifndef MNG_SKIPCHUNK_DEFI - pData->iDEFIobjectid = 0; /* no DEFI data */ - pData->bDEFIhasdonotshow = MNG_FALSE; - pData->iDEFIdonotshow = 0; - pData->bDEFIhasconcrete = MNG_FALSE; - pData->iDEFIconcrete = 0; - pData->bDEFIhasloca = MNG_FALSE; - pData->iDEFIlocax = 0; - pData->iDEFIlocay = 0; - pData->bDEFIhasclip = MNG_FALSE; - pData->iDEFIclipl = 0; - pData->iDEFIclipr = 0; - pData->iDEFIclipt = 0; - pData->iDEFIclipb = 0; -#endif - -#ifndef MNG_SKIPCHUNK_BACK - pData->iBACKred = 0; /* no BACK data */ - pData->iBACKgreen = 0; - pData->iBACKblue = 0; - pData->iBACKmandatory = 0; - pData->iBACKimageid = 0; - pData->iBACKtile = 0; -#endif - -#ifndef MNG_SKIPCHUNK_FRAM - pData->iFRAMmode = 1; /* default global FRAM variables */ - pData->iFRAMdelay = 1; - pData->iFRAMtimeout = 0x7fffffffl; - pData->bFRAMclipping = MNG_FALSE; - pData->iFRAMclipl = 0; - pData->iFRAMclipr = 0; - pData->iFRAMclipt = 0; - pData->iFRAMclipb = 0; - - pData->iFramemode = 1; /* again for the current frame */ - pData->iFramedelay = 1; - pData->iFrametimeout = 0x7fffffffl; - pData->bFrameclipping = MNG_FALSE; - pData->iFrameclipl = 0; - pData->iFrameclipr = 0; - pData->iFrameclipt = 0; - pData->iFrameclipb = 0; - - pData->iNextdelay = 1; -#endif - -#ifndef MNG_SKIPCHUNK_SHOW - pData->iSHOWmode = 0; /* no SHOW data */ - pData->iSHOWfromid = 0; - pData->iSHOWtoid = 0; - pData->iSHOWnextid = 0; - pData->iSHOWskip = 0; -#endif - - pData->iGlobalPLTEcount = 0; /* no global PLTE data */ - - pData->iGlobalTRNSrawlen = 0; /* no global tRNS data */ - - pData->iGlobalGamma = 0; /* no global gAMA data */ - -#ifndef MNG_SKIPCHUNK_cHRM - pData->iGlobalWhitepointx = 0; /* no global cHRM data */ - pData->iGlobalWhitepointy = 0; - pData->iGlobalPrimaryredx = 0; - pData->iGlobalPrimaryredy = 0; - pData->iGlobalPrimarygreenx = 0; - pData->iGlobalPrimarygreeny = 0; - pData->iGlobalPrimarybluex = 0; - pData->iGlobalPrimarybluey = 0; -#endif - - pData->iGlobalRendintent = 0; /* no global sRGB data */ - -#ifndef MNG_SKIPCHUNK_iCCP - pData->iGlobalProfilesize = 0; /* no global iCCP data */ - pData->pGlobalProfile = MNG_NULL; -#endif - -#ifndef MNG_SKIPCHUNK_bKGD - pData->iGlobalBKGDred = 0; /* no global bKGD data */ - pData->iGlobalBKGDgreen = 0; - pData->iGlobalBKGDblue = 0; -#endif - /* no delta-image */ -#ifndef MNG_NO_DELTA_PNG - pData->pDeltaImage = MNG_NULL; - pData->iDeltaImagetype = 0; - pData->iDeltatype = 0; - pData->iDeltaBlockwidth = 0; - pData->iDeltaBlockheight = 0; - pData->iDeltaBlockx = 0; - pData->iDeltaBlocky = 0; - pData->bDeltaimmediate = MNG_FALSE; - - pData->fDeltagetrow = MNG_NULL; - pData->fDeltaaddrow = MNG_NULL; - pData->fDeltareplacerow = MNG_NULL; - pData->fDeltaputrow = MNG_NULL; - - pData->fPromoterow = MNG_NULL; - pData->fPromBitdepth = MNG_NULL; - pData->pPromBuf = MNG_NULL; - pData->iPromColortype = 0; - pData->iPromBitdepth = 0; - pData->iPromFilltype = 0; - pData->iPromWidth = 0; - pData->pPromSrc = MNG_NULL; - pData->pPromDst = MNG_NULL; -#endif - -#ifndef MNG_SKIPCHUNK_MAGN - pData->iMAGNfromid = 0; - pData->iMAGNtoid = 0; -#endif - -#ifndef MNG_SKIPCHUNK_PAST - pData->iPastx = 0; - pData->iPasty = 0; -#endif - - pData->pLastseek = MNG_NULL; -#endif - -#ifdef MNG_INCLUDE_ZLIB - pData->bInflating = 0; /* no inflating or deflating */ - pData->bDeflating = 0; /* going on at the moment */ -#endif - -#ifdef MNG_SUPPORT_DISPLAY /* reset object 0 */ - mng_reset_objzero (pData); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_RESET, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_cleanup (mng_handle* hHandle) -{ - mng_datap pData; /* local vars */ -#ifndef MNG_INTERNAL_MEMMNGMT - mng_memfree fFree; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)*hHandle), MNG_FN_CLEANUP, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (*hHandle) /* check validity handle */ - pData = ((mng_datap)(*hHandle)); /* and address main structure */ - - mng_reset (*hHandle); /* do an implicit reset to cleanup most stuff */ - -#ifdef MNG_SUPPORT_DISPLAY /* drop object 0 */ - mng_free_imageobject (pData, (mng_imagep)pData->pObjzero); -#endif - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_FULL_CMS) - if (pData->hProf2) /* output profile defined ? */ - mnglcms_freeprofile (pData->hProf2); - - if (pData->hProf3) /* sRGB profile defined ? */ - mnglcms_freeprofile (pData->hProf3); -#endif - -#ifdef MNG_INCLUDE_ZLIB - mngzlib_cleanup (pData); /* cleanup zlib stuff */ -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)*hHandle), MNG_FN_CLEANUP, MNG_LC_CLEANUP) -#endif - - pData->iMagic = 0; /* invalidate the actual memory */ - -#ifdef MNG_INTERNAL_MEMMNGMT - free ((void *)*hHandle); /* cleanup the data-structure */ -#else - fFree = ((mng_datap)*hHandle)->fMemfree; - fFree ((mng_ptr)*hHandle, sizeof (mng_data)); -#endif - - *hHandle = 0; /* wipe pointer to inhibit future use */ - - return MNG_NOERROR; /* and we're done */ -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_read (mng_handle hHandle) -{ - mng_datap pData; /* local vars */ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle and callbacks */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - -#ifndef MNG_INTERNAL_MEMMNGMT - MNG_VALIDCB (hHandle, fMemalloc) - MNG_VALIDCB (hHandle, fMemfree) -#endif - -#ifndef MNG_NO_OPEN_CLOSE_STREAM - MNG_VALIDCB (hHandle, fOpenstream) - MNG_VALIDCB (hHandle, fClosestream) -#endif - MNG_VALIDCB (hHandle, fReaddata) - -#ifdef MNG_SUPPORT_DISPLAY /* valid at this point ? */ - if ((pData->bReading) || (pData->bDisplaying)) -#else - if (pData->bReading) -#endif - MNG_ERROR (pData, MNG_FUNCTIONINVALID); - -#ifdef MNG_SUPPORT_WRITE - if ((pData->bWriting) || (pData->bCreating)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID); -#endif - - if (!pData->bCacheplayback) /* must store playback info to work!! */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID); - - cleanup_errors (pData); /* cleanup previous errors */ - - pData->bReading = MNG_TRUE; /* read only! */ - -#ifndef MNG_NO_OPEN_CLOSE_STREAM - if (pData->fOpenstream && !pData->fOpenstream (hHandle)) - /* open it and start reading */ - iRetcode = MNG_APPIOERROR; - else -#endif - iRetcode = mng_read_graphic (pData); - - if (pData->bEOF) /* already at EOF ? */ - { - pData->bReading = MNG_FALSE; /* then we're no longer reading */ - -#ifdef MNG_SUPPORT_DISPLAY - mng_reset_rundata (pData); /* reset rundata */ -#endif - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->bSuspended) /* read suspension ? */ - { - iRetcode = MNG_NEEDMOREDATA; - pData->iSuspendtime = pData->fGettickcount ((mng_handle)pData); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ, MNG_LC_END); -#endif - - return iRetcode; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_read_pushdata (mng_handle hHandle, - mng_ptr pData, - mng_size_t iLength, - mng_bool bTakeownership) -{ - mng_datap pMyData; /* local vars */ - mng_pushdatap pPush; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ_PUSHDATA, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pMyData = ((mng_datap)hHandle); /* and make it addressable */ - /* create a containing buffer */ - iRetcode = make_pushbuffer (pMyData, pData, iLength, bTakeownership, &pPush); - if (iRetcode) - return iRetcode; - - if (pMyData->pLastpushdata) /* and update the buffer chain */ - pMyData->pLastpushdata->pNext = pPush; - else - pMyData->pFirstpushdata = pPush; - - pMyData->pLastpushdata = pPush; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ_PUSHDATA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_read_pushsig (mng_handle hHandle, - mng_imgtype eSigtype) -{ - mng_datap pData; /* local vars */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ_PUSHSIG, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - - if (pData->bHavesig) /* can we expect this call ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID); - - pData->eSigtype = eSigtype; - pData->bHavesig = MNG_TRUE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ_PUSHSIG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_read_pushchunk (mng_handle hHandle, - mng_ptr pChunk, - mng_size_t iLength, - mng_bool bTakeownership) -{ - mng_datap pMyData; /* local vars */ - mng_pushdatap pPush; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ_PUSHCHUNK, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pMyData = ((mng_datap)hHandle); /* and make it addressable */ - /* create a containing buffer */ - iRetcode = make_pushbuffer (pMyData, pChunk, iLength, bTakeownership, &pPush); - if (iRetcode) - return iRetcode; - - if (pMyData->pLastpushchunk) /* and update the buffer chain */ - pMyData->pLastpushchunk->pNext = pPush; - else - pMyData->pFirstpushchunk = pPush; - - pMyData->pLastpushchunk = pPush; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ_PUSHCHUNK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_read_resume (mng_handle hHandle) -{ - mng_datap pData; /* local vars */ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ_RESUME, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - /* can we expect this call ? */ - if ((!pData->bReading) || (!pData->bSuspended)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID); - - cleanup_errors (pData); /* cleanup previous errors */ - - pData->bSuspended = MNG_FALSE; /* reset the flag */ - -#ifdef MNG_SUPPORT_DISPLAY /* re-synchronize ? */ - if ((pData->bDisplaying) && (pData->bRunning)) - pData->iSynctime = pData->iSynctime - pData->iSuspendtime + - pData->fGettickcount (hHandle); -#endif - - iRetcode = mng_read_graphic (pData); /* continue reading now */ - - if (pData->bEOF) /* at EOF ? */ - { - pData->bReading = MNG_FALSE; /* then we're no longer reading */ - -#ifdef MNG_SUPPORT_DISPLAY - mng_reset_rundata (pData); /* reset rundata */ -#endif - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->bSuspended) /* read suspension ? */ - { - iRetcode = MNG_NEEDMOREDATA; - pData->iSuspendtime = pData->fGettickcount ((mng_handle)pData); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ_RESUME, MNG_LC_END); -#endif - - return iRetcode; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_WRITE -mng_retcode MNG_DECL mng_write (mng_handle hHandle) -{ - mng_datap pData; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_WRITE, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle and callbacks */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - -#ifndef MNG_INTERNAL_MEMMNGMT - MNG_VALIDCB (hHandle, fMemalloc) - MNG_VALIDCB (hHandle, fMemfree) -#endif - -#ifndef MNG_NO_OPEN_CLOSE_STREAM - MNG_VALIDCB (hHandle, fOpenstream) - MNG_VALIDCB (hHandle, fClosestream) -#endif - MNG_VALIDCB (hHandle, fWritedata) - -#ifdef MNG_SUPPORT_READ - if (pData->bReading) /* valid at this point ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID); -#endif - - cleanup_errors (pData); /* cleanup previous errors */ - - iRetcode = mng_write_graphic (pData);/* do the write */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_WRITE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_WRITE -mng_retcode MNG_DECL mng_create (mng_handle hHandle) -{ - mng_datap pData; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_CREATE, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle and callbacks */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - -#ifndef MNG_INTERNAL_MEMMNGMT - MNG_VALIDCB (hHandle, fMemalloc) - MNG_VALIDCB (hHandle, fMemfree) -#endif - -#ifdef MNG_SUPPORT_READ - if (pData->bReading) /* valid at this point ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID); -#endif - - if ((pData->bWriting) || (pData->bCreating)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID); - - cleanup_errors (pData); /* cleanup previous errors */ - - iRetcode = mng_reset (hHandle); /* clear any previous stuff */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - - pData->bCreating = MNG_TRUE; /* indicate we're creating a new file */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_CREATE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_SUPPORT_READ) -mng_retcode MNG_DECL mng_readdisplay (mng_handle hHandle) -{ - mng_datap pData; /* local vars */ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_READDISPLAY, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle and callbacks */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - -#ifndef MNG_INTERNAL_MEMMNGMT - MNG_VALIDCB (hHandle, fMemalloc) - MNG_VALIDCB (hHandle, fMemfree) -#endif - - MNG_VALIDCB (hHandle, fReaddata) - MNG_VALIDCB (hHandle, fGetcanvasline) - MNG_VALIDCB (hHandle, fRefresh) - MNG_VALIDCB (hHandle, fGettickcount) - MNG_VALIDCB (hHandle, fSettimer) - /* valid at this point ? */ - if ((pData->bReading) || (pData->bDisplaying)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID); - -#ifdef MNG_SUPPORT_WRITE - if ((pData->bWriting) || (pData->bCreating)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID); -#endif - - cleanup_errors (pData); /* cleanup previous errors */ - - pData->bReading = MNG_TRUE; /* read & display! */ - pData->bDisplaying = MNG_TRUE; - pData->bRunning = MNG_TRUE; - pData->iFrameseq = 0; - pData->iLayerseq = 0; - pData->iFrametime = 0; - pData->iRequestframe = 0; - pData->iRequestlayer = 0; - pData->iRequesttime = 0; - pData->bSearching = MNG_FALSE; - pData->iRuntime = 0; - pData->iSynctime = pData->fGettickcount (hHandle); - pData->iSuspendtime = 0; - pData->iStarttime = pData->iSynctime; - pData->iEndtime = 0; - -#ifndef MNG_NO_OPEN_CLOSE_STREAM - if (pData->fOpenstream && !pData->fOpenstream (hHandle)) - /* open it and start reading */ - iRetcode = MNG_APPIOERROR; - else -#endif - iRetcode = mng_read_graphic (pData); - - if (pData->bEOF) /* already at EOF ? */ - { - pData->bReading = MNG_FALSE; /* then we're no longer reading */ - mng_drop_invalid_objects (pData); /* drop invalidly stored objects */ - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->bSuspended) /* read suspension ? */ - { - iRetcode = MNG_NEEDMOREDATA; - pData->iSuspendtime = pData->fGettickcount ((mng_handle)pData); - } - else - if (pData->bTimerset) /* indicate timer break ? */ - iRetcode = MNG_NEEDTIMERWAIT; - else - if (pData->bSectionwait) /* indicate section break ? */ - iRetcode = MNG_NEEDSECTIONWAIT; - else - { /* no breaks = end of run */ - pData->bRunning = MNG_FALSE; - - if (pData->bFreezing) /* dynamic MNG reached SEEK ? */ - pData->bFreezing = MNG_FALSE; /* reset it ! */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_READDISPLAY, MNG_LC_END); -#endif - - return iRetcode; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_display (mng_handle hHandle) -{ - mng_datap pData; /* local vars */ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle and callbacks */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - -#ifndef MNG_INTERNAL_MEMMNGMT - MNG_VALIDCB (hHandle, fMemalloc) - MNG_VALIDCB (hHandle, fMemfree) -#endif - - MNG_VALIDCB (hHandle, fGetcanvasline) - MNG_VALIDCB (hHandle, fRefresh) - MNG_VALIDCB (hHandle, fGettickcount) - MNG_VALIDCB (hHandle, fSettimer) - - if (pData->bDisplaying) /* valid at this point ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID); - -#ifdef MNG_SUPPORT_READ - if (pData->bReading) - MNG_ERROR (pData, MNG_FUNCTIONINVALID); -#endif - -#ifdef MNG_SUPPORT_WRITE - if ((pData->bWriting) || (pData->bCreating)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID); -#endif - - cleanup_errors (pData); /* cleanup previous errors */ - - pData->bDisplaying = MNG_TRUE; /* display! */ - pData->bRunning = MNG_TRUE; - pData->iFrameseq = 0; - pData->iLayerseq = 0; - pData->iFrametime = 0; - pData->iRequestframe = 0; - pData->iRequestlayer = 0; - pData->iRequesttime = 0; - pData->bSearching = MNG_FALSE; - pData->iRuntime = 0; - pData->iSynctime = pData->fGettickcount (hHandle); -#ifdef MNG_SUPPORT_READ - pData->iSuspendtime = 0; -#endif - pData->iStarttime = pData->iSynctime; - pData->iEndtime = 0; - pData->pCurraniobj = pData->pFirstaniobj; - /* go do it */ - iRetcode = mng_process_display (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->bTimerset) /* indicate timer break ? */ - iRetcode = MNG_NEEDTIMERWAIT; - else - { /* no breaks = end of run */ - pData->bRunning = MNG_FALSE; - - if (pData->bFreezing) /* dynamic MNG reached SEEK ? */ - pData->bFreezing = MNG_FALSE; /* reset it ! */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY, MNG_LC_END); -#endif - - return iRetcode; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_display_resume (mng_handle hHandle) -{ - mng_datap pData; /* local vars */ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_RESUME, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - - if (!pData->bDisplaying) /* can we expect this call ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID); - - cleanup_errors (pData); /* cleanup previous errors */ - /* was it running ? */ - if ((pData->bRunning) || (pData->bReading)) - { /* are we expecting this call ? */ - if ((pData->bTimerset) || (pData->bSuspended) || (pData->bSectionwait)) - { - pData->bTimerset = MNG_FALSE; /* reset the flags */ - pData->bSectionwait = MNG_FALSE; - -#ifdef MNG_SUPPORT_READ - if (pData->bReading) /* set during read&display ? */ - { - if (pData->bSuspended) /* calculate proper synchronization */ - pData->iSynctime = pData->iSynctime - pData->iSuspendtime + - pData->fGettickcount (hHandle); - else - pData->iSynctime = pData->fGettickcount (hHandle); - - pData->bSuspended = MNG_FALSE; /* now reset this flag */ - /* and continue reading */ - iRetcode = mng_read_graphic (pData); - - if (pData->bEOF) /* already at EOF ? */ - { - pData->bReading = MNG_FALSE; /* then we're no longer reading */ - /* drop invalidly stored objects */ - mng_drop_invalid_objects (pData); - } - } - else -#endif /* MNG_SUPPORT_READ */ - { /* synchronize timing */ - pData->iSynctime = pData->fGettickcount (hHandle); - /* resume display processing */ - iRetcode = mng_process_display (pData); - } - } - else - { - MNG_ERROR (pData, MNG_FUNCTIONINVALID); - } - } - else - { /* synchronize timing */ - pData->iSynctime = pData->fGettickcount (hHandle); - pData->bRunning = MNG_TRUE; /* it's restarted again ! */ - /* resume display processing */ - iRetcode = mng_process_display (pData); - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->bSuspended) /* read suspension ? */ - { - iRetcode = MNG_NEEDMOREDATA; - pData->iSuspendtime = pData->fGettickcount ((mng_handle)pData); - } - else - if (pData->bTimerset) /* indicate timer break ? */ - iRetcode = MNG_NEEDTIMERWAIT; - else - if (pData->bSectionwait) /* indicate section break ? */ - iRetcode = MNG_NEEDSECTIONWAIT; - else - { /* no breaks = end of run */ - pData->bRunning = MNG_FALSE; - - if (pData->bFreezing) /* trying to freeze ? */ - pData->bFreezing = MNG_FALSE; /* then we're there */ - - if (pData->bResetting) /* trying to reset as well ? */ - { /* full stop!!! */ - pData->bDisplaying = MNG_FALSE; - - iRetcode = mng_reset_rundata (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_RESUME, MNG_LC_END); -#endif - - return iRetcode; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_display_freeze (mng_handle hHandle) -{ - mng_datap pData; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_FREEZE, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - /* can we expect this call ? */ - if ((!pData->bDisplaying) || (pData->bReading)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID); - - cleanup_errors (pData); /* cleanup previous errors */ - - if (pData->bRunning) /* is it running ? */ - { - mng_retcode iRetcode; - - pData->bFreezing = MNG_TRUE; /* indicate we need to freeze */ - /* continue "normal" processing */ - iRetcode = mng_display_resume (hHandle); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_FREEZE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_display_reset (mng_handle hHandle) -{ - mng_datap pData; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_RESET, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - /* can we expect this call ? */ - if ((!pData->bDisplaying) || (pData->bReading)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID); - - if (!pData->bCacheplayback) /* must store playback info to work!! */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID); - - cleanup_errors (pData); /* cleanup previous errors */ - - if (pData->bRunning) /* is it running ? */ - { - pData->bFreezing = MNG_TRUE; /* indicate we need to freeze */ - pData->bResetting = MNG_TRUE; /* indicate we're about to reset too */ - /* continue normal processing ? */ - iRetcode = mng_display_resume (hHandle); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - else - { /* full stop!!! */ - pData->bDisplaying = MNG_FALSE; - - iRetcode = mng_reset_rundata (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_RESET, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -#ifndef MNG_NO_DISPLAY_GO_SUPPORTED -mng_retcode MNG_DECL mng_display_goframe (mng_handle hHandle, - mng_uint32 iFramenr) -{ - mng_datap pData; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_GOFRAME, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - - if (pData->eImagetype != mng_it_mng) /* is it an animation ? */ - MNG_ERROR (pData, MNG_NOTANANIMATION); - /* can we expect this call ? */ - if ((!pData->bDisplaying) || (pData->bRunning)) - MNG_ERROR ((mng_datap)hHandle, MNG_FUNCTIONINVALID); - - if (!pData->bCacheplayback) /* must store playback info to work!! */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID); - - if (iFramenr > pData->iTotalframes) /* is the parameter within bounds ? */ - MNG_ERROR (pData, MNG_FRAMENRTOOHIGH); - /* within MHDR bounds ? */ - if ((pData->iFramecount) && (iFramenr > pData->iFramecount)) - MNG_WARNING (pData, MNG_FRAMENRTOOHIGH); - - cleanup_errors (pData); /* cleanup previous errors */ - - if (pData->iFrameseq > iFramenr) /* search from current or go back to start ? */ - { - iRetcode = mng_reset_rundata (pData); - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - if (iFramenr) - { - pData->iRequestframe = iFramenr; /* go find the requested frame then */ - iRetcode = mng_process_display (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - pData->bTimerset = MNG_FALSE; /* reset just to be safe */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_GOFRAME, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -#ifndef MNG_NO_DISPLAY_GO_SUPPORTED -mng_retcode MNG_DECL mng_display_golayer (mng_handle hHandle, - mng_uint32 iLayernr) -{ - mng_datap pData; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_GOLAYER, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - - if (pData->eImagetype != mng_it_mng) /* is it an animation ? */ - MNG_ERROR (pData, MNG_NOTANANIMATION); - /* can we expect this call ? */ - if ((!pData->bDisplaying) || (pData->bRunning)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID); - - if (!pData->bCacheplayback) /* must store playback info to work!! */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID); - - if (iLayernr > pData->iTotallayers) /* is the parameter within bounds ? */ - MNG_ERROR (pData, MNG_LAYERNRTOOHIGH); - /* within MHDR bounds ? */ - if ((pData->iLayercount) && (iLayernr > pData->iLayercount)) - MNG_WARNING (pData, MNG_LAYERNRTOOHIGH); - - cleanup_errors (pData); /* cleanup previous errors */ - - if (pData->iLayerseq > iLayernr) /* search from current or go back to start ? */ - { - iRetcode = mng_reset_rundata (pData); - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - if (iLayernr) - { - pData->iRequestlayer = iLayernr; /* go find the requested layer then */ - iRetcode = mng_process_display (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - pData->bTimerset = MNG_FALSE; /* reset just to be safe */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_GOLAYER, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -#ifndef MNG_NO_DISPLAY_GO_SUPPORTED -mng_retcode MNG_DECL mng_display_gotime (mng_handle hHandle, - mng_uint32 iPlaytime) -{ - mng_datap pData; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_GOTIME, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - - if (pData->eImagetype != mng_it_mng) /* is it an animation ? */ - MNG_ERROR (pData, MNG_NOTANANIMATION); - /* can we expect this call ? */ - if ((!pData->bDisplaying) || (pData->bRunning)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID); - - if (!pData->bCacheplayback) /* must store playback info to work!! */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID); - /* is the parameter within bounds ? */ - if (iPlaytime > pData->iTotalplaytime) - MNG_ERROR (pData, MNG_PLAYTIMETOOHIGH); - /* within MHDR bounds ? */ - if ((pData->iPlaytime) && (iPlaytime > pData->iPlaytime)) - MNG_WARNING (pData, MNG_PLAYTIMETOOHIGH); - - cleanup_errors (pData); /* cleanup previous errors */ - - if (pData->iFrametime > iPlaytime) /* search from current or go back to start ? */ - { - iRetcode = mng_reset_rundata (pData); - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - if (iPlaytime) - { - pData->iRequesttime = iPlaytime; /* go find the requested playtime then */ - iRetcode = mng_process_display (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - pData->bTimerset = MNG_FALSE; /* reset just to be safe */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_GOTIME, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_SUPPORT_DYNAMICMNG) -mng_retcode MNG_DECL mng_trapevent (mng_handle hHandle, - mng_uint8 iEventtype, - mng_int32 iX, - mng_int32 iY) -{ - mng_datap pData; - mng_eventp pEvent; - mng_bool bFound = MNG_FALSE; - mng_retcode iRetcode; - mng_imagep pImage; - mng_uint8p pPixel; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_TRAPEVENT, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - - if (pData->eImagetype != mng_it_mng) /* is it an animation ? */ - MNG_ERROR (pData, MNG_NOTANANIMATION); - - if (!pData->bDisplaying) /* can we expect this call ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID); - - if (!pData->bCacheplayback) /* must store playback info to work!! */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID); - /* let's find a matching event object */ - pEvent = (mng_eventp)pData->pFirstevent; - - while ((pEvent) && (!bFound)) - { /* matching eventtype ? */ - if (pEvent->iEventtype == iEventtype) - { - switch (pEvent->iMasktype) /* check X/Y on basis of masktype */ - { - case MNG_MASK_NONE : /* no mask is easy */ - { - bFound = MNG_TRUE; - break; - } - - case MNG_MASK_BOX : /* inside the given box ? */ - { /* right- and bottom-border don't count ! */ - if ((iX >= pEvent->iLeft) && (iX < pEvent->iRight) && - (iY >= pEvent->iTop) && (iY < pEvent->iBottom)) - bFound = MNG_TRUE; - break; - } - - case MNG_MASK_OBJECT : /* non-zero pixel in the image object ? */ - { - pImage = mng_find_imageobject (pData, pEvent->iObjectid); - /* valid image ? */ - if ((pImage) && (pImage->pImgbuf->iBitdepth <= 8) && - ((pImage->pImgbuf->iColortype == 0) || (pImage->pImgbuf->iColortype == 3)) && - ((mng_int32)pImage->pImgbuf->iWidth > iX) && - ((mng_int32)pImage->pImgbuf->iHeight > iY)) - { - pPixel = pImage->pImgbuf->pImgdata + ((pImage->pImgbuf->iWidth * iY) + iX); - - if (*pPixel) /* non-zero ? */ - bFound = MNG_TRUE; - } - - break; - } - - case MNG_MASK_OBJECTIX : /* pixel in the image object matches index ? */ - { - pImage = mng_find_imageobject (pData, pEvent->iObjectid); - /* valid image ? */ - if ((pImage) && (pImage->pImgbuf->iBitdepth <= 8) && - ((pImage->pImgbuf->iColortype == 0) || (pImage->pImgbuf->iColortype == 3)) && - ((mng_int32)pImage->pImgbuf->iWidth > iX) && (iX >= 0) && - ((mng_int32)pImage->pImgbuf->iHeight > iY) && (iY >= 0)) - { - pPixel = pImage->pImgbuf->pImgdata + ((pImage->pImgbuf->iWidth * iY) + iX); - /* matching index ? */ - if (*pPixel == pEvent->iIndex) - bFound = MNG_TRUE; - } - - break; - } - - case MNG_MASK_BOXOBJECT : /* non-zero pixel in the image object ? */ - { - mng_int32 iTempx = iX - pEvent->iLeft; - mng_int32 iTempy = iY - pEvent->iTop; - - pImage = mng_find_imageobject (pData, pEvent->iObjectid); - /* valid image ? */ - if ((pImage) && (pImage->pImgbuf->iBitdepth <= 8) && - ((pImage->pImgbuf->iColortype == 0) || (pImage->pImgbuf->iColortype == 3)) && - (iTempx < (mng_int32)pImage->pImgbuf->iWidth) && - (iTempx >= 0) && (iX < pEvent->iRight) && - (iTempy < (mng_int32)pImage->pImgbuf->iHeight) && - (iTempy >= 0) && (iY < pEvent->iBottom)) - { - pPixel = pImage->pImgbuf->pImgdata + ((pImage->pImgbuf->iWidth * iTempy) + iTempx); - - if (*pPixel) /* non-zero ? */ - bFound = MNG_TRUE; - } - - break; - } - - case MNG_MASK_BOXOBJECTIX : /* pixel in the image object matches index ? */ - { - mng_int32 iTempx = iX - pEvent->iLeft; - mng_int32 iTempy = iY - pEvent->iTop; - - pImage = mng_find_imageobject (pData, pEvent->iObjectid); - /* valid image ? */ - if ((pImage) && (pImage->pImgbuf->iBitdepth <= 8) && - ((pImage->pImgbuf->iColortype == 0) || (pImage->pImgbuf->iColortype == 3)) && - (iTempx < (mng_int32)pImage->pImgbuf->iWidth) && - (iTempx >= 0) && (iX < pEvent->iRight) && - (iTempy < (mng_int32)pImage->pImgbuf->iHeight) && - (iTempy >= 0) && (iY < pEvent->iBottom)) - { - pPixel = pImage->pImgbuf->pImgdata + ((pImage->pImgbuf->iWidth * iTempy) + iTempx); - /* matching index ? */ - if (*pPixel == pEvent->iIndex) - bFound = MNG_TRUE; - } - - break; - } - - } - } - - if (!bFound) /* try the next one */ - pEvent = (mng_eventp)pEvent->sHeader.pNext; - } - /* found one that's not the last mousemove ? */ - if ((pEvent) && ((mng_objectp)pEvent != pData->pLastmousemove)) - { /* can we start an event process now ? */ - if ((!pData->bReading) && (!pData->bRunning)) - { - pData->iEventx = iX; /* save coordinates */ - pData->iEventy = iY; - /* do it then ! */ - iRetcode = pEvent->sHeader.fProcess (pData, pEvent); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* remember last mousemove event */ - if (pEvent->iEventtype == MNG_EVENT_MOUSEMOVE) - pData->pLastmousemove = (mng_objectp)pEvent; - else - pData->pLastmousemove = MNG_NULL; - } - else - { - - /* TODO: store unprocessed events or not ??? */ - - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_TRAPEVENT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getlasterror (mng_handle hHandle, - mng_int8* iSeverity, - mng_chunkid* iChunkname, - mng_uint32* iChunkseq, - mng_int32* iExtra1, - mng_int32* iExtra2, - mng_pchar* zErrortext) -{ - mng_datap pData; /* local vars */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETLASTERROR, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - - *iSeverity = pData->iSeverity; /* return the appropriate fields */ - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) - *iChunkname = pData->iChunkname; - *iChunkseq = pData->iChunkseq; -#else - *iChunkname = MNG_UINT_HUH; - *iChunkseq = 0; -#endif - - *iExtra1 = pData->iErrorx1; - *iExtra2 = pData->iErrorx2; - *zErrortext = pData->zErrortext; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETLASTERROR, MNG_LC_END); -#endif - - return pData->iErrorcode; /* and the errorcode */ -} - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - - diff --git a/plugins/AdvaImg/src/LibMNG/libmng_jpeg.c b/plugins/AdvaImg/src/LibMNG/libmng_jpeg.c deleted file mode 100644 index 409f6df74d..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_jpeg.c +++ /dev/null @@ -1,1088 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_jpeg.c copyright (c) 2000-2004 G.Juyn * */ -/* * version : 1.0.9 * */ -/* * * */ -/* * purpose : JPEG library interface (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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 * */ -/* * * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added support for JDAA * */ -/* * * */ -/* * 1.0.1 - 04/19/2001 - G.Juyn * */ -/* * - added export of JPEG functions for DLL * */ -/* * 1.0.1 - 04/22/2001 - G.Juyn * */ -/* * - fixed memory-leaks (Thanks Gregg!) * */ -/* * * */ -/* * 1.0.4 - 06/22/2002 - G.Juyn * */ -/* * - B526138 - returned IJGSRC6B calling convention to * */ -/* * default for MSVC * */ -/* * * */ -/* * 1.0.5 - 24/02/2003 - G.Juyn * */ -/* * - B683152 - libjpeg suspension not always honored correctly* */ -/* * * */ -/* * 1.0.6 - 03/04/2003 - G.Juyn * */ -/* * - fixed some compiler-warnings * */ -/* * * */ -/* * 1.0.8 - 08/01/2004 - G.Juyn * */ -/* * - added support for 3+byte pixelsize for JPEG's * */ -/* * * */ -/* * 1.0.9 - 12/20/2004 - G.Juyn * */ -/* * - cleaned up macro-invocations (thanks to D. Airlie) * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_memory.h" -#include "libmng_pixels.h" -#include "libmng_jpeg.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#if defined(MNG_INCLUDE_JNG) && defined(MNG_INCLUDE_DISPLAY_PROCS) - -/* ************************************************************************** */ -/* * * */ -/* * Local IJG callback routines (source-manager, error-manager and such) * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_IJG6B - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -#ifdef MNG_DEFINE_JPEG_STDCALL -void MNG_DECL mng_init_source (j_decompress_ptr cinfo) -#else -void mng_init_source (j_decompress_ptr cinfo) -#endif -{ - return; /* nothing needed */ -} -#endif /* MNG_INCLUDE_JNG_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -#ifdef MNG_DEFINE_JPEG_STDCALL -boolean MNG_DECL mng_fill_input_buffer (j_decompress_ptr cinfo) -#else -boolean mng_fill_input_buffer (j_decompress_ptr cinfo) -#endif -{ - return FALSE; /* force IJG routine to return to caller */ -} -#endif /* MNG_INCLUDE_JNG_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -#ifdef MNG_DEFINE_JPEG_STDCALL -void MNG_DECL mng_skip_input_data (j_decompress_ptr cinfo, long num_bytes) -#else -void mng_skip_input_data (j_decompress_ptr cinfo, long num_bytes) -#endif -{ - 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 -#ifdef MNG_DEFINE_JPEG_STDCALL -void MNG_DECL mng_skip_input_data2 (j_decompress_ptr cinfo, long num_bytes) -#else -void mng_skip_input_data2 (j_decompress_ptr cinfo, long num_bytes) -#endif -{ - 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->pJPEGdinfo2->src; - /* problem scenario ? */ - if (pSrc->bytes_in_buffer < (size_t)num_bytes) - { /* tell the boss we need to skip some data! */ - pData->iJPEGtoskip2 = (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 -#ifdef MNG_DEFINE_JPEG_STDCALL -void MNG_DECL mng_term_source (j_decompress_ptr cinfo) -#else -void mng_term_source (j_decompress_ptr cinfo) -#endif -{ - return; /* nothing needed */ -} -#endif /* MNG_INCLUDE_JNG_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_USE_SETJMP -#ifdef MNG_DEFINE_JPEG_STDCALL -void MNG_DECL mng_error_exit (j_common_ptr cinfo) -#else -void mng_error_exit (j_common_ptr cinfo) -#endif -{ /* 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 -#ifdef MNG_DEFINE_JPEG_STDCALL -void MNG_DECL mng_output_message (j_common_ptr cinfo) -#else -void mng_output_message (j_common_ptr cinfo) -#endif -{ - 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; - - if (pData->pJPEGderr2 == MNG_NULL) - MNG_ALLOC (pData, pData->pJPEGderr2, sizeof (mngjpeg_error )); - if (pData->pJPEGdsrc2 == MNG_NULL) - MNG_ALLOC (pData, pData->pJPEGdsrc2, sizeof (mngjpeg_source)); - if (pData->pJPEGdinfo2 == MNG_NULL) - MNG_ALLOC (pData, pData->pJPEGdinfo2, sizeof (mngjpeg_decomp)); - /* enable reverse addressing */ - pData->pJPEGdinfo2->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 - - if (pData->pJPEGbuf == MNG_NULL) /* initialize temporary buffers */ - { - pData->iJPEGbufmax = MNG_JPEG_MAXBUF; - MNG_ALLOC (pData, pData->pJPEGbuf, pData->iJPEGbufmax); - } - - if (pData->pJPEGbuf2 == MNG_NULL) - { - pData->iJPEGbufmax2 = MNG_JPEG_MAXBUF; - MNG_ALLOC (pData, pData->pJPEGbuf2, pData->iJPEGbufmax2); - } - - pData->pJPEGcurrent = pData->pJPEGbuf; - pData->iJPEGbufremain = 0; - pData->pJPEGrow = MNG_NULL; - pData->iJPEGrowlen = 0; - pData->iJPEGtoskip = 0; - - pData->pJPEGcurrent2 = pData->pJPEGbuf2; - pData->iJPEGbufremain2 = 0; - pData->pJPEGrow2 = MNG_NULL; - pData->iJPEGrowlen2 = 0; - pData->iJPEGtoskip2 = 0; - /* not doing anything yet ! */ - pData->bJPEGcompress = MNG_FALSE; - - pData->bJPEGdecompress = MNG_FALSE; - pData->bJPEGhasheader = MNG_FALSE; - pData->bJPEGdecostarted = MNG_FALSE; - pData->bJPEGscanstarted = MNG_FALSE; - pData->bJPEGscanending = MNG_FALSE; - - pData->bJPEGdecompress2 = MNG_FALSE; - pData->bJPEGhasheader2 = MNG_FALSE; - pData->bJPEGdecostarted2 = MNG_FALSE; - pData->bJPEGscanstarted2 = 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 /* still decompressing something ? */ - if (pData->bJPEGdecompress) - jpeg_destroy_decompress (pData->pJPEGdinfo); - if (pData->bJPEGdecompress2) - jpeg_destroy_decompress (pData->pJPEGdinfo2); -#endif - -#ifdef MNG_INCLUDE_JNG_WRITE - if (pData->bJPEGcompress) /* still compressing something ? */ - jpeg_destroy_compress (pData->pJPEGcinfo); -#endif - -#endif /* MNG_INCLUDE_IJG6B */ - /* cleanup temporary buffers */ - MNG_FREE (pData, pData->pJPEGbuf2, pData->iJPEGbufmax2); - MNG_FREE (pData, pData->pJPEGbuf, pData->iJPEGbufmax); - /* cleanup space for JPEG structures */ -#ifdef MNG_INCLUDE_JNG_WRITE - MNG_FREE (pData, pData->pJPEGcinfo, sizeof (mngjpeg_comp )); - MNG_FREE (pData, pData->pJPEGcerr, sizeof (mngjpeg_error )); -#endif - -#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 )); - MNG_FREE (pData, pData->pJPEGdinfo2, sizeof (mngjpeg_decomp)); - MNG_FREE (pData, pData->pJPEGdsrc2, sizeof (mngjpeg_source)); - MNG_FREE (pData, pData->pJPEGderr2, sizeof (mngjpeg_error )); -#endif - - MNG_FREE (pData, pData->pJPEGrow2, pData->iJPEGrowlen2); - MNG_FREE (pData, pData->pJPEGrow, pData->iJPEGrowlen); - /* whatever we were doing ... */ - /* we don't anymore ... */ - pData->bJPEGcompress = MNG_FALSE; - - pData->bJPEGdecompress = MNG_FALSE; - pData->bJPEGhasheader = MNG_FALSE; - pData->bJPEGdecostarted = MNG_FALSE; - pData->bJPEGscanstarted = MNG_FALSE; - pData->bJPEGscanending = MNG_FALSE; - - pData->bJPEGdecompress2 = MNG_FALSE; - pData->bJPEGhasheader2 = MNG_FALSE; - pData->bJPEGdecostarted2 = MNG_FALSE; - pData->bJPEGscanstarted2 = MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_CLEANUP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * JPEG decompression routines (JDAT) * */ -/* * * */ -/* ************************************************************************** */ - -#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; - /* let's do some sanity checks ! */ - 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 * RGB_PIXELSIZE; - 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) || - ((pData->bJPEGprogressive) && (pData->bJPEGscanending)))) - { - mng_int32 iLines = 0; - - /* for (each output pass) */ - do - { /* address the row output buffer */ - JSAMPROW pRow = (JSAMPROW)pData->pJPEGrow; - - /* init new pass ? */ - if ((pData->bJPEGprogressive) && (!pData->bJPEGscanstarted)) - { - 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) */ - if ((!pData->bJPEGprogressive) || (!pData->bJPEGscanending)) - { - 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 - if (jpeg_finish_output (pData->pJPEGdinfo) != JPEG_SUSPENDED) - { /* this scan has ended */ - pData->bJPEGscanstarted = MNG_FALSE; - pData->bJPEGscanending = MNG_FALSE; - } - else - { - pData->bJPEGscanending = MNG_TRUE; - } - } - } - while ((!jpeg_input_complete (pData->pJPEGdinfo)) && - (iLines > 0) && (!pData->bJPEGscanending)); - } - /* end of image ? */ - if ((pData->bJPEGhasheader) && (pData->bJPEGdecostarted) && - (!pData->bJPEGscanending) && (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 - /* free the row of JPEG-samples*/ - MNG_FREE (pData, pData->pJPEGrow, pData->iJPEGrowlen); - - /* 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 */ - -/* ************************************************************************** */ -/* * * */ -/* * JPEG decompression routines (JDAA) * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -mng_retcode mngjpeg_decompressinit2 (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->pJPEGdinfo2->err = jpeg_std_error (pData->pJPEGderr2); - -#ifdef MNG_USE_SETJMP /* setup local JPEG error-routines */ - pData->pJPEGderr2->error_exit = mng_error_exit; - pData->pJPEGderr2->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->pJPEGdinfo2); - - pData->bJPEGdecompress2 = 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->pJPEGdinfo2->src = pData->pJPEGdsrc2; - /* use the default handler */ - pData->pJPEGdinfo2->src->resync_to_restart = jpeg_resync_to_restart; - /* setup local source routine & parms */ - pData->pJPEGdinfo2->src->init_source = mng_init_source; - pData->pJPEGdinfo2->src->fill_input_buffer = mng_fill_input_buffer; - pData->pJPEGdinfo2->src->skip_input_data = mng_skip_input_data2; - pData->pJPEGdinfo2->src->term_source = mng_term_source; - pData->pJPEGdinfo2->src->next_input_byte = pData->pJPEGcurrent2; - pData->pJPEGdinfo2->src->bytes_in_buffer = pData->iJPEGbufremain2; - -#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_decompressdata2 (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->iJPEGtoskip2) /* JPEG-lib told us to skip some more data ? */ - { - if (iRemain > pData->iJPEGtoskip2) /* enough data in this buffer ? */ - { - iRemain -= pData->iJPEGtoskip2; /* skip enough to access the next byte */ - pWork += pData->iJPEGtoskip2; - - pData->iJPEGtoskip2 = 0; /* no more to skip then */ - } - else - { - pData->iJPEGtoskip2 -= iRemain; /* skip all data in the buffer */ - iRemain = 0; /* and indicate this accordingly */ - } - /* the skip set current-pointer to NULL ! */ - pData->pJPEGcurrent2 = pData->pJPEGbuf2; - } - - while (iRemain) /* repeat until no more input-bytes */ - { /* need to shift anything ? */ - if ((pData->pJPEGcurrent2 > pData->pJPEGbuf2) && - (pData->pJPEGcurrent2 - pData->pJPEGbuf2 + pData->iJPEGbufremain2 + iRemain > pData->iJPEGbufmax2)) - { - if (pData->iJPEGbufremain2 > 0) /* then do so */ - MNG_COPY (pData->pJPEGbuf2, pData->pJPEGcurrent2, pData->iJPEGbufremain2); - - pData->pJPEGcurrent2 = pData->pJPEGbuf2; - } - /* does the remaining input fit into the buffer ? */ - if (pData->iJPEGbufremain2 + iRemain <= pData->iJPEGbufmax2) - { /* move the lot */ - MNG_COPY ((pData->pJPEGcurrent2 + pData->iJPEGbufremain2), pWork, iRemain); - /* adjust remaining_bytes counter */ - pData->iJPEGbufremain2 += iRemain; - iRemain = 0; /* and indicate there's no input left */ - } - else - { /* calculate what does fit */ - mng_uint32 iFits = pData->iJPEGbufmax2 - pData->iJPEGbufremain2; - - if (iFits <= 0) /* no space is just bugger 'm all */ - MNG_ERROR (pData, MNG_JPEGBUFTOOSMALL); - /* move that */ - MNG_COPY ((pData->pJPEGcurrent2 + pData->iJPEGbufremain2), pWork, iFits); - - pData->iJPEGbufremain2 += iFits; /* adjust remain_bytes counter */ - iRemain -= iFits; /* and the input-parms */ - pWork += iFits; - } - -#ifdef MNG_INCLUDE_IJG6B - pData->pJPEGdinfo2->src->next_input_byte = pData->pJPEGcurrent2; - pData->pJPEGdinfo2->src->bytes_in_buffer = pData->iJPEGbufremain2; - - if (!pData->bJPEGhasheader2) /* 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->pJPEGdinfo2, TRUE) != JPEG_SUSPENDED) - { /* indicate the header's oke */ - pData->bJPEGhasheader2 = MNG_TRUE; - /* let's do some sanity checks ! */ - if ((pData->pJPEGdinfo2->image_width != pData->iDatawidth ) || - (pData->pJPEGdinfo2->image_height != pData->iDataheight) ) - MNG_ERROR (pData, MNG_JPEGPARMSERR); - - if (pData->pJPEGdinfo2->jpeg_color_space != JCS_GRAYSCALE) - MNG_ERROR (pData, MNG_JPEGPARMSERR); - /* indicate whether or not it's progressive */ - pData->bJPEGprogressive2 = (mng_bool)jpeg_has_multiple_scans (pData->pJPEGdinfo2); - - if (pData->bJPEGprogressive2) /* progressive alphachannel not allowed !!! */ - MNG_ERROR (pData, MNG_JPEGPARMSERR); - /* allocate a row of JPEG-samples */ - if (pData->pJPEGdinfo2->jpeg_color_space == JCS_YCbCr) - pData->iJPEGrowlen2 = pData->pJPEGdinfo2->image_width * RGB_PIXELSIZE; - else - pData->iJPEGrowlen2 = pData->pJPEGdinfo2->image_width; - - MNG_ALLOC (pData, pData->pJPEGrow2, pData->iJPEGrowlen2); - - pData->iJPEGalpharow = 0; /* quite empty up to now */ - } - - pData->pJPEGcurrent2 = (mng_uint8p)pData->pJPEGdinfo2->src->next_input_byte; - pData->iJPEGbufremain2 = (mng_uint32)pData->pJPEGdinfo2->src->bytes_in_buffer; - } - /* decompress not started ? */ - if ((pData->bJPEGhasheader2) && (!pData->bJPEGdecostarted2)) - { - /* set parameters for decompression */ - - if (pData->bJPEGprogressive2) /* progressive display ? */ - pData->pJPEGdinfo2->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->pJPEGdinfo2) == TRUE) - /* indicate it started */ - pData->bJPEGdecostarted2 = MNG_TRUE; - - pData->pJPEGcurrent2 = (mng_uint8p)pData->pJPEGdinfo2->src->next_input_byte; - pData->iJPEGbufremain2 = (mng_uint32)pData->pJPEGdinfo2->src->bytes_in_buffer; - } - /* process some scanlines ? */ - if ((pData->bJPEGhasheader2) && (pData->bJPEGdecostarted2) && - ((!jpeg_input_complete (pData->pJPEGdinfo2)) || - (pData->pJPEGdinfo2->output_scanline < pData->pJPEGdinfo2->output_height))) - { - mng_int32 iLines; - - /* for (each output pass) */ - do - { /* address the row output buffer */ - JSAMPROW pRow = (JSAMPROW)pData->pJPEGrow2; - - /* init new pass ? */ - if ((pData->bJPEGprogressive2) && - ((!pData->bJPEGscanstarted2) || - (pData->pJPEGdinfo2->output_scanline >= pData->pJPEGdinfo2->output_height))) - { - pData->bJPEGscanstarted2 = 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->pJPEGdinfo2, pData->pJPEGdinfo2->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->pJPEGdinfo2, (JSAMPARRAY)&pRow, 1); - - pData->pJPEGcurrent2 = (mng_uint8p)pData->pJPEGdinfo2->src->next_input_byte; - pData->iJPEGbufremain2 = (mng_uint32)pData->pJPEGdinfo2->src->bytes_in_buffer; - - if (iLines > 0) /* got something ? */ - { - if (pData->fStorerow3) /* store in object ? */ - { - iRetcode = ((mng_storerow)pData->fStorerow3) (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } - } - } - while ((pData->pJPEGdinfo2->output_scanline < pData->pJPEGdinfo2->output_height) && - (iLines > 0)); /* until end-of-image or not enough input-data */ - - /* terminate output pass */ - if ((pData->bJPEGprogressive2) && - (pData->pJPEGdinfo2->output_scanline >= pData->pJPEGdinfo2->output_height)) - { -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_FINISH_OUTPUT) -#endif - if (jpeg_finish_output (pData->pJPEGdinfo2) == JPEG_SUSPENDED) - jpeg_finish_output (pData->pJPEGdinfo2); - /* this scan has ended */ - pData->bJPEGscanstarted2 = MNG_FALSE; - } - } - while ((!jpeg_input_complete (pData->pJPEGdinfo2)) && (iLines > 0)); - } - /* end of image ? */ - if ((pData->bJPEGhasheader2) && (pData->bJPEGdecostarted2) && - (jpeg_input_complete (pData->pJPEGdinfo2)) && - (pData->pJPEGdinfo2->input_scan_number == pData->pJPEGdinfo2->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->pJPEGdinfo2) == TRUE) - { /* indicate it's done */ - pData->bJPEGhasheader2 = MNG_FALSE; - pData->bJPEGdecostarted2 = MNG_FALSE; - pData->pJPEGcurrent2 = (mng_uint8p)pData->pJPEGdinfo2->src->next_input_byte; - pData->iJPEGbufremain2 = (mng_uint32)pData->pJPEGdinfo2->src->bytes_in_buffer; - /* remaining fluff is an error ! */ - if ((pData->iJPEGbufremain2 > 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_decompressfree2 (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 - /* free the row of JPEG-samples*/ - MNG_FREE (pData, pData->pJPEGrow2, pData->iJPEGrowlen2); - - /* 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->pJPEGdinfo2); - - pData->bJPEGdecompress2 = 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 && MNG_INCLUDE_DISPLAY_PROCS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/plugins/AdvaImg/src/LibMNG/libmng_jpeg.h b/plugins/AdvaImg/src/LibMNG/libmng_jpeg.h deleted file mode 100644 index ef9dbf204d..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_jpeg.h +++ /dev/null @@ -1,57 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_jpeg.h copyright (c) 2000-2002 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : JPEG library interface (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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 * */ -/* * * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added support for JDAA * */ -/* * * */ -/* ************************************************************************** */ - -#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); - -mng_retcode mngjpeg_decompressinit2 (mng_datap pData); -mng_retcode mngjpeg_decompressdata2 (mng_datap pData, - mng_uint32 iRawsize, - mng_uint8p pRawdata); -mng_retcode mngjpeg_decompressfree2 (mng_datap pData); - -/* ************************************************************************** */ - -#endif /* _libmng_jpeg_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/plugins/AdvaImg/src/LibMNG/libmng_memory.h b/plugins/AdvaImg/src/LibMNG/libmng_memory.h deleted file mode 100644 index 9da16a460b..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_memory.h +++ /dev/null @@ -1,64 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_memory.h copyright (c) 2000-2003 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Memory management (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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_ - -/* ************************************************************************** */ -/* * * */ -/* * 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 * */ -/* ************************************************************************** */ diff --git a/plugins/AdvaImg/src/LibMNG/libmng_object_prc.c b/plugins/AdvaImg/src/LibMNG/libmng_object_prc.c deleted file mode 100644 index 570d346aa6..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_object_prc.c +++ /dev/null @@ -1,6998 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_object_prc.c copyright (c) 2000-2007 G.Juyn * */ -/* * version : 1.0.10 * */ -/* * * */ -/* * purpose : Object processing routines (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * comment : implementation of the internal object processing routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * * */ -/* * 0.5.2 - 05/20/2000 - G.Juyn * */ -/* * - fixed to support JNG objects * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - added support for global color-chunks in animation * */ -/* * - added support for global PLTE,tRNS,bKGD in animation * */ -/* * - added SAVE & SEEK animation objects * */ -/* * 0.5.2 - 05/29/2000 - G.Juyn * */ -/* * - added initialization of framenr/layernr/playtime * */ -/* * - changed ani_object create routines not to return the * */ -/* * created object (wasn't necessary) * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added object promotion routine (PROM handling) * */ -/* * - added ani-object routines for delta-image processing * */ -/* * - added compression/filter/interlace fields to * */ -/* * object-buffer for delta-image processing * */ -/* * * */ -/* * 0.5.3 - 06/17/2000 - G.Juyn * */ -/* * - changed support for delta-image processing * */ -/* * 0.5.3 - 06/20/2000 - G.Juyn * */ -/* * - fixed some small things (as precaution) * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added processing of PLTE/tRNS & color-info for * */ -/* * delta-images in the ani_objects chain * */ -/* * 0.5.3 - 06/22/2000 - G.Juyn * */ -/* * - added support for PPLT chunk * */ -/* * * */ -/* * 0.9.1 - 07/07/2000 - G.Juyn * */ -/* * - added support for freeze/restart/resume & go_xxxx * */ -/* * 0.9.1 - 07/16/2000 - G.Juyn * */ -/* * - fixed support for mng_display() after mng_read() * */ -/* * * */ -/* * 0.9.2 - 07/29/2000 - G.Juyn * */ -/* * - fixed small bugs in display processing * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/07/2000 - G.Juyn * */ -/* * - B111300 - fixup for improved portability * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/10/2000 - G.Juyn * */ -/* * - fixed DEFI behavior * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added valid-flag to stored objects for read() / display()* */ -/* * - added routine to discard "invalid" objects * */ -/* * 0.9.3 - 10/18/2000 - G.Juyn * */ -/* * - fixed delta-processing behavior * */ -/* * 0.9.3 - 10/19/2000 - G.Juyn * */ -/* * - added storage for pixel-/alpha-sampledepth for delta's * */ -/* * * */ -/* * 0.9.4 - 1/18/2001 - G.Juyn * */ -/* * - removed "old" MAGN methods 3 & 4 * */ -/* * - added "new" MAGN methods 3, 4 & 5 * */ -/* * * */ -/* * 0.9.5 - 1/22/2001 - G.Juyn * */ -/* * - B129681 - fixed compiler warnings SGI/Irix * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added optimization option for MNG-video playback * */ -/* * * */ -/* * 1.0.5 - 08/15/2002 - G.Juyn * */ -/* * - completed PROM support * */ -/* * 1.0.5 - 08/16/2002 - G.Juyn * */ -/* * - completed MAGN support (16-bit functions) * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * 1.0.5 - 09/13/2002 - G.Juyn * */ -/* * - fixed read/write of MAGN chunk * */ -/* * 1.0.5 - 09/15/2002 - G.Juyn * */ -/* * - added event handling for dynamic MNG * */ -/* * 1.0.5 - 09/20/2002 - G.Juyn * */ -/* * - added support for PAST * */ -/* * 1.0.5 - 09/23/2002 - G.Juyn * */ -/* * - fixed reset_object_detail to clear old buffer * */ -/* * - added in-memory color-correction of abstract images * */ -/* * 1.0.5 - 10/05/2002 - G.Juyn * */ -/* * - fixed problem with cloned objects marked as invalid * */ -/* * - fixed problem cloning frozen object_buffers * */ -/* * 1.0.5 - 10/07/2002 - G.Juyn * */ -/* * - fixed DISC support * */ -/* * 1.0.5 - 11/04/2002 - G.Juyn * */ -/* * - fixed goframe/golayer/gotime processing * */ -/* * 1.0.5 - 11/07/2002 - G.Juyn * */ -/* * - fixed magnification bug with object 0 * */ -/* * 1.0.5 - 01/19/2003 - G.Juyn * */ -/* * - B664911 - fixed buffer overflow during init * */ -/* * * */ -/* * 1.0.6 - 04/19/2003 - G.Juyn * */ -/* * - fixed problem with infinite loops during readdisplay() * */ -/* * 1.0.6 - 05/25/2003 - G.R-P * */ -/* * - added MNG_SKIPCHUNK_cHNK footprint optimizations * */ -/* * 1.0.6 - 06/09/2003 - G. R-P * */ -/* * - added conditionals around 8-bit magn routines * */ -/* * 1.0.6 - 07/07/2003 - G.R-P * */ -/* * - added conditionals around some JNG-supporting code * */ -/* * - removed conditionals around 8-bit magn routines * */ -/* * - added conditionals around delta-png and 16-bit code * */ -/* * 1.0.6 - 07/14/2003 - G.R-P * */ -/* * - added MNG_NO_LOOP_SIGNALS_SUPPORTED conditional * */ -/* * 1.0.6 - 07/29/2003 - G.Juyn * */ -/* * - fixed invalid test in promote_imageobject * */ -/* * 1.0.6 - 07/29/2003 - G.R-P. * */ -/* * - added conditionals around PAST chunk support * */ -/* * 1.0.6 - 08/17/2003 - G.R-P. * */ -/* * - added conditionals around MAGN chunk support * */ -/* * * */ -/* * 1.0.7 - 03/21/2004 - G.Juyn * */ -/* * - fixed some 64-bit platform compiler warnings * */ -/* * * */ -/* * 1.0.9 - 10/10/2004 - G.R-P. * */ -/* * - added MNG_NO_1_2_4BIT_SUPPORT support * */ -/* * 1.0.9 - 12/05/2004 - G.Juyn * */ -/* * - added conditional MNG_OPTIMIZE_OBJCLEANUP * */ -/* * 1.0.9 - 12/11/2004 - G.Juyn * */ -/* * - added conditional MNG_OPTIMIZE_DISPLAYCALLS * */ -/* * 1.0.9 - 12/31/2004 - G.R-P. * */ -/* * - fixed warnings about possible uninitialized pointers * */ -/* * 1.0.9 - 01/02/2005 - G.Juyn * */ -/* * - fixing some compiler-warnings * */ -/* * * */ -/* * 1.0.10 - 02/07/2005 - G.Juyn * */ -/* * - fixed some compiler-warnings * */ -/* * 1.0.10 - 07/30/2005 - G.Juyn * */ -/* * - fixed problem with CLON object during readdisplay() * */ -/* * 1.0.10 - 04/08/2007 - G.Juyn * */ -/* * - added support for mPNG proposal * */ -/* * 1.0.10 - 04/12/2007 - G.Juyn * */ -/* * - added support for ANG proposal * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_memory.h" -#include "libmng_chunks.h" -#include "libmng_objects.h" -#include "libmng_display.h" -#include "libmng_pixels.h" -#include "libmng_object_prc.h" -#include "libmng_cms.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_DISPLAY_PROCS - -/* ************************************************************************** */ -/* * * */ -/* * Generic object routines * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode mng_drop_invalid_objects (mng_datap pData) -{ - mng_objectp pObject; - mng_objectp pNext; - mng_cleanupobject fCleanup; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DROP_INVALID_OBJECTS, MNG_LC_START); -#endif - - pObject = pData->pFirstimgobj; /* get first stored image-object (if any) */ - - while (pObject) /* more objects to check ? */ - { - pNext = ((mng_object_headerp)pObject)->pNext; - /* invalid ? */ - if (!((mng_imagep)pObject)->bValid) - { /* call appropriate cleanup */ - fCleanup = ((mng_object_headerp)pObject)->fCleanup; - fCleanup (pData, pObject); - } - - pObject = pNext; /* neeeext */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DROP_INVALID_OBJECTS, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifdef MNG_OPTIMIZE_OBJCLEANUP -MNG_LOCAL mng_retcode create_obj_general (mng_datap pData, - mng_size_t iObjsize, - mng_cleanupobject fCleanup, - mng_processobject fProcess, - mng_ptr *ppObject) -{ - mng_object_headerp pWork; - - MNG_ALLOC (pData, pWork, iObjsize); - - pWork->fCleanup = fCleanup; - pWork->fProcess = fProcess; - pWork->iObjsize = iObjsize; - *ppObject = (mng_ptr)pWork; - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -MNG_LOCAL mng_retcode mng_free_obj_general (mng_datap pData, - mng_objectp pObject) -{ - MNG_FREEX (pData, pObject, ((mng_object_headerp)pObject)->iObjsize); - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Image-data-object routines * */ -/* * * */ -/* * these handle the "object buffer" as defined by the MNG specification * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode mng_create_imagedataobject (mng_datap pData, - mng_bool bConcrete, - mng_bool bViewable, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_imagedatap *ppObject) -{ - mng_imagedatap pImagedata; - mng_uint32 iSamplesize = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_IMGDATAOBJECT, MNG_LC_START); -#endif - /* get a buffer */ -#ifdef MNG_OPTIMIZE_OBJCLEANUP - { - mng_ptr pTemp; - mng_retcode iRetcode = create_obj_general (pData, sizeof (mng_imagedata), - (mng_cleanupobject)mng_free_imagedataobject, - MNG_NULL, &pTemp); - if (iRetcode) - return iRetcode; - pImagedata = (mng_imagedatap)pTemp; - } -#else - MNG_ALLOC (pData, pImagedata, sizeof (mng_imagedata)); - /* fill the appropriate fields */ - pImagedata->sHeader.fCleanup = (mng_cleanupobject)mng_free_imagedataobject; - pImagedata->sHeader.fProcess = MNG_NULL; -#endif - pImagedata->iRefcount = 1; - pImagedata->bFrozen = MNG_FALSE; - pImagedata->bConcrete = bConcrete; - pImagedata->bViewable = bViewable; - pImagedata->iWidth = iWidth; - pImagedata->iHeight = iHeight; - pImagedata->iBitdepth = iBitdepth; - pImagedata->iColortype = iColortype; - pImagedata->iCompression = iCompression; - pImagedata->iFilter = iFilter; - pImagedata->iInterlace = iInterlace; - pImagedata->bCorrected = MNG_FALSE; - pImagedata->iAlphabitdepth = 0; - pImagedata->iJHDRcompression = 0; - pImagedata->iJHDRinterlace = 0; - pImagedata->iPixelsampledepth = iBitdepth; - pImagedata->iAlphasampledepth = iBitdepth; - /* determine samplesize from color_type/bit_depth */ - switch (iColortype) /* for < 8-bit samples we just reserve 8 bits */ - { - case 0 : ; /* gray */ - case 8 : { /* JPEG gray */ -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth > 8) - iSamplesize = 2; - else -#endif - iSamplesize = 1; - - break; - } - case 2 : ; /* rgb */ - case 10 : { /* JPEG rgb */ -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth > 8) - iSamplesize = 6; - else -#endif - iSamplesize = 3; - - break; - } - case 3 : { /* indexed */ - iSamplesize = 1; - break; - } - case 4 : ; /* gray+alpha */ - case 12 : { /* JPEG gray+alpha */ -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth > 8) - iSamplesize = 4; - else -#endif - iSamplesize = 2; - - break; - } - case 6 : ; /* rgb+alpha */ - case 14 : { /* JPEG rgb+alpha */ -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth > 8) - iSamplesize = 8; - else -#endif - iSamplesize = 4; - - break; - } - } - /* make sure we remember all this */ - pImagedata->iSamplesize = iSamplesize; - pImagedata->iRowsize = iSamplesize * iWidth; - pImagedata->iImgdatasize = pImagedata->iRowsize * iHeight; - - if (pImagedata->iImgdatasize) /* need a buffer ? */ - { /* so allocate it */ - MNG_ALLOCX (pData, pImagedata->pImgdata, pImagedata->iImgdatasize); - - if (!pImagedata->pImgdata) /* enough memory ? */ - { - MNG_FREEX (pData, pImagedata, sizeof (mng_imagedata)); - MNG_ERROR (pData, MNG_OUTOFMEMORY); - } - } - /* check global stuff */ - pImagedata->bHasGAMA = pData->bHasglobalGAMA; -#ifndef MNG_SKIPCHUNK_cHRM - pImagedata->bHasCHRM = pData->bHasglobalCHRM; -#endif - pImagedata->bHasSRGB = pData->bHasglobalSRGB; -#ifndef MNG_SKIPCHUNK_iCCP - pImagedata->bHasICCP = pData->bHasglobalICCP; -#endif -#ifndef MNG_SKIPCHUNK_bKGD - pImagedata->bHasBKGD = pData->bHasglobalBKGD; -#endif - - if (pData->bHasglobalGAMA) /* global gAMA present ? */ - pImagedata->iGamma = pData->iGlobalGamma; - -#ifndef MNG_SKIPCHUNK_cHRM - if (pData->bHasglobalCHRM) /* global cHRM present ? */ - { - pImagedata->iWhitepointx = pData->iGlobalWhitepointx; - pImagedata->iWhitepointy = pData->iGlobalWhitepointy; - pImagedata->iPrimaryredx = pData->iGlobalPrimaryredx; - pImagedata->iPrimaryredy = pData->iGlobalPrimaryredy; - pImagedata->iPrimarygreenx = pData->iGlobalPrimarygreenx; - pImagedata->iPrimarygreeny = pData->iGlobalPrimarygreeny; - pImagedata->iPrimarybluex = pData->iGlobalPrimarybluex; - pImagedata->iPrimarybluey = pData->iGlobalPrimarybluey; - } -#endif - - if (pData->bHasglobalSRGB) /* glbal sRGB present ? */ - pImagedata->iRenderingintent = pData->iGlobalRendintent; - -#ifndef MNG_SKIPCHUNK_iCCP - if (pData->bHasglobalICCP) /* glbal iCCP present ? */ - { - pImagedata->iProfilesize = pData->iGlobalProfilesize; - - if (pImagedata->iProfilesize) - { - MNG_ALLOCX (pData, pImagedata->pProfile, pImagedata->iProfilesize); - - if (!pImagedata->pProfile) /* enough memory ? */ - { - MNG_FREEX (pData, pImagedata->pImgdata, pImagedata->iImgdatasize); - MNG_FREEX (pData, pImagedata, sizeof (mng_imagedata)); - MNG_ERROR (pData, MNG_OUTOFMEMORY); - } - - MNG_COPY (pImagedata->pProfile, pData->pGlobalProfile, pImagedata->iProfilesize); - } - } -#endif - -#ifndef MNG_SKIPCHUNK_bKGD - if (pData->bHasglobalBKGD) /* global bKGD present ? */ - { - pImagedata->iBKGDred = pData->iGlobalBKGDred; - pImagedata->iBKGDgreen = pData->iGlobalBKGDgreen; - pImagedata->iBKGDblue = pData->iGlobalBKGDblue; - } -#endif - - *ppObject = pImagedata; /* return it */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_IMGDATAOBJECT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_free_imagedataobject (mng_datap pData, - mng_imagedatap pImagedata) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IMGDATAOBJECT, MNG_LC_START); -#endif - - if (pImagedata->iRefcount) /* decrease reference count */ - pImagedata->iRefcount--; - - if (!pImagedata->iRefcount) /* reached zero ? */ - { -#ifndef MNG_SKIPCHUNK_iCCP - if (pImagedata->iProfilesize) /* stored an iCCP profile ? */ - MNG_FREEX (pData, pImagedata->pProfile, pImagedata->iProfilesize); -#endif - if (pImagedata->iImgdatasize) /* sample-buffer present ? */ - MNG_FREEX (pData, pImagedata->pImgdata, pImagedata->iImgdatasize); - /* drop the buffer */ - MNG_FREEX (pData, pImagedata, sizeof (mng_imagedata)); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IMGDATAOBJECT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_clone_imagedataobject (mng_datap pData, - mng_bool bConcrete, - mng_imagedatap pSource, - mng_imagedatap *ppClone) -{ - mng_imagedatap pNewdata; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLONE_IMGDATAOBJECT, MNG_LC_START); -#endif - /* get a buffer */ - MNG_ALLOC (pData, pNewdata, sizeof (mng_imagedata)); - /* blatently copy the original buffer */ - MNG_COPY (pNewdata, pSource, sizeof (mng_imagedata)); - - pNewdata->iRefcount = 1; /* only the reference count */ - pNewdata->bConcrete = bConcrete; /* and concrete-flag are different */ - pNewdata->bFrozen = MNG_FALSE; - - if (pNewdata->iImgdatasize) /* sample buffer present ? */ - { - MNG_ALLOCX (pData, pNewdata->pImgdata, pNewdata->iImgdatasize); - - if (!pNewdata->pImgdata) /* not enough memory ? */ - { - MNG_FREEX (pData, pNewdata, sizeof (mng_imagedata)); - MNG_ERROR (pData, MNG_OUTOFMEMORY); - } - /* make a copy */ - MNG_COPY (pNewdata->pImgdata, pSource->pImgdata, pNewdata->iImgdatasize); - } - -#ifndef MNG_SKIPCHUNK_iCCP - if (pNewdata->iProfilesize) /* iCCP profile present ? */ - { - MNG_ALLOCX (pData, pNewdata->pProfile, pNewdata->iProfilesize); - - if (!pNewdata->pProfile) /* enough memory ? */ - { - MNG_FREEX (pData, pNewdata, sizeof (mng_imagedata)); - MNG_ERROR (pData, MNG_OUTOFMEMORY); - } - /* make a copy */ - MNG_COPY (pNewdata->pProfile, pSource->pProfile, pNewdata->iProfilesize); - } -#endif - - *ppClone = pNewdata; /* return the clone */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLONE_IMGDATAOBJECT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Image-object routines * */ -/* * * */ -/* * these handle the "object" as defined by the MNG specification * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode mng_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_imagep pImage; - mng_imagep pPrev, pNext; - mng_retcode iRetcode; - mng_imagedatap pImgbuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_IMGOBJECT, MNG_LC_START); -#endif - /* get a buffer */ - MNG_ALLOC (pData, pImage, sizeof (mng_image)); - /* now get a new "object buffer" */ - iRetcode = mng_create_imagedataobject (pData, bConcrete, bViewable, - iWidth, iHeight, iBitdepth, iColortype, - iCompression, iFilter, iInterlace, - &pImgbuf); - - if (iRetcode) /* on error bail out */ - { - MNG_FREEX (pData, pImage, sizeof (mng_image)); - return iRetcode; - } - /* fill the appropriate fields */ - pImage->sHeader.fCleanup = (mng_cleanupobject)mng_free_imageobject; - pImage->sHeader.fProcess = MNG_NULL; -#ifdef MNG_OPTIMIZE_OBJCLEANUP - pImage->sHeader.iObjsize = sizeof (mng_image); -#endif - pImage->iId = iId; - pImage->bFrozen = MNG_FALSE; - pImage->bVisible = bVisible; - pImage->bViewable = bViewable; - pImage->bValid = (mng_bool)((pData->bDisplaying) && - ((pData->bRunning) || (pData->bSearching)) && - (!pData->bFreezing)); - pImage->iPosx = iPosx; - pImage->iPosy = iPosy; - pImage->bClipped = bClipped; - pImage->iClipl = iClipl; - pImage->iClipr = iClipr; - pImage->iClipt = iClipt; - pImage->iClipb = iClipb; -#ifndef MNG_SKIPCHUNK_MAGN - pImage->iMAGN_MethodX = 0; - pImage->iMAGN_MethodY = 0; - pImage->iMAGN_MX = 0; - pImage->iMAGN_MY = 0; - pImage->iMAGN_ML = 0; - pImage->iMAGN_MR = 0; - pImage->iMAGN_MT = 0; - pImage->iMAGN_MB = 0; -#endif -#ifndef MNG_SKIPCHUNK_PAST - pImage->iPastx = 0; - pImage->iPasty = 0; -#endif - pImage->pImgbuf = pImgbuf; - - if (iId) /* only if not object 0 ! */ - { /* find previous lower object-id */ - pPrev = (mng_imagep)pData->pLastimgobj; - - while ((pPrev) && (pPrev->iId > iId)) - pPrev = (mng_imagep)pPrev->sHeader.pPrev; - - if (pPrev) /* found it ? */ - { - pImage->sHeader.pPrev = pPrev; /* than link it in place */ - pImage->sHeader.pNext = pPrev->sHeader.pNext; - pPrev->sHeader.pNext = pImage; - } - else /* if not found, it becomes the first ! */ - { - pImage->sHeader.pNext = pData->pFirstimgobj; - pData->pFirstimgobj = pImage; - } - - pNext = (mng_imagep)pImage->sHeader.pNext; - - if (pNext) - pNext->sHeader.pPrev = pImage; - else - pData->pLastimgobj = pImage; - - } - - *ppObject = pImage; /* and return the new buffer */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_IMGOBJECT, MNG_LC_END); -#endif - - return MNG_NOERROR; /* okido */ -} - -/* ************************************************************************** */ - -mng_retcode mng_free_imageobject (mng_datap pData, - mng_imagep pImage) -{ - mng_retcode iRetcode; - mng_imagep pPrev = pImage->sHeader.pPrev; - mng_imagep pNext = pImage->sHeader.pNext; - mng_imagedatap pImgbuf = pImage->pImgbuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IMGOBJECT, MNG_LC_START); -#endif - - if (pImage->iId) /* not for object 0 */ - { - if (pPrev) /* unlink from the list first ! */ - pPrev->sHeader.pNext = pImage->sHeader.pNext; - else - pData->pFirstimgobj = pImage->sHeader.pNext; - - if (pNext) - pNext->sHeader.pPrev = pImage->sHeader.pPrev; - else - pData->pLastimgobj = pImage->sHeader.pPrev; - - } - /* unlink the image-data buffer */ - iRetcode = mng_free_imagedataobject (pData, pImgbuf); - /* drop its own buffer */ - MNG_FREEX (pData, pImage, sizeof (mng_image)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IMGOBJECT, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -mng_imagep mng_find_imageobject (mng_datap pData, - mng_uint16 iId) -{ - mng_imagep pImage = (mng_imagep)pData->pFirstimgobj; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (pData, MNG_FN_FIND_IMGOBJECT, MNG_LC_START); -#endif - /* look up the right id */ - while ((pImage) && (pImage->iId != iId)) - pImage = (mng_imagep)pImage->sHeader.pNext; - -#ifdef MNG_INCLUDE_MPNG_PROPOSAL - if ((!pImage) && (pData->eImagetype == mng_it_mpng)) - pImage = pData->pObjzero; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (pData, MNG_FN_FIND_IMGOBJECT, MNG_LC_END); -#endif - - return pImage; -} - -/* ************************************************************************** */ - -mng_retcode mng_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_imagep pNew; - mng_imagep pPrev, pNext; - mng_retcode iRetcode; - mng_imagedatap pImgbuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLONE_IMGOBJECT, MNG_LC_START); -#endif - -#ifndef MNG_SKIPCHUNK_MAGN - if ((pSource->iId) && /* needs magnification ? */ - ((pSource->iMAGN_MethodX) || (pSource->iMAGN_MethodY))) - { - iRetcode = mng_magnify_imageobject (pData, pSource); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif - /* get a buffer */ -#ifdef MNG_OPTIMIZE_OBJCLEANUP - { - mng_ptr pTemp; - mng_retcode iRetcode = create_obj_general (pData, sizeof (mng_image), - (mng_cleanupobject)mng_free_imageobject, - MNG_NULL, &pTemp); - if (iRetcode) - return iRetcode; - pNew = (mng_imagep)pTemp; - } -#else - MNG_ALLOC (pData, pNew, sizeof (mng_image)); - /* fill or copy the appropriate fields */ - pNew->sHeader.fCleanup = (mng_cleanupobject)mng_free_imageobject; - pNew->sHeader.fProcess = MNG_NULL; -#endif - pNew->iId = iId; - pNew->bFrozen = MNG_FALSE; - pNew->bVisible = bVisible; - pNew->bViewable = pSource->bViewable; - pNew->bValid = MNG_TRUE; - - if (bHasloca) /* location info available ? */ - { - if (iLocationtype == 0) /* absolute position ? */ - { - pNew->iPosx = iLocationx; - pNew->iPosy = iLocationy; - } - else /* relative */ - { - pNew->iPosx = pSource->iPosx + iLocationx; - pNew->iPosy = pSource->iPosy + iLocationy; - } - } - else /* copy from source */ - { - pNew->iPosx = pSource->iPosx; - pNew->iPosy = pSource->iPosy; - } - /* copy clipping info */ - pNew->bClipped = pSource->bClipped; - pNew->iClipl = pSource->iClipl; - pNew->iClipr = pSource->iClipr; - pNew->iClipt = pSource->iClipt; - pNew->iClipb = pSource->iClipb; -#ifndef MNG_SKIPCHUNK_MAGN - /* copy magnification info */ -/* pNew->iMAGN_MethodX = pSource->iMAGN_MethodX; LET'S NOT !!!!!! - pNew->iMAGN_MethodY = pSource->iMAGN_MethodY; - pNew->iMAGN_MX = pSource->iMAGN_MX; - pNew->iMAGN_MY = pSource->iMAGN_MY; - pNew->iMAGN_ML = pSource->iMAGN_ML; - pNew->iMAGN_MR = pSource->iMAGN_MR; - pNew->iMAGN_MT = pSource->iMAGN_MT; - pNew->iMAGN_MB = pSource->iMAGN_MB; */ -#endif - -#ifndef MNG_SKIPCHUNK_PAST - pNew->iPastx = 0; /* initialize PAST info */ - pNew->iPasty = 0; -#endif - - if (iId) /* not for object 0 */ - { /* find previous lower object-id */ - pPrev = (mng_imagep)pData->pLastimgobj; - while ((pPrev) && (pPrev->iId > iId)) - pPrev = (mng_imagep)pPrev->sHeader.pPrev; - - if (pPrev) /* found it ? */ - { - pNew->sHeader.pPrev = pPrev; /* than link it in place */ - pNew->sHeader.pNext = pPrev->sHeader.pNext; - pPrev->sHeader.pNext = pNew; - } - else /* if not found, it becomes the first ! */ - { - pNew->sHeader.pNext = pData->pFirstimgobj; - pData->pFirstimgobj = pNew; - } - - pNext = (mng_imagep)pNew->sHeader.pNext; - - if (pNext) - pNext->sHeader.pPrev = pNew; - else - pData->pLastimgobj = pNew; - - } - - if (bPartial) /* partial clone ? */ - { - pNew->pImgbuf = pSource->pImgbuf; /* use the same object buffer */ - pNew->pImgbuf->iRefcount++; /* and increase the reference count */ - } - else /* create a full clone ! */ - { - mng_bool bConcrete = MNG_FALSE; /* it's abstract by default (?) */ - - if (!bAbstract) /* determine concreteness from source ? */ - bConcrete = pSource->pImgbuf->bConcrete; - /* create a full clone ! */ - iRetcode = mng_clone_imagedataobject (pData, bConcrete, pSource->pImgbuf, &pImgbuf); - - if (iRetcode) /* on error bail out */ - { - MNG_FREEX (pData, pNew, sizeof (mng_image)); - return iRetcode; - } - - pNew->pImgbuf = pImgbuf; /* and remember it */ - } - - *ppClone = pNew; /* return it */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLONE_IMGOBJECT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_renum_imageobject (mng_datap pData, - mng_imagep pSource, - mng_uint16 iId, - mng_bool bVisible, - mng_bool bAbstract, - mng_bool bHasloca, - mng_uint8 iLocationtype, - mng_int32 iLocationx, - mng_int32 iLocationy) -{ - mng_imagep pPrev, pNext; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RENUM_IMGOBJECT, MNG_LC_START); -#endif - - pSource->bVisible = bVisible; /* store the new visibility */ - - if (bHasloca) /* location info available ? */ - { - if (iLocationtype == 0) /* absolute position ? */ - { - pSource->iPosx = iLocationx; - pSource->iPosy = iLocationy; - } - else /* relative */ - { - pSource->iPosx = pSource->iPosx + iLocationx; - pSource->iPosy = pSource->iPosy + iLocationy; - } - } - - if (iId) /* not for object 0 */ - { /* find previous lower object-id */ - pPrev = (mng_imagep)pData->pLastimgobj; - while ((pPrev) && (pPrev->iId > iId)) - pPrev = (mng_imagep)pPrev->sHeader.pPrev; - /* different from current ? */ - if (pPrev != (mng_imagep)pSource->sHeader.pPrev) - { - if (pSource->sHeader.pPrev) /* unlink from current position !! */ - ((mng_imagep)pSource->sHeader.pPrev)->sHeader.pNext = pSource->sHeader.pNext; - else - pData->pFirstimgobj = pSource->sHeader.pNext; - - if (pSource->sHeader.pNext) - ((mng_imagep)pSource->sHeader.pNext)->sHeader.pPrev = pSource->sHeader.pPrev; - else - pData->pLastimgobj = pSource->sHeader.pPrev; - - if (pPrev) /* found the previous ? */ - { /* than link it in place */ - pSource->sHeader.pPrev = pPrev; - pSource->sHeader.pNext = pPrev->sHeader.pNext; - pPrev->sHeader.pNext = pSource; - } - else /* if not found, it becomes the first ! */ - { - pSource->sHeader.pNext = pData->pFirstimgobj; - pData->pFirstimgobj = pSource; - } - - pNext = (mng_imagep)pSource->sHeader.pNext; - - if (pNext) - pNext->sHeader.pPrev = pSource; - else - pData->pLastimgobj = pSource; - - } - } - - pSource->iId = iId; /* now set the new id! */ - - if (bAbstract) /* force it to abstract ? */ - pSource->pImgbuf->bConcrete = MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RENUM_IMGOBJECT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_reset_object_details (mng_datap pData, - mng_imagep pImage, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_bool bResetall) -{ - mng_imagedatap pBuf = pImage->pImgbuf; - mng_uint32 iSamplesize = 0; - mng_uint32 iRowsize; - mng_uint32 iImgdatasize; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESET_OBJECTDETAILS, MNG_LC_START); -#endif - - pBuf->iWidth = iWidth; /* set buffer characteristics */ - pBuf->iHeight = iHeight; - pBuf->iBitdepth = iBitdepth; - pBuf->iColortype = iColortype; - pBuf->iCompression = iCompression; - pBuf->iFilter = iFilter; - pBuf->iInterlace = iInterlace; - pBuf->bCorrected = MNG_FALSE; - pBuf->iAlphabitdepth = 0; - /* determine samplesize from color_type/bit_depth */ - switch (iColortype) /* for < 8-bit samples we just reserve 8 bits */ - { - case 0 : ; /* gray */ - case 8 : { /* JPEG gray */ -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth > 8) - iSamplesize = 2; - else -#endif - iSamplesize = 1; - - break; - } - case 2 : ; /* rgb */ - case 10 : { /* JPEG rgb */ -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth > 8) - iSamplesize = 6; - else -#endif - iSamplesize = 3; - - break; - } - case 3 : { /* indexed */ - iSamplesize = 1; - break; - } - case 4 : ; /* gray+alpha */ - case 12 : { /* JPEG gray+alpha */ -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth > 8) - iSamplesize = 4; - else -#endif - iSamplesize = 2; - - break; - } - case 6 : ; /* rgb+alpha */ - case 14 : { /* JPEG rgb+alpha */ -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth > 8) - iSamplesize = 8; - else -#endif - iSamplesize = 4; - - break; - } - } - - iRowsize = iSamplesize * iWidth; - iImgdatasize = iRowsize * iHeight; - /* buffer size changed ? */ - if (iImgdatasize != pBuf->iImgdatasize) - { /* drop the old one */ - MNG_FREE (pData, pBuf->pImgdata, pBuf->iImgdatasize); - - if (iImgdatasize) /* allocate new sample-buffer ? */ - MNG_ALLOC (pData, pBuf->pImgdata, iImgdatasize); - } - else - { - if (iImgdatasize) /* clear old buffer */ - { - mng_uint8p pTemp = pBuf->pImgdata; - mng_uint32 iX; - - for (iX = 0; iX < (iImgdatasize & (mng_uint32)(~3L)); iX += 4) - { - *((mng_uint32p)pTemp) = 0x00000000l; - pTemp += 4; - } - - while (pTemp < (pBuf->pImgdata + iImgdatasize)) - { - *pTemp = 0; - pTemp++; - } - } - } - - pBuf->iSamplesize = iSamplesize; /* remember new sizes */ - pBuf->iRowsize = iRowsize; - pBuf->iImgdatasize = iImgdatasize; - - if (!pBuf->iPixelsampledepth) /* set delta sampledepths if empty */ - pBuf->iPixelsampledepth = iBitdepth; - if (!pBuf->iAlphasampledepth) - pBuf->iAlphasampledepth = iBitdepth; - /* dimension set and clipping not ? */ - if ((iWidth) && (iHeight) && (!pImage->bClipped)) - { - pImage->iClipl = 0; /* set clipping to dimension by default */ - pImage->iClipr = iWidth; - pImage->iClipt = 0; - pImage->iClipb = iHeight; - } - -#ifndef MNG_SKIPCHUNK_MAGN - if (pImage->iId) /* reset magnification info ? */ - { - pImage->iMAGN_MethodX = 0; - pImage->iMAGN_MethodY = 0; - pImage->iMAGN_MX = 0; - pImage->iMAGN_MY = 0; - pImage->iMAGN_ML = 0; - pImage->iMAGN_MR = 0; - pImage->iMAGN_MT = 0; - pImage->iMAGN_MB = 0; - } -#endif - - if (bResetall) /* reset the other characteristics ? */ - { -#ifndef MNG_SKIPCHUNK_PAST - pImage->iPastx = 0; - pImage->iPasty = 0; -#endif - - pBuf->bHasPLTE = MNG_FALSE; - pBuf->bHasTRNS = MNG_FALSE; - pBuf->bHasGAMA = pData->bHasglobalGAMA; -#ifndef MNG_SKIPCHUNK_cHRM - pBuf->bHasCHRM = pData->bHasglobalCHRM; -#endif - pBuf->bHasSRGB = pData->bHasglobalSRGB; -#ifndef MNG_SKIPCHUNK_iCCP - pBuf->bHasICCP = pData->bHasglobalICCP; -#endif -#ifndef MNG_SKIPCHUNK_bKGD - pBuf->bHasBKGD = pData->bHasglobalBKGD; -#endif - -#ifndef MNG_SKIPCHUNK_iCCP - if (pBuf->iProfilesize) /* drop possibly old ICC profile */ - { - MNG_FREE (pData, pBuf->pProfile, pBuf->iProfilesize); - pBuf->iProfilesize = 0; - } -#endif - - if (pData->bHasglobalGAMA) /* global gAMA present ? */ - pBuf->iGamma = pData->iGlobalGamma; - -#ifndef MNG_SKIPCHUNK_cHRM - if (pData->bHasglobalCHRM) /* global cHRM present ? */ - { - pBuf->iWhitepointx = pData->iGlobalWhitepointx; - pBuf->iWhitepointy = pData->iGlobalWhitepointy; - pBuf->iPrimaryredx = pData->iGlobalPrimaryredx; - pBuf->iPrimaryredy = pData->iGlobalPrimaryredy; - pBuf->iPrimarygreenx = pData->iGlobalPrimarygreenx; - pBuf->iPrimarygreeny = pData->iGlobalPrimarygreeny; - pBuf->iPrimarybluex = pData->iGlobalPrimarybluex; - pBuf->iPrimarybluey = pData->iGlobalPrimarybluey; - } -#endif - - if (pData->bHasglobalSRGB) /* global sRGB present ? */ - pBuf->iRenderingintent = pData->iGlobalRendintent; - -#ifndef MNG_SKIPCHUNK_iCCP - if (pData->bHasglobalICCP) /* global iCCP present ? */ - { - if (pData->iGlobalProfilesize) - { - MNG_ALLOC (pData, pBuf->pProfile, pData->iGlobalProfilesize); - MNG_COPY (pBuf->pProfile, pData->pGlobalProfile, pData->iGlobalProfilesize); - } - - pBuf->iProfilesize = pData->iGlobalProfilesize; - } -#endif - -#ifndef MNG_SKIPCHUNK_bKGD - if (pData->bHasglobalBKGD) /* global bKGD present ? */ - { - pBuf->iBKGDred = pData->iGlobalBKGDred; - pBuf->iBKGDgreen = pData->iGlobalBKGDgreen; - pBuf->iBKGDblue = pData->iGlobalBKGDblue; - } -#endif - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESET_OBJECTDETAILS, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#if !defined(MNG_NO_DELTA_PNG) || !defined(MNG_SKIPCHUNK_PAST) || !defined(MNG_SKIPCHUNK_MAGN) -mng_retcode mng_promote_imageobject (mng_datap pData, - mng_imagep pImage, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iFilltype) -{ - mng_retcode iRetcode = MNG_NOERROR; - mng_imagedatap pBuf = pImage->pImgbuf; - mng_uint32 iW = pBuf->iWidth; - mng_uint32 iH = pBuf->iHeight; - mng_uint8p pNewbuf; - mng_uint32 iNewbufsize; - mng_uint32 iNewrowsize; - mng_uint32 iNewsamplesize = pBuf->iSamplesize; - mng_uint32 iY; - mng_uint8 iTempdepth; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_IMGOBJECT, MNG_LC_START); -#endif - -#ifdef MNG_NO_1_2_4BIT_SUPPORT - if (iBitdepth < 8) - iBitdepth=8; - if (pBuf->iBitdepth < 8) - pBuf->iBitdepth=8; -#endif -#ifdef MNG_NO_16BIT_SUPPORT - if (iBitdepth > 8) - iBitdepth=8; - if (pBuf->iBitdepth > 8) - pBuf->iBitdepth=8; -#endif - - pData->fPromoterow = MNG_NULL; /* init promotion fields */ - pData->fPromBitdepth = MNG_NULL; - pData->iPromColortype = iColortype; - pData->iPromBitdepth = iBitdepth; - pData->iPromFilltype = iFilltype; - - if (iBitdepth != pBuf->iBitdepth) /* determine bitdepth promotion */ - { - if (pBuf->iColortype == MNG_COLORTYPE_INDEXED) - iTempdepth = 8; - else - iTempdepth = pBuf->iBitdepth; - -#ifndef MNG_NO_DELTA_PNG - if (iFilltype == MNG_FILLMETHOD_ZEROFILL) - { - switch (iTempdepth) - { -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case 1 : { - switch (iBitdepth) - { - case 2 : { pData->fPromBitdepth = (mng_fptr)mng_promote_zerofill_1_2; break; } - case 4 : { pData->fPromBitdepth = (mng_fptr)mng_promote_zerofill_1_4; break; } - case 8 : { pData->fPromBitdepth = (mng_fptr)mng_promote_zerofill_1_8; break; } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { pData->fPromBitdepth = (mng_fptr)mng_promote_zerofill_1_16; break; } -#endif - } - break; - } - case 2 : { - switch (iBitdepth) - { - case 4 : { pData->fPromBitdepth = (mng_fptr)mng_promote_zerofill_2_4; break; } - case 8 : { pData->fPromBitdepth = (mng_fptr)mng_promote_zerofill_2_8; break; } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { pData->fPromBitdepth = (mng_fptr)mng_promote_zerofill_2_16; break; } -#endif - } - break; - } - case 4 : { - switch (iBitdepth) - { - case 8 : { pData->fPromBitdepth = (mng_fptr)mng_promote_zerofill_4_8; break; } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { pData->fPromBitdepth = (mng_fptr)mng_promote_zerofill_4_16; break; } -#endif - } - break; - } -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case 8 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) - pData->fPromBitdepth = (mng_fptr)mng_promote_zerofill_8_16; -#endif - break; - } - } - } - else -#endif - { - switch (iTempdepth) - { -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case 1 : { - switch (iBitdepth) - { - case 2 : { pData->fPromBitdepth = (mng_fptr)mng_promote_replicate_1_2; break; } - case 4 : { pData->fPromBitdepth = (mng_fptr)mng_promote_replicate_1_4; break; } - case 8 : { pData->fPromBitdepth = (mng_fptr)mng_promote_replicate_1_8; break; } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { pData->fPromBitdepth = (mng_fptr)mng_promote_replicate_1_16; break; } -#endif - } - break; - } - case 2 : { - switch (iBitdepth) - { - case 4 : { pData->fPromBitdepth = (mng_fptr)mng_promote_replicate_2_4; break; } - case 8 : { pData->fPromBitdepth = (mng_fptr)mng_promote_replicate_2_8; break; } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { pData->fPromBitdepth = (mng_fptr)mng_promote_replicate_2_16; break; } -#endif - } - break; - } - case 4 : { - switch (iBitdepth) - { - case 8 : { pData->fPromBitdepth = (mng_fptr)mng_promote_replicate_4_8; break; } -#ifndef MNG_NO_16BIT_SUPPORT - case 16 : { pData->fPromBitdepth = (mng_fptr)mng_promote_replicate_4_16; break; } -#endif - } - break; - } -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case 8 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) - pData->fPromBitdepth = (mng_fptr)mng_promote_replicate_8_16; -#endif - break; - } - } - } - } - /* g -> g */ - if ((pBuf->iColortype == MNG_COLORTYPE_GRAY) && - (iColortype == MNG_COLORTYPE_GRAY)) - { - if (pBuf->iBitdepth <= 8) /* source <= 8 bits */ - { -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) - pData->fPromoterow = (mng_fptr)mng_promote_g8_g16; - else -#endif - pData->fPromoterow = (mng_fptr)mng_promote_g8_g8; - } - - iNewsamplesize = 1; - -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) /* 16-bit wide ? */ - iNewsamplesize = 2; -#endif - } - else /* g -> ga */ - if ((pBuf->iColortype == MNG_COLORTYPE_GRAY) && - (iColortype == MNG_COLORTYPE_GRAYA)) - { - if (pBuf->iBitdepth <= 8) /* source <= 8 bits */ - { -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) - pData->fPromoterow = (mng_fptr)mng_promote_g8_ga16; - else -#endif - pData->fPromoterow = (mng_fptr)mng_promote_g8_ga8; - } -#ifndef MNG_NO_16BIT_SUPPORT - else /* source = 16 bits */ - pData->fPromoterow = (mng_fptr)mng_promote_g16_ga16; -#endif - - iNewsamplesize = 2; - -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) /* 16-bit wide ? */ - iNewsamplesize = 4; -#endif - } - else /* g -> rgb */ - if ((pBuf->iColortype == MNG_COLORTYPE_GRAY) && - (iColortype == MNG_COLORTYPE_RGB)) - { - if (pBuf->iBitdepth <= 8) /* source <= 8 bits */ - { -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) - pData->fPromoterow = (mng_fptr)mng_promote_g8_rgb16; - else -#endif - pData->fPromoterow = (mng_fptr)mng_promote_g8_rgb8; - } -#ifndef MNG_NO_16BIT_SUPPORT - else /* source = 16 bits */ - pData->fPromoterow = (mng_fptr)mng_promote_g16_rgb16; -#endif - - iNewsamplesize = 3; - -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) /* 16-bit wide ? */ - iNewsamplesize = 6; -#endif - } - else /* g -> rgba */ - if ((pBuf->iColortype == MNG_COLORTYPE_GRAY) && - (iColortype == MNG_COLORTYPE_RGBA)) - { - if (pBuf->iBitdepth <= 8) /* source <= 8 bits */ - { -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) - pData->fPromoterow = (mng_fptr)mng_promote_g8_rgba16; - else -#endif - pData->fPromoterow = (mng_fptr)mng_promote_g8_rgba8; - } -#ifndef MNG_NO_16BIT_SUPPORT - else /* source = 16 bits */ - pData->fPromoterow = (mng_fptr)mng_promote_g16_rgba16; -#endif - - iNewsamplesize = 4; - -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) /* 16-bit wide ? */ - iNewsamplesize = 8; -#endif - } - else /* ga -> ga */ - if ((pBuf->iColortype == MNG_COLORTYPE_GRAYA) && - (iColortype == MNG_COLORTYPE_GRAYA)) - { - iNewsamplesize = 2; -#ifndef MNG_NO_16BIT_SUPPORT - if (pBuf->iBitdepth <= 8) /* source <= 8 bits */ - if (iBitdepth == 16) - pData->fPromoterow = (mng_fptr)mng_promote_ga8_ga16; - if (iBitdepth == 16) - iNewsamplesize = 4; -#endif - } - else /* ga -> rgba */ - if ((pBuf->iColortype == MNG_COLORTYPE_GRAYA) && - (iColortype == MNG_COLORTYPE_RGBA)) - { - if (pBuf->iBitdepth <= 8) /* source <= 8 bits */ - { -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) - pData->fPromoterow = (mng_fptr)mng_promote_ga8_rgba16; - else -#endif - pData->fPromoterow = (mng_fptr)mng_promote_ga8_rgba8; - } -#ifndef MNG_NO_16BIT_SUPPORT - else /* source = 16 bits */ - pData->fPromoterow = (mng_fptr)mng_promote_ga16_rgba16; -#endif - - iNewsamplesize = 4; - -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) /* 16-bit wide ? */ - iNewsamplesize = 8; -#endif - } - else /* rgb -> rgb */ - if ((pBuf->iColortype == MNG_COLORTYPE_RGB) && - (iColortype == MNG_COLORTYPE_RGB)) - { - iNewsamplesize = 3; -#ifndef MNG_NO_16BIT_SUPPORT - if (pBuf->iBitdepth <= 8) /* source <= 8 bits */ - if (iBitdepth == 16) - pData->fPromoterow = (mng_fptr)mng_promote_rgb8_rgb16; - if (iBitdepth == 16) - iNewsamplesize = 6; -#endif - } - else /* rgb -> rgba */ - if ((pBuf->iColortype == MNG_COLORTYPE_RGB) && - (iColortype == MNG_COLORTYPE_RGBA)) - { - if (pBuf->iBitdepth <= 8) /* source <= 8 bits */ - { -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) - pData->fPromoterow = (mng_fptr)mng_promote_rgb8_rgba16; - else -#endif - pData->fPromoterow = (mng_fptr)mng_promote_rgb8_rgba8; - } -#ifndef MNG_NO_16BIT_SUPPORT - else /* source = 16 bits */ - pData->fPromoterow = (mng_fptr)mng_promote_rgb16_rgba16; -#endif - - iNewsamplesize = 4; -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) /* 16-bit wide ? */ - iNewsamplesize = 8; -#endif - } - else /* indexed -> rgb */ - if ((pBuf->iColortype == MNG_COLORTYPE_INDEXED) && - (iColortype == MNG_COLORTYPE_RGB)) - { -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) - pData->fPromoterow = (mng_fptr)mng_promote_idx8_rgb16; - else -#endif - pData->fPromoterow = (mng_fptr)mng_promote_idx8_rgb8; - - iNewsamplesize = 3; - -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) /* 16-bit wide ? */ - iNewsamplesize = 6; -#endif - } - else /* indexed -> rgba */ - if ((pBuf->iColortype == MNG_COLORTYPE_INDEXED) && - (iColortype == MNG_COLORTYPE_RGBA)) - { -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) - pData->fPromoterow = (mng_fptr)mng_promote_idx8_rgba16; - else -#endif - pData->fPromoterow = (mng_fptr)mng_promote_idx8_rgba8; - - iNewsamplesize = 4; - -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) /* 16-bit wide ? */ - iNewsamplesize = 8; -#endif - } - else /* rgba -> rgba */ - if ((pBuf->iColortype == MNG_COLORTYPE_RGBA) && - (iColortype == MNG_COLORTYPE_RGBA)) - { - iNewsamplesize = 4; -#ifndef MNG_NO_16BIT_SUPPORT - if (pBuf->iBitdepth <= 8) /* source <= 8 bits */ - { - if (iBitdepth == 16) - pData->fPromoterow = (mng_fptr)mng_promote_rgba8_rgba16; - } - if (iBitdepth == 16) /* 16-bit wide ? */ - iNewsamplesize = 8; -#endif - } -#ifdef MNG_INCLUDE_JNG - else /* JPEG g -> g */ - if ((pBuf->iColortype == MNG_COLORTYPE_JPEGGRAY) && - (iColortype == MNG_COLORTYPE_JPEGGRAY)) - { - if (pBuf->iBitdepth <= 8) /* source <= 8 bits */ - { -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) - pData->fPromoterow = (mng_fptr)mng_promote_g8_g16; - else -#endif - pData->fPromoterow = (mng_fptr)mng_promote_g8_g8; - } - - iNewsamplesize = 1; - -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) /* 16-bit wide ? */ - iNewsamplesize = 2; -#endif - } - else /* JPEG g -> ga */ - if ((pBuf->iColortype == MNG_COLORTYPE_JPEGGRAY) && - (iColortype == MNG_COLORTYPE_JPEGGRAYA)) - { - if (pBuf->iBitdepth <= 8) /* source <= 8 bits */ - { -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) - pData->fPromoterow = (mng_fptr)mng_promote_g8_ga16; - else -#endif - pData->fPromoterow = (mng_fptr)mng_promote_g8_ga8; - } -#ifndef MNG_NO_16BIT_SUPPORT - else /* source = 16 bits */ - pData->fPromoterow = (mng_fptr)mng_promote_g16_ga16; -#endif - - iNewsamplesize = 2; - -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) /* 16-bit wide ? */ - iNewsamplesize = 4; -#endif - } - else /* JPEG g -> rgb */ - if ((pBuf->iColortype == MNG_COLORTYPE_JPEGGRAY) && - (iColortype == MNG_COLORTYPE_JPEGCOLOR)) - { - if (pBuf->iBitdepth <= 8) /* source <= 8 bits */ - { -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) - pData->fPromoterow = (mng_fptr)mng_promote_g8_rgb16; - else -#endif - pData->fPromoterow = (mng_fptr)mng_promote_g8_rgb8; - } -#ifndef MNG_NO_16BIT_SUPPORT - else /* source = 16 bits */ - pData->fPromoterow = (mng_fptr)mng_promote_g16_rgb16; -#endif - - iNewsamplesize = 3; - -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) /* 16-bit wide ? */ - iNewsamplesize = 6; -#endif - } - else /* JPEG g -> rgba */ - if ((pBuf->iColortype == MNG_COLORTYPE_JPEGGRAY) && - (iColortype == MNG_COLORTYPE_JPEGCOLORA)) - { - if (pBuf->iBitdepth <= 8) /* source <= 8 bits */ - { -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) - pData->fPromoterow = (mng_fptr)mng_promote_g8_rgba16; - else -#endif - pData->fPromoterow = (mng_fptr)mng_promote_g8_rgba8; - } -#ifndef MNG_NO_16BIT_SUPPORT - else /* source = 16 bits */ - pData->fPromoterow = (mng_fptr)mng_promote_g16_rgba16; -#endif - - iNewsamplesize = 4; - -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) /* 16-bit wide ? */ - iNewsamplesize = 8; -#endif - } - else /* JPEG ga -> ga */ - if ((pBuf->iColortype == MNG_COLORTYPE_JPEGGRAYA) && - (iColortype == MNG_COLORTYPE_JPEGGRAYA)) - { - iNewsamplesize = 2; -#ifndef MNG_NO_16BIT_SUPPORT - if (pBuf->iBitdepth <= 8) /* source <= 8 bits */ - if (iBitdepth == 16) - pData->fPromoterow = (mng_fptr)mng_promote_ga8_ga16; - if (iBitdepth == 16) - iNewsamplesize = 4; -#endif - - } - else /* JPEG ga -> rgba */ - if ((pBuf->iColortype == MNG_COLORTYPE_JPEGGRAYA) && - (iColortype == MNG_COLORTYPE_JPEGCOLORA)) - { - if (pBuf->iBitdepth <= 8) /* source <= 8 bits */ - { -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) - pData->fPromoterow = (mng_fptr)mng_promote_ga8_rgba16; - else -#endif - pData->fPromoterow = (mng_fptr)mng_promote_ga8_rgba8; - } -#ifndef MNG_NO_16BIT_SUPPORT - else /* source = 16 bits */ - pData->fPromoterow = (mng_fptr)mng_promote_ga16_rgba16; -#endif - - iNewsamplesize = 4; - -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) /* 16-bit wide ? */ - iNewsamplesize = 8; -#endif - } - else /* JPEG rgb -> rgb */ - if ((pBuf->iColortype == MNG_COLORTYPE_JPEGCOLOR) && - (iColortype == MNG_COLORTYPE_JPEGCOLOR)) - { - iNewsamplesize = 3; -#ifndef MNG_NO_16BIT_SUPPORT - if (pBuf->iBitdepth <= 8) /* source <= 8 bits */ - if (iBitdepth == 16) - pData->fPromoterow = (mng_fptr)mng_promote_rgb8_rgb16; - if (iBitdepth == 16) - iNewsamplesize = 6; -#endif - - } - else /* JPEG rgb -> rgba */ - if ((pBuf->iColortype == MNG_COLORTYPE_JPEGCOLOR) && - (iColortype == MNG_COLORTYPE_JPEGCOLORA)) - { - if (pBuf->iBitdepth <= 8) /* source <= 8 bits */ - { -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) - pData->fPromoterow = (mng_fptr)mng_promote_rgb8_rgba16; - else -#endif - pData->fPromoterow = (mng_fptr)mng_promote_rgb8_rgba8; - } -#ifndef MNG_NO_16BIT_SUPPORT - else /* source = 16 bits */ - pData->fPromoterow = (mng_fptr)mng_promote_rgb16_rgba16; -#endif - - iNewsamplesize = 4; - -#ifndef MNG_NO_16BIT_SUPPORT - if (iBitdepth == 16) /* 16-bit wide ? */ - iNewsamplesize = 8; -#endif - } - else /* JPEG rgba -> rgba */ - if ((pBuf->iColortype == MNG_COLORTYPE_JPEGCOLORA) && - (iColortype == MNG_COLORTYPE_JPEGCOLORA)) - { - iNewsamplesize = 4; -#ifndef MNG_NO_16BIT_SUPPORT - if (pBuf->iBitdepth <= 8) /* source <= 8 bits */ - if (iBitdepth == 16) - pData->fPromoterow = (mng_fptr)mng_promote_rgba8_rgba16; - if (iBitdepth == 16) - iNewsamplesize = 8; -#endif - } -#endif /* JNG */ - - /* found a proper promotion ? */ - if (pData->fPromoterow) - { - pData->pPromBuf = (mng_ptr)pBuf; - pData->iPromWidth = pBuf->iWidth; - iNewrowsize = iW * iNewsamplesize; - iNewbufsize = iH * iNewrowsize; - - MNG_ALLOC (pData, pNewbuf, iNewbufsize); - - pData->pPromSrc = (mng_ptr)pBuf->pImgdata; - pData->pPromDst = (mng_ptr)pNewbuf; - iY = 0; - - while ((!iRetcode) && (iY < iH)) - { - iRetcode = ((mng_promoterow)pData->fPromoterow) (pData); - pData->pPromSrc = (mng_uint8p)pData->pPromSrc + pBuf->iRowsize; - pData->pPromDst = (mng_uint8p)pData->pPromDst + iNewrowsize; -/* pData->pPromSrc = (mng_ptr)((mng_uint32)pData->pPromSrc + pBuf->iRowsize); */ -/* pData->pPromDst = (mng_ptr)((mng_uint32)pData->pPromDst + iNewrowsize); */ - iY++; - } - - MNG_FREEX (pData, pBuf->pImgdata, pBuf->iImgdatasize); - - pBuf->iBitdepth = iBitdepth; - pBuf->iColortype = iColortype; - pBuf->iSamplesize = iNewsamplesize; - pBuf->iRowsize = iNewrowsize; - pBuf->iImgdatasize = iNewbufsize; - pBuf->pImgdata = pNewbuf; - pBuf->bHasPLTE = MNG_FALSE; - pBuf->iPLTEcount = 0; - pBuf->bHasTRNS = MNG_FALSE; - pBuf->iTRNScount = 0; - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_IMGOBJECT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_MAGN -mng_retcode mng_magnify_imageobject (mng_datap pData, - mng_imagep pImage) -{ - mng_uint8p pNewdata; - mng_uint8p pSrcline1; - mng_uint8p pSrcline2; - mng_uint8p pTempline; - mng_uint8p pDstline; - mng_uint32 iNewrowsize; - mng_uint32 iNewsize; - mng_uint32 iY; - mng_int32 iS, iM; - mng_retcode iRetcode; - - mng_imagedatap pBuf = pImage->pImgbuf; - mng_uint32 iNewW = pBuf->iWidth; - mng_uint32 iNewH = pBuf->iHeight; - mng_magnify_x fMagnifyX = MNG_NULL; - mng_magnify_y fMagnifyY = MNG_NULL; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_IMGOBJECT, MNG_LC_START); -#endif - - if (pBuf->iColortype == MNG_COLORTYPE_INDEXED) /* indexed color ? */ - { /* concrete buffer ? */ - if ((pBuf->bConcrete) && (pImage->iId)) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE); - -#ifndef MNG_OPTIMIZE_FOOTPRINT_MAGN - if (pBuf->iTRNScount) /* with transparency ? */ - iRetcode = mng_promote_imageobject (pData, pImage, 8, 6, 0); - else - iRetcode = mng_promote_imageobject (pData, pImage, 8, 2, 0); - - if (iRetcode) /* on error bail out */ - return iRetcode; -#endif - } - -#ifdef MNG_OPTIMIZE_FOOTPRINT_MAGN - /* Promote everything to RGBA, using fill method 0 (LBR) */ - iRetcode = mng_promote_imageobject (pData, pImage, 8, 6, 0); - if (iRetcode) /* on error bail out */ - return iRetcode; -#endif - - if (pImage->iMAGN_MethodX) /* determine new width */ - { - if (pImage->iMAGN_MethodX == 1) - { - iNewW = pImage->iMAGN_ML; - if (pBuf->iWidth > 1) - iNewW = iNewW + pImage->iMAGN_MR; - if (pBuf->iWidth > 2) - iNewW = iNewW + (pBuf->iWidth - 2) * (pImage->iMAGN_MX); - } - else - { - iNewW = pBuf->iWidth + pImage->iMAGN_ML - 1; - if (pBuf->iWidth > 2) - iNewW = iNewW + pImage->iMAGN_MR - 1; - if (pBuf->iWidth > 3) - iNewW = iNewW + (pBuf->iWidth - 3) * (pImage->iMAGN_MX - 1); - } - } - - if (pImage->iMAGN_MethodY) /* determine new height */ - { - if (pImage->iMAGN_MethodY == 1) - { - iNewH = pImage->iMAGN_MT; - if (pBuf->iHeight > 1) - iNewH = iNewH + pImage->iMAGN_ML; - if (pBuf->iHeight > 2) - iNewH = iNewH + (pBuf->iHeight - 2) * (pImage->iMAGN_MY); - } - else - { - iNewH = pBuf->iHeight + pImage->iMAGN_MT - 1; - if (pBuf->iHeight > 2) - iNewH = iNewH + pImage->iMAGN_MB - 1; - if (pBuf->iHeight > 3) - iNewH = iNewH + (pBuf->iHeight - 3) * (pImage->iMAGN_MY - 1); - } - } - /* get new buffer */ - iNewrowsize = iNewW * pBuf->iSamplesize; - iNewsize = iNewH * iNewrowsize; - - MNG_ALLOC (pData, pNewdata, iNewsize); - - switch (pBuf->iColortype) /* determine magnification routines */ - { -#ifndef MNG_OPTIMIZE_FOOTPRINT_MAGN - case 0 : ; - case 8 : { - if (pBuf->iBitdepth <= 8) - { - switch (pImage->iMAGN_MethodX) - { - case 1 : { fMagnifyX = mng_magnify_g8_x1; break; } - case 2 : { fMagnifyX = mng_magnify_g8_x2; break; } - case 3 : { fMagnifyX = mng_magnify_g8_x3; break; } - case 4 : { fMagnifyX = mng_magnify_g8_x2; break; } - case 5 : { fMagnifyX = mng_magnify_g8_x3; break; } - } - - switch (pImage->iMAGN_MethodY) - { - case 1 : { fMagnifyY = mng_magnify_g8_y1; break; } - case 2 : { fMagnifyY = mng_magnify_g8_y2; break; } - case 3 : { fMagnifyY = mng_magnify_g8_y3; break; } - case 4 : { fMagnifyY = mng_magnify_g8_y2; break; } - case 5 : { fMagnifyY = mng_magnify_g8_y3; break; } - } - } -#ifndef MNG_NO_16BIT_SUPPORT - else - { - switch (pImage->iMAGN_MethodX) - { - case 1 : { fMagnifyX = mng_magnify_g16_x1; break; } - case 2 : { fMagnifyX = mng_magnify_g16_x2; break; } - case 3 : { fMagnifyX = mng_magnify_g16_x3; break; } - case 4 : { fMagnifyX = mng_magnify_g16_x2; break; } - case 5 : { fMagnifyX = mng_magnify_g16_x3; break; } - } - - switch (pImage->iMAGN_MethodY) - { - case 1 : { fMagnifyY = mng_magnify_g16_y1; break; } - case 2 : { fMagnifyY = mng_magnify_g16_y2; break; } - case 3 : { fMagnifyY = mng_magnify_g16_y3; break; } - case 4 : { fMagnifyY = mng_magnify_g16_y2; break; } - case 5 : { fMagnifyY = mng_magnify_g16_y3; break; } - } - } -#endif - - break; - } - - case 2 : ; - case 10 : { - if (pBuf->iBitdepth <= 8) - { - switch (pImage->iMAGN_MethodX) - { - case 1 : { fMagnifyX = mng_magnify_rgb8_x1; break; } - case 2 : { fMagnifyX = mng_magnify_rgb8_x2; break; } - case 3 : { fMagnifyX = mng_magnify_rgb8_x3; break; } - case 4 : { fMagnifyX = mng_magnify_rgb8_x2; break; } - case 5 : { fMagnifyX = mng_magnify_rgb8_x3; break; } - } - - switch (pImage->iMAGN_MethodY) - { - case 1 : { fMagnifyY = mng_magnify_rgb8_y1; break; } - case 2 : { fMagnifyY = mng_magnify_rgb8_y2; break; } - case 3 : { fMagnifyY = mng_magnify_rgb8_y3; break; } - case 4 : { fMagnifyY = mng_magnify_rgb8_y2; break; } - case 5 : { fMagnifyY = mng_magnify_rgb8_y3; break; } - } - } -#ifndef MNG_NO_16BIT_SUPPORT - else - { - switch (pImage->iMAGN_MethodX) - { - case 1 : { fMagnifyX = mng_magnify_rgb16_x1; break; } - case 2 : { fMagnifyX = mng_magnify_rgb16_x2; break; } - case 3 : { fMagnifyX = mng_magnify_rgb16_x3; break; } - case 4 : { fMagnifyX = mng_magnify_rgb16_x2; break; } - case 5 : { fMagnifyX = mng_magnify_rgb16_x3; break; } - } - - switch (pImage->iMAGN_MethodY) - { - case 1 : { fMagnifyY = mng_magnify_rgb16_y1; break; } - case 2 : { fMagnifyY = mng_magnify_rgb16_y2; break; } - case 3 : { fMagnifyY = mng_magnify_rgb16_y3; break; } - case 4 : { fMagnifyY = mng_magnify_rgb16_y2; break; } - case 5 : { fMagnifyY = mng_magnify_rgb16_y3; break; } - } - } -#endif - - break; - } - - case 4 : ; - case 12 : { - if (pBuf->iBitdepth <= 8) - { - switch (pImage->iMAGN_MethodX) - { - case 1 : { fMagnifyX = mng_magnify_ga8_x1; break; } - case 2 : { fMagnifyX = mng_magnify_ga8_x2; break; } - case 3 : { fMagnifyX = mng_magnify_ga8_x3; break; } - case 4 : { fMagnifyX = mng_magnify_ga8_x4; break; } - case 5 : { fMagnifyX = mng_magnify_ga8_x5; break; } - } - - switch (pImage->iMAGN_MethodY) - { - case 1 : { fMagnifyY = mng_magnify_ga8_y1; break; } - case 2 : { fMagnifyY = mng_magnify_ga8_y2; break; } - case 3 : { fMagnifyY = mng_magnify_ga8_y3; break; } - case 4 : { fMagnifyY = mng_magnify_ga8_y4; break; } - case 5 : { fMagnifyY = mng_magnify_ga8_y5; break; } - } - } -#ifndef MNG_NO_16BIT_SUPPORT - else - { - switch (pImage->iMAGN_MethodX) - { - case 1 : { fMagnifyX = mng_magnify_ga16_x1; break; } - case 2 : { fMagnifyX = mng_magnify_ga16_x2; break; } - case 3 : { fMagnifyX = mng_magnify_ga16_x3; break; } - case 4 : { fMagnifyX = mng_magnify_ga16_x4; break; } - case 5 : { fMagnifyX = mng_magnify_ga16_x5; break; } - } - - switch (pImage->iMAGN_MethodY) - { - case 1 : { fMagnifyY = mng_magnify_ga16_y1; break; } - case 2 : { fMagnifyY = mng_magnify_ga16_y2; break; } - case 3 : { fMagnifyY = mng_magnify_ga16_y3; break; } - case 4 : { fMagnifyY = mng_magnify_ga16_y4; break; } - case 5 : { fMagnifyY = mng_magnify_ga16_y5; break; } - } - } -#endif - - break; - } -#endif - - case 6 : ; - case 14 : { - if (pBuf->iBitdepth <= 8) - { - switch (pImage->iMAGN_MethodX) - { - case 1 : { fMagnifyX = mng_magnify_rgba8_x1; break; } - case 2 : { fMagnifyX = mng_magnify_rgba8_x2; break; } - case 3 : { fMagnifyX = mng_magnify_rgba8_x3; break; } - case 4 : { fMagnifyX = mng_magnify_rgba8_x4; break; } - case 5 : { fMagnifyX = mng_magnify_rgba8_x5; break; } - } - - switch (pImage->iMAGN_MethodY) - { - case 1 : { fMagnifyY = mng_magnify_rgba8_y1; break; } - case 2 : { fMagnifyY = mng_magnify_rgba8_y2; break; } - case 3 : { fMagnifyY = mng_magnify_rgba8_y3; break; } - case 4 : { fMagnifyY = mng_magnify_rgba8_y4; break; } - case 5 : { fMagnifyY = mng_magnify_rgba8_y5; break; } - } - } -#ifndef MNG_NO_16BIT_SUPPORT -#ifndef MNG_OPTIMIZE_FOOTPRINT_MAGN - else - { - switch (pImage->iMAGN_MethodX) - { - case 1 : { fMagnifyX = mng_magnify_rgba16_x1; break; } - case 2 : { fMagnifyX = mng_magnify_rgba16_x2; break; } - case 3 : { fMagnifyX = mng_magnify_rgba16_x3; break; } - case 4 : { fMagnifyX = mng_magnify_rgba16_x4; break; } - case 5 : { fMagnifyX = mng_magnify_rgba16_x5; break; } - } - - switch (pImage->iMAGN_MethodY) - { - case 1 : { fMagnifyY = mng_magnify_rgba16_y1; break; } - case 2 : { fMagnifyY = mng_magnify_rgba16_y2; break; } - case 3 : { fMagnifyY = mng_magnify_rgba16_y3; break; } - case 4 : { fMagnifyY = mng_magnify_rgba16_y4; break; } - case 5 : { fMagnifyY = mng_magnify_rgba16_y5; break; } - } - } -#endif -#endif - break; - } - } - - pSrcline1 = pBuf->pImgdata; /* initialize row-loop variables */ - pDstline = pNewdata; - /* allocate temporary row */ - MNG_ALLOC (pData, pTempline, iNewrowsize); - - for (iY = 0; iY < pBuf->iHeight; iY++) - { - pSrcline2 = pSrcline1 + pBuf->iRowsize; - - if (fMagnifyX) /* magnifying in X-direction ? */ - { - iRetcode = fMagnifyX (pData, pImage->iMAGN_MX, - pImage->iMAGN_ML, pImage->iMAGN_MR, - pBuf->iWidth, pSrcline1, pDstline); - - if (iRetcode) /* on error bail out */ - { - MNG_FREEX (pData, pTempline, iNewrowsize); - MNG_FREEX (pData, pNewdata, iNewsize); - return iRetcode; - } - } - else - { - MNG_COPY (pDstline, pSrcline1, iNewrowsize); - } - - pDstline += iNewrowsize; - /* magnifying in Y-direction ? */ - if ((fMagnifyY) && - ((iY < pBuf->iHeight - 1) || (pBuf->iHeight == 1) || (pImage->iMAGN_MethodY == 1))) - { - if (iY == 0) /* first interval ? */ - { - if (pBuf->iHeight == 1) /* single row ? */ - pSrcline2 = MNG_NULL; - - iM = (mng_int32)pImage->iMAGN_MT; - } - else /* last interval ? */ - if (((pImage->iMAGN_MethodY == 1) && (iY == (pBuf->iHeight - 1))) || - ((pImage->iMAGN_MethodY != 1) && (iY == (pBuf->iHeight - 2))) ) - iM = (mng_int32)pImage->iMAGN_MB; - else /* middle interval */ - iM = (mng_int32)pImage->iMAGN_MY; - - for (iS = 1; iS < iM; iS++) - { - iRetcode = fMagnifyY (pData, iS, iM, pBuf->iWidth, - pSrcline1, pSrcline2, pTempline); - - if (iRetcode) /* on error bail out */ - { - MNG_FREEX (pData, pTempline, iNewrowsize); - MNG_FREEX (pData, pNewdata, iNewsize); - return iRetcode; - } - - if (fMagnifyX) /* magnifying in X-direction ? */ - { - iRetcode = fMagnifyX (pData, pImage->iMAGN_MX, - pImage->iMAGN_ML, pImage->iMAGN_MR, - pBuf->iWidth, pTempline, pDstline); - - if (iRetcode) /* on error bail out */ - { - MNG_FREEX (pData, pTempline, iNewrowsize); - MNG_FREEX (pData, pNewdata, iNewsize); - return iRetcode; - } - } - else - { - MNG_COPY (pDstline, pTempline, iNewrowsize); - } - - pDstline += iNewrowsize; - } - } - - pSrcline1 += pBuf->iRowsize; - } - /* drop temporary row */ - MNG_FREEX (pData, pTempline, iNewrowsize); - /* drop old pixel-data */ - MNG_FREEX (pData, pBuf->pImgdata, pBuf->iImgdatasize); - - pBuf->pImgdata = pNewdata; /* save new buffer dimensions */ - pBuf->iRowsize = iNewrowsize; - pBuf->iImgdatasize = iNewsize; - pBuf->iWidth = iNewW; - pBuf->iHeight = iNewH; - - if (pImage->iId) /* real object ? */ - { - pImage->iMAGN_MethodX = 0; /* it's done; don't do it again !!! */ - pImage->iMAGN_MethodY = 0; - pImage->iMAGN_MX = 0; - pImage->iMAGN_MY = 0; - pImage->iMAGN_ML = 0; - pImage->iMAGN_MR = 0; - pImage->iMAGN_MT = 0; - pImage->iMAGN_MB = 0; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_IMGOBJECT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_colorcorrect_object (mng_datap pData, - mng_imagep pImage) -{ - mng_imagedatap pBuf = pImage->pImgbuf; - mng_retcode iRetcode; - mng_uint32 iY; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_COLORCORRECT_OBJECT, MNG_LC_START); -#endif - -#ifdef MNG_INCLUDE_JNG - if ((pBuf->iBitdepth < 8) || /* we need 8- or 16-bit RGBA !!! */ - ((pBuf->iColortype != MNG_COLORTYPE_RGBA ) && - (pBuf->iColortype != MNG_COLORTYPE_JPEGCOLORA) )) -#else - if (pBuf->iBitdepth < 8) /* we need 8- or 16-bit RGBA !!! */ -#endif - MNG_ERROR (pData, MNG_OBJNOTABSTRACT); - - if (!pBuf->bCorrected) /* only if not already done ! */ - { /* so the row routines now to find it */ - pData->pRetrieveobj = (mng_objectp)pImage; - pData->pStoreobj = (mng_objectp)pImage; - pData->pStorebuf = (mng_objectp)pImage->pImgbuf; - -#ifndef MNG_NO_16BIT_SUPPORT - if (pBuf->iBitdepth > 8) - { - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgba16; - pData->fStorerow = (mng_fptr)mng_store_rgba16; - } - else -#endif - { - pData->fRetrieverow = (mng_fptr)mng_retrieve_rgba8; - pData->fStorerow = (mng_fptr)mng_store_rgba8; - } - - pData->bIsOpaque = MNG_FALSE; - - pData->iPass = -1; /* these are the object's dimensions now */ - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pBuf->iWidth; - pData->iRowsize = pData->iRowsamples << 2; - pData->iPixelofs = 0; - pData->bIsRGBA16 = MNG_FALSE; - /* adjust for 16-bit object ? */ -#ifndef MNG_NO_16BIT_SUPPORT - if (pBuf->iBitdepth > 8) - { - pData->bIsRGBA16 = MNG_TRUE; - pData->iRowsize = pData->iRowsamples << 3; - } -#endif - - pData->fCorrectrow = MNG_NULL; /* default no color-correction */ - -#ifdef MNG_NO_CMS - iRetcode = MNG_NOERROR; -#else -#if defined(MNG_FULL_CMS) /* determine color-management routine */ - iRetcode = mng_init_full_cms (pData, MNG_FALSE, MNG_FALSE, MNG_TRUE); -#elif defined(MNG_GAMMA_ONLY) - iRetcode = mng_init_gamma_only (pData, MNG_FALSE, MNG_FALSE, MNG_TRUE); -#elif defined(MNG_APP_CMS) - iRetcode = mng_init_app_cms (pData, MNG_FALSE, MNG_FALSE, MNG_TRUE); -#endif - if (iRetcode) /* on error bail out */ - return iRetcode; -#endif /* MNG_NO_CMS */ - - if (pData->fCorrectrow) /* really correct something ? */ - { /* get a temporary row-buffer */ - MNG_ALLOC (pData, pData->pRGBArow, pData->iRowsize); - - pData->pWorkrow = pData->pRGBArow; - iY = 0; /* start from the top */ - - while ((!iRetcode) && (iY < pBuf->iHeight)) - { /* get a row */ - iRetcode = ((mng_retrieverow)pData->fRetrieverow) (pData); - - if (!iRetcode) /* color correct it */ - iRetcode = ((mng_correctrow)pData->fCorrectrow) (pData); - - if (!iRetcode) /* store it back ! */ - iRetcode = ((mng_storerow)pData->fStorerow) (pData); - - if (!iRetcode) /* adjust variables for next row */ - iRetcode = mng_next_row (pData); - - iY++; /* and next line */ - } - /* drop the temporary row-buffer */ - MNG_FREEX (pData, pData->pRGBArow, pData->iRowsize); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#if defined(MNG_FULL_CMS) /* cleanup cms stuff */ - iRetcode = mng_clear_cms (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; -#endif - } - - pBuf->bCorrected = MNG_TRUE; /* let's not go through that again ! */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_COLORCORRECT_OBJECT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Animation-object routines * */ -/* * * */ -/* * these handle the animation objects used to re-run parts of a MNG. * */ -/* * eg. during LOOP or TERM processing * */ -/* * * */ -/* ************************************************************************** */ - -void mng_add_ani_object (mng_datap pData, - mng_object_headerp pObject) -{ - mng_object_headerp pLast = (mng_object_headerp)pData->pLastaniobj; - - if (pLast) /* link it as last in the chain */ - { - pObject->pPrev = pLast; - pLast->pNext = pObject; - } - else - { - pObject->pPrev = MNG_NULL; /* be on the safe side */ - pData->pFirstaniobj = pObject; - } - - pObject->pNext = MNG_NULL; /* be on the safe side */ - pData->pLastaniobj = pObject; - /* keep track for jumping */ - pObject->iFramenr = pData->iFrameseq; - pObject->iLayernr = pData->iLayerseq; - pObject->iPlaytime = pData->iFrametime; - /* save restart object ? */ - if ((pData->bDisplaying) && (!pData->bRunning) && (!pData->pCurraniobj)) - pData->pCurraniobj = pObject; - - return; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode mng_create_ani_image (mng_datap pData) -{ - mng_ani_imagep pImage; - mng_imagep pCurrent; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_IMAGE, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifndef MNG_NO_DELTA_PNG - if (pData->bHasDHDR) /* processing delta-image ? */ - pCurrent = (mng_imagep)pData->pObjzero; - else /* get the current object */ -#endif - pCurrent = (mng_imagep)pData->pCurrentobj; - - if (!pCurrent) /* otherwise object 0 */ - pCurrent = (mng_imagep)pData->pObjzero; - /* now just clone the object !!! */ - iRetcode = mng_clone_imageobject (pData, 0, MNG_FALSE, pCurrent->bVisible, - MNG_FALSE, MNG_FALSE, 0, 0, 0, pCurrent, - &pImage); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - pImage->sHeader.fCleanup = mng_free_ani_image; - pImage->sHeader.fProcess = mng_process_ani_image; - - mng_add_ani_object (pData, (mng_object_headerp)pImage); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_IMAGE, MNG_LC_END); -#endif - - return MNG_NOERROR; /* okido */ -} - -/* ************************************************************************** */ - -mng_retcode mng_free_ani_image (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_imagep pImage = (mng_ani_imagep)pObject; - mng_imagedatap pImgbuf = pImage->pImgbuf; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_IMAGE, MNG_LC_START); -#endif - /* unlink the image-data buffer */ - iRetcode = mng_free_imagedataobject (pData, pImgbuf); - /* drop its own buffer */ - MNG_FREEX (pData, pImage, sizeof (mng_ani_image)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_IMAGE, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_image (mng_datap pData, - mng_objectp pObject) -{ - mng_retcode iRetcode = MNG_NOERROR; - mng_ani_imagep pImage = (mng_imagep)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_IMAGE, MNG_LC_START); -#endif - -#ifndef MNG_NO_DELTA_PNG - if (pData->bHasDHDR) /* processing delta-image ? */ - { - mng_imagep pDelta = (mng_imagep)pData->pDeltaImage; - - if (!pData->iBreakpoint) /* only execute if not broken before */ - { /* make sure to process pixels as well */ - pData->bDeltaimmediate = MNG_FALSE; - /* execute the delta process */ - iRetcode = mng_execute_delta_image (pData, pDelta, (mng_imagep)pObject); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - /* now go and shoot it off (if required) */ - if ((pDelta->bVisible) && (pDelta->bViewable)) - iRetcode = mng_display_image (pData, pDelta, MNG_FALSE); - - if (!pData->bTimerset) - pData->bHasDHDR = MNG_FALSE; /* this image signifies IEND !! */ - - } - else -#endif - if (pData->pCurrentobj) /* active object ? */ - { - mng_imagep pCurrent = (mng_imagep)pData->pCurrentobj; - mng_imagedatap pBuf = pCurrent->pImgbuf; - - if (!pData->iBreakpoint) /* don't copy it again ! */ - { - if (pBuf->iImgdatasize) /* buffer present in active object ? */ - /* then drop it */ - MNG_FREE (pData, pBuf->pImgdata, pBuf->iImgdatasize); - -#ifndef MNG_SKIPCHUNK_iCCP - if (pBuf->iProfilesize) /* iCCP profile present ? */ - /* then drop it */ - MNG_FREE (pData, pBuf->pProfile, pBuf->iProfilesize); -#endif - /* now blatently copy the animation buffer */ - MNG_COPY (pBuf, pImage->pImgbuf, sizeof (mng_imagedata)); - /* copy viewability */ - pCurrent->bViewable = pImage->bViewable; - - if (pBuf->iImgdatasize) /* sample buffer present ? */ - { /* then make a copy */ - MNG_ALLOC (pData, pBuf->pImgdata, pBuf->iImgdatasize); - MNG_COPY (pBuf->pImgdata, pImage->pImgbuf->pImgdata, pBuf->iImgdatasize); - } - -#ifndef MNG_SKIPCHUNK_iCCP - if (pBuf->iProfilesize) /* iCCP profile present ? */ - { /* then make a copy */ - MNG_ALLOC (pData, pBuf->pProfile, pBuf->iProfilesize); - MNG_COPY (pBuf->pProfile, pImage->pImgbuf->pProfile, pBuf->iProfilesize); - } -#endif - } - /* now go and shoot it off (if required) */ - if ((pCurrent->bVisible) && (pCurrent->bViewable)) - iRetcode = mng_display_image (pData, pCurrent, MNG_FALSE); - } - else - { - mng_imagep pObjzero = (mng_imagep)pData->pObjzero; - mng_imagedatap pBuf = pObjzero->pImgbuf; - - if (!pData->iBreakpoint) /* don't copy it again ! */ - { - if (pBuf->iImgdatasize) /* buffer present in active object ? */ - /* then drop it */ - MNG_FREE (pData, pBuf->pImgdata, pBuf->iImgdatasize); - -#ifndef MNG_SKIPCHUNK_iCCP - if (pBuf->iProfilesize) /* iCCP profile present ? */ - /* then drop it */ - MNG_FREE (pData, pBuf->pProfile, pBuf->iProfilesize); -#endif - /* now blatently copy the animation buffer */ - MNG_COPY (pBuf, pImage->pImgbuf, sizeof (mng_imagedata)); - /* copy viewability */ - pObjzero->bViewable = pImage->bViewable; - - if (pBuf->iImgdatasize) /* sample buffer present ? */ - { /* then make a copy */ - MNG_ALLOC (pData, pBuf->pImgdata, pBuf->iImgdatasize); - MNG_COPY (pBuf->pImgdata, pImage->pImgbuf->pImgdata, pBuf->iImgdatasize); - } - -#ifndef MNG_SKIPCHUNK_iCCP - if (pBuf->iProfilesize) /* iCCP profile present ? */ - { /* then make a copy */ - MNG_ALLOC (pData, pBuf->pProfile, pBuf->iProfilesize); - MNG_COPY (pBuf->pProfile, pImage->pImgbuf->pProfile, pBuf->iProfilesize); - } -#endif - } - /* now go and show it */ - iRetcode = mng_display_image (pData, pObjzero, MNG_FALSE); - } - - if (!iRetcode) /* all's well ? */ - { - if (pData->bTimerset) /* timer break ? */ - pData->iBreakpoint = 99; /* fictive number; no more processing needed! */ - else - pData->iBreakpoint = 0; /* else clear it */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_IMAGE, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_create_ani_plte (mng_datap pData, - mng_uint32 iEntrycount, - mng_palette8ep paEntries) -#else -mng_retcode mng_create_ani_plte (mng_datap pData) -#endif -{ - mng_ani_pltep pPLTE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_PLTE, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_ptr pTemp; - mng_retcode iRetcode = create_obj_general (pData, sizeof (mng_ani_plte), - mng_free_obj_general, - mng_process_ani_plte, - &pTemp); - if (iRetcode) - return iRetcode; - pPLTE = (mng_ani_pltep)pTemp; -#else - MNG_ALLOC (pData, pPLTE, sizeof (mng_ani_plte)); - - pPLTE->sHeader.fCleanup = mng_free_ani_plte; - pPLTE->sHeader.fProcess = mng_process_ani_plte; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pPLTE); - -#ifndef MNG_OPTIMIZE_CHUNKREADER - pPLTE->iEntrycount = iEntrycount; - MNG_COPY (pPLTE->aEntries, paEntries, sizeof (pPLTE->aEntries)); -#else - pPLTE->iEntrycount = pData->iGlobalPLTEcount; - MNG_COPY (pPLTE->aEntries, pData->aGlobalPLTEentries, sizeof (pPLTE->aEntries)); -#endif - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_PLTE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_OBJCLEANUP -mng_retcode mng_free_ani_plte (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_PLTE, MNG_LC_START); -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_plte)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_PLTE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_plte (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_pltep pPLTE = (mng_ani_pltep)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_PLTE, MNG_LC_START); -#endif - - pData->bHasglobalPLTE = MNG_TRUE; - pData->iGlobalPLTEcount = pPLTE->iEntrycount; - - MNG_COPY (pData->aGlobalPLTEentries, pPLTE->aEntries, sizeof (pPLTE->aEntries)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_PLTE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_create_ani_trns (mng_datap pData, - mng_uint32 iRawlen, - mng_uint8p pRawdata) -#else -mng_retcode mng_create_ani_trns (mng_datap pData) -#endif -{ - mng_ani_trnsp pTRNS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_TRNS, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_ptr pTemp; - mng_retcode iRetcode = create_obj_general (pData, sizeof (mng_ani_trns), - mng_free_obj_general, - mng_process_ani_trns, - &pTemp); - if (iRetcode) - return iRetcode; - pTRNS = (mng_ani_trnsp)pTemp; -#else - MNG_ALLOC (pData, pTRNS, sizeof (mng_ani_trns)); - - pTRNS->sHeader.fCleanup = mng_free_ani_trns; - pTRNS->sHeader.fProcess = mng_process_ani_trns; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pTRNS); - -#ifndef MNG_OPTIMIZE_CHUNKREADER - pTRNS->iRawlen = iRawlen; - MNG_COPY (pTRNS->aRawdata, pRawdata, sizeof (pTRNS->aRawdata)); -#else - pTRNS->iRawlen = pData->iGlobalTRNSrawlen; - MNG_COPY (pTRNS->aRawdata, pData->aGlobalTRNSrawdata, sizeof (pTRNS->aRawdata)); -#endif - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_TRNS, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_OBJCLEANUP -mng_retcode mng_free_ani_trns (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_TRNS, MNG_LC_START); -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_trns)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_TRNS, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_trns (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_trnsp pTRNS = (mng_ani_trnsp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_TRNS, MNG_LC_START); -#endif - - pData->bHasglobalTRNS = MNG_TRUE; - pData->iGlobalTRNSrawlen = pTRNS->iRawlen; - - MNG_COPY (pData->aGlobalTRNSrawdata, pTRNS->aRawdata, sizeof (pTRNS->aRawdata)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_TRNS, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_gAMA -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_create_ani_gama (mng_datap pData, - mng_bool bEmpty, - mng_uint32 iGamma) -#else -mng_retcode mng_create_ani_gama (mng_datap pData, - mng_chunkp pChunk) -#endif -{ - mng_ani_gamap pGAMA; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_GAMA, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_ptr pTemp; - mng_retcode iRetcode = create_obj_general (pData, sizeof (mng_ani_gama), - mng_free_obj_general, - mng_process_ani_gama, - &pTemp); - if (iRetcode) - return iRetcode; - pGAMA = (mng_ani_gamap)pTemp; -#else - MNG_ALLOC (pData, pGAMA, sizeof (mng_ani_gama)); - - pGAMA->sHeader.fCleanup = mng_free_ani_gama; - pGAMA->sHeader.fProcess = mng_process_ani_gama; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pGAMA); - -#ifndef MNG_OPTIMIZE_CHUNKREADER - pGAMA->bEmpty = bEmpty; - pGAMA->iGamma = iGamma; -#else - pGAMA->bEmpty = ((mng_gamap)pChunk)->bEmpty; - pGAMA->iGamma = ((mng_gamap)pChunk)->iGamma; -#endif - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_GAMA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_OBJCLEANUP -mng_retcode mng_free_ani_gama (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_GAMA, MNG_LC_START); -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_gama)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_GAMA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_gama (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_gamap pGAMA = (mng_ani_gamap)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_GAMA, MNG_LC_START); -#endif - - if (pGAMA->bEmpty) /* empty chunk ? */ - { /* clear global gAMA */ - pData->bHasglobalGAMA = MNG_FALSE; - pData->iGlobalGamma = 0; - } - else - { /* set global gAMA */ - pData->bHasglobalGAMA = MNG_TRUE; - pData->iGlobalGamma = pGAMA->iGamma; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_GAMA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_cHRM -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_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) -#else -mng_retcode mng_create_ani_chrm (mng_datap pData, - mng_chunkp pChunk) -#endif -{ - mng_ptr pTemp; - mng_ani_chrmp pCHRM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_CHRM, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_retcode iRetcode = create_obj_general (pData, sizeof (mng_ani_chrm), - mng_free_obj_general, - mng_process_ani_chrm, - &pTemp); - if (iRetcode) - return iRetcode; - pCHRM = (mng_ani_chrmp)pTemp; -#else - MNG_ALLOC (pData, pCHRM, sizeof (mng_ani_chrm)); - - pCHRM->sHeader.fCleanup = mng_free_ani_chrm; - pCHRM->sHeader.fProcess = mng_process_ani_chrm; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pCHRM); - -#ifndef MNG_OPTIMIZE_CHUNKREADER - pCHRM->bEmpty = bEmpty; - pCHRM->iWhitepointx = iWhitepointx; - pCHRM->iWhitepointy = iWhitepointy; - pCHRM->iRedx = iRedx; - pCHRM->iRedy = iRedy; - pCHRM->iGreenx = iGreenx; - pCHRM->iGreeny = iGreeny; - pCHRM->iBluex = iBluex; - pCHRM->iBluey = iBluey; -#else - pCHRM->bEmpty = ((mng_chrmp)pChunk)->bEmpty; - pCHRM->iWhitepointx = ((mng_chrmp)pChunk)->iWhitepointx; - pCHRM->iWhitepointy = ((mng_chrmp)pChunk)->iWhitepointy; - pCHRM->iRedx = ((mng_chrmp)pChunk)->iRedx; - pCHRM->iRedy = ((mng_chrmp)pChunk)->iRedy; - pCHRM->iGreenx = ((mng_chrmp)pChunk)->iGreenx; - pCHRM->iGreeny = ((mng_chrmp)pChunk)->iGreeny; - pCHRM->iBluex = ((mng_chrmp)pChunk)->iBluex; - pCHRM->iBluey = ((mng_chrmp)pChunk)->iBluey; -#endif - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_CHRM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_OBJCLEANUP -mng_retcode mng_free_ani_chrm (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_CHRM, MNG_LC_START); -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_chrm)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_CHRM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_chrm (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_chrmp pCHRM = (mng_ani_chrmp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_CHRM, MNG_LC_START); -#endif - - if (pCHRM->bEmpty) /* empty chunk ? */ - { /* clear global cHRM */ - pData->bHasglobalCHRM = MNG_FALSE; - pData->iGlobalWhitepointx = 0; - pData->iGlobalWhitepointy = 0; - pData->iGlobalPrimaryredx = 0; - pData->iGlobalPrimaryredy = 0; - pData->iGlobalPrimarygreenx = 0; - pData->iGlobalPrimarygreeny = 0; - pData->iGlobalPrimarybluex = 0; - pData->iGlobalPrimarybluey = 0; - } - else - { /* set global cHRM */ - pData->bHasglobalCHRM = MNG_TRUE; - pData->iGlobalWhitepointx = pCHRM->iWhitepointx; - pData->iGlobalWhitepointy = pCHRM->iWhitepointy; - pData->iGlobalPrimaryredx = pCHRM->iRedx; - pData->iGlobalPrimaryredy = pCHRM->iRedy; - pData->iGlobalPrimarygreenx = pCHRM->iGreenx; - pData->iGlobalPrimarygreeny = pCHRM->iGreeny; - pData->iGlobalPrimarybluex = pCHRM->iBluex; - pData->iGlobalPrimarybluey = pCHRM->iBluey; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_CHRM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_sRGB -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_create_ani_srgb (mng_datap pData, - mng_bool bEmpty, - mng_uint8 iRenderingintent) -#else -mng_retcode mng_create_ani_srgb (mng_datap pData, - mng_chunkp pChunk) -#endif -{ - mng_ani_srgbp pSRGB; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_SRGB, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_ptr pTemp; - mng_retcode iRetcode = create_obj_general (pData, sizeof (mng_ani_srgb), - mng_free_obj_general, - mng_process_ani_srgb, - &pTemp); - if (iRetcode) - return iRetcode; - pSRGB = (mng_ani_srgbp)pTemp; -#else - MNG_ALLOC (pData, pSRGB, sizeof (mng_ani_srgb)); - - pSRGB->sHeader.fCleanup = mng_free_ani_srgb; - pSRGB->sHeader.fProcess = mng_process_ani_srgb; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pSRGB); - -#ifndef MNG_OPTIMIZE_CHUNKREADER - pSRGB->bEmpty = bEmpty; - pSRGB->iRenderingintent = iRenderingintent; -#else - pSRGB->bEmpty = ((mng_srgbp)pChunk)->bEmpty; - pSRGB->iRenderingintent = ((mng_srgbp)pChunk)->iRenderingintent; -#endif - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_SRGB, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_OBJCLEANUP -mng_retcode mng_free_ani_srgb (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_SRGB, MNG_LC_START); -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_srgb)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_SRGB, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_srgb (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_srgbp pSRGB = (mng_ani_srgbp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_SRGB, MNG_LC_START); -#endif - - if (pSRGB->bEmpty) /* empty chunk ? */ - { /* clear global sRGB */ - pData->bHasglobalSRGB = MNG_FALSE; - pData->iGlobalRendintent = 0; - } - else - { /* set global sRGB */ - pData->bHasglobalSRGB = MNG_TRUE; - pData->iGlobalRendintent = pSRGB->iRenderingintent; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_SRGB, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_iCCP -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_create_ani_iccp (mng_datap pData, - mng_bool bEmpty, - mng_uint32 iProfilesize, - mng_ptr pProfile) -#else -mng_retcode mng_create_ani_iccp (mng_datap pData, - mng_chunkp pChunk) -#endif -{ - mng_ptr pTemp; - mng_ani_iccpp pICCP; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_ICCP, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_retcode iRetcode = create_obj_general (pData, sizeof (mng_ani_iccp), - mng_free_ani_iccp, - mng_process_ani_iccp, - &pTemp); - if (iRetcode) - return iRetcode; - pICCP = (mng_ani_iccpp)pTemp; -#else - MNG_ALLOC (pData, pICCP, sizeof (mng_ani_iccp)); - - pICCP->sHeader.fCleanup = mng_free_ani_iccp; - pICCP->sHeader.fProcess = mng_process_ani_iccp; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pICCP); - -#ifndef MNG_OPTIMIZE_CHUNKREADER - pICCP->bEmpty = bEmpty; - pICCP->iProfilesize = iProfilesize; - - if (iProfilesize) - { - MNG_ALLOC (pData, pICCP->pProfile, iProfilesize); - MNG_COPY (pICCP->pProfile, pProfile, iProfilesize); - } -#else - pICCP->bEmpty = ((mng_iccpp)pChunk)->bEmpty; - pICCP->iProfilesize = ((mng_iccpp)pChunk)->iProfilesize; - - if (pICCP->iProfilesize) - { - MNG_ALLOC (pData, pICCP->pProfile, pICCP->iProfilesize); - MNG_COPY (pICCP->pProfile, ((mng_iccpp)pChunk)->pProfile, pICCP->iProfilesize); - } -#endif - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_ICCP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_free_ani_iccp (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_iccpp pICCP = (mng_ani_iccpp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_ICCP, MNG_LC_START); -#endif - - if (pICCP->iProfilesize) - MNG_FREEX (pData, pICCP->pProfile, pICCP->iProfilesize); - -#ifndef MNG_OPTIMIZE_OBJCLEANUP - MNG_FREEX (pData, pObject, sizeof (mng_ani_iccp)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_ICCP, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_OBJCLEANUP - return MNG_NOERROR; -#else - return mng_free_obj_general(pData, pObject); -#endif -} - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_iccp (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_iccpp pICCP = (mng_ani_iccpp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_ICCP, MNG_LC_START); -#endif - - if (pICCP->bEmpty) /* empty chunk ? */ - { /* clear global iCCP */ - pData->bHasglobalICCP = MNG_FALSE; - - if (pData->iGlobalProfilesize) - MNG_FREEX (pData, pData->pGlobalProfile, pData->iGlobalProfilesize); - - pData->iGlobalProfilesize = 0; - pData->pGlobalProfile = MNG_NULL; - } - else - { /* set global iCCP */ - pData->bHasglobalICCP = MNG_TRUE; - pData->iGlobalProfilesize = pICCP->iProfilesize; - - if (pICCP->iProfilesize) - { - MNG_ALLOC (pData, pData->pGlobalProfile, pICCP->iProfilesize); - MNG_COPY (pData->pGlobalProfile, pICCP->pProfile, pICCP->iProfilesize); - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_ICCP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_bKGD -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_create_ani_bkgd (mng_datap pData, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue) -#else -mng_retcode mng_create_ani_bkgd (mng_datap pData) -#endif -{ - mng_ptr pTemp; - mng_ani_bkgdp pBKGD; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_BKGD, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_retcode iRetcode = create_obj_general (pData, sizeof (mng_ani_bkgd), - mng_free_obj_general, - mng_process_ani_bkgd, - &pTemp); - if (iRetcode) - return iRetcode; - pBKGD = (mng_ani_bkgdp)pTemp; -#else - MNG_ALLOC (pData, pBKGD, sizeof (mng_ani_bkgd)); - - pBKGD->sHeader.fCleanup = mng_free_ani_bkgd; - pBKGD->sHeader.fProcess = mng_process_ani_bkgd; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pBKGD); - -#ifndef MNG_OPTIMIZE_CHUNKREADER - pBKGD->iRed = iRed; - pBKGD->iGreen = iGreen; - pBKGD->iBlue = iBlue; -#else - pBKGD->iRed = pData->iGlobalBKGDred; - pBKGD->iGreen = pData->iGlobalBKGDgreen; - pBKGD->iBlue = pData->iGlobalBKGDblue; -#endif - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_BKGD, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_OBJCLEANUP -mng_retcode mng_free_ani_bkgd (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_BKGD, MNG_LC_START); -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_bkgd)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_BKGD, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_bkgd (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_bkgdp pBKGD = (mng_ani_bkgdp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_BKGD, MNG_LC_START); -#endif - - pData->bHasglobalBKGD = MNG_TRUE; - pData->iGlobalBKGDred = pBKGD->iRed; - pData->iGlobalBKGDgreen = pBKGD->iGreen; - pData->iGlobalBKGDblue = pBKGD->iBlue; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_BKGD, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_LOOP -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_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) -#else -mng_retcode mng_create_ani_loop (mng_datap pData, - mng_chunkp pChunk) -#endif -{ - mng_ani_loopp pLOOP; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_LOOP, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_ptr pTemp; - mng_retcode iRetcode = create_obj_general (pData, sizeof (mng_ani_loop), - mng_free_ani_loop, - mng_process_ani_loop, - &pTemp); - if (iRetcode) - return iRetcode; - pLOOP = (mng_ani_loopp)pTemp; -#else - MNG_ALLOC (pData, pLOOP, sizeof (mng_ani_loop)); - - pLOOP->sHeader.fCleanup = mng_free_ani_loop; - pLOOP->sHeader.fProcess = mng_process_ani_loop; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pLOOP); - -#ifndef MNG_OPTIMIZE_CHUNKREADER - pLOOP->iLevel = iLevel; - pLOOP->iRepeatcount = iRepeatcount; - pLOOP->iTermcond = iTermcond; - pLOOP->iItermin = iItermin; - pLOOP->iItermax = iItermax; - pLOOP->iCount = iCount; - -#ifndef MNG_NO_LOOP_SIGNALS_SUPPORTED - if (iCount) - { - MNG_ALLOC (pData, pLOOP->pSignals, (iCount << 1)); - MNG_COPY (pLOOP->pSignals, pSignals, (iCount << 1)); - } -#endif -#else /* MNG_OPTIMIZE_CHUNKREADER */ - pLOOP->iLevel = ((mng_loopp)pChunk)->iLevel; - pLOOP->iRepeatcount = ((mng_loopp)pChunk)->iRepeat; - pLOOP->iTermcond = ((mng_loopp)pChunk)->iTermination; - pLOOP->iItermin = ((mng_loopp)pChunk)->iItermin; - pLOOP->iItermax = ((mng_loopp)pChunk)->iItermax; - pLOOP->iCount = ((mng_loopp)pChunk)->iCount; - -#ifndef MNG_NO_LOOP_SIGNALS_SUPPORTED - if (pLOOP->iCount) - { - MNG_ALLOC (pData, pLOOP->pSignals, (pLOOP->iCount << 1)); - MNG_COPY (pLOOP->pSignals, ((mng_loopp)pChunk)->pSignals, (pLOOP->iCount << 1)); - } -#endif -#endif /* MNG_OPTIMIZE_CHUNKREADER */ - /* running counter starts with repeat_count */ - pLOOP->iRunningcount = pLOOP->iRepeatcount; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_LOOP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_free_ani_loop (mng_datap pData, - mng_objectp pObject) -{ -#ifndef MNG_NO_LOOP_SIGNALS_SUPPORTED - mng_ani_loopp pLOOP = (mng_ani_loopp)pObject; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_LOOP, MNG_LC_START); -#endif - -#ifndef MNG_NO_LOOP_SIGNALS_SUPPORTED - if (pLOOP->iCount) /* drop signal buffer ? */ - MNG_FREEX (pData, pLOOP->pSignals, (pLOOP->iCount << 1)); -#endif - -#ifndef MNG_OPTIMIZE_OBJCLEANUP - MNG_FREEX (pData, pObject, sizeof (mng_ani_loop)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_LOOP, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_OBJCLEANUP - return MNG_NOERROR; -#else - return mng_free_obj_general(pData, pObject); -#endif -} - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_loop (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_loopp pLOOP = (mng_ani_loopp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_LOOP, MNG_LC_START); -#endif - /* just reset the running counter */ - pLOOP->iRunningcount = pLOOP->iRepeatcount; - /* iteration=0 means we're skipping ! */ - if ((!pData->bSkipping) && (pLOOP->iRepeatcount == 0)) - pData->bSkipping = MNG_TRUE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_LOOP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode mng_create_ani_endl (mng_datap pData, - mng_uint8 iLevel) -{ - mng_ani_endlp pENDL; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_ENDL, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - mng_retcode iRetcode; -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_ptr pTemp; - iRetcode = create_obj_general (pData, sizeof (mng_ani_endl), - mng_free_obj_general, - mng_process_ani_endl, - &pTemp); - if (iRetcode) - return iRetcode; - pENDL = (mng_ani_endlp)pTemp; -#else - MNG_ALLOC (pData, pENDL, sizeof (mng_ani_endl)); - - pENDL->sHeader.fCleanup = mng_free_ani_endl; - pENDL->sHeader.fProcess = mng_process_ani_endl; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pENDL); - - pENDL->iLevel = iLevel; - - iRetcode = mng_process_ani_endl (pData, (mng_objectp)pENDL); - if (iRetcode) - return iRetcode; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_ENDL, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_OBJCLEANUP -mng_retcode mng_free_ani_endl (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_ENDL, MNG_LC_START); -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_endl)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_ENDL, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_endl (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_endlp pENDL = (mng_ani_endlp)pObject; - mng_ani_loopp pLOOP; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_ENDL, MNG_LC_START); -#endif - - if (((pData->bDisplaying) && ((pData->bRunning) || (pData->bSearching))) || - (pData->bReading) ) - { - pLOOP = pENDL->pLOOP; /* determine matching LOOP */ - - if (!pLOOP) /* haven't got it yet ? */ - { /* go and look back in the list */ - pLOOP = (mng_ani_loopp)pENDL->sHeader.pPrev; - - while ((pLOOP) && - ((pLOOP->sHeader.fCleanup != mng_free_ani_loop) || - (pLOOP->iLevel != pENDL->iLevel) )) - pLOOP = pLOOP->sHeader.pPrev; - } - /* got it now ? */ - if ((pLOOP) && (pLOOP->iLevel == pENDL->iLevel)) - { - pENDL->pLOOP = pLOOP; /* save for next time ! */ - /* decrease running counter ? */ - if ((pLOOP->iRunningcount) && (pLOOP->iRunningcount < 0x7fffffffL)) - pLOOP->iRunningcount--; - - if ((!pData->bDisplaying) && (pData->bReading) && - (pLOOP->iRunningcount >= 0x7fffffffL)) - { - pData->iTotalframes = 0x7fffffffL; - pData->iTotallayers = 0x7fffffffL; - pData->iTotalplaytime = 0x7fffffffL; - } - else - { - /* TODO: we're cheating out on the termination_condition, - iteration_min, iteration_max and possible signals; - the code is just not ready for that can of worms.... */ - - if (!pLOOP->iRunningcount) /* reached zero ? */ - { /* was this the outer LOOP ? */ - if (pData->pFirstaniobj == (mng_objectp)pLOOP) /* TODO: THIS IS WRONG!! */ - pData->bHasLOOP = MNG_FALSE; - } - else - { - if (pData->pCurraniobj) /* was we processing objects ? */ - pData->pCurraniobj = pLOOP;/* then restart with LOOP */ - else /* else restart behind LOOP !!! */ - pData->pCurraniobj = pLOOP->sHeader.pNext; - } - } - /* does this match a 'skipping' LOOP? */ - if ((pData->bSkipping) && (pLOOP->iRepeatcount == 0)) - pData->bSkipping = MNG_FALSE; - } - else - MNG_ERROR (pData, MNG_NOMATCHINGLOOP); - - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_ENDL, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_DEFI -mng_retcode mng_create_ani_defi (mng_datap pData) -{ - mng_ani_defip pDEFI; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_DEFI, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_ptr pTemp; - mng_retcode iRetcode = create_obj_general (pData, sizeof (mng_ani_defi), - mng_free_obj_general, - mng_process_ani_defi, - &pTemp); - if (iRetcode) - return iRetcode; - pDEFI = (mng_ani_defip)pTemp; -#else - MNG_ALLOC (pData, pDEFI, sizeof (mng_ani_defi)); - - pDEFI->sHeader.fCleanup = mng_free_ani_defi; - pDEFI->sHeader.fProcess = mng_process_ani_defi; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pDEFI); - - pDEFI->iId = pData->iDEFIobjectid; - pDEFI->bHasdonotshow = pData->bDEFIhasdonotshow; - pDEFI->iDonotshow = pData->iDEFIdonotshow; - pDEFI->bHasconcrete = pData->bDEFIhasconcrete; - pDEFI->iConcrete = pData->iDEFIconcrete; - pDEFI->bHasloca = pData->bDEFIhasloca; - pDEFI->iLocax = pData->iDEFIlocax; - pDEFI->iLocay = pData->iDEFIlocay; - pDEFI->bHasclip = pData->bDEFIhasclip; - pDEFI->iClipl = pData->iDEFIclipl; - pDEFI->iClipr = pData->iDEFIclipr; - pDEFI->iClipt = pData->iDEFIclipt; - pDEFI->iClipb = pData->iDEFIclipb; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_DEFI, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_OBJCLEANUP -mng_retcode mng_free_ani_defi (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_DEFI, MNG_LC_START); -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_defi)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_DEFI, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_defi (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_defip pDEFI = (mng_ani_defip)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_DEFI, MNG_LC_START); -#endif - - pData->iDEFIobjectid = pDEFI->iId; - pData->bDEFIhasdonotshow = pDEFI->bHasdonotshow; - pData->iDEFIdonotshow = pDEFI->iDonotshow; - pData->bDEFIhasconcrete = pDEFI->bHasconcrete; - pData->iDEFIconcrete = pDEFI->iConcrete; - pData->bDEFIhasloca = pDEFI->bHasloca; - pData->iDEFIlocax = pDEFI->iLocax; - pData->iDEFIlocay = pDEFI->iLocay; - pData->bDEFIhasclip = pDEFI->bHasclip; - pData->iDEFIclipl = pDEFI->iClipl; - pData->iDEFIclipr = pDEFI->iClipr; - pData->iDEFIclipt = pDEFI->iClipt; - pData->iDEFIclipb = pDEFI->iClipb; - - iRetcode = mng_process_display_defi (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_DEFI, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_BASI -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_create_ani_basi (mng_datap pData, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_bool bHasalpha, - mng_uint16 iAlpha, - mng_uint8 iViewable) -#else -mng_retcode mng_create_ani_basi (mng_datap pData, - mng_chunkp pChunk) -#endif -{ - mng_ani_basip pBASI; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_BASI, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_ptr pTemp; - iRetcode = create_obj_general (pData, sizeof (mng_ani_basi), - mng_free_obj_general, - mng_process_ani_basi, - &pTemp); - if (iRetcode) - return iRetcode; - pBASI = (mng_ani_basip)pTemp; -#else - MNG_ALLOC (pData, pBASI, sizeof (mng_ani_basi)); - - pBASI->sHeader.fCleanup = mng_free_ani_basi; - pBASI->sHeader.fProcess = mng_process_ani_basi; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pBASI); - -#ifndef MNG_OPTIMIZE_CHUNKREADER - pBASI->iRed = iRed; - pBASI->iGreen = iGreen; - pBASI->iBlue = iBlue; - pBASI->bHasalpha = bHasalpha; - pBASI->iAlpha = iAlpha; - pBASI->iViewable = iViewable; -#else - pBASI->iRed = ((mng_basip)pChunk)->iRed; - pBASI->iGreen = ((mng_basip)pChunk)->iGreen; - pBASI->iBlue = ((mng_basip)pChunk)->iBlue; - pBASI->bHasalpha = ((mng_basip)pChunk)->bHasalpha; - pBASI->iAlpha = ((mng_basip)pChunk)->iAlpha; - pBASI->iViewable = ((mng_basip)pChunk)->iViewable; -#endif - } - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS -#ifndef MNG_OPTIMIZE_CHUNKREADER - iRetcode = mng_process_display_basi (pData, iRed, iGreen, iBlue, - bHasalpha, iAlpha, iViewable); -#else - iRetcode = mng_process_display_basi (pData, - ((mng_basip)pChunk)->iRed, - ((mng_basip)pChunk)->iGreen, - ((mng_basip)pChunk)->iBlue, - ((mng_basip)pChunk)->bHasalpha, - ((mng_basip)pChunk)->iAlpha, - ((mng_basip)pChunk)->iViewable); -#endif -#else -#ifndef MNG_OPTIMIZE_CHUNKREADER - pData->iBASIred = iRed; - pData->iBASIgreen = iGreen; - pData->iBASIblue = iBlue; - pData->bBASIhasalpha = bHasalpha; - pData->iBASIalpha = iAlpha; - pData->iBASIviewable = iViewable; -#else - pData->iBASIred = ((mng_basip)pChunk)->iRed; - pData->iBASIgreen = ((mng_basip)pChunk)->iGreen; - pData->iBASIblue = ((mng_basip)pChunk)->iBlue; - pData->bBASIhasalpha = ((mng_basip)pChunk)->bHasalpha; - pData->iBASIalpha = ((mng_basip)pChunk)->iAlpha; - pData->iBASIviewable = ((mng_basip)pChunk)->iViewable; -#endif - - iRetcode = mng_process_display_basi (pData); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_BASI, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_OBJCLEANUP -mng_retcode mng_free_ani_basi (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_BASI, MNG_LC_START); -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_basi)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_BASI, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_basi (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_basip pBASI = (mng_ani_basip)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_BASI, MNG_LC_START); -#endif - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - iRetcode = mng_process_display_basi (pData, pBASI->iRed, pBASI->iGreen, pBASI->iBlue, - pBASI->bHasalpha, pBASI->iAlpha, pBASI->iViewable); -#else - pData->iBASIred = pBASI->iRed; - pData->iBASIgreen = pBASI->iGreen; - pData->iBASIblue = pBASI->iBlue; - pData->bBASIhasalpha = pBASI->bHasalpha; - pData->iBASIalpha = pBASI->iAlpha; - pData->iBASIviewable = pBASI->iViewable; - - iRetcode = mng_process_display_basi (pData); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_BASI, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_CLON -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_create_ani_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 iLocatype, - mng_int32 iLocax, - mng_int32 iLocay) -#else -mng_retcode mng_create_ani_clon (mng_datap pData, - mng_chunkp pChunk) -#endif -{ - mng_ani_clonp pCLON; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_CLON, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_ptr pTemp; - iRetcode = create_obj_general (pData, sizeof (mng_ani_clon), - mng_free_obj_general, - mng_process_ani_clon, - &pTemp); - if (iRetcode) - return iRetcode; - pCLON = (mng_ani_clonp)pTemp; -#else - MNG_ALLOC (pData, pCLON, sizeof (mng_ani_clon)); - - pCLON->sHeader.fCleanup = mng_free_ani_clon; - pCLON->sHeader.fProcess = mng_process_ani_clon; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pCLON); - -#ifndef MNG_OPTIMIZE_CHUNKREADER - pCLON->iSourceid = iSourceid; - pCLON->iCloneid = iCloneid; - pCLON->iClonetype = iClonetype; - pCLON->bHasdonotshow = bHasdonotshow; - pCLON->iDonotshow = iDonotshow; - pCLON->iConcrete = iConcrete; - pCLON->bHasloca = bHasloca; - pCLON->iLocatype = iLocatype; - pCLON->iLocax = iLocax; - pCLON->iLocay = iLocay; -#else - pCLON->iSourceid = ((mng_clonp)pChunk)->iSourceid; - pCLON->iCloneid = ((mng_clonp)pChunk)->iCloneid; - pCLON->iClonetype = ((mng_clonp)pChunk)->iClonetype; - pCLON->bHasdonotshow = ((mng_clonp)pChunk)->bHasdonotshow; - pCLON->iDonotshow = ((mng_clonp)pChunk)->iDonotshow; - pCLON->iConcrete = ((mng_clonp)pChunk)->iConcrete; - pCLON->bHasloca = ((mng_clonp)pChunk)->bHasloca; - pCLON->iLocatype = ((mng_clonp)pChunk)->iLocationtype; - pCLON->iLocax = ((mng_clonp)pChunk)->iLocationx; - pCLON->iLocay = ((mng_clonp)pChunk)->iLocationy; -#endif - } - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS -#ifndef MNG_OPTIMIZE_CHUNKREADER - iRetcode = mng_process_display_clon (pData, iSourceid, iCloneid, iClonetype, - bHasdonotshow, iDonotshow, iConcrete, - bHasloca, iLocatype, iLocax, iLocay); -#else - iRetcode = mng_process_display_clon (pData, - ((mng_clonp)pChunk)->iSourceid, - ((mng_clonp)pChunk)->iCloneid, - ((mng_clonp)pChunk)->iClonetype, - ((mng_clonp)pChunk)->bHasdonotshow, - ((mng_clonp)pChunk)->iDonotshow, - ((mng_clonp)pChunk)->iConcrete, - ((mng_clonp)pChunk)->bHasloca, - ((mng_clonp)pChunk)->iLocationtype, - ((mng_clonp)pChunk)->iLocationx, - ((mng_clonp)pChunk)->iLocationy); -#endif -#else -#ifndef MNG_OPTIMIZE_CHUNKREADER - pData->iCLONsourceid = iSourceid; - pData->iCLONcloneid = iCloneid; - pData->iCLONclonetype = iClonetype; - pData->bCLONhasdonotshow = bHasdonotshow; - pData->iCLONdonotshow = iDonotshow; - pData->iCLONconcrete = iConcrete; - pData->bCLONhasloca = bHasloca; - pData->iCLONlocationtype = iLocatype; - pData->iCLONlocationx = iLocax; - pData->iCLONlocationy = iLocay; -#else - pData->iCLONsourceid = ((mng_clonp)pChunk)->iSourceid; - pData->iCLONcloneid = ((mng_clonp)pChunk)->iCloneid; - pData->iCLONclonetype = ((mng_clonp)pChunk)->iClonetype; - pData->bCLONhasdonotshow = ((mng_clonp)pChunk)->bHasdonotshow; - pData->iCLONdonotshow = ((mng_clonp)pChunk)->iDonotshow; - pData->iCLONconcrete = ((mng_clonp)pChunk)->iConcrete; - pData->bCLONhasloca = ((mng_clonp)pChunk)->bHasloca; - pData->iCLONlocationtype = ((mng_clonp)pChunk)->iLocationtype; - pData->iCLONlocationx = ((mng_clonp)pChunk)->iLocationx; - pData->iCLONlocationy = ((mng_clonp)pChunk)->iLocationy; -#endif - - iRetcode = mng_process_display_clon (pData); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_CLON, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_OBJCLEANUP -mng_retcode mng_free_ani_clon (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_CLON, MNG_LC_START); -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_clon)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_CLON, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_clon (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_clonp pCLON = (mng_ani_clonp)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_CLON, MNG_LC_START); -#endif - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - iRetcode = mng_process_display_clon (pData, pCLON->iSourceid, pCLON->iCloneid, - pCLON->iClonetype, pCLON->bHasdonotshow, - pCLON->iDonotshow, pCLON->iConcrete, - pCLON->bHasloca, pCLON->iLocatype, - pCLON->iLocax, pCLON->iLocay); -#else - pData->iCLONcloneid = pCLON->iCloneid; - pData->iCLONsourceid = pCLON->iSourceid; - pData->iCLONclonetype = pCLON->iClonetype; - pData->bCLONhasdonotshow = pCLON->bHasdonotshow; - pData->iCLONdonotshow = pCLON->iDonotshow; - pData->iCLONconcrete = pCLON->iConcrete; - pData->bCLONhasloca = pCLON->bHasloca; - pData->iCLONlocationtype = pCLON->iLocatype; - pData->iCLONlocationx = pCLON->iLocax; - pData->iCLONlocationy = pCLON->iLocay; - - iRetcode = mng_process_display_clon (pData); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_CLON, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_BACK -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_create_ani_back (mng_datap pData, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint8 iMandatory, - mng_uint16 iImageid, - mng_uint8 iTile) -#else -mng_retcode mng_create_ani_back (mng_datap pData) -#endif -{ - mng_ani_backp pBACK; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_BACK, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_ptr pTemp; - mng_retcode iRetcode = create_obj_general (pData, sizeof (mng_ani_back), - mng_free_obj_general, - mng_process_ani_back, - &pTemp); - if (iRetcode) - return iRetcode; - pBACK = (mng_ani_backp)pTemp; -#else - MNG_ALLOC (pData, pBACK, sizeof (mng_ani_back)); - - pBACK->sHeader.fCleanup = mng_free_ani_back; - pBACK->sHeader.fProcess = mng_process_ani_back; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pBACK); - -#ifndef MNG_OPTIMIZE_CHUNKREADER - pBACK->iRed = iRed; - pBACK->iGreen = iGreen; - pBACK->iBlue = iBlue; - pBACK->iMandatory = iMandatory; - pBACK->iImageid = iImageid; - pBACK->iTile = iTile; -#else - pBACK->iRed = pData->iBACKred; - pBACK->iGreen = pData->iBACKgreen; - pBACK->iBlue = pData->iBACKblue; - pBACK->iMandatory = pData->iBACKmandatory; - pBACK->iImageid = pData->iBACKimageid; - pBACK->iTile = pData->iBACKtile; -#endif - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_BACK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_OBJCLEANUP -mng_retcode mng_free_ani_back (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_BACK, MNG_LC_START); -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_back)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_BACK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_back (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_backp pBACK = (mng_ani_backp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_BACK, MNG_LC_START); -#endif - - pData->iBACKred = pBACK->iRed; - pData->iBACKgreen = pBACK->iGreen; - pData->iBACKblue = pBACK->iBlue; - pData->iBACKmandatory = pBACK->iMandatory; - pData->iBACKimageid = pBACK->iImageid; - pData->iBACKtile = pBACK->iTile; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_BACK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_FRAM -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_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) -#else -mng_retcode mng_create_ani_fram (mng_datap pData, - mng_chunkp pChunk) -#endif -{ - mng_ani_framp pFRAM; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_FRAM, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_ptr pTemp; - iRetcode = create_obj_general (pData, sizeof (mng_ani_fram), - mng_free_obj_general, - mng_process_ani_fram, - &pTemp); - if (iRetcode) - return iRetcode; - pFRAM = (mng_ani_framp)pTemp; -#else - MNG_ALLOC (pData, pFRAM, sizeof (mng_ani_fram)); - - pFRAM->sHeader.fCleanup = mng_free_ani_fram; - pFRAM->sHeader.fProcess = mng_process_ani_fram; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pFRAM); - -#ifndef MNG_OPTIMIZE_CHUNKREADER - pFRAM->iFramemode = iFramemode; - pFRAM->iChangedelay = iChangedelay; - pFRAM->iDelay = iDelay; - pFRAM->iChangetimeout = iChangetimeout; - pFRAM->iTimeout = iTimeout; - pFRAM->iChangeclipping = iChangeclipping; - pFRAM->iCliptype = iCliptype; - pFRAM->iClipl = iClipl; - pFRAM->iClipr = iClipr; - pFRAM->iClipt = iClipt; - pFRAM->iClipb = iClipb; -#else - pFRAM->iFramemode = ((mng_framp)pChunk)->iMode; - pFRAM->iChangedelay = ((mng_framp)pChunk)->iChangedelay; - pFRAM->iDelay = ((mng_framp)pChunk)->iDelay; - pFRAM->iChangetimeout = ((mng_framp)pChunk)->iChangetimeout; - pFRAM->iTimeout = ((mng_framp)pChunk)->iTimeout; - pFRAM->iChangeclipping = ((mng_framp)pChunk)->iChangeclipping; - pFRAM->iCliptype = ((mng_framp)pChunk)->iBoundarytype; - pFRAM->iClipl = ((mng_framp)pChunk)->iBoundaryl; - pFRAM->iClipr = ((mng_framp)pChunk)->iBoundaryr; - pFRAM->iClipt = ((mng_framp)pChunk)->iBoundaryt; - pFRAM->iClipb = ((mng_framp)pChunk)->iBoundaryb; -#endif - } - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS -#ifndef MNG_OPTIMIZE_CHUNKREADER - iRetcode = mng_process_display_fram (pData, iFramemode, - iChangedelay, iDelay, - iChangetimeout, iTimeout, - iChangeclipping, iCliptype, - iClipl, iClipr, - iClipt, iClipb); -#else - iRetcode = mng_process_display_fram (pData, - ((mng_framp)pChunk)->iMode, - ((mng_framp)pChunk)->iChangedelay, - ((mng_framp)pChunk)->iDelay, - ((mng_framp)pChunk)->iChangetimeout, - ((mng_framp)pChunk)->iTimeout, - ((mng_framp)pChunk)->iChangeclipping, - ((mng_framp)pChunk)->iBoundarytype, - ((mng_framp)pChunk)->iBoundaryl, - ((mng_framp)pChunk)->iBoundaryr, - ((mng_framp)pChunk)->iBoundaryt, - ((mng_framp)pChunk)->iBoundaryb); -#endif -#else -#ifndef MNG_OPTIMIZE_CHUNKREADER - pData->iTempFramemode = iFramemode; - pData->iTempChangedelay = iChangedelay; - pData->iTempDelay = iDelay; - pData->iTempChangetimeout = iChangetimeout; - pData->iTempTimeout = iTimeout; - pData->iTempChangeclipping = iChangeclipping; - pData->iTempCliptype = iCliptype; - pData->iTempClipl = iClipl; - pData->iTempClipr = iClipr; - pData->iTempClipt = iClipt; - pData->iTempClipb = iClipb; -#else - pData->iTempFramemode = ((mng_framp)pChunk)->iMode; - pData->iTempChangedelay = ((mng_framp)pChunk)->iChangedelay; - pData->iTempDelay = ((mng_framp)pChunk)->iDelay; - pData->iTempChangetimeout = ((mng_framp)pChunk)->iChangetimeout; - pData->iTempTimeout = ((mng_framp)pChunk)->iTimeout; - pData->iTempChangeclipping = ((mng_framp)pChunk)->iChangeclipping; - pData->iTempCliptype = ((mng_framp)pChunk)->iBoundarytype; - pData->iTempClipl = ((mng_framp)pChunk)->iBoundaryl; - pData->iTempClipr = ((mng_framp)pChunk)->iBoundaryr; - pData->iTempClipt = ((mng_framp)pChunk)->iBoundaryt; - pData->iTempClipb = ((mng_framp)pChunk)->iBoundaryb; -#endif - - iRetcode = mng_process_display_fram (pData); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_FRAM, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_OBJCLEANUP -mng_retcode mng_free_ani_fram (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_FRAM, MNG_LC_START); -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_fram)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_FRAM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_fram (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_framp pFRAM = (mng_ani_framp)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_FRAM, MNG_LC_START); -#endif - - if (pData->iBreakpoint) /* previously broken ? */ - { - iRetcode = mng_process_display_fram2 (pData); - pData->iBreakpoint = 0; /* not again */ - } - else - { -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - iRetcode = mng_process_display_fram (pData, pFRAM->iFramemode, - pFRAM->iChangedelay, pFRAM->iDelay, - pFRAM->iChangetimeout, pFRAM->iTimeout, - pFRAM->iChangeclipping, pFRAM->iCliptype, - pFRAM->iClipl, pFRAM->iClipr, - pFRAM->iClipt, pFRAM->iClipb); -#else - pData->iTempFramemode = pFRAM->iFramemode; - pData->iTempChangedelay = pFRAM->iChangedelay; - pData->iTempDelay = pFRAM->iDelay; - pData->iTempChangetimeout = pFRAM->iChangetimeout; - pData->iTempTimeout = pFRAM->iTimeout; - pData->iTempChangeclipping = pFRAM->iChangeclipping; - pData->iTempCliptype = pFRAM->iCliptype; - pData->iTempClipl = pFRAM->iClipl; - pData->iTempClipr = pFRAM->iClipr; - pData->iTempClipt = pFRAM->iClipt; - pData->iTempClipb = pFRAM->iClipb; - - iRetcode = mng_process_display_fram (pData); -#endif - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_FRAM, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_MOVE -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_create_ani_move (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iType, - mng_int32 iLocax, - mng_int32 iLocay) -#else -mng_retcode mng_create_ani_move (mng_datap pData, - mng_chunkp pChunk) -#endif -{ - mng_ani_movep pMOVE; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_MOVE, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_ptr pTemp; - iRetcode = create_obj_general (pData, sizeof (mng_ani_move), - mng_free_obj_general, - mng_process_ani_move, - &pTemp); - if (iRetcode) - return iRetcode; - pMOVE = (mng_ani_movep)pTemp; -#else - MNG_ALLOC (pData, pMOVE, sizeof (mng_ani_move)); - - pMOVE->sHeader.fCleanup = mng_free_ani_move; - pMOVE->sHeader.fProcess = mng_process_ani_move; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pMOVE); - -#ifndef MNG_OPTIMIZE_CHUNKREADER - pMOVE->iFirstid = iFirstid; - pMOVE->iLastid = iLastid; - pMOVE->iType = iType; - pMOVE->iLocax = iLocax; - pMOVE->iLocay = iLocay; -#else - pMOVE->iFirstid = ((mng_movep)pChunk)->iFirstid; - pMOVE->iLastid = ((mng_movep)pChunk)->iLastid; - pMOVE->iType = ((mng_movep)pChunk)->iMovetype; - pMOVE->iLocax = ((mng_movep)pChunk)->iMovex; - pMOVE->iLocay = ((mng_movep)pChunk)->iMovey; -#endif - } - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS -#ifndef MNG_OPTIMIZE_CHUNKREADER - iRetcode = mng_process_display_move (pData, iFirstid, iLastid, - iType, iLocax, iLocay); -#else - iRetcode = mng_process_display_move (pData, - ((mng_movep)pChunk)->iFirstid, - ((mng_movep)pChunk)->iLastid, - ((mng_movep)pChunk)->iMovetype, - ((mng_movep)pChunk)->iMovex, - ((mng_movep)pChunk)->iMovey); -#endif -#else -#ifndef MNG_OPTIMIZE_CHUNKREADER - pData->iMOVEfromid = iFirstid; - pData->iMOVEtoid = iLastid; - pData->iMOVEmovetype = iType; - pData->iMOVEmovex = iLocax; - pData->iMOVEmovey = iLocay; -#else - pData->iMOVEfromid = ((mng_movep)pChunk)->iFirstid; - pData->iMOVEtoid = ((mng_movep)pChunk)->iLastid; - pData->iMOVEmovetype = ((mng_movep)pChunk)->iMovetype; - pData->iMOVEmovex = ((mng_movep)pChunk)->iMovex; - pData->iMOVEmovey = ((mng_movep)pChunk)->iMovey; -#endif - - iRetcode = mng_process_display_move (pData); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_MOVE, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_OBJCLEANUP -mng_retcode mng_free_ani_move (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_MOVE, MNG_LC_START); -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_move)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_MOVE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_move (mng_datap pData, - mng_objectp pObject) -{ - mng_retcode iRetcode; - mng_ani_movep pMOVE = (mng_ani_movep)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_MOVE, MNG_LC_START); -#endif - /* re-process the MOVE chunk */ -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - iRetcode = mng_process_display_move (pData, pMOVE->iFirstid, pMOVE->iLastid, - pMOVE->iType, pMOVE->iLocax, pMOVE->iLocay); -#else - pData->iMOVEfromid = pMOVE->iFirstid; - pData->iMOVEtoid = pMOVE->iLastid; - pData->iMOVEmovetype = pMOVE->iType; - pData->iMOVEmovex = pMOVE->iLocax; - pData->iMOVEmovey = pMOVE->iLocay; - - iRetcode = mng_process_display_move (pData); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_MOVE, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_CLIP -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_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) -#else -mng_retcode mng_create_ani_clip (mng_datap pData, - mng_chunkp pChunk) -#endif -{ - mng_ani_clipp pCLIP; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_CLIP, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_ptr pTemp; - iRetcode = create_obj_general (pData, sizeof (mng_ani_clip), - mng_free_obj_general, - mng_process_ani_clip, - &pTemp); - if (iRetcode) - return iRetcode; - pCLIP = (mng_ani_clipp)pTemp; -#else - MNG_ALLOC (pData, pCLIP, sizeof (mng_ani_clip)); - - pCLIP->sHeader.fCleanup = mng_free_ani_clip; - pCLIP->sHeader.fProcess = mng_process_ani_clip; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pCLIP); - -#ifndef MNG_OPTIMIZE_CHUNKREADER - pCLIP->iFirstid = iFirstid; - pCLIP->iLastid = iLastid; - pCLIP->iType = iType; - pCLIP->iClipl = iClipl; - pCLIP->iClipr = iClipr; - pCLIP->iClipt = iClipt; - pCLIP->iClipb = iClipb; -#else - pCLIP->iFirstid = ((mng_clipp)pChunk)->iFirstid; - pCLIP->iLastid = ((mng_clipp)pChunk)->iLastid; - pCLIP->iType = ((mng_clipp)pChunk)->iCliptype; - pCLIP->iClipl = ((mng_clipp)pChunk)->iClipl; - pCLIP->iClipr = ((mng_clipp)pChunk)->iClipr; - pCLIP->iClipt = ((mng_clipp)pChunk)->iClipt; - pCLIP->iClipb = ((mng_clipp)pChunk)->iClipb; -#endif - } - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS -#ifndef MNG_OPTIMIZE_CHUNKREADER - iRetcode = mng_process_display_clip (pData, iFirstid, iLastid, - iType, iClipl, iClipr, - iClipt, iClipb); -#else - iRetcode = mng_process_display_clip (pData, - ((mng_clipp)pChunk)->iFirstid, - ((mng_clipp)pChunk)->iLastid, - ((mng_clipp)pChunk)->iCliptype, - ((mng_clipp)pChunk)->iClipl, - ((mng_clipp)pChunk)->iClipr, - ((mng_clipp)pChunk)->iClipt, - ((mng_clipp)pChunk)->iClipb); -#endif -#else -#ifndef MNG_OPTIMIZE_CHUNKREADER - pData->iCLIPfromid = iFirstid; - pData->iCLIPtoid = iLastid; - pData->iCLIPcliptype = iType; - pData->iCLIPclipl = iClipl; - pData->iCLIPclipr = iClipr; - pData->iCLIPclipt = iClipt; - pData->iCLIPclipb = iClipb; -#else - pData->iCLIPfromid = ((mng_clipp)pChunk)->iFirstid; - pData->iCLIPtoid = ((mng_clipp)pChunk)->iLastid; - pData->iCLIPcliptype = ((mng_clipp)pChunk)->iCliptype; - pData->iCLIPclipl = ((mng_clipp)pChunk)->iClipl; - pData->iCLIPclipr = ((mng_clipp)pChunk)->iClipr; - pData->iCLIPclipt = ((mng_clipp)pChunk)->iClipt; - pData->iCLIPclipb = ((mng_clipp)pChunk)->iClipb; -#endif - - iRetcode = mng_process_display_clip (pData); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_CLIP, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_OBJCLEANUP -mng_retcode mng_free_ani_clip (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_CLIP, MNG_LC_START); -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_clip)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_CLIP, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_clip (mng_datap pData, - mng_objectp pObject) -{ - mng_retcode iRetcode; - mng_ani_clipp pCLIP = (mng_ani_clipp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_CLIP, MNG_LC_START); -#endif - /* re-process the CLIP chunk */ -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - iRetcode = mng_process_display_clip (pData, pCLIP->iFirstid, pCLIP->iLastid, - pCLIP->iType, pCLIP->iClipl, pCLIP->iClipr, - pCLIP->iClipt, pCLIP->iClipb); -#else - pData->iCLIPfromid = pCLIP->iFirstid; - pData->iCLIPtoid = pCLIP->iLastid; - pData->iCLIPcliptype = pCLIP->iType; - pData->iCLIPclipl = pCLIP->iClipl; - pData->iCLIPclipr = pCLIP->iClipr; - pData->iCLIPclipt = pCLIP->iClipt; - pData->iCLIPclipb = pCLIP->iClipb; - - iRetcode = mng_process_display_clip (pData); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_CLIP, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SHOW -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_create_ani_show (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iMode) -#else -mng_retcode mng_create_ani_show (mng_datap pData) -#endif -{ - mng_ani_showp pSHOW; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_SHOW, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_ptr pTemp; - mng_retcode iRetcode = create_obj_general (pData, sizeof (mng_ani_show), - mng_free_obj_general, - mng_process_ani_show, - &pTemp); - if (iRetcode) - return iRetcode; - pSHOW = (mng_ani_showp)pTemp; -#else - MNG_ALLOC (pData, pSHOW, sizeof (mng_ani_show)); - - pSHOW->sHeader.fCleanup = mng_free_ani_show; - pSHOW->sHeader.fProcess = mng_process_ani_show; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pSHOW); - -#ifndef MNG_OPTIMIZE_CHUNKREADER - pSHOW->iFirstid = iFirstid; - pSHOW->iLastid = iLastid; - pSHOW->iMode = iMode; -#else - pSHOW->iFirstid = pData->iSHOWfromid; - pSHOW->iLastid = pData->iSHOWtoid; - pSHOW->iMode = pData->iSHOWmode; -#endif - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_SHOW, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_OBJCLEANUP -mng_retcode mng_free_ani_show (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_SHOW, MNG_LC_START); -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_show)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_SHOW, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_show (mng_datap pData, - mng_objectp pObject) -{ - mng_retcode iRetcode; - mng_ani_showp pSHOW = (mng_ani_showp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_SHOW, MNG_LC_START); -#endif - - if (pData->iBreakpoint) /* returning from breakpoint ? */ - { - iRetcode = mng_process_display_show (pData); - } - else - { /* "re-run" SHOW chunk */ - pData->iSHOWmode = pSHOW->iMode; - pData->iSHOWfromid = pSHOW->iFirstid; - pData->iSHOWtoid = pSHOW->iLastid; - - iRetcode = mng_process_display_show (pData); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_SHOW, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_TERM -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_create_ani_term (mng_datap pData, - mng_uint8 iTermaction, - mng_uint8 iIteraction, - mng_uint32 iDelay, - mng_uint32 iItermax) -#else -mng_retcode mng_create_ani_term (mng_datap pData, - mng_chunkp pChunk) -#endif -{ - mng_ani_termp pTERM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_TERM, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_ptr pTemp; - mng_retcode iRetcode = create_obj_general (pData, sizeof (mng_ani_term), - mng_free_obj_general, - mng_process_ani_term, - &pTemp); - if (iRetcode) - return iRetcode; - pTERM = (mng_ani_termp)pTemp; -#else - MNG_ALLOC (pData, pTERM, sizeof (mng_ani_term)); - - pTERM->sHeader.fCleanup = mng_free_ani_term; - pTERM->sHeader.fProcess = mng_process_ani_term; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pTERM); - -#ifndef MNG_OPTIMIZE_CHUNKREADER - pTERM->iTermaction = iTermaction; - pTERM->iIteraction = iIteraction; - pTERM->iDelay = iDelay; - pTERM->iItermax = iItermax; -#else - pTERM->iTermaction = ((mng_termp)pChunk)->iTermaction; - pTERM->iIteraction = ((mng_termp)pChunk)->iIteraction; - pTERM->iDelay = ((mng_termp)pChunk)->iDelay; - pTERM->iItermax = ((mng_termp)pChunk)->iItermax; -#endif - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_TERM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_OBJCLEANUP -mng_retcode mng_free_ani_term (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_TERM, MNG_LC_START); -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_term)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_TERM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_term (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_TERM, MNG_LC_START); -#endif - - /* dummy: no action required! */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_TERM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SAVE -mng_retcode mng_create_ani_save (mng_datap pData) -{ - mng_ptr pTemp; - mng_ani_savep pSAVE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_SAVE, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_retcode iRetcode = create_obj_general (pData, sizeof (mng_ani_save), - mng_free_obj_general, - mng_process_ani_save, - &pTemp); - if (iRetcode) - return iRetcode; - pSAVE = (mng_ani_savep)pTemp; -#else - MNG_ALLOC (pData, pSAVE, sizeof (mng_ani_save)); - - pSAVE->sHeader.fCleanup = mng_free_ani_save; - pSAVE->sHeader.fProcess = mng_process_ani_save; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pSAVE); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_SAVE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_OBJCLEANUP -mng_retcode mng_free_ani_save (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_SAVE, MNG_LC_START); -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_save)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_SAVE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_save (mng_datap pData, - mng_objectp pObject) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_SAVE, MNG_LC_START); -#endif - - iRetcode = mng_process_display_save (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_SAVE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_SEEK -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_create_ani_seek (mng_datap pData, - mng_uint32 iSegmentnamesize, - mng_pchar zSegmentname) -#else -mng_retcode mng_create_ani_seek (mng_datap pData, - mng_chunkp pChunk) -#endif -{ - mng_ptr pTemp; - mng_ani_seekp pSEEK; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_SEEK, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_retcode iRetcode = create_obj_general (pData, sizeof (mng_ani_seek), - mng_free_ani_seek, - mng_process_ani_seek, - &pTemp); - if (iRetcode) - return iRetcode; - pSEEK = (mng_ani_seekp)pTemp; -#else - MNG_ALLOC (pData, pSEEK, sizeof (mng_ani_seek)); - - pSEEK->sHeader.fCleanup = mng_free_ani_seek; - pSEEK->sHeader.fProcess = mng_process_ani_seek; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pSEEK); - - pData->pLastseek = (mng_objectp)pSEEK; - -#ifndef MNG_OPTIMIZE_CHUNKREADER - pSEEK->iSegmentnamesize = iSegmentnamesize; - if (iSegmentnamesize) - { - MNG_ALLOC (pData, pSEEK->zSegmentname, iSegmentnamesize + 1); - MNG_COPY (pSEEK->zSegmentname, zSegmentname, iSegmentnamesize); - } -#else - pSEEK->iSegmentnamesize = ((mng_seekp)pChunk)->iNamesize; - if (pSEEK->iSegmentnamesize) - { - MNG_ALLOC (pData, pSEEK->zSegmentname, pSEEK->iSegmentnamesize + 1); - MNG_COPY (pSEEK->zSegmentname, ((mng_seekp)pChunk)->zName, pSEEK->iSegmentnamesize); - } -#endif - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_SEEK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_free_ani_seek (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_seekp pSEEK = (mng_ani_seekp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_SEEK, MNG_LC_START); -#endif - - if (pSEEK->iSegmentnamesize) - MNG_FREEX (pData, pSEEK->zSegmentname, pSEEK->iSegmentnamesize + 1); - -#ifndef MNG_OPTIMIZE_OBJCLEANUP - MNG_FREEX (pData, pObject, sizeof (mng_ani_seek)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_SEEK, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_OBJCLEANUP - return MNG_NOERROR; -#else - return mng_free_obj_general(pData, pObject); -#endif -} - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_seek (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_seekp pSEEK = (mng_ani_seekp)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_SEEK, MNG_LC_START); -#endif - -#ifdef MNG_SUPPORT_DYNAMICMNG - if (!pData->bStopafterseek) /* can we really process this one ? */ -#endif - { - pData->pLastseek = pObject; - - if (pData->fProcessseek) /* inform the app ? */ - { - mng_bool bOke; - mng_pchar zName; - - MNG_ALLOC (pData, zName, pSEEK->iSegmentnamesize + 1); - - if (pSEEK->iSegmentnamesize) - MNG_COPY (zName, pSEEK->zSegmentname, pSEEK->iSegmentnamesize); - - bOke = pData->fProcessseek ((mng_handle)pData, zName); - - MNG_FREEX (pData, zName, pSEEK->iSegmentnamesize + 1); - - if (!bOke) - MNG_ERROR (pData, MNG_APPMISCERROR); - } - } - - iRetcode = mng_process_display_seek (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_SEEK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_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) -#else -mng_retcode mng_create_ani_dhdr (mng_datap pData, - mng_chunkp pChunk) -#endif -{ - mng_ani_dhdrp pDHDR; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_DHDR, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_ptr pTemp; - iRetcode = create_obj_general (pData, sizeof (mng_ani_dhdr), - mng_free_obj_general, - mng_process_ani_dhdr, - &pTemp); - if (iRetcode) - return iRetcode; - pDHDR = (mng_ani_dhdrp)pTemp; -#else - MNG_ALLOC (pData, pDHDR, sizeof (mng_ani_dhdr)); - - pDHDR->sHeader.fCleanup = mng_free_ani_dhdr; - pDHDR->sHeader.fProcess = mng_process_ani_dhdr; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pDHDR); - -#ifndef MNG_OPTIMIZE_CHUNKREADER - pDHDR->iObjectid = iObjectid; - pDHDR->iImagetype = iImagetype; - pDHDR->iDeltatype = iDeltatype; - pDHDR->iBlockwidth = iBlockwidth; - pDHDR->iBlockheight = iBlockheight; - pDHDR->iBlockx = iBlockx; - pDHDR->iBlocky = iBlocky; -#else - pDHDR->iObjectid = ((mng_dhdrp)pChunk)->iObjectid; - pDHDR->iImagetype = ((mng_dhdrp)pChunk)->iImagetype; - pDHDR->iDeltatype = ((mng_dhdrp)pChunk)->iDeltatype; - pDHDR->iBlockwidth = ((mng_dhdrp)pChunk)->iBlockwidth; - pDHDR->iBlockheight = ((mng_dhdrp)pChunk)->iBlockheight; - pDHDR->iBlockx = ((mng_dhdrp)pChunk)->iBlockx; - pDHDR->iBlocky = ((mng_dhdrp)pChunk)->iBlocky; -#endif - } - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS -#ifndef MNG_OPTIMIZE_CHUNKREADER - iRetcode = mng_process_display_dhdr (pData, iObjectid, - iImagetype, iDeltatype, - iBlockwidth, iBlockheight, - iBlockx, iBlocky); -#else - iRetcode = mng_process_display_dhdr (pData, - ((mng_dhdrp)pChunk)->iObjectid, - ((mng_dhdrp)pChunk)->iImagetype, - ((mng_dhdrp)pChunk)->iDeltatype, - ((mng_dhdrp)pChunk)->iBlockwidth, - ((mng_dhdrp)pChunk)->iBlockheight, - ((mng_dhdrp)pChunk)->iBlockx, - ((mng_dhdrp)pChunk)->iBlocky); -#endif -#else -#ifndef MNG_OPTIMIZE_CHUNKREADER - pData->iDHDRobjectid = iObjectid; - pData->iDHDRimagetype = iImagetype; - pData->iDHDRdeltatype = iDeltatype; - pData->iDHDRblockwidth = iBlockwidth; - pData->iDHDRblockheight = iBlockheight; - pData->iDHDRblockx = iBlockx; - pData->iDHDRblocky = iBlocky; -#else - pData->iDHDRobjectid = ((mng_dhdrp)pChunk)->iObjectid; - pData->iDHDRimagetype = ((mng_dhdrp)pChunk)->iImagetype; - pData->iDHDRdeltatype = ((mng_dhdrp)pChunk)->iDeltatype; - pData->iDHDRblockwidth = ((mng_dhdrp)pChunk)->iBlockwidth; - pData->iDHDRblockheight = ((mng_dhdrp)pChunk)->iBlockheight; - pData->iDHDRblockx = ((mng_dhdrp)pChunk)->iBlockx; - pData->iDHDRblocky = ((mng_dhdrp)pChunk)->iBlocky; -#endif - - iRetcode = mng_process_display_dhdr (pData); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_DHDR, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_OBJCLEANUP -mng_retcode mng_free_ani_dhdr (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_DHDR, MNG_LC_START); -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_dhdr)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_DHDR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_dhdr (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_dhdrp pDHDR = (mng_ani_dhdrp)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_DHDR, MNG_LC_START); -#endif - - pData->bHasDHDR = MNG_TRUE; /* let everyone know we're inside a DHDR */ - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - iRetcode = mng_process_display_dhdr (pData, pDHDR->iObjectid, - pDHDR->iImagetype, pDHDR->iDeltatype, - pDHDR->iBlockwidth, pDHDR->iBlockheight, - pDHDR->iBlockx, pDHDR->iBlocky); -#else - pData->iDHDRobjectid = pDHDR->iObjectid; - pData->iDHDRimagetype = pDHDR->iImagetype; - pData->iDHDRdeltatype = pDHDR->iDeltatype; - pData->iDHDRblockwidth = pDHDR->iBlockwidth; - pData->iDHDRblockheight = pDHDR->iBlockheight; - pData->iDHDRblockx = pDHDR->iBlockx; - pData->iDHDRblocky = pDHDR->iBlocky; - - iRetcode = mng_process_display_dhdr (pData); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_DHDR, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_create_ani_prom (mng_datap pData, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iFilltype) -#else -mng_retcode mng_create_ani_prom (mng_datap pData, - mng_chunkp pChunk) -#endif -{ - mng_ani_promp pPROM=NULL; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_PROM, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_ptr pTemp; - iRetcode = create_obj_general (pData, sizeof (mng_ani_prom), - mng_free_obj_general, - mng_process_ani_prom, - &pTemp); - if (iRetcode) - return iRetcode; - pPROM = (mng_ani_promp)pTemp; -#else - MNG_ALLOC (pData, pPROM, sizeof (mng_ani_prom)); - - pPROM->sHeader.fCleanup = mng_free_ani_prom; - pPROM->sHeader.fProcess = mng_process_ani_prom; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pPROM); - -#ifndef MNG_OPTIMIZE_CHUNKREADER - pPROM->iBitdepth = iBitdepth; - pPROM->iColortype = iColortype; - pPROM->iFilltype = iFilltype; -#else - pPROM->iBitdepth = ((mng_promp)pChunk)->iSampledepth; - pPROM->iColortype = ((mng_promp)pChunk)->iColortype; - pPROM->iFilltype = ((mng_promp)pChunk)->iFilltype; -#endif - } - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS -#ifndef MNG_OPTIMIZE_CHUNKREADER - iRetcode = mng_process_display_prom (pData, iBitdepth, - iColortype, iFilltype); -#else - iRetcode = mng_process_display_prom (pData, - ((mng_promp)pChunk)->iSampledepth, - ((mng_promp)pChunk)->iColortype, - ((mng_promp)pChunk)->iFilltype); -#endif -#else -#ifndef MNG_OPTIMIZE_CHUNKREADER - pData->iPROMbitdepth = iBitdepth; - pData->iPROMcolortype = iColortype; - pData->iPROMfilltype = iFilltype; -#else - pData->iPROMbitdepth = ((mng_promp)pChunk)->iSampledepth; - pData->iPROMcolortype = ((mng_promp)pChunk)->iColortype; - pData->iPROMfilltype = ((mng_promp)pChunk)->iFilltype; -#endif - - iRetcode = mng_process_display_prom (pData); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_PROM, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_OBJCLEANUP -mng_retcode mng_free_ani_prom (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_PROM, MNG_LC_START); -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_prom)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_PROM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_prom (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_promp pPROM = (mng_ani_promp)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_PROM, MNG_LC_START); -#endif - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - iRetcode = mng_process_display_prom (pData, pPROM->iBitdepth, - pPROM->iColortype, pPROM->iFilltype); -#else - pData->iPROMbitdepth = pPROM->iBitdepth; - pData->iPROMcolortype = pPROM->iColortype; - pData->iPROMfilltype = pPROM->iFilltype; - - iRetcode = mng_process_display_prom (pData); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_PROM, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -mng_retcode mng_create_ani_ipng (mng_datap pData) -{ - mng_ani_ipngp pIPNG; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_IPNG, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_ptr pTemp; - mng_retcode iRetcode = create_obj_general (pData, sizeof (mng_ani_ipng), - mng_free_obj_general, - mng_process_ani_ipng, - &pTemp); - if (iRetcode) - return iRetcode; - pIPNG = (mng_ani_ipngp)pTemp; -#else - MNG_ALLOC (pData, pIPNG, sizeof (mng_ani_ipng)); - - pIPNG->sHeader.fCleanup = mng_free_ani_ipng; - pIPNG->sHeader.fProcess = mng_process_ani_ipng; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pIPNG); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_IPNG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_OBJCLEANUP -mng_retcode mng_free_ani_ipng (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_IPNG, MNG_LC_START); -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_ipng)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_IPNG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_ipng (mng_datap pData, - mng_objectp pObject) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_IPNG, MNG_LC_START); -#endif - - iRetcode = mng_process_display_ipng (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_IPNG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifdef MNG_INCLUDE_JNG -mng_retcode mng_create_ani_ijng (mng_datap pData) -{ - mng_ani_ijngp pIJNG; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_IJNG, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_ptr pTemp; - mng_retcode iRetcode = create_obj_general (pData, sizeof (mng_ani_ijng), - mng_free_obj_general, - mng_process_ani_ijng, - &pTemp); - if (iRetcode) - return iRetcode; - pIJNG = (mng_ani_ijngp)pTemp; -#else - MNG_ALLOC (pData, pIJNG, sizeof (mng_ani_ijng)); - - pIJNG->sHeader.fCleanup = mng_free_ani_ijng; - pIJNG->sHeader.fProcess = mng_process_ani_ijng; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pIJNG); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_IJNG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_OBJCLEANUP -mng_retcode mng_free_ani_ijng (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_IJNG, MNG_LC_START); -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_ijng)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_IJNG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_ijng (mng_datap pData, - mng_objectp pObject) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_IJNG, MNG_LC_START); -#endif - - iRetcode = mng_process_display_ijng (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_IJNG, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -mng_retcode mng_create_ani_pplt (mng_datap pData, - mng_uint8 iType, - mng_uint32 iCount, - mng_palette8ep paIndexentries, - mng_uint8p paAlphaentries, - mng_uint8p paUsedentries) -{ - mng_ani_ppltp pPPLT; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_PPLT, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_ptr pTemp; - iRetcode = create_obj_general (pData, sizeof (mng_ani_pplt), - mng_free_obj_general, - mng_process_ani_pplt, - &pTemp); - if (iRetcode) - return iRetcode; - pPPLT = (mng_ani_ppltp)pTemp; -#else - MNG_ALLOC (pData, pPPLT, sizeof (mng_ani_pplt)); - - pPPLT->sHeader.fCleanup = mng_free_ani_pplt; - pPPLT->sHeader.fProcess = mng_process_ani_pplt; -#endif - - pPPLT->iType = iType; - pPPLT->iCount = iCount; - - MNG_COPY (pPPLT->aIndexentries, paIndexentries, sizeof (pPPLT->aIndexentries)); - MNG_COPY (pPPLT->aAlphaentries, paAlphaentries, sizeof (pPPLT->aAlphaentries)); - MNG_COPY (pPPLT->aUsedentries, paUsedentries, sizeof (pPPLT->aUsedentries )); - - mng_add_ani_object (pData, (mng_object_headerp)pPPLT); - } - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - iRetcode = mng_process_display_pplt (pData, iType, iCount, - paIndexentries, paAlphaentries, paUsedentries); -#else - pData->iPPLTtype = iType; - pData->iPPLTcount = iCount; - pData->paPPLTindexentries = paIndexentries; - pData->paPPLTalphaentries = paAlphaentries; - pData->paPPLTusedentries = paUsedentries; - - iRetcode = mng_process_display_pplt (pData); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_PPLT, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_OBJCLEANUP -mng_retcode mng_free_ani_pplt (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_PPLT, MNG_LC_START); -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_pplt)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_PPLT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_pplt (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_ppltp pPPLT = (mng_ani_ppltp)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_PPLT, MNG_LC_START); -#endif - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - iRetcode = mng_process_display_pplt (pData, pPPLT->iType, pPPLT->iCount, - pPPLT->aIndexentries, pPPLT->aAlphaentries, - pPPLT->aUsedentries); -#else - pData->iPPLTtype = pPPLT->iType; - pData->iPPLTcount = pPPLT->iCount; - pData->paPPLTindexentries = &pPPLT->aIndexentries; - pData->paPPLTalphaentries = &pPPLT->aAlphaentries; - pData->paPPLTusedentries = &pPPLT->aUsedentries; - - iRetcode = mng_process_display_pplt (pData); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_PPLT, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_MAGN -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_create_ani_magn (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iMethodX, - mng_uint16 iMX, - mng_uint16 iMY, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint16 iMT, - mng_uint16 iMB, - mng_uint8 iMethodY) -#else -mng_retcode mng_create_ani_magn (mng_datap pData, - mng_chunkp pChunk) -#endif -{ - mng_ani_magnp pMAGN=NULL; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_MAGN, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_ptr pTemp; - iRetcode = create_obj_general (pData, sizeof (mng_ani_magn), - mng_free_obj_general, - mng_process_ani_magn, - &pTemp); - if (iRetcode) - return iRetcode; - pMAGN = (mng_ani_magnp)pTemp; -#else - MNG_ALLOC (pData, pMAGN, sizeof (mng_ani_magn)); - - pMAGN->sHeader.fCleanup = mng_free_ani_magn; - pMAGN->sHeader.fProcess = mng_process_ani_magn; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pMAGN); - -#ifndef MNG_OPTIMIZE_CHUNKREADER - pMAGN->iFirstid = iFirstid; - pMAGN->iLastid = iLastid; - pMAGN->iMethodX = iMethodX; - pMAGN->iMX = iMX; - pMAGN->iMY = iMY; - pMAGN->iML = iML; - pMAGN->iMR = iMR; - pMAGN->iMT = iMT; - pMAGN->iMB = iMB; - pMAGN->iMethodY = iMethodY; -#else - pMAGN->iFirstid = ((mng_magnp)pChunk)->iFirstid; - pMAGN->iLastid = ((mng_magnp)pChunk)->iLastid; - pMAGN->iMethodX = ((mng_magnp)pChunk)->iMethodX; - pMAGN->iMX = ((mng_magnp)pChunk)->iMX; - pMAGN->iMY = ((mng_magnp)pChunk)->iMY; - pMAGN->iML = ((mng_magnp)pChunk)->iML; - pMAGN->iMR = ((mng_magnp)pChunk)->iMR; - pMAGN->iMT = ((mng_magnp)pChunk)->iMT; - pMAGN->iMB = ((mng_magnp)pChunk)->iMB; - pMAGN->iMethodY = ((mng_magnp)pChunk)->iMethodY; -#endif - } - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS -#ifndef MNG_OPTIMIZE_CHUNKREADER - iRetcode = mng_process_display_magn (pData, pMAGN->iFirstid, pMAGN->iLastid, - pMAGN->iMethodX, pMAGN->iMX, pMAGN->iMY, - pMAGN->iML, pMAGN->iMR, pMAGN->iMT, - pMAGN->iMB, pMAGN->iMethodY); -#else - iRetcode = mng_process_display_magn (pData, - ((mng_magnp)pChunk)->iFirstid, - ((mng_magnp)pChunk)->iLastid, - ((mng_magnp)pChunk)->iMethodX, - ((mng_magnp)pChunk)->iMX, - ((mng_magnp)pChunk)->iMY, - ((mng_magnp)pChunk)->iML, - ((mng_magnp)pChunk)->iMR, - ((mng_magnp)pChunk)->iMT, - ((mng_magnp)pChunk)->iMB, - ((mng_magnp)pChunk)->iMethodY); -#endif -#else -#ifndef MNG_OPTIMIZE_CHUNKREADER - pData->iMAGNfirstid = iFirstid; - pData->iMAGNlastid = iLastid; - pData->iMAGNmethodX = iMethodX; - pData->iMAGNmX = iMX; - pData->iMAGNmY = iMY; - pData->iMAGNmL = iML; - pData->iMAGNmR = iMR; - pData->iMAGNmT = iMT; - pData->iMAGNmB = iMB; - pData->iMAGNmethodY = iMethodY; -#else - pData->iMAGNfirstid = ((mng_magnp)pChunk)->iFirstid; - pData->iMAGNlastid = ((mng_magnp)pChunk)->iLastid; - pData->iMAGNmethodX = ((mng_magnp)pChunk)->iMethodX; - pData->iMAGNmX = ((mng_magnp)pChunk)->iMX; - pData->iMAGNmY = ((mng_magnp)pChunk)->iMY; - pData->iMAGNmL = ((mng_magnp)pChunk)->iML; - pData->iMAGNmR = ((mng_magnp)pChunk)->iMR; - pData->iMAGNmT = ((mng_magnp)pChunk)->iMT; - pData->iMAGNmB = ((mng_magnp)pChunk)->iMB; - pData->iMAGNmethodY = ((mng_magnp)pChunk)->iMethodY; -#endif - - iRetcode = mng_process_display_magn (pData); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_MAGN, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_OBJCLEANUP -mng_retcode mng_free_ani_magn (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_MAGN, MNG_LC_START); -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_magn)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_MAGN, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_magn (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_magnp pMAGN = (mng_ani_magnp)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_MAGN, MNG_LC_START); -#endif - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - iRetcode = mng_process_display_magn (pData, pMAGN->iFirstid, pMAGN->iLastid, - pMAGN->iMethodX, pMAGN->iMX, pMAGN->iMY, - pMAGN->iML, pMAGN->iMR, pMAGN->iMT, - pMAGN->iMB, pMAGN->iMethodY); -#else - pData->iMAGNfirstid = pMAGN->iFirstid; - pData->iMAGNlastid = pMAGN->iLastid; - pData->iMAGNmethodX = pMAGN->iMethodX; - pData->iMAGNmX = pMAGN->iMX; - pData->iMAGNmY = pMAGN->iMY; - pData->iMAGNmL = pMAGN->iML; - pData->iMAGNmR = pMAGN->iMR; - pData->iMAGNmT = pMAGN->iMT; - pData->iMAGNmB = pMAGN->iMB; - pData->iMAGNmethodY = pMAGN->iMethodY; - - iRetcode = mng_process_display_magn (pData); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_MAGN, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_PAST -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_create_ani_past (mng_datap pData, - mng_uint16 iTargetid, - mng_uint8 iTargettype, - mng_int32 iTargetx, - mng_int32 iTargety, - mng_uint32 iCount, - mng_ptr pSources) -#else -mng_retcode mng_create_ani_past (mng_datap pData, - mng_chunkp pChunk) -#endif -{ - mng_ani_pastp pPAST; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_PAST, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_ptr pTemp; - iRetcode = create_obj_general (pData, sizeof (mng_ani_past), - mng_free_ani_past, - mng_process_ani_past, - &pTemp); - if (iRetcode) - return iRetcode; - pPAST = (mng_ani_pastp)pTemp; -#else - MNG_ALLOC (pData, pPAST, sizeof (mng_ani_past)); - - pPAST->sHeader.fCleanup = mng_free_ani_past; - pPAST->sHeader.fProcess = mng_process_ani_past; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pPAST); - -#ifndef MNG_OPTIMIZE_CHUNKREADER - pPAST->iTargetid = iTargetid; - pPAST->iTargettype = iTargettype; - pPAST->iTargetx = iTargetx; - pPAST->iTargety = iTargety; - pPAST->iCount = iCount; - - if (iCount) - { - MNG_ALLOC (pData, pPAST->pSources, (iCount * sizeof (mng_past_source))); - MNG_COPY (pPAST->pSources, pSources, (iCount * sizeof (mng_past_source))); - } -#else - pPAST->iTargetid = ((mng_pastp)pChunk)->iDestid; - pPAST->iTargettype = ((mng_pastp)pChunk)->iTargettype; - pPAST->iTargetx = ((mng_pastp)pChunk)->iTargetx; - pPAST->iTargety = ((mng_pastp)pChunk)->iTargety; - pPAST->iCount = ((mng_pastp)pChunk)->iCount; - - if (pPAST->iCount) - { - mng_size_t iSize = (mng_size_t)(pPAST->iCount * sizeof (mng_past_source)); - MNG_ALLOC (pData, pPAST->pSources, iSize); - MNG_COPY (pPAST->pSources, ((mng_pastp)pChunk)->pSources, iSize); - } -#endif - } - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS -#ifndef MNG_OPTIMIZE_CHUNKREADER - iRetcode = mng_process_display_past (pData, iTargetid, iTargettype, - iTargetx, iTargety, - iCount, pSources); -#else - iRetcode = mng_process_display_past (pData, - ((mng_pastp)pChunk)->iDestid, - ((mng_pastp)pChunk)->iTargettype, - ((mng_pastp)pChunk)->iTargetx, - ((mng_pastp)pChunk)->iTargety, - ((mng_pastp)pChunk)->iCount, - ((mng_pastp)pChunk)->pSources); -#endif -#else -#ifndef MNG_OPTIMIZE_CHUNKREADER - pData->iPASTtargetid = iTargetid; - pData->iPASTtargettype = iTargettype; - pData->iPASTtargetx = iTargetx; - pData->iPASTtargety = iTargety; - pData->iPASTcount = iCount; - pData->pPASTsources = pSources; -#else - pData->iPASTtargetid = ((mng_pastp)pChunk)->iDestid; - pData->iPASTtargettype = ((mng_pastp)pChunk)->iTargettype; - pData->iPASTtargetx = ((mng_pastp)pChunk)->iTargetx; - pData->iPASTtargety = ((mng_pastp)pChunk)->iTargety; - pData->iPASTcount = ((mng_pastp)pChunk)->iCount; - pData->pPASTsources = ((mng_pastp)pChunk)->pSources; -#endif - - iRetcode = mng_process_display_past (pData); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_PAST, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_PAST -mng_retcode mng_free_ani_past (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_pastp pPAST = (mng_ani_pastp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_PAST, MNG_LC_START); -#endif - - if (pPAST->iCount) - MNG_FREEX (pData, pPAST->pSources, (pPAST->iCount * sizeof (mng_past_source))); - -#ifndef MNG_OPTIMIZE_OBJCLEANUP - MNG_FREEX (pData, pObject, sizeof (mng_ani_past)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_PAST, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_OBJCLEANUP - return MNG_NOERROR; -#else - return mng_free_obj_general(pData, pObject); -#endif -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_PAST -mng_retcode mng_process_ani_past (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_pastp pPAST = (mng_ani_pastp)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_PAST, MNG_LC_START); -#endif - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - iRetcode = mng_process_display_past (pData, pPAST->iTargetid, pPAST->iTargettype, - pPAST->iTargetx, pPAST->iTargety, - pPAST->iCount, pPAST->pSources); -#else - pData->iPASTtargetid = pPAST->iTargetid; - pData->iPASTtargettype = pPAST->iTargettype; - pData->iPASTtargetx = pPAST->iTargetx; - pData->iPASTtargety = pPAST->iTargety; - pData->iPASTcount = pPAST->iCount; - pData->pPASTsources = pPAST->pSources; - - iRetcode = mng_process_display_past (pData); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_PAST, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_DISC -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_create_ani_disc (mng_datap pData, - mng_uint32 iCount, - mng_uint16p pIds) -#else -mng_retcode mng_create_ani_disc (mng_datap pData, - mng_chunkp pChunk) -#endif -{ - mng_ani_discp pDISC; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_DISC, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_ptr pTemp; - iRetcode = create_obj_general (pData, sizeof (mng_ani_disc), - mng_free_ani_disc, - mng_process_ani_disc, - &pTemp); - if (iRetcode) - return iRetcode; - pDISC = (mng_ani_discp)pTemp; -#else - MNG_ALLOC (pData, pDISC, sizeof (mng_ani_disc)); - - pDISC->sHeader.fCleanup = mng_free_ani_disc; - pDISC->sHeader.fProcess = mng_process_ani_disc; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pDISC); - -#ifndef MNG_OPTIMIZE_CHUNKREADER - pDISC->iCount = iCount; - - if (iCount) - { - MNG_ALLOC (pData, pDISC->pIds, (iCount << 1)); - MNG_COPY (pDISC->pIds, pIds, (iCount << 1)); - } -#else - pDISC->iCount = ((mng_discp)pChunk)->iCount; - - if (pDISC->iCount) - { - mng_size_t iSize = (mng_size_t)(pDISC->iCount << 1); - MNG_ALLOC (pData, pDISC->pIds, iSize); - MNG_COPY (pDISC->pIds, ((mng_discp)pChunk)->pObjectids, iSize); - } -#endif - } - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS -#ifndef MNG_OPTIMIZE_CHUNKREADER - iRetcode = mng_process_display_disc (pData, iCount, pIds); -#else - iRetcode = mng_process_display_disc (pData, - ((mng_discp)pChunk)->iCount, - ((mng_discp)pChunk)->pObjectids); -#endif -#else -#ifndef MNG_OPTIMIZE_CHUNKREADER - pData->iDISCcount = iCount; - pData->pDISCids = pIds; -#else - pData->iDISCcount = ((mng_discp)pChunk)->iCount; - pData->pDISCids = ((mng_discp)pChunk)->pObjectids; -#endif - - iRetcode = mng_process_display_disc (pData); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_DISC, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_free_ani_disc (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_discp pDISC = (mng_ani_discp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_DISC, MNG_LC_START); -#endif - - if (pDISC->iCount) - MNG_FREEX (pData, pDISC->pIds, (pDISC->iCount << 1)); - -#ifndef MNG_OPTIMIZE_OBJCLEANUP - MNG_FREEX (pData, pObject, sizeof (mng_ani_disc)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_DISC, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_OBJCLEANUP - return MNG_NOERROR; -#else - return mng_free_obj_general(pData, pObject); -#endif -} - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_disc (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_discp pDISC = (mng_ani_discp)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_DISC, MNG_LC_START); -#endif - -#ifndef MNG_OPTIMIZE_DISPLAYCALLS - iRetcode = mng_process_display_disc (pData, pDISC->iCount, pDISC->pIds); -#else - pData->iDISCcount = pDISC->iCount; - pData->pDISCids = pDISC->pIds; - - iRetcode = mng_process_display_disc (pData); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_DISC, MNG_LC_END); -#endif - - return iRetcode; -} -#endif - -/* ************************************************************************** */ -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DYNAMICMNG - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_create_event (mng_datap pData, - mng_uint8 iEventtype, - mng_uint8 iMasktype, - mng_int32 iLeft, - mng_int32 iRight, - mng_int32 iTop, - mng_int32 iBottom, - mng_uint16 iObjectid, - mng_uint8 iIndex, - mng_uint32 iSegmentnamesize, - mng_pchar zSegmentname) -#else -mng_retcode mng_create_event (mng_datap pData, - mng_ptr pEntry) -#endif -{ - mng_eventp pEvent; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_EVENT, MNG_LC_START); -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - mng_object_headerp pLast; - -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_ptr pTemp; - mng_retcode iRetcode = create_obj_general (pData, sizeof (mng_event), - mng_free_event, - mng_process_event, - &pTemp); - if (iRetcode) - return iRetcode; - pEvent = (mng_eventp)pTemp; -#else - MNG_ALLOC (pData, pEvent, sizeof (mng_event)); - - pEvent->sHeader.fCleanup = mng_free_event; - pEvent->sHeader.fProcess = mng_process_event; -#endif - -#ifndef MNG_OPTIMIZE_CHUNKREADER - pEvent->iEventtype = iEventtype; - pEvent->iMasktype = iMasktype; - pEvent->iLeft = iLeft; - pEvent->iRight = iRight; - pEvent->iTop = iTop; - pEvent->iBottom = iBottom; - pEvent->iObjectid = iObjectid; - pEvent->iIndex = iIndex; - pEvent->iSegmentnamesize = iSegmentnamesize; - - if (iSegmentnamesize) - { - MNG_ALLOC (pData, pEvent->zSegmentname, iSegmentnamesize+1); - MNG_COPY (pEvent->zSegmentname, zSegmentname, iSegmentnamesize); - } -#else - pEvent->iEventtype = ((mng_evnt_entryp)pEntry)->iEventtype; - pEvent->iMasktype = ((mng_evnt_entryp)pEntry)->iMasktype; - pEvent->iLeft = ((mng_evnt_entryp)pEntry)->iLeft; - pEvent->iRight = ((mng_evnt_entryp)pEntry)->iRight; - pEvent->iTop = ((mng_evnt_entryp)pEntry)->iTop; - pEvent->iBottom = ((mng_evnt_entryp)pEntry)->iBottom; - pEvent->iObjectid = ((mng_evnt_entryp)pEntry)->iObjectid; - pEvent->iIndex = ((mng_evnt_entryp)pEntry)->iIndex; - pEvent->iSegmentnamesize = ((mng_evnt_entryp)pEntry)->iSegmentnamesize; - - if (pEvent->iSegmentnamesize) - { - MNG_ALLOC (pData, pEvent->zSegmentname, pEvent->iSegmentnamesize+1); - MNG_COPY (pEvent->zSegmentname, ((mng_evnt_entryp)pEntry)->zSegmentname, pEvent->iSegmentnamesize); - } -#endif - /* fixup the double-linked list */ - pLast = (mng_object_headerp)pData->pLastevent; - - if (pLast) /* link it as last in the chain */ - { - pEvent->sHeader.pPrev = pLast; - pLast->pNext = pEvent; - } - else - { - pData->pFirstevent = pEvent; - } - - pData->pLastevent = pEvent; - pData->bDynamic = MNG_TRUE; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_EVENT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_free_event (mng_datap pData, - mng_objectp pObject) -{ - mng_eventp pEvent = (mng_eventp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_EVENT, MNG_LC_START); -#endif - - if (pEvent->iSegmentnamesize) - MNG_FREEX (pData, pEvent->zSegmentname, pEvent->iSegmentnamesize + 1); - -#ifndef MNG_OPTIMIZE_OBJCLEANUP - MNG_FREEX (pData, pEvent, sizeof (mng_event)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_EVENT, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_OBJCLEANUP - return MNG_NOERROR; -#else - return mng_free_obj_general(pData, pObject); -#endif -} - -/* ************************************************************************** */ - -mng_retcode mng_process_event (mng_datap pData, - mng_objectp pObject) -{ -#ifndef MNG_SKIPCHUNK_SEEK - mng_eventp pEvent = (mng_eventp)pObject; - mng_object_headerp pAni; - mng_bool bFound = MNG_FALSE; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_EVENT, MNG_LC_START); -#endif - -#ifndef MNG_SKIPCHUNK_SEEK - if (!pEvent->pSEEK) /* need to find SEEK first ? */ - { - pAni = (mng_object_headerp)pData->pFirstaniobj; - - while ((pAni) && (!bFound)) - { - if ((pAni->fCleanup == mng_free_ani_seek) && - (strcmp(pEvent->zSegmentname, ((mng_ani_seekp)pAni)->zSegmentname) == 0)) - bFound = MNG_TRUE; - else - pAni = (mng_object_headerp)pAni->pNext; - } - - if (pAni) - pEvent->pSEEK = (mng_ani_seekp)pAni; - } - - if (pEvent->pSEEK) /* anything to do ? */ - { - pEvent->iLastx = pData->iEventx; - pEvent->iLasty = pData->iEventy; - /* let's start from this SEEK then */ - pData->pCurraniobj = (mng_objectp)pEvent->pSEEK; - pData->bRunningevent = MNG_TRUE; - /* wake-up the app ! */ - if (!pData->fSettimer ((mng_handle)pData, 5)) - MNG_ERROR (pData, MNG_APPTIMERERROR); - - } - else - MNG_ERROR (pData, MNG_SEEKNOTFOUND); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_EVENT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_SUPPORT_DYNAMICMNG */ - -/* ************************************************************************** */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_MPNG_PROPOSAL - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_create_mpng_obj (mng_datap pData, - mng_uint32 iFramewidth, - mng_uint32 iFrameheight, - mng_uint16 iNumplays, - mng_uint16 iTickspersec, - mng_uint32 iFramessize, - mng_ptr pFrames) -#else -mng_retcode mng_create_mpng_obj (mng_datap pData, - mng_ptr pEntry) -#endif -{ - mng_mpng_objp pMPNG; - mng_ptr pTemp; - mng_retcode iRetcode; - mng_uint8p pFrame; - mng_int32 iCnt, iMax; - mng_uint32 iX, iY, iWidth, iHeight; - mng_int32 iXoffset, iYoffset; - mng_uint16 iTicks; - mng_uint16 iDelay; - mng_bool bNewframe; - mng_ani_loopp pLOOP; - mng_ani_endlp pENDL; - mng_ani_framp pFRAM; - mng_ani_movep pMOVE; - mng_ani_clipp pCLIP; - mng_ani_showp pSHOW; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_MPNG_OBJ, MNG_LC_START); -#endif - -#ifdef MNG_OPTIMIZE_OBJCLEANUP - iRetcode = create_obj_general (pData, sizeof (mng_mpng_obj), mng_free_mpng_obj, - mng_process_mpng_obj, &pTemp); - if (iRetcode) - return iRetcode; - pMPNG = (mng_mpng_objp)pTemp; -#else - MNG_ALLOC (pData, pMPNG, sizeof (mng_mpng_obj)); - - pMPNG->sHeader.fCleanup = mng_free_mpng_obj; - pMPNG->sHeader.fProcess = mng_process_mpng_obj; -#endif - -#ifndef MNG_OPTIMIZE_CHUNKREADER - pMPNG->iFramewidth = iFramewidth; - pMPNG->iFrameheight = iFrameheight; - pMPNG->iNumplays = iNumplays; - pMPNG->iTickspersec = iTickspersec; - pMPNG->iFramessize = iFramessize; - - if (iFramessize) - { - MNG_ALLOC (pData, pMPNG->pFrames, iFramessize); - MNG_COPY (pMPNG->pFrames, pFrames, iFramessize); - } -#else - pMPNG->iFramewidth = ((mng_mpngp)pEntry)->iFramewidth; - pMPNG->iFrameheight = ((mng_mpngp)pEntry)->iFrameheight; - pMPNG->iNumplays = ((mng_mpngp)pEntry)->iNumplays; - pMPNG->iTickspersec = ((mng_mpngp)pEntry)->iTickspersec; - pMPNG->iFramessize = ((mng_mpngp)pEntry)->iFramessize; - - if (pMPNG->iFramessize) - { - MNG_ALLOC (pData, pMPNG->pFrames, pMPNG->iFramessize); - MNG_COPY (pMPNG->pFrames, ((mng_mpngp)pEntry)->pFrames, pMPNG->iFramessize); - } -#endif - - pData->pMPNG = pMPNG; - pData->eImagetype = mng_it_mpng; - - iRetcode = mng_process_display_mpng (pData); - if (iRetcode) - return iRetcode; - - /* now let's create the MNG animation directives from this */ - - pFrame = (mng_uint8p)pMPNG->pFrames; - iMax = pMPNG->iFramessize / 26; - /* set up MNG impersonation */ - pData->iTicks = pMPNG->iTickspersec; - pData->iLayercount = iMax; - - if (pMPNG->iNumplays != 1) /* create a LOOP/ENDL pair ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - iRetcode = create_obj_general (pData, sizeof (mng_ani_loop), - mng_free_ani_loop, mng_process_ani_loop, - &((mng_ptr)pLOOP)); - if (iRetcode) - return iRetcode; -#else - MNG_ALLOC (pData, pLOOP, sizeof (mng_ani_loop)); - - pLOOP->sHeader.fCleanup = mng_free_ani_loop; - pLOOP->sHeader.fProcess = mng_process_ani_loop; -#endif - - pLOOP->iLevel = 1; - if (pMPNG->iNumplays) - pLOOP->iRepeatcount = pMPNG->iNumplays; - else - pLOOP->iRepeatcount = 0xFFFFFFFFl; - - mng_add_ani_object (pData, (mng_object_headerp)pLOOP); - } - - bNewframe = MNG_TRUE; /* create the frame display objects */ - - for (iCnt = 0; iCnt < iMax; iCnt++) - { - iX = mng_get_uint32 (pFrame); - iY = mng_get_uint32 (pFrame+4); - iWidth = mng_get_uint32 (pFrame+8); - iHeight = mng_get_uint32 (pFrame+12); - iXoffset = mng_get_int32 (pFrame+16); - iYoffset = mng_get_int32 (pFrame+20); - iTicks = mng_get_uint16 (pFrame+24); - - iDelay = iTicks; - if (!iDelay) - { - mng_uint8p pTemp = pFrame+26; - mng_int32 iTemp = iCnt+1; - - while ((iTemp < iMax) && (!iDelay)) - { - iDelay = mng_get_uint16 (pTemp+24); - pTemp += 26; - iTemp++; - } - } - - if (bNewframe) - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - iRetcode = create_obj_general (pData, sizeof (mng_ani_fram), - mng_free_obj_general, mng_process_ani_fram, - &((mng_ptr)pFRAM)); - if (iRetcode) - return iRetcode; -#else - MNG_ALLOC (pData, pFRAM, sizeof (mng_ani_fram)); - - pFRAM->sHeader.fCleanup = mng_free_ani_fram; - pFRAM->sHeader.fProcess = mng_process_ani_fram; -#endif - - pFRAM->iFramemode = 4; - pFRAM->iChangedelay = 1; - pFRAM->iDelay = iDelay; - - mng_add_ani_object (pData, (mng_object_headerp)pFRAM); - } - -#ifdef MNG_OPTIMIZE_OBJCLEANUP - iRetcode = create_obj_general (pData, sizeof (mng_ani_move), - mng_free_obj_general, - mng_process_ani_move, - &((mng_ptr)pMOVE)); - if (iRetcode) - return iRetcode; -#else - MNG_ALLOC (pData, pMOVE, sizeof (mng_ani_move)); - - pMOVE->sHeader.fCleanup = mng_free_ani_move; - pMOVE->sHeader.fProcess = mng_process_ani_move; -#endif - - pMOVE->iLocax = iXoffset - (mng_int32)iX; - pMOVE->iLocay = iYoffset - (mng_int32)iY; - - mng_add_ani_object (pData, (mng_object_headerp)pMOVE); - -#ifdef MNG_OPTIMIZE_OBJCLEANUP - iRetcode = create_obj_general (pData, sizeof (mng_ani_clip), - mng_free_obj_general, - mng_process_ani_clip, - &((mng_ptr)pCLIP)); - if (iRetcode) - return iRetcode; -#else - MNG_ALLOC (pData, pCLIP, sizeof (mng_ani_clip)); - - pCLIP->sHeader.fCleanup = mng_free_ani_clip; - pCLIP->sHeader.fProcess = mng_process_ani_clip; -#endif - - pCLIP->iClipl = iXoffset; - pCLIP->iClipr = iXoffset + (mng_int32)iWidth; - pCLIP->iClipt = iYoffset; - pCLIP->iClipb = iYoffset + (mng_int32)iHeight; - - mng_add_ani_object (pData, (mng_object_headerp)pCLIP); - -#ifdef MNG_OPTIMIZE_OBJCLEANUP - iRetcode = create_obj_general (pData, sizeof (mng_ani_show), - mng_free_obj_general, mng_process_ani_show, - &((mng_ptr)pSHOW)); - if (iRetcode) - return iRetcode; -#else - MNG_ALLOC (pData, pSHOW, sizeof (mng_ani_show)); - - pSHOW->sHeader.fCleanup = mng_free_ani_show; - pSHOW->sHeader.fProcess = mng_process_ani_show; -#endif - - mng_add_ani_object (pData, (mng_object_headerp)pSHOW); - - bNewframe = (mng_bool)iTicks; - pFrame += 26; - } - - if (pMPNG->iNumplays != 1) /* create a LOOP/ENDL pair ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - iRetcode = create_obj_general (pData, sizeof (mng_ani_endl), - mng_free_obj_general, mng_process_ani_endl, - &((mng_ptr)pENDL)); - if (iRetcode) - return iRetcode; -#else - MNG_ALLOC (pData, pENDL, sizeof (mng_ani_endl)); - - pENDL->sHeader.fCleanup = mng_free_ani_endl; - pENDL->sHeader.fProcess = mng_process_ani_endl; -#endif - - pENDL->iLevel = 1; - - mng_add_ani_object (pData, (mng_object_headerp)pENDL); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_MPNG_OBJ, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_free_mpng_obj (mng_datap pData, - mng_objectp pObject) -{ - mng_mpng_objp pMPNG = (mng_mpng_objp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MPNG_OBJ, MNG_LC_START); -#endif - - if (pMPNG->iFramessize) - MNG_FREEX (pData, pMPNG->pFrames, pMPNG->iFramessize); - -#ifndef MNG_OPTIMIZE_OBJCLEANUP - MNG_FREEX (pData, pMPNG, sizeof (mng_mpng_obj)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MPNG_OBJ, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_OBJCLEANUP - return MNG_NOERROR; -#else - return mng_free_obj_general(pData, pObject); -#endif -} - -/* ************************************************************************** */ - -mng_retcode mng_process_mpng_obj (mng_datap pData, - mng_objectp pObject) -{ - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_MPNG_PROPOSAL */ - -/* ************************************************************************** */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ANG_PROPOSAL - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_create_ang_obj (mng_datap pData, - mng_uint32 iNumframes, - mng_uint32 iTickspersec, - mng_uint32 iNumplays, - mng_uint32 iTilewidth, - mng_uint32 iTileheight, - mng_uint8 iInterlace, - mng_uint8 iStillused) -#else -mng_retcode mng_create_ang_obj (mng_datap pData, - mng_ptr pEntry) -#endif -{ - mng_ang_objp pANG; - mng_ptr pTemp; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANG_OBJ, MNG_LC_START); -#endif - -#ifdef MNG_OPTIMIZE_OBJCLEANUP - iRetcode = create_obj_general (pData, sizeof (mng_ang_obj), mng_free_ang_obj, - mng_process_ang_obj, &pTemp); - if (iRetcode) - return iRetcode; - pANG = (mng_ang_objp)pTemp; -#else - MNG_ALLOC (pData, pANG, sizeof (mng_ang_obj)); - - pANG->sHeader.fCleanup = mng_free_ang_obj; - pANG->sHeader.fProcess = mng_process_ang_obj; -#endif - -#ifndef MNG_OPTIMIZE_CHUNKREADER - pANG->iNumframes = iNumframes; - pANG->iTickspersec = iTickspersec; - pANG->iNumplays = iNumplays; - pANG->iTilewidth = iTilewidth; - pANG->iTileheight = iTileheight; - pANG->iInterlace = iInterlace; - pANG->iStillused = iStillused; -#else - pANG->iNumframes = ((mng_ahdrp)pEntry)->iNumframes; - pANG->iTickspersec = ((mng_ahdrp)pEntry)->iTickspersec; - pANG->iNumplays = ((mng_ahdrp)pEntry)->iNumplays; - pANG->iTilewidth = ((mng_ahdrp)pEntry)->iTilewidth; - pANG->iTileheight = ((mng_ahdrp)pEntry)->iTileheight; - pANG->iInterlace = ((mng_ahdrp)pEntry)->iInterlace; - pANG->iStillused = ((mng_ahdrp)pEntry)->iStillused; -#endif - - pData->pANG = pANG; - pData->eImagetype = mng_it_ang; - - iRetcode = mng_process_display_ang (pData); - if (iRetcode) - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANG_OBJ, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_free_ang_obj (mng_datap pData, - mng_objectp pObject) -{ - mng_ang_objp pANG = (mng_ang_objp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANG_OBJ, MNG_LC_START); -#endif - - if (pANG->iTilessize) - MNG_FREEX (pData, pANG->pTiles, pANG->iTilessize); - -#ifndef MNG_OPTIMIZE_OBJCLEANUP - MNG_FREEX (pData, pANG, sizeof (mng_ang_obj)); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANG_OBJ, MNG_LC_END); -#endif - -#ifndef MNG_OPTIMIZE_OBJCLEANUP - return MNG_NOERROR; -#else - return mng_free_obj_general(pData, pObject); -#endif -} - -/* ************************************************************************** */ - -mng_retcode mng_process_ang_obj (mng_datap pData, - mng_objectp pObject) -{ - mng_ang_objp pANG = (mng_ang_objp)pObject; - mng_uint8p pTile = (mng_uint8p)pANG->pTiles; - mng_retcode iRetcode; - mng_int32 iCnt, iMax; - mng_uint32 iTicks; - mng_int32 iXoffset, iYoffset; - mng_uint8 iSource; - mng_ani_loopp pLOOP; - mng_ani_endlp pENDL; - mng_ani_framp pFRAM; - mng_ani_movep pMOVE; - mng_ani_showp pSHOW; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANG_OBJ, MNG_LC_START); -#endif - - /* let's create the MNG animation directives from this */ - - iMax = pANG->iNumframes; - /* set up MNG impersonation */ - pData->iTicks = pANG->iTickspersec; - pData->iLayercount = iMax; - - if (pANG->iNumplays != 1) /* create a LOOP/ENDL pair ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - iRetcode = create_obj_general (pData, sizeof (mng_ani_loop), - mng_free_ani_loop, mng_process_ani_loop, - &((mng_ptr)pLOOP)); - if (iRetcode) - return iRetcode; -#else - MNG_ALLOC (pData, pLOOP, sizeof (mng_ani_loop)); - - pLOOP->sHeader.fCleanup = mng_free_ani_loop; - pLOOP->sHeader.fProcess = mng_process_ani_loop; -#endif - - pLOOP->iLevel = 1; - if (pANG->iNumplays) - pLOOP->iRepeatcount = pANG->iNumplays; - else - pLOOP->iRepeatcount = 0xFFFFFFFFl; - - mng_add_ani_object (pData, (mng_object_headerp)pLOOP); - } - - for (iCnt = 0; iCnt < iMax; iCnt++) - { - iTicks = mng_get_uint32 (pTile); - iXoffset = mng_get_int32 (pTile+4); - iYoffset = mng_get_int32 (pTile+8); - iSource = *(pTile+12); - -#ifdef MNG_OPTIMIZE_OBJCLEANUP - iRetcode = create_obj_general (pData, sizeof (mng_ani_fram), - mng_free_obj_general, mng_process_ani_fram, - &((mng_ptr)pFRAM)); - if (iRetcode) - return iRetcode; -#else - MNG_ALLOC (pData, pFRAM, sizeof (mng_ani_fram)); - - pFRAM->sHeader.fCleanup = mng_free_ani_fram; - pFRAM->sHeader.fProcess = mng_process_ani_fram; -#endif - - pFRAM->iFramemode = 4; - pFRAM->iChangedelay = 1; - pFRAM->iDelay = iTicks; - - mng_add_ani_object (pData, (mng_object_headerp)pFRAM); - - if (!iSource) - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - iRetcode = create_obj_general (pData, sizeof (mng_ani_move), - mng_free_obj_general, - mng_process_ani_move, - &((mng_ptr)pMOVE)); - if (iRetcode) - return iRetcode; -#else - MNG_ALLOC (pData, pMOVE, sizeof (mng_ani_move)); - - pMOVE->sHeader.fCleanup = mng_free_ani_move; - pMOVE->sHeader.fProcess = mng_process_ani_move; -#endif - - pMOVE->iFirstid = 1; - pMOVE->iLastid = 1; - pMOVE->iLocax = -iXoffset; - pMOVE->iLocay = -iYoffset; - - mng_add_ani_object (pData, (mng_object_headerp)pMOVE); - } - -#ifdef MNG_OPTIMIZE_OBJCLEANUP - iRetcode = create_obj_general (pData, sizeof (mng_ani_show), - mng_free_obj_general, mng_process_ani_show, - &((mng_ptr)pSHOW)); - if (iRetcode) - return iRetcode; -#else - MNG_ALLOC (pData, pSHOW, sizeof (mng_ani_show)); - - pSHOW->sHeader.fCleanup = mng_free_ani_show; - pSHOW->sHeader.fProcess = mng_process_ani_show; -#endif - - if (iSource) - pSHOW->iFirstid = 0; - else - pSHOW->iFirstid = 1; - pSHOW->iLastid = pSHOW->iFirstid; - - mng_add_ani_object (pData, (mng_object_headerp)pSHOW); - - pTile += sizeof(mng_adat_tile); - } - - if (pANG->iNumplays != 1) /* create a LOOP/ENDL pair ? */ - { -#ifdef MNG_OPTIMIZE_OBJCLEANUP - iRetcode = create_obj_general (pData, sizeof (mng_ani_endl), - mng_free_obj_general, mng_process_ani_endl, - &((mng_ptr)pENDL)); - if (iRetcode) - return iRetcode; -#else - MNG_ALLOC (pData, pENDL, sizeof (mng_ani_endl)); - - pENDL->sHeader.fCleanup = mng_free_ani_endl; - pENDL->sHeader.fProcess = mng_process_ani_endl; -#endif - - pENDL->iLevel = 1; - - mng_add_ani_object (pData, (mng_object_headerp)pENDL); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANG_OBJ, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_ANG_PROPOSAL */ - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_DISPLAY_PROCS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/plugins/AdvaImg/src/LibMNG/libmng_object_prc.h b/plugins/AdvaImg/src/LibMNG/libmng_object_prc.h deleted file mode 100644 index 46d201ca0e..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_object_prc.h +++ /dev/null @@ -1,690 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_object_prc.h copyright (c) 2000-2007 G.Juyn * */ -/* * version : 1.0.10 * */ -/* * * */ -/* * purpose : Object processing routines (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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 * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added routine to discard "invalid" objects * */ -/* * * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * 1.0.5 - 09/13/2002 - G.Juyn * */ -/* * - fixed read/write of MAGN chunk * */ -/* * 1.0.5 - 09/15/2002 - G.Juyn * */ -/* * - added event handling for dynamic MNG * */ -/* * 1.0.5 - 09/20/2002 - G.Juyn * */ -/* * - added support for PAST * */ -/* * 1.0.5 - 09/23/2002 - G.Juyn * */ -/* * - added in-memory color-correction of abstract images * */ -/* * 1.0.5 - 10/07/2002 - G.Juyn * */ -/* * - fixed DISC support * */ -/* * * */ -/* * 1.0.6 - 07/07/2003 - G.R-P * */ -/* * - added conditionals around Delta-PNG code * */ -/* * - added SKIPCHUNK feature * */ -/* * 1.0.6 - 07/29/2003 - G.R-P * */ -/* * - added conditionals around PAST chunk support * */ -/* * * */ -/* * 1.0.7 - 03/24/2004 - G.R-P * */ -/* * - added more SKIPCHUNK conditionals * */ -/* * * */ -/* * 1.0.9 - 12/05/2004 - G.Juyn * */ -/* * - added conditional MNG_OPTIMIZE_OBJCLEANUP * */ -/* * * */ -/* * 1.0.10 - 04/08/2007 - G.Juyn * */ -/* * - added support for mPNG proposal * */ -/* * 1.0.10 - 04/12/2007 - G.Juyn * */ -/* * - added support for ANG proposal * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_object_prc_h_ -#define _libmng_object_prc_h_ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_DISPLAY_PROCS - -/* ************************************************************************** */ - -mng_retcode mng_drop_invalid_objects (mng_datap pData); - -/* ************************************************************************** */ - -mng_retcode mng_create_imagedataobject (mng_datap pData, - mng_bool bConcrete, - mng_bool bViewable, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_imagedatap *ppObject); - -mng_retcode mng_free_imagedataobject (mng_datap pData, - mng_imagedatap pImagedata); - -mng_retcode mng_clone_imagedataobject (mng_datap pData, - mng_bool bConcrete, - mng_imagedatap pSource, - mng_imagedatap *ppClone); - -/* ************************************************************************** */ - -mng_retcode mng_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 mng_free_imageobject (mng_datap pData, - mng_imagep pImage); - -mng_imagep mng_find_imageobject (mng_datap pData, - mng_uint16 iId); - -mng_retcode mng_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 mng_renum_imageobject (mng_datap pData, - mng_imagep pSource, - mng_uint16 iId, - mng_bool bVisible, - mng_bool bAbstract, - mng_bool bHasloca, - mng_uint8 iLocationtype, - mng_int32 iLocationx, - mng_int32 iLocationy); - -mng_retcode mng_reset_object_details (mng_datap pData, - mng_imagep pImage, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_bool bResetall); - -mng_retcode mng_promote_imageobject (mng_datap pData, - mng_imagep pImage, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iFilltype); - -mng_retcode mng_magnify_imageobject (mng_datap pData, - mng_imagep pImage); - -mng_retcode mng_colorcorrect_object (mng_datap pData, - mng_imagep pImage); - -/* ************************************************************************** */ - -mng_retcode mng_create_ani_image (mng_datap pData); - -#ifndef MNG_OPTIMIZE_CHUNKREADER - -mng_retcode mng_create_ani_plte (mng_datap pData, - mng_uint32 iEntrycount, - mng_palette8ep paEntries); - -mng_retcode mng_create_ani_trns (mng_datap pData, - mng_uint32 iRawlen, - mng_uint8p pRawdata); - -mng_retcode mng_create_ani_gama (mng_datap pData, - mng_bool bEmpty, - mng_uint32 iGamma); - -mng_retcode mng_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 mng_create_ani_srgb (mng_datap pData, - mng_bool bEmpty, - mng_uint8 iRenderinginent); - -mng_retcode mng_create_ani_iccp (mng_datap pData, - mng_bool bEmpty, - mng_uint32 iProfilesize, - mng_ptr pProfile); - -mng_retcode mng_create_ani_bkgd (mng_datap pData, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue); - -mng_retcode mng_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 mng_create_ani_endl (mng_datap pData, - mng_uint8 iLevel); - -mng_retcode mng_create_ani_defi (mng_datap pData); - -mng_retcode mng_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 mng_create_ani_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 iLocatype, - mng_int32 iLocax, - mng_int32 iLocay); - -mng_retcode mng_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 mng_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 mng_create_ani_move (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iType, - mng_int32 iLocax, - mng_int32 iLocay); - -mng_retcode mng_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 mng_create_ani_show (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iMode); - -mng_retcode mng_create_ani_term (mng_datap pData, - mng_uint8 iTermaction, - mng_uint8 iIteraction, - mng_uint32 iDelay, - mng_uint32 iItermax); - -#ifndef MNG_SKIPCHUNK_SAVE -mng_retcode mng_create_ani_save (mng_datap pData); -#endif -#ifndef MNG_SKIPCHUNK_SEEK -mng_retcode mng_create_ani_seek (mng_datap pData, - mng_uint32 iSegmentnamesize, - mng_pchar zSegmentname); -#endif -#ifndef MNG_NO_DELTA_PNG -mng_retcode mng_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 mng_create_ani_prom (mng_datap pData, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iFilltype); - -mng_retcode mng_create_ani_ipng (mng_datap pData); -mng_retcode mng_create_ani_ijng (mng_datap pData); - -mng_retcode mng_create_ani_pplt (mng_datap pData, - mng_uint8 iType, - mng_uint32 iCount, - mng_palette8ep paIndexentries, - mng_uint8p paAlphaentries, - mng_uint8p paUsedentries); -#endif - -#ifndef MNG_SKIPCHUNK_MAGN -mng_retcode mng_create_ani_magn (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iMethodX, - mng_uint16 iMX, - mng_uint16 iMY, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint16 iMT, - mng_uint16 iMB, - mng_uint8 iMethodY); -#endif - -#ifndef MNG_SKIPCHUNK_PAST -mng_retcode mng_create_ani_past (mng_datap pData, - mng_uint16 iTargetid, - mng_uint8 iTargettype, - mng_int32 iTargetx, - mng_int32 iTargety, - mng_uint32 iCount, - mng_ptr pSources); -#endif - -#ifndef MNG_SKIPCHUNK_DISC -mng_retcode mng_create_ani_disc (mng_datap pData, - mng_uint32 iCount, - mng_uint16p pIds); -#endif - -#else /* MNG_OPTIMIZE_CHUNKREADER */ - -mng_retcode mng_create_ani_plte (mng_datap pData); -mng_retcode mng_create_ani_trns (mng_datap pData); -mng_retcode mng_create_ani_gama (mng_datap pData, - mng_chunkp pChunk); -mng_retcode mng_create_ani_chrm (mng_datap pData, - mng_chunkp pChunk); -mng_retcode mng_create_ani_srgb (mng_datap pData, - mng_chunkp pChunk); -mng_retcode mng_create_ani_iccp (mng_datap pData, - mng_chunkp pChunk); -mng_retcode mng_create_ani_bkgd (mng_datap pData); -mng_retcode mng_create_ani_loop (mng_datap pData, - mng_chunkp pChunk); -mng_retcode mng_create_ani_endl (mng_datap pData, - mng_uint8 iLevel); -mng_retcode mng_create_ani_defi (mng_datap pData); -mng_retcode mng_create_ani_basi (mng_datap pData, - mng_chunkp pChunk); -mng_retcode mng_create_ani_clon (mng_datap pData, - mng_chunkp pChunk); -mng_retcode mng_create_ani_back (mng_datap pData); -mng_retcode mng_create_ani_fram (mng_datap pData, - mng_chunkp pChunk); -mng_retcode mng_create_ani_move (mng_datap pData, - mng_chunkp pChunk); -mng_retcode mng_create_ani_clip (mng_datap pData, - mng_chunkp pChunk); -mng_retcode mng_create_ani_show (mng_datap pData); -mng_retcode mng_create_ani_term (mng_datap pData, - mng_chunkp pChunk); -#ifndef MNG_SKIPCHUNK_SAVE -mng_retcode mng_create_ani_save (mng_datap pData); -#endif -#ifndef MNG_SKIPCHUNK_SEEK -mng_retcode mng_create_ani_seek (mng_datap pData, - mng_chunkp pChunk); -#endif -#ifndef MNG_NO_DELTA_PNG -mng_retcode mng_create_ani_dhdr (mng_datap pData, - mng_chunkp pChunk); -mng_retcode mng_create_ani_prom (mng_datap pData, - mng_chunkp pChunk); -mng_retcode mng_create_ani_ipng (mng_datap pData); -mng_retcode mng_create_ani_ijng (mng_datap pData); - -mng_retcode mng_create_ani_pplt (mng_datap pData, - mng_uint8 iType, - mng_uint32 iCount, - mng_palette8ep paIndexentries, - mng_uint8p paAlphaentries, - mng_uint8p paUsedentries); -#endif - -#ifndef MNG_SKIPCHUNK_MAGN -mng_retcode mng_create_ani_magn (mng_datap pData, - mng_chunkp pChunk); -#endif -#ifndef MNG_SKIPCHUNK_PAST -mng_retcode mng_create_ani_past (mng_datap pData, - mng_chunkp pChunk); -#endif -#ifndef MNG_SKIPCHUNK_DISC -mng_retcode mng_create_ani_disc (mng_datap pData, - mng_chunkp pChunk); -#endif - -#endif /* MNG_OPTIMIZE_CHUNKREADER */ - -/* ************************************************************************** */ - -mng_retcode mng_free_ani_image (mng_datap pData, - mng_objectp pObject); - -#ifndef MNG_OPTIMIZE_OBJCLEANUP - -mng_retcode mng_free_ani_plte (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_free_ani_trns (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_free_ani_gama (mng_datap pData, - mng_objectp pObject); -#ifndef MNG_SKIPCHUNK_cHRM -mng_retcode mng_free_ani_chrm (mng_datap pData, - mng_objectp pObject); -#endif -#ifndef MNG_SKIPCHUNK_sRGB -mng_retcode mng_free_ani_srgb (mng_datap pData, - mng_objectp pObject); -#endif -#ifndef MNG_SKIPCHUNK_bKGD -mng_retcode mng_free_ani_bkgd (mng_datap pData, - mng_objectp pObject); -#endif -#ifndef MNG_SKIPCHUNK_LOOP -mng_retcode mng_free_ani_endl (mng_datap pData, - mng_objectp pObject); -#endif -mng_retcode mng_free_ani_defi (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_free_ani_basi (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_free_ani_clon (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_free_ani_back (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_free_ani_fram (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_free_ani_move (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_free_ani_clip (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_free_ani_show (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_free_ani_term (mng_datap pData, - mng_objectp pObject); -#ifndef MNG_SKIPCHUNK_SAVE -mng_retcode mng_free_ani_save (mng_datap pData, - mng_objectp pObject); -#endif -#ifndef MNG_NO_DELTA_PNG -mng_retcode mng_free_ani_dhdr (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_free_ani_prom (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_free_ani_ipng (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_free_ani_ijng (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_free_ani_pplt (mng_datap pData, - mng_objectp pObject); -#endif -#ifndef MNG_SKIPCHUNK_MAGN -mng_retcode mng_free_ani_magn (mng_datap pData, - mng_objectp pObject); -#endif - -#endif /* MNG_OPTIMIZE_OBJCLEANUP */ - - -#ifndef MNG_SKIPCHUNK_iCCP -mng_retcode mng_free_ani_iccp (mng_datap pData, - mng_objectp pObject); -#endif -#ifndef MNG_SKIPCHUNK_LOOP -mng_retcode mng_free_ani_loop (mng_datap pData, - mng_objectp pObject); -#endif -#ifndef MNG_SKIPCHUNK_SAVE -mng_retcode mng_free_ani_seek (mng_datap pData, - mng_objectp pObject); -#endif -#ifndef MNG_SKIPCHUNK_PAST -mng_retcode mng_free_ani_past (mng_datap pData, - mng_objectp pObject); -#endif -mng_retcode mng_free_ani_disc (mng_datap pData, - mng_objectp pObject); - -/* ************************************************************************** */ - -mng_retcode mng_process_ani_image (mng_datap pData, - mng_objectp pObject); - -mng_retcode mng_process_ani_plte (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_process_ani_trns (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_process_ani_gama (mng_datap pData, - mng_objectp pObject); -#ifndef MNG_SKIPCHUNK_cHRM -mng_retcode mng_process_ani_chrm (mng_datap pData, - mng_objectp pObject); -#endif -#ifndef MNG_SKIPCHUNK_sRGB -mng_retcode mng_process_ani_srgb (mng_datap pData, - mng_objectp pObject); -#endif -#ifndef MNG_SKIPCHUNK_iCCP -mng_retcode mng_process_ani_iccp (mng_datap pData, - mng_objectp pObject); -#endif -#ifndef MNG_SKIPCHUNK_bKGD -mng_retcode mng_process_ani_bkgd (mng_datap pData, - mng_objectp pObject); -#endif -#ifndef MNG_SKIPCHUNK_LOOP -mng_retcode mng_process_ani_loop (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_process_ani_endl (mng_datap pData, - mng_objectp pObject); -#endif -mng_retcode mng_process_ani_defi (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_process_ani_basi (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_process_ani_clon (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_process_ani_back (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_process_ani_fram (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_process_ani_move (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_process_ani_clip (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_process_ani_show (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_process_ani_term (mng_datap pData, - mng_objectp pObject); -#ifndef MNG_SKIPCHUNK_SAVE -mng_retcode mng_process_ani_save (mng_datap pData, - mng_objectp pObject); -#endif -#ifndef MNG_SKIPCHUNK_SEEK -mng_retcode mng_process_ani_seek (mng_datap pData, - mng_objectp pObject); -#endif -#ifndef MNG_NO_DELTA_PNG -mng_retcode mng_process_ani_dhdr (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_process_ani_prom (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_process_ani_ipng (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_process_ani_ijng (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_process_ani_pplt (mng_datap pData, - mng_objectp pObject); -#endif -mng_retcode mng_process_ani_magn (mng_datap pData, - mng_objectp pObject); -#ifndef MNG_SKIPCHUNK_PAST -mng_retcode mng_process_ani_past (mng_datap pData, - mng_objectp pObject); -#endif -mng_retcode mng_process_ani_disc (mng_datap pData, - mng_objectp pObject); - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DYNAMICMNG -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_create_event (mng_datap pData, - mng_uint8 iEventtype, - mng_uint8 iMasktype, - mng_int32 iLeft, - mng_int32 iRight, - mng_int32 iTop, - mng_int32 iBottom, - mng_uint16 iObjectid, - mng_uint8 iIndex, - mng_uint32 iSegmentnamesize, - mng_pchar zSegmentname); -#else -mng_retcode mng_create_event (mng_datap pData, - mng_ptr pEntry); -#endif -mng_retcode mng_free_event (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_process_event (mng_datap pData, - mng_objectp pObject); -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_MPNG_PROPOSAL -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_create_mpng_obj (mng_datap pData, - mng_uint32 iFramewidth, - mng_uint32 iFrameheight, - mng_uint16 iNumplays, - mng_uint16 iTickspersec, - mng_uint32 iFramessize, - mng_ptr pFrames); -#else -mng_retcode mng_create_mpng_obj (mng_datap pData, - mng_ptr pEntry); -#endif -mng_retcode mng_free_mpng_obj (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_process_mpng_obj (mng_datap pData, - mng_objectp pObject); -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ANG_PROPOSAL -#ifndef MNG_OPTIMIZE_CHUNKREADER -mng_retcode mng_create_ang_obj (mng_datap pData, - mng_uint32 iNumframes, - mng_uint32 iTickspersec, - mng_uint32 iNumplays, - mng_uint32 iTilewidth, - mng_uint32 iTileheight, - mng_uint8 iInterlace, - mng_uint8 iStillused); -#else -mng_retcode mng_create_ang_obj (mng_datap pData, - mng_ptr pEntry); -#endif -mng_retcode mng_free_ang_obj (mng_datap pData, - mng_objectp pObject); -mng_retcode mng_process_ang_obj (mng_datap pData, - mng_objectp pObject); -#endif - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_DISPLAY_PROCS */ - -/* ************************************************************************** */ - -#endif /* _libmng_object_prc_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/plugins/AdvaImg/src/LibMNG/libmng_objects.h b/plugins/AdvaImg/src/LibMNG/libmng_objects.h deleted file mode 100644 index ab7290fdf3..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_objects.h +++ /dev/null @@ -1,635 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_objects.h copyright (c) 2000-2007 G.Juyn * */ -/* * version : 1.0.10 * */ -/* * * */ -/* * purpose : Internal object structures (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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 * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/10/2000 - G.Juyn * */ -/* * - fixed DEFI behavior * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added support for delta-JNG * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added valid-flag to stored objects for read() / display()* */ -/* * 0.9.3 - 10/19/2000 - G.Juyn * */ -/* * - added storage for pixel-/alpha-sampledepth for delta's * */ -/* * * */ -/* * 1.0.5 - 09/13/2002 - G.Juyn * */ -/* * - fixed read/write of MAGN chunk * */ -/* * 1.0.5 - 09/15/2002 - G.Juyn * */ -/* * - added event handling for dynamic MNG * */ -/* * 1.0.5 - 09/20/2002 - G.Juyn * */ -/* * - added support for PAST * */ -/* * 1.0.5 - 09/23/2002 - G.Juyn * */ -/* * - added in-memory color-correction of abstract images * */ -/* * 1.0.5 - 10/07/2002 - G.Juyn * */ -/* * - fixed DISC support * */ -/* * * */ -/* * 1.0.6 - 10/07/2003 - G.R-P * */ -/* * - added SKIPCHUNK conditionals * */ -/* * * */ -/* * 1.0.7 - 03/24/2004 - G.R-P * */ -/* * - added more SKIPCHUNK conditionals * */ -/* * * */ -/* * 1.0.9 - 12/05/2004 - G.Juyn * */ -/* * - added conditional MNG_OPTIMIZE_OBJCLEANUP * */ -/* * * */ -/* * 1.0.10 - 04/08/2007 - G.Juyn * */ -/* * - added support for mPNG proposal * */ -/* * 1.0.10 - 04/12/2007 - G.Juyn * */ -/* * - added support for ANG proposal * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_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; -#ifdef MNG_OPTIMIZE_OBJCLEANUP - mng_size_t iObjsize; -#endif - } 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_bool bCorrected; /* indicates if an abstract image - has already been color-corrected */ - - mng_uint8 iAlphabitdepth; /* used only for JNG images */ - mng_uint8 iJHDRcompression; - mng_uint8 iJHDRinterlace; - - mng_uint8 iPixelsampledepth; /* used with delta-images */ - mng_uint8 iAlphasampledepth; - - 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_bool bValid; /* marks invalid when only reading */ - 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; -#ifndef MNG_SKIPCHUNK_MAGN - mng_uint8 iMAGN_MethodX; /* magnification (MAGN) */ - mng_uint8 iMAGN_MethodY; - mng_uint16 iMAGN_MX; - mng_uint16 iMAGN_MY; - mng_uint16 iMAGN_ML; - mng_uint16 iMAGN_MR; - mng_uint16 iMAGN_MT; - mng_uint16 iMAGN_MB; -#endif -#ifndef MNG_SKIPCHUNK_PAST - mng_int32 iPastx; /* target x/y from previous PAST */ - mng_int32 iPasty; -#endif - 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; - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_cHRM -typedef struct { /* global cHRM 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; -#endif - -/* ************************************************************************** */ - -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; - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_iCCP -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; -#endif - -/* ************************************************************************** */ - -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_bool bHasdonotshow; - mng_uint8 iDonotshow; - mng_bool bHasconcrete; - 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_uint32 iSegmentnamesize; - mng_pchar zSegmentname; - } mng_ani_seek; -typedef mng_ani_seek * mng_ani_seekp; - -/* ************************************************************************** */ -#ifndef MNG_NO_DELTA_PNG -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 - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_MAGN -typedef struct { /* MAGN object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint16 iFirstid; - mng_uint16 iLastid; - mng_uint8 iMethodX; - mng_uint16 iMX; - mng_uint16 iMY; - mng_uint16 iML; - mng_uint16 iMR; - mng_uint16 iMT; - mng_uint16 iMB; - mng_uint8 iMethodY; - } mng_ani_magn; -typedef mng_ani_magn * mng_ani_magnp; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_PAST -typedef struct { /* PAST object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint16 iTargetid; - mng_uint8 iTargettype; - mng_int32 iTargetx; - mng_int32 iTargety; - mng_uint32 iCount; - mng_ptr pSources; - } mng_ani_past; -typedef mng_ani_past * mng_ani_pastp; -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_DISC -typedef struct { /* DISC object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint32 iCount; - mng_uint16p pIds; - } mng_ani_disc; -typedef mng_ani_disc * mng_ani_discp; -#endif - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DYNAMICMNG -typedef struct { /* event object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint8 iEventtype; - mng_uint8 iMasktype; - mng_int32 iLeft; - mng_int32 iRight; - mng_int32 iTop; - mng_int32 iBottom; - mng_uint16 iObjectid; - mng_uint8 iIndex; - mng_uint32 iSegmentnamesize; - mng_pchar zSegmentname; - - mng_ani_seekp pSEEK; /* SEEK ani object */ - mng_int32 iLastx; /* last X/Y coordinates */ - mng_int32 iLasty; - } mng_event; -typedef mng_event * mng_eventp; -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_MPNG_PROPOSAL -typedef struct { /* mPNG object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint32 iFramewidth; - mng_uint32 iFrameheight; - mng_uint32 iNumplays; - mng_uint16 iTickspersec; - mng_uint32 iFramessize; - mng_ptr pFrames; - } mng_mpng_obj; -typedef mng_mpng_obj * mng_mpng_objp; -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ANG_PROPOSAL -typedef struct { /* ANG object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint32 iNumframes; - mng_uint32 iTickspersec; - mng_uint32 iNumplays; - mng_uint32 iTilewidth; - mng_uint32 iTileheight; - mng_uint8 iInterlace; - mng_uint8 iStillused; - mng_uint32 iTilessize; - mng_ptr pTiles; - } mng_ang_obj; -typedef mng_ang_obj * mng_ang_objp; -#endif - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_DISPLAY_PROCS */ - -/* ************************************************************************** */ - -#endif /* _libmng_objects_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/plugins/AdvaImg/src/LibMNG/libmng_pixels.c b/plugins/AdvaImg/src/LibMNG/libmng_pixels.c deleted file mode 100644 index 9990ee67bb..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_pixels.c +++ /dev/null @@ -1,24610 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_pixels.c copyright (c) 2000-2005 G.Juyn * */ -/* * version : 1.0.10 * */ -/* * * */ -/* * purpose : Pixel-row management routines (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * comment : implementation of the pixel-row management routines * */ -/* * * */ -/* * the dual alpha-composing for RGBA/BGRA/etc output-canvas' * */ -/* * is based on the Note on Compositing chapter of the * */ -/* * DOH-3 draft, noted to me by Adam M. Costello * */ -/* * * */ -/* * 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/22/2000 - G.Juyn * */ -/* * - added JNG support * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - fixed minor bugs 16-bit pixel-handling * */ -/* * - added delta-image row-processing routines * */ -/* * 0.5.2 - 06/02/2000 - G.Juyn * */ -/* * - fixed endian support (hopefully) * */ -/* * 0.5.2 - 06/03/2000 - G.Juyn * */ -/* * - fixed makeup for Linux gcc compile * */ -/* * 0.5.2 - 06/05/2000 - G.Juyn * */ -/* * - implemented app bkgd restore routines * */ -/* * - implemented RGBA8, ARGB8, BGRA8 & ABGR8 display routines * */ -/* * - added support for RGB8_A8 canvasstyle * */ -/* * 0.5.2 - 06/09/2000 - G.Juyn * */ -/* * - fixed alpha-handling for alpha canvasstyles * */ -/* * * */ -/* * 0.5.3 - 06/16/2000 - G.Juyn * */ -/* * - changed progressive-display processing * */ -/* * 0.5.3 - 06/17/2000 - G.Juyn * */ -/* * - changed to support delta-images * */ -/* * - optimized some store_xxx routines * */ -/* * 0.5.3 - 06/20/2000 - G.Juyn * */ -/* * - fixed nasty bug with embedded PNG after delta-image * */ -/* * 0.5.3 - 06/24/2000 - G.Juyn * */ -/* * - fixed problem with 16-bit GA format * */ -/* * 0.5.3 - 06/25/2000 - G.Juyn * */ -/* * - fixed problem with cheap transparency for 4-bit gray * */ -/* * - fixed display_xxxx routines for interlaced images * */ -/* * 0.5.3 - 06/28/2000 - G.Juyn * */ -/* * - fixed compiler-warning for non-initialized iB variable * */ -/* * * */ -/* * 0.9.1 - 07/05/2000 - G.Juyn * */ -/* * - fixed mandatory BACK color to be opaque * */ -/* * * */ -/* * 0.9.2 - 07/31/2000 - G.Juyn * */ -/* * - B110547 - fixed bug in interlace code * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/20/2000 - G.Juyn * */ -/* * - fixed app-supplied background restore * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * 0.9.3 - 09/30/2000 - G.Juyn * */ -/* * - fixed MAGN rounding errors (thanks Matthias!) * */ -/* * 0.9.3 - 10/10/2000 - G.Juyn * */ -/* * - fixed alpha-blending for RGBA canvasstyle * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - fixed alpha-blending for other alpha-canvasstyles * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added optional support for bKGD for PNG images * */ -/* * - added support for JDAA * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - fixed support for bKGD * */ -/* * 0.9.3 - 10/19/2000 - G.Juyn * */ -/* * - implemented delayed delta-processing * */ -/* * 0.9.3 - 10/28/2000 - G.Juyn * */ -/* * - fixed tRNS processing for gray-image < 8-bits * */ -/* * * */ -/* * 0.9.4 - 12/16/2000 - G.Juyn * */ -/* * - fixed mixup of data- & function-pointers (thanks Dimitri)* */ -/* * 0.9.4 - 1/18/2001 - G.Juyn * */ -/* * - removed "old" MAGN methods 3 & 4 * */ -/* * - added "new" MAGN methods 3, 4 & 5 * */ -/* * - removed test filter-methods 1 & 65 * */ -/* * * */ -/* * 1.0.1 - 04/21/2001 - G.Juyn (code by G.Kelly) * */ -/* * - added BGRA8 canvas with premultiplied alpha * */ -/* * 1.0.1 - 04/25/2001 - G.Juyn * */ -/* * - moved mng_clear_cms to libmng_cms * */ -/* * * */ -/* * 1.0.2 - 06/25/2001 - G.Juyn * */ -/* * - added option to turn off progressive refresh * */ -/* * * */ -/* * 1.0.4 - 11/04/2001 - G.Juyn * */ -/* * - fixed possible compile-problem in cleanup_rowproc * */ -/* * 1.0.4 - 06/22/2002 - G.Juyn * */ -/* * - B558212 - off by one error * */ -/* * - MNG subimage alpha composite wrong for rgba8 images * */ -/* * * */ -/* * 1.0.5 - 08/07/2002 - G.Juyn * */ -/* * - added test-option for PNG filter method 193 (=no filter) * */ -/* * 1.0.5 - 08/15/2002 - G.Juyn * */ -/* * - completed PROM support * */ -/* * - completed delta-image support * */ -/* * 1.0.5 - 08/16/2002 - G.Juyn * */ -/* * - completed MAGN support (16-bit functions) * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * 1.0.5 - 09/19/2002 - G.Juyn * */ -/* * - optimized restore-background for bKGD cases * */ -/* * 1.0.5 - 09/20/2002 - G.Juyn * */ -/* * - finished support for BACK image & tiling * */ -/* * 1.0.5 - 09/22/2002 - G.Juyn * */ -/* * - added bgrx8 canvas (filler byte) * */ -/* * 1.0.5 - 09/23/2002 - G.Juyn * */ -/* * - added compose over/under routines for PAST processing * */ -/* * - added flip & tile routines for PAST processing * */ -/* * * */ -/* * 1.0.6 - 03/09/2003 - G.Juyn * */ -/* * - hiding 12-bit JPEG stuff * */ -/* * 1.0.6 - 05/11/2003 - Glenn RP * */ -/* * - added size-optimization COMPOSE routine usage * */ -/* * 1.0.6 - 05/11/2003 - G. Juyn * */ -/* * - added conditionals around canvas update routines * */ -/* * 1.0.6 - 05/25/2003 - Glenn RP * */ -/* * - added size-optimization DIV255B8 routine usage * */ -/* * 1.0.6 - 06/09/2003 - G. R-P * */ -/* * - added conditionals around 8-bit magn routines * */ -/* * 1.0.6 - 07/07/2003 - G. R-P * */ -/* * - removed conditionals around 8-bit magn routines * */ -/* * - added MNG_NO_16BIT_SUPPORT and MNG_NO_DELTA_PNG * */ -/* * conditionals * */ -/* * - reversed many loops to use decrementing counter * */ -/* * - combined init functions * */ -/* * - converted some switches to array references * */ -/* * 1.0.6 - 07/29/2003 - G.Juyn * */ -/* * - fixed duplicate for-loop * */ -/* * 1.0.6 - 07/29/2003 - G.R-P * */ -/* * - added SKIPCHUNK conditionals around PAST chunk support * */ -/* * - fixed "FOOTPRINT_COMPOSEIV" typo (now "FOOTPRINT_DIV") * */ -/* * 1.0.6 - 08/17/2003 - G.R-P * */ -/* * - added more conditionals around "promote" functions * */ -/* * * */ -/* * 1.0.7 - 11/27/2003 - R.A * */ -/* * - added CANVAS_RGB565 and CANVAS_BGR565 * */ -/* * 1.0.7 - 12/06/2003 - R.A * */ -/* * - added CANVAS_RGBA565 and CANVAS_BGRA565 * */ -/* * 1.0.7 - 01/25/2004 - J.S * */ -/* * - added premultiplied alpha canvas' for RGBA, ARGB, ABGR * */ -/* * 1.0.7 - 03/08/2004 - G.R-P * */ -/* * - added more conditionals around 16-bit-supporting code * */ -/* * 1.0.7 - 03/09/2004 - G.Juyn * */ -/* * - fixed bug in promote_g8_g8 with 16bit support off * */ -/* * 1.0.7 - 03/09/2004 - G.R-P * */ -/* * - more optimizations with 16bit support off * */ -/* * 1.0.7 - 03/10/2004 - G.Juyn * */ -/* * - fixed some warnings for 16bit optimizations * */ -/* * 1.0.7 - 03/21/2004 - G.Juyn * */ -/* * - fixed some 64-bit platform compiler warnings * */ -/* * * */ -/* * 1.0.8 - 06/20/2004 - G.Juyn * */ -/* * - some speed optimizations (thanks to John Stiles) * */ -/* * 1.0.8 - 08/01/2004 - G.Juyn * */ -/* * - added support for 3+byte pixelsize for JPEG's * */ -/* * * */ -/* * 1.0.9 - 10/10/2004 - G.R-P. * */ -/* * - added MNG_NO_1_2_4BIT_SUPPORT * */ -/* * 1.0.9 - 10/14/2004 - G.Juyn * */ -/* * - added bgr565_a8 canvas-style (thanks to J. Elvander) * */ -/* * 1.0.9 - 12/05/2004 - G.Juyn * */ -/* * - added LITTLEENDIAN/BIGENDIAN fixtures (thanks J.Stiles) * */ -/* * - fixed MNG_NO_1_2_4BIT_SUPPORT for TBBN1G04.PNG * */ -/* * 1.0.9 - 12/31/2004 - G.R-P. * */ -/* * - fixed warnings about C++ style (//) comments * */ -/* * * */ -/* * 1.0.10 - 07/06/2005 - G.R-P. * */ -/* * - added MORE MNG_NO_1_2_4BIT_SUPPORT * */ -/* * 1.0.10 - 10/06/2005 - G.R-P. * */ -/* * - alloc more memory for MNG_NO_1_2_4BIT_SUPPORT * */ -/* * 1.0.10 - 12/07/2005 - G.R-P. * */ -/* * - optimized footprint of 16bit support * */ -/* * 1.0.10 - 03/07/2006 - (thanks to W. Manthey) * */ -/* * - added CANVAS_RGB555 and CANVAS_BGR555 * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_objects.h" -#include "libmng_object_prc.h" -#include "libmng_memory.h" -#include "libmng_cms.h" -#include "libmng_filter.h" -#include "libmng_pixels.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_DISPLAY_PROCS - -/* TODO: magnification & canvas-positioning/-clipping */ - -/* TODO: major optimization of pixel-loops by using assembler (?) */ - -/* ************************************************************************** */ -/* * * */ -/* * Interlace tables * */ -/* * * */ -/* ************************************************************************** */ - -MNG_LOCAL mng_uint32 const interlace_row [7] = { 0, 0, 4, 0, 2, 0, 1 }; -MNG_LOCAL mng_uint32 const interlace_rowskip [7] = { 8, 8, 8, 4, 4, 2, 2 }; -MNG_LOCAL mng_uint32 const interlace_col [7] = { 0, 4, 0, 2, 0, 1, 0 }; -MNG_LOCAL mng_uint32 const interlace_colskip [7] = { 8, 8, 4, 4, 2, 2, 1 }; -MNG_LOCAL mng_uint32 const interlace_roundoff [7] = { 7, 7, 3, 3, 1, 1, 0 }; -MNG_LOCAL mng_uint32 const interlace_divider [7] = { 3, 3, 2, 2, 1, 1, 0 }; - -/* ************************************************************************** */ -/* * * */ -/* * Alpha composing macros * */ -/* * the code below is slightly modified from the libpng package * */ -/* * the original was last optimized by Greg Roelofs & Mark Adler * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_COMPOSE8(RET,FG,ALPHA,BG) { \ - mng_uint16 iH = (mng_uint16)((mng_uint16)(FG) * (mng_uint16)(ALPHA) \ - + (mng_uint16)(BG)*(mng_uint16)(255 - \ - (mng_uint16)(ALPHA)) + (mng_uint16)128); \ - (RET) = (mng_uint8)((iH + (iH >> 8)) >> 8); } - -#define MNG_COMPOSE16(RET,FG,ALPHA,BG) { \ - mng_uint32 iH = (mng_uint32)((mng_uint32)(FG) * (mng_uint32)(ALPHA) \ - + (mng_uint32)(BG)*(mng_uint32)(65535L - \ - (mng_uint32)(ALPHA)) + (mng_uint32)32768L); \ - (RET) = (mng_uint16)((iH + (iH >> 16)) >> 16); } - -/* ************************************************************************** */ -/* * * */ -/* * Alpha blending macros * */ -/* * this code is based on Adam Costello's "Note on Compositing" from the * */ -/* * mng-list which gives the following formula: * */ -/* * * */ -/* * top pixel = (Rt, Gt, Bt, At) * */ -/* * bottom pixel = (Rb, Gb, Bb, Ab) * */ -/* * composite pixel = (Rc, Gc, Bc, Ac) * */ -/* * * */ -/* * all values in the range 0..1 * */ -/* * * */ -/* * Ac = 1 - (1 - At)(1 - Ab) * */ -/* * s = At / Ac * */ -/* * t = (1 - At) Ab / Ac * */ -/* * Rc = s Rt + t Rb * */ -/* * Gc = s Gt + t Gb * */ -/* * Bc = s Bt + t Bb * */ -/* * * */ -/* * (I just hope I coded it correctly in integer arithmetic...) * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_BLEND8(RT, GT, BT, AT, RB, GB, BB, AB, RC, GC, BC, AC) { \ - mng_uint32 S, T; \ - (AC) = (mng_uint8)((mng_uint32)255 - \ - ((((mng_uint32)255 - (mng_uint32)(AT)) * \ - ((mng_uint32)255 - (mng_uint32)(AB)) ) >> 8)); \ - S = (mng_uint32)(((mng_uint32)(AT) << 8) / \ - (mng_uint32)(AC)); \ - T = (mng_uint32)(((mng_uint32)255 - (mng_uint32)(AT)) * \ - (mng_uint32)(AB) / (mng_uint32)(AC)); \ - (RC) = (mng_uint8)((S * (mng_uint32)(RT) + \ - T * (mng_uint32)(RB) + (mng_uint32)127) >> 8); \ - (GC) = (mng_uint8)((S * (mng_uint32)(GT) + \ - T * (mng_uint32)(GB) + (mng_uint32)127) >> 8); \ - (BC) = (mng_uint8)((S * (mng_uint32)(BT) + \ - T * (mng_uint32)(BB) + (mng_uint32)127) >> 8); } - -#define MNG_BLEND16(RT, GT, BT, AT, RB, GB, BB, AB, RC, GC, BC, AC) { \ - mng_uint32 S, T; \ - (AC) = (mng_uint16)((mng_uint32)65535 - \ - ((((mng_uint32)65535 - (mng_uint32)(AT)) * \ - ((mng_uint32)65535 - (mng_uint32)(AB)) ) >> 16)); \ - S = (mng_uint32)(((mng_uint32)(AT) << 16) / \ - (mng_uint32)(AC)); \ - T = (mng_uint32)(((mng_uint32)65535 - (mng_uint32)(AT)) * \ - (mng_uint32)(AB) / (mng_uint32)(AC)); \ - (RC) = (mng_uint16)((S * (mng_uint32)(RT) + \ - T * (mng_uint32)(RB) + (mng_uint32)32767) >> 16); \ - (GC) = (mng_uint16)((S * (mng_uint32)(GT) + \ - T * (mng_uint32)(GB) + (mng_uint32)32767) >> 16); \ - (BC) = (mng_uint16)((S * (mng_uint32)(BT) + \ - T * (mng_uint32)(BB) + (mng_uint32)32767) >> 16); } - -/* ************************************************************************** */ - -/* note a good optimizing compiler will optimize this */ -#define DIV255B8(x) (mng_uint8)(((x) + 127) / 255) -#define DIV255B16(x) (mng_uint16)(((x) + 32767) / 65535) - -/* ************************************************************************** */ -/* * * */ -/* * 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 mng_display_progressive_check (mng_datap pData) -{ - if ((pData->bDoProgressive) && /* need progressive display? */ - ((pData->eImagetype != mng_it_mng) || (pData->iDataheight > 300)) && - (pData->iDestb - pData->iDestt > 50) && (!pData->pCurraniobj)) - { - mng_int32 iC = pData->iRow + pData->iDestt - pData->iSourcet; - - if (iC % 20 == 0) /* every 20th line */ - pData->bNeedrefresh = MNG_TRUE; - - } - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Display routines - convert rowdata (which is already color-corrected) * */ -/* * to the output canvas, respecting the opacity information * */ -/* * * */ -/* ************************************************************************** */ - -MNG_LOCAL void check_update_region (mng_datap pData) -{ /* determine actual canvas row */ - mng_int32 iRow = pData->iRow + pData->iDestt - pData->iSourcet; - /* check for change in update-region */ - if ((pData->iDestl < (mng_int32)pData->iUpdateleft) || (pData->iUpdateright == 0)) - pData->iUpdateleft = pData->iDestl; - - if (pData->iDestr > (mng_int32)pData->iUpdateright) - pData->iUpdateright = pData->iDestr; - - if ((iRow < (mng_int32)pData->iUpdatetop) || (pData->iUpdatebottom == 0)) - pData->iUpdatetop = iRow; - - if (iRow+1 > (mng_int32)pData->iUpdatebottom) - pData->iUpdatebottom = iRow+1; - - return; -} - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCANVAS_RGB8 -#ifndef MNG_NO_16BIT_SUPPORT -#ifndef MNG_OPTIMIZE_FOOTPRINT_COMPOSE -mng_retcode mng_display_rgb8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iA16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint8 iA8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB8, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol * 3) + (pData->iDestl * 3); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+4); - - pScanline += (pData->iColinc * 3); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - - pScanline += (pData->iColinc * 3); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA16 = mng_get_uint16 (pDataline+6); - - if (iA16) /* any opacity at all ? */ - { - if (iA16 == 0xFFFF) /* fully opaque ? */ - { /* scale down by dropping the LSB */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+4); - } - else - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGr16 = (mng_uint16)(*pScanline ); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*(pScanline+2)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iA16, iBGr16); - MNG_COMPOSE16(iFGg16, iFGg16, iA16, iBGg16); - MNG_COMPOSE16(iFGb16, iFGb16, iA16, iBGb16); - /* and return the composed values */ - *pScanline = (mng_uint8)(iFGr16 >> 8); - *(pScanline+1) = (mng_uint8)(iFGg16 >> 8); - *(pScanline+2) = (mng_uint8)(iFGb16 >> 8); - } - } - - pScanline += (pData->iColinc * 3); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - - if (iA8) /* any opacity at all ? */ - { - if (iA8 == 0xFF) /* fully opaque ? */ - { /* then simply copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - } - else - { /* do alpha composing */ - MNG_COMPOSE8 (*pScanline, *pDataline, iA8, *pScanline ); - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+1), iA8, *(pScanline+1)); - MNG_COMPOSE8 (*(pScanline+2), *(pDataline+2), iA8, *(pScanline+2)); - } - } - - pScanline += (pData->iColinc * 3); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#else /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -mng_retcode mng_display_rgb8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iA16; - mng_uint16 iFGg16; - mng_uint16 iBGg16; - mng_uint8 iA8; - mng_uint8 iBps; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB8, MNG_LC_START); -#endif - - iBps=(mng_uint8)(pData->bIsRGBA16 ? 2:1); - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol * 3) + (pData->iDestl * 3); - pDataline = pData->pRGBArow; /* address source row */ - - /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << (iBps+1)); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+iBps); - *(pScanline+2) = *(pDataline+2*iBps); - - pScanline += (pData->iColinc * 3); - pDataline += 4*iBps; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA16 = mng_get_uint16 (pDataline+6); - - if (iA16) /* any opacity at all ? */ - { - if (iA16 == 0xFFFF) /* fully opaque ? */ - { /* scale down by dropping the LSB */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+4); - } - else - { /* get the proper values */ - int i; - for (i=2; i >= 0; i--) - { - iFGg16 = mng_get_uint16 (pDataline+i+i); - /* scale background up */ - iBGg16 = (mng_uint16)(*(pScanline+i)); - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - /* now compose */ - MNG_COMPOSE16(iFGg16, iFGg16, iA16, iBGg16); - /* and return the composed values */ - *(pScanline+i) = (mng_uint8)(iFGg16 >> 8); - } - } - } - - pScanline += (pData->iColinc * 3); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - - if (iA8) /* any opacity at all ? */ - { - if (iA8 == 0xFF) /* fully opaque ? */ - { /* then simply copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - } - else - { /* do alpha composing */ - int i; - for (i=2; i >= 0; i--) - { - MNG_COMPOSE8 (*(pScanline+i), *(pDataline+i), iA8, *(pScanline+i)); - } - } - } - - pScanline += (pData->iColinc * 3); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -#else /* MNG_NO_16BIT_SUPPORT */ -mng_retcode mng_display_rgb8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iA8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB8, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol * 3) + (pData->iDestl * 3); - pDataline = pData->pRGBArow; /* address source row */ - - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - - pScanline += (pData->iColinc * 3); - pDataline += 4; - } - } - } - else - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - - if (iA8) /* any opacity at all ? */ - { - if (iA8 == 0xFF) /* fully opaque ? */ - { /* then simply copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - } - else - { /* do alpha composing */ -#ifdef MNG_OPTIMIZE_FOOTPRINT_COMPOSE - int i; - for (i=2; i >= 0; i--) - { - MNG_COMPOSE8 (*(pScanline+i), *(pDataline+i), iA8, *(pScanline+i)); - } -#else - MNG_COMPOSE8 (*pScanline, *pDataline, iA8, *pScanline ); - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+1), iA8, *(pScanline+1)); - MNG_COMPOSE8 (*(pScanline+2), *(pDataline+2), iA8, *(pScanline+2)); -#endif - } - } - - pScanline += (pData->iColinc * 3); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_16BIT_SUPPORT */ -#endif /* MNG_SKIPCANVAS_RGB8 */ - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCANVAS_RGBA8 -#ifndef MNG_NO_16BIT_SUPPORT -#ifndef MNG_OPTIMIZE_FOOTPRINT_COMPOSE -mng_retcode mng_display_rgba8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint16 iFGa16, iBGa16, iCa16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16; - mng_uint8 iCr8, iCg8, iCb8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGBA8, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+4); - *(pScanline+3) = *(pDataline+6); - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - *(pScanline+3) = *(pDataline+3); - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha values */ - iFGa16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*(pScanline+3)); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iFGa16) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa16 == 0xFFFF) || (iBGa16 == 0)) - { /* plain copy it */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+4); - *(pScanline+3) = *(pDataline+6); - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGr16 = (mng_uint16)(*pScanline ); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*(pScanline+2)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iFGa16, iBGr16); - MNG_COMPOSE16(iFGg16, iFGg16, iFGa16, iBGg16); - MNG_COMPOSE16(iFGb16, iFGb16, iFGa16, iBGb16); - /* and return the composed values */ - *pScanline = (mng_uint8)(iFGr16 >> 8); - *(pScanline+1) = (mng_uint8)(iFGg16 >> 8); - *(pScanline+2) = (mng_uint8)(iFGb16 >> 8); - /* alpha remains fully opaque !!! */ - } - else - { /* scale background up */ - iBGr16 = (mng_uint16)(*pScanline ); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*(pScanline+2)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16); - /* and return the composed values */ - *pScanline = (mng_uint8)(iCr16 >> 8); - *(pScanline+1) = (mng_uint8)(iCg16 >> 8); - *(pScanline+2) = (mng_uint8)(iCb16 >> 8); - *(pScanline+3) = (mng_uint8)(iCa16 >> 8); - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *(pScanline+3); - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - *(pScanline+3) = *(pDataline+3); - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do alpha composing */ - MNG_COMPOSE8 (*pScanline, *pDataline, iFGa8, *pScanline ); - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+1), iFGa8, *(pScanline+1)); - MNG_COMPOSE8 (*(pScanline+2), *(pDataline+2), iFGa8, *(pScanline+2)); - /* alpha remains fully opaque !!! */ - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - *pScanline, *(pScanline+1), *(pScanline+2), iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - *pScanline = iCr8; - *(pScanline+1) = iCg8; - *(pScanline+2) = iCb8; - *(pScanline+3) = iCa8; - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGBA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#else /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -mng_retcode mng_display_rgba8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint16 iFGa16, iBGa16, iCa16; - mng_uint16 iFGg16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16; - mng_uint8 iCr8, iCg8, iCb8; - mng_uint8 iBps; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGBA8, MNG_LC_START); -#endif - - iBps=(mng_uint8)(pData->bIsRGBA16 ? 2:1); - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << (iBps+1)); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+iBps); - *(pScanline+2) = *(pDataline+2*iBps); - *(pScanline+3) = *(pDataline+3*iBps); - - pScanline += (pData->iColinc << 2); - pDataline += 4*iBps; - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha values */ - iFGa16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*(pScanline+3)); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iFGa16) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa16 == 0xFFFF) || (iBGa16 == 0)) - { /* plain copy it */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+4); - *(pScanline+3) = *(pDataline+6); - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* get the proper values */ - int i; - for (i=2; i >= 0; i--) - { - iFGg16 = mng_get_uint16 (pDataline+i+i); - /* scale background up */ - iBGg16 = (mng_uint16)(*(pScanline+i)); - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - /* now compose */ - MNG_COMPOSE16(iFGg16, iFGg16, iFGa16, iBGg16); - /* and return the composed values */ - *(pScanline+i) = (mng_uint8)(iFGg16 >> 8); - /* alpha remains fully opaque !!! */ - } - } - else - { /* scale background up */ - iBGr16 = (mng_uint16)(*pScanline ); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*(pScanline+2)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16); - /* and return the composed values */ - *pScanline = (mng_uint8)(iCr16 >> 8); - *(pScanline+1) = (mng_uint8)(iCg16 >> 8); - *(pScanline+2) = (mng_uint8)(iCb16 >> 8); - *(pScanline+3) = (mng_uint8)(iCa16 >> 8); - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *(pScanline+3); - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - *(pScanline+3) = *(pDataline+3); - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do alpha composing */ - int i; - for (i=2; i >= 0; i--) - { - MNG_COMPOSE8 (*(pScanline+i), *(pDataline+i), iFGa8, *(pScanline+i)); - } - /* alpha remains fully opaque !!! */ - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - *pScanline, *(pScanline+1), *(pScanline+2), iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - *pScanline = iCr8; - *(pScanline+1) = iCg8; - *(pScanline+2) = iCb8; - *(pScanline+3) = iCa8; - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGBA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -#else /* MNG_NO_16BIT_SUPPORT */ -mng_retcode mng_display_rgba8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint8 iCr8, iCg8, iCb8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGBA8, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - *(pScanline+3) = *(pDataline+3); - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *(pScanline+3); - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - *(pScanline+3) = *(pDataline+3); - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do alpha composing */ -#ifdef MNG_OPTIMIZE_FOOTPRINT_COMPOSE - int i; - for (i=2; i >= 0; i--) - { - MNG_COMPOSE8 (*(pScanline+i), *(pDataline+i), iFGa8, *(pScanline+i)); - } -#else - MNG_COMPOSE8 (*pScanline, *pDataline, iFGa8, *pScanline ); - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+1), iFGa8, *(pScanline+1)); - MNG_COMPOSE8 (*(pScanline+2), *(pDataline+2), iFGa8, *(pScanline+2)); -#endif - /* alpha remains fully opaque !!! */ - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - *pScanline, *(pScanline+1), *(pScanline+2), iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - *pScanline = iCr8; - *(pScanline+1) = iCg8; - *(pScanline+2) = iCb8; - *(pScanline+3) = iCa8; - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGBA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_16BIT_SUPPORT */ -#endif /* MNG_SKIPCANVAS_RGBA8 */ - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCANVAS_RGBA8_PM -#ifndef MNG_NO_16BIT_SUPPORT -#ifndef MNG_OPTIMIZE_FOOTPRINT_COMPOSE -mng_retcode mng_display_rgba8_pm (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint32 s, t; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGBA8_PM, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - if ((s = pDataline[6]) == 0) - *(mng_uint32*) pScanline = 0; /* set all components = 0 */ - else - { - if (s == 255) - { - pScanline[0] = pDataline[0]; - pScanline[1] = pDataline[2]; - pScanline[2] = pDataline[4]; - pScanline[3] = 255; - } - else - { -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - int i; - for (i=2; i >= 0; i--) - { - pScanline[2-i] = DIV255B8(s * pDataline[4-i-i]); - } -#else - pScanline[0] = DIV255B8(s * pDataline[0]); - pScanline[1] = DIV255B8(s * pDataline[2]); - pScanline[2] = DIV255B8(s * pDataline[4]); -#endif - pScanline[3] = (mng_uint8)s; - } - } - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values and premultiply */ - if ((s = pDataline[3]) == 0) - *(mng_uint32*) pScanline = 0; /* set all components = 0 */ - else - { - if (s == 255) - { -#ifdef MNG_BIGENDIAN_SUPPORTED - *(mng_uint32*)pScanline = (*(mng_uint32*)pDataline) | 0x000000FF; -#else - pScanline[0] = pDataline[0]; - pScanline[1] = pDataline[1]; - pScanline[2] = pDataline[2]; - pScanline[3] = 255; -#endif - } - else - { -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - int i; - for (i=2; i >= 0; i--) - { - pScanline[2-i] = DIV255B8(s * pDataline[2-i]); - } -#else - pScanline[0] = DIV255B8(s * pDataline[0]); - pScanline[1] = DIV255B8(s * pDataline[1]); - pScanline[2] = DIV255B8(s * pDataline[2]); -#endif - pScanline[3] = (mng_uint8)s; - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha values */ - if ((s = pDataline[6]) != 0) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if (s == 255) - { /* plain copy it */ - pScanline[0] = pDataline[0]; - pScanline[1] = pDataline[2]; - pScanline[2] = pDataline[4]; - pScanline[3] = 255; - } - else - { /* now blend (premultiplied) */ - t = 255 - s; -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[2-i] = DIV255B8(s * pDataline[4-i-i] + t * - pScanline[2-i]); - } - } -#else - pScanline[0] = DIV255B8(s * pDataline[0] + t * pScanline[0]); - pScanline[1] = DIV255B8(s * pDataline[2] + t * pScanline[1]); - pScanline[2] = DIV255B8(s * pDataline[4] + t * pScanline[2]); -#endif - pScanline[3] = (mng_uint8)(255 - DIV255B8(t * (255 - pScanline[3]))); - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - if ((s = pDataline[3]) != 0) /* any opacity at all ? */ - { /* fully opaque ? */ - if (s == 255) - { /* then simply copy the values */ -#ifdef MNG_BIGENDIAN_SUPPORTED - *(mng_uint32*)pScanline = (*(mng_uint32*)pDataline) | 0x000000FF; -#else - pScanline[0] = pDataline[0]; - pScanline[1] = pDataline[1]; - pScanline[2] = pDataline[2]; - pScanline[3] = 255; -#endif - } - else - { /* now blend (premultiplied) */ - t = 255 - s; -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[2-i] = DIV255B8(s * pDataline[2-i] + t * - pScanline[2-i]); - } - } -#else - pScanline[0] = DIV255B8(s * pDataline[0] + t * pScanline[0]); - pScanline[1] = DIV255B8(s * pDataline[1] + t * pScanline[1]); - pScanline[2] = DIV255B8(s * pDataline[2] + t * pScanline[2]); -#endif - pScanline[3] = (mng_uint8)(255 - DIV255B8(t * (255 - pScanline[3]))); - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGBA8_PM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#else /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -mng_retcode mng_display_rgba8_pm (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint32 s, t; - mng_uint8 iBps; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGBA8_PM, MNG_LC_START); -#endif - - iBps=(mng_uint8)(pData->bIsRGBA16 ? 2:1); - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << (iBps+1)); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - if ((s = pDataline[6]) == 0) - *(mng_uint32*) pScanline = 0; /* set all components = 0 */ - else - { - if (s == 255) - { - pScanline[0] = pDataline[0]; - pScanline[1] = pDataline[2]; - pScanline[2] = pDataline[4]; - pScanline[3] = 255; - } - else - { -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - int i; - for (i=2; i >= 0; i--) - { - pScanline[2-i] = DIV255B8(s * pDataline[4-i-i]); - } -#else - pScanline[0] = DIV255B8(s * pDataline[0]); - pScanline[1] = DIV255B8(s * pDataline[2]); - pScanline[2] = DIV255B8(s * pDataline[4]); -#endif - pScanline[3] = (mng_uint8)s; - } - } - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values and premultiply */ - if ((s = pDataline[3]) == 0) - *(mng_uint32*) pScanline = 0; /* set all components = 0 */ - else - { - if (s == 255) - { -#ifdef MNG_BIGENDIAN_SUPPORTED - *(mng_uint32*)pScanline = (*(mng_uint32*)pDataline) | 0x000000FF; -#else - pScanline[0] = pDataline[0]; - pScanline[1] = pDataline[1]; - pScanline[2] = pDataline[2]; - pScanline[3] = 255; -#endif - } - else - { -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - int i; - for (i=2; i >= 0; i--) - { - pScanline[2-i] = DIV255B8(s * pDataline[2-i]); - } -#else - pScanline[0] = DIV255B8(s * pDataline[0]); - pScanline[1] = DIV255B8(s * pDataline[1]); - pScanline[2] = DIV255B8(s * pDataline[2]); -#endif - pScanline[3] = (mng_uint8)s; - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha values */ - if ((s = pDataline[6]) != 0) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if (s == 255) - { /* plain copy it */ - pScanline[0] = pDataline[0]; - pScanline[1] = pDataline[2]; - pScanline[2] = pDataline[4]; - pScanline[3] = 255; - } - else - { /* now blend (premultiplied) */ - t = 255 - s; -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[2-i] = DIV255B8(s * pDataline[4-i-i] + t * - pScanline[2-i]); - } - } -#else - pScanline[0] = DIV255B8(s * pDataline[0] + t * pScanline[0]); - pScanline[1] = DIV255B8(s * pDataline[2] + t * pScanline[1]); - pScanline[2] = DIV255B8(s * pDataline[4] + t * pScanline[2]); -#endif - pScanline[3] = (mng_uint8)(255 - DIV255B8(t * (255 - pScanline[3]))); - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - if ((s = pDataline[3]) != 0) /* any opacity at all ? */ - { /* fully opaque ? */ - if (s == 255) - { /* then simply copy the values */ -#ifdef MNG_BIGENDIAN_SUPPORTED - *(mng_uint32*)pScanline = (*(mng_uint32*)pDataline) | 0x000000FF; -#else - pScanline[0] = pDataline[0]; - pScanline[1] = pDataline[1]; - pScanline[2] = pDataline[2]; - pScanline[3] = 255; -#endif - } - else - { /* now blend (premultiplied) */ - t = 255 - s; -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[2-i] = DIV255B8(s * pDataline[2-i] + t * - pScanline[2-i]); - } - } -#else - pScanline[0] = DIV255B8(s * pDataline[0] + t * pScanline[0]); - pScanline[1] = DIV255B8(s * pDataline[1] + t * pScanline[1]); - pScanline[2] = DIV255B8(s * pDataline[2] + t * pScanline[2]); -#endif - pScanline[3] = (mng_uint8)(255 - DIV255B8(t * (255 - pScanline[3]))); - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGBA8_PM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -#else /* MNG_NO_16BIT_SUPPORT */ -mng_retcode mng_display_rgba8_pm (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint32 s, t; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGBA8_PM, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values and premultiply */ - if ((s = pDataline[3]) == 0) - *(mng_uint32*) pScanline = 0; /* set all components = 0 */ - else - { - if (s == 255) - { -#ifdef MNG_BIGENDIAN_SUPPORTED - *(mng_uint32*)pScanline = (*(mng_uint32*)pDataline) | 0x000000FF; -#else - pScanline[0] = pDataline[0]; - pScanline[1] = pDataline[1]; - pScanline[2] = pDataline[2]; - pScanline[3] = 255; -#endif - } - else - { -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - int i; - for (i=2; i >= 0; i--) - { - pScanline[2-i] = DIV255B8(s * pDataline[2-i]); - } -#else - pScanline[0] = DIV255B8(s * pDataline[0]); - pScanline[1] = DIV255B8(s * pDataline[1]); - pScanline[2] = DIV255B8(s * pDataline[2]); -#endif - pScanline[3] = (mng_uint8)s; - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - if ((s = pDataline[3]) != 0) /* any opacity at all ? */ - { /* fully opaque ? */ - if (s == 255) - { /* then simply copy the values */ -#ifdef MNG_BIGENDIAN_SUPPORTED - *(mng_uint32*)pScanline = (*(mng_uint32*)pDataline) | 0x000000FF; -#else - pScanline[0] = pDataline[0]; - pScanline[1] = pDataline[1]; - pScanline[2] = pDataline[2]; - pScanline[3] = 255; -#endif - } - else - { /* now blend (premultiplied) */ - t = 255 - s; -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[2-i] = DIV255B8(s * pDataline[2-i] + t * - pScanline[2-i]); - } - } -#else - pScanline[0] = DIV255B8(s * pDataline[0] + t * pScanline[0]); - pScanline[1] = DIV255B8(s * pDataline[1] + t * pScanline[1]); - pScanline[2] = DIV255B8(s * pDataline[2] + t * pScanline[2]); -#endif - pScanline[3] = (mng_uint8)(255 - DIV255B8(t * (255 - pScanline[3]))); - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGBA8_PM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_16BIT_SUPPORT */ -#endif /* MNG_SKIPCANVAS_RGBA8_PM */ - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCANVAS_ARGB8 -#ifndef MNG_NO_16BIT_SUPPORT -#ifndef MNG_OPTIMIZE_FOOTPRINT_COMPOSE -mng_retcode mng_display_argb8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint16 iFGa16, iBGa16, iCa16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16; - mng_uint8 iCr8, iCg8, iCb8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ARGB8, MNG_LC_START); -#endif - - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *(pDataline+6); - *(pScanline+1) = *pDataline; - *(pScanline+2) = *(pDataline+2); - *(pScanline+3) = *(pDataline+4); - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *pScanline = *(pDataline+3); - *(pScanline+1) = *pDataline; - *(pScanline+2) = *(pDataline+1); - *(pScanline+3) = *(pDataline+2); - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha values */ - iFGa16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*pScanline); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iFGa16) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa16 == 0xFFFF) || (iBGa16 == 0)) - { /* plain copy it */ - *pScanline = *(pDataline+6); - *(pScanline+1) = *pDataline; - *(pScanline+2) = *(pDataline+2); - *(pScanline+3) = *(pDataline+4); - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGr16 = (mng_uint16)(*(pScanline+1)); - iBGg16 = (mng_uint16)(*(pScanline+2)); - iBGb16 = (mng_uint16)(*(pScanline+3)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iFGa16, iBGr16); - MNG_COMPOSE16(iFGg16, iFGg16, iFGa16, iBGg16); - MNG_COMPOSE16(iFGb16, iFGb16, iFGa16, iBGb16); - /* and return the composed values */ - /* alpha remains fully opaque !!! */ - *(pScanline+1) = (mng_uint8)(iFGr16 >> 8); - *(pScanline+2) = (mng_uint8)(iFGg16 >> 8); - *(pScanline+3) = (mng_uint8)(iFGb16 >> 8); - } - else - { /* scale background up */ - iBGr16 = (mng_uint16)(*(pScanline+1)); - iBGg16 = (mng_uint16)(*(pScanline+2)); - iBGb16 = (mng_uint16)(*(pScanline+3)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16); - /* and return the composed values */ - *pScanline = (mng_uint8)(iCa16 >> 8); - *(pScanline+1) = (mng_uint8)(iCr16 >> 8); - *(pScanline+2) = (mng_uint8)(iCg16 >> 8); - *(pScanline+3) = (mng_uint8)(iCb16 >> 8); - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *pScanline; - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pScanline = *(pDataline+3); - *(pScanline+1) = *pDataline; - *(pScanline+2) = *(pDataline+1); - *(pScanline+3) = *(pDataline+2); - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do simple alpha composing */ - /* alpha itself remains fully opaque !!! */ - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - *(pScanline+1), *(pScanline+2), *(pScanline+3), iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - *pScanline = iCa8; - *(pScanline+1) = iCr8; - *(pScanline+2) = iCg8; - *(pScanline+3) = iCb8; - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ARGB8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#else /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -mng_retcode mng_display_argb8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint16 iFGa16, iBGa16, iCa16; - mng_uint16 iFGg16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16; - mng_uint8 iCr8, iCg8, iCb8; - mng_uint8 iBps; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ARGB8, MNG_LC_START); -#endif - - iBps=(mng_uint8)(pData->bIsRGBA16 ? 2:1); - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << (iBps+1)); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *(pDataline+3*iBps); - *(pScanline+1) = *pDataline; - *(pScanline+2) = *(pDataline+iBps); - *(pScanline+3) = *(pDataline+2*iBps); - - pScanline += (pData->iColinc << 2); - pDataline += 4*iBps; - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha values */ - iFGa16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*pScanline); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iFGa16) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa16 == 0xFFFF) || (iBGa16 == 0)) - { /* plain copy it */ - *pScanline = *(pDataline+6); - *(pScanline+1) = *pDataline; - *(pScanline+2) = *(pDataline+2); - *(pScanline+3) = *(pDataline+4); - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* get the proper values */ - int i; - for (i=2; i >= 0; i--) - { - iFGg16 = mng_get_uint16 (pDataline+i+i); - /* scale background up */ - iBGg16 = (mng_uint16)(*(pScanline+i+1)); - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - /* now compose */ - MNG_COMPOSE16(iFGg16, iFGg16, iFGa16, iBGg16); - /* and return the composed values */ - /* alpha remains fully opaque !!! */ - *(pScanline+i+1) = (mng_uint8)(iFGg16 >> 8); - } - } - else - { /* scale background up */ - iBGr16 = (mng_uint16)(*(pScanline+1)); - iBGg16 = (mng_uint16)(*(pScanline+2)); - iBGb16 = (mng_uint16)(*(pScanline+3)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16); - /* and return the composed values */ - *pScanline = (mng_uint8)(iCa16 >> 8); - *(pScanline+1) = (mng_uint8)(iCr16 >> 8); - *(pScanline+2) = (mng_uint8)(iCg16 >> 8); - *(pScanline+3) = (mng_uint8)(iCb16 >> 8); - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *pScanline; - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pScanline = *(pDataline+3); - *(pScanline+1) = *pDataline; - *(pScanline+2) = *(pDataline+1); - *(pScanline+3) = *(pDataline+2); - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do simple alpha composing */ - /* alpha itself remains fully opaque !!! */ - int i; - for (i=2; i >= 0; i--) - { - MNG_COMPOSE8 (*(pScanline+i+1), *(pDataline+i), iFGa8, *(pScanline+i+1)); - } - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - *(pScanline+1), *(pScanline+2), *(pScanline+3), iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - *pScanline = iCa8; - *(pScanline+1) = iCr8; - *(pScanline+2) = iCg8; - *(pScanline+3) = iCb8; - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ARGB8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -#else /* MNG_NO_16BIT_SUPPORT */ -mng_retcode mng_display_argb8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint8 iCr8, iCg8, iCb8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ARGB8, MNG_LC_START); -#endif - - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *pScanline = *(pDataline+3); - *(pScanline+1) = *pDataline; - *(pScanline+2) = *(pDataline+1); - *(pScanline+3) = *(pDataline+2); - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *pScanline; - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pScanline = *(pDataline+3); - *(pScanline+1) = *pDataline; - *(pScanline+2) = *(pDataline+1); - *(pScanline+3) = *(pDataline+2); - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do simple alpha composing */ - /* alpha itself remains fully opaque !!! */ -#ifdef MNG_OPTIMIZE_FOOTPRINT_COMPOSE - int i; - for (i=2; i >= 0; i--) - { - MNG_COMPOSE8 (*(pScanline+i+1), *(pDataline+i), iFGa8, *(pScanline+i+1)); - } -#else - MNG_COMPOSE8 (*(pScanline+1), *pDataline, iFGa8, *(pScanline+1)); - MNG_COMPOSE8 (*(pScanline+2), *(pDataline+1), iFGa8, *(pScanline+2)); - MNG_COMPOSE8 (*(pScanline+3), *(pDataline+2), iFGa8, *(pScanline+3)); -#endif - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - *(pScanline+1), *(pScanline+2), *(pScanline+3), iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - *pScanline = iCa8; - *(pScanline+1) = iCr8; - *(pScanline+2) = iCg8; - *(pScanline+3) = iCb8; - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ARGB8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_16BIT_SUPPORT */ -#endif /* MNG_SKIPCANVAS_ARGB8 */ - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCANVAS_ARGB8_PM -#ifndef MNG_NO_16BIT_SUPPORT -#ifndef MNG_OPTIMIZE_FOOTPRINT_COMPOSE -mng_retcode mng_display_argb8_pm (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint32 s, t; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ARGB8_PM, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - if ((s = pDataline[6]) == 0) - *(mng_uint32*) pScanline = 0; /* set all components = 0 */ - else - { - if (s == 255) - { - pScanline[0] = 255; - pScanline[1] = pDataline[0]; - pScanline[2] = pDataline[2]; - pScanline[3] = pDataline[4]; - } - else - { - pScanline[0] = (mng_uint8)s; -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[3-i] = DIV255B8(s * pDataline[4-i-i]); - } - } -#else - pScanline[1] = DIV255B8(s * pDataline[0]); - pScanline[2] = DIV255B8(s * pDataline[2]); - pScanline[3] = DIV255B8(s * pDataline[4]); -#endif - } - } - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values and premultiply */ - if ((s = pDataline[3]) == 0) - *(mng_uint32*) pScanline = 0; /* set all components = 0 */ - else - { - if (s == 255) - { - pScanline[0] = 255; - pScanline[1] = pDataline[0]; - pScanline[2] = pDataline[1]; - pScanline[3] = pDataline[2]; - } - else - { - pScanline[0] = (mng_uint8)s; -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[3-i] = DIV255B8(s * pDataline[2-i]); - } - } -#else - pScanline[1] = DIV255B8(s * pDataline[0]); - pScanline[2] = DIV255B8(s * pDataline[1]); - pScanline[3] = DIV255B8(s * pDataline[2]); -#endif - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha values */ - if ((s = pDataline[6]) != 0) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if (s == 255) - { /* plain copy it */ - pScanline[0] = 255; - pScanline[1] = pDataline[0]; - pScanline[2] = pDataline[2]; - pScanline[3] = pDataline[4]; - } - else - { /* now blend (premultiplied) */ - t = 255 - s; - pScanline[0] = (mng_uint8)(255 - DIV255B8(t * (255 - pScanline[0]))); -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[3-i] = DIV255B8(s * pDataline[4-i-i] + t * - pScanline[3-i]); - } - } -#else - pScanline[1] = DIV255B8(s * pDataline[0] + t * pScanline[1]); - pScanline[2] = DIV255B8(s * pDataline[2] + t * pScanline[2]); - pScanline[3] = DIV255B8(s * pDataline[4] + t * pScanline[3]); -#endif - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - if ((s = pDataline[3]) != 0) /* any opacity at all ? */ - { /* fully opaque ? */ - if (s == 255) - { /* then simply copy the values */ - pScanline[0] = 255; - pScanline[1] = pDataline[0]; - pScanline[2] = pDataline[1]; - pScanline[3] = pDataline[2]; - } - else - { /* now blend (premultiplied) */ - t = 255 - s; - pScanline[0] = (mng_uint8)(255 - DIV255B8(t * (255 - pScanline[0]))); -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[3-i] = DIV255B8(s * pDataline[2-i] + t * - pScanline[3-i]); - } - } -#else - pScanline[1] = DIV255B8(s * pDataline[0] + t * pScanline[1]); - pScanline[2] = DIV255B8(s * pDataline[1] + t * pScanline[2]); - pScanline[3] = DIV255B8(s * pDataline[2] + t * pScanline[3]); -#endif - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ARGB8_PM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#else /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -mng_retcode mng_display_argb8_pm (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint32 s, t; - mng_uint8 iBps; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ARGB8_PM, MNG_LC_START); -#endif - - iBps=(mng_uint8)(pData->bIsRGBA16 ? 2:1); - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << (iBps+1)); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - if ((s = pDataline[6]) == 0) - *(mng_uint32*) pScanline = 0; /* set all components = 0 */ - else - { - if (s == 255) - { - pScanline[0] = 255; - pScanline[1] = pDataline[0]; - pScanline[2] = pDataline[2]; - pScanline[3] = pDataline[4]; - } - else - { - pScanline[0] = (mng_uint8)s; -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[3-i] = DIV255B8(s * pDataline[4-i-i]); - } - } -#else - pScanline[1] = DIV255B8(s * pDataline[0]); - pScanline[2] = DIV255B8(s * pDataline[2]); - pScanline[3] = DIV255B8(s * pDataline[4]); -#endif - } - } - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values and premultiply */ - if ((s = pDataline[3]) == 0) - *(mng_uint32*) pScanline = 0; /* set all components = 0 */ - else - { - if (s == 255) - { - pScanline[0] = 255; - pScanline[1] = pDataline[0]; - pScanline[2] = pDataline[1]; - pScanline[3] = pDataline[2]; - } - else - { - pScanline[0] = (mng_uint8)s; -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[3-i] = DIV255B8(s * pDataline[2-i]); - } - } -#else - pScanline[1] = DIV255B8(s * pDataline[0]); - pScanline[2] = DIV255B8(s * pDataline[1]); - pScanline[3] = DIV255B8(s * pDataline[2]); -#endif - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha values */ - if ((s = pDataline[6]) != 0) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if (s == 255) - { /* plain copy it */ - pScanline[0] = 255; - pScanline[1] = pDataline[0]; - pScanline[2] = pDataline[2]; - pScanline[3] = pDataline[4]; - } - else - { /* now blend (premultiplied) */ - t = 255 - s; - pScanline[0] = (mng_uint8)(255 - DIV255B8(t * (255 - pScanline[0]))); -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[3-i] = DIV255B8(s * pDataline[4-i-i] + t * - pScanline[3-i]); - } - } -#else - pScanline[1] = DIV255B8(s * pDataline[0] + t * pScanline[1]); - pScanline[2] = DIV255B8(s * pDataline[2] + t * pScanline[2]); - pScanline[3] = DIV255B8(s * pDataline[4] + t * pScanline[3]); -#endif - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - if ((s = pDataline[3]) != 0) /* any opacity at all ? */ - { /* fully opaque ? */ - if (s == 255) - { /* then simply copy the values */ - pScanline[0] = 255; - pScanline[1] = pDataline[0]; - pScanline[2] = pDataline[1]; - pScanline[3] = pDataline[2]; - } - else - { /* now blend (premultiplied) */ - t = 255 - s; - pScanline[0] = (mng_uint8)(255 - DIV255B8(t * (255 - pScanline[0]))); -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[3-i] = DIV255B8(s * pDataline[2-i] + t * - pScanline[3-i]); - } - } -#else - pScanline[1] = DIV255B8(s * pDataline[0] + t * pScanline[1]); - pScanline[2] = DIV255B8(s * pDataline[1] + t * pScanline[2]); - pScanline[3] = DIV255B8(s * pDataline[2] + t * pScanline[3]); -#endif - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ARGB8_PM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -#else /* MNG_NO_16BIT_SUPPORT */ -mng_retcode mng_display_argb8_pm (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint32 s, t; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ARGB8_PM, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values and premultiply */ - if ((s = pDataline[3]) == 0) - *(mng_uint32*) pScanline = 0; /* set all components = 0 */ - else - { - if (s == 255) - { - pScanline[0] = 255; - pScanline[1] = pDataline[0]; - pScanline[2] = pDataline[1]; - pScanline[3] = pDataline[2]; - } - else - { - pScanline[0] = (mng_uint8)s; -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[3-i] = DIV255B8(s * pDataline[2-i]); - } - } -#else - pScanline[1] = DIV255B8(s * pDataline[0]); - pScanline[2] = DIV255B8(s * pDataline[1]); - pScanline[3] = DIV255B8(s * pDataline[2]); -#endif - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - if ((s = pDataline[3]) != 0) /* any opacity at all ? */ - { /* fully opaque ? */ - if (s == 255) - { /* then simply copy the values */ - pScanline[0] = 255; - pScanline[1] = pDataline[0]; - pScanline[2] = pDataline[1]; - pScanline[3] = pDataline[2]; - } - else - { /* now blend (premultiplied) */ - t = 255 - s; - pScanline[0] = (mng_uint8)(255 - DIV255B8(t * (255 - pScanline[0]))); -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[3-i] = DIV255B8(s * pDataline[2-i] + t * - pScanline[3-i]); - } - } -#else - pScanline[1] = DIV255B8(s * pDataline[0] + t * pScanline[1]); - pScanline[2] = DIV255B8(s * pDataline[1] + t * pScanline[2]); - pScanline[3] = DIV255B8(s * pDataline[2] + t * pScanline[3]); -#endif - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ARGB8_PM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_16BIT_SUPPORT */ -#endif /* MNG_SKIPCANVAS_ARGB8_PM */ - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCANVAS_RGB8_A8 -#ifndef MNG_NO_16BIT_SUPPORT -#ifndef MNG_OPTIMIZE_FOOTPRINT_COMPOSE -mng_retcode mng_display_rgb8_a8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pAlphaline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint16 iFGa16, iBGa16, iCa16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16; - mng_uint8 iCr8, iCg8, iCb8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB8_A8, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination rows */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - pAlphaline = (mng_uint8p)pData->fGetalphaline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination rows starting-point */ - pScanline = pScanline + (pData->iCol * 3) + (pData->iDestl * 3); - pAlphaline = pAlphaline + pData->iCol + pData->iDestl; - - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+4); - *pAlphaline = *(pDataline+6); - - pScanline += (pData->iColinc * 3); - pAlphaline += pData->iColinc; - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - *pAlphaline = *(pDataline+3); - - pScanline += (pData->iColinc * 3); - pAlphaline += pData->iColinc; - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha values */ - iFGa16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*pAlphaline); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iFGa16) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa16 == 0xFFFF) || (iBGa16 == 0)) - { /* plain copy it */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+4); - *pAlphaline = *(pDataline+6); - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGr16 = (mng_uint16)(*pScanline ); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*(pScanline+2)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iFGa16, iBGr16); - MNG_COMPOSE16(iFGg16, iFGg16, iFGa16, iBGg16); - MNG_COMPOSE16(iFGb16, iFGb16, iFGa16, iBGb16); - /* and return the composed values */ - *pScanline = (mng_uint8)(iFGr16 >> 8); - *(pScanline+1) = (mng_uint8)(iFGg16 >> 8); - *(pScanline+2) = (mng_uint8)(iFGb16 >> 8); - /* alpha remains fully opaque !!! */ - } - else - { /* scale background up */ - iBGr16 = (mng_uint16)(*pScanline ); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*(pScanline+2)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16); - /* and return the composed values */ - *pScanline = (mng_uint8)(iCr16 >> 8); - *(pScanline+1) = (mng_uint8)(iCg16 >> 8); - *(pScanline+2) = (mng_uint8)(iCb16 >> 8); - *pAlphaline = (mng_uint8)(iCa16 >> 8); - } - } - } - - pScanline += (pData->iColinc * 3); - pAlphaline += pData->iColinc; - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *pAlphaline; - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - *pAlphaline = *(pDataline+3); - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do alpha composing */ - MNG_COMPOSE8 (*pScanline, *pDataline, iFGa8, *pScanline ); - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+1), iFGa8, *(pScanline+1)); - MNG_COMPOSE8 (*(pScanline+2), *(pDataline+2), iFGa8, *(pScanline+2)); - /* alpha remains fully opaque !!! */ - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - *pScanline, *(pScanline+1), *(pScanline+2), iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - *pScanline = iCr8; - *(pScanline+1) = iCg8; - *(pScanline+2) = iCb8; - *pAlphaline = iCa8; - } - } - } - - pScanline += (pData->iColinc * 3); - pAlphaline += pData->iColinc; - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB8_A8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#else /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -mng_retcode mng_display_rgb8_a8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pAlphaline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint16 iFGa16, iBGa16, iCa16; - mng_uint16 iFGg16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16; - mng_uint8 iCr8, iCg8, iCb8; - mng_uint8 iBps; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB8_A8, MNG_LC_START); -#endif - - iBps=(mng_uint8)(pData->bIsRGBA16 ? 2:1); - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination rows */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - pAlphaline = (mng_uint8p)pData->fGetalphaline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination rows starting-point */ - pScanline = pScanline + (pData->iCol * 3) + (pData->iDestl * 3); - pAlphaline = pAlphaline + pData->iCol + pData->iDestl; - - pDataline = pData->pRGBArow; /* address source row */ - - /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << (iBps+1)); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+iBps); - *(pScanline+2) = *(pDataline+2*iBps); - *pAlphaline = *(pDataline+3*iBps); - - pScanline += (pData->iColinc * 3); - pAlphaline += pData->iColinc; - pDataline += 4*iBps; - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha values */ - iFGa16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*pAlphaline); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iFGa16) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa16 == 0xFFFF) || (iBGa16 == 0)) - { /* plain copy it */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+4); - *pAlphaline = *(pDataline+6); - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* get the proper values */ - int i; - for (i=2; i >= 0; i--) - { - iFGg16 = mng_get_uint16 (pDataline+i+i); - /* scale background up */ - iBGg16 = (mng_uint16)(*(pScanline+i)); - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - /* now compose */ - MNG_COMPOSE16(iFGg16, iFGg16, iFGa16, iBGg16); - /* and return the composed values */ - *(pScanline+i) = (mng_uint8)(iFGg16 >> 8); - /* alpha remains fully opaque !!! */ - } - } - else - { /* scale background up */ - iBGr16 = (mng_uint16)(*pScanline ); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*(pScanline+2)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16); - /* and return the composed values */ - *pScanline = (mng_uint8)(iCr16 >> 8); - *(pScanline+1) = (mng_uint8)(iCg16 >> 8); - *(pScanline+2) = (mng_uint8)(iCb16 >> 8); - *pAlphaline = (mng_uint8)(iCa16 >> 8); - } - } - } - - pScanline += (pData->iColinc * 3); - pAlphaline += pData->iColinc; - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *pAlphaline; - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - *pAlphaline = *(pDataline+3); - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do alpha composing */ - int i; - for (i=2; i >= 0; i--) - { - MNG_COMPOSE8 (*(pScanline+i), *(pDataline+i), iFGa8, *(pScanline+i)); - } - /* alpha remains fully opaque !!! */ - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - *pScanline, *(pScanline+1), *(pScanline+2), iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - *pScanline = iCr8; - *(pScanline+1) = iCg8; - *(pScanline+2) = iCb8; - *pAlphaline = iCa8; - } - } - } - - pScanline += (pData->iColinc * 3); - pAlphaline += pData->iColinc; - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB8_A8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -#else /* MNG_NO_16BIT_SUPPORT */ -mng_retcode mng_display_rgb8_a8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pAlphaline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint8 iCr8, iCg8, iCb8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB8_A8, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination rows */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - pAlphaline = (mng_uint8p)pData->fGetalphaline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination rows starting-point */ - pScanline = pScanline + (pData->iCol * 3) + (pData->iDestl * 3); - pAlphaline = pAlphaline + pData->iCol + pData->iDestl; - - pDataline = pData->pRGBArow; /* address source row */ - - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - *pAlphaline = *(pDataline+3); - - pScanline += (pData->iColinc * 3); - pAlphaline += pData->iColinc; - pDataline += 4; - } - } - } - else - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *pAlphaline; - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - *pAlphaline = *(pDataline+3); - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do alpha composing */ -#ifdef MNG_OPTIMIZE_FOOTPRINT_COMPOSE - int i; - for (i=2; i >= 0; i--) - { - MNG_COMPOSE8 (*(pScanline+i), *(pDataline+i), iFGa8, *(pScanline+i)); - } -#else - MNG_COMPOSE8 (*pScanline, *pDataline, iFGa8, *pScanline ); - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+1), iFGa8, *(pScanline+1)); - MNG_COMPOSE8 (*(pScanline+2), *(pDataline+2), iFGa8, *(pScanline+2)); -#endif - /* alpha remains fully opaque !!! */ - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - *pScanline, *(pScanline+1), *(pScanline+2), iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - *pScanline = iCr8; - *(pScanline+1) = iCg8; - *(pScanline+2) = iCb8; - *pAlphaline = iCa8; - } - } - } - - pScanline += (pData->iColinc * 3); - pAlphaline += pData->iColinc; - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB8_A8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_16BIT_SUPPORT */ -#endif /* MNG_SKIPCANVAS_RGB8_A8 */ - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCANVAS_BGR8 -#ifndef MNG_NO_16BIT_SUPPORT -#ifndef MNG_OPTIMIZE_FOOTPRINT_COMPOSE -mng_retcode mng_display_bgr8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iA16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint8 iA8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR8, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol * 3) + (pData->iDestl * 3); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + (pData->iSourcel / pData->iColinc) * 8; - else - pDataline = pDataline + (pData->iSourcel / pData->iColinc) * 4; - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *(pDataline+4); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *pDataline; - - pScanline += (pData->iColinc * 3); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *pScanline = *(pDataline+2); - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *pDataline; - - pScanline += (pData->iColinc * 3); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha value */ - iA16 = mng_get_uint16 (pDataline+6); - - if (iA16) /* any opacity at all ? */ - { - if (iA16 == 0xFFFF) /* fully opaque ? */ - { /* scale down by dropping the LSB */ - *pScanline = *(pDataline+4); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *pDataline; - } - else - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGr16 = (mng_uint16)(*(pScanline+2)); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*pScanline ); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iA16, iBGr16); - MNG_COMPOSE16(iFGg16, iFGg16, iA16, iBGg16); - MNG_COMPOSE16(iFGb16, iFGb16, iA16, iBGb16); - /* and return the composed values */ - *pScanline = (mng_uint8)(iFGb16 >> 8); - *(pScanline+1) = (mng_uint8)(iFGg16 >> 8); - *(pScanline+2) = (mng_uint8)(iFGr16 >> 8); - } - } - - pScanline += (pData->iColinc * 3); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - - if (iA8) /* any opacity at all ? */ - { - if (iA8 == 0xFF) /* fully opaque ? */ - { /* then simply copy the values */ - *pScanline = *(pDataline+2); - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *pDataline; - } - else - { /* do alpha composing */ - MNG_COMPOSE8 (*pScanline, *(pDataline+2), iA8, *pScanline ); - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+1), iA8, *(pScanline+1)); - MNG_COMPOSE8 (*(pScanline+2), *pDataline, iA8, *(pScanline+2)); - } - } - - pScanline += (pData->iColinc * 3); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#else /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -mng_retcode mng_display_bgr8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iA16; - mng_uint16 iFGg16; - mng_uint16 iBGg16; - mng_uint8 iA8; - mng_uint8 iBps; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR8, MNG_LC_START); -#endif - - iBps=(mng_uint8)(pData->bIsRGBA16 ? 2:1); - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol * 3) + (pData->iDestl * 3); - pDataline = pData->pRGBArow; /* address source row */ - - /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << (iBps+1)); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *(pDataline+2*iBps); - *(pScanline+1) = *(pDataline+iBps); - *(pScanline+2) = *pDataline; - - pScanline += (pData->iColinc * 3); - pDataline += 4*iBps; - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha value */ - iA16 = mng_get_uint16 (pDataline+6); - - if (iA16) /* any opacity at all ? */ - { - if (iA16 == 0xFFFF) /* fully opaque ? */ - { /* scale down by dropping the LSB */ - *pScanline = *(pDataline+4); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *pDataline; - } - else - { /* get the proper values */ - int i; - for (i=2; i >= 0; i--) - { - iFGg16 = mng_get_uint16 (pDataline+i+i); - /* scale background up */ - iBGg16 = (mng_uint16)(*(pScanline+2-i)); - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - /* now compose */ - MNG_COMPOSE16(iFGg16, iFGg16, iA16, iBGg16); - /* and return the composed values */ - *(pScanline+2-i) = (mng_uint8)(iFGg16 >> 8); - } - } - } - - pScanline += (pData->iColinc * 3); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - - if (iA8) /* any opacity at all ? */ - { - if (iA8 == 0xFF) /* fully opaque ? */ - { /* then simply copy the values */ - *pScanline = *(pDataline+2); - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *pDataline; - } - else - { /* do alpha composing */ - int i; - for (i=2; i >= 0; i--) - { - MNG_COMPOSE8 (*(pScanline+i), *(pDataline+2-i), iA8, *(pScanline+i)); - } - } - } - - pScanline += (pData->iColinc * 3); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -#else /* MNG_NO_16BIT_SUPPORT */ -mng_retcode mng_display_bgr8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iA8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR8, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol * 3) + (pData->iDestl * 3); - pDataline = pData->pRGBArow; /* address source row */ - - pDataline = pDataline + (pData->iSourcel / pData->iColinc) * 4; - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *pScanline = *(pDataline+2); - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *pDataline; - - pScanline += (pData->iColinc * 3); - pDataline += 4; - } - } - } - else - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - - if (iA8) /* any opacity at all ? */ - { - if (iA8 == 0xFF) /* fully opaque ? */ - { /* then simply copy the values */ - *pScanline = *(pDataline+2); - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *pDataline; - } - else - { /* do alpha composing */ -#ifdef MNG_OPTIMIZE_FOOTPRINT_COMPOSE - int i; - for (i=2; i >= 0; i--) - { - MNG_COMPOSE8 (*(pScanline+i), *(pDataline+2-i), iA8, *(pScanline+i)); - } -#else - MNG_COMPOSE8 (*pScanline, *(pDataline+2), iA8, *pScanline ); - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+1), iA8, *(pScanline+1)); - MNG_COMPOSE8 (*(pScanline+2), *pDataline, iA8, *(pScanline+2)); -#endif - } - } - - pScanline += (pData->iColinc * 3); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_16BIT_SUPPORT */ -#endif /* MNG_SKIPCANVAS_BGR8 */ - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCANVAS_BGRX8 -#ifndef MNG_NO_16BIT_SUPPORT -#ifndef MNG_OPTIMIZE_FOOTPRINT_COMPOSE -mng_retcode mng_display_bgrx8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iA16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint8 iA8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRX8, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + (pData->iSourcel / pData->iColinc) * 8; - else - pDataline = pDataline + (pData->iSourcel / pData->iColinc) * 4; - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *(pDataline+4); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *pDataline; - *(pScanline+3) = 0xFF; /* filler byte */ - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *pScanline = *(pDataline+2); - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *pDataline; - *(pScanline+3) = 0xFF; /* filler byte */ - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha value */ - iA16 = mng_get_uint16 (pDataline+6); - - if (iA16) /* any opacity at all ? */ - { - if (iA16 == 0xFFFF) /* fully opaque ? */ - { /* scale down by dropping the LSB */ - *pScanline = *(pDataline+4); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *pDataline; - *(pScanline+3) = 0xFF; /* filler byte */ - } - else - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGr16 = (mng_uint16)(*(pScanline+2)); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*pScanline ); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iA16, iBGr16); - MNG_COMPOSE16(iFGg16, iFGg16, iA16, iBGg16); - MNG_COMPOSE16(iFGb16, iFGb16, iA16, iBGb16); - /* and return the composed values */ - *pScanline = (mng_uint8)(iFGb16 >> 8); - *(pScanline+1) = (mng_uint8)(iFGg16 >> 8); - *(pScanline+2) = (mng_uint8)(iFGr16 >> 8); - *(pScanline+3) = 0xFF; /* filler byte */ - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - - if (iA8) /* any opacity at all ? */ - { - if (iA8 == 0xFF) /* fully opaque ? */ - { /* then simply copy the values */ - *pScanline = *(pDataline+2); - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *pDataline; - *(pScanline+3) = 0xFF; /* filler byte */ - } - else - { /* do alpha composing */ - MNG_COMPOSE8 (*pScanline, *(pDataline+2), iA8, *pScanline ); - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+1), iA8, *(pScanline+1)); - MNG_COMPOSE8 (*(pScanline+2), *pDataline, iA8, *(pScanline+2)); - *(pScanline+3) = 0xFF; /* filler byte */ - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRX8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#else /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -mng_retcode mng_display_bgrx8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iA16; - mng_uint16 iFGg16; - mng_uint16 iBGg16; - mng_uint8 iA8; - mng_uint8 iBps; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRX8, MNG_LC_START); -#endif - - iBps=(mng_uint8)(pData->bIsRGBA16 ? 2:1); - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << (iBps+1)); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *(pDataline+2*iBps); - *(pScanline+1) = *(pDataline+iBps); - *(pScanline+2) = *pDataline; - *(pScanline+3) = 0xFF; /* filler byte */ - - pScanline += (pData->iColinc << 2); - pDataline += 4*iBps; - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha value */ - iA16 = mng_get_uint16 (pDataline+6); - - if (iA16) /* any opacity at all ? */ - { - if (iA16 == 0xFFFF) /* fully opaque ? */ - { /* scale down by dropping the LSB */ - *pScanline = *(pDataline+4); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *pDataline; - *(pScanline+3) = 0xFF; /* filler byte */ - } - else - { /* get the proper values */ - int i; - for (i=2; i >= 0; i--) - { - iFGg16 = mng_get_uint16 (pDataline+i+i); - /* scale background up */ - iBGg16 = (mng_uint16)(*(pScanline+2-i)); - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - /* now compose */ - MNG_COMPOSE16(iFGg16, iFGg16, iA16, iBGg16); - /* and return the composed values */ - *(pScanline+2-i) = (mng_uint8)(iFGg16 >> 8); - } - *(pScanline+3) = 0xFF; /* filler byte */ - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - - if (iA8) /* any opacity at all ? */ - { - if (iA8 == 0xFF) /* fully opaque ? */ - { /* then simply copy the values */ - *pScanline = *(pDataline+2); - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *pDataline; - *(pScanline+3) = 0xFF; /* filler byte */ - } - else - { /* do alpha composing */ - int i; - for (i=2; i >= 0; i--) - { - MNG_COMPOSE8 (*(pScanline+i), *(pDataline+2-i), iA8, *(pScanline+i)); - } - *(pScanline+3) = 0xFF; /* filler byte */ - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRX8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -#else /* MNG_NO_16BIT_SUPPORT */ -mng_retcode mng_display_bgrx8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iA8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRX8, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - pDataline = pDataline + (pData->iSourcel / pData->iColinc) * 4; - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *pScanline = *(pDataline+2); - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *pDataline; - *(pScanline+3) = 0xFF; /* filler byte */ - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - - if (iA8) /* any opacity at all ? */ - { - if (iA8 == 0xFF) /* fully opaque ? */ - { /* then simply copy the values */ - *pScanline = *(pDataline+2); - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *pDataline; - *(pScanline+3) = 0xFF; /* filler byte */ - } - else - { /* do alpha composing */ -#ifdef MNG_OPTIMIZE_FOOTPRINT_COMPOSE - int i; - for (i=2; i >= 0; i--) - { - MNG_COMPOSE8 (*(pScanline+i), *(pDataline+2-i), iA8, *(pScanline+i)); - } -#else - MNG_COMPOSE8 (*pScanline, *(pDataline+2), iA8, *pScanline ); - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+1), iA8, *(pScanline+1)); - MNG_COMPOSE8 (*(pScanline+2), *pDataline, iA8, *(pScanline+2)); -#endif - *(pScanline+3) = 0xFF; /* filler byte */ - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRX8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_16BIT_SUPPORT */ -#endif /* MNG_SKIPCANVAS_BGRX8 */ - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCANVAS_BGRA8 -#ifndef MNG_NO_16BIT_SUPPORT -#ifndef MNG_OPTIMIZE_FOOTPRINT_COMPOSE -mng_retcode mng_display_bgra8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint16 iFGa16, iBGa16, iCa16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16; - mng_uint8 iCr8, iCg8, iCb8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA8, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *(pDataline+4); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *pDataline; - *(pScanline+3) = *(pDataline+6); - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *pScanline = *(pDataline+2); - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *pDataline; - *(pScanline+3) = *(pDataline+3); - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha values */ - iFGa16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*(pScanline+3)); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iFGa16) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa16 == 0xFFFF) || (iBGa16 == 0)) - { /* plain copy it */ - *pScanline = *(pDataline+4); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *pDataline; - *(pScanline+3) = *(pDataline+6); - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGr16 = (mng_uint16)(*(pScanline+2)); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*pScanline ); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iFGa16, iBGr16); - MNG_COMPOSE16(iFGg16, iFGg16, iFGa16, iBGg16); - MNG_COMPOSE16(iFGb16, iFGb16, iFGa16, iBGb16); - /* and return the composed values */ - *pScanline = (mng_uint8)(iFGb16 >> 8); - *(pScanline+1) = (mng_uint8)(iFGg16 >> 8); - *(pScanline+2) = (mng_uint8)(iFGr16 >> 8); - /* alpha remains fully opaque !!! */ - } - else - { /* scale background up */ - iBGr16 = (mng_uint16)(*(pScanline+2)); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*pScanline ); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16); - /* and return the composed values */ - *pScanline = (mng_uint8)(iCb16 >> 8); - *(pScanline+1) = (mng_uint8)(iCg16 >> 8); - *(pScanline+2) = (mng_uint8)(iCr16 >> 8); - *(pScanline+3) = (mng_uint8)(iCa16 >> 8); - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *(pScanline+3); - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pScanline = *(pDataline+2); - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *pDataline; - *(pScanline+3) = *(pDataline+3); - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do alpha composing */ - MNG_COMPOSE8 (*pScanline, *(pDataline+2), iFGa8, *pScanline ); - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+1), iFGa8, *(pScanline+1)); - MNG_COMPOSE8 (*(pScanline+2), *pDataline, iFGa8, *(pScanline+2)); - /* alpha remains fully opaque !!! */ - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - *(pScanline+2), *(pScanline+1), *pScanline, iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - *pScanline = iCb8; - *(pScanline+1) = iCg8; - *(pScanline+2) = iCr8; - *(pScanline+3) = iCa8; - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#else /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -mng_retcode mng_display_bgra8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint16 iFGa16, iBGa16, iCa16; - mng_uint16 iFGg16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16; - mng_uint8 iCr8, iCg8, iCb8; - mng_uint8 iBps; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA8, MNG_LC_START); -#endif - - iBps=(mng_uint8)(pData->bIsRGBA16 ? 2:1); - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << (iBps+1)); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *(pDataline+2*iBps); - *(pScanline+1) = *(pDataline+iBps); - *(pScanline+2) = *pDataline; - *(pScanline+3) = *(pDataline+3*iBps); - - pScanline += (pData->iColinc << 2); - pDataline += 4*iBps; - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha values */ - iFGa16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*(pScanline+3)); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iFGa16) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa16 == 0xFFFF) || (iBGa16 == 0)) - { /* plain copy it */ - *pScanline = *(pDataline+4); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *pDataline; - *(pScanline+3) = *(pDataline+6); - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* get the proper values */ - int i; - for (i=2; i >= 0; i--) - { - iFGg16 = mng_get_uint16 (pDataline+i+i); - /* scale background up */ - iBGg16 = (mng_uint16)(*(pScanline+2-i)); - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - /* now compose */ - MNG_COMPOSE16(iFGg16, iFGg16, iFGa16, iBGg16); - /* and return the composed values */ - *(pScanline+2-i) = (mng_uint8)(iFGg16 >> 8); - /* alpha remains fully opaque !!! */ - } - } - else - { /* scale background up */ - iBGr16 = (mng_uint16)(*(pScanline+2)); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*pScanline ); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16); - /* and return the composed values */ - *pScanline = (mng_uint8)(iCb16 >> 8); - *(pScanline+1) = (mng_uint8)(iCg16 >> 8); - *(pScanline+2) = (mng_uint8)(iCr16 >> 8); - *(pScanline+3) = (mng_uint8)(iCa16 >> 8); - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *(pScanline+3); - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pScanline = *(pDataline+2); - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *pDataline; - *(pScanline+3) = *(pDataline+3); - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do alpha composing */ - int i; - for (i=2; i >= 0; i--) - { - MNG_COMPOSE8 (*(pScanline+i), *(pDataline+2-i), iFGa8, *(pScanline+i)); - } - /* alpha remains fully opaque !!! */ - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - *(pScanline+2), *(pScanline+1), *pScanline, iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - *pScanline = iCb8; - *(pScanline+1) = iCg8; - *(pScanline+2) = iCr8; - *(pScanline+3) = iCa8; - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -#else /* MNG_NO_16BIT_SUPPORT */ -mng_retcode mng_display_bgra8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint8 iCr8, iCg8, iCb8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA8, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *pScanline = *(pDataline+2); - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *pDataline; - *(pScanline+3) = *(pDataline+3); - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *(pScanline+3); - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pScanline = *(pDataline+2); - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *pDataline; - *(pScanline+3) = *(pDataline+3); - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do alpha composing */ -#ifdef MNG_OPTIMIZE_FOOTPRINT_COMPOSE - int i; - for (i=2; i >= 0; i--) - { - MNG_COMPOSE8 (*(pScanline+i), *(pDataline+2-i), iFGa8, *(pScanline+i)); - } -#else - MNG_COMPOSE8 (*pScanline, *(pDataline+2), iFGa8, *pScanline ); - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+1), iFGa8, *(pScanline+1)); - MNG_COMPOSE8 (*(pScanline+2), *pDataline, iFGa8, *(pScanline+2)); -#endif - /* alpha remains fully opaque !!! */ - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - *(pScanline+2), *(pScanline+1), *pScanline, iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - *pScanline = iCb8; - *(pScanline+1) = iCg8; - *(pScanline+2) = iCr8; - *(pScanline+3) = iCa8; - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_16BIT_SUPPORT */ -#endif /* MNG_SKIPCANVAS_BGRA8 */ - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCANVAS_BGRA8_PM -#ifndef MNG_NO_16BIT_SUPPORT -#ifndef MNG_OPTIMIZE_FOOTPRINT_COMPOSE -mng_retcode mng_display_bgra8_pm (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint32 s, t; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA8PM, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - if ((s = pDataline[6]) == 0) - *(mng_uint32*) pScanline = 0; /* set all components = 0 */ - else - { - if (s == 255) - { - pScanline[0] = pDataline[4]; - pScanline[1] = pDataline[2]; - pScanline[2] = pDataline[0]; - pScanline[3] = 255; - } - else - { - pScanline[0] = DIV255B8(s * pDataline[4]); - pScanline[1] = DIV255B8(s * pDataline[2]); - pScanline[2] = DIV255B8(s * pDataline[0]); - pScanline[3] = (mng_uint8)s; - } - } - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values and premultiply */ - if ((s = pDataline[3]) == 0) - *(mng_uint32*) pScanline = 0; /* set all components = 0 */ - else - { - if (s == 255) - { - pScanline[0] = pDataline[2]; - pScanline[1] = pDataline[1]; - pScanline[2] = pDataline[0]; - pScanline[3] = 255; - } - else - { - pScanline[0] = DIV255B8(s * pDataline[2]); - pScanline[1] = DIV255B8(s * pDataline[1]); - pScanline[2] = DIV255B8(s * pDataline[0]); - pScanline[3] = (mng_uint8)s; - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha values */ - if ((s = pDataline[6]) != 0) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if (s == 255) - { /* plain copy it */ - pScanline[0] = pDataline[4]; - pScanline[1] = pDataline[2]; - pScanline[2] = pDataline[0]; - pScanline[3] = 255; - } - else - { /* now blend (premultiplied) */ - t = 255 - s; -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[i] = DIV255B8(s * pDataline[4-i-i] + t * - pScanline[i]); - } - } -#else - pScanline[0] = DIV255B8(s * pDataline[4] + t * pScanline[0]); - pScanline[1] = DIV255B8(s * pDataline[2] + t * pScanline[1]); - pScanline[2] = DIV255B8(s * pDataline[0] + t * pScanline[2]); -#endif - pScanline[3] = (mng_uint8)(255 - DIV255B8(t * (255 - pScanline[3]))); - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - if ((s = pDataline[3]) != 0) /* any opacity at all ? */ - { /* fully opaque ? */ - if (s == 255) - { /* then simply copy the values */ - pScanline[0] = pDataline[2]; - pScanline[1] = pDataline[1]; - pScanline[2] = pDataline[0]; - pScanline[3] = 255; - } - else - { /* now blend (premultiplied) */ - t = 255 - s; -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[i] = DIV255B8(s * pDataline[2-i] + t * - pScanline[i]); - } - } -#else - pScanline[0] = DIV255B8(s * pDataline[2] + t * pScanline[0]); - pScanline[1] = DIV255B8(s * pDataline[1] + t * pScanline[1]); - pScanline[2] = DIV255B8(s * pDataline[0] + t * pScanline[2]); -#endif - pScanline[3] = (mng_uint8)(255 - DIV255B8(t * (255 - pScanline[3]))); - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA8PM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#else /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -mng_retcode mng_display_bgra8_pm (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint32 s, t; - mng_uint8 iBps; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA8PM, MNG_LC_START); -#endif - - iBps=(mng_uint8)(pData->bIsRGBA16 ? 2:1); - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << (iBps+1)); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - if ((s = pDataline[6]) == 0) - *(mng_uint32*) pScanline = 0; /* set all components = 0 */ - else - { - if (s == 255) - { - pScanline[0] = pDataline[4]; - pScanline[1] = pDataline[2]; - pScanline[2] = pDataline[0]; - pScanline[3] = 255; - } - else - { -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - int i; - for (i=2; i >= 0; i--) - { - pScanline[i] = DIV255B8(s * pDataline[4-i-i]); - } -#else - pScanline[0] = DIV255B8(s * pDataline[4]); - pScanline[1] = DIV255B8(s * pDataline[2]); - pScanline[2] = DIV255B8(s * pDataline[0]); -#endif - pScanline[3] = (mng_uint8)s; - } - } - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values and premultiply */ - if ((s = pDataline[3]) == 0) - *(mng_uint32*) pScanline = 0; /* set all components = 0 */ - else - { - if (s == 255) - { - pScanline[0] = pDataline[2]; - pScanline[1] = pDataline[1]; - pScanline[2] = pDataline[0]; - pScanline[3] = 255; - } - else - { -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - int i; - for (i=2; i >= 0; i--) - { - pScanline[i] = DIV255B8(s * pDataline[2-i]); - } -#else - pScanline[0] = DIV255B8(s * pDataline[2]); - pScanline[1] = DIV255B8(s * pDataline[1]); - pScanline[2] = DIV255B8(s * pDataline[0]); -#endif - pScanline[3] = (mng_uint8)s; - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha values */ - if ((s = pDataline[6]) != 0) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if (s == 255) - { /* plain copy it */ - pScanline[0] = pDataline[4]; - pScanline[1] = pDataline[2]; - pScanline[2] = pDataline[0]; - pScanline[3] = 255; - } - else - { /* now blend (premultiplied) */ - t = 255 - s; -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[i] = DIV255B8(s * pDataline[4-i-i] + t * - pScanline[i]); - } - } -#else - pScanline[0] = DIV255B8(s * pDataline[4] + t * pScanline[0]); - pScanline[1] = DIV255B8(s * pDataline[2] + t * pScanline[1]); - pScanline[2] = DIV255B8(s * pDataline[0] + t * pScanline[2]); -#endif - pScanline[3] = (mng_uint8)(255 - DIV255B8(t * (255 - pScanline[3]))); - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - if ((s = pDataline[3]) != 0) /* any opacity at all ? */ - { /* fully opaque ? */ - if (s == 255) - { /* then simply copy the values */ - pScanline[0] = pDataline[2]; - pScanline[1] = pDataline[1]; - pScanline[2] = pDataline[0]; - pScanline[3] = 255; - } - else - { /* now blend (premultiplied) */ - t = 255 - s; -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[i] = DIV255B8(s * pDataline[2-i] + t * - pScanline[i]); - } - } -#else - pScanline[0] = DIV255B8(s * pDataline[2] + t * pScanline[0]); - pScanline[1] = DIV255B8(s * pDataline[1] + t * pScanline[1]); - pScanline[2] = DIV255B8(s * pDataline[0] + t * pScanline[2]); -#endif - pScanline[3] = (mng_uint8)(255 - DIV255B8(t * (255 - pScanline[3]))); - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA8PM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -#else /* MNG_NO_16BIT_SUPPORT */ -mng_retcode mng_display_bgra8_pm (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint32 s, t; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA8PM, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values and premultiply */ - if ((s = pDataline[3]) == 0) - *(mng_uint32*) pScanline = 0; /* set all components = 0 */ - else - { - if (s == 255) - { - pScanline[0] = pDataline[2]; - pScanline[1] = pDataline[1]; - pScanline[2] = pDataline[0]; - pScanline[3] = 255; - } - else - { -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - int i; - for (i=2; i >= 0; i--) - { - pScanline[i] = DIV255B8(s * pDataline[2-i]); - } -#else - pScanline[0] = DIV255B8(s * pDataline[2]); - pScanline[1] = DIV255B8(s * pDataline[1]); - pScanline[2] = DIV255B8(s * pDataline[0]); -#endif - pScanline[3] = (mng_uint8)s; - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - if ((s = pDataline[3]) != 0) /* any opacity at all ? */ - { /* fully opaque ? */ - if (s == 255) - { /* then simply copy the values */ - pScanline[0] = pDataline[2]; - pScanline[1] = pDataline[1]; - pScanline[2] = pDataline[0]; - pScanline[3] = 255; - } - else - { /* now blend (premultiplied) */ - t = 255 - s; -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[i] = DIV255B8(s * pDataline[2-i] + t * - pScanline[i]); - } - } -#else - pScanline[0] = DIV255B8(s * pDataline[2] + t * pScanline[0]); - pScanline[1] = DIV255B8(s * pDataline[1] + t * pScanline[1]); - pScanline[2] = DIV255B8(s * pDataline[0] + t * pScanline[2]); -#endif - pScanline[3] = (mng_uint8)(255 - DIV255B8(t * (255 - pScanline[3]))); - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA8PM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_16BIT_SUPPORT */ -#endif /* MNG_SKIPCANVAS_BGRA8_PM */ - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCANVAS_ABGR8 -#ifndef MNG_NO_16BIT_SUPPORT -#ifndef MNG_OPTIMIZE_FOOTPRINT_COMPOSE -mng_retcode mng_display_abgr8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint16 iFGa16, iBGa16, iCa16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16; - mng_uint8 iCr8, iCg8, iCb8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ABGR8, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *(pDataline+6); - *(pScanline+1) = *(pDataline+4); - *(pScanline+2) = *(pDataline+2); - *(pScanline+3) = *pDataline; - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *pScanline = *(pDataline+3); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+1); - *(pScanline+3) = *pDataline; - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha values */ - iFGa16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*pScanline); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iFGa16) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa16 == 0xFFFF) || (iBGa16 == 0)) - { /* plain copy it */ - *pScanline = *(pDataline+6); - *(pScanline+1) = *(pDataline+4); - *(pScanline+2) = *(pDataline+2); - *(pScanline+3) = *pDataline; - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGr16 = (mng_uint16)(*(pScanline+3)); - iBGg16 = (mng_uint16)(*(pScanline+2)); - iBGb16 = (mng_uint16)(*(pScanline+1)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iFGa16, iBGr16); - MNG_COMPOSE16(iFGg16, iFGg16, iFGa16, iBGg16); - MNG_COMPOSE16(iFGb16, iFGb16, iFGa16, iBGb16); - /* and return the composed values */ - /* alpha itself remains fully opaque !!! */ - *(pScanline+1) = (mng_uint8)(iFGb16 >> 8); - *(pScanline+2) = (mng_uint8)(iFGg16 >> 8); - *(pScanline+3) = (mng_uint8)(iFGr16 >> 8); - } - else - { /* scale background up */ - iBGr16 = (mng_uint16)(*(pScanline+3)); - iBGg16 = (mng_uint16)(*(pScanline+2)); - iBGb16 = (mng_uint16)(*(pScanline+1)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16); - /* and return the composed values */ - *pScanline = (mng_uint8)(iCa16 >> 8); - *(pScanline+1) = (mng_uint8)(iCb16 >> 8); - *(pScanline+2) = (mng_uint8)(iCg16 >> 8); - *(pScanline+3) = (mng_uint8)(iCr16 >> 8); - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *pScanline; - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pScanline = *(pDataline+3); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+1); - *(pScanline+3) = *pDataline; - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do simple alpha composing */ - /* alpha itself remains fully opaque !!! */ - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+2), iFGa8, *(pScanline+1)); - MNG_COMPOSE8 (*(pScanline+2), *(pDataline+1), iFGa8, *(pScanline+2)); - MNG_COMPOSE8 (*(pScanline+3), *pDataline, iFGa8, *(pScanline+3)); - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - *(pScanline+3), *(pScanline+2), *(pScanline+1), iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - *pScanline = iCa8; - *(pScanline+1) = iCb8; - *(pScanline+2) = iCg8; - *(pScanline+3) = iCr8; - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ABGR8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#else /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -mng_retcode mng_display_abgr8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint16 iFGa16, iBGa16, iCa16; - mng_uint16 iFGg16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16; - mng_uint8 iCr8, iCg8, iCb8; - mng_uint8 iBps; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ABGR8, MNG_LC_START); -#endif - - iBps=(mng_uint8)(pData->bIsRGBA16 ? 2:1); - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << (iBps+1)); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *(pDataline+3*iBps); - *(pScanline+1) = *(pDataline+2*iBps); - *(pScanline+2) = *(pDataline+iBps); - *(pScanline+3) = *pDataline; - - pScanline += (pData->iColinc << 2); - pDataline += 4*iBps; - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha values */ - iFGa16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*pScanline); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iFGa16) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa16 == 0xFFFF) || (iBGa16 == 0)) - { /* plain copy it */ - *pScanline = *(pDataline+6); - *(pScanline+1) = *(pDataline+4); - *(pScanline+2) = *(pDataline+2); - *(pScanline+3) = *pDataline; - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* get the proper values */ - int i; - for (i=2; i >= 0; i--) - { - iFGg16 = mng_get_uint16 (pDataline+i+i); - /* scale background up */ - iBGg16 = (mng_uint16)(*(pScanline+3-i)); - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - /* now compose */ - MNG_COMPOSE16(iFGg16, iFGg16, iFGa16, iBGg16); - /* and return the composed values */ - /* alpha itself remains fully opaque !!! */ - *(pScanline+3-i) = (mng_uint8)(iFGg16 >> 8); - } - } - else - { /* scale background up */ - iBGr16 = (mng_uint16)(*(pScanline+3)); - iBGg16 = (mng_uint16)(*(pScanline+2)); - iBGb16 = (mng_uint16)(*(pScanline+1)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16); - /* and return the composed values */ - *pScanline = (mng_uint8)(iCa16 >> 8); - *(pScanline+1) = (mng_uint8)(iCb16 >> 8); - *(pScanline+2) = (mng_uint8)(iCg16 >> 8); - *(pScanline+3) = (mng_uint8)(iCr16 >> 8); - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *pScanline; - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pScanline = *(pDataline+3); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+1); - *(pScanline+3) = *pDataline; - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do simple alpha composing */ - /* alpha itself remains fully opaque !!! */ - int i; - for (i=2; i >= 0; i--) - { - MNG_COMPOSE8 (*(pScanline+i+1), *(pDataline+2-i), iFGa8, *(pScanline+i+1)); - } - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - *(pScanline+3), *(pScanline+2), *(pScanline+1), iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - *pScanline = iCa8; - *(pScanline+1) = iCb8; - *(pScanline+2) = iCg8; - *(pScanline+3) = iCr8; - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ABGR8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -#else /* MNG_NO_16BIT_SUPPORT */ -mng_retcode mng_display_abgr8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint8 iCr8, iCg8, iCb8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ABGR8, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *pScanline = *(pDataline+3); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+1); - *(pScanline+3) = *pDataline; - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *pScanline; - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pScanline = *(pDataline+3); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+1); - *(pScanline+3) = *pDataline; - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do simple alpha composing */ - /* alpha itself remains fully opaque !!! */ -#ifdef MNG_OPTIMIZE_FOOTPRINT_COMPOSE - int i; - for (i=2; i >= 0; i--) - { - MNG_COMPOSE8 (*(pScanline+i+1), *(pDataline+2-i), iFGa8, *(pScanline+i+1)); - } -#else - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+2), iFGa8, *(pScanline+1)); - MNG_COMPOSE8 (*(pScanline+2), *(pDataline+1), iFGa8, *(pScanline+2)); - MNG_COMPOSE8 (*(pScanline+3), *pDataline, iFGa8, *(pScanline+3)); -#endif - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - *(pScanline+3), *(pScanline+2), *(pScanline+1), iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - *pScanline = iCa8; - *(pScanline+1) = iCb8; - *(pScanline+2) = iCg8; - *(pScanline+3) = iCr8; - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ABGR8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_16BIT_SUPPORT */ -#endif /* MNG_SKIPCANVAS_ABGR8 */ - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCANVAS_ABGR8_PM -#ifndef MNG_NO_16BIT_SUPPORT -#ifndef MNG_OPTIMIZE_FOOTPRINT_COMPOSE -mng_retcode mng_display_abgr8_pm (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint32 s, t; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ABGR8_PM, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - if ((s = pDataline[6]) == 0) - *(mng_uint32*) pScanline = 0; /* set all components = 0 */ - else - { - if (s == 255) - { - pScanline[0] = 255; - pScanline[1] = pDataline[4]; - pScanline[2] = pDataline[2]; - pScanline[3] = pDataline[0]; - } - else - { - pScanline[0] = (mng_uint8)s; -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[i+1] = DIV255B8(s * pDataline[4-i-i]); - } - } -#else - pScanline[1] = DIV255B8(s * pDataline[4]); - pScanline[2] = DIV255B8(s * pDataline[2]); - pScanline[3] = DIV255B8(s * pDataline[0]); -#endif - } - } - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values and premultiply */ - if ((s = pDataline[3]) == 0) - *(mng_uint32*) pScanline = 0; /* set all components = 0 */ - else - { - if (s == 255) - { - pScanline[0] = 255; - pScanline[1] = pDataline[2]; - pScanline[2] = pDataline[1]; - pScanline[3] = pDataline[0]; - } - else - { - pScanline[0] = (mng_uint8)s; -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[i+1] = DIV255B8(s * pDataline[2-i]); - } - } -#else - pScanline[1] = DIV255B8(s * pDataline[2]); - pScanline[2] = DIV255B8(s * pDataline[1]); - pScanline[3] = DIV255B8(s * pDataline[0]); -#endif - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha values */ - if ((s = pDataline[6]) != 0) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if (s == 255) - { /* plain copy it */ - pScanline[0] = 255; - pScanline[1] = pDataline[4]; - pScanline[2] = pDataline[2]; - pScanline[3] = pDataline[0]; - } - else - { /* now blend (premultiplied) */ - t = 255 - s; - pScanline[0] = (mng_uint8)(255 - DIV255B8(t * (255 - pScanline[0]))); -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[i+1] = DIV255B8(s * pDataline[4-i-i] + t * - pScanline[i+1]); - } - } -#else - pScanline[1] = DIV255B8(s * pDataline[4] + t * pScanline[1]); - pScanline[2] = DIV255B8(s * pDataline[2] + t * pScanline[2]); - pScanline[3] = DIV255B8(s * pDataline[0] + t * pScanline[3]); -#endif - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - if ((s = pDataline[3]) != 0) /* any opacity at all ? */ - { /* fully opaque ? */ - if (s == 255) - { /* then simply copy the values */ - pScanline[0] = 255; - pScanline[1] = pDataline[2]; - pScanline[2] = pDataline[1]; - pScanline[3] = pDataline[0]; - } - else - { /* now blend (premultiplied) */ - t = 255 - s; - pScanline[0] = (mng_uint8)(255 - DIV255B8(t * (255 - pScanline[0]))); -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[i+1] = DIV255B8(s * pDataline[2-i] + t * - pScanline[i+1]); - } - } -#else - pScanline[1] = DIV255B8(s * pDataline[2] + t * pScanline[1]); - pScanline[2] = DIV255B8(s * pDataline[1] + t * pScanline[2]); - pScanline[3] = DIV255B8(s * pDataline[0] + t * pScanline[3]); -#endif - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ABGR8_PM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#else /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -mng_retcode mng_display_abgr8_pm (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint32 s, t; - mng_uint8 iBps; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ABGR8_PM, MNG_LC_START); -#endif - - iBps=(mng_uint8)(pData->bIsRGBA16 ? 2:1); - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << (iBps+1)); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - if ((s = pDataline[6]) == 0) - *(mng_uint32*) pScanline = 0; /* set all components = 0 */ - else - { - if (s == 255) - { - pScanline[0] = 255; - pScanline[1] = pDataline[4]; - pScanline[2] = pDataline[2]; - pScanline[3] = pDataline[0]; - } - else - { - pScanline[0] = (mng_uint8)s; -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[i+1] = DIV255B8(s * pDataline[4-i-i]); - } - } -#else - pScanline[1] = DIV255B8(s * pDataline[4]); - pScanline[2] = DIV255B8(s * pDataline[2]); - pScanline[3] = DIV255B8(s * pDataline[0]); -#endif - } - } - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values and premultiply */ - if ((s = pDataline[3]) == 0) - *(mng_uint32*) pScanline = 0; /* set all components = 0 */ - else - { - if (s == 255) - { - pScanline[0] = 255; - pScanline[1] = pDataline[2]; - pScanline[2] = pDataline[1]; - pScanline[3] = pDataline[0]; - } - else - { - pScanline[0] = (mng_uint8)s; -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[i+1] = DIV255B8(s * pDataline[2-i]); - } - } -#else - pScanline[1] = DIV255B8(s * pDataline[2]); - pScanline[2] = DIV255B8(s * pDataline[1]); - pScanline[3] = DIV255B8(s * pDataline[0]); -#endif - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha values */ - if ((s = pDataline[6]) != 0) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if (s == 255) - { /* plain copy it */ - pScanline[0] = 255; - pScanline[1] = pDataline[4]; - pScanline[2] = pDataline[2]; - pScanline[3] = pDataline[0]; - } - else - { /* now blend (premultiplied) */ - t = 255 - s; - pScanline[0] = (mng_uint8)(255 - DIV255B8(t * (255 - pScanline[0]))); -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[i+1] = DIV255B8(s * pDataline[4-i-i] + t * - pScanline[i+1]); - } - } -#else - pScanline[1] = DIV255B8(s * pDataline[4] + t * pScanline[1]); - pScanline[2] = DIV255B8(s * pDataline[2] + t * pScanline[2]); - pScanline[3] = DIV255B8(s * pDataline[0] + t * pScanline[3]); -#endif - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - if ((s = pDataline[3]) != 0) /* any opacity at all ? */ - { /* fully opaque ? */ - if (s == 255) - { /* then simply copy the values */ - pScanline[0] = 255; - pScanline[1] = pDataline[2]; - pScanline[2] = pDataline[1]; - pScanline[3] = pDataline[0]; - } - else - { /* now blend (premultiplied) */ - t = 255 - s; - pScanline[0] = (mng_uint8)(255 - DIV255B8(t * (255 - pScanline[0]))); -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[i+1] = DIV255B8(s * pDataline[2-i] + t * - pScanline[i+1]); - } - } -#else - pScanline[1] = DIV255B8(s * pDataline[2] + t * pScanline[1]); - pScanline[2] = DIV255B8(s * pDataline[1] + t * pScanline[2]); - pScanline[3] = DIV255B8(s * pDataline[0] + t * pScanline[3]); -#endif - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ABGR8_PM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -#else /* MNG_NO_16BIT_SUPPORT */ -mng_retcode mng_display_abgr8_pm (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint32 s, t; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ABGR8_PM, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values and premultiply */ - if ((s = pDataline[3]) == 0) - *(mng_uint32*) pScanline = 0; /* set all components = 0 */ - else - { - if (s == 255) - { - pScanline[0] = 255; - pScanline[1] = pDataline[2]; - pScanline[2] = pDataline[1]; - pScanline[3] = pDataline[0]; - } - else - { - pScanline[0] = (mng_uint8)s; -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[i+1] = DIV255B8(s * pDataline[2-i]); - } - } -#else - pScanline[1] = DIV255B8(s * pDataline[2]); - pScanline[2] = DIV255B8(s * pDataline[1]); - pScanline[3] = DIV255B8(s * pDataline[0]); -#endif - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - if ((s = pDataline[3]) != 0) /* any opacity at all ? */ - { /* fully opaque ? */ - if (s == 255) - { /* then simply copy the values */ - pScanline[0] = 255; - pScanline[1] = pDataline[2]; - pScanline[2] = pDataline[1]; - pScanline[3] = pDataline[0]; - } - else - { /* now blend (premultiplied) */ - t = 255 - s; - pScanline[0] = (mng_uint8)(255 - DIV255B8(t * (255 - pScanline[0]))); -#ifdef MNG_OPTIMIZE_FOOTPRINT_DIV - { - int i; - for (i=2; i >= 0; i--) - { - pScanline[i+1] = DIV255B8(s * pDataline[2-i] + t * - pScanline[i+1]); - } - } -#else - pScanline[1] = DIV255B8(s * pDataline[2] + t * pScanline[1]); - pScanline[2] = DIV255B8(s * pDataline[1] + t * pScanline[2]); - pScanline[3] = DIV255B8(s * pDataline[0] + t * pScanline[3]); -#endif - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ABGR8_PM, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_16BIT_SUPPORT */ -#endif /* MNG_SKIPCANVAS_ABGR8_PM */ - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCANVAS_BGR565 -#ifndef MNG_NO_16BIT_SUPPORT -#ifndef MNG_OPTIMIZE_FOOTPRINT_COMPOSE -mng_retcode mng_display_bgr565 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iA16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint8 iA8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR565, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol * 2) + (pData->iDestl * 2); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline))&0xF8 ) | ( (*(pDataline+2)>>5) ) ); - *pScanline = (mng_uint8)( ( (*(pDataline+4)) >>3) | ( (*(pDataline+2)&0xFC) << 3) ); - - pScanline += (pData->iColinc * 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline))&0xF8 ) | ( (*(pDataline+1)>>5 ) ) ); - *pScanline = (mng_uint8)( ( *(pDataline+2) >>3 ) | ( (*(pDataline+1)&0xFC ) << 3) ); - - - pScanline += (pData->iColinc * 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA16 = mng_get_uint16 (pDataline+6); - - if (iA16) /* any opacity at all ? */ - { - if (iA16 == 0xFFFF) /* fully opaque ? */ - { /* scale down by dropping the LSB */ - *(pScanline+1) = (mng_uint8)( (*(pDataline))&0xF8 ) | (mng_uint8)( (*(pDataline+2)>>5 ) ); - *pScanline = (mng_uint8)( (*(pDataline+4)) >>3) | (mng_uint8)( (*(pDataline+2)&0xFC) << 3); - } - else - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - - iBGb16 = (mng_uint16)( (*(pScanline+1)) & 0xF8 ); - iBGg16 = (mng_uint16)( (*(pScanline+1) << 5) | (((*(pScanline )) & 0xE0) >>3 ) ); - iBGr16 = (mng_uint16)( (*(pScanline )) << 3 ); - - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iA16, iBGr16); - MNG_COMPOSE16(iFGg16, iFGg16, iA16, iBGg16); - MNG_COMPOSE16(iFGb16, iFGb16, iA16, iBGb16); - /* and return the composed values */ - *(pScanline+1) = (mng_uint8) ( ( (iFGr16 >> 8)&0xF8 ) | ( (mng_uint8)(iFGg16>>8) >> 5) ); - *pScanline = (mng_uint8) ( ( (iFGb16>>11) ) | (((mng_uint8)(iFGg16>>8)&0xFC) << 3) ); - } - } - - pScanline += (pData->iColinc * 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - - if (iA8) /* any opacity at all ? */ - { - if (iA8 == 0xFF) /* fully opaque ? */ - { /* then simply copy the values */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline)) &0xF8 ) | (*(pDataline+1) >>5 ) ); - *pScanline = (mng_uint8)( ( ((*(pDataline+2))>>3) ) | ((*(pDataline+1)&0xFC) << 3) ); - } - else - { /* do alpha composing */ - mng_uint8 iRed, iGreen, iBlue; - - iRed = (mng_uint8) ( *(pScanline+1) & 0xF8 ); - iGreen = (mng_uint8) ( (*(pScanline+1) << 5) | ( ((*pScanline) & 0xE0)>>3 ) ); - iBlue = (mng_uint8) ( (*pScanline << 3) ); - - MNG_COMPOSE8 (iRed, *pDataline, iA8, iRed ); - MNG_COMPOSE8 (iGreen, *(pDataline+1), iA8, iGreen ); - MNG_COMPOSE8 (iBlue, *(pDataline+2), iA8, iBlue ); - - *(pScanline+1) = (mng_uint8) ( ( iRed & 0xF8 ) | (iGreen>>5) ); - *pScanline = (mng_uint8) ( ( iBlue >> 3 ) | ( (iGreen & 0xFC) << 3) ); - } - } - - pScanline += (pData->iColinc * 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR565, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#else /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -mng_retcode mng_display_bgr565 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iA16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint8 iA8; - mng_uint8 iBps; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR565, MNG_LC_START); -#endif - - iBps=(mng_uint8)(pData->bIsRGBA16 ? 2:1); - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol * 2) + (pData->iDestl * 2); - pDataline = pData->pRGBArow; /* address source row */ - - /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << (iBps+1)); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline))&0xF8 ) | - ( (*(pDataline+iBps)>>5) ) ); - *pScanline = (mng_uint8)( ( (*(pDataline+2*iBps)) >>3) | - ( (*(pDataline+iBps)&0xFC) << 3) ); - - pScanline += (pData->iColinc * 2); - pDataline += 4*iBps; - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA16 = mng_get_uint16 (pDataline+6); - - if (iA16) /* any opacity at all ? */ - { - if (iA16 == 0xFFFF) /* fully opaque ? */ - { /* scale down by dropping the LSB */ - *(pScanline+1) = (mng_uint8)( (*(pDataline))&0xF8 ) | (mng_uint8)( (*(pDataline+2)>>5 ) ); - *pScanline = (mng_uint8)( (*(pDataline+4)) >>3) | (mng_uint8)( (*(pDataline+2)&0xFC) << 3); - } - else - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - - iBGb16 = (mng_uint16)( (*(pScanline+1)) & 0xF8 ); - iBGg16 = (mng_uint16)( (*(pScanline+1) << 5) | (((*(pScanline )) & 0xE0) >>3 ) ); - iBGr16 = (mng_uint16)( (*(pScanline )) << 3 ); - - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iA16, iBGr16); - MNG_COMPOSE16(iFGg16, iFGg16, iA16, iBGg16); - MNG_COMPOSE16(iFGb16, iFGb16, iA16, iBGb16); - /* and return the composed values */ - *(pScanline+1) = (mng_uint8) ( ( (iFGr16 >> 8)&0xF8 ) | ( (mng_uint8)(iFGg16>>8) >> 5) ); - *pScanline = (mng_uint8) ( ( (iFGb16>>11) ) | (((mng_uint8)(iFGg16>>8)&0xFC) << 3) ); - } - } - - pScanline += (pData->iColinc * 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - - if (iA8) /* any opacity at all ? */ - { - if (iA8 == 0xFF) /* fully opaque ? */ - { /* then simply copy the values */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline)) &0xF8 ) | (*(pDataline+1) >>5 ) ); - *pScanline = (mng_uint8)( ( ((*(pDataline+2))>>3) ) | ((*(pDataline+1)&0xFC) << 3) ); - } - else - { /* do alpha composing */ - mng_uint8 iRed, iGreen, iBlue; - - iRed = (mng_uint8) ( *(pScanline+1) & 0xF8 ); - iGreen = (mng_uint8) ( (*(pScanline+1) << 5) | ( ((*pScanline) & 0xE0)>>3 ) ); - iBlue = (mng_uint8) ( (*pScanline << 3) ); - - MNG_COMPOSE8 (iRed, *pDataline, iA8, iRed ); - MNG_COMPOSE8 (iGreen, *(pDataline+1), iA8, iGreen ); - MNG_COMPOSE8 (iBlue, *(pDataline+2), iA8, iBlue ); - - *(pScanline+1) = (mng_uint8) ( ( iRed & 0xF8 ) | (iGreen>>5) ); - *pScanline = (mng_uint8) ( ( iBlue >> 3 ) | ( (iGreen & 0xFC) << 3) ); - } - } - - pScanline += (pData->iColinc * 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR565, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -#else /* MNG_NO_16BIT_SUPPORT */ -mng_retcode mng_display_bgr565 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iA8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR565, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol * 2) + (pData->iDestl * 2); - pDataline = pData->pRGBArow; /* address source row */ - - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline))&0xF8 ) | ( (*(pDataline+1)>>5 ) ) ); - *pScanline = (mng_uint8)( ( *(pDataline+2) >>3 ) | ( (*(pDataline+1)&0xFC ) << 3) ); - - - pScanline += (pData->iColinc * 2); - pDataline += 4; - } - } - } - else - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - - if (iA8) /* any opacity at all ? */ - { - if (iA8 == 0xFF) /* fully opaque ? */ - { /* then simply copy the values */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline)) &0xF8 ) | (*(pDataline+1) >>5 ) ); - *pScanline = (mng_uint8)( ( ((*(pDataline+2))>>3) ) | ((*(pDataline+1)&0xFC) << 3) ); - } - else - { /* do alpha composing */ - mng_uint8 iRed, iGreen, iBlue; - - iRed = (mng_uint8) ( *(pScanline+1) & 0xF8 ); - iGreen = (mng_uint8) ( (*(pScanline+1) << 5) | ( ((*pScanline) & 0xE0)>>3 ) ); - iBlue = (mng_uint8) ( (*pScanline << 3) ); - - MNG_COMPOSE8 (iRed, *pDataline, iA8, iRed ); - MNG_COMPOSE8 (iGreen, *(pDataline+1), iA8, iGreen ); - MNG_COMPOSE8 (iBlue, *(pDataline+2), iA8, iBlue ); - - *(pScanline+1) = (mng_uint8) ( ( iRed & 0xF8 ) | (iGreen>>5) ); - *pScanline = (mng_uint8) ( ( iBlue >> 3 ) | ( (iGreen & 0xFC) << 3) ); - } - } - - pScanline += (pData->iColinc * 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR565, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_16BIT_SUPPORT */ -#endif /* MNG_SKIPCANVAS_BGR565 */ - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCANVAS_RGB565 -#ifndef MNG_NO_16BIT_SUPPORT -#ifndef MNG_OPTIMIZE_FOOTPRINT_COMPOSE -mng_retcode mng_display_rgb565 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iA16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint8 iA8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB565, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol * 2) + (pData->iDestl * 2); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *(pScanline+1) = (mng_uint8)( ( ( *(pDataline+4)) & 0xF8) | (*(pDataline+2) >> 5 ) ); - *pScanline = (mng_uint8)( ( ( *(pDataline )) >> 3 ) | ((*(pDataline+2) & 0xFC) << 3) ); - - pScanline += (pData->iColinc * 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline+2)) & 0xF8) | (*(pDataline+1) >> 5 ) ); - *pScanline = (mng_uint8)( ( *(pDataline ) >> 3 ) | ((*(pDataline+1) & 0xFC) << 3) ); - - pScanline += (pData->iColinc * 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA16 = mng_get_uint16 (pDataline+6); - - if (iA16) /* any opacity at all ? */ - { - if (iA16 == 0xFFFF) /* fully opaque ? */ - { /* scale down by dropping the LSB */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline+4)) & 0xF8) | (*(pDataline+2)>>5) ); - *pScanline = (mng_uint8)( ( (*(pDataline )) >> 3 ) | ((*(pDataline+2)&0xFC) << 3) ); - } - else - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - - /* scale background up */ - iBGr16 = (mng_uint8)( *(pScanline+1) & 0xF8 ); - iBGg16 = (mng_uint8)( (*(pScanline+1) << 5) | ( ((*pScanline) & 0xE0) >> 3 ) ); - iBGb16 = (mng_uint8)( *(pScanline ) << 3 ); - - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iA16, iBGr16); - MNG_COMPOSE16(iFGg16, iFGg16, iA16, iBGg16); - MNG_COMPOSE16(iFGb16, iFGb16, iA16, iBGb16); - /* and return the composed values */ - *(pScanline+1) = (mng_uint8)( (mng_uint8)((iFGb16 >> 8) &0xF8) | ( (mng_uint8)(iFGg16 >> 8) >> 5 ) ); - *pScanline = (mng_uint8)( (mng_uint8) (iFGr16 >>11) | ( ( (mng_uint8)(iFGg16 >> 8) & 0xFC) << 3) ); - } - } - - pScanline += (pData->iColinc * 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - - if (iA8) /* any opacity at all ? */ - { - if (iA8 == 0xFF) /* fully opaque ? */ - { /* then simply copy the values */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline+2)) & 0xF8) | ( *(pDataline+1) >> 5 ) ); - *pScanline = (mng_uint8)( ( (*(pDataline )) >> 3 ) | ( (*(pDataline+1) & 0xFC) << 3 ) ); - } - else - { /* do alpha composing */ - mng_uint8 iRed, iGreen, iBlue; - - iRed = (mng_uint8)( *(pScanline+1) & 0xF8); - iGreen = (mng_uint8)( ( *(pScanline+1) << 5 ) | ( ( (*pScanline)&0xE0)>>3 ) ); - iBlue = (mng_uint8)( *(pScanline ) << 3 ); - - MNG_COMPOSE8 (iRed, *(pDataline+2), iA8, iRed ); - MNG_COMPOSE8 (iGreen, *(pDataline+1), iA8, iGreen ); - MNG_COMPOSE8 (iBlue, *(pDataline+0), iA8, iBlue ); - - *(pScanline+1) = (mng_uint8)( ( iRed & 0xF8) | ( iGreen >> 5 ) ); - *pScanline = (mng_uint8)( (iBlue >> 3 ) | ( (iGreen & 0xFC) << 3) ); - } - } - - pScanline += (pData->iColinc * 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB565, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#else /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -mng_retcode mng_display_rgb565 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iA16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint8 iA8; - mng_uint8 iBps; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB565, MNG_LC_START); -#endif - - iBps=(mng_uint8)(pData->bIsRGBA16 ? 2:1); - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol * 2) + (pData->iDestl * 2); - pDataline = pData->pRGBArow; /* address source row */ - - /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << (iBps+1)); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *(pScanline+1) = (mng_uint8)( ( ( *(pDataline+2*iBps)) & 0xF8) | - (*(pDataline+iBps) >> 5 ) ); - *pScanline = (mng_uint8)( ( ( *(pDataline )) >> 3 ) | - ((*(pDataline+iBps) & 0xFC) << 3) ); - - pScanline += (pData->iColinc * 2); - pDataline += 4*iBps; - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA16 = mng_get_uint16 (pDataline+6); - - if (iA16) /* any opacity at all ? */ - { - if (iA16 == 0xFFFF) /* fully opaque ? */ - { /* scale down by dropping the LSB */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline+4)) & 0xF8) | (*(pDataline+2)>>5) ); - *pScanline = (mng_uint8)( ( (*(pDataline )) >> 3 ) | ((*(pDataline+2)&0xFC) << 3) ); - } - else - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - - /* scale background up */ - iBGr16 = (mng_uint8)( *(pScanline+1) & 0xF8 ); - iBGg16 = (mng_uint8)( (*(pScanline+1) << 5) | ( ((*pScanline) & 0xE0) >> 3 ) ); - iBGb16 = (mng_uint8)( *(pScanline ) << 3 ); - - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iA16, iBGr16); - MNG_COMPOSE16(iFGg16, iFGg16, iA16, iBGg16); - MNG_COMPOSE16(iFGb16, iFGb16, iA16, iBGb16); - /* and return the composed values */ - *(pScanline+1) = (mng_uint8)( (mng_uint8)((iFGb16 >> 8) &0xF8) | ( (mng_uint8)(iFGg16 >> 8) >> 5 ) ); - *pScanline = (mng_uint8)( (mng_uint8) (iFGr16 >>11) | ( ( (mng_uint8)(iFGg16 >> 8) & 0xFC) << 3) ); - } - } - - pScanline += (pData->iColinc * 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - - if (iA8) /* any opacity at all ? */ - { - if (iA8 == 0xFF) /* fully opaque ? */ - { /* then simply copy the values */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline+2)) & 0xF8) | ( *(pDataline+1) >> 5 ) ); - *pScanline = (mng_uint8)( ( (*(pDataline )) >> 3 ) | ( (*(pDataline+1) & 0xFC) << 3 ) ); - } - else - { /* do alpha composing */ - mng_uint8 iRed, iGreen, iBlue; - - iRed = (mng_uint8)( *(pScanline+1) & 0xF8); - iGreen = (mng_uint8)( ( *(pScanline+1) << 5 ) | ( ( (*pScanline)&0xE0)>>3 ) ); - iBlue = (mng_uint8)( *(pScanline ) << 3 ); - - MNG_COMPOSE8 (iRed, *(pDataline+2), iA8, iRed ); - MNG_COMPOSE8 (iGreen, *(pDataline+1), iA8, iGreen ); - MNG_COMPOSE8 (iBlue, *(pDataline+0), iA8, iBlue ); - - *(pScanline+1) = (mng_uint8)( ( iRed & 0xF8) | ( iGreen >> 5 ) ); - *pScanline = (mng_uint8)( (iBlue >> 3 ) | ( (iGreen & 0xFC) << 3) ); - } - } - - pScanline += (pData->iColinc * 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB565, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -#else /* MNG_NO_16BIT_SUPPORT */ -mng_retcode mng_display_rgb565 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iA8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB565, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol * 2) + (pData->iDestl * 2); - pDataline = pData->pRGBArow; /* address source row */ - - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline+2)) & 0xF8) | (*(pDataline+1) >> 5 ) ); - *pScanline = (mng_uint8)( ( *(pDataline ) >> 3 ) | ((*(pDataline+1) & 0xFC) << 3) ); - - pScanline += (pData->iColinc * 2); - pDataline += 4; - } - } - } - else - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - - if (iA8) /* any opacity at all ? */ - { - if (iA8 == 0xFF) /* fully opaque ? */ - { /* then simply copy the values */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline+2)) & 0xF8) | ( *(pDataline+1) >> 5 ) ); - *pScanline = (mng_uint8)( ( (*(pDataline )) >> 3 ) | ( (*(pDataline+1) & 0xFC) << 3 ) ); - } - else - { /* do alpha composing */ - mng_uint8 iRed, iGreen, iBlue; - - iRed = (mng_uint8)( *(pScanline+1) & 0xF8); - iGreen = (mng_uint8)( ( *(pScanline+1) << 5 ) | ( ( (*pScanline)&0xE0)>>3 ) ); - iBlue = (mng_uint8)( *(pScanline ) << 3 ); - - MNG_COMPOSE8 (iRed, *(pDataline+2), iA8, iRed ); - MNG_COMPOSE8 (iGreen, *(pDataline+1), iA8, iGreen ); - MNG_COMPOSE8 (iBlue, *(pDataline+0), iA8, iBlue ); - - *(pScanline+1) = (mng_uint8)( ( iRed & 0xF8) | ( iGreen >> 5 ) ); - *pScanline = (mng_uint8)( (iBlue >> 3 ) | ( (iGreen & 0xFC) << 3) ); - } - } - - pScanline += (pData->iColinc * 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB565, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_16BIT_SUPPORT */ -#endif /* MNG_SKIPCANVAS_RGB565 */ - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCANVAS_BGRA565 -#ifndef MNG_NO_16BIT_SUPPORT -#ifndef MNG_OPTIMIZE_FOOTPRINT_COMPOSE -mng_retcode mng_display_bgra565 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint16 iFGa16, iBGa16, iCa16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16; - mng_uint8 iCr8, iCg8, iCb8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA565, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl * 3); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline))&0xF8 ) | ( (*(pDataline+2)>>5) ) ); - *pScanline = (mng_uint8)( ( (*(pDataline+4)) >>3) | ( (*(pDataline+2)&0xFC) << 3) ); - *(pScanline+2) = *(pDataline+6); - - pScanline += (pData->iColinc * 3); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline))&0xF8 ) | ( (*(pDataline+1)>>5 ) ) ); - *pScanline = (mng_uint8)( ( *(pDataline+2) >>3 ) | ( (*(pDataline+1)&0xFC ) << 3) ); - *(pScanline+2) = *(pDataline+3); - - pScanline += (pData->iColinc * 3); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha values */ - iFGa16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*(pScanline+2)); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iFGa16) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa16 == 0xFFFF) || (iBGa16 == 0)) - { /* plain copy it */ - *(pScanline+1) = (mng_uint8)( (*(pDataline))&0xF8 ) | (mng_uint8)( (*(pDataline+2)>>5 ) ); - *pScanline = (mng_uint8)( (*(pDataline+4)) >>3) | (mng_uint8)( (*(pDataline+2)&0xFC) << 3); - *(pScanline+2) = *(pDataline+6); - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGb16 = (mng_uint16)( (*(pScanline+1)) & 0xF8 ); - iBGg16 = (mng_uint16)( (*(pScanline+1) << 5) | (((*(pScanline )) & 0xE0) >>3 ) ); - iBGr16 = (mng_uint16)( (*(pScanline )) << 3 ); - - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iFGa16, iBGr16); - MNG_COMPOSE16(iFGg16, iFGg16, iFGa16, iBGg16); - MNG_COMPOSE16(iFGb16, iFGb16, iFGa16, iBGb16); - /* and return the composed values */ - *(pScanline+1) = (mng_uint8) ( ( (iFGr16 >> 8)&0xF8 ) | ( (mng_uint8)(iFGg16>>8) >> 5) ); - *pScanline = (mng_uint8) ( ( (iFGb16>>11) ) | (((mng_uint8)(iFGg16>>8)&0xFC) << 3) ); - } - else - { /* scale background up */ - iBGb16 = (mng_uint16)( (*(pScanline+1)) & 0xF8 ); - iBGg16 = (mng_uint16)( (*(pScanline+1) << 5) | (((*(pScanline )) & 0xE0) >>3 ) ); - iBGr16 = (mng_uint16)( (*(pScanline )) << 3 ); - - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16); - /* and return the composed values */ - *(pScanline+1) = (mng_uint8) ( ( (iCr16 >> 8) & 0xF8 ) | ( (mng_uint8)(iCg16 >> 8) >> 5 ) ); - *pScanline = (mng_uint8) ( ( (iCb16 >> 11) ) | (((mng_uint8)(iCg16 >> 8) & 0xFC) << 3) ); - *(pScanline+2) = (mng_uint8)(iCa16 >> 8); - } - } - } - - pScanline += (pData->iColinc * 3); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *(pScanline+2); - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline)) &0xF8 ) | (*(pDataline+1) >>5 ) ); - *pScanline = (mng_uint8)( ( ((*(pDataline+2))>>3) ) | ((*(pDataline+1)&0xFC) << 3) ); - *(pScanline+2) = *(pDataline+3); - } - else - { - mng_uint8 iRed, iGreen, iBlue; - - iRed = (mng_uint8) ( *(pScanline+1) & 0xF8 ); - iGreen = (mng_uint8) ( (*(pScanline+1) << 5) | ( ((*pScanline) & 0xE0)>>3 ) ); - iBlue = (mng_uint8) ( (*pScanline << 3) ); - - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do alpha composing */ - MNG_COMPOSE8 (iRed, *pDataline, iFGa8, iRed ); - MNG_COMPOSE8 (iGreen, *(pDataline+1), iFGa8, iGreen ); - MNG_COMPOSE8 (iBlue, *(pDataline+2), iFGa8, iBlue ); - /* alpha remains fully opaque !!! */ - *(pScanline+1) = (mng_uint8) ( ( iRed & 0xF8 ) | (iGreen>>5) ); - *pScanline = (mng_uint8) ( ( iBlue >> 3 ) | ( (iGreen & 0xFC) << 3) ); - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - iRed , iGreen , iBlue , iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - - - *pScanline = (mng_uint8) ( ( iCb8 >> 3 ) | ( (iCg8 & 0xFC) << 3) ); - *(pScanline+1) = (mng_uint8) ( ( iCr8 & 0xF8 ) | (iCg8>>5) ); - *(pScanline+2) = (mng_uint8) iCa8; - } - } - } - - pScanline += (pData->iColinc *3); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA565, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#else /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -mng_retcode mng_display_bgra565 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint16 iFGa16, iBGa16, iCa16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16; - mng_uint8 iCr8, iCg8, iCb8; - mng_uint8 iBps; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA565, MNG_LC_START); -#endif - - iBps=(mng_uint8)(pData->bIsRGBA16 ? 2:1); - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl * 3); - pDataline = pData->pRGBArow; /* address source row */ - - /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << (iBps+1)); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline))&0xF8 ) | - ( (*(pDataline+iBps)>>5) ) ); - *pScanline = (mng_uint8)( ( (*(pDataline+2*iBps)) >>3) | - ( (*(pDataline+iBps)&0xFC) << 3) ); - *(pScanline+2) = *(pDataline+3*iBps); - - pScanline += (pData->iColinc * 3); - pDataline += 4*iBps; - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha values */ - iFGa16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*(pScanline+2)); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iFGa16) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa16 == 0xFFFF) || (iBGa16 == 0)) - { /* plain copy it */ - *(pScanline+1) = (mng_uint8)( (*(pDataline))&0xF8 ) | (mng_uint8)( (*(pDataline+2)>>5 ) ); - *pScanline = (mng_uint8)( (*(pDataline+4)) >>3) | (mng_uint8)( (*(pDataline+2)&0xFC) << 3); - *(pScanline+2) = *(pDataline+6); - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGb16 = (mng_uint16)( (*(pScanline+1)) & 0xF8 ); - iBGg16 = (mng_uint16)( (*(pScanline+1) << 5) | (((*(pScanline )) & 0xE0) >>3 ) ); - iBGr16 = (mng_uint16)( (*(pScanline )) << 3 ); - - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iFGa16, iBGr16); - MNG_COMPOSE16(iFGg16, iFGg16, iFGa16, iBGg16); - MNG_COMPOSE16(iFGb16, iFGb16, iFGa16, iBGb16); - /* and return the composed values */ - *(pScanline+1) = (mng_uint8) ( ( (iFGr16 >> 8)&0xF8 ) | ( (mng_uint8)(iFGg16>>8) >> 5) ); - *pScanline = (mng_uint8) ( ( (iFGb16>>11) ) | (((mng_uint8)(iFGg16>>8)&0xFC) << 3) ); - } - else - { /* scale background up */ - iBGb16 = (mng_uint16)( (*(pScanline+1)) & 0xF8 ); - iBGg16 = (mng_uint16)( (*(pScanline+1) << 5) | (((*(pScanline )) & 0xE0) >>3 ) ); - iBGr16 = (mng_uint16)( (*(pScanline )) << 3 ); - - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16); - /* and return the composed values */ - *(pScanline+1) = (mng_uint8) ( ( (iCr16 >> 8) & 0xF8 ) | ( (mng_uint8)(iCg16 >> 8) >> 5 ) ); - *pScanline = (mng_uint8) ( ( (iCb16 >> 11) ) | (((mng_uint8)(iCg16 >> 8) & 0xFC) << 3) ); - *(pScanline+2) = (mng_uint8)(iCa16 >> 8); - } - } - } - - pScanline += (pData->iColinc * 3); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *(pScanline+2); - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline)) &0xF8 ) | (*(pDataline+1) >>5 ) ); - *pScanline = (mng_uint8)( ( ((*(pDataline+2))>>3) ) | ((*(pDataline+1)&0xFC) << 3) ); - *(pScanline+2) = *(pDataline+3); - } - else - { - mng_uint8 iRed, iGreen, iBlue; - - iRed = (mng_uint8) ( *(pScanline+1) & 0xF8 ); - iGreen = (mng_uint8) ( (*(pScanline+1) << 5) | ( ((*pScanline) & 0xE0)>>3 ) ); - iBlue = (mng_uint8) ( (*pScanline << 3) ); - - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do alpha composing */ - MNG_COMPOSE8 (iRed, *pDataline, iFGa8, iRed ); - MNG_COMPOSE8 (iGreen, *(pDataline+1), iFGa8, iGreen ); - MNG_COMPOSE8 (iBlue, *(pDataline+2), iFGa8, iBlue ); - /* alpha remains fully opaque !!! */ - *(pScanline+1) = (mng_uint8) ( ( iRed & 0xF8 ) | (iGreen>>5) ); - *pScanline = (mng_uint8) ( ( iBlue >> 3 ) | ( (iGreen & 0xFC) << 3) ); - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - iRed , iGreen , iBlue , iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - - - *pScanline = (mng_uint8) ( ( iCb8 >> 3 ) | ( (iCg8 & 0xFC) << 3) ); - *(pScanline+1) = (mng_uint8) ( ( iCr8 & 0xF8 ) | (iCg8>>5) ); - *(pScanline+2) = (mng_uint8) iCa8; - } - } - } - - pScanline += (pData->iColinc *3); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA565, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -#else /* MNG_NO_16BIT_SUPPORT */ -mng_retcode mng_display_bgra565 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint8 iCr8, iCg8, iCb8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA565, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl * 3); - pDataline = pData->pRGBArow; /* address source row */ - - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline))&0xF8 ) | ( (*(pDataline+1)>>5 ) ) ); - *pScanline = (mng_uint8)( ( *(pDataline+2) >>3 ) | ( (*(pDataline+1)&0xFC ) << 3) ); - *(pScanline+2) = *(pDataline+3); - - pScanline += (pData->iColinc * 3); - pDataline += 4; - } - } - } - else - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *(pScanline+2); - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline)) &0xF8 ) | (*(pDataline+1) >>5 ) ); - *pScanline = (mng_uint8)( ( ((*(pDataline+2))>>3) ) | ((*(pDataline+1)&0xFC) << 3) ); - *(pScanline+2) = *(pDataline+3); - } - else - { - mng_uint8 iRed, iGreen, iBlue; - - iRed = (mng_uint8) ( *(pScanline+1) & 0xF8 ); - iGreen = (mng_uint8) ( (*(pScanline+1) << 5) | ( ((*pScanline) & 0xE0)>>3 ) ); - iBlue = (mng_uint8) ( (*pScanline << 3) ); - - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do alpha composing */ - MNG_COMPOSE8 (iRed, *pDataline, iFGa8, iRed ); - MNG_COMPOSE8 (iGreen, *(pDataline+1), iFGa8, iGreen ); - MNG_COMPOSE8 (iBlue, *(pDataline+2), iFGa8, iBlue ); - /* alpha remains fully opaque !!! */ - *(pScanline+1) = (mng_uint8) ( ( iRed & 0xF8 ) | (iGreen>>5) ); - *pScanline = (mng_uint8) ( ( iBlue >> 3 ) | ( (iGreen & 0xFC) << 3) ); - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - iRed , iGreen , iBlue , iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - - - *pScanline = (mng_uint8) ( ( iCb8 >> 3 ) | ( (iCg8 & 0xFC) << 3) ); - *(pScanline+1) = (mng_uint8) ( ( iCr8 & 0xF8 ) | (iCg8>>5) ); - *(pScanline+2) = (mng_uint8) iCa8; - } - } - } - - pScanline += (pData->iColinc *3); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA565, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_16BIT_SUPPORT */ -#endif /* MNG_SKIPCANVAS_BGRA565 */ - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCANVAS_RGBA565 -#ifndef MNG_NO_16BIT_SUPPORT -#ifndef MNG_OPTIMIZE_FOOTPRINT_COMPOSE -mng_retcode mng_display_rgba565 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint16 iFGa16, iBGa16, iCa16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16; - mng_uint8 iCr8, iCg8, iCb8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGBA565, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl * 3); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline+4))&0xF8 ) | ( (*(pDataline+2)>>5) ) ); - *pScanline = (mng_uint8)( ( (*(pDataline)) >>3) | ( (*(pDataline+2)&0xFC) << 3) ); - *(pScanline+2) = *(pDataline+6); - - pScanline += (pData->iColinc * 3); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline+2))&0xF8 ) | ( (*(pDataline+1)>>5 ) ) ); - *pScanline = (mng_uint8)( ( *(pDataline) >>3 ) | ( (*(pDataline+1)&0xFC ) << 3) ); - *(pScanline+2) = *(pDataline+3); - - pScanline += (pData->iColinc * 3); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha values */ - iFGa16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*(pScanline+2)); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iFGa16) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa16 == 0xFFFF) || (iBGa16 == 0)) - { /* plain copy it */ - *(pScanline+1) = (mng_uint8)( (*(pDataline+4))&0xF8 ) | (mng_uint8)( (*(pDataline+2)>>5 ) ); - *pScanline = (mng_uint8)( (*(pDataline)) >>3) | (mng_uint8)( (*(pDataline+2)&0xFC) << 3); - *(pScanline+2) = *(pDataline+6); - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGr16 = (mng_uint16)( (*(pScanline+1)) & 0xF8 ); - iBGg16 = (mng_uint16)( (*(pScanline+1) << 5) | (((*(pScanline )) & 0xE0) >>3 ) ); - iBGb16 = (mng_uint16)( (*(pScanline )) << 3 ); - - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iFGa16, iBGr16); - MNG_COMPOSE16(iFGg16, iFGg16, iFGa16, iBGg16); - MNG_COMPOSE16(iFGb16, iFGb16, iFGa16, iBGb16); - /* and return the composed values */ - *(pScanline+1) = (mng_uint8) ( ( (iFGb16 >> 8)&0xF8 ) | ( (mng_uint8)(iFGg16>>8) >> 5) ); - *pScanline = (mng_uint8) ( ( (iFGr16>>11) ) | (((mng_uint8)(iFGg16>>8)&0xFC) << 3) ); - } - else - { /* scale background up */ - iBGr16 = (mng_uint16)( (*(pScanline+1)) & 0xF8 ); - iBGg16 = (mng_uint16)( (*(pScanline+1) << 5) | (((*(pScanline )) & 0xE0) >>3 ) ); - iBGb16 = (mng_uint16)( (*(pScanline )) << 3 ); - - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16); - /* and return the composed values */ - *(pScanline+1) = (mng_uint8) ( ( (iCb16 >> 8) & 0xF8 ) | ( (mng_uint8)(iCg16 >> 8) >> 5 ) ); - *pScanline = (mng_uint8) ( ( (iCr16 >> 11) ) | (((mng_uint8)(iCg16 >> 8) & 0xFC) << 3) ); - *(pScanline+2) = (mng_uint8)(iCa16 >> 8); - } - } - } - - pScanline += (pData->iColinc * 3); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *(pScanline+2); - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline+2)) &0xF8 ) | (*(pDataline+1) >>5 ) ); - *pScanline = (mng_uint8)( ( ((*(pDataline))>>3) ) | ((*(pDataline+1)&0xFC) << 3) ); - *(pScanline+2) = *(pDataline+3); - } - else - { - mng_uint8 iRed, iGreen, iBlue; - - iBlue = (mng_uint8) ( *(pScanline+1) & 0xF8 ); - iGreen = (mng_uint8) ( (*(pScanline+1) << 5) | ( ((*pScanline) & 0xE0)>>3 ) ); - iRed = (mng_uint8) ( (*pScanline << 3) ); - - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do alpha composing */ - MNG_COMPOSE8 (iRed, *pDataline, iFGa8, iRed ); - MNG_COMPOSE8 (iGreen, *(pDataline+1), iFGa8, iGreen ); - MNG_COMPOSE8 (iBlue, *(pDataline+2), iFGa8, iBlue ); - /* alpha remains fully opaque !!! */ - *(pScanline+1) = (mng_uint8) ( ( iBlue & 0xF8 ) | (iGreen>>5) ); - *pScanline = (mng_uint8) ( ( iRed >> 3 ) | ( (iGreen & 0xFC) << 3) ); - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - iRed , iGreen , iBlue , iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - - - *pScanline = (mng_uint8) ( ( iCr8 >> 3 ) | ( (iCg8 & 0xFC) << 3) ); - *(pScanline+1) = (mng_uint8) ( ( iCb8 & 0xF8 ) | (iCg8>>5) ); - *(pScanline+2) = (mng_uint8) iCa8; - } - } - } - - pScanline += (pData->iColinc *3); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGBA565, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#else /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -mng_retcode mng_display_rgba565 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint16 iFGa16, iBGa16, iCa16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16; - mng_uint8 iCr8, iCg8, iCb8; - mng_uint8 iBps; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGBA565, MNG_LC_START); -#endif - - iBps=(mng_uint8)(pData->bIsRGBA16 ? 2:1); - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl * 3); - pDataline = pData->pRGBArow; /* address source row */ - - /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << (iBps+1)); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline+2*iBps))&0xF8 ) | - ( (*(pDataline+iBps)>>5) ) ); - *pScanline = (mng_uint8)( ( (*(pDataline)) >>3) | - ( (*(pDataline+iBps)&0xFC) << 3) ); - *(pScanline+2) = *(pDataline+3*iBps); - - pScanline += (pData->iColinc * 3); - pDataline += 4*iBps; - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* get alpha values */ - iFGa16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*(pScanline+2)); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iFGa16) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa16 == 0xFFFF) || (iBGa16 == 0)) - { /* plain copy it */ - *(pScanline+1) = (mng_uint8)( (*(pDataline+4))&0xF8 ) | (mng_uint8)( (*(pDataline+2)>>5 ) ); - *pScanline = (mng_uint8)( (*(pDataline)) >>3) | (mng_uint8)( (*(pDataline+2)&0xFC) << 3); - *(pScanline+2) = *(pDataline+6); - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGr16 = (mng_uint16)( (*(pScanline+1)) & 0xF8 ); - iBGg16 = (mng_uint16)( (*(pScanline+1) << 5) | (((*(pScanline )) & 0xE0) >>3 ) ); - iBGb16 = (mng_uint16)( (*(pScanline )) << 3 ); - - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iFGa16, iBGr16); - MNG_COMPOSE16(iFGg16, iFGg16, iFGa16, iBGg16); - MNG_COMPOSE16(iFGb16, iFGb16, iFGa16, iBGb16); - /* and return the composed values */ - *(pScanline+1) = (mng_uint8) ( ( (iFGb16 >> 8)&0xF8 ) | ( (mng_uint8)(iFGg16>>8) >> 5) ); - *pScanline = (mng_uint8) ( ( (iFGr16>>11) ) | (((mng_uint8)(iFGg16>>8)&0xFC) << 3) ); - } - else - { /* scale background up */ - iBGr16 = (mng_uint16)( (*(pScanline+1)) & 0xF8 ); - iBGg16 = (mng_uint16)( (*(pScanline+1) << 5) | (((*(pScanline )) & 0xE0) >>3 ) ); - iBGb16 = (mng_uint16)( (*(pScanline )) << 3 ); - - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16); - /* and return the composed values */ - *(pScanline+1) = (mng_uint8) ( ( (iCb16 >> 8) & 0xF8 ) | ( (mng_uint8)(iCg16 >> 8) >> 5 ) ); - *pScanline = (mng_uint8) ( ( (iCr16 >> 11) ) | (((mng_uint8)(iCg16 >> 8) & 0xFC) << 3) ); - *(pScanline+2) = (mng_uint8)(iCa16 >> 8); - } - } - } - - pScanline += (pData->iColinc * 3); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *(pScanline+2); - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline+2)) &0xF8 ) | (*(pDataline+1) >>5 ) ); - *pScanline = (mng_uint8)( ( ((*(pDataline))>>3) ) | ((*(pDataline+1)&0xFC) << 3) ); - *(pScanline+2) = *(pDataline+3); - } - else - { - mng_uint8 iRed, iGreen, iBlue; - - iBlue = (mng_uint8) ( *(pScanline+1) & 0xF8 ); - iGreen = (mng_uint8) ( (*(pScanline+1) << 5) | ( ((*pScanline) & 0xE0)>>3 ) ); - iRed = (mng_uint8) ( (*pScanline << 3) ); - - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do alpha composing */ - MNG_COMPOSE8 (iRed, *pDataline, iFGa8, iRed ); - MNG_COMPOSE8 (iGreen, *(pDataline+1), iFGa8, iGreen ); - MNG_COMPOSE8 (iBlue, *(pDataline+2), iFGa8, iBlue ); - /* alpha remains fully opaque !!! */ - *(pScanline+1) = (mng_uint8) ( ( iBlue & 0xF8 ) | (iGreen>>5) ); - *pScanline = (mng_uint8) ( ( iRed >> 3 ) | ( (iGreen & 0xFC) << 3) ); - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - iRed , iGreen , iBlue , iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - - - *pScanline = (mng_uint8) ( ( iCr8 >> 3 ) | ( (iCg8 & 0xFC) << 3) ); - *(pScanline+1) = (mng_uint8) ( ( iCb8 & 0xF8 ) | (iCg8>>5) ); - *(pScanline+2) = (mng_uint8) iCa8; - } - } - } - - pScanline += (pData->iColinc *3); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGBA565, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -#else /* MNG_NO_16BIT_SUPPORT */ -mng_retcode mng_display_rgba565 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint8 iCr8, iCg8, iCb8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGBA565, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl * 3); - pDataline = pData->pRGBArow; /* address source row */ - - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline+2))&0xF8 ) | ( (*(pDataline+1)>>5 ) ) ); - *pScanline = (mng_uint8)( ( *(pDataline) >>3 ) | ( (*(pDataline+1)&0xFC ) << 3) ); - *(pScanline+2) = *(pDataline+3); - - pScanline += (pData->iColinc * 3); - pDataline += 4; - } - } - } - else - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *(pScanline+2); - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline+2)) &0xF8 ) | (*(pDataline+1) >>5 ) ); - *pScanline = (mng_uint8)( ( ((*(pDataline))>>3) ) | ((*(pDataline+1)&0xFC) << 3) ); - *(pScanline+2) = *(pDataline+3); - } - else - { - mng_uint8 iRed, iGreen, iBlue; - - iBlue = (mng_uint8) ( *(pScanline+1) & 0xF8 ); - iGreen = (mng_uint8) ( (*(pScanline+1) << 5) | ( ((*pScanline) & 0xE0)>>3 ) ); - iRed = (mng_uint8) ( (*pScanline << 3) ); - - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do alpha composing */ - MNG_COMPOSE8 (iRed, *pDataline, iFGa8, iRed ); - MNG_COMPOSE8 (iGreen, *(pDataline+1), iFGa8, iGreen ); - MNG_COMPOSE8 (iBlue, *(pDataline+2), iFGa8, iBlue ); - /* alpha remains fully opaque !!! */ - *(pScanline+1) = (mng_uint8) ( ( iBlue & 0xF8 ) | (iGreen>>5) ); - *pScanline = (mng_uint8) ( ( iRed >> 3 ) | ( (iGreen & 0xFC) << 3) ); - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - iRed , iGreen , iBlue , iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - - - *pScanline = (mng_uint8) ( ( iCr8 >> 3 ) | ( (iCg8 & 0xFC) << 3) ); - *(pScanline+1) = (mng_uint8) ( ( iCb8 & 0xF8 ) | (iCg8>>5) ); - *(pScanline+2) = (mng_uint8) iCa8; - } - } - } - - pScanline += (pData->iColinc *3); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGBA565, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_16BIT_SUPPORT */ -#endif /* MNG_SKIPCANVAS_RGBA565 */ - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCANVAS_BGR565_A8 -#ifndef MNG_NO_16BIT_SUPPORT -#ifndef MNG_OPTIMIZE_FOOTPRINT_COMPOSE -mng_retcode mng_display_bgr565_a8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pAlphaline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iA16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16, iBGa16; - mng_uint16 iCr16, iCg16, iCb16, iCa16; - mng_uint8 iA8, iBGa8, iCa8; - mng_uint8 iCr8, iCg8, iCb8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR565_A8, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - pAlphaline = (mng_uint8p)pData->fGetalphaline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row -starting-point */ - pScanline = pScanline + (pData->iCol * 2) + (pData->iDestl * 2); - pAlphaline = pAlphaline + pData->iCol + pData->iDestl; - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline))&0xF8 ) | ((*(pDataline+2)>>5) ) ); - *pScanline = (mng_uint8)( ( (*(pDataline+4)) >>3) | ((*(pDataline+2)&0xFC) << 3) ); - *pAlphaline = (mng_uint8)(*(pDataline+6)); - - pScanline += (pData->iColinc * 2); - pAlphaline += pData->iColinc; - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline))&0xF8 ) | ((*(pDataline+1)>>5 ) ) ); - *pScanline = (mng_uint8)( ( *(pDataline+2) >>3 ) | ((*(pDataline+1)&0xFC ) << 3) ); - *pAlphaline = (mng_uint8)(*(pDataline+3)); - - pScanline += (pData->iColinc * 2); - pAlphaline += pData->iColinc; - pDataline += 4; - } - } - } - else /* Not fully opaque */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*pAlphaline); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iA16) /* any opacity at all ? */ - { - if ((iA16 == 0xFFFF) || (iBGa16 == 0)) /* fully opaque or background fully transparent ? */ - { /* scale down by dropping the LSB */ - *(pScanline+1) = (mng_uint8)( (*(pDataline))&0xF8 ) | (mng_uint8)( (*(pDataline+2)>>5 ) ); - *pScanline = (mng_uint8)( (*(pDataline+4)) >>3) | (mng_uint8)( (*(pDataline+2)&0xFC) << 3); - *pAlphaline = *(pDataline+6); - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { - /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - - iBGb16 = (mng_uint16)( (*(pScanline+1)) & 0xF8 ); - iBGg16 = (mng_uint16)( (*(pScanline+1) << 5) | (((*(pScanline )) & 0xE0) >>3 ) ); - iBGr16 = (mng_uint16)( (*(pScanline )) << 3 ); - - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iA16, iBGr16); - MNG_COMPOSE16(iFGg16, iFGg16, iA16, iBGg16); - MNG_COMPOSE16(iFGb16, iFGb16, iA16, iBGb16); - /* and return the composed values */ - *(pScanline+1) = (mng_uint8) ( ( (iFGr16 >> 8)&0xF8 ) | ( (mng_uint8)(iFGg16>>8) >> 5) ); - *pScanline = (mng_uint8) ( ( (iFGb16>>11) ) | (((mng_uint8)(iFGg16>>8)&0xFC) << 3) ); - *pAlphaline = (mng_uint8)(iA16>>8); - } - else /* background is not fully opaque */ - { /* scale background up */ - iBGb16 = (mng_uint16)( (*(pScanline+1)) & 0xF8 ); - iBGg16 = (mng_uint16)( (*(pScanline+1) << 5) | (((*(pScanline )) & 0xE0) >>3 ) ); - iBGr16 = (mng_uint16)( (*(pScanline )) << 3 ); - - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iA16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16); - /* and return the composed values */ - *(pScanline+1) = (mng_uint8) ( ( (iCr16 >> 8)&0xF8 ) | ( (mng_uint8)(iCg16>>8) >> 5) ); - *pScanline = (mng_uint8) ( ( (iCb16>>11) ) | (((mng_uint8)(iCg16>>8)&0xFC) << 3) ); - *pAlphaline = (mng_uint8)(iCa16 >> 8); - } - } - } - - pScanline += (pData->iColinc * 2); - pAlphaline += pData->iColinc; - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; -iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - iBGa8 = *pAlphaline; - - if (iA8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iA8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline)) &0xF8 ) | (*(pDataline+1) >>5 ) ); - *pScanline = (mng_uint8)( ( ((*(pDataline+2))>>3) ) | ((*(pDataline+1)&0xFC) << 3) ); - *pAlphaline = *(pDataline+3); - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { - /* do alpha composing */ - mng_uint8 iRed, iGreen, iBlue; - - iRed = (mng_uint8) ( *(pScanline+1) & 0xF8 ); - iGreen = (mng_uint8) ( (*(pScanline+1) << 5) | (((*pScanline) & 0xE0)>>3 ) ); - iBlue = (mng_uint8) ( (*pScanline << 3) ); - - MNG_COMPOSE8 (iRed, *pDataline, iA8, iRed ); - MNG_COMPOSE8 (iGreen, *(pDataline+1), iA8, iGreen ); - MNG_COMPOSE8 (iBlue, *(pDataline+2), iA8, iBlue ); - - *(pScanline+1) = (mng_uint8) ( ( iRed & 0xF8 ) | (iGreen>>5) ); - *pScanline = (mng_uint8) ( ( iBlue >> 3 ) | ((iGreen & 0xFC) << 3) ); - *pAlphaline = iA8; - } - else /* background not fully opaque */ - { - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iA8, - *pScanline, *(pScanline+1), *(pScanline+2), iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - *(pScanline+1) = (mng_uint8) ( ( iCr8 & 0xF8 ) | (iCg8>>5) ); - *pScanline = (mng_uint8) ( ( iCb8 >> 3 ) | ((iCg8 & 0xFC) << 3) ); - *pAlphaline = iCa8; - } - } - } - - pScanline += (pData->iColinc * 2); - pAlphaline += pData->iColinc; - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR565_A8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#else /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -mng_retcode mng_display_bgr565_a8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pAlphaline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iA16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16, iBGa16; - mng_uint16 iCr16, iCg16, iCb16, iCa16; - mng_uint8 iA8, iBGa8, iCa8; - mng_uint8 iCr8, iCg8, iCb8; - mng_uint8 iBps; - - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR565_A8, MNG_LC_START); -#endif - - iBps=(mng_uint8)(pData->bIsRGBA16 ? 2:1); - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - pAlphaline = (mng_uint8p)pData->fGetalphaline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row -starting-point */ - pScanline = pScanline + (pData->iCol * 2) + (pData->iDestl * 2); - pAlphaline = pAlphaline + pData->iCol + pData->iDestl; - pDataline = pData->pRGBArow; /* address source row */ - - /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << (iBps+1)); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline))&0xF8 ) | - ((*(pDataline+iBps)>>5) ) ); - *pScanline = (mng_uint8)( ( (*(pDataline+2*iBps)) >>3) | - ((*(pDataline+iBps)&0xFC) << 3) ); - *pAlphaline = (mng_uint8)(*(pDataline+6)); - - pScanline += (pData->iColinc * 2); - pAlphaline += pData->iColinc; - pDataline += 8; - } - } - else /* Not fully opaque */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*pAlphaline); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iA16) /* any opacity at all ? */ - { - if ((iA16 == 0xFFFF) || (iBGa16 == 0)) /* fully opaque or background fully transparent ? */ - { /* scale down by dropping the LSB */ - *(pScanline+1) = (mng_uint8)( (*(pDataline))&0xF8 ) | (mng_uint8)( (*(pDataline+2)>>5 ) ); - *pScanline = (mng_uint8)( (*(pDataline+4)) >>3) | (mng_uint8)( (*(pDataline+2)&0xFC) << 3); - *pAlphaline = *(pDataline+6); - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { - /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - - iBGb16 = (mng_uint16)( (*(pScanline+1)) & 0xF8 ); - iBGg16 = (mng_uint16)( (*(pScanline+1) << 5) | (((*(pScanline )) & 0xE0) >>3 ) ); - iBGr16 = (mng_uint16)( (*(pScanline )) << 3 ); - - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iA16, iBGr16); - MNG_COMPOSE16(iFGg16, iFGg16, iA16, iBGg16); - MNG_COMPOSE16(iFGb16, iFGb16, iA16, iBGb16); - /* and return the composed values */ - *(pScanline+1) = (mng_uint8) ( ( (iFGr16 >> 8)&0xF8 ) | ( (mng_uint8)(iFGg16>>8) >> 5) ); - *pScanline = (mng_uint8) ( ( (iFGb16>>11) ) | (((mng_uint8)(iFGg16>>8)&0xFC) << 3) ); - *pAlphaline = (mng_uint8)(iA16>>8); - } - else /* background is not fully opaque */ - { /* scale background up */ - iBGb16 = (mng_uint16)( (*(pScanline+1)) & 0xF8 ); - iBGg16 = (mng_uint16)( (*(pScanline+1) << 5) | (((*(pScanline )) & 0xE0) >>3 ) ); - iBGr16 = (mng_uint16)( (*(pScanline )) << 3 ); - - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iA16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16); - /* and return the composed values */ - *(pScanline+1) = (mng_uint8) ( ( (iCr16 >> 8)&0xF8 ) | ( (mng_uint8)(iCg16>>8) >> 5) ); - *pScanline = (mng_uint8) ( ( (iCb16>>11) ) | (((mng_uint8)(iCg16>>8)&0xFC) << 3) ); - *pAlphaline = (mng_uint8)(iCa16 >> 8); - } - } - } - - pScanline += (pData->iColinc * 2); - pAlphaline += pData->iColinc; - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; -iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - iBGa8 = *pAlphaline; - - if (iA8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iA8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline)) &0xF8 ) | (*(pDataline+1) >>5 ) ); - *pScanline = (mng_uint8)( ( ((*(pDataline+2))>>3) ) | ((*(pDataline+1)&0xFC) << 3) ); - *pAlphaline = *(pDataline+3); - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { - /* do alpha composing */ - mng_uint8 iRed, iGreen, iBlue; - - iRed = (mng_uint8) ( *(pScanline+1) & 0xF8 ); - iGreen = (mng_uint8) ( (*(pScanline+1) << 5) | (((*pScanline) & 0xE0)>>3 ) ); - iBlue = (mng_uint8) ( (*pScanline << 3) ); - - MNG_COMPOSE8 (iRed, *pDataline, iA8, iRed ); - MNG_COMPOSE8 (iGreen, *(pDataline+1), iA8, iGreen ); - MNG_COMPOSE8 (iBlue, *(pDataline+2), iA8, iBlue ); - - *(pScanline+1) = (mng_uint8) ( ( iRed & 0xF8 ) | (iGreen>>5) ); - *pScanline = (mng_uint8) ( ( iBlue >> 3 ) | ((iGreen & 0xFC) << 3) ); - *pAlphaline = iA8; - } - else /* background not fully opaque */ - { - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iA8, - *pScanline, *(pScanline+1), *(pScanline+2), iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - *(pScanline+1) = (mng_uint8) ( ( iCr8 & 0xF8 ) | (iCg8>>5) ); - *pScanline = (mng_uint8) ( ( iCb8 >> 3 ) | ((iCg8 & 0xFC) << 3) ); - *pAlphaline = iCa8; - } - } - } - - pScanline += (pData->iColinc * 2); - pAlphaline += pData->iColinc; - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR565_A8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -#else /* MNG_NO_16BIT_SUPPORT */ -mng_retcode mng_display_bgr565_a8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pAlphaline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iA8, iBGa8, iCa8; - mng_uint8 iCr8, iCg8, iCb8; - - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR565_A8, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - pAlphaline = (mng_uint8p)pData->fGetalphaline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row -starting-point */ - pScanline = pScanline + (pData->iCol * 2) + (pData->iDestl * 2); - pAlphaline = pAlphaline + pData->iCol + pData->iDestl; - pDataline = pData->pRGBArow; /* address source row */ - - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline))&0xF8 ) | ((*(pDataline+1)>>5 ) ) ); - *pScanline = (mng_uint8)( ( *(pDataline+2) >>3 ) | ((*(pDataline+1)&0xFC ) << 3) ); - *pAlphaline = (mng_uint8)(*(pDataline+3)); - - pScanline += (pData->iColinc * 2); - pAlphaline += pData->iColinc; - pDataline += 4; - } - } - } - else /* Not fully opaque */ - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; -iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - iBGa8 = *pAlphaline; - - if (iA8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iA8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *(pScanline+1) = (mng_uint8)( ( (*(pDataline)) &0xF8 ) | (*(pDataline+1) >>5 ) ); - *pScanline = (mng_uint8)( ( ((*(pDataline+2))>>3) ) | ((*(pDataline+1)&0xFC) << 3) ); - *pAlphaline = *(pDataline+3); - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { - /* do alpha composing */ - mng_uint8 iRed, iGreen, iBlue; - - iRed = (mng_uint8) ( *(pScanline+1) & 0xF8 ); - iGreen = (mng_uint8) ( (*(pScanline+1) << 5) | (((*pScanline) & 0xE0)>>3 ) ); - iBlue = (mng_uint8) ( (*pScanline << 3) ); - - MNG_COMPOSE8 (iRed, *pDataline, iA8, iRed ); - MNG_COMPOSE8 (iGreen, *(pDataline+1), iA8, iGreen ); - MNG_COMPOSE8 (iBlue, *(pDataline+2), iA8, iBlue ); - - *(pScanline+1) = (mng_uint8) ( ( iRed & 0xF8 ) | (iGreen>>5) ); - *pScanline = (mng_uint8) ( ( iBlue >> 3 ) | ((iGreen & 0xFC) << 3) ); - *pAlphaline = iA8; - } - else /* background not fully opaque */ - { - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iA8, - *pScanline, *(pScanline+1), *(pScanline+2), iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - *(pScanline+1) = (mng_uint8) ( ( iCr8 & 0xF8 ) | (iCg8>>5) ); - *pScanline = (mng_uint8) ( ( iCb8 >> 3 ) | ((iCg8 & 0xFC) << 3) ); - *pAlphaline = iCa8; - } - } - } - - pScanline += (pData->iColinc * 2); - pAlphaline += pData->iColinc; - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR565_A8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_16BIT_SUPPORT */ -#endif /* MNG_SKIPCANVAS_BGR565_A8 */ - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCANVAS_RGB555 -#ifndef MNG_NO_16BIT_SUPPORT -#ifndef MNG_OPTIMIZE_FOOTPRINT_COMPOSE -mng_retcode mng_display_rgb555 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iA16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint8 iA8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB555, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol * 2) + (pData->iDestl * 2); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *(pScanline+1) = (mng_uint8)( ((*(pDataline+4) & 0xF8) >> 1 ) | (*(pDataline+2) >> 6 ) ); - *pScanline = (mng_uint8)( ( *(pDataline ) >> 3 ) | ((*(pDataline+2) & 0xF8) << 2 ) ); - - pScanline += (pData->iColinc * 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *(pScanline+1) = (mng_uint8)( ((*(pDataline+2) & 0xF8) >> 1 ) | (*(pDataline+1) >> 6 ) ); - *pScanline = (mng_uint8)( ( *(pDataline ) >> 3 ) | ((*(pDataline+1) & 0xF8) << 2 ) ); - - pScanline += (pData->iColinc * 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA16 = mng_get_uint16 (pDataline+6); - - if (iA16) /* any opacity at all ? */ - { - if (iA16 == 0xFFFF) /* fully opaque ? */ - { /* scale down by dropping the LSB */ - *(pScanline+1) = (mng_uint8)( ((*(pDataline+4) & 0xF8) >> 1 ) | (*(pDataline+2) >> 6 ) ); - *pScanline = (mng_uint8)( ( *(pDataline ) >> 3 ) | ((*(pDataline+2) & 0xF8) << 2 ) ); - } - else - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - - /* scale background up */ - iBGr16 = (mng_uint8)( (*(pScanline+1) & 0xF8) << 1 ); - iBGg16 = (mng_uint8)( (*(pScanline+1) << 6 ) | ( ((*pScanline) & 0xE0) >> 2 ) ); - iBGb16 = (mng_uint8)( *(pScanline ) << 3 ); - - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iA16, iBGr16); - MNG_COMPOSE16(iFGg16, iFGg16, iA16, iBGg16); - MNG_COMPOSE16(iFGb16, iFGb16, iA16, iBGb16); - /* and return the composed values */ - *(pScanline+1) = (mng_uint8)( (mng_uint8)(((iFGb16 >> 8) & 0xF8) >> 1 ) | ( (mng_uint8)(iFGg16 >> 8) >> 6 ) ); - *pScanline = (mng_uint8)( (mng_uint8) ((iFGr16 >>11) >> 3 ) | ( ( (mng_uint8)(iFGg16 >> 8) & 0xF8) << 2 ) ); - } - } - - pScanline += (pData->iColinc * 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - - if (iA8) /* any opacity at all ? */ - { - if (iA8 == 0xFF) /* fully opaque ? */ - { /* then simply copy the values */ - *(pScanline+1) = (mng_uint8)( ((*(pDataline+2) & 0xF8) >> 1 ) | (*(pDataline+1) >> 6 ) ); - *pScanline = (mng_uint8)( ( *(pDataline ) >> 3 ) | ((*(pDataline+1) & 0xF8) << 2 ) ); - } - else - { /* do alpha composing */ - mng_uint8 iRed, iGreen, iBlue; - - iRed = (mng_uint8)( (*(pScanline+1) & 0xF8) << 1 ); - iGreen = (mng_uint8)( (*(pScanline+1) << 6 ) | ( ((*pScanline) & 0xE0) >> 2 ) ); - iBlue = (mng_uint8)( *(pScanline ) << 3 ); - - MNG_COMPOSE8 (iRed, *(pDataline+2), iA8, iRed ); - MNG_COMPOSE8 (iGreen, *(pDataline+1), iA8, iGreen ); - MNG_COMPOSE8 (iBlue, *(pDataline+0), iA8, iBlue ); - - *(pScanline+1) = (mng_uint8)( ( (iRed & 0xF8) >> 1 ) | ( iGreen >> 6 ) ); - *pScanline = (mng_uint8)( (iBlue >> 3 ) | ( (iGreen & 0xF8) << 2 ) ); - } - } - - pScanline += (pData->iColinc * 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB555, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#else /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -mng_retcode mng_display_rgb555 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iA16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint8 iA8; - mng_uint8 iBps; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB555, MNG_LC_START); -#endif - - iBps=(mng_uint8)(pData->bIsRGBA16 ? 2:1); - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol * 2) + (pData->iDestl * 2); - pDataline = pData->pRGBArow; /* address source row */ - - /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << (iBps+1)); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *(pScanline+1) = (mng_uint8)( ((*(pDataline+2*iBps) & 0xF8) >> 1 ) | (*(pDataline+iBps) >> 6 ) ); - *pScanline = (mng_uint8)( ( *(pDataline ) >> 3 ) | ((*(pDataline+iBps) & 0xF8) << 2 ) ); - - pScanline += (pData->iColinc * 2); - pDataline += 4*iBps; - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA16 = mng_get_uint16 (pDataline+6); - - if (iA16) /* any opacity at all ? */ - { - if (iA16 == 0xFFFF) /* fully opaque ? */ - { /* scale down by dropping the LSB */ - *(pScanline+1) = (mng_uint8)( ((*(pDataline+4) & 0xF8) >> 1 ) | (*(pDataline+2) >> 6 ) ); - *pScanline = (mng_uint8)( ( *(pDataline ) >> 3 ) | ((*(pDataline+2) & 0xF8) << 2 ) ); - } - else - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - - /* scale background up */ - iBGr16 = (mng_uint8)( (*(pScanline+1) & 0xF8) << 1 ); - iBGg16 = (mng_uint8)( (*(pScanline+1) << 6 ) | ( ((*pScanline) & 0xE0) >> 2 ) ); - iBGb16 = (mng_uint8)( *(pScanline ) << 3 ); - - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iA16, iBGr16); - MNG_COMPOSE16(iFGg16, iFGg16, iA16, iBGg16); - MNG_COMPOSE16(iFGb16, iFGb16, iA16, iBGb16); - /* and return the composed values */ - *(pScanline+1) = (mng_uint8)( (mng_uint8)(((iFGb16 >> 8) & 0xF8) >> 1 ) | ( (mng_uint8)(iFGg16 >> 8) >> 6 ) ); - *pScanline = (mng_uint8)( (mng_uint8) ((iFGr16 >>11) >> 3 ) | ( ( (mng_uint8)(iFGg16 >> 8) & 0xF8) << 2 ) ); - } - } - - pScanline += (pData->iColinc * 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - - if (iA8) /* any opacity at all ? */ - { - if (iA8 == 0xFF) /* fully opaque ? */ - { /* then simply copy the values */ - *(pScanline+1) = (mng_uint8)( ((*(pDataline+2) & 0xF8) >> 1 ) | (*(pDataline+1) >> 6 ) ); - *pScanline = (mng_uint8)( ( *(pDataline ) >> 3 ) | ((*(pDataline+1) & 0xF8) << 2 ) ); - } - else - { /* do alpha composing */ - mng_uint8 iRed, iGreen, iBlue; - - iRed = (mng_uint8)( (*(pScanline+1) & 0xF8) << 1 ); - iGreen = (mng_uint8)( (*(pScanline+1) << 6 ) | ( ((*pScanline) & 0xE0) >> 2 ) ); - iBlue = (mng_uint8)( *(pScanline ) << 3 ); - - MNG_COMPOSE8 (iRed, *(pDataline+2), iA8, iRed ); - MNG_COMPOSE8 (iGreen, *(pDataline+1), iA8, iGreen ); - MNG_COMPOSE8 (iBlue, *(pDataline+0), iA8, iBlue ); - - *(pScanline+1) = (mng_uint8)( ( (iRed & 0xF8) >> 1 ) | ( iGreen >> 6 ) ); - *pScanline = (mng_uint8)( (iBlue >> 3 ) | ( (iGreen & 0xF8) << 2 ) ); - } - } - - pScanline += (pData->iColinc * 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB555, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -#else /* MNG_NO_16BIT_SUPPORT */ -mng_retcode mng_display_rgb555 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iA8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB555, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol * 2) + (pData->iDestl * 2); - pDataline = pData->pRGBArow; /* address source row */ - - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *(pScanline+1) = (mng_uint8)( ((*(pDataline+2) & 0xF8) >> 1 ) | (*(pDataline+1) >> 6 ) ); - *pScanline = (mng_uint8)( ( *(pDataline ) >> 3 ) | ((*(pDataline+1) & 0xF8) << 2 ) ); - - pScanline += (pData->iColinc * 2); - pDataline += 4; - } - } - } - else - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - - if (iA8) /* any opacity at all ? */ - { - if (iA8 == 0xFF) /* fully opaque ? */ - { /* then simply copy the values */ - *(pScanline+1) = (mng_uint8)( ((*(pDataline+2) & 0xF8) >> 1 ) | (*(pDataline+1) >> 6 ) ); - *pScanline = (mng_uint8)( ( *(pDataline ) >> 3 ) | ((*(pDataline+1) & 0xF8) << 2 ) ); - } - else - { /* do alpha composing */ - mng_uint8 iRed, iGreen, iBlue; - - iRed = (mng_uint8)( (*(pScanline+1) & 0xF8) << 1 ); - iGreen = (mng_uint8)( (*(pScanline+1) << 6 ) | ( ((*pScanline) & 0xE0) >> 2 ) ); - iBlue = (mng_uint8)( *(pScanline ) << 3 ); - - MNG_COMPOSE8 (iRed, *(pDataline+2), iA8, iRed ); - MNG_COMPOSE8 (iGreen, *(pDataline+1), iA8, iGreen ); - MNG_COMPOSE8 (iBlue, *(pDataline+0), iA8, iBlue ); - - *(pScanline+1) = (mng_uint8)( ( (iRed & 0xF8) >> 1 ) | ( iGreen >> 6 ) ); - *pScanline = (mng_uint8)( (iBlue >> 3 ) | ( (iGreen & 0xF8) << 2 ) ); - } - } - - pScanline += (pData->iColinc * 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB555, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_16BIT_SUPPORT */ -#endif /* MNG_SKIPCANVAS_RGB555 */ - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCANVAS_BGR555 -#ifndef MNG_NO_16BIT_SUPPORT -#ifndef MNG_OPTIMIZE_FOOTPRINT_COMPOSE -mng_retcode mng_display_bgr555 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iA16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint8 iA8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR555, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol * 2) + (pData->iDestl * 2); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *(pScanline+1) = (mng_uint8)( ((*(pDataline ) & 0xF8) >> 1 ) | (*(pDataline+2) >> 6 ) ); - *pScanline = (mng_uint8)( ( *(pDataline+4) >> 3 ) | ((*(pDataline+2) & 0xF8) << 2 ) ); - - pScanline += (pData->iColinc * 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *(pScanline+1) = (mng_uint8)( ((*(pDataline ) & 0xF8) >> 1 ) | (*(pDataline+1) >> 6 ) ); - *pScanline = (mng_uint8)( ( *(pDataline+2) >> 3 ) | ((*(pDataline+1) & 0xF8) << 2 ) ); - - pScanline += (pData->iColinc * 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA16 = mng_get_uint16 (pDataline+6); - - if (iA16) /* any opacity at all ? */ - { - if (iA16 == 0xFFFF) /* fully opaque ? */ - { /* scale down by dropping the LSB */ - *(pScanline+1) = (mng_uint8)( ((*(pDataline ) & 0xF8) >> 1 ) | (*(pDataline+2) >> 6 ) ); - *pScanline = (mng_uint8)( ( *(pDataline+4) >> 3 ) | ((*(pDataline+2) & 0xF8) << 2 ) ); - } - else - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - - /* scale background up */ - iBGb16 = (mng_uint8)( (*(pScanline+1) & 0xF8) << 1 ); - iBGg16 = (mng_uint8)( (*(pScanline+1) << 6 ) | ( ((*pScanline) & 0xE0) >> 2 ) ); - iBGr16 = (mng_uint8)( *(pScanline ) << 3 ); - - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iA16, iBGr16); - MNG_COMPOSE16(iFGg16, iFGg16, iA16, iBGg16); - MNG_COMPOSE16(iFGb16, iFGb16, iA16, iBGb16); - /* and return the composed values */ - *(pScanline+1) = (mng_uint8)( (mng_uint8)(((iFGr16 >> 8) & 0xF8) >> 1 ) | ( (mng_uint8)(iFGg16 >> 8) >> 6 ) ); - *pScanline = (mng_uint8)( (mng_uint8) ((iFGb16 >>11) >> 3 ) | ( ( (mng_uint8)(iFGg16 >> 8) & 0xF8) << 2 ) ); - } - } - - pScanline += (pData->iColinc * 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - - if (iA8) /* any opacity at all ? */ - { - if (iA8 == 0xFF) /* fully opaque ? */ - { /* then simply copy the values */ - *(pScanline+1) = (mng_uint8)( ((*(pDataline ) & 0xF8) >> 1 ) | (*(pDataline+1) >> 6 ) ); - *pScanline = (mng_uint8)( ( *(pDataline+2) >> 3 ) | ((*(pDataline+1) & 0xF8) << 2 ) ); - } - else - { /* do alpha composing */ - mng_uint8 iRed, iGreen, iBlue; - - iRed = (mng_uint8)( (*(pScanline+1) & 0xF8) << 1 ); - iGreen = (mng_uint8)( (*(pScanline+1) << 6 ) | ( ((*pScanline) & 0xE0) >> 2 ) ); - iBlue = (mng_uint8)( *(pScanline ) << 3 ); - - MNG_COMPOSE8 (iRed, *(pDataline+0), iA8, iRed ); - MNG_COMPOSE8 (iGreen, *(pDataline+1), iA8, iGreen ); - MNG_COMPOSE8 (iBlue, *(pDataline+2), iA8, iBlue ); - - *(pScanline+1) = (mng_uint8)( ( (iRed & 0xF8) >> 1 ) | ( iGreen >> 6 ) ); - *pScanline = (mng_uint8)( (iBlue >> 3 ) | ( (iGreen & 0xF8) << 2 ) ); - } - } - - pScanline += (pData->iColinc * 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR555, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#else /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -mng_retcode mng_display_bgr555 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iA16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint8 iA8; - mng_uint8 iBps; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR555, MNG_LC_START); -#endif - - iBps=(mng_uint8)(pData->bIsRGBA16 ? 2:1); - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol * 2) + (pData->iDestl * 2); - pDataline = pData->pRGBArow; /* address source row */ - - /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << (iBps+1)); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *(pScanline+1) = (mng_uint8)( ((*(pDataline ) & 0xF8) >> 1 ) | (*(pDataline+iBps) >> 6 ) ); - *pScanline = (mng_uint8)( ( *(pDataline+2*iBps) >> 3 ) | ((*(pDataline+iBps) & 0xF8) << 2 ) ); - - pScanline += (pData->iColinc * 2); - pDataline += 4*iBps; - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA16 = mng_get_uint16 (pDataline+6); - - if (iA16) /* any opacity at all ? */ - { - if (iA16 == 0xFFFF) /* fully opaque ? */ - { /* scale down by dropping the LSB */ - *(pScanline+1) = (mng_uint8)( ((*(pDataline ) & 0xF8) >> 1 ) | (*(pDataline+2) >> 6 ) ); - *pScanline = (mng_uint8)( ( *(pDataline+4) >> 3 ) | ((*(pDataline+2) & 0xF8) << 2 ) ); - } - else - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - - /* scale background up */ - iBGb16 = (mng_uint8)( (*(pScanline+1) & 0xF8) << 1 ); - iBGg16 = (mng_uint8)( (*(pScanline+1) << 6 ) | ( ((*pScanline) & 0xE0) >> 2 ) ); - iBGr16 = (mng_uint8)( *(pScanline ) << 3 ); - - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iA16, iBGr16); - MNG_COMPOSE16(iFGg16, iFGg16, iA16, iBGg16); - MNG_COMPOSE16(iFGb16, iFGb16, iA16, iBGb16); - /* and return the composed values */ - *(pScanline+1) = (mng_uint8)( (mng_uint8)(((iFGr16 >> 8) & 0xF8) >> 1 ) | ( (mng_uint8)(iFGg16 >> 8) >> 6 ) ); - *pScanline = (mng_uint8)( (mng_uint8) ((iFGb16 >>11) >> 3 ) | ( ( (mng_uint8)(iFGg16 >> 8) & 0xF8) << 2 ) ); - } - } - - pScanline += (pData->iColinc * 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - - if (iA8) /* any opacity at all ? */ - { - if (iA8 == 0xFF) /* fully opaque ? */ - { /* then simply copy the values */ - *(pScanline+1) = (mng_uint8)( ((*(pDataline ) & 0xF8) >> 1 ) | (*(pDataline+1) >> 6 ) ); - *pScanline = (mng_uint8)( ( *(pDataline+2) >> 3 ) | ((*(pDataline+1) & 0xF8) << 2 ) ); - } - else - { /* do alpha composing */ - mng_uint8 iRed, iGreen, iBlue; - - iRed = (mng_uint8)( (*(pScanline+1) & 0xF8) << 1 ); - iGreen = (mng_uint8)( (*(pScanline+1) << 6 ) | ( ((*pScanline) & 0xE0) >> 2 ) ); - iBlue = (mng_uint8)( *(pScanline ) << 3 ); - - MNG_COMPOSE8 (iRed, *(pDataline+0), iA8, iRed ); - MNG_COMPOSE8 (iGreen, *(pDataline+1), iA8, iGreen ); - MNG_COMPOSE8 (iBlue, *(pDataline+2), iA8, iBlue ); - - *(pScanline+1) = (mng_uint8)( ( (iRed & 0xF8) >> 1 ) | ( iGreen >> 6 ) ); - *pScanline = (mng_uint8)( (iBlue >> 3 ) | ( (iGreen & 0xF8) << 2 ) ); - } - } - - pScanline += (pData->iColinc * 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR555, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_OPTIMIZE_FOOTPRINT_COMPOSE */ -#else /* MNG_NO_16BIT_SUPPORT */ -mng_retcode mng_display_bgr555 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint8 iA8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR555, MNG_LC_START); -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol * 2) + (pData->iDestl * 2); - pDataline = pData->pRGBArow; /* address source row */ - - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { /* copy the values */ - *(pScanline+1) = (mng_uint8)( ((*(pDataline ) & 0xF8) >> 1 ) | (*(pDataline+1) >> 6 ) ); - *pScanline = (mng_uint8)( ( *(pDataline+2) >> 3 ) | ((*(pDataline+1) & 0xF8) << 2 ) ); - - pScanline += (pData->iColinc * 2); - pDataline += 4; - } - } - } - else - { - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; - iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - - if (iA8) /* any opacity at all ? */ - { - if (iA8 == 0xFF) /* fully opaque ? */ - { /* then simply copy the values */ - *(pScanline+1) = (mng_uint8)( ((*(pDataline ) & 0xF8) >> 1 ) | (*(pDataline+1) >> 6 ) ); - *pScanline = (mng_uint8)( ( *(pDataline+2) >> 3 ) | ((*(pDataline+1) & 0xF8) << 2 ) ); - } - else - { /* do alpha composing */ - mng_uint8 iRed, iGreen, iBlue; - - iRed = (mng_uint8)( (*(pScanline+1) & 0xF8) << 1 ); - iGreen = (mng_uint8)( (*(pScanline+1) << 6 ) | ( ((*pScanline) & 0xE0) >> 2 ) ); - iBlue = (mng_uint8)( *(pScanline ) << 3 ); - - MNG_COMPOSE8 (iRed, *(pDataline+0), iA8, iRed ); - MNG_COMPOSE8 (iGreen, *(pDataline+1), iA8, iGreen ); - MNG_COMPOSE8 (iBlue, *(pDataline+2), iA8, iBlue ); - - *(pScanline+1) = (mng_uint8)( ( (iRed & 0xF8) >> 1 ) | ( iGreen >> 6 ) ); - *pScanline = (mng_uint8)( (iBlue >> 3 ) | ( (iGreen & 0xF8) << 2 ) ); - } - } - - pScanline += (pData->iColinc * 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR555, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_16BIT_SUPPORT */ -#endif /* MNG_SKIPCANVAS_BGR555 */ - - -#ifndef MNG_SKIPCHUNK_BACK -/* ************************************************************************** */ -/* * * */ -/* * Background restore routines - restore the background with info from * */ -/* * the BACK and/or bKGD chunk or the app's background canvas * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode mng_restore_bkgd_backimage (mng_datap pData) -{ - /* save some stuff */ - mng_uint8p pRGBArow = pData->pRGBArow; - mng_int32 iRow = pData->iRow; - mng_int32 iRowsamples = pData->iRowsamples; - - mng_retcode iRetcode; /* work variables */ - mng_uint8p pTemp; - mng_uint8p pWork = pRGBArow; - mng_uint32 iX; - mng_int32 iZ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BACKIMAGE, MNG_LC_START); -#endif - /* determine row to retrieve */ - pData->iRow = pData->iDestt + iRow + pData->iBackimgoffsy; - - while (pData->iRow >= (mng_int32)pData->iBackimgheight) - pData->iRow -= (mng_int32)pData->iBackimgheight; - /* set width to that of background image */ - pData->iRowsamples = pData->iBackimgwidth; - /* retrieve into alternate buffer ! */ - pData->pRGBArow = pData->pPrevrow; - /* get it then */ - iRetcode = ((mng_retrieverow)pData->fRetrieverow) (pData); - - if (iRetcode) /* on error; bail out */ - return iRetcode; - /* we got the full row; but now need to - paste it into the proper location */ - iX = pData->iDestl - pData->iBackimgoffsx; - - while (iX >= pData->iBackimgwidth) - iX -= pData->iBackimgwidth; - -#ifndef MNG_NO_16BIT_SUPPORT - if (pData->bIsRGBA16) /* 16-bit buffer ? */ - { - pTemp = pData->pPrevrow + (iX << 3); - - for (iZ = (pData->iDestr - pData->iDestl); iZ > 0; iZ--) - { - MNG_COPY (pWork, pTemp, 8); - - pWork += 8; - pTemp += 8; - iX++; - /* reached end of bkgd-image line ? */ - if (iX >= pData->iBackimgwidth) - { - iX = 0; - pTemp = pData->pPrevrow; - } - } - } - else -#endif - { - pTemp = pData->pPrevrow + (iX << 2); - - for (iZ = (pData->iDestr - pData->iDestl); iZ > 0; iZ--) - { - MNG_COPY (pWork, pTemp, 4); - - pWork += 4; - pTemp += 4; - iX++; - /* reached end of bkgd-image line ? */ - if (iX >= pData->iBackimgwidth) - { - iX = 0; - pTemp = pData->pPrevrow; - } - } - } - - pData->pRGBArow = pRGBArow; /* restore original values */ - pData->iRow = iRow; - pData->iRowsamples = iRowsamples; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BACKIMAGE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_restore_bkgd_backcolor (mng_datap pData) -{ - mng_int32 iX; - mng_uint32p pWork32 = (mng_uint32p)pData->pRGBArow; - mng_uint32 iWrite; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BACKCOLOR, MNG_LC_START); -#endif - -#ifdef MNG_BIGENDIAN_SUPPORTED - /* fast way for big endian */ - iWrite = (((mng_uint8)(pData->iBACKred >> 8)) << 24) | - (((mng_uint8)(pData->iBACKgreen >> 8)) << 16) | - (((mng_uint8)(pData->iBACKblue >> 8)) << 8) | - ( 0xFF ); -#elif defined(MNG_LITTLEENDIAN_SUPPORTED) - /* fast way for little endian */ - iWrite = ( 0xFF << 24) | - (((mng_uint8)(pData->iBACKblue >> 8)) << 16) | - (((mng_uint8)(pData->iBACKgreen >> 8)) << 8) | - (((mng_uint8)(pData->iBACKred >> 8)) ); -#else - /* generic way, works on all platforms */ - /* put the data in memory in the correct order */ - { - mng_uint8 aBytes[4]; - aBytes[0] = (mng_uint8)(pData->iBACKred >> 8); - aBytes[1] = (mng_uint8)(pData->iBACKgreen >> 8); - aBytes[2] = (mng_uint8)(pData->iBACKblue >> 8); - aBytes[3] = 0xFF; - /* load that data into a register */ - iWrite = *(mng_uint32*) aBytes; - } -#endif - /* ok; drop the background-color in there */ - for (iX = (pData->iSourcer - pData->iSourcel); iX > 0; iX--) - *pWork32++ = iWrite; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BACKCOLOR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_bKGD -mng_retcode mng_restore_bkgd_bkgd (mng_datap pData) -{ - mng_int32 iX; - mng_uint8p pWork = pData->pRGBArow; - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - mng_imagedatap pBuf = pImage->pImgbuf; - mng_uint8 iRed = 0; - mng_uint8 iGreen = 0; - mng_uint8 iBlue = 0; - mng_uint32p pWork32 = (mng_uint32p)pWork; - mng_uint32 iWrite; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BKGD, MNG_LC_START); -#endif - - switch (pBuf->iColortype) - { - case 0 : ; /* gray types */ - case 4 : { - mng_uint8 iGray; - -#ifndef MNG_NO_16BIT_SUPPORT - if (pBuf->iBitdepth > 8) - iGray = (mng_uint8)(pBuf->iBKGDgray >> 8); - else -#endif - { -#ifndef MNG_NO_1_2_4BIT_SUPPORT - /* LBR scaling */ - mng_uint8 multiplier[]={0,255,85,0,17,0,0,0,1}; - iGray = (mng_uint8)(multiplier[pBuf->iBitdepth] * pBuf->iBKGDgray); -#else - iGray = (mng_uint8)pBuf->iBKGDgray; -#endif - } - - iRed = iGray; - iGreen = iGray; - iBlue = iGray; - - break; - } - - case 3 : { /* indexed type */ - iRed = pBuf->aPLTEentries [pBuf->iBKGDindex].iRed; - iGreen = pBuf->aPLTEentries [pBuf->iBKGDindex].iGreen; - iBlue = pBuf->aPLTEentries [pBuf->iBKGDindex].iBlue; - - break; - } - - case 2 : ; /* rgb types */ - case 6 : { -#ifndef MNG_NO_16BIT_SUPPORT - if (pBuf->iBitdepth > 8) - { - iRed = (mng_uint8)(pBuf->iBKGDred >> 8); - iGreen = (mng_uint8)(pBuf->iBKGDgreen >> 8); - iBlue = (mng_uint8)(pBuf->iBKGDblue >> 8); - } - else -#endif - { - iRed = (mng_uint8)(pBuf->iBKGDred ); - iGreen = (mng_uint8)(pBuf->iBKGDgreen); - iBlue = (mng_uint8)(pBuf->iBKGDblue ); - } - - break; - } - } - -#ifdef MNG_BIGENDIAN_SUPPORTED - /* fast way for big endian */ - iWrite = (iRed << 24) | - (iGreen << 16) | - (iBlue << 8); -#elif defined(MNG_LITTLEENDIAN_SUPPORTED) - /* fast way for little endian */ - iWrite = (iBlue << 16) | - (iGreen << 8) | - (iRed ); -#else - /* generic way, works on all platforms */ - /* put the data in memory in the correct order */ - { - mng_uint8 aBytes[4]; - aBytes[0] = (mng_uint8)(iRed); - aBytes[1] = (mng_uint8)(iGreen); - aBytes[2] = (mng_uint8)(iBlue); - aBytes[3] = 0x00; - /* load that data into a register */ - iWrite = *(mng_uint32*) aBytes; - } -#endif - /* ok; drop it in there */ - for (iX = (pData->iSourcer - pData->iSourcel); iX > 0; iX--) - *pWork32++ = iWrite; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BKGD, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_restore_bkgd_bgcolor (mng_datap pData) -{ - mng_int32 iX; - mng_uint32p pWork32 = (mng_uint32p)pData->pRGBArow; - mng_uint32 iWrite; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BGCOLOR, MNG_LC_START); -#endif - -#ifdef MNG_BIGENDIAN_SUPPORTED - /* fast way for big endian */ - iWrite = (((mng_uint8)(pData->iBGred >> 8)) << 24) | - (((mng_uint8)(pData->iBGgreen >> 8)) << 16) | - (((mng_uint8)(pData->iBGblue >> 8)) << 8); -#elif defined(MNG_LITTLEENDIAN_SUPPORTED) - /* fast way for little endian */ - iWrite = (((mng_uint8)(pData->iBGblue >> 8)) << 16) | - (((mng_uint8)(pData->iBGgreen >> 8)) << 8) | - (((mng_uint8)(pData->iBGred >> 8)) ); -#else - /* generic way, works on all platforms */ - /* put the data in memory in the correct order */ - { - mng_uint8 aBytes[4]; - aBytes[0] = (mng_uint8)(pData->iBGred >> 8); - aBytes[1] = (mng_uint8)(pData->iBGgreen >> 8); - aBytes[2] = (mng_uint8)(pData->iBGblue >> 8); - aBytes[3] = 0x00; - /* load that data into a register */ - iWrite = *(mng_uint32*) aBytes; - } -#endif - /* ok; drop the background-color in there */ - for (iX = (pData->iSourcer - pData->iSourcel); iX > 0; iX--) - *pWork32++ = iWrite; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BGCOLOR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCANVAS_RGB8 -mng_retcode mng_restore_bkgd_rgb8 (mng_datap pData) -{ - mng_int32 iX; - mng_uint8p pBkgd; - mng_uint8p pWork = pData->pRGBArow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_RGB8, MNG_LC_START); -#endif - - if (pData->fGetbkgdline) /* can we access the background ? */ - { /* point to the right pixel then */ - pBkgd = (mng_uint8p)pData->fGetbkgdline ((mng_handle)pData, - pData->iRow + pData->iDestt) + - (3 * pData->iDestl); - - for (iX = (pData->iSourcer - pData->iSourcel); iX > 0; iX--) - { - *pWork = *pBkgd; /* ok; copy the pixel */ - *(pWork+1) = *(pBkgd+1); - *(pWork+2) = *(pBkgd+2); - *(pWork+3) = 0x00; /* transparant for alpha-canvasses */ - - pWork += 4; - pBkgd += 3; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_RGB8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SKIPCANVAS_RGB8 */ - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCANVAS_BGR8 -mng_retcode mng_restore_bkgd_bgr8 (mng_datap pData) -{ - mng_int32 iX; - mng_uint8p pBkgd; - mng_uint8p pWork = pData->pRGBArow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BGR8, MNG_LC_START); -#endif - - if (pData->fGetbkgdline) /* can we access the background ? */ - { /* point to the right pixel then */ - pBkgd = (mng_uint8p)pData->fGetbkgdline ((mng_handle)pData, - pData->iRow + pData->iDestt) + - (3 * pData->iDestl); - - for (iX = (pData->iSourcer - pData->iSourcel); iX > 0; iX--) - { - *pWork = *(pBkgd+2); /* ok; copy the pixel */ - *(pWork+1) = *(pBkgd+1); - *(pWork+2) = *pBkgd; - *(pWork+3) = 0x00; /* transparant for alpha-canvasses */ - - pWork += 4; - pBkgd += 3; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BGR8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SKIPCANVAS_BGR8 */ - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCANVAS_BGRX8 -mng_retcode mng_restore_bkgd_bgrx8 (mng_datap pData) -{ - mng_int32 iX; - mng_uint8p pBkgd; - mng_uint8p pWork = pData->pRGBArow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BGRX8, MNG_LC_START); -#endif - - if (pData->fGetbkgdline) /* can we access the background ? */ - { /* point to the right pixel then */ - pBkgd = (mng_uint8p)pData->fGetbkgdline ((mng_handle)pData, - pData->iRow + pData->iDestt) + - (3 * pData->iDestl); - - for (iX = (pData->iSourcer - pData->iSourcel); iX > 0; iX--) - { - *pWork = *(pBkgd+2); /* ok; copy the pixel */ - *(pWork+1) = *(pBkgd+1); - *(pWork+2) = *pBkgd; - *(pWork+3) = 0x00; /* transparant for alpha-canvasses */ - - pWork += 4; - pBkgd += 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BGRX8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SKIPCANVAS_BGRX8 */ - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCANVAS_BGR565 -mng_retcode mng_restore_bkgd_bgr565 (mng_datap pData) -{ - mng_int32 iX; - mng_uint8p pBkgd; - mng_uint8p pWork = pData->pRGBArow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BGR565, MNG_LC_START); -#endif - - if (pData->fGetbkgdline) /* can we access the background ? */ - { /* point to the right pixel then */ - pBkgd = (mng_uint8p)pData->fGetbkgdline ((mng_handle)pData, - pData->iRow + pData->iDestt) + - (3 * pData->iDestl); - - for (iX = (pData->iSourcer - pData->iSourcel); iX > 0; iX--) - { - *pWork = (mng_uint8)( *(pBkgd+1) & 0xF8); /* ok; copy the pixel */ - *(pWork+1) = (mng_uint8)( (*(pBkgd+1) << 5 ) | ( ((*pBkgd)&0xE0)>>3 ) ); - *(pWork+2) = (mng_uint8)( *(pBkgd) << 3 ); - *(pWork+3) = 0x00; /* transparant for alpha-canvasses */ - - pWork += 4; - pBkgd += 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BGR565, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SKIPCANVAS_BGR565 */ - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCANVAS_RGB565 -mng_retcode mng_restore_bkgd_rgb565 (mng_datap pData) -{ - mng_int32 iX; - mng_uint8p pBkgd; - mng_uint8p pWork = pData->pRGBArow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_RGB565, MNG_LC_START); -#endif - - if (pData->fGetbkgdline) /* can we access the background ? */ - { /* point to the right pixel then */ - pBkgd = (mng_uint8p)pData->fGetbkgdline ((mng_handle)pData, - pData->iRow + pData->iDestt) + - (3 * pData->iDestl); - - for (iX = (pData->iSourcer - pData->iSourcel); iX > 0; iX--) - { - *pWork = (mng_uint8)( *(pBkgd)&0xF8); /* ok; copy the pixel */ - *(pWork+1) = (mng_uint8)( (*(pBkgd+1) << 5) | ( ((*pBkgd)&0xE0)>>3 ) ); - *(pWork+2) = (mng_uint8)( *(pBkgd+1) << 3); - *(pWork+3) = 0x00; /* transparant for alpha-canvasses */ - - pWork += 4; - pBkgd += 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_RGB565, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SKIPCANVAS_RBB565 */ - - -/* ************************************************************************** */ -/* * * */ -/* * Row retrieval routines - retrieve processed & uncompressed row-data * */ -/* * from the current "object" * */ -/* * * */ -/* ************************************************************************** */ - -/* TODO: a serious optimization is to retrieve only those pixels that will - actually be displayed; this would require changes in - the "display_image" routine (in mng_display.c) & - all the "retrieve_xxx" routines below & - the "display_xxx" routines above !!!!! - NOTE that "correct_xxx" routines would not require modification */ - -mng_retcode mng_retrieve_g8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iG; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_G8, MNG_LC_START); -#endif - - pRGBArow = pData->pRGBArow; /* temporary work pointers */ - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - - if (pBuf->bHasTRNS) /* tRNS in buffer ? */ - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - iG = *pWorkrow; /* get the gray-value */ - /* is it transparent ? */ - if ((mng_uint16)iG == pBuf->iTRNSgray) - { - *pRGBArow = 0x00; /* nuttin to display */ - *(pRGBArow+1) = 0x00; - *(pRGBArow+2) = 0x00; - *(pRGBArow+3) = 0x00; - } - else - { -#ifndef MNG_NO_1_2_4BIT_SUPPORT - mng_uint8 multiplier[]={0,255,85,0,17,0,0,0,1}; - iG = (mng_uint8)(iG * multiplier[pBuf->iBitdepth]); -#endif - - *pRGBArow = iG; /* put in intermediate row */ - *(pRGBArow+1) = iG; - *(pRGBArow+2) = iG; - *(pRGBArow+3) = 0xFF; - } - - pWorkrow++; /* next pixel */ - pRGBArow += 4; - } - } - else - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { -#ifndef MNG_NO_1_2_4BIT_SUPPORT - mng_uint8 multiplier[]={0,255,85,0,17,0,0,0,1}; /* LBR scaling */ - iG = (mng_uint8)(multiplier[pBuf->iBitdepth] * *pWorkrow); -#else - iG = *pWorkrow; /* get the gray-value */ -#endif - - *pRGBArow = iG; /* put in intermediate row */ - *(pRGBArow+1) = iG; - *(pRGBArow+2) = iG; - *(pRGBArow+3) = 0xFF; - - pWorkrow++; /* next pixel */ - pRGBArow += 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_G8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_retrieve_g16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint16 iG; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_G16, MNG_LC_START); -#endif - /* temporary work pointers */ - pRGBArow = pData->pRGBArow; - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - - if (pBuf->bHasTRNS) /* tRNS in buffer ? */ - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - iG = mng_get_uint16 (pWorkrow); /* get the gray-value */ - /* is it transparent ? */ - if (iG == pBuf->iTRNSgray) - { /* nuttin to display */ - mng_put_uint16 (pRGBArow, 0x0000); - mng_put_uint16 (pRGBArow+2, 0x0000); - mng_put_uint16 (pRGBArow+4, 0x0000); - mng_put_uint16 (pRGBArow+6, 0x0000); - } - else - { /* put in intermediate row */ - mng_put_uint16 (pRGBArow, iG); - mng_put_uint16 (pRGBArow+2, iG); - mng_put_uint16 (pRGBArow+4, iG); - mng_put_uint16 (pRGBArow+6, 0xFFFF); - } - - pWorkrow += 2; /* next pixel */ - pRGBArow += 8; - } - } - else - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - iG = mng_get_uint16 (pWorkrow); /* get the gray-value */ - - mng_put_uint16 (pRGBArow, iG); /* and put in intermediate row */ - mng_put_uint16 (pRGBArow+2, iG); - mng_put_uint16 (pRGBArow+4, iG); - mng_put_uint16 (pRGBArow+6, 0xFFFF); - - pWorkrow += 2; /* next pixel */ - pRGBArow += 8; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_G16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_retrieve_rgb8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iR, iG, iB; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_RGB8, MNG_LC_START); -#endif - - pRGBArow = pData->pRGBArow; /* temporary work pointers */ - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - - if (pBuf->bHasTRNS) /* tRNS in buffer ? */ - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - iR = *pWorkrow; /* get the rgb-values */ - iG = *(pWorkrow+1); - iB = *(pWorkrow+2); - /* is it transparent ? */ - if (((mng_uint16)iR == pBuf->iTRNSred ) && - ((mng_uint16)iG == pBuf->iTRNSgreen) && - ((mng_uint16)iB == pBuf->iTRNSblue ) ) - { - *pRGBArow = 0x00; /* nothing to display */ - *(pRGBArow+1) = 0x00; - *(pRGBArow+2) = 0x00; - *(pRGBArow+3) = 0x00; - } - else - { - *pRGBArow = iR; /* put in intermediate row */ - *(pRGBArow+1) = iG; - *(pRGBArow+2) = iB; - *(pRGBArow+3) = 0xFF; - } - - pWorkrow += 3; /* next pixel */ - pRGBArow += 4; - } - } - else - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pRGBArow = *pWorkrow; /* just copy the pixel */ - *(pRGBArow+1) = *(pWorkrow+1); - *(pRGBArow+2) = *(pWorkrow+2); - *(pRGBArow+3) = 0xFF; - - pWorkrow += 3; /* next pixel */ - pRGBArow += 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_RGB8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_retrieve_rgb16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint16 iR, iG, iB; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_RGB16, MNG_LC_START); -#endif - /* temporary work pointers */ - pRGBArow = pData->pRGBArow; - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - - if (pBuf->bHasTRNS) /* tRNS in buffer ? */ - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - iR = mng_get_uint16 (pWorkrow); /* get the rgb-values */ - iG = mng_get_uint16 (pWorkrow+2); - iB = mng_get_uint16 (pWorkrow+4); - /* is it transparent ? */ - if ((iR == pBuf->iTRNSred ) && - (iG == pBuf->iTRNSgreen) && - (iB == pBuf->iTRNSblue ) ) - { /* nothing to display */ - mng_put_uint16 (pRGBArow, 0x0000); - mng_put_uint16 (pRGBArow+2, 0x0000); - mng_put_uint16 (pRGBArow+4, 0x0000); - mng_put_uint16 (pRGBArow+6, 0x0000); - } - else - { /* put in intermediate row */ - mng_put_uint16 (pRGBArow, iR); - mng_put_uint16 (pRGBArow+2, iG); - mng_put_uint16 (pRGBArow+4, iB); - mng_put_uint16 (pRGBArow+6, 0xFFFF); - } - - pWorkrow += 6; /* next pixel */ - pRGBArow += 8; - } - } - else - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { /* just copy the pixel */ - mng_put_uint16 (pRGBArow, mng_get_uint16 (pWorkrow )); - mng_put_uint16 (pRGBArow+2, mng_get_uint16 (pWorkrow+2)); - mng_put_uint16 (pRGBArow+4, mng_get_uint16 (pWorkrow+4)); - mng_put_uint16 (pRGBArow+6, 0xFFFF); - - pWorkrow += 6; /* next pixel */ - pRGBArow += 8; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_RGB16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_retrieve_idx8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_IDX8, MNG_LC_START); -#endif - - pRGBArow = pData->pRGBArow; /* temporary work pointers */ - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - - if (pBuf->bHasTRNS) /* tRNS in buffer ? */ - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - iQ = *pWorkrow; /* get the index */ - /* is it valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - *pRGBArow = pBuf->aPLTEentries [iQ].iRed; - *(pRGBArow+1) = pBuf->aPLTEentries [iQ].iGreen; - *(pRGBArow+2) = pBuf->aPLTEentries [iQ].iBlue; - /* transparency for this index ? */ - if ((mng_uint32)iQ < pBuf->iTRNScount) - *(pRGBArow+3) = pBuf->aTRNSentries [iQ]; - else - *(pRGBArow+3) = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR); - - pWorkrow++; /* next pixel */ - pRGBArow += 4; - } - } - else - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - iQ = *pWorkrow; /* get the index */ - /* is it valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - *pRGBArow = pBuf->aPLTEentries [iQ].iRed; - *(pRGBArow+1) = pBuf->aPLTEentries [iQ].iGreen; - *(pRGBArow+2) = pBuf->aPLTEentries [iQ].iBlue; - *(pRGBArow+3) = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR); - - pWorkrow++; /* next pixel */ - pRGBArow += 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_IDX8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_retrieve_ga8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iG; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_GA8, MNG_LC_START); -#endif - - pRGBArow = pData->pRGBArow; /* temporary work pointers */ - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - iG = *pWorkrow; /* get the gray-value */ - *pRGBArow = iG; /* put in intermediate row */ - *(pRGBArow+1) = iG; - *(pRGBArow+2) = iG; - *(pRGBArow+3) = *(pWorkrow+1); - - pWorkrow += 2; /* next pixel */ - pRGBArow += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_GA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_retrieve_ga16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint16 iG; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_GA16, MNG_LC_START); -#endif - /* temporary work pointers */ - pRGBArow = pData->pRGBArow; - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - iG = mng_get_uint16 (pWorkrow); /* get the gray-value */ - - mng_put_uint16 (pRGBArow, iG); /* and put in intermediate row */ - mng_put_uint16 (pRGBArow+2, iG); - mng_put_uint16 (pRGBArow+4, iG); - mng_put_uint16 (pRGBArow+6, mng_get_uint16 (pWorkrow+2)); - - pWorkrow += 4; /* next pixel */ - pRGBArow += 8; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_GA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_retrieve_rgba8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_RGBA8, MNG_LC_START); -#endif - - pRGBArow = pData->pRGBArow; /* temporary work pointers */ - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - /* can't be easier than this ! */ - MNG_COPY (pRGBArow, pWorkrow, pBuf->iRowsize); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_RGBA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_retrieve_rgba16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_RGBA16, MNG_LC_START); -#endif - /* temporary work pointers */ - pRGBArow = pData->pRGBArow; - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - /* can't be easier than this ! */ - MNG_COPY (pRGBArow, pWorkrow, pBuf->iRowsize); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_RGBA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Row storage routines - store processed & uncompressed row-data * */ -/* * into the current "object" * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_store_g1 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G1, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* is it white ? */ - *pOutrow = 0x01; /* white */ - else - *pOutrow = 0x00; /* black */ - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 1; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_store_g2 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G2, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - - iQ = (mng_uint8)((iB & iM) >> iS); /* get the gray level */ - *pOutrow = iQ; /* put in object buffer */ - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 2; - iS -= 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_store_g4 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G4, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - - iQ = (mng_uint8)((iB & iM) >> iS); /* get the gray level */ - *pOutrow = iQ; /* put in object buffer */ - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 4; - iS -= 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G4, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_store_g8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G8, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; /* put in object buffer */ - - pOutrow += pData->iColinc; /* next pixel */ - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_store_g16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G16, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { /* copy into object buffer */ - mng_put_uint16 (pOutrow, mng_get_uint16 (pWorkrow)); - - pOutrow += (pData->iColinc << 1); /* next pixel */ - pWorkrow += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_store_rgb8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_RGB8, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; /* copy the RGB bytes */ - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - - pWorkrow += 3; /* next pixel */ - pOutrow += (pData->iColinc * 3); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_RGB8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_store_rgb16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_RGB16, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - MNG_COPY (pOutrow, pWorkrow, 6); /* copy the RGB bytes */ - - pWorkrow += 6; /* next pixel */ - pOutrow += (pData->iColinc * 6); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_RGB16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_store_idx1 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_IDX1, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* store the index */ - *pOutrow = 0x01; - else - *pOutrow = 0x00; - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 1; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_IDX1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_store_idx2 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_IDX2, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - /* store the index */ - *pOutrow = (mng_uint8)((iB & iM) >> iS); - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 2; - iS -= 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_IDX2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_store_idx4 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_IDX4, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* store the index */ - *pOutrow = (mng_uint8)((iB & iM) >> iS); - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 4; - iS -= 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_IDX4, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_store_idx8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_IDX8, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; /* put in object buffer */ - - pOutrow += pData->iColinc; /* next pixel */ - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_IDX8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_store_ga8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_GA8, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; /* copy the GA bytes */ - *(pOutrow+1) = *(pWorkrow+1); - - pWorkrow += 2; /* next pixel */ - pOutrow += (pData->iColinc << 1); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_GA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_store_ga16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_GA16, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - MNG_COPY (pOutrow, pWorkrow, 4); /* copy the GA bytes */ - - pWorkrow += 4; /* next pixel */ - pOutrow += (pData->iColinc << 2); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_GA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_store_rgba8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_RGBA8, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; /* copy the RGBA bytes */ - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - *(pOutrow+3) = *(pWorkrow+3); - - pWorkrow += 4; /* next pixel */ - pOutrow += (pData->iColinc << 2); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_RGBA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_store_rgba16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_RGBA16, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - MNG_COPY (pOutrow, pWorkrow, 8); /* copy the RGBA bytes */ - - pWorkrow += 8; /* next pixel */ - pOutrow += (pData->iColinc << 3); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_RGBA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Row storage routines (JPEG) - store processed & uncompressed row-data * */ -/* * into the current "object" * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG - -/* ************************************************************************** */ - -mng_retcode mng_store_jpeg_g8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8, MNG_LC_START); -#endif - - pWorkrow = pData->pJPEGrow; /* temporary work pointers */ - pOutrow = pBuf->pImgdata + (pData->iJPEGrow * pBuf->iRowsize); - /* easy as pie ... */ - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8, MNG_LC_END); -#endif - - return mng_next_jpeg_row (pData); /* we've got one more row of gray-samples */ -} - -/* ************************************************************************** */ - -mng_retcode mng_store_jpeg_rgb8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; -#if RGB_PIXELSIZE != 3 - mng_int32 iX; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8, MNG_LC_START); -#endif - - pWorkrow = pData->pJPEGrow; /* temporary work pointers */ - pOutrow = pBuf->pImgdata + (pData->iJPEGrow * pBuf->iRowsize); - -#if RGB_PIXELSIZE == 3 - /* easy as pie ... */ - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples * 3); -#else -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; /* copy pixel into object buffer */ - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - - pOutrow += 3; /* next pixel */ - pWorkrow += RGB_PIXELSIZE; - } -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8, MNG_LC_END); -#endif - - return mng_next_jpeg_row (pData); /* we've got one more row of rgb-samples */ -} - -/* ************************************************************************** */ - -mng_retcode mng_store_jpeg_ga8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_GA8, MNG_LC_START); -#endif - - pWorkrow = pData->pJPEGrow; /* temporary work pointers */ - pOutrow = pBuf->pImgdata + (pData->iJPEGrow * pBuf->iRowsize); - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; /* copy into object buffer */ - - pOutrow += 2; /* next pixel */ - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_GA8, MNG_LC_END); -#endif - - return mng_next_jpeg_row (pData); /* we've got one more row of gray-samples */ -} - -/* ************************************************************************** */ - -mng_retcode mng_store_jpeg_rgba8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGBA8, MNG_LC_START); -#endif - - pWorkrow = pData->pJPEGrow; /* temporary work pointers */ - pOutrow = pBuf->pImgdata + (pData->iJPEGrow * pBuf->iRowsize); - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; /* copy pixel into object buffer */ - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - - pOutrow += 4; /* next pixel */ - pWorkrow += RGB_PIXELSIZE; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGBA8, MNG_LC_END); -#endif - - return mng_next_jpeg_row (pData); /* we've got one more row of rgb-samples */ -} - -/* ************************************************************************** */ - -mng_retcode mng_store_jpeg_g8_alpha (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_ALPHA, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pJPEGrow2; - pOutrow = pBuf->pImgdata + (pData->iJPEGalpharow * pBuf->iRowsize) + 1; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; /* put in object buffer */ - - pOutrow += 2; /* next pixel */ - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_ALPHA, MNG_LC_END); -#endif - /* we've got one more row of alpha-samples */ - return mng_next_jpeg_alpharow (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_store_jpeg_rgb8_alpha (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_ALPHA, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pJPEGrow2; - pOutrow = pBuf->pImgdata + (pData->iJPEGalpharow * pBuf->iRowsize) + 3; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; /* put in object buffer */ - - pOutrow += 4; /* next pixel */ - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_ALPHA, MNG_LC_END); -#endif - /* we've got one more row of alpha-samples */ - return mng_next_jpeg_alpharow (pData); -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_store_jpeg_g8_a1 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A1, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 1; - iM = 0; /* start at pixel 0 */ - iB = 0; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* is it opaque ? */ - *pOutrow = 0xFF; /* opaque */ - else - *pOutrow = 0x00; /* transparent */ - - pOutrow += 2; /* next pixel */ - iM >>= 1; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A1, MNG_LC_END); -#endif - /* we've got one more row of alpha-samples */ - return mng_next_jpeg_alpharow (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_store_jpeg_g8_a2 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A2, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 1; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - -#ifdef MNG_OPTIMIZE_FOOTPRINT_SWITCH - { - const mng_uint8 alpha_level[4] = { 0x00, 0x55, 0xAA, 0xFF}; - *pOutrow = alpha_level[((iB & iM) >> iS)] ; - } -#else - switch ((iB & iM) >> iS) /* determine the alpha level */ - { - case 0x03 : { *pOutrow = 0xFF; break; } - case 0x02 : { *pOutrow = 0xAA; break; } - case 0x01 : { *pOutrow = 0x55; break; } - default : { *pOutrow = 0x00; } - } -#endif - - pOutrow += 2; /* next pixel */ - iM >>= 2; - iS -= 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A2, MNG_LC_END); -#endif - /* we've got one more row of alpha-samples */ - return mng_next_jpeg_alpharow (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_store_jpeg_g8_a4 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A4, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 1; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the alpha level */ - iQ = (mng_uint8)((iB & iM) >> iS); - iQ = (mng_uint8)(iQ + (iQ << 4)); /* expand to 8-bit by replication */ - - *pOutrow = iQ; /* put in object buffer */ - - pOutrow += 2; /* next pixel */ - iM >>= 4; - iS -= 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A4, MNG_LC_END); -#endif - /* we've got one more row of alpha-samples */ - return mng_next_jpeg_alpharow (pData); -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_store_jpeg_g8_a8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A8, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 1; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; /* put in object buffer */ - - pOutrow += 2; /* next pixel */ - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A8, MNG_LC_END); -#endif - /* we've got one more row of alpha-samples */ - return mng_next_jpeg_alpharow (pData); -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_store_jpeg_g8_a16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A16, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 1; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; /* only high-order byte! */ - - pOutrow += 2; /* next pixel */ - pWorkrow += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A16, MNG_LC_END); -#endif - /* we've got one more row of alpha-samples */ - return mng_next_jpeg_alpharow (pData); -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_store_jpeg_rgb8_a1 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A1, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 3; - iM = 0; /* start at pixel 0 */ - iB = 0; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* is it opaque ? */ - *pOutrow = 0xFF; /* opaque */ - else - *pOutrow = 0x00; /* transparent */ - - pOutrow += 4; /* next pixel */ - iM >>= 1; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A1, MNG_LC_END); -#endif - /* we've got one more row of alpha-samples */ - return mng_next_jpeg_alpharow (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_store_jpeg_rgb8_a2 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A2, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 3; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - -#ifdef MNG_OPTIMIZE_FOOTPRINT_SWITCH - { - const mng_uint8 alpha_level[4] = { 0x00, 0x55, 0xAA, 0xFF}; - *pOutrow = alpha_level[((iB & iM) >> iS)] ; - } -#else - switch ((iB & iM) >> iS) /* determine the alpha level */ - { - case 0x03 : { *pOutrow = 0xFF; break; } - case 0x02 : { *pOutrow = 0xAA; break; } - case 0x01 : { *pOutrow = 0x55; break; } - default : { *pOutrow = 0x00; } - } -#endif - - pOutrow += 4; /* next pixel */ - iM >>= 2; - iS -= 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A2, MNG_LC_END); -#endif - /* we've got one more row of alpha-samples */ - return mng_next_jpeg_alpharow (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_store_jpeg_rgb8_a4 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A4, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 3; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the alpha level */ - iQ = (mng_uint8)((iB & iM) >> iS); - iQ = (mng_uint8)(iQ + (iQ << 4)); /* expand to 8-bit by replication */ - - *pOutrow = iQ; /* put in object buffer */ - - pOutrow += 4; /* next pixel */ - iM >>= 4; - iS -= 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A4, MNG_LC_END); -#endif - /* we've got one more row of alpha-samples */ - return mng_next_jpeg_alpharow (pData); -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_store_jpeg_rgb8_a8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A8, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 3; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; /* put in buffer */ - - pOutrow += 4; /* next pixel */ - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A8, MNG_LC_END); -#endif - /* we've got one more row of alpha-samples */ - return mng_next_jpeg_alpharow (pData); -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_store_jpeg_rgb8_a16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A16, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 3; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; /* only high-order byte */ - - pOutrow += 4; /* next pixel */ - pWorkrow += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A16, MNG_LC_END); -#endif - /* we've got one more row of alpha-samples */ - return mng_next_jpeg_alpharow (pData); -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_JPEG12 -mng_retcode mng_store_jpeg_g12_a1 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A1, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 2; - iM = 0; /* start at pixel 0 */ - iB = 0; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* opaque ? */ - mng_put_uint16 (pOutrow, 0xFFFF);/* opaque */ - else - mng_put_uint16 (pOutrow, 0x0000);/* transparent */ - - pOutrow += 4; /* next pixel */ - iM >>= 1; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A1, MNG_LC_END); -#endif - /* we've got one more row of alpha-samples */ - return mng_next_jpeg_alpharow (pData); -} -#endif /* MNG_SUPPORT_JPEG12 */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_JPEG12 -mng_retcode mng_store_jpeg_g12_a2 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A2, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 2; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - -#ifdef MNG_OPTIMIZE_FOOTPRINT_SWITCH - { - const mng_uint16 gray_level[4] = { 0x0000, 0x5555, 0xAAAA, 0xFFFF}; - mng_put_uint16 (pOutrow, gray_level[((iB & iM) >> iS)]) ; - } -#else - switch ((iB & iM) >> iS) /* determine the gray level */ - { - case 0x03 : { mng_put_uint16 (pOutrow, 0xFFFF); break; } - case 0x02 : { mng_put_uint16 (pOutrow, 0xAAAA); break; } - case 0x01 : { mng_put_uint16 (pOutrow, 0x5555); break; } - default : { mng_put_uint16 (pOutrow, 0x0000); } - } -#endif - - pOutrow += 4; /* next pixel */ - iM >>= 2; - iS -= 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A2, MNG_LC_END); -#endif - /* we've got one more row of alpha-samples */ - return mng_next_jpeg_alpharow (pData); -} -#endif /* MNG_SUPPORT_JPEG12 */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_JPEG12 -mng_retcode mng_store_jpeg_g12_a4 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint16 iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A4, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 2; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the gray level */ - iQ = (mng_uint16)((iB & iM) >> iS); - iQ = (mng_uint16)(iQ + (iQ << 4)); /* expand to 16-bit by replication */ - iQ = (mng_uint16)(iQ + (iQ << 8)); - /* put in object buffer */ - mng_put_uint16 (pOutrow, iQ); - - pOutrow += 4; /* next pixel */ - iM >>= 4; - iS -= 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A4, MNG_LC_END); -#endif - /* we've got one more row of alpha-samples */ - return mng_next_jpeg_alpharow (pData); -} -#endif /* MNG_SUPPORT_JPEG12 */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_JPEG12 -mng_retcode mng_store_jpeg_g12_a8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint16 iW; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A8, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 2; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - iW = (mng_uint16)(*pWorkrow); /* get input byte */ - iW = (mng_uint16)(iW + (iW << 8)); /* expand to 16-bit by replication */ - - mng_put_uint16 (pOutrow, iW); /* put in object buffer */ - - pOutrow += 4; /* next pixel */ - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A8, MNG_LC_END); -#endif - /* we've got one more row of alpha-samples */ - return mng_next_jpeg_alpharow (pData); -} -#endif /* MNG_SUPPORT_JPEG12 */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_JPEG12 -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_store_jpeg_g12_a16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A16, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 2; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { /* copy it */ - mng_put_uint16 (pOutrow, mng_get_uint16 (pWorkrow)); - - pOutrow += 4; /* next pixel */ - pWorkrow += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A16, MNG_LC_END); -#endif - /* we've got one more row of alpha-samples */ - return mng_next_jpeg_alpharow (pData); -} -#endif -#endif /* MNG_SUPPORT_JPEG12 */ - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_JNG */ - -#ifndef MNG_NO_DELTA_PNG -/* ************************************************************************** */ -/* * * */ -/* * Delta-image row routines - apply the processed & uncompressed row-data * */ -/* * onto the target "object" * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_delta_g1 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G1, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* is it white ? */ - *pOutrow = 0xFF; /* white */ - else - *pOutrow = 0x00; /* black */ - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 1; - } - } - else - { /* pixel add ! */ -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* invert if it is white ? */ - *pOutrow = (mng_uint8)(*pOutrow ^ 0xFF); - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 1; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G1, MNG_LC_END); -#endif - - return mng_store_g1 (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_delta_g2 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; -#ifdef MNG_OPTIMIZE_FOOTPRINT_SWITCH - const mng_uint8 level[4] = { 0x00, 0x55, 0xAA, 0xFF}; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G2, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - -#ifdef MNG_OPTIMIZE_FOOTPRINT_SWITCH - *pOutrow = level[((iB & iM) >> iS)] ; -#else - switch ((iB & iM) >> iS) /* determine the alpha level */ - { - case 0x03 : { *pOutrow = 0xFF; break; } - case 0x02 : { *pOutrow = 0xAA; break; } - case 0x01 : { *pOutrow = 0x55; break; } - default : { *pOutrow = 0x00; } - } -#endif - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 2; - iS -= 2; - } - } - else - { /* pixel add ! */ -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - -#ifdef MNG_OPTIMIZE_FOOTPRINT_SWITCH - *pOutrow = level[((*pOutrow >> 6) + ((iB & iM) >> iS)) & 0x03] ; -#else - switch (((*pOutrow >> 6) + ((iB & iM) >> iS)) & 0x03) - { - case 0x03 : { *pOutrow = 0xFF; break; } - case 0x02 : { *pOutrow = 0xAA; break; } - case 0x01 : { *pOutrow = 0x55; break; } - default : { *pOutrow = 0x00; } - } -#endif - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 2; - iS -= 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G2, MNG_LC_END); -#endif - - return mng_store_g2 (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_delta_g4 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G4, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the gray level */ - iQ = (mng_uint8)((iB & iM) >> iS); - /* expand to 8-bit by replication */ - iQ = (mng_uint8)(iQ + (iQ << 4)); - - *pOutrow = iQ; /* put in object buffer */ - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 4; - iS -= 4; - } - } - else - { /* pixel add ! */ -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the gray level */ - iQ = (mng_uint8)(((*pOutrow >> 4) + ((iB & iM) >> iS)) & 0x0F); - /* expand to 8-bit by replication */ - iQ = (mng_uint8)(iQ + (iQ << 4)); - - *pOutrow = iQ; /* put in object buffer */ - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 4; - iS -= 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G4, MNG_LC_END); -#endif - - return mng_store_g4 (pData); -} -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - -/* ************************************************************************** */ - -mng_retcode mng_delta_g8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G8, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; /* put in object buffer */ - - pOutrow += pData->iColinc; /* next pixel */ - pWorkrow++; - } - } - else - { /* pixel add ! */ -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { /* add to object buffer */ - *pOutrow = (mng_uint8)(*pOutrow + *pWorkrow); - - pOutrow += pData->iColinc; /* next pixel */ - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G8, MNG_LC_END); -#endif - - return mng_store_g8 (pData); -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_delta_g16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G16, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; /* put in object buffer */ - *(pOutrow+1) = *(pWorkrow+1); - /* next pixel */ - pOutrow += (pData->iColinc << 1); - pWorkrow += 2; - } - } - else - { /* pixel add ! */ -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { /* add to object buffer */ - mng_put_uint16 (pOutrow, (mng_uint16)(mng_get_uint16 (pOutrow ) + - mng_get_uint16 (pWorkrow) )); - /* next pixel */ - pOutrow += (pData->iColinc << 1); - pWorkrow += 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G16, MNG_LC_END); -#endif - - return mng_store_g16 (pData); -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_delta_rgb8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGB8, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; /* put in object buffer */ - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - /* next pixel */ - pOutrow += (pData->iColinc * 3); - pWorkrow += 3; - } - } - else - { /* pixel add ! */ -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { /* add to object buffer */ - *pOutrow = (mng_uint8)(*pOutrow + *pWorkrow ); - *(pOutrow+1) = (mng_uint8)(*(pOutrow+1) + *(pWorkrow+1)); - *(pOutrow+2) = (mng_uint8)(*(pOutrow+2) + *(pWorkrow+2)); - /* next pixel */ - pOutrow += (pData->iColinc * 3); - pWorkrow += 3; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGB8, MNG_LC_END); -#endif - - return mng_store_rgb8 (pData); -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_delta_rgb16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGB16, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; /* put in object buffer */ - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - *(pOutrow+3) = *(pWorkrow+3); - *(pOutrow+4) = *(pWorkrow+4); - *(pOutrow+5) = *(pWorkrow+5); - /* next pixel */ - pOutrow += (pData->iColinc * 6); - pWorkrow += 6; - } - } - else - { /* pixel add ! */ -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { /* add to object buffer */ - mng_put_uint16 (pOutrow, (mng_uint16)(mng_get_uint16 (pOutrow ) + - mng_get_uint16 (pWorkrow ) )); - mng_put_uint16 (pOutrow+2, (mng_uint16)(mng_get_uint16 (pOutrow+2 ) + - mng_get_uint16 (pWorkrow+2) )); - mng_put_uint16 (pOutrow+4, (mng_uint16)(mng_get_uint16 (pOutrow+4 ) + - mng_get_uint16 (pWorkrow+4) )); - /* next pixel */ - pOutrow += (pData->iColinc * 6); - pWorkrow += 6; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGB16, MNG_LC_END); -#endif - - return mng_store_rgb16 (pData); -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_delta_idx1 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_IDX1, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* put the right index value */ - *pOutrow = 1; - else - *pOutrow = 0; - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 1; - } - } - else - { /* pixel add ! */ -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* invert if it is non-zero index */ - *pOutrow = (mng_uint8)(*pOutrow ^ 0x01); - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 1; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_IDX1, MNG_LC_END); -#endif - - return mng_store_idx1 (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_delta_idx2 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_IDX2, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - /* put the index */ - *pOutrow = (mng_uint8)((iB & iM) >> iS); - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 2; - iS -= 2; - } - } - else - { /* pixel add ! */ -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - /* calculate the index */ - *pOutrow = (mng_uint8)((*pOutrow + ((iB & iM) >> iS)) & 0x03); - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 2; - iS -= 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_IDX2, MNG_LC_END); -#endif - - return mng_store_idx2 (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_delta_idx4 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_IDX4, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* put the index */ - *pOutrow = (mng_uint8)((iB & iM) >> iS); - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 4; - iS -= 4; - } - } - else - { /* pixel add ! */ -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* calculate the index */ - *pOutrow = (mng_uint8)((*pOutrow + ((iB & iM) >> iS)) & 0x0F); - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 4; - iS -= 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_IDX4, MNG_LC_END); -#endif - - return mng_store_idx4 (pData); -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_delta_idx8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_IDX8, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; /* put in object buffer */ - - pOutrow += pData->iColinc; /* next pixel */ - pWorkrow++; - } - } - else - { /* pixel add ! */ -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { /* add to object buffer */ - *pOutrow = (mng_uint8)(*pOutrow + *pWorkrow); - - pOutrow += pData->iColinc; /* next pixel */ - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_IDX8, MNG_LC_END); -#endif - - return mng_store_idx8 (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_delta_ga8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA8, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; /* put in object buffer */ - *(pOutrow+1) = *(pWorkrow+1); - /* next pixel */ - pOutrow += (pData->iColinc << 1); - pWorkrow += 2; - } - } - else - { /* pixel add ! */ -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { /* add to object buffer */ - *pOutrow = (mng_uint8)(*pOutrow + *pWorkrow ); - *(pOutrow+1) = (mng_uint8)(*(pOutrow+1) + *(pWorkrow+1)); - /* next pixel */ - pOutrow += (pData->iColinc << 1); - pWorkrow += 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA8, MNG_LC_END); -#endif - - return mng_store_ga8 (pData); -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_delta_ga16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA16, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; /* put in object buffer */ - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - *(pOutrow+3) = *(pWorkrow+3); - /* next pixel */ - pOutrow += (pData->iColinc << 2); - pWorkrow += 4; - } - } - else - { /* pixel add ! */ -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { /* add to object buffer */ - mng_put_uint16 (pOutrow, (mng_uint16)(mng_get_uint16 (pOutrow ) + - mng_get_uint16 (pWorkrow ) )); - mng_put_uint16 (pOutrow+2, (mng_uint16)(mng_get_uint16 (pOutrow+2 ) + - mng_get_uint16 (pWorkrow+2) )); - /* next pixel */ - pOutrow += (pData->iColinc << 2); - pWorkrow += 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA16, MNG_LC_END); -#endif - - return mng_store_ga16 (pData); -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_delta_rgba8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA8, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; /* put in object buffer */ - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - *(pOutrow+3) = *(pWorkrow+3); - /* next pixel */ - pOutrow += (pData->iColinc << 2); - pWorkrow += 4; - } - } - else - { /* pixel add ! */ -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { /* add to object buffer */ - *pOutrow = (mng_uint8)(*pOutrow + *pWorkrow ); - *(pOutrow+1) = (mng_uint8)(*(pOutrow+1) + *(pWorkrow+1)); - *(pOutrow+2) = (mng_uint8)(*(pOutrow+2) + *(pWorkrow+2)); - *(pOutrow+3) = (mng_uint8)(*(pOutrow+3) + *(pWorkrow+3)); - /* next pixel */ - pOutrow += (pData->iColinc << 2); - pWorkrow += 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA8, MNG_LC_END); -#endif - - return mng_store_rgba8 (pData); -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_delta_rgba16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA16, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - MNG_COPY (pOutrow, pWorkrow, 8); /* put in object buffer */ - /* next pixel */ - pOutrow += (pData->iColinc << 3); - pWorkrow += 8; - } - } - else - { /* pixel add ! */ -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { /* add to object buffer */ - mng_put_uint16 (pOutrow, (mng_uint16)(mng_get_uint16 (pOutrow ) + - mng_get_uint16 (pWorkrow ) )); - mng_put_uint16 (pOutrow+2, (mng_uint16)(mng_get_uint16 (pOutrow+2 ) + - mng_get_uint16 (pWorkrow+2) )); - mng_put_uint16 (pOutrow+4, (mng_uint16)(mng_get_uint16 (pOutrow+4 ) + - mng_get_uint16 (pWorkrow+4) )); - mng_put_uint16 (pOutrow+6, (mng_uint16)(mng_get_uint16 (pOutrow+6 ) + - mng_get_uint16 (pWorkrow+6) )); - /* next pixel */ - pOutrow += (pData->iColinc << 3); - pWorkrow += 8; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA16, MNG_LC_END); -#endif - - return mng_store_rgba16 (pData); -} -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Delta-image row routines - apply the source row onto the target * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_delta_g1_g1 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G1_G1, MNG_LC_START); -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples); - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0x01); - - pOutrow++; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G1_G1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_delta_g2_g2 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G2_G2, MNG_LC_START); -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples); - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0x03); - - pOutrow++; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G2_G2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_delta_g4_g4 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G4_G4, MNG_LC_START); -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples); - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0x0F); - - pOutrow++; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G4_G4, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_delta_g8_g8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G8_G8, MNG_LC_START); -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples); - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0xFF); - - pOutrow++; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G8_G8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_delta_g16_g16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G16_G16, MNG_LC_START); -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, (pData->iRowsamples << 1)); - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - mng_put_uint16 (pOutrow, (mng_uint16)((mng_get_uint16 (pOutrow) + - mng_get_uint16 (pWorkrow)) & 0xFFFF)); - - pOutrow += 2; - pWorkrow += 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G16_G16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif /* MNG_NO_DELTA_PNG */ - -/* ************************************************************************** */ - -mng_retcode mng_delta_rgb8_rgb8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGB8_RGB8, MNG_LC_START); -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples * 3); - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples*3; iX > 0; iX--) -#else - for (iX = 0; iX < (pData->iRowsamples * 3); iX++) -#endif - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0xFF); - - pOutrow++; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGB8_RGB8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_delta_rgb16_rgb16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGB16_RGB16, MNG_LC_START); -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, (pData->iRowsamples * 6)); - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - mng_put_uint16 (pOutrow, (mng_uint16)((mng_get_uint16 (pOutrow ) + - mng_get_uint16 (pWorkrow )) & 0xFFFF)); - mng_put_uint16 (pOutrow+2, (mng_uint16)((mng_get_uint16 (pOutrow+2) + - mng_get_uint16 (pWorkrow+2)) & 0xFFFF)); - mng_put_uint16 (pOutrow+4, (mng_uint16)((mng_get_uint16 (pOutrow+4) + - mng_get_uint16 (pWorkrow+4)) & 0xFFFF)); - - pOutrow += 6; - pWorkrow += 6; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGB16_RGB16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -mng_retcode mng_delta_ga8_ga8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA8_GA8, MNG_LC_START); -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples << 1); - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = (pData->iRowsamples<<1); iX > 0; iX--) -#else - for (iX = 0; iX < (pData->iRowsamples << 1); iX++) -#endif - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0xFF); - - pOutrow++; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA8_GA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_delta_ga8_g8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA8_G8, MNG_LC_START); -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORREPLACE) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; - - pOutrow += 2; - pWorkrow++; - } - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORADD) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0xFF); - - pOutrow += 2; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA8_G8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_delta_ga8_a8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA8_A8, MNG_LC_START); -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 1; - - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAREPLACE) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; - - pOutrow += 2; - pWorkrow++; - } - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAADD) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0xFF); - - pOutrow += 2; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA8_A8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_delta_ga16_ga16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA16_GA16, MNG_LC_START); -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, (pData->iRowsamples << 2)); - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - mng_put_uint16 (pOutrow, (mng_uint16)((mng_get_uint16 (pOutrow ) + - mng_get_uint16 (pWorkrow )) & 0xFFFF)); - mng_put_uint16 (pOutrow+2, (mng_uint16)((mng_get_uint16 (pOutrow+2) + - mng_get_uint16 (pWorkrow+2)) & 0xFFFF)); - - pOutrow += 4; - pWorkrow += 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA16_GA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_delta_ga16_g16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA16_G16, MNG_LC_START); -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORREPLACE) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - mng_put_uint16 (pOutrow, mng_get_uint16 (pWorkrow)); - - pOutrow += 4; - pWorkrow += 2; - } - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORADD) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - mng_put_uint16 (pOutrow, (mng_uint16)((mng_get_uint16 (pOutrow) + - mng_get_uint16 (pWorkrow)) & 0xFFFF)); - - pOutrow += 4; - pWorkrow += 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA16_G16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_delta_ga16_a16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA16_A16, MNG_LC_START); -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAREPLACE) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - mng_put_uint16 (pOutrow+2, mng_get_uint16 (pWorkrow)); - - pOutrow += 4; - pWorkrow += 2; - } - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAADD) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - mng_put_uint16 (pOutrow+2, (mng_uint16)((mng_get_uint16 (pOutrow+2) + - mng_get_uint16 (pWorkrow)) & 0xFFFF)); - - pOutrow += 4; - pWorkrow += 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA16_A16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif /* MNG_NO_DELTA_PNG */ - -/* ************************************************************************** */ - -mng_retcode mng_delta_rgba8_rgba8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA8_RGBA8, MNG_LC_START); -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples << 2); - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = (pData->iRowsamples << 2); iX > 0; iX--) -#else - for (iX = 0; iX < (pData->iRowsamples << 2); iX++) -#endif - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0xFF); - - pOutrow++; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA8_RGBA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -mng_retcode mng_delta_rgba8_rgb8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA8_RGB8, MNG_LC_START); -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORREPLACE) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - - pOutrow += 4; - pWorkrow += 3; - } - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORADD) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow ) & 0xFF); - *(pOutrow+1) = (mng_uint8)(((mng_uint16)*(pOutrow+1) + - (mng_uint16)*(pWorkrow+1)) & 0xFF); - *(pOutrow+2) = (mng_uint8)(((mng_uint16)*(pOutrow+2) + - (mng_uint16)*(pWorkrow+2)) & 0xFF); - - pOutrow += 4; - pWorkrow += 3; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA8_RGB8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_delta_rgba8_a8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA8_A8, MNG_LC_START); -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 3; - - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAREPLACE) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = *pWorkrow; - - pOutrow += 4; - pWorkrow++; - } - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAADD) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0xFF); - - pOutrow += 4; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA8_A8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_DELTA_PNG */ - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_delta_rgba16_rgba16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA16_RGBA16, MNG_LC_START); -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, (pData->iRowsamples << 3)); - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - mng_put_uint16 (pOutrow, (mng_uint16)((mng_get_uint16 (pOutrow ) + - mng_get_uint16 (pWorkrow )) & 0xFFFF)); - mng_put_uint16 (pOutrow+2, (mng_uint16)((mng_get_uint16 (pOutrow+2) + - mng_get_uint16 (pWorkrow+2)) & 0xFFFF)); - mng_put_uint16 (pOutrow+4, (mng_uint16)((mng_get_uint16 (pOutrow+4) + - mng_get_uint16 (pWorkrow+4)) & 0xFFFF)); - mng_put_uint16 (pOutrow+6, (mng_uint16)((mng_get_uint16 (pOutrow+6) + - mng_get_uint16 (pWorkrow+6)) & 0xFFFF)); - - pOutrow += 8; - pWorkrow += 8; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA16_RGBA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_delta_rgba16_rgb16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA16_RGB16, MNG_LC_START); -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORREPLACE) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - mng_put_uint16 (pOutrow, mng_get_uint16 (pWorkrow )); - mng_put_uint16 (pOutrow+2, mng_get_uint16 (pWorkrow+2)); - mng_put_uint16 (pOutrow+4, mng_get_uint16 (pWorkrow+4)); - - pOutrow += 8; - pWorkrow += 6; - } - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORADD) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - mng_put_uint16 (pOutrow, (mng_uint16)((mng_get_uint16 (pOutrow ) + - mng_get_uint16 (pWorkrow )) & 0xFFFF)); - mng_put_uint16 (pOutrow+2, (mng_uint16)((mng_get_uint16 (pOutrow+2) + - mng_get_uint16 (pWorkrow+2)) & 0xFFFF)); - mng_put_uint16 (pOutrow+4, (mng_uint16)((mng_get_uint16 (pOutrow+4) + - mng_get_uint16 (pWorkrow+4)) & 0xFFFF)); - - pOutrow += 8; - pWorkrow += 6; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA16_RGB16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_delta_rgba16_a16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA16_A16, MNG_LC_START); -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAREPLACE) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - mng_put_uint16 (pOutrow+6, mng_get_uint16 (pWorkrow)); - - pOutrow += 8; - pWorkrow += 2; - } - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAADD) - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - mng_put_uint16 (pOutrow+6, (mng_uint16)((mng_get_uint16 (pOutrow+6) + - mng_get_uint16 (pWorkrow)) & 0xFFFF)); - - pOutrow += 8; - pWorkrow += 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA16_A16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif /* MNG_NO_DELTA_PNG */ - -/* ************************************************************************** */ -/* * * */ -/* * Delta-image row routines - scale the delta to bitdepth of target * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_scale_g1_g2 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G1_G2, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pWorkrow = (mng_uint8)(*pWorkrow << 1); - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G1_G2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_scale_g1_g4 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G1_G4, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pWorkrow = (mng_uint8)(*pWorkrow << 3); - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G1_G4, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_scale_g1_g8 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G1_G8, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pWorkrow = (mng_uint8)(*pWorkrow << 7); - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G1_G8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_scale_g1_g16 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_uint8p pOutrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G1_G16, MNG_LC_START); -#endif - - pWorkrow = pWorkrow + (pData->iRowsamples - 1); - pOutrow = pOutrow + ((pData->iRowsamples - 1) << 1); -/* pWorkrow = (mng_uint8p)((mng_uint32)pWorkrow + pData->iRowsamples - 1); */ -/* pOutrow = (mng_uint8p)((mng_uint32)pOutrow + ((pData->iRowsamples - 1) << 1)); */ - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *(pOutrow+1) = 0; - *pOutrow = (mng_uint8)(*pWorkrow << 7); - - pWorkrow--; - pOutrow -= 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G1_G16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_scale_g2_g4 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G2_G4, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pWorkrow = (mng_uint8)(*pWorkrow << 2); - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G2_G4, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_scale_g2_g8 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G2_G8, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pWorkrow = (mng_uint8)(*pWorkrow << 6); - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G2_G8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_scale_g2_g16 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_uint8p pOutrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G2_G16, MNG_LC_START); -#endif - - pWorkrow = pWorkrow + (pData->iRowsamples - 1); - pOutrow = pOutrow + ((pData->iRowsamples - 1) << 1); -/* pWorkrow = (mng_uint8p)((mng_uint32)pWorkrow + pData->iRowsamples - 1); */ -/* pOutrow = (mng_uint8p)((mng_uint32)pOutrow + ((pData->iRowsamples - 1) << 1)); */ - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *(pOutrow+1) = 0; - *pOutrow = (mng_uint8)(*pWorkrow << 6); - - pWorkrow--; - pOutrow -= 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G2_G16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_scale_g4_g8 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G4_G8, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pWorkrow = (mng_uint8)(*pWorkrow << 4); - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G4_G8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_scale_g4_g16 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_uint8p pOutrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G4_G16, MNG_LC_START); -#endif - - pWorkrow = pWorkrow + (pData->iRowsamples - 1); - pOutrow = pOutrow + ((pData->iRowsamples - 1) << 1); -/* pWorkrow = (mng_uint8p)((mng_uint32)pWorkrow + pData->iRowsamples - 1); */ -/* pOutrow = (mng_uint8p)((mng_uint32)pOutrow + ((pData->iRowsamples - 1) << 1)); */ - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *(pOutrow+1) = 0; - *pOutrow = (mng_uint8)(*pWorkrow << 4); - - pWorkrow--; - pOutrow -= 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G4_G16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_scale_g8_g16 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_uint8p pOutrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G8_G16, MNG_LC_START); -#endif - - pWorkrow = pWorkrow + (pData->iRowsamples - 1); - pOutrow = pOutrow + ((pData->iRowsamples - 1) << 1); -/* pWorkrow = (mng_uint8p)((mng_uint32)pWorkrow + pData->iRowsamples - 1); */ -/* pOutrow = (mng_uint8p)((mng_uint32)pOutrow + ((pData->iRowsamples - 1) << 1)); */ - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *(pOutrow+1) = 0; - *pOutrow = *pWorkrow; - - pWorkrow--; - pOutrow -= 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G8_G16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_scale_ga8_ga16 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_uint8p pOutrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_GA8_GA16, MNG_LC_START); -#endif - - pWorkrow = pWorkrow + ((pData->iRowsamples - 1) << 1); - pOutrow = pOutrow + ((pData->iRowsamples - 1) << 2); -/* pWorkrow = (mng_uint8p)((mng_uint32)pWorkrow + ((pData->iRowsamples - 1) << 1)); */ -/* pOutrow = (mng_uint8p)((mng_uint32)pOutrow + ((pData->iRowsamples - 1) << 2)); */ - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *(pOutrow+3) = 0; - *(pOutrow+2) = *(pWorkrow+1); - *(pOutrow+1) = 0; - *pOutrow = *pWorkrow; - - pWorkrow -= 2; - pOutrow -= 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_GA8_GA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_scale_rgb8_rgb16 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_uint8p pOutrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_RGB8_RGB16, MNG_LC_START); -#endif - - pWorkrow = pWorkrow + (3 * (pData->iRowsamples - 1)); - pOutrow = pOutrow + (6 * (pData->iRowsamples - 1)); -/* pWorkrow = (mng_uint8p)((mng_uint32)pWorkrow + 3 * (pData->iRowsamples - 1)); */ -/* pOutrow = (mng_uint8p)((mng_uint32)pOutrow + 6 * (pData->iRowsamples - 1)); */ - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *(pOutrow+5) = 0; - *(pOutrow+4) = *(pWorkrow+2); - *(pOutrow+3) = 0; - *(pOutrow+2) = *(pWorkrow+1); - *(pOutrow+1) = 0; - *pOutrow = *pWorkrow; - - pWorkrow -= 3; - pOutrow -= 6; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_RGB8_RGB16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_scale_rgba8_rgba16 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_uint8p pOutrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_RGBA8_RGBA16, MNG_LC_START); -#endif - - pWorkrow = pWorkrow + ((pData->iRowsamples - 1) << 2); - pOutrow = pOutrow + ((pData->iRowsamples - 1) << 3); -/* pWorkrow = (mng_uint8p)((mng_uint32)pWorkrow + ((pData->iRowsamples - 1) << 2)); */ -/* pOutrow = (mng_uint8p)((mng_uint32)pOutrow + ((pData->iRowsamples - 1) << 3)); */ - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *(pOutrow+7) = 0; - *(pOutrow+6) = *(pWorkrow+3); - *(pOutrow+5) = 0; - *(pOutrow+4) = *(pWorkrow+2); - *(pOutrow+3) = 0; - *(pOutrow+2) = *(pWorkrow+1); - *(pOutrow+1) = 0; - *pOutrow = *pWorkrow; - - pWorkrow -= 4; - pOutrow -= 8; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_RGBA8_RGBA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_scale_g2_g1 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G2_G1, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pWorkrow = (mng_uint8)(*pWorkrow >> 1); - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G2_G1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_scale_g4_g1 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G4_G1, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pWorkrow = (mng_uint8)(*pWorkrow >> 3); - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G4_G1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_scale_g8_g1 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G8_G1, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pWorkrow = (mng_uint8)(*pWorkrow >> 7); - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G8_G1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_scale_g16_g1 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_uint8p pOutrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G16_G1, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = (mng_uint8)(mng_get_uint16 (pWorkrow) >> 15); - pOutrow++; - pWorkrow += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G16_G1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_scale_g4_g2 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G4_G2, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pWorkrow = (mng_uint8)(*pWorkrow >> 2); - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G4_G2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_scale_g8_g2 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G8_G2, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pWorkrow = (mng_uint8)(*pWorkrow >> 6); - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G8_G2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_scale_g16_g2 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_uint8p pOutrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G16_G2, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = (mng_uint8)(mng_get_uint16 (pWorkrow) >> 14); - pOutrow++; - pWorkrow += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G16_G2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_scale_g8_g4 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G8_G4, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pWorkrow = (mng_uint8)(*pWorkrow >> 4); - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G8_G4, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_scale_g16_g4 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_uint8p pOutrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G16_G4, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = (mng_uint8)(mng_get_uint16 (pWorkrow) >> 12); - pOutrow++; - pWorkrow += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G16_G4, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif /* NO_1_2_4BIT_SUPPORT */ - -/* ************************************************************************** */ - -mng_retcode mng_scale_g16_g8 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_uint8p pOutrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G16_G8, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = (mng_uint8)(mng_get_uint16 (pWorkrow) >> 8); - pOutrow++; - pWorkrow += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_G16_G8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_scale_ga16_ga8 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_uint8p pOutrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_GA16_GA8, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = (mng_uint8)(mng_get_uint16 (pWorkrow) >> 8); - pOutrow++; - pWorkrow += 2; - *pOutrow = (mng_uint8)(mng_get_uint16 (pWorkrow) >> 8); - pOutrow++; - pWorkrow += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_GA16_GA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_scale_rgb16_rgb8 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_uint8p pOutrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_RGB16_RGB8, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = (mng_uint8)(mng_get_uint16 (pWorkrow) >> 8); - pOutrow++; - pWorkrow += 2; - *pOutrow = (mng_uint8)(mng_get_uint16 (pWorkrow) >> 8); - pOutrow++; - pWorkrow += 2; - *pOutrow = (mng_uint8)(mng_get_uint16 (pWorkrow) >> 8); - pOutrow++; - pWorkrow += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_RGB16_RGB8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_scale_rgba16_rgba8 (mng_datap pData) -{ - mng_uint8p pWorkrow = pData->pRGBArow; - mng_uint8p pOutrow = pData->pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_RGBA16_RGBA8, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pOutrow = (mng_uint8)(mng_get_uint16 (pWorkrow) >> 8); - pOutrow++; - pWorkrow += 2; - *pOutrow = (mng_uint8)(mng_get_uint16 (pWorkrow) >> 8); - pOutrow++; - pWorkrow += 2; - *pOutrow = (mng_uint8)(mng_get_uint16 (pWorkrow) >> 8); - pOutrow++; - pWorkrow += 2; - *pOutrow = (mng_uint8)(mng_get_uint16 (pWorkrow) >> 8); - pOutrow++; - pWorkrow += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SCALE_RGBA16_RGBA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Delta-image bit routines - promote bit_depth * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_uint8 mng_promote_replicate_1_2 (mng_uint8 iB) -{ - return (mng_uint8)((iB << 1) | iB); -} - -/* ************************************************************************** */ - -mng_uint8 mng_promote_replicate_1_4 (mng_uint8 iB) -{ - iB = (mng_uint8)((iB << 1) + iB); - return (mng_uint8)((iB << 2) + iB); -} - -/* ************************************************************************** */ - -mng_uint8 mng_promote_replicate_1_8 (mng_uint8 iB) -{ - iB = (mng_uint8)((iB << 1) + iB); - iB = (mng_uint8)((iB << 2) + iB); - return (mng_uint8)((iB << 4) + iB); -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_uint16 mng_promote_replicate_1_16 (mng_uint8 iB) -{ - iB = (mng_uint8)((iB << 1) + iB); - iB = (mng_uint8)((iB << 2) + iB); - iB = (mng_uint8)((iB << 4) + iB); - return (mng_uint16)(((mng_uint16)iB << 8) + (mng_uint16)iB); -} -#endif - -/* ************************************************************************** */ - -mng_uint8 mng_promote_replicate_2_4 (mng_uint8 iB) -{ - return (mng_uint8)((iB << 2) + iB); -} - -/* ************************************************************************** */ - -mng_uint8 mng_promote_replicate_2_8 (mng_uint8 iB) -{ - iB = (mng_uint8)((iB << 2) + iB); - return (mng_uint8)((iB << 4) + iB); -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_uint16 mng_promote_replicate_2_16 (mng_uint8 iB) -{ - iB = (mng_uint8)((iB << 2) + iB); - iB = (mng_uint8)((iB << 4) + iB); - return (mng_uint16)(((mng_uint16)iB << 8) + (mng_uint16)iB); -} -#endif - -/* ************************************************************************** */ - -mng_uint8 mng_promote_replicate_4_8 (mng_uint8 iB) -{ - return (mng_uint8)((iB << 4) + iB); -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_uint16 mng_promote_replicate_4_16 (mng_uint8 iB) -{ - iB = (mng_uint8)((iB << 4) + iB); - return (mng_uint16)(((mng_uint16)iB << 8) + (mng_uint16)iB); -} -#endif -#endif /* NO_1_2_4BIT_SUPPORT */ - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_uint16 mng_promote_replicate_8_16 (mng_uint8 iB) -{ - return (mng_uint16)(((mng_uint16)iB << 8) + (mng_uint16)iB); -} -#endif - -/* ************************************************************************** */ - -#if !defined(MNG_NO_DELTA_PNG) -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_uint8 mng_promote_zerofill_1_2 (mng_uint8 iB) -{ - return (mng_uint8)(iB << 1); -} - -/* ************************************************************************** */ - -mng_uint8 mng_promote_zerofill_1_4 (mng_uint8 iB) -{ - return (mng_uint8)(iB << 3); -} - -/* ************************************************************************** */ - -mng_uint8 mng_promote_zerofill_1_8 (mng_uint8 iB) -{ - return (mng_uint8)(iB << 7); -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_uint16 mng_promote_zerofill_1_16 (mng_uint8 iB) -{ - return (mng_uint16)((mng_uint16)iB << 15); -} -#endif - -/* ************************************************************************** */ - -mng_uint8 mng_promote_zerofill_2_4 (mng_uint8 iB) -{ - return (mng_uint8)(iB << 2); -} - -/* ************************************************************************** */ - -mng_uint8 mng_promote_zerofill_2_8 (mng_uint8 iB) -{ - return (mng_uint8)(iB << 6); -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_uint16 mng_promote_zerofill_2_16 (mng_uint8 iB) -{ - return (mng_uint16)((mng_uint16)iB << 14); -} -#endif - -/* ************************************************************************** */ - -mng_uint8 mng_promote_zerofill_4_8 (mng_uint8 iB) -{ - return (mng_uint8)(iB << 4); -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_uint16 mng_promote_zerofill_4_16 (mng_uint8 iB) -{ - return (mng_uint16)((mng_uint16)iB << 12); -} -#endif -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_uint16 mng_promote_zerofill_8_16 (mng_uint8 iB) -{ - return (mng_uint16)((mng_uint16)iB << 8); -} -#endif -#endif /* MNG_NO_DELTA_PNG */ - -/* ************************************************************************** */ -/* * * */ -/* * Delta-image row routines - promote color_type * */ -/* * * */ -/* ************************************************************************** */ - -#if !defined(MNG_NO_DELTA_PNG) || !defined(MNG_SKIPCHUNK_PAST) || !defined(MNG_SKIPCHUNK_MAGN) -mng_retcode mng_promote_g8_g8 (mng_datap pData) -{ - mng_uint8p pSrcline = (mng_uint8p)pData->pPromSrc; - mng_uint8p pDstline = (mng_uint8p)pData->pPromDst; - mng_uint32 iX; - mng_uint8 iB; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_G8_G8, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPromWidth; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPromWidth; iX++) -#endif - { - iB = *pSrcline; - if (pData->fPromBitdepth) /* bitdepth promoted ? */ - iB = ((mng_bitdepth_8)pData->fPromBitdepth) (iB); - *pDstline = iB; - - pSrcline++; - pDstline++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_G8_G8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_promote_g8_g16 (mng_datap pData) -{ - mng_uint8p pSrcline = (mng_uint8p)pData->pPromSrc; - mng_uint8p pDstline = (mng_uint8p)pData->pPromDst; - mng_uint32 iX; - mng_uint16 iW; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_G8_G16, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPromWidth; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPromWidth; iX++) -#endif - { - iW = ((mng_bitdepth_16)pData->fPromBitdepth) (*pSrcline); - - *pDstline = (mng_uint8)(iW >> 8); - *(pDstline+1) = (mng_uint8)(iW && 0xFF); - - pSrcline++; - pDstline += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_G8_G16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_promote_g16_g16 (mng_datap pData) -{ - mng_uint16p pSrcline = (mng_uint16p)pData->pPromSrc; - mng_uint16p pDstline = (mng_uint16p)pData->pPromDst; - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_G16_G16, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPromWidth; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPromWidth; iX++) -#endif - { - *pDstline = *pSrcline; - pSrcline++; - pDstline++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_G16_G16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_promote_g8_ga8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pPromBuf; - mng_uint8p pSrcline = (mng_uint8p)pData->pPromSrc; - mng_uint8p pDstline = (mng_uint8p)pData->pPromDst; - mng_uint32 iX; - mng_uint8 iB; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_G8_GA8, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPromWidth; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPromWidth; iX++) -#endif - { - iB = *pSrcline; - /* no cheap transparency ? */ - if ((!pBuf->bHasTRNS) || ((mng_uint16)iB != pBuf->iTRNSgray)) - *(pDstline+1) = 0xFF; - - if (pData->fPromBitdepth) /* bitdepth promoted ? */ - iB = ((mng_bitdepth_8)pData->fPromBitdepth) (iB); - - *pDstline = iB; - - pSrcline++; - pDstline += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_G8_GA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_promote_g8_ga16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pPromBuf; - mng_uint8p pSrcline = (mng_uint8p)pData->pPromSrc; - mng_uint8p pDstline = (mng_uint8p)pData->pPromDst; - mng_uint32 iX; - mng_uint8 iB; - mng_uint16 iW; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_G8_GA16, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPromWidth; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPromWidth; iX++) -#endif - { - iB = *pSrcline; - /* no cheap transparency ? */ - if ((!pBuf->bHasTRNS) || ((mng_uint16)iB != pBuf->iTRNSgray)) - { - *(pDstline+2) = 0xFF; - *(pDstline+3) = 0xFF; - } - - iW = ((mng_bitdepth_16)pData->fPromBitdepth) (iB); - - *pDstline = (mng_uint8)(iW >> 8); - *(pDstline+1) = (mng_uint8)(iW && 0xFF); - - pSrcline++; - pDstline += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_G8_GA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_promote_g16_ga16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pPromBuf; - mng_uint16p pSrcline = (mng_uint16p)pData->pPromSrc; - mng_uint16p pDstline = (mng_uint16p)pData->pPromDst; - mng_uint32 iX; - mng_uint16 iW; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_G16_GA16, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPromWidth; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPromWidth; iX++) -#endif - { - iW = *pSrcline; - /* no cheap transparency ? */ - if ((!pBuf->bHasTRNS) || ((mng_uint16)iW != pBuf->iTRNSgray)) - *(pDstline+1) = 0xFFFF; - - *pDstline = iW; - - pSrcline++; - pDstline += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_G16_GA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_promote_g8_rgb8 (mng_datap pData) -{ - mng_uint8p pSrcline = (mng_uint8p)pData->pPromSrc; - mng_uint8p pDstline = (mng_uint8p)pData->pPromDst; - mng_uint32 iX; - mng_uint8 iB; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_G8_RGB8, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPromWidth; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPromWidth; iX++) -#endif - { - iB = *pSrcline; - - if (pData->fPromBitdepth) /* bitdepth promoted ? */ - iB = ((mng_bitdepth_8)pData->fPromBitdepth) (iB); - - *pDstline = iB; - *(pDstline+1) = iB; - *(pDstline+2) = iB; - - pSrcline++; - pDstline += 3; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_G8_RGB8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_promote_g8_rgb16 (mng_datap pData) -{ - mng_uint8p pSrcline = (mng_uint8p)pData->pPromSrc; - mng_uint8p pDstline = (mng_uint8p)pData->pPromDst; - mng_uint32 iX; - mng_uint8 iB; - mng_uint16 iW; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_G8_RGB16, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPromWidth; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPromWidth; iX++) -#endif - { - iB = *pSrcline; - iW = ((mng_bitdepth_16)pData->fPromBitdepth) (iB); - - iB = (mng_uint8)(iW >> 8); - *pDstline = iB; - *(pDstline+2) = iB; - *(pDstline+4) = iB; - iB = (mng_uint8)(iW && 0xFF); - *(pDstline+1) = iB; - *(pDstline+3) = iB; - *(pDstline+5) = iB; - - pSrcline++; - pDstline += 6; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_G8_RGB16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_promote_g16_rgb16 (mng_datap pData) -{ - mng_uint16p pSrcline = (mng_uint16p)pData->pPromSrc; - mng_uint16p pDstline = (mng_uint16p)pData->pPromDst; - mng_uint32 iX; - mng_uint16 iW; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_G16_RGB16, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPromWidth; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPromWidth; iX++) -#endif - { - iW = *pSrcline; - - *pDstline = iW; - *(pDstline+1) = iW; - *(pDstline+2) = iW; - - pSrcline++; - pDstline += 3; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_G16_RGB16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_promote_g8_rgba8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pPromBuf; - mng_uint8p pSrcline = (mng_uint8p)pData->pPromSrc; - mng_uint8p pDstline = (mng_uint8p)pData->pPromDst; - mng_uint32 iX; - mng_uint8 iB; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_G8_RGBA8, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPromWidth; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPromWidth; iX++) -#endif - { - iB = *pSrcline; - /* no cheap transparency ? */ - if ((!pBuf->bHasTRNS) || ((mng_uint16)iB != pBuf->iTRNSgray)) - *(pDstline+3) = 0xFF; - - if (pData->fPromBitdepth) /* bitdepth promoted ? */ - iB = ((mng_bitdepth_8)pData->fPromBitdepth) (iB); - - *pDstline = iB; - *(pDstline+1) = iB; - *(pDstline+2) = iB; - - pSrcline++; - pDstline += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_G8_RGBA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_promote_g8_rgba16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pPromBuf; - mng_uint8p pSrcline = (mng_uint8p)pData->pPromSrc; - mng_uint8p pDstline = (mng_uint8p)pData->pPromDst; - mng_uint32 iX; - mng_uint8 iB; - mng_uint16 iW; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_G8_RGBA16, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPromWidth; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPromWidth; iX++) -#endif - { - iB = *pSrcline; - /* no cheap transparency ? */ - if ((!pBuf->bHasTRNS) || ((mng_uint16)iB != pBuf->iTRNSgray)) - { - *(pDstline+6) = 0xFF; - *(pDstline+7) = 0xFF; - } - - iW = ((mng_bitdepth_16)pData->fPromBitdepth) (iB); - - iB = (mng_uint8)(iW >> 8); - *pDstline = iB; - *(pDstline+2) = iB; - *(pDstline+4) = iB; - iB = (mng_uint8)(iW && 0xFF); - *(pDstline+1) = iB; - *(pDstline+3) = iB; - *(pDstline+5) = iB;; - - pSrcline++; - pDstline += 8; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_G8_RGBA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_promote_g16_rgba16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pPromBuf; - mng_uint16p pSrcline = (mng_uint16p)pData->pPromSrc; - mng_uint16p pDstline = (mng_uint16p)pData->pPromDst; - mng_uint32 iX; - mng_uint16 iW; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_G16_RGBA16, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPromWidth; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPromWidth; iX++) -#endif - { - iW = *pSrcline; - /* no cheap transparency ? */ - if ((!pBuf->bHasTRNS) || (iW != pBuf->iTRNSgray)) - *(pDstline+3) = 0xFFFF; - - *pDstline = iW; - *(pDstline+1) = iW; - *(pDstline+2) = iW; - - pSrcline++; - pDstline += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_G16_RGBA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_promote_ga8_ga16 (mng_datap pData) -{ - mng_uint8p pSrcline = (mng_uint8p)pData->pPromSrc; - mng_uint8p pDstline = (mng_uint8p)pData->pPromDst; - mng_uint32 iX; - mng_uint16 iW; - mng_uint16 iA; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_GA8_GA16, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPromWidth; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPromWidth; iX++) -#endif - { - iW = ((mng_bitdepth_16)pData->fPromBitdepth) (*pSrcline); - iA = ((mng_bitdepth_16)pData->fPromBitdepth) (*(pSrcline+1)); - - *pDstline = (mng_uint8)(iW >> 8); - *(pDstline+1) = (mng_uint8)(iW && 0xFF); - *(pDstline+2) = (mng_uint8)(iA >> 8); - *(pDstline+3) = (mng_uint8)(iA && 0xFF); - - pSrcline += 2; - pDstline += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_GA8_GA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_promote_ga8_rgba8 (mng_datap pData) -{ - mng_uint8p pSrcline = (mng_uint8p)pData->pPromSrc; - mng_uint8p pDstline = (mng_uint8p)pData->pPromDst; - mng_uint32 iX; - mng_uint8 iB; - mng_uint8 iA; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_GA8_RGBA8, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPromWidth; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPromWidth; iX++) -#endif - { - iB = *pSrcline; - iA = *(pSrcline+1); - - *pDstline = iB; - *(pDstline+1) = iB; - *(pDstline+2) = iB; - *(pDstline+3) = iA; - - pSrcline += 2; - pDstline += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_GA8_RGBA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_promote_ga8_rgba16 (mng_datap pData) -{ - mng_uint8p pSrcline = (mng_uint8p)pData->pPromSrc; - mng_uint8p pDstline = (mng_uint8p)pData->pPromDst; - mng_uint32 iX; - mng_uint8 iB; - mng_uint16 iW; - mng_uint16 iA; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_GA8_RGBA16, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPromWidth; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPromWidth; iX++) -#endif - { - iW = ((mng_bitdepth_16)pData->fPromBitdepth) (*pSrcline); - iA = ((mng_bitdepth_16)pData->fPromBitdepth) (*(pSrcline+1)); - - iB = (mng_uint8)(iW >> 8); - *pDstline = iB; - *(pDstline+2) = iB; - *(pDstline+4) = iB; - iB = (mng_uint8)(iW && 0xFF); - *(pDstline+1) = iB; - *(pDstline+3) = iB; - *(pDstline+5) = iB; - *(pDstline+6) = (mng_uint8)(iA >> 8); - *(pDstline+7) = (mng_uint8)(iA && 0xFF); - - pSrcline += 2; - pDstline += 8; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_GA8_RGBA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_promote_ga16_rgba16 (mng_datap pData) -{ - mng_uint16p pSrcline = (mng_uint16p)pData->pPromSrc; - mng_uint16p pDstline = (mng_uint16p)pData->pPromDst; - mng_uint32 iX; - mng_uint16 iW; - mng_uint16 iA; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_GA16_RGBA16, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPromWidth; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPromWidth; iX++) -#endif - { - iW = *pSrcline; - iA = *(pSrcline+1); - - *pDstline = iW; - *(pDstline+1) = iW; - *(pDstline+2) = iW; - *(pDstline+3) = iA; - - pSrcline += 2; - pDstline += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_GA16_RGBA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_promote_rgb8_rgb16 (mng_datap pData) -{ - mng_uint8p pSrcline = (mng_uint8p)pData->pPromSrc; - mng_uint8p pDstline = (mng_uint8p)pData->pPromDst; - mng_uint32 iX; - mng_uint16 iR; - mng_uint16 iG; - mng_uint16 iB; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_RGB8_RGB16, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPromWidth; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPromWidth; iX++) -#endif - { - iR = ((mng_bitdepth_16)pData->fPromBitdepth) (*pSrcline); - iG = ((mng_bitdepth_16)pData->fPromBitdepth) (*(pSrcline+1)); - iB = ((mng_bitdepth_16)pData->fPromBitdepth) (*(pSrcline+2)); - - *pDstline = (mng_uint8)(iR >> 8); - *(pDstline+1) = (mng_uint8)(iR && 0xFF); - *(pDstline+2) = (mng_uint8)(iG >> 8); - *(pDstline+3) = (mng_uint8)(iG && 0xFF); - *(pDstline+4) = (mng_uint8)(iB >> 8); - *(pDstline+5) = (mng_uint8)(iB && 0xFF); - - pSrcline += 3; - pDstline += 6; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_RGB8_RGB16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_promote_rgb8_rgba8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pPromBuf; - mng_uint8p pSrcline = (mng_uint8p)pData->pPromSrc; - mng_uint8p pDstline = (mng_uint8p)pData->pPromDst; - mng_uint32 iX; - mng_uint8 iR; - mng_uint8 iG; - mng_uint8 iB; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_RGB8_RGBA8, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPromWidth; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPromWidth; iX++) -#endif - { - iR = *pSrcline; - iG = *(pSrcline+1); - iB = *(pSrcline+2); - /* no cheap transparency ? */ - if ((!pBuf->bHasTRNS) || ((mng_uint16)iR != pBuf->iTRNSred) || - ((mng_uint16)iG != pBuf->iTRNSgreen) || ((mng_uint16)iB != pBuf->iTRNSblue)) - *(pDstline+3) = 0xFF; - - *pDstline = iR; - *(pDstline+1) = iG; - *(pDstline+2) = iB; - - pSrcline += 3; - pDstline += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_RGB8_RGBA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_promote_rgb8_rgba16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pPromBuf; - mng_uint8p pSrcline = (mng_uint8p)pData->pPromSrc; - mng_uint8p pDstline = (mng_uint8p)pData->pPromDst; - mng_uint32 iX; - mng_uint8 iR; - mng_uint8 iG; - mng_uint8 iB; - mng_uint16 iRw; - mng_uint16 iGw; - mng_uint16 iBw; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_RGB8_RGBA16, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPromWidth; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPromWidth; iX++) -#endif - { - iR = *pSrcline; - iG = *(pSrcline+1); - iB = *(pSrcline+2); - /* no cheap transparency ? */ - if ((!pBuf->bHasTRNS) || ((mng_uint16)iR != pBuf->iTRNSred) || - ((mng_uint16)iG != pBuf->iTRNSgreen) || ((mng_uint16)iB != pBuf->iTRNSblue)) - { - *(pDstline+6) = 0xFF; - *(pDstline+7) = 0xFF; - } - - iRw = ((mng_bitdepth_16)pData->fPromBitdepth) (iR); - iGw = ((mng_bitdepth_16)pData->fPromBitdepth) (iG); - iBw = ((mng_bitdepth_16)pData->fPromBitdepth) (iB); - - *pDstline = (mng_uint8)(iRw >> 8); - *(pDstline+1) = (mng_uint8)(iRw && 0xFF); - *(pDstline+2) = (mng_uint8)(iGw >> 8); - *(pDstline+3) = (mng_uint8)(iGw && 0xFF); - *(pDstline+4) = (mng_uint8)(iBw >> 8); - *(pDstline+5) = (mng_uint8)(iBw && 0xFF); - - pSrcline += 3; - pDstline += 8; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_RGB8_RGBA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_promote_rgb16_rgba16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pPromBuf; - mng_uint16p pSrcline = (mng_uint16p)pData->pPromSrc; - mng_uint16p pDstline = (mng_uint16p)pData->pPromDst; - mng_uint32 iX; - mng_uint16 iR; - mng_uint16 iG; - mng_uint16 iB; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_RGB16_RGBA16, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPromWidth; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPromWidth; iX++) -#endif - { - iR = *pSrcline; - iG = *(pSrcline+1); - iB = *(pSrcline+2); - /* no cheap transparency ? */ - if ((!pBuf->bHasTRNS) || (iR != pBuf->iTRNSred) || - (iG != pBuf->iTRNSgreen) || (iB != pBuf->iTRNSblue)) - *(pDstline+3) = 0xFFFF; - - *pDstline = iR; - *(pDstline+1) = iG; - *(pDstline+2) = iB; - - pSrcline += 3; - pDstline += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_RGB16_RGBA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_promote_idx8_rgb8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pPromBuf; - mng_uint8p pSrcline = (mng_uint8p)pData->pPromSrc; - mng_uint8p pDstline = (mng_uint8p)pData->pPromDst; - mng_uint32 iX; - mng_uint8 iB; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_IDX8_RGB8, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPromWidth; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPromWidth; iX++) -#endif - { - iB = *pSrcline; - - if ((mng_uint32)iB < pBuf->iPLTEcount) - { - *pDstline = pBuf->aPLTEentries [iB].iRed; - *(pDstline+1) = pBuf->aPLTEentries [iB].iGreen; - *(pDstline+2) = pBuf->aPLTEentries [iB].iBlue; - } - - pSrcline++; - pDstline += 3; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_IDX8_RGB8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_promote_idx8_rgb16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pPromBuf; - mng_uint8p pSrcline = (mng_uint8p)pData->pPromSrc; - mng_uint8p pDstline = (mng_uint8p)pData->pPromDst; - mng_uint32 iX; - mng_uint8 iN; - mng_uint16 iR; - mng_uint16 iG; - mng_uint16 iB; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_IDX8_RGB16, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPromWidth; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPromWidth; iX++) -#endif - { - iN = *pSrcline; - - if ((mng_uint32)iN < pBuf->iPLTEcount) - { - iR = ((mng_bitdepth_16)pData->fPromBitdepth) (pBuf->aPLTEentries [iN].iRed); - iG = ((mng_bitdepth_16)pData->fPromBitdepth) (pBuf->aPLTEentries [iN].iGreen); - iB = ((mng_bitdepth_16)pData->fPromBitdepth) (pBuf->aPLTEentries [iN].iBlue); - *pDstline = (mng_uint8)(iR >> 8); - *(pDstline+1) = (mng_uint8)(iR && 0xFF); - *(pDstline+2) = (mng_uint8)(iG >> 8); - *(pDstline+3) = (mng_uint8)(iG && 0xFF); - *(pDstline+4) = (mng_uint8)(iB >> 8); - *(pDstline+5) = (mng_uint8)(iB && 0xFF); - } - - pSrcline++; - pDstline += 6; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_IDX8_RGB16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_promote_idx8_rgba8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pPromBuf; - mng_uint8p pSrcline = (mng_uint8p)pData->pPromSrc; - mng_uint8p pDstline = (mng_uint8p)pData->pPromDst; - mng_uint32 iX; - mng_uint8 iB; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_IDX8_RGBA8, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPromWidth; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPromWidth; iX++) -#endif - { - iB = *pSrcline; - - if ((mng_uint32)iB < pBuf->iPLTEcount) - { - *pDstline = pBuf->aPLTEentries [iB].iRed; - *(pDstline+1) = pBuf->aPLTEentries [iB].iGreen; - *(pDstline+2) = pBuf->aPLTEentries [iB].iBlue; - - if ((pBuf->bHasTRNS) && ((mng_uint32)iB < pBuf->iTRNScount)) - *(pDstline+3) = pBuf->aTRNSentries [iB]; - else - *(pDstline+3) = 0xFF; - } - - pSrcline++; - pDstline += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_IDX8_RGBA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_promote_idx8_rgba16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pPromBuf; - mng_uint8p pSrcline = (mng_uint8p)pData->pPromSrc; - mng_uint8p pDstline = (mng_uint8p)pData->pPromDst; - mng_uint32 iX; - mng_uint8 iN; - mng_uint16 iR; - mng_uint16 iG; - mng_uint16 iB; - mng_uint16 iA; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_IDX8_RGBA16, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPromWidth; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPromWidth; iX++) -#endif - { - iN = *pSrcline; - - if ((mng_uint32)iN < pBuf->iPLTEcount) - { - iR = ((mng_bitdepth_16)pData->fPromBitdepth) (pBuf->aPLTEentries [iN].iRed); - iG = ((mng_bitdepth_16)pData->fPromBitdepth) (pBuf->aPLTEentries [iN].iGreen); - iB = ((mng_bitdepth_16)pData->fPromBitdepth) (pBuf->aPLTEentries [iN].iBlue); - - if ((pBuf->bHasTRNS) && ((mng_uint32)iN < pBuf->iTRNScount)) - iA = ((mng_bitdepth_16)pData->fPromBitdepth) (pBuf->aTRNSentries [iN]); - else - iA = 0xFFFF; - - *pDstline = (mng_uint8)(iR >> 8); - *(pDstline+1) = (mng_uint8)(iR && 0xFF); - *(pDstline+2) = (mng_uint8)(iG >> 8); - *(pDstline+3) = (mng_uint8)(iG && 0xFF); - *(pDstline+4) = (mng_uint8)(iB >> 8); - *(pDstline+5) = (mng_uint8)(iB && 0xFF); - *(pDstline+6) = (mng_uint8)(iA >> 8); - *(pDstline+7) = (mng_uint8)(iA && 0xFF); - } - - pSrcline++; - pDstline += 8; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_IDX8_RGBA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_promote_rgba8_rgba16 (mng_datap pData) -{ - mng_uint8p pSrcline = (mng_uint8p)pData->pPromSrc; - mng_uint8p pDstline = (mng_uint8p)pData->pPromDst; - mng_uint32 iX; - mng_uint16 iR; - mng_uint16 iG; - mng_uint16 iB; - mng_uint16 iA; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_RGBA8_RGBA16, MNG_LC_START); -#endif - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPromWidth; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPromWidth; iX++) -#endif - { - iR = ((mng_bitdepth_16)pData->fPromBitdepth) (*pSrcline); - iG = ((mng_bitdepth_16)pData->fPromBitdepth) (*(pSrcline+1)); - iB = ((mng_bitdepth_16)pData->fPromBitdepth) (*(pSrcline+2)); - iA = ((mng_bitdepth_16)pData->fPromBitdepth) (*(pSrcline+3)); - - *pDstline = (mng_uint8)(iR >> 8); - *(pDstline+1) = (mng_uint8)(iR && 0xFF); - *(pDstline+2) = (mng_uint8)(iG >> 8); - *(pDstline+3) = (mng_uint8)(iG && 0xFF); - *(pDstline+4) = (mng_uint8)(iB >> 8); - *(pDstline+5) = (mng_uint8)(iB && 0xFF); - *(pDstline+6) = (mng_uint8)(iA >> 8); - *(pDstline+7) = (mng_uint8)(iA && 0xFF); - - pSrcline += 4; - pDstline += 8; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_RGBA8_RGBA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif /* !defined(MNG_NO_DELTA_PNG) || !defined(MNG_SKIPCHUNK_PAST) || !defined(MNG_SKIPCHUNK_MAGN) */ - -/* ************************************************************************** */ -/* * * */ -/* * Row processing routines - convert uncompressed data from zlib to * */ -/* * managable row-data which serves as input to the color-management * */ -/* * routines * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_process_g1 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G1, MNG_LC_START); -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - iM = 0; /* start at pixel 0 */ - iB = 0; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { - if (pBuf->iTRNSgray) /* white transparent ? */ - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* is it white ? */ - /* transparent ! */ - mng_put_uint32 (pRGBArow, 0x00000000); - else /* opaque black */ - mng_put_uint32 (pRGBArow, 0x000000FF); - - pRGBArow += 4; /* next pixel */ - iM >>= 1; - } - } - else /* black transparent */ - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* is it white ? */ - /* opaque white */ - mng_put_uint32 (pRGBArow, 0xFFFFFFFF); - else /* transparent */ - mng_put_uint32 (pRGBArow, 0x00000000); - - pRGBArow += 4; /* next pixel */ - iM >>= 1; - } - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else /* no transparency */ - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* is it white ? */ - /* opaque white */ - mng_put_uint32 (pRGBArow, 0xFFFFFFFF); - else /* opaque black */ - mng_put_uint32 (pRGBArow, 0x000000FF); - - pRGBArow += 4; /* next pixel */ - iM >>= 1; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_process_g2 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; -#ifdef MNG_OPTIMIZE_FOOTPRINT_SWITCH - const mng_uint32 level[4] = { 0x000000FF, 0x555555FF, - 0xAAAAAAFF, 0xFFFFFFFF}; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G2, MNG_LC_START); -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - /* determine gray level */ - iQ = (mng_uint8)((iB & iM) >> iS); - - if (iQ == pBuf->iTRNSgray) /* transparent ? */ - mng_put_uint32 (pRGBArow, 0x00000000); - else - { -#ifdef MNG_OPTIMIZE_FOOTPRINT_SWITCH - mng_put_uint32 (pRGBArow, level[iQ]); -#else - switch (iQ) /* determine the gray level */ - { - case 0x03 : { mng_put_uint32 (pRGBArow, 0xFFFFFFFF); break; } - case 0x02 : { mng_put_uint32 (pRGBArow, 0xAAAAAAFF); break; } - case 0x01 : { mng_put_uint32 (pRGBArow, 0x555555FF); break; } - default : { mng_put_uint32 (pRGBArow, 0x000000FF); } - } -#endif - } - - pRGBArow += 4; /* next pixel */ - iM >>= 2; - iS -= 2; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - -#ifdef MNG_OPTIMIZE_FOOTPRINT_SWITCH - mng_put_uint32 (pRGBArow, level[((iB & iM) >> iS)] ); -#else - switch ((iB & iM) >> iS) /* determine the gray level */ - { - case 0x03 : { mng_put_uint32 (pRGBArow, 0xFFFFFFFF); break; } - case 0x02 : { mng_put_uint32 (pRGBArow, 0xAAAAAAFF); break; } - case 0x01 : { mng_put_uint32 (pRGBArow, 0x555555FF); break; } - default : { mng_put_uint32 (pRGBArow, 0x000000FF); } - } -#endif - - pRGBArow += 4; /* next pixel */ - iM >>= 2; - iS -= 2; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_process_g4 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G4, MNG_LC_START); -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the gray level */ - iQ = (mng_uint8)((iB & iM) >> iS); - - if (iQ == pBuf->iTRNSgray) /* transparent ? */ - { - *pRGBArow = 0; /* put in intermediate row */ - *(pRGBArow+1) = 0; - *(pRGBArow+2) = 0; - *(pRGBArow+3) = 0; - } - else - { /* expand to 8-bit by replication */ - iQ = (mng_uint8)(iQ + (iQ << 4)); - - *pRGBArow = iQ; /* put in intermediate row */ - *(pRGBArow+1) = iQ; - *(pRGBArow+2) = iQ; - *(pRGBArow+3) = 0xFF; - } - - pRGBArow += 4; /* next pixel */ - iM >>= 4; - iS -= 4; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the gray level */ - iQ = (mng_uint8)((iB & iM) >> iS); - iQ = (mng_uint8)(iQ + (iQ << 4));/* expand to 8-bit by replication */ - - *pRGBArow = iQ; /* put in intermediate row */ - *(pRGBArow+1) = iQ; - *(pRGBArow+2) = iQ; - *(pRGBArow+3) = 0xFF; - - pRGBArow += 4; /* next pixel */ - iM >>= 4; - iS -= 4; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G4, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - -/* ************************************************************************** */ - -mng_retcode mng_process_g8 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iB; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G8, MNG_LC_START); -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - iB = *pWorkrow; /* get next input-byte */ - - if (iB == pBuf->iTRNSgray) /* transparent ? */ - { - *pRGBArow = 0; /* put in intermediate row */ - *(pRGBArow+1) = 0; - *(pRGBArow+2) = 0; - *(pRGBArow+3) = 0; - } - else - { - *pRGBArow = iB; /* put in intermediate row */ - *(pRGBArow+1) = iB; - *(pRGBArow+2) = iB; - *(pRGBArow+3) = 0xFF; - } - - pRGBArow += 4; /* next pixel */ - pWorkrow++; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - iB = *pWorkrow; /* get next input-byte */ - - *pRGBArow = iB; /* put in intermediate row */ - *(pRGBArow+1) = iB; - *(pRGBArow+2) = iB; - *(pRGBArow+3) = 0xFF; - - pRGBArow += 4; /* next pixel */ - pWorkrow++; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_process_g16 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint16 iW; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G16, MNG_LC_START); -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - iW = mng_get_uint16 (pWorkrow); /* get input */ - - if (iW == pBuf->iTRNSgray) /* transparent ? */ - { /* put in intermediate row */ - mng_put_uint16 (pRGBArow, 0); - mng_put_uint16 (pRGBArow+2, 0); - mng_put_uint16 (pRGBArow+4, 0); - mng_put_uint16 (pRGBArow+6, 0); - } - else - { /* put in intermediate row */ - mng_put_uint16 (pRGBArow, iW); - mng_put_uint16 (pRGBArow+2, iW); - mng_put_uint16 (pRGBArow+4, iW); - mng_put_uint16 (pRGBArow+6, 0xFFFF); - } - - pRGBArow += 8; /* next pixel */ - pWorkrow += 2; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - iW = mng_get_uint16 (pWorkrow); /* get input */ - - mng_put_uint16 (pRGBArow, iW); /* and put in intermediate row */ - mng_put_uint16 (pRGBArow+2, iW); - mng_put_uint16 (pRGBArow+4, iW); - mng_put_uint16 (pRGBArow+6, 0xFFFF); - - pRGBArow += 8; /* next pixel */ - pWorkrow += 2; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_process_rgb8 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iR, iG, iB; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RGB8, MNG_LC_START); -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - iR = *pWorkrow; /* get the RGB values */ - iG = *(pWorkrow+1); - iB = *(pWorkrow+2); - /* transparent ? */ - if ((iR == pBuf->iTRNSred) && (iG == pBuf->iTRNSgreen) && - (iB == pBuf->iTRNSblue)) - { - *pRGBArow = 0; /* this pixel is transparent ! */ - *(pRGBArow+1) = 0; - *(pRGBArow+2) = 0; - *(pRGBArow+3) = 0; - } - else - { - *pRGBArow = iR; /* copy the RGB values */ - *(pRGBArow+1) = iG; - *(pRGBArow+2) = iB; - *(pRGBArow+3) = 0xFF; /* this one isn't transparent */ - } - - pWorkrow += 3; /* next pixel */ - pRGBArow += 4; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pRGBArow = *pWorkrow; /* copy the RGB bytes */ - *(pRGBArow+1) = *(pWorkrow+1); - *(pRGBArow+2) = *(pWorkrow+2); - *(pRGBArow+3) = 0xFF; /* no alpha; so always fully opaque */ - - pWorkrow += 3; /* next pixel */ - pRGBArow += 4; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RGB8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_process_rgb16 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint16 iR, iG, iB; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RGB16, MNG_LC_START); -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - iR = mng_get_uint16 (pWorkrow); /* get the RGB values */ - iG = mng_get_uint16 (pWorkrow+2); - iB = mng_get_uint16 (pWorkrow+4); - /* transparent ? */ - if ((iR == pBuf->iTRNSred) && (iG == pBuf->iTRNSgreen) && - (iB == pBuf->iTRNSblue)) - { /* transparent then */ - mng_put_uint16 (pRGBArow, 0); - mng_put_uint16 (pRGBArow+2, 0); - mng_put_uint16 (pRGBArow+4, 0); - mng_put_uint16 (pRGBArow+6, 0); - } - else - { /* put in intermediate row */ - mng_put_uint16 (pRGBArow, iR); - mng_put_uint16 (pRGBArow+2, iG); - mng_put_uint16 (pRGBArow+4, iB); - mng_put_uint16 (pRGBArow+6, 0xFFFF); - } - - pWorkrow += 6; /* next pixel */ - pRGBArow += 8; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { /* copy the RGB values */ - mng_put_uint16 (pRGBArow, mng_get_uint16 (pWorkrow )); - mng_put_uint16 (pRGBArow+2, mng_get_uint16 (pWorkrow+2)); - mng_put_uint16 (pRGBArow+4, mng_get_uint16 (pWorkrow+4)); - mng_put_uint16 (pRGBArow+6, 0xFFFF); - - pWorkrow += 6; /* next pixel */ - pRGBArow += 8; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RGB16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_process_idx1 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_IDX1, MNG_LC_START); -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - iS = 7; - } - /* get the index */ - iQ = (mng_uint8)((iB & iM) >> iS); - /* index valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - *pRGBArow = pBuf->aPLTEentries [iQ].iRed; - *(pRGBArow+1) = pBuf->aPLTEentries [iQ].iGreen; - *(pRGBArow+2) = pBuf->aPLTEentries [iQ].iBlue; - /* transparency for this index ? */ - if ((mng_uint32)iQ < pBuf->iTRNScount) - *(pRGBArow+3) = pBuf->aTRNSentries [iQ]; - else - *(pRGBArow+3) = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR); - - pRGBArow += 4; /* next pixel */ - iM >>= 1; - iS -= 1; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - iS = 7; - } - /* get the index */ - iQ = (mng_uint8)((iB & iM) >> iS); - /* index valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - *pRGBArow = pBuf->aPLTEentries [iQ].iRed; - *(pRGBArow+1) = pBuf->aPLTEentries [iQ].iGreen; - *(pRGBArow+2) = pBuf->aPLTEentries [iQ].iBlue; - *(pRGBArow+3) = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR); - - pRGBArow += 4; /* next pixel */ - iM >>= 1; - iS -= 1; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_IDX1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_process_idx2 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_IDX2, MNG_LC_START); -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - /* get the index */ - iQ = (mng_uint8)((iB & iM) >> iS); - /* index valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - *pRGBArow = pBuf->aPLTEentries [iQ].iRed; - *(pRGBArow+1) = pBuf->aPLTEentries [iQ].iGreen; - *(pRGBArow+2) = pBuf->aPLTEentries [iQ].iBlue; - /* transparency for this index ? */ - if ((mng_uint32)iQ < pBuf->iTRNScount) - *(pRGBArow+3) = pBuf->aTRNSentries [iQ]; - else - *(pRGBArow+3) = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR); - - pRGBArow += 4; /* next pixel */ - iM >>= 2; - iS -= 2; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - /* get the index */ - iQ = (mng_uint8)((iB & iM) >> iS); - /* index valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - *pRGBArow = pBuf->aPLTEentries [iQ].iRed; - *(pRGBArow+1) = pBuf->aPLTEentries [iQ].iGreen; - *(pRGBArow+2) = pBuf->aPLTEentries [iQ].iBlue; - *(pRGBArow+3) = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR); - - pRGBArow += 4; /* next pixel */ - iM >>= 2; - iS -= 2; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_IDX2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_process_idx4 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_IDX4, MNG_LC_START); -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = pWorkrow [0]; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the index */ - iQ = (mng_uint8)((iB & iM) >> iS); - /* index valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - pRGBArow [0] = pBuf->aPLTEentries [iQ].iRed; - pRGBArow [1] = pBuf->aPLTEentries [iQ].iGreen; - pRGBArow [2] = pBuf->aPLTEentries [iQ].iBlue; - /* transparency for this index ? */ - if ((mng_uint32)iQ < pBuf->iTRNScount) - pRGBArow [3] = pBuf->aTRNSentries [iQ]; - else - pRGBArow [3] = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR); - - pRGBArow += 4; /* next pixel */ - iM >>= 4; - iS -= 4; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - if (!iM) /* mask underflow ? */ - { - iB = pWorkrow [0]; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the index */ - iQ = (mng_uint8)((iB & iM) >> iS); - /* index valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - pRGBArow [0] = pBuf->aPLTEentries [iQ].iRed; - pRGBArow [1] = pBuf->aPLTEentries [iQ].iGreen; - pRGBArow [2] = pBuf->aPLTEentries [iQ].iBlue; - pRGBArow [3] = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR); - - pRGBArow += 4; /* next pixel */ - iM >>= 4; - iS -= 4; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_IDX4, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - -/* ************************************************************************** */ - -mng_retcode mng_process_idx8 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iQ; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_IDX8, MNG_LC_START); -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - iQ = *pWorkrow; /* get input byte */ - /* index valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - pRGBArow [0] = pBuf->aPLTEentries [iQ].iRed; - pRGBArow [1] = pBuf->aPLTEentries [iQ].iGreen; - pRGBArow [2] = pBuf->aPLTEentries [iQ].iBlue; - /* transparency for this index ? */ - if ((mng_uint32)iQ < pBuf->iTRNScount) - pRGBArow [3] = pBuf->aTRNSentries [iQ]; - else - pRGBArow [3] = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR); - - pRGBArow += 4; /* next pixel */ - pWorkrow++; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - iQ = *pWorkrow; /* get input byte */ - /* index valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - pRGBArow [0] = pBuf->aPLTEentries [iQ].iRed; - pRGBArow [1] = pBuf->aPLTEentries [iQ].iGreen; - pRGBArow [2] = pBuf->aPLTEentries [iQ].iBlue; - pRGBArow [3] = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR); - - pRGBArow += 4; /* next pixel */ - pWorkrow++; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_IDX8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_process_ga8 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_GA8, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - *pRGBArow = *pWorkrow; /* copy the gray value */ - *(pRGBArow+1) = *pWorkrow; - *(pRGBArow+2) = *pWorkrow; - *(pRGBArow+3) = *(pWorkrow+1); /* copy the alpha value */ - - pWorkrow += 2; /* next pixel */ - pRGBArow += 4; - } - - pData->bIsOpaque = MNG_FALSE; /* it's definitely not fully opaque */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_GA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_process_ga16 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint16 iW; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_GA16, MNG_LC_START); -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - iW = mng_get_uint16 (pWorkrow); /* copy the gray value */ - mng_put_uint16 (pRGBArow, iW); - mng_put_uint16 (pRGBArow+2, iW); - mng_put_uint16 (pRGBArow+4, iW); - /* copy the alpha value */ - mng_put_uint16 (pRGBArow+6, mng_get_uint16 (pWorkrow+2)); - - pWorkrow += 4; /* next pixel */ - pRGBArow += 8; - } - - pData->bIsOpaque = MNG_FALSE; /* it's definitely not fully opaque */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_GA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_process_rgba8 (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RGBA8, MNG_LC_START); -#endif - /* this is the easiest transform */ - MNG_COPY (pData->pRGBArow, pData->pWorkrow + pData->iPixelofs, pData->iRowsize); - - pData->bIsOpaque = MNG_FALSE; /* it's definitely not fully opaque */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RGBA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_process_rgba16 (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RGBA16, MNG_LC_START); -#endif - /* this is the easiest transform */ - MNG_COPY (pData->pRGBArow, pData->pWorkrow + pData->iPixelofs, pData->iRowsize); - - pData->bIsOpaque = MNG_FALSE; /* it's definitely not fully opaque */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RGBA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Row processing initialization routines - set up the variables needed * */ -/* * to process uncompressed row-data * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_FOOTPRINT_INIT -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_init_g1_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G1_NI, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_g1; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_g1; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_g1; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_g1; -#endif - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 7; - pData->iSamplediv = 3; - pData->iRowsize = (pData->iRowsamples + 7) >> 3; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G1_NI, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_init_g1_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G1_I, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_g1; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_g1; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_g1; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_g1; -#endif - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 1; - pData->iSampleofs = 7; - pData->iSamplediv = 3; - pData->iRowsize = ((pData->iRowsamples + 7) >> 3); - pData->iRowmax = ((pData->iDatawidth + 7) >> 3) + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G1_I, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_init_g2_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G2_NI, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_g2; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_g2; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_g2; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_g2; -#endif - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 3; - pData->iSamplediv = 2; - pData->iRowsize = (pData->iRowsamples + 3) >> 2; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G2_NI, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_init_g2_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G2_I, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_g2; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_g2; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_g2; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_g2; -#endif - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 1; - pData->iSampleofs = 3; - pData->iSamplediv = 2; - pData->iRowsize = ((pData->iRowsamples + 3) >> 2); - pData->iRowmax = ((pData->iDatawidth + 3) >> 2) + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G2_I, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_init_g4_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G4_NI, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_g4; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_g4; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_g4; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_g4; -#endif - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 1; - pData->iSamplediv = 1; - pData->iRowsize = (pData->iRowsamples + 1) >> 1; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G4_NI, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_init_g4_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G4_I, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_g4; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_g4; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_g4; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_g4; -#endif - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 1; - pData->iSampleofs = 1; - pData->iSamplediv = 1; - pData->iRowsize = ((pData->iRowsamples + 1) >> 1); - pData->iRowmax = ((pData->iDatawidth + 1) >> 1) + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G4_I, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - -/* ************************************************************************** */ - -mng_retcode mng_init_g8_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G8_NI, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_g8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_g8; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_g8; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_g8; -#endif - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G8_NI, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_init_g8_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G8_I, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_g8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_g8; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_g8; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_g8; -#endif - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 1; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples; - pData->iRowmax = pData->iDatawidth + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G8_I, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_init_g16_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G16_NI, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_g16; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_g16; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_g16; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_g16; -#endif - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 2; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 1; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 2; - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G16_NI, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_init_g16_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G16_I, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_g16; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_g16; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_g16; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_g16; -#endif - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 2; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 1; - pData->iRowmax = (pData->iDatawidth << 1) + pData->iPixelofs; - pData->iFilterbpp = 2; - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G16_I, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_init_rgb8_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGB8_NI, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_rgb8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_rgb8; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_rgb8; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_rgb8; -#endif - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 3; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples * 3; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 3; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGB8_NI, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_init_rgb8_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGB8_I, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_rgb8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_rgb8; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_rgb8; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_rgb8; -#endif - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 3; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples * 3; - pData->iRowmax = (pData->iDatawidth * 3) + pData->iPixelofs; - pData->iFilterbpp = 3; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGB8_I, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_init_rgb16_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGB16_NI, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_rgb16; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_rgb16; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_rgb16; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_rgb16; -#endif - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 6; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples * 6; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 6; - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGB16_NI, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_init_rgb16_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGB16_I, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_rgb16; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_rgb16; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_rgb16; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_rgb16; -#endif - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 6; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples * 6; - pData->iRowmax = (pData->iDatawidth * 6) + pData->iPixelofs; - pData->iFilterbpp = 6; - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGB16_I, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_init_idx1_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX1_NI, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_idx1; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_idx1; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_idx1; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_idx1; -#endif - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 7; - pData->iSamplediv = 3; - pData->iRowsize = (pData->iRowsamples + 7) >> 3; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX1_NI, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_init_idx1_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX1_I, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_idx1; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_idx1; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_idx1; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_idx1; -#endif - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 1; - pData->iSampleofs = 7; - pData->iSamplediv = 3; - pData->iRowsize = (pData->iRowsamples + 7) >> 3; - pData->iRowmax = ((pData->iDatawidth + 7) >> 3) + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX1_I, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_init_idx2_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX2_NI, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_idx2; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_idx2; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_idx2; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_idx2; -#endif - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 3; - pData->iSamplediv = 2; - pData->iRowsize = (pData->iRowsamples + 3) >> 2; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX2_NI, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_init_idx2_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX2_I, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_idx2; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_idx2; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_idx2; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_idx2; -#endif - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 1; - pData->iSampleofs = 3; - pData->iSamplediv = 2; - pData->iRowsize = (pData->iRowsamples + 3) >> 2; - pData->iRowmax = ((pData->iDatawidth + 3) >> 2) + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX2_I, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_init_idx4_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX4_NI, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_idx4; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_idx4; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_idx4; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_idx4; -#endif - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 1; - pData->iSamplediv = 1; - pData->iRowsize = (pData->iRowsamples + 1) >> 1; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX4_NI, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_init_idx4_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX4_I, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_idx4; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_idx4; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_idx4; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_idx4; -#endif - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 1; - pData->iSampleofs = 1; - pData->iSamplediv = 1; - pData->iRowsize = (pData->iRowsamples + 1) >> 1; - pData->iRowmax = ((pData->iDatawidth + 1) >> 1) + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX4_I, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - -/* ************************************************************************** */ - -mng_retcode mng_init_idx8_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX8_NI, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_idx8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_idx8; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_idx8; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_idx8; -#endif - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX8_NI, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_init_idx8_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX8_I, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_idx8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_idx8; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_idx8; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_idx8; -#endif - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 1; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples; - pData->iRowmax = pData->iDatawidth + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX8_I, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_init_ga8_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GA8_NI, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_ga8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_ga8; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_ga8; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_ga8; -#endif - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 2; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 1; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 2; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GA8_NI, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_init_ga8_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GA8_I, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_ga8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_ga8; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_ga8; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_ga8; -#endif - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 2; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 1; - pData->iRowmax = (pData->iDatawidth << 1) + pData->iPixelofs; - pData->iFilterbpp = 2; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GA8_I, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_init_ga16_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GA16_NI, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_ga16; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_ga16; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_ga16; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_ga16; -#endif - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 4; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 2; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 4; - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GA16_NI, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_init_ga16_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GA16_I, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_ga16; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_ga16; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_ga16; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_ga16; -#endif - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 4; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 2; - pData->iRowmax = (pData->iDatawidth << 2) + pData->iPixelofs; - pData->iFilterbpp = 4; - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GA16_I, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_init_rgba8_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGBA8_NI, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_rgba8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_rgba8; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_rgba8; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_rgba8; -#endif - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 4; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 2; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 4; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGBA8_NI, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} -/* ************************************************************************** */ - -mng_retcode mng_init_rgba8_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGBA8_I, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_rgba8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_rgba8; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_rgba8; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_rgba8; -#endif - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 4; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 2; - pData->iRowmax = (pData->iDatawidth << 2) + pData->iPixelofs; - pData->iFilterbpp = 4; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGBA8_I, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_init_rgba16_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGBA16_NI, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_rgba16; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_rgba16; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_rgba16; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_rgba16; -#endif - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 8; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 3; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 8; - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGBA16_NI, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_init_rgba16_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGBA16_I, MNG_LC_START); -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)mng_process_rgba16; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)mng_delta_rgba16; - else -#endif - pData->fStorerow = (mng_fptr)mng_store_rgba16; - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_rgba16; -#endif - - pData->iPass = 0; /* from 0..6; (1..7 in specification) */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 8; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 3; - pData->iRowmax = (pData->iDatawidth << 3) + pData->iPixelofs; - pData->iFilterbpp = 8; - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGBA16_I, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Row processing initialization routines (JPEG) - set up the variables * */ -/* * needed to process uncompressed row-data * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG - -/* ************************************************************************** */ - -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_init_jpeg_a1_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A1_NI, MNG_LC_START); -#endif - - if (pData->pStoreobj) /* store in object too ? */ - { - if (pData->iJHDRimgbitdepth == 8) - { - switch (pData->iJHDRcolortype) - { - case 12 : { pData->fStorerow = (mng_fptr)mng_store_jpeg_g8_a1; break; } - case 14 : { pData->fStorerow = (mng_fptr)mng_store_jpeg_rgb8_a1; break; } - } - } - - /* TODO: bitdepth 12 & 20 */ - - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_g1; -#endif - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 7; - pData->iSamplediv = 3; - pData->iRowsize = (pData->iRowsamples + 7) >> 3; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A1_NI, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_init_jpeg_a2_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A2_NI, MNG_LC_START); -#endif - - if (pData->pStoreobj) /* store in object too ? */ - { - if (pData->iJHDRimgbitdepth == 8) - { - switch (pData->iJHDRcolortype) - { - case 12 : { pData->fStorerow = (mng_fptr)mng_store_jpeg_g8_a2; break; } - case 14 : { pData->fStorerow = (mng_fptr)mng_store_jpeg_rgb8_a2; break; } - } - } - - /* TODO: bitdepth 12 & 20 */ - - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_g2; -#endif - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 3; - pData->iSamplediv = 2; - pData->iRowsize = (pData->iRowsamples + 3) >> 2; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A2_NI, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_init_jpeg_a4_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A4_NI, MNG_LC_START); -#endif - - if (pData->pStoreobj) /* store in object too ? */ - { - if (pData->iJHDRimgbitdepth == 8) - { - switch (pData->iJHDRcolortype) - { - case 12 : { pData->fStorerow = (mng_fptr)mng_store_jpeg_g8_a4; break; } - case 14 : { pData->fStorerow = (mng_fptr)mng_store_jpeg_rgb8_a4; break; } - } - } - - /* TODO: bitdepth 12 & 20 */ - - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_g4; -#endif - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 1; - pData->iSamplediv = 1; - pData->iRowsize = (pData->iRowsamples + 1) >> 1; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A4_NI, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - -/* ************************************************************************** */ - -mng_retcode mng_init_jpeg_a8_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A8_NI, MNG_LC_START); -#endif - - if (pData->pStoreobj) /* store in object too ? */ - { - if (pData->iJHDRimgbitdepth == 8) - { - switch (pData->iJHDRcolortype) - { - case 12 : { pData->fStorerow = (mng_fptr)mng_store_jpeg_g8_a8; break; } - case 14 : { pData->fStorerow = (mng_fptr)mng_store_jpeg_rgb8_a8; break; } - } - } - - /* TODO: bitdepth 12 & 20 */ - - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_g8; -#endif - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A8_NI, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_init_jpeg_a16_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A16_NI, MNG_LC_START); -#endif - - if (pData->pStoreobj) /* store in object too ? */ - { - if (pData->iJHDRimgbitdepth == 8) - { - switch (pData->iJHDRcolortype) - { - case 12 : { pData->fStorerow = (mng_fptr)mng_store_jpeg_g8_a16; break; } - case 14 : { pData->fStorerow = (mng_fptr)mng_store_jpeg_rgb8_a16; break; } - } - } - - /* TODO: bitdepth 12 & 20 */ - - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - pData->fDifferrow = (mng_fptr)mng_differ_g16; -#endif - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 2; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 1; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 2; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A16_NI, MNG_LC_END); -#endif - - return mng_init_rowproc (pData); -} -#endif - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_JNG */ -#endif /* MNG_OPTIMIZE_FOOTPRINT_INIT */ - - -/* ************************************************************************** */ -/* * * */ -/* * Generic row processing initialization & cleanup routines * */ -/* * - initialize the buffers used by the row processing routines * */ -/* * - cleanup the buffers used by the row processing routines * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode mng_init_rowproc (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ROWPROC, MNG_LC_START); -#endif - -#ifdef MNG_OPTIMIZE_FOOTPRINT_INIT - if (pData->ePng_imgtype != png_none) - { - if (pData->fDisplayrow) - switch (pData->ePng_imgtype) - { -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case png_g1: - pData->fProcessrow = (mng_fptr)mng_process_g1; - break; - case png_g2: - pData->fProcessrow = (mng_fptr)mng_process_g2; - break; - case png_g4: - pData->fProcessrow = (mng_fptr)mng_process_g4; - break; -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case png_g8: - pData->fProcessrow = (mng_fptr)mng_process_g8; - break; -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case png_idx1: - pData->fProcessrow = (mng_fptr)mng_process_idx1; - break; - case png_idx2: - pData->fProcessrow = (mng_fptr)mng_process_idx2; - break; - case png_idx4: - pData->fProcessrow = (mng_fptr)mng_process_idx4; - break; -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case png_idx8: - pData->fProcessrow = (mng_fptr)mng_process_idx8; - break; - case png_ga8: - pData->fProcessrow = (mng_fptr)mng_process_ga8; - break; - case png_rgb8: - pData->fProcessrow = (mng_fptr)mng_process_rgb8; - break; - case png_rgba8: - pData->fProcessrow = (mng_fptr)mng_process_rgba8; - break; -#ifndef MNG_NO_16BIT_SUPPORT - case png_g16: - pData->fProcessrow = (mng_fptr)mng_process_g16; - break; - case png_ga16: - pData->fProcessrow = (mng_fptr)mng_process_ga16; - break; - case png_rgb16: - pData->fProcessrow = (mng_fptr)mng_process_rgb16; - break; - case png_rgba16: - pData->fProcessrow = (mng_fptr)mng_process_rgba16; - break; -#endif - default: - break; - } - - if (pData->pStoreobj) /* store in object too ? */ - { -#ifndef MNG_NO_DELTA_PNG - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - switch (pData->ePng_imgtype) - { -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case png_g1: - pData->fStorerow = (mng_fptr)mng_delta_g1; - break; - case png_g2: - pData->fStorerow = (mng_fptr)mng_delta_g2; - break; - case png_g4: - pData->fStorerow = (mng_fptr)mng_delta_g4; - break; -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case png_g8: - pData->fStorerow = (mng_fptr)mng_delta_g8; - break; -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case png_idx1: - pData->fStorerow = (mng_fptr)mng_delta_idx1; - break; - case png_idx2: - pData->fStorerow = (mng_fptr)mng_delta_idx2; - break; - case png_idx4: - pData->fStorerow = (mng_fptr)mng_delta_idx4; - break; -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case png_idx8: - pData->fStorerow = (mng_fptr)mng_delta_idx8; - break; - case png_ga8: - pData->fStorerow = (mng_fptr)mng_delta_ga8; - break; - case png_rgb8: - pData->fStorerow = (mng_fptr)mng_delta_rgb8; - break; - case png_rgba8: - pData->fStorerow = (mng_fptr)mng_delta_rgba8; - break; -#ifndef MNG_NO_16BIT_SUPPORT - case png_g16: - pData->fStorerow = (mng_fptr)mng_delta_g16; - break; - case png_ga16: - pData->fStorerow = (mng_fptr)mng_delta_ga16; - break; - case png_rgb16: - pData->fStorerow = (mng_fptr)mng_delta_rgb16; - break; - case png_rgba16: - pData->fStorerow = (mng_fptr)mng_delta_rgba16; - break; -#endif - default: - break; - } - else -#endif /* MNG_NO_DELTA_PNG */ - switch (pData->ePng_imgtype) - { -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case png_g1: - pData->fStorerow = (mng_fptr)mng_store_g1; - break; - case png_g2: - pData->fStorerow = (mng_fptr)mng_store_g2; - break; - case png_g4: - pData->fStorerow = (mng_fptr)mng_store_g4; - break; -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case png_g8: - pData->fStorerow = (mng_fptr)mng_store_g8; - break; -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case png_idx1: - pData->fStorerow = (mng_fptr)mng_store_idx1; - break; - case png_idx2: - pData->fStorerow = (mng_fptr)mng_store_idx2; - break; - case png_idx4: - pData->fStorerow = (mng_fptr)mng_store_idx4; - break; -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case png_idx8: - pData->fStorerow = (mng_fptr)mng_store_idx8; - break; - case png_ga8: - pData->fStorerow = (mng_fptr)mng_store_ga8; - break; - case png_rgb8: - pData->fStorerow = (mng_fptr)mng_store_rgb8; - break; - case png_rgba8: - pData->fStorerow = (mng_fptr)mng_store_rgba8; - break; -#ifndef MNG_NO_16BIT_SUPPORT - case png_g16: - pData->fStorerow = (mng_fptr)mng_store_g16; - break; - case png_ga16: - pData->fStorerow = (mng_fptr)mng_store_ga16; - break; - case png_rgb16: - pData->fStorerow = (mng_fptr)mng_store_rgb16; - break; - case png_rgba16: - pData->fStorerow = (mng_fptr)mng_store_rgba16; - break; -#endif - -#ifdef MNG_INCLUDE_JNG -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case png_jpeg_a1: -/* if (pData->iJHDRimgbitdepth == 8) */ - { - switch (pData->iJHDRcolortype) - { - case 12 : - { pData->fStorerow = (mng_fptr)mng_store_jpeg_g8_a1; break; } - case 14 : - { pData->fStorerow = (mng_fptr)mng_store_jpeg_rgb8_a1; break; } - } - } - /* TODO: bitdepth 12 & 20 */ - break; - case png_jpeg_a2: -/* if (pData->iJHDRimgbitdepth == 8) */ - { - switch (pData->iJHDRcolortype) - { - case 12 : - { pData->fStorerow = (mng_fptr)mng_store_jpeg_g8_a2; break; } - case 14 : - { pData->fStorerow = (mng_fptr)mng_store_jpeg_rgb8_a2; break; } - } - } - break; - /* TODO: bitdepth 12 & 20 */ - case png_jpeg_a4: -/* if (pData->iJHDRimgbitdepth == 8) */ - { - switch (pData->iJHDRcolortype) - { - case 12 : - { pData->fStorerow = (mng_fptr)mng_store_jpeg_g8_a4; break; } - case 14 : - { pData->fStorerow = (mng_fptr)mng_store_jpeg_rgb8_a4; break; } - } - } - break; -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - /* TODO: bitdepth 12 & 20 */ - case png_jpeg_a8: -/* if (pData->iJHDRimgbitdepth == 8) */ - { - switch (pData->iJHDRcolortype) - { - case 12 : - { pData->fStorerow = (mng_fptr)mng_store_jpeg_g8_a8; break; } - case 14 : - { pData->fStorerow = (mng_fptr)mng_store_jpeg_rgb8_a8; break; } - } - } - break; - /* TODO: bitdepth 12 & 20 */ -#ifndef MNG_NO_16BIT_SUPPORT - case png_jpeg_a16: -/* if (pData->iJHDRimgbitdepth == 8) */ - { - switch (pData->iJHDRcolortype) - { - case 12 : - { pData->fStorerow = (mng_fptr)mng_store_jpeg_g8_a16; break; } - case 14 : - { pData->fStorerow = (mng_fptr)mng_store_jpeg_rgb8_a16; break; } - } - } - break; - /* TODO: bitdepth 12 & 20 */ -#endif -#endif /* MNG_INCLUDE_JNG */ - default: - break; - } - } - -#ifdef FILTER192 /* leveling & differing ? */ - if (pData->iFilter == MNG_FILTER_DIFFERING) - switch (pData->ePng_imgtype) - { -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case png_g1: -#ifdef MNG_INCLUDE_JNG - case png_jpeg_a1: -#endif - pData->fDifferrow = (mng_fptr)mng_differ_g1; - break; - case png_g2: -#ifdef MNG_INCLUDE_JNG - case png_jpeg_a2: -#endif - pData->fDifferrow = (mng_fptr)mng_differ_g2; - break; - case png_g4: -#ifdef MNG_INCLUDE_JNG - case png_jpeg_a4: -#endif - pData->fDifferrow = (mng_fptr)mng_differ_g4; - break; -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case png_g8: -#ifdef MNG_INCLUDE_JNG - case png_jpeg_a8: -#endif - pData->fDifferrow = (mng_fptr)mng_differ_g8; - break; - case png_rgb8: - pData->fDifferrow = (mng_fptr)mng_differ_rgb8; - break; -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case png_idx1: - pData->fDifferrow = (mng_fptr)mng_differ_idx1; - break; - case png_idx2: - pData->fDifferrow = (mng_fptr)mng_differ_idx2; - break; - case png_idx4: - pData->fDifferrow = (mng_fptr)mng_differ_idx4; - break; -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case png_idx8: - pData->fDifferrow = (mng_fptr)mng_differ_idx8; - break; - case png_ga8: - pData->fDifferrow = (mng_fptr)mng_differ_ga8; - break; - case png_rgb8: - pData->fDifferrow = (mng_fptr)mng_differ_rgb8; - break; - case png_rgba8: - pData->fDifferrow = (mng_fptr)mng_differ_rgba8; - break; -#ifndef MNG_NO_16BIT_SUPPORT - case png_g16: -#ifdef MNG_INCLUDE_JNG - case png_jpeg_a16: -#endif - pData->fDifferrow = (mng_fptr)mng_differ_g16; - break; - case png_ga16: - pData->fDifferrow = (mng_fptr)mng_differ_ga16; - break; - case png_rgb16: - pData->fDifferrow = (mng_fptr)mng_differ_rgb16; - break; - case png_rgba16: - pData->fDifferrow = (mng_fptr)mng_differ_rgba16; - break; -#endif - default: - break; - } -#endif - - switch (pData->ePng_imgtype) - { -#ifndef MNG_NO_1_2_4BIT_SUPPORT - case png_g1: - case png_idx1: -#ifdef MNG_INCLUDE_JNG - case png_jpeg_a1: -#endif - pData->iSamplemul = 1; - pData->iSampleofs = 7; - pData->iSamplediv = 3; - pData->iFilterbpp = 1; - break; - case png_g2: - case png_idx2: -#ifdef MNG_INCLUDE_JNG - case png_jpeg_a2: -#endif - pData->iSamplemul = 1; - pData->iSampleofs = 3; - pData->iSamplediv = 2; - pData->iFilterbpp = 1; - break; - case png_g4: - case png_idx4: -#ifdef MNG_INCLUDE_JNG - case png_jpeg_a4: -#endif - pData->iSamplemul = 1; - pData->iSampleofs = 1; - pData->iSamplediv = 1; - pData->iFilterbpp = 1; - break; -#endif /* MNG_NO_1_2_4BIT_SUPPORT */ - case png_g8: - case png_idx8: -#ifdef MNG_INCLUDE_JNG - case png_jpeg_a8: -#endif - pData->iSamplemul = 1; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iFilterbpp = 1; - break; - case png_ga8: -#ifndef MNG_NO_16BIT_SUPPORT - case png_g16: -#ifdef MNG_INCLUDE_JNG - case png_jpeg_a16: -#endif -#endif - pData->iSamplemul = 2; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iFilterbpp = 2; - break; - case png_rgb8: - pData->iSamplemul = 3; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iFilterbpp = 3; - break; -#ifndef MNG_NO_16BIT_SUPPORT - case png_ga16: -#endif - case png_rgba8: - pData->iSamplemul = 4; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iFilterbpp = 4; - break; -#ifndef MNG_NO_16BIT_SUPPORT - case png_rgb16: - pData->iSamplemul = 6; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iFilterbpp = 6; - break; - case png_rgba16: - pData->iSamplemul = 8; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iFilterbpp = 8; - break; -#endif - default: - break; - } - - if (pData->iInterlace) /* noninterlaced */ - { - pData->iPass = 0; /* from 0..6; (1..7 in specification) */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> - interlace_divider [0]; - pData->iRowmax = ((pData->iDatawidth * pData->iSamplemul + - pData->iSampleofs) >> pData->iSamplediv) + pData->iPixelofs; - } - else /* interlaced */ - { - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - } - if (pData->iSamplediv > 0) - pData->iRowsize = (pData->iRowsamples + pData->iSampleofs) >> - pData->iSamplediv; - else - pData->iRowsize = (pData->iRowsamples * pData->iSamplemul); - - if (!pData->iInterlace) /* noninterlaced */ - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - -#ifdef MNG_NO_16BIT_SUPPORT - pData->bIsRGBA16 = MNG_FALSE; -#else - switch (pData->ePng_imgtype) - { - case png_g16: - case png_ga16: - case png_rgb16: - case png_rgba16: - pData->bIsRGBA16 = MNG_TRUE; - break; - default: - pData->bIsRGBA16 = MNG_FALSE; - break; - } -#endif - - } -#endif /* MNG_OPTIMIZE_FOOTPRINT_INIT */ - - if (pData->pStoreobj) /* storage object selected ? */ - { - pData->pStorebuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - /* and so it becomes viewable ! */ - ((mng_imagep)pData->pStoreobj)->bViewable = MNG_TRUE; - ((mng_imagedatap)pData->pStorebuf)->bViewable = MNG_TRUE; - } - - /* allocate the buffers; the individual init routines have already - calculated the required maximum size; except in the case of a JNG - without alpha!!! */ - if (pData->iRowmax) - { -#if defined(MNG_NO_16BIT_SUPPORT) || defined (MNG_NO_1_2_4BIT_SUPPORT) - mng_uint8 iRowadd = 0; -#ifdef MNG_NO_1_2_4BIT_SUPPORT - if (pData->iPNGdepth < 8) - iRowadd=(pData->iPNGdepth*pData->iRowmax+7)/8; -#endif -#ifdef MNG_NO_16BIT_SUPPORT - if (pData->iPNGdepth > 8) - iRowadd=pData->iRowmax; -#endif - MNG_ALLOC (pData, pData->pWorkrow, pData->iRowmax+iRowadd); - MNG_ALLOC (pData, pData->pPrevrow, pData->iRowmax+iRowadd); -#else - MNG_ALLOC (pData, pData->pWorkrow, pData->iRowmax); - MNG_ALLOC (pData, pData->pPrevrow, pData->iRowmax); -#endif - } - - /* allocate an RGBA16 row for intermediate processing */ - MNG_ALLOC (pData, pData->pRGBArow, (pData->iDatawidth << 3)); - -#ifndef MNG_NO_CMS - if (pData->fDisplayrow) /* display "on-the-fly" ? */ - { -#if defined(MNG_FULL_CMS) /* determine color-management initialization */ - mng_retcode iRetcode = mng_init_full_cms (pData, MNG_TRUE, MNG_TRUE, MNG_FALSE); -#elif defined(MNG_GAMMA_ONLY) - mng_retcode iRetcode = mng_init_gamma_only (pData, MNG_TRUE, MNG_TRUE, MNG_FALSE); -#elif defined(MNG_APP_CMS) - mng_retcode iRetcode = mng_init_app_cms (pData, MNG_TRUE, MNG_TRUE, MNG_FALSE); -#endif - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* !MNG_NO_CMS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ROWPROC, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_next_row (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_ROW, MNG_LC_START); -#endif - - pData->iRow += pData->iRowinc; /* increase the row counter */ - - if (pData->iPass >= 0) /* interlaced ? */ - { - while ((pData->iPass < 7) && /* went 'outside' the image ? */ - ((pData->iRow >= (mng_int32)pData->iDataheight) || - (pData->iCol >= (mng_int32)pData->iDatawidth ) )) - { - pData->iPass++; /* next pass ! */ - - if (pData->iPass < 7) /* there's only 7 passes ! */ - { - pData->iRow = interlace_row [pData->iPass]; - pData->iRowinc = interlace_rowskip [pData->iPass]; - pData->iCol = interlace_col [pData->iPass]; - pData->iColinc = interlace_colskip [pData->iPass]; - pData->iRowsamples = (pData->iDatawidth - pData->iCol + interlace_roundoff [pData->iPass]) - >> interlace_divider [pData->iPass]; - - if (pData->iSamplemul > 1) /* recalculate row dimension */ - pData->iRowsize = pData->iRowsamples * pData->iSamplemul; - else - if (pData->iSamplediv > 0) - pData->iRowsize = (pData->iRowsamples + pData->iSampleofs) >> pData->iSamplediv; - else - pData->iRowsize = pData->iRowsamples; - - } - - if ((pData->iPass < 7) && /* reset previous row to zeroes ? */ - (pData->iRow < (mng_int32)pData->iDataheight) && - (pData->iCol < (mng_int32)pData->iDatawidth ) ) - { /* making sure the filters will work properly! */ - mng_int32 iX; - mng_uint8p pTemp = pData->pPrevrow; - -#ifdef MNG_NO_16BIT_SUPPORT -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iPNGmult*pData->iRowsize; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iPNGmult*pData->iRowsize; iX++) -#endif -#else -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsize; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsize; iX++) -#endif -#endif - { - *pTemp = 0; - pTemp++; - } - } - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_ROW, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_cleanup_rowproc (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLEANUP_ROWPROC, MNG_LC_START); -#endif - -#ifdef MNG_INCLUDE_LCMS /* cleanup cms profile/transform */ - { - mng_retcode iRetcode = mng_clear_cms (pData); - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_INCLUDE_LCMS */ - - if (pData->pRGBArow) /* cleanup buffer for intermediate row */ - MNG_FREEX (pData, pData->pRGBArow, (pData->iDatawidth << 3)); - if (pData->pPrevrow) /* cleanup buffer for previous row */ - MNG_FREEX (pData, pData->pPrevrow, pData->iRowmax); - if (pData->pWorkrow) /* cleanup buffer for working row */ - MNG_FREEX (pData, pData->pWorkrow, pData->iRowmax); - - pData->pWorkrow = MNG_NULL; /* propogate uninitialized buffers */ - pData->pPrevrow = MNG_NULL; - pData->pRGBArow = MNG_NULL; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLEANUP_ROWPROC, MNG_LC_END); -#endif - - return MNG_NOERROR; /* woohiii */ -} - -/* ************************************************************************** */ -/* * * */ -/* * Generic row processing routines for JNG * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG - -/* ************************************************************************** */ - -mng_retcode mng_display_jpeg_rows (mng_datap pData) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_JPEG_ROWS, MNG_LC_START); -#endif - /* any completed rows ? */ - if ((pData->iJPEGrow > pData->iJPEGdisprow) && - (pData->iJPEGalpharow > pData->iJPEGdisprow) ) - { - mng_uint32 iX, iMax; - mng_uint32 iSaverow = pData->iRow; /* save alpha decompression row-count */ - /* determine the highest complete(!) row */ - if (pData->iJPEGrow > pData->iJPEGalpharow) - iMax = pData->iJPEGalpharow; - else - iMax = pData->iJPEGrow; - /* display the rows */ - for (iX = pData->iJPEGdisprow; iX < iMax; iX++) - { - pData->iRow = iX; /* make sure we all know which row to handle */ - /* makeup an intermediate row from the buffer */ - iRetcode = ((mng_retrieverow)pData->fRetrieverow) (pData); - /* color-correct it if necessary */ - if ((!iRetcode) && (pData->fCorrectrow)) - iRetcode = ((mng_correctrow)pData->fCorrectrow) (pData); - - if (!iRetcode) /* and display it */ - { - iRetcode = ((mng_displayrow)pData->fDisplayrow) (pData); - - if (!iRetcode) /* check progressive display refresh */ - iRetcode = mng_display_progressive_check (pData); - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - pData->iJPEGdisprow = iMax; /* keep track of the last displayed row */ - pData->iRow = iSaverow; /* restore alpha decompression row-count */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_JPEG_ROWS, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_next_jpeg_alpharow (mng_datap pData) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_JPEG_ALPHAROW, MNG_LC_START); -#endif - - pData->iJPEGalpharow++; /* count the row */ - - if (pData->fDisplayrow) /* display "on-the-fly" ? */ - { /* try to display what you can */ - iRetcode = mng_display_jpeg_rows (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_JPEG_ALPHAROW, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_next_jpeg_row (mng_datap pData) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_JPEG_ROW, MNG_LC_START); -#endif - - pData->iJPEGrow++; /* increase the row-counter */ - - if (pData->fDisplayrow) /* display "on-the-fly" ? */ - { /* has alpha channel ? */ - if ((pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) ) - { /* try to display what you can */ - iRetcode = mng_display_jpeg_rows (pData); - } - else - { /* make sure we all know which row to handle */ - pData->iRow = pData->iJPEGrow - 1; - /* makeup an intermediate row from the buffer */ - iRetcode = ((mng_retrieverow)pData->fRetrieverow) (pData); - /* color-correct it if necessary */ - if ((!iRetcode) && (pData->fCorrectrow)) - iRetcode = ((mng_correctrow)pData->fCorrectrow) (pData); - - if (!iRetcode) /* and display it */ - { - iRetcode = ((mng_displayrow)pData->fDisplayrow) (pData); - - if (!iRetcode) /* check progressive display refresh */ - iRetcode = mng_display_progressive_check (pData); - } - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - /* surpassed last filled row ? */ - if (pData->iJPEGrow > pData->iJPEGrgbrow) - pData->iJPEGrgbrow = pData->iJPEGrow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_JPEG_ROW, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_MAGN -#ifndef MNG_OPTIMIZE_FOOTPRINT_MAGN -#ifndef MNG_NO_GRAY_SUPPORT -mng_retcode mng_magnify_g8_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX, iS, iM; - mng_uint8p pTempsrc1; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_X1, MNG_LC_START); -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - - if (iX == 0) /* first interval ? */ - iM = iML; - else - if (iX == (iWidth - 1)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - - for (iS = 1; iS < iM; iS++) /* fill interval */ - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - } - - pTempsrc1++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_X1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_g8_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_X2, MNG_LC_START); -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 1; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { /* is it same as first ? */ - if (*pTempsrc1 == *pTempsrc2) - { - for (iS = 1; iS < iM; iS++) /* then just repeat the first */ - { - *pTempdst = *pTempsrc1; - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) /* calculate the distances */ - { - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2)) + (mng_int32)(*pTempsrc1) ); - pTempdst++; - } - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - } - } - } - - pTempsrc1++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_X2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_g8_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_X3, MNG_LC_START); -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 1; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { /* is it same as first ? */ - if (*pTempsrc1 == *pTempsrc2) - { - for (iS = 1; iS < iM; iS++) /* then just repeat the first */ - { - *pTempdst = *pTempsrc1; - pTempdst++; - } - } - else - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* replicate first half */ - { - *pTempdst = *pTempsrc1; - pTempdst++; - } - - for (iS = iH; iS < iM; iS++) /* replicate second half */ - { - *pTempdst = *pTempsrc2; - pTempdst++; - } - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - } - } - } - - pTempsrc1++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_X3, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_GRAY_SUPPORT */ - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgb8_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX, iS, iM; - mng_uint8p pTempsrc1; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_X1, MNG_LC_START); -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - - if (iX == 0) /* first interval ? */ - iM = iML; - else - if (iX == (iWidth - 1)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - - for (iS = 1; iS < iM; iS++) /* fill interval */ - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - } - - pTempsrc1 += 3; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_X1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgb8_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_X2, MNG_LC_START); -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 3; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = (mng_int32)iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = (mng_int32)iMR; - else - iM = (mng_int32)iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - for (iS = 1; iS < iM; iS++) - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2)) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+1)) - - (mng_int32)(*(pTempsrc1+1)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+1)) ); - - pTempdst++; - - if (*(pTempsrc1+2) == *(pTempsrc2+2)) - *pTempdst = *(pTempsrc1+2); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+2)) - - (mng_int32)(*(pTempsrc1+2)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+2)) ); - - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - } - } - } - - pTempsrc1 += 3; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_X2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgb8_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_X3, MNG_LC_START); -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 3; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = (mng_int32)iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = (mng_int32)iMR; - else - iM = (mng_int32)iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* replicate first half */ - { - *pTempdst = *pTempsrc1; - *(pTempdst+1) = *(pTempsrc1+1); - *(pTempdst+2) = *(pTempsrc1+2); - - pTempdst += 3; - } - - for (iS = iH; iS < iM; iS++) /* replicate second half */ - { - *pTempdst = *pTempsrc2; - *(pTempdst+1) = *(pTempsrc2+1); - *(pTempdst+2) = *(pTempsrc2+2); - - pTempdst += 3; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - } - } - } - - pTempsrc1 += 3; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_X3, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_GRAY_SUPPORT -mng_retcode mng_magnify_ga8_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX, iS, iM; - mng_uint8p pTempsrc1; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X1, MNG_LC_START); -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - - if (iX == 0) /* first interval ? */ - iM = iML; - else - if (iX == (iWidth - 1)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - - for (iS = 1; iS < iM; iS++) /* fill interval */ - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - } - - pTempsrc1 += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_ga8_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X2, MNG_LC_START); -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 2; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - for (iS = 1; iS < iM; iS++) - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2)) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+1)) - - (mng_int32)(*(pTempsrc1+1)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+1)) ); - - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - } - } - } - - pTempsrc1 += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_ga8_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X3, MNG_LC_START); -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 2; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* replicate first half */ - { - *pTempdst = *pTempsrc1; - *(pTempdst+1) = *(pTempsrc1+1); - - pTempdst += 2; - } - - for (iS = iH; iS < iM; iS++) /* replicate second half */ - { - *pTempdst = *pTempsrc2; - *(pTempdst+1) = *(pTempsrc2+1); - - pTempdst += 2; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - } - } - } - - pTempsrc1 += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X3, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_ga8_x4 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X4, MNG_LC_START); -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 2; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* first half */ - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2)) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - - *pTempdst = *(pTempsrc1+1); /* replicate alpha from left */ - - pTempdst++; - } - - for (iS = iH; iS < iM; iS++) /* second half */ - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2)) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - - *pTempdst = *(pTempsrc2+1); /* replicate alpha from right */ - - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - } - } - } - - pTempsrc1 += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X4, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_ga8_x5 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X5, MNG_LC_START); -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 2; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* first half */ - { - *pTempdst = *pTempsrc1; /* replicate gray from left */ - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1);/* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+1)) - - (mng_int32)(*(pTempsrc1+1)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+1)) ); - - pTempdst++; - } - - for (iS = iH; iS < iM; iS++) /* second half */ - { - *pTempdst = *pTempsrc2; /* replicate gray from right */ - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1);/* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+1)) - - (mng_int32)(*(pTempsrc1+1)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+1)) ); - - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - } - } - } - - pTempsrc1 += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X5, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_GRAY_SUPPORT */ -#endif /* MNG_OPTIMIZE_FOOTPRINT_MAGN */ - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgba8_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX, iS, iM; - mng_uint8p pTempsrc1; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X1, MNG_LC_START); -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - - if (iX == 0) /* first interval ? */ - iM = iML; - else - if (iX == (iWidth - 1)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - - for (iS = 1; iS < iM; iS++) /* fill interval */ - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - } - - pTempsrc1 += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgba8_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X2, MNG_LC_START); -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 4; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = (mng_int32)iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = (mng_int32)iMR; - else - iM = (mng_int32)iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - for (iS = 1; iS < iM; iS++) - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2)) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+1)) - - (mng_int32)(*(pTempsrc1+1)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+1)) ); - - pTempdst++; - - if (*(pTempsrc1+2) == *(pTempsrc2+2)) - *pTempdst = *(pTempsrc1+2); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+2)) - - (mng_int32)(*(pTempsrc1+2)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+2)) ); - - pTempdst++; - - if (*(pTempsrc1+3) == *(pTempsrc2+3)) - *pTempdst = *(pTempsrc1+3); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+3)) - - (mng_int32)(*(pTempsrc1+3)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+3)) ); - - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - } - } - } - - pTempsrc1 += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgba8_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X3, MNG_LC_START); -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 4; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = (mng_int32)iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = (mng_int32)iMR; - else - iM = (mng_int32)iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* replicate first half */ - { - *pTempdst = *pTempsrc1; - *(pTempdst+1) = *(pTempsrc1+1); - *(pTempdst+2) = *(pTempsrc1+2); - *(pTempdst+3) = *(pTempsrc1+3); - - pTempdst += 4; - } - - for (iS = iH; iS < iM; iS++) /* replicate second half */ - { - *pTempdst = *pTempsrc2; - *(pTempdst+1) = *(pTempsrc2+1); - *(pTempdst+2) = *(pTempsrc2+2); - *(pTempdst+3) = *(pTempsrc2+3); - - pTempdst += 4; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - } - } - } - - pTempsrc1 += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X3, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgba8_x4 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X4, MNG_LC_START); -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 4; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = (mng_int32)iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = (mng_int32)iMR; - else - iM = (mng_int32)iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* first half */ - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2)) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+1)) - - (mng_int32)(*(pTempsrc1+1)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+1)) ); - - pTempdst++; - - if (*(pTempsrc1+2) == *(pTempsrc2+2)) - *pTempdst = *(pTempsrc1+2); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+2)) - - (mng_int32)(*(pTempsrc1+2)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+2)) ); - - pTempdst++; - /* replicate alpha from left */ - *pTempdst = *(pTempsrc1+3); - - pTempdst++; - } - - for (iS = iH; iS < iM; iS++) /* second half */ - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2)) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+1)) - - (mng_int32)(*(pTempsrc1+1)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+1)) ); - - pTempdst++; - - if (*(pTempsrc1+2) == *(pTempsrc2+2)) - *pTempdst = *(pTempsrc1+2); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+2)) - - (mng_int32)(*(pTempsrc1+2)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+2)) ); - - pTempdst++; - /* replicate alpha from right */ - *pTempdst = *(pTempsrc2+3); - - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - } - } - } - - pTempsrc1 += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X4, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgba8_x5 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X5, MNG_LC_START); -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 4; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = (mng_int32)iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = (mng_int32)iMR; - else - iM = (mng_int32)iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* first half */ - { - *pTempdst = *pTempsrc1; /* replicate color from left */ - *(pTempdst+1) = *(pTempsrc1+1); - *(pTempdst+2) = *(pTempsrc1+2); - - if (*(pTempsrc1+3) == *(pTempsrc2+3)) - *(pTempdst+3) = *(pTempsrc1+3); - else - *(pTempdst+3) = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+3)) - - (mng_int32)(*(pTempsrc1+3)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+3)) ); - - pTempdst += 4; - } - - for (iS = iH; iS < iM; iS++) /* second half */ - { - *pTempdst = *pTempsrc2; /* replicate color from right */ - *(pTempdst+1) = *(pTempsrc2+1); - *(pTempdst+2) = *(pTempsrc2+2); - - if (*(pTempsrc1+3) == *(pTempsrc2+3)) - *(pTempdst+3) = *(pTempsrc1+3); - else - *(pTempdst+3) = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+3)) - - (mng_int32)(*(pTempsrc1+3)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+3)) ); - - pTempdst += 4; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - } - } - } - - pTempsrc1 += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X4, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_FOOTPRINT_MAGN -#ifndef MNG_NO_GRAY_SUPPORT -mng_retcode mng_magnify_g8_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_Y1, MNG_LC_START); -#endif - - MNG_COPY (pDstline, pSrcline1, iWidth); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_Y1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -mng_retcode mng_magnify_g8_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_Y2, MNG_LC_START); -#endif - - pTempsrc1 = pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = pSrcline2; - pTempdst = pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, iWidth); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_Y2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_g8_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_Y3, MNG_LC_START); -#endif - - if (pSrcline2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - MNG_COPY (pDstline, pSrcline1, iWidth) - else - MNG_COPY (pDstline, pSrcline2, iWidth); - } - else - { /* just repeat the entire line */ - MNG_COPY (pDstline, pSrcline1, iWidth); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_Y3, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_GRAY_SUPPORT */ - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgb8_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_Y1, MNG_LC_START); -#endif - - MNG_COPY (pDstline, pSrcline1, iWidth * 3); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_Y1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgb8_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_Y2, MNG_LC_START); -#endif - - pTempsrc1 = pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = pSrcline2; - pTempdst = pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, iWidth * 3); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_Y2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgb8_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_Y3, MNG_LC_START); -#endif - - if (pSrcline2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - MNG_COPY (pDstline, pSrcline1, iWidth * 3) - else - MNG_COPY (pDstline, pSrcline2, iWidth * 3); - } - else - { /* just repeat the entire line */ - MNG_COPY (pDstline, pSrcline1, iWidth * 3); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_Y3, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_GRAY_SUPPORT -mng_retcode mng_magnify_ga8_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y1, MNG_LC_START); -#endif - - MNG_COPY (pDstline, pSrcline1, iWidth << 1); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_ga8_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y2, MNG_LC_START); -#endif - - pTempsrc1 = pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = pSrcline2; - pTempdst = pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, iWidth << 1); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_ga8_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y3, MNG_LC_START); -#endif - - if (pSrcline2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - MNG_COPY (pDstline, pSrcline1, iWidth << 1) - else - MNG_COPY (pDstline, pSrcline2, iWidth << 1); - } - else - { /* just repeat the entire line */ - MNG_COPY (pDstline, pSrcline1, iWidth << 1); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_ga8_y4 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y4, MNG_LC_START); -#endif - - pTempsrc1 = pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = pSrcline2; - pTempdst = pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2 += 2; - - *pTempdst++ = *pTempsrc1++; /* replicate alpha from top */ - } - } - else - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1 += 2; - pTempsrc2++; - - *pTempdst++ = *pTempsrc2++; /* replicate alpha from bottom */ - } - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, iWidth << 1); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y4, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_ga8_y5 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y5, MNG_LC_START); -#endif - - pTempsrc1 = pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = pSrcline2; - pTempdst = pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - { - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst = *pTempsrc1; /* replicate gray from top */ - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) /* calculate the distances */ - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - else - { - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst = *pTempsrc2; /* replicate gray from bottom */ - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) /* calculate the distances */ - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, iWidth << 1); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y5, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_GRAY_SUPPORT */ -#endif /* MNG_OPTIMIZE_FOOTPRINT_MAGN */ - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgba8_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y1, MNG_LC_START); -#endif - - MNG_COPY (pDstline, pSrcline1, iWidth << 2); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgba8_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y2, MNG_LC_START); -#endif - - pTempsrc1 = pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = pSrcline2; - pTempdst = pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, iWidth << 2); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgba8_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y3, MNG_LC_START); -#endif - - if (pSrcline2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - MNG_COPY (pDstline, pSrcline1, iWidth << 2) - else - MNG_COPY (pDstline, pSrcline2, iWidth << 2); - } - else - { /* just repeat the entire line */ - MNG_COPY (pDstline, pSrcline1, iWidth << 2); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgba8_y4 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y4, MNG_LC_START); -#endif - - pTempsrc1 = pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = pSrcline2; - pTempdst = pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2 += 2; - - *pTempdst++ = *pTempsrc1++; /* replicate alpha from top */ - } - } - else - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1 += 2; - pTempsrc2++; - - *pTempdst++ = *pTempsrc2++; /* replicate alpha from bottom */ - } - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, iWidth << 2); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y4, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgba8_y5 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y5, MNG_LC_START); -#endif - - pTempsrc1 = pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = pSrcline2; - pTempdst = pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - { - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst++ = *pTempsrc1++; /* replicate color from top */ - *pTempdst++ = *pTempsrc1++; - *pTempdst++ = *pTempsrc1++; - - pTempsrc2 += 3; - - if (*pTempsrc1 == *pTempsrc2) /* calculate the distances */ - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - else - { - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst++ = *pTempsrc2++; /* replicate color from bottom */ - *pTempdst++ = *pTempsrc2++; - *pTempdst++ = *pTempsrc2++; - - pTempsrc1 += 3; - - if (*pTempsrc1 == *pTempsrc2) /* calculate the distances */ - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, iWidth << 2); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y5, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_FOOTPRINT_MAGN -#ifndef MNG_NO_16BIT_SUPPORT -#ifndef MNG_NO_GRAY_SUPPORT -mng_retcode mng_magnify_g16_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX, iS, iM; - mng_uint16p pTempsrc1; - mng_uint16p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G16_X1, MNG_LC_START); -#endif - - pTempsrc1 = (mng_uint16p)pSrcline; /* initialize pixel-loop */ - pTempdst = (mng_uint16p)pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - - if (iX == 0) /* first interval ? */ - iM = iML; - else - if (iX == (iWidth - 1)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - - for (iS = 1; iS < iM; iS++) /* fill interval */ - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - } - - pTempsrc1++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G16_X1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_g16_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM; - mng_uint16p pTempsrc1; - mng_uint16p pTempsrc2; - mng_uint16p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G16_X2, MNG_LC_START); -#endif - - pTempsrc1 = (mng_uint16p)pSrcline; /* initialize pixel-loop */ - pTempdst = (mng_uint16p)pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 1; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { /* is it same as first ? */ - if (*pTempsrc1 == *pTempsrc2) - { - for (iS = 1; iS < iM; iS++) /* then just repeat the first */ - { - *pTempdst = *pTempsrc1; - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) /* calculate the distances */ - { - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)(((2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) )); - pTempdst++; - } - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - } - } - } - - pTempsrc1++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G16_X2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_g16_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint16p pTempsrc1; - mng_uint16p pTempsrc2; - mng_uint16p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G16_X3, MNG_LC_START); -#endif - - pTempsrc1 = (mng_uint16p)pSrcline; /* initialize pixel-loop */ - pTempdst = (mng_uint16p)pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 1; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { /* is it same as first ? */ - if (*pTempsrc1 == *pTempsrc2) - { - for (iS = 1; iS < iM; iS++) /* then just repeat the first */ - { - *pTempdst = *pTempsrc1; - pTempdst++; - } - } - else - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* replicate first half */ - { - *pTempdst = *pTempsrc1; - pTempdst++; - } - - for (iS = iH; iS < iM; iS++) /* replicate second half */ - { - *pTempdst = *pTempsrc2; - pTempdst++; - } - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - } - } - } - - pTempsrc1++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G16_X3, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_GRAY_SUPPORT */ - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgb16_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX, iS, iM; - mng_uint16p pTempsrc1; - mng_uint16p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB16_X1, MNG_LC_START); -#endif - - pTempsrc1 = (mng_uint16p)pSrcline; /* initialize pixel-loop */ - pTempdst = (mng_uint16p)pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - - if (iX == 0) /* first interval ? */ - iM = iML; - else - if (iX == (iWidth - 1)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - - for (iS = 1; iS < iM; iS++) /* fill interval */ - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - } - - pTempsrc1 += 3; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB16_X1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgb16_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM; - mng_uint16p pTempsrc1; - mng_uint16p pTempsrc2; - mng_uint16p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB16_X2, MNG_LC_START); -#endif - - pTempsrc1 = (mng_uint16p)pSrcline; /* initialize pixel-loop */ - pTempdst = (mng_uint16p)pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 3; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = (mng_int32)iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = (mng_int32)iMR; - else - iM = (mng_int32)iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - for (iS = 1; iS < iM; iS++) - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)(((2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1); - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)(((2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc2+1))) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+1))) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+1))) ) ); - - pTempdst++; - - if (*(pTempsrc1+2) == *(pTempsrc2+2)) - *pTempdst = *(pTempsrc1+2); - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)(((2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc2+2))) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+2))) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+2))) ) ); - - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - } - } - } - - pTempsrc1 += 3; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB16_X2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgb16_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint16p pTempsrc1; - mng_uint16p pTempsrc2; - mng_uint16p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB16_X3, MNG_LC_START); -#endif - - pTempsrc1 = (mng_uint16p)pSrcline; /* initialize pixel-loop */ - pTempdst = (mng_uint16p)pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 3; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = (mng_int32)iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = (mng_int32)iMR; - else - iM = (mng_int32)iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* replicate first half */ - { - *pTempdst = *pTempsrc1; - *(pTempdst+1) = *(pTempsrc1+1); - *(pTempdst+2) = *(pTempsrc1+2); - - pTempdst += 3; - } - - for (iS = iH; iS < iM; iS++) /* replicate second half */ - { - *pTempdst = *pTempsrc2; - *(pTempdst+1) = *(pTempsrc2+1); - *(pTempdst+2) = *(pTempsrc2+2); - - pTempdst += 3; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - } - } - } - - pTempsrc1 += 3; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB16_X3, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_GRAY_SUPPORT -mng_retcode mng_magnify_ga16_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX, iS, iM; - mng_uint16p pTempsrc1; - mng_uint16p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA16_X1, MNG_LC_START); -#endif - - pTempsrc1 = (mng_uint16p) pSrcline; /* initialize pixel-loop */ - pTempdst = (mng_uint16p)pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - - if (iX == 0) /* first interval ? */ - iM = iML; - else - if (iX == (iWidth - 1)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - - for (iS = 1; iS < iM; iS++) /* fill interval */ - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - } - - pTempsrc1 += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA16_X1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_ga16_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM; - mng_uint16p pTempsrc1; - mng_uint16p pTempsrc2; - mng_uint16p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA16_X2, MNG_LC_START); -#endif - - pTempsrc1 = (mng_uint16p)pSrcline; /* initialize pixel-loop */ - pTempdst = (mng_uint16p)pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 2; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - for (iS = 1; iS < iM; iS++) - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)(((2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1); - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)(((2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc2+1))) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+1))) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+1))) ) ); - - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - } - } - } - - pTempsrc1 += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA16_X2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_ga16_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint16p pTempsrc1; - mng_uint16p pTempsrc2; - mng_uint16p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA16_X3, MNG_LC_START); -#endif - - pTempsrc1 = (mng_uint16p)pSrcline; /* initialize pixel-loop */ - pTempdst = (mng_uint16p)pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 2; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* replicate first half */ - { - *pTempdst = *pTempsrc1; - *(pTempdst+1) = *(pTempsrc1+1); - - pTempdst += 2; - } - - for (iS = iH; iS < iM; iS++) /* replicate second half */ - { - *pTempdst = *pTempsrc2; - *(pTempdst+1) = *(pTempsrc2+1); - - pTempdst += 2; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - } - } - } - - pTempsrc1 += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA16_X3, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_ga16_x4 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint16p pTempsrc1; - mng_uint16p pTempsrc2; - mng_uint16p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA16_X4, MNG_LC_START); -#endif - - pTempsrc1 = (mng_uint16p)pSrcline; /* initialize pixel-loop */ - pTempdst = (mng_uint16p)pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 2; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* first half */ - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)(((2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - - *pTempdst = *(pTempsrc1+1); /* replicate alpha from left */ - - pTempdst++; - } - - for (iS = iH; iS < iM; iS++) /* second half */ - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)(((2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - - *pTempdst = *(pTempsrc2+1); /* replicate alpha from right */ - - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - } - } - } - - pTempsrc1 += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA16_X4, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_ga16_x5 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint16p pTempsrc1; - mng_uint16p pTempsrc2; - mng_uint16p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA16_X5, MNG_LC_START); -#endif - - pTempsrc1 = (mng_uint16p)pSrcline; /* initialize pixel-loop */ - pTempdst = (mng_uint16p)pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 2; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* first half */ - { - *pTempdst = *pTempsrc1; /* replicate gray from left */ - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1);/* just repeat the first */ - else /* calculate the distance */ - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)(((2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc2+1))) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+1))) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+1))) ) ); - - pTempdst++; - } - - for (iS = iH; iS < iM; iS++) /* second half */ - { - *pTempdst = *pTempsrc2; /* replicate gray from right */ - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1);/* just repeat the first */ - else /* calculate the distance */ - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)(((2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc2+1))) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+1))) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+1))) ) ); - - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - } - } - } - - pTempsrc1 += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA16_X5, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_GRAY_SUPPORT */ - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgba16_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX, iS, iM; - mng_uint16p pTempsrc1; - mng_uint16p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA16_X1, MNG_LC_START); -#endif - - pTempsrc1 = (mng_uint16p)pSrcline; /* initialize pixel-loop */ - pTempdst = (mng_uint16p)pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - - if (iX == 0) /* first interval ? */ - iM = iML; - else - if (iX == (iWidth - 1)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - - for (iS = 1; iS < iM; iS++) /* fill interval */ - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - } - - pTempsrc1 += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA16_X1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgba16_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM; - mng_uint16p pTempsrc1; - mng_uint16p pTempsrc2; - mng_uint16p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA16_X2, MNG_LC_START); -#endif - - pTempsrc1 = (mng_uint16p)pSrcline; /* initialize pixel-loop */ - pTempdst = (mng_uint16p)pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 4; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = (mng_int32)iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = (mng_int32)iMR; - else - iM = (mng_int32)iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - for (iS = 1; iS < iM; iS++) - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)(((2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1); - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)(((2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc2+1))) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+1))) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+1))) ) ); - - pTempdst++; - - if (*(pTempsrc1+2) == *(pTempsrc2+2)) - *pTempdst = *(pTempsrc1+2); - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)(((2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc2+2))) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+2))) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+2))) ) ); - - pTempdst++; - - if (*(pTempsrc1+3) == *(pTempsrc2+3)) - *pTempdst = *(pTempsrc1+3); - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)(((2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc2+3))) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+3))) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+3))) ) ); - - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - } - } - } - - pTempsrc1 += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA16_X2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgba16_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint16p pTempsrc1; - mng_uint16p pTempsrc2; - mng_uint16p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA16_X3, MNG_LC_START); -#endif - - pTempsrc1 = (mng_uint16p)pSrcline; /* initialize pixel-loop */ - pTempdst = (mng_uint16p)pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 4; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = (mng_int32)iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = (mng_int32)iMR; - else - iM = (mng_int32)iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* replicate first half */ - { - *pTempdst = *pTempsrc1; - *(pTempdst+1) = *(pTempsrc1+1); - *(pTempdst+2) = *(pTempsrc1+2); - *(pTempdst+3) = *(pTempsrc1+3); - - pTempdst += 4; - } - - for (iS = iH; iS < iM; iS++) /* replicate second half */ - { - *pTempdst = *pTempsrc2; - *(pTempdst+1) = *(pTempsrc2+1); - *(pTempdst+2) = *(pTempsrc2+2); - *(pTempdst+3) = *(pTempsrc2+3); - - pTempdst += 4; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - } - } - } - - pTempsrc1 += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA16_X3, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgba16_x4 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint16p pTempsrc1; - mng_uint16p pTempsrc2; - mng_uint16p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA16_X4, MNG_LC_START); -#endif - - pTempsrc1 = (mng_uint16p)pSrcline; /* initialize pixel-loop */ - pTempdst = (mng_uint16p)pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 4; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = (mng_int32)iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = (mng_int32)iMR; - else - iM = (mng_int32)iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* first half */ - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)(((2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1); - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)(((2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc2+1))) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+1))) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+1))) ) ); - - pTempdst++; - - if (*(pTempsrc1+2) == *(pTempsrc2+2)) - *pTempdst = *(pTempsrc1+2); - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)(((2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc2+2))) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+2))) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+2))) ) ); - - pTempdst++; - /* replicate alpha from left */ - *pTempdst = *(pTempsrc1+3); - - pTempdst++; - } - - for (iS = iH; iS < iM; iS++) /* second half */ - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)(((2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1); - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)(((2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc2+1))) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+1))) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+1))) ) ); - - pTempdst++; - - if (*(pTempsrc1+2) == *(pTempsrc2+2)) - *pTempdst = *(pTempsrc1+2); - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)(((2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc2+2))) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+2))) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+2))) ) ); - - pTempdst++; - /* replicate alpha from right */ - *pTempdst = *(pTempsrc2+3); - - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - } - } - } - - pTempsrc1 += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA16_X4, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgba16_x5 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint16p pTempsrc1; - mng_uint16p pTempsrc2; - mng_uint16p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA16_X5, MNG_LC_START); -#endif - - pTempsrc1 = (mng_uint16p)pSrcline; /* initialize pixel-loop */ - pTempdst = (mng_uint16p)pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 4; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = (mng_int32)iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = (mng_int32)iMR; - else - iM = (mng_int32)iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* first half */ - { - *pTempdst = *pTempsrc1; /* replicate color from left */ - *(pTempdst+1) = *(pTempsrc1+1); - *(pTempdst+2) = *(pTempsrc1+2); - - if (*(pTempsrc1+3) == *(pTempsrc2+3)) - *(pTempdst+3) = *(pTempsrc1+3); - else - mng_put_uint16 ((mng_uint8p)(pTempdst+3), - (mng_uint16)(((2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc2+3))) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+3))) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+3))) ) ); - - pTempdst += 4; - } - - for (iS = iH; iS < iM; iS++) /* second half */ - { - *pTempdst = *pTempsrc2; /* replicate color from right */ - *(pTempdst+1) = *(pTempsrc2+1); - *(pTempdst+2) = *(pTempsrc2+2); - - if (*(pTempsrc1+3) == *(pTempsrc2+3)) - *(pTempdst+3) = *(pTempsrc1+3); - else - mng_put_uint16 ((mng_uint8p)(pTempdst+3), - (mng_uint16)(((2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc2+3))) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+3))) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)(pTempsrc1+3))) ) ); - - pTempdst += 4; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - } - } - } - - pTempsrc1 += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA16_X4, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_GRAY_SUPPORT -mng_retcode mng_magnify_g16_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G16_Y1, MNG_LC_START); -#endif - - MNG_COPY (pDstline, pSrcline1, (iWidth << 1)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G16_Y1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_g16_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint16p pTempsrc1; - mng_uint16p pTempsrc2; - mng_uint16p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G16_Y2, MNG_LC_START); -#endif - - pTempsrc1 = (mng_uint16p)pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = (mng_uint16p)pSrcline2; - pTempdst = (mng_uint16p)pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)( ( (2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, (iWidth << 1)); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G16_Y2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_g16_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G16_Y3, MNG_LC_START); -#endif - - if (pSrcline2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - MNG_COPY (pDstline, pSrcline1, (iWidth << 1)) - else - MNG_COPY (pDstline, pSrcline2, (iWidth << 1)); - } - else - { /* just repeat the entire line */ - MNG_COPY (pDstline, pSrcline1, (iWidth << 1)); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G16_Y3, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_GRAY_SUPPORT */ - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgb16_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB16_Y1, MNG_LC_START); -#endif - - MNG_COPY (pDstline, pSrcline1, iWidth * 6); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB16_Y1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgb16_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint16p pTempsrc1; - mng_uint16p pTempsrc2; - mng_uint16p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB16_Y2, MNG_LC_START); -#endif - - pTempsrc1 = (mng_uint16p)pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = (mng_uint16p)pSrcline2; - pTempdst = (mng_uint16p)pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)( ( (2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)( ( (2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)( ( (2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, iWidth * 6); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB16_Y2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgb16_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB16_Y3, MNG_LC_START); -#endif - - if (pSrcline2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - MNG_COPY (pDstline, pSrcline1, iWidth * 6) - else - MNG_COPY (pDstline, pSrcline2, iWidth * 6); - } - else - { /* just repeat the entire line */ - MNG_COPY (pDstline, pSrcline1, iWidth * 6); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB16_Y3, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_GRAY_SUPPORT -mng_retcode mng_magnify_ga16_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA16_Y1, MNG_LC_START); -#endif - - MNG_COPY (pDstline, pSrcline1, (iWidth << 2)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA16_Y1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_ga16_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint16p pTempsrc1; - mng_uint16p pTempsrc2; - mng_uint16p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA16_Y2, MNG_LC_START); -#endif - - pTempsrc1 = (mng_uint16p)pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = (mng_uint16p)pSrcline2; - pTempdst = (mng_uint16p)pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)( ( (2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)( ( (2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, (iWidth << 2)); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA16_Y2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_ga16_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA16_Y3, MNG_LC_START); -#endif - - if (pSrcline2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - MNG_COPY (pDstline, pSrcline1, (iWidth << 2)) - else - MNG_COPY (pDstline, pSrcline2, (iWidth << 2)); - } - else - { /* just repeat the entire line */ - MNG_COPY (pDstline, pSrcline1, (iWidth << 2)); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA16_Y2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_ga16_y4 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint16p pTempsrc1; - mng_uint16p pTempsrc2; - mng_uint16p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA16_Y4, MNG_LC_START); -#endif - - pTempsrc1 = (mng_uint16p)pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = (mng_uint16p)pSrcline2; - pTempdst = (mng_uint16p)pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)( ( (2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2 += 2; - - *pTempdst++ = *pTempsrc1++; /* replicate alpha from top */ - } - } - else - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)( ( (2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - pTempsrc1 += 2; - pTempsrc2++; - - *pTempdst++ = *pTempsrc2++; /* replicate alpha from bottom */ - } - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, (iWidth << 2)); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA16_Y4, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_ga16_y5 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint16p pTempsrc1; - mng_uint16p pTempsrc2; - mng_uint16p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA16_Y5, MNG_LC_START); -#endif - - pTempsrc1 = (mng_uint16p)pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = (mng_uint16p)pSrcline2; - pTempdst = (mng_uint16p)pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - { - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst = *pTempsrc1; /* replicate gray from top */ - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) /* calculate the distances */ - *pTempdst = *pTempsrc1; - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)( ( (2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - else - { - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst = *pTempsrc2; /* replicate gray from bottom */ - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) /* calculate the distances */ - *pTempdst = *pTempsrc1; - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)( ( (2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, (iWidth << 2)); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA16_Y5, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_GRAY_SUPPORT */ - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgba16_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA16_Y1, MNG_LC_START); -#endif - - MNG_COPY (pDstline, pSrcline1, (iWidth << 3)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA16_Y1, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgba16_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint16p pTempsrc1; - mng_uint16p pTempsrc2; - mng_uint16p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA16_Y2, MNG_LC_START); -#endif - - pTempsrc1 = (mng_uint16p)pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = (mng_uint16p)pSrcline2; - pTempdst = (mng_uint16p)pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)( ( (2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)( ( (2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)( ( (2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)( ( (2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, (iWidth << 3)); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA16_Y2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgba16_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA16_Y3, MNG_LC_START); -#endif - - if (pSrcline2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - MNG_COPY (pDstline, pSrcline1, (iWidth << 3)) - else - MNG_COPY (pDstline, pSrcline2, (iWidth << 3)); - } - else - { /* just repeat the entire line */ - MNG_COPY (pDstline, pSrcline1, (iWidth << 3)); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA16_Y2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgba16_y4 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint16p pTempsrc1; - mng_uint16p pTempsrc2; - mng_uint16p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA16_Y4, MNG_LC_START); -#endif - - pTempsrc1 = (mng_uint16p)pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = (mng_uint16p)pSrcline2; - pTempdst = (mng_uint16p)pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)( ( (2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)( ( (2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)( ( (2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2 += 2; - - *pTempdst++ = *pTempsrc1++; /* replicate alpha from top */ - } - } - else - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)( ( (2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)( ( (2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)( ( (2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - pTempsrc1 += 2; - pTempsrc2++; - - *pTempdst++ = *pTempsrc2++; /* replicate alpha from bottom */ - } - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, (iWidth << 3)); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA16_Y4, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_magnify_rgba16_y5 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint16p pTempsrc1; - mng_uint16p pTempsrc2; - mng_uint16p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA16_Y5, MNG_LC_START); -#endif - - pTempsrc1 = (mng_uint16p)pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = (mng_uint16p)pSrcline2; - pTempdst = (mng_uint16p)pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - { - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst++ = *pTempsrc1++; /* replicate color from top */ - *pTempdst++ = *pTempsrc1++; - *pTempdst++ = *pTempsrc1++; - - pTempsrc2 += 3; - - if (*pTempsrc1 == *pTempsrc2) /* calculate the distances */ - *pTempdst = *pTempsrc1; - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)( ( (2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - else - { - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst++ = *pTempsrc2++; /* replicate color from bottom */ - *pTempdst++ = *pTempsrc2++; - *pTempdst++ = *pTempsrc2++; - - pTempsrc1 += 3; - - if (*pTempsrc1 == *pTempsrc2) /* calculate the distances */ - *pTempdst = *pTempsrc1; - else - mng_put_uint16 ((mng_uint8p)pTempdst, - (mng_uint16)( ( (2 * iS * ( (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc2)) - - (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) + iM) / - (iM * 2)) + (mng_int32)(mng_get_uint16 ((mng_uint8p)pTempsrc1)) ) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, (iWidth << 3)); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA16_Y5, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_NO_16BIT_SUPPORT */ -#endif /* MNG_OPTIMIZE_FOOTPRINT_MAGN */ -#endif /* MNG_SKIPCHUNK_MAGN */ - -/* ************************************************************************** */ -/* * * */ -/* * PAST composition routines - compose over/under with a target object * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_PAST -mng_retcode mng_composeover_rgba8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iFGa8, iBGa8; - mng_uint8 iCr8, iCg8, iCb8, iCa8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_COMPOSEOVER_RGBA8, MNG_LC_START); -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - iFGa8 = *(pWorkrow+3); /* get alpha values */ - iBGa8 = *(pOutrow+3); - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pOutrow = *pWorkrow; - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - *(pOutrow+3) = iFGa8; - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do alpha composing */ -#ifdef MNG_OPTIMIZE_FOOTPRINT_COMPOSE - int i; - for (i=2; i >= 0; i--) - { - MNG_COMPOSE8 (*(pOutrow+i), *(pWorkrow+i), iFGa8, *(pOutrow+i)); - } -#else - MNG_COMPOSE8 (*pOutrow, *pWorkrow, iFGa8, *pOutrow ); - MNG_COMPOSE8 (*(pOutrow+1), *(pWorkrow+1), iFGa8, *(pOutrow+1)); - MNG_COMPOSE8 (*(pOutrow+2), *(pWorkrow+2), iFGa8, *(pOutrow+2)); -#endif - /* alpha remains fully opaque !!! */ - } - else - { /* here we'll have to blend */ - MNG_BLEND8 (*pWorkrow, *(pWorkrow+1), *(pWorkrow+2), iFGa8, - *pOutrow, *(pOutrow+1), *(pOutrow+2), iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - *pOutrow = iCr8; - *(pOutrow+1) = iCg8; - *(pOutrow+2) = iCb8; - *(pOutrow+3) = iCa8; - } - } - } - - pOutrow += 4; - pWorkrow += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_COMPOSEOVER_RGBA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_composeover_rgba16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint16p pWorkrow; - mng_uint16p pOutrow; - mng_int32 iX; - mng_uint16 iFGa16, iFGr16, iFGg16, iFGb16; - mng_uint16 iBGa16, iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16, iCa16; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_COMPOSEOVER_RGBA16, MNG_LC_START); -#endif - - pWorkrow = (mng_uint16p)pData->pRGBArow; - pOutrow = (mng_uint16p)(pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize)); - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { /* get alpha values */ - iFGa16 = mng_get_uint16 ((mng_uint8p)(pWorkrow+3)); - iBGa16 = mng_get_uint16 ((mng_uint8p)(pOutrow+3)); - - if (iFGa16) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa16 == 0xFFFF) || (iBGa16 == 0)) - { /* then simply copy the values */ - *pOutrow = *pWorkrow; - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - *(pOutrow+3) = *(pWorkrow+3); - } - else - { /* get color values */ - iFGr16 = mng_get_uint16 ((mng_uint8p)pWorkrow); - iFGg16 = mng_get_uint16 ((mng_uint8p)(pWorkrow+1)); - iFGb16 = mng_get_uint16 ((mng_uint8p)(pWorkrow+2)); - iBGr16 = mng_get_uint16 ((mng_uint8p)pOutrow); - iBGg16 = mng_get_uint16 ((mng_uint8p)(pOutrow+1)); - iBGb16 = mng_get_uint16 ((mng_uint8p)(pOutrow+2)); - - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* do alpha composing */ - MNG_COMPOSE16 (iFGr16, iFGr16, iFGa16, iBGr16); - MNG_COMPOSE16 (iFGg16, iFGg16, iFGa16, iBGg16); - MNG_COMPOSE16 (iFGb16, iFGb16, iFGa16, iBGb16); - - mng_put_uint16 ((mng_uint8p)pOutrow, iFGr16); - mng_put_uint16 ((mng_uint8p)(pOutrow+1), iFGg16); - mng_put_uint16 ((mng_uint8p)(pOutrow+2), iFGb16); - /* alpha remains fully opaque !!! */ - } - else - { /* here we'll have to blend */ - MNG_BLEND16 (iFGr16, iFGg16, iFGb16, iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16); - /* and return the composed values */ - mng_put_uint16 ((mng_uint8p)pOutrow, iCr16); - mng_put_uint16 ((mng_uint8p)(pOutrow+1), iCg16); - mng_put_uint16 ((mng_uint8p)(pOutrow+2), iCb16); - mng_put_uint16 ((mng_uint8p)(pOutrow+3), iCa16); - } - } - } - - pOutrow += 4; - pWorkrow += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_COMPOSEOVER_RGBA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_composeunder_rgba8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iFGa8, iBGa8; - mng_uint8 iCr8, iCg8, iCb8, iCa8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_COMPOSEUNDER_RGBA8, MNG_LC_START); -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { - iFGa8 = *(pOutrow+3); /* get alpha values */ - iBGa8 = *(pWorkrow+3); - /* anything to do at all ? */ - if ((iBGa8) && (iFGa8 != 0xFF)) - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do alpha composing */ -#ifdef MNG_OPTIMIZE_FOOTPRINT_COMPOSE - int i; - for (i=2; i >= 0; i--) - { - MNG_COMPOSE8 (*(pOutrow+i), *(pOutrow+i), iFGa8, *(pWorkrow+i)); - } -#else - MNG_COMPOSE8 (*pOutrow, *pOutrow, iFGa8, *pWorkrow ); - MNG_COMPOSE8 (*(pOutrow+1), *(pOutrow+1), iFGa8, *(pWorkrow+1)); - MNG_COMPOSE8 (*(pOutrow+2), *(pOutrow+2), iFGa8, *(pWorkrow+2)); -#endif - *(pOutrow+3) = 0xFF; /* alpha becomes fully opaque !!! */ - } - else - { /* here we'll have to blend */ - MNG_BLEND8 (*pOutrow, *(pOutrow+1), *(pOutrow+2), iFGa8, - *pWorkrow, *(pWorkrow+1), *(pWorkrow+2), iBGa8, - iCr8, iCg8, iCb8, iCa8); - /* and return the composed values */ - *pOutrow = iCr8; - *(pOutrow+1) = iCg8; - *(pOutrow+2) = iCb8; - *(pOutrow+3) = iCa8; - } - } - - pOutrow += 4; - pWorkrow += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_COMPOSEUNDER_RGBA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_composeunder_rgba16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint16p pWorkrow; - mng_uint16p pOutrow; - mng_int32 iX; - mng_uint16 iFGa16, iFGr16, iFGg16, iFGb16; - mng_uint16 iBGa16, iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16, iCa16; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_COMPOSEUNDER_RGBA16, MNG_LC_START); -#endif - - pWorkrow = (mng_uint16p)pData->pRGBArow; - pOutrow = (mng_uint16p)(pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize)); - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { /* get alpha values */ - iFGa16 = mng_get_uint16 ((mng_uint8p)(pOutrow+3)); - iBGa16 = mng_get_uint16 ((mng_uint8p)(pWorkrow+3)); - /* anything to do at all ? */ - if ((iBGa16) && (iFGa16 != 0xFFFF)) - { - iFGr16 = mng_get_uint16 ((mng_uint8p)pOutrow); - iFGg16 = mng_get_uint16 ((mng_uint8p)(pOutrow+1)); - iFGb16 = mng_get_uint16 ((mng_uint8p)(pOutrow+2)); - iBGr16 = mng_get_uint16 ((mng_uint8p)pWorkrow); - iBGg16 = mng_get_uint16 ((mng_uint8p)(pWorkrow+1)); - iBGb16 = mng_get_uint16 ((mng_uint8p)(pWorkrow+2)); - - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* do alpha composing */ - MNG_COMPOSE16 (iFGr16, iFGr16, iFGa16, iBGr16); - MNG_COMPOSE16 (iFGg16, iFGg16, iFGa16, iBGg16); - MNG_COMPOSE16 (iFGb16, iFGb16, iFGa16, iBGb16); - - mng_put_uint16 ((mng_uint8p)pOutrow, iFGr16); - mng_put_uint16 ((mng_uint8p)(pOutrow+1), iFGg16); - mng_put_uint16 ((mng_uint8p)(pOutrow+2), iFGb16); - *(pOutrow+3) = 0xFFFF; /* alpha becomes fully opaque !!! */ - } - else - { /* here we'll have to blend */ - MNG_BLEND16 (iFGr16, iFGg16, iFGb16, iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16); - /* and return the composed values */ - mng_put_uint16 ((mng_uint8p)pOutrow, iCr16); - mng_put_uint16 ((mng_uint8p)(pOutrow+1), iCg16); - mng_put_uint16 ((mng_uint8p)(pOutrow+2), iCb16); - mng_put_uint16 ((mng_uint8p)(pOutrow+3), iCa16); - } - } - - pOutrow += 4; - pWorkrow += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_COMPOSEUNDER_RGBA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif - -/* ************************************************************************** */ -/* * * */ -/* * PAST flip & tile routines - flip or tile a row of pixels * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_PAST -mng_retcode mng_flip_rgba8 (mng_datap pData) -{ - mng_uint32p pWorkrow; - mng_uint32p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FLIP_RGBA8, MNG_LC_START); -#endif - /* setup temp pointers */ - pWorkrow = (mng_uint32p)pData->pRGBArow + pData->iRowsamples - 1; - pOutrow = (mng_uint32p)pData->pWorkrow; - /* swap original buffers */ - pData->pWorkrow = pData->pRGBArow; - pData->pRGBArow = (mng_uint8p)pOutrow; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { /* let's flip */ - *pOutrow = *pWorkrow; - pOutrow++; - pWorkrow--; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FLIP_RGBA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_flip_rgba16 (mng_datap pData) -{ - mng_uint32p pWorkrow; - mng_uint32p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FLIP_RGBA16, MNG_LC_START); -#endif - /* setup temp pointers */ - pWorkrow = (mng_uint32p)pData->pRGBArow + ((pData->iRowsamples - 1) << 1); - pOutrow = (mng_uint32p)pData->pWorkrow; - /* swap original buffers */ - pData->pWorkrow = pData->pRGBArow; - pData->pRGBArow = (mng_uint8p)pOutrow; - -#ifdef MNG_DECREMENT_LOOPS - for (iX = pData->iRowsamples; iX > 0; iX--) -#else - for (iX = 0; iX < pData->iRowsamples; iX++) -#endif - { /* let's flip */ - *pOutrow = *pWorkrow; - *(pOutrow + 1) = *(pWorkrow + 1); - - pOutrow += 2; - pWorkrow -= 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FLIP_RGBA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode mng_tile_rgba8 (mng_datap pData) -{ - mng_uint32p pWorkrow; - mng_uint32p pOutrow; - mng_int32 iX; - mng_uint32 iZ, iMax; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_TILE_RGBA8, MNG_LC_START); -#endif - - iZ = pData->iSourcel; /* indent ? */ - /* what's our source-length */ - iMax = ((mng_imagep)pData->pRetrieveobj)->pImgbuf->iWidth; - /* setup temp pointers */ - pWorkrow = (mng_uint32p)pData->pRGBArow + iZ; - pOutrow = (mng_uint32p)pData->pWorkrow; - /* swap original buffers */ - pData->pWorkrow = pData->pRGBArow; - pData->pRGBArow = (mng_uint8p)pOutrow; - - for (iX = pData->iDestl; iX < pData->iDestr; iX++) - { /* tiiiile */ - *pOutrow = *pWorkrow; - - pWorkrow++; - pOutrow++; - iZ++; - - if (iZ >= iMax) /* end of source ? */ - { - iZ = 0; - pWorkrow = (mng_uint32p)pData->pWorkrow; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_TILE_RGBA8, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_tile_rgba16 (mng_datap pData) -{ - mng_uint32p pWorkrow; - mng_uint32p pOutrow; - mng_int32 iX; - mng_uint32 iZ, iMax; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_TILE_RGBA16, MNG_LC_START); -#endif - - iZ = pData->iSourcel; /* indent ? */ - /* what's our source-length */ - iMax = ((mng_imagep)pData->pRetrieveobj)->pImgbuf->iWidth; - /* setup temp pointers */ - pWorkrow = (mng_uint32p)pData->pRGBArow + (iZ << 1); - pOutrow = (mng_uint32p)pData->pWorkrow; - /* swap original buffers */ - pData->pWorkrow = pData->pRGBArow; - pData->pRGBArow = (mng_uint8p)pOutrow; - - for (iX = pData->iDestl; iX < pData->iDestr; iX++) - { /* tiiiile */ - *pOutrow = *pWorkrow; - *(pOutrow + 1) = *(pWorkrow + 1); - - pWorkrow += 2; - pOutrow += 2; - iZ++; - - if (iZ >= iMax) /* end of source ? */ - { - iZ = 0; - pWorkrow = (mng_uint32p)pData->pWorkrow; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_TILE_RGBA16, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif /* MNG_SKIPCHUNK_PAST */ - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_DISPLAY_PROCS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/plugins/AdvaImg/src/LibMNG/libmng_pixels.h b/plugins/AdvaImg/src/LibMNG/libmng_pixels.h deleted file mode 100644 index 203d1c1f99..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_pixels.h +++ /dev/null @@ -1,1147 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_pixels.h copyright (c) 2000-2006 G.Juyn * */ -/* * version : 1.0.10 * */ -/* * * */ -/* * purpose : Pixel-row management routines (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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 * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN support * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added optional support for bKGD for PNG images * */ -/* * - added support for JDAA * */ -/* * 0.9.3 - 10/19/2000 - G.Juyn * */ -/* * - implemented delayed delta-processing * */ -/* * * */ -/* * 0.9.4 - 1/18/2001 - G.Juyn * */ -/* * - added "new" MAGN methods 3, 4 & 5 * */ -/* * * */ -/* * 1.0.1 - 04/21/2001 - G.Juyn (code by G.Kelly) * */ -/* * - added BGRA8 canvas with premultiplied alpha * */ -/* * * */ -/* * 1.0.5 - 08/15/2002 - G.Juyn * */ -/* * - completed PROM support * */ -/* * - completed delta-image support * */ -/* * 1.0.5 - 08/16/2002 - G.Juyn * */ -/* * - completed MAGN support (16-bit functions) * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * 1.0.5 - 09/22/2002 - G.Juyn * */ -/* * - added bgrx8 canvas (filler byte) * */ -/* * 1.0.5 - 09/23/2002 - G.Juyn * */ -/* * - added compose over/under routines for PAST processing * */ -/* * - added flip & tile routines for PAST processing * */ -/* * * */ -/* * 1.0.6 - 03/09/2003 - G.Juyn * */ -/* * - hiding 12-bit JPEG stuff * */ -/* * 1.0.6 - 05/11/2003 - G. Juyn * */ -/* * - added conditionals around canvas update routines * */ -/* * 1.0.6 - 06/09/2003 - G. R-P * */ -/* * - added conditionals around 8-bit magn routines * */ -/* * 1.0.6 - 07/07/2003 - G. R-P * */ -/* * - removed conditionals around 8-bit magn routines * */ -/* * - added conditionals around 16-bit and delta-PNG * */ -/* * supporting code * */ -/* * 1.0.6 - 07/29/2003 - G.R-P * */ -/* * - added SKIPCHUNK conditionals around PAST chunk support * */ -/* * 1.0.6 - 08/18/2003 - G.R-P * */ -/* * - added conditionals around 1, 2, and 4-bit prototypes * */ -/* * * */ -/* * 1.0.7 - 11/27/2003 - R.A * */ -/* * - added CANVAS_RGB565 and CANVAS_BGR565 * */ -/* * 1.0.7 - 12/06/2003 - R.A * */ -/* * - added CANVAS_RGBA565 and CANVAS_BGRA565 * */ -/* * 1.0.7 - 01/25/2004 - J.S * */ -/* * - added premultiplied alpha canvas' for RGBA, ARGB, ABGR * */ -/* * * */ -/* * 1.0.9 - 10/10/2004 - G.R-P. * */ -/* * - added MNG_NO_1_2_4BIT_SUPPORT * */ -/* * 1.0.9 - 10/14/2004 - G.Juyn * */ -/* * - added bgr565_a8 canvas-style (thanks to J. Elvander) * */ -/* * * */ -/* * 1.0.10 - 03/07/2006 - (thanks to W. Manthey) * */ -/* * - added CANVAS_RGB555 and CANVAS_BGR555 * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_pixels_h_ -#define _libmng_pixels_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 mng_display_progressive_check (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * Display routines - convert rowdata (which is already color-corrected) * */ -/* * to the output canvas, respecting any transparency information * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_SKIPCANVAS_RGB8 -mng_retcode mng_display_rgb8 (mng_datap pData); -#endif -#ifndef MNG_SKIPCANVAS_RGBA8 -mng_retcode mng_display_rgba8 (mng_datap pData); -#endif -#ifndef MNG_SKIPCANVAS_RGBA8_PM -mng_retcode mng_display_rgba8_pm (mng_datap pData); -#endif -#ifndef MNG_SKIPCANVAS_ARGB8 -mng_retcode mng_display_argb8 (mng_datap pData); -#endif -#ifndef MNG_SKIPCANVAS_ARGB8_PM -mng_retcode mng_display_argb8_pm (mng_datap pData); -#endif -#ifndef MNG_SKIPCANVAS_RGB8_A8 -mng_retcode mng_display_rgb8_a8 (mng_datap pData); -#endif -#ifndef MNG_SKIPCANVAS_BGR8 -mng_retcode mng_display_bgr8 (mng_datap pData); -#endif -#ifndef MNG_SKIPCANVAS_BGRX8 -mng_retcode mng_display_bgrx8 (mng_datap pData); -#endif -#ifndef MNG_SKIPCANVAS_BGRA8 -mng_retcode mng_display_bgra8 (mng_datap pData); -#endif -#ifndef MNG_SKIPCANVAS_BGRA8_PM -mng_retcode mng_display_bgra8_pm (mng_datap pData); -#endif -#ifndef MNG_SKIPCANVAS_ABGR8 -mng_retcode mng_display_abgr8 (mng_datap pData); -#endif -#ifndef MNG_SKIPCANVAS_ABGR8_PM -mng_retcode mng_display_abgr8_pm (mng_datap pData); -#endif -#ifndef MNG_SKIPCANVAS_RGB565 -mng_retcode mng_display_rgb565 (mng_datap pData); -#endif -#ifndef MNG_SKIPCANVAS_RGBA565 -mng_retcode mng_display_rgba565 (mng_datap pData); -#endif -#ifndef MNG_SKIPCANVAS_BGR565 -mng_retcode mng_display_bgr565 (mng_datap pData); -#endif -#ifndef MNG_SKIPCANVAS_BGRA565 -mng_retcode mng_display_bgra565 (mng_datap pData); -#endif -#ifndef MNG_SKIPCANVAS_BGR565_A8 -mng_retcode mng_display_bgr565_a8 (mng_datap pData); -#endif -#ifndef MNG_SKIPCANVAS_RGB555 -mng_retcode mng_display_rgb555 (mng_datap pData); -#endif -#ifndef MNG_SKIPCANVAS_BGR555 -mng_retcode mng_display_bgr555 (mng_datap pData); -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Background restore routines - restore the background with info from * */ -/* * the BACK and/or bKGD chunk and/or the app's background canvas * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode mng_restore_bkgd_backimage (mng_datap pData); -mng_retcode mng_restore_bkgd_backcolor (mng_datap pData); -mng_retcode mng_restore_bkgd_bkgd (mng_datap pData); -mng_retcode mng_restore_bkgd_bgcolor (mng_datap pData); -#ifndef MNG_SKIPCANVAS_RGB8 -mng_retcode mng_restore_bkgd_rgb8 (mng_datap pData); -#endif -#ifndef MNG_SKIPCANVAS_BGR8 -mng_retcode mng_restore_bkgd_bgr8 (mng_datap pData); -#endif -#ifndef MNG_SKIPCANVAS_BGRX8 -mng_retcode mng_restore_bkgd_bgrx8 (mng_datap pData); -#endif -#ifndef MNG_SKIPCANVAS_RGB565 -mng_retcode mng_restore_bkgd_rgb565 (mng_datap pData); -#endif -#ifndef MNG_SKIPCANVAS_BGR565 -mng_retcode mng_restore_bkgd_bgr565 (mng_datap pData); -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Row retrieval routines - retrieve processed & uncompressed row-data * */ -/* * from the current "object" * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode mng_retrieve_g8 (mng_datap pData); -mng_retcode mng_retrieve_rgb8 (mng_datap pData); -mng_retcode mng_retrieve_idx8 (mng_datap pData); -mng_retcode mng_retrieve_ga8 (mng_datap pData); -mng_retcode mng_retrieve_rgba8 (mng_datap pData); -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_retrieve_g16 (mng_datap pData); -mng_retcode mng_retrieve_ga16 (mng_datap pData); -mng_retcode mng_retrieve_rgb16 (mng_datap pData); -mng_retcode mng_retrieve_rgba16 (mng_datap pData); -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Row storage routines - store processed & uncompressed row-data * */ -/* * into the current "object" * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_store_g1 (mng_datap pData); -mng_retcode mng_store_g2 (mng_datap pData); -mng_retcode mng_store_g4 (mng_datap pData); -mng_retcode mng_store_idx1 (mng_datap pData); -mng_retcode mng_store_idx2 (mng_datap pData); -mng_retcode mng_store_idx4 (mng_datap pData); -#endif -mng_retcode mng_store_idx8 (mng_datap pData); -mng_retcode mng_store_rgb8 (mng_datap pData); -mng_retcode mng_store_g8 (mng_datap pData); -mng_retcode mng_store_ga8 (mng_datap pData); -mng_retcode mng_store_rgba8 (mng_datap pData); -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_store_g16 (mng_datap pData); -mng_retcode mng_store_ga16 (mng_datap pData); -mng_retcode mng_store_rgb16 (mng_datap pData); -mng_retcode mng_store_rgba16 (mng_datap pData); -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Row storage routines (JPEG) - store processed & uncompressed row-data * */ -/* * into the current "object" * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_retcode mng_store_jpeg_g8 (mng_datap pData); -mng_retcode mng_store_jpeg_rgb8 (mng_datap pData); -mng_retcode mng_store_jpeg_ga8 (mng_datap pData); -mng_retcode mng_store_jpeg_rgba8 (mng_datap pData); - -#ifdef MNG_SUPPORT_JPEG12 -mng_retcode mng_store_jpeg_g12 (mng_datap pData); -mng_retcode mng_store_jpeg_rgb12 (mng_datap pData); -mng_retcode mng_store_jpeg_ga12 (mng_datap pData); -mng_retcode mng_store_jpeg_rgba12 (mng_datap pData); -#endif - -mng_retcode mng_store_jpeg_g8_alpha (mng_datap pData); -mng_retcode mng_store_jpeg_rgb8_alpha (mng_datap pData); - -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_store_jpeg_g8_a1 (mng_datap pData); -mng_retcode mng_store_jpeg_g8_a2 (mng_datap pData); -mng_retcode mng_store_jpeg_g8_a4 (mng_datap pData); -#endif -mng_retcode mng_store_jpeg_g8_a8 (mng_datap pData); -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_store_jpeg_g8_a16 (mng_datap pData); -#endif - -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_store_jpeg_rgb8_a1 (mng_datap pData); -mng_retcode mng_store_jpeg_rgb8_a2 (mng_datap pData); -mng_retcode mng_store_jpeg_rgb8_a4 (mng_datap pData); -#endif -mng_retcode mng_store_jpeg_rgb8_a8 (mng_datap pData); -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_store_jpeg_rgb8_a16 (mng_datap pData); -#endif - -#ifdef MNG_SUPPORT_JPEG12 -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_store_jpeg_g12_a1 (mng_datap pData); -mng_retcode mng_store_jpeg_g12_a2 (mng_datap pData); -mng_retcode mng_store_jpeg_g12_a4 (mng_datap pData); -#endif -mng_retcode mng_store_jpeg_g12_a8 (mng_datap pData); -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_store_jpeg_g12_a16 (mng_datap pData); -#endif - -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_store_jpeg_rgb12_a1 (mng_datap pData); -mng_retcode mng_store_jpeg_rgb12_a2 (mng_datap pData); -mng_retcode mng_store_jpeg_rgb12_a4 (mng_datap pData); -#endif -mng_retcode mng_store_jpeg_rgb12_a8 (mng_datap pData); -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_store_jpeg_rgb12_a16 (mng_datap pData); -#endif -#endif -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Delta-image row routines - apply the processed & uncompressed row-data * */ -/* * onto the target "object" * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_delta_g1 (mng_datap pData); -mng_retcode mng_delta_g2 (mng_datap pData); -mng_retcode mng_delta_g4 (mng_datap pData); -#endif -mng_retcode mng_delta_g8 (mng_datap pData); -mng_retcode mng_delta_g16 (mng_datap pData); -mng_retcode mng_delta_rgb8 (mng_datap pData); -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_delta_rgb16 (mng_datap pData); -#endif -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_delta_idx1 (mng_datap pData); -mng_retcode mng_delta_idx2 (mng_datap pData); -mng_retcode mng_delta_idx4 (mng_datap pData); -#endif -mng_retcode mng_delta_idx8 (mng_datap pData); -mng_retcode mng_delta_ga8 (mng_datap pData); -mng_retcode mng_delta_rgba8 (mng_datap pData); -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_delta_ga16 (mng_datap pData); -mng_retcode mng_delta_rgba16 (mng_datap pData); -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Delta-image row routines - apply the source row onto the target * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_delta_g1_g1 (mng_datap pData); -mng_retcode mng_delta_g2_g2 (mng_datap pData); -mng_retcode mng_delta_g4_g4 (mng_datap pData); -#endif -mng_retcode mng_delta_g8_g8 (mng_datap pData); -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_delta_g16_g16 (mng_datap pData); -#endif -mng_retcode mng_delta_ga8_ga8 (mng_datap pData); -mng_retcode mng_delta_ga8_g8 (mng_datap pData); -mng_retcode mng_delta_ga8_a8 (mng_datap pData); -mng_retcode mng_delta_rgba8_rgb8 (mng_datap pData); -mng_retcode mng_delta_rgba8_a8 (mng_datap pData); -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_delta_ga16_ga16 (mng_datap pData); -mng_retcode mng_delta_ga16_g16 (mng_datap pData); -mng_retcode mng_delta_ga16_a16 (mng_datap pData); -mng_retcode mng_delta_rgba16_a16 (mng_datap pData); -mng_retcode mng_delta_rgba16_rgb16 (mng_datap pData); -#endif -#endif /* MNG_NO_DELTA_PNG */ -mng_retcode mng_delta_rgb8_rgb8 (mng_datap pData); /* Used for PAST */ -mng_retcode mng_delta_rgba8_rgba8 (mng_datap pData); -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_delta_rgb16_rgb16 (mng_datap pData); -mng_retcode mng_delta_rgba16_rgba16 (mng_datap pData); -#endif - -#ifndef MNG_NO_DELTA_PNG -/* ************************************************************************** */ -/* * * */ -/* * Delta-image row routines - scale the delta to bitdepth of target * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_scale_g1_g2 (mng_datap pData); -mng_retcode mng_scale_g1_g4 (mng_datap pData); -mng_retcode mng_scale_g1_g8 (mng_datap pData); -mng_retcode mng_scale_g2_g4 (mng_datap pData); -mng_retcode mng_scale_g2_g8 (mng_datap pData); -mng_retcode mng_scale_g4_g8 (mng_datap pData); -#endif -#ifndef MNG_NO_16BIT_SUPPORT -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_scale_g1_g16 (mng_datap pData); -mng_retcode mng_scale_g2_g16 (mng_datap pData); -mng_retcode mng_scale_g4_g16 (mng_datap pData); -#endif -mng_retcode mng_scale_g8_g16 (mng_datap pData); -mng_retcode mng_scale_ga8_ga16 (mng_datap pData); -mng_retcode mng_scale_rgb8_rgb16 (mng_datap pData); -mng_retcode mng_scale_rgba8_rgba16 (mng_datap pData); -#endif - -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_scale_g2_g1 (mng_datap pData); -mng_retcode mng_scale_g4_g1 (mng_datap pData); -mng_retcode mng_scale_g8_g1 (mng_datap pData); -mng_retcode mng_scale_g4_g2 (mng_datap pData); -mng_retcode mng_scale_g8_g2 (mng_datap pData); -mng_retcode mng_scale_g8_g4 (mng_datap pData); -#endif -#ifndef MNG_NO_16BIT_SUPPORT -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_scale_g16_g1 (mng_datap pData); -mng_retcode mng_scale_g16_g2 (mng_datap pData); -mng_retcode mng_scale_g16_g4 (mng_datap pData); -#endif -mng_retcode mng_scale_g16_g8 (mng_datap pData); -mng_retcode mng_scale_ga16_ga8 (mng_datap pData); -mng_retcode mng_scale_rgb16_rgb8 (mng_datap pData); -mng_retcode mng_scale_rgba16_rgba8 (mng_datap pData); -#endif -#endif /* MNG_NO_DELTA_PNG */ - -/* ************************************************************************** */ -/* * * */ -/* * Delta-image bit routines - promote bit_depth * */ -/* * * */ -/* ************************************************************************** */ - -mng_uint8 mng_promote_replicate_1_2 (mng_uint8 iB); -mng_uint8 mng_promote_replicate_1_4 (mng_uint8 iB); -mng_uint8 mng_promote_replicate_1_8 (mng_uint8 iB); -mng_uint8 mng_promote_replicate_2_4 (mng_uint8 iB); -mng_uint8 mng_promote_replicate_2_8 (mng_uint8 iB); -mng_uint8 mng_promote_replicate_4_8 (mng_uint8 iB); -#ifndef MNG_NO_16BIT_SUPPORT -mng_uint16 mng_promote_replicate_1_16 (mng_uint8 iB); -mng_uint16 mng_promote_replicate_2_16 (mng_uint8 iB); -mng_uint16 mng_promote_replicate_4_16 (mng_uint8 iB); -mng_uint16 mng_promote_replicate_8_16 (mng_uint8 iB); -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DELTA_PNG -mng_uint8 mng_promote_zerofill_1_2 (mng_uint8 iB); -mng_uint8 mng_promote_zerofill_1_4 (mng_uint8 iB); -mng_uint8 mng_promote_zerofill_1_8 (mng_uint8 iB); -mng_uint8 mng_promote_zerofill_2_4 (mng_uint8 iB); -mng_uint8 mng_promote_zerofill_2_8 (mng_uint8 iB); -mng_uint8 mng_promote_zerofill_4_8 (mng_uint8 iB); -#ifndef MNG_NO_16BIT_SUPPORT -mng_uint16 mng_promote_zerofill_1_16 (mng_uint8 iB); -mng_uint16 mng_promote_zerofill_2_16 (mng_uint8 iB); -mng_uint16 mng_promote_zerofill_4_16 (mng_uint8 iB); -mng_uint16 mng_promote_zerofill_8_16 (mng_uint8 iB); -#endif -#endif /* MNG_NO_DELTA_PNG */ - -/* ************************************************************************** */ -/* * * */ -/* * Delta-image row routines - promote color_type * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode mng_promote_g8_g8 (mng_datap pData); -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_promote_g8_g16 (mng_datap pData); -mng_retcode mng_promote_g16_g16 (mng_datap pData); -#endif - -mng_retcode mng_promote_g8_ga8 (mng_datap pData); -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_promote_g8_ga16 (mng_datap pData); -mng_retcode mng_promote_g16_ga16 (mng_datap pData); -#endif - -mng_retcode mng_promote_g8_rgb8 (mng_datap pData); -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_promote_g8_rgb16 (mng_datap pData); -mng_retcode mng_promote_g16_rgb16 (mng_datap pData); -#endif - -mng_retcode mng_promote_g8_rgba8 (mng_datap pData); -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_promote_g8_rgba16 (mng_datap pData); -mng_retcode mng_promote_g16_rgba16 (mng_datap pData); - -mng_retcode mng_promote_ga8_ga16 (mng_datap pData); -#endif - -mng_retcode mng_promote_ga8_rgba8 (mng_datap pData); -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_promote_ga8_rgba16 (mng_datap pData); -mng_retcode mng_promote_ga16_rgba16 (mng_datap pData); -#endif - -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_promote_rgb8_rgb16 (mng_datap pData); -#endif - -mng_retcode mng_promote_rgb8_rgba8 (mng_datap pData); -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_promote_rgb8_rgba16 (mng_datap pData); -mng_retcode mng_promote_rgb16_rgba16 (mng_datap pData); -#endif - -mng_retcode mng_promote_idx8_rgb8 (mng_datap pData); -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_promote_idx8_rgb16 (mng_datap pData); -#endif - -mng_retcode mng_promote_idx8_rgba8 (mng_datap pData); -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_promote_idx8_rgba16 (mng_datap pData); - -mng_retcode mng_promote_rgba8_rgba16 (mng_datap pData); -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Row processing routines - convert uncompressed data from zlib to * */ -/* * managable row-data which serves as input to the color-management * */ -/* * routines * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_process_g1 (mng_datap pData); -mng_retcode mng_process_g2 (mng_datap pData); -mng_retcode mng_process_g4 (mng_datap pData); -#endif -mng_retcode mng_process_g8 (mng_datap pData); -mng_retcode mng_process_rgb8 (mng_datap pData); -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_process_idx1 (mng_datap pData); -mng_retcode mng_process_idx2 (mng_datap pData); -mng_retcode mng_process_idx4 (mng_datap pData); -#endif -mng_retcode mng_process_idx8 (mng_datap pData); -mng_retcode mng_process_ga8 (mng_datap pData); -mng_retcode mng_process_rgba8 (mng_datap pData); -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_process_g16 (mng_datap pData); -mng_retcode mng_process_ga16 (mng_datap pData); -mng_retcode mng_process_rgb16 (mng_datap pData); -mng_retcode mng_process_rgba16 (mng_datap pData); -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Row processing initialization routines - set up the variables needed * */ -/* * to process uncompressed row-data * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_FOOTPRINT_INIT -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_init_g1_i (mng_datap pData); -mng_retcode mng_init_g2_i (mng_datap pData); -mng_retcode mng_init_g4_i (mng_datap pData); -#endif -mng_retcode mng_init_g8_i (mng_datap pData); -mng_retcode mng_init_rgb8_i (mng_datap pData); -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_init_idx1_i (mng_datap pData); -mng_retcode mng_init_idx2_i (mng_datap pData); -mng_retcode mng_init_idx4_i (mng_datap pData); -#endif -mng_retcode mng_init_idx8_i (mng_datap pData); -mng_retcode mng_init_ga8_i (mng_datap pData); -mng_retcode mng_init_rgba8_i (mng_datap pData); -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_init_g1_ni (mng_datap pData); -mng_retcode mng_init_g2_ni (mng_datap pData); -mng_retcode mng_init_g4_ni (mng_datap pData); -#endif -mng_retcode mng_init_g8_ni (mng_datap pData); -mng_retcode mng_init_rgb8_ni (mng_datap pData); -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_init_idx1_ni (mng_datap pData); -mng_retcode mng_init_idx2_ni (mng_datap pData); -mng_retcode mng_init_idx4_ni (mng_datap pData); -#endif -mng_retcode mng_init_idx8_ni (mng_datap pData); -mng_retcode mng_init_ga8_ni (mng_datap pData); -mng_retcode mng_init_rgba8_ni (mng_datap pData); -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_init_g16_i (mng_datap pData); -mng_retcode mng_init_rgb16_i (mng_datap pData); -mng_retcode mng_init_ga16_i (mng_datap pData); -mng_retcode mng_init_rgba16_i (mng_datap pData); -mng_retcode mng_init_g16_ni (mng_datap pData); -mng_retcode mng_init_rgb16_ni (mng_datap pData); -mng_retcode mng_init_ga16_ni (mng_datap pData); -mng_retcode mng_init_rgba16_ni (mng_datap pData); -#endif -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Row processing initialization routines (JPEG) - set up the variables * */ -/* * needed to process uncompressed row-data * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_FOOTPRINT_INIT -#ifdef MNG_INCLUDE_JNG -#ifndef MNG_NO_1_2_4BIT_SUPPORT -mng_retcode mng_init_jpeg_a1_ni (mng_datap pData); -mng_retcode mng_init_jpeg_a2_ni (mng_datap pData); -mng_retcode mng_init_jpeg_a4_ni (mng_datap pData); -#endif -mng_retcode mng_init_jpeg_a8_ni (mng_datap pData); -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_init_jpeg_a16_ni (mng_datap pData); -#endif -#endif -#endif - -/* ************************************************************************** */ -/* * * */ -/* * General row processing routines * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode mng_init_rowproc (mng_datap pData); -mng_retcode mng_next_row (mng_datap pData); -#ifdef MNG_INCLUDE_JNG -mng_retcode mng_next_jpeg_alpharow (mng_datap pData); -mng_retcode mng_next_jpeg_row (mng_datap pData); -#endif -mng_retcode mng_cleanup_rowproc (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * Magnification row routines - apply magnification transforms * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_OPTIMIZE_FOOTPRINT_MAGN -mng_retcode mng_magnify_g8_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_g8_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_g8_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgb8_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgb8_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgb8_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_ga8_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_ga8_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_ga8_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_ga8_x4 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_ga8_x5 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -#endif -mng_retcode mng_magnify_rgba8_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgba8_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgba8_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgba8_x4 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgba8_x5 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -#ifndef MNG_OPTIMIZE_FOOTPRINT_MAGN -mng_retcode mng_magnify_g8_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_g8_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_g8_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgb8_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgb8_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgb8_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_ga8_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_ga8_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_ga8_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_ga8_y4 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_ga8_y5 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -#endif -mng_retcode mng_magnify_rgba8_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgba8_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgba8_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgba8_y4 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgba8_y5 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); - -/* ************************************************************************** */ -#ifndef MNG_NO_16BIT_SUPPORT -#ifndef MNG_OPTIMIZE_FOOTPRINT_MAGN -mng_retcode mng_magnify_g16_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_g16_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_g16_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgb16_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgb16_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgb16_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_ga16_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_ga16_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_ga16_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_ga16_x4 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_ga16_x5 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgba16_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgba16_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgba16_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgba16_x4 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgba16_x5 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); - -mng_retcode mng_magnify_g16_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_g16_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_g16_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgb16_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgb16_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgb16_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_ga16_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_ga16_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_ga16_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_ga16_y4 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_ga16_y5 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgba16_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgba16_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgba16_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgba16_y4 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode mng_magnify_rgba16_y5 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -#endif -#endif - -/* ************************************************************************** */ -/* * * */ -/* * PAST composition routines - compose over/under with a target object * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode mng_composeover_rgba8 (mng_datap pData); -#ifndef MNG_SKIPCHUNK_PAST -mng_retcode mng_composeunder_rgba8 (mng_datap pData); -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_composeover_rgba16 (mng_datap pData); -mng_retcode mng_composeunder_rgba16 (mng_datap pData); -#endif -#endif - -/* ************************************************************************** */ -/* * * */ -/* * PAST flip & tile routines - flip or tile a row of pixels * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_SKIPCHUNK_PAST -mng_retcode mng_flip_rgba8 (mng_datap pData); -mng_retcode mng_tile_rgba8 (mng_datap pData); -#ifndef MNG_NO_16BIT_SUPPORT -mng_retcode mng_flip_rgba16 (mng_datap pData); -mng_retcode mng_tile_rgba16 (mng_datap pData); -#endif -#endif - -/* ************************************************************************** */ - -#endif /* _libmng_pixels_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/plugins/AdvaImg/src/LibMNG/libmng_prop_xs.c b/plugins/AdvaImg/src/LibMNG/libmng_prop_xs.c deleted file mode 100644 index d4afc87d09..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_prop_xs.c +++ /dev/null @@ -1,2799 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_prop_xs.c copyright (c) 2000-2006 G.Juyn * */ -/* * version : 1.0.10 * */ -/* * * */ -/* * purpose : property get/set interface (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * comment : implementation of the property get/set functions * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - fixed calling convention * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - added set_outputprofile2 & set_srgbprofile2 * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * * */ -/* * 0.5.2 - 05/23/2000 - G.Juyn * */ -/* * - changed inclusion of cms-routines * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - added support for get/set default zlib/IJG parms * */ -/* * 0.5.2 - 05/31/2000 - G.Juyn * */ -/* * - fixed up punctuation (contribution by Tim Rowley) * */ -/* * 0.5.2 - 06/05/2000 - G.Juyn * */ -/* * - added support for RGB8_A8 canvasstyle * */ -/* * * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added get/set for speedtype to facilitate testing * */ -/* * - added get for imagelevel during processtext callback * */ -/* * 0.5.3 - 06/26/2000 - G.Juyn * */ -/* * - changed userdata variable to mng_ptr * */ -/* * 0.5.3 - 06/29/2000 - G.Juyn * */ -/* * - fixed incompatible return-types * */ -/* * * */ -/* * 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 get/set routines for sectionbreak variable * */ -/* * * */ -/* * 0.9.2 - 07/31/2000 - G.Juyn * */ -/* * - added status_xxxx functions * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 10/10/2000 - G.Juyn * */ -/* * - added support for alpha-depth prediction * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added functions to retrieve PNG/JNG specific header-info * */ -/* * 0.9.3 - 10/20/2000 - G.Juyn * */ -/* * - added get/set for bKGD preference setting * */ -/* * 0.9.3 - 10/21/2000 - G.Juyn * */ -/* * - added get function for interlace/progressive display * */ -/* * * */ -/* * 1.0.1 - 04/21/2001 - G.Juyn (code by G.Kelly) * */ -/* * - added BGRA8 canvas with premultiplied alpha * */ -/* * 1.0.1 - 05/02/2001 - G.Juyn * */ -/* * - added "default" sRGB generation (Thanks Marti!) * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added optimization option for MNG-video playback * */ -/* * 1.0.2 - 06/25/2001 - G.Juyn * */ -/* * - added option to turn off progressive refresh * */ -/* * * */ -/* * 1.0.3 - 08/06/2001 - G.Juyn * */ -/* * - added get function for last processed BACK chunk * */ -/* * * */ -/* * 1.0.4 - 06/22/2002 - G.Juyn * */ -/* * - B495442 - invalid returnvalue in mng_get_suspensionmode * */ -/* * * */ -/* * 1.0.5 - 09/14/2002 - G.Juyn * */ -/* * - added event handling for dynamic MNG * */ -/* * 1.0.5 - 09/22/2002 - G.Juyn * */ -/* * - added bgrx8 canvas (filler byte) * */ -/* * 1.0.5 - 11/07/2002 - G.Juyn * */ -/* * - added support to get totals after mng_read() * */ -/* * * */ -/* * 1.0.6 - 05/11/2003 - G. Juyn * */ -/* * - added conditionals around canvas update routines * */ -/* * 1.0.6 - 07/07/2003 - G.R-P * */ -/* * - added conditionals around some JNG-supporting code * */ -/* * 1.0.6 - 07/11/2003 - G.R-P * */ -/* * - added conditionals zlib and jpeg property accessors * */ -/* * 1.0.6 - 07/14/2003 - G.R-P * */ -/* * - added conditionals around various unused functions * */ -/* * * */ -/* * 1.0.7 - 11/27/2003 - R.A * */ -/* * - added CANVAS_RGB565 and CANVAS_BGR565 * */ -/* * 1.0.7 - 12/06/2003 - R.A * */ -/* * - added CANVAS_RGBA565 and CANVAS_BGRA565 * */ -/* * 1.0.7 - 01/25/2004 - J.S * */ -/* * - added premultiplied alpha canvas' for RGBA, ARGB, ABGR * */ -/* * 1.0.7 - 03/07/2004 - G.R-P. * */ -/* * - put gamma, cms-related functions inside #ifdef * */ -/* * * */ -/* * 1.0.8 - 04/02/2004 - G.Juyn * */ -/* * - added CRC existence & checking flags * */ -/* * * */ -/* * 1.0.9 - 09/18/2004 - G.R-P. * */ -/* * - added some MNG_SUPPORT_WRITE conditionals * */ -/* * 1.0.9 - 10/03/2004 - G.Juyn * */ -/* * - added function to retrieve current FRAM delay * */ -/* * 1.0.9 - 10/14/2004 - G.Juyn * */ -/* * - added bgr565_a8 canvas-style (thanks to J. Elvander) * */ -/* * 1.0.9 - 12/20/2004 - G.Juyn * */ -/* * - cleaned up macro-invocations (thanks to D. Airlie) * */ -/* * * */ -/* * 1.0.10 - 03/07/2006 - (thanks to W. Manthey) * */ -/* * - added CANVAS_RGB555 and CANVAS_BGR555 * */ -/* * * */ -/* ************************************************************************** */ - -#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_memory.h" -#include "libmng_cms.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Property set functions * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_userdata (mng_handle hHandle, - mng_ptr pUserdata) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_USERDATA, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->pUserdata = pUserdata; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_USERDATA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_canvasstyle (mng_handle hHandle, - mng_uint32 iStyle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_CANVASSTYLE, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - - switch (iStyle) - { -#ifndef MNG_SKIPCANVAS_RGB8 - case MNG_CANVAS_RGB8 : break; -#endif -#ifndef MNG_SKIPCANVAS_RGBA8 - case MNG_CANVAS_RGBA8 : break; -#endif -#ifndef MNG_SKIPCANVAS_RGBA8_PM - case MNG_CANVAS_RGBA8_PM: break; -#endif -#ifndef MNG_SKIPCANVAS_ARGB8 - case MNG_CANVAS_ARGB8 : break; -#endif -#ifndef MNG_SKIPCANVAS_ARGB8_PM - case MNG_CANVAS_ARGB8_PM: break; -#endif -#ifndef MNG_SKIPCANVAS_RGB8_A8 - case MNG_CANVAS_RGB8_A8 : break; -#endif -#ifndef MNG_SKIPCANVAS_BGR8 - case MNG_CANVAS_BGR8 : break; -#endif -#ifndef MNG_SKIPCANVAS_BGRX8 - case MNG_CANVAS_BGRX8 : break; -#endif -#ifndef MNG_SKIPCANVAS_BGRA8 - case MNG_CANVAS_BGRA8 : break; -#endif -#ifndef MNG_SKIPCANVAS_BGRA8_PM - case MNG_CANVAS_BGRA8_PM: break; -#endif -#ifndef MNG_SKIPCANVAS_ABGR8 - case MNG_CANVAS_ABGR8 : break; -#endif -#ifndef MNG_SKIPCANVAS_ABGR8_PM - case MNG_CANVAS_ABGR8_PM: break; -#endif -#ifndef MNG_SKIPCANVAS_RGB565 - case MNG_CANVAS_RGB565 : break; -#endif -#ifndef MNG_SKIPCANVAS_RGBA565 - case MNG_CANVAS_RGBA565 : break; -#endif -#ifndef MNG_SKIPCANVAS_BGR565 - case MNG_CANVAS_BGR565 : break; -#endif -#ifndef MNG_SKIPCANVAS_BGRA565 - case MNG_CANVAS_BGRA565 : break; -#endif -#ifndef MNG_SKIPCANVAS_BGR565_A8 - case MNG_CANVAS_BGR565_A8 : break; -#endif -#ifndef MNG_SKIPCANVAS_RGB555 - case MNG_CANVAS_RGB555 : break; -#endif -#ifndef MNG_SKIPCANVAS_BGR555 - case MNG_CANVAS_BGR555 : break; -#endif -/* case MNG_CANVAS_RGB16 : break; */ -/* case MNG_CANVAS_RGBA16 : break; */ -/* case MNG_CANVAS_ARGB16 : break; */ -/* case MNG_CANVAS_BGR16 : break; */ -/* case MNG_CANVAS_BGRA16 : break; */ -/* case MNG_CANVAS_ABGR16 : break; */ -/* case MNG_CANVAS_INDEX8 : break; */ -/* case MNG_CANVAS_INDEXA8 : break; */ -/* case MNG_CANVAS_AINDEX8 : break; */ -/* case MNG_CANVAS_GRAY8 : break; */ -/* case MNG_CANVAS_GRAY16 : break; */ -/* case MNG_CANVAS_GRAYA8 : break; */ -/* case MNG_CANVAS_GRAYA16 : break; */ -/* case MNG_CANVAS_AGRAY8 : break; */ -/* case MNG_CANVAS_AGRAY16 : break; */ -/* case MNG_CANVAS_DX15 : break; */ -/* case MNG_CANVAS_DX16 : break; */ - default : { MNG_ERROR (((mng_datap)hHandle), MNG_INVALIDCNVSTYLE) }; - } - - ((mng_datap)hHandle)->iCanvasstyle = iStyle; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_CANVASSTYLE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_bkgdstyle (mng_handle hHandle, - mng_uint32 iStyle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_BKGDSTYLE, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - - switch (iStyle) /* alpha-modes not supported */ - { -#ifndef MNG_SKIPCANVAS_RGB8 - case MNG_CANVAS_RGB8 : break; -#endif -#ifndef MNG_SKIPCANVAS_BGR8 - case MNG_CANVAS_BGR8 : break; -#endif -#ifndef MNG_SKIPCANVAS_BGRX8 - case MNG_CANVAS_BGRX8 : break; -#endif -#ifndef MNG_SKIPCANVAS_RGB565 - case MNG_CANVAS_RGB565 : break; -#endif -#ifndef MNG_SKIPCANVAS_BGR565 - case MNG_CANVAS_BGR565 : break; -#endif -/* case MNG_CANVAS_RGB16 : break; */ -/* case MNG_CANVAS_BGR16 : break; */ -/* case MNG_CANVAS_INDEX8 : break; */ -/* case MNG_CANVAS_GRAY8 : break; */ -/* case MNG_CANVAS_GRAY16 : break; */ -/* case MNG_CANVAS_DX15 : break; */ -/* case MNG_CANVAS_DX16 : break; */ - default : MNG_ERROR (((mng_datap)hHandle), MNG_INVALIDCNVSTYLE); - } - - ((mng_datap)hHandle)->iBkgdstyle = iStyle; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_BKGDSTYLE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_bgcolor (mng_handle hHandle, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_BGCOLOR, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iBGred = iRed; - ((mng_datap)hHandle)->iBGgreen = iGreen; - ((mng_datap)hHandle)->iBGblue = iBlue; - ((mng_datap)hHandle)->bUseBKGD = MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_BGCOLOR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_usebkgd (mng_handle hHandle, - mng_bool bUseBKGD) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_USEBKGD, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->bUseBKGD = bUseBKGD; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_USEBKGD, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_storechunks (mng_handle hHandle, - mng_bool bStorechunks) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_STORECHUNKS, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->bStorechunks = bStorechunks; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_STORECHUNKS, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_sectionbreaks (mng_handle hHandle, - mng_bool bSectionbreaks) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SECTIONBREAKS, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->bSectionbreaks = bSectionbreaks; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SECTIONBREAKS, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_cacheplayback (mng_handle hHandle, - mng_bool bCacheplayback) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_CACHEPLAYBACK, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - - if (((mng_datap)hHandle)->bHasheader) - MNG_ERROR (((mng_datap)hHandle), MNG_FUNCTIONINVALID); - - ((mng_datap)hHandle)->bCacheplayback = bCacheplayback; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_CACHEPLAYBACK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_doprogressive (mng_handle hHandle, - mng_bool bDoProgressive) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DOPROGRESSIVE, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - - ((mng_datap)hHandle)->bDoProgressive = bDoProgressive; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DOPROGRESSIVE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_crcmode (mng_handle hHandle, - mng_uint32 iCrcmode) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_CRCMODE, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - - ((mng_datap)hHandle)->iCrcmode = iCrcmode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_CRCMODE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_set_srgb (mng_handle hHandle, - mng_bool bIssRGB) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGB, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->bIssRGB = bIssRGB; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGB, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -#ifndef MNG_SKIPCHUNK_iCCP -mng_retcode MNG_DECL mng_set_outputprofile (mng_handle hHandle, - mng_pchar zFilename) -{ -#ifdef MNG_INCLUDE_LCMS - mng_datap pData; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_OUTPUTPROFILE, MNG_LC_START); -#endif - -#ifdef MNG_INCLUDE_LCMS - MNG_VALIDHANDLE (hHandle) - - pData = (mng_datap)hHandle; /* address the structure */ - - if (pData->hProf2) /* previously defined ? */ - mnglcms_freeprofile (pData->hProf2); - /* allocate new CMS profile handle */ - pData->hProf2 = mnglcms_createfileprofile (zFilename); - - if (!pData->hProf2) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE); -#endif /* MNG_INCLUDE_LCMS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_OUTPUTPROFILE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -#ifndef MNG_SKIPCHUNK_iCCP -mng_retcode MNG_DECL mng_set_outputprofile2 (mng_handle hHandle, - mng_uint32 iProfilesize, - mng_ptr pProfile) -{ -#ifdef MNG_INCLUDE_LCMS - mng_datap pData; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_OUTPUTPROFILE2, MNG_LC_START); -#endif - -#ifdef MNG_INCLUDE_LCMS - MNG_VALIDHANDLE (hHandle) - - pData = (mng_datap)hHandle; /* address the structure */ - - if (pData->hProf2) /* previously defined ? */ - mnglcms_freeprofile (pData->hProf2); - /* allocate new CMS profile handle */ - pData->hProf2 = mnglcms_creatememprofile (iProfilesize, pProfile); - - if (!pData->hProf2) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE); -#endif /* MNG_INCLUDE_LCMS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_OUTPUTPROFILE2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_outputsrgb (mng_handle hHandle) -{ -#ifdef MNG_INCLUDE_LCMS - mng_datap pData; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_OUTPUTSRGB, MNG_LC_START); -#endif - -#ifdef MNG_INCLUDE_LCMS - MNG_VALIDHANDLE (hHandle) - - pData = (mng_datap)hHandle; /* address the structure */ - - if (pData->hProf2) /* previously defined ? */ - mnglcms_freeprofile (pData->hProf2); - /* allocate new CMS profile handle */ - pData->hProf2 = mnglcms_createsrgbprofile (); - - if (!pData->hProf2) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE); -#endif /* MNG_INCLUDE_LCMS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_OUTPUTSRGB, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_set_srgbprofile (mng_handle hHandle, - mng_pchar zFilename) -{ -#ifdef MNG_INCLUDE_LCMS - mng_datap pData; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGBPROFILE2, MNG_LC_START); -#endif - -#ifdef MNG_INCLUDE_LCMS - MNG_VALIDHANDLE (hHandle) - - pData = (mng_datap)hHandle; /* address the structure */ - - if (pData->hProf3) /* previously defined ? */ - mnglcms_freeprofile (pData->hProf3); - /* allocate new CMS profile handle */ - pData->hProf3 = mnglcms_createfileprofile (zFilename); - - if (!pData->hProf3) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE); -#endif /* MNG_INCLUDE_LCMS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGBPROFILE2, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_set_srgbprofile2 (mng_handle hHandle, - mng_uint32 iProfilesize, - mng_ptr pProfile) -{ -#ifdef MNG_INCLUDE_LCMS - mng_datap pData; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGBPROFILE, MNG_LC_START); -#endif - -#ifdef MNG_INCLUDE_LCMS - MNG_VALIDHANDLE (hHandle) - - pData = (mng_datap)hHandle; /* address the structure */ - - if (pData->hProf3) /* previously defined ? */ - mnglcms_freeprofile (pData->hProf3); - /* allocate new CMS profile handle */ - pData->hProf3 = mnglcms_creatememprofile (iProfilesize, pProfile); - - if (!pData->hProf3) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE); -#endif /* MNG_INCLUDE_LCMS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGBPROFILE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_srgbimplicit (mng_handle hHandle) -{ -#ifdef MNG_INCLUDE_LCMS - mng_datap pData; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGBIMPLICIT, MNG_LC_START); -#endif - -#ifdef MNG_INCLUDE_LCMS - MNG_VALIDHANDLE (hHandle) - - pData = (mng_datap)hHandle; /* address the structure */ - - if (pData->hProf3) /* previously defined ? */ - mnglcms_freeprofile (pData->hProf3); - /* allocate new CMS profile handle */ - pData->hProf3 = mnglcms_createsrgbprofile (); - - if (!pData->hProf3) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE); -#endif /* MNG_INCLUDE_LCMS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGBIMPLICIT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) || defined(MNG_APP_CMS) -mng_retcode MNG_DECL mng_set_viewgamma (mng_handle hHandle, - mng_float dGamma) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_VIEWGAMMA, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->dViewgamma = dGamma; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_VIEWGAMMA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_displaygamma (mng_handle hHandle, - mng_float dGamma) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DISPLAYGAMMA, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->dDisplaygamma = dGamma; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DISPLAYGAMMA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_dfltimggamma (mng_handle hHandle, - mng_float dGamma) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DFLTIMGGAMMA, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->dDfltimggamma = dGamma; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DFLTIMGGAMMA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) || defined(MNG_APP_CMS) -mng_retcode MNG_DECL mng_set_viewgammaint (mng_handle hHandle, - mng_uint32 iGamma) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_VIEWGAMMA, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->dViewgamma = (mng_float)iGamma / 100000; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_VIEWGAMMA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_displaygammaint (mng_handle hHandle, - mng_uint32 iGamma) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DISPLAYGAMMA, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->dDisplaygamma = (mng_float)iGamma / 100000; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DISPLAYGAMMA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifndef MNG_NO_DFLT_INFO -mng_retcode MNG_DECL mng_set_dfltimggammaint (mng_handle hHandle, - mng_uint32 iGamma) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DFLTIMGGAMMA, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->dDfltimggamma = (mng_float)iGamma / 100000; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DFLTIMGGAMMA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIP_MAXCANVAS -mng_retcode MNG_DECL mng_set_maxcanvaswidth (mng_handle hHandle, - mng_uint32 iMaxwidth) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_MAXCANVASWIDTH, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iMaxwidth = iMaxwidth; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_MAXCANVASWIDTH, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_maxcanvasheight (mng_handle hHandle, - mng_uint32 iMaxheight) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_MAXCANVASHEIGHT, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iMaxheight = iMaxheight; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_MAXCANVASHEIGHT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_maxcanvassize (mng_handle hHandle, - mng_uint32 iMaxwidth, - mng_uint32 iMaxheight) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_MAXCANVASSIZE, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iMaxwidth = iMaxwidth; - ((mng_datap)hHandle)->iMaxheight = iMaxheight; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_MAXCANVASSIZE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -#ifdef MNG_ACCESS_ZLIB -#ifdef MNG_SUPPORT_WRITE -mng_retcode MNG_DECL mng_set_zlib_level (mng_handle hHandle, - mng_int32 iZlevel) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_LEVEL, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iZlevel = iZlevel; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_LEVEL, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_WRITE */ -#endif /* MNG_ACCESS_ZLIB */ -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -#ifdef MNG_ACCESS_ZLIB -#ifdef MNG_SUPPORT_WRITE -mng_retcode MNG_DECL mng_set_zlib_method (mng_handle hHandle, - mng_int32 iZmethod) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_METHOD, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iZmethod = iZmethod; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_METHOD, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_WRITE */ -#endif /* MNG_ACCESS_ZLIB */ -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -#ifdef MNG_ACCESS_ZLIB -#ifdef MNG_SUPPORT_WRITE -mng_retcode MNG_DECL mng_set_zlib_windowbits (mng_handle hHandle, - mng_int32 iZwindowbits) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_WINDOWBITS, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iZwindowbits = iZwindowbits; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_WINDOWBITS, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_WRITE */ -#endif /* MNG_ACCESS_ZLIB */ -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -#ifdef MNG_ACCESS_ZLIB -#ifdef MNG_SUPPORT_WRITE -mng_retcode MNG_DECL mng_set_zlib_memlevel (mng_handle hHandle, - mng_int32 iZmemlevel) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_MEMLEVEL, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iZmemlevel = iZmemlevel; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_MEMLEVEL, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_WRITE */ -#endif /* MNG_ACCESS_ZLIB */ -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -#ifdef MNG_ACCESS_ZLIB -#ifdef MNG_SUPPORT_WRITE -mng_retcode MNG_DECL mng_set_zlib_strategy (mng_handle hHandle, - mng_int32 iZstrategy) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_STRATEGY, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iZstrategy = iZstrategy; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_STRATEGY, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_WRITE */ -#endif /* MNG_ACCESS_ZLIB */ -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -#ifdef MNG_ACCESS_ZLIB -#ifdef MNG_SUPPORT_WRITE -mng_retcode MNG_DECL mng_set_zlib_maxidat (mng_handle hHandle, - mng_uint32 iMaxIDAT) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_MAXIDAT, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iMaxIDAT = iMaxIDAT; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_MAXIDAT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_WRITE */ -#endif /* MNG_ACCESS_ZLIB */ -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -#ifdef MNG_ACCESS_JPEG -#ifdef MNG_SUPPORT_WRITE -mng_retcode MNG_DECL mng_set_jpeg_dctmethod (mng_handle hHandle, - mngjpeg_dctmethod eJPEGdctmethod) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_DCTMETHOD, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->eJPEGdctmethod = eJPEGdctmethod; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_DCTMETHOD, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif MNG_SUPPORT_WRITE -#endif /* MNG_ACCESS_JPEG */ -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -#ifdef MNG_ACCESS_JPEG -#ifdef MNG_SUPPORT_WRITE -mng_retcode MNG_DECL mng_set_jpeg_quality (mng_handle hHandle, - mng_int32 iJPEGquality) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_QUALITY, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iJPEGquality = iJPEGquality; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_QUALITY, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_WRITE */ -#endif /* MNG_ACCESS_JPEG */ -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -#ifdef MNG_ACCESS_JPEG -#ifdef MNG_SUPPORT_WRITE -mng_retcode MNG_DECL mng_set_jpeg_smoothing (mng_handle hHandle, - mng_int32 iJPEGsmoothing) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_SMOOTHING, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iJPEGsmoothing = iJPEGsmoothing; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_SMOOTHING, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_WRITE */ -#endif /* MNG_ACCESS_JPEG */ -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -#ifdef MNG_ACCESS_JPEG -#ifdef MNG_SUPPORT_WRITE -mng_retcode MNG_DECL mng_set_jpeg_progressive (mng_handle hHandle, - mng_bool bJPEGprogressive) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_PROGRESSIVE, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->bJPEGcompressprogr = bJPEGprogressive; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_PROGRESSIVE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_WRITE */ -#endif /* MNG_ACCESS_JPEG */ -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -#ifdef MNG_ACCESS_JPEG -#ifdef MNG_SUPPORT_WRITE -mng_retcode MNG_DECL mng_set_jpeg_optimized (mng_handle hHandle, - mng_bool bJPEGoptimized) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_OPTIMIZED, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->bJPEGcompressopt = bJPEGoptimized; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_OPTIMIZED, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_WRITE */ -#endif /* MNG_ACCESS_JPEG */ -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -#ifdef MNG_ACCESS_JPEG -#ifdef MNG_SUPPORT_WRITE -mng_retcode MNG_DECL mng_set_jpeg_maxjdat (mng_handle hHandle, - mng_uint32 iMaxJDAT) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_MAXJDAT, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iMaxJDAT = iMaxJDAT; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_MAXJDAT, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_WRITE */ -#endif /* MNG_ACCESS_JPEG */ -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_set_suspensionmode (mng_handle hHandle, - mng_bool bSuspensionmode) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SUSPENSIONMODE, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - - if (((mng_datap)hHandle)->bReading) /* we must NOT be reading !!! */ - MNG_ERROR ((mng_datap)hHandle, MNG_FUNCTIONINVALID); - - ((mng_datap)hHandle)->bSuspensionmode = bSuspensionmode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SUSPENSIONMODE, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_set_speed (mng_handle hHandle, - mng_speedtype iSpeed) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SPEED, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iSpeed = iSpeed; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SPEED, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ -/* * * */ -/* * Property get functions * */ -/* * * */ -/* ************************************************************************** */ - -mng_ptr MNG_DECL mng_get_userdata (mng_handle hHandle) -{ /* no tracing in here to prevent recursive calls */ - MNG_VALIDHANDLEX (hHandle) - return ((mng_datap)hHandle)->pUserdata; -} - -/* ************************************************************************** */ - -mng_imgtype MNG_DECL mng_get_sigtype (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SIGTYPE, MNG_LC_START); -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_it_unknown; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SIGTYPE, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->eSigtype; -} - -/* ************************************************************************** */ - -mng_imgtype MNG_DECL mng_get_imagetype (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGETYPE, MNG_LC_START); -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_it_unknown; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGETYPE, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->eImagetype; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_imagewidth (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGEWIDTH, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGEWIDTH, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iWidth; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_imageheight (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGEWIDTH, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGEHEIGHT, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iHeight; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_ticks (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_TICKS, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_TICKS, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iTicks; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_framecount (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_FRAMECOUNT, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_FRAMECOUNT, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iFramecount; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_layercount (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_LAYERCOUNT, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_LAYERCOUNT, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iLayercount; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_playtime (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_PLAYTIME, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_PLAYTIME, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iPlaytime; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_simplicity (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SIMPLICITY, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SIMPLICITY, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iSimplicity; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_bitdepth (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_BITDEPTH, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - - if (((mng_datap)hHandle)->eImagetype == mng_it_png) - iRslt = ((mng_datap)hHandle)->iBitdepth; - else -#ifdef MNG_INCLUDE_JNG - if (((mng_datap)hHandle)->eImagetype == mng_it_jng) - iRslt = ((mng_datap)hHandle)->iJHDRimgbitdepth; - else -#endif - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_BITDEPTH, MNG_LC_END); -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_colortype (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_COLORTYPE, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - - if (((mng_datap)hHandle)->eImagetype == mng_it_png) - iRslt = ((mng_datap)hHandle)->iColortype; - else -#ifdef MNG_INCLUDE_JNG - if (((mng_datap)hHandle)->eImagetype == mng_it_jng) - iRslt = ((mng_datap)hHandle)->iJHDRcolortype; - else -#endif - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_COLORTYPE, MNG_LC_END); -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_compression (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_COMPRESSION, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - - if (((mng_datap)hHandle)->eImagetype == mng_it_png) - iRslt = ((mng_datap)hHandle)->iCompression; - else -#ifdef MNG_INCLUDE_JNG - if (((mng_datap)hHandle)->eImagetype == mng_it_jng) - iRslt = ((mng_datap)hHandle)->iJHDRimgcompression; - else -#endif - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_COMPRESSION, MNG_LC_END); -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_filter (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_FILTER, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - - if (((mng_datap)hHandle)->eImagetype == mng_it_png) - iRslt = ((mng_datap)hHandle)->iFilter; - else - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_FILTER, MNG_LC_END); -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_interlace (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_INTERLACE, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - - if (((mng_datap)hHandle)->eImagetype == mng_it_png) - iRslt = ((mng_datap)hHandle)->iInterlace; - else -#ifdef MNG_INCLUDE_JNG - if (((mng_datap)hHandle)->eImagetype == mng_it_jng) - iRslt = ((mng_datap)hHandle)->iJHDRimginterlace; - else -#endif - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_INTERLACE, MNG_LC_END); -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_alphabitdepth (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHABITDEPTH, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_INCLUDE_JNG - if (((mng_datap)hHandle)->eImagetype == mng_it_jng) - iRslt = ((mng_datap)hHandle)->iJHDRalphabitdepth; - else -#endif - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHABITDEPTH, MNG_LC_END); -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_uint8 MNG_DECL mng_get_refreshpass (mng_handle hHandle) -{ - mng_uint8 iRslt; - mng_datap pData; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_REFRESHPASS, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - - pData = (mng_datap)hHandle; - /* for PNG we know the exact pass */ - if ((pData->eImagetype == mng_it_png) && (pData->iPass >= 0)) - iRslt = pData->iPass; -#ifdef MNG_INCLUDE_JNG - else /* for JNG we'll fake it... */ - if ((pData->eImagetype == mng_it_jng) && - (pData->bJPEGhasheader) && (pData->bJPEGdecostarted) && - (pData->bJPEGprogressive)) - { - if (pData->pJPEGdinfo->input_scan_number <= 1) - iRslt = 0; /* first pass (I think...) */ - else - if (jpeg_input_complete (pData->pJPEGdinfo)) - iRslt = 7; /* input complete; aka final pass */ - else - iRslt = 3; /* anything between 0 and 7 will do */ - - } -#endif - else - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_REFRESHPASS, MNG_LC_END); -#endif - - return iRslt; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ -mng_uint8 MNG_DECL mng_get_alphacompression (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHACOMPRESSION, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_INCLUDE_JNG - if (((mng_datap)hHandle)->eImagetype == mng_it_jng) - iRslt = ((mng_datap)hHandle)->iJHDRalphacompression; - else -#endif - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHACOMPRESSION, MNG_LC_END); -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_alphafilter (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHAFILTER, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_INCLUDE_JNG - if (((mng_datap)hHandle)->eImagetype == mng_it_jng) - iRslt = ((mng_datap)hHandle)->iJHDRalphafilter; - else -#endif - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHAFILTER, MNG_LC_END); -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_alphainterlace (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHAINTERLACE, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_INCLUDE_JNG - if (((mng_datap)hHandle)->eImagetype == mng_it_jng) - iRslt = ((mng_datap)hHandle)->iJHDRalphainterlace; - else -#endif - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHAINTERLACE, MNG_LC_END); -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_alphadepth (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHADEPTH, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHADEPTH, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iAlphadepth; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_canvasstyle (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CANVASSTYLE, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CANVASSTYLE, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iCanvasstyle; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_bkgdstyle (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_BKGDSTYLE, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_BKGDSTYLE, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iBkgdstyle; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_get_bgcolor (mng_handle hHandle, - mng_uint16* iRed, - mng_uint16* iGreen, - mng_uint16* iBlue) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GET_BGCOLOR, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - *iRed = ((mng_datap)hHandle)->iBGred; - *iGreen = ((mng_datap)hHandle)->iBGgreen; - *iBlue = ((mng_datap)hHandle)->iBGblue; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GET_BGCOLOR, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_bool MNG_DECL mng_get_usebkgd (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_USEBKGD, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_USEBKGD, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->bUseBKGD; -} - -/* ************************************************************************** */ - -mng_bool MNG_DECL mng_get_storechunks (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_STORECHUNKS, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_STORECHUNKS, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->bStorechunks; -} - -/* ************************************************************************** */ - -mng_bool MNG_DECL mng_get_sectionbreaks (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_SECTIONBREAKS, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_SECTIONBREAKS, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->bSectionbreaks; -} - -/* ************************************************************************** */ - -mng_bool MNG_DECL mng_get_cacheplayback (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_CACHEPLAYBACK, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_CACHEPLAYBACK, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->bCacheplayback; -} - -/* ************************************************************************** */ - -mng_bool MNG_DECL mng_get_doprogressive (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_DOPROGRESSIVE, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_DOPROGRESSIVE, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->bDoProgressive; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_crcmode (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_CRCMODE, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_CRCMODE, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iCrcmode; -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_bool MNG_DECL mng_get_srgb (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_SRGB, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_SRGB, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->bIssRGB; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) || defined(MNG_APP_CMS) -mng_float MNG_DECL mng_get_viewgamma (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_VIEWGAMMA, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_VIEWGAMMA, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->dViewgamma; -} -#endif - -/* ************************************************************************** */ - -#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) || defined(MNG_APP_CMS) -mng_float MNG_DECL mng_get_displaygamma (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_DISPLAYGAMMA, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_DISPLAYGAMMA, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->dDisplaygamma; -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DFLT_INFO -#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) || defined(MNG_APP_CMS) -mng_float MNG_DECL mng_get_dfltimggamma (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_DFLTIMGGAMMA, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_DFLTIMGGAMMA, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->dDfltimggamma; -} -#endif -#endif - -/* ************************************************************************** */ - -#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) || defined(MNG_APP_CMS) -mng_uint32 MNG_DECL mng_get_viewgammaint (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_VIEWGAMMA, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_VIEWGAMMA, MNG_LC_END); -#endif - - return (mng_uint32)(((mng_datap)hHandle)->dViewgamma * 100000); -} -#endif - -/* ************************************************************************** */ - -#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) || defined(MNG_APP_CMS) -mng_uint32 MNG_DECL mng_get_displaygammaint (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_DISPLAYGAMMA, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_DISPLAYGAMMA, MNG_LC_END); -#endif - - return (mng_uint32)(((mng_datap)hHandle)->dDisplaygamma * 100000); -} -#endif - -/* ************************************************************************** */ - -#ifndef MNG_NO_DFLT_INFO -#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) || defined(MNG_APP_CMS) -mng_uint32 MNG_DECL mng_get_dfltimggammaint (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_DFLTIMGGAMMA, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_DFLTIMGGAMMA, MNG_LC_END); -#endif - - return (mng_uint32)(((mng_datap)hHandle)->dDfltimggamma * 100000); -} -#endif -#endif - -/* ************************************************************************** */ - -#ifndef MNG_SKIP_MAXCANVAS -mng_uint32 MNG_DECL mng_get_maxcanvaswidth (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_MAXCANVASWIDTH, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_MAXCANVASWIDTH, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iMaxwidth; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_maxcanvasheight (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_MAXCANVASHEIGHT, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_MAXCANVASHEIGHT, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iMaxheight; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -#ifdef MNG_ACCESS_ZLIB -mng_int32 MNG_DECL mng_get_zlib_level (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_LEVEL, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_LEVEL, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iZlevel; -} -#endif /* MNG_ACCESS_ZLIB */ -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ -#ifdef MNG_INCLUDE_ZLIB -#ifdef MNG_ACCESS_ZLIB -mng_int32 MNG_DECL mng_get_zlib_method (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_METHOD, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_METHOD, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iZmethod; -} - -#endif /* MNG_ACCESS_ZLIB */ -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -#ifdef MNG_ACCESS_ZLIB -mng_int32 MNG_DECL mng_get_zlib_windowbits (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_WINDOWBITS, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_WINDOWBITS, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iZwindowbits; -} -#endif /* MNG_ACCESS_ZLIB */ -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -#ifdef MNG_ACCESS_ZLIB -mng_int32 MNG_DECL mng_get_zlib_memlevel (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_MEMLEVEL, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_MEMLEVEL, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iZmemlevel; -} -#endif /* MNG_ACCESS_ZLIB */ -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -#ifdef MNG_ACCESS_ZLIB -mng_int32 MNG_DECL mng_get_zlib_strategy (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_STRATEGY, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_STRATEGY, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iZstrategy; -} -#endif /* MNG_ACCESS_ZLIB */ -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -#ifdef MNG_ACCESS_ZLIB -mng_uint32 MNG_DECL mng_get_zlib_maxidat (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_MAXIDAT, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_MAXIDAT, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iMaxIDAT; -} -#endif /* MNG_ACCESS_ZLIB */ -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -#ifdef MNG_ACCESS_JPEG -mngjpeg_dctmethod MNG_DECL mng_get_jpeg_dctmethod (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_DCTMETHOD, MNG_LC_START); -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return JDCT_ISLOW; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_DCTMETHOD, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->eJPEGdctmethod; -} -#endif /* MNG_ACCESS_JPEG */ -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -#ifdef MNG_ACCESS_JPEG -mng_int32 MNG_DECL mng_get_jpeg_quality (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_QUALITY, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_QUALITY, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iJPEGquality; -} -#endif /* MNG_ACCESS_JPEG */ -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -#ifdef MNG_ACCESS_JPEG -mng_int32 MNG_DECL mng_get_jpeg_smoothing (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_SMOOTHING, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_SMOOTHING, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iJPEGsmoothing; -} -#endif /* MNG_ACCESS_JPEG */ -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -#ifdef MNG_ACCESS_JPEG -mng_bool MNG_DECL mng_get_jpeg_progressive (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_PROGRESSIVE, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_PROGRESSIVE, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->bJPEGcompressprogr; -} -#endif /* MNG_ACCESS_JPEG */ -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -#ifdef MNG_ACCESS_JPEG -mng_bool MNG_DECL mng_get_jpeg_optimized (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_OPTIMIZED, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_OPTIMIZED, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->bJPEGcompressopt; -} -#endif /* MNG_ACCESS_JPEG */ -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -#ifdef MNG_ACCESS_JPEG -mng_uint32 MNG_DECL mng_get_jpeg_maxjdat (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_MAXJDAT, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_MAXJDAT, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iMaxJDAT; -} -#endif /* MNG_ACCESS_JPEG */ -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_bool MNG_DECL mng_get_suspensionmode (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SUSPENSIONMODE, MNG_LC_START); -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SUSPENSIONMODE, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->bSuspensionmode; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_speedtype MNG_DECL mng_get_speed (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SPEED, MNG_LC_START); -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_st_normal; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SPEED, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iSpeed; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_imagelevel (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGELEVEL, MNG_LC_START); -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGELEVEL, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iImagelevel; -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_get_lastbackchunk (mng_handle hHandle, - mng_uint16* iRed, - mng_uint16* iGreen, - mng_uint16* iBlue, - mng_uint8* iMandatory) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_LASTBACKCHUNK, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - - if (((mng_datap)hHandle)->eImagetype != mng_it_mng) - MNG_ERROR (((mng_datap)hHandle), MNG_FUNCTIONINVALID); - - *iRed = ((mng_datap)hHandle)->iBACKred; - *iGreen = ((mng_datap)hHandle)->iBACKgreen; - *iBlue = ((mng_datap)hHandle)->iBACKblue; - *iMandatory = ((mng_datap)hHandle)->iBACKmandatory; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_LASTBACKCHUNK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_get_lastseekname (mng_handle hHandle, - mng_pchar zSegmentname) -{ - mng_datap pData; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_LASTSEEKNAME, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - - pData = (mng_datap)hHandle; - /* only allowed for MNG ! */ - if (pData->eImagetype != mng_it_mng) - MNG_ERROR (pData, MNG_FUNCTIONINVALID); - - if (pData->pLastseek) /* is there a last SEEK ? */ - { - mng_ani_seekp pSEEK = (mng_ani_seekp)pData->pLastseek; - - if (pSEEK->iSegmentnamesize) /* copy the name if there is one */ - MNG_COPY (zSegmentname, pSEEK->zSegmentname, pSEEK->iSegmentnamesize); - - *(((mng_uint8p)zSegmentname) + pSEEK->iSegmentnamesize) = 0; - } - else - { /* return an empty string */ - *((mng_uint8p)zSegmentname) = 0; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_LASTSEEKNAME, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_uint32 MNG_DECL mng_get_currframdelay (mng_handle hHandle) -{ - mng_datap pData; - mng_uint32 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CURRFRAMDELAY, MNG_LC_START); -#endif - - MNG_VALIDHANDLE (hHandle) - - pData = (mng_datap)hHandle; - /* only allowed for MNG ! */ - if (pData->eImagetype != mng_it_mng) - MNG_ERROR (pData, MNG_FUNCTIONINVALID); - - iRslt = pData->iFramedelay; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CURRFRAMDELAY, MNG_LC_END); -#endif - - return iRslt; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_uint32 MNG_DECL mng_get_starttime (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_STARTTIME, MNG_LC_START); -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_st_normal; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_STARTTIME, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iStarttime; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_uint32 MNG_DECL mng_get_runtime (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_RUNTIME, MNG_LC_START); -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_st_normal; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_RUNTIME, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iRuntime; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -#ifndef MNG_NO_CURRENT_INFO -mng_uint32 MNG_DECL mng_get_currentframe (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CURRENTFRAME, MNG_LC_START); -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_st_normal; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CURRENTFRAME, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iFrameseq; -} -#endif -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -#ifndef MNG_NO_CURRENT_INFO -mng_uint32 MNG_DECL mng_get_currentlayer (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CURRENTLAYER, MNG_LC_START); -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_st_normal; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CURRENTLAYER, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iLayerseq; -} -#endif -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -#ifndef MNG_NO_CURRENT_INFO -mng_uint32 MNG_DECL mng_get_currentplaytime (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CURRENTPLAYTIME, MNG_LC_START); -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_st_normal; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CURRENTPLAYTIME, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iFrametime; -} -#endif -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -#ifndef MNG_NO_CURRENT_INFO -mng_uint32 MNG_DECL mng_get_totalframes (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_TOTALFRAMES, MNG_LC_START); -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_st_normal; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_TOTALFRAMES, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iTotalframes; -} -#endif -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -#ifndef MNG_NO_CURRENT_INFO -mng_uint32 MNG_DECL mng_get_totallayers (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_TOTALLAYERS, MNG_LC_START); -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_st_normal; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_TOTALLAYERS, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iTotallayers; -} -#endif -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -#ifndef MNG_NO_CURRENT_INFO -mng_uint32 MNG_DECL mng_get_totalplaytime (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_TOTALPLAYTIME, MNG_LC_START); -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_st_normal; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_TOTALPLAYTIME, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->iTotalplaytime; -} -#endif -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -mng_bool MNG_DECL mng_status_error (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_ERROR, MNG_LC_START); -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_ERROR, MNG_LC_END); -#endif - - return (mng_bool)((mng_datap)hHandle)->iErrorcode; -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_bool MNG_DECL mng_status_reading (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_READING, MNG_LC_START); -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_READING, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->bReading; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_bool MNG_DECL mng_status_suspendbreak (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_SUSPENDBREAK, MNG_LC_START); -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_SUSPENDBREAK, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->bSuspended; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_WRITE -mng_bool MNG_DECL mng_status_creating (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_CREATING, MNG_LC_START); -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_CREATING, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->bCreating; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_WRITE -mng_bool MNG_DECL mng_status_writing (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_WRITING, MNG_LC_START); -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_WRITING, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->bWriting; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_bool MNG_DECL mng_status_displaying (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_DISPLAYING, MNG_LC_START); -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_DISPLAYING, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->bDisplaying; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_bool MNG_DECL mng_status_running (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_RUNNING, MNG_LC_START); -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_RUNNING, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->bRunning; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_bool MNG_DECL mng_status_timerbreak (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_TIMERBREAK, MNG_LC_START); -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_TIMERBREAK, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->bTimerset; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DYNAMICMNG -mng_bool MNG_DECL mng_status_dynamic (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_DYNAMIC, MNG_LC_START); -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_DYNAMIC, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->bDynamic; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DYNAMICMNG -mng_bool MNG_DECL mng_status_runningevent (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_RUNNINGEVENT, MNG_LC_START); -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_RUNNINGEVENT, MNG_LC_END); -#endif - - return ((mng_datap)hHandle)->bRunningevent; -} -#endif - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/plugins/AdvaImg/src/LibMNG/libmng_read.c b/plugins/AdvaImg/src/LibMNG/libmng_read.c deleted file mode 100644 index 3a6e49fcac..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_read.c +++ /dev/null @@ -1,1369 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_read.c copyright (c) 2000-2007 G.Juyn * */ -/* * version : 1.0.10 * */ -/* * * */ -/* * purpose : Read logic (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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 * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - removed test-MaGN * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added support for JDAA * */ -/* * * */ -/* * 0.9.5 - 01/23/2001 - G.Juyn * */ -/* * - fixed timing-problem with switching framing_modes * */ -/* * * */ -/* * 1.0.4 - 06/22/2002 - G.Juyn * */ -/* * - B495443 - incorrect suspend check in read_databuffer * */ -/* * * */ -/* * 1.0.5 - 07/04/2002 - G.Juyn * */ -/* * - added errorcode for extreme chunk-sizes * */ -/* * 1.0.5 - 07/08/2002 - G.Juyn * */ -/* * - B578572 - removed eMNGma hack (thanks Dimitri!) * */ -/* * 1.0.5 - 07/16/2002 - G.Juyn * */ -/* * - B581625 - large chunks fail with suspension reads * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * - added HLAPI function to copy chunks * */ -/* * 1.0.5 - 09/16/2002 - G.Juyn * */ -/* * - added event handling for dynamic MNG * */ -/* * * */ -/* * 1.0.6 - 05/25/2003 - G.R-P * */ -/* * - added MNG_SKIPCHUNK_cHNK footprint optimizations * */ -/* * 1.0.6 - 07/07/2003 - G.R-P * */ -/* * - added MNG_NO_DELTA_PNG reduction * */ -/* * - skip additional code when MNG_INCLUDE_JNG is not enabled * */ -/* * 1.0.6 - 07/29/2003 - G.R-P * */ -/* * - added conditionals around PAST chunk support * */ -/* * 1.0.6 - 08/17/2003 - G.R-P * */ -/* * - added conditionals around non-VLC chunk support * */ -/* * * */ -/* * 1.0.7 - 03/10/2004 - G.R-P * */ -/* * - added conditionals around openstream/closestream * */ -/* * * */ -/* * 1.0.8 - 04/08/2004 - G.Juyn * */ -/* * - added CRC existence & checking flags * */ -/* * 1.0.8 - 04/11/2004 - G.Juyn * */ -/* * - added data-push mechanisms for specialized decoders * */ -/* * 1.0.8 - 07/06/2004 - G.R-P * */ -/* * - defend against using undefined closestream function * */ -/* * 1.0.8 - 07/28/2004 - G.R-P * */ -/* * - added check for extreme chunk-lengths * */ -/* * * */ -/* * 1.0.9 - 09/16/2004 - G.Juyn * */ -/* * - fixed chunk pushing mechanism * */ -/* * 1.0.9 - 12/05/2004 - G.Juyn * */ -/* * - added conditional MNG_OPTIMIZE_CHUNKINITFREE * */ -/* * 1.0.9 - 12/06/2004 - G.Juyn * */ -/* * - added conditional MNG_OPTIMIZE_CHUNKASSIGN * */ -/* * - added conditional MNG_OPTIMIZE_CHUNKREADER * */ -/* * 1.0.9 - 12/20/2004 - G.Juyn * */ -/* * - cleaned up macro-invocations (thanks to D. Airlie) * */ -/* * 1.0.9 - 12/31/2004 - G.R-P * */ -/* * - removed stray characters from #ifdef directive * */ -/* * * */ -/* * 1.0.10 - 04/08/2007 - G.Juyn * */ -/* * - added support for mPNG proposal * */ -/* * * */ -/* ************************************************************************** */ - -#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" -#ifdef MNG_OPTIMIZE_CHUNKREADER -#include "libmng_chunk_descr.h" -#endif -#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 mng_process_eof (mng_datap pData) -{ - if (!pData->bEOF) /* haven't closed the stream yet ? */ - { - pData->bEOF = MNG_TRUE; /* now we do! */ - -#ifndef MNG_NO_OPEN_CLOSE_STREAM - if (pData->fClosestream && !pData->fClosestream ((mng_handle)pData)) - { - MNG_ERROR (pData, MNG_APPIOERROR); - } -#endif - } - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_release_pushdata (mng_datap pData) -{ - mng_pushdatap pFirst = pData->pFirstpushdata; - mng_pushdatap pNext = pFirst->pNext; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RELEASE_PUSHDATA, MNG_LC_START); -#endif - - pData->pFirstpushdata = pNext; /* next becomes the first */ - - if (!pNext) /* no next? => no last! */ - pData->pLastpushdata = MNG_NULL; - /* buffer owned and release callback defined? */ - if ((pFirst->bOwned) && (pData->fReleasedata)) - pData->fReleasedata ((mng_handle)pData, pFirst->pData, pFirst->iLength); - else /* otherwise use internal free mechanism */ - MNG_FREEX (pData, pFirst->pData, pFirst->iLength); - /* and free it */ - MNG_FREEX (pData, pFirst, sizeof(mng_pushdata)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RELEASE_PUSHDATA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_release_pushchunk (mng_datap pData) -{ - mng_pushdatap pFirst = pData->pFirstpushchunk; - mng_pushdatap pNext = pFirst->pNext; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RELEASE_PUSHCHUNK, MNG_LC_START); -#endif - - pData->pFirstpushchunk = pNext; /* next becomes the first */ - - if (!pNext) /* no next? => no last! */ - pData->pLastpushchunk = MNG_NULL; - /* buffer owned and release callback defined? */ - if ((pFirst->bOwned) && (pData->fReleasedata)) - pData->fReleasedata ((mng_handle)pData, pFirst->pData, pFirst->iLength); - else /* otherwise use internal free mechanism */ - MNG_FREEX (pData, pFirst->pData, pFirst->iLength); - /* and free it */ - MNG_FREEX (pData, pFirst, sizeof(mng_pushdata)); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RELEASE_PUSHCHUNK, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -MNG_LOCAL mng_retcode read_data (mng_datap pData, - mng_uint8p pBuf, - mng_uint32 iSize, - mng_uint32 * iRead) -{ - mng_retcode iRetcode; - mng_uint32 iTempsize = iSize; - mng_uint8p pTempbuf = pBuf; - mng_pushdatap pPush = pData->pFirstpushdata; - mng_uint32 iPushsize = 0; - *iRead = 0; /* nothing yet */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DATA, MNG_LC_START); -#endif - - while (pPush) /* calculate size of pushed data */ - { - iPushsize += pPush->iRemaining; - pPush = pPush->pNext; - } - - if (iTempsize <= iPushsize) /* got enough push data? */ - { - while (iTempsize) - { - pPush = pData->pFirstpushdata; - /* enough data remaining in this buffer? */ - if (pPush->iRemaining <= iTempsize) - { /* no: then copy what we've got */ - MNG_COPY (pTempbuf, pPush->pDatanext, pPush->iRemaining); - /* move pointers & lengths */ - pTempbuf += pPush->iRemaining; - *iRead += pPush->iRemaining; - iTempsize -= pPush->iRemaining; - /* release the depleted buffer */ - iRetcode = mng_release_pushdata (pData); - if (iRetcode) - return iRetcode; - } - else - { /* copy the needed bytes */ - MNG_COPY (pTempbuf, pPush->pDatanext, iTempsize); - /* move pointers & lengths */ - pPush->iRemaining -= iTempsize; - pPush->pDatanext += iTempsize; - pTempbuf += iTempsize; - *iRead += iTempsize; - iTempsize = 0; /* all done!!! */ - } - } - } - else - { - mng_uint32 iTempread = 0; - /* get it from the app then */ - if (!pData->fReaddata (((mng_handle)pData), pTempbuf, iTempsize, &iTempread)) - MNG_ERROR (pData, MNG_APPIOERROR); - - *iRead += iTempread; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DATA, MNG_LC_END); -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -MNG_LOCAL mng_retcode read_databuffer (mng_datap pData, - mng_uint8p pBuf, - mng_uint8p * pBufnext, - mng_uint32 iSize, - mng_uint32 * iRead) -{ - mng_retcode iRetcode; - -#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 (!*pBufnext) /* first time ? */ - { - if (pData->iSuspendbufleft) /* do we have some data left ? */ - { /* then copy it */ - MNG_COPY (pBuf, pData->pSuspendbufnext, pData->iSuspendbufleft); - /* fixup variables */ - *pBufnext = pBuf + pData->iSuspendbufleft; - pData->pSuspendbufnext = pData->pSuspendbuf; - pData->iSuspendbufleft = 0; - } - else - { - *pBufnext = pBuf; - } - } - /* calculate how much to get */ - iRemain = iSize - (mng_uint32)(*pBufnext - pBuf); - /* let's go get it */ - iRetcode = read_data (pData, *pBufnext, iRemain, &iTemp); - if (iRetcode) - return iRetcode; - /* first read after suspension return 0 means EOF */ - if ((pData->iSuspendpoint) && (iTemp == 0)) - { /* that makes it final */ - mng_retcode iRetcode = mng_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 ? */ - { - *pBufnext = *pBufnext + 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; - - iRetcode = read_data (pData, pTemp, MNG_SUSPENDREQUESTSIZE, &iTemp); - if (iRetcode) - return iRetcode; - /* 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 = mng_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 - { - iRetcode = read_data (pData, (mng_ptr)pBuf, iSize, iRead); - if (iRetcode) - return iRetcode; - if (*iRead == 0) /* suspension required ? */ - pData->bSuspended = MNG_TRUE; - } - - 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_LOCAL mng_retcode process_raw_chunk (mng_datap pData, - mng_uint8p pBuf, - mng_uint32 iBuflen) -{ - -#ifndef MNG_OPTIMIZE_CHUNKREADER - /* the table-idea & binary search code was adapted from - libpng 1.1.0 (pngread.c) */ - /* NOTE1: the table must remain sorted by chunkname, otherwise the binary - search will break !!! (ps. watch upper-/lower-case chunknames !!) */ - /* NOTE2: the layout must remain equal to the header part of all the - chunk-structures (yes, that means even the pNext and pPrev fields; - it's wasting a bit of space, but hey, the code is a lot easier) */ - -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - mng_chunk_header mng_chunk_unknown = {MNG_UINT_HUH, mng_init_general, mng_free_unknown, - mng_read_unknown, mng_write_unknown, mng_assign_unknown, 0, 0, sizeof(mng_unknown_chunk)}; -#else - mng_chunk_header mng_chunk_unknown = {MNG_UINT_HUH, mng_init_unknown, mng_free_unknown, - mng_read_unknown, mng_write_unknown, mng_assign_unknown, 0, 0}; -#endif - -#ifdef MNG_OPTIMIZE_CHUNKINITFREE - - mng_chunk_header mng_chunk_table [] = - { -#ifndef MNG_SKIPCHUNK_BACK - {MNG_UINT_BACK, mng_init_general, mng_free_general, mng_read_back, mng_write_back, mng_assign_general, 0, 0, sizeof(mng_back)}, -#endif -#ifndef MNG_SKIPCHUNK_BASI - {MNG_UINT_BASI, mng_init_general, mng_free_general, mng_read_basi, mng_write_basi, mng_assign_general, 0, 0, sizeof(mng_basi)}, -#endif -#ifndef MNG_SKIPCHUNK_CLIP - {MNG_UINT_CLIP, mng_init_general, mng_free_general, mng_read_clip, mng_write_clip, mng_assign_general, 0, 0, sizeof(mng_clip)}, -#endif -#ifndef MNG_SKIPCHUNK_CLON - {MNG_UINT_CLON, mng_init_general, mng_free_general, mng_read_clon, mng_write_clon, mng_assign_general, 0, 0, sizeof(mng_clon)}, -#endif -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_DBYK - {MNG_UINT_DBYK, mng_init_general, mng_free_dbyk, mng_read_dbyk, mng_write_dbyk, mng_assign_dbyk, 0, 0, sizeof(mng_dbyk)}, -#endif -#endif -#ifndef MNG_SKIPCHUNK_DEFI - {MNG_UINT_DEFI, mng_init_general, mng_free_general, mng_read_defi, mng_write_defi, mng_assign_general, 0, 0, sizeof(mng_defi)}, -#endif -#ifndef MNG_NO_DELTA_PNG - {MNG_UINT_DHDR, mng_init_general, mng_free_general, mng_read_dhdr, mng_write_dhdr, mng_assign_general, 0, 0, sizeof(mng_dhdr)}, -#endif -#ifndef MNG_SKIPCHUNK_DISC - {MNG_UINT_DISC, mng_init_general, mng_free_disc, mng_read_disc, mng_write_disc, mng_assign_disc, 0, 0, sizeof(mng_disc)}, -#endif -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_DROP - {MNG_UINT_DROP, mng_init_general, mng_free_drop, mng_read_drop, mng_write_drop, mng_assign_drop, 0, 0, sizeof(mng_drop)}, -#endif -#endif -#ifndef MNG_SKIPCHUNK_LOOP - {MNG_UINT_ENDL, mng_init_general, mng_free_general, mng_read_endl, mng_write_endl, mng_assign_general, 0, 0, sizeof(mng_endl)}, -#endif -#ifndef MNG_SKIPCHUNK_FRAM - {MNG_UINT_FRAM, mng_init_general, mng_free_fram, mng_read_fram, mng_write_fram, mng_assign_fram, 0, 0, sizeof(mng_fram)}, -#endif - {MNG_UINT_IDAT, mng_init_general, mng_free_idat, mng_read_idat, mng_write_idat, mng_assign_idat, 0, 0, sizeof(mng_idat)}, /* 12-th element! */ - {MNG_UINT_IEND, mng_init_general, mng_free_general, mng_read_iend, mng_write_iend, mng_assign_general, 0, 0, sizeof(mng_iend)}, - {MNG_UINT_IHDR, mng_init_general, mng_free_general, mng_read_ihdr, mng_write_ihdr, mng_assign_general, 0, 0, sizeof(mng_ihdr)}, -#ifndef MNG_NO_DELTA_PNG -#ifdef MNG_INCLUDE_JNG - {MNG_UINT_IJNG, mng_init_general, mng_free_general, mng_read_ijng, mng_write_ijng, mng_assign_general, 0, 0, sizeof(mng_ijng)}, -#endif - {MNG_UINT_IPNG, mng_init_general, mng_free_general, mng_read_ipng, mng_write_ipng, mng_assign_general, 0, 0, sizeof(mng_ipng)}, -#endif -#ifdef MNG_INCLUDE_JNG - {MNG_UINT_JDAA, mng_init_general, mng_free_jdaa, mng_read_jdaa, mng_write_jdaa, mng_assign_jdaa, 0, 0, sizeof(mng_jdaa)}, - {MNG_UINT_JDAT, mng_init_general, mng_free_jdat, mng_read_jdat, mng_write_jdat, mng_assign_jdat, 0, 0, sizeof(mng_jdat)}, - {MNG_UINT_JHDR, mng_init_general, mng_free_general, mng_read_jhdr, mng_write_jhdr, mng_assign_general, 0, 0, sizeof(mng_jhdr)}, - {MNG_UINT_JSEP, mng_init_general, mng_free_general, mng_read_jsep, mng_write_jsep, mng_assign_general, 0, 0, sizeof(mng_jsep)}, - {MNG_UINT_JdAA, mng_init_general, mng_free_jdaa, mng_read_jdaa, mng_write_jdaa, mng_assign_jdaa, 0, 0, sizeof(mng_jdaa)}, -#endif -#ifndef MNG_SKIPCHUNK_LOOP - {MNG_UINT_LOOP, mng_init_general, mng_free_loop, mng_read_loop, mng_write_loop, mng_assign_loop, 0, 0, sizeof(mng_loop)}, -#endif -#ifndef MNG_SKIPCHUNK_MAGN - {MNG_UINT_MAGN, mng_init_general, mng_free_general, mng_read_magn, mng_write_magn, mng_assign_general, 0, 0, sizeof(mng_magn)}, -#endif - {MNG_UINT_MEND, mng_init_general, mng_free_general, mng_read_mend, mng_write_mend, mng_assign_general, 0, 0, sizeof(mng_mend)}, - {MNG_UINT_MHDR, mng_init_general, mng_free_general, mng_read_mhdr, mng_write_mhdr, mng_assign_general, 0, 0, sizeof(mng_mhdr)}, -#ifndef MNG_SKIPCHUNK_MOVE - {MNG_UINT_MOVE, mng_init_general, mng_free_general, mng_read_move, mng_write_move, mng_assign_general, 0, 0, sizeof(mng_move)}, -#endif -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_ORDR - {MNG_UINT_ORDR, mng_init_general, mng_free_ordr, mng_read_ordr, mng_write_ordr, mng_assign_ordr, 0, 0, sizeof(mng_ordr)}, -#endif -#endif -#ifndef MNG_SKIPCHUNK_PAST - {MNG_UINT_PAST, mng_init_general, mng_free_past, mng_read_past, mng_write_past, mng_assign_past, 0, 0, sizeof(mng_past)}, -#endif - {MNG_UINT_PLTE, mng_init_general, mng_free_general, mng_read_plte, mng_write_plte, mng_assign_general, 0, 0, sizeof(mng_plte)}, -#ifndef MNG_NO_DELTA_PNG - {MNG_UINT_PPLT, mng_init_general, mng_free_general, mng_read_pplt, mng_write_pplt, mng_assign_general, 0, 0, sizeof(mng_pplt)}, - {MNG_UINT_PROM, mng_init_general, mng_free_general, mng_read_prom, mng_write_prom, mng_assign_general, 0, 0, sizeof(mng_prom)}, -#endif -#ifndef MNG_SKIPCHUNK_SAVE - {MNG_UINT_SAVE, mng_init_general, mng_free_save, mng_read_save, mng_write_save, mng_assign_save, 0, 0, sizeof(mng_save)}, -#endif -#ifndef MNG_SKIPCHUNK_SEEK - {MNG_UINT_SEEK, mng_init_general, mng_free_seek, mng_read_seek, mng_write_seek, mng_assign_seek, 0, 0, sizeof(mng_seek)}, -#endif -#ifndef MNG_SKIPCHUNK_SHOW - {MNG_UINT_SHOW, mng_init_general, mng_free_general, mng_read_show, mng_write_show, mng_assign_general, 0, 0, sizeof(mng_show)}, -#endif -#ifndef MNG_SKIPCHUNK_TERM - {MNG_UINT_TERM, mng_init_general, mng_free_general, mng_read_term, mng_write_term, mng_assign_general, 0, 0, sizeof(mng_term)}, -#endif -#ifndef MNG_SKIPCHUNK_bKGD - {MNG_UINT_bKGD, mng_init_general, mng_free_general, mng_read_bkgd, mng_write_bkgd, mng_assign_general, 0, 0, sizeof(mng_bkgd)}, -#endif -#ifndef MNG_SKIPCHUNK_cHRM - {MNG_UINT_cHRM, mng_init_general, mng_free_general, mng_read_chrm, mng_write_chrm, mng_assign_general, 0, 0, sizeof(mng_chrm)}, -#endif -#ifndef MNG_SKIPCHUNK_eXPI - {MNG_UINT_eXPI, mng_init_general, mng_free_expi, mng_read_expi, mng_write_expi, mng_assign_expi, 0, 0, sizeof(mng_expi)}, -#endif -#ifndef MNG_SKIPCHUNK_evNT - {MNG_UINT_evNT, mng_init_general, mng_free_evnt, mng_read_evnt, mng_write_evnt, mng_assign_evnt, 0, 0, sizeof(mng_evnt)}, -#endif -#ifndef MNG_SKIPCHUNK_fPRI - {MNG_UINT_fPRI, mng_init_general, mng_free_general, mng_read_fpri, mng_write_fpri, mng_assign_general, 0, 0, sizeof(mng_fpri)}, -#endif -#ifndef MNG_SKIPCHUNK_gAMA - {MNG_UINT_gAMA, mng_init_general, mng_free_general, mng_read_gama, mng_write_gama, mng_assign_general, 0, 0, sizeof(mng_gama)}, -#endif -#ifndef MNG_SKIPCHUNK_hIST - {MNG_UINT_hIST, mng_init_general, mng_free_general, mng_read_hist, mng_write_hist, mng_assign_general, 0, 0, sizeof(mng_hist)}, -#endif -#ifndef MNG_SKIPCHUNK_iCCP - {MNG_UINT_iCCP, mng_init_general, mng_free_iccp, mng_read_iccp, mng_write_iccp, mng_assign_iccp, 0, 0, sizeof(mng_iccp)}, -#endif -#ifndef MNG_SKIPCHUNK_iTXt - {MNG_UINT_iTXt, mng_init_general, mng_free_itxt, mng_read_itxt, mng_write_itxt, mng_assign_itxt, 0, 0, sizeof(mng_itxt)}, -#endif -#ifdef MNG_INCLUDE_MPNG_PROPOSAL - {MNG_UINT_mpNG, mng_init_general, mng_free_mpng, mng_read_mpng, mng_write_mpng, mng_assign_mpng, 0, 0, sizeof(mng_mpng)}, -#endif -#ifndef MNG_SKIPCHUNK_nEED - {MNG_UINT_nEED, mng_init_general, mng_free_need, mng_read_need, mng_write_need, mng_assign_need, 0, 0, sizeof(mng_need)}, -#endif -/* TODO: {MNG_UINT_oFFs, 0, 0, 0, 0, 0, 0}, */ -/* TODO: {MNG_UINT_pCAL, 0, 0, 0, 0, 0, 0}, */ -#ifndef MNG_SKIPCHUNK_pHYg - {MNG_UINT_pHYg, mng_init_general, mng_free_general, mng_read_phyg, mng_write_phyg, mng_assign_general, 0, 0, sizeof(mng_phyg)}, -#endif -#ifndef MNG_SKIPCHUNK_pHYs - {MNG_UINT_pHYs, mng_init_general, mng_free_general, mng_read_phys, mng_write_phys, mng_assign_general, 0, 0, sizeof(mng_phys)}, -#endif -#ifndef MNG_SKIPCHUNK_sBIT - {MNG_UINT_sBIT, mng_init_general, mng_free_general, mng_read_sbit, mng_write_sbit, mng_assign_general, 0, 0, sizeof(mng_sbit)}, -#endif -/* TODO: {MNG_UINT_sCAL, 0, 0, 0, 0, 0, 0}, */ -#ifndef MNG_SKIPCHUNK_sPLT - {MNG_UINT_sPLT, mng_init_general, mng_free_splt, mng_read_splt, mng_write_splt, mng_assign_splt, 0, 0, sizeof(mng_splt)}, -#endif - {MNG_UINT_sRGB, mng_init_general, mng_free_general, mng_read_srgb, mng_write_srgb, mng_assign_general, 0, 0, sizeof(mng_srgb)}, -#ifndef MNG_SKIPCHUNK_tEXt - {MNG_UINT_tEXt, mng_init_general, mng_free_text, mng_read_text, mng_write_text, mng_assign_text, 0, 0, sizeof(mng_text)}, -#endif -#ifndef MNG_SKIPCHUNK_tIME - {MNG_UINT_tIME, mng_init_general, mng_free_general, mng_read_time, mng_write_time, mng_assign_general, 0, 0, sizeof(mng_time)}, -#endif - {MNG_UINT_tRNS, mng_init_general, mng_free_general, mng_read_trns, mng_write_trns, mng_assign_general, 0, 0, sizeof(mng_trns)}, -#ifndef MNG_SKIPCHUNK_zTXt - {MNG_UINT_zTXt, mng_init_general, mng_free_ztxt, mng_read_ztxt, mng_write_ztxt, mng_assign_ztxt, 0, 0, sizeof(mng_ztxt)}, -#endif - }; - -#else /* MNG_OPTIMIZE_CHUNKINITFREE */ - - mng_chunk_header mng_chunk_table [] = - { -#ifndef MNG_SKIPCHUNK_BACK - {MNG_UINT_BACK, mng_init_back, mng_free_back, mng_read_back, mng_write_back, mng_assign_back, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_BASI - {MNG_UINT_BASI, mng_init_basi, mng_free_basi, mng_read_basi, mng_write_basi, mng_assign_basi, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_CLIP - {MNG_UINT_CLIP, mng_init_clip, mng_free_clip, mng_read_clip, mng_write_clip, mng_assign_clip, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_CLON - {MNG_UINT_CLON, mng_init_clon, mng_free_clon, mng_read_clon, mng_write_clon, mng_assign_clon, 0, 0}, -#endif -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_DBYK - {MNG_UINT_DBYK, mng_init_dbyk, mng_free_dbyk, mng_read_dbyk, mng_write_dbyk, mng_assign_dbyk, 0, 0}, -#endif -#endif -#ifndef MNG_SKIPCHUNK_DEFI - {MNG_UINT_DEFI, mng_init_defi, mng_free_defi, mng_read_defi, mng_write_defi, mng_assign_defi, 0, 0}, -#endif -#ifndef MNG_NO_DELTA_PNG - {MNG_UINT_DHDR, mng_init_dhdr, mng_free_dhdr, mng_read_dhdr, mng_write_dhdr, mng_assign_dhdr, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_DISC - {MNG_UINT_DISC, mng_init_disc, mng_free_disc, mng_read_disc, mng_write_disc, mng_assign_disc, 0, 0}, -#endif -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_DROP - {MNG_UINT_DROP, mng_init_drop, mng_free_drop, mng_read_drop, mng_write_drop, mng_assign_drop, 0, 0}, -#endif -#endif -#ifndef MNG_SKIPCHUNK_LOOP - {MNG_UINT_ENDL, mng_init_endl, mng_free_endl, mng_read_endl, mng_write_endl, mng_assign_endl, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_FRAM - {MNG_UINT_FRAM, mng_init_fram, mng_free_fram, mng_read_fram, mng_write_fram, mng_assign_fram, 0, 0}, -#endif - {MNG_UINT_IDAT, mng_init_idat, mng_free_idat, mng_read_idat, mng_write_idat, mng_assign_idat, 0, 0}, /* 12-th element! */ - {MNG_UINT_IEND, mng_init_iend, mng_free_iend, mng_read_iend, mng_write_iend, mng_assign_iend, 0, 0}, - {MNG_UINT_IHDR, mng_init_ihdr, mng_free_ihdr, mng_read_ihdr, mng_write_ihdr, mng_assign_ihdr, 0, 0}, -#ifndef MNG_NO_DELTA_PNG -#ifdef MNG_INCLUDE_JNG - {MNG_UINT_IJNG, mng_init_ijng, mng_free_ijng, mng_read_ijng, mng_write_ijng, mng_assign_ijng, 0, 0}, -#endif - {MNG_UINT_IPNG, mng_init_ipng, mng_free_ipng, mng_read_ipng, mng_write_ipng, mng_assign_ipng, 0, 0}, -#endif -#ifdef MNG_INCLUDE_JNG - {MNG_UINT_JDAA, mng_init_jdaa, mng_free_jdaa, mng_read_jdaa, mng_write_jdaa, mng_assign_jdaa, 0, 0}, - {MNG_UINT_JDAT, mng_init_jdat, mng_free_jdat, mng_read_jdat, mng_write_jdat, mng_assign_jdat, 0, 0}, - {MNG_UINT_JHDR, mng_init_jhdr, mng_free_jhdr, mng_read_jhdr, mng_write_jhdr, mng_assign_jhdr, 0, 0}, - {MNG_UINT_JSEP, mng_init_jsep, mng_free_jsep, mng_read_jsep, mng_write_jsep, mng_assign_jsep, 0, 0}, - {MNG_UINT_JdAA, mng_init_jdaa, mng_free_jdaa, mng_read_jdaa, mng_write_jdaa, mng_assign_jdaa, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_LOOP - {MNG_UINT_LOOP, mng_init_loop, mng_free_loop, mng_read_loop, mng_write_loop, mng_assign_loop, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_MAGN - {MNG_UINT_MAGN, mng_init_magn, mng_free_magn, mng_read_magn, mng_write_magn, mng_assign_magn, 0, 0}, -#endif - {MNG_UINT_MEND, mng_init_mend, mng_free_mend, mng_read_mend, mng_write_mend, mng_assign_mend, 0, 0}, - {MNG_UINT_MHDR, mng_init_mhdr, mng_free_mhdr, mng_read_mhdr, mng_write_mhdr, mng_assign_mhdr, 0, 0}, -#ifndef MNG_SKIPCHUNK_MOVE - {MNG_UINT_MOVE, mng_init_move, mng_free_move, mng_read_move, mng_write_move, mng_assign_move, 0, 0}, -#endif -#ifndef MNG_NO_DELTA_PNG -#ifndef MNG_SKIPCHUNK_ORDR - {MNG_UINT_ORDR, mng_init_ordr, mng_free_ordr, mng_read_ordr, mng_write_ordr, mng_assign_ordr, 0, 0}, -#endif -#endif -#ifndef MNG_SKIPCHUNK_PAST - {MNG_UINT_PAST, mng_init_past, mng_free_past, mng_read_past, mng_write_past, mng_assign_past, 0, 0}, -#endif - {MNG_UINT_PLTE, mng_init_plte, mng_free_plte, mng_read_plte, mng_write_plte, mng_assign_plte, 0, 0}, -#ifndef MNG_NO_DELTA_PNG - {MNG_UINT_PPLT, mng_init_pplt, mng_free_pplt, mng_read_pplt, mng_write_pplt, mng_assign_pplt, 0, 0}, - {MNG_UINT_PROM, mng_init_prom, mng_free_prom, mng_read_prom, mng_write_prom, mng_assign_prom, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_SAVE - {MNG_UINT_SAVE, mng_init_save, mng_free_save, mng_read_save, mng_write_save, mng_assign_save, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_SEEK - {MNG_UINT_SEEK, mng_init_seek, mng_free_seek, mng_read_seek, mng_write_seek, mng_assign_seek, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_SHOW - {MNG_UINT_SHOW, mng_init_show, mng_free_show, mng_read_show, mng_write_show, mng_assign_show, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_TERM - {MNG_UINT_TERM, mng_init_term, mng_free_term, mng_read_term, mng_write_term, mng_assign_term, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_bKGD - {MNG_UINT_bKGD, mng_init_bkgd, mng_free_bkgd, mng_read_bkgd, mng_write_bkgd, mng_assign_bkgd, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_cHRM - {MNG_UINT_cHRM, mng_init_chrm, mng_free_chrm, mng_read_chrm, mng_write_chrm, mng_assign_chrm, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_eXPI - {MNG_UINT_eXPI, mng_init_expi, mng_free_expi, mng_read_expi, mng_write_expi, mng_assign_expi, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_evNT - {MNG_UINT_evNT, mng_init_evnt, mng_free_evnt, mng_read_evnt, mng_write_evnt, mng_assign_evnt, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_fPRI - {MNG_UINT_fPRI, mng_init_fpri, mng_free_fpri, mng_read_fpri, mng_write_fpri, mng_assign_fpri, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_gAMA - {MNG_UINT_gAMA, mng_init_gama, mng_free_gama, mng_read_gama, mng_write_gama, mng_assign_gama, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_hIST - {MNG_UINT_hIST, mng_init_hist, mng_free_hist, mng_read_hist, mng_write_hist, mng_assign_hist, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_iCCP - {MNG_UINT_iCCP, mng_init_iccp, mng_free_iccp, mng_read_iccp, mng_write_iccp, mng_assign_iccp, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_iTXt - {MNG_UINT_iTXt, mng_init_itxt, mng_free_itxt, mng_read_itxt, mng_write_itxt, mng_assign_itxt, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_nEED - {MNG_UINT_nEED, mng_init_need, mng_free_need, mng_read_need, mng_write_need, mng_assign_need, 0, 0}, -#endif -/* TODO: {MNG_UINT_oFFs, 0, 0, 0, 0, 0, 0}, */ -/* TODO: {MNG_UINT_pCAL, 0, 0, 0, 0, 0, 0}, */ -#ifndef MNG_SKIPCHUNK_pHYg - {MNG_UINT_pHYg, mng_init_phyg, mng_free_phyg, mng_read_phyg, mng_write_phyg, mng_assign_phyg, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_pHYs - {MNG_UINT_pHYs, mng_init_phys, mng_free_phys, mng_read_phys, mng_write_phys, mng_assign_phys, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_sBIT - {MNG_UINT_sBIT, mng_init_sbit, mng_free_sbit, mng_read_sbit, mng_write_sbit, mng_assign_sbit, 0, 0}, -#endif -/* TODO: {MNG_UINT_sCAL, 0, 0, 0, 0, 0, 0}, */ -#ifndef MNG_SKIPCHUNK_sPLT - {MNG_UINT_sPLT, mng_init_splt, mng_free_splt, mng_read_splt, mng_write_splt, mng_assign_splt, 0, 0}, -#endif - {MNG_UINT_sRGB, mng_init_srgb, mng_free_srgb, mng_read_srgb, mng_write_srgb, mng_assign_srgb, 0, 0}, -#ifndef MNG_SKIPCHUNK_tEXt - {MNG_UINT_tEXt, mng_init_text, mng_free_text, mng_read_text, mng_write_text, mng_assign_text, 0, 0}, -#endif -#ifndef MNG_SKIPCHUNK_tIME - {MNG_UINT_tIME, mng_init_time, mng_free_time, mng_read_time, mng_write_time, mng_assign_time, 0, 0}, -#endif - {MNG_UINT_tRNS, mng_init_trns, mng_free_trns, mng_read_trns, mng_write_trns, mng_assign_trns, 0, 0}, -#ifndef MNG_SKIPCHUNK_zTXt - {MNG_UINT_zTXt, mng_init_ztxt, mng_free_ztxt, mng_read_ztxt, mng_write_ztxt, mng_assign_ztxt, 0, 0}, -#endif - }; - -#endif /* MNG_OPTIMIZE_CHUNKINITFREE */ - - /* binary search variables */ - mng_int32 iTop, iLower, iUpper, iMiddle; - mng_chunk_headerp pEntry; /* pointer to found entry */ -#else - mng_chunk_header sEntry; /* temp chunk-header */ -#endif /* MNG_OPTIMIZE_CHUNKREADER */ - - 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 - /* reset timer indicator on read-cycle */ - if ((pData->bReading) && (!pData->bDisplaying)) - pData->bTimerset = MNG_FALSE; - /* get the chunkname */ - iChunkname = (mng_chunkid)(mng_get_uint32 (pBuf)); - - pBuf += sizeof (mng_chunkid); /* adjust the buffer */ - iBuflen -= sizeof (mng_chunkid); - pChunk = 0; - -#ifndef MNG_OPTIMIZE_CHUNKREADER - /* determine max index of table */ - iTop = (sizeof (mng_chunk_table) / sizeof (mng_chunk_table [0])) - 1; - - /* binary search; with 54 chunks, worst-case is 7 comparisons */ - iLower = 0; -#ifndef MNG_NO_DELTA_PNG - iMiddle = 11; /* start with the IDAT entry */ -#else - iMiddle = 8; -#endif - iUpper = iTop; - pEntry = 0; /* no goods yet! */ - - do /* the binary search itself */ - { - if (mng_chunk_table [iMiddle].iChunkname < iChunkname) - iLower = iMiddle + 1; - else if (mng_chunk_table [iMiddle].iChunkname > iChunkname) - iUpper = iMiddle - 1; - else - { - pEntry = &mng_chunk_table [iMiddle]; - break; - } - - iMiddle = (iLower + iUpper) >> 1; - } - while (iLower <= iUpper); - - if (!pEntry) /* unknown chunk ? */ - pEntry = &mng_chunk_unknown; /* make it so! */ - -#else /* MNG_OPTIMIZE_CHUNKREADER */ - - mng_get_chunkheader (iChunkname, &sEntry); - -#endif /* MNG_OPTIMIZE_CHUNKREADER */ - - pData->iChunkname = iChunkname; /* keep track of where we are */ - pData->iChunkseq++; - -#ifndef MNG_OPTIMIZE_CHUNKREADER - 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->iChunkname == MNG_UINT_HUH)) - ((mng_chunk_headerp)pChunk)->iChunkname = iChunkname; - } - } -#else /* MNG_OPTIMIZE_CHUNKREADER */ - if (sEntry.fRead) /* read-callback available ? */ - { - iRetcode = sEntry.fRead (pData, &sEntry, iBuflen, (mng_ptr)pBuf, &pChunk); - -#ifndef MNG_OPTIMIZE_CHUNKREADER - if (!iRetcode) /* everything oke ? */ - { /* remember unknown chunk's id */ - if ((pChunk) && (sEntry.iChunkname == MNG_UINT_HUH)) - ((mng_chunk_headerp)pChunk)->iChunkname = iChunkname; - } -#endif - } -#endif /* MNG_OPTIMIZE_CHUNKREADER */ - else - iRetcode = MNG_NOERROR; - - if (pChunk) /* store this chunk ? */ - mng_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 = mng_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_LOCAL mng_retcode check_chunk_crc (mng_datap pData, - mng_uint8p pBuf, - mng_uint32 iBuflen) -{ - mng_uint32 iCrc; /* calculated CRC */ - mng_bool bDiscard = MNG_FALSE; - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_CHUNK_CRC, MNG_LC_START); -#endif - - if (pData->iCrcmode & MNG_CRC_INPUT) /* crc included ? */ - { - mng_bool bCritical = (mng_bool)((*pBuf & 0x20) == 0); - mng_uint32 iL = iBuflen - (mng_uint32)(sizeof (iCrc)); - - if (((bCritical ) && (pData->iCrcmode & MNG_CRC_CRITICAL )) || - ((!bCritical) && (pData->iCrcmode & MNG_CRC_ANCILLARY))) - { /* calculate the crc */ - iCrc = mng_crc (pData, pBuf, iL); - /* and check it */ - if (!(iCrc == mng_get_uint32 (pBuf + iL))) - { - mng_bool bWarning = MNG_FALSE; - mng_bool bError = MNG_FALSE; - - if (bCritical) - { - switch (pData->iCrcmode & MNG_CRC_CRITICAL) - { - case MNG_CRC_CRITICAL_WARNING : { bWarning = MNG_TRUE; break; } - case MNG_CRC_CRITICAL_ERROR : { bError = MNG_TRUE; break; } - } - } - else - { - switch (pData->iCrcmode & MNG_CRC_ANCILLARY) - { - case MNG_CRC_ANCILLARY_DISCARD : { bDiscard = MNG_TRUE; break; } - case MNG_CRC_ANCILLARY_WARNING : { bWarning = MNG_TRUE; break; } - case MNG_CRC_ANCILLARY_ERROR : { bError = MNG_TRUE; break; } - } - } - - if (bWarning) - MNG_WARNING (pData, MNG_INVALIDCRC); - if (bError) - MNG_ERROR (pData, MNG_INVALIDCRC); - } - } - - if (!bDiscard) /* still processing ? */ - iRetcode = process_raw_chunk (pData, pBuf, iL); - } - else - { /* no crc => straight onto processing */ - iRetcode = process_raw_chunk (pData, pBuf, iBuflen); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_CHUNK_CRC, MNG_LC_END); -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -MNG_LOCAL 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_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)) - { /* reset timer indicator on read-cycle */ - if ((pData->bReading) && (!pData->bDisplaying)) - pData->bTimerset = MNG_FALSE; - - pData->pCurraniobj = ((mng_object_headerp)pData->pCurraniobj)->pNext; - /* TERM processing to be done ? */ - if ((!pData->pCurraniobj) && (pData->bHasTERM) && (!pData->bHasMHDR)) - iRetcode = mng_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 */ - { -#ifndef MNG_SKIPCHUNK_FRAM - case 1 : { iRetcode = mng_process_display_fram2 (pData); break; } -#endif - case 2 : { iRetcode = mng_process_display_ihdr (pData); break; } -#ifndef MNG_SKIPCHUNK_SHOW - case 3 : ; /* same as 4 !!! */ - case 4 : { iRetcode = mng_process_display_show (pData); break; } -#endif -#ifndef MNG_SKIPCHUNK_CLON - case 5 : { iRetcode = mng_process_display_clon2 (pData); break; } -#endif -#ifdef MNG_INCLUDE_JNG - case 7 : { iRetcode = mng_process_display_jhdr (pData); break; } -#endif - case 6 : ; /* same as 8 !!! */ - case 8 : { iRetcode = mng_process_display_iend (pData); break; } -#ifndef MNG_SKIPCHUNK_MAGN - case 9 : { iRetcode = mng_process_display_magn2 (pData); break; } -#endif - case 10 : { iRetcode = mng_process_display_mend2 (pData); break; } -#ifndef MNG_SKIPCHUNK_PAST - case 11 : { iRetcode = mng_process_display_past2 (pData); break; } -#endif - } - } - } - - 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 - { -#ifdef MNG_SUPPORT_DISPLAY - /* freezing in progress ? */ - if ((pData->bFreezing) && (pData->iSuspendpoint == 0)) - pData->bRunning = MNG_FALSE; /* then this is the right moment to do it */ -#endif - - if (pData->iSuspendpoint <= 2) - { - iBuflen = sizeof (mng_uint32); /* read length */ - iRetcode = read_databuffer (pData, pBuf, &pData->pReadbufnext, 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->iChunklen > 0x7ffffff) - return MNG_INVALIDLENGTH; - } - - } - - if (!pData->bSuspended) /* still going ? */ - { /* previously suspended or not eof ? */ - if ((pData->iSuspendpoint > 2) || (iRead == iBuflen)) - { /* determine length chunkname + data (+ crc) */ - if (pData->iCrcmode & MNG_CRC_INPUT) - iBuflen = pData->iChunklen + (mng_uint32)(sizeof (mng_chunkid) + sizeof (mng_uint32)); - else - iBuflen = pData->iChunklen + (mng_uint32)(sizeof (mng_chunkid)); - - /* do we have enough data in the current push buffer ? */ - if ((pData->pFirstpushdata) && (iBuflen <= pData->pFirstpushdata->iRemaining)) - { - mng_pushdatap pPush = pData->pFirstpushdata; - pBuf = pPush->pDatanext; - pPush->pDatanext += iBuflen; - pPush->iRemaining -= iBuflen; - pData->iSuspendpoint = 0; /* safely reset this here ! */ - - iRetcode = check_chunk_crc (pData, pBuf, iBuflen); - if (iRetcode) - return iRetcode; - - if (!pPush->iRemaining) /* buffer depleted? then release it */ - iRetcode = mng_release_pushdata (pData); - } - else - { - 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, &pData->pReadbufnext, 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 ? */ - MNG_ERROR (pData, MNG_UNEXPECTEDEOF); - iRetcode = check_chunk_crc (pData, pBuf, iBuflen); - } - } - else - { - if (iBuflen > 16777216) /* is the length incredible? */ - MNG_ERROR (pData, MNG_IMPROBABLELENGTH); - - if (!pData->iSuspendpoint) /* create additional large buffer ? */ - { /* again reserve space for the last zero-byte */ - pData->iLargebufsize = iBuflen + 1; - pData->pLargebufnext = MNG_NULL; - MNG_ALLOC (pData, pData->pLargebuf, pData->iLargebufsize); - } - - iRetcode = read_databuffer (pData, pData->pLargebuf, &pData->pLargebufnext, iBuflen, &iRead); - if (iRetcode) - return iRetcode; - - if (pData->bSuspended) /* suspended ? */ - pData->iSuspendpoint = 4; - else - { - if (iRead != iBuflen) /* did we get all the data ? */ - MNG_ERROR (pData, MNG_UNEXPECTEDEOF); - iRetcode = check_chunk_crc (pData, pData->pLargebuf, iBuflen); - /* cleanup additional large buffer */ - MNG_FREE (pData, pData->pLargebuf, pData->iLargebufsize); - } - } - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } - else - { /* that's final */ - iRetcode = mng_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 = mng_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_LOCAL mng_retcode process_pushedchunk (mng_datap pData) -{ - mng_pushdatap pPush; - mng_retcode iRetcode = MNG_NOERROR; - -#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)) - { /* reset timer indicator on read-cycle */ - if ((pData->bReading) && (!pData->bDisplaying)) - pData->bTimerset = MNG_FALSE; - - pData->pCurraniobj = ((mng_object_headerp)pData->pCurraniobj)->pNext; - /* TERM processing to be done ? */ - if ((!pData->pCurraniobj) && (pData->bHasTERM) && (!pData->bHasMHDR)) - iRetcode = mng_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 */ - { -#ifndef MNG_SKIPCHUNK_FRAM - case 1 : { iRetcode = mng_process_display_fram2 (pData); break; } -#endif - case 2 : { iRetcode = mng_process_display_ihdr (pData); break; } -#ifndef MNG_SKIPCHUNK_SHOW - case 3 : ; /* same as 4 !!! */ - case 4 : { iRetcode = mng_process_display_show (pData); break; } -#endif -#ifndef MNG_SKIPCHUNK_CLON - case 5 : { iRetcode = mng_process_display_clon2 (pData); break; } -#endif -#ifdef MNG_INCLUDE_JNG - case 7 : { iRetcode = mng_process_display_jhdr (pData); break; } -#endif - case 6 : ; /* same as 8 !!! */ - case 8 : { iRetcode = mng_process_display_iend (pData); break; } -#ifndef MNG_SKIPCHUNK_MAGN - case 9 : { iRetcode = mng_process_display_magn2 (pData); break; } -#endif - case 10 : { iRetcode = mng_process_display_mend2 (pData); break; } -#ifndef MNG_SKIPCHUNK_PAST - case 11 : { iRetcode = mng_process_display_past2 (pData); break; } -#endif - } - } - } - - 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 - { - pData->iSuspendpoint = 0; /* safely reset it here ! */ - pPush = pData->pFirstpushchunk; - - iRetcode = process_raw_chunk (pData, pPush->pData, pPush->iLength); - if (iRetcode) - return iRetcode; - -#ifdef MNG_SUPPORT_DISPLAY /* refresh needed ? */ - if ((!pData->bTimerset) && (!pData->bSuspended) && (pData->bNeedrefresh)) - { - iRetcode = mng_display_progressive_refresh (pData, 1); - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif - } - - return mng_release_pushchunk (pData); -} - -/* ************************************************************************** */ - -mng_retcode mng_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, &pData->pReadbufnext, 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 -#ifdef MNG_INCLUDE_JNG - if (mng_get_uint32 (pData->pReadbuf) == JNG_SIG) - pData->eSigtype = mng_it_jng; - else -#endif - 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 - { /* reset timer during mng_read() ? */ - if ((pData->bReading) && (!pData->bDisplaying)) - pData->bTimerset = MNG_FALSE; - - if (pData->pFirstpushchunk) /* chunks pushed ? */ - iRetcode = process_pushedchunk (pData); /* process the pushed chunk */ - else - iRetcode = read_chunk (pData); /* read & 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->pCurraniobj)) && - (!pData->bSuspended) && (!pData->bSectionwait) && - ((!pData->bTimerset) || ((pData->bReading) && (!pData->bDisplaying)))); -#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 * */ -/* ************************************************************************** */ - diff --git a/plugins/AdvaImg/src/LibMNG/libmng_read.h b/plugins/AdvaImg/src/LibMNG/libmng_read.h deleted file mode 100644 index e6399532b7..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_read.h +++ /dev/null @@ -1,53 +0,0 @@ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_read.h copyright (c) 2000-2004 G.Juyn * */ -/* * version : 1.0.8 * */ -/* * * */ -/* * purpose : Read management (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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 * */ -/* * * */ -/* * 0.9.3 - 10/18/2000 - G.Juyn * */ -/* * - added closestream() processing for mng_cleanup() * */ -/* * * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * * */ -/* * 1.0.8 - 04/12/2004 - G.Juyn * */ -/* * - added data-push mechanisms for specialized decoders * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_read_h_ -#define _libmng_read_h_ - -/* ************************************************************************** */ - -mng_retcode mng_process_eof (mng_datap pData); - -mng_retcode mng_release_pushdata (mng_datap pData); - -mng_retcode mng_release_pushchunk (mng_datap pData); - -mng_retcode mng_read_graphic (mng_datap pData); - -/* ************************************************************************** */ - -#endif /* _libmng_read_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/plugins/AdvaImg/src/LibMNG/libmng_trace.c b/plugins/AdvaImg/src/LibMNG/libmng_trace.c deleted file mode 100644 index ffb7b57d2e..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_trace.c +++ /dev/null @@ -1,1683 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_trace.c copyright (c) 2000-2007 G.Juyn * */ -/* * version : 1.0.10 * */ -/* * * */ -/* * purpose : Trace functions (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * comment : implementation of the trace functions * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - added callback error-reporting support * */ -/* * * */ -/* * 0.5.2 - 05/23/2000 - G.Juyn * */ -/* * - added trace telltale reporting * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - added tracestrings for global animation color-chunks * */ -/* * - added tracestrings for get/set of default ZLIB/IJG parms * */ -/* * - added tracestrings for global PLTE,tRNS,bKGD * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added tracestrings for image-object promotion * */ -/* * - added tracestrings for delta-image processing * */ -/* * 0.5.2 - 06/02/2000 - G.Juyn * */ -/* * - added tracestrings for getalphaline callback * */ -/* * 0.5.2 - 06/05/2000 - G.Juyn * */ -/* * - added tracestring for RGB8_A8 canvasstyle * */ -/* * 0.5.2 - 06/06/2000 - G.Juyn * */ -/* * - added tracestring for mng_read_resume HLAPI function * */ -/* * * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added tracestrings for get/set speedtype * */ -/* * - added tracestring for get imagelevel * */ -/* * 0.5.3 - 06/22/2000 - G.Juyn * */ -/* * - added tracestring for delta-image processing * */ -/* * - added tracestrings for PPLT chunk processing * */ -/* * * */ -/* * 0.9.1 - 07/07/2000 - G.Juyn * */ -/* * - added tracecodes for special display processing * */ -/* * 0.9.1 - 07/08/2000 - G.Juyn * */ -/* * - added tracestring for get/set suspensionmode * */ -/* * - added tracestrings for get/set display variables * */ -/* * - added tracecode for read_databuffer (I/O-suspension) * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - added tracestrings for SAVE/SEEK callbacks * */ -/* * - added tracestrings for get/set sectionbreaks * */ -/* * - added tracestring for special error routine * */ -/* * 0.9.1 - 07/19/2000 - G.Juyn * */ -/* * - added tracestring for updatemngheader * */ -/* * * */ -/* * 0.9.2 - 07/31/2000 - G.Juyn * */ -/* * - added tracestrings for status_xxxxx functions * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * - added tracestring for updatemngsimplicity * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * 0.9.3 - 10/10/2000 - G.Juyn * */ -/* * - added support for alpha-depth prediction * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - added JDAA chunk * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added functions to retrieve PNG/JNG specific header-info * */ -/* * - added optional support for bKGD for PNG images * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added callback to process non-critical unknown chunks * */ -/* * - added routine to discard "invalid" objects * */ -/* * 0.9.3 - 10/19/2000 - G.Juyn * */ -/* * - implemented delayed delta-processing * */ -/* * 0.9.3 - 10/20/2000 - G.Juyn * */ -/* * - added get/set for bKGD preference setting * */ -/* * 0.9.3 - 10/21/2000 - G.Juyn * */ -/* * - added get function for interlace/progressive display * */ -/* * * */ -/* * 0.9.4 - 1/18/2001 - G.Juyn * */ -/* * - added "new" MAGN methods 3, 4 & 5 * */ -/* * * */ -/* * 1.0.1 - 02/08/2001 - G.Juyn * */ -/* * - added MEND processing callback * */ -/* * 1.0.1 - 04/21/2001 - G.Juyn (code by G.Kelly) * */ -/* * - added BGRA8 canvas with premultiplied alpha * */ -/* * 1.0.1 - 05/02/2001 - G.Juyn * */ -/* * - added "default" sRGB generation (Thanks Marti!) * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added optimization option for MNG-video playback * */ -/* * - added processterm callback * */ -/* * 1.0.2 - 06/25/2001 - G.Juyn * */ -/* * - added option to turn off progressive refresh * */ -/* * * */ -/* * 1.0.3 - 08/06/2001 - G.Juyn * */ -/* * - added get function for last processed BACK chunk * */ -/* * * */ -/* * 1.0.5 - 08/15/2002 - G.Juyn * */ -/* * - completed PROM support * */ -/* * - completed delta-image support * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * - added HLAPI function to copy chunks * */ -/* * 1.0.5 - 09/14/2002 - G.Juyn * */ -/* * - added event handling for dynamic MNG * */ -/* * 1.0.5 - 09/20/2002 - G.Juyn * */ -/* * - added support for PAST * */ -/* * 1.0.5 - 09/22/2002 - G.Juyn * */ -/* * - added bgrx8 canvas (filler byte) * */ -/* * 1.0.5 - 09/23/2002 - G.Juyn * */ -/* * - added in-memory color-correction of abstract images * */ -/* * - added compose over/under routines for PAST processing * */ -/* * - added flip & tile routines for PAST processing * */ -/* * 1.0.5 - 10/09/2002 - G.Juyn * */ -/* * - fixed trace-constants for PAST chunk * */ -/* * 1.0.5 - 11/07/2002 - G.Juyn * */ -/* * - added support to get totals after mng_read() * */ -/* * * */ -/* * 1.0.6 - 07/07/2003 - G.R-P * */ -/* * - added conditionals around JNG and Delta-PNG code * */ -/* * 1.0.6 - 07/14/2003 - G.R-P * */ -/* * - added conditionals around various unused functions * */ -/* * 1.0.6 - 07/29/2003 - G.R-P * */ -/* * - added conditionals around PAST chunk support * */ -/* * * */ -/* * 1.0.7 - 11/27/2003 - R.A * */ -/* * - added CANVAS_RGB565 and CANVAS_BGR565 * */ -/* * 1.0.7 - 01/25/2004 - J.S * */ -/* * - added premultiplied alpha canvas' for RGBA, ARGB, ABGR * */ -/* * 1.0.7 - 03/07/2004 - G. Randers-Pehrson * */ -/* * - put gamma, cms-related declarations inside #ifdef * */ -/* * 1.0.7 - 03/10/2004 - G.R-P * */ -/* * - added conditionals around openstream/closestream * */ -/* * * */ -/* * 1.0.8 - 04/02/2004 - G.Juyn * */ -/* * - added CRC existence & checking flags * */ -/* * 1.0.8 - 04/11/2004 - G.Juyn * */ -/* * - added data-push mechanisms for specialized decoders * */ -/* * * */ -/* * 1.0.9 - 10/03/2004 - G.Juyn * */ -/* * - added function to retrieve current FRAM delay * */ -/* * 1.0.9 - 10/14/2004 - G.Juyn * */ -/* * - added bgr565_a8 canvas-style (thanks to J. Elvander) * */ -/* * * */ -/* * 1.0.10 - 04/08/2007 - G.Juyn * */ -/* * - added support for mPNG proposal * */ -/* * 1.0.10 - 07/06/2007 - G.R-P bugfix by Lucas Quintana * */ -/* * * */ -/* ************************************************************************** */ - -#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_TRACE_PROCS - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_TRACE_STRINGS -MNG_LOCAL mng_trace_entry const trace_table [] = - { - {MNG_FN_INITIALIZE, "initialize"}, - {MNG_FN_RESET, "reset"}, - {MNG_FN_CLEANUP, "cleanup"}, - {MNG_FN_READ, "read"}, - {MNG_FN_WRITE, "write"}, - {MNG_FN_CREATE, "create"}, - {MNG_FN_READDISPLAY, "readdisplay"}, - {MNG_FN_DISPLAY, "display"}, - {MNG_FN_DISPLAY_RESUME, "display_resume"}, - {MNG_FN_DISPLAY_FREEZE, "display_freeze"}, - {MNG_FN_DISPLAY_RESET, "display_reset"}, -#ifndef MNG_NO_DISPLAY_GO_SUPPORTED - {MNG_FN_DISPLAY_GOFRAME, "display_goframe"}, - {MNG_FN_DISPLAY_GOLAYER, "display_golayer"}, - {MNG_FN_DISPLAY_GOTIME, "display_gotime"}, -#endif - {MNG_FN_GETLASTERROR, "getlasterror"}, - {MNG_FN_READ_RESUME, "read_resume"}, - {MNG_FN_TRAPEVENT, "trapevent"}, - {MNG_FN_READ_PUSHDATA, "read_pushdata"}, - {MNG_FN_READ_PUSHSIG, "read_pushsig"}, - {MNG_FN_READ_PUSHCHUNK, "read_pushchunk"}, - - {MNG_FN_SETCB_MEMALLOC, "setcb_memalloc"}, - {MNG_FN_SETCB_MEMFREE, "setcb_memfree"}, - {MNG_FN_SETCB_READDATA, "setcb_readdata"}, - {MNG_FN_SETCB_WRITEDATA, "setcb_writedata"}, - {MNG_FN_SETCB_ERRORPROC, "setcb_errorproc"}, - {MNG_FN_SETCB_TRACEPROC, "setcb_traceproc"}, - {MNG_FN_SETCB_PROCESSHEADER, "setcb_processheader"}, - {MNG_FN_SETCB_PROCESSTEXT, "setcb_processtext"}, - {MNG_FN_SETCB_GETCANVASLINE, "setcb_getcanvasline"}, - {MNG_FN_SETCB_GETBKGDLINE, "setcb_getbkgdline"}, - {MNG_FN_SETCB_REFRESH, "setcb_refresh"}, - {MNG_FN_SETCB_GETTICKCOUNT, "setcb_gettickcount"}, - {MNG_FN_SETCB_SETTIMER, "setcb_settimer"}, - {MNG_FN_SETCB_PROCESSGAMMA, "setcb_processgamma"}, - {MNG_FN_SETCB_PROCESSCHROMA, "setcb_processchroma"}, - {MNG_FN_SETCB_PROCESSSRGB, "setcb_processsrgb"}, - {MNG_FN_SETCB_PROCESSICCP, "setcb_processiccp"}, - {MNG_FN_SETCB_PROCESSAROW, "setcb_processarow"}, -#ifndef MNG_NO_OPEN_CLOSE_STREAM - {MNG_FN_SETCB_OPENSTREAM, "setcb_openstream"}, - {MNG_FN_SETCB_CLOSESTREAM, "setcb_closestream"}, -#endif - {MNG_FN_SETCB_GETALPHALINE, "setcb_getalphaline"}, - {MNG_FN_SETCB_PROCESSSAVE, "setcb_processsave"}, - {MNG_FN_SETCB_PROCESSSEEK, "setcb_processseek"}, - {MNG_FN_SETCB_PROCESSNEED, "setcb_processneed"}, - {MNG_FN_SETCB_PROCESSUNKNOWN, "setcb_processunknown"}, - {MNG_FN_SETCB_PROCESSMEND, "setcb_processmend"}, - {MNG_FN_SETCB_PROCESSTERM, "setcb_processterm"}, - {MNG_FN_SETCB_RELEASEDATA, "setcb_releasedata"}, - - {MNG_FN_GETCB_MEMALLOC, "getcb_memalloc"}, - {MNG_FN_GETCB_MEMFREE, "getcb_memfree"}, - {MNG_FN_GETCB_READDATA, "getcb_readdata,"}, - {MNG_FN_GETCB_WRITEDATA, "getcb_writedata"}, - {MNG_FN_GETCB_ERRORPROC, "getcb_errorproc"}, - {MNG_FN_GETCB_TRACEPROC, "getcb_traceproc"}, - {MNG_FN_GETCB_PROCESSHEADER, "getcb_processheader"}, - {MNG_FN_GETCB_PROCESSTEXT, "getcb_processtext"}, - {MNG_FN_GETCB_GETCANVASLINE, "getcb_getcanvasline"}, - {MNG_FN_GETCB_GETBKGDLINE, "getcb_getbkgdline"}, - {MNG_FN_GETCB_REFRESH, "getcb_refresh"}, - {MNG_FN_GETCB_GETTICKCOUNT, "getcb_gettickcount"}, - {MNG_FN_GETCB_SETTIMER, "getcb_settimer"}, - {MNG_FN_GETCB_PROCESSGAMMA, "getcb_processgamma"}, - {MNG_FN_GETCB_PROCESSCHROMA, "getcb_processchroma"}, - {MNG_FN_GETCB_PROCESSSRGB, "getcb_processsrgb"}, - {MNG_FN_GETCB_PROCESSICCP, "getcb_processiccp"}, - {MNG_FN_GETCB_PROCESSAROW, "getcb_processarow"}, -#ifndef MNG_NO_OPEN_CLOSE_STREAM - {MNG_FN_GETCB_OPENSTREAM, "getcb_openstream"}, - {MNG_FN_GETCB_CLOSESTREAM, "getcb_closestream"}, -#endif - {MNG_FN_GETCB_GETALPHALINE, "getcb_getalphaline"}, - {MNG_FN_GETCB_PROCESSSAVE, "getcb_processsave"}, - {MNG_FN_GETCB_PROCESSSEEK, "getcb_processseek"}, - {MNG_FN_GETCB_PROCESSNEED, "getcb_processneed"}, - {MNG_FN_GETCB_PROCESSUNKNOWN, "getcb_processunknown"}, - {MNG_FN_GETCB_PROCESSMEND, "getcb_processmend"}, - {MNG_FN_GETCB_PROCESSTERM, "getcb_processterm"}, - {MNG_FN_GETCB_RELEASEDATA, "getcb_releasedata"}, - - {MNG_FN_SET_USERDATA, "set_userdata"}, - {MNG_FN_SET_CANVASSTYLE, "set_canvasstyle"}, - {MNG_FN_SET_BKGDSTYLE, "set_bkgdstyle"}, - {MNG_FN_SET_BGCOLOR, "set_bgcolor"}, - {MNG_FN_SET_STORECHUNKS, "set_storechunks"}, -#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) || defined(MNG_APP_CMS) - {MNG_FN_SET_VIEWGAMMA, "set_viewgamma"}, -#ifndef MNG_NO_DFLT_INFO - {MNG_FN_SET_DISPLAYGAMMA, "set_displaygamma"}, -#endif - {MNG_FN_SET_DFLTIMGGAMMA, "set_dfltimggamma"}, -#endif - {MNG_FN_SET_SRGB, "set_srgb"}, - {MNG_FN_SET_OUTPUTPROFILE, "set_outputprofile"}, - {MNG_FN_SET_SRGBPROFILE, "set_srgbprofile"}, -#ifndef MNG_SKIP_MAXCANVAS - {MNG_FN_SET_MAXCANVASWIDTH, "set_maxcanvaswidth"}, - {MNG_FN_SET_MAXCANVASHEIGHT, "set_maxcanvasheight"}, - {MNG_FN_SET_MAXCANVASSIZE, "set_maxcanvassize"}, -#endif -#ifndef MNG_NO_ACCESS_ZLIB - {MNG_FN_SET_ZLIB_LEVEL, "set_zlib_level"}, - {MNG_FN_SET_ZLIB_METHOD, "set_zlib_method"}, - {MNG_FN_SET_ZLIB_WINDOWBITS, "set_zlib_windowbits"}, - {MNG_FN_SET_ZLIB_MEMLEVEL, "set_zlib_memlevel"}, - {MNG_FN_SET_ZLIB_STRATEGY, "set_zlib_strategy"}, - {MNG_FN_SET_ZLIB_MAXIDAT, "set_zlib_maxidat"}, -#endif -#ifndef MNG_NO_ACCESS_JPEG - {MNG_FN_SET_JPEG_DCTMETHOD, "set_jpeg_dctmethod"}, - {MNG_FN_SET_JPEG_QUALITY, "set_jpeg_quality"}, - {MNG_FN_SET_JPEG_SMOOTHING, "set_jpeg_smoothing"}, - {MNG_FN_SET_JPEG_PROGRESSIVE, "set_jpeg_progressive"}, - {MNG_FN_SET_JPEG_OPTIMIZED, "set_jpeg_optimized"}, - {MNG_FN_SET_JPEG_MAXJDAT, "set_jpeg_maxjdat"}, -#endif - {MNG_FN_SET_SPEED, "set_speed"}, - {MNG_FN_SET_SUSPENSIONMODE, "set_suspensionmode"}, - {MNG_FN_SET_SECTIONBREAKS, "set_sectionbreaks"}, - {MNG_FN_SET_USEBKGD, "set_usebkgd"}, - {MNG_FN_SET_OUTPUTPROFILE2, "set_outputprofile2"}, - {MNG_FN_SET_SRGBPROFILE2, "set_srgbprofile2"}, - {MNG_FN_SET_OUTPUTSRGB, "set_outputsrgb"}, - {MNG_FN_SET_SRGBIMPLICIT, "set_srgbimplicit"}, - {MNG_FN_SET_CACHEPLAYBACK, "set_cacheplayback"}, - {MNG_FN_SET_DOPROGRESSIVE, "set_doprogressive"}, - {MNG_FN_SET_CRCMODE, "set_crcmode"}, - - {MNG_FN_GET_USERDATA, "get_userdata"}, - {MNG_FN_GET_SIGTYPE, "get_sigtype"}, - {MNG_FN_GET_IMAGETYPE, "get_imagetype"}, - {MNG_FN_GET_IMAGEWIDTH, "get_imagewidth"}, - {MNG_FN_GET_IMAGEHEIGHT, "get_imageheight"}, - {MNG_FN_GET_TICKS, "get_ticks"}, - {MNG_FN_GET_FRAMECOUNT, "get_framecount"}, - {MNG_FN_GET_LAYERCOUNT, "get_layercount"}, - {MNG_FN_GET_PLAYTIME, "get_playtime"}, - {MNG_FN_GET_SIMPLICITY, "get_simplicity"}, - {MNG_FN_GET_CANVASSTYLE, "get_canvasstyle"}, - {MNG_FN_GET_BKGDSTYLE, "get_bkgdstyle"}, - {MNG_FN_GET_BGCOLOR, "get_bgcolor"}, - {MNG_FN_GET_STORECHUNKS, "get_storechunks"}, -#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) || defined(MNG_APP_CMS) - {MNG_FN_GET_VIEWGAMMA, "get_viewgamma"}, - {MNG_FN_GET_DISPLAYGAMMA, "get_displaygamma"}, -#ifndef MNG_NO_DFLT_INFO - {MNG_FN_GET_DFLTIMGGAMMA, "get_dfltimggamma"}, -#endif -#endif - {MNG_FN_GET_SRGB, "get_srgb"}, -#ifndef MNG_SKIP_MAXCANVAS - {MNG_FN_GET_MAXCANVASWIDTH, "get_maxcanvaswidth"}, - {MNG_FN_GET_MAXCANVASHEIGHT, "get_maxcanvasheight"}, -#endif -#ifndef MNG_NO_ACCESS_ZLIB - {MNG_FN_GET_ZLIB_LEVEL, "get_zlib_level"}, - {MNG_FN_GET_ZLIB_METHOD, "get_zlib_method"}, - {MNG_FN_GET_ZLIB_WINDOWBITS, "get_zlib_windowbits"}, - {MNG_FN_GET_ZLIB_MEMLEVEL, "get_zlib_memlevel"}, - {MNG_FN_GET_ZLIB_STRATEGY, "get_zlib_strategy"}, - {MNG_FN_GET_ZLIB_MAXIDAT, "get_zlib_maxidat"}, -#endif -#ifndef MNG_NO_ACCESS_JPEG - {MNG_FN_GET_JPEG_DCTMETHOD, "get_jpeg_dctmethod"}, - {MNG_FN_GET_JPEG_QUALITY, "get_jpeg_quality"}, - {MNG_FN_GET_JPEG_SMOOTHING, "get_jpeg_smoothing"}, - {MNG_FN_GET_JPEG_PROGRESSIVE, "get_jpeg_progressive"}, - {MNG_FN_GET_JPEG_OPTIMIZED, "get_jpeg_optimized"}, - {MNG_FN_GET_JPEG_MAXJDAT, "get_jpeg_maxjdat"}, -#endif - {MNG_FN_GET_SPEED, "get_speed"}, - {MNG_FN_GET_IMAGELEVEL, "get_imagelevel"}, - {MNG_FN_GET_SUSPENSIONMODE, "get_speed"}, - {MNG_FN_GET_STARTTIME, "get_starttime"}, - {MNG_FN_GET_RUNTIME, "get_runtime"}, -#ifndef MNG_NO_CURRENT_INFO - {MNG_FN_GET_CURRENTFRAME, "get_currentframe"}, - {MNG_FN_GET_CURRENTLAYER, "get_currentlayer"}, - {MNG_FN_GET_CURRENTPLAYTIME, "get_currentplaytime"}, -#endif - {MNG_FN_GET_SECTIONBREAKS, "get_sectionbreaks"}, - {MNG_FN_GET_ALPHADEPTH, "get_alphadepth"}, - {MNG_FN_GET_BITDEPTH, "get_bitdepth"}, - {MNG_FN_GET_COLORTYPE, "get_colortype"}, - {MNG_FN_GET_COMPRESSION, "get_compression"}, - {MNG_FN_GET_FILTER, "get_filter"}, - {MNG_FN_GET_INTERLACE, "get_interlace"}, - {MNG_FN_GET_ALPHABITDEPTH, "get_alphabitdepth"}, - {MNG_FN_GET_ALPHACOMPRESSION, "get_alphacompression"}, - {MNG_FN_GET_ALPHAFILTER, "get_alphafilter"}, - {MNG_FN_GET_ALPHAINTERLACE, "get_alphainterlace"}, - {MNG_FN_GET_USEBKGD, "get_usebkgd"}, - {MNG_FN_GET_REFRESHPASS, "get_refreshpass"}, - {MNG_FN_GET_CACHEPLAYBACK, "get_cacheplayback"}, - {MNG_FN_GET_DOPROGRESSIVE, "get_doprogressive"}, - {MNG_FN_GET_LASTBACKCHUNK, "get_lastbackchunk"}, - {MNG_FN_GET_LASTSEEKNAME, "get_lastseekname"}, -#ifndef MNG_NO_CURRENT_INFO - {MNG_FN_GET_TOTALFRAMES, "get_totalframes"}, - {MNG_FN_GET_TOTALLAYERS, "get_totallayers"}, - {MNG_FN_GET_TOTALPLAYTIME, "get_totalplaytime"}, -#endif - {MNG_FN_GET_CRCMODE, "get_crcmode"}, - {MNG_FN_GET_CURRFRAMDELAY, "get_currframdelay"}, - - {MNG_FN_STATUS_ERROR, "status_error"}, - {MNG_FN_STATUS_READING, "status_reading"}, - {MNG_FN_STATUS_SUSPENDBREAK, "status_suspendbreak"}, - {MNG_FN_STATUS_CREATING, "status_creating"}, - {MNG_FN_STATUS_WRITING, "status_writing"}, - {MNG_FN_STATUS_DISPLAYING, "status_displaying"}, - {MNG_FN_STATUS_RUNNING, "status_running"}, - {MNG_FN_STATUS_TIMERBREAK, "status_timerbreak"}, - {MNG_FN_STATUS_DYNAMIC, "status_dynamic"}, - {MNG_FN_STATUS_RUNNINGEVENT, "status_runningevent"}, - - {MNG_FN_ITERATE_CHUNKS, "iterate_chunks"}, - {MNG_FN_COPY_CHUNK, "copy_chunk"}, - - {MNG_FN_GETCHUNK_IHDR, "getchunk_ihdr"}, - {MNG_FN_GETCHUNK_PLTE, "getchunk_plte"}, - {MNG_FN_GETCHUNK_IDAT, "getchunk_idat"}, - {MNG_FN_GETCHUNK_IEND, "getchunk_iend"}, - {MNG_FN_GETCHUNK_TRNS, "getchunk_trns"}, -#ifndef MNG_SKIPCHUNK_gAMA - {MNG_FN_GETCHUNK_GAMA, "getchunk_gama"}, -#endif -#ifndef MNG_SKIPCHUNK_cHRM - {MNG_FN_GETCHUNK_CHRM, "getchunk_chrm"}, -#endif -#ifndef MNG_SKIPCHUNK_sRGB - {MNG_FN_GETCHUNK_SRGB, "getchunk_srgb"}, -#endif -#ifndef MNG_SKIPCHUNK_iCCP - {MNG_FN_GETCHUNK_ICCP, "getchunk_iccp"}, -#endif -#ifndef MNG_SKIPCHUNK_tEXt - {MNG_FN_GETCHUNK_TEXT, "getchunk_text"}, -#endif -#ifndef MNG_SKIPCHUNK_zTXt - {MNG_FN_GETCHUNK_ZTXT, "getchunk_ztxt"}, -#endif -#ifndef MNG_SKIPCHUNK_iTXt - {MNG_FN_GETCHUNK_ITXT, "getchunk_itxt"}, -#endif -#ifndef MNG_SKIPCHUNK_bKGD - {MNG_FN_GETCHUNK_BKGD, "getchunk_bkgd"}, -#endif -#ifndef MNG_SKIPCHUNK_pHYs - {MNG_FN_GETCHUNK_PHYS, "getchunk_phys"}, -#endif -#ifndef MNG_SKIPCHUNK_sBIT - {MNG_FN_GETCHUNK_SBIT, "getchunk_sbit"}, -#endif -#ifndef MNG_SKIPCHUNK_sPLT - {MNG_FN_GETCHUNK_SPLT, "getchunk_splt"}, -#endif -#ifndef MNG_SKIPCHUNK_hIST - {MNG_FN_GETCHUNK_HIST, "getchunk_hist"}, -#endif -#ifndef MNG_SKIPCHUNK_tIME - {MNG_FN_GETCHUNK_TIME, "getchunk_time"}, -#endif - {MNG_FN_GETCHUNK_MHDR, "getchunk_mhdr"}, - {MNG_FN_GETCHUNK_MEND, "getchunk_mend"}, -#ifndef MNG_SKIPCHUNK_LOOP - {MNG_FN_GETCHUNK_LOOP, "getchunk_loop"}, - {MNG_FN_GETCHUNK_ENDL, "getchunk_endl"}, -#endif - {MNG_FN_GETCHUNK_DEFI, "getchunk_defi"}, -#ifndef MNG_SKIPCHUNK_BASI - {MNG_FN_GETCHUNK_BASI, "getchunk_basi"}, -#endif - {MNG_FN_GETCHUNK_CLON, "getchunk_clon"}, -#ifndef MNG_SKIPCHUNK_PAST - {MNG_FN_GETCHUNK_PAST, "getchunk_past"}, -#endif - {MNG_FN_GETCHUNK_DISC, "getchunk_disc"}, - {MNG_FN_GETCHUNK_BACK, "getchunk_back"}, - {MNG_FN_GETCHUNK_FRAM, "getchunk_fram"}, - {MNG_FN_GETCHUNK_MOVE, "getchunk_move"}, - {MNG_FN_GETCHUNK_CLIP, "getchunk_clip"}, - {MNG_FN_GETCHUNK_SHOW, "getchunk_show"}, - {MNG_FN_GETCHUNK_TERM, "getchunk_term"}, -#ifndef MNG_SKIPCHUNK_SAVE - {MNG_FN_GETCHUNK_SAVE, "getchunk_save"}, -#endif -#ifndef MNG_SKIPCHUNK_SEEK - {MNG_FN_GETCHUNK_SEEK, "getchunk_seek"}, -#endif -#ifndef MNG_SKIPCHUNK_eXPI - {MNG_FN_GETCHUNK_EXPI, "getchunk_expi"}, -#endif -#ifndef MNG_SKIPCHUNK_fPRI - {MNG_FN_GETCHUNK_FPRI, "getchunk_fpri"}, -#endif -#ifndef MNG_SKIPCHUNK_nEED - {MNG_FN_GETCHUNK_NEED, "getchunk_need"}, -#endif -#ifndef MNG_SKIPCHUNK_pHYg - {MNG_FN_GETCHUNK_PHYG, "getchunk_phyg"}, -#endif -#ifdef MNG_INCLUDE_JNG - {MNG_FN_GETCHUNK_JHDR, "getchunk_jhdr"}, - {MNG_FN_GETCHUNK_JDAT, "getchunk_jdat"}, - {MNG_FN_GETCHUNK_JSEP, "getchunk_jsep"}, -#endif -#ifndef MNG_NO_DELTA_PNG - {MNG_FN_GETCHUNK_DHDR, "getchunk_dhdr"}, - {MNG_FN_GETCHUNK_PROM, "getchunk_prom"}, - {MNG_FN_GETCHUNK_IPNG, "getchunk_ipng"}, - {MNG_FN_GETCHUNK_PPLT, "getchunk_pplt"}, -#ifdef MNG_INCLUDE_JNG - {MNG_FN_GETCHUNK_IJNG, "getchunk_ijng"}, -#endif -#ifndef MNG_SKIPCHUNK_DROP - {MNG_FN_GETCHUNK_DROP, "getchunk_drop"}, -#endif -#ifndef MNG_SKIPCHUNK_DBYK - {MNG_FN_GETCHUNK_DBYK, "getchunk_dbyk"}, -#endif -#ifndef MNG_SKIPCHUNK_ORDR - {MNG_FN_GETCHUNK_ORDR, "getchunk_ordr"}, -#endif -#endif - {MNG_FN_GETCHUNK_UNKNOWN, "getchunk_unknown"}, - {MNG_FN_GETCHUNK_MAGN, "getchunk_magn"}, -#ifdef MNG_INCLUDE_JNG - {MNG_FN_GETCHUNK_JDAA, "getchunk_jdaa"}, -#endif -#ifndef MNG_SKIPCHUNK_evNT - {MNG_FN_GETCHUNK_EVNT, "getchunk_evnt"}, -#endif -#ifdef MNG_INCLUDE_MPNG_PROPOSAL - {MNG_FN_GETCHUNK_MPNG, "getchunk_mpng"}, -#endif - -#ifndef MNG_SKIPCHUNK_PAST - {MNG_FN_GETCHUNK_PAST_SRC, "getchunk_past_src"}, -#endif -#ifndef MNG_SKIPCHUNK_SAVE - {MNG_FN_GETCHUNK_SAVE_ENTRY, "getchunk_save_entry"}, -#endif -#ifndef MNG_NO_DELTA_PNG - {MNG_FN_GETCHUNK_PPLT_ENTRY, "getchunk_pplt_entry"}, - {MNG_FN_GETCHUNK_ORDR_ENTRY, "getchunk_ordr_entry"}, -#endif -#ifndef MNG_SKIPCHUNK_evNT - {MNG_FN_GETCHUNK_EVNT_ENTRY, "getchunk_evnt_entry"}, -#endif -#ifdef MNG_INCLUDE_MPNG_PROPOSAL - {MNG_FN_GETCHUNK_MPNG_FRAME, "getchunk_mpng_frame"}, -#endif - - {MNG_FN_PUTCHUNK_IHDR, "putchunk_ihdr"}, - {MNG_FN_PUTCHUNK_PLTE, "putchunk_plte"}, - {MNG_FN_PUTCHUNK_IDAT, "putchunk_idat"}, - {MNG_FN_PUTCHUNK_IEND, "putchunk_iend"}, - {MNG_FN_PUTCHUNK_TRNS, "putchunk_trns"}, -#ifndef MNG_SKIPCHUNK_gAMA - {MNG_FN_PUTCHUNK_GAMA, "putchunk_gama"}, -#endif -#ifndef MNG_SKIPCHUNK_cHRM - {MNG_FN_PUTCHUNK_CHRM, "putchunk_chrm"}, -#endif -#ifndef MNG_SKIPCHUNK_sRGB - {MNG_FN_PUTCHUNK_SRGB, "putchunk_srgb"}, -#endif -#ifndef MNG_SKIPCHUNK_iCCP - {MNG_FN_PUTCHUNK_ICCP, "putchunk_iccp"}, -#endif -#ifndef MNG_SKIPCHUNK_tEXt - {MNG_FN_PUTCHUNK_TEXT, "putchunk_text"}, -#endif -#ifndef MNG_SKIPCHUNK_zTXt - {MNG_FN_PUTCHUNK_ZTXT, "putchunk_ztxt"}, -#endif -#ifndef MNG_SKIPCHUNK_iTXt - {MNG_FN_PUTCHUNK_ITXT, "putchunk_itxt"}, -#endif -#ifndef MNG_SKIPCHUNK_bKGD - {MNG_FN_PUTCHUNK_BKGD, "putchunk_bkgd"}, -#endif -#ifndef MNG_SKIPCHUNK_pHYs - {MNG_FN_PUTCHUNK_PHYS, "putchunk_phys"}, -#endif -#ifndef MNG_SKIPCHUNK_sBIT - {MNG_FN_PUTCHUNK_SBIT, "putchunk_sbit"}, -#endif -#ifndef MNG_SKIPCHUNK_sPLT - {MNG_FN_PUTCHUNK_SPLT, "putchunk_splt"}, -#endif -#ifndef MNG_SKIPCHUNK_hIST - {MNG_FN_PUTCHUNK_HIST, "putchunk_hist"}, -#endif -#ifndef MNG_SKIPCHUNK_tIME - {MNG_FN_PUTCHUNK_TIME, "putchunk_time"}, -#endif - {MNG_FN_PUTCHUNK_MHDR, "putchunk_mhdr"}, - {MNG_FN_PUTCHUNK_MEND, "putchunk_mend"}, - {MNG_FN_PUTCHUNK_LOOP, "putchunk_loop"}, - {MNG_FN_PUTCHUNK_ENDL, "putchunk_endl"}, - {MNG_FN_PUTCHUNK_DEFI, "putchunk_defi"}, - {MNG_FN_PUTCHUNK_BASI, "putchunk_basi"}, - {MNG_FN_PUTCHUNK_CLON, "putchunk_clon"}, -#ifndef MNG_SKIPCHUNK_PAST - {MNG_FN_PUTCHUNK_PAST, "putchunk_past"}, -#endif - {MNG_FN_PUTCHUNK_DISC, "putchunk_disc"}, - {MNG_FN_PUTCHUNK_BACK, "putchunk_back"}, - {MNG_FN_PUTCHUNK_FRAM, "putchunk_fram"}, - {MNG_FN_PUTCHUNK_MOVE, "putchunk_move"}, - {MNG_FN_PUTCHUNK_CLIP, "putchunk_clip"}, - {MNG_FN_PUTCHUNK_SHOW, "putchunk_show"}, - {MNG_FN_PUTCHUNK_TERM, "putchunk_term"}, -#ifndef MNG_SKIPCHUNK_SAVE - {MNG_FN_PUTCHUNK_SAVE, "putchunk_save"}, -#endif -#ifndef MNG_SKIPCHUNK_SEEK - {MNG_FN_PUTCHUNK_SEEK, "putchunk_seek"}, -#endif -#ifndef MNG_SKIPCHUNK_eXPI - {MNG_FN_PUTCHUNK_EXPI, "putchunk_expi"}, -#endif -#ifndef MNG_SKIPCHUNK_fPRI - {MNG_FN_PUTCHUNK_FPRI, "putchunk_fpri"}, -#endif -#ifndef MNG_SKIPCHUNK_nEED - {MNG_FN_PUTCHUNK_NEED, "putchunk_need"}, -#endif -#ifndef MNG_SKIPCHUNK_pHYg - {MNG_FN_PUTCHUNK_PHYG, "putchunk_phyg"}, -#endif -#ifdef MNG_INCLUDE_JNG - {MNG_FN_PUTCHUNK_JHDR, "putchunk_jhdr"}, - {MNG_FN_PUTCHUNK_JDAT, "putchunk_jdat"}, - {MNG_FN_PUTCHUNK_JSEP, "putchunk_jsep"}, -#endif -#ifndef MNG_NO_DELTA_PNG - {MNG_FN_PUTCHUNK_DHDR, "putchunk_dhdr"}, - {MNG_FN_PUTCHUNK_PROM, "putchunk_prom"}, -#ifdef MNG_INCLUDE_JNG - {MNG_FN_PUTCHUNK_IPNG, "putchunk_ipng"}, -#endif - {MNG_FN_PUTCHUNK_PPLT, "putchunk_pplt"}, - {MNG_FN_PUTCHUNK_IJNG, "putchunk_ijng"}, -#ifndef MNG_SKIPCHUNK_DROP - {MNG_FN_PUTCHUNK_DROP, "putchunk_drop"}, -#endif -#ifndef MNG_SKIPCHUNK_DBYK - {MNG_FN_PUTCHUNK_DBYK, "putchunk_dbyk"}, -#endif -#ifndef MNG_SKIPCHUNK_ORDR - {MNG_FN_PUTCHUNK_ORDR, "putchunk_ordr"}, -#endif -#endif - {MNG_FN_PUTCHUNK_UNKNOWN, "putchunk_unknown"}, - {MNG_FN_PUTCHUNK_MAGN, "putchunk_magn"}, - {MNG_FN_PUTCHUNK_JDAA, "putchunk_jdaa"}, -#ifndef MNG_SKIPCHUNK_evNT - {MNG_FN_PUTCHUNK_EVNT, "putchunk_evnt"}, -#endif -#ifdef MNG_INCLUDE_MPNG_PROPOSAL - {MNG_FN_PUTCHUNK_MPNG, "putchunk_mpng"}, -#endif - -#ifndef MNG_SKIPCHUNK_PAST - {MNG_FN_PUTCHUNK_PAST_SRC, "putchunk_past_src"}, -#endif -#ifndef MNG_SKIPCHUNK_SAVE - {MNG_FN_PUTCHUNK_SAVE_ENTRY, "putchunk_save_entry"}, -#endif -#ifndef MNG_NO_DELTA_PNG - {MNG_FN_PUTCHUNK_PPLT_ENTRY, "putchunk_pplt_entry"}, -#ifndef MNG_SKIPCHUNK_ORDR - {MNG_FN_PUTCHUNK_ORDR_ENTRY, "putchunk_ordr_entry"}, -#endif -#endif -#ifndef MNG_SKIPCHUNK_evNT - {MNG_FN_PUTCHUNK_EVNT_ENTRY, "putchunk_evnt_entry"}, -#endif -#ifdef MNG_INCLUDE_MPNG_PROPOSAL - {MNG_FN_PUTCHUNK_MPNG_FRAME, "putchunk_mpng_frame"}, -#endif - - {MNG_FN_GETIMGDATA_SEQ, "getimgdata_seq"}, - {MNG_FN_GETIMGDATA_CHUNKSEQ, "getimgdata_chunkseq"}, - {MNG_FN_GETIMGDATA_CHUNK, "getimgdata_chunk"}, - - {MNG_FN_PUTIMGDATA_IHDR, "putimgdata_ihdr"}, -#ifdef MNG_INCLUDE_JNG - {MNG_FN_PUTIMGDATA_JHDR, "putimgdata_jhdr"}, - {MNG_FN_PUTIMGDATA_BASI, "putimgdata_basi"}, - {MNG_FN_PUTIMGDATA_DHDR, "putimgdata_dhdr"}, -#endif - - {MNG_FN_UPDATEMNGHEADER, "updatemngheader"}, - {MNG_FN_UPDATEMNGSIMPLICITY, "updatemngsimplicity"}, - - {MNG_FN_PROCESS_RAW_CHUNK, "process_raw_chunk"}, - {MNG_FN_READ_GRAPHIC, "read_graphic"}, - {MNG_FN_DROP_CHUNKS, "drop_chunks"}, - {MNG_FN_PROCESS_ERROR, "process_error"}, - {MNG_FN_CLEAR_CMS, "clear_cms"}, - {MNG_FN_DROP_OBJECTS, "drop_objects"}, - {MNG_FN_READ_CHUNK, "read_chunk"}, - {MNG_FN_LOAD_BKGDLAYER, "load_bkgdlayer"}, - {MNG_FN_NEXT_FRAME, "next_frame"}, - {MNG_FN_NEXT_LAYER, "next_layer"}, - {MNG_FN_INTERFRAME_DELAY, "interframe_delay"}, - {MNG_FN_DISPLAY_IMAGE, "display_image"}, - {MNG_FN_DROP_IMGOBJECTS, "drop_imgobjects"}, - {MNG_FN_DROP_ANIOBJECTS, "drop_aniobjects"}, - {MNG_FN_INFLATE_BUFFER, "inflate_buffer"}, - {MNG_FN_DEFLATE_BUFFER, "deflate_buffer"}, - {MNG_FN_WRITE_RAW_CHUNK, "write_raw_chunk"}, - {MNG_FN_WRITE_GRAPHIC, "write_graphic"}, - {MNG_FN_SAVE_STATE, "save_state"}, - {MNG_FN_RESTORE_STATE, "restore_state"}, - {MNG_FN_DROP_SAVEDATA, "drop_savedata"}, -#ifndef MNG_NO_DELTA_PNG - {MNG_FN_EXECUTE_DELTA_IMAGE, "execute_delta_image"}, -#endif - {MNG_FN_PROCESS_DISPLAY, "process_display"}, - {MNG_FN_CLEAR_CANVAS, "clear_canvas"}, - {MNG_FN_READ_DATABUFFER, "read_databuffer"}, - {MNG_FN_STORE_ERROR, "store_error"}, - {MNG_FN_DROP_INVALID_OBJECTS, "drop_invalid_objects"}, - {MNG_FN_RELEASE_PUSHDATA, "release_pushdata"}, - {MNG_FN_READ_DATA, "read_data"}, - {MNG_FN_READ_CHUNK_CRC, "read_chunk_crc"}, - {MNG_FN_RELEASE_PUSHCHUNK, "release_pushchunk"}, - - {MNG_FN_DISPLAY_RGB8, "display_rgb8"}, - {MNG_FN_DISPLAY_RGBA8, "display_rgba8"}, - {MNG_FN_DISPLAY_ARGB8, "display_argb8"}, - {MNG_FN_DISPLAY_BGR8, "display_bgr8"}, - {MNG_FN_DISPLAY_BGRA8, "display_bgra8"}, - {MNG_FN_DISPLAY_ABGR8, "display_abgr8"}, - {MNG_FN_DISPLAY_RGB16, "display_rgb16"}, - {MNG_FN_DISPLAY_RGBA16, "display_rgba16"}, - {MNG_FN_DISPLAY_ARGB16, "display_argb16"}, - {MNG_FN_DISPLAY_BGR16, "display_bgr16"}, - {MNG_FN_DISPLAY_BGRA16, "display_bgra16"}, - {MNG_FN_DISPLAY_ABGR16, "display_abgr16"}, - {MNG_FN_DISPLAY_INDEX8, "display_index8"}, - {MNG_FN_DISPLAY_INDEXA8, "display_indexa8"}, - {MNG_FN_DISPLAY_AINDEX8, "display_aindex8"}, - {MNG_FN_DISPLAY_GRAY8, "display_gray8"}, - {MNG_FN_DISPLAY_GRAY16, "display_gray16"}, - {MNG_FN_DISPLAY_GRAYA8, "display_graya8"}, - {MNG_FN_DISPLAY_GRAYA16, "display_graya16"}, - {MNG_FN_DISPLAY_AGRAY8, "display_agray8"}, - {MNG_FN_DISPLAY_AGRAY16, "display_agray16"}, - {MNG_FN_DISPLAY_DX15, "display_dx15"}, - {MNG_FN_DISPLAY_DX16, "display_dx16"}, - {MNG_FN_DISPLAY_RGB8_A8, "display_rgb8_a8"}, - {MNG_FN_DISPLAY_BGRA8PM, "display_bgra8_pm"}, - {MNG_FN_DISPLAY_BGRX8, "display_bgrx8"}, - {MNG_FN_DISPLAY_RGB565, "display_rgb565"}, - {MNG_FN_DISPLAY_RGBA565, "display_rgba565"}, - {MNG_FN_DISPLAY_BGR565, "display_bgr565"}, - {MNG_FN_DISPLAY_BGRA565, "display_bgra565"}, - {MNG_FN_DISPLAY_RGBA8_PM, "display_rgba8_pm"}, - {MNG_FN_DISPLAY_ARGB8_PM, "display_argb8_pm"}, - {MNG_FN_DISPLAY_ABGR8_PM, "display_abgr8_pm"}, - {MNG_FN_DISPLAY_BGR565_A8, "display_bgr565_a8"}, - - {MNG_FN_INIT_FULL_CMS, "init_full_cms"}, - {MNG_FN_CORRECT_FULL_CMS, "correct_full_cms"}, - {MNG_FN_INIT_GAMMA_ONLY, "init_gamma_only"}, - {MNG_FN_CORRECT_GAMMA_ONLY, "correct_gamma_only"}, - {MNG_FN_CORRECT_APP_CMS, "correct_app_cms"}, - {MNG_FN_INIT_FULL_CMS_OBJ, "init_full_cms_obj"}, - {MNG_FN_INIT_GAMMA_ONLY_OBJ, "init_gamma_only_obj"}, - {MNG_FN_INIT_APP_CMS, "init_app_cms"}, - {MNG_FN_INIT_APP_CMS_OBJ, "init_app_cms_obj"}, - - {MNG_FN_PROCESS_G1, "process_g1"}, - {MNG_FN_PROCESS_G2, "process_g2"}, - {MNG_FN_PROCESS_G4, "process_g4"}, - {MNG_FN_PROCESS_G8, "process_g8"}, - {MNG_FN_PROCESS_G16, "process_g16"}, - {MNG_FN_PROCESS_RGB8, "process_rgb8"}, - {MNG_FN_PROCESS_RGB16, "process_rgb16"}, - {MNG_FN_PROCESS_IDX1, "process_idx1"}, - {MNG_FN_PROCESS_IDX2, "process_idx2"}, - {MNG_FN_PROCESS_IDX4, "process_idx4"}, - {MNG_FN_PROCESS_IDX8, "process_idx8"}, - {MNG_FN_PROCESS_GA8, "process_ga8"}, - {MNG_FN_PROCESS_GA16, "process_ga16"}, - {MNG_FN_PROCESS_RGBA8, "process_rgba8"}, - {MNG_FN_PROCESS_RGBA16, "process_rgba16"}, - - {MNG_FN_INIT_G1_I, "init_g1_i"}, - {MNG_FN_INIT_G2_I, "init_g2_i"}, - {MNG_FN_INIT_G4_I, "init_g4_i"}, - {MNG_FN_INIT_G8_I, "init_g8_i"}, - {MNG_FN_INIT_G16_I, "init_g16_i"}, - {MNG_FN_INIT_RGB8_I, "init_rgb8_i"}, - {MNG_FN_INIT_RGB16_I, "init_rgb16_i"}, - {MNG_FN_INIT_IDX1_I, "init_idx1_i"}, - {MNG_FN_INIT_IDX2_I, "init_idx2_i"}, - {MNG_FN_INIT_IDX4_I, "init_idx4_i"}, - {MNG_FN_INIT_IDX8_I, "init_idx8_i"}, - {MNG_FN_INIT_GA8_I, "init_ga8_i"}, - {MNG_FN_INIT_GA16_I, "init_ga16_i"}, - {MNG_FN_INIT_RGBA8_I, "init_rgba8_i"}, - {MNG_FN_INIT_RGBA16_I, "init_rgba16_i"}, -#ifndef MNG_OPTIMIZE_FOOTPRINT_INIT - {MNG_FN_INIT_G1_NI, "init_g1_ni"}, - {MNG_FN_INIT_G2_NI, "init_g2_ni"}, - {MNG_FN_INIT_G4_NI, "init_g4_ni"}, - {MNG_FN_INIT_G8_NI, "init_g8_ni"}, - {MNG_FN_INIT_G16_NI, "init_g16_ni"}, - {MNG_FN_INIT_RGB8_NI, "init_rgb8_ni"}, - {MNG_FN_INIT_RGB16_NI, "init_rgb16_ni"}, - {MNG_FN_INIT_IDX1_NI, "init_idx1_ni"}, - {MNG_FN_INIT_IDX2_NI, "init_idx2_ni"}, - {MNG_FN_INIT_IDX4_NI, "init_idx4_ni"}, - {MNG_FN_INIT_IDX8_NI, "init_idx8_ni"}, - {MNG_FN_INIT_GA8_NI, "init_ga8_ni"}, - {MNG_FN_INIT_GA16_NI, "init_ga16_ni"}, - {MNG_FN_INIT_RGBA8_NI, "init_rgba8_ni"}, - {MNG_FN_INIT_RGBA16_NI, "init_rgba16_ni"}, -#endif - - {MNG_FN_INIT_ROWPROC, "init_rowproc"}, - {MNG_FN_NEXT_ROW, "next_row"}, - {MNG_FN_CLEANUP_ROWPROC, "cleanup_rowproc"}, - - {MNG_FN_FILTER_A_ROW, "filter_a_row"}, - {MNG_FN_FILTER_SUB, "filter_sub"}, - {MNG_FN_FILTER_UP, "filter_up"}, - {MNG_FN_FILTER_AVERAGE, "filter_average"}, - {MNG_FN_FILTER_PAETH, "filter_paeth"}, - - {MNG_FN_INIT_ROWDIFFERING, "init_rowdiffering"}, - {MNG_FN_DIFFER_G1, "differ_g1"}, - {MNG_FN_DIFFER_G2, "differ_g2"}, - {MNG_FN_DIFFER_G4, "differ_g4"}, - {MNG_FN_DIFFER_G8, "differ_g8"}, - {MNG_FN_DIFFER_G16, "differ_g16"}, - {MNG_FN_DIFFER_RGB8, "differ_rgb8"}, - {MNG_FN_DIFFER_RGB16, "differ_rgb16"}, - {MNG_FN_DIFFER_IDX1, "differ_idx1"}, - {MNG_FN_DIFFER_IDX2, "differ_idx2"}, - {MNG_FN_DIFFER_IDX4, "differ_idx4"}, - {MNG_FN_DIFFER_IDX8, "differ_idx8"}, - {MNG_FN_DIFFER_GA8, "differ_ga8"}, - {MNG_FN_DIFFER_GA16, "differ_ga16"}, - {MNG_FN_DIFFER_RGBA8, "differ_rgba8"}, - {MNG_FN_DIFFER_RGBA16, "differ_rgba16"}, - - {MNG_FN_CREATE_IMGDATAOBJECT, "create_imgdataobject"}, - {MNG_FN_FREE_IMGDATAOBJECT, "free_imgdataobject"}, - {MNG_FN_CLONE_IMGDATAOBJECT, "clone_imgdataobject"}, - {MNG_FN_CREATE_IMGOBJECT, "create_imgobject"}, - {MNG_FN_FREE_IMGOBJECT, "free_imgobject"}, - {MNG_FN_FIND_IMGOBJECT, "find_imgobject"}, - {MNG_FN_CLONE_IMGOBJECT, "clone_imgobject"}, - {MNG_FN_RESET_OBJECTDETAILS, "reset_objectdetails"}, - {MNG_FN_RENUM_IMGOBJECT, "renum_imgobject"}, - {MNG_FN_PROMOTE_IMGOBJECT, "promote_imgobject"}, - {MNG_FN_MAGNIFY_IMGOBJECT, "magnify_imgobject"}, - {MNG_FN_COLORCORRECT_OBJECT, "colorcorrect_object"}, - - {MNG_FN_STORE_G1, "store_g1"}, - {MNG_FN_STORE_G2, "store_g2"}, - {MNG_FN_STORE_G4, "store_g4"}, - {MNG_FN_STORE_G8, "store_g8"}, - {MNG_FN_STORE_G16, "store_g16"}, - {MNG_FN_STORE_RGB8, "store_rgb8"}, - {MNG_FN_STORE_RGB16, "store_rgb16"}, - {MNG_FN_STORE_IDX1, "store_idx1"}, - {MNG_FN_STORE_IDX2, "store_idx2"}, - {MNG_FN_STORE_IDX4, "store_idx4"}, - {MNG_FN_STORE_IDX8, "store_idx8"}, - {MNG_FN_STORE_GA8, "store_ga8"}, - {MNG_FN_STORE_GA16, "store_ga16"}, - {MNG_FN_STORE_RGBA8, "store_rgba8"}, - {MNG_FN_STORE_RGBA16, "store_rgba16"}, - - {MNG_FN_RETRIEVE_G8, "retrieve_g8"}, - {MNG_FN_RETRIEVE_G16, "retrieve_g16"}, - {MNG_FN_RETRIEVE_RGB8, "retrieve_rgb8"}, - {MNG_FN_RETRIEVE_RGB16, "retrieve_rgb16"}, - {MNG_FN_RETRIEVE_IDX8, "retrieve_idx8"}, - {MNG_FN_RETRIEVE_GA8, "retrieve_ga8"}, - {MNG_FN_RETRIEVE_GA16, "retrieve_ga16"}, - {MNG_FN_RETRIEVE_RGBA8, "retrieve_rgba8"}, - {MNG_FN_RETRIEVE_RGBA16, "retrieve_rgba16"}, - -#ifndef MNG_NO_DELTA_PNG - {MNG_FN_DELTA_G1, "delta_g1"}, - {MNG_FN_DELTA_G2, "delta_g2"}, - {MNG_FN_DELTA_G4, "delta_g4"}, - {MNG_FN_DELTA_G8, "delta_g8"}, - {MNG_FN_DELTA_G16, "delta_g16"}, - {MNG_FN_DELTA_RGB8, "delta_rgb8"}, - {MNG_FN_DELTA_RGB16, "delta_rgb16"}, - {MNG_FN_DELTA_IDX1, "delta_idx1"}, - {MNG_FN_DELTA_IDX2, "delta_idx2"}, - {MNG_FN_DELTA_IDX4, "delta_idx4"}, - {MNG_FN_DELTA_IDX8, "delta_idx8"}, - {MNG_FN_DELTA_GA8, "delta_ga8"}, - {MNG_FN_DELTA_GA16, "delta_ga16"}, - {MNG_FN_DELTA_RGBA8, "delta_rgba8"}, - {MNG_FN_DELTA_RGBA16, "delta_rgba16"}, -#endif - - {MNG_FN_CREATE_ANI_LOOP, "create_ani_loop"}, - {MNG_FN_CREATE_ANI_ENDL, "create_ani_endl"}, - {MNG_FN_CREATE_ANI_DEFI, "create_ani_defi"}, - {MNG_FN_CREATE_ANI_BASI, "create_ani_basi"}, - {MNG_FN_CREATE_ANI_CLON, "create_ani_clon"}, -#ifndef MNG_SKIPCHUNK_PAST - {MNG_FN_CREATE_ANI_PAST, "create_ani_past"}, -#endif - {MNG_FN_CREATE_ANI_DISC, "create_ani_disc"}, - {MNG_FN_CREATE_ANI_BACK, "create_ani_back"}, - {MNG_FN_CREATE_ANI_FRAM, "create_ani_fram"}, - {MNG_FN_CREATE_ANI_MOVE, "create_ani_move"}, - {MNG_FN_CREATE_ANI_CLIP, "create_ani_clip"}, - {MNG_FN_CREATE_ANI_SHOW, "create_ani_show"}, - {MNG_FN_CREATE_ANI_TERM, "create_ani_term"}, - {MNG_FN_CREATE_ANI_SAVE, "create_ani_save"}, - {MNG_FN_CREATE_ANI_SEEK, "create_ani_seek"}, - {MNG_FN_CREATE_ANI_GAMA, "create_ani_gama"}, - {MNG_FN_CREATE_ANI_CHRM, "create_ani_chrm"}, - {MNG_FN_CREATE_ANI_SRGB, "create_ani_srgb"}, - {MNG_FN_CREATE_ANI_ICCP, "create_ani_iccp"}, - {MNG_FN_CREATE_ANI_PLTE, "create_ani_plte"}, - {MNG_FN_CREATE_ANI_TRNS, "create_ani_trns"}, - {MNG_FN_CREATE_ANI_BKGD, "create_ani_bkgd"}, -#ifndef MNG_NO_DELTA_PNG - {MNG_FN_CREATE_ANI_DHDR, "create_ani_dhdr"}, - {MNG_FN_CREATE_ANI_PROM, "create_ani_prom"}, -#ifdef MNG_INCLUDE_JNG - {MNG_FN_CREATE_ANI_IPNG, "create_ani_ipng"}, -#endif - {MNG_FN_CREATE_ANI_IJNG, "create_ani_ijng"}, - {MNG_FN_CREATE_ANI_PPLT, "create_ani_pplt"}, -#endif - {MNG_FN_CREATE_ANI_MAGN, "create_ani_magn"}, - - {MNG_FN_CREATE_ANI_IMAGE, "create_ani_image"}, - {MNG_FN_CREATE_EVENT, "create_event"}, - - {MNG_FN_FREE_ANI_LOOP, "free_ani_loop"}, - {MNG_FN_FREE_ANI_ENDL, "free_ani_endl"}, - {MNG_FN_FREE_ANI_DEFI, "free_ani_defi"}, - {MNG_FN_FREE_ANI_BASI, "free_ani_basi"}, - {MNG_FN_FREE_ANI_CLON, "free_ani_clon"}, -#ifndef MNG_SKIPCHUNK_PAST - {MNG_FN_FREE_ANI_PAST, "free_ani_past"}, -#endif - {MNG_FN_FREE_ANI_DISC, "free_ani_disc"}, - {MNG_FN_FREE_ANI_BACK, "free_ani_back"}, - {MNG_FN_FREE_ANI_FRAM, "free_ani_fram"}, - {MNG_FN_FREE_ANI_MOVE, "free_ani_move"}, - {MNG_FN_FREE_ANI_CLIP, "free_ani_clip"}, - {MNG_FN_FREE_ANI_SHOW, "free_ani_show"}, - {MNG_FN_FREE_ANI_TERM, "free_ani_term"}, - {MNG_FN_FREE_ANI_SAVE, "free_ani_save"}, - {MNG_FN_FREE_ANI_SEEK, "free_ani_seek"}, - {MNG_FN_FREE_ANI_GAMA, "free_ani_gama"}, - {MNG_FN_FREE_ANI_CHRM, "free_ani_chrm"}, - {MNG_FN_FREE_ANI_SRGB, "free_ani_srgb"}, - {MNG_FN_FREE_ANI_ICCP, "free_ani_iccp"}, - {MNG_FN_FREE_ANI_PLTE, "free_ani_plte"}, - {MNG_FN_FREE_ANI_TRNS, "free_ani_trns"}, - {MNG_FN_FREE_ANI_BKGD, "free_ani_bkgd"}, -#ifndef MNG_NO_DELTA_PNG - {MNG_FN_FREE_ANI_DHDR, "free_ani_dhdr"}, - {MNG_FN_FREE_ANI_PROM, "free_ani_prom"}, -#ifdef MNG_INCLUDE_JNG - {MNG_FN_FREE_ANI_IPNG, "free_ani_ipng"}, -#endif - {MNG_FN_FREE_ANI_IJNG, "free_ani_ijng"}, - {MNG_FN_FREE_ANI_PPLT, "free_ani_pplt"}, -#endif - {MNG_FN_FREE_ANI_MAGN, "free_ani_magn"}, - - {MNG_FN_FREE_ANI_IMAGE, "free_ani_image"}, - {MNG_FN_FREE_EVENT, "free_event"}, - - {MNG_FN_PROCESS_ANI_LOOP, "process_ani_loop"}, - {MNG_FN_PROCESS_ANI_ENDL, "process_ani_endl"}, - {MNG_FN_PROCESS_ANI_DEFI, "process_ani_defi"}, - {MNG_FN_PROCESS_ANI_BASI, "process_ani_basi"}, - {MNG_FN_PROCESS_ANI_CLON, "process_ani_clon"}, -#ifndef MNG_SKIPCHUNK_PAST - {MNG_FN_PROCESS_ANI_PAST, "process_ani_past"}, -#endif - {MNG_FN_PROCESS_ANI_DISC, "process_ani_disc"}, - {MNG_FN_PROCESS_ANI_BACK, "process_ani_back"}, - {MNG_FN_PROCESS_ANI_FRAM, "process_ani_fram"}, - {MNG_FN_PROCESS_ANI_MOVE, "process_ani_move"}, - {MNG_FN_PROCESS_ANI_CLIP, "process_ani_clip"}, - {MNG_FN_PROCESS_ANI_SHOW, "process_ani_show"}, - {MNG_FN_PROCESS_ANI_TERM, "process_ani_term"}, - {MNG_FN_PROCESS_ANI_SAVE, "process_ani_save"}, - {MNG_FN_PROCESS_ANI_SEEK, "process_ani_seek"}, - {MNG_FN_PROCESS_ANI_GAMA, "process_ani_gama"}, - {MNG_FN_PROCESS_ANI_CHRM, "process_ani_chrm"}, - {MNG_FN_PROCESS_ANI_SRGB, "process_ani_srgb"}, - {MNG_FN_PROCESS_ANI_ICCP, "process_ani_iccp"}, - {MNG_FN_PROCESS_ANI_PLTE, "process_ani_plte"}, - {MNG_FN_PROCESS_ANI_TRNS, "process_ani_trns"}, - {MNG_FN_PROCESS_ANI_BKGD, "process_ani_bkgd"}, -#ifndef MNG_NO_DELTA_PNG - {MNG_FN_PROCESS_ANI_DHDR, "process_ani_dhdr"}, - {MNG_FN_PROCESS_ANI_PROM, "process_ani_prom"}, -#ifdef MNG_INCLUDE_JNG - {MNG_FN_PROCESS_ANI_IPNG, "process_ani_ipng"}, -#endif - {MNG_FN_PROCESS_ANI_IJNG, "process_ani_ijng"}, - {MNG_FN_PROCESS_ANI_PPLT, "process_ani_pplt"}, -#endif - {MNG_FN_PROCESS_ANI_MAGN, "process_ani_magn"}, - - {MNG_FN_PROCESS_ANI_IMAGE, "process_ani_image"}, - {MNG_FN_PROCESS_EVENT, "process_event"}, - - {MNG_FN_RESTORE_BACKIMAGE, "restore_backimage"}, - {MNG_FN_RESTORE_BACKCOLOR, "restore_backcolor"}, - {MNG_FN_RESTORE_BGCOLOR, "restore_bgcolor"}, - {MNG_FN_RESTORE_RGB8, "restore_rgb8"}, - {MNG_FN_RESTORE_BGR8, "restore_bgr8"}, - {MNG_FN_RESTORE_BKGD, "restore_bkgd"}, - {MNG_FN_RESTORE_BGRX8, "restore_bgrx8"}, - {MNG_FN_RESTORE_RGB565, "restore_rgb565"}, - - {MNG_FN_INIT_IHDR, "init_ihdr"}, - {MNG_FN_INIT_PLTE, "init_plte"}, - {MNG_FN_INIT_IDAT, "init_idat"}, - {MNG_FN_INIT_IEND, "init_iend"}, - {MNG_FN_INIT_TRNS, "init_trns"}, - {MNG_FN_INIT_GAMA, "init_gama"}, - {MNG_FN_INIT_CHRM, "init_chrm"}, - {MNG_FN_INIT_SRGB, "init_srgb"}, - {MNG_FN_INIT_ICCP, "init_iccp"}, - {MNG_FN_INIT_TEXT, "init_text"}, - {MNG_FN_INIT_ZTXT, "init_ztxt"}, - {MNG_FN_INIT_ITXT, "init_itxt"}, - {MNG_FN_INIT_BKGD, "init_bkgd"}, - {MNG_FN_INIT_PHYS, "init_phys"}, - {MNG_FN_INIT_SBIT, "init_sbit"}, - {MNG_FN_INIT_SPLT, "init_splt"}, - {MNG_FN_INIT_HIST, "init_hist"}, - {MNG_FN_INIT_TIME, "init_time"}, - {MNG_FN_INIT_MHDR, "init_mhdr"}, - {MNG_FN_INIT_MEND, "init_mend"}, - {MNG_FN_INIT_LOOP, "init_loop"}, - {MNG_FN_INIT_ENDL, "init_endl"}, - {MNG_FN_INIT_DEFI, "init_defi"}, - {MNG_FN_INIT_BASI, "init_basi"}, - {MNG_FN_INIT_CLON, "init_clon"}, -#ifndef MNG_SKIPCHUNK_PAST - {MNG_FN_INIT_PAST, "init_past"}, -#endif - {MNG_FN_INIT_DISC, "init_disc"}, - {MNG_FN_INIT_BACK, "init_back"}, - {MNG_FN_INIT_FRAM, "init_fram"}, - {MNG_FN_INIT_MOVE, "init_move"}, - {MNG_FN_INIT_CLIP, "init_clip"}, - {MNG_FN_INIT_SHOW, "init_show"}, - {MNG_FN_INIT_TERM, "init_term"}, - {MNG_FN_INIT_SAVE, "init_save"}, - {MNG_FN_INIT_SEEK, "init_seek"}, - {MNG_FN_INIT_EXPI, "init_expi"}, - {MNG_FN_INIT_FPRI, "init_fpri"}, - {MNG_FN_INIT_NEED, "init_need"}, - {MNG_FN_INIT_PHYG, "init_phyg"}, -#ifndef MNG_NO_DELTA_PNG - {MNG_FN_INIT_JHDR, "init_jhdr"}, - {MNG_FN_INIT_JDAT, "init_jdat"}, - {MNG_FN_INIT_JSEP, "init_jsep"}, -#endif -#ifndef MNG_NO_DELTA_PNG - {MNG_FN_INIT_DHDR, "init_dhdr"}, - {MNG_FN_INIT_PROM, "init_prom"}, -#ifdef MNG_INCLUDE_JNG - {MNG_FN_INIT_IPNG, "init_ipng"}, -#endif - {MNG_FN_INIT_PPLT, "init_pplt"}, - {MNG_FN_INIT_IJNG, "init_ijng"}, - {MNG_FN_INIT_DROP, "init_drop"}, - {MNG_FN_INIT_DBYK, "init_dbyk"}, - {MNG_FN_INIT_ORDR, "init_ordr"}, -#endif - {MNG_FN_INIT_UNKNOWN, "init_unknown"}, - {MNG_FN_INIT_MAGN, "init_magn"}, - {MNG_FN_INIT_JDAA, "init_jdaa"}, - {MNG_FN_INIT_EVNT, "init_evnt"}, -#ifdef MNG_INCLUDE_MPNG_PROPOSAL - {MNG_FN_INIT_MPNG, "init_mpng"}, -#endif - - {MNG_FN_ASSIGN_IHDR, "assign_ihdr"}, - {MNG_FN_ASSIGN_PLTE, "assign_plte"}, - {MNG_FN_ASSIGN_IDAT, "assign_idat"}, - {MNG_FN_ASSIGN_IEND, "assign_iend"}, - {MNG_FN_ASSIGN_TRNS, "assign_trns"}, - {MNG_FN_ASSIGN_GAMA, "assign_gama"}, - {MNG_FN_ASSIGN_CHRM, "assign_chrm"}, - {MNG_FN_ASSIGN_SRGB, "assign_srgb"}, - {MNG_FN_ASSIGN_ICCP, "assign_iccp"}, - {MNG_FN_ASSIGN_TEXT, "assign_text"}, - {MNG_FN_ASSIGN_ZTXT, "assign_ztxt"}, - {MNG_FN_ASSIGN_ITXT, "assign_itxt"}, - {MNG_FN_ASSIGN_BKGD, "assign_bkgd"}, - {MNG_FN_ASSIGN_PHYS, "assign_phys"}, - {MNG_FN_ASSIGN_SBIT, "assign_sbit"}, - {MNG_FN_ASSIGN_SPLT, "assign_splt"}, - {MNG_FN_ASSIGN_HIST, "assign_hist"}, - {MNG_FN_ASSIGN_TIME, "assign_time"}, - {MNG_FN_ASSIGN_MHDR, "assign_mhdr"}, - {MNG_FN_ASSIGN_MEND, "assign_mend"}, - {MNG_FN_ASSIGN_LOOP, "assign_loop"}, - {MNG_FN_ASSIGN_ENDL, "assign_endl"}, - {MNG_FN_ASSIGN_DEFI, "assign_defi"}, - {MNG_FN_ASSIGN_BASI, "assign_basi"}, - {MNG_FN_ASSIGN_CLON, "assign_clon"}, -#ifndef MNG_SKIPCHUNK_PAST - {MNG_FN_ASSIGN_PAST, "assign_past"}, -#endif - {MNG_FN_ASSIGN_DISC, "assign_disc"}, - {MNG_FN_ASSIGN_BACK, "assign_back"}, - {MNG_FN_ASSIGN_FRAM, "assign_fram"}, - {MNG_FN_ASSIGN_MOVE, "assign_move"}, - {MNG_FN_ASSIGN_CLIP, "assign_clip"}, - {MNG_FN_ASSIGN_SHOW, "assign_show"}, - {MNG_FN_ASSIGN_TERM, "assign_term"}, - {MNG_FN_ASSIGN_SAVE, "assign_save"}, - {MNG_FN_ASSIGN_SEEK, "assign_seek"}, - {MNG_FN_ASSIGN_EXPI, "assign_expi"}, - {MNG_FN_ASSIGN_FPRI, "assign_fpri"}, - {MNG_FN_ASSIGN_NEED, "assign_need"}, - {MNG_FN_ASSIGN_PHYG, "assign_phyg"}, -#ifdef MNG_INCLUDE_JNG - {MNG_FN_ASSIGN_JHDR, "assign_jhdr"}, - {MNG_FN_ASSIGN_JDAT, "assign_jdat"}, - {MNG_FN_ASSIGN_JSEP, "assign_jsep"}, -#endif -#ifndef MNG_NO_DELTA_PNG - {MNG_FN_ASSIGN_DHDR, "assign_dhdr"}, - {MNG_FN_ASSIGN_PROM, "assign_prom"}, -#ifdef MNG_INCLUDE_JNG - {MNG_FN_ASSIGN_IPNG, "assign_ipng"}, -#endif - {MNG_FN_ASSIGN_PPLT, "assign_pplt"}, - {MNG_FN_ASSIGN_IJNG, "assign_ijng"}, - {MNG_FN_ASSIGN_DROP, "assign_drop"}, - {MNG_FN_ASSIGN_DBYK, "assign_dbyk"}, - {MNG_FN_ASSIGN_ORDR, "assign_ordr"}, -#endif - {MNG_FN_ASSIGN_UNKNOWN, "assign_unknown"}, - {MNG_FN_ASSIGN_MAGN, "assign_magn"}, - {MNG_FN_ASSIGN_JDAA, "assign_jdaa"}, - {MNG_FN_ASSIGN_EVNT, "assign_evnt"}, -#ifdef MNG_INCLUDE_MPNG_PROPOSAL - {MNG_FN_ASSIGN_MPNG, "assign_mpng"}, -#endif - - {MNG_FN_FREE_IHDR, "free_ihdr"}, - {MNG_FN_FREE_PLTE, "free_plte"}, - {MNG_FN_FREE_IDAT, "free_idat"}, - {MNG_FN_FREE_IEND, "free_iend"}, - {MNG_FN_FREE_TRNS, "free_trns"}, - {MNG_FN_FREE_GAMA, "free_gama"}, - {MNG_FN_FREE_CHRM, "free_chrm"}, - {MNG_FN_FREE_SRGB, "free_srgb"}, - {MNG_FN_FREE_ICCP, "free_iccp"}, - {MNG_FN_FREE_TEXT, "free_text"}, - {MNG_FN_FREE_ZTXT, "free_ztxt"}, - {MNG_FN_FREE_ITXT, "free_itxt"}, - {MNG_FN_FREE_BKGD, "free_bkgd"}, - {MNG_FN_FREE_PHYS, "free_phys"}, - {MNG_FN_FREE_SBIT, "free_sbit"}, - {MNG_FN_FREE_SPLT, "free_splt"}, - {MNG_FN_FREE_HIST, "free_hist"}, - {MNG_FN_FREE_TIME, "free_time"}, - {MNG_FN_FREE_MHDR, "free_mhdr"}, - {MNG_FN_FREE_MEND, "free_mend"}, - {MNG_FN_FREE_LOOP, "free_loop"}, - {MNG_FN_FREE_ENDL, "free_endl"}, - {MNG_FN_FREE_DEFI, "free_defi"}, - {MNG_FN_FREE_BASI, "free_basi"}, - {MNG_FN_FREE_CLON, "free_clon"}, -#ifndef MNG_SKIPCHUNK_PAST - {MNG_FN_FREE_PAST, "free_past"}, -#endif - {MNG_FN_FREE_DISC, "free_disc"}, - {MNG_FN_FREE_BACK, "free_back"}, - {MNG_FN_FREE_FRAM, "free_fram"}, - {MNG_FN_FREE_MOVE, "free_move"}, - {MNG_FN_FREE_CLIP, "free_clip"}, - {MNG_FN_FREE_SHOW, "free_show"}, - {MNG_FN_FREE_TERM, "free_term"}, - {MNG_FN_FREE_SAVE, "free_save"}, - {MNG_FN_FREE_SEEK, "free_seek"}, - {MNG_FN_FREE_EXPI, "free_expi"}, - {MNG_FN_FREE_FPRI, "free_fpri"}, - {MNG_FN_FREE_NEED, "free_need"}, - {MNG_FN_FREE_PHYG, "free_phyg"}, -#ifdef MNG_INCLUDE_JNG - {MNG_FN_FREE_JHDR, "free_jhdr"}, - {MNG_FN_FREE_JDAT, "free_jdat"}, - {MNG_FN_FREE_JSEP, "free_jsep"}, -#endif -#ifndef MNG_NO_DELTA_PNG - {MNG_FN_FREE_DHDR, "free_dhdr"}, - {MNG_FN_FREE_PROM, "free_prom"}, -#ifdef MNG_INCLUDE_JNG - {MNG_FN_FREE_IPNG, "free_ipng"}, -#endif - {MNG_FN_FREE_PPLT, "free_pplt"}, - {MNG_FN_FREE_IJNG, "free_ijng"}, - {MNG_FN_FREE_DROP, "free_drop"}, - {MNG_FN_FREE_DBYK, "free_dbyk"}, - {MNG_FN_FREE_ORDR, "free_ordr"}, -#endif - {MNG_FN_FREE_UNKNOWN, "free_unknown"}, - {MNG_FN_FREE_MAGN, "free_magn"}, - {MNG_FN_FREE_JDAA, "free_jdaa"}, - {MNG_FN_FREE_EVNT, "free_evnt"}, -#ifdef MNG_INCLUDE_MPNG_PROPOSAL - {MNG_FN_FREE_MPNG, "free_mpng"}, -#endif - - {MNG_FN_READ_IHDR, "read_ihdr"}, - {MNG_FN_READ_PLTE, "read_plte"}, - {MNG_FN_READ_IDAT, "read_idat"}, - {MNG_FN_READ_IEND, "read_iend"}, - {MNG_FN_READ_TRNS, "read_trns"}, - {MNG_FN_READ_GAMA, "read_gama"}, - {MNG_FN_READ_CHRM, "read_chrm"}, - {MNG_FN_READ_SRGB, "read_srgb"}, - {MNG_FN_READ_ICCP, "read_iccp"}, - {MNG_FN_READ_TEXT, "read_text"}, - {MNG_FN_READ_ZTXT, "read_ztxt"}, - {MNG_FN_READ_ITXT, "read_itxt"}, - {MNG_FN_READ_BKGD, "read_bkgd"}, - {MNG_FN_READ_PHYS, "read_phys"}, - {MNG_FN_READ_SBIT, "read_sbit"}, - {MNG_FN_READ_SPLT, "read_splt"}, - {MNG_FN_READ_HIST, "read_hist"}, - {MNG_FN_READ_TIME, "read_time"}, - {MNG_FN_READ_MHDR, "read_mhdr"}, - {MNG_FN_READ_MEND, "read_mend"}, - {MNG_FN_READ_LOOP, "read_loop"}, - {MNG_FN_READ_ENDL, "read_endl"}, - {MNG_FN_READ_DEFI, "read_defi"}, - {MNG_FN_READ_BASI, "read_basi"}, - {MNG_FN_READ_CLON, "read_clon"}, -#ifndef MNG_SKIPCHUNK_PAST - {MNG_FN_READ_PAST, "read_past"}, -#endif - {MNG_FN_READ_DISC, "read_disc"}, - {MNG_FN_READ_BACK, "read_back"}, - {MNG_FN_READ_FRAM, "read_fram"}, - {MNG_FN_READ_MOVE, "read_move"}, - {MNG_FN_READ_CLIP, "read_clip"}, - {MNG_FN_READ_SHOW, "read_show"}, - {MNG_FN_READ_TERM, "read_term"}, - {MNG_FN_READ_SAVE, "read_save"}, - {MNG_FN_READ_SEEK, "read_seek"}, - {MNG_FN_READ_EXPI, "read_expi"}, - {MNG_FN_READ_FPRI, "read_fpri"}, - {MNG_FN_READ_NEED, "read_need"}, - {MNG_FN_READ_PHYG, "read_phyg"}, -#ifdef MNG_INCLUDE_JNG - {MNG_FN_READ_JHDR, "read_jhdr"}, - {MNG_FN_READ_JDAT, "read_jdat"}, - {MNG_FN_READ_JSEP, "read_jsep"}, -#endif -#ifndef MNG_NO_DELTA_PNG - {MNG_FN_READ_DHDR, "read_dhdr"}, - {MNG_FN_READ_PROM, "read_prom"}, - {MNG_FN_READ_IPNG, "read_ipng"}, - {MNG_FN_READ_PPLT, "read_pplt"}, -#ifdef MNG_INCLUDE_JNG - {MNG_FN_READ_IJNG, "read_ijng"}, -#endif - {MNG_FN_READ_DROP, "read_drop"}, - {MNG_FN_READ_DBYK, "read_dbyk"}, - {MNG_FN_READ_ORDR, "read_ordr"}, -#endif - {MNG_FN_READ_UNKNOWN, "read_unknown"}, - {MNG_FN_READ_MAGN, "read_magn"}, - {MNG_FN_READ_JDAA, "read_jdaa"}, - {MNG_FN_READ_EVNT, "read_evnt"}, -#ifdef MNG_INCLUDE_MPNG_PROPOSAL - {MNG_FN_READ_MPNG, "read_mpng"}, -#endif - - {MNG_FN_WRITE_IHDR, "write_ihdr"}, - {MNG_FN_WRITE_PLTE, "write_plte"}, - {MNG_FN_WRITE_IDAT, "write_idat"}, - {MNG_FN_WRITE_IEND, "write_iend"}, - {MNG_FN_WRITE_TRNS, "write_trns"}, - {MNG_FN_WRITE_GAMA, "write_gama"}, - {MNG_FN_WRITE_CHRM, "write_chrm"}, - {MNG_FN_WRITE_SRGB, "write_srgb"}, - {MNG_FN_WRITE_ICCP, "write_iccp"}, - {MNG_FN_WRITE_TEXT, "write_text"}, - {MNG_FN_WRITE_ZTXT, "write_ztxt"}, - {MNG_FN_WRITE_ITXT, "write_itxt"}, - {MNG_FN_WRITE_BKGD, "write_bkgd"}, - {MNG_FN_WRITE_PHYS, "write_phys"}, - {MNG_FN_WRITE_SBIT, "write_sbit"}, - {MNG_FN_WRITE_SPLT, "write_splt"}, - {MNG_FN_WRITE_HIST, "write_hist"}, - {MNG_FN_WRITE_TIME, "write_time"}, - {MNG_FN_WRITE_MHDR, "write_mhdr"}, - {MNG_FN_WRITE_MEND, "write_mend"}, - {MNG_FN_WRITE_LOOP, "write_loop"}, - {MNG_FN_WRITE_ENDL, "write_endl"}, - {MNG_FN_WRITE_DEFI, "write_defi"}, - {MNG_FN_WRITE_BASI, "write_basi"}, - {MNG_FN_WRITE_CLON, "write_clon"}, -#ifndef MNG_SKIPCHUNK_PAST - {MNG_FN_WRITE_PAST, "write_past"}, -#endif - {MNG_FN_WRITE_DISC, "write_disc"}, - {MNG_FN_WRITE_BACK, "write_back"}, - {MNG_FN_WRITE_FRAM, "write_fram"}, - {MNG_FN_WRITE_MOVE, "write_move"}, - {MNG_FN_WRITE_CLIP, "write_clip"}, - {MNG_FN_WRITE_SHOW, "write_show"}, - {MNG_FN_WRITE_TERM, "write_term"}, - {MNG_FN_WRITE_SAVE, "write_save"}, - {MNG_FN_WRITE_SEEK, "write_seek"}, - {MNG_FN_WRITE_EXPI, "write_expi"}, - {MNG_FN_WRITE_FPRI, "write_fpri"}, - {MNG_FN_WRITE_NEED, "write_need"}, - {MNG_FN_WRITE_PHYG, "write_phyg"}, -#ifdef MNG_INCLUDE_JNG - {MNG_FN_WRITE_JHDR, "write_jhdr"}, - {MNG_FN_WRITE_JDAT, "write_jdat"}, - {MNG_FN_WRITE_JSEP, "write_jsep"}, -#endif -#ifndef MNG_NO_DELTA_PNG - {MNG_FN_WRITE_DHDR, "write_dhdr"}, - {MNG_FN_WRITE_PROM, "write_prom"}, -#ifdef MNG_INCLUDE_JNG - {MNG_FN_WRITE_IPNG, "write_ipng"}, -#endif - {MNG_FN_WRITE_PPLT, "write_pplt"}, - {MNG_FN_WRITE_IJNG, "write_ijng"}, - {MNG_FN_WRITE_DROP, "write_drop"}, - {MNG_FN_WRITE_DBYK, "write_dbyk"}, - {MNG_FN_WRITE_ORDR, "write_ordr"}, -#endif - {MNG_FN_WRITE_UNKNOWN, "write_unknown"}, - {MNG_FN_WRITE_MAGN, "write_magn"}, - {MNG_FN_WRITE_JDAA, "write_jdaa"}, - {MNG_FN_WRITE_EVNT, "write_evnt"}, -#ifdef MNG_INCLUDE_MPNG_PROPOSAL - {MNG_FN_WRITE_MPNG, "write_mpng"}, -#endif - - {MNG_FN_ZLIB_INITIALIZE, "zlib_initialize"}, - {MNG_FN_ZLIB_CLEANUP, "zlib_cleanup"}, - {MNG_FN_ZLIB_INFLATEINIT, "zlib_inflateinit"}, - {MNG_FN_ZLIB_INFLATEROWS, "zlib_inflaterows"}, - {MNG_FN_ZLIB_INFLATEDATA, "zlib_inflatedata"}, - {MNG_FN_ZLIB_INFLATEFREE, "zlib_inflatefree"}, - {MNG_FN_ZLIB_DEFLATEINIT, "zlib_deflateinit"}, - {MNG_FN_ZLIB_DEFLATEROWS, "zlib_deflaterows"}, - {MNG_FN_ZLIB_DEFLATEDATA, "zlib_deflatedata"}, - {MNG_FN_ZLIB_DEFLATEFREE, "zlib_deflatefree"}, - - {MNG_FN_PROCESS_DISPLAY_IHDR, "process_display_ihdr"}, - {MNG_FN_PROCESS_DISPLAY_PLTE, "process_display_plte"}, - {MNG_FN_PROCESS_DISPLAY_IDAT, "process_display_idat"}, - {MNG_FN_PROCESS_DISPLAY_IEND, "process_display_iend"}, - {MNG_FN_PROCESS_DISPLAY_TRNS, "process_display_trns"}, - {MNG_FN_PROCESS_DISPLAY_GAMA, "process_display_gama"}, - {MNG_FN_PROCESS_DISPLAY_CHRM, "process_display_chrm"}, - {MNG_FN_PROCESS_DISPLAY_SRGB, "process_display_srgb"}, - {MNG_FN_PROCESS_DISPLAY_ICCP, "process_display_iccp"}, - {MNG_FN_PROCESS_DISPLAY_BKGD, "process_display_bkgd"}, - {MNG_FN_PROCESS_DISPLAY_PHYS, "process_display_phys"}, - {MNG_FN_PROCESS_DISPLAY_SBIT, "process_display_sbit"}, - {MNG_FN_PROCESS_DISPLAY_SPLT, "process_display_splt"}, - {MNG_FN_PROCESS_DISPLAY_HIST, "process_display_hist"}, - {MNG_FN_PROCESS_DISPLAY_MHDR, "process_display_mhdr"}, - {MNG_FN_PROCESS_DISPLAY_MEND, "process_display_mend"}, - {MNG_FN_PROCESS_DISPLAY_LOOP, "process_display_loop"}, - {MNG_FN_PROCESS_DISPLAY_ENDL, "process_display_endl"}, - {MNG_FN_PROCESS_DISPLAY_DEFI, "process_display_defi"}, - {MNG_FN_PROCESS_DISPLAY_BASI, "process_display_basi"}, - {MNG_FN_PROCESS_DISPLAY_CLON, "process_display_clon"}, -#ifndef MNG_SKIPCHUNK_PAST - {MNG_FN_PROCESS_DISPLAY_PAST, "process_display_past"}, -#endif - {MNG_FN_PROCESS_DISPLAY_DISC, "process_display_disc"}, - {MNG_FN_PROCESS_DISPLAY_BACK, "process_display_back"}, - {MNG_FN_PROCESS_DISPLAY_FRAM, "process_display_fram"}, - {MNG_FN_PROCESS_DISPLAY_MOVE, "process_display_move"}, - {MNG_FN_PROCESS_DISPLAY_CLIP, "process_display_clip"}, - {MNG_FN_PROCESS_DISPLAY_SHOW, "process_display_show"}, - {MNG_FN_PROCESS_DISPLAY_TERM, "process_display_term"}, - {MNG_FN_PROCESS_DISPLAY_SAVE, "process_display_save"}, - {MNG_FN_PROCESS_DISPLAY_SEEK, "process_display_seek"}, - {MNG_FN_PROCESS_DISPLAY_EXPI, "process_display_expi"}, - {MNG_FN_PROCESS_DISPLAY_FPRI, "process_display_fpri"}, - {MNG_FN_PROCESS_DISPLAY_NEED, "process_display_need"}, - {MNG_FN_PROCESS_DISPLAY_PHYG, "process_display_phyg"}, -#ifdef MNG_INCLUDE_JNG - {MNG_FN_PROCESS_DISPLAY_JHDR, "process_display_jhdr"}, - {MNG_FN_PROCESS_DISPLAY_JDAT, "process_display_jdat"}, - {MNG_FN_PROCESS_DISPLAY_JSEP, "process_display_jsep"}, -#endif -#ifndef MNG_NO_DELTA_PNG - {MNG_FN_PROCESS_DISPLAY_DHDR, "process_display_dhdr"}, - {MNG_FN_PROCESS_DISPLAY_PROM, "process_display_prom"}, -#ifdef MNG_INCLUDE_JNG - {MNG_FN_PROCESS_DISPLAY_IPNG, "process_display_ipng"}, -#endif - {MNG_FN_PROCESS_DISPLAY_PPLT, "process_display_pplt"}, - {MNG_FN_PROCESS_DISPLAY_IJNG, "process_display_ijng"}, - {MNG_FN_PROCESS_DISPLAY_DROP, "process_display_drop"}, - {MNG_FN_PROCESS_DISPLAY_DBYK, "process_display_dbyk"}, - {MNG_FN_PROCESS_DISPLAY_ORDR, "process_display_ordr"}, -#endif - {MNG_FN_PROCESS_DISPLAY_MAGN, "process_display_magn"}, - {MNG_FN_PROCESS_DISPLAY_JDAA, "process_display_jdaa"}, - - {MNG_FN_JPEG_INITIALIZE, "jpeg_initialize"}, - {MNG_FN_JPEG_CLEANUP, "jpeg_cleanup"}, - {MNG_FN_JPEG_DECOMPRESSINIT, "jpeg_decompressinit"}, - {MNG_FN_JPEG_DECOMPRESSDATA, "jpeg_decompressdata"}, - {MNG_FN_JPEG_DECOMPRESSFREE, "jpeg_decompressfree"}, - - {MNG_FN_STORE_JPEG_G8, "store_jpeg_g8"}, - {MNG_FN_STORE_JPEG_RGB8, "store_jpeg_rgb8"}, - {MNG_FN_STORE_JPEG_G12, "store_jpeg_g12"}, - {MNG_FN_STORE_JPEG_RGB12, "store_jpeg_rgb12"}, - {MNG_FN_STORE_JPEG_GA8, "store_jpeg_ga8"}, - {MNG_FN_STORE_JPEG_RGBA8, "store_jpeg_rgba8"}, - {MNG_FN_STORE_JPEG_GA12, "store_jpeg_ga12"}, - {MNG_FN_STORE_JPEG_RGBA12, "store_jpeg_rgba12"}, - {MNG_FN_STORE_JPEG_G8_ALPHA, "store_jpeg_g8_alpha"}, - {MNG_FN_STORE_JPEG_RGB8_ALPHA, "store_jpeg_rgb8_alpha"}, - - {MNG_FN_INIT_JPEG_A1_NI, "init_jpeg_a1_ni"}, - {MNG_FN_INIT_JPEG_A2_NI, "init_jpeg_a2_ni"}, - {MNG_FN_INIT_JPEG_A4_NI, "init_jpeg_a4_ni"}, - {MNG_FN_INIT_JPEG_A8_NI, "init_jpeg_a8_ni"}, - {MNG_FN_INIT_JPEG_A16_NI, "init_jpeg_a16_ni"}, - - {MNG_FN_STORE_JPEG_G8_A1, "store_jpeg_g8_a1"}, - {MNG_FN_STORE_JPEG_G8_A2, "store_jpeg_g8_a2"}, - {MNG_FN_STORE_JPEG_G8_A4, "store_jpeg_g8_a4"}, - {MNG_FN_STORE_JPEG_G8_A8, "store_jpeg_g8_a8"}, - {MNG_FN_STORE_JPEG_G8_A16, "store_jpeg_g8_a16"}, - - {MNG_FN_STORE_JPEG_RGB8_A1, "store_jpeg_rgb8_a1"}, - {MNG_FN_STORE_JPEG_RGB8_A2, "store_jpeg_rgb8_a2"}, - {MNG_FN_STORE_JPEG_RGB8_A4, "store_jpeg_rgb8_a4"}, - {MNG_FN_STORE_JPEG_RGB8_A8, "store_jpeg_rgb8_a8"}, - {MNG_FN_STORE_JPEG_RGB8_A16, "store_jpeg_rgb8_a16"}, - - {MNG_FN_STORE_JPEG_G12_A1, "store_jpeg_g12_a1"}, - {MNG_FN_STORE_JPEG_G12_A2, "store_jpeg_g12_a2"}, - {MNG_FN_STORE_JPEG_G12_A4, "store_jpeg_g12_a4"}, - {MNG_FN_STORE_JPEG_G12_A8, "store_jpeg_g12_a8"}, - {MNG_FN_STORE_JPEG_G12_A16, "store_jpeg_g12_a16"}, - - {MNG_FN_STORE_JPEG_RGB12_A1, "store_jpeg_rgb12_a1"}, - {MNG_FN_STORE_JPEG_RGB12_A2, "store_jpeg_rgb12_a2"}, - {MNG_FN_STORE_JPEG_RGB12_A4, "store_jpeg_rgb12_a4"}, - {MNG_FN_STORE_JPEG_RGB12_A8, "store_jpeg_rgb12_a8"}, - {MNG_FN_STORE_JPEG_RGB12_A16, "store_jpeg_rgb12_a16"}, - - {MNG_FN_NEXT_JPEG_ALPHAROW, "next_jpeg_alpharow"}, - {MNG_FN_NEXT_JPEG_ROW, "next_jpeg_row"}, - {MNG_FN_DISPLAY_JPEG_ROWS, "display_jpeg_rows"}, - - {MNG_FN_MAGNIFY_G8_X1, "magnify_g8_x1"}, - {MNG_FN_MAGNIFY_G8_X2, "magnify_g8_x2"}, - {MNG_FN_MAGNIFY_RGB8_X1, "magnify_rgb8_x1"}, - {MNG_FN_MAGNIFY_RGB8_X2, "magnify_rgb8_x2"}, - {MNG_FN_MAGNIFY_GA8_X1, "magnify_ga8_x1"}, - {MNG_FN_MAGNIFY_GA8_X2, "magnify_ga8_x2"}, - {MNG_FN_MAGNIFY_GA8_X3, "magnify_ga8_x3"}, - {MNG_FN_MAGNIFY_GA8_X4, "magnify_ga8_x4"}, - {MNG_FN_MAGNIFY_RGBA8_X1, "magnify_rgba8_x1"}, - {MNG_FN_MAGNIFY_RGBA8_X2, "magnify_rgba8_x2"}, - {MNG_FN_MAGNIFY_RGBA8_X3, "magnify_rgba8_x3"}, - {MNG_FN_MAGNIFY_RGBA8_X4, "magnify_rgba8_x4"}, - {MNG_FN_MAGNIFY_G8_X3, "magnify_g8_x3"}, - {MNG_FN_MAGNIFY_RGB8_X3, "magnify_rgb8_x3"}, - {MNG_FN_MAGNIFY_GA8_X5, "magnify_ga8_x5"}, - {MNG_FN_MAGNIFY_RGBA8_X5, "magnify_rgba8_x5"}, - - {MNG_FN_MAGNIFY_G8_Y1, "magnify_g8_y1"}, - {MNG_FN_MAGNIFY_G8_Y2, "magnify_g8_y2"}, - {MNG_FN_MAGNIFY_RGB8_Y1, "magnify_rgb8_y1"}, - {MNG_FN_MAGNIFY_RGB8_Y2, "magnify_rgb8_y2"}, - {MNG_FN_MAGNIFY_GA8_Y1, "magnify_ga8_y1"}, - {MNG_FN_MAGNIFY_GA8_Y2, "magnify_ga8_y2"}, - {MNG_FN_MAGNIFY_GA8_Y3, "magnify_ga8_y3"}, - {MNG_FN_MAGNIFY_GA8_Y4, "magnify_ga8_y4"}, - {MNG_FN_MAGNIFY_RGBA8_Y1, "magnify_rgba8_y1"}, - {MNG_FN_MAGNIFY_RGBA8_Y2, "magnify_rgba8_y2"}, - {MNG_FN_MAGNIFY_RGBA8_Y3, "magnify_rgba8_y3"}, - {MNG_FN_MAGNIFY_RGBA8_Y4, "magnify_rgba8_y4"}, - {MNG_FN_MAGNIFY_G8_Y3, "magnify_g8_y3"}, - {MNG_FN_MAGNIFY_RGB8_Y3, "magnify_rgb8_y3"}, - {MNG_FN_MAGNIFY_GA8_Y5, "magnify_ga8_y5"}, - {MNG_FN_MAGNIFY_RGBA8_Y5, "magnify_rgba8_y5"}, - - {MNG_FN_MAGNIFY_G8_X1, "magnify_g8_x1"}, - {MNG_FN_MAGNIFY_G8_X2, "magnify_g8_x2"}, - {MNG_FN_MAGNIFY_RGB8_X1, "magnify_rgb8_x1"}, - {MNG_FN_MAGNIFY_RGB8_X2, "magnify_rgb8_x2"}, - {MNG_FN_MAGNIFY_GA8_X1, "magnify_ga8_x1"}, - {MNG_FN_MAGNIFY_GA8_X2, "magnify_ga8_x2"}, - {MNG_FN_MAGNIFY_GA8_X3, "magnify_ga8_x3"}, - {MNG_FN_MAGNIFY_GA8_X4, "magnify_ga8_x4"}, - {MNG_FN_MAGNIFY_RGBA8_X1, "magnify_rgba8_x1"}, - {MNG_FN_MAGNIFY_RGBA8_X2, "magnify_rgba8_x2"}, - {MNG_FN_MAGNIFY_RGBA8_X3, "magnify_rgba8_x3"}, - {MNG_FN_MAGNIFY_RGBA8_X4, "magnify_rgba8_x4"}, - {MNG_FN_MAGNIFY_G8_X3, "magnify_g8_x3"}, - {MNG_FN_MAGNIFY_RGB8_X3, "magnify_rgb8_x3"}, - {MNG_FN_MAGNIFY_GA8_X5, "magnify_ga8_x5"}, - {MNG_FN_MAGNIFY_RGBA8_X5, "magnify_rgba8_x5"}, - - {MNG_FN_MAGNIFY_G8_Y1, "magnify_g8_y1"}, - {MNG_FN_MAGNIFY_G8_Y2, "magnify_g8_y2"}, - {MNG_FN_MAGNIFY_RGB8_Y1, "magnify_rgb8_y1"}, - {MNG_FN_MAGNIFY_RGB8_Y2, "magnify_rgb8_y2"}, - {MNG_FN_MAGNIFY_GA8_Y1, "magnify_ga8_y1"}, - {MNG_FN_MAGNIFY_GA8_Y2, "magnify_ga8_y2"}, - {MNG_FN_MAGNIFY_GA8_Y3, "magnify_ga8_y3"}, - {MNG_FN_MAGNIFY_GA8_Y4, "magnify_ga8_y4"}, - {MNG_FN_MAGNIFY_RGBA8_Y1, "magnify_rgba8_y1"}, - {MNG_FN_MAGNIFY_RGBA8_Y2, "magnify_rgba8_y2"}, - {MNG_FN_MAGNIFY_RGBA8_Y3, "magnify_rgba8_y3"}, - {MNG_FN_MAGNIFY_RGBA8_Y4, "magnify_rgba8_y4"}, - {MNG_FN_MAGNIFY_G8_Y3, "magnify_g8_y3"}, - {MNG_FN_MAGNIFY_RGB8_Y3, "magnify_rgb8_y3"}, - {MNG_FN_MAGNIFY_GA8_Y5, "magnify_ga8_y5"}, - {MNG_FN_MAGNIFY_RGBA8_Y5, "magnify_rgba8_y5"}, - - {MNG_FN_DELTA_G1_G1, "delta_g1_g1"}, - {MNG_FN_DELTA_G2_G2, "delta_g2_g2"}, - {MNG_FN_DELTA_G4_G4, "delta_g4_g4"}, - {MNG_FN_DELTA_G8_G8, "delta_g8_g8"}, - {MNG_FN_DELTA_G16_G16, "delta_g16_g16"}, - {MNG_FN_DELTA_RGB8_RGB8, "delta_rgb8_rgb8"}, - {MNG_FN_DELTA_RGB16_RGB16, "delta_rgb16_rgb16"}, - {MNG_FN_DELTA_GA8_GA8, "delta_ga8_ga8"}, - {MNG_FN_DELTA_GA8_G8, "delta_ga8_g8"}, - {MNG_FN_DELTA_GA8_A8, "delta_ga8_a8"}, - {MNG_FN_DELTA_GA16_GA16, "delta_ga16_ga16"}, - {MNG_FN_DELTA_GA16_G16, "delta_ga16_g16"}, - {MNG_FN_DELTA_GA16_A16, "delta_ga16_a16"}, - {MNG_FN_DELTA_RGBA8_RGBA8, "delta_rgba8_rgba8"}, - {MNG_FN_DELTA_RGBA8_RGB8, "delta_rgba8_rgb8"}, - {MNG_FN_DELTA_RGBA8_A8, "delta_rgba8_a8"}, - {MNG_FN_DELTA_RGBA16_RGBA16, "delta_rgba16_rgba16"}, - {MNG_FN_DELTA_RGBA16_RGB16, "delta_rgba16_rgb16"}, - {MNG_FN_DELTA_RGBA16_A16, "delta_rgba16_a16"}, - - {MNG_FN_PROMOTE_G8_G8, "promote_g8_g8"}, - {MNG_FN_PROMOTE_G8_G16, "promote_g8_g16"}, - {MNG_FN_PROMOTE_G16_G16, "promote_g8_g16"}, - {MNG_FN_PROMOTE_G8_GA8, "promote_g8_ga8"}, - {MNG_FN_PROMOTE_G8_GA16, "promote_g8_ga16"}, - {MNG_FN_PROMOTE_G16_GA16, "promote_g16_ga16"}, - {MNG_FN_PROMOTE_G8_RGB8, "promote_g8_rgb8"}, - {MNG_FN_PROMOTE_G8_RGB16, "promote_g8_rgb16"}, - {MNG_FN_PROMOTE_G16_RGB16, "promote_g16_rgb16"}, - {MNG_FN_PROMOTE_G8_RGBA8, "promote_g8_rgba8"}, - {MNG_FN_PROMOTE_G8_RGBA16, "promote_g8_rgba16"}, - {MNG_FN_PROMOTE_G16_RGBA16, "promote_g16_rgba16"}, - {MNG_FN_PROMOTE_GA8_GA16, "promote_ga8_ga16"}, - {MNG_FN_PROMOTE_GA8_RGBA8, "promote_ga8_rgba8"}, - {MNG_FN_PROMOTE_GA8_RGBA16, "promote_ga8_rgba16"}, - {MNG_FN_PROMOTE_GA16_RGBA16, "promote_ga16_rgba16"}, - {MNG_FN_PROMOTE_RGB8_RGB16, "promote_rgb8_rgb16"}, - {MNG_FN_PROMOTE_RGB8_RGBA8, "promote_rgb8_rgba8"}, - {MNG_FN_PROMOTE_RGB8_RGBA16, "promote_rgb8_rgba16"}, - {MNG_FN_PROMOTE_RGB16_RGBA16, "promote_rgb16_rgba16"}, - {MNG_FN_PROMOTE_RGBA8_RGBA16, "promote_rgba8_rgba16"}, - {MNG_FN_PROMOTE_IDX8_RGB8, "promote_idx8_rgb8"}, - {MNG_FN_PROMOTE_IDX8_RGB16, "promote_idx8_rgb16"}, - {MNG_FN_PROMOTE_IDX8_RGBA8, "promote_idx8_rgba8"}, - {MNG_FN_PROMOTE_IDX8_RGBA16, "promote_idx8_rgba16"}, - - {MNG_FN_SCALE_G1_G2, "scale_g1_g2"}, - {MNG_FN_SCALE_G1_G4, "scale_g1_g4"}, - {MNG_FN_SCALE_G1_G8, "scale_g1_g8"}, - {MNG_FN_SCALE_G1_G16, "scale_g1_g16"}, - {MNG_FN_SCALE_G2_G4, "scale_g2_g4"}, - {MNG_FN_SCALE_G2_G8, "scale_g2_g8"}, - {MNG_FN_SCALE_G2_G16, "scale_g2_g16"}, - {MNG_FN_SCALE_G4_G8, "scale_g4_g8"}, - {MNG_FN_SCALE_G4_G16, "scale_g4_g16"}, - {MNG_FN_SCALE_G8_G16, "scale_g8_g16"}, - {MNG_FN_SCALE_GA8_GA16, "scale_ga8_ga16"}, - {MNG_FN_SCALE_RGB8_RGB16, "scale_rgb8_rgb16"}, - {MNG_FN_SCALE_RGBA8_RGBA16, "scale_rgba8_rgba16"}, - - {MNG_FN_SCALE_G2_G1, "scale_g2_g1"}, - {MNG_FN_SCALE_G4_G1, "scale_g4_g1"}, - {MNG_FN_SCALE_G8_G1, "scale_g8_g1"}, - {MNG_FN_SCALE_G16_G1, "scale_g16_g1"}, - {MNG_FN_SCALE_G4_G2, "scale_g4_g2"}, - {MNG_FN_SCALE_G8_G2, "scale_g8_g2"}, - {MNG_FN_SCALE_G16_G2, "scale_g16_g2"}, - {MNG_FN_SCALE_G8_G4, "scale_g8_g4"}, - {MNG_FN_SCALE_G16_G4, "scale_g16_g4"}, - {MNG_FN_SCALE_G16_G8, "scale_g16_g8"}, - {MNG_FN_SCALE_GA16_GA8, "scale_ga16_ga8"}, - {MNG_FN_SCALE_RGB16_RGB8, "scale_rgb16_rgb8"}, - {MNG_FN_SCALE_RGBA16_RGBA8, "scale_rgba16_rgba8"}, - - {MNG_FN_COMPOSEOVER_RGBA8, "composeover_rgba8"}, - {MNG_FN_COMPOSEOVER_RGBA16, "composeover_rgba16"}, - {MNG_FN_COMPOSEUNDER_RGBA8, "composeunder_rgba8"}, - {MNG_FN_COMPOSEUNDER_RGBA16, "composeunder_rgba16"}, - - {MNG_FN_FLIP_RGBA8, "flip_rgba8"}, - {MNG_FN_FLIP_RGBA16, "flip_rgba16"}, - {MNG_FN_TILE_RGBA8, "tile_rgba8"}, - {MNG_FN_TILE_RGBA16, "tile_rgba16"} - - }; -#endif /* MNG_INCLUDE_TRACE_STINGS */ - -/* ************************************************************************** */ - -mng_retcode mng_trace (mng_datap pData, - mng_uint32 iFunction, - mng_uint32 iLocation) -{ - mng_pchar zName = 0; /* bufferptr for tracestring */ - - if ((pData == 0) || (pData->iMagic != MNG_MAGIC)) - return MNG_INVALIDHANDLE; /* no good if the handle is corrupt */ - - if (pData->fTraceproc) /* report back to user ? */ - { -#ifdef MNG_INCLUDE_TRACE_STRINGS - { /* binary search variables */ - mng_int32 iTop, iLower, iUpper, iMiddle; - mng_trace_entryp pEntry; /* pointer to found entry */ - /* determine max index of table */ - iTop = (sizeof (trace_table) / sizeof (trace_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 (trace_table [iMiddle].iFunction < iFunction) - iLower = iMiddle + 1; - else if (trace_table [iMiddle].iFunction > iFunction) - iUpper = iMiddle - 1; - else - { - pEntry = &trace_table [iMiddle]; - break; - }; - - iMiddle = (iLower + iUpper) >> 1; - } - while (iLower <= iUpper); - - if (pEntry) /* found it ? */ - zName = pEntry->zTracetext; - - } -#endif - /* oke, now tell */ - if (!pData->fTraceproc (((mng_handle)pData), iFunction, iLocation, zName)) - return MNG_APPTRACEABORT; - - } - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_TRACE_PROCS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/plugins/AdvaImg/src/LibMNG/libmng_trace.h b/plugins/AdvaImg/src/LibMNG/libmng_trace.h deleted file mode 100644 index d8621c34c3..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_trace.h +++ /dev/null @@ -1,1474 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_trace.h copyright (c) 2000-2007 G.Juyn * */ -/* * version : 1.0.10 * */ -/* * * */ -/* * purpose : Trace functions (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * comment : Definition of the trace functions * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - added chunk-access function trace-codes * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * 0.5.1 - 05/13/2000 - G.Juyn * */ -/* * - added save_state & restore_state trace-codes * */ -/* * 0.5.1 - 05/15/2000 - G.Juyn * */ -/* * - added getimgdata & putimgdata trace-codes * */ -/* * * */ -/* * 0.5.2 - 05/20/2000 - G.Juyn * */ -/* * - added JNG tracecodes * */ -/* * 0.5.2 - 05/23/2000 - G.Juyn * */ -/* * - added trace-table entry definition * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - added tracecodes for global animation color-chunks * */ -/* * - added tracecodes for get/set of default ZLIB/IJG parms * */ -/* * - added tracecodes for global PLTE,tRNS,bKGD * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added tracecodes for image-object promotion * */ -/* * - added tracecodes for delta-image processing * */ -/* * 0.5.2 - 06/02/2000 - G.Juyn * */ -/* * - added tracecodes for getalphaline callback * */ -/* * 0.5.2 - 06/05/2000 - G.Juyn * */ -/* * - added tracecode for RGB8_A8 canvasstyle * */ -/* * 0.5.2 - 06/06/2000 - G.Juyn * */ -/* * - added tracecode for mng_read_resume HLAPI function * */ -/* * * */ -/* * 0.5.3 - 06/06/2000 - G.Juyn * */ -/* * - added tracecodes for tracing JPEG progression * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added tracecodes for get/set speedtype * */ -/* * - added tracecodes for get imagelevel * */ -/* * 0.5.3 - 06/22/2000 - G.Juyn * */ -/* * - added tracecode for delta-image processing * */ -/* * - added tracecodes for PPLT chunk processing * */ -/* * * */ -/* * 0.9.1 - 07/07/2000 - G.Juyn * */ -/* * - added tracecodes for special display processing * */ -/* * 0.9.1 - 07/08/2000 - G.Juyn * */ -/* * - added tracecode for get/set suspensionmode * */ -/* * - added tracecodes for get/set display variables * */ -/* * - added tracecode for read_databuffer (I/O-suspension) * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - added tracecodes for SAVE/SEEK callbacks * */ -/* * - added tracecodes for get/set sectionbreaks * */ -/* * - added tracecode for special error routine * */ -/* * 0.9.1 - 07/19/2000 - G.Juyn * */ -/* * - added tracecode for updatemngheader * */ -/* * * */ -/* * 0.9.2 - 07/31/2000 - G.Juyn * */ -/* * - added tracecodes for status_xxxxx functions * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * - added tracecode for updatemngsimplicity * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * 0.9.3 - 10/10/2000 - G.Juyn * */ -/* * - added support for alpha-depth prediction * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - added JDAA chunk * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added functions to retrieve PNG/JNG specific header-info * */ -/* * - added optional support for bKGD for PNG images * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added callback to process non-critical unknown chunks * */ -/* * - added routine to discard "invalid" objects * */ -/* * 0.9.3 - 10/19/2000 - G.Juyn * */ -/* * - implemented delayed delta-processing * */ -/* * 0.9.3 - 10/20/2000 - G.Juyn * */ -/* * - added get/set for bKGD preference setting * */ -/* * 0.9.3 - 10/21/2000 - G.Juyn * */ -/* * - added get function for interlace/progressive display * */ -/* * * */ -/* * 0.9.4 - 1/18/2001 - G.Juyn * */ -/* * - added "new" MAGN methods 3, 4 & 5 * */ -/* * * */ -/* * 1.0.1 - 02/08/2001 - G.Juyn * */ -/* * - added MEND processing callback * */ -/* * 1.0.1 - 04/21/2001 - G.Juyn (code by G.Kelly) * */ -/* * - added BGRA8 canvas with premultiplied alpha * */ -/* * 1.0.1 - 05/02/2001 - G.Juyn * */ -/* * - added "default" sRGB generation (Thanks Marti!) * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added optimization option for MNG-video playback * */ -/* * - added processterm callback * */ -/* * 1.0.2 - 06/25/2001 - G.Juyn * */ -/* * - added option to turn off progressive refresh * */ -/* * * */ -/* * 1.0.3 - 08/06/2001 - G.Juyn * */ -/* * - added get function for last processed BACK chunk * */ -/* * * */ -/* * 1.0.5 - 08/15/2002 - G.Juyn * */ -/* * - completed PROM support * */ -/* * - completed delta-image support * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * - added HLAPI function to copy chunks * */ -/* * 1.0.5 - 09/14/2002 - G.Juyn * */ -/* * - added event handling for dynamic MNG * */ -/* * 1.0.5 - 09/20/2002 - G.Juyn * */ -/* * - added support for PAST * */ -/* * 1.0.5 - 09/22/2002 - G.Juyn * */ -/* * - added bgrx8 canvas (filler byte) * */ -/* * 1.0.5 - 09/23/2002 - G.Juyn * */ -/* * - added in-memory color-correction of abstract images * */ -/* * - added compose over/under routines for PAST processing * */ -/* * - added flip & tile routines for PAST processing * */ -/* * 1.0.5 - 10/09/2002 - G.Juyn * */ -/* * - fixed trace-constants for PAST chunk * */ -/* * 1.0.5 - 11/07/2002 - G.Juyn * */ -/* * - added support to get totals after mng_read() * */ -/* * * */ -/* * 1.0.6 - 07/14/2003 - G.Randers-Pehrson * */ -/* * - added conditionals around rarely used features * */ -/* * * */ -/* * 1.0.7 - 11/27/2003 - R.A * */ -/* * - added CANVAS_RGB565 and CANVAS_BGR565 * */ -/* * 1.0.7 - 01/25/2004 - J.S * */ -/* * - added premultiplied alpha canvas' for RGBA, ARGB, ABGR * */ -/* * 1.0.7 - 03/10/2004 - G.R-P * */ -/* * - added conditionals around openstream/closestream * */ -/* * * */ -/* * 1.0.8 - 04/02/2004 - G.Juyn * */ -/* * - added CRC existence & checking flags * */ -/* * 1.0.8 - 04/11/2004 - G.Juyn * */ -/* * - added data-push mechanisms for specialized decoders * */ -/* * * */ -/* * 1.0.9 - 10/03/2004 - G.Juyn * */ -/* * - added function to retrieve current FRAM delay * */ -/* * 1.0.9 - 10/14/2004 - G.Juyn * */ -/* * - added bgr565_a8 canvas-style (thanks to J. Elvander) * */ -/* * * */ -/* * 1.0.10 - 04/08/2007 - G.Juyn * */ -/* * - added support for mPNG proposal * */ -/* * 1.0.10 - 07/06/2007 - G.R-P bugfix by Lucas Quintana * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_trace_h_ -#define _libmng_trace_h_ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_TRACE_PROCS - -/* ************************************************************************** */ - -/* TODO: add a trace-mask so certain functions can be excluded */ - -mng_retcode mng_trace (mng_datap pData, - mng_uint32 iFunction, - mng_uint32 iLocation); - -/* ************************************************************************** */ - -#define MNG_TRACE(D,F,L) { mng_retcode iR = mng_trace (D,F,L); \ - if (iR) return iR; } - -#define MNG_TRACEB(D,F,L) { if (mng_trace (D,F,L)) return MNG_FALSE; } - -#define MNG_TRACEX(D,F,L) { if (mng_trace (D,F,L)) return 0; } - -/* ************************************************************************** */ - -#define MNG_LC_START 1 -#define MNG_LC_END 2 -#define MNG_LC_INITIALIZE 3 -#define MNG_LC_CLEANUP 4 - -/* ************************************************************************** */ - -#define MNG_LC_JPEG_CREATE_DECOMPRESS 101 -#define MNG_LC_JPEG_READ_HEADER 102 -#define MNG_LC_JPEG_START_DECOMPRESS 103 -#define MNG_LC_JPEG_START_OUTPUT 104 -#define MNG_LC_JPEG_READ_SCANLINES 105 -#define MNG_LC_JPEG_FINISH_OUTPUT 106 -#define MNG_LC_JPEG_FINISH_DECOMPRESS 107 -#define MNG_LC_JPEG_DESTROY_DECOMPRESS 108 - -/* ************************************************************************** */ - -#define MNG_FN_INITIALIZE 1 -#define MNG_FN_RESET 2 -#define MNG_FN_CLEANUP 3 -#define MNG_FN_READ 4 -#define MNG_FN_WRITE 5 -#define MNG_FN_CREATE 6 -#define MNG_FN_READDISPLAY 7 -#define MNG_FN_DISPLAY 8 -#define MNG_FN_DISPLAY_RESUME 9 -#define MNG_FN_DISPLAY_FREEZE 10 -#define MNG_FN_DISPLAY_RESET 11 -#ifndef MNG_NO_DISPLAY_GO_SUPPORTED -#define MNG_FN_DISPLAY_GOFRAME 12 -#define MNG_FN_DISPLAY_GOLAYER 13 -#define MNG_FN_DISPLAY_GOTIME 14 -#endif -#define MNG_FN_GETLASTERROR 15 -#define MNG_FN_READ_RESUME 16 -#define MNG_FN_TRAPEVENT 17 -#define MNG_FN_READ_PUSHDATA 18 -#define MNG_FN_READ_PUSHSIG 19 -#define MNG_FN_READ_PUSHCHUNK 20 - -#define MNG_FN_SETCB_MEMALLOC 101 -#define MNG_FN_SETCB_MEMFREE 102 -#define MNG_FN_SETCB_READDATA 103 -#define MNG_FN_SETCB_WRITEDATA 104 -#define MNG_FN_SETCB_ERRORPROC 105 -#define MNG_FN_SETCB_TRACEPROC 106 -#define MNG_FN_SETCB_PROCESSHEADER 107 -#define MNG_FN_SETCB_PROCESSTEXT 108 -#define MNG_FN_SETCB_GETCANVASLINE 109 -#define MNG_FN_SETCB_GETBKGDLINE 110 -#define MNG_FN_SETCB_REFRESH 111 -#define MNG_FN_SETCB_GETTICKCOUNT 112 -#define MNG_FN_SETCB_SETTIMER 113 -#define MNG_FN_SETCB_PROCESSGAMMA 114 -#define MNG_FN_SETCB_PROCESSCHROMA 115 -#define MNG_FN_SETCB_PROCESSSRGB 116 -#define MNG_FN_SETCB_PROCESSICCP 117 -#define MNG_FN_SETCB_PROCESSAROW 118 -#ifndef MNG_NO_OPEN_CLOSE_STREAM -#define MNG_FN_SETCB_OPENSTREAM 119 -#define MNG_FN_SETCB_CLOSESTREAM 120 -#endif -#define MNG_FN_SETCB_GETALPHALINE 121 -#define MNG_FN_SETCB_PROCESSSAVE 122 -#define MNG_FN_SETCB_PROCESSSEEK 123 -#define MNG_FN_SETCB_PROCESSNEED 124 -#define MNG_FN_SETCB_PROCESSUNKNOWN 125 -#define MNG_FN_SETCB_PROCESSMEND 126 -#define MNG_FN_SETCB_PROCESSTERM 127 -#define MNG_FN_SETCB_RELEASEDATA 128 - -#define MNG_FN_GETCB_MEMALLOC 201 -#define MNG_FN_GETCB_MEMFREE 202 -#define MNG_FN_GETCB_READDATA 203 -#define MNG_FN_GETCB_WRITEDATA 204 -#define MNG_FN_GETCB_ERRORPROC 205 -#define MNG_FN_GETCB_TRACEPROC 206 -#define MNG_FN_GETCB_PROCESSHEADER 207 -#define MNG_FN_GETCB_PROCESSTEXT 208 -#define MNG_FN_GETCB_GETCANVASLINE 209 -#define MNG_FN_GETCB_GETBKGDLINE 210 -#define MNG_FN_GETCB_REFRESH 211 -#define MNG_FN_GETCB_GETTICKCOUNT 212 -#define MNG_FN_GETCB_SETTIMER 213 -#define MNG_FN_GETCB_PROCESSGAMMA 214 -#define MNG_FN_GETCB_PROCESSCHROMA 215 -#define MNG_FN_GETCB_PROCESSSRGB 216 -#define MNG_FN_GETCB_PROCESSICCP 217 -#define MNG_FN_GETCB_PROCESSAROW 218 -#ifndef MNG_NO_OPEN_CLOSE_STREAM -#define MNG_FN_GETCB_OPENSTREAM 219 -#define MNG_FN_GETCB_CLOSESTREAM 220 -#endif -#define MNG_FN_GETCB_GETALPHALINE 221 -#define MNG_FN_GETCB_PROCESSSAVE 222 -#define MNG_FN_GETCB_PROCESSSEEK 223 -#define MNG_FN_GETCB_PROCESSNEED 224 -#define MNG_FN_GETCB_PROCESSUNKNOWN 225 -#define MNG_FN_GETCB_PROCESSMEND 226 -#define MNG_FN_GETCB_PROCESSTERM 227 -#define MNG_FN_GETCB_RELEASEDATA 228 - -#define MNG_FN_SET_USERDATA 301 -#define MNG_FN_SET_CANVASSTYLE 302 -#define MNG_FN_SET_BKGDSTYLE 303 -#define MNG_FN_SET_BGCOLOR 304 -#define MNG_FN_SET_STORECHUNKS 305 -#define MNG_FN_SET_VIEWGAMMA 306 -#define MNG_FN_SET_DISPLAYGAMMA 307 -#define MNG_FN_SET_DFLTIMGGAMMA 308 -#define MNG_FN_SET_SRGB 309 -#define MNG_FN_SET_OUTPUTPROFILE 310 -#define MNG_FN_SET_SRGBPROFILE 311 -#define MNG_FN_SET_MAXCANVASWIDTH 312 -#define MNG_FN_SET_MAXCANVASHEIGHT 313 -#define MNG_FN_SET_MAXCANVASSIZE 314 -#define MNG_FN_SET_ZLIB_LEVEL 315 -#define MNG_FN_SET_ZLIB_METHOD 316 -#define MNG_FN_SET_ZLIB_WINDOWBITS 317 -#define MNG_FN_SET_ZLIB_MEMLEVEL 318 -#define MNG_FN_SET_ZLIB_STRATEGY 319 -#define MNG_FN_SET_ZLIB_MAXIDAT 320 -#define MNG_FN_SET_JPEG_DCTMETHOD 321 -#define MNG_FN_SET_JPEG_QUALITY 322 -#define MNG_FN_SET_JPEG_SMOOTHING 323 -#define MNG_FN_SET_JPEG_PROGRESSIVE 324 -#define MNG_FN_SET_JPEG_OPTIMIZED 325 -#define MNG_FN_SET_JPEG_MAXJDAT 326 -#define MNG_FN_SET_SPEED 327 -#define MNG_FN_SET_SUSPENSIONMODE 328 -#define MNG_FN_SET_SECTIONBREAKS 329 -#define MNG_FN_SET_USEBKGD 330 -#define MNG_FN_SET_OUTPUTPROFILE2 331 -#define MNG_FN_SET_SRGBPROFILE2 332 -#define MNG_FN_SET_OUTPUTSRGB 333 -#define MNG_FN_SET_SRGBIMPLICIT 334 -#define MNG_FN_SET_CACHEPLAYBACK 335 -#define MNG_FN_SET_DOPROGRESSIVE 336 -#define MNG_FN_SET_CRCMODE 337 - -#define MNG_FN_GET_USERDATA 401 -#define MNG_FN_GET_SIGTYPE 402 -#define MNG_FN_GET_IMAGETYPE 403 -#define MNG_FN_GET_IMAGEWIDTH 404 -#define MNG_FN_GET_IMAGEHEIGHT 405 -#define MNG_FN_GET_TICKS 406 -#define MNG_FN_GET_FRAMECOUNT 407 -#define MNG_FN_GET_LAYERCOUNT 408 -#define MNG_FN_GET_PLAYTIME 409 -#define MNG_FN_GET_SIMPLICITY 410 -#define MNG_FN_GET_CANVASSTYLE 411 -#define MNG_FN_GET_BKGDSTYLE 412 -#define MNG_FN_GET_BGCOLOR 413 -#define MNG_FN_GET_STORECHUNKS 414 -#define MNG_FN_GET_VIEWGAMMA 415 -#define MNG_FN_GET_DISPLAYGAMMA 416 -#define MNG_FN_GET_DFLTIMGGAMMA 417 -#define MNG_FN_GET_SRGB 418 -#define MNG_FN_GET_MAXCANVASWIDTH 419 -#define MNG_FN_GET_MAXCANVASHEIGHT 420 -#define MNG_FN_GET_ZLIB_LEVEL 421 -#define MNG_FN_GET_ZLIB_METHOD 422 -#define MNG_FN_GET_ZLIB_WINDOWBITS 423 -#define MNG_FN_GET_ZLIB_MEMLEVEL 424 -#define MNG_FN_GET_ZLIB_STRATEGY 425 -#define MNG_FN_GET_ZLIB_MAXIDAT 426 -#define MNG_FN_GET_JPEG_DCTMETHOD 427 -#define MNG_FN_GET_JPEG_QUALITY 428 -#define MNG_FN_GET_JPEG_SMOOTHING 429 -#define MNG_FN_GET_JPEG_PROGRESSIVE 430 -#define MNG_FN_GET_JPEG_OPTIMIZED 431 -#define MNG_FN_GET_JPEG_MAXJDAT 432 -#define MNG_FN_GET_SPEED 433 -#define MNG_FN_GET_IMAGELEVEL 434 -#define MNG_FN_GET_SUSPENSIONMODE 435 -#define MNG_FN_GET_STARTTIME 436 -#define MNG_FN_GET_RUNTIME 437 -#define MNG_FN_GET_CURRENTFRAME 438 -#define MNG_FN_GET_CURRENTLAYER 439 -#define MNG_FN_GET_CURRENTPLAYTIME 440 -#define MNG_FN_GET_SECTIONBREAKS 441 -#define MNG_FN_GET_ALPHADEPTH 442 -#define MNG_FN_GET_BITDEPTH 443 -#define MNG_FN_GET_COLORTYPE 444 -#define MNG_FN_GET_COMPRESSION 445 -#define MNG_FN_GET_FILTER 446 -#define MNG_FN_GET_INTERLACE 447 -#define MNG_FN_GET_ALPHABITDEPTH 448 -#define MNG_FN_GET_ALPHACOMPRESSION 449 -#define MNG_FN_GET_ALPHAFILTER 450 -#define MNG_FN_GET_ALPHAINTERLACE 451 -#define MNG_FN_GET_USEBKGD 452 -#define MNG_FN_GET_REFRESHPASS 453 -#define MNG_FN_GET_CACHEPLAYBACK 454 -#define MNG_FN_GET_DOPROGRESSIVE 455 -#define MNG_FN_GET_LASTBACKCHUNK 456 -#define MNG_FN_GET_LASTSEEKNAME 457 -#define MNG_FN_GET_TOTALFRAMES 458 -#define MNG_FN_GET_TOTALLAYERS 459 -#define MNG_FN_GET_TOTALPLAYTIME 460 -#define MNG_FN_GET_CRCMODE 461 -#define MNG_FN_GET_CURRFRAMDELAY 462 - -#define MNG_FN_STATUS_ERROR 481 -#define MNG_FN_STATUS_READING 482 -#define MNG_FN_STATUS_SUSPENDBREAK 483 -#define MNG_FN_STATUS_CREATING 484 -#define MNG_FN_STATUS_WRITING 485 -#define MNG_FN_STATUS_DISPLAYING 486 -#define MNG_FN_STATUS_RUNNING 487 -#define MNG_FN_STATUS_TIMERBREAK 488 -#define MNG_FN_STATUS_DYNAMIC 489 -#define MNG_FN_STATUS_RUNNINGEVENT 490 - -/* ************************************************************************** */ - -#define MNG_FN_ITERATE_CHUNKS 601 -#define MNG_FN_COPY_CHUNK 602 - -#define MNG_FN_GETCHUNK_IHDR 701 -#define MNG_FN_GETCHUNK_PLTE 702 -#define MNG_FN_GETCHUNK_IDAT 703 -#define MNG_FN_GETCHUNK_IEND 704 -#define MNG_FN_GETCHUNK_TRNS 705 -#define MNG_FN_GETCHUNK_GAMA 706 -#define MNG_FN_GETCHUNK_CHRM 707 -#define MNG_FN_GETCHUNK_SRGB 708 -#define MNG_FN_GETCHUNK_ICCP 709 -#define MNG_FN_GETCHUNK_TEXT 710 -#define MNG_FN_GETCHUNK_ZTXT 711 -#define MNG_FN_GETCHUNK_ITXT 712 -#define MNG_FN_GETCHUNK_BKGD 713 -#define MNG_FN_GETCHUNK_PHYS 714 -#define MNG_FN_GETCHUNK_SBIT 715 -#define MNG_FN_GETCHUNK_SPLT 716 -#define MNG_FN_GETCHUNK_HIST 717 -#define MNG_FN_GETCHUNK_TIME 718 -#define MNG_FN_GETCHUNK_MHDR 719 -#define MNG_FN_GETCHUNK_MEND 720 -#define MNG_FN_GETCHUNK_LOOP 721 -#define MNG_FN_GETCHUNK_ENDL 722 -#define MNG_FN_GETCHUNK_DEFI 723 -#define MNG_FN_GETCHUNK_BASI 724 -#define MNG_FN_GETCHUNK_CLON 725 -#define MNG_FN_GETCHUNK_PAST 726 -#define MNG_FN_GETCHUNK_DISC 727 -#define MNG_FN_GETCHUNK_BACK 728 -#define MNG_FN_GETCHUNK_FRAM 729 -#define MNG_FN_GETCHUNK_MOVE 730 -#define MNG_FN_GETCHUNK_CLIP 731 -#define MNG_FN_GETCHUNK_SHOW 732 -#define MNG_FN_GETCHUNK_TERM 733 -#define MNG_FN_GETCHUNK_SAVE 734 -#define MNG_FN_GETCHUNK_SEEK 735 -#define MNG_FN_GETCHUNK_EXPI 736 -#define MNG_FN_GETCHUNK_FPRI 737 -#define MNG_FN_GETCHUNK_NEED 738 -#define MNG_FN_GETCHUNK_PHYG 739 -#define MNG_FN_GETCHUNK_JHDR 740 -#define MNG_FN_GETCHUNK_JDAT 741 -#define MNG_FN_GETCHUNK_JSEP 742 -#define MNG_FN_GETCHUNK_DHDR 743 -#define MNG_FN_GETCHUNK_PROM 744 -#define MNG_FN_GETCHUNK_IPNG 745 -#define MNG_FN_GETCHUNK_PPLT 746 -#define MNG_FN_GETCHUNK_IJNG 747 -#define MNG_FN_GETCHUNK_DROP 748 -#define MNG_FN_GETCHUNK_DBYK 749 -#define MNG_FN_GETCHUNK_ORDR 750 -#define MNG_FN_GETCHUNK_UNKNOWN 751 -#define MNG_FN_GETCHUNK_MAGN 752 -#define MNG_FN_GETCHUNK_JDAA 753 -#define MNG_FN_GETCHUNK_EVNT 754 -#define MNG_FN_GETCHUNK_MPNG 755 - -#define MNG_FN_GETCHUNK_PAST_SRC 781 -#define MNG_FN_GETCHUNK_SAVE_ENTRY 782 -#define MNG_FN_GETCHUNK_PPLT_ENTRY 783 -#define MNG_FN_GETCHUNK_ORDR_ENTRY 784 -#define MNG_FN_GETCHUNK_EVNT_ENTRY 785 -#define MNG_FN_GETCHUNK_MPNG_FRAME 786 - -#define MNG_FN_PUTCHUNK_IHDR 801 -#define MNG_FN_PUTCHUNK_PLTE 802 -#define MNG_FN_PUTCHUNK_IDAT 803 -#define MNG_FN_PUTCHUNK_IEND 804 -#define MNG_FN_PUTCHUNK_TRNS 805 -#define MNG_FN_PUTCHUNK_GAMA 806 -#define MNG_FN_PUTCHUNK_CHRM 807 -#define MNG_FN_PUTCHUNK_SRGB 808 -#define MNG_FN_PUTCHUNK_ICCP 809 -#define MNG_FN_PUTCHUNK_TEXT 810 -#define MNG_FN_PUTCHUNK_ZTXT 811 -#define MNG_FN_PUTCHUNK_ITXT 812 -#define MNG_FN_PUTCHUNK_BKGD 813 -#define MNG_FN_PUTCHUNK_PHYS 814 -#define MNG_FN_PUTCHUNK_SBIT 815 -#define MNG_FN_PUTCHUNK_SPLT 816 -#define MNG_FN_PUTCHUNK_HIST 817 -#define MNG_FN_PUTCHUNK_TIME 818 -#define MNG_FN_PUTCHUNK_MHDR 819 -#define MNG_FN_PUTCHUNK_MEND 820 -#define MNG_FN_PUTCHUNK_LOOP 821 -#define MNG_FN_PUTCHUNK_ENDL 822 -#define MNG_FN_PUTCHUNK_DEFI 823 -#define MNG_FN_PUTCHUNK_BASI 824 -#define MNG_FN_PUTCHUNK_CLON 825 -#define MNG_FN_PUTCHUNK_PAST 826 -#define MNG_FN_PUTCHUNK_DISC 827 -#define MNG_FN_PUTCHUNK_BACK 828 -#define MNG_FN_PUTCHUNK_FRAM 829 -#define MNG_FN_PUTCHUNK_MOVE 830 -#define MNG_FN_PUTCHUNK_CLIP 831 -#define MNG_FN_PUTCHUNK_SHOW 832 -#define MNG_FN_PUTCHUNK_TERM 833 -#define MNG_FN_PUTCHUNK_SAVE 834 -#define MNG_FN_PUTCHUNK_SEEK 835 -#define MNG_FN_PUTCHUNK_EXPI 836 -#define MNG_FN_PUTCHUNK_FPRI 837 -#define MNG_FN_PUTCHUNK_NEED 838 -#define MNG_FN_PUTCHUNK_PHYG 839 -#define MNG_FN_PUTCHUNK_JHDR 840 -#define MNG_FN_PUTCHUNK_JDAT 841 -#define MNG_FN_PUTCHUNK_JSEP 842 -#define MNG_FN_PUTCHUNK_DHDR 843 -#define MNG_FN_PUTCHUNK_PROM 844 -#define MNG_FN_PUTCHUNK_IPNG 845 -#define MNG_FN_PUTCHUNK_PPLT 846 -#define MNG_FN_PUTCHUNK_IJNG 847 -#define MNG_FN_PUTCHUNK_DROP 848 -#define MNG_FN_PUTCHUNK_DBYK 849 -#define MNG_FN_PUTCHUNK_ORDR 850 -#define MNG_FN_PUTCHUNK_UNKNOWN 851 -#define MNG_FN_PUTCHUNK_MAGN 852 -#define MNG_FN_PUTCHUNK_JDAA 853 -#define MNG_FN_PUTCHUNK_EVNT 854 -#define MNG_FN_PUTCHUNK_MPNG 855 - -#define MNG_FN_PUTCHUNK_PAST_SRC 881 -#define MNG_FN_PUTCHUNK_SAVE_ENTRY 882 -#define MNG_FN_PUTCHUNK_PPLT_ENTRY 883 -#define MNG_FN_PUTCHUNK_ORDR_ENTRY 884 -#define MNG_FN_PUTCHUNK_EVNT_ENTRY 885 -#define MNG_FN_PUTCHUNK_MPNG_FRAME 886 - -/* ************************************************************************** */ - -#define MNG_FN_GETIMGDATA_SEQ 901 -#define MNG_FN_GETIMGDATA_CHUNKSEQ 902 -#define MNG_FN_GETIMGDATA_CHUNK 903 - -#define MNG_FN_PUTIMGDATA_IHDR 951 -#define MNG_FN_PUTIMGDATA_JHDR 952 -#define MNG_FN_PUTIMGDATA_BASI 953 -#define MNG_FN_PUTIMGDATA_DHDR 954 - -#define MNG_FN_UPDATEMNGHEADER 981 -#define MNG_FN_UPDATEMNGSIMPLICITY 982 - -/* ************************************************************************** */ - -#define MNG_FN_PROCESS_RAW_CHUNK 1001 -#define MNG_FN_READ_GRAPHIC 1002 -#define MNG_FN_DROP_CHUNKS 1003 -#define MNG_FN_PROCESS_ERROR 1004 -#define MNG_FN_CLEAR_CMS 1005 -#define MNG_FN_DROP_OBJECTS 1006 -#define MNG_FN_READ_CHUNK 1007 -#define MNG_FN_LOAD_BKGDLAYER 1008 -#define MNG_FN_NEXT_FRAME 1009 -#define MNG_FN_NEXT_LAYER 1010 -#define MNG_FN_INTERFRAME_DELAY 1011 -#define MNG_FN_DISPLAY_IMAGE 1012 -#define MNG_FN_DROP_IMGOBJECTS 1013 -#define MNG_FN_DROP_ANIOBJECTS 1014 -#define MNG_FN_INFLATE_BUFFER 1015 -#define MNG_FN_DEFLATE_BUFFER 1016 -#define MNG_FN_WRITE_RAW_CHUNK 1017 -#define MNG_FN_WRITE_GRAPHIC 1018 -#define MNG_FN_SAVE_STATE 1019 -#define MNG_FN_RESTORE_STATE 1020 -#define MNG_FN_DROP_SAVEDATA 1021 -#define MNG_FN_EXECUTE_DELTA_IMAGE 1022 -#define MNG_FN_PROCESS_DISPLAY 1023 -#define MNG_FN_CLEAR_CANVAS 1024 -#define MNG_FN_READ_DATABUFFER 1025 -#define MNG_FN_STORE_ERROR 1026 -#define MNG_FN_DROP_INVALID_OBJECTS 1027 -#define MNG_FN_RELEASE_PUSHDATA 1028 -#define MNG_FN_READ_DATA 1029 -#define MNG_FN_READ_CHUNK_CRC 1030 -#define MNG_FN_RELEASE_PUSHCHUNK 1031 - -/* ************************************************************************** */ - -#define MNG_FN_DISPLAY_RGB8 1101 -#define MNG_FN_DISPLAY_RGBA8 1102 -#define MNG_FN_DISPLAY_ARGB8 1103 -#define MNG_FN_DISPLAY_BGR8 1104 -#define MNG_FN_DISPLAY_BGRA8 1105 -#define MNG_FN_DISPLAY_ABGR8 1106 -#define MNG_FN_DISPLAY_RGB16 1107 -#define MNG_FN_DISPLAY_RGBA16 1108 -#define MNG_FN_DISPLAY_ARGB16 1109 -#define MNG_FN_DISPLAY_BGR16 1110 -#define MNG_FN_DISPLAY_BGRA16 1111 -#define MNG_FN_DISPLAY_ABGR16 1112 -#define MNG_FN_DISPLAY_INDEX8 1113 -#define MNG_FN_DISPLAY_INDEXA8 1114 -#define MNG_FN_DISPLAY_AINDEX8 1115 -#define MNG_FN_DISPLAY_GRAY8 1116 -#define MNG_FN_DISPLAY_GRAY16 1117 -#define MNG_FN_DISPLAY_GRAYA8 1118 -#define MNG_FN_DISPLAY_GRAYA16 1119 -#define MNG_FN_DISPLAY_AGRAY8 1120 -#define MNG_FN_DISPLAY_AGRAY16 1121 -#define MNG_FN_DISPLAY_DX15 1122 -#define MNG_FN_DISPLAY_DX16 1123 -#define MNG_FN_DISPLAY_RGB8_A8 1124 -#define MNG_FN_DISPLAY_BGRA8PM 1125 -#define MNG_FN_DISPLAY_BGRX8 1126 -#define MNG_FN_DISPLAY_RGB565 1127 -#define MNG_FN_DISPLAY_RGBA565 1128 -#define MNG_FN_DISPLAY_BGR565 1129 -#define MNG_FN_DISPLAY_BGRA565 1130 -#define MNG_FN_DISPLAY_RGBA8_PM 1131 -#define MNG_FN_DISPLAY_ARGB8_PM 1132 -#define MNG_FN_DISPLAY_ABGR8_PM 1133 -#define MNG_FN_DISPLAY_BGR565_A8 1134 -#define MNG_FN_DISPLAY_RGB555 1135 -#define MNG_FN_DISPLAY_BGR555 1136 - -/* ************************************************************************** */ - -#define MNG_FN_INIT_FULL_CMS 1201 -#define MNG_FN_CORRECT_FULL_CMS 1202 -#define MNG_FN_INIT_GAMMA_ONLY 1204 -#define MNG_FN_CORRECT_GAMMA_ONLY 1205 -#define MNG_FN_CORRECT_APP_CMS 1206 -#define MNG_FN_INIT_FULL_CMS_OBJ 1207 -#define MNG_FN_INIT_GAMMA_ONLY_OBJ 1208 -#define MNG_FN_INIT_APP_CMS 1209 -#define MNG_FN_INIT_APP_CMS_OBJ 1210 - -/* ************************************************************************** */ - -#define MNG_FN_PROCESS_G1 1301 -#define MNG_FN_PROCESS_G2 1302 -#define MNG_FN_PROCESS_G4 1303 -#define MNG_FN_PROCESS_G8 1304 -#define MNG_FN_PROCESS_G16 1305 -#define MNG_FN_PROCESS_RGB8 1306 -#define MNG_FN_PROCESS_RGB16 1307 -#define MNG_FN_PROCESS_IDX1 1308 -#define MNG_FN_PROCESS_IDX2 1309 -#define MNG_FN_PROCESS_IDX4 1310 -#define MNG_FN_PROCESS_IDX8 1311 -#define MNG_FN_PROCESS_GA8 1312 -#define MNG_FN_PROCESS_GA16 1313 -#define MNG_FN_PROCESS_RGBA8 1314 -#define MNG_FN_PROCESS_RGBA16 1315 - -/* ************************************************************************** */ - -#define MNG_FN_INIT_G1_NI 1401 -#define MNG_FN_INIT_G1_I 1402 -#define MNG_FN_INIT_G2_NI 1403 -#define MNG_FN_INIT_G2_I 1404 -#define MNG_FN_INIT_G4_NI 1405 -#define MNG_FN_INIT_G4_I 1406 -#define MNG_FN_INIT_G8_NI 1407 -#define MNG_FN_INIT_G8_I 1408 -#define MNG_FN_INIT_G16_NI 1409 -#define MNG_FN_INIT_G16_I 1410 -#define MNG_FN_INIT_RGB8_NI 1411 -#define MNG_FN_INIT_RGB8_I 1412 -#define MNG_FN_INIT_RGB16_NI 1413 -#define MNG_FN_INIT_RGB16_I 1414 -#define MNG_FN_INIT_IDX1_NI 1415 -#define MNG_FN_INIT_IDX1_I 1416 -#define MNG_FN_INIT_IDX2_NI 1417 -#define MNG_FN_INIT_IDX2_I 1418 -#define MNG_FN_INIT_IDX4_NI 1419 -#define MNG_FN_INIT_IDX4_I 1420 -#define MNG_FN_INIT_IDX8_NI 1421 -#define MNG_FN_INIT_IDX8_I 1422 -#define MNG_FN_INIT_GA8_NI 1423 -#define MNG_FN_INIT_GA8_I 1424 -#define MNG_FN_INIT_GA16_NI 1425 -#define MNG_FN_INIT_GA16_I 1426 -#define MNG_FN_INIT_RGBA8_NI 1427 -#define MNG_FN_INIT_RGBA8_I 1428 -#define MNG_FN_INIT_RGBA16_NI 1429 -#define MNG_FN_INIT_RGBA16_I 1430 - -#define MNG_FN_INIT_ROWPROC 1497 -#define MNG_FN_NEXT_ROW 1498 -#define MNG_FN_CLEANUP_ROWPROC 1499 - -/* ************************************************************************** */ - -#define MNG_FN_FILTER_A_ROW 1501 -#define MNG_FN_FILTER_SUB 1502 -#define MNG_FN_FILTER_UP 1503 -#define MNG_FN_FILTER_AVERAGE 1504 -#define MNG_FN_FILTER_PAETH 1505 - -#define MNG_FN_INIT_ROWDIFFERING 1551 -#define MNG_FN_DIFFER_G1 1552 -#define MNG_FN_DIFFER_G2 1553 -#define MNG_FN_DIFFER_G4 1554 -#define MNG_FN_DIFFER_G8 1555 -#define MNG_FN_DIFFER_G16 1556 -#define MNG_FN_DIFFER_RGB8 1557 -#define MNG_FN_DIFFER_RGB16 1558 -#define MNG_FN_DIFFER_IDX1 1559 -#define MNG_FN_DIFFER_IDX2 1560 -#define MNG_FN_DIFFER_IDX4 1561 -#define MNG_FN_DIFFER_IDX8 1562 -#define MNG_FN_DIFFER_GA8 1563 -#define MNG_FN_DIFFER_GA16 1564 -#define MNG_FN_DIFFER_RGBA8 1565 -#define MNG_FN_DIFFER_RGBA16 1566 - -/* ************************************************************************** */ - -#define MNG_FN_CREATE_IMGDATAOBJECT 1601 -#define MNG_FN_FREE_IMGDATAOBJECT 1602 -#define MNG_FN_CLONE_IMGDATAOBJECT 1603 -#define MNG_FN_CREATE_IMGOBJECT 1604 -#define MNG_FN_FREE_IMGOBJECT 1605 -#define MNG_FN_FIND_IMGOBJECT 1606 -#define MNG_FN_CLONE_IMGOBJECT 1607 -#define MNG_FN_RESET_OBJECTDETAILS 1608 -#define MNG_FN_RENUM_IMGOBJECT 1609 -#define MNG_FN_PROMOTE_IMGOBJECT 1610 -#define MNG_FN_MAGNIFY_IMGOBJECT 1611 -#define MNG_FN_COLORCORRECT_OBJECT 1612 - -/* ************************************************************************** */ - -#define MNG_FN_STORE_G1 1701 -#define MNG_FN_STORE_G2 1702 -#define MNG_FN_STORE_G4 1703 -#define MNG_FN_STORE_G8 1704 -#define MNG_FN_STORE_G16 1705 -#define MNG_FN_STORE_RGB8 1706 -#define MNG_FN_STORE_RGB16 1707 -#define MNG_FN_STORE_IDX1 1708 -#define MNG_FN_STORE_IDX2 1709 -#define MNG_FN_STORE_IDX4 1710 -#define MNG_FN_STORE_IDX8 1711 -#define MNG_FN_STORE_GA8 1712 -#define MNG_FN_STORE_GA16 1713 -#define MNG_FN_STORE_RGBA8 1714 -#define MNG_FN_STORE_RGBA16 1715 - -#define MNG_FN_RETRIEVE_G8 1751 -#define MNG_FN_RETRIEVE_G16 1752 -#define MNG_FN_RETRIEVE_RGB8 1753 -#define MNG_FN_RETRIEVE_RGB16 1754 -#define MNG_FN_RETRIEVE_IDX8 1755 -#define MNG_FN_RETRIEVE_GA8 1756 -#define MNG_FN_RETRIEVE_GA16 1757 -#define MNG_FN_RETRIEVE_RGBA8 1758 -#define MNG_FN_RETRIEVE_RGBA16 1759 - -#define MNG_FN_DELTA_G1 1771 -#define MNG_FN_DELTA_G2 1772 -#define MNG_FN_DELTA_G4 1773 -#define MNG_FN_DELTA_G8 1774 -#define MNG_FN_DELTA_G16 1775 -#define MNG_FN_DELTA_RGB8 1776 -#define MNG_FN_DELTA_RGB16 1777 -#define MNG_FN_DELTA_IDX1 1778 -#define MNG_FN_DELTA_IDX2 1779 -#define MNG_FN_DELTA_IDX4 1780 -#define MNG_FN_DELTA_IDX8 1781 -#define MNG_FN_DELTA_GA8 1782 -#define MNG_FN_DELTA_GA16 1783 -#define MNG_FN_DELTA_RGBA8 1784 -#define MNG_FN_DELTA_RGBA16 1785 - -/* ************************************************************************** */ - -#define MNG_FN_CREATE_ANI_LOOP 1801 -#define MNG_FN_CREATE_ANI_ENDL 1802 -#define MNG_FN_CREATE_ANI_DEFI 1803 -#define MNG_FN_CREATE_ANI_BASI 1804 -#define MNG_FN_CREATE_ANI_CLON 1805 -#define MNG_FN_CREATE_ANI_PAST 1806 -#define MNG_FN_CREATE_ANI_DISC 1807 -#define MNG_FN_CREATE_ANI_BACK 1808 -#define MNG_FN_CREATE_ANI_FRAM 1809 -#define MNG_FN_CREATE_ANI_MOVE 1810 -#define MNG_FN_CREATE_ANI_CLIP 1811 -#define MNG_FN_CREATE_ANI_SHOW 1812 -#define MNG_FN_CREATE_ANI_TERM 1813 -#define MNG_FN_CREATE_ANI_SAVE 1814 -#define MNG_FN_CREATE_ANI_SEEK 1815 -#define MNG_FN_CREATE_ANI_GAMA 1816 -#define MNG_FN_CREATE_ANI_CHRM 1817 -#define MNG_FN_CREATE_ANI_SRGB 1818 -#define MNG_FN_CREATE_ANI_ICCP 1819 -#define MNG_FN_CREATE_ANI_PLTE 1820 -#define MNG_FN_CREATE_ANI_TRNS 1821 -#define MNG_FN_CREATE_ANI_BKGD 1822 -#define MNG_FN_CREATE_ANI_DHDR 1823 -#define MNG_FN_CREATE_ANI_PROM 1824 -#define MNG_FN_CREATE_ANI_IPNG 1825 -#define MNG_FN_CREATE_ANI_IJNG 1826 -#define MNG_FN_CREATE_ANI_PPLT 1827 -#define MNG_FN_CREATE_ANI_MAGN 1828 - -#define MNG_FN_CREATE_ANI_IMAGE 1891 -#define MNG_FN_CREATE_EVENT 1892 - -/* ************************************************************************** */ - -#define MNG_FN_FREE_ANI_LOOP 1901 -#define MNG_FN_FREE_ANI_ENDL 1902 -#define MNG_FN_FREE_ANI_DEFI 1903 -#define MNG_FN_FREE_ANI_BASI 1904 -#define MNG_FN_FREE_ANI_CLON 1905 -#define MNG_FN_FREE_ANI_PAST 1906 -#define MNG_FN_FREE_ANI_DISC 1907 -#define MNG_FN_FREE_ANI_BACK 1908 -#define MNG_FN_FREE_ANI_FRAM 1909 -#define MNG_FN_FREE_ANI_MOVE 1910 -#define MNG_FN_FREE_ANI_CLIP 1911 -#define MNG_FN_FREE_ANI_SHOW 1912 -#define MNG_FN_FREE_ANI_TERM 1913 -#define MNG_FN_FREE_ANI_SAVE 1914 -#define MNG_FN_FREE_ANI_SEEK 1915 -#define MNG_FN_FREE_ANI_GAMA 1916 -#define MNG_FN_FREE_ANI_CHRM 1917 -#define MNG_FN_FREE_ANI_SRGB 1918 -#define MNG_FN_FREE_ANI_ICCP 1919 -#define MNG_FN_FREE_ANI_PLTE 1920 -#define MNG_FN_FREE_ANI_TRNS 1921 -#define MNG_FN_FREE_ANI_BKGD 1922 -#define MNG_FN_FREE_ANI_DHDR 1923 -#define MNG_FN_FREE_ANI_PROM 1924 -#define MNG_FN_FREE_ANI_IPNG 1925 -#define MNG_FN_FREE_ANI_IJNG 1926 -#define MNG_FN_FREE_ANI_PPLT 1927 -#define MNG_FN_FREE_ANI_MAGN 1928 - -#define MNG_FN_FREE_ANI_IMAGE 1991 -#define MNG_FN_FREE_EVENT 1992 - -/* ************************************************************************** */ - -#define MNG_FN_PROCESS_ANI_LOOP 2001 -#define MNG_FN_PROCESS_ANI_ENDL 2002 -#define MNG_FN_PROCESS_ANI_DEFI 2003 -#define MNG_FN_PROCESS_ANI_BASI 2004 -#define MNG_FN_PROCESS_ANI_CLON 2005 -#define MNG_FN_PROCESS_ANI_PAST 2006 -#define MNG_FN_PROCESS_ANI_DISC 2007 -#define MNG_FN_PROCESS_ANI_BACK 2008 -#define MNG_FN_PROCESS_ANI_FRAM 2009 -#define MNG_FN_PROCESS_ANI_MOVE 2010 -#define MNG_FN_PROCESS_ANI_CLIP 2011 -#define MNG_FN_PROCESS_ANI_SHOW 2012 -#define MNG_FN_PROCESS_ANI_TERM 2013 -#define MNG_FN_PROCESS_ANI_SAVE 2014 -#define MNG_FN_PROCESS_ANI_SEEK 2015 -#define MNG_FN_PROCESS_ANI_GAMA 2016 -#define MNG_FN_PROCESS_ANI_CHRM 2017 -#define MNG_FN_PROCESS_ANI_SRGB 2018 -#define MNG_FN_PROCESS_ANI_ICCP 2019 -#define MNG_FN_PROCESS_ANI_PLTE 2020 -#define MNG_FN_PROCESS_ANI_TRNS 2021 -#define MNG_FN_PROCESS_ANI_BKGD 2022 -#define MNG_FN_PROCESS_ANI_DHDR 2023 -#define MNG_FN_PROCESS_ANI_PROM 2024 -#define MNG_FN_PROCESS_ANI_IPNG 2025 -#define MNG_FN_PROCESS_ANI_IJNG 2026 -#define MNG_FN_PROCESS_ANI_PPLT 2027 -#define MNG_FN_PROCESS_ANI_MAGN 2028 - -#define MNG_FN_PROCESS_ANI_IMAGE 2091 -#define MNG_FN_PROCESS_EVENT 2092 - -/* ************************************************************************** */ - -#define MNG_FN_RESTORE_BACKIMAGE 2101 -#define MNG_FN_RESTORE_BACKCOLOR 2102 -#define MNG_FN_RESTORE_BGCOLOR 2103 -#define MNG_FN_RESTORE_RGB8 2104 -#define MNG_FN_RESTORE_BGR8 2105 -#define MNG_FN_RESTORE_BKGD 2106 -#define MNG_FN_RESTORE_BGRX8 2107 -#define MNG_FN_RESTORE_RGB565 2108 -#define MNG_FN_RESTORE_BGR565 2109 - -/* ************************************************************************** */ - -#define MNG_FN_INIT_IHDR 2201 -#define MNG_FN_INIT_PLTE 2202 -#define MNG_FN_INIT_IDAT 2203 -#define MNG_FN_INIT_IEND 2204 -#define MNG_FN_INIT_TRNS 2205 -#define MNG_FN_INIT_GAMA 2206 -#define MNG_FN_INIT_CHRM 2207 -#define MNG_FN_INIT_SRGB 2208 -#define MNG_FN_INIT_ICCP 2209 -#define MNG_FN_INIT_TEXT 2210 -#define MNG_FN_INIT_ZTXT 2211 -#define MNG_FN_INIT_ITXT 2212 -#define MNG_FN_INIT_BKGD 2213 -#define MNG_FN_INIT_PHYS 2214 -#define MNG_FN_INIT_SBIT 2215 -#define MNG_FN_INIT_SPLT 2216 -#define MNG_FN_INIT_HIST 2217 -#define MNG_FN_INIT_TIME 2218 -#define MNG_FN_INIT_MHDR 2219 -#define MNG_FN_INIT_MEND 2220 -#define MNG_FN_INIT_LOOP 2221 -#define MNG_FN_INIT_ENDL 2222 -#define MNG_FN_INIT_DEFI 2223 -#define MNG_FN_INIT_BASI 2224 -#define MNG_FN_INIT_CLON 2225 -#define MNG_FN_INIT_PAST 2226 -#define MNG_FN_INIT_DISC 2227 -#define MNG_FN_INIT_BACK 2228 -#define MNG_FN_INIT_FRAM 2229 -#define MNG_FN_INIT_MOVE 2230 -#define MNG_FN_INIT_CLIP 2231 -#define MNG_FN_INIT_SHOW 2232 -#define MNG_FN_INIT_TERM 2233 -#define MNG_FN_INIT_SAVE 2234 -#define MNG_FN_INIT_SEEK 2235 -#define MNG_FN_INIT_EXPI 2236 -#define MNG_FN_INIT_FPRI 2237 -#define MNG_FN_INIT_NEED 2238 -#define MNG_FN_INIT_PHYG 2239 -#define MNG_FN_INIT_JHDR 2240 -#define MNG_FN_INIT_JDAT 2241 -#define MNG_FN_INIT_JSEP 2242 -#define MNG_FN_INIT_DHDR 2243 -#define MNG_FN_INIT_PROM 2244 -#define MNG_FN_INIT_IPNG 2245 -#define MNG_FN_INIT_PPLT 2246 -#define MNG_FN_INIT_IJNG 2247 -#define MNG_FN_INIT_DROP 2248 -#define MNG_FN_INIT_DBYK 2249 -#define MNG_FN_INIT_ORDR 2250 -#define MNG_FN_INIT_UNKNOWN 2251 -#define MNG_FN_INIT_MAGN 2252 -#define MNG_FN_INIT_JDAA 2253 -#define MNG_FN_INIT_EVNT 2254 -#define MNG_FN_INIT_MPNG 2255 - -/* ************************************************************************** */ - -#define MNG_FN_ASSIGN_IHDR 2301 -#define MNG_FN_ASSIGN_PLTE 2302 -#define MNG_FN_ASSIGN_IDAT 2303 -#define MNG_FN_ASSIGN_IEND 2304 -#define MNG_FN_ASSIGN_TRNS 2305 -#define MNG_FN_ASSIGN_GAMA 2306 -#define MNG_FN_ASSIGN_CHRM 2307 -#define MNG_FN_ASSIGN_SRGB 2308 -#define MNG_FN_ASSIGN_ICCP 2309 -#define MNG_FN_ASSIGN_TEXT 2310 -#define MNG_FN_ASSIGN_ZTXT 2311 -#define MNG_FN_ASSIGN_ITXT 2312 -#define MNG_FN_ASSIGN_BKGD 2313 -#define MNG_FN_ASSIGN_PHYS 2314 -#define MNG_FN_ASSIGN_SBIT 2315 -#define MNG_FN_ASSIGN_SPLT 2316 -#define MNG_FN_ASSIGN_HIST 2317 -#define MNG_FN_ASSIGN_TIME 2318 -#define MNG_FN_ASSIGN_MHDR 2319 -#define MNG_FN_ASSIGN_MEND 2320 -#define MNG_FN_ASSIGN_LOOP 2321 -#define MNG_FN_ASSIGN_ENDL 2322 -#define MNG_FN_ASSIGN_DEFI 2323 -#define MNG_FN_ASSIGN_BASI 2324 -#define MNG_FN_ASSIGN_CLON 2325 -#define MNG_FN_ASSIGN_PAST 2326 -#define MNG_FN_ASSIGN_DISC 2327 -#define MNG_FN_ASSIGN_BACK 2328 -#define MNG_FN_ASSIGN_FRAM 2329 -#define MNG_FN_ASSIGN_MOVE 2330 -#define MNG_FN_ASSIGN_CLIP 2331 -#define MNG_FN_ASSIGN_SHOW 2332 -#define MNG_FN_ASSIGN_TERM 2333 -#define MNG_FN_ASSIGN_SAVE 2334 -#define MNG_FN_ASSIGN_SEEK 2335 -#define MNG_FN_ASSIGN_EXPI 2336 -#define MNG_FN_ASSIGN_FPRI 2337 -#define MNG_FN_ASSIGN_NEED 2338 -#define MNG_FN_ASSIGN_PHYG 2339 -#define MNG_FN_ASSIGN_JHDR 2340 -#define MNG_FN_ASSIGN_JDAT 2341 -#define MNG_FN_ASSIGN_JSEP 2342 -#define MNG_FN_ASSIGN_DHDR 2343 -#define MNG_FN_ASSIGN_PROM 2344 -#define MNG_FN_ASSIGN_IPNG 2345 -#define MNG_FN_ASSIGN_PPLT 2346 -#define MNG_FN_ASSIGN_IJNG 2347 -#define MNG_FN_ASSIGN_DROP 2348 -#define MNG_FN_ASSIGN_DBYK 2349 -#define MNG_FN_ASSIGN_ORDR 2350 -#define MNG_FN_ASSIGN_UNKNOWN 2351 -#define MNG_FN_ASSIGN_MAGN 2352 -#define MNG_FN_ASSIGN_JDAA 2353 -#define MNG_FN_ASSIGN_EVNT 2354 -#define MNG_FN_ASSIGN_MPNG 2355 - -/* ************************************************************************** */ - -#define MNG_FN_FREE_IHDR 2401 -#define MNG_FN_FREE_PLTE 2402 -#define MNG_FN_FREE_IDAT 2403 -#define MNG_FN_FREE_IEND 2404 -#define MNG_FN_FREE_TRNS 2405 -#define MNG_FN_FREE_GAMA 2406 -#define MNG_FN_FREE_CHRM 2407 -#define MNG_FN_FREE_SRGB 2408 -#define MNG_FN_FREE_ICCP 2409 -#define MNG_FN_FREE_TEXT 2410 -#define MNG_FN_FREE_ZTXT 2411 -#define MNG_FN_FREE_ITXT 2412 -#define MNG_FN_FREE_BKGD 2413 -#define MNG_FN_FREE_PHYS 2414 -#define MNG_FN_FREE_SBIT 2415 -#define MNG_FN_FREE_SPLT 2416 -#define MNG_FN_FREE_HIST 2417 -#define MNG_FN_FREE_TIME 2418 -#define MNG_FN_FREE_MHDR 2419 -#define MNG_FN_FREE_MEND 2420 -#define MNG_FN_FREE_LOOP 2421 -#define MNG_FN_FREE_ENDL 2422 -#define MNG_FN_FREE_DEFI 2423 -#define MNG_FN_FREE_BASI 2424 -#define MNG_FN_FREE_CLON 2425 -#define MNG_FN_FREE_PAST 2426 -#define MNG_FN_FREE_DISC 2427 -#define MNG_FN_FREE_BACK 2428 -#define MNG_FN_FREE_FRAM 2429 -#define MNG_FN_FREE_MOVE 2430 -#define MNG_FN_FREE_CLIP 2431 -#define MNG_FN_FREE_SHOW 2432 -#define MNG_FN_FREE_TERM 2433 -#define MNG_FN_FREE_SAVE 2434 -#define MNG_FN_FREE_SEEK 2435 -#define MNG_FN_FREE_EXPI 2436 -#define MNG_FN_FREE_FPRI 2437 -#define MNG_FN_FREE_NEED 2438 -#define MNG_FN_FREE_PHYG 2439 -#define MNG_FN_FREE_JHDR 2440 -#define MNG_FN_FREE_JDAT 2441 -#define MNG_FN_FREE_JSEP 2442 -#define MNG_FN_FREE_DHDR 2443 -#define MNG_FN_FREE_PROM 2444 -#define MNG_FN_FREE_IPNG 2445 -#define MNG_FN_FREE_PPLT 2446 -#define MNG_FN_FREE_IJNG 2447 -#define MNG_FN_FREE_DROP 2448 -#define MNG_FN_FREE_DBYK 2449 -#define MNG_FN_FREE_ORDR 2450 -#define MNG_FN_FREE_UNKNOWN 2451 -#define MNG_FN_FREE_MAGN 2452 -#define MNG_FN_FREE_JDAA 2453 -#define MNG_FN_FREE_EVNT 2454 -#define MNG_FN_FREE_MPNG 2455 - -/* ************************************************************************** */ - -#define MNG_FN_READ_IHDR 2601 -#define MNG_FN_READ_PLTE 2602 -#define MNG_FN_READ_IDAT 2603 -#define MNG_FN_READ_IEND 2604 -#define MNG_FN_READ_TRNS 2605 -#define MNG_FN_READ_GAMA 2606 -#define MNG_FN_READ_CHRM 2607 -#define MNG_FN_READ_SRGB 2608 -#define MNG_FN_READ_ICCP 2609 -#define MNG_FN_READ_TEXT 2610 -#define MNG_FN_READ_ZTXT 2611 -#define MNG_FN_READ_ITXT 2612 -#define MNG_FN_READ_BKGD 2613 -#define MNG_FN_READ_PHYS 2614 -#define MNG_FN_READ_SBIT 2615 -#define MNG_FN_READ_SPLT 2616 -#define MNG_FN_READ_HIST 2617 -#define MNG_FN_READ_TIME 2618 -#define MNG_FN_READ_MHDR 2619 -#define MNG_FN_READ_MEND 2620 -#define MNG_FN_READ_LOOP 2621 -#define MNG_FN_READ_ENDL 2622 -#define MNG_FN_READ_DEFI 2623 -#define MNG_FN_READ_BASI 2624 -#define MNG_FN_READ_CLON 2625 -#define MNG_FN_READ_PAST 2626 -#define MNG_FN_READ_DISC 2627 -#define MNG_FN_READ_BACK 2628 -#define MNG_FN_READ_FRAM 2629 -#define MNG_FN_READ_MOVE 2630 -#define MNG_FN_READ_CLIP 2631 -#define MNG_FN_READ_SHOW 2632 -#define MNG_FN_READ_TERM 2633 -#define MNG_FN_READ_SAVE 2634 -#define MNG_FN_READ_SEEK 2635 -#define MNG_FN_READ_EXPI 2636 -#define MNG_FN_READ_FPRI 2637 -#define MNG_FN_READ_NEED 2638 -#define MNG_FN_READ_PHYG 2639 -#define MNG_FN_READ_JHDR 2640 -#define MNG_FN_READ_JDAT 2641 -#define MNG_FN_READ_JSEP 2642 -#define MNG_FN_READ_DHDR 2643 -#define MNG_FN_READ_PROM 2644 -#define MNG_FN_READ_IPNG 2645 -#define MNG_FN_READ_PPLT 2646 -#define MNG_FN_READ_IJNG 2647 -#define MNG_FN_READ_DROP 2648 -#define MNG_FN_READ_DBYK 2649 -#define MNG_FN_READ_ORDR 2650 -#define MNG_FN_READ_UNKNOWN 2651 -#define MNG_FN_READ_MAGN 2652 -#define MNG_FN_READ_JDAA 2653 -#define MNG_FN_READ_EVNT 2654 -#define MNG_FN_READ_MPNG 2655 - -/* ************************************************************************** */ - -#define MNG_FN_WRITE_IHDR 2801 -#define MNG_FN_WRITE_PLTE 2802 -#define MNG_FN_WRITE_IDAT 2803 -#define MNG_FN_WRITE_IEND 2804 -#define MNG_FN_WRITE_TRNS 2805 -#define MNG_FN_WRITE_GAMA 2806 -#define MNG_FN_WRITE_CHRM 2807 -#define MNG_FN_WRITE_SRGB 2808 -#define MNG_FN_WRITE_ICCP 2809 -#define MNG_FN_WRITE_TEXT 2810 -#define MNG_FN_WRITE_ZTXT 2811 -#define MNG_FN_WRITE_ITXT 2812 -#define MNG_FN_WRITE_BKGD 2813 -#define MNG_FN_WRITE_PHYS 2814 -#define MNG_FN_WRITE_SBIT 2815 -#define MNG_FN_WRITE_SPLT 2816 -#define MNG_FN_WRITE_HIST 2817 -#define MNG_FN_WRITE_TIME 2818 -#define MNG_FN_WRITE_MHDR 2819 -#define MNG_FN_WRITE_MEND 2820 -#define MNG_FN_WRITE_LOOP 2821 -#define MNG_FN_WRITE_ENDL 2822 -#define MNG_FN_WRITE_DEFI 2823 -#define MNG_FN_WRITE_BASI 2824 -#define MNG_FN_WRITE_CLON 2825 -#define MNG_FN_WRITE_PAST 2826 -#define MNG_FN_WRITE_DISC 2827 -#define MNG_FN_WRITE_BACK 2828 -#define MNG_FN_WRITE_FRAM 2829 -#define MNG_FN_WRITE_MOVE 2830 -#define MNG_FN_WRITE_CLIP 2831 -#define MNG_FN_WRITE_SHOW 2832 -#define MNG_FN_WRITE_TERM 2833 -#define MNG_FN_WRITE_SAVE 2834 -#define MNG_FN_WRITE_SEEK 2835 -#define MNG_FN_WRITE_EXPI 2836 -#define MNG_FN_WRITE_FPRI 2837 -#define MNG_FN_WRITE_NEED 2838 -#define MNG_FN_WRITE_PHYG 2839 -#define MNG_FN_WRITE_JHDR 2840 -#define MNG_FN_WRITE_JDAT 2841 -#define MNG_FN_WRITE_JSEP 2842 -#define MNG_FN_WRITE_DHDR 2843 -#define MNG_FN_WRITE_PROM 2844 -#define MNG_FN_WRITE_IPNG 2845 -#define MNG_FN_WRITE_PPLT 2846 -#define MNG_FN_WRITE_IJNG 2847 -#define MNG_FN_WRITE_DROP 2848 -#define MNG_FN_WRITE_DBYK 2849 -#define MNG_FN_WRITE_ORDR 2850 -#define MNG_FN_WRITE_UNKNOWN 2851 -#define MNG_FN_WRITE_MAGN 2852 -#define MNG_FN_WRITE_JDAA 2853 -#define MNG_FN_WRITE_EVNT 2854 -#define MNG_FN_WRITE_MPNG 2855 - -/* ************************************************************************** */ - -#define MNG_FN_ZLIB_INITIALIZE 3001 -#define MNG_FN_ZLIB_CLEANUP 3002 -#define MNG_FN_ZLIB_INFLATEINIT 3003 -#define MNG_FN_ZLIB_INFLATEROWS 3004 -#define MNG_FN_ZLIB_INFLATEDATA 3005 -#define MNG_FN_ZLIB_INFLATEFREE 3006 -#define MNG_FN_ZLIB_DEFLATEINIT 3007 -#define MNG_FN_ZLIB_DEFLATEROWS 3008 -#define MNG_FN_ZLIB_DEFLATEDATA 3009 -#define MNG_FN_ZLIB_DEFLATEFREE 3010 - -/* ************************************************************************** */ - -#define MNG_FN_PROCESS_DISPLAY_IHDR 3201 -#define MNG_FN_PROCESS_DISPLAY_PLTE 3202 -#define MNG_FN_PROCESS_DISPLAY_IDAT 3203 -#define MNG_FN_PROCESS_DISPLAY_IEND 3204 -#define MNG_FN_PROCESS_DISPLAY_TRNS 3205 -#define MNG_FN_PROCESS_DISPLAY_GAMA 3206 -#define MNG_FN_PROCESS_DISPLAY_CHRM 3207 -#define MNG_FN_PROCESS_DISPLAY_SRGB 3208 -#define MNG_FN_PROCESS_DISPLAY_ICCP 3209 -#define MNG_FN_PROCESS_DISPLAY_BKGD 3210 -#define MNG_FN_PROCESS_DISPLAY_PHYS 3211 -#define MNG_FN_PROCESS_DISPLAY_SBIT 3212 -#define MNG_FN_PROCESS_DISPLAY_SPLT 3213 -#define MNG_FN_PROCESS_DISPLAY_HIST 3214 -#define MNG_FN_PROCESS_DISPLAY_MHDR 3215 -#define MNG_FN_PROCESS_DISPLAY_MEND 3216 -#define MNG_FN_PROCESS_DISPLAY_LOOP 3217 -#define MNG_FN_PROCESS_DISPLAY_ENDL 3218 -#define MNG_FN_PROCESS_DISPLAY_DEFI 3219 -#define MNG_FN_PROCESS_DISPLAY_BASI 3220 -#define MNG_FN_PROCESS_DISPLAY_CLON 3221 -#define MNG_FN_PROCESS_DISPLAY_PAST 3222 -#define MNG_FN_PROCESS_DISPLAY_DISC 3223 -#define MNG_FN_PROCESS_DISPLAY_BACK 3224 -#define MNG_FN_PROCESS_DISPLAY_FRAM 3225 -#define MNG_FN_PROCESS_DISPLAY_MOVE 3226 -#define MNG_FN_PROCESS_DISPLAY_CLIP 3227 -#define MNG_FN_PROCESS_DISPLAY_SHOW 3228 -#define MNG_FN_PROCESS_DISPLAY_TERM 3229 -#define MNG_FN_PROCESS_DISPLAY_SAVE 3230 -#define MNG_FN_PROCESS_DISPLAY_SEEK 3231 -#define MNG_FN_PROCESS_DISPLAY_EXPI 3232 -#define MNG_FN_PROCESS_DISPLAY_FPRI 3233 -#define MNG_FN_PROCESS_DISPLAY_NEED 3234 -#define MNG_FN_PROCESS_DISPLAY_PHYG 3235 -#define MNG_FN_PROCESS_DISPLAY_JHDR 3236 -#define MNG_FN_PROCESS_DISPLAY_JDAT 3237 -#define MNG_FN_PROCESS_DISPLAY_JSEP 3238 -#define MNG_FN_PROCESS_DISPLAY_DHDR 3239 -#define MNG_FN_PROCESS_DISPLAY_PROM 3240 -#define MNG_FN_PROCESS_DISPLAY_IPNG 3241 -#define MNG_FN_PROCESS_DISPLAY_PPLT 3242 -#define MNG_FN_PROCESS_DISPLAY_IJNG 3243 -#define MNG_FN_PROCESS_DISPLAY_DROP 3244 -#define MNG_FN_PROCESS_DISPLAY_DBYK 3245 -#define MNG_FN_PROCESS_DISPLAY_ORDR 3246 -#define MNG_FN_PROCESS_DISPLAY_MAGN 3247 -#define MNG_FN_PROCESS_DISPLAY_JDAA 3248 - -/* ************************************************************************** */ - -#define MNG_FN_JPEG_INITIALIZE 3401 -#define MNG_FN_JPEG_CLEANUP 3402 -#define MNG_FN_JPEG_DECOMPRESSINIT 3403 -#define MNG_FN_JPEG_DECOMPRESSDATA 3404 -#define MNG_FN_JPEG_DECOMPRESSFREE 3405 - -#define MNG_FN_STORE_JPEG_G8 3501 -#define MNG_FN_STORE_JPEG_RGB8 3502 -#define MNG_FN_STORE_JPEG_G12 3503 -#define MNG_FN_STORE_JPEG_RGB12 3504 -#define MNG_FN_STORE_JPEG_GA8 3505 -#define MNG_FN_STORE_JPEG_RGBA8 3506 -#define MNG_FN_STORE_JPEG_GA12 3507 -#define MNG_FN_STORE_JPEG_RGBA12 3508 -#define MNG_FN_STORE_JPEG_G8_ALPHA 3509 -#define MNG_FN_STORE_JPEG_RGB8_ALPHA 3510 - -#define MNG_FN_INIT_JPEG_A1_NI 3511 -#define MNG_FN_INIT_JPEG_A2_NI 3512 -#define MNG_FN_INIT_JPEG_A4_NI 3513 -#define MNG_FN_INIT_JPEG_A8_NI 3514 -#define MNG_FN_INIT_JPEG_A16_NI 3515 - -#define MNG_FN_STORE_JPEG_G8_A1 3521 -#define MNG_FN_STORE_JPEG_G8_A2 3522 -#define MNG_FN_STORE_JPEG_G8_A4 3523 -#define MNG_FN_STORE_JPEG_G8_A8 3524 -#define MNG_FN_STORE_JPEG_G8_A16 3525 - -#define MNG_FN_STORE_JPEG_RGB8_A1 3531 -#define MNG_FN_STORE_JPEG_RGB8_A2 3532 -#define MNG_FN_STORE_JPEG_RGB8_A4 3533 -#define MNG_FN_STORE_JPEG_RGB8_A8 3534 -#define MNG_FN_STORE_JPEG_RGB8_A16 3535 - -#define MNG_FN_STORE_JPEG_G12_A1 3541 -#define MNG_FN_STORE_JPEG_G12_A2 3542 -#define MNG_FN_STORE_JPEG_G12_A4 3543 -#define MNG_FN_STORE_JPEG_G12_A8 3544 -#define MNG_FN_STORE_JPEG_G12_A16 3545 - -#define MNG_FN_STORE_JPEG_RGB12_A1 3551 -#define MNG_FN_STORE_JPEG_RGB12_A2 3552 -#define MNG_FN_STORE_JPEG_RGB12_A4 3553 -#define MNG_FN_STORE_JPEG_RGB12_A8 3554 -#define MNG_FN_STORE_JPEG_RGB12_A16 3555 - -#define MNG_FN_NEXT_JPEG_ALPHAROW 3591 -#define MNG_FN_NEXT_JPEG_ROW 3592 -#define MNG_FN_DISPLAY_JPEG_ROWS 3593 - -/* ************************************************************************** */ - -#define MNG_FN_MAGNIFY_G8_X1 3701 -#define MNG_FN_MAGNIFY_G8_X2 3702 -#define MNG_FN_MAGNIFY_RGB8_X1 3703 -#define MNG_FN_MAGNIFY_RGB8_X2 3704 -#define MNG_FN_MAGNIFY_GA8_X1 3705 -#define MNG_FN_MAGNIFY_GA8_X2 3706 -#define MNG_FN_MAGNIFY_GA8_X3 3707 -#define MNG_FN_MAGNIFY_GA8_X4 3708 -#define MNG_FN_MAGNIFY_RGBA8_X1 3709 -#define MNG_FN_MAGNIFY_RGBA8_X2 3710 -#define MNG_FN_MAGNIFY_RGBA8_X3 3711 -#define MNG_FN_MAGNIFY_RGBA8_X4 3712 -#define MNG_FN_MAGNIFY_G8_X3 3713 -#define MNG_FN_MAGNIFY_RGB8_X3 3714 -#define MNG_FN_MAGNIFY_GA8_X5 3715 -#define MNG_FN_MAGNIFY_RGBA8_X5 3716 - -#define MNG_FN_MAGNIFY_G16_X1 3725 -#define MNG_FN_MAGNIFY_G16_X2 3726 -#define MNG_FN_MAGNIFY_RGB16_X1 3727 -#define MNG_FN_MAGNIFY_RGB16_X2 3728 -#define MNG_FN_MAGNIFY_GA16_X1 3729 -#define MNG_FN_MAGNIFY_GA16_X2 3730 -#define MNG_FN_MAGNIFY_GA16_X3 3731 -#define MNG_FN_MAGNIFY_GA16_X4 3732 -#define MNG_FN_MAGNIFY_RGBA16_X1 3733 -#define MNG_FN_MAGNIFY_RGBA16_X2 3734 -#define MNG_FN_MAGNIFY_RGBA16_X3 3735 -#define MNG_FN_MAGNIFY_RGBA16_X4 3736 -#define MNG_FN_MAGNIFY_G16_X3 3737 -#define MNG_FN_MAGNIFY_RGB16_X3 3738 -#define MNG_FN_MAGNIFY_GA16_X5 3739 -#define MNG_FN_MAGNIFY_RGBA16_X5 3740 - -#define MNG_FN_MAGNIFY_G8_Y1 3751 -#define MNG_FN_MAGNIFY_G8_Y2 3752 -#define MNG_FN_MAGNIFY_RGB8_Y1 3753 -#define MNG_FN_MAGNIFY_RGB8_Y2 3754 -#define MNG_FN_MAGNIFY_GA8_Y1 3755 -#define MNG_FN_MAGNIFY_GA8_Y2 3756 -#define MNG_FN_MAGNIFY_GA8_Y3 3757 -#define MNG_FN_MAGNIFY_GA8_Y4 3758 -#define MNG_FN_MAGNIFY_RGBA8_Y1 3759 -#define MNG_FN_MAGNIFY_RGBA8_Y2 3760 -#define MNG_FN_MAGNIFY_RGBA8_Y3 3761 -#define MNG_FN_MAGNIFY_RGBA8_Y4 3762 -#define MNG_FN_MAGNIFY_G8_Y3 3763 -#define MNG_FN_MAGNIFY_RGB8_Y3 3764 -#define MNG_FN_MAGNIFY_GA8_Y5 3765 -#define MNG_FN_MAGNIFY_RGBA8_Y5 3766 - -#define MNG_FN_MAGNIFY_G16_Y1 3775 -#define MNG_FN_MAGNIFY_G16_Y2 3776 -#define MNG_FN_MAGNIFY_RGB16_Y1 3777 -#define MNG_FN_MAGNIFY_RGB16_Y2 3778 -#define MNG_FN_MAGNIFY_GA16_Y1 3779 -#define MNG_FN_MAGNIFY_GA16_Y2 3780 -#define MNG_FN_MAGNIFY_GA16_Y3 3781 -#define MNG_FN_MAGNIFY_GA16_Y4 3782 -#define MNG_FN_MAGNIFY_RGBA16_Y1 3783 -#define MNG_FN_MAGNIFY_RGBA16_Y2 3784 -#define MNG_FN_MAGNIFY_RGBA16_Y3 3785 -#define MNG_FN_MAGNIFY_RGBA16_Y4 3786 -#define MNG_FN_MAGNIFY_G16_Y3 3787 -#define MNG_FN_MAGNIFY_RGB16_Y3 3788 -#define MNG_FN_MAGNIFY_GA16_Y5 3789 -#define MNG_FN_MAGNIFY_RGBA16_Y5 3790 - -/* ************************************************************************** */ - -#define MNG_FN_DELTA_G1_G1 3801 -#define MNG_FN_DELTA_G2_G2 3802 -#define MNG_FN_DELTA_G4_G4 3803 -#define MNG_FN_DELTA_G8_G8 3804 -#define MNG_FN_DELTA_G16_G16 3805 -#define MNG_FN_DELTA_RGB8_RGB8 3806 -#define MNG_FN_DELTA_RGB16_RGB16 3807 -#define MNG_FN_DELTA_GA8_GA8 3808 -#define MNG_FN_DELTA_GA8_G8 3809 -#define MNG_FN_DELTA_GA8_A8 3810 -#define MNG_FN_DELTA_GA16_GA16 3811 -#define MNG_FN_DELTA_GA16_G16 3812 -#define MNG_FN_DELTA_GA16_A16 3813 -#define MNG_FN_DELTA_RGBA8_RGBA8 3814 -#define MNG_FN_DELTA_RGBA8_RGB8 3815 -#define MNG_FN_DELTA_RGBA8_A8 3816 -#define MNG_FN_DELTA_RGBA16_RGBA16 3817 -#define MNG_FN_DELTA_RGBA16_RGB16 3818 -#define MNG_FN_DELTA_RGBA16_A16 3819 - -#define MNG_FN_PROMOTE_G8_G8 3901 -#define MNG_FN_PROMOTE_G8_G16 3902 -#define MNG_FN_PROMOTE_G16_G16 3903 -#define MNG_FN_PROMOTE_G8_GA8 3904 -#define MNG_FN_PROMOTE_G8_GA16 3905 -#define MNG_FN_PROMOTE_G16_GA16 3906 -#define MNG_FN_PROMOTE_G8_RGB8 3907 -#define MNG_FN_PROMOTE_G8_RGB16 3908 -#define MNG_FN_PROMOTE_G16_RGB16 3909 -#define MNG_FN_PROMOTE_G8_RGBA8 3910 -#define MNG_FN_PROMOTE_G8_RGBA16 3911 -#define MNG_FN_PROMOTE_G16_RGBA16 3912 -#define MNG_FN_PROMOTE_GA8_GA16 3913 -#define MNG_FN_PROMOTE_GA8_RGBA8 3914 -#define MNG_FN_PROMOTE_GA8_RGBA16 3915 -#define MNG_FN_PROMOTE_GA16_RGBA16 3916 -#define MNG_FN_PROMOTE_RGB8_RGB16 3917 -#define MNG_FN_PROMOTE_RGB8_RGBA8 3918 -#define MNG_FN_PROMOTE_RGB8_RGBA16 3919 -#define MNG_FN_PROMOTE_RGB16_RGBA16 3920 -#define MNG_FN_PROMOTE_RGBA8_RGBA16 3921 -#define MNG_FN_PROMOTE_IDX8_RGB8 3922 -#define MNG_FN_PROMOTE_IDX8_RGB16 3923 -#define MNG_FN_PROMOTE_IDX8_RGBA8 3924 -#define MNG_FN_PROMOTE_IDX8_RGBA16 3925 - -#define MNG_FN_SCALE_G1_G2 4001 -#define MNG_FN_SCALE_G1_G4 4002 -#define MNG_FN_SCALE_G1_G8 4003 -#define MNG_FN_SCALE_G1_G16 4004 -#define MNG_FN_SCALE_G2_G4 4005 -#define MNG_FN_SCALE_G2_G8 4006 -#define MNG_FN_SCALE_G2_G16 4007 -#define MNG_FN_SCALE_G4_G8 4008 -#define MNG_FN_SCALE_G4_G16 4009 -#define MNG_FN_SCALE_G8_G16 4010 -#define MNG_FN_SCALE_GA8_GA16 4011 -#define MNG_FN_SCALE_RGB8_RGB16 4012 -#define MNG_FN_SCALE_RGBA8_RGBA16 4013 - -#define MNG_FN_SCALE_G2_G1 4021 -#define MNG_FN_SCALE_G4_G1 4022 -#define MNG_FN_SCALE_G8_G1 4023 -#define MNG_FN_SCALE_G16_G1 4024 -#define MNG_FN_SCALE_G4_G2 4025 -#define MNG_FN_SCALE_G8_G2 4026 -#define MNG_FN_SCALE_G16_G2 4027 -#define MNG_FN_SCALE_G8_G4 4028 -#define MNG_FN_SCALE_G16_G4 4029 -#define MNG_FN_SCALE_G16_G8 4030 -#define MNG_FN_SCALE_GA16_GA8 4031 -#define MNG_FN_SCALE_RGB16_RGB8 4032 -#define MNG_FN_SCALE_RGBA16_RGBA8 4033 - -#define MNG_FN_COMPOSEOVER_RGBA8 4501 -#define MNG_FN_COMPOSEOVER_RGBA16 4502 -#define MNG_FN_COMPOSEUNDER_RGBA8 4503 -#define MNG_FN_COMPOSEUNDER_RGBA16 4504 - -#define MNG_FN_FLIP_RGBA8 4521 -#define MNG_FN_FLIP_RGBA16 4522 -#define MNG_FN_TILE_RGBA8 4523 -#define MNG_FN_TILE_RGBA16 4524 - -/* ************************************************************************** */ -/* * * */ -/* * Trace string-table entry * */ -/* * * */ -/* ************************************************************************** */ - -typedef struct { - mng_uint32 iFunction; - mng_pchar zTracetext; - } mng_trace_entry; -typedef mng_trace_entry const * mng_trace_entryp; - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_TRACE_PROCS */ - -/* ************************************************************************** */ - -#endif /* _libmng_trace_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/plugins/AdvaImg/src/LibMNG/libmng_types.h b/plugins/AdvaImg/src/LibMNG/libmng_types.h deleted file mode 100644 index 08086b69f2..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_types.h +++ /dev/null @@ -1,574 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_types.h copyright (c) 2000-2007 G.Juyn * */ -/* * version : 1.0.10 * */ -/* * * */ -/* * purpose : type specifications * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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 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 * */ -/* * 0.9.3 - 08/12/2000 - G.Juyn * */ -/* * - added workaround for faulty PhotoShop iCCP chunk * */ -/* * 0.9.3 - 09/11/2000 - G.Juyn * */ -/* * - added export of zlib functions from windows dll * */ -/* * - fixed inclusion parameters once again to make those * */ -/* * external libs work together * */ -/* * - re-fixed fixed inclusion parameters * */ -/* * (these freeking libraries make me mad) * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added callback to process non-critical unknown chunks * */ -/* * * */ -/* * 0.9.4 - 11/20/2000 - R.Giles * */ -/* * - fixed inclusion of lcms header for non-windows platforms * */ -/* * 0.9.4 - 12/12/2000 - G.Juyn * */ -/* * - changed callback convention for MSVC (Thanks Chad) * */ -/* * 0.9.4 - 12/16/2000 - G.Juyn * */ -/* * - fixed mixup of data- & function-pointers (thanks Dimitri)* */ -/* * * */ -/* * 1.0.1 - 02/08/2001 - G.Juyn * */ -/* * - added MEND processing callback * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added processterm callback * */ -/* * * */ -/* * 1.0.3 - 08/06/2001 - G.Juyn * */ -/* * - changed inclusion of lcms.h for Linux platforms * */ -/* * * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * * */ -/* * 1.0.6 - 04/11/2003 - G.Juyn * */ -/* * - B719420 - fixed several MNG_APP_CMS problems * */ -/* * 1.0.6 - 06/15/2003 - R.Giles * */ -/* * - lcms.h inclusion is generally no longer prefixed * */ -/* * 1.0.6 - 07/07/2003 - G. R-P. * */ -/* * - added png_imgtypes enumeration * */ -/* * * */ -/* * 1.0.7 - 03/10/2004 - G.R-P * */ -/* * - added conditionals around openstream/closestream * */ -/* * * */ -/* * 1.0.8 - 04/11/2004 - G.Juyn * */ -/* * - added data-push mechanisms for specialized decoders * */ -/* * 1.0.8 - 08/01/2004 - G.Juyn * */ -/* * - added support for 3+byte pixelsize for JPEG's * */ -/* * * */ -/* * 1.0.9 - 12/05/2004 - G.Juyn * */ -/* * - inclusion of zlib/lcms/ijgsrc6b with <> instead of "" * */ -/* * 1.0.9 - 12/06/2004 - G.Juyn * */ -/* * - added conditional MNG_OPTIMIZE_CHUNKREADER * */ -/* * * */ -/* * 1.0.10 - 04/08/2007 - G.Juyn * */ -/* * - added support for mPNG proposal * */ -/* * 1.0.10 - 04/12/2007 - G.Juyn * */ -/* * - added support for ANG proposal * */ -/* * * */ -/* ************************************************************************** */ - -#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 WIN32 /* only include needed stuff */ -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#endif - -#ifdef MNG_USE_DLL -#ifdef MNG_SKIP_ZLIB -#undef MNG_INCLUDE_ZLIB -#endif -#ifdef MNG_SKIP_LCMS -#undef MNG_INCLUDE_LCMS -#endif -#ifdef MNG_SKIP_IJG6B -#undef MNG_INCLUDE_IJG6B -#endif -#endif - -#ifdef MNG_INCLUDE_ZLIB /* zlib by Mark Adler & Jean-loup Gailly */ -#include -#endif - -#ifdef MNG_INCLUDE_LCMS /* little cms by Marti Maria Saguer */ -#ifndef ZLIB_DLL -#undef FAR -#endif -#include -#endif /* MNG_INCLUDE_LCMS */ - -#ifdef MNG_INCLUDE_IJG6B /* IJG's jpgsrc6b */ -#include -#ifdef MNG_USE_SETJMP -#include /* needed for error-recovery (blergh) */ -#else -#ifdef WIN32 -#define USE_WINDOWS_MESSAGEBOX /* display a messagebox under Windoze */ -#endif -#endif /* MNG_USE_SETJMP */ -#ifdef FAR -#undef FAR /* possibly defined by zlib or lcms */ -#endif -#define JPEG_INTERNAL_OPTIONS /* for RGB_PIXELSIZE */ -#include "../LibJPEG/jpeglib.h" /* all that for JPEG support :-) */ -#endif /* MNG_INCLUDE_IJG6B */ - -#if defined(MNG_INTERNAL_MEMMNGMT) || defined(MNG_INCLUDE_FILTERS) -#include /* "calloc" & "free" & "abs" */ -#endif - -#include /* get proper integer widths */ - -#ifdef WIN32 -#if defined __BORLANDC__ -#include /* defines "memcpy" for BCB */ -#else -#include /* defines "memcpy" for other win32 platforms */ -#endif -#include /* "strncmp" + "strcmp" */ -#else /* WIN32 */ -#ifdef BSD -#include /* defines "memcpy", etc for BSD (?) */ -#else -#include /* defines "memcpy", etc for all others (???) */ -#endif -#endif /* WIN32 */ - -#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) || defined(MNG_APP_CMS) -#include /* 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 - -#define MNG_LOCAL static - -#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 */ -typedef void (*mng_fptr) (void); /* generic function 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 -#ifdef MNG_INCLUDE_MPNG_PROPOSAL - ,mng_it_mpng -#endif -#ifdef MNG_INCLUDE_ANG_PROPOSAL - ,mng_it_ang -#endif - }; -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; - -#ifdef MNG_OPTIMIZE_CHUNKREADER - /* enumeration object-creation indicators */ -enum mng_createobjtypes {mng_create_none, mng_create_always, mng_create_ifglobal}; -typedef enum mng_createobjtypes mng_createobjtype; -#endif - -/* ************************************************************************** */ - -/* enumeration of PNG image types */ -#ifdef MNG_OPTIMIZE_FOOTPRINT_INIT -enum png_imgtypes - { - png_g1, - png_g2, - png_g4, - png_g8, - png_rgb8, - png_idx1, - png_idx2, - png_idx4, - png_idx8, - png_ga8, - png_rgba8, -#ifdef MNG_INCLUDE_JNG - png_jpeg_a1, - png_jpeg_a2, - png_jpeg_a4, - png_jpeg_a8, -#endif -#ifndef MNG_NO_16BIT_SUPPORT - png_g16, - png_ga16, - png_rgb16, - png_rgba16, -#ifdef MNG_INCLUDE_JNG - png_jpeg_a16, -#endif -#endif - png_none - }; - -typedef enum png_imgtypes png_imgtype; -#endif -/* ************************************************************************** */ - - /* 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); - -typedef void (MNG_DECL *mng_releasedata) (mng_ptr pUserdata, - mng_ptr pData, - mng_size_t iLength); - - /* I/O management callbacks */ -#ifndef MNG_NO_OPEN_CLOSE_STREAM -typedef mng_bool (MNG_DECL *mng_openstream) (mng_handle hHandle); -typedef mng_bool (MNG_DECL *mng_closestream) (mng_handle hHandle); -#endif -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); -typedef mng_bool (MNG_DECL *mng_processneed) (mng_handle hHandle, - mng_pchar zKeyword); -typedef mng_bool (MNG_DECL *mng_processmend) (mng_handle hHandle, - mng_uint32 iIterationsdone, - mng_uint32 iIterationsleft); -typedef mng_bool (MNG_DECL *mng_processunknown) (mng_handle hHandle, - mng_chunkid iChunkid, - mng_uint32 iRawlen, - mng_ptr pRawdata); -typedef mng_bool (MNG_DECL *mng_processterm) (mng_handle hHandle, - mng_uint8 iTermaction, - mng_uint8 iIteraction, - mng_uint32 iDelay, - mng_uint32 iItermax); - - /* 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 * */ -/* ************************************************************************** */ - diff --git a/plugins/AdvaImg/src/LibMNG/libmng_write.c b/plugins/AdvaImg/src/LibMNG/libmng_write.c deleted file mode 100644 index 22ed3a01e4..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_write.c +++ /dev/null @@ -1,198 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_write.c copyright (c) 2000-2004 G.Juyn * */ -/* * version : 1.0.9 * */ -/* * * */ -/* * purpose : Write management (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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 its 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 * */ -/* * * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * * */ -/* * 1.0.8 - 07/06/2004 - G.R-P * */ -/* * - added conditionals around openstream/closestream * */ -/* * - defend against using undefined Open/Closestream function * */ -/* * 1.0.8 - 08/02/2004 - G.Juyn * */ -/* * - added conditional to allow easier writing of large MNG's * */ -/* * * */ -/* * 1.0.9 - 09/25/2004 - G.Juyn * */ -/* * - replaced MNG_TWEAK_LARGE_FILES with permanent solution * */ -/* * 1.0.9 - 12/20/2004 - G.Juyn * */ -/* * - cleaned up macro-invocations (thanks to D. Airlie) * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_memory.h" -#include "libmng_chunks.h" -#include "libmng_chunk_io.h" -#include "libmng_write.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) -mng_retcode mng_drop_chunks (mng_datap pData) -{ - mng_chunkp pChunk; - mng_chunkp pNext; - mng_cleanupchunk fCleanup; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DROP_CHUNKS, MNG_LC_START); -#endif - - pChunk = pData->pFirstchunk; /* and get first stored chunk (if any) */ - - while (pChunk) /* more chunks to discard ? */ - { - pNext = ((mng_chunk_headerp)pChunk)->pNext; - /* call appropriate cleanup */ - fCleanup = ((mng_chunk_headerp)pChunk)->fCleanup; - fCleanup (pData, pChunk); - - pChunk = pNext; /* neeeext */ - } - - pData->pFirstchunk = MNG_NULL; - pData->pLastchunk = MNG_NULL; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DROP_CHUNKS, MNG_LC_END); -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_WRITE_PROCS - -/* ************************************************************************** */ - -mng_retcode mng_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->bWriting) - { -#ifndef MNG_NO_OPEN_CLOSE_STREAM - if (pData->fOpenstream && !pData->fOpenstream ((mng_handle)pData)) - MNG_ERROR (pData, MNG_APPIOERROR); -#endif - { - 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 its output routine */ - iRetcode = ((mng_chunk_headerp)pChunk)->fWrite (pData, pChunk); - if (iRetcode) /* on error bail out */ - return iRetcode; - /* neeeext */ - pChunk = ((mng_chunk_headerp)pChunk)->pNext; - } - - if (!pData->bCreating) - { /* free the temporary buffer */ - MNG_FREE (pData, pData->pWritebuf, pData->iWritebufsize+12); - - pData->bWriting = MNG_FALSE; /* done writing */ - /* close the stream now */ -#ifndef MNG_NO_OPEN_CLOSE_STREAM - if (pData->fClosestream && !pData->fClosestream ((mng_handle)pData)) - MNG_ERROR (pData, MNG_APPIOERROR); -#endif - - } else { - /* cleanup the written chunks */ - iRetcode = mng_drop_chunks (pData); - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - -#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 * */ -/* ************************************************************************** */ - - diff --git a/plugins/AdvaImg/src/LibMNG/libmng_write.h b/plugins/AdvaImg/src/LibMNG/libmng_write.h deleted file mode 100644 index 31e5d1b622..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_write.h +++ /dev/null @@ -1,49 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_write.h copyright (c) 2000-2004 G.Juyn * */ -/* * version : 1.0.9 * */ -/* * * */ -/* * purpose : Write management (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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 * */ -/* * * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * * */ -/* * 1.0.9 - 09/25/2004 - G.Juyn * */ -/* * - replaced MNG_TWEAK_LARGE_FILES with permanent solution * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_write_h_ -#define _libmng_write_h_ - -/* ************************************************************************** */ - -mng_retcode mng_drop_chunks (mng_datap pData); - -mng_retcode mng_write_graphic (mng_datap pData); - -/* ************************************************************************** */ - -#endif /* _libmng_write_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/plugins/AdvaImg/src/LibMNG/libmng_zlib.c b/plugins/AdvaImg/src/LibMNG/libmng_zlib.c deleted file mode 100644 index 894bc74ac7..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_zlib.c +++ /dev/null @@ -1,607 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_zlib.c copyright (c) 2000-2004 G.Juyn * */ -/* * version : 1.0.9 * */ -/* * * */ -/* * purpose : ZLIB library interface (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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 * */ -/* * * */ -/* * 0.9.3 - 08/08/2000 - G.Juyn * */ -/* * - fixed compiler-warnings from Mozilla * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * * */ -/* * 1.0.5 - 08/07/2002 - G.Juyn * */ -/* * - added test-option for PNG filter method 193 (=no filter) * */ -/* * 1.0.5 - 08/19/2002 - G.Juyn * */ -/* * - B597134 - libmng pollutes the linker namespace * */ -/* * 1.0.5 - 09/19/2002 - G.Juyn * */ -/* * - added warning for too much IDAT data * */ -/* * * */ -/* * 1.0.6 - 07/07/2003 - G.R-P * */ -/* * - added MNG_NO_16BIT_SUPPORT support * */ -/* * * */ -/* * 1.0.9 - 10/09/2004 - G.R-P * */ -/* * - added MNG_NO_1_2_4BIT_SUPPORT support * */ -/* * * */ -/* ************************************************************************** */ - -#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) -{ - int 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) -{ - int 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 + pData->iPixelofs); -#ifdef MNG_NO_1_2_4BIT_SUPPORT - if (pData->iPNGdepth < 8) - pData->sZlib.avail_out = (uInt)((pData->iPNGdepth*pData->iRowsize + 7)/8 - + pData->iPixelofs); -#endif -#ifdef MNG_NO_16BIT_SUPPORT - if (pData->iPNGdepth > 8) - pData->sZlib.avail_out = (uInt)(2*pData->iRowsize + pData->iPixelofs); -#endif - } - - 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)) - { /* image not completed yet ? */ - if (pData->iRow < (mng_int32)pData->iDataheight) - { -#ifdef MNG_NO_1_2_4BIT_SUPPORT - if (pData->iPNGdepth == 1) - { - /* Inflate Workrow to 8-bit */ - mng_int32 iX; - mng_uint8p pSrc = pData->pWorkrow+1; - mng_uint8p pDest = pSrc + pData->iRowsize - (pData->iRowsize+7)/8; - - for (iX = ((pData->iRowsize+7)/8) ; iX > 0 ; iX--) - *pDest++ = *pSrc++; - - pDest = pData->pWorkrow+1; - pSrc = pDest + pData->iRowsize - (pData->iRowsize+7)/8; - for (iX = pData->iRowsize; ;) - { - *pDest++ = (((*pSrc)>>7)&1); - if (iX-- <= 0) - break; - *pDest++ = (((*pSrc)>>6)&1); - if (iX-- <= 0) - break; - *pDest++ = (((*pSrc)>>5)&1); - if (iX-- <= 0) - break; - *pDest++ = (((*pSrc)>>4)&1); - if (iX-- <= 0) - break; - *pDest++ = (((*pSrc)>>3)&1); - if (iX-- <= 0) - break; - *pDest++ = (((*pSrc)>>2)&1); - if (iX-- <= 0) - break; - *pDest++ = (((*pSrc)>>1)&1); - if (iX-- <= 0) - break; - *pDest++ = (((*pSrc) )&1); - if (iX-- <= 0) - break; - pSrc++; - } - } - else if (pData->iPNGdepth == 2) - { - /* Inflate Workrow to 8-bit */ - mng_int32 iX; - mng_uint8p pSrc = pData->pWorkrow+1; - mng_uint8p pDest = pSrc + pData->iRowsize - (2*pData->iRowsize+7)/8; - - for (iX = ((2*pData->iRowsize+7)/8) ; iX > 0 ; iX--) - *pDest++ = *pSrc++; - - pDest = pData->pWorkrow+1; - pSrc = pDest + pData->iRowsize - (2*pData->iRowsize+7)/8; - for (iX = pData->iRowsize; ;) - { - *pDest++ = (((*pSrc)>>6)&3); - if (iX-- <= 0) - break; - *pDest++ = (((*pSrc)>>4)&3); - if (iX-- <= 0) - break; - *pDest++ = (((*pSrc)>>2)&3); - if (iX-- <= 0) - break; - *pDest++ = (((*pSrc) )&3); - if (iX-- <= 0) - break; - pSrc++; - } - } - else if (pData->iPNGdepth == 4) - { - /* Inflate Workrow to 8-bit */ - mng_int32 iX; - mng_uint8p pSrc = pData->pWorkrow+1; - mng_uint8p pDest = pSrc + pData->iRowsize - (4*pData->iRowsize+7)/8; - - for (iX = ((4*pData->iRowsize+7)/8) ; iX > 0 ; iX--) - *pDest++ = *pSrc++; - - pDest = pData->pWorkrow+1; - pSrc = pDest + pData->iRowsize - (4*pData->iRowsize+7)/8; - for (iX = pData->iRowsize; ;) - { - *pDest++ = (((*pSrc)>>4)&0x0f); - if (iX-- <= 0) - break; - *pDest++ = (((*pSrc) )&0x0f); - if (iX-- <= 0) - break; - pSrc++; - } - } - if (pData->iPNGdepth < 8 && pData->iColortype == 0) - { - /* Expand samples to 8-bit by LBR */ - mng_int32 iX; - mng_uint8p pSrc = pData->pWorkrow+1; - mng_uint8 multiplier[]={0,255,85,0,17,0,0,0,1}; - - for (iX = pData->iRowsize; iX > 0; iX--) - *pSrc++ *= multiplier[pData->iPNGdepth]; - } -#endif -#ifdef MNG_NO_16BIT_SUPPORT - if (pData->iPNGdepth > 8) - { - /* Reduce Workrow to 8-bit */ - mng_int32 iX; - mng_uint8p pSrc = pData->pWorkrow+1; - mng_uint8p pDest = pSrc; - - for (iX = pData->iRowsize; iX > 0; iX--) - { - *pDest = *pSrc; - pDest++; - pSrc+=2; - } - } -#endif - -#ifdef FILTER192 /* has leveling info ? */ - if (pData->iFilterofs == MNG_FILTER_DIFFERING) - iRslt = init_rowdiffering (pData); - else -#endif - iRslt = MNG_NOERROR; - /* filter the row if necessary */ - if ((!iRslt) && (pData->iFilterofs < pData->iPixelofs ) && - (*(pData->pWorkrow + pData->iFilterofs)) ) - iRslt = mng_filter_a_row (pData); - else - iRslt = MNG_NOERROR; - /* additional leveling/differing ? */ - if ((!iRslt) && (pData->fDifferrow)) - { - iRslt = ((mng_differrow)pData->fDifferrow) (pData); - - pSwap = pData->pWorkrow; - pData->pWorkrow = pData->pPrevrow; - pData->pPrevrow = pSwap; /* make sure we're processing the right data */ - } - - 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 = mng_display_progressive_check (pData); - - } - } - } - - if (iRslt) /* on error bail out */ - MNG_ERROR (pData, iRslt); - - if (!pData->fDifferrow) /* swap row-pointers */ - { - pSwap = pData->pWorkrow; - pData->pWorkrow = pData->pPrevrow; - pData->pPrevrow = pSwap; /* so prev points to the processed row! */ - } - - iRslt = mng_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 + pData->iPixelofs); -#ifdef MNG_NO_1_2_4BIT_SUPPORT - if (pData->iPNGdepth < 8) - pData->sZlib.avail_out = (uInt)((pData->iPNGdepth*pData->iRowsize + 7)/8 - + pData->iPixelofs); -#endif -#ifdef MNG_NO_16BIT_SUPPORT - if (pData->iPNGdepth > 8) - pData->sZlib.avail_out = (uInt)(2*pData->iRowsize + pData->iPixelofs); -#endif - } - } /* until some error or EOI - or all pixels received */ - while ( (iZrslt == Z_OK) && (pData->sZlib.avail_in > 0) && - ( (pData->iRow < (mng_int32)pData->iDataheight) || - ( (pData->iPass >= 0) && (pData->iPass < 7) ) ) ); - /* on error bail out */ - if ((iZrslt != Z_OK) && (iZrslt != Z_STREAM_END)) - MNG_ERRORZ (pData, (mng_uint32)iZrslt); - /* too much data ? */ - if ((iZrslt == Z_OK) && (pData->sZlib.avail_in > 0)) - MNG_WARNING (pData, MNG_TOOMUCHIDAT); - -#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) -{ - int 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) -{ - int 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 its 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) -{ - int 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) -{ - int 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) -{ - int iZrslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_DEFLATEFREE, MNG_LC_START); -#endif - - iZrslt = deflateEnd (&pData->sZlib); /* let zlib cleanup its 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 * */ -/* ************************************************************************** */ - diff --git a/plugins/AdvaImg/src/LibMNG/libmng_zlib.h b/plugins/AdvaImg/src/LibMNG/libmng_zlib.h deleted file mode 100644 index 4309344ded..0000000000 --- a/plugins/AdvaImg/src/LibMNG/libmng_zlib.h +++ /dev/null @@ -1,60 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_zlib.h copyright (c) 2000-2002 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : ZLIB package interface (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * * */ -/* * 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_ - -/* ************************************************************************** */ - -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 * */ -/* ************************************************************************** */ diff --git a/plugins/AdvaImg/src/LibPNG/ANNOUNCE b/plugins/AdvaImg/src/LibPNG/ANNOUNCE index e8498a379c..346383d7b9 100644 --- a/plugins/AdvaImg/src/LibPNG/ANNOUNCE +++ b/plugins/AdvaImg/src/LibPNG/ANNOUNCE @@ -1,5 +1,5 @@ -Libpng 1.5.9 - February 18, 2012 +Libpng 1.5.13 - September 27, 2012 This is a public release of libpng, intended for use in production codes. @@ -8,30 +8,35 @@ Files available for download: Source files with LF line endings (for Unix/Linux) and with a "configure" script - libpng-1.5.9.tar.xz (LZMA-compressed, recommended) - libpng-1.5.9.tar.gz - libpng-1.5.9.tar.bz2 + libpng-1.5.13.tar.xz (LZMA-compressed, recommended) + libpng-1.5.13.tar.gz + libpng-1.5.13.tar.bz2 Source files with CRLF line endings (for Windows), without the "configure" script - lpng159.7z (LZMA-compressed, recommended) - lpng159.zip + lpng1513.7z (LZMA-compressed, recommended) + lpng1513.zip Other information: - libpng-1.5.9-README.txt - libpng-1.5.9-LICENSE.txt - -Changes since the last public release (1.5.8): - - Rebuilt configure scripts in the tar distributions. - Removed two unused definitions from scripts/pnglibconf.h.prebuilt - Removed some unused arrays (with #ifdef) from png_read_push_finish_row(). - Removed tests for no-longer-used *_EMPTY_PLTE_SUPPORTED from pngstruct.h - Fixed CVE-2011-3026 buffer overrun bug. Deal more correctly with the test - on iCCP chunk length. Also removed spurious casts that may hide problems - on 16-bit systems. + libpng-1.5.13-README.txt + libpng-1.5.13-LICENSE.txt + +Changes since the last public release (1.5.12): + Do not compile PNG_DEPRECATED, PNG_ALLOC and PNG_PRIVATE when __GNUC__ < 3. + Removed references to png_zalloc() and png_zfree() from the manual. + Revised PNG_FP_EXPORT and PNG_FIXED_EXPORT macros to avoid generating + lone semicolons (patch ported from libpng-1.6.0beta11). + Corrected handling of the image array and the row_pointers array in example.c + When png_set_filler is used to strip a filler channel during write, the + code prior to 1.5 would ignore the case where the output required an + alpha channel or when the output was a palettized PNG. In libpng-1.5 the + ignorance was lost and libpng proceeded to strip the channel resulting + in a bad (potential memory overwrite) failure later. This reverts + the behavior to the pre-1.5 state but issues a warning. libpng-1.6 is + expected to issue an error on the erroneous png_set_filler call. + Use png_memset() consistently (pngmem.c contained some bare "memset" calls). Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/plugins/AdvaImg/src/LibPNG/CHANGES b/plugins/AdvaImg/src/LibPNG/CHANGES index fb3a90be8c..d3c0cccc1c 100644 --- a/plugins/AdvaImg/src/LibPNG/CHANGES +++ b/plugins/AdvaImg/src/LibPNG/CHANGES @@ -3803,13 +3803,122 @@ Version 1.5.9beta02 [February 16, 2012] Removed tests for no-longer-used *_EMPTY_PLTE_SUPPORTED from pngstruct.h Version 1.5.9rc01 [February 17, 2012] - Fixed CVE-2011-3026 buffer overrun bug. Deal more correctly with the test - on iCCP chunk length. Also removed spurious casts that may hide problems - on 16-bit systems. + Fixed CVE-2011-3026 buffer overrun bug. This bug was introduced when + iCCP chunk support was added at libpng-1.0.6. Deal more correctly with the + test on iCCP chunk length. Also removed spurious casts that may hide + problems on 16-bit systems. Version 1.5.9 [February 18, 2012] No changes. +Version 1.5.10beta01 [February 24, 2012] + Removed two useless #ifdef directives from pngread.c and one from pngrutil.c + Always put the CMAKE_LIBRARY in "lib" (removed special WIN32 case). + Removed empty vstudio/pngstest directory (Clifford Yapp). + Eliminated redundant png_push_read_tEXt|zTXt|iTXt|unknown code from + pngpread.c and use the sequential png_handle_tEXt, etc., in pngrutil.c; + now that png_ptr->buffer is inaccessible to applications, the special + handling is no longer useful. + Fixed bug with png_handle_hIST with odd chunk length (Frank Busse). + Added PNG_SAFE_LIMITS feature to pnglibconf.dfa and code in pngconf.h + to reset the user limits to safe ones if PNG_SAFE_LIMITS is defined. + To enable, use "CPPFLAGS=-DPNG_SAFE_LIMITS_SUPPORTED" on the configure + command or put "#define PNG_SAFE_LIMITS_SUPPORTED" in pnglibconf.h. + Revised the SAFE_LIMITS feature to be the same as the feature in libpng16. + Added information about the new limits in the manual. + +Version 1.5.10beta02 [February 27, 2012] + Updated Makefile.in + +Version 1.5.10beta03 [March 6, 2012] + Removed unused "current_text" members of png_struct and the png_free() + of png_ptr->current_text from pngread.c + Added palette-index checking. Issue a png_warning() if an invalid index is + found. + +Version 1.5.10beta04 [March 10, 2012] + Fixed PNG_LIBPNG_BUILD_BASE_TYPE definition. + Fixed CMF optimization of non-IDAT compressed chunks, which was added at + libpng-1.5.4. It sometimes produced too small of a window. + +Version 1.5.10beta05 [March 10, 2012] + Reject all iCCP chunks after the first, even if the first one is invalid. + Issue a png_benign_error() instead of png_warning() about bad palette index. + Fixed an off-by-one error in the palette index checking function. + Revised example.c to put text strings in a temporary character array + instead of directly assigning string constants to png_textp members. + This avoids compiler warnings when -Wwrite-strings is enabled. + +Version 1.5.10 [March 29, 2012] + Prevent PNG_EXPAND+PNG_SHIFT doing the shift twice. + Revised png_set_text_2() to avoid potential memory corruption (fixes + CVE-2011-3048, also known as CVE-2012-3425). + +Version 1.5.11beta01 [April 28, 2012] + Revised scripts/makefile.darwin: use system zlib; remove quotes around + architecture list; add missing ppc architecture; add architecture options + to shared library link; don't try to create a shared lib based on missing + RELEASE variable. + Enable png_set_check_for_invalid_index() for both read and write. + Removed #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED/#endif in pngpriv.h around + declaration of png_handle_unknown(). + Added -lssp_nonshared in a comment in scripts/makefile.freebsd + and changed deprecated NOOBJ and NOPROFILE to NO_OBJ and NO_PROFILE. + +Version 1.5.11rc01 [May 23, 2012] + No changes. + +Version 1.5.11rc02 [May 29, 2012] + Fixed some typos in comments. + Revised CMakeLists.txt to not attempt to make a symlink under mingw. + Added two images to contrib/pngsuite (1-bit and 2-bit transparent grayscale), + and renamed three whose names were inconsistent with those in + pngsuite/README.txt. + +Version 1.5.11rc03 [June 4, 2012] + Do not depend upon a GCC feature macro being available for use in generating + the linker mapfile symbol prefix. + Made fixes for new optimization warnings from gcc 4.7.0. The compiler + performed an optimization which is safe but then warned about it. + Changing the type of 'palette_number' in pngvalid.c removes the warning. + +Version 1.5.11rc04 [June 6, 2012] + Improved performance of new do_check_palette_indexes() function. + +Version 1.5.11rc05 [June 7, 2012] + Don't check palette indexes if num_palette is 0 (as it can be in MNG files). + +Version 1.5.11 [June 14, 2012] + Include zlib.h in contrib/gregbook and contrib/visupng examples. + +Version 1.5.12 [July 11, 2012] + Removed scripts/makefile.cegcc from the *.zip and *.7z distributions; it + depends on configure, which is not included in those archives. + Changed "a+w" to "u+w" in Makefile.in to fix CVE-2012-3386. + +Version 1.5.13beta01 [August 8, 2012] + Do not compile PNG_DEPRECATED, PNG_ALLOC and PNG_PRIVATE when __GNUC__ < 3. + Removed references to png_zalloc() and png_zfree() from the manual. + Revised PNG_FP_EXPORT and PNG_FIXED_EXPORT macros to avoid generating + lone semicolons (patch ported from libpng-1.6.0beta11). + +Version 1.5.13beta02 [September 10, 2012] + Corrected handling of the image array and the row_pointers array in example.c + When png_set_filler is used to strip a filler channel during write, the + code prior to 1.5 would ignore the case where the output required an + alpha channel or when the output was a palettized PNG. In libpng-1.5 the + ignorance was lost and libpng proceeded to strip the channel resulting + in a bad (potential memory overwrite) failure later. This reverts + the behavior to the pre-1.5 state but issues a warning. libpng-1.6 is + expected to issue an error on the erroneous png_set_filler call. + Use png_memset() consistently (pngmem.c contained some bare "memset" calls). + +Version 1.5.13rc01 [September 17, 2012] + No changes. + +Version 1.5.13 [September 27, 2012] + No changes. + Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit https://lists.sourceforge.net/lists/listinfo/png-mng-implement diff --git a/plugins/AdvaImg/src/LibPNG/KNOWNBUG b/plugins/AdvaImg/src/LibPNG/KNOWNBUG deleted file mode 100644 index f3ddc5245f..0000000000 --- a/plugins/AdvaImg/src/LibPNG/KNOWNBUG +++ /dev/null @@ -1,29 +0,0 @@ - -Known bugs in libpng version 1.2.43 - -1. December 4, 2009: The PNG_NO_ERROR_NUMBERS macro was inadvertently - defined in libpng-1.2.41/pngconf.h, which may cause a problem with - building a binary-compatible library. - - STATUS: This will be fixed in libpng-1.2.42. In the meantime, simply - delete the definition from line : - -2. February 23, 2006: The custom makefiles don't build libpng with -lz. - - STATUS: This is a subject of debate. The change will probably be made - as a part of a major overhaul of the makefiles in libpng version 1.4.0. - -3. February 24, 2006: The Makefile generated by the "configure" script - fails to install symbolic links - libpng12.so => libpng12.so.0.1.2.9betaN - that are generated by the custom makefiles. - -4. September 4, 2007: There is a report that pngtest crashes on MacOS 10. - - STATUS: workarounds are - 1) Compile without optimization (crashes are observed with - -arch i386 and -O2 or -O3, using gcc-4.0.1). - 2) Compile pngtest.c with PNG_DEBUG defined (the bug goes away if - you try to look at it). - 3) Ignore the crash. The library itself seems to be OK. - diff --git a/plugins/AdvaImg/src/LibPNG/LICENSE b/plugins/AdvaImg/src/LibPNG/LICENSE index 0c927409ac..853fb2cc24 100644 --- a/plugins/AdvaImg/src/LibPNG/LICENSE +++ b/plugins/AdvaImg/src/LibPNG/LICENSE @@ -10,8 +10,8 @@ this sentence. This code is released under the libpng license. -libpng versions 1.2.6, August 15, 2004, through 1.5.9, February 18, 2012, are -Copyright (c) 2004, 2006-2011 Glenn Randers-Pehrson, and are +libpng versions 1.2.6, August 15, 2004, through 1.5.13, September 27, 2012, are +Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are distributed according to the same disclaimer and license as libpng-1.2.5 with the following individual added to the list of Contributing Authors @@ -108,4 +108,4 @@ certification mark of the Open Source Initiative. Glenn Randers-Pehrson glennrp at users.sourceforge.net -February 18, 2012 +September 27, 2012 diff --git a/plugins/AdvaImg/src/LibPNG/README b/plugins/AdvaImg/src/LibPNG/README index c648a5ad78..5afeae8c45 100644 --- a/plugins/AdvaImg/src/LibPNG/README +++ b/plugins/AdvaImg/src/LibPNG/README @@ -1,4 +1,4 @@ -README for libpng version 1.5.9 - February 18, 2012 (shared library 15.0) +README for libpng version 1.5.13 - September 27, 2012 (shared library 15.0) See the note about version numbers near the top of png.h See INSTALL for instructions on how to install libpng. diff --git a/plugins/AdvaImg/src/LibPNG/Y2KINFO b/plugins/AdvaImg/src/LibPNG/Y2KINFO deleted file mode 100644 index 7776d83732..0000000000 --- a/plugins/AdvaImg/src/LibPNG/Y2KINFO +++ /dev/null @@ -1,55 +0,0 @@ - Y2K compliance in libpng: - ========================= - - February 25, 2010 - - Since the PNG Development group is an ad-hoc body, we can't make - an official declaration. - - This is your unofficial assurance that libpng from version 0.71 and - upward through 1.2.43 are Y2K compliant. It is my belief that earlier - versions were also Y2K compliant. - - Libpng only has three year fields. One is a 2-byte unsigned integer - that will hold years up to 65535. The other two hold the date in text - format, and will hold years up to 9999. - - The integer is - "png_uint_16 year" in png_time_struct. - - The strings are - "png_charp time_buffer" in png_struct and - "near_time_buffer", which is a local character string in png.c. - - There are seven time-related functions: - - png_convert_to_rfc_1123() in png.c - (formerly png_convert_to_rfc_1152() in error) - png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c - png_convert_from_time_t() in pngwrite.c - png_get_tIME() in pngget.c - png_handle_tIME() in pngrutil.c, called in pngread.c - png_set_tIME() in pngset.c - png_write_tIME() in pngwutil.c, called in pngwrite.c - - All appear to handle dates properly in a Y2K environment. The - png_convert_from_time_t() function calls gmtime() to convert from system - clock time, which returns (year - 1900), which we properly convert to - the full 4-digit year. There is a possibility that applications using - libpng are not passing 4-digit years into the png_convert_to_rfc_1123() - function, or that they are incorrectly passing only a 2-digit year - instead of "year - 1900" into the png_convert_from_struct_tm() function, - but this is not under our control. The libpng documentation has always - stated that it works with 4-digit years, and the APIs have been - documented as such. - - The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned - integer to hold the year, and can hold years as large as 65535. - - zlib, upon which libpng depends, is also Y2K compliant. It contains - no date-related code. - - - Glenn Randers-Pehrson - libpng maintainer - PNG Development Group diff --git a/plugins/AdvaImg/src/LibPNG/configure b/plugins/AdvaImg/src/LibPNG/configure index 9da0f74eca..218dddd913 100644 --- a/plugins/AdvaImg/src/LibPNG/configure +++ b/plugins/AdvaImg/src/LibPNG/configure @@ -1,19 +1,19 @@ echo " - There is no \"configure\" script in this distribution of - libpng-1.5.9. + There is no \"configure\" script in this distribution (*.zip or *.7z) of + libpng-1.5.13. Instead, please copy the appropriate makefile for your system from the \"scripts\" directory. Read the INSTALL file for more details. Update, July 2004: you can get a \"configure\" based distribution from the libpng distribution sites. Download the file - libpng-1.5.9.tar.gz, libpng-1.5.9.tar.xz, or libpng-1.5.9.tar.bz2 + libpng-1.5.13.tar.gz, libpng-1.5.13.tar.xz, or libpng-1.5.13.tar.bz2 If the line endings in the files look funny, which is likely to be the case if you were trying to run \"configure\" on a Linux machine, you may wish to get the other distribution of libpng. It is available in both - tar.gz/tar.xz (UNIX style line endings) and .7z/.zip (DOS style line - endings) formats. + tar.gz/tar.xz (UNIX style line endings, with \"configure\") and .7z/.zip + (DOS style line endings, without \"configure\") formats. " diff --git a/plugins/AdvaImg/src/LibPNG/example.c b/plugins/AdvaImg/src/LibPNG/example.c new file mode 100644 index 0000000000..04241ef416 --- /dev/null +++ b/plugins/AdvaImg/src/LibPNG/example.c @@ -0,0 +1,879 @@ + +#if 0 /* in case someone actually tries to compile this */ + +/* example.c - an example of using libpng + * Last changed in libpng 1.5.10 [March 8, 2012] + * Maintained 1998-2012 Glenn Randers-Pehrson + * Maintained 1996, 1997 Andreas Dilger + * Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc. + */ + +/* This is an example of how to use libpng to read and write PNG files. + * The file libpng-manual.txt is much more verbose then this. If you have not + * read it, do so first. This was designed to be a starting point of an + * implementation. This is not officially part of libpng, is hereby placed + * in the public domain, and therefore does not require a copyright notice. + * To the extent possible under law, the authors have waived all copyright and + * related or neighboring rights to this file. + * + * This file does not currently compile, because it is missing certain + * parts, like allocating memory to hold an image. You will have to + * supply these parts to get it to compile. For an example of a minimal + * working PNG reader/writer, see pngtest.c, included in this distribution; + * see also the programs in the contrib directory. + */ + +#define _POSIX_SOURCE 1 /* libpng and zlib are POSIX-compliant. You may + * change this if your application uses non-POSIX + * extensions. */ + +#include "png.h" + + /* The png_jmpbuf() macro, used in error handling, became available in + * libpng version 1.0.6. If you want to be able to run your code with older + * versions of libpng, you must define the macro yourself (but only if it + * is not already defined by libpng!). + */ + +#ifndef png_jmpbuf +# define png_jmpbuf(png_ptr) ((png_ptr)->png_jmpbuf) +#endif + +/* Check to see if a file is a PNG file using png_sig_cmp(). png_sig_cmp() + * returns zero if the image is a PNG and nonzero if it isn't a PNG. + * + * The function check_if_png() shown here, but not used, returns nonzero (true) + * if the file can be opened and is a PNG, 0 (false) otherwise. + * + * If this call is successful, and you are going to keep the file open, + * you should call png_set_sig_bytes(png_ptr, PNG_BYTES_TO_CHECK); once + * you have created the png_ptr, so that libpng knows your application + * has read that many bytes from the start of the file. Make sure you + * don't call png_set_sig_bytes() with more than 8 bytes read or give it + * an incorrect number of bytes read, or you will either have read too + * many bytes (your fault), or you are telling libpng to read the wrong + * number of magic bytes (also your fault). + * + * Many applications already read the first 2 or 4 bytes from the start + * of the image to determine the file type, so it would be easiest just + * to pass the bytes to png_sig_cmp() or even skip that if you know + * you have a PNG file, and call png_set_sig_bytes(). + */ +#define PNG_BYTES_TO_CHECK 4 +int check_if_png(char *file_name, FILE **fp) +{ + char buf[PNG_BYTES_TO_CHECK]; + + /* Open the prospective PNG file. */ + if ((*fp = fopen(file_name, "rb")) == NULL) + return 0; + + /* Read in some of the signature bytes */ + if (fread(buf, 1, PNG_BYTES_TO_CHECK, *fp) != PNG_BYTES_TO_CHECK) + return 0; + + /* Compare the first PNG_BYTES_TO_CHECK bytes of the signature. + Return nonzero (true) if they match */ + + return(!png_sig_cmp(buf, (png_size_t)0, PNG_BYTES_TO_CHECK)); +} + +/* Read a PNG file. You may want to return an error code if the read + * fails (depending upon the failure). There are two "prototypes" given + * here - one where we are given the filename, and we need to open the + * file, and the other where we are given an open file (possibly with + * some or all of the magic bytes read - see comments above). + */ +#ifdef open_file /* prototype 1 */ +void read_png(char *file_name) /* We need to open the file */ +{ + png_structp png_ptr; + png_infop info_ptr; + unsigned int sig_read = 0; + png_uint_32 width, height; + int bit_depth, color_type, interlace_type; + FILE *fp; + + if ((fp = fopen(file_name, "rb")) == NULL) + return (ERROR); + +#else no_open_file /* prototype 2 */ +void read_png(FILE *fp, unsigned int sig_read) /* File is already open */ +{ + png_structp png_ptr; + png_infop info_ptr; + png_uint_32 width, height; + int bit_depth, color_type, interlace_type; +#endif no_open_file /* Only use one prototype! */ + + /* Create and initialize the png_struct with the desired error handler + * functions. If you want to use the default stderr and longjump method, + * you can supply NULL for the last three parameters. We also supply the + * the compiler header file version, so that we know if the application + * was compiled with a compatible version of the library. REQUIRED + */ + png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, + png_voidp user_error_ptr, user_error_fn, user_warning_fn); + + if (png_ptr == NULL) + { + fclose(fp); + return (ERROR); + } + + /* Allocate/initialize the memory for image information. REQUIRED. */ + info_ptr = png_create_info_struct(png_ptr); + if (info_ptr == NULL) + { + fclose(fp); + png_destroy_read_struct(&png_ptr, NULL, NULL); + return (ERROR); + } + + /* Set error handling if you are using the setjmp/longjmp method (this is + * the normal method of doing things with libpng). REQUIRED unless you + * set up your own error handlers in the png_create_read_struct() earlier. + */ + + if (setjmp(png_jmpbuf(png_ptr))) + { + /* Free all of the memory associated with the png_ptr and info_ptr */ + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + fclose(fp); + /* If we get here, we had a problem reading the file */ + return (ERROR); + } + + /* One of the following I/O initialization methods is REQUIRED */ +#ifdef streams /* PNG file I/O method 1 */ + /* Set up the input control if you are using standard C streams */ + png_init_io(png_ptr, fp); + +#else no_streams /* PNG file I/O method 2 */ + /* If you are using replacement read functions, instead of calling + * png_init_io() here you would call: + */ + png_set_read_fn(png_ptr, (void *)user_io_ptr, user_read_fn); + /* where user_io_ptr is a structure you want available to the callbacks */ +#endif no_streams /* Use only one I/O method! */ + + /* If we have already read some of the signature */ + png_set_sig_bytes(png_ptr, sig_read); + +#ifdef hilevel + /* + * If you have enough memory to read in the entire image at once, + * and you need to specify only transforms that can be controlled + * with one of the PNG_TRANSFORM_* bits (this presently excludes + * quantizing, filling, setting background, and doing gamma + * adjustment), then you can read the entire image (including + * pixels) into the info structure with this call: + */ + png_read_png(png_ptr, info_ptr, png_transforms, NULL); + +#else + /* OK, you're doing it the hard way, with the lower-level functions */ + + /* The call to png_read_info() gives us all of the information from the + * PNG file before the first IDAT (image data chunk). REQUIRED + */ + png_read_info(png_ptr, info_ptr); + + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, + &interlace_type, NULL, NULL); + + /* Set up the data transformations you want. Note that these are all + * optional. Only call them if you want/need them. Many of the + * transformations only work on specific types of images, and many + * are mutually exclusive. + */ + + /* Tell libpng to strip 16 bit/color files down to 8 bits/color. + * Use accurate scaling if it's available, otherwise just chop off the + * low byte. + */ +#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED + png_set_scale_16(png_ptr); +#else + png_set_strip_16(png_ptr); +#endif + + /* Strip alpha bytes from the input data without combining with the + * background (not recommended). + */ + png_set_strip_alpha(png_ptr); + + /* Extract multiple pixels with bit depths of 1, 2, and 4 from a single + * byte into separate bytes (useful for paletted and grayscale images). + */ + png_set_packing(png_ptr); + + /* Change the order of packed pixels to least significant bit first + * (not useful if you are using png_set_packing). */ + png_set_packswap(png_ptr); + + /* Expand paletted colors into true RGB triplets */ + if (color_type == PNG_COLOR_TYPE_PALETTE) + png_set_palette_to_rgb(png_ptr); + + /* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */ + if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) + png_set_expand_gray_1_2_4_to_8(png_ptr); + + /* Expand paletted or RGB images with transparency to full alpha channels + * so the data will be available as RGBA quartets. + */ + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) + png_set_tRNS_to_alpha(png_ptr); + + /* Set the background color to draw transparent and alpha images over. + * It is possible to set the red, green, and blue components directly + * for paletted images instead of supplying a palette index. Note that + * even if the PNG file supplies a background, you are not required to + * use it - you should use the (solid) application background if it has one. + */ + + png_color_16 my_background, *image_background; + + if (png_get_bKGD(png_ptr, info_ptr, &image_background)) + png_set_background(png_ptr, image_background, + PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); + else + png_set_background(png_ptr, &my_background, + PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); + + /* Some suggestions as to how to get a screen gamma value + * + * Note that screen gamma is the display_exponent, which includes + * the CRT_exponent and any correction for viewing conditions + */ + if (/* We have a user-defined screen gamma value */) + { + screen_gamma = user-defined screen_gamma; + } + /* This is one way that applications share the same screen gamma value */ + else if ((gamma_str = getenv("SCREEN_GAMMA")) != NULL) + { + screen_gamma = atof(gamma_str); + } + /* If we don't have another value */ + else + { + screen_gamma = 2.2; /* A good guess for a PC monitor in a dimly + lit room */ + screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */ + } + + /* Tell libpng to handle the gamma conversion for you. The final call + * is a good guess for PC generated images, but it should be configurable + * by the user at run time by the user. It is strongly suggested that + * your application support gamma correction. + */ + + int intent; + + if (png_get_sRGB(png_ptr, info_ptr, &intent)) + png_set_gamma(png_ptr, screen_gamma, 0.45455); + else + { + double image_gamma; + if (png_get_gAMA(png_ptr, info_ptr, &image_gamma)) + png_set_gamma(png_ptr, screen_gamma, image_gamma); + else + png_set_gamma(png_ptr, screen_gamma, 0.45455); + } + +#ifdef PNG_READ_QUANTIZE_SUPPORTED + /* Quantize RGB files down to 8 bit palette or reduce palettes + * to the number of colors available on your screen. + */ + if (color_type & PNG_COLOR_MASK_COLOR) + { + int num_palette; + png_colorp palette; + + /* This reduces the image to the application supplied palette */ + if (/* We have our own palette */) + { + /* An array of colors to which the image should be quantized */ + png_color std_color_cube[MAX_SCREEN_COLORS]; + + png_set_quantize(png_ptr, std_color_cube, MAX_SCREEN_COLORS, + MAX_SCREEN_COLORS, NULL, 0); + } + /* This reduces the image to the palette supplied in the file */ + else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette)) + { + png_uint_16p histogram = NULL; + + png_get_hIST(png_ptr, info_ptr, &histogram); + + png_set_quantize(png_ptr, palette, num_palette, + max_screen_colors, histogram, 0); + } + } +#endif /* PNG_READ_QUANTIZE_SUPPORTED */ + + /* Invert monochrome files to have 0 as white and 1 as black */ + png_set_invert_mono(png_ptr); + + /* If you want to shift the pixel values from the range [0,255] or + * [0,65535] to the original [0,7] or [0,31], or whatever range the + * colors were originally in: + */ + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT)) + { + png_color_8p sig_bit_p; + + png_get_sBIT(png_ptr, info_ptr, &sig_bit_p); + png_set_shift(png_ptr, sig_bit_p); + } + + /* Flip the RGB pixels to BGR (or RGBA to BGRA) */ + if (color_type & PNG_COLOR_MASK_COLOR) + png_set_bgr(png_ptr); + + /* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ + png_set_swap_alpha(png_ptr); + + /* Swap bytes of 16 bit files to least significant byte first */ + png_set_swap(png_ptr); + + /* Add filler (or alpha) byte (before/after each RGB triplet) */ + png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER); + +#ifdef PNG_READ_INTERLACING_SUPPORTED + /* Turn on interlace handling. REQUIRED if you are not using + * png_read_image(). To see how to handle interlacing passes, + * see the png_read_row() method below: + */ + number_passes = png_set_interlace_handling(png_ptr); +#else + number_passes = 1; +#endif /* PNG_READ_INTERLACING_SUPPORTED */ + + + /* Optional call to gamma correct and add the background to the palette + * and update info structure. REQUIRED if you are expecting libpng to + * update the palette for you (ie you selected such a transform above). + */ + png_read_update_info(png_ptr, info_ptr); + + /* Allocate the memory to hold the image using the fields of info_ptr. */ + + /* The easiest way to read the image: */ + png_bytep row_pointers[height]; + + /* Clear the pointer array */ + for (row = 0; row < height; row++) + row_pointers[row] = NULL; + + for (row = 0; row < height; row++) + row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr, + info_ptr)); + + /* Now it's time to read the image. One of these methods is REQUIRED */ +#ifdef entire /* Read the entire image in one go */ + png_read_image(png_ptr, row_pointers); + +#else no_entire /* Read the image one or more scanlines at a time */ + /* The other way to read images - deal with interlacing: */ + + for (pass = 0; pass < number_passes; pass++) + { +#ifdef single /* Read the image a single row at a time */ + for (y = 0; y < height; y++) + { + png_read_rows(png_ptr, &row_pointers[y], NULL, 1); + } + +#else no_single /* Read the image several rows at a time */ + for (y = 0; y < height; y += number_of_rows) + { +#ifdef sparkle /* Read the image using the "sparkle" effect. */ + png_read_rows(png_ptr, &row_pointers[y], NULL, + number_of_rows); +#else no_sparkle /* Read the image using the "rectangle" effect */ + png_read_rows(png_ptr, NULL, &row_pointers[y], + number_of_rows); +#endif no_sparkle /* Use only one of these two methods */ + } + + /* If you want to display the image after every pass, do so here */ +#endif no_single /* Use only one of these two methods */ + } +#endif no_entire /* Use only one of these two methods */ + + /* Read rest of file, and get additional chunks in info_ptr - REQUIRED */ + png_read_end(png_ptr, info_ptr); +#endif hilevel + + /* At this point you have read the entire image */ + + /* Clean up after the read, and free any memory allocated - REQUIRED */ + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + + /* Close the file */ + fclose(fp); + + /* That's it */ + return (OK); +} + +/* Progressively read a file */ + +int +initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr) +{ + /* Create and initialize the png_struct with the desired error handler + * functions. If you want to use the default stderr and longjump method, + * you can supply NULL for the last three parameters. We also check that + * the library version is compatible in case we are using dynamically + * linked libraries. + */ + *png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, + png_voidp user_error_ptr, user_error_fn, user_warning_fn); + + if (*png_ptr == NULL) + { + *info_ptr = NULL; + return (ERROR); + } + + *info_ptr = png_create_info_struct(png_ptr); + + if (*info_ptr == NULL) + { + png_destroy_read_struct(png_ptr, info_ptr, NULL); + return (ERROR); + } + + if (setjmp(png_jmpbuf((*png_ptr)))) + { + png_destroy_read_struct(png_ptr, info_ptr, NULL); + return (ERROR); + } + + /* This one's new. You will need to provide all three + * function callbacks, even if you aren't using them all. + * If you aren't using all functions, you can specify NULL + * parameters. Even when all three functions are NULL, + * you need to call png_set_progressive_read_fn(). + * These functions shouldn't be dependent on global or + * static variables if you are decoding several images + * simultaneously. You should store stream specific data + * in a separate struct, given as the second parameter, + * and retrieve the pointer from inside the callbacks using + * the function png_get_progressive_ptr(png_ptr). + */ + png_set_progressive_read_fn(*png_ptr, (void *)stream_data, + info_callback, row_callback, end_callback); + + return (OK); +} + +int +process_data(png_structp *png_ptr, png_infop *info_ptr, + png_bytep buffer, png_uint_32 length) +{ + if (setjmp(png_jmpbuf((*png_ptr)))) + { + /* Free the png_ptr and info_ptr memory on error */ + png_destroy_read_struct(png_ptr, info_ptr, NULL); + return (ERROR); + } + + /* This one's new also. Simply give it chunks of data as + * they arrive from the data stream (in order, of course). + * On segmented machines, don't give it any more than 64K. + * The library seems to run fine with sizes of 4K, although + * you can give it much less if necessary (I assume you can + * give it chunks of 1 byte, but I haven't tried with less + * than 256 bytes yet). When this function returns, you may + * want to display any rows that were generated in the row + * callback, if you aren't already displaying them there. + */ + png_process_data(*png_ptr, *info_ptr, buffer, length); + return (OK); +} + +info_callback(png_structp png_ptr, png_infop info) +{ + /* Do any setup here, including setting any of the transformations + * mentioned in the Reading PNG files section. For now, you _must_ + * call either png_start_read_image() or png_read_update_info() + * after all the transformations are set (even if you don't set + * any). You may start getting rows before png_process_data() + * returns, so this is your last chance to prepare for that. + */ +} + +row_callback(png_structp png_ptr, png_bytep new_row, + png_uint_32 row_num, int pass) +{ + /* + * This function is called for every row in the image. If the + * image is interlaced, and you turned on the interlace handler, + * this function will be called for every row in every pass. + * + * In this function you will receive a pointer to new row data from + * libpng called new_row that is to replace a corresponding row (of + * the same data format) in a buffer allocated by your application. + * + * The new row data pointer "new_row" may be NULL, indicating there is + * no new data to be replaced (in cases of interlace loading). + * + * If new_row is not NULL then you need to call + * png_progressive_combine_row() to replace the corresponding row as + * shown below: + */ + + /* Get pointer to corresponding row in our + * PNG read buffer. + */ + png_bytep old_row = ((png_bytep *)our_data)[row_num]; + +#ifdef PNG_READ_INTERLACING_SUPPORTED + /* If both rows are allocated then copy the new row + * data to the corresponding row data. + */ + if ((old_row != NULL) && (new_row != NULL)) + png_progressive_combine_row(png_ptr, old_row, new_row); + + /* + * The rows and passes are called in order, so you don't really + * need the row_num and pass, but I'm supplying them because it + * may make your life easier. + * + * For the non-NULL rows of interlaced images, you must call + * png_progressive_combine_row() passing in the new row and the + * old row, as demonstrated above. You can call this function for + * NULL rows (it will just return) and for non-interlaced images + * (it just does the png_memcpy for you) if it will make the code + * easier. Thus, you can just do this for all cases: + */ + + png_progressive_combine_row(png_ptr, old_row, new_row); + + /* where old_row is what was displayed for previous rows. Note + * that the first pass (pass == 0 really) will completely cover + * the old row, so the rows do not have to be initialized. After + * the first pass (and only for interlaced images), you will have + * to pass the current row as new_row, and the function will combine + * the old row and the new row. + */ +#endif /* PNG_READ_INTERLACING_SUPPORTED */ +} + +end_callback(png_structp png_ptr, png_infop info) +{ + /* This function is called when the whole image has been read, + * including any chunks after the image (up to and including + * the IEND). You will usually have the same info chunk as you + * had in the header, although some data may have been added + * to the comments and time fields. + * + * Most people won't do much here, perhaps setting a flag that + * marks the image as finished. + */ +} + +/* Write a png file */ +void write_png(char *file_name /* , ... other image information ... */) +{ + FILE *fp; + png_structp png_ptr; + png_infop info_ptr; + png_colorp palette; + + /* Open the file */ + fp = fopen(file_name, "wb"); + if (fp == NULL) + return (ERROR); + + /* Create and initialize the png_struct with the desired error handler + * functions. If you want to use the default stderr and longjump method, + * you can supply NULL for the last three parameters. We also check that + * the library version is compatible with the one used at compile time, + * in case we are using dynamically linked libraries. REQUIRED. + */ + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, + png_voidp user_error_ptr, user_error_fn, user_warning_fn); + + if (png_ptr == NULL) + { + fclose(fp); + return (ERROR); + } + + /* Allocate/initialize the image information data. REQUIRED */ + info_ptr = png_create_info_struct(png_ptr); + if (info_ptr == NULL) + { + fclose(fp); + png_destroy_write_struct(&png_ptr, NULL); + return (ERROR); + } + + /* Set error handling. REQUIRED if you aren't supplying your own + * error handling functions in the png_create_write_struct() call. + */ + if (setjmp(png_jmpbuf(png_ptr))) + { + /* If we get here, we had a problem writing the file */ + fclose(fp); + png_destroy_write_struct(&png_ptr, &info_ptr); + return (ERROR); + } + + /* One of the following I/O initialization functions is REQUIRED */ + +#ifdef streams /* I/O initialization method 1 */ + /* Set up the output control if you are using standard C streams */ + png_init_io(png_ptr, fp); + +#else no_streams /* I/O initialization method 2 */ + /* If you are using replacement write functions, instead of calling + * png_init_io() here you would call + */ + png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn, + user_IO_flush_function); + /* where user_io_ptr is a structure you want available to the callbacks */ +#endif no_streams /* Only use one initialization method */ + +#ifdef hilevel + /* This is the easy way. Use it if you already have all the + * image info living in the structure. You could "|" many + * PNG_TRANSFORM flags into the png_transforms integer here. + */ + png_write_png(png_ptr, info_ptr, png_transforms, NULL); + +#else + /* This is the hard way */ + + /* Set the image information here. Width and height are up to 2^31, + * bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on + * the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY, + * PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB, + * or PNG_COLOR_TYPE_RGB_ALPHA. interlace is either PNG_INTERLACE_NONE or + * PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST + * currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. REQUIRED + */ + png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, PNG_COLOR_TYPE_???, + PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + + /* Set the palette if there is one. REQUIRED for indexed-color images */ + palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH + * png_sizeof(png_color)); + /* ... Set palette colors ... */ + png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH); + /* You must not free palette here, because png_set_PLTE only makes a link to + * the palette that you malloced. Wait until you are about to destroy + * the png structure. + */ + + /* Optional significant bit (sBIT) chunk */ + png_color_8 sig_bit; + + /* If we are dealing with a grayscale image then */ + sig_bit.gray = true_bit_depth; + + /* Otherwise, if we are dealing with a color image then */ + sig_bit.red = true_red_bit_depth; + sig_bit.green = true_green_bit_depth; + sig_bit.blue = true_blue_bit_depth; + + /* If the image has an alpha channel then */ + sig_bit.alpha = true_alpha_bit_depth; + + png_set_sBIT(png_ptr, info_ptr, &sig_bit); + + + /* Optional gamma chunk is strongly suggested if you have any guess + * as to the correct gamma of the image. + */ + png_set_gAMA(png_ptr, info_ptr, gamma); + + /* Optionally write comments into the image */ + { + png_text text_ptr[3]; + + char key0[]="Title"; + char text0[]="Mona Lisa"; + text_ptr[0].key = key0; + text_ptr[0].text = text0; + text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE; + text_ptr[0].itxt_length = 0; + text_ptr[0].lang = NULL; + text_ptr[0].lang_key = NULL; + + char key1[]="Author"; + char text1[]="Leonardo DaVinci"; + text_ptr[1].key = key1; + text_ptr[1].text = text1; + text_ptr[1].compression = PNG_TEXT_COMPRESSION_NONE; + text_ptr[1].itxt_length = 0; + text_ptr[1].lang = NULL; + text_ptr[1].lang_key = NULL; + + char key2[]="Description"; + char text2[]=""; + text_ptr[2].key = key2; + text_ptr[2].text = text2; + text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt; + text_ptr[2].itxt_length = 0; + text_ptr[2].lang = NULL; + text_ptr[2].lang_key = NULL; + + png_set_text(write_ptr, write_info_ptr, text_ptr, 3); + } + + /* Other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs */ + + /* Note that if sRGB is present the gAMA and cHRM chunks must be ignored + * on read and, if your application chooses to write them, they must + * be written in accordance with the sRGB profile + */ + + /* Write the file header information. REQUIRED */ + png_write_info(png_ptr, info_ptr); + + /* If you want, you can write the info in two steps, in case you need to + * write your private chunk ahead of PLTE: + * + * png_write_info_before_PLTE(write_ptr, write_info_ptr); + * write_my_chunk(); + * png_write_info(png_ptr, info_ptr); + * + * However, given the level of known- and unknown-chunk support in 1.2.0 + * and up, this should no longer be necessary. + */ + + /* Once we write out the header, the compression type on the text + * chunks gets changed to PNG_TEXT_COMPRESSION_NONE_WR or + * PNG_TEXT_COMPRESSION_zTXt_WR, so it doesn't get written out again + * at the end. + */ + + /* Set up the transformations you want. Note that these are + * all optional. Only call them if you want them. + */ + + /* Invert monochrome pixels */ + png_set_invert_mono(png_ptr); + + /* Shift the pixels up to a legal bit depth and fill in + * as appropriate to correctly scale the image. + */ + png_set_shift(png_ptr, &sig_bit); + + /* Pack pixels into bytes */ + png_set_packing(png_ptr); + + /* Swap location of alpha bytes from ARGB to RGBA */ + png_set_swap_alpha(png_ptr); + + /* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into + * RGB (4 channels -> 3 channels). The second parameter is not used. + */ + png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); + + /* Flip BGR pixels to RGB */ + png_set_bgr(png_ptr); + + /* Swap bytes of 16-bit files to most significant byte first */ + png_set_swap(png_ptr); + + /* Swap bits of 1, 2, 4 bit packed pixel formats */ + png_set_packswap(png_ptr); + + /* Turn on interlace handling if you are not using png_write_image() */ + if (interlacing) + number_passes = png_set_interlace_handling(png_ptr); + + else + number_passes = 1; + + /* The easiest way to write the image (you may have a different memory + * layout, however, so choose what fits your needs best). You need to + * use the first method if you aren't handling interlacing yourself. + */ + png_uint_32 k, height, width; + + /* In this example, "image" is a one-dimensional array of bytes */ + png_byte image[height*width*bytes_per_pixel]; + + png_bytep row_pointers[height]; + + if (height > PNG_UINT_32_MAX/png_sizeof(png_bytep)) + png_error (png_ptr, "Image is too tall to process in memory"); + + /* Set up pointers into your "image" byte array */ + for (k = 0; k < height; k++) + row_pointers[k] = image + k*width*bytes_per_pixel; + + /* One of the following output methods is REQUIRED */ + +#ifdef entire /* Write out the entire image data in one call */ + png_write_image(png_ptr, row_pointers); + + /* The other way to write the image - deal with interlacing */ + +#else no_entire /* Write out the image data by one or more scanlines */ + + /* The number of passes is either 1 for non-interlaced images, + * or 7 for interlaced images. + */ + for (pass = 0; pass < number_passes; pass++) + { + /* Write a few rows at a time. */ + png_write_rows(png_ptr, &row_pointers[first_row], number_of_rows); + + /* If you are only writing one row at a time, this works */ + for (y = 0; y < height; y++) + png_write_rows(png_ptr, &row_pointers[y], 1); + } +#endif no_entire /* Use only one output method */ + + /* You can write optional chunks like tEXt, zTXt, and tIME at the end + * as well. Shouldn't be necessary in 1.2.0 and up as all the public + * chunks are supported and you can use png_set_unknown_chunks() to + * register unknown chunks into the info structure to be written out. + */ + + /* It is REQUIRED to call this to finish writing the rest of the file */ + png_write_end(png_ptr, info_ptr); +#endif hilevel + + /* If you png_malloced a palette, free it here (don't free info_ptr->palette, + * as recommended in versions 1.0.5m and earlier of this example; if + * libpng mallocs info_ptr->palette, libpng will free it). If you + * allocated it with malloc() instead of png_malloc(), use free() instead + * of png_free(). + */ + png_free(png_ptr, palette); + palette = NULL; + + /* Similarly, if you png_malloced any data that you passed in with + * png_set_something(), such as a hist or trans array, free it here, + * when you can be sure that libpng is through with it. + */ + png_free(png_ptr, trans); + trans = NULL; + /* Whenever you use png_free() it is a good idea to set the pointer to + * NULL in case your application inadvertently tries to png_free() it + * again. When png_free() sees a NULL it returns without action, thus + * avoiding the double-free security problem. + */ + + /* Clean up after the write, and free any memory allocated */ + png_destroy_write_struct(&png_ptr, &info_ptr); + + /* Close the file */ + fclose(fp); + + /* That's it */ + return (OK); +} + +#endif /* if 0 */ diff --git a/plugins/AdvaImg/src/LibPNG/libpng-manual.txt b/plugins/AdvaImg/src/LibPNG/libpng-manual.txt new file mode 100644 index 0000000000..82afe70641 --- /dev/null +++ b/plugins/AdvaImg/src/LibPNG/libpng-manual.txt @@ -0,0 +1,4667 @@ +Libpng-manual.txt - A description on how to use and modify libpng + + libpng version 1.5.13 - September 27, 2012 + Updated and distributed by Glenn Randers-Pehrson + + Copyright (c) 1998-2012 Glenn Randers-Pehrson + + This document is released under the libpng license. + For conditions of distribution and use, see the disclaimer + and license in png.h + + Based on: + + libpng versions 0.97, January 1998, through 1.5.13 - September 27, 2012 + Updated and distributed by Glenn Randers-Pehrson + Copyright (c) 1998-2012 Glenn Randers-Pehrson + + libpng 1.0 beta 6 version 0.96 May 28, 1997 + Updated and distributed by Andreas Dilger + Copyright (c) 1996, 1997 Andreas Dilger + + libpng 1.0 beta 2 - version 0.88 January 26, 1996 + For conditions of distribution and use, see copyright + notice in png.h. Copyright (c) 1995, 1996 Guy Eric + Schalnat, Group 42, Inc. + + Updated/rewritten per request in the libpng FAQ + Copyright (c) 1995, 1996 Frank J. T. Wojcik + December 18, 1995 & January 20, 1996 + +I. Introduction + +This file describes how to use and modify the PNG reference library +(known as libpng) for your own use. There are five sections to this +file: introduction, structures, reading, writing, and modification and +configuration notes for various special platforms. In addition to this +file, example.c is a good starting point for using the library, as +it is heavily commented and should include everything most people +will need. We assume that libpng is already installed; see the +INSTALL file for instructions on how to install libpng. + +For examples of libpng usage, see the files "example.c", "pngtest.c", +and the files in the "contrib" directory, all of which are included in +the libpng distribution. + +Libpng was written as a companion to the PNG specification, as a way +of reducing the amount of time and effort it takes to support the PNG +file format in application programs. + +The PNG specification (second edition), November 2003, is available as +a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2003 (E)) at +. It is technically equivalent +to the PNG specification (second edition) but has some additional material. + +The PNG-1.0 specification is available +as RFC 2083 and as a +W3C Recommendation . + +Some additional chunks are described in the special-purpose public chunks +documents at . + +Other information +about PNG, and the latest version of libpng, can be found at the PNG home +page, . + +Most users will not have to modify the library significantly; advanced +users may want to modify it more. All attempts were made to make it as +complete as possible, while keeping the code easy to understand. +Currently, this library only supports C. Support for other languages +is being considered. + +Libpng has been designed to handle multiple sessions at one time, +to be easily modifiable, to be portable to the vast majority of +machines (ANSI, K&R, 16-, 32-, and 64-bit) available, and to be easy +to use. The ultimate goal of libpng is to promote the acceptance of +the PNG file format in whatever way possible. While there is still +work to be done (see the TODO file), libpng should cover the +majority of the needs of its users. + +Libpng uses zlib for its compression and decompression of PNG files. +Further information about zlib, and the latest version of zlib, can +be found at the zlib home page, . +The zlib compression utility is a general purpose utility that is +useful for more than PNG files, and can be used without libpng. +See the documentation delivered with zlib for more details. +You can usually find the source files for the zlib utility wherever you +find the libpng source files. + +Libpng is thread safe, provided the threads are using different +instances of the structures. Each thread should have its own +png_struct and png_info instances, and thus its own image. +Libpng does not protect itself against two threads using the +same instance of a structure. + +II. Structures + +There are two main structures that are important to libpng, png_struct +and png_info. Both are internal structures that are no longer exposed +in the libpng interface (as of libpng 1.5.0). + +The png_info structure is designed to provide information about the +PNG file. At one time, the fields of png_info were intended to be +directly accessible to the user. However, this tended to cause problems +with applications using dynamically loaded libraries, and as a result +a set of interface functions for png_info (the png_get_*() and png_set_*() +functions) was developed, and direct access to the png_info fields was +deprecated.. + +The png_struct structure is the object used by the library to decode a +single image. As of 1.5.0 this structure is also not exposed. + +Almost all libpng APIs require a pointer to a png_struct as the first argument. +Many (in particular the png_set and png_get APIs) also require a pointer +to png_info as the second argument. Some application visible macros +defined in png.h designed for basic data access (reading and writing +integers in the PNG format) don't take a png_info pointer, but it's almost +always safe to assume that a (png_struct*) has to be passed to call an API +function. + +You can have more than one png_info structure associated with an image, +as illustrated in pngtest.c, one for information valid prior to the +IDAT chunks and another (called "end_info" below) for things after them. + +The png.h header file is an invaluable reference for programming with libpng. +And while I'm on the topic, make sure you include the libpng header file: + +#include + +and also (as of libpng-1.5.0) the zlib header file, if you need it: + +#include + +Types + +The png.h header file defines a number of integral types used by the +APIs. Most of these are fairly obvious; for example types corresponding +to integers of particular sizes and types for passing color values. + +One exception is how non-integral numbers are handled. For application +convenience most APIs that take such numbers have C (double) arguments; +however, internally PNG, and libpng, use 32 bit signed integers and encode +the value by multiplying by 100,000. As of libpng 1.5.0 a convenience +macro PNG_FP_1 is defined in png.h along with a type (png_fixed_point) +which is simply (png_int_32). + +All APIs that take (double) arguments also have a matching API that +takes the corresponding fixed point integer arguments. The fixed point +API has the same name as the floating point one with "_fixed" appended. +The actual range of values permitted in the APIs is frequently less than +the full range of (png_fixed_point) (-21474 to +21474). When APIs require +a non-negative argument the type is recorded as png_uint_32 above. Consult +the header file and the text below for more information. + +Special care must be take with sCAL chunk handling because the chunk itself +uses non-integral values encoded as strings containing decimal floating point +numbers. See the comments in the header file. + +Configuration + +The main header file function declarations are frequently protected by C +preprocessing directives of the form: + + #ifdef PNG_feature_SUPPORTED + declare-function + #endif + ... + #ifdef PNG_feature_SUPPORTED + use-function + #endif + +The library can be built without support for these APIs, although a +standard build will have all implemented APIs. Application programs +should check the feature macros before using an API for maximum +portability. From libpng 1.5.0 the feature macros set during the build +of libpng are recorded in the header file "pnglibconf.h" and this file +is always included by png.h. + +If you don't need to change the library configuration from the default, skip to +the next section ("Reading"). + +Notice that some of the makefiles in the 'scripts' directory and (in 1.5.0) all +of the build project files in the 'projects' directory simply copy +scripts/pnglibconf.h.prebuilt to pnglibconf.h. This means that these build +systems do not permit easy auto-configuration of the library - they only +support the default configuration. + +The easiest way to make minor changes to the libpng configuration when +auto-configuration is supported is to add definitions to the command line +using (typically) CPPFLAGS. For example: + +CPPFLAGS=-DPNG_NO_FLOATING_ARITHMETIC + +will change the internal libpng math implementation for gamma correction and +other arithmetic calculations to fixed point, avoiding the need for fast +floating point support. The result can be seen in the generated pnglibconf.h - +make sure it contains the changed feature macro setting. + +If you need to make more extensive configuration changes - more than one or two +feature macro settings - you can either add -DPNG_USER_CONFIG to the build +command line and put a list of feature macro settings in pngusr.h or you can set +DFA_XTRA (a makefile variable) to a file containing the same information in the +form of 'option' settings. + +A. Changing pnglibconf.h + +A variety of methods exist to build libpng. Not all of these support +reconfiguration of pnglibconf.h. To reconfigure pnglibconf.h it must either be +rebuilt from scripts/pnglibconf.dfa using awk or it must be edited by hand. + +Hand editing is achieved by copying scripts/pnglibconf.h.prebuilt to +pnglibconf.h and changing the lines defining the supported features, paying +very close attention to the 'option' information in scripts/pnglibconf.dfa +that describes those features and their requirements. This is easy to get +wrong. + +B. Configuration using DFA_XTRA + +Rebuilding from pnglibconf.dfa is easy if a functioning 'awk', or a later +variant such as 'nawk' or 'gawk', is available. The configure build will +automatically find an appropriate awk and build pnglibconf.h. +The scripts/pnglibconf.mak file contains a set of make rules for doing the +same thing if configure is not used, and many of the makefiles in the scripts +directory use this approach. + +When rebuilding simply write a new file containing changed options and set +DFA_XTRA to the name of this file. This causes the build to append the new file +to the end of scripts/pnglibconf.dfa. The pngusr.dfa file should contain lines +of the following forms: + +everything = off + +This turns all optional features off. Include it at the start of pngusr.dfa to +make it easier to build a minimal configuration. You will need to turn at least +some features on afterward to enable either reading or writing code, or both. + +option feature on +option feature off + +Enable or disable a single feature. This will automatically enable other +features required by a feature that is turned on or disable other features that +require a feature which is turned off. Conflicting settings will cause an error +message to be emitted by awk. + +setting feature default value + +Changes the default value of setting 'feature' to 'value'. There are a small +number of settings listed at the top of pnglibconf.h, they are documented in the +source code. Most of these values have performance implications for the library +but most of them have no visible effect on the API. Some can also be overridden +from the API. + +This method of building a customized pnglibconf.h is illustrated in +contrib/pngminim/*. See the "$(PNGCONF):" target in the makefile and +pngusr.dfa in these directories. + +C. Configuration using PNG_USR_CONFIG + +If -DPNG_USR_CONFIG is added to the CFLAGS when pnglibconf.h is built the file +pngusr.h will automatically be included before the options in +scripts/pnglibconf.dfa are processed. Your pngusr.h file should contain only +macro definitions turning features on or off or setting settings. + +Apart from the global setting "everything = off" all the options listed above +can be set using macros in pngusr.h: + +#define PNG_feature_SUPPORTED + +is equivalent to: + +option feature on + +#define PNG_NO_feature + +is equivalent to: + +option feature off + +#define PNG_feature value + +is equivalent to: + +setting feature default value + +Notice that in both cases, pngusr.dfa and pngusr.h, the contents of the +pngusr file you supply override the contents of scripts/pnglibconf.dfa + +If confusing or incomprehensible behavior results it is possible to +examine the intermediate file pnglibconf.dfn to find the full set of +dependency information for each setting and option. Simply locate the +feature in the file and read the C comments that precede it. + +This method is also illustrated in the contrib/pngminim/* makefiles and +pngusr.h. + +III. Reading + +We'll now walk you through the possible functions to call when reading +in a PNG file sequentially, briefly explaining the syntax and purpose +of each one. See example.c and png.h for more detail. While +progressive reading is covered in the next section, you will still +need some of the functions discussed in this section to read a PNG +file. + +Setup + +You will want to do the I/O initialization(*) before you get into libpng, +so if it doesn't work, you don't have much to undo. Of course, you +will also want to insure that you are, in fact, dealing with a PNG +file. Libpng provides a simple check to see if a file is a PNG file. +To use it, pass in the first 1 to 8 bytes of the file to the function +png_sig_cmp(), and it will return 0 (false) if the bytes match the +corresponding bytes of the PNG signature, or nonzero (true) otherwise. +Of course, the more bytes you pass in, the greater the accuracy of the +prediction. + +If you are intending to keep the file pointer open for use in libpng, +you must ensure you don't read more than 8 bytes from the beginning +of the file, and you also have to make a call to png_set_sig_bytes_read() +with the number of bytes you read from the beginning. Libpng will +then only check the bytes (if any) that your program didn't read. + +(*): If you are not using the standard I/O functions, you will need +to replace them with custom functions. See the discussion under +Customizing libpng. + + + FILE *fp = fopen(file_name, "rb"); + if (!fp) + { + return (ERROR); + } + + fread(header, 1, number, fp); + is_png = !png_sig_cmp(header, 0, number); + + if (!is_png) + { + return (NOT_PNG); + } + + +Next, png_struct and png_info need to be allocated and initialized. In +order to ensure that the size of these structures is correct even with a +dynamically linked libpng, there are functions to initialize and +allocate the structures. We also pass the library version, optional +pointers to error handling functions, and a pointer to a data struct for +use by the error functions, if necessary (the pointer and functions can +be NULL if the default error handlers are to be used). See the section +on Changes to Libpng below regarding the old initialization functions. +The structure allocation functions quietly return NULL if they fail to +create the structure, so your application should check for that. + + png_structp png_ptr = png_create_read_struct + (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, + user_error_fn, user_warning_fn); + + if (!png_ptr) + return (ERROR); + + png_infop info_ptr = png_create_info_struct(png_ptr); + + if (!info_ptr) + { + png_destroy_read_struct(&png_ptr, + (png_infopp)NULL, (png_infopp)NULL); + return (ERROR); + } + +If you want to use your own memory allocation routines, +use a libpng that was built with PNG_USER_MEM_SUPPORTED defined, and use +png_create_read_struct_2() instead of png_create_read_struct(): + + png_structp png_ptr = png_create_read_struct_2 + (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, + user_error_fn, user_warning_fn, (png_voidp) + user_mem_ptr, user_malloc_fn, user_free_fn); + +The error handling routines passed to png_create_read_struct() +and the memory alloc/free routines passed to png_create_struct_2() +are only necessary if you are not using the libpng supplied error +handling and memory alloc/free functions. + +When libpng encounters an error, it expects to longjmp back +to your routine. Therefore, you will need to call setjmp and pass +your png_jmpbuf(png_ptr). If you read the file from different +routines, you will need to update the longjmp buffer every time you enter +a new routine that will call a png_*() function. + +See your documentation of setjmp/longjmp for your compiler for more +information on setjmp/longjmp. See the discussion on libpng error +handling in the Customizing Libpng section below for more information +on the libpng error handling. If an error occurs, and libpng longjmp's +back to your setjmp, you will want to call png_destroy_read_struct() to +free any memory. + + if (setjmp(png_jmpbuf(png_ptr))) + { + png_destroy_read_struct(&png_ptr, &info_ptr, + &end_info); + fclose(fp); + return (ERROR); + } + +Pass (png_infopp)NULL instead of &end_info if you didn't create +an end_info structure. + +If you would rather avoid the complexity of setjmp/longjmp issues, +you can compile libpng with PNG_NO_SETJMP, in which case +errors will result in a call to PNG_ABORT() which defaults to abort(). + +You can #define PNG_ABORT() to a function that does something +more useful than abort(), as long as your function does not +return. + +Now you need to set up the input code. The default for libpng is to +use the C function fread(). If you use this, you will need to pass a +valid FILE * in the function png_init_io(). Be sure that the file is +opened in binary mode. If you wish to handle reading data in another +way, you need not call the png_init_io() function, but you must then +implement the libpng I/O methods discussed in the Customizing Libpng +section below. + + png_init_io(png_ptr, fp); + +If you had previously opened the file and read any of the signature from +the beginning in order to see if this was a PNG file, you need to let +libpng know that there are some bytes missing from the start of the file. + + png_set_sig_bytes(png_ptr, number); + +You can change the zlib compression buffer size to be used while +reading compressed data with + + png_set_compression_buffer_size(png_ptr, buffer_size); + +where the default size is 8192 bytes. Note that the buffer size +is changed immediately and the buffer is reallocated immediately, +instead of setting a flag to be acted upon later. + +If you want CRC errors to be handled in a different manner than +the default, use + + png_set_crc_action(png_ptr, crit_action, ancil_action); + +The values for png_set_crc_action() say how libpng is to handle CRC errors in +ancillary and critical chunks, and whether to use the data contained +therein. Note that it is impossible to "discard" data in a critical +chunk. + +Choices for (int) crit_action are + PNG_CRC_DEFAULT 0 error/quit + PNG_CRC_ERROR_QUIT 1 error/quit + PNG_CRC_WARN_USE 3 warn/use data + PNG_CRC_QUIET_USE 4 quiet/use data + PNG_CRC_NO_CHANGE 5 use the current value + +Choices for (int) ancil_action are + PNG_CRC_DEFAULT 0 error/quit + PNG_CRC_ERROR_QUIT 1 error/quit + PNG_CRC_WARN_DISCARD 2 warn/discard data + PNG_CRC_WARN_USE 3 warn/use data + PNG_CRC_QUIET_USE 4 quiet/use data + PNG_CRC_NO_CHANGE 5 use the current value + +Setting up callback code + +You can set up a callback function to handle any unknown chunks in the +input stream. You must supply the function + + read_chunk_callback(png_structp png_ptr, + png_unknown_chunkp chunk); + { + /* The unknown chunk structure contains your + chunk data, along with similar data for any other + unknown chunks: */ + + png_byte name[5]; + png_byte *data; + png_size_t size; + + /* Note that libpng has already taken care of + the CRC handling */ + + /* put your code here. Search for your chunk in the + unknown chunk structure, process it, and return one + of the following: */ + + return (-n); /* chunk had an error */ + return (0); /* did not recognize */ + return (n); /* success */ + } + +(You can give your function another name that you like instead of +"read_chunk_callback") + +To inform libpng about your function, use + + png_set_read_user_chunk_fn(png_ptr, user_chunk_ptr, + read_chunk_callback); + +This names not only the callback function, but also a user pointer that +you can retrieve with + + png_get_user_chunk_ptr(png_ptr); + +If you call the png_set_read_user_chunk_fn() function, then all unknown +chunks will be saved when read, in case your callback function will need +one or more of them. This behavior can be changed with the +png_set_keep_unknown_chunks() function, described below. + +At this point, you can set up a callback function that will be +called after each row has been read, which you can use to control +a progress meter or the like. It's demonstrated in pngtest.c. +You must supply a function + + void read_row_callback(png_structp png_ptr, + png_uint_32 row, int pass); + { + /* put your code here */ + } + +(You can give it another name that you like instead of "read_row_callback") + +To inform libpng about your function, use + + png_set_read_status_fn(png_ptr, read_row_callback); + +When this function is called the row has already been completely processed and +the 'row' and 'pass' refer to the next row to be handled. For the +non-interlaced case the row that was just handled is simply one less than the +passed in row number, and pass will always be 0. For the interlaced case the +same applies unless the row value is 0, in which case the row just handled was +the last one from one of the preceding passes. Because interlacing may skip a +pass you cannot be sure that the preceding pass is just 'pass-1', if you really +need to know what the last pass is record (row,pass) from the callback and use +the last recorded value each time. + +As with the user transform you can find the output row using the +PNG_ROW_FROM_PASS_ROW macro. + +Unknown-chunk handling + +Now you get to set the way the library processes unknown chunks in the +input PNG stream. Both known and unknown chunks will be read. Normal +behavior is that known chunks will be parsed into information in +various info_ptr members while unknown chunks will be discarded. This +behavior can be wasteful if your application will never use some known +chunk types. To change this, you can call: + + png_set_keep_unknown_chunks(png_ptr, keep, + chunk_list, num_chunks); + keep - 0: default unknown chunk handling + 1: ignore; do not keep + 2: keep only if safe-to-copy + 3: keep even if unsafe-to-copy + + You can use these definitions: + PNG_HANDLE_CHUNK_AS_DEFAULT 0 + PNG_HANDLE_CHUNK_NEVER 1 + PNG_HANDLE_CHUNK_IF_SAFE 2 + PNG_HANDLE_CHUNK_ALWAYS 3 + + chunk_list - list of chunks affected (a byte string, + five bytes per chunk, NULL or '\0' if + num_chunks is 0) + + num_chunks - number of chunks affected; if 0, all + unknown chunks are affected. If nonzero, + only the chunks in the list are affected + +Unknown chunks declared in this way will be saved as raw data onto a +list of png_unknown_chunk structures. If a chunk that is normally +known to libpng is named in the list, it will be handled as unknown, +according to the "keep" directive. If a chunk is named in successive +instances of png_set_keep_unknown_chunks(), the final instance will +take precedence. The IHDR and IEND chunks should not be named in +chunk_list; if they are, libpng will process them normally anyway. +If you know that your application will never make use of some particular +chunks, use PNG_HANDLE_CHUNK_NEVER (or 1) as demonstrated below. + +Here is an example of the usage of png_set_keep_unknown_chunks(), +where the private "vpAg" chunk will later be processed by a user chunk +callback function: + + png_byte vpAg[5]={118, 112, 65, 103, (png_byte) '\0'}; + + #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + png_byte unused_chunks[]= + { + 104, 73, 83, 84, (png_byte) '\0', /* hIST */ + 105, 84, 88, 116, (png_byte) '\0', /* iTXt */ + 112, 67, 65, 76, (png_byte) '\0', /* pCAL */ + 115, 67, 65, 76, (png_byte) '\0', /* sCAL */ + 115, 80, 76, 84, (png_byte) '\0', /* sPLT */ + 116, 73, 77, 69, (png_byte) '\0', /* tIME */ + }; + #endif + + ... + + #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + /* ignore all unknown chunks: */ + png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0); + + /* except for vpAg: */ + png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1); + + /* also ignore unused known chunks: */ + png_set_keep_unknown_chunks(read_ptr, 1, unused_chunks, + (int)sizeof(unused_chunks)/5); + #endif + +User limits + +The PNG specification allows the width and height of an image to be as +large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns. +Since very few applications really need to process such large images, +we have imposed an arbitrary 1-million limit on rows and columns. +Larger images will be rejected immediately with a png_error() call. If +you wish to change this limit, you can use + + png_set_user_limits(png_ptr, width_max, height_max); + +to set your own limits, or use width_max = height_max = 0x7fffffffL +to allow all valid dimensions (libpng may reject some very large images +anyway because of potential buffer overflow conditions). + +You should put this statement after you create the PNG structure and +before calling png_read_info(), png_read_png(), or png_process_data(). + +When writing a PNG datastream, put this statement before calling +png_write_info() or png_write_png(). + +If you need to retrieve the limits that are being applied, use + + width_max = png_get_user_width_max(png_ptr); + height_max = png_get_user_height_max(png_ptr); + +The PNG specification sets no limit on the number of ancillary chunks +allowed in a PNG datastream. You can impose a limit on the total number +of sPLT, tEXt, iTXt, zTXt, and unknown chunks that will be stored, with + + png_set_chunk_cache_max(png_ptr, user_chunk_cache_max); + +where 0x7fffffffL means unlimited. You can retrieve this limit with + + chunk_cache_max = png_get_chunk_cache_max(png_ptr); + +This limit also applies to the number of buffers that can be allocated +by png_decompress_chunk() while decompressing iTXt, zTXt, and iCCP chunks. + +You can also set a limit on the amount of memory that a compressed chunk +other than IDAT can occupy, with + + png_set_chunk_malloc_max(png_ptr, user_chunk_malloc_max); + +and you can retrieve the limit with + + chunk_malloc_max = png_get_chunk_malloc_max(png_ptr); + +Any chunks that would cause either of these limits to be exceeded will +be ignored. + +Information about your system + +If you intend to display the PNG or to incorporate it in other image data you +need to tell libpng information about your display or drawing surface so that +libpng can convert the values in the image to match the display. + +From libpng-1.5.4 this information can be set before reading the PNG file +header. In earlier versions png_set_gamma() existed but behaved incorrectly if +called before the PNG file header had been read and png_set_alpha_mode() did not +exist. + +If you need to support versions prior to libpng-1.5.4 test the version number +as illustrated below using "PNG_LIBPNG_VER >= 10504" and follow the procedures +described in the appropriate manual page. + +You give libpng the encoding expected by your system expressed as a 'gamma' +value. You can also specify a default encoding for the PNG file in +case the required information is missing from the file. By default libpng +assumes that the PNG data matches your system, to keep this default call: + + png_set_gamma(png_ptr, screen_gamma, 1/screen_gamma/*file gamma*/); + +or you can use the fixed point equivalent: + + png_set_gamma_fixed(png_ptr, PNG_FP_1*screen_gamma, PNG_FP_1/screen_gamma); + +If you don't know the gamma for your system it is probably 2.2 - a good +approximation to the IEC standard for display systems (sRGB). If images are +too contrasty or washed out you got the value wrong - check your system +documentation! + +Many systems permit the system gamma to be changed via a lookup table in the +display driver, a few systems, including older Macs, change the response by +default. As of 1.5.4 three special values are available to handle common +situations: + + PNG_DEFAULT_sRGB: Indicates that the system conforms to the IEC 61966-2-1 + standard. This matches almost all systems. + PNG_GAMMA_MAC_18: Indicates that the system is an older (pre Mac OS 10.6) + Apple Macintosh system with the default settings. + PNG_GAMMA_LINEAR: Just the fixed point value for 1.0 - indicates that the + system expects data with no gamma encoding. + +You would use the linear (unencoded) value if you need to process the pixel +values further because this avoids the need to decode and reencode each +component value whenever arithmetic is performed. A lot of graphics software +uses linear values for this reason, often with higher precision component values +to preserve overall accuracy. + +The second thing you may need to tell libpng about is how your system handles +alpha channel information. Some, but not all, PNG files contain an alpha +channel. To display these files correctly you need to compose the data onto a +suitable background, as described in the PNG specification. + +Libpng only supports composing onto a single color (using png_set_background; +see below). Otherwise you must do the composition yourself and, in this case, +you may need to call png_set_alpha_mode: + + #if PNG_LIBPNG_VER >= 10504 + png_set_alpha_mode(png_ptr, mode, screen_gamma); + #else + png_set_gamma(png_ptr, screen_gamma, 1.0/screen_gamma); + #endif + +The screen_gamma value is the same as the argument to png_set_gamma; however, +how it affects the output depends on the mode. png_set_alpha_mode() sets the +file gamma default to 1/screen_gamma, so normally you don't need to call +png_set_gamma. If you need different defaults call png_set_gamma() before +png_set_alpha_mode() - if you call it after it will override the settings made +by png_set_alpha_mode(). + +The mode is as follows: + + PNG_ALPHA_PNG: The data is encoded according to the PNG specification. Red, +green and blue, or gray, components are gamma encoded color +values and are not premultiplied by the alpha value. The +alpha value is a linear measure of the contribution of the +pixel to the corresponding final output pixel. + +You should normally use this format if you intend to perform +color correction on the color values; most, maybe all, color +correction software has no handling for the alpha channel and, +anyway, the math to handle pre-multiplied component values is +unnecessarily complex. + +Before you do any arithmetic on the component values you need +to remove the gamma encoding and multiply out the alpha +channel. See the PNG specification for more detail. It is +important to note that when an image with an alpha channel is +scaled, linear encoded, pre-multiplied component values must +be used! + +The remaining modes assume you don't need to do any further color correction or +that if you do, your color correction software knows all about alpha (it +probably doesn't!) + + PNG_ALPHA_STANDARD: The data libpng produces +is encoded in the standard way +assumed by most correctly written graphics software. +The gamma encoding will be removed by libpng and the +linear component values will be pre-multiplied by the +alpha channel. + +With this format the final image must be re-encoded to +match the display gamma before the image is displayed. +If your system doesn't do that, yet still seems to +perform arithmetic on the pixels without decoding them, +it is broken - check out the modes below. + +With PNG_ALPHA_STANDARD libpng always produces linear +component values, whatever screen_gamma you supply. The +screen_gamma value is, however, used as a default for +the file gamma if the PNG file has no gamma information. + +If you call png_set_gamma() after png_set_alpha_mode() you +will override the linear encoding. Instead the +pre-multiplied pixel values will be gamma encoded but +the alpha channel will still be linear. This may +actually match the requirements of some broken software, +but it is unlikely. + +While linear 8-bit data is often used it has +insufficient precision for any image with a reasonable +dynamic range. To avoid problems, and if your software +supports it, use png_set_expand_16() to force all +components to 16 bits. + + PNG_ALPHA_OPTIMIZED: This mode is the same +as PNG_ALPHA_STANDARD except that +completely opaque pixels are gamma encoded according to +the screen_gamma value. Pixels with alpha less than 1.0 +will still have linear components. + +Use this format if you have control over your +compositing software and so don't do other arithmetic +(such as scaling) on the data you get from libpng. Your +compositing software can simply copy opaque pixels to +the output but still has linear values for the +non-opaque pixels. + +In normal compositing, where the alpha channel encodes +partial pixel coverage (as opposed to broad area +translucency), the inaccuracies of the 8-bit +representation of non-opaque pixels are irrelevant. + +You can also try this format if your software is broken; +it might look better. + + PNG_ALPHA_BROKEN: This is PNG_ALPHA_STANDARD; +however, all component values, +including the alpha channel are gamma encoded. This is +an appropriate format to try if your software, or more +likely hardware, is totally broken, i.e., if it performs +linear arithmetic directly on gamma encoded values. + +In most cases of broken software or hardware the bug in the final display +manifests as a subtle halo around composited parts of the image. You may not +even perceive this as a halo; the composited part of the image may simply appear +separate from the background, as though it had been cut out of paper and pasted +on afterward. + +If you don't have to deal with bugs in software or hardware, or if you can fix +them, there are three recommended ways of using png_set_alpha_mode(): + + png_set_alpha_mode(png_ptr, PNG_ALPHA_PNG, + screen_gamma); + +You can do color correction on the result (libpng does not currently +support color correction internally). When you handle the alpha channel +you need to undo the gamma encoding and multiply out the alpha. + + png_set_alpha_mode(png_ptr, PNG_ALPHA_STANDARD, + screen_gamma); + png_set_expand_16(png_ptr); + +If you are using the high level interface, don't call png_set_expand_16(); +instead pass PNG_TRANSFORM_EXPAND_16 to the interface. + +With this mode you can't do color correction, but you can do arithmetic, +including composition and scaling, on the data without further processing. + + png_set_alpha_mode(png_ptr, PNG_ALPHA_OPTIMIZED, + screen_gamma); + +You can avoid the expansion to 16-bit components with this mode, but you +lose the ability to scale the image or perform other linear arithmetic. +All you can do is compose the result onto a matching output. Since this +mode is libpng-specific you also need to write your own composition +software. + +If you don't need, or can't handle, the alpha channel you can call +png_set_background() to remove it by compositing against a fixed color. Don't +call png_set_strip_alpha() to do this - it will leave spurious pixel values in +transparent parts of this image. + + png_set_background(png_ptr, &background_color, + PNG_BACKGROUND_GAMMA_SCREEN, 0, 1); + +The background_color is an RGB or grayscale value according to the data format +libpng will produce for you. Because you don't yet know the format of the PNG +file, if you call png_set_background at this point you must arrange for the +format produced by libpng to always have 8-bit or 16-bit components and then +store the color as an 8-bit or 16-bit color as appropriate. The color contains +separate gray and RGB component values, so you can let libpng produce gray or +RGB output according to the input format, but low bit depth grayscale images +must always be converted to at least 8-bit format. (Even though low bit depth +grayscale images can't have an alpha channel they can have a transparent +color!) + +You set the transforms you need later, either as flags to the high level +interface or libpng API calls for the low level interface. For reference the +settings and API calls required are: + +8-bit values: + PNG_TRANSFORM_SCALE_16 | PNG_EXPAND + png_set_expand(png_ptr); png_set_scale_16(png_ptr); + + If you must get exactly the same inaccurate results + produced by default in versions prior to libpng-1.5.4, + use PNG_TRANSFORM_STRIP_16 and png_set_strip_16(png_ptr) + instead. + +16-bit values: + PNG_TRANSFORM_EXPAND_16 + png_set_expand_16(png_ptr); + +In either case palette image data will be expanded to RGB. If you just want +color data you can add PNG_TRANSFORM_GRAY_TO_RGB or png_set_gray_to_rgb(png_ptr) +to the list. + +Calling png_set_background before the PNG file header is read will not work +prior to libpng-1.5.4. Because the failure may result in unexpected warnings or +errors it is therefore much safer to call png_set_background after the head has +been read. Unfortunately this means that prior to libpng-1.5.4 it cannot be +used with the high level interface. + +The high-level read interface + +At this point there are two ways to proceed; through the high-level +read interface, or through a sequence of low-level read operations. +You can use the high-level interface if (a) you are willing to read +the entire image into memory, and (b) the input transformations +you want to do are limited to the following set: + + PNG_TRANSFORM_IDENTITY No transformation + PNG_TRANSFORM_SCALE_16 Strip 16-bit samples to + 8-bit accurately + PNG_TRANSFORM_STRIP_16 Chop 16-bit samples to + 8-bit less accurately + PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel + PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit + samples to bytes + PNG_TRANSFORM_PACKSWAP Change order of packed + pixels to LSB first + PNG_TRANSFORM_EXPAND Perform set_expand() + PNG_TRANSFORM_INVERT_MONO Invert monochrome images + PNG_TRANSFORM_SHIFT Normalize pixels to the + sBIT depth + PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA + to BGRA + PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA + to AG + PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity + to transparency + PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples + PNG_TRANSFORM_GRAY_TO_RGB Expand grayscale samples + to RGB (or GA to RGBA) + PNG_TRANSFORM_EXPAND_16 Expand samples to 16 bits + +(This excludes setting a background color, doing gamma transformation, +quantizing, and setting filler.) If this is the case, simply do this: + + png_read_png(png_ptr, info_ptr, png_transforms, NULL) + +where png_transforms is an integer containing the bitwise OR of some +set of transformation flags. This call is equivalent to png_read_info(), +followed the set of transformations indicated by the transform mask, +then png_read_image(), and finally png_read_end(). + +(The final parameter of this call is not yet used. Someday it might point +to transformation parameters required by some future input transform.) + +You must use png_transforms and not call any png_set_transform() functions +when you use png_read_png(). + +After you have called png_read_png(), you can retrieve the image data +with + + row_pointers = png_get_rows(png_ptr, info_ptr); + +where row_pointers is an array of pointers to the pixel data for each row: + + png_bytep row_pointers[height]; + +If you know your image size and pixel size ahead of time, you can allocate +row_pointers prior to calling png_read_png() with + + if (height > PNG_UINT_32_MAX/png_sizeof(png_byte)) + png_error (png_ptr, + "Image is too tall to process in memory"); + + if (width > PNG_UINT_32_MAX/pixel_size) + png_error (png_ptr, + "Image is too wide to process in memory"); + + row_pointers = png_malloc(png_ptr, + height*png_sizeof(png_bytep)); + + for (int i=0; i) and +png_get_(png_ptr, info_ptr, ...) functions return non-zero if the +data has been read, or zero if it is missing. The parameters to the +png_get_ are set directly if they are simple data types, or a +pointer into the info_ptr is returned for any complex types. + +The colorspace data from gAMA, cHRM, sRGB, iCCP, and sBIT chunks +is simply returned to give the application information about how the +image was encoded. Libpng itself only does transformations using the file +gamma when combining semitransparent pixels with the background color. + + png_get_PLTE(png_ptr, info_ptr, &palette, + &num_palette); + + palette - the palette for the file + (array of png_color) + + num_palette - number of entries in the palette + + png_get_gAMA(png_ptr, info_ptr, &file_gamma); + png_get_gAMA_fixed(png_ptr, info_ptr, &int_file_gamma); + + file_gamma - the gamma at which the file was + written (PNG_INFO_gAMA) + + int_file_gamma - 100,000 times the gamma at which the + file is written + + png_get_cHRM(png_ptr, info_ptr, &white_x, &white_y, &red_x, + &red_y, &green_x, &green_y, &blue_x, &blue_y) + png_get_cHRM_XYZ(png_ptr, info_ptr, &red_X, &red_Y, &red_Z, &green_X, + &green_Y, &green_Z, &blue_X, &blue_Y, &blue_Z) + png_get_cHRM_fixed(png_ptr, info_ptr, &int_white_x, &int_white_y, + &int_red_x, &int_red_y, &int_green_x, &int_green_y, + &int_blue_x, &int_blue_y) + png_get_cHRM_XYZ_fixed(png_ptr, info_ptr, &int_red_X, &int_red_Y, + &int_red_Z, &int_green_X, &int_green_Y, &int_green_Z, + &int_blue_X, &int_blue_Y, &int_blue_Z) + + {white,red,green,blue}_{x,y} + A color space encoding specified using the + chromaticities of the end points and the + white point. (PNG_INFO_cHRM) + + {red,green,blue}_{X,Y,Z} + A color space encoding specified using the encoding end + points - the CIE tristimulus specification of the intended + color of the red, green and blue channels in the PNG RGB + data. The white point is simply the sum of the three end + points. (PNG_INFO_cHRM) + + png_get_sRGB(png_ptr, info_ptr, &srgb_intent); + + file_srgb_intent - the rendering intent (PNG_INFO_sRGB) + The presence of the sRGB chunk + means that the pixel data is in the + sRGB color space. This chunk also + implies specific values of gAMA and + cHRM. + + png_get_iCCP(png_ptr, info_ptr, &name, + &compression_type, &profile, &proflen); + + name - The profile name. + + compression_type - The compression type; always + PNG_COMPRESSION_TYPE_BASE for PNG 1.0. + You may give NULL to this argument to + ignore it. + + profile - International Color Consortium color + profile data. May contain NULs. + + proflen - length of profile data in bytes. + + png_get_sBIT(png_ptr, info_ptr, &sig_bit); + + sig_bit - the number of significant bits for + (PNG_INFO_sBIT) each of the gray, + red, green, and blue channels, + whichever are appropriate for the + given color type (png_color_16) + + png_get_tRNS(png_ptr, info_ptr, &trans_alpha, + &num_trans, &trans_color); + + trans_alpha - array of alpha (transparency) + entries for palette (PNG_INFO_tRNS) + + num_trans - number of transparent entries + (PNG_INFO_tRNS) + + trans_color - graylevel or color sample values of + the single transparent color for + non-paletted images (PNG_INFO_tRNS) + + png_get_hIST(png_ptr, info_ptr, &hist); + (PNG_INFO_hIST) + + hist - histogram of palette (array of + png_uint_16) + + png_get_tIME(png_ptr, info_ptr, &mod_time); + + mod_time - time image was last modified + (PNG_VALID_tIME) + + png_get_bKGD(png_ptr, info_ptr, &background); + + background - background color (of type + png_color_16p) (PNG_VALID_bKGD) + valid 16-bit red, green and blue + values, regardless of color_type + + num_comments = png_get_text(png_ptr, info_ptr, + &text_ptr, &num_text); + + num_comments - number of comments + + text_ptr - array of png_text holding image + comments + + text_ptr[i].compression - type of compression used + on "text" PNG_TEXT_COMPRESSION_NONE + PNG_TEXT_COMPRESSION_zTXt + PNG_ITXT_COMPRESSION_NONE + PNG_ITXT_COMPRESSION_zTXt + + text_ptr[i].key - keyword for comment. Must contain + 1-79 characters. + + text_ptr[i].text - text comments for current + keyword. Can be empty. + + text_ptr[i].text_length - length of text string, + after decompression, 0 for iTXt + + text_ptr[i].itxt_length - length of itxt string, + after decompression, 0 for tEXt/zTXt + + text_ptr[i].lang - language of comment (empty + string for unknown). + + text_ptr[i].lang_key - keyword in UTF-8 + (empty string for unknown). + + Note that the itxt_length, lang, and lang_key + members of the text_ptr structure only exist when the + library is built with iTXt chunk support. Prior to + libpng-1.4.0 the library was built by default without + iTXt support. Also note that when iTXt is supported, + they contain NULL pointers when the "compression" + field contains PNG_TEXT_COMPRESSION_NONE or + PNG_TEXT_COMPRESSION_zTXt. + + num_text - number of comments (same as + num_comments; you can put NULL here + to avoid the duplication) + + Note while png_set_text() will accept text, language, + and translated keywords that can be NULL pointers, the + structure returned by png_get_text will always contain + regular zero-terminated C strings. They might be + empty strings but they will never be NULL pointers. + + num_spalettes = png_get_sPLT(png_ptr, info_ptr, + &palette_ptr); + + num_spalettes - number of sPLT chunks read. + + palette_ptr - array of palette structures holding + contents of one or more sPLT chunks + read. + + png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y, + &unit_type); + + offset_x - positive offset from the left edge + of the screen (can be negative) + + offset_y - positive offset from the top edge + of the screen (can be negative) + + unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER + + png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, + &unit_type); + + res_x - pixels/unit physical resolution in + x direction + + res_y - pixels/unit physical resolution in + x direction + + unit_type - PNG_RESOLUTION_UNKNOWN, + PNG_RESOLUTION_METER + + png_get_sCAL(png_ptr, info_ptr, &unit, &width, + &height) + + unit - physical scale units (an integer) + + width - width of a pixel in physical scale units + + height - height of a pixel in physical scale units + (width and height are doubles) + + png_get_sCAL_s(png_ptr, info_ptr, &unit, &width, + &height) + + unit - physical scale units (an integer) + + width - width of a pixel in physical scale units + (expressed as a string) + + height - height of a pixel in physical scale units + (width and height are strings like "2.54") + + num_unknown_chunks = png_get_unknown_chunks(png_ptr, + info_ptr, &unknowns) + + unknowns - array of png_unknown_chunk + structures holding unknown chunks + + unknowns[i].name - name of unknown chunk + + unknowns[i].data - data of unknown chunk + + unknowns[i].size - size of unknown chunk's data + + unknowns[i].location - position of chunk in file + + The value of "i" corresponds to the order in which the + chunks were read from the PNG file or inserted with the + png_set_unknown_chunks() function. + + The value of "location" is a bitwise "or" of + + PNG_HAVE_IHDR (0x01) + PNG_HAVE_PLTE (0x02) + PNG_AFTER_IDAT (0x08) + +The data from the pHYs chunk can be retrieved in several convenient +forms: + + res_x = png_get_x_pixels_per_meter(png_ptr, + info_ptr) + + res_y = png_get_y_pixels_per_meter(png_ptr, + info_ptr) + + res_x_and_y = png_get_pixels_per_meter(png_ptr, + info_ptr) + + res_x = png_get_x_pixels_per_inch(png_ptr, + info_ptr) + + res_y = png_get_y_pixels_per_inch(png_ptr, + info_ptr) + + res_x_and_y = png_get_pixels_per_inch(png_ptr, + info_ptr) + + aspect_ratio = png_get_pixel_aspect_ratio(png_ptr, + info_ptr) + + Each of these returns 0 [signifying "unknown"] if + the data is not present or if res_x is 0; + res_x_and_y is 0 if res_x != res_y + + Note that because of the way the resolutions are + stored internally, the inch conversions won't + come out to exactly even number. For example, + 72 dpi is stored as 0.28346 pixels/meter, and + when this is retrieved it is 71.9988 dpi, so + be sure to round the returned value appropriately + if you want to display a reasonable-looking result. + +The data from the oFFs chunk can be retrieved in several convenient +forms: + + x_offset = png_get_x_offset_microns(png_ptr, info_ptr); + + y_offset = png_get_y_offset_microns(png_ptr, info_ptr); + + x_offset = png_get_x_offset_inches(png_ptr, info_ptr); + + y_offset = png_get_y_offset_inches(png_ptr, info_ptr); + + Each of these returns 0 [signifying "unknown" if both + x and y are 0] if the data is not present or if the + chunk is present but the unit is the pixel. The + remark about inexact inch conversions applies here + as well, because a value in inches can't always be + converted to microns and back without some loss + of precision. + +For more information, see the +PNG specification for chunk contents. Be careful with trusting +rowbytes, as some of the transformations could increase the space +needed to hold a row (expand, filler, gray_to_rgb, etc.). +See png_read_update_info(), below. + +A quick word about text_ptr and num_text. PNG stores comments in +keyword/text pairs, one pair per chunk, with no limit on the number +of text chunks, and a 2^31 byte limit on their size. While there are +suggested keywords, there is no requirement to restrict the use to these +strings. It is strongly suggested that keywords and text be sensible +to humans (that's the point), so don't use abbreviations. Non-printing +symbols are not allowed. See the PNG specification for more details. +There is also no requirement to have text after the keyword. + +Keywords should be limited to 79 Latin-1 characters without leading or +trailing spaces, but non-consecutive spaces are allowed within the +keyword. It is possible to have the same keyword any number of times. +The text_ptr is an array of png_text structures, each holding a +pointer to a language string, a pointer to a keyword and a pointer to +a text string. The text string, language code, and translated +keyword may be empty or NULL pointers. The keyword/text +pairs are put into the array in the order that they are received. +However, some or all of the text chunks may be after the image, so, to +make sure you have read all the text chunks, don't mess with these +until after you read the stuff after the image. This will be +mentioned again below in the discussion that goes with png_read_end(). + +Input transformations + +After you've read the header information, you can set up the library +to handle any special transformations of the image data. The various +ways to transform the data will be described in the order that they +should occur. This is important, as some of these change the color +type and/or bit depth of the data, and some others only work on +certain color types and bit depths. + +Transformations you request are ignored if they don't have any meaning for a +particular input data format. However some transformations can have an effect +as a result of a previous transformation. If you specify a contradictory set of +transformations, for example both adding and removing the alpha channel, you +cannot predict the final result. + +The color used for the transparency values should be supplied in the same +format/depth as the current image data. It is stored in the same format/depth +as the image data in a tRNS chunk, so this is what libpng expects for this data. + +The color used for the background value depends on the need_expand argument as +described below. + +Data will be decoded into the supplied row buffers packed into bytes +unless the library has been told to transform it into another format. +For example, 4 bit/pixel paletted or grayscale data will be returned +2 pixels/byte with the leftmost pixel in the high-order bits of the +byte, unless png_set_packing() is called. 8-bit RGB data will be stored +in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha() +is called to insert filler bytes, either before or after each RGB triplet. +16-bit RGB data will be returned RRGGBB RRGGBB, with the most significant +byte of the color value first, unless png_set_scale_16() is called to +transform it to regular RGB RGB triplets, or png_set_filler() or +png_set_add alpha() is called to insert filler bytes, either before or +after each RRGGBB triplet. Similarly, 8-bit or 16-bit grayscale data can +be modified with png_set_filler(), png_set_add_alpha(), png_set_strip_16(), +or png_set_scale_16(). + +The following code transforms grayscale images of less than 8 to 8 bits, +changes paletted images to RGB, and adds a full alpha channel if there is +transparency information in a tRNS chunk. This is most useful on +grayscale images with bit depths of 2 or 4 or if there is a multiple-image +viewing application that wishes to treat all images in the same way. + + if (color_type == PNG_COLOR_TYPE_PALETTE) + png_set_palette_to_rgb(png_ptr); + + if (png_get_valid(png_ptr, info_ptr, + PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr); + + if (color_type == PNG_COLOR_TYPE_GRAY && + bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png_ptr); + +The first two functions are actually aliases for png_set_expand(), added +in libpng version 1.0.4, with the function names expanded to improve code +readability. In some future version they may actually do different +things. + +As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() was +added. It expands the sample depth without changing tRNS to alpha. + +As of libpng version 1.5.2, png_set_expand_16() was added. It behaves as +png_set_expand(); however, the resultant channels have 16 bits rather than 8. +Use this when the output color or gray channels are made linear to avoid fairly +severe accuracy loss. + + if (bit_depth < 16) + png_set_expand_16(png_ptr); + +PNG can have files with 16 bits per channel. If you only can handle +8 bits per channel, this will strip the pixels down to 8-bit. + + if (bit_depth == 16) +#if PNG_LIBPNG_VER >= 10504 + png_set_scale_16(png_ptr); +#else + png_set_strip_16(png_ptr); +#endif + +(The more accurate "png_set_scale_16()" API became available in libpng version +1.5.4). + +If you need to process the alpha channel on the image separately from the image +data (for example if you convert it to a bitmap mask) it is possible to have +libpng strip the channel leaving just RGB or gray data: + + if (color_type & PNG_COLOR_MASK_ALPHA) + png_set_strip_alpha(png_ptr); + +If you strip the alpha channel you need to find some other way of dealing with +the information. If, instead, you want to convert the image to an opaque +version with no alpha channel use png_set_background; see below. + +As of libpng version 1.5.2, almost all useful expansions are supported, the +major ommissions are conversion of grayscale to indexed images (which can be +done trivially in the application) and conversion of indexed to grayscale (which +can be done by a trivial manipulation of the palette.) + +In the following table, the 01 means grayscale with depth<8, 31 means +indexed with depth<8, other numerals represent the color type, "T" means +the tRNS chunk is present, A means an alpha channel is present, and O +means tRNS or alpha is present but all pixels in the image are opaque. + + FROM 01 31 0 0T 0O 2 2T 2O 3 3T 3O 4A 4O 6A 6O + TO + 01 - [G] - - - - - - - - - - - - - + 31 [Q] Q [Q] [Q] [Q] Q Q Q Q Q Q [Q] [Q] Q Q + 0 1 G + . . G G G G G G B B GB GB + 0T lt Gt t + . Gt G G Gt G G Bt Bt GBt GBt + 0O lt Gt t . + Gt Gt G Gt Gt G Bt Bt GBt GBt + 2 C P C C C + . . C - - CB CB B B + 2T Ct - Ct C C t + t - - - CBt CBt Bt Bt + 2O Ct - Ct C C t t + - - - CBt CBt Bt Bt + 3 [Q] p [Q] [Q] [Q] Q Q Q + . . [Q] [Q] Q Q + 3T [Qt] p [Qt][Q] [Q] Qt Qt Qt t + t [Qt][Qt] Qt Qt + 3O [Qt] p [Qt][Q] [Q] Qt Qt Qt t t + [Qt][Qt] Qt Qt + 4A lA G A T T GA GT GT GA GT GT + BA G GBA + 4O lA GBA A T T GA GT GT GA GT GT BA + GBA G + 6A CA PA CA C C A T tT PA P P C CBA + BA + 6O CA PBA CA C C A tT T PA P P CBA C BA + + +Within the matrix, + "+" identifies entries where 'from' and 'to' are the same. + "-" means the transformation is not supported. + "." means nothing is necessary (a tRNS chunk can just be ignored). + "t" means the transformation is obtained by png_set_tRNS. + "A" means the transformation is obtained by png_set_add_alpha(). + "X" means the transformation is obtained by png_set_expand(). + "1" means the transformation is obtained by + png_set_expand_gray_1_2_4_to_8() (and by png_set_expand() + if there is no transparency in the original or the final + format). + "C" means the transformation is obtained by png_set_gray_to_rgb(). + "G" means the transformation is obtained by png_set_rgb_to_gray(). + "P" means the transformation is obtained by + png_set_expand_palette_to_rgb(). + "p" means the transformation is obtained by png_set_packing(). + "Q" means the transformation is obtained by png_set_quantize(). + "T" means the transformation is obtained by + png_set_tRNS_to_alpha(). + "B" means the transformation is obtained by + png_set_background(), or png_strip_alpha(). + +When an entry has multiple transforms listed all are required to cause the +right overall transformation. When two transforms are separated by a comma +either will do the job. When transforms are enclosed in [] the transform should +do the job but this is currently unimplemented - a different format will result +if the suggested transformations are used. + +In PNG files, the alpha channel in an image +is the level of opacity. If you need the alpha channel in an image to +be the level of transparency instead of opacity, you can invert the +alpha channel (or the tRNS chunk data) after it's read, so that 0 is +fully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bit +images) is fully transparent, with + + png_set_invert_alpha(png_ptr); + +PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as +they can, resulting in, for example, 8 pixels per byte for 1 bit +files. This code expands to 1 pixel per byte without changing the +values of the pixels: + + if (bit_depth < 8) + png_set_packing(png_ptr); + +PNG files have possible bit depths of 1, 2, 4, 8, and 16. All pixels +stored in a PNG image have been "scaled" or "shifted" up to the next +higher possible bit depth (e.g. from 5 bits/sample in the range [0,31] +to 8 bits/sample in the range [0, 255]). However, it is also possible +to convert the PNG pixel data back to the original bit depth of the +image. This call reduces the pixels back down to the original bit depth: + + png_color_8p sig_bit; + + if (png_get_sBIT(png_ptr, info_ptr, &sig_bit)) + png_set_shift(png_ptr, sig_bit); + +PNG files store 3-color pixels in red, green, blue order. This code +changes the storage of the pixels to blue, green, red: + + if (color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_RGB_ALPHA) + png_set_bgr(png_ptr); + +PNG files store RGB pixels packed into 3 or 6 bytes. This code expands them +into 4 or 8 bytes for windowing systems that need them in this format: + + if (color_type == PNG_COLOR_TYPE_RGB) + png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE); + +where "filler" is the 8 or 16-bit number to fill with, and the location is +either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether +you want the filler before the RGB or after. This transformation +does not affect images that already have full alpha channels. To add an +opaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER which +will generate RGBA pixels. + +Note that png_set_filler() does not change the color type. If you want +to do that, you can add a true alpha channel with + + if (color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_GRAY) + png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER); + +where "filler" contains the alpha value to assign to each pixel. +This function was added in libpng-1.2.7. + +If you are reading an image with an alpha channel, and you need the +data as ARGB instead of the normal PNG format RGBA: + + if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) + png_set_swap_alpha(png_ptr); + +For some uses, you may want a grayscale image to be represented as +RGB. This code will do that conversion: + + if (color_type == PNG_COLOR_TYPE_GRAY || + color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + png_set_gray_to_rgb(png_ptr); + +Conversely, you can convert an RGB or RGBA image to grayscale or grayscale +with alpha. + + if (color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_RGB_ALPHA) + png_set_rgb_to_gray(png_ptr, error_action, + double red_weight, double green_weight); + + error_action = 1: silently do the conversion + + error_action = 2: issue a warning if the original + image has any pixel where + red != green or red != blue + + error_action = 3: issue an error and abort the + conversion if the original + image has any pixel where + red != green or red != blue + + red_weight: weight of red component + + green_weight: weight of green component + If either weight is negative, default + weights are used. + +In the corresponding fixed point API the red_weight and green_weight values are +simply scaled by 100,000: + + png_set_rgb_to_gray(png_ptr, error_action, + png_fixed_point red_weight, + png_fixed_point green_weight); + +If you have set error_action = 1 or 2, you can +later check whether the image really was gray, after processing +the image rows, with the png_get_rgb_to_gray_status(png_ptr) function. +It will return a png_byte that is zero if the image was gray or +1 if there were any non-gray pixels. Background and sBIT data +will be silently converted to grayscale, using the green channel +data for sBIT, regardless of the error_action setting. + +The default values come from the PNG file cHRM chunk if present; otherwise, the +defaults correspond to the ITU-R recommendation 709, and also the sRGB color +space, as recommended in the Charles Poynton's Colour FAQ, +, in section 9: + + + + Y = 0.2126 * R + 0.7152 * G + 0.0722 * B + +Previous versions of this document, 1998 through 2002, recommended a slightly +different formula: + + Y = 0.212671 * R + 0.715160 * G + 0.072169 * B + +Libpng uses an integer approximation: + + Y = (6968 * R + 23434 * G + 2366 * B)/32768 + +The calculation is done in a linear colorspace, if the image gamma +can be determined. + +The png_set_background() function has been described already; it tells libpng to +composite images with alpha or simple transparency against the supplied +background color. For compatibility with versions of libpng earlier than +libpng-1.5.4 it is recommended that you call the function after reading the file +header, even if you don't want to use the color in a bKGD chunk, if one exists. + +If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid), +you may use this color, or supply another color more suitable for +the current display (e.g., the background color from a web page). You +need to tell libpng how the color is represented, both the format of the +component values in the color (the number of bits) and the gamma encoding of the +color. The function takes two arguments, background_gamma_mode and need_expand +to convey this information; however, only two combinations are likely to be +useful: + + png_color_16 my_background; + png_color_16p image_background; + + if (png_get_bKGD(png_ptr, info_ptr, &image_background)) + png_set_background(png_ptr, image_background, + PNG_BACKGROUND_GAMMA_FILE, 1/*needs to be expanded*/, 1); + else + png_set_background(png_ptr, &my_background, + PNG_BACKGROUND_GAMMA_SCREEN, 0/*do not expand*/, 1); + +The second call was described above - my_background is in the format of the +final, display, output produced by libpng. Because you now know the format of +the PNG it is possible to avoid the need to choose either 8-bit or 16-bit +output and to retain palette images (the palette colors will be modified +appropriately and the tRNS chunk removed.) However, if you are doing this, +take great care not to ask for transformations without checking first that +they apply! + +In the first call the background color has the original bit depth and color type +of the PNG file. So, for palette images the color is supplied as a palette +index and for low bit greyscale images the color is a reduced bit value in +image_background->gray. + +If you didn't call png_set_gamma() before reading the file header, for example +if you need your code to remain compatible with older versions of libpng prior +to libpng-1.5.4, this is the place to call it. + +Do not call it if you called png_set_alpha_mode(); doing so will damage the +settings put in place by png_set_alpha_mode(). (If png_set_alpha_mode() is +supported then you can certainly do png_set_gamma() before reading the PNG +header.) + +This API unconditionally sets the screen and file gamma values, so it will +override the value in the PNG file unless it is called before the PNG file +reading starts. For this reason you must always call it with the PNG file +value when you call it in this position: + + if (png_get_gAMA(png_ptr, info_ptr, &file_gamma)) + png_set_gamma(png_ptr, screen_gamma, file_gamma); + + else + png_set_gamma(png_ptr, screen_gamma, 0.45455); + +If you need to reduce an RGB file to a paletted file, or if a paletted +file has more entries then will fit on your screen, png_set_quantize() +will do that. Note that this is a simple match quantization that merely +finds the closest color available. This should work fairly well with +optimized palettes, but fairly badly with linear color cubes. If you +pass a palette that is larger than maximum_colors, the file will +reduce the number of colors in the palette so it will fit into +maximum_colors. If there is a histogram, libpng will use it to make +more intelligent choices when reducing the palette. If there is no +histogram, it may not do as good a job. + + if (color_type & PNG_COLOR_MASK_COLOR) + { + if (png_get_valid(png_ptr, info_ptr, + PNG_INFO_PLTE)) + { + png_uint_16p histogram = NULL; + + png_get_hIST(png_ptr, info_ptr, + &histogram); + png_set_quantize(png_ptr, palette, num_palette, + max_screen_colors, histogram, 1); + } + + else + { + png_color std_color_cube[MAX_SCREEN_COLORS] = + { ... colors ... }; + + png_set_quantize(png_ptr, std_color_cube, + MAX_SCREEN_COLORS, MAX_SCREEN_COLORS, + NULL,0); + } + } + +PNG files describe monochrome as black being zero and white being one. +The following code will reverse this (make black be one and white be +zero): + + if (bit_depth == 1 && color_type == PNG_COLOR_TYPE_GRAY) + png_set_invert_mono(png_ptr); + +This function can also be used to invert grayscale and gray-alpha images: + + if (color_type == PNG_COLOR_TYPE_GRAY || + color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + png_set_invert_mono(png_ptr); + +PNG files store 16-bit pixels in network byte order (big-endian, +ie. most significant bits first). This code changes the storage to the +other way (little-endian, i.e. least significant bits first, the +way PCs store them): + + if (bit_depth == 16) + png_set_swap(png_ptr); + +If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you +need to change the order the pixels are packed into bytes, you can use: + + if (bit_depth < 8) + png_set_packswap(png_ptr); + +Finally, you can write your own transformation function if none of +the existing ones meets your needs. This is done by setting a callback +with + + png_set_read_user_transform_fn(png_ptr, + read_transform_fn); + +You must supply the function + + void read_transform_fn(png_structp png_ptr, png_row_infop + row_info, png_bytep data) + +See pngtest.c for a working example. Your function will be called +after all of the other transformations have been processed. Take care with +interlaced images if you do the interlace yourself - the width of the row is the +width in 'row_info', not the overall image width. + +If supported, libpng provides two information routines that you can use to find +where you are in processing the image: + + png_get_current_pass_number(png_structp png_ptr); + png_get_current_row_number(png_structp png_ptr); + +Don't try using these outside a transform callback - firstly they are only +supported if user transforms are supported, secondly they may well return +unexpected results unless the row is actually being processed at the moment they +are called. + +With interlaced +images the value returned is the row in the input sub-image image. Use +PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to +find the output pixel (x,y) given an interlaced sub-image pixel (row,col,pass). + +The discussion of interlace handling above contains more information on how to +use these values. + +You can also set up a pointer to a user structure for use by your +callback function, and you can inform libpng that your transform +function will change the number of channels or bit depth with the +function + + png_set_user_transform_info(png_ptr, user_ptr, + user_depth, user_channels); + +The user's application, not libpng, is responsible for allocating and +freeing any memory required for the user structure. + +You can retrieve the pointer via the function +png_get_user_transform_ptr(). For example: + + voidp read_user_transform_ptr = + png_get_user_transform_ptr(png_ptr); + +The last thing to handle is interlacing; this is covered in detail below, +but you must call the function here if you want libpng to handle expansion +of the interlaced image. + + number_of_passes = png_set_interlace_handling(png_ptr); + +After setting the transformations, libpng can update your png_info +structure to reflect any transformations you've requested with this +call. + + png_read_update_info(png_ptr, info_ptr); + +This is most useful to update the info structure's rowbytes +field so you can use it to allocate your image memory. This function +will also update your palette with the correct screen_gamma and +background if these have been given with the calls above. You may +only call png_read_update_info() once with a particular info_ptr. + +After you call png_read_update_info(), you can allocate any +memory you need to hold the image. The row data is simply +raw byte data for all forms of images. As the actual allocation +varies among applications, no example will be given. If you +are allocating one large chunk, you will need to build an +array of pointers to each row, as it will be needed for some +of the functions below. + +Remember: Before you call png_read_update_info(), the png_get_*() +functions return the values corresponding to the original PNG image. +After you call png_read_update_info the values refer to the image +that libpng will output. Consequently you must call all the png_set_ +functions before you call png_read_update_info(). This is particularly +important for png_set_interlace_handling() - if you are going to call +png_read_update_info() you must call png_set_interlace_handling() before +it unless you want to receive interlaced output. + +Reading image data + +After you've allocated memory, you can read the image data. +The simplest way to do this is in one function call. If you are +allocating enough memory to hold the whole image, you can just +call png_read_image() and libpng will read in all the image data +and put it in the memory area supplied. You will need to pass in +an array of pointers to each row. + +This function automatically handles interlacing, so you don't +need to call png_set_interlace_handling() (unless you call +png_read_update_info()) or call this function multiple times, or any +of that other stuff necessary with png_read_rows(). + + png_read_image(png_ptr, row_pointers); + +where row_pointers is: + + png_bytep row_pointers[height]; + +You can point to void or char or whatever you use for pixels. + +If you don't want to read in the whole image at once, you can +use png_read_rows() instead. If there is no interlacing (check +interlace_type == PNG_INTERLACE_NONE), this is simple: + + png_read_rows(png_ptr, row_pointers, NULL, + number_of_rows); + +where row_pointers is the same as in the png_read_image() call. + +If you are doing this just one row at a time, you can do this with +a single row_pointer instead of an array of row_pointers: + + png_bytep row_pointer = row; + png_read_row(png_ptr, row_pointer, NULL); + +If the file is interlaced (interlace_type != 0 in the IHDR chunk), things +get somewhat harder. The only current (PNG Specification version 1.2) +interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7); +a somewhat complicated 2D interlace scheme, known as Adam7, that +breaks down an image into seven smaller images of varying size, based +on an 8x8 grid. This number is defined (from libpng 1.5) as +PNG_INTERLACE_ADAM7_PASSES in png.h + +libpng can fill out those images or it can give them to you "as is". +It is almost always better to have libpng handle the interlacing for you. +If you want the images filled out, there are two ways to do that. The one +mentioned in the PNG specification is to expand each pixel to cover +those pixels that have not been read yet (the "rectangle" method). +This results in a blocky image for the first pass, which gradually +smooths out as more pixels are read. The other method is the "sparkle" +method, where pixels are drawn only in their final locations, with the +rest of the image remaining whatever colors they were initialized to +before the start of the read. The first method usually looks better, +but tends to be slower, as there are more pixels to put in the rows. + +If, as is likely, you want libpng to expand the images, call this before +calling png_start_read_image() or png_read_update_info(): + + if (interlace_type == PNG_INTERLACE_ADAM7) + number_of_passes + = png_set_interlace_handling(png_ptr); + +This will return the number of passes needed. Currently, this is seven, +but may change if another interlace type is added. This function can be +called even if the file is not interlaced, where it will return one pass. +You then need to read the whole image 'number_of_passes' times. Each time +will distribute the pixels from the current pass to the correct place in +the output image, so you need to supply the same rows to png_read_rows in +each pass. + +If you are not going to display the image after each pass, but are +going to wait until the entire image is read in, use the sparkle +effect. This effect is faster and the end result of either method +is exactly the same. If you are planning on displaying the image +after each pass, the "rectangle" effect is generally considered the +better looking one. + +If you only want the "sparkle" effect, just call png_read_rows() as +normal, with the third parameter NULL. Make sure you make pass over +the image number_of_passes times, and you don't change the data in the +rows between calls. You can change the locations of the data, just +not the data. Each pass only writes the pixels appropriate for that +pass, and assumes the data from previous passes is still valid. + + png_read_rows(png_ptr, row_pointers, NULL, + number_of_rows); + +If you only want the first effect (the rectangles), do the same as +before except pass the row buffer in the third parameter, and leave +the second parameter NULL. + + png_read_rows(png_ptr, NULL, row_pointers, + number_of_rows); + +If you don't want libpng to handle the interlacing details, just call +png_read_rows() PNG_INTERLACE_ADAM7_PASSES times to read in all the images. +Each of the images is a valid image by itself; however, you will almost +certainly need to distribute the pixels from each sub-image to the +correct place. This is where everything gets very tricky. + +If you want to retrieve the separate images you must pass the correct +number of rows to each successive call of png_read_rows(). The calculation +gets pretty complicated for small images, where some sub-images may +not even exist because either their width or height ends up zero. +libpng provides two macros to help you in 1.5 and later versions: + + png_uint_32 width = PNG_PASS_COLS(image_width, pass_number); + png_uint_32 height = PNG_PASS_ROWS(image_height, pass_number); + +Respectively these tell you the width and height of the sub-image +corresponding to the numbered pass. 'pass' is in in the range 0 to 6 - +this can be confusing because the specification refers to the same passes +as 1 to 7! Be careful, you must check both the width and height before +calling png_read_rows() and not call it for that pass if either is zero. + +You can, of course, read each sub-image row by row. If you want to +produce optimal code to make a pixel-by-pixel transformation of an +interlaced image this is the best approach; read each row of each pass, +transform it, and write it out to a new interlaced image. + +If you want to de-interlace the image yourself libpng provides further +macros to help that tell you where to place the pixels in the output image. +Because the interlacing scheme is rectangular - sub-image pixels are always +arranged on a rectangular grid - all you need to know for each pass is the +starting column and row in the output image of the first pixel plus the +spacing between each pixel. As of libpng 1.5 there are four macros to +retrieve this information: + + png_uint_32 x = PNG_PASS_START_COL(pass); + png_uint_32 y = PNG_PASS_START_ROW(pass); + png_uint_32 xStep = 1U << PNG_PASS_COL_SHIFT(pass); + png_uint_32 yStep = 1U << PNG_PASS_ROW_SHIFT(pass); + +These allow you to write the obvious loop: + + png_uint_32 input_y = 0; + png_uint_32 output_y = PNG_PASS_START_ROW(pass); + + while (output_y < output_image_height) + { + png_uint_32 input_x = 0; + png_uint_32 output_x = PNG_PASS_START_COL(pass); + + while (output_x < output_image_width) + { + image[output_y][output_x] = + subimage[pass][input_y][input_x++]; + + output_x += xStep; + } + + ++input_y; + output_y += yStep; + } + +Notice that the steps between successive output rows and columns are +returned as shifts. This is possible because the pixels in the subimages +are always a power of 2 apart - 1, 2, 4 or 8 pixels - in the original +image. In practice you may need to directly calculate the output coordinate +given an input coordinate. libpng provides two further macros for this +purpose: + + png_uint_32 output_x = PNG_COL_FROM_PASS_COL(input_x, pass); + png_uint_32 output_y = PNG_ROW_FROM_PASS_ROW(input_y, pass); + +Finally a pair of macros are provided to tell you if a particular image +row or column appears in a given pass: + + int col_in_pass = PNG_COL_IN_INTERLACE_PASS(output_x, pass); + int row_in_pass = PNG_ROW_IN_INTERLACE_PASS(output_y, pass); + +Bear in mind that you will probably also need to check the width and height +of the pass in addition to the above to be sure the pass even exists! + +With any luck you are convinced by now that you don't want to do your own +interlace handling. In reality normally the only good reason for doing this +is if you are processing PNG files on a pixel-by-pixel basis and don't want +to load the whole file into memory when it is interlaced. + +libpng includes a test program, pngvalid, that illustrates reading and +writing of interlaced images. If you can't get interlacing to work in your +code and don't want to leave it to libpng (the recommended approach), see +how pngvalid.c does it. + +Finishing a sequential read + +After you are finished reading the image through the +low-level interface, you can finish reading the file. If you are +interested in comments or time, which may be stored either before or +after the image data, you should pass the separate png_info struct if +you want to keep the comments from before and after the image +separate. + + png_infop end_info = png_create_info_struct(png_ptr); + + if (!end_info) + { + png_destroy_read_struct(&png_ptr, &info_ptr, + (png_infopp)NULL); + return (ERROR); + } + + png_read_end(png_ptr, end_info); + +If you are not interested, you should still call png_read_end() +but you can pass NULL, avoiding the need to create an end_info structure. + + png_read_end(png_ptr, (png_infop)NULL); + +If you don't call png_read_end(), then your file pointer will be +left pointing to the first chunk after the last IDAT, which is probably +not what you want if you expect to read something beyond the end of +the PNG datastream. + +When you are done, you can free all memory allocated by libpng like this: + + png_destroy_read_struct(&png_ptr, &info_ptr, + &end_info); + +or, if you didn't create an end_info structure, + + png_destroy_read_struct(&png_ptr, &info_ptr, + (png_infopp)NULL); + +It is also possible to individually free the info_ptr members that +point to libpng-allocated storage with the following function: + + png_free_data(png_ptr, info_ptr, mask, seq) + + mask - identifies data to be freed, a mask + containing the bitwise OR of one or + more of + PNG_FREE_PLTE, PNG_FREE_TRNS, + PNG_FREE_HIST, PNG_FREE_ICCP, + PNG_FREE_PCAL, PNG_FREE_ROWS, + PNG_FREE_SCAL, PNG_FREE_SPLT, + PNG_FREE_TEXT, PNG_FREE_UNKN, + or simply PNG_FREE_ALL + + seq - sequence number of item to be freed + (-1 for all items) + +This function may be safely called when the relevant storage has +already been freed, or has not yet been allocated, or was allocated +by the user and not by libpng, and will in those cases do nothing. +The "seq" parameter is ignored if only one item of the selected data +type, such as PLTE, is allowed. If "seq" is not -1, and multiple items +are allowed for the data type identified in the mask, such as text or +sPLT, only the n'th item in the structure is freed, where n is "seq". + +The default behavior is only to free data that was allocated internally +by libpng. This can be changed, so that libpng will not free the data, +or so that it will free data that was allocated by the user with png_malloc() +or png_calloc() and passed in via a png_set_*() function, with + + png_data_freer(png_ptr, info_ptr, freer, mask) + + freer - one of + PNG_DESTROY_WILL_FREE_DATA + PNG_SET_WILL_FREE_DATA + PNG_USER_WILL_FREE_DATA + + mask - which data elements are affected + same choices as in png_free_data() + +This function only affects data that has already been allocated. +You can call this function after reading the PNG data but before calling +any png_set_*() functions, to control whether the user or the png_set_*() +function is responsible for freeing any existing data that might be present, +and again after the png_set_*() functions to control whether the user +or png_destroy_*() is supposed to free the data. When the user assumes +responsibility for libpng-allocated data, the application must use +png_free() to free it, and when the user transfers responsibility to libpng +for data that the user has allocated, the user must have used png_malloc() +or png_calloc() to allocate it. + +If you allocated your row_pointers in a single block, as suggested above in +the description of the high level read interface, you must not transfer +responsibility for freeing it to the png_set_rows or png_read_destroy function, +because they would also try to free the individual row_pointers[i]. + +If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword +separately, do not transfer responsibility for freeing text_ptr to libpng, +because when libpng fills a png_text structure it combines these members with +the key member, and png_free_data() will free only text_ptr.key. Similarly, +if you transfer responsibility for free'ing text_ptr from libpng to your +application, your application must not separately free those members. + +The png_free_data() function will turn off the "valid" flag for anything +it frees. If you need to turn the flag off for a chunk that was freed by +your application instead of by libpng, you can use + + png_set_invalid(png_ptr, info_ptr, mask); + + mask - identifies the chunks to be made invalid, + containing the bitwise OR of one or + more of + PNG_INFO_gAMA, PNG_INFO_sBIT, + PNG_INFO_cHRM, PNG_INFO_PLTE, + PNG_INFO_tRNS, PNG_INFO_bKGD, + PNG_INFO_hIST, PNG_INFO_pHYs, + PNG_INFO_oFFs, PNG_INFO_tIME, + PNG_INFO_pCAL, PNG_INFO_sRGB, + PNG_INFO_iCCP, PNG_INFO_sPLT, + PNG_INFO_sCAL, PNG_INFO_IDAT + +For a more compact example of reading a PNG image, see the file example.c. + +Reading PNG files progressively + +The progressive reader is slightly different then the non-progressive +reader. Instead of calling png_read_info(), png_read_rows(), and +png_read_end(), you make one call to png_process_data(), which calls +callbacks when it has the info, a row, or the end of the image. You +set up these callbacks with png_set_progressive_read_fn(). You don't +have to worry about the input/output functions of libpng, as you are +giving the library the data directly in png_process_data(). I will +assume that you have read the section on reading PNG files above, +so I will only highlight the differences (although I will show +all of the code). + +png_structp png_ptr; +png_infop info_ptr; + + /* An example code fragment of how you would + initialize the progressive reader in your + application. */ + int + initialize_png_reader() + { + png_ptr = png_create_read_struct + (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, + user_error_fn, user_warning_fn); + + if (!png_ptr) + return (ERROR); + + info_ptr = png_create_info_struct(png_ptr); + + if (!info_ptr) + { + png_destroy_read_struct(&png_ptr, + (png_infopp)NULL, (png_infopp)NULL); + return (ERROR); + } + + if (setjmp(png_jmpbuf(png_ptr))) + { + png_destroy_read_struct(&png_ptr, &info_ptr, + (png_infopp)NULL); + return (ERROR); + } + + /* This one's new. You can provide functions + to be called when the header info is valid, + when each row is completed, and when the image + is finished. If you aren't using all functions, + you can specify NULL parameters. Even when all + three functions are NULL, you need to call + png_set_progressive_read_fn(). You can use + any struct as the user_ptr (cast to a void pointer + for the function call), and retrieve the pointer + from inside the callbacks using the function + + png_get_progressive_ptr(png_ptr); + + which will return a void pointer, which you have + to cast appropriately. + */ + png_set_progressive_read_fn(png_ptr, (void *)user_ptr, + info_callback, row_callback, end_callback); + + return 0; + } + + /* A code fragment that you call as you receive blocks + of data */ + int + process_data(png_bytep buffer, png_uint_32 length) + { + if (setjmp(png_jmpbuf(png_ptr))) + { + png_destroy_read_struct(&png_ptr, &info_ptr, + (png_infopp)NULL); + return (ERROR); + } + + /* This one's new also. Simply give it a chunk + of data from the file stream (in order, of + course). On machines with segmented memory + models machines, don't give it any more than + 64K. The library seems to run fine with sizes + of 4K. Although you can give it much less if + necessary (I assume you can give it chunks of + 1 byte, I haven't tried less then 256 bytes + yet). When this function returns, you may + want to display any rows that were generated + in the row callback if you don't already do + so there. + */ + png_process_data(png_ptr, info_ptr, buffer, length); + + /* At this point you can call png_process_data_skip if + you want to handle data the library will skip yourself; + it simply returns the number of bytes to skip (and stops + libpng skipping that number of bytes on the next + png_process_data call). + return 0; + } + + /* This function is called (as set by + png_set_progressive_read_fn() above) when enough data + has been supplied so all of the header has been + read. + */ + void + info_callback(png_structp png_ptr, png_infop info) + { + /* Do any setup here, including setting any of + the transformations mentioned in the Reading + PNG files section. For now, you _must_ call + either png_start_read_image() or + png_read_update_info() after all the + transformations are set (even if you don't set + any). You may start getting rows before + png_process_data() returns, so this is your + last chance to prepare for that. + + This is where you turn on interlace handling, + assuming you don't want to do it yourself. + + If you need to you can stop the processing of + your original input data at this point by calling + png_process_data_pause. This returns the number + of unprocessed bytes from the last png_process_data + call - it is up to you to ensure that the next call + sees these bytes again. If you don't want to bother + with this you can get libpng to cache the unread + bytes by setting the 'save' parameter (see png.h) but + then libpng will have to copy the data internally. + */ + } + + /* This function is called when each row of image + data is complete */ + void + row_callback(png_structp png_ptr, png_bytep new_row, + png_uint_32 row_num, int pass) + { + /* If the image is interlaced, and you turned + on the interlace handler, this function will + be called for every row in every pass. Some + of these rows will not be changed from the + previous pass. When the row is not changed, + the new_row variable will be NULL. The rows + and passes are called in order, so you don't + really need the row_num and pass, but I'm + supplying them because it may make your life + easier. + + If you did not turn on interlace handling then + the callback is called for each row of each + sub-image when the image is interlaced. In this + case 'row_num' is the row in the sub-image, not + the row in the output image as it is in all other + cases. + + For the non-NULL rows of interlaced images when + you have switched on libpng interlace handling, + you must call png_progressive_combine_row() + passing in the row and the old row. You can + call this function for NULL rows (it will just + return) and for non-interlaced images (it just + does the memcpy for you) if it will make the + code easier. Thus, you can just do this for + all cases if you switch on interlace handling; + */ + + png_progressive_combine_row(png_ptr, old_row, + new_row); + + /* where old_row is what was displayed for + previously for the row. Note that the first + pass (pass == 0, really) will completely cover + the old row, so the rows do not have to be + initialized. After the first pass (and only + for interlaced images), you will have to pass + the current row, and the function will combine + the old row and the new row. + + You can also call png_process_data_pause in this + callback - see above. + */ + } + + void + end_callback(png_structp png_ptr, png_infop info) + { + /* This function is called after the whole image + has been read, including any chunks after the + image (up to and including the IEND). You + will usually have the same info chunk as you + had in the header, although some data may have + been added to the comments and time fields. + + Most people won't do much here, perhaps setting + a flag that marks the image as finished. + */ + } + + + +IV. Writing + +Much of this is very similar to reading. However, everything of +importance is repeated here, so you won't have to constantly look +back up in the reading section to understand writing. + +Setup + +You will want to do the I/O initialization before you get into libpng, +so if it doesn't work, you don't have anything to undo. If you are not +using the standard I/O functions, you will need to replace them with +custom writing functions. See the discussion under Customizing libpng. + + FILE *fp = fopen(file_name, "wb"); + + if (!fp) + return (ERROR); + +Next, png_struct and png_info need to be allocated and initialized. +As these can be both relatively large, you may not want to store these +on the stack, unless you have stack space to spare. Of course, you +will want to check if they return NULL. If you are also reading, +you won't want to name your read structure and your write structure +both "png_ptr"; you can call them anything you like, such as +"read_ptr" and "write_ptr". Look at pngtest.c, for example. + + png_structp png_ptr = png_create_write_struct + (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, + user_error_fn, user_warning_fn); + + if (!png_ptr) + return (ERROR); + + png_infop info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) + { + png_destroy_write_struct(&png_ptr, + (png_infopp)NULL); + return (ERROR); + } + +If you want to use your own memory allocation routines, +define PNG_USER_MEM_SUPPORTED and use +png_create_write_struct_2() instead of png_create_write_struct(): + + png_structp png_ptr = png_create_write_struct_2 + (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, + user_error_fn, user_warning_fn, (png_voidp) + user_mem_ptr, user_malloc_fn, user_free_fn); + +After you have these structures, you will need to set up the +error handling. When libpng encounters an error, it expects to +longjmp() back to your routine. Therefore, you will need to call +setjmp() and pass the png_jmpbuf(png_ptr). If you +write the file from different routines, you will need to update +the png_jmpbuf(png_ptr) every time you enter a new routine that will +call a png_*() function. See your documentation of setjmp/longjmp +for your compiler for more information on setjmp/longjmp. See +the discussion on libpng error handling in the Customizing Libpng +section below for more information on the libpng error handling. + + if (setjmp(png_jmpbuf(png_ptr))) + { + png_destroy_write_struct(&png_ptr, &info_ptr); + fclose(fp); + return (ERROR); + } + ... + return; + +If you would rather avoid the complexity of setjmp/longjmp issues, +you can compile libpng with PNG_NO_SETJMP, in which case +errors will result in a call to PNG_ABORT() which defaults to abort(). + +You can #define PNG_ABORT() to a function that does something +more useful than abort(), as long as your function does not +return. + +Now you need to set up the output code. The default for libpng is to +use the C function fwrite(). If you use this, you will need to pass a +valid FILE * in the function png_init_io(). Be sure that the file is +opened in binary mode. Again, if you wish to handle writing data in +another way, see the discussion on libpng I/O handling in the Customizing +Libpng section below. + + png_init_io(png_ptr, fp); + +If you are embedding your PNG into a datastream such as MNG, and don't +want libpng to write the 8-byte signature, or if you have already +written the signature in your application, use + + png_set_sig_bytes(png_ptr, 8); + +to inform libpng that it should not write a signature. + +Write callbacks + +At this point, you can set up a callback function that will be +called after each row has been written, which you can use to control +a progress meter or the like. It's demonstrated in pngtest.c. +You must supply a function + + void write_row_callback(png_structp png_ptr, png_uint_32 row, + int pass); + { + /* put your code here */ + } + +(You can give it another name that you like instead of "write_row_callback") + +To inform libpng about your function, use + + png_set_write_status_fn(png_ptr, write_row_callback); + +When this function is called the row has already been completely processed and +it has also been written out. The 'row' and 'pass' refer to the next row to be +handled. For the +non-interlaced case the row that was just handled is simply one less than the +passed in row number, and pass will always be 0. For the interlaced case the +same applies unless the row value is 0, in which case the row just handled was +the last one from one of the preceding passes. Because interlacing may skip a +pass you cannot be sure that the preceding pass is just 'pass-1', if you really +need to know what the last pass is record (row,pass) from the callback and use +the last recorded value each time. + +As with the user transform you can find the output row using the +PNG_ROW_FROM_PASS_ROW macro. + +You now have the option of modifying how the compression library will +run. The following functions are mainly for testing, but may be useful +in some cases, like if you need to write PNG files extremely fast and +are willing to give up some compression, or if you want to get the +maximum possible compression at the expense of slower writing. If you +have no special needs in this area, let the library do what it wants by +not calling this function at all, as it has been tuned to deliver a good +speed/compression ratio. The second parameter to png_set_filter() is +the filter method, for which the only valid values are 0 (as of the +July 1999 PNG specification, version 1.2) or 64 (if you are writing +a PNG datastream that is to be embedded in a MNG datastream). The third +parameter is a flag that indicates which filter type(s) are to be tested +for each scanline. See the PNG specification for details on the specific +filter types. + + + /* turn on or off filtering, and/or choose + specific filters. You can use either a single + PNG_FILTER_VALUE_NAME or the bitwise OR of one + or more PNG_FILTER_NAME masks. + */ + png_set_filter(png_ptr, 0, + PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE | + PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB | + PNG_FILTER_UP | PNG_FILTER_VALUE_UP | + PNG_FILTER_AVG | PNG_FILTER_VALUE_AVG | + PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH| + PNG_ALL_FILTERS); + +If an application wants to start and stop using particular filters during +compression, it should start out with all of the filters (to ensure that +the previous row of pixels will be stored in case it's needed later), +and then add and remove them after the start of compression. + +If you are writing a PNG datastream that is to be embedded in a MNG +datastream, the second parameter can be either 0 or 64. + +The png_set_compression_*() functions interface to the zlib compression +library, and should mostly be ignored unless you really know what you are +doing. The only generally useful call is png_set_compression_level() +which changes how much time zlib spends on trying to compress the image +data. See the Compression Library (zlib.h and algorithm.txt, distributed +with zlib) for details on the compression levels. + + #include zlib.h + + /* Set the zlib compression level */ + png_set_compression_level(png_ptr, + Z_BEST_COMPRESSION); + + /* Set other zlib parameters for compressing IDAT */ + png_set_compression_mem_level(png_ptr, 8); + png_set_compression_strategy(png_ptr, + Z_DEFAULT_STRATEGY); + png_set_compression_window_bits(png_ptr, 15); + png_set_compression_method(png_ptr, 8); + png_set_compression_buffer_size(png_ptr, 8192) + + /* Set zlib parameters for text compression + * If you don't call these, the parameters + * fall back on those defined for IDAT chunks + */ + png_set_text_compression_mem_level(png_ptr, 8); + png_set_text_compression_strategy(png_ptr, + Z_DEFAULT_STRATEGY); + png_set_text_compression_window_bits(png_ptr, 15); + png_set_text_compression_method(png_ptr, 8); + +Setting the contents of info for output + +You now need to fill in the png_info structure with all the data you +wish to write before the actual image. Note that the only thing you +are allowed to write after the image is the text chunks and the time +chunk (as of PNG Specification 1.2, anyway). See png_write_end() and +the latest PNG specification for more information on that. If you +wish to write them before the image, fill them in now, and flag that +data as being valid. If you want to wait until after the data, don't +fill them until png_write_end(). For all the fields in png_info and +their data types, see png.h. For explanations of what the fields +contain, see the PNG specification. + +Some of the more important parts of the png_info are: + + png_set_IHDR(png_ptr, info_ptr, width, height, + bit_depth, color_type, interlace_type, + compression_type, filter_method) + + width - holds the width of the image + in pixels (up to 2^31). + + height - holds the height of the image + in pixels (up to 2^31). + + bit_depth - holds the bit depth of one of the + image channels. + (valid values are 1, 2, 4, 8, 16 + and depend also on the + color_type. See also significant + bits (sBIT) below). + + color_type - describes which color/alpha + channels are present. + PNG_COLOR_TYPE_GRAY + (bit depths 1, 2, 4, 8, 16) + PNG_COLOR_TYPE_GRAY_ALPHA + (bit depths 8, 16) + PNG_COLOR_TYPE_PALETTE + (bit depths 1, 2, 4, 8) + PNG_COLOR_TYPE_RGB + (bit_depths 8, 16) + PNG_COLOR_TYPE_RGB_ALPHA + (bit_depths 8, 16) + + PNG_COLOR_MASK_PALETTE + PNG_COLOR_MASK_COLOR + PNG_COLOR_MASK_ALPHA + + interlace_type - PNG_INTERLACE_NONE or + PNG_INTERLACE_ADAM7 + + compression_type - (must be + PNG_COMPRESSION_TYPE_DEFAULT) + + filter_method - (must be PNG_FILTER_TYPE_DEFAULT + or, if you are writing a PNG to + be embedded in a MNG datastream, + can also be + PNG_INTRAPIXEL_DIFFERENCING) + +If you call png_set_IHDR(), the call must appear before any of the +other png_set_*() functions, because they might require access to some of +the IHDR settings. The remaining png_set_*() functions can be called +in any order. + +If you wish, you can reset the compression_type, interlace_type, or +filter_method later by calling png_set_IHDR() again; if you do this, the +width, height, bit_depth, and color_type must be the same in each call. + + png_set_PLTE(png_ptr, info_ptr, palette, + num_palette); + + palette - the palette for the file + (array of png_color) + num_palette - number of entries in the palette + + png_set_gAMA(png_ptr, info_ptr, file_gamma); + png_set_gAMA_fixed(png_ptr, info_ptr, int_file_gamma); + + file_gamma - the gamma at which the image was + created (PNG_INFO_gAMA) + + int_file_gamma - 100,000 times the gamma at which + the image was created + + png_set_cHRM(png_ptr, info_ptr, white_x, white_y, red_x, red_y, + green_x, green_y, blue_x, blue_y) + png_set_cHRM_XYZ(png_ptr, info_ptr, red_X, red_Y, red_Z, green_X, + green_Y, green_Z, blue_X, blue_Y, blue_Z) + png_set_cHRM_fixed(png_ptr, info_ptr, int_white_x, int_white_y, + int_red_x, int_red_y, int_green_x, int_green_y, + int_blue_x, int_blue_y) + png_set_cHRM_XYZ_fixed(png_ptr, info_ptr, int_red_X, int_red_Y, + int_red_Z, int_green_X, int_green_Y, int_green_Z, + int_blue_X, int_blue_Y, int_blue_Z) + + {white,red,green,blue}_{x,y} + A color space encoding specified using the chromaticities + of the end points and the white point. + + {red,green,blue}_{X,Y,Z} + A color space encoding specified using the encoding end + points - the CIE tristimulus specification of the intended + color of the red, green and blue channels in the PNG RGB + data. The white point is simply the sum of the three end + points. + + png_set_sRGB(png_ptr, info_ptr, srgb_intent); + + srgb_intent - the rendering intent + (PNG_INFO_sRGB) The presence of + the sRGB chunk means that the pixel + data is in the sRGB color space. + This chunk also implies specific + values of gAMA and cHRM. Rendering + intent is the CSS-1 property that + has been defined by the International + Color Consortium + (http://www.color.org). + It can be one of + PNG_sRGB_INTENT_SATURATION, + PNG_sRGB_INTENT_PERCEPTUAL, + PNG_sRGB_INTENT_ABSOLUTE, or + PNG_sRGB_INTENT_RELATIVE. + + + png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, + srgb_intent); + + srgb_intent - the rendering intent + (PNG_INFO_sRGB) The presence of the + sRGB chunk means that the pixel + data is in the sRGB color space. + This function also causes gAMA and + cHRM chunks with the specific values + that are consistent with sRGB to be + written. + + png_set_iCCP(png_ptr, info_ptr, name, compression_type, + profile, proflen); + + name - The profile name. + + compression_type - The compression type; always + PNG_COMPRESSION_TYPE_BASE for PNG 1.0. + You may give NULL to this argument to + ignore it. + + profile - International Color Consortium color + profile data. May contain NULs. + + proflen - length of profile data in bytes. + + png_set_sBIT(png_ptr, info_ptr, sig_bit); + + sig_bit - the number of significant bits for + (PNG_INFO_sBIT) each of the gray, red, + green, and blue channels, whichever are + appropriate for the given color type + (png_color_16) + + png_set_tRNS(png_ptr, info_ptr, trans_alpha, + num_trans, trans_color); + + trans_alpha - array of alpha (transparency) + entries for palette (PNG_INFO_tRNS) + + num_trans - number of transparent entries + (PNG_INFO_tRNS) + + trans_color - graylevel or color sample values + (in order red, green, blue) of the + single transparent color for + non-paletted images (PNG_INFO_tRNS) + + png_set_hIST(png_ptr, info_ptr, hist); + + hist - histogram of palette (array of + png_uint_16) (PNG_INFO_hIST) + + png_set_tIME(png_ptr, info_ptr, mod_time); + + mod_time - time image was last modified + (PNG_VALID_tIME) + + png_set_bKGD(png_ptr, info_ptr, background); + + background - background color (of type + png_color_16p) (PNG_VALID_bKGD) + + png_set_text(png_ptr, info_ptr, text_ptr, num_text); + + text_ptr - array of png_text holding image + comments + + text_ptr[i].compression - type of compression used + on "text" PNG_TEXT_COMPRESSION_NONE + PNG_TEXT_COMPRESSION_zTXt + PNG_ITXT_COMPRESSION_NONE + PNG_ITXT_COMPRESSION_zTXt + text_ptr[i].key - keyword for comment. Must contain + 1-79 characters. + text_ptr[i].text - text comments for current + keyword. Can be NULL or empty. + text_ptr[i].text_length - length of text string, + after decompression, 0 for iTXt + text_ptr[i].itxt_length - length of itxt string, + after decompression, 0 for tEXt/zTXt + text_ptr[i].lang - language of comment (NULL or + empty for unknown). + text_ptr[i].translated_keyword - keyword in UTF-8 (NULL + or empty for unknown). + + Note that the itxt_length, lang, and lang_key + members of the text_ptr structure only exist when the + library is built with iTXt chunk support. Prior to + libpng-1.4.0 the library was built by default without + iTXt support. Also note that when iTXt is supported, + they contain NULL pointers when the "compression" + field contains PNG_TEXT_COMPRESSION_NONE or + PNG_TEXT_COMPRESSION_zTXt. + + num_text - number of comments + + png_set_sPLT(png_ptr, info_ptr, &palette_ptr, + num_spalettes); + + palette_ptr - array of png_sPLT_struct structures + to be added to the list of palettes + in the info structure. + num_spalettes - number of palette structures to be + added. + + png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, + unit_type); + + offset_x - positive offset from the left + edge of the screen + + offset_y - positive offset from the top + edge of the screen + + unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER + + png_set_pHYs(png_ptr, info_ptr, res_x, res_y, + unit_type); + + res_x - pixels/unit physical resolution + in x direction + + res_y - pixels/unit physical resolution + in y direction + + unit_type - PNG_RESOLUTION_UNKNOWN, + PNG_RESOLUTION_METER + + png_set_sCAL(png_ptr, info_ptr, unit, width, height) + + unit - physical scale units (an integer) + + width - width of a pixel in physical scale units + + height - height of a pixel in physical scale units + (width and height are doubles) + + png_set_sCAL_s(png_ptr, info_ptr, unit, width, height) + + unit - physical scale units (an integer) + + width - width of a pixel in physical scale units + expressed as a string + + height - height of a pixel in physical scale units + (width and height are strings like "2.54") + + png_set_unknown_chunks(png_ptr, info_ptr, &unknowns, + num_unknowns) + + unknowns - array of png_unknown_chunk + structures holding unknown chunks + unknowns[i].name - name of unknown chunk + unknowns[i].data - data of unknown chunk + unknowns[i].size - size of unknown chunk's data + unknowns[i].location - position to write chunk in file + 0: do not write chunk + PNG_HAVE_IHDR: before PLTE + PNG_HAVE_PLTE: before IDAT + PNG_AFTER_IDAT: after IDAT + +The "location" member is set automatically according to +what part of the output file has already been written. +You can change its value after calling png_set_unknown_chunks() +as demonstrated in pngtest.c. Within each of the "locations", +the chunks are sequenced according to their position in the +structure (that is, the value of "i", which is the order in which +the chunk was either read from the input file or defined with +png_set_unknown_chunks). + +A quick word about text and num_text. text is an array of png_text +structures. num_text is the number of valid structures in the array. +Each png_text structure holds a language code, a keyword, a text value, +and a compression type. + +The compression types have the same valid numbers as the compression +types of the image data. Currently, the only valid number is zero. +However, you can store text either compressed or uncompressed, unlike +images, which always have to be compressed. So if you don't want the +text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE. +Because tEXt and zTXt chunks don't have a language field, if you +specify PNG_TEXT_COMPRESSION_NONE or PNG_TEXT_COMPRESSION_zTXt +any language code or translated keyword will not be written out. + +Until text gets around a few hundred bytes, it is not worth compressing it. +After the text has been written out to the file, the compression type +is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR, +so that it isn't written out again at the end (in case you are calling +png_write_end() with the same struct). + +The keywords that are given in the PNG Specification are: + + Title Short (one line) title or + caption for image + + Author Name of image's creator + + Description Description of image (possibly long) + + Copyright Copyright notice + + Creation Time Time of original image creation + (usually RFC 1123 format, see below) + + Software Software used to create the image + + Disclaimer Legal disclaimer + + Warning Warning of nature of content + + Source Device used to create the image + + Comment Miscellaneous comment; conversion + from other image format + +The keyword-text pairs work like this. Keywords should be short +simple descriptions of what the comment is about. Some typical +keywords are found in the PNG specification, as is some recommendations +on keywords. You can repeat keywords in a file. You can even write +some text before the image and some after. For example, you may want +to put a description of the image before the image, but leave the +disclaimer until after, so viewers working over modem connections +don't have to wait for the disclaimer to go over the modem before +they start seeing the image. Finally, keywords should be full +words, not abbreviations. Keywords and text are in the ISO 8859-1 +(Latin-1) character set (a superset of regular ASCII) and can not +contain NUL characters, and should not contain control or other +unprintable characters. To make the comments widely readable, stick +with basic ASCII, and avoid machine specific character set extensions +like the IBM-PC character set. The keyword must be present, but +you can leave off the text string on non-compressed pairs. +Compressed pairs must have a text string, as only the text string +is compressed anyway, so the compression would be meaningless. + +PNG supports modification time via the png_time structure. Two +conversion routines are provided, png_convert_from_time_t() for +time_t and png_convert_from_struct_tm() for struct tm. The +time_t routine uses gmtime(). You don't have to use either of +these, but if you wish to fill in the png_time structure directly, +you should provide the time in universal time (GMT) if possible +instead of your local time. Note that the year number is the full +year (e.g. 1998, rather than 98 - PNG is year 2000 compliant!), and +that months start with 1. + +If you want to store the time of the original image creation, you should +use a plain tEXt chunk with the "Creation Time" keyword. This is +necessary because the "creation time" of a PNG image is somewhat vague, +depending on whether you mean the PNG file, the time the image was +created in a non-PNG format, a still photo from which the image was +scanned, or possibly the subject matter itself. In order to facilitate +machine-readable dates, it is recommended that the "Creation Time" +tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"), +although this isn't a requirement. Unlike the tIME chunk, the +"Creation Time" tEXt chunk is not expected to be automatically changed +by the software. To facilitate the use of RFC 1123 dates, a function +png_convert_to_rfc1123(png_ptr, png_timep) is provided to convert +from PNG time to an RFC 1123 format string. + +Writing unknown chunks + +You can use the png_set_unknown_chunks function to queue up chunks +for writing. You give it a chunk name, raw data, and a size; that's +all there is to it. The chunks will be written by the next following +png_write_info_before_PLTE, png_write_info, or png_write_end function. +Any chunks previously read into the info structure's unknown-chunk +list will also be written out in a sequence that satisfies the PNG +specification's ordering rules. + +The high-level write interface + +At this point there are two ways to proceed; through the high-level +write interface, or through a sequence of low-level write operations. +You can use the high-level interface if your image data is present +in the info structure. All defined output +transformations are permitted, enabled by the following masks. + + PNG_TRANSFORM_IDENTITY No transformation + PNG_TRANSFORM_PACKING Pack 1, 2 and 4-bit samples + PNG_TRANSFORM_PACKSWAP Change order of packed + pixels to LSB first + PNG_TRANSFORM_INVERT_MONO Invert monochrome images + PNG_TRANSFORM_SHIFT Normalize pixels to the + sBIT depth + PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA + to BGRA + PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA + to AG + PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity + to transparency + PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples + PNG_TRANSFORM_STRIP_FILLER Strip out filler + bytes (deprecated). + PNG_TRANSFORM_STRIP_FILLER_BEFORE Strip out leading + filler bytes + PNG_TRANSFORM_STRIP_FILLER_AFTER Strip out trailing + filler bytes + +If you have valid image data in the info structure (you can use +png_set_rows() to put image data in the info structure), simply do this: + + png_write_png(png_ptr, info_ptr, png_transforms, NULL) + +where png_transforms is an integer containing the bitwise OR of some set of +transformation flags. This call is equivalent to png_write_info(), +followed the set of transformations indicated by the transform mask, +then png_write_image(), and finally png_write_end(). + +(The final parameter of this call is not yet used. Someday it might point +to transformation parameters required by some future output transform.) + +You must use png_transforms and not call any png_set_transform() functions +when you use png_write_png(). + +The low-level write interface + +If you are going the low-level route instead, you are now ready to +write all the file information up to the actual image data. You do +this with a call to png_write_info(). + + png_write_info(png_ptr, info_ptr); + +Note that there is one transformation you may need to do before +png_write_info(). In PNG files, the alpha channel in an image is the +level of opacity. If your data is supplied as a level of transparency, +you can invert the alpha channel before you write it, so that 0 is +fully transparent and 255 (in 8-bit or paletted images) or 65535 +(in 16-bit images) is fully opaque, with + + png_set_invert_alpha(png_ptr); + +This must appear before png_write_info() instead of later with the +other transformations because in the case of paletted images the tRNS +chunk data has to be inverted before the tRNS chunk is written. If +your image is not a paletted image, the tRNS data (which in such cases +represents a single color to be rendered as transparent) won't need to +be changed, and you can safely do this transformation after your +png_write_info() call. + +If you need to write a private chunk that you want to appear before +the PLTE chunk when PLTE is present, you can write the PNG info in +two steps, and insert code to write your own chunk between them: + + png_write_info_before_PLTE(png_ptr, info_ptr); + png_set_unknown_chunks(png_ptr, info_ptr, ...); + png_write_info(png_ptr, info_ptr); + +After you've written the file information, you can set up the library +to handle any special transformations of the image data. The various +ways to transform the data will be described in the order that they +should occur. This is important, as some of these change the color +type and/or bit depth of the data, and some others only work on +certain color types and bit depths. Even though each transformation +checks to see if it has data that it can do something with, you should +make sure to only enable a transformation if it will be valid for the +data. For example, don't swap red and blue on grayscale data. + +PNG files store RGB pixels packed into 3 or 6 bytes. This code tells +the library to strip input data that has 4 or 8 bytes per pixel down +to 3 or 6 bytes (or strip 2 or 4-byte grayscale+filler data to 1 or 2 +bytes per pixel). + + png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); + +where the 0 is unused, and the location is either PNG_FILLER_BEFORE or +PNG_FILLER_AFTER, depending upon whether the filler byte in the pixel +is stored XRGB or RGBX. + +PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as +they can, resulting in, for example, 8 pixels per byte for 1 bit files. +If the data is supplied at 1 pixel per byte, use this code, which will +correctly pack the pixels into a single byte: + + png_set_packing(png_ptr); + +PNG files reduce possible bit depths to 1, 2, 4, 8, and 16. If your +data is of another bit depth, you can write an sBIT chunk into the +file so that decoders can recover the original data if desired. + + /* Set the true bit depth of the image data */ + if (color_type & PNG_COLOR_MASK_COLOR) + { + sig_bit.red = true_bit_depth; + sig_bit.green = true_bit_depth; + sig_bit.blue = true_bit_depth; + } + + else + { + sig_bit.gray = true_bit_depth; + } + + if (color_type & PNG_COLOR_MASK_ALPHA) + { + sig_bit.alpha = true_bit_depth; + } + + png_set_sBIT(png_ptr, info_ptr, &sig_bit); + +If the data is stored in the row buffer in a bit depth other than +one supported by PNG (e.g. 3 bit data in the range 0-7 for a 4-bit PNG), +this will scale the values to appear to be the correct bit depth as +is required by PNG. + + png_set_shift(png_ptr, &sig_bit); + +PNG files store 16-bit pixels in network byte order (big-endian, +ie. most significant bits first). This code would be used if they are +supplied the other way (little-endian, i.e. least significant bits +first, the way PCs store them): + + if (bit_depth > 8) + png_set_swap(png_ptr); + +If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you +need to change the order the pixels are packed into bytes, you can use: + + if (bit_depth < 8) + png_set_packswap(png_ptr); + +PNG files store 3 color pixels in red, green, blue order. This code +would be used if they are supplied as blue, green, red: + + png_set_bgr(png_ptr); + +PNG files describe monochrome as black being zero and white being +one. This code would be used if the pixels are supplied with this reversed +(black being one and white being zero): + + png_set_invert_mono(png_ptr); + +Finally, you can write your own transformation function if none of +the existing ones meets your needs. This is done by setting a callback +with + + png_set_write_user_transform_fn(png_ptr, + write_transform_fn); + +You must supply the function + + void write_transform_fn(png_structp png_ptr, png_row_infop + row_info, png_bytep data) + +See pngtest.c for a working example. Your function will be called +before any of the other transformations are processed. If supported +libpng also supplies an information routine that may be called from +your callback: + + png_get_current_row_number(png_ptr); + png_get_current_pass_number(png_ptr); + +This returns the current row passed to the transform. With interlaced +images the value returned is the row in the input sub-image image. Use +PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to +find the output pixel (x,y) given an interlaced sub-image pixel (row,col,pass). + +The discussion of interlace handling above contains more information on how to +use these values. + +You can also set up a pointer to a user structure for use by your +callback function. + + png_set_user_transform_info(png_ptr, user_ptr, 0, 0); + +The user_channels and user_depth parameters of this function are ignored +when writing; you can set them to zero as shown. + +You can retrieve the pointer via the function png_get_user_transform_ptr(). +For example: + + voidp write_user_transform_ptr = + png_get_user_transform_ptr(png_ptr); + +It is possible to have libpng flush any pending output, either manually, +or automatically after a certain number of lines have been written. To +flush the output stream a single time call: + + png_write_flush(png_ptr); + +and to have libpng flush the output stream periodically after a certain +number of scanlines have been written, call: + + png_set_flush(png_ptr, nrows); + +Note that the distance between rows is from the last time png_write_flush() +was called, or the first row of the image if it has never been called. +So if you write 50 lines, and then png_set_flush 25, it will flush the +output on the next scanline, and every 25 lines thereafter, unless +png_write_flush() is called before 25 more lines have been written. +If nrows is too small (less than about 10 lines for a 640 pixel wide +RGB image) the image compression may decrease noticeably (although this +may be acceptable for real-time applications). Infrequent flushing will +only degrade the compression performance by a few percent over images +that do not use flushing. + +Writing the image data + +That's it for the transformations. Now you can write the image data. +The simplest way to do this is in one function call. If you have the +whole image in memory, you can just call png_write_image() and libpng +will write the image. You will need to pass in an array of pointers to +each row. This function automatically handles interlacing, so you don't +need to call png_set_interlace_handling() or call this function multiple +times, or any of that other stuff necessary with png_write_rows(). + + png_write_image(png_ptr, row_pointers); + +where row_pointers is: + + png_byte *row_pointers[height]; + +You can point to void or char or whatever you use for pixels. + +If you don't want to write the whole image at once, you can +use png_write_rows() instead. If the file is not interlaced, +this is simple: + + png_write_rows(png_ptr, row_pointers, + number_of_rows); + +row_pointers is the same as in the png_write_image() call. + +If you are just writing one row at a time, you can do this with +a single row_pointer instead of an array of row_pointers: + + png_bytep row_pointer = row; + + png_write_row(png_ptr, row_pointer); + +When the file is interlaced, things can get a good deal more complicated. +The only currently (as of the PNG Specification version 1.2, dated July +1999) defined interlacing scheme for PNG files is the "Adam7" interlace +scheme, that breaks down an image into seven smaller images of varying +size. libpng will build these images for you, or you can do them +yourself. If you want to build them yourself, see the PNG specification +for details of which pixels to write when. + +If you don't want libpng to handle the interlacing details, just +use png_set_interlace_handling() and call png_write_rows() the +correct number of times to write all the sub-images +(png_set_interlace_handling() returns the number of sub-images.) + +If you want libpng to build the sub-images, call this before you start +writing any rows: + + number_of_passes = png_set_interlace_handling(png_ptr); + +This will return the number of passes needed. Currently, this is seven, +but may change if another interlace type is added. + +Then write the complete image number_of_passes times. + + png_write_rows(png_ptr, row_pointers, number_of_rows); + +Think carefully before you write an interlaced image. Typically code that +reads such images reads all the image data into memory, uncompressed, before +doing any processing. Only code that can display an image on the fly can +take advantage of the interlacing and even then the image has to be exactly +the correct size for the output device, because scaling an image requires +adjacent pixels and these are not available until all the passes have been +read. + +If you do write an interlaced image you will hardly ever need to handle +the interlacing yourself. Call png_set_interlace_handling() and use the +approach described above. + +The only time it is conceivable that you will really need to write an +interlaced image pass-by-pass is when you have read one pass by pass and +made some pixel-by-pixel transformation to it, as described in the read +code above. In this case use the PNG_PASS_ROWS and PNG_PASS_COLS macros +to determine the size of each sub-image in turn and simply write the rows +you obtained from the read code. + +Finishing a sequential write + +After you are finished writing the image, you should finish writing +the file. If you are interested in writing comments or time, you should +pass an appropriately filled png_info pointer. If you are not interested, +you can pass NULL. + + png_write_end(png_ptr, info_ptr); + +When you are done, you can free all memory used by libpng like this: + + png_destroy_write_struct(&png_ptr, &info_ptr); + +It is also possible to individually free the info_ptr members that +point to libpng-allocated storage with the following function: + + png_free_data(png_ptr, info_ptr, mask, seq) + + mask - identifies data to be freed, a mask + containing the bitwise OR of one or + more of + PNG_FREE_PLTE, PNG_FREE_TRNS, + PNG_FREE_HIST, PNG_FREE_ICCP, + PNG_FREE_PCAL, PNG_FREE_ROWS, + PNG_FREE_SCAL, PNG_FREE_SPLT, + PNG_FREE_TEXT, PNG_FREE_UNKN, + or simply PNG_FREE_ALL + + seq - sequence number of item to be freed + (-1 for all items) + +This function may be safely called when the relevant storage has +already been freed, or has not yet been allocated, or was allocated +by the user and not by libpng, and will in those cases do nothing. +The "seq" parameter is ignored if only one item of the selected data +type, such as PLTE, is allowed. If "seq" is not -1, and multiple items +are allowed for the data type identified in the mask, such as text or +sPLT, only the n'th item in the structure is freed, where n is "seq". + +If you allocated data such as a palette that you passed in to libpng +with png_set_*, you must not free it until just before the call to +png_destroy_write_struct(). + +The default behavior is only to free data that was allocated internally +by libpng. This can be changed, so that libpng will not free the data, +or so that it will free data that was allocated by the user with png_malloc() +or png_calloc() and passed in via a png_set_*() function, with + + png_data_freer(png_ptr, info_ptr, freer, mask) + + freer - one of + PNG_DESTROY_WILL_FREE_DATA + PNG_SET_WILL_FREE_DATA + PNG_USER_WILL_FREE_DATA + + mask - which data elements are affected + same choices as in png_free_data() + +For example, to transfer responsibility for some data from a read structure +to a write structure, you could use + + png_data_freer(read_ptr, read_info_ptr, + PNG_USER_WILL_FREE_DATA, + PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) + + png_data_freer(write_ptr, write_info_ptr, + PNG_DESTROY_WILL_FREE_DATA, + PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) + +thereby briefly reassigning responsibility for freeing to the user but +immediately afterwards reassigning it once more to the write_destroy +function. Having done this, it would then be safe to destroy the read +structure and continue to use the PLTE, tRNS, and hIST data in the write +structure. + +This function only affects data that has already been allocated. +You can call this function before calling after the png_set_*() functions +to control whether the user or png_destroy_*() is supposed to free the data. +When the user assumes responsibility for libpng-allocated data, the +application must use +png_free() to free it, and when the user transfers responsibility to libpng +for data that the user has allocated, the user must have used png_malloc() +or png_calloc() to allocate it. + +If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword +separately, do not transfer responsibility for freeing text_ptr to libpng, +because when libpng fills a png_text structure it combines these members with +the key member, and png_free_data() will free only text_ptr.key. Similarly, +if you transfer responsibility for free'ing text_ptr from libpng to your +application, your application must not separately free those members. +For a more compact example of writing a PNG image, see the file example.c. + +V. Modifying/Customizing libpng: + +There are two issues here. The first is changing how libpng does +standard things like memory allocation, input/output, and error handling. +The second deals with more complicated things like adding new chunks, +adding new transformations, and generally changing how libpng works. +Both of those are compile-time issues; that is, they are generally +determined at the time the code is written, and there is rarely a need +to provide the user with a means of changing them. + +Memory allocation, input/output, and error handling + +All of the memory allocation, input/output, and error handling in libpng +goes through callbacks that are user-settable. The default routines are +in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively. To change +these functions, call the appropriate png_set_*_fn() function. + +Memory allocation is done through the functions png_malloc(), png_calloc(), +and png_free(). The png_malloc() and png_free() functions currently just +call the standard C functions and png_calloc() calls png_malloc() and then +clears the newly allocated memory to zero; note that png_calloc(png_ptr, size) +is not the same as the calloc(number, size) function provided by stdlib.h. +There is limited support for certain systems with segmented memory +architectures and the types of pointers declared by png.h match this; you +will have to use appropriate pointers in your application. Since it is +unlikely that the method of handling memory allocation on a platform +will change between applications, these functions must be modified in +the library at compile time. If you prefer to use a different method +of allocating and freeing data, you can use png_create_read_struct_2() or +png_create_write_struct_2() to register your own functions as described +above. These functions also provide a void pointer that can be retrieved +via + + mem_ptr=png_get_mem_ptr(png_ptr); + +Your replacement memory functions must have prototypes as follows: + + png_voidp malloc_fn(png_structp png_ptr, + png_alloc_size_t size); + + void free_fn(png_structp png_ptr, png_voidp ptr); + +Your malloc_fn() must return NULL in case of failure. The png_malloc() +function will normally call png_error() if it receives a NULL from the +system memory allocator or from your replacement malloc_fn(). + +Your free_fn() will never be called with a NULL ptr, since libpng's +png_free() checks for NULL before calling free_fn(). + +Input/Output in libpng is done through png_read() and png_write(), +which currently just call fread() and fwrite(). The FILE * is stored in +png_struct and is initialized via png_init_io(). If you wish to change +the method of I/O, the library supplies callbacks that you can set +through the function png_set_read_fn() and png_set_write_fn() at run +time, instead of calling the png_init_io() function. These functions +also provide a void pointer that can be retrieved via the function +png_get_io_ptr(). For example: + + png_set_read_fn(png_structp read_ptr, + voidp read_io_ptr, png_rw_ptr read_data_fn) + + png_set_write_fn(png_structp write_ptr, + voidp write_io_ptr, png_rw_ptr write_data_fn, + png_flush_ptr output_flush_fn); + + voidp read_io_ptr = png_get_io_ptr(read_ptr); + voidp write_io_ptr = png_get_io_ptr(write_ptr); + +The replacement I/O functions must have prototypes as follows: + + void user_read_data(png_structp png_ptr, + png_bytep data, png_size_t length); + + void user_write_data(png_structp png_ptr, + png_bytep data, png_size_t length); + + void user_flush_data(png_structp png_ptr); + +The user_read_data() function is responsible for detecting and +handling end-of-data errors. + +Supplying NULL for the read, write, or flush functions sets them back +to using the default C stream functions, which expect the io_ptr to +point to a standard *FILE structure. It is probably a mistake +to use NULL for one of write_data_fn and output_flush_fn but not both +of them, unless you have built libpng with PNG_NO_WRITE_FLUSH defined. +It is an error to read from a write stream, and vice versa. + +Error handling in libpng is done through png_error() and png_warning(). +Errors handled through png_error() are fatal, meaning that png_error() +should never return to its caller. Currently, this is handled via +setjmp() and longjmp() (unless you have compiled libpng with +PNG_NO_SETJMP, in which case it is handled via PNG_ABORT()), +but you could change this to do things like exit() if you should wish, +as long as your function does not return. + +On non-fatal errors, png_warning() is called +to print a warning message, and then control returns to the calling code. +By default png_error() and png_warning() print a message on stderr via +fprintf() unless the library is compiled with PNG_NO_CONSOLE_IO defined +(because you don't want the messages) or PNG_NO_STDIO defined (because +fprintf() isn't available). If you wish to change the behavior of the error +functions, you will need to set up your own message callbacks. These +functions are normally supplied at the time that the png_struct is created. +It is also possible to redirect errors and warnings to your own replacement +functions after png_create_*_struct() has been called by calling: + + png_set_error_fn(png_structp png_ptr, + png_voidp error_ptr, png_error_ptr error_fn, + png_error_ptr warning_fn); + + png_voidp error_ptr = png_get_error_ptr(png_ptr); + +If NULL is supplied for either error_fn or warning_fn, then the libpng +default function will be used, calling fprintf() and/or longjmp() if a +problem is encountered. The replacement error functions should have +parameters as follows: + + void user_error_fn(png_structp png_ptr, + png_const_charp error_msg); + + void user_warning_fn(png_structp png_ptr, + png_const_charp warning_msg); + +The motivation behind using setjmp() and longjmp() is the C++ throw and +catch exception handling methods. This makes the code much easier to write, +as there is no need to check every return code of every function call. +However, there are some uncertainties about the status of local variables +after a longjmp, so the user may want to be careful about doing anything +after setjmp returns non-zero besides returning itself. Consult your +compiler documentation for more details. For an alternative approach, you +may wish to use the "cexcept" facility (see http://cexcept.sourceforge.net), +which is illustrated in pngvalid.c and in contrib/visupng. + +Custom chunks + +If you need to read or write custom chunks, you may need to get deeper +into the libpng code. The library now has mechanisms for storing +and writing chunks of unknown type; you can even declare callbacks +for custom chunks. However, this may not be good enough if the +library code itself needs to know about interactions between your +chunk and existing `intrinsic' chunks. + +If you need to write a new intrinsic chunk, first read the PNG +specification. Acquire a first level of understanding of how it works. +Pay particular attention to the sections that describe chunk names, +and look at how other chunks were designed, so you can do things +similarly. Second, check out the sections of libpng that read and +write chunks. Try to find a chunk that is similar to yours and use +it as a template. More details can be found in the comments inside +the code. It is best to handle private or unknown chunks in a generic method, +via callback functions, instead of by modifying libpng functions. This +is illustrated in pngtest.c, which uses a callback function to handle a +private "vpAg" chunk and the new "sTER" chunk, which are both unknown to +libpng. + +If you wish to write your own transformation for the data, look through +the part of the code that does the transformations, and check out some of +the simpler ones to get an idea of how they work. Try to find a similar +transformation to the one you want to add and copy off of it. More details +can be found in the comments inside the code itself. + +Configuring for 16-bit platforms + +You will want to look into zconf.h to tell zlib (and thus libpng) that +it cannot allocate more then 64K at a time. Even if you can, the memory +won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K. + +Configuring for DOS + +For DOS users who only have access to the lower 640K, you will +have to limit zlib's memory usage via a png_set_compression_mem_level() +call. See zlib.h or zconf.h in the zlib library for more information. + +Configuring for Medium Model + +Libpng's support for medium model has been tested on most of the popular +compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets +defined, and FAR gets defined to far in pngconf.h, and you should be +all set. Everything in the library (except for zlib's structure) is +expecting far data. You must use the typedefs with the p or pp on +the end for pointers (or at least look at them and be careful). Make +note that the rows of data are defined as png_bytepp, which is +an "unsigned char far * far *". + +Configuring for gui/windowing platforms: + +You will need to write new error and warning functions that use the GUI +interface, as described previously, and set them to be the error and +warning functions at the time that png_create_*_struct() is called, +in order to have them available during the structure initialization. +They can be changed later via png_set_error_fn(). On some compilers, +you may also have to change the memory allocators (png_malloc, etc.). + +Configuring for compiler xxx: + +All includes for libpng are in pngconf.h. If you need to add, change +or delete an include, this is the place to do it. +The includes that are not needed outside libpng are placed in pngpriv.h, +which is only used by the routines inside libpng itself. +The files in libpng proper only include pngpriv.h and png.h, which +in turn includes pngconf.h and, as of libpng-1.5.0, pnglibconf.h. +As of libpng-1.5.0, pngpriv.h also includes three other private header +files, pngstruct.h, pnginfo.h, and pngdebug.h, which contain material +that previously appeared in the public headers. + +Configuring zlib: + +There are special functions to configure the compression. Perhaps the +most useful one changes the compression level, which currently uses +input compression values in the range 0 - 9. The library normally +uses the default compression level (Z_DEFAULT_COMPRESSION = 6). Tests +have shown that for a large majority of images, compression values in +the range 3-6 compress nearly as well as higher levels, and do so much +faster. For online applications it may be desirable to have maximum speed +(Z_BEST_SPEED = 1). With versions of zlib after v0.99, you can also +specify no compression (Z_NO_COMPRESSION = 0), but this would create +files larger than just storing the raw bitmap. You can specify the +compression level by calling: + + #include zlib.h + png_set_compression_level(png_ptr, level); + +Another useful one is to reduce the memory level used by the library. +The memory level defaults to 8, but it can be lowered if you are +short on memory (running DOS, for example, where you only have 640K). +Note that the memory level does have an effect on compression; among +other things, lower levels will result in sections of incompressible +data being emitted in smaller stored blocks, with a correspondingly +larger relative overhead of up to 15% in the worst case. + + #include zlib.h + png_set_compression_mem_level(png_ptr, level); + +The other functions are for configuring zlib. They are not recommended +for normal use and may result in writing an invalid PNG file. See +zlib.h for more information on what these mean. + + #include zlib.h + png_set_compression_strategy(png_ptr, + strategy); + + png_set_compression_window_bits(png_ptr, + window_bits); + + png_set_compression_method(png_ptr, method); + + png_set_compression_buffer_size(png_ptr, size); + +As of libpng version 1.5.4, additional APIs became +available to set these separately for non-IDAT +compressed chunks such as zTXt, iTXt, and iCCP: + + #include zlib.h + #if PNG_LIBPNG_VER >= 10504 + png_set_text_compression_level(png_ptr, level); + + png_set_text_compression_mem_level(png_ptr, level); + + png_set_text_compression_strategy(png_ptr, + strategy); + + png_set_text_compression_window_bits(png_ptr, + window_bits); + + png_set_text_compression_method(png_ptr, method); + #endif + +Controlling row filtering + +If you want to control whether libpng uses filtering or not, which +filters are used, and how it goes about picking row filters, you +can call one of these functions. The selection and configuration +of row filters can have a significant impact on the size and +encoding speed and a somewhat lesser impact on the decoding speed +of an image. Filtering is enabled by default for RGB and grayscale +images (with and without alpha), but not for paletted images nor +for any images with bit depths less than 8 bits/pixel. + +The 'method' parameter sets the main filtering method, which is +currently only '0' in the PNG 1.2 specification. The 'filters' +parameter sets which filter(s), if any, should be used for each +scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS +to turn filtering on and off, respectively. + +Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB, +PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise +ORed together with '|' to specify one or more filters to use. +These filters are described in more detail in the PNG specification. +If you intend to change the filter type during the course of writing +the image, you should start with flags set for all of the filters +you intend to use so that libpng can initialize its internal +structures appropriately for all of the filter types. (Note that this +means the first row must always be adaptively filtered, because libpng +currently does not allocate the filter buffers until png_write_row() +is called for the first time.) + + filters = PNG_FILTER_NONE | PNG_FILTER_SUB + PNG_FILTER_UP | PNG_FILTER_AVG | + PNG_FILTER_PAETH | PNG_ALL_FILTERS; + + png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, + filters); + The second parameter can also be + PNG_INTRAPIXEL_DIFFERENCING if you are + writing a PNG to be embedded in a MNG + datastream. This parameter must be the + same as the value of filter_method used + in png_set_IHDR(). + +It is also possible to influence how libpng chooses from among the +available filters. This is done in one or both of two ways - by +telling it how important it is to keep the same filter for successive +rows, and by telling it the relative computational costs of the filters. + + double weights[3] = {1.5, 1.3, 1.1}, + costs[PNG_FILTER_VALUE_LAST] = + {1.0, 1.3, 1.3, 1.5, 1.7}; + + png_set_filter_heuristics(png_ptr, + PNG_FILTER_HEURISTIC_WEIGHTED, 3, + weights, costs); + +The weights are multiplying factors that indicate to libpng that the +row filter should be the same for successive rows unless another row filter +is that many times better than the previous filter. In the above example, +if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a +"sum of absolute differences" 1.5 x 1.3 times higher than other filters +and still be chosen, while the NONE filter could have a sum 1.1 times +higher than other filters and still be chosen. Unspecified weights are +taken to be 1.0, and the specified weights should probably be declining +like those above in order to emphasize recent filters over older filters. + +The filter costs specify for each filter type a relative decoding cost +to be considered when selecting row filters. This means that filters +with higher costs are less likely to be chosen over filters with lower +costs, unless their "sum of absolute differences" is that much smaller. +The costs do not necessarily reflect the exact computational speeds of +the various filters, since this would unduly influence the final image +size. + +Note that the numbers above were invented purely for this example and +are given only to help explain the function usage. Little testing has +been done to find optimum values for either the costs or the weights. + +Removing unwanted object code + +There are a bunch of #define's in pngconf.h that control what parts of +libpng are compiled. All the defines end in _SUPPORTED. If you are +never going to use a capability, you can change the #define to #undef +before recompiling libpng and save yourself code and data space, or +you can turn off individual capabilities with defines that begin with +PNG_NO_. + +In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead. + +You can also turn all of the transforms and ancillary chunk capabilities +off en masse with compiler directives that define +PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS, +or all four, +along with directives to turn on any of the capabilities that you do +want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable the extra +transformations but still leave the library fully capable of reading +and writing PNG files with all known public chunks. Use of the +PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive produces a library +that is incapable of reading or writing ancillary chunks. If you are +not using the progressive reading capability, you can turn that off +with PNG_NO_PROGRESSIVE_READ (don't confuse this with the INTERLACING +capability, which you'll still have). + +All the reading and writing specific code are in separate files, so the +linker should only grab the files it needs. However, if you want to +make sure, or if you are building a stand alone library, all the +reading files start with "pngr" and all the writing files start with "pngw". +The files that don't match either (like png.c, pngtrans.c, etc.) +are used for both reading and writing, and always need to be included. +The progressive reader is in pngpread.c + +If you are creating or distributing a dynamically linked library (a .so +or DLL file), you should not remove or disable any parts of the library, +as this will cause applications linked with different versions of the +library to fail if they call functions not available in your library. +The size of the library itself should not be an issue, because only +those sections that are actually used will be loaded into memory. + +Requesting debug printout + +The macro definition PNG_DEBUG can be used to request debugging +printout. Set it to an integer value in the range 0 to 3. Higher +numbers result in increasing amounts of debugging information. The +information is printed to the "stderr" file, unless another file +name is specified in the PNG_DEBUG_FILE macro definition. + +When PNG_DEBUG > 0, the following functions (macros) become available: + + png_debug(level, message) + png_debug1(level, message, p1) + png_debug2(level, message, p1, p2) + +in which "level" is compared to PNG_DEBUG to decide whether to print +the message, "message" is the formatted string to be printed, +and p1 and p2 are parameters that are to be embedded in the string +according to printf-style formatting directives. For example, + + png_debug1(2, "foo=%d\n", foo); + +is expanded to + + if (PNG_DEBUG > 2) + fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo); + +When PNG_DEBUG is defined but is zero, the macros aren't defined, but you +can still use PNG_DEBUG to control your own debugging: + + #ifdef PNG_DEBUG + fprintf(stderr, ... + #endif + +When PNG_DEBUG = 1, the macros are defined, but only png_debug statements +having level = 0 will be printed. There aren't any such statements in +this version of libpng, but if you insert some they will be printed. + +VI. MNG support + +The MNG specification (available at http://www.libpng.org/pub/mng) allows +certain extensions to PNG for PNG images that are embedded in MNG datastreams. +Libpng can support some of these extensions. To enable them, use the +png_permit_mng_features() function: + + feature_set = png_permit_mng_features(png_ptr, mask) + + mask is a png_uint_32 containing the bitwise OR of the + features you want to enable. These include + PNG_FLAG_MNG_EMPTY_PLTE + PNG_FLAG_MNG_FILTER_64 + PNG_ALL_MNG_FEATURES + + feature_set is a png_uint_32 that is the bitwise AND of + your mask with the set of MNG features that is + supported by the version of libpng that you are using. + +It is an error to use this function when reading or writing a standalone +PNG file with the PNG 8-byte signature. The PNG datastream must be wrapped +in a MNG datastream. As a minimum, it must have the MNG 8-byte signature +and the MHDR and MEND chunks. Libpng does not provide support for these +or any other MNG chunks; your application must provide its own support for +them. You may wish to consider using libmng (available at +http://www.libmng.com) instead. + +VII. Changes to Libpng from version 0.88 + +It should be noted that versions of libpng later than 0.96 are not +distributed by the original libpng author, Guy Schalnat, nor by +Andreas Dilger, who had taken over from Guy during 1996 and 1997, and +distributed versions 0.89 through 0.96, but rather by another member +of the original PNG Group, Glenn Randers-Pehrson. Guy and Andreas are +still alive and well, but they have moved on to other things. + +The old libpng functions png_read_init(), png_write_init(), +png_info_init(), png_read_destroy(), and png_write_destroy() have been +moved to PNG_INTERNAL in version 0.95 to discourage their use. These +functions will be removed from libpng version 1.4.0. + +The preferred method of creating and initializing the libpng structures is +via the png_create_read_struct(), png_create_write_struct(), and +png_create_info_struct() because they isolate the size of the structures +from the application, allow version error checking, and also allow the +use of custom error handling routines during the initialization, which +the old functions do not. The functions png_read_destroy() and +png_write_destroy() do not actually free the memory that libpng +allocated for these structs, but just reset the data structures, so they +can be used instead of png_destroy_read_struct() and +png_destroy_write_struct() if you feel there is too much system overhead +allocating and freeing the png_struct for each image read. + +Setting the error callbacks via png_set_message_fn() before +png_read_init() as was suggested in libpng-0.88 is no longer supported +because this caused applications that do not use custom error functions +to fail if the png_ptr was not initialized to zero. It is still possible +to set the error callbacks AFTER png_read_init(), or to change them with +png_set_error_fn(), which is essentially the same function, but with a new +name to force compilation errors with applications that try to use the old +method. + +Starting with version 1.0.7, you can find out which version of the library +you are using at run-time: + + png_uint_32 libpng_vn = png_access_version_number(); + +The number libpng_vn is constructed from the major version, minor +version with leading zero, and release number with leading zero, +(e.g., libpng_vn for version 1.0.7 is 10007). + +Note that this function does not take a png_ptr, so you can call it +before you've created one. + +You can also check which version of png.h you used when compiling your +application: + + png_uint_32 application_vn = PNG_LIBPNG_VER; + +VIII. Changes to Libpng from version 1.0.x to 1.2.x + +Support for user memory management was enabled by default. To +accomplish this, the functions png_create_read_struct_2(), +png_create_write_struct_2(), png_set_mem_fn(), png_get_mem_ptr(), +png_malloc_default(), and png_free_default() were added. + +Support for the iTXt chunk has been enabled by default as of +version 1.2.41. + +Support for certain MNG features was enabled. + +Support for numbered error messages was added. However, we never got +around to actually numbering the error messages. The function +png_set_strip_error_numbers() was added (Note: the prototype for this +function was inadvertently removed from png.h in PNG_NO_ASSEMBLER_CODE +builds of libpng-1.2.15. It was restored in libpng-1.2.36). + +The png_malloc_warn() function was added at libpng-1.2.3. This issues +a png_warning and returns NULL instead of aborting when it fails to +acquire the requested memory allocation. + +Support for setting user limits on image width and height was enabled +by default. The functions png_set_user_limits(), png_get_user_width_max(), +and png_get_user_height_max() were added at libpng-1.2.6. + +The png_set_add_alpha() function was added at libpng-1.2.7. + +The function png_set_expand_gray_1_2_4_to_8() was added at libpng-1.2.9. +Unlike png_set_gray_1_2_4_to_8(), the new function does not expand the +tRNS chunk to alpha. The png_set_gray_1_2_4_to_8() function is +deprecated. + +A number of macro definitions in support of runtime selection of +assembler code features (especially Intel MMX code support) were +added at libpng-1.2.0: + + PNG_ASM_FLAG_MMX_SUPPORT_COMPILED + PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU + PNG_ASM_FLAG_MMX_READ_COMBINE_ROW + PNG_ASM_FLAG_MMX_READ_INTERLACE + PNG_ASM_FLAG_MMX_READ_FILTER_SUB + PNG_ASM_FLAG_MMX_READ_FILTER_UP + PNG_ASM_FLAG_MMX_READ_FILTER_AVG + PNG_ASM_FLAG_MMX_READ_FILTER_PAETH + PNG_ASM_FLAGS_INITIALIZED + PNG_MMX_READ_FLAGS + PNG_MMX_FLAGS + PNG_MMX_WRITE_FLAGS + PNG_MMX_FLAGS + +We added the following functions in support of runtime +selection of assembler code features: + + png_get_mmx_flagmask() + png_set_mmx_thresholds() + png_get_asm_flags() + png_get_mmx_bitdepth_threshold() + png_get_mmx_rowbytes_threshold() + png_set_asm_flags() + +We replaced all of these functions with simple stubs in libpng-1.2.20, +when the Intel assembler code was removed due to a licensing issue. + +These macros are deprecated: + + PNG_READ_TRANSFORMS_NOT_SUPPORTED + PNG_PROGRESSIVE_READ_NOT_SUPPORTED + PNG_NO_SEQUENTIAL_READ_SUPPORTED + PNG_WRITE_TRANSFORMS_NOT_SUPPORTED + PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED + PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED + +They have been replaced, respectively, by: + + PNG_NO_READ_TRANSFORMS + PNG_NO_PROGRESSIVE_READ + PNG_NO_SEQUENTIAL_READ + PNG_NO_WRITE_TRANSFORMS + PNG_NO_READ_ANCILLARY_CHUNKS + PNG_NO_WRITE_ANCILLARY_CHUNKS + +PNG_MAX_UINT was replaced with PNG_UINT_31_MAX. It has been +deprecated since libpng-1.0.16 and libpng-1.2.6. + +The function + png_check_sig(sig, num) +was replaced with + !png_sig_cmp(sig, 0, num) +It has been deprecated since libpng-0.90. + +The function + png_set_gray_1_2_4_to_8() +which also expands tRNS to alpha was replaced with + png_set_expand_gray_1_2_4_to_8() +which does not. It has been deprecated since libpng-1.0.18 and 1.2.9. + +IX. Changes to Libpng from version 1.0.x/1.2.x to 1.4.x + +Private libpng prototypes and macro definitions were moved from +png.h and pngconf.h into a new pngpriv.h header file. + +Functions png_set_benign_errors(), png_benign_error(), and +png_chunk_benign_error() were added. + +Support for setting the maximum amount of memory that the application +will allocate for reading chunks was added, as a security measure. +The functions png_set_chunk_cache_max() and png_get_chunk_cache_max() +were added to the library. + +We implemented support for I/O states by adding png_ptr member io_state +and functions png_get_io_chunk_name() and png_get_io_state() in pngget.c + +We added PNG_TRANSFORM_GRAY_TO_RGB to the available high-level +input transforms. + +Checking for and reporting of errors in the IHDR chunk is more thorough. + +Support for global arrays was removed, to improve thread safety. + +Some obsolete/deprecated macros and functions have been removed. + +Typecasted NULL definitions such as + #define png_voidp_NULL (png_voidp)NULL +were eliminated. If you used these in your application, just use +NULL instead. + +The png_struct and info_struct members "trans" and "trans_values" were +changed to "trans_alpha" and "trans_color", respectively. + +The obsolete, unused pnggccrd.c and pngvcrd.c files and related makefiles +were removed. + +The PNG_1_0_X and PNG_1_2_X macros were eliminated. + +The PNG_LEGACY_SUPPORTED macro was eliminated. + +Many WIN32_WCE #ifdefs were removed. + +The functions png_read_init(info_ptr), png_write_init(info_ptr), +png_info_init(info_ptr), png_read_destroy(), and png_write_destroy() +have been removed. They have been deprecated since libpng-0.95. + +The png_permit_empty_plte() was removed. It has been deprecated +since libpng-1.0.9. Use png_permit_mng_features() instead. + +We removed the obsolete stub functions png_get_mmx_flagmask(), +png_set_mmx_thresholds(), png_get_asm_flags(), +png_get_mmx_bitdepth_threshold(), png_get_mmx_rowbytes_threshold(), +png_set_asm_flags(), and png_mmx_supported() + +We removed the obsolete png_check_sig(), png_memcpy_check(), and +png_memset_check() functions. Instead use !png_sig_cmp(), png_memcpy(), +and png_memset(), respectively. + +The function png_set_gray_1_2_4_to_8() was removed. It has been +deprecated since libpng-1.0.18 and 1.2.9, when it was replaced with +png_set_expand_gray_1_2_4_to_8() because the former function also +expanded any tRNS chunk to an alpha channel. + +Macros for png_get_uint_16, png_get_uint_32, and png_get_int_32 +were added and are used by default instead of the corresponding +functions. Unfortunately, +from libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the +function) incorrectly returned a value of type png_uint_32. + +We changed the prototype for png_malloc() from + png_malloc(png_structp png_ptr, png_uint_32 size) +to + png_malloc(png_structp png_ptr, png_alloc_size_t size) + +This also applies to the prototype for the user replacement malloc_fn(). + +The png_calloc() function was added and is used in place of +of "png_malloc(); memset();" except in the case in png_read_png() +where the array consists of pointers; in this case a "for" loop is used +after the png_malloc() to set the pointers to NULL, to give robust. +behavior in case the application runs out of memory part-way through +the process. + +We changed the prototypes of png_get_compression_buffer_size() and +png_set_compression_buffer_size() to work with png_size_t instead of +png_uint_32. + +Support for numbered error messages was removed by default, since we +never got around to actually numbering the error messages. The function +png_set_strip_error_numbers() was removed from the library by default. + +The png_zalloc() and png_zfree() functions are no longer exported. +The png_zalloc() function no longer zeroes out the memory that it +allocates. Applications that called png_zalloc(png_ptr, number, size) +can call png_calloc(png_ptr, number*size) instead, and can call +png_free() instead of png_zfree(). + +Support for dithering was disabled by default in libpng-1.4.0, because +it has not been well tested and doesn't actually "dither". +The code was not +removed, however, and could be enabled by building libpng with +PNG_READ_DITHER_SUPPORTED defined. In libpng-1.4.2, this support +was reenabled, but the function was renamed png_set_quantize() to +reflect more accurately what it actually does. At the same time, +the PNG_DITHER_[RED,GREEN_BLUE]_BITS macros were also renamed to +PNG_QUANTIZE_[RED,GREEN,BLUE]_BITS, and PNG_READ_DITHER_SUPPORTED +was renamed to PNG_READ_QUANTIZE_SUPPORTED. + +We removed the trailing '.' from the warning and error messages. + +X. Changes to Libpng from version 1.4.x to 1.5.x + +From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the +function) incorrectly returned a value of type png_uint_32. + +Checking for invalid palette index on read or write was added at libpng +1.5.10. When an invalid index is found, libpng issues a benign error. +This is enabled by default but can be disabled in each png_ptr with + + png_set_check_for_invalid_index(png_ptr, allowed); + + allowed - one of + 0: disable + 1: enable + +A. Changes that affect users of libpng + +There are no substantial API changes between the non-deprecated parts of +the 1.4.5 API and the 1.5.0 API; however, the ability to directly access +members of the main libpng control structures, png_struct and png_info, +deprecated in earlier versions of libpng, has been completely removed from +libpng 1.5. + +We no longer include zlib.h in png.h. Applications that need access +to information in zlib.h will need to add the '#include "zlib.h"' +directive. It does not matter whether it is placed prior to or after +the '"#include png.h"' directive. + +The png_sprintf(), png_strcpy(), and png_strncpy() macros are no longer used +and were removed. + +We moved the png_strlen(), png_memcpy(), png_memset(), and png_memcmp() +macros into a private header file (pngpriv.h) that is not accessible to +applications. + +In png_get_iCCP, the type of "profile" was changed from png_charpp +to png_bytepp, and in png_set_iCCP, from png_charp to png_const_bytep. + +There are changes of form in png.h, including new and changed macros to +declare parts of the API. Some API functions with arguments that are +pointers to data not modified within the function have been corrected to +declare these arguments with PNG_CONST. + +Much of the internal use of C macros to control the library build has also +changed and some of this is visible in the exported header files, in +particular the use of macros to control data and API elements visible +during application compilation may require significant revision to +application code. (It is extremely rare for an application to do this.) + +Any program that compiled against libpng 1.4 and did not use deprecated +features or access internal library structures should compile and work +against libpng 1.5, except for the change in the prototype for +png_get_iCCP() and png_set_iCCP() API functions mentioned above. + +libpng 1.5.0 adds PNG_ PASS macros to help in the reading and writing of +interlaced images. The macros return the number of rows and columns in +each pass and information that can be used to de-interlace and (if +absolutely necessary) interlace an image. + +libpng 1.5.0 adds an API png_longjmp(png_ptr, value). This API calls +the application-provided png_longjmp_ptr on the internal, but application +initialized, longjmp buffer. It is provided as a convenience to avoid +the need to use the png_jmpbuf macro, which had the unnecessary side +effect of resetting the internal png_longjmp_ptr value. + +libpng 1.5.0 includes a complete fixed point API. By default this is +present along with the corresponding floating point API. In general the +fixed point API is faster and smaller than the floating point one because +the PNG file format used fixed point, not floating point. This applies +even if the library uses floating point in internal calculations. A new +macro, PNG_FLOATING_ARITHMETIC_SUPPORTED, reveals whether the library +uses floating point arithmetic (the default) or fixed point arithmetic +internally for performance critical calculations such as gamma correction. +In some cases, the gamma calculations may produce slightly different +results. This has changed the results in png_rgb_to_gray and in alpha +composition (png_set_background for example). This applies even if the +original image was already linear (gamma == 1.0) and, therefore, it is +not necessary to linearize the image. This is because libpng has *not* +been changed to optimize that case correctly, yet. + +Fixed point support for the sCAL chunk comes with an important caveat; +the sCAL specification uses a decimal encoding of floating point values +and the accuracy of PNG fixed point values is insufficient for +representation of these values. Consequently a "string" API +(png_get_sCAL_s and png_set_sCAL_s) is the only reliable way of reading +arbitrary sCAL chunks in the absence of either the floating point API or +internal floating point calculations. + +Applications no longer need to include the optional distribution header +file pngusr.h or define the corresponding macros during application +build in order to see the correct variant of the libpng API. From 1.5.0 +application code can check for the corresponding _SUPPORTED macro: + +#ifdef PNG_INCH_CONVERSIONS_SUPPORTED + /* code that uses the inch conversion APIs. */ +#endif + +This macro will only be defined if the inch conversion functions have been +compiled into libpng. The full set of macros, and whether or not support +has been compiled in, are available in the header file pnglibconf.h. +This header file is specific to the libpng build. Notice that prior to +1.5.0 the _SUPPORTED macros would always have the default definition unless +reset by pngusr.h or by explicit settings on the compiler command line. +These settings may produce compiler warnings or errors in 1.5.0 because +of macro redefinition. + +From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the +function) incorrectly returned a value of type png_uint_32. libpng 1.5.0 +is consistent with the implementation in 1.4.5 and 1.2.x (where the macro +did not exist.) + +Applications can now choose whether to use these macros or to call the +corresponding function by defining PNG_USE_READ_MACROS or +PNG_NO_USE_READ_MACROS before including png.h. Notice that this is +only supported from 1.5.0 -defining PNG_NO_USE_READ_MACROS prior to 1.5.0 +will lead to a link failure. + +Prior to libpng-1.5.4, the zlib compressor used the same set of parameters +when compressing the IDAT data and textual data such as zTXt and iCCP. +In libpng-1.5.4 we reinitialized the zlib stream for each type of data. +We added five png_set_text_*() functions for setting the parameters to +use with textual data. + +Prior to libpng-1.5.4, the PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED +option was off by default, and slightly inaccurate scaling occurred. +This option can no longer be turned off, and the choice of accurate +or inaccurate 16-to-8 scaling is by using the new png_set_scale_16_to_8() +API for accurate scaling or the old png_set_strip_16_to_8() API for simple +chopping. + +Prior to libpng-1.5.4, the png_set_user_limits() function could only be +used to reduce the width and height limits from the value of +PNG_USER_WIDTH_MAX and PNG_USER_HEIGHT_MAX, although this document said +that it could be used to override them. Now this function will reduce or +increase the limits. + +Starting in libpng-1.5.10, the user limits can be set en masse with the +configuration option PNG_SAFE_LIMITS_SUPPORTED. If this option is enabled, +a set of "safe" limits is applied in pngpriv.h. These can be overridden by +application calls to png_set_user_limits(), png_set_user_chunk_cache_max(), +and/or png_set_user_malloc_max() that increase or decrease the limits. Also, +in libpng-1.5.10 the default width and height limits were increased +from 1,000,000 to 0x7ffffff (i.e., made unlimited). Therefore, the +limits are now + default safe + png_user_width_max 0x7fffffff 1,000,000 + png_user_height_max 0x7fffffff 1,000,000 + png_user_chunk_cache_max 0 (unlimited) 128 + png_user_chunk_malloc_max 0 (unlimited) 8,000,000 + +B. Changes to the build and configuration of libpng + +Details of internal changes to the library code can be found in the CHANGES +file and in the GIT repository logs. These will be of no concern to the vast +majority of library users or builders; however, the few who configure libpng +to a non-default feature set may need to change how this is done. + +There should be no need for library builders to alter build scripts if +these use the distributed build support - configure or the makefiles - +however, users of the makefiles may care to update their build scripts +to build pnglibconf.h where the corresponding makefile does not do so. + +Building libpng with a non-default configuration has changed completely. +The old method using pngusr.h should still work correctly even though the +way pngusr.h is used in the build has been changed; however, library +builders will probably want to examine the changes to take advantage of +new capabilities and to simplify their build system. + +B.1 Specific changes to library configuration capabilities + +The library now supports a complete fixed point implementation and can +thus be used on systems that have no floating point support or very +limited or slow support. Previously gamma correction, an essential part +of complete PNG support, required reasonably fast floating point. + +As part of this the choice of internal implementation has been made +independent of the choice of fixed versus floating point APIs and all the +missing fixed point APIs have been implemented. + +The exact mechanism used to control attributes of API functions has +changed. A single set of operating system independent macro definitions +is used and operating system specific directives are defined in +pnglibconf.h + +As part of this the mechanism used to choose procedure call standards on +those systems that allow a choice has been changed. At present this only +affects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systems +running on Intel processors. As before, PNGAPI is defined where required +to control the exported API functions; however, two new macros, PNGCBAPI +and PNGCAPI, are used instead for callback functions (PNGCBAPI) and +(PNGCAPI) for functions that must match a C library prototype (currently +only png_longjmp_ptr, which must match the C longjmp function.) The new +approach is documented in pngconf.h + +Despite these changes, libpng 1.5.0 only supports the native C function +calling standard on those platforms tested so far (__cdecl on Microsoft +Windows). This is because the support requirements for alternative +calling conventions seem to no longer exist. Developers who find it +necessary to set PNG_API_RULE to 1 should advise the mailing list +(png-mng-implement) of this and library builders who use Openwatcom and +therefore set PNG_API_RULE to 2 should also contact the mailing list. + +A new test program, pngvalid, is provided in addition to pngtest. +pngvalid validates the arithmetic accuracy of the gamma correction +calculations and includes a number of validations of the file format. +A subset of the full range of tests is run when "make check" is done +(in the 'configure' build.) pngvalid also allows total allocated memory +usage to be evaluated and performs additional memory overwrite validation. + +Many changes to individual feature macros have been made. The following +are the changes most likely to be noticed by library builders who +configure libpng: + +1) All feature macros now have consistent naming: + +#define PNG_NO_feature turns the feature off +#define PNG_feature_SUPPORTED turns the feature on + +pnglibconf.h contains one line for each feature macro which is either: + +#define PNG_feature_SUPPORTED + +if the feature is supported or: + +/*#undef PNG_feature_SUPPORTED*/ + +if it is not. Library code consistently checks for the 'SUPPORTED' macro. +It does not, and libpng applications should not, check for the 'NO' macro +which will not normally be defined even if the feature is not supported. +The 'NO' macros are only used internally for setting or not setting the +corresponding 'SUPPORTED' macros. + +Compatibility with the old names is provided as follows: + +PNG_INCH_CONVERSIONS turns on PNG_INCH_CONVERSIONS_SUPPORTED + +And the following definitions disable the corresponding feature: + +PNG_SETJMP_NOT_SUPPORTED disables SETJMP +PNG_READ_TRANSFORMS_NOT_SUPPORTED disables READ_TRANSFORMS +PNG_NO_READ_COMPOSITED_NODIV disables READ_COMPOSITE_NODIV +PNG_WRITE_TRANSFORMS_NOT_SUPPORTED disables WRITE_TRANSFORMS +PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED disables READ_ANCILLARY_CHUNKS +PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED disables WRITE_ANCILLARY_CHUNKS + +Library builders should remove use of the above, inconsistent, names. + +2) Warning and error message formatting was previously conditional on +the STDIO feature. The library has been changed to use the +CONSOLE_IO feature instead. This means that if CONSOLE_IO is disabled +the library no longer uses the printf(3) functions, even though the +default read/write implementations use (FILE) style stdio.h functions. + +3) Three feature macros now control the fixed/floating point decisions: + +PNG_FLOATING_POINT_SUPPORTED enables the floating point APIs + +PNG_FIXED_POINT_SUPPORTED enables the fixed point APIs; however, in +practice these are normally required internally anyway (because the PNG +file format is fixed point), therefore in most cases PNG_NO_FIXED_POINT +merely stops the function from being exported. + +PNG_FLOATING_ARITHMETIC_SUPPORTED chooses between the internal floating +point implementation or the fixed point one. Typically the fixed point +implementation is larger and slower than the floating point implementation +on a system that supports floating point; however, it may be faster on a +system which lacks floating point hardware and therefore uses a software +emulation. + +4) Added PNG_{READ,WRITE}_INT_FUNCTIONS_SUPPORTED. This allows the +functions to read and write ints to be disabled independently of +PNG_USE_READ_MACROS, which allows libpng to be built with the functions +even though the default is to use the macros - this allows applications +to choose at app buildtime whether or not to use macros (previously +impossible because the functions weren't in the default build.) + +B.2 Changes to the configuration mechanism + +Prior to libpng-1.5.0 library builders who needed to configure libpng +had either to modify the exported pngconf.h header file to add system +specific configuration or had to write feature selection macros into +pngusr.h and cause this to be included into pngconf.h by defining +PNG_USER_CONFIG. The latter mechanism had the disadvantage that an +application built without PNG_USER_CONFIG defined would see the +unmodified, default, libpng API and thus would probably fail to link. + +These mechanisms still work in the configure build and in any makefile +build that builds pnglibconf.h, although the feature selection macros +have changed somewhat as described above. In 1.5.0, however, pngusr.h is +processed only once, when the exported header file pnglibconf.h is built. +pngconf.h no longer includes pngusr.h, therefore pngusr.h is ignored after the +build of pnglibconf.h and it is never included in an application build. + +The rarely used alternative of adding a list of feature macros to the +CFLAGS setting in the build also still works; however, the macros will be +copied to pnglibconf.h and this may produce macro redefinition warnings +when the individual C files are compiled. + +All configuration now only works if pnglibconf.h is built from +scripts/pnglibconf.dfa. This requires the program awk. Brian Kernighan +(the original author of awk) maintains C source code of that awk and this +and all known later implementations (often called by subtly different +names - nawk and gawk for example) are adequate to build pnglibconf.h. +The Sun Microsystems (now Oracle) program 'awk' is an earlier version +and does not work; this may also apply to other systems that have a +functioning awk called 'nawk'. + +Configuration options are now documented in scripts/pnglibconf.dfa. This +file also includes dependency information that ensures a configuration is +consistent; that is, if a feature is switched off dependent features are +also removed. As a recommended alternative to using feature macros in +pngusr.h a system builder may also define equivalent options in pngusr.dfa +(or, indeed, any file) and add that to the configuration by setting +DFA_XTRA to the file name. The makefiles in contrib/pngminim illustrate +how to do this, and a case where pngusr.h is still required. + +XI. Detecting libpng + +The png_get_io_ptr() function has been present since libpng-0.88, has never +changed, and is unaffected by conditional compilation macros. It is the +best choice for use in configure scripts for detecting the presence of any +libpng version since 0.88. In an autoconf "configure.in" you could use + + AC_CHECK_LIB(png, png_get_io_ptr, ... + +XII. Source code repository + +Since about February 2009, version 1.2.34, libpng has been under "git" source +control. The git repository was built from old libpng-x.y.z.tar.gz files +going back to version 0.70. You can access the git repository (read only) +at + + git://libpng.git.sourceforge.net/gitroot/libpng + +or you can browse it via "gitweb" at + + http://libpng.git.sourceforge.net/git/gitweb.cgi?p=libpng + +Patches can be sent to glennrp at users.sourceforge.net or to +png-mng-implement at lists.sourceforge.net or you can upload them to +the libpng bug tracker at + + http://libpng.sourceforge.net + +We also accept patches built from the tar or zip distributions, and +simple verbal discriptions of bug fixes, reported either to the +SourceForge bug tracker, to the png-mng-implement at lists.sf.net +mailing list, or directly to glennrp. + +XIII. Coding style + +Our coding style is similar to the "Allman" style, with curly +braces on separate lines: + + if (condition) + { + action; + } + + else if (another condition) + { + another action; + } + +The braces can be omitted from simple one-line actions: + + if (condition) + return (0); + +We use 3-space indentation, except for continued statements which +are usually indented the same as the first line of the statement +plus four more spaces. + +For macro definitions we use 2-space indentation, always leaving the "#" +in the first column. + + #ifndef PNG_NO_FEATURE + # ifndef PNG_FEATURE_SUPPORTED + # define PNG_FEATURE_SUPPORTED + # endif + #endif + +Comments appear with the leading "/*" at the same indentation as +the statement that follows the comment: + + /* Single-line comment */ + statement; + + /* This is a multiple-line + * comment. + */ + statement; + +Very short comments can be placed after the end of the statement +to which they pertain: + + statement; /* comment */ + +We don't use C++ style ("//") comments. We have, however, +used them in the past in some now-abandoned MMX assembler +code. + +Functions and their curly braces are not indented, and +exported functions are marked with PNGAPI: + + /* This is a public function that is visible to + * application programmers. It does thus-and-so. + */ + void PNGAPI + png_exported_function(png_ptr, png_info, foo) + { + body; + } + +The prototypes for all exported functions appear in png.h, +above the comment that says + + /* Maintainer: Put new public prototypes here ... */ + +We mark all non-exported functions with "/* PRIVATE */"": + + void /* PRIVATE */ + png_non_exported_function(png_ptr, png_info, foo) + { + body; + } + +The prototypes for non-exported functions (except for those in +pngtest) appear in +pngpriv.h +above the comment that says + + /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ + +To avoid polluting the global namespace, the names of all exported +functions and variables begin with "png_", and all publicly visible C +preprocessor macros begin with "PNG". We request that applications that +use libpng *not* begin any of their own symbols with either of these strings. + +We put a space after each comma and after each semicolon +in "for" statements, and we put spaces before and after each +C binary operator and after "for" or "while", and before +"?". We don't put a space between a typecast and the expression +being cast, nor do we put one between a function name and the +left parenthesis that follows it: + + for (i = 2; i > 0; --i) + y[i] = a(x) + (int)b; + +We prefer #ifdef and #ifndef to #if defined() and if !defined() +when there is only one macro being tested. + +We prefer to express integers that are used as bit masks in hex format, +with an even number of lower-case hex digits (e.g., 0x00, 0xff, 0x0100). + +We do not use the TAB character for indentation in the C sources. + +Lines do not exceed 80 characters. + +Other rules can be inferred by inspecting the libpng source. + +XIV. Y2K Compliance in libpng + +September 27, 2012 + +Since the PNG Development group is an ad-hoc body, we can't make +an official declaration. + +This is your unofficial assurance that libpng from version 0.71 and +upward through 1.5.13 are Y2K compliant. It is my belief that earlier +versions were also Y2K compliant. + +Libpng only has two year fields. One is a 2-byte unsigned integer that +will hold years up to 65535. The other holds the date in text +format, and will hold years up to 9999. + +The integer is + "png_uint_16 year" in png_time_struct. + +The string is + "char time_buffer[29]" in png_struct. This will no +longer be used in libpng-1.6.x and will be removed from libpng-1.7.0. + +There are seven time-related functions: + + png_convert_to_rfc_1123() in png.c + (formerly png_convert_to_rfc_1152() in error) + png_convert_from_struct_tm() in pngwrite.c, called + in pngwrite.c + png_convert_from_time_t() in pngwrite.c + png_get_tIME() in pngget.c + png_handle_tIME() in pngrutil.c, called in pngread.c + png_set_tIME() in pngset.c + png_write_tIME() in pngwutil.c, called in pngwrite.c + +All appear to handle dates properly in a Y2K environment. The +png_convert_from_time_t() function calls gmtime() to convert from system +clock time, which returns (year - 1900), which we properly convert to +the full 4-digit year. There is a possibility that applications using +libpng are not passing 4-digit years into the png_convert_to_rfc_1123() +function, or that they are incorrectly passing only a 2-digit year +instead of "year - 1900" into the png_convert_from_struct_tm() function, +but this is not under our control. The libpng documentation has always +stated that it works with 4-digit years, and the APIs have been +documented as such. + +The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned +integer to hold the year, and can hold years as large as 65535. + +zlib, upon which libpng depends, is also Y2K compliant. It contains +no date-related code. + + + Glenn Randers-Pehrson + libpng maintainer + PNG Development Group diff --git a/plugins/AdvaImg/src/LibPNG/libpng.3 b/plugins/AdvaImg/src/LibPNG/libpng.3 index 1d72ab4cae..e0e0aec725 100644 --- a/plugins/AdvaImg/src/LibPNG/libpng.3 +++ b/plugins/AdvaImg/src/LibPNG/libpng.3 @@ -1,6 +1,6 @@ -.TH LIBPNG 3 "February 18, 2012" +.TH LIBPNG 3 "September 27, 2012" .SH NAME -libpng \- Portable Network Graphics (PNG) Reference Library 1.5.9 +libpng \- Portable Network Graphics (PNG) Reference Library 1.5.13 .SH SYNOPSIS \fI\fB @@ -552,6 +552,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.5.9 \fI\fB +\fBvoid png_set_check_for_invalid_index(png_structrp \fP\fIpng_ptr\fP\fB, int \fIallowed\fP\fB);\fP + +\fI\fB + \fBvoid png_set_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fP\fIwhite_x\fP\fB, double \fP\fIwhite_y\fP\fB, double \fP\fIred_x\fP\fB, double \fP\fIred_y\fP\fB, double \fP\fIgreen_x\fP\fB, double \fP\fIgreen_y\fP\fB, double \fP\fIblue_x\fP\fB, double \fIblue_y\fP\fB);\fP \fI\fB @@ -958,14 +962,6 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.5.9 \fI\fB -\fBvoidpf png_zalloc (voidpf \fP\fIpng_ptr\fP\fB, uInt \fP\fIitems\fP\fB, uInt \fIsize\fP\fB);\fP - -\fI\fB - -\fBvoid png_zfree (voidpf \fP\fIpng_ptr\fP\fB, voidpf \fIptr\fP\fB);\fP - -\fI\fB - .SH DESCRIPTION The .I libpng @@ -975,12 +971,12 @@ the Portable Network Graphics (PNG) format image files. It uses the compression library. Following is a copy of the libpng-manual.txt file that accompanies libpng. .SH LIBPNG.TXT -libpng-manual.txt - A description on how to use and modify libpng +Libpng-manual.txt - A description on how to use and modify libpng - libpng version 1.5.9 - February 18, 2012 + libpng version 1.5.13 - September 27, 2012 Updated and distributed by Glenn Randers-Pehrson - Copyright (c) 1998-2011 Glenn Randers-Pehrson + Copyright (c) 1998-2012 Glenn Randers-Pehrson This document is released under the libpng license. For conditions of distribution and use, see the disclaimer @@ -988,9 +984,9 @@ libpng-manual.txt - A description on how to use and modify libpng Based on: - libpng versions 0.97, January 1998, through 1.5.9 - February 18, 2012 + libpng versions 0.97, January 1998, through 1.5.13 - September 27, 2012 Updated and distributed by Glenn Randers-Pehrson - Copyright (c) 1998-2011 Glenn Randers-Pehrson + Copyright (c) 1998-2012 Glenn Randers-Pehrson libpng 1.0 beta 6 version 0.96 May 28, 1997 Updated and distributed by Andreas Dilger @@ -1118,8 +1114,8 @@ APIs. Most of these are fairly obvious; for example types corresponding to integers of particular sizes and types for passing color values. One exception is how non-integral numbers are handled. For application -convenience most APIs that take such numbers have C (double) arguments, -however internally PNG, and libpng, use 32 bit signed integers and encode +convenience most APIs that take such numbers have C (double) arguments; +however, internally PNG, and libpng, use 32 bit signed integers and encode the value by multiplying by 100,000. As of libpng 1.5.0 a convenience macro PNG_FP_1 is defined in png.h along with a type (png_fixed_point) which is simply (png_int_32). @@ -1700,11 +1696,11 @@ Libpng only supports composing onto a single color (using png_set_background; see below). Otherwise you must do the composition yourself and, in this case, you may need to call png_set_alpha_mode: -#if PNG_LIBPNG_VER >= 10504 - png_set_alpha_mode(png_ptr, mode, screen_gamma); -#else - png_set_gamma(png_ptr, screen_gamma, 1.0/screen_gamma); -#endif + #if PNG_LIBPNG_VER >= 10504 + png_set_alpha_mode(png_ptr, mode, screen_gamma); + #else + png_set_gamma(png_ptr, screen_gamma, 1.0/screen_gamma); + #endif The screen_gamma value is the same as the argument to png_set_gamma; however, how it affects the output depends on the mode. png_set_alpha_mode() sets the @@ -1776,7 +1772,7 @@ the screen_gamma value. Pixels with alpha less than 1.0 will still have linear components. Use this format if you have control over your -compositing software and do don't do other arithmetic +compositing software and so don't do other arithmetic (such as scaling) on the data you get from libpng. Your compositing software can simply copy opaque pixels to the output but still has linear values for the @@ -2107,6 +2103,11 @@ data has been read, or zero if it is missing. The parameters to the png_get_ are set directly if they are simple data types, or a pointer into the info_ptr is returned for any complex types. +The colorspace data from gAMA, cHRM, sRGB, iCCP, and sBIT chunks +is simply returned to give the application information about how the +image was encoded. Libpng itself only does transformations using the file +gamma when combining semitransparent pixels with the background color. + png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette); @@ -2118,14 +2119,14 @@ pointer into the info_ptr is returned for any complex types. png_get_gAMA(png_ptr, info_ptr, &file_gamma); png_get_gAMA_fixed(png_ptr, info_ptr, &int_file_gamma); - file_gamma - the gamma at which the file is + file_gamma - the gamma at which the file was written (PNG_INFO_gAMA) int_file_gamma - 100,000 times the gamma at which the file is written - png_get_cHRM(png_ptr, info_ptr, &white_x, &white_y, &red_x, &red_y, - &green_x, &green_y, &blue_x, &blue_y) + png_get_cHRM(png_ptr, info_ptr, &white_x, &white_y, &red_x, + &red_y, &green_x, &green_y, &blue_x, &blue_y) png_get_cHRM_XYZ(png_ptr, info_ptr, &red_X, &red_Y, &red_Z, &green_X, &green_Y, &green_Z, &blue_X, &blue_Y, &blue_Z) png_get_cHRM_fixed(png_ptr, info_ptr, &int_white_x, &int_white_y, @@ -2136,8 +2137,9 @@ pointer into the info_ptr is returned for any complex types. &int_blue_X, &int_blue_Y, &int_blue_Z) {white,red,green,blue}_{x,y} - A color space encoding specified using the chromaticities - of the end points and the white point. (PNG_INFO_cHRM) + A color space encoding specified using the + chromaticities of the end points and the + white point. (PNG_INFO_cHRM) {red,green,blue}_{X,Y,Z} A color space encoding specified using the encoding end @@ -2548,17 +2550,19 @@ Within the matrix, "A" means the transformation is obtained by png_set_add_alpha(). "X" means the transformation is obtained by png_set_expand(). "1" means the transformation is obtained by - png_set_expand_gray_1_2_4_to_8() (and by png_set_expand() if there - is no transparency in the original or the final format). + png_set_expand_gray_1_2_4_to_8() (and by png_set_expand() + if there is no transparency in the original or the final + format). "C" means the transformation is obtained by png_set_gray_to_rgb(). "G" means the transformation is obtained by png_set_rgb_to_gray(). "P" means the transformation is obtained by png_set_expand_palette_to_rgb(). "p" means the transformation is obtained by png_set_packing(). "Q" means the transformation is obtained by png_set_quantize(). - "T" means the transformation is obtained by png_set_tRNS_to_alpha(). - "B" means the transformation is obtained by png_set_background(), or - png_strip_alpha(). + "T" means the transformation is obtained by + png_set_tRNS_to_alpha(). + "B" means the transformation is obtained by + png_set_background(), or png_strip_alpha(). When an entry has multiple transforms listed all are required to cause the right overall transformation. When two transforms are separated by a comma @@ -2643,8 +2647,8 @@ with alpha. if (color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_rgb_to_gray(png_ptr, error_action, double red_weight, - double green_weight); + png_set_rgb_to_gray(png_ptr, error_action, + double red_weight, double green_weight); error_action = 1: silently do the conversion @@ -2666,7 +2670,8 @@ with alpha. In the corresponding fixed point API the red_weight and green_weight values are simply scaled by 100,000: - png_set_rgb_to_gray(png_ptr, error_action, png_fixed_point red_weight, + png_set_rgb_to_gray(png_ptr, error_action, + png_fixed_point red_weight, png_fixed_point green_weight); If you have set error_action = 1 or 2, you can @@ -2710,7 +2715,7 @@ the current display (e.g., the background color from a web page). You need to tell libpng how the color is represented, both the format of the component values in the color (the number of bits) and the gamma encoding of the color. The function takes two arguments, background_gamma_mode and need_expand -to convey this information, however only two combinations are likely to be +to convey this information; however, only two combinations are likely to be useful: png_color_16 my_background; @@ -3004,7 +3009,7 @@ the second parameter NULL. If you don't want libpng to handle the interlacing details, just call png_read_rows() PNG_INTERLACE_ADAM7_PASSES times to read in all the images. -Each of the images is a valid image by itself, however you will almost +Each of the images is a valid image by itself; however, you will almost certainly need to distribute the pixels from each sub-image to the correct place. This is where everything gets very tricky. @@ -3161,7 +3166,7 @@ sPLT, only the n'th item in the structure is freed, where n is "seq". The default behavior is only to free data that was allocated internally by libpng. This can be changed, so that libpng will not free the data, or so that it will free data that was allocated by the user with png_malloc() -or png_zalloc() and passed in via a png_set_*() function, with +or png_calloc() and passed in via a png_set_*() function, with png_data_freer(png_ptr, info_ptr, freer, mask) @@ -3182,7 +3187,7 @@ or png_destroy_*() is supposed to free the data. When the user assumes responsibility for libpng-allocated data, the application must use png_free() to free it, and when the user transfers responsibility to libpng for data that the user has allocated, the user must have used png_malloc() -or png_zalloc() to allocate it. +or png_calloc() to allocate it. If you allocated your row_pointers in a single block, as suggested above in the description of the high level read interface, you must not transfer @@ -4000,8 +4005,8 @@ tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"), although this isn't a requirement. Unlike the tIME chunk, the "Creation Time" tEXt chunk is not expected to be automatically changed by the software. To facilitate the use of RFC 1123 dates, a function -png_convert_to_rfc1123(png_timep) is provided to convert from PNG -time to an RFC 1123 format string. +png_convert_to_rfc1123(png_ptr, png_timep) is provided to convert +from PNG time to an RFC 1123 format string. .SS Writing unknown chunks @@ -4363,7 +4368,7 @@ png_destroy_write_struct(). The default behavior is only to free data that was allocated internally by libpng. This can be changed, so that libpng will not free the data, or so that it will free data that was allocated by the user with png_malloc() -or png_zalloc() and passed in via a png_set_*() function, with +or png_calloc() and passed in via a png_set_*() function, with png_data_freer(png_ptr, info_ptr, freer, mask) @@ -4399,7 +4404,7 @@ When the user assumes responsibility for libpng-allocated data, the application must use png_free() to free it, and when the user transfers responsibility to libpng for data that the user has allocated, the user must have used png_malloc() -or png_zalloc() to allocate it. +or png_calloc() to allocate it. If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword separately, do not transfer responsibility for freeing text_ptr to libpng, @@ -4427,12 +4432,13 @@ in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively. To change these functions, call the appropriate png_set_*_fn() function. Memory allocation is done through the functions png_malloc(), png_calloc(), -and png_free(). These currently just call the standard C functions. -png_calloc() calls png_malloc() and then clears the newly -allocated memory to zero. There is limited support for certain systems -with segmented memory architectures and the types of pointers declared by -png.h match this; you will have to use appropriate pointers in your -application. Since it is +and png_free(). The png_malloc() and png_free() functions currently just +call the standard C functions and png_calloc() calls png_malloc() and then +clears the newly allocated memory to zero; note that png_calloc(png_ptr, size) +is not the same as the calloc(number, size) function provided by stdlib.h. +There is limited support for certain systems with segmented memory +architectures and the types of pointers declared by png.h match this; you +will have to use appropriate pointers in your application. Since it is unlikely that the method of handling memory allocation on a platform will change between applications, these functions must be modified in the library at compile time. If you prefer to use a different method @@ -4663,7 +4669,7 @@ available to set these separately for non-IDAT compressed chunks such as zTXt, iTXt, and iCCP: #include zlib.h - #if PNG_LIBPNG_VER <= 10504 + #if PNG_LIBPNG_VER >= 10504 png_set_text_compression_level(png_ptr, level); png_set_text_compression_mem_level(png_ptr, level); @@ -5062,8 +5068,8 @@ png_get_mmx_bitdepth_threshold(), png_get_mmx_rowbytes_threshold(), png_set_asm_flags(), and png_mmx_supported() We removed the obsolete png_check_sig(), png_memcpy_check(), and -png_memset_check() functions. Instead use !png_sig_cmp(), memcpy(), -and memset(), respectively. +png_memset_check() functions. Instead use !png_sig_cmp(), png_memcpy(), +and png_memset(), respectively. The function png_set_gray_1_2_4_to_8() was removed. It has been deprecated since libpng-1.0.18 and 1.2.9, when it was replaced with @@ -5100,7 +5106,9 @@ png_set_strip_error_numbers() was removed from the library by default. The png_zalloc() and png_zfree() functions are no longer exported. The png_zalloc() function no longer zeroes out the memory that it -allocates. +allocates. Applications that called png_zalloc(png_ptr, number, size) +can call png_calloc(png_ptr, number*size) instead, and can call +png_free() instead of png_zfree(). Support for dithering was disabled by default in libpng-1.4.0, because it has not been well tested and doesn't actually "dither". @@ -5120,12 +5128,22 @@ We removed the trailing '.' from the warning and error messages. From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the function) incorrectly returned a value of type png_uint_32. +Checking for invalid palette index on read or write was added at libpng +1.5.10. When an invalid index is found, libpng issues a benign error. +This is enabled by default but can be disabled in each png_ptr with + + png_set_check_for_invalid_index(png_ptr, allowed); + + allowed - one of + 0: disable + 1: enable + A. Changes that affect users of libpng There are no substantial API changes between the non-deprecated parts of -the 1.4.5 API and the 1.5.0 API, however the ability to directly access -the main libpng control structures, png_struct and png_info, deprecated -in earlier versions of libpng, has been completely removed from +the 1.4.5 API and the 1.5.0 API; however, the ability to directly access +members of the main libpng control structures, png_struct and png_info, +deprecated in earlier versions of libpng, has been completely removed from libpng 1.5. We no longer include zlib.h in png.h. Applications that need access @@ -5133,9 +5151,12 @@ to information in zlib.h will need to add the '#include "zlib.h"' directive. It does not matter whether it is placed prior to or after the '"#include png.h"' directive. -We moved the png_strcpy(), png_strncpy(), png_strlen(), png_memcpy(), -png_memcmp(), png_sprintf, and png_memcpy() macros into a private -header file (pngpriv.h) that is not accessible to applications. +The png_sprintf(), png_strcpy(), and png_strncpy() macros are no longer used +and were removed. + +We moved the png_strlen(), png_memcpy(), png_memset(), and png_memcmp() +macros into a private header file (pngpriv.h) that is not accessible to +applications. In png_get_iCCP, the type of "profile" was changed from png_charpp to png_bytepp, and in png_set_iCCP, from png_charp to png_const_bytep. @@ -5238,16 +5259,30 @@ PNG_USER_WIDTH_MAX and PNG_USER_HEIGHT_MAX, although this document said that it could be used to override them. Now this function will reduce or increase the limits. +Starting in libpng-1.5.10, the user limits can be set en masse with the +configuration option PNG_SAFE_LIMITS_SUPPORTED. If this option is enabled, +a set of "safe" limits is applied in pngpriv.h. These can be overridden by +application calls to png_set_user_limits(), png_set_user_chunk_cache_max(), +and/or png_set_user_malloc_max() that increase or decrease the limits. Also, +in libpng-1.5.10 the default width and height limits were increased +from 1,000,000 to 0x7ffffff (i.e., made unlimited). Therefore, the +limits are now + default safe + png_user_width_max 0x7fffffff 1,000,000 + png_user_height_max 0x7fffffff 1,000,000 + png_user_chunk_cache_max 0 (unlimited) 128 + png_user_chunk_malloc_max 0 (unlimited) 8,000,000 + B. Changes to the build and configuration of libpng Details of internal changes to the library code can be found in the CHANGES file and in the GIT repository logs. These will be of no concern to the vast -majority of library users or builders, however the few who configure libpng +majority of library users or builders; however, the few who configure libpng to a non-default feature set may need to change how this is done. There should be no need for library builders to alter build scripts if these use the distributed build support - configure or the makefiles - -however users of the makefiles may care to update their build scripts +however, users of the makefiles may care to update their build scripts to build pnglibconf.h where the corresponding makefile does not do so. Building libpng with a non-default configuration has changed completely. @@ -5353,7 +5388,7 @@ merely stops the function from being exported. PNG_FLOATING_ARITHMETIC_SUPPORTED chooses between the internal floating point implementation or the fixed point one. Typically the fixed point implementation is larger and slower than the floating point implementation -on a system that supports floating point, however it may be faster on a +on a system that supports floating point; however, it may be faster on a system which lacks floating point hardware and therefore uses a software emulation. @@ -5382,7 +5417,7 @@ pngconf.h no longer includes pngusr.h, therefore pngusr.h is ignored after the build of pnglibconf.h and it is never included in an application build. The rarely used alternative of adding a list of feature macros to the -CFLAGS setting in the build also still works, however the macros will be +CFLAGS setting in the build also still works; however, the macros will be copied to pnglibconf.h and this may produce macro redefinition warnings when the individual C files are compiled. @@ -5523,8 +5558,8 @@ above the comment that says /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ To avoid polluting the global namespace, the names of all exported -functions and variables begin with "png_", and all publicly visible C -preprocessor macros begin with "PNG_". We request that applications that +functions and variables begin with "png_", and all publicly visible C +preprocessor macros begin with "PNG". We request that applications that use libpng *not* begin any of their own symbols with either of these strings. We put a space after each comma and after each semicolon @@ -5551,25 +5586,25 @@ Other rules can be inferred by inspecting the libpng source. .SH XIV. Y2K Compliance in libpng -February 18, 2012 +September 27, 2012 Since the PNG Development group is an ad-hoc body, we can't make an official declaration. This is your unofficial assurance that libpng from version 0.71 and -upward through 1.5.9 are Y2K compliant. It is my belief that earlier +upward through 1.5.13 are Y2K compliant. It is my belief that earlier versions were also Y2K compliant. -Libpng only has three year fields. One is a 2-byte unsigned integer that -will hold years up to 65535. The other two hold the date in text +Libpng only has two year fields. One is a 2-byte unsigned integer that +will hold years up to 65535. The other holds the date in text format, and will hold years up to 9999. The integer is "png_uint_16 year" in png_time_struct. -The strings are - "png_charp time_buffer" in png_struct and - "near_time_buffer", which is a local character string in png.c. +The string is + "char time_buffer[29]" in png_struct. This will no +longer be used in libpng-1.6.x and will be removed from libpng-1.7.0. There are seven time-related functions: @@ -5768,6 +5803,15 @@ the first widely used release: 1.5.9beta01-02 15 10509 15.so.15.9[.0] 1.5.9rc01 15 10509 15.so.15.9[.0] 1.5.9 15 10509 15.so.15.9[.0] + 1.5.10beta01-05 15 10510 15.so.15.10[.0] + 1.5.10 15 10510 15.so.15.10[.0] + 1.5.11beta01 15 10511 15.so.15.11[.0] + 1.5.11rc01-05 15 10511 15.so.15.11[.0] + 1.5.11 15 10511 15.so.15.11[.0] + 1.5.12 15 10512 15.so.15.12[.0] + 1.5.13beta01-02 15 10513 15.so.15.13[.0] + 1.5.13rc01 15 10513 15.so.15.13[.0] + 1.5.13 15 10513 15.so.15.13[.0] Henceforth the source version will match the shared-library minor and patch numbers; the shared-library major version number will be @@ -5824,7 +5868,7 @@ possible without all of you. Thanks to Frank J. T. Wojcik for helping with the documentation. -Libpng version 1.5.9 - February 18, 2012: +Libpng version 1.5.13 - September 27, 2012: Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc. Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net). @@ -5847,7 +5891,7 @@ this sentence. This code is released under the libpng license. -libpng versions 1.2.6, August 15, 2004, through 1.5.9, February 18, 2012, are +libpng versions 1.2.6, August 15, 2004, through 1.5.13, September 27, 2012, are Copyright (c) 2004,2006-2007 Glenn Randers-Pehrson, and are distributed according to the same disclaimer and license as libpng-1.2.5 with the following individual added to the list of Contributing Authors @@ -5946,7 +5990,7 @@ certification mark of the Open Source Initiative. Glenn Randers-Pehrson glennrp at users.sourceforge.net -February 18, 2012 +September 27, 2012 .\" end of man page diff --git a/plugins/AdvaImg/src/LibPNG/libpng.txt b/plugins/AdvaImg/src/LibPNG/libpng.txt deleted file mode 100644 index f1eefbbb37..0000000000 --- a/plugins/AdvaImg/src/LibPNG/libpng.txt +++ /dev/null @@ -1,3352 +0,0 @@ -libpng.txt - A description on how to use and modify libpng - - libpng version 1.4.3 - June 26, 2010 - Updated and distributed by Glenn Randers-Pehrson - - Copyright (c) 1998-2009 Glenn Randers-Pehrson - - This document is released under the libpng license. - For conditions of distribution and use, see the disclaimer - and license in png.h - - Based on: - - libpng versions 0.97, January 1998, through 1.4.3 - June 26, 2010 - Updated and distributed by Glenn Randers-Pehrson - Copyright (c) 1998-2009 Glenn Randers-Pehrson - - libpng 1.0 beta 6 version 0.96 May 28, 1997 - Updated and distributed by Andreas Dilger - Copyright (c) 1996, 1997 Andreas Dilger - - libpng 1.0 beta 2 - version 0.88 January 26, 1996 - For conditions of distribution and use, see copyright - notice in png.h. Copyright (c) 1995, 1996 Guy Eric - Schalnat, Group 42, Inc. - - Updated/rewritten per request in the libpng FAQ - Copyright (c) 1995, 1996 Frank J. T. Wojcik - December 18, 1995 & January 20, 1996 - -I. Introduction - -This file describes how to use and modify the PNG reference library -(known as libpng) for your own use. There are five sections to this -file: introduction, structures, reading, writing, and modification and -configuration notes for various special platforms. In addition to this -file, example.c is a good starting point for using the library, as -it is heavily commented and should include everything most people -will need. We assume that libpng is already installed; see the -INSTALL file for instructions on how to install libpng. - -For examples of libpng usage, see the files "example.c", "pngtest.c", -and the files in the "contrib" directory, all of which are included in -the libpng distribution. - -Libpng was written as a companion to the PNG specification, as a way -of reducing the amount of time and effort it takes to support the PNG -file format in application programs. - -The PNG specification (second edition), November 2003, is available as -a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2003 (E)) at -. It is technically equivalent -to the PNG specification (second edition) but has some additional material. - -The PNG-1.0 specification is available -as RFC 2083 and as a -W3C Recommendation . - -Some additional chunks are described in the special-purpose public chunks -documents at . - -Other information -about PNG, and the latest version of libpng, can be found at the PNG home -page, . - -Most users will not have to modify the library significantly; advanced -users may want to modify it more. All attempts were made to make it as -complete as possible, while keeping the code easy to understand. -Currently, this library only supports C. Support for other languages -is being considered. - -Libpng has been designed to handle multiple sessions at one time, -to be easily modifiable, to be portable to the vast majority of -machines (ANSI, K&R, 16-, 32-, and 64-bit) available, and to be easy -to use. The ultimate goal of libpng is to promote the acceptance of -the PNG file format in whatever way possible. While there is still -work to be done (see the TODO file), libpng should cover the -majority of the needs of its users. - -Libpng uses zlib for its compression and decompression of PNG files. -Further information about zlib, and the latest version of zlib, can -be found at the zlib home page, . -The zlib compression utility is a general purpose utility that is -useful for more than PNG files, and can be used without libpng. -See the documentation delivered with zlib for more details. -You can usually find the source files for the zlib utility wherever you -find the libpng source files. - -Libpng is thread safe, provided the threads are using different -instances of the structures. Each thread should have its own -png_struct and png_info instances, and thus its own image. -Libpng does not protect itself against two threads using the -same instance of a structure. - -II. Structures - -There are two main structures that are important to libpng, png_struct -and png_info. The first, png_struct, is an internal structure that -will not, for the most part, be used by a user except as the first -variable passed to every libpng function call. - -The png_info structure is designed to provide information about the -PNG file. At one time, the fields of png_info were intended to be -directly accessible to the user. However, this tended to cause problems -with applications using dynamically loaded libraries, and as a result -a set of interface functions for png_info (the png_get_*() and png_set_*() -functions) was developed. The fields of png_info are still available for -older applications, but it is suggested that applications use the new -interfaces if at all possible. - -Applications that do make direct access to the members of png_struct (except -for png_ptr->jmpbuf) must be recompiled whenever the library is updated, -and applications that make direct access to the members of png_info must -be recompiled if they were compiled or loaded with libpng version 1.0.6, -in which the members were in a different order. In version 1.0.7, the -members of the png_info structure reverted to the old order, as they were -in versions 0.97c through 1.0.5. Starting with version 2.0.0, both -structures are going to be hidden, and the contents of the structures will -only be accessible through the png_get/png_set functions. - -The png.h header file is an invaluable reference for programming with libpng. -And while I'm on the topic, make sure you include the libpng header file: - -#include - -III. Reading - -We'll now walk you through the possible functions to call when reading -in a PNG file sequentially, briefly explaining the syntax and purpose -of each one. See example.c and png.h for more detail. While -progressive reading is covered in the next section, you will still -need some of the functions discussed in this section to read a PNG -file. - -Setup - -You will want to do the I/O initialization(*) before you get into libpng, -so if it doesn't work, you don't have much to undo. Of course, you -will also want to insure that you are, in fact, dealing with a PNG -file. Libpng provides a simple check to see if a file is a PNG file. -To use it, pass in the first 1 to 8 bytes of the file to the function -png_sig_cmp(), and it will return 0 (false) if the bytes match the -corresponding bytes of the PNG signature, or nonzero (true) otherwise. -Of course, the more bytes you pass in, the greater the accuracy of the -prediction. - -If you are intending to keep the file pointer open for use in libpng, -you must ensure you don't read more than 8 bytes from the beginning -of the file, and you also have to make a call to png_set_sig_bytes_read() -with the number of bytes you read from the beginning. Libpng will -then only check the bytes (if any) that your program didn't read. - -(*): If you are not using the standard I/O functions, you will need -to replace them with custom functions. See the discussion under -Customizing libpng. - - - FILE *fp = fopen(file_name, "rb"); - if (!fp) - { - return (ERROR); - } - fread(header, 1, number, fp); - is_png = !png_sig_cmp(header, 0, number); - if (!is_png) - { - return (NOT_PNG); - } - - -Next, png_struct and png_info need to be allocated and initialized. In -order to ensure that the size of these structures is correct even with a -dynamically linked libpng, there are functions to initialize and -allocate the structures. We also pass the library version, optional -pointers to error handling functions, and a pointer to a data struct for -use by the error functions, if necessary (the pointer and functions can -be NULL if the default error handlers are to be used). See the section -on Changes to Libpng below regarding the old initialization functions. -The structure allocation functions quietly return NULL if they fail to -create the structure, so your application should check for that. - - png_structp png_ptr = png_create_read_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_read_struct(&png_ptr, - (png_infopp)NULL, (png_infopp)NULL); - return (ERROR); - } - - png_infop end_info = png_create_info_struct(png_ptr); - if (!end_info) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - -If you want to use your own memory allocation routines, -define PNG_USER_MEM_SUPPORTED and use -png_create_read_struct_2() instead of png_create_read_struct(): - - png_structp png_ptr = png_create_read_struct_2 - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn, (png_voidp) - user_mem_ptr, user_malloc_fn, user_free_fn); - -The error handling routines passed to png_create_read_struct() -and the memory alloc/free routines passed to png_create_struct_2() -are only necessary if you are not using the libpng supplied error -handling and memory alloc/free functions. - -When libpng encounters an error, it expects to longjmp back -to your routine. Therefore, you will need to call setjmp and pass -your png_jmpbuf(png_ptr). If you read the file from different -routines, you will need to update the jmpbuf field every time you enter -a new routine that will call a png_*() function. - -See your documentation of setjmp/longjmp for your compiler for more -information on setjmp/longjmp. See the discussion on libpng error -handling in the Customizing Libpng section below for more information -on the libpng error handling. If an error occurs, and libpng longjmp's -back to your setjmp, you will want to call png_destroy_read_struct() to -free any memory. - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - &end_info); - fclose(fp); - return (ERROR); - } - -If you would rather avoid the complexity of setjmp/longjmp issues, -you can compile libpng with PNG_NO_SETJMP, in which case -errors will result in a call to PNG_ABORT() which defaults to abort(). - -You can #define PNG_ABORT() to a function that does something -more useful than abort(), as long as your function does not -return. - -Now you need to set up the input code. The default for libpng is to -use the C function fread(). If you use this, you will need to pass a -valid FILE * in the function png_init_io(). Be sure that the file is -opened in binary mode. If you wish to handle reading data in another -way, you need not call the png_init_io() function, but you must then -implement the libpng I/O methods discussed in the Customizing Libpng -section below. - - png_init_io(png_ptr, fp); - -If you had previously opened the file and read any of the signature from -the beginning in order to see if this was a PNG file, you need to let -libpng know that there are some bytes missing from the start of the file. - - png_set_sig_bytes(png_ptr, number); - -You can change the zlib compression buffer size to be used while -reading compressed data with - - png_set_compression_buffer_size(png_ptr, buffer_size); - -where the default size is 8192 bytes. Note that the buffer size -is changed immediately and the buffer is reallocated immediately, -instead of setting a flag to be acted upon later. - -Setting up callback code - -You can set up a callback function to handle any unknown chunks in the -input stream. You must supply the function - - read_chunk_callback(png_ptr ptr, - png_unknown_chunkp chunk); - { - /* The unknown chunk structure contains your - chunk data, along with similar data for any other - unknown chunks: */ - - png_byte name[5]; - png_byte *data; - png_size_t size; - - /* Note that libpng has already taken care of - the CRC handling */ - - /* put your code here. Search for your chunk in the - unknown chunk structure, process it, and return one - of the following: */ - - return (-n); /* chunk had an error */ - return (0); /* did not recognize */ - return (n); /* success */ - } - -(You can give your function another name that you like instead of -"read_chunk_callback") - -To inform libpng about your function, use - - png_set_read_user_chunk_fn(png_ptr, user_chunk_ptr, - read_chunk_callback); - -This names not only the callback function, but also a user pointer that -you can retrieve with - - png_get_user_chunk_ptr(png_ptr); - -If you call the png_set_read_user_chunk_fn() function, then all unknown -chunks will be saved when read, in case your callback function will need -one or more of them. This behavior can be changed with the -png_set_keep_unknown_chunks() function, described below. - -At this point, you can set up a callback function that will be -called after each row has been read, which you can use to control -a progress meter or the like. It's demonstrated in pngtest.c. -You must supply a function - - void read_row_callback(png_ptr ptr, png_uint_32 row, - int pass); - { - /* put your code here */ - } - -(You can give it another name that you like instead of "read_row_callback") - -To inform libpng about your function, use - - png_set_read_status_fn(png_ptr, read_row_callback); - -Unknown-chunk handling - -Now you get to set the way the library processes unknown chunks in the -input PNG stream. Both known and unknown chunks will be read. Normal -behavior is that known chunks will be parsed into information in -various info_ptr members while unknown chunks will be discarded. This -behavior can be wasteful if your application will never use some known -chunk types. To change this, you can call: - - png_set_keep_unknown_chunks(png_ptr, keep, - chunk_list, num_chunks); - keep - 0: default unknown chunk handling - 1: ignore; do not keep - 2: keep only if safe-to-copy - 3: keep even if unsafe-to-copy - You can use these definitions: - PNG_HANDLE_CHUNK_AS_DEFAULT 0 - PNG_HANDLE_CHUNK_NEVER 1 - PNG_HANDLE_CHUNK_IF_SAFE 2 - PNG_HANDLE_CHUNK_ALWAYS 3 - chunk_list - list of chunks affected (a byte string, - five bytes per chunk, NULL or '\0' if - num_chunks is 0) - num_chunks - number of chunks affected; if 0, all - unknown chunks are affected. If nonzero, - only the chunks in the list are affected - -Unknown chunks declared in this way will be saved as raw data onto a -list of png_unknown_chunk structures. If a chunk that is normally -known to libpng is named in the list, it will be handled as unknown, -according to the "keep" directive. If a chunk is named in successive -instances of png_set_keep_unknown_chunks(), the final instance will -take precedence. The IHDR and IEND chunks should not be named in -chunk_list; if they are, libpng will process them normally anyway. - -Here is an example of the usage of png_set_keep_unknown_chunks(), -where the private "vpAg" chunk will later be processed by a user chunk -callback function: - - png_byte vpAg[5]={118, 112, 65, 103, (png_byte) '\0'}; - - #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - png_byte unused_chunks[]= - { - 104, 73, 83, 84, (png_byte) '\0', /* hIST */ - 105, 84, 88, 116, (png_byte) '\0', /* iTXt */ - 112, 67, 65, 76, (png_byte) '\0', /* pCAL */ - 115, 67, 65, 76, (png_byte) '\0', /* sCAL */ - 115, 80, 76, 84, (png_byte) '\0', /* sPLT */ - 116, 73, 77, 69, (png_byte) '\0', /* tIME */ - }; - #endif - - ... - - #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - /* ignore all unknown chunks: */ - png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0); - /* except for vpAg: */ - png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1); - /* also ignore unused known chunks: */ - png_set_keep_unknown_chunks(read_ptr, 1, unused_chunks, - (int)sizeof(unused_chunks)/5); - #endif - -User limits - -The PNG specification allows the width and height of an image to be as -large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns. -Since very few applications really need to process such large images, -we have imposed an arbitrary 1-million limit on rows and columns. -Larger images will be rejected immediately with a png_error() call. If -you wish to override this limit, you can use - - png_set_user_limits(png_ptr, width_max, height_max); - -to set your own limits, or use width_max = height_max = 0x7fffffffL -to allow all valid dimensions (libpng may reject some very large images -anyway because of potential buffer overflow conditions). - -You should put this statement after you create the PNG structure and -before calling png_read_info(), png_read_png(), or png_process_data(). -If you need to retrieve the limits that are being applied, use - - width_max = png_get_user_width_max(png_ptr); - height_max = png_get_user_height_max(png_ptr); - -The PNG specification sets no limit on the number of ancillary chunks -allowed in a PNG datastream. You can impose a limit on the total number -of sPLT, tEXt, iTXt, zTXt, and unknown chunks that will be stored, with - - png_set_chunk_cache_max(png_ptr, user_chunk_cache_max); - -where 0x7fffffffL means unlimited. You can retrieve this limit with - - chunk_cache_max = png_get_chunk_cache_max(png_ptr); - -This limit also applies to the number of buffers that can be allocated -by png_decompress_chunk() while decompressing iTXt, zTXt, and iCCP chunks. - -You can also set a limit on the amount of memory that a compressed chunk -other than IDAT can occupy, with - - png_set_chunk_malloc_max(png_ptr, user_chunk_malloc_max); - -and you can retrieve the limit with - - chunk_malloc_max = png_get_chunk_malloc_max(png_ptr); - -Any chunks that would cause either of these limits to be exceeded will -be ignored. - -The high-level read interface - -At this point there are two ways to proceed; through the high-level -read interface, or through a sequence of low-level read operations. -You can use the high-level interface if (a) you are willing to read -the entire image into memory, and (b) the input transformations -you want to do are limited to the following set: - - PNG_TRANSFORM_IDENTITY No transformation - PNG_TRANSFORM_STRIP_16 Strip 16-bit samples to - 8 bits - PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel - PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit - samples to bytes - PNG_TRANSFORM_PACKSWAP Change order of packed - pixels to LSB first - PNG_TRANSFORM_EXPAND Perform set_expand() - PNG_TRANSFORM_INVERT_MONO Invert monochrome images - PNG_TRANSFORM_SHIFT Normalize pixels to the - sBIT depth - PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA - to BGRA - PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA - to AG - PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity - to transparency - PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples - PNG_TRANSFORM_GRAY_TO_RGB Expand grayscale samples - to RGB (or GA to RGBA) - -(This excludes setting a background color, doing gamma transformation, -quantizing, and setting filler.) If this is the case, simply do this: - - png_read_png(png_ptr, info_ptr, png_transforms, NULL) - -where png_transforms is an integer containing the bitwise OR of some -set of transformation flags. This call is equivalent to png_read_info(), -followed the set of transformations indicated by the transform mask, -then png_read_image(), and finally png_read_end(). - -(The final parameter of this call is not yet used. Someday it might point -to transformation parameters required by some future input transform.) - -You must use png_transforms and not call any png_set_transform() functions -when you use png_read_png(). - -After you have called png_read_png(), you can retrieve the image data -with - - row_pointers = png_get_rows(png_ptr, info_ptr); - -where row_pointers is an array of pointers to the pixel data for each row: - - png_bytep row_pointers[height]; - -If you know your image size and pixel size ahead of time, you can allocate -row_pointers prior to calling png_read_png() with - - if (height > PNG_UINT_32_MAX/png_sizeof(png_byte)) - png_error (png_ptr, - "Image is too tall to process in memory"); - if (width > PNG_UINT_32_MAX/pixel_size) - png_error (png_ptr, - "Image is too wide to process in memory"); - row_pointers = png_malloc(png_ptr, - height*png_sizeof(png_bytep)); - for (int i=0; i) and -png_get_(png_ptr, info_ptr, ...) functions return non-zero if the -data has been read, or zero if it is missing. The parameters to the -png_get_ are set directly if they are simple data types, or a -pointer into the info_ptr is returned for any complex types. - - png_get_PLTE(png_ptr, info_ptr, &palette, - &num_palette); - palette - the palette for the file - (array of png_color) - num_palette - number of entries in the palette - - png_get_gAMA(png_ptr, info_ptr, &gamma); - gamma - the gamma the file is written - at (PNG_INFO_gAMA) - - png_get_sRGB(png_ptr, info_ptr, &srgb_intent); - srgb_intent - the rendering intent (PNG_INFO_sRGB) - The presence of the sRGB chunk - means that the pixel data is in the - sRGB color space. This chunk also - implies specific values of gAMA and - cHRM. - - png_get_iCCP(png_ptr, info_ptr, &name, - &compression_type, &profile, &proflen); - name - The profile name. - compression - The compression type; always - PNG_COMPRESSION_TYPE_BASE for PNG 1.0. - You may give NULL to this argument to - ignore it. - profile - International Color Consortium color - profile data. May contain NULs. - proflen - length of profile data in bytes. - - png_get_sBIT(png_ptr, info_ptr, &sig_bit); - sig_bit - the number of significant bits for - (PNG_INFO_sBIT) each of the gray, - red, green, and blue channels, - whichever are appropriate for the - given color type (png_color_16) - - png_get_tRNS(png_ptr, info_ptr, &trans_alpha, - &num_trans, &trans_color); - trans_alpha - array of alpha (transparency) - entries for palette (PNG_INFO_tRNS) - trans_color - graylevel or color sample values of - the single transparent color for - non-paletted images (PNG_INFO_tRNS) - num_trans - number of transparent entries - (PNG_INFO_tRNS) - - png_get_hIST(png_ptr, info_ptr, &hist); - (PNG_INFO_hIST) - hist - histogram of palette (array of - png_uint_16) - - png_get_tIME(png_ptr, info_ptr, &mod_time); - mod_time - time image was last modified - (PNG_VALID_tIME) - - png_get_bKGD(png_ptr, info_ptr, &background); - background - background color (PNG_VALID_bKGD) - valid 16-bit red, green and blue - values, regardless of color_type - - num_comments = png_get_text(png_ptr, info_ptr, - &text_ptr, &num_text); - num_comments - number of comments - text_ptr - array of png_text holding image - comments - text_ptr[i].compression - type of compression used - on "text" PNG_TEXT_COMPRESSION_NONE - PNG_TEXT_COMPRESSION_zTXt - PNG_ITXT_COMPRESSION_NONE - PNG_ITXT_COMPRESSION_zTXt - text_ptr[i].key - keyword for comment. Must contain - 1-79 characters. - text_ptr[i].text - text comments for current - keyword. Can be empty. - text_ptr[i].text_length - length of text string, - after decompression, 0 for iTXt - text_ptr[i].itxt_length - length of itxt string, - after decompression, 0 for tEXt/zTXt - text_ptr[i].lang - language of comment (empty - string for unknown). - text_ptr[i].lang_key - keyword in UTF-8 - (empty string for unknown). - Note that the itxt_length, lang, and lang_key - members of the text_ptr structure only exist - when the library is built with iTXt chunk support. - - num_text - number of comments (same as - num_comments; you can put NULL here - to avoid the duplication) - Note while png_set_text() will accept text, language, - and translated keywords that can be NULL pointers, the - structure returned by png_get_text will always contain - regular zero-terminated C strings. They might be - empty strings but they will never be NULL pointers. - - num_spalettes = png_get_sPLT(png_ptr, info_ptr, - &palette_ptr); - palette_ptr - array of palette structures holding - contents of one or more sPLT chunks - read. - num_spalettes - number of sPLT chunks read. - - png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y, - &unit_type); - offset_x - positive offset from the left edge - of the screen - offset_y - positive offset from the top edge - of the screen - unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER - - png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, - &unit_type); - res_x - pixels/unit physical resolution in - x direction - res_y - pixels/unit physical resolution in - x direction - unit_type - PNG_RESOLUTION_UNKNOWN, - PNG_RESOLUTION_METER - - png_get_sCAL(png_ptr, info_ptr, &unit, &width, - &height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are doubles) - - png_get_sCAL_s(png_ptr, info_ptr, &unit, &width, - &height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are strings like "2.54") - - num_unknown_chunks = png_get_unknown_chunks(png_ptr, - info_ptr, &unknowns) - unknowns - array of png_unknown_chunk - structures holding unknown chunks - unknowns[i].name - name of unknown chunk - unknowns[i].data - data of unknown chunk - unknowns[i].size - size of unknown chunk's data - unknowns[i].location - position of chunk in file - - The value of "i" corresponds to the order in which the - chunks were read from the PNG file or inserted with the - png_set_unknown_chunks() function. - -The data from the pHYs chunk can be retrieved in several convenient -forms: - - res_x = png_get_x_pixels_per_meter(png_ptr, - info_ptr) - res_y = png_get_y_pixels_per_meter(png_ptr, - info_ptr) - res_x_and_y = png_get_pixels_per_meter(png_ptr, - info_ptr) - res_x = png_get_x_pixels_per_inch(png_ptr, - info_ptr) - res_y = png_get_y_pixels_per_inch(png_ptr, - info_ptr) - res_x_and_y = png_get_pixels_per_inch(png_ptr, - info_ptr) - aspect_ratio = png_get_pixel_aspect_ratio(png_ptr, - info_ptr) - - (Each of these returns 0 [signifying "unknown"] if - the data is not present or if res_x is 0; - res_x_and_y is 0 if res_x != res_y) - -The data from the oFFs chunk can be retrieved in several convenient -forms: - - x_offset = png_get_x_offset_microns(png_ptr, info_ptr); - y_offset = png_get_y_offset_microns(png_ptr, info_ptr); - x_offset = png_get_x_offset_inches(png_ptr, info_ptr); - y_offset = png_get_y_offset_inches(png_ptr, info_ptr); - - (Each of these returns 0 [signifying "unknown" if both - x and y are 0] if the data is not present or if the - chunk is present but the unit is the pixel) - -For more information, see the png_info definition in png.h and the -PNG specification for chunk contents. Be careful with trusting -rowbytes, as some of the transformations could increase the space -needed to hold a row (expand, filler, gray_to_rgb, etc.). -See png_read_update_info(), below. - -A quick word about text_ptr and num_text. PNG stores comments in -keyword/text pairs, one pair per chunk, with no limit on the number -of text chunks, and a 2^31 byte limit on their size. While there are -suggested keywords, there is no requirement to restrict the use to these -strings. It is strongly suggested that keywords and text be sensible -to humans (that's the point), so don't use abbreviations. Non-printing -symbols are not allowed. See the PNG specification for more details. -There is also no requirement to have text after the keyword. - -Keywords should be limited to 79 Latin-1 characters without leading or -trailing spaces, but non-consecutive spaces are allowed within the -keyword. It is possible to have the same keyword any number of times. -The text_ptr is an array of png_text structures, each holding a -pointer to a language string, a pointer to a keyword and a pointer to -a text string. The text string, language code, and translated -keyword may be empty or NULL pointers. The keyword/text -pairs are put into the array in the order that they are received. -However, some or all of the text chunks may be after the image, so, to -make sure you have read all the text chunks, don't mess with these -until after you read the stuff after the image. This will be -mentioned again below in the discussion that goes with png_read_end(). - -Input transformations - -After you've read the header information, you can set up the library -to handle any special transformations of the image data. The various -ways to transform the data will be described in the order that they -should occur. This is important, as some of these change the color -type and/or bit depth of the data, and some others only work on -certain color types and bit depths. Even though each transformation -checks to see if it has data that it can do something with, you should -make sure to only enable a transformation if it will be valid for the -data. For example, don't swap red and blue on grayscale data. - -The colors used for the background and transparency values should be -supplied in the same format/depth as the current image data. They -are stored in the same format/depth as the image data in a bKGD or tRNS -chunk, so this is what libpng expects for this data. The colors are -transformed to keep in sync with the image data when an application -calls the png_read_update_info() routine (see below). - -Data will be decoded into the supplied row buffers packed into bytes -unless the library has been told to transform it into another format. -For example, 4 bit/pixel paletted or grayscale data will be returned -2 pixels/byte with the leftmost pixel in the high-order bits of the -byte, unless png_set_packing() is called. 8-bit RGB data will be stored -in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha() -is called to insert filler bytes, either before or after each RGB triplet. -16-bit RGB data will be returned RRGGBB RRGGBB, with the most significant -byte of the color value first, unless png_set_strip_16() is called to -transform it to regular RGB RGB triplets, or png_set_filler() or -png_set_add alpha() is called to insert filler bytes, either before or -after each RRGGBB triplet. Similarly, 8-bit or 16-bit grayscale data can -be modified with -png_set_filler(), png_set_add_alpha(), or png_set_strip_16(). - -The following code transforms grayscale images of less than 8 to 8 bits, -changes paletted images to RGB, and adds a full alpha channel if there is -transparency information in a tRNS chunk. This is most useful on -grayscale images with bit depths of 2 or 4 or if there is a multiple-image -viewing application that wishes to treat all images in the same way. - - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_palette_to_rgb(png_ptr); - - if (color_type == PNG_COLOR_TYPE_GRAY && - bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png_ptr); - - if (png_get_valid(png_ptr, info_ptr, - PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr); - -These three functions are actually aliases for png_set_expand(), added -in libpng version 1.0.4, with the function names expanded to improve code -readability. In some future version they may actually do different -things. - -As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() was -added. It expands the sample depth without changing tRNS to alpha. - -As of libpng version 1.4.3, not all possible expansions are supported. - -In the following table, the 01 means grayscale with depth<8, 31 means -indexed with depth<8, other numerals represent the color type, "T" means -the tRNS chunk is present, A means an alpha channel is present, and O -means tRNS or alpha is present but all pixels in the image are opaque. - - FROM 01 31 0 0T 0O 2 2T 2O 3 3T 3O 4A 4O 6A 6O - TO - 01 - - 31 - - 0 1 - - 0T - - 0O - - 2 GX - - 2T - - 2O - - 3 1 - - 3T - - 3O - - 4A T - - 4O - - 6A GX TX TX - - 6O GX TX - - -Within the matrix, - "-" means the transformation is not supported. - "X" means the transformation is obtained by png_set_expand(). - "1" means the transformation is obtained by - png_set_expand_gray_1_2_4_to_8 - "G" means the transformation is obtained by - png_set_gray_to_rgb(). - "P" means the transformation is obtained by - png_set_expand_palette_to_rgb(). - "T" means the transformation is obtained by - png_set_tRNS_to_alpha(). - -PNG can have files with 16 bits per channel. If you only can handle -8 bits per channel, this will strip the pixels down to 8 bit. - - if (bit_depth == 16) - png_set_strip_16(png_ptr); - -If, for some reason, you don't need the alpha channel on an image, -and you want to remove it rather than combining it with the background -(but the image author certainly had in mind that you *would* combine -it with the background, so that's what you should probably do): - - if (color_type & PNG_COLOR_MASK_ALPHA) - png_set_strip_alpha(png_ptr); - -In PNG files, the alpha channel in an image -is the level of opacity. If you need the alpha channel in an image to -be the level of transparency instead of opacity, you can invert the -alpha channel (or the tRNS chunk data) after it's read, so that 0 is -fully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bit -images) is fully transparent, with - - png_set_invert_alpha(png_ptr); - -PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as -they can, resulting in, for example, 8 pixels per byte for 1 bit -files. This code expands to 1 pixel per byte without changing the -values of the pixels: - - if (bit_depth < 8) - png_set_packing(png_ptr); - -PNG files have possible bit depths of 1, 2, 4, 8, and 16. All pixels -stored in a PNG image have been "scaled" or "shifted" up to the next -higher possible bit depth (e.g. from 5 bits/sample in the range [0,31] -to 8 bits/sample in the range [0, 255]). However, it is also possible -to convert the PNG pixel data back to the original bit depth of the -image. This call reduces the pixels back down to the original bit depth: - - png_color_8p sig_bit; - - if (png_get_sBIT(png_ptr, info_ptr, &sig_bit)) - png_set_shift(png_ptr, sig_bit); - -PNG files store 3-color pixels in red, green, blue order. This code -changes the storage of the pixels to blue, green, red: - - if (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_bgr(png_ptr); - -PNG files store RGB pixels packed into 3 or 6 bytes. This code expands them -into 4 or 8 bytes for windowing systems that need them in this format: - - if (color_type == PNG_COLOR_TYPE_RGB) - png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE); - -where "filler" is the 8 or 16-bit number to fill with, and the location is -either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether -you want the filler before the RGB or after. This transformation -does not affect images that already have full alpha channels. To add an -opaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER which -will generate RGBA pixels. - -Note that png_set_filler() does not change the color type. If you want -to do that, you can add a true alpha channel with - - if (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_GRAY) - png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER); - -where "filler" contains the alpha value to assign to each pixel. -This function was added in libpng-1.2.7. - -If you are reading an image with an alpha channel, and you need the -data as ARGB instead of the normal PNG format RGBA: - - if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_swap_alpha(png_ptr); - -For some uses, you may want a grayscale image to be represented as -RGB. This code will do that conversion: - - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb(png_ptr); - -Conversely, you can convert an RGB or RGBA image to grayscale or grayscale -with alpha. - - if (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_rgb_to_gray_fixed(png_ptr, error_action, - int red_weight, int green_weight); - - error_action = 1: silently do the conversion - error_action = 2: issue a warning if the original - image has any pixel where - red != green or red != blue - error_action = 3: issue an error and abort the - conversion if the original - image has any pixel where - red != green or red != blue - - red_weight: weight of red component times 100000 - green_weight: weight of green component times 100000 - If either weight is negative, default - weights (21268, 71514) are used. - -If you have set error_action = 1 or 2, you can -later check whether the image really was gray, after processing -the image rows, with the png_get_rgb_to_gray_status(png_ptr) function. -It will return a png_byte that is zero if the image was gray or -1 if there were any non-gray pixels. bKGD and sBIT data -will be silently converted to grayscale, using the green channel -data, regardless of the error_action setting. - -With red_weight+green_weight<=100000, -the normalized graylevel is computed: - - int rw = red_weight * 65536; - int gw = green_weight * 65536; - int bw = 65536 - (rw + gw); - gray = (rw*red + gw*green + bw*blue)/65536; - -The default values approximate those recommended in the Charles -Poynton's Color FAQ, -Copyright (c) 1998-01-04 Charles Poynton - - Y = 0.212671 * R + 0.715160 * G + 0.072169 * B - -Libpng approximates this with - - Y = 0.21268 * R + 0.7151 * G + 0.07217 * B - -which can be expressed with integers as - - Y = (6969 * R + 23434 * G + 2365 * B)/32768 - -The calculation is done in a linear colorspace, if the image gamma -is known. - -If you have a grayscale and you are using png_set_expand_depth(), -png_set_expand(), or png_set_gray_to_rgb to change to truecolor or to -a higher bit-depth, you must either supply the background color as a gray -value at the original file bit-depth (need_expand = 1) or else supply the -background color as an RGB triplet at the final, expanded bit depth -(need_expand = 0). Similarly, if you are reading a paletted image, you -must either supply the background color as a palette index (need_expand = 1) -or as an RGB triplet that may or may not be in the palette (need_expand = 0). - - png_color_16 my_background; - png_color_16p image_background; - - if (png_get_bKGD(png_ptr, info_ptr, &image_background)) - png_set_background(png_ptr, image_background, - PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); - else - png_set_background(png_ptr, &my_background, - PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); - -The png_set_background() function tells libpng to composite images -with alpha or simple transparency against the supplied background -color. If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid), -you may use this color, or supply another color more suitable for -the current display (e.g., the background color from a web page). You -need to tell libpng whether the color is in the gamma space of the -display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file -(PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one -that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't -know why anyone would use this, but it's here). - -To properly display PNG images on any kind of system, the application needs -to know what the display gamma is. Ideally, the user will know this, and -the application will allow them to set it. One method of allowing the user -to set the display gamma separately for each system is to check for a -SCREEN_GAMMA or DISPLAY_GAMMA environment variable, which will hopefully be -correctly set. - -Note that display_gamma is the overall gamma correction required to produce -pleasing results, which depends on the lighting conditions in the surrounding -environment. In a dim or brightly lit room, no compensation other than -the physical gamma exponent of the monitor is needed, while in a dark room -a slightly smaller exponent is better. - - double gamma, screen_gamma; - - if (/* We have a user-defined screen - gamma value */) - { - screen_gamma = user_defined_screen_gamma; - } - /* One way that applications can share the same - screen gamma value */ - else if ((gamma_str = getenv("SCREEN_GAMMA")) - != NULL) - { - screen_gamma = (double)atof(gamma_str); - } - /* If we don't have another value */ - else - { - screen_gamma = 2.2; /* A good guess for a - PC monitor in a bright office or a dim room */ - screen_gamma = 2.0; /* A good guess for a - PC monitor in a dark room */ - screen_gamma = 1.7 or 1.0; /* A good - guess for Mac systems */ - } - -The png_set_gamma() function handles gamma transformations of the data. -Pass both the file gamma and the current screen_gamma. If the file does -not have a gamma value, you can pass one anyway if you have an idea what -it is (usually 0.45455 is a good guess for GIF images on PCs). Note -that file gammas are inverted from screen gammas. See the discussions -on gamma in the PNG specification for an excellent description of what -gamma is, and why all applications should support it. It is strongly -recommended that PNG viewers support gamma correction. - - if (png_get_gAMA(png_ptr, info_ptr, &gamma)) - png_set_gamma(png_ptr, screen_gamma, gamma); - else - png_set_gamma(png_ptr, screen_gamma, 0.45455); - -If you need to reduce an RGB file to a paletted file, or if a paletted -file has more entries then will fit on your screen, png_set_quantize() -will do that. Note that this is a simple match dither that merely -finds the closest color available. This should work fairly well with -optimized palettes, and fairly badly with linear color cubes. If you -pass a palette that is larger then maximum_colors, the file will -reduce the number of colors in the palette so it will fit into -maximum_colors. If there is a histogram, it will use it to make -more intelligent choices when reducing the palette. If there is no -histogram, it may not do as good a job. - - if (color_type & PNG_COLOR_MASK_COLOR) - { - if (png_get_valid(png_ptr, info_ptr, - PNG_INFO_PLTE)) - { - png_uint_16p histogram = NULL; - - png_get_hIST(png_ptr, info_ptr, - &histogram); - png_set_quantize(png_ptr, palette, num_palette, - max_screen_colors, histogram, 1); - } - else - { - png_color std_color_cube[MAX_SCREEN_COLORS] = - { ... colors ... }; - - png_set_quantize(png_ptr, std_color_cube, - MAX_SCREEN_COLORS, MAX_SCREEN_COLORS, - NULL,0); - } - } - -PNG files describe monochrome as black being zero and white being one. -The following code will reverse this (make black be one and white be -zero): - - if (bit_depth == 1 && color_type == PNG_COLOR_TYPE_GRAY) - png_set_invert_mono(png_ptr); - -This function can also be used to invert grayscale and gray-alpha images: - - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_invert_mono(png_ptr); - -PNG files store 16 bit pixels in network byte order (big-endian, -ie. most significant bits first). This code changes the storage to the -other way (little-endian, i.e. least significant bits first, the -way PCs store them): - - if (bit_depth == 16) - png_set_swap(png_ptr); - -If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you -need to change the order the pixels are packed into bytes, you can use: - - if (bit_depth < 8) - png_set_packswap(png_ptr); - -Finally, you can write your own transformation function if none of -the existing ones meets your needs. This is done by setting a callback -with - - png_set_read_user_transform_fn(png_ptr, - read_transform_fn); - -You must supply the function - - void read_transform_fn(png_ptr ptr, row_info_ptr - row_info, png_bytep data) - -See pngtest.c for a working example. Your function will be called -after all of the other transformations have been processed. - -You can also set up a pointer to a user structure for use by your -callback function, and you can inform libpng that your transform -function will change the number of channels or bit depth with the -function - - png_set_user_transform_info(png_ptr, user_ptr, - user_depth, user_channels); - -The user's application, not libpng, is responsible for allocating and -freeing any memory required for the user structure. - -You can retrieve the pointer via the function -png_get_user_transform_ptr(). For example: - - voidp read_user_transform_ptr = - png_get_user_transform_ptr(png_ptr); - -The last thing to handle is interlacing; this is covered in detail below, -but you must call the function here if you want libpng to handle expansion -of the interlaced image. - - number_of_passes = png_set_interlace_handling(png_ptr); - -After setting the transformations, libpng can update your png_info -structure to reflect any transformations you've requested with this -call. This is most useful to update the info structure's rowbytes -field so you can use it to allocate your image memory. This function -will also update your palette with the correct screen_gamma and -background if these have been given with the calls above. - - png_read_update_info(png_ptr, info_ptr); - -After you call png_read_update_info(), you can allocate any -memory you need to hold the image. The row data is simply -raw byte data for all forms of images. As the actual allocation -varies among applications, no example will be given. If you -are allocating one large chunk, you will need to build an -array of pointers to each row, as it will be needed for some -of the functions below. - -Reading image data - -After you've allocated memory, you can read the image data. -The simplest way to do this is in one function call. If you are -allocating enough memory to hold the whole image, you can just -call png_read_image() and libpng will read in all the image data -and put it in the memory area supplied. You will need to pass in -an array of pointers to each row. - -This function automatically handles interlacing, so you don't need -to call png_set_interlace_handling() or call this function multiple -times, or any of that other stuff necessary with png_read_rows(). - - png_read_image(png_ptr, row_pointers); - -where row_pointers is: - - png_bytep row_pointers[height]; - -You can point to void or char or whatever you use for pixels. - -If you don't want to read in the whole image at once, you can -use png_read_rows() instead. If there is no interlacing (check -interlace_type == PNG_INTERLACE_NONE), this is simple: - - png_read_rows(png_ptr, row_pointers, NULL, - number_of_rows); - -where row_pointers is the same as in the png_read_image() call. - -If you are doing this just one row at a time, you can do this with -a single row_pointer instead of an array of row_pointers: - - png_bytep row_pointer = row; - png_read_row(png_ptr, row_pointer, NULL); - -If the file is interlaced (interlace_type != 0 in the IHDR chunk), things -get somewhat harder. The only current (PNG Specification version 1.2) -interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7) -is a somewhat complicated 2D interlace scheme, known as Adam7, that -breaks down an image into seven smaller images of varying size, based -on an 8x8 grid. - -libpng can fill out those images or it can give them to you "as is". -If you want them filled out, there are two ways to do that. The one -mentioned in the PNG specification is to expand each pixel to cover -those pixels that have not been read yet (the "rectangle" method). -This results in a blocky image for the first pass, which gradually -smooths out as more pixels are read. The other method is the "sparkle" -method, where pixels are drawn only in their final locations, with the -rest of the image remaining whatever colors they were initialized to -before the start of the read. The first method usually looks better, -but tends to be slower, as there are more pixels to put in the rows. - -If you don't want libpng to handle the interlacing details, just call -png_read_rows() seven times to read in all seven images. Each of the -images is a valid image by itself, or they can all be combined on an -8x8 grid to form a single image (although if you intend to combine them -you would be far better off using the libpng interlace handling). - -The first pass will return an image 1/8 as wide as the entire image -(every 8th column starting in column 0) and 1/8 as high as the original -(every 8th row starting in row 0), the second will be 1/8 as wide -(starting in column 4) and 1/8 as high (also starting in row 0). The -third pass will be 1/4 as wide (every 4th pixel starting in column 0) and -1/8 as high (every 8th row starting in row 4), and the fourth pass will -be 1/4 as wide and 1/4 as high (every 4th column starting in column 2, -and every 4th row starting in row 0). The fifth pass will return an -image 1/2 as wide, and 1/4 as high (starting at column 0 and row 2), -while the sixth pass will be 1/2 as wide and 1/2 as high as the original -(starting in column 1 and row 0). The seventh and final pass will be as -wide as the original, and 1/2 as high, containing all of the odd -numbered scanlines. Phew! - -If you want libpng to expand the images, call this before calling -png_start_read_image() or png_read_update_info(): - - if (interlace_type == PNG_INTERLACE_ADAM7) - number_of_passes - = png_set_interlace_handling(png_ptr); - -This will return the number of passes needed. Currently, this -is seven, but may change if another interlace type is added. -This function can be called even if the file is not interlaced, -where it will return one pass. - -If you are not going to display the image after each pass, but are -going to wait until the entire image is read in, use the sparkle -effect. This effect is faster and the end result of either method -is exactly the same. If you are planning on displaying the image -after each pass, the "rectangle" effect is generally considered the -better looking one. - -If you only want the "sparkle" effect, just call png_read_rows() as -normal, with the third parameter NULL. Make sure you make pass over -the image number_of_passes times, and you don't change the data in the -rows between calls. You can change the locations of the data, just -not the data. Each pass only writes the pixels appropriate for that -pass, and assumes the data from previous passes is still valid. - - png_read_rows(png_ptr, row_pointers, NULL, - number_of_rows); - -If you only want the first effect (the rectangles), do the same as -before except pass the row buffer in the third parameter, and leave -the second parameter NULL. - - png_read_rows(png_ptr, NULL, row_pointers, - number_of_rows); - -Finishing a sequential read - -After you are finished reading the image through the -low-level interface, you can finish reading the file. If you are -interested in comments or time, which may be stored either before or -after the image data, you should pass the separate png_info struct if -you want to keep the comments from before and after the image -separate. If you are not interested, you can pass NULL. - - png_read_end(png_ptr, end_info); - -When you are done, you can free all memory allocated by libpng like this: - - png_destroy_read_struct(&png_ptr, &info_ptr, - &end_info); - -It is also possible to individually free the info_ptr members that -point to libpng-allocated storage with the following function: - - png_free_data(png_ptr, info_ptr, mask, seq) - mask - identifies data to be freed, a mask - containing the bitwise OR of one or - more of - PNG_FREE_PLTE, PNG_FREE_TRNS, - PNG_FREE_HIST, PNG_FREE_ICCP, - PNG_FREE_PCAL, PNG_FREE_ROWS, - PNG_FREE_SCAL, PNG_FREE_SPLT, - PNG_FREE_TEXT, PNG_FREE_UNKN, - or simply PNG_FREE_ALL - seq - sequence number of item to be freed - (-1 for all items) - -This function may be safely called when the relevant storage has -already been freed, or has not yet been allocated, or was allocated -by the user and not by libpng, and will in those cases do nothing. -The "seq" parameter is ignored if only one item of the selected data -type, such as PLTE, is allowed. If "seq" is not -1, and multiple items -are allowed for the data type identified in the mask, such as text or -sPLT, only the n'th item in the structure is freed, where n is "seq". - -The default behavior is only to free data that was allocated internally -by libpng. This can be changed, so that libpng will not free the data, -or so that it will free data that was allocated by the user with png_malloc() -or png_zalloc() and passed in via a png_set_*() function, with - - png_data_freer(png_ptr, info_ptr, freer, mask) - mask - which data elements are affected - same choices as in png_free_data() - freer - one of - PNG_DESTROY_WILL_FREE_DATA - PNG_SET_WILL_FREE_DATA - PNG_USER_WILL_FREE_DATA - -This function only affects data that has already been allocated. -You can call this function after reading the PNG data but before calling -any png_set_*() functions, to control whether the user or the png_set_*() -function is responsible for freeing any existing data that might be present, -and again after the png_set_*() functions to control whether the user -or png_destroy_*() is supposed to free the data. When the user assumes -responsibility for libpng-allocated data, the application must use -png_free() to free it, and when the user transfers responsibility to libpng -for data that the user has allocated, the user must have used png_malloc() -or png_zalloc() to allocate it. - -If you allocated your row_pointers in a single block, as suggested above in -the description of the high level read interface, you must not transfer -responsibility for freeing it to the png_set_rows or png_read_destroy function, -because they would also try to free the individual row_pointers[i]. - -If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword -separately, do not transfer responsibility for freeing text_ptr to libpng, -because when libpng fills a png_text structure it combines these members with -the key member, and png_free_data() will free only text_ptr.key. Similarly, -if you transfer responsibility for free'ing text_ptr from libpng to your -application, your application must not separately free those members. - -The png_free_data() function will turn off the "valid" flag for anything -it frees. If you need to turn the flag off for a chunk that was freed by -your application instead of by libpng, you can use - - png_set_invalid(png_ptr, info_ptr, mask); - mask - identifies the chunks to be made invalid, - containing the bitwise OR of one or - more of - PNG_INFO_gAMA, PNG_INFO_sBIT, - PNG_INFO_cHRM, PNG_INFO_PLTE, - PNG_INFO_tRNS, PNG_INFO_bKGD, - PNG_INFO_hIST, PNG_INFO_pHYs, - PNG_INFO_oFFs, PNG_INFO_tIME, - PNG_INFO_pCAL, PNG_INFO_sRGB, - PNG_INFO_iCCP, PNG_INFO_sPLT, - PNG_INFO_sCAL, PNG_INFO_IDAT - -For a more compact example of reading a PNG image, see the file example.c. - -Reading PNG files progressively - -The progressive reader is slightly different then the non-progressive -reader. Instead of calling png_read_info(), png_read_rows(), and -png_read_end(), you make one call to png_process_data(), which calls -callbacks when it has the info, a row, or the end of the image. You -set up these callbacks with png_set_progressive_read_fn(). You don't -have to worry about the input/output functions of libpng, as you are -giving the library the data directly in png_process_data(). I will -assume that you have read the section on reading PNG files above, -so I will only highlight the differences (although I will show -all of the code). - -png_structp png_ptr; -png_infop info_ptr; - - /* An example code fragment of how you would - initialize the progressive reader in your - application. */ - int - initialize_png_reader() - { - png_ptr = png_create_read_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_read_struct(&png_ptr, (png_infopp)NULL, - (png_infopp)NULL); - return (ERROR); - } - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - - /* This one's new. You can provide functions - to be called when the header info is valid, - when each row is completed, and when the image - is finished. If you aren't using all functions, - you can specify NULL parameters. Even when all - three functions are NULL, you need to call - png_set_progressive_read_fn(). You can use - any struct as the user_ptr (cast to a void pointer - for the function call), and retrieve the pointer - from inside the callbacks using the function - - png_get_progressive_ptr(png_ptr); - - which will return a void pointer, which you have - to cast appropriately. - */ - png_set_progressive_read_fn(png_ptr, (void *)user_ptr, - info_callback, row_callback, end_callback); - - return 0; - } - - /* A code fragment that you call as you receive blocks - of data */ - int - process_data(png_bytep buffer, png_uint_32 length) - { - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - - /* This one's new also. Simply give it a chunk - of data from the file stream (in order, of - course). On machines with segmented memory - models machines, don't give it any more than - 64K. The library seems to run fine with sizes - of 4K. Although you can give it much less if - necessary (I assume you can give it chunks of - 1 byte, I haven't tried less then 256 bytes - yet). When this function returns, you may - want to display any rows that were generated - in the row callback if you don't already do - so there. - */ - png_process_data(png_ptr, info_ptr, buffer, length); - return 0; - } - - /* This function is called (as set by - png_set_progressive_read_fn() above) when enough data - has been supplied so all of the header has been - read. - */ - void - info_callback(png_structp png_ptr, png_infop info) - { - /* Do any setup here, including setting any of - the transformations mentioned in the Reading - PNG files section. For now, you _must_ call - either png_start_read_image() or - png_read_update_info() after all the - transformations are set (even if you don't set - any). You may start getting rows before - png_process_data() returns, so this is your - last chance to prepare for that. - */ - } - - /* This function is called when each row of image - data is complete */ - void - row_callback(png_structp png_ptr, png_bytep new_row, - png_uint_32 row_num, int pass) - { - /* If the image is interlaced, and you turned - on the interlace handler, this function will - be called for every row in every pass. Some - of these rows will not be changed from the - previous pass. When the row is not changed, - the new_row variable will be NULL. The rows - and passes are called in order, so you don't - really need the row_num and pass, but I'm - supplying them because it may make your life - easier. - - For the non-NULL rows of interlaced images, - you must call png_progressive_combine_row() - passing in the row and the old row. You can - call this function for NULL rows (it will just - return) and for non-interlaced images (it just - does the memcpy for you) if it will make the - code easier. Thus, you can just do this for - all cases: - */ - - png_progressive_combine_row(png_ptr, old_row, - new_row); - - /* where old_row is what was displayed for - previously for the row. Note that the first - pass (pass == 0, really) will completely cover - the old row, so the rows do not have to be - initialized. After the first pass (and only - for interlaced images), you will have to pass - the current row, and the function will combine - the old row and the new row. - */ - } - - void - end_callback(png_structp png_ptr, png_infop info) - { - /* This function is called after the whole image - has been read, including any chunks after the - image (up to and including the IEND). You - will usually have the same info chunk as you - had in the header, although some data may have - been added to the comments and time fields. - - Most people won't do much here, perhaps setting - a flag that marks the image as finished. - */ - } - - - -IV. Writing - -Much of this is very similar to reading. However, everything of -importance is repeated here, so you won't have to constantly look -back up in the reading section to understand writing. - -Setup - -You will want to do the I/O initialization before you get into libpng, -so if it doesn't work, you don't have anything to undo. If you are not -using the standard I/O functions, you will need to replace them with -custom writing functions. See the discussion under Customizing libpng. - - FILE *fp = fopen(file_name, "wb"); - if (!fp) - { - return (ERROR); - } - -Next, png_struct and png_info need to be allocated and initialized. -As these can be both relatively large, you may not want to store these -on the stack, unless you have stack space to spare. Of course, you -will want to check if they return NULL. If you are also reading, -you won't want to name your read structure and your write structure -both "png_ptr"; you can call them anything you like, such as -"read_ptr" and "write_ptr". Look at pngtest.c, for example. - - png_structp png_ptr = png_create_write_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_write_struct(&png_ptr, - (png_infopp)NULL); - return (ERROR); - } - -If you want to use your own memory allocation routines, -define PNG_USER_MEM_SUPPORTED and use -png_create_write_struct_2() instead of png_create_write_struct(): - - png_structp png_ptr = png_create_write_struct_2 - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn, (png_voidp) - user_mem_ptr, user_malloc_fn, user_free_fn); - -After you have these structures, you will need to set up the -error handling. When libpng encounters an error, it expects to -longjmp() back to your routine. Therefore, you will need to call -setjmp() and pass the png_jmpbuf(png_ptr). If you -write the file from different routines, you will need to update -the png_jmpbuf(png_ptr) every time you enter a new routine that will -call a png_*() function. See your documentation of setjmp/longjmp -for your compiler for more information on setjmp/longjmp. See -the discussion on libpng error handling in the Customizing Libpng -section below for more information on the libpng error handling. - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_write_struct(&png_ptr, &info_ptr); - fclose(fp); - return (ERROR); - } - ... - return; - -If you would rather avoid the complexity of setjmp/longjmp issues, -you can compile libpng with PNG_NO_SETJMP, in which case -errors will result in a call to PNG_ABORT() which defaults to abort(). - -You can #define PNG_ABORT() to a function that does something -more useful than abort(), as long as your function does not -return. - -Now you need to set up the output code. The default for libpng is to -use the C function fwrite(). If you use this, you will need to pass a -valid FILE * in the function png_init_io(). Be sure that the file is -opened in binary mode. Again, if you wish to handle writing data in -another way, see the discussion on libpng I/O handling in the Customizing -Libpng section below. - - png_init_io(png_ptr, fp); - -If you are embedding your PNG into a datastream such as MNG, and don't -want libpng to write the 8-byte signature, or if you have already -written the signature in your application, use - - png_set_sig_bytes(png_ptr, 8); - -to inform libpng that it should not write a signature. - -Write callbacks - -At this point, you can set up a callback function that will be -called after each row has been written, which you can use to control -a progress meter or the like. It's demonstrated in pngtest.c. -You must supply a function - - void write_row_callback(png_ptr, png_uint_32 row, - int pass); - { - /* put your code here */ - } - -(You can give it another name that you like instead of "write_row_callback") - -To inform libpng about your function, use - - png_set_write_status_fn(png_ptr, write_row_callback); - -You now have the option of modifying how the compression library will -run. The following functions are mainly for testing, but may be useful -in some cases, like if you need to write PNG files extremely fast and -are willing to give up some compression, or if you want to get the -maximum possible compression at the expense of slower writing. If you -have no special needs in this area, let the library do what it wants by -not calling this function at all, as it has been tuned to deliver a good -speed/compression ratio. The second parameter to png_set_filter() is -the filter method, for which the only valid values are 0 (as of the -July 1999 PNG specification, version 1.2) or 64 (if you are writing -a PNG datastream that is to be embedded in a MNG datastream). The third -parameter is a flag that indicates which filter type(s) are to be tested -for each scanline. See the PNG specification for details on the specific -filter types. - - - /* turn on or off filtering, and/or choose - specific filters. You can use either a single - PNG_FILTER_VALUE_NAME or the bitwise OR of one - or more PNG_FILTER_NAME masks. */ - png_set_filter(png_ptr, 0, - PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE | - PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB | - PNG_FILTER_UP | PNG_FILTER_VALUE_UP | - PNG_FILTER_AVG | PNG_FILTER_VALUE_AVG | - PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH| - PNG_ALL_FILTERS); - -If an application -wants to start and stop using particular filters during compression, -it should start out with all of the filters (to ensure that the previous -row of pixels will be stored in case it's needed later), and then add -and remove them after the start of compression. - -If you are writing a PNG datastream that is to be embedded in a MNG -datastream, the second parameter can be either 0 or 64. - -The png_set_compression_*() functions interface to the zlib compression -library, and should mostly be ignored unless you really know what you are -doing. The only generally useful call is png_set_compression_level() -which changes how much time zlib spends on trying to compress the image -data. See the Compression Library (zlib.h and algorithm.txt, distributed -with zlib) for details on the compression levels. - - /* set the zlib compression level */ - png_set_compression_level(png_ptr, - Z_BEST_COMPRESSION); - - /* set other zlib parameters */ - png_set_compression_mem_level(png_ptr, 8); - png_set_compression_strategy(png_ptr, - Z_DEFAULT_STRATEGY); - png_set_compression_window_bits(png_ptr, 15); - png_set_compression_method(png_ptr, 8); - png_set_compression_buffer_size(png_ptr, 8192) - -extern PNG_EXPORT(void,png_set_zbuf_size) - -Setting the contents of info for output - -You now need to fill in the png_info structure with all the data you -wish to write before the actual image. Note that the only thing you -are allowed to write after the image is the text chunks and the time -chunk (as of PNG Specification 1.2, anyway). See png_write_end() and -the latest PNG specification for more information on that. If you -wish to write them before the image, fill them in now, and flag that -data as being valid. If you want to wait until after the data, don't -fill them until png_write_end(). For all the fields in png_info and -their data types, see png.h. For explanations of what the fields -contain, see the PNG specification. - -Some of the more important parts of the png_info are: - - png_set_IHDR(png_ptr, info_ptr, width, height, - bit_depth, color_type, interlace_type, - compression_type, filter_method) - width - holds the width of the image - in pixels (up to 2^31). - height - holds the height of the image - in pixels (up to 2^31). - bit_depth - holds the bit depth of one of the - image channels. - (valid values are 1, 2, 4, 8, 16 - and depend also on the - color_type. See also significant - bits (sBIT) below). - color_type - describes which color/alpha - channels are present. - PNG_COLOR_TYPE_GRAY - (bit depths 1, 2, 4, 8, 16) - PNG_COLOR_TYPE_GRAY_ALPHA - (bit depths 8, 16) - PNG_COLOR_TYPE_PALETTE - (bit depths 1, 2, 4, 8) - PNG_COLOR_TYPE_RGB - (bit_depths 8, 16) - PNG_COLOR_TYPE_RGB_ALPHA - (bit_depths 8, 16) - - PNG_COLOR_MASK_PALETTE - PNG_COLOR_MASK_COLOR - PNG_COLOR_MASK_ALPHA - - interlace_type - PNG_INTERLACE_NONE or - PNG_INTERLACE_ADAM7 - compression_type - (must be - PNG_COMPRESSION_TYPE_DEFAULT) - filter_method - (must be PNG_FILTER_TYPE_DEFAULT - or, if you are writing a PNG to - be embedded in a MNG datastream, - can also be - PNG_INTRAPIXEL_DIFFERENCING) - -If you call png_set_IHDR(), the call must appear before any of the -other png_set_*() functions, because they might require access to some of -the IHDR settings. The remaining png_set_*() functions can be called -in any order. - -If you wish, you can reset the compression_type, interlace_type, or -filter_method later by calling png_set_IHDR() again; if you do this, the -width, height, bit_depth, and color_type must be the same in each call. - - png_set_PLTE(png_ptr, info_ptr, palette, - num_palette); - palette - the palette for the file - (array of png_color) - num_palette - number of entries in the palette - - png_set_gAMA(png_ptr, info_ptr, gamma); - gamma - the gamma the image was created - at (PNG_INFO_gAMA) - - png_set_sRGB(png_ptr, info_ptr, srgb_intent); - srgb_intent - the rendering intent - (PNG_INFO_sRGB) The presence of - the sRGB chunk means that the pixel - data is in the sRGB color space. - This chunk also implies specific - values of gAMA and cHRM. Rendering - intent is the CSS-1 property that - has been defined by the International - Color Consortium - (http://www.color.org). - It can be one of - PNG_sRGB_INTENT_SATURATION, - PNG_sRGB_INTENT_PERCEPTUAL, - PNG_sRGB_INTENT_ABSOLUTE, or - PNG_sRGB_INTENT_RELATIVE. - - - png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, - srgb_intent); - srgb_intent - the rendering intent - (PNG_INFO_sRGB) The presence of the - sRGB chunk means that the pixel - data is in the sRGB color space. - This function also causes gAMA and - cHRM chunks with the specific values - that are consistent with sRGB to be - written. - - png_set_iCCP(png_ptr, info_ptr, name, compression_type, - profile, proflen); - name - The profile name. - compression - The compression type; always - PNG_COMPRESSION_TYPE_BASE for PNG 1.0. - You may give NULL to this argument to - ignore it. - profile - International Color Consortium color - profile data. May contain NULs. - proflen - length of profile data in bytes. - - png_set_sBIT(png_ptr, info_ptr, sig_bit); - sig_bit - the number of significant bits for - (PNG_INFO_sBIT) each of the gray, red, - green, and blue channels, whichever are - appropriate for the given color type - (png_color_16) - - png_set_tRNS(png_ptr, info_ptr, trans_alpha, - num_trans, trans_color); - trans_alpha - array of alpha (transparency) - entries for palette (PNG_INFO_tRNS) - trans_color - graylevel or color sample values - (in order red, green, blue) of the - single transparent color for - non-paletted images (PNG_INFO_tRNS) - num_trans - number of transparent entries - (PNG_INFO_tRNS) - - png_set_hIST(png_ptr, info_ptr, hist); - (PNG_INFO_hIST) - hist - histogram of palette (array of - png_uint_16) - - png_set_tIME(png_ptr, info_ptr, mod_time); - mod_time - time image was last modified - (PNG_VALID_tIME) - - png_set_bKGD(png_ptr, info_ptr, background); - background - background color (PNG_VALID_bKGD) - - png_set_text(png_ptr, info_ptr, text_ptr, num_text); - text_ptr - array of png_text holding image - comments - text_ptr[i].compression - type of compression used - on "text" PNG_TEXT_COMPRESSION_NONE - PNG_TEXT_COMPRESSION_zTXt - PNG_ITXT_COMPRESSION_NONE - PNG_ITXT_COMPRESSION_zTXt - text_ptr[i].key - keyword for comment. Must contain - 1-79 characters. - text_ptr[i].text - text comments for current - keyword. Can be NULL or empty. - text_ptr[i].text_length - length of text string, - after decompression, 0 for iTXt - text_ptr[i].itxt_length - length of itxt string, - after decompression, 0 for tEXt/zTXt - text_ptr[i].lang - language of comment (NULL or - empty for unknown). - text_ptr[i].translated_keyword - keyword in UTF-8 (NULL - or empty for unknown). - Note that the itxt_length, lang, and lang_key - members of the text_ptr structure only exist - when the library is built with iTXt chunk support. - - num_text - number of comments - - png_set_sPLT(png_ptr, info_ptr, &palette_ptr, - num_spalettes); - palette_ptr - array of png_sPLT_struct structures - to be added to the list of palettes - in the info structure. - num_spalettes - number of palette structures to be - added. - - png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, - unit_type); - offset_x - positive offset from the left - edge of the screen - offset_y - positive offset from the top - edge of the screen - unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER - - png_set_pHYs(png_ptr, info_ptr, res_x, res_y, - unit_type); - res_x - pixels/unit physical resolution - in x direction - res_y - pixels/unit physical resolution - in y direction - unit_type - PNG_RESOLUTION_UNKNOWN, - PNG_RESOLUTION_METER - - png_set_sCAL(png_ptr, info_ptr, unit, width, height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are doubles) - - png_set_sCAL_s(png_ptr, info_ptr, unit, width, height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are strings like "2.54") - - png_set_unknown_chunks(png_ptr, info_ptr, &unknowns, - num_unknowns) - unknowns - array of png_unknown_chunk - structures holding unknown chunks - unknowns[i].name - name of unknown chunk - unknowns[i].data - data of unknown chunk - unknowns[i].size - size of unknown chunk's data - unknowns[i].location - position to write chunk in file - 0: do not write chunk - PNG_HAVE_IHDR: before PLTE - PNG_HAVE_PLTE: before IDAT - PNG_AFTER_IDAT: after IDAT - -The "location" member is set automatically according to -what part of the output file has already been written. -You can change its value after calling png_set_unknown_chunks() -as demonstrated in pngtest.c. Within each of the "locations", -the chunks are sequenced according to their position in the -structure (that is, the value of "i", which is the order in which -the chunk was either read from the input file or defined with -png_set_unknown_chunks). - -A quick word about text and num_text. text is an array of png_text -structures. num_text is the number of valid structures in the array. -Each png_text structure holds a language code, a keyword, a text value, -and a compression type. - -The compression types have the same valid numbers as the compression -types of the image data. Currently, the only valid number is zero. -However, you can store text either compressed or uncompressed, unlike -images, which always have to be compressed. So if you don't want the -text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE. -Because tEXt and zTXt chunks don't have a language field, if you -specify PNG_TEXT_COMPRESSION_NONE or PNG_TEXT_COMPRESSION_zTXt -any language code or translated keyword will not be written out. - -Until text gets around 1000 bytes, it is not worth compressing it. -After the text has been written out to the file, the compression type -is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR, -so that it isn't written out again at the end (in case you are calling -png_write_end() with the same struct. - -The keywords that are given in the PNG Specification are: - - Title Short (one line) title or - caption for image - Author Name of image's creator - Description Description of image (possibly long) - Copyright Copyright notice - Creation Time Time of original image creation - (usually RFC 1123 format, see below) - Software Software used to create the image - Disclaimer Legal disclaimer - Warning Warning of nature of content - Source Device used to create the image - Comment Miscellaneous comment; conversion - from other image format - -The keyword-text pairs work like this. Keywords should be short -simple descriptions of what the comment is about. Some typical -keywords are found in the PNG specification, as is some recommendations -on keywords. You can repeat keywords in a file. You can even write -some text before the image and some after. For example, you may want -to put a description of the image before the image, but leave the -disclaimer until after, so viewers working over modem connections -don't have to wait for the disclaimer to go over the modem before -they start seeing the image. Finally, keywords should be full -words, not abbreviations. Keywords and text are in the ISO 8859-1 -(Latin-1) character set (a superset of regular ASCII) and can not -contain NUL characters, and should not contain control or other -unprintable characters. To make the comments widely readable, stick -with basic ASCII, and avoid machine specific character set extensions -like the IBM-PC character set. The keyword must be present, but -you can leave off the text string on non-compressed pairs. -Compressed pairs must have a text string, as only the text string -is compressed anyway, so the compression would be meaningless. - -PNG supports modification time via the png_time structure. Two -conversion routines are provided, png_convert_from_time_t() for -time_t and png_convert_from_struct_tm() for struct tm. The -time_t routine uses gmtime(). You don't have to use either of -these, but if you wish to fill in the png_time structure directly, -you should provide the time in universal time (GMT) if possible -instead of your local time. Note that the year number is the full -year (e.g. 1998, rather than 98 - PNG is year 2000 compliant!), and -that months start with 1. - -If you want to store the time of the original image creation, you should -use a plain tEXt chunk with the "Creation Time" keyword. This is -necessary because the "creation time" of a PNG image is somewhat vague, -depending on whether you mean the PNG file, the time the image was -created in a non-PNG format, a still photo from which the image was -scanned, or possibly the subject matter itself. In order to facilitate -machine-readable dates, it is recommended that the "Creation Time" -tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"), -although this isn't a requirement. Unlike the tIME chunk, the -"Creation Time" tEXt chunk is not expected to be automatically changed -by the software. To facilitate the use of RFC 1123 dates, a function -png_convert_to_rfc1123(png_timep) is provided to convert from PNG -time to an RFC 1123 format string. - -Writing unknown chunks - -You can use the png_set_unknown_chunks function to queue up chunks -for writing. You give it a chunk name, raw data, and a size; that's -all there is to it. The chunks will be written by the next following -png_write_info_before_PLTE, png_write_info, or png_write_end function. -Any chunks previously read into the info structure's unknown-chunk -list will also be written out in a sequence that satisfies the PNG -specification's ordering rules. - -The high-level write interface - -At this point there are two ways to proceed; through the high-level -write interface, or through a sequence of low-level write operations. -You can use the high-level interface if your image data is present -in the info structure. All defined output -transformations are permitted, enabled by the following masks. - - PNG_TRANSFORM_IDENTITY No transformation - PNG_TRANSFORM_PACKING Pack 1, 2 and 4-bit samples - PNG_TRANSFORM_PACKSWAP Change order of packed - pixels to LSB first - PNG_TRANSFORM_INVERT_MONO Invert monochrome images - PNG_TRANSFORM_SHIFT Normalize pixels to the - sBIT depth - PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA - to BGRA - PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA - to AG - PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity - to transparency - PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples - PNG_TRANSFORM_STRIP_FILLER Strip out filler - bytes (deprecated). - PNG_TRANSFORM_STRIP_FILLER_BEFORE Strip out leading - filler bytes - PNG_TRANSFORM_STRIP_FILLER_AFTER Strip out trailing - filler bytes - -If you have valid image data in the info structure (you can use -png_set_rows() to put image data in the info structure), simply do this: - - png_write_png(png_ptr, info_ptr, png_transforms, NULL) - -where png_transforms is an integer containing the bitwise OR of some set of -transformation flags. This call is equivalent to png_write_info(), -followed the set of transformations indicated by the transform mask, -then png_write_image(), and finally png_write_end(). - -(The final parameter of this call is not yet used. Someday it might point -to transformation parameters required by some future output transform.) - -You must use png_transforms and not call any png_set_transform() functions -when you use png_write_png(). - -The low-level write interface - -If you are going the low-level route instead, you are now ready to -write all the file information up to the actual image data. You do -this with a call to png_write_info(). - - png_write_info(png_ptr, info_ptr); - -Note that there is one transformation you may need to do before -png_write_info(). In PNG files, the alpha channel in an image is the -level of opacity. If your data is supplied as a level of transparency, -you can invert the alpha channel before you write it, so that 0 is -fully transparent and 255 (in 8-bit or paletted images) or 65535 -(in 16-bit images) is fully opaque, with - - png_set_invert_alpha(png_ptr); - -This must appear before png_write_info() instead of later with the -other transformations because in the case of paletted images the tRNS -chunk data has to be inverted before the tRNS chunk is written. If -your image is not a paletted image, the tRNS data (which in such cases -represents a single color to be rendered as transparent) won't need to -be changed, and you can safely do this transformation after your -png_write_info() call. - -If you need to write a private chunk that you want to appear before -the PLTE chunk when PLTE is present, you can write the PNG info in -two steps, and insert code to write your own chunk between them: - - png_write_info_before_PLTE(png_ptr, info_ptr); - png_set_unknown_chunks(png_ptr, info_ptr, ...); - png_write_info(png_ptr, info_ptr); - -After you've written the file information, you can set up the library -to handle any special transformations of the image data. The various -ways to transform the data will be described in the order that they -should occur. This is important, as some of these change the color -type and/or bit depth of the data, and some others only work on -certain color types and bit depths. Even though each transformation -checks to see if it has data that it can do something with, you should -make sure to only enable a transformation if it will be valid for the -data. For example, don't swap red and blue on grayscale data. - -PNG files store RGB pixels packed into 3 or 6 bytes. This code tells -the library to strip input data that has 4 or 8 bytes per pixel down -to 3 or 6 bytes (or strip 2 or 4-byte grayscale+filler data to 1 or 2 -bytes per pixel). - - png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); - -where the 0 is unused, and the location is either PNG_FILLER_BEFORE or -PNG_FILLER_AFTER, depending upon whether the filler byte in the pixel -is stored XRGB or RGBX. - -PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as -they can, resulting in, for example, 8 pixels per byte for 1 bit files. -If the data is supplied at 1 pixel per byte, use this code, which will -correctly pack the pixels into a single byte: - - png_set_packing(png_ptr); - -PNG files reduce possible bit depths to 1, 2, 4, 8, and 16. If your -data is of another bit depth, you can write an sBIT chunk into the -file so that decoders can recover the original data if desired. - - /* Set the true bit depth of the image data */ - if (color_type & PNG_COLOR_MASK_COLOR) - { - sig_bit.red = true_bit_depth; - sig_bit.green = true_bit_depth; - sig_bit.blue = true_bit_depth; - } - else - { - sig_bit.gray = true_bit_depth; - } - if (color_type & PNG_COLOR_MASK_ALPHA) - { - sig_bit.alpha = true_bit_depth; - } - - png_set_sBIT(png_ptr, info_ptr, &sig_bit); - -If the data is stored in the row buffer in a bit depth other than -one supported by PNG (e.g. 3 bit data in the range 0-7 for a 4-bit PNG), -this will scale the values to appear to be the correct bit depth as -is required by PNG. - - png_set_shift(png_ptr, &sig_bit); - -PNG files store 16 bit pixels in network byte order (big-endian, -ie. most significant bits first). This code would be used if they are -supplied the other way (little-endian, i.e. least significant bits -first, the way PCs store them): - - if (bit_depth > 8) - png_set_swap(png_ptr); - -If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you -need to change the order the pixels are packed into bytes, you can use: - - if (bit_depth < 8) - png_set_packswap(png_ptr); - -PNG files store 3 color pixels in red, green, blue order. This code -would be used if they are supplied as blue, green, red: - - png_set_bgr(png_ptr); - -PNG files describe monochrome as black being zero and white being -one. This code would be used if the pixels are supplied with this reversed -(black being one and white being zero): - - png_set_invert_mono(png_ptr); - -Finally, you can write your own transformation function if none of -the existing ones meets your needs. This is done by setting a callback -with - - png_set_write_user_transform_fn(png_ptr, - write_transform_fn); - -You must supply the function - - void write_transform_fn(png_ptr ptr, row_info_ptr - row_info, png_bytep data) - -See pngtest.c for a working example. Your function will be called -before any of the other transformations are processed. - -You can also set up a pointer to a user structure for use by your -callback function. - - png_set_user_transform_info(png_ptr, user_ptr, 0, 0); - -The user_channels and user_depth parameters of this function are ignored -when writing; you can set them to zero as shown. - -You can retrieve the pointer via the function png_get_user_transform_ptr(). -For example: - - voidp write_user_transform_ptr = - png_get_user_transform_ptr(png_ptr); - -It is possible to have libpng flush any pending output, either manually, -or automatically after a certain number of lines have been written. To -flush the output stream a single time call: - - png_write_flush(png_ptr); - -and to have libpng flush the output stream periodically after a certain -number of scanlines have been written, call: - - png_set_flush(png_ptr, nrows); - -Note that the distance between rows is from the last time png_write_flush() -was called, or the first row of the image if it has never been called. -So if you write 50 lines, and then png_set_flush 25, it will flush the -output on the next scanline, and every 25 lines thereafter, unless -png_write_flush() is called before 25 more lines have been written. -If nrows is too small (less than about 10 lines for a 640 pixel wide -RGB image) the image compression may decrease noticeably (although this -may be acceptable for real-time applications). Infrequent flushing will -only degrade the compression performance by a few percent over images -that do not use flushing. - -Writing the image data - -That's it for the transformations. Now you can write the image data. -The simplest way to do this is in one function call. If you have the -whole image in memory, you can just call png_write_image() and libpng -will write the image. You will need to pass in an array of pointers to -each row. This function automatically handles interlacing, so you don't -need to call png_set_interlace_handling() or call this function multiple -times, or any of that other stuff necessary with png_write_rows(). - - png_write_image(png_ptr, row_pointers); - -where row_pointers is: - - png_byte *row_pointers[height]; - -You can point to void or char or whatever you use for pixels. - -If you don't want to write the whole image at once, you can -use png_write_rows() instead. If the file is not interlaced, -this is simple: - - png_write_rows(png_ptr, row_pointers, - number_of_rows); - -row_pointers is the same as in the png_write_image() call. - -If you are just writing one row at a time, you can do this with -a single row_pointer instead of an array of row_pointers: - - png_bytep row_pointer = row; - - png_write_row(png_ptr, row_pointer); - -When the file is interlaced, things can get a good deal more complicated. -The only currently (as of the PNG Specification version 1.2, dated July -1999) defined interlacing scheme for PNG files is the "Adam7" interlace -scheme, that breaks down an image into seven smaller images of varying -size. libpng will build these images for you, or you can do them -yourself. If you want to build them yourself, see the PNG specification -for details of which pixels to write when. - -If you don't want libpng to handle the interlacing details, just -use png_set_interlace_handling() and call png_write_rows() the -correct number of times to write all seven sub-images. - -If you want libpng to build the sub-images, call this before you start -writing any rows: - - number_of_passes = - png_set_interlace_handling(png_ptr); - -This will return the number of passes needed. Currently, this is seven, -but may change if another interlace type is added. - -Then write the complete image number_of_passes times. - - png_write_rows(png_ptr, row_pointers, - number_of_rows); - -As some of these rows are not used, and thus return immediately, you may -want to read about interlacing in the PNG specification, and only update -the rows that are actually used. - -Finishing a sequential write - -After you are finished writing the image, you should finish writing -the file. If you are interested in writing comments or time, you should -pass an appropriately filled png_info pointer. If you are not interested, -you can pass NULL. - - png_write_end(png_ptr, info_ptr); - -When you are done, you can free all memory used by libpng like this: - - png_destroy_write_struct(&png_ptr, &info_ptr); - -It is also possible to individually free the info_ptr members that -point to libpng-allocated storage with the following function: - - png_free_data(png_ptr, info_ptr, mask, seq) - mask - identifies data to be freed, a mask - containing the bitwise OR of one or - more of - PNG_FREE_PLTE, PNG_FREE_TRNS, - PNG_FREE_HIST, PNG_FREE_ICCP, - PNG_FREE_PCAL, PNG_FREE_ROWS, - PNG_FREE_SCAL, PNG_FREE_SPLT, - PNG_FREE_TEXT, PNG_FREE_UNKN, - or simply PNG_FREE_ALL - seq - sequence number of item to be freed - (-1 for all items) - -This function may be safely called when the relevant storage has -already been freed, or has not yet been allocated, or was allocated -by the user and not by libpng, and will in those cases do nothing. -The "seq" parameter is ignored if only one item of the selected data -type, such as PLTE, is allowed. If "seq" is not -1, and multiple items -are allowed for the data type identified in the mask, such as text or -sPLT, only the n'th item in the structure is freed, where n is "seq". - -If you allocated data such as a palette that you passed in to libpng -with png_set_*, you must not free it until just before the call to -png_destroy_write_struct(). - -The default behavior is only to free data that was allocated internally -by libpng. This can be changed, so that libpng will not free the data, -or so that it will free data that was allocated by the user with png_malloc() -or png_zalloc() and passed in via a png_set_*() function, with - - png_data_freer(png_ptr, info_ptr, freer, mask) - mask - which data elements are affected - same choices as in png_free_data() - freer - one of - PNG_DESTROY_WILL_FREE_DATA - PNG_SET_WILL_FREE_DATA - PNG_USER_WILL_FREE_DATA - -For example, to transfer responsibility for some data from a read structure -to a write structure, you could use - - png_data_freer(read_ptr, read_info_ptr, - PNG_USER_WILL_FREE_DATA, - PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) - png_data_freer(write_ptr, write_info_ptr, - PNG_DESTROY_WILL_FREE_DATA, - PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) - -thereby briefly reassigning responsibility for freeing to the user but -immediately afterwards reassigning it once more to the write_destroy -function. Having done this, it would then be safe to destroy the read -structure and continue to use the PLTE, tRNS, and hIST data in the write -structure. - -This function only affects data that has already been allocated. -You can call this function before calling after the png_set_*() functions -to control whether the user or png_destroy_*() is supposed to free the data. -When the user assumes responsibility for libpng-allocated data, the -application must use -png_free() to free it, and when the user transfers responsibility to libpng -for data that the user has allocated, the user must have used png_malloc() -or png_zalloc() to allocate it. - -If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword -separately, do not transfer responsibility for freeing text_ptr to libpng, -because when libpng fills a png_text structure it combines these members with -the key member, and png_free_data() will free only text_ptr.key. Similarly, -if you transfer responsibility for free'ing text_ptr from libpng to your -application, your application must not separately free those members. -For a more compact example of writing a PNG image, see the file example.c. - -V. Modifying/Customizing libpng: - -There are two issues here. The first is changing how libpng does -standard things like memory allocation, input/output, and error handling. -The second deals with more complicated things like adding new chunks, -adding new transformations, and generally changing how libpng works. -Both of those are compile-time issues; that is, they are generally -determined at the time the code is written, and there is rarely a need -to provide the user with a means of changing them. - -Memory allocation, input/output, and error handling - -All of the memory allocation, input/output, and error handling in libpng -goes through callbacks that are user-settable. The default routines are -in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively. To change -these functions, call the appropriate png_set_*_fn() function. - -Memory allocation is done through the functions png_malloc(), png_calloc(), -and png_free(). These currently just call the standard C functions. -png_calloc() calls png_malloc() and then png_memset() to clear the newly -allocated memory to zero. If your pointers can't access more then 64K -at a time, you will want to set MAXSEG_64K in zlib.h. Since it is -unlikely that the method of handling memory allocation on a platform -will change between applications, these functions must be modified in -the library at compile time. If you prefer to use a different method -of allocating and freeing data, you can use png_create_read_struct_2() or -png_create_write_struct_2() to register your own functions as described -above. These functions also provide a void pointer that can be retrieved -via - - mem_ptr=png_get_mem_ptr(png_ptr); - -Your replacement memory functions must have prototypes as follows: - - png_voidp malloc_fn(png_structp png_ptr, - png_alloc_size_t size); - void free_fn(png_structp png_ptr, png_voidp ptr); - -Your malloc_fn() must return NULL in case of failure. The png_malloc() -function will normally call png_error() if it receives a NULL from the -system memory allocator or from your replacement malloc_fn(). - -Your free_fn() will never be called with a NULL ptr, since libpng's -png_free() checks for NULL before calling free_fn(). - -Input/Output in libpng is done through png_read() and png_write(), -which currently just call fread() and fwrite(). The FILE * is stored in -png_struct and is initialized via png_init_io(). If you wish to change -the method of I/O, the library supplies callbacks that you can set -through the function png_set_read_fn() and png_set_write_fn() at run -time, instead of calling the png_init_io() function. These functions -also provide a void pointer that can be retrieved via the function -png_get_io_ptr(). For example: - - png_set_read_fn(png_structp read_ptr, - voidp read_io_ptr, png_rw_ptr read_data_fn) - - png_set_write_fn(png_structp write_ptr, - voidp write_io_ptr, png_rw_ptr write_data_fn, - png_flush_ptr output_flush_fn); - - voidp read_io_ptr = png_get_io_ptr(read_ptr); - voidp write_io_ptr = png_get_io_ptr(write_ptr); - -The replacement I/O functions must have prototypes as follows: - - void user_read_data(png_structp png_ptr, - png_bytep data, png_size_t length); - void user_write_data(png_structp png_ptr, - png_bytep data, png_size_t length); - void user_flush_data(png_structp png_ptr); - -The user_read_data() function is responsible for detecting and -handling end-of-data errors. - -Supplying NULL for the read, write, or flush functions sets them back -to using the default C stream functions, which expect the io_ptr to -point to a standard *FILE structure. It is probably a mistake -to use NULL for one of write_data_fn and output_flush_fn but not both -of them, unless you have built libpng with PNG_NO_WRITE_FLUSH defined. -It is an error to read from a write stream, and vice versa. - -Error handling in libpng is done through png_error() and png_warning(). -Errors handled through png_error() are fatal, meaning that png_error() -should never return to its caller. Currently, this is handled via -setjmp() and longjmp() (unless you have compiled libpng with -PNG_NO_SETJMP, in which case it is handled via PNG_ABORT()), -but you could change this to do things like exit() if you should wish, -as long as your function does not return. - -On non-fatal errors, png_warning() is called -to print a warning message, and then control returns to the calling code. -By default png_error() and png_warning() print a message on stderr via -fprintf() unless the library is compiled with PNG_NO_CONSOLE_IO defined -(because you don't want the messages) or PNG_NO_STDIO defined (because -fprintf() isn't available). If you wish to change the behavior of the error -functions, you will need to set up your own message callbacks. These -functions are normally supplied at the time that the png_struct is created. -It is also possible to redirect errors and warnings to your own replacement -functions after png_create_*_struct() has been called by calling: - - png_set_error_fn(png_structp png_ptr, - png_voidp error_ptr, png_error_ptr error_fn, - png_error_ptr warning_fn); - - png_voidp error_ptr = png_get_error_ptr(png_ptr); - -If NULL is supplied for either error_fn or warning_fn, then the libpng -default function will be used, calling fprintf() and/or longjmp() if a -problem is encountered. The replacement error functions should have -parameters as follows: - - void user_error_fn(png_structp png_ptr, - png_const_charp error_msg); - void user_warning_fn(png_structp png_ptr, - png_const_charp warning_msg); - -The motivation behind using setjmp() and longjmp() is the C++ throw and -catch exception handling methods. This makes the code much easier to write, -as there is no need to check every return code of every function call. -However, there are some uncertainties about the status of local variables -after a longjmp, so the user may want to be careful about doing anything -after setjmp returns non-zero besides returning itself. Consult your -compiler documentation for more details. For an alternative approach, you -may wish to use the "cexcept" facility (see http://cexcept.sourceforge.net). - -Custom chunks - -If you need to read or write custom chunks, you may need to get deeper -into the libpng code. The library now has mechanisms for storing -and writing chunks of unknown type; you can even declare callbacks -for custom chunks. However, this may not be good enough if the -library code itself needs to know about interactions between your -chunk and existing `intrinsic' chunks. - -If you need to write a new intrinsic chunk, first read the PNG -specification. Acquire a first level of understanding of how it works. -Pay particular attention to the sections that describe chunk names, -and look at how other chunks were designed, so you can do things -similarly. Second, check out the sections of libpng that read and -write chunks. Try to find a chunk that is similar to yours and use -it as a template. More details can be found in the comments inside -the code. It is best to handle unknown chunks in a generic method, -via callback functions, instead of by modifying libpng functions. - -If you wish to write your own transformation for the data, look through -the part of the code that does the transformations, and check out some of -the simpler ones to get an idea of how they work. Try to find a similar -transformation to the one you want to add and copy off of it. More details -can be found in the comments inside the code itself. - -Configuring for 16 bit platforms - -You will want to look into zconf.h to tell zlib (and thus libpng) that -it cannot allocate more then 64K at a time. Even if you can, the memory -won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K. - -Configuring for DOS - -For DOS users who only have access to the lower 640K, you will -have to limit zlib's memory usage via a png_set_compression_mem_level() -call. See zlib.h or zconf.h in the zlib library for more information. - -Configuring for Medium Model - -Libpng's support for medium model has been tested on most of the popular -compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets -defined, and FAR gets defined to far in pngconf.h, and you should be -all set. Everything in the library (except for zlib's structure) is -expecting far data. You must use the typedefs with the p or pp on -the end for pointers (or at least look at them and be careful). Make -note that the rows of data are defined as png_bytepp, which is an -unsigned char far * far *. - -Configuring for gui/windowing platforms: - -You will need to write new error and warning functions that use the GUI -interface, as described previously, and set them to be the error and -warning functions at the time that png_create_*_struct() is called, -in order to have them available during the structure initialization. -They can be changed later via png_set_error_fn(). On some compilers, -you may also have to change the memory allocators (png_malloc, etc.). - -Configuring for compiler xxx: - -All includes for libpng are in pngconf.h. If you need to add, change -or delete an include, this is the place to do it. -The includes that are not needed outside libpng are placed in pngpriv.h, -which is only used by the routines inside libpng itself. -The files in libpng proper only include pngpriv.h and png.h, which -in turn includes pngconf.h. - -Configuring zlib: - -There are special functions to configure the compression. Perhaps the -most useful one changes the compression level, which currently uses -input compression values in the range 0 - 9. The library normally -uses the default compression level (Z_DEFAULT_COMPRESSION = 6). Tests -have shown that for a large majority of images, compression values in -the range 3-6 compress nearly as well as higher levels, and do so much -faster. For online applications it may be desirable to have maximum speed -(Z_BEST_SPEED = 1). With versions of zlib after v0.99, you can also -specify no compression (Z_NO_COMPRESSION = 0), but this would create -files larger than just storing the raw bitmap. You can specify the -compression level by calling: - - png_set_compression_level(png_ptr, level); - -Another useful one is to reduce the memory level used by the library. -The memory level defaults to 8, but it can be lowered if you are -short on memory (running DOS, for example, where you only have 640K). -Note that the memory level does have an effect on compression; among -other things, lower levels will result in sections of incompressible -data being emitted in smaller stored blocks, with a correspondingly -larger relative overhead of up to 15% in the worst case. - - png_set_compression_mem_level(png_ptr, level); - -The other functions are for configuring zlib. They are not recommended -for normal use and may result in writing an invalid PNG file. See -zlib.h for more information on what these mean. - - png_set_compression_strategy(png_ptr, - strategy); - png_set_compression_window_bits(png_ptr, - window_bits); - png_set_compression_method(png_ptr, method); - png_set_compression_buffer_size(png_ptr, size); - -Controlling row filtering - -If you want to control whether libpng uses filtering or not, which -filters are used, and how it goes about picking row filters, you -can call one of these functions. The selection and configuration -of row filters can have a significant impact on the size and -encoding speed and a somewhat lesser impact on the decoding speed -of an image. Filtering is enabled by default for RGB and grayscale -images (with and without alpha), but not for paletted images nor -for any images with bit depths less than 8 bits/pixel. - -The 'method' parameter sets the main filtering method, which is -currently only '0' in the PNG 1.2 specification. The 'filters' -parameter sets which filter(s), if any, should be used for each -scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS -to turn filtering on and off, respectively. - -Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB, -PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise -ORed together with '|' to specify one or more filters to use. -These filters are described in more detail in the PNG specification. -If you intend to change the filter type during the course of writing -the image, you should start with flags set for all of the filters -you intend to use so that libpng can initialize its internal -structures appropriately for all of the filter types. (Note that this -means the first row must always be adaptively filtered, because libpng -currently does not allocate the filter buffers until png_write_row() -is called for the first time.) - - filters = PNG_FILTER_NONE | PNG_FILTER_SUB - PNG_FILTER_UP | PNG_FILTER_AVG | - PNG_FILTER_PAETH | PNG_ALL_FILTERS; - - png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, - filters); - The second parameter can also be - PNG_INTRAPIXEL_DIFFERENCING if you are - writing a PNG to be embedded in a MNG - datastream. This parameter must be the - same as the value of filter_method used - in png_set_IHDR(). - -It is also possible to influence how libpng chooses from among the -available filters. This is done in one or both of two ways - by -telling it how important it is to keep the same filter for successive -rows, and by telling it the relative computational costs of the filters. - - double weights[3] = {1.5, 1.3, 1.1}, - costs[PNG_FILTER_VALUE_LAST] = - {1.0, 1.3, 1.3, 1.5, 1.7}; - - png_set_filter_heuristics(png_ptr, - PNG_FILTER_HEURISTIC_WEIGHTED, 3, - weights, costs); - -The weights are multiplying factors that indicate to libpng that the -row filter should be the same for successive rows unless another row filter -is that many times better than the previous filter. In the above example, -if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a -"sum of absolute differences" 1.5 x 1.3 times higher than other filters -and still be chosen, while the NONE filter could have a sum 1.1 times -higher than other filters and still be chosen. Unspecified weights are -taken to be 1.0, and the specified weights should probably be declining -like those above in order to emphasize recent filters over older filters. - -The filter costs specify for each filter type a relative decoding cost -to be considered when selecting row filters. This means that filters -with higher costs are less likely to be chosen over filters with lower -costs, unless their "sum of absolute differences" is that much smaller. -The costs do not necessarily reflect the exact computational speeds of -the various filters, since this would unduly influence the final image -size. - -Note that the numbers above were invented purely for this example and -are given only to help explain the function usage. Little testing has -been done to find optimum values for either the costs or the weights. - -Removing unwanted object code - -There are a bunch of #define's in pngconf.h that control what parts of -libpng are compiled. All the defines end in _SUPPORTED. If you are -never going to use a capability, you can change the #define to #undef -before recompiling libpng and save yourself code and data space, or -you can turn off individual capabilities with defines that begin with -PNG_NO_. - -You can also turn all of the transforms and ancillary chunk capabilities -off en masse with compiler directives that define -PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS, -or all four, -along with directives to turn on any of the capabilities that you do -want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable the extra -transformations but still leave the library fully capable of reading -and writing PNG files with all known public chunks. Use of the -PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive produces a library -that is incapable of reading or writing ancillary chunks. If you are -not using the progressive reading capability, you can turn that off -with PNG_NO_PROGRESSIVE_READ (don't confuse this with the INTERLACING -capability, which you'll still have). - -All the reading and writing specific code are in separate files, so the -linker should only grab the files it needs. However, if you want to -make sure, or if you are building a stand alone library, all the -reading files start with pngr and all the writing files start with -pngw. The files that don't match either (like png.c, pngtrans.c, etc.) -are used for both reading and writing, and always need to be included. -The progressive reader is in pngpread.c - -If you are creating or distributing a dynamically linked library (a .so -or DLL file), you should not remove or disable any parts of the library, -as this will cause applications linked with different versions of the -library to fail if they call functions not available in your library. -The size of the library itself should not be an issue, because only -those sections that are actually used will be loaded into memory. - -Requesting debug printout - -The macro definition PNG_DEBUG can be used to request debugging -printout. Set it to an integer value in the range 0 to 3. Higher -numbers result in increasing amounts of debugging information. The -information is printed to the "stderr" file, unless another file -name is specified in the PNG_DEBUG_FILE macro definition. - -When PNG_DEBUG > 0, the following functions (macros) become available: - - png_debug(level, message) - png_debug1(level, message, p1) - png_debug2(level, message, p1, p2) - -in which "level" is compared to PNG_DEBUG to decide whether to print -the message, "message" is the formatted string to be printed, -and p1 and p2 are parameters that are to be embedded in the string -according to printf-style formatting directives. For example, - - png_debug1(2, "foo=%d\n", foo); - -is expanded to - - if(PNG_DEBUG > 2) - fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo); - -When PNG_DEBUG is defined but is zero, the macros aren't defined, but you -can still use PNG_DEBUG to control your own debugging: - - #ifdef PNG_DEBUG - fprintf(stderr, ... - #endif - -When PNG_DEBUG = 1, the macros are defined, but only png_debug statements -having level = 0 will be printed. There aren't any such statements in -this version of libpng, but if you insert some they will be printed. - -VI. MNG support - -The MNG specification (available at http://www.libpng.org/pub/mng) allows -certain extensions to PNG for PNG images that are embedded in MNG datastreams. -Libpng can support some of these extensions. To enable them, use the -png_permit_mng_features() function: - - feature_set = png_permit_mng_features(png_ptr, mask) - mask is a png_uint_32 containing the bitwise OR of the - features you want to enable. These include - PNG_FLAG_MNG_EMPTY_PLTE - PNG_FLAG_MNG_FILTER_64 - PNG_ALL_MNG_FEATURES - feature_set is a png_uint_32 that is the bitwise AND of - your mask with the set of MNG features that is - supported by the version of libpng that you are using. - -It is an error to use this function when reading or writing a standalone -PNG file with the PNG 8-byte signature. The PNG datastream must be wrapped -in a MNG datastream. As a minimum, it must have the MNG 8-byte signature -and the MHDR and MEND chunks. Libpng does not provide support for these -or any other MNG chunks; your application must provide its own support for -them. You may wish to consider using libmng (available at -http://www.libmng.com) instead. - -VII. Changes to Libpng from version 0.88 - -It should be noted that versions of libpng later than 0.96 are not -distributed by the original libpng author, Guy Schalnat, nor by -Andreas Dilger, who had taken over from Guy during 1996 and 1997, and -distributed versions 0.89 through 0.96, but rather by another member -of the original PNG Group, Glenn Randers-Pehrson. Guy and Andreas are -still alive and well, but they have moved on to other things. - -The old libpng functions png_read_init(), png_write_init(), -png_info_init(), png_read_destroy(), and png_write_destroy() have been -moved to PNG_INTERNAL in version 0.95 to discourage their use. These -functions will be removed from libpng version 2.0.0. - -The preferred method of creating and initializing the libpng structures is -via the png_create_read_struct(), png_create_write_struct(), and -png_create_info_struct() because they isolate the size of the structures -from the application, allow version error checking, and also allow the -use of custom error handling routines during the initialization, which -the old functions do not. The functions png_read_destroy() and -png_write_destroy() do not actually free the memory that libpng -allocated for these structs, but just reset the data structures, so they -can be used instead of png_destroy_read_struct() and -png_destroy_write_struct() if you feel there is too much system overhead -allocating and freeing the png_struct for each image read. - -Setting the error callbacks via png_set_message_fn() before -png_read_init() as was suggested in libpng-0.88 is no longer supported -because this caused applications that do not use custom error functions -to fail if the png_ptr was not initialized to zero. It is still possible -to set the error callbacks AFTER png_read_init(), or to change them with -png_set_error_fn(), which is essentially the same function, but with a new -name to force compilation errors with applications that try to use the old -method. - -Starting with version 1.0.7, you can find out which version of the library -you are using at run-time: - - png_uint_32 libpng_vn = png_access_version_number(); - -The number libpng_vn is constructed from the major version, minor -version with leading zero, and release number with leading zero, -(e.g., libpng_vn for version 1.0.7 is 10007). - -You can also check which version of png.h you used when compiling your -application: - - png_uint_32 application_vn = PNG_LIBPNG_VER; - -VIII. Changes to Libpng from version 1.0.x to 1.2.x - -Support for user memory management was enabled by default. To -accomplish this, the functions png_create_read_struct_2(), -png_create_write_struct_2(), png_set_mem_fn(), png_get_mem_ptr(), -png_malloc_default(), and png_free_default() were added. - -Support for the iTXt chunk has been enabled by default as of -version 1.2.41. - -Support for certain MNG features was enabled. - -Support for numbered error messages was added. However, we never got -around to actually numbering the error messages. The function -png_set_strip_error_numbers() was added (Note: the prototype for this -function was inadvertently removed from png.h in PNG_NO_ASSEMBLER_CODE -builds of libpng-1.2.15. It was restored in libpng-1.2.36). - -The png_malloc_warn() function was added at libpng-1.2.3. This issues -a png_warning and returns NULL instead of aborting when it fails to -acquire the requested memory allocation. - -Support for setting user limits on image width and height was enabled -by default. The functions png_set_user_limits(), png_get_user_width_max(), -and png_get_user_height_max() were added at libpng-1.2.6. - -The png_set_add_alpha() function was added at libpng-1.2.7. - -The function png_set_expand_gray_1_2_4_to_8() was added at libpng-1.2.9. -Unlike png_set_gray_1_2_4_to_8(), the new function does not expand the -tRNS chunk to alpha. The png_set_gray_1_2_4_to_8() function is -deprecated. - -A number of macro definitions in support of runtime selection of -assembler code features (especially Intel MMX code support) were -added at libpng-1.2.0: - - PNG_ASM_FLAG_MMX_SUPPORT_COMPILED - PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU - PNG_ASM_FLAG_MMX_READ_COMBINE_ROW - PNG_ASM_FLAG_MMX_READ_INTERLACE - PNG_ASM_FLAG_MMX_READ_FILTER_SUB - PNG_ASM_FLAG_MMX_READ_FILTER_UP - PNG_ASM_FLAG_MMX_READ_FILTER_AVG - PNG_ASM_FLAG_MMX_READ_FILTER_PAETH - PNG_ASM_FLAGS_INITIALIZED - PNG_MMX_READ_FLAGS - PNG_MMX_FLAGS - PNG_MMX_WRITE_FLAGS - PNG_MMX_FLAGS - -We added the following functions in support of runtime -selection of assembler code features: - - png_get_mmx_flagmask() - png_set_mmx_thresholds() - png_get_asm_flags() - png_get_mmx_bitdepth_threshold() - png_get_mmx_rowbytes_threshold() - png_set_asm_flags() - -We replaced all of these functions with simple stubs in libpng-1.2.20, -when the Intel assembler code was removed due to a licensing issue. - -These macros are deprecated: - - PNG_READ_TRANSFORMS_NOT_SUPPORTED - PNG_PROGRESSIVE_READ_NOT_SUPPORTED - PNG_NO_SEQUENTIAL_READ_SUPPORTED - PNG_WRITE_TRANSFORMS_NOT_SUPPORTED - PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED - PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED - -They have been replaced, respectively, by: - - PNG_NO_READ_TRANSFORMS - PNG_NO_PROGRESSIVE_READ - PNG_NO_SEQUENTIAL_READ - PNG_NO_WRITE_TRANSFORMS - PNG_NO_READ_ANCILLARY_CHUNKS - PNG_NO_WRITE_ANCILLARY_CHUNKS - -PNG_MAX_UINT was replaced with PNG_UINT_31_MAX. It has been -deprecated since libpng-1.0.16 and libpng-1.2.6. - -The function - png_check_sig(sig, num) -was replaced with - !png_sig_cmp(sig, 0, num) -It has been deprecated since libpng-0.90. - -The function - png_set_gray_1_2_4_to_8() -which also expands tRNS to alpha was replaced with - png_set_expand_gray_1_2_4_to_8() -which does not. It has been deprecated since libpng-1.0.18 and 1.2.9. - -IX. Changes to Libpng from version 1.0.x/1.2.x to 1.4.x - -Private libpng prototypes and macro definitions were moved from -png.h and pngconf.h into a new pngpriv.h header file. - -Functions png_set_benign_errors(), png_benign_error(), and -png_chunk_benign_error() were added. - -Support for setting the maximum amount of memory that the application -will allocate for reading chunks was added, as a security measure. -The functions png_set_chunk_cache_max() and png_get_chunk_cache_max() -were added to the library. - -We implemented support for I/O states by adding png_ptr member io_state -and functions png_get_io_chunk_name() and png_get_io_state() in pngget.c - -We added PNG_TRANSFORM_GRAY_TO_RGB to the available high-level -input transforms. - -Checking for and reporting of errors in the IHDR chunk is more thorough. - -Support for global arrays was removed, to improve thread safety. - -Some obsolete/deprecated macros and functions have been removed. - -Typecasted NULL definitions such as - #define png_voidp_NULL (png_voidp)NULL -were eliminated. If you used these in your application, just use -NULL instead. - -The png_struct and info_struct members "trans" and "trans_values" were -changed to "trans_alpha" and "trans_color", respectively. - -The obsolete, unused pnggccrd.c and pngvcrd.c files and related makefiles -were removed. - -The PNG_1_0_X and PNG_1_2_X macros were eliminated. - -The PNG_LEGACY_SUPPORTED macro was eliminated. - -Many WIN32_WCE #ifdefs were removed. - -The functions png_read_init(info_ptr), png_write_init(info_ptr), -png_info_init(info_ptr), png_read_destroy(), and png_write_destroy() -have been removed. They have been deprecated since libpng-0.95. - -The png_permit_empty_plte() was removed. It has been deprecated -since libpng-1.0.9. Use png_permit_mng_features() instead. - -We removed the obsolete stub functions png_get_mmx_flagmask(), -png_set_mmx_thresholds(), png_get_asm_flags(), -png_get_mmx_bitdepth_threshold(), png_get_mmx_rowbytes_threshold(), -png_set_asm_flags(), and png_mmx_supported() - -We removed the obsolete png_check_sig(), png_memcpy_check(), and -png_memset_check() functions. Instead use !png_sig_cmp(), png_memcpy(), -and png_memset(), respectively. - -The function png_set_gray_1_2_4_to_8() was removed. It has been -deprecated since libpng-1.0.18 and 1.2.9, when it was replaced with -png_set_expand_gray_1_2_4_to_8() because the former function also -expanded palette images. - -We changed the prototype for png_malloc() from - png_malloc(png_structp png_ptr, png_uint_32 size) -to - png_malloc(png_structp png_ptr, png_alloc_size_t size) - -This also applies to the prototype for the user replacement malloc_fn(). - -The png_calloc() function was added and is used in place of -of "png_malloc(); png_memset();" except in the case in png_read_png() -where the array consists of pointers; in this case a "for" loop is used -after the png_malloc() to set the pointers to NULL, to give robust. -behavior in case the application runs out of memory part-way through -the process. - -We changed the prototypes of png_get_compression_buffer_size() and -png_set_compression_buffer_size() to work with png_size_t instead of -png_uint_32. - -Support for numbered error messages was removed by default, since we -never got around to actually numbering the error messages. The function -png_set_strip_error_numbers() was removed from the library by default. - -The png_zalloc() and png_zfree() functions are no longer exported. -The png_zalloc() function no longer zeroes out the memory that it -allocates. - -Support for dithering was disabled by default in libpng-1.4.0, because -been well tested and doesn't actually "dither". The code was not -removed, however, and could be enabled by building libpng with -PNG_READ_DITHER_SUPPORTED defined. In libpng-1.4.2, this support -was reenabled, but the function was renamed png_set_quantize() to -reflect more accurately what it actually does. At the same time, -the PNG_DITHER_[RED,GREEN_BLUE]_BITS macros were also renamed to -PNG_QUANTIZE_[RED,GREEN,BLUE]_BITS. - -We removed the trailing '.' from the warning and error messages. - -X. Detecting libpng - -The png_get_io_ptr() function has been present since libpng-0.88, has never -changed, and is unaffected by conditional compilation macros. It is the -best choice for use in configure scripts for detecting the presence of any -libpng version since 0.88. In an autoconf "configure.in" you could use - - AC_CHECK_LIB(png, png_get_io_ptr, ... - -XI. Source code repository - -Since about February 2009, version 1.2.34, libpng has been under "git" source -control. The git repository was built from old libpng-x.y.z.tar.gz files -going back to version 0.70. You can access the git repository (read only) -at - - git://libpng.git.sourceforge.net/gitroot/libpng - -or you can browse it via "gitweb" at - - http://libpng.git.sourceforge.net/git/gitweb.cgi?p=libpng - -Patches can be sent to glennrp at users.sourceforge.net or to -png-mng-implement at lists.sourceforge.net or you can upload them to -the libpng bug tracker at - - http://libpng.sourceforge.net - -XII. Coding style - -Our coding style is similar to the "Allman" style, with curly -braces on separate lines: - - if (condition) - { - action; - } - - else if (another condition) - { - another action; - } - -The braces can be omitted from simple one-line actions: - - if (condition) - return (0); - -We use 3-space indentation, except for continued statements which -are usually indented the same as the first line of the statement -plus four more spaces. - -For macro definitions we use 2-space indentation, always leaving the "#" -in the first column. - - #ifndef PNG_NO_FEATURE - # ifndef PNG_FEATURE_SUPPORTED - # define PNG_FEATURE_SUPPORTED - # endif - #endif - -Comments appear with the leading "/*" at the same indentation as -the statement that follows the comment: - - /* Single-line comment */ - statement; - - /* This is a multiple-line - * comment. - */ - statement; - -Very short comments can be placed after the end of the statement -to which they pertain: - - statement; /* comment */ - -We don't use C++ style ("//") comments. We have, however, -used them in the past in some now-abandoned MMX assembler -code. - -Functions and their curly braces are not indented, and -exported functions are marked with PNGAPI: - - /* This is a public function that is visible to - * application programers. It does thus-and-so. - */ - void PNGAPI - png_exported_function(png_ptr, png_info, foo) - { - body; - } - -The prototypes for all exported functions appear in png.h, -above the comment that says - - /* Maintainer: Put new public prototypes here ... */ - -We mark all non-exported functions with "/* PRIVATE */"": - - void /* PRIVATE */ - png_non_exported_function(png_ptr, png_info, foo) - { - body; - } - -The prototypes for non-exported functions (except for those in -pngtest) appear in -pngpriv.h -above the comment that says - - /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ - -The names of all exported functions and variables begin -with "png_", and all publicly visible C preprocessor -macros begin with "PNG_". - -We put a space after each comma and after each semicolon -in "for" statments, and we put spaces before and after each -C binary operator and after "for" or "while", and before -"?". We don't put a space between a typecast and the expression -being cast, nor do we put one between a function name and the -left parenthesis that follows it: - - for (i = 2; i > 0; --i) - y[i] = a(x) + (int)b; - -We prefer #ifdef and #ifndef to #if defined() and if !defined() -when there is only one macro being tested. - -We do not use the TAB character for indentation in the C sources. - -Lines do not exceed 80 characters. - -Other rules can be inferred by inspecting the libpng source. - -XIII. Y2K Compliance in libpng - -June 26, 2010 - -Since the PNG Development group is an ad-hoc body, we can't make -an official declaration. - -This is your unofficial assurance that libpng from version 0.71 and -upward through 1.4.3 are Y2K compliant. It is my belief that earlier -versions were also Y2K compliant. - -Libpng only has three year fields. One is a 2-byte unsigned integer that -will hold years up to 65535. The other two hold the date in text -format, and will hold years up to 9999. - -The integer is - "png_uint_16 year" in png_time_struct. - -The strings are - "png_charp time_buffer" in png_struct and - "near_time_buffer", which is a local character string in png.c. - -There are seven time-related functions: - - png_convert_to_rfc_1123() in png.c - (formerly png_convert_to_rfc_1152() in error) - png_convert_from_struct_tm() in pngwrite.c, called - in pngwrite.c - png_convert_from_time_t() in pngwrite.c - png_get_tIME() in pngget.c - png_handle_tIME() in pngrutil.c, called in pngread.c - png_set_tIME() in pngset.c - png_write_tIME() in pngwutil.c, called in pngwrite.c - -All appear to handle dates properly in a Y2K environment. The -png_convert_from_time_t() function calls gmtime() to convert from system -clock time, which returns (year - 1900), which we properly convert to -the full 4-digit year. There is a possibility that applications using -libpng are not passing 4-digit years into the png_convert_to_rfc_1123() -function, or that they are incorrectly passing only a 2-digit year -instead of "year - 1900" into the png_convert_from_struct_tm() function, -but this is not under our control. The libpng documentation has always -stated that it works with 4-digit years, and the APIs have been -documented as such. - -The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned -integer to hold the year, and can hold years as large as 65535. - -zlib, upon which libpng depends, is also Y2K compliant. It contains -no date-related code. - - - Glenn Randers-Pehrson - libpng maintainer - PNG Development Group diff --git a/plugins/AdvaImg/src/LibPNG/libpngpf.3 b/plugins/AdvaImg/src/LibPNG/libpngpf.3 index ef54f7b5b0..f6b62a0323 100644 --- a/plugins/AdvaImg/src/LibPNG/libpngpf.3 +++ b/plugins/AdvaImg/src/LibPNG/libpngpf.3 @@ -1,6 +1,6 @@ -.TH LIBPNGPF 3 "February 18, 2012" +.TH LIBPNGPF 3 "September 27, 2012" .SH NAME -libpng \- Portable Network Graphics (PNG) Reference Library 1.5.9 +libpng \- Portable Network Graphics (PNG) Reference Library 1.5.13 (private functions) .SH SYNOPSIS \fB#include \fI"pngpriv.h" diff --git a/plugins/AdvaImg/src/LibPNG/png.5 b/plugins/AdvaImg/src/LibPNG/png.5 index 6df917d4ae..cfd109f291 100644 --- a/plugins/AdvaImg/src/LibPNG/png.5 +++ b/plugins/AdvaImg/src/LibPNG/png.5 @@ -1,4 +1,4 @@ -.TH PNG 5 "February 18, 2012" +.TH PNG 5 "September 27, 2012" .SH NAME png \- Portable Network Graphics (PNG) format .SH DESCRIPTION diff --git a/plugins/AdvaImg/src/LibPNG/png.c b/plugins/AdvaImg/src/LibPNG/png.c index 0df53a62af..55fbc8fcc1 100644 --- a/plugins/AdvaImg/src/LibPNG/png.c +++ b/plugins/AdvaImg/src/LibPNG/png.c @@ -1,8 +1,8 @@ /* png.c - location for general purpose libpng functions * - * Last changed in libpng 1.5.7 [December 15, 2011] - * Copyright (c) 1998-2011 Glenn Randers-Pehrson + * Last changed in libpng 1.5.11 [June 14, 2012] + * Copyright (c) 1998-2012 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -14,7 +14,7 @@ #include "pngpriv.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_5_9 Your_png_h_is_not_version_1_5_9; +typedef png_libpng_version_1_5_13 Your_png_h_is_not_version_1_5_13; /* Tells libpng that we have already handled the first "num_bytes" bytes * of the PNG file signature. If the PNG data is embedded into another @@ -655,14 +655,14 @@ png_get_copyright(png_const_structp png_ptr) #else # ifdef __STDC__ return PNG_STRING_NEWLINE \ - "libpng version 1.5.9 - February 18, 2012" PNG_STRING_NEWLINE \ - "Copyright (c) 1998-2011 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \ + "libpng version 1.5.13 - September 27, 2012" PNG_STRING_NEWLINE \ + "Copyright (c) 1998-2012 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ PNG_STRING_NEWLINE; # else - return "libpng version 1.5.9 - February 18, 2012\ - Copyright (c) 1998-2011 Glenn Randers-Pehrson\ + return "libpng version 1.5.13 - September 27, 2012\ + Copyright (c) 1998-2012 Glenn Randers-Pehrson\ Copyright (c) 1996-1997 Andreas Dilger\ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; # endif @@ -969,8 +969,8 @@ int png_XYZ_from_xy(png_XYZ *XYZ, png_xy xy) * and it is certain that it becomes unstable where the end points are close * together. * - * So this code uses the perhaps slighly less optimal but more understandable - * and totally obvious approach of calculating color-scale. + * So this code uses the perhaps slightly less optimal but more + * understandable and totally obvious approach of calculating color-scale. * * This algorithm depends on the precision in white-scale and that is * (1/white-y), so we can immediately see that as white-y approaches 0 the @@ -1035,13 +1035,13 @@ int png_XYZ_from_xy(png_XYZ *XYZ, png_xy xy) * * red-scale = * ( (green-x - blue-x) * (white-y - blue-y) - - * (green-y - blue-y) * (white-x - blue-x)) / white-y + * (green-y - blue-y) * (white-x - blue-x) ) / white-y * ------------------------------------------------------------------------- * (green-x - blue-x)*(red-y - blue-y)-(green-y - blue-y)*(red-x - blue-x) * * green-scale = * ( (red-y - blue-y) * (white-x - blue-x) - - * (red-x - blue-x) * (white-y - blue-y)) / white-y + * (red-x - blue-x) * (white-y - blue-y) ) / white-y * ------------------------------------------------------------------------- * (green-x - blue-x)*(red-y - blue-y)-(green-y - blue-y)*(red-x - blue-x) * @@ -1467,7 +1467,7 @@ static double png_pow10(int power) { int recip = 0; - double d = 1; + double d = 1.0; /* Handle negative exponent with a reciprocal at the end because * 10 is exact whereas .1 is inexact in base 2 @@ -1481,7 +1481,7 @@ png_pow10(int power) if (power > 0) { /* Decompose power bitwise. */ - double mult = 10; + double mult = 10.0; do { if (power & 1) d *= mult; @@ -1600,7 +1600,8 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size, { double d; - fp *= 10; + fp *= 10.0; + /* Use modf here, not floor and subtract, so that * the separation is done in one step. At the end * of the loop don't break the number into parts so @@ -1613,7 +1614,7 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size, { d = floor(fp + .5); - if (d > 9) + if (d > 9.0) { /* Rounding up to 10, handle that here. */ if (czero > 0) @@ -1621,9 +1622,10 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size, --czero, d = 1; if (cdigits == 0) --clead; } + else { - while (cdigits > 0 && d > 9) + while (cdigits > 0 && d > 9.0) { int ch = *--ascii; @@ -1648,7 +1650,7 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size, * exponent but take into account the leading * decimal point. */ - if (d > 9) /* cdigits == 0 */ + if (d > 9.0) /* cdigits == 0 */ { if (exp_b10 == (-1)) { @@ -1669,18 +1671,19 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size, ++exp_b10; /* In all cases we output a '1' */ - d = 1; + d = 1.0; } } } fp = 0; /* Guarantees termination below. */ } - if (d == 0) + if (d == 0.0) { ++czero; if (cdigits == 0) ++clead; } + else { /* Included embedded zeros in the digit count. */ @@ -1708,6 +1711,7 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size, above */ --exp_b10; } + *ascii++ = (char)(48 + (int)d), ++cdigits; } } @@ -2040,7 +2044,7 @@ png_muldiv_warn(png_structp png_ptr, png_fixed_point a, png_int_32 times, } #endif -#ifdef PNG_READ_GAMMA_SUPPORTED /* more fixed point functions for gammma */ +#ifdef PNG_READ_GAMMA_SUPPORTED /* more fixed point functions for gamma */ /* Calculate a reciprocal, return 0 on div-by-zero or overflow. */ png_fixed_point png_reciprocal(png_fixed_point a) diff --git a/plugins/AdvaImg/src/LibPNG/png.h b/plugins/AdvaImg/src/LibPNG/png.h index 81267675a5..6d762fca69 100644 --- a/plugins/AdvaImg/src/LibPNG/png.h +++ b/plugins/AdvaImg/src/LibPNG/png.h @@ -1,7 +1,7 @@ /* png.h - header file for PNG reference library * - * libpng version 1.5.9 - February 18, 2012 + * libpng version 1.5.13 - September 27, 2012 * Copyright (c) 1998-2012 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -11,7 +11,7 @@ * Authors and maintainers: * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger - * libpng versions 0.97, January 1998, through 1.5.9 - February 18, 2012: Glenn + * libpng versions 0.97, January 1998, through 1.5.13 - September 27, 2012: Glenn * See also "Contributing Authors", below. * * Note about libpng version numbers: @@ -172,6 +172,15 @@ * 1.5.9beta01-02 15 10509 15.so.15.9[.0] * 1.5.9rc01 15 10509 15.so.15.9[.0] * 1.5.9 15 10509 15.so.15.9[.0] + * 1.5.10beta01-05 15 10510 15.so.15.10[.0] + * 1.5.10 15 10510 15.so.15.10[.0] + * 1.5.11beta01 15 10511 15.so.15.11[.0] + * 1.5.11rc01-05 15 10511 15.so.15.11[.0] + * 1.5.11 15 10511 15.so.15.11[.0] + * 1.5.12 15 10512 15.so.15.12[.0] + * 1.5.13beta01-02 15 10513 15.so.15.13[.0] + * 1.5.13rc01 15 10513 15.so.15.13[.0] + * 1.5.13 15 10513 15.so.15.13[.0] * * Henceforth the source version will match the shared-library major * and minor numbers; the shared-library major version number will be @@ -181,7 +190,7 @@ * to the source version x.y.z (leading zeros in y and z). Beta versions * were given the previous public release number plus a letter, until * version 1.0.6j; from then on they were given the upcoming public - * release number plus "betaNN" or "rcN". + * release number plus "betaNN" or "rcNN". * * Binary incompatibility exists only when applications make direct access * to the info_ptr or png_ptr members through png.h, and the compiled @@ -203,7 +212,7 @@ * * This code is released under the libpng license. * - * libpng versions 1.2.6, August 15, 2004, through 1.5.9, February 18, 2012, are + * libpng versions 1.2.6, August 15, 2004, through 1.5.13, September 27, 2012, are * Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are * distributed according to the same disclaimer and license as libpng-1.2.5 * with the following individual added to the list of Contributing Authors: @@ -315,13 +324,13 @@ * Y2K compliance in libpng: * ========================= * - * February 18, 2012 + * September 27, 2012 * * Since the PNG Development group is an ad-hoc body, we can't make * an official declaration. * * This is your unofficial assurance that libpng from version 0.71 and - * upward through 1.5.9 are Y2K compliant. It is my belief that + * upward through 1.5.13 are Y2K compliant. It is my belief that * earlier versions were also Y2K compliant. * * Libpng only has two year fields. One is a 2-byte unsigned integer @@ -332,7 +341,8 @@ * "png_uint_16 year" in png_time_struct. * * The string is - * "png_char time_buffer" in png_struct + * "char time_buffer[29]" in png_struct. This will be no + * longer used in libpng-1.6.0 and will be removed from libpng-1.7.0. * * There are seven time-related functions: * png.c: png_convert_to_rfc_1123() in png.c @@ -379,9 +389,9 @@ */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.5.9" +#define PNG_LIBPNG_VER_STRING "1.5.13" #define PNG_HEADER_VERSION_STRING \ - " libpng version 1.5.9 - February 18, 2012\n" + " libpng version 1.5.13 - September 27, 2012\n" #define PNG_LIBPNG_VER_SONUM 15 #define PNG_LIBPNG_VER_DLLNUM 15 @@ -389,7 +399,7 @@ /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ #define PNG_LIBPNG_VER_MAJOR 1 #define PNG_LIBPNG_VER_MINOR 5 -#define PNG_LIBPNG_VER_RELEASE 9 +#define PNG_LIBPNG_VER_RELEASE 13 /* This should match the numeric part of the final component of * PNG_LIBPNG_VER_STRING, omitting any leading zero: @@ -412,7 +422,7 @@ #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with PNG_LIBPNG_BUILD_PRIVATE */ -#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_BETA +#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE /* Careful here. At one time, Guy wanted to use 082, but that would be octal. * We must not include leading zeros. @@ -420,7 +430,7 @@ * version 1.0.0 was mis-numbered 100 instead of 10000). From * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */ -#define PNG_LIBPNG_VER 10509 /* 1.5.9 */ +#define PNG_LIBPNG_VER 10513 /* 1.5.13 */ /* Library configuration: these options cannot be changed after * the library has been built. @@ -542,7 +552,7 @@ extern "C" { /* This triggers a compiler error in png.c, if png.c and png.h * do not agree upon the version number. */ -typedef char* png_libpng_version_1_5_9; +typedef char* png_libpng_version_1_5_13; /* Three color definitions. The order of the red, green, and blue, (and the * exact size) is not important, although the size of the fields need to @@ -1151,9 +1161,9 @@ PNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structp png_ptr)); #define PNG_RGB_TO_GRAY_DEFAULT (-1)/*for red/green coefficients*/ PNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structp png_ptr, - int error_action, double red, double green)); + int error_action, double red, double green)) PNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structp png_ptr, - int error_action, png_fixed_point red, png_fixed_point green)); + int error_action, png_fixed_point red, png_fixed_point green)) PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structp png_ptr)); @@ -1221,9 +1231,9 @@ PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth, #define PNG_ALPHA_BROKEN 3 /* the alpha channel is gamma encoded */ PNG_FP_EXPORT(227, void, png_set_alpha_mode, (png_structp png_ptr, int mode, - double output_gamma)); + double output_gamma)) PNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structp png_ptr, - int mode, png_fixed_point output_gamma)); + int mode, png_fixed_point output_gamma)) #endif #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED) @@ -1446,10 +1456,10 @@ PNG_EXPORT(46, void, png_set_invert_mono, (png_structp png_ptr)); */ PNG_FP_EXPORT(47, void, png_set_background, (png_structp png_ptr, png_const_color_16p background_color, int background_gamma_code, - int need_expand, double background_gamma)); + int need_expand, double background_gamma)) PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structp png_ptr, png_const_color_16p background_color, int background_gamma_code, - int need_expand, png_fixed_point background_gamma)); + int need_expand, png_fixed_point background_gamma)) #endif #ifdef PNG_READ_BACKGROUND_SUPPORTED # define PNG_BACKGROUND_GAMMA_UNKNOWN 0 @@ -1498,9 +1508,9 @@ PNG_EXPORT(49, void, png_set_quantize, */ PNG_FP_EXPORT(50, void, png_set_gamma, (png_structp png_ptr, double screen_gamma, - double override_file_gamma)); + double override_file_gamma)) PNG_FIXED_EXPORT(208, void, png_set_gamma_fixed, (png_structp png_ptr, - png_fixed_point screen_gamma, png_fixed_point override_file_gamma)); + png_fixed_point screen_gamma, png_fixed_point override_file_gamma)) #endif #ifdef PNG_WRITE_FLUSH_SUPPORTED @@ -1660,11 +1670,11 @@ PNG_EXPORT(67, void, png_set_filter, */ PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structp png_ptr, int heuristic_method, int num_weights, png_const_doublep filter_weights, - png_const_doublep filter_costs)); + png_const_doublep filter_costs)) PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed, (png_structp png_ptr, int heuristic_method, int num_weights, png_const_fixed_point_p - filter_weights, png_const_fixed_point_p filter_costs)); + filter_weights, png_const_fixed_point_p filter_costs)) #endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ /* Heuristic used for row filter selection. These defines should NOT be @@ -2046,9 +2056,9 @@ PNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter, /* Returns pixel aspect ratio, computed from pHYs chunk data. */ PNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio, - (png_const_structp png_ptr, png_const_infop info_ptr)); + (png_const_structp png_ptr, png_const_infop info_ptr)) PNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed, - (png_const_structp png_ptr, png_const_infop info_ptr)); + (png_const_structp png_ptr, png_const_infop info_ptr)) /* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ PNG_EXPORT(126, png_int_32, png_get_x_offset_pixels, @@ -2081,11 +2091,11 @@ PNG_EXPORT(132, void, png_set_bKGD, (png_structp png_ptr, png_infop info_ptr, PNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structp png_ptr, png_const_infop info_ptr, double *white_x, double *white_y, double *red_x, double *red_y, double *green_x, double *green_y, double *blue_x, - double *blue_y)); + double *blue_y)) PNG_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_structp png_ptr, png_const_infop info_ptr, double *red_X, double *red_Y, double *red_Z, double *green_X, double *green_Y, double *green_Z, double *blue_X, - double *blue_Y, double *blue_Z)); + double *blue_Y, double *blue_Z)) #ifdef PNG_FIXED_POINT_SUPPORTED /* Otherwise not implemented */ PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed, (png_const_structp png_ptr, @@ -2093,7 +2103,7 @@ PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed, png_fixed_point *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y, png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point *int_blue_x, - png_fixed_point *int_blue_y)); + png_fixed_point *int_blue_y)) #endif PNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed, (png_structp png_ptr, png_const_infop info_ptr, @@ -2101,46 +2111,46 @@ PNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed, png_fixed_point *int_red_Z, png_fixed_point *int_green_X, png_fixed_point *int_green_Y, png_fixed_point *int_green_Z, png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y, - png_fixed_point *int_blue_Z)); + png_fixed_point *int_blue_Z)) #endif #ifdef PNG_cHRM_SUPPORTED PNG_FP_EXPORT(135, void, png_set_cHRM, (png_structp png_ptr, png_infop info_ptr, double white_x, double white_y, double red_x, double red_y, double green_x, - double green_y, double blue_x, double blue_y)); + double green_y, double blue_x, double blue_y)) PNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_structp png_ptr, png_infop info_ptr, double red_X, double red_Y, double red_Z, double green_X, double green_Y, double green_Z, double blue_X, - double blue_Y, double blue_Z)); + double blue_Y, double blue_Z)) PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_structp png_ptr, png_infop info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y, png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, - png_fixed_point int_blue_y)); + png_fixed_point int_blue_y)) PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_structp png_ptr, png_infop info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y, png_fixed_point int_red_Z, png_fixed_point int_green_X, png_fixed_point int_green_Y, png_fixed_point int_green_Z, png_fixed_point int_blue_X, png_fixed_point int_blue_Y, - png_fixed_point int_blue_Z)); + png_fixed_point int_blue_Z)) #endif #ifdef PNG_gAMA_SUPPORTED PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, (png_const_structp png_ptr, png_const_infop info_ptr, - double *file_gamma)); + double *file_gamma)) PNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed, (png_const_structp png_ptr, png_const_infop info_ptr, - png_fixed_point *int_file_gamma)); + png_fixed_point *int_file_gamma)) #endif #ifdef PNG_gAMA_SUPPORTED PNG_FP_EXPORT(139, void, png_set_gAMA, (png_structp png_ptr, - png_infop info_ptr, double file_gamma)); + png_infop info_ptr, double file_gamma)) PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_structp png_ptr, - png_infop info_ptr, png_fixed_point int_file_gamma)); + png_infop info_ptr, png_fixed_point int_file_gamma)) #endif #ifdef PNG_hIST_SUPPORTED @@ -2306,7 +2316,7 @@ PNG_EXPORT(167, void, png_set_tRNS, #ifdef PNG_sCAL_SUPPORTED PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structp png_ptr, png_const_infop info_ptr, - int *unit, double *width, double *height)); + int *unit, double *width, double *height)) #ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED /* NOTE: this API is currently implemented using floating point arithmetic, * consequently it can only be used on systems with floating point support. @@ -2316,7 +2326,7 @@ PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, PNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed, (png_structp png_ptr, png_const_infop info_ptr, int *unit, png_fixed_point *width, - png_fixed_point *height)); + png_fixed_point *height)) #endif PNG_EXPORT(169, png_uint_32, png_get_sCAL_s, (png_const_structp png_ptr, png_const_infop info_ptr, @@ -2324,10 +2334,10 @@ PNG_EXPORT(169, png_uint_32, png_get_sCAL_s, PNG_FP_EXPORT(170, void, png_set_sCAL, (png_structp png_ptr, png_infop info_ptr, - int unit, double width, double height)); + int unit, double width, double height)) PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_structp png_ptr, png_infop info_ptr, int unit, png_fixed_point width, - png_fixed_point height)); + png_fixed_point height)) PNG_EXPORT(171, void, png_set_sCAL_s, (png_structp png_ptr, png_infop info_ptr, int unit, png_const_charp swidth, png_const_charp sheight)); @@ -2440,17 +2450,17 @@ PNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch, (png_const_structp png_ptr, png_const_infop info_ptr)); PNG_FP_EXPORT(196, float, png_get_x_offset_inches, - (png_const_structp png_ptr, png_const_infop info_ptr)); + (png_const_structp png_ptr, png_const_infop info_ptr)) #ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ PNG_FIXED_EXPORT(211, png_fixed_point, png_get_x_offset_inches_fixed, - (png_structp png_ptr, png_const_infop info_ptr)); + (png_structp png_ptr, png_const_infop info_ptr)) #endif PNG_FP_EXPORT(197, float, png_get_y_offset_inches, (png_const_structp png_ptr, - png_const_infop info_ptr)); + png_const_infop info_ptr)) #ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ PNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed, - (png_structp png_ptr, png_const_infop info_ptr)); + (png_structp png_ptr, png_const_infop info_ptr)) #endif # ifdef PNG_pHYs_SUPPORTED @@ -2637,6 +2647,12 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i)); : (png_int_32)png_get_uint_32(buf))) #endif +#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \ + defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED) +PNG_EXPORT(234, void, png_set_check_for_invalid_index, (png_structp png_ptr, + int allowed)); +#endif + /* Maintainer: Put new public prototypes here ^, in libpng.3, and project * defs */ @@ -2646,7 +2662,7 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i)); * scripts/symbols.def as well. */ #ifdef PNG_EXPORT_LAST_ORDINAL - PNG_EXPORT_LAST_ORDINAL(233); + PNG_EXPORT_LAST_ORDINAL(234); #endif #ifdef __cplusplus diff --git a/plugins/AdvaImg/src/LibPNG/pngconf.h b/plugins/AdvaImg/src/LibPNG/pngconf.h index 121d204ccd..5298e667a8 100644 --- a/plugins/AdvaImg/src/LibPNG/pngconf.h +++ b/plugins/AdvaImg/src/LibPNG/pngconf.h @@ -1,7 +1,7 @@ /* pngconf.h - machine configurable file for libpng * - * libpng version 1.5.9 - February 18, 2012 + * libpng version 1.5.13 - September 27, 2012 * * Copyright (c) 1998-2012 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -25,7 +25,7 @@ #ifndef PNG_BUILDING_SYMBOL_TABLE /* PNG_NO_LIMITS_H may be used to turn off the use of the standard C * definition file for machine specific limits, this may impact the - * correctness of the definitons below (see uses of INT_MAX). + * correctness of the definitions below (see uses of INT_MAX). */ # ifndef PNG_NO_LIMITS_H # include @@ -51,8 +51,8 @@ /* This controls optimization of the reading of 16 and 32 bit values * from PNG files. It can be set on a per-app-file basis - it - * just changes whether a macro is used to the function is called. - * The library builder sets the default, if read functions are not + * just changes whether a macro is used when the function is called. + * The library builder sets the default; if read functions are not * built into the library the macro implementation is forced on. */ #ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED @@ -182,9 +182,9 @@ * conventions of the various functions. */ #if ( defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\ - defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)) &&\ + defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) ) &&\ ( defined(_X86_) || defined(_X64_) || defined(_M_IX86) ||\ - defined(_M_X64) || defined(_M_IA64)) + defined(_M_X64) || defined(_M_IA64) ) /* Windows system (DOS doesn't support DLLs) running on x86/x64. Includes * builds under Cygwin or MinGW. Also includes Watcom builds but these need * special treatment because they are not compatible with GCC or Visual C @@ -344,21 +344,23 @@ # ifndef PNG_NORETURN # define PNG_NORETURN __attribute__((__noreturn__)) # endif -# ifndef PNG_ALLOCATED -# define PNG_ALLOCATED __attribute__((__malloc__)) -# endif -# ifndef PNG_DEPRECATED -# define PNG_DEPRECATED __attribute__((__deprecated__)) -# endif -# ifndef PNG_PRIVATE -# if 0 /* Doesn't work so we use deprecated instead*/ -# define PNG_PRIVATE \ - __attribute__((warning("This function is not exported by libpng."))) -# else -# define PNG_PRIVATE \ - __attribute__((__deprecated__)) +# if __GNUC__ >= 3 +# ifndef PNG_ALLOCATED +# define PNG_ALLOCATED __attribute__((__malloc__)) # endif -# endif +# ifndef PNG_DEPRECATED +# define PNG_DEPRECATED __attribute__((__deprecated__)) +# endif +# ifndef PNG_PRIVATE +# if 0 /* Doesn't work so we use deprecated instead*/ +# define PNG_PRIVATE \ + __attribute__((warning("This function is not exported by libpng."))) +# else +# define PNG_PRIVATE \ + __attribute__((__deprecated__)) +# endif +# endif +# endif /* __GNUC__ >= 3 */ # endif /* __GNUC__ */ # if defined(_MSC_VER) && (_MSC_VER >= 1300) @@ -400,7 +402,7 @@ #ifndef PNG_FP_EXPORT /* A floating point API. */ # ifdef PNG_FLOATING_POINT_SUPPORTED # define PNG_FP_EXPORT(ordinal, type, name, args)\ - PNG_EXPORT(ordinal, type, name, args) + PNG_EXPORT(ordinal, type, name, args); # else /* No floating point APIs */ # define PNG_FP_EXPORT(ordinal, type, name, args) # endif @@ -408,7 +410,7 @@ #ifndef PNG_FIXED_EXPORT /* A fixed point API. */ # ifdef PNG_FIXED_POINT_SUPPORTED # define PNG_FIXED_EXPORT(ordinal, type, name, args)\ - PNG_EXPORT(ordinal, type, name, args) + PNG_EXPORT(ordinal, type, name, args); # else /* No fixed point APIs */ # define PNG_FIXED_EXPORT(ordinal, type, name, args) # endif diff --git a/plugins/AdvaImg/src/LibPNG/pngerror.c b/plugins/AdvaImg/src/LibPNG/pngerror.c index 9df97f583c..ef60d553fd 100644 --- a/plugins/AdvaImg/src/LibPNG/pngerror.c +++ b/plugins/AdvaImg/src/LibPNG/pngerror.c @@ -2,7 +2,7 @@ /* pngerror.c - stub functions for i/o and memory allocation * * Last changed in libpng 1.5.8 [February 1, 2011] - * Copyright (c) 1998-2012 Glenn Randers-Pehrson + * Copyright (c) 1998-2011 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * diff --git a/plugins/AdvaImg/src/LibPNG/pngmem.c b/plugins/AdvaImg/src/LibPNG/pngmem.c index 25b5c73546..3099246cba 100644 --- a/plugins/AdvaImg/src/LibPNG/pngmem.c +++ b/plugins/AdvaImg/src/LibPNG/pngmem.c @@ -1,8 +1,8 @@ /* pngmem.c - stub functions for memory allocation * - * Last changed in libpng 1.5.7 [December 15, 2011] - * Copyright (c) 1998-2011 Glenn Randers-Pehrson + * Last changed in libpng 1.5.13 [September 27, 2012] + * Copyright (c) 1998-2012 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -56,7 +56,7 @@ png_create_struct_2,(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr), if (malloc_fn != NULL) { png_struct dummy_struct; - memset(&dummy_struct, 0, sizeof dummy_struct); + png_memset(&dummy_struct, 0, sizeof dummy_struct); dummy_struct.mem_ptr=mem_ptr; struct_ptr = (*(malloc_fn))(&dummy_struct, (png_alloc_size_t)size); } @@ -90,7 +90,7 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, if (free_fn != NULL) { png_struct dummy_struct; - memset(&dummy_struct, 0, sizeof dummy_struct); + png_memset(&dummy_struct, 0, sizeof dummy_struct); dummy_struct.mem_ptr=mem_ptr; (*(free_fn))(&dummy_struct, struct_ptr); return; diff --git a/plugins/AdvaImg/src/LibPNG/pngpread.c b/plugins/AdvaImg/src/LibPNG/pngpread.c index eda5a6c80f..39f8f6fa9d 100644 --- a/plugins/AdvaImg/src/LibPNG/pngpread.c +++ b/plugins/AdvaImg/src/LibPNG/pngpread.c @@ -1,8 +1,8 @@ /* pngpread.c - read a png file in push mode * - * Last changed in libpng 1.5.9 [February 18, 2012] - * Copyright (c) 1998-2011 Glenn Randers-Pehrson + * Last changed in libpng 1.5.11 [June 14, 2012] + * Copyright (c) 1998-2012 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -128,30 +128,6 @@ png_process_some_data(png_structp png_ptr, png_infop info_ptr) break; } -#ifdef PNG_READ_tEXt_SUPPORTED - case PNG_READ_tEXt_MODE: - { - png_push_read_tEXt(png_ptr, info_ptr); - break; - } - -#endif -#ifdef PNG_READ_zTXt_SUPPORTED - case PNG_READ_zTXt_MODE: - { - png_push_read_zTXt(png_ptr, info_ptr); - break; - } - -#endif -#ifdef PNG_READ_iTXt_SUPPORTED - case PNG_READ_iTXt_MODE: - { - png_push_read_iTXt(png_ptr, info_ptr); - break; - } - -#endif case PNG_SKIP_MODE: { png_push_crc_finish(png_ptr); @@ -176,7 +152,7 @@ void /* PRIVATE */ png_push_read_sig(png_structp png_ptr, png_infop info_ptr) { png_size_t num_checked = png_ptr->sig_bytes, - num_to_check = 8 - num_checked; + num_to_check = 8 - num_checked; if (png_ptr->buffer_size < num_to_check) { @@ -196,6 +172,7 @@ png_push_read_sig(png_structp png_ptr, png_infop info_ptr) else png_error(png_ptr, "PNG file corrupted by ASCII conversion"); } + else { if (png_ptr->sig_bytes >= 8) @@ -305,8 +282,8 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_error(png_ptr, "Missing PLTE before IDAT"); } } - #endif + else if (chunk_name == png_PLTE) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) @@ -543,7 +520,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) return; } - png_push_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length); + png_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length); } #endif @@ -556,7 +533,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) return; } - png_push_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length); + png_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length); } #endif @@ -569,10 +546,11 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) return; } - png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length); + png_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length); } #endif + else { if (png_ptr->push_length + 4 > png_ptr->buffer_size) @@ -580,7 +558,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_push_save_buffer(png_ptr); return; } - png_push_handle_unknown(png_ptr, info_ptr, png_ptr->push_length); + png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length); } png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; @@ -620,6 +598,7 @@ png_push_crc_finish(png_structp png_ptr) png_ptr->save_buffer_size -= save_size; png_ptr->save_buffer_ptr += save_size; } + if (png_ptr->skip_length && png_ptr->current_buffer_size) { png_size_t save_size = png_ptr->current_buffer_size; @@ -641,6 +620,7 @@ png_push_crc_finish(png_structp png_ptr) png_ptr->current_buffer_size -= save_size; png_ptr->current_buffer_ptr += save_size; } + if (!png_ptr->skip_length) { if (png_ptr->buffer_size < 4) @@ -663,6 +643,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) return; ptr = buffer; + if (png_ptr->save_buffer_size) { png_size_t save_size; @@ -680,6 +661,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) png_ptr->save_buffer_size -= save_size; png_ptr->save_buffer_ptr += save_size; } + if (length && png_ptr->current_buffer_size) { png_size_t save_size; @@ -709,6 +691,7 @@ png_push_save_buffer(png_structp png_ptr) png_bytep dp; istop = png_ptr->save_buffer_size; + for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer; i < istop; i++, sp++, dp++) { @@ -716,6 +699,7 @@ png_push_save_buffer(png_structp png_ptr) } } } + if (png_ptr->save_buffer_size + png_ptr->current_buffer_size > png_ptr->save_buffer_max) { @@ -742,6 +726,7 @@ png_push_save_buffer(png_structp png_ptr) png_free(png_ptr, old_buffer); png_ptr->save_buffer_max = new_max; } + if (png_ptr->current_buffer_size) { png_memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size, @@ -749,6 +734,7 @@ png_push_save_buffer(png_structp png_ptr) png_ptr->save_buffer_size += png_ptr->current_buffer_size; png_ptr->current_buffer_size = 0; } + png_ptr->save_buffer_ptr = png_ptr->save_buffer; png_ptr->buffer_size = 0; } @@ -850,6 +836,7 @@ png_push_read_IDAT(png_structp png_ptr) png_ptr->current_buffer_size -= save_size; png_ptr->current_buffer_ptr += save_size; } + if (!png_ptr->idat_size) { if (png_ptr->buffer_size < 4) @@ -1263,521 +1250,6 @@ png_read_push_finish_row(png_structp png_ptr) #endif /* PNG_READ_INTERLACING_SUPPORTED */ } -#ifdef PNG_READ_tEXt_SUPPORTED -void /* PRIVATE */ -png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) - { - PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */ - png_error(png_ptr, "Out of place tEXt"); - /* NOT REACHED */ - } - -#ifdef PNG_MAX_MALLOC_64K - png_ptr->skip_length = 0; /* This may not be necessary */ - - if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */ - { - png_warning(png_ptr, "tEXt chunk too large to fit in memory"); - png_ptr->skip_length = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - png_ptr->current_text = (png_charp)png_malloc(png_ptr, length + 1); - png_ptr->current_text[length] = '\0'; - png_ptr->current_text_ptr = png_ptr->current_text; - png_ptr->current_text_size = (png_size_t)length; - png_ptr->current_text_left = (png_size_t)length; - png_ptr->process_mode = PNG_READ_tEXt_MODE; -} - -void /* PRIVATE */ -png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr->buffer_size && png_ptr->current_text_left) - { - png_size_t text_size; - - if (png_ptr->buffer_size < png_ptr->current_text_left) - text_size = png_ptr->buffer_size; - - else - text_size = png_ptr->current_text_left; - - png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); - png_ptr->current_text_left -= text_size; - png_ptr->current_text_ptr += text_size; - } - if (!(png_ptr->current_text_left)) - { - png_textp text_ptr; - png_charp text; - png_charp key; - int ret; - - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_crc_finish(png_ptr); - -#ifdef PNG_MAX_MALLOC_64K - if (png_ptr->skip_length) - return; -#endif - - key = png_ptr->current_text; - - for (text = key; *text; text++) - /* Empty loop */ ; - - if (text < key + png_ptr->current_text_size) - text++; - - text_ptr = (png_textp)png_malloc(png_ptr, png_sizeof(png_text)); - text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; - text_ptr->key = key; - text_ptr->itxt_length = 0; - text_ptr->lang = NULL; - text_ptr->lang_key = NULL; - text_ptr->text = text; - - ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, key); - png_free(png_ptr, text_ptr); - png_ptr->current_text = NULL; - - if (ret) - png_warning(png_ptr, "Insufficient memory to store text chunk"); - } -} -#endif - -#ifdef PNG_READ_zTXt_SUPPORTED -void /* PRIVATE */ -png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) - { - PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */ - png_error(png_ptr, "Out of place zTXt"); - /* NOT REACHED */ - } - -#ifdef PNG_MAX_MALLOC_64K - /* We can't handle zTXt chunks > 64K, since we don't have enough space - * to be able to store the uncompressed data. Actually, the threshold - * is probably around 32K, but it isn't as definite as 64K is. - */ - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "zTXt chunk too large to fit in memory"); - png_push_crc_skip(png_ptr, length); - return; - } -#endif - - png_ptr->current_text = (png_charp)png_malloc(png_ptr, length + 1); - png_ptr->current_text[length] = '\0'; - png_ptr->current_text_ptr = png_ptr->current_text; - png_ptr->current_text_size = (png_size_t)length; - png_ptr->current_text_left = (png_size_t)length; - png_ptr->process_mode = PNG_READ_zTXt_MODE; -} - -void /* PRIVATE */ -png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr->buffer_size && png_ptr->current_text_left) - { - png_size_t text_size; - - if (png_ptr->buffer_size < (png_uint_32)png_ptr->current_text_left) - text_size = png_ptr->buffer_size; - - else - text_size = png_ptr->current_text_left; - - png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); - png_ptr->current_text_left -= text_size; - png_ptr->current_text_ptr += text_size; - } - if (!(png_ptr->current_text_left)) - { - png_textp text_ptr; - png_charp text; - png_charp key; - int ret; - png_size_t text_size, key_size; - - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_crc_finish(png_ptr); - - key = png_ptr->current_text; - - for (text = key; *text; text++) - /* Empty loop */ ; - - /* zTXt can't have zero text */ - if (text >= key + png_ptr->current_text_size) - { - png_ptr->current_text = NULL; - png_free(png_ptr, key); - return; - } - - text++; - - if (*text != PNG_TEXT_COMPRESSION_zTXt) /* Check compression byte */ - { - png_ptr->current_text = NULL; - png_free(png_ptr, key); - return; - } - - text++; - - png_ptr->zstream.next_in = (png_bytep)text; - png_ptr->zstream.avail_in = (uInt)(png_ptr->current_text_size - - (text - key)); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - key_size = text - key; - text_size = 0; - text = NULL; - ret = Z_STREAM_END; - - while (png_ptr->zstream.avail_in) - { - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret != Z_OK && ret != Z_STREAM_END) - { - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; - png_ptr->current_text = NULL; - png_free(png_ptr, key); - png_free(png_ptr, text); - return; - } - - if (!(png_ptr->zstream.avail_out) || ret == Z_STREAM_END) - { - if (text == NULL) - { - text = (png_charp)png_malloc(png_ptr, - (png_ptr->zbuf_size - - png_ptr->zstream.avail_out + key_size + 1)); - - png_memcpy(text + key_size, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - - png_memcpy(text, key, key_size); - - text_size = key_size + png_ptr->zbuf_size - - png_ptr->zstream.avail_out; - - *(text + text_size) = '\0'; - } - - else - { - png_charp tmp; - - tmp = text; - text = (png_charp)png_malloc(png_ptr, text_size + - (png_ptr->zbuf_size - - png_ptr->zstream.avail_out + 1)); - - png_memcpy(text, tmp, text_size); - png_free(png_ptr, tmp); - - png_memcpy(text + text_size, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - - text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out; - *(text + text_size) = '\0'; - } - - if (ret != Z_STREAM_END) - { - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - } - else - { - break; - } - - if (ret == Z_STREAM_END) - break; - } - - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; - - if (ret != Z_STREAM_END) - { - png_ptr->current_text = NULL; - png_free(png_ptr, key); - png_free(png_ptr, text); - return; - } - - png_ptr->current_text = NULL; - png_free(png_ptr, key); - key = text; - text += key_size; - - text_ptr = (png_textp)png_malloc(png_ptr, - png_sizeof(png_text)); - text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt; - text_ptr->key = key; - text_ptr->itxt_length = 0; - text_ptr->lang = NULL; - text_ptr->lang_key = NULL; - text_ptr->text = text; - - ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, key); - png_free(png_ptr, text_ptr); - - if (ret) - png_warning(png_ptr, "Insufficient memory to store text chunk"); - } -} -#endif - -#ifdef PNG_READ_iTXt_SUPPORTED -void /* PRIVATE */ -png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) - { - PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */ - png_error(png_ptr, "Out of place iTXt"); - /* NOT REACHED */ - } - -#ifdef PNG_MAX_MALLOC_64K - png_ptr->skip_length = 0; /* This may not be necessary */ - - if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */ - { - png_warning(png_ptr, "iTXt chunk too large to fit in memory"); - png_ptr->skip_length = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - png_ptr->current_text = (png_charp)png_malloc(png_ptr, length + 1); - png_ptr->current_text[length] = '\0'; - png_ptr->current_text_ptr = png_ptr->current_text; - png_ptr->current_text_size = (png_size_t)length; - png_ptr->current_text_left = (png_size_t)length; - png_ptr->process_mode = PNG_READ_iTXt_MODE; -} - -void /* PRIVATE */ -png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr) -{ - - if (png_ptr->buffer_size && png_ptr->current_text_left) - { - png_size_t text_size; - - if (png_ptr->buffer_size < png_ptr->current_text_left) - text_size = png_ptr->buffer_size; - - else - text_size = png_ptr->current_text_left; - - png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); - png_ptr->current_text_left -= text_size; - png_ptr->current_text_ptr += text_size; - } - - if (!(png_ptr->current_text_left)) - { - png_textp text_ptr; - png_charp key; - int comp_flag; - png_charp lang; - png_charp lang_key; - png_charp text; - int ret; - - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_crc_finish(png_ptr); - -#ifdef PNG_MAX_MALLOC_64K - if (png_ptr->skip_length) - return; -#endif - - key = png_ptr->current_text; - - for (lang = key; *lang; lang++) - /* Empty loop */ ; - - if (lang < key + png_ptr->current_text_size - 3) - lang++; - - comp_flag = *lang++; - lang++; /* Skip comp_type, always zero */ - - for (lang_key = lang; *lang_key; lang_key++) - /* Empty loop */ ; - - lang_key++; /* Skip NUL separator */ - - text=lang_key; - - if (lang_key < key + png_ptr->current_text_size - 1) - { - for (; *text; text++) - /* Empty loop */ ; - } - - if (text < key + png_ptr->current_text_size) - text++; - - text_ptr = (png_textp)png_malloc(png_ptr, - png_sizeof(png_text)); - - text_ptr->compression = comp_flag + 2; - text_ptr->key = key; - text_ptr->lang = lang; - text_ptr->lang_key = lang_key; - text_ptr->text = text; - text_ptr->text_length = 0; - text_ptr->itxt_length = png_strlen(text); - - ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_ptr->current_text = NULL; - - png_free(png_ptr, text_ptr); - if (ret) - png_warning(png_ptr, "Insufficient memory to store iTXt chunk"); - } -} -#endif - -/* This function is called when we haven't found a handler for this - * chunk. If there isn't a problem with the chunk itself (ie a bad chunk - * name or a critical chunk), the chunk is (currently) silently ignored. - */ -void /* PRIVATE */ -png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - png_uint_32 skip = 0; - png_uint_32 chunk_name = png_ptr->chunk_name; - - if (PNG_CHUNK_CRITICAL(chunk_name)) - { -#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED - if (png_chunk_unknown_handling(png_ptr, chunk_name) != - PNG_HANDLE_CHUNK_ALWAYS -#ifdef PNG_READ_USER_CHUNKS_SUPPORTED - && png_ptr->read_user_chunk_fn == NULL -#endif - ) -#endif - png_chunk_error(png_ptr, "unknown critical chunk"); - - PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */ - } - -#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED - /* TODO: the code below is apparently just using the - * png_struct::unknown_chunk member as a temporarily variable, it should be - * possible to eliminate both it and the temporary buffer. - */ - if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) - { -#ifdef PNG_MAX_MALLOC_64K - if (length > 65535) - { - png_warning(png_ptr, "unknown chunk too large to fit in memory"); - skip = length - 65535; - length = 65535; - } -#endif - /* This is just a record for the user; libpng doesn't use the character - * form of the name. - */ - PNG_CSTRING_FROM_CHUNK(png_ptr->unknown_chunk.name, png_ptr->chunk_name); - - png_ptr->unknown_chunk.size = length; - - if (length == 0) - png_ptr->unknown_chunk.data = NULL; - - else - { - png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, - png_ptr->unknown_chunk.size); - png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, - png_ptr->unknown_chunk.size); - } - -#ifdef PNG_READ_USER_CHUNKS_SUPPORTED - if (png_ptr->read_user_chunk_fn != NULL) - { - /* Callback to user unknown chunk handler */ - int ret; - ret = (*(png_ptr->read_user_chunk_fn)) - (png_ptr, &png_ptr->unknown_chunk); - - if (ret < 0) - png_chunk_error(png_ptr, "error in user chunk"); - - if (ret == 0) - { - if (PNG_CHUNK_CRITICAL(png_ptr->chunk_name)) - if (png_chunk_unknown_handling(png_ptr, chunk_name) != - PNG_HANDLE_CHUNK_ALWAYS) - png_chunk_error(png_ptr, "unknown critical chunk"); - png_set_unknown_chunks(png_ptr, info_ptr, - &png_ptr->unknown_chunk, 1); - } - } - - else -#endif - png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1); - png_free(png_ptr, png_ptr->unknown_chunk.data); - png_ptr->unknown_chunk.data = NULL; - } - - else -#endif - skip=length; - png_push_crc_skip(png_ptr, skip); -} - void /* PRIVATE */ png_push_have_info(png_structp png_ptr, png_infop info_ptr) { diff --git a/plugins/AdvaImg/src/LibPNG/pngpriv.h b/plugins/AdvaImg/src/LibPNG/pngpriv.h index 02cc5d8c53..3863f1f5cf 100644 --- a/plugins/AdvaImg/src/LibPNG/pngpriv.h +++ b/plugins/AdvaImg/src/LibPNG/pngpriv.h @@ -2,11 +2,11 @@ /* pngpriv.h - private declarations for use inside libpng * * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2011 Glenn Randers-Pehrson + * Copyright (c) 1998-2012 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * - * Last changed in libpng 1.5.7 [December 15, 2011] + * Last changed in libpng 1.5.10 [March 29, 2012] * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer @@ -133,6 +133,46 @@ # define PNG_DLL_EXPORT #endif +/* SECURITY and SAFETY: + * + * By default libpng is built without any internal limits on image size, + * individual heap (png_malloc) allocations or the total amount of memory used. + * If PNG_SAFE_LIMITS_SUPPORTED is defined, however, the limits below are used + * (unless individually overridden). These limits are believed to be fairly + * safe, but builders of secure systems should verify the values against the + * real system capabilities. + */ + +#ifdef PNG_SAFE_LIMITS_SUPPORTED + /* 'safe' limits */ +# ifndef PNG_USER_WIDTH_MAX +# define PNG_USER_WIDTH_MAX 1000000 +# endif +# ifndef PNG_USER_HEIGHT_MAX +# define PNG_USER_HEIGHT_MAX 1000000 +# endif +# ifndef PNG_USER_CHUNK_CACHE_MAX +# define PNG_USER_CHUNK_CACHE_MAX 128 +# endif +# ifndef PNG_USER_CHUNK_MALLOC_MAX +# define PNG_USER_CHUNK_MALLOC_MAX 8000000 +# endif +#else + /* values for no limits */ +# ifndef PNG_USER_WIDTH_MAX +# define PNG_USER_WIDTH_MAX 0x7fffffff +# endif +# ifndef PNG_USER_HEIGHT_MAX +# define PNG_USER_HEIGHT_MAX 0x7fffffff +# endif +# ifndef PNG_USER_CHUNK_CACHE_MAX +# define PNG_USER_CHUNK_CACHE_MAX 0 +# endif +# ifndef PNG_USER_CHUNK_MALLOC_MAX +# define PNG_USER_CHUNK_MALLOC_MAX 0 +# endif +#endif + /* This is used for 16 bit gamma tables - only the top level pointers are const, * this could be changed: */ @@ -426,6 +466,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp; #define PNG_BACKGROUND_IS_GRAY 0x800 #define PNG_HAVE_PNG_SIGNATURE 0x1000 #define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */ +#define PNG_HAVE_iCCP 0x4000 /* Flags for the transformations the PNG library does on the image data */ #define PNG_BGR 0x0001 @@ -532,7 +573,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp; #define PNG_ROWBYTES(pixel_bits, width) \ ((pixel_bits) >= 8 ? \ ((png_size_t)(width) * (((png_size_t)(pixel_bits)) >> 3)) : \ - (( ((png_size_t)(width) * ((png_size_t)(pixel_bits))) + 7) >> 3)) + (( ((png_size_t)(width) * ((png_size_t)(pixel_bits))) + 7) >> 3) ) /* PNG_OUT_OF_RANGE returns true if value is outside the range * ideal-delta..ideal+delta. Each argument is evaluated twice. @@ -540,7 +581,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp; * integers, "value" a variable. Added to libpng-1.2.6 JB */ #define PNG_OUT_OF_RANGE(value, ideal, delta) \ - ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta)) + ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) ) /* Conversions between fixed and floating point, only defined if * required (to make sure the code doesn't accidentally use float @@ -952,8 +993,8 @@ PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info, /* Unfilter a row: check the filter value before calling this, there is no point * calling it for PNG_FILTER_VALUE_NONE. */ -PNG_EXTERN void png_read_filter_row PNGARG((png_structp pp, png_row_infop row_info, - png_bytep row, png_const_bytep prev_row, int filter)); +PNG_EXTERN void png_read_filter_row PNGARG((png_structp pp, png_row_infop + row_info, png_bytep row, png_const_bytep prev_row, int filter)); PNG_EXTERN void png_read_filter_row_up_neon PNGARG((png_row_infop row_info, png_bytep row, png_const_bytep prev_row)); @@ -1218,10 +1259,8 @@ PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); #endif -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); -#endif PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr, png_uint_32 chunk_name)); @@ -1355,6 +1394,13 @@ PNG_EXTERN void png_check_IHDR PNGARG((png_structp png_ptr, int color_type, int interlace_type, int compression_type, int filter_type)); +/* Added at libpng version 1.5.10 */ +#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \ + defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED) +PNG_EXTERN void png_do_check_palette_indexes PNGARG((png_structp png_ptr, + png_row_infop row_info)); +#endif + /* Free all memory used by the read (old method - NOT DLL EXPORTED) */ PNG_EXTERN void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr)); @@ -1536,7 +1582,7 @@ PNG_EXTERN void png_ascii_from_fixed PNGARG((png_structp png_ptr, #define PNG_FP_IS_ZERO(state) (((state) & PNG_FP_Z_MASK) == PNG_FP_SAW_DIGIT) #define PNG_FP_IS_POSITIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_Z_MASK) #define PNG_FP_IS_NEGATIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_NZ_MASK) - + /* The actual parser. This can be called repeatedly, it updates * the index into the string and the state variable (which must * be initialzed to 0). It returns a result code, as above. There diff --git a/plugins/AdvaImg/src/LibPNG/pngread.c b/plugins/AdvaImg/src/LibPNG/pngread.c index e2641d540f..96a2a56673 100644 --- a/plugins/AdvaImg/src/LibPNG/pngread.c +++ b/plugins/AdvaImg/src/LibPNG/pngread.c @@ -1,8 +1,8 @@ /* pngread.c - read a PNG file * - * Last changed in libpng 1.5.7 [December 15, 2011] - * Copyright (c) 1998-2011 Glenn Randers-Pehrson + * Last changed in libpng 1.5.10 [March 8, 2012] + * Copyright (c) 1998-2012 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -67,15 +67,11 @@ png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr, png_ptr->user_width_max = PNG_USER_WIDTH_MAX; png_ptr->user_height_max = PNG_USER_HEIGHT_MAX; -# ifdef PNG_USER_CHUNK_CACHE_MAX /* Added at libpng-1.2.43 and 1.4.0 */ png_ptr->user_chunk_cache_max = PNG_USER_CHUNK_CACHE_MAX; -# endif -# ifdef PNG_SET_USER_CHUNK_MALLOC_MAX /* Added at libpng-1.2.43 and 1.4.1 */ png_ptr->user_chunk_malloc_max = PNG_USER_CHUNK_MALLOC_MAX; -# endif #endif #ifdef PNG_SETJMP_SUPPORTED @@ -805,6 +801,13 @@ png_read_end(png_structp png_ptr, png_infop info_ptr) png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */ +#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED + /* Report invalid palette index; added at libng-1.5.10 */ + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && + png_ptr->num_palette_max > png_ptr->num_palette) + png_benign_error(png_ptr, "Read palette index exceeding num_palette"); +#endif + do { png_uint_32 length = png_read_chunk_header(png_ptr); @@ -1070,12 +1073,6 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_free(png_ptr, png_ptr->save_buffer); #endif -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -#ifdef PNG_TEXT_SUPPORTED - png_free(png_ptr, png_ptr->current_text); -#endif /* PNG_TEXT_SUPPORTED */ -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - /* Save the important info out of the png_struct, in case it is * being used again. */ diff --git a/plugins/AdvaImg/src/LibPNG/pngrtran.c b/plugins/AdvaImg/src/LibPNG/pngrtran.c index bbee10ce56..4a4049597b 100644 --- a/plugins/AdvaImg/src/LibPNG/pngrtran.c +++ b/plugins/AdvaImg/src/LibPNG/pngrtran.c @@ -1,8 +1,8 @@ /* pngrtran.c - transforms the data in a row for PNG readers * - * Last changed in libpng 1.5.7 [December 15, 2011] - * Copyright (c) 1998-2011 Glenn Randers-Pehrson + * Last changed in libpng 1.5.11 [June 14, 2012] + * Copyright (c) 1998-2012 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -1770,8 +1770,8 @@ png_init_read_transformations(png_structp png_ptr) int num_palette = png_ptr->num_palette; int i; - /*NOTE: there are other transformations that should probably be in here - * too. + /* NOTE: there are other transformations that should probably be in + * here too. */ for (i = 0; i < num_palette; i++) { @@ -1830,12 +1830,15 @@ png_init_read_transformations(png_structp png_ptr) #ifdef PNG_READ_SHIFT_SUPPORTED if ((png_ptr->transformations & PNG_SHIFT) && + !(png_ptr->transformations & PNG_EXPAND) && (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) { int i; int istop = png_ptr->num_palette; int shift = 8 - png_ptr->sig_bit.red; + png_ptr->transformations &= ~PNG_SHIFT; + /* significant bits can be in the range 1 to 7 for a meaninful result, if * the number of significant bits is 0 then no shift is done (this is an * error condition which is silently ignored.) @@ -2274,7 +2277,7 @@ png_do_read_transformations(png_structp png_ptr, png_row_infop row_info) #endif #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED - /*NOTE: moved here in 1.5.4 (from much later in this list.) */ + /* NOTE: moved here in 1.5.4 (from much later in this list.) */ if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && (png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1); @@ -2296,6 +2299,13 @@ png_do_read_transformations(png_structp png_ptr, png_row_infop row_info) png_do_unpack(row_info, png_ptr->row_buf + 1); #endif +#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED + /* Added at libpng-1.5.10 */ + if (row_info->color_type == PNG_COLOR_TYPE_PALETTE && + png_ptr->num_palette_max >= 0) + png_do_check_palette_indexes(png_ptr, row_info); +#endif + #ifdef PNG_READ_BGR_SUPPORTED if (png_ptr->transformations & PNG_BGR) png_do_bgr(row_info, png_ptr->row_buf + 1); @@ -3293,7 +3303,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) if (red != green || red != blue) { rgb_error |= 1; - /*NOTE: this is the historical approach which simply + /* NOTE: this is the historical approach which simply * truncates the results. */ *(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15); @@ -3695,8 +3705,10 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr) if (v == png_ptr->trans_color.gray) { /* Background is already in screen gamma */ - *sp = (png_byte)((png_ptr->background.gray >> 8) & 0xff); - *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff); + *sp = (png_byte)((png_ptr->background.gray >> 8) + & 0xff); + *(sp + 1) = (png_byte)(png_ptr->background.gray + & 0xff); } else @@ -3719,8 +3731,10 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr) if (v == png_ptr->trans_color.gray) { - *sp = (png_byte)((png_ptr->background.gray >> 8) & 0xff); - *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff); + *sp = (png_byte)((png_ptr->background.gray >> 8) + & 0xff); + *(sp + 1) = (png_byte)(png_ptr->background.gray + & 0xff); } } } @@ -3800,9 +3814,12 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr) /* Background is already in screen gamma */ *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); - *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) & 0xff); - *(sp + 3) = (png_byte)(png_ptr->background.green & 0xff); - *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) & 0xff); + *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) + & 0xff); + *(sp + 3) = (png_byte)(png_ptr->background.green + & 0xff); + *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) + & 0xff); *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); } @@ -3843,9 +3860,12 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr) { *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); - *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) & 0xff); - *(sp + 3) = (png_byte)(png_ptr->background.green & 0xff); - *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) & 0xff); + *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) + & 0xff); + *(sp + 3) = (png_byte)(png_ptr->background.green + & 0xff); + *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) + & 0xff); *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); } } @@ -3928,7 +3948,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr) else if (a == 0) { /* Background is already in screen gamma */ - *sp = (png_byte)((png_ptr->background.gray >> 8) & 0xff); + *sp = (png_byte)((png_ptr->background.gray >> 8) + & 0xff); *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff); } @@ -3958,7 +3979,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr) if (a == 0) { - *sp = (png_byte)((png_ptr->background.gray >> 8) & 0xff); + *sp = (png_byte)((png_ptr->background.gray >> 8) + & 0xff); *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff); } @@ -4088,9 +4110,12 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr) /* Background is already in screen gamma */ *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); - *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) & 0xff); - *(sp + 3) = (png_byte)(png_ptr->background.green & 0xff); - *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) & 0xff); + *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) + & 0xff); + *(sp + 3) = (png_byte)(png_ptr->background.green + & 0xff); + *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) + & 0xff); *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); } @@ -4101,14 +4126,16 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr) v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; png_composite_16(w, v, a, png_ptr->background_1.red); if (!optimize) - w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8]; + w = gamma_16_from_1[((w&0xff) >> gamma_shift)] + [w >> 8]; *sp = (png_byte)((w >> 8) & 0xff); *(sp + 1) = (png_byte)(w & 0xff); v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)]; png_composite_16(w, v, a, png_ptr->background_1.green); if (!optimize) - w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8]; + w = gamma_16_from_1[((w&0xff) >> gamma_shift)] + [w >> 8]; *(sp + 2) = (png_byte)((w >> 8) & 0xff); *(sp + 3) = (png_byte)(w & 0xff); @@ -4116,7 +4143,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr) v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)]; png_composite_16(w, v, a, png_ptr->background_1.blue); if (!optimize) - w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8]; + w = gamma_16_from_1[((w&0xff) >> gamma_shift)] + [w >> 8]; *(sp + 4) = (png_byte)((w >> 8) & 0xff); *(sp + 5) = (png_byte)(w & 0xff); @@ -4137,9 +4165,12 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr) { *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); - *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) & 0xff); - *(sp + 3) = (png_byte)(png_ptr->background.green & 0xff); - *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) & 0xff); + *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) + & 0xff); + *(sp + 3) = (png_byte)(png_ptr->background.green + & 0xff); + *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) + & 0xff); *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); } @@ -4331,7 +4362,7 @@ png_do_gamma(png_row_infop row_info, png_bytep row, png_structp png_ptr) ((((int)gamma_table[a|(a>>2)|(a>>4)|(a>>6)]) ) & 0xc0)| ((((int)gamma_table[(b<<2)|b|(b>>2)|(b>>4)])>>2) & 0x30)| ((((int)gamma_table[(c<<4)|(c<<2)|c|(c>>2)])>>4) & 0x0c)| - ((((int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6))); + ((((int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) )); sp++; } } diff --git a/plugins/AdvaImg/src/LibPNG/pngrutil.c b/plugins/AdvaImg/src/LibPNG/pngrutil.c index 995896dbc5..b9c3905c79 100644 --- a/plugins/AdvaImg/src/LibPNG/pngrutil.c +++ b/plugins/AdvaImg/src/LibPNG/pngrutil.c @@ -1,7 +1,7 @@ /* pngrutil.c - utilities to read a PNG file * - * Last changed in libpng 1.5.9 [February 18, 2012] + * Last changed in libpng 1.5.10 [March 8, 2012] * Copyright (c) 1998-2012 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -434,14 +434,12 @@ png_decompress_chunk(png_structp png_ptr, int comp_type, */ if (prefix_size >= (~(png_size_t)0) - 1 || expanded_size >= (~(png_size_t)0) - 1 - prefix_size -#ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED +#ifdef PNG_USER_LIMITS_SUPPORTED || (png_ptr->user_chunk_malloc_max && (prefix_size + expanded_size >= png_ptr->user_chunk_malloc_max - 1)) #else -# ifdef PNG_USER_CHUNK_MALLOC_MAX || ((PNG_USER_CHUNK_MALLOC_MAX > 0) && prefix_size + expanded_size >= PNG_USER_CHUNK_MALLOC_MAX - 1) -# endif #endif ) png_warning(png_ptr, "Exceeded size limit while expanding chunk"); @@ -1259,13 +1257,16 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) /* Should be an error, but we can cope with it */ png_warning(png_ptr, "Out of place iCCP chunk"); - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)) + if ((png_ptr->mode & PNG_HAVE_iCCP) || (info_ptr != NULL && + (info_ptr->valid & (PNG_INFO_iCCP|PNG_INFO_sRGB)))) { png_warning(png_ptr, "Duplicate iCCP chunk"); png_crc_finish(png_ptr, length); return; } + png_ptr->mode |= PNG_HAVE_iCCP; + #ifdef PNG_MAX_MALLOC_64K if (length > (png_uint_32)65535L) { @@ -1795,16 +1796,16 @@ png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) return; } - num = length / 2 ; - - if (num != (unsigned int)png_ptr->num_palette || num > - (unsigned int)PNG_MAX_PALETTE_LENGTH) + if (length > 2*PNG_MAX_PALETTE_LENGTH || + length != (unsigned int) (2*png_ptr->num_palette)) { png_warning(png_ptr, "Incorrect hIST chunk length"); png_crc_finish(png_ptr, length); return; } + num = length / 2 ; + for (i = 0; i < num; i++) { png_byte buf[2]; @@ -3115,7 +3116,7 @@ png_combine_row(png_structp png_ptr, png_bytep dp, int display) /* This can only be the RGB case, so each copy is exactly one * pixel and it is not necessary to check for a partial copy. */ - for (;;) + for(;;) { dp[0] = sp[0], dp[1] = sp[1], dp[2] = sp[2]; @@ -3705,7 +3706,7 @@ png_init_filter_functions_neon(png_structp pp, unsigned int bpp) { pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_neon; pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_neon; - pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = + pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth3_neon; } diff --git a/plugins/AdvaImg/src/LibPNG/pngset.c b/plugins/AdvaImg/src/LibPNG/pngset.c index e753ca8867..fc99f5fdb6 100644 --- a/plugins/AdvaImg/src/LibPNG/pngset.c +++ b/plugins/AdvaImg/src/LibPNG/pngset.c @@ -1,8 +1,8 @@ /* pngset.c - storage of image information into info struct * - * Last changed in libpng 1.5.7 [December 15, 2011] - * Copyright (c) 1998-2011 Glenn Randers-Pehrson + * Last changed in libpng 1.5.11 [June 14, 2012] + * Copyright (c) 1998-2012 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -149,7 +149,7 @@ png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point * possible for 1/gamma to overflow the limit of 21474 and this means the * gamma value must be at least 5/100000 and hence at most 20000.0. For * safety the limits here are a little narrower. The values are 0.00016 to - * 6250.0, which are truly ridiculous gammma values (and will produce + * 6250.0, which are truly ridiculous gamma values (and will produce * displays that are all black or all white.) */ if (file_gamma < 16 || file_gamma > 625000000) @@ -692,24 +692,28 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, */ if (info_ptr->num_text + num_text > info_ptr->max_text) { + int old_max_text = info_ptr->max_text; + int old_num_text = info_ptr->num_text; + if (info_ptr->text != NULL) { png_textp old_text; - int old_max; - old_max = info_ptr->max_text; info_ptr->max_text = info_ptr->num_text + num_text + 8; old_text = info_ptr->text; + info_ptr->text = (png_textp)png_malloc_warn(png_ptr, (png_size_t)(info_ptr->max_text * png_sizeof(png_text))); if (info_ptr->text == NULL) { - png_free(png_ptr, old_text); + /* Restore to previous condition */ + info_ptr->max_text = old_max_text; + info_ptr->text = old_text; return(1); } - png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max * + png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max_text * png_sizeof(png_text))); png_free(png_ptr, old_text); } @@ -721,7 +725,12 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, info_ptr->text = (png_textp)png_malloc_warn(png_ptr, (png_size_t)(info_ptr->max_text * png_sizeof(png_text))); if (info_ptr->text == NULL) + { + /* Restore to previous condition */ + info_ptr->num_text = old_num_text; + info_ptr->max_text = old_max_text; return(1); + } info_ptr->free_me |= PNG_FREE_TEXT; } @@ -1281,4 +1290,22 @@ png_set_benign_errors(png_structp png_ptr, int allowed) png_ptr->flags &= ~PNG_FLAG_BENIGN_ERRORS_WARN; } #endif /* PNG_BENIGN_ERRORS_SUPPORTED */ + +#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED +/* Whether to report invalid palette index; added at libng-1.5.10 + * allowed - one of 0: disable; 1: enable + */ +void PNGAPI +png_set_check_for_invalid_index(png_structp png_ptr, int allowed) +{ + png_debug(1, "in png_set_check_for_invalid_index"); + + if (allowed) + png_ptr->num_palette_max = 0; + + else + png_ptr->num_palette_max = -1; +} +#endif + #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff --git a/plugins/AdvaImg/src/LibPNG/pngstruct.h b/plugins/AdvaImg/src/LibPNG/pngstruct.h index 1824c49114..73d71149ee 100644 --- a/plugins/AdvaImg/src/LibPNG/pngstruct.h +++ b/plugins/AdvaImg/src/LibPNG/pngstruct.h @@ -1,7 +1,7 @@ /* pngstruct.h - header file for PNG reference library * - * Copyright (c) 1998-2011 Glenn Randers-Pehrson + * Copyright (c) 1998-2012 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -121,6 +121,12 @@ struct png_struct_def png_uint_32 crc; /* current chunk CRC value */ png_colorp palette; /* palette from the input file */ png_uint_16 num_palette; /* number of color entries in palette */ + +/* Added at libpng-1.5.10 */ +#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED + int num_palette_max; /* maximum palette index found in IDAT */ +#endif + png_uint_16 num_trans; /* number of transparency values */ png_byte compression; /* file compression type (always 0) */ png_byte filter; /* file filter type (always 0) */ @@ -211,13 +217,6 @@ struct png_struct_def int process_mode; /* what push library is currently doing */ int cur_palette; /* current push library palette index */ -# ifdef PNG_TEXT_SUPPORTED - png_size_t current_text_size; /* current size of text input data */ - png_size_t current_text_left; /* how much text left to read in input */ - png_charp current_text; /* current text chunk buffer */ - png_charp current_text_ptr; /* current location in current_text */ -# endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */ - #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) @@ -249,6 +248,7 @@ struct png_struct_def #endif #ifdef PNG_TIME_RFC1123_SUPPORTED + /* This is going to be unused in libpng16 and removed from libpng17 */ char time_buffer[29]; /* String to hold RFC 1123 time text */ #endif diff --git a/plugins/AdvaImg/src/LibPNG/pngtest.c b/plugins/AdvaImg/src/LibPNG/pngtest.c index 840517400b..5594333568 100644 --- a/plugins/AdvaImg/src/LibPNG/pngtest.c +++ b/plugins/AdvaImg/src/LibPNG/pngtest.c @@ -1817,4 +1817,4 @@ main(int argc, char *argv[]) } /* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_5_9 Your_png_h_is_not_version_1_5_9; +typedef png_libpng_version_1_5_13 Your_png_h_is_not_version_1_5_13; diff --git a/plugins/AdvaImg/src/LibPNG/pngtrans.c b/plugins/AdvaImg/src/LibPNG/pngtrans.c index 53d9a25b95..d562eb061c 100644 --- a/plugins/AdvaImg/src/LibPNG/pngtrans.c +++ b/plugins/AdvaImg/src/LibPNG/pngtrans.c @@ -1,8 +1,8 @@ /* pngtrans.c - transforms the data in a row (used by both readers and writers) * - * Last changed in libpng 1.5.4 [July 7, 2011] - * Copyright (c) 1998-2011 Glenn Randers-Pehrson + * Last changed in libpng 1.5.11 [June 14, 2012] + * Copyright (c) 1998-2012 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -619,6 +619,109 @@ png_do_bgr(png_row_infop row_info, png_bytep row) } #endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */ +#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \ + defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED) +/* Added at libpng-1.5.10 */ +void /* PRIVATE */ +png_do_check_palette_indexes(png_structp png_ptr, png_row_infop row_info) +{ + if (png_ptr->num_palette < (1 << row_info->bit_depth) && + png_ptr->num_palette > 0) /* num_palette can be 0 in MNG files */ + { + /* Calculations moved outside switch in an attempt to stop different + * compiler warnings. 'padding' is in *bits* within the last byte, it is + * an 'int' because pixel_depth becomes an 'int' in the expression below, + * and this calculation is used because it avoids warnings that other + * forms produced on either GCC or MSVC. + */ + int padding = (-row_info->pixel_depth * row_info->width) & 7; + png_bytep rp = png_ptr->row_buf + row_info->rowbytes; + + switch (row_info->bit_depth) + { + case 1: + { + /* in this case, all bytes must be 0 so we don't need + * to unpack the pixels except for the rightmost one. + */ + for (; rp > png_ptr->row_buf; rp--) + { + if (*rp >> padding != 0) + png_ptr->num_palette_max = 1; + padding = 0; + } + + break; + } + + case 2: + { + for (; rp > png_ptr->row_buf; rp--) + { + int i = ((*rp >> padding) & 0x03); + + if (i > png_ptr->num_palette_max) + png_ptr->num_palette_max = i; + + i = (((*rp >> padding) >> 2) & 0x03); + + if (i > png_ptr->num_palette_max) + png_ptr->num_palette_max = i; + + i = (((*rp >> padding) >> 4) & 0x03); + + if (i > png_ptr->num_palette_max) + png_ptr->num_palette_max = i; + + i = (((*rp >> padding) >> 6) & 0x03); + + if (i > png_ptr->num_palette_max) + png_ptr->num_palette_max = i; + + padding = 0; + } + + break; + } + + case 4: + { + for (; rp > png_ptr->row_buf; rp--) + { + int i = ((*rp >> padding) & 0x0f); + + if (i > png_ptr->num_palette_max) + png_ptr->num_palette_max = i; + + i = (((*rp >> padding) >> 4) & 0x0f); + + if (i > png_ptr->num_palette_max) + png_ptr->num_palette_max = i; + + padding = 0; + } + + break; + } + + case 8: + { + for (; rp > png_ptr->row_buf; rp--) + { + if (*rp > png_ptr->num_palette_max) + png_ptr->num_palette_max = (int) *rp; + } + + break; + } + + default: + break; + } + } +} +#endif /* PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED */ + #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) #ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED diff --git a/plugins/AdvaImg/src/LibPNG/pngwrite.c b/plugins/AdvaImg/src/LibPNG/pngwrite.c index dc12a20481..c188439759 100644 --- a/plugins/AdvaImg/src/LibPNG/pngwrite.c +++ b/plugins/AdvaImg/src/LibPNG/pngwrite.c @@ -1,8 +1,8 @@ /* pngwrite.c - general routines to write a PNG file * - * Last changed in libpng 1.5.7 [December 15, 2011] - * Copyright (c) 1998-2011 Glenn Randers-Pehrson + * Last changed in libpng 1.5.11 [June 14, 2012] + * Copyright (c) 1998-2012 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -305,6 +305,11 @@ png_write_end(png_structp png_ptr, png_infop info_ptr) if (!(png_ptr->mode & PNG_HAVE_IDAT)) png_error(png_ptr, "No IDATs written into file"); +#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED + if (png_ptr->num_palette_max > png_ptr->num_palette) + png_benign_error(png_ptr, "Wrote palette index exceeding num_palette"); +#endif + /* See if user wants us to write information chunks */ if (info_ptr != NULL) { @@ -798,6 +803,14 @@ png_write_row(png_structp png_ptr, png_const_bytep row) } #endif +/* Added at libpng-1.5.10 */ +#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED + /* Check for out-of-range palette index */ + if (row_info.color_type == PNG_COLOR_TYPE_PALETTE && + png_ptr->num_palette_max >= 0) + png_do_check_palette_indexes(png_ptr, &row_info); +#endif + /* Find a filter if necessary, filter the row and write it out. */ png_write_find_filter(png_ptr, &row_info); diff --git a/plugins/AdvaImg/src/LibPNG/pngwtran.c b/plugins/AdvaImg/src/LibPNG/pngwtran.c index b598149a96..e962b68353 100644 --- a/plugins/AdvaImg/src/LibPNG/pngwtran.c +++ b/plugins/AdvaImg/src/LibPNG/pngwtran.c @@ -1,8 +1,8 @@ /* pngwtran.c - transforms the data in a row for PNG writers * - * Last changed in libpng 1.5.6 [November 3, 2011] - * Copyright (c) 1998-2011 Glenn Randers-Pehrson + * Last changed in libpng 1.5.13 [September 27, 2012] + * Copyright (c) 1998-2012 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -45,8 +45,20 @@ png_do_write_transformations(png_structp png_ptr, png_row_infop row_info) #ifdef PNG_WRITE_FILLER_SUPPORTED if (png_ptr->transformations & PNG_FILLER) - png_do_strip_channel(row_info, png_ptr->row_buf + 1, - !(png_ptr->flags & PNG_FLAG_FILLER_AFTER)); + { + if (png_ptr->color_type & (PNG_COLOR_MASK_ALPHA|PNG_COLOR_MASK_PALETTE)) + { + /* GA, RGBA or palette; in any of these cases libpng will not do the + * the correct thing (whatever that might be). + */ + png_warning(png_ptr, "incorrect png_set_filler call ignored"); + png_ptr->transformations &= ~PNG_FILLER; + } + + else + png_do_strip_channel(row_info, png_ptr->row_buf + 1, + !(png_ptr->flags & PNG_FLAG_FILLER_AFTER)); + } #endif #ifdef PNG_WRITE_PACKSWAP_SUPPORTED diff --git a/plugins/AdvaImg/src/LibPNG/pngwutil.c b/plugins/AdvaImg/src/LibPNG/pngwutil.c index 64888f7c6c..3cef5b295d 100644 --- a/plugins/AdvaImg/src/LibPNG/pngwutil.c +++ b/plugins/AdvaImg/src/LibPNG/pngwutil.c @@ -1,8 +1,8 @@ /* pngwutil.c - utilities to write a PNG file * - * Last changed in libpng 1.5.6 [November 3, 2011] - * Copyright (c) 1998-2011 Glenn Randers-Pehrson + * Last changed in libpng 1.5.10 [March 8, 2012] + * Copyright (c) 1998-2012 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -569,14 +569,15 @@ png_text_compress(png_structp png_ptr, /* Ship the compressed text out via chunk writes */ static void /* PRIVATE */ -png_write_compressed_data_out(png_structp png_ptr, compression_state *comp) +png_write_compressed_data_out(png_structp png_ptr, compression_state *comp, + png_size_t data_len) { int i; /* Handle the no-compression case */ if (comp->input) { - png_write_chunk_data(png_ptr, comp->input, comp->input_len); + png_write_chunk_data(png_ptr, comp->input, data_len); return; } @@ -585,7 +586,7 @@ png_write_compressed_data_out(png_structp png_ptr, compression_state *comp) /* The zbuf_size test is because the code below doesn't work if zbuf_size is * '1'; simply skip it to avoid memory overwrite. */ - if (comp->input_len >= 2 && comp->input_len < 16384 && png_ptr->zbuf_size > 1) + if (data_len >= 2 && comp->input_len < 16384 && png_ptr->zbuf_size > 1) { unsigned int z_cmf; /* zlib compression method and flags */ @@ -1164,8 +1165,7 @@ png_write_iCCP(png_structp png_ptr, png_const_charp name, int compression_type, if (profile_len) { - comp.input_len = profile_len; - png_write_compressed_data_out(png_ptr, &comp); + png_write_compressed_data_out(png_ptr, &comp, profile_len); } png_write_chunk_end(png_ptr); @@ -1370,7 +1370,8 @@ png_write_tRNS(png_structp png_ptr, png_const_bytep trans_alpha, } /* Write the chunk out as it is */ - png_write_complete_chunk(png_ptr, png_tRNS, trans_alpha, (png_size_t)num_trans); + png_write_complete_chunk(png_ptr, png_tRNS, trans_alpha, + (png_size_t)num_trans); } else if (color_type == PNG_COLOR_TYPE_GRAY) @@ -1735,8 +1736,7 @@ png_write_zTXt(png_structp png_ptr, png_const_charp key, png_const_charp text, png_write_chunk_data(png_ptr, &buf, (png_size_t)1); /* Write the compressed data */ - comp.input_len = text_len; - png_write_compressed_data_out(png_ptr, &comp); + png_write_compressed_data_out(png_ptr, &comp, text_len); /* Close the chunk */ png_write_chunk_end(png_ptr); @@ -1827,7 +1827,7 @@ png_write_iTXt(png_structp png_ptr, int compression, png_const_charp key, png_write_chunk_data(png_ptr, (lang_key ? (png_const_bytep)lang_key : cbuf), (png_size_t)(lang_key_len + 1)); - png_write_compressed_data_out(png_ptr, &comp); + png_write_compressed_data_out(png_ptr, &comp, text_len); png_write_chunk_end(png_ptr); diff --git a/plugins/AdvaImg/src/LibTIFF/ChangeLog b/plugins/AdvaImg/src/LibTIFF/ChangeLog deleted file mode 100644 index f3dfe26b0b..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/ChangeLog +++ /dev/null @@ -1,4849 +0,0 @@ -2011-04-09 Bob Friesenhahn - - * libtiff 3.9.5 released. - -2011-04-09 Bob Friesenhahn - - * configure.ac: Should use AC_CANONICAL_HOST since host specifies - the run-time target whereas target is used to specify the final - output target if the package is a build tool (like a compiler), - which libtiff is not. Resolves libtiff bug 2307 "Use - AC_CANONICAL_HOST macro". - -2011-04-02 Bob Friesenhahn - - * tools/fax2ps.c (main): Use tmpfile() rather than mkstemp() since - it is much more portable. Tmpfile is included in ISO/IEC - 9899:1990 and the WIN32 CRT. - -2011-03-21 Frank Warmerdam - - * libtiff/tiffiop.h: avoid declaring int64/uint64 on AIX with XLC - where they are already available. (#2301) - - * libtiff/tif_thunder.c: Correct potential buffer overflow with - thunder encoded files with wrong bitspersample set. The libtiff - development team would like to thank Marin Barbella and TippingPoint's - Zero Day Initiative for reporting this vulnerability (ZDI-CAN-1004, - CVE-2011-1167). - http://bugzilla.maptools.org/show_bug.cgi?id=2300 - -2011-03-10 Frank Warmerdam - - * libtiff/tif_fax3.h: Fix to last change allowing zero length - runs at the start of a scanline - needed for legal cases. - -2011-03-02 Frank Warmerdam - - * libtiff/tif_fax3.h: Protect against a fax VL(n) codeword commanding - a move left. Without this, a malicious input file can generate an - indefinitely large series of runs without a0 ever reaching the right - margin, thus overrunning our buffer of run lengths. Per CVE-2011-0192. - This is a modified version of a patch proposed by Drew Yao of Apple - Product Security. It adds an unexpected() report, and disallows the - equality case, since emitting a run without increasing a0 still allows - buffer overrun. - -2011-02-25 Andrey Kiselev - - * libtiff/tif_dirwrite.c: Avoid undefined behaviour when casting from - float to unsigned integer in TIFFWriteRationalArray() as reported by - Kareem Shehata. - -2011-01-03 Lee Howard - - * libtiff/tif_jpeg.c: Fix regressions with 2 and 3 band images - caused by commit on 2010-12-14. Submitted by e-mail from - Even Rouault - -2010-12-31 Olivier Paquet - - * libtiff/tif_dirread.c: Allow reading directories where - TIFFTAG_SMINSAMPLEVALUE and TIFFTAG_SMAXSAMPLEVALUE values differ for each - channel. The min/max of all channels is used as appropriate. - -2010-12-14 Lee Howard - - * libtiff/tif_dirread.c: tolerate some cases where - FIELD_COLORMAP is missing - http://bugzilla.maptools.org/show_bug.cgi?id=2189 - -2010-12-14 Lee Howard - - * libtiff/tif_strip.c: use TIFFGetFieldDefaulted instead - of TIFFGetField when we assume that it will succeed - http://bugzilla.maptools.org/show_bug.cgi?id=2215 - -2010-12-14 Lee Howard - - * tools/gif2tiff.c: fix buffer overrun - http://bugzilla.maptools.org/show_bug.cgi?id=2270 - -2010-12-14 Lee Howard - - * libtiff/tif_jpeg.c: reduce usage of JCS_UNKNOWN in order - to improve compatibility with various viewers - submitted by e-mail from Dwight Kelly - -2010-12-13 Lee Howard - - * tools/fax2ps.c: be consistent with page-numbering - http://bugzilla.maptools.org/show_bug.cgi?id=2225 - -2010-12-13 Lee Howard - - * libtiff/tif_dirread.c: fix needless tag ordering warning - http://bugzilla.maptools.org/show_bug.cgi?id=2210 - -2010-12-13 Lee Howard - - * libtiff/tif_color.c: prevent crash in handling bad TIFFs - resolves CVE-2010-2595 - http://bugzilla.maptools.org/show_bug.cgi?id=2208 - -2010-12-13 Lee Howard - - * tools/tiffcrop.c: new release by Richard Nolde - http://bugzilla.maptools.org/show_bug.cgi?id=2004 - -2010-12-12 Lee Howard - - * tools/tiff2pdf.c: fix colors for images with RGBA - interleaved data - http://bugzilla.maptools.org/show_bug.cgi?id=2250 - -2010-12-11 Lee Howard - - * tools/tiff2pdf.c: remove invalid duplication for Lab - http://bugzilla.maptools.org/show_bug.cgi?id=2162 - -2010-12-11 Lee Howard - - * libtiff/tif_jpeg.c: fix use of clumplines calculation - http://bugzilla.maptools.org/show_bug.cgi?id=2149 - -2010-12-11 Lee Howard - - * tools/fax2ps.c: replace unsafe tmpfile() with mkstemp() - http://bugzilla.maptools.org/show_bug.cgi?id=2118 - -2010-12-11 Lee Howard - - * tools/tiff2pdf.c: add fill-page option - http://bugzilla.maptools.org/show_bug.cgi?id=2051 - -2010-12-11 Lee Howard - - * libtiff/tif_dirread.c: modify warnings - http://bugzilla.maptools.org/show_bug.cgi?id=2016 - -2010-12-11 Lee Howard - - * libtiff/tif_ojpeg.c: fix buffer overflow on problem data - http://bugzilla.maptools.org/show_bug.cgi?id=1999 - -2010-12-11 Lee Howard - - * libtiff/tif_ojpeg.c: fix crash when reading a TIFF with a zero - or missing byte-count tag - * tools/tiffsplit.c: abort when reading a TIFF without a byte-count - per http://bugzilla.maptools.org/show_bug.cgi?id=1996 - -2010-12-08 Lee Howard - - * libtiff/tif_dirread.c: fix crash when reading a badly-constructed - TIFF per http://bugzilla.maptools.org/show_bug.cgi?id=1994 - -2010-12-07 Lee Howard - - * libtiff/tif_jpeg.c, libtiff/tif_strip.c: apply patch for - CVE-2010-3087 per bug - http://bugzilla.maptools.org/show_bug.cgi?id=2140 - -2010-12-06 Lee Howard - - * libtiff/tif_open.c: Fix mode check before opening a file. - http://bugzilla.maptools.org/show_bug.cgi?id=1906 - -2010-09-25 Lee Howard - - * tools/tiff2ps.c: improvements and enhancements from Richard Nolde - with additional command line options for Document Title, - Document Creator, and Page Orientation - -2010-07-13 Bob Friesenhahn - - * tools/tiffcrop.c: Patch from Richard Nolde to avoid a - potentially unterminated buffer due to using an exceptionally long - file name. - -2010-07-08 Andrey Kiselev - - * tools/tiff2pdf.c: Fixed ID buffer filling in - t2p_write_pdf_trailer(), thanks to Dmitry V. Levin. - -2010-07-07 Andrey Kiselev - - * libtiff/tif_dirread.c: Really reset the tag count in CheckDirCount() - to expected value as the warning message suggests. As per bug - http://bugzilla.maptools.org/show_bug.cgi?id=1963 - - * tools/tiffdump.c: Avoid integer overflows computing the buffer size - for large directories. As per bug - http://bugzilla.maptools.org/show_bug.cgi?id=2218 - -2010-07-06 Andrey Kiselev - - * tools/tiffset.c: Properly handle TIFFTAG_PAGENUMBER, - TIFFTAG_HALFTONEHINTS, TIFFTAG_YCBCRSUBSAMPLING, TIFFTAG_DOTRANGE - which should be set by value. - - * libtiff/tif_dirinfo.c: Don't use assertions in _TIFFFieldWithTag() - and _TIFFFieldWithName() if the tag is not found in the tag table. - This should be normal situation and returned NULL value should be - properly handled by the caller. - - * libtiff/{tif_dirwrite.c, tif_print.c}: Properly handle "DotRange" - tag as it can be either byte or short size and should be set and read - by value, not as an array. As per bug - http://bugzilla.maptools.org/show_bug.cgi?id=2116 - -2010-07-02 Andrey Kiselev - - * libtiff/tif_getimage.c: Avoid wrong math du to the signed/unsigned - integer type conversions. As per bug - http://bugzilla.maptools.org/show_bug.cgi?id=2207 - - * tools/{tiff2bw.c, thumbnail.c, pal2rgb.c}: Fix the count for - WhitePoint tag as per bug - http://bugzilla.maptools.org/show_bug.cgi?id=2042 - - * tools/tiffdump.c: Use PrintData() function instead of - PrintByte/Short/Long(). Should fix an issue reported at - http://bugzilla.maptools.org/show_bug.cgi?id=2116 - - * libtiff/tif_getimage.c: Check the number of samples per pixel when - working with YCbCr image in PickContigCase(). As per bug - http://bugzilla.maptools.org/show_bug.cgi?id=2216 - - * libtiff/tif_dir.c: Set the bogus post-decoding hook when processing - TIFFTAG_BITSPERSAMPLE in _TIFFVSetField() for the case of 8 bit when - we don't need any post-processing. That helps to reset the hook if we - previously set this field to some other value and the hook was - initialized accordingly. As per bug - http://bugzilla.maptools.org/show_bug.cgi?id=2035 - -2010-06-30 Andrey Kiselev - - * tools/tiff2pdf.c: Better generation of ID field in - t2p_write_pdf_trailer(). Get rid of GCC aliasing warnings. - - * tools/tiff2pdf.c: Fixed computation of the tile buffer size when - converting JPEG encoded tiles. - - * tools/tiff2pdf.c: Better handling of string fields, use static - string buffers instead of dynamically allocated, use strncpy() instead - of strcpy(), control the string lengths. - -2010-06-25 Andrey Kiselev - - * tools/tiffcp.c: Initialize buffer arrays with zero to avoid - referencing to uninitialized memory in some cases (e.g. when tile size - set bigger than the image size). - -2010-06-15 Bob Friesenhahn - - * tools/tiffcrop.c: Patch from Richard Nolde. Reject YCbCr - subsampled data since tiffcrop currently doesn't support it. Fix - JPEG support. - -2010-06-15 Bob Friesenhahn - - * libtiff 3.9.4 released. - -2010-06-13 Frank Warmerdam - - * libtiff/tif_jpeg.c: avoid re-preparing jpeg tables unnecessarily - (gdal #3633, libtiff #2135). - - * libtiff/tif_dirread.c: Fixed bad handling of out of order tags - definated late by a codec (#2210) - - * libtiff/tif_dirread.c: Fixed inadequate validation of the - SubjectDistance field (#2212). - - * tiff2pdf.c: Fix assorted bugs in tiff2pdf: missing "return" - in t2p_read_tiff_size() causes t2p->tiff_datasize to be set entirely - wrong for COMPRESSION_JPEG case, resulting in memory stomp if actual - size is larger. Also, there are a bunch of places that try to - memset() a malloc'd buffer before checking for malloc failure, which - would result in core dump if there actually were a failure. (#2211) - -2010-06-11 Bob Friesenhahn - - * tools/tiff2rgba.c: Applied portion of patch (from Tom Lane) - which was left out in order to fully resolve "CVE-2009-2347 - libtiff: integer overflows in various inter-color space conversion - tools". http://bugzilla.maptools.org/show_bug.cgi?id=2079 - - * libtiff/tiffiop.h (TIFFSafeMultiply): Need more castings to - avoid compiler warnings if parameter types are not sign - consistent. - - * tools/tiffcrop.c: Applied patch from Richard Nolde: Corrected - European page size dimensions. Added an option to allow the user - to specify a custom page size on the command line. Fix the case - where a page size specified with a fractional part was being - coerced to an integer by retyping the variables that define the - paper size. - - * libtiff 3.9.3 released. - - * tools/tiffcp.c (tiffcp): Applied Tom Lane's patch to reject - YCbCr subsampled data since tiffcp currently doesn't support it. - http://bugzilla.maptools.org/show_bug.cgi?id=2097 - - * Update libtool to version 2.2.10. - -2010-06-10 Bob Friesenhahn - - * libtiff/tiffiop.h (TIFFSafeMultiply): Work properly if - multiplier is zero. - -2010-06-09 Bob Friesenhahn - - * libtiff/tif_dir.h: Restore ReferenceBlackWhite as a non-custom - field. This avoids a multi-thread reentrancy problem as well as - fixing output of wrong tag value due to redundant definitions for - the same tag in the tiffFieldInfo[] array. Resolves - http://bugzilla.maptools.org/show_bug.cgi?id=2185 - - * libtiff/tif_fax3.c (Fax3SetupState): Yesterday's fix for - CVE-2010-1411 was not complete. - - * libtiff/tiffiop.h (TIFFSafeMultiply): New macro to safely - multiply two integers. Returns zero if there is an integer - overflow. - - * tools/tiffcp.c (main): Fix more TIFF handle leaks. - - * libtiff/tif_read.c (TIFFReadBufferSetup): Skip allocating - tif_rawdata if tif_rawdatasize becomes zero. - -2010-06-08 Bob Friesenhahn - - * tools/tiffcrop.c: Removed duplicated macros such as - TIFFhowmany(). - - * Update libtool to version 2.2.8. - - * libtiff/tif_fax3.c (Fax3SetupState): Avoid under-allocation of - buffer due to integer overflow in TIFFroundup() and several other - potential overflows. In conjunction with the fix to TIFFhowmany(), - fixes CVE-2010-1411. - - * libtiff/tiffiop.h (TIFFhowmany): Return zero if parameters would - result in an integer overflow. This causes TIFFroundup() to also - return zero if there would be an integer overflow. - - * libtiff/tif_read.c (TIFFReadBufferSetup): Return an error if - tif_rawdatasize becomes zero due to an initial raw size of zero or - an overflow reported by TIFFroundup(). - - * libtiff/tif_ojpeg.c (OJPEGReadBufferFill): Report an error and - avoid a crash if the input file is so broken that the strip - offsets are not defined. - - * tools/tiffcp.c (main): tiffcp should not leak memory if an error - is reported when reading the input file. - - * libtiff/tif_aux.c (_TIFFCheckRealloc): Produce a fully detailed - error message string. - - * Add an emacs formatting mode footer to all source files so that - emacs can be effectively used. - -2010-06-03 Oliver Chen Feng - - * libtiff/tools/tiffcp.c: add a new option -x to force merged tiff - file PAGENUMBER value in sequence for users who care the page - sequence, this will also prevent tiff2pdf from creating pdf file from - the merged tiff file with wrong page sequence. - -2010-05-07 Frank Warmerdam - - * libtiff/tif_jpeg.c: Ensure that quality is always set in - JPEGPreEncode(), not just when we want to output local tables. - Otherwise the quality used during compression may not be right and - might not match the tables in the tables tag. This bug only occurs - when seeking between directories in the midst of writing blocks. - http://trac.osgeo.org/gdal/ticket/3539 - -2010-05-05 Olivier Paquet - - * libtiff/tif_print.c: Have TIFFTAG_REFERENCEBLACKWHITE always print 6 - floats instead of 2*SamplesPerPixel. - http://bugzilla.maptools.org/show_bug.cgi?id=2186 - * man/TIFFGetField.3tiff, man/TIFFSetField.3tiff: Fixed doc to reflect the - fact that libtiff considers TIFFTAG_REFERENCEBLACKWHITE to be 6 floats. - -2010-04-10 Bob Friesenhahn - - * tools/ppm2tiff.c (main): While case for parsing comment line - requires extra parenthesis to work as expected. Reported by - Thomas Sinclair. - -2010-02-22 Lee Howard - - * libtiff/tif_jpeg.c: Do not generate a JPEGTables tag when creating - the JPEG TIFF as is is not required in order to prevent it from - being unused and filled with invalid data. (Leave it to be - generated by later activity.) - http://bugzilla.maptools.org/show_bug.cgi?id=2135 - * tools/tiff2pdf.c: Write the JPEG SOI headers into the TIFF strip - data rather than skipping them. This fixes the ability to view in - Acrobat Reader, Evince, and Ghostscript. - http://bugzilla.maptools.org/show_bug.cgi?id=2135 - * libtiff/tif_fax3.c: Don't return error on badly-terminated MMR - strips. - http://bugzilla.maptools.org/show_bug.cgi?id=2029 - -2010-01-06 Frank Warmerdam - - * libtiff/tif_dir.c: Ensure tile and scanline sizes are reset - when moving to new directories. - http://bugzilla.maptools.org/show_bug.cgi?id=1936 - -2009-12-03 Frank Warmerdam - - * libtiff/tif_jpeg.c: Fix a couple of issues that trigger failures in - some cases when using TIFFReadScanline() with JPEG compressed - subsampled ycbcr images. - http://bugzilla.maptools.org/show_bug.cgi?id=1936 - -2009-11-04 Bob Friesenhahn - - * libtiff 3.9.2 released. - -2009-11-03 Bob Friesenhahn - - * tools/tiffcrop.c: Updated tiffcrop from Richard Nolde. This - version has undergone substantial testing with arbitrary sample - bit depths. Also eliminates GCC compilation warnings. - -2009-11-02 Bob Friesenhahn - - * port/libport.h: Added header file for porting prototypes and - extern declarations. - -2009-10-31 Bob Friesenhahn - - * libtiff/tif_dirwrite.c (TIFFWriteAnyArray): Add missing break - statement so writing an array of TIFF_DOUBLE works. - -2009-10-29 Bob Friesenhahn - - * libtiff/tif_dirread.c: Eliminate GCC "dereferencing type-punned - pointer" warnings. - -2009-10-28 Bob Friesenhahn - - * html/tools.html: Add manual page links, and a summary - description of tiffcrop. - -2009-10-07 Bob Friesenhahn - - * configure.ac: x86_64 should use the same fill order as i386. - -2009-09-24 Bob Friesenhahn - - * tools/tiffcrop.c, man/tiffcrop.1: New tiffcrop from Richard - Nolde. Major updates to add significant functionality for reading - and writing tile based images with bit depths not a multiple of 8 - which cannot be handled by tiffcp. - -2009-09-03 Bob Friesenhahn - - * libtiff/tif_ojpeg.c (OJPEGWriteHeaderInfo): IJG JPEG 7 needs - do_fancy_upsampling=FALSE in order to read raw data. Resolves - "Bug 2090 - OJPEG crash with libjpeg v7". - http://bugzilla.maptools.org/show_bug.cgi?id=2090 - -2009-08-30 Bob Friesenhahn - - * contrib/iptcutil/iptcutil.c, - libtiff/tif_getimage.c,libtiff/tif_jpeg.c,libtiff/tif_ojpeg.c,tools/tiffcrop.c,tools/tiffgt.c: - Applied patch from Oden Eriksson to allow building with GCC using - the "-Wformat -Werror=format-security" flags. - -2009-08-28 Bob Friesenhahn - - * libtiff 3.9.1 released. - -2009-08-28 Frank Warmerdam - - * libtiff/tif_dirwrite.c: Back out changes from 2007-11-22 that - resulted in the final strip not being written in some circumstances. - http://bugzilla.maptools.org/show_bug.cgi?id=2088 - -2009-08-27 Bob Friesenhahn - - * libtiff/tif_write.c (TIFFAppendToStrip): Remove cast which - caused libtiff to output a wrong last strip with byte-count and - strip-offset of zero. This cast was added on the day of the 3.9.0 - release. - - * libtiff/tif_config.vc.h: tiffiop.h needs the TIFF_INT64_T and - TIFF_UINT64_T defines in order to compile. Copy existing - definitions from tiffconf.vc.h. - -2009-08-21 Bob Friesenhahn - - * test/Makefile.am (AUTOMAKE_OPTIONS): Colorized tests was not - actually activated since it needed to be enabled in this - Makefile.am. Also activated parallel-tests mode since it offers - useful features such as per-test .log files and a summary test - report .log file. - -2009-08-20 Bob Friesenhahn - - * libtiff 3.9.0 released. - - * libtiff/tif_print.c (TIFFPrintDirectory): Applied patch for "tag - error may cause segfault in tif_print.c." - http://bugzilla.maptools.org/show_bug.cgi?id=1896 - - * tools/{rgb2ycbcr.c, tiff2rgba.c}: Applied patch for - CVE-2009-2347 libtiff: integer overflows in various inter-color - space conversion tools. - http://bugzilla.maptools.org/show_bug.cgi?id=2079 - - * configure.ac: Updated autotools. Autoconf 2.64, Automake 1.11, - libtool 2.2.6. Enabled support for silent build rules - (--enable-silent-rules or 'make V=0') and colorized tests. - -2009-06-30 Frank Warmerdam - - * libtiff/tif_luv.c: correct return codes from encoderow to be - 1 on success instead of zero. - http://bugzilla.maptools.org/show_bug.cgi?id=2069 - -2009-06-22 Frank Warmerdam - - * libtiff/tif_lzw.c: Fix buffer underflow bug. - http://bugzilla.maptools.org/show_bug.cgi?id=2065 - -2009-06-03 Frank Warmerdam - - * libtiff/tif_write.c: do not override the planar configuration to be - contig for one sample files if planar configuration is already set. - http://bugzilla.maptools.org/show_bug.cgi?id=2057 - -2009-02-12 Frank Warmerdam - - * libtiff/tif_luv.c: Fix handling of tiled logluv images. - http://bugzilla.maptools.org/show_bug.cgi?id=2005 - -2009-01-23 Frank Warmerdam - - * libtiff/tif_predict.c: Add support for 32bit integer horz. predictors. - http://bugzilla.maptools.org/show_bug.cgi?id=1911 - -2009-01-20 Frank Warmerdam - - * tools/tiffsplit.c: fix sampleformat to be shortv instead of longv. - -2009-01-12 Bob Friesenhahn - - * tools/tiff2ps.c: Remove spurious message printed to stderr. - -2009-01-11 Bob Friesenhahn - - * tools/tiff2ps.c: Incorporated significant functionality update - from Richard Nolde. In particular, support for rotating the image - by 90, 180, 270, and 'auto' has been added. - - * tools/tiffcrop.c: Incorporated significant functionality update - from Richard Nolde. - -2009-01-06 Bob Friesenhahn - - * libtiff/tiffiop.h: Add private type declarations for int64, and - uint64 so that bundled utilities (like tiffcrop) can use it when - necessary. - -2009-01-01 Bob Friesenhahn - - * configure.ac: Updated to test for 64-bit types. This version of - the library does not require a 64-bit type, but tiffcrop needs it. - -2008-12-31 Bob Friesenhahn - - * Update to use current FSF autotools versions. - * libtiff/tiffio.h: GCC will now validate format specifications - for TIFFError(), TIFFErrorExt(), TIFFWarning(), and - TIFFWarningExt() in order to reveal bugs. Cleaned up resulting - warnings throughout for 32 bit build only. - -2008-12-31 Frank Warmerdam - - * tools/tiffcrop.c, man/tiffcrop.1: A major update from Richard - Nolde. - -2008-12-21 Frank Warmerdam - - * libtiff/tif_jpeg.c: Avoid errors if the application writes a full - strip for the last partial strip in a jpeg compressed file. - http://bugzilla.maptools.org/show_bug.cgi?id=1981 - -2008-12-21 Frank Warmerdam - - * libtiff/tif_getimage.c, tiffio.h: More ABI corrections. - Removed SubsamplingHor/Ver from TIFFRGBAImage structure. - http://bugzilla.maptools.org/show_bug.cgi?id=1980 - -2008-12-18 Frank Warmerdam - - * libtiff/tif_getimage.c,tiffio.h: removed all use of UaToAa and - Bitmap16to8 arrays in TIFFRGBAImage structure to restore ABI - compatability. These were just an attempt to speed up processing - with precalculated tables. - http://bugzilla.maptools.org/show_bug.cgi?id=1979 - - * libtiff/tif_codec.c: Avoid printing c->name if it does not exist. - -2008-10-21 Andrey Kiselev - - * libtiff/tif_jbig.c: Support the JBIG-KIT 2.0 (compatibility with - the older versions retained). - -2008-09-05 Andrey Kiselev - - * tools/tiffsplit.c: Use dynamically allocated array instead of static - when constructing output file names. - -2008-09-03 Andrey Kiselev - - * tools/tiffsplit.c: Get rid of unsafe strcpy()/strcat() calls when - doing the filename/path construction. - - * tools/tiff2pdf.c: More appropriate format string in - t2p_write_pdf_string(); avoid signed/unsigned mismatch. - - * libtiff/tif_lzw.c: Properly zero out the codetable. As per bug - - http://bugzilla.maptools.org/show_bug.cgi?id=1929 - - * libtiff/tif_lzw.c: Properly zero out the string table. Fixes - CVE-2008-2327 security issue. - -2008-05-24 Frank Warmerdam - - * tif_codec.c: Avoid NULL pointer dereferencing for exotic - compression codec codes. - - * tif_dirread.c: zero tif->tif_dir after freeing the directory - in TIFFReadCustomDirectory(). I don't exactly remember why this - was important. - - * tif_dirwrite.c: Fix potential memory leak writing large double - tags. - - * tif_dirread.c: Fix unchecked malloc result. - -2008-01-30 Andrey Kiselev - - * tif_fax3.c: Make find0span() and find1span() non-inline to - make MSVC 6.0 compiler happy. - -2007-11-26 Frank Warmerdam - - * tif_fax3.c: fix leak of FAXCS state (per bug 1603). - -2007-11-23 Andrey Kiselev - - * configure.com, libtiff/tif_vms.c: Better OpenVMS support. Patches - from Alexey Chupahin. - -2007-11-22 Frank Warmerdam - - * tif_write.c: Rip out the fancy logic in TIFFAppendToStrip() for - establishing if an existing tile can be rewritten to the same location - by comparing the current size to all the other blocks in the same - directory. This is dangerous in many situations and can easily - corrupt a file. (observed in esoteric GDAL situation that's hard to - document). This change involves leaving the stripbytecount[] values - unaltered till TIFFAppendToStrip(). Now we only write a block back - to the same location it used to be at if the new data is the same - size or smaller - otherwise we move it to the end of file. - - * tif_dirwrite.c: Try to avoid writing out a full readbuffer of tile - data when writing the directory just because we have BEENWRITING at - some point in the past. This was causing odd junk to be written out - in a tile of data when a single tile had an interleaving of reading - and writing with reading last. (highlighted by gdal - autotest/gcore/tif_write.py test 7. - - * tif_predict.c: use working buffer in PredictorEncodeTile to avoid - modifying callers buffer. - http://trac.osgeo.org/gdal/ticket/1965 - - * tif_predict.c/h, tif_lzw.c, tif_zip.c: Improvements so that - predictor based encoding and decoding works in read-write update - mode properly. - http://trac.osgeo.org/gdal/ticket/1948 - -2007-10-05 Frank Warmerdam - - * tools/tiff2pdf.c: Fixed setting of alpha value per report on list. - -2007-09-13 Frank Warmerdam - - * tif_dirinfo.c: _TIFFMergeFields() now only merges in field - definitions that are missing. Existing definitions are silently - ignored. (Bug #1585) - -2007-07-18 Andrey Kiselev - - * libtiff/{Makefile.am, Makefile.v}: Do not distribute tiffconf.h, - remove tif_config.h/tiffconf.h during cleaning. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1573 - -2007-07-13 Andrey Kiselev - - * libtiff 3.9.0beta released. - -2007-07-12 Andrey Kiselev - - * tools/tiff2pdf.c: Added missed extern optind as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1567 - -2007-07-03 Andrey Kiselev - - * tools/tiff2ps.c: Added support 16-bit images as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1566 - - Patch from William Bader. - - * tools/tiff2pdf.c: Fix for TIFFTAG_JPEGTABLES tag fetching and - significant upgrade of the whole utility as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1560 - - Now we don't need tiffiop.h in tiff2pdf anymore and will open output - PDF file using TIFFClientOpen() machinery as it is implemented - by Leon Bottou. - -2007-06-29 Bob Friesenhahn - - * libtiff/tif_dirinfo.c (_TIFFFindFieldInfo): Don't attempt to - bsearch() on a NULL fieldinfo list. - (_TIFFFindFieldInfoByName): Don't attempt to - lfind() on a NULL fieldinfo list. - -2007-05-01 Andrey Kiselev - - * libtiff/tif_dirwrite.c: Fixed problem introduced with a fix for a - byte swapping issue - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1363 - - As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1550 - -2007-04-27 Andrey Kiselev - - * tools/tiff2pdf.c: Check the tmpfile() return status as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=154 - -2007-04-07 Andrey Kiselev - - * libtiff/{tif_dir.h, tif_dirread.c, tif_dirinfo.c, tif_jpeg.c, - tif_fax3.c, tif_jbig.c, tif_luv.c, tif_ojpeg.c, tif_pixarlog.c, - tif_predict.c, tif_zip.c}: Finally fix bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1274 - - by introducing _TIFFMergeFieldInfo() returning integer error status - instead of void in case of problems with field merging (e.g., if the - field with such a tag already registered). TIFFMergeFieldInfo() in - public API remains void. Use _TIFFMergeFieldInfo() everywhere and - check returned value. - -2007-04-07 Frank Warmerdam - - * contrib/addtiffo/tif_overview.c: Fix problems with odd sized output - blocks in TIFF_DownSample_Subsampled() (bug 1542). - -2007-04-06 Frank Warmerdam - - * libtiff/tif_jpeg.c: Changed JPEGInitializeLibJPEG() so that it - will convert from decompressor to compressor or compress to decompress - if required by the force arguments. This works around a problem in - where the JPEGFixupTestSubsampling() may cause a decompressor to - be setup on a directory when later a compressor is required with the - force flag set. Occurs with the addtiffo program for instance. - -2007-04-06 Andrey Kiselev - - * libtiff/tif_dirwrite.c: Fixed swapping of byte arrays stored - in-place in tag offsets as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1363 - - * tools/tiffcrop.c, man/tiffcrop.1: Significant update in - functionality from Richard Nolde. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1525 - -2007-03-28 Frank Warmerdam - - * libtiff/tif_fax3.c: "inline static" -> "static inline" for IRIC CC. - -2007-03-07 Joris Van Damme - - * libtiff/tif_getimage.c: workaround for 'Fractional scanline' error reading - OJPEG images with rowsperstrip that is not a multiple of vertical subsampling - factor. This bug is mentioned in: - http://bugzilla.remotesensing.org/show_bug.cgi?id=1390 - http://www.asmail.be/msg0054766825.html - -2007-03-07 Joris Van Damme - - * libtiff/tif_win32.c: made inclusion of windows.h unconditional - - * libtiff/tif_win32.c: replaced preprocessor indication for consiously - unused arguments by standard C indication for the same - -2007-02-27 Andrey Kiselev - - * libtiff/tif_dirread.c: Use uint32 type instead of tsize_t in byte - counters in TIFFFetchData(). Should finally fix the issue - - http://bugzilla.remotesensing.org/show_bug.cgi?id=890 - -2007-02-24 Andrey Kiselev - - * tools/tiffset.c: Properly handle tags with TIFF_VARIABLE writecount. - As per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1350 - - * libtiff/tif_dirread.c: Added special function to handle - SubjectDistance EXIF tag as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1362 - - * tools/tiff2pdf.c: Do not assume inches when the resolution units - do not specified. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1366 - - * tools/{tiffcp.c, tiffcrop.c}: Do not change RowsPerStrip value if - it was set as infinite. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1368 - - * tools/tiffcrop.c, man/tiffcrop.1: New tiffcrop utility contributed - by Richard Nolde. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1383 - -2007-02-22 Andrey Kiselev - - * libtiff/tif_dir.c: Workaround for incorrect TIFFs with - ExtraSamples == 999 produced by Corel Draw. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1490 - - * libtiff/{tif_dirread.c, tif_read.c}: Type of the byte counters - changed from tsize_t to uint32 to be able to work with data arrays - larger than 2GB. Fixes bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=890 - - Idea submitted by Matt Hancher. - -2007-01-31 Andrey Kiselev - - * tools/tif2rgba.c: This utility does not work properly on big-endian - architectures. It was fixed including the bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1149 - -2007-01-15 Mateusz Loskot - - * Submitted libtiff port for Windows CE platform - * libtiff/tif_config.wince.h: Added configuration header for WinCE. - * libtiff/tiffconf.wince.h: Ported old configuration header for WinCE. - * libtiff/tif_wince.c: Added WinCE-specific implementation of some - functons from tif_win32.c. - * libtiff/tif_win32.c: Disabled some functions already reimplemented in tif_wince.c. - * libtiff/tiffiop.h, port/lfind.c: Added conditional include of some - standard header files for Windows CE build. - * tools/tiffinfoce.c: Ported tiffinfo utility for Windows CE. - -2006-11-19 Frank Warmerdam - - * libtiff/tif_write.c: TIFFAppendToStrip() - clear sorted flag if - we move a strip. - http://bugzilla.remotesensing.org/show_bug.cgi?id=1359 - -2006-10-13 Andrey Kiselev - - * libtiff/tif_dir.c: More fixes for vulnerabilities, reported - in Gentoo bug (): - - http://bugs.gentoo.org/show_bug.cgi?id=142383 - - * libtiff/contrib/dbs/xtiff/xtiff.c: Make xtiff utility compilable. - Though it is still far from the state of being working and useful. - -2006-10-12 Andrey Kiselev - - * libtiff/tif_fax3.c: Save the state of printdir codec dependent - method. - - * libtiff/tif_jpeg.c: Save the state of printdir codec dependent method - as per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1273 - - * libtiff/tif_win32.c: Fixed problem with offset value manipulation - as per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1322 - - * libtiff/{tif_read.c, tif_jpeg.c, tif_dir.c}: More fixes for - vulnerabilities, reported in Gentoo bug (): - - http://bugs.gentoo.org/show_bug.cgi?id=142383 - -2006-09-28 Andrey Kiselev - - * libtiff/{tif_fax3.c, tif_next.c, tif_pixarlog.c}: Fixed multiple - vulnerabilities, as per Gentoo bug (): - - http://bugs.gentoo.org/show_bug.cgi?id=142383 - -2006-09-27 Frank Warmerdam - - * libtiff/tif_lzw.c, libtiff/tif_zip.c: Fixed problems with mixing - encoding and decoding on the same read-write TIFF handle. The LZW - code can now maintain encode and decode state at the same time. The - ZIP code will switch back and forth as needed. - http://bugzilla.remotesensing.org/show_bug.cgi?id=757 - -2006-09-20 Frank Warmerdam - - * libtiff: Rename config.h.vc and tif_config.h.vc to config.vc.h and - tif_config.vc.h for easier identification by folks using an IDE. - -2006-07-25 Frank Warmerdam - - * tif_msdos.c: Avoid handle leak for failed opens. c/o Thierry Pierron - -2006-07-19 Frank Warmerdam - - * tif_dirwrite.c: take care not to flush out buffer of strip/tile - data in _TIFFWriteDirectory if TIFF_BEENWRITING not set. Relates - to bug report by Peng Gao with black strip at bottom of images. - -2006-07-12 Frank Warmerdam - - * tif_dirwrite.c: make sure to use uint32 for wordcount in - TIFFWriteNormanTag if writecount is VARIABLE2 for ASCII fields. - It already seems to have been done for other field types. Needed - for "tiffset" on files with geotiff ascii text. - -2006-07-04 Bob Friesenhahn - - * {configure.ac, libtiff/tif_config.h.vc, libtiff/tif_jbig.c} - (JBIGDecode): jbg_newlen is not available in older JBIG-KIT and - its use does not appear to be required, so use it only when it is - available. - -2006-06-24 Andrey Kiselev - - * libtiff/tif_dirinfo.c: Added missed EXIF tag ColorSpace (40961). - - * libtiff/tif_dirread.c: Move IFD fetching code in the separate - function TIFFFetchDirectory() avoiding code duplication in - TIFFReadDirectory() and TIFFReadCustomDirectory(). - -2006-06-19 Frank Warmerdam - - * tools/tiff2pdf.c: Fix handling of -q values. - http://bugzilla.remotesensing.org/show_bug.cgi?id=587 - -2006-06-17 Frank Warmerdam - - * tif_readdir.c: Added case in EstimateStripByteCounts() for tiled - files. Modified TIFFReadDirectory() to not invoke - EstimateStripByteCounts() for case where entry 0 and 1 are unequal - but one of them is zero. - http://bugzilla.remotesensing.org/show_bug.cgi?id=1204 - -2006-06-08 Andrey Kiselev - - * libtiff/{tif_open.c, tif_dirread.c, tiffiop.h}: Move IFD looping - checking code in the separate function TIFFCheckDirOffset(). - - * libtiff/tif_aux.c: Added _TIFFCheckRealloc() function. - - * tools/tiffcmp.c: Fixed floating point comparison logic as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1191 - - * libtiff/tif_fax3.c: Fixed problems in fax decoder as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1194 - - * tools/tiff2pdf.c: Fixed buffer overflow condition in - t2p_write_pdf_string() as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1196 - -2006-06-07 Andrey Kiselev - - * {configure, configure.ac, libtiff/tif_jbig.c, tools/tiffcp.c}: Added - support for JBIG compression scheme (34661 code) contributed by Lee - Howard. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=896 - - * configure, configure.ac: OJPEG support enabled by default. - - * contrib/ojpeg/: Removed. New OJPEG support does not need this patch. - -2006-06-03 Bob Friesenhahn - - * libtiff/{tif_dirinfo.c, tif_print.c} : Fix crash in - TIFFPrintDirectory(). Joris Van Damme authored the fix. - -2006-04-21 Andrey Kiselev - - * tools/tiff2pdf.c: Unified line ending characters (always use '\n') - as per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1163 - - * README.vms, Makefile.am, configure.com, libtiff/{Makefile.am, - tif_config.h-vms, tif_stream.cxx, tif_vms.c, tiffconf.h-vms}: - Added support for OpenVMS by Alexey Chupahin, elvis_75@mail.ru. - -2006-04-20 Andrey Kiselev - - * tools/{fax2ps.c, fax2tiff.c, ppm2tiff.c, ras2tiff.c, tiff2pdf.c}: - Properly set the binary mode for stdin stream as per bug - http://bugzilla.remotesensing.org/show_bug.cgi?id=1141 - - * man/{bmp2tiff.1, fax2ps.1, fax2tiff.1, gif2tiff.1, ras2tiff.1, - raw2tiff.1, rgb2ycbcr.1, sgi2tiff.1, tiff2bw.1, tiff2pdf.1, tiff2ps.1, - tiff2rgba.1, tiffcmp.1, tiffcp.1, tiffdither.1, tiffdump.1, tiffgt.1, - tiffset.1}: Improvements in page formatting as per bug - http://bugzilla.remotesensing.org/show_bug.cgi?id=1140 - - * html/tools.html, html/man/Makefile.am, tools/tiff2pdf.c: Fixed - typos as per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1139 - -2006-04-18 Frank Warmerdam - - * nmake.opt: use /EHsc for VS2005 compatibility. Also define - _CRT_SECURE_NO_DEPRECATE to avoid noise on VS2005. - -2006-04-12 Joris Van Damme - - * libtiff/tif_getimage.c: Added support for planarconfig separate - non-subsampled YCbCr (i.e. separate YCbCr with subsampling [1,1]) - -2006-04-11 Joris Van Damme - - * libtiff/tif_getimage.c: Revision of all RGB(A) put routines - - Conversion of unassociated alpha to associated alpha now done with - more performant LUT, and calculation more correct - - Conversion of 16bit data to 8bit data now done with - more performant LUT, and calculation more correct - - Bugfix of handling of 16bit RGB with unassociated alpha - -2006-04-11 Joris Van Damme - - * libtiff/tif_getimage.c: - - When there is no alpha, gtTileSeparate and gtStripSeparate allocated - buffer for alpha strile and filled it, only to never read it back. - Removed allocation and fill. - - Minor rename of vars in gtTileSeparate and gtStripSeparate - anticipating planned functionality extension - -2006-04-08 Joris Van Damme - - * libtiff/tif_getimage.c: renamed pickTileContigCase to PickContigCase - and pickTileSeparateCase to PickSeparateCase as both work on strips as - well - - * libtiff/tif_getimage.c: moved img->get selection from - TIFFRGBAImageBegin into PickContigCase and PickSeparateCase to create - logical hook for planned functionality extension - -2006-04-08 Joris Van Damme - - * libtiff/tif_ojpeg.c: resolved memory leak that was a consequence - of inappropriate use of jpeg_abort instead of jpeg_destroy - -2006-04-07 Joris Van Damme - - * libtiff/tif_getimage.c: replaced usage of TIFFScanlineSize in - gtStripContig with TIFFNewScanlineSize so as to fix buggy behaviour - on subsampled images - this ought to get sorted when we feel brave - enough to replace TIFFScanlineSize alltogether - - * libtiff/tif_ojpeg.c: fixed bug in OJPEGReadSkip - -2006-04-04 Joris Van Damme - - * libtiff/tiffio.h: added new type tstrile_t - - * libtiff/tif_dir.h: changed types of td_stripsperimage and td_nstrips - to new tstrile_t, types of td_stripoffset and td_stripbytecount to - toff_t* - - * libtiff/tif_ojpeg.c: totally new implementation - - * libtiff/tif_dirread.c: added several hacks to suit new support of - OJPEG - - * libtiff/tif_getimage.c: removed TIFFTAG_JPEGCOLORMODE handling - of OJPEG images in favor of tif_getimage.c native handling of - YCbCr and desubsampling - -2006-03-29 Frank Warmerdam - - * libtiff/tif_jpeg.c: JPEGVSetField() so that altering the photometric - interpretation causes the "upsampled" flag to be recomputed. Fixes - peculiar bug where photometric flag had to be set before jpegcolormode - flag. - -2006-03-25 Joris Van Damme - - * libtiff/tif_jpeg.c: strip size related bugfix in encode raw - - * libtiff/tif_strip.c: temporarilly added two new versions of - TIFFScanlineSize - - TIFFNewScanlineSize: proposed new version, after all related - issues and side-effects are sorted out - - TIFFOldScanlineSize: old version, from prior to 2006-03-21 change - This needs further sorting out. - -2006-03-25 Joris Van Damme - - * contrib/addtiffo/tif_ovrcache.c: bugfix to correctly pass size - of last truncated strip data to TIFFWriteEncodedStrip - -2006-03-25 Joris Van Damme - - * libtiff/{tif_jpeg.c, tif_strip.c}: bugfix of tif_jpeg decode raw - -2006-03-25 Joris Van Damme - - * libtiff/tif_getimage.c: bugfix/rewrite of putcontig8bitYCbCr22tile - - * libtiff/tif_getimage.c: added putcontig8bitYCbCr12tile - - * libtiff/tif_read.c: added support for new TIFF_NOREADRAW flag to - prepare the path for new tif_ojpeg.c - -2006-03-23 Andrey Kiselev - - * libtiff 3.8.2 released. - - * tools/Makefile.am: Use runtime paths linker flags when rpath - option enabled. - -2006-03-21 Andrey Kiselev - - * libtiff/libtiff.def: Added missed exports as per bug - http://bugzilla.remotesensing.org/attachment.cgi?id=337 - - * contrib/addtiffo/Makefile.vc, libtiff/Makefile.vc, port/Makefile.vc, - tools/Makefile.vc: Makefiles improvements as per bug - http://bugzilla.remotesensing.org/show_bug.cgi?id=1128 - - * nmake.opt libtiff/{tif_config.h.vc, tif_unix.c, tiffio.h}, - tools/{fax2ps.c, fax2tiff.c, tiff2pdf.c}: Fixed win32 I/O functions - usage as per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1127 - - * libtiff/tif_strip.c: Take subsampling in account when calculating - TIFFScanlineSize(). - - * tools/tiffcp.c: Do not set RowsPerStrip bigger than image length. - -2006-03-17 Andrey Kiselev - - * tools/fax2tiff.c: Fixed wrong TIFFerror() invocations as per bug - http://bugzilla.remotesensing.org/show_bug.cgi?id=1125 - - * tools/fax2ps.c: Fixed reading the input stream from stdin as per bug - http://bugzilla.remotesensing.org/show_bug.cgi?id=1124 - -2006-03-16 Andrey Kiselev - - * libtiff/tiffiop.h: Added decalration for - _TIFFSetDefaultCompressionState(). - - * libtiff/{tif_jpeg.c, tif_fax3.c, tif_zip.c, tif_pixarlog.c, - tif_lzw.c, tif_luv.c}: Use _TIFFSetDefaultCompressionState() in all - codec cleanup methods. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1120 - -2006-03-15 Andrey Kiselev - - * libtiff/tif_jpeg.c: Do not cleanup codec state in TIFFInitJPEG(). As - per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1119 - - * tools/raw2tiff.c: Do not set RowsPerStrip larger than ImageLength. - As per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1110 - - * libtiff/tiffiop.h: dblparam_t typedef removed; GLOBALDATA macro - removed; move here the STRIP_SIZE_DEFAULT macro definition. - - * libtiff/{tif_dirread.c, tif_strip.c}: Removed STRIP_SIZE_DEFAULT - macro definition. - - * libtiff/tif_dir.c: Use double type instead of dblparam_t. - -2006-03-14 Andrey Kiselev - - * libtiff/tif_dirread.c: Do not check the PlanarConfig tag presence - in TIFFReadDirectory, because it is always set at the start of - function and we allow TIFFs without that tag set. - -2005-03-13 Andrey Kiselev - - * libtiff 3.8.1 released. - -2006-03-07 Andrey Kiselev - - * libtiff/tif_dirread.c: Fixed error reporting in TIFFFetchAnyArray() - function as per bug - http://bugzilla.remotesensing.org/show_bug.cgi?id=1102 - - * libtiff/tif_dirread.c: More wise check for integer overflow - condition as per bug - http://bugzilla.remotesensing.org/show_bug.cgi?id=1102 - - * libtiff/{tif_jpeg.c, tif_pixarlog.c, tif_fax3.c, tif_zip.c}: - Properly restore setfield/getfield methods in cleanup functions. As - per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1102 - -2006-03-03 Andrey Kiselev - - * libtiff/{tif_predict.c, tif_predict.h}: Added new function - TIFFPredictorCleanup() to restore parent decode/encode/field methods. - - * libtiff/{tif_lzw.c, tif_pixarlog.c, tif_zip.c}: Use - TIFFPredictorCleanup() in codec cleanup methods. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1102 - - * libtiff/tif_dirread.c: Fixed integer overflow condition in - TIFFFetchData() function. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1102 - -2006-03-01 Andrey Kiselev - - * libtiff/tif_ojpeg.c: Set the ReferenceBlackWhite with the - TIFFSetField() method, not directly. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1043 - - * tools/ppm2tiff.c: Added support for PBM files as per bug - http://bugzilla.remotesensing.org/show_bug.cgi?id=1044 - -2006-02-27 Andrey Kiselev - - * libtiff/tif_write.c: Small code rearrangement in TIFFWriteScanline() - to avoid crash as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1081. - -2006-02-26 Andrey Kiselev - - * tools/tiff2pdf.c: Functions t2p_sample_rgbaa_to_rgb() and - t2p_sample_rgba_to_rgb() was used in place of each other, that was - resulted in problems with RGBA images with associated alpha. - As per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1097 - -2006-02-23 Andrey Kiselev - - * libtiff/tif_dirwrite.c: Properly write TIFFTAG_DOTRANGE tag as per - bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1088. - - * libtiff/tif_print.c: Properly read TIFFTAG_PAGENUMBER, - TIFFTAG_HALFTONEHINTS, TIFFTAG_YCBCRSUBSAMPLING and TIFFTAG_DOTRANGE - tags as per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1088. - - * tools/tiff2ps.c: Properly scale all the pages when converting - multipage TIFF with /width/height/center options set. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1080 - -2006-02-15 Andrey Kiselev - - * tools/tiff2pdf.c: Do not create output file until all option checks - will be done. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1072 - - * tools/bmp2tiff.c: Added ability to create multipage TIFFs from the - list of input files as per bug: - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1077 - -2006-02-09 Andrey Kiselev - - * libtiff/tif_tile.c: Fix error reporting in TIFFCheckTile() as per - bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1063. - - * tools/tiffgt.c: Avoid crashing in case of image unsupported by - TIFFRGBAImage interface. - - * libtiff/tif_color.c: Avoid overflow in case of wrong input as per - bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1065. - -2006-02-07 Frank Warmerdam - - * tools/tiff2pdf.c: Fixed support for non-YCbCr encoded JPEG - compressed TIFF files, per submission from Dan Cobra. - -2006-02-07 Andrey Kiselev - - * libtiff/{tif_dirread.c, tif_packbits.c, tif_win32.c}: Properly - cast values to avoid warnings. As per bug - http://bugzilla.remotesensing.org/show_bug.cgi?id=1033. - - * libtiff/tif_dirinfo.c: Use TIFF_NOTYPE instead of 0 when - appropriate. As per bug - http://bugzilla.remotesensing.org/show_bug.cgi?id=1033. - - * libtiff/tif_aux.c: Fixed type of temporary variable in - _TIFFCheckMalloc() as per bug - http://bugzilla.remotesensing.org/show_bug.cgi?id=1033. - -2006-02-06 Andrey Kiselev - - * libtiff/tif_aux.c: Return static array when fetching default - YCbCrCoefficients (another problem, reported a the - http://bugzilla.remotesensing.org/show_bug.cgi?id=1029 entry). - -2006-02-03 Andrey Kiselev - - * libtiff/tif_dir.c: Special handling for PageNumber, HalftoneHints, - YCbCrSubsampling and DotRange tags as per bugs - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1029 - http://bugzilla.remotesensing.org/show_bug.cgi?id=1034 - - * libtiff/tif_dirread.c: Use _TIFFGetExifFieldInfo() instead of - _TIFFGetFieldInfo() in TIFFReadEXIFDirectory() call as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1026. - -2006-01-23 Andrey Kiselev - - * libtool related stuff updated from the 2.1a branch. - -2006-01-11 Frank Warmerdam - - * tools/bmp2tiff,pal2rgb,ppm2tiff,ras2tiff,raw2tiff,sgi2tiff, - tiff2bw,tiffcp: Fixed jpeg option processing so -c jpeg:r:50 works - properly as per bug: - http://bugzilla.remotesensing.org/show_bug.cgi?id=1025 - -2006-01-09 Bob Friesenhahn - - * configure.ac: Fix with_default_strip_size comparison as reported - by Norihiko Murase. - -2006-01-08 Bob Friesenhahn - - * test/Makefile.am (LIBTIFF): Due to linking against libtiff - incorrectly, tests were not actually testing the uninstalled - libtiff. Now they are. - -2006-01-04 Andrey Kiselev - - * libtiff/tif_dirinfo.c: Change definitions for TIFFTAG_ICCPROFILE, - TIFFTAG_PHOTOSHOP, TIFFTAG_RICHTIFFIPTC, TIFFTAG_XMLPACKET: readcount - should be uint32 value. - -2006-01-02 Bob Friesenhahn - - * html/man/Makefile.am (htmldoc): Fix htmldoc rule so that it can - be used if build directory is not the same as source directory. - * man/{TIFFGetField.3tiff, TIFFSetField.3tiff}: Documented - TIFFTAG_PHOTOSHOP, TIFFTAG_RICHTIFFIPTC, and TIFFTAG_XMLPACKET, - and re-sorted tag names in alphabetical order. - -2005-12-29 Andrey Kiselev - - * libtiff 3.8.0 released. - -2005-12-28 Bob Friesenhahn - - * tools/bmp2tiff.c (main): Fixed warning regarding returning - inconsistent types from a condition. - * tools/tiffcmp.c (CheckLongTag): Eliminate warning due to printf - format. - * tools/bmp2tiff.c: Reduce compilation warnings on big-endian CPUs. - -2005-12-28 Joris Van Damme - - * html/{index.html, support.hml, libtiff.html}: Cleaned up HTML - -2005-12-27 Andrey Kiselev - - * libtiff/tiffio.h: Added VC_EXTRALEAN definition before including - windows.h, to reduce the compile time. - -2005-12-26 Bob Friesenhahn - - * libtiff/tif_jpeg.c: Improve compilation under MinGW. - -2005-12-26 Andrey Kiselev - - * libtiff/{tif_dir.c, tif_dir.h, tif_dirread.c, tif_dirinfo.c}: - tiffFieldInfo and exifFieldInfo arrays definitions moved back to - tif_dirinfo.c; added _TIFFGetFieldInfo() and _TIFFGetExifFieldInfo() - private functions to retrieve FieldInfo arrays. - -2005-12-24 Bob Friesenhahn - - * html/build.html: Added some additional instructions for when - building using MSVC under Windows. Also fixed two HTML syntax - errors and used HTML Tidy to tidy up the HTML syntax and - formatting. - -2005-12-24 Andrey Kiselev - - * libtiff/{tif_aux.c, tif_dir.c, tif_dir.h, tif_dirwrite.c, - tif_print.c, tif_getimage.c}: Make InkSet, NumberOfInks, DotRange and - StoNits tags custom. - -2005-12-23 Andrey Kiselev - - * libtiff/{tif_aux.c, tif_dir.c, tif_dir.h, tif_print.c}: Make - WhitePoint tag custom. - - * libtiff/{tif_dir.h, tiff.h}: More EXIF tags added. - -2005-12-23 Joris Van Damme - - * libtiff/tiffio.h: fixed typo that potentially resulted in - redefininition of USE_WIN32_FILEIO - - * libtiff/*: Added more 'dual-mode' error handling: Done TIFFWarning - calls in core LibTiff. - -2005-12-21 Andrey Kiselev - - * libtiff/{tif_dir.c, tif_dir.h, tif_print.c}: Make RichTIFFIPTC, - Photoshop and ICCProfile tags custom. - -2005-12-21 Joris Van Damme - - * libtiff/*, contrib/*: Added 'dual-mode' error handling, enabling - newer code to get context indicator in error handler and still - remain compatible with older code: Done TIFFError calls everywhere - except in tools - -2005-12-20 Andrey Kiselev - - * tools/tiffcp.c: Added many error reporting messages; fixed integer - overflow as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=789 - -2005-12-16 Frank Warmerdam - - * contrib/addtiffo/*: Major upgrade by Joris to support subsampled - YCbCr images in jpeg compressed TIFF files. - -2005-12-14 Andrey Kiselev - - * tools/tiffcp.c: Return non-zero status when reading fails (again). - -2005-12-13 Andrey Kiselev - - * tools/tiffcp.c: Return non-zero status when reading fails. - -2005-12-12 Andrey Kiselev - - * libtiff/{tif_dir.h, tiff.h}: Added more EXIF tags. - -2005-12-09 Andrey Kiselev - - * libtiff/{tif_dir.c, tif_dir.h, tif_print.c}: Make XMLPacket tag - custom. - - * tools/tiffinfo.c: Print EXIF directory contents if exist. - - * libtiff/tiff.h: Few EXIF tag numbers added. - - * libtiff/{tif_dirinfo.c, tif_dirread.c, tif_dir.h, tif_dir.c, - tiffio.h}: Preliminary support to read custom directories. New - functions: TIFFReadCustomDirectory() and TIFFReadEXIFDirectory(). - -2005-12-07 Andrey Kiselev - - * libtiff/{tif_dirinfo.c, tif_dirread.c, tif_dir.h, tif_dir.c}: - More work to implement custom directory read support. - - * libtiff/{tif_aux.c, tif_dirinfo.c, tif_dirread.c, tif_dir.h, - tif_dir.c, tif_print.c}: Make YCbCrCoefficients and ReferenceBlackWhite - tags custom. - -2005-12-05 Andrey Kiselev - - * libtiff/tif_dirread.c: One more workaround for broken - StripByteCounts tag. Handle the case when StripByteCounts array filled - with completely wrong values. - -2005-11-30 Andrey Kiselev - - * libtiff/tif_dirinfo.c: Release file descriptor in case of failure - in the TIFFOpenW() function as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1003 - - * libtiff/tif_dirinfo.c: Correctly yse bsearch() and lfind() - functions as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=1008 - -2005-11-20 Frank Warmerdam - - * tif_open.c, tiff.h, tiffdump.c: Incorporate preliminary support - for MS MDI format. - http://bugzilla.remotesensing.org/show_bug.cgi?id=1002 - - * .cvsignore: many files added, and a few update according - to suggestion of Brad HArds on tiff mailing list. - -2005-11-03 Frank Warmerdam - - * libtiff/libtiff.def, tiffiop.h, tiffio.h: Made TIFFFreeDirectory - public. - -2005-10-31 Andrey Kiselev - - * tools/fax2tiff.c: Properly calculate sizes of temporary arrays - as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=943 - - * tools/fax2tiff.c: Added option '-r' to set RowsPerStrip parameter - as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=944 - - * tools/tiffdump.c: Fixed typeshift and typemask arrays initialization - problem as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=946 - - * tools/bmp2tiff.c: Fixed possible integer overflow error as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=965 - - * libtiff/tif_dirinfo.c: Make XResolution, YResolution and - ResolutionUnit tags modifiable during write process. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=977 - - * tools/tiffsplit.c: Copy fax related fields over splitted parts - as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=983 - -2005-10-21 Frank Warmerdam - - * tif_dirread.c: Don't try and split single strips into "0" strips - in ChopUpSingleUncompressedStrip. This happens in some degenerate - cases (like 1x1 files with stripbytecounts==0 (gtsmall.jp2 embed tiff) - -2005-10-20 Joris Van Damme - - * tif_fax3.c: changed 'at scanline ...' style warning/errors - with incorrect use of tif_row, to 'at line ... of - strip/tile ...' style - -2005-10-15 Frank Warmerdam - - * tif_write.c: fixed setting of planarconfig as per bug report - on the mailing list from Joris. - -2005-10-07 Andrey Kiselev - - * configure.ac, configure, nmake.opt, libtiff/{tif_config.h, - tif_dirread.c}: Make the default strip size configurable via the - --with-default-strip-size and STRIP_SIZE_DEFAULT options. - -2005-09-30 Bob Friesenhahn - - * html/support.html: Fixed link to documentation on Greg Ward's - LogLuv TIFF format. - -2005-09-28 Andrey Kiselev - - * tools/tiffdump.c: Fixed crash when reading malformed tags. - -2005-09-20 Andrey Kiselev - - * tools/tiff2pdf.c: Added missed 'break' statement as per bug - http://bugzilla.remotesensing.org/show_bug.cgi?id=932 - -2005-09-12 Andrey Kiselev - - * libtiff 3.7.4 released. - - * {configure, configure.ac, Makefile.am, autogen.sh}: Applied patch - from Patrick Welche (all scripts moved in the 'config' and 'm4' - directories). - -2005-09-12 Frank Warmerdam - - * libtiff/tif_open.c: reintroduce seek to avoid problem on solaris. - -2005-09-05 Frank Warmerdam - - * libtiff/tif_dir.c: When prefreeing tv->value in TIFFSetFieldV - also set it to NULL to avoid double free when re-setting custom - string fields as per: - - http://bugzilla.remotesensing.org/show_bug.cgi?id=922 - -2005-08-12 Frank Warmerdam - - * libtiff/tif_print.c: avoid signed/unsigned warning. - - * libtiff/tif_dirread.c: removed unused variable. - -2005-07-30 Frank Warmerdam - - * libtiff/tif_dir.c: Fixed up support for swapping "double complex" - values (128 bits as 2 64 bits doubles). GDAL gcore tests now - pass on bigendian (macosx) system. - -2005-07-28 Andrey Kiselev - - * libtiff/{tif_aux.c, tif_dirread.c, tif_fax3.c, tiffiop.h}: Rename - CheckMalloc() function to _TIFFCheckMalloc() and make it available - globally as an internal helper routine. - -2005-07-27 Andrey Kiselev - - * libtiff/tif_dir.c: More improvements in the "pass by value" part of - the custom tags handling code. - -2005-07-26 Andrey Kiselev - - * libtiff/{tif_dirread.c, tif_dirinfo.c}: Do not upcast BYTEs to - SHORTs in the TIFFFetchByteArray(). Remove TIFFFetchExtraSamples() - function, use TIFFFetchNormalTag() instead as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=831 - - Remove TIFFFetchExtraSamples() function, use TIFFFetchNormalTag() - instead. - - * libtiff/tiffconf.h.in: One more attempt to fix the AIX bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=39 - -2005-07-25 Andrey Kiselev - - * libtiff/tif_print.c: Fixed printing of the BYTE and SBYTE arrays. - - * tools/tiffdump.c: Added support for TIFF_IFD datatype. - -2005-07-21 Andrey Kiselev - - * libtiff/tif_write.c: Do not check the PlanarConfiguration field in - the TIFFWriteCheck() function in case of single band images (as per - TIFF spec). - -2005-07-12 Andrey Kiselev - - * SConstruct, libtiff/SConstruct: Added the first very preliminary - support for SCons software building tool (http://www.scons.org/). - This is experimental infrastructure and it will exist along with the - autotools mechanics. - -2005-07-07 Andrey Kiselev - - * port/{getopt.c, strcasecmp.c, strtoul.c}: Update modules from - the NetBSD source tree (the old 4-clause BSD license changed to - the new 3-clause one). - - * configure.ac, port/lfind.c, libtiff/tiffiop.h: Added lfind() - replacement module. - - * port/dummy.c: Make the dummy function static. - -2005-07-06 Andrey Kiselev - - * tools/tiffcp.c: Fixed WhitePoint tag copying. - - * libtiff/{tif_dir.c, tif_dir.h, tif_dirinfo.c, tif_print.c}: - Make FieldOfViewCotangent, MatrixWorldToScreen, MatrixWorldToCamera, - ImageFullWidth, ImageFullLength and PrimaryChromaticities tags custom. - -2005-07-04 Andrey Kiselev - - * libtiff 3.7.3 released. - - * configure, configure.ac: Do not use empty -R option when linking - with --enable-rpath. - -2005-07-01 Andrey Kiselev - - * libtiff/{tiffiop.h, tif_open.c}: Added open option 'h' to avoid - reading the first IFD when needed. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=875 - - * libtiff/tif_color.c: Better use of TIFFmin() macro to avoid side - effects. - -2005-06-23 Andrey Kiselev - - * tools/tiff2pdf.c: Print two characters per loop in the - t2p_write_pdf_trailer(). As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=594 - - * tools/tiffgt.c: Use MacOS X OpenGL framework when appropriate. As - per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=844 - - * acinclude.m4: Updated to latest OpenGL test macros versions. - - * libtiff/tiff.h: Use correct int size on Sparc 64bit/Sun compiler - platform. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=855 - -2005-06-14 Andrey Kiselev - - * libtiff/tif_dirinfo.c: Added support for ClipPath, XClipPathUnits - and YClipPathUnits tags. - -2005-06-07 Andrey Kiselev - - * contrib/addtiffo/tif_ovrcache.c: Properly extract tile/strip size; - use pixel sized shift in contigous case. - -2005-06-06 Andrey Kiselev - - * contrib/addtiffo/{tif_overview.c, tif_ovrcache.c, tif_ovrcache.h}: - Make overviews working for contiguos images. - -2005-06-03 Andrey Kiselev - - * libtiff/tif_open.c: Replace runtime endianess check with the compile - time one. - - * libtiff/tif_predict.c: Floating point predictor now works on - big-endian hosts. - -2005-06-01 Andrey Kiselev - - * libtiff/tif_dir.c: Use _TIFFsetString() function when read custom - ASCII values. - - * libtiff/{tif_dirinfo.c, tif_dir.h, tif_dir.c, tif_print.c}: Make - DocumentName, Artist, HostComputer, ImageDescription, Make, Model, - Copyright, DateTime, PageName, TextureFormat, TextureWrapModes and - TargetPrinter tags custom. - - * libtiff/tif_jpeg.c: Cleanup the codec state depending on - TIFF_CODERSETUP flag (to fix memry leaks). - - * libtiff/tif_jpeg.c: Initialize JPEGTables array with zero after - allocating. - -2005-05-26 Andrey Kiselev - - * configure.ac, libtiff/Makefile.am: Added workaround for - OpenBSD/MirOS soname problem as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=838 - - * libtiff/tif_dirwrite.c: Use tdir_count when calling - TIFFCvtNativeToIEEEDouble() in the TIFFWriteDoubleArray() function as - per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=845 - -2005-05-25 Andrey Kiselev - - * tools/ppm2tiff.c: Fixed format string when read PPM file header with - the fscanf() function. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=861 - - * libtiff/{tif_dirinfo.c, tif_print.c}: TIFFFetchByteArray() returns - uint16 array when fetching the BYTE and SBYTE filds, so we should - consider result as pointer to uint16 array and not as array of chars. - As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=831 - - * libtiff/tif_dir.c: More efficient custom tags retrieval as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=830 - - * libtiff/tif_win32.c: Use FILE_SHARE_READ | FILE_SHARE_WRITE share - mode in CreateFile() call as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=829 - - * libtiff/Makefile.am: Fixed parallel compilation of the libtiff and - libtiffxx libraries as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=826 - - * contrib/addtiffo/{tif_overview.c, tif_ovrcache.h}: Sinchronized with - GDAL. - -2005-05-23 Frank Warmerdam - - * libtiff/tif_jpeg.c: Substantial fix for addtiffo problems with - JPEG encoded TIFF files. Pre-allocate lots of space for jpegtables - in directory. - -2005-05-22 Frank Warmerdam - - * libtiff/tif_dirread.c: Changed the code that computes - stripbytecount[0] if it appears bogus to ignore if stripoffset[0] is - zero. This is a common case with GDAL indicating a "null" tile/strip. - -2005-05-17 Andrey Kiselev - - * tools/tiffsplit.c: Check for JPEGTables tag presence before copying. - -2005-05-06 Frank Warmerdam - - * libtiff/tif_dirread.c: Applied similar change to - TIFFFetchPerSampleLongs and TIFFFetchPerSampleAnys. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=843 - - * libtiff/tif_jpeg.c: added LIB_JPEG_MK1 support in JPEGDecodeRaw(). - -2005-05-06 Andrey Kiselev - * tools/tiff2pdfr.c, man/tiff2pdf.1: Calculate the tile width properly; - added new option '-b' to use interpolation in output PDF files (Bruno - Ledoux). - -2005-05-05 Frank Warmerdam - - * libtiff/tif_dirread.c: Ensure that broken files with too many - values in PerSampleShorts work ok instead of crashing. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=843 - -2005-04-27 Andrey Kiselev - - * tools/tiffdither.c: Copy the PhotometricInterpretation tag from the - input file. - -2005-04-15 Andrey Kiselev - - * libtiff/tif_predict.c: Added ability to encode floating point - predictor, as per TIFF Technical Note 3. - -2005-04-14 Andrey Kiselev - - * libtiff/{tif_predict.h, tif_predict.c}: Added ability to decode - floating point predictor, as per TIFF Technical Note 3. - -2005-04-13 Andrey Kiselev - - * libtiff/{tiffio.h, tiffiop.h, tif_dir.c, tif_read.c, tif_swab.c}: - Added _TIFFSwab24BitData() and TIFFSwabArrayOfLong() functions used to - swap 24-bit floating point values. - - * libtiff/tiff.h: Added predictor constants. - -2005-04-08 Andrey Kiselev - - * libtiff/{tiffiop.h, tif_dir.c}: Use uint32 type for appropriate - values in _TIFFVSetField() function. Inspired by the bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=816 - - * man/TIFFSetField.3tiff: Fixed definition of the TIFFTAG_INKNAMES tag - as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=816 - -2005-03-30 Andrey Kiselev - - * libtiff/tif_open.c: Do not read header in case the output file - should be truncated (Ron). - - * libtiff/{tif_dirinfo.c, tif_config.h.vc}: Use lfind() instead - of bsearch() in _TIFFFindFieldInfoByName() function (Ron). - - * libtiff/{tiff.h, tif_dirinfo.c}: Fixes in EXIF tag ordering (Ron). - -2005-03-22 Andrey Kiselev - - * configure.ac, libtiff/Makefile.am: Use libtool machinery to pass - rpath option. - -2005-03-21 Andrey Kiselev - - * libtiff/{tif_dir.c, tif_print.c}: Handle all data types in custom - tags. - -2005-03-18 Andrey Kiselev - - * libtiff/dirinfo.c: Added DNG tags. - - * libtiff/{tif_dir.c, tif_print.c}: More improvements in custom tag - handling code. - - * libtiff/tiff.h: More comments; added missed DNG tag (LensInfo); - added DNG 1.1.0.0 tags. - - * tools/tif2pdf.c: Fixed problem with alpha channel handling as per - bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=794 - - * man/TIFFGetField.3tiff: Add a note about autoregistered tags. - -2005-03-17 Andrey Kiselev - - * nmake.opt: Build with Win32 CRT library by default. - - * tools/tiff2ps.c: Fixed typo in page size handling code. - - * libtiff/{tif_dir.c, tif_print.c}: Support for custom tags, passed - by value. - - * libtiff/{tiff.h, tif_dirinfo.c, tiffiop.h}: Added EXIF related tags. - -2005-03-15 Andrey Kiselev - - * libtiff 3.7.2 released. - -2005-03-09 Andrey Kiselev - - * tools/tiffcmp.c: Added ability to compare the 32-bit integer and - floating point data; complain on unsupported bit depths. - -2005-03-05 Andrey Kiselev - - * tif_stream.cxx: Use ios namespace instead of ios_base to support - GCC 2.95. - - * libtiff/{tiff.h, tif_fax3.tif, tif_jpeg.c}: Applied correct patch from - Lee Howard for HylaFax DCS tag - (see http://bugzilla.remotesensing.org/show_bug.cgi?id=771) - -2005-03-04 Andrey Kiselev - - * configure, configure.ac: Use -rpath option instead of -R as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=732 - - * libtiff/{tiff.h, tif_fax3.tif, tif_jpeg.c}: Applied patch from Lee - Howard to support a new tag TIFFTAG_FAXDCS (34911) used in HylaFax - software. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=771 - - * nmake.opt, html/build.html: Add more comments, change the config - file organization a bit as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=764 - - * tools/tiffcmp.c: Use properly sized buffer in short arrays comparison - as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=785 - -2005-03-03 Andrey Kiselev - - * libtiff/tif_dirread.c: More logic to guess missed strip size as per - bug http://bugzilla.remotesensing.org/show_bug.cgi?id=705 - - * tools/fax2ps.c: Replace insecure mktemp() function with the - tmpfile() as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=786 - -2005-02-04 Andrey Kiselev - - * libtiff/tiff.h: Changed the int8 definition to be always signed char - as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=727 - - * libtiff/tiffio.h: Move TIFFOpenW() function into the extern "C"{} - block as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=763 - -2005-02-03 Bob Friesenhahn - - * tools/tiffgt.c: Fix problem on big-endian CPUs so that images - display more correctly. Images display brighter than they should - on a Sun workstation. - -2005-02-03 Andrey Kiselev - - * libtiff/tif_dirread.c: Estimate strip size in case of wrong or - suspicious values in the tags. As per bugs - - http://bugzilla.remotesensing.org/show_bug.cgi?id=705 - - and - - http://bugzilla.remotesensing.org/show_bug.cgi?id=320 - - * tools/tiff2ps.c: Fixed problem with page sizes as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=742 - -2005-01-31 Bob Friesenhahn - - * libtiff/tiff.h (TIFFTAG_TILEWIDTH): Corrected description. - (TIFFTAG_TILELENGTH): Corrected description. - -2005-01-30 Andrey Kiselev - - * configure.ac: Fixes for --with-docdir option as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=759 - - * libtiff/tif_open.c: Remove unnesessary TIFFSeekFile() call as per - bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=756 - - * libtiff/tif_stream.cxx: Fixes for C++ stream interface from - Michael Rinne and Edward Lam. - -2005-01-15 Andrey Kiselev - - * configure.ac: Make the documentation directory location configurable - via the --with-docdir option (as suggested by Jeremy C. Reed). - - * libtiff/tif_color.c: Use double as the second argument of pow() - function in TIFFCIELabToRGBInit(). As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=741 - - * libtiff/tif_pixarlog.c: Avoid warnings when converting float to - integer as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=740 - - * libtiff/tif_getimage.c: Always fill the error message buffer in - TIFFRGBAImageBegin() as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=739 - -2005-01-12 Andrey Kiselev - - * libtiff/tif_jpeg.c: Added ability to read/write the fax specific - TIFFTAG_FAXRECVPARAMS, TIFFTAG_FAXSUBADDRESS and TIFFTAG_FAXRECVTIME - tags as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=736 - - * libtiff/tif_win32.c: Fixed message formatting in functions - Win32WarningHandler() and Win32ErrorHandler() as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=735 - - * tools/tiff2ps.c: Interpret the -w and -h options independently. As - per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=689 - -2005-01-11 Andrey Kiselev - - * libtiff/tiffio.h: Move the color conversion routines in the 'extern - "C"' section as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=727 - - * libtiff/tiff.h: Restore back the workaround for AIX Visual Age C - compiler to avoid double definition of BSD types as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=39 - - * libtiff/Makefile.am: Place the C++ stream API in the separate - library called libtiffxx to avoid unneeded dependencies. Probably - there will be more C++ API in the future. As per bugs - - http://bugzilla.remotesensing.org/show_bug.cgi?id=733 - - and - - http://bugzilla.remotesensing.org/show_bug.cgi?id=730 - -2005-01-05 Andrey Kiselev - - * tools/tiffdump.c: Fixed problem when read broken TIFFs with the - wrong tag counts (Dmitry V. Levin, Martin Pitt). - - * configure.ac: Replace --disable-c++ with the --disable-cxx option as - per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=730 - -2004-12-25 Andrey Kiselev - - * libtiff/tif_getimage.c: More fixes for multiple-alpha-channelled - RGB-images as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=713 - - - * tools/tiffset.c: Convert character option to integer value as per - bug http://bugzilla.remotesensing.org/show_bug.cgi?id=725 - -2004-12-20 Andrey Kiselev - - * libtiff 3.7.1 released. - - * html/tiffset.1.html: Add missed manual page as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=678 - - * libtiff/tiff.h: Revert back libtiff data type definitions as per - bug http://bugzilla.remotesensing.org/show_bug.cgi?id=687 - -2004-12-19 Andrey Kiselev - - * libtiff/tif_dirread.c: Do not forget about TIFF_VARIABLE2 when - checking for tag count in TIFFReadDirectory() function. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=713 - - * libtiff/{tif_dirread.c, tif_fax3.c}: More argument checking in - CheckMallock() function. - - * libtiff/tif_getimage.c: Support for multiple-alpha-channelled - RGB-images as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=718 - -2004-12-15 Frank Warmerdam - - * libtiff/tif_getimage.c: #define A1 bracketing for clean build on - SunPro compiler. - -2004-12-11 Bob Friesenhahn - - * autogen.sh: aclocal and autoheader should be executed after - libtoolize. Also add '-I .' to aclocal invocation to check - current directory for macros. - -2004-12-10 Andrey Kiselev - - * libtiff/tif_dirwrite.c: Always write TIFFTAG_SUBIFD using LONG type - as per bugs - - http://bugzilla.remotesensing.org/show_bug.cgi?id=703 - - and - - http://bugzilla.remotesensing.org/show_bug.cgi?id=704 - -2004-12-04 Andrey Kiselev - - * nmake.opt: Link with the user32.lib in windowed mode. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=697 - - * libtiff/tif_win32.c: Use char* strings instead of TCHAR in windowed - mode as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=697 - - * libtiff/tif_config.in.vc: Removed unneded definitions for - read/open/close/lseek functions to fix the - - http://bugzilla.remotesensing.org/show_bug.cgi?id=680 - -2004-12-03 Andrey Kiselev - - * libtiff/{tif_dir.c, tif_dirread.c}: Remove TIFFReassignTagToIgnore() - call from the TIFFReadDirectory() function. TIFFReassignTagToIgnore - must be removed in the future, as it was never used properly. As per - bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=692 - -2004-11-30 Bob Friesenhahn - - * libtiff/tif_jpeg.c: Added a work-around in order to allow - compilation with the heavily modified version of libjpeg delivered - with Cygwin. - -2004-11-29 Andrey Kiselev - - * libtiff/tif_dir.c: Properly handle tags, which have the uint32 - counts. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=693 - - * tools/fax2ps.c: Be able to extract the first page (#0). As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=690 - -2004-11-28 Andrey Kiselev - - * libtiff/tif_unix.c: Make UNIX module compilable (and usable) - on Windows. - - * nmake.opt: Add missed DLLNAME variable. - -2004-11-26 Frank Warmerdam - - * libtiff/makefile.vc: make it easier to rename the libtiff DLL. - -2004-11-24 Andrey Kiselev - - * man/libtiff.3tiff: Improvements in the "LIST OF ROUTINES" table as - per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=545 - - * man/tiffset.1: Added manual page for tiffset tool written by Jay - Berkenbilt. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=678 - -2004-11-23 Frank Warmerdam - - * libtiff/tif_error.c: fixed TIFFerror call to be TIFFError. - -2004-11-21 Frank Warmerdam - - * html/document.html: Updated Adobe web links as per email from Joris. - -2004-11-21 Andrey Kiselev - - * libtiff/{tiffio.hxx, tiffio.h}: C++ stream interface moved to new - file tiffio.hxx. We don't have any C++ in tiffio.h, those who want to - use C++ streams should #include . - -2004-11-13 Andrey Kiselev - - * libtiff/tiff.h: Added Adobe DNG tags. - - * libtiff/tif_win32.c: Typo fixed. - - * libtiff/{tif_stream.cxx, tiffio.h}: C++ stream interface updated to - be compliant with the latest standard. Appropriate additions in - makefiles now completed. - -2004-11-11 Andrey Kiselev - - * tools/tiffset.c, libtiff/tif_dirinfo.c: Properly handle the - different tag types. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=600 - -2004-11-10 Andrey Kiselev - - * libtiff/tif_aux.c: Set the appropriate ReferenceBlackWhite array for - YCbCr image which lacks that tag (noted by Hans Petter Selasky). - -2004-11-09 Andrey Kiselev - - * libtiff/tif_color.c: Division by zero fixed (Hans Petter Selasky). - -2004-11-07 Andrey Kiselev - - * libtiff/{tif_stream.cxx, tiffio.h}: Added C++ stream interface - contributed by Edward Lam (see - http://bugzilla.remotesensing.org/show_bug.cgi?id=654 for details). - Though no changes in any makefiles yet. - -2004-11-05 Frank Warmerdam - - * libtiff/tif_open.c: Removed close() in TIFFClientOpen() if file - is bad. This is the callers responsibility. - http://bugzilla.remotesensing.org/show_bug.cgi?id=651 - -2004-11-05 Andrey Kiselev - - * libtiff/{tiffio.h, tif_win32.c, libtiff.def}: Added TIFFOpenW() - function to work with the double byte strings (used to represent - filenames in some locales). As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=625 - - * libtiff/tif_dirread.c: Fixed problem when fetching BitsPerSample and - Compression tags of type LONG from broken TIFFS as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=662 - - * libtiff/tif_dirinfo.c: Fixed definition for TIFFTAG_RICHTIFFIPTC, - the writecount should have uint32 type. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=662 - - * libtiff/tif_write.c: Fixed wrong if() statement in - TIFFAppendToStrip() function as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=660 - -2004-11-04 Andrey Kiselev - - * libtiff/tif_dirinfo.c: Change definition for TIFFTAG_EXTRASAMPLES - field. The caller should supply a count when setting this field. As - per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=648 - - * libtiff/{tif_jpeg.c, tif_ojpeg.c}: TIFFTAG_JPEGTABLES should have - uint32 count. Use this type everywhere. - -2004-11-03 Frank Warmerdam - - * libtiff/tif_next.c: avoid use of u_long and u_char types. Bug 653. - -2004-11-02 Frank Warmerdam - - * tools/tiff2rgba.c: removed extra newlines in usage message. - -2004-10-30 Andrey Kiselev - - * libtiff/tif_dirwrite.c: Improvements in tag writing code. - - * tools/tiff2ps.c: Fixed wrong variable data type when read Position - tags (Tristan Hill). - -2004-10-30 Frank Warmerdam - - * libtiff/tiffiop.h: added fallback definition of assert() if we - don't have assert.h. - -2004-10-29 Andrey Kiselev - - * libtiff/tif_fax3.c: Fixed case with the wrong decode routines - choosing when the incorrect Group4Options tag set. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=323 - - * libtiff/tif_dirwrite.c: Fixed problem with passing count variable of - wrong type when writing the TIFF_BYTE/TIFF_SBYTE tags in - TIFFWriteNormalTag(). - -2004-10-28 Andrey Kiselev - - * tools/tiff2ps.c: Fixed wrong variable data type when read Resolution - tags (Peter Fales). - - * tools/{bmp2tiff.c, raw2tiff.c}: Get rid of stream I/O functions. - -2004-10-28 Frank Warmerdam - - * tools/tiff2pdf.c: added casts to avoid warnings. - - * libtiff/libtiff.def: Added several more entry points required - to link fax2tiff.c against the DLL on windows. - -2004-10-27 Andrey Kiselev - - * configure, configure.ac: Added --enable-rpath option to embed linker - paths into library binary. - -2004-10-26 Andrey Kiselev - - * tools/tiffset.c: Check the malloc return value (Dmitry V. Levin). - - * libtiff/{tif_strip.c, tif_tile.c}: Zero division problem fixed - (Vladimir Nadvornik, Dmitry V. Levin). - -2004-10-16 Andrey Kiselev - - * libtiff 3.7.0 released. - -2004-10-15 Bob Friesenhahn - - * libtiff/tif_jpeg.c: There seems to be no need to include stdio.h - in this file so its inclusion is removed. Including stdio.h - sometimes incurs an INT32 typedef conflict between MinGW's - basetsd.h and libjpeg's jmorecfg.h. - -2004-10-15 Andrey Kiselev - - * man/bmp2tiff.1: Added manual page for bmp2tiff utility. - -2004-10-13 Bob Friesenhahn - - * tools/tiffcmp.c (leof): Renamed from 'eof' in order to avoid - conflict noticed under MinGW. - * ltmain.sh: Fix for MinGW compilation. - -2004-10-13 Frank Warmerdam - - * man/tiffsplit.1: Fixed to indicate using aaa-zzz, not aa-zz. - http://bugzilla.remotesensing.org/show_bug.cgi?id=635 - -2004-10-12 Andrey Kiselev - - * libtiff/{tif_dirread.c, tif_jpeg.c, tif_luv.c, tif_ojpeg.c, - tif_pixarlog.c, tif_write.c}: Handle the zero strip/tile sizes - properly (Dmitry V. Levin, Marcus Meissner). - -2004-10-11 Andrey Kiselev - - * libtiff/tif_dirinfo.c: Type of the TIFFTAG_SUBIFD field changed - to TIFF_IFD. - -2004-10-10 Andrey Kiselev - - * tools/bmp2tif.c: Check the space allocation results. - -2004-10-09 Andrey Kiselev - - * libtiff/tif_dir.c: Initialize td_tilewidth and td_tilelength fields - of the TIFFDirectory structure with the 0 instead of -1 to avoid - confusing integer overflows in TIFFTileRowSize() for striped images. - - * tools/tiff2pdf.c: Fixed TransferFunction tag handling reported - by Ross A. Finlayson. - - * libtiff/tif_dir.c: Fixed custom tags handling as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=629 - -2004-10-08 Frank Warmerdam - - * libtiff/tif_dirinfo.c: Fix bug with tif_foundfield and reallocation - of tif_fieldinfo. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=630 - -2004-10-04 Bob Friesenhahn - - * contrib/iptcutil/README: Added the missing README which goes - along with iptcutil. - -2004-10-03 Andrey Kiselev - - * libtiff/tif_compress.c: Improved error reporting in - TIFFGetConfiguredCODECs() (Dmitry V. Levin). - -2004-10-02 Andrey Kiselev - - * libtiff 3.7.0beta2 released. - - * libtiff/{tif_aux.c, tif_compress.c, tif_dirinfo.c, tif_dirwrite.c, - tif_extension.c, tif_fax3.c, tif_luv.c, tif_packbits.c, - tif_pixarlog.c, tif_write.c}: Added checks for failed memory - allocations and integer overflows (Dmitry V. Levin). - - * libtiff/tiff.h: Missed TIFF_BIGTIFF_VERSION constant added. - -2004-10-01 Frank Warmerdam - - * libtiff/tif_open.c: added a more informative message if a BigTIFF - file is opened. - -2004-09-30 Frank Warmerdam - - * libtiff/tif_dirinfo.c: changed type of XMLPacket (tag 700) to - TIFFTAG_BYTE instead of TIFFTAG_UNDEFINED to comply with the info - in the Adobe XMP Specification. - -2004-09-29 Andrey Kiselev - - * libtiff/{tif_jpeg.c, tif_pixarlog.c}: Use _TIFFmemset() instead of - memset(). - - * libtiff/{tif_dirread.c, tif_strip.c, tif_tile.c}: Applied patches - from Dmitry V. Levin to fix possible integer overflow problems. - -2004-09-28 Andrey Kiselev - - * libtiff/tif_getimage.c: Check for allocated buffers before clearing - (Dmitry V. Levin). - -2004-09-26 Andrey Kiselev - - * libtiff/{tif_dir.h, tif_dir.c, tif_dirread.c, tif_write.c}: - Optimize checking for the strip bounds. - - * libtiff/{tif_dirread.c, tif_strip.c}: TIFFScanlineSize() and - TIFFRasterScanlineSize() functions report zero in the case of integer - overflow now. Properly handle this case in TIFFReadDirectory() - (patches from Dmitry V. Levin). - -2004-09-25 Andrey Kiselev - - * libtiff/{tif_dirinfo.c, tif_strip.c, tif_tile.c}: Use TIFFhowmany8() - macro where appropriate. - - * tools/tiff2bw.c: Write ImageWidth/Height tags to output file, as - noted by Gennady Khokhorin. - - * libtiff/tif_dirread.c: Always check the return values, returned - by the _TIFFmalloc() (Dmitry V. Levin). - - * libtiff/tif_dir.c: Fixed possible integer overflow _TIFFset*Array() - functions (Dmitry V. Levin). - - * libtiff/{tif_dirread.c, tif_dir.c, tif_write.c}: - Potential memory leak fixed in TIFFReadDirectory(), _TIFFVSetField(), - TIFFGrowStrips() (found by Dmitry V. Levin). - -2004-09-24 Andrey Kiselev - - * libtiff/{tiffio.h, tif_compress.c}: Added TIFFGetConfiguredCODECs() - to get the list of configured codecs. - - * libtiff/{tiffiop.h, tif_dirread.c}: More overflow fixes from - Dmitry V. Levin. - -2004-09-23 Andrey Kiselev - - * libtiff/tif_dirread.c: Applied patch from Dmitry V. Levin to fix - possible integer overflow in CheckMalloc() function. - -2004-09-22 Andrey Kiselev - - * libtiff/{tiffiop.h, tif_strip.c}: Use TIFFhowmany8() macro instead - of plain TIFFhowmany() where appropriate. - -2004-09-21 Andrey Kiselev - - * libtiff/tif_getimage.c: Initialize arrays after space allocation. - -2004-09-19 Andrey Kiselev - - * libtiff 3.7.0beta released. - - * libtiff/{tif_luv.c, tif_next.c, tif_thunder.c}: Several buffer - overruns fixed, as noted by Chris Evans. - -2004-09-14 Bob Friesenhahn - - * commit: Added a script to make it more convenient to commit - updates. The CVS commit message is extracted from this ChangeLog - file. - -2004-09-14 Andrey Kiselev - - * configure.ac, configure, aclocal.m4, libtiff/{mkspans.c, tif_fax3.c, - tif_getimage.c, tif_luv.c, tif_lzw.c, tif_ojpeg.c, tif_packbits.c, - tif_predict.c, tif_read.c, tif_swab.c, tif_thunder.c, tif_write.c, - tif_dir.c, tif_dirread.c, tif_dirwrite.c, tif_jpeg.c, tif_dirinfo.c, - tif_vms.c, tif_print.c, tif_strip.c, tif_tile.c, tif_dir.h, - tif_config.h.in, tiffiop.h}: - Get rid of BSD data types (u_char, u_short, u_int, u_long). - -2004-09-13 Bob Friesenhahn - - * libtiff/tiff.h: Fix column tagging. Reference current Adobe XMP - specification. Reference libtiff bug tracking system to submit - private tag additions. - -2004-09-12 Bob Friesenhahn - - * tools/tiffgt.c: Include "tif_config.h". - - * configure.ac: Use AM_PROG_CC_C_O since it is now needed to build - tiffgt. This results in the 'compile' script being added to the - project. - - * tools/Makefile.am (tiffgt_CFLAGS): Add extra build options - required to find OpenGL headers necessary to build tiffgt. Also - ensure that the libtiff that we built is used rather than some other - libtiff installed on the system. - -2004-09-12 Andrey Kiselev - - * configure.ac, acinclude.m4, aclocal.m4: New macros to detect GLUT - libraries. - -2004-09-11 Bob Friesenhahn - - * configure.ac: Pass library configuration defines via - tif_config.h rather than extending CPPFLAGS. Configure a - libtiff/tiffconf.h in order to satisfy application requirements - (not used by library build). Do not define _POSIX_C_SOURCE=2 since - this causes failure to build on systems which properly respect - this request. - - * libtiff/tiffconf.h.in: New file to act as the template for the - configured tiffconf.h - - * libtiff/files.lst (HDRS): Install the configured tiffconf.h. - -2004-09-10 Frank Warmerdam - - * html/internals.html: Split off a discussion of adding new tags - into addingtags.html. - -2004-09-10 Andrey Kiselev - - * test/{ascii_tag.c, long_tag.c}: Preliminary test suite added. - - * tools/tiff2pdf.c: Fixed reading TransferFunction tag as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=590 - - * libtiff/tif_print.c: Fixes in InkNames and NumberOfInks reporting. - - * libtiff/tif_dirread.c: Don't reject to read tags of the - SamplesPerPixel size when the tag count is greater than number of - samples as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=576 - - * libtiff/tiff.h: Use _TIFF_DATA_TYPEDEFS_ guardian to switch off - defining int8/uint8/... etc. types. As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=607 - -2004-09-09 Frank Warmerdam - - * tools/tiff2ps.c, tools/tiffmedian.c: fiddle with include files - to avoid compile warnings about getopt() and a few other things. - -2004-09-02 Andrey Kiselev - - * libtiff/tif_dirread.c: Use memcpy() function instead of pointer - assigning magic in TIFFFetchFloat(). - -2004-09-01 Andrey Kiselev - - * libtiff/{tiffio.h, tif_open.c}: Applied patches from Joris Van Damme - to avoid requirement for tiffiop.h inclusion in some applications. See - here - - http://www.asmail.be/msg0054799560.html - - for details. - - * tools/fax2tiff.c: Use the new functions in the code. - -2004-08-25 Andrey Kiselev - - * tools/tiff2pdf.c: Initialize arrays properly. - - * tools/tiff2ps.c: Avoid zero division in setupPageState() function; - properly initialize array in PSDataBW(). - -2004-08-24 Andrey Kiselev - - * tools/tiff2pdf.c: More fixes for bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=590 - - from Ross Finlayson. - -2004-08-23 Andrey Kiselev - - * tools/tiff2ps.c: Fixed problem with uninitialized values. - - * libtiff/tif_dir.c: Initialize tif_foundfield data member in the - TIFFDefaultDirectory() (in addition to 2004-08-19 fix). - - * tools/tiff2pdf.c: Fixed a bunch of problems as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=590 - -2004-08-20 Andrey Kiselev - - * tools/tiff2pdf.c: Applied patch from Ross Finlayson that checks - that the input file has compression, photometric interpretation, - etcetra, tags or if not than a more descriptive error is returned. - - * libtiff/tif_dirread.c: Fixed problem in TIFFReadDirectory() in the - code, responsible for tag data type checking. - -2004-08-19 Andrey Kiselev - - * libtiff/{tiffiop.h, tif_dirinfo.c}: Fixed problem with the static - variable as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=593 - -2004-08-16 Andrey Kiselev - - * tools/ras2tiff.c: Fixed issue with missed big-endian checks as per - bug http://bugzilla.remotesensing.org/show_bug.cgi?id=586 - -2004-08-01 Andrey Kiselev - - * libtiff/{tif_config.h.in, tif_config.h.vc}: config.h.in and - config.h.vc files renamed in the tif_config.h.in and tif_config.h.vc. - -2004-07-24 Andrey Kiselev - - * libtiff/tif_lzw.c: LZW compression code is merged back from the - separate package. All libtiff tools are updated to not advertise an - abcence of LZW support. - -2004-07-12 Andrey Kiselev - - * libtiff/tiffio.h: Revert thandle_t back to void* type. - -2004-07-11 Andrey Kiselev - - * libtiff/{tif_read.c, tif_tile.c, tif_strip.c}: Fixes in error - messages, as suggested by Bernd Herd. - -2004-07-03 Andrey Kiselev - - * libtiff/tif_dir.c: Call TIFFError() instead of producing warnings - when setting custom tags by value. Reported by Eric Fieleke. - -2004-06-14 Andrey Kiselev - - * tools/bmp2tiff.c: Add missed RawsPerStrip setting. - -2004-06-08 Andrey Kiselev - - * tools/bmp2tiff.c: Added new utility to convert Windows BMP files - into TIFFs. - -2004-06-07 Andrey Kiselev - - * libtiff 3.7.0alpha released. - -2004-06-06 Andrey Kiselev - - * libtiff/{tiff.h, tif_dirwrite.c, tif_fax3.c, tif_packbits.c,}: Get rid - of ugly 64-bit hacks, replace them with the clever (autoconf based ) - ones :-). - - * libtiff/tiffio.h: Define thandle_t as int, not void* (may cause - problems in 64-bit environment). - -2004-06-05 Andrey Kiselev - - * tools/tiffset.c: tiffset now can set any libtiff supported tags. - Tags can be supplied by the mnemonic name or number. - - * libtiff/{tiffio.h, tif_dir.h, tif_dirinfo.c,}: Added two new - functions TIFFFindFieldInfoByName() and TIFFFieldWithName(). - -2004-05-27 Andrey Kiselev - - * libtiff/tif_ojpeg.c: Fixed problem with duplicated SOI and SOF - markers as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=581 - -2004-05-24 Andrey Kiselev - - * tools/tiffsplit.c: Don't forget to copy Photometric - Interpretation tag. - -2004-05-20 Andrey Kiselev - - * libtiff/{tif_open.c, tiffio.h}: New function added: - TIFFIsBigEndian(). Function returns nonzero if given was file written - in big-endian order. - - * tools/tiffsplit.c: Fixed problem with unproperly written multibyte - files. Now output files will be written using the same byte order - flag as in the input image. See - - http://bugzilla.remotesensing.org/show_bug.cgi?id=574 - - for details. - -2004-05-19 Frank Warmerdam - - * libtiff/tif_print.c: added (untested) support for printing - SSHORT, SLONG and SRATIONAL fields. - - * tools/tiffcp.c: close output file on normal exit. - -2004-05-17 Andrey Kiselev - - * libtiff/tif_fax3.c: Avoid reading CCITT compression options - if compression type mismatches. See - - http://bugzilla.remotesensing.org/show_bug.cgi?id=565 - -2004-04-30 Andrey Kiselev - - * libtiff/tif_strip.c: Never return 0 from the - TIFFNumberOfStrips(). - -2004-04-29 Andrey Kiselev - - * libtiff/tif_dirread.c: Workaround for broken TIFF writers which - store single SampleFormat value for multisampled images. See - - http://bugzilla.remotesensing.org/show_bug.cgi?id=562 - -2004-04-25 Andrey Kiselev - - * configure.ac, libtiff/{tiff.h, config.h.in}: Added tests for int8, - int16 and int32 types to avoid complains on some compilers. Details at - - http://bugzilla.remotesensing.org/show_bug.cgi?id=39 - -2004-04-20 Andrey Kiselev - - * tools/tiff2pdf.c: Fixed problem with unaligned access as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=555 - -2004-04-14 Andrey Kiselev - - * libtiff/tif_write.c: Allow in-place updating of the compressed - images (don't work properly with all codecs). For details see GDAL bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=534 - -2004-04-06 Andrey Kiselev - - * libtiff/tif_jpeg.c: Workaround for wrong sampling factors used - in the Intergarph JPEG compressed TIFF images as per bug: - - http://bugzilla.remotesensing.org/show_bug.cgi?id=532 - -2004-04-04 Frank Warmerdam - - * libtiff/tif_open.c: close clientdata if TIFFClientOpen() fails - via bad2. - -2004-03-26 Andrey Kiselev - - * tools/tiffcp.c: Properly set Photometric Interpretation in case of - JPEG compression of grayscale images. - - * tools/tiffcp.c: Don't emit warnings when Orientation tag does not - present in the input image. - -2004-03-19 Andrey Kiselev - - * {many}: The first attempt to switch to autotools. - -2004-03-03 Andrey Kiselev - - * libtiff/tif_open.c: Use dummy mmap/munmap functions in - TIFFClientOpen() when the appropriate client functions was not - supplied by user. - -2004-03-02 Frank Warmerdam - - * tools/ycbcr.c: fixed main() declaration as per: - http://bugzilla.remotesensing.org/show_bug.cgi?id=513 - -2004-02-26 Andrey Kiselev - - * tools/tiffsplit.c: Copy JPEGTables tag contents for JPEG compressed - images. Reported by Artem Mirolubov. - - * libtiff/tif_dirread.c: Fixed problem with handling TIFF_UNDEFINED - tag type in TIFFFetchNormalTag() as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=508 - -2004-02-17 Frank Warmerdam - - * libtiff/tif_codec.c: Fixed typo in TIFFInitPackBits name as per: - http://bugzilla.remotesensing.org/show_bug.cgi?id=494 - -2004-02-05 Andrey Kiselev - - * libtiff/tif_fax3.c: Fixed problem with CCITT encoding modes as per - bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=483 - - But we need more work on fax codec to support update mode. - -2004-01-30 Frank Warmerdam - - * libtiff/libtiff.def: Added TIFFCurrentDirOffset, TIFFWriteCheck, - TIFFRGBAImageOK, and TIFFNumberOfDirectories as suggested by - Scott Reynolds. - -2004-01-29 Andrey Kiselev - - * libtiff/tiff.h: Fixed tag definitions for TIFFTAG_YCLIPPATHUNITS - and TIFFTAG_INDEXED as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=475 - - * libtiff/{tif_win32.c, tif_unix.c}: Check whether the pointer is - NULL before proceeding further as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=474 - - Check results, returned by the TIFFFdOpen() before returning and close - file if TIFFFdOpen() failed as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=468 - - * libtiff/tif_open.c: More fixes for - - http://bugzilla.remotesensing.org/show_bug.cgi?id=468 - -2004-01-28 Andrey Kiselev - - * libtiff/{libtiff.def, tif_close.c, tiffio.h, tif_open.c}: Separate - TIFFCleanup() from the TIFFClose() in order to fix the bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=468 - - * tools/tiffcp.c: Fixed problem with wrong interpretation of the - InkNames tag as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=466 - - Memory leak fixed. - -2004-01-21 Frank Warmerdam - - * libtiff/tif_dirwrite.c: Fixed handling of writable ASCII tags that - are field_passcount=TRUE properly. Arguably anonymous custom tags - should be declared as passcount=FALSE, but I don't want to change - that without a careful review. - -2004-01-20 Andrey Kiselev - - * libtiff/tif_write.c: Fixed reporting size of the buffer in case of - stripped image in TIFFWriteBufferSetup(). As per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=460 - -2004-01-11 Andrey Kiselev - - * libtiff/tif_dir.c: Incomplete cleanup in TIFFFreeDirectory(), - patch from Gerben Koopmans. - - * libtiff/tif_dirread.c: Check field_passcount value before setting - the value of undefined type, patch from Gerben Koopmans. - -2004-01-02 Andrey Kiselev - - * tools/tiffcp.c: Fixed problem with wrong Photometric setting for - non-RGB images. - -2003-12-31 Andrey Kiselev - - * libtiff/tif_win32.c: Fixed problem with _TIFFrealloc() when the NULL - pointer passed. Patch supplied by Larry Grill. - - * libtiff/{tiff.h, tif_fax3.c}:Fixes for AMD 64 platform as - suggested by Jeremy C. Reed. - -2003-12-26 Andrey Kiselev - - * libtiff 3.6.1 released. - -2003-12-24 Andrey Kiselev - - * config.guess, config.sub: Updated from the recent upstream. - -2003-12-22 Andrey Kiselev - - * libtiff/{tif_color, tif_getimage.c, tiffio.h}, man/TIFFcolor.3t: - More cleanups in color conversion interface, added appropriate manual - page. - -2003-12-19 Andrey Kiselev - - * libtiff/{tif_extension.c, tif_dirinfo.c, tiff.h}: Warnings fixed as - per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=357 - - * tools/tiff2ps.c: Added support for alpha channel. Fixes - - http://bugzilla.remotesensing.org/show_bug.cgi?id=428 - - * libtiff/{libtiff.def, tif_color.c, tif_getimage.c, tiffio.h}: - Interface for Lab->RGB color conversion is finally cleaned up. - Added support for ReferenceBlackWhite tag handling when converted from - YCbCr color space. The latter closes - - http://bugzilla.remotesensing.org/show_bug.cgi?id=120 - -2003-12-07 Andrey Kiselev - - * libtiff/{tif_getimage.c, tiffio.h}: Avoid warnings. - - * libtiff/makefile.vc, tools/makefile.vc: Support for IJG JPEG - library. - -2003-12-06 Andrey Kiselev - - * libtiff/{tif_getimage.c, tif_aux.c}: Read WhitePoint tag from the - file and properly use it for CIE Lab->RGB transform. - -2003-12-04 Andrey Kiselev - - * libtiff/{tif_getimage.c, tif_color.c, tiffio.h}: YCbCr->RGB - conversion routines now in the tif_color.c module. New function - TIFFYCbCrtoRGB() available in TIFF API. - - * libtiff/tif_dirwrite.c: Handle TIFF_IFD tag type correctly. - -2003-12-03 Andrey Kiselev - - * libtiff/{tif_getimage.c, tif_color.c, tiffio.h}: Improvements in - CIE Lab conversion code. Start moving YCbCr stuff to the tif_color.c - module. - - * libtiff/{tif_getimage.c, tiffio.h}, man{TIFFReadRGBAImage.3t, - TIFFReadRGBAStrip.3t, TIFFReadRGBATile.3t, TIFFRGBAImage.3t}: - Finally resolved problems with orientation handling. TIFFRGBAImage - interface now properly supports all possible orientations, i.e. images - will be flipped both in horizontal and vertical directions if - required. 'Known bugs' section now removed from the appropriate manual - pages. Closed bug entry: - - http://bugzilla.remotesensing.org/show_bug.cgi?id=322 - -2003-12-02 Andrey Kiselev - - * libtiff/tif_dir.c: Fixed order of the parameters in TIFFError() - function calls as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=440 - -2003-11-28 Ross Finlayson - - * tools/tiff2pdf.c: Some bugs fixed. - -2003-11-27 Andrey Kiselev - - * libtiff/tif_luv.c: Fixed bug in 48-bit to 24-bit conversion routine, - reported by Antonio Scuri. - - * man/tiff2pdf.1: Few improvements in page layout. - - * Makefile.in, /man/Makefile.in, /html/man/tiff2pdf.1.html: - Added support fpr tiff2pdf manual page. - -2003-11-26 Ross Finlayson - - * /man/tiff2pdf.1: File added to repository. - -2003-11-26 Andrey Kiselev - - * Makefile.in, /tools/{Makefile.in, makefile.vc}: - Added support fpr tiff2pdf utility. - -2003-11-25 Ross Finlayson - - * /tools/tiff2pdf.c: File added to repository. - -2003-11-22 Andrey Kiselev - - * /tools/raw2tiff.c: sqrtf() replaced with sqrt(). - -2003-11-21 Andrey Kiselev - - * /tools/raw2tiff.c: #include removed. - - * tools/{Makefile.in, tiffgt.c}: Unmaintained and platform dependent - sgigt utility removed and replaced with the completely rewritten - portable tiffgt tool (depend on OpenGL and GLUT). Initial revision, - there is a lot of things to improve. - - * libtiff/tif_ojpeg.c: TIFFVGetField() function now can properly - extract the fields from the OJPEG files. Patch supplied by Ross - Finlayson. - - * libtiff/{tiffio.h, tif_codec.c}, man/{libtiff.3t, TIFFcodec.3t}: - Added new function TIFFIsCODECConfigured(), suggested by Ross - Finlayson. - -2003-11-18 Andrey Kiselev - - * libtiff/tif_dirinfo.c: Implemented binary search in - _TIFFMergeFieldInfo(). Patch supplied by Ross Finlayson. - - * libtiff/tif_dir.h: _TIFFFindOrRegisterdInfo declaration replaced - with _TIFFFindOrRegisterFieldInfo as reported by Ross Finlayson. - -2003-11-17 Frank Warmerdam - - * tif_dirread.c: do not mark all anonymously defined tags to be - IGNOREd. - -2003-11-17 Andrey Kiselev - - * contrib/pds/{tif_pdsdirread.c, tif_pdsdirwrite.c}: Use - TIFFDataWidth() function insted of tiffDataWidth array. - -2003-11-16 Andrey Kiselev - - * libtiff/{tiff.h, tif_dirinfo.c}: Added support for IFD (13) - datatype, intruduced in "Adobe PageMaker TIFF Tech. Notes". - -2003-11-15 Frank Warmerdam - - * Makefile.in: fixed missing backslash for tif_color.c in list. - -2003-11-13 Andrey Kiselev - - * libtiff/{tif_color.c, tif_getimage.c, tiffio.h, Makefile.in}: - New color space conversion code: CIE L*a*b* 1976 images now supported - by the TIFFRGBAImage interface. All introduced routines go to new - module tif_color.c. Eventually all color conversion functions should - be moved there. - -2003-11-12 Andrey Kiselev - - * tools/{ras2tiff.c, rasterfile.h}: Properly determine SUN Rasterfiles - with the reverse byte order (it is reported by the magic header - field). Problem reported by Andreas Wiesmann. - - * tools/raw2tiff.c, man/raw2tiff.1: Few improvements in correlation - calculation function. Guessing mechanics now documented in manual page. - -2003-11-11 Andrey Kiselev - - * tools/raw2tiff.c: Implemented image size guessing using - correlation coefficient calculation between two neighbour lines. - -2003-11-09 Frank Warmerdam - - * libtiff/tif_tile.c: remove spurious use of "s" (sample) in the - planarconfig_contig case in TIFFComputeTile(). - - http://bugzilla.remotesensing.org/show_bug.cgi?id=387 - -2003-11-09 Andrey Kiselev - - * libtiff/tiffiop.h: New macros: TIFFmax, TIFFmin and TIFFrint. - -2003-11-07 Andrey Kiselev - - * libtiff/{tiffio.h, tif_strip.c}, man/{TIFFstrip.3t, libtiff.3t}: - Added TIFFRawStripSize() function as suggested by Chris Hanson. - -2003-11-03 Andrey Kiselev - - * libtiff/{tif_lzw.c, tif_fax3.c}: Proper support for update mode as - per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=424 - -2003-10-29 Andrey Kiselev - - * libtiff/libtiff.def: Added TIFFReadRGBAImageOriented. - - * html/build.html: Added note about GNU make requirement. - -2003-10-25 Andrey Kiselev - - * Makefile.in: Fixes in using MAKEFLAGS as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=418 - - * port/install.sh.in: Option -p added to the mkdir command to create - all directory tree structure before installing. - -2003-10-18 Andrey Kiselev - - * /tools/tiff2ps.c: #include replaced with the - #include . - -2003-10-16 Andrey Kiselev - - * Makefile.in: Add an absolute path to the test_pics.sh call. - -2003-10-12 Andrey Kiselev - - * libtiff/tiffcomp.h: #define _BSDTYPES_DEFINED when defining BSD - typedefs. - -2003-10-09 Andrey Kiselev - - * configure, libtiff/{Makefile.in, mkversion.c}: - Relative buildings fixed. - - * tools/Makefile.in: Added "-I../libtiff" to the tiffset building - rule. - -2003-10-07 Andrey Kiselev - - * Makefile.in: Added missed v3.6.0.html. - - * libtiff/tiffio.h: Typo fixed: ORIENTATION_BOTTOMLEFT replaced with - ORIENTATION_BOTLEFT. - -2003-10-04 Andrey Kiselev - - * 3.6.0 final release. - -2003-10-03 Andrey Kiselev - - * libtiff/{tif_getimage.c, tiffio.h}, man/TIFFReadRGBAImage.3t: New - function TIFFReadRGBAImageOriented() implemented to retrieve raster - array with user-specified origin position as suggested by Jason Frank. - See - - http://bugzilla.remotesensing.org/show_bug.cgi?id=322 - - for details. - - * tools/tiff2rgba.c: Switched to use TIFFReadRGBAImageOriented() - instead of TIFFReadRGBAImage(). - - * tools/tiff2ps.c: Fixed possible endless loop as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=404 - -2003-09-30 Andrey Kiselev - - * libtiff/tif_dirread.c: Check field counter against number of fields - in order to fix - - http://bugzilla.remotesensing.org/show_bug.cgi?id=366 - - * libtiff/tif_fax3.c: Fix wrong line numbering as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=342 - -2003-09-25 Andrey Kiselev - - * libtiff/{tiffiop.h, tif_dirread.c, tif_dir.c, tif_open.c, - tif_close.c}: Store a list of opened IFD to prevent looping as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=383 - -2003-09-23 Andrey Kiselev - - * libtiff/tif_dirread.c: More fixes for EstimateStripByteCounts(). See - - http://bugzilla.remotesensing.org/show_bug.cgi?id=358 - -2003-08-21 Andrey Kiselev - - * tools/tiffmedian.c: int declaration replaced with the uint32 to - support large images as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=382 - -2003-08-12 Andrey Kiselev - - * libtiff/Makefile.in: Fixed problem with building in different - directory. - - * tools/tiff2ps.c: Added missing #include . - - * libtiff/tif_dirwrite.c: More fixes for custom tags code - from Ashley Dreier. - -2003-08-07 Andrey Kiselev - - * tools/tiff2ps.c: Added page size setting when creating PS Level 2. - Patch submitted by Balatoni Denes (with corrections from Tom - Kacvinsky). - - * tools/tiff2ps.c: Fixed PS comment emitted when FlateDecode is - being used. Reported by Tom Kacvinsky. - - * libtiff/tif_dirwrite.c: Fixed problem with custom tags writing, - reported by Ashley Dreier. - - * libtiff/tif_print.c: Fixed problem with float tags reading, support - for printing RATIONAL and BYTE tags added. - -2003-08-05 Andrey Kiselev - - * libtiff/tif_lzw.c: Move LZW codec state block allocation back to - TIFFInitLZW(), because its initialization in LZWSetupDecode() cause - problems with predictor initialization. Remove O_RDONLY check during - state block allocation to be able open LZW compressed files in update - mode. - - Problem exist for libtiff version of the tif_lzw.c module. One from - lzw-compression-kit hasn't such troubles. - -2003-08-04 Frank Warmerdam - - * libtiff/tif_write.c: modified tif_write.c so that the various - encoded write functions use tif_postdecode() to apply byte order - swapping (swab) to the application passed data buffer if the same - would be done when reading. This allows us to write pixel data with - more than 8 bits per sample to existing files of a non-native byte - order. One side effect of this change is the applications buffer - itself is altered in this case by the act of writing. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=171 - -2003-07-25 Frank Warmerdam - - * libtiff/tif_open.c: avoid signed/unsigned casting warning - initializing typemask as per patch from J.A. Strother. - - * tools/tiffcp.c: fixed signed/unsigned casting warning. - - * libtiff/tif_print.c: dos2unix conversion. - - * tools/tiffsplit.c: increased the maximum number of pages that - can be split. Patch provided by Andrew J. Montalenti. - -2003-07-11 Andrey Kiselev - - * tools/raw2tiff.c: Added option `-p' to explicitly select color - space of input image data. Closes - - http://bugzilla.remotesensing.org/show_bug.cgi?id=364 - -2003-07-08 Frank Warmerdam - - * tif_aux.c, tif_codec.c, tif_dir.c, tif_dirread.c, tif_extension.c, - tif_fax3.c, tif_getimage.c, tif_luv.c, tif_lzw.c, tif_next.c, - tif_packbits.c, tif_predict.c, tif_print.c, tif_swab.c, tif_thunder.c: - avoid casting warning at /W4. - -2003-07-03 Andrey Kiselev - - * tools/thumbnail.c: Memory leak fixed as reported by Robert S. Kissel. - -2003-06-30 Andrey Kiselev - - * libtiff/tif_pixarlog.c: Unused variables removed. - - * libtiff/{tif_dirread.c, tif_dir.c}: Fixed problem with - EstimateStripByteCounts() as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=358 - - * libtiff/{tif_dirwrite.c, tif_packbits.c}: Fixed compilation on - 64-bit architectures as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=357 - - * libtiff/tif_dirinfo.c: TIFFDataWidth() returns 0 in case of - unknown data type. - -2003-06-19 Frank Warmerdam - - * libtiff/tif_print.c: fixed some serious bugs when printing - custom tags ... almost certain to crash. - - * libtiff/tif_dirread.c: Don't ignore custom fields that are - autodefined. Not sure how this got to be like this. - -2003-06-18 Andrey Kiselev - - * 3.6.0 Beta2 released. - - * tools/tiffcmp.c, man/tiffcmp.1: Fixed problem with unused data - comparing as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=349 - - `-z' option now can be used to set the number of reported different - bytes. - -2003-06-09 Andrey Kiselev - - * tools/tiffcp.c, man/tiffcp.1: Added possibility to specify value -1 - to -r option to get the entire image as one strip. See - - http://bugzilla.remotesensing.org/show_bug.cgi?id=343 - - for details. - -2003-06-04 Andrey Kiselev - - * tools/tiffcp.c: Set the correct RowsPerStrip and PageNumber - values as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=343 - -2003-05-27 Frank Warmerdam - - * libtiff/tif_jpeg.c: modified segment_height calculation to always - be a full height tile for tiled images. Also changed error to just - be a warning. - -2003-05-25 Andrey Kiselev - - * tools/fax2tiff.c: Page numbering fixed, as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=341 - -2003-05-20 Andrey Kiselev - - * contrib/ojpeg/{Makefile.in, jdhuff.h, jinclude.h, ojpeg.c, README}, - configure, Makefile.in: Switched back to the old behaviour. Likely - better solution should be found for OJPEG support. - -2003-05-11 Andrey Kiselev - - * libtiff/mkversion.c: Fixed problem with wrong string size when - reading RELEASE-DATE file. - -2003-05-07 Andrey Kiselev - - * tools/tiff2ps.c: Fixed bug in Ascii85EncodeBlock() function: array - index was out of range. - -2003-05-06 Andrey Kiselev - - * contrib/ojpeg/{Makefile.in, jdhuff.h, jinclude.h, ojpeg.c, README}, - configure, Makefile.in: Improved libtiff compilation with OJPEG - support. Now no need for patching IJG JPEG library, hack requred by - libtiff will be compiled and used in-place. Implemented with - suggestion and help from Bill Allombert, Debian's libjpeg maintainer. - - * libtiff/tif_aux.c: Properly handle TIFFTAG_PREDICTOR in - TIFFVGetFieldDefaulted() function. - -2003-05-05 Andrey Kiselev - - * tools/ppm2tiff.c: PPM header parser improved: now able to skip - comments. - - * tools/tiffdither.c: Fixed problem with bit fill order tag setting: - was not copied from source image. - - * libtiff/getimage.c: Workaround for some images without correct - info about alpha channel as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=331 - -2003-04-29 Andrey Kiselev - - * tools/tiff2ps.c, man/tiff2ps.1: Add ability to generate PS Level 3. - It basically allows one to use the /flateDecode filter for ZIP - compressed TIFF images. Patch supplied by Tom Kacvinsky. Fixes - - http://bugzilla.remotesensing.org/show_bug.cgi?id=328 - - * tools/tiff2ps.c: Force deadzone printing when EPS output specified - as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=325 - -2003-04-17 Andrey Kiselev - - * libtiff/tif_dirread.c: Removed additional check for StripByteCounts - due to problems with multidirectory images. Quality of error messages - improved. - -2003-04-16 Andrey Kiselev - - * tools/tiffcp.c: Fixed problem with colorspace conversion for JPEG - encoded images. See bug entries - - http://bugzilla.remotesensing.org/show_bug.cgi?id=275 - - and - - http://bugzilla.remotesensing.org/show_bug.cgi?id=23 - - * libtiff/tif_dirread.c: Additional check for StripByteCounts - correctness. Fixes - - http://bugzilla.remotesensing.org/show_bug.cgi?id=320 - -2003-03-12 Andrey Kiselev - - * tools/{fax2ps.c, fax2tiff.c, gif2tiff.c, pal2rgb.c, ppm2tiff.c, - ras2tiff.c, raw2tiff.c, rgb2ycbcr.c, thumbnail.c, tiff2bw.c, - tiff2ps.c, tiff2rgba.c, tiffcp.c, tiffdither.c, tiffinfo.c, - tiffmedian.c}: Added library version reporting facility to all tools. - -2003-03-06 Frank Warmerdam - - * port/install.sh.in: Fixed problems with install producing paths - like ///usr/local/lib on cygwin. - -2003-02-27 Andrey Kiselev - - * tools/fax2tiff.c, man/fax2tiff.1: New switch (-X) to set width of - raw input page. Patch supplied by Julien Gaulmin. See - - http://bugzilla.remotesensing.org/show_bug.cgi?id=293 - - for details. - -2003-02-26 Frank Warmerdam - - * libtiff/tif_dir.c: fixed up the tif_postdecode settings - responsible for byte swapping complex image data. - - * libtiff/tif_lzw.c: fixed so that decoder state isn't allocated till - LZWSetupDecode(). Needed to read LZW files in "r+" mode. - -2003-02-07 Andrey Kiselev - - * tools/ppm2tiff.c: Fixed problem with too many arguments. - -2003-02-04 Andrey Kiselev - - * tools/raw2tiff.c: Memory leak fixed. - -2003-02-03 Andrey Kiselev - - * tools/fax2tiff.c, man/fax2tiff.1: Applied patch from Julien Gaulmin - (thanks, Julien!). More switches for fax2tiff tool for better control - of input and output. Details at - - http://bugzilla.remotesensing.org/show_bug.cgi?id=272 - -2003-02-03 Frank Warmerdam - - * libtiff/tif_jpeg.c: Modified to defer initialization of jpeg - library so that we can check if there is already any tile/strip data - before deciding between creating a compressor or a decompressor. - -2003-01-31 Frank Warmerdam - - * libtiff/tif_write.c: TIFFWriteCheck() now fails if the image is - a pre-existing compressed image. That is, image writing to - pre-existing compressed images is not allowed. - - * libtiff/tif_open.c: Removed error if opening a compressed file - in update mode. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=198 - -2003-01-31 Andrey Kiselev - - * config.guess, config.sub: Updated to recent upstream versions. - -2003-01-15 Frank Warmerdam - - * cut 3.6.0 Beta release. - -2002-12-20 Andrey Kiselev - - * tools/fax2ps.c, man/fax2ps.1: Page size was determined - in wrong way as per bug - - http://bugzilla.remotesensing.org/show_bug.cgi?id=239 - -2002-12-17 Frank Warmerdam - - * libtiff/tif_dirread.c: Allow wrong sized arrays in - TIFFFetchStripThing(). - - http://bugzilla.remotesensing.org/show_bug.cgi?id=49 - -2002-12-02 Frank Warmerdam - - * libtiff/tif_dir.c: fix problem with test on td_customValueCount. - Was using realloc even first time. Fix by Igor Venevtsev. - -2002-11-30 Frank Warmerdam - - * libtiff/tif_dir.c: fixed bug with resetting an existing custom - field value. - - * libtiff/tif_dir.c: Fixed potential problem with ascii "custom" - tags in TIFFVGetField() ... added missing break. - -2002-10-14 Frank Warmerdam - - * tools/tiff2ps.c: fixes a problem where "tiff2ps -1e" did not make - the scanline buffer long enough when writing rgb triplets. - The scanline needs to be 3 X the number of dots or else it will - contain an incomplete triplet and programs that try to separate - the eps by redefining the colorimage operator will get messed up. - Patch supplied by William Bader. - - * Makefile.in: added tif_extension.c to file list as per - http://bugzilla.remotesensing.org/show_bug.cgi?id=218. - -2002-10-11 Andrey Kiselev - - * configure, config.site, libtiff/{tif_unix.c, Makefile.in}: Fix for - large files (>2GiB) supporting. New option in the config.site: - LARGEFILE="yes". Should be enough for I/O of the large files. - -2002-10-10 Frank Warmerdam - - * libtiff/html/v3.6.0.html: new release notes. - - * libtiff/index.html: removed faq, cvs snapshot cruft. Added email - link for Andrey. Pointer to v3.6.0.html. - - * libtiff/Makefile.in: added direct rule for tiffvers.h for release. - -2002-10-07 Andrey Kiselev - * tools/tiff2ps.c, man/tiff2ps.1: Applied patch form Sebastian Eken - (thanks, Sebastian!). New switches: - -b # for a bottom margin of # inches - -c center image - -l # for a left margin of # inches - -r rotate the image by 180 degrees - New features merged with code for shrinking/overlapping. - Previously added -c and -n switches (for overriding PS units) renamed - in -x and -y respectively. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=200 - - * html/man/*.html: Updated from actual manual pages. - -2002-10-06 Frank Warmerdam - - * libtiff/tif_jpeg.c: fixed problem with boolean defined with wrong - size on windows. Use #define boolean hack. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=188 - - * libtiff/tiff.h: Don't do special type handling in tiff.h unless - USING_VISUALAGE is defined. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=39 - -2002-10-03 Frank Warmerdam - - * libtiff/tiff.h: added COMPRESSION_JP2000. - -2002-10-02 Andrey Kiselev - - * libtiff/tif_dirread.c: Another fix for the fetching SBYTE arrays - by the TIFFFetchByteArray() function. Should finally resolve - - http://bugzilla.remotesensing.org/show_bug.cgi?id=52 - - * configure: Set -DPIXARLOG_SUPPORT option along with -DZIP_SUPPORT - - * html/Makefile.in: New targets added: html and groffhtml for - producing HTML representations of the manual pages automatically. - html target uses man2html tool, groffhtml uses groff tool. - -2002-09-29 Frank Warmerdam - - * configure, libtiff/Makefile.in: Added SCO OpenServer 5.0.6 support - from John H. DuBois III. - -2002-09-15 Andrey Kiselev - - * Makefile.in, /man/{raw2tiff.1, Makefile.in, libtiff.3}: Added - manual page for raw2tiff(1) tool. - -2002-09-12 Andrey Kiselev - - * /libtiff/{tiffio.h, tif_dir.h}: TIFFDataWidth() declaration moved to - the tiffio.h header file. - - * Makefile.in, /man/{TIFFDataWidth.3t, Makefile.in, libtiff.3}: Added - manual page for TIFFDataWidth() function - -2002-09-08 Frank Warmerdam - - * libtiff/tif_dirread.c: Expand v[2] to v[4] in TIFFFetchShortPair() - as per http://bugzilla.remotesensing.org/show_bug.cgi?id=196. - - * tools/tiff2ps.c: Don't emit BeginData/EndData DSC comments - since we are unable to properly include the amount to skip. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=80 - -2002-09-02 Andrey Kiselev - - * /libtiff/tif_dirread.c: Fixed problem with SBYTE type data fetching - in TIFFFetchByteArray(). Problem described at - http://bugzilla.remotesensing.org/show_bug.cgi?id=52 - -2002-08-22 Andrey Kiselev - - * /libtiff/tif_dirinfo.c: Further additions to free custom fields - in _TIFFSetupFieldInfo() function. - See http://bugzilla.remotesensing.org/show_bug.cgi?id=169 for details. - - * /libtiff/tif_lzw.c: Additional consistency checking added in - LZWDecode() and LZWDecodeCompat(). - Fixes http://bugzilla.remotesensing.org/show_bug.cgi?id=190 - and http://bugzilla.remotesensing.org/show_bug.cgi?id=100 - - * /libtiff/tif_lzw.c: - Added check for valid code lengths in LZWDecode() and - LZWDecodeCompat(). Fixes - http://bugzilla.remotesensing.org/show_bug.cgi?id=115 - -2002-08-16 Andrey Kiselev - - * /libtiff/{Makefile.vc, libtiff.def}: - Missed declarations added. - -2002-08-15 Frank Warmerdam - - * tif_getimage.c: Ensure that TIFFRGBAImageBegin() returns the - return code from the underlying pick function. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=177 - - * tif_dir.h: changed FIELD_CODEC to 66 from 64 to avoid overlap - with FIELD_CUSTOM as mentioned in bug 169. - - * tif_close.c: added logic to free dynamically created anonymous - field definitions to correct a small memory leak. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=169 - -2002-08-10 Andrey Kiselev - - * /tools/{raw2tiff.c, Makefile.in, Makefile.lcc, Makefile.vc}: - New tool: raw2tiff --- raw images to TIFF converter. No manual page yet. - -2002-07-31 Frank Warmerdam - - * libtiff/tif_jpeg.c: Fixed problem with setting of nrows in - JPEGDecode() as per bugzilla bug (issue 1): - - http://bugzilla.remotesensing.org/show_bug.cgi?id=129 - - * libtiff/{tif_jpeg.c,tif_strip.c,tif_print.c}: Hacked tif_jpeg.c to - fetch TIFFTAG_YCBCRSUBSAMPLING from the jpeg data stream if it isn't - present in the tiff tags. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=168 - - * libtiff/tif_read.c, libtiff/tif_write.c: TIFFReadScanline() and - TIFFWriteScanline() now set tif_row explicitly in case the codec has - fooled with the value. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=129 - -2002-06-22 Andrey Kiselev - - * /tools/tiff2ps.c: Added workaround for some software that may crash - when last strip of image contains fewer number of scanlines than - specified by the `/Height' variable. See - http://bugzilla.remotesensing.org/show_bug.cgi?id=164 - for explanation. - -2002-06-21 Andrey Kiselev - - * tools/tiff2ps, man/tiff2ps.1: New functionality for tiff2ps utility: - splitting long images in several pages. See - http://bugzilla.remotesensing.org/show_bug.cgi?id=142 for explanation. - Patch granted by John Williams . - -2002-06-11 Frank Warmerdam - - * libtiff/contrib/win95: renamed to contrib/win_dib. Added new - Tiffile.cpp example of converting TIFF files into a DIB on Win32. - This one is described in: - - http://bugzilla.remotesensing.org/show_bug.cgi?id=143 - - * libtiff/tif_ojpeg.c: Major upgrade from Scott. See details at: - - http://bugzilla.remotesensing.org/show_bug.cgi?id=156 - -2002-05-10 Andrey Kiselev - - * tools/tiff2ps: New commandline switches to override resolution - units obtained from the input file. Closes - http://bugzilla.remotesensing.org/show_bug.cgi?id=131 - -2002-04-26 Andrey Kiselev - - * libtiff/libtiff.def: Added missed declaration. - -2002-04-22 Andrey Kiselev - - * tools/fax2tiff.c: Updated to reflect latest changes in libtiff. - Closes http://bugzilla.remotesensing.org/show_bug.cgi?id=125 - -2002-04-20 Andrey Kiselev - - * libtiff/tif_open.c: Pointers to custom procedures - in TIFFClientOpen() are checked to be not NULL-pointers. - -2002-04-18 Andrey Kiselev - - * libtiff/libtiff.def: Added missed declarations. - - * libtiff/tif_pixarlog.c: Updated for using tif_tagmethods structure. - -2002-04-16 Andrey Kiselev - - * libtiff/tif_lzw.c: Additional checks for data integrity introduced. - Should finally close - http://bugzilla.remotesensing.org/show_bug.cgi?id=100 - -2002-04-10 Andrey Kiselev - - * tools/tiff2ps: Division by zero fixed. - Closes http://bugzilla.remotesensing.org/show_bug.cgi?id=88 - -2002-04-09 Andrey Kiselev - - * libtiff/: tif_dirwrite.c, tif_write.c, tiffio.h: - TIFFCheckpointDirectory() routine added. - Closes http://bugzilla.remotesensing.org/show_bug.cgi?id=124 - - * man/: TIFFWriteDirectory.3t, Makefile.in: Added description - for the new function. - -2002-04-08 Andrey Kiselev - - * libtiff/: tif_codec.c, tif_compress.c, tiffiop.h: Introduced - additional members tif->tif_decodestatus and tif->tif_encodestatus - for correct handling of unconfigured codecs (we should not try to read - data or to define data size without correct codecs). - - * libtiff/tif_getimage.c: The way of codecs checking in TIFFRGBAImageOK - changed. Now it has used tif->tif_decodestatus and - tif->tif_encodestatus. - Should fix http://bugzilla.remotesensing.org/show_bug.cgi?id=119 (in - case of __cvs_8.tif test image). - - * libtiff/: tif_dirinfo.c, tif_dirread.c: Somebody makes a bug in - tif_dirread.c when TIFFCreateAnonFieldInfo was introduced. - Closes http://bugzilla.remotesensing.org/show_bug.cgi?id=119 in case - of _cvs_00000-00.tif, _cvs_00000-01.tif and _cvs_00000-02.tif. - -2002-04-04 Andrey Kiselev - - * libtiff/: tif_lzw.c: Assertions in LZWDecode and LZWDecodeCompat - replaced by warnings. Now libtiff should read corrupted LZW-compressed - files by skipping bad strips. - Closes http://bugzilla.remotesensing.org/show_bug.cgi?id=100 - -2002-04-03 Frank Warmerdam - - * libtiff/tif_dirwrite.c: Removed some dead code. - - * libtiff/*: Cleanup some warnings. - - * libtiff/tif_dir.c: Fixed bug with count returned by TIFFGetField() - for variable length FIELD_CUSTOM values. Was int * but should be - u_short *. - -2002-04-01 Andrey Kiselev - - * tools/: tifcp.c: Added support for 'Orientation' tag in tiffcp - utility (at cpStripToTile routine). - -2002-03-27 Frank Warmerdam - - * tif_dirread.c: avoid div-by-zero if rowbytes is zero in chop func. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=111 - - * tif_print.c: Fixed so that ASCII FIELD_CUSTOM values with - passcount set FALSE can be printed (such as TIFFTAG_SOFTWARE). - - * libtiff/tif_dir.c,tif_dirinfo.c,tif_dir.h,tif_ojpeg.c: modified so - that TIFFTAG_SOFTWARE uses FIELD_CUSTOM as an example. - -2002-03-26 Dwight Kelly - - * libtiff/: tiff.h, tif_dir.c, tif_dir.h, tif_dirinfo.c, tif_dirread.c, - tif_dirwrite.c: Added get/put code for new tag XMLPACKET as defined - in Adobe XMP Technote. Added missing INKSET tag value from TIFF 6.0 spec - INKSET_MULTIINK (=2). Added missing tags from Adobe TIFF technotes: - CLIPPATH, XCLIPPATHUNITS, YCLIPPATHUNITS, OPIIMAGEID, OPIPROXY and - INDEXED. Added PHOTOMETRIC tag value from TIFF technote 4 ICCLAB (=9). - -2002-03-26 Andrey Kiselev - - * libtiff/: tif_getimage.c: TIFFReadRGBAStrip and TIFFReadRGBATile - now also uses TIFFRGBAImageOK before reading. This is additional fix - for http://bugzilla.remotesensing.org/show_bug.cgi?id=110 - -2002-03-25 Andrey Kiselev - - * libtiff/: tif_getimage.c: Additional check for supported - codecs added in TIFFRGBAImageOK and TIFFReadRGBAImage now uses - TIFFRGBAImageOK before reading. - Closes http://bugzilla.remotesensing.org/show_bug.cgi?id=110 - -2002-03-15 Andrey Kiselev - - * libtiff/: tif_dir.c, tif_dir.h, tif_dirinfo.c, tif_dirread.c, - tif_dirwrite.c: Added routine TIFFDataWidth for detrmining - TIFFDataType sizes instead of working with tiffDataWidth array - directly. Should prevent out-of-borders bugs in case of unknown or - broken data types. EstimateStripByteCounts routine modified, so it - won't work when tags with uknown sizes founded. - Closes http://bugzilla.remotesensing.org/show_bug.cgi?id=109 - -2002-03-13 Andrey Kiselev - - * libtiff/tif_getimage.c: Added support for correct handling - `Orientation' tag in gtTileContig. Should be added in other gt* - functions as well, but I have not images for testing yet. Partially - resolves http://bugzilla.remotesensing.org/show_bug.cgi?id=23 - -2002-03-10 Andrey Kiselev - - * libtiff/: tif_dirinfo.c, tif_dirwrite.c: Added possibility to - read broken TIFFs with LONG type used for TIFFTAG_COMPRESSION, - TIFFTAG_BITSPERSAMPLE, TIFFTAG_PHOTOMETRIC. Closes - http://bugzilla.remotesensing.org/show_bug.cgi?id=99 - -2002-03-08 Andrey Kiselev - - * libtiff/Makefile.in, tools/Makefile.in: Shared library will not - be stripped when installing, utility binaries will do. Closes - http://bugzilla.remotesensing.org/show_bug.cgi?id=93 - -2002-02-28 Frank Warmerdam - - * man/TIFFGetField: fixed type of TIFFTAG_COPYRIGHT. - - * man/libtiff.3t: added copyright tag info. - -2002-02-11 Frank Warmerdam - - * libtiff/{tiff.h,tif_fax3.c}: Add support for __arch64__. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=94 - - * man/Makefile.in: Patch DESTDIR handling - - http://bugzilla.remotesensing.org/show_bug.cgi?id=95 - - * configure: OpenBSD changes for Sparc64 and DSO version. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=96 - -2002-02-05 Frank Warmerdam - - * config.site/configure: added support for OJPEG=yes option to enable - OJPEG support from config.site. - -2002-01-27 Frank Warmerdam - - * html/document.html: fixed links for TIFf 6 docs. - -2002-01-18 Frank Warmerdam - - * config.guess, config.sub: Updated from ftp.gnu.org/pub/config. - - * libtiff/tif_read.c: Fixed TIFFReadEncodedStrip() to fail if the - decodestrip function returns anything not greater than zero as per - http://bugzilla.remotesensing.org/show_bug.cgi?id=97 - - * configure: Modify CheckForBigEndian so it can work in a cross - compiled situation. - -2002-01-16 Frank Warmerdam - - * tools/tiffdump.c: include TIFFTAG_JPEGTABLES in tag list. - - * tools/tiffset.c: fix bug in error reporting. - - * tools/tiffcp.c: fix several warnings that show up with -Wall. - -2002-01-04 Frank Warmerdam - - * libtiff/tif_jpeg.c: fixed computation of segment_width for - tiles files to avoid error about it not matching the - cinfo.d.image_width values ("JPEGPreDecode: Improper JPEG strip/tile - size.") for ITIFF files. Apparently the problem was incorporated since - 3.5.5, presumably during the OJPEG/JPEG work recently. - -2001-12-15 Frank Warmerdam - - * configure, libtiff/Makefile.in: Changes for building on MacOS 10.1. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=94 - - * libtiff/tif_getimage.c: If DEFAULT_EXTRASAMPLE_AS_ALPHA is 1 - (defined in tiffconf.h - 1 by default) then the RGBA interface - will assume that a fourth extra sample is ASSOCALPHA if the - EXTRASAMPLE value isn't set for it. This changes the behaviour of - the library, but makes it work better with RGBA files produced by - lots of applications that don't mark the alpha values properly. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=93 - http://bugzilla.remotesensing.org/show_bug.cgi?id=65 - -2001-12-12 Frank Warmerdam - - * libtiff/tif_jpeg.c: allow jpeg data stream sampling values to - override those from tiff directory. This makes this work with - ImageGear generated files. - -2001-12-07 Frank Warmerdam - - * html/Makefile.in: added missing images per bug 92. - - * port/Makefile.in: fixed clean target per bug 92. - -2001-11-28 Frank Warmerdam - - * Reissue 3.5.7 release. - - * libtiff/mkversion.c: Fix output of TIFF_VERSION to be - YYYYMMDD so that it is increasing over time. - - * Makefile.in: Ensure that tiffvers.h is regenerated in the - make release target. - - * Makefile.in: added libtiff/tiffvers.h to the release file list. - -2001-11-23 Frank Warmerdam - - * added html/v3.5.7.html, updated html/index.html. - - * Makefile.in: added contrib/addtiffo/tif_ovrcache.{c,h}. - -2001-11-15 Frank Warmerdam - - * configure: fixed test for -lm. - -2001-11-02 Frank Warmerdam - - * Added PHOTOMETRIC_ITULAB as per bug 90. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=90 - -2001-10-10 Frank Warmerdam - - * libtiff/tiff.h: I have created COMPRESSION_CCITT_T4, - COMPRESSION_CCITT_T6, TIFFTAG_T4OPTIONS and TIFFTAG_T6OPTIONS aliases - in keeping with TIFF 6.0 standard in tiff.h - - http://bugzilla.remotesensing.org/show_bug.cgi?id=83 - -2001-09-26 Frank Warmerdam - - * libtiff/tif_dirwrite.c: added TIFFRewriteDirectory() function. - Updated TIFFWriteDirectory man page to include TIFFRewriteDirectory. - -2001-09-24 Frank Warmerdam - - * libtiff/tif_lzw.c: Avoid MS VC++ 5.0 optimization bug. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=78 - - * libtiff/tif_lzw.c: added dummy LZWSetupEncode() to report an - error about LZW not being available. - - * libtiff/tif_dir.c: propagate failure to initialize compression - back from TIFFSetField() as an error status, so applications can - detect failure. - - * libtiff/tif_dir.c: removed the auto replacement of - COMPRESSION_LZW with COMPRESSION_NONE in _TIFFVSetField(). - - * Removed Makefile, tools/Makefile, port/install.sh, man/Makefile - from CVS as they are all supposed to be auto-generated by configure. - -2001-09-22 Frank Warmerdam - - * libtiff/tif_ojpeg.c: new update from Scott. - -2001-09-09 Frank Warmerdam - - * libtif/tif_fax3.c: Removed #ifdef PURIFY logic, and modified to - always use the "safe" version, even if there is a very slight - cost in performance. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=54 - - * libtiff/Makefile.in: Fixed @DSOSUB_VERSION to be @DSOSUF_VERSION@ - in two places. - - * libtiff/tif_getimage.c: Fixed problem with reading strips or - tiles that don't start on a tile boundary. Fix contributed by - Josep Vallverdu (from HP), and further described in bug 47. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=47 - - * tools/tiff2ps.c: added OJPEG YCbCr to RGB support. - - * libtiff/tif_ojpeg.c: Applied substantial patch from Scott. - -2001-09-06 Frank Warmerdam - - * libtiff/tif_packbits.c: fixed memory overrun error. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=77 - -2001-08-31 Frank Warmerdam - - * libtiff/tif_getimage.c: relax handling of contig case where - there are extra samples that are supposed to be ignored. This - should now work for 8bit greyscale or palletted images. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=75 - -2001-08-28 Frank Warmerdam - - * libtiff/tif_getimage.c: Don't complain for CMYK (separated) - images with more than four samples per pixel. See: - - http://bugzilla.remotesensing.org/show_bug.cgi?id=73 - -2001-08-10 Frank Warmerdam - - * libtiff/tif_getimage.c: Use memmove() instead of TIFFmemcpy() - in TIFFReadRGBATile() to avoid issues in cases of overlapping - buffers. See Bug 69 in Bugzilla. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=69 - - * tools/tiff2rgba.c: fixed getopt() call so that -b works again. - -2001-08-09 Frank Warmerdam - - * libtiff/tiff.h, libtiff/tif_fax3.c: added check for __LP64__ - when checking for 64 bit architectures as per bugzilla bug 67. - -2001-07-27 Frank Warmerdam - - * man/Makefile.in: add TIFFClientOpen link as per debian submitted - bug 66. - -2001-07-20 Frank Warmerdam - - * libtiff/tif_jpeg.c: Define HAVE_BOOLEAN on windows if RPCNDR.H - has been included. - -2001-07-19 Frank Warmerdam - - * libtiff/tif_open.c: Seek back to zero after failed read, - before writing header. - -2001-07-18 Frank Warmerdam - - * libtiff/tif_ojpeg.c: updates from Scott. Handles colors - much better. Now depends on having patched libjpeg as per - patch in contrib/ojpeg/*. - -2001-07-17 Frank Warmerdam - - * */Makefile.in: added DESTDIR support. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=60 - -2001-07-16 Frank Warmerdam - - * configure, libtiff/Makefile.in: applied OpenBSD patches - as per: - - http://bugzilla.remotesensing.org/show_bug.cgi?id=61 - -2001-06-28 Frank Warmerdam - - * libtiff/tif_getimage.c: Fixed so that failure is properly - reported by gtTileContig, gtStripContig, gtTileSeparate and - gtStripSeparate. - - See http://bugzilla.remotesensing.org/show_bug.cgi?id=51 - - * tiffcmp.c: Fixed multi samples per pixel support for ContigCompare. - Updated bug section of tiffcmp.1 to note tiled file issues. - - See http://bugzilla.remotesensing.org/show_bug.cgi?id=53 - -2001-06-22 Frank Warmerdam - - * configure: Changes for DSO generation on AIX provided by - John Marquart . - - * configure, libtiff/Makeifle.in: Modified to build DSOs properly - on Darwin thanks to Robert Krajewski (rpk@alum.mit.edu) and - Keisuke Fujii (fujiik@jlcuxf.kek.jp). - -2001-06-13 Frank Warmerdam - - * tools/tiff2rgba.c: added -n flag to avoid emitting alpha component. - - * man/tiff2rgba.1: new - -2001-05-22 Frank Warmerdam - - * Added tiffset and tif_ojpeg to the dist lists in Makefile.in. - -2001-05-13 Frank Warmerdam - - * libtiff/tools/thumbnail.c: changed default output compression - to packbits from LZW since LZW isn't generally available. - -2001-05-12 Frank Warmerdam - - * libtiff/tif_ojpeg.c: New. - libtiff/tif_jpeg.c, tiffconf.h, tif_getimage.c: changes related - to OJPEG support. - - Scott Marovich supplied OJPEG support. - -2001-05-11 Frank Warmerdam - - * tiff.h: removed, it duplicates libtiff/tiff.h. - -2001-05-08 Frank Warmerdam - - * libtiff/tif_dirinfo.c: moved pixar and copyright flags to - ensure everything is in order. - - * libtiff/libtiff.def: added TIFFCreateDirectory and - TIFFDefaultStripSize as per: - - http://bugzilla.remotesensing.org/show_bug.cgi?id=46 - -2001-05-02 Frank Warmerdam - - * libtiff/tif_dirinfo.c: Modified the TIFF_BYTE definition for - TIFFTAG_PHOTOSHOP to use a writecount of TIFF_VARIABLE2 (-3) to - force use of uint32 counts instead of short counts. - - * libtiff/tif_dirwrite.c: Added support for TIFF_VARIABLE2 in the - case of writing TIFF_BYTE/TIFF_SBYTE fields. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=43 - -2001-05-01 Frank Warmerdam - - * libtiff/tif_dirinfo.c: removed duplicate TIFFTAG_PHOTOSHOP as per - bug report http://bugzilla.remotesensing.org/show_bug.cgi?id=44 - -2001-04-05 Frank Warmerdam - - * tiffio.h: removed C++ style comment. - - * configure: fixed up SCRIPT_SH/SHELL handling. - - * Makefile.in: Fixed SCRIPT_SH/SHELL handling. - - * config.guess: documented more variables as per bug 40. - -2001-04-03 Frank Warmerdam - - * configure, *Makefile.in: Various changes to improve configuration - for HP/UX specifically, and also in general. They include: - - Try to handle /usr/bin/sh instead of /bin/sh where necessary. - - Upgrade to HP/UX 10.x+ compiler, linker and dso options. - - Fixed mmap() test to avoid MMAP_FIXED ... it isn't available on HP - - Use -${MAKEFLAGS} in sub makes from makefiles. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=40 - -2001-04-02 Frank Warmerdam - - * libtiff/tiff.h: Applied hac to try and resolve the problem - with the inttypes.h include file on AIX. - - See http://bugzilla.remotesensing.org/show_bug.cgi?id=39 - - * VERSION: update to 3.5.7 beta in preparation for release. - - * configure/config.site: modified to check if -lm is needed for - MACHDEPLIBS if not supplied by config.site. Needed for Darwin. - - * config.guess: updated wholesale to an FSF version apparently - from 1998 (as opposed to 1994). This is mainly inspired by - providing for MacOS X support. - -2001-03-29 Frank Warmerdam - - * configure, Makefile.in, etc: added support for OPTIMIZER being - set from config.site. - -2001-03-28 Frank Warmerdam - - * fax2ps.c: Helge (libtiff at oldach.net) submitted fix: - - Here's a fix for fax2ps that corrects behaviour for non-Letter paper - sizes. It fixes two problems: - - Without scaling (-S) the fax is now centered on the page size specified - with -H and/or -W. Before, fax2ps was using an obscure and practially - useless algorithm to allocate the image relative to Letter sized paper - which sometime sled to useless whitespace on the paper, while at the - same time cutting of the faxes printable area at the opposite border. - - Second, scaling now preserves aspect ratio, which makes unusual faxes - (in particular short ones) print properly. - - See http://bugzilla.remotesensing.org/show_bug.cgi?id=35 - - * tiff2ps.c/tiff2ps.1: Substantial changes to tiff2ps by - Bruce A. Mallett. See check message for detailed information - on all the changes, including a faster encoder, fixes for level - 2 PostScript, and support for the imagemask operator. - -2001-03-27 Frank Warmerdam - - * libtiff/tiffio.h: Changed "#if LOGLUV_PUBLIC" to - "#ifdef LOGLUV_PUBLIC" so it will work with VisualAge on AIX. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=39 - -2001-03-16 Frank Warmerdam - - * tif_dirinfo.c: moved definition of copyright tag in field list. - Apparently they have to be in sorted order by tag id. - -2001-03-13 Frank Warmerdam - - * tif_getimage.c: Added support for 16bit minisblack/miniswhite - images in RGBA interface. - -2001-03-02 Frank Warmerdam - - * Added TIFFTAG_COPYRIGHT support. - -2001-02-19 Frank Warmerdam - - * Brent Roman contributed updated tiffcp utility (and tiffcp.1) - with support for extracting subimages with the ,n syntax, and also - adding the -b bias removal flag. - -2001-02-16 Frank Warmerdam - - * libtiff/libtiff.def: Brent Roman submitted new version adding - serveral missing entry points. - - * libtiff/tif_dirinfo.c: don't declare tiffFieldInfo static on VMS. - Some sort of weird VMS thing. - - http://bugzilla.remotesensing.org/show_bug.cgi?id=31 - - * tif_luv.c/tiff.h/tiffio.h: - New version of TIFF LogLuv (SGILOG) modules contributed by Greg Ward - (greg@shutterfly.com). He writes: - - 1) I improved the gamut-mapping function in tif_luv.c for imaginary - colors, because some images were being super-saturated on the input - side and this resulted in some strange color shifts in the output. - - 2) I added a psuedotag in tiff.h to control random dithering during - LogLuv encoding. This is turned off by default for 32-bit LogLuv and - on for 24-bit LogLuv output. Dithering improves the average color - accuracy over the image. - - 3) I added a #define for LOG_LUV_PUBLIC, which is enabled by default in - tiffio.h, to expose internal routines for converting between LogLuv and - XYZ coordinates. This is helpful for writing more efficient, - specialized conversion routines, especially for reading LogLuv files. - - Changes applied with minor edits. - -2001-01-23 Frank Warmerdam - - * tif_fax3.c: keep rw_mode flag internal to fax3 state to remember - whether we are encoding or decoding. This is to ensure graceful - recovery if TIFFClientOpen() discovers an attempt to open a compressed - file for "r+" access, and subsequently close it, as it resets the - tif_mode flag to O_RDONLY in this case to avoid writes, confusing the - compressor's concept of whether it is in encode or decode mode. - -2001-01-08 Mike Welles - - * Makefile.in: Now cleaning up after itself after creating the .tar.gz and .zip - -2001-01-07 Frank Warmerdam - - * html/libtiff.html: Fixed arguments in example for TIFFRGBAImageGet() - as per bug report by Patrick Connor. - -2000-12-28 Frank Warmerdam - - * Added RELEASE-DATE file to release file list. - - * Fixed libtiff/makefile.vc to make tiffvers.h not version.h. - -2000-12-22 Mike Welles - * added link to CVS mirror from index.html - - * updated html/internals.html to note that LZW compression is - not supported by default. - -2000-12-22 Frank Warmerdam - - * updated html/libtiff.html to not point at Niles' old JPL web site - for the man pages, point at www.libtiff.org. - -2000-12-21 Frank Warmerdam - - * libtiff/tif_apple.c: Applied "Carbon" support patches supplied by - Leonard Rosenthol . May interfere - with correct building on older systems. If so, please let me know. - -2000-12-19 Mike Welles - - * Took out LZW Encoding from tif_lzw.c - - * Created HOWTO-RELEASE - - * Created html/v3.5.6.html - - * updated index.html - -2000-12-01 Frank Warmerdam - - * Added patches for EOFB support in tif_fax3.c and tif_fax3.h. - Patches supplied by Frank Cringle - Example file at: ftp://ftp.remotesensing.org/pub/libtiff/eofb_396.tif - -2000-11-24 Frank Warmerdam - - * libtiff/Makefile.in: Added an installPrivateHdrs and install-private - target so that the private headers required by libgeotiff can be - installed with the others. They are not installed by default. - - * libtiff/Makefile.in: Added @MACHLIBDEPS@ to LINUXdso and GNULDdso - targets so libtiff.so will be built with an explicit dependency - on libm.so. - - * libtiff/Makefile.in: Use softlinks to link libtiff.so.3 to - libtiff.so.3.5.5. - - * libtiff/Makefile.in & configure: Remove all references to the ALPHA - file, or ALPHA version logic. Added stuff about DIST_POINT in - place of DIST_TYPE and the alpha release number stuff. - -2000-11-22 Frank Warmerdam - - * I have applied a patch from Steffen Moeller to - the configure script so that it now accepts the --prefix, and - --exec-prefix directives. - -2000-11-13 Frank Warmerdam - - * I have made a variety of modifications in an effort to ensure the - TIFFLIB_VERSION macro is automatically generated from the RELEASE-DATE - file which seems to be updated regularly. - - o mkversion.c now reads RELEASE-DATE and emits TIFFLIB_VERSION in - version include file. - o renamed version.h to tiffvers.h because we now have to install it - with the public libtiff include files. - o include tiffvers.h in tiffio.h. - o updated tif_version.c to use tiffvers.h. - o Updated Makefile.in accordingly. - - * As per http://bugzilla.remotesensing.org/show_bug.cgi?id=25 - I have updated the win32 detection rules in tiffcomp.h. - -2000-10-20 Frank Warmerdam - - * tif_getimage.c: Fixed RGBA translation for YCbCr images for which - the strip/tile width and height aren't multiples of the sampling size. - See http://bugzilla.remotesensing.org/show_bug.cgi?id=20 - Some patches from Rick LaMont of Dot C Software. - - * Modified tif_packbits.c encoder to avoid compressing more - data than provided if rowsize doesn't factor into provided data - (such as occurs for YCbCr). - -2000-10-19 Frank Warmerdam - - * tools/rgb2ycbcr.c: fixed output strip size to account for vertical - roundup if rows_per_strip not a multiple of vertical sample size. - -2000-10-16 Frank Warmerdam - - * tif_dir.c: Clear TIFF_ISTILED flag in TIFFDefaultDirectory - as per http://bugzilla.remotesensing.org/show_bug.cgi?id=18 - from vandrove@vc.cvut.cz. - - * Modified tif_packbits.c decoding to avoid overrunning the - output buffer, and to issue a warning if data needs to be - discarded. See http://bugzilla.remotesensing.org/show_bug.cgi?id=18 - -2000-10-12 Frank Warmerdam - - * Modified tiff2bw to ensure portions add to 100%, and that - white is properly recovered. - - See bug http://bugzilla.remotesensing.org/show_bug.cgi?id=15 - Patch c/o Stanislav Brabec - -2000-09-30 Frank Warmerdam - - * Modified TIFFClientOpen() to emit an error on an attempt to - open a comperessed file for update (O_RDWR/r+) access. This is - because the compressor/decompressor code gets very confused when - the mode is O_RDWR, assuming this means writing only. See - bug http://bugzilla.remotesensing.org/show_bug.cgi?id=13 - -2000-09-27 Frank Warmerdam - - * Added GNULDdso target an`d switched linux and freebsd to use it. - -2000-09-26 Frank Warmerdam - - * Applied patch for 0x0000 sequences in tif_fax3.h's definition - of EXPAND1D() as per bug 11 (from Roman). - -2000-09-25 Frank Warmerdam - * Fixed tiffcomp.h to avoid win32 stuff if unix #defined, to improve - cygwin compatibility. - - * Applied patch from Roman Shpount to tif_fax3.c. This seems to - be a proper fix to the buffer sizing problem. See - http://bugzilla.remotesensing.org/show_bug.cgi?id=11 - - * Fixed tif_getimage.c to fix overrun bug with YCbCr images without - downsampling. http://bugzilla.remotesensing.org/show_bug.cgi?id=10 - Thanks to Nick Lamb for reporting the - bug and proving the patch. - -2000-09-18 Frank Warmerdam - - * Fixed tif_jpeg.c so avoid destroying the decompressor before - we are done access data thanks to bug report from: - Michael Eckstein . - - * Reverted tif_flush change. - -2000-09-14 Frank Warmerdam - - * tif_flush.c: Changed so that TIFFFlushData() doesn't return an - error when TIFF_BEENWRITING is not set. This ensures that the - directory contents can still be flushed by TIFFFlush(). - -2000-08-14 Frank Warmerdam - - * tif_open.c: Don't set MMAP for O_RDWR files. - - * tif_open.c: Set STRIPCHOP_DEFAULT for O_RDWR as well as O_RDONLY - so that files opened for update can be strip chopped too. - - * tif_read.c: fixed up bug with files missing rowsperstrip and - the strips per separation fix done a few weeks ago. - -2000-07-17 Frank Warmerdam - - * Tentatively added support for SAMPLEFORMAT_COMPLEXIEEEFP, and - SAMPLEFORMAT_COMPLEXINT. - -2000-07-13 Mike Welles - - * index.html, bugs.html: added bugzilla info. - -2000-07-12 Frank Warmerdam - - * tif_read.c: fix subtle bug with determining the number of - rows for strips that are the last strip in a separation but - not the last strip of all in TIFFReadEncodedStrip(). - - * Applied 16/32 bit fix to tif_fax3.c. Fix supplied by - Peter Skarpetis - -2000-06-15 Frank Warmerdam - - * Modified tiffio.h logic with regard to including windows.h. It - won't include it when building with __CYGWIN__. - -2000-05-11 Frank Warmerdam - - * README: update to mention www.libtiff.org, don't list Sam's old - email address. - - * configure: Fixed DSO test for Linux as per patch from - Jan Van Buggenhout . - -2000-04-21 Frank Warmerdam - - * libtiff/tif_dirread.c: Don't use estimate strip byte count for - one tile/strip images with an offset, and byte count of zero. These - could be "unpopulated" images. - -2000-04-18 Frank Warmerdam - - * contrib/addtiffo: Added "averaging" resampling option. - - * tools/tiffsplit.c: Copy TIFFTAG_SAMPLEFORMAT. - -Tue Apr 18 16:18:08 2000 Frank Warmerdam - - * tools/Makefile.in: Modified to install properly on SGI. - -2000-04-12 Mike Welles - * configure: Fixed stupid mistake in libc6 test on Linux - -2000-04-04 Mike Welles - * tif_win32.c: Applied patch to fix overreads and ovverwrites - caught by BoundsChecker. From Arvan Pritchard - (untested). - - * tif_getimage.c: Applied patch to silence VC6 warnings. From - Arvan Pritchard - - * tif_lzw.c: Applied patch to silence VC6 warnings. From - Arvan Pritchard - -2000-03-28 Frank Warmerdam - - * Added contrib/stream (stream io) code submitted by Avi Bleiweiss. - -2000-03-28 Frank Warmerdam *** 3.5.5 release *** - - * fax2ps: Fixed mixup of width and height in bounding box statement - as per submission by Nalin Dahyabhai . - -2000-03-27 Mike Welles - - * fax2ps: Modified printruns to take uint32 instead of uint16. - Patch courtesy of Bernt Herd - -2000-03-20 Mike Welles - - * configure: added test for libc6 for linux targets. Bug reported by - Stanislav Brabec - - * Added 3.5 docs to html/Makefile.in. - Thanks to Stanislav Brabec - - * configure: fixed bugs in sed scripts - (applied sed script s:/@:s;@:;s:/s;;:;: to configure). - fix submitted to Stanislav Brabec - - * tools/iptcutil was not in files list, and wasn't being - added to tar archive. Updated Makefile.in. - -2000-03-17 Frank Warmerdam - - * tif_fax3.c: Fixed serious bug introduced during the uint16->uint32 - conversion for the run arrays. - -2000-03-03 Frank Warmerdam - - * Set td_sampleformat default to SAMPLEFORMAT_UINT instead of - SAMPLEFORMAT_VOID in TIFFDefaultDirectory() in tif_dir.c. - -2000-03-02 Frank Warmerdam - - * Added "GetDefaulted" support for TIFFTAG_SAMPLEFORMAT in tif_aux.c. - - * Patched tif_fax3.c so that dsp->runs is allocated a bit bigger - to avoid overruns encountered with frle_bug.tif. - -Tue Feb 15 22:01:05 2000 Frank Warmerdam - - * Fixed tools/tiffcmp so that stopondiff testing works. - Patch care of Joseph Orost . - -2000-01-28 - - * Modified tif_unix.c to support 2-4GB seeks if USE_64BIT_API is - set to 1, and added default (off) setting in tiffconf.h. This - should eventually be set by the configure script somehow. - - The original work on all these 2-4GB changes was done by - Peter Smith (psmith@creo.com). - - * Modified tif_win32.c to support 2-4GB seeks. - - * tentatively changed toff_t to be unsigned instead of signed to - facilitate support for 2-4GB files. - - * Updated a variety of files to use toff_t. Fixed some mixups - between toff_t and tsize_t. - -Fri Jan 28 10:13:49 2000 Frank Warmerdam - - * Largely reimplemented contrib/addtiffo to avoid temp files, - updating the TIFF file in place. Fixed a few other bugs to. - - * Set tif_rawdatasize to zero when freeing raw data buffer in - TIFFWriteDirectory(). - - * Enabled "REWRITE_HACK" in tif_write.c by default. - - * Fix bug in tif_write.c when switching between reading one directory - and writing to another. - - * Made TIFFWriteCheck() public, and added TIFFCreateDirectory() - -Wed Jan 5 12:37:48 2000 Frank Warmerdam - - * Added TIFFmemory(3t) functions to libtiff.def. - -Tue Jan 4 13:39:00 2000 Frank Warmerdam - - * Added libtiff/libtiff.def to TIFFILES distribution list. - -Mon Dec 27 12:13:39 EST 1999 Mike Welles - - * Created lzw compression kit, as a new module (libtiff-lzw-compression-kit). - - * Altered descriptions in tools to reflect "by default" lzw not supported - - * Updated index.html to note lzw compression kit. - -Tue Dec 21 14:01:51 1999 Frank Warmerdam - - * Added fax3sm_winnt.c to distribution list in Makefile.in. - -Tue Dec 21 11:04:45 EST 1999 Mike Welles *** 3.5.4 release *** - - * Aadded Pixar tag support. Contributed by Phil Beffery - - * Made one more change to tif_dir.c for removal of LZW compression. Also added notice - when LZW compression invoked. - - * Changed default compression in tools to TIFF_PACKBITS, and changed usage descriptions - in tools to reflect removal of LZW compression - -Mon Dec 20 18:39:02 EST 1999 Mike Welles - - * Fixed bug that caused LZW (non) compression to segfault. Added - warning about LZW compression removed being removed, and why. - - * Added nostrip to install in tools/Makefile.in so that debugging - symbols are kept. - -Tue Dec 7 12:04:47 EST 1999 Mike Welles - - * Added patch from Ivo Penzar , - supporting Adobe ZIP deflate. Untested. - -Sat Dec 4 15:47:11 1999 Frank Warmerdam - - * Made Packbits the default compression in tools/tiff2rgba.c instead - of LZW. - -Tue Nov 30 14:41:43 1999 Frank Warmerdam *** 3.5.3. release *** - - * Added tif_luv to contrib/djgpp/Makefile.lib. - -Tue Nov 30 14:15:32 EST 1999 Mike Welles - - * Added zip creation to relase makefile target - - * Added html for TIFFWriteTile.3t man page. - -Tue Nov 30 09:20:16 1999 Frank Warmerdam - - * Added some changes to tif_write.c to support rewriting existing - fixed sized tiles and strips. Code mods disabled by default, only - enabled if REWRITE_HACK is defined for now. - -Mon Nov 29 11:43:42 1999 Frank Warmerdam - - * Added TIFFWriteTile.3t man page. - -Sun Nov 28 20:36:18 1999 Frank Warmerdam - - * Added notes on use of makefile.vc in build.html, and fixed - email subscription address. - -199-11-28 Mike Welles - - * Fixed apocalypse-inducing y2k bug in contrib/ras/ras2tiff.c - - * Did some casts cleaning up to reduce compiler warnings in tif_fax3.c, - from Bruce Carmeron -- modifications of - changes made by Frank (sun cc still complained on cast). - - * Added tiffconf.h to install target per request from Bill - Radcliffe : "We need a way for ImageMagick to - know features have been compiled into the TIFF library in order to - handle things properly". - -Sat Nov 27 16:49:21 1999 Frank Warmerdam - - * fixed various VC++ warnings as suggested by Gilles Vollant - . - -Wed Nov 24 12:08:16 1999 Frank Warmerdam - - * Modified TIFFquery.3t man pages info on TIFFIsByteSwapped() to - not imply applications are responsible for image data swapping. - -1999-11-22 Mike Welles - * HTML-ized the man pages, added to html/man - - * Removed LZW Compression to comply with Unisys patent extortion. - -1999-09-29 Mike Welles - * Corrected one remaining 16 -> 32 bit value in tif_fax3.c, - From Ivo Penzar - -1999-09-26 Mike Welles *** 3.5.2 release *** - * Corrected alpha versioning. - - * Removed distinction between alpha and release targets in Makefile.in. - - * added release.stamp target, which tags cvs tree, and updates - "RELEASE-DATE" - - * added releasediff target, which diffs tree with source as of - date in "RELEASE-DATE" - - * Ticked up version to 3.5.2 (alpha 01 -- but I think we'll moving - away from alpha/non-alpha distinctions). - - * updated html to reflect release - -1999-09-23 - - * Set O_BINARY for tif_unix.c open() ... used on cygwin for instance. - - * Added CYGWIN case in configure. - -Fri Sep 17 00:13:51 CEST 1999 Mike Welles - - * Applied Francois Dagand's patch to handle fax decompression bug. - (sizes >= 65536 were failing) - -Tue Sep 14 21:31:43 1999 Frank Warmerdam - - * Applied "a" mode fix to tif_win32.c/TIFFOpen() as suggested - by Christopher Lawton - -Wed Sep 8 08:19:18 1999 Frank Warmerdam - - * Added IRIX/gcc, and OSF/1 4.x support on behalf of - Albert Chin-A-Young - - * Added TIFFReassignTagToIgnore() API on behalf of - Bruce Cameron . Man page still pending. - -Wed Aug 25 11:39:07 1999 Frank Warmerdam - - * Added test target in Makefile, test_pics.sh script and pics/*.rpt - files to provide for a rudimentary testsuite. - - * Added contrib/tags back from old distribution ... fixed up a bit. - -1999-08-16 - - * Added simple makefile.vc makefiles for building with MS VC++ - on Windows NT/98/95 in console mode. Stuff in contrib/win* make give - better solutions for some users. - -Mon Aug 16 21:52:11 1999 Frank Warmerdam - - * Added addtiffo (add overviews to a TIFF file) in contrib. Didn't - put it in tools since part of it is in C++. - -1999-08-16 Michael L. Welles - - * Updated html/index.html with anon CVS instructions. - -Mon Aug 16 13:18:41 1999 Frank Warmerdam - - * pre-remove so link before softlink in LINUXdso action in - libtiff/Makefile.in to avoid failure on LINUXdso builds other than - the first. - - * Fixed problem with cvtcmap() in tif_getimage.c modifying the - colormaps owned by the TIFF handle itself when trying to fixup wrong - (eight bit) colormaps. Corrected by maintaining a private copy of - the colormap. - - * Added TIFFReadRGBATile()/TIFFReadRGBAStrip() support in - tif_getimage.c. - - * CVS Repository placed at remotesensing.org. ChangeLog added. diff --git a/plugins/AdvaImg/src/LibTIFF/LibTIFF.dsp b/plugins/AdvaImg/src/LibTIFF/LibTIFF.dsp deleted file mode 100644 index 9dd04050be..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/LibTIFF.dsp +++ /dev/null @@ -1,293 +0,0 @@ -# Microsoft Developer Studio Project File - Name="LibTIFF" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** NICHT BEARBEITEN ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=LibTIFF - Win32 Debug -!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE -!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl -!MESSAGE -!MESSAGE NMAKE /f "LibTIFF.mak". -!MESSAGE -!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben -!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: -!MESSAGE -!MESSAGE NMAKE /f "LibTIFF.mak" CFG="LibTIFF - Win32 Debug" -!MESSAGE -!MESSAGE Für die Konfiguration stehen zur Auswahl: -!MESSAGE -!MESSAGE "LibTIFF - Win32 Release" (basierend auf "Win32 (x86) Static Library") -!MESSAGE "LibTIFF - Win32 Debug" (basierend auf "Win32 (x86) Static Library") -!MESSAGE "LibTIFF - Win32 Release Unicode" (basierend auf "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "LibTIFF - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "LibTIFF - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "LibTIFF - Win32 Release Unicode" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "LibTIFF___Win32_Release_Unicode" -# PROP BASE Intermediate_Dir "LibTIFF___Win32_Release_Unicode" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "LibTIFF___Win32_Release_Unicode" -# PROP Intermediate_Dir "LibTIFF___Win32_Release_Unicode" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ENDIF - -# Begin Target - -# Name "LibTIFF - Win32 Release" -# Name "LibTIFF - Win32 Debug" -# Name "LibTIFF - Win32 Release Unicode" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\tif_aux.c -# End Source File -# Begin Source File - -SOURCE=.\tif_close.c -# End Source File -# Begin Source File - -SOURCE=.\tif_codec.c -# End Source File -# Begin Source File - -SOURCE=.\tif_color.c -# End Source File -# Begin Source File - -SOURCE=.\tif_compress.c -# End Source File -# Begin Source File - -SOURCE=.\tif_dir.c -# End Source File -# Begin Source File - -SOURCE=.\tif_dirinfo.c -# End Source File -# Begin Source File - -SOURCE=.\tif_dirread.c -# End Source File -# Begin Source File - -SOURCE=.\tif_dirwrite.c -# End Source File -# Begin Source File - -SOURCE=.\tif_dumpmode.c -# End Source File -# Begin Source File - -SOURCE=.\tif_error.c -# End Source File -# Begin Source File - -SOURCE=.\tif_extension.c -# End Source File -# Begin Source File - -SOURCE=.\tif_fax3.c -# End Source File -# Begin Source File - -SOURCE=.\tif_fax3sm.c -# End Source File -# Begin Source File - -SOURCE=.\tif_flush.c -# End Source File -# Begin Source File - -SOURCE=.\tif_getimage.c -# End Source File -# Begin Source File - -SOURCE=.\tif_jpeg.c -# End Source File -# Begin Source File - -SOURCE=.\tif_luv.c -# End Source File -# Begin Source File - -SOURCE=.\tif_lzw.c -# End Source File -# Begin Source File - -SOURCE=.\tif_next.c -# End Source File -# Begin Source File - -SOURCE=.\tif_open.c -# End Source File -# Begin Source File - -SOURCE=.\tif_packbits.c -# End Source File -# Begin Source File - -SOURCE=.\tif_pixarlog.c -# End Source File -# Begin Source File - -SOURCE=.\tif_predict.c -# End Source File -# Begin Source File - -SOURCE=.\tif_print.c -# End Source File -# Begin Source File - -SOURCE=.\tif_read.c -# End Source File -# Begin Source File - -SOURCE=.\tif_strip.c -# End Source File -# Begin Source File - -SOURCE=.\tif_swab.c -# End Source File -# Begin Source File - -SOURCE=.\tif_thunder.c -# End Source File -# Begin Source File - -SOURCE=.\tif_tile.c -# End Source File -# Begin Source File - -SOURCE=.\tif_version.c -# End Source File -# Begin Source File - -SOURCE=.\tif_warning.c -# End Source File -# Begin Source File - -SOURCE=.\tif_write.c -# End Source File -# Begin Source File - -SOURCE=.\tif_zip.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\t4.h -# End Source File -# Begin Source File - -SOURCE=.\tif_config.h -# End Source File -# Begin Source File - -SOURCE=.\tif_dir.h -# End Source File -# Begin Source File - -SOURCE=.\tif_fax3.h -# End Source File -# Begin Source File - -SOURCE=.\tif_predict.h -# End Source File -# Begin Source File - -SOURCE=.\tiff.h -# End Source File -# Begin Source File - -SOURCE=.\tiffio.h -# End Source File -# Begin Source File - -SOURCE=.\tiffiop.h -# End Source File -# Begin Source File - -SOURCE=.\tiffvers.h -# End Source File -# Begin Source File - -SOURCE=.\uvcode.h -# End Source File -# End Group -# End Target -# End Project diff --git a/plugins/AdvaImg/src/LibTIFF/SConstruct b/plugins/AdvaImg/src/LibTIFF/SConstruct deleted file mode 100644 index d1a2620cf5..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/SConstruct +++ /dev/null @@ -1,73 +0,0 @@ -# $Id: SConstruct,v 1.29 2011/04/10 17:14:09 drolon Exp $ - -# Tag Image File Format (TIFF) Software -# -# Copyright (C) 2005, Andrey Kiselev -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, provided -# that (i) the above copyright notices and this permission notice appear in -# all copies of the software and related documentation, and (ii) the names of -# Sam Leffler and Silicon Graphics may not be used in any advertising or -# publicity relating to the software without the specific, prior written -# permission of Sam Leffler and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# -# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -# OF THIS SOFTWARE. - -# This file contains rules to build software with the SCons tool -# (see the http://www.scons.org/ for details on SCons). - -# Import globally defined options -Import([ 'env', 'idir_lib' ]) - -SRCS = [ \ - 'tif_aux.c', \ - 'tif_close.c', \ - 'tif_codec.c', \ - 'tif_color.c', \ - 'tif_compress.c', \ - 'tif_dir.c', \ - 'tif_dirinfo.c', \ - 'tif_dirread.c', \ - 'tif_dirwrite.c', \ - 'tif_dumpmode.c', \ - 'tif_error.c', \ - 'tif_extension.c', \ - 'tif_fax3.c', \ - 'tif_fax3sm.c', \ - 'tif_flush.c', \ - 'tif_getimage.c', \ - 'tif_jbig.c', \ - 'tif_jpeg.c', \ - 'tif_luv.c', \ - 'tif_lzw.c', \ - 'tif_next.c', \ - 'tif_ojpeg.c', \ - 'tif_open.c', \ - 'tif_packbits.c', \ - 'tif_pixarlog.c', \ - 'tif_predict.c', \ - 'tif_print.c', \ - 'tif_read.c', \ - 'tif_strip.c', \ - 'tif_swab.c', \ - 'tif_thunder.c', \ - 'tif_tile.c', \ - 'tif_unix.c', \ - 'tif_version.c', \ - 'tif_warning.c', \ - 'tif_write.c', \ - 'tif_zip.c' ] - -StaticLibrary('tiff', SRCS) -SharedLibrary('tiff', SRCS) - diff --git a/plugins/AdvaImg/src/LibTIFF/mkg3states.c b/plugins/AdvaImg/src/LibTIFF/mkg3states.c deleted file mode 100644 index 46fac37a9c..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/mkg3states.c +++ /dev/null @@ -1,451 +0,0 @@ -/* "$Id: mkg3states.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1991-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* Initialise fax decoder tables - * Decoder support is derived, with permission, from the code - * in Frank Cringle's viewfax program; - * Copyright (C) 1990, 1995 Frank D. Cringle. - */ -#include "tif_config.h" - -#include -#include -#include - -#ifdef HAVE_UNISTD_H -# include -#endif - -#include "tif_fax3.h" - -#ifndef HAVE_GETOPT -extern int getopt(int, char**, char*); -#endif - -#define streq(a,b) (strcmp(a,b) == 0) - -/* NB: can't use names in tif_fax3.h 'cuz they are declared const */ -TIFFFaxTabEnt MainTable[128]; -TIFFFaxTabEnt WhiteTable[4096]; -TIFFFaxTabEnt BlackTable[8192]; - -struct proto { - uint16 code; /* right justified, lsb-first, zero filled */ - uint16 val; /* (pixel count)<<4 + code width */ -}; - -static struct proto Pass[] = { -{ 0x0008, 4 }, -{ 0, 0 } -}; - -static struct proto Horiz[] = { -{ 0x0004, 3 }, -{ 0, 0 } -}; - -static struct proto V0[] = { -{ 0x0001, 1 }, -{ 0, 0 } -}; - -static struct proto VR[] = { -{ 0x0006, (1<<4)+3 }, -{ 0x0030, (2<<4)+6 }, -{ 0x0060, (3<<4)+7 }, -{ 0, 0 } -}; - -static struct proto VL[] = { -{ 0x0002, (1<<4)+3 }, -{ 0x0010, (2<<4)+6 }, -{ 0x0020, (3<<4)+7 }, -{ 0, 0 } -}; - -static struct proto Ext[] = { -{ 0x0040, 7 }, -{ 0, 0 } -}; - -static struct proto EOLV[] = { -{ 0x0000, 7 }, -{ 0, 0 } -}; - -static struct proto MakeUpW[] = { -{ 0x001b, 1029 }, -{ 0x0009, 2053 }, -{ 0x003a, 3078 }, -{ 0x0076, 4103 }, -{ 0x006c, 5128 }, -{ 0x00ec, 6152 }, -{ 0x0026, 7176 }, -{ 0x00a6, 8200 }, -{ 0x0016, 9224 }, -{ 0x00e6, 10248 }, -{ 0x0066, 11273 }, -{ 0x0166, 12297 }, -{ 0x0096, 13321 }, -{ 0x0196, 14345 }, -{ 0x0056, 15369 }, -{ 0x0156, 16393 }, -{ 0x00d6, 17417 }, -{ 0x01d6, 18441 }, -{ 0x0036, 19465 }, -{ 0x0136, 20489 }, -{ 0x00b6, 21513 }, -{ 0x01b6, 22537 }, -{ 0x0032, 23561 }, -{ 0x0132, 24585 }, -{ 0x00b2, 25609 }, -{ 0x0006, 26630 }, -{ 0x01b2, 27657 }, -{ 0, 0 } -}; - -static struct proto MakeUpB[] = { -{ 0x03c0, 1034 }, -{ 0x0130, 2060 }, -{ 0x0930, 3084 }, -{ 0x0da0, 4108 }, -{ 0x0cc0, 5132 }, -{ 0x02c0, 6156 }, -{ 0x0ac0, 7180 }, -{ 0x06c0, 8205 }, -{ 0x16c0, 9229 }, -{ 0x0a40, 10253 }, -{ 0x1a40, 11277 }, -{ 0x0640, 12301 }, -{ 0x1640, 13325 }, -{ 0x09c0, 14349 }, -{ 0x19c0, 15373 }, -{ 0x05c0, 16397 }, -{ 0x15c0, 17421 }, -{ 0x0dc0, 18445 }, -{ 0x1dc0, 19469 }, -{ 0x0940, 20493 }, -{ 0x1940, 21517 }, -{ 0x0540, 22541 }, -{ 0x1540, 23565 }, -{ 0x0b40, 24589 }, -{ 0x1b40, 25613 }, -{ 0x04c0, 26637 }, -{ 0x14c0, 27661 }, -{ 0, 0 } -}; - -static struct proto MakeUp[] = { -{ 0x0080, 28683 }, -{ 0x0180, 29707 }, -{ 0x0580, 30731 }, -{ 0x0480, 31756 }, -{ 0x0c80, 32780 }, -{ 0x0280, 33804 }, -{ 0x0a80, 34828 }, -{ 0x0680, 35852 }, -{ 0x0e80, 36876 }, -{ 0x0380, 37900 }, -{ 0x0b80, 38924 }, -{ 0x0780, 39948 }, -{ 0x0f80, 40972 }, -{ 0, 0 } -}; - -static struct proto TermW[] = { -{ 0x00ac, 8 }, -{ 0x0038, 22 }, -{ 0x000e, 36 }, -{ 0x0001, 52 }, -{ 0x000d, 68 }, -{ 0x0003, 84 }, -{ 0x0007, 100 }, -{ 0x000f, 116 }, -{ 0x0019, 133 }, -{ 0x0005, 149 }, -{ 0x001c, 165 }, -{ 0x0002, 181 }, -{ 0x0004, 198 }, -{ 0x0030, 214 }, -{ 0x000b, 230 }, -{ 0x002b, 246 }, -{ 0x0015, 262 }, -{ 0x0035, 278 }, -{ 0x0072, 295 }, -{ 0x0018, 311 }, -{ 0x0008, 327 }, -{ 0x0074, 343 }, -{ 0x0060, 359 }, -{ 0x0010, 375 }, -{ 0x000a, 391 }, -{ 0x006a, 407 }, -{ 0x0064, 423 }, -{ 0x0012, 439 }, -{ 0x000c, 455 }, -{ 0x0040, 472 }, -{ 0x00c0, 488 }, -{ 0x0058, 504 }, -{ 0x00d8, 520 }, -{ 0x0048, 536 }, -{ 0x00c8, 552 }, -{ 0x0028, 568 }, -{ 0x00a8, 584 }, -{ 0x0068, 600 }, -{ 0x00e8, 616 }, -{ 0x0014, 632 }, -{ 0x0094, 648 }, -{ 0x0054, 664 }, -{ 0x00d4, 680 }, -{ 0x0034, 696 }, -{ 0x00b4, 712 }, -{ 0x0020, 728 }, -{ 0x00a0, 744 }, -{ 0x0050, 760 }, -{ 0x00d0, 776 }, -{ 0x004a, 792 }, -{ 0x00ca, 808 }, -{ 0x002a, 824 }, -{ 0x00aa, 840 }, -{ 0x0024, 856 }, -{ 0x00a4, 872 }, -{ 0x001a, 888 }, -{ 0x009a, 904 }, -{ 0x005a, 920 }, -{ 0x00da, 936 }, -{ 0x0052, 952 }, -{ 0x00d2, 968 }, -{ 0x004c, 984 }, -{ 0x00cc, 1000 }, -{ 0x002c, 1016 }, -{ 0, 0 } -}; - -static struct proto TermB[] = { -{ 0x03b0, 10 }, -{ 0x0002, 19 }, -{ 0x0003, 34 }, -{ 0x0001, 50 }, -{ 0x0006, 67 }, -{ 0x000c, 84 }, -{ 0x0004, 100 }, -{ 0x0018, 117 }, -{ 0x0028, 134 }, -{ 0x0008, 150 }, -{ 0x0010, 167 }, -{ 0x0050, 183 }, -{ 0x0070, 199 }, -{ 0x0020, 216 }, -{ 0x00e0, 232 }, -{ 0x0030, 249 }, -{ 0x03a0, 266 }, -{ 0x0060, 282 }, -{ 0x0040, 298 }, -{ 0x0730, 315 }, -{ 0x00b0, 331 }, -{ 0x01b0, 347 }, -{ 0x0760, 363 }, -{ 0x00a0, 379 }, -{ 0x0740, 395 }, -{ 0x00c0, 411 }, -{ 0x0530, 428 }, -{ 0x0d30, 444 }, -{ 0x0330, 460 }, -{ 0x0b30, 476 }, -{ 0x0160, 492 }, -{ 0x0960, 508 }, -{ 0x0560, 524 }, -{ 0x0d60, 540 }, -{ 0x04b0, 556 }, -{ 0x0cb0, 572 }, -{ 0x02b0, 588 }, -{ 0x0ab0, 604 }, -{ 0x06b0, 620 }, -{ 0x0eb0, 636 }, -{ 0x0360, 652 }, -{ 0x0b60, 668 }, -{ 0x05b0, 684 }, -{ 0x0db0, 700 }, -{ 0x02a0, 716 }, -{ 0x0aa0, 732 }, -{ 0x06a0, 748 }, -{ 0x0ea0, 764 }, -{ 0x0260, 780 }, -{ 0x0a60, 796 }, -{ 0x04a0, 812 }, -{ 0x0ca0, 828 }, -{ 0x0240, 844 }, -{ 0x0ec0, 860 }, -{ 0x01c0, 876 }, -{ 0x0e40, 892 }, -{ 0x0140, 908 }, -{ 0x01a0, 924 }, -{ 0x09a0, 940 }, -{ 0x0d40, 956 }, -{ 0x0340, 972 }, -{ 0x05a0, 988 }, -{ 0x0660, 1004 }, -{ 0x0e60, 1020 }, -{ 0, 0 } -}; - -static struct proto EOLH[] = { -{ 0x0000, 11 }, -{ 0, 0 } -}; - -static void -FillTable(TIFFFaxTabEnt *T, int Size, struct proto *P, int State) -{ - int limit = 1 << Size; - - while (P->val) { - int width = P->val & 15; - int param = P->val >> 4; - int incr = 1 << width; - int code; - for (code = P->code; code < limit; code += incr) { - TIFFFaxTabEnt *E = T+code; - E->State = State; - E->Width = width; - E->Param = param; - } - P++; - } -} - -static char* storage_class = ""; -static char* const_class = ""; -static int packoutput = 1; -static char* prebrace = ""; -static char* postbrace = ""; - -void -WriteTable(FILE* fd, const TIFFFaxTabEnt* T, int Size, const char* name) -{ - int i; - char* sep; - - fprintf(fd, "%s %s TIFFFaxTabEnt %s[%d] = {", - storage_class, const_class, name, Size); - if (packoutput) { - sep = "\n"; - for (i = 0; i < Size; i++) { - fprintf(fd, "%s%s%d,%d,%d%s", - sep, prebrace, T->State, T->Width, (int) T->Param, postbrace); - if (((i+1) % 10) == 0) - sep = ",\n"; - else - sep = ","; - T++; - } - } else { - sep = "\n "; - for (i = 0; i < Size; i++) { - fprintf(fd, "%s%s%3d,%3d,%4d%s", - sep, prebrace, T->State, T->Width, (int) T->Param, postbrace); - if (((i+1) % 6) == 0) - sep = ",\n "; - else - sep = ","; - T++; - } - } - fprintf(fd, "\n};\n"); -} - -/* initialise the huffman code tables */ -int -main(int argc, char* argv[]) -{ - FILE* fd; - char* outputfile; - int c; - extern int optind; - extern char* optarg; - - while ((c = getopt(argc, argv, "c:s:bp")) != -1) - switch (c) { - case 'c': - const_class = optarg; - break; - case 's': - storage_class = optarg; - break; - case 'p': - packoutput = 0; - break; - case 'b': - prebrace = "{"; - postbrace = "}"; - break; - case '?': - fprintf(stderr, - "usage: %s [-c const] [-s storage] [-p] [-b] file\n", - argv[0]); - return (-1); - } - outputfile = optind < argc ? argv[optind] : "g3states.h"; - fd = fopen(outputfile, "w"); - if (fd == NULL) { - fprintf(stderr, "%s: %s: Cannot create output file.\n", - argv[0], outputfile); - return (-2); - } - FillTable(MainTable, 7, Pass, S_Pass); - FillTable(MainTable, 7, Horiz, S_Horiz); - FillTable(MainTable, 7, V0, S_V0); - FillTable(MainTable, 7, VR, S_VR); - FillTable(MainTable, 7, VL, S_VL); - FillTable(MainTable, 7, Ext, S_Ext); - FillTable(MainTable, 7, EOLV, S_EOL); - FillTable(WhiteTable, 12, MakeUpW, S_MakeUpW); - FillTable(WhiteTable, 12, MakeUp, S_MakeUp); - FillTable(WhiteTable, 12, TermW, S_TermW); - FillTable(WhiteTable, 12, EOLH, S_EOL); - FillTable(BlackTable, 13, MakeUpB, S_MakeUpB); - FillTable(BlackTable, 13, MakeUp, S_MakeUp); - FillTable(BlackTable, 13, TermB, S_TermB); - FillTable(BlackTable, 13, EOLH, S_EOL); - - fprintf(fd, "/* WARNING, this file was automatically generated by the\n"); - fprintf(fd, " mkg3states program */\n"); - fprintf(fd, "#include \"tiff.h\"\n"); - fprintf(fd, "#include \"tif_fax3.h\"\n"); - WriteTable(fd, MainTable, 128, "TIFFFaxMainTable"); - WriteTable(fd, WhiteTable, 4096, "TIFFFaxWhiteTable"); - WriteTable(fd, BlackTable, 8192, "TIFFFaxBlackTable"); - fclose(fd); - return (0); -} - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/t4.h b/plugins/AdvaImg/src/LibTIFF/t4.h deleted file mode 100644 index 1457ebfabe..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/t4.h +++ /dev/null @@ -1,292 +0,0 @@ -/* $Id: t4.h,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _T4_ -#define _T4_ -/* - * CCITT T.4 1D Huffman runlength codes and - * related definitions. Given the small sizes - * of these tables it does not seem - * worthwhile to make code & length 8 bits. - */ -typedef struct tableentry { - unsigned short length; /* bit length of g3 code */ - unsigned short code; /* g3 code */ - short runlen; /* run length in bits */ -} tableentry; - -#define EOL 0x001 /* EOL code value - 0000 0000 0000 1 */ - -/* status values returned instead of a run length */ -#define G3CODE_EOL -1 /* NB: ACT_EOL - ACT_WRUNT */ -#define G3CODE_INVALID -2 /* NB: ACT_INVALID - ACT_WRUNT */ -#define G3CODE_EOF -3 /* end of input data */ -#define G3CODE_INCOMP -4 /* incomplete run code */ - -/* - * Note that these tables are ordered such that the - * index into the table is known to be either the - * run length, or (run length / 64) + a fixed offset. - * - * NB: The G3CODE_INVALID entries are only used - * during state generation (see mkg3states.c). - */ -#ifdef G3CODES -const tableentry TIFFFaxWhiteCodes[] = { - { 8, 0x35, 0 }, /* 0011 0101 */ - { 6, 0x7, 1 }, /* 0001 11 */ - { 4, 0x7, 2 }, /* 0111 */ - { 4, 0x8, 3 }, /* 1000 */ - { 4, 0xB, 4 }, /* 1011 */ - { 4, 0xC, 5 }, /* 1100 */ - { 4, 0xE, 6 }, /* 1110 */ - { 4, 0xF, 7 }, /* 1111 */ - { 5, 0x13, 8 }, /* 1001 1 */ - { 5, 0x14, 9 }, /* 1010 0 */ - { 5, 0x7, 10 }, /* 0011 1 */ - { 5, 0x8, 11 }, /* 0100 0 */ - { 6, 0x8, 12 }, /* 0010 00 */ - { 6, 0x3, 13 }, /* 0000 11 */ - { 6, 0x34, 14 }, /* 1101 00 */ - { 6, 0x35, 15 }, /* 1101 01 */ - { 6, 0x2A, 16 }, /* 1010 10 */ - { 6, 0x2B, 17 }, /* 1010 11 */ - { 7, 0x27, 18 }, /* 0100 111 */ - { 7, 0xC, 19 }, /* 0001 100 */ - { 7, 0x8, 20 }, /* 0001 000 */ - { 7, 0x17, 21 }, /* 0010 111 */ - { 7, 0x3, 22 }, /* 0000 011 */ - { 7, 0x4, 23 }, /* 0000 100 */ - { 7, 0x28, 24 }, /* 0101 000 */ - { 7, 0x2B, 25 }, /* 0101 011 */ - { 7, 0x13, 26 }, /* 0010 011 */ - { 7, 0x24, 27 }, /* 0100 100 */ - { 7, 0x18, 28 }, /* 0011 000 */ - { 8, 0x2, 29 }, /* 0000 0010 */ - { 8, 0x3, 30 }, /* 0000 0011 */ - { 8, 0x1A, 31 }, /* 0001 1010 */ - { 8, 0x1B, 32 }, /* 0001 1011 */ - { 8, 0x12, 33 }, /* 0001 0010 */ - { 8, 0x13, 34 }, /* 0001 0011 */ - { 8, 0x14, 35 }, /* 0001 0100 */ - { 8, 0x15, 36 }, /* 0001 0101 */ - { 8, 0x16, 37 }, /* 0001 0110 */ - { 8, 0x17, 38 }, /* 0001 0111 */ - { 8, 0x28, 39 }, /* 0010 1000 */ - { 8, 0x29, 40 }, /* 0010 1001 */ - { 8, 0x2A, 41 }, /* 0010 1010 */ - { 8, 0x2B, 42 }, /* 0010 1011 */ - { 8, 0x2C, 43 }, /* 0010 1100 */ - { 8, 0x2D, 44 }, /* 0010 1101 */ - { 8, 0x4, 45 }, /* 0000 0100 */ - { 8, 0x5, 46 }, /* 0000 0101 */ - { 8, 0xA, 47 }, /* 0000 1010 */ - { 8, 0xB, 48 }, /* 0000 1011 */ - { 8, 0x52, 49 }, /* 0101 0010 */ - { 8, 0x53, 50 }, /* 0101 0011 */ - { 8, 0x54, 51 }, /* 0101 0100 */ - { 8, 0x55, 52 }, /* 0101 0101 */ - { 8, 0x24, 53 }, /* 0010 0100 */ - { 8, 0x25, 54 }, /* 0010 0101 */ - { 8, 0x58, 55 }, /* 0101 1000 */ - { 8, 0x59, 56 }, /* 0101 1001 */ - { 8, 0x5A, 57 }, /* 0101 1010 */ - { 8, 0x5B, 58 }, /* 0101 1011 */ - { 8, 0x4A, 59 }, /* 0100 1010 */ - { 8, 0x4B, 60 }, /* 0100 1011 */ - { 8, 0x32, 61 }, /* 0011 0010 */ - { 8, 0x33, 62 }, /* 0011 0011 */ - { 8, 0x34, 63 }, /* 0011 0100 */ - { 5, 0x1B, 64 }, /* 1101 1 */ - { 5, 0x12, 128 }, /* 1001 0 */ - { 6, 0x17, 192 }, /* 0101 11 */ - { 7, 0x37, 256 }, /* 0110 111 */ - { 8, 0x36, 320 }, /* 0011 0110 */ - { 8, 0x37, 384 }, /* 0011 0111 */ - { 8, 0x64, 448 }, /* 0110 0100 */ - { 8, 0x65, 512 }, /* 0110 0101 */ - { 8, 0x68, 576 }, /* 0110 1000 */ - { 8, 0x67, 640 }, /* 0110 0111 */ - { 9, 0xCC, 704 }, /* 0110 0110 0 */ - { 9, 0xCD, 768 }, /* 0110 0110 1 */ - { 9, 0xD2, 832 }, /* 0110 1001 0 */ - { 9, 0xD3, 896 }, /* 0110 1001 1 */ - { 9, 0xD4, 960 }, /* 0110 1010 0 */ - { 9, 0xD5, 1024 }, /* 0110 1010 1 */ - { 9, 0xD6, 1088 }, /* 0110 1011 0 */ - { 9, 0xD7, 1152 }, /* 0110 1011 1 */ - { 9, 0xD8, 1216 }, /* 0110 1100 0 */ - { 9, 0xD9, 1280 }, /* 0110 1100 1 */ - { 9, 0xDA, 1344 }, /* 0110 1101 0 */ - { 9, 0xDB, 1408 }, /* 0110 1101 1 */ - { 9, 0x98, 1472 }, /* 0100 1100 0 */ - { 9, 0x99, 1536 }, /* 0100 1100 1 */ - { 9, 0x9A, 1600 }, /* 0100 1101 0 */ - { 6, 0x18, 1664 }, /* 0110 00 */ - { 9, 0x9B, 1728 }, /* 0100 1101 1 */ - { 11, 0x8, 1792 }, /* 0000 0001 000 */ - { 11, 0xC, 1856 }, /* 0000 0001 100 */ - { 11, 0xD, 1920 }, /* 0000 0001 101 */ - { 12, 0x12, 1984 }, /* 0000 0001 0010 */ - { 12, 0x13, 2048 }, /* 0000 0001 0011 */ - { 12, 0x14, 2112 }, /* 0000 0001 0100 */ - { 12, 0x15, 2176 }, /* 0000 0001 0101 */ - { 12, 0x16, 2240 }, /* 0000 0001 0110 */ - { 12, 0x17, 2304 }, /* 0000 0001 0111 */ - { 12, 0x1C, 2368 }, /* 0000 0001 1100 */ - { 12, 0x1D, 2432 }, /* 0000 0001 1101 */ - { 12, 0x1E, 2496 }, /* 0000 0001 1110 */ - { 12, 0x1F, 2560 }, /* 0000 0001 1111 */ - { 12, 0x1, G3CODE_EOL }, /* 0000 0000 0001 */ - { 9, 0x1, G3CODE_INVALID }, /* 0000 0000 1 */ - { 10, 0x1, G3CODE_INVALID }, /* 0000 0000 01 */ - { 11, 0x1, G3CODE_INVALID }, /* 0000 0000 001 */ - { 12, 0x0, G3CODE_INVALID }, /* 0000 0000 0000 */ -}; - -const tableentry TIFFFaxBlackCodes[] = { - { 10, 0x37, 0 }, /* 0000 1101 11 */ - { 3, 0x2, 1 }, /* 010 */ - { 2, 0x3, 2 }, /* 11 */ - { 2, 0x2, 3 }, /* 10 */ - { 3, 0x3, 4 }, /* 011 */ - { 4, 0x3, 5 }, /* 0011 */ - { 4, 0x2, 6 }, /* 0010 */ - { 5, 0x3, 7 }, /* 0001 1 */ - { 6, 0x5, 8 }, /* 0001 01 */ - { 6, 0x4, 9 }, /* 0001 00 */ - { 7, 0x4, 10 }, /* 0000 100 */ - { 7, 0x5, 11 }, /* 0000 101 */ - { 7, 0x7, 12 }, /* 0000 111 */ - { 8, 0x4, 13 }, /* 0000 0100 */ - { 8, 0x7, 14 }, /* 0000 0111 */ - { 9, 0x18, 15 }, /* 0000 1100 0 */ - { 10, 0x17, 16 }, /* 0000 0101 11 */ - { 10, 0x18, 17 }, /* 0000 0110 00 */ - { 10, 0x8, 18 }, /* 0000 0010 00 */ - { 11, 0x67, 19 }, /* 0000 1100 111 */ - { 11, 0x68, 20 }, /* 0000 1101 000 */ - { 11, 0x6C, 21 }, /* 0000 1101 100 */ - { 11, 0x37, 22 }, /* 0000 0110 111 */ - { 11, 0x28, 23 }, /* 0000 0101 000 */ - { 11, 0x17, 24 }, /* 0000 0010 111 */ - { 11, 0x18, 25 }, /* 0000 0011 000 */ - { 12, 0xCA, 26 }, /* 0000 1100 1010 */ - { 12, 0xCB, 27 }, /* 0000 1100 1011 */ - { 12, 0xCC, 28 }, /* 0000 1100 1100 */ - { 12, 0xCD, 29 }, /* 0000 1100 1101 */ - { 12, 0x68, 30 }, /* 0000 0110 1000 */ - { 12, 0x69, 31 }, /* 0000 0110 1001 */ - { 12, 0x6A, 32 }, /* 0000 0110 1010 */ - { 12, 0x6B, 33 }, /* 0000 0110 1011 */ - { 12, 0xD2, 34 }, /* 0000 1101 0010 */ - { 12, 0xD3, 35 }, /* 0000 1101 0011 */ - { 12, 0xD4, 36 }, /* 0000 1101 0100 */ - { 12, 0xD5, 37 }, /* 0000 1101 0101 */ - { 12, 0xD6, 38 }, /* 0000 1101 0110 */ - { 12, 0xD7, 39 }, /* 0000 1101 0111 */ - { 12, 0x6C, 40 }, /* 0000 0110 1100 */ - { 12, 0x6D, 41 }, /* 0000 0110 1101 */ - { 12, 0xDA, 42 }, /* 0000 1101 1010 */ - { 12, 0xDB, 43 }, /* 0000 1101 1011 */ - { 12, 0x54, 44 }, /* 0000 0101 0100 */ - { 12, 0x55, 45 }, /* 0000 0101 0101 */ - { 12, 0x56, 46 }, /* 0000 0101 0110 */ - { 12, 0x57, 47 }, /* 0000 0101 0111 */ - { 12, 0x64, 48 }, /* 0000 0110 0100 */ - { 12, 0x65, 49 }, /* 0000 0110 0101 */ - { 12, 0x52, 50 }, /* 0000 0101 0010 */ - { 12, 0x53, 51 }, /* 0000 0101 0011 */ - { 12, 0x24, 52 }, /* 0000 0010 0100 */ - { 12, 0x37, 53 }, /* 0000 0011 0111 */ - { 12, 0x38, 54 }, /* 0000 0011 1000 */ - { 12, 0x27, 55 }, /* 0000 0010 0111 */ - { 12, 0x28, 56 }, /* 0000 0010 1000 */ - { 12, 0x58, 57 }, /* 0000 0101 1000 */ - { 12, 0x59, 58 }, /* 0000 0101 1001 */ - { 12, 0x2B, 59 }, /* 0000 0010 1011 */ - { 12, 0x2C, 60 }, /* 0000 0010 1100 */ - { 12, 0x5A, 61 }, /* 0000 0101 1010 */ - { 12, 0x66, 62 }, /* 0000 0110 0110 */ - { 12, 0x67, 63 }, /* 0000 0110 0111 */ - { 10, 0xF, 64 }, /* 0000 0011 11 */ - { 12, 0xC8, 128 }, /* 0000 1100 1000 */ - { 12, 0xC9, 192 }, /* 0000 1100 1001 */ - { 12, 0x5B, 256 }, /* 0000 0101 1011 */ - { 12, 0x33, 320 }, /* 0000 0011 0011 */ - { 12, 0x34, 384 }, /* 0000 0011 0100 */ - { 12, 0x35, 448 }, /* 0000 0011 0101 */ - { 13, 0x6C, 512 }, /* 0000 0011 0110 0 */ - { 13, 0x6D, 576 }, /* 0000 0011 0110 1 */ - { 13, 0x4A, 640 }, /* 0000 0010 0101 0 */ - { 13, 0x4B, 704 }, /* 0000 0010 0101 1 */ - { 13, 0x4C, 768 }, /* 0000 0010 0110 0 */ - { 13, 0x4D, 832 }, /* 0000 0010 0110 1 */ - { 13, 0x72, 896 }, /* 0000 0011 1001 0 */ - { 13, 0x73, 960 }, /* 0000 0011 1001 1 */ - { 13, 0x74, 1024 }, /* 0000 0011 1010 0 */ - { 13, 0x75, 1088 }, /* 0000 0011 1010 1 */ - { 13, 0x76, 1152 }, /* 0000 0011 1011 0 */ - { 13, 0x77, 1216 }, /* 0000 0011 1011 1 */ - { 13, 0x52, 1280 }, /* 0000 0010 1001 0 */ - { 13, 0x53, 1344 }, /* 0000 0010 1001 1 */ - { 13, 0x54, 1408 }, /* 0000 0010 1010 0 */ - { 13, 0x55, 1472 }, /* 0000 0010 1010 1 */ - { 13, 0x5A, 1536 }, /* 0000 0010 1101 0 */ - { 13, 0x5B, 1600 }, /* 0000 0010 1101 1 */ - { 13, 0x64, 1664 }, /* 0000 0011 0010 0 */ - { 13, 0x65, 1728 }, /* 0000 0011 0010 1 */ - { 11, 0x8, 1792 }, /* 0000 0001 000 */ - { 11, 0xC, 1856 }, /* 0000 0001 100 */ - { 11, 0xD, 1920 }, /* 0000 0001 101 */ - { 12, 0x12, 1984 }, /* 0000 0001 0010 */ - { 12, 0x13, 2048 }, /* 0000 0001 0011 */ - { 12, 0x14, 2112 }, /* 0000 0001 0100 */ - { 12, 0x15, 2176 }, /* 0000 0001 0101 */ - { 12, 0x16, 2240 }, /* 0000 0001 0110 */ - { 12, 0x17, 2304 }, /* 0000 0001 0111 */ - { 12, 0x1C, 2368 }, /* 0000 0001 1100 */ - { 12, 0x1D, 2432 }, /* 0000 0001 1101 */ - { 12, 0x1E, 2496 }, /* 0000 0001 1110 */ - { 12, 0x1F, 2560 }, /* 0000 0001 1111 */ - { 12, 0x1, G3CODE_EOL }, /* 0000 0000 0001 */ - { 9, 0x1, G3CODE_INVALID }, /* 0000 0000 1 */ - { 10, 0x1, G3CODE_INVALID }, /* 0000 0000 01 */ - { 11, 0x1, G3CODE_INVALID }, /* 0000 0000 001 */ - { 12, 0x0, G3CODE_INVALID }, /* 0000 0000 0000 */ -}; -#else -extern const tableentry TIFFFaxWhiteCodes[]; -extern const tableentry TIFFFaxBlackCodes[]; -#endif -#endif /* _T4_ */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_acorn.c b/plugins/AdvaImg/src/LibTIFF/tif_acorn.c deleted file mode 100644 index d2de42de53..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_acorn.c +++ /dev/null @@ -1,526 +0,0 @@ -/* $Header: /cvsroot/freeimage/FreeImage/Source/LibTIFF/tif_acorn.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library RISC OS specific Routines. - * Developed out of the Unix version. - * Peter Greenham, May 1995 - */ -#include "tiffiop.h" -#include -#include - -/* -Low-level file handling -~~~~~~~~~~~~~~~~~~~~~~~ -The functions in osfcn.h are unavailable when compiling under C, as it's a -C++ header. Therefore they have been implemented here. - -Now, why have I done it this way? - -The definitive API library for RISC OS is Jonathan Coxhead's OSLib, which -uses heavily optimised ARM assembler or even plain inline SWI calls for -maximum performance and minimum runtime size. However, I don't want to make -LIBTIFF need that to survive. Therefore I have also emulated the functions -using macros to _swi() and _swix() defined in the swis.h header, and -borrowing types from kernel.h, which is less efficient but doesn't need any -third-party libraries. - */ - -#ifdef INCLUDE_OSLIB - -#include "osfile.h" -#include "osgbpb.h" -#include "osargs.h" -#include "osfind.h" - -#else - -/* OSLIB EMULATION STARTS */ - -#include "kernel.h" -#include "swis.h" - -/* From oslib:types.h */ -typedef unsigned int bits; -typedef unsigned char byte; -#ifndef TRUE -#define TRUE 1 -#endif -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef NULL -#define NULL 0 -#endif -#ifndef SKIP -#define SKIP 0 -#endif - -/* From oslib:os.h */ -typedef _kernel_oserror os_error; -typedef byte os_f; - -/* From oslib:osfile.h */ -#undef OS_File -#define OS_File 0x8 - -/* From oslib:osgbpb.h */ -#undef OS_GBPB -#define OS_GBPB 0xC -#undef OSGBPB_Write -#define OSGBPB_Write 0x2 -#undef OSGBPB_Read -#define OSGBPB_Read 0x4 - -extern os_error *xosgbpb_write (os_f file, - byte *data, - int size, - int *unwritten); -extern int osgbpb_write (os_f file, - byte *data, - int size); - -#define xosgbpb_write(file, data, size, unwritten) \ - (os_error*) _swix(OS_GBPB, _IN(0)|_IN(1)|_IN(2)|_IN(3)|_IN(4)|_OUT(3), \ - OSGBPB_WriteAt, \ - file, \ - data, \ - size, \ - unwritten) - -#define osgbpb_write(file, data, size) \ - _swi(OS_GBPB, _IN(0)|_IN(1)|_IN(2)|_IN(3)|_RETURN(3), \ - OSGBPB_Write, \ - file, \ - data, \ - size) - -extern os_error *xosgbpb_read (os_f file, - byte *buffer, - int size, - int *unread); -extern int osgbpb_read (os_f file, - byte *buffer, - int size); - -#define xosgbpb_read(file, buffer, size, unread) \ - (os_error*) _swix(OS_GBPB, _IN(0)|_IN(1)|_IN(2)|_IN(3)|_OUT(3), \ - OSGBPB_Read, \ - file, \ - buffer, \ - size, \ - unread) - -#define osgbpb_read(file, buffer, size) \ - _swi(OS_GBPB, _IN(0)|_IN(1)|_IN(2)|_IN(3)|_RETURN(3), \ - OSGBPB_Read, \ - file, \ - buffer, \ - size) - -/* From oslib:osfind.h */ -#undef OS_Find -#define OS_Find 0xD -#undef OSFind_Openin -#define OSFind_Openin 0x40 -#undef OSFind_Openout -#define OSFind_Openout 0x80 -#undef OSFind_Openup -#define OSFind_Openup 0xC0 -#undef OSFind_Close -#define OSFind_Close 0x0 - -#define xosfind_open(reason, file_name, path, file) \ - (os_error*) _swix(OS_Find, _IN(0)|_IN(1)|_IN(2)|_OUT(0), \ - reason, file_name, path, file) - -#define osfind_open(reason, file_name, path) \ - (os_f) _swi(OS_Find, _IN(0)|_IN(1)|_IN(2)|_RETURN(0), \ - reason, file_name, path) - -extern os_error *xosfind_openin (bits flags, - char *file_name, - char *path, - os_f *file); -extern os_f osfind_openin (bits flags, - char *file_name, - char *path); - -#define xosfind_openin(flags, file_name, path, file) \ - xosfind_open(flags | OSFind_Openin, file_name, path, file) - -#define osfind_openin(flags, file_name, path) \ - osfind_open(flags | OSFind_Openin, file_name, path) - -extern os_error *xosfind_openout (bits flags, - char *file_name, - char *path, - os_f *file); -extern os_f osfind_openout (bits flags, - char *file_name, - char *path); - -#define xosfind_openout(flags, file_name, path, file) \ - xosfind_open(flags | OSFind_Openout, file_name, path, file) - -#define osfind_openout(flags, file_name, path) \ - osfind_open(flags | OSFind_Openout, file_name, path) - -extern os_error *xosfind_openup (bits flags, - char *file_name, - char *path, - os_f *file); -extern os_f osfind_openup (bits flags, - char *file_name, - char *path); - -#define xosfind_openup(flags, file_name, path, file) \ - xosfind_open(flags | OSFind_Openup, file_name, path, file) - -#define osfind_openup(flags, file_name, path) \ - osfind_open(flags | OSFind_Openup, file_name, path) - -extern os_error *xosfind_close (os_f file); -extern void osfind_close (os_f file); - -#define xosfind_close(file) \ - (os_error*) _swix(OS_Find, _IN(0)|_IN(1), \ - OSFind_Close, \ - file) - -#define osfind_close(file) \ - (void) _swi(OS_Find, _IN(0)|_IN(1), \ - OSFind_Close, \ - file) - -/* From oslib:osargs.h */ -#undef OS_Args -#define OS_Args 0x9 -#undef OSArgs_ReadPtr -#define OSArgs_ReadPtr 0x0 -#undef OSArgs_SetPtr -#define OSArgs_SetPtr 0x1 -#undef OSArgs_ReadExt -#define OSArgs_ReadExt 0x2 - -extern os_error *xosargs_read_ptr (os_f file, - int *ptr); -extern int osargs_read_ptr (os_f file); - -#define xosargs_read_ptr(file, ptr) \ - (os_error*) _swix(OS_Args, _IN(0)|_IN(1)|_OUT(2), \ - OSArgs_ReadPtr, \ - file, \ - ptr) - -#define osargs_read_ptr(file) \ - _swi(OS_Args, _IN(0)|_IN(1)|_RETURN(2), \ - OSArgs_ReadPtr, \ - file) - -extern os_error *xosargs_set_ptr (os_f file, - int ptr); -extern void osargs_set_ptr (os_f file, - int ptr); - -#define xosargs_set_ptr(file, ptr) \ - (os_error*) _swix(OS_Args, _IN(0)|_IN(1)|_IN(2), \ - OSArgs_SetPtr, \ - file, \ - ptr) - -#define osargs_set_ptr(file, ptr) \ - (void) _swi(OS_Args, _IN(0)|_IN(1)|_IN(2), \ - OSArgs_SetPtr, \ - file, \ - ptr) - -extern os_error *xosargs_read_ext (os_f file, - int *ext); -extern int osargs_read_ext (os_f file); - -#define xosargs_read_ext(file, ext) \ - (os_error*) _swix(OS_Args, _IN(0)|_IN(1)|_OUT(2), \ - OSArgs_ReadExt, \ - file, \ - ext) - -#define osargs_read_ext(file) \ - _swi(OS_Args, _IN(0)|_IN(1)|_RETURN(2), \ - OSArgs_ReadExt, \ - file) - -/* OSLIB EMULATION ENDS */ - -#endif - -#ifndef __osfcn_h -/* Will be set or not during tiffcomp.h */ -/* You get this to compile under C++? Please say how! */ - -extern int open(const char* name, int flags, int mode) -{ - /* From what I can tell, should return <0 for failure */ - os_error* e = (os_error*) 1; /* Cheeky way to use a pointer eh? :-) */ - os_f file = (os_f) -1; - - flags = flags; - - switch(mode) - { - case O_RDONLY: - { - e = xosfind_openin(SKIP, name, SKIP, &file); - break; - } - case O_WRONLY: - case O_RDWR|O_CREAT: - case O_RDWR|O_CREAT|O_TRUNC: - { - e = xosfind_openout(SKIP, name, SKIP, &file); - break; - } - case O_RDWR: - { - e = xosfind_openup(SKIP, name, SKIP, &file); - break; - } - } - if (e) - { - file = (os_f) -1; - } - return (file); -} - -extern int close(int fd) -{ - return ((int) xosfind_close((os_f) fd)); -} - -extern int write(int fd, const char *buf, int nbytes) -{ - /* Returns number of bytes written */ - return (nbytes - osgbpb_write((os_f) fd, (const byte*) buf, nbytes)); -} - -extern int read(int fd, char *buf, int nbytes) -{ - /* Returns number of bytes read */ - return (nbytes - osgbpb_read((os_f) fd, (byte*) buf, nbytes)); -} - -extern off_t lseek(int fd, off_t offset, int whence) -{ - int absolute = 0; - - switch (whence) - { - case SEEK_SET: - { - absolute = (int) offset; - break; - } - case SEEK_CUR: - { - absolute = osargs_read_ptr((os_f) fd) + (int) offset; - break; - } - case SEEK_END: - { - absolute = osargs_read_ext((os_f) fd) + (int) offset; - break; - } - } - - osargs_set_ptr((os_f) fd, absolute); - - return ((off_t) osargs_read_ptr((os_f) fd)); -} -#endif - -static tsize_t -_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return ((tsize_t) read((int) fd, buf, (size_t) size)); -} - -static tsize_t -_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return ((tsize_t) write((int) fd, buf, (size_t) size)); -} - -static toff_t -_tiffSeekProc(thandle_t fd, toff_t off, int whence) -{ - return ((toff_t) lseek((int) fd, (off_t) off, whence)); -} - -static int -_tiffCloseProc(thandle_t fd) -{ - return (close((int) fd)); -} - -static toff_t -_tiffSizeProc(thandle_t fd) -{ - return (lseek((int) fd, SEEK_END, SEEK_SET)); -} - -#ifdef HAVE_MMAP -#error "I didn't know Acorn had that!" -#endif - -/* !HAVE_MMAP */ -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - (void) fd; (void) pbase; (void) psize; - return (0); -} - -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ - (void) fd; (void) base; (void) size; -} - -/* - * Open a TIFF file descriptor for read/writing. - */ -TIFF* -TIFFFdOpen(int fd, const char* name, const char* mode) -{ - TIFF* tif; - - tif = TIFFClientOpen(name, mode, - (thandle_t) fd, - _tiffReadProc, _tiffWriteProc, - _tiffSeekProc, _tiffCloseProc, _tiffSizeProc, - _tiffMapProc, _tiffUnmapProc); - if (tif) - { - tif->tif_fd = fd; - } - return (tif); -} - -/* - * Open a TIFF file for read/writing. - */ -TIFF* -TIFFOpen(const char* name, const char* mode) -{ - static const char module[] = "TIFFOpen"; - int m, fd; - - m = _TIFFgetMode(mode, module); - - if (m == -1) - { - return ((TIFF*) 0); - } - - fd = open(name, 0, m); - - if (fd < 0) - { - TIFFErrorExt(0, module, "%s: Cannot open", name); - return ((TIFF *)0); - } - return (TIFFFdOpen(fd, name, mode)); -} - -void* -_TIFFmalloc(tsize_t s) -{ - return (malloc((size_t) s)); -} - -void -_TIFFfree(tdata_t p) -{ - free(p); -} - -void* -_TIFFrealloc(tdata_t p, tsize_t s) -{ - return (realloc(p, (size_t) s)); -} - -void -_TIFFmemset(tdata_t p, int v, tsize_t c) -{ - memset(p, v, (size_t) c); -} - -void -_TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c) -{ - memcpy(d, s, (size_t) c); -} - -int -_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) -{ - return (memcmp(p1, p2, (size_t) c)); -} - -static void -acornWarningHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - { - fprintf(stderr, "%s: ", module); - } - fprintf(stderr, "Warning, "); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFwarningHandler = acornWarningHandler; - -static void -acornErrorHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - { - fprintf(stderr, "%s: ", module); - } - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFerrorHandler = acornErrorHandler; -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_apple.c b/plugins/AdvaImg/src/LibTIFF/tif_apple.c deleted file mode 100644 index 0cd2948cb7..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_apple.c +++ /dev/null @@ -1,281 +0,0 @@ -/* $Header: /cvsroot/freeimage/FreeImage/Source/LibTIFF/tif_apple.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library Macintosh-specific routines. - * - * These routines use only Toolbox and high-level File Manager traps. - * They make no calls to the THINK C "unix" compatibility library. Also, - * malloc is not used directly but it is still referenced internally by - * the ANSI library in rare cases. Heap fragmentation by the malloc ring - * buffer is therefore minimized. - * - * O_RDONLY and O_RDWR are treated identically here. The tif_mode flag is - * checked in TIFFWriteCheck(). - * - * Create below fills in a blank creator signature and sets the file type - * to 'TIFF'. It is much better for the application to do this by Create'ing - * the file first and TIFFOpen'ing it later. - * --------- - * This code has been "Carbonized", and may not work with older MacOS versions. - * If so, grab the tif_apple.c out of an older libtiff distribution, like - * 3.5.5 from www.libtiff.org. - */ - -#include "tiffiop.h" -#include -#include -#include -#include - -#if defined(__PPCC__) || defined(__SC__) || defined(__MRC__) || defined(applec) -#define CtoPstr c2pstr -#endif - -static tsize_t -_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return (FSRead((short) fd, (long*) &size, (char*) buf) == noErr ? - size : (tsize_t) -1); -} - -static tsize_t -_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return (FSWrite((short) fd, (long*) &size, (char*) buf) == noErr ? - size : (tsize_t) -1); -} - -static toff_t -_tiffSeekProc(thandle_t fd, toff_t off, int whence) -{ - long fpos, size; - - if (GetEOF((short) fd, &size) != noErr) - return EOF; - (void) GetFPos((short) fd, &fpos); - - switch (whence) { - case SEEK_CUR: - if (off + fpos > size) - SetEOF((short) fd, off + fpos); - if (SetFPos((short) fd, fsFromMark, off) != noErr) - return EOF; - break; - case SEEK_END: - if (off > 0) - SetEOF((short) fd, off + size); - if (SetFPos((short) fd, fsFromStart, off + size) != noErr) - return EOF; - break; - case SEEK_SET: - if (off > size) - SetEOF((short) fd, off); - if (SetFPos((short) fd, fsFromStart, off) != noErr) - return EOF; - break; - } - - return (toff_t)(GetFPos((short) fd, &fpos) == noErr ? fpos : EOF); -} - -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - return (0); -} - -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ -} - -static int -_tiffCloseProc(thandle_t fd) -{ - return (FSClose((short) fd)); -} - -static toff_t -_tiffSizeProc(thandle_t fd) -{ - long size; - - if (GetEOF((short) fd, &size) != noErr) { - TIFFErrorExt(fd, "_tiffSizeProc", "%s: Cannot get file size"); - return (-1L); - } - return ((toff_t) size); -} - -/* - * Open a TIFF file descriptor for read/writing. - */ -TIFF* -TIFFFdOpen(int fd, const char* name, const char* mode) -{ - TIFF* tif; - - tif = TIFFClientOpen(name, mode, (thandle_t) fd, - _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, - _tiffSizeProc, _tiffMapProc, _tiffUnmapProc); - if (tif) - tif->tif_fd = fd; - return (tif); -} - -static void ourc2pstr( char* inString ) -{ - int sLen = strlen( inString ); - BlockMoveData( inString, &inString[1], sLen ); - inString[0] = sLen; -} - -/* - * Open a TIFF file for read/writing. - */ -TIFF* -TIFFOpen(const char* name, const char* mode) -{ - static const char module[] = "TIFFOpen"; - Str255 pname; - FInfo finfo; - short fref; - OSErr err; - FSSpec fSpec; - - strcpy((char*) pname, name); - ourc2pstr((char*) pname); - - err = FSMakeFSSpec( 0, 0, pname, &fSpec ); - - switch (_TIFFgetMode(mode, module)) { - default: - return ((TIFF*) 0); - case O_RDWR | O_CREAT | O_TRUNC: - if (FSpGetFInfo(&fSpec, &finfo) == noErr) - FSpDelete(&fSpec); - /* fall through */ - case O_RDWR | O_CREAT: - if ((err = FSpGetFInfo(&fSpec, &finfo)) == fnfErr) { - if (FSpCreate(&fSpec, ' ', 'TIFF', smSystemScript) != noErr) - goto badCreate; - if (FSpOpenDF(&fSpec, fsRdWrPerm, &fref) != noErr) - goto badOpen; - } else if (err == noErr) { - if (FSpOpenDF(&fSpec, fsRdWrPerm, &fref) != noErr) - goto badOpen; - } else - goto badOpen; - break; - case O_RDONLY: - if (FSpOpenDF(&fSpec, fsRdPerm, &fref) != noErr) - goto badOpen; - break; - case O_RDWR: - if (FSpOpenDF(&fSpec, fsRdWrPerm, &fref) != noErr) - goto badOpen; - break; - } - return (TIFFFdOpen((int) fref, name, mode)); -badCreate: - TIFFErrorExt(0, module, "%s: Cannot create", name); - return ((TIFF*) 0); -badOpen: - TIFFErrorExt(0, module, "%s: Cannot open", name); - return ((TIFF*) 0); -} - -void -_TIFFmemset(tdata_t p, int v, tsize_t c) -{ - memset(p, v, (size_t) c); -} - -void -_TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c) -{ - memcpy(d, s, (size_t) c); -} - -int -_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) -{ - return (memcmp(p1, p2, (size_t) c)); -} - -tdata_t -_TIFFmalloc(tsize_t s) -{ - return (NewPtr((size_t) s)); -} - -void -_TIFFfree(tdata_t p) -{ - DisposePtr(p); -} - -tdata_t -_TIFFrealloc(tdata_t p, tsize_t s) -{ - Ptr n = p; - - SetPtrSize(p, (size_t) s); - if (MemError() && (n = NewPtr((size_t) s)) != NULL) { - BlockMove(p, n, GetPtrSize(p)); - DisposePtr(p); - } - return ((tdata_t) n); -} - -static void -appleWarningHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - fprintf(stderr, "Warning, "); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFwarningHandler = appleWarningHandler; - -static void -appleErrorHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFerrorHandler = appleErrorHandler; -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_atari.c b/plugins/AdvaImg/src/LibTIFF/tif_atari.c deleted file mode 100644 index 62453a1d93..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_atari.c +++ /dev/null @@ -1,250 +0,0 @@ -/* "$Header: /cvsroot/freeimage/FreeImage/Source/LibTIFF/tif_atari.c,v 1.37 2011/04/10 17:14:09 drolon Exp $" */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library ATARI-specific Routines. - */ -#include "tiffiop.h" -#if defined(__TURBOC__) -#include -#include -#else -#include -#include -#endif - -#ifndef O_ACCMODE -#define O_ACCMODE 3 -#endif - -#include - -#define AEFILNF -33 - -static tsize_t -_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - long r; - - r = Fread((int) fd, size, buf); - if (r < 0) { - errno = (int)-r; - r = -1; - } - return r; -} - -static tsize_t -_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - long r; - - r = Fwrite((int) fd, size, buf); - if (r < 0) { - errno = (int)-r; - r = -1; - } - return r; -} - -static toff_t -_tiffSeekProc(thandle_t fd, off_t off, int whence) -{ - char buf[256]; - long current_off, expected_off, new_off; - - if (whence == SEEK_END || off <= 0) - return Fseek(off, (int) fd, whence); - current_off = Fseek(0, (int) fd, SEEK_CUR); /* find out where we are */ - if (whence == SEEK_SET) - expected_off = off; - else - expected_off = off + current_off; - new_off = Fseek(off, (int) fd, whence); - if (new_off == expected_off) - return new_off; - /* otherwise extend file -- zero filling the hole */ - if (new_off < 0) /* error? */ - new_off = Fseek(0, (int) fd, SEEK_END); /* go to eof */ - _TIFFmemset(buf, 0, sizeof(buf)); - while (expected_off > new_off) { - off = expected_off - new_off; - if (off > sizeof(buf)) - off = sizeof(buf); - if ((current_off = Fwrite((int) fd, off, buf)) != off) - return (current_off > 0) ? - new_off + current_off : new_off; - new_off += off; - } - return new_off; -} - -static int -_tiffCloseProc(thandle_t fd) -{ - long r; - - r = Fclose((int) fd); - if (r < 0) { - errno = (int)-r; - r = -1; - } - return (int)r; -} - -static toff_t -_tiffSizeProc(thandle_t fd) -{ - long pos, eof; - - pos = Fseek(0, (int) fd, SEEK_CUR); - eof = Fseek(0, (int) fd, SEEK_END); - Fseek(pos, (int) fd, SEEK_SET); - return eof; -} - -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - return (0); -} - -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ -} - -/* -* Open a TIFF file descriptor for read/writing. -*/ -TIFF* -TIFFFdOpen(int fd, const char* name, const char* mode) -{ - TIFF* tif; - - tif = TIFFClientOpen(name, mode, - (thandle_t) fd, - _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, - _tiffSizeProc, _tiffMapProc, _tiffUnmapProc); - if (tif) - tif->tif_fd = fd; - return (tif); -} - -/* -* Open a TIFF file for read/writing. -*/ -TIFF* -TIFFOpen(const char* name, const char* mode) -{ - static const char module[] = "TIFFOpen"; - int m; - long fd; - - m = _TIFFgetMode(mode, module); - if (m == -1) - return ((TIFF*)0); - if (m & O_TRUNC) { - fd = Fcreate(name, 0); - } else { - fd = Fopen(name, m & O_ACCMODE); - if (fd == AEFILNF && m & O_CREAT) - fd = Fcreate(name, 0); - } - if (fd < 0) - errno = (int)fd; - if (fd < 0) { - TIFFErrorExt(0, module, "%s: Cannot open", name); - return ((TIFF*)0); - } - return (TIFFFdOpen(fd, name, mode)); -} - -#include - -tdata_t -_TIFFmalloc(tsize_t s) -{ - return (malloc((size_t) s)); -} - -void -_TIFFfree(tdata_t p) -{ - free(p); -} - -tdata_t -_TIFFrealloc(tdata_t p, tsize_t s) -{ - return (realloc(p, (size_t) s)); -} - -void -_TIFFmemset(tdata_t p, int v, size_t c) -{ - memset(p, v, (size_t) c); -} - -void -_TIFFmemcpy(tdata_t d, const tdata_t s, size_t c) -{ - memcpy(d, s, (size_t) c); -} - -int -_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) -{ - return (memcmp(p1, p2, (size_t) c)); -} - -static void -atariWarningHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - fprintf(stderr, "Warning, "); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFwarningHandler = atariWarningHandler; - -static void -atariErrorHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFerrorHandler = atariErrorHandler; -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_aux.c b/plugins/AdvaImg/src/LibTIFF/tif_aux.c deleted file mode 100644 index 92df69bd1a..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_aux.c +++ /dev/null @@ -1,290 +0,0 @@ -/* $Id: tif_aux.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1991-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Auxiliary Support Routines. - */ -#include "tiffiop.h" -#include "tif_predict.h" -#include - -tdata_t -_TIFFCheckRealloc(TIFF* tif, tdata_t buffer, - size_t nmemb, size_t elem_size, const char* what) -{ - tdata_t cp = NULL; - tsize_t bytes = nmemb * elem_size; - - /* - * XXX: Check for integer overflow. - */ - if (nmemb && elem_size && bytes / elem_size == nmemb) - cp = _TIFFrealloc(buffer, bytes); - - if (cp == NULL) - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Failed to allocate memory for %s " - "(%ld elements of %ld bytes each)", - what,(long) nmemb, (long) elem_size); - - return cp; -} - -tdata_t -_TIFFCheckMalloc(TIFF* tif, size_t nmemb, size_t elem_size, const char* what) -{ - return _TIFFCheckRealloc(tif, NULL, nmemb, elem_size, what); -} - -static int -TIFFDefaultTransferFunction(TIFFDirectory* td) -{ - uint16 **tf = td->td_transferfunction; - tsize_t i, n, nbytes; - - tf[0] = tf[1] = tf[2] = 0; - if (td->td_bitspersample >= sizeof(tsize_t) * 8 - 2) - return 0; - - n = 1<td_bitspersample; - nbytes = n * sizeof (uint16); - if (!(tf[0] = (uint16 *)_TIFFmalloc(nbytes))) - return 0; - tf[0][0] = 0; - for (i = 1; i < n; i++) { - double t = (double)i/((double) n-1.); - tf[0][i] = (uint16)floor(65535.*pow(t, 2.2) + .5); - } - - if (td->td_samplesperpixel - td->td_extrasamples > 1) { - if (!(tf[1] = (uint16 *)_TIFFmalloc(nbytes))) - goto bad; - _TIFFmemcpy(tf[1], tf[0], nbytes); - if (!(tf[2] = (uint16 *)_TIFFmalloc(nbytes))) - goto bad; - _TIFFmemcpy(tf[2], tf[0], nbytes); - } - return 1; - -bad: - if (tf[0]) - _TIFFfree(tf[0]); - if (tf[1]) - _TIFFfree(tf[1]); - if (tf[2]) - _TIFFfree(tf[2]); - tf[0] = tf[1] = tf[2] = 0; - return 0; -} - -static int -TIFFDefaultRefBlackWhite(TIFFDirectory* td) -{ - int i; - - if (!(td->td_refblackwhite = (float *)_TIFFmalloc(6*sizeof (float)))) - return 0; - if (td->td_photometric == PHOTOMETRIC_YCBCR) { - /* - * YCbCr (Class Y) images must have the ReferenceBlackWhite - * tag set. Fix the broken images, which lacks that tag. - */ - td->td_refblackwhite[0] = 0.0F; - td->td_refblackwhite[1] = td->td_refblackwhite[3] = - td->td_refblackwhite[5] = 255.0F; - td->td_refblackwhite[2] = td->td_refblackwhite[4] = 128.0F; - } else { - /* - * Assume RGB (Class R) - */ - for (i = 0; i < 3; i++) { - td->td_refblackwhite[2*i+0] = 0; - td->td_refblackwhite[2*i+1] = - (float)((1L<td_bitspersample)-1L); - } - } - return 1; -} - -/* - * Like TIFFGetField, but return any default - * value if the tag is not present in the directory. - * - * NB: We use the value in the directory, rather than - * explcit values so that defaults exist only one - * place in the library -- in TIFFDefaultDirectory. - */ -int -TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap) -{ - TIFFDirectory *td = &tif->tif_dir; - - if (TIFFVGetField(tif, tag, ap)) - return (1); - switch (tag) { - case TIFFTAG_SUBFILETYPE: - *va_arg(ap, uint32 *) = td->td_subfiletype; - return (1); - case TIFFTAG_BITSPERSAMPLE: - *va_arg(ap, uint16 *) = td->td_bitspersample; - return (1); - case TIFFTAG_THRESHHOLDING: - *va_arg(ap, uint16 *) = td->td_threshholding; - return (1); - case TIFFTAG_FILLORDER: - *va_arg(ap, uint16 *) = td->td_fillorder; - return (1); - case TIFFTAG_ORIENTATION: - *va_arg(ap, uint16 *) = td->td_orientation; - return (1); - case TIFFTAG_SAMPLESPERPIXEL: - *va_arg(ap, uint16 *) = td->td_samplesperpixel; - return (1); - case TIFFTAG_ROWSPERSTRIP: - *va_arg(ap, uint32 *) = td->td_rowsperstrip; - return (1); - case TIFFTAG_MINSAMPLEVALUE: - *va_arg(ap, uint16 *) = td->td_minsamplevalue; - return (1); - case TIFFTAG_MAXSAMPLEVALUE: - *va_arg(ap, uint16 *) = td->td_maxsamplevalue; - return (1); - case TIFFTAG_PLANARCONFIG: - *va_arg(ap, uint16 *) = td->td_planarconfig; - return (1); - case TIFFTAG_RESOLUTIONUNIT: - *va_arg(ap, uint16 *) = td->td_resolutionunit; - return (1); - case TIFFTAG_PREDICTOR: - { - TIFFPredictorState* sp = (TIFFPredictorState*) tif->tif_data; - *va_arg(ap, uint16*) = (uint16) sp->predictor; - return 1; - } - case TIFFTAG_DOTRANGE: - *va_arg(ap, uint16 *) = 0; - *va_arg(ap, uint16 *) = (1<td_bitspersample)-1; - return (1); - case TIFFTAG_INKSET: - *va_arg(ap, uint16 *) = INKSET_CMYK; - return 1; - case TIFFTAG_NUMBEROFINKS: - *va_arg(ap, uint16 *) = 4; - return (1); - case TIFFTAG_EXTRASAMPLES: - *va_arg(ap, uint16 *) = td->td_extrasamples; - *va_arg(ap, uint16 **) = td->td_sampleinfo; - return (1); - case TIFFTAG_MATTEING: - *va_arg(ap, uint16 *) = - (td->td_extrasamples == 1 && - td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA); - return (1); - case TIFFTAG_TILEDEPTH: - *va_arg(ap, uint32 *) = td->td_tiledepth; - return (1); - case TIFFTAG_DATATYPE: - *va_arg(ap, uint16 *) = td->td_sampleformat-1; - return (1); - case TIFFTAG_SAMPLEFORMAT: - *va_arg(ap, uint16 *) = td->td_sampleformat; - return(1); - case TIFFTAG_IMAGEDEPTH: - *va_arg(ap, uint32 *) = td->td_imagedepth; - return (1); - case TIFFTAG_YCBCRCOEFFICIENTS: - { - /* defaults are from CCIR Recommendation 601-1 */ - static float ycbcrcoeffs[] = { 0.299f, 0.587f, 0.114f }; - *va_arg(ap, float **) = ycbcrcoeffs; - return 1; - } - case TIFFTAG_YCBCRSUBSAMPLING: - *va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[0]; - *va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[1]; - return (1); - case TIFFTAG_YCBCRPOSITIONING: - *va_arg(ap, uint16 *) = td->td_ycbcrpositioning; - return (1); - case TIFFTAG_WHITEPOINT: - { - static float whitepoint[2]; - - /* TIFF 6.0 specification tells that it is no default - value for the WhitePoint, but AdobePhotoshop TIFF - Technical Note tells that it should be CIE D50. */ - whitepoint[0] = D50_X0 / (D50_X0 + D50_Y0 + D50_Z0); - whitepoint[1] = D50_Y0 / (D50_X0 + D50_Y0 + D50_Z0); - *va_arg(ap, float **) = whitepoint; - return 1; - } - case TIFFTAG_TRANSFERFUNCTION: - if (!td->td_transferfunction[0] && - !TIFFDefaultTransferFunction(td)) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "No space for \"TransferFunction\" tag"); - return (0); - } - *va_arg(ap, uint16 **) = td->td_transferfunction[0]; - if (td->td_samplesperpixel - td->td_extrasamples > 1) { - *va_arg(ap, uint16 **) = td->td_transferfunction[1]; - *va_arg(ap, uint16 **) = td->td_transferfunction[2]; - } - return (1); - case TIFFTAG_REFERENCEBLACKWHITE: - if (!td->td_refblackwhite && !TIFFDefaultRefBlackWhite(td)) - return (0); - *va_arg(ap, float **) = td->td_refblackwhite; - return (1); - } - return 0; -} - -/* - * Like TIFFGetField, but return any default - * value if the tag is not present in the directory. - */ -int -TIFFGetFieldDefaulted(TIFF* tif, ttag_t tag, ...) -{ - int ok; - va_list ap; - - va_start(ap, tag); - ok = TIFFVGetFieldDefaulted(tif, tag, ap); - va_end(ap); - return (ok); -} - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_close.c b/plugins/AdvaImg/src/LibTIFF/tif_close.c deleted file mode 100644 index 03a8847e84..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_close.c +++ /dev/null @@ -1,126 +0,0 @@ -/* $Id: tif_close.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - */ -#include "tiffiop.h" - -/************************************************************************/ -/* TIFFCleanup() */ -/************************************************************************/ - -/** - * Auxiliary function to free the TIFF structure. Given structure will be - * completetly freed, so you should save opened file handle and pointer - * to the close procedure in external variables before calling - * _TIFFCleanup(), if you will need these ones to close the file. - * - * @param tif A TIFF pointer. - */ - -void -TIFFCleanup(TIFF* tif) -{ - if (tif->tif_mode != O_RDONLY) - /* - * Flush buffered data and directory (if dirty). - */ - TIFFFlush(tif); - (*tif->tif_cleanup)(tif); - TIFFFreeDirectory(tif); - - if (tif->tif_dirlist) - _TIFFfree(tif->tif_dirlist); - - /* Clean up client info links */ - while( tif->tif_clientinfo ) - { - TIFFClientInfoLink *link = tif->tif_clientinfo; - - tif->tif_clientinfo = link->next; - _TIFFfree( link->name ); - _TIFFfree( link ); - } - - if (tif->tif_rawdata && (tif->tif_flags&TIFF_MYBUFFER)) - _TIFFfree(tif->tif_rawdata); - if (isMapped(tif)) - TIFFUnmapFileContents(tif, tif->tif_base, tif->tif_size); - - /* Clean up custom fields */ - if (tif->tif_nfields > 0) - { - size_t i; - - for (i = 0; i < tif->tif_nfields; i++) - { - TIFFFieldInfo *fld = tif->tif_fieldinfo[i]; - if (fld->field_bit == FIELD_CUSTOM && - strncmp("Tag ", fld->field_name, 4) == 0) - { - _TIFFfree(fld->field_name); - _TIFFfree(fld); - } - } - - _TIFFfree(tif->tif_fieldinfo); - } - - _TIFFfree(tif); -} - -/************************************************************************/ -/* TIFFClose() */ -/************************************************************************/ - -/** - * Close a previously opened TIFF file. - * - * TIFFClose closes a file that was previously opened with TIFFOpen(). - * Any buffered data are flushed to the file, including the contents of - * the current directory (if modified); and all resources are reclaimed. - * - * @param tif A TIFF pointer. - */ - -void -TIFFClose(TIFF* tif) -{ - TIFFCloseProc closeproc = tif->tif_closeproc; - thandle_t fd = tif->tif_clientdata; - - TIFFCleanup(tif); - (void) (*closeproc)(fd); -} - -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_codec.c b/plugins/AdvaImg/src/LibTIFF/tif_codec.c deleted file mode 100644 index 7876a5fc63..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_codec.c +++ /dev/null @@ -1,160 +0,0 @@ -/* $Id: tif_codec.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library - * - * Builtin Compression Scheme Configuration Support. - */ -#include "tiffiop.h" - -static int NotConfigured(TIFF*, int); - -#ifndef LZW_SUPPORT -#define TIFFInitLZW NotConfigured -#endif -#ifndef PACKBITS_SUPPORT -#define TIFFInitPackBits NotConfigured -#endif -#ifndef THUNDER_SUPPORT -#define TIFFInitThunderScan NotConfigured -#endif -#ifndef NEXT_SUPPORT -#define TIFFInitNeXT NotConfigured -#endif -#ifndef JPEG_SUPPORT -#define TIFFInitJPEG NotConfigured -#endif -#ifndef OJPEG_SUPPORT -#define TIFFInitOJPEG NotConfigured -#endif -#ifndef CCITT_SUPPORT -#define TIFFInitCCITTRLE NotConfigured -#define TIFFInitCCITTRLEW NotConfigured -#define TIFFInitCCITTFax3 NotConfigured -#define TIFFInitCCITTFax4 NotConfigured -#endif -#ifndef JBIG_SUPPORT -#define TIFFInitJBIG NotConfigured -#endif -#ifndef ZIP_SUPPORT -#define TIFFInitZIP NotConfigured -#endif -#ifndef PIXARLOG_SUPPORT -#define TIFFInitPixarLog NotConfigured -#endif -#ifndef LOGLUV_SUPPORT -#define TIFFInitSGILog NotConfigured -#endif - -/* - * Compression schemes statically built into the library. - */ -#ifdef VMS -const TIFFCodec _TIFFBuiltinCODECS[] = { -#else -TIFFCodec _TIFFBuiltinCODECS[] = { -#endif - { "None", COMPRESSION_NONE, TIFFInitDumpMode }, - { "LZW", COMPRESSION_LZW, TIFFInitLZW }, - { "PackBits", COMPRESSION_PACKBITS, TIFFInitPackBits }, - { "ThunderScan", COMPRESSION_THUNDERSCAN,TIFFInitThunderScan }, - { "NeXT", COMPRESSION_NEXT, TIFFInitNeXT }, - { "JPEG", COMPRESSION_JPEG, TIFFInitJPEG }, - { "Old-style JPEG", COMPRESSION_OJPEG, TIFFInitOJPEG }, - { "CCITT RLE", COMPRESSION_CCITTRLE, TIFFInitCCITTRLE }, - { "CCITT RLE/W", COMPRESSION_CCITTRLEW, TIFFInitCCITTRLEW }, - { "CCITT Group 3", COMPRESSION_CCITTFAX3, TIFFInitCCITTFax3 }, - { "CCITT Group 4", COMPRESSION_CCITTFAX4, TIFFInitCCITTFax4 }, - { "ISO JBIG", COMPRESSION_JBIG, TIFFInitJBIG }, - { "Deflate", COMPRESSION_DEFLATE, TIFFInitZIP }, - { "AdobeDeflate", COMPRESSION_ADOBE_DEFLATE , TIFFInitZIP }, - { "PixarLog", COMPRESSION_PIXARLOG, TIFFInitPixarLog }, - { "SGILog", COMPRESSION_SGILOG, TIFFInitSGILog }, - { "SGILog24", COMPRESSION_SGILOG24, TIFFInitSGILog }, - { NULL, 0, NULL } -}; - -static int -_notConfigured(TIFF* tif) -{ - const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression); - char compression_code[20]; - - sprintf( compression_code, "%d", tif->tif_dir.td_compression ); - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%s compression support is not configured", - c ? c->name : compression_code ); - return (0); -} - -static int -NotConfigured(TIFF* tif, int scheme) -{ - (void) scheme; - - tif->tif_decodestatus = FALSE; - tif->tif_setupdecode = _notConfigured; - tif->tif_encodestatus = FALSE; - tif->tif_setupencode = _notConfigured; - return (1); -} - -/************************************************************************/ -/* TIFFIsCODECConfigured() */ -/************************************************************************/ - -/** - * Check whether we have working codec for the specific coding scheme. - * - * @return returns 1 if the codec is configured and working. Otherwise - * 0 will be returned. - */ - -int -TIFFIsCODECConfigured(uint16 scheme) -{ - const TIFFCodec* codec = TIFFFindCODEC(scheme); - - if(codec == NULL) { - return 0; - } - if(codec->init == NULL) { - return 0; - } - if(codec->init != NotConfigured){ - return 1; - } - return 0; -} - -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_color.c b/plugins/AdvaImg/src/LibTIFF/tif_color.c deleted file mode 100644 index f0302e4bf2..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_color.c +++ /dev/null @@ -1,287 +0,0 @@ -/* $Id: tif_color.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * CIE L*a*b* to CIE XYZ and CIE XYZ to RGB conversion routines are taken - * from the VIPS library (http://www.vips.ecs.soton.ac.uk) with - * the permission of John Cupitt, the VIPS author. - */ - -/* - * TIFF Library. - * - * Color space conversion routines. - */ - -#include "tiffiop.h" -#include - -/* - * Convert color value from the CIE L*a*b* 1976 space to CIE XYZ. - */ -void -TIFFCIELabToXYZ(TIFFCIELabToRGB *cielab, uint32 l, int32 a, int32 b, - float *X, float *Y, float *Z) -{ - float L = (float)l * 100.0F / 255.0F; - float cby, tmp; - - if ( L < 8.856F ) { - *Y = (L * cielab->Y0) / 903.292F; - cby = 7.787F * (*Y / cielab->Y0) + 16.0F / 116.0F; - } else { - cby = (L + 16.0F) / 116.0F; - *Y = cielab->Y0 * cby * cby * cby; - } - - tmp = (float)a / 500.0F + cby; - if ( tmp < 0.2069F ) - *X = cielab->X0 * (tmp - 0.13793F) / 7.787F; - else - *X = cielab->X0 * tmp * tmp * tmp; - - tmp = cby - (float)b / 200.0F; - if ( tmp < 0.2069F ) - *Z = cielab->Z0 * (tmp - 0.13793F) / 7.787F; - else - *Z = cielab->Z0 * tmp * tmp * tmp; -} - -#define RINT(R) ((uint32)((R)>0?((R)+0.5):((R)-0.5))) -/* - * Convert color value from the XYZ space to RGB. - */ -void -TIFFXYZToRGB(TIFFCIELabToRGB *cielab, float X, float Y, float Z, - uint32 *r, uint32 *g, uint32 *b) -{ - int i; - float Yr, Yg, Yb; - float *matrix = &cielab->display.d_mat[0][0]; - - /* Multiply through the matrix to get luminosity values. */ - Yr = matrix[0] * X + matrix[1] * Y + matrix[2] * Z; - Yg = matrix[3] * X + matrix[4] * Y + matrix[5] * Z; - Yb = matrix[6] * X + matrix[7] * Y + matrix[8] * Z; - - /* Clip input */ - Yr = TIFFmax(Yr, cielab->display.d_Y0R); - Yg = TIFFmax(Yg, cielab->display.d_Y0G); - Yb = TIFFmax(Yb, cielab->display.d_Y0B); - - /* Avoid overflow in case of wrong input values */ - Yr = TIFFmin(Yr, cielab->display.d_YCR); - Yg = TIFFmin(Yg, cielab->display.d_YCG); - Yb = TIFFmin(Yb, cielab->display.d_YCB); - - /* Turn luminosity to colour value. */ - i = (int)((Yr - cielab->display.d_Y0R) / cielab->rstep); - i = TIFFmin(cielab->range, i); - *r = RINT(cielab->Yr2r[i]); - - i = (int)((Yg - cielab->display.d_Y0G) / cielab->gstep); - i = TIFFmin(cielab->range, i); - *g = RINT(cielab->Yg2g[i]); - - i = (int)((Yb - cielab->display.d_Y0B) / cielab->bstep); - i = TIFFmin(cielab->range, i); - *b = RINT(cielab->Yb2b[i]); - - /* Clip output. */ - *r = TIFFmin(*r, cielab->display.d_Vrwr); - *g = TIFFmin(*g, cielab->display.d_Vrwg); - *b = TIFFmin(*b, cielab->display.d_Vrwb); -} -#undef RINT - -/* - * Allocate conversion state structures and make look_up tables for - * the Yr,Yb,Yg <=> r,g,b conversions. - */ -int -TIFFCIELabToRGBInit(TIFFCIELabToRGB* cielab, - TIFFDisplay *display, float *refWhite) -{ - int i; - double gamma; - - cielab->range = CIELABTORGB_TABLE_RANGE; - - _TIFFmemcpy(&cielab->display, display, sizeof(TIFFDisplay)); - - /* Red */ - gamma = 1.0 / cielab->display.d_gammaR ; - cielab->rstep = - (cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range; - for(i = 0; i <= cielab->range; i++) { - cielab->Yr2r[i] = cielab->display.d_Vrwr - * ((float)pow((double)i / cielab->range, gamma)); - } - - /* Green */ - gamma = 1.0 / cielab->display.d_gammaG ; - cielab->gstep = - (cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range; - for(i = 0; i <= cielab->range; i++) { - cielab->Yg2g[i] = cielab->display.d_Vrwg - * ((float)pow((double)i / cielab->range, gamma)); - } - - /* Blue */ - gamma = 1.0 / cielab->display.d_gammaB ; - cielab->bstep = - (cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range; - for(i = 0; i <= cielab->range; i++) { - cielab->Yb2b[i] = cielab->display.d_Vrwb - * ((float)pow((double)i / cielab->range, gamma)); - } - - /* Init reference white point */ - cielab->X0 = refWhite[0]; - cielab->Y0 = refWhite[1]; - cielab->Z0 = refWhite[2]; - - return 0; -} - -/* - * Convert color value from the YCbCr space to CIE XYZ. - * The colorspace conversion algorithm comes from the IJG v5a code; - * see below for more information on how it works. - */ -#define SHIFT 16 -#define FIX(x) ((int32)((x) * (1L<(max)?(max):(f)) -#define HICLAMP(f,max) ((f)>(max)?(max):(f)) - -void -TIFFYCbCrtoRGB(TIFFYCbCrToRGB *ycbcr, uint32 Y, int32 Cb, int32 Cr, - uint32 *r, uint32 *g, uint32 *b) -{ - int32 i; - - /* XXX: Only 8-bit YCbCr input supported for now */ - Y = HICLAMP(Y, 255), Cb = CLAMP(Cb, 0, 255), Cr = CLAMP(Cr, 0, 255); - - i = ycbcr->Y_tab[Y] + ycbcr->Cr_r_tab[Cr]; - *r = CLAMP(i, 0, 255); - i = ycbcr->Y_tab[Y] - + (int)((ycbcr->Cb_g_tab[Cb] + ycbcr->Cr_g_tab[Cr]) >> SHIFT); - *g = CLAMP(i, 0, 255); - i = ycbcr->Y_tab[Y] + ycbcr->Cb_b_tab[Cb]; - *b = CLAMP(i, 0, 255); -} - -/* - * Initialize the YCbCr->RGB conversion tables. The conversion - * is done according to the 6.0 spec: - * - * R = Y + Cr*(2 - 2*LumaRed) - * B = Y + Cb*(2 - 2*LumaBlue) - * G = Y - * - LumaBlue*Cb*(2-2*LumaBlue)/LumaGreen - * - LumaRed*Cr*(2-2*LumaRed)/LumaGreen - * - * To avoid floating point arithmetic the fractional constants that - * come out of the equations are represented as fixed point values - * in the range 0...2^16. We also eliminate multiplications by - * pre-calculating possible values indexed by Cb and Cr (this code - * assumes conversion is being done for 8-bit samples). - */ -int -TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite) -{ - TIFFRGBValue* clamptab; - int i; - -#define LumaRed luma[0] -#define LumaGreen luma[1] -#define LumaBlue luma[2] - - clamptab = (TIFFRGBValue*)( - (tidata_t) ycbcr+TIFFroundup(sizeof (TIFFYCbCrToRGB), sizeof (long))); - _TIFFmemset(clamptab, 0, 256); /* v < 0 => 0 */ - ycbcr->clamptab = (clamptab += 256); - for (i = 0; i < 256; i++) - clamptab[i] = (TIFFRGBValue) i; - _TIFFmemset(clamptab+256, 255, 2*256); /* v > 255 => 255 */ - ycbcr->Cr_r_tab = (int*) (clamptab + 3*256); - ycbcr->Cb_b_tab = ycbcr->Cr_r_tab + 256; - ycbcr->Cr_g_tab = (int32*) (ycbcr->Cb_b_tab + 256); - ycbcr->Cb_g_tab = ycbcr->Cr_g_tab + 256; - ycbcr->Y_tab = ycbcr->Cb_g_tab + 256; - - { float f1 = 2-2*LumaRed; int32 D1 = FIX(f1); - float f2 = LumaRed*f1/LumaGreen; int32 D2 = -FIX(f2); - float f3 = 2-2*LumaBlue; int32 D3 = FIX(f3); - float f4 = LumaBlue*f3/LumaGreen; int32 D4 = -FIX(f4); - int x; - -#undef LumaBlue -#undef LumaGreen -#undef LumaRed - - /* - * i is the actual input pixel value in the range 0..255 - * Cb and Cr values are in the range -128..127 (actually - * they are in a range defined by the ReferenceBlackWhite - * tag) so there is some range shifting to do here when - * constructing tables indexed by the raw pixel data. - */ - for (i = 0, x = -128; i < 256; i++, x++) { - int32 Cr = (int32)Code2V(x, refBlackWhite[4] - 128.0F, - refBlackWhite[5] - 128.0F, 127); - int32 Cb = (int32)Code2V(x, refBlackWhite[2] - 128.0F, - refBlackWhite[3] - 128.0F, 127); - - ycbcr->Cr_r_tab[i] = (int32)((D1*Cr + ONE_HALF)>>SHIFT); - ycbcr->Cb_b_tab[i] = (int32)((D3*Cb + ONE_HALF)>>SHIFT); - ycbcr->Cr_g_tab[i] = D2*Cr; - ycbcr->Cb_g_tab[i] = D4*Cb + ONE_HALF; - ycbcr->Y_tab[i] = - (int32)Code2V(x + 128, refBlackWhite[0], refBlackWhite[1], 255); - } - } - - return 0; -} -#undef HICLAMP -#undef CLAMP -#undef Code2V -#undef SHIFT -#undef ONE_HALF -#undef FIX - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_compress.c b/plugins/AdvaImg/src/LibTIFF/tif_compress.c deleted file mode 100644 index ac471b1e10..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_compress.c +++ /dev/null @@ -1,295 +0,0 @@ -/* $Id: tif_compress.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library - * - * Compression Scheme Configuration Support. - */ -#include "tiffiop.h" - -static int -TIFFNoEncode(TIFF* tif, const char* method) -{ - const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression); - - if (c) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%s %s encoding is not implemented", - c->name, method); - } else { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Compression scheme %u %s encoding is not implemented", - tif->tif_dir.td_compression, method); - } - return (-1); -} - -int -_TIFFNoRowEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) -{ - (void) pp; (void) cc; (void) s; - return (TIFFNoEncode(tif, "scanline")); -} - -int -_TIFFNoStripEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) -{ - (void) pp; (void) cc; (void) s; - return (TIFFNoEncode(tif, "strip")); -} - -int -_TIFFNoTileEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) -{ - (void) pp; (void) cc; (void) s; - return (TIFFNoEncode(tif, "tile")); -} - -static int -TIFFNoDecode(TIFF* tif, const char* method) -{ - const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression); - - if (c) - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%s %s decoding is not implemented", - c->name, method); - else - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Compression scheme %u %s decoding is not implemented", - tif->tif_dir.td_compression, method); - return (-1); -} - -int -_TIFFNoRowDecode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) -{ - (void) pp; (void) cc; (void) s; - return (TIFFNoDecode(tif, "scanline")); -} - -int -_TIFFNoStripDecode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) -{ - (void) pp; (void) cc; (void) s; - return (TIFFNoDecode(tif, "strip")); -} - -int -_TIFFNoTileDecode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) -{ - (void) pp; (void) cc; (void) s; - return (TIFFNoDecode(tif, "tile")); -} - -int -_TIFFNoSeek(TIFF* tif, uint32 off) -{ - (void) off; - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Compression algorithm does not support random access"); - return (0); -} - -int -_TIFFNoPreCode(TIFF* tif, tsample_t s) -{ - (void) tif; (void) s; - return (1); -} - -static int _TIFFtrue(TIFF* tif) { (void) tif; return (1); } -static void _TIFFvoid(TIFF* tif) { (void) tif; } - -void -_TIFFSetDefaultCompressionState(TIFF* tif) -{ - tif->tif_decodestatus = TRUE; - tif->tif_setupdecode = _TIFFtrue; - tif->tif_predecode = _TIFFNoPreCode; - tif->tif_decoderow = _TIFFNoRowDecode; - tif->tif_decodestrip = _TIFFNoStripDecode; - tif->tif_decodetile = _TIFFNoTileDecode; - tif->tif_encodestatus = TRUE; - tif->tif_setupencode = _TIFFtrue; - tif->tif_preencode = _TIFFNoPreCode; - tif->tif_postencode = _TIFFtrue; - tif->tif_encoderow = _TIFFNoRowEncode; - tif->tif_encodestrip = _TIFFNoStripEncode; - tif->tif_encodetile = _TIFFNoTileEncode; - tif->tif_close = _TIFFvoid; - tif->tif_seek = _TIFFNoSeek; - tif->tif_cleanup = _TIFFvoid; - tif->tif_defstripsize = _TIFFDefaultStripSize; - tif->tif_deftilesize = _TIFFDefaultTileSize; - tif->tif_flags &= ~(TIFF_NOBITREV|TIFF_NOREADRAW); -} - -int -TIFFSetCompressionScheme(TIFF* tif, int scheme) -{ - const TIFFCodec *c = TIFFFindCODEC((uint16) scheme); - - _TIFFSetDefaultCompressionState(tif); - /* - * Don't treat an unknown compression scheme as an error. - * This permits applications to open files with data that - * the library does not have builtin support for, but which - * may still be meaningful. - */ - return (c ? (*c->init)(tif, scheme) : 1); -} - -/* - * Other compression schemes may be registered. Registered - * schemes can also override the builtin versions provided - * by this library. - */ -typedef struct _codec { - struct _codec* next; - TIFFCodec* info; -} codec_t; -static codec_t* registeredCODECS = NULL; - -const TIFFCodec* -TIFFFindCODEC(uint16 scheme) -{ - const TIFFCodec* c; - codec_t* cd; - - for (cd = registeredCODECS; cd; cd = cd->next) - if (cd->info->scheme == scheme) - return ((const TIFFCodec*) cd->info); - for (c = _TIFFBuiltinCODECS; c->name; c++) - if (c->scheme == scheme) - return (c); - return ((const TIFFCodec*) 0); -} - -TIFFCodec* -TIFFRegisterCODEC(uint16 scheme, const char* name, TIFFInitMethod init) -{ - codec_t* cd = (codec_t*) - _TIFFmalloc(sizeof (codec_t) + sizeof (TIFFCodec) + strlen(name)+1); - - if (cd != NULL) { - cd->info = (TIFFCodec*) ((tidata_t) cd + sizeof (codec_t)); - cd->info->name = (char*) - ((tidata_t) cd->info + sizeof (TIFFCodec)); - strcpy(cd->info->name, name); - cd->info->scheme = scheme; - cd->info->init = init; - cd->next = registeredCODECS; - registeredCODECS = cd; - } else { - TIFFErrorExt(0, "TIFFRegisterCODEC", - "No space to register compression scheme %s", name); - return NULL; - } - return (cd->info); -} - -void -TIFFUnRegisterCODEC(TIFFCodec* c) -{ - codec_t* cd; - codec_t** pcd; - - for (pcd = ®isteredCODECS; (cd = *pcd); pcd = &cd->next) - if (cd->info == c) { - *pcd = cd->next; - _TIFFfree(cd); - return; - } - TIFFErrorExt(0, "TIFFUnRegisterCODEC", - "Cannot remove compression scheme %s; not registered", c->name); -} - -/************************************************************************/ -/* TIFFGetConfisuredCODECs() */ -/************************************************************************/ - -/** - * Get list of configured codecs, both built-in and registered by user. - * Caller is responsible to free this structure. - * - * @return returns array of TIFFCodec records (the last record should be NULL) - * or NULL if function failed. - */ - -TIFFCodec* -TIFFGetConfiguredCODECs() -{ - int i = 1; - codec_t *cd; - const TIFFCodec *c; - TIFFCodec *codecs = NULL, *new_codecs; - - for (cd = registeredCODECS; cd; cd = cd->next) { - new_codecs = (TIFFCodec *) - _TIFFrealloc(codecs, i * sizeof(TIFFCodec)); - if (!new_codecs) { - _TIFFfree (codecs); - return NULL; - } - codecs = new_codecs; - _TIFFmemcpy(codecs + i - 1, cd, sizeof(TIFFCodec)); - i++; - } - for (c = _TIFFBuiltinCODECS; c->name; c++) { - if (TIFFIsCODECConfigured(c->scheme)) { - new_codecs = (TIFFCodec *) - _TIFFrealloc(codecs, i * sizeof(TIFFCodec)); - if (!new_codecs) { - _TIFFfree (codecs); - return NULL; - } - codecs = new_codecs; - _TIFFmemcpy(codecs + i - 1, (const tdata_t)c, sizeof(TIFFCodec)); - i++; - } - } - - new_codecs = (TIFFCodec *) _TIFFrealloc(codecs, i * sizeof(TIFFCodec)); - if (!new_codecs) { - _TIFFfree (codecs); - return NULL; - } - codecs = new_codecs; - _TIFFmemset(codecs + i - 1, 0, sizeof(TIFFCodec)); - - return codecs; -} - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_config.h b/plugins/AdvaImg/src/LibTIFF/tif_config.h deleted file mode 100644 index 3e08176627..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_config.h +++ /dev/null @@ -1,266 +0,0 @@ -/* FreeImage libtiff config */ - -#ifndef _TIFFCONF_ -#define _TIFFCONF_ - -/* Define as 0 or 1 according to the floating point format suported by the - machine */ -#define HAVE_IEEEFP 1 - -/* --- byte order --- */ - -/* Some versions of gcc may have BYTE_ORDER or __BYTE_ORDER defined - If your big endian system isn't being detected, add an OS specific check -*/ -#if (defined(BYTE_ORDER) && BYTE_ORDER==BIG_ENDIAN) || \ - (defined(__BYTE_ORDER) && __BYTE_ORDER==__BIG_ENDIAN) || \ - defined(__BIG_ENDIAN__) -/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ -#define HOST_FILLORDER FILLORDER_MSB2LSB -/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian (Intel) */ -#define WORDS_BIGENDIAN 1 -#else -/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ -#define HOST_FILLORDER FILLORDER_LSB2MSB -/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian (Intel) */ -#undef WORDS_BIGENDIAN -#endif // BYTE_ORDER - -/* --- compression algorithms --- */ - -/* Support CCITT Group 3 & 4 algorithms */ -#define CCITT_SUPPORT 1 - -/* Support JPEG compression (requires IJG JPEG library) */ -#define JPEG_SUPPORT 1 - -/* Support LogLuv high dynamic range encoding */ -#define LOGLUV_SUPPORT 1 - -/* Support LZW algorithm */ -#define LZW_SUPPORT 1 - -/* Support NeXT 2-bit RLE algorithm */ -#define NEXT_SUPPORT 1 - -/* Support Old JPEG compression (read-only) */ -#define OJPEG_SUPPORT 1 - -/* Support Macintosh PackBits algorithm */ -#define PACKBITS_SUPPORT 1 - -/* Support Pixar log-format algorithm (requires Zlib) */ -#define PIXARLOG_SUPPORT 1 - -/* Support ThunderScan 4-bit RLE algorithm */ -#define THUNDER_SUPPORT 1 - -/* Support Deflate compression */ -#define ZIP_SUPPORT 1 - -/* --- ``Orthogonal Features'' --- */ - -/* Support strip chopping (whether or not to convert single-strip uncompressed - images to mutiple strips of ~8Kb to reduce memory usage) */ -#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP - -/* Enable SubIFD tag (330) support */ -#define SUBIFD_SUPPORT 1 - -/* Treat extra sample as alpha (default enabled). The RGBA interface will - treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many - packages produce RGBA files but don't mark the alpha properly. */ -#define DEFAULT_EXTRASAMPLE_AS_ALPHA 1 - -/* Pick up YCbCr subsampling info from the JPEG data stream to support files - lacking the tag (default enabled). */ -#define CHECK_JPEG_YCBCR_SUBSAMPLING 1 - -/* --- include files --- */ - -/* Use the Apple OpenGL framework. */ -/* #undef HAVE_APPLE_OPENGL_FRAMEWORK */ - -/* Define to 1 if you have the header file. */ -#define HAVE_ASSERT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define to 1 if you have the `floor' function. */ -#define HAVE_FLOOR 1 - -/* Define to 1 if you have the `getopt' function. */ -#define HAVE_GETOPT 1 - -/* Define as 0 or 1 according to the floating point format suported by the - machine */ -#define HAVE_IEEEFP 1 - -/* Define to 1 if the system has the type `int16'. */ -/* #undef HAVE_INT16 */ - -/* Define to 1 if the system has the type `int32'. */ -/* #undef HAVE_INT32 */ - -/* Define to 1 if the system has the type `int8'. */ -/* #undef HAVE_INT8 */ - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the `isascii' function. */ -#define HAVE_ISASCII 1 - -/* Define to 1 if you have the `c' library (-lc). */ -#define HAVE_LIBC 1 - -/* Define to 1 if you have the `m' library (-lm). */ -#define HAVE_LIBM 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MALLOC_H 1 - -/* Define to 1 if you have the `memmove' function. */ -#define HAVE_MEMMOVE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `memset' function. */ -#define HAVE_MEMSET 1 - -/* Define to 1 if you have the `mmap' function. */ -#define HAVE_MMAP 1 - -/* Define to 1 if you have the `pow' function. */ -#define HAVE_POW 1 - -/* Define if you have POSIX threads libraries and header files. */ -#define HAVE_PTHREAD 1 - -/* Define to 1 if you have the `sqrt' function. */ -#define HAVE_SQRT 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the `strcasecmp' function. */ -#define HAVE_STRCASECMP 1 - -/* Define to 1 if you have the `strchr' function. */ -#define HAVE_STRCHR 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the `strrchr' function. */ -#define HAVE_STRRCHR 1 - -/* Define to 1 if you have the `strstr' function. */ -#define HAVE_STRSTR 1 - -/* Define to 1 if you have the `strtol' function. */ -#define HAVE_STRTOL 1 - -/* Define to 1 if you have the `strtoul' function. */ -#define HAVE_STRTOUL 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TIME_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_WINDOWS_H */ - - -/* Define to 1 if your C compiler doesn't accept -c and -o together. */ -/* #undef NO_MINUS_C_MINUS_O */ - - -/* Define to the necessary symbol if this constant uses a non-standard name on - your system. */ -/* #undef PTHREAD_CREATE_JOINABLE */ - -/* The size of a `int', as computed by sizeof. */ -#define SIZEOF_INT 4 - -/* The size of a `long', as computed by sizeof. */ -#include -#if (LONG_MAX == +9223372036854775807L) -#define SIZEOF_LONG 8 -#elif (LONG_MAX == +2147483647) -#define SIZEOF_LONG 4 -#else -#error "Cannot detect SIZEOF_LONG" -#endif - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define to 1 if you can safely include both and . */ -#define TIME_WITH_SYS_TIME 1 - -/* Define to 1 if your declares `struct tm'. */ -/* #undef TM_IN_SYS_TIME */ - - -/* Define to 1 if your processor stores words with the most significant byte - first (like Motorola and SPARC, unlike Intel and VAX). */ -/* #undef WORDS_BIGENDIAN */ - -/* Define to 1 if the X Window System is missing or not being used. */ -/* #undef X_DISPLAY_MISSING */ - -/* Define for large files, on AIX-style hosts. */ -/* #undef _LARGE_FILES */ - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus - #ifdef _MSC_VER - #ifndef inline - #define inline __inline - #endif - #else - #undef inline - #endif // _MSC_VER -#endif // __cplusplus - -#ifdef _MSC_VER -#define lfind _lfind -/* Define to 1 if you have the header file. */ -#define HAVE_SEARCH_H 1 -#endif // _MSC_VER - - -/* Define to `long' if does not define. */ -/* #undef off_t */ - -/* Define to `unsigned' if does not define. */ -/* #undef size_t */ - -#endif /* _TIFFCONF_ */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_config.h-vms b/plugins/AdvaImg/src/LibTIFF/tif_config.h-vms deleted file mode 100644 index c2cae5752e..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_config.h-vms +++ /dev/null @@ -1,46 +0,0 @@ -/* Define to 1 if you have the header file. */ -#define HAVE_ASSERT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define as 0 or 1 according to the floating point format suported by the - machine */ -#define HAVE_IEEEFP 1 - -#define HAVE_UNISTD_H 1 - -#define HAVE_STRING_H 1 -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -//#define HAVE_IO_H 1 - -/* Define to 1 if you have the header file. */ -//#define HAVE_SEARCH_H 1 - -/* The size of a `int', as computed by sizeof. */ -#define SIZEOF_INT 4 - -/* The size of a `long', as computed by sizeof. */ -#define SIZEOF_LONG 4 - -/* Set the native cpu bit order */ -#define HOST_FILLORDER FILLORDER_LSB2MSB - -/* Define to 1 if your processor stores words with the most significant byte - first (like Motorola and SPARC, unlike Intel and VAX). */ -/* #undef WORDS_BIGENDIAN */ - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -/* -#ifndef __cplusplus -# ifndef inline -# define inline __inline -# endif -#endif -*/ - -// #define lfind _lfind diff --git a/plugins/AdvaImg/src/LibTIFF/tif_config.h.in b/plugins/AdvaImg/src/LibTIFF/tif_config.h.in deleted file mode 100644 index 86c07e6a99..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_config.h.in +++ /dev/null @@ -1,309 +0,0 @@ -/* libtiff/tif_config.h.in. Generated from configure.ac by autoheader. */ - -/* Define if building universal (internal helper macro) */ -#undef AC_APPLE_UNIVERSAL_BUILD - -/* Support CCITT Group 3 & 4 algorithms */ -#undef CCITT_SUPPORT - -/* Pick up YCbCr subsampling info from the JPEG data stream to support files - lacking the tag (default enabled). */ -#undef CHECK_JPEG_YCBCR_SUBSAMPLING - -/* Support C++ stream API (requires C++ compiler) */ -#undef CXX_SUPPORT - -/* Treat extra sample as alpha (default enabled). The RGBA interface will - treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many - packages produce RGBA files but don't mark the alpha properly. */ -#undef DEFAULT_EXTRASAMPLE_AS_ALPHA - -/* Use the Apple OpenGL framework. */ -#undef HAVE_APPLE_OPENGL_FRAMEWORK - -/* Define to 1 if you have the header file. */ -#undef HAVE_ASSERT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_DLFCN_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_FCNTL_H - -/* Define to 1 if you have the `floor' function. */ -#undef HAVE_FLOOR - -/* Define to 1 if you have the `getopt' function. */ -#undef HAVE_GETOPT - -/* Define as 0 or 1 according to the floating point format suported by the - machine */ -#undef HAVE_IEEEFP - -/* Define to 1 if the system has the type `int16'. */ -#undef HAVE_INT16 - -/* Define to 1 if the system has the type `int32'. */ -#undef HAVE_INT32 - -/* Define to 1 if the system has the type `int8'. */ -#undef HAVE_INT8 - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_IO_H - -/* Define to 1 if you have the `isascii' function. */ -#undef HAVE_ISASCII - -/* Define to 1 if you have the `jbg_newlen' function. */ -#undef HAVE_JBG_NEWLEN - -/* Define to 1 if you have the `lfind' function. */ -#undef HAVE_LFIND - -/* Define to 1 if you have the `c' library (-lc). */ -#undef HAVE_LIBC - -/* Define to 1 if you have the `m' library (-lm). */ -#undef HAVE_LIBM - -/* Define to 1 if you have the header file. */ -#undef HAVE_LIMITS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_MALLOC_H - -/* Define to 1 if you have the `memmove' function. */ -#undef HAVE_MEMMOVE - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have the `memset' function. */ -#undef HAVE_MEMSET - -/* Define to 1 if you have the `mmap' function. */ -#undef HAVE_MMAP - -/* Define to 1 if you have the `pow' function. */ -#undef HAVE_POW - -/* Define if you have POSIX threads libraries and header files. */ -#undef HAVE_PTHREAD - -/* Define to 1 if you have the header file. */ -#undef HAVE_SEARCH_H - -/* Define to 1 if you have the `setmode' function. */ -#undef HAVE_SETMODE - -/* Define to 1 if you have the `sqrt' function. */ -#undef HAVE_SQRT - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the `strcasecmp' function. */ -#undef HAVE_STRCASECMP - -/* Define to 1 if you have the `strchr' function. */ -#undef HAVE_STRCHR - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the `strrchr' function. */ -#undef HAVE_STRRCHR - -/* Define to 1 if you have the `strstr' function. */ -#undef HAVE_STRSTR - -/* Define to 1 if you have the `strtol' function. */ -#undef HAVE_STRTOL - -/* Define to 1 if you have the `strtoul' function. */ -#undef HAVE_STRTOUL - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TIME_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_WINDOWS_H - -/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian - (Intel) */ -#undef HOST_BIGENDIAN - -/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ -#undef HOST_FILLORDER - -/* Support ISO JBIG compression (requires JBIG-KIT library) */ -#undef JBIG_SUPPORT - -/* Support JPEG compression (requires IJG JPEG library) */ -#undef JPEG_SUPPORT - -/* Support LogLuv high dynamic range encoding */ -#undef LOGLUV_SUPPORT - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#undef LT_OBJDIR - -/* Support LZW algorithm */ -#undef LZW_SUPPORT - -/* Support Microsoft Document Imaging format */ -#undef MDI_SUPPORT - -/* Support NeXT 2-bit RLE algorithm */ -#undef NEXT_SUPPORT - -/* Define to 1 if your C compiler doesn't accept -c and -o together. */ -#undef NO_MINUS_C_MINUS_O - -/* Support Old JPEG compresson (read-only) */ -#undef OJPEG_SUPPORT - -/* Name of package */ -#undef PACKAGE - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the home page for this package. */ -#undef PACKAGE_URL - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Support Macintosh PackBits algorithm */ -#undef PACKBITS_SUPPORT - -/* Support Pixar log-format algorithm (requires Zlib) */ -#undef PIXARLOG_SUPPORT - -/* Define to necessary symbol if this constant uses a non-standard name on - your system. */ -#undef PTHREAD_CREATE_JOINABLE - -/* The size of `int', as computed by sizeof. */ -#undef SIZEOF_INT - -/* The size of `long', as computed by sizeof. */ -#undef SIZEOF_LONG - -/* The size of `signed long', as computed by sizeof. */ -#undef SIZEOF_SIGNED_LONG - -/* The size of `signed long long', as computed by sizeof. */ -#undef SIZEOF_SIGNED_LONG_LONG - -/* The size of `unsigned long', as computed by sizeof. */ -#undef SIZEOF_UNSIGNED_LONG - -/* The size of `unsigned long long', as computed by sizeof. */ -#undef SIZEOF_UNSIGNED_LONG_LONG - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Support strip chopping (whether or not to convert single-strip uncompressed - images to mutiple strips of specified size to reduce memory usage) */ -#undef STRIPCHOP_DEFAULT - -/* Default size of the strip in bytes (when strip chopping enabled) */ -#undef STRIP_SIZE_DEFAULT - -/* Enable SubIFD tag (330) support */ -#undef SUBIFD_SUPPORT - -/* Support ThunderScan 4-bit RLE algorithm */ -#undef THUNDER_SUPPORT - -/* Signed 64-bit type formatter */ -#undef TIFF_INT64_FORMAT - -/* Signed 64-bit type */ -#undef TIFF_INT64_T - -/* Unsigned 64-bit type formatter */ -#undef TIFF_UINT64_FORMAT - -/* Unsigned 64-bit type */ -#undef TIFF_UINT64_T - -/* Define to 1 if you can safely include both and . */ -#undef TIME_WITH_SYS_TIME - -/* Define to 1 if your declares `struct tm'. */ -#undef TM_IN_SYS_TIME - -/* Version number of package */ -#undef VERSION - -/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most - significant byte first (like Motorola and SPARC, unlike Intel). */ -#if defined AC_APPLE_UNIVERSAL_BUILD -# if defined __BIG_ENDIAN__ -# define WORDS_BIGENDIAN 1 -# endif -#else -# ifndef WORDS_BIGENDIAN -# undef WORDS_BIGENDIAN -# endif -#endif - -/* Define to 1 if the X Window System is missing or not being used. */ -#undef X_DISPLAY_MISSING - -/* Support Deflate compression */ -#undef ZIP_SUPPORT - -/* Number of bits in a file offset, on hosts where this is settable. */ -#undef _FILE_OFFSET_BITS - -/* Define for large files, on AIX-style hosts. */ -#undef _LARGE_FILES - -/* Define to empty if `const' does not conform to ANSI C. */ -#undef const - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -#undef inline -#endif - -/* Define to `long int' if does not define. */ -#undef off_t - -/* Define to `unsigned int' if does not define. */ -#undef size_t diff --git a/plugins/AdvaImg/src/LibTIFF/tif_config.vc.h b/plugins/AdvaImg/src/LibTIFF/tif_config.vc.h deleted file mode 100644 index 2bb16d3322..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_config.vc.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Define to 1 if you have the header file. */ -#define HAVE_ASSERT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define as 0 or 1 according to the floating point format suported by the - machine */ -#define HAVE_IEEEFP 1 - -/* Define to 1 if you have the `jbg_newlen' function. */ -#define HAVE_JBG_NEWLEN 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_IO_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SEARCH_H 1 - -/* Define to 1 if you have the `setmode' function. */ -#define HAVE_SETMODE 1 - -/* The size of a `int', as computed by sizeof. */ -#define SIZEOF_INT 4 - -/* The size of a `long', as computed by sizeof. */ -#define SIZEOF_LONG 4 - -/* Signed 64-bit type */ -#define TIFF_INT64_T signed __int64 - -/* Unsigned 64-bit type */ -#define TIFF_UINT64_T unsigned __int64 - -/* Set the native cpu bit order */ -#define HOST_FILLORDER FILLORDER_LSB2MSB - -/* Define to 1 if your processor stores words with the most significant byte - first (like Motorola and SPARC, unlike Intel and VAX). */ -/* #undef WORDS_BIGENDIAN */ - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -# ifndef inline -# define inline __inline -# endif -#endif - -#define lfind _lfind -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_dir.c b/plugins/AdvaImg/src/LibTIFF/tif_dir.c deleted file mode 100644 index 081bb43c06..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_dir.c +++ /dev/null @@ -1,1391 +0,0 @@ -/* $Id: tif_dir.c,v 1.38 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Directory Tag Get & Set Routines. - * (and also some miscellaneous stuff) - */ -#include "tiffiop.h" - -/* - * These are used in the backwards compatibility code... - */ -#define DATATYPE_VOID 0 /* !untyped data */ -#define DATATYPE_INT 1 /* !signed integer data */ -#define DATATYPE_UINT 2 /* !unsigned integer data */ -#define DATATYPE_IEEEFP 3 /* !IEEE floating point data */ - -static void -setByteArray(void** vpp, void* vp, size_t nmemb, size_t elem_size) -{ - if (*vpp) - _TIFFfree(*vpp), *vpp = 0; - if (vp) { - tsize_t bytes = nmemb * elem_size; - if (elem_size && bytes / elem_size == nmemb) - *vpp = (void*) _TIFFmalloc(bytes); - if (*vpp) - _TIFFmemcpy(*vpp, vp, bytes); - } -} -void _TIFFsetByteArray(void** vpp, void* vp, uint32 n) - { setByteArray(vpp, vp, n, 1); } -void _TIFFsetString(char** cpp, char* cp) - { setByteArray((void**) cpp, (void*) cp, strlen(cp)+1, 1); } -void _TIFFsetNString(char** cpp, char* cp, uint32 n) - { setByteArray((void**) cpp, (void*) cp, n, 1); } -void _TIFFsetShortArray(uint16** wpp, uint16* wp, uint32 n) - { setByteArray((void**) wpp, (void*) wp, n, sizeof (uint16)); } -void _TIFFsetLongArray(uint32** lpp, uint32* lp, uint32 n) - { setByteArray((void**) lpp, (void*) lp, n, sizeof (uint32)); } -void _TIFFsetFloatArray(float** fpp, float* fp, uint32 n) - { setByteArray((void**) fpp, (void*) fp, n, sizeof (float)); } -void _TIFFsetDoubleArray(double** dpp, double* dp, uint32 n) - { setByteArray((void**) dpp, (void*) dp, n, sizeof (double)); } - -/* - * Install extra samples information. - */ -static int -setExtraSamples(TIFFDirectory* td, va_list ap, uint32* v) -{ -/* XXX: Unassociated alpha data == 999 is a known Corel Draw bug, see below */ -#define EXTRASAMPLE_COREL_UNASSALPHA 999 - - uint16* va; - uint32 i; - - *v = va_arg(ap, uint32); - if ((uint16) *v > td->td_samplesperpixel) - return 0; - va = va_arg(ap, uint16*); - if (*v > 0 && va == NULL) /* typically missing param */ - return 0; - for (i = 0; i < *v; i++) { - if (va[i] > EXTRASAMPLE_UNASSALPHA) { - /* - * XXX: Corel Draw is known to produce incorrect - * ExtraSamples tags which must be patched here if we - * want to be able to open some of the damaged TIFF - * files: - */ - if (va[i] == EXTRASAMPLE_COREL_UNASSALPHA) - va[i] = EXTRASAMPLE_UNASSALPHA; - else - return 0; - } - } - td->td_extrasamples = (uint16) *v; - _TIFFsetShortArray(&td->td_sampleinfo, va, td->td_extrasamples); - return 1; - -#undef EXTRASAMPLE_COREL_UNASSALPHA -} - -static uint32 -checkInkNamesString(TIFF* tif, uint32 slen, const char* s) -{ - TIFFDirectory* td = &tif->tif_dir; - uint16 i = td->td_samplesperpixel; - - if (slen > 0) { - const char* ep = s+slen; - const char* cp = s; - for (; i > 0; i--) { - for (; *cp != '\0'; cp++) - if (cp >= ep) - goto bad; - cp++; /* skip \0 */ - } - return (cp-s); - } -bad: - TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", - "%s: Invalid InkNames value; expecting %d names, found %d", - tif->tif_name, - td->td_samplesperpixel, - td->td_samplesperpixel-i); - return (0); -} - -static int -_TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap) -{ - static const char module[] = "_TIFFVSetField"; - - TIFFDirectory* td = &tif->tif_dir; - int status = 1; - uint32 v32, i, v; - char* s; - - switch (tag) { - case TIFFTAG_SUBFILETYPE: - td->td_subfiletype = va_arg(ap, uint32); - break; - case TIFFTAG_IMAGEWIDTH: - td->td_imagewidth = va_arg(ap, uint32); - break; - case TIFFTAG_IMAGELENGTH: - td->td_imagelength = va_arg(ap, uint32); - break; - case TIFFTAG_BITSPERSAMPLE: - td->td_bitspersample = (uint16) va_arg(ap, int); - /* - * If the data require post-decoding processing to byte-swap - * samples, set it up here. Note that since tags are required - * to be ordered, compression code can override this behaviour - * in the setup method if it wants to roll the post decoding - * work in with its normal work. - */ - if (tif->tif_flags & TIFF_SWAB) { - if (td->td_bitspersample == 8) - tif->tif_postdecode = _TIFFNoPostDecode; - else if (td->td_bitspersample == 16) - tif->tif_postdecode = _TIFFSwab16BitData; - else if (td->td_bitspersample == 24) - tif->tif_postdecode = _TIFFSwab24BitData; - else if (td->td_bitspersample == 32) - tif->tif_postdecode = _TIFFSwab32BitData; - else if (td->td_bitspersample == 64) - tif->tif_postdecode = _TIFFSwab64BitData; - else if (td->td_bitspersample == 128) /* two 64's */ - tif->tif_postdecode = _TIFFSwab64BitData; - } - break; - case TIFFTAG_COMPRESSION: - v = va_arg(ap, uint32) & 0xffff; - /* - * If we're changing the compression scheme, the notify the - * previous module so that it can cleanup any state it's - * setup. - */ - if (TIFFFieldSet(tif, FIELD_COMPRESSION)) { - if (td->td_compression == v) - break; - (*tif->tif_cleanup)(tif); - tif->tif_flags &= ~TIFF_CODERSETUP; - } - /* - * Setup new compression routine state. - */ - if ( (status = TIFFSetCompressionScheme(tif, v)) != 0 ) - td->td_compression = (uint16) v; - else - status = 0; - break; - case TIFFTAG_PHOTOMETRIC: - td->td_photometric = (uint16) va_arg(ap, int); - break; - case TIFFTAG_THRESHHOLDING: - td->td_threshholding = (uint16) va_arg(ap, int); - break; - case TIFFTAG_FILLORDER: - v = va_arg(ap, uint32); - if (v != FILLORDER_LSB2MSB && v != FILLORDER_MSB2LSB) - goto badvalue; - td->td_fillorder = (uint16) v; - break; - case TIFFTAG_ORIENTATION: - v = va_arg(ap, uint32); - if (v < ORIENTATION_TOPLEFT || ORIENTATION_LEFTBOT < v) - goto badvalue; - else - td->td_orientation = (uint16) v; - break; - case TIFFTAG_SAMPLESPERPIXEL: - /* XXX should cross check -- e.g. if pallette, then 1 */ - v = va_arg(ap, uint32); - if (v == 0) - goto badvalue; - td->td_samplesperpixel = (uint16) v; - break; - case TIFFTAG_ROWSPERSTRIP: - v32 = va_arg(ap, uint32); - if (v32 == 0) - goto badvalue32; - td->td_rowsperstrip = v32; - if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) { - td->td_tilelength = v32; - td->td_tilewidth = td->td_imagewidth; - } - break; - case TIFFTAG_MINSAMPLEVALUE: - td->td_minsamplevalue = (uint16) va_arg(ap, int); - break; - case TIFFTAG_MAXSAMPLEVALUE: - td->td_maxsamplevalue = (uint16) va_arg(ap, int); - break; - case TIFFTAG_SMINSAMPLEVALUE: - td->td_sminsamplevalue = va_arg(ap, double); - break; - case TIFFTAG_SMAXSAMPLEVALUE: - td->td_smaxsamplevalue = va_arg(ap, double); - break; - case TIFFTAG_XRESOLUTION: - td->td_xresolution = (float) va_arg(ap, double); - break; - case TIFFTAG_YRESOLUTION: - td->td_yresolution = (float) va_arg(ap, double); - break; - case TIFFTAG_PLANARCONFIG: - v = va_arg(ap, uint32); - if (v != PLANARCONFIG_CONTIG && v != PLANARCONFIG_SEPARATE) - goto badvalue; - td->td_planarconfig = (uint16) v; - break; - case TIFFTAG_XPOSITION: - td->td_xposition = (float) va_arg(ap, double); - break; - case TIFFTAG_YPOSITION: - td->td_yposition = (float) va_arg(ap, double); - break; - case TIFFTAG_RESOLUTIONUNIT: - v = va_arg(ap, uint32); - if (v < RESUNIT_NONE || RESUNIT_CENTIMETER < v) - goto badvalue; - td->td_resolutionunit = (uint16) v; - break; - case TIFFTAG_PAGENUMBER: - td->td_pagenumber[0] = (uint16) va_arg(ap, int); - td->td_pagenumber[1] = (uint16) va_arg(ap, int); - break; - case TIFFTAG_HALFTONEHINTS: - td->td_halftonehints[0] = (uint16) va_arg(ap, int); - td->td_halftonehints[1] = (uint16) va_arg(ap, int); - break; - case TIFFTAG_COLORMAP: - v32 = (uint32)(1L<td_bitspersample); - _TIFFsetShortArray(&td->td_colormap[0], va_arg(ap, uint16*), v32); - _TIFFsetShortArray(&td->td_colormap[1], va_arg(ap, uint16*), v32); - _TIFFsetShortArray(&td->td_colormap[2], va_arg(ap, uint16*), v32); - break; - case TIFFTAG_EXTRASAMPLES: - if (!setExtraSamples(td, ap, &v)) - goto badvalue; - break; - case TIFFTAG_MATTEING: - td->td_extrasamples = (uint16) (va_arg(ap, int) != 0); - if (td->td_extrasamples) { - uint16 sv = EXTRASAMPLE_ASSOCALPHA; - _TIFFsetShortArray(&td->td_sampleinfo, &sv, 1); - } - break; - case TIFFTAG_TILEWIDTH: - v32 = va_arg(ap, uint32); - if (v32 % 16) { - if (tif->tif_mode != O_RDONLY) - goto badvalue32; - TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "Nonstandard tile width %d, convert file", v32); - } - td->td_tilewidth = v32; - tif->tif_flags |= TIFF_ISTILED; - break; - case TIFFTAG_TILELENGTH: - v32 = va_arg(ap, uint32); - if (v32 % 16) { - if (tif->tif_mode != O_RDONLY) - goto badvalue32; - TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "Nonstandard tile length %d, convert file", v32); - } - td->td_tilelength = v32; - tif->tif_flags |= TIFF_ISTILED; - break; - case TIFFTAG_TILEDEPTH: - v32 = va_arg(ap, uint32); - if (v32 == 0) - goto badvalue32; - td->td_tiledepth = v32; - break; - case TIFFTAG_DATATYPE: - v = va_arg(ap, uint32); - switch (v) { - case DATATYPE_VOID: v = SAMPLEFORMAT_VOID; break; - case DATATYPE_INT: v = SAMPLEFORMAT_INT; break; - case DATATYPE_UINT: v = SAMPLEFORMAT_UINT; break; - case DATATYPE_IEEEFP: v = SAMPLEFORMAT_IEEEFP;break; - default: goto badvalue; - } - td->td_sampleformat = (uint16) v; - break; - case TIFFTAG_SAMPLEFORMAT: - v = va_arg(ap, uint32); - if (v < SAMPLEFORMAT_UINT || SAMPLEFORMAT_COMPLEXIEEEFP < v) - goto badvalue; - td->td_sampleformat = (uint16) v; - - /* Try to fix up the SWAB function for complex data. */ - if ( td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT - && td->td_bitspersample == 32 - && tif->tif_postdecode == _TIFFSwab32BitData ) - tif->tif_postdecode = _TIFFSwab16BitData; - else if ( (td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT - || td->td_sampleformat == SAMPLEFORMAT_COMPLEXIEEEFP) - && td->td_bitspersample == 64 - && tif->tif_postdecode == _TIFFSwab64BitData ) - tif->tif_postdecode = _TIFFSwab32BitData; - break; - case TIFFTAG_IMAGEDEPTH: - td->td_imagedepth = va_arg(ap, uint32); - break; - case TIFFTAG_SUBIFD: - if ((tif->tif_flags & TIFF_INSUBIFD) == 0) { - td->td_nsubifd = (uint16) va_arg(ap, int); - _TIFFsetLongArray(&td->td_subifd, va_arg(ap, uint32*), - (long) td->td_nsubifd); - } else { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Sorry, cannot nest SubIFDs", - tif->tif_name); - status = 0; - } - break; - case TIFFTAG_YCBCRPOSITIONING: - td->td_ycbcrpositioning = (uint16) va_arg(ap, int); - break; - case TIFFTAG_YCBCRSUBSAMPLING: - td->td_ycbcrsubsampling[0] = (uint16) va_arg(ap, int); - td->td_ycbcrsubsampling[1] = (uint16) va_arg(ap, int); - break; - case TIFFTAG_TRANSFERFUNCTION: - v = (td->td_samplesperpixel - td->td_extrasamples) > 1 ? 3 : 1; - for (i = 0; i < v; i++) - _TIFFsetShortArray(&td->td_transferfunction[i], - va_arg(ap, uint16*), 1L<td_bitspersample); - break; - case TIFFTAG_REFERENCEBLACKWHITE: - /* XXX should check for null range */ - _TIFFsetFloatArray(&td->td_refblackwhite, va_arg(ap, float*), 6); - break; - case TIFFTAG_INKNAMES: - v = va_arg(ap, uint32); - s = va_arg(ap, char*); - v = checkInkNamesString(tif, v, s); - status = v > 0; - if ( v > 0 ) { - _TIFFsetNString(&td->td_inknames, s, v); - td->td_inknameslen = v; - } - break; - default: { - TIFFTagValue *tv; - int tv_size, iCustom; - const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY); - - /* - * This can happen if multiple images are open with different - * codecs which have private tags. The global tag information - * table may then have tags that are valid for one file but not - * the other. If the client tries to set a tag that is not valid - * for the image's codec then we'll arrive here. This - * happens, for example, when tiffcp is used to convert between - * compression schemes and codec-specific tags are blindly copied. - */ - if(fip == NULL || fip->field_bit != FIELD_CUSTOM) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Invalid %stag \"%s\" (not supported by codec)", - tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", - fip ? fip->field_name : "Unknown"); - status = 0; - break; - } - - /* - * Find the existing entry for this custom value. - */ - tv = NULL; - for (iCustom = 0; iCustom < td->td_customValueCount; iCustom++) { - if (td->td_customValues[iCustom].info->field_tag == tag) { - tv = td->td_customValues + iCustom; - if (tv->value != NULL) { - _TIFFfree(tv->value); - tv->value = NULL; - } - break; - } - } - - /* - * Grow the custom list if the entry was not found. - */ - if(tv == NULL) { - TIFFTagValue *new_customValues; - - td->td_customValueCount++; - new_customValues = (TIFFTagValue *) - _TIFFrealloc(td->td_customValues, - sizeof(TIFFTagValue) * td->td_customValueCount); - if (!new_customValues) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Failed to allocate space for list of custom values", - tif->tif_name); - status = 0; - goto end; - } - - td->td_customValues = new_customValues; - - tv = td->td_customValues + (td->td_customValueCount - 1); - tv->info = fip; - tv->value = NULL; - tv->count = 0; - } - - /* - * Set custom value ... save a copy of the custom tag value. - */ - tv_size = _TIFFDataSize(fip->field_type); - if (tv_size == 0) { - status = 0; - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Bad field type %d for \"%s\"", - tif->tif_name, fip->field_type, - fip->field_name); - goto end; - } - - if(fip->field_passcount) { - if (fip->field_writecount == TIFF_VARIABLE2) - tv->count = (uint32) va_arg(ap, uint32); - else - tv->count = (int) va_arg(ap, int); - } else if (fip->field_writecount == TIFF_VARIABLE - || fip->field_writecount == TIFF_VARIABLE2) - tv->count = 1; - else if (fip->field_writecount == TIFF_SPP) - tv->count = td->td_samplesperpixel; - else - tv->count = fip->field_writecount; - - - if (fip->field_type == TIFF_ASCII) - _TIFFsetString((char **)&tv->value, va_arg(ap, char *)); - else { - tv->value = _TIFFCheckMalloc(tif, tv_size, tv->count, - "Tag Value"); - if (!tv->value) { - status = 0; - goto end; - } - - if ((fip->field_passcount - || fip->field_writecount == TIFF_VARIABLE - || fip->field_writecount == TIFF_VARIABLE2 - || fip->field_writecount == TIFF_SPP - || tv->count > 1) - && fip->field_tag != TIFFTAG_PAGENUMBER - && fip->field_tag != TIFFTAG_HALFTONEHINTS - && fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING - && fip->field_tag != TIFFTAG_DOTRANGE) { - _TIFFmemcpy(tv->value, va_arg(ap, void *), - tv->count * tv_size); - } else { - /* - * XXX: The following loop required to handle - * TIFFTAG_PAGENUMBER, TIFFTAG_HALFTONEHINTS, - * TIFFTAG_YCBCRSUBSAMPLING and TIFFTAG_DOTRANGE tags. - * These tags are actually arrays and should be passed as - * array pointers to TIFFSetField() function, but actually - * passed as a list of separate values. This behaviour - * must be changed in the future! - */ - int i; - char *val = (char *)tv->value; - - for (i = 0; i < tv->count; i++, val += tv_size) { - switch (fip->field_type) { - case TIFF_BYTE: - case TIFF_UNDEFINED: - { - uint8 v = (uint8)va_arg(ap, int); - _TIFFmemcpy(val, &v, tv_size); - } - break; - case TIFF_SBYTE: - { - int8 v = (int8)va_arg(ap, int); - _TIFFmemcpy(val, &v, tv_size); - } - break; - case TIFF_SHORT: - { - uint16 v = (uint16)va_arg(ap, int); - _TIFFmemcpy(val, &v, tv_size); - } - break; - case TIFF_SSHORT: - { - int16 v = (int16)va_arg(ap, int); - _TIFFmemcpy(val, &v, tv_size); - } - break; - case TIFF_LONG: - case TIFF_IFD: - { - uint32 v = va_arg(ap, uint32); - _TIFFmemcpy(val, &v, tv_size); - } - break; - case TIFF_SLONG: - { - int32 v = va_arg(ap, int32); - _TIFFmemcpy(val, &v, tv_size); - } - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - case TIFF_FLOAT: - { - float v = (float)va_arg(ap, double); - _TIFFmemcpy(val, &v, tv_size); - } - break; - case TIFF_DOUBLE: - { - double v = va_arg(ap, double); - _TIFFmemcpy(val, &v, tv_size); - } - break; - default: - _TIFFmemset(val, 0, tv_size); - status = 0; - break; - } - } - } - } - } - } - if (status) { - TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit); - tif->tif_flags |= TIFF_DIRTYDIRECT; - } - -end: - va_end(ap); - return (status); -badvalue: - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Bad value %d for \"%s\" tag", - tif->tif_name, v, - _TIFFFieldWithTag(tif, tag)->field_name); - va_end(ap); - return (0); -badvalue32: - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Bad value %u for \"%s\" tag", - tif->tif_name, v32, - _TIFFFieldWithTag(tif, tag)->field_name); - va_end(ap); - return (0); -} - -/* - * Return 1/0 according to whether or not - * it is permissible to set the tag's value. - * Note that we allow ImageLength to be changed - * so that we can append and extend to images. - * Any other tag may not be altered once writing - * has commenced, unless its value has no effect - * on the format of the data that is written. - */ -static int -OkToChangeTag(TIFF* tif, ttag_t tag) -{ - const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY); - if (!fip) { /* unknown tag */ - TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", "%s: Unknown %stag %u", - tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", tag); - return (0); - } - if (tag != TIFFTAG_IMAGELENGTH && (tif->tif_flags & TIFF_BEENWRITING) && - !fip->field_oktochange) { - /* - * Consult info table to see if tag can be changed - * after we've started writing. We only allow changes - * to those tags that don't/shouldn't affect the - * compression and/or format of the data. - */ - TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", - "%s: Cannot modify tag \"%s\" while writing", - tif->tif_name, fip->field_name); - return (0); - } - return (1); -} - -/* - * Record the value of a field in the - * internal directory structure. The - * field will be written to the file - * when/if the directory structure is - * updated. - */ -int -TIFFSetField(TIFF* tif, ttag_t tag, ...) -{ - va_list ap; - int status; - - va_start(ap, tag); - status = TIFFVSetField(tif, tag, ap); - va_end(ap); - return (status); -} - -/* - * Like TIFFSetField, but taking a varargs - * parameter list. This routine is useful - * for building higher-level interfaces on - * top of the library. - */ -int -TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap) -{ - return OkToChangeTag(tif, tag) ? - (*tif->tif_tagmethods.vsetfield)(tif, tag, ap) : 0; -} - -static int -_TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap) -{ - TIFFDirectory* td = &tif->tif_dir; - int ret_val = 1; - - switch (tag) { - case TIFFTAG_SUBFILETYPE: - *va_arg(ap, uint32*) = td->td_subfiletype; - break; - case TIFFTAG_IMAGEWIDTH: - *va_arg(ap, uint32*) = td->td_imagewidth; - break; - case TIFFTAG_IMAGELENGTH: - *va_arg(ap, uint32*) = td->td_imagelength; - break; - case TIFFTAG_BITSPERSAMPLE: - *va_arg(ap, uint16*) = td->td_bitspersample; - break; - case TIFFTAG_COMPRESSION: - *va_arg(ap, uint16*) = td->td_compression; - break; - case TIFFTAG_PHOTOMETRIC: - *va_arg(ap, uint16*) = td->td_photometric; - break; - case TIFFTAG_THRESHHOLDING: - *va_arg(ap, uint16*) = td->td_threshholding; - break; - case TIFFTAG_FILLORDER: - *va_arg(ap, uint16*) = td->td_fillorder; - break; - case TIFFTAG_ORIENTATION: - *va_arg(ap, uint16*) = td->td_orientation; - break; - case TIFFTAG_SAMPLESPERPIXEL: - *va_arg(ap, uint16*) = td->td_samplesperpixel; - break; - case TIFFTAG_ROWSPERSTRIP: - *va_arg(ap, uint32*) = td->td_rowsperstrip; - break; - case TIFFTAG_MINSAMPLEVALUE: - *va_arg(ap, uint16*) = td->td_minsamplevalue; - break; - case TIFFTAG_MAXSAMPLEVALUE: - *va_arg(ap, uint16*) = td->td_maxsamplevalue; - break; - case TIFFTAG_SMINSAMPLEVALUE: - *va_arg(ap, double*) = td->td_sminsamplevalue; - break; - case TIFFTAG_SMAXSAMPLEVALUE: - *va_arg(ap, double*) = td->td_smaxsamplevalue; - break; - case TIFFTAG_XRESOLUTION: - *va_arg(ap, float*) = td->td_xresolution; - break; - case TIFFTAG_YRESOLUTION: - *va_arg(ap, float*) = td->td_yresolution; - break; - case TIFFTAG_PLANARCONFIG: - *va_arg(ap, uint16*) = td->td_planarconfig; - break; - case TIFFTAG_XPOSITION: - *va_arg(ap, float*) = td->td_xposition; - break; - case TIFFTAG_YPOSITION: - *va_arg(ap, float*) = td->td_yposition; - break; - case TIFFTAG_RESOLUTIONUNIT: - *va_arg(ap, uint16*) = td->td_resolutionunit; - break; - case TIFFTAG_PAGENUMBER: - *va_arg(ap, uint16*) = td->td_pagenumber[0]; - *va_arg(ap, uint16*) = td->td_pagenumber[1]; - break; - case TIFFTAG_HALFTONEHINTS: - *va_arg(ap, uint16*) = td->td_halftonehints[0]; - *va_arg(ap, uint16*) = td->td_halftonehints[1]; - break; - case TIFFTAG_COLORMAP: - *va_arg(ap, uint16**) = td->td_colormap[0]; - *va_arg(ap, uint16**) = td->td_colormap[1]; - *va_arg(ap, uint16**) = td->td_colormap[2]; - break; - case TIFFTAG_STRIPOFFSETS: - case TIFFTAG_TILEOFFSETS: - *va_arg(ap, uint32**) = td->td_stripoffset; - break; - case TIFFTAG_STRIPBYTECOUNTS: - case TIFFTAG_TILEBYTECOUNTS: - *va_arg(ap, uint32**) = td->td_stripbytecount; - break; - case TIFFTAG_MATTEING: - *va_arg(ap, uint16*) = - (td->td_extrasamples == 1 && - td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA); - break; - case TIFFTAG_EXTRASAMPLES: - *va_arg(ap, uint16*) = td->td_extrasamples; - *va_arg(ap, uint16**) = td->td_sampleinfo; - break; - case TIFFTAG_TILEWIDTH: - *va_arg(ap, uint32*) = td->td_tilewidth; - break; - case TIFFTAG_TILELENGTH: - *va_arg(ap, uint32*) = td->td_tilelength; - break; - case TIFFTAG_TILEDEPTH: - *va_arg(ap, uint32*) = td->td_tiledepth; - break; - case TIFFTAG_DATATYPE: - switch (td->td_sampleformat) { - case SAMPLEFORMAT_UINT: - *va_arg(ap, uint16*) = DATATYPE_UINT; - break; - case SAMPLEFORMAT_INT: - *va_arg(ap, uint16*) = DATATYPE_INT; - break; - case SAMPLEFORMAT_IEEEFP: - *va_arg(ap, uint16*) = DATATYPE_IEEEFP; - break; - case SAMPLEFORMAT_VOID: - *va_arg(ap, uint16*) = DATATYPE_VOID; - break; - } - break; - case TIFFTAG_SAMPLEFORMAT: - *va_arg(ap, uint16*) = td->td_sampleformat; - break; - case TIFFTAG_IMAGEDEPTH: - *va_arg(ap, uint32*) = td->td_imagedepth; - break; - case TIFFTAG_SUBIFD: - *va_arg(ap, uint16*) = td->td_nsubifd; - *va_arg(ap, uint32**) = td->td_subifd; - break; - case TIFFTAG_YCBCRPOSITIONING: - *va_arg(ap, uint16*) = td->td_ycbcrpositioning; - break; - case TIFFTAG_YCBCRSUBSAMPLING: - *va_arg(ap, uint16*) = td->td_ycbcrsubsampling[0]; - *va_arg(ap, uint16*) = td->td_ycbcrsubsampling[1]; - break; - case TIFFTAG_TRANSFERFUNCTION: - *va_arg(ap, uint16**) = td->td_transferfunction[0]; - if (td->td_samplesperpixel - td->td_extrasamples > 1) { - *va_arg(ap, uint16**) = td->td_transferfunction[1]; - *va_arg(ap, uint16**) = td->td_transferfunction[2]; - } - break; - case TIFFTAG_REFERENCEBLACKWHITE: - *va_arg(ap, float**) = td->td_refblackwhite; - break; - case TIFFTAG_INKNAMES: - *va_arg(ap, char**) = td->td_inknames; - break; - default: - { - const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY); - int i; - - /* - * This can happen if multiple images are open with different - * codecs which have private tags. The global tag information - * table may then have tags that are valid for one file but not - * the other. If the client tries to get a tag that is not valid - * for the image's codec then we'll arrive here. - */ - if ( fip == NULL || fip->field_bit != FIELD_CUSTOM ) - { - TIFFErrorExt(tif->tif_clientdata, "_TIFFVGetField", - "%s: Invalid %stag \"%s\" " - "(not supported by codec)", - tif->tif_name, - isPseudoTag(tag) ? "pseudo-" : "", - fip ? fip->field_name : "Unknown"); - ret_val = 0; - break; - } - - /* - * Do we have a custom value? - */ - ret_val = 0; - for (i = 0; i < td->td_customValueCount; i++) { - TIFFTagValue *tv = td->td_customValues + i; - - if (tv->info->field_tag != tag) - continue; - - if (fip->field_passcount) { - if (fip->field_readcount == TIFF_VARIABLE2) - *va_arg(ap, uint32*) = (uint32)tv->count; - else /* Assume TIFF_VARIABLE */ - *va_arg(ap, uint16*) = (uint16)tv->count; - *va_arg(ap, void **) = tv->value; - ret_val = 1; - } else { - if ((fip->field_type == TIFF_ASCII - || fip->field_readcount == TIFF_VARIABLE - || fip->field_readcount == TIFF_VARIABLE2 - || fip->field_readcount == TIFF_SPP - || tv->count > 1) - && fip->field_tag != TIFFTAG_PAGENUMBER - && fip->field_tag != TIFFTAG_HALFTONEHINTS - && fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING - && fip->field_tag != TIFFTAG_DOTRANGE) { - *va_arg(ap, void **) = tv->value; - ret_val = 1; - } else { - int j; - char *val = (char *)tv->value; - - for (j = 0; j < tv->count; - j++, val += _TIFFDataSize(tv->info->field_type)) { - switch (fip->field_type) { - case TIFF_BYTE: - case TIFF_UNDEFINED: - *va_arg(ap, uint8*) = - *(uint8 *)val; - ret_val = 1; - break; - case TIFF_SBYTE: - *va_arg(ap, int8*) = - *(int8 *)val; - ret_val = 1; - break; - case TIFF_SHORT: - *va_arg(ap, uint16*) = - *(uint16 *)val; - ret_val = 1; - break; - case TIFF_SSHORT: - *va_arg(ap, int16*) = - *(int16 *)val; - ret_val = 1; - break; - case TIFF_LONG: - case TIFF_IFD: - *va_arg(ap, uint32*) = - *(uint32 *)val; - ret_val = 1; - break; - case TIFF_SLONG: - *va_arg(ap, int32*) = - *(int32 *)val; - ret_val = 1; - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - case TIFF_FLOAT: - *va_arg(ap, float*) = - *(float *)val; - ret_val = 1; - break; - case TIFF_DOUBLE: - *va_arg(ap, double*) = - *(double *)val; - ret_val = 1; - break; - default: - ret_val = 0; - break; - } - } - } - } - break; - } - } - } - return(ret_val); -} - -/* - * Return the value of a field in the - * internal directory structure. - */ -int -TIFFGetField(TIFF* tif, ttag_t tag, ...) -{ - int status; - va_list ap; - - va_start(ap, tag); - status = TIFFVGetField(tif, tag, ap); - va_end(ap); - return (status); -} - -/* - * Like TIFFGetField, but taking a varargs - * parameter list. This routine is useful - * for building higher-level interfaces on - * top of the library. - */ -int -TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap) -{ - const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY); - return (fip && (isPseudoTag(tag) || TIFFFieldSet(tif, fip->field_bit)) ? - (*tif->tif_tagmethods.vgetfield)(tif, tag, ap) : 0); -} - -#define CleanupField(member) { \ - if (td->member) { \ - _TIFFfree(td->member); \ - td->member = 0; \ - } \ -} - -/* - * Release storage associated with a directory. - */ -void -TIFFFreeDirectory(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - int i; - - _TIFFmemset(td->td_fieldsset, 0, FIELD_SETLONGS); - CleanupField(td_colormap[0]); - CleanupField(td_colormap[1]); - CleanupField(td_colormap[2]); - CleanupField(td_sampleinfo); - CleanupField(td_subifd); - CleanupField(td_inknames); - CleanupField(td_refblackwhite); - CleanupField(td_transferfunction[0]); - CleanupField(td_transferfunction[1]); - CleanupField(td_transferfunction[2]); - CleanupField(td_stripoffset); - CleanupField(td_stripbytecount); - TIFFClrFieldBit(tif, FIELD_YCBCRSUBSAMPLING); - TIFFClrFieldBit(tif, FIELD_YCBCRPOSITIONING); - - /* Cleanup custom tag values */ - for ( i = 0; i < td->td_customValueCount; i++ ) { - if (td->td_customValues[i].value) - _TIFFfree(td->td_customValues[i].value); - } - - td->td_customValueCount = 0; - CleanupField(td_customValues); -} -#undef CleanupField - -/* - * Client Tag extension support (from Niles Ritter). - */ -static TIFFExtendProc _TIFFextender = (TIFFExtendProc) NULL; - -TIFFExtendProc -TIFFSetTagExtender(TIFFExtendProc extender) -{ - TIFFExtendProc prev = _TIFFextender; - _TIFFextender = extender; - return (prev); -} - -/* - * Setup for a new directory. Should we automatically call - * TIFFWriteDirectory() if the current one is dirty? - * - * The newly created directory will not exist on the file till - * TIFFWriteDirectory(), TIFFFlush() or TIFFClose() is called. - */ -int -TIFFCreateDirectory(TIFF* tif) -{ - TIFFDefaultDirectory(tif); - tif->tif_diroff = 0; - tif->tif_nextdiroff = 0; - tif->tif_curoff = 0; - tif->tif_row = (uint32) -1; - tif->tif_curstrip = (tstrip_t) -1; - - return 0; -} - -/* - * Setup a default directory structure. - */ -int -TIFFDefaultDirectory(TIFF* tif) -{ - register TIFFDirectory* td = &tif->tif_dir; - - size_t tiffFieldInfoCount; - const TIFFFieldInfo *tiffFieldInfo = - _TIFFGetFieldInfo(&tiffFieldInfoCount); - _TIFFSetupFieldInfo(tif, tiffFieldInfo, tiffFieldInfoCount); - - _TIFFmemset(td, 0, sizeof (*td)); - td->td_fillorder = FILLORDER_MSB2LSB; - td->td_bitspersample = 1; - td->td_threshholding = THRESHHOLD_BILEVEL; - td->td_orientation = ORIENTATION_TOPLEFT; - td->td_samplesperpixel = 1; - td->td_rowsperstrip = (uint32) -1; - td->td_tilewidth = 0; - td->td_tilelength = 0; - td->td_tiledepth = 1; - td->td_stripbytecountsorted = 1; /* Our own arrays always sorted. */ - td->td_resolutionunit = RESUNIT_INCH; - td->td_sampleformat = SAMPLEFORMAT_UINT; - td->td_imagedepth = 1; - td->td_ycbcrsubsampling[0] = 2; - td->td_ycbcrsubsampling[1] = 2; - td->td_ycbcrpositioning = YCBCRPOSITION_CENTERED; - tif->tif_postdecode = _TIFFNoPostDecode; - tif->tif_foundfield = NULL; - tif->tif_tagmethods.vsetfield = _TIFFVSetField; - tif->tif_tagmethods.vgetfield = _TIFFVGetField; - tif->tif_tagmethods.printdir = NULL; - /* - * Give client code a chance to install their own - * tag extensions & methods, prior to compression overloads. - */ - if (_TIFFextender) - (*_TIFFextender)(tif); - (void) TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); - /* - * NB: The directory is marked dirty as a result of setting - * up the default compression scheme. However, this really - * isn't correct -- we want TIFF_DIRTYDIRECT to be set only - * if the user does something. We could just do the setup - * by hand, but it seems better to use the normal mechanism - * (i.e. TIFFSetField). - */ - tif->tif_flags &= ~TIFF_DIRTYDIRECT; - - /* - * As per http://bugzilla.remotesensing.org/show_bug.cgi?id=19 - * we clear the ISTILED flag when setting up a new directory. - * Should we also be clearing stuff like INSUBIFD? - */ - tif->tif_flags &= ~TIFF_ISTILED; - /* - * Clear other directory-specific fields. - */ - tif->tif_tilesize = -1; - tif->tif_scanlinesize = -1; - - return (1); -} - -static int -TIFFAdvanceDirectory(TIFF* tif, uint32* nextdir, toff_t* off) -{ - static const char module[] = "TIFFAdvanceDirectory"; - uint16 dircount; - if (isMapped(tif)) - { - toff_t poff=*nextdir; - if (poff+sizeof(uint16) > tif->tif_size) - { - TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory count", - tif->tif_name); - return (0); - } - _TIFFmemcpy(&dircount, tif->tif_base+poff, sizeof (uint16)); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount); - poff+=sizeof (uint16)+dircount*sizeof (TIFFDirEntry); - if (off != NULL) - *off = poff; - if (((toff_t) (poff+sizeof (uint32))) > tif->tif_size) - { - TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory link", - tif->tif_name); - return (0); - } - _TIFFmemcpy(nextdir, tif->tif_base+poff, sizeof (uint32)); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(nextdir); - return (1); - } - else - { - if (!SeekOK(tif, *nextdir) || - !ReadOK(tif, &dircount, sizeof (uint16))) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory count", - tif->tif_name); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount); - if (off != NULL) - *off = TIFFSeekFile(tif, - dircount*sizeof (TIFFDirEntry), SEEK_CUR); - else - (void) TIFFSeekFile(tif, - dircount*sizeof (TIFFDirEntry), SEEK_CUR); - if (!ReadOK(tif, nextdir, sizeof (uint32))) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory link", - tif->tif_name); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(nextdir); - return (1); - } -} - -/* - * Count the number of directories in a file. - */ -tdir_t -TIFFNumberOfDirectories(TIFF* tif) -{ - toff_t nextdir = tif->tif_header.tiff_diroff; - tdir_t n = 0; - - while (nextdir != 0 && TIFFAdvanceDirectory(tif, &nextdir, NULL)) - n++; - return (n); -} - -/* - * Set the n-th directory as the current directory. - * NB: Directories are numbered starting at 0. - */ -int -TIFFSetDirectory(TIFF* tif, tdir_t dirn) -{ - toff_t nextdir; - tdir_t n; - - nextdir = tif->tif_header.tiff_diroff; - for (n = dirn; n > 0 && nextdir != 0; n--) - if (!TIFFAdvanceDirectory(tif, &nextdir, NULL)) - return (0); - tif->tif_nextdiroff = nextdir; - /* - * Set curdir to the actual directory index. The - * -1 is because TIFFReadDirectory will increment - * tif_curdir after successfully reading the directory. - */ - tif->tif_curdir = (dirn - n) - 1; - /* - * Reset tif_dirnumber counter and start new list of seen directories. - * We need this to prevent IFD loops. - */ - tif->tif_dirnumber = 0; - return (TIFFReadDirectory(tif)); -} - -/* - * Set the current directory to be the directory - * located at the specified file offset. This interface - * is used mainly to access directories linked with - * the SubIFD tag (e.g. thumbnail images). - */ -int -TIFFSetSubDirectory(TIFF* tif, uint32 diroff) -{ - tif->tif_nextdiroff = diroff; - /* - * Reset tif_dirnumber counter and start new list of seen directories. - * We need this to prevent IFD loops. - */ - tif->tif_dirnumber = 0; - return (TIFFReadDirectory(tif)); -} - -/* - * Return file offset of the current directory. - */ -uint32 -TIFFCurrentDirOffset(TIFF* tif) -{ - return (tif->tif_diroff); -} - -/* - * Return an indication of whether or not we are - * at the last directory in the file. - */ -int -TIFFLastDirectory(TIFF* tif) -{ - return (tif->tif_nextdiroff == 0); -} - -/* - * Unlink the specified directory from the directory chain. - */ -int -TIFFUnlinkDirectory(TIFF* tif, tdir_t dirn) -{ - static const char module[] = "TIFFUnlinkDirectory"; - toff_t nextdir; - toff_t off; - tdir_t n; - - if (tif->tif_mode == O_RDONLY) { - TIFFErrorExt(tif->tif_clientdata, module, - "Can not unlink directory in read-only file"); - return (0); - } - /* - * Go to the directory before the one we want - * to unlink and nab the offset of the link - * field we'll need to patch. - */ - nextdir = tif->tif_header.tiff_diroff; - off = sizeof (uint16) + sizeof (uint16); - for (n = dirn-1; n > 0; n--) { - if (nextdir == 0) { - TIFFErrorExt(tif->tif_clientdata, module, "Directory %d does not exist", dirn); - return (0); - } - if (!TIFFAdvanceDirectory(tif, &nextdir, &off)) - return (0); - } - /* - * Advance to the directory to be unlinked and fetch - * the offset of the directory that follows. - */ - if (!TIFFAdvanceDirectory(tif, &nextdir, NULL)) - return (0); - /* - * Go back and patch the link field of the preceding - * directory to point to the offset of the directory - * that follows. - */ - (void) TIFFSeekFile(tif, off, SEEK_SET); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&nextdir); - if (!WriteOK(tif, &nextdir, sizeof (uint32))) { - TIFFErrorExt(tif->tif_clientdata, module, "Error writing directory link"); - return (0); - } - /* - * Leave directory state setup safely. We don't have - * facilities for doing inserting and removing directories, - * so it's safest to just invalidate everything. This - * means that the caller can only append to the directory - * chain. - */ - (*tif->tif_cleanup)(tif); - if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) { - _TIFFfree(tif->tif_rawdata); - tif->tif_rawdata = NULL; - tif->tif_rawcc = 0; - } - tif->tif_flags &= ~(TIFF_BEENWRITING|TIFF_BUFFERSETUP|TIFF_POSTENCODE); - TIFFFreeDirectory(tif); - TIFFDefaultDirectory(tif); - tif->tif_diroff = 0; /* force link on next write */ - tif->tif_nextdiroff = 0; /* next write must be at end */ - tif->tif_curoff = 0; - tif->tif_row = (uint32) -1; - tif->tif_curstrip = (tstrip_t) -1; - return (1); -} - -/* [BFC] - * - * Author: Bruce Cameron - * - * Set a table of tags that are to be replaced during directory process by the - * 'IGNORE' state - or return TRUE/FALSE for the requested tag such that - * 'ReadDirectory' can use the stored information. - * - * FIXME: this is never used properly. Should be removed in the future. - */ -int -TIFFReassignTagToIgnore (enum TIFFIgnoreSense task, int TIFFtagID) -{ - static int TIFFignoretags [FIELD_LAST]; - static int tagcount = 0 ; - int i; /* Loop index */ - int j; /* Loop index */ - - switch (task) - { - case TIS_STORE: - if ( tagcount < (FIELD_LAST - 1) ) - { - for ( j = 0 ; j < tagcount ; ++j ) - { /* Do not add duplicate tag */ - if ( TIFFignoretags [j] == TIFFtagID ) - return (TRUE) ; - } - TIFFignoretags [tagcount++] = TIFFtagID ; - return (TRUE) ; - } - break ; - - case TIS_EXTRACT: - for ( i = 0 ; i < tagcount ; ++i ) - { - if ( TIFFignoretags [i] == TIFFtagID ) - return (TRUE) ; - } - break; - - case TIS_EMPTY: - tagcount = 0 ; /* Clear the list */ - return (TRUE) ; - - default: - break; - } - - return (FALSE); -} - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_dir.h b/plugins/AdvaImg/src/LibTIFF/tif_dir.h deleted file mode 100644 index f642834c44..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_dir.h +++ /dev/null @@ -1,211 +0,0 @@ -/* $Id: tif_dir.h,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFFDIR_ -#define _TIFFDIR_ -/* - * ``Library-private'' Directory-related Definitions. - */ - -/* - * Internal format of a TIFF directory entry. - */ -typedef struct { -#define FIELD_SETLONGS 4 - /* bit vector of fields that are set */ - unsigned long td_fieldsset[FIELD_SETLONGS]; - - uint32 td_imagewidth, td_imagelength, td_imagedepth; - uint32 td_tilewidth, td_tilelength, td_tiledepth; - uint32 td_subfiletype; - uint16 td_bitspersample; - uint16 td_sampleformat; - uint16 td_compression; - uint16 td_photometric; - uint16 td_threshholding; - uint16 td_fillorder; - uint16 td_orientation; - uint16 td_samplesperpixel; - uint32 td_rowsperstrip; - uint16 td_minsamplevalue, td_maxsamplevalue; - double td_sminsamplevalue, td_smaxsamplevalue; - float td_xresolution, td_yresolution; - uint16 td_resolutionunit; - uint16 td_planarconfig; - float td_xposition, td_yposition; - uint16 td_pagenumber[2]; - uint16* td_colormap[3]; - uint16 td_halftonehints[2]; - uint16 td_extrasamples; - uint16* td_sampleinfo; - /* even though the name is misleading, td_stripsperimage is the number - * of striles (=strips or tiles) per plane, and td_nstrips the total - * number of striles */ - tstrile_t td_stripsperimage; - tstrile_t td_nstrips; /* size of offset & bytecount arrays */ - toff_t* td_stripoffset; - toff_t* td_stripbytecount; /* FIXME: it should be tsize_t array */ - int td_stripbytecountsorted; /* is the bytecount array sorted ascending? */ - uint16 td_nsubifd; - uint32* td_subifd; - /* YCbCr parameters */ - uint16 td_ycbcrsubsampling[2]; - uint16 td_ycbcrpositioning; - /* Colorimetry parameters */ - float* td_refblackwhite; - uint16* td_transferfunction[3]; - /* CMYK parameters */ - int td_inknameslen; - char* td_inknames; - - int td_customValueCount; - TIFFTagValue *td_customValues; -} TIFFDirectory; - -/* - * Field flags used to indicate fields that have - * been set in a directory, and to reference fields - * when manipulating a directory. - */ - -/* - * FIELD_IGNORE is used to signify tags that are to - * be processed but otherwise ignored. This permits - * antiquated tags to be quietly read and discarded. - * Note that a bit *is* allocated for ignored tags; - * this is understood by the directory reading logic - * which uses this fact to avoid special-case handling - */ -#define FIELD_IGNORE 0 - -/* multi-item fields */ -#define FIELD_IMAGEDIMENSIONS 1 -#define FIELD_TILEDIMENSIONS 2 -#define FIELD_RESOLUTION 3 -#define FIELD_POSITION 4 - -/* single-item fields */ -#define FIELD_SUBFILETYPE 5 -#define FIELD_BITSPERSAMPLE 6 -#define FIELD_COMPRESSION 7 -#define FIELD_PHOTOMETRIC 8 -#define FIELD_THRESHHOLDING 9 -#define FIELD_FILLORDER 10 -#define FIELD_ORIENTATION 15 -#define FIELD_SAMPLESPERPIXEL 16 -#define FIELD_ROWSPERSTRIP 17 -#define FIELD_MINSAMPLEVALUE 18 -#define FIELD_MAXSAMPLEVALUE 19 -#define FIELD_PLANARCONFIG 20 -#define FIELD_RESOLUTIONUNIT 22 -#define FIELD_PAGENUMBER 23 -#define FIELD_STRIPBYTECOUNTS 24 -#define FIELD_STRIPOFFSETS 25 -#define FIELD_COLORMAP 26 -#define FIELD_EXTRASAMPLES 31 -#define FIELD_SAMPLEFORMAT 32 -#define FIELD_SMINSAMPLEVALUE 33 -#define FIELD_SMAXSAMPLEVALUE 34 -#define FIELD_IMAGEDEPTH 35 -#define FIELD_TILEDEPTH 36 -#define FIELD_HALFTONEHINTS 37 -#define FIELD_YCBCRSUBSAMPLING 39 -#define FIELD_YCBCRPOSITIONING 40 -#define FIELD_REFBLACKWHITE 41 -#define FIELD_TRANSFERFUNCTION 44 -#define FIELD_INKNAMES 46 -#define FIELD_SUBIFD 49 -/* FIELD_CUSTOM (see tiffio.h) 65 */ -/* end of support for well-known tags; codec-private tags follow */ -#define FIELD_CODEC 66 /* base of codec-private tags */ - - -/* - * Pseudo-tags don't normally need field bits since they - * are not written to an output file (by definition). - * The library also has express logic to always query a - * codec for a pseudo-tag so allocating a field bit for - * one is a waste. If codec wants to promote the notion - * of a pseudo-tag being ``set'' or ``unset'' then it can - * do using internal state flags without polluting the - * field bit space defined for real tags. - */ -#define FIELD_PSEUDO 0 - -#define FIELD_LAST (32*FIELD_SETLONGS-1) - -#define TIFFExtractData(tif, type, v) \ - ((uint32) ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \ - ((v) >> (tif)->tif_typeshift[type]) & (tif)->tif_typemask[type] : \ - (v) & (tif)->tif_typemask[type])) -#define TIFFInsertData(tif, type, v) \ - ((uint32) ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \ - ((v) & (tif)->tif_typemask[type]) << (tif)->tif_typeshift[type] : \ - (v) & (tif)->tif_typemask[type])) - - -#define BITn(n) (((unsigned long)1L)<<((n)&0x1f)) -#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n)/32]) -#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field)) -#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field)) -#define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field)) - -#define FieldSet(fields, f) (fields[(f)/32] & BITn(f)) -#define ResetFieldBit(fields, f) (fields[(f)/32] &= ~BITn(f)) - -#if defined(__cplusplus) -extern "C" { -#endif -extern const TIFFFieldInfo *_TIFFGetFieldInfo(size_t *); -extern const TIFFFieldInfo *_TIFFGetExifFieldInfo(size_t *); -extern void _TIFFSetupFieldInfo(TIFF*, const TIFFFieldInfo[], size_t); -extern int _TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], int); -extern void _TIFFPrintFieldInfo(TIFF*, FILE*); -extern TIFFDataType _TIFFSampleToTagType(TIFF*); -extern const TIFFFieldInfo* _TIFFFindOrRegisterFieldInfo( TIFF *tif, - ttag_t tag, - TIFFDataType dt ); -extern TIFFFieldInfo* _TIFFCreateAnonFieldInfo( TIFF *tif, ttag_t tag, - TIFFDataType dt ); - -#define _TIFFFindFieldInfo TIFFFindFieldInfo -#define _TIFFFindFieldInfoByName TIFFFindFieldInfoByName -#define _TIFFFieldWithTag TIFFFieldWithTag -#define _TIFFFieldWithName TIFFFieldWithName - -#if defined(__cplusplus) -} -#endif -#endif /* _TIFFDIR_ */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_dirinfo.c b/plugins/AdvaImg/src/LibTIFF/tif_dirinfo.c deleted file mode 100644 index 7b7507a8cb..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_dirinfo.c +++ /dev/null @@ -1,884 +0,0 @@ -/* $Id: tif_dirinfo.c,v 1.38 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Core Directory Tag Support. - */ -#include "tiffiop.h" -#include -#include - -/* - * NB: NB: THIS ARRAY IS ASSUMED TO BE SORTED BY TAG. - * If a tag can have both LONG and SHORT types then the LONG must be - * placed before the SHORT for writing to work properly. - * - * NOTE: The second field (field_readcount) and third field (field_writecount) - * sometimes use the values TIFF_VARIABLE (-1), TIFF_VARIABLE2 (-3) - * and TIFFTAG_SPP (-2). The macros should be used but would throw off - * the formatting of the code, so please interprete the -1, -2 and -3 - * values accordingly. - */ -static const TIFFFieldInfo -tiffFieldInfo[] = { - { TIFFTAG_SUBFILETYPE, 1, 1, TIFF_LONG, FIELD_SUBFILETYPE, - 1, 0, "SubfileType" }, -/* XXX SHORT for compatibility w/ old versions of the library */ - { TIFFTAG_SUBFILETYPE, 1, 1, TIFF_SHORT, FIELD_SUBFILETYPE, - 1, 0, "SubfileType" }, - { TIFFTAG_OSUBFILETYPE, 1, 1, TIFF_SHORT, FIELD_SUBFILETYPE, - 1, 0, "OldSubfileType" }, - { TIFFTAG_IMAGEWIDTH, 1, 1, TIFF_LONG, FIELD_IMAGEDIMENSIONS, - 0, 0, "ImageWidth" }, - { TIFFTAG_IMAGEWIDTH, 1, 1, TIFF_SHORT, FIELD_IMAGEDIMENSIONS, - 0, 0, "ImageWidth" }, - { TIFFTAG_IMAGELENGTH, 1, 1, TIFF_LONG, FIELD_IMAGEDIMENSIONS, - 1, 0, "ImageLength" }, - { TIFFTAG_IMAGELENGTH, 1, 1, TIFF_SHORT, FIELD_IMAGEDIMENSIONS, - 1, 0, "ImageLength" }, - { TIFFTAG_BITSPERSAMPLE, -1,-1, TIFF_SHORT, FIELD_BITSPERSAMPLE, - 0, 0, "BitsPerSample" }, -/* XXX LONG for compatibility with some broken TIFF writers */ - { TIFFTAG_BITSPERSAMPLE, -1,-1, TIFF_LONG, FIELD_BITSPERSAMPLE, - 0, 0, "BitsPerSample" }, - { TIFFTAG_COMPRESSION, -1, 1, TIFF_SHORT, FIELD_COMPRESSION, - 0, 0, "Compression" }, -/* XXX LONG for compatibility with some broken TIFF writers */ - { TIFFTAG_COMPRESSION, -1, 1, TIFF_LONG, FIELD_COMPRESSION, - 0, 0, "Compression" }, - { TIFFTAG_PHOTOMETRIC, 1, 1, TIFF_SHORT, FIELD_PHOTOMETRIC, - 0, 0, "PhotometricInterpretation" }, -/* XXX LONG for compatibility with some broken TIFF writers */ - { TIFFTAG_PHOTOMETRIC, 1, 1, TIFF_LONG, FIELD_PHOTOMETRIC, - 0, 0, "PhotometricInterpretation" }, - { TIFFTAG_THRESHHOLDING, 1, 1, TIFF_SHORT, FIELD_THRESHHOLDING, - 1, 0, "Threshholding" }, - { TIFFTAG_CELLWIDTH, 1, 1, TIFF_SHORT, FIELD_IGNORE, - 1, 0, "CellWidth" }, - { TIFFTAG_CELLLENGTH, 1, 1, TIFF_SHORT, FIELD_IGNORE, - 1, 0, "CellLength" }, - { TIFFTAG_FILLORDER, 1, 1, TIFF_SHORT, FIELD_FILLORDER, - 0, 0, "FillOrder" }, - { TIFFTAG_DOCUMENTNAME, -1,-1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "DocumentName" }, - { TIFFTAG_IMAGEDESCRIPTION, -1,-1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "ImageDescription" }, - { TIFFTAG_MAKE, -1,-1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "Make" }, - { TIFFTAG_MODEL, -1,-1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "Model" }, - { TIFFTAG_STRIPOFFSETS, -1,-1, TIFF_LONG, FIELD_STRIPOFFSETS, - 0, 0, "StripOffsets" }, - { TIFFTAG_STRIPOFFSETS, -1,-1, TIFF_SHORT, FIELD_STRIPOFFSETS, - 0, 0, "StripOffsets" }, - { TIFFTAG_ORIENTATION, 1, 1, TIFF_SHORT, FIELD_ORIENTATION, - 0, 0, "Orientation" }, - { TIFFTAG_SAMPLESPERPIXEL, 1, 1, TIFF_SHORT, FIELD_SAMPLESPERPIXEL, - 0, 0, "SamplesPerPixel" }, - { TIFFTAG_ROWSPERSTRIP, 1, 1, TIFF_LONG, FIELD_ROWSPERSTRIP, - 0, 0, "RowsPerStrip" }, - { TIFFTAG_ROWSPERSTRIP, 1, 1, TIFF_SHORT, FIELD_ROWSPERSTRIP, - 0, 0, "RowsPerStrip" }, - { TIFFTAG_STRIPBYTECOUNTS, -1,-1, TIFF_LONG, FIELD_STRIPBYTECOUNTS, - 0, 0, "StripByteCounts" }, - { TIFFTAG_STRIPBYTECOUNTS, -1,-1, TIFF_SHORT, FIELD_STRIPBYTECOUNTS, - 0, 0, "StripByteCounts" }, - { TIFFTAG_MINSAMPLEVALUE, -2,-1, TIFF_SHORT, FIELD_MINSAMPLEVALUE, - 1, 0, "MinSampleValue" }, - { TIFFTAG_MAXSAMPLEVALUE, -2,-1, TIFF_SHORT, FIELD_MAXSAMPLEVALUE, - 1, 0, "MaxSampleValue" }, - { TIFFTAG_XRESOLUTION, 1, 1, TIFF_RATIONAL, FIELD_RESOLUTION, - 1, 0, "XResolution" }, - { TIFFTAG_YRESOLUTION, 1, 1, TIFF_RATIONAL, FIELD_RESOLUTION, - 1, 0, "YResolution" }, - { TIFFTAG_PLANARCONFIG, 1, 1, TIFF_SHORT, FIELD_PLANARCONFIG, - 0, 0, "PlanarConfiguration" }, - { TIFFTAG_PAGENAME, -1,-1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "PageName" }, - { TIFFTAG_XPOSITION, 1, 1, TIFF_RATIONAL, FIELD_POSITION, - 1, 0, "XPosition" }, - { TIFFTAG_YPOSITION, 1, 1, TIFF_RATIONAL, FIELD_POSITION, - 1, 0, "YPosition" }, - { TIFFTAG_FREEOFFSETS, -1,-1, TIFF_LONG, FIELD_IGNORE, - 0, 0, "FreeOffsets" }, - { TIFFTAG_FREEBYTECOUNTS, -1,-1, TIFF_LONG, FIELD_IGNORE, - 0, 0, "FreeByteCounts" }, - { TIFFTAG_GRAYRESPONSEUNIT, 1, 1, TIFF_SHORT, FIELD_IGNORE, - 1, 0, "GrayResponseUnit" }, - { TIFFTAG_GRAYRESPONSECURVE,-1,-1, TIFF_SHORT, FIELD_IGNORE, - 1, 0, "GrayResponseCurve" }, - { TIFFTAG_RESOLUTIONUNIT, 1, 1, TIFF_SHORT, FIELD_RESOLUTIONUNIT, - 1, 0, "ResolutionUnit" }, - { TIFFTAG_PAGENUMBER, 2, 2, TIFF_SHORT, FIELD_PAGENUMBER, - 1, 0, "PageNumber" }, - { TIFFTAG_COLORRESPONSEUNIT, 1, 1, TIFF_SHORT, FIELD_IGNORE, - 1, 0, "ColorResponseUnit" }, - { TIFFTAG_TRANSFERFUNCTION, -1,-1, TIFF_SHORT, FIELD_TRANSFERFUNCTION, - 1, 0, "TransferFunction" }, - { TIFFTAG_SOFTWARE, -1,-1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "Software" }, - { TIFFTAG_DATETIME, 20,20, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "DateTime" }, - { TIFFTAG_ARTIST, -1,-1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "Artist" }, - { TIFFTAG_HOSTCOMPUTER, -1,-1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "HostComputer" }, - { TIFFTAG_WHITEPOINT, 2, 2, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "WhitePoint" }, - { TIFFTAG_PRIMARYCHROMATICITIES,6,6,TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "PrimaryChromaticities" }, - { TIFFTAG_COLORMAP, -1,-1, TIFF_SHORT, FIELD_COLORMAP, - 1, 0, "ColorMap" }, - { TIFFTAG_HALFTONEHINTS, 2, 2, TIFF_SHORT, FIELD_HALFTONEHINTS, - 1, 0, "HalftoneHints" }, - { TIFFTAG_TILEWIDTH, 1, 1, TIFF_LONG, FIELD_TILEDIMENSIONS, - 0, 0, "TileWidth" }, - { TIFFTAG_TILEWIDTH, 1, 1, TIFF_SHORT, FIELD_TILEDIMENSIONS, - 0, 0, "TileWidth" }, - { TIFFTAG_TILELENGTH, 1, 1, TIFF_LONG, FIELD_TILEDIMENSIONS, - 0, 0, "TileLength" }, - { TIFFTAG_TILELENGTH, 1, 1, TIFF_SHORT, FIELD_TILEDIMENSIONS, - 0, 0, "TileLength" }, - { TIFFTAG_TILEOFFSETS, -1, 1, TIFF_LONG, FIELD_STRIPOFFSETS, - 0, 0, "TileOffsets" }, - { TIFFTAG_TILEBYTECOUNTS, -1, 1, TIFF_LONG, FIELD_STRIPBYTECOUNTS, - 0, 0, "TileByteCounts" }, - { TIFFTAG_TILEBYTECOUNTS, -1, 1, TIFF_SHORT, FIELD_STRIPBYTECOUNTS, - 0, 0, "TileByteCounts" }, - { TIFFTAG_SUBIFD, -1,-1, TIFF_IFD, FIELD_SUBIFD, - 1, 1, "SubIFD" }, - { TIFFTAG_SUBIFD, -1,-1, TIFF_LONG, FIELD_SUBIFD, - 1, 1, "SubIFD" }, - { TIFFTAG_INKSET, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 0, 0, "InkSet" }, - { TIFFTAG_INKNAMES, -1,-1, TIFF_ASCII, FIELD_INKNAMES, - 1, 1, "InkNames" }, - { TIFFTAG_NUMBEROFINKS, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "NumberOfInks" }, - { TIFFTAG_DOTRANGE, 2, 2, TIFF_SHORT, FIELD_CUSTOM, - 0, 0, "DotRange" }, - { TIFFTAG_DOTRANGE, 2, 2, TIFF_BYTE, FIELD_CUSTOM, - 0, 0, "DotRange" }, - { TIFFTAG_TARGETPRINTER, -1,-1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "TargetPrinter" }, - { TIFFTAG_EXTRASAMPLES, -1,-1, TIFF_SHORT, FIELD_EXTRASAMPLES, - 0, 1, "ExtraSamples" }, -/* XXX for bogus Adobe Photoshop v2.5 files */ - { TIFFTAG_EXTRASAMPLES, -1,-1, TIFF_BYTE, FIELD_EXTRASAMPLES, - 0, 1, "ExtraSamples" }, - { TIFFTAG_SAMPLEFORMAT, -1,-1, TIFF_SHORT, FIELD_SAMPLEFORMAT, - 0, 0, "SampleFormat" }, - { TIFFTAG_SMINSAMPLEVALUE, -2,-1, TIFF_ANY, FIELD_SMINSAMPLEVALUE, - 1, 0, "SMinSampleValue" }, - { TIFFTAG_SMAXSAMPLEVALUE, -2,-1, TIFF_ANY, FIELD_SMAXSAMPLEVALUE, - 1, 0, "SMaxSampleValue" }, - { TIFFTAG_CLIPPATH, -1, -3, TIFF_BYTE, FIELD_CUSTOM, - 0, 1, "ClipPath" }, - { TIFFTAG_XCLIPPATHUNITS, 1, 1, TIFF_SLONG, FIELD_CUSTOM, - 0, 0, "XClipPathUnits" }, - { TIFFTAG_XCLIPPATHUNITS, 1, 1, TIFF_SSHORT, FIELD_CUSTOM, - 0, 0, "XClipPathUnits" }, - { TIFFTAG_XCLIPPATHUNITS, 1, 1, TIFF_SBYTE, FIELD_CUSTOM, - 0, 0, "XClipPathUnits" }, - { TIFFTAG_YCLIPPATHUNITS, 1, 1, TIFF_SLONG, FIELD_CUSTOM, - 0, 0, "YClipPathUnits" }, - { TIFFTAG_YCLIPPATHUNITS, 1, 1, TIFF_SSHORT, FIELD_CUSTOM, - 0, 0, "YClipPathUnits" }, - { TIFFTAG_YCLIPPATHUNITS, 1, 1, TIFF_SBYTE, FIELD_CUSTOM, - 0, 0, "YClipPathUnits" }, - { TIFFTAG_YCBCRCOEFFICIENTS, 3, 3, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "YCbCrCoefficients" }, - { TIFFTAG_YCBCRSUBSAMPLING, 2, 2, TIFF_SHORT, FIELD_YCBCRSUBSAMPLING, - 0, 0, "YCbCrSubsampling" }, - { TIFFTAG_YCBCRPOSITIONING, 1, 1, TIFF_SHORT, FIELD_YCBCRPOSITIONING, - 0, 0, "YCbCrPositioning" }, - { TIFFTAG_REFERENCEBLACKWHITE, 6, 6, TIFF_RATIONAL, FIELD_REFBLACKWHITE, - 1, 0, "ReferenceBlackWhite" }, -/* XXX temporarily accept LONG for backwards compatibility */ - { TIFFTAG_REFERENCEBLACKWHITE, 6, 6, TIFF_LONG, FIELD_REFBLACKWHITE, - 1, 0, "ReferenceBlackWhite" }, - { TIFFTAG_XMLPACKET, -3,-3, TIFF_BYTE, FIELD_CUSTOM, - 0, 1, "XMLPacket" }, -/* begin SGI tags */ - { TIFFTAG_MATTEING, 1, 1, TIFF_SHORT, FIELD_EXTRASAMPLES, - 0, 0, "Matteing" }, - { TIFFTAG_DATATYPE, -2,-1, TIFF_SHORT, FIELD_SAMPLEFORMAT, - 0, 0, "DataType" }, - { TIFFTAG_IMAGEDEPTH, 1, 1, TIFF_LONG, FIELD_IMAGEDEPTH, - 0, 0, "ImageDepth" }, - { TIFFTAG_IMAGEDEPTH, 1, 1, TIFF_SHORT, FIELD_IMAGEDEPTH, - 0, 0, "ImageDepth" }, - { TIFFTAG_TILEDEPTH, 1, 1, TIFF_LONG, FIELD_TILEDEPTH, - 0, 0, "TileDepth" }, - { TIFFTAG_TILEDEPTH, 1, 1, TIFF_SHORT, FIELD_TILEDEPTH, - 0, 0, "TileDepth" }, -/* end SGI tags */ -/* begin Pixar tags */ - { TIFFTAG_PIXAR_IMAGEFULLWIDTH, 1, 1, TIFF_LONG, FIELD_CUSTOM, - 1, 0, "ImageFullWidth" }, - { TIFFTAG_PIXAR_IMAGEFULLLENGTH, 1, 1, TIFF_LONG, FIELD_CUSTOM, - 1, 0, "ImageFullLength" }, - { TIFFTAG_PIXAR_TEXTUREFORMAT, -1, -1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "TextureFormat" }, - { TIFFTAG_PIXAR_WRAPMODES, -1, -1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "TextureWrapModes" }, - { TIFFTAG_PIXAR_FOVCOT, 1, 1, TIFF_FLOAT, FIELD_CUSTOM, - 1, 0, "FieldOfViewCotangent" }, - { TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN, 16,16, TIFF_FLOAT, - FIELD_CUSTOM, 1, 0, "MatrixWorldToScreen" }, - { TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA, 16,16, TIFF_FLOAT, - FIELD_CUSTOM, 1, 0, "MatrixWorldToCamera" }, - { TIFFTAG_COPYRIGHT, -1, -1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "Copyright" }, -/* end Pixar tags */ - { TIFFTAG_RICHTIFFIPTC, -3, -3, TIFF_LONG, FIELD_CUSTOM, - 0, 1, "RichTIFFIPTC" }, - { TIFFTAG_PHOTOSHOP, -3, -3, TIFF_BYTE, FIELD_CUSTOM, - 0, 1, "Photoshop" }, - { TIFFTAG_EXIFIFD, 1, 1, TIFF_LONG, FIELD_CUSTOM, - 0, 0, "EXIFIFDOffset" }, - { TIFFTAG_ICCPROFILE, -3, -3, TIFF_UNDEFINED, FIELD_CUSTOM, - 0, 1, "ICC Profile" }, - { TIFFTAG_GPSIFD, 1, 1, TIFF_LONG, FIELD_CUSTOM, - 0, 0, "GPSIFDOffset" }, - { TIFFTAG_STONITS, 1, 1, TIFF_DOUBLE, FIELD_CUSTOM, - 0, 0, "StoNits" }, - { TIFFTAG_INTEROPERABILITYIFD, 1, 1, TIFF_LONG, FIELD_CUSTOM, - 0, 0, "InteroperabilityIFDOffset" }, -/* begin DNG tags */ - { TIFFTAG_DNGVERSION, 4, 4, TIFF_BYTE, FIELD_CUSTOM, - 0, 0, "DNGVersion" }, - { TIFFTAG_DNGBACKWARDVERSION, 4, 4, TIFF_BYTE, FIELD_CUSTOM, - 0, 0, "DNGBackwardVersion" }, - { TIFFTAG_UNIQUECAMERAMODEL, -1, -1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "UniqueCameraModel" }, - { TIFFTAG_LOCALIZEDCAMERAMODEL, -1, -1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "LocalizedCameraModel" }, - { TIFFTAG_LOCALIZEDCAMERAMODEL, -1, -1, TIFF_BYTE, FIELD_CUSTOM, - 1, 1, "LocalizedCameraModel" }, - { TIFFTAG_CFAPLANECOLOR, -1, -1, TIFF_BYTE, FIELD_CUSTOM, - 0, 1, "CFAPlaneColor" }, - { TIFFTAG_CFALAYOUT, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 0, 0, "CFALayout" }, - { TIFFTAG_LINEARIZATIONTABLE, -1, -1, TIFF_SHORT, FIELD_CUSTOM, - 0, 1, "LinearizationTable" }, - { TIFFTAG_BLACKLEVELREPEATDIM, 2, 2, TIFF_SHORT, FIELD_CUSTOM, - 0, 0, "BlackLevelRepeatDim" }, - { TIFFTAG_BLACKLEVEL, -1, -1, TIFF_LONG, FIELD_CUSTOM, - 0, 1, "BlackLevel" }, - { TIFFTAG_BLACKLEVEL, -1, -1, TIFF_SHORT, FIELD_CUSTOM, - 0, 1, "BlackLevel" }, - { TIFFTAG_BLACKLEVEL, -1, -1, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 1, "BlackLevel" }, - { TIFFTAG_BLACKLEVELDELTAH, -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, - 0, 1, "BlackLevelDeltaH" }, - { TIFFTAG_BLACKLEVELDELTAV, -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, - 0, 1, "BlackLevelDeltaV" }, - { TIFFTAG_WHITELEVEL, -2, -2, TIFF_LONG, FIELD_CUSTOM, - 0, 0, "WhiteLevel" }, - { TIFFTAG_WHITELEVEL, -2, -2, TIFF_SHORT, FIELD_CUSTOM, - 0, 0, "WhiteLevel" }, - { TIFFTAG_DEFAULTSCALE, 2, 2, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "DefaultScale" }, - { TIFFTAG_BESTQUALITYSCALE, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "BestQualityScale" }, - { TIFFTAG_DEFAULTCROPORIGIN, 2, 2, TIFF_LONG, FIELD_CUSTOM, - 0, 0, "DefaultCropOrigin" }, - { TIFFTAG_DEFAULTCROPORIGIN, 2, 2, TIFF_SHORT, FIELD_CUSTOM, - 0, 0, "DefaultCropOrigin" }, - { TIFFTAG_DEFAULTCROPORIGIN, 2, 2, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "DefaultCropOrigin" }, - { TIFFTAG_DEFAULTCROPSIZE, 2, 2, TIFF_LONG, FIELD_CUSTOM, - 0, 0, "DefaultCropSize" }, - { TIFFTAG_DEFAULTCROPSIZE, 2, 2, TIFF_SHORT, FIELD_CUSTOM, - 0, 0, "DefaultCropSize" }, - { TIFFTAG_DEFAULTCROPSIZE, 2, 2, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "DefaultCropSize" }, - { TIFFTAG_COLORMATRIX1, -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, - 0, 1, "ColorMatrix1" }, - { TIFFTAG_COLORMATRIX2, -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, - 0, 1, "ColorMatrix2" }, - { TIFFTAG_CAMERACALIBRATION1, -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, - 0, 1, "CameraCalibration1" }, - { TIFFTAG_CAMERACALIBRATION2, -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, - 0, 1, "CameraCalibration2" }, - { TIFFTAG_REDUCTIONMATRIX1, -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, - 0, 1, "ReductionMatrix1" }, - { TIFFTAG_REDUCTIONMATRIX2, -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, - 0, 1, "ReductionMatrix2" }, - { TIFFTAG_ANALOGBALANCE, -1, -1, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 1, "AnalogBalance" }, - { TIFFTAG_ASSHOTNEUTRAL, -1, -1, TIFF_SHORT, FIELD_CUSTOM, - 0, 1, "AsShotNeutral" }, - { TIFFTAG_ASSHOTNEUTRAL, -1, -1, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 1, "AsShotNeutral" }, - { TIFFTAG_ASSHOTWHITEXY, 2, 2, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "AsShotWhiteXY" }, - { TIFFTAG_BASELINEEXPOSURE, 1, 1, TIFF_SRATIONAL, FIELD_CUSTOM, - 0, 0, "BaselineExposure" }, - { TIFFTAG_BASELINENOISE, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "BaselineNoise" }, - { TIFFTAG_BASELINESHARPNESS, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "BaselineSharpness" }, - { TIFFTAG_BAYERGREENSPLIT, 1, 1, TIFF_LONG, FIELD_CUSTOM, - 0, 0, "BayerGreenSplit" }, - { TIFFTAG_LINEARRESPONSELIMIT, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "LinearResponseLimit" }, - { TIFFTAG_CAMERASERIALNUMBER, -1, -1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "CameraSerialNumber" }, - { TIFFTAG_LENSINFO, 4, 4, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "LensInfo" }, - { TIFFTAG_CHROMABLURRADIUS, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "ChromaBlurRadius" }, - { TIFFTAG_ANTIALIASSTRENGTH, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "AntiAliasStrength" }, - { TIFFTAG_SHADOWSCALE, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "ShadowScale" }, - { TIFFTAG_DNGPRIVATEDATA, -1, -1, TIFF_BYTE, FIELD_CUSTOM, - 0, 1, "DNGPrivateData" }, - { TIFFTAG_MAKERNOTESAFETY, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 0, 0, "MakerNoteSafety" }, - { TIFFTAG_CALIBRATIONILLUMINANT1, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 0, 0, "CalibrationIlluminant1" }, - { TIFFTAG_CALIBRATIONILLUMINANT2, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 0, 0, "CalibrationIlluminant2" }, - { TIFFTAG_RAWDATAUNIQUEID, 16, 16, TIFF_BYTE, FIELD_CUSTOM, - 0, 0, "RawDataUniqueID" }, - { TIFFTAG_ORIGINALRAWFILENAME, -1, -1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "OriginalRawFileName" }, - { TIFFTAG_ORIGINALRAWFILENAME, -1, -1, TIFF_BYTE, FIELD_CUSTOM, - 1, 1, "OriginalRawFileName" }, - { TIFFTAG_ORIGINALRAWFILEDATA, -1, -1, TIFF_UNDEFINED, FIELD_CUSTOM, - 0, 1, "OriginalRawFileData" }, - { TIFFTAG_ACTIVEAREA, 4, 4, TIFF_LONG, FIELD_CUSTOM, - 0, 0, "ActiveArea" }, - { TIFFTAG_ACTIVEAREA, 4, 4, TIFF_SHORT, FIELD_CUSTOM, - 0, 0, "ActiveArea" }, - { TIFFTAG_MASKEDAREAS, -1, -1, TIFF_LONG, FIELD_CUSTOM, - 0, 1, "MaskedAreas" }, - { TIFFTAG_ASSHOTICCPROFILE, -1, -1, TIFF_UNDEFINED, FIELD_CUSTOM, - 0, 1, "AsShotICCProfile" }, - { TIFFTAG_ASSHOTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, - 0, 1, "AsShotPreProfileMatrix" }, - { TIFFTAG_CURRENTICCPROFILE, -1, -1, TIFF_UNDEFINED, FIELD_CUSTOM, - 0, 1, "CurrentICCProfile" }, - { TIFFTAG_CURRENTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, - 0, 1, "CurrentPreProfileMatrix" }, -/* end DNG tags */ -}; - -static const TIFFFieldInfo -exifFieldInfo[] = { - { EXIFTAG_EXPOSURETIME, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "ExposureTime" }, - { EXIFTAG_FNUMBER, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "FNumber" }, - { EXIFTAG_EXPOSUREPROGRAM, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "ExposureProgram" }, - { EXIFTAG_SPECTRALSENSITIVITY, -1, -1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "SpectralSensitivity" }, - { EXIFTAG_ISOSPEEDRATINGS, -1, -1, TIFF_SHORT, FIELD_CUSTOM, - 1, 1, "ISOSpeedRatings" }, - { EXIFTAG_OECF, -1, -1, TIFF_UNDEFINED, FIELD_CUSTOM, - 1, 1, "OptoelectricConversionFactor" }, - { EXIFTAG_EXIFVERSION, 4, 4, TIFF_UNDEFINED, FIELD_CUSTOM, - 1, 0, "ExifVersion" }, - { EXIFTAG_DATETIMEORIGINAL, 20, 20, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "DateTimeOriginal" }, - { EXIFTAG_DATETIMEDIGITIZED, 20, 20, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "DateTimeDigitized" }, - { EXIFTAG_COMPONENTSCONFIGURATION, 4, 4, TIFF_UNDEFINED, FIELD_CUSTOM, - 1, 0, "ComponentsConfiguration" }, - { EXIFTAG_COMPRESSEDBITSPERPIXEL, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "CompressedBitsPerPixel" }, - { EXIFTAG_SHUTTERSPEEDVALUE, 1, 1, TIFF_SRATIONAL, FIELD_CUSTOM, - 1, 0, "ShutterSpeedValue" }, - { EXIFTAG_APERTUREVALUE, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "ApertureValue" }, - { EXIFTAG_BRIGHTNESSVALUE, 1, 1, TIFF_SRATIONAL, FIELD_CUSTOM, - 1, 0, "BrightnessValue" }, - { EXIFTAG_EXPOSUREBIASVALUE, 1, 1, TIFF_SRATIONAL, FIELD_CUSTOM, - 1, 0, "ExposureBiasValue" }, - { EXIFTAG_MAXAPERTUREVALUE, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "MaxApertureValue" }, - { EXIFTAG_SUBJECTDISTANCE, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "SubjectDistance" }, - { EXIFTAG_METERINGMODE, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "MeteringMode" }, - { EXIFTAG_LIGHTSOURCE, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "LightSource" }, - { EXIFTAG_FLASH, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "Flash" }, - { EXIFTAG_FOCALLENGTH, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "FocalLength" }, - { EXIFTAG_SUBJECTAREA, -1, -1, TIFF_SHORT, FIELD_CUSTOM, - 1, 1, "SubjectArea" }, - { EXIFTAG_MAKERNOTE, -1, -1, TIFF_UNDEFINED, FIELD_CUSTOM, - 1, 1, "MakerNote" }, - { EXIFTAG_USERCOMMENT, -1, -1, TIFF_UNDEFINED, FIELD_CUSTOM, - 1, 1, "UserComment" }, - { EXIFTAG_SUBSECTIME, -1, -1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "SubSecTime" }, - { EXIFTAG_SUBSECTIMEORIGINAL, -1, -1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "SubSecTimeOriginal" }, - { EXIFTAG_SUBSECTIMEDIGITIZED,-1, -1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "SubSecTimeDigitized" }, - { EXIFTAG_FLASHPIXVERSION, 4, 4, TIFF_UNDEFINED, FIELD_CUSTOM, - 1, 0, "FlashpixVersion" }, - { EXIFTAG_COLORSPACE, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "ColorSpace" }, - { EXIFTAG_PIXELXDIMENSION, 1, 1, TIFF_LONG, FIELD_CUSTOM, - 1, 0, "PixelXDimension" }, - { EXIFTAG_PIXELXDIMENSION, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "PixelXDimension" }, - { EXIFTAG_PIXELYDIMENSION, 1, 1, TIFF_LONG, FIELD_CUSTOM, - 1, 0, "PixelYDimension" }, - { EXIFTAG_PIXELYDIMENSION, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "PixelYDimension" }, - { EXIFTAG_RELATEDSOUNDFILE, 13, 13, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "RelatedSoundFile" }, - { EXIFTAG_FLASHENERGY, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "FlashEnergy" }, - { EXIFTAG_SPATIALFREQUENCYRESPONSE, -1, -1, TIFF_UNDEFINED, FIELD_CUSTOM, - 1, 1, "SpatialFrequencyResponse" }, - { EXIFTAG_FOCALPLANEXRESOLUTION, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "FocalPlaneXResolution" }, - { EXIFTAG_FOCALPLANEYRESOLUTION, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "FocalPlaneYResolution" }, - { EXIFTAG_FOCALPLANERESOLUTIONUNIT, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "FocalPlaneResolutionUnit" }, - { EXIFTAG_SUBJECTLOCATION, 2, 2, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "SubjectLocation" }, - { EXIFTAG_EXPOSUREINDEX, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "ExposureIndex" }, - { EXIFTAG_SENSINGMETHOD, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "SensingMethod" }, - { EXIFTAG_FILESOURCE, 1, 1, TIFF_UNDEFINED, FIELD_CUSTOM, - 1, 0, "FileSource" }, - { EXIFTAG_SCENETYPE, 1, 1, TIFF_UNDEFINED, FIELD_CUSTOM, - 1, 0, "SceneType" }, - { EXIFTAG_CFAPATTERN, -1, -1, TIFF_UNDEFINED, FIELD_CUSTOM, - 1, 1, "CFAPattern" }, - { EXIFTAG_CUSTOMRENDERED, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "CustomRendered" }, - { EXIFTAG_EXPOSUREMODE, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "ExposureMode" }, - { EXIFTAG_WHITEBALANCE, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "WhiteBalance" }, - { EXIFTAG_DIGITALZOOMRATIO, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "DigitalZoomRatio" }, - { EXIFTAG_FOCALLENGTHIN35MMFILM, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "FocalLengthIn35mmFilm" }, - { EXIFTAG_SCENECAPTURETYPE, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "SceneCaptureType" }, - { EXIFTAG_GAINCONTROL, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "GainControl" }, - { EXIFTAG_CONTRAST, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "Contrast" }, - { EXIFTAG_SATURATION, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "Saturation" }, - { EXIFTAG_SHARPNESS, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "Sharpness" }, - { EXIFTAG_DEVICESETTINGDESCRIPTION, -1, -1, TIFF_UNDEFINED, FIELD_CUSTOM, - 1, 1, "DeviceSettingDescription" }, - { EXIFTAG_SUBJECTDISTANCERANGE, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "SubjectDistanceRange" }, - { EXIFTAG_IMAGEUNIQUEID, 33, 33, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "ImageUniqueID" } -}; - -const TIFFFieldInfo * -_TIFFGetFieldInfo(size_t *size) -{ - *size = TIFFArrayCount(tiffFieldInfo); - return tiffFieldInfo; -} - -const TIFFFieldInfo * -_TIFFGetExifFieldInfo(size_t *size) -{ - *size = TIFFArrayCount(exifFieldInfo); - return exifFieldInfo; -} - -void -_TIFFSetupFieldInfo(TIFF* tif, const TIFFFieldInfo info[], size_t n) -{ - if (tif->tif_fieldinfo) { - size_t i; - - for (i = 0; i < tif->tif_nfields; i++) - { - TIFFFieldInfo *fld = tif->tif_fieldinfo[i]; - if (fld->field_bit == FIELD_CUSTOM && - strncmp("Tag ", fld->field_name, 4) == 0) { - _TIFFfree(fld->field_name); - _TIFFfree(fld); - } - } - - _TIFFfree(tif->tif_fieldinfo); - tif->tif_nfields = 0; - } - if (!_TIFFMergeFieldInfo(tif, info, n)) - { - TIFFErrorExt(tif->tif_clientdata, "_TIFFSetupFieldInfo", - "Setting up field info failed"); - } -} - -static int -tagCompare(const void* a, const void* b) -{ - const TIFFFieldInfo* ta = *(const TIFFFieldInfo**) a; - const TIFFFieldInfo* tb = *(const TIFFFieldInfo**) b; - /* NB: be careful of return values for 16-bit platforms */ - if (ta->field_tag != tb->field_tag) - return (int)ta->field_tag - (int)tb->field_tag; - else - return (ta->field_type == TIFF_ANY) ? - 0 : ((int)tb->field_type - (int)ta->field_type); -} - -static int -tagNameCompare(const void* a, const void* b) -{ - const TIFFFieldInfo* ta = *(const TIFFFieldInfo**) a; - const TIFFFieldInfo* tb = *(const TIFFFieldInfo**) b; - int ret = strcmp(ta->field_name, tb->field_name); - - if (ret) - return ret; - else - return (ta->field_type == TIFF_ANY) ? - 0 : ((int)tb->field_type - (int)ta->field_type); -} - -void -TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], int n) -{ - if (_TIFFMergeFieldInfo(tif, info, n) < 0) - { - TIFFErrorExt(tif->tif_clientdata, "TIFFMergeFieldInfo", - "Merging block of %d fields failed", n); - } -} - -int -_TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], int n) -{ - static const char module[] = "_TIFFMergeFieldInfo"; - static const char reason[] = "for field info array"; - TIFFFieldInfo** tp; - int i; - - tif->tif_foundfield = NULL; - - if (tif->tif_nfields > 0) { - tif->tif_fieldinfo = (TIFFFieldInfo**) - _TIFFCheckRealloc(tif, tif->tif_fieldinfo, - (tif->tif_nfields + n), - sizeof (TIFFFieldInfo*), reason); - } else { - tif->tif_fieldinfo = (TIFFFieldInfo**) - _TIFFCheckMalloc(tif, n, sizeof (TIFFFieldInfo*), - reason); - } - if (!tif->tif_fieldinfo) { - TIFFErrorExt(tif->tif_clientdata, module, - "Failed to allocate field info array"); - return 0; - } - tp = tif->tif_fieldinfo + tif->tif_nfields; - for (i = 0; i < n; i++) - { - const TIFFFieldInfo *fip = - _TIFFFindFieldInfo(tif, info[i].field_tag, info[i].field_type); - - /* only add definitions that aren't already present */ - if (!fip) { - *tp++ = (TIFFFieldInfo*) (info + i); - tif->tif_nfields++; - } - } - - /* Sort the field info by tag number */ - qsort(tif->tif_fieldinfo, tif->tif_nfields, - sizeof (TIFFFieldInfo*), tagCompare); - - return n; -} - -void -_TIFFPrintFieldInfo(TIFF* tif, FILE* fd) -{ - size_t i; - - fprintf(fd, "%s: \n", tif->tif_name); - for (i = 0; i < tif->tif_nfields; i++) { - const TIFFFieldInfo* fip = tif->tif_fieldinfo[i]; - fprintf(fd, "field[%2d] %5lu, %2d, %2d, %d, %2d, %5s, %5s, %s\n" - , (int)i - , (unsigned long) fip->field_tag - , fip->field_readcount, fip->field_writecount - , fip->field_type - , fip->field_bit - , fip->field_oktochange ? "TRUE" : "FALSE" - , fip->field_passcount ? "TRUE" : "FALSE" - , fip->field_name - ); - } -} - -/* - * Return size of TIFFDataType in bytes - */ -int -TIFFDataWidth(TIFFDataType type) -{ - switch(type) - { - case 0: /* nothing */ - case 1: /* TIFF_BYTE */ - case 2: /* TIFF_ASCII */ - case 6: /* TIFF_SBYTE */ - case 7: /* TIFF_UNDEFINED */ - return 1; - case 3: /* TIFF_SHORT */ - case 8: /* TIFF_SSHORT */ - return 2; - case 4: /* TIFF_LONG */ - case 9: /* TIFF_SLONG */ - case 11: /* TIFF_FLOAT */ - case 13: /* TIFF_IFD */ - return 4; - case 5: /* TIFF_RATIONAL */ - case 10: /* TIFF_SRATIONAL */ - case 12: /* TIFF_DOUBLE */ - return 8; - default: - return 0; /* will return 0 for unknown types */ - } -} - -/* - * Return size of TIFFDataType in bytes. - * - * XXX: We need a separate function to determine the space needed - * to store the value. For TIFF_RATIONAL values TIFFDataWidth() returns 8, - * but we use 4-byte float to represent rationals. - */ -int -_TIFFDataSize(TIFFDataType type) -{ - switch (type) { - case TIFF_BYTE: - case TIFF_SBYTE: - case TIFF_ASCII: - case TIFF_UNDEFINED: - return 1; - case TIFF_SHORT: - case TIFF_SSHORT: - return 2; - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_FLOAT: - case TIFF_IFD: - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - return 4; - case TIFF_DOUBLE: - return 8; - default: - return 0; - } -} - -/* - * Return nearest TIFFDataType to the sample type of an image. - */ -TIFFDataType -_TIFFSampleToTagType(TIFF* tif) -{ - uint32 bps = TIFFhowmany8(tif->tif_dir.td_bitspersample); - - switch (tif->tif_dir.td_sampleformat) { - case SAMPLEFORMAT_IEEEFP: - return (bps == 4 ? TIFF_FLOAT : TIFF_DOUBLE); - case SAMPLEFORMAT_INT: - return (bps <= 1 ? TIFF_SBYTE : - bps <= 2 ? TIFF_SSHORT : TIFF_SLONG); - case SAMPLEFORMAT_UINT: - return (bps <= 1 ? TIFF_BYTE : - bps <= 2 ? TIFF_SHORT : TIFF_LONG); - case SAMPLEFORMAT_VOID: - return (TIFF_UNDEFINED); - } - /*NOTREACHED*/ - return (TIFF_UNDEFINED); -} - -const TIFFFieldInfo* -_TIFFFindFieldInfo(TIFF* tif, ttag_t tag, TIFFDataType dt) -{ - TIFFFieldInfo key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0}; - TIFFFieldInfo* pkey = &key; - const TIFFFieldInfo **ret; - - if (tif->tif_foundfield && tif->tif_foundfield->field_tag == tag && - (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type)) - return tif->tif_foundfield; - - /* If we are invoked with no field information, then just return. */ - if ( !tif->tif_fieldinfo ) { - return NULL; - } - - /* NB: use sorted search (e.g. binary search) */ - key.field_tag = tag; - key.field_type = dt; - - ret = (const TIFFFieldInfo **) bsearch(&pkey, - tif->tif_fieldinfo, - tif->tif_nfields, - sizeof(TIFFFieldInfo *), - tagCompare); - return tif->tif_foundfield = (ret ? *ret : NULL); -} - -const TIFFFieldInfo* -_TIFFFindFieldInfoByName(TIFF* tif, const char *field_name, TIFFDataType dt) -{ - TIFFFieldInfo key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0}; - TIFFFieldInfo* pkey = &key; - const TIFFFieldInfo **ret; - - if (tif->tif_foundfield - && streq(tif->tif_foundfield->field_name, field_name) - && (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type)) - return (tif->tif_foundfield); - - /* If we are invoked with no field information, then just return. */ - if ( !tif->tif_fieldinfo ) { - return NULL; - } - - /* NB: use sorted search (e.g. binary search) */ - key.field_name = (char *)field_name; - key.field_type = dt; - - ret = (const TIFFFieldInfo **) lfind(&pkey, - tif->tif_fieldinfo, - &tif->tif_nfields, - sizeof(TIFFFieldInfo *), - tagNameCompare); - return tif->tif_foundfield = (ret ? *ret : NULL); -} - -const TIFFFieldInfo* -_TIFFFieldWithTag(TIFF* tif, ttag_t tag) -{ - const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY); - if (!fip) { - TIFFErrorExt(tif->tif_clientdata, "TIFFFieldWithTag", - "Internal error, unknown tag 0x%x", - (unsigned int) tag); - } - return (fip); -} - -const TIFFFieldInfo* -_TIFFFieldWithName(TIFF* tif, const char *field_name) -{ - const TIFFFieldInfo* fip = - _TIFFFindFieldInfoByName(tif, field_name, TIFF_ANY); - if (!fip) { - TIFFErrorExt(tif->tif_clientdata, "TIFFFieldWithName", - "Internal error, unknown tag %s", field_name); - } - return (fip); -} - -const TIFFFieldInfo* -_TIFFFindOrRegisterFieldInfo( TIFF *tif, ttag_t tag, TIFFDataType dt ) - -{ - const TIFFFieldInfo *fld; - - fld = _TIFFFindFieldInfo( tif, tag, dt ); - if ( fld == NULL ) - { - fld = _TIFFCreateAnonFieldInfo( tif, tag, dt ); - if (!_TIFFMergeFieldInfo(tif, fld, 1)) - return NULL; - } - - return fld; -} - -TIFFFieldInfo* -_TIFFCreateAnonFieldInfo(TIFF *tif, ttag_t tag, TIFFDataType field_type) -{ - TIFFFieldInfo *fld; - (void) tif; - - fld = (TIFFFieldInfo *) _TIFFmalloc(sizeof (TIFFFieldInfo)); - if (fld == NULL) - return NULL; - _TIFFmemset( fld, 0, sizeof(TIFFFieldInfo) ); - - fld->field_tag = tag; - fld->field_readcount = TIFF_VARIABLE2; - fld->field_writecount = TIFF_VARIABLE2; - fld->field_type = field_type; - fld->field_bit = FIELD_CUSTOM; - fld->field_oktochange = TRUE; - fld->field_passcount = TRUE; - fld->field_name = (char *) _TIFFmalloc(32); - if (fld->field_name == NULL) { - _TIFFfree(fld); - return NULL; - } - - /* - * note that this name is a special sign to TIFFClose() and - * _TIFFSetupFieldInfo() to free the field - */ - sprintf(fld->field_name, "Tag %d", (int) tag); - - return fld; -} - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_dirread.c b/plugins/AdvaImg/src/LibTIFF/tif_dirread.c deleted file mode 100644 index 3567b2ae51..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_dirread.c +++ /dev/null @@ -1,2117 +0,0 @@ -/* $Id: tif_dirread.c,v 1.38 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Directory Read Support Routines. - */ -#include "tiffiop.h" - -#define IGNORE 0 /* tag placeholder used below */ - -#ifdef HAVE_IEEEFP -# define TIFFCvtIEEEFloatToNative(tif, n, fp) -# define TIFFCvtIEEEDoubleToNative(tif, n, dp) -#else -extern void TIFFCvtIEEEFloatToNative(TIFF*, uint32, float*); -extern void TIFFCvtIEEEDoubleToNative(TIFF*, uint32, double*); -#endif - -static TIFFDirEntry* TIFFReadDirectoryFind(TIFFDirEntry* dir, - uint16 dircount, uint16 tagid); -static int EstimateStripByteCounts(TIFF*, TIFFDirEntry*, uint16); -static void MissingRequired(TIFF*, const char*); -static int TIFFCheckDirOffset(TIFF*, toff_t); -static int CheckDirCount(TIFF*, TIFFDirEntry*, uint32); -static uint16 TIFFFetchDirectory(TIFF*, toff_t, TIFFDirEntry**, toff_t *); -static tsize_t TIFFFetchData(TIFF*, TIFFDirEntry*, char*); -static tsize_t TIFFFetchString(TIFF*, TIFFDirEntry*, char*); -static float TIFFFetchRational(TIFF*, TIFFDirEntry*); -static int TIFFFetchNormalTag(TIFF*, TIFFDirEntry*); -static int TIFFFetchPerSampleShorts(TIFF*, TIFFDirEntry*, uint16*); -static int TIFFFetchPerSampleLongs(TIFF*, TIFFDirEntry*, uint32*); -static int TIFFFetchPerSampleAnys(TIFF*, TIFFDirEntry*, double*, double*); -static int TIFFFetchShortArray(TIFF*, TIFFDirEntry*, uint16*); -static int TIFFFetchStripThing(TIFF*, TIFFDirEntry*, long, uint32**); -static int TIFFFetchRefBlackWhite(TIFF*, TIFFDirEntry*); -static int TIFFFetchSubjectDistance(TIFF*, TIFFDirEntry*); -static float TIFFFetchFloat(TIFF*, TIFFDirEntry*); -static int TIFFFetchFloatArray(TIFF*, TIFFDirEntry*, float*); -static int TIFFFetchDoubleArray(TIFF*, TIFFDirEntry*, double*); -static int TIFFFetchAnyArray(TIFF*, TIFFDirEntry*, double*); -static int TIFFFetchShortPair(TIFF*, TIFFDirEntry*); -static void ChopUpSingleUncompressedStrip(TIFF*); - -/* - * Read the next TIFF directory from a file and convert it to the internal - * format. We read directories sequentially. - */ -int -TIFFReadDirectory(TIFF* tif) -{ - static const char module[] = "TIFFReadDirectory"; - - int n; - TIFFDirectory* td; - TIFFDirEntry *dp, *dir = NULL; - uint16 iv; - uint32 v; - const TIFFFieldInfo* fip; - size_t fix; - uint16 dircount; - uint16 previous_tag = 0; - int diroutoforderwarning = 0, compressionknown = 0; - int haveunknowntags = 0; - - tif->tif_diroff = tif->tif_nextdiroff; - /* - * Check whether we have the last offset or bad offset (IFD looping). - */ - if (!TIFFCheckDirOffset(tif, tif->tif_nextdiroff)) - return 0; - /* - * Cleanup any previous compression state. - */ - (*tif->tif_cleanup)(tif); - tif->tif_curdir++; - dircount = TIFFFetchDirectory(tif, tif->tif_nextdiroff, - &dir, &tif->tif_nextdiroff); - if (!dircount) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Failed to read directory at offset %u", - tif->tif_name, tif->tif_nextdiroff); - return 0; - } - { - TIFFDirEntry* ma; - uint16 mb; - for (ma=dir, mb=0; mbtdir_tag==na->tdir_tag) - na->tdir_tag=IGNORE; - } - } - } - tif->tif_flags &= ~TIFF_BEENWRITING; /* reset before new dir */ - /* - * Setup default value and then make a pass over - * the fields to check type and tag information, - * and to extract info required to size data - * structures. A second pass is made afterwards - * to read in everthing not taken in the first pass. - */ - td = &tif->tif_dir; - /* free any old stuff and reinit */ - TIFFFreeDirectory(tif); - TIFFDefaultDirectory(tif); - /* - * Electronic Arts writes gray-scale TIFF files - * without a PlanarConfiguration directory entry. - * Thus we setup a default value here, even though - * the TIFF spec says there is no default value. - */ - TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - - /* - * Sigh, we must make a separate pass through the - * directory for the following reason: - * - * We must process the Compression tag in the first pass - * in order to merge in codec-private tag definitions (otherwise - * we may get complaints about unknown tags). However, the - * Compression tag may be dependent on the SamplesPerPixel - * tag value because older TIFF specs permited Compression - * to be written as a SamplesPerPixel-count tag entry. - * Thus if we don't first figure out the correct SamplesPerPixel - * tag value then we may end up ignoring the Compression tag - * value because it has an incorrect count value (if the - * true value of SamplesPerPixel is not 1). - * - * It sure would have been nice if Aldus had really thought - * this stuff through carefully. - */ - for (dp = dir, n = dircount; n > 0; n--, dp++) { - if (tif->tif_flags & TIFF_SWAB) { - TIFFSwabArrayOfShort(&dp->tdir_tag, 2); - TIFFSwabArrayOfLong(&dp->tdir_count, 2); - } - if (dp->tdir_tag == TIFFTAG_SAMPLESPERPIXEL) { - if (!TIFFFetchNormalTag(tif, dp)) - goto bad; - dp->tdir_tag = IGNORE; - } - } - /* - * First real pass over the directory. - */ - fix = 0; - for (dp = dir, n = dircount; n > 0; n--, dp++) { - - if (dp->tdir_tag == IGNORE) - continue; - - /* - * Silicon Beach (at least) writes unordered - * directory tags (violating the spec). Handle - * it here, but be obnoxious (maybe they'll fix it?). - */ - if (dp->tdir_tag < previous_tag) { - if (!diroutoforderwarning) { - TIFFWarningExt(tif->tif_clientdata, module, - "%s: invalid TIFF directory; tags are not sorted in ascending order", - tif->tif_name); - diroutoforderwarning = 1; - } - } - previous_tag = dp->tdir_tag; - if (fix >= tif->tif_nfields || - dp->tdir_tag < tif->tif_fieldinfo[fix]->field_tag) - fix = 0; /* O(n^2) */ - while (fix < tif->tif_nfields && - tif->tif_fieldinfo[fix]->field_tag < dp->tdir_tag) - fix++; - if (fix >= tif->tif_nfields || - tif->tif_fieldinfo[fix]->field_tag != dp->tdir_tag) { - /* Unknown tag ... we'll deal with it below */ - haveunknowntags = 1; - continue; - } - /* - * Null out old tags that we ignore. - */ - if (tif->tif_fieldinfo[fix]->field_bit == FIELD_IGNORE) { - ignore: - dp->tdir_tag = IGNORE; - continue; - } - /* - * Check data type. - */ - fip = tif->tif_fieldinfo[fix]; - while (dp->tdir_type != (unsigned short) fip->field_type - && fix < tif->tif_nfields) { - if (fip->field_type == TIFF_ANY) /* wildcard */ - break; - fip = tif->tif_fieldinfo[++fix]; - if (fix >= tif->tif_nfields || - fip->field_tag != dp->tdir_tag) { - TIFFWarningExt(tif->tif_clientdata, module, - "%s: wrong data type %d for \"%s\"; tag ignored", - tif->tif_name, dp->tdir_type, - tif->tif_fieldinfo[fix-1]->field_name); - goto ignore; - } - } - /* - * Check count if known in advance. - */ - if (fip->field_readcount != TIFF_VARIABLE - && fip->field_readcount != TIFF_VARIABLE2) { - uint32 expected = (fip->field_readcount == TIFF_SPP) ? - (uint32) td->td_samplesperpixel : - (uint32) fip->field_readcount; - if (!CheckDirCount(tif, dp, expected)) - goto ignore; - } - - switch (dp->tdir_tag) { - case TIFFTAG_COMPRESSION: - /* - * The 5.0 spec says the Compression tag has - * one value, while earlier specs say it has - * one value per sample. Because of this, we - * accept the tag if one value is supplied. - */ - if (dp->tdir_count == 1) { - v = TIFFExtractData(tif, - dp->tdir_type, dp->tdir_offset); - if (!TIFFSetField(tif, dp->tdir_tag, (uint16)v)) - goto bad; - else - compressionknown = 1; - break; - /* XXX: workaround for broken TIFFs */ - } else if (dp->tdir_type == TIFF_LONG) { - if (!TIFFFetchPerSampleLongs(tif, dp, &v) || - !TIFFSetField(tif, dp->tdir_tag, (uint16)v)) - goto bad; - } else { - if (!TIFFFetchPerSampleShorts(tif, dp, &iv) - || !TIFFSetField(tif, dp->tdir_tag, iv)) - goto bad; - } - dp->tdir_tag = IGNORE; - break; - case TIFFTAG_STRIPOFFSETS: - case TIFFTAG_STRIPBYTECOUNTS: - case TIFFTAG_TILEOFFSETS: - case TIFFTAG_TILEBYTECOUNTS: - TIFFSetFieldBit(tif, fip->field_bit); - break; - case TIFFTAG_IMAGEWIDTH: - case TIFFTAG_IMAGELENGTH: - case TIFFTAG_IMAGEDEPTH: - case TIFFTAG_TILELENGTH: - case TIFFTAG_TILEWIDTH: - case TIFFTAG_TILEDEPTH: - case TIFFTAG_PLANARCONFIG: - case TIFFTAG_ROWSPERSTRIP: - case TIFFTAG_EXTRASAMPLES: - if (!TIFFFetchNormalTag(tif, dp)) - goto bad; - dp->tdir_tag = IGNORE; - break; - } - } - - /* - * If we saw any unknown tags, make an extra pass over the directory - * to deal with them. This must be done separately because the tags - * could have become known when we registered a codec after finding - * the Compression tag. In a correctly-sorted directory there's - * no problem because Compression will come before any codec-private - * tags, but if the sorting is wrong that might not hold. - */ - if (haveunknowntags) { - fix = 0; - for (dp = dir, n = dircount; n > 0; n--, dp++) { - if (dp->tdir_tag == IGNORE) - continue; - if (fix >= tif->tif_nfields || - dp->tdir_tag < tif->tif_fieldinfo[fix]->field_tag) - fix = 0; /* O(n^2) */ - while (fix < tif->tif_nfields && - tif->tif_fieldinfo[fix]->field_tag < dp->tdir_tag) - fix++; - if (fix >= tif->tif_nfields || - tif->tif_fieldinfo[fix]->field_tag != dp->tdir_tag) { - - TIFFWarningExt(tif->tif_clientdata, - module, - "%s: unknown field with tag %d (0x%x) encountered", - tif->tif_name, - dp->tdir_tag, - dp->tdir_tag); - - if (!_TIFFMergeFieldInfo(tif, - _TIFFCreateAnonFieldInfo(tif, - dp->tdir_tag, - (TIFFDataType) dp->tdir_type), - 1)) - { - TIFFWarningExt(tif->tif_clientdata, - module, - "Registering anonymous field with tag %d (0x%x) failed", - dp->tdir_tag, - dp->tdir_tag); - dp->tdir_tag = IGNORE; - continue; - } - fix = 0; - while (fix < tif->tif_nfields && - tif->tif_fieldinfo[fix]->field_tag < dp->tdir_tag) - fix++; - } - /* - * Check data type. - */ - fip = tif->tif_fieldinfo[fix]; - while (dp->tdir_type != (unsigned short) fip->field_type - && fix < tif->tif_nfields) { - if (fip->field_type == TIFF_ANY) /* wildcard */ - break; - fip = tif->tif_fieldinfo[++fix]; - if (fix >= tif->tif_nfields || - fip->field_tag != dp->tdir_tag) { - TIFFWarningExt(tif->tif_clientdata, module, - "%s: wrong data type %d for \"%s\"; tag ignored", - tif->tif_name, dp->tdir_type, - tif->tif_fieldinfo[fix-1]->field_name); - dp->tdir_tag = IGNORE; - break; - } - } - } - } - - /* - * XXX: OJPEG hack. - * If a) compression is OJPEG, b) planarconfig tag says it's separate, - * c) strip offsets/bytecounts tag are both present and - * d) both contain exactly one value, then we consistently find - * that the buggy implementation of the buggy compression scheme - * matches contig planarconfig best. So we 'fix-up' the tag here - */ - if ((td->td_compression==COMPRESSION_OJPEG) && - (td->td_planarconfig==PLANARCONFIG_SEPARATE)) { - dp = TIFFReadDirectoryFind(dir,dircount,TIFFTAG_STRIPOFFSETS); - if ((dp!=0) && (dp->tdir_count==1)) { - dp = TIFFReadDirectoryFind(dir, dircount, - TIFFTAG_STRIPBYTECOUNTS); - if ((dp!=0) && (dp->tdir_count==1)) { - td->td_planarconfig=PLANARCONFIG_CONTIG; - TIFFWarningExt(tif->tif_clientdata, - "TIFFReadDirectory", - "Planarconfig tag value assumed incorrect, " - "assuming data is contig instead of chunky"); - } - } - } - - /* - * Allocate directory structure and setup defaults. - */ - if (!TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS)) { - MissingRequired(tif, "ImageLength"); - goto bad; - } - /* - * Setup appropriate structures (by strip or by tile) - */ - if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) { - td->td_nstrips = TIFFNumberOfStrips(tif); - td->td_tilewidth = td->td_imagewidth; - td->td_tilelength = td->td_rowsperstrip; - td->td_tiledepth = td->td_imagedepth; - tif->tif_flags &= ~TIFF_ISTILED; - } else { - td->td_nstrips = TIFFNumberOfTiles(tif); - tif->tif_flags |= TIFF_ISTILED; - } - if (!td->td_nstrips) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: cannot handle zero number of %s", - tif->tif_name, isTiled(tif) ? "tiles" : "strips"); - goto bad; - } - td->td_stripsperimage = td->td_nstrips; - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - td->td_stripsperimage /= td->td_samplesperpixel; - if (!TIFFFieldSet(tif, FIELD_STRIPOFFSETS)) { - if ((td->td_compression==COMPRESSION_OJPEG) && - (isTiled(tif)==0) && - (td->td_nstrips==1)) { - /* - * XXX: OJPEG hack. - * If a) compression is OJPEG, b) it's not a tiled TIFF, - * and c) the number of strips is 1, - * then we tolerate the absence of stripoffsets tag, - * because, presumably, all required data is in the - * JpegInterchangeFormat stream. - */ - TIFFSetFieldBit(tif, FIELD_STRIPOFFSETS); - } else { - MissingRequired(tif, - isTiled(tif) ? "TileOffsets" : "StripOffsets"); - goto bad; - } - } - - /* - * Second pass: extract other information. - */ - for (dp = dir, n = dircount; n > 0; n--, dp++) { - if (dp->tdir_tag == IGNORE) - continue; - switch (dp->tdir_tag) { - case TIFFTAG_MINSAMPLEVALUE: - case TIFFTAG_MAXSAMPLEVALUE: - case TIFFTAG_BITSPERSAMPLE: - case TIFFTAG_DATATYPE: - case TIFFTAG_SAMPLEFORMAT: - /* - * The 5.0 spec says the Compression tag has - * one value, while earlier specs say it has - * one value per sample. Because of this, we - * accept the tag if one value is supplied. - * - * The MinSampleValue, MaxSampleValue, BitsPerSample - * DataType and SampleFormat tags are supposed to be - * written as one value/sample, but some vendors - * incorrectly write one value only -- so we accept - * that as well (yech). Other vendors write correct - * value for NumberOfSamples, but incorrect one for - * BitsPerSample and friends, and we will read this - * too. - */ - if (dp->tdir_count == 1) { - v = TIFFExtractData(tif, - dp->tdir_type, dp->tdir_offset); - if (!TIFFSetField(tif, dp->tdir_tag, (uint16)v)) - goto bad; - /* XXX: workaround for broken TIFFs */ - } else if (dp->tdir_tag == TIFFTAG_BITSPERSAMPLE - && dp->tdir_type == TIFF_LONG) { - if (!TIFFFetchPerSampleLongs(tif, dp, &v) || - !TIFFSetField(tif, dp->tdir_tag, (uint16)v)) - goto bad; - } else { - if (!TIFFFetchPerSampleShorts(tif, dp, &iv) || - !TIFFSetField(tif, dp->tdir_tag, iv)) - goto bad; - } - break; - case TIFFTAG_SMINSAMPLEVALUE: - { - double minv = 0.0, maxv = 0.0; - if (!TIFFFetchPerSampleAnys(tif, dp, &minv, &maxv) || - !TIFFSetField(tif, dp->tdir_tag, minv)) - goto bad; - } - break; - case TIFFTAG_SMAXSAMPLEVALUE: - { - double minv = 0.0, maxv = 0.0; - if (!TIFFFetchPerSampleAnys(tif, dp, &minv, &maxv) || - !TIFFSetField(tif, dp->tdir_tag, maxv)) - goto bad; - } - break; - case TIFFTAG_STRIPOFFSETS: - case TIFFTAG_TILEOFFSETS: - if (!TIFFFetchStripThing(tif, dp, - td->td_nstrips, &td->td_stripoffset)) - goto bad; - break; - case TIFFTAG_STRIPBYTECOUNTS: - case TIFFTAG_TILEBYTECOUNTS: - if (!TIFFFetchStripThing(tif, dp, - td->td_nstrips, &td->td_stripbytecount)) - goto bad; - break; - case TIFFTAG_COLORMAP: - case TIFFTAG_TRANSFERFUNCTION: - { - char* cp; - /* - * TransferFunction can have either 1x or 3x - * data values; Colormap can have only 3x - * items. - */ - v = 1L<td_bitspersample; - if (dp->tdir_tag == TIFFTAG_COLORMAP || - dp->tdir_count != v) { - if (!CheckDirCount(tif, dp, 3 * v)) - break; - } - v *= sizeof(uint16); - cp = (char *)_TIFFCheckMalloc(tif, - dp->tdir_count, - sizeof (uint16), - "to read \"TransferFunction\" tag"); - if (cp != NULL) { - if (TIFFFetchData(tif, dp, cp)) { - /* - * This deals with there being - * only one array to apply to - * all samples. - */ - uint32 c = 1L << td->td_bitspersample; - if (dp->tdir_count == c) - v = 0L; - TIFFSetField(tif, dp->tdir_tag, - cp, cp+v, cp+2*v); - } - _TIFFfree(cp); - } - break; - } - case TIFFTAG_PAGENUMBER: - case TIFFTAG_HALFTONEHINTS: - case TIFFTAG_YCBCRSUBSAMPLING: - case TIFFTAG_DOTRANGE: - (void) TIFFFetchShortPair(tif, dp); - break; - case TIFFTAG_REFERENCEBLACKWHITE: - (void) TIFFFetchRefBlackWhite(tif, dp); - break; -/* BEGIN REV 4.0 COMPATIBILITY */ - case TIFFTAG_OSUBFILETYPE: - v = 0L; - switch (TIFFExtractData(tif, dp->tdir_type, - dp->tdir_offset)) { - case OFILETYPE_REDUCEDIMAGE: - v = FILETYPE_REDUCEDIMAGE; - break; - case OFILETYPE_PAGE: - v = FILETYPE_PAGE; - break; - } - if (v) - TIFFSetField(tif, TIFFTAG_SUBFILETYPE, v); - break; -/* END REV 4.0 COMPATIBILITY */ - default: - (void) TIFFFetchNormalTag(tif, dp); - break; - } - } - /* - * OJPEG hack: - * - If a) compression is OJPEG, and b) photometric tag is missing, - * then we consistently find that photometric should be YCbCr - * - If a) compression is OJPEG, and b) photometric tag says it's RGB, - * then we consistently find that the buggy implementation of the - * buggy compression scheme matches photometric YCbCr instead. - * - If a) compression is OJPEG, and b) bitspersample tag is missing, - * then we consistently find bitspersample should be 8. - * - If a) compression is OJPEG, b) samplesperpixel tag is missing, - * and c) photometric is RGB or YCbCr, then we consistently find - * samplesperpixel should be 3 - * - If a) compression is OJPEG, b) samplesperpixel tag is missing, - * and c) photometric is MINISWHITE or MINISBLACK, then we consistently - * find samplesperpixel should be 3 - */ - if (td->td_compression==COMPRESSION_OJPEG) - { - if (!TIFFFieldSet(tif,FIELD_PHOTOMETRIC)) - { - TIFFWarningExt(tif->tif_clientdata, "TIFFReadDirectory", - "Photometric tag is missing, assuming data is YCbCr"); - if (!TIFFSetField(tif,TIFFTAG_PHOTOMETRIC,PHOTOMETRIC_YCBCR)) - goto bad; - } - else if (td->td_photometric==PHOTOMETRIC_RGB) - { - td->td_photometric=PHOTOMETRIC_YCBCR; - TIFFWarningExt(tif->tif_clientdata, "TIFFReadDirectory", - "Photometric tag value assumed incorrect, " - "assuming data is YCbCr instead of RGB"); - } - if (!TIFFFieldSet(tif,FIELD_BITSPERSAMPLE)) - { - TIFFWarningExt(tif->tif_clientdata,"TIFFReadDirectory", - "BitsPerSample tag is missing, assuming 8 bits per sample"); - if (!TIFFSetField(tif,TIFFTAG_BITSPERSAMPLE,8)) - goto bad; - } - if (!TIFFFieldSet(tif,FIELD_SAMPLESPERPIXEL)) - { - if (td->td_photometric==PHOTOMETRIC_RGB) - { - TIFFWarningExt(tif->tif_clientdata, - "TIFFReadDirectory", - "SamplesPerPixel tag is missing, " - "assuming correct SamplesPerPixel value is 3"); - if (!TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,3)) - goto bad; - } - if (td->td_photometric==PHOTOMETRIC_YCBCR) - { - TIFFWarningExt(tif->tif_clientdata, - "TIFFReadDirectory", - "SamplesPerPixel tag is missing, " - "applying correct SamplesPerPixel value of 3"); - if (!TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,3)) - goto bad; - } - else if ((td->td_photometric==PHOTOMETRIC_MINISWHITE) - || (td->td_photometric==PHOTOMETRIC_MINISBLACK)) - { - /* - * SamplesPerPixel tag is missing, but is not required - * by spec. Assume correct SamplesPerPixel value of 1. - */ - if (!TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,1)) - goto bad; - } - } - } - /* - * Verify Palette image has a Colormap. - */ - if (td->td_photometric == PHOTOMETRIC_PALETTE && - !TIFFFieldSet(tif, FIELD_COLORMAP)) { - if ( tif->tif_dir.td_bitspersample>=8 && tif->tif_dir.td_samplesperpixel==3) - tif->tif_dir.td_photometric = PHOTOMETRIC_RGB; - else if (tif->tif_dir.td_bitspersample>=8) - tif->tif_dir.td_photometric = PHOTOMETRIC_MINISBLACK; - else { - MissingRequired(tif, "Colormap"); - goto bad; - } - } - /* - * OJPEG hack: - * We do no further messing with strip/tile offsets/bytecounts in OJPEG - * TIFFs - */ - if (td->td_compression!=COMPRESSION_OJPEG) - { - /* - * Attempt to deal with a missing StripByteCounts tag. - */ - if (!TIFFFieldSet(tif, FIELD_STRIPBYTECOUNTS)) { - /* - * Some manufacturers violate the spec by not giving - * the size of the strips. In this case, assume there - * is one uncompressed strip of data. - */ - if ((td->td_planarconfig == PLANARCONFIG_CONTIG && - td->td_nstrips > 1) || - (td->td_planarconfig == PLANARCONFIG_SEPARATE && - td->td_nstrips != td->td_samplesperpixel)) { - MissingRequired(tif, "StripByteCounts"); - goto bad; - } - TIFFWarningExt(tif->tif_clientdata, module, - "%s: TIFF directory is missing required " - "\"%s\" field, calculating from imagelength", - tif->tif_name, - _TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name); - if (EstimateStripByteCounts(tif, dir, dircount) < 0) - goto bad; - /* - * Assume we have wrong StripByteCount value (in case - * of single strip) in following cases: - * - it is equal to zero along with StripOffset; - * - it is larger than file itself (in case of uncompressed - * image); - * - it is smaller than the size of the bytes per row - * multiplied on the number of rows. The last case should - * not be checked in the case of writing new image, - * because we may do not know the exact strip size - * until the whole image will be written and directory - * dumped out. - */ - #define BYTECOUNTLOOKSBAD \ - ( (td->td_stripbytecount[0] == 0 && td->td_stripoffset[0] != 0) || \ - (td->td_compression == COMPRESSION_NONE && \ - td->td_stripbytecount[0] > TIFFGetFileSize(tif) - td->td_stripoffset[0]) || \ - (tif->tif_mode == O_RDONLY && \ - td->td_compression == COMPRESSION_NONE && \ - td->td_stripbytecount[0] < TIFFScanlineSize(tif) * td->td_imagelength) ) - - } else if (td->td_nstrips == 1 - && td->td_stripoffset[0] != 0 - && BYTECOUNTLOOKSBAD) { - /* - * XXX: Plexus (and others) sometimes give a value of - * zero for a tag when they don't know what the - * correct value is! Try and handle the simple case - * of estimating the size of a one strip image. - */ - TIFFWarningExt(tif->tif_clientdata, module, - "%s: Bogus \"%s\" field, ignoring and calculating from imagelength", - tif->tif_name, - _TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name); - if(EstimateStripByteCounts(tif, dir, dircount) < 0) - goto bad; - } else if (td->td_planarconfig == PLANARCONFIG_CONTIG - && td->td_nstrips > 2 - && td->td_compression == COMPRESSION_NONE - && td->td_stripbytecount[0] != td->td_stripbytecount[1] - && td->td_stripbytecount[0] != 0 - && td->td_stripbytecount[1] != 0 ) { - /* - * XXX: Some vendors fill StripByteCount array with - * absolutely wrong values (it can be equal to - * StripOffset array, for example). Catch this case - * here. - */ - TIFFWarningExt(tif->tif_clientdata, module, - "%s: Wrong \"%s\" field, ignoring and calculating from imagelength", - tif->tif_name, - _TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name); - if (EstimateStripByteCounts(tif, dir, dircount) < 0) - goto bad; - } - } - if (dir) { - _TIFFfree((char *)dir); - dir = NULL; - } - if (!TIFFFieldSet(tif, FIELD_MAXSAMPLEVALUE)) - td->td_maxsamplevalue = (uint16)((1L<td_bitspersample)-1); - /* - * Setup default compression scheme. - */ - - /* - * XXX: We can optimize checking for the strip bounds using the sorted - * bytecounts array. See also comments for TIFFAppendToStrip() - * function in tif_write.c. - */ - if (td->td_nstrips > 1) { - tstrip_t strip; - - td->td_stripbytecountsorted = 1; - for (strip = 1; strip < td->td_nstrips; strip++) { - if (td->td_stripoffset[strip - 1] > - td->td_stripoffset[strip]) { - td->td_stripbytecountsorted = 0; - break; - } - } - } - - if (!TIFFFieldSet(tif, FIELD_COMPRESSION)) - TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); - /* - * Some manufacturers make life difficult by writing - * large amounts of uncompressed data as a single strip. - * This is contrary to the recommendations of the spec. - * The following makes an attempt at breaking such images - * into strips closer to the recommended 8k bytes. A - * side effect, however, is that the RowsPerStrip tag - * value may be changed. - */ - if (td->td_nstrips == 1 && td->td_compression == COMPRESSION_NONE && - (tif->tif_flags & (TIFF_STRIPCHOP|TIFF_ISTILED)) == TIFF_STRIPCHOP) - ChopUpSingleUncompressedStrip(tif); - - /* - * Reinitialize i/o since we are starting on a new directory. - */ - tif->tif_row = (uint32) -1; - tif->tif_curstrip = (tstrip_t) -1; - tif->tif_col = (uint32) -1; - tif->tif_curtile = (ttile_t) -1; - tif->tif_tilesize = (tsize_t) -1; - - tif->tif_scanlinesize = TIFFScanlineSize(tif); - if (!tif->tif_scanlinesize) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: cannot handle zero scanline size", - tif->tif_name); - return (0); - } - - if (isTiled(tif)) { - tif->tif_tilesize = TIFFTileSize(tif); - if (!tif->tif_tilesize) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: cannot handle zero tile size", - tif->tif_name); - return (0); - } - } else { - if (!TIFFStripSize(tif)) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: cannot handle zero strip size", - tif->tif_name); - return (0); - } - } - return (1); -bad: - if (dir) - _TIFFfree(dir); - return (0); -} - -static TIFFDirEntry* -TIFFReadDirectoryFind(TIFFDirEntry* dir, uint16 dircount, uint16 tagid) -{ - TIFFDirEntry* m; - uint16 n; - for (m=dir, n=0; ntdir_tag==tagid) - return(m); - } - return(0); -} - -/* - * Read custom directory from the arbitarry offset. - * The code is very similar to TIFFReadDirectory(). - */ -int -TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, - const TIFFFieldInfo info[], size_t n) -{ - static const char module[] = "TIFFReadCustomDirectory"; - - TIFFDirectory* td = &tif->tif_dir; - TIFFDirEntry *dp, *dir = NULL; - const TIFFFieldInfo* fip; - size_t fix; - uint16 i, dircount; - - _TIFFSetupFieldInfo(tif, info, n); - - dircount = TIFFFetchDirectory(tif, diroff, &dir, NULL); - if (!dircount) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Failed to read custom directory at offset %u", - tif->tif_name, diroff); - return 0; - } - - TIFFFreeDirectory(tif); - _TIFFmemset(&tif->tif_dir, 0, sizeof(TIFFDirectory)); - - fix = 0; - for (dp = dir, i = dircount; i > 0; i--, dp++) { - if (tif->tif_flags & TIFF_SWAB) { - TIFFSwabArrayOfShort(&dp->tdir_tag, 2); - TIFFSwabArrayOfLong(&dp->tdir_count, 2); - } - - if (fix >= tif->tif_nfields || dp->tdir_tag == IGNORE) - continue; - - while (fix < tif->tif_nfields && - tif->tif_fieldinfo[fix]->field_tag < dp->tdir_tag) - fix++; - - if (fix >= tif->tif_nfields || - tif->tif_fieldinfo[fix]->field_tag != dp->tdir_tag) { - - TIFFWarningExt(tif->tif_clientdata, module, - "%s: unknown field with tag %d (0x%x) encountered", - tif->tif_name, dp->tdir_tag, dp->tdir_tag); - if (!_TIFFMergeFieldInfo(tif, - _TIFFCreateAnonFieldInfo(tif, - dp->tdir_tag, - (TIFFDataType) dp->tdir_type), - 1)) - { - TIFFWarningExt(tif->tif_clientdata, module, - "Registering anonymous field with tag %d (0x%x) failed", - dp->tdir_tag, dp->tdir_tag); - goto ignore; - } - - fix = 0; - while (fix < tif->tif_nfields && - tif->tif_fieldinfo[fix]->field_tag < dp->tdir_tag) - fix++; - } - /* - * Null out old tags that we ignore. - */ - if (tif->tif_fieldinfo[fix]->field_bit == FIELD_IGNORE) { - ignore: - dp->tdir_tag = IGNORE; - continue; - } - /* - * Check data type. - */ - fip = tif->tif_fieldinfo[fix]; - while (dp->tdir_type != (unsigned short) fip->field_type - && fix < tif->tif_nfields) { - if (fip->field_type == TIFF_ANY) /* wildcard */ - break; - fip = tif->tif_fieldinfo[++fix]; - if (fix >= tif->tif_nfields || - fip->field_tag != dp->tdir_tag) { - TIFFWarningExt(tif->tif_clientdata, module, - "%s: wrong data type %d for \"%s\"; tag ignored", - tif->tif_name, dp->tdir_type, - tif->tif_fieldinfo[fix-1]->field_name); - goto ignore; - } - } - /* - * Check count if known in advance. - */ - if (fip->field_readcount != TIFF_VARIABLE - && fip->field_readcount != TIFF_VARIABLE2) { - uint32 expected = (fip->field_readcount == TIFF_SPP) ? - (uint32) td->td_samplesperpixel : - (uint32) fip->field_readcount; - if (!CheckDirCount(tif, dp, expected)) - goto ignore; - } - - /* - * EXIF tags which need to be specifically processed. - */ - switch (dp->tdir_tag) { - case EXIFTAG_SUBJECTDISTANCE: - (void) TIFFFetchSubjectDistance(tif, dp); - break; - default: - (void) TIFFFetchNormalTag(tif, dp); - break; - } - } - - if (dir) - _TIFFfree(dir); - return 1; -} - -/* - * EXIF is important special case of custom IFD, so we have a special - * function to read it. - */ -int -TIFFReadEXIFDirectory(TIFF* tif, toff_t diroff) -{ - size_t exifFieldInfoCount; - const TIFFFieldInfo *exifFieldInfo = - _TIFFGetExifFieldInfo(&exifFieldInfoCount); - return TIFFReadCustomDirectory(tif, diroff, exifFieldInfo, - exifFieldInfoCount); -} - -static int -EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) -{ - static const char module[] = "EstimateStripByteCounts"; - - TIFFDirEntry *dp; - TIFFDirectory *td = &tif->tif_dir; - uint32 strip; - - if (td->td_stripbytecount) - _TIFFfree(td->td_stripbytecount); - td->td_stripbytecount = (uint32*) - _TIFFCheckMalloc(tif, td->td_nstrips, sizeof (uint32), - "for \"StripByteCounts\" array"); - if ( td->td_stripbytecount == NULL ) - return -1; - - if (td->td_compression != COMPRESSION_NONE) { - uint32 space = (uint32)(sizeof (TIFFHeader) - + sizeof (uint16) - + (dircount * sizeof (TIFFDirEntry)) - + sizeof (uint32)); - toff_t filesize = TIFFGetFileSize(tif); - uint16 n; - - /* calculate amount of space used by indirect values */ - for (dp = dir, n = dircount; n > 0; n--, dp++) - { - uint32 cc = TIFFDataWidth((TIFFDataType) dp->tdir_type); - if (cc == 0) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Cannot determine size of unknown tag type %d", - tif->tif_name, dp->tdir_type); - return -1; - } - cc = cc * dp->tdir_count; - if (cc > sizeof (uint32)) - space += cc; - } - space = filesize - space; - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - space /= td->td_samplesperpixel; - for (strip = 0; strip < td->td_nstrips; strip++) - td->td_stripbytecount[strip] = space; - /* - * This gross hack handles the case were the offset to - * the last strip is past the place where we think the strip - * should begin. Since a strip of data must be contiguous, - * it's safe to assume that we've overestimated the amount - * of data in the strip and trim this number back accordingly. - */ - strip--; - if (((toff_t)(td->td_stripoffset[strip]+ - td->td_stripbytecount[strip])) > filesize) - td->td_stripbytecount[strip] = - filesize - td->td_stripoffset[strip]; - } else if (isTiled(tif)) { - uint32 bytespertile = TIFFTileSize(tif); - - for (strip = 0; strip < td->td_nstrips; strip++) - td->td_stripbytecount[strip] = bytespertile; - } else { - uint32 rowbytes = TIFFScanlineSize(tif); - uint32 rowsperstrip = td->td_imagelength/td->td_stripsperimage; - for (strip = 0; strip < td->td_nstrips; strip++) - td->td_stripbytecount[strip] = rowbytes * rowsperstrip; - } - TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS); - if (!TIFFFieldSet(tif, FIELD_ROWSPERSTRIP)) - td->td_rowsperstrip = td->td_imagelength; - return 1; -} - -static void -MissingRequired(TIFF* tif, const char* tagname) -{ - static const char module[] = "MissingRequired"; - - TIFFErrorExt(tif->tif_clientdata, module, - "%s: TIFF directory is missing required \"%s\" field", - tif->tif_name, tagname); -} - -/* - * Check the directory offset against the list of already seen directory - * offsets. This is a trick to prevent IFD looping. The one can create TIFF - * file with looped directory pointers. We will maintain a list of already - * seen directories and check every IFD offset against that list. - */ -static int -TIFFCheckDirOffset(TIFF* tif, toff_t diroff) -{ - uint16 n; - - if (diroff == 0) /* no more directories */ - return 0; - - for (n = 0; n < tif->tif_dirnumber && tif->tif_dirlist; n++) { - if (tif->tif_dirlist[n] == diroff) - return 0; - } - - tif->tif_dirnumber++; - - if (tif->tif_dirnumber > tif->tif_dirlistsize) { - toff_t* new_dirlist; - - /* - * XXX: Reduce memory allocation granularity of the dirlist - * array. - */ - new_dirlist = (toff_t *)_TIFFCheckRealloc(tif, - tif->tif_dirlist, - tif->tif_dirnumber, - 2 * sizeof(toff_t), - "for IFD list"); - if (!new_dirlist) - return 0; - tif->tif_dirlistsize = 2 * tif->tif_dirnumber; - tif->tif_dirlist = new_dirlist; - } - - tif->tif_dirlist[tif->tif_dirnumber - 1] = diroff; - - return 1; -} - -/* - * Check the count field of a directory entry against a known value. The - * caller is expected to skip/ignore the tag if there is a mismatch. - */ -static int -CheckDirCount(TIFF* tif, TIFFDirEntry* dir, uint32 count) -{ - if (count > dir->tdir_count) { - TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "incorrect count for field \"%s\" (%u, expecting %u); tag ignored", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name, - dir->tdir_count, count); - return (0); - } else if (count < dir->tdir_count) { - TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "incorrect count for field \"%s\" (%u, expecting %u); tag trimmed", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name, - dir->tdir_count, count); - dir->tdir_count = count; - return (1); - } - return (1); -} - -/* - * Read IFD structure from the specified offset. If the pointer to - * nextdiroff variable has been specified, read it too. Function returns a - * number of fields in the directory or 0 if failed. - */ -static uint16 -TIFFFetchDirectory(TIFF* tif, toff_t diroff, TIFFDirEntry **pdir, - toff_t *nextdiroff) -{ - static const char module[] = "TIFFFetchDirectory"; - - TIFFDirEntry *dir; - uint16 dircount; - - assert(pdir); - - tif->tif_diroff = diroff; - if (nextdiroff) - *nextdiroff = 0; - if (!isMapped(tif)) { - if (!SeekOK(tif, tif->tif_diroff)) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Seek error accessing TIFF directory", - tif->tif_name); - return 0; - } - if (!ReadOK(tif, &dircount, sizeof (uint16))) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Can not read TIFF directory count", - tif->tif_name); - return 0; - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount); - dir = (TIFFDirEntry *)_TIFFCheckMalloc(tif, dircount, - sizeof (TIFFDirEntry), - "to read TIFF directory"); - if (dir == NULL) - return 0; - if (!ReadOK(tif, dir, dircount*sizeof (TIFFDirEntry))) { - TIFFErrorExt(tif->tif_clientdata, module, - "%.100s: Can not read TIFF directory", - tif->tif_name); - _TIFFfree(dir); - return 0; - } - /* - * Read offset to next directory for sequential scans if - * needed. - */ - if (nextdiroff) - (void) ReadOK(tif, nextdiroff, sizeof(uint32)); - } else { - toff_t off = tif->tif_diroff; - - /* - * Check for integer overflow when validating the dir_off, - * otherwise a very high offset may cause an OOB read and - * crash the client. Make two comparisons instead of - * - * off + sizeof(uint16) > tif->tif_size - * - * to avoid overflow. - */ - if (tif->tif_size < sizeof (uint16) || - off > tif->tif_size - sizeof(uint16)) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Can not read TIFF directory count", - tif->tif_name); - return 0; - } else { - _TIFFmemcpy(&dircount, tif->tif_base + off, - sizeof(uint16)); - } - off += sizeof (uint16); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount); - dir = (TIFFDirEntry *)_TIFFCheckMalloc(tif, dircount, - sizeof(TIFFDirEntry), - "to read TIFF directory"); - if (dir == NULL) - return 0; - if (off + dircount * sizeof (TIFFDirEntry) > tif->tif_size) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Can not read TIFF directory", - tif->tif_name); - _TIFFfree(dir); - return 0; - } else { - _TIFFmemcpy(dir, tif->tif_base + off, - dircount * sizeof(TIFFDirEntry)); - } - if (nextdiroff) { - off += dircount * sizeof (TIFFDirEntry); - if (off + sizeof (uint32) <= tif->tif_size) { - _TIFFmemcpy(nextdiroff, tif->tif_base + off, - sizeof (uint32)); - } - } - } - if (nextdiroff && tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(nextdiroff); - *pdir = dir; - return dircount; -} - -/* - * Fetch a contiguous directory item. - */ -static tsize_t -TIFFFetchData(TIFF* tif, TIFFDirEntry* dir, char* cp) -{ - uint32 w = TIFFDataWidth((TIFFDataType) dir->tdir_type); - /* - * FIXME: butecount should have tsize_t type, but for now libtiff - * defines tsize_t as a signed 32-bit integer and we are losing - * ability to read arrays larger than 2^31 bytes. So we are using - * uint32 instead of tsize_t here. - */ - uint32 cc = dir->tdir_count * w; - - /* Check for overflow. */ - if (!dir->tdir_count || !w || cc / w != dir->tdir_count) - goto bad; - - if (!isMapped(tif)) { - if (!SeekOK(tif, dir->tdir_offset)) - goto bad; - if (!ReadOK(tif, cp, cc)) - goto bad; - } else { - /* Check for overflow. */ - if (dir->tdir_offset + cc < dir->tdir_offset - || dir->tdir_offset + cc < cc - || dir->tdir_offset + cc > tif->tif_size) - goto bad; - _TIFFmemcpy(cp, tif->tif_base + dir->tdir_offset, cc); - } - if (tif->tif_flags & TIFF_SWAB) { - switch (dir->tdir_type) { - case TIFF_SHORT: - case TIFF_SSHORT: - TIFFSwabArrayOfShort((uint16*) cp, dir->tdir_count); - break; - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_FLOAT: - TIFFSwabArrayOfLong((uint32*) cp, dir->tdir_count); - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - TIFFSwabArrayOfLong((uint32*) cp, 2*dir->tdir_count); - break; - case TIFF_DOUBLE: - TIFFSwabArrayOfDouble((double*) cp, dir->tdir_count); - break; - } - } - return (cc); -bad: - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Error fetching data for field \"%s\"", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); - return (tsize_t) 0; -} - -/* - * Fetch an ASCII item from the file. - */ -static tsize_t -TIFFFetchString(TIFF* tif, TIFFDirEntry* dir, char* cp) -{ - if (dir->tdir_count <= 4) { - uint32 l = dir->tdir_offset; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&l); - _TIFFmemcpy(cp, &l, dir->tdir_count); - return (1); - } - return (TIFFFetchData(tif, dir, cp)); -} - -/* - * Convert numerator+denominator to float. - */ -static int -cvtRational(TIFF* tif, TIFFDirEntry* dir, uint32 num, uint32 denom, float* rv) -{ - if (denom == 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%s: Rational with zero denominator (num = %u)", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name, num); - return (0); - } else { - if (dir->tdir_type == TIFF_RATIONAL) - *rv = ((float)num / (float)denom); - else - *rv = ((float)(int32)num / (float)(int32)denom); - return (1); - } -} - -/* - * Fetch a rational item from the file at offset off and return the value as a - * floating point number. - */ -static float -TIFFFetchRational(TIFF* tif, TIFFDirEntry* dir) -{ - uint32 l[2]; - float v; - - return (!TIFFFetchData(tif, dir, (char *)l) || - !cvtRational(tif, dir, l[0], l[1], &v) ? 1.0f : v); -} - -/* - * Fetch a single floating point value from the offset field and return it as - * a native float. - */ -static float -TIFFFetchFloat(TIFF* tif, TIFFDirEntry* dir) -{ - float v; - int32 l = TIFFExtractData(tif, dir->tdir_type, dir->tdir_offset); - _TIFFmemcpy(&v, &l, sizeof(float)); - TIFFCvtIEEEFloatToNative(tif, 1, &v); - return (v); -} - -/* - * Fetch an array of BYTE or SBYTE values. - */ -static int -TIFFFetchByteArray(TIFF* tif, TIFFDirEntry* dir, uint8* v) -{ - if (dir->tdir_count <= 4) { - /* - * Extract data from offset field. - */ - if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) { - if (dir->tdir_type == TIFF_SBYTE) - switch (dir->tdir_count) { - case 4: v[3] = dir->tdir_offset & 0xff; - case 3: v[2] = (dir->tdir_offset >> 8) & 0xff; - case 2: v[1] = (dir->tdir_offset >> 16) & 0xff; - case 1: v[0] = dir->tdir_offset >> 24; - } - else - switch (dir->tdir_count) { - case 4: v[3] = dir->tdir_offset & 0xff; - case 3: v[2] = (dir->tdir_offset >> 8) & 0xff; - case 2: v[1] = (dir->tdir_offset >> 16) & 0xff; - case 1: v[0] = dir->tdir_offset >> 24; - } - } else { - if (dir->tdir_type == TIFF_SBYTE) - switch (dir->tdir_count) { - case 4: v[3] = dir->tdir_offset >> 24; - case 3: v[2] = (dir->tdir_offset >> 16) & 0xff; - case 2: v[1] = (dir->tdir_offset >> 8) & 0xff; - case 1: v[0] = dir->tdir_offset & 0xff; - } - else - switch (dir->tdir_count) { - case 4: v[3] = dir->tdir_offset >> 24; - case 3: v[2] = (dir->tdir_offset >> 16) & 0xff; - case 2: v[1] = (dir->tdir_offset >> 8) & 0xff; - case 1: v[0] = dir->tdir_offset & 0xff; - } - } - return (1); - } else - return (TIFFFetchData(tif, dir, (char*) v) != 0); /* XXX */ -} - -/* - * Fetch an array of SHORT or SSHORT values. - */ -static int -TIFFFetchShortArray(TIFF* tif, TIFFDirEntry* dir, uint16* v) -{ - if (dir->tdir_count <= 2) { - if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) { - switch (dir->tdir_count) { - case 2: v[1] = (uint16) (dir->tdir_offset & 0xffff); - case 1: v[0] = (uint16) (dir->tdir_offset >> 16); - } - } else { - switch (dir->tdir_count) { - case 2: v[1] = (uint16) (dir->tdir_offset >> 16); - case 1: v[0] = (uint16) (dir->tdir_offset & 0xffff); - } - } - return (1); - } else - return (TIFFFetchData(tif, dir, (char *)v) != 0); -} - -/* - * Fetch a pair of SHORT or BYTE values. Some tags may have either BYTE - * or SHORT type and this function works with both ones. - */ -static int -TIFFFetchShortPair(TIFF* tif, TIFFDirEntry* dir) -{ - /* - * Prevent overflowing the v stack arrays below by performing a sanity - * check on tdir_count, this should never be greater than two. - */ - if (dir->tdir_count > 2) { - TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "unexpected count for field \"%s\", %u, expected 2; ignored", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name, - dir->tdir_count); - return 0; - } - - switch (dir->tdir_type) { - case TIFF_BYTE: - case TIFF_SBYTE: - { - uint8 v[4]; - return TIFFFetchByteArray(tif, dir, v) - && TIFFSetField(tif, dir->tdir_tag, v[0], v[1]); - } - case TIFF_SHORT: - case TIFF_SSHORT: - { - uint16 v[2]; - return TIFFFetchShortArray(tif, dir, v) - && TIFFSetField(tif, dir->tdir_tag, v[0], v[1]); - } - default: - return 0; - } -} - -/* - * Fetch an array of LONG or SLONG values. - */ -static int -TIFFFetchLongArray(TIFF* tif, TIFFDirEntry* dir, uint32* v) -{ - if (dir->tdir_count == 1) { - v[0] = dir->tdir_offset; - return (1); - } else - return (TIFFFetchData(tif, dir, (char*) v) != 0); -} - -/* - * Fetch an array of RATIONAL or SRATIONAL values. - */ -static int -TIFFFetchRationalArray(TIFF* tif, TIFFDirEntry* dir, float* v) -{ - int ok = 0; - uint32* l; - - l = (uint32*)_TIFFCheckMalloc(tif, - dir->tdir_count, TIFFDataWidth((TIFFDataType) dir->tdir_type), - "to fetch array of rationals"); - if (l) { - if (TIFFFetchData(tif, dir, (char *)l)) { - uint32 i; - for (i = 0; i < dir->tdir_count; i++) { - ok = cvtRational(tif, dir, - l[2*i+0], l[2*i+1], &v[i]); - if (!ok) - break; - } - } - _TIFFfree((char *)l); - } - return (ok); -} - -/* - * Fetch an array of FLOAT values. - */ -static int -TIFFFetchFloatArray(TIFF* tif, TIFFDirEntry* dir, float* v) -{ - - if (dir->tdir_count == 1) { - union - { - float f; - uint32 i; - } float_union; - - float_union.i=dir->tdir_offset; - v[0]=float_union.f; - TIFFCvtIEEEFloatToNative(tif, dir->tdir_count, v); - return (1); - } else if (TIFFFetchData(tif, dir, (char*) v)) { - TIFFCvtIEEEFloatToNative(tif, dir->tdir_count, v); - return (1); - } else - return (0); -} - -/* - * Fetch an array of DOUBLE values. - */ -static int -TIFFFetchDoubleArray(TIFF* tif, TIFFDirEntry* dir, double* v) -{ - if (TIFFFetchData(tif, dir, (char*) v)) { - TIFFCvtIEEEDoubleToNative(tif, dir->tdir_count, v); - return (1); - } else - return (0); -} - -/* - * Fetch an array of ANY values. The actual values are returned as doubles - * which should be able hold all the types. Yes, there really should be an - * tany_t to avoid this potential non-portability ... Note in particular that - * we assume that the double return value vector is large enough to read in - * any fundamental type. We use that vector as a buffer to read in the base - * type vector and then convert it in place to double (from end to front of - * course). - */ -static int -TIFFFetchAnyArray(TIFF* tif, TIFFDirEntry* dir, double* v) -{ - int i; - - switch (dir->tdir_type) { - case TIFF_BYTE: - case TIFF_SBYTE: - if (!TIFFFetchByteArray(tif, dir, (uint8*) v)) - return (0); - if (dir->tdir_type == TIFF_BYTE) { - uint8* vp = (uint8*) v; - for (i = dir->tdir_count-1; i >= 0; i--) - v[i] = vp[i]; - } else { - int8* vp = (int8*) v; - for (i = dir->tdir_count-1; i >= 0; i--) - v[i] = vp[i]; - } - break; - case TIFF_SHORT: - case TIFF_SSHORT: - if (!TIFFFetchShortArray(tif, dir, (uint16*) v)) - return (0); - if (dir->tdir_type == TIFF_SHORT) { - uint16* vp = (uint16*) v; - for (i = dir->tdir_count-1; i >= 0; i--) - v[i] = vp[i]; - } else { - int16* vp = (int16*) v; - for (i = dir->tdir_count-1; i >= 0; i--) - v[i] = vp[i]; - } - break; - case TIFF_LONG: - case TIFF_SLONG: - if (!TIFFFetchLongArray(tif, dir, (uint32*) v)) - return (0); - if (dir->tdir_type == TIFF_LONG) { - uint32* vp = (uint32*) v; - for (i = dir->tdir_count-1; i >= 0; i--) - v[i] = vp[i]; - } else { - int32* vp = (int32*) v; - for (i = dir->tdir_count-1; i >= 0; i--) - v[i] = vp[i]; - } - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - if (!TIFFFetchRationalArray(tif, dir, (float*) v)) - return (0); - { float* vp = (float*) v; - for (i = dir->tdir_count-1; i >= 0; i--) - v[i] = vp[i]; - } - break; - case TIFF_FLOAT: - if (!TIFFFetchFloatArray(tif, dir, (float*) v)) - return (0); - { float* vp = (float*) v; - for (i = dir->tdir_count-1; i >= 0; i--) - v[i] = vp[i]; - } - break; - case TIFF_DOUBLE: - return (TIFFFetchDoubleArray(tif, dir, (double*) v)); - default: - /* TIFF_NOTYPE */ - /* TIFF_ASCII */ - /* TIFF_UNDEFINED */ - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "cannot read TIFF_ANY type %d for field \"%s\"", - dir->tdir_type, - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); - return (0); - } - return (1); -} - -/* - * Fetch a tag that is not handled by special case code. - */ -static int -TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp) -{ - static const char mesg[] = "to fetch tag value"; - int ok = 0; - const TIFFFieldInfo* fip = _TIFFFieldWithTag(tif, dp->tdir_tag); - - if (dp->tdir_count > 1) { /* array of values */ - char* cp = NULL; - - switch (dp->tdir_type) { - case TIFF_BYTE: - case TIFF_SBYTE: - cp = (char *)_TIFFCheckMalloc(tif, - dp->tdir_count, sizeof (uint8), mesg); - ok = cp && TIFFFetchByteArray(tif, dp, (uint8*) cp); - break; - case TIFF_SHORT: - case TIFF_SSHORT: - cp = (char *)_TIFFCheckMalloc(tif, - dp->tdir_count, sizeof (uint16), mesg); - ok = cp && TIFFFetchShortArray(tif, dp, (uint16*) cp); - break; - case TIFF_LONG: - case TIFF_SLONG: - cp = (char *)_TIFFCheckMalloc(tif, - dp->tdir_count, sizeof (uint32), mesg); - ok = cp && TIFFFetchLongArray(tif, dp, (uint32*) cp); - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - cp = (char *)_TIFFCheckMalloc(tif, - dp->tdir_count, sizeof (float), mesg); - ok = cp && TIFFFetchRationalArray(tif, dp, (float*) cp); - break; - case TIFF_FLOAT: - cp = (char *)_TIFFCheckMalloc(tif, - dp->tdir_count, sizeof (float), mesg); - ok = cp && TIFFFetchFloatArray(tif, dp, (float*) cp); - break; - case TIFF_DOUBLE: - cp = (char *)_TIFFCheckMalloc(tif, - dp->tdir_count, sizeof (double), mesg); - ok = cp && TIFFFetchDoubleArray(tif, dp, (double*) cp); - break; - case TIFF_ASCII: - case TIFF_UNDEFINED: /* bit of a cheat... */ - /* - * Some vendors write strings w/o the trailing - * NULL byte, so always append one just in case. - */ - cp = (char *)_TIFFCheckMalloc(tif, dp->tdir_count + 1, - 1, mesg); - if ( (ok = (cp && TIFFFetchString(tif, dp, cp))) != 0 ) - cp[dp->tdir_count] = '\0'; /* XXX */ - break; - } - if (ok) { - ok = (fip->field_passcount ? - TIFFSetField(tif, dp->tdir_tag, dp->tdir_count, cp) - : TIFFSetField(tif, dp->tdir_tag, cp)); - } - if (cp != NULL) - _TIFFfree(cp); - } else if (CheckDirCount(tif, dp, 1)) { /* singleton value */ - switch (dp->tdir_type) { - case TIFF_BYTE: - case TIFF_SBYTE: - case TIFF_SHORT: - case TIFF_SSHORT: - /* - * If the tag is also acceptable as a LONG or SLONG - * then TIFFSetField will expect an uint32 parameter - * passed to it (through varargs). Thus, for machines - * where sizeof (int) != sizeof (uint32) we must do - * a careful check here. It's hard to say if this - * is worth optimizing. - * - * NB: We use TIFFFieldWithTag here knowing that - * it returns us the first entry in the table - * for the tag and that that entry is for the - * widest potential data type the tag may have. - */ - { TIFFDataType type = fip->field_type; - if (type != TIFF_LONG && type != TIFF_SLONG) { - uint16 v = (uint16) - TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset); - ok = (fip->field_passcount ? - TIFFSetField(tif, dp->tdir_tag, 1, &v) - : TIFFSetField(tif, dp->tdir_tag, v)); - break; - } - } - /* fall thru... */ - case TIFF_LONG: - case TIFF_SLONG: - { uint32 v32 = - TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset); - ok = (fip->field_passcount ? - TIFFSetField(tif, dp->tdir_tag, 1, &v32) - : TIFFSetField(tif, dp->tdir_tag, v32)); - } - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - case TIFF_FLOAT: - { float v = (dp->tdir_type == TIFF_FLOAT ? - TIFFFetchFloat(tif, dp) - : TIFFFetchRational(tif, dp)); - ok = (fip->field_passcount ? - TIFFSetField(tif, dp->tdir_tag, 1, &v) - : TIFFSetField(tif, dp->tdir_tag, v)); - } - break; - case TIFF_DOUBLE: - { double v; - ok = (TIFFFetchDoubleArray(tif, dp, &v) && - (fip->field_passcount ? - TIFFSetField(tif, dp->tdir_tag, 1, &v) - : TIFFSetField(tif, dp->tdir_tag, v)) - ); - } - break; - case TIFF_ASCII: - case TIFF_UNDEFINED: /* bit of a cheat... */ - { char c[2]; - if ( (ok = (TIFFFetchString(tif, dp, c) != 0)) != 0 ) { - c[1] = '\0'; /* XXX paranoid */ - ok = (fip->field_passcount ? - TIFFSetField(tif, dp->tdir_tag, 1, c) - : TIFFSetField(tif, dp->tdir_tag, c)); - } - } - break; - } - } - return (ok); -} - -#define NITEMS(x) (sizeof (x) / sizeof (x[0])) -/* - * Fetch samples/pixel short values for - * the specified tag and verify that - * all values are the same. - */ -static int -TIFFFetchPerSampleShorts(TIFF* tif, TIFFDirEntry* dir, uint16* pl) -{ - uint16 samples = tif->tif_dir.td_samplesperpixel; - int status = 0; - - if (CheckDirCount(tif, dir, (uint32) samples)) { - uint16 buf[10]; - uint16* v = buf; - - if (dir->tdir_count > NITEMS(buf)) - v = (uint16*) _TIFFCheckMalloc(tif, dir->tdir_count, sizeof(uint16), - "to fetch per-sample values"); - if (v && TIFFFetchShortArray(tif, dir, v)) { - uint16 i; - int check_count = dir->tdir_count; - if ( samples < check_count ) - check_count = samples; - - for (i = 1; i < check_count; i++) - if (v[i] != v[0]) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Cannot handle different per-sample values for field \"%s\"", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); - goto bad; - } - *pl = v[0]; - status = 1; - } - bad: - if (v && v != buf) - _TIFFfree(v); - } - return (status); -} - -/* - * Fetch samples/pixel long values for - * the specified tag and verify that - * all values are the same. - */ -static int -TIFFFetchPerSampleLongs(TIFF* tif, TIFFDirEntry* dir, uint32* pl) -{ - uint16 samples = tif->tif_dir.td_samplesperpixel; - int status = 0; - - if (CheckDirCount(tif, dir, (uint32) samples)) { - uint32 buf[10]; - uint32* v = buf; - - if (dir->tdir_count > NITEMS(buf)) - v = (uint32*) _TIFFCheckMalloc(tif, dir->tdir_count, sizeof(uint32), - "to fetch per-sample values"); - if (v && TIFFFetchLongArray(tif, dir, v)) { - uint16 i; - int check_count = dir->tdir_count; - - if ( samples < check_count ) - check_count = samples; - for (i = 1; i < check_count; i++) - if (v[i] != v[0]) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Cannot handle different per-sample values for field \"%s\"", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); - goto bad; - } - *pl = v[0]; - status = 1; - } - bad: - if (v && v != buf) - _TIFFfree(v); - } - return (status); -} - -/* - * Fetch samples/pixel ANY values for the specified tag and returns their min - * and max. - */ -static int -TIFFFetchPerSampleAnys(TIFF* tif, TIFFDirEntry* dir, double* minv, double* maxv) -{ - uint16 samples = tif->tif_dir.td_samplesperpixel; - int status = 0; - - if (CheckDirCount(tif, dir, (uint32) samples)) { - double buf[10]; - double* v = buf; - - if (dir->tdir_count > NITEMS(buf)) - v = (double*) _TIFFCheckMalloc(tif, dir->tdir_count, sizeof (double), - "to fetch per-sample values"); - if (v && TIFFFetchAnyArray(tif, dir, v)) { - uint16 i; - int check_count = dir->tdir_count; - if ( samples < check_count ) - check_count = samples; - - *minv = *maxv = v[0]; - for (i = 1; i < check_count; i++) - { - if (v[i] < *minv) - *minv = v[i]; - if (v[i] > *maxv) - *maxv = v[i]; - } - status = 1; - } - if (v && v != buf) - _TIFFfree(v); - } - return (status); -} -#undef NITEMS - -/* - * Fetch a set of offsets or lengths. - * While this routine says "strips", in fact it's also used for tiles. - */ -static int -TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, long nstrips, uint32** lpp) -{ - register uint32* lp; - int status; - - CheckDirCount(tif, dir, (uint32) nstrips); - - /* - * Allocate space for strip information. - */ - if (*lpp == NULL && - (*lpp = (uint32 *)_TIFFCheckMalloc(tif, - nstrips, sizeof (uint32), "for strip array")) == NULL) - return (0); - lp = *lpp; - _TIFFmemset( lp, 0, sizeof(uint32) * nstrips ); - - if (dir->tdir_type == (int)TIFF_SHORT) { - /* - * Handle uint16->uint32 expansion. - */ - uint16* dp = (uint16*) _TIFFCheckMalloc(tif, - dir->tdir_count, sizeof (uint16), "to fetch strip tag"); - if (dp == NULL) - return (0); - if ( (status = TIFFFetchShortArray(tif, dir, dp)) != 0 ) { - int i; - - for ( i = 0; i < nstrips && i < (int) dir->tdir_count; i++ ) - { - lp[i] = dp[i]; - } - } - _TIFFfree((char*) dp); - - } else if ( nstrips != (int) dir->tdir_count ) { - /* Special case to correct length */ - - uint32* dp = (uint32*) _TIFFCheckMalloc(tif, - dir->tdir_count, sizeof (uint32), "to fetch strip tag"); - if (dp == NULL) - return (0); - - status = TIFFFetchLongArray(tif, dir, dp); - if ( status != 0 ) { - int i; - - for ( i = 0; i < nstrips && i < (int) dir->tdir_count; i++ ) - { - lp[i] = dp[i]; - } - } - - _TIFFfree( (char *) dp ); - } else - status = TIFFFetchLongArray(tif, dir, lp); - - return (status); -} - -/* - * Fetch and set the RefBlackWhite tag. - */ -static int -TIFFFetchRefBlackWhite(TIFF* tif, TIFFDirEntry* dir) -{ - static const char mesg[] = "for \"ReferenceBlackWhite\" array"; - char* cp; - int ok; - - if (dir->tdir_type == TIFF_RATIONAL) - return (TIFFFetchNormalTag(tif, dir)); - /* - * Handle LONG's for backward compatibility. - */ - cp = (char *)_TIFFCheckMalloc(tif, dir->tdir_count, - sizeof (uint32), mesg); - if ( (ok = (cp && TIFFFetchLongArray(tif, dir, (uint32*) cp))) != 0) { - float* fp = (float*) - _TIFFCheckMalloc(tif, dir->tdir_count, sizeof (float), mesg); - if ( (ok = (fp != NULL)) != 0 ) { - uint32 i; - for (i = 0; i < dir->tdir_count; i++) - fp[i] = (float)((uint32*) cp)[i]; - ok = TIFFSetField(tif, dir->tdir_tag, fp); - _TIFFfree((char*) fp); - } - } - if (cp) - _TIFFfree(cp); - return (ok); -} - -/* - * Fetch and set the SubjectDistance EXIF tag. - */ -static int -TIFFFetchSubjectDistance(TIFF* tif, TIFFDirEntry* dir) -{ - uint32 l[2]; - float v; - int ok = 0; - - if ( dir->tdir_count != 1 || dir->tdir_type != TIFF_RATIONAL ) - { - TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "incorrect count or type for SubjectDistance, tag ignored" ); - return (0); - } - - if (TIFFFetchData(tif, dir, (char *)l) - && cvtRational(tif, dir, l[0], l[1], &v)) { - /* - * XXX: Numerator 0xFFFFFFFF means that we have infinite - * distance. Indicate that with a negative floating point - * SubjectDistance value. - */ - ok = TIFFSetField(tif, dir->tdir_tag, - (l[0] != 0xFFFFFFFF) ? v : -v); - } - - return ok; -} - -/* - * Replace a single strip (tile) of uncompressed data by multiple strips - * (tiles), each approximately STRIP_SIZE_DEFAULT bytes. This is useful for - * dealing with large images or for dealing with machines with a limited - * amount memory. - */ -static void -ChopUpSingleUncompressedStrip(TIFF* tif) -{ - register TIFFDirectory *td = &tif->tif_dir; - uint32 bytecount = td->td_stripbytecount[0]; - uint32 offset = td->td_stripoffset[0]; - tsize_t rowbytes = TIFFVTileSize(tif, 1), stripbytes; - tstrip_t strip, nstrips, rowsperstrip; - uint32* newcounts; - uint32* newoffsets; - - /* - * Make the rows hold at least one scanline, but fill specified amount - * of data if possible. - */ - if (rowbytes > STRIP_SIZE_DEFAULT) { - stripbytes = rowbytes; - rowsperstrip = 1; - } else if (rowbytes > 0 ) { - rowsperstrip = STRIP_SIZE_DEFAULT / rowbytes; - stripbytes = rowbytes * rowsperstrip; - } - else - return; - - /* - * never increase the number of strips in an image - */ - if (rowsperstrip >= td->td_rowsperstrip) - return; - nstrips = (tstrip_t) TIFFhowmany(bytecount, stripbytes); - if ( nstrips == 0 ) /* something is wonky, do nothing. */ - return; - - newcounts = (uint32*) _TIFFCheckMalloc(tif, nstrips, sizeof (uint32), - "for chopped \"StripByteCounts\" array"); - newoffsets = (uint32*) _TIFFCheckMalloc(tif, nstrips, sizeof (uint32), - "for chopped \"StripOffsets\" array"); - if (newcounts == NULL || newoffsets == NULL) { - /* - * Unable to allocate new strip information, give up and use - * the original one strip information. - */ - if (newcounts != NULL) - _TIFFfree(newcounts); - if (newoffsets != NULL) - _TIFFfree(newoffsets); - return; - } - /* - * Fill the strip information arrays with new bytecounts and offsets - * that reflect the broken-up format. - */ - for (strip = 0; strip < nstrips; strip++) { - if ((uint32)stripbytes > bytecount) - stripbytes = bytecount; - newcounts[strip] = stripbytes; - newoffsets[strip] = offset; - offset += stripbytes; - bytecount -= stripbytes; - } - /* - * Replace old single strip info with multi-strip info. - */ - td->td_stripsperimage = td->td_nstrips = nstrips; - TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip); - - _TIFFfree(td->td_stripbytecount); - _TIFFfree(td->td_stripoffset); - td->td_stripbytecount = newcounts; - td->td_stripoffset = newoffsets; - td->td_stripbytecountsorted = 1; -} - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_dirwrite.c b/plugins/AdvaImg/src/LibTIFF/tif_dirwrite.c deleted file mode 100644 index 962937298e..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_dirwrite.c +++ /dev/null @@ -1,1436 +0,0 @@ -/* $Id: tif_dirwrite.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Directory Write Support Routines. - */ -#include "tiffiop.h" - -#ifdef HAVE_IEEEFP -# define TIFFCvtNativeToIEEEFloat(tif, n, fp) -# define TIFFCvtNativeToIEEEDouble(tif, n, dp) -#else -extern void TIFFCvtNativeToIEEEFloat(TIFF*, uint32, float*); -extern void TIFFCvtNativeToIEEEDouble(TIFF*, uint32, double*); -#endif - -static int TIFFWriteNormalTag(TIFF*, TIFFDirEntry*, const TIFFFieldInfo*); -static void TIFFSetupShortLong(TIFF*, ttag_t, TIFFDirEntry*, uint32); -static void TIFFSetupShort(TIFF*, ttag_t, TIFFDirEntry*, uint16); -static int TIFFSetupBytePair(TIFF*, ttag_t, TIFFDirEntry*); -static int TIFFSetupShortPair(TIFF*, ttag_t, TIFFDirEntry*); -static int TIFFWritePerSampleShorts(TIFF*, ttag_t, TIFFDirEntry*); -static int TIFFWritePerSampleAnys(TIFF*, TIFFDataType, ttag_t, TIFFDirEntry*); -static int TIFFWriteShortTable(TIFF*, ttag_t, TIFFDirEntry*, uint32, uint16**); -static int TIFFWriteShortArray(TIFF*, TIFFDirEntry*, uint16*); -static int TIFFWriteLongArray(TIFF *, TIFFDirEntry*, uint32*); -static int TIFFWriteRationalArray(TIFF *, TIFFDirEntry*, float*); -static int TIFFWriteFloatArray(TIFF *, TIFFDirEntry*, float*); -static int TIFFWriteDoubleArray(TIFF *, TIFFDirEntry*, double*); -static int TIFFWriteByteArray(TIFF*, TIFFDirEntry*, char*); -static int TIFFWriteAnyArray(TIFF*, - TIFFDataType, ttag_t, TIFFDirEntry*, uint32, double*); -static int TIFFWriteTransferFunction(TIFF*, TIFFDirEntry*); -static int TIFFWriteInkNames(TIFF*, TIFFDirEntry*); -static int TIFFWriteData(TIFF*, TIFFDirEntry*, char*); -static int TIFFLinkDirectory(TIFF*); - -#define WriteRationalPair(type, tag1, v1, tag2, v2) { \ - TIFFWriteRational((tif), (type), (tag1), (dir), (v1)) \ - TIFFWriteRational((tif), (type), (tag2), (dir)+1, (v2)) \ - (dir)++; \ -} -#define TIFFWriteRational(tif, type, tag, dir, v) \ - (dir)->tdir_tag = (tag); \ - (dir)->tdir_type = (type); \ - (dir)->tdir_count = 1; \ - if (!TIFFWriteRationalArray((tif), (dir), &(v))) \ - goto bad; - -/* - * Write the contents of the current directory - * to the specified file. This routine doesn't - * handle overwriting a directory with auxiliary - * storage that's been changed. - */ -static int -_TIFFWriteDirectory(TIFF* tif, int done) -{ - uint16 dircount; - toff_t diroff; - ttag_t tag; - uint32 nfields; - tsize_t dirsize; - char* data; - TIFFDirEntry* dir; - TIFFDirectory* td; - unsigned long b, fields[FIELD_SETLONGS]; - int fi, nfi; - - if (tif->tif_mode == O_RDONLY) - return (1); - /* - * Clear write state so that subsequent images with - * different characteristics get the right buffers - * setup for them. - */ - if (done) - { - if (tif->tif_flags & TIFF_POSTENCODE) { - tif->tif_flags &= ~TIFF_POSTENCODE; - if (!(*tif->tif_postencode)(tif)) { - TIFFErrorExt(tif->tif_clientdata, - tif->tif_name, - "Error post-encoding before directory write"); - return (0); - } - } - (*tif->tif_close)(tif); /* shutdown encoder */ - /* - * Flush any data that might have been written - * by the compression close+cleanup routines. - */ - if (tif->tif_rawcc > 0 - && (tif->tif_flags & TIFF_BEENWRITING) != 0 - && !TIFFFlushData1(tif)) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Error flushing data before directory write"); - return (0); - } - if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) { - _TIFFfree(tif->tif_rawdata); - tif->tif_rawdata = NULL; - tif->tif_rawcc = 0; - tif->tif_rawdatasize = 0; - } - tif->tif_flags &= ~(TIFF_BEENWRITING|TIFF_BUFFERSETUP); - } - - td = &tif->tif_dir; - /* - * Size the directory so that we can calculate - * offsets for the data items that aren't kept - * in-place in each field. - */ - nfields = 0; - for (b = 0; b <= FIELD_LAST; b++) - if (TIFFFieldSet(tif, b) && b != FIELD_CUSTOM) - nfields += (b < FIELD_SUBFILETYPE ? 2 : 1); - nfields += td->td_customValueCount; - dirsize = nfields * sizeof (TIFFDirEntry); - data = (char*) _TIFFmalloc(dirsize); - if (data == NULL) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Cannot write directory, out of space"); - return (0); - } - /* - * Directory hasn't been placed yet, put - * it at the end of the file and link it - * into the existing directory structure. - */ - if (tif->tif_diroff == 0 && !TIFFLinkDirectory(tif)) - goto bad; - tif->tif_dataoff = (toff_t)( - tif->tif_diroff + sizeof (uint16) + dirsize + sizeof (toff_t)); - if (tif->tif_dataoff & 1) - tif->tif_dataoff++; - (void) TIFFSeekFile(tif, tif->tif_dataoff, SEEK_SET); - tif->tif_curdir++; - dir = (TIFFDirEntry*) data; - /* - * Setup external form of directory - * entries and write data items. - */ - _TIFFmemcpy(fields, td->td_fieldsset, sizeof (fields)); - /* - * Write out ExtraSamples tag only if - * extra samples are present in the data. - */ - if (FieldSet(fields, FIELD_EXTRASAMPLES) && !td->td_extrasamples) { - ResetFieldBit(fields, FIELD_EXTRASAMPLES); - nfields--; - dirsize -= sizeof (TIFFDirEntry); - } /*XXX*/ - for (fi = 0, nfi = tif->tif_nfields; nfi > 0; nfi--, fi++) { - const TIFFFieldInfo* fip = tif->tif_fieldinfo[fi]; - - /* - * For custom fields, we test to see if the custom field - * is set or not. For normal fields, we just use the - * FieldSet test. - */ - if ( fip->field_bit == FIELD_CUSTOM ) - { - int ci, is_set = FALSE; - - for ( ci = 0; ci < td->td_customValueCount; ci++ ) - is_set |= (td->td_customValues[ci].info == fip); - - if ( !is_set ) - continue; - } - else if (!FieldSet(fields, fip->field_bit)) - continue; - - /* - * Handle other fields. - */ - switch (fip->field_bit) - { - case FIELD_STRIPOFFSETS: - /* - * We use one field bit for both strip and tile - - * offsets, and so must be careful in selecting - * the appropriate field descriptor (so that tags - * are written in sorted order). - */ - tag = isTiled(tif) ? - TIFFTAG_TILEOFFSETS : TIFFTAG_STRIPOFFSETS; - if (tag != fip->field_tag) - continue; - - dir->tdir_tag = (uint16) tag; - dir->tdir_type = (uint16) TIFF_LONG; - dir->tdir_count = (uint32) td->td_nstrips; - if (!TIFFWriteLongArray(tif, dir, td->td_stripoffset)) - goto bad; - break; - case FIELD_STRIPBYTECOUNTS: - /* - * We use one field bit for both strip and tile - * byte counts, and so must be careful in selecting - * the appropriate field descriptor (so that tags - * are written in sorted order). - */ - tag = isTiled(tif) ? - TIFFTAG_TILEBYTECOUNTS : TIFFTAG_STRIPBYTECOUNTS; - if (tag != fip->field_tag) - continue; - - dir->tdir_tag = (uint16) tag; - dir->tdir_type = (uint16) TIFF_LONG; - dir->tdir_count = (uint32) td->td_nstrips; - if (!TIFFWriteLongArray(tif, dir, td->td_stripbytecount)) - goto bad; - break; - case FIELD_ROWSPERSTRIP: - TIFFSetupShortLong(tif, TIFFTAG_ROWSPERSTRIP, - dir, td->td_rowsperstrip); - break; - case FIELD_COLORMAP: - if (!TIFFWriteShortTable(tif, TIFFTAG_COLORMAP, dir, - 3, td->td_colormap)) - goto bad; - break; - case FIELD_IMAGEDIMENSIONS: - TIFFSetupShortLong(tif, TIFFTAG_IMAGEWIDTH, - dir++, td->td_imagewidth); - TIFFSetupShortLong(tif, TIFFTAG_IMAGELENGTH, - dir, td->td_imagelength); - break; - case FIELD_TILEDIMENSIONS: - TIFFSetupShortLong(tif, TIFFTAG_TILEWIDTH, - dir++, td->td_tilewidth); - TIFFSetupShortLong(tif, TIFFTAG_TILELENGTH, - dir, td->td_tilelength); - break; - case FIELD_COMPRESSION: - TIFFSetupShort(tif, TIFFTAG_COMPRESSION, - dir, td->td_compression); - break; - case FIELD_PHOTOMETRIC: - TIFFSetupShort(tif, TIFFTAG_PHOTOMETRIC, - dir, td->td_photometric); - break; - case FIELD_POSITION: - WriteRationalPair(TIFF_RATIONAL, - TIFFTAG_XPOSITION, td->td_xposition, - TIFFTAG_YPOSITION, td->td_yposition); - break; - case FIELD_RESOLUTION: - WriteRationalPair(TIFF_RATIONAL, - TIFFTAG_XRESOLUTION, td->td_xresolution, - TIFFTAG_YRESOLUTION, td->td_yresolution); - break; - case FIELD_BITSPERSAMPLE: - case FIELD_MINSAMPLEVALUE: - case FIELD_MAXSAMPLEVALUE: - case FIELD_SAMPLEFORMAT: - if (!TIFFWritePerSampleShorts(tif, fip->field_tag, dir)) - goto bad; - break; - case FIELD_SMINSAMPLEVALUE: - case FIELD_SMAXSAMPLEVALUE: - if (!TIFFWritePerSampleAnys(tif, - _TIFFSampleToTagType(tif), fip->field_tag, dir)) - goto bad; - break; - case FIELD_INKNAMES: - if (!TIFFWriteInkNames(tif, dir)) - goto bad; - break; - case FIELD_TRANSFERFUNCTION: - if (!TIFFWriteTransferFunction(tif, dir)) - goto bad; - break; - case FIELD_SUBIFD: - /* - * XXX: Always write this field using LONG type - * for backward compatibility. - */ - dir->tdir_tag = (uint16) fip->field_tag; - dir->tdir_type = (uint16) TIFF_LONG; - dir->tdir_count = (uint32) td->td_nsubifd; - if (!TIFFWriteLongArray(tif, dir, td->td_subifd)) - goto bad; - /* - * Total hack: if this directory includes a SubIFD - * tag then force the next directories to be - * written as ``sub directories'' of this one. This - * is used to write things like thumbnails and - * image masks that one wants to keep out of the - * normal directory linkage access mechanism. - */ - if (dir->tdir_count > 0) { - tif->tif_flags |= TIFF_INSUBIFD; - tif->tif_nsubifd = (uint16) dir->tdir_count; - if (dir->tdir_count > 1) - tif->tif_subifdoff = dir->tdir_offset; - else - tif->tif_subifdoff = (uint32)( - tif->tif_diroff - + sizeof (uint16) - + ((char*)&dir->tdir_offset-data)); - } - break; - default: - /* - * XXX: Should be fixed and removed. See comments - * related to these tags in tif_dir.c. - */ - if (fip->field_tag == TIFFTAG_PAGENUMBER - || fip->field_tag == TIFFTAG_HALFTONEHINTS - || fip->field_tag == TIFFTAG_YCBCRSUBSAMPLING - || fip->field_tag == TIFFTAG_DOTRANGE) { - if (fip->field_type == TIFF_BYTE) { - if (!TIFFSetupBytePair(tif, fip->field_tag, dir)) - goto bad; - } else if (fip->field_type == TIFF_SHORT) { - if (!TIFFSetupShortPair(tif, fip->field_tag, dir)) - goto bad; - } - } else if (!TIFFWriteNormalTag(tif, dir, fip)) - goto bad; - break; - } - dir++; - - if ( fip->field_bit != FIELD_CUSTOM ) - ResetFieldBit(fields, fip->field_bit); - } - - /* - * Write directory. - */ - dircount = (uint16) nfields; - diroff = (uint32) tif->tif_nextdiroff; - if (tif->tif_flags & TIFF_SWAB) { - /* - * The file's byte order is opposite to the - * native machine architecture. We overwrite - * the directory information with impunity - * because it'll be released below after we - * write it to the file. Note that all the - * other tag construction routines assume that - * we do this byte-swapping; i.e. they only - * byte-swap indirect data. - */ - for (dir = (TIFFDirEntry*) data; dircount; dir++, dircount--) { - TIFFSwabArrayOfShort(&dir->tdir_tag, 2); - TIFFSwabArrayOfLong(&dir->tdir_count, 2); - } - dircount = (uint16) nfields; - TIFFSwabShort(&dircount); - TIFFSwabLong(&diroff); - } - (void) TIFFSeekFile(tif, tif->tif_diroff, SEEK_SET); - if (!WriteOK(tif, &dircount, sizeof (dircount))) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Error writing directory count"); - goto bad; - } - if (!WriteOK(tif, data, dirsize)) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Error writing directory contents"); - goto bad; - } - if (!WriteOK(tif, &diroff, sizeof (uint32))) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Error writing directory link"); - goto bad; - } - if (done) { - TIFFFreeDirectory(tif); - tif->tif_flags &= ~TIFF_DIRTYDIRECT; - (*tif->tif_cleanup)(tif); - - /* - * Reset directory-related state for subsequent - * directories. - */ - TIFFCreateDirectory(tif); - } - _TIFFfree(data); - return (1); -bad: - _TIFFfree(data); - return (0); -} -#undef WriteRationalPair - -int -TIFFWriteDirectory(TIFF* tif) -{ - return _TIFFWriteDirectory(tif, TRUE); -} - -/* - * Similar to TIFFWriteDirectory(), writes the directory out - * but leaves all data structures in memory so that it can be - * written again. This will make a partially written TIFF file - * readable before it is successfully completed/closed. - */ -int -TIFFCheckpointDirectory(TIFF* tif) -{ - int rc; - /* Setup the strips arrays, if they haven't already been. */ - if (tif->tif_dir.td_stripoffset == NULL) - (void) TIFFSetupStrips(tif); - rc = _TIFFWriteDirectory(tif, FALSE); - (void) TIFFSetWriteOffset(tif, TIFFSeekFile(tif, 0, SEEK_END)); - return rc; -} - -static int -_TIFFWriteCustomDirectory(TIFF* tif, toff_t *pdiroff) -{ - uint16 dircount; - uint32 nfields; - tsize_t dirsize; - char* data; - TIFFDirEntry* dir; - TIFFDirectory* td; - unsigned long b, fields[FIELD_SETLONGS]; - int fi, nfi; - - if (tif->tif_mode == O_RDONLY) - return (1); - - td = &tif->tif_dir; - /* - * Size the directory so that we can calculate - * offsets for the data items that aren't kept - * in-place in each field. - */ - nfields = 0; - for (b = 0; b <= FIELD_LAST; b++) - if (TIFFFieldSet(tif, b) && b != FIELD_CUSTOM) - nfields += (b < FIELD_SUBFILETYPE ? 2 : 1); - nfields += td->td_customValueCount; - dirsize = nfields * sizeof (TIFFDirEntry); - data = (char*) _TIFFmalloc(dirsize); - if (data == NULL) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Cannot write directory, out of space"); - return (0); - } - /* - * Put the directory at the end of the file. - */ - tif->tif_diroff = (TIFFSeekFile(tif, (toff_t) 0, SEEK_END)+1) &~ 1; - tif->tif_dataoff = (toff_t)( - tif->tif_diroff + sizeof (uint16) + dirsize + sizeof (toff_t)); - if (tif->tif_dataoff & 1) - tif->tif_dataoff++; - (void) TIFFSeekFile(tif, tif->tif_dataoff, SEEK_SET); - dir = (TIFFDirEntry*) data; - /* - * Setup external form of directory - * entries and write data items. - */ - _TIFFmemcpy(fields, td->td_fieldsset, sizeof (fields)); - - for (fi = 0, nfi = tif->tif_nfields; nfi > 0; nfi--, fi++) { - const TIFFFieldInfo* fip = tif->tif_fieldinfo[fi]; - - /* - * For custom fields, we test to see if the custom field - * is set or not. For normal fields, we just use the - * FieldSet test. - */ - if ( fip->field_bit == FIELD_CUSTOM ) - { - int ci, is_set = FALSE; - - for ( ci = 0; ci < td->td_customValueCount; ci++ ) - is_set |= (td->td_customValues[ci].info == fip); - - if ( !is_set ) - continue; - } - else if (!FieldSet(fields, fip->field_bit)) - continue; - - if ( fip->field_bit != FIELD_CUSTOM ) - ResetFieldBit(fields, fip->field_bit); - } - - /* - * Write directory. - */ - dircount = (uint16) nfields; - *pdiroff = (uint32) tif->tif_nextdiroff; - if (tif->tif_flags & TIFF_SWAB) { - /* - * The file's byte order is opposite to the - * native machine architecture. We overwrite - * the directory information with impunity - * because it'll be released below after we - * write it to the file. Note that all the - * other tag construction routines assume that - * we do this byte-swapping; i.e. they only - * byte-swap indirect data. - */ - for (dir = (TIFFDirEntry*) data; dircount; dir++, dircount--) { - TIFFSwabArrayOfShort(&dir->tdir_tag, 2); - TIFFSwabArrayOfLong(&dir->tdir_count, 2); - } - dircount = (uint16) nfields; - TIFFSwabShort(&dircount); - TIFFSwabLong(pdiroff); - } - (void) TIFFSeekFile(tif, tif->tif_diroff, SEEK_SET); - if (!WriteOK(tif, &dircount, sizeof (dircount))) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Error writing directory count"); - goto bad; - } - if (!WriteOK(tif, data, dirsize)) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Error writing directory contents"); - goto bad; - } - if (!WriteOK(tif, pdiroff, sizeof (uint32))) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Error writing directory link"); - goto bad; - } - _TIFFfree(data); - return (1); -bad: - _TIFFfree(data); - return (0); -} - -int -TIFFWriteCustomDirectory(TIFF* tif, toff_t *pdiroff) -{ - return _TIFFWriteCustomDirectory(tif, pdiroff); -} - -/* - * Process tags that are not special cased. - */ -static int -TIFFWriteNormalTag(TIFF* tif, TIFFDirEntry* dir, const TIFFFieldInfo* fip) -{ - uint16 wc = (uint16) fip->field_writecount; - uint32 wc2; - - dir->tdir_tag = (uint16) fip->field_tag; - dir->tdir_type = (uint16) fip->field_type; - dir->tdir_count = wc; - - switch (fip->field_type) { - case TIFF_SHORT: - case TIFF_SSHORT: - if (fip->field_passcount) { - uint16* wp; - if (wc == (uint16) TIFF_VARIABLE2) { - TIFFGetField(tif, fip->field_tag, &wc2, &wp); - dir->tdir_count = wc2; - } else { /* Assume TIFF_VARIABLE */ - TIFFGetField(tif, fip->field_tag, &wc, &wp); - dir->tdir_count = wc; - } - if (!TIFFWriteShortArray(tif, dir, wp)) - return 0; - } else { - if (wc == 1) { - uint16 sv; - TIFFGetField(tif, fip->field_tag, &sv); - dir->tdir_offset = - TIFFInsertData(tif, dir->tdir_type, sv); - } else { - uint16* wp; - TIFFGetField(tif, fip->field_tag, &wp); - if (!TIFFWriteShortArray(tif, dir, wp)) - return 0; - } - } - break; - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_IFD: - if (fip->field_passcount) { - uint32* lp; - if (wc == (uint16) TIFF_VARIABLE2) { - TIFFGetField(tif, fip->field_tag, &wc2, &lp); - dir->tdir_count = wc2; - } else { /* Assume TIFF_VARIABLE */ - TIFFGetField(tif, fip->field_tag, &wc, &lp); - dir->tdir_count = wc; - } - if (!TIFFWriteLongArray(tif, dir, lp)) - return 0; - } else { - if (wc == 1) { - /* XXX handle LONG->SHORT conversion */ - TIFFGetField(tif, fip->field_tag, - &dir->tdir_offset); - } else { - uint32* lp; - TIFFGetField(tif, fip->field_tag, &lp); - if (!TIFFWriteLongArray(tif, dir, lp)) - return 0; - } - } - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - if (fip->field_passcount) { - float* fp; - if (wc == (uint16) TIFF_VARIABLE2) { - TIFFGetField(tif, fip->field_tag, &wc2, &fp); - dir->tdir_count = wc2; - } else { /* Assume TIFF_VARIABLE */ - TIFFGetField(tif, fip->field_tag, &wc, &fp); - dir->tdir_count = wc; - } - if (!TIFFWriteRationalArray(tif, dir, fp)) - return 0; - } else { - if (wc == 1) { - float fv; - TIFFGetField(tif, fip->field_tag, &fv); - if (!TIFFWriteRationalArray(tif, dir, &fv)) - return 0; - } else { - float* fp; - TIFFGetField(tif, fip->field_tag, &fp); - if (!TIFFWriteRationalArray(tif, dir, fp)) - return 0; - } - } - break; - case TIFF_FLOAT: - if (fip->field_passcount) { - float* fp; - if (wc == (uint16) TIFF_VARIABLE2) { - TIFFGetField(tif, fip->field_tag, &wc2, &fp); - dir->tdir_count = wc2; - } else { /* Assume TIFF_VARIABLE */ - TIFFGetField(tif, fip->field_tag, &wc, &fp); - dir->tdir_count = wc; - } - if (!TIFFWriteFloatArray(tif, dir, fp)) - return 0; - } else { - if (wc == 1) { - float fv; - TIFFGetField(tif, fip->field_tag, &fv); - if (!TIFFWriteFloatArray(tif, dir, &fv)) - return 0; - } else { - float* fp; - TIFFGetField(tif, fip->field_tag, &fp); - if (!TIFFWriteFloatArray(tif, dir, fp)) - return 0; - } - } - break; - case TIFF_DOUBLE: - if (fip->field_passcount) { - double* dp; - if (wc == (uint16) TIFF_VARIABLE2) { - TIFFGetField(tif, fip->field_tag, &wc2, &dp); - dir->tdir_count = wc2; - } else { /* Assume TIFF_VARIABLE */ - TIFFGetField(tif, fip->field_tag, &wc, &dp); - dir->tdir_count = wc; - } - if (!TIFFWriteDoubleArray(tif, dir, dp)) - return 0; - } else { - if (wc == 1) { - double dv; - TIFFGetField(tif, fip->field_tag, &dv); - if (!TIFFWriteDoubleArray(tif, dir, &dv)) - return 0; - } else { - double* dp; - TIFFGetField(tif, fip->field_tag, &dp); - if (!TIFFWriteDoubleArray(tif, dir, dp)) - return 0; - } - } - break; - case TIFF_ASCII: - { - char* cp; - if (fip->field_passcount) - { - if ( wc == (uint16) TIFF_VARIABLE2 ) - TIFFGetField(tif, fip->field_tag, &wc2, &cp); - else - TIFFGetField(tif, fip->field_tag, &wc, &cp); - } - else - TIFFGetField(tif, fip->field_tag, &cp); - - dir->tdir_count = (uint32) (strlen(cp) + 1); - if (!TIFFWriteByteArray(tif, dir, cp)) - return (0); - } - break; - - case TIFF_BYTE: - case TIFF_SBYTE: - if (fip->field_passcount) { - char* cp; - if (wc == (uint16) TIFF_VARIABLE2) { - TIFFGetField(tif, fip->field_tag, &wc2, &cp); - dir->tdir_count = wc2; - } else { /* Assume TIFF_VARIABLE */ - TIFFGetField(tif, fip->field_tag, &wc, &cp); - dir->tdir_count = wc; - } - if (!TIFFWriteByteArray(tif, dir, cp)) - return 0; - } else { - if (wc == 1) { - char cv; - TIFFGetField(tif, fip->field_tag, &cv); - if (!TIFFWriteByteArray(tif, dir, &cv)) - return 0; - } else { - char* cp; - TIFFGetField(tif, fip->field_tag, &cp); - if (!TIFFWriteByteArray(tif, dir, cp)) - return 0; - } - } - break; - - case TIFF_UNDEFINED: - { char* cp; - if (wc == (unsigned short) TIFF_VARIABLE) { - TIFFGetField(tif, fip->field_tag, &wc, &cp); - dir->tdir_count = wc; - } else if (wc == (unsigned short) TIFF_VARIABLE2) { - TIFFGetField(tif, fip->field_tag, &wc2, &cp); - dir->tdir_count = wc2; - } else - TIFFGetField(tif, fip->field_tag, &cp); - if (!TIFFWriteByteArray(tif, dir, cp)) - return (0); - } - break; - - case TIFF_NOTYPE: - break; - } - return (1); -} - -/* - * Setup a directory entry with either a SHORT - * or LONG type according to the value. - */ -static void -TIFFSetupShortLong(TIFF* tif, ttag_t tag, TIFFDirEntry* dir, uint32 v) -{ - dir->tdir_tag = (uint16) tag; - dir->tdir_count = 1; - if (v > 0xffffL) { - dir->tdir_type = (short) TIFF_LONG; - dir->tdir_offset = v; - } else { - dir->tdir_type = (short) TIFF_SHORT; - dir->tdir_offset = TIFFInsertData(tif, (int) TIFF_SHORT, v); - } -} - -/* - * Setup a SHORT directory entry - */ -static void -TIFFSetupShort(TIFF* tif, ttag_t tag, TIFFDirEntry* dir, uint16 v) -{ - dir->tdir_tag = (uint16) tag; - dir->tdir_count = 1; - dir->tdir_type = (short) TIFF_SHORT; - dir->tdir_offset = TIFFInsertData(tif, (int) TIFF_SHORT, v); -} -#undef MakeShortDirent - -#define NITEMS(x) (sizeof (x) / sizeof (x[0])) -/* - * Setup a directory entry that references a - * samples/pixel array of SHORT values and - * (potentially) write the associated indirect - * values. - */ -static int -TIFFWritePerSampleShorts(TIFF* tif, ttag_t tag, TIFFDirEntry* dir) -{ - uint16 buf[10], v; - uint16* w = buf; - uint16 i, samples = tif->tif_dir.td_samplesperpixel; - int status; - - if (samples > NITEMS(buf)) { - w = (uint16*) _TIFFmalloc(samples * sizeof (uint16)); - if (w == NULL) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "No space to write per-sample shorts"); - return (0); - } - } - TIFFGetField(tif, tag, &v); - for (i = 0; i < samples; i++) - w[i] = v; - - dir->tdir_tag = (uint16) tag; - dir->tdir_type = (uint16) TIFF_SHORT; - dir->tdir_count = samples; - status = TIFFWriteShortArray(tif, dir, w); - if (w != buf) - _TIFFfree((char*) w); - return (status); -} - -/* - * Setup a directory entry that references a samples/pixel array of ``type'' - * values and (potentially) write the associated indirect values. The source - * data from TIFFGetField() for the specified tag must be returned as double. - */ -static int -TIFFWritePerSampleAnys(TIFF* tif, - TIFFDataType type, ttag_t tag, TIFFDirEntry* dir) -{ - double buf[10], v; - double* w = buf; - uint16 i, samples = tif->tif_dir.td_samplesperpixel; - int status; - - if (samples > NITEMS(buf)) { - w = (double*) _TIFFmalloc(samples * sizeof (double)); - if (w == NULL) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "No space to write per-sample values"); - return (0); - } - } - TIFFGetField(tif, tag, &v); - for (i = 0; i < samples; i++) - w[i] = v; - status = TIFFWriteAnyArray(tif, type, tag, dir, samples, w); - if (w != buf) - _TIFFfree(w); - return (status); -} -#undef NITEMS - -/* - * Setup a pair of bytes that are returned by - * value, rather than as a reference to an array. - */ -static int -TIFFSetupBytePair(TIFF* tif, ttag_t tag, TIFFDirEntry* dir) -{ - char v[2]; - - TIFFGetField(tif, tag, &v[0], &v[1]); - - dir->tdir_tag = (uint16) tag; - dir->tdir_type = (uint16) TIFF_BYTE; - dir->tdir_count = 2; - return (TIFFWriteByteArray(tif, dir, v)); -} - -/* - * Setup a pair of shorts that are returned by - * value, rather than as a reference to an array. - */ -static int -TIFFSetupShortPair(TIFF* tif, ttag_t tag, TIFFDirEntry* dir) -{ - uint16 v[2]; - - TIFFGetField(tif, tag, &v[0], &v[1]); - - dir->tdir_tag = (uint16) tag; - dir->tdir_type = (uint16) TIFF_SHORT; - dir->tdir_count = 2; - return (TIFFWriteShortArray(tif, dir, v)); -} - -/* - * Setup a directory entry for an NxM table of shorts, - * where M is known to be 2**bitspersample, and write - * the associated indirect data. - */ -static int -TIFFWriteShortTable(TIFF* tif, - ttag_t tag, TIFFDirEntry* dir, uint32 n, uint16** table) -{ - uint32 i, off; - - dir->tdir_tag = (uint16) tag; - dir->tdir_type = (short) TIFF_SHORT; - /* XXX -- yech, fool TIFFWriteData */ - dir->tdir_count = (uint32) (1L<tif_dir.td_bitspersample); - off = tif->tif_dataoff; - for (i = 0; i < n; i++) - if (!TIFFWriteData(tif, dir, (char *)table[i])) - return (0); - dir->tdir_count *= n; - dir->tdir_offset = off; - return (1); -} - -/* - * Write/copy data associated with an ASCII or opaque tag value. - */ -static int -TIFFWriteByteArray(TIFF* tif, TIFFDirEntry* dir, char* cp) -{ - if (dir->tdir_count <= 4) { - if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) { - dir->tdir_offset = (uint32)cp[0] << 24; - if (dir->tdir_count >= 2) - dir->tdir_offset |= (uint32)cp[1] << 16; - if (dir->tdir_count >= 3) - dir->tdir_offset |= (uint32)cp[2] << 8; - if (dir->tdir_count == 4) - dir->tdir_offset |= cp[3]; - } else { - dir->tdir_offset = cp[0]; - if (dir->tdir_count >= 2) - dir->tdir_offset |= (uint32) cp[1] << 8; - if (dir->tdir_count >= 3) - dir->tdir_offset |= (uint32) cp[2] << 16; - if (dir->tdir_count == 4) - dir->tdir_offset |= (uint32) cp[3] << 24; - } - return 1; - } else - return TIFFWriteData(tif, dir, cp); -} - -/* - * Setup a directory entry of an array of SHORT - * or SSHORT and write the associated indirect values. - */ -static int -TIFFWriteShortArray(TIFF* tif, TIFFDirEntry* dir, uint16* v) -{ - if (dir->tdir_count <= 2) { - if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) { - dir->tdir_offset = (uint32) v[0] << 16; - if (dir->tdir_count == 2) - dir->tdir_offset |= v[1] & 0xffff; - } else { - dir->tdir_offset = v[0] & 0xffff; - if (dir->tdir_count == 2) - dir->tdir_offset |= (uint32) v[1] << 16; - } - return (1); - } else - return (TIFFWriteData(tif, dir, (char*) v)); -} - -/* - * Setup a directory entry of an array of LONG - * or SLONG and write the associated indirect values. - */ -static int -TIFFWriteLongArray(TIFF* tif, TIFFDirEntry* dir, uint32* v) -{ - if (dir->tdir_count == 1) { - dir->tdir_offset = v[0]; - return (1); - } else - return (TIFFWriteData(tif, dir, (char*) v)); -} - -/* - * Setup a directory entry of an array of RATIONAL - * or SRATIONAL and write the associated indirect values. - */ -static int -TIFFWriteRationalArray(TIFF* tif, TIFFDirEntry* dir, float* v) -{ - uint32 i; - uint32* t; - int status; - - t = (uint32*) _TIFFmalloc(2 * dir->tdir_count * sizeof (uint32)); - if (t == NULL) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "No space to write RATIONAL array"); - return (0); - } - for (i = 0; i < dir->tdir_count; i++) { - float fv = v[i]; - int sign = 1; - uint32 den; - - if (fv < 0) { - if (dir->tdir_type == TIFF_RATIONAL) { - TIFFWarningExt(tif->tif_clientdata, - tif->tif_name, - "\"%s\": Information lost writing value (%g) as (unsigned) RATIONAL", - _TIFFFieldWithTag(tif,dir->tdir_tag)->field_name, - fv); - fv = 0; - } else - fv = -fv, sign = -1; - } - den = 1L; - if (fv > 0) { - while (fv < 1L<<(31-3) && den < 1L<<(31-3)) - fv *= 1<<3, den *= 1L<<3; - } - t[2*i+0] = (uint32) (sign * (int32)(fv + 0.5)); - t[2*i+1] = den; - } - status = TIFFWriteData(tif, dir, (char *)t); - _TIFFfree((char*) t); - return (status); -} - -static int -TIFFWriteFloatArray(TIFF* tif, TIFFDirEntry* dir, float* v) -{ - TIFFCvtNativeToIEEEFloat(tif, dir->tdir_count, v); - if (dir->tdir_count == 1) { - dir->tdir_offset = *(uint32*) &v[0]; - return (1); - } else - return (TIFFWriteData(tif, dir, (char*) v)); -} - -static int -TIFFWriteDoubleArray(TIFF* tif, TIFFDirEntry* dir, double* v) -{ - TIFFCvtNativeToIEEEDouble(tif, dir->tdir_count, v); - return (TIFFWriteData(tif, dir, (char*) v)); -} - -/* - * Write an array of ``type'' values for a specified tag (i.e. this is a tag - * which is allowed to have different types, e.g. SMaxSampleType). - * Internally the data values are represented as double since a double can - * hold any of the TIFF tag types (yes, this should really be an abstract - * type tany_t for portability). The data is converted into the specified - * type in a temporary buffer and then handed off to the appropriate array - * writer. - */ -static int -TIFFWriteAnyArray(TIFF* tif, - TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, double* v) -{ - char buf[10 * sizeof(double)]; - char* w = buf; - int i, status = 0; - - if (n * TIFFDataWidth(type) > sizeof buf) { - w = (char*) _TIFFmalloc(n * TIFFDataWidth(type)); - if (w == NULL) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "No space to write array"); - return (0); - } - } - - dir->tdir_tag = (uint16) tag; - dir->tdir_type = (uint16) type; - dir->tdir_count = n; - - switch (type) { - case TIFF_BYTE: - { - uint8* bp = (uint8*) w; - for (i = 0; i < (int) n; i++) - bp[i] = (uint8) v[i]; - if (!TIFFWriteByteArray(tif, dir, (char*) bp)) - goto out; - } - break; - case TIFF_SBYTE: - { - int8* bp = (int8*) w; - for (i = 0; i < (int) n; i++) - bp[i] = (int8) v[i]; - if (!TIFFWriteByteArray(tif, dir, (char*) bp)) - goto out; - } - break; - case TIFF_SHORT: - { - uint16* bp = (uint16*) w; - for (i = 0; i < (int) n; i++) - bp[i] = (uint16) v[i]; - if (!TIFFWriteShortArray(tif, dir, (uint16*)bp)) - goto out; - } - break; - case TIFF_SSHORT: - { - int16* bp = (int16*) w; - for (i = 0; i < (int) n; i++) - bp[i] = (int16) v[i]; - if (!TIFFWriteShortArray(tif, dir, (uint16*)bp)) - goto out; - } - break; - case TIFF_LONG: - { - uint32* bp = (uint32*) w; - for (i = 0; i < (int) n; i++) - bp[i] = (uint32) v[i]; - if (!TIFFWriteLongArray(tif, dir, bp)) - goto out; - } - break; - case TIFF_SLONG: - { - int32* bp = (int32*) w; - for (i = 0; i < (int) n; i++) - bp[i] = (int32) v[i]; - if (!TIFFWriteLongArray(tif, dir, (uint32*) bp)) - goto out; - } - break; - case TIFF_FLOAT: - { - float* bp = (float*) w; - for (i = 0; i < (int) n; i++) - bp[i] = (float) v[i]; - if (!TIFFWriteFloatArray(tif, dir, bp)) - goto out; - } - break; - case TIFF_DOUBLE: - { - if ( !TIFFWriteDoubleArray(tif, dir, v)) - goto out; - } - break; - default: - /* TIFF_NOTYPE */ - /* TIFF_ASCII */ - /* TIFF_UNDEFINED */ - /* TIFF_RATIONAL */ - /* TIFF_SRATIONAL */ - goto out; - } - status = 1; - out: - if (w != buf) - _TIFFfree(w); - return (status); -} - -static int -TIFFWriteTransferFunction(TIFF* tif, TIFFDirEntry* dir) -{ - TIFFDirectory* td = &tif->tif_dir; - tsize_t n = (1L<td_bitspersample) * sizeof (uint16); - uint16** tf = td->td_transferfunction; - int ncols; - - /* - * Check if the table can be written as a single column, - * or if it must be written as 3 columns. Note that we - * write a 3-column tag if there are 2 samples/pixel and - * a single column of data won't suffice--hmm. - */ - switch (td->td_samplesperpixel - td->td_extrasamples) { - default: if (_TIFFmemcmp(tf[0], tf[2], n)) { ncols = 3; break; } - case 2: if (_TIFFmemcmp(tf[0], tf[1], n)) { ncols = 3; break; } - case 1: case 0: ncols = 1; - } - return (TIFFWriteShortTable(tif, - TIFFTAG_TRANSFERFUNCTION, dir, ncols, tf)); -} - -static int -TIFFWriteInkNames(TIFF* tif, TIFFDirEntry* dir) -{ - TIFFDirectory* td = &tif->tif_dir; - - dir->tdir_tag = TIFFTAG_INKNAMES; - dir->tdir_type = (short) TIFF_ASCII; - dir->tdir_count = td->td_inknameslen; - return (TIFFWriteByteArray(tif, dir, td->td_inknames)); -} - -/* - * Write a contiguous directory item. - */ -static int -TIFFWriteData(TIFF* tif, TIFFDirEntry* dir, char* cp) -{ - tsize_t cc; - - if (tif->tif_flags & TIFF_SWAB) { - switch (dir->tdir_type) { - case TIFF_SHORT: - case TIFF_SSHORT: - TIFFSwabArrayOfShort((uint16*) cp, dir->tdir_count); - break; - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_FLOAT: - TIFFSwabArrayOfLong((uint32*) cp, dir->tdir_count); - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - TIFFSwabArrayOfLong((uint32*) cp, 2*dir->tdir_count); - break; - case TIFF_DOUBLE: - TIFFSwabArrayOfDouble((double*) cp, dir->tdir_count); - break; - } - } - dir->tdir_offset = tif->tif_dataoff; - cc = dir->tdir_count * TIFFDataWidth((TIFFDataType) dir->tdir_type); - if (SeekOK(tif, dir->tdir_offset) && - WriteOK(tif, cp, cc)) { - tif->tif_dataoff += (cc + 1) & ~1; - return (1); - } - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Error writing data for field \"%s\"", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); - return (0); -} - -/* - * Similar to TIFFWriteDirectory(), but if the directory has already - * been written once, it is relocated to the end of the file, in case it - * has changed in size. Note that this will result in the loss of the - * previously used directory space. - */ - -int -TIFFRewriteDirectory( TIFF *tif ) -{ - static const char module[] = "TIFFRewriteDirectory"; - - /* We don't need to do anything special if it hasn't been written. */ - if ( tif->tif_diroff == 0 ) - return TIFFWriteDirectory( tif ); - - /* - ** Find and zero the pointer to this directory, so that TIFFLinkDirectory - ** will cause it to be added after this directories current pre-link. - */ - - /* Is it the first directory in the file? */ - if (tif->tif_header.tiff_diroff == tif->tif_diroff) - { - tif->tif_header.tiff_diroff = 0; - tif->tif_diroff = 0; - - TIFFSeekFile(tif, (toff_t)(TIFF_MAGIC_SIZE+TIFF_VERSION_SIZE), - SEEK_SET); - if (!WriteOK(tif, &(tif->tif_header.tiff_diroff), - sizeof (tif->tif_diroff))) - { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Error updating TIFF header"); - return (0); - } - } - else - { - toff_t nextdir, off; - - nextdir = tif->tif_header.tiff_diroff; - do { - uint16 dircount; - - if (!SeekOK(tif, nextdir) || - !ReadOK(tif, &dircount, sizeof (dircount))) { - TIFFErrorExt(tif->tif_clientdata, module, - "Error fetching directory count"); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount); - (void) TIFFSeekFile(tif, - dircount * sizeof (TIFFDirEntry), SEEK_CUR); - if (!ReadOK(tif, &nextdir, sizeof (nextdir))) { - TIFFErrorExt(tif->tif_clientdata, module, - "Error fetching directory link"); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&nextdir); - } while (nextdir != tif->tif_diroff && nextdir != 0); - off = TIFFSeekFile(tif, 0, SEEK_CUR); /* get current offset */ - (void) TIFFSeekFile(tif, off - (toff_t)sizeof(nextdir), SEEK_SET); - tif->tif_diroff = 0; - if (!WriteOK(tif, &(tif->tif_diroff), sizeof (nextdir))) { - TIFFErrorExt(tif->tif_clientdata, module, - "Error writing directory link"); - return (0); - } - } - - /* - ** Now use TIFFWriteDirectory() normally. - */ - - return TIFFWriteDirectory( tif ); -} - - -/* - * Link the current directory into the directory chain for the file. - */ -static int -TIFFLinkDirectory(TIFF* tif) -{ - static const char module[] = "TIFFLinkDirectory"; - toff_t nextdir; - toff_t diroff, off; - - tif->tif_diroff = (TIFFSeekFile(tif, (toff_t) 0, SEEK_END)+1) &~ 1; - diroff = tif->tif_diroff; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&diroff); - - /* - * Handle SubIFDs - */ - if (tif->tif_flags & TIFF_INSUBIFD) { - (void) TIFFSeekFile(tif, tif->tif_subifdoff, SEEK_SET); - if (!WriteOK(tif, &diroff, sizeof (diroff))) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Error writing SubIFD directory link", - tif->tif_name); - return (0); - } - /* - * Advance to the next SubIFD or, if this is - * the last one configured, revert back to the - * normal directory linkage. - */ - if (--tif->tif_nsubifd) - tif->tif_subifdoff += sizeof (diroff); - else - tif->tif_flags &= ~TIFF_INSUBIFD; - return (1); - } - - if (tif->tif_header.tiff_diroff == 0) { - /* - * First directory, overwrite offset in header. - */ - tif->tif_header.tiff_diroff = tif->tif_diroff; - (void) TIFFSeekFile(tif, - (toff_t)(TIFF_MAGIC_SIZE+TIFF_VERSION_SIZE), - SEEK_SET); - if (!WriteOK(tif, &diroff, sizeof (diroff))) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Error writing TIFF header"); - return (0); - } - return (1); - } - /* - * Not the first directory, search to the last and append. - */ - nextdir = tif->tif_header.tiff_diroff; - do { - uint16 dircount; - - if (!SeekOK(tif, nextdir) || - !ReadOK(tif, &dircount, sizeof (dircount))) { - TIFFErrorExt(tif->tif_clientdata, module, - "Error fetching directory count"); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount); - (void) TIFFSeekFile(tif, - dircount * sizeof (TIFFDirEntry), SEEK_CUR); - if (!ReadOK(tif, &nextdir, sizeof (nextdir))) { - TIFFErrorExt(tif->tif_clientdata, module, - "Error fetching directory link"); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&nextdir); - } while (nextdir != 0); - off = TIFFSeekFile(tif, 0, SEEK_CUR); /* get current offset */ - (void) TIFFSeekFile(tif, off - (toff_t)sizeof(nextdir), SEEK_SET); - if (!WriteOK(tif, &diroff, sizeof (diroff))) { - TIFFErrorExt(tif->tif_clientdata, module, - "Error writing directory link"); - return (0); - } - return (1); -} - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_dumpmode.c b/plugins/AdvaImg/src/LibTIFF/tif_dumpmode.c deleted file mode 100644 index 273614728d..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_dumpmode.c +++ /dev/null @@ -1,126 +0,0 @@ -/* $Header: /cvsroot/freeimage/FreeImage/Source/LibTIFF/tif_dumpmode.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * "Null" Compression Algorithm Support. - */ -#include "tiffiop.h" - -/* - * Encode a hunk of pixels. - */ -static int -DumpModeEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) -{ - (void) s; - while (cc > 0) { - tsize_t n; - - n = cc; - if (tif->tif_rawcc + n > tif->tif_rawdatasize) - n = tif->tif_rawdatasize - tif->tif_rawcc; - - assert( n > 0 ); - - /* - * Avoid copy if client has setup raw - * data buffer to avoid extra copy. - */ - if (tif->tif_rawcp != pp) - _TIFFmemcpy(tif->tif_rawcp, pp, n); - tif->tif_rawcp += n; - tif->tif_rawcc += n; - pp += n; - cc -= n; - if (tif->tif_rawcc >= tif->tif_rawdatasize && - !TIFFFlushData1(tif)) - return (-1); - } - return (1); -} - -/* - * Decode a hunk of pixels. - */ -static int -DumpModeDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) -{ - (void) s; -/* fprintf(stderr,"DumpModeDecode: scanline %ld, expected %ld bytes, got %ld bytes\n", */ -/* (long) tif->tif_row, (long) tif->tif_rawcc, (long) cc); */ - if (tif->tif_rawcc < cc) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "DumpModeDecode: Not enough data for scanline %d", - tif->tif_row); - return (0); - } - /* - * Avoid copy if client has setup raw - * data buffer to avoid extra copy. - */ - if (tif->tif_rawcp != buf) - _TIFFmemcpy(buf, tif->tif_rawcp, cc); - tif->tif_rawcp += cc; - tif->tif_rawcc -= cc; - return (1); -} - -/* - * Seek forwards nrows in the current strip. - */ -static int -DumpModeSeek(TIFF* tif, uint32 nrows) -{ - tif->tif_rawcp += nrows * tif->tif_scanlinesize; - tif->tif_rawcc -= nrows * tif->tif_scanlinesize; - return (1); -} - -/* - * Initialize dump mode. - */ -int -TIFFInitDumpMode(TIFF* tif, int scheme) -{ - (void) scheme; - tif->tif_decoderow = DumpModeDecode; - tif->tif_decodestrip = DumpModeDecode; - tif->tif_decodetile = DumpModeDecode; - tif->tif_encoderow = DumpModeEncode; - tif->tif_encodestrip = DumpModeEncode; - tif->tif_encodetile = DumpModeEncode; - tif->tif_seek = DumpModeSeek; - return (1); -} -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_error.c b/plugins/AdvaImg/src/LibTIFF/tif_error.c deleted file mode 100644 index 23f90648de..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_error.c +++ /dev/null @@ -1,80 +0,0 @@ -/* $Header: /cvsroot/freeimage/FreeImage/Source/LibTIFF/tif_error.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - */ -#include "tiffiop.h" - -TIFFErrorHandlerExt _TIFFerrorHandlerExt = NULL; - -TIFFErrorHandler -TIFFSetErrorHandler(TIFFErrorHandler handler) -{ - TIFFErrorHandler prev = _TIFFerrorHandler; - _TIFFerrorHandler = handler; - return (prev); -} - -TIFFErrorHandlerExt -TIFFSetErrorHandlerExt(TIFFErrorHandlerExt handler) -{ - TIFFErrorHandlerExt prev = _TIFFerrorHandlerExt; - _TIFFerrorHandlerExt = handler; - return (prev); -} - -void -TIFFError(const char* module, const char* fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - if (_TIFFerrorHandler) - (*_TIFFerrorHandler)(module, fmt, ap); - if (_TIFFerrorHandlerExt) - (*_TIFFerrorHandlerExt)(0, module, fmt, ap); - va_end(ap); -} - -void -TIFFErrorExt(thandle_t fd, const char* module, const char* fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - if (_TIFFerrorHandler) - (*_TIFFerrorHandler)(module, fmt, ap); - if (_TIFFerrorHandlerExt) - (*_TIFFerrorHandlerExt)(fd, module, fmt, ap); - va_end(ap); -} - -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_extension.c b/plugins/AdvaImg/src/LibTIFF/tif_extension.c deleted file mode 100644 index e8fb4a2cac..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_extension.c +++ /dev/null @@ -1,118 +0,0 @@ -/* $Header: /cvsroot/freeimage/FreeImage/Source/LibTIFF/tif_extension.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Various routines support external extension of the tag set, and other - * application extension capabilities. - */ - -#include "tiffiop.h" - -int TIFFGetTagListCount( TIFF *tif ) - -{ - TIFFDirectory* td = &tif->tif_dir; - - return td->td_customValueCount; -} - -ttag_t TIFFGetTagListEntry( TIFF *tif, int tag_index ) - -{ - TIFFDirectory* td = &tif->tif_dir; - - if ( tag_index < 0 || tag_index >= td->td_customValueCount ) - return (ttag_t) -1; - else - return td->td_customValues[tag_index].info->field_tag; -} - -/* -** This provides read/write access to the TIFFTagMethods within the TIFF -** structure to application code without giving access to the private -** TIFF structure. -*/ -TIFFTagMethods *TIFFAccessTagMethods( TIFF *tif ) - -{ - return &(tif->tif_tagmethods); -} - -void *TIFFGetClientInfo( TIFF *tif, const char *name ) - -{ - TIFFClientInfoLink *link = tif->tif_clientinfo; - - while( link != NULL && strcmp(link->name,name) != 0 ) - link = link->next; - - if ( link != NULL ) - return link->data; - else - return NULL; -} - -void TIFFSetClientInfo( TIFF *tif, void *data, const char *name ) - -{ - TIFFClientInfoLink *link = tif->tif_clientinfo; - - /* - ** Do we have an existing link with this name? If so, just - ** set it. - */ - while( link != NULL && strcmp(link->name,name) != 0 ) - link = link->next; - - if ( link != NULL ) - { - link->data = data; - return; - } - - /* - ** Create a new link. - */ - - link = (TIFFClientInfoLink *) _TIFFmalloc(sizeof(TIFFClientInfoLink)); - assert (link != NULL); - link->next = tif->tif_clientinfo; - link->name = (char *) _TIFFmalloc(strlen(name)+1); - assert (link->name != NULL); - strcpy(link->name, name); - link->data = data; - - tif->tif_clientinfo = link; -} -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_fax3.c b/plugins/AdvaImg/src/LibTIFF/tif_fax3.c deleted file mode 100644 index 2e74a37c69..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_fax3.c +++ /dev/null @@ -1,1626 +0,0 @@ -/* $Id: tif_fax3.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1990-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#include "tiffiop.h" -#ifdef CCITT_SUPPORT -/* - * TIFF Library. - * - * CCITT Group 3 (T.4) and Group 4 (T.6) Compression Support. - * - * This file contains support for decoding and encoding TIFF - * compression algorithms 2, 3, 4, and 32771. - * - * Decoder support is derived, with permission, from the code - * in Frank Cringle's viewfax program; - * Copyright (C) 1990, 1995 Frank D. Cringle. - */ -#include "tif_fax3.h" -#define G3CODES -#include "t4.h" -#include - -/* - * Compression+decompression state blocks are - * derived from this ``base state'' block. - */ -typedef struct { - int rw_mode; /* O_RDONLY for decode, else encode */ - int mode; /* operating mode */ - uint32 rowbytes; /* bytes in a decoded scanline */ - uint32 rowpixels; /* pixels in a scanline */ - - uint16 cleanfaxdata; /* CleanFaxData tag */ - uint32 badfaxrun; /* BadFaxRun tag */ - uint32 badfaxlines; /* BadFaxLines tag */ - uint32 groupoptions; /* Group 3/4 options tag */ - uint32 recvparams; /* encoded Class 2 session params */ - char* subaddress; /* subaddress string */ - uint32 recvtime; /* time spent receiving (secs) */ - char* faxdcs; /* Table 2/T.30 encoded session params */ - TIFFVGetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ - TIFFPrintMethod printdir; /* super-class method */ -} Fax3BaseState; -#define Fax3State(tif) ((Fax3BaseState*) (tif)->tif_data) - -typedef enum { G3_1D, G3_2D } Ttag; -typedef struct { - Fax3BaseState b; - - /* Decoder state info */ - const unsigned char* bitmap; /* bit reversal table */ - uint32 data; /* current i/o byte/word */ - int bit; /* current i/o bit in byte */ - int EOLcnt; /* count of EOL codes recognized */ - TIFFFaxFillFunc fill; /* fill routine */ - uint32* runs; /* b&w runs for current/previous row */ - uint32* refruns; /* runs for reference line */ - uint32* curruns; /* runs for current line */ - - /* Encoder state info */ - Ttag tag; /* encoding state */ - unsigned char* refline; /* reference line for 2d decoding */ - int k; /* #rows left that can be 2d encoded */ - int maxk; /* max #rows that can be 2d encoded */ - - int line; -} Fax3CodecState; -#define DecoderState(tif) ((Fax3CodecState*) Fax3State(tif)) -#define EncoderState(tif) ((Fax3CodecState*) Fax3State(tif)) - -#define is2DEncoding(sp) \ - (sp->b.groupoptions & GROUP3OPT_2DENCODING) -#define isAligned(p,t) ((((unsigned long)(p)) & (sizeof (t)-1)) == 0) - -/* - * Group 3 and Group 4 Decoding. - */ - -/* - * These macros glue the TIFF library state to - * the state expected by Frank's decoder. - */ -#define DECLARE_STATE(tif, sp, mod) \ - static const char module[] = mod; \ - Fax3CodecState* sp = DecoderState(tif); \ - int a0; /* reference element */ \ - int lastx = sp->b.rowpixels; /* last element in row */ \ - uint32 BitAcc; /* bit accumulator */ \ - int BitsAvail; /* # valid bits in BitAcc */ \ - int RunLength; /* length of current run */ \ - unsigned char* cp; /* next byte of input data */ \ - unsigned char* ep; /* end of input data */ \ - uint32* pa; /* place to stuff next run */ \ - uint32* thisrun; /* current row's run array */ \ - int EOLcnt; /* # EOL codes recognized */ \ - const unsigned char* bitmap = sp->bitmap; /* input data bit reverser */ \ - const TIFFFaxTabEnt* TabEnt -#define DECLARE_STATE_2D(tif, sp, mod) \ - DECLARE_STATE(tif, sp, mod); \ - int b1; /* next change on prev line */ \ - uint32* pb /* next run in reference line */\ -/* - * Load any state that may be changed during decoding. - */ -#define CACHE_STATE(tif, sp) do { \ - BitAcc = sp->data; \ - BitsAvail = sp->bit; \ - EOLcnt = sp->EOLcnt; \ - cp = (unsigned char*) tif->tif_rawcp; \ - ep = cp + tif->tif_rawcc; \ -} while (0) -/* - * Save state possibly changed during decoding. - */ -#define UNCACHE_STATE(tif, sp) do { \ - sp->bit = BitsAvail; \ - sp->data = BitAcc; \ - sp->EOLcnt = EOLcnt; \ - tif->tif_rawcc -= (tidata_t) cp - tif->tif_rawcp; \ - tif->tif_rawcp = (tidata_t) cp; \ -} while (0) - -/* - * Setup state for decoding a strip. - */ -static int -Fax3PreDecode(TIFF* tif, tsample_t s) -{ - Fax3CodecState* sp = DecoderState(tif); - - (void) s; - assert(sp != NULL); - sp->bit = 0; /* force initial read */ - sp->data = 0; - sp->EOLcnt = 0; /* force initial scan for EOL */ - /* - * Decoder assumes lsb-to-msb bit order. Note that we select - * this here rather than in Fax3SetupState so that viewers can - * hold the image open, fiddle with the FillOrder tag value, - * and then re-decode the image. Otherwise they'd need to close - * and open the image to get the state reset. - */ - sp->bitmap = - TIFFGetBitRevTable(tif->tif_dir.td_fillorder != FILLORDER_LSB2MSB); - if (sp->refruns) { /* init reference line to white */ - sp->refruns[0] = (uint32) sp->b.rowpixels; - sp->refruns[1] = 0; - } - sp->line = 0; - return (1); -} - -/* - * Routine for handling various errors/conditions. - * Note how they are "glued into the decoder" by - * overriding the definitions used by the decoder. - */ - -static void -Fax3Unexpected(const char* module, TIFF* tif, uint32 line, uint32 a0) -{ - TIFFErrorExt(tif->tif_clientdata, module, "%s: Bad code word at line %u of %s %u (x %u)", - tif->tif_name, line, isTiled(tif) ? "tile" : "strip", - (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), - a0); -} -#define unexpected(table, a0) Fax3Unexpected(module, tif, sp->line, a0) - -static void -Fax3Extension(const char* module, TIFF* tif, uint32 line, uint32 a0) -{ - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Uncompressed data (not supported) at line %u of %s %u (x %u)", - tif->tif_name, line, isTiled(tif) ? "tile" : "strip", - (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), - a0); -} -#define extension(a0) Fax3Extension(module, tif, sp->line, a0) - -static void -Fax3BadLength(const char* module, TIFF* tif, uint32 line, uint32 a0, uint32 lastx) -{ - TIFFWarningExt(tif->tif_clientdata, module, "%s: %s at line %u of %s %u (got %u, expected %u)", - tif->tif_name, - a0 < lastx ? "Premature EOL" : "Line length mismatch", - line, isTiled(tif) ? "tile" : "strip", - (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), - a0, lastx); -} -#define badlength(a0,lastx) Fax3BadLength(module, tif, sp->line, a0, lastx) - -static void -Fax3PrematureEOF(const char* module, TIFF* tif, uint32 line, uint32 a0) -{ - TIFFWarningExt(tif->tif_clientdata, module, "%s: Premature EOF at line %u of %s %u (x %u)", - tif->tif_name, - line, isTiled(tif) ? "tile" : "strip", - (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), - a0); -} -#define prematureEOF(a0) Fax3PrematureEOF(module, tif, sp->line, a0) - -#define Nop - -/* - * Decode the requested amount of G3 1D-encoded data. - */ -static int -Fax3Decode1D(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) -{ - DECLARE_STATE(tif, sp, "Fax3Decode1D"); - - (void) s; - CACHE_STATE(tif, sp); - thisrun = sp->curruns; - while ((long)occ > 0) { - a0 = 0; - RunLength = 0; - pa = thisrun; -#ifdef FAX3_DEBUG - printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail); - printf("-------------------- %d\n", tif->tif_row); - fflush(stdout); -#endif - SYNC_EOL(EOF1D); - EXPAND1D(EOF1Da); - (*sp->fill)(buf, thisrun, pa, lastx); - buf += sp->b.rowbytes; - occ -= sp->b.rowbytes; - sp->line++; - continue; - EOF1D: /* premature EOF */ - CLEANUP_RUNS(); - EOF1Da: /* premature EOF */ - (*sp->fill)(buf, thisrun, pa, lastx); - UNCACHE_STATE(tif, sp); - return (-1); - } - UNCACHE_STATE(tif, sp); - return (1); -} - -#define SWAP(t,a,b) { t x; x = (a); (a) = (b); (b) = x; } -/* - * Decode the requested amount of G3 2D-encoded data. - */ -static int -Fax3Decode2D(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) -{ - DECLARE_STATE_2D(tif, sp, "Fax3Decode2D"); - int is1D; /* current line is 1d/2d-encoded */ - - (void) s; - CACHE_STATE(tif, sp); - while ((long)occ > 0) { - a0 = 0; - RunLength = 0; - pa = thisrun = sp->curruns; -#ifdef FAX3_DEBUG - printf("\nBitAcc=%08X, BitsAvail = %d EOLcnt = %d", - BitAcc, BitsAvail, EOLcnt); -#endif - SYNC_EOL(EOF2D); - NeedBits8(1, EOF2D); - is1D = GetBits(1); /* 1D/2D-encoding tag bit */ - ClrBits(1); -#ifdef FAX3_DEBUG - printf(" %s\n-------------------- %d\n", - is1D ? "1D" : "2D", tif->tif_row); - fflush(stdout); -#endif - pb = sp->refruns; - b1 = *pb++; - if (is1D) - EXPAND1D(EOF2Da); - else - EXPAND2D(EOF2Da); - (*sp->fill)(buf, thisrun, pa, lastx); - SETVALUE(0); /* imaginary change for reference */ - SWAP(uint32*, sp->curruns, sp->refruns); - buf += sp->b.rowbytes; - occ -= sp->b.rowbytes; - sp->line++; - continue; - EOF2D: /* premature EOF */ - CLEANUP_RUNS(); - EOF2Da: /* premature EOF */ - (*sp->fill)(buf, thisrun, pa, lastx); - UNCACHE_STATE(tif, sp); - return (-1); - } - UNCACHE_STATE(tif, sp); - return (1); -} -#undef SWAP - -/* - * The ZERO & FILL macros must handle spans < 2*sizeof(long) bytes. - * For machines with 64-bit longs this is <16 bytes; otherwise - * this is <8 bytes. We optimize the code here to reflect the - * machine characteristics. - */ -#if SIZEOF_LONG == 8 -# define FILL(n, cp) \ - switch (n) { \ - case 15:(cp)[14] = 0xff; case 14:(cp)[13] = 0xff; case 13: (cp)[12] = 0xff;\ - case 12:(cp)[11] = 0xff; case 11:(cp)[10] = 0xff; case 10: (cp)[9] = 0xff;\ - case 9: (cp)[8] = 0xff; case 8: (cp)[7] = 0xff; case 7: (cp)[6] = 0xff;\ - case 6: (cp)[5] = 0xff; case 5: (cp)[4] = 0xff; case 4: (cp)[3] = 0xff;\ - case 3: (cp)[2] = 0xff; case 2: (cp)[1] = 0xff; \ - case 1: (cp)[0] = 0xff; (cp) += (n); case 0: ; \ - } -# define ZERO(n, cp) \ - switch (n) { \ - case 15:(cp)[14] = 0; case 14:(cp)[13] = 0; case 13: (cp)[12] = 0; \ - case 12:(cp)[11] = 0; case 11:(cp)[10] = 0; case 10: (cp)[9] = 0; \ - case 9: (cp)[8] = 0; case 8: (cp)[7] = 0; case 7: (cp)[6] = 0; \ - case 6: (cp)[5] = 0; case 5: (cp)[4] = 0; case 4: (cp)[3] = 0; \ - case 3: (cp)[2] = 0; case 2: (cp)[1] = 0; \ - case 1: (cp)[0] = 0; (cp) += (n); case 0: ; \ - } -#else -# define FILL(n, cp) \ - switch (n) { \ - case 7: (cp)[6] = 0xff; case 6: (cp)[5] = 0xff; case 5: (cp)[4] = 0xff; \ - case 4: (cp)[3] = 0xff; case 3: (cp)[2] = 0xff; case 2: (cp)[1] = 0xff; \ - case 1: (cp)[0] = 0xff; (cp) += (n); case 0: ; \ - } -# define ZERO(n, cp) \ - switch (n) { \ - case 7: (cp)[6] = 0; case 6: (cp)[5] = 0; case 5: (cp)[4] = 0; \ - case 4: (cp)[3] = 0; case 3: (cp)[2] = 0; case 2: (cp)[1] = 0; \ - case 1: (cp)[0] = 0; (cp) += (n); case 0: ; \ - } -#endif - -/* - * Bit-fill a row according to the white/black - * runs generated during G3/G4 decoding. - */ -void -_TIFFFax3fillruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx) -{ - static const unsigned char _fillmasks[] = - { 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff }; - unsigned char* cp; - uint32 x, bx, run; - int32 n, nw; - long* lp; - - if ((erun-runs)&1) - *erun++ = 0; - x = 0; - for (; runs < erun; runs += 2) { - run = runs[0]; - if (x+run > lastx || run > lastx ) - run = runs[0] = (uint32) (lastx - x); - if (run) { - cp = buf + (x>>3); - bx = x&7; - if (run > 8-bx) { - if (bx) { /* align to byte boundary */ - *cp++ &= 0xff << (8-bx); - run -= 8-bx; - } - if ( (n = run >> 3) != 0 ) { /* multiple bytes to fill */ - if ((n/sizeof (long)) > 1) { - /* - * Align to longword boundary and fill. - */ - for (; n && !isAligned(cp, long); n--) - *cp++ = 0x00; - lp = (long*) cp; - nw = (int32)(n / sizeof (long)); - n -= nw * sizeof (long); - do { - *lp++ = 0L; - } while (--nw); - cp = (unsigned char*) lp; - } - ZERO(n, cp); - run &= 7; - } - if (run) - cp[0] &= 0xff >> run; - } else - cp[0] &= ~(_fillmasks[run]>>bx); - x += runs[0]; - } - run = runs[1]; - if (x+run > lastx || run > lastx ) - run = runs[1] = lastx - x; - if (run) { - cp = buf + (x>>3); - bx = x&7; - if (run > 8-bx) { - if (bx) { /* align to byte boundary */ - *cp++ |= 0xff >> bx; - run -= 8-bx; - } - if ( (n = run>>3) != 0 ) { /* multiple bytes to fill */ - if ((n/sizeof (long)) > 1) { - /* - * Align to longword boundary and fill. - */ - for (; n && !isAligned(cp, long); n--) - *cp++ = 0xff; - lp = (long*) cp; - nw = (int32)(n / sizeof (long)); - n -= nw * sizeof (long); - do { - *lp++ = -1L; - } while (--nw); - cp = (unsigned char*) lp; - } - FILL(n, cp); - run &= 7; - } - if (run) - cp[0] |= 0xff00 >> run; - } else - cp[0] |= _fillmasks[run]>>bx; - x += runs[1]; - } - } - assert(x == lastx); -} -#undef ZERO -#undef FILL - -/* - * Setup G3/G4-related compression/decompression state - * before data is processed. This routine is called once - * per image -- it sets up different state based on whether - * or not decoding or encoding is being done and whether - * 1D- or 2D-encoded data is involved. - */ -static int -Fax3SetupState(TIFF* tif) -{ - TIFFDirectory* td = &tif->tif_dir; - Fax3BaseState* sp = Fax3State(tif); - int needsRefLine; - Fax3CodecState* dsp = (Fax3CodecState*) Fax3State(tif); - uint32 rowbytes, rowpixels, nruns; - - if (td->td_bitspersample != 1) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Bits/sample must be 1 for Group 3/4 encoding/decoding"); - return (0); - } - /* - * Calculate the scanline/tile widths. - */ - if (isTiled(tif)) { - rowbytes = TIFFTileRowSize(tif); - rowpixels = td->td_tilewidth; - } else { - rowbytes = TIFFScanlineSize(tif); - rowpixels = td->td_imagewidth; - } - sp->rowbytes = (uint32) rowbytes; - sp->rowpixels = (uint32) rowpixels; - /* - * Allocate any additional space required for decoding/encoding. - */ - needsRefLine = ( - (sp->groupoptions & GROUP3OPT_2DENCODING) || - td->td_compression == COMPRESSION_CCITTFAX4 - ); - - /* - Assure that allocation computations do not overflow. - - TIFFroundup and TIFFSafeMultiply return zero on integer overflow - */ - dsp->runs=(uint32*) NULL; - nruns = TIFFroundup(rowpixels,32); - if (needsRefLine) { - nruns = TIFFSafeMultiply(uint32,nruns,2); - } - if ((nruns == 0) || (TIFFSafeMultiply(uint32,nruns,2) == 0)) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Row pixels integer overflow (rowpixels %u)", - rowpixels); - return (0); - } - dsp->runs = (uint32*) _TIFFCheckMalloc(tif, - TIFFSafeMultiply(uint32,nruns,2), - sizeof (uint32), - "for Group 3/4 run arrays"); - if (dsp->runs == NULL) - return (0); - dsp->curruns = dsp->runs; - if (needsRefLine) - dsp->refruns = dsp->runs + nruns; - else - dsp->refruns = NULL; - if (td->td_compression == COMPRESSION_CCITTFAX3 - && is2DEncoding(dsp)) { /* NB: default is 1D routine */ - tif->tif_decoderow = Fax3Decode2D; - tif->tif_decodestrip = Fax3Decode2D; - tif->tif_decodetile = Fax3Decode2D; - } - - if (needsRefLine) { /* 2d encoding */ - Fax3CodecState* esp = EncoderState(tif); - /* - * 2d encoding requires a scanline - * buffer for the ``reference line''; the - * scanline against which delta encoding - * is referenced. The reference line must - * be initialized to be ``white'' (done elsewhere). - */ - esp->refline = (unsigned char*) _TIFFmalloc(rowbytes); - if (esp->refline == NULL) { - TIFFErrorExt(tif->tif_clientdata, "Fax3SetupState", - "%s: No space for Group 3/4 reference line", - tif->tif_name); - return (0); - } - } else /* 1d encoding */ - EncoderState(tif)->refline = NULL; - - return (1); -} - -/* - * CCITT Group 3 FAX Encoding. - */ - -#define Fax3FlushBits(tif, sp) { \ - if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) \ - (void) TIFFFlushData1(tif); \ - *(tif)->tif_rawcp++ = (tidataval_t) (sp)->data; \ - (tif)->tif_rawcc++; \ - (sp)->data = 0, (sp)->bit = 8; \ -} -#define _FlushBits(tif) { \ - if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) \ - (void) TIFFFlushData1(tif); \ - *(tif)->tif_rawcp++ = (tidataval_t) data; \ - (tif)->tif_rawcc++; \ - data = 0, bit = 8; \ -} -static const int _msbmask[9] = - { 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff }; -#define _PutBits(tif, bits, length) { \ - while (length > bit) { \ - data |= bits >> (length - bit); \ - length -= bit; \ - _FlushBits(tif); \ - } \ - data |= (bits & _msbmask[length]) << (bit - length); \ - bit -= length; \ - if (bit == 0) \ - _FlushBits(tif); \ -} - -/* - * Write a variable-length bit-value to - * the output stream. Values are - * assumed to be at most 16 bits. - */ -static void -Fax3PutBits(TIFF* tif, unsigned int bits, unsigned int length) -{ - Fax3CodecState* sp = EncoderState(tif); - unsigned int bit = sp->bit; - int data = sp->data; - - _PutBits(tif, bits, length); - - sp->data = data; - sp->bit = bit; -} - -/* - * Write a code to the output stream. - */ -#define putcode(tif, te) Fax3PutBits(tif, (te)->code, (te)->length) - -#ifdef FAX3_DEBUG -#define DEBUG_COLOR(w) (tab == TIFFFaxWhiteCodes ? w "W" : w "B") -#define DEBUG_PRINT(what,len) { \ - int t; \ - printf("%08X/%-2d: %s%5d\t", data, bit, DEBUG_COLOR(what), len); \ - for (t = length-1; t >= 0; t--) \ - putchar(code & (1<bit; - int data = sp->data; - unsigned int code, length; - - while (span >= 2624) { - const tableentry* te = &tab[63 + (2560>>6)]; - code = te->code, length = te->length; -#ifdef FAX3_DEBUG - DEBUG_PRINT("MakeUp", te->runlen); -#endif - _PutBits(tif, code, length); - span -= te->runlen; - } - if (span >= 64) { - const tableentry* te = &tab[63 + (span>>6)]; - assert(te->runlen == 64*(span>>6)); - code = te->code, length = te->length; -#ifdef FAX3_DEBUG - DEBUG_PRINT("MakeUp", te->runlen); -#endif - _PutBits(tif, code, length); - span -= te->runlen; - } - code = tab[span].code, length = tab[span].length; -#ifdef FAX3_DEBUG - DEBUG_PRINT(" Term", tab[span].runlen); -#endif - _PutBits(tif, code, length); - - sp->data = data; - sp->bit = bit; -} - -/* - * Write an EOL code to the output stream. The zero-fill - * logic for byte-aligning encoded scanlines is handled - * here. We also handle writing the tag bit for the next - * scanline when doing 2d encoding. - */ -static void -Fax3PutEOL(TIFF* tif) -{ - Fax3CodecState* sp = EncoderState(tif); - unsigned int bit = sp->bit; - int data = sp->data; - unsigned int code, length, tparm; - - if (sp->b.groupoptions & GROUP3OPT_FILLBITS) { - /* - * Force bit alignment so EOL will terminate on - * a byte boundary. That is, force the bit alignment - * to 16-12 = 4 before putting out the EOL code. - */ - int align = 8 - 4; - if (align != sp->bit) { - if (align > sp->bit) - align = sp->bit + (8 - align); - else - align = sp->bit - align; - code = 0; - tparm=align; - _PutBits(tif, 0, tparm); - } - } - code = EOL, length = 12; - if (is2DEncoding(sp)) - code = (code<<1) | (sp->tag == G3_1D), length++; - _PutBits(tif, code, length); - - sp->data = data; - sp->bit = bit; -} - -/* - * Reset encoding state at the start of a strip. - */ -static int -Fax3PreEncode(TIFF* tif, tsample_t s) -{ - Fax3CodecState* sp = EncoderState(tif); - - (void) s; - assert(sp != NULL); - sp->bit = 8; - sp->data = 0; - sp->tag = G3_1D; - /* - * This is necessary for Group 4; otherwise it isn't - * needed because the first scanline of each strip ends - * up being copied into the refline. - */ - if (sp->refline) - _TIFFmemset(sp->refline, 0x00, sp->b.rowbytes); - if (is2DEncoding(sp)) { - float res = tif->tif_dir.td_yresolution; - /* - * The CCITT spec says that when doing 2d encoding, you - * should only do it on K consecutive scanlines, where K - * depends on the resolution of the image being encoded - * (2 for <= 200 lpi, 4 for > 200 lpi). Since the directory - * code initializes td_yresolution to 0, this code will - * select a K of 2 unless the YResolution tag is set - * appropriately. (Note also that we fudge a little here - * and use 150 lpi to avoid problems with units conversion.) - */ - if (tif->tif_dir.td_resolutionunit == RESUNIT_CENTIMETER) - res *= 2.54f; /* convert to inches */ - sp->maxk = (res > 150 ? 4 : 2); - sp->k = sp->maxk-1; - } else - sp->k = sp->maxk = 0; - sp->line = 0; - return (1); -} - -static const unsigned char zeroruns[256] = { - 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, /* 0x00 - 0x0f */ - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0x10 - 0x1f */ - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0x20 - 0x2f */ - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0x30 - 0x3f */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x40 - 0x4f */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x50 - 0x5f */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x60 - 0x6f */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x70 - 0x7f */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x80 - 0x8f */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x90 - 0x9f */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xa0 - 0xaf */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xb0 - 0xbf */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xc0 - 0xcf */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xd0 - 0xdf */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xe0 - 0xef */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xf0 - 0xff */ -}; -static const unsigned char oneruns[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00 - 0x0f */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 - 0x1f */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 - 0x2f */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x30 - 0x3f */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40 - 0x4f */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x50 - 0x5f */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x6f */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70 - 0x7f */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x80 - 0x8f */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x90 - 0x9f */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xa0 - 0xaf */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xb0 - 0xbf */ - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0xc0 - 0xcf */ - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0xd0 - 0xdf */ - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0xe0 - 0xef */ - 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 8, /* 0xf0 - 0xff */ -}; - -/* - * On certain systems it pays to inline - * the routines that find pixel spans. - */ -#ifdef VAXC -static int32 find0span(unsigned char*, int32, int32); -static int32 find1span(unsigned char*, int32, int32); -#pragma inline(find0span,find1span) -#endif - -/* - * Find a span of ones or zeros using the supplied - * table. The ``base'' of the bit string is supplied - * along with the start+end bit indices. - */ -static int32 -find0span(unsigned char* bp, int32 bs, int32 be) -{ - int32 bits = be - bs; - int32 n, span; - - bp += bs>>3; - /* - * Check partial byte on lhs. - */ - if (bits > 0 && (n = (bs & 7))) { - span = zeroruns[(*bp << n) & 0xff]; - if (span > 8-n) /* table value too generous */ - span = 8-n; - if (span > bits) /* constrain span to bit range */ - span = bits; - if (n+span < 8) /* doesn't extend to edge of byte */ - return (span); - bits -= span; - bp++; - } else - span = 0; - if (bits >= (int32)(2 * 8 * sizeof(long))) { - long* lp; - /* - * Align to longword boundary and check longwords. - */ - while (!isAligned(bp, long)) { - if (*bp != 0x00) - return (span + zeroruns[*bp]); - span += 8, bits -= 8; - bp++; - } - lp = (long*) bp; - while ((bits >= (int32)(8 * sizeof(long))) && (0 == *lp)) { - span += 8*sizeof (long), bits -= 8*sizeof (long); - lp++; - } - bp = (unsigned char*) lp; - } - /* - * Scan full bytes for all 0's. - */ - while (bits >= 8) { - if (*bp != 0x00) /* end of run */ - return (span + zeroruns[*bp]); - span += 8, bits -= 8; - bp++; - } - /* - * Check partial byte on rhs. - */ - if (bits > 0) { - n = zeroruns[*bp]; - span += (n > bits ? bits : n); - } - return (span); -} - -static int32 -find1span(unsigned char* bp, int32 bs, int32 be) -{ - int32 bits = be - bs; - int32 n, span; - - bp += bs>>3; - /* - * Check partial byte on lhs. - */ - if (bits > 0 && (n = (bs & 7))) { - span = oneruns[(*bp << n) & 0xff]; - if (span > 8-n) /* table value too generous */ - span = 8-n; - if (span > bits) /* constrain span to bit range */ - span = bits; - if (n+span < 8) /* doesn't extend to edge of byte */ - return (span); - bits -= span; - bp++; - } else - span = 0; - if (bits >= (int32)(2 * 8 * sizeof(long))) { - long* lp; - /* - * Align to longword boundary and check longwords. - */ - while (!isAligned(bp, long)) { - if (*bp != 0xff) - return (span + oneruns[*bp]); - span += 8, bits -= 8; - bp++; - } - lp = (long*) bp; - while ((bits >= (int32)(8 * sizeof(long))) && (~0 == *lp)) { - span += 8*sizeof (long), bits -= 8*sizeof (long); - lp++; - } - bp = (unsigned char*) lp; - } - /* - * Scan full bytes for all 1's. - */ - while (bits >= 8) { - if (*bp != 0xff) /* end of run */ - return (span + oneruns[*bp]); - span += 8, bits -= 8; - bp++; - } - /* - * Check partial byte on rhs. - */ - if (bits > 0) { - n = oneruns[*bp]; - span += (n > bits ? bits : n); - } - return (span); -} - -/* - * Return the offset of the next bit in the range - * [bs..be] that is different from the specified - * color. The end, be, is returned if no such bit - * exists. - */ -#define finddiff(_cp, _bs, _be, _color) \ - (_bs + (_color ? find1span(_cp,_bs,_be) : find0span(_cp,_bs,_be))) -/* - * Like finddiff, but also check the starting bit - * against the end in case start > end. - */ -#define finddiff2(_cp, _bs, _be, _color) \ - (_bs < _be ? finddiff(_cp,_bs,_be,_color) : _be) - -/* - * 1d-encode a row of pixels. The encoding is - * a sequence of all-white or all-black spans - * of pixels encoded with Huffman codes. - */ -static int -Fax3Encode1DRow(TIFF* tif, unsigned char* bp, uint32 bits) -{ - Fax3CodecState* sp = EncoderState(tif); - int32 span; - uint32 bs = 0; - - for (;;) { - span = find0span(bp, bs, bits); /* white span */ - putspan(tif, span, TIFFFaxWhiteCodes); - bs += span; - if (bs >= bits) - break; - span = find1span(bp, bs, bits); /* black span */ - putspan(tif, span, TIFFFaxBlackCodes); - bs += span; - if (bs >= bits) - break; - } - if (sp->b.mode & (FAXMODE_BYTEALIGN|FAXMODE_WORDALIGN)) { - if (sp->bit != 8) /* byte-align */ - Fax3FlushBits(tif, sp); - if ((sp->b.mode&FAXMODE_WORDALIGN) && - !isAligned(tif->tif_rawcp, uint16)) - Fax3FlushBits(tif, sp); - } - return (1); -} - -static const tableentry horizcode = - { 3, 0x1, 0 }; /* 001 */ -static const tableentry passcode = - { 4, 0x1, 0 }; /* 0001 */ -static const tableentry vcodes[7] = { - { 7, 0x03, 0 }, /* 0000 011 */ - { 6, 0x03, 0 }, /* 0000 11 */ - { 3, 0x03, 0 }, /* 011 */ - { 1, 0x1, 0 }, /* 1 */ - { 3, 0x2, 0 }, /* 010 */ - { 6, 0x02, 0 }, /* 0000 10 */ - { 7, 0x02, 0 } /* 0000 010 */ -}; - -/* - * 2d-encode a row of pixels. Consult the CCITT - * documentation for the algorithm. - */ -static int -Fax3Encode2DRow(TIFF* tif, unsigned char* bp, unsigned char* rp, uint32 bits) -{ -#define PIXEL(buf,ix) ((((buf)[(ix)>>3]) >> (7-((ix)&7))) & 1) - uint32 a0 = 0; - uint32 a1 = (PIXEL(bp, 0) != 0 ? 0 : finddiff(bp, 0, bits, 0)); - uint32 b1 = (PIXEL(rp, 0) != 0 ? 0 : finddiff(rp, 0, bits, 0)); - uint32 a2, b2; - - for (;;) { - b2 = finddiff2(rp, b1, bits, PIXEL(rp,b1)); - if (b2 >= a1) { - int32 d = b1 - a1; - if (!(-3 <= d && d <= 3)) { /* horizontal mode */ - a2 = finddiff2(bp, a1, bits, PIXEL(bp,a1)); - putcode(tif, &horizcode); - if (a0+a1 == 0 || PIXEL(bp, a0) == 0) { - putspan(tif, a1-a0, TIFFFaxWhiteCodes); - putspan(tif, a2-a1, TIFFFaxBlackCodes); - } else { - putspan(tif, a1-a0, TIFFFaxBlackCodes); - putspan(tif, a2-a1, TIFFFaxWhiteCodes); - } - a0 = a2; - } else { /* vertical mode */ - putcode(tif, &vcodes[d+3]); - a0 = a1; - } - } else { /* pass mode */ - putcode(tif, &passcode); - a0 = b2; - } - if (a0 >= bits) - break; - a1 = finddiff(bp, a0, bits, PIXEL(bp,a0)); - b1 = finddiff(rp, a0, bits, !PIXEL(bp,a0)); - b1 = finddiff(rp, b1, bits, PIXEL(bp,a0)); - } - return (1); -#undef PIXEL -} - -/* - * Encode a buffer of pixels. - */ -static int -Fax3Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - Fax3CodecState* sp = EncoderState(tif); - - (void) s; - while ((long)cc > 0) { - if ((sp->b.mode & FAXMODE_NOEOL) == 0) - Fax3PutEOL(tif); - if (is2DEncoding(sp)) { - if (sp->tag == G3_1D) { - if (!Fax3Encode1DRow(tif, bp, sp->b.rowpixels)) - return (0); - sp->tag = G3_2D; - } else { - if (!Fax3Encode2DRow(tif, bp, sp->refline, - sp->b.rowpixels)) - return (0); - sp->k--; - } - if (sp->k == 0) { - sp->tag = G3_1D; - sp->k = sp->maxk-1; - } else - _TIFFmemcpy(sp->refline, bp, sp->b.rowbytes); - } else { - if (!Fax3Encode1DRow(tif, bp, sp->b.rowpixels)) - return (0); - } - bp += sp->b.rowbytes; - cc -= sp->b.rowbytes; - } - return (1); -} - -static int -Fax3PostEncode(TIFF* tif) -{ - Fax3CodecState* sp = EncoderState(tif); - - if (sp->bit != 8) - Fax3FlushBits(tif, sp); - return (1); -} - -static void -Fax3Close(TIFF* tif) -{ - if ((Fax3State(tif)->mode & FAXMODE_NORTC) == 0) { - Fax3CodecState* sp = EncoderState(tif); - unsigned int code = EOL; - unsigned int length = 12; - int i; - - if (is2DEncoding(sp)) - code = (code<<1) | (sp->tag == G3_1D), length++; - for (i = 0; i < 6; i++) - Fax3PutBits(tif, code, length); - Fax3FlushBits(tif, sp); - } -} - -static void -Fax3Cleanup(TIFF* tif) -{ - Fax3CodecState* sp = DecoderState(tif); - - assert(sp != 0); - - tif->tif_tagmethods.vgetfield = sp->b.vgetparent; - tif->tif_tagmethods.vsetfield = sp->b.vsetparent; - tif->tif_tagmethods.printdir = sp->b.printdir; - - if (sp->runs) - _TIFFfree(sp->runs); - if (sp->refline) - _TIFFfree(sp->refline); - - if (Fax3State(tif)->subaddress) - _TIFFfree(Fax3State(tif)->subaddress); - if (Fax3State(tif)->faxdcs) - _TIFFfree(Fax3State(tif)->faxdcs); - - _TIFFfree(tif->tif_data); - tif->tif_data = NULL; - - _TIFFSetDefaultCompressionState(tif); -} - -#define FIELD_BADFAXLINES (FIELD_CODEC+0) -#define FIELD_CLEANFAXDATA (FIELD_CODEC+1) -#define FIELD_BADFAXRUN (FIELD_CODEC+2) -#define FIELD_RECVPARAMS (FIELD_CODEC+3) -#define FIELD_SUBADDRESS (FIELD_CODEC+4) -#define FIELD_RECVTIME (FIELD_CODEC+5) -#define FIELD_FAXDCS (FIELD_CODEC+6) - -#define FIELD_OPTIONS (FIELD_CODEC+7) - -static const TIFFFieldInfo faxFieldInfo[] = { - { TIFFTAG_FAXMODE, 0, 0, TIFF_ANY, FIELD_PSEUDO, - FALSE, FALSE, "FaxMode" }, - { TIFFTAG_FAXFILLFUNC, 0, 0, TIFF_ANY, FIELD_PSEUDO, - FALSE, FALSE, "FaxFillFunc" }, - { TIFFTAG_BADFAXLINES, 1, 1, TIFF_LONG, FIELD_BADFAXLINES, - TRUE, FALSE, "BadFaxLines" }, - { TIFFTAG_BADFAXLINES, 1, 1, TIFF_SHORT, FIELD_BADFAXLINES, - TRUE, FALSE, "BadFaxLines" }, - { TIFFTAG_CLEANFAXDATA, 1, 1, TIFF_SHORT, FIELD_CLEANFAXDATA, - TRUE, FALSE, "CleanFaxData" }, - { TIFFTAG_CONSECUTIVEBADFAXLINES,1,1, TIFF_LONG, FIELD_BADFAXRUN, - TRUE, FALSE, "ConsecutiveBadFaxLines" }, - { TIFFTAG_CONSECUTIVEBADFAXLINES,1,1, TIFF_SHORT, FIELD_BADFAXRUN, - TRUE, FALSE, "ConsecutiveBadFaxLines" }, - { TIFFTAG_FAXRECVPARAMS, 1, 1, TIFF_LONG, FIELD_RECVPARAMS, - TRUE, FALSE, "FaxRecvParams" }, - { TIFFTAG_FAXSUBADDRESS, -1,-1, TIFF_ASCII, FIELD_SUBADDRESS, - TRUE, FALSE, "FaxSubAddress" }, - { TIFFTAG_FAXRECVTIME, 1, 1, TIFF_LONG, FIELD_RECVTIME, - TRUE, FALSE, "FaxRecvTime" }, - { TIFFTAG_FAXDCS, -1,-1, TIFF_ASCII, FIELD_FAXDCS, - TRUE, FALSE, "FaxDcs" }, -}; -static const TIFFFieldInfo fax3FieldInfo[] = { - { TIFFTAG_GROUP3OPTIONS, 1, 1, TIFF_LONG, FIELD_OPTIONS, - FALSE, FALSE, "Group3Options" }, -}; -static const TIFFFieldInfo fax4FieldInfo[] = { - { TIFFTAG_GROUP4OPTIONS, 1, 1, TIFF_LONG, FIELD_OPTIONS, - FALSE, FALSE, "Group4Options" }, -}; -#define N(a) (sizeof (a) / sizeof (a[0])) - -static int -Fax3VSetField(TIFF* tif, ttag_t tag, va_list ap) -{ - Fax3BaseState* sp = Fax3State(tif); - const TIFFFieldInfo* fip; - - assert(sp != 0); - assert(sp->vsetparent != 0); - - switch (tag) { - case TIFFTAG_FAXMODE: - sp->mode = va_arg(ap, int); - return 1; /* NB: pseudo tag */ - case TIFFTAG_FAXFILLFUNC: - DecoderState(tif)->fill = va_arg(ap, TIFFFaxFillFunc); - return 1; /* NB: pseudo tag */ - case TIFFTAG_GROUP3OPTIONS: - /* XXX: avoid reading options if compression mismatches. */ - if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX3) - sp->groupoptions = va_arg(ap, uint32); - break; - case TIFFTAG_GROUP4OPTIONS: - /* XXX: avoid reading options if compression mismatches. */ - if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX4) - sp->groupoptions = va_arg(ap, uint32); - break; - case TIFFTAG_BADFAXLINES: - sp->badfaxlines = va_arg(ap, uint32); - break; - case TIFFTAG_CLEANFAXDATA: - sp->cleanfaxdata = (uint16) va_arg(ap, int); - break; - case TIFFTAG_CONSECUTIVEBADFAXLINES: - sp->badfaxrun = va_arg(ap, uint32); - break; - case TIFFTAG_FAXRECVPARAMS: - sp->recvparams = va_arg(ap, uint32); - break; - case TIFFTAG_FAXSUBADDRESS: - _TIFFsetString(&sp->subaddress, va_arg(ap, char*)); - break; - case TIFFTAG_FAXRECVTIME: - sp->recvtime = va_arg(ap, uint32); - break; - case TIFFTAG_FAXDCS: - _TIFFsetString(&sp->faxdcs, va_arg(ap, char*)); - break; - default: - return (*sp->vsetparent)(tif, tag, ap); - } - - if ((fip = _TIFFFieldWithTag(tif, tag))) - TIFFSetFieldBit(tif, fip->field_bit); - else - return 0; - - tif->tif_flags |= TIFF_DIRTYDIRECT; - return 1; -} - -static int -Fax3VGetField(TIFF* tif, ttag_t tag, va_list ap) -{ - Fax3BaseState* sp = Fax3State(tif); - - assert(sp != 0); - - switch (tag) { - case TIFFTAG_FAXMODE: - *va_arg(ap, int*) = sp->mode; - break; - case TIFFTAG_FAXFILLFUNC: - *va_arg(ap, TIFFFaxFillFunc*) = DecoderState(tif)->fill; - break; - case TIFFTAG_GROUP3OPTIONS: - case TIFFTAG_GROUP4OPTIONS: - *va_arg(ap, uint32*) = sp->groupoptions; - break; - case TIFFTAG_BADFAXLINES: - *va_arg(ap, uint32*) = sp->badfaxlines; - break; - case TIFFTAG_CLEANFAXDATA: - *va_arg(ap, uint16*) = sp->cleanfaxdata; - break; - case TIFFTAG_CONSECUTIVEBADFAXLINES: - *va_arg(ap, uint32*) = sp->badfaxrun; - break; - case TIFFTAG_FAXRECVPARAMS: - *va_arg(ap, uint32*) = sp->recvparams; - break; - case TIFFTAG_FAXSUBADDRESS: - *va_arg(ap, char**) = sp->subaddress; - break; - case TIFFTAG_FAXRECVTIME: - *va_arg(ap, uint32*) = sp->recvtime; - break; - case TIFFTAG_FAXDCS: - *va_arg(ap, char**) = sp->faxdcs; - break; - default: - return (*sp->vgetparent)(tif, tag, ap); - } - return (1); -} - -static void -Fax3PrintDir(TIFF* tif, FILE* fd, long flags) -{ - Fax3BaseState* sp = Fax3State(tif); - - assert(sp != 0); - - (void) flags; - if (TIFFFieldSet(tif,FIELD_OPTIONS)) { - const char* sep = " "; - if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX4) { - fprintf(fd, " Group 4 Options:"); - if (sp->groupoptions & GROUP4OPT_UNCOMPRESSED) - fprintf(fd, "%suncompressed data", sep); - } else { - - fprintf(fd, " Group 3 Options:"); - if (sp->groupoptions & GROUP3OPT_2DENCODING) - fprintf(fd, "%s2-d encoding", sep), sep = "+"; - if (sp->groupoptions & GROUP3OPT_FILLBITS) - fprintf(fd, "%sEOL padding", sep), sep = "+"; - if (sp->groupoptions & GROUP3OPT_UNCOMPRESSED) - fprintf(fd, "%suncompressed data", sep); - } - fprintf(fd, " (%lu = 0x%lx)\n", - (unsigned long) sp->groupoptions, - (unsigned long) sp->groupoptions); - } - if (TIFFFieldSet(tif,FIELD_CLEANFAXDATA)) { - fprintf(fd, " Fax Data:"); - switch (sp->cleanfaxdata) { - case CLEANFAXDATA_CLEAN: - fprintf(fd, " clean"); - break; - case CLEANFAXDATA_REGENERATED: - fprintf(fd, " receiver regenerated"); - break; - case CLEANFAXDATA_UNCLEAN: - fprintf(fd, " uncorrected errors"); - break; - } - fprintf(fd, " (%u = 0x%x)\n", - sp->cleanfaxdata, sp->cleanfaxdata); - } - if (TIFFFieldSet(tif,FIELD_BADFAXLINES)) - fprintf(fd, " Bad Fax Lines: %lu\n", - (unsigned long) sp->badfaxlines); - if (TIFFFieldSet(tif,FIELD_BADFAXRUN)) - fprintf(fd, " Consecutive Bad Fax Lines: %lu\n", - (unsigned long) sp->badfaxrun); - if (TIFFFieldSet(tif,FIELD_RECVPARAMS)) - fprintf(fd, " Fax Receive Parameters: %08lx\n", - (unsigned long) sp->recvparams); - if (TIFFFieldSet(tif,FIELD_SUBADDRESS)) - fprintf(fd, " Fax SubAddress: %s\n", sp->subaddress); - if (TIFFFieldSet(tif,FIELD_RECVTIME)) - fprintf(fd, " Fax Receive Time: %lu secs\n", - (unsigned long) sp->recvtime); - if (TIFFFieldSet(tif,FIELD_FAXDCS)) - fprintf(fd, " Fax DCS: %s\n", sp->faxdcs); -} - -static int -InitCCITTFax3(TIFF* tif) -{ - Fax3BaseState* sp; - - /* - * Merge codec-specific tag information. - */ - if (!_TIFFMergeFieldInfo(tif, faxFieldInfo, N(faxFieldInfo))) { - TIFFErrorExt(tif->tif_clientdata, "InitCCITTFax3", - "Merging common CCITT Fax codec-specific tags failed"); - return 0; - } - - /* - * Allocate state block so tag methods have storage to record values. - */ - tif->tif_data = (tidata_t) - _TIFFmalloc(sizeof (Fax3CodecState)); - - if (tif->tif_data == NULL) { - TIFFErrorExt(tif->tif_clientdata, "TIFFInitCCITTFax3", - "%s: No space for state block", tif->tif_name); - return (0); - } - - sp = Fax3State(tif); - sp->rw_mode = tif->tif_mode; - - /* - * Override parent get/set field methods. - */ - sp->vgetparent = tif->tif_tagmethods.vgetfield; - tif->tif_tagmethods.vgetfield = Fax3VGetField; /* hook for codec tags */ - sp->vsetparent = tif->tif_tagmethods.vsetfield; - tif->tif_tagmethods.vsetfield = Fax3VSetField; /* hook for codec tags */ - sp->printdir = tif->tif_tagmethods.printdir; - tif->tif_tagmethods.printdir = Fax3PrintDir; /* hook for codec tags */ - sp->groupoptions = 0; - sp->recvparams = 0; - sp->subaddress = NULL; - sp->faxdcs = NULL; - - if (sp->rw_mode == O_RDONLY) /* FIXME: improve for in place update */ - tif->tif_flags |= TIFF_NOBITREV; /* decoder does bit reversal */ - DecoderState(tif)->runs = NULL; - TIFFSetField(tif, TIFFTAG_FAXFILLFUNC, _TIFFFax3fillruns); - EncoderState(tif)->refline = NULL; - - /* - * Install codec methods. - */ - tif->tif_setupdecode = Fax3SetupState; - tif->tif_predecode = Fax3PreDecode; - tif->tif_decoderow = Fax3Decode1D; - tif->tif_decodestrip = Fax3Decode1D; - tif->tif_decodetile = Fax3Decode1D; - tif->tif_setupencode = Fax3SetupState; - tif->tif_preencode = Fax3PreEncode; - tif->tif_postencode = Fax3PostEncode; - tif->tif_encoderow = Fax3Encode; - tif->tif_encodestrip = Fax3Encode; - tif->tif_encodetile = Fax3Encode; - tif->tif_close = Fax3Close; - tif->tif_cleanup = Fax3Cleanup; - - return (1); -} - -int -TIFFInitCCITTFax3(TIFF* tif, int scheme) -{ - (void) scheme; - if (InitCCITTFax3(tif)) { - /* - * Merge codec-specific tag information. - */ - if (!_TIFFMergeFieldInfo(tif, fax3FieldInfo, N(fax3FieldInfo))) { - TIFFErrorExt(tif->tif_clientdata, "TIFFInitCCITTFax3", - "Merging CCITT Fax 3 codec-specific tags failed"); - return 0; - } - - /* - * The default format is Class/F-style w/o RTC. - */ - return TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_CLASSF); - } else - return 01; -} - -/* - * CCITT Group 4 (T.6) Facsimile-compatible - * Compression Scheme Support. - */ - -#define SWAP(t,a,b) { t x; x = (a); (a) = (b); (b) = x; } -/* - * Decode the requested amount of G4-encoded data. - */ -static int -Fax4Decode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) -{ - DECLARE_STATE_2D(tif, sp, "Fax4Decode"); - - (void) s; - CACHE_STATE(tif, sp); - while ((long)occ > 0) { - a0 = 0; - RunLength = 0; - pa = thisrun = sp->curruns; - pb = sp->refruns; - b1 = *pb++; -#ifdef FAX3_DEBUG - printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail); - printf("-------------------- %d\n", tif->tif_row); - fflush(stdout); -#endif - EXPAND2D(EOFG4); - if (EOLcnt) - goto EOFG4; - (*sp->fill)(buf, thisrun, pa, lastx); - SETVALUE(0); /* imaginary change for reference */ - SWAP(uint32*, sp->curruns, sp->refruns); - buf += sp->b.rowbytes; - occ -= sp->b.rowbytes; - sp->line++; - continue; - EOFG4: - NeedBits16( 13, BADG4 ); - BADG4: -#ifdef FAX3_DEBUG - if ( GetBits(13) != 0x1001 ) - fputs( "Bad EOFB\n", stderr ); -#endif - ClrBits( 13 ); - (*sp->fill)(buf, thisrun, pa, lastx); - UNCACHE_STATE(tif, sp); - return ( sp->line ? 1 : -1); /* don't error on badly-terminated strips */ - } - UNCACHE_STATE(tif, sp); - return (1); -} -#undef SWAP - -/* - * Encode the requested amount of data. - */ -static int -Fax4Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - Fax3CodecState *sp = EncoderState(tif); - - (void) s; - while ((long)cc > 0) { - if (!Fax3Encode2DRow(tif, bp, sp->refline, sp->b.rowpixels)) - return (0); - _TIFFmemcpy(sp->refline, bp, sp->b.rowbytes); - bp += sp->b.rowbytes; - cc -= sp->b.rowbytes; - } - return (1); -} - -static int -Fax4PostEncode(TIFF* tif) -{ - Fax3CodecState *sp = EncoderState(tif); - - /* terminate strip w/ EOFB */ - Fax3PutBits(tif, EOL, 12); - Fax3PutBits(tif, EOL, 12); - if (sp->bit != 8) - Fax3FlushBits(tif, sp); - return (1); -} - -int -TIFFInitCCITTFax4(TIFF* tif, int scheme) -{ - (void) scheme; - if (InitCCITTFax3(tif)) { /* reuse G3 support */ - /* - * Merge codec-specific tag information. - */ - if (!_TIFFMergeFieldInfo(tif, fax4FieldInfo, N(fax4FieldInfo))) { - TIFFErrorExt(tif->tif_clientdata, "TIFFInitCCITTFax4", - "Merging CCITT Fax 4 codec-specific tags failed"); - return 0; - } - - tif->tif_decoderow = Fax4Decode; - tif->tif_decodestrip = Fax4Decode; - tif->tif_decodetile = Fax4Decode; - tif->tif_encoderow = Fax4Encode; - tif->tif_encodestrip = Fax4Encode; - tif->tif_encodetile = Fax4Encode; - tif->tif_postencode = Fax4PostEncode; - /* - * Suppress RTC at the end of each strip. - */ - return TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_NORTC); - } else - return (0); -} - -/* - * CCITT Group 3 1-D Modified Huffman RLE Compression Support. - * (Compression algorithms 2 and 32771) - */ - -/* - * Decode the requested amount of RLE-encoded data. - */ -static int -Fax3DecodeRLE(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) -{ - DECLARE_STATE(tif, sp, "Fax3DecodeRLE"); - int mode = sp->b.mode; - - (void) s; - CACHE_STATE(tif, sp); - thisrun = sp->curruns; - while ((long)occ > 0) { - a0 = 0; - RunLength = 0; - pa = thisrun; -#ifdef FAX3_DEBUG - printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail); - printf("-------------------- %d\n", tif->tif_row); - fflush(stdout); -#endif - EXPAND1D(EOFRLE); - (*sp->fill)(buf, thisrun, pa, lastx); - /* - * Cleanup at the end of the row. - */ - if (mode & FAXMODE_BYTEALIGN) { - int n = BitsAvail - (BitsAvail &~ 7); - ClrBits(n); - } else if (mode & FAXMODE_WORDALIGN) { - int n = BitsAvail - (BitsAvail &~ 15); - ClrBits(n); - if (BitsAvail == 0 && !isAligned(cp, uint16)) - cp++; - } - buf += sp->b.rowbytes; - occ -= sp->b.rowbytes; - sp->line++; - continue; - EOFRLE: /* premature EOF */ - (*sp->fill)(buf, thisrun, pa, lastx); - UNCACHE_STATE(tif, sp); - return (-1); - } - UNCACHE_STATE(tif, sp); - return (1); -} - -int -TIFFInitCCITTRLE(TIFF* tif, int scheme) -{ - (void) scheme; - if (InitCCITTFax3(tif)) { /* reuse G3 support */ - tif->tif_decoderow = Fax3DecodeRLE; - tif->tif_decodestrip = Fax3DecodeRLE; - tif->tif_decodetile = Fax3DecodeRLE; - /* - * Suppress RTC+EOLs when encoding and byte-align data. - */ - return TIFFSetField(tif, TIFFTAG_FAXMODE, - FAXMODE_NORTC|FAXMODE_NOEOL|FAXMODE_BYTEALIGN); - } else - return (0); -} - -int -TIFFInitCCITTRLEW(TIFF* tif, int scheme) -{ - (void) scheme; - if (InitCCITTFax3(tif)) { /* reuse G3 support */ - tif->tif_decoderow = Fax3DecodeRLE; - tif->tif_decodestrip = Fax3DecodeRLE; - tif->tif_decodetile = Fax3DecodeRLE; - /* - * Suppress RTC+EOLs when encoding and word-align data. - */ - return TIFFSetField(tif, TIFFTAG_FAXMODE, - FAXMODE_NORTC|FAXMODE_NOEOL|FAXMODE_WORDALIGN); - } else - return (0); -} -#endif /* CCITT_SUPPORT */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_fax3.h b/plugins/AdvaImg/src/LibTIFF/tif_fax3.h deleted file mode 100644 index ec2811f660..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_fax3.h +++ /dev/null @@ -1,538 +0,0 @@ -/* $Id: tif_fax3.h,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1990-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _FAX3_ -#define _FAX3_ -/* - * TIFF Library. - * - * CCITT Group 3 (T.4) and Group 4 (T.6) Decompression Support. - * - * Decoder support is derived, with permission, from the code - * in Frank Cringle's viewfax program; - * Copyright (C) 1990, 1995 Frank D. Cringle. - */ -#include "tiff.h" - -/* - * To override the default routine used to image decoded - * spans one can use the pseduo tag TIFFTAG_FAXFILLFUNC. - * The routine must have the type signature given below; - * for example: - * - * fillruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx) - * - * where buf is place to set the bits, runs is the array of b&w run - * lengths (white then black), erun is the last run in the array, and - * lastx is the width of the row in pixels. Fill routines can assume - * the run array has room for at least lastx runs and can overwrite - * data in the run array as needed (e.g. to append zero runs to bring - * the count up to a nice multiple). - */ -typedef void (*TIFFFaxFillFunc)(unsigned char*, uint32*, uint32*, uint32); - -/* - * The default run filler; made external for other decoders. - */ -#if defined(__cplusplus) -extern "C" { -#endif -extern void _TIFFFax3fillruns(unsigned char*, uint32*, uint32*, uint32); -#if defined(__cplusplus) -} -#endif - - -/* finite state machine codes */ -#define S_Null 0 -#define S_Pass 1 -#define S_Horiz 2 -#define S_V0 3 -#define S_VR 4 -#define S_VL 5 -#define S_Ext 6 -#define S_TermW 7 -#define S_TermB 8 -#define S_MakeUpW 9 -#define S_MakeUpB 10 -#define S_MakeUp 11 -#define S_EOL 12 - -typedef struct { /* state table entry */ - unsigned char State; /* see above */ - unsigned char Width; /* width of code in bits */ - uint32 Param; /* unsigned 32-bit run length in bits */ -} TIFFFaxTabEnt; - -extern const TIFFFaxTabEnt TIFFFaxMainTable[]; -extern const TIFFFaxTabEnt TIFFFaxWhiteTable[]; -extern const TIFFFaxTabEnt TIFFFaxBlackTable[]; - -/* - * The following macros define the majority of the G3/G4 decoder - * algorithm using the state tables defined elsewhere. To build - * a decoder you need some setup code and some glue code. Note - * that you may also need/want to change the way the NeedBits* - * macros get input data if, for example, you know the data to be - * decoded is properly aligned and oriented (doing so before running - * the decoder can be a big performance win). - * - * Consult the decoder in the TIFF library for an idea of what you - * need to define and setup to make use of these definitions. - * - * NB: to enable a debugging version of these macros define FAX3_DEBUG - * before including this file. Trace output goes to stdout. - */ - -#ifndef EndOfData -#define EndOfData() (cp >= ep) -#endif -/* - * Need <=8 or <=16 bits of input data. Unlike viewfax we - * cannot use/assume a word-aligned, properly bit swizzled - * input data set because data may come from an arbitrarily - * aligned, read-only source such as a memory-mapped file. - * Note also that the viewfax decoder does not check for - * running off the end of the input data buffer. This is - * possible for G3-encoded data because it prescans the input - * data to count EOL markers, but can cause problems for G4 - * data. In any event, we don't prescan and must watch for - * running out of data since we can't permit the library to - * scan past the end of the input data buffer. - * - * Finally, note that we must handle remaindered data at the end - * of a strip specially. The coder asks for a fixed number of - * bits when scanning for the next code. This may be more bits - * than are actually present in the data stream. If we appear - * to run out of data but still have some number of valid bits - * remaining then we makeup the requested amount with zeros and - * return successfully. If the returned data is incorrect then - * we should be called again and get a premature EOF error; - * otherwise we should get the right answer. - */ -#ifndef NeedBits8 -#define NeedBits8(n,eoflab) do { \ - if (BitsAvail < (n)) { \ - if (EndOfData()) { \ - if (BitsAvail == 0) /* no valid bits */ \ - goto eoflab; \ - BitsAvail = (n); /* pad with zeros */ \ - } else { \ - BitAcc |= ((uint32) bitmap[*cp++])<>= (n); \ -} while (0) - -#ifdef FAX3_DEBUG -static const char* StateNames[] = { - "Null ", - "Pass ", - "Horiz ", - "V0 ", - "VR ", - "VL ", - "Ext ", - "TermW ", - "TermB ", - "MakeUpW", - "MakeUpB", - "MakeUp ", - "EOL ", -}; -#define DEBUG_SHOW putchar(BitAcc & (1 << t) ? '1' : '0') -#define LOOKUP8(wid,tab,eoflab) do { \ - int t; \ - NeedBits8(wid,eoflab); \ - TabEnt = tab + GetBits(wid); \ - printf("%08lX/%d: %s%5d\t", (long) BitAcc, BitsAvail, \ - StateNames[TabEnt->State], TabEnt->Param); \ - for (t = 0; t < TabEnt->Width; t++) \ - DEBUG_SHOW; \ - putchar('\n'); \ - fflush(stdout); \ - ClrBits(TabEnt->Width); \ -} while (0) -#define LOOKUP16(wid,tab,eoflab) do { \ - int t; \ - NeedBits16(wid,eoflab); \ - TabEnt = tab + GetBits(wid); \ - printf("%08lX/%d: %s%5d\t", (long) BitAcc, BitsAvail, \ - StateNames[TabEnt->State], TabEnt->Param); \ - for (t = 0; t < TabEnt->Width; t++) \ - DEBUG_SHOW; \ - putchar('\n'); \ - fflush(stdout); \ - ClrBits(TabEnt->Width); \ -} while (0) - -#define SETVALUE(x) do { \ - *pa++ = RunLength + (x); \ - printf("SETVALUE: %d\t%d\n", RunLength + (x), a0); \ - a0 += x; \ - RunLength = 0; \ -} while (0) -#else -#define LOOKUP8(wid,tab,eoflab) do { \ - NeedBits8(wid,eoflab); \ - TabEnt = tab + GetBits(wid); \ - ClrBits(TabEnt->Width); \ -} while (0) -#define LOOKUP16(wid,tab,eoflab) do { \ - NeedBits16(wid,eoflab); \ - TabEnt = tab + GetBits(wid); \ - ClrBits(TabEnt->Width); \ -} while (0) - -/* - * Append a run to the run length array for the - * current row and reset decoding state. - */ -#define SETVALUE(x) do { \ - *pa++ = RunLength + (x); \ - a0 += (x); \ - RunLength = 0; \ -} while (0) -#endif - -/* - * Synchronize input decoding at the start of each - * row by scanning for an EOL (if appropriate) and - * skipping any trash data that might be present - * after a decoding error. Note that the decoding - * done elsewhere that recognizes an EOL only consumes - * 11 consecutive zero bits. This means that if EOLcnt - * is non-zero then we still need to scan for the final flag - * bit that is part of the EOL code. - */ -#define SYNC_EOL(eoflab) do { \ - if (EOLcnt == 0) { \ - for (;;) { \ - NeedBits16(11,eoflab); \ - if (GetBits(11) == 0) \ - break; \ - ClrBits(1); \ - } \ - } \ - for (;;) { \ - NeedBits8(8,eoflab); \ - if (GetBits(8)) \ - break; \ - ClrBits(8); \ - } \ - while (GetBits(1) == 0) \ - ClrBits(1); \ - ClrBits(1); /* EOL bit */ \ - EOLcnt = 0; /* reset EOL counter/flag */ \ -} while (0) - -/* - * Cleanup the array of runs after decoding a row. - * We adjust final runs to insure the user buffer is not - * overwritten and/or undecoded area is white filled. - */ -#define CLEANUP_RUNS() do { \ - if (RunLength) \ - SETVALUE(0); \ - if (a0 != lastx) { \ - badlength(a0, lastx); \ - while (a0 > lastx && pa > thisrun) \ - a0 -= *--pa; \ - if (a0 < lastx) { \ - if (a0 < 0) \ - a0 = 0; \ - if ((pa-thisrun)&1) \ - SETVALUE(0); \ - SETVALUE(lastx - a0); \ - } else if (a0 > lastx) { \ - SETVALUE(lastx); \ - SETVALUE(0); \ - } \ - } \ -} while (0) - -/* - * Decode a line of 1D-encoded data. - * - * The line expanders are written as macros so that they can be reused - * but still have direct access to the local variables of the "calling" - * function. - * - * Note that unlike the original version we have to explicitly test for - * a0 >= lastx after each black/white run is decoded. This is because - * the original code depended on the input data being zero-padded to - * insure the decoder recognized an EOL before running out of data. - */ -#define EXPAND1D(eoflab) do { \ - for (;;) { \ - for (;;) { \ - LOOKUP16(12, TIFFFaxWhiteTable, eof1d); \ - switch (TabEnt->State) { \ - case S_EOL: \ - EOLcnt = 1; \ - goto done1d; \ - case S_TermW: \ - SETVALUE(TabEnt->Param); \ - goto doneWhite1d; \ - case S_MakeUpW: \ - case S_MakeUp: \ - a0 += TabEnt->Param; \ - RunLength += TabEnt->Param; \ - break; \ - default: \ - unexpected("WhiteTable", a0); \ - goto done1d; \ - } \ - } \ - doneWhite1d: \ - if (a0 >= lastx) \ - goto done1d; \ - for (;;) { \ - LOOKUP16(13, TIFFFaxBlackTable, eof1d); \ - switch (TabEnt->State) { \ - case S_EOL: \ - EOLcnt = 1; \ - goto done1d; \ - case S_TermB: \ - SETVALUE(TabEnt->Param); \ - goto doneBlack1d; \ - case S_MakeUpB: \ - case S_MakeUp: \ - a0 += TabEnt->Param; \ - RunLength += TabEnt->Param; \ - break; \ - default: \ - unexpected("BlackTable", a0); \ - goto done1d; \ - } \ - } \ - doneBlack1d: \ - if (a0 >= lastx) \ - goto done1d; \ - if ( *(pa-1) == 0 && *(pa-2) == 0 ) \ - pa -= 2; \ - } \ -eof1d: \ - prematureEOF(a0); \ - CLEANUP_RUNS(); \ - goto eoflab; \ -done1d: \ - CLEANUP_RUNS(); \ -} while (0) - -/* - * Update the value of b1 using the array - * of runs for the reference line. - */ -#define CHECK_b1 do { \ - if (pa != thisrun) while (b1 <= a0 && b1 < lastx) { \ - b1 += pb[0] + pb[1]; \ - pb += 2; \ - } \ -} while (0) - -/* - * Expand a row of 2D-encoded data. - */ -#define EXPAND2D(eoflab) do { \ - while (a0 < lastx) { \ - LOOKUP8(7, TIFFFaxMainTable, eof2d); \ - switch (TabEnt->State) { \ - case S_Pass: \ - CHECK_b1; \ - b1 += *pb++; \ - RunLength += b1 - a0; \ - a0 = b1; \ - b1 += *pb++; \ - break; \ - case S_Horiz: \ - if ((pa-thisrun)&1) { \ - for (;;) { /* black first */ \ - LOOKUP16(13, TIFFFaxBlackTable, eof2d); \ - switch (TabEnt->State) { \ - case S_TermB: \ - SETVALUE(TabEnt->Param); \ - goto doneWhite2da; \ - case S_MakeUpB: \ - case S_MakeUp: \ - a0 += TabEnt->Param; \ - RunLength += TabEnt->Param; \ - break; \ - default: \ - goto badBlack2d; \ - } \ - } \ - doneWhite2da:; \ - for (;;) { /* then white */ \ - LOOKUP16(12, TIFFFaxWhiteTable, eof2d); \ - switch (TabEnt->State) { \ - case S_TermW: \ - SETVALUE(TabEnt->Param); \ - goto doneBlack2da; \ - case S_MakeUpW: \ - case S_MakeUp: \ - a0 += TabEnt->Param; \ - RunLength += TabEnt->Param; \ - break; \ - default: \ - goto badWhite2d; \ - } \ - } \ - doneBlack2da:; \ - } else { \ - for (;;) { /* white first */ \ - LOOKUP16(12, TIFFFaxWhiteTable, eof2d); \ - switch (TabEnt->State) { \ - case S_TermW: \ - SETVALUE(TabEnt->Param); \ - goto doneWhite2db; \ - case S_MakeUpW: \ - case S_MakeUp: \ - a0 += TabEnt->Param; \ - RunLength += TabEnt->Param; \ - break; \ - default: \ - goto badWhite2d; \ - } \ - } \ - doneWhite2db:; \ - for (;;) { /* then black */ \ - LOOKUP16(13, TIFFFaxBlackTable, eof2d); \ - switch (TabEnt->State) { \ - case S_TermB: \ - SETVALUE(TabEnt->Param); \ - goto doneBlack2db; \ - case S_MakeUpB: \ - case S_MakeUp: \ - a0 += TabEnt->Param; \ - RunLength += TabEnt->Param; \ - break; \ - default: \ - goto badBlack2d; \ - } \ - } \ - doneBlack2db:; \ - } \ - CHECK_b1; \ - break; \ - case S_V0: \ - CHECK_b1; \ - SETVALUE(b1 - a0); \ - b1 += *pb++; \ - break; \ - case S_VR: \ - CHECK_b1; \ - SETVALUE(b1 - a0 + TabEnt->Param); \ - b1 += *pb++; \ - break; \ - case S_VL: \ - CHECK_b1; \ - if (b1 <= (int) (a0 + TabEnt->Param)) { \ - if (b1 < (int) (a0 + TabEnt->Param) || pa != thisrun) { \ - unexpected("VL", a0); \ - goto eol2d; \ - } \ - } \ - SETVALUE(b1 - a0 - TabEnt->Param); \ - b1 -= *--pb; \ - break; \ - case S_Ext: \ - *pa++ = lastx - a0; \ - extension(a0); \ - goto eol2d; \ - case S_EOL: \ - *pa++ = lastx - a0; \ - NeedBits8(4,eof2d); \ - if (GetBits(4)) \ - unexpected("EOL", a0); \ - ClrBits(4); \ - EOLcnt = 1; \ - goto eol2d; \ - default: \ - badMain2d: \ - unexpected("MainTable", a0); \ - goto eol2d; \ - badBlack2d: \ - unexpected("BlackTable", a0); \ - goto eol2d; \ - badWhite2d: \ - unexpected("WhiteTable", a0); \ - goto eol2d; \ - eof2d: \ - prematureEOF(a0); \ - CLEANUP_RUNS(); \ - goto eoflab; \ - } \ - } \ - if (RunLength) { \ - if (RunLength + a0 < lastx) { \ - /* expect a final V0 */ \ - NeedBits8(1,eof2d); \ - if (!GetBits(1)) \ - goto badMain2d; \ - ClrBits(1); \ - } \ - SETVALUE(0); \ - } \ -eol2d: \ - CLEANUP_RUNS(); \ -} while (0) -#endif /* _FAX3_ */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_fax3sm.c b/plugins/AdvaImg/src/LibTIFF/tif_fax3sm.c deleted file mode 100644 index 1e2fe42316..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_fax3sm.c +++ /dev/null @@ -1,1260 +0,0 @@ -/* WARNING, this file was automatically generated by the - mkg3states program */ -#include "tiff.h" -#include "tif_fax3.h" - const TIFFFaxTabEnt TIFFFaxMainTable[128] = { -{12,7,0},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0},{1,4,0},{3,1,0}, -{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0},{5,6,2},{3,1,0},{5,3,1},{3,1,0}, -{2,3,0},{3,1,0},{4,3,1},{3,1,0},{1,4,0},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0}, -{4,3,1},{3,1,0},{5,7,3},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0}, -{1,4,0},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0},{4,6,2},{3,1,0}, -{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0},{1,4,0},{3,1,0},{5,3,1},{3,1,0}, -{2,3,0},{3,1,0},{4,3,1},{3,1,0},{6,7,0},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0}, -{4,3,1},{3,1,0},{1,4,0},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0}, -{5,6,2},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0},{1,4,0},{3,1,0}, -{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0},{4,7,3},{3,1,0},{5,3,1},{3,1,0}, -{2,3,0},{3,1,0},{4,3,1},{3,1,0},{1,4,0},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0}, -{4,3,1},{3,1,0},{4,6,2},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0}, -{1,4,0},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0} -}; - const TIFFFaxTabEnt TIFFFaxWhiteTable[4096] = { -{12,11,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128}, -{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5}, -{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6}, -{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3}, -{9,9,1472},{7,4,5},{7,8,43},{7,6,17},{9,9,1216},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9}, -{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7}, -{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,960},{7,4,6},{7,8,31},{7,5,8}, -{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5}, -{7,7,26},{7,5,9},{9,9,704},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4}, -{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6}, -{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,11,1792},{7,4,3}, -{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14}, -{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16}, -{9,9,832},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}, -{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128}, -{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1600},{7,4,5}, -{7,8,44},{7,6,17},{9,9,1344},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6}, -{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3}, -{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1088},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9}, -{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7}, -{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8}, -{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5}, -{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4}, -{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6}, -{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3}, -{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15}, -{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1536},{7,4,5},{7,8,43},{7,6,17}, -{9,9,1280},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}, -{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128}, -{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5}, -{7,8,41},{7,6,16},{9,9,1024},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,768},{7,4,6}, -{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3}, -{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,11,1856},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9}, -{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7}, -{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,896},{7,4,6},{7,7,19},{7,5,8}, -{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5}, -{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4}, -{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1728},{7,4,5},{7,8,44},{7,6,17},{9,9,1408},{7,4,6}, -{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3}, -{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14}, -{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16}, -{9,9,1152},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}, -{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128}, -{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5}, -{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6}, -{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3}, -{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9}, -{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7}, -{7,6,13},{7,4,3},{9,9,1472},{7,4,5},{7,8,43},{7,6,17},{9,9,1216},{7,4,6},{7,6,1},{7,5,8}, -{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5}, -{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4}, -{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,960},{7,4,6}, -{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3}, -{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,704},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15}, -{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17}, -{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}, -{11,12,2112},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128}, -{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5}, -{7,8,40},{7,6,16},{9,9,832},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6}, -{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3}, -{9,9,1600},{7,4,5},{7,8,44},{7,6,17},{9,9,1344},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9}, -{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7}, -{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1088},{7,4,6},{7,8,32},{7,5,8}, -{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5}, -{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4}, -{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6}, -{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{0,0,0},{7,4,3}, -{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14}, -{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16}, -{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}, -{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128}, -{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1536},{7,4,5}, -{7,8,43},{7,6,17},{9,9,1280},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6}, -{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3}, -{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,1024},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9}, -{9,9,768},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7}, -{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8}, -{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,12,2368},{7,4,3},{7,5,11},{7,4,5}, -{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4}, -{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,896},{7,4,6}, -{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3}, -{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15}, -{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1728},{7,4,5},{7,8,44},{7,6,17}, -{9,9,1408},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}, -{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128}, -{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5}, -{7,8,42},{7,6,16},{9,9,1152},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6}, -{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3}, -{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9}, -{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7}, -{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8}, -{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5}, -{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4}, -{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1472},{7,4,5},{7,8,43},{7,6,17},{9,9,1216},{7,4,6}, -{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3}, -{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14}, -{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16}, -{9,9,960},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}, -{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,704},{7,4,6},{7,8,37},{9,5,128}, -{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5}, -{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{11,12,1984},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6}, -{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3}, -{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,832},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9}, -{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7}, -{7,6,13},{7,4,3},{9,9,1600},{7,4,5},{7,8,44},{7,6,17},{9,9,1344},{7,4,6},{7,6,1},{7,5,8}, -{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5}, -{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4}, -{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1088},{7,4,6}, -{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3}, -{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15}, -{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17}, -{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}, -{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128}, -{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5}, -{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6}, -{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3}, -{9,9,1536},{7,4,5},{7,8,43},{7,6,17},{9,9,1280},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9}, -{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7}, -{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,1024},{7,4,6},{7,8,31},{7,5,8}, -{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5}, -{7,7,26},{7,5,9},{9,9,768},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4}, -{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6}, -{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,11,1920},{7,4,3}, -{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14}, -{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16}, -{9,9,896},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}, -{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128}, -{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1728},{7,4,5}, -{7,8,44},{7,6,17},{9,9,1408},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6}, -{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3}, -{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1152},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9}, -{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7}, -{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8}, -{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5}, -{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4}, -{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6}, -{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3}, -{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15}, -{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1472},{7,4,5},{7,8,43},{7,6,17}, -{9,9,1216},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}, -{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128}, -{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5}, -{7,8,41},{7,6,16},{9,9,960},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,704},{7,4,6}, -{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3}, -{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,12,2240},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9}, -{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7}, -{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,832},{7,4,6},{7,7,19},{7,5,8}, -{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5}, -{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4}, -{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1600},{7,4,5},{7,8,44},{7,6,17},{9,9,1344},{7,4,6}, -{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3}, -{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14}, -{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16}, -{9,9,1088},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}, -{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128}, -{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5}, -{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6}, -{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3}, -{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9}, -{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7}, -{7,6,13},{7,4,3},{9,9,1536},{7,4,5},{7,8,43},{7,6,17},{9,9,1280},{7,4,6},{7,6,1},{7,5,8}, -{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5}, -{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4}, -{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,1024},{7,4,6}, -{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3}, -{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,768},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15}, -{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17}, -{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}, -{11,12,2496},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128}, -{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5}, -{7,8,40},{7,6,16},{9,9,896},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6}, -{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3}, -{9,9,1728},{7,4,5},{7,8,44},{7,6,17},{9,9,1408},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9}, -{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7}, -{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1152},{7,4,6},{7,8,32},{7,5,8}, -{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5}, -{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4}, -{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6}, -{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{12,11,0},{7,4,3}, -{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14}, -{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16}, -{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}, -{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128}, -{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1472},{7,4,5}, -{7,8,43},{7,6,17},{9,9,1216},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6}, -{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3}, -{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,960},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9}, -{9,9,704},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7}, -{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8}, -{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,11,1792},{7,4,3},{7,5,11},{7,4,5}, -{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4}, -{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,832},{7,4,6}, -{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3}, -{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15}, -{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1600},{7,4,5},{7,8,44},{7,6,17}, -{9,9,1344},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}, -{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128}, -{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5}, -{7,8,42},{7,6,16},{9,9,1088},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6}, -{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3}, -{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9}, -{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7}, -{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8}, -{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5}, -{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4}, -{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1536},{7,4,5},{7,8,43},{7,6,17},{9,9,1280},{7,4,6}, -{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3}, -{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14}, -{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16}, -{9,9,1024},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}, -{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,768},{7,4,6},{7,8,37},{9,5,128}, -{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5}, -{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{11,11,1856},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6}, -{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3}, -{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,896},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9}, -{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7}, -{7,6,13},{7,4,3},{9,9,1728},{7,4,5},{7,8,44},{7,6,17},{9,9,1408},{7,4,6},{7,6,1},{7,5,8}, -{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5}, -{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4}, -{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1152},{7,4,6}, -{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3}, -{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15}, -{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17}, -{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}, -{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128}, -{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5}, -{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6}, -{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3}, -{9,9,1472},{7,4,5},{7,8,43},{7,6,17},{9,9,1216},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9}, -{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7}, -{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,960},{7,4,6},{7,8,31},{7,5,8}, -{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5}, -{7,7,26},{7,5,9},{9,9,704},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4}, -{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6}, -{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,12,2176},{7,4,3}, -{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14}, -{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16}, -{9,9,832},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}, -{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128}, -{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1600},{7,4,5}, -{7,8,44},{7,6,17},{9,9,1344},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6}, -{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3}, -{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1088},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9}, -{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7}, -{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8}, -{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5}, -{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4}, -{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6}, -{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3}, -{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15}, -{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1536},{7,4,5},{7,8,43},{7,6,17}, -{9,9,1280},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}, -{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128}, -{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5}, -{7,8,41},{7,6,16},{9,9,1024},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,768},{7,4,6}, -{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3}, -{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,12,2432},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9}, -{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7}, -{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,896},{7,4,6},{7,7,19},{7,5,8}, -{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5}, -{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4}, -{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1728},{7,4,5},{7,8,44},{7,6,17},{9,9,1408},{7,4,6}, -{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3}, -{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14}, -{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16}, -{9,9,1152},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}, -{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128}, -{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5}, -{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6}, -{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3}, -{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9}, -{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7}, -{7,6,13},{7,4,3},{9,9,1472},{7,4,5},{7,8,43},{7,6,17},{9,9,1216},{7,4,6},{7,6,1},{7,5,8}, -{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5}, -{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4}, -{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,960},{7,4,6}, -{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3}, -{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,704},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15}, -{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17}, -{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}, -{11,12,2048},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128}, -{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5}, -{7,8,40},{7,6,16},{9,9,832},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6}, -{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3}, -{9,9,1600},{7,4,5},{7,8,44},{7,6,17},{9,9,1344},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9}, -{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7}, -{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1088},{7,4,6},{7,8,32},{7,5,8}, -{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5}, -{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4}, -{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6}, -{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{0,0,0},{7,4,3}, -{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14}, -{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16}, -{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}, -{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128}, -{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1536},{7,4,5}, -{7,8,43},{7,6,17},{9,9,1280},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6}, -{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3}, -{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,1024},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9}, -{9,9,768},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7}, -{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8}, -{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,11,1920},{7,4,3},{7,5,11},{7,4,5}, -{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4}, -{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,896},{7,4,6}, -{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3}, -{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15}, -{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1728},{7,4,5},{7,8,44},{7,6,17}, -{9,9,1408},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}, -{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128}, -{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5}, -{7,8,42},{7,6,16},{9,9,1152},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6}, -{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3}, -{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9}, -{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7}, -{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8}, -{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5}, -{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4}, -{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1472},{7,4,5},{7,8,43},{7,6,17},{9,9,1216},{7,4,6}, -{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3}, -{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14}, -{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16}, -{9,9,960},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}, -{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,704},{7,4,6},{7,8,37},{9,5,128}, -{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5}, -{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{11,12,2304},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6}, -{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3}, -{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,832},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9}, -{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7}, -{7,6,13},{7,4,3},{9,9,1600},{7,4,5},{7,8,44},{7,6,17},{9,9,1344},{7,4,6},{7,6,1},{7,5,8}, -{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5}, -{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4}, -{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1088},{7,4,6}, -{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3}, -{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15}, -{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17}, -{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}, -{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128}, -{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5}, -{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6}, -{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3}, -{9,9,1536},{7,4,5},{7,8,43},{7,6,17},{9,9,1280},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9}, -{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7}, -{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,1024},{7,4,6},{7,8,31},{7,5,8}, -{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5}, -{7,7,26},{7,5,9},{9,9,768},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4}, -{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6}, -{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,12,2560},{7,4,3}, -{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14}, -{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16}, -{9,9,896},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}, -{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128}, -{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1728},{7,4,5}, -{7,8,44},{7,6,17},{9,9,1408},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4}, -{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6}, -{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3}, -{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1152},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64}, -{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9}, -{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7}, -{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8}, -{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7} -}; - const TIFFFaxTabEnt TIFFFaxBlackTable[8192] = { -{12,11,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,18},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,17},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,11,1792},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,11,23},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,20},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,11,25},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,12,128},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,12,56},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,12,30},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,11,1856},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,57},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,11,21},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,54},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,52},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,48},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{11,12,2112},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,12,44},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,36},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,12,384},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,28},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,12,60},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,40},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2368},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,16},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{10,10,64},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,18},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,10,17},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{11,12,1984},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,50},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,12,34},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,1664},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,26},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,1408},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,32},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,11,1920},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,12,61},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,42},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{10,13,1024},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{10,13,768},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,12,62},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2240},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,46},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,12,38},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,512},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,11,19},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,24},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,22},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{11,12,2496},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,10,16},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,0},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,10,64},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{12,11,0},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,10,18},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,17},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,11,1792},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,23},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,20},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,11,25},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{10,12,192},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,1280},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,12,31},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{11,11,1856},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,58},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,11,21},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,896},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,640},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,49},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2176},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,12,45},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,37},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{10,12,448},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,29},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{10,13,1536},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,12,41},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2432},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,16},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,10,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,10,64},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,18},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,17},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{11,12,2048},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,12,51},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,35},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,12,320},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,27},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,12,59},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,33},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,11,1920},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,12,256},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,43},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{10,13,1152},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,55},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,12,63},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{11,12,2304},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,47},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,12,39},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,53},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,19},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,24},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,22},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2560},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,10,16},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,0},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{10,10,64},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{12,11,0},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,10,18},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,10,17},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,11,1792},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,23},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,11,20},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,25},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{10,12,128},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,56},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,30},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{11,11,1856},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,12,57},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,21},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,54},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,12,52},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,48},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2112},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,44},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,36},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{10,12,384},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,12,28},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,60},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,12,40},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{11,12,2368},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,16},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,10,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,10,64},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,18},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,17},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,1984},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,12,50},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,34},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{10,13,1728},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,26},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{10,13,1472},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,12,32},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,11,1920},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,61},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,12,42},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,1088},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,832},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,62},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{11,12,2240},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,12,46},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,38},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,576},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,19},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,11,24},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,22},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2496},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,16},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{10,10,64},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{12,11,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,18},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,10,17},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{11,11,1792},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,23},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,11,20},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,25},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,12,192},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,1344},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,31},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,11,1856},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,12,58},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,21},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{10,13,960},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{10,13,704},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,12,49},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2176},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,45},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,12,37},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,12,448},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,12,29},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,1600},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,41},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{11,12,2432},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,10,16},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,0},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,10,64},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,10,18},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,17},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2048},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,51},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,35},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{10,12,320},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,12,27},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,59},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,12,33},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{11,11,1920},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,12,256},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,12,43},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,1216},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,55},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,63},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2304},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,12,47},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,39},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,12,53},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,19},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,11,24},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,11,22},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2560},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,16},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2},{8,10,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2}, -{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,10,64},{8,2,3}, -{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2}, -{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3}, -{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2}, -{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3}, -{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2}, -{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, -{8,3,4},{8,2,2} -}; -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_flush.c b/plugins/AdvaImg/src/LibTIFF/tif_flush.c deleted file mode 100644 index af7fdd9b2a..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_flush.c +++ /dev/null @@ -1,74 +0,0 @@ -/* $Header: /cvsroot/freeimage/FreeImage/Source/LibTIFF/tif_flush.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - */ -#include "tiffiop.h" - -int -TIFFFlush(TIFF* tif) -{ - - if (tif->tif_mode != O_RDONLY) { - if (!TIFFFlushData(tif)) - return (0); - if ((tif->tif_flags & TIFF_DIRTYDIRECT) && - !TIFFWriteDirectory(tif)) - return (0); - } - return (1); -} - -/* - * Flush buffered data to the file. - * - * Frank Warmerdam'2000: I modified this to return 1 if TIFF_BEENWRITING - * is not set, so that TIFFFlush() will proceed to write out the directory. - * The documentation says returning 1 is an error indicator, but not having - * been writing isn't exactly a an error. Hopefully this doesn't cause - * problems for other people. - */ -int -TIFFFlushData(TIFF* tif) -{ - if ((tif->tif_flags & TIFF_BEENWRITING) == 0) - return (0); - if (tif->tif_flags & TIFF_POSTENCODE) { - tif->tif_flags &= ~TIFF_POSTENCODE; - if (!(*tif->tif_postencode)(tif)) - return (0); - } - return (TIFFFlushData1(tif)); -} - -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_getimage.c b/plugins/AdvaImg/src/LibTIFF/tif_getimage.c deleted file mode 100644 index 041e540cba..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_getimage.c +++ /dev/null @@ -1,2678 +0,0 @@ -/* $Id: tif_getimage.c,v 1.39 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1991-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library - * - * Read and return a packed RGBA image. - */ -#include "tiffiop.h" -#include - -static int gtTileContig(TIFFRGBAImage*, uint32*, uint32, uint32); -static int gtTileSeparate(TIFFRGBAImage*, uint32*, uint32, uint32); -static int gtStripContig(TIFFRGBAImage*, uint32*, uint32, uint32); -static int gtStripSeparate(TIFFRGBAImage*, uint32*, uint32, uint32); -static int PickContigCase(TIFFRGBAImage*); -static int PickSeparateCase(TIFFRGBAImage*); -static const char photoTag[] = "PhotometricInterpretation"; - -/* - * Helper constants used in Orientation tag handling - */ -#define FLIP_VERTICALLY 0x01 -#define FLIP_HORIZONTALLY 0x02 - -/* - * Color conversion constants. We will define display types here. - */ - -TIFFDisplay display_sRGB = { - { /* XYZ -> luminance matrix */ - { 3.2410F, -1.5374F, -0.4986F }, - { -0.9692F, 1.8760F, 0.0416F }, - { 0.0556F, -0.2040F, 1.0570F } - }, - 100.0F, 100.0F, 100.0F, /* Light o/p for reference white */ - 255, 255, 255, /* Pixel values for ref. white */ - 1.0F, 1.0F, 1.0F, /* Residual light o/p for black pixel */ - 2.4F, 2.4F, 2.4F, /* Gamma values for the three guns */ -}; - -/* - * Check the image to see if TIFFReadRGBAImage can deal with it. - * 1/0 is returned according to whether or not the image can - * be handled. If 0 is returned, emsg contains the reason - * why it is being rejected. - */ -int -TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) -{ - TIFFDirectory* td = &tif->tif_dir; - uint16 photometric; - int colorchannels; - - if (!tif->tif_decodestatus) { - sprintf(emsg, "Sorry, requested compression method is not configured"); - return (0); - } - switch (td->td_bitspersample) { - case 1: - case 2: - case 4: - case 8: - case 16: - break; - default: - sprintf(emsg, "Sorry, can not handle images with %d-bit samples", - td->td_bitspersample); - return (0); - } - colorchannels = td->td_samplesperpixel - td->td_extrasamples; - if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric)) { - switch (colorchannels) { - case 1: - photometric = PHOTOMETRIC_MINISBLACK; - break; - case 3: - photometric = PHOTOMETRIC_RGB; - break; - default: - sprintf(emsg, "Missing needed %s tag", photoTag); - return (0); - } - } - switch (photometric) { - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: - case PHOTOMETRIC_PALETTE: - if (td->td_planarconfig == PLANARCONFIG_CONTIG - && td->td_samplesperpixel != 1 - && td->td_bitspersample < 8 ) { - sprintf(emsg, - "Sorry, can not handle contiguous data with %s=%d, " - "and %s=%d and Bits/Sample=%d", - photoTag, photometric, - "Samples/pixel", td->td_samplesperpixel, - td->td_bitspersample); - return (0); - } - /* - * We should likely validate that any extra samples are either - * to be ignored, or are alpha, and if alpha we should try to use - * them. But for now we won't bother with this. - */ - break; - case PHOTOMETRIC_YCBCR: - /* - * TODO: if at all meaningful and useful, make more complete - * support check here, or better still, refactor to let supporting - * code decide whether there is support and what meaningfull - * error to return - */ - break; - case PHOTOMETRIC_RGB: - if (colorchannels < 3) { - sprintf(emsg, "Sorry, can not handle RGB image with %s=%d", - "Color channels", colorchannels); - return (0); - } - break; - case PHOTOMETRIC_SEPARATED: - { - uint16 inkset; - TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset); - if (inkset != INKSET_CMYK) { - sprintf(emsg, - "Sorry, can not handle separated image with %s=%d", - "InkSet", inkset); - return 0; - } - if (td->td_samplesperpixel < 4) { - sprintf(emsg, - "Sorry, can not handle separated image with %s=%d", - "Samples/pixel", td->td_samplesperpixel); - return 0; - } - break; - } - case PHOTOMETRIC_LOGL: - if (td->td_compression != COMPRESSION_SGILOG) { - sprintf(emsg, "Sorry, LogL data must have %s=%d", - "Compression", COMPRESSION_SGILOG); - return (0); - } - break; - case PHOTOMETRIC_LOGLUV: - if (td->td_compression != COMPRESSION_SGILOG && - td->td_compression != COMPRESSION_SGILOG24) { - sprintf(emsg, "Sorry, LogLuv data must have %s=%d or %d", - "Compression", COMPRESSION_SGILOG, COMPRESSION_SGILOG24); - return (0); - } - if (td->td_planarconfig != PLANARCONFIG_CONTIG) { - sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%d", - "Planarconfiguration", td->td_planarconfig); - return (0); - } - break; - case PHOTOMETRIC_CIELAB: - break; - default: - sprintf(emsg, "Sorry, can not handle image with %s=%d", - photoTag, photometric); - return (0); - } - return (1); -} - -void -TIFFRGBAImageEnd(TIFFRGBAImage* img) -{ - if (img->Map) - _TIFFfree(img->Map), img->Map = NULL; - if (img->BWmap) - _TIFFfree(img->BWmap), img->BWmap = NULL; - if (img->PALmap) - _TIFFfree(img->PALmap), img->PALmap = NULL; - if (img->ycbcr) - _TIFFfree(img->ycbcr), img->ycbcr = NULL; - if (img->cielab) - _TIFFfree(img->cielab), img->cielab = NULL; - if ( img->redcmap ) { - _TIFFfree( img->redcmap ); - _TIFFfree( img->greencmap ); - _TIFFfree( img->bluecmap ); - } -} - -static int -isCCITTCompression(TIFF* tif) -{ - uint16 compress; - TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress); - return (compress == COMPRESSION_CCITTFAX3 || - compress == COMPRESSION_CCITTFAX4 || - compress == COMPRESSION_CCITTRLE || - compress == COMPRESSION_CCITTRLEW); -} - -int -TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) -{ - uint16* sampleinfo; - uint16 extrasamples; - uint16 planarconfig; - uint16 compress; - int colorchannels; - uint16 *red_orig, *green_orig, *blue_orig; - int n_color; - - /* Initialize to normal values */ - img->row_offset = 0; - img->col_offset = 0; - img->redcmap = NULL; - img->greencmap = NULL; - img->bluecmap = NULL; - img->req_orientation = ORIENTATION_BOTLEFT; /* It is the default */ - - img->tif = tif; - img->stoponerr = stop; - TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &img->bitspersample); - switch (img->bitspersample) { - case 1: - case 2: - case 4: - case 8: - case 16: - break; - default: - sprintf(emsg, "Sorry, can not handle images with %d-bit samples", - img->bitspersample); - return (0); - } - img->alpha = 0; - TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &img->samplesperpixel); - TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES, - &extrasamples, &sampleinfo); - if (extrasamples >= 1) - { - switch (sampleinfo[0]) { - case EXTRASAMPLE_UNSPECIFIED: /* Workaround for some images without */ - if (img->samplesperpixel > 3) /* correct info about alpha channel */ - img->alpha = EXTRASAMPLE_ASSOCALPHA; - break; - case EXTRASAMPLE_ASSOCALPHA: /* data is pre-multiplied */ - case EXTRASAMPLE_UNASSALPHA: /* data is not pre-multiplied */ - img->alpha = sampleinfo[0]; - break; - } - } - -#ifdef DEFAULT_EXTRASAMPLE_AS_ALPHA - if ( !TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric)) - img->photometric = PHOTOMETRIC_MINISWHITE; - - if ( extrasamples == 0 - && img->samplesperpixel == 4 - && img->photometric == PHOTOMETRIC_RGB ) - { - img->alpha = EXTRASAMPLE_ASSOCALPHA; - extrasamples = 1; - } -#endif - - colorchannels = img->samplesperpixel - extrasamples; - TIFFGetFieldDefaulted(tif, TIFFTAG_COMPRESSION, &compress); - TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG, &planarconfig); - if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric)) { - switch (colorchannels) { - case 1: - if (isCCITTCompression(tif)) - img->photometric = PHOTOMETRIC_MINISWHITE; - else - img->photometric = PHOTOMETRIC_MINISBLACK; - break; - case 3: - img->photometric = PHOTOMETRIC_RGB; - break; - default: - sprintf(emsg, "Missing needed %s tag", photoTag); - return (0); - } - } - switch (img->photometric) { - case PHOTOMETRIC_PALETTE: - if (!TIFFGetField(tif, TIFFTAG_COLORMAP, - &red_orig, &green_orig, &blue_orig)) { - sprintf(emsg, "Missing required \"Colormap\" tag"); - return (0); - } - - /* copy the colormaps so we can modify them */ - n_color = (1L << img->bitspersample); - img->redcmap = (uint16 *) _TIFFmalloc(sizeof(uint16)*n_color); - img->greencmap = (uint16 *) _TIFFmalloc(sizeof(uint16)*n_color); - img->bluecmap = (uint16 *) _TIFFmalloc(sizeof(uint16)*n_color); - if ( !img->redcmap || !img->greencmap || !img->bluecmap ) { - sprintf(emsg, "Out of memory for colormap copy"); - return (0); - } - - _TIFFmemcpy( img->redcmap, red_orig, n_color * 2 ); - _TIFFmemcpy( img->greencmap, green_orig, n_color * 2 ); - _TIFFmemcpy( img->bluecmap, blue_orig, n_color * 2 ); - - /* fall thru... */ - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: - if (planarconfig == PLANARCONFIG_CONTIG - && img->samplesperpixel != 1 - && img->bitspersample < 8 ) { - sprintf(emsg, - "Sorry, can not handle contiguous data with %s=%d, " - "and %s=%d and Bits/Sample=%d", - photoTag, img->photometric, - "Samples/pixel", img->samplesperpixel, - img->bitspersample); - return (0); - } - break; - case PHOTOMETRIC_YCBCR: - /* It would probably be nice to have a reality check here. */ - if (planarconfig == PLANARCONFIG_CONTIG) - /* can rely on libjpeg to convert to RGB */ - /* XXX should restore current state on exit */ - switch (compress) { - case COMPRESSION_JPEG: - /* - * TODO: when complete tests verify complete desubsampling - * and YCbCr handling, remove use of TIFFTAG_JPEGCOLORMODE in - * favor of tif_getimage.c native handling - */ - TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); - img->photometric = PHOTOMETRIC_RGB; - break; - default: - /* do nothing */; - break; - } - /* - * TODO: if at all meaningful and useful, make more complete - * support check here, or better still, refactor to let supporting - * code decide whether there is support and what meaningfull - * error to return - */ - break; - case PHOTOMETRIC_RGB: - if (colorchannels < 3) { - sprintf(emsg, "Sorry, can not handle RGB image with %s=%d", - "Color channels", colorchannels); - return (0); - } - break; - case PHOTOMETRIC_SEPARATED: - { - uint16 inkset; - TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset); - if (inkset != INKSET_CMYK) { - sprintf(emsg, "Sorry, can not handle separated image with %s=%d", - "InkSet", inkset); - return (0); - } - if (img->samplesperpixel < 4) { - sprintf(emsg, "Sorry, can not handle separated image with %s=%d", - "Samples/pixel", img->samplesperpixel); - return (0); - } - } - break; - case PHOTOMETRIC_LOGL: - if (compress != COMPRESSION_SGILOG) { - sprintf(emsg, "Sorry, LogL data must have %s=%d", - "Compression", COMPRESSION_SGILOG); - return (0); - } - TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT); - img->photometric = PHOTOMETRIC_MINISBLACK; /* little white lie */ - img->bitspersample = 8; - break; - case PHOTOMETRIC_LOGLUV: - if (compress != COMPRESSION_SGILOG && compress != COMPRESSION_SGILOG24) { - sprintf(emsg, "Sorry, LogLuv data must have %s=%d or %d", - "Compression", COMPRESSION_SGILOG, COMPRESSION_SGILOG24); - return (0); - } - if (planarconfig != PLANARCONFIG_CONTIG) { - sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%d", - "Planarconfiguration", planarconfig); - return (0); - } - TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT); - img->photometric = PHOTOMETRIC_RGB; /* little white lie */ - img->bitspersample = 8; - break; - case PHOTOMETRIC_CIELAB: - break; - default: - sprintf(emsg, "Sorry, can not handle image with %s=%d", - photoTag, img->photometric); - return (0); - } - img->Map = NULL; - img->BWmap = NULL; - img->PALmap = NULL; - img->ycbcr = NULL; - img->cielab = NULL; - TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &img->width); - TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &img->height); - TIFFGetFieldDefaulted(tif, TIFFTAG_ORIENTATION, &img->orientation); - img->isContig = - !(planarconfig == PLANARCONFIG_SEPARATE && colorchannels > 1); - if (img->isContig) { - if (!PickContigCase(img)) { - sprintf(emsg, "Sorry, can not handle image"); - return 0; - } - } else { - if (!PickSeparateCase(img)) { - sprintf(emsg, "Sorry, can not handle image"); - return 0; - } - } - return 1; -} - -int -TIFFRGBAImageGet(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) -{ - if (img->get == NULL) { - TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif), "No \"get\" routine setup"); - return (0); - } - if (img->put.any == NULL) { - TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif), - "No \"put\" routine setupl; probably can not handle image format"); - return (0); - } - return (*img->get)(img, raster, w, h); -} - -/* - * Read the specified image into an ABGR-format rastertaking in account - * specified orientation. - */ -int -TIFFReadRGBAImageOriented(TIFF* tif, - uint32 rwidth, uint32 rheight, uint32* raster, - int orientation, int stop) -{ - char emsg[1024] = ""; - TIFFRGBAImage img; - int ok; - - if (TIFFRGBAImageOK(tif, emsg) && TIFFRGBAImageBegin(&img, tif, stop, emsg)) { - img.req_orientation = orientation; - /* XXX verify rwidth and rheight against width and height */ - ok = TIFFRGBAImageGet(&img, raster+(rheight-img.height)*rwidth, - rwidth, img.height); - TIFFRGBAImageEnd(&img); - } else { - TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", emsg); - ok = 0; - } - return (ok); -} - -/* - * Read the specified image into an ABGR-format raster. Use bottom left - * origin for raster by default. - */ -int -TIFFReadRGBAImage(TIFF* tif, - uint32 rwidth, uint32 rheight, uint32* raster, int stop) -{ - return TIFFReadRGBAImageOriented(tif, rwidth, rheight, raster, - ORIENTATION_BOTLEFT, stop); -} - -static int -setorientation(TIFFRGBAImage* img) -{ - switch (img->orientation) { - case ORIENTATION_TOPLEFT: - case ORIENTATION_LEFTTOP: - if (img->req_orientation == ORIENTATION_TOPRIGHT || - img->req_orientation == ORIENTATION_RIGHTTOP) - return FLIP_HORIZONTALLY; - else if (img->req_orientation == ORIENTATION_BOTRIGHT || - img->req_orientation == ORIENTATION_RIGHTBOT) - return FLIP_HORIZONTALLY | FLIP_VERTICALLY; - else if (img->req_orientation == ORIENTATION_BOTLEFT || - img->req_orientation == ORIENTATION_LEFTBOT) - return FLIP_VERTICALLY; - else - return 0; - case ORIENTATION_TOPRIGHT: - case ORIENTATION_RIGHTTOP: - if (img->req_orientation == ORIENTATION_TOPLEFT || - img->req_orientation == ORIENTATION_LEFTTOP) - return FLIP_HORIZONTALLY; - else if (img->req_orientation == ORIENTATION_BOTRIGHT || - img->req_orientation == ORIENTATION_RIGHTBOT) - return FLIP_VERTICALLY; - else if (img->req_orientation == ORIENTATION_BOTLEFT || - img->req_orientation == ORIENTATION_LEFTBOT) - return FLIP_HORIZONTALLY | FLIP_VERTICALLY; - else - return 0; - case ORIENTATION_BOTRIGHT: - case ORIENTATION_RIGHTBOT: - if (img->req_orientation == ORIENTATION_TOPLEFT || - img->req_orientation == ORIENTATION_LEFTTOP) - return FLIP_HORIZONTALLY | FLIP_VERTICALLY; - else if (img->req_orientation == ORIENTATION_TOPRIGHT || - img->req_orientation == ORIENTATION_RIGHTTOP) - return FLIP_VERTICALLY; - else if (img->req_orientation == ORIENTATION_BOTLEFT || - img->req_orientation == ORIENTATION_LEFTBOT) - return FLIP_HORIZONTALLY; - else - return 0; - case ORIENTATION_BOTLEFT: - case ORIENTATION_LEFTBOT: - if (img->req_orientation == ORIENTATION_TOPLEFT || - img->req_orientation == ORIENTATION_LEFTTOP) - return FLIP_VERTICALLY; - else if (img->req_orientation == ORIENTATION_TOPRIGHT || - img->req_orientation == ORIENTATION_RIGHTTOP) - return FLIP_HORIZONTALLY | FLIP_VERTICALLY; - else if (img->req_orientation == ORIENTATION_BOTRIGHT || - img->req_orientation == ORIENTATION_RIGHTBOT) - return FLIP_HORIZONTALLY; - else - return 0; - default: /* NOTREACHED */ - return 0; - } -} - -/* - * Get an tile-organized image that has - * PlanarConfiguration contiguous if SamplesPerPixel > 1 - * or - * SamplesPerPixel == 1 - */ -static int -gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) -{ - TIFF* tif = img->tif; - tileContigRoutine put = img->put.contig; - uint32 col, row, y, rowstoread; - uint32 pos; - uint32 tw, th; - unsigned char* buf; - int32 fromskew, toskew; - uint32 nrow; - int ret = 1, flip; - - buf = (unsigned char*) _TIFFmalloc(TIFFTileSize(tif)); - if (buf == 0) { - TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "No space for tile buffer"); - return (0); - } - _TIFFmemset(buf, 0, TIFFTileSize(tif)); - TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw); - TIFFGetField(tif, TIFFTAG_TILELENGTH, &th); - - flip = setorientation(img); - if (flip & FLIP_VERTICALLY) { - y = h - 1; - toskew = -(int32)(tw + w); - } - else { - y = 0; - toskew = -(int32)(tw - w); - } - - for (row = 0; row < h; row += nrow) - { - rowstoread = th - (row + img->row_offset) % th; - nrow = (row + rowstoread > h ? h - row : rowstoread); - for (col = 0; col < w; col += tw) - { - if (TIFFReadTile(tif, buf, col+img->col_offset, - row+img->row_offset, 0, 0) < 0 && img->stoponerr) - { - ret = 0; - break; - } - - pos = ((row+img->row_offset) % th) * TIFFTileRowSize(tif); - - if (col + tw > w) - { - /* - * Tile is clipped horizontally. Calculate - * visible portion and skewing factors. - */ - uint32 npix = w - col; - fromskew = tw - npix; - (*put)(img, raster+y*w+col, col, y, - npix, nrow, fromskew, toskew + fromskew, buf + pos); - } - else - { - (*put)(img, raster+y*w+col, col, y, tw, nrow, 0, toskew, buf + pos); - } - } - - y += (flip & FLIP_VERTICALLY ? -(int32) nrow : (int32) nrow); - } - _TIFFfree(buf); - - if (flip & FLIP_HORIZONTALLY) { - uint32 line; - - for (line = 0; line < h; line++) { - uint32 *left = raster + (line * w); - uint32 *right = left + w - 1; - - while ( left < right ) { - uint32 temp = *left; - *left = *right; - *right = temp; - left++, right--; - } - } - } - - return (ret); -} - -/* - * Get an tile-organized image that has - * SamplesPerPixel > 1 - * PlanarConfiguration separated - * We assume that all such images are RGB. - */ -static int -gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) -{ - TIFF* tif = img->tif; - tileSeparateRoutine put = img->put.separate; - uint32 col, row, y, rowstoread; - uint32 pos; - uint32 tw, th; - unsigned char* buf; - unsigned char* p0; - unsigned char* p1; - unsigned char* p2; - unsigned char* pa; - tsize_t tilesize; - int32 fromskew, toskew; - int alpha = img->alpha; - uint32 nrow; - int ret = 1, flip; - - tilesize = TIFFTileSize(tif); - buf = (unsigned char*) _TIFFmalloc((alpha?4:3)*tilesize); - if (buf == 0) { - TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "No space for tile buffer"); - return (0); - } - _TIFFmemset(buf, 0, (alpha?4:3)*tilesize); - p0 = buf; - p1 = p0 + tilesize; - p2 = p1 + tilesize; - pa = (alpha?(p2+tilesize):NULL); - TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw); - TIFFGetField(tif, TIFFTAG_TILELENGTH, &th); - - flip = setorientation(img); - if (flip & FLIP_VERTICALLY) { - y = h - 1; - toskew = -(int32)(tw + w); - } - else { - y = 0; - toskew = -(int32)(tw - w); - } - - for (row = 0; row < h; row += nrow) - { - rowstoread = th - (row + img->row_offset) % th; - nrow = (row + rowstoread > h ? h - row : rowstoread); - for (col = 0; col < w; col += tw) - { - if (TIFFReadTile(tif, p0, col+img->col_offset, - row+img->row_offset,0,0) < 0 && img->stoponerr) - { - ret = 0; - break; - } - if (TIFFReadTile(tif, p1, col+img->col_offset, - row+img->row_offset,0,1) < 0 && img->stoponerr) - { - ret = 0; - break; - } - if (TIFFReadTile(tif, p2, col+img->col_offset, - row+img->row_offset,0,2) < 0 && img->stoponerr) - { - ret = 0; - break; - } - if (alpha) - { - if (TIFFReadTile(tif,pa,col+img->col_offset, - row+img->row_offset,0,3) < 0 && img->stoponerr) - { - ret = 0; - break; - } - } - - pos = ((row+img->row_offset) % th) * TIFFTileRowSize(tif); - - if (col + tw > w) - { - /* - * Tile is clipped horizontally. Calculate - * visible portion and skewing factors. - */ - uint32 npix = w - col; - fromskew = tw - npix; - (*put)(img, raster+y*w+col, col, y, - npix, nrow, fromskew, toskew + fromskew, - p0 + pos, p1 + pos, p2 + pos, (alpha?(pa+pos):NULL)); - } else { - (*put)(img, raster+y*w+col, col, y, - tw, nrow, 0, toskew, p0 + pos, p1 + pos, p2 + pos, (alpha?(pa+pos):NULL)); - } - } - - y += (flip & FLIP_VERTICALLY ?-(int32) nrow : (int32) nrow); - } - - if (flip & FLIP_HORIZONTALLY) { - uint32 line; - - for (line = 0; line < h; line++) { - uint32 *left = raster + (line * w); - uint32 *right = left + w - 1; - - while ( left < right ) { - uint32 temp = *left; - *left = *right; - *right = temp; - left++, right--; - } - } - } - - _TIFFfree(buf); - return (ret); -} - -/* - * Get a strip-organized image that has - * PlanarConfiguration contiguous if SamplesPerPixel > 1 - * or - * SamplesPerPixel == 1 - */ -static int -gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) -{ - TIFF* tif = img->tif; - tileContigRoutine put = img->put.contig; - uint32 row, y, nrow, nrowsub, rowstoread; - uint32 pos; - unsigned char* buf; - uint32 rowsperstrip; - uint16 subsamplinghor,subsamplingver; - uint32 imagewidth = img->width; - tsize_t scanline; - int32 fromskew, toskew; - int ret = 1, flip; - - buf = (unsigned char*) _TIFFmalloc(TIFFStripSize(tif)); - if (buf == 0) { - TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "No space for strip buffer"); - return (0); - } - _TIFFmemset(buf, 0, TIFFStripSize(tif)); - - flip = setorientation(img); - if (flip & FLIP_VERTICALLY) { - y = h - 1; - toskew = -(int32)(w + w); - } else { - y = 0; - toskew = -(int32)(w - w); - } - - TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); - TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING, &subsamplinghor, &subsamplingver); - scanline = TIFFNewScanlineSize(tif); - fromskew = (w < imagewidth ? imagewidth - w : 0); - for (row = 0; row < h; row += nrow) - { - rowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip; - nrow = (row + rowstoread > h ? h - row : rowstoread); - nrowsub = nrow; - if ((nrowsub%subsamplingver)!=0) - nrowsub+=subsamplingver-nrowsub%subsamplingver; - if (TIFFReadEncodedStrip(tif, - TIFFComputeStrip(tif,row+img->row_offset, 0), - buf, - ((row + img->row_offset)%rowsperstrip + nrowsub) * scanline) < 0 - && img->stoponerr) - { - ret = 0; - break; - } - - pos = ((row + img->row_offset) % rowsperstrip) * scanline; - (*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, buf + pos); - y += (flip & FLIP_VERTICALLY ? -(int32) nrow : (int32) nrow); - } - - if (flip & FLIP_HORIZONTALLY) { - uint32 line; - - for (line = 0; line < h; line++) { - uint32 *left = raster + (line * w); - uint32 *right = left + w - 1; - - while ( left < right ) { - uint32 temp = *left; - *left = *right; - *right = temp; - left++, right--; - } - } - } - - _TIFFfree(buf); - return (ret); -} - -/* - * Get a strip-organized image with - * SamplesPerPixel > 1 - * PlanarConfiguration separated - * We assume that all such images are RGB. - */ -static int -gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) -{ - TIFF* tif = img->tif; - tileSeparateRoutine put = img->put.separate; - unsigned char *buf; - unsigned char *p0, *p1, *p2, *pa; - uint32 row, y, nrow, rowstoread; - uint32 pos; - tsize_t scanline; - uint32 rowsperstrip, offset_row; - uint32 imagewidth = img->width; - tsize_t stripsize; - int32 fromskew, toskew; - int alpha = img->alpha; - int ret = 1, flip; - - stripsize = TIFFStripSize(tif); - p0 = buf = (unsigned char *)_TIFFmalloc((alpha?4:3)*stripsize); - if (buf == 0) { - TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "No space for tile buffer"); - return (0); - } - _TIFFmemset(buf, 0, (alpha?4:3)*stripsize); - p1 = p0 + stripsize; - p2 = p1 + stripsize; - pa = (alpha?(p2+stripsize):NULL); - - flip = setorientation(img); - if (flip & FLIP_VERTICALLY) { - y = h - 1; - toskew = -(int32)(w + w); - } - else { - y = 0; - toskew = -(int32)(w - w); - } - - TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); - scanline = TIFFScanlineSize(tif); - fromskew = (w < imagewidth ? imagewidth - w : 0); - for (row = 0; row < h; row += nrow) - { - rowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip; - nrow = (row + rowstoread > h ? h - row : rowstoread); - offset_row = row + img->row_offset; - if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 0), - p0, ((row + img->row_offset)%rowsperstrip + nrow) * scanline) < 0 - && img->stoponerr) - { - ret = 0; - break; - } - if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 1), - p1, ((row + img->row_offset)%rowsperstrip + nrow) * scanline) < 0 - && img->stoponerr) - { - ret = 0; - break; - } - if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 2), - p2, ((row + img->row_offset)%rowsperstrip + nrow) * scanline) < 0 - && img->stoponerr) - { - ret = 0; - break; - } - if (alpha) - { - if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 3), - pa, ((row + img->row_offset)%rowsperstrip + nrow) * scanline) < 0 - && img->stoponerr) - { - ret = 0; - break; - } - } - - pos = ((row + img->row_offset) % rowsperstrip) * scanline; - (*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, p0 + pos, p1 + pos, - p2 + pos, (alpha?(pa+pos):NULL)); - y += (flip & FLIP_VERTICALLY ? -(int32) nrow : (int32) nrow); - } - - if (flip & FLIP_HORIZONTALLY) { - uint32 line; - - for (line = 0; line < h; line++) { - uint32 *left = raster + (line * w); - uint32 *right = left + w - 1; - - while ( left < right ) { - uint32 temp = *left; - *left = *right; - *right = temp; - left++, right--; - } - } - } - - _TIFFfree(buf); - return (ret); -} - -/* - * The following routines move decoded data returned - * from the TIFF library into rasters filled with packed - * ABGR pixels (i.e. suitable for passing to lrecwrite.) - * - * The routines have been created according to the most - * important cases and optimized. PickContigCase and - * PickSeparateCase analyze the parameters and select - * the appropriate "get" and "put" routine to use. - */ -#define REPEAT8(op) REPEAT4(op); REPEAT4(op) -#define REPEAT4(op) REPEAT2(op); REPEAT2(op) -#define REPEAT2(op) op; op -#define CASE8(x,op) \ - switch (x) { \ - case 7: op; case 6: op; case 5: op; \ - case 4: op; case 3: op; case 2: op; \ - case 1: op; \ - } -#define CASE4(x,op) switch (x) { case 3: op; case 2: op; case 1: op; } -#define NOP - -#define UNROLL8(w, op1, op2) { \ - uint32 _x; \ - for (_x = w; _x >= 8; _x -= 8) { \ - op1; \ - REPEAT8(op2); \ - } \ - if (_x > 0) { \ - op1; \ - CASE8(_x,op2); \ - } \ -} -#define UNROLL4(w, op1, op2) { \ - uint32 _x; \ - for (_x = w; _x >= 4; _x -= 4) { \ - op1; \ - REPEAT4(op2); \ - } \ - if (_x > 0) { \ - op1; \ - CASE4(_x,op2); \ - } \ -} -#define UNROLL2(w, op1, op2) { \ - uint32 _x; \ - for (_x = w; _x >= 2; _x -= 2) { \ - op1; \ - REPEAT2(op2); \ - } \ - if (_x) { \ - op1; \ - op2; \ - } \ -} - -#define SKEW(r,g,b,skew) { r += skew; g += skew; b += skew; } -#define SKEW4(r,g,b,a,skew) { r += skew; g += skew; b += skew; a+= skew; } - -#define A1 (((uint32)0xffL)<<24) -#define PACK(r,g,b) \ - ((uint32)(r)|((uint32)(g)<<8)|((uint32)(b)<<16)|A1) -#define PACK4(r,g,b,a) \ - ((uint32)(r)|((uint32)(g)<<8)|((uint32)(b)<<16)|((uint32)(a)<<24)) -#define W2B(v) (((v)>>8)&0xff) -#define PACKW(r,g,b) \ - ((uint32)W2B(r)|((uint32)W2B(g)<<8)|((uint32)W2B(b)<<16)|A1) -#define PACKW4(r,g,b,a) \ - ((uint32)W2B(r)|((uint32)W2B(g)<<8)|((uint32)W2B(b)<<16)|((uint32)W2B(a)<<24)) - -#define DECLAREContigPutFunc(name) \ -static void name(\ - TIFFRGBAImage* img, \ - uint32* cp, \ - uint32 x, uint32 y, \ - uint32 w, uint32 h, \ - int32 fromskew, int32 toskew, \ - unsigned char* pp \ -) - -/* - * 8-bit palette => colormap/RGB - */ -DECLAREContigPutFunc(put8bitcmaptile) -{ - uint32** PALmap = img->PALmap; - int samplesperpixel = img->samplesperpixel; - - (void) y; - while (h-- > 0) { - for (x = w; x-- > 0;) - { - *cp++ = PALmap[*pp][0]; - pp += samplesperpixel; - } - cp += toskew; - pp += fromskew; - } -} - -/* - * 4-bit palette => colormap/RGB - */ -DECLAREContigPutFunc(put4bitcmaptile) -{ - uint32** PALmap = img->PALmap; - - (void) x; (void) y; - fromskew /= 2; - while (h-- > 0) { - uint32* bw; - UNROLL2(w, bw = PALmap[*pp++], *cp++ = *bw++); - cp += toskew; - pp += fromskew; - } -} - -/* - * 2-bit palette => colormap/RGB - */ -DECLAREContigPutFunc(put2bitcmaptile) -{ - uint32** PALmap = img->PALmap; - - (void) x; (void) y; - fromskew /= 4; - while (h-- > 0) { - uint32* bw; - UNROLL4(w, bw = PALmap[*pp++], *cp++ = *bw++); - cp += toskew; - pp += fromskew; - } -} - -/* - * 1-bit palette => colormap/RGB - */ -DECLAREContigPutFunc(put1bitcmaptile) -{ - uint32** PALmap = img->PALmap; - - (void) x; (void) y; - fromskew /= 8; - while (h-- > 0) { - uint32* bw; - UNROLL8(w, bw = PALmap[*pp++], *cp++ = *bw++); - cp += toskew; - pp += fromskew; - } -} - -/* - * 8-bit greyscale => colormap/RGB - */ -DECLAREContigPutFunc(putgreytile) -{ - int samplesperpixel = img->samplesperpixel; - uint32** BWmap = img->BWmap; - - (void) y; - while (h-- > 0) { - for (x = w; x-- > 0;) - { - *cp++ = BWmap[*pp][0]; - pp += samplesperpixel; - } - cp += toskew; - pp += fromskew; - } -} - -/* - * 16-bit greyscale => colormap/RGB - */ -DECLAREContigPutFunc(put16bitbwtile) -{ - int samplesperpixel = img->samplesperpixel; - uint32** BWmap = img->BWmap; - - (void) y; - while (h-- > 0) { - uint16 *wp = (uint16 *) pp; - - for (x = w; x-- > 0;) - { - /* use high order byte of 16bit value */ - - *cp++ = BWmap[*wp >> 8][0]; - pp += 2 * samplesperpixel; - wp += samplesperpixel; - } - cp += toskew; - pp += fromskew; - } -} - -/* - * 1-bit bilevel => colormap/RGB - */ -DECLAREContigPutFunc(put1bitbwtile) -{ - uint32** BWmap = img->BWmap; - - (void) x; (void) y; - fromskew /= 8; - while (h-- > 0) { - uint32* bw; - UNROLL8(w, bw = BWmap[*pp++], *cp++ = *bw++); - cp += toskew; - pp += fromskew; - } -} - -/* - * 2-bit greyscale => colormap/RGB - */ -DECLAREContigPutFunc(put2bitbwtile) -{ - uint32** BWmap = img->BWmap; - - (void) x; (void) y; - fromskew /= 4; - while (h-- > 0) { - uint32* bw; - UNROLL4(w, bw = BWmap[*pp++], *cp++ = *bw++); - cp += toskew; - pp += fromskew; - } -} - -/* - * 4-bit greyscale => colormap/RGB - */ -DECLAREContigPutFunc(put4bitbwtile) -{ - uint32** BWmap = img->BWmap; - - (void) x; (void) y; - fromskew /= 2; - while (h-- > 0) { - uint32* bw; - UNROLL2(w, bw = BWmap[*pp++], *cp++ = *bw++); - cp += toskew; - pp += fromskew; - } -} - -/* - * 8-bit packed samples, no Map => RGB - */ -DECLAREContigPutFunc(putRGBcontig8bittile) -{ - int samplesperpixel = img->samplesperpixel; - - (void) x; (void) y; - fromskew *= samplesperpixel; - while (h-- > 0) { - UNROLL8(w, NOP, - *cp++ = PACK(pp[0], pp[1], pp[2]); - pp += samplesperpixel); - cp += toskew; - pp += fromskew; - } -} - -/* - * 8-bit packed samples => RGBA w/ associated alpha - * (known to have Map == NULL) - */ -DECLAREContigPutFunc(putRGBAAcontig8bittile) -{ - int samplesperpixel = img->samplesperpixel; - - (void) x; (void) y; - fromskew *= samplesperpixel; - while (h-- > 0) { - UNROLL8(w, NOP, - *cp++ = PACK4(pp[0], pp[1], pp[2], pp[3]); - pp += samplesperpixel); - cp += toskew; - pp += fromskew; - } -} - -/* - * 8-bit packed samples => RGBA w/ unassociated alpha - * (known to have Map == NULL) - */ -DECLAREContigPutFunc(putRGBUAcontig8bittile) -{ - int samplesperpixel = img->samplesperpixel; - (void) y; - fromskew *= samplesperpixel; - while (h-- > 0) { - uint32 r, g, b, a; - for (x = w; x-- > 0;) { - a = pp[3]; - r = (a*pp[0] + 127) / 255; - g = (a*pp[1] + 127) / 255; - b = (a*pp[2] + 127) / 255; - *cp++ = PACK4(r,g,b,a); - pp += samplesperpixel; - } - cp += toskew; - pp += fromskew; - } -} - -/* - * 16-bit packed samples => RGB - */ -DECLAREContigPutFunc(putRGBcontig16bittile) -{ - int samplesperpixel = img->samplesperpixel; - uint16 *wp = (uint16 *)pp; - (void) y; - fromskew *= samplesperpixel; - while (h-- > 0) { - for (x = w; x-- > 0;) { - *cp++ = PACKW(wp[0],wp[1],wp[2]); - wp += samplesperpixel; - } - cp += toskew; - wp += fromskew; - } -} - -/* - * 16-bit packed samples => RGBA w/ associated alpha - * (known to have Map == NULL) - */ -DECLAREContigPutFunc(putRGBAAcontig16bittile) -{ - int samplesperpixel = img->samplesperpixel; - uint16 *wp = (uint16 *)pp; - (void) y; - fromskew *= samplesperpixel; - while (h-- > 0) { - for (x = w; x-- > 0;) { - *cp++ = PACKW4(wp[0],wp[1],wp[2],wp[3]); - wp += samplesperpixel; - } - cp += toskew; - wp += fromskew; - } -} - -/* - * 16-bit packed samples => RGBA w/ unassociated alpha - * (known to have Map == NULL) - */ -DECLAREContigPutFunc(putRGBUAcontig16bittile) -{ - int samplesperpixel = img->samplesperpixel; - uint16 *wp = (uint16 *)pp; - (void) y; - fromskew *= samplesperpixel; - while (h-- > 0) { - uint32 r,g,b,a; - for (x = w; x-- > 0;) { - a = W2B(wp[3]); - r = (a*W2B(wp[0]) + 127) / 255; - g = (a*W2B(wp[1]) + 127) / 255; - b = (a*W2B(wp[2]) + 127) / 255; - *cp++ = PACK4(r,g,b,a); - wp += samplesperpixel; - } - cp += toskew; - wp += fromskew; - } -} - -/* - * 8-bit packed CMYK samples w/o Map => RGB - * - * NB: The conversion of CMYK->RGB is *very* crude. - */ -DECLAREContigPutFunc(putRGBcontig8bitCMYKtile) -{ - int samplesperpixel = img->samplesperpixel; - uint16 r, g, b, k; - - (void) x; (void) y; - fromskew *= samplesperpixel; - while (h-- > 0) { - UNROLL8(w, NOP, - k = 255 - pp[3]; - r = (k*(255-pp[0]))/255; - g = (k*(255-pp[1]))/255; - b = (k*(255-pp[2]))/255; - *cp++ = PACK(r, g, b); - pp += samplesperpixel); - cp += toskew; - pp += fromskew; - } -} - -/* - * 8-bit packed CMYK samples w/Map => RGB - * - * NB: The conversion of CMYK->RGB is *very* crude. - */ -DECLAREContigPutFunc(putRGBcontig8bitCMYKMaptile) -{ - int samplesperpixel = img->samplesperpixel; - TIFFRGBValue* Map = img->Map; - uint16 r, g, b, k; - - (void) y; - fromskew *= samplesperpixel; - while (h-- > 0) { - for (x = w; x-- > 0;) { - k = 255 - pp[3]; - r = (k*(255-pp[0]))/255; - g = (k*(255-pp[1]))/255; - b = (k*(255-pp[2]))/255; - *cp++ = PACK(Map[r], Map[g], Map[b]); - pp += samplesperpixel; - } - pp += fromskew; - cp += toskew; - } -} - -#define DECLARESepPutFunc(name) \ -static void name(\ - TIFFRGBAImage* img,\ - uint32* cp,\ - uint32 x, uint32 y, \ - uint32 w, uint32 h,\ - int32 fromskew, int32 toskew,\ - unsigned char* r, unsigned char* g, unsigned char* b, unsigned char* a\ -) - -/* - * 8-bit unpacked samples => RGB - */ -DECLARESepPutFunc(putRGBseparate8bittile) -{ - (void) img; (void) x; (void) y; (void) a; - while (h-- > 0) { - UNROLL8(w, NOP, *cp++ = PACK(*r++, *g++, *b++)); - SKEW(r, g, b, fromskew); - cp += toskew; - } -} - -/* - * 8-bit unpacked samples => RGBA w/ associated alpha - */ -DECLARESepPutFunc(putRGBAAseparate8bittile) -{ - (void) img; (void) x; (void) y; - while (h-- > 0) { - UNROLL8(w, NOP, *cp++ = PACK4(*r++, *g++, *b++, *a++)); - SKEW4(r, g, b, a, fromskew); - cp += toskew; - } -} - -/* - * 8-bit unpacked samples => RGBA w/ unassociated alpha - */ -DECLARESepPutFunc(putRGBUAseparate8bittile) -{ - (void) img; (void) y; - while (h-- > 0) { - uint32 rv, gv, bv, av; - for (x = w; x-- > 0;) { - av = *a++; - rv = (av* *r++ + 127) / 255; - gv = (av* *g++ + 127) / 255; - bv = (av* *b++ + 127) / 255; - *cp++ = PACK4(rv,gv,bv,av); - } - SKEW4(r, g, b, a, fromskew); - cp += toskew; - } -} - -/* - * 16-bit unpacked samples => RGB - */ -DECLARESepPutFunc(putRGBseparate16bittile) -{ - uint16 *wr = (uint16*) r; - uint16 *wg = (uint16*) g; - uint16 *wb = (uint16*) b; - (void) img; (void) y; (void) a; - while (h-- > 0) { - for (x = 0; x < w; x++) - *cp++ = PACKW(*wr++,*wg++,*wb++); - SKEW(wr, wg, wb, fromskew); - cp += toskew; - } -} - -/* - * 16-bit unpacked samples => RGBA w/ associated alpha - */ -DECLARESepPutFunc(putRGBAAseparate16bittile) -{ - uint16 *wr = (uint16*) r; - uint16 *wg = (uint16*) g; - uint16 *wb = (uint16*) b; - uint16 *wa = (uint16*) a; - (void) img; (void) y; - while (h-- > 0) { - for (x = 0; x < w; x++) - *cp++ = PACKW4(*wr++,*wg++,*wb++,*wa++); - SKEW4(wr, wg, wb, wa, fromskew); - cp += toskew; - } -} - -/* - * 16-bit unpacked samples => RGBA w/ unassociated alpha - */ -DECLARESepPutFunc(putRGBUAseparate16bittile) -{ - uint16 *wr = (uint16*) r; - uint16 *wg = (uint16*) g; - uint16 *wb = (uint16*) b; - uint16 *wa = (uint16*) a; - (void) img; (void) y; - while (h-- > 0) { - uint32 r,g,b,a; - for (x = w; x-- > 0;) { - a = W2B(*wa++); - r = (a*W2B(*wr++) + 127) / 255; - g = (a*W2B(*wg++) + 127) / 255; - b = (a*W2B(*wb++) + 127) / 255; - *cp++ = PACK4(r,g,b,a); - } - SKEW4(wr, wg, wb, wa, fromskew); - cp += toskew; - } -} - -/* - * 8-bit packed CIE L*a*b 1976 samples => RGB - */ -DECLAREContigPutFunc(putcontig8bitCIELab) -{ - float X, Y, Z; - uint32 r, g, b; - (void) y; - fromskew *= 3; - while (h-- > 0) { - for (x = w; x-- > 0;) { - TIFFCIELabToXYZ(img->cielab, - (unsigned char)pp[0], - (signed char)pp[1], - (signed char)pp[2], - &X, &Y, &Z); - TIFFXYZToRGB(img->cielab, X, Y, Z, &r, &g, &b); - *cp++ = PACK(r, g, b); - pp += 3; - } - cp += toskew; - pp += fromskew; - } -} - -/* - * YCbCr -> RGB conversion and packing routines. - */ - -#define YCbCrtoRGB(dst, Y) { \ - uint32 r, g, b; \ - TIFFYCbCrtoRGB(img->ycbcr, (Y), Cb, Cr, &r, &g, &b); \ - dst = PACK(r, g, b); \ -} - -/* - * 8-bit packed YCbCr samples => RGB - * This function is generic for different sampling sizes, - * and can handle blocks sizes that aren't multiples of the - * sampling size. However, it is substantially less optimized - * than the specific sampling cases. It is used as a fallback - * for difficult blocks. - */ -#ifdef notdef -static void putcontig8bitYCbCrGenericTile( - TIFFRGBAImage* img, - uint32* cp, - uint32 x, uint32 y, - uint32 w, uint32 h, - int32 fromskew, int32 toskew, - unsigned char* pp, - int h_group, - int v_group ) - -{ - uint32* cp1 = cp+w+toskew; - uint32* cp2 = cp1+w+toskew; - uint32* cp3 = cp2+w+toskew; - int32 incr = 3*w+4*toskew; - int32 Cb, Cr; - int group_size = v_group * h_group + 2; - - (void) y; - fromskew = (fromskew * group_size) / h_group; - - for ( yy = 0; yy < h; yy++ ) - { - unsigned char *pp_line; - int y_line_group = yy / v_group; - int y_remainder = yy - y_line_group * v_group; - - pp_line = pp + v_line_group * - - - for ( xx = 0; xx < w; xx++ ) - { - Cb = pp - } - } - for (; h >= 4; h -= 4) { - x = w>>2; - do { - Cb = pp[16]; - Cr = pp[17]; - - YCbCrtoRGB(cp [0], pp[ 0]); - YCbCrtoRGB(cp [1], pp[ 1]); - YCbCrtoRGB(cp [2], pp[ 2]); - YCbCrtoRGB(cp [3], pp[ 3]); - YCbCrtoRGB(cp1[0], pp[ 4]); - YCbCrtoRGB(cp1[1], pp[ 5]); - YCbCrtoRGB(cp1[2], pp[ 6]); - YCbCrtoRGB(cp1[3], pp[ 7]); - YCbCrtoRGB(cp2[0], pp[ 8]); - YCbCrtoRGB(cp2[1], pp[ 9]); - YCbCrtoRGB(cp2[2], pp[10]); - YCbCrtoRGB(cp2[3], pp[11]); - YCbCrtoRGB(cp3[0], pp[12]); - YCbCrtoRGB(cp3[1], pp[13]); - YCbCrtoRGB(cp3[2], pp[14]); - YCbCrtoRGB(cp3[3], pp[15]); - - cp += 4, cp1 += 4, cp2 += 4, cp3 += 4; - pp += 18; - } while (--x); - cp += incr, cp1 += incr, cp2 += incr, cp3 += incr; - pp += fromskew; - } -} -#endif - -/* - * 8-bit packed YCbCr samples w/ 4,4 subsampling => RGB - */ -DECLAREContigPutFunc(putcontig8bitYCbCr44tile) -{ - uint32* cp1 = cp+w+toskew; - uint32* cp2 = cp1+w+toskew; - uint32* cp3 = cp2+w+toskew; - int32 incr = 3*w+4*toskew; - - (void) y; - /* adjust fromskew */ - fromskew = (fromskew * 18) / 4; - if ((h & 3) == 0 && (w & 3) == 0) { - for (; h >= 4; h -= 4) { - x = w>>2; - do { - int32 Cb = pp[16]; - int32 Cr = pp[17]; - - YCbCrtoRGB(cp [0], pp[ 0]); - YCbCrtoRGB(cp [1], pp[ 1]); - YCbCrtoRGB(cp [2], pp[ 2]); - YCbCrtoRGB(cp [3], pp[ 3]); - YCbCrtoRGB(cp1[0], pp[ 4]); - YCbCrtoRGB(cp1[1], pp[ 5]); - YCbCrtoRGB(cp1[2], pp[ 6]); - YCbCrtoRGB(cp1[3], pp[ 7]); - YCbCrtoRGB(cp2[0], pp[ 8]); - YCbCrtoRGB(cp2[1], pp[ 9]); - YCbCrtoRGB(cp2[2], pp[10]); - YCbCrtoRGB(cp2[3], pp[11]); - YCbCrtoRGB(cp3[0], pp[12]); - YCbCrtoRGB(cp3[1], pp[13]); - YCbCrtoRGB(cp3[2], pp[14]); - YCbCrtoRGB(cp3[3], pp[15]); - - cp += 4, cp1 += 4, cp2 += 4, cp3 += 4; - pp += 18; - } while (--x); - cp += incr, cp1 += incr, cp2 += incr, cp3 += incr; - pp += fromskew; - } - } else { - while (h > 0) { - for (x = w; x > 0;) { - int32 Cb = pp[16]; - int32 Cr = pp[17]; - switch (x) { - default: - switch (h) { - default: YCbCrtoRGB(cp3[3], pp[15]); /* FALLTHROUGH */ - case 3: YCbCrtoRGB(cp2[3], pp[11]); /* FALLTHROUGH */ - case 2: YCbCrtoRGB(cp1[3], pp[ 7]); /* FALLTHROUGH */ - case 1: YCbCrtoRGB(cp [3], pp[ 3]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - case 3: - switch (h) { - default: YCbCrtoRGB(cp3[2], pp[14]); /* FALLTHROUGH */ - case 3: YCbCrtoRGB(cp2[2], pp[10]); /* FALLTHROUGH */ - case 2: YCbCrtoRGB(cp1[2], pp[ 6]); /* FALLTHROUGH */ - case 1: YCbCrtoRGB(cp [2], pp[ 2]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - case 2: - switch (h) { - default: YCbCrtoRGB(cp3[1], pp[13]); /* FALLTHROUGH */ - case 3: YCbCrtoRGB(cp2[1], pp[ 9]); /* FALLTHROUGH */ - case 2: YCbCrtoRGB(cp1[1], pp[ 5]); /* FALLTHROUGH */ - case 1: YCbCrtoRGB(cp [1], pp[ 1]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - case 1: - switch (h) { - default: YCbCrtoRGB(cp3[0], pp[12]); /* FALLTHROUGH */ - case 3: YCbCrtoRGB(cp2[0], pp[ 8]); /* FALLTHROUGH */ - case 2: YCbCrtoRGB(cp1[0], pp[ 4]); /* FALLTHROUGH */ - case 1: YCbCrtoRGB(cp [0], pp[ 0]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - } - if (x < 4) { - cp += x; cp1 += x; cp2 += x; cp3 += x; - x = 0; - } - else { - cp += 4; cp1 += 4; cp2 += 4; cp3 += 4; - x -= 4; - } - pp += 18; - } - if (h <= 4) - break; - h -= 4; - cp += incr, cp1 += incr, cp2 += incr, cp3 += incr; - pp += fromskew; - } - } -} - -/* - * 8-bit packed YCbCr samples w/ 4,2 subsampling => RGB - */ -DECLAREContigPutFunc(putcontig8bitYCbCr42tile) -{ - uint32* cp1 = cp+w+toskew; - int32 incr = 2*toskew+w; - - (void) y; - fromskew = (fromskew * 10) / 4; - if ((h & 3) == 0 && (w & 1) == 0) { - for (; h >= 2; h -= 2) { - x = w>>2; - do { - int32 Cb = pp[8]; - int32 Cr = pp[9]; - - YCbCrtoRGB(cp [0], pp[0]); - YCbCrtoRGB(cp [1], pp[1]); - YCbCrtoRGB(cp [2], pp[2]); - YCbCrtoRGB(cp [3], pp[3]); - YCbCrtoRGB(cp1[0], pp[4]); - YCbCrtoRGB(cp1[1], pp[5]); - YCbCrtoRGB(cp1[2], pp[6]); - YCbCrtoRGB(cp1[3], pp[7]); - - cp += 4, cp1 += 4; - pp += 10; - } while (--x); - cp += incr, cp1 += incr; - pp += fromskew; - } - } else { - while (h > 0) { - for (x = w; x > 0;) { - int32 Cb = pp[8]; - int32 Cr = pp[9]; - switch (x) { - default: - switch (h) { - default: YCbCrtoRGB(cp1[3], pp[ 7]); /* FALLTHROUGH */ - case 1: YCbCrtoRGB(cp [3], pp[ 3]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - case 3: - switch (h) { - default: YCbCrtoRGB(cp1[2], pp[ 6]); /* FALLTHROUGH */ - case 1: YCbCrtoRGB(cp [2], pp[ 2]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - case 2: - switch (h) { - default: YCbCrtoRGB(cp1[1], pp[ 5]); /* FALLTHROUGH */ - case 1: YCbCrtoRGB(cp [1], pp[ 1]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - case 1: - switch (h) { - default: YCbCrtoRGB(cp1[0], pp[ 4]); /* FALLTHROUGH */ - case 1: YCbCrtoRGB(cp [0], pp[ 0]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - } - if (x < 4) { - cp += x; cp1 += x; - x = 0; - } - else { - cp += 4; cp1 += 4; - x -= 4; - } - pp += 10; - } - if (h <= 2) - break; - h -= 2; - cp += incr, cp1 += incr; - pp += fromskew; - } - } -} - -/* - * 8-bit packed YCbCr samples w/ 4,1 subsampling => RGB - */ -DECLAREContigPutFunc(putcontig8bitYCbCr41tile) -{ - (void) y; - /* XXX adjust fromskew */ - do { - x = w>>2; - do { - int32 Cb = pp[4]; - int32 Cr = pp[5]; - - YCbCrtoRGB(cp [0], pp[0]); - YCbCrtoRGB(cp [1], pp[1]); - YCbCrtoRGB(cp [2], pp[2]); - YCbCrtoRGB(cp [3], pp[3]); - - cp += 4; - pp += 6; - } while (--x); - - if ( (w&3) != 0 ) - { - int32 Cb = pp[4]; - int32 Cr = pp[5]; - - switch( (w&3) ) { - case 3: YCbCrtoRGB(cp [2], pp[2]); - case 2: YCbCrtoRGB(cp [1], pp[1]); - case 1: YCbCrtoRGB(cp [0], pp[0]); - case 0: break; - } - - cp += (w&3); - pp += 6; - } - - cp += toskew; - pp += fromskew; - } while (--h); - -} - -/* - * 8-bit packed YCbCr samples w/ 2,2 subsampling => RGB - */ -DECLAREContigPutFunc(putcontig8bitYCbCr22tile) -{ - uint32* cp2; - int32 incr = 2*toskew+w; - (void) y; - fromskew = (fromskew / 2) * 6; - cp2 = cp+w+toskew; - while (h>=2) { - x = w; - while (x>=2) { - uint32 Cb = pp[4]; - uint32 Cr = pp[5]; - YCbCrtoRGB(cp[0], pp[0]); - YCbCrtoRGB(cp[1], pp[1]); - YCbCrtoRGB(cp2[0], pp[2]); - YCbCrtoRGB(cp2[1], pp[3]); - cp += 2; - cp2 += 2; - pp += 6; - x -= 2; - } - if (x==1) { - uint32 Cb = pp[4]; - uint32 Cr = pp[5]; - YCbCrtoRGB(cp[0], pp[0]); - YCbCrtoRGB(cp2[0], pp[2]); - cp ++ ; - cp2 ++ ; - pp += 6; - } - cp += incr; - cp2 += incr; - pp += fromskew; - h-=2; - } - if (h==1) { - x = w; - while (x>=2) { - uint32 Cb = pp[4]; - uint32 Cr = pp[5]; - YCbCrtoRGB(cp[0], pp[0]); - YCbCrtoRGB(cp[1], pp[1]); - cp += 2; - cp2 += 2; - pp += 6; - x -= 2; - } - if (x==1) { - uint32 Cb = pp[4]; - uint32 Cr = pp[5]; - YCbCrtoRGB(cp[0], pp[0]); - } - } -} - -/* - * 8-bit packed YCbCr samples w/ 2,1 subsampling => RGB - */ -DECLAREContigPutFunc(putcontig8bitYCbCr21tile) -{ - (void) y; - fromskew = (fromskew * 4) / 2; - do { - x = w>>1; - do { - int32 Cb = pp[2]; - int32 Cr = pp[3]; - - YCbCrtoRGB(cp[0], pp[0]); - YCbCrtoRGB(cp[1], pp[1]); - - cp += 2; - pp += 4; - } while (--x); - - if ( (w&1) != 0 ) - { - int32 Cb = pp[2]; - int32 Cr = pp[3]; - - YCbCrtoRGB(cp[0], pp[0]); - - cp += 1; - pp += 4; - } - - cp += toskew; - pp += fromskew; - } while (--h); -} - -/* - * 8-bit packed YCbCr samples w/ 1,2 subsampling => RGB - */ -DECLAREContigPutFunc(putcontig8bitYCbCr12tile) -{ - uint32* cp2; - int32 incr = 2*toskew+w; - (void) y; - fromskew = (fromskew / 2) * 4; - cp2 = cp+w+toskew; - while (h>=2) { - x = w; - do { - uint32 Cb = pp[2]; - uint32 Cr = pp[3]; - YCbCrtoRGB(cp[0], pp[0]); - YCbCrtoRGB(cp2[0], pp[1]); - cp ++; - cp2 ++; - pp += 4; - } while (--x); - cp += incr; - cp2 += incr; - pp += fromskew; - h-=2; - } - if (h==1) { - x = w; - do { - uint32 Cb = pp[2]; - uint32 Cr = pp[3]; - YCbCrtoRGB(cp[0], pp[0]); - cp ++; - pp += 4; - } while (--x); - } -} - -/* - * 8-bit packed YCbCr samples w/ no subsampling => RGB - */ -DECLAREContigPutFunc(putcontig8bitYCbCr11tile) -{ - (void) y; - fromskew *= 3; - do { - x = w; /* was x = w>>1; patched 2000/09/25 warmerda@home.com */ - do { - int32 Cb = pp[1]; - int32 Cr = pp[2]; - - YCbCrtoRGB(*cp++, pp[0]); - - pp += 3; - } while (--x); - cp += toskew; - pp += fromskew; - } while (--h); -} - -/* - * 8-bit packed YCbCr samples w/ no subsampling => RGB - */ -DECLARESepPutFunc(putseparate8bitYCbCr11tile) -{ - (void) y; - (void) a; - /* TODO: naming of input vars is still off, change obfuscating declaration inside define, or resolve obfuscation */ - while (h-- > 0) { - x = w; - do { - uint32 dr, dg, db; - TIFFYCbCrtoRGB(img->ycbcr,*r++,*g++,*b++,&dr,&dg,&db); - *cp++ = PACK(dr,dg,db); - } while (--x); - SKEW(r, g, b, fromskew); - cp += toskew; - } -} -#undef YCbCrtoRGB - -static int -initYCbCrConversion(TIFFRGBAImage* img) -{ - static char module[] = "initYCbCrConversion"; - - float *luma, *refBlackWhite; - - if (img->ycbcr == NULL) { - img->ycbcr = (TIFFYCbCrToRGB*) _TIFFmalloc( - TIFFroundup(sizeof (TIFFYCbCrToRGB), sizeof (long)) - + 4*256*sizeof (TIFFRGBValue) - + 2*256*sizeof (int) - + 3*256*sizeof (int32) - ); - if (img->ycbcr == NULL) { - TIFFErrorExt(img->tif->tif_clientdata, module, - "No space for YCbCr->RGB conversion state"); - return (0); - } - } - - TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRCOEFFICIENTS, &luma); - TIFFGetFieldDefaulted(img->tif, TIFFTAG_REFERENCEBLACKWHITE, - &refBlackWhite); - if (TIFFYCbCrToRGBInit(img->ycbcr, luma, refBlackWhite) < 0) - return(0); - return (1); -} - -static tileContigRoutine -initCIELabConversion(TIFFRGBAImage* img) -{ - static char module[] = "initCIELabConversion"; - - float *whitePoint; - float refWhite[3]; - - if (!img->cielab) { - img->cielab = (TIFFCIELabToRGB *) - _TIFFmalloc(sizeof(TIFFCIELabToRGB)); - if (!img->cielab) { - TIFFErrorExt(img->tif->tif_clientdata, module, - "No space for CIE L*a*b*->RGB conversion state."); - return NULL; - } - } - - TIFFGetFieldDefaulted(img->tif, TIFFTAG_WHITEPOINT, &whitePoint); - refWhite[1] = 100.0F; - refWhite[0] = whitePoint[0] / whitePoint[1] * refWhite[1]; - refWhite[2] = (1.0F - whitePoint[0] - whitePoint[1]) - / whitePoint[1] * refWhite[1]; - if (TIFFCIELabToRGBInit(img->cielab, &display_sRGB, refWhite) < 0) { - TIFFErrorExt(img->tif->tif_clientdata, module, - "Failed to initialize CIE L*a*b*->RGB conversion state."); - _TIFFfree(img->cielab); - return NULL; - } - - return putcontig8bitCIELab; -} - -/* - * Greyscale images with less than 8 bits/sample are handled - * with a table to avoid lots of shifts and masks. The table - * is setup so that put*bwtile (below) can retrieve 8/bitspersample - * pixel values simply by indexing into the table with one - * number. - */ -static int -makebwmap(TIFFRGBAImage* img) -{ - TIFFRGBValue* Map = img->Map; - int bitspersample = img->bitspersample; - int nsamples = 8 / bitspersample; - int i; - uint32* p; - - if ( nsamples == 0 ) - nsamples = 1; - - img->BWmap = (uint32**) _TIFFmalloc( - 256*sizeof (uint32 *)+(256*nsamples*sizeof(uint32))); - if (img->BWmap == NULL) { - TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif), "No space for B&W mapping table"); - return (0); - } - p = (uint32*)(img->BWmap + 256); - for (i = 0; i < 256; i++) { - TIFFRGBValue c; - img->BWmap[i] = p; - switch (bitspersample) { -#define GREY(x) c = Map[x]; *p++ = PACK(c,c,c); - case 1: - GREY(i>>7); - GREY((i>>6)&1); - GREY((i>>5)&1); - GREY((i>>4)&1); - GREY((i>>3)&1); - GREY((i>>2)&1); - GREY((i>>1)&1); - GREY(i&1); - break; - case 2: - GREY(i>>6); - GREY((i>>4)&3); - GREY((i>>2)&3); - GREY(i&3); - break; - case 4: - GREY(i>>4); - GREY(i&0xf); - break; - case 8: - case 16: - GREY(i); - break; - } -#undef GREY - } - return (1); -} - -/* - * Construct a mapping table to convert from the range - * of the data samples to [0,255] --for display. This - * process also handles inverting B&W images when needed. - */ -static int -setupMap(TIFFRGBAImage* img) -{ - int32 x, range; - - range = (int32)((1L<bitspersample)-1); - - /* treat 16 bit the same as eight bit */ - if ( img->bitspersample == 16 ) - range = (int32) 255; - - img->Map = (TIFFRGBValue*) _TIFFmalloc((range+1) * sizeof (TIFFRGBValue)); - if (img->Map == NULL) { - TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif), - "No space for photometric conversion table"); - return (0); - } - if (img->photometric == PHOTOMETRIC_MINISWHITE) { - for (x = 0; x <= range; x++) - img->Map[x] = (TIFFRGBValue) (((range - x) * 255) / range); - } else { - for (x = 0; x <= range; x++) - img->Map[x] = (TIFFRGBValue) ((x * 255) / range); - } - if (img->bitspersample <= 16 && - (img->photometric == PHOTOMETRIC_MINISBLACK || - img->photometric == PHOTOMETRIC_MINISWHITE)) { - /* - * Use photometric mapping table to construct - * unpacking tables for samples <= 8 bits. - */ - if (!makebwmap(img)) - return (0); - /* no longer need Map, free it */ - _TIFFfree(img->Map), img->Map = NULL; - } - return (1); -} - -static int -checkcmap(TIFFRGBAImage* img) -{ - uint16* r = img->redcmap; - uint16* g = img->greencmap; - uint16* b = img->bluecmap; - long n = 1L<bitspersample; - - while (n-- > 0) - if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256) - return (16); - return (8); -} - -static void -cvtcmap(TIFFRGBAImage* img) -{ - uint16* r = img->redcmap; - uint16* g = img->greencmap; - uint16* b = img->bluecmap; - long i; - - for (i = (1L<bitspersample)-1; i >= 0; i--) { -#define CVT(x) ((uint16)((x)>>8)) - r[i] = CVT(r[i]); - g[i] = CVT(g[i]); - b[i] = CVT(b[i]); -#undef CVT - } -} - -/* - * Palette images with <= 8 bits/sample are handled - * with a table to avoid lots of shifts and masks. The table - * is setup so that put*cmaptile (below) can retrieve 8/bitspersample - * pixel values simply by indexing into the table with one - * number. - */ -static int -makecmap(TIFFRGBAImage* img) -{ - int bitspersample = img->bitspersample; - int nsamples = 8 / bitspersample; - uint16* r = img->redcmap; - uint16* g = img->greencmap; - uint16* b = img->bluecmap; - uint32 *p; - int i; - - img->PALmap = (uint32**) _TIFFmalloc( - 256*sizeof (uint32 *)+(256*nsamples*sizeof(uint32))); - if (img->PALmap == NULL) { - TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif), "No space for Palette mapping table"); - return (0); - } - p = (uint32*)(img->PALmap + 256); - for (i = 0; i < 256; i++) { - TIFFRGBValue c; - img->PALmap[i] = p; -#define CMAP(x) c = (TIFFRGBValue) x; *p++ = PACK(r[c]&0xff, g[c]&0xff, b[c]&0xff); - switch (bitspersample) { - case 1: - CMAP(i>>7); - CMAP((i>>6)&1); - CMAP((i>>5)&1); - CMAP((i>>4)&1); - CMAP((i>>3)&1); - CMAP((i>>2)&1); - CMAP((i>>1)&1); - CMAP(i&1); - break; - case 2: - CMAP(i>>6); - CMAP((i>>4)&3); - CMAP((i>>2)&3); - CMAP(i&3); - break; - case 4: - CMAP(i>>4); - CMAP(i&0xf); - break; - case 8: - CMAP(i); - break; - } -#undef CMAP - } - return (1); -} - -/* - * Construct any mapping table used - * by the associated put routine. - */ -static int -buildMap(TIFFRGBAImage* img) -{ - switch (img->photometric) { - case PHOTOMETRIC_RGB: - case PHOTOMETRIC_YCBCR: - case PHOTOMETRIC_SEPARATED: - if (img->bitspersample == 8) - break; - /* fall thru... */ - case PHOTOMETRIC_MINISBLACK: - case PHOTOMETRIC_MINISWHITE: - if (!setupMap(img)) - return (0); - break; - case PHOTOMETRIC_PALETTE: - /* - * Convert 16-bit colormap to 8-bit (unless it looks - * like an old-style 8-bit colormap). - */ - if (checkcmap(img) == 16) - cvtcmap(img); - else - TIFFWarningExt(img->tif->tif_clientdata, TIFFFileName(img->tif), "Assuming 8-bit colormap"); - /* - * Use mapping table and colormap to construct - * unpacking tables for samples < 8 bits. - */ - if (img->bitspersample <= 8 && !makecmap(img)) - return (0); - break; - } - return (1); -} - -/* - * Select the appropriate conversion routine for packed data. - */ -static int -PickContigCase(TIFFRGBAImage* img) -{ - img->get = TIFFIsTiled(img->tif) ? gtTileContig : gtStripContig; - img->put.contig = NULL; - switch (img->photometric) { - case PHOTOMETRIC_RGB: - switch (img->bitspersample) { - case 8: - if (img->alpha == EXTRASAMPLE_ASSOCALPHA) - img->put.contig = putRGBAAcontig8bittile; - else if (img->alpha == EXTRASAMPLE_UNASSALPHA) - { - img->put.contig = putRGBUAcontig8bittile; - } - else - img->put.contig = putRGBcontig8bittile; - break; - case 16: - if (img->alpha == EXTRASAMPLE_ASSOCALPHA) - { - img->put.contig = putRGBAAcontig16bittile; - } - else if (img->alpha == EXTRASAMPLE_UNASSALPHA) - { - img->put.contig = putRGBUAcontig16bittile; - } - else - { - img->put.contig = putRGBcontig16bittile; - } - break; - } - break; - case PHOTOMETRIC_SEPARATED: - if (buildMap(img)) { - if (img->bitspersample == 8) { - if (!img->Map) - img->put.contig = putRGBcontig8bitCMYKtile; - else - img->put.contig = putRGBcontig8bitCMYKMaptile; - } - } - break; - case PHOTOMETRIC_PALETTE: - if (buildMap(img)) { - switch (img->bitspersample) { - case 8: - img->put.contig = put8bitcmaptile; - break; - case 4: - img->put.contig = put4bitcmaptile; - break; - case 2: - img->put.contig = put2bitcmaptile; - break; - case 1: - img->put.contig = put1bitcmaptile; - break; - } - } - break; - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: - if (buildMap(img)) { - switch (img->bitspersample) { - case 16: - img->put.contig = put16bitbwtile; - break; - case 8: - img->put.contig = putgreytile; - break; - case 4: - img->put.contig = put4bitbwtile; - break; - case 2: - img->put.contig = put2bitbwtile; - break; - case 1: - img->put.contig = put1bitbwtile; - break; - } - } - break; - case PHOTOMETRIC_YCBCR: - if ((img->bitspersample==8) && (img->samplesperpixel==3)) - { - if (initYCbCrConversion(img)!=0) - { - /* - * The 6.0 spec says that subsampling must be - * one of 1, 2, or 4, and that vertical subsampling - * must always be <= horizontal subsampling; so - * there are only a few possibilities and we just - * enumerate the cases. - * Joris: added support for the [1,2] case, nonetheless, to accomodate - * some OJPEG files - */ - uint16 SubsamplingHor; - uint16 SubsamplingVer; - TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &SubsamplingHor, &SubsamplingVer); - switch ((SubsamplingHor<<4)|SubsamplingVer) { - case 0x44: - img->put.contig = putcontig8bitYCbCr44tile; - break; - case 0x42: - img->put.contig = putcontig8bitYCbCr42tile; - break; - case 0x41: - img->put.contig = putcontig8bitYCbCr41tile; - break; - case 0x22: - img->put.contig = putcontig8bitYCbCr22tile; - break; - case 0x21: - img->put.contig = putcontig8bitYCbCr21tile; - break; - case 0x12: - img->put.contig = putcontig8bitYCbCr12tile; - break; - case 0x11: - img->put.contig = putcontig8bitYCbCr11tile; - break; - } - } - } - break; - case PHOTOMETRIC_CIELAB: - if (buildMap(img)) { - if (img->bitspersample == 8) - img->put.contig = initCIELabConversion(img); - break; - } - } - return ((img->get!=NULL) && (img->put.contig!=NULL)); -} - -/* - * Select the appropriate conversion routine for unpacked data. - * - * NB: we assume that unpacked single channel data is directed - * to the "packed routines. - */ -static int -PickSeparateCase(TIFFRGBAImage* img) -{ - img->get = TIFFIsTiled(img->tif) ? gtTileSeparate : gtStripSeparate; - img->put.separate = NULL; - switch (img->photometric) { - case PHOTOMETRIC_RGB: - switch (img->bitspersample) { - case 8: - if (img->alpha == EXTRASAMPLE_ASSOCALPHA) - img->put.separate = putRGBAAseparate8bittile; - else if (img->alpha == EXTRASAMPLE_UNASSALPHA) - { - img->put.separate = putRGBUAseparate8bittile; - } - else - img->put.separate = putRGBseparate8bittile; - break; - case 16: - if (img->alpha == EXTRASAMPLE_ASSOCALPHA) - { - img->put.separate = putRGBAAseparate16bittile; - } - else if (img->alpha == EXTRASAMPLE_UNASSALPHA) - { - img->put.separate = putRGBUAseparate16bittile; - } - else - { - img->put.separate = putRGBseparate16bittile; - } - break; - } - break; - case PHOTOMETRIC_YCBCR: - if ((img->bitspersample==8) && (img->samplesperpixel==3)) - { - if (initYCbCrConversion(img)!=0) - { - uint16 hs, vs; - TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &hs, &vs); - switch ((hs<<4)|vs) { - case 0x11: - img->put.separate = putseparate8bitYCbCr11tile; - break; - /* TODO: add other cases here */ - } - } - } - break; - } - return ((img->get!=NULL) && (img->put.separate!=NULL)); -} - -/* - * Read a whole strip off data from the file, and convert to RGBA form. - * If this is the last strip, then it will only contain the portion of - * the strip that is actually within the image space. The result is - * organized in bottom to top form. - */ - - -int -TIFFReadRGBAStrip(TIFF* tif, uint32 row, uint32 * raster ) - -{ - char emsg[1024] = ""; - TIFFRGBAImage img; - int ok; - uint32 rowsperstrip, rows_to_read; - - if ( TIFFIsTiled( tif ) ) - { - TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), - "Can't use TIFFReadRGBAStrip() with tiled file."); - return (0); - } - - TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); - if ( (row % rowsperstrip) != 0 ) - { - TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), - "Row passed to TIFFReadRGBAStrip() must be first in a strip."); - return (0); - } - - if (TIFFRGBAImageOK(tif, emsg) && TIFFRGBAImageBegin(&img, tif, 0, emsg)) { - - img.row_offset = row; - img.col_offset = 0; - - if ( row + rowsperstrip > img.height ) - rows_to_read = img.height - row; - else - rows_to_read = rowsperstrip; - - ok = TIFFRGBAImageGet(&img, raster, img.width, rows_to_read ); - - TIFFRGBAImageEnd(&img); - } else { - TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", emsg); - ok = 0; - } - - return (ok); -} - -/* - * Read a whole tile off data from the file, and convert to RGBA form. - * The returned RGBA data is organized from bottom to top of tile, - * and may include zeroed areas if the tile extends off the image. - */ - -int -TIFFReadRGBATile(TIFF* tif, uint32 col, uint32 row, uint32 * raster) - -{ - char emsg[1024] = ""; - TIFFRGBAImage img; - int ok; - uint32 tile_xsize, tile_ysize; - uint32 read_xsize, read_ysize; - uint32 i_row; - - /* - * Verify that our request is legal - on a tile file, and on a - * tile boundary. - */ - - if ( !TIFFIsTiled( tif ) ) - { - TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), - "Can't use TIFFReadRGBATile() with stripped file."); - return (0); - } - - TIFFGetFieldDefaulted(tif, TIFFTAG_TILEWIDTH, &tile_xsize); - TIFFGetFieldDefaulted(tif, TIFFTAG_TILELENGTH, &tile_ysize); - if ( (col % tile_xsize) != 0 || (row % tile_ysize) != 0 ) - { - TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), - "Row/col passed to TIFFReadRGBATile() must be top" - "left corner of a tile."); - return (0); - } - - /* - * Setup the RGBA reader. - */ - - if (!TIFFRGBAImageOK(tif, emsg) - || !TIFFRGBAImageBegin(&img, tif, 0, emsg)) { - TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", emsg); - return( 0 ); - } - - /* - * The TIFFRGBAImageGet() function doesn't allow us to get off the - * edge of the image, even to fill an otherwise valid tile. So we - * figure out how much we can read, and fix up the tile buffer to - * a full tile configuration afterwards. - */ - - if ( row + tile_ysize > img.height ) - read_ysize = img.height - row; - else - read_ysize = tile_ysize; - - if ( col + tile_xsize > img.width ) - read_xsize = img.width - col; - else - read_xsize = tile_xsize; - - /* - * Read the chunk of imagery. - */ - - img.row_offset = row; - img.col_offset = col; - - ok = TIFFRGBAImageGet(&img, raster, read_xsize, read_ysize ); - - TIFFRGBAImageEnd(&img); - - /* - * If our read was incomplete we will need to fix up the tile by - * shifting the data around as if a full tile of data is being returned. - * - * This is all the more complicated because the image is organized in - * bottom to top format. - */ - - if ( read_xsize == tile_xsize && read_ysize == tile_ysize ) - return( ok ); - - for ( i_row = 0; i_row < read_ysize; i_row++ ) { - memmove( raster + (tile_ysize - i_row - 1) * tile_xsize, - raster + (read_ysize - i_row - 1) * read_xsize, - read_xsize * sizeof(uint32) ); - _TIFFmemset( raster + (tile_ysize - i_row - 1) * tile_xsize+read_xsize, - 0, sizeof(uint32) * (tile_xsize - read_xsize) ); - } - - for ( i_row = read_ysize; i_row < tile_ysize; i_row++ ) { - _TIFFmemset( raster + (tile_ysize - i_row - 1) * tile_xsize, - 0, sizeof(uint32) * tile_xsize ); - } - - return (ok); -} - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_jbig.c b/plugins/AdvaImg/src/LibTIFF/tif_jbig.c deleted file mode 100644 index c779c9b0f6..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_jbig.c +++ /dev/null @@ -1,385 +0,0 @@ -/* $Id: tif_jbig.c,v 1.23 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * JBIG Compression Algorithm Support. - * Contributed by Lee Howard - * - */ - -#include "tiffiop.h" - -#ifdef JBIG_SUPPORT -#include "jbig.h" - -typedef struct -{ - uint32 recvparams; /* encoded Class 2 session params */ - char* subaddress; /* subaddress string */ - uint32 recvtime; /* time spend receiving in seconds */ - char* faxdcs; /* encoded fax parameters (DCS, Table 2/T.30) */ - - TIFFVGetMethod vgetparent; - TIFFVSetMethod vsetparent; -} JBIGState; - -#define GetJBIGState(tif) ((JBIGState*)(tif)->tif_data) - -#define FIELD_RECVPARAMS (FIELD_CODEC+0) -#define FIELD_SUBADDRESS (FIELD_CODEC+1) -#define FIELD_RECVTIME (FIELD_CODEC+2) -#define FIELD_FAXDCS (FIELD_CODEC+3) - -static const TIFFFieldInfo jbigFieldInfo[] = -{ - {TIFFTAG_FAXRECVPARAMS, 1, 1, TIFF_LONG, FIELD_RECVPARAMS, TRUE, FALSE, "FaxRecvParams"}, - {TIFFTAG_FAXSUBADDRESS, -1, -1, TIFF_ASCII, FIELD_SUBADDRESS, TRUE, FALSE, "FaxSubAddress"}, - {TIFFTAG_FAXRECVTIME, 1, 1, TIFF_LONG, FIELD_RECVTIME, TRUE, FALSE, "FaxRecvTime"}, - {TIFFTAG_FAXDCS, -1, -1, TIFF_ASCII, FIELD_FAXDCS, TRUE, FALSE, "FaxDcs"}, -}; - -static int JBIGSetupDecode(TIFF* tif) -{ - if (TIFFNumberOfStrips(tif) != 1) - { - TIFFError("JBIG", "Multistrip images not supported in decoder"); - return 0; - } - - return 1; -} - -static int JBIGDecode(TIFF* tif, tidata_t buffer, tsize_t size, tsample_t s) -{ - struct jbg_dec_state decoder; - int decodeStatus = 0; - unsigned char* pImage = NULL; - (void) size, (void) s; - - if (isFillOrder(tif, tif->tif_dir.td_fillorder)) - { - TIFFReverseBits(tif->tif_rawdata, tif->tif_rawdatasize); - } - - jbg_dec_init(&decoder); - -#if defined(HAVE_JBG_NEWLEN) - jbg_newlen(tif->tif_rawdata, tif->tif_rawdatasize); - /* - * I do not check the return status of jbg_newlen because even if this - * function fails it does not necessarily mean that decoding the image - * will fail. It is generally only needed for received fax images - * that do not contain the actual length of the image in the BIE - * header. I do not log when an error occurs because that will cause - * problems when converting JBIG encoded TIFF's to - * PostScript. As long as the actual image length is contained in the - * BIE header jbg_dec_in should succeed. - */ -#endif /* HAVE_JBG_NEWLEN */ - - decodeStatus = jbg_dec_in(&decoder, tif->tif_rawdata, - tif->tif_rawdatasize, NULL); - if (JBG_EOK != decodeStatus) - { - /* - * XXX: JBG_EN constant was defined in pre-2.0 releases of the - * JBIG-KIT. Since the 2.0 the error reporting functions were - * changed. We will handle both cases here. - */ - TIFFError("JBIG", "Error (%d) decoding: %s", decodeStatus, -#if defined(JBG_EN) - jbg_strerror(decodeStatus, JBG_EN) -#else - jbg_strerror(decodeStatus) -#endif - ); - return 0; - } - - pImage = jbg_dec_getimage(&decoder, 0); - _TIFFmemcpy(buffer, pImage, jbg_dec_getsize(&decoder)); - jbg_dec_free(&decoder); - return 1; -} - -static int JBIGSetupEncode(TIFF* tif) -{ - if (TIFFNumberOfStrips(tif) != 1) - { - TIFFError("JBIG", "Multistrip images not supported in encoder"); - return 0; - } - - return 1; -} - -static int JBIGCopyEncodedData(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) -{ - (void) s; - while (cc > 0) - { - tsize_t n = cc; - - if (tif->tif_rawcc + n > tif->tif_rawdatasize) - { - n = tif->tif_rawdatasize - tif->tif_rawcc; - } - - assert(n > 0); - _TIFFmemcpy(tif->tif_rawcp, pp, n); - tif->tif_rawcp += n; - tif->tif_rawcc += n; - pp += n; - cc -= n; - if (tif->tif_rawcc >= tif->tif_rawdatasize && - !TIFFFlushData1(tif)) - { - return (-1); - } - } - - return (1); -} - -static void JBIGOutputBie(unsigned char* buffer, size_t len, void *userData) -{ - TIFF* tif = (TIFF*)userData; - - if (isFillOrder(tif, tif->tif_dir.td_fillorder)) - { - TIFFReverseBits(buffer, len); - } - - JBIGCopyEncodedData(tif, buffer, len, 0); -} - -static int JBIGEncode(TIFF* tif, tidata_t buffer, tsize_t size, tsample_t s) -{ - TIFFDirectory* dir = &tif->tif_dir; - struct jbg_enc_state encoder; - - (void) size, (void) s; - - jbg_enc_init(&encoder, - dir->td_imagewidth, - dir->td_imagelength, - 1, - &buffer, - JBIGOutputBie, - tif); - /* - * jbg_enc_out does the "real" encoding. As data is encoded, - * JBIGOutputBie is called, which writes the data to the directory. - */ - jbg_enc_out(&encoder); - jbg_enc_free(&encoder); - - return 1; -} - -static void JBIGCleanup(TIFF* tif) -{ - JBIGState *sp = GetJBIGState(tif); - - assert(sp != 0); - - tif->tif_tagmethods.vgetfield = sp->vgetparent; - tif->tif_tagmethods.vsetfield = sp->vsetparent; - - _TIFFfree(tif->tif_data); - tif->tif_data = NULL; - - _TIFFSetDefaultCompressionState(tif); -} - -static void JBIGPrintDir(TIFF* tif, FILE* fd, long flags) -{ - JBIGState* codec = GetJBIGState(tif); - (void)flags; - - if (TIFFFieldSet(tif, FIELD_RECVPARAMS)) - { - fprintf(fd, - " Fax Receive Parameters: %08lx\n", - (unsigned long)codec->recvparams); - } - - if (TIFFFieldSet(tif, FIELD_SUBADDRESS)) - { - fprintf(fd, - " Fax SubAddress: %s\n", - codec->subaddress); - } - - if (TIFFFieldSet(tif, FIELD_RECVTIME)) - { - fprintf(fd, - " Fax Receive Time: %lu secs\n", - (unsigned long)codec->recvtime); - } - - if (TIFFFieldSet(tif, FIELD_FAXDCS)) - { - fprintf(fd, - " Fax DCS: %s\n", - codec->faxdcs); - } -} - -static int JBIGVGetField(TIFF* tif, ttag_t tag, va_list ap) -{ - JBIGState* codec = GetJBIGState(tif); - - switch (tag) - { - case TIFFTAG_FAXRECVPARAMS: - *va_arg(ap, uint32*) = codec->recvparams; - break; - - case TIFFTAG_FAXSUBADDRESS: - *va_arg(ap, char**) = codec->subaddress; - break; - - case TIFFTAG_FAXRECVTIME: - *va_arg(ap, uint32*) = codec->recvtime; - break; - - case TIFFTAG_FAXDCS: - *va_arg(ap, char**) = codec->faxdcs; - break; - - default: - return (*codec->vgetparent)(tif, tag, ap); - } - - return 1; -} - -static int JBIGVSetField(TIFF* tif, ttag_t tag, va_list ap) -{ - JBIGState* codec = GetJBIGState(tif); - - switch (tag) - { - case TIFFTAG_FAXRECVPARAMS: - codec->recvparams = va_arg(ap, uint32); - break; - - case TIFFTAG_FAXSUBADDRESS: - _TIFFsetString(&codec->subaddress, va_arg(ap, char*)); - break; - - case TIFFTAG_FAXRECVTIME: - codec->recvtime = va_arg(ap, uint32); - break; - - case TIFFTAG_FAXDCS: - _TIFFsetString(&codec->faxdcs, va_arg(ap, char*)); - break; - - default: - return (*codec->vsetparent)(tif, tag, ap); - } - - TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit); - tif->tif_flags |= TIFF_DIRTYDIRECT; - return 1; -} - -int TIFFInitJBIG(TIFF* tif, int scheme) -{ - JBIGState* codec = NULL; - - assert(scheme == COMPRESSION_JBIG); - - /* - * Merge codec-specific tag information. - */ - if (!_TIFFMergeFieldInfo(tif, jbigFieldInfo, - TIFFArrayCount(jbigFieldInfo))) { - TIFFErrorExt(tif->tif_clientdata, "TIFFInitJBIG", - "Merging JBIG codec-specific tags failed"); - return 0; - } - - /* Allocate memory for the JBIGState structure.*/ - tif->tif_data = (tdata_t)_TIFFmalloc(sizeof(JBIGState)); - if (tif->tif_data == NULL) - { - TIFFError("TIFFInitJBIG", "Not enough memory for JBIGState"); - return 0; - } - _TIFFmemset(tif->tif_data, 0, sizeof(JBIGState)); - codec = GetJBIGState(tif); - - /* Initialize codec private fields */ - codec->recvparams = 0; - codec->subaddress = NULL; - codec->faxdcs = NULL; - codec->recvtime = 0; - - /* - * Override parent get/set field methods. - */ - codec->vgetparent = tif->tif_tagmethods.vgetfield; - codec->vsetparent = tif->tif_tagmethods.vsetfield; - tif->tif_tagmethods.vgetfield = JBIGVGetField; - tif->tif_tagmethods.vsetfield = JBIGVSetField; - tif->tif_tagmethods.printdir = JBIGPrintDir; - - /* - * These flags are set so the JBIG Codec can control when to reverse - * bits and when not to and to allow the jbig decoder and bit reverser - * to write to memory when necessary. - */ - tif->tif_flags |= TIFF_NOBITREV; - tif->tif_flags &= ~TIFF_MAPPED; - - /* Setup the function pointers for encode, decode, and cleanup. */ - tif->tif_setupdecode = JBIGSetupDecode; - tif->tif_decodestrip = JBIGDecode; - - tif->tif_setupencode = JBIGSetupEncode; - tif->tif_encodestrip = JBIGEncode; - - tif->tif_cleanup = JBIGCleanup; - - return 1; -} - -#endif /* JBIG_SUPPORT */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ - -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_jpeg.c b/plugins/AdvaImg/src/LibTIFF/tif_jpeg.c deleted file mode 100644 index ee7d886fa8..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_jpeg.c +++ /dev/null @@ -1,2078 +0,0 @@ -/* $Id: tif_jpeg.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1994-1997 Sam Leffler - * Copyright (c) 1994-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#define WIN32_LEAN_AND_MEAN -#define VC_EXTRALEAN - -#include "tiffiop.h" -#ifdef JPEG_SUPPORT - -/* - * TIFF Library - * - * JPEG Compression support per TIFF Technical Note #2 - * (*not* per the original TIFF 6.0 spec). - * - * This file is simply an interface to the libjpeg library written by - * the Independent JPEG Group. You need release 5 or later of the IJG - * code, which you can find on the Internet at ftp.uu.net:/graphics/jpeg/. - * - * Contributed by Tom Lane . - */ -#include - -int TIFFFillStrip(TIFF*, tstrip_t); -int TIFFFillTile(TIFF*, ttile_t); - -/* We undefine FAR to avoid conflict with JPEG definition */ - -#ifdef FAR -#undef FAR -#endif - -/* - Libjpeg's jmorecfg.h defines INT16 and INT32, but only if XMD_H is - not defined. Unfortunately, the MinGW and Borland compilers include - a typedef for INT32, which causes a conflict. MSVC does not include - a conficting typedef given the headers which are included. -*/ -#if defined(__BORLANDC__) || defined(__MINGW32__) -# define XMD_H 1 -#endif - -/* - The windows RPCNDR.H file defines boolean, but defines it with the - unsigned char size. You should compile JPEG library using appropriate - definitions in jconfig.h header, but many users compile library in wrong - way. That causes errors of the following type: - - "JPEGLib: JPEG parameter struct mismatch: library thinks size is 432, - caller expects 464" - - For such users we wil fix the problem here. See install.doc file from - the JPEG library distribution for details. -*/ - -/* Define "boolean" as unsigned char, not int, per Windows custom. */ -#if defined(WIN32) && !defined(__MINGW32__) -# ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ - typedef unsigned char boolean; -# endif -# define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ -#endif - -#include "../LibJPEG/jpeglib.h" -#include "../LibJPEG/jerror.h" - -/* - * We are using width_in_blocks which is supposed to be private to - * libjpeg. Unfortunately, the libjpeg delivered with Cygwin has - * renamed this member to width_in_data_units. Since the header has - * also renamed a define, use that unique define name in order to - * detect the problem header and adjust to suit. - */ -#if defined(D_MAX_DATA_UNITS_IN_MCU) -#define width_in_blocks width_in_data_units -#endif - -/* - * On some machines it may be worthwhile to use _setjmp or sigsetjmp - * in place of plain setjmp. These macros will make it easier. - */ -#define SETJMP(jbuf) setjmp(jbuf) -#define LONGJMP(jbuf,code) longjmp(jbuf,code) -#define JMP_BUF jmp_buf - -typedef struct jpeg_destination_mgr jpeg_destination_mgr; -typedef struct jpeg_source_mgr jpeg_source_mgr; -typedef struct jpeg_error_mgr jpeg_error_mgr; - -/* - * State block for each open TIFF file using - * libjpeg to do JPEG compression/decompression. - * - * libjpeg's visible state is either a jpeg_compress_struct - * or jpeg_decompress_struct depending on which way we - * are going. comm can be used to refer to the fields - * which are common to both. - * - * NB: cinfo is required to be the first member of JPEGState, - * so we can safely cast JPEGState* -> jpeg_xxx_struct* - * and vice versa! - */ -typedef struct { - union { - struct jpeg_compress_struct c; - struct jpeg_decompress_struct d; - struct jpeg_common_struct comm; - } cinfo; /* NB: must be first */ - int cinfo_initialized; - - jpeg_error_mgr err; /* libjpeg error manager */ - JMP_BUF exit_jmpbuf; /* for catching libjpeg failures */ - /* - * The following two members could be a union, but - * they're small enough that it's not worth the effort. - */ - jpeg_destination_mgr dest; /* data dest for compression */ - jpeg_source_mgr src; /* data source for decompression */ - /* private state */ - TIFF* tif; /* back link needed by some code */ - uint16 photometric; /* copy of PhotometricInterpretation */ - uint16 h_sampling; /* luminance sampling factors */ - uint16 v_sampling; - tsize_t bytesperline; /* decompressed bytes per scanline */ - /* pointers to intermediate buffers when processing downsampled data */ - JSAMPARRAY ds_buffer[MAX_COMPONENTS]; - int scancount; /* number of "scanlines" accumulated */ - int samplesperclump; - - TIFFVGetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ - TIFFPrintMethod printdir; /* super-class method */ - TIFFStripMethod defsparent; /* super-class method */ - TIFFTileMethod deftparent; /* super-class method */ - /* pseudo-tag fields */ - void* jpegtables; /* JPEGTables tag value, or NULL */ - uint32 jpegtables_length; /* number of bytes in same */ - int jpegquality; /* Compression quality level */ - int jpegcolormode; /* Auto RGB<=>YCbCr convert? */ - int jpegtablesmode; /* What to put in JPEGTables */ - - int ycbcrsampling_fetched; - uint32 recvparams; /* encoded Class 2 session params */ - char* subaddress; /* subaddress string */ - uint32 recvtime; /* time spent receiving (secs) */ - char* faxdcs; /* encoded fax parameters (DCS, Table 2/T.30) */ -} JPEGState; - -#define JState(tif) ((JPEGState*)(tif)->tif_data) - -static int JPEGDecode(TIFF*, tidata_t, tsize_t, tsample_t); -static int JPEGDecodeRaw(TIFF*, tidata_t, tsize_t, tsample_t); -static int JPEGEncode(TIFF*, tidata_t, tsize_t, tsample_t); -static int JPEGEncodeRaw(TIFF*, tidata_t, tsize_t, tsample_t); -static int JPEGInitializeLibJPEG( TIFF * tif, - int force_encode, int force_decode ); - -#define FIELD_JPEGTABLES (FIELD_CODEC+0) -#define FIELD_RECVPARAMS (FIELD_CODEC+1) -#define FIELD_SUBADDRESS (FIELD_CODEC+2) -#define FIELD_RECVTIME (FIELD_CODEC+3) -#define FIELD_FAXDCS (FIELD_CODEC+4) - -static const TIFFFieldInfo jpegFieldInfo[] = { - { TIFFTAG_JPEGTABLES, -3,-3, TIFF_UNDEFINED, FIELD_JPEGTABLES, - FALSE, TRUE, "JPEGTables" }, - { TIFFTAG_JPEGQUALITY, 0, 0, TIFF_ANY, FIELD_PSEUDO, - TRUE, FALSE, "" }, - { TIFFTAG_JPEGCOLORMODE, 0, 0, TIFF_ANY, FIELD_PSEUDO, - FALSE, FALSE, "" }, - { TIFFTAG_JPEGTABLESMODE, 0, 0, TIFF_ANY, FIELD_PSEUDO, - FALSE, FALSE, "" }, - /* Specific for JPEG in faxes */ - { TIFFTAG_FAXRECVPARAMS, 1, 1, TIFF_LONG, FIELD_RECVPARAMS, - TRUE, FALSE, "FaxRecvParams" }, - { TIFFTAG_FAXSUBADDRESS, -1,-1, TIFF_ASCII, FIELD_SUBADDRESS, - TRUE, FALSE, "FaxSubAddress" }, - { TIFFTAG_FAXRECVTIME, 1, 1, TIFF_LONG, FIELD_RECVTIME, - TRUE, FALSE, "FaxRecvTime" }, - { TIFFTAG_FAXDCS, -1, -1, TIFF_ASCII, FIELD_FAXDCS, - TRUE, FALSE, "FaxDcs" }, -}; -#define N(a) (sizeof (a) / sizeof (a[0])) - -/* - * libjpeg interface layer. - * - * We use setjmp/longjmp to return control to libtiff - * when a fatal error is encountered within the JPEG - * library. We also direct libjpeg error and warning - * messages through the appropriate libtiff handlers. - */ - -/* - * Error handling routines (these replace corresponding - * IJG routines from jerror.c). These are used for both - * compression and decompression. - */ -static void -TIFFjpeg_error_exit(j_common_ptr cinfo) -{ - JPEGState *sp = (JPEGState *) cinfo; /* NB: cinfo assumed first */ - char buffer[JMSG_LENGTH_MAX]; - - (*cinfo->err->format_message) (cinfo, buffer); - TIFFErrorExt(sp->tif->tif_clientdata, "JPEGLib", "%s", buffer); /* display the error message */ - jpeg_abort(cinfo); /* clean up libjpeg state */ - LONGJMP(sp->exit_jmpbuf, 1); /* return to libtiff caller */ -} - -/* - * This routine is invoked only for warning messages, - * since error_exit does its own thing and trace_level - * is never set > 0. - */ -static void -TIFFjpeg_output_message(j_common_ptr cinfo) -{ - char buffer[JMSG_LENGTH_MAX]; - - (*cinfo->err->format_message) (cinfo, buffer); - TIFFWarningExt(((JPEGState *) cinfo)->tif->tif_clientdata, "JPEGLib", "%s", buffer); -} - -/* - * Interface routines. This layer of routines exists - * primarily to limit side-effects from using setjmp. - * Also, normal/error returns are converted into return - * values per libtiff practice. - */ -#define CALLJPEG(sp, fail, op) (SETJMP((sp)->exit_jmpbuf) ? (fail) : (op)) -#define CALLVJPEG(sp, op) CALLJPEG(sp, 0, ((op),1)) - -static int -TIFFjpeg_create_compress(JPEGState* sp) -{ - /* initialize JPEG error handling */ - sp->cinfo.c.err = jpeg_std_error(&sp->err); - sp->err.error_exit = TIFFjpeg_error_exit; - sp->err.output_message = TIFFjpeg_output_message; - - return CALLVJPEG(sp, jpeg_create_compress(&sp->cinfo.c)); -} - -static int -TIFFjpeg_create_decompress(JPEGState* sp) -{ - /* initialize JPEG error handling */ - sp->cinfo.d.err = jpeg_std_error(&sp->err); - sp->err.error_exit = TIFFjpeg_error_exit; - sp->err.output_message = TIFFjpeg_output_message; - - return CALLVJPEG(sp, jpeg_create_decompress(&sp->cinfo.d)); -} - -static int -TIFFjpeg_set_defaults(JPEGState* sp) -{ - return CALLVJPEG(sp, jpeg_set_defaults(&sp->cinfo.c)); -} - -static int -TIFFjpeg_set_colorspace(JPEGState* sp, J_COLOR_SPACE colorspace) -{ - return CALLVJPEG(sp, jpeg_set_colorspace(&sp->cinfo.c, colorspace)); -} - -static int -TIFFjpeg_set_quality(JPEGState* sp, int quality, boolean force_baseline) -{ - return CALLVJPEG(sp, - jpeg_set_quality(&sp->cinfo.c, quality, force_baseline)); -} - -static int -TIFFjpeg_suppress_tables(JPEGState* sp, boolean suppress) -{ - return CALLVJPEG(sp, jpeg_suppress_tables(&sp->cinfo.c, suppress)); -} - -static int -TIFFjpeg_start_compress(JPEGState* sp, boolean write_all_tables) -{ - return CALLVJPEG(sp, - jpeg_start_compress(&sp->cinfo.c, write_all_tables)); -} - -static int -TIFFjpeg_write_scanlines(JPEGState* sp, JSAMPARRAY scanlines, int num_lines) -{ - return CALLJPEG(sp, -1, (int) jpeg_write_scanlines(&sp->cinfo.c, - scanlines, (JDIMENSION) num_lines)); -} - -static int -TIFFjpeg_write_raw_data(JPEGState* sp, JSAMPIMAGE data, int num_lines) -{ - return CALLJPEG(sp, -1, (int) jpeg_write_raw_data(&sp->cinfo.c, - data, (JDIMENSION) num_lines)); -} - -static int -TIFFjpeg_finish_compress(JPEGState* sp) -{ - return CALLVJPEG(sp, jpeg_finish_compress(&sp->cinfo.c)); -} - -static int -TIFFjpeg_write_tables(JPEGState* sp) -{ - return CALLVJPEG(sp, jpeg_write_tables(&sp->cinfo.c)); -} - -static int -TIFFjpeg_read_header(JPEGState* sp, boolean require_image) -{ - return CALLJPEG(sp, -1, jpeg_read_header(&sp->cinfo.d, require_image)); -} - -static int -TIFFjpeg_start_decompress(JPEGState* sp) -{ - return CALLVJPEG(sp, jpeg_start_decompress(&sp->cinfo.d)); -} - -static int -TIFFjpeg_read_scanlines(JPEGState* sp, JSAMPARRAY scanlines, int max_lines) -{ - return CALLJPEG(sp, -1, (int) jpeg_read_scanlines(&sp->cinfo.d, - scanlines, (JDIMENSION) max_lines)); -} - -static int -TIFFjpeg_read_raw_data(JPEGState* sp, JSAMPIMAGE data, int max_lines) -{ - return CALLJPEG(sp, -1, (int) jpeg_read_raw_data(&sp->cinfo.d, - data, (JDIMENSION) max_lines)); -} - -static int -TIFFjpeg_finish_decompress(JPEGState* sp) -{ - return CALLJPEG(sp, -1, (int) jpeg_finish_decompress(&sp->cinfo.d)); -} - -static int -TIFFjpeg_abort(JPEGState* sp) -{ - return CALLVJPEG(sp, jpeg_abort(&sp->cinfo.comm)); -} - -static int -TIFFjpeg_destroy(JPEGState* sp) -{ - return CALLVJPEG(sp, jpeg_destroy(&sp->cinfo.comm)); -} - -static JSAMPARRAY -TIFFjpeg_alloc_sarray(JPEGState* sp, int pool_id, - JDIMENSION samplesperrow, JDIMENSION numrows) -{ - return CALLJPEG(sp, (JSAMPARRAY) NULL, - (*sp->cinfo.comm.mem->alloc_sarray) - (&sp->cinfo.comm, pool_id, samplesperrow, numrows)); -} - -/* - * JPEG library destination data manager. - * These routines direct compressed data from libjpeg into the - * libtiff output buffer. - */ - -static void -std_init_destination(j_compress_ptr cinfo) -{ - JPEGState* sp = (JPEGState*) cinfo; - TIFF* tif = sp->tif; - - sp->dest.next_output_byte = (JOCTET*) tif->tif_rawdata; - sp->dest.free_in_buffer = (size_t) tif->tif_rawdatasize; -} - -static boolean -std_empty_output_buffer(j_compress_ptr cinfo) -{ - JPEGState* sp = (JPEGState*) cinfo; - TIFF* tif = sp->tif; - - /* the entire buffer has been filled */ - tif->tif_rawcc = tif->tif_rawdatasize; - TIFFFlushData1(tif); - sp->dest.next_output_byte = (JOCTET*) tif->tif_rawdata; - sp->dest.free_in_buffer = (size_t) tif->tif_rawdatasize; - - return (TRUE); -} - -static void -std_term_destination(j_compress_ptr cinfo) -{ - JPEGState* sp = (JPEGState*) cinfo; - TIFF* tif = sp->tif; - - tif->tif_rawcp = (tidata_t) sp->dest.next_output_byte; - tif->tif_rawcc = - tif->tif_rawdatasize - (tsize_t) sp->dest.free_in_buffer; - /* NB: libtiff does the final buffer flush */ -} - -static void -TIFFjpeg_data_dest(JPEGState* sp, TIFF* tif) -{ - (void) tif; - sp->cinfo.c.dest = &sp->dest; - sp->dest.init_destination = std_init_destination; - sp->dest.empty_output_buffer = std_empty_output_buffer; - sp->dest.term_destination = std_term_destination; -} - -/* - * Alternate destination manager for outputting to JPEGTables field. - */ - -static void -tables_init_destination(j_compress_ptr cinfo) -{ - JPEGState* sp = (JPEGState*) cinfo; - - /* while building, jpegtables_length is allocated buffer size */ - sp->dest.next_output_byte = (JOCTET*) sp->jpegtables; - sp->dest.free_in_buffer = (size_t) sp->jpegtables_length; -} - -static boolean -tables_empty_output_buffer(j_compress_ptr cinfo) -{ - JPEGState* sp = (JPEGState*) cinfo; - void* newbuf; - - /* the entire buffer has been filled; enlarge it by 1000 bytes */ - newbuf = _TIFFrealloc((tdata_t) sp->jpegtables, - (tsize_t) (sp->jpegtables_length + 1000)); - if (newbuf == NULL) - ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 100); - sp->dest.next_output_byte = (JOCTET*) newbuf + sp->jpegtables_length; - sp->dest.free_in_buffer = (size_t) 1000; - sp->jpegtables = newbuf; - sp->jpegtables_length += 1000; - return (TRUE); -} - -static void -tables_term_destination(j_compress_ptr cinfo) -{ - JPEGState* sp = (JPEGState*) cinfo; - - /* set tables length to number of bytes actually emitted */ - sp->jpegtables_length -= sp->dest.free_in_buffer; -} - -static int -TIFFjpeg_tables_dest(JPEGState* sp, TIFF* tif) -{ - (void) tif; - /* - * Allocate a working buffer for building tables. - * Initial size is 1000 bytes, which is usually adequate. - */ - if (sp->jpegtables) - _TIFFfree(sp->jpegtables); - sp->jpegtables_length = 1000; - sp->jpegtables = (void*) _TIFFmalloc((tsize_t) sp->jpegtables_length); - if (sp->jpegtables == NULL) { - sp->jpegtables_length = 0; - TIFFErrorExt(sp->tif->tif_clientdata, "TIFFjpeg_tables_dest", "No space for JPEGTables"); - return (0); - } - sp->cinfo.c.dest = &sp->dest; - sp->dest.init_destination = tables_init_destination; - sp->dest.empty_output_buffer = tables_empty_output_buffer; - sp->dest.term_destination = tables_term_destination; - return (1); -} - -/* - * JPEG library source data manager. - * These routines supply compressed data to libjpeg. - */ - -static void -std_init_source(j_decompress_ptr cinfo) -{ - JPEGState* sp = (JPEGState*) cinfo; - TIFF* tif = sp->tif; - - sp->src.next_input_byte = (const JOCTET*) tif->tif_rawdata; - sp->src.bytes_in_buffer = (size_t) tif->tif_rawcc; -} - -static boolean -std_fill_input_buffer(j_decompress_ptr cinfo) -{ - JPEGState* sp = (JPEGState* ) cinfo; - static const JOCTET dummy_EOI[2] = { 0xFF, JPEG_EOI }; - - /* - * Should never get here since entire strip/tile is - * read into memory before the decompressor is called, - * and thus was supplied by init_source. - */ - WARNMS(cinfo, JWRN_JPEG_EOF); - /* insert a fake EOI marker */ - sp->src.next_input_byte = dummy_EOI; - sp->src.bytes_in_buffer = 2; - return (TRUE); -} - -static void -std_skip_input_data(j_decompress_ptr cinfo, long num_bytes) -{ - JPEGState* sp = (JPEGState*) cinfo; - - if (num_bytes > 0) { - if (num_bytes > (long) sp->src.bytes_in_buffer) { - /* oops, buffer overrun */ - (void) std_fill_input_buffer(cinfo); - } else { - sp->src.next_input_byte += (size_t) num_bytes; - sp->src.bytes_in_buffer -= (size_t) num_bytes; - } - } -} - -static void -std_term_source(j_decompress_ptr cinfo) -{ - /* No work necessary here */ - /* Or must we update tif->tif_rawcp, tif->tif_rawcc ??? */ - /* (if so, need empty tables_term_source!) */ - (void) cinfo; -} - -static void -TIFFjpeg_data_src(JPEGState* sp, TIFF* tif) -{ - (void) tif; - sp->cinfo.d.src = &sp->src; - sp->src.init_source = std_init_source; - sp->src.fill_input_buffer = std_fill_input_buffer; - sp->src.skip_input_data = std_skip_input_data; - sp->src.resync_to_restart = jpeg_resync_to_restart; - sp->src.term_source = std_term_source; - sp->src.bytes_in_buffer = 0; /* for safety */ - sp->src.next_input_byte = NULL; -} - -/* - * Alternate source manager for reading from JPEGTables. - * We can share all the code except for the init routine. - */ - -static void -tables_init_source(j_decompress_ptr cinfo) -{ - JPEGState* sp = (JPEGState*) cinfo; - - sp->src.next_input_byte = (const JOCTET*) sp->jpegtables; - sp->src.bytes_in_buffer = (size_t) sp->jpegtables_length; -} - -static void -TIFFjpeg_tables_src(JPEGState* sp, TIFF* tif) -{ - TIFFjpeg_data_src(sp, tif); - sp->src.init_source = tables_init_source; -} - -/* - * Allocate downsampled-data buffers needed for downsampled I/O. - * We use values computed in jpeg_start_compress or jpeg_start_decompress. - * We use libjpeg's allocator so that buffers will be released automatically - * when done with strip/tile. - * This is also a handy place to compute samplesperclump, bytesperline. - */ -static int -alloc_downsampled_buffers(TIFF* tif, jpeg_component_info* comp_info, - int num_components) -{ - JPEGState* sp = JState(tif); - int ci; - jpeg_component_info* compptr; - JSAMPARRAY buf; - int samples_per_clump = 0; - - for (ci = 0, compptr = comp_info; ci < num_components; - ci++, compptr++) { - samples_per_clump += compptr->h_samp_factor * - compptr->v_samp_factor; - buf = TIFFjpeg_alloc_sarray(sp, JPOOL_IMAGE, - compptr->width_in_blocks * DCTSIZE, - (JDIMENSION) (compptr->v_samp_factor*DCTSIZE)); - if (buf == NULL) - return (0); - sp->ds_buffer[ci] = buf; - } - sp->samplesperclump = samples_per_clump; - return (1); -} - - -/* - * JPEG Decoding. - */ - -static int -JPEGSetupDecode(TIFF* tif) -{ - JPEGState* sp = JState(tif); - TIFFDirectory *td = &tif->tif_dir; - - JPEGInitializeLibJPEG( tif, 0, 1 ); - - assert(sp != NULL); - assert(sp->cinfo.comm.is_decompressor); - - /* Read JPEGTables if it is present */ - if (TIFFFieldSet(tif,FIELD_JPEGTABLES)) { - TIFFjpeg_tables_src(sp, tif); - if(TIFFjpeg_read_header(sp,FALSE) != JPEG_HEADER_TABLES_ONLY) { - TIFFErrorExt(tif->tif_clientdata, "JPEGSetupDecode", "Bogus JPEGTables field"); - return (0); - } - } - - /* Grab parameters that are same for all strips/tiles */ - sp->photometric = td->td_photometric; - switch (sp->photometric) { - case PHOTOMETRIC_YCBCR: - sp->h_sampling = td->td_ycbcrsubsampling[0]; - sp->v_sampling = td->td_ycbcrsubsampling[1]; - break; - default: - /* TIFF 6.0 forbids subsampling of all other color spaces */ - sp->h_sampling = 1; - sp->v_sampling = 1; - break; - } - - /* Set up for reading normal data */ - TIFFjpeg_data_src(sp, tif); - tif->tif_postdecode = _TIFFNoPostDecode; /* override byte swapping */ - return (1); -} - -/* - * Set up for decoding a strip or tile. - */ -static int -JPEGPreDecode(TIFF* tif, tsample_t s) -{ - JPEGState *sp = JState(tif); - TIFFDirectory *td = &tif->tif_dir; - static const char module[] = "JPEGPreDecode"; - uint32 segment_width, segment_height; - int downsampled_output; - int ci; - - assert(sp != NULL); - assert(sp->cinfo.comm.is_decompressor); - /* - * Reset decoder state from any previous strip/tile, - * in case application didn't read the whole strip. - */ - if (!TIFFjpeg_abort(sp)) - return (0); - /* - * Read the header for this strip/tile. - */ - if (TIFFjpeg_read_header(sp, TRUE) != JPEG_HEADER_OK) - return (0); - /* - * Check image parameters and set decompression parameters. - */ - segment_width = td->td_imagewidth; - segment_height = td->td_imagelength - tif->tif_row; - if (isTiled(tif)) { - segment_width = td->td_tilewidth; - segment_height = td->td_tilelength; - sp->bytesperline = TIFFTileRowSize(tif); - } else { - if (segment_height > td->td_rowsperstrip) - segment_height = td->td_rowsperstrip; - sp->bytesperline = TIFFOldScanlineSize(tif); - } - if (td->td_planarconfig == PLANARCONFIG_SEPARATE && s > 0) { - /* - * For PC 2, scale down the expected strip/tile size - * to match a downsampled component - */ - segment_width = TIFFhowmany(segment_width, sp->h_sampling); - segment_height = TIFFhowmany(segment_height, sp->v_sampling); - } - if (sp->cinfo.d.image_width < segment_width || - sp->cinfo.d.image_height < segment_height) { - TIFFWarningExt(tif->tif_clientdata, module, - "Improper JPEG strip/tile size, " - "expected %dx%d, got %dx%d", - segment_width, segment_height, - sp->cinfo.d.image_width, - sp->cinfo.d.image_height); - } - if (sp->cinfo.d.image_width > segment_width || - sp->cinfo.d.image_height > segment_height) { - /* - * This case could be dangerous, if the strip or tile size has - * been reported as less than the amount of data jpeg will - * return, some potential security issues arise. Catch this - * case and error out. - */ - TIFFErrorExt(tif->tif_clientdata, module, - "JPEG strip/tile size exceeds expected dimensions," - " expected %dx%d, got %dx%d", - segment_width, segment_height, - sp->cinfo.d.image_width, sp->cinfo.d.image_height); - return (0); - } - if (sp->cinfo.d.num_components != - (td->td_planarconfig == PLANARCONFIG_CONTIG ? - td->td_samplesperpixel : 1)) { - TIFFErrorExt(tif->tif_clientdata, module, "Improper JPEG component count"); - return (0); - } -#ifdef JPEG_LIB_MK1 - if (12 != td->td_bitspersample && 8 != td->td_bitspersample) { - TIFFErrorExt(tif->tif_clientdata, module, "Improper JPEG data precision"); - return (0); - } - sp->cinfo.d.data_precision = td->td_bitspersample; - sp->cinfo.d.bits_in_jsample = td->td_bitspersample; -#else - if (sp->cinfo.d.data_precision != td->td_bitspersample) { - TIFFErrorExt(tif->tif_clientdata, module, "Improper JPEG data precision"); - return (0); - } -#endif - if (td->td_planarconfig == PLANARCONFIG_CONTIG) { - /* Component 0 should have expected sampling factors */ - if (sp->cinfo.d.comp_info[0].h_samp_factor != sp->h_sampling || - sp->cinfo.d.comp_info[0].v_samp_factor != sp->v_sampling) { - TIFFWarningExt(tif->tif_clientdata, module, - "Improper JPEG sampling factors %d,%d\n" - "Apparently should be %d,%d.", - sp->cinfo.d.comp_info[0].h_samp_factor, - sp->cinfo.d.comp_info[0].v_samp_factor, - sp->h_sampling, sp->v_sampling); - - /* - * There are potential security issues here - * for decoders that have already allocated - * buffers based on the expected sampling - * factors. Lets check the sampling factors - * dont exceed what we were expecting. - */ - if (sp->cinfo.d.comp_info[0].h_samp_factor - > sp->h_sampling - || sp->cinfo.d.comp_info[0].v_samp_factor - > sp->v_sampling) { - TIFFErrorExt(tif->tif_clientdata, - module, - "Cannot honour JPEG sampling factors" - " that exceed those specified."); - return (0); - } - - /* - * XXX: Files written by the Intergraph software - * has different sampling factors stored in the - * TIFF tags and in the JPEG structures. We will - * try to deduce Intergraph files by the presense - * of the tag 33918. - */ - if (!_TIFFFindFieldInfo(tif, 33918, TIFF_ANY)) { - TIFFWarningExt(tif->tif_clientdata, module, - "Decompressor will try reading with " - "sampling %d,%d.", - sp->cinfo.d.comp_info[0].h_samp_factor, - sp->cinfo.d.comp_info[0].v_samp_factor); - - sp->h_sampling = (uint16) - sp->cinfo.d.comp_info[0].h_samp_factor; - sp->v_sampling = (uint16) - sp->cinfo.d.comp_info[0].v_samp_factor; - } - } - /* Rest should have sampling factors 1,1 */ - for (ci = 1; ci < sp->cinfo.d.num_components; ci++) { - if (sp->cinfo.d.comp_info[ci].h_samp_factor != 1 || - sp->cinfo.d.comp_info[ci].v_samp_factor != 1) { - TIFFErrorExt(tif->tif_clientdata, module, "Improper JPEG sampling factors"); - return (0); - } - } - } else { - /* PC 2's single component should have sampling factors 1,1 */ - if (sp->cinfo.d.comp_info[0].h_samp_factor != 1 || - sp->cinfo.d.comp_info[0].v_samp_factor != 1) { - TIFFErrorExt(tif->tif_clientdata, module, "Improper JPEG sampling factors"); - return (0); - } - } - downsampled_output = FALSE; - if (td->td_planarconfig == PLANARCONFIG_CONTIG && - sp->photometric == PHOTOMETRIC_YCBCR && - sp->jpegcolormode == JPEGCOLORMODE_RGB) { - /* Convert YCbCr to RGB */ - sp->cinfo.d.jpeg_color_space = JCS_YCbCr; - sp->cinfo.d.out_color_space = JCS_RGB; - } else { - /* Suppress colorspace handling */ - sp->cinfo.d.jpeg_color_space = JCS_UNKNOWN; - sp->cinfo.d.out_color_space = JCS_UNKNOWN; - if (td->td_planarconfig == PLANARCONFIG_CONTIG && - (sp->h_sampling != 1 || sp->v_sampling != 1)) - downsampled_output = TRUE; - /* XXX what about up-sampling? */ - } - if (downsampled_output) { - /* Need to use raw-data interface to libjpeg */ - sp->cinfo.d.raw_data_out = TRUE; - tif->tif_decoderow = JPEGDecodeRaw; - tif->tif_decodestrip = JPEGDecodeRaw; - tif->tif_decodetile = JPEGDecodeRaw; - } else { - /* Use normal interface to libjpeg */ - sp->cinfo.d.raw_data_out = FALSE; - tif->tif_decoderow = JPEGDecode; - tif->tif_decodestrip = JPEGDecode; - tif->tif_decodetile = JPEGDecode; - } - /* Start JPEG decompressor */ - if (!TIFFjpeg_start_decompress(sp)) - return (0); - /* Allocate downsampled-data buffers if needed */ - if (downsampled_output) { - if (!alloc_downsampled_buffers(tif, sp->cinfo.d.comp_info, - sp->cinfo.d.num_components)) - return (0); - sp->scancount = DCTSIZE; /* mark buffer empty */ - } - return (1); -} - -/* - * Decode a chunk of pixels. - * "Standard" case: returned data is not downsampled. - */ -/*ARGSUSED*/ static int -JPEGDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) -{ - JPEGState *sp = JState(tif); - tsize_t nrows; - (void) s; - - nrows = cc / sp->bytesperline; - if (cc % sp->bytesperline) - TIFFWarningExt(tif->tif_clientdata, tif->tif_name, "fractional scanline not read"); - - if ( nrows > (int) sp->cinfo.d.image_height ) - nrows = sp->cinfo.d.image_height; - - /* data is expected to be read in multiples of a scanline */ - if (nrows) - { - JSAMPROW line_work_buf = NULL; - - /* - ** For 6B, only use temporary buffer for 12 bit imagery. - ** For Mk1 always use it. - */ -#if !defined(JPEG_LIB_MK1) - if ( sp->cinfo.d.data_precision == 12 ) -#endif - { - line_work_buf = (JSAMPROW) - _TIFFmalloc(sizeof(short) * sp->cinfo.d.output_width - * sp->cinfo.d.num_components ); - } - - do { - if ( line_work_buf != NULL ) - { - /* - ** In the MK1 case, we aways read into a 16bit buffer, and then - ** pack down to 12bit or 8bit. In 6B case we only read into 16 - ** bit buffer for 12bit data, which we need to repack. - */ - if (TIFFjpeg_read_scanlines(sp, &line_work_buf, 1) != 1) - return (0); - - if ( sp->cinfo.d.data_precision == 12 ) - { - int value_pairs = (sp->cinfo.d.output_width - * sp->cinfo.d.num_components) / 2; - int iPair; - - for ( iPair = 0; iPair < value_pairs; iPair++ ) - { - unsigned char *out_ptr = - ((unsigned char *) buf) + iPair * 3; - JSAMPLE *in_ptr = line_work_buf + iPair * 2; - - out_ptr[0] = (in_ptr[0] & 0xff0) >> 4; - out_ptr[1] = ((in_ptr[0] & 0xf) << 4) - | ((in_ptr[1] & 0xf00) >> 8); - out_ptr[2] = ((in_ptr[1] & 0xff) >> 0); - } - } - else if ( sp->cinfo.d.data_precision == 8 ) - { - int value_count = (sp->cinfo.d.output_width - * sp->cinfo.d.num_components); - int iValue; - - for ( iValue = 0; iValue < value_count; iValue++ ) - { - ((unsigned char *) buf)[iValue] = - line_work_buf[iValue] & 0xff; - } - } - } - else - { - /* - ** In the libjpeg6b 8bit case. We read directly into the - ** TIFF buffer. - */ - JSAMPROW bufptr = (JSAMPROW)buf; - - if (TIFFjpeg_read_scanlines(sp, &bufptr, 1) != 1) - return (0); - } - - ++tif->tif_row; - buf += sp->bytesperline; - cc -= sp->bytesperline; - } while (--nrows > 0); - - if ( line_work_buf != NULL ) - _TIFFfree( line_work_buf ); - } - - /* Close down the decompressor if we've finished the strip or tile. */ - return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height - || TIFFjpeg_finish_decompress(sp); -} - -/* - * Decode a chunk of pixels. - * Returned data is downsampled per sampling factors. - */ -/*ARGSUSED*/ static int -JPEGDecodeRaw(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) -{ - JPEGState *sp = JState(tif); - tsize_t nrows; - (void) s; - - nrows = cc / sp->bytesperline; - if (cc % sp->bytesperline) - TIFFWarningExt(tif->tif_clientdata, tif->tif_name, "fractional scanline not read"); - - if ( nrows > (int) sp->cinfo.d.image_height ) - nrows = sp->cinfo.d.image_height; - - /* data is expected to be read in multiples of a scanline */ - if (nrows) { - /* Cb,Cr both have sampling factors 1, so this is correct */ - JDIMENSION clumps_per_line = sp->cinfo.d.comp_info[1].downsampled_width; - int samples_per_clump = sp->samplesperclump; - -#ifdef JPEG_LIB_MK1 - unsigned short* tmpbuf = _TIFFmalloc(sizeof(unsigned short) * - sp->cinfo.d.output_width * - sp->cinfo.d.num_components); -#endif - - do { - jpeg_component_info *compptr; - int ci, clumpoffset; - - /* Reload downsampled-data buffer if needed */ - if (sp->scancount >= DCTSIZE) { - int n = sp->cinfo.d.max_v_samp_factor * DCTSIZE; - if (TIFFjpeg_read_raw_data(sp, sp->ds_buffer, n) != n) - return (0); - sp->scancount = 0; - } - /* - * Fastest way to unseparate data is to make one pass - * over the scanline for each row of each component. - */ - clumpoffset = 0; /* first sample in clump */ - for (ci = 0, compptr = sp->cinfo.d.comp_info; - ci < sp->cinfo.d.num_components; - ci++, compptr++) { - int hsamp = compptr->h_samp_factor; - int vsamp = compptr->v_samp_factor; - int ypos; - - for (ypos = 0; ypos < vsamp; ypos++) { - JSAMPLE *inptr = sp->ds_buffer[ci][sp->scancount*vsamp + ypos]; -#ifdef JPEG_LIB_MK1 - JSAMPLE *outptr = (JSAMPLE*)tmpbuf + clumpoffset; -#else - JSAMPLE *outptr = (JSAMPLE*)buf + clumpoffset; -#endif - JDIMENSION nclump; - - if (hsamp == 1) { - /* fast path for at least Cb and Cr */ - for (nclump = clumps_per_line; nclump-- > 0; ) { - outptr[0] = *inptr++; - outptr += samples_per_clump; - } - } else { - int xpos; - - /* general case */ - for (nclump = clumps_per_line; nclump-- > 0; ) { - for (xpos = 0; xpos < hsamp; xpos++) - outptr[xpos] = *inptr++; - outptr += samples_per_clump; - } - } - clumpoffset += hsamp; - } - } - -#ifdef JPEG_LIB_MK1 - { - if (sp->cinfo.d.data_precision == 8) - { - int i=0; - int len = sp->cinfo.d.output_width * sp->cinfo.d.num_components; - for (i=0; icinfo.d.output_width - * sp->cinfo.d.num_components) / 2; - int iPair; - for ( iPair = 0; iPair < value_pairs; iPair++ ) - { - unsigned char *out_ptr = ((unsigned char *) buf) + iPair * 3; - JSAMPLE *in_ptr = tmpbuf + iPair * 2; - out_ptr[0] = (in_ptr[0] & 0xff0) >> 4; - out_ptr[1] = ((in_ptr[0] & 0xf) << 4) - | ((in_ptr[1] & 0xf00) >> 8); - out_ptr[2] = ((in_ptr[1] & 0xff) >> 0); - } - } - } -#endif - - sp->scancount ++; - tif->tif_row += sp->v_sampling; - /* increment/decrement of buf and cc is still incorrect, but should not matter - * TODO: resolve this */ - buf += sp->bytesperline; - cc -= sp->bytesperline; - } while (--nrows > 0); - -#ifdef JPEG_LIB_MK1 - _TIFFfree(tmpbuf); -#endif - - } - - /* Close down the decompressor if done. */ - return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height - || TIFFjpeg_finish_decompress(sp); -} - - -/* - * JPEG Encoding. - */ - -static void -unsuppress_quant_table (JPEGState* sp, int tblno) -{ - JQUANT_TBL* qtbl; - - if ((qtbl = sp->cinfo.c.quant_tbl_ptrs[tblno]) != NULL) - qtbl->sent_table = FALSE; -} - -static void -unsuppress_huff_table (JPEGState* sp, int tblno) -{ - JHUFF_TBL* htbl; - - if ((htbl = sp->cinfo.c.dc_huff_tbl_ptrs[tblno]) != NULL) - htbl->sent_table = FALSE; - if ((htbl = sp->cinfo.c.ac_huff_tbl_ptrs[tblno]) != NULL) - htbl->sent_table = FALSE; -} - -static int -prepare_JPEGTables(TIFF* tif) -{ - JPEGState* sp = JState(tif); - - JPEGInitializeLibJPEG( tif, 0, 0 ); - - /* Initialize quant tables for current quality setting */ - if (!TIFFjpeg_set_quality(sp, sp->jpegquality, FALSE)) - return (0); - /* Mark only the tables we want for output */ - /* NB: chrominance tables are currently used only with YCbCr */ - if (!TIFFjpeg_suppress_tables(sp, TRUE)) - return (0); - if (sp->jpegtablesmode & JPEGTABLESMODE_QUANT) { - unsuppress_quant_table(sp, 0); - if (sp->photometric == PHOTOMETRIC_YCBCR) - unsuppress_quant_table(sp, 1); - } - if (sp->jpegtablesmode & JPEGTABLESMODE_HUFF) { - unsuppress_huff_table(sp, 0); - if (sp->photometric == PHOTOMETRIC_YCBCR) - unsuppress_huff_table(sp, 1); - } - /* Direct libjpeg output into jpegtables */ - if (!TIFFjpeg_tables_dest(sp, tif)) - return (0); - /* Emit tables-only datastream */ - if (!TIFFjpeg_write_tables(sp)) - return (0); - - return (1); -} - -static int -JPEGSetupEncode(TIFF* tif) -{ - JPEGState* sp = JState(tif); - TIFFDirectory *td = &tif->tif_dir; - static const char module[] = "JPEGSetupEncode"; - - JPEGInitializeLibJPEG( tif, 1, 0 ); - - assert(sp != NULL); - assert(!sp->cinfo.comm.is_decompressor); - - /* - * Initialize all JPEG parameters to default values. - * Note that jpeg_set_defaults needs legal values for - * in_color_space and input_components. - */ - sp->cinfo.c.in_color_space = JCS_UNKNOWN; - sp->cinfo.c.input_components = 1; - if (!TIFFjpeg_set_defaults(sp)) - return (0); - /* Set per-file parameters */ - sp->photometric = td->td_photometric; - switch (sp->photometric) { - case PHOTOMETRIC_YCBCR: - sp->h_sampling = td->td_ycbcrsubsampling[0]; - sp->v_sampling = td->td_ycbcrsubsampling[1]; - /* - * A ReferenceBlackWhite field *must* be present since the - * default value is inappropriate for YCbCr. Fill in the - * proper value if application didn't set it. - */ - { - float *ref; - if (!TIFFGetField(tif, TIFFTAG_REFERENCEBLACKWHITE, - &ref)) { - float refbw[6]; - long top = 1L << td->td_bitspersample; - refbw[0] = 0; - refbw[1] = (float)(top-1L); - refbw[2] = (float)(top>>1); - refbw[3] = refbw[1]; - refbw[4] = refbw[2]; - refbw[5] = refbw[1]; - TIFFSetField(tif, TIFFTAG_REFERENCEBLACKWHITE, - refbw); - } - } - break; - case PHOTOMETRIC_PALETTE: /* disallowed by Tech Note */ - case PHOTOMETRIC_MASK: - TIFFErrorExt(tif->tif_clientdata, module, - "PhotometricInterpretation %d not allowed for JPEG", - (int) sp->photometric); - return (0); - default: - /* TIFF 6.0 forbids subsampling of all other color spaces */ - sp->h_sampling = 1; - sp->v_sampling = 1; - break; - } - - /* Verify miscellaneous parameters */ - - /* - * This would need work if libtiff ever supports different - * depths for different components, or if libjpeg ever supports - * run-time selection of depth. Neither is imminent. - */ -#ifdef JPEG_LIB_MK1 - /* BITS_IN_JSAMPLE now permits 8 and 12 --- dgilbert */ - if (td->td_bitspersample != 8 && td->td_bitspersample != 12) -#else - if (td->td_bitspersample != BITS_IN_JSAMPLE ) -#endif - { - TIFFErrorExt(tif->tif_clientdata, module, "BitsPerSample %d not allowed for JPEG", - (int) td->td_bitspersample); - return (0); - } - sp->cinfo.c.data_precision = td->td_bitspersample; -#ifdef JPEG_LIB_MK1 - sp->cinfo.c.bits_in_jsample = td->td_bitspersample; -#endif - if (isTiled(tif)) { - if ((td->td_tilelength % (sp->v_sampling * DCTSIZE)) != 0) { - TIFFErrorExt(tif->tif_clientdata, module, - "JPEG tile height must be multiple of %d", - sp->v_sampling * DCTSIZE); - return (0); - } - if ((td->td_tilewidth % (sp->h_sampling * DCTSIZE)) != 0) { - TIFFErrorExt(tif->tif_clientdata, module, - "JPEG tile width must be multiple of %d", - sp->h_sampling * DCTSIZE); - return (0); - } - } else { - if (td->td_rowsperstrip < td->td_imagelength && - (td->td_rowsperstrip % (sp->v_sampling * DCTSIZE)) != 0) { - TIFFErrorExt(tif->tif_clientdata, module, - "RowsPerStrip must be multiple of %d for JPEG", - sp->v_sampling * DCTSIZE); - return (0); - } - } - - /* Create a JPEGTables field if appropriate */ - if (sp->jpegtablesmode & (JPEGTABLESMODE_QUANT|JPEGTABLESMODE_HUFF)) { - if ( sp->jpegtables == NULL - || memcmp(sp->jpegtables,"\0\0\0\0\0\0\0\0\0",8) == 0 ) - { - if (!prepare_JPEGTables(tif)) - return (0); - /* Mark the field present */ - /* Can't use TIFFSetField since BEENWRITING is already set! */ - tif->tif_flags |= TIFF_DIRTYDIRECT; - TIFFSetFieldBit(tif, FIELD_JPEGTABLES); - } - } else { - /* We do not support application-supplied JPEGTables, */ - /* so mark the field not present */ - TIFFClrFieldBit(tif, FIELD_JPEGTABLES); - } - - /* Direct libjpeg output to libtiff's output buffer */ - TIFFjpeg_data_dest(sp, tif); - - return (1); -} - -/* - * Set encoding state at the start of a strip or tile. - */ -static int -JPEGPreEncode(TIFF* tif, tsample_t s) -{ - JPEGState *sp = JState(tif); - TIFFDirectory *td = &tif->tif_dir; - static const char module[] = "JPEGPreEncode"; - uint32 segment_width, segment_height; - int downsampled_input; - - assert(sp != NULL); - assert(!sp->cinfo.comm.is_decompressor); - /* - * Set encoding parameters for this strip/tile. - */ - if (isTiled(tif)) { - segment_width = td->td_tilewidth; - segment_height = td->td_tilelength; - sp->bytesperline = TIFFTileRowSize(tif); - } else { - segment_width = td->td_imagewidth; - segment_height = td->td_imagelength - tif->tif_row; - if (segment_height > td->td_rowsperstrip) - segment_height = td->td_rowsperstrip; - sp->bytesperline = TIFFOldScanlineSize(tif); - } - if (td->td_planarconfig == PLANARCONFIG_SEPARATE && s > 0) { - /* for PC 2, scale down the strip/tile size - * to match a downsampled component - */ - segment_width = TIFFhowmany(segment_width, sp->h_sampling); - segment_height = TIFFhowmany(segment_height, sp->v_sampling); - } - if (segment_width > 65535 || segment_height > 65535) { - TIFFErrorExt(tif->tif_clientdata, module, "Strip/tile too large for JPEG"); - return (0); - } - sp->cinfo.c.image_width = segment_width; - sp->cinfo.c.image_height = segment_height; - downsampled_input = FALSE; - if (td->td_planarconfig == PLANARCONFIG_CONTIG) { - sp->cinfo.c.input_components = td->td_samplesperpixel; - if (sp->photometric == PHOTOMETRIC_YCBCR) { - if (sp->jpegcolormode == JPEGCOLORMODE_RGB) { - sp->cinfo.c.in_color_space = JCS_RGB; - } else { - sp->cinfo.c.in_color_space = JCS_YCbCr; - if (sp->h_sampling != 1 || sp->v_sampling != 1) - downsampled_input = TRUE; - } - if (!TIFFjpeg_set_colorspace(sp, JCS_YCbCr)) - return (0); - /* - * Set Y sampling factors; - * we assume jpeg_set_colorspace() set the rest to 1 - */ - sp->cinfo.c.comp_info[0].h_samp_factor = sp->h_sampling; - sp->cinfo.c.comp_info[0].v_samp_factor = sp->v_sampling; - } else { - if ((td->td_photometric == PHOTOMETRIC_MINISWHITE || td->td_photometric == PHOTOMETRIC_MINISBLACK) && td->td_samplesperpixel == 1) - sp->cinfo.c.in_color_space = JCS_GRAYSCALE; - else if (td->td_photometric == PHOTOMETRIC_RGB) - sp->cinfo.c.in_color_space = JCS_RGB; - else if (td->td_photometric == PHOTOMETRIC_SEPARATED && td->td_samplesperpixel == 4) - sp->cinfo.c.in_color_space = JCS_CMYK; - else - sp->cinfo.c.in_color_space = JCS_UNKNOWN; - if (!TIFFjpeg_set_colorspace(sp, sp->cinfo.c.in_color_space)) - return (0); - /* jpeg_set_colorspace set all sampling factors to 1 */ - } - } else { - sp->cinfo.c.input_components = 1; - sp->cinfo.c.in_color_space = JCS_UNKNOWN; - if (!TIFFjpeg_set_colorspace(sp, JCS_UNKNOWN)) - return (0); - sp->cinfo.c.comp_info[0].component_id = s; - /* jpeg_set_colorspace() set sampling factors to 1 */ - if (sp->photometric == PHOTOMETRIC_YCBCR && s > 0) { - sp->cinfo.c.comp_info[0].quant_tbl_no = 1; - sp->cinfo.c.comp_info[0].dc_tbl_no = 1; - sp->cinfo.c.comp_info[0].ac_tbl_no = 1; - } - } - /* ensure libjpeg won't write any extraneous markers */ - sp->cinfo.c.write_JFIF_header = FALSE; - sp->cinfo.c.write_Adobe_marker = FALSE; - /* set up table handling correctly */ - if (!TIFFjpeg_set_quality(sp, sp->jpegquality, FALSE)) - return (0); - if (! (sp->jpegtablesmode & JPEGTABLESMODE_QUANT)) { - unsuppress_quant_table(sp, 0); - unsuppress_quant_table(sp, 1); - } - if (sp->jpegtablesmode & JPEGTABLESMODE_HUFF) - sp->cinfo.c.optimize_coding = FALSE; - else - sp->cinfo.c.optimize_coding = TRUE; - if (downsampled_input) { - /* Need to use raw-data interface to libjpeg */ - sp->cinfo.c.raw_data_in = TRUE; - tif->tif_encoderow = JPEGEncodeRaw; - tif->tif_encodestrip = JPEGEncodeRaw; - tif->tif_encodetile = JPEGEncodeRaw; - } else { - /* Use normal interface to libjpeg */ - sp->cinfo.c.raw_data_in = FALSE; - tif->tif_encoderow = JPEGEncode; - tif->tif_encodestrip = JPEGEncode; - tif->tif_encodetile = JPEGEncode; - } - /* Start JPEG compressor */ - if (!TIFFjpeg_start_compress(sp, FALSE)) - return (0); - /* Allocate downsampled-data buffers if needed */ - if (downsampled_input) { - if (!alloc_downsampled_buffers(tif, sp->cinfo.c.comp_info, - sp->cinfo.c.num_components)) - return (0); - } - sp->scancount = 0; - - return (1); -} - -/* - * Encode a chunk of pixels. - * "Standard" case: incoming data is not downsampled. - */ -static int -JPEGEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) -{ - JPEGState *sp = JState(tif); - tsize_t nrows; - JSAMPROW bufptr[1]; - - (void) s; - assert(sp != NULL); - /* data is expected to be supplied in multiples of a scanline */ - nrows = cc / sp->bytesperline; - if (cc % sp->bytesperline) - TIFFWarningExt(tif->tif_clientdata, tif->tif_name, "fractional scanline discarded"); - - /* The last strip will be limited to image size */ - if ( !isTiled(tif) && tif->tif_row+nrows > tif->tif_dir.td_imagelength ) - nrows = tif->tif_dir.td_imagelength - tif->tif_row; - - while (nrows-- > 0) { - bufptr[0] = (JSAMPROW) buf; - if (TIFFjpeg_write_scanlines(sp, bufptr, 1) != 1) - return (0); - if (nrows > 0) - tif->tif_row++; - buf += sp->bytesperline; - } - return (1); -} - -/* - * Encode a chunk of pixels. - * Incoming data is expected to be downsampled per sampling factors. - */ -static int -JPEGEncodeRaw(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) -{ - JPEGState *sp = JState(tif); - JSAMPLE* inptr; - JSAMPLE* outptr; - tsize_t nrows; - JDIMENSION clumps_per_line, nclump; - int clumpoffset, ci, xpos, ypos; - jpeg_component_info* compptr; - int samples_per_clump = sp->samplesperclump; - tsize_t bytesperclumpline; - - (void) s; - assert(sp != NULL); - /* data is expected to be supplied in multiples of a clumpline */ - /* a clumpline is equivalent to v_sampling desubsampled scanlines */ - /* TODO: the following calculation of bytesperclumpline, should substitute calculation of sp->bytesperline, except that it is per v_sampling lines */ - bytesperclumpline = (((sp->cinfo.c.image_width+sp->h_sampling-1)/sp->h_sampling) - *(sp->h_sampling*sp->v_sampling+2)*sp->cinfo.c.data_precision+7) - /8; - - nrows = ( cc / bytesperclumpline ) * sp->v_sampling; - if (cc % bytesperclumpline) - TIFFWarningExt(tif->tif_clientdata, tif->tif_name, "fractional scanline discarded"); - - /* Cb,Cr both have sampling factors 1, so this is correct */ - clumps_per_line = sp->cinfo.c.comp_info[1].downsampled_width; - - while (nrows > 0) { - /* - * Fastest way to separate the data is to make one pass - * over the scanline for each row of each component. - */ - clumpoffset = 0; /* first sample in clump */ - for (ci = 0, compptr = sp->cinfo.c.comp_info; - ci < sp->cinfo.c.num_components; - ci++, compptr++) { - int hsamp = compptr->h_samp_factor; - int vsamp = compptr->v_samp_factor; - int padding = (int) (compptr->width_in_blocks * DCTSIZE - - clumps_per_line * hsamp); - for (ypos = 0; ypos < vsamp; ypos++) { - inptr = ((JSAMPLE*) buf) + clumpoffset; - outptr = sp->ds_buffer[ci][sp->scancount*vsamp + ypos]; - if (hsamp == 1) { - /* fast path for at least Cb and Cr */ - for (nclump = clumps_per_line; nclump-- > 0; ) { - *outptr++ = inptr[0]; - inptr += samples_per_clump; - } - } else { - /* general case */ - for (nclump = clumps_per_line; nclump-- > 0; ) { - for (xpos = 0; xpos < hsamp; xpos++) - *outptr++ = inptr[xpos]; - inptr += samples_per_clump; - } - } - /* pad each scanline as needed */ - for (xpos = 0; xpos < padding; xpos++) { - *outptr = outptr[-1]; - outptr++; - } - clumpoffset += hsamp; - } - } - sp->scancount++; - if (sp->scancount >= DCTSIZE) { - int n = sp->cinfo.c.max_v_samp_factor * DCTSIZE; - if (TIFFjpeg_write_raw_data(sp, sp->ds_buffer, n) != n) - return (0); - sp->scancount = 0; - } - tif->tif_row += sp->v_sampling; - buf += bytesperclumpline; - nrows -= sp->v_sampling; - } - return (1); -} - -/* - * Finish up at the end of a strip or tile. - */ -static int -JPEGPostEncode(TIFF* tif) -{ - JPEGState *sp = JState(tif); - - if (sp->scancount > 0) { - /* - * Need to emit a partial bufferload of downsampled data. - * Pad the data vertically. - */ - int ci, ypos, n; - jpeg_component_info* compptr; - - for (ci = 0, compptr = sp->cinfo.c.comp_info; - ci < sp->cinfo.c.num_components; - ci++, compptr++) { - int vsamp = compptr->v_samp_factor; - tsize_t row_width = compptr->width_in_blocks * DCTSIZE - * sizeof(JSAMPLE); - for (ypos = sp->scancount * vsamp; - ypos < DCTSIZE * vsamp; ypos++) { - _TIFFmemcpy((tdata_t)sp->ds_buffer[ci][ypos], - (tdata_t)sp->ds_buffer[ci][ypos-1], - row_width); - - } - } - n = sp->cinfo.c.max_v_samp_factor * DCTSIZE; - if (TIFFjpeg_write_raw_data(sp, sp->ds_buffer, n) != n) - return (0); - } - - return (TIFFjpeg_finish_compress(JState(tif))); -} - -static void -JPEGCleanup(TIFF* tif) -{ - JPEGState *sp = JState(tif); - - assert(sp != 0); - - tif->tif_tagmethods.vgetfield = sp->vgetparent; - tif->tif_tagmethods.vsetfield = sp->vsetparent; - tif->tif_tagmethods.printdir = sp->printdir; - - if ( sp->cinfo_initialized ) - TIFFjpeg_destroy(sp); /* release libjpeg resources */ - if (sp->jpegtables) /* tag value */ - _TIFFfree(sp->jpegtables); - _TIFFfree(tif->tif_data); /* release local state */ - tif->tif_data = NULL; - - _TIFFSetDefaultCompressionState(tif); -} - -static void -JPEGResetUpsampled( TIFF* tif ) -{ - JPEGState* sp = JState(tif); - TIFFDirectory* td = &tif->tif_dir; - - /* - * Mark whether returned data is up-sampled or not so TIFFStripSize - * and TIFFTileSize return values that reflect the true amount of - * data. - */ - tif->tif_flags &= ~TIFF_UPSAMPLED; - if (td->td_planarconfig == PLANARCONFIG_CONTIG) { - if (td->td_photometric == PHOTOMETRIC_YCBCR && - sp->jpegcolormode == JPEGCOLORMODE_RGB) { - tif->tif_flags |= TIFF_UPSAMPLED; - } else { -#ifdef notdef - if (td->td_ycbcrsubsampling[0] != 1 || - td->td_ycbcrsubsampling[1] != 1) - ; /* XXX what about up-sampling? */ -#endif - } - } - - /* - * Must recalculate cached tile size in case sampling state changed. - * Should we really be doing this now if image size isn't set? - */ - if ( tif->tif_tilesize > 0 ) - tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tsize_t) -1; - - if(tif->tif_scanlinesize > 0 ) - tif->tif_scanlinesize = TIFFScanlineSize(tif); -} - -static int -JPEGVSetField(TIFF* tif, ttag_t tag, va_list ap) -{ - JPEGState* sp = JState(tif); - const TIFFFieldInfo* fip; - uint32 v32; - - assert(sp != NULL); - - switch (tag) { - case TIFFTAG_JPEGTABLES: - v32 = va_arg(ap, uint32); - if (v32 == 0) { - /* XXX */ - return (0); - } - _TIFFsetByteArray(&sp->jpegtables, va_arg(ap, void*), - (long) v32); - sp->jpegtables_length = v32; - TIFFSetFieldBit(tif, FIELD_JPEGTABLES); - break; - case TIFFTAG_JPEGQUALITY: - sp->jpegquality = va_arg(ap, int); - return (1); /* pseudo tag */ - case TIFFTAG_JPEGCOLORMODE: - sp->jpegcolormode = va_arg(ap, int); - JPEGResetUpsampled( tif ); - return (1); /* pseudo tag */ - case TIFFTAG_PHOTOMETRIC: - { - int ret_value = (*sp->vsetparent)(tif, tag, ap); - JPEGResetUpsampled( tif ); - return ret_value; - } - case TIFFTAG_JPEGTABLESMODE: - sp->jpegtablesmode = va_arg(ap, int); - return (1); /* pseudo tag */ - case TIFFTAG_YCBCRSUBSAMPLING: - /* mark the fact that we have a real ycbcrsubsampling! */ - sp->ycbcrsampling_fetched = 1; - /* should we be recomputing upsampling info here? */ - return (*sp->vsetparent)(tif, tag, ap); - case TIFFTAG_FAXRECVPARAMS: - sp->recvparams = va_arg(ap, uint32); - break; - case TIFFTAG_FAXSUBADDRESS: - _TIFFsetString(&sp->subaddress, va_arg(ap, char*)); - break; - case TIFFTAG_FAXRECVTIME: - sp->recvtime = va_arg(ap, uint32); - break; - case TIFFTAG_FAXDCS: - _TIFFsetString(&sp->faxdcs, va_arg(ap, char*)); - break; - default: - return (*sp->vsetparent)(tif, tag, ap); - } - - if ((fip = _TIFFFieldWithTag(tif, tag))) { - TIFFSetFieldBit(tif, fip->field_bit); - } else { - return (0); - } - - tif->tif_flags |= TIFF_DIRTYDIRECT; - return (1); -} - -/* - * Some JPEG-in-TIFF produces do not emit the YCBCRSUBSAMPLING values in - * the TIFF tags, but still use non-default (2,2) values within the jpeg - * data stream itself. In order for TIFF applications to work properly - * - for instance to get the strip buffer size right - it is imperative - * that the subsampling be available before we start reading the image - * data normally. This function will attempt to load the first strip in - * order to get the sampling values from the jpeg data stream. Various - * hacks are various places are done to ensure this function gets called - * before the td_ycbcrsubsampling values are used from the directory structure, - * including calling TIFFGetField() for the YCBCRSUBSAMPLING field from - * TIFFStripSize(), and the printing code in tif_print.c. - * - * Note that JPEGPreDeocode() will produce a fairly loud warning when the - * discovered sampling does not match the default sampling (2,2) or whatever - * was actually in the tiff tags. - * - * Problems: - * o This code will cause one whole strip/tile of compressed data to be - * loaded just to get the tags right, even if the imagery is never read. - * It would be more efficient to just load a bit of the header, and - * initialize things from that. - * - * See the bug in bugzilla for details: - * - * http://bugzilla.remotesensing.org/show_bug.cgi?id=168 - * - * Frank Warmerdam, July 2002 - */ - -static void -JPEGFixupTestSubsampling( TIFF * tif ) -{ -#ifdef CHECK_JPEG_YCBCR_SUBSAMPLING - JPEGState *sp = JState(tif); - TIFFDirectory *td = &tif->tif_dir; - - JPEGInitializeLibJPEG( tif, 0, 0 ); - - /* - * Some JPEG-in-TIFF files don't provide the ycbcrsampling tags, - * and use a sampling schema other than the default 2,2. To handle - * this we actually have to scan the header of a strip or tile of - * jpeg data to get the sampling. - */ - if ( !sp->cinfo.comm.is_decompressor - || sp->ycbcrsampling_fetched - || td->td_photometric != PHOTOMETRIC_YCBCR ) - return; - - sp->ycbcrsampling_fetched = 1; - if ( TIFFIsTiled( tif ) ) - { - if ( !TIFFFillTile( tif, 0 ) ) - return; - } - else - { - if ( !TIFFFillStrip( tif, 0 ) ) - return; - } - - TIFFSetField( tif, TIFFTAG_YCBCRSUBSAMPLING, - (uint16) sp->h_sampling, (uint16) sp->v_sampling ); - - /* - ** We want to clear the loaded strip so the application has time - ** to set JPEGCOLORMODE or other behavior modifiers. This essentially - ** undoes the JPEGPreDecode triggers by TIFFFileStrip(). (#1936) - */ - tif->tif_curstrip = -1; - -#endif /* CHECK_JPEG_YCBCR_SUBSAMPLING */ -} - -static int -JPEGVGetField(TIFF* tif, ttag_t tag, va_list ap) -{ - JPEGState* sp = JState(tif); - - assert(sp != NULL); - - switch (tag) { - case TIFFTAG_JPEGTABLES: - *va_arg(ap, uint32*) = sp->jpegtables_length; - *va_arg(ap, void**) = sp->jpegtables; - break; - case TIFFTAG_JPEGQUALITY: - *va_arg(ap, int*) = sp->jpegquality; - break; - case TIFFTAG_JPEGCOLORMODE: - *va_arg(ap, int*) = sp->jpegcolormode; - break; - case TIFFTAG_JPEGTABLESMODE: - *va_arg(ap, int*) = sp->jpegtablesmode; - break; - case TIFFTAG_YCBCRSUBSAMPLING: - JPEGFixupTestSubsampling( tif ); - return (*sp->vgetparent)(tif, tag, ap); - case TIFFTAG_FAXRECVPARAMS: - *va_arg(ap, uint32*) = sp->recvparams; - break; - case TIFFTAG_FAXSUBADDRESS: - *va_arg(ap, char**) = sp->subaddress; - break; - case TIFFTAG_FAXRECVTIME: - *va_arg(ap, uint32*) = sp->recvtime; - break; - case TIFFTAG_FAXDCS: - *va_arg(ap, char**) = sp->faxdcs; - break; - default: - return (*sp->vgetparent)(tif, tag, ap); - } - return (1); -} - -static void -JPEGPrintDir(TIFF* tif, FILE* fd, long flags) -{ - JPEGState* sp = JState(tif); - - assert(sp != NULL); - - (void) flags; - if (TIFFFieldSet(tif,FIELD_JPEGTABLES)) - fprintf(fd, " JPEG Tables: (%lu bytes)\n", - (unsigned long) sp->jpegtables_length); - if (TIFFFieldSet(tif,FIELD_RECVPARAMS)) - fprintf(fd, " Fax Receive Parameters: %08lx\n", - (unsigned long) sp->recvparams); - if (TIFFFieldSet(tif,FIELD_SUBADDRESS)) - fprintf(fd, " Fax SubAddress: %s\n", sp->subaddress); - if (TIFFFieldSet(tif,FIELD_RECVTIME)) - fprintf(fd, " Fax Receive Time: %lu secs\n", - (unsigned long) sp->recvtime); - if (TIFFFieldSet(tif,FIELD_FAXDCS)) - fprintf(fd, " Fax DCS: %s\n", sp->faxdcs); -} - -static uint32 -JPEGDefaultStripSize(TIFF* tif, uint32 s) -{ - JPEGState* sp = JState(tif); - TIFFDirectory *td = &tif->tif_dir; - - s = (*sp->defsparent)(tif, s); - if (s < td->td_imagelength) - s = TIFFroundup(s, td->td_ycbcrsubsampling[1] * DCTSIZE); - return (s); -} - -static void -JPEGDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) -{ - JPEGState* sp = JState(tif); - TIFFDirectory *td = &tif->tif_dir; - - (*sp->deftparent)(tif, tw, th); - *tw = TIFFroundup(*tw, td->td_ycbcrsubsampling[0] * DCTSIZE); - *th = TIFFroundup(*th, td->td_ycbcrsubsampling[1] * DCTSIZE); -} - -/* - * The JPEG library initialized used to be done in TIFFInitJPEG(), but - * now that we allow a TIFF file to be opened in update mode it is necessary - * to have some way of deciding whether compression or decompression is - * desired other than looking at tif->tif_mode. We accomplish this by - * examining {TILE/STRIP}BYTECOUNTS to see if there is a non-zero entry. - * If so, we assume decompression is desired. - * - * This is tricky, because TIFFInitJPEG() is called while the directory is - * being read, and generally speaking the BYTECOUNTS tag won't have been read - * at that point. So we try to defer jpeg library initialization till we - * do have that tag ... basically any access that might require the compressor - * or decompressor that occurs after the reading of the directory. - * - * In an ideal world compressors or decompressors would be setup - * at the point where a single tile or strip was accessed (for read or write) - * so that stuff like update of missing tiles, or replacement of tiles could - * be done. However, we aren't trying to crack that nut just yet ... - * - * NFW, Feb 3rd, 2003. - */ - -static int JPEGInitializeLibJPEG( TIFF * tif, int force_encode, int force_decode ) -{ - JPEGState* sp = JState(tif); - uint32 *byte_counts = NULL; - int data_is_empty = TRUE; - int decompress; - - - if(sp->cinfo_initialized) - { - if ( force_encode && sp->cinfo.comm.is_decompressor ) - TIFFjpeg_destroy( sp ); - else if ( force_decode && !sp->cinfo.comm.is_decompressor ) - TIFFjpeg_destroy( sp ); - else - return 1; - - sp->cinfo_initialized = 0; - } - - /* - * Do we have tile data already? Make sure we initialize the - * the state in decompressor mode if we have tile data, even if we - * are not in read-only file access mode. - */ - if ( TIFFIsTiled( tif ) - && TIFFGetField( tif, TIFFTAG_TILEBYTECOUNTS, &byte_counts ) - && byte_counts != NULL ) - { - data_is_empty = byte_counts[0] == 0; - } - if ( !TIFFIsTiled( tif ) - && TIFFGetField( tif, TIFFTAG_STRIPBYTECOUNTS, &byte_counts) - && byte_counts != NULL ) - { - data_is_empty = byte_counts[0] == 0; - } - - if ( force_decode ) - decompress = 1; - else if ( force_encode ) - decompress = 0; - else if ( tif->tif_mode == O_RDONLY ) - decompress = 1; - else if ( data_is_empty ) - decompress = 0; - else - decompress = 1; - - /* - * Initialize libjpeg. - */ - if ( decompress ) { - if (!TIFFjpeg_create_decompress(sp)) - return (0); - - } else { - if (!TIFFjpeg_create_compress(sp)) - return (0); - } - - sp->cinfo_initialized = TRUE; - - return 1; -} - -int -TIFFInitJPEG(TIFF* tif, int scheme) -{ - JPEGState* sp; - - assert(scheme == COMPRESSION_JPEG); - - /* - * Merge codec-specific tag information. - */ - if (!_TIFFMergeFieldInfo(tif, jpegFieldInfo, N(jpegFieldInfo))) { - TIFFErrorExt(tif->tif_clientdata, - "TIFFInitJPEG", - "Merging JPEG codec-specific tags failed"); - return 0; - } - - /* - * Allocate state block so tag methods have storage to record values. - */ - tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (JPEGState)); - - if (tif->tif_data == NULL) { - TIFFErrorExt(tif->tif_clientdata, - "TIFFInitJPEG", "No space for JPEG state block"); - return 0; - } - _TIFFmemset(tif->tif_data, 0, sizeof(JPEGState)); - - sp = JState(tif); - sp->tif = tif; /* back link */ - - /* - * Override parent get/set field methods. - */ - sp->vgetparent = tif->tif_tagmethods.vgetfield; - tif->tif_tagmethods.vgetfield = JPEGVGetField; /* hook for codec tags */ - sp->vsetparent = tif->tif_tagmethods.vsetfield; - tif->tif_tagmethods.vsetfield = JPEGVSetField; /* hook for codec tags */ - sp->printdir = tif->tif_tagmethods.printdir; - tif->tif_tagmethods.printdir = JPEGPrintDir; /* hook for codec tags */ - - /* Default values for codec-specific fields */ - sp->jpegtables = NULL; - sp->jpegtables_length = 0; - sp->jpegquality = 75; /* Default IJG quality */ - sp->jpegcolormode = JPEGCOLORMODE_RAW; - sp->jpegtablesmode = JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF; - - sp->recvparams = 0; - sp->subaddress = NULL; - sp->faxdcs = NULL; - - sp->ycbcrsampling_fetched = 0; - - /* - * Install codec methods. - */ - tif->tif_setupdecode = JPEGSetupDecode; - tif->tif_predecode = JPEGPreDecode; - tif->tif_decoderow = JPEGDecode; - tif->tif_decodestrip = JPEGDecode; - tif->tif_decodetile = JPEGDecode; - tif->tif_setupencode = JPEGSetupEncode; - tif->tif_preencode = JPEGPreEncode; - tif->tif_postencode = JPEGPostEncode; - tif->tif_encoderow = JPEGEncode; - tif->tif_encodestrip = JPEGEncode; - tif->tif_encodetile = JPEGEncode; - tif->tif_cleanup = JPEGCleanup; - sp->defsparent = tif->tif_defstripsize; - tif->tif_defstripsize = JPEGDefaultStripSize; - sp->deftparent = tif->tif_deftilesize; - tif->tif_deftilesize = JPEGDefaultTileSize; - tif->tif_flags |= TIFF_NOBITREV; /* no bit reversal, please */ - - sp->cinfo_initialized = FALSE; - - /* - ** Create a JPEGTables field if no directory has yet been created. - ** We do this just to ensure that sufficient space is reserved for - ** the JPEGTables field. It will be properly created the right - ** size later. - */ - if ( tif->tif_diroff == 0 ) - { -#define SIZE_OF_JPEGTABLES 2000 -/* -The following line assumes incorrectly that all JPEG-in-TIFF files will have -a JPEGTABLES tag generated and causes null-filled JPEGTABLES tags to be written -when the JPEG data is placed with TIFFWriteRawStrip. The field bit should be -set, anyway, later when actual JPEGTABLES header is generated, so removing it -here hopefully is harmless. - TIFFSetFieldBit(tif, FIELD_JPEGTABLES); -*/ - sp->jpegtables_length = SIZE_OF_JPEGTABLES; - sp->jpegtables = (void *) _TIFFmalloc(sp->jpegtables_length); - _TIFFmemset(sp->jpegtables, 0, SIZE_OF_JPEGTABLES); -#undef SIZE_OF_JPEGTABLES - } - - /* - * Mark the TIFFTAG_YCBCRSAMPLES as present even if it is not - * see: JPEGFixupTestSubsampling(). - */ - TIFFSetFieldBit( tif, FIELD_YCBCRSUBSAMPLING ); - - return 1; -} -#endif /* JPEG_SUPPORT */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ - -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_luv.c b/plugins/AdvaImg/src/LibTIFF/tif_luv.c deleted file mode 100644 index 5e72ca63ba..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_luv.c +++ /dev/null @@ -1,1629 +0,0 @@ -/* $Id: tif_luv.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1997 Greg Ward Larson - * Copyright (c) 1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler, Greg Larson and Silicon Graphics may not be used in any - * advertising or publicity relating to the software without the specific, - * prior written permission of Sam Leffler, Greg Larson and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER, GREG LARSON OR SILICON GRAPHICS BE LIABLE - * FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#include "tiffiop.h" -#ifdef LOGLUV_SUPPORT - -/* - * TIFF Library. - * LogLuv compression support for high dynamic range images. - * - * Contributed by Greg Larson. - * - * LogLuv image support uses the TIFF library to store 16 or 10-bit - * log luminance values with 8 bits each of u and v or a 14-bit index. - * - * The codec can take as input and produce as output 32-bit IEEE float values - * as well as 16-bit integer values. A 16-bit luminance is interpreted - * as a sign bit followed by a 15-bit integer that is converted - * to and from a linear magnitude using the transformation: - * - * L = 2^( (Le+.5)/256 - 64 ) # real from 15-bit - * - * Le = floor( 256*(log2(L) + 64) ) # 15-bit from real - * - * The actual conversion to world luminance units in candelas per sq. meter - * requires an additional multiplier, which is stored in the TIFFTAG_STONITS. - * This value is usually set such that a reasonable exposure comes from - * clamping decoded luminances above 1 to 1 in the displayed image. - * - * The 16-bit values for u and v may be converted to real values by dividing - * each by 32768. (This allows for negative values, which aren't useful as - * far as we know, but are left in case of future improvements in human - * color vision.) - * - * Conversion from (u,v), which is actually the CIE (u',v') system for - * you color scientists, is accomplished by the following transformation: - * - * u = 4*x / (-2*x + 12*y + 3) - * v = 9*y / (-2*x + 12*y + 3) - * - * x = 9*u / (6*u - 16*v + 12) - * y = 4*v / (6*u - 16*v + 12) - * - * This process is greatly simplified by passing 32-bit IEEE floats - * for each of three CIE XYZ coordinates. The codec then takes care - * of conversion to and from LogLuv, though the application is still - * responsible for interpreting the TIFFTAG_STONITS calibration factor. - * - * By definition, a CIE XYZ vector of [1 1 1] corresponds to a neutral white - * point of (x,y)=(1/3,1/3). However, most color systems assume some other - * white point, such as D65, and an absolute color conversion to XYZ then - * to another color space with a different white point may introduce an - * unwanted color cast to the image. It is often desirable, therefore, to - * perform a white point conversion that maps the input white to [1 1 1] - * in XYZ, then record the original white point using the TIFFTAG_WHITEPOINT - * tag value. A decoder that demands absolute color calibration may use - * this white point tag to get back the original colors, but usually it - * will be ignored and the new white point will be used instead that - * matches the output color space. - * - * Pixel information is compressed into one of two basic encodings, depending - * on the setting of the compression tag, which is one of COMPRESSION_SGILOG - * or COMPRESSION_SGILOG24. For COMPRESSION_SGILOG, greyscale data is - * stored as: - * - * 1 15 - * |-+---------------| - * - * COMPRESSION_SGILOG color data is stored as: - * - * 1 15 8 8 - * |-+---------------|--------+--------| - * S Le ue ve - * - * For the 24-bit COMPRESSION_SGILOG24 color format, the data is stored as: - * - * 10 14 - * |----------|--------------| - * Le' Ce - * - * There is no sign bit in the 24-bit case, and the (u,v) chromaticity is - * encoded as an index for optimal color resolution. The 10 log bits are - * defined by the following conversions: - * - * L = 2^((Le'+.5)/64 - 12) # real from 10-bit - * - * Le' = floor( 64*(log2(L) + 12) ) # 10-bit from real - * - * The 10 bits of the smaller format may be converted into the 15 bits of - * the larger format by multiplying by 4 and adding 13314. Obviously, - * a smaller range of magnitudes is covered (about 5 orders of magnitude - * instead of 38), and the lack of a sign bit means that negative luminances - * are not allowed. (Well, they aren't allowed in the real world, either, - * but they are useful for certain types of image processing.) - * - * The desired user format is controlled by the setting the internal - * pseudo tag TIFFTAG_SGILOGDATAFMT to one of: - * SGILOGDATAFMT_FLOAT = IEEE 32-bit float XYZ values - * SGILOGDATAFMT_16BIT = 16-bit integer encodings of logL, u and v - * Raw data i/o is also possible using: - * SGILOGDATAFMT_RAW = 32-bit unsigned integer with encoded pixel - * In addition, the following decoding is provided for ease of display: - * SGILOGDATAFMT_8BIT = 8-bit default RGB gamma-corrected values - * - * For grayscale images, we provide the following data formats: - * SGILOGDATAFMT_FLOAT = IEEE 32-bit float Y values - * SGILOGDATAFMT_16BIT = 16-bit integer w/ encoded luminance - * SGILOGDATAFMT_8BIT = 8-bit gray monitor values - * - * Note that the COMPRESSION_SGILOG applies a simple run-length encoding - * scheme by separating the logL, u and v bytes for each row and applying - * a PackBits type of compression. Since the 24-bit encoding is not - * adaptive, the 32-bit color format takes less space in many cases. - * - * Further control is provided over the conversion from higher-resolution - * formats to final encoded values through the pseudo tag - * TIFFTAG_SGILOGENCODE: - * SGILOGENCODE_NODITHER = do not dither encoded values - * SGILOGENCODE_RANDITHER = apply random dithering during encoding - * - * The default value of this tag is SGILOGENCODE_NODITHER for - * COMPRESSION_SGILOG to maximize run-length encoding and - * SGILOGENCODE_RANDITHER for COMPRESSION_SGILOG24 to turn - * quantization errors into noise. - */ - -#include -#include -#include - -/* - * State block for each open TIFF - * file using LogLuv compression/decompression. - */ -typedef struct logLuvState LogLuvState; - -struct logLuvState { - int user_datafmt; /* user data format */ - int encode_meth; /* encoding method */ - int pixel_size; /* bytes per pixel */ - - tidata_t* tbuf; /* translation buffer */ - int tbuflen; /* buffer length */ - void (*tfunc)(LogLuvState*, tidata_t, int); - - TIFFVSetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ -}; - -#define DecoderState(tif) ((LogLuvState*) (tif)->tif_data) -#define EncoderState(tif) ((LogLuvState*) (tif)->tif_data) - -#define SGILOGDATAFMT_UNKNOWN -1 - -#define MINRUN 4 /* minimum run length */ - -/* - * Decode a string of 16-bit gray pixels. - */ -static int -LogL16Decode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) -{ - LogLuvState* sp = DecoderState(tif); - int shft, i, npixels; - unsigned char* bp; - int16* tp; - int16 b; - int cc, rc; - - assert(s == 0); - assert(sp != NULL); - - npixels = occ / sp->pixel_size; - - if (sp->user_datafmt == SGILOGDATAFMT_16BIT) - tp = (int16*) op; - else { - assert(sp->tbuflen >= npixels); - tp = (int16*) sp->tbuf; - } - _TIFFmemset((tdata_t) tp, 0, npixels*sizeof (tp[0])); - - bp = (unsigned char*) tif->tif_rawcp; - cc = tif->tif_rawcc; - /* get each byte string */ - for (shft = 2*8; (shft -= 8) >= 0; ) { - for (i = 0; i < npixels && cc > 0; ) - if (*bp >= 128) { /* run */ - rc = *bp++ + (2-128); - b = (int16)(*bp++ << shft); - cc -= 2; - while (rc-- && i < npixels) - tp[i++] |= b; - } else { /* non-run */ - rc = *bp++; /* nul is noop */ - while (--cc && rc-- && i < npixels) - tp[i++] |= (int16)*bp++ << shft; - } - if (i != npixels) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LogL16Decode: Not enough data at row %d (short %d pixels)", - tif->tif_row, npixels - i); - tif->tif_rawcp = (tidata_t) bp; - tif->tif_rawcc = cc; - return (0); - } - } - (*sp->tfunc)(sp, op, npixels); - tif->tif_rawcp = (tidata_t) bp; - tif->tif_rawcc = cc; - return (1); -} - -/* - * Decode a string of 24-bit pixels. - */ -static int -LogLuvDecode24(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) -{ - LogLuvState* sp = DecoderState(tif); - int cc, i, npixels; - unsigned char* bp; - uint32* tp; - - assert(s == 0); - assert(sp != NULL); - - npixels = occ / sp->pixel_size; - - if (sp->user_datafmt == SGILOGDATAFMT_RAW) - tp = (uint32 *)op; - else { - assert(sp->tbuflen >= npixels); - tp = (uint32 *) sp->tbuf; - } - /* copy to array of uint32 */ - bp = (unsigned char*) tif->tif_rawcp; - cc = tif->tif_rawcc; - for (i = 0; i < npixels && cc > 0; i++) { - tp[i] = bp[0] << 16 | bp[1] << 8 | bp[2]; - bp += 3; - cc -= 3; - } - tif->tif_rawcp = (tidata_t) bp; - tif->tif_rawcc = cc; - if (i != npixels) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LogLuvDecode24: Not enough data at row %d (short %d pixels)", - tif->tif_row, npixels - i); - return (0); - } - (*sp->tfunc)(sp, op, npixels); - return (1); -} - -/* - * Decode a string of 32-bit pixels. - */ -static int -LogLuvDecode32(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) -{ - LogLuvState* sp; - int shft, i, npixels; - unsigned char* bp; - uint32* tp; - uint32 b; - int cc, rc; - - assert(s == 0); - sp = DecoderState(tif); - assert(sp != NULL); - - npixels = occ / sp->pixel_size; - - if (sp->user_datafmt == SGILOGDATAFMT_RAW) - tp = (uint32*) op; - else { - assert(sp->tbuflen >= npixels); - tp = (uint32*) sp->tbuf; - } - _TIFFmemset((tdata_t) tp, 0, npixels*sizeof (tp[0])); - - bp = (unsigned char*) tif->tif_rawcp; - cc = tif->tif_rawcc; - /* get each byte string */ - for (shft = 4*8; (shft -= 8) >= 0; ) { - for (i = 0; i < npixels && cc > 0; ) - if (*bp >= 128) { /* run */ - rc = *bp++ + (2-128); - b = (uint32)*bp++ << shft; - cc -= 2; - while (rc-- && i < npixels) - tp[i++] |= b; - } else { /* non-run */ - rc = *bp++; /* nul is noop */ - while (--cc && rc-- && i < npixels) - tp[i++] |= (uint32)*bp++ << shft; - } - if (i != npixels) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LogLuvDecode32: Not enough data at row %d (short %d pixels)", - tif->tif_row, npixels - i); - tif->tif_rawcp = (tidata_t) bp; - tif->tif_rawcc = cc; - return (0); - } - } - (*sp->tfunc)(sp, op, npixels); - tif->tif_rawcp = (tidata_t) bp; - tif->tif_rawcc = cc; - return (1); -} - -/* - * Decode a strip of pixels. We break it into rows to - * maintain synchrony with the encode algorithm, which - * is row by row. - */ -static int -LogLuvDecodeStrip(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - tsize_t rowlen = TIFFScanlineSize(tif); - - assert(cc%rowlen == 0); - while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s)) - bp += rowlen, cc -= rowlen; - return (cc == 0); -} - -/* - * Decode a tile of pixels. We break it into rows to - * maintain synchrony with the encode algorithm, which - * is row by row. - */ -static int -LogLuvDecodeTile(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - tsize_t rowlen = TIFFTileRowSize(tif); - - assert(cc%rowlen == 0); - while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s)) - bp += rowlen, cc -= rowlen; - return (cc == 0); -} - -/* - * Encode a row of 16-bit pixels. - */ -static int -LogL16Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - LogLuvState* sp = EncoderState(tif); - int shft, i, j, npixels; - tidata_t op; - int16* tp; - int16 b; - int occ, rc=0, mask, beg; - - assert(s == 0); - assert(sp != NULL); - npixels = cc / sp->pixel_size; - - if (sp->user_datafmt == SGILOGDATAFMT_16BIT) - tp = (int16*) bp; - else { - tp = (int16*) sp->tbuf; - assert(sp->tbuflen >= npixels); - (*sp->tfunc)(sp, bp, npixels); - } - /* compress each byte string */ - op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; - for (shft = 2*8; (shft -= 8) >= 0; ) - for (i = 0; i < npixels; i += rc) { - if (occ < 4) { - tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; - if (!TIFFFlushData1(tif)) - return (-1); - op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; - } - mask = 0xff << shft; /* find next run */ - for (beg = i; beg < npixels; beg += rc) { - b = (int16) (tp[beg] & mask); - rc = 1; - while (rc < 127+2 && beg+rc < npixels && - (tp[beg+rc] & mask) == b) - rc++; - if (rc >= MINRUN) - break; /* long enough */ - } - if (beg-i > 1 && beg-i < MINRUN) { - b = (int16) (tp[i] & mask);/*check short run */ - j = i+1; - while ((tp[j++] & mask) == b) - if (j == beg) { - *op++ = (tidataval_t)(128-2+j-i); - *op++ = (tidataval_t) (b >> shft); - occ -= 2; - i = beg; - break; - } - } - while (i < beg) { /* write out non-run */ - if ((j = beg-i) > 127) j = 127; - if (occ < j+3) { - tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; - if (!TIFFFlushData1(tif)) - return (-1); - op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; - } - *op++ = (tidataval_t) j; occ--; - while (j--) { - *op++ = (tidataval_t) (tp[i++] >> shft & 0xff); - occ--; - } - } - if (rc >= MINRUN) { /* write out run */ - *op++ = (tidataval_t) (128-2+rc); - *op++ = (tidataval_t) (tp[beg] >> shft & 0xff); - occ -= 2; - } else - rc = 0; - } - tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; - - return (1); -} - -/* - * Encode a row of 24-bit pixels. - */ -static int -LogLuvEncode24(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - LogLuvState* sp = EncoderState(tif); - int i, npixels, occ; - tidata_t op; - uint32* tp; - - assert(s == 0); - assert(sp != NULL); - npixels = cc / sp->pixel_size; - - if (sp->user_datafmt == SGILOGDATAFMT_RAW) - tp = (uint32*) bp; - else { - tp = (uint32*) sp->tbuf; - assert(sp->tbuflen >= npixels); - (*sp->tfunc)(sp, bp, npixels); - } - /* write out encoded pixels */ - op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; - for (i = npixels; i--; ) { - if (occ < 3) { - tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; - if (!TIFFFlushData1(tif)) - return (-1); - op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; - } - *op++ = (tidataval_t)(*tp >> 16); - *op++ = (tidataval_t)(*tp >> 8 & 0xff); - *op++ = (tidataval_t)(*tp++ & 0xff); - occ -= 3; - } - tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; - - return (1); -} - -/* - * Encode a row of 32-bit pixels. - */ -static int -LogLuvEncode32(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - LogLuvState* sp = EncoderState(tif); - int shft, i, j, npixels; - tidata_t op; - uint32* tp; - uint32 b; - int occ, rc=0, mask, beg; - - assert(s == 0); - assert(sp != NULL); - - npixels = cc / sp->pixel_size; - - if (sp->user_datafmt == SGILOGDATAFMT_RAW) - tp = (uint32*) bp; - else { - tp = (uint32*) sp->tbuf; - assert(sp->tbuflen >= npixels); - (*sp->tfunc)(sp, bp, npixels); - } - /* compress each byte string */ - op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; - for (shft = 4*8; (shft -= 8) >= 0; ) - for (i = 0; i < npixels; i += rc) { - if (occ < 4) { - tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; - if (!TIFFFlushData1(tif)) - return (-1); - op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; - } - mask = 0xff << shft; /* find next run */ - for (beg = i; beg < npixels; beg += rc) { - b = tp[beg] & mask; - rc = 1; - while (rc < 127+2 && beg+rc < npixels && - (tp[beg+rc] & mask) == b) - rc++; - if (rc >= MINRUN) - break; /* long enough */ - } - if (beg-i > 1 && beg-i < MINRUN) { - b = tp[i] & mask; /* check short run */ - j = i+1; - while ((tp[j++] & mask) == b) - if (j == beg) { - *op++ = (tidataval_t)(128-2+j-i); - *op++ = (tidataval_t)(b >> shft); - occ -= 2; - i = beg; - break; - } - } - while (i < beg) { /* write out non-run */ - if ((j = beg-i) > 127) j = 127; - if (occ < j+3) { - tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; - if (!TIFFFlushData1(tif)) - return (-1); - op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; - } - *op++ = (tidataval_t) j; occ--; - while (j--) { - *op++ = (tidataval_t)(tp[i++] >> shft & 0xff); - occ--; - } - } - if (rc >= MINRUN) { /* write out run */ - *op++ = (tidataval_t) (128-2+rc); - *op++ = (tidataval_t)(tp[beg] >> shft & 0xff); - occ -= 2; - } else - rc = 0; - } - tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; - - return (1); -} - -/* - * Encode a strip of pixels. We break it into rows to - * avoid encoding runs across row boundaries. - */ -static int -LogLuvEncodeStrip(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - tsize_t rowlen = TIFFScanlineSize(tif); - - assert(cc%rowlen == 0); - while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 1) - bp += rowlen, cc -= rowlen; - return (cc == 0); -} - -/* - * Encode a tile of pixels. We break it into rows to - * avoid encoding runs across row boundaries. - */ -static int -LogLuvEncodeTile(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - tsize_t rowlen = TIFFTileRowSize(tif); - - assert(cc%rowlen == 0); - while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 1) - bp += rowlen, cc -= rowlen; - return (cc == 0); -} - -/* - * Encode/Decode functions for converting to and from user formats. - */ - -#include "uvcode.h" - -#ifndef UVSCALE -#define U_NEU 0.210526316 -#define V_NEU 0.473684211 -#define UVSCALE 410. -#endif - -#ifndef M_LN2 -#define M_LN2 0.69314718055994530942 -#endif -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif -#define log2(x) ((1./M_LN2)*log(x)) -#define exp2(x) exp(M_LN2*(x)) - -#define itrunc(x,m) ((m)==SGILOGENCODE_NODITHER ? \ - (int)(x) : \ - (int)((x) + rand()*(1./RAND_MAX) - .5)) - -#if !LOGLUV_PUBLIC -static -#endif -double -LogL16toY(int p16) /* compute luminance from 16-bit LogL */ -{ - int Le = p16 & 0x7fff; - double Y; - - if (!Le) - return (0.); - Y = exp(M_LN2/256.*(Le+.5) - M_LN2*64.); - return (!(p16 & 0x8000) ? Y : -Y); -} - -#if !LOGLUV_PUBLIC -static -#endif -int -LogL16fromY(double Y, int em) /* get 16-bit LogL from Y */ -{ - if (Y >= 1.8371976e19) - return (0x7fff); - if (Y <= -1.8371976e19) - return (0xffff); - if (Y > 5.4136769e-20) - return itrunc(256.*(log2(Y) + 64.), em); - if (Y < -5.4136769e-20) - return (~0x7fff | itrunc(256.*(log2(-Y) + 64.), em)); - return (0); -} - -static void -L16toY(LogLuvState* sp, tidata_t op, int n) -{ - int16* l16 = (int16*) sp->tbuf; - float* yp = (float*) op; - - while (n-- > 0) - *yp++ = (float)LogL16toY(*l16++); -} - -static void -L16toGry(LogLuvState* sp, tidata_t op, int n) -{ - int16* l16 = (int16*) sp->tbuf; - uint8* gp = (uint8*) op; - - while (n-- > 0) { - double Y = LogL16toY(*l16++); - *gp++ = (uint8) ((Y <= 0.) ? 0 : (Y >= 1.) ? 255 : (int)(256.*sqrt(Y))); - } -} - -static void -L16fromY(LogLuvState* sp, tidata_t op, int n) -{ - int16* l16 = (int16*) sp->tbuf; - float* yp = (float*) op; - - while (n-- > 0) - *l16++ = (int16) (LogL16fromY(*yp++, sp->encode_meth)); -} - -#if !LOGLUV_PUBLIC -static -#endif -void -XYZtoRGB24(float xyz[3], uint8 rgb[3]) -{ - double r, g, b; - /* assume CCIR-709 primaries */ - r = 2.690*xyz[0] + -1.276*xyz[1] + -0.414*xyz[2]; - g = -1.022*xyz[0] + 1.978*xyz[1] + 0.044*xyz[2]; - b = 0.061*xyz[0] + -0.224*xyz[1] + 1.163*xyz[2]; - /* assume 2.0 gamma for speed */ - /* could use integer sqrt approx., but this is probably faster */ - rgb[0] = (uint8)((r<=0.) ? 0 : (r >= 1.) ? 255 : (int)(256.*sqrt(r))); - rgb[1] = (uint8)((g<=0.) ? 0 : (g >= 1.) ? 255 : (int)(256.*sqrt(g))); - rgb[2] = (uint8)((b<=0.) ? 0 : (b >= 1.) ? 255 : (int)(256.*sqrt(b))); -} - -#if !LOGLUV_PUBLIC -static -#endif -double -LogL10toY(int p10) /* compute luminance from 10-bit LogL */ -{ - if (p10 == 0) - return (0.); - return (exp(M_LN2/64.*(p10+.5) - M_LN2*12.)); -} - -#if !LOGLUV_PUBLIC -static -#endif -int -LogL10fromY(double Y, int em) /* get 10-bit LogL from Y */ -{ - if (Y >= 15.742) - return (0x3ff); - else if (Y <= .00024283) - return (0); - else - return itrunc(64.*(log2(Y) + 12.), em); -} - -#define NANGLES 100 -#define uv2ang(u, v) ( (NANGLES*.499999999/M_PI) \ - * atan2((v)-V_NEU,(u)-U_NEU) + .5*NANGLES ) - -static int -oog_encode(double u, double v) /* encode out-of-gamut chroma */ -{ - static int oog_table[NANGLES]; - static int initialized = 0; - register int i; - - if (!initialized) { /* set up perimeter table */ - double eps[NANGLES], ua, va, ang, epsa; - int ui, vi, ustep; - for (i = NANGLES; i--; ) - eps[i] = 2.; - for (vi = UV_NVS; vi--; ) { - va = UV_VSTART + (vi+.5)*UV_SQSIZ; - ustep = uv_row[vi].nus-1; - if (vi == UV_NVS-1 || vi == 0 || ustep <= 0) - ustep = 1; - for (ui = uv_row[vi].nus-1; ui >= 0; ui -= ustep) { - ua = uv_row[vi].ustart + (ui+.5)*UV_SQSIZ; - ang = uv2ang(ua, va); - i = (int) ang; - epsa = fabs(ang - (i+.5)); - if (epsa < eps[i]) { - oog_table[i] = uv_row[vi].ncum + ui; - eps[i] = epsa; - } - } - } - for (i = NANGLES; i--; ) /* fill any holes */ - if (eps[i] > 1.5) { - int i1, i2; - for (i1 = 1; i1 < NANGLES/2; i1++) - if (eps[(i+i1)%NANGLES] < 1.5) - break; - for (i2 = 1; i2 < NANGLES/2; i2++) - if (eps[(i+NANGLES-i2)%NANGLES] < 1.5) - break; - if (i1 < i2) - oog_table[i] = - oog_table[(i+i1)%NANGLES]; - else - oog_table[i] = - oog_table[(i+NANGLES-i2)%NANGLES]; - } - initialized = 1; - } - i = (int) uv2ang(u, v); /* look up hue angle */ - return (oog_table[i]); -} - -#undef uv2ang -#undef NANGLES - -#if !LOGLUV_PUBLIC -static -#endif -int -uv_encode(double u, double v, int em) /* encode (u',v') coordinates */ -{ - register int vi, ui; - - if (v < UV_VSTART) - return oog_encode(u, v); - vi = itrunc((v - UV_VSTART)*(1./UV_SQSIZ), em); - if (vi >= UV_NVS) - return oog_encode(u, v); - if (u < uv_row[vi].ustart) - return oog_encode(u, v); - ui = itrunc((u - uv_row[vi].ustart)*(1./UV_SQSIZ), em); - if (ui >= uv_row[vi].nus) - return oog_encode(u, v); - - return (uv_row[vi].ncum + ui); -} - -#if !LOGLUV_PUBLIC -static -#endif -int -uv_decode(double *up, double *vp, int c) /* decode (u',v') index */ -{ - int upper, lower; - register int ui, vi; - - if (c < 0 || c >= UV_NDIVS) - return (-1); - lower = 0; /* binary search */ - upper = UV_NVS; - while (upper - lower > 1) { - vi = (lower + upper) >> 1; - ui = c - uv_row[vi].ncum; - if (ui > 0) - lower = vi; - else if (ui < 0) - upper = vi; - else { - lower = vi; - break; - } - } - vi = lower; - ui = c - uv_row[vi].ncum; - *up = uv_row[vi].ustart + (ui+.5)*UV_SQSIZ; - *vp = UV_VSTART + (vi+.5)*UV_SQSIZ; - return (0); -} - -#if !LOGLUV_PUBLIC -static -#endif -void -LogLuv24toXYZ(uint32 p, float XYZ[3]) -{ - int Ce; - double L, u, v, s, x, y; - /* decode luminance */ - L = LogL10toY(p>>14 & 0x3ff); - if (L <= 0.) { - XYZ[0] = XYZ[1] = XYZ[2] = 0.; - return; - } - /* decode color */ - Ce = p & 0x3fff; - if (uv_decode(&u, &v, Ce) < 0) { - u = U_NEU; v = V_NEU; - } - s = 1./(6.*u - 16.*v + 12.); - x = 9.*u * s; - y = 4.*v * s; - /* convert to XYZ */ - XYZ[0] = (float)(x/y * L); - XYZ[1] = (float)L; - XYZ[2] = (float)((1.-x-y)/y * L); -} - -#if !LOGLUV_PUBLIC -static -#endif -uint32 -LogLuv24fromXYZ(float XYZ[3], int em) -{ - int Le, Ce; - double u, v, s; - /* encode luminance */ - Le = LogL10fromY(XYZ[1], em); - /* encode color */ - s = XYZ[0] + 15.*XYZ[1] + 3.*XYZ[2]; - if (!Le || s <= 0.) { - u = U_NEU; - v = V_NEU; - } else { - u = 4.*XYZ[0] / s; - v = 9.*XYZ[1] / s; - } - Ce = uv_encode(u, v, em); - if (Ce < 0) /* never happens */ - Ce = uv_encode(U_NEU, V_NEU, SGILOGENCODE_NODITHER); - /* combine encodings */ - return (Le << 14 | Ce); -} - -static void -Luv24toXYZ(LogLuvState* sp, tidata_t op, int n) -{ - uint32* luv = (uint32*) sp->tbuf; - float* xyz = (float*) op; - - while (n-- > 0) { - LogLuv24toXYZ(*luv, xyz); - xyz += 3; - luv++; - } -} - -static void -Luv24toLuv48(LogLuvState* sp, tidata_t op, int n) -{ - uint32* luv = (uint32*) sp->tbuf; - int16* luv3 = (int16*) op; - - while (n-- > 0) { - double u, v; - - *luv3++ = (int16)((*luv >> 12 & 0xffd) + 13314); - if (uv_decode(&u, &v, *luv&0x3fff) < 0) { - u = U_NEU; - v = V_NEU; - } - *luv3++ = (int16)(u * (1L<<15)); - *luv3++ = (int16)(v * (1L<<15)); - luv++; - } -} - -static void -Luv24toRGB(LogLuvState* sp, tidata_t op, int n) -{ - uint32* luv = (uint32*) sp->tbuf; - uint8* rgb = (uint8*) op; - - while (n-- > 0) { - float xyz[3]; - - LogLuv24toXYZ(*luv++, xyz); - XYZtoRGB24(xyz, rgb); - rgb += 3; - } -} - -static void -Luv24fromXYZ(LogLuvState* sp, tidata_t op, int n) -{ - uint32* luv = (uint32*) sp->tbuf; - float* xyz = (float*) op; - - while (n-- > 0) { - *luv++ = LogLuv24fromXYZ(xyz, sp->encode_meth); - xyz += 3; - } -} - -static void -Luv24fromLuv48(LogLuvState* sp, tidata_t op, int n) -{ - uint32* luv = (uint32*) sp->tbuf; - int16* luv3 = (int16*) op; - - while (n-- > 0) { - int Le, Ce; - - if (luv3[0] <= 0) - Le = 0; - else if (luv3[0] >= (1<<12)+3314) - Le = (1<<10) - 1; - else if (sp->encode_meth == SGILOGENCODE_NODITHER) - Le = (luv3[0]-3314) >> 2; - else - Le = itrunc(.25*(luv3[0]-3314.), sp->encode_meth); - - Ce = uv_encode((luv3[1]+.5)/(1<<15), (luv3[2]+.5)/(1<<15), - sp->encode_meth); - if (Ce < 0) /* never happens */ - Ce = uv_encode(U_NEU, V_NEU, SGILOGENCODE_NODITHER); - *luv++ = (uint32)Le << 14 | Ce; - luv3 += 3; - } -} - -#if !LOGLUV_PUBLIC -static -#endif -void -LogLuv32toXYZ(uint32 p, float XYZ[3]) -{ - double L, u, v, s, x, y; - /* decode luminance */ - L = LogL16toY((int)p >> 16); - if (L <= 0.) { - XYZ[0] = XYZ[1] = XYZ[2] = 0.; - return; - } - /* decode color */ - u = 1./UVSCALE * ((p>>8 & 0xff) + .5); - v = 1./UVSCALE * ((p & 0xff) + .5); - s = 1./(6.*u - 16.*v + 12.); - x = 9.*u * s; - y = 4.*v * s; - /* convert to XYZ */ - XYZ[0] = (float)(x/y * L); - XYZ[1] = (float)L; - XYZ[2] = (float)((1.-x-y)/y * L); -} - -#if !LOGLUV_PUBLIC -static -#endif -uint32 -LogLuv32fromXYZ(float XYZ[3], int em) -{ - unsigned int Le, ue, ve; - double u, v, s; - /* encode luminance */ - Le = (unsigned int)LogL16fromY(XYZ[1], em); - /* encode color */ - s = XYZ[0] + 15.*XYZ[1] + 3.*XYZ[2]; - if (!Le || s <= 0.) { - u = U_NEU; - v = V_NEU; - } else { - u = 4.*XYZ[0] / s; - v = 9.*XYZ[1] / s; - } - if (u <= 0.) ue = 0; - else ue = itrunc(UVSCALE*u, em); - if (ue > 255) ue = 255; - if (v <= 0.) ve = 0; - else ve = itrunc(UVSCALE*v, em); - if (ve > 255) ve = 255; - /* combine encodings */ - return (Le << 16 | ue << 8 | ve); -} - -static void -Luv32toXYZ(LogLuvState* sp, tidata_t op, int n) -{ - uint32* luv = (uint32*) sp->tbuf; - float* xyz = (float*) op; - - while (n-- > 0) { - LogLuv32toXYZ(*luv++, xyz); - xyz += 3; - } -} - -static void -Luv32toLuv48(LogLuvState* sp, tidata_t op, int n) -{ - uint32* luv = (uint32*) sp->tbuf; - int16* luv3 = (int16*) op; - - while (n-- > 0) { - double u, v; - - *luv3++ = (int16)(*luv >> 16); - u = 1./UVSCALE * ((*luv>>8 & 0xff) + .5); - v = 1./UVSCALE * ((*luv & 0xff) + .5); - *luv3++ = (int16)(u * (1L<<15)); - *luv3++ = (int16)(v * (1L<<15)); - luv++; - } -} - -static void -Luv32toRGB(LogLuvState* sp, tidata_t op, int n) -{ - uint32* luv = (uint32*) sp->tbuf; - uint8* rgb = (uint8*) op; - - while (n-- > 0) { - float xyz[3]; - - LogLuv32toXYZ(*luv++, xyz); - XYZtoRGB24(xyz, rgb); - rgb += 3; - } -} - -static void -Luv32fromXYZ(LogLuvState* sp, tidata_t op, int n) -{ - uint32* luv = (uint32*) sp->tbuf; - float* xyz = (float*) op; - - while (n-- > 0) { - *luv++ = LogLuv32fromXYZ(xyz, sp->encode_meth); - xyz += 3; - } -} - -static void -Luv32fromLuv48(LogLuvState* sp, tidata_t op, int n) -{ - uint32* luv = (uint32*) sp->tbuf; - int16* luv3 = (int16*) op; - - if (sp->encode_meth == SGILOGENCODE_NODITHER) { - while (n-- > 0) { - *luv++ = (uint32)luv3[0] << 16 | - (luv3[1]*(uint32)(UVSCALE+.5) >> 7 & 0xff00) | - (luv3[2]*(uint32)(UVSCALE+.5) >> 15 & 0xff); - luv3 += 3; - } - return; - } - while (n-- > 0) { - *luv++ = (uint32)luv3[0] << 16 | - (itrunc(luv3[1]*(UVSCALE/(1<<15)), sp->encode_meth) << 8 & 0xff00) | - (itrunc(luv3[2]*(UVSCALE/(1<<15)), sp->encode_meth) & 0xff); - luv3 += 3; - } -} - -static void -_logLuvNop(LogLuvState* sp, tidata_t op, int n) -{ - (void) sp; (void) op; (void) n; -} - -static int -LogL16GuessDataFmt(TIFFDirectory *td) -{ -#define PACK(s,b,f) (((b)<<6)|((s)<<3)|(f)) - switch (PACK(td->td_samplesperpixel, td->td_bitspersample, td->td_sampleformat)) { - case PACK(1, 32, SAMPLEFORMAT_IEEEFP): - return (SGILOGDATAFMT_FLOAT); - case PACK(1, 16, SAMPLEFORMAT_VOID): - case PACK(1, 16, SAMPLEFORMAT_INT): - case PACK(1, 16, SAMPLEFORMAT_UINT): - return (SGILOGDATAFMT_16BIT); - case PACK(1, 8, SAMPLEFORMAT_VOID): - case PACK(1, 8, SAMPLEFORMAT_UINT): - return (SGILOGDATAFMT_8BIT); - } -#undef PACK - return (SGILOGDATAFMT_UNKNOWN); -} - -static uint32 -multiply(size_t m1, size_t m2) -{ - uint32 bytes = m1 * m2; - - if (m1 && bytes / m1 != m2) - bytes = 0; - - return bytes; -} - -static int -LogL16InitState(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - LogLuvState* sp = DecoderState(tif); - static const char module[] = "LogL16InitState"; - - assert(sp != NULL); - assert(td->td_photometric == PHOTOMETRIC_LOGL); - - /* for some reason, we can't do this in TIFFInitLogL16 */ - if (sp->user_datafmt == SGILOGDATAFMT_UNKNOWN) - sp->user_datafmt = LogL16GuessDataFmt(td); - switch (sp->user_datafmt) { - case SGILOGDATAFMT_FLOAT: - sp->pixel_size = sizeof (float); - break; - case SGILOGDATAFMT_16BIT: - sp->pixel_size = sizeof (int16); - break; - case SGILOGDATAFMT_8BIT: - sp->pixel_size = sizeof (uint8); - break; - default: - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "No support for converting user data format to LogL"); - return (0); - } - if ( isTiled(tif) ) - sp->tbuflen = multiply(td->td_tilewidth, td->td_tilelength); - else - sp->tbuflen = multiply(td->td_imagewidth, td->td_rowsperstrip); - if (multiply(sp->tbuflen, sizeof (int16)) == 0 || - (sp->tbuf = (tidata_t*) _TIFFmalloc(sp->tbuflen * sizeof (int16))) == NULL) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: No space for SGILog translation buffer", - tif->tif_name); - return (0); - } - return (1); -} - -static int -LogLuvGuessDataFmt(TIFFDirectory *td) -{ - int guess; - - /* - * If the user didn't tell us their datafmt, - * take our best guess from the bitspersample. - */ -#define PACK(a,b) (((a)<<3)|(b)) - switch (PACK(td->td_bitspersample, td->td_sampleformat)) { - case PACK(32, SAMPLEFORMAT_IEEEFP): - guess = SGILOGDATAFMT_FLOAT; - break; - case PACK(32, SAMPLEFORMAT_VOID): - case PACK(32, SAMPLEFORMAT_UINT): - case PACK(32, SAMPLEFORMAT_INT): - guess = SGILOGDATAFMT_RAW; - break; - case PACK(16, SAMPLEFORMAT_VOID): - case PACK(16, SAMPLEFORMAT_INT): - case PACK(16, SAMPLEFORMAT_UINT): - guess = SGILOGDATAFMT_16BIT; - break; - case PACK( 8, SAMPLEFORMAT_VOID): - case PACK( 8, SAMPLEFORMAT_UINT): - guess = SGILOGDATAFMT_8BIT; - break; - default: - guess = SGILOGDATAFMT_UNKNOWN; - break; -#undef PACK - } - /* - * Double-check samples per pixel. - */ - switch (td->td_samplesperpixel) { - case 1: - if (guess != SGILOGDATAFMT_RAW) - guess = SGILOGDATAFMT_UNKNOWN; - break; - case 3: - if (guess == SGILOGDATAFMT_RAW) - guess = SGILOGDATAFMT_UNKNOWN; - break; - default: - guess = SGILOGDATAFMT_UNKNOWN; - break; - } - return (guess); -} - -static int -LogLuvInitState(TIFF* tif) -{ - TIFFDirectory* td = &tif->tif_dir; - LogLuvState* sp = DecoderState(tif); - static const char module[] = "LogLuvInitState"; - - assert(sp != NULL); - assert(td->td_photometric == PHOTOMETRIC_LOGLUV); - - /* for some reason, we can't do this in TIFFInitLogLuv */ - if (td->td_planarconfig != PLANARCONFIG_CONTIG) { - TIFFErrorExt(tif->tif_clientdata, module, - "SGILog compression cannot handle non-contiguous data"); - return (0); - } - if (sp->user_datafmt == SGILOGDATAFMT_UNKNOWN) - sp->user_datafmt = LogLuvGuessDataFmt(td); - switch (sp->user_datafmt) { - case SGILOGDATAFMT_FLOAT: - sp->pixel_size = 3*sizeof (float); - break; - case SGILOGDATAFMT_16BIT: - sp->pixel_size = 3*sizeof (int16); - break; - case SGILOGDATAFMT_RAW: - sp->pixel_size = sizeof (uint32); - break; - case SGILOGDATAFMT_8BIT: - sp->pixel_size = 3*sizeof (uint8); - break; - default: - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "No support for converting user data format to LogLuv"); - return (0); - } - if ( isTiled(tif) ) - sp->tbuflen = multiply(td->td_tilewidth, td->td_tilelength); - else - sp->tbuflen = multiply(td->td_imagewidth, td->td_rowsperstrip); - if (multiply(sp->tbuflen, sizeof (uint32)) == 0 || - (sp->tbuf = (tidata_t*) _TIFFmalloc(sp->tbuflen * sizeof (uint32))) == NULL) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: No space for SGILog translation buffer", - tif->tif_name); - return (0); - } - return (1); -} - -static int -LogLuvSetupDecode(TIFF* tif) -{ - LogLuvState* sp = DecoderState(tif); - TIFFDirectory* td = &tif->tif_dir; - - tif->tif_postdecode = _TIFFNoPostDecode; - switch (td->td_photometric) { - case PHOTOMETRIC_LOGLUV: - if (!LogLuvInitState(tif)) - break; - if (td->td_compression == COMPRESSION_SGILOG24) { - tif->tif_decoderow = LogLuvDecode24; - switch (sp->user_datafmt) { - case SGILOGDATAFMT_FLOAT: - sp->tfunc = Luv24toXYZ; - break; - case SGILOGDATAFMT_16BIT: - sp->tfunc = Luv24toLuv48; - break; - case SGILOGDATAFMT_8BIT: - sp->tfunc = Luv24toRGB; - break; - } - } else { - tif->tif_decoderow = LogLuvDecode32; - switch (sp->user_datafmt) { - case SGILOGDATAFMT_FLOAT: - sp->tfunc = Luv32toXYZ; - break; - case SGILOGDATAFMT_16BIT: - sp->tfunc = Luv32toLuv48; - break; - case SGILOGDATAFMT_8BIT: - sp->tfunc = Luv32toRGB; - break; - } - } - return (1); - case PHOTOMETRIC_LOGL: - if (!LogL16InitState(tif)) - break; - tif->tif_decoderow = LogL16Decode; - switch (sp->user_datafmt) { - case SGILOGDATAFMT_FLOAT: - sp->tfunc = L16toY; - break; - case SGILOGDATAFMT_8BIT: - sp->tfunc = L16toGry; - break; - } - return (1); - default: - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Inappropriate photometric interpretation %d for SGILog compression; %s", - td->td_photometric, "must be either LogLUV or LogL"); - break; - } - return (0); -} - -static int -LogLuvSetupEncode(TIFF* tif) -{ - LogLuvState* sp = EncoderState(tif); - TIFFDirectory* td = &tif->tif_dir; - - switch (td->td_photometric) { - case PHOTOMETRIC_LOGLUV: - if (!LogLuvInitState(tif)) - break; - if (td->td_compression == COMPRESSION_SGILOG24) { - tif->tif_encoderow = LogLuvEncode24; - switch (sp->user_datafmt) { - case SGILOGDATAFMT_FLOAT: - sp->tfunc = Luv24fromXYZ; - break; - case SGILOGDATAFMT_16BIT: - sp->tfunc = Luv24fromLuv48; - break; - case SGILOGDATAFMT_RAW: - break; - default: - goto notsupported; - } - } else { - tif->tif_encoderow = LogLuvEncode32; - switch (sp->user_datafmt) { - case SGILOGDATAFMT_FLOAT: - sp->tfunc = Luv32fromXYZ; - break; - case SGILOGDATAFMT_16BIT: - sp->tfunc = Luv32fromLuv48; - break; - case SGILOGDATAFMT_RAW: - break; - default: - goto notsupported; - } - } - break; - case PHOTOMETRIC_LOGL: - if (!LogL16InitState(tif)) - break; - tif->tif_encoderow = LogL16Encode; - switch (sp->user_datafmt) { - case SGILOGDATAFMT_FLOAT: - sp->tfunc = L16fromY; - break; - case SGILOGDATAFMT_16BIT: - break; - default: - goto notsupported; - } - break; - default: - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Inappropriate photometric interpretation %d for SGILog compression; %s", - td->td_photometric, "must be either LogLUV or LogL"); - break; - } - return (1); -notsupported: - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "SGILog compression supported only for %s, or raw data", - td->td_photometric == PHOTOMETRIC_LOGL ? "Y, L" : "XYZ, Luv"); - return (0); -} - -static void -LogLuvClose(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - - /* - * For consistency, we always want to write out the same - * bitspersample and sampleformat for our TIFF file, - * regardless of the data format being used by the application. - * Since this routine is called after tags have been set but - * before they have been recorded in the file, we reset them here. - */ - td->td_samplesperpixel = - (td->td_photometric == PHOTOMETRIC_LOGL) ? 1 : 3; - td->td_bitspersample = 16; - td->td_sampleformat = SAMPLEFORMAT_INT; -} - -static void -LogLuvCleanup(TIFF* tif) -{ - LogLuvState* sp = (LogLuvState *)tif->tif_data; - - assert(sp != 0); - - tif->tif_tagmethods.vgetfield = sp->vgetparent; - tif->tif_tagmethods.vsetfield = sp->vsetparent; - - if (sp->tbuf) - _TIFFfree(sp->tbuf); - _TIFFfree(sp); - tif->tif_data = NULL; - - _TIFFSetDefaultCompressionState(tif); -} - -static int -LogLuvVSetField(TIFF* tif, ttag_t tag, va_list ap) -{ - LogLuvState* sp = DecoderState(tif); - int bps, fmt; - - switch (tag) { - case TIFFTAG_SGILOGDATAFMT: - sp->user_datafmt = va_arg(ap, int); - /* - * Tweak the TIFF header so that the rest of libtiff knows what - * size of data will be passed between app and library, and - * assume that the app knows what it is doing and is not - * confused by these header manipulations... - */ - switch (sp->user_datafmt) { - case SGILOGDATAFMT_FLOAT: - bps = 32, fmt = SAMPLEFORMAT_IEEEFP; - break; - case SGILOGDATAFMT_16BIT: - bps = 16, fmt = SAMPLEFORMAT_INT; - break; - case SGILOGDATAFMT_RAW: - bps = 32, fmt = SAMPLEFORMAT_UINT; - TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1); - break; - case SGILOGDATAFMT_8BIT: - bps = 8, fmt = SAMPLEFORMAT_UINT; - break; - default: - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Unknown data format %d for LogLuv compression", - sp->user_datafmt); - return (0); - } - TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps); - TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, fmt); - /* - * Must recalculate sizes should bits/sample change. - */ - tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tsize_t) -1; - tif->tif_scanlinesize = TIFFScanlineSize(tif); - return (1); - case TIFFTAG_SGILOGENCODE: - sp->encode_meth = va_arg(ap, int); - if (sp->encode_meth != SGILOGENCODE_NODITHER && - sp->encode_meth != SGILOGENCODE_RANDITHER) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Unknown encoding %d for LogLuv compression", - sp->encode_meth); - return (0); - } - return (1); - default: - return (*sp->vsetparent)(tif, tag, ap); - } -} - -static int -LogLuvVGetField(TIFF* tif, ttag_t tag, va_list ap) -{ - LogLuvState *sp = (LogLuvState *)tif->tif_data; - - switch (tag) { - case TIFFTAG_SGILOGDATAFMT: - *va_arg(ap, int*) = sp->user_datafmt; - return (1); - default: - return (*sp->vgetparent)(tif, tag, ap); - } -} - -static const TIFFFieldInfo LogLuvFieldInfo[] = { - { TIFFTAG_SGILOGDATAFMT, 0, 0, TIFF_SHORT, FIELD_PSEUDO, - TRUE, FALSE, "SGILogDataFmt"}, - { TIFFTAG_SGILOGENCODE, 0, 0, TIFF_SHORT, FIELD_PSEUDO, - TRUE, FALSE, "SGILogEncode"} -}; - -int -TIFFInitSGILog(TIFF* tif, int scheme) -{ - static const char module[] = "TIFFInitSGILog"; - LogLuvState* sp; - - assert(scheme == COMPRESSION_SGILOG24 || scheme == COMPRESSION_SGILOG); - - /* - * Merge codec-specific tag information. - */ - if (!_TIFFMergeFieldInfo(tif, LogLuvFieldInfo, - TIFFArrayCount(LogLuvFieldInfo))) { - TIFFErrorExt(tif->tif_clientdata, module, - "Merging SGILog codec-specific tags failed"); - return 0; - } - - /* - * Allocate state block so tag methods have storage to record values. - */ - tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (LogLuvState)); - if (tif->tif_data == NULL) - goto bad; - sp = (LogLuvState*) tif->tif_data; - _TIFFmemset((tdata_t)sp, 0, sizeof (*sp)); - sp->user_datafmt = SGILOGDATAFMT_UNKNOWN; - sp->encode_meth = (scheme == COMPRESSION_SGILOG24) ? - SGILOGENCODE_RANDITHER : SGILOGENCODE_NODITHER; - sp->tfunc = _logLuvNop; - - /* - * Install codec methods. - * NB: tif_decoderow & tif_encoderow are filled - * in at setup time. - */ - tif->tif_setupdecode = LogLuvSetupDecode; - tif->tif_decodestrip = LogLuvDecodeStrip; - tif->tif_decodetile = LogLuvDecodeTile; - tif->tif_setupencode = LogLuvSetupEncode; - tif->tif_encodestrip = LogLuvEncodeStrip; - tif->tif_encodetile = LogLuvEncodeTile; - tif->tif_close = LogLuvClose; - tif->tif_cleanup = LogLuvCleanup; - - /* - * Override parent get/set field methods. - */ - sp->vgetparent = tif->tif_tagmethods.vgetfield; - tif->tif_tagmethods.vgetfield = LogLuvVGetField; /* hook for codec tags */ - sp->vsetparent = tif->tif_tagmethods.vsetfield; - tif->tif_tagmethods.vsetfield = LogLuvVSetField; /* hook for codec tags */ - - return (1); -bad: - TIFFErrorExt(tif->tif_clientdata, module, - "%s: No space for LogLuv state block", tif->tif_name); - return (0); -} -#endif /* LOGLUV_SUPPORT */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_lzw.c b/plugins/AdvaImg/src/LibTIFF/tif_lzw.c deleted file mode 100644 index 16fcd7f9a7..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_lzw.c +++ /dev/null @@ -1,1129 +0,0 @@ -/* $Id: tif_lzw.c,v 1.38 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#include "tiffiop.h" -#ifdef LZW_SUPPORT -/* - * TIFF Library. - * Rev 5.0 Lempel-Ziv & Welch Compression Support - * - * This code is derived from the compress program whose code is - * derived from software contributed to Berkeley by James A. Woods, - * derived from original work by Spencer Thomas and Joseph Orost. - * - * The original Berkeley copyright notice appears below in its entirety. - */ -#include "tif_predict.h" - -#include - -/* - * NB: The 5.0 spec describes a different algorithm than Aldus - * implements. Specifically, Aldus does code length transitions - * one code earlier than should be done (for real LZW). - * Earlier versions of this library implemented the correct - * LZW algorithm, but emitted codes in a bit order opposite - * to the TIFF spec. Thus, to maintain compatibility w/ Aldus - * we interpret MSB-LSB ordered codes to be images written w/ - * old versions of this library, but otherwise adhere to the - * Aldus "off by one" algorithm. - * - * Future revisions to the TIFF spec are expected to "clarify this issue". - */ -#define LZW_COMPAT /* include backwards compatibility code */ -/* - * Each strip of data is supposed to be terminated by a CODE_EOI. - * If the following #define is included, the decoder will also - * check for end-of-strip w/o seeing this code. This makes the - * library more robust, but also slower. - */ -#define LZW_CHECKEOS /* include checks for strips w/o EOI code */ - -#define MAXCODE(n) ((1L<<(n))-1) -/* - * The TIFF spec specifies that encoded bit - * strings range from 9 to 12 bits. - */ -#define BITS_MIN 9 /* start with 9 bits */ -#define BITS_MAX 12 /* max of 12 bit strings */ -/* predefined codes */ -#define CODE_CLEAR 256 /* code to clear string table */ -#define CODE_EOI 257 /* end-of-information code */ -#define CODE_FIRST 258 /* first free code entry */ -#define CODE_MAX MAXCODE(BITS_MAX) -#define HSIZE 9001L /* 91% occupancy */ -#define HSHIFT (13-8) -#ifdef LZW_COMPAT -/* NB: +1024 is for compatibility with old files */ -#define CSIZE (MAXCODE(BITS_MAX)+1024L) -#else -#define CSIZE (MAXCODE(BITS_MAX)+1L) -#endif - -/* - * State block for each open TIFF file using LZW - * compression/decompression. Note that the predictor - * state block must be first in this data structure. - */ -typedef struct { - TIFFPredictorState predict; /* predictor super class */ - - unsigned short nbits; /* # of bits/code */ - unsigned short maxcode; /* maximum code for lzw_nbits */ - unsigned short free_ent; /* next free entry in hash table */ - long nextdata; /* next bits of i/o */ - long nextbits; /* # of valid bits in lzw_nextdata */ - - int rw_mode; /* preserve rw_mode from init */ -} LZWBaseState; - -#define lzw_nbits base.nbits -#define lzw_maxcode base.maxcode -#define lzw_free_ent base.free_ent -#define lzw_nextdata base.nextdata -#define lzw_nextbits base.nextbits - -/* - * Encoding-specific state. - */ -typedef uint16 hcode_t; /* codes fit in 16 bits */ -typedef struct { - long hash; - hcode_t code; -} hash_t; - -/* - * Decoding-specific state. - */ -typedef struct code_ent { - struct code_ent *next; - unsigned short length; /* string len, including this token */ - unsigned char value; /* data value */ - unsigned char firstchar; /* first token of string */ -} code_t; - -typedef int (*decodeFunc)(TIFF*, tidata_t, tsize_t, tsample_t); - -typedef struct { - LZWBaseState base; - - /* Decoding specific data */ - long dec_nbitsmask; /* lzw_nbits 1 bits, right adjusted */ - long dec_restart; /* restart count */ -#ifdef LZW_CHECKEOS - long dec_bitsleft; /* available bits in raw data */ -#endif - decodeFunc dec_decode; /* regular or backwards compatible */ - code_t* dec_codep; /* current recognized code */ - code_t* dec_oldcodep; /* previously recognized code */ - code_t* dec_free_entp; /* next free entry */ - code_t* dec_maxcodep; /* max available entry */ - code_t* dec_codetab; /* kept separate for small machines */ - - /* Encoding specific data */ - int enc_oldcode; /* last code encountered */ - long enc_checkpoint; /* point at which to clear table */ -#define CHECK_GAP 10000 /* enc_ratio check interval */ - long enc_ratio; /* current compression ratio */ - long enc_incount; /* (input) data bytes encoded */ - long enc_outcount; /* encoded (output) bytes */ - tidata_t enc_rawlimit; /* bound on tif_rawdata buffer */ - hash_t* enc_hashtab; /* kept separate for small machines */ -} LZWCodecState; - -#define LZWState(tif) ((LZWBaseState*) (tif)->tif_data) -#define DecoderState(tif) ((LZWCodecState*) LZWState(tif)) -#define EncoderState(tif) ((LZWCodecState*) LZWState(tif)) - -static int LZWDecode(TIFF*, tidata_t, tsize_t, tsample_t); -#ifdef LZW_COMPAT -static int LZWDecodeCompat(TIFF*, tidata_t, tsize_t, tsample_t); -#endif -static void cl_hash(LZWCodecState*); - -/* - * LZW Decoder. - */ - -#ifdef LZW_CHECKEOS -/* - * This check shouldn't be necessary because each - * strip is suppose to be terminated with CODE_EOI. - */ -#define NextCode(_tif, _sp, _bp, _code, _get) { \ - if ((_sp)->dec_bitsleft < nbits) { \ - TIFFWarningExt(_tif->tif_clientdata, _tif->tif_name, \ - "LZWDecode: Strip %d not terminated with EOI code", \ - _tif->tif_curstrip); \ - _code = CODE_EOI; \ - } else { \ - _get(_sp,_bp,_code); \ - (_sp)->dec_bitsleft -= nbits; \ - } \ -} -#else -#define NextCode(tif, sp, bp, code, get) get(sp, bp, code) -#endif - -static int -LZWSetupDecode(TIFF* tif) -{ - LZWCodecState* sp = DecoderState(tif); - static const char module[] = " LZWSetupDecode"; - int code; - - if ( sp == NULL ) - { - /* - * Allocate state block so tag methods have storage to record - * values. - */ - tif->tif_data = (tidata_t) _TIFFmalloc(sizeof(LZWCodecState)); - if (tif->tif_data == NULL) - { - TIFFErrorExt(tif->tif_clientdata, "LZWPreDecode", "No space for LZW state block"); - return (0); - } - - DecoderState(tif)->dec_codetab = NULL; - DecoderState(tif)->dec_decode = NULL; - - /* - * Setup predictor setup. - */ - (void) TIFFPredictorInit(tif); - - sp = DecoderState(tif); - } - - assert(sp != NULL); - - if (sp->dec_codetab == NULL) { - sp->dec_codetab = (code_t*)_TIFFmalloc(CSIZE*sizeof (code_t)); - if (sp->dec_codetab == NULL) { - TIFFErrorExt(tif->tif_clientdata, module, - "No space for LZW code table"); - return (0); - } - /* - * Pre-load the table. - */ - code = 255; - do { - sp->dec_codetab[code].value = code; - sp->dec_codetab[code].firstchar = code; - sp->dec_codetab[code].length = 1; - sp->dec_codetab[code].next = NULL; - } while (code--); - /* - * Zero-out the unused entries - */ - _TIFFmemset(&sp->dec_codetab[CODE_CLEAR], 0, - (CODE_FIRST - CODE_CLEAR) * sizeof (code_t)); - } - return (1); -} - -/* - * Setup state for decoding a strip. - */ -static int -LZWPreDecode(TIFF* tif, tsample_t s) -{ - LZWCodecState *sp = DecoderState(tif); - - (void) s; - assert(sp != NULL); - if ( sp->dec_codetab == NULL ) - { - tif->tif_setupdecode( tif ); - } - - /* - * Check for old bit-reversed codes. - */ - if (tif->tif_rawdata[0] == 0 && (tif->tif_rawdata[1] & 0x1)) { -#ifdef LZW_COMPAT - if (!sp->dec_decode) { - TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "Old-style LZW codes, convert file"); - /* - * Override default decoding methods with - * ones that deal with the old coding. - * Otherwise the predictor versions set - * above will call the compatibility routines - * through the dec_decode method. - */ - tif->tif_decoderow = LZWDecodeCompat; - tif->tif_decodestrip = LZWDecodeCompat; - tif->tif_decodetile = LZWDecodeCompat; - /* - * If doing horizontal differencing, must - * re-setup the predictor logic since we - * switched the basic decoder methods... - */ - (*tif->tif_setupdecode)(tif); - sp->dec_decode = LZWDecodeCompat; - } - sp->lzw_maxcode = MAXCODE(BITS_MIN); -#else /* !LZW_COMPAT */ - if (!sp->dec_decode) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Old-style LZW codes not supported"); - sp->dec_decode = LZWDecode; - } - return (0); -#endif/* !LZW_COMPAT */ - } else { - sp->lzw_maxcode = MAXCODE(BITS_MIN)-1; - sp->dec_decode = LZWDecode; - } - sp->lzw_nbits = BITS_MIN; - sp->lzw_nextbits = 0; - sp->lzw_nextdata = 0; - - sp->dec_restart = 0; - sp->dec_nbitsmask = MAXCODE(BITS_MIN); -#ifdef LZW_CHECKEOS - sp->dec_bitsleft = tif->tif_rawcc << 3; -#endif - sp->dec_free_entp = sp->dec_codetab + CODE_FIRST; - /* - * Zero entries that are not yet filled in. We do - * this to guard against bogus input data that causes - * us to index into undefined entries. If you can - * come up with a way to safely bounds-check input codes - * while decoding then you can remove this operation. - */ - _TIFFmemset(sp->dec_free_entp, 0, (CSIZE-CODE_FIRST)*sizeof (code_t)); - sp->dec_oldcodep = &sp->dec_codetab[-1]; - sp->dec_maxcodep = &sp->dec_codetab[sp->dec_nbitsmask-1]; - return (1); -} - -/* - * Decode a "hunk of data". - */ -#define GetNextCode(sp, bp, code) { \ - nextdata = (nextdata<<8) | *(bp)++; \ - nextbits += 8; \ - if (nextbits < nbits) { \ - nextdata = (nextdata<<8) | *(bp)++; \ - nextbits += 8; \ - } \ - code = (hcode_t)((nextdata >> (nextbits-nbits)) & nbitsmask); \ - nextbits -= nbits; \ -} - -static void -codeLoop(TIFF* tif) -{ - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecode: Bogus encoding, loop in the code table; scanline %d", - tif->tif_row); -} - -static int -LZWDecode(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) -{ - LZWCodecState *sp = DecoderState(tif); - char *op = (char*) op0; - long occ = (long) occ0; - char *tp; - unsigned char *bp; - hcode_t code; - int len; - long nbits, nextbits, nextdata, nbitsmask; - code_t *codep, *free_entp, *maxcodep, *oldcodep; - - (void) s; - assert(sp != NULL); - assert(sp->dec_codetab != NULL); - /* - * Restart interrupted output operation. - */ - if (sp->dec_restart) { - long residue; - - codep = sp->dec_codep; - residue = codep->length - sp->dec_restart; - if (residue > occ) { - /* - * Residue from previous decode is sufficient - * to satisfy decode request. Skip to the - * start of the decoded string, place decoded - * values in the output buffer, and return. - */ - sp->dec_restart += occ; - do { - codep = codep->next; - } while (--residue > occ && codep); - if (codep) { - tp = op + occ; - do { - *--tp = codep->value; - codep = codep->next; - } while (--occ && codep); - } - return (1); - } - /* - * Residue satisfies only part of the decode request. - */ - op += residue, occ -= residue; - tp = op; - do { - int t; - --tp; - t = codep->value; - codep = codep->next; - *tp = t; - } while (--residue && codep); - sp->dec_restart = 0; - } - - bp = (unsigned char *)tif->tif_rawcp; - nbits = sp->lzw_nbits; - nextdata = sp->lzw_nextdata; - nextbits = sp->lzw_nextbits; - nbitsmask = sp->dec_nbitsmask; - oldcodep = sp->dec_oldcodep; - free_entp = sp->dec_free_entp; - maxcodep = sp->dec_maxcodep; - - while (occ > 0) { - NextCode(tif, sp, bp, code, GetNextCode); - if (code == CODE_EOI) - break; - if (code == CODE_CLEAR) { - free_entp = sp->dec_codetab + CODE_FIRST; - _TIFFmemset(free_entp, 0, - (CSIZE - CODE_FIRST) * sizeof (code_t)); - nbits = BITS_MIN; - nbitsmask = MAXCODE(BITS_MIN); - maxcodep = sp->dec_codetab + nbitsmask-1; - NextCode(tif, sp, bp, code, GetNextCode); - if (code == CODE_EOI) - break; - if (code == CODE_CLEAR) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecode: Corrupted LZW table at scanline %d", - tif->tif_row); - return (0); - } - *op++ = (char)code, occ--; - oldcodep = sp->dec_codetab + code; - continue; - } - codep = sp->dec_codetab + code; - - /* - * Add the new entry to the code table. - */ - if (free_entp < &sp->dec_codetab[0] || - free_entp >= &sp->dec_codetab[CSIZE]) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecode: Corrupted LZW table at scanline %d", - tif->tif_row); - return (0); - } - - free_entp->next = oldcodep; - if (free_entp->next < &sp->dec_codetab[0] || - free_entp->next >= &sp->dec_codetab[CSIZE]) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecode: Corrupted LZW table at scanline %d", - tif->tif_row); - return (0); - } - free_entp->firstchar = free_entp->next->firstchar; - free_entp->length = free_entp->next->length+1; - free_entp->value = (codep < free_entp) ? - codep->firstchar : free_entp->firstchar; - if (++free_entp > maxcodep) { - if (++nbits > BITS_MAX) /* should not happen */ - nbits = BITS_MAX; - nbitsmask = MAXCODE(nbits); - maxcodep = sp->dec_codetab + nbitsmask-1; - } - oldcodep = codep; - if (code >= 256) { - /* - * Code maps to a string, copy string - * value to output (written in reverse). - */ - if(codep->length == 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecode: Wrong length of decoded string: " - "data probably corrupted at scanline %d", - tif->tif_row); - return (0); - } - if (codep->length > occ) { - /* - * String is too long for decode buffer, - * locate portion that will fit, copy to - * the decode buffer, and setup restart - * logic for the next decoding call. - */ - sp->dec_codep = codep; - do { - codep = codep->next; - } while (codep && codep->length > occ); - if (codep) { - sp->dec_restart = occ; - tp = op + occ; - do { - *--tp = codep->value; - codep = codep->next; - } while (--occ && codep); - if (codep) - codeLoop(tif); - } - break; - } - len = codep->length; - tp = op + len; - do { - int t; - --tp; - t = codep->value; - codep = codep->next; - *tp = t; - } while (codep && tp > op); - if (codep) { - codeLoop(tif); - break; - } - op += len, occ -= len; - } else - *op++ = (char)code, occ--; - } - - tif->tif_rawcp = (tidata_t) bp; - sp->lzw_nbits = (unsigned short) nbits; - sp->lzw_nextdata = nextdata; - sp->lzw_nextbits = nextbits; - sp->dec_nbitsmask = nbitsmask; - sp->dec_oldcodep = oldcodep; - sp->dec_free_entp = free_entp; - sp->dec_maxcodep = maxcodep; - - if (occ > 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecode: Not enough data at scanline %d (short %ld bytes)", - tif->tif_row, occ); - return (0); - } - return (1); -} - -#ifdef LZW_COMPAT -/* - * Decode a "hunk of data" for old images. - */ -#define GetNextCodeCompat(sp, bp, code) { \ - nextdata |= (unsigned long) *(bp)++ << nextbits; \ - nextbits += 8; \ - if (nextbits < nbits) { \ - nextdata |= (unsigned long) *(bp)++ << nextbits;\ - nextbits += 8; \ - } \ - code = (hcode_t)(nextdata & nbitsmask); \ - nextdata >>= nbits; \ - nextbits -= nbits; \ -} - -static int -LZWDecodeCompat(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) -{ - LZWCodecState *sp = DecoderState(tif); - char *op = (char*) op0; - long occ = (long) occ0; - char *tp; - unsigned char *bp; - int code, nbits; - long nextbits, nextdata, nbitsmask; - code_t *codep, *free_entp, *maxcodep, *oldcodep; - - (void) s; - assert(sp != NULL); - /* - * Restart interrupted output operation. - */ - if (sp->dec_restart) { - long residue; - - codep = sp->dec_codep; - residue = codep->length - sp->dec_restart; - if (residue > occ) { - /* - * Residue from previous decode is sufficient - * to satisfy decode request. Skip to the - * start of the decoded string, place decoded - * values in the output buffer, and return. - */ - sp->dec_restart += occ; - do { - codep = codep->next; - } while (--residue > occ); - tp = op + occ; - do { - *--tp = codep->value; - codep = codep->next; - } while (--occ); - return (1); - } - /* - * Residue satisfies only part of the decode request. - */ - op += residue, occ -= residue; - tp = op; - do { - *--tp = codep->value; - codep = codep->next; - } while (--residue); - sp->dec_restart = 0; - } - - bp = (unsigned char *)tif->tif_rawcp; - nbits = sp->lzw_nbits; - nextdata = sp->lzw_nextdata; - nextbits = sp->lzw_nextbits; - nbitsmask = sp->dec_nbitsmask; - oldcodep = sp->dec_oldcodep; - free_entp = sp->dec_free_entp; - maxcodep = sp->dec_maxcodep; - - while (occ > 0) { - NextCode(tif, sp, bp, code, GetNextCodeCompat); - if (code == CODE_EOI) - break; - if (code == CODE_CLEAR) { - free_entp = sp->dec_codetab + CODE_FIRST; - _TIFFmemset(free_entp, 0, - (CSIZE - CODE_FIRST) * sizeof (code_t)); - nbits = BITS_MIN; - nbitsmask = MAXCODE(BITS_MIN); - maxcodep = sp->dec_codetab + nbitsmask; - NextCode(tif, sp, bp, code, GetNextCodeCompat); - if (code == CODE_EOI) - break; - if (code == CODE_CLEAR) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecode: Corrupted LZW table at scanline %d", - tif->tif_row); - return (0); - } - *op++ = code, occ--; - oldcodep = sp->dec_codetab + code; - continue; - } - codep = sp->dec_codetab + code; - - /* - * Add the new entry to the code table. - */ - if (free_entp < &sp->dec_codetab[0] || - free_entp >= &sp->dec_codetab[CSIZE]) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecodeCompat: Corrupted LZW table at scanline %d", - tif->tif_row); - return (0); - } - - free_entp->next = oldcodep; - if (free_entp->next < &sp->dec_codetab[0] || - free_entp->next >= &sp->dec_codetab[CSIZE]) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecodeCompat: Corrupted LZW table at scanline %d", - tif->tif_row); - return (0); - } - free_entp->firstchar = free_entp->next->firstchar; - free_entp->length = free_entp->next->length+1; - free_entp->value = (codep < free_entp) ? - codep->firstchar : free_entp->firstchar; - if (++free_entp > maxcodep) { - if (++nbits > BITS_MAX) /* should not happen */ - nbits = BITS_MAX; - nbitsmask = MAXCODE(nbits); - maxcodep = sp->dec_codetab + nbitsmask; - } - oldcodep = codep; - if (code >= 256) { - char *op_orig = op; - /* - * Code maps to a string, copy string - * value to output (written in reverse). - */ - if(codep->length == 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecodeCompat: Wrong length of decoded " - "string: data probably corrupted at scanline %d", - tif->tif_row); - return (0); - } - if (codep->length > occ) { - /* - * String is too long for decode buffer, - * locate portion that will fit, copy to - * the decode buffer, and setup restart - * logic for the next decoding call. - */ - sp->dec_codep = codep; - do { - codep = codep->next; - } while (codep->length > occ); - sp->dec_restart = occ; - tp = op + occ; - do { - *--tp = codep->value; - codep = codep->next; - } while (--occ); - break; - } - op += codep->length, occ -= codep->length; - tp = op; - do { - *--tp = codep->value; - } while( (codep = codep->next) != NULL && tp > op_orig); - } else - *op++ = code, occ--; - } - - tif->tif_rawcp = (tidata_t) bp; - sp->lzw_nbits = nbits; - sp->lzw_nextdata = nextdata; - sp->lzw_nextbits = nextbits; - sp->dec_nbitsmask = nbitsmask; - sp->dec_oldcodep = oldcodep; - sp->dec_free_entp = free_entp; - sp->dec_maxcodep = maxcodep; - - if (occ > 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecodeCompat: Not enough data at scanline %d (short %ld bytes)", - tif->tif_row, occ); - return (0); - } - return (1); -} -#endif /* LZW_COMPAT */ - -/* - * LZW Encoding. - */ - -static int -LZWSetupEncode(TIFF* tif) -{ - LZWCodecState* sp = EncoderState(tif); - static const char module[] = "LZWSetupEncode"; - - assert(sp != NULL); - sp->enc_hashtab = (hash_t*) _TIFFmalloc(HSIZE*sizeof (hash_t)); - if (sp->enc_hashtab == NULL) { - TIFFErrorExt(tif->tif_clientdata, module, "No space for LZW hash table"); - return (0); - } - return (1); -} - -/* - * Reset encoding state at the start of a strip. - */ -static int -LZWPreEncode(TIFF* tif, tsample_t s) -{ - LZWCodecState *sp = EncoderState(tif); - - (void) s; - assert(sp != NULL); - - if ( sp->enc_hashtab == NULL ) - { - tif->tif_setupencode( tif ); - } - - sp->lzw_nbits = BITS_MIN; - sp->lzw_maxcode = MAXCODE(BITS_MIN); - sp->lzw_free_ent = CODE_FIRST; - sp->lzw_nextbits = 0; - sp->lzw_nextdata = 0; - sp->enc_checkpoint = CHECK_GAP; - sp->enc_ratio = 0; - sp->enc_incount = 0; - sp->enc_outcount = 0; - /* - * The 4 here insures there is space for 2 max-sized - * codes in LZWEncode and LZWPostDecode. - */ - sp->enc_rawlimit = tif->tif_rawdata + tif->tif_rawdatasize-1 - 4; - cl_hash(sp); /* clear hash table */ - sp->enc_oldcode = (hcode_t) -1; /* generates CODE_CLEAR in LZWEncode */ - return (1); -} - -#define CALCRATIO(sp, rat) { \ - if (incount > 0x007fffff) { /* NB: shift will overflow */\ - rat = outcount >> 8; \ - rat = (rat == 0 ? 0x7fffffff : incount/rat); \ - } else \ - rat = (incount<<8) / outcount; \ -} -#define PutNextCode(op, c) { \ - nextdata = (nextdata << nbits) | c; \ - nextbits += nbits; \ - *op++ = (unsigned char)(nextdata >> (nextbits-8)); \ - nextbits -= 8; \ - if (nextbits >= 8) { \ - *op++ = (unsigned char)(nextdata >> (nextbits-8)); \ - nextbits -= 8; \ - } \ - outcount += nbits; \ -} - -/* - * Encode a chunk of pixels. - * - * Uses an open addressing double hashing (no chaining) on the - * prefix code/next character combination. We do a variant of - * Knuth's algorithm D (vol. 3, sec. 6.4) along with G. Knott's - * relatively-prime secondary probe. Here, the modular division - * first probe is gives way to a faster exclusive-or manipulation. - * Also do block compression with an adaptive reset, whereby the - * code table is cleared when the compression ratio decreases, - * but after the table fills. The variable-length output codes - * are re-sized at this point, and a CODE_CLEAR is generated - * for the decoder. - */ -static int -LZWEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - register LZWCodecState *sp = EncoderState(tif); - register long fcode; - register hash_t *hp; - register int h, c; - hcode_t ent; - long disp; - long incount, outcount, checkpoint; - long nextdata, nextbits; - int free_ent, maxcode, nbits; - tidata_t op, limit; - - (void) s; - if (sp == NULL) - return (0); - - assert(sp->enc_hashtab != NULL); - - /* - * Load local state. - */ - incount = sp->enc_incount; - outcount = sp->enc_outcount; - checkpoint = sp->enc_checkpoint; - nextdata = sp->lzw_nextdata; - nextbits = sp->lzw_nextbits; - free_ent = sp->lzw_free_ent; - maxcode = sp->lzw_maxcode; - nbits = sp->lzw_nbits; - op = tif->tif_rawcp; - limit = sp->enc_rawlimit; - ent = sp->enc_oldcode; - - if (ent == (hcode_t) -1 && cc > 0) { - /* - * NB: This is safe because it can only happen - * at the start of a strip where we know there - * is space in the data buffer. - */ - PutNextCode(op, CODE_CLEAR); - ent = *bp++; cc--; incount++; - } - while (cc > 0) { - c = *bp++; cc--; incount++; - fcode = ((long)c << BITS_MAX) + ent; - h = (c << HSHIFT) ^ ent; /* xor hashing */ -#ifdef _WINDOWS - /* - * Check hash index for an overflow. - */ - if (h >= HSIZE) - h -= HSIZE; -#endif - hp = &sp->enc_hashtab[h]; - if (hp->hash == fcode) { - ent = hp->code; - continue; - } - if (hp->hash >= 0) { - /* - * Primary hash failed, check secondary hash. - */ - disp = HSIZE - h; - if (h == 0) - disp = 1; - do { - /* - * Avoid pointer arithmetic 'cuz of - * wraparound problems with segments. - */ - if ((h -= disp) < 0) - h += HSIZE; - hp = &sp->enc_hashtab[h]; - if (hp->hash == fcode) { - ent = hp->code; - goto hit; - } - } while (hp->hash >= 0); - } - /* - * New entry, emit code and add to table. - */ - /* - * Verify there is space in the buffer for the code - * and any potential Clear code that might be emitted - * below. The value of limit is setup so that there - * are at least 4 bytes free--room for 2 codes. - */ - if (op > limit) { - tif->tif_rawcc = (tsize_t)(op - tif->tif_rawdata); - TIFFFlushData1(tif); - op = tif->tif_rawdata; - } - PutNextCode(op, ent); - ent = c; - hp->code = free_ent++; - hp->hash = fcode; - if (free_ent == CODE_MAX-1) { - /* table is full, emit clear code and reset */ - cl_hash(sp); - sp->enc_ratio = 0; - incount = 0; - outcount = 0; - free_ent = CODE_FIRST; - PutNextCode(op, CODE_CLEAR); - nbits = BITS_MIN; - maxcode = MAXCODE(BITS_MIN); - } else { - /* - * If the next entry is going to be too big for - * the code size, then increase it, if possible. - */ - if (free_ent > maxcode) { - nbits++; - assert(nbits <= BITS_MAX); - maxcode = (int) MAXCODE(nbits); - } else if (incount >= checkpoint) { - long rat; - /* - * Check compression ratio and, if things seem - * to be slipping, clear the hash table and - * reset state. The compression ratio is a - * 24+8-bit fractional number. - */ - checkpoint = incount+CHECK_GAP; - CALCRATIO(sp, rat); - if (rat <= sp->enc_ratio) { - cl_hash(sp); - sp->enc_ratio = 0; - incount = 0; - outcount = 0; - free_ent = CODE_FIRST; - PutNextCode(op, CODE_CLEAR); - nbits = BITS_MIN; - maxcode = MAXCODE(BITS_MIN); - } else - sp->enc_ratio = rat; - } - } - hit: - ; - } - - /* - * Restore global state. - */ - sp->enc_incount = incount; - sp->enc_outcount = outcount; - sp->enc_checkpoint = checkpoint; - sp->enc_oldcode = ent; - sp->lzw_nextdata = nextdata; - sp->lzw_nextbits = nextbits; - sp->lzw_free_ent = free_ent; - sp->lzw_maxcode = maxcode; - sp->lzw_nbits = nbits; - tif->tif_rawcp = op; - return (1); -} - -/* - * Finish off an encoded strip by flushing the last - * string and tacking on an End Of Information code. - */ -static int -LZWPostEncode(TIFF* tif) -{ - register LZWCodecState *sp = EncoderState(tif); - tidata_t op = tif->tif_rawcp; - long nextbits = sp->lzw_nextbits; - long nextdata = sp->lzw_nextdata; - long outcount = sp->enc_outcount; - int nbits = sp->lzw_nbits; - - if (op > sp->enc_rawlimit) { - tif->tif_rawcc = (tsize_t)(op - tif->tif_rawdata); - TIFFFlushData1(tif); - op = tif->tif_rawdata; - } - if (sp->enc_oldcode != (hcode_t) -1) { - PutNextCode(op, sp->enc_oldcode); - sp->enc_oldcode = (hcode_t) -1; - } - PutNextCode(op, CODE_EOI); - if (nextbits > 0) - *op++ = (unsigned char)(nextdata << (8-nextbits)); - tif->tif_rawcc = (tsize_t)(op - tif->tif_rawdata); - return (1); -} - -/* - * Reset encoding hash table. - */ -static void -cl_hash(LZWCodecState* sp) -{ - register hash_t *hp = &sp->enc_hashtab[HSIZE-1]; - register long i = HSIZE-8; - - do { - i -= 8; - hp[-7].hash = -1; - hp[-6].hash = -1; - hp[-5].hash = -1; - hp[-4].hash = -1; - hp[-3].hash = -1; - hp[-2].hash = -1; - hp[-1].hash = -1; - hp[ 0].hash = -1; - hp -= 8; - } while (i >= 0); - for (i += 8; i > 0; i--, hp--) - hp->hash = -1; -} - -static void -LZWCleanup(TIFF* tif) -{ - (void)TIFFPredictorCleanup(tif); - - assert(tif->tif_data != 0); - - if (DecoderState(tif)->dec_codetab) - _TIFFfree(DecoderState(tif)->dec_codetab); - - if (EncoderState(tif)->enc_hashtab) - _TIFFfree(EncoderState(tif)->enc_hashtab); - - _TIFFfree(tif->tif_data); - tif->tif_data = NULL; - - _TIFFSetDefaultCompressionState(tif); -} - -int -TIFFInitLZW(TIFF* tif, int scheme) -{ - assert(scheme == COMPRESSION_LZW); - /* - * Allocate state block so tag methods have storage to record values. - */ - tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (LZWCodecState)); - if (tif->tif_data == NULL) - goto bad; - DecoderState(tif)->dec_codetab = NULL; - DecoderState(tif)->dec_decode = NULL; - EncoderState(tif)->enc_hashtab = NULL; - LZWState(tif)->rw_mode = tif->tif_mode; - - /* - * Install codec methods. - */ - tif->tif_setupdecode = LZWSetupDecode; - tif->tif_predecode = LZWPreDecode; - tif->tif_decoderow = LZWDecode; - tif->tif_decodestrip = LZWDecode; - tif->tif_decodetile = LZWDecode; - tif->tif_setupencode = LZWSetupEncode; - tif->tif_preencode = LZWPreEncode; - tif->tif_postencode = LZWPostEncode; - tif->tif_encoderow = LZWEncode; - tif->tif_encodestrip = LZWEncode; - tif->tif_encodetile = LZWEncode; - tif->tif_cleanup = LZWCleanup; - /* - * Setup predictor setup. - */ - (void) TIFFPredictorInit(tif); - return (1); -bad: - TIFFErrorExt(tif->tif_clientdata, "TIFFInitLZW", - "No space for LZW state block"); - return (0); -} - -/* - * Copyright (c) 1985, 1986 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * James A. Woods, derived from original work by Spencer Thomas - * and Joseph Orost. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by the University of California, Berkeley. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ -#endif /* LZW_SUPPORT */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_msdos.c b/plugins/AdvaImg/src/LibTIFF/tif_msdos.c deleted file mode 100644 index 884981fa49..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_msdos.c +++ /dev/null @@ -1,193 +0,0 @@ -/* $Header: /cvsroot/freeimage/FreeImage/Source/LibTIFF/tif_msdos.c,v 1.35 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library MSDOS-specific Routines. - */ -#if defined(__WATCOMC__) || defined(__BORLANDC__) || defined(_MSC_VER) -#include /* for open, close, etc. function prototypes */ -#include -#endif -#include "tiffiop.h" - -static tsize_t -_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return (read((int) fd, buf, size)); -} - -static tsize_t -_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return (write((int) fd, buf, size)); -} - -static toff_t -_tiffSeekProc(thandle_t fd, toff_t off, int whence) -{ - return (lseek((int) fd, (off_t) off, whence)); -} - -static int -_tiffCloseProc(thandle_t fd) -{ - return (close((int) fd)); -} - -#include - -static toff_t -_tiffSizeProc(thandle_t fd) -{ - struct stat sb; - return (fstat((int) fd, &sb) < 0 ? 0 : sb.st_size); -} - -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - return (0); -} - -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ -} - -/* - * Open a TIFF file descriptor for read/writing. - */ -TIFF* -TIFFFdOpen(int fd, const char* name, const char* mode) -{ - TIFF* tif; - - tif = TIFFClientOpen(name, mode, - (void*) fd, - _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, - _tiffSizeProc, _tiffMapProc, _tiffUnmapProc); - if (tif) - tif->tif_fd = fd; - return (tif); -} - -/* - * Open a TIFF file for read/writing. - */ -TIFF* -TIFFOpen(const char* name, const char* mode) -{ - static const char module[] = "TIFFOpen"; - int m, fd; - TIFF *ret; - - m = _TIFFgetMode(mode, module); - if (m == -1) - return ((TIFF*)0); - fd = open(name, m|O_BINARY, 0666); - if (fd < 0) { - TIFFErrorExt(0, module, "%s: Cannot open", name); - return ((TIFF*)0); - } - return (TIFFFdOpen(fd, name, mode)); - - ret = TIFFFdOpen(fd, name, mode); - - if (ret == NULL) close(fd); - - return ret; -} - -#ifdef __GNUC__ -extern char* malloc(); -extern char* realloc(); -#else -#include -#endif - -tdata_t -_TIFFmalloc(tsize_t s) -{ - return (malloc((size_t) s)); -} - -void -_TIFFfree(tdata_t p) -{ - free(p); -} - -tdata_t -_TIFFrealloc(tdata_t p, tsize_t s) -{ - return (realloc(p, (size_t) s)); -} - -void -_TIFFmemset(tdata_t p, int v, tsize_t c) -{ - memset(p, v, (size_t) c); -} - -void -_TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c) -{ - memcpy(d, s, (size_t) c); -} - -int -_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) -{ - return (memcmp(p1, p2, (size_t) c)); -} - -static void -msdosWarningHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - fprintf(stderr, "Warning, "); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFwarningHandler = msdosWarningHandler; - -static void -msdosErrorHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFerrorHandler = msdosErrorHandler; -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_next.c b/plugins/AdvaImg/src/LibTIFF/tif_next.c deleted file mode 100644 index 3fa6406e68..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_next.c +++ /dev/null @@ -1,154 +0,0 @@ -/* $Id: tif_next.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#include "tiffiop.h" -#ifdef NEXT_SUPPORT -/* - * TIFF Library. - * - * NeXT 2-bit Grey Scale Compression Algorithm Support - */ - -#define SETPIXEL(op, v) { \ - switch (npixels++ & 3) { \ - case 0: op[0] = (unsigned char) ((v) << 6); break; \ - case 1: op[0] |= (v) << 4; break; \ - case 2: op[0] |= (v) << 2; break; \ - case 3: *op++ |= (v); break; \ - } \ -} - -#define LITERALROW 0x00 -#define LITERALSPAN 0x40 -#define WHITE ((1<<2)-1) - -static int -NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) -{ - unsigned char *bp, *op; - tsize_t cc; - tidata_t row; - tsize_t scanline, n; - - (void) s; - /* - * Each scanline is assumed to start off as all - * white (we assume a PhotometricInterpretation - * of ``min-is-black''). - */ - for (op = buf, cc = occ; cc-- > 0;) - *op++ = 0xff; - - bp = (unsigned char *)tif->tif_rawcp; - cc = tif->tif_rawcc; - scanline = tif->tif_scanlinesize; - for (row = buf; occ > 0; occ -= scanline, row += scanline) { - n = *bp++, cc--; - switch (n) { - case LITERALROW: - /* - * The entire scanline is given as literal values. - */ - if (cc < scanline) - goto bad; - _TIFFmemcpy(row, bp, scanline); - bp += scanline; - cc -= scanline; - break; - case LITERALSPAN: { - tsize_t off; - /* - * The scanline has a literal span that begins at some - * offset. - */ - off = (bp[0] * 256) + bp[1]; - n = (bp[2] * 256) + bp[3]; - if (cc < 4+n || off+n > scanline) - goto bad; - _TIFFmemcpy(row+off, bp+4, n); - bp += 4+n; - cc -= 4+n; - break; - } - default: { - uint32 npixels = 0, grey; - uint32 imagewidth = tif->tif_dir.td_imagewidth; - - /* - * The scanline is composed of a sequence of constant - * color ``runs''. We shift into ``run mode'' and - * interpret bytes as codes of the form - * until we've filled the scanline. - */ - op = row; - for (;;) { - grey = (n>>6) & 0x3; - n &= 0x3f; - /* - * Ensure the run does not exceed the scanline - * bounds, potentially resulting in a security - * issue. - */ - while (n-- > 0 && npixels < imagewidth) - SETPIXEL(op, grey); - if (npixels >= imagewidth) - break; - if (cc == 0) - goto bad; - n = *bp++, cc--; - } - break; - } - } - } - tif->tif_rawcp = (tidata_t) bp; - tif->tif_rawcc = cc; - return (1); -bad: - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "NeXTDecode: Not enough data for scanline %ld", - (long) tif->tif_row); - return (0); -} - -int -TIFFInitNeXT(TIFF* tif, int scheme) -{ - (void) scheme; - tif->tif_decoderow = NeXTDecode; - tif->tif_decodestrip = NeXTDecode; - tif->tif_decodetile = NeXTDecode; - return (1); -} -#endif /* NEXT_SUPPORT */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_ojpeg.c b/plugins/AdvaImg/src/LibTIFF/tif_ojpeg.c deleted file mode 100644 index ad339afc1b..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_ojpeg.c +++ /dev/null @@ -1,2448 +0,0 @@ -/* $Id: tif_ojpeg.c,v 1.36 2011/04/10 17:14:09 drolon Exp $ */ - -/* WARNING: The type of JPEG encapsulation defined by the TIFF Version 6.0 - specification is now totally obsolete and deprecated for new applications and - images. This file was was created solely in order to read unconverted images - still present on some users' computer systems. It will never be extended - to write such files. Writing new-style JPEG compressed TIFFs is implemented - in tif_jpeg.c. - - The code is carefully crafted to robustly read all gathered JPEG-in-TIFF - testfiles, and anticipate as much as possible all other... But still, it may - fail on some. If you encounter problems, please report them on the TIFF - mailing list and/or to Joris Van Damme . - - Please read the file called "TIFF Technical Note #2" if you need to be - convinced this compression scheme is bad and breaks TIFF. That document - is linked to from the LibTiff site - and from AWare Systems' TIFF section - . It is also absorbed - in Adobe's specification supplements, marked "draft" up to this day, but - supported by the TIFF community. - - This file interfaces with Release 6B of the JPEG Library written by the - Independent JPEG Group. Previous versions of this file required a hack inside - the LibJpeg library. This version no longer requires that. Remember to - remove the hack if you update from the old version. - - Copyright (c) Joris Van Damme - Copyright (c) AWare Systems - - The licence agreement for this file is the same as the rest of the LibTiff - library. - - IN NO EVENT SHALL JORIS VAN DAMME OR AWARE SYSTEMS BE LIABLE FOR - ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - OF THIS SOFTWARE. - - Joris Van Damme and/or AWare Systems may be available for custom - developement. If you like what you see, and need anything similar or related, - contact . -*/ - -/* What is what, and what is not? - - This decoder starts with an input stream, that is essentially the JpegInterchangeFormat - stream, if any, followed by the strile data, if any. This stream is read in - OJPEGReadByte and related functions. - - It analyzes the start of this stream, until it encounters non-marker data, i.e. - compressed image data. Some of the header markers it sees have no actual content, - like the SOI marker, and APP/COM markers that really shouldn't even be there. Some - other markers do have content, and the valuable bits and pieces of information - in these markers are saved, checking all to verify that the stream is more or - less within expected bounds. This happens inside the OJPEGReadHeaderInfoSecStreamXxx - functions. - - Some OJPEG imagery contains no valid JPEG header markers. This situation is picked - up on if we've seen no SOF marker when we're at the start of the compressed image - data. In this case, the tables are read from JpegXxxTables tags, and the other - bits and pieces of information is initialized to its most basic value. This is - implemented in the OJPEGReadHeaderInfoSecTablesXxx functions. - - When this is complete, a good and valid JPEG header can be assembled, and this is - passed through to LibJpeg. When that's done, the remainder of the input stream, i.e. - the compressed image data, can be passed through unchanged. This is done in - OJPEGWriteStream functions. - - LibTiff rightly expects to know the subsampling values before decompression. Just like - in new-style JPEG-in-TIFF, though, or even more so, actually, the YCbCrsubsampling - tag is notoriously unreliable. To correct these tag values with the ones inside - the JPEG stream, the first part of the input stream is pre-scanned in - OJPEGSubsamplingCorrect, making no note of any other data, reporting no warnings - or errors, up to the point where either these values are read, or it's clear they - aren't there. This means that some of the data is read twice, but we feel speed - in correcting these values is important enough to warrant this sacrifice. Allthough - there is currently no define or other configuration mechanism to disable this behaviour, - the actual header scanning is build to robustly respond with error report if it - should encounter an uncorrected mismatch of subsampling values. See - OJPEGReadHeaderInfoSecStreamSof. - - The restart interval and restart markers are the most tricky part... The restart - interval can be specified in a tag. It can also be set inside the input JPEG stream. - It can be used inside the input JPEG stream. If reading from strile data, we've - consistenly discovered the need to insert restart markers in between the different - striles, as is also probably the most likely interpretation of the original TIFF 6.0 - specification. With all this setting of interval, and actual use of markers that is not - predictable at the time of valid JPEG header assembly, the restart thing may turn - out the Achilles heel of this implementation. Fortunately, most OJPEG writer vendors - succeed in reading back what they write, which may be the reason why we've been able - to discover ways that seem to work. - - Some special provision is made for planarconfig separate OJPEG files. These seem - to consistently contain header info, a SOS marker, a plane, SOS marker, plane, SOS, - and plane. This may or may not be a valid JPEG configuration, we don't know and don't - care. We want LibTiff to be able to access the planes individually, without huge - buffering inside LibJpeg, anyway. So we compose headers to feed to LibJpeg, in this - case, that allow us to pass a single plane such that LibJpeg sees a valid - single-channel JPEG stream. Locating subsequent SOS markers, and thus subsequent - planes, is done inside OJPEGReadSecondarySos. - - The benefit of the scheme is... that it works, basically. We know of no other that - does. It works without checking software tag, or otherwise going about things in an - OJPEG flavor specific manner. Instead, it is a single scheme, that covers the cases - with and without JpegInterchangeFormat, with and without striles, with part of - the header in JpegInterchangeFormat and remainder in first strile, etc. It is forgiving - and robust, may likely work with OJPEG flavors we've not seen yet, and makes most out - of the data. - - Another nice side-effect is that a complete JPEG single valid stream is build if - planarconfig is not separate (vast majority). We may one day use that to build - converters to JPEG, and/or to new-style JPEG compression inside TIFF. - - A dissadvantage is the lack of random access to the individual striles. This is the - reason for much of the complicated restart-and-position stuff inside OJPEGPreDecode. - Applications would do well accessing all striles in order, as this will result in - a single sequential scan of the input stream, and no restarting of LibJpeg decoding - session. -*/ - - -#include "tiffiop.h" -#ifdef OJPEG_SUPPORT - -/* Configuration defines here are: - * JPEG_ENCAP_EXTERNAL: The normal way to call libjpeg, uses longjump. In some environments, - * like eg LibTiffDelphi, this is not possible. For this reason, the actual calls to - * libjpeg, with longjump stuff, are encapsulated in dedicated functions. When - * JPEG_ENCAP_EXTERNAL is defined, these encapsulating functions are declared external - * to this unit, and can be defined elsewhere to use stuff other then longjump. - * The default mode, without JPEG_ENCAP_EXTERNAL, implements the call encapsulators - * here, internally, with normal longjump. - * SETJMP, LONGJMP, JMP_BUF: On some machines/environments a longjump equivalent is - * conviniently available, but still it may be worthwhile to use _setjmp or sigsetjmp - * in place of plain setjmp. These macros will make it easier. It is useless - * to fiddle with these if you define JPEG_ENCAP_EXTERNAL. - * OJPEG_BUFFER: Define the size of the desired buffer here. Should be small enough so as to guarantee - * instant processing, optimal streaming and optimal use of processor cache, but also big - * enough so as to not result in significant call overhead. It should be at least a few - * bytes to accomodate some structures (this is verified in asserts), but it would not be - * sensible to make it this small anyway, and it should be at most 64K since it is indexed - * with uint16. We recommend 2K. - * EGYPTIANWALK: You could also define EGYPTIANWALK here, but it is not used anywhere and has - * absolutely no effect. That is why most people insist the EGYPTIANWALK is a bit silly. - */ - -/* #define LIBJPEG_ENCAP_EXTERNAL */ -#define SETJMP(jbuf) setjmp(jbuf) -#define LONGJMP(jbuf,code) longjmp(jbuf,code) -#define JMP_BUF jmp_buf -#define OJPEG_BUFFER 2048 -/* define EGYPTIANWALK */ - -#define JPEG_MARKER_SOF0 0xC0 -#define JPEG_MARKER_SOF1 0xC1 -#define JPEG_MARKER_SOF3 0xC3 -#define JPEG_MARKER_DHT 0xC4 -#define JPEG_MARKER_RST0 0XD0 -#define JPEG_MARKER_SOI 0xD8 -#define JPEG_MARKER_EOI 0xD9 -#define JPEG_MARKER_SOS 0xDA -#define JPEG_MARKER_DQT 0xDB -#define JPEG_MARKER_DRI 0xDD -#define JPEG_MARKER_APP0 0xE0 -#define JPEG_MARKER_COM 0xFE - -#define FIELD_OJPEG_JPEGINTERCHANGEFORMAT (FIELD_CODEC+0) -#define FIELD_OJPEG_JPEGINTERCHANGEFORMATLENGTH (FIELD_CODEC+1) -#define FIELD_OJPEG_JPEGQTABLES (FIELD_CODEC+2) -#define FIELD_OJPEG_JPEGDCTABLES (FIELD_CODEC+3) -#define FIELD_OJPEG_JPEGACTABLES (FIELD_CODEC+4) -#define FIELD_OJPEG_JPEGPROC (FIELD_CODEC+5) -#define FIELD_OJPEG_JPEGRESTARTINTERVAL (FIELD_CODEC+6) -#define FIELD_OJPEG_COUNT 7 - -static const TIFFFieldInfo ojpeg_field_info[] = { - {TIFFTAG_JPEGIFOFFSET,1,1,TIFF_LONG,FIELD_OJPEG_JPEGINTERCHANGEFORMAT,TRUE,FALSE,"JpegInterchangeFormat"}, - {TIFFTAG_JPEGIFBYTECOUNT,1,1,TIFF_LONG,FIELD_OJPEG_JPEGINTERCHANGEFORMATLENGTH,TRUE,FALSE,"JpegInterchangeFormatLength"}, - {TIFFTAG_JPEGQTABLES,TIFF_VARIABLE,TIFF_VARIABLE,TIFF_LONG,FIELD_OJPEG_JPEGQTABLES,FALSE,TRUE,"JpegQTables"}, - {TIFFTAG_JPEGDCTABLES,TIFF_VARIABLE,TIFF_VARIABLE,TIFF_LONG,FIELD_OJPEG_JPEGDCTABLES,FALSE,TRUE,"JpegDcTables"}, - {TIFFTAG_JPEGACTABLES,TIFF_VARIABLE,TIFF_VARIABLE,TIFF_LONG,FIELD_OJPEG_JPEGACTABLES,FALSE,TRUE,"JpegAcTables"}, - {TIFFTAG_JPEGPROC,1,1,TIFF_SHORT,FIELD_OJPEG_JPEGPROC,FALSE,FALSE,"JpegProc"}, - {TIFFTAG_JPEGRESTARTINTERVAL,1,1,TIFF_SHORT,FIELD_OJPEG_JPEGRESTARTINTERVAL,FALSE,FALSE,"JpegRestartInterval"}, -}; - -#ifndef LIBJPEG_ENCAP_EXTERNAL -#include -#endif - -#include "../LibJPEG/jpeglib.h" -#include "../LibJPEG/jerror.h" - -typedef struct jpeg_error_mgr jpeg_error_mgr; -typedef struct jpeg_common_struct jpeg_common_struct; -typedef struct jpeg_decompress_struct jpeg_decompress_struct; -typedef struct jpeg_source_mgr jpeg_source_mgr; - -typedef enum { - osibsNotSetYet, - osibsJpegInterchangeFormat, - osibsStrile, - osibsEof -} OJPEGStateInBufferSource; - -typedef enum { - ososSoi, - ososQTable0,ososQTable1,ososQTable2,ososQTable3, - ososDcTable0,ososDcTable1,ososDcTable2,ososDcTable3, - ososAcTable0,ososAcTable1,ososAcTable2,ososAcTable3, - ososDri, - ososSof, - ososSos, - ososCompressed, - ososRst, - ososEoi -} OJPEGStateOutState; - -typedef struct { - TIFF* tif; - #ifndef LIBJPEG_ENCAP_EXTERNAL - JMP_BUF exit_jmpbuf; - #endif - TIFFVGetMethod vgetparent; - TIFFVSetMethod vsetparent; - toff_t file_size; - uint32 image_width; - uint32 image_length; - uint32 strile_width; - uint32 strile_length; - uint32 strile_length_total; - uint8 samples_per_pixel; - uint8 plane_sample_offset; - uint8 samples_per_pixel_per_plane; - toff_t jpeg_interchange_format; - toff_t jpeg_interchange_format_length; - uint8 jpeg_proc; - uint8 subsamplingcorrect; - uint8 subsamplingcorrect_done; - uint8 subsampling_tag; - uint8 subsampling_hor; - uint8 subsampling_ver; - uint8 subsampling_force_desubsampling_inside_decompression; - uint8 qtable_offset_count; - uint8 dctable_offset_count; - uint8 actable_offset_count; - toff_t qtable_offset[3]; - toff_t dctable_offset[3]; - toff_t actable_offset[3]; - uint8* qtable[4]; - uint8* dctable[4]; - uint8* actable[4]; - uint16 restart_interval; - uint8 restart_index; - uint8 sof_log; - uint8 sof_marker_id; - uint32 sof_x; - uint32 sof_y; - uint8 sof_c[3]; - uint8 sof_hv[3]; - uint8 sof_tq[3]; - uint8 sos_cs[3]; - uint8 sos_tda[3]; - struct { - uint8 log; - OJPEGStateInBufferSource in_buffer_source; - tstrile_t in_buffer_next_strile; - toff_t in_buffer_file_pos; - toff_t in_buffer_file_togo; - } sos_end[3]; - uint8 readheader_done; - uint8 writeheader_done; - tsample_t write_cursample; - tstrile_t write_curstrile; - uint8 libjpeg_session_active; - uint8 libjpeg_jpeg_query_style; - jpeg_error_mgr libjpeg_jpeg_error_mgr; - jpeg_decompress_struct libjpeg_jpeg_decompress_struct; - jpeg_source_mgr libjpeg_jpeg_source_mgr; - uint8 subsampling_convert_log; - uint32 subsampling_convert_ylinelen; - uint32 subsampling_convert_ylines; - uint32 subsampling_convert_clinelen; - uint32 subsampling_convert_clines; - uint32 subsampling_convert_ybuflen; - uint32 subsampling_convert_cbuflen; - uint32 subsampling_convert_ycbcrbuflen; - uint8* subsampling_convert_ycbcrbuf; - uint8* subsampling_convert_ybuf; - uint8* subsampling_convert_cbbuf; - uint8* subsampling_convert_crbuf; - uint32 subsampling_convert_ycbcrimagelen; - uint8** subsampling_convert_ycbcrimage; - uint32 subsampling_convert_clinelenout; - uint32 subsampling_convert_state; - uint32 bytes_per_line; /* if the codec outputs subsampled data, a 'line' in bytes_per_line */ - uint32 lines_per_strile; /* and lines_per_strile means subsampling_ver desubsampled rows */ - OJPEGStateInBufferSource in_buffer_source; - tstrile_t in_buffer_next_strile; - tstrile_t in_buffer_strile_count; - toff_t in_buffer_file_pos; - uint8 in_buffer_file_pos_log; - toff_t in_buffer_file_togo; - uint16 in_buffer_togo; - uint8* in_buffer_cur; - uint8 in_buffer[OJPEG_BUFFER]; - OJPEGStateOutState out_state; - uint8 out_buffer[OJPEG_BUFFER]; - uint8* skip_buffer; -} OJPEGState; - -static int OJPEGVGetField(TIFF* tif, ttag_t tag, va_list ap); -static int OJPEGVSetField(TIFF* tif, ttag_t tag, va_list ap); -static void OJPEGPrintDir(TIFF* tif, FILE* fd, long flags); - -static int OJPEGSetupDecode(TIFF* tif); -static int OJPEGPreDecode(TIFF* tif, tsample_t s); -static int OJPEGPreDecodeSkipRaw(TIFF* tif); -static int OJPEGPreDecodeSkipScanlines(TIFF* tif); -static int OJPEGDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s); -static int OJPEGDecodeRaw(TIFF* tif, tidata_t buf, tsize_t cc); -static int OJPEGDecodeScanlines(TIFF* tif, tidata_t buf, tsize_t cc); -static void OJPEGPostDecode(TIFF* tif, tidata_t buf, tsize_t cc); -static int OJPEGSetupEncode(TIFF* tif); -static int OJPEGPreEncode(TIFF* tif, tsample_t s); -static int OJPEGEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s); -static int OJPEGPostEncode(TIFF* tif); -static void OJPEGCleanup(TIFF* tif); - -static void OJPEGSubsamplingCorrect(TIFF* tif); -static int OJPEGReadHeaderInfo(TIFF* tif); -static int OJPEGReadSecondarySos(TIFF* tif, tsample_t s); -static int OJPEGWriteHeaderInfo(TIFF* tif); -static void OJPEGLibjpegSessionAbort(TIFF* tif); - -static int OJPEGReadHeaderInfoSec(TIFF* tif); -static int OJPEGReadHeaderInfoSecStreamDri(TIFF* tif); -static int OJPEGReadHeaderInfoSecStreamDqt(TIFF* tif); -static int OJPEGReadHeaderInfoSecStreamDht(TIFF* tif); -static int OJPEGReadHeaderInfoSecStreamSof(TIFF* tif, uint8 marker_id); -static int OJPEGReadHeaderInfoSecStreamSos(TIFF* tif); -static int OJPEGReadHeaderInfoSecTablesQTable(TIFF* tif); -static int OJPEGReadHeaderInfoSecTablesDcTable(TIFF* tif); -static int OJPEGReadHeaderInfoSecTablesAcTable(TIFF* tif); - -static int OJPEGReadBufferFill(OJPEGState* sp); -static int OJPEGReadByte(OJPEGState* sp, uint8* byte); -static int OJPEGReadBytePeek(OJPEGState* sp, uint8* byte); -static void OJPEGReadByteAdvance(OJPEGState* sp); -static int OJPEGReadWord(OJPEGState* sp, uint16* word); -static int OJPEGReadBlock(OJPEGState* sp, uint16 len, void* mem); -static void OJPEGReadSkip(OJPEGState* sp, uint16 len); - -static int OJPEGWriteStream(TIFF* tif, void** mem, uint32* len); -static void OJPEGWriteStreamSoi(TIFF* tif, void** mem, uint32* len); -static void OJPEGWriteStreamQTable(TIFF* tif, uint8 table_index, void** mem, uint32* len); -static void OJPEGWriteStreamDcTable(TIFF* tif, uint8 table_index, void** mem, uint32* len); -static void OJPEGWriteStreamAcTable(TIFF* tif, uint8 table_index, void** mem, uint32* len); -static void OJPEGWriteStreamDri(TIFF* tif, void** mem, uint32* len); -static void OJPEGWriteStreamSof(TIFF* tif, void** mem, uint32* len); -static void OJPEGWriteStreamSos(TIFF* tif, void** mem, uint32* len); -static int OJPEGWriteStreamCompressed(TIFF* tif, void** mem, uint32* len); -static void OJPEGWriteStreamRst(TIFF* tif, void** mem, uint32* len); -static void OJPEGWriteStreamEoi(TIFF* tif, void** mem, uint32* len); - -#ifdef LIBJPEG_ENCAP_EXTERNAL -extern int jpeg_create_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo); -extern int jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8 require_image); -extern int jpeg_start_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo); -extern int jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32 max_lines); -extern int jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32 max_lines); -extern void jpeg_encap_unwind(TIFF* tif); -#else -static int jpeg_create_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* j); -static int jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8 require_image); -static int jpeg_start_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo); -static int jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32 max_lines); -static int jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32 max_lines); -static void jpeg_encap_unwind(TIFF* tif); -#endif - -static void OJPEGLibjpegJpegErrorMgrOutputMessage(jpeg_common_struct* cinfo); -static void OJPEGLibjpegJpegErrorMgrErrorExit(jpeg_common_struct* cinfo); -static void OJPEGLibjpegJpegSourceMgrInitSource(jpeg_decompress_struct* cinfo); -static boolean OJPEGLibjpegJpegSourceMgrFillInputBuffer(jpeg_decompress_struct* cinfo); -static void OJPEGLibjpegJpegSourceMgrSkipInputData(jpeg_decompress_struct* cinfo, long num_bytes); -static boolean OJPEGLibjpegJpegSourceMgrResyncToRestart(jpeg_decompress_struct* cinfo, int desired); -static void OJPEGLibjpegJpegSourceMgrTermSource(jpeg_decompress_struct* cinfo); - -int -TIFFInitOJPEG(TIFF* tif, int scheme) -{ - static const char module[]="TIFFInitOJPEG"; - OJPEGState* sp; - - assert(scheme==COMPRESSION_OJPEG); - - /* - * Merge codec-specific tag information. - */ - if (!_TIFFMergeFieldInfo(tif,ojpeg_field_info,FIELD_OJPEG_COUNT)) { - TIFFErrorExt(tif->tif_clientdata, module, - "Merging Old JPEG codec-specific tags failed"); - return 0; - } - - /* state block */ - sp=_TIFFmalloc(sizeof(OJPEGState)); - if (sp==NULL) - { - TIFFErrorExt(tif->tif_clientdata,module,"No space for OJPEG state block"); - return(0); - } - _TIFFmemset(sp,0,sizeof(OJPEGState)); - sp->tif=tif; - sp->jpeg_proc=1; - sp->subsampling_hor=2; - sp->subsampling_ver=2; - TIFFSetField(tif,TIFFTAG_YCBCRSUBSAMPLING,2,2); - /* tif codec methods */ - tif->tif_setupdecode=OJPEGSetupDecode; - tif->tif_predecode=OJPEGPreDecode; - tif->tif_postdecode=OJPEGPostDecode; - tif->tif_decoderow=OJPEGDecode; - tif->tif_decodestrip=OJPEGDecode; - tif->tif_decodetile=OJPEGDecode; - tif->tif_setupencode=OJPEGSetupEncode; - tif->tif_preencode=OJPEGPreEncode; - tif->tif_postencode=OJPEGPostEncode; - tif->tif_encoderow=OJPEGEncode; - tif->tif_encodestrip=OJPEGEncode; - tif->tif_encodetile=OJPEGEncode; - tif->tif_cleanup=OJPEGCleanup; - tif->tif_data=(tidata_t)sp; - /* tif tag methods */ - sp->vgetparent=tif->tif_tagmethods.vgetfield; - tif->tif_tagmethods.vgetfield=OJPEGVGetField; - sp->vsetparent=tif->tif_tagmethods.vsetfield; - tif->tif_tagmethods.vsetfield=OJPEGVSetField; - tif->tif_tagmethods.printdir=OJPEGPrintDir; - /* Some OJPEG files don't have strip or tile offsets or bytecounts tags. - Some others do, but have totally meaningless or corrupt values - in these tags. In these cases, the JpegInterchangeFormat stream is - reliable. In any case, this decoder reads the compressed data itself, - from the most reliable locations, and we need to notify encapsulating - LibTiff not to read raw strips or tiles for us. */ - tif->tif_flags|=TIFF_NOREADRAW; - return(1); -} - -static int -OJPEGVGetField(TIFF* tif, ttag_t tag, va_list ap) -{ - OJPEGState* sp=(OJPEGState*)tif->tif_data; - switch(tag) - { - case TIFFTAG_JPEGIFOFFSET: - *va_arg(ap,uint32*)=(uint32)sp->jpeg_interchange_format; - break; - case TIFFTAG_JPEGIFBYTECOUNT: - *va_arg(ap,uint32*)=(uint32)sp->jpeg_interchange_format_length; - break; - case TIFFTAG_YCBCRSUBSAMPLING: - if (sp->subsamplingcorrect_done==0) - OJPEGSubsamplingCorrect(tif); - *va_arg(ap,uint16*)=(uint16)sp->subsampling_hor; - *va_arg(ap,uint16*)=(uint16)sp->subsampling_ver; - break; - case TIFFTAG_JPEGQTABLES: - *va_arg(ap,uint32*)=(uint32)sp->qtable_offset_count; - *va_arg(ap,void**)=(void*)sp->qtable_offset; - break; - case TIFFTAG_JPEGDCTABLES: - *va_arg(ap,uint32*)=(uint32)sp->dctable_offset_count; - *va_arg(ap,void**)=(void*)sp->dctable_offset; - break; - case TIFFTAG_JPEGACTABLES: - *va_arg(ap,uint32*)=(uint32)sp->actable_offset_count; - *va_arg(ap,void**)=(void*)sp->actable_offset; - break; - case TIFFTAG_JPEGPROC: - *va_arg(ap,uint16*)=(uint16)sp->jpeg_proc; - break; - case TIFFTAG_JPEGRESTARTINTERVAL: - *va_arg(ap,uint16*)=sp->restart_interval; - break; - default: - return (*sp->vgetparent)(tif,tag,ap); - } - return (1); -} - -static int -OJPEGVSetField(TIFF* tif, ttag_t tag, va_list ap) -{ - static const char module[]="OJPEGVSetField"; - OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint32 ma; - uint32* mb; - uint32 n; - switch(tag) - { - case TIFFTAG_JPEGIFOFFSET: - sp->jpeg_interchange_format=(toff_t)va_arg(ap,uint32); - break; - case TIFFTAG_JPEGIFBYTECOUNT: - sp->jpeg_interchange_format_length=(toff_t)va_arg(ap,uint32); - break; - case TIFFTAG_YCBCRSUBSAMPLING: - sp->subsampling_tag=1; - sp->subsampling_hor=(uint8)va_arg(ap,int); - sp->subsampling_ver=(uint8)va_arg(ap,int); - tif->tif_dir.td_ycbcrsubsampling[0]=sp->subsampling_hor; - tif->tif_dir.td_ycbcrsubsampling[1]=sp->subsampling_ver; - break; - case TIFFTAG_JPEGQTABLES: - ma=va_arg(ap,uint32); - if (ma!=0) - { - if (ma>3) - { - TIFFErrorExt(tif->tif_clientdata,module,"JpegQTables tag has incorrect count"); - return(0); - } - sp->qtable_offset_count=(uint8)ma; - mb=va_arg(ap,uint32*); - for (n=0; nqtable_offset[n]=(toff_t)mb[n]; - } - break; - case TIFFTAG_JPEGDCTABLES: - ma=va_arg(ap,uint32); - if (ma!=0) - { - if (ma>3) - { - TIFFErrorExt(tif->tif_clientdata,module,"JpegDcTables tag has incorrect count"); - return(0); - } - sp->dctable_offset_count=(uint8)ma; - mb=va_arg(ap,uint32*); - for (n=0; ndctable_offset[n]=(toff_t)mb[n]; - } - break; - case TIFFTAG_JPEGACTABLES: - ma=va_arg(ap,uint32); - if (ma!=0) - { - if (ma>3) - { - TIFFErrorExt(tif->tif_clientdata,module,"JpegAcTables tag has incorrect count"); - return(0); - } - sp->actable_offset_count=(uint8)ma; - mb=va_arg(ap,uint32*); - for (n=0; nactable_offset[n]=(toff_t)mb[n]; - } - break; - case TIFFTAG_JPEGPROC: - sp->jpeg_proc=(uint8)va_arg(ap,uint32); - break; - case TIFFTAG_JPEGRESTARTINTERVAL: - sp->restart_interval=(uint16)va_arg(ap,uint32); - break; - default: - return (*sp->vsetparent)(tif,tag,ap); - } - TIFFSetFieldBit(tif,_TIFFFieldWithTag(tif,tag)->field_bit); - tif->tif_flags|=TIFF_DIRTYDIRECT; - return(1); -} - -static void -OJPEGPrintDir(TIFF* tif, FILE* fd, long flags) -{ - OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 m; - (void)flags; - assert(sp!=NULL); - if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGINTERCHANGEFORMAT)) - fprintf(fd," JpegInterchangeFormat: %lu\n",(unsigned long)sp->jpeg_interchange_format); - if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGINTERCHANGEFORMATLENGTH)) - fprintf(fd," JpegInterchangeFormatLength: %lu\n",(unsigned long)sp->jpeg_interchange_format_length); - if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGQTABLES)) - { - fprintf(fd," JpegQTables:"); - for (m=0; mqtable_offset_count; m++) - fprintf(fd," %lu",(unsigned long)sp->qtable_offset[m]); - fprintf(fd,"\n"); - } - if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGDCTABLES)) - { - fprintf(fd," JpegDcTables:"); - for (m=0; mdctable_offset_count; m++) - fprintf(fd," %lu",(unsigned long)sp->dctable_offset[m]); - fprintf(fd,"\n"); - } - if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGACTABLES)) - { - fprintf(fd," JpegAcTables:"); - for (m=0; mactable_offset_count; m++) - fprintf(fd," %lu",(unsigned long)sp->actable_offset[m]); - fprintf(fd,"\n"); - } - if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGPROC)) - fprintf(fd," JpegProc: %u\n",(unsigned int)sp->jpeg_proc); - if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGRESTARTINTERVAL)) - fprintf(fd," JpegRestartInterval: %u\n",(unsigned int)sp->restart_interval); -} - -static int -OJPEGSetupDecode(TIFF* tif) -{ - static const char module[]="OJPEGSetupDecode"; - TIFFWarningExt(tif->tif_clientdata,module,"Depreciated and troublesome old-style JPEG compression mode, please convert to new-style JPEG compression and notify vendor of writing software"); - return(1); -} - -static int -OJPEGPreDecode(TIFF* tif, tsample_t s) -{ - OJPEGState* sp=(OJPEGState*)tif->tif_data; - tstrile_t m; - if (sp->subsamplingcorrect_done==0) - OJPEGSubsamplingCorrect(tif); - if (sp->readheader_done==0) - { - if (OJPEGReadHeaderInfo(tif)==0) - return(0); - } - if (sp->sos_end[s].log==0) - { - if (OJPEGReadSecondarySos(tif,s)==0) - return(0); - } - if isTiled(tif) - m=(tstrile_t)tif->tif_curtile; - else - m=(tstrile_t)tif->tif_curstrip; - if ((sp->writeheader_done!=0) && ((sp->write_cursample!=s) || (sp->write_curstrile>m))) - { - if (sp->libjpeg_session_active!=0) - OJPEGLibjpegSessionAbort(tif); - sp->writeheader_done=0; - } - if (sp->writeheader_done==0) - { - sp->plane_sample_offset=s; - sp->write_cursample=s; - sp->write_curstrile=s*tif->tif_dir.td_stripsperimage; - if ((sp->in_buffer_file_pos_log==0) || - (sp->in_buffer_file_pos-sp->in_buffer_togo!=sp->sos_end[s].in_buffer_file_pos)) - { - sp->in_buffer_source=sp->sos_end[s].in_buffer_source; - sp->in_buffer_next_strile=sp->sos_end[s].in_buffer_next_strile; - sp->in_buffer_file_pos=sp->sos_end[s].in_buffer_file_pos; - sp->in_buffer_file_pos_log=0; - sp->in_buffer_file_togo=sp->sos_end[s].in_buffer_file_togo; - sp->in_buffer_togo=0; - sp->in_buffer_cur=0; - } - if (OJPEGWriteHeaderInfo(tif)==0) - return(0); - } - while (sp->write_curstrilelibjpeg_jpeg_query_style==0) - { - if (OJPEGPreDecodeSkipRaw(tif)==0) - return(0); - } - else - { - if (OJPEGPreDecodeSkipScanlines(tif)==0) - return(0); - } - sp->write_curstrile++; - } - return(1); -} - -static int -OJPEGPreDecodeSkipRaw(TIFF* tif) -{ - OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint32 m; - m=sp->lines_per_strile; - if (sp->subsampling_convert_state!=0) - { - if (sp->subsampling_convert_clines-sp->subsampling_convert_state>=m) - { - sp->subsampling_convert_state+=m; - if (sp->subsampling_convert_state==sp->subsampling_convert_clines) - sp->subsampling_convert_state=0; - return(1); - } - m-=sp->subsampling_convert_clines-sp->subsampling_convert_state; - sp->subsampling_convert_state=0; - } - while (m>=sp->subsampling_convert_clines) - { - if (jpeg_read_raw_data_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),sp->subsampling_convert_ycbcrimage,sp->subsampling_ver*8)==0) - return(0); - m-=sp->subsampling_convert_clines; - } - if (m>0) - { - if (jpeg_read_raw_data_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),sp->subsampling_convert_ycbcrimage,sp->subsampling_ver*8)==0) - return(0); - sp->subsampling_convert_state=m; - } - return(1); -} - -static int -OJPEGPreDecodeSkipScanlines(TIFF* tif) -{ - static const char module[]="OJPEGPreDecodeSkipScanlines"; - OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint32 m; - if (sp->skip_buffer==NULL) - { - sp->skip_buffer=_TIFFmalloc(sp->bytes_per_line); - if (sp->skip_buffer==NULL) - { - TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); - return(0); - } - } - for (m=0; mlines_per_strile; m++) - { - if (jpeg_read_scanlines_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),&sp->skip_buffer,1)==0) - return(0); - } - return(1); -} - -static int -OJPEGDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) -{ - OJPEGState* sp=(OJPEGState*)tif->tif_data; - (void)s; - if (sp->libjpeg_jpeg_query_style==0) - { - if (OJPEGDecodeRaw(tif,buf,cc)==0) - return(0); - } - else - { - if (OJPEGDecodeScanlines(tif,buf,cc)==0) - return(0); - } - return(1); -} - -static int -OJPEGDecodeRaw(TIFF* tif, tidata_t buf, tsize_t cc) -{ - static const char module[]="OJPEGDecodeRaw"; - OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8* m; - uint32 n; - uint8* oy; - uint8* ocb; - uint8* ocr; - uint8* p; - uint32 q; - uint8* r; - uint8 sx,sy; - if (cc%sp->bytes_per_line!=0) - { - TIFFErrorExt(tif->tif_clientdata,module,"Fractional scanline not read"); - return(0); - } - assert(cc>0); - m=buf; - n=cc; - do - { - if (sp->subsampling_convert_state==0) - { - if (jpeg_read_raw_data_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),sp->subsampling_convert_ycbcrimage,sp->subsampling_ver*8)==0) - return(0); - } - oy=sp->subsampling_convert_ybuf+sp->subsampling_convert_state*sp->subsampling_ver*sp->subsampling_convert_ylinelen; - ocb=sp->subsampling_convert_cbbuf+sp->subsampling_convert_state*sp->subsampling_convert_clinelen; - ocr=sp->subsampling_convert_crbuf+sp->subsampling_convert_state*sp->subsampling_convert_clinelen; - p=m; - for (q=0; qsubsampling_convert_clinelenout; q++) - { - r=oy; - for (sy=0; sysubsampling_ver; sy++) - { - for (sx=0; sxsubsampling_hor; sx++) - *p++=*r++; - r+=sp->subsampling_convert_ylinelen-sp->subsampling_hor; - } - oy+=sp->subsampling_hor; - *p++=*ocb++; - *p++=*ocr++; - } - sp->subsampling_convert_state++; - if (sp->subsampling_convert_state==sp->subsampling_convert_clines) - sp->subsampling_convert_state=0; - m+=sp->bytes_per_line; - n-=sp->bytes_per_line; - } while(n>0); - return(1); -} - -static int -OJPEGDecodeScanlines(TIFF* tif, tidata_t buf, tsize_t cc) -{ - static const char module[]="OJPEGDecodeScanlines"; - OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8* m; - uint32 n; - if (cc%sp->bytes_per_line!=0) - { - TIFFErrorExt(tif->tif_clientdata,module,"Fractional scanline not read"); - return(0); - } - assert(cc>0); - m=buf; - n=cc; - do - { - if (jpeg_read_scanlines_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),&m,1)==0) - return(0); - m+=sp->bytes_per_line; - n-=sp->bytes_per_line; - } while(n>0); - return(1); -} - -static void -OJPEGPostDecode(TIFF* tif, tidata_t buf, tsize_t cc) -{ - OJPEGState* sp=(OJPEGState*)tif->tif_data; - (void)buf; - (void)cc; - sp->write_curstrile++; - if (sp->write_curstrile%tif->tif_dir.td_stripsperimage==0) - { - assert(sp->libjpeg_session_active!=0); - OJPEGLibjpegSessionAbort(tif); - sp->writeheader_done=0; - } -} - -static int -OJPEGSetupEncode(TIFF* tif) -{ - static const char module[]="OJPEGSetupEncode"; - TIFFErrorExt(tif->tif_clientdata,module,"OJPEG encoding not supported; use new-style JPEG compression instead"); - return(0); -} - -static int -OJPEGPreEncode(TIFF* tif, tsample_t s) -{ - static const char module[]="OJPEGPreEncode"; - (void)s; - TIFFErrorExt(tif->tif_clientdata,module,"OJPEG encoding not supported; use new-style JPEG compression instead"); - return(0); -} - -static int -OJPEGEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) -{ - static const char module[]="OJPEGEncode"; - (void)buf; - (void)cc; - (void)s; - TIFFErrorExt(tif->tif_clientdata,module,"OJPEG encoding not supported; use new-style JPEG compression instead"); - return(0); -} - -static int -OJPEGPostEncode(TIFF* tif) -{ - static const char module[]="OJPEGPostEncode"; - TIFFErrorExt(tif->tif_clientdata,module,"OJPEG encoding not supported; use new-style JPEG compression instead"); - return(0); -} - -static void -OJPEGCleanup(TIFF* tif) -{ - OJPEGState* sp=(OJPEGState*)tif->tif_data; - if (sp!=0) - { - tif->tif_tagmethods.vgetfield=sp->vgetparent; - tif->tif_tagmethods.vsetfield=sp->vsetparent; - if (sp->qtable[0]!=0) - _TIFFfree(sp->qtable[0]); - if (sp->qtable[1]!=0) - _TIFFfree(sp->qtable[1]); - if (sp->qtable[2]!=0) - _TIFFfree(sp->qtable[2]); - if (sp->qtable[3]!=0) - _TIFFfree(sp->qtable[3]); - if (sp->dctable[0]!=0) - _TIFFfree(sp->dctable[0]); - if (sp->dctable[1]!=0) - _TIFFfree(sp->dctable[1]); - if (sp->dctable[2]!=0) - _TIFFfree(sp->dctable[2]); - if (sp->dctable[3]!=0) - _TIFFfree(sp->dctable[3]); - if (sp->actable[0]!=0) - _TIFFfree(sp->actable[0]); - if (sp->actable[1]!=0) - _TIFFfree(sp->actable[1]); - if (sp->actable[2]!=0) - _TIFFfree(sp->actable[2]); - if (sp->actable[3]!=0) - _TIFFfree(sp->actable[3]); - if (sp->libjpeg_session_active!=0) - OJPEGLibjpegSessionAbort(tif); - if (sp->subsampling_convert_ycbcrbuf!=0) - _TIFFfree(sp->subsampling_convert_ycbcrbuf); - if (sp->subsampling_convert_ycbcrimage!=0) - _TIFFfree(sp->subsampling_convert_ycbcrimage); - if (sp->skip_buffer!=0) - _TIFFfree(sp->skip_buffer); - _TIFFfree(sp); - tif->tif_data=NULL; - _TIFFSetDefaultCompressionState(tif); - } -} - -static void -OJPEGSubsamplingCorrect(TIFF* tif) -{ - static const char module[]="OJPEGSubsamplingCorrect"; - OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 mh; - uint8 mv; - assert(sp->subsamplingcorrect_done==0); - if ((tif->tif_dir.td_samplesperpixel!=3) || ((tif->tif_dir.td_photometric!=PHOTOMETRIC_YCBCR) && - (tif->tif_dir.td_photometric!=PHOTOMETRIC_ITULAB))) - { - if (sp->subsampling_tag!=0) - TIFFWarningExt(tif->tif_clientdata,module,"Subsampling tag not appropriate for this Photometric and/or SamplesPerPixel"); - sp->subsampling_hor=1; - sp->subsampling_ver=1; - sp->subsampling_force_desubsampling_inside_decompression=0; - } - else - { - sp->subsamplingcorrect_done=1; - mh=sp->subsampling_hor; - mv=sp->subsampling_ver; - sp->subsamplingcorrect=1; - OJPEGReadHeaderInfoSec(tif); - if (sp->subsampling_force_desubsampling_inside_decompression!=0) - { - sp->subsampling_hor=1; - sp->subsampling_ver=1; - } - sp->subsamplingcorrect=0; - if (((sp->subsampling_hor!=mh) || (sp->subsampling_ver!=mv)) && (sp->subsampling_force_desubsampling_inside_decompression==0)) - { - if (sp->subsampling_tag==0) - TIFFWarningExt(tif->tif_clientdata,module,"Subsampling tag is not set, yet subsampling inside JPEG data [%d,%d] does not match default values [2,2]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampling_ver); - else - TIFFWarningExt(tif->tif_clientdata,module,"Subsampling inside JPEG data [%d,%d] does not match subsampling tag values [%d,%d]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampling_ver,mh,mv); - } - if (sp->subsampling_force_desubsampling_inside_decompression!=0) - { - if (sp->subsampling_tag==0) - TIFFWarningExt(tif->tif_clientdata,module,"Subsampling tag is not set, yet subsampling inside JPEG data does not match default values [2,2] (nor any other values allowed in TIFF); assuming subsampling inside JPEG data is correct and desubsampling inside JPEG decompression"); - else - TIFFWarningExt(tif->tif_clientdata,module,"Subsampling inside JPEG data does not match subsampling tag values [%d,%d] (nor any other values allowed in TIFF); assuming subsampling inside JPEG data is correct and desubsampling inside JPEG decompression",mh,mv); - } - if (sp->subsampling_force_desubsampling_inside_decompression==0) - { - if (sp->subsampling_horsubsampling_ver) - TIFFWarningExt(tif->tif_clientdata,module,"Subsampling values [%d,%d] are not allowed in TIFF",sp->subsampling_hor,sp->subsampling_ver); - } - } - sp->subsamplingcorrect_done=1; -} - -static int -OJPEGReadHeaderInfo(TIFF* tif) -{ - static const char module[]="OJPEGReadHeaderInfo"; - OJPEGState* sp=(OJPEGState*)tif->tif_data; - assert(sp->readheader_done==0); - sp->image_width=tif->tif_dir.td_imagewidth; - sp->image_length=tif->tif_dir.td_imagelength; - if isTiled(tif) - { - sp->strile_width=tif->tif_dir.td_tilewidth; - sp->strile_length=tif->tif_dir.td_tilelength; - sp->strile_length_total=((sp->image_length+sp->strile_length-1)/sp->strile_length)*sp->strile_length; - } - else - { - sp->strile_width=sp->image_width; - sp->strile_length=tif->tif_dir.td_rowsperstrip; - sp->strile_length_total=sp->image_length; - } - sp->samples_per_pixel=tif->tif_dir.td_samplesperpixel; - if (sp->samples_per_pixel==1) - { - sp->plane_sample_offset=0; - sp->samples_per_pixel_per_plane=sp->samples_per_pixel; - sp->subsampling_hor=1; - sp->subsampling_ver=1; - } - else - { - if (sp->samples_per_pixel!=3) - { - TIFFErrorExt(tif->tif_clientdata,module,"SamplesPerPixel %d not supported for this compression scheme",sp->samples_per_pixel); - return(0); - } - sp->plane_sample_offset=0; - if (tif->tif_dir.td_planarconfig==PLANARCONFIG_CONTIG) - sp->samples_per_pixel_per_plane=3; - else - sp->samples_per_pixel_per_plane=1; - } - if (sp->strile_lengthimage_length) - { - if (sp->strile_length%(sp->subsampling_ver*8)!=0) - { - TIFFErrorExt(tif->tif_clientdata,module,"Incompatible vertical subsampling and image strip/tile length"); - return(0); - } - sp->restart_interval=((sp->strile_width+sp->subsampling_hor*8-1)/(sp->subsampling_hor*8))*(sp->strile_length/(sp->subsampling_ver*8)); - } - if (OJPEGReadHeaderInfoSec(tif)==0) - return(0); - sp->sos_end[0].log=1; - sp->sos_end[0].in_buffer_source=sp->in_buffer_source; - sp->sos_end[0].in_buffer_next_strile=sp->in_buffer_next_strile; - sp->sos_end[0].in_buffer_file_pos=sp->in_buffer_file_pos-sp->in_buffer_togo; - sp->sos_end[0].in_buffer_file_togo=sp->in_buffer_file_togo+sp->in_buffer_togo; - sp->readheader_done=1; - return(1); -} - -static int -OJPEGReadSecondarySos(TIFF* tif, tsample_t s) -{ - OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 m; - assert(s>0); - assert(s<3); - assert(sp->sos_end[0].log!=0); - assert(sp->sos_end[s].log==0); - sp->plane_sample_offset=s-1; - while(sp->sos_end[sp->plane_sample_offset].log==0) - sp->plane_sample_offset--; - sp->in_buffer_source=sp->sos_end[sp->plane_sample_offset].in_buffer_source; - sp->in_buffer_next_strile=sp->sos_end[sp->plane_sample_offset].in_buffer_next_strile; - sp->in_buffer_file_pos=sp->sos_end[sp->plane_sample_offset].in_buffer_file_pos; - sp->in_buffer_file_pos_log=0; - sp->in_buffer_file_togo=sp->sos_end[sp->plane_sample_offset].in_buffer_file_togo; - sp->in_buffer_togo=0; - sp->in_buffer_cur=0; - while(sp->plane_sample_offsetplane_sample_offset++; - if (OJPEGReadHeaderInfoSecStreamSos(tif)==0) - return(0); - sp->sos_end[sp->plane_sample_offset].log=1; - sp->sos_end[sp->plane_sample_offset].in_buffer_source=sp->in_buffer_source; - sp->sos_end[sp->plane_sample_offset].in_buffer_next_strile=sp->in_buffer_next_strile; - sp->sos_end[sp->plane_sample_offset].in_buffer_file_pos=sp->in_buffer_file_pos-sp->in_buffer_togo; - sp->sos_end[sp->plane_sample_offset].in_buffer_file_togo=sp->in_buffer_file_togo+sp->in_buffer_togo; - } - return(1); -} - -static int -OJPEGWriteHeaderInfo(TIFF* tif) -{ - static const char module[]="OJPEGWriteHeaderInfo"; - OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8** m; - uint32 n; - assert(sp->libjpeg_session_active==0); - sp->out_state=ososSoi; - sp->restart_index=0; - jpeg_std_error(&(sp->libjpeg_jpeg_error_mgr)); - sp->libjpeg_jpeg_error_mgr.output_message=OJPEGLibjpegJpegErrorMgrOutputMessage; - sp->libjpeg_jpeg_error_mgr.error_exit=OJPEGLibjpegJpegErrorMgrErrorExit; - sp->libjpeg_jpeg_decompress_struct.err=&(sp->libjpeg_jpeg_error_mgr); - sp->libjpeg_jpeg_decompress_struct.client_data=(void*)tif; - if (jpeg_create_decompress_encap(sp,&(sp->libjpeg_jpeg_decompress_struct))==0) - return(0); - sp->libjpeg_session_active=1; - sp->libjpeg_jpeg_source_mgr.bytes_in_buffer=0; - sp->libjpeg_jpeg_source_mgr.init_source=OJPEGLibjpegJpegSourceMgrInitSource; - sp->libjpeg_jpeg_source_mgr.fill_input_buffer=OJPEGLibjpegJpegSourceMgrFillInputBuffer; - sp->libjpeg_jpeg_source_mgr.skip_input_data=OJPEGLibjpegJpegSourceMgrSkipInputData; - sp->libjpeg_jpeg_source_mgr.resync_to_restart=OJPEGLibjpegJpegSourceMgrResyncToRestart; - sp->libjpeg_jpeg_source_mgr.term_source=OJPEGLibjpegJpegSourceMgrTermSource; - sp->libjpeg_jpeg_decompress_struct.src=&(sp->libjpeg_jpeg_source_mgr); - if (jpeg_read_header_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),1)==0) - return(0); - if ((sp->subsampling_force_desubsampling_inside_decompression==0) && (sp->samples_per_pixel_per_plane>1)) - { - sp->libjpeg_jpeg_decompress_struct.raw_data_out=1; -#if JPEG_LIB_VERSION >= 70 - sp->libjpeg_jpeg_decompress_struct.do_fancy_upsampling=FALSE; -#endif - sp->libjpeg_jpeg_query_style=0; - if (sp->subsampling_convert_log==0) - { - assert(sp->subsampling_convert_ycbcrbuf==0); - assert(sp->subsampling_convert_ycbcrimage==0); - sp->subsampling_convert_ylinelen=((sp->strile_width+sp->subsampling_hor*8-1)/(sp->subsampling_hor*8)*sp->subsampling_hor*8); - sp->subsampling_convert_ylines=sp->subsampling_ver*8; - sp->subsampling_convert_clinelen=sp->subsampling_convert_ylinelen/sp->subsampling_hor; - sp->subsampling_convert_clines=8; - sp->subsampling_convert_ybuflen=sp->subsampling_convert_ylinelen*sp->subsampling_convert_ylines; - sp->subsampling_convert_cbuflen=sp->subsampling_convert_clinelen*sp->subsampling_convert_clines; - sp->subsampling_convert_ycbcrbuflen=sp->subsampling_convert_ybuflen+2*sp->subsampling_convert_cbuflen; - sp->subsampling_convert_ycbcrbuf=_TIFFmalloc(sp->subsampling_convert_ycbcrbuflen); - if (sp->subsampling_convert_ycbcrbuf==0) - { - TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); - return(0); - } - sp->subsampling_convert_ybuf=sp->subsampling_convert_ycbcrbuf; - sp->subsampling_convert_cbbuf=sp->subsampling_convert_ybuf+sp->subsampling_convert_ybuflen; - sp->subsampling_convert_crbuf=sp->subsampling_convert_cbbuf+sp->subsampling_convert_cbuflen; - sp->subsampling_convert_ycbcrimagelen=3+sp->subsampling_convert_ylines+2*sp->subsampling_convert_clines; - sp->subsampling_convert_ycbcrimage=_TIFFmalloc(sp->subsampling_convert_ycbcrimagelen*sizeof(uint8*)); - if (sp->subsampling_convert_ycbcrimage==0) - { - TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); - return(0); - } - m=sp->subsampling_convert_ycbcrimage; - *m++=(uint8*)(sp->subsampling_convert_ycbcrimage+3); - *m++=(uint8*)(sp->subsampling_convert_ycbcrimage+3+sp->subsampling_convert_ylines); - *m++=(uint8*)(sp->subsampling_convert_ycbcrimage+3+sp->subsampling_convert_ylines+sp->subsampling_convert_clines); - for (n=0; nsubsampling_convert_ylines; n++) - *m++=sp->subsampling_convert_ybuf+n*sp->subsampling_convert_ylinelen; - for (n=0; nsubsampling_convert_clines; n++) - *m++=sp->subsampling_convert_cbbuf+n*sp->subsampling_convert_clinelen; - for (n=0; nsubsampling_convert_clines; n++) - *m++=sp->subsampling_convert_crbuf+n*sp->subsampling_convert_clinelen; - sp->subsampling_convert_clinelenout=((sp->strile_width+sp->subsampling_hor-1)/sp->subsampling_hor); - sp->subsampling_convert_state=0; - sp->bytes_per_line=sp->subsampling_convert_clinelenout*(sp->subsampling_ver*sp->subsampling_hor+2); - sp->lines_per_strile=((sp->strile_length+sp->subsampling_ver-1)/sp->subsampling_ver); - sp->subsampling_convert_log=1; - } - } - else - { - sp->libjpeg_jpeg_decompress_struct.jpeg_color_space=JCS_UNKNOWN; - sp->libjpeg_jpeg_decompress_struct.out_color_space=JCS_UNKNOWN; - sp->libjpeg_jpeg_query_style=1; - sp->bytes_per_line=sp->samples_per_pixel_per_plane*sp->strile_width; - sp->lines_per_strile=sp->strile_length; - } - if (jpeg_start_decompress_encap(sp,&(sp->libjpeg_jpeg_decompress_struct))==0) - return(0); - sp->writeheader_done=1; - return(1); -} - -static void -OJPEGLibjpegSessionAbort(TIFF* tif) -{ - OJPEGState* sp=(OJPEGState*)tif->tif_data; - assert(sp->libjpeg_session_active!=0); - jpeg_destroy((jpeg_common_struct*)(&(sp->libjpeg_jpeg_decompress_struct))); - sp->libjpeg_session_active=0; -} - -static int -OJPEGReadHeaderInfoSec(TIFF* tif) -{ - static const char module[]="OJPEGReadHeaderInfoSec"; - OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 m; - uint16 n; - uint8 o; - if (sp->file_size==0) - sp->file_size=TIFFGetFileSize(tif); - if (sp->jpeg_interchange_format!=0) - { - if (sp->jpeg_interchange_format>=sp->file_size) - { - sp->jpeg_interchange_format=0; - sp->jpeg_interchange_format_length=0; - } - else - { - if ((sp->jpeg_interchange_format_length==0) || (sp->jpeg_interchange_format+sp->jpeg_interchange_format_length>sp->file_size)) - sp->jpeg_interchange_format_length=sp->file_size-sp->jpeg_interchange_format; - } - } - sp->in_buffer_source=osibsNotSetYet; - sp->in_buffer_next_strile=0; - sp->in_buffer_strile_count=tif->tif_dir.td_nstrips; - sp->in_buffer_file_togo=0; - sp->in_buffer_togo=0; - do - { - if (OJPEGReadBytePeek(sp,&m)==0) - return(0); - if (m!=255) - break; - OJPEGReadByteAdvance(sp); - do - { - if (OJPEGReadByte(sp,&m)==0) - return(0); - } while(m==255); - switch(m) - { - case JPEG_MARKER_SOI: - /* this type of marker has no data, and should be skipped */ - break; - case JPEG_MARKER_COM: - case JPEG_MARKER_APP0: - case JPEG_MARKER_APP0+1: - case JPEG_MARKER_APP0+2: - case JPEG_MARKER_APP0+3: - case JPEG_MARKER_APP0+4: - case JPEG_MARKER_APP0+5: - case JPEG_MARKER_APP0+6: - case JPEG_MARKER_APP0+7: - case JPEG_MARKER_APP0+8: - case JPEG_MARKER_APP0+9: - case JPEG_MARKER_APP0+10: - case JPEG_MARKER_APP0+11: - case JPEG_MARKER_APP0+12: - case JPEG_MARKER_APP0+13: - case JPEG_MARKER_APP0+14: - case JPEG_MARKER_APP0+15: - /* this type of marker has data, but it has no use to us (and no place here) and should be skipped */ - if (OJPEGReadWord(sp,&n)==0) - return(0); - if (n<2) - { - if (sp->subsamplingcorrect==0) - TIFFErrorExt(tif->tif_clientdata,module,"Corrupt JPEG data"); - return(0); - } - if (n>2) - OJPEGReadSkip(sp,n-2); - break; - case JPEG_MARKER_DRI: - if (OJPEGReadHeaderInfoSecStreamDri(tif)==0) - return(0); - break; - case JPEG_MARKER_DQT: - if (OJPEGReadHeaderInfoSecStreamDqt(tif)==0) - return(0); - break; - case JPEG_MARKER_DHT: - if (OJPEGReadHeaderInfoSecStreamDht(tif)==0) - return(0); - break; - case JPEG_MARKER_SOF0: - case JPEG_MARKER_SOF1: - case JPEG_MARKER_SOF3: - if (OJPEGReadHeaderInfoSecStreamSof(tif,m)==0) - return(0); - if (sp->subsamplingcorrect!=0) - return(1); - break; - case JPEG_MARKER_SOS: - if (sp->subsamplingcorrect!=0) - return(1); - assert(sp->plane_sample_offset==0); - if (OJPEGReadHeaderInfoSecStreamSos(tif)==0) - return(0); - break; - default: - TIFFErrorExt(tif->tif_clientdata,module,"Unknown marker type %d in JPEG data",m); - return(0); - } - } while(m!=JPEG_MARKER_SOS); - if (sp->subsamplingcorrect) - return(1); - if (sp->sof_log==0) - { - if (OJPEGReadHeaderInfoSecTablesQTable(tif)==0) - return(0); - sp->sof_marker_id=JPEG_MARKER_SOF0; - for (o=0; osamples_per_pixel; o++) - sp->sof_c[o]=o; - sp->sof_hv[0]=((sp->subsampling_hor<<4)|sp->subsampling_ver); - for (o=1; osamples_per_pixel; o++) - sp->sof_hv[o]=17; - sp->sof_x=sp->strile_width; - sp->sof_y=sp->strile_length_total; - sp->sof_log=1; - if (OJPEGReadHeaderInfoSecTablesDcTable(tif)==0) - return(0); - if (OJPEGReadHeaderInfoSecTablesAcTable(tif)==0) - return(0); - for (o=1; osamples_per_pixel; o++) - sp->sos_cs[o]=o; - } - return(1); -} - -static int -OJPEGReadHeaderInfoSecStreamDri(TIFF* tif) -{ - /* this could easilly cause trouble in some cases... but no such cases have occured sofar */ - static const char module[]="OJPEGReadHeaderInfoSecStreamDri"; - OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint16 m; - if (OJPEGReadWord(sp,&m)==0) - return(0); - if (m!=4) - { - TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DRI marker in JPEG data"); - return(0); - } - if (OJPEGReadWord(sp,&m)==0) - return(0); - sp->restart_interval=m; - return(1); -} - -static int -OJPEGReadHeaderInfoSecStreamDqt(TIFF* tif) -{ - /* this is a table marker, and it is to be saved as a whole for exact pushing on the jpeg stream later on */ - static const char module[]="OJPEGReadHeaderInfoSecStreamDqt"; - OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint16 m; - uint32 na; - uint8* nb; - uint8 o; - if (OJPEGReadWord(sp,&m)==0) - return(0); - if (m<=2) - { - if (sp->subsamplingcorrect==0) - TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DQT marker in JPEG data"); - return(0); - } - if (sp->subsamplingcorrect!=0) - OJPEGReadSkip(sp,m-2); - else - { - m-=2; - do - { - if (m<65) - { - TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DQT marker in JPEG data"); - return(0); - } - na=sizeof(uint32)+69; - nb=_TIFFmalloc(na); - if (nb==0) - { - TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); - return(0); - } - *(uint32*)nb=na; - nb[sizeof(uint32)]=255; - nb[sizeof(uint32)+1]=JPEG_MARKER_DQT; - nb[sizeof(uint32)+2]=0; - nb[sizeof(uint32)+3]=67; - if (OJPEGReadBlock(sp,65,&nb[sizeof(uint32)+4])==0) - return(0); - o=nb[sizeof(uint32)+4]&15; - if (3tif_clientdata,module,"Corrupt DQT marker in JPEG data"); - return(0); - } - if (sp->qtable[o]!=0) - _TIFFfree(sp->qtable[o]); - sp->qtable[o]=nb; - m-=65; - } while(m>0); - } - return(1); -} - -static int -OJPEGReadHeaderInfoSecStreamDht(TIFF* tif) -{ - /* this is a table marker, and it is to be saved as a whole for exact pushing on the jpeg stream later on */ - /* TODO: the following assumes there is only one table in this marker... but i'm not quite sure that assumption is guaranteed correct */ - static const char module[]="OJPEGReadHeaderInfoSecStreamDht"; - OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint16 m; - uint32 na; - uint8* nb; - uint8 o; - if (OJPEGReadWord(sp,&m)==0) - return(0); - if (m<=2) - { - if (sp->subsamplingcorrect==0) - TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DHT marker in JPEG data"); - return(0); - } - if (sp->subsamplingcorrect!=0) - { - OJPEGReadSkip(sp,m-2); - } - else - { - na=sizeof(uint32)+2+m; - nb=_TIFFmalloc(na); - if (nb==0) - { - TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); - return(0); - } - *(uint32*)nb=na; - nb[sizeof(uint32)]=255; - nb[sizeof(uint32)+1]=JPEG_MARKER_DHT; - nb[sizeof(uint32)+2]=(m>>8); - nb[sizeof(uint32)+3]=(m&255); - if (OJPEGReadBlock(sp,m-2,&nb[sizeof(uint32)+4])==0) - return(0); - o=nb[sizeof(uint32)+4]; - if ((o&240)==0) - { - if (3tif_clientdata,module,"Corrupt DHT marker in JPEG data"); - return(0); - } - if (sp->dctable[o]!=0) - _TIFFfree(sp->dctable[o]); - sp->dctable[o]=nb; - } - else - { - if ((o&240)!=16) - { - TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DHT marker in JPEG data"); - return(0); - } - o&=15; - if (3tif_clientdata,module,"Corrupt DHT marker in JPEG data"); - return(0); - } - if (sp->actable[o]!=0) - _TIFFfree(sp->actable[o]); - sp->actable[o]=nb; - } - } - return(1); -} - -static int -OJPEGReadHeaderInfoSecStreamSof(TIFF* tif, uint8 marker_id) -{ - /* this marker needs to be checked, and part of its data needs to be saved for regeneration later on */ - static const char module[]="OJPEGReadHeaderInfoSecStreamSof"; - OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint16 m; - uint16 n; - uint8 o; - uint16 p; - uint16 q; - if (sp->sof_log!=0) - { - TIFFErrorExt(tif->tif_clientdata,module,"Corrupt JPEG data"); - return(0); - } - if (sp->subsamplingcorrect==0) - sp->sof_marker_id=marker_id; - /* Lf: data length */ - if (OJPEGReadWord(sp,&m)==0) - return(0); - if (m<11) - { - if (sp->subsamplingcorrect==0) - TIFFErrorExt(tif->tif_clientdata,module,"Corrupt SOF marker in JPEG data"); - return(0); - } - m-=8; - if (m%3!=0) - { - if (sp->subsamplingcorrect==0) - TIFFErrorExt(tif->tif_clientdata,module,"Corrupt SOF marker in JPEG data"); - return(0); - } - n=m/3; - if (sp->subsamplingcorrect==0) - { - if (n!=sp->samples_per_pixel) - { - TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected number of samples"); - return(0); - } - } - /* P: Sample precision */ - if (OJPEGReadByte(sp,&o)==0) - return(0); - if (o!=8) - { - if (sp->subsamplingcorrect==0) - TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected number of bits per sample"); - return(0); - } - /* Y: Number of lines, X: Number of samples per line */ - if (sp->subsamplingcorrect) - OJPEGReadSkip(sp,4); - else - { - /* Y: Number of lines */ - if (OJPEGReadWord(sp,&p)==0) - return(0); - if ((pimage_length) && (pstrile_length_total)) - { - TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected height"); - return(0); - } - sp->sof_y=p; - /* X: Number of samples per line */ - if (OJPEGReadWord(sp,&p)==0) - return(0); - if ((pimage_width) && (pstrile_width)) - { - TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected width"); - return(0); - } - if ((uint32)p>sp->strile_width) - { - TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data image width exceeds expected image width"); - return(0); - } - sp->sof_x=p; - } - /* Nf: Number of image components in frame */ - if (OJPEGReadByte(sp,&o)==0) - return(0); - if (o!=n) - { - if (sp->subsamplingcorrect==0) - TIFFErrorExt(tif->tif_clientdata,module,"Corrupt SOF marker in JPEG data"); - return(0); - } - /* per component stuff */ - /* TODO: double-check that flow implies that n cannot be as big as to make us overflow sof_c, sof_hv and sof_tq arrays */ - for (q=0; qsubsamplingcorrect==0) - sp->sof_c[q]=o; - /* H: Horizontal sampling factor, and V: Vertical sampling factor */ - if (OJPEGReadByte(sp,&o)==0) - return(0); - if (sp->subsamplingcorrect!=0) - { - if (q==0) - { - sp->subsampling_hor=(o>>4); - sp->subsampling_ver=(o&15); - if (((sp->subsampling_hor!=1) && (sp->subsampling_hor!=2) && (sp->subsampling_hor!=4)) || - ((sp->subsampling_ver!=1) && (sp->subsampling_ver!=2) && (sp->subsampling_ver!=4))) - sp->subsampling_force_desubsampling_inside_decompression=1; - } - else - { - if (o!=17) - sp->subsampling_force_desubsampling_inside_decompression=1; - } - } - else - { - sp->sof_hv[q]=o; - if (sp->subsampling_force_desubsampling_inside_decompression==0) - { - if (q==0) - { - if (o!=((sp->subsampling_hor<<4)|sp->subsampling_ver)) - { - TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected subsampling values"); - return(0); - } - } - else - { - if (o!=17) - { - TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected subsampling values"); - return(0); - } - } - } - } - /* Tq: Quantization table destination selector */ - if (OJPEGReadByte(sp,&o)==0) - return(0); - if (sp->subsamplingcorrect==0) - sp->sof_tq[q]=o; - } - if (sp->subsamplingcorrect==0) - sp->sof_log=1; - return(1); -} - -static int -OJPEGReadHeaderInfoSecStreamSos(TIFF* tif) -{ - /* this marker needs to be checked, and part of its data needs to be saved for regeneration later on */ - static const char module[]="OJPEGReadHeaderInfoSecStreamSos"; - OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint16 m; - uint8 n; - uint8 o; - assert(sp->subsamplingcorrect==0); - if (sp->sof_log==0) - { - TIFFErrorExt(tif->tif_clientdata,module,"Corrupt SOS marker in JPEG data"); - return(0); - } - /* Ls */ - if (OJPEGReadWord(sp,&m)==0) - return(0); - if (m!=6+sp->samples_per_pixel_per_plane*2) - { - TIFFErrorExt(tif->tif_clientdata,module,"Corrupt SOS marker in JPEG data"); - return(0); - } - /* Ns */ - if (OJPEGReadByte(sp,&n)==0) - return(0); - if (n!=sp->samples_per_pixel_per_plane) - { - TIFFErrorExt(tif->tif_clientdata,module,"Corrupt SOS marker in JPEG data"); - return(0); - } - /* Cs, Td, and Ta */ - for (o=0; osamples_per_pixel_per_plane; o++) - { - /* Cs */ - if (OJPEGReadByte(sp,&n)==0) - return(0); - sp->sos_cs[sp->plane_sample_offset+o]=n; - /* Td and Ta */ - if (OJPEGReadByte(sp,&n)==0) - return(0); - sp->sos_tda[sp->plane_sample_offset+o]=n; - } - /* skip Ss, Se, Ah, en Al -> no check, as per Tom Lane recommendation, as per LibJpeg source */ - OJPEGReadSkip(sp,3); - return(1); -} - -static int -OJPEGReadHeaderInfoSecTablesQTable(TIFF* tif) -{ - static const char module[]="OJPEGReadHeaderInfoSecTablesQTable"; - OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 m; - uint8 n; - uint32 oa; - uint8* ob; - uint32 p; - if (sp->qtable_offset[0]==0) - { - TIFFErrorExt(tif->tif_clientdata,module,"Missing JPEG tables"); - return(0); - } - sp->in_buffer_file_pos_log=0; - for (m=0; msamples_per_pixel; m++) - { - if ((sp->qtable_offset[m]!=0) && ((m==0) || (sp->qtable_offset[m]!=sp->qtable_offset[m-1]))) - { - for (n=0; nqtable_offset[m]==sp->qtable_offset[n]) - { - TIFFErrorExt(tif->tif_clientdata,module,"Corrupt JpegQTables tag value"); - return(0); - } - } - oa=sizeof(uint32)+69; - ob=_TIFFmalloc(oa); - if (ob==0) - { - TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); - return(0); - } - *(uint32*)ob=oa; - ob[sizeof(uint32)]=255; - ob[sizeof(uint32)+1]=JPEG_MARKER_DQT; - ob[sizeof(uint32)+2]=0; - ob[sizeof(uint32)+3]=67; - ob[sizeof(uint32)+4]=m; - TIFFSeekFile(tif,sp->qtable_offset[m],SEEK_SET); - p=TIFFReadFile(tif,&ob[sizeof(uint32)+5],64); - if (p!=64) - return(0); - sp->qtable[m]=ob; - sp->sof_tq[m]=m; - } - else - sp->sof_tq[m]=sp->sof_tq[m-1]; - } - return(1); -} - -static int -OJPEGReadHeaderInfoSecTablesDcTable(TIFF* tif) -{ - static const char module[]="OJPEGReadHeaderInfoSecTablesDcTable"; - OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 m; - uint8 n; - uint8 o[16]; - uint32 p; - uint32 q; - uint32 ra; - uint8* rb; - if (sp->dctable_offset[0]==0) - { - TIFFErrorExt(tif->tif_clientdata,module,"Missing JPEG tables"); - return(0); - } - sp->in_buffer_file_pos_log=0; - for (m=0; msamples_per_pixel; m++) - { - if ((sp->dctable_offset[m]!=0) && ((m==0) || (sp->dctable_offset[m]!=sp->dctable_offset[m-1]))) - { - for (n=0; ndctable_offset[m]==sp->dctable_offset[n]) - { - TIFFErrorExt(tif->tif_clientdata,module,"Corrupt JpegDcTables tag value"); - return(0); - } - } - TIFFSeekFile(tif,sp->dctable_offset[m],SEEK_SET); - p=TIFFReadFile(tif,o,16); - if (p!=16) - return(0); - q=0; - for (n=0; n<16; n++) - q+=o[n]; - ra=sizeof(uint32)+21+q; - rb=_TIFFmalloc(ra); - if (rb==0) - { - TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); - return(0); - } - *(uint32*)rb=ra; - rb[sizeof(uint32)]=255; - rb[sizeof(uint32)+1]=JPEG_MARKER_DHT; - rb[sizeof(uint32)+2]=((19+q)>>8); - rb[sizeof(uint32)+3]=((19+q)&255); - rb[sizeof(uint32)+4]=m; - for (n=0; n<16; n++) - rb[sizeof(uint32)+5+n]=o[n]; - p=TIFFReadFile(tif,&(rb[sizeof(uint32)+21]),q); - if (p!=q) - return(0); - sp->dctable[m]=rb; - sp->sos_tda[m]=(m<<4); - } - else - sp->sos_tda[m]=sp->sos_tda[m-1]; - } - return(1); -} - -static int -OJPEGReadHeaderInfoSecTablesAcTable(TIFF* tif) -{ - static const char module[]="OJPEGReadHeaderInfoSecTablesAcTable"; - OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 m; - uint8 n; - uint8 o[16]; - uint32 p; - uint32 q; - uint32 ra; - uint8* rb; - if (sp->actable_offset[0]==0) - { - TIFFErrorExt(tif->tif_clientdata,module,"Missing JPEG tables"); - return(0); - } - sp->in_buffer_file_pos_log=0; - for (m=0; msamples_per_pixel; m++) - { - if ((sp->actable_offset[m]!=0) && ((m==0) || (sp->actable_offset[m]!=sp->actable_offset[m-1]))) - { - for (n=0; nactable_offset[m]==sp->actable_offset[n]) - { - TIFFErrorExt(tif->tif_clientdata,module,"Corrupt JpegAcTables tag value"); - return(0); - } - } - TIFFSeekFile(tif,sp->actable_offset[m],SEEK_SET); - p=TIFFReadFile(tif,o,16); - if (p!=16) - return(0); - q=0; - for (n=0; n<16; n++) - q+=o[n]; - ra=sizeof(uint32)+21+q; - rb=_TIFFmalloc(ra); - if (rb==0) - { - TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); - return(0); - } - *(uint32*)rb=ra; - rb[sizeof(uint32)]=255; - rb[sizeof(uint32)+1]=JPEG_MARKER_DHT; - rb[sizeof(uint32)+2]=((19+q)>>8); - rb[sizeof(uint32)+3]=((19+q)&255); - rb[sizeof(uint32)+4]=(16|m); - for (n=0; n<16; n++) - rb[sizeof(uint32)+5+n]=o[n]; - p=TIFFReadFile(tif,&(rb[sizeof(uint32)+21]),q); - if (p!=q) - return(0); - sp->actable[m]=rb; - sp->sos_tda[m]=(sp->sos_tda[m]|m); - } - else - sp->sos_tda[m]=(sp->sos_tda[m]|(sp->sos_tda[m-1]&15)); - } - return(1); -} - -static int -OJPEGReadBufferFill(OJPEGState* sp) -{ - uint16 m; - tsize_t n; - /* TODO: double-check: when subsamplingcorrect is set, no call to TIFFErrorExt or TIFFWarningExt should be made - * in any other case, seek or read errors should be passed through */ - do - { - if (sp->in_buffer_file_togo!=0) - { - if (sp->in_buffer_file_pos_log==0) - { - TIFFSeekFile(sp->tif,sp->in_buffer_file_pos,SEEK_SET); - sp->in_buffer_file_pos_log=1; - } - m=OJPEG_BUFFER; - if (m>sp->in_buffer_file_togo) - m=(uint16)sp->in_buffer_file_togo; - n=TIFFReadFile(sp->tif,sp->in_buffer,(tsize_t)m); - if (n==0) - return(0); - assert(n>0); - assert(n<=OJPEG_BUFFER); - assert(n<65536); - assert((uint16)n<=sp->in_buffer_file_togo); - m=(uint16)n; - sp->in_buffer_togo=m; - sp->in_buffer_cur=sp->in_buffer; - sp->in_buffer_file_togo-=m; - sp->in_buffer_file_pos+=m; - break; - } - sp->in_buffer_file_pos_log=0; - switch(sp->in_buffer_source) - { - case osibsNotSetYet: - if (sp->jpeg_interchange_format!=0) - { - sp->in_buffer_file_pos=sp->jpeg_interchange_format; - sp->in_buffer_file_togo=sp->jpeg_interchange_format_length; - } - sp->in_buffer_source=osibsJpegInterchangeFormat; - break; - case osibsJpegInterchangeFormat: - sp->in_buffer_source=osibsStrile; - case osibsStrile: - if (sp->in_buffer_next_strile==sp->in_buffer_strile_count) - sp->in_buffer_source=osibsEof; - else - { - if (sp->tif->tif_dir.td_stripoffset == 0) { - TIFFErrorExt(sp->tif->tif_clientdata,sp->tif->tif_name,"Strip offsets are missing"); - return(0); - } - sp->in_buffer_file_pos=sp->tif->tif_dir.td_stripoffset[sp->in_buffer_next_strile]; - if (sp->in_buffer_file_pos!=0) - { - if (sp->in_buffer_file_pos>=sp->file_size) - sp->in_buffer_file_pos=0; - else if (sp->tif->tif_dir.td_stripbytecount==NULL) - sp->in_buffer_file_togo=sp->file_size-sp->in_buffer_file_pos; - else - { - if (sp->tif->tif_dir.td_stripbytecount == 0) { - TIFFErrorExt(sp->tif->tif_clientdata,sp->tif->tif_name,"Strip byte counts are missing"); - return(0); - } - sp->in_buffer_file_togo=sp->tif->tif_dir.td_stripbytecount[sp->in_buffer_next_strile]; - if (sp->in_buffer_file_togo==0) - sp->in_buffer_file_pos=0; - else if (sp->in_buffer_file_pos+sp->in_buffer_file_togo>sp->file_size) - sp->in_buffer_file_togo=sp->file_size-sp->in_buffer_file_pos; - } - } - sp->in_buffer_next_strile++; - } - break; - default: - return(0); - } - } while (1); - return(1); -} - -static int -OJPEGReadByte(OJPEGState* sp, uint8* byte) -{ - if (sp->in_buffer_togo==0) - { - if (OJPEGReadBufferFill(sp)==0) - return(0); - assert(sp->in_buffer_togo>0); - } - *byte=*(sp->in_buffer_cur); - sp->in_buffer_cur++; - sp->in_buffer_togo--; - return(1); -} - -static int -OJPEGReadBytePeek(OJPEGState* sp, uint8* byte) -{ - if (sp->in_buffer_togo==0) - { - if (OJPEGReadBufferFill(sp)==0) - return(0); - assert(sp->in_buffer_togo>0); - } - *byte=*(sp->in_buffer_cur); - return(1); -} - -static void -OJPEGReadByteAdvance(OJPEGState* sp) -{ - assert(sp->in_buffer_togo>0); - sp->in_buffer_cur++; - sp->in_buffer_togo--; -} - -static int -OJPEGReadWord(OJPEGState* sp, uint16* word) -{ - uint8 m; - if (OJPEGReadByte(sp,&m)==0) - return(0); - *word=(m<<8); - if (OJPEGReadByte(sp,&m)==0) - return(0); - *word|=m; - return(1); -} - -static int -OJPEGReadBlock(OJPEGState* sp, uint16 len, void* mem) -{ - uint16 mlen; - uint8* mmem; - uint16 n; - assert(len>0); - mlen=len; - mmem=mem; - do - { - if (sp->in_buffer_togo==0) - { - if (OJPEGReadBufferFill(sp)==0) - return(0); - assert(sp->in_buffer_togo>0); - } - n=mlen; - if (n>sp->in_buffer_togo) - n=sp->in_buffer_togo; - _TIFFmemcpy(mmem,sp->in_buffer_cur,n); - sp->in_buffer_cur+=n; - sp->in_buffer_togo-=n; - mlen-=n; - mmem+=n; - } while(mlen>0); - return(1); -} - -static void -OJPEGReadSkip(OJPEGState* sp, uint16 len) -{ - uint16 m; - uint16 n; - m=len; - n=m; - if (n>sp->in_buffer_togo) - n=sp->in_buffer_togo; - sp->in_buffer_cur+=n; - sp->in_buffer_togo-=n; - m-=n; - if (m>0) - { - assert(sp->in_buffer_togo==0); - n=m; - if (n>sp->in_buffer_file_togo) - n=sp->in_buffer_file_togo; - sp->in_buffer_file_pos+=n; - sp->in_buffer_file_togo-=n; - sp->in_buffer_file_pos_log=0; - /* we don't skip past jpeginterchangeformat/strile block... - * if that is asked from us, we're dealing with totally bazurk - * data anyway, and we've not seen this happening on any - * testfile, so we might as well likely cause some other - * meaningless error to be passed at some later time - */ - } -} - -static int -OJPEGWriteStream(TIFF* tif, void** mem, uint32* len) -{ - OJPEGState* sp=(OJPEGState*)tif->tif_data; - *len=0; - do - { - assert(sp->out_state<=ososEoi); - switch(sp->out_state) - { - case ososSoi: - OJPEGWriteStreamSoi(tif,mem,len); - break; - case ososQTable0: - OJPEGWriteStreamQTable(tif,0,mem,len); - break; - case ososQTable1: - OJPEGWriteStreamQTable(tif,1,mem,len); - break; - case ososQTable2: - OJPEGWriteStreamQTable(tif,2,mem,len); - break; - case ososQTable3: - OJPEGWriteStreamQTable(tif,3,mem,len); - break; - case ososDcTable0: - OJPEGWriteStreamDcTable(tif,0,mem,len); - break; - case ososDcTable1: - OJPEGWriteStreamDcTable(tif,1,mem,len); - break; - case ososDcTable2: - OJPEGWriteStreamDcTable(tif,2,mem,len); - break; - case ososDcTable3: - OJPEGWriteStreamDcTable(tif,3,mem,len); - break; - case ososAcTable0: - OJPEGWriteStreamAcTable(tif,0,mem,len); - break; - case ososAcTable1: - OJPEGWriteStreamAcTable(tif,1,mem,len); - break; - case ososAcTable2: - OJPEGWriteStreamAcTable(tif,2,mem,len); - break; - case ososAcTable3: - OJPEGWriteStreamAcTable(tif,3,mem,len); - break; - case ososDri: - OJPEGWriteStreamDri(tif,mem,len); - break; - case ososSof: - OJPEGWriteStreamSof(tif,mem,len); - break; - case ososSos: - OJPEGWriteStreamSos(tif,mem,len); - break; - case ososCompressed: - if (OJPEGWriteStreamCompressed(tif,mem,len)==0) - return(0); - break; - case ososRst: - OJPEGWriteStreamRst(tif,mem,len); - break; - case ososEoi: - OJPEGWriteStreamEoi(tif,mem,len); - break; - } - } while (*len==0); - return(1); -} - -static void -OJPEGWriteStreamSoi(TIFF* tif, void** mem, uint32* len) -{ - OJPEGState* sp=(OJPEGState*)tif->tif_data; - assert(OJPEG_BUFFER>=2); - sp->out_buffer[0]=255; - sp->out_buffer[1]=JPEG_MARKER_SOI; - *len=2; - *mem=(void*)sp->out_buffer; - sp->out_state++; -} - -static void -OJPEGWriteStreamQTable(TIFF* tif, uint8 table_index, void** mem, uint32* len) -{ - OJPEGState* sp=(OJPEGState*)tif->tif_data; - if (sp->qtable[table_index]!=0) - { - *mem=(void*)(sp->qtable[table_index]+sizeof(uint32)); - *len=*((uint32*)sp->qtable[table_index])-sizeof(uint32); - } - sp->out_state++; -} - -static void -OJPEGWriteStreamDcTable(TIFF* tif, uint8 table_index, void** mem, uint32* len) -{ - OJPEGState* sp=(OJPEGState*)tif->tif_data; - if (sp->dctable[table_index]!=0) - { - *mem=(void*)(sp->dctable[table_index]+sizeof(uint32)); - *len=*((uint32*)sp->dctable[table_index])-sizeof(uint32); - } - sp->out_state++; -} - -static void -OJPEGWriteStreamAcTable(TIFF* tif, uint8 table_index, void** mem, uint32* len) -{ - OJPEGState* sp=(OJPEGState*)tif->tif_data; - if (sp->actable[table_index]!=0) - { - *mem=(void*)(sp->actable[table_index]+sizeof(uint32)); - *len=*((uint32*)sp->actable[table_index])-sizeof(uint32); - } - sp->out_state++; -} - -static void -OJPEGWriteStreamDri(TIFF* tif, void** mem, uint32* len) -{ - OJPEGState* sp=(OJPEGState*)tif->tif_data; - assert(OJPEG_BUFFER>=6); - if (sp->restart_interval!=0) - { - sp->out_buffer[0]=255; - sp->out_buffer[1]=JPEG_MARKER_DRI; - sp->out_buffer[2]=0; - sp->out_buffer[3]=4; - sp->out_buffer[4]=(sp->restart_interval>>8); - sp->out_buffer[5]=(sp->restart_interval&255); - *len=6; - *mem=(void*)sp->out_buffer; - } - sp->out_state++; -} - -static void -OJPEGWriteStreamSof(TIFF* tif, void** mem, uint32* len) -{ - OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 m; - assert(OJPEG_BUFFER>=2+8+sp->samples_per_pixel_per_plane*3); - assert(255>=8+sp->samples_per_pixel_per_plane*3); - sp->out_buffer[0]=255; - sp->out_buffer[1]=sp->sof_marker_id; - /* Lf */ - sp->out_buffer[2]=0; - sp->out_buffer[3]=8+sp->samples_per_pixel_per_plane*3; - /* P */ - sp->out_buffer[4]=8; - /* Y */ - sp->out_buffer[5]=(sp->sof_y>>8); - sp->out_buffer[6]=(sp->sof_y&255); - /* X */ - sp->out_buffer[7]=(sp->sof_x>>8); - sp->out_buffer[8]=(sp->sof_x&255); - /* Nf */ - sp->out_buffer[9]=sp->samples_per_pixel_per_plane; - for (m=0; msamples_per_pixel_per_plane; m++) - { - /* C */ - sp->out_buffer[10+m*3]=sp->sof_c[sp->plane_sample_offset+m]; - /* H and V */ - sp->out_buffer[10+m*3+1]=sp->sof_hv[sp->plane_sample_offset+m]; - /* Tq */ - sp->out_buffer[10+m*3+2]=sp->sof_tq[sp->plane_sample_offset+m]; - } - *len=10+sp->samples_per_pixel_per_plane*3; - *mem=(void*)sp->out_buffer; - sp->out_state++; -} - -static void -OJPEGWriteStreamSos(TIFF* tif, void** mem, uint32* len) -{ - OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 m; - assert(OJPEG_BUFFER>=2+6+sp->samples_per_pixel_per_plane*2); - assert(255>=6+sp->samples_per_pixel_per_plane*2); - sp->out_buffer[0]=255; - sp->out_buffer[1]=JPEG_MARKER_SOS; - /* Ls */ - sp->out_buffer[2]=0; - sp->out_buffer[3]=6+sp->samples_per_pixel_per_plane*2; - /* Ns */ - sp->out_buffer[4]=sp->samples_per_pixel_per_plane; - for (m=0; msamples_per_pixel_per_plane; m++) - { - /* Cs */ - sp->out_buffer[5+m*2]=sp->sos_cs[sp->plane_sample_offset+m]; - /* Td and Ta */ - sp->out_buffer[5+m*2+1]=sp->sos_tda[sp->plane_sample_offset+m]; - } - /* Ss */ - sp->out_buffer[5+sp->samples_per_pixel_per_plane*2]=0; - /* Se */ - sp->out_buffer[5+sp->samples_per_pixel_per_plane*2+1]=63; - /* Ah and Al */ - sp->out_buffer[5+sp->samples_per_pixel_per_plane*2+2]=0; - *len=8+sp->samples_per_pixel_per_plane*2; - *mem=(void*)sp->out_buffer; - sp->out_state++; -} - -static int -OJPEGWriteStreamCompressed(TIFF* tif, void** mem, uint32* len) -{ - OJPEGState* sp=(OJPEGState*)tif->tif_data; - if (sp->in_buffer_togo==0) - { - if (OJPEGReadBufferFill(sp)==0) - return(0); - assert(sp->in_buffer_togo>0); - } - *len=sp->in_buffer_togo; - *mem=(void*)sp->in_buffer_cur; - sp->in_buffer_togo=0; - if (sp->in_buffer_file_togo==0) - { - switch(sp->in_buffer_source) - { - case osibsStrile: - if (sp->in_buffer_next_strilein_buffer_strile_count) - sp->out_state=ososRst; - else - sp->out_state=ososEoi; - break; - case osibsEof: - sp->out_state=ososEoi; - break; - default: - break; - } - } - return(1); -} - -static void -OJPEGWriteStreamRst(TIFF* tif, void** mem, uint32* len) -{ - OJPEGState* sp=(OJPEGState*)tif->tif_data; - assert(OJPEG_BUFFER>=2); - sp->out_buffer[0]=255; - sp->out_buffer[1]=JPEG_MARKER_RST0+sp->restart_index; - sp->restart_index++; - if (sp->restart_index==8) - sp->restart_index=0; - *len=2; - *mem=(void*)sp->out_buffer; - sp->out_state=ososCompressed; -} - -static void -OJPEGWriteStreamEoi(TIFF* tif, void** mem, uint32* len) -{ - OJPEGState* sp=(OJPEGState*)tif->tif_data; - assert(OJPEG_BUFFER>=2); - sp->out_buffer[0]=255; - sp->out_buffer[1]=JPEG_MARKER_EOI; - *len=2; - *mem=(void*)sp->out_buffer; -} - -#ifndef LIBJPEG_ENCAP_EXTERNAL -static int -jpeg_create_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo) -{ - return(SETJMP(sp->exit_jmpbuf)?0:(jpeg_create_decompress(cinfo),1)); -} -#endif - -#ifndef LIBJPEG_ENCAP_EXTERNAL -static int -jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8 require_image) -{ - return(SETJMP(sp->exit_jmpbuf)?0:(jpeg_read_header(cinfo,require_image),1)); -} -#endif - -#ifndef LIBJPEG_ENCAP_EXTERNAL -static int -jpeg_start_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo) -{ - return(SETJMP(sp->exit_jmpbuf)?0:(jpeg_start_decompress(cinfo),1)); -} -#endif - -#ifndef LIBJPEG_ENCAP_EXTERNAL -static int -jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32 max_lines) -{ - return(SETJMP(sp->exit_jmpbuf)?0:(jpeg_read_scanlines(cinfo,scanlines,max_lines),1)); -} -#endif - -#ifndef LIBJPEG_ENCAP_EXTERNAL -static int -jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32 max_lines) -{ - return(SETJMP(sp->exit_jmpbuf)?0:(jpeg_read_raw_data(cinfo,data,max_lines),1)); -} -#endif - -#ifndef LIBJPEG_ENCAP_EXTERNAL -static void -jpeg_encap_unwind(TIFF* tif) -{ - OJPEGState* sp=(OJPEGState*)tif->tif_data; - LONGJMP(sp->exit_jmpbuf,1); -} -#endif - -static void -OJPEGLibjpegJpegErrorMgrOutputMessage(jpeg_common_struct* cinfo) -{ - char buffer[JMSG_LENGTH_MAX]; - (*cinfo->err->format_message)(cinfo,buffer); - TIFFWarningExt(((TIFF*)(cinfo->client_data))->tif_clientdata,"LibJpeg", "%s", buffer); -} - -static void -OJPEGLibjpegJpegErrorMgrErrorExit(jpeg_common_struct* cinfo) -{ - char buffer[JMSG_LENGTH_MAX]; - (*cinfo->err->format_message)(cinfo,buffer); - TIFFErrorExt(((TIFF*)(cinfo->client_data))->tif_clientdata,"LibJpeg", "%s", buffer); - jpeg_encap_unwind((TIFF*)(cinfo->client_data)); -} - -static void -OJPEGLibjpegJpegSourceMgrInitSource(jpeg_decompress_struct* cinfo) -{ - (void)cinfo; -} - -static boolean -OJPEGLibjpegJpegSourceMgrFillInputBuffer(jpeg_decompress_struct* cinfo) -{ - TIFF* tif=(TIFF*)cinfo->client_data; - OJPEGState* sp=(OJPEGState*)tif->tif_data; - void* mem=0; - uint32 len=0; - if (OJPEGWriteStream(tif,&mem,&len)==0) - { - TIFFErrorExt(tif->tif_clientdata,"LibJpeg","Premature end of JPEG data"); - jpeg_encap_unwind(tif); - } - sp->libjpeg_jpeg_source_mgr.bytes_in_buffer=len; - sp->libjpeg_jpeg_source_mgr.next_input_byte=mem; - return(1); -} - -static void -OJPEGLibjpegJpegSourceMgrSkipInputData(jpeg_decompress_struct* cinfo, long num_bytes) -{ - TIFF* tif=(TIFF*)cinfo->client_data; - (void)num_bytes; - TIFFErrorExt(tif->tif_clientdata,"LibJpeg","Unexpected error"); - jpeg_encap_unwind(tif); -} - -static boolean -OJPEGLibjpegJpegSourceMgrResyncToRestart(jpeg_decompress_struct* cinfo, int desired) -{ - TIFF* tif=(TIFF*)cinfo->client_data; - (void)desired; - TIFFErrorExt(tif->tif_clientdata,"LibJpeg","Unexpected error"); - jpeg_encap_unwind(tif); - return(0); -} - -static void -OJPEGLibjpegJpegSourceMgrTermSource(jpeg_decompress_struct* cinfo) -{ - (void)cinfo; -} - -#endif - - -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_open.c b/plugins/AdvaImg/src/LibTIFF/tif_open.c deleted file mode 100644 index c2a0412e90..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_open.c +++ /dev/null @@ -1,695 +0,0 @@ -/* $Id: tif_open.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - */ -#include "tiffiop.h" - -static const long typemask[13] = { - (long)0L, /* TIFF_NOTYPE */ - (long)0x000000ffL, /* TIFF_BYTE */ - (long)0xffffffffL, /* TIFF_ASCII */ - (long)0x0000ffffL, /* TIFF_SHORT */ - (long)0xffffffffL, /* TIFF_LONG */ - (long)0xffffffffL, /* TIFF_RATIONAL */ - (long)0x000000ffL, /* TIFF_SBYTE */ - (long)0x000000ffL, /* TIFF_UNDEFINED */ - (long)0x0000ffffL, /* TIFF_SSHORT */ - (long)0xffffffffL, /* TIFF_SLONG */ - (long)0xffffffffL, /* TIFF_SRATIONAL */ - (long)0xffffffffL, /* TIFF_FLOAT */ - (long)0xffffffffL, /* TIFF_DOUBLE */ -}; -static const int bigTypeshift[13] = { - 0, /* TIFF_NOTYPE */ - 24, /* TIFF_BYTE */ - 0, /* TIFF_ASCII */ - 16, /* TIFF_SHORT */ - 0, /* TIFF_LONG */ - 0, /* TIFF_RATIONAL */ - 24, /* TIFF_SBYTE */ - 24, /* TIFF_UNDEFINED */ - 16, /* TIFF_SSHORT */ - 0, /* TIFF_SLONG */ - 0, /* TIFF_SRATIONAL */ - 0, /* TIFF_FLOAT */ - 0, /* TIFF_DOUBLE */ -}; -static const int litTypeshift[13] = { - 0, /* TIFF_NOTYPE */ - 0, /* TIFF_BYTE */ - 0, /* TIFF_ASCII */ - 0, /* TIFF_SHORT */ - 0, /* TIFF_LONG */ - 0, /* TIFF_RATIONAL */ - 0, /* TIFF_SBYTE */ - 0, /* TIFF_UNDEFINED */ - 0, /* TIFF_SSHORT */ - 0, /* TIFF_SLONG */ - 0, /* TIFF_SRATIONAL */ - 0, /* TIFF_FLOAT */ - 0, /* TIFF_DOUBLE */ -}; - -/* - * Dummy functions to fill the omitted client procedures. - */ -static int -_tiffDummyMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - (void) fd; (void) pbase; (void) psize; - return (0); -} - -static void -_tiffDummyUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ - (void) fd; (void) base; (void) size; -} - -/* - * Initialize the shift & mask tables, and the - * byte swapping state according to the file - * contents and the machine architecture. - */ -static void -TIFFInitOrder(TIFF* tif, int magic) -{ - tif->tif_typemask = typemask; - if (magic == TIFF_BIGENDIAN) { - tif->tif_typeshift = bigTypeshift; -#ifndef WORDS_BIGENDIAN - tif->tif_flags |= TIFF_SWAB; -#endif - } else { - tif->tif_typeshift = litTypeshift; -#ifdef WORDS_BIGENDIAN - tif->tif_flags |= TIFF_SWAB; -#endif - } -} - -int -_TIFFgetMode(const char* mode, const char* module) -{ - int m = -1; - - switch (mode[0]) { - case 'r': - m = O_RDONLY; - if (mode[1] == '+') - m = O_RDWR; - break; - case 'w': - case 'a': - m = O_RDWR|O_CREAT; - if (mode[0] == 'w') - m |= O_TRUNC; - break; - default: - TIFFErrorExt(0, module, "\"%s\": Bad mode", mode); - break; - } - return (m); -} - -TIFF* -TIFFClientOpen( - const char* name, const char* mode, - thandle_t clientdata, - TIFFReadWriteProc readproc, - TIFFReadWriteProc writeproc, - TIFFSeekProc seekproc, - TIFFCloseProc closeproc, - TIFFSizeProc sizeproc, - TIFFMapFileProc mapproc, - TIFFUnmapFileProc unmapproc -) -{ - static const char module[] = "TIFFClientOpen"; - TIFF *tif; - int m; - const char* cp; - - m = _TIFFgetMode(mode, module); - if (m == -1) - goto bad2; - tif = (TIFF *)_TIFFmalloc(sizeof (TIFF) + strlen(name) + 1); - if (tif == NULL) { - TIFFErrorExt(clientdata, module, "%s: Out of memory (TIFF structure)", name); - goto bad2; - } - _TIFFmemset(tif, 0, sizeof (*tif)); - tif->tif_name = (char *)tif + sizeof (TIFF); - strcpy(tif->tif_name, name); - tif->tif_mode = m &~ (O_CREAT|O_TRUNC); - tif->tif_curdir = (tdir_t) -1; /* non-existent directory */ - tif->tif_curoff = 0; - tif->tif_curstrip = (tstrip_t) -1; /* invalid strip */ - tif->tif_row = (uint32) -1; /* read/write pre-increment */ - tif->tif_clientdata = clientdata; - if (!readproc || !writeproc || !seekproc || !closeproc || !sizeproc) { - TIFFErrorExt(clientdata, module, - "One of the client procedures is NULL pointer."); - goto bad2; - } - tif->tif_readproc = readproc; - tif->tif_writeproc = writeproc; - tif->tif_seekproc = seekproc; - tif->tif_closeproc = closeproc; - tif->tif_sizeproc = sizeproc; - if (mapproc) - tif->tif_mapproc = mapproc; - else - tif->tif_mapproc = _tiffDummyMapProc; - if (unmapproc) - tif->tif_unmapproc = unmapproc; - else - tif->tif_unmapproc = _tiffDummyUnmapProc; - _TIFFSetDefaultCompressionState(tif); /* setup default state */ - /* - * Default is to return data MSB2LSB and enable the - * use of memory-mapped files and strip chopping when - * a file is opened read-only. - */ - tif->tif_flags = FILLORDER_MSB2LSB; - if (m == O_RDONLY ) - tif->tif_flags |= TIFF_MAPPED; - -#ifdef STRIPCHOP_DEFAULT - if (m == O_RDONLY || m == O_RDWR) - tif->tif_flags |= STRIPCHOP_DEFAULT; -#endif - - /* - * Process library-specific flags in the open mode string. - * The following flags may be used to control intrinsic library - * behaviour that may or may not be desirable (usually for - * compatibility with some application that claims to support - * TIFF but only supports some braindead idea of what the - * vendor thinks TIFF is): - * - * 'l' use little-endian byte order for creating a file - * 'b' use big-endian byte order for creating a file - * 'L' read/write information using LSB2MSB bit order - * 'B' read/write information using MSB2LSB bit order - * 'H' read/write information using host bit order - * 'M' enable use of memory-mapped files when supported - * 'm' disable use of memory-mapped files - * 'C' enable strip chopping support when reading - * 'c' disable strip chopping support - * 'h' read TIFF header only, do not load the first IFD - * - * The use of the 'l' and 'b' flags is strongly discouraged. - * These flags are provided solely because numerous vendors, - * typically on the PC, do not correctly support TIFF; they - * only support the Intel little-endian byte order. This - * support is not configured by default because it supports - * the violation of the TIFF spec that says that readers *MUST* - * support both byte orders. It is strongly recommended that - * you not use this feature except to deal with busted apps - * that write invalid TIFF. And even in those cases you should - * bang on the vendors to fix their software. - * - * The 'L', 'B', and 'H' flags are intended for applications - * that can optimize operations on data by using a particular - * bit order. By default the library returns data in MSB2LSB - * bit order for compatibiltiy with older versions of this - * library. Returning data in the bit order of the native cpu - * makes the most sense but also requires applications to check - * the value of the FillOrder tag; something they probably do - * not do right now. - * - * The 'M' and 'm' flags are provided because some virtual memory - * systems exhibit poor behaviour when large images are mapped. - * These options permit clients to control the use of memory-mapped - * files on a per-file basis. - * - * The 'C' and 'c' flags are provided because the library support - * for chopping up large strips into multiple smaller strips is not - * application-transparent and as such can cause problems. The 'c' - * option permits applications that only want to look at the tags, - * for example, to get the unadulterated TIFF tag information. - */ - for (cp = mode; *cp; cp++) - switch (*cp) { - case 'b': -#ifndef WORDS_BIGENDIAN - if (m&O_CREAT) - tif->tif_flags |= TIFF_SWAB; -#endif - break; - case 'l': -#ifdef WORDS_BIGENDIAN - if ((m&O_CREAT)) - tif->tif_flags |= TIFF_SWAB; -#endif - break; - case 'B': - tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) | - FILLORDER_MSB2LSB; - break; - case 'L': - tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) | - FILLORDER_LSB2MSB; - break; - case 'H': - tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) | - HOST_FILLORDER; - break; - case 'M': - if (m == O_RDONLY) - tif->tif_flags |= TIFF_MAPPED; - break; - case 'm': - if (m == O_RDONLY) - tif->tif_flags &= ~TIFF_MAPPED; - break; - case 'C': - if (m == O_RDONLY) - tif->tif_flags |= TIFF_STRIPCHOP; - break; - case 'c': - if (m == O_RDONLY) - tif->tif_flags &= ~TIFF_STRIPCHOP; - break; - case 'h': - tif->tif_flags |= TIFF_HEADERONLY; - break; - } - /* - * Read in TIFF header. - */ - if ((m & O_TRUNC) || - !ReadOK(tif, &tif->tif_header, sizeof (TIFFHeader))) { - if (tif->tif_mode == O_RDONLY) { - TIFFErrorExt(tif->tif_clientdata, name, - "Cannot read TIFF header"); - goto bad; - } - /* - * Setup header and write. - */ -#ifdef WORDS_BIGENDIAN - tif->tif_header.tiff_magic = tif->tif_flags & TIFF_SWAB - ? TIFF_LITTLEENDIAN : TIFF_BIGENDIAN; -#else - tif->tif_header.tiff_magic = tif->tif_flags & TIFF_SWAB - ? TIFF_BIGENDIAN : TIFF_LITTLEENDIAN; -#endif - tif->tif_header.tiff_version = TIFF_VERSION; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&tif->tif_header.tiff_version); - tif->tif_header.tiff_diroff = 0; /* filled in later */ - - - /* - * The doc for "fopen" for some STD_C_LIBs says that if you - * open a file for modify ("+"), then you must fseek (or - * fflush?) between any freads and fwrites. This is not - * necessary on most systems, but has been shown to be needed - * on Solaris. - */ - TIFFSeekFile( tif, 0, SEEK_SET ); - - if (!WriteOK(tif, &tif->tif_header, sizeof (TIFFHeader))) { - TIFFErrorExt(tif->tif_clientdata, name, - "Error writing TIFF header"); - goto bad; - } - /* - * Setup the byte order handling. - */ - TIFFInitOrder(tif, tif->tif_header.tiff_magic); - /* - * Setup default directory. - */ - if (!TIFFDefaultDirectory(tif)) - goto bad; - tif->tif_diroff = 0; - tif->tif_dirlist = NULL; - tif->tif_dirlistsize = 0; - tif->tif_dirnumber = 0; - return (tif); - } - /* - * Setup the byte order handling. - */ - if (tif->tif_header.tiff_magic != TIFF_BIGENDIAN && - tif->tif_header.tiff_magic != TIFF_LITTLEENDIAN -#if MDI_SUPPORT - && -#if HOST_BIGENDIAN - tif->tif_header.tiff_magic != MDI_BIGENDIAN -#else - tif->tif_header.tiff_magic != MDI_LITTLEENDIAN -#endif - ) { - TIFFErrorExt(tif->tif_clientdata, name, - "Not a TIFF or MDI file, bad magic number %d (0x%x)", -#else - ) { - TIFFErrorExt(tif->tif_clientdata, name, - "Not a TIFF file, bad magic number %d (0x%x)", -#endif - tif->tif_header.tiff_magic, - tif->tif_header.tiff_magic); - goto bad; - } - TIFFInitOrder(tif, tif->tif_header.tiff_magic); - /* - * Swap header if required. - */ - if (tif->tif_flags & TIFF_SWAB) { - TIFFSwabShort(&tif->tif_header.tiff_version); - TIFFSwabLong(&tif->tif_header.tiff_diroff); - } - /* - * Now check version (if needed, it's been byte-swapped). - * Note that this isn't actually a version number, it's a - * magic number that doesn't change (stupid). - */ - if (tif->tif_header.tiff_version == TIFF_BIGTIFF_VERSION) { - TIFFErrorExt(tif->tif_clientdata, name, - "This is a BigTIFF file. This format not supported\n" - "by this version of libtiff." ); - goto bad; - } - if (tif->tif_header.tiff_version != TIFF_VERSION) { - TIFFErrorExt(tif->tif_clientdata, name, - "Not a TIFF file, bad version number %d (0x%x)", - tif->tif_header.tiff_version, - tif->tif_header.tiff_version); - goto bad; - } - tif->tif_flags |= TIFF_MYBUFFER; - tif->tif_rawcp = tif->tif_rawdata = 0; - tif->tif_rawdatasize = 0; - - /* - * Sometimes we do not want to read the first directory (for example, - * it may be broken) and want to proceed to other directories. I this - * case we use the TIFF_HEADERONLY flag to open file and return - * immediately after reading TIFF header. - */ - if (tif->tif_flags & TIFF_HEADERONLY) - return (tif); - - /* - * Setup initial directory. - */ - switch (mode[0]) { - case 'r': - tif->tif_nextdiroff = tif->tif_header.tiff_diroff; - /* - * Try to use a memory-mapped file if the client - * has not explicitly suppressed usage with the - * 'm' flag in the open mode (see above). - */ - if ((tif->tif_flags & TIFF_MAPPED) && - !TIFFMapFileContents(tif, (tdata_t*) &tif->tif_base, &tif->tif_size)) - tif->tif_flags &= ~TIFF_MAPPED; - if (TIFFReadDirectory(tif)) { - tif->tif_rawcc = -1; - tif->tif_flags |= TIFF_BUFFERSETUP; - return (tif); - } - break; - case 'a': - /* - * New directories are automatically append - * to the end of the directory chain when they - * are written out (see TIFFWriteDirectory). - */ - if (!TIFFDefaultDirectory(tif)) - goto bad; - return (tif); - } -bad: - tif->tif_mode = O_RDONLY; /* XXX avoid flush */ - TIFFCleanup(tif); -bad2: - return ((TIFF*)0); -} - -/* - * Query functions to access private data. - */ - -/* - * Return open file's name. - */ -const char * -TIFFFileName(TIFF* tif) -{ - return (tif->tif_name); -} - -/* - * Set the file name. - */ -const char * -TIFFSetFileName(TIFF* tif, const char *name) -{ - const char* old_name = tif->tif_name; - tif->tif_name = (char *)name; - return (old_name); -} - -/* - * Return open file's I/O descriptor. - */ -int -TIFFFileno(TIFF* tif) -{ - return (tif->tif_fd); -} - -/* - * Set open file's I/O descriptor, and return previous value. - */ -int -TIFFSetFileno(TIFF* tif, int fd) -{ - int old_fd = tif->tif_fd; - tif->tif_fd = fd; - return old_fd; -} - -/* - * Return open file's clientdata. - */ -thandle_t -TIFFClientdata(TIFF* tif) -{ - return (tif->tif_clientdata); -} - -/* - * Set open file's clientdata, and return previous value. - */ -thandle_t -TIFFSetClientdata(TIFF* tif, thandle_t newvalue) -{ - thandle_t m = tif->tif_clientdata; - tif->tif_clientdata = newvalue; - return m; -} - -/* - * Return read/write mode. - */ -int -TIFFGetMode(TIFF* tif) -{ - return (tif->tif_mode); -} - -/* - * Return read/write mode. - */ -int -TIFFSetMode(TIFF* tif, int mode) -{ - int old_mode = tif->tif_mode; - tif->tif_mode = mode; - return (old_mode); -} - -/* - * Return nonzero if file is organized in - * tiles; zero if organized as strips. - */ -int -TIFFIsTiled(TIFF* tif) -{ - return (isTiled(tif)); -} - -/* - * Return current row being read/written. - */ -uint32 -TIFFCurrentRow(TIFF* tif) -{ - return (tif->tif_row); -} - -/* - * Return index of the current directory. - */ -tdir_t -TIFFCurrentDirectory(TIFF* tif) -{ - return (tif->tif_curdir); -} - -/* - * Return current strip. - */ -tstrip_t -TIFFCurrentStrip(TIFF* tif) -{ - return (tif->tif_curstrip); -} - -/* - * Return current tile. - */ -ttile_t -TIFFCurrentTile(TIFF* tif) -{ - return (tif->tif_curtile); -} - -/* - * Return nonzero if the file has byte-swapped data. - */ -int -TIFFIsByteSwapped(TIFF* tif) -{ - return ((tif->tif_flags & TIFF_SWAB) != 0); -} - -/* - * Return nonzero if the data is returned up-sampled. - */ -int -TIFFIsUpSampled(TIFF* tif) -{ - return (isUpSampled(tif)); -} - -/* - * Return nonzero if the data is returned in MSB-to-LSB bit order. - */ -int -TIFFIsMSB2LSB(TIFF* tif) -{ - return (isFillOrder(tif, FILLORDER_MSB2LSB)); -} - -/* - * Return nonzero if given file was written in big-endian order. - */ -int -TIFFIsBigEndian(TIFF* tif) -{ - return (tif->tif_header.tiff_magic == TIFF_BIGENDIAN); -} - -/* - * Return pointer to file read method. - */ -TIFFReadWriteProc -TIFFGetReadProc(TIFF* tif) -{ - return (tif->tif_readproc); -} - -/* - * Return pointer to file write method. - */ -TIFFReadWriteProc -TIFFGetWriteProc(TIFF* tif) -{ - return (tif->tif_writeproc); -} - -/* - * Return pointer to file seek method. - */ -TIFFSeekProc -TIFFGetSeekProc(TIFF* tif) -{ - return (tif->tif_seekproc); -} - -/* - * Return pointer to file close method. - */ -TIFFCloseProc -TIFFGetCloseProc(TIFF* tif) -{ - return (tif->tif_closeproc); -} - -/* - * Return pointer to file size requesting method. - */ -TIFFSizeProc -TIFFGetSizeProc(TIFF* tif) -{ - return (tif->tif_sizeproc); -} - -/* - * Return pointer to memory mapping method. - */ -TIFFMapFileProc -TIFFGetMapFileProc(TIFF* tif) -{ - return (tif->tif_mapproc); -} - -/* - * Return pointer to memory unmapping method. - */ -TIFFUnmapFileProc -TIFFGetUnmapFileProc(TIFF* tif) -{ - return (tif->tif_unmapproc); -} - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_packbits.c b/plugins/AdvaImg/src/LibTIFF/tif_packbits.c deleted file mode 100644 index 1fc96d13a2..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_packbits.c +++ /dev/null @@ -1,300 +0,0 @@ -/* $Id: tif_packbits.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#include "tiffiop.h" -#ifdef PACKBITS_SUPPORT -/* - * TIFF Library. - * - * PackBits Compression Algorithm Support - */ -#include - -static int -PackBitsPreEncode(TIFF* tif, tsample_t s) -{ - (void) s; - - if (!(tif->tif_data = (tidata_t)_TIFFmalloc(sizeof(tsize_t)))) - return (0); - /* - * Calculate the scanline/tile-width size in bytes. - */ - if (isTiled(tif)) - *(tsize_t*)tif->tif_data = TIFFTileRowSize(tif); - else - *(tsize_t*)tif->tif_data = TIFFScanlineSize(tif); - return (1); -} - -static int -PackBitsPostEncode(TIFF* tif) -{ - if (tif->tif_data) - _TIFFfree(tif->tif_data); - return (1); -} - -/* - * NB: tidata is the type representing *(tidata_t); - * if tidata_t is made signed then this type must - * be adjusted accordingly. - */ -typedef unsigned char tidata; - -/* - * Encode a run of pixels. - */ -static int -PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) -{ - unsigned char* bp = (unsigned char*) buf; - tidata_t op, ep, lastliteral; - long n, slop; - int b; - enum { BASE, LITERAL, RUN, LITERAL_RUN } state; - - (void) s; - op = tif->tif_rawcp; - ep = tif->tif_rawdata + tif->tif_rawdatasize; - state = BASE; - lastliteral = 0; - while (cc > 0) { - /* - * Find the longest string of identical bytes. - */ - b = *bp++, cc--, n = 1; - for (; cc > 0 && b == *bp; cc--, bp++) - n++; - again: - if (op + 2 >= ep) { /* insure space for new data */ - /* - * Be careful about writing the last - * literal. Must write up to that point - * and then copy the remainder to the - * front of the buffer. - */ - if (state == LITERAL || state == LITERAL_RUN) { - slop = op - lastliteral; - tif->tif_rawcc += lastliteral - tif->tif_rawcp; - if (!TIFFFlushData1(tif)) - return (-1); - op = tif->tif_rawcp; - while (slop-- > 0) - *op++ = *lastliteral++; - lastliteral = tif->tif_rawcp; - } else { - tif->tif_rawcc += op - tif->tif_rawcp; - if (!TIFFFlushData1(tif)) - return (-1); - op = tif->tif_rawcp; - } - } - switch (state) { - case BASE: /* initial state, set run/literal */ - if (n > 1) { - state = RUN; - if (n > 128) { - *op++ = (tidata) -127; - *op++ = (tidataval_t) b; - n -= 128; - goto again; - } - *op++ = (tidataval_t)(-(n-1)); - *op++ = (tidataval_t) b; - } else { - lastliteral = op; - *op++ = 0; - *op++ = (tidataval_t) b; - state = LITERAL; - } - break; - case LITERAL: /* last object was literal string */ - if (n > 1) { - state = LITERAL_RUN; - if (n > 128) { - *op++ = (tidata) -127; - *op++ = (tidataval_t) b; - n -= 128; - goto again; - } - *op++ = (tidataval_t)(-(n-1)); /* encode run */ - *op++ = (tidataval_t) b; - } else { /* extend literal */ - if (++(*lastliteral) == 127) - state = BASE; - *op++ = (tidataval_t) b; - } - break; - case RUN: /* last object was run */ - if (n > 1) { - if (n > 128) { - *op++ = (tidata) -127; - *op++ = (tidataval_t) b; - n -= 128; - goto again; - } - *op++ = (tidataval_t)(-(n-1)); - *op++ = (tidataval_t) b; - } else { - lastliteral = op; - *op++ = 0; - *op++ = (tidataval_t) b; - state = LITERAL; - } - break; - case LITERAL_RUN: /* literal followed by a run */ - /* - * Check to see if previous run should - * be converted to a literal, in which - * case we convert literal-run-literal - * to a single literal. - */ - if (n == 1 && op[-2] == (tidata) -1 && - *lastliteral < 126) { - state = (((*lastliteral) += 2) == 127 ? - BASE : LITERAL); - op[-2] = op[-1]; /* replicate */ - } else - state = RUN; - goto again; - } - } - tif->tif_rawcc += op - tif->tif_rawcp; - tif->tif_rawcp = op; - return (1); -} - -/* - * Encode a rectangular chunk of pixels. We break it up - * into row-sized pieces to insure that encoded runs do - * not span rows. Otherwise, there can be problems with - * the decoder if data is read, for example, by scanlines - * when it was encoded by strips. - */ -static int -PackBitsEncodeChunk(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - tsize_t rowsize = *(tsize_t*)tif->tif_data; - - while ((long)cc > 0) { - int chunk = rowsize; - - if ( cc < chunk ) - chunk = cc; - - if (PackBitsEncode(tif, bp, chunk, s) < 0) - return (-1); - bp += chunk; - cc -= chunk; - } - return (1); -} - -static int -PackBitsDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) -{ - char *bp; - tsize_t cc; - long n; - int b; - - (void) s; - bp = (char*) tif->tif_rawcp; - cc = tif->tif_rawcc; - while (cc > 0 && (long)occ > 0) { - n = (long) *bp++, cc--; - /* - * Watch out for compilers that - * don't sign extend chars... - */ - if (n >= 128) - n -= 256; - if (n < 0) { /* replicate next byte -n+1 times */ - if (n == -128) /* nop */ - continue; - n = -n + 1; - if ( occ < n ) - { - TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "PackBitsDecode: discarding %ld bytes " - "to avoid buffer overrun", - n - occ); - n = occ; - } - occ -= n; - b = *bp++, cc--; - while (n-- > 0) - *op++ = (tidataval_t) b; - } else { /* copy next n+1 bytes literally */ - if (occ < n + 1) - { - TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "PackBitsDecode: discarding %ld bytes " - "to avoid buffer overrun", - n - occ + 1); - n = occ - 1; - } - _TIFFmemcpy(op, bp, ++n); - op += n; occ -= n; - bp += n; cc -= n; - } - } - tif->tif_rawcp = (tidata_t) bp; - tif->tif_rawcc = cc; - if (occ > 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "PackBitsDecode: Not enough data for scanline %ld", - (long) tif->tif_row); - return (0); - } - return (1); -} - -int -TIFFInitPackBits(TIFF* tif, int scheme) -{ - (void) scheme; - tif->tif_decoderow = PackBitsDecode; - tif->tif_decodestrip = PackBitsDecode; - tif->tif_decodetile = PackBitsDecode; - tif->tif_preencode = PackBitsPreEncode; - tif->tif_postencode = PackBitsPostEncode; - tif->tif_encoderow = PackBitsEncode; - tif->tif_encodestrip = PackBitsEncodeChunk; - tif->tif_encodetile = PackBitsEncodeChunk; - return (1); -} -#endif /* PACKBITS_SUPPORT */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_pixarlog.c b/plugins/AdvaImg/src/LibTIFF/tif_pixarlog.c deleted file mode 100644 index ef4faa4e45..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_pixarlog.c +++ /dev/null @@ -1,1371 +0,0 @@ -/* $Id: tif_pixarlog.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1996-1997 Sam Leffler - * Copyright (c) 1996 Pixar - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Pixar, Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Pixar, Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL PIXAR, SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#include "tiffiop.h" -#ifdef PIXARLOG_SUPPORT - -/* - * TIFF Library. - * PixarLog Compression Support - * - * Contributed by Dan McCoy. - * - * PixarLog film support uses the TIFF library to store companded - * 11 bit values into a tiff file, which are compressed using the - * zip compressor. - * - * The codec can take as input and produce as output 32-bit IEEE float values - * as well as 16-bit or 8-bit unsigned integer values. - * - * On writing any of the above are converted into the internal - * 11-bit log format. In the case of 8 and 16 bit values, the - * input is assumed to be unsigned linear color values that represent - * the range 0-1. In the case of IEEE values, the 0-1 range is assumed to - * be the normal linear color range, in addition over 1 values are - * accepted up to a value of about 25.0 to encode "hot" hightlights and such. - * The encoding is lossless for 8-bit values, slightly lossy for the - * other bit depths. The actual color precision should be better - * than the human eye can perceive with extra room to allow for - * error introduced by further image computation. As with any quantized - * color format, it is possible to perform image calculations which - * expose the quantization error. This format should certainly be less - * susceptable to such errors than standard 8-bit encodings, but more - * susceptable than straight 16-bit or 32-bit encodings. - * - * On reading the internal format is converted to the desired output format. - * The program can request which format it desires by setting the internal - * pseudo tag TIFFTAG_PIXARLOGDATAFMT to one of these possible values: - * PIXARLOGDATAFMT_FLOAT = provide IEEE float values. - * PIXARLOGDATAFMT_16BIT = provide unsigned 16-bit integer values - * PIXARLOGDATAFMT_8BIT = provide unsigned 8-bit integer values - * - * alternately PIXARLOGDATAFMT_8BITABGR provides unsigned 8-bit integer - * values with the difference that if there are exactly three or four channels - * (rgb or rgba) it swaps the channel order (bgr or abgr). - * - * PIXARLOGDATAFMT_11BITLOG provides the internal encoding directly - * packed in 16-bit values. However no tools are supplied for interpreting - * these values. - * - * "hot" (over 1.0) areas written in floating point get clamped to - * 1.0 in the integer data types. - * - * When the file is closed after writing, the bit depth and sample format - * are set always to appear as if 8-bit data has been written into it. - * That way a naive program unaware of the particulars of the encoding - * gets the format it is most likely able to handle. - * - * The codec does it's own horizontal differencing step on the coded - * values so the libraries predictor stuff should be turned off. - * The codec also handle byte swapping the encoded values as necessary - * since the library does not have the information necessary - * to know the bit depth of the raw unencoded buffer. - * - */ - -#include "tif_predict.h" -#include "../ZLib/zlib.h" - -#include -#include -#include - -/* Tables for converting to/from 11 bit coded values */ - -#define TSIZE 2048 /* decode table size (11-bit tokens) */ -#define TSIZEP1 2049 /* Plus one for slop */ -#define ONE 1250 /* token value of 1.0 exactly */ -#define RATIO 1.004 /* nominal ratio for log part */ - -#define CODE_MASK 0x7ff /* 11 bits. */ - -static float Fltsize; -static float LogK1, LogK2; - -#define REPEAT(n, op) { int i; i=n; do { i--; op; } while (i>0); } - -static void -horizontalAccumulateF(uint16 *wp, int n, int stride, float *op, - float *ToLinearF) -{ - register unsigned int cr, cg, cb, ca, mask; - register float t0, t1, t2, t3; - - if (n >= stride) { - mask = CODE_MASK; - if (stride == 3) { - t0 = ToLinearF[cr = wp[0]]; - t1 = ToLinearF[cg = wp[1]]; - t2 = ToLinearF[cb = wp[2]]; - op[0] = t0; - op[1] = t1; - op[2] = t2; - n -= 3; - while (n > 0) { - wp += 3; - op += 3; - n -= 3; - t0 = ToLinearF[(cr += wp[0]) & mask]; - t1 = ToLinearF[(cg += wp[1]) & mask]; - t2 = ToLinearF[(cb += wp[2]) & mask]; - op[0] = t0; - op[1] = t1; - op[2] = t2; - } - } else if (stride == 4) { - t0 = ToLinearF[cr = wp[0]]; - t1 = ToLinearF[cg = wp[1]]; - t2 = ToLinearF[cb = wp[2]]; - t3 = ToLinearF[ca = wp[3]]; - op[0] = t0; - op[1] = t1; - op[2] = t2; - op[3] = t3; - n -= 4; - while (n > 0) { - wp += 4; - op += 4; - n -= 4; - t0 = ToLinearF[(cr += wp[0]) & mask]; - t1 = ToLinearF[(cg += wp[1]) & mask]; - t2 = ToLinearF[(cb += wp[2]) & mask]; - t3 = ToLinearF[(ca += wp[3]) & mask]; - op[0] = t0; - op[1] = t1; - op[2] = t2; - op[3] = t3; - } - } else { - REPEAT(stride, *op = ToLinearF[*wp&mask]; wp++; op++) - n -= stride; - while (n > 0) { - REPEAT(stride, - wp[stride] += *wp; *op = ToLinearF[*wp&mask]; wp++; op++) - n -= stride; - } - } - } -} - -static void -horizontalAccumulate12(uint16 *wp, int n, int stride, int16 *op, - float *ToLinearF) -{ - register unsigned int cr, cg, cb, ca, mask; - register float t0, t1, t2, t3; - -#define SCALE12 2048.0F -#define CLAMP12(t) (((t) < 3071) ? (uint16) (t) : 3071) - - if (n >= stride) { - mask = CODE_MASK; - if (stride == 3) { - t0 = ToLinearF[cr = wp[0]] * SCALE12; - t1 = ToLinearF[cg = wp[1]] * SCALE12; - t2 = ToLinearF[cb = wp[2]] * SCALE12; - op[0] = CLAMP12(t0); - op[1] = CLAMP12(t1); - op[2] = CLAMP12(t2); - n -= 3; - while (n > 0) { - wp += 3; - op += 3; - n -= 3; - t0 = ToLinearF[(cr += wp[0]) & mask] * SCALE12; - t1 = ToLinearF[(cg += wp[1]) & mask] * SCALE12; - t2 = ToLinearF[(cb += wp[2]) & mask] * SCALE12; - op[0] = CLAMP12(t0); - op[1] = CLAMP12(t1); - op[2] = CLAMP12(t2); - } - } else if (stride == 4) { - t0 = ToLinearF[cr = wp[0]] * SCALE12; - t1 = ToLinearF[cg = wp[1]] * SCALE12; - t2 = ToLinearF[cb = wp[2]] * SCALE12; - t3 = ToLinearF[ca = wp[3]] * SCALE12; - op[0] = CLAMP12(t0); - op[1] = CLAMP12(t1); - op[2] = CLAMP12(t2); - op[3] = CLAMP12(t3); - n -= 4; - while (n > 0) { - wp += 4; - op += 4; - n -= 4; - t0 = ToLinearF[(cr += wp[0]) & mask] * SCALE12; - t1 = ToLinearF[(cg += wp[1]) & mask] * SCALE12; - t2 = ToLinearF[(cb += wp[2]) & mask] * SCALE12; - t3 = ToLinearF[(ca += wp[3]) & mask] * SCALE12; - op[0] = CLAMP12(t0); - op[1] = CLAMP12(t1); - op[2] = CLAMP12(t2); - op[3] = CLAMP12(t3); - } - } else { - REPEAT(stride, t0 = ToLinearF[*wp&mask] * SCALE12; - *op = CLAMP12(t0); wp++; op++) - n -= stride; - while (n > 0) { - REPEAT(stride, - wp[stride] += *wp; t0 = ToLinearF[wp[stride]&mask]*SCALE12; - *op = CLAMP12(t0); wp++; op++) - n -= stride; - } - } - } -} - -static void -horizontalAccumulate16(uint16 *wp, int n, int stride, uint16 *op, - uint16 *ToLinear16) -{ - register unsigned int cr, cg, cb, ca, mask; - - if (n >= stride) { - mask = CODE_MASK; - if (stride == 3) { - op[0] = ToLinear16[cr = wp[0]]; - op[1] = ToLinear16[cg = wp[1]]; - op[2] = ToLinear16[cb = wp[2]]; - n -= 3; - while (n > 0) { - wp += 3; - op += 3; - n -= 3; - op[0] = ToLinear16[(cr += wp[0]) & mask]; - op[1] = ToLinear16[(cg += wp[1]) & mask]; - op[2] = ToLinear16[(cb += wp[2]) & mask]; - } - } else if (stride == 4) { - op[0] = ToLinear16[cr = wp[0]]; - op[1] = ToLinear16[cg = wp[1]]; - op[2] = ToLinear16[cb = wp[2]]; - op[3] = ToLinear16[ca = wp[3]]; - n -= 4; - while (n > 0) { - wp += 4; - op += 4; - n -= 4; - op[0] = ToLinear16[(cr += wp[0]) & mask]; - op[1] = ToLinear16[(cg += wp[1]) & mask]; - op[2] = ToLinear16[(cb += wp[2]) & mask]; - op[3] = ToLinear16[(ca += wp[3]) & mask]; - } - } else { - REPEAT(stride, *op = ToLinear16[*wp&mask]; wp++; op++) - n -= stride; - while (n > 0) { - REPEAT(stride, - wp[stride] += *wp; *op = ToLinear16[*wp&mask]; wp++; op++) - n -= stride; - } - } - } -} - -/* - * Returns the log encoded 11-bit values with the horizontal - * differencing undone. - */ -static void -horizontalAccumulate11(uint16 *wp, int n, int stride, uint16 *op) -{ - register unsigned int cr, cg, cb, ca, mask; - - if (n >= stride) { - mask = CODE_MASK; - if (stride == 3) { - op[0] = cr = wp[0]; op[1] = cg = wp[1]; op[2] = cb = wp[2]; - n -= 3; - while (n > 0) { - wp += 3; - op += 3; - n -= 3; - op[0] = (cr += wp[0]) & mask; - op[1] = (cg += wp[1]) & mask; - op[2] = (cb += wp[2]) & mask; - } - } else if (stride == 4) { - op[0] = cr = wp[0]; op[1] = cg = wp[1]; - op[2] = cb = wp[2]; op[3] = ca = wp[3]; - n -= 4; - while (n > 0) { - wp += 4; - op += 4; - n -= 4; - op[0] = (cr += wp[0]) & mask; - op[1] = (cg += wp[1]) & mask; - op[2] = (cb += wp[2]) & mask; - op[3] = (ca += wp[3]) & mask; - } - } else { - REPEAT(stride, *op = *wp&mask; wp++; op++) - n -= stride; - while (n > 0) { - REPEAT(stride, - wp[stride] += *wp; *op = *wp&mask; wp++; op++) - n -= stride; - } - } - } -} - -static void -horizontalAccumulate8(uint16 *wp, int n, int stride, unsigned char *op, - unsigned char *ToLinear8) -{ - register unsigned int cr, cg, cb, ca, mask; - - if (n >= stride) { - mask = CODE_MASK; - if (stride == 3) { - op[0] = ToLinear8[cr = wp[0]]; - op[1] = ToLinear8[cg = wp[1]]; - op[2] = ToLinear8[cb = wp[2]]; - n -= 3; - while (n > 0) { - n -= 3; - wp += 3; - op += 3; - op[0] = ToLinear8[(cr += wp[0]) & mask]; - op[1] = ToLinear8[(cg += wp[1]) & mask]; - op[2] = ToLinear8[(cb += wp[2]) & mask]; - } - } else if (stride == 4) { - op[0] = ToLinear8[cr = wp[0]]; - op[1] = ToLinear8[cg = wp[1]]; - op[2] = ToLinear8[cb = wp[2]]; - op[3] = ToLinear8[ca = wp[3]]; - n -= 4; - while (n > 0) { - n -= 4; - wp += 4; - op += 4; - op[0] = ToLinear8[(cr += wp[0]) & mask]; - op[1] = ToLinear8[(cg += wp[1]) & mask]; - op[2] = ToLinear8[(cb += wp[2]) & mask]; - op[3] = ToLinear8[(ca += wp[3]) & mask]; - } - } else { - REPEAT(stride, *op = ToLinear8[*wp&mask]; wp++; op++) - n -= stride; - while (n > 0) { - REPEAT(stride, - wp[stride] += *wp; *op = ToLinear8[*wp&mask]; wp++; op++) - n -= stride; - } - } - } -} - - -static void -horizontalAccumulate8abgr(uint16 *wp, int n, int stride, unsigned char *op, - unsigned char *ToLinear8) -{ - register unsigned int cr, cg, cb, ca, mask; - register unsigned char t0, t1, t2, t3; - - if (n >= stride) { - mask = CODE_MASK; - if (stride == 3) { - op[0] = 0; - t1 = ToLinear8[cb = wp[2]]; - t2 = ToLinear8[cg = wp[1]]; - t3 = ToLinear8[cr = wp[0]]; - op[1] = t1; - op[2] = t2; - op[3] = t3; - n -= 3; - while (n > 0) { - n -= 3; - wp += 3; - op += 4; - op[0] = 0; - t1 = ToLinear8[(cb += wp[2]) & mask]; - t2 = ToLinear8[(cg += wp[1]) & mask]; - t3 = ToLinear8[(cr += wp[0]) & mask]; - op[1] = t1; - op[2] = t2; - op[3] = t3; - } - } else if (stride == 4) { - t0 = ToLinear8[ca = wp[3]]; - t1 = ToLinear8[cb = wp[2]]; - t2 = ToLinear8[cg = wp[1]]; - t3 = ToLinear8[cr = wp[0]]; - op[0] = t0; - op[1] = t1; - op[2] = t2; - op[3] = t3; - n -= 4; - while (n > 0) { - n -= 4; - wp += 4; - op += 4; - t0 = ToLinear8[(ca += wp[3]) & mask]; - t1 = ToLinear8[(cb += wp[2]) & mask]; - t2 = ToLinear8[(cg += wp[1]) & mask]; - t3 = ToLinear8[(cr += wp[0]) & mask]; - op[0] = t0; - op[1] = t1; - op[2] = t2; - op[3] = t3; - } - } else { - REPEAT(stride, *op = ToLinear8[*wp&mask]; wp++; op++) - n -= stride; - while (n > 0) { - REPEAT(stride, - wp[stride] += *wp; *op = ToLinear8[*wp&mask]; wp++; op++) - n -= stride; - } - } - } -} - -/* - * State block for each open TIFF - * file using PixarLog compression/decompression. - */ -typedef struct { - TIFFPredictorState predict; - z_stream stream; - uint16 *tbuf; - uint16 stride; - int state; - int user_datafmt; - int quality; -#define PLSTATE_INIT 1 - - TIFFVSetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ - - float *ToLinearF; - uint16 *ToLinear16; - unsigned char *ToLinear8; - uint16 *FromLT2; - uint16 *From14; /* Really for 16-bit data, but we shift down 2 */ - uint16 *From8; - -} PixarLogState; - -static int -PixarLogMakeTables(PixarLogState *sp) -{ - -/* - * We make several tables here to convert between various external - * representations (float, 16-bit, and 8-bit) and the internal - * 11-bit companded representation. The 11-bit representation has two - * distinct regions. A linear bottom end up through .018316 in steps - * of about .000073, and a region of constant ratio up to about 25. - * These floating point numbers are stored in the main table ToLinearF. - * All other tables are derived from this one. The tables (and the - * ratios) are continuous at the internal seam. - */ - - int nlin, lt2size; - int i, j; - double b, c, linstep, v; - float *ToLinearF; - uint16 *ToLinear16; - unsigned char *ToLinear8; - uint16 *FromLT2; - uint16 *From14; /* Really for 16-bit data, but we shift down 2 */ - uint16 *From8; - - c = log(RATIO); - nlin = (int)(1./c); /* nlin must be an integer */ - c = 1./nlin; - b = exp(-c*ONE); /* multiplicative scale factor [b*exp(c*ONE) = 1] */ - linstep = b*c*exp(1.); - - LogK1 = (float)(1./c); /* if (v >= 2) token = k1*log(v*k2) */ - LogK2 = (float)(1./b); - lt2size = (int)(2./linstep) + 1; - FromLT2 = (uint16 *)_TIFFmalloc(lt2size*sizeof(uint16)); - From14 = (uint16 *)_TIFFmalloc(16384*sizeof(uint16)); - From8 = (uint16 *)_TIFFmalloc(256*sizeof(uint16)); - ToLinearF = (float *)_TIFFmalloc(TSIZEP1 * sizeof(float)); - ToLinear16 = (uint16 *)_TIFFmalloc(TSIZEP1 * sizeof(uint16)); - ToLinear8 = (unsigned char *)_TIFFmalloc(TSIZEP1 * sizeof(unsigned char)); - if (FromLT2 == NULL || From14 == NULL || From8 == NULL || - ToLinearF == NULL || ToLinear16 == NULL || ToLinear8 == NULL) { - if (FromLT2) _TIFFfree(FromLT2); - if (From14) _TIFFfree(From14); - if (From8) _TIFFfree(From8); - if (ToLinearF) _TIFFfree(ToLinearF); - if (ToLinear16) _TIFFfree(ToLinear16); - if (ToLinear8) _TIFFfree(ToLinear8); - sp->FromLT2 = NULL; - sp->From14 = NULL; - sp->From8 = NULL; - sp->ToLinearF = NULL; - sp->ToLinear16 = NULL; - sp->ToLinear8 = NULL; - return 0; - } - - j = 0; - - for (i = 0; i < nlin; i++) { - v = i * linstep; - ToLinearF[j++] = (float)v; - } - - for (i = nlin; i < TSIZE; i++) - ToLinearF[j++] = (float)(b*exp(c*i)); - - ToLinearF[2048] = ToLinearF[2047]; - - for (i = 0; i < TSIZEP1; i++) { - v = ToLinearF[i]*65535.0 + 0.5; - ToLinear16[i] = (v > 65535.0) ? 65535 : (uint16)v; - v = ToLinearF[i]*255.0 + 0.5; - ToLinear8[i] = (v > 255.0) ? 255 : (unsigned char)v; - } - - j = 0; - for (i = 0; i < lt2size; i++) { - if ((i*linstep)*(i*linstep) > ToLinearF[j]*ToLinearF[j+1]) - j++; - FromLT2[i] = j; - } - - /* - * Since we lose info anyway on 16-bit data, we set up a 14-bit - * table and shift 16-bit values down two bits on input. - * saves a little table space. - */ - j = 0; - for (i = 0; i < 16384; i++) { - while ((i/16383.)*(i/16383.) > ToLinearF[j]*ToLinearF[j+1]) - j++; - From14[i] = j; - } - - j = 0; - for (i = 0; i < 256; i++) { - while ((i/255.)*(i/255.) > ToLinearF[j]*ToLinearF[j+1]) - j++; - From8[i] = j; - } - - Fltsize = (float)(lt2size/2); - - sp->ToLinearF = ToLinearF; - sp->ToLinear16 = ToLinear16; - sp->ToLinear8 = ToLinear8; - sp->FromLT2 = FromLT2; - sp->From14 = From14; - sp->From8 = From8; - - return 1; -} - -#define DecoderState(tif) ((PixarLogState*) (tif)->tif_data) -#define EncoderState(tif) ((PixarLogState*) (tif)->tif_data) - -static int PixarLogEncode(TIFF*, tidata_t, tsize_t, tsample_t); -static int PixarLogDecode(TIFF*, tidata_t, tsize_t, tsample_t); - -#define PIXARLOGDATAFMT_UNKNOWN -1 - -static int -PixarLogGuessDataFmt(TIFFDirectory *td) -{ - int guess = PIXARLOGDATAFMT_UNKNOWN; - int format = td->td_sampleformat; - - /* If the user didn't tell us his datafmt, - * take our best guess from the bitspersample. - */ - switch (td->td_bitspersample) { - case 32: - if (format == SAMPLEFORMAT_IEEEFP) - guess = PIXARLOGDATAFMT_FLOAT; - break; - case 16: - if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT) - guess = PIXARLOGDATAFMT_16BIT; - break; - case 12: - if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_INT) - guess = PIXARLOGDATAFMT_12BITPICIO; - break; - case 11: - if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT) - guess = PIXARLOGDATAFMT_11BITLOG; - break; - case 8: - if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT) - guess = PIXARLOGDATAFMT_8BIT; - break; - } - - return guess; -} - -static uint32 -multiply(size_t m1, size_t m2) -{ - uint32 bytes = m1 * m2; - - if (m1 && bytes / m1 != m2) - bytes = 0; - - return bytes; -} - -static int -PixarLogSetupDecode(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - PixarLogState* sp = DecoderState(tif); - tsize_t tbuf_size; - static const char module[] = "PixarLogSetupDecode"; - - assert(sp != NULL); - - /* Make sure no byte swapping happens on the data - * after decompression. */ - tif->tif_postdecode = _TIFFNoPostDecode; - - /* for some reason, we can't do this in TIFFInitPixarLog */ - - sp->stride = (td->td_planarconfig == PLANARCONFIG_CONTIG ? - td->td_samplesperpixel : 1); - tbuf_size = multiply(multiply(multiply(sp->stride, td->td_imagewidth), - td->td_rowsperstrip), sizeof(uint16)); - if (tbuf_size == 0) - return (0); - sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size); - if (sp->tbuf == NULL) - return (0); - if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) - sp->user_datafmt = PixarLogGuessDataFmt(td); - if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) { - TIFFErrorExt(tif->tif_clientdata, module, - "PixarLog compression can't handle bits depth/data format combination (depth: %d)", - td->td_bitspersample); - return (0); - } - - if (inflateInit(&sp->stream) != Z_OK) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: %s", tif->tif_name, sp->stream.msg); - return (0); - } else { - sp->state |= PLSTATE_INIT; - return (1); - } -} - -/* - * Setup state for decoding a strip. - */ -static int -PixarLogPreDecode(TIFF* tif, tsample_t s) -{ - PixarLogState* sp = DecoderState(tif); - - (void) s; - assert(sp != NULL); - sp->stream.next_in = tif->tif_rawdata; - sp->stream.avail_in = tif->tif_rawcc; - return (inflateReset(&sp->stream) == Z_OK); -} - -static int -PixarLogDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) -{ - TIFFDirectory *td = &tif->tif_dir; - PixarLogState* sp = DecoderState(tif); - static const char module[] = "PixarLogDecode"; - int i, nsamples, llen; - uint16 *up; - - switch (sp->user_datafmt) { - case PIXARLOGDATAFMT_FLOAT: - nsamples = occ / sizeof(float); /* XXX float == 32 bits */ - break; - case PIXARLOGDATAFMT_16BIT: - case PIXARLOGDATAFMT_12BITPICIO: - case PIXARLOGDATAFMT_11BITLOG: - nsamples = occ / sizeof(uint16); /* XXX uint16 == 16 bits */ - break; - case PIXARLOGDATAFMT_8BIT: - case PIXARLOGDATAFMT_8BITABGR: - nsamples = occ; - break; - default: - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%d bit input not supported in PixarLog", - td->td_bitspersample); - return 0; - } - - llen = sp->stride * td->td_imagewidth; - - (void) s; - assert(sp != NULL); - sp->stream.next_out = (unsigned char *) sp->tbuf; - sp->stream.avail_out = nsamples * sizeof(uint16); - do { - int state = inflate(&sp->stream, Z_PARTIAL_FLUSH); - if (state == Z_STREAM_END) { - break; /* XXX */ - } - if (state == Z_DATA_ERROR) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Decoding error at scanline %d, %s", - tif->tif_name, tif->tif_row, sp->stream.msg); - if (inflateSync(&sp->stream) != Z_OK) - return (0); - continue; - } - if (state != Z_OK) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: zlib error: %s", - tif->tif_name, sp->stream.msg); - return (0); - } - } while (sp->stream.avail_out > 0); - - /* hopefully, we got all the bytes we needed */ - if (sp->stream.avail_out != 0) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Not enough data at scanline %d (short %d bytes)", - tif->tif_name, tif->tif_row, sp->stream.avail_out); - return (0); - } - - up = sp->tbuf; - /* Swap bytes in the data if from a different endian machine. */ - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfShort(up, nsamples); - - /* - * if llen is not an exact multiple of nsamples, the decode operation - * may overflow the output buffer, so truncate it enough to prevent - * that but still salvage as much data as possible. - */ - if (nsamples % llen) { - TIFFWarningExt(tif->tif_clientdata, module, - "%s: stride %d is not a multiple of sample count, " - "%d, data truncated.", tif->tif_name, llen, nsamples); - nsamples -= nsamples % llen; - } - - for (i = 0; i < nsamples; i += llen, up += llen) { - switch (sp->user_datafmt) { - case PIXARLOGDATAFMT_FLOAT: - horizontalAccumulateF(up, llen, sp->stride, - (float *)op, sp->ToLinearF); - op += llen * sizeof(float); - break; - case PIXARLOGDATAFMT_16BIT: - horizontalAccumulate16(up, llen, sp->stride, - (uint16 *)op, sp->ToLinear16); - op += llen * sizeof(uint16); - break; - case PIXARLOGDATAFMT_12BITPICIO: - horizontalAccumulate12(up, llen, sp->stride, - (int16 *)op, sp->ToLinearF); - op += llen * sizeof(int16); - break; - case PIXARLOGDATAFMT_11BITLOG: - horizontalAccumulate11(up, llen, sp->stride, - (uint16 *)op); - op += llen * sizeof(uint16); - break; - case PIXARLOGDATAFMT_8BIT: - horizontalAccumulate8(up, llen, sp->stride, - (unsigned char *)op, sp->ToLinear8); - op += llen * sizeof(unsigned char); - break; - case PIXARLOGDATAFMT_8BITABGR: - horizontalAccumulate8abgr(up, llen, sp->stride, - (unsigned char *)op, sp->ToLinear8); - op += llen * sizeof(unsigned char); - break; - default: - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "PixarLogDecode: unsupported bits/sample: %d", - td->td_bitspersample); - return (0); - } - } - - return (1); -} - -static int -PixarLogSetupEncode(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - PixarLogState* sp = EncoderState(tif); - tsize_t tbuf_size; - static const char module[] = "PixarLogSetupEncode"; - - assert(sp != NULL); - - /* for some reason, we can't do this in TIFFInitPixarLog */ - - sp->stride = (td->td_planarconfig == PLANARCONFIG_CONTIG ? - td->td_samplesperpixel : 1); - tbuf_size = multiply(multiply(multiply(sp->stride, td->td_imagewidth), - td->td_rowsperstrip), sizeof(uint16)); - if (tbuf_size == 0) - return (0); - sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size); - if (sp->tbuf == NULL) - return (0); - if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) - sp->user_datafmt = PixarLogGuessDataFmt(td); - if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) { - TIFFErrorExt(tif->tif_clientdata, module, "PixarLog compression can't handle %d bit linear encodings", td->td_bitspersample); - return (0); - } - - if (deflateInit(&sp->stream, sp->quality) != Z_OK) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: %s", tif->tif_name, sp->stream.msg); - return (0); - } else { - sp->state |= PLSTATE_INIT; - return (1); - } -} - -/* - * Reset encoding state at the start of a strip. - */ -static int -PixarLogPreEncode(TIFF* tif, tsample_t s) -{ - PixarLogState *sp = EncoderState(tif); - - (void) s; - assert(sp != NULL); - sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = tif->tif_rawdatasize; - return (deflateReset(&sp->stream) == Z_OK); -} - -static void -horizontalDifferenceF(float *ip, int n, int stride, uint16 *wp, uint16 *FromLT2) -{ - - int32 r1, g1, b1, a1, r2, g2, b2, a2, mask; - float fltsize = Fltsize; - -#define CLAMP(v) ( (v<(float)0.) ? 0 \ - : (v<(float)2.) ? FromLT2[(int)(v*fltsize)] \ - : (v>(float)24.2) ? 2047 \ - : LogK1*log(v*LogK2) + 0.5 ) - - mask = CODE_MASK; - if (n >= stride) { - if (stride == 3) { - r2 = wp[0] = (uint16) CLAMP(ip[0]); - g2 = wp[1] = (uint16) CLAMP(ip[1]); - b2 = wp[2] = (uint16) CLAMP(ip[2]); - n -= 3; - while (n > 0) { - n -= 3; - wp += 3; - ip += 3; - r1 = (int32) CLAMP(ip[0]); wp[0] = (r1-r2) & mask; r2 = r1; - g1 = (int32) CLAMP(ip[1]); wp[1] = (g1-g2) & mask; g2 = g1; - b1 = (int32) CLAMP(ip[2]); wp[2] = (b1-b2) & mask; b2 = b1; - } - } else if (stride == 4) { - r2 = wp[0] = (uint16) CLAMP(ip[0]); - g2 = wp[1] = (uint16) CLAMP(ip[1]); - b2 = wp[2] = (uint16) CLAMP(ip[2]); - a2 = wp[3] = (uint16) CLAMP(ip[3]); - n -= 4; - while (n > 0) { - n -= 4; - wp += 4; - ip += 4; - r1 = (int32) CLAMP(ip[0]); wp[0] = (r1-r2) & mask; r2 = r1; - g1 = (int32) CLAMP(ip[1]); wp[1] = (g1-g2) & mask; g2 = g1; - b1 = (int32) CLAMP(ip[2]); wp[2] = (b1-b2) & mask; b2 = b1; - a1 = (int32) CLAMP(ip[3]); wp[3] = (a1-a2) & mask; a2 = a1; - } - } else { - ip += n - 1; /* point to last one */ - wp += n - 1; /* point to last one */ - n -= stride; - while (n > 0) { - REPEAT(stride, wp[0] = (uint16) CLAMP(ip[0]); - wp[stride] -= wp[0]; - wp[stride] &= mask; - wp--; ip--) - n -= stride; - } - REPEAT(stride, wp[0] = (uint16) CLAMP(ip[0]); wp--; ip--) - } - } -} - -static void -horizontalDifference16(unsigned short *ip, int n, int stride, - unsigned short *wp, uint16 *From14) -{ - register int r1, g1, b1, a1, r2, g2, b2, a2, mask; - -/* assumption is unsigned pixel values */ -#undef CLAMP -#define CLAMP(v) From14[(v) >> 2] - - mask = CODE_MASK; - if (n >= stride) { - if (stride == 3) { - r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]); - b2 = wp[2] = CLAMP(ip[2]); - n -= 3; - while (n > 0) { - n -= 3; - wp += 3; - ip += 3; - r1 = CLAMP(ip[0]); wp[0] = (r1-r2) & mask; r2 = r1; - g1 = CLAMP(ip[1]); wp[1] = (g1-g2) & mask; g2 = g1; - b1 = CLAMP(ip[2]); wp[2] = (b1-b2) & mask; b2 = b1; - } - } else if (stride == 4) { - r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]); - b2 = wp[2] = CLAMP(ip[2]); a2 = wp[3] = CLAMP(ip[3]); - n -= 4; - while (n > 0) { - n -= 4; - wp += 4; - ip += 4; - r1 = CLAMP(ip[0]); wp[0] = (r1-r2) & mask; r2 = r1; - g1 = CLAMP(ip[1]); wp[1] = (g1-g2) & mask; g2 = g1; - b1 = CLAMP(ip[2]); wp[2] = (b1-b2) & mask; b2 = b1; - a1 = CLAMP(ip[3]); wp[3] = (a1-a2) & mask; a2 = a1; - } - } else { - ip += n - 1; /* point to last one */ - wp += n - 1; /* point to last one */ - n -= stride; - while (n > 0) { - REPEAT(stride, wp[0] = CLAMP(ip[0]); - wp[stride] -= wp[0]; - wp[stride] &= mask; - wp--; ip--) - n -= stride; - } - REPEAT(stride, wp[0] = CLAMP(ip[0]); wp--; ip--) - } - } -} - - -static void -horizontalDifference8(unsigned char *ip, int n, int stride, - unsigned short *wp, uint16 *From8) -{ - register int r1, g1, b1, a1, r2, g2, b2, a2, mask; - -#undef CLAMP -#define CLAMP(v) (From8[(v)]) - - mask = CODE_MASK; - if (n >= stride) { - if (stride == 3) { - r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]); - b2 = wp[2] = CLAMP(ip[2]); - n -= 3; - while (n > 0) { - n -= 3; - r1 = CLAMP(ip[3]); wp[3] = (r1-r2) & mask; r2 = r1; - g1 = CLAMP(ip[4]); wp[4] = (g1-g2) & mask; g2 = g1; - b1 = CLAMP(ip[5]); wp[5] = (b1-b2) & mask; b2 = b1; - wp += 3; - ip += 3; - } - } else if (stride == 4) { - r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]); - b2 = wp[2] = CLAMP(ip[2]); a2 = wp[3] = CLAMP(ip[3]); - n -= 4; - while (n > 0) { - n -= 4; - r1 = CLAMP(ip[4]); wp[4] = (r1-r2) & mask; r2 = r1; - g1 = CLAMP(ip[5]); wp[5] = (g1-g2) & mask; g2 = g1; - b1 = CLAMP(ip[6]); wp[6] = (b1-b2) & mask; b2 = b1; - a1 = CLAMP(ip[7]); wp[7] = (a1-a2) & mask; a2 = a1; - wp += 4; - ip += 4; - } - } else { - wp += n + stride - 1; /* point to last one */ - ip += n + stride - 1; /* point to last one */ - n -= stride; - while (n > 0) { - REPEAT(stride, wp[0] = CLAMP(ip[0]); - wp[stride] -= wp[0]; - wp[stride] &= mask; - wp--; ip--) - n -= stride; - } - REPEAT(stride, wp[0] = CLAMP(ip[0]); wp--; ip--) - } - } -} - -/* - * Encode a chunk of pixels. - */ -static int -PixarLogEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - TIFFDirectory *td = &tif->tif_dir; - PixarLogState *sp = EncoderState(tif); - static const char module[] = "PixarLogEncode"; - int i, n, llen; - unsigned short * up; - - (void) s; - - switch (sp->user_datafmt) { - case PIXARLOGDATAFMT_FLOAT: - n = cc / sizeof(float); /* XXX float == 32 bits */ - break; - case PIXARLOGDATAFMT_16BIT: - case PIXARLOGDATAFMT_12BITPICIO: - case PIXARLOGDATAFMT_11BITLOG: - n = cc / sizeof(uint16); /* XXX uint16 == 16 bits */ - break; - case PIXARLOGDATAFMT_8BIT: - case PIXARLOGDATAFMT_8BITABGR: - n = cc; - break; - default: - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%d bit input not supported in PixarLog", - td->td_bitspersample); - return 0; - } - - llen = sp->stride * td->td_imagewidth; - - for (i = 0, up = sp->tbuf; i < n; i += llen, up += llen) { - switch (sp->user_datafmt) { - case PIXARLOGDATAFMT_FLOAT: - horizontalDifferenceF((float *)bp, llen, - sp->stride, up, sp->FromLT2); - bp += llen * sizeof(float); - break; - case PIXARLOGDATAFMT_16BIT: - horizontalDifference16((uint16 *)bp, llen, - sp->stride, up, sp->From14); - bp += llen * sizeof(uint16); - break; - case PIXARLOGDATAFMT_8BIT: - horizontalDifference8((unsigned char *)bp, llen, - sp->stride, up, sp->From8); - bp += llen * sizeof(unsigned char); - break; - default: - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%d bit input not supported in PixarLog", - td->td_bitspersample); - return 0; - } - } - - sp->stream.next_in = (unsigned char *) sp->tbuf; - sp->stream.avail_in = n * sizeof(uint16); - - do { - if (deflate(&sp->stream, Z_NO_FLUSH) != Z_OK) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: Encoder error: %s", - tif->tif_name, sp->stream.msg); - return (0); - } - if (sp->stream.avail_out == 0) { - tif->tif_rawcc = tif->tif_rawdatasize; - TIFFFlushData1(tif); - sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = tif->tif_rawdatasize; - } - } while (sp->stream.avail_in > 0); - return (1); -} - -/* - * Finish off an encoded strip by flushing the last - * string and tacking on an End Of Information code. - */ - -static int -PixarLogPostEncode(TIFF* tif) -{ - PixarLogState *sp = EncoderState(tif); - static const char module[] = "PixarLogPostEncode"; - int state; - - sp->stream.avail_in = 0; - - do { - state = deflate(&sp->stream, Z_FINISH); - switch (state) { - case Z_STREAM_END: - case Z_OK: - if (sp->stream.avail_out != (uint32)tif->tif_rawdatasize) { - tif->tif_rawcc = - tif->tif_rawdatasize - sp->stream.avail_out; - TIFFFlushData1(tif); - sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = tif->tif_rawdatasize; - } - break; - default: - TIFFErrorExt(tif->tif_clientdata, module, "%s: zlib error: %s", - tif->tif_name, sp->stream.msg); - return (0); - } - } while (state != Z_STREAM_END); - return (1); -} - -static void -PixarLogClose(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - - /* In a really sneaky maneuver, on close, we covertly modify both - * bitspersample and sampleformat in the directory to indicate - * 8-bit linear. This way, the decode "just works" even for - * readers that don't know about PixarLog, or how to set - * the PIXARLOGDATFMT pseudo-tag. - */ - td->td_bitspersample = 8; - td->td_sampleformat = SAMPLEFORMAT_UINT; -} - -static void -PixarLogCleanup(TIFF* tif) -{ - PixarLogState* sp = (PixarLogState*) tif->tif_data; - - assert(sp != 0); - - (void)TIFFPredictorCleanup(tif); - - tif->tif_tagmethods.vgetfield = sp->vgetparent; - tif->tif_tagmethods.vsetfield = sp->vsetparent; - - if (sp->FromLT2) _TIFFfree(sp->FromLT2); - if (sp->From14) _TIFFfree(sp->From14); - if (sp->From8) _TIFFfree(sp->From8); - if (sp->ToLinearF) _TIFFfree(sp->ToLinearF); - if (sp->ToLinear16) _TIFFfree(sp->ToLinear16); - if (sp->ToLinear8) _TIFFfree(sp->ToLinear8); - if (sp->state&PLSTATE_INIT) { - if (tif->tif_mode == O_RDONLY) - inflateEnd(&sp->stream); - else - deflateEnd(&sp->stream); - } - if (sp->tbuf) - _TIFFfree(sp->tbuf); - _TIFFfree(sp); - tif->tif_data = NULL; - - _TIFFSetDefaultCompressionState(tif); -} - -static int -PixarLogVSetField(TIFF* tif, ttag_t tag, va_list ap) -{ - PixarLogState *sp = (PixarLogState *)tif->tif_data; - int result; - static const char module[] = "PixarLogVSetField"; - - switch (tag) { - case TIFFTAG_PIXARLOGQUALITY: - sp->quality = va_arg(ap, int); - if (tif->tif_mode != O_RDONLY && (sp->state&PLSTATE_INIT)) { - if (deflateParams(&sp->stream, - sp->quality, Z_DEFAULT_STRATEGY) != Z_OK) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: zlib error: %s", - tif->tif_name, sp->stream.msg); - return (0); - } - } - return (1); - case TIFFTAG_PIXARLOGDATAFMT: - sp->user_datafmt = va_arg(ap, int); - /* Tweak the TIFF header so that the rest of libtiff knows what - * size of data will be passed between app and library, and - * assume that the app knows what it is doing and is not - * confused by these header manipulations... - */ - switch (sp->user_datafmt) { - case PIXARLOGDATAFMT_8BIT: - case PIXARLOGDATAFMT_8BITABGR: - TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8); - TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); - break; - case PIXARLOGDATAFMT_11BITLOG: - TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 16); - TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); - break; - case PIXARLOGDATAFMT_12BITPICIO: - TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 16); - TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_INT); - break; - case PIXARLOGDATAFMT_16BIT: - TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 16); - TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); - break; - case PIXARLOGDATAFMT_FLOAT: - TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 32); - TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP); - break; - } - /* - * Must recalculate sizes should bits/sample change. - */ - tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tsize_t) -1; - tif->tif_scanlinesize = TIFFScanlineSize(tif); - result = 1; /* NB: pseudo tag */ - break; - default: - result = (*sp->vsetparent)(tif, tag, ap); - } - return (result); -} - -static int -PixarLogVGetField(TIFF* tif, ttag_t tag, va_list ap) -{ - PixarLogState *sp = (PixarLogState *)tif->tif_data; - - switch (tag) { - case TIFFTAG_PIXARLOGQUALITY: - *va_arg(ap, int*) = sp->quality; - break; - case TIFFTAG_PIXARLOGDATAFMT: - *va_arg(ap, int*) = sp->user_datafmt; - break; - default: - return (*sp->vgetparent)(tif, tag, ap); - } - return (1); -} - -static const TIFFFieldInfo pixarlogFieldInfo[] = { - {TIFFTAG_PIXARLOGDATAFMT,0,0,TIFF_ANY, FIELD_PSEUDO,FALSE,FALSE,""}, - {TIFFTAG_PIXARLOGQUALITY,0,0,TIFF_ANY, FIELD_PSEUDO,FALSE,FALSE,""} -}; - -int -TIFFInitPixarLog(TIFF* tif, int scheme) -{ - static const char module[] = "TIFFInitPixarLog"; - - PixarLogState* sp; - - assert(scheme == COMPRESSION_PIXARLOG); - - /* - * Merge codec-specific tag information. - */ - if (!_TIFFMergeFieldInfo(tif, pixarlogFieldInfo, - TIFFArrayCount(pixarlogFieldInfo))) { - TIFFErrorExt(tif->tif_clientdata, module, - "Merging PixarLog codec-specific tags failed"); - return 0; - } - - /* - * Allocate state block so tag methods have storage to record values. - */ - tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (PixarLogState)); - if (tif->tif_data == NULL) - goto bad; - sp = (PixarLogState*) tif->tif_data; - _TIFFmemset(sp, 0, sizeof (*sp)); - sp->stream.data_type = Z_BINARY; - sp->user_datafmt = PIXARLOGDATAFMT_UNKNOWN; - - /* - * Install codec methods. - */ - tif->tif_setupdecode = PixarLogSetupDecode; - tif->tif_predecode = PixarLogPreDecode; - tif->tif_decoderow = PixarLogDecode; - tif->tif_decodestrip = PixarLogDecode; - tif->tif_decodetile = PixarLogDecode; - tif->tif_setupencode = PixarLogSetupEncode; - tif->tif_preencode = PixarLogPreEncode; - tif->tif_postencode = PixarLogPostEncode; - tif->tif_encoderow = PixarLogEncode; - tif->tif_encodestrip = PixarLogEncode; - tif->tif_encodetile = PixarLogEncode; - tif->tif_close = PixarLogClose; - tif->tif_cleanup = PixarLogCleanup; - - /* Override SetField so we can handle our private pseudo-tag */ - sp->vgetparent = tif->tif_tagmethods.vgetfield; - tif->tif_tagmethods.vgetfield = PixarLogVGetField; /* hook for codec tags */ - sp->vsetparent = tif->tif_tagmethods.vsetfield; - tif->tif_tagmethods.vsetfield = PixarLogVSetField; /* hook for codec tags */ - - /* Default values for codec-specific fields */ - sp->quality = Z_DEFAULT_COMPRESSION; /* default comp. level */ - sp->state = 0; - - /* we don't wish to use the predictor, - * the default is none, which predictor value 1 - */ - (void) TIFFPredictorInit(tif); - - /* - * build the companding tables - */ - PixarLogMakeTables(sp); - - return (1); -bad: - TIFFErrorExt(tif->tif_clientdata, module, - "No space for PixarLog state block"); - return (0); -} -#endif /* PIXARLOG_SUPPORT */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_predict.c b/plugins/AdvaImg/src/LibTIFF/tif_predict.c deleted file mode 100644 index 7f7dc636be..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_predict.c +++ /dev/null @@ -1,736 +0,0 @@ -/* $Id: tif_predict.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Predictor Tag Support (used by multiple codecs). - */ -#include "tiffiop.h" -#include "tif_predict.h" - -#define PredictorState(tif) ((TIFFPredictorState*) (tif)->tif_data) - -static void horAcc8(TIFF*, tidata_t, tsize_t); -static void horAcc16(TIFF*, tidata_t, tsize_t); -static void horAcc32(TIFF*, tidata_t, tsize_t); -static void swabHorAcc16(TIFF*, tidata_t, tsize_t); -static void swabHorAcc32(TIFF*, tidata_t, tsize_t); -static void horDiff8(TIFF*, tidata_t, tsize_t); -static void horDiff16(TIFF*, tidata_t, tsize_t); -static void horDiff32(TIFF*, tidata_t, tsize_t); -static void fpAcc(TIFF*, tidata_t, tsize_t); -static void fpDiff(TIFF*, tidata_t, tsize_t); -static int PredictorDecodeRow(TIFF*, tidata_t, tsize_t, tsample_t); -static int PredictorDecodeTile(TIFF*, tidata_t, tsize_t, tsample_t); -static int PredictorEncodeRow(TIFF*, tidata_t, tsize_t, tsample_t); -static int PredictorEncodeTile(TIFF*, tidata_t, tsize_t, tsample_t); - -static int -PredictorSetup(TIFF* tif) -{ - static const char module[] = "PredictorSetup"; - - TIFFPredictorState* sp = PredictorState(tif); - TIFFDirectory* td = &tif->tif_dir; - - switch (sp->predictor) /* no differencing */ - { - case PREDICTOR_NONE: - return 1; - case PREDICTOR_HORIZONTAL: - if (td->td_bitspersample != 8 - && td->td_bitspersample != 16 - && td->td_bitspersample != 32) { - TIFFErrorExt(tif->tif_clientdata, module, - "Horizontal differencing \"Predictor\" not supported with %d-bit samples", - td->td_bitspersample); - return 0; - } - break; - case PREDICTOR_FLOATINGPOINT: - if (td->td_sampleformat != SAMPLEFORMAT_IEEEFP) { - TIFFErrorExt(tif->tif_clientdata, module, - "Floating point \"Predictor\" not supported with %d data format", - td->td_sampleformat); - return 0; - } - break; - default: - TIFFErrorExt(tif->tif_clientdata, module, - "\"Predictor\" value %d not supported", - sp->predictor); - return 0; - } - sp->stride = (td->td_planarconfig == PLANARCONFIG_CONTIG ? - td->td_samplesperpixel : 1); - /* - * Calculate the scanline/tile-width size in bytes. - */ - if (isTiled(tif)) - sp->rowsize = TIFFTileRowSize(tif); - else - sp->rowsize = TIFFScanlineSize(tif); - - return 1; -} - -static int -PredictorSetupDecode(TIFF* tif) -{ - TIFFPredictorState* sp = PredictorState(tif); - TIFFDirectory* td = &tif->tif_dir; - - if (!(*sp->setupdecode)(tif) || !PredictorSetup(tif)) - return 0; - - if (sp->predictor == 2) { - switch (td->td_bitspersample) { - case 8: sp->decodepfunc = horAcc8; break; - case 16: sp->decodepfunc = horAcc16; break; - case 32: sp->decodepfunc = horAcc32; break; - } - /* - * Override default decoding method with one that does the - * predictor stuff. - */ - if ( tif->tif_decoderow != PredictorDecodeRow ) - { - sp->decoderow = tif->tif_decoderow; - tif->tif_decoderow = PredictorDecodeRow; - sp->decodestrip = tif->tif_decodestrip; - tif->tif_decodestrip = PredictorDecodeTile; - sp->decodetile = tif->tif_decodetile; - tif->tif_decodetile = PredictorDecodeTile; - } - /* - * If the data is horizontally differenced 16-bit data that - * requires byte-swapping, then it must be byte swapped before - * the accumulation step. We do this with a special-purpose - * routine and override the normal post decoding logic that - * the library setup when the directory was read. - */ - if (tif->tif_flags & TIFF_SWAB) { - if (sp->decodepfunc == horAcc16) { - sp->decodepfunc = swabHorAcc16; - tif->tif_postdecode = _TIFFNoPostDecode; - } else if (sp->decodepfunc == horAcc32) { - sp->decodepfunc = swabHorAcc32; - tif->tif_postdecode = _TIFFNoPostDecode; - } - } - } - - else if (sp->predictor == 3) { - sp->decodepfunc = fpAcc; - /* - * Override default decoding method with one that does the - * predictor stuff. - */ - if ( tif->tif_decoderow != PredictorDecodeRow ) - { - sp->decoderow = tif->tif_decoderow; - tif->tif_decoderow = PredictorDecodeRow; - sp->decodestrip = tif->tif_decodestrip; - tif->tif_decodestrip = PredictorDecodeTile; - sp->decodetile = tif->tif_decodetile; - tif->tif_decodetile = PredictorDecodeTile; - } - /* - * The data should not be swapped outside of the floating - * point predictor, the accumulation routine should return - * byres in the native order. - */ - if (tif->tif_flags & TIFF_SWAB) { - tif->tif_postdecode = _TIFFNoPostDecode; - } - /* - * Allocate buffer to keep the decoded bytes before - * rearranging in the ight order - */ - } - - return 1; -} - -static int -PredictorSetupEncode(TIFF* tif) -{ - TIFFPredictorState* sp = PredictorState(tif); - TIFFDirectory* td = &tif->tif_dir; - - if (!(*sp->setupencode)(tif) || !PredictorSetup(tif)) - return 0; - - if (sp->predictor == 2) { - switch (td->td_bitspersample) { - case 8: sp->encodepfunc = horDiff8; break; - case 16: sp->encodepfunc = horDiff16; break; - case 32: sp->encodepfunc = horDiff32; break; - } - /* - * Override default encoding method with one that does the - * predictor stuff. - */ - if ( tif->tif_encoderow != PredictorEncodeRow ) - { - sp->encoderow = tif->tif_encoderow; - tif->tif_encoderow = PredictorEncodeRow; - sp->encodestrip = tif->tif_encodestrip; - tif->tif_encodestrip = PredictorEncodeTile; - sp->encodetile = tif->tif_encodetile; - tif->tif_encodetile = PredictorEncodeTile; - } - } - - else if (sp->predictor == 3) { - sp->encodepfunc = fpDiff; - /* - * Override default encoding method with one that does the - * predictor stuff. - */ - if ( tif->tif_encoderow != PredictorEncodeRow ) - { - sp->encoderow = tif->tif_encoderow; - tif->tif_encoderow = PredictorEncodeRow; - sp->encodestrip = tif->tif_encodestrip; - tif->tif_encodestrip = PredictorEncodeTile; - sp->encodetile = tif->tif_encodetile; - tif->tif_encodetile = PredictorEncodeTile; - } - } - - return 1; -} - -#define REPEAT4(n, op) \ - switch (n) { \ - default: { int i; for (i = n-4; i > 0; i--) { op; } } \ - case 4: op; \ - case 3: op; \ - case 2: op; \ - case 1: op; \ - case 0: ; \ - } - -static void -horAcc8(TIFF* tif, tidata_t cp0, tsize_t cc) -{ - tsize_t stride = PredictorState(tif)->stride; - - char* cp = (char*) cp0; - if (cc > stride) { - cc -= stride; - /* - * Pipeline the most common cases. - */ - if (stride == 3) { - unsigned int cr = cp[0]; - unsigned int cg = cp[1]; - unsigned int cb = cp[2]; - do { - cc -= 3, cp += 3; - cp[0] = (char) (cr += cp[0]); - cp[1] = (char) (cg += cp[1]); - cp[2] = (char) (cb += cp[2]); - } while ((int32) cc > 0); - } else if (stride == 4) { - unsigned int cr = cp[0]; - unsigned int cg = cp[1]; - unsigned int cb = cp[2]; - unsigned int ca = cp[3]; - do { - cc -= 4, cp += 4; - cp[0] = (char) (cr += cp[0]); - cp[1] = (char) (cg += cp[1]); - cp[2] = (char) (cb += cp[2]); - cp[3] = (char) (ca += cp[3]); - } while ((int32) cc > 0); - } else { - do { - REPEAT4(stride, cp[stride] = - (char) (cp[stride] + *cp); cp++) - cc -= stride; - } while ((int32) cc > 0); - } - } -} - -static void -swabHorAcc16(TIFF* tif, tidata_t cp0, tsize_t cc) -{ - tsize_t stride = PredictorState(tif)->stride; - uint16* wp = (uint16*) cp0; - tsize_t wc = cc / 2; - - if (wc > stride) { - TIFFSwabArrayOfShort(wp, wc); - wc -= stride; - do { - REPEAT4(stride, wp[stride] += wp[0]; wp++) - wc -= stride; - } while ((int32) wc > 0); - } -} - -static void -horAcc16(TIFF* tif, tidata_t cp0, tsize_t cc) -{ - tsize_t stride = PredictorState(tif)->stride; - uint16* wp = (uint16*) cp0; - tsize_t wc = cc / 2; - - if (wc > stride) { - wc -= stride; - do { - REPEAT4(stride, wp[stride] += wp[0]; wp++) - wc -= stride; - } while ((int32) wc > 0); - } -} - -static void -swabHorAcc32(TIFF* tif, tidata_t cp0, tsize_t cc) -{ - tsize_t stride = PredictorState(tif)->stride; - uint32* wp = (uint32*) cp0; - tsize_t wc = cc / 4; - - if (wc > stride) { - TIFFSwabArrayOfLong(wp, wc); - wc -= stride; - do { - REPEAT4(stride, wp[stride] += wp[0]; wp++) - wc -= stride; - } while ((int32) wc > 0); - } -} - -static void -horAcc32(TIFF* tif, tidata_t cp0, tsize_t cc) -{ - tsize_t stride = PredictorState(tif)->stride; - uint32* wp = (uint32*) cp0; - tsize_t wc = cc / 4; - - if (wc > stride) { - wc -= stride; - do { - REPEAT4(stride, wp[stride] += wp[0]; wp++) - wc -= stride; - } while ((int32) wc > 0); - } -} - -/* - * Floating point predictor accumulation routine. - */ -static void -fpAcc(TIFF* tif, tidata_t cp0, tsize_t cc) -{ - tsize_t stride = PredictorState(tif)->stride; - uint32 bps = tif->tif_dir.td_bitspersample / 8; - tsize_t wc = cc / bps; - tsize_t count = cc; - uint8 *cp = (uint8 *) cp0; - uint8 *tmp = (uint8 *)_TIFFmalloc(cc); - - if (!tmp) - return; - - while (count > stride) { - REPEAT4(stride, cp[stride] += cp[0]; cp++) - count -= stride; - } - - _TIFFmemcpy(tmp, cp0, cc); - cp = (uint8 *) cp0; - for (count = 0; count < wc; count++) { - uint32 byte; - for (byte = 0; byte < bps; byte++) { -#if WORDS_BIGENDIAN - cp[bps * count + byte] = tmp[byte * wc + count]; -#else - cp[bps * count + byte] = - tmp[(bps - byte - 1) * wc + count]; -#endif - } - } - _TIFFfree(tmp); -} - -/* - * Decode a scanline and apply the predictor routine. - */ -static int -PredictorDecodeRow(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) -{ - TIFFPredictorState *sp = PredictorState(tif); - - assert(sp != NULL); - assert(sp->decoderow != NULL); - assert(sp->decodepfunc != NULL); - - if ((*sp->decoderow)(tif, op0, occ0, s)) { - (*sp->decodepfunc)(tif, op0, occ0); - return 1; - } else - return 0; -} - -/* - * Decode a tile/strip and apply the predictor routine. - * Note that horizontal differencing must be done on a - * row-by-row basis. The width of a "row" has already - * been calculated at pre-decode time according to the - * strip/tile dimensions. - */ -static int -PredictorDecodeTile(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) -{ - TIFFPredictorState *sp = PredictorState(tif); - - assert(sp != NULL); - assert(sp->decodetile != NULL); - - if ((*sp->decodetile)(tif, op0, occ0, s)) { - tsize_t rowsize = sp->rowsize; - assert(rowsize > 0); - assert(sp->decodepfunc != NULL); - while ((long)occ0 > 0) { - (*sp->decodepfunc)(tif, op0, (tsize_t) rowsize); - occ0 -= rowsize; - op0 += rowsize; - } - return 1; - } else - return 0; -} - -static void -horDiff8(TIFF* tif, tidata_t cp0, tsize_t cc) -{ - TIFFPredictorState* sp = PredictorState(tif); - tsize_t stride = sp->stride; - char* cp = (char*) cp0; - - if (cc > stride) { - cc -= stride; - /* - * Pipeline the most common cases. - */ - if (stride == 3) { - int r1, g1, b1; - int r2 = cp[0]; - int g2 = cp[1]; - int b2 = cp[2]; - do { - r1 = cp[3]; cp[3] = r1-r2; r2 = r1; - g1 = cp[4]; cp[4] = g1-g2; g2 = g1; - b1 = cp[5]; cp[5] = b1-b2; b2 = b1; - cp += 3; - } while ((int32)(cc -= 3) > 0); - } else if (stride == 4) { - int r1, g1, b1, a1; - int r2 = cp[0]; - int g2 = cp[1]; - int b2 = cp[2]; - int a2 = cp[3]; - do { - r1 = cp[4]; cp[4] = r1-r2; r2 = r1; - g1 = cp[5]; cp[5] = g1-g2; g2 = g1; - b1 = cp[6]; cp[6] = b1-b2; b2 = b1; - a1 = cp[7]; cp[7] = a1-a2; a2 = a1; - cp += 4; - } while ((int32)(cc -= 4) > 0); - } else { - cp += cc - 1; - do { - REPEAT4(stride, cp[stride] -= cp[0]; cp--) - } while ((int32)(cc -= stride) > 0); - } - } -} - -static void -horDiff16(TIFF* tif, tidata_t cp0, tsize_t cc) -{ - TIFFPredictorState* sp = PredictorState(tif); - tsize_t stride = sp->stride; - int16 *wp = (int16*) cp0; - tsize_t wc = cc/2; - - if (wc > stride) { - wc -= stride; - wp += wc - 1; - do { - REPEAT4(stride, wp[stride] -= wp[0]; wp--) - wc -= stride; - } while ((int32) wc > 0); - } -} - -static void -horDiff32(TIFF* tif, tidata_t cp0, tsize_t cc) -{ - TIFFPredictorState* sp = PredictorState(tif); - tsize_t stride = sp->stride; - int32 *wp = (int32*) cp0; - tsize_t wc = cc/4; - - if (wc > stride) { - wc -= stride; - wp += wc - 1; - do { - REPEAT4(stride, wp[stride] -= wp[0]; wp--) - wc -= stride; - } while ((int32) wc > 0); - } -} - -/* - * Floating point predictor differencing routine. - */ -static void -fpDiff(TIFF* tif, tidata_t cp0, tsize_t cc) -{ - tsize_t stride = PredictorState(tif)->stride; - uint32 bps = tif->tif_dir.td_bitspersample / 8; - tsize_t wc = cc / bps; - tsize_t count; - uint8 *cp = (uint8 *) cp0; - uint8 *tmp = (uint8 *)_TIFFmalloc(cc); - - if (!tmp) - return; - - _TIFFmemcpy(tmp, cp0, cc); - for (count = 0; count < wc; count++) { - uint32 byte; - for (byte = 0; byte < bps; byte++) { -#if WORDS_BIGENDIAN - cp[byte * wc + count] = tmp[bps * count + byte]; -#else - cp[(bps - byte - 1) * wc + count] = - tmp[bps * count + byte]; -#endif - } - } - _TIFFfree(tmp); - - cp = (uint8 *) cp0; - cp += cc - stride - 1; - for (count = cc; count > stride; count -= stride) - REPEAT4(stride, cp[stride] -= cp[0]; cp--) -} - -static int -PredictorEncodeRow(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - TIFFPredictorState *sp = PredictorState(tif); - - assert(sp != NULL); - assert(sp->encodepfunc != NULL); - assert(sp->encoderow != NULL); - - /* XXX horizontal differencing alters user's data XXX */ - (*sp->encodepfunc)(tif, bp, cc); - return (*sp->encoderow)(tif, bp, cc, s); -} - -static int -PredictorEncodeTile(TIFF* tif, tidata_t bp0, tsize_t cc0, tsample_t s) -{ - static const char module[] = "PredictorEncodeTile"; - TIFFPredictorState *sp = PredictorState(tif); - uint8 *working_copy; - tsize_t cc = cc0, rowsize; - unsigned char* bp; - int result_code; - - assert(sp != NULL); - assert(sp->encodepfunc != NULL); - assert(sp->encodetile != NULL); - - /* - * Do predictor manipulation in a working buffer to avoid altering - * the callers buffer. http://trac.osgeo.org/gdal/ticket/1965 - */ - working_copy = (uint8*) _TIFFmalloc(cc0); - if ( working_copy == NULL ) - { - TIFFErrorExt(tif->tif_clientdata, module, - "Out of memory allocating %d byte temp buffer.", - cc0 ); - return 0; - } - memcpy( working_copy, bp0, cc0 ); - bp = working_copy; - - rowsize = sp->rowsize; - assert(rowsize > 0); - assert((cc0%rowsize)==0); - while (cc > 0) { - (*sp->encodepfunc)(tif, bp, rowsize); - cc -= rowsize; - bp += rowsize; - } - result_code = (*sp->encodetile)(tif, working_copy, cc0, s); - - _TIFFfree( working_copy ); - - return result_code; -} - -#define FIELD_PREDICTOR (FIELD_CODEC+0) /* XXX */ - -static const TIFFFieldInfo predictFieldInfo[] = { - { TIFFTAG_PREDICTOR, 1, 1, TIFF_SHORT, FIELD_PREDICTOR, - FALSE, FALSE, "Predictor" }, -}; - -static int -PredictorVSetField(TIFF* tif, ttag_t tag, va_list ap) -{ - TIFFPredictorState *sp = PredictorState(tif); - - assert(sp != NULL); - assert(sp->vsetparent != NULL); - - switch (tag) { - case TIFFTAG_PREDICTOR: - sp->predictor = (uint16) va_arg(ap, int); - TIFFSetFieldBit(tif, FIELD_PREDICTOR); - break; - default: - return (*sp->vsetparent)(tif, tag, ap); - } - tif->tif_flags |= TIFF_DIRTYDIRECT; - return 1; -} - -static int -PredictorVGetField(TIFF* tif, ttag_t tag, va_list ap) -{ - TIFFPredictorState *sp = PredictorState(tif); - - assert(sp != NULL); - assert(sp->vgetparent != NULL); - - switch (tag) { - case TIFFTAG_PREDICTOR: - *va_arg(ap, uint16*) = sp->predictor; - break; - default: - return (*sp->vgetparent)(tif, tag, ap); - } - return 1; -} - -static void -PredictorPrintDir(TIFF* tif, FILE* fd, long flags) -{ - TIFFPredictorState* sp = PredictorState(tif); - - (void) flags; - if (TIFFFieldSet(tif,FIELD_PREDICTOR)) { - fprintf(fd, " Predictor: "); - switch (sp->predictor) { - case 1: fprintf(fd, "none "); break; - case 2: fprintf(fd, "horizontal differencing "); break; - case 3: fprintf(fd, "floating point predictor "); break; - } - fprintf(fd, "%u (0x%x)\n", sp->predictor, sp->predictor); - } - if (sp->printdir) - (*sp->printdir)(tif, fd, flags); -} - -int -TIFFPredictorInit(TIFF* tif) -{ - TIFFPredictorState* sp = PredictorState(tif); - - assert(sp != 0); - - /* - * Merge codec-specific tag information. - */ - if (!_TIFFMergeFieldInfo(tif, predictFieldInfo, - TIFFArrayCount(predictFieldInfo))) { - TIFFErrorExt(tif->tif_clientdata, "TIFFPredictorInit", - "Merging Predictor codec-specific tags failed"); - return 0; - } - - /* - * Override parent get/set field methods. - */ - sp->vgetparent = tif->tif_tagmethods.vgetfield; - tif->tif_tagmethods.vgetfield = - PredictorVGetField;/* hook for predictor tag */ - sp->vsetparent = tif->tif_tagmethods.vsetfield; - tif->tif_tagmethods.vsetfield = - PredictorVSetField;/* hook for predictor tag */ - sp->printdir = tif->tif_tagmethods.printdir; - tif->tif_tagmethods.printdir = - PredictorPrintDir; /* hook for predictor tag */ - - sp->setupdecode = tif->tif_setupdecode; - tif->tif_setupdecode = PredictorSetupDecode; - sp->setupencode = tif->tif_setupencode; - tif->tif_setupencode = PredictorSetupEncode; - - sp->predictor = 1; /* default value */ - sp->encodepfunc = NULL; /* no predictor routine */ - sp->decodepfunc = NULL; /* no predictor routine */ - return 1; -} - -int -TIFFPredictorCleanup(TIFF* tif) -{ - TIFFPredictorState* sp = PredictorState(tif); - - assert(sp != 0); - - tif->tif_tagmethods.vgetfield = sp->vgetparent; - tif->tif_tagmethods.vsetfield = sp->vsetparent; - tif->tif_tagmethods.printdir = sp->printdir; - tif->tif_setupdecode = sp->setupdecode; - tif->tif_setupencode = sp->setupencode; - - return 1; -} - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_predict.h b/plugins/AdvaImg/src/LibTIFF/tif_predict.h deleted file mode 100644 index 6675d9b2a7..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_predict.h +++ /dev/null @@ -1,77 +0,0 @@ -/* $Id: tif_predict.h,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1995-1997 Sam Leffler - * Copyright (c) 1995-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFFPREDICT_ -#define _TIFFPREDICT_ -/* - * ``Library-private'' Support for the Predictor Tag - */ - -/* - * Codecs that want to support the Predictor tag must place - * this structure first in their private state block so that - * the predictor code can cast tif_data to find its state. - */ -typedef struct { - int predictor; /* predictor tag value */ - int stride; /* sample stride over data */ - tsize_t rowsize; /* tile/strip row size */ - - TIFFCodeMethod encoderow; /* parent codec encode/decode row */ - TIFFCodeMethod encodestrip; /* parent codec encode/decode strip */ - TIFFCodeMethod encodetile; /* parent codec encode/decode tile */ - TIFFPostMethod encodepfunc; /* horizontal differencer */ - - TIFFCodeMethod decoderow; /* parent codec encode/decode row */ - TIFFCodeMethod decodestrip; /* parent codec encode/decode strip */ - TIFFCodeMethod decodetile; /* parent codec encode/decode tile */ - TIFFPostMethod decodepfunc; /* horizontal accumulator */ - - TIFFVGetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ - TIFFPrintMethod printdir; /* super-class method */ - TIFFBoolMethod setupdecode; /* super-class method */ - TIFFBoolMethod setupencode; /* super-class method */ -} TIFFPredictorState; - -#if defined(__cplusplus) -extern "C" { -#endif -extern int TIFFPredictorInit(TIFF*); -extern int TIFFPredictorCleanup(TIFF*); -#if defined(__cplusplus) -} -#endif -#endif /* _TIFFPREDICT_ */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_print.c b/plugins/AdvaImg/src/LibTIFF/tif_print.c deleted file mode 100644 index 50663396df..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_print.c +++ /dev/null @@ -1,642 +0,0 @@ -/* $Id: tif_print.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Directory Printing Support - */ -#include "tiffiop.h" -#include -#include -#include - -static const char *photoNames[] = { - "min-is-white", /* PHOTOMETRIC_MINISWHITE */ - "min-is-black", /* PHOTOMETRIC_MINISBLACK */ - "RGB color", /* PHOTOMETRIC_RGB */ - "palette color (RGB from colormap)", /* PHOTOMETRIC_PALETTE */ - "transparency mask", /* PHOTOMETRIC_MASK */ - "separated", /* PHOTOMETRIC_SEPARATED */ - "YCbCr", /* PHOTOMETRIC_YCBCR */ - "7 (0x7)", - "CIE L*a*b*", /* PHOTOMETRIC_CIELAB */ -}; -#define NPHOTONAMES (sizeof (photoNames) / sizeof (photoNames[0])) - -static const char *orientNames[] = { - "0 (0x0)", - "row 0 top, col 0 lhs", /* ORIENTATION_TOPLEFT */ - "row 0 top, col 0 rhs", /* ORIENTATION_TOPRIGHT */ - "row 0 bottom, col 0 rhs", /* ORIENTATION_BOTRIGHT */ - "row 0 bottom, col 0 lhs", /* ORIENTATION_BOTLEFT */ - "row 0 lhs, col 0 top", /* ORIENTATION_LEFTTOP */ - "row 0 rhs, col 0 top", /* ORIENTATION_RIGHTTOP */ - "row 0 rhs, col 0 bottom", /* ORIENTATION_RIGHTBOT */ - "row 0 lhs, col 0 bottom", /* ORIENTATION_LEFTBOT */ -}; -#define NORIENTNAMES (sizeof (orientNames) / sizeof (orientNames[0])) - -static void -_TIFFPrintField(FILE* fd, const TIFFFieldInfo *fip, - uint32 value_count, void *raw_data) -{ - uint32 j; - - fprintf(fd, " %s: ", fip->field_name); - - for(j = 0; j < value_count; j++) { - if(fip->field_type == TIFF_BYTE) - fprintf(fd, "%u", ((uint8 *) raw_data)[j]); - else if(fip->field_type == TIFF_UNDEFINED) - fprintf(fd, "0x%x", - (unsigned int) ((unsigned char *) raw_data)[j]); - else if(fip->field_type == TIFF_SBYTE) - fprintf(fd, "%d", ((int8 *) raw_data)[j]); - else if(fip->field_type == TIFF_SHORT) - fprintf(fd, "%u", ((uint16 *) raw_data)[j]); - else if(fip->field_type == TIFF_SSHORT) - fprintf(fd, "%d", ((int16 *) raw_data)[j]); - else if(fip->field_type == TIFF_LONG) - fprintf(fd, "%lu", - (unsigned long)((uint32 *) raw_data)[j]); - else if(fip->field_type == TIFF_SLONG) - fprintf(fd, "%ld", (long)((int32 *) raw_data)[j]); - else if(fip->field_type == TIFF_RATIONAL - || fip->field_type == TIFF_SRATIONAL - || fip->field_type == TIFF_FLOAT) - fprintf(fd, "%f", ((float *) raw_data)[j]); - else if(fip->field_type == TIFF_IFD) - fprintf(fd, "0x%ulx", ((uint32 *) raw_data)[j]); - else if(fip->field_type == TIFF_ASCII) { - fprintf(fd, "%s", (char *) raw_data); - break; - } - else if(fip->field_type == TIFF_DOUBLE) - fprintf(fd, "%f", ((double *) raw_data)[j]); - else if(fip->field_type == TIFF_FLOAT) - fprintf(fd, "%f", ((float *)raw_data)[j]); - else { - fprintf(fd, ""); - break; - } - - if(j < value_count - 1) - fprintf(fd, ","); - } - - fprintf(fd, "\n"); -} - -static int -_TIFFPrettyPrintField(TIFF* tif, FILE* fd, ttag_t tag, - uint32 value_count, void *raw_data) -{ - TIFFDirectory *td = &tif->tif_dir; - - switch (tag) - { - case TIFFTAG_INKSET: - fprintf(fd, " Ink Set: "); - switch (*((uint16*)raw_data)) { - case INKSET_CMYK: - fprintf(fd, "CMYK\n"); - break; - default: - fprintf(fd, "%u (0x%x)\n", - *((uint16*)raw_data), - *((uint16*)raw_data)); - break; - } - return 1; - case TIFFTAG_WHITEPOINT: - fprintf(fd, " White Point: %g-%g\n", - ((float *)raw_data)[0], ((float *)raw_data)[1]); return 1; - case TIFFTAG_REFERENCEBLACKWHITE: - { - uint16 i; - - fprintf(fd, " Reference Black/White:\n"); - for (i = 0; i < 3; i++) - fprintf(fd, " %2d: %5g %5g\n", i, - ((float *)raw_data)[2*i+0], - ((float *)raw_data)[2*i+1]); - return 1; - } - case TIFFTAG_XMLPACKET: - { - uint32 i; - - fprintf(fd, " XMLPacket (XMP Metadata):\n" ); - for(i = 0; i < value_count; i++) - fputc(((char *)raw_data)[i], fd); - fprintf( fd, "\n" ); - return 1; - } - case TIFFTAG_RICHTIFFIPTC: - /* - * XXX: for some weird reason RichTIFFIPTC tag - * defined as array of LONG values. - */ - fprintf(fd, - " RichTIFFIPTC Data: , %lu bytes\n", - (unsigned long) value_count * 4); - return 1; - case TIFFTAG_PHOTOSHOP: - fprintf(fd, " Photoshop Data: , %lu bytes\n", - (unsigned long) value_count); - return 1; - case TIFFTAG_ICCPROFILE: - fprintf(fd, " ICC Profile: , %lu bytes\n", - (unsigned long) value_count); - return 1; - case TIFFTAG_STONITS: - fprintf(fd, - " Sample to Nits conversion factor: %.4e\n", - *((double*)raw_data)); - return 1; - } - - return 0; -} - -/* - * Print the contents of the current directory - * to the specified stdio file stream. - */ -void -TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) -{ - TIFFDirectory *td = &tif->tif_dir; - char *sep; - uint16 i; - long l, n; - - fprintf(fd, "TIFF Directory at offset 0x%lx (%lu)\n", - (unsigned long)tif->tif_diroff, (unsigned long)tif->tif_diroff); - if (TIFFFieldSet(tif,FIELD_SUBFILETYPE)) { - fprintf(fd, " Subfile Type:"); - sep = " "; - if (td->td_subfiletype & FILETYPE_REDUCEDIMAGE) { - fprintf(fd, "%sreduced-resolution image", sep); - sep = "/"; - } - if (td->td_subfiletype & FILETYPE_PAGE) { - fprintf(fd, "%smulti-page document", sep); - sep = "/"; - } - if (td->td_subfiletype & FILETYPE_MASK) - fprintf(fd, "%stransparency mask", sep); - fprintf(fd, " (%lu = 0x%lx)\n", - (long) td->td_subfiletype, (long) td->td_subfiletype); - } - if (TIFFFieldSet(tif,FIELD_IMAGEDIMENSIONS)) { - fprintf(fd, " Image Width: %lu Image Length: %lu", - (unsigned long) td->td_imagewidth, (unsigned long) td->td_imagelength); - if (TIFFFieldSet(tif,FIELD_IMAGEDEPTH)) - fprintf(fd, " Image Depth: %lu", - (unsigned long) td->td_imagedepth); - fprintf(fd, "\n"); - } - if (TIFFFieldSet(tif,FIELD_TILEDIMENSIONS)) { - fprintf(fd, " Tile Width: %lu Tile Length: %lu", - (unsigned long) td->td_tilewidth, (unsigned long) td->td_tilelength); - if (TIFFFieldSet(tif,FIELD_TILEDEPTH)) - fprintf(fd, " Tile Depth: %lu", - (unsigned long) td->td_tiledepth); - fprintf(fd, "\n"); - } - if (TIFFFieldSet(tif,FIELD_RESOLUTION)) { - fprintf(fd, " Resolution: %g, %g", - td->td_xresolution, td->td_yresolution); - if (TIFFFieldSet(tif,FIELD_RESOLUTIONUNIT)) { - switch (td->td_resolutionunit) { - case RESUNIT_NONE: - fprintf(fd, " (unitless)"); - break; - case RESUNIT_INCH: - fprintf(fd, " pixels/inch"); - break; - case RESUNIT_CENTIMETER: - fprintf(fd, " pixels/cm"); - break; - default: - fprintf(fd, " (unit %u = 0x%x)", - td->td_resolutionunit, - td->td_resolutionunit); - break; - } - } - fprintf(fd, "\n"); - } - if (TIFFFieldSet(tif,FIELD_POSITION)) - fprintf(fd, " Position: %g, %g\n", - td->td_xposition, td->td_yposition); - if (TIFFFieldSet(tif,FIELD_BITSPERSAMPLE)) - fprintf(fd, " Bits/Sample: %u\n", td->td_bitspersample); - if (TIFFFieldSet(tif,FIELD_SAMPLEFORMAT)) { - fprintf(fd, " Sample Format: "); - switch (td->td_sampleformat) { - case SAMPLEFORMAT_VOID: - fprintf(fd, "void\n"); - break; - case SAMPLEFORMAT_INT: - fprintf(fd, "signed integer\n"); - break; - case SAMPLEFORMAT_UINT: - fprintf(fd, "unsigned integer\n"); - break; - case SAMPLEFORMAT_IEEEFP: - fprintf(fd, "IEEE floating point\n"); - break; - case SAMPLEFORMAT_COMPLEXINT: - fprintf(fd, "complex signed integer\n"); - break; - case SAMPLEFORMAT_COMPLEXIEEEFP: - fprintf(fd, "complex IEEE floating point\n"); - break; - default: - fprintf(fd, "%u (0x%x)\n", - td->td_sampleformat, td->td_sampleformat); - break; - } - } - if (TIFFFieldSet(tif,FIELD_COMPRESSION)) { - const TIFFCodec* c = TIFFFindCODEC(td->td_compression); - fprintf(fd, " Compression Scheme: "); - if (c) - fprintf(fd, "%s\n", c->name); - else - fprintf(fd, "%u (0x%x)\n", - td->td_compression, td->td_compression); - } - if (TIFFFieldSet(tif,FIELD_PHOTOMETRIC)) { - fprintf(fd, " Photometric Interpretation: "); - if (td->td_photometric < NPHOTONAMES) - fprintf(fd, "%s\n", photoNames[td->td_photometric]); - else { - switch (td->td_photometric) { - case PHOTOMETRIC_LOGL: - fprintf(fd, "CIE Log2(L)\n"); - break; - case PHOTOMETRIC_LOGLUV: - fprintf(fd, "CIE Log2(L) (u',v')\n"); - break; - default: - fprintf(fd, "%u (0x%x)\n", - td->td_photometric, td->td_photometric); - break; - } - } - } - if (TIFFFieldSet(tif,FIELD_EXTRASAMPLES) && td->td_extrasamples) { - fprintf(fd, " Extra Samples: %u<", td->td_extrasamples); - sep = ""; - for (i = 0; i < td->td_extrasamples; i++) { - switch (td->td_sampleinfo[i]) { - case EXTRASAMPLE_UNSPECIFIED: - fprintf(fd, "%sunspecified", sep); - break; - case EXTRASAMPLE_ASSOCALPHA: - fprintf(fd, "%sassoc-alpha", sep); - break; - case EXTRASAMPLE_UNASSALPHA: - fprintf(fd, "%sunassoc-alpha", sep); - break; - default: - fprintf(fd, "%s%u (0x%x)", sep, - td->td_sampleinfo[i], td->td_sampleinfo[i]); - break; - } - sep = ", "; - } - fprintf(fd, ">\n"); - } - if (TIFFFieldSet(tif,FIELD_INKNAMES)) { - char* cp; - fprintf(fd, " Ink Names: "); - i = td->td_samplesperpixel; - sep = ""; - for (cp = td->td_inknames; i > 0; cp = strchr(cp,'\0')+1, i--) { - fputs(sep, fd); - _TIFFprintAscii(fd, cp); - sep = ", "; - } - fputs("\n", fd); - } - if (TIFFFieldSet(tif,FIELD_THRESHHOLDING)) { - fprintf(fd, " Thresholding: "); - switch (td->td_threshholding) { - case THRESHHOLD_BILEVEL: - fprintf(fd, "bilevel art scan\n"); - break; - case THRESHHOLD_HALFTONE: - fprintf(fd, "halftone or dithered scan\n"); - break; - case THRESHHOLD_ERRORDIFFUSE: - fprintf(fd, "error diffused\n"); - break; - default: - fprintf(fd, "%u (0x%x)\n", - td->td_threshholding, td->td_threshholding); - break; - } - } - if (TIFFFieldSet(tif,FIELD_FILLORDER)) { - fprintf(fd, " FillOrder: "); - switch (td->td_fillorder) { - case FILLORDER_MSB2LSB: - fprintf(fd, "msb-to-lsb\n"); - break; - case FILLORDER_LSB2MSB: - fprintf(fd, "lsb-to-msb\n"); - break; - default: - fprintf(fd, "%u (0x%x)\n", - td->td_fillorder, td->td_fillorder); - break; - } - } - if (TIFFFieldSet(tif,FIELD_YCBCRSUBSAMPLING)) - { - /* - * For hacky reasons (see tif_jpeg.c - JPEGFixupTestSubsampling), - * we need to fetch this rather than trust what is in our - * structures. - */ - uint16 subsampling[2]; - - TIFFGetField( tif, TIFFTAG_YCBCRSUBSAMPLING, - subsampling + 0, subsampling + 1 ); - fprintf(fd, " YCbCr Subsampling: %u, %u\n", - subsampling[0], subsampling[1] ); - } - if (TIFFFieldSet(tif,FIELD_YCBCRPOSITIONING)) { - fprintf(fd, " YCbCr Positioning: "); - switch (td->td_ycbcrpositioning) { - case YCBCRPOSITION_CENTERED: - fprintf(fd, "centered\n"); - break; - case YCBCRPOSITION_COSITED: - fprintf(fd, "cosited\n"); - break; - default: - fprintf(fd, "%u (0x%x)\n", - td->td_ycbcrpositioning, td->td_ycbcrpositioning); - break; - } - } - if (TIFFFieldSet(tif,FIELD_HALFTONEHINTS)) - fprintf(fd, " Halftone Hints: light %u dark %u\n", - td->td_halftonehints[0], td->td_halftonehints[1]); - if (TIFFFieldSet(tif,FIELD_ORIENTATION)) { - fprintf(fd, " Orientation: "); - if (td->td_orientation < NORIENTNAMES) - fprintf(fd, "%s\n", orientNames[td->td_orientation]); - else - fprintf(fd, "%u (0x%x)\n", - td->td_orientation, td->td_orientation); - } - if (TIFFFieldSet(tif,FIELD_SAMPLESPERPIXEL)) - fprintf(fd, " Samples/Pixel: %u\n", td->td_samplesperpixel); - if (TIFFFieldSet(tif,FIELD_ROWSPERSTRIP)) { - fprintf(fd, " Rows/Strip: "); - if (td->td_rowsperstrip == (uint32) -1) - fprintf(fd, "(infinite)\n"); - else - fprintf(fd, "%lu\n", (unsigned long) td->td_rowsperstrip); - } - if (TIFFFieldSet(tif,FIELD_MINSAMPLEVALUE)) - fprintf(fd, " Min Sample Value: %u\n", td->td_minsamplevalue); - if (TIFFFieldSet(tif,FIELD_MAXSAMPLEVALUE)) - fprintf(fd, " Max Sample Value: %u\n", td->td_maxsamplevalue); - if (TIFFFieldSet(tif,FIELD_SMINSAMPLEVALUE)) - fprintf(fd, " SMin Sample Value: %g\n", - td->td_sminsamplevalue); - if (TIFFFieldSet(tif,FIELD_SMAXSAMPLEVALUE)) - fprintf(fd, " SMax Sample Value: %g\n", - td->td_smaxsamplevalue); - if (TIFFFieldSet(tif,FIELD_PLANARCONFIG)) { - fprintf(fd, " Planar Configuration: "); - switch (td->td_planarconfig) { - case PLANARCONFIG_CONTIG: - fprintf(fd, "single image plane\n"); - break; - case PLANARCONFIG_SEPARATE: - fprintf(fd, "separate image planes\n"); - break; - default: - fprintf(fd, "%u (0x%x)\n", - td->td_planarconfig, td->td_planarconfig); - break; - } - } - if (TIFFFieldSet(tif,FIELD_PAGENUMBER)) - fprintf(fd, " Page Number: %u-%u\n", - td->td_pagenumber[0], td->td_pagenumber[1]); - if (TIFFFieldSet(tif,FIELD_COLORMAP)) { - fprintf(fd, " Color Map: "); - if (flags & TIFFPRINT_COLORMAP) { - fprintf(fd, "\n"); - n = 1L<td_bitspersample; - for (l = 0; l < n; l++) - fprintf(fd, " %5lu: %5u %5u %5u\n", - l, - td->td_colormap[0][l], - td->td_colormap[1][l], - td->td_colormap[2][l]); - } else - fprintf(fd, "(present)\n"); - } - if (TIFFFieldSet(tif,FIELD_TRANSFERFUNCTION)) { - fprintf(fd, " Transfer Function: "); - if (flags & TIFFPRINT_CURVES) { - fprintf(fd, "\n"); - n = 1L<td_bitspersample; - for (l = 0; l < n; l++) { - fprintf(fd, " %2lu: %5u", - l, td->td_transferfunction[0][l]); - for (i = 1; i < td->td_samplesperpixel; i++) - fprintf(fd, " %5u", - td->td_transferfunction[i][l]); - fputc('\n', fd); - } - } else - fprintf(fd, "(present)\n"); - } - if (TIFFFieldSet(tif, FIELD_SUBIFD) && (td->td_subifd)) { - fprintf(fd, " SubIFD Offsets:"); - for (i = 0; i < td->td_nsubifd; i++) - fprintf(fd, " %5lu", (long) td->td_subifd[i]); - fputc('\n', fd); - } - - /* - ** Custom tag support. - */ - { - int i; - short count; - - count = (short) TIFFGetTagListCount(tif); - for(i = 0; i < count; i++) { - ttag_t tag = TIFFGetTagListEntry(tif, i); - const TIFFFieldInfo *fip; - uint32 value_count; - int mem_alloc = 0; - void *raw_data; - - fip = TIFFFieldWithTag(tif, tag); - if(fip == NULL) - continue; - - if(fip->field_passcount) { - if(TIFFGetField(tif, tag, &value_count, &raw_data) != 1) - continue; - } else { - if (fip->field_readcount == TIFF_VARIABLE - || fip->field_readcount == TIFF_VARIABLE2) - value_count = 1; - else if (fip->field_readcount == TIFF_SPP) - value_count = td->td_samplesperpixel; - else - value_count = fip->field_readcount; - if ((fip->field_type == TIFF_ASCII - || fip->field_readcount == TIFF_VARIABLE - || fip->field_readcount == TIFF_VARIABLE2 - || fip->field_readcount == TIFF_SPP - || value_count > 1) - && fip->field_tag != TIFFTAG_PAGENUMBER - && fip->field_tag != TIFFTAG_HALFTONEHINTS - && fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING - && fip->field_tag != TIFFTAG_DOTRANGE) { - if(TIFFGetField(tif, tag, &raw_data) != 1) - continue; - } else if (fip->field_tag != TIFFTAG_PAGENUMBER - && fip->field_tag != TIFFTAG_HALFTONEHINTS - && fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING - && fip->field_tag != TIFFTAG_DOTRANGE) { - raw_data = _TIFFmalloc( - _TIFFDataSize(fip->field_type) - * value_count); - mem_alloc = 1; - if(TIFFGetField(tif, tag, raw_data) != 1) { - _TIFFfree(raw_data); - continue; - } - } else { - /* - * XXX: Should be fixed and removed, see the - * notes related to TIFFTAG_PAGENUMBER, - * TIFFTAG_HALFTONEHINTS, - * TIFFTAG_YCBCRSUBSAMPLING and - * TIFFTAG_DOTRANGE tags in tif_dir.c. */ - char *tmp; - raw_data = _TIFFmalloc( - _TIFFDataSize(fip->field_type) - * value_count); - tmp = raw_data; - mem_alloc = 1; - if(TIFFGetField(tif, tag, tmp, - tmp + _TIFFDataSize(fip->field_type)) != 1) { - _TIFFfree(raw_data); - continue; - } - } - } - - /* - * Catch the tags which needs to be specially handled and - * pretty print them. If tag not handled in - * _TIFFPrettyPrintField() fall down and print it as any other - * tag. - */ - if (_TIFFPrettyPrintField(tif, fd, tag, value_count, raw_data)) { - if(mem_alloc) - _TIFFfree(raw_data); - continue; - } - else - _TIFFPrintField(fd, fip, value_count, raw_data); - - if(mem_alloc) - _TIFFfree(raw_data); - } - } - - if (tif->tif_tagmethods.printdir) - (*tif->tif_tagmethods.printdir)(tif, fd, flags); - if ((flags & TIFFPRINT_STRIPS) && - TIFFFieldSet(tif,FIELD_STRIPOFFSETS)) { - tstrip_t s; - - fprintf(fd, " %lu %s:\n", - (long) td->td_nstrips, - isTiled(tif) ? "Tiles" : "Strips"); - for (s = 0; s < td->td_nstrips; s++) - fprintf(fd, " %3lu: [%8lu, %8lu]\n", - (unsigned long) s, - (unsigned long) td->td_stripoffset[s], - (unsigned long) td->td_stripbytecount[s]); - } -} - -void -_TIFFprintAscii(FILE* fd, const char* cp) -{ - for (; *cp != '\0'; cp++) { - const char* tp; - - if (isprint((int)*cp)) { - fputc(*cp, fd); - continue; - } - for (tp = "\tt\bb\rr\nn\vv"; *tp; tp++) - if (*tp++ == *cp) - break; - if (*tp) - fprintf(fd, "\\%c", *tp); - else - fprintf(fd, "\\%03o", *cp & 0xff); - } -} - -void -_TIFFprintAsciiTag(FILE* fd, const char* name, const char* value) -{ - fprintf(fd, " %s: \"", name); - _TIFFprintAscii(fd, value); - fprintf(fd, "\"\n"); -} - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_read.c b/plugins/AdvaImg/src/LibTIFF/tif_read.c deleted file mode 100644 index 351a1b058d..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_read.c +++ /dev/null @@ -1,750 +0,0 @@ -/* $Id: tif_read.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * Scanline-oriented Read Support - */ -#include "tiffiop.h" -#include - - int TIFFFillStrip(TIFF*, tstrip_t); - int TIFFFillTile(TIFF*, ttile_t); -static int TIFFStartStrip(TIFF*, tstrip_t); -static int TIFFStartTile(TIFF*, ttile_t); -static int TIFFCheckRead(TIFF*, int); - -#define NOSTRIP ((tstrip_t) -1) /* undefined state */ -#define NOTILE ((ttile_t) -1) /* undefined state */ - -/* - * Seek to a random row+sample in a file. - */ -static int -TIFFSeek(TIFF* tif, uint32 row, tsample_t sample) -{ - register TIFFDirectory *td = &tif->tif_dir; - tstrip_t strip; - - if (row >= td->td_imagelength) { /* out of range */ - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Row out of range, max %lu", - (unsigned long) row, - (unsigned long) td->td_imagelength); - return (0); - } - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { - if (sample >= td->td_samplesperpixel) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Sample out of range, max %lu", - (unsigned long) sample, (unsigned long) td->td_samplesperpixel); - return (0); - } - strip = sample*td->td_stripsperimage + row/td->td_rowsperstrip; - } else - strip = row / td->td_rowsperstrip; - if (strip != tif->tif_curstrip) { /* different strip, refill */ - if (!TIFFFillStrip(tif, strip)) - return (0); - } else if (row < tif->tif_row) { - /* - * Moving backwards within the same strip: backup - * to the start and then decode forward (below). - * - * NB: If you're planning on lots of random access within a - * strip, it's better to just read and decode the entire - * strip, and then access the decoded data in a random fashion. - */ - if (!TIFFStartStrip(tif, strip)) - return (0); - } - if (row != tif->tif_row) { - /* - * Seek forward to the desired row. - */ - if (!(*tif->tif_seek)(tif, row - tif->tif_row)) - return (0); - tif->tif_row = row; - } - return (1); -} - -int -TIFFReadScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample) -{ - int e; - - if (!TIFFCheckRead(tif, 0)) - return (-1); - if ( (e = TIFFSeek(tif, row, sample)) != 0) { - /* - * Decompress desired row into user buffer. - */ - e = (*tif->tif_decoderow) - (tif, (tidata_t) buf, tif->tif_scanlinesize, sample); - - /* we are now poised at the beginning of the next row */ - tif->tif_row = row + 1; - - if (e) - (*tif->tif_postdecode)(tif, (tidata_t) buf, - tif->tif_scanlinesize); - } - return (e > 0 ? 1 : -1); -} - -/* - * Read a strip of data and decompress the specified - * amount into the user-supplied buffer. - */ -tsize_t -TIFFReadEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t buf, tsize_t size) -{ - TIFFDirectory *td = &tif->tif_dir; - uint32 nrows; - tsize_t stripsize; - tstrip_t sep_strip, strips_per_sep; - - if (!TIFFCheckRead(tif, 0)) - return (-1); - if (strip >= td->td_nstrips) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%ld: Strip out of range, max %ld", - (long) strip, (long) td->td_nstrips); - return (-1); - } - /* - * Calculate the strip size according to the number of - * rows in the strip (check for truncated last strip on any - * of the separations). - */ - if ( td->td_rowsperstrip >= td->td_imagelength ) - strips_per_sep = 1; - else - strips_per_sep = (td->td_imagelength+td->td_rowsperstrip-1) - / td->td_rowsperstrip; - - sep_strip = strip % strips_per_sep; - - if (sep_strip != strips_per_sep-1 || - (nrows = td->td_imagelength % td->td_rowsperstrip) == 0) - nrows = td->td_rowsperstrip; - - stripsize = TIFFVStripSize(tif, nrows); - if (size == (tsize_t) -1) - size = stripsize; - else if (size > stripsize) - size = stripsize; - if (TIFFFillStrip(tif, strip) - && (*tif->tif_decodestrip)(tif, (tidata_t) buf, size, - (tsample_t)(strip / td->td_stripsperimage)) > 0 ) { - (*tif->tif_postdecode)(tif, (tidata_t) buf, size); - return (size); - } else - return ((tsize_t) -1); -} - -static tsize_t -TIFFReadRawStrip1(TIFF* tif, - tstrip_t strip, tdata_t buf, tsize_t size, const char* module) -{ - TIFFDirectory *td = &tif->tif_dir; - - assert((tif->tif_flags&TIFF_NOREADRAW)==0); - if (!isMapped(tif)) { - tsize_t cc; - - if (!SeekOK(tif, td->td_stripoffset[strip])) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Seek error at scanline %lu, strip %lu", - tif->tif_name, - (unsigned long) tif->tif_row, (unsigned long) strip); - return (-1); - } - cc = TIFFReadFile(tif, buf, size); - if (cc != size) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Read error at scanline %lu; got %lu bytes, expected %lu", - tif->tif_name, - (unsigned long) tif->tif_row, - (unsigned long) cc, - (unsigned long) size); - return (-1); - } - } else { - if (td->td_stripoffset[strip] + size > tif->tif_size) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Read error at scanline %lu, strip %lu; got %lu bytes, expected %lu", - tif->tif_name, - (unsigned long) tif->tif_row, - (unsigned long) strip, - (unsigned long) tif->tif_size - td->td_stripoffset[strip], - (unsigned long) size); - return (-1); - } - _TIFFmemcpy(buf, tif->tif_base + td->td_stripoffset[strip], - size); - } - return (size); -} - -/* - * Read a strip of data from the file. - */ -tsize_t -TIFFReadRawStrip(TIFF* tif, tstrip_t strip, tdata_t buf, tsize_t size) -{ - static const char module[] = "TIFFReadRawStrip"; - TIFFDirectory *td = &tif->tif_dir; - /* - * FIXME: butecount should have tsize_t type, but for now libtiff - * defines tsize_t as a signed 32-bit integer and we are losing - * ability to read arrays larger than 2^31 bytes. So we are using - * uint32 instead of tsize_t here. - */ - uint32 bytecount; - - if (!TIFFCheckRead(tif, 0)) - return ((tsize_t) -1); - if (strip >= td->td_nstrips) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Strip out of range, max %lu", - (unsigned long) strip, - (unsigned long) td->td_nstrips); - return ((tsize_t) -1); - } - if (tif->tif_flags&TIFF_NOREADRAW) - { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Compression scheme does not support access to raw uncompressed data"); - return ((tsize_t) -1); - } - bytecount = td->td_stripbytecount[strip]; - if (bytecount <= 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Invalid strip byte count, strip %lu", - (unsigned long) bytecount, (unsigned long) strip); - return ((tsize_t) -1); - } - if (size != (tsize_t)-1 && (uint32)size < bytecount) - bytecount = size; - return (TIFFReadRawStrip1(tif, strip, buf, bytecount, module)); -} - -/* - * Read the specified strip and setup for decoding. The data buffer is - * expanded, as necessary, to hold the strip's data. - */ -int -TIFFFillStrip(TIFF* tif, tstrip_t strip) -{ - static const char module[] = "TIFFFillStrip"; - TIFFDirectory *td = &tif->tif_dir; - - if ((tif->tif_flags&TIFF_NOREADRAW)==0) - { - /* - * FIXME: butecount should have tsize_t type, but for now - * libtiff defines tsize_t as a signed 32-bit integer and we - * are losing ability to read arrays larger than 2^31 bytes. - * So we are using uint32 instead of tsize_t here. - */ - uint32 bytecount = td->td_stripbytecount[strip]; - if (bytecount <= 0) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Invalid strip byte count %lu, strip %lu", - tif->tif_name, (unsigned long) bytecount, - (unsigned long) strip); - return (0); - } - if (isMapped(tif) && - (isFillOrder(tif, td->td_fillorder) - || (tif->tif_flags & TIFF_NOBITREV))) { - /* - * The image is mapped into memory and we either don't - * need to flip bits or the compression routine is - * going to handle this operation itself. In this - * case, avoid copying the raw data and instead just - * reference the data from the memory mapped file - * image. This assumes that the decompression - * routines do not modify the contents of the raw data - * buffer (if they try to, the application will get a - * fault since the file is mapped read-only). - */ - if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) - _TIFFfree(tif->tif_rawdata); - tif->tif_flags &= ~TIFF_MYBUFFER; - /* - * We must check for overflow, potentially causing - * an OOB read. Instead of simple - * - * td->td_stripoffset[strip]+bytecount > tif->tif_size - * - * comparison (which can overflow) we do the following - * two comparisons: - */ - if (bytecount > tif->tif_size || - td->td_stripoffset[strip] > tif->tif_size - bytecount) { - /* - * This error message might seem strange, but - * it's what would happen if a read were done - * instead. - */ - TIFFErrorExt(tif->tif_clientdata, module, - - "%s: Read error on strip %lu; " - "got %lu bytes, expected %lu", - tif->tif_name, (unsigned long) strip, - (unsigned long) tif->tif_size - td->td_stripoffset[strip], - (unsigned long) bytecount); - tif->tif_curstrip = NOSTRIP; - return (0); - } - tif->tif_rawdatasize = bytecount; - tif->tif_rawdata = tif->tif_base + td->td_stripoffset[strip]; - } else { - /* - * Expand raw data buffer, if needed, to hold data - * strip coming from file (perhaps should set upper - * bound on the size of a buffer we'll use?). - */ - if (bytecount > (uint32)tif->tif_rawdatasize) { - tif->tif_curstrip = NOSTRIP; - if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { - TIFFErrorExt(tif->tif_clientdata, - module, - "%s: Data buffer too small to hold strip %lu", - tif->tif_name, - (unsigned long) strip); - return (0); - } - if (!TIFFReadBufferSetup(tif, 0, - TIFFroundup(bytecount, 1024))) - return (0); - } - if ((uint32)TIFFReadRawStrip1(tif, strip, - (unsigned char *)tif->tif_rawdata, - bytecount, module) != bytecount) - return (0); - if (!isFillOrder(tif, td->td_fillorder) && - (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits(tif->tif_rawdata, bytecount); - } - } - return (TIFFStartStrip(tif, strip)); -} - -/* - * Tile-oriented Read Support - * Contributed by Nancy Cam (Silicon Graphics). - */ - -/* - * Read and decompress a tile of data. The - * tile is selected by the (x,y,z,s) coordinates. - */ -tsize_t -TIFFReadTile(TIFF* tif, - tdata_t buf, uint32 x, uint32 y, uint32 z, tsample_t s) -{ - if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s)) - return (-1); - return (TIFFReadEncodedTile(tif, - TIFFComputeTile(tif, x, y, z, s), buf, (tsize_t) -1)); -} - -/* - * Read a tile of data and decompress the specified - * amount into the user-supplied buffer. - */ -tsize_t -TIFFReadEncodedTile(TIFF* tif, ttile_t tile, tdata_t buf, tsize_t size) -{ - TIFFDirectory *td = &tif->tif_dir; - tsize_t tilesize = tif->tif_tilesize; - - if (!TIFFCheckRead(tif, 1)) - return (-1); - if (tile >= td->td_nstrips) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%ld: Tile out of range, max %ld", - (long) tile, (unsigned long) td->td_nstrips); - return (-1); - } - if (size == (tsize_t) -1) - size = tilesize; - else if (size > tilesize) - size = tilesize; - if (TIFFFillTile(tif, tile) && (*tif->tif_decodetile)(tif, - (tidata_t) buf, size, (tsample_t)(tile/td->td_stripsperimage))) { - (*tif->tif_postdecode)(tif, (tidata_t) buf, size); - return (size); - } else - return (-1); -} - -static tsize_t -TIFFReadRawTile1(TIFF* tif, - ttile_t tile, tdata_t buf, tsize_t size, const char* module) -{ - TIFFDirectory *td = &tif->tif_dir; - - assert((tif->tif_flags&TIFF_NOREADRAW)==0); - if (!isMapped(tif)) { - tsize_t cc; - - if (!SeekOK(tif, td->td_stripoffset[tile])) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Seek error at row %ld, col %ld, tile %ld", - tif->tif_name, - (long) tif->tif_row, - (long) tif->tif_col, - (long) tile); - return ((tsize_t) -1); - } - cc = TIFFReadFile(tif, buf, size); - if (cc != size) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Read error at row %ld, col %ld; got %lu bytes, expected %lu", - tif->tif_name, - (long) tif->tif_row, - (long) tif->tif_col, - (unsigned long) cc, - (unsigned long) size); - return ((tsize_t) -1); - } - } else { - if (td->td_stripoffset[tile] + size > tif->tif_size) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Read error at row %ld, col %ld, tile %ld; got %lu bytes, expected %lu", - tif->tif_name, - (long) tif->tif_row, - (long) tif->tif_col, - (long) tile, - (unsigned long) tif->tif_size - td->td_stripoffset[tile], - (unsigned long) size); - return ((tsize_t) -1); - } - _TIFFmemcpy(buf, tif->tif_base + td->td_stripoffset[tile], size); - } - return (size); -} - -/* - * Read a tile of data from the file. - */ -tsize_t -TIFFReadRawTile(TIFF* tif, ttile_t tile, tdata_t buf, tsize_t size) -{ - static const char module[] = "TIFFReadRawTile"; - TIFFDirectory *td = &tif->tif_dir; - /* - * FIXME: butecount should have tsize_t type, but for now libtiff - * defines tsize_t as a signed 32-bit integer and we are losing - * ability to read arrays larger than 2^31 bytes. So we are using - * uint32 instead of tsize_t here. - */ - uint32 bytecount; - - if (!TIFFCheckRead(tif, 1)) - return ((tsize_t) -1); - if (tile >= td->td_nstrips) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Tile out of range, max %lu", - (unsigned long) tile, (unsigned long) td->td_nstrips); - return ((tsize_t) -1); - } - if (tif->tif_flags&TIFF_NOREADRAW) - { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Compression scheme does not support access to raw uncompressed data"); - return ((tsize_t) -1); - } - bytecount = td->td_stripbytecount[tile]; - if (size != (tsize_t) -1 && (uint32)size < bytecount) - bytecount = size; - return (TIFFReadRawTile1(tif, tile, buf, bytecount, module)); -} - -/* - * Read the specified tile and setup for decoding. The data buffer is - * expanded, as necessary, to hold the tile's data. - */ -int -TIFFFillTile(TIFF* tif, ttile_t tile) -{ - static const char module[] = "TIFFFillTile"; - TIFFDirectory *td = &tif->tif_dir; - - if ((tif->tif_flags&TIFF_NOREADRAW)==0) - { - /* - * FIXME: butecount should have tsize_t type, but for now - * libtiff defines tsize_t as a signed 32-bit integer and we - * are losing ability to read arrays larger than 2^31 bytes. - * So we are using uint32 instead of tsize_t here. - */ - uint32 bytecount = td->td_stripbytecount[tile]; - if (bytecount <= 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Invalid tile byte count, tile %lu", - (unsigned long) bytecount, (unsigned long) tile); - return (0); - } - if (isMapped(tif) && - (isFillOrder(tif, td->td_fillorder) - || (tif->tif_flags & TIFF_NOBITREV))) { - /* - * The image is mapped into memory and we either don't - * need to flip bits or the compression routine is - * going to handle this operation itself. In this - * case, avoid copying the raw data and instead just - * reference the data from the memory mapped file - * image. This assumes that the decompression - * routines do not modify the contents of the raw data - * buffer (if they try to, the application will get a - * fault since the file is mapped read-only). - */ - if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) - _TIFFfree(tif->tif_rawdata); - tif->tif_flags &= ~TIFF_MYBUFFER; - /* - * We must check for overflow, potentially causing - * an OOB read. Instead of simple - * - * td->td_stripoffset[tile]+bytecount > tif->tif_size - * - * comparison (which can overflow) we do the following - * two comparisons: - */ - if (bytecount > tif->tif_size || - td->td_stripoffset[tile] > tif->tif_size - bytecount) { - tif->tif_curtile = NOTILE; - return (0); - } - tif->tif_rawdatasize = bytecount; - tif->tif_rawdata = - tif->tif_base + td->td_stripoffset[tile]; - } else { - /* - * Expand raw data buffer, if needed, to hold data - * tile coming from file (perhaps should set upper - * bound on the size of a buffer we'll use?). - */ - if (bytecount > (uint32)tif->tif_rawdatasize) { - tif->tif_curtile = NOTILE; - if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { - TIFFErrorExt(tif->tif_clientdata, - module, - "%s: Data buffer too small to hold tile %ld", - tif->tif_name, - (long) tile); - return (0); - } - if (!TIFFReadBufferSetup(tif, 0, - TIFFroundup(bytecount, 1024))) - return (0); - } - if ((uint32)TIFFReadRawTile1(tif, tile, - (unsigned char *)tif->tif_rawdata, - bytecount, module) != bytecount) - return (0); - if (!isFillOrder(tif, td->td_fillorder) && - (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits(tif->tif_rawdata, bytecount); - } - } - return (TIFFStartTile(tif, tile)); -} - -/* - * Setup the raw data buffer in preparation for - * reading a strip of raw data. If the buffer - * is specified as zero, then a buffer of appropriate - * size is allocated by the library. Otherwise, - * the client must guarantee that the buffer is - * large enough to hold any individual strip of - * raw data. - */ -int -TIFFReadBufferSetup(TIFF* tif, tdata_t bp, tsize_t size) -{ - static const char module[] = "TIFFReadBufferSetup"; - - assert((tif->tif_flags&TIFF_NOREADRAW)==0); - if (tif->tif_rawdata) { - if (tif->tif_flags & TIFF_MYBUFFER) - _TIFFfree(tif->tif_rawdata); - tif->tif_rawdata = NULL; - } - - if (bp) { - tif->tif_rawdatasize = size; - tif->tif_rawdata = (tidata_t) bp; - tif->tif_flags &= ~TIFF_MYBUFFER; - } else { - tif->tif_rawdatasize = TIFFroundup(size, 1024); - if (tif->tif_rawdatasize > 0) - tif->tif_rawdata = (tidata_t) _TIFFmalloc(tif->tif_rawdatasize); - tif->tif_flags |= TIFF_MYBUFFER; - } - if ((tif->tif_rawdata == NULL) || (tif->tif_rawdatasize == 0)) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: No space for data buffer at scanline %ld", - tif->tif_name, (long) tif->tif_row); - tif->tif_rawdatasize = 0; - return (0); - } - return (1); -} - -/* - * Set state to appear as if a - * strip has just been read in. - */ -static int -TIFFStartStrip(TIFF* tif, tstrip_t strip) -{ - TIFFDirectory *td = &tif->tif_dir; - - if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { - if (!(*tif->tif_setupdecode)(tif)) - return (0); - tif->tif_flags |= TIFF_CODERSETUP; - } - tif->tif_curstrip = strip; - tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; - if (tif->tif_flags&TIFF_NOREADRAW) - { - tif->tif_rawcp = NULL; - tif->tif_rawcc = 0; - } - else - { - tif->tif_rawcp = tif->tif_rawdata; - tif->tif_rawcc = td->td_stripbytecount[strip]; - } - return ((*tif->tif_predecode)(tif, - (tsample_t)(strip / td->td_stripsperimage))); -} - -/* - * Set state to appear as if a - * tile has just been read in. - */ -static int -TIFFStartTile(TIFF* tif, ttile_t tile) -{ - TIFFDirectory *td = &tif->tif_dir; - - if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { - if (!(*tif->tif_setupdecode)(tif)) - return (0); - tif->tif_flags |= TIFF_CODERSETUP; - } - tif->tif_curtile = tile; - tif->tif_row = - (tile % TIFFhowmany(td->td_imagewidth, td->td_tilewidth)) * - td->td_tilelength; - tif->tif_col = - (tile % TIFFhowmany(td->td_imagelength, td->td_tilelength)) * - td->td_tilewidth; - if (tif->tif_flags&TIFF_NOREADRAW) - { - tif->tif_rawcp = NULL; - tif->tif_rawcc = 0; - } - else - { - tif->tif_rawcp = tif->tif_rawdata; - tif->tif_rawcc = td->td_stripbytecount[tile]; - } - return ((*tif->tif_predecode)(tif, - (tsample_t)(tile/td->td_stripsperimage))); -} - -static int -TIFFCheckRead(TIFF* tif, int tiles) -{ - if (tif->tif_mode == O_WRONLY) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "File not open for reading"); - return (0); - } - if (tiles ^ isTiled(tif)) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, tiles ? - "Can not read tiles from a stripped image" : - "Can not read scanlines from a tiled image"); - return (0); - } - return (1); -} - -void -_TIFFNoPostDecode(TIFF* tif, tidata_t buf, tsize_t cc) -{ - (void) tif; (void) buf; (void) cc; -} - -void -_TIFFSwab16BitData(TIFF* tif, tidata_t buf, tsize_t cc) -{ - (void) tif; - assert((cc & 1) == 0); - TIFFSwabArrayOfShort((uint16*) buf, cc/2); -} - -void -_TIFFSwab24BitData(TIFF* tif, tidata_t buf, tsize_t cc) -{ - (void) tif; - assert((cc % 3) == 0); - TIFFSwabArrayOfTriples((uint8*) buf, cc/3); -} - -void -_TIFFSwab32BitData(TIFF* tif, tidata_t buf, tsize_t cc) -{ - (void) tif; - assert((cc & 3) == 0); - TIFFSwabArrayOfLong((uint32*) buf, cc/4); -} - -void -_TIFFSwab64BitData(TIFF* tif, tidata_t buf, tsize_t cc) -{ - (void) tif; - assert((cc & 7) == 0); - TIFFSwabArrayOfDouble((double*) buf, cc/8); -} - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_stream.cxx b/plugins/AdvaImg/src/LibTIFF/tif_stream.cxx deleted file mode 100644 index a3aaea19d7..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_stream.cxx +++ /dev/null @@ -1,295 +0,0 @@ -/* $Id: tif_stream.cxx,v 1.32 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1996 Sam Leffler - * Copyright (c) 1991-1996 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library UNIX-specific Routines. - */ -#include "tiffiop.h" -#include - -#ifndef __VMS -using namespace std; -#endif - -class tiffis_data -{ - public: - - istream *myIS; - long myStreamStartPos; -}; - -class tiffos_data -{ - public: - - ostream *myOS; - long myStreamStartPos; -}; - -static tsize_t -_tiffosReadProc(thandle_t, tdata_t, tsize_t) -{ - return 0; -} - -static tsize_t -_tiffisReadProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - tiffis_data *data = (tiffis_data *)fd; - - data->myIS->read((char *)buf, (int)size); - - return data->myIS->gcount(); -} - -static tsize_t -_tiffosWriteProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - tiffos_data *data = (tiffos_data *)fd; - ostream *os = data->myOS; - int pos = os->tellp(); - - os->write((const char *)buf, size); - - return ((int)os->tellp()) - pos; -} - -static tsize_t -_tiffisWriteProc(thandle_t, tdata_t, tsize_t) -{ - return 0; -} - -static toff_t -_tiffosSeekProc(thandle_t fd, toff_t off, int whence) -{ - tiffos_data *data = (tiffos_data *)fd; - ostream *os = data->myOS; - - // if the stream has already failed, don't do anything - if( os->fail() ) - return os->tellp(); - - switch(whence) { - case SEEK_SET: - os->seekp(data->myStreamStartPos + off, ios::beg); - break; - case SEEK_CUR: - os->seekp(off, ios::cur); - break; - case SEEK_END: - os->seekp(off, ios::end); - break; - } - - // Attempt to workaround problems with seeking past the end of the - // stream. ofstream doesn't have a problem with this but - // ostrstream/ostringstream does. In that situation, add intermediate - // '\0' characters. - if( os->fail() ) { -#ifdef __VMS - int old_state; -#else - ios::iostate old_state; -#endif - toff_t origin=0; - - old_state = os->rdstate(); - // reset the fail bit or else tellp() won't work below - os->clear(os->rdstate() & ~ios::failbit); - switch( whence ) { - case SEEK_SET: - origin = data->myStreamStartPos; - break; - case SEEK_CUR: - origin = os->tellp(); - break; - case SEEK_END: - os->seekp(0, ios::end); - origin = os->tellp(); - break; - } - // restore original stream state - os->clear(old_state); - - // only do something if desired seek position is valid - if( origin + off > data->myStreamStartPos ) { - toff_t num_fill; - - // clear the fail bit - os->clear(os->rdstate() & ~ios::failbit); - - // extend the stream to the expected size - os->seekp(0, ios::end); - num_fill = origin + off - (toff_t)os->tellp(); - for( toff_t i = 0; i < num_fill; i++ ) - os->put('\0'); - - // retry the seek - os->seekp(origin + off, ios::beg); - } - } - - return os->tellp(); -} - -static toff_t -_tiffisSeekProc(thandle_t fd, toff_t off, int whence) -{ - tiffis_data *data = (tiffis_data *)fd; - - switch(whence) { - case SEEK_SET: - data->myIS->seekg(data->myStreamStartPos + off, ios::beg); - break; - case SEEK_CUR: - data->myIS->seekg(off, ios::cur); - break; - case SEEK_END: - data->myIS->seekg(off, ios::end); - break; - } - - return ((long)data->myIS->tellg()) - data->myStreamStartPos; -} - -static toff_t -_tiffosSizeProc(thandle_t fd) -{ - tiffos_data *data = (tiffos_data *)fd; - ostream *os = data->myOS; - toff_t pos = os->tellp(); - toff_t len; - - os->seekp(0, ios::end); - len = os->tellp(); - os->seekp(pos); - - return len; -} - -static toff_t -_tiffisSizeProc(thandle_t fd) -{ - tiffis_data *data = (tiffis_data *)fd; - int pos = data->myIS->tellg(); - int len; - - data->myIS->seekg(0, ios::end); - len = data->myIS->tellg(); - data->myIS->seekg(pos); - - return len; -} - -static int -_tiffosCloseProc(thandle_t fd) -{ - // Our stream was not allocated by us, so it shouldn't be closed by us. - delete (tiffos_data *)fd; - return 0; -} - -static int -_tiffisCloseProc(thandle_t fd) -{ - // Our stream was not allocated by us, so it shouldn't be closed by us. - delete (tiffis_data *)fd; - return 0; -} - -static int -_tiffDummyMapProc(thandle_t , tdata_t* , toff_t* ) -{ - return (0); -} - -static void -_tiffDummyUnmapProc(thandle_t , tdata_t , toff_t ) -{ -} - -/* - * Open a TIFF file descriptor for read/writing. - */ -static TIFF* -_tiffStreamOpen(const char* name, const char* mode, void *fd) -{ - TIFF* tif; - - if( strchr(mode, 'w') ) { - tiffos_data *data = new tiffos_data; - data->myOS = (ostream *)fd; - data->myStreamStartPos = data->myOS->tellp(); - - // Open for writing. - tif = TIFFClientOpen(name, mode, - (thandle_t) data, - _tiffosReadProc, _tiffosWriteProc, - _tiffosSeekProc, _tiffosCloseProc, - _tiffosSizeProc, - _tiffDummyMapProc, _tiffDummyUnmapProc); - } else { - tiffis_data *data = new tiffis_data; - data->myIS = (istream *)fd; - data->myStreamStartPos = data->myIS->tellg(); - // Open for reading. - tif = TIFFClientOpen(name, mode, - (thandle_t) data, - _tiffisReadProc, _tiffisWriteProc, - _tiffisSeekProc, _tiffisCloseProc, - _tiffisSizeProc, - _tiffDummyMapProc, _tiffDummyUnmapProc); - } - - return (tif); -} - -TIFF* -TIFFStreamOpen(const char* name, ostream *os) -{ - // If os is either a ostrstream or ostringstream, and has no data - // written to it yet, then tellp() will return -1 which will break us. - // We workaround this by writing out a dummy character and - // then seek back to the beginning. - if( !os->fail() && (int)os->tellp() < 0 ) { - *os << '\0'; - os->seekp(0); - } - - // NB: We don't support mapped files with streams so add 'm' - return _tiffStreamOpen(name, "wm", os); -} - -TIFF* -TIFFStreamOpen(const char* name, istream *is) -{ - // NB: We don't support mapped files with streams so add 'm' - return _tiffStreamOpen(name, "rm", is); -} - -/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_strip.c b/plugins/AdvaImg/src/LibTIFF/tif_strip.c deleted file mode 100644 index 8abf726a00..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_strip.c +++ /dev/null @@ -1,366 +0,0 @@ -/* $Id: tif_strip.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1991-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Strip-organized Image Support Routines. - */ -#include "tiffiop.h" - -static uint32 -summarize(TIFF* tif, size_t summand1, size_t summand2, const char* where) -{ - /* - * XXX: We are using casting to uint32 here, bacause sizeof(size_t) - * may be larger than sizeof(uint32) on 64-bit architectures. - */ - uint32 bytes = summand1 + summand2; - - if (bytes - summand1 != summand2) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Integer overflow in %s", where); - bytes = 0; - } - - return (bytes); -} - -static uint32 -multiply(TIFF* tif, size_t nmemb, size_t elem_size, const char* where) -{ - uint32 bytes = nmemb * elem_size; - - if (elem_size && bytes / elem_size != nmemb) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Integer overflow in %s", where); - bytes = 0; - } - - return (bytes); -} - -/* - * Compute which strip a (row,sample) value is in. - */ -tstrip_t -TIFFComputeStrip(TIFF* tif, uint32 row, tsample_t sample) -{ - TIFFDirectory *td = &tif->tif_dir; - tstrip_t strip; - - strip = row / td->td_rowsperstrip; - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { - if (sample >= td->td_samplesperpixel) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Sample out of range, max %lu", - (unsigned long) sample, (unsigned long) td->td_samplesperpixel); - return ((tstrip_t) 0); - } - strip += sample*td->td_stripsperimage; - } - return (strip); -} - -/* - * Compute how many strips are in an image. - */ -tstrip_t -TIFFNumberOfStrips(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - tstrip_t nstrips; - - nstrips = (td->td_rowsperstrip == (uint32) -1 ? 1 : - TIFFhowmany(td->td_imagelength, td->td_rowsperstrip)); - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - nstrips = multiply(tif, nstrips, td->td_samplesperpixel, - "TIFFNumberOfStrips"); - return (nstrips); -} - -/* - * Compute the # bytes in a variable height, row-aligned strip. - */ -tsize_t -TIFFVStripSize(TIFF* tif, uint32 nrows) -{ - TIFFDirectory *td = &tif->tif_dir; - - if (nrows == (uint32) -1) - nrows = td->td_imagelength; - if (td->td_planarconfig == PLANARCONFIG_CONTIG && - td->td_photometric == PHOTOMETRIC_YCBCR && - !isUpSampled(tif)) { - /* - * Packed YCbCr data contain one Cb+Cr for every - * HorizontalSampling*VerticalSampling Y values. - * Must also roundup width and height when calculating - * since images that are not a multiple of the - * horizontal/vertical subsampling area include - * YCbCr data for the extended image. - */ - uint16 ycbcrsubsampling[2]; - tsize_t w, scanline, samplingarea; - - TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING, - ycbcrsubsampling + 0, - ycbcrsubsampling + 1); - - samplingarea = ycbcrsubsampling[0]*ycbcrsubsampling[1]; - if (samplingarea == 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Invalid YCbCr subsampling"); - return 0; - } - - w = TIFFroundup(td->td_imagewidth, ycbcrsubsampling[0]); - scanline = TIFFhowmany8(multiply(tif, w, td->td_bitspersample, - "TIFFVStripSize")); - nrows = TIFFroundup(nrows, ycbcrsubsampling[1]); - /* NB: don't need TIFFhowmany here 'cuz everything is rounded */ - scanline = multiply(tif, nrows, scanline, "TIFFVStripSize"); - return ((tsize_t) - summarize(tif, scanline, - multiply(tif, 2, scanline / samplingarea, - "TIFFVStripSize"), "TIFFVStripSize")); - } else - return ((tsize_t) multiply(tif, nrows, TIFFScanlineSize(tif), - "TIFFVStripSize")); -} - - -/* - * Compute the # bytes in a raw strip. - */ -tsize_t -TIFFRawStripSize(TIFF* tif, tstrip_t strip) -{ - TIFFDirectory* td = &tif->tif_dir; - tsize_t bytecount = td->td_stripbytecount[strip]; - - if (bytecount <= 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Invalid strip byte count, strip %lu", - (unsigned long) bytecount, (unsigned long) strip); - bytecount = (tsize_t) -1; - } - - return bytecount; -} - -/* - * Compute the # bytes in a (row-aligned) strip. - * - * Note that if RowsPerStrip is larger than the - * recorded ImageLength, then the strip size is - * truncated to reflect the actual space required - * to hold the strip. - */ -tsize_t -TIFFStripSize(TIFF* tif) -{ - TIFFDirectory* td = &tif->tif_dir; - uint32 rps = td->td_rowsperstrip; - if (rps > td->td_imagelength) - rps = td->td_imagelength; - return (TIFFVStripSize(tif, rps)); -} - -/* - * Compute a default strip size based on the image - * characteristics and a requested value. If the - * request is <1 then we choose a strip size according - * to certain heuristics. - */ -uint32 -TIFFDefaultStripSize(TIFF* tif, uint32 request) -{ - return (*tif->tif_defstripsize)(tif, request); -} - -uint32 -_TIFFDefaultStripSize(TIFF* tif, uint32 s) -{ - if ((int32) s < 1) { - /* - * If RowsPerStrip is unspecified, try to break the - * image up into strips that are approximately - * STRIP_SIZE_DEFAULT bytes long. - */ - tsize_t scanline = TIFFScanlineSize(tif); - s = (uint32)STRIP_SIZE_DEFAULT / (scanline == 0 ? 1 : scanline); - if (s == 0) /* very wide images */ - s = 1; - } - return (s); -} - -/* - * Return the number of bytes to read/write in a call to - * one of the scanline-oriented i/o routines. Note that - * this number may be 1/samples-per-pixel if data is - * stored as separate planes. - */ -tsize_t -TIFFScanlineSize(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - tsize_t scanline; - - if (td->td_planarconfig == PLANARCONFIG_CONTIG) { - if (td->td_photometric == PHOTOMETRIC_YCBCR - && !isUpSampled(tif)) { - uint16 ycbcrsubsampling[2]; - - TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING, - ycbcrsubsampling + 0, - ycbcrsubsampling + 1); - - if (ycbcrsubsampling[0]*ycbcrsubsampling[1] == 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Invalid YCbCr subsampling"); - return 0; - } - - /* number of sample clumps per line */ - scanline = TIFFhowmany(td->td_imagewidth, - ycbcrsubsampling[0]); - /* number of samples per line */ - scanline = multiply(tif, scanline, - ycbcrsubsampling[0]*ycbcrsubsampling[1] + 2, - "TIFFScanlineSize"); - } else { - scanline = multiply(tif, td->td_imagewidth, - td->td_samplesperpixel, - "TIFFScanlineSize"); - } - } else - scanline = td->td_imagewidth; - return ((tsize_t) TIFFhowmany8(multiply(tif, scanline, - td->td_bitspersample, - "TIFFScanlineSize"))); -} - -/* - * Some stuff depends on this older version of TIFFScanlineSize - * TODO: resolve this - */ -tsize_t -TIFFOldScanlineSize(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - tsize_t scanline; - - scanline = multiply (tif, td->td_bitspersample, td->td_imagewidth, - "TIFFScanlineSize"); - if (td->td_planarconfig == PLANARCONFIG_CONTIG) - scanline = multiply (tif, scanline, td->td_samplesperpixel, - "TIFFScanlineSize"); - return ((tsize_t) TIFFhowmany8(scanline)); -} - -/* - * Return the number of bytes to read/write in a call to - * one of the scanline-oriented i/o routines. Note that - * this number may be 1/samples-per-pixel if data is - * stored as separate planes. - * The ScanlineSize in case of YCbCrSubsampling is defined as the - * strip size divided by the strip height, i.e. the size of a pack of vertical - * subsampling lines divided by vertical subsampling. It should thus make - * sense when multiplied by a multiple of vertical subsampling. - * Some stuff depends on this newer version of TIFFScanlineSize - * TODO: resolve this - */ -tsize_t -TIFFNewScanlineSize(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - tsize_t scanline; - - if (td->td_planarconfig == PLANARCONFIG_CONTIG) { - if (td->td_photometric == PHOTOMETRIC_YCBCR - && !isUpSampled(tif)) { - uint16 ycbcrsubsampling[2]; - - TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING, - ycbcrsubsampling + 0, - ycbcrsubsampling + 1); - - if (ycbcrsubsampling[0]*ycbcrsubsampling[1] == 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Invalid YCbCr subsampling"); - return 0; - } - - return((tsize_t) ((((td->td_imagewidth+ycbcrsubsampling[0]-1) - /ycbcrsubsampling[0]) - *(ycbcrsubsampling[0]*ycbcrsubsampling[1]+2) - *td->td_bitspersample+7) - /8)/ycbcrsubsampling[1]); - - } else { - scanline = multiply(tif, td->td_imagewidth, - td->td_samplesperpixel, - "TIFFScanlineSize"); - } - } else - scanline = td->td_imagewidth; - return ((tsize_t) TIFFhowmany8(multiply(tif, scanline, - td->td_bitspersample, - "TIFFScanlineSize"))); -} - -/* - * Return the number of bytes required to store a complete - * decoded and packed raster scanline (as opposed to the - * I/O size returned by TIFFScanlineSize which may be less - * if data is store as separate planes). - */ -tsize_t -TIFFRasterScanlineSize(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - tsize_t scanline; - - scanline = multiply (tif, td->td_bitspersample, td->td_imagewidth, - "TIFFRasterScanlineSize"); - if (td->td_planarconfig == PLANARCONFIG_CONTIG) { - scanline = multiply (tif, scanline, td->td_samplesperpixel, - "TIFFRasterScanlineSize"); - return ((tsize_t) TIFFhowmany8(scanline)); - } else - return ((tsize_t) multiply (tif, TIFFhowmany8(scanline), - td->td_samplesperpixel, - "TIFFRasterScanlineSize")); -} - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_swab.c b/plugins/AdvaImg/src/LibTIFF/tif_swab.c deleted file mode 100644 index 5a42713d5c..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_swab.c +++ /dev/null @@ -1,242 +0,0 @@ -/* $Id: tif_swab.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library Bit & Byte Swapping Support. - * - * XXX We assume short = 16-bits and long = 32-bits XXX - */ -#include "tiffiop.h" - -#ifndef TIFFSwabShort -void -TIFFSwabShort(uint16* wp) -{ - register unsigned char* cp = (unsigned char*) wp; - unsigned char t; - - t = cp[1]; cp[1] = cp[0]; cp[0] = t; -} -#endif - -#ifndef TIFFSwabLong -void -TIFFSwabLong(uint32* lp) -{ - register unsigned char* cp = (unsigned char*) lp; - unsigned char t; - - t = cp[3]; cp[3] = cp[0]; cp[0] = t; - t = cp[2]; cp[2] = cp[1]; cp[1] = t; -} -#endif - -#ifndef TIFFSwabArrayOfShort -void -TIFFSwabArrayOfShort(uint16* wp, register unsigned long n) -{ - register unsigned char* cp; - register unsigned char t; - - /* XXX unroll loop some */ - while (n-- > 0) { - cp = (unsigned char*) wp; - t = cp[1]; cp[1] = cp[0]; cp[0] = t; - wp++; - } -} -#endif - -#ifndef TIFFSwabArrayOfTriples -void -TIFFSwabArrayOfTriples(uint8* tp, unsigned long n) -{ - unsigned char* cp; - unsigned char t; - - /* XXX unroll loop some */ - while (n-- > 0) { - cp = (unsigned char*) tp; - t = cp[2]; cp[2] = cp[0]; cp[0] = t; - tp += 3; - } -} -#endif - -#ifndef TIFFSwabArrayOfLong -void -TIFFSwabArrayOfLong(register uint32* lp, register unsigned long n) -{ - register unsigned char *cp; - register unsigned char t; - - /* XXX unroll loop some */ - while (n-- > 0) { - cp = (unsigned char *)lp; - t = cp[3]; cp[3] = cp[0]; cp[0] = t; - t = cp[2]; cp[2] = cp[1]; cp[1] = t; - lp++; - } -} -#endif - -#ifndef TIFFSwabDouble -void -TIFFSwabDouble(double *dp) -{ - register uint32* lp = (uint32*) dp; - uint32 t; - - TIFFSwabArrayOfLong(lp, 2); - t = lp[0]; lp[0] = lp[1]; lp[1] = t; -} -#endif - -#ifndef TIFFSwabArrayOfDouble -void -TIFFSwabArrayOfDouble(double* dp, register unsigned long n) -{ - register uint32* lp = (uint32*) dp; - register uint32 t; - - TIFFSwabArrayOfLong(lp, n + n); - while (n-- > 0) { - t = lp[0]; lp[0] = lp[1]; lp[1] = t; - lp += 2; - } -} -#endif - -/* - * Bit reversal tables. TIFFBitRevTable[] gives - * the bit reversed value of . Used in various - * places in the library when the FillOrder requires - * bit reversal of byte values (e.g. CCITT Fax 3 - * encoding/decoding). TIFFNoBitRevTable is provided - * for algorithms that want an equivalent table that - * do not reverse bit values. - */ -static const unsigned char TIFFBitRevTable[256] = { - 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, - 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, - 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, - 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, - 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, - 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, - 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, - 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, - 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, - 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, - 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, - 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, - 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, - 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, - 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, - 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, - 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, - 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, - 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, - 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, - 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, - 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, - 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, - 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, - 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, - 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, - 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, - 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, - 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, - 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, - 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, - 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff -}; -static const unsigned char TIFFNoBitRevTable[256] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, - 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, - 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, - 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, - 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, - 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, -}; - -const unsigned char* -TIFFGetBitRevTable(int reversed) -{ - return (reversed ? TIFFBitRevTable : TIFFNoBitRevTable); -} - -void -TIFFReverseBits(register unsigned char* cp, register unsigned long n) -{ - for (; n > 8; n -= 8) { - cp[0] = TIFFBitRevTable[cp[0]]; - cp[1] = TIFFBitRevTable[cp[1]]; - cp[2] = TIFFBitRevTable[cp[2]]; - cp[3] = TIFFBitRevTable[cp[3]]; - cp[4] = TIFFBitRevTable[cp[4]]; - cp[5] = TIFFBitRevTable[cp[5]]; - cp[6] = TIFFBitRevTable[cp[6]]; - cp[7] = TIFFBitRevTable[cp[7]]; - cp += 8; - } - while (n-- > 0) - *cp = TIFFBitRevTable[*cp], cp++; -} - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_thunder.c b/plugins/AdvaImg/src/LibTIFF/tif_thunder.c deleted file mode 100644 index b8c6cc93cc..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_thunder.c +++ /dev/null @@ -1,189 +0,0 @@ -/* $Id: tif_thunder.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#include "tiffiop.h" -#include -#ifdef THUNDER_SUPPORT -/* - * TIFF Library. - * - * ThunderScan 4-bit Compression Algorithm Support - */ - -/* - * ThunderScan uses an encoding scheme designed for - * 4-bit pixel values. Data is encoded in bytes, with - * each byte split into a 2-bit code word and a 6-bit - * data value. The encoding gives raw data, runs of - * pixels, or pixel values encoded as a delta from the - * previous pixel value. For the latter, either 2-bit - * or 3-bit delta values are used, with the deltas packed - * into a single byte. - */ -#define THUNDER_DATA 0x3f /* mask for 6-bit data */ -#define THUNDER_CODE 0xc0 /* mask for 2-bit code word */ -/* code values */ -#define THUNDER_RUN 0x00 /* run of pixels w/ encoded count */ -#define THUNDER_2BITDELTAS 0x40 /* 3 pixels w/ encoded 2-bit deltas */ -#define DELTA2_SKIP 2 /* skip code for 2-bit deltas */ -#define THUNDER_3BITDELTAS 0x80 /* 2 pixels w/ encoded 3-bit deltas */ -#define DELTA3_SKIP 4 /* skip code for 3-bit deltas */ -#define THUNDER_RAW 0xc0 /* raw data encoded */ - -static const int twobitdeltas[4] = { 0, 1, 0, -1 }; -static const int threebitdeltas[8] = { 0, 1, 2, 3, 0, -3, -2, -1 }; - -#define SETPIXEL(op, v) { \ - lastpixel = (v) & 0xf; \ - if ( npixels < maxpixels ) \ - { \ - if (npixels++ & 1) \ - *op++ |= lastpixel; \ - else \ - op[0] = (tidataval_t) (lastpixel << 4); \ - } \ -} - -static int -ThunderSetupDecode(TIFF* tif) -{ - static const char module[] = "ThunderSetupDecode"; - - if ( tif->tif_dir.td_bitspersample != 4 ) - { - TIFFErrorExt(tif->tif_clientdata, module, - "Wrong bitspersample value (%d), Thunder decoder only supports 4bits per sample.", - (int) tif->tif_dir.td_bitspersample ); - return 0; - } - - - return (1); -} - -static int -ThunderDecode(TIFF* tif, tidata_t op, tsize_t maxpixels) -{ - register unsigned char *bp; - register tsize_t cc; - unsigned int lastpixel; - tsize_t npixels; - - bp = (unsigned char *)tif->tif_rawcp; - cc = tif->tif_rawcc; - lastpixel = 0; - npixels = 0; - while (cc > 0 && npixels < maxpixels) { - int n, delta; - - n = *bp++, cc--; - switch (n & THUNDER_CODE) { - case THUNDER_RUN: /* pixel run */ - /* - * Replicate the last pixel n times, - * where n is the lower-order 6 bits. - */ - if (npixels & 1) { - op[0] |= lastpixel; - lastpixel = *op++; npixels++; n--; - } else - lastpixel |= lastpixel << 4; - npixels += n; - if (npixels < maxpixels) { - for (; n > 0; n -= 2) - *op++ = (tidataval_t) lastpixel; - } - if (n == -1) - *--op &= 0xf0; - lastpixel &= 0xf; - break; - case THUNDER_2BITDELTAS: /* 2-bit deltas */ - if ((delta = ((n >> 4) & 3)) != DELTA2_SKIP) - SETPIXEL(op, lastpixel + twobitdeltas[delta]); - if ((delta = ((n >> 2) & 3)) != DELTA2_SKIP) - SETPIXEL(op, lastpixel + twobitdeltas[delta]); - if ((delta = (n & 3)) != DELTA2_SKIP) - SETPIXEL(op, lastpixel + twobitdeltas[delta]); - break; - case THUNDER_3BITDELTAS: /* 3-bit deltas */ - if ((delta = ((n >> 3) & 7)) != DELTA3_SKIP) - SETPIXEL(op, lastpixel + threebitdeltas[delta]); - if ((delta = (n & 7)) != DELTA3_SKIP) - SETPIXEL(op, lastpixel + threebitdeltas[delta]); - break; - case THUNDER_RAW: /* raw data */ - SETPIXEL(op, n); - break; - } - } - tif->tif_rawcp = (tidata_t) bp; - tif->tif_rawcc = cc; - if (npixels != maxpixels) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "ThunderDecode: %s data at scanline %ld (%lu != %lu)", - npixels < maxpixels ? "Not enough" : "Too much", - (long) tif->tif_row, (long) npixels, (long) maxpixels); - return (0); - } - return (1); -} - -static int -ThunderDecodeRow(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) -{ - tidata_t row = buf; - - (void) s; - while ((long)occ > 0) { - if (!ThunderDecode(tif, row, tif->tif_dir.td_imagewidth)) - return (0); - occ -= tif->tif_scanlinesize; - row += tif->tif_scanlinesize; - } - - return (1); -} - -int -TIFFInitThunderScan(TIFF* tif, int scheme) -{ - (void) scheme; - tif->tif_decoderow = ThunderDecodeRow; - tif->tif_decodestrip = ThunderDecodeRow; - tif->tif_setupdecode = ThunderSetupDecode; - return (1); -} -#endif /* THUNDER_SUPPORT */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ - diff --git a/plugins/AdvaImg/src/LibTIFF/tif_tile.c b/plugins/AdvaImg/src/LibTIFF/tif_tile.c deleted file mode 100644 index 4659825aab..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_tile.c +++ /dev/null @@ -1,280 +0,0 @@ -/* $Id: tif_tile.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1991-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Tiled Image Support Routines. - */ -#include "tiffiop.h" - -static uint32 -summarize(TIFF* tif, size_t summand1, size_t summand2, const char* where) -{ - /* - * XXX: We are using casting to uint32 here, because sizeof(size_t) - * may be larger than sizeof(uint32) on 64-bit architectures. - */ - uint32 bytes = summand1 + summand2; - - if (bytes - summand1 != summand2) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Integer overflow in %s", where); - bytes = 0; - } - - return (bytes); -} - -static uint32 -multiply(TIFF* tif, size_t nmemb, size_t elem_size, const char* where) -{ - uint32 bytes = nmemb * elem_size; - - if (elem_size && bytes / elem_size != nmemb) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Integer overflow in %s", where); - bytes = 0; - } - - return (bytes); -} - -/* - * Compute which tile an (x,y,z,s) value is in. - */ -ttile_t -TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, tsample_t s) -{ - TIFFDirectory *td = &tif->tif_dir; - uint32 dx = td->td_tilewidth; - uint32 dy = td->td_tilelength; - uint32 dz = td->td_tiledepth; - ttile_t tile = 1; - - if (td->td_imagedepth == 1) - z = 0; - if (dx == (uint32) -1) - dx = td->td_imagewidth; - if (dy == (uint32) -1) - dy = td->td_imagelength; - if (dz == (uint32) -1) - dz = td->td_imagedepth; - if (dx != 0 && dy != 0 && dz != 0) { - uint32 xpt = TIFFhowmany(td->td_imagewidth, dx); - uint32 ypt = TIFFhowmany(td->td_imagelength, dy); - uint32 zpt = TIFFhowmany(td->td_imagedepth, dz); - - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - tile = (xpt*ypt*zpt)*s + - (xpt*ypt)*(z/dz) + - xpt*(y/dy) + - x/dx; - else - tile = (xpt*ypt)*(z/dz) + xpt*(y/dy) + x/dx; - } - return (tile); -} - -/* - * Check an (x,y,z,s) coordinate - * against the image bounds. - */ -int -TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, tsample_t s) -{ - TIFFDirectory *td = &tif->tif_dir; - - if (x >= td->td_imagewidth) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Col out of range, max %lu", - (unsigned long) x, - (unsigned long) (td->td_imagewidth - 1)); - return (0); - } - if (y >= td->td_imagelength) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Row out of range, max %lu", - (unsigned long) y, - (unsigned long) (td->td_imagelength - 1)); - return (0); - } - if (z >= td->td_imagedepth) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Depth out of range, max %lu", - (unsigned long) z, - (unsigned long) (td->td_imagedepth - 1)); - return (0); - } - if (td->td_planarconfig == PLANARCONFIG_SEPARATE && - s >= td->td_samplesperpixel) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Sample out of range, max %lu", - (unsigned long) s, - (unsigned long) (td->td_samplesperpixel - 1)); - return (0); - } - return (1); -} - -/* - * Compute how many tiles are in an image. - */ -ttile_t -TIFFNumberOfTiles(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - uint32 dx = td->td_tilewidth; - uint32 dy = td->td_tilelength; - uint32 dz = td->td_tiledepth; - ttile_t ntiles; - - if (dx == (uint32) -1) - dx = td->td_imagewidth; - if (dy == (uint32) -1) - dy = td->td_imagelength; - if (dz == (uint32) -1) - dz = td->td_imagedepth; - ntiles = (dx == 0 || dy == 0 || dz == 0) ? 0 : - multiply(tif, multiply(tif, TIFFhowmany(td->td_imagewidth, dx), - TIFFhowmany(td->td_imagelength, dy), - "TIFFNumberOfTiles"), - TIFFhowmany(td->td_imagedepth, dz), "TIFFNumberOfTiles"); - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - ntiles = multiply(tif, ntiles, td->td_samplesperpixel, - "TIFFNumberOfTiles"); - return (ntiles); -} - -/* - * Compute the # bytes in each row of a tile. - */ -tsize_t -TIFFTileRowSize(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - tsize_t rowsize; - - if (td->td_tilelength == 0 || td->td_tilewidth == 0) - return ((tsize_t) 0); - rowsize = multiply(tif, td->td_bitspersample, td->td_tilewidth, - "TIFFTileRowSize"); - if (td->td_planarconfig == PLANARCONFIG_CONTIG) - rowsize = multiply(tif, rowsize, td->td_samplesperpixel, - "TIFFTileRowSize"); - return ((tsize_t) TIFFhowmany8(rowsize)); -} - -/* - * Compute the # bytes in a variable length, row-aligned tile. - */ -tsize_t -TIFFVTileSize(TIFF* tif, uint32 nrows) -{ - TIFFDirectory *td = &tif->tif_dir; - tsize_t tilesize; - - if (td->td_tilelength == 0 || td->td_tilewidth == 0 || - td->td_tiledepth == 0) - return ((tsize_t) 0); - if (td->td_planarconfig == PLANARCONFIG_CONTIG && - td->td_photometric == PHOTOMETRIC_YCBCR && - !isUpSampled(tif)) { - /* - * Packed YCbCr data contain one Cb+Cr for every - * HorizontalSampling*VerticalSampling Y values. - * Must also roundup width and height when calculating - * since images that are not a multiple of the - * horizontal/vertical subsampling area include - * YCbCr data for the extended image. - */ - tsize_t w = - TIFFroundup(td->td_tilewidth, td->td_ycbcrsubsampling[0]); - tsize_t rowsize = - TIFFhowmany8(multiply(tif, w, td->td_bitspersample, - "TIFFVTileSize")); - tsize_t samplingarea = - td->td_ycbcrsubsampling[0]*td->td_ycbcrsubsampling[1]; - if (samplingarea == 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Invalid YCbCr subsampling"); - return 0; - } - nrows = TIFFroundup(nrows, td->td_ycbcrsubsampling[1]); - /* NB: don't need TIFFhowmany here 'cuz everything is rounded */ - tilesize = multiply(tif, nrows, rowsize, "TIFFVTileSize"); - tilesize = summarize(tif, tilesize, - multiply(tif, 2, tilesize / samplingarea, - "TIFFVTileSize"), - "TIFFVTileSize"); - } else - tilesize = multiply(tif, nrows, TIFFTileRowSize(tif), - "TIFFVTileSize"); - return ((tsize_t) - multiply(tif, tilesize, td->td_tiledepth, "TIFFVTileSize")); -} - -/* - * Compute the # bytes in a row-aligned tile. - */ -tsize_t -TIFFTileSize(TIFF* tif) -{ - return (TIFFVTileSize(tif, tif->tif_dir.td_tilelength)); -} - -/* - * Compute a default tile size based on the image - * characteristics and a requested value. If a - * request is <1 then we choose a size according - * to certain heuristics. - */ -void -TIFFDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) -{ - (*tif->tif_deftilesize)(tif, tw, th); -} - -void -_TIFFDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) -{ - (void) tif; - if (*(int32*) tw < 1) - *tw = 256; - if (*(int32*) th < 1) - *th = 256; - /* roundup to a multiple of 16 per the spec */ - if (*tw & 0xf) - *tw = TIFFroundup(*tw, 16); - if (*th & 0xf) - *th = TIFFroundup(*th, 16); -} - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_unix.c b/plugins/AdvaImg/src/LibTIFF/tif_unix.c deleted file mode 100644 index 7e294cb78b..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_unix.c +++ /dev/null @@ -1,300 +0,0 @@ -/* $Id: tif_unix.c,v 1.35 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library UNIX-specific Routines. These are should also work with the - * Windows Common RunTime Library. - */ -#include "tif_config.h" - -#ifdef HAVE_SYS_TYPES_H -# include -#endif - -#include -#include -#include - -#ifdef HAVE_UNISTD_H -# include -#endif - -#ifdef HAVE_FCNTL_H -# include -#endif - -#ifdef HAVE_IO_H -# include -#endif - -#include "tiffiop.h" - -static tsize_t -_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return ((tsize_t) read((int) fd, buf, (size_t) size)); -} - -static tsize_t -_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return ((tsize_t) write((int) fd, buf, (size_t) size)); -} - -static toff_t -_tiffSeekProc(thandle_t fd, toff_t off, int whence) -{ - return ((toff_t) lseek((int) fd, (off_t) off, whence)); -} - -static int -_tiffCloseProc(thandle_t fd) -{ - return (close((int) fd)); -} - - -static toff_t -_tiffSizeProc(thandle_t fd) -{ -#ifdef _AM29K - long fsize; - return ((fsize = lseek((int) fd, 0, SEEK_END)) < 0 ? 0 : fsize); -#else - struct stat sb; - return (toff_t) (fstat((int) fd, &sb) < 0 ? 0 : sb.st_size); -#endif -} - -#ifdef HAVE_MMAP -#include - -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - toff_t size = _tiffSizeProc(fd); - if (size != (toff_t) -1) { - *pbase = (tdata_t) - mmap(0, size, PROT_READ, MAP_SHARED, (int) fd, 0); - if (*pbase != (tdata_t) -1) { - *psize = size; - return (1); - } - } - return (0); -} - -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ - (void) fd; - (void) munmap(base, (off_t) size); -} -#else /* !HAVE_MMAP */ -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - (void) fd; (void) pbase; (void) psize; - return (0); -} - -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ - (void) fd; (void) base; (void) size; -} -#endif /* !HAVE_MMAP */ - -/* - * Open a TIFF file descriptor for read/writing. - */ -TIFF* -TIFFFdOpen(int fd, const char* name, const char* mode) -{ - TIFF* tif; - - tif = TIFFClientOpen(name, mode, - (thandle_t) fd, - _tiffReadProc, _tiffWriteProc, - _tiffSeekProc, _tiffCloseProc, _tiffSizeProc, - _tiffMapProc, _tiffUnmapProc); - if (tif) - tif->tif_fd = fd; - return (tif); -} - -/* - * Open a TIFF file for read/writing. - */ -TIFF* -TIFFOpen(const char* name, const char* mode) -{ - static const char module[] = "TIFFOpen"; - int m, fd; - TIFF* tif; - - m = _TIFFgetMode(mode, module); - if (m == -1) - return ((TIFF*)0); - -/* for cygwin and mingw */ -#ifdef O_BINARY - m |= O_BINARY; -#endif - -#ifdef _AM29K - fd = open(name, m); -#else - fd = open(name, m, 0666); -#endif - if (fd < 0) { - TIFFErrorExt(0, module, "%s: Cannot open", name); - return ((TIFF *)0); - } - - tif = TIFFFdOpen((int)fd, name, mode); - if (!tif) - close(fd); - return tif; -} - -#ifdef __WIN32__ -#include -/* - * Open a TIFF file with a Unicode filename, for read/writing. - */ -TIFF* -TIFFOpenW(const wchar_t* name, const char* mode) -{ - static const char module[] = "TIFFOpenW"; - int m, fd; - int mbsize; - char *mbname; - TIFF* tif; - - m = _TIFFgetMode(mode, module); - if (m == -1) - return ((TIFF*)0); - -/* for cygwin and mingw */ -#ifdef O_BINARY - m |= O_BINARY; -#endif - - fd = _wopen(name, m, 0666); - if (fd < 0) { - TIFFErrorExt(0, module, "%s: Cannot open", name); - return ((TIFF *)0); - } - - mbname = NULL; - mbsize = WideCharToMultiByte(CP_ACP, 0, name, -1, NULL, 0, NULL, NULL); - if (mbsize > 0) { - mbname = _TIFFmalloc(mbsize); - if (!mbname) { - TIFFErrorExt(0, module, - "Can't allocate space for filename conversion buffer"); - return ((TIFF*)0); - } - - WideCharToMultiByte(CP_ACP, 0, name, -1, mbname, mbsize, - NULL, NULL); - } - - tif = TIFFFdOpen((int)fd, (mbname != NULL) ? mbname : "", - mode); - - _TIFFfree(mbname); - - if (!tif) - close(fd); - return tif; -} -#endif - -void* -_TIFFmalloc(tsize_t s) -{ - return (malloc((size_t) s)); -} - -void -_TIFFfree(tdata_t p) -{ - free(p); -} - -void* -_TIFFrealloc(tdata_t p, tsize_t s) -{ - return (realloc(p, (size_t) s)); -} - -void -_TIFFmemset(tdata_t p, int v, tsize_t c) -{ - memset(p, v, (size_t) c); -} - -void -_TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c) -{ - memcpy(d, s, (size_t) c); -} - -int -_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) -{ - return (memcmp(p1, p2, (size_t) c)); -} - -static void -unixWarningHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - fprintf(stderr, "Warning, "); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFwarningHandler = unixWarningHandler; - -static void -unixErrorHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFerrorHandler = unixErrorHandler; -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_version.c b/plugins/AdvaImg/src/LibTIFF/tif_version.c deleted file mode 100644 index 6badfcdb5f..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_version.c +++ /dev/null @@ -1,40 +0,0 @@ -/* $Header: /cvsroot/freeimage/FreeImage/Source/LibTIFF/tif_version.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ -/* - * Copyright (c) 1992-1997 Sam Leffler - * Copyright (c) 1992-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ -#include "tiffiop.h" - -static const char TIFFVersion[] = TIFFLIB_VERSION_STR; - -const char* -TIFFGetVersion(void) -{ - return (TIFFVersion); -} -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_vms.c b/plugins/AdvaImg/src/LibTIFF/tif_vms.c deleted file mode 100644 index 553f5072e3..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_vms.c +++ /dev/null @@ -1,595 +0,0 @@ -/* $Id: tif_vms.c,v 1.21 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library VMS-specific Routines. - */ - -#include -#include -#include "tiffiop.h" -#if !HAVE_IEEEFP -#include -#endif - -#ifdef VAXC -#define NOSHARE noshare -#else -#define NOSHARE -#endif - -#ifdef __alpha -/* Dummy entry point for backwards compatibility */ -void TIFFModeCCITTFax3(void){} -#endif - -static tsize_t -_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return (read((int) fd, buf, size)); -} - -static tsize_t -_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return (write((int) fd, buf, size)); -} - -static toff_t -_tiffSeekProc(thandle_t fd, toff_t off, int whence) -{ - return ((toff_t) lseek((int) fd, (off_t) off, whence)); -} - -static int -_tiffCloseProc(thandle_t fd) -{ - return (close((int) fd)); -} - -#include - -static toff_t -_tiffSizeProc(thandle_t fd) -{ - struct stat sb; - return (toff_t) (fstat((int) fd, &sb) < 0 ? 0 : sb.st_size); -} - -#ifdef HAVE_MMAP -#include -#include -#include - -/* - * Table for storing information on current open sections. - * (Should really be a linked list) - */ -#define MAX_MAPPED 100 -static int no_mapped = 0; -static struct { - char *base; - char *top; - unsigned short channel; -} map_table[MAX_MAPPED]; - -/* - * This routine maps a file into a private section. Note that this - * method of accessing a file is by far the fastest under VMS. - * The routine may fail (i.e. return 0) for several reasons, for - * example: - * - There is no more room for storing the info on sections. - * - The process is out of open file quota, channels, ... - * - fd does not describe an opened file. - * - The file is already opened for write access by this process - * or another process - * - There is no free "hole" in virtual memory that fits the - * size of the file - */ -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - char name[256]; - struct FAB fab; - unsigned short channel; - char *inadr[2], *retadr[2]; - unsigned long status; - long size; - - if (no_mapped >= MAX_MAPPED) - return(0); - /* - * We cannot use a file descriptor, we - * must open the file once more. - */ - if (getname((int)fd, name, 1) == NULL) - return(0); - /* prepare the FAB for a user file open */ - fab = cc$rms_fab; - fab.fab$l_fop |= FAB$V_UFO; - fab.fab$b_fac = FAB$M_GET; - fab.fab$b_shr = FAB$M_SHRGET; - fab.fab$l_fna = name; - fab.fab$b_fns = strlen(name); - status = sys$open(&fab); /* open file & get channel number */ - if ((status&1) == 0) - return(0); - channel = (unsigned short)fab.fab$l_stv; - inadr[0] = inadr[1] = (char *)0; /* just an address in P0 space */ - /* - * Map the blocks of the file up to - * the EOF block into virtual memory. - */ - size = _tiffSizeProc(fd); - status = sys$crmpsc(inadr, retadr, 0, SEC$M_EXPREG, 0,0,0, channel, - TIFFhowmany(size,512), 0,0,0); - if ((status&1) == 0){ - sys$dassgn(channel); - return(0); - } - *pbase = (tdata_t) retadr[0]; /* starting virtual address */ - /* - * Use the size of the file up to the - * EOF mark for UNIX compatibility. - */ - *psize = (toff_t) size; - /* Record the section in the table */ - map_table[no_mapped].base = retadr[0]; - map_table[no_mapped].top = retadr[1]; - map_table[no_mapped].channel = channel; - no_mapped++; - - return(1); -} - -/* - * This routine unmaps a section from the virtual address space of - * the process, but only if the base was the one returned from a - * call to TIFFMapFileContents. - */ -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ - char *inadr[2]; - int i, j; - - /* Find the section in the table */ - for (i = 0;i < no_mapped; i++) { - if (map_table[i].base == (char *) base) { - /* Unmap the section */ - inadr[0] = (char *) base; - inadr[1] = map_table[i].top; - sys$deltva(inadr, 0, 0); - sys$dassgn(map_table[i].channel); - /* Remove this section from the list */ - for (j = i+1; j < no_mapped; j++) - map_table[j-1] = map_table[j]; - no_mapped--; - return; - } - } -} -#else /* !HAVE_MMAP */ -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - return (0); -} - -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ -} -#endif /* !HAVE_MMAP */ - -/* - * Open a TIFF file descriptor for read/writing. - */ -TIFF* -TIFFFdOpen(int fd, const char* name, const char* mode) -{ - TIFF* tif; - - tif = TIFFClientOpen(name, mode, - (thandle_t) fd, - _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, - _tiffSizeProc, _tiffMapProc, _tiffUnmapProc); - if (tif) - tif->tif_fd = fd; - return (tif); -} - -/* - * Open a TIFF file for read/writing. - */ -TIFF* -TIFFOpen(const char* name, const char* mode) -{ - static const char module[] = "TIFFOpen"; - int m, fd; - - m = _TIFFgetMode(mode, module); - if (m == -1) - return ((TIFF*)0); - if (m&O_TRUNC){ - /* - * There is a bug in open in VAXC. If you use - * open w/ m=O_RDWR|O_CREAT|O_TRUNC the - * wrong thing happens. On the other hand - * creat does the right thing. - */ - fd = creat((char *) /* bug in stdio.h */ name, 0666, - "alq = 128", "deq = 64", "mbc = 32", - "fop = tef"); - } else if (m&O_RDWR) { - fd = open(name, m, 0666, - "deq = 64", "mbc = 32", "fop = tef", "ctx = stm"); - } else - fd = open(name, m, 0666, "mbc = 32", "ctx = stm"); - if (fd < 0) { - TIFFErrorExt(0, module, "%s: Cannot open", name); - return ((TIFF*)0); - } - return (TIFFFdOpen(fd, name, mode)); -} - -tdata_t -_TIFFmalloc(tsize_t s) -{ - return (malloc((size_t) s)); -} - -void -_TIFFfree(tdata_t p) -{ - free(p); -} - -tdata_t -_TIFFrealloc(tdata_t p, tsize_t s) -{ - return (realloc(p, (size_t) s)); -} - -void -_TIFFmemset(tdata_t p, int v, tsize_t c) -{ - memset(p, v, (size_t) c); -} - -void -_TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c) -{ - memcpy(d, s, (size_t) c); -} - -int -_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) -{ - return (memcmp(p1, p2, (size_t) c)); -} - -/* - * On the VAX, we need to make those global, writable pointers - * non-shareable, otherwise they would be made shareable by default. - * On the AXP, this brain damage has been corrected. - * - * I (Karsten Spang, krs@kampsax.dk) have dug around in the GCC - * manual and the GAS code and have come up with the following - * construct, but I don't have GCC on my VAX, so it is untested. - * Please tell me if it does not work. - */ - -static void -vmsWarningHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - fprintf(stderr, "Warning, "); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} - -NOSHARE TIFFErrorHandler _TIFFwarningHandler = vmsWarningHandler -#if defined(VAX) && defined(__GNUC__) -asm("_$$PsectAttributes_NOSHR$$_TIFFwarningHandler") -#endif -; - -static void -vmsErrorHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} - -NOSHARE TIFFErrorHandler _TIFFerrorHandler = vmsErrorHandler -#if defined(VAX) && defined(__GNUC__) -asm("_$$PsectAttributes_NOSHR$$_TIFFerrorHandler") -#endif -; - - -#if !HAVE_IEEEFP -/* IEEE floting point handling */ - -typedef struct ieeedouble { - unsigned long mant2; /* fix NDR: full 8-byte swap */ - unsigned long mant : 20, - exp : 11, - sign : 1; -} ieeedouble; -typedef struct ieeefloat { - unsigned long mant : 23, - exp : 8, - sign : 1; -} ieeefloat; - -/* - * NB: These are D_FLOAT's, not G_FLOAT's. A G_FLOAT is - * simply a reverse-IEEE float/double. - */ - -typedef struct { - unsigned long mant1 : 7, - exp : 8, - sign : 1, - mant2 : 16, - mant3 : 16, - mant4 : 16; -} nativedouble; -typedef struct { - unsigned long mant1 : 7, - exp : 8, - sign : 1, - mant2 : 16; -} nativefloat; - -typedef union { - ieeedouble ieee; - nativedouble native; - char b[8]; - uint32 l[2]; - double d; -} double_t; - -typedef union { - ieeefloat ieee; - nativefloat native; - char b[4]; - uint32 l; - float f; -} float_t; - -#if defined(VAXC) || defined(DECC) -#pragma inline(ieeetod,dtoieee) -#endif - -/* - * Convert an IEEE double precision number to native double precision. - * The source is contained in two longwords, the second holding the sign, - * exponent and the higher order bits of the mantissa, and the first - * holding the rest of the mantissa as follows: - * (Note: It is assumed that the number has been eight-byte swapped to - * LSB first.) - * - * First longword: - * 32 least significant bits of mantissa - * Second longword: - * 0-19: 20 most significant bits of mantissa - * 20-30: exponent - * 31: sign - * The exponent is stored as excess 1023. - * The most significant bit of the mantissa is implied 1, and not stored. - * If the exponent and mantissa are zero, the number is zero. - * If the exponent is 0 (i.e. -1023) and the mantissa is non-zero, it is an - * unnormalized number with the most significant bit NOT implied. - * If the exponent is 2047, the number is invalid, in case the mantissa is zero, - * this means overflow (+/- depending of the sign bit), otherwise - * it simply means invalid number. - * - * If the number is too large for the machine or was specified as overflow, - * +/-HUGE_VAL is returned. - */ -INLINE static void -ieeetod(double *dp) -{ - double_t source; - long sign,exp,mant; - double dmant; - - source.ieee = ((double_t*)dp)->ieee; - sign = source.ieee.sign; - exp = source.ieee.exp; - mant = source.ieee.mant; - - if (exp == 2047) { - if (mant) /* Not a Number (NAN) */ - *dp = HUGE_VAL; - else /* +/- infinity */ - *dp = (sign ? -HUGE_VAL : HUGE_VAL); - return; - } - if (!exp) { - if (!(mant || source.ieee.mant2)) { /* zero */ - *dp=0; - return; - } else { /* Unnormalized number */ - /* NB: not -1023, the 1 bit is not implied */ - exp= -1022; - } - } else { - mant |= 1<<20; - exp -= 1023; - } - dmant = (((double) mant) + - ((double) source.ieee.mant2) / (((double) (1<<16)) * - ((double) (1<<16)))) / (double) (1<<20); - dmant = ldexp(dmant, exp); - if (sign) - dmant= -dmant; - *dp = dmant; -} - -INLINE static void -dtoieee(double *dp) -{ - double_t num; - double x; - int exp; - - num.d = *dp; - if (!num.d) { /* Zero is just binary all zeros */ - num.l[0] = num.l[1] = 0; - return; - } - - if (num.d < 0) { /* Sign is encoded separately */ - num.d = -num.d; - num.ieee.sign = 1; - } else { - num.ieee.sign = 0; - } - - /* Now separate the absolute value into mantissa and exponent */ - x = frexp(num.d, &exp); - - /* - * Handle cases where the value is outside the - * range for IEEE floating point numbers. - * (Overflow cannot happen on a VAX, but underflow - * can happen for G float.) - */ - if (exp < -1022) { /* Unnormalized number */ - x = ldexp(x, -1023-exp); - exp = 0; - } else if (exp > 1023) { /* +/- infinity */ - x = 0; - exp = 2047; - } else { /* Get rid of most significant bit */ - x *= 2; - x -= 1; - exp += 1022; /* fix NDR: 1.0 -> x=0.5, exp=1 -> ieee.exp = 1023 */ - } - num.ieee.exp = exp; - - x *= (double) (1<<20); - num.ieee.mant = (long) x; - x -= (double) num.ieee.mant; - num.ieee.mant2 = (long) (x*((double) (1<<16)*(double) (1<<16))); - - if (!(num.ieee.mant || num.ieee.exp || num.ieee.mant2)) { - /* Avoid negative zero */ - num.ieee.sign = 0; - } - ((double_t*)dp)->ieee = num.ieee; -} - -/* - * Beware, these do not handle over/under-flow - * during conversion from ieee to native format. - */ -#define NATIVE2IEEEFLOAT(fp) { \ - float_t t; \ - if (t.ieee.exp = (fp)->native.exp) \ - t.ieee.exp += -129 + 127; \ - t.ieee.sign = (fp)->native.sign; \ - t.ieee.mant = ((fp)->native.mant1<<16)|(fp)->native.mant2; \ - *(fp) = t; \ -} -#define IEEEFLOAT2NATIVE(fp) { \ - float_t t; int v = (fp)->ieee.exp; \ - if (v) v += -127 + 129; /* alter bias of exponent */\ - t.native.exp = v; /* implicit truncation of exponent */\ - t.native.sign = (fp)->ieee.sign; \ - v = (fp)->ieee.mant; \ - t.native.mant1 = v >> 16; \ - t.native.mant2 = v;\ - *(fp) = t; \ -} - -#define IEEEDOUBLE2NATIVE(dp) ieeetod(dp) - -#define NATIVE2IEEEDOUBLE(dp) dtoieee(dp) - - -/* - * These unions are used during floating point - * conversions. The above macros define the - * conversion operations. - */ -void -TIFFCvtIEEEFloatToNative(TIFF* tif, u_int n, float* f) -{ - float_t* fp = (float_t*) f; - - while (n-- > 0) { - IEEEFLOAT2NATIVE(fp); - fp++; - } -} - -void -TIFFCvtNativeToIEEEFloat(TIFF* tif, u_int n, float* f) -{ - float_t* fp = (float_t*) f; - - while (n-- > 0) { - NATIVE2IEEEFLOAT(fp); - fp++; - } -} -void -TIFFCvtIEEEDoubleToNative(TIFF* tif, u_int n, double* f) -{ - double_t* fp = (double_t*) f; - - while (n-- > 0) { - IEEEDOUBLE2NATIVE(fp); - fp++; - } -} - -void -TIFFCvtNativeToIEEEDouble(TIFF* tif, u_int n, double* f) -{ - double_t* fp = (double_t*) f; - - while (n-- > 0) { - NATIVE2IEEEDOUBLE(fp); - fp++; - } -} -#endif -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_warning.c b/plugins/AdvaImg/src/LibTIFF/tif_warning.c deleted file mode 100644 index a2dbbe7e2f..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_warning.c +++ /dev/null @@ -1,81 +0,0 @@ -/* $Header: /cvsroot/freeimage/FreeImage/Source/LibTIFF/tif_warning.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - */ -#include "tiffiop.h" - -TIFFErrorHandlerExt _TIFFwarningHandlerExt = NULL; - -TIFFErrorHandler -TIFFSetWarningHandler(TIFFErrorHandler handler) -{ - TIFFErrorHandler prev = _TIFFwarningHandler; - _TIFFwarningHandler = handler; - return (prev); -} - -TIFFErrorHandlerExt -TIFFSetWarningHandlerExt(TIFFErrorHandlerExt handler) -{ - TIFFErrorHandlerExt prev = _TIFFwarningHandlerExt; - _TIFFwarningHandlerExt = handler; - return (prev); -} - -void -TIFFWarning(const char* module, const char* fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - if (_TIFFwarningHandler) - (*_TIFFwarningHandler)(module, fmt, ap); - if (_TIFFwarningHandlerExt) - (*_TIFFwarningHandlerExt)(0, module, fmt, ap); - va_end(ap); -} - -void -TIFFWarningExt(thandle_t fd, const char* module, const char* fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - if (_TIFFwarningHandler) - (*_TIFFwarningHandler)(module, fmt, ap); - if (_TIFFwarningHandlerExt) - (*_TIFFwarningHandlerExt)(fd, module, fmt, ap); - va_end(ap); -} - - -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_win3.c b/plugins/AdvaImg/src/LibTIFF/tif_win3.c deleted file mode 100644 index aa21e3aef8..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_win3.c +++ /dev/null @@ -1,232 +0,0 @@ -/* $Header: /cvsroot/freeimage/FreeImage/Source/LibTIFF/tif_win3.c,v 1.35 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library Windows 3.x-specific Routines. - */ -#include "tiffiop.h" -#if defined(__WATCOMC__) || defined(__BORLANDC__) || defined(_MSC_VER) -#include /* for open, close, etc. function prototypes */ -#endif - -#include -#include -#include - -static tsize_t -_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return (_hread(fd, buf, size)); -} - -static tsize_t -_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return (_hwrite(fd, buf, size)); -} - -static toff_t -_tiffSeekProc(thandle_t fd, toff_t off, int whence) -{ - return (_llseek(fd, (off_t) off, whence)); -} - -static int -_tiffCloseProc(thandle_t fd) -{ - return (_lclose(fd)); -} - -#include - -static toff_t -_tiffSizeProc(thandle_t fd) -{ - struct stat sb; - return (fstat((int) fd, &sb) < 0 ? 0 : sb.st_size); -} - -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - return (0); -} - -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ -} - -/* - * Open a TIFF file descriptor for read/writing. - */ -TIFF* -TIFFFdOpen(int fd, const char* name, const char* mode) -{ - TIFF* tif; - - tif = TIFFClientOpen(name, mode, - (thandle_t) fd, - _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, - _tiffSizeProc, _tiffMapProc, _tiffUnmapProc); - if (tif) - tif->tif_fd = fd; - return (tif); -} - -/* - * Open a TIFF file for read/writing. - */ -TIFF* -TIFFOpen(const char* name, const char* mode) -{ - static const char module[] = "TIFFOpen"; - int m, fd; - OFSTRUCT of; - int mm = 0; - - m = _TIFFgetMode(mode, module); - if (m == -1) - return ((TIFF*)0); - if (m & O_CREAT) { - if ((m & O_TRUNC) || OpenFile(name, &of, OF_EXIST) != HFILE_ERROR) - mm |= OF_CREATE; - } - if (m & O_WRONLY) - mm |= OF_WRITE; - if (m & O_RDWR) - mm |= OF_READWRITE; - fd = OpenFile(name, &of, mm); - if (fd < 0) { - TIFFErrorExt(0, module, "%s: Cannot open", name); - return ((TIFF*)0); - } - return (TIFFFdOpen(fd, name, mode)); -} - -tdata_t -_TIFFmalloc(tsize_t s) -{ - return (tdata_t) GlobalAllocPtr(GHND, (DWORD) s); -} - -void -_TIFFfree(tdata_t p) -{ - GlobalFreePtr(p); -} - -tdata_t -_TIFFrealloc(tdata_t p, tsize_t s) -{ - return (tdata_t) GlobalReAllocPtr(p, (DWORD) s, GHND); -} - -void -_TIFFmemset(tdata_t p, int v, tsize_t c) -{ - char* pp = (char*) p; - - while (c > 0) { - tsize_t chunk = 0x10000 - ((uint32) pp & 0xffff);/* What's left in segment */ - if (chunk > 0xff00) /* No more than 0xff00 */ - chunk = 0xff00; - if (chunk > c) /* No more than needed */ - chunk = c; - memset(pp, v, chunk); - pp = (char*) (chunk + (char huge*) pp); - c -= chunk; - } -} - -void -_TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c) -{ - if (c > 0xFFFF) - hmemcpy((void _huge*) d, (void _huge*) s, c); - else - (void) memcpy(d, s, (size_t) c); -} - -int -_TIFFmemcmp(const tdata_t d, const tdata_t s, tsize_t c) -{ - char* dd = (char*) d; - char* ss = (char*) s; - tsize_t chunks, chunkd, chunk; - int result; - - while (c > 0) { - chunks = 0x10000 - ((uint32) ss & 0xffff); /* What's left in segment */ - chunkd = 0x10000 - ((uint32) dd & 0xffff); /* What's left in segment */ - chunk = c; /* Get the largest of */ - if (chunk > chunks) /* c, chunks, chunkd, */ - chunk = chunks; /* 0xff00 */ - if (chunk > chunkd) - chunk = chunkd; - if (chunk > 0xff00) - chunk = 0xff00; - result = memcmp(dd, ss, chunk); - if (result != 0) - return (result); - dd = (char*) (chunk + (char huge*) dd); - ss = (char*) (chunk + (char huge*) ss); - c -= chunk; - } - return (0); -} - -static void -win3WarningHandler(const char* module, const char* fmt, va_list ap) -{ - char e[512] = { '\0' }; - if (module != NULL) - strcat(strcpy(e, module), ":"); - vsprintf(e+strlen(e), fmt, ap); - strcat(e, "."); - MessageBox(GetActiveWindow(), e, "LibTIFF Warning", - MB_OK|MB_ICONEXCLAMATION); -} -TIFFErrorHandler _TIFFwarningHandler = win3WarningHandler; - -static void -win3ErrorHandler(const char* module, const char* fmt, va_list ap) -{ - char e[512] = { '\0' }; - if (module != NULL) - strcat(strcpy(e, module), ":"); - vsprintf(e+strlen(e), fmt, ap); - strcat(e, "."); - MessageBox(GetActiveWindow(), e, "LibTIFF Error", MB_OK|MB_ICONSTOP); -} -TIFFErrorHandler _TIFFerrorHandler = win3ErrorHandler; -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_win32.c b/plugins/AdvaImg/src/LibTIFF/tif_win32.c deleted file mode 100644 index 5b3875901d..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_win32.c +++ /dev/null @@ -1,408 +0,0 @@ -/* $Id: tif_win32.c,v 1.35 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library Win32-specific Routines. Adapted from tif_unix.c 4/5/95 by - * Scott Wagner (wagner@itek.com), Itek Graphix, Rochester, NY USA - */ -#include "tiffiop.h" - -#include - -static tsize_t -_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - DWORD dwSizeRead; - if (!ReadFile(fd, buf, size, &dwSizeRead, NULL)) - return(0); - return ((tsize_t) dwSizeRead); -} - -static tsize_t -_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - DWORD dwSizeWritten; - if (!WriteFile(fd, buf, size, &dwSizeWritten, NULL)) - return(0); - return ((tsize_t) dwSizeWritten); -} - -static toff_t -_tiffSeekProc(thandle_t fd, toff_t off, int whence) -{ - ULARGE_INTEGER li; - DWORD dwMoveMethod; - - li.QuadPart = off; - - switch(whence) - { - case SEEK_SET: - dwMoveMethod = FILE_BEGIN; - break; - case SEEK_CUR: - dwMoveMethod = FILE_CURRENT; - break; - case SEEK_END: - dwMoveMethod = FILE_END; - break; - default: - dwMoveMethod = FILE_BEGIN; - break; - } - return ((toff_t)SetFilePointer(fd, (LONG) li.LowPart, - (PLONG)&li.HighPart, dwMoveMethod)); -} - -static int -_tiffCloseProc(thandle_t fd) -{ - return (CloseHandle(fd) ? 0 : -1); -} - -static toff_t -_tiffSizeProc(thandle_t fd) -{ - return ((toff_t)GetFileSize(fd, NULL)); -} - -static int -_tiffDummyMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - (void) fd; - (void) pbase; - (void) psize; - return (0); -} - -/* - * From "Hermann Josef Hill" : - * - * Windows uses both a handle and a pointer for file mapping, - * but according to the SDK documentation and Richter's book - * "Advanced Windows Programming" it is safe to free the handle - * after obtaining the file mapping pointer - * - * This removes a nasty OS dependency and cures a problem - * with Visual C++ 5.0 - */ -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - toff_t size; - HANDLE hMapFile; - - if ((size = _tiffSizeProc(fd)) == 0xFFFFFFFF) - return (0); - hMapFile = CreateFileMapping(fd, NULL, PAGE_READONLY, 0, size, NULL); - if (hMapFile == NULL) - return (0); - *pbase = MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0); - CloseHandle(hMapFile); - if (*pbase == NULL) - return (0); - *psize = size; - return(1); -} - -static void -_tiffDummyUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ - (void) fd; - (void) base; - (void) size; -} - -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ - UnmapViewOfFile(base); -} - -/* - * Open a TIFF file descriptor for read/writing. - * Note that TIFFFdOpen and TIFFOpen recognise the character 'u' in the mode - * string, which forces the file to be opened unmapped. - */ -TIFF* -TIFFFdOpen(int ifd, const char* name, const char* mode) -{ - TIFF* tif; - BOOL fSuppressMap = (mode[1] == 'u' || (mode[1]!=0 && mode[2] == 'u')); - - tif = TIFFClientOpen(name, mode, (thandle_t)ifd, - _tiffReadProc, _tiffWriteProc, - _tiffSeekProc, _tiffCloseProc, _tiffSizeProc, - fSuppressMap ? _tiffDummyMapProc : _tiffMapProc, - fSuppressMap ? _tiffDummyUnmapProc : _tiffUnmapProc); - if (tif) - tif->tif_fd = ifd; - return (tif); -} - -#ifndef _WIN32_WCE - -/* - * Open a TIFF file for read/writing. - */ -TIFF* -TIFFOpen(const char* name, const char* mode) -{ - static const char module[] = "TIFFOpen"; - thandle_t fd; - int m; - DWORD dwMode; - TIFF* tif; - - m = _TIFFgetMode(mode, module); - - switch(m) - { - case O_RDONLY: - dwMode = OPEN_EXISTING; - break; - case O_RDWR: - dwMode = OPEN_ALWAYS; - break; - case O_RDWR|O_CREAT: - dwMode = OPEN_ALWAYS; - break; - case O_RDWR|O_TRUNC: - dwMode = CREATE_ALWAYS; - break; - case O_RDWR|O_CREAT|O_TRUNC: - dwMode = CREATE_ALWAYS; - break; - default: - return ((TIFF*)0); - } - fd = (thandle_t)CreateFileA(name, - (m == O_RDONLY)?GENERIC_READ:(GENERIC_READ | GENERIC_WRITE), - FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, dwMode, - (m == O_RDONLY)?FILE_ATTRIBUTE_READONLY:FILE_ATTRIBUTE_NORMAL, - NULL); - if (fd == INVALID_HANDLE_VALUE) { - TIFFErrorExt(0, module, "%s: Cannot open", name); - return ((TIFF *)0); - } - - tif = TIFFFdOpen((int)fd, name, mode); - if (!tif) - CloseHandle(fd); - return tif; -} - -/* - * Open a TIFF file with a Unicode filename, for read/writing. - */ -TIFF* -TIFFOpenW(const wchar_t* name, const char* mode) -{ - static const char module[] = "TIFFOpenW"; - thandle_t fd; - int m; - DWORD dwMode; - int mbsize; - char *mbname; - TIFF *tif; - - m = _TIFFgetMode(mode, module); - - switch(m) { - case O_RDONLY: dwMode = OPEN_EXISTING; break; - case O_RDWR: dwMode = OPEN_ALWAYS; break; - case O_RDWR|O_CREAT: dwMode = OPEN_ALWAYS; break; - case O_RDWR|O_TRUNC: dwMode = CREATE_ALWAYS; break; - case O_RDWR|O_CREAT|O_TRUNC: dwMode = CREATE_ALWAYS; break; - default: return ((TIFF*)0); - } - - fd = (thandle_t)CreateFileW(name, - (m == O_RDONLY)?GENERIC_READ:(GENERIC_READ|GENERIC_WRITE), - FILE_SHARE_READ, NULL, dwMode, - (m == O_RDONLY)?FILE_ATTRIBUTE_READONLY:FILE_ATTRIBUTE_NORMAL, - NULL); - if (fd == INVALID_HANDLE_VALUE) { - TIFFErrorExt(0, module, "%S: Cannot open", name); - return ((TIFF *)0); - } - - mbname = NULL; - mbsize = WideCharToMultiByte(CP_ACP, 0, name, -1, NULL, 0, NULL, NULL); - if (mbsize > 0) { - mbname = (char *)_TIFFmalloc(mbsize); - if (!mbname) { - TIFFErrorExt(0, module, - "Can't allocate space for filename conversion buffer"); - return ((TIFF*)0); - } - - WideCharToMultiByte(CP_ACP, 0, name, -1, mbname, mbsize, - NULL, NULL); - } - - tif = TIFFFdOpen((int)fd, - (mbname != NULL) ? mbname : "", mode); - if (!tif) - CloseHandle(fd); - - _TIFFfree(mbname); - - return tif; -} - -#endif /* ndef _WIN32_WCE */ - - -tdata_t -_TIFFmalloc(tsize_t s) -{ - return ((tdata_t)GlobalAlloc(GMEM_FIXED, s)); -} - -void -_TIFFfree(tdata_t p) -{ - GlobalFree(p); - return; -} - -tdata_t -_TIFFrealloc(tdata_t p, tsize_t s) -{ - void* pvTmp; - tsize_t old; - - if(p == NULL) - return ((tdata_t)GlobalAlloc(GMEM_FIXED, s)); - - old = GlobalSize(p); - - if (old>=s) { - if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) != NULL) { - CopyMemory(pvTmp, p, s); - GlobalFree(p); - } - } else { - if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) != NULL) { - CopyMemory(pvTmp, p, old); - GlobalFree(p); - } - } - return ((tdata_t)pvTmp); -} - -void -_TIFFmemset(void* p, int v, tsize_t c) -{ - FillMemory(p, c, (BYTE)v); -} - -void -_TIFFmemcpy(void* d, const tdata_t s, tsize_t c) -{ - CopyMemory(d, s, c); -} - -int -_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) -{ - register const BYTE *pb1 = (const BYTE *) p1; - register const BYTE *pb2 = (const BYTE *) p2; - register DWORD dwTmp = c; - register int iTmp; - for (iTmp = 0; dwTmp-- && !iTmp; iTmp = (int)*pb1++ - (int)*pb2++) - ; - return (iTmp); -} - -#ifndef _WIN32_WCE - -static void -Win32WarningHandler(const char* module, const char* fmt, va_list ap) -{ -#ifndef TIF_PLATFORM_CONSOLE - LPTSTR szTitle; - LPTSTR szTmp; - LPCTSTR szTitleText = "%s Warning"; - LPCTSTR szDefaultModule = "LIBTIFF"; - LPCTSTR szTmpModule = (module == NULL) ? szDefaultModule : module; - if ((szTitle = (LPTSTR)LocalAlloc(LMEM_FIXED, (strlen(szTmpModule) + - strlen(szTitleText) + strlen(fmt) + 128)*sizeof(char))) == NULL) - return; - sprintf(szTitle, szTitleText, szTmpModule); - szTmp = szTitle + (strlen(szTitle)+2)*sizeof(char); - vsprintf(szTmp, fmt, ap); - MessageBoxA(GetFocus(), szTmp, szTitle, MB_OK | MB_ICONINFORMATION); - LocalFree(szTitle); - return; -#else - if (module != NULL) - fprintf(stderr, "%s: ", module); - fprintf(stderr, "Warning, "); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -#endif -} -TIFFErrorHandler _TIFFwarningHandler = Win32WarningHandler; - -static void -Win32ErrorHandler(const char* module, const char* fmt, va_list ap) -{ -#ifndef TIF_PLATFORM_CONSOLE - LPTSTR szTitle; - LPTSTR szTmp; - LPCTSTR szTitleText = "%s Error"; - LPCTSTR szDefaultModule = "LIBTIFF"; - LPCTSTR szTmpModule = (module == NULL) ? szDefaultModule : module; - if ((szTitle = (LPTSTR)LocalAlloc(LMEM_FIXED, (strlen(szTmpModule) + - strlen(szTitleText) + strlen(fmt) + 128)*sizeof(char))) == NULL) - return; - sprintf(szTitle, szTitleText, szTmpModule); - szTmp = szTitle + (strlen(szTitle)+2)*sizeof(char); - vsprintf(szTmp, fmt, ap); - MessageBoxA(GetFocus(), szTmp, szTitle, MB_OK | MB_ICONEXCLAMATION); - LocalFree(szTitle); - return; -#else - if (module != NULL) - fprintf(stderr, "%s: ", module); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -#endif -} -TIFFErrorHandler _TIFFerrorHandler = Win32ErrorHandler; - -#endif /* ndef _WIN32_WCE */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_write.c b/plugins/AdvaImg/src/LibTIFF/tif_write.c deleted file mode 100644 index 043e645b87..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_write.c +++ /dev/null @@ -1,718 +0,0 @@ -/* $Id: tif_write.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Scanline-oriented Write Support - */ -#include "tiffiop.h" -#include - -#define STRIPINCR 20 /* expansion factor on strip array */ - -#define WRITECHECKSTRIPS(tif, module) \ - (((tif)->tif_flags&TIFF_BEENWRITING) || TIFFWriteCheck((tif),0,module)) -#define WRITECHECKTILES(tif, module) \ - (((tif)->tif_flags&TIFF_BEENWRITING) || TIFFWriteCheck((tif),1,module)) -#define BUFFERCHECK(tif) \ - ((((tif)->tif_flags & TIFF_BUFFERSETUP) && tif->tif_rawdata) || \ - TIFFWriteBufferSetup((tif), NULL, (tsize_t) -1)) - -static int TIFFGrowStrips(TIFF*, int, const char*); -static int TIFFAppendToStrip(TIFF*, tstrip_t, tidata_t, tsize_t); - -int -TIFFWriteScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample) -{ - static const char module[] = "TIFFWriteScanline"; - register TIFFDirectory *td; - int status, imagegrew = 0; - tstrip_t strip; - - if (!WRITECHECKSTRIPS(tif, module)) - return (-1); - /* - * Handle delayed allocation of data buffer. This - * permits it to be sized more intelligently (using - * directory information). - */ - if (!BUFFERCHECK(tif)) - return (-1); - td = &tif->tif_dir; - /* - * Extend image length if needed - * (but only for PlanarConfig=1). - */ - if (row >= td->td_imagelength) { /* extend image */ - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Can not change \"ImageLength\" when using separate planes"); - return (-1); - } - td->td_imagelength = row+1; - imagegrew = 1; - } - /* - * Calculate strip and check for crossings. - */ - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { - if (sample >= td->td_samplesperpixel) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%d: Sample out of range, max %d", - sample, td->td_samplesperpixel); - return (-1); - } - strip = sample*td->td_stripsperimage + row/td->td_rowsperstrip; - } else - strip = row / td->td_rowsperstrip; - /* - * Check strip array to make sure there's space. We don't support - * dynamically growing files that have data organized in separate - * bitplanes because it's too painful. In that case we require that - * the imagelength be set properly before the first write (so that the - * strips array will be fully allocated above). - */ - if (strip >= td->td_nstrips && !TIFFGrowStrips(tif, 1, module)) - return (-1); - if (strip != tif->tif_curstrip) { - /* - * Changing strips -- flush any data present. - */ - if (!TIFFFlushData(tif)) - return (-1); - tif->tif_curstrip = strip; - /* - * Watch out for a growing image. The value of strips/image - * will initially be 1 (since it can't be deduced until the - * imagelength is known). - */ - if (strip >= td->td_stripsperimage && imagegrew) - td->td_stripsperimage = - TIFFhowmany(td->td_imagelength,td->td_rowsperstrip); - tif->tif_row = - (strip % td->td_stripsperimage) * td->td_rowsperstrip; - if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { - if (!(*tif->tif_setupencode)(tif)) - return (-1); - tif->tif_flags |= TIFF_CODERSETUP; - } - - tif->tif_rawcc = 0; - tif->tif_rawcp = tif->tif_rawdata; - - if ( td->td_stripbytecount[strip] > 0 ) - { - /* if we are writing over existing tiles, zero length */ - td->td_stripbytecount[strip] = 0; - - /* this forces TIFFAppendToStrip() to do a seek */ - tif->tif_curoff = 0; - } - - if (!(*tif->tif_preencode)(tif, sample)) - return (-1); - tif->tif_flags |= TIFF_POSTENCODE; - } - /* - * Ensure the write is either sequential or at the - * beginning of a strip (or that we can randomly - * access the data -- i.e. no encoding). - */ - if (row != tif->tif_row) { - if (row < tif->tif_row) { - /* - * Moving backwards within the same strip: - * backup to the start and then decode - * forward (below). - */ - tif->tif_row = (strip % td->td_stripsperimage) * - td->td_rowsperstrip; - tif->tif_rawcp = tif->tif_rawdata; - } - /* - * Seek forward to the desired row. - */ - if (!(*tif->tif_seek)(tif, row - tif->tif_row)) - return (-1); - tif->tif_row = row; - } - - /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode( tif, (tidata_t) buf, tif->tif_scanlinesize ); - - status = (*tif->tif_encoderow)(tif, (tidata_t) buf, - tif->tif_scanlinesize, sample); - - /* we are now poised at the beginning of the next row */ - tif->tif_row = row + 1; - return (status); -} - -/* - * Encode the supplied data and write it to the - * specified strip. - * - * NB: Image length must be setup before writing. - */ -tsize_t -TIFFWriteEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t data, tsize_t cc) -{ - static const char module[] = "TIFFWriteEncodedStrip"; - TIFFDirectory *td = &tif->tif_dir; - tsample_t sample; - - if (!WRITECHECKSTRIPS(tif, module)) - return ((tsize_t) -1); - /* - * Check strip array to make sure there's space. - * We don't support dynamically growing files that - * have data organized in separate bitplanes because - * it's too painful. In that case we require that - * the imagelength be set properly before the first - * write (so that the strips array will be fully - * allocated above). - */ - if (strip >= td->td_nstrips) { - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Can not grow image by strips when using separate planes"); - return ((tsize_t) -1); - } - if (!TIFFGrowStrips(tif, 1, module)) - return ((tsize_t) -1); - td->td_stripsperimage = - TIFFhowmany(td->td_imagelength, td->td_rowsperstrip); - } - /* - * Handle delayed allocation of data buffer. This - * permits it to be sized according to the directory - * info. - */ - if (!BUFFERCHECK(tif)) - return ((tsize_t) -1); - tif->tif_curstrip = strip; - tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; - if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { - if (!(*tif->tif_setupencode)(tif)) - return ((tsize_t) -1); - tif->tif_flags |= TIFF_CODERSETUP; - } - - tif->tif_rawcc = 0; - tif->tif_rawcp = tif->tif_rawdata; - - if ( td->td_stripbytecount[strip] > 0 ) - { - /* Force TIFFAppendToStrip() to consider placing data at end - of file. */ - tif->tif_curoff = 0; - } - - tif->tif_flags &= ~TIFF_POSTENCODE; - sample = (tsample_t)(strip / td->td_stripsperimage); - if (!(*tif->tif_preencode)(tif, sample)) - return ((tsize_t) -1); - - /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode( tif, (tidata_t) data, cc ); - - if (!(*tif->tif_encodestrip)(tif, (tidata_t) data, cc, sample)) - return ((tsize_t) 0); - if (!(*tif->tif_postencode)(tif)) - return ((tsize_t) -1); - if (!isFillOrder(tif, td->td_fillorder) && - (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits(tif->tif_rawdata, tif->tif_rawcc); - if (tif->tif_rawcc > 0 && - !TIFFAppendToStrip(tif, strip, tif->tif_rawdata, tif->tif_rawcc)) - return ((tsize_t) -1); - tif->tif_rawcc = 0; - tif->tif_rawcp = tif->tif_rawdata; - return (cc); -} - -/* - * Write the supplied data to the specified strip. - * - * NB: Image length must be setup before writing. - */ -tsize_t -TIFFWriteRawStrip(TIFF* tif, tstrip_t strip, tdata_t data, tsize_t cc) -{ - static const char module[] = "TIFFWriteRawStrip"; - TIFFDirectory *td = &tif->tif_dir; - - if (!WRITECHECKSTRIPS(tif, module)) - return ((tsize_t) -1); - /* - * Check strip array to make sure there's space. - * We don't support dynamically growing files that - * have data organized in separate bitplanes because - * it's too painful. In that case we require that - * the imagelength be set properly before the first - * write (so that the strips array will be fully - * allocated above). - */ - if (strip >= td->td_nstrips) { - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Can not grow image by strips when using separate planes"); - return ((tsize_t) -1); - } - /* - * Watch out for a growing image. The value of - * strips/image will initially be 1 (since it - * can't be deduced until the imagelength is known). - */ - if (strip >= td->td_stripsperimage) - td->td_stripsperimage = - TIFFhowmany(td->td_imagelength,td->td_rowsperstrip); - if (!TIFFGrowStrips(tif, 1, module)) - return ((tsize_t) -1); - } - tif->tif_curstrip = strip; - tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; - return (TIFFAppendToStrip(tif, strip, (tidata_t) data, cc) ? - cc : (tsize_t) -1); -} - -/* - * Write and compress a tile of data. The - * tile is selected by the (x,y,z,s) coordinates. - */ -tsize_t -TIFFWriteTile(TIFF* tif, - tdata_t buf, uint32 x, uint32 y, uint32 z, tsample_t s) -{ - if (!TIFFCheckTile(tif, x, y, z, s)) - return (-1); - /* - * NB: A tile size of -1 is used instead of tif_tilesize knowing - * that TIFFWriteEncodedTile will clamp this to the tile size. - * This is done because the tile size may not be defined until - * after the output buffer is setup in TIFFWriteBufferSetup. - */ - return (TIFFWriteEncodedTile(tif, - TIFFComputeTile(tif, x, y, z, s), buf, (tsize_t) -1)); -} - -/* - * Encode the supplied data and write it to the - * specified tile. There must be space for the - * data. The function clamps individual writes - * to a tile to the tile size, but does not (and - * can not) check that multiple writes to the same - * tile do not write more than tile size data. - * - * NB: Image length must be setup before writing; this - * interface does not support automatically growing - * the image on each write (as TIFFWriteScanline does). - */ -tsize_t -TIFFWriteEncodedTile(TIFF* tif, ttile_t tile, tdata_t data, tsize_t cc) -{ - static const char module[] = "TIFFWriteEncodedTile"; - TIFFDirectory *td; - tsample_t sample; - - if (!WRITECHECKTILES(tif, module)) - return ((tsize_t) -1); - td = &tif->tif_dir; - if (tile >= td->td_nstrips) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: Tile %lu out of range, max %lu", - tif->tif_name, (unsigned long) tile, (unsigned long) td->td_nstrips); - return ((tsize_t) -1); - } - /* - * Handle delayed allocation of data buffer. This - * permits it to be sized more intelligently (using - * directory information). - */ - if (!BUFFERCHECK(tif)) - return ((tsize_t) -1); - tif->tif_curtile = tile; - - tif->tif_rawcc = 0; - tif->tif_rawcp = tif->tif_rawdata; - - if ( td->td_stripbytecount[tile] > 0 ) - { - /* Force TIFFAppendToStrip() to consider placing data at end - of file. */ - tif->tif_curoff = 0; - } - - /* - * Compute tiles per row & per column to compute - * current row and column - */ - tif->tif_row = (tile % TIFFhowmany(td->td_imagelength, td->td_tilelength)) - * td->td_tilelength; - tif->tif_col = (tile % TIFFhowmany(td->td_imagewidth, td->td_tilewidth)) - * td->td_tilewidth; - - if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { - if (!(*tif->tif_setupencode)(tif)) - return ((tsize_t) -1); - tif->tif_flags |= TIFF_CODERSETUP; - } - tif->tif_flags &= ~TIFF_POSTENCODE; - sample = (tsample_t)(tile/td->td_stripsperimage); - if (!(*tif->tif_preencode)(tif, sample)) - return ((tsize_t) -1); - /* - * Clamp write amount to the tile size. This is mostly - * done so that callers can pass in some large number - * (e.g. -1) and have the tile size used instead. - */ - if ( cc < 1 || cc > tif->tif_tilesize) - cc = tif->tif_tilesize; - - /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode( tif, (tidata_t) data, cc ); - - if (!(*tif->tif_encodetile)(tif, (tidata_t) data, cc, sample)) - return ((tsize_t) 0); - if (!(*tif->tif_postencode)(tif)) - return ((tsize_t) -1); - if (!isFillOrder(tif, td->td_fillorder) && - (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits((unsigned char *)tif->tif_rawdata, tif->tif_rawcc); - if (tif->tif_rawcc > 0 && !TIFFAppendToStrip(tif, tile, - tif->tif_rawdata, tif->tif_rawcc)) - return ((tsize_t) -1); - tif->tif_rawcc = 0; - tif->tif_rawcp = tif->tif_rawdata; - return (cc); -} - -/* - * Write the supplied data to the specified strip. - * There must be space for the data; we don't check - * if strips overlap! - * - * NB: Image length must be setup before writing; this - * interface does not support automatically growing - * the image on each write (as TIFFWriteScanline does). - */ -tsize_t -TIFFWriteRawTile(TIFF* tif, ttile_t tile, tdata_t data, tsize_t cc) -{ - static const char module[] = "TIFFWriteRawTile"; - - if (!WRITECHECKTILES(tif, module)) - return ((tsize_t) -1); - if (tile >= tif->tif_dir.td_nstrips) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: Tile %lu out of range, max %lu", - tif->tif_name, (unsigned long) tile, - (unsigned long) tif->tif_dir.td_nstrips); - return ((tsize_t) -1); - } - return (TIFFAppendToStrip(tif, tile, (tidata_t) data, cc) ? - cc : (tsize_t) -1); -} - -#define isUnspecified(tif, f) \ - (TIFFFieldSet(tif,f) && (tif)->tif_dir.td_imagelength == 0) - -int -TIFFSetupStrips(TIFF* tif) -{ - TIFFDirectory* td = &tif->tif_dir; - - if (isTiled(tif)) - td->td_stripsperimage = - isUnspecified(tif, FIELD_TILEDIMENSIONS) ? - td->td_samplesperpixel : TIFFNumberOfTiles(tif); - else - td->td_stripsperimage = - isUnspecified(tif, FIELD_ROWSPERSTRIP) ? - td->td_samplesperpixel : TIFFNumberOfStrips(tif); - td->td_nstrips = td->td_stripsperimage; - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - td->td_stripsperimage /= td->td_samplesperpixel; - td->td_stripoffset = (uint32 *) - _TIFFmalloc(td->td_nstrips * sizeof (uint32)); - td->td_stripbytecount = (uint32 *) - _TIFFmalloc(td->td_nstrips * sizeof (uint32)); - if (td->td_stripoffset == NULL || td->td_stripbytecount == NULL) - return (0); - /* - * Place data at the end-of-file - * (by setting offsets to zero). - */ - _TIFFmemset(td->td_stripoffset, 0, td->td_nstrips*sizeof (uint32)); - _TIFFmemset(td->td_stripbytecount, 0, td->td_nstrips*sizeof (uint32)); - TIFFSetFieldBit(tif, FIELD_STRIPOFFSETS); - TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS); - return (1); -} -#undef isUnspecified - -/* - * Verify file is writable and that the directory - * information is setup properly. In doing the latter - * we also "freeze" the state of the directory so - * that important information is not changed. - */ -int -TIFFWriteCheck(TIFF* tif, int tiles, const char* module) -{ - if (tif->tif_mode == O_RDONLY) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: File not open for writing", - tif->tif_name); - return (0); - } - if (tiles ^ isTiled(tif)) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, tiles ? - "Can not write tiles to a stripped image" : - "Can not write scanlines to a tiled image"); - return (0); - } - - /* - * On the first write verify all the required information - * has been setup and initialize any data structures that - * had to wait until directory information was set. - * Note that a lot of our work is assumed to remain valid - * because we disallow any of the important parameters - * from changing after we start writing (i.e. once - * TIFF_BEENWRITING is set, TIFFSetField will only allow - * the image's length to be changed). - */ - if (!TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS)) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Must set \"ImageWidth\" before writing data", - tif->tif_name); - return (0); - } - if (tif->tif_dir.td_samplesperpixel == 1) { - /* - * Planarconfiguration is irrelevant in case of single band - * images and need not be included. We will set it anyway, - * because this field is used in other parts of library even - * in the single band case. - */ - if (!TIFFFieldSet(tif, FIELD_PLANARCONFIG)) - tif->tif_dir.td_planarconfig = PLANARCONFIG_CONTIG; - } else { - if (!TIFFFieldSet(tif, FIELD_PLANARCONFIG)) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Must set \"PlanarConfiguration\" before writing data", - tif->tif_name); - return (0); - } - } - if (tif->tif_dir.td_stripoffset == NULL && !TIFFSetupStrips(tif)) { - tif->tif_dir.td_nstrips = 0; - TIFFErrorExt(tif->tif_clientdata, module, "%s: No space for %s arrays", - tif->tif_name, isTiled(tif) ? "tile" : "strip"); - return (0); - } - tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tsize_t) -1; - tif->tif_scanlinesize = TIFFScanlineSize(tif); - tif->tif_flags |= TIFF_BEENWRITING; - return (1); -} - -/* - * Setup the raw data buffer used for encoding. - */ -int -TIFFWriteBufferSetup(TIFF* tif, tdata_t bp, tsize_t size) -{ - static const char module[] = "TIFFWriteBufferSetup"; - - if (tif->tif_rawdata) { - if (tif->tif_flags & TIFF_MYBUFFER) { - _TIFFfree(tif->tif_rawdata); - tif->tif_flags &= ~TIFF_MYBUFFER; - } - tif->tif_rawdata = NULL; - } - if (size == (tsize_t) -1) { - size = (isTiled(tif) ? - tif->tif_tilesize : TIFFStripSize(tif)); - /* - * Make raw data buffer at least 8K - */ - if (size < 8*1024) - size = 8*1024; - bp = NULL; /* NB: force malloc */ - } - if (bp == NULL) { - bp = _TIFFmalloc(size); - if (bp == NULL) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: No space for output buffer", - tif->tif_name); - return (0); - } - tif->tif_flags |= TIFF_MYBUFFER; - } else - tif->tif_flags &= ~TIFF_MYBUFFER; - tif->tif_rawdata = (tidata_t) bp; - tif->tif_rawdatasize = size; - tif->tif_rawcc = 0; - tif->tif_rawcp = tif->tif_rawdata; - tif->tif_flags |= TIFF_BUFFERSETUP; - return (1); -} - -/* - * Grow the strip data structures by delta strips. - */ -static int -TIFFGrowStrips(TIFF* tif, int delta, const char* module) -{ - TIFFDirectory *td = &tif->tif_dir; - uint32 *new_stripoffset, *new_stripbytecount; - - assert(td->td_planarconfig == PLANARCONFIG_CONTIG); - new_stripoffset = (uint32*)_TIFFrealloc(td->td_stripoffset, - (td->td_nstrips + delta) * sizeof (uint32)); - new_stripbytecount = (uint32*)_TIFFrealloc(td->td_stripbytecount, - (td->td_nstrips + delta) * sizeof (uint32)); - if (new_stripoffset == NULL || new_stripbytecount == NULL) { - if (new_stripoffset) - _TIFFfree(new_stripoffset); - if (new_stripbytecount) - _TIFFfree(new_stripbytecount); - td->td_nstrips = 0; - TIFFErrorExt(tif->tif_clientdata, module, "%s: No space to expand strip arrays", - tif->tif_name); - return (0); - } - td->td_stripoffset = new_stripoffset; - td->td_stripbytecount = new_stripbytecount; - _TIFFmemset(td->td_stripoffset + td->td_nstrips, - 0, delta*sizeof (uint32)); - _TIFFmemset(td->td_stripbytecount + td->td_nstrips, - 0, delta*sizeof (uint32)); - td->td_nstrips += delta; - return (1); -} - -/* - * Append the data to the specified strip. - */ -static int -TIFFAppendToStrip(TIFF* tif, tstrip_t strip, tidata_t data, tsize_t cc) -{ - static const char module[] = "TIFFAppendToStrip"; - TIFFDirectory *td = &tif->tif_dir; - - if (td->td_stripoffset[strip] == 0 || tif->tif_curoff == 0) { - assert(td->td_nstrips > 0); - - if ( td->td_stripbytecount[strip] != 0 - && td->td_stripoffset[strip] != 0 - && td->td_stripbytecount[strip] >= cc ) - { - /* - * There is already tile data on disk, and the new tile - * data we have to will fit in the same space. The only - * aspect of this that is risky is that there could be - * more data to append to this strip before we are done - * depending on how we are getting called. - */ - if (!SeekOK(tif, td->td_stripoffset[strip])) { - TIFFErrorExt(tif->tif_clientdata, module, - "Seek error at scanline %lu", - (unsigned long)tif->tif_row); - return (0); - } - } - else - { - /* - * Seek to end of file, and set that as our location to - * write this strip. - */ - td->td_stripoffset[strip] = TIFFSeekFile(tif, 0, SEEK_END); - } - - tif->tif_curoff = td->td_stripoffset[strip]; - - /* - * We are starting a fresh strip/tile, so set the size to zero. - */ - td->td_stripbytecount[strip] = 0; - } - - if (!WriteOK(tif, data, cc)) { - TIFFErrorExt(tif->tif_clientdata, module, "Write error at scanline %lu", - (unsigned long) tif->tif_row); - return (0); - } - tif->tif_curoff = tif->tif_curoff+cc; - td->td_stripbytecount[strip] += cc; - return (1); -} - -/* - * Internal version of TIFFFlushData that can be - * called by ``encodestrip routines'' w/o concern - * for infinite recursion. - */ -int -TIFFFlushData1(TIFF* tif) -{ - if (tif->tif_rawcc > 0) { - if (!isFillOrder(tif, tif->tif_dir.td_fillorder) && - (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits((unsigned char *)tif->tif_rawdata, - tif->tif_rawcc); - if (!TIFFAppendToStrip(tif, - isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip, - tif->tif_rawdata, tif->tif_rawcc)) - return (0); - tif->tif_rawcc = 0; - tif->tif_rawcp = tif->tif_rawdata; - } - return (1); -} - -/* - * Set the current write offset. This should only be - * used to set the offset to a known previous location - * (very carefully), or to 0 so that the next write gets - * appended to the end of the file. - */ -void -TIFFSetWriteOffset(TIFF* tif, toff_t off) -{ - tif->tif_curoff = off; -} - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tif_zip.c b/plugins/AdvaImg/src/LibTIFF/tif_zip.c deleted file mode 100644 index 74ee9c4b5a..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tif_zip.c +++ /dev/null @@ -1,419 +0,0 @@ -/* $Id: tif_zip.c,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1995-1997 Sam Leffler - * Copyright (c) 1995-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#include "tiffiop.h" -#ifdef ZIP_SUPPORT -/* - * TIFF Library. - * - * ZIP (aka Deflate) Compression Support - * - * This file is simply an interface to the zlib library written by - * Jean-loup Gailly and Mark Adler. You must use version 1.0 or later - * of the library: this code assumes the 1.0 API and also depends on - * the ability to write the zlib header multiple times (one per strip) - * which was not possible with versions prior to 0.95. Note also that - * older versions of this codec avoided this bug by supressing the header - * entirely. This means that files written with the old library cannot - * be read; they should be converted to a different compression scheme - * and then reconverted. - * - * The data format used by the zlib library is described in the files - * zlib-3.1.doc, deflate-1.1.doc and gzip-4.1.doc, available in the - * directory ftp://ftp.uu.net/pub/archiving/zip/doc. The library was - * last found at ftp://ftp.uu.net/pub/archiving/zip/zlib/zlib-0.99.tar.gz. - */ -#include "tif_predict.h" -#include "../ZLib/zlib.h" - -#include - -/* - * Sigh, ZLIB_VERSION is defined as a string so there's no - * way to do a proper check here. Instead we guess based - * on the presence of #defines that were added between the - * 0.95 and 1.0 distributions. - */ -#if !defined(Z_NO_COMPRESSION) || !defined(Z_DEFLATED) -#error "Antiquated ZLIB software; you must use version 1.0 or later" -#endif - -/* - * State block for each open TIFF - * file using ZIP compression/decompression. - */ -typedef struct { - TIFFPredictorState predict; - z_stream stream; - int zipquality; /* compression level */ - int state; /* state flags */ -#define ZSTATE_INIT_DECODE 0x01 -#define ZSTATE_INIT_ENCODE 0x02 - - TIFFVGetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ -} ZIPState; - -#define ZState(tif) ((ZIPState*) (tif)->tif_data) -#define DecoderState(tif) ZState(tif) -#define EncoderState(tif) ZState(tif) - -static int ZIPEncode(TIFF*, tidata_t, tsize_t, tsample_t); -static int ZIPDecode(TIFF*, tidata_t, tsize_t, tsample_t); - -static int -ZIPSetupDecode(TIFF* tif) -{ - ZIPState* sp = DecoderState(tif); - static const char module[] = "ZIPSetupDecode"; - - assert(sp != NULL); - - /* if we were last encoding, terminate this mode */ - if (sp->state & ZSTATE_INIT_ENCODE) { - deflateEnd(&sp->stream); - sp->state = 0; - } - - if (inflateInit(&sp->stream) != Z_OK) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: %s", tif->tif_name, sp->stream.msg); - return (0); - } else { - sp->state |= ZSTATE_INIT_DECODE; - return (1); - } -} - -/* - * Setup state for decoding a strip. - */ -static int -ZIPPreDecode(TIFF* tif, tsample_t s) -{ - ZIPState* sp = DecoderState(tif); - - (void) s; - assert(sp != NULL); - - if ( (sp->state & ZSTATE_INIT_DECODE) == 0 ) - tif->tif_setupdecode( tif ); - - sp->stream.next_in = tif->tif_rawdata; - sp->stream.avail_in = tif->tif_rawcc; - return (inflateReset(&sp->stream) == Z_OK); -} - -static int -ZIPDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) -{ - ZIPState* sp = DecoderState(tif); - static const char module[] = "ZIPDecode"; - - (void) s; - assert(sp != NULL); - assert(sp->state == ZSTATE_INIT_DECODE); - - sp->stream.next_out = op; - sp->stream.avail_out = occ; - do { - int state = inflate(&sp->stream, Z_PARTIAL_FLUSH); - if (state == Z_STREAM_END) - break; - if (state == Z_DATA_ERROR) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Decoding error at scanline %d, %s", - tif->tif_name, tif->tif_row, sp->stream.msg); - if (inflateSync(&sp->stream) != Z_OK) - return (0); - continue; - } - if (state != Z_OK) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: zlib error: %s", - tif->tif_name, sp->stream.msg); - return (0); - } - } while (sp->stream.avail_out > 0); - if (sp->stream.avail_out != 0) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Not enough data at scanline %d (short %d bytes)", - tif->tif_name, tif->tif_row, sp->stream.avail_out); - return (0); - } - return (1); -} - -static int -ZIPSetupEncode(TIFF* tif) -{ - ZIPState* sp = EncoderState(tif); - static const char module[] = "ZIPSetupEncode"; - - assert(sp != NULL); - if (sp->state & ZSTATE_INIT_DECODE) { - inflateEnd(&sp->stream); - sp->state = 0; - } - - if (deflateInit(&sp->stream, sp->zipquality) != Z_OK) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: %s", tif->tif_name, sp->stream.msg); - return (0); - } else { - sp->state |= ZSTATE_INIT_ENCODE; - return (1); - } -} - -/* - * Reset encoding state at the start of a strip. - */ -static int -ZIPPreEncode(TIFF* tif, tsample_t s) -{ - ZIPState *sp = EncoderState(tif); - - (void) s; - assert(sp != NULL); - if ( sp->state != ZSTATE_INIT_ENCODE ) - tif->tif_setupencode( tif ); - - sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = tif->tif_rawdatasize; - return (deflateReset(&sp->stream) == Z_OK); -} - -/* - * Encode a chunk of pixels. - */ -static int -ZIPEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - ZIPState *sp = EncoderState(tif); - static const char module[] = "ZIPEncode"; - - assert(sp != NULL); - assert(sp->state == ZSTATE_INIT_ENCODE); - - (void) s; - sp->stream.next_in = bp; - sp->stream.avail_in = cc; - do { - if (deflate(&sp->stream, Z_NO_FLUSH) != Z_OK) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: Encoder error: %s", - tif->tif_name, sp->stream.msg); - return (0); - } - if (sp->stream.avail_out == 0) { - tif->tif_rawcc = tif->tif_rawdatasize; - TIFFFlushData1(tif); - sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = tif->tif_rawdatasize; - } - } while (sp->stream.avail_in > 0); - return (1); -} - -/* - * Finish off an encoded strip by flushing the last - * string and tacking on an End Of Information code. - */ -static int -ZIPPostEncode(TIFF* tif) -{ - ZIPState *sp = EncoderState(tif); - static const char module[] = "ZIPPostEncode"; - int state; - - sp->stream.avail_in = 0; - do { - state = deflate(&sp->stream, Z_FINISH); - switch (state) { - case Z_STREAM_END: - case Z_OK: - if ((int)sp->stream.avail_out != (int)tif->tif_rawdatasize) - { - tif->tif_rawcc = - tif->tif_rawdatasize - sp->stream.avail_out; - TIFFFlushData1(tif); - sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = tif->tif_rawdatasize; - } - break; - default: - TIFFErrorExt(tif->tif_clientdata, module, "%s: zlib error: %s", - tif->tif_name, sp->stream.msg); - return (0); - } - } while (state != Z_STREAM_END); - return (1); -} - -static void -ZIPCleanup(TIFF* tif) -{ - ZIPState* sp = ZState(tif); - - assert(sp != 0); - - (void)TIFFPredictorCleanup(tif); - - tif->tif_tagmethods.vgetfield = sp->vgetparent; - tif->tif_tagmethods.vsetfield = sp->vsetparent; - - if (sp->state & ZSTATE_INIT_ENCODE) { - deflateEnd(&sp->stream); - sp->state = 0; - } else if ( sp->state & ZSTATE_INIT_DECODE) { - inflateEnd(&sp->stream); - sp->state = 0; - } - _TIFFfree(sp); - tif->tif_data = NULL; - - _TIFFSetDefaultCompressionState(tif); -} - -static int -ZIPVSetField(TIFF* tif, ttag_t tag, va_list ap) -{ - ZIPState* sp = ZState(tif); - static const char module[] = "ZIPVSetField"; - - switch (tag) { - case TIFFTAG_ZIPQUALITY: - sp->zipquality = va_arg(ap, int); - if ( sp->state&ZSTATE_INIT_ENCODE ) { - if (deflateParams(&sp->stream, - sp->zipquality, Z_DEFAULT_STRATEGY) != Z_OK) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: zlib error: %s", - tif->tif_name, sp->stream.msg); - return (0); - } - } - return (1); - default: - return (*sp->vsetparent)(tif, tag, ap); - } - /*NOTREACHED*/ -} - -static int -ZIPVGetField(TIFF* tif, ttag_t tag, va_list ap) -{ - ZIPState* sp = ZState(tif); - - switch (tag) { - case TIFFTAG_ZIPQUALITY: - *va_arg(ap, int*) = sp->zipquality; - break; - default: - return (*sp->vgetparent)(tif, tag, ap); - } - return (1); -} - -static const TIFFFieldInfo zipFieldInfo[] = { - { TIFFTAG_ZIPQUALITY, 0, 0, TIFF_ANY, FIELD_PSEUDO, - TRUE, FALSE, "" }, -}; - -int -TIFFInitZIP(TIFF* tif, int scheme) -{ - static const char module[] = "TIFFInitZIP"; - ZIPState* sp; - - assert( (scheme == COMPRESSION_DEFLATE) - || (scheme == COMPRESSION_ADOBE_DEFLATE)); - - /* - * Merge codec-specific tag information. - */ - if (!_TIFFMergeFieldInfo(tif, zipFieldInfo, - TIFFArrayCount(zipFieldInfo))) { - TIFFErrorExt(tif->tif_clientdata, module, - "Merging Deflate codec-specific tags failed"); - return 0; - } - - /* - * Allocate state block so tag methods have storage to record values. - */ - tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (ZIPState)); - if (tif->tif_data == NULL) - goto bad; - sp = ZState(tif); - sp->stream.zalloc = NULL; - sp->stream.zfree = NULL; - sp->stream.opaque = NULL; - sp->stream.data_type = Z_BINARY; - - /* - * Override parent get/set field methods. - */ - sp->vgetparent = tif->tif_tagmethods.vgetfield; - tif->tif_tagmethods.vgetfield = ZIPVGetField; /* hook for codec tags */ - sp->vsetparent = tif->tif_tagmethods.vsetfield; - tif->tif_tagmethods.vsetfield = ZIPVSetField; /* hook for codec tags */ - - /* Default values for codec-specific fields */ - sp->zipquality = Z_DEFAULT_COMPRESSION; /* default comp. level */ - sp->state = 0; - - /* - * Install codec methods. - */ - tif->tif_setupdecode = ZIPSetupDecode; - tif->tif_predecode = ZIPPreDecode; - tif->tif_decoderow = ZIPDecode; - tif->tif_decodestrip = ZIPDecode; - tif->tif_decodetile = ZIPDecode; - tif->tif_setupencode = ZIPSetupEncode; - tif->tif_preencode = ZIPPreEncode; - tif->tif_postencode = ZIPPostEncode; - tif->tif_encoderow = ZIPEncode; - tif->tif_encodestrip = ZIPEncode; - tif->tif_encodetile = ZIPEncode; - tif->tif_cleanup = ZIPCleanup; - /* - * Setup predictor setup. - */ - (void) TIFFPredictorInit(tif); - return (1); -bad: - TIFFErrorExt(tif->tif_clientdata, module, - "No space for ZIP state block"); - return (0); -} -#endif /* ZIP_SUPORT */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tiff.h b/plugins/AdvaImg/src/LibTIFF/tiff.h deleted file mode 100644 index b8912efb9d..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tiff.h +++ /dev/null @@ -1,654 +0,0 @@ -/* $Id: tiff.h,v 1.38 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFF_ -#define _TIFF_ - -#include "tif_config.h" - -/* - * Tag Image File Format (TIFF) - * - * Based on Rev 6.0 from: - * Developer's Desk - * Aldus Corporation - * 411 First Ave. South - * Suite 200 - * Seattle, WA 98104 - * 206-622-5500 - * - * (http://partners.adobe.com/asn/developer/PDFS/TN/TIFF6.pdf) - * - * For Big TIFF design notes see the following link - * http://www.remotesensing.org/libtiff/bigtiffdesign.html - */ -#define TIFF_VERSION 42 -#define TIFF_BIGTIFF_VERSION 43 - -#define TIFF_BIGENDIAN 0x4d4d -#define TIFF_LITTLEENDIAN 0x4949 -#define MDI_LITTLEENDIAN 0x5045 -#define MDI_BIGENDIAN 0x4550 -/* - * Intrinsic data types required by the file format: - * - * 8-bit quantities int8/uint8 - * 16-bit quantities int16/uint16 - * 32-bit quantities int32/uint32 - * strings unsigned char* - */ - -#ifndef HAVE_INT8 -typedef signed char int8; /* NB: non-ANSI compilers may not grok */ -#endif -typedef unsigned char uint8; -#ifndef HAVE_INT16 -typedef short int16; -#endif -typedef unsigned short uint16; /* sizeof (uint16) must == 2 */ -#if SIZEOF_INT == 4 -#ifndef HAVE_INT32 -typedef int int32; -#endif -typedef unsigned int uint32; /* sizeof (uint32) must == 4 */ -#elif SIZEOF_LONG == 4 -#ifndef HAVE_INT32 -typedef long int32; -#endif -typedef unsigned long uint32; /* sizeof (uint32) must == 4 */ -#endif - -/* For TIFFReassignTagToIgnore */ -enum TIFFIgnoreSense /* IGNORE tag table */ -{ - TIS_STORE, - TIS_EXTRACT, - TIS_EMPTY -}; - -/* - * TIFF header. - */ -typedef struct { - uint16 tiff_magic; /* magic number (defines byte order) */ -#define TIFF_MAGIC_SIZE 2 - uint16 tiff_version; /* TIFF version number */ -#define TIFF_VERSION_SIZE 2 - uint32 tiff_diroff; /* byte offset to first directory */ -#define TIFF_DIROFFSET_SIZE 4 -} TIFFHeader; - - -/* - * TIFF Image File Directories are comprised of a table of field - * descriptors of the form shown below. The table is sorted in - * ascending order by tag. The values associated with each entry are - * disjoint and may appear anywhere in the file (so long as they are - * placed on a word boundary). - * - * If the value is 4 bytes or less, then it is placed in the offset - * field to save space. If the value is less than 4 bytes, it is - * left-justified in the offset field. - */ -typedef struct { - uint16 tdir_tag; /* see below */ - uint16 tdir_type; /* data type; see below */ - uint32 tdir_count; /* number of items; length in spec */ - uint32 tdir_offset; /* byte offset to field data */ -} TIFFDirEntry; - -/* - * NB: In the comments below, - * - items marked with a + are obsoleted by revision 5.0, - * - items marked with a ! are introduced in revision 6.0. - * - items marked with a % are introduced post revision 6.0. - * - items marked with a $ are obsoleted by revision 6.0. - * - items marked with a & are introduced by Adobe DNG specification. - */ - -/* - * Tag data type information. - * - * Note: RATIONALs are the ratio of two 32-bit integer values. - */ -typedef enum { - TIFF_NOTYPE = 0, /* placeholder */ - TIFF_BYTE = 1, /* 8-bit unsigned integer */ - TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */ - TIFF_SHORT = 3, /* 16-bit unsigned integer */ - TIFF_LONG = 4, /* 32-bit unsigned integer */ - TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */ - TIFF_SBYTE = 6, /* !8-bit signed integer */ - TIFF_UNDEFINED = 7, /* !8-bit untyped data */ - TIFF_SSHORT = 8, /* !16-bit signed integer */ - TIFF_SLONG = 9, /* !32-bit signed integer */ - TIFF_SRATIONAL = 10, /* !64-bit signed fraction */ - TIFF_FLOAT = 11, /* !32-bit IEEE floating point */ - TIFF_DOUBLE = 12, /* !64-bit IEEE floating point */ - TIFF_IFD = 13 /* %32-bit unsigned integer (offset) */ -} TIFFDataType; - -/* - * TIFF Tag Definitions. - */ -#define TIFFTAG_SUBFILETYPE 254 /* subfile data descriptor */ -#define FILETYPE_REDUCEDIMAGE 0x1 /* reduced resolution version */ -#define FILETYPE_PAGE 0x2 /* one page of many */ -#define FILETYPE_MASK 0x4 /* transparency mask */ -#define TIFFTAG_OSUBFILETYPE 255 /* +kind of data in subfile */ -#define OFILETYPE_IMAGE 1 /* full resolution image data */ -#define OFILETYPE_REDUCEDIMAGE 2 /* reduced size image data */ -#define OFILETYPE_PAGE 3 /* one page of many */ -#define TIFFTAG_IMAGEWIDTH 256 /* image width in pixels */ -#define TIFFTAG_IMAGELENGTH 257 /* image height in pixels */ -#define TIFFTAG_BITSPERSAMPLE 258 /* bits per channel (sample) */ -#define TIFFTAG_COMPRESSION 259 /* data compression technique */ -#define COMPRESSION_NONE 1 /* dump mode */ -#define COMPRESSION_CCITTRLE 2 /* CCITT modified Huffman RLE */ -#define COMPRESSION_CCITTFAX3 3 /* CCITT Group 3 fax encoding */ -#define COMPRESSION_CCITT_T4 3 /* CCITT T.4 (TIFF 6 name) */ -#define COMPRESSION_CCITTFAX4 4 /* CCITT Group 4 fax encoding */ -#define COMPRESSION_CCITT_T6 4 /* CCITT T.6 (TIFF 6 name) */ -#define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */ -#define COMPRESSION_OJPEG 6 /* !6.0 JPEG */ -#define COMPRESSION_JPEG 7 /* %JPEG DCT compression */ -#define COMPRESSION_NEXT 32766 /* NeXT 2-bit RLE */ -#define COMPRESSION_CCITTRLEW 32771 /* #1 w/ word alignment */ -#define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */ -#define COMPRESSION_THUNDERSCAN 32809 /* ThunderScan RLE */ -/* codes 32895-32898 are reserved for ANSI IT8 TIFF/IT */ -#define COMPRESSION_DCS 32947 /* Kodak DCS encoding */ -#define COMPRESSION_JBIG 34661 /* ISO JBIG */ -#define COMPRESSION_SGILOG 34676 /* SGI Log Luminance RLE */ -#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */ -#define COMPRESSION_JP2000 34712 /* Leadtools JPEG2000 */ -#define TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */ -#define PHOTOMETRIC_MINISWHITE 0 /* min value is white */ -#define PHOTOMETRIC_MINISBLACK 1 /* min value is black */ -#define PHOTOMETRIC_RGB 2 /* RGB color model */ -#define PHOTOMETRIC_PALETTE 3 /* color map indexed */ -#define PHOTOMETRIC_MASK 4 /* $holdout mask */ -#define PHOTOMETRIC_SEPARATED 5 /* !color separations */ -#define PHOTOMETRIC_YCBCR 6 /* !CCIR 601 */ -#define PHOTOMETRIC_CIELAB 8 /* !1976 CIE L*a*b* */ -#define PHOTOMETRIC_ICCLAB 9 /* ICC L*a*b* [Adobe TIFF Technote 4] */ -#define PHOTOMETRIC_ITULAB 10 /* ITU L*a*b* */ -#define PHOTOMETRIC_LOGL 32844 /* CIE Log2(L) */ -#define PHOTOMETRIC_LOGLUV 32845 /* CIE Log2(L) (u',v') */ -#define TIFFTAG_THRESHHOLDING 263 /* +thresholding used on data */ -#define THRESHHOLD_BILEVEL 1 /* b&w art scan */ -#define THRESHHOLD_HALFTONE 2 /* or dithered scan */ -#define THRESHHOLD_ERRORDIFFUSE 3 /* usually floyd-steinberg */ -#define TIFFTAG_CELLWIDTH 264 /* +dithering matrix width */ -#define TIFFTAG_CELLLENGTH 265 /* +dithering matrix height */ -#define TIFFTAG_FILLORDER 266 /* data order within a byte */ -#define FILLORDER_MSB2LSB 1 /* most significant -> least */ -#define FILLORDER_LSB2MSB 2 /* least significant -> most */ -#define TIFFTAG_DOCUMENTNAME 269 /* name of doc. image is from */ -#define TIFFTAG_IMAGEDESCRIPTION 270 /* info about image */ -#define TIFFTAG_MAKE 271 /* scanner manufacturer name */ -#define TIFFTAG_MODEL 272 /* scanner model name/number */ -#define TIFFTAG_STRIPOFFSETS 273 /* offsets to data strips */ -#define TIFFTAG_ORIENTATION 274 /* +image orientation */ -#define ORIENTATION_TOPLEFT 1 /* row 0 top, col 0 lhs */ -#define ORIENTATION_TOPRIGHT 2 /* row 0 top, col 0 rhs */ -#define ORIENTATION_BOTRIGHT 3 /* row 0 bottom, col 0 rhs */ -#define ORIENTATION_BOTLEFT 4 /* row 0 bottom, col 0 lhs */ -#define ORIENTATION_LEFTTOP 5 /* row 0 lhs, col 0 top */ -#define ORIENTATION_RIGHTTOP 6 /* row 0 rhs, col 0 top */ -#define ORIENTATION_RIGHTBOT 7 /* row 0 rhs, col 0 bottom */ -#define ORIENTATION_LEFTBOT 8 /* row 0 lhs, col 0 bottom */ -#define TIFFTAG_SAMPLESPERPIXEL 277 /* samples per pixel */ -#define TIFFTAG_ROWSPERSTRIP 278 /* rows per strip of data */ -#define TIFFTAG_STRIPBYTECOUNTS 279 /* bytes counts for strips */ -#define TIFFTAG_MINSAMPLEVALUE 280 /* +minimum sample value */ -#define TIFFTAG_MAXSAMPLEVALUE 281 /* +maximum sample value */ -#define TIFFTAG_XRESOLUTION 282 /* pixels/resolution in x */ -#define TIFFTAG_YRESOLUTION 283 /* pixels/resolution in y */ -#define TIFFTAG_PLANARCONFIG 284 /* storage organization */ -#define PLANARCONFIG_CONTIG 1 /* single image plane */ -#define PLANARCONFIG_SEPARATE 2 /* separate planes of data */ -#define TIFFTAG_PAGENAME 285 /* page name image is from */ -#define TIFFTAG_XPOSITION 286 /* x page offset of image lhs */ -#define TIFFTAG_YPOSITION 287 /* y page offset of image lhs */ -#define TIFFTAG_FREEOFFSETS 288 /* +byte offset to free block */ -#define TIFFTAG_FREEBYTECOUNTS 289 /* +sizes of free blocks */ -#define TIFFTAG_GRAYRESPONSEUNIT 290 /* $gray scale curve accuracy */ -#define GRAYRESPONSEUNIT_10S 1 /* tenths of a unit */ -#define GRAYRESPONSEUNIT_100S 2 /* hundredths of a unit */ -#define GRAYRESPONSEUNIT_1000S 3 /* thousandths of a unit */ -#define GRAYRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ -#define GRAYRESPONSEUNIT_100000S 5 /* hundred-thousandths */ -#define TIFFTAG_GRAYRESPONSECURVE 291 /* $gray scale response curve */ -#define TIFFTAG_GROUP3OPTIONS 292 /* 32 flag bits */ -#define TIFFTAG_T4OPTIONS 292 /* TIFF 6.0 proper name alias */ -#define GROUP3OPT_2DENCODING 0x1 /* 2-dimensional coding */ -#define GROUP3OPT_UNCOMPRESSED 0x2 /* data not compressed */ -#define GROUP3OPT_FILLBITS 0x4 /* fill to byte boundary */ -#define TIFFTAG_GROUP4OPTIONS 293 /* 32 flag bits */ -#define TIFFTAG_T6OPTIONS 293 /* TIFF 6.0 proper name */ -#define GROUP4OPT_UNCOMPRESSED 0x2 /* data not compressed */ -#define TIFFTAG_RESOLUTIONUNIT 296 /* units of resolutions */ -#define RESUNIT_NONE 1 /* no meaningful units */ -#define RESUNIT_INCH 2 /* english */ -#define RESUNIT_CENTIMETER 3 /* metric */ -#define TIFFTAG_PAGENUMBER 297 /* page numbers of multi-page */ -#define TIFFTAG_COLORRESPONSEUNIT 300 /* $color curve accuracy */ -#define COLORRESPONSEUNIT_10S 1 /* tenths of a unit */ -#define COLORRESPONSEUNIT_100S 2 /* hundredths of a unit */ -#define COLORRESPONSEUNIT_1000S 3 /* thousandths of a unit */ -#define COLORRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ -#define COLORRESPONSEUNIT_100000S 5 /* hundred-thousandths */ -#define TIFFTAG_TRANSFERFUNCTION 301 /* !colorimetry info */ -#define TIFFTAG_SOFTWARE 305 /* name & release */ -#define TIFFTAG_DATETIME 306 /* creation date and time */ -#define TIFFTAG_ARTIST 315 /* creator of image */ -#define TIFFTAG_HOSTCOMPUTER 316 /* machine where created */ -#define TIFFTAG_PREDICTOR 317 /* prediction scheme w/ LZW */ -#define PREDICTOR_NONE 1 /* no prediction scheme used */ -#define PREDICTOR_HORIZONTAL 2 /* horizontal differencing */ -#define PREDICTOR_FLOATINGPOINT 3 /* floating point predictor */ -#define TIFFTAG_WHITEPOINT 318 /* image white point */ -#define TIFFTAG_PRIMARYCHROMATICITIES 319 /* !primary chromaticities */ -#define TIFFTAG_COLORMAP 320 /* RGB map for pallette image */ -#define TIFFTAG_HALFTONEHINTS 321 /* !highlight+shadow info */ -#define TIFFTAG_TILEWIDTH 322 /* !tile width in pixels */ -#define TIFFTAG_TILELENGTH 323 /* !tile height in pixels */ -#define TIFFTAG_TILEOFFSETS 324 /* !offsets to data tiles */ -#define TIFFTAG_TILEBYTECOUNTS 325 /* !byte counts for tiles */ -#define TIFFTAG_BADFAXLINES 326 /* lines w/ wrong pixel count */ -#define TIFFTAG_CLEANFAXDATA 327 /* regenerated line info */ -#define CLEANFAXDATA_CLEAN 0 /* no errors detected */ -#define CLEANFAXDATA_REGENERATED 1 /* receiver regenerated lines */ -#define CLEANFAXDATA_UNCLEAN 2 /* uncorrected errors exist */ -#define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */ -#define TIFFTAG_SUBIFD 330 /* subimage descriptors */ -#define TIFFTAG_INKSET 332 /* !inks in separated image */ -#define INKSET_CMYK 1 /* !cyan-magenta-yellow-black color */ -#define INKSET_MULTIINK 2 /* !multi-ink or hi-fi color */ -#define TIFFTAG_INKNAMES 333 /* !ascii names of inks */ -#define TIFFTAG_NUMBEROFINKS 334 /* !number of inks */ -#define TIFFTAG_DOTRANGE 336 /* !0% and 100% dot codes */ -#define TIFFTAG_TARGETPRINTER 337 /* !separation target */ -#define TIFFTAG_EXTRASAMPLES 338 /* !info about extra samples */ -#define EXTRASAMPLE_UNSPECIFIED 0 /* !unspecified data */ -#define EXTRASAMPLE_ASSOCALPHA 1 /* !associated alpha data */ -#define EXTRASAMPLE_UNASSALPHA 2 /* !unassociated alpha data */ -#define TIFFTAG_SAMPLEFORMAT 339 /* !data sample format */ -#define SAMPLEFORMAT_UINT 1 /* !unsigned integer data */ -#define SAMPLEFORMAT_INT 2 /* !signed integer data */ -#define SAMPLEFORMAT_IEEEFP 3 /* !IEEE floating point data */ -#define SAMPLEFORMAT_VOID 4 /* !untyped data */ -#define SAMPLEFORMAT_COMPLEXINT 5 /* !complex signed int */ -#define SAMPLEFORMAT_COMPLEXIEEEFP 6 /* !complex ieee floating */ -#define TIFFTAG_SMINSAMPLEVALUE 340 /* !variable MinSampleValue */ -#define TIFFTAG_SMAXSAMPLEVALUE 341 /* !variable MaxSampleValue */ -#define TIFFTAG_CLIPPATH 343 /* %ClipPath - [Adobe TIFF technote 2] */ -#define TIFFTAG_XCLIPPATHUNITS 344 /* %XClipPathUnits - [Adobe TIFF technote 2] */ -#define TIFFTAG_YCLIPPATHUNITS 345 /* %YClipPathUnits - [Adobe TIFF technote 2] */ -#define TIFFTAG_INDEXED 346 /* %Indexed - [Adobe TIFF Technote 3] */ -#define TIFFTAG_JPEGTABLES 347 /* %JPEG table stream */ -#define TIFFTAG_OPIPROXY 351 /* %OPI Proxy [Adobe TIFF technote] */ -/* - * Tags 512-521 are obsoleted by Technical Note #2 which specifies a - * revised JPEG-in-TIFF scheme. - */ -#define TIFFTAG_JPEGPROC 512 /* !JPEG processing algorithm */ -#define JPEGPROC_BASELINE 1 /* !baseline sequential */ -#define JPEGPROC_LOSSLESS 14 /* !Huffman coded lossless */ -#define TIFFTAG_JPEGIFOFFSET 513 /* !pointer to SOI marker */ -#define TIFFTAG_JPEGIFBYTECOUNT 514 /* !JFIF stream length */ -#define TIFFTAG_JPEGRESTARTINTERVAL 515 /* !restart interval length */ -#define TIFFTAG_JPEGLOSSLESSPREDICTORS 517 /* !lossless proc predictor */ -#define TIFFTAG_JPEGPOINTTRANSFORM 518 /* !lossless point transform */ -#define TIFFTAG_JPEGQTABLES 519 /* !Q matrice offsets */ -#define TIFFTAG_JPEGDCTABLES 520 /* !DCT table offsets */ -#define TIFFTAG_JPEGACTABLES 521 /* !AC coefficient offsets */ -#define TIFFTAG_YCBCRCOEFFICIENTS 529 /* !RGB -> YCbCr transform */ -#define TIFFTAG_YCBCRSUBSAMPLING 530 /* !YCbCr subsampling factors */ -#define TIFFTAG_YCBCRPOSITIONING 531 /* !subsample positioning */ -#define YCBCRPOSITION_CENTERED 1 /* !as in PostScript Level 2 */ -#define YCBCRPOSITION_COSITED 2 /* !as in CCIR 601-1 */ -#define TIFFTAG_REFERENCEBLACKWHITE 532 /* !colorimetry info */ -#define TIFFTAG_XMLPACKET 700 /* %XML packet - [Adobe XMP Specification, - January 2004 */ -#define TIFFTAG_OPIIMAGEID 32781 /* %OPI ImageID - [Adobe TIFF technote] */ -/* tags 32952-32956 are private tags registered to Island Graphics */ -#define TIFFTAG_REFPTS 32953 /* image reference points */ -#define TIFFTAG_REGIONTACKPOINT 32954 /* region-xform tack point */ -#define TIFFTAG_REGIONWARPCORNERS 32955 /* warp quadrilateral */ -#define TIFFTAG_REGIONAFFINE 32956 /* affine transformation mat */ -/* tags 32995-32999 are private tags registered to SGI */ -#define TIFFTAG_MATTEING 32995 /* $use ExtraSamples */ -#define TIFFTAG_DATATYPE 32996 /* $use SampleFormat */ -#define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */ -#define TIFFTAG_TILEDEPTH 32998 /* z depth/data tile */ -/* tags 33300-33309 are private tags registered to Pixar */ -/* - * TIFFTAG_PIXAR_IMAGEFULLWIDTH and TIFFTAG_PIXAR_IMAGEFULLLENGTH - * are set when an image has been cropped out of a larger image. - * They reflect the size of the original uncropped image. - * The TIFFTAG_XPOSITION and TIFFTAG_YPOSITION can be used - * to determine the position of the smaller image in the larger one. - */ -#define TIFFTAG_PIXAR_IMAGEFULLWIDTH 33300 /* full image size in x */ -#define TIFFTAG_PIXAR_IMAGEFULLLENGTH 33301 /* full image size in y */ - /* Tags 33302-33306 are used to identify special image modes and data - * used by Pixar's texture formats. - */ -#define TIFFTAG_PIXAR_TEXTUREFORMAT 33302 /* texture map format */ -#define TIFFTAG_PIXAR_WRAPMODES 33303 /* s & t wrap modes */ -#define TIFFTAG_PIXAR_FOVCOT 33304 /* cotan(fov) for env. maps */ -#define TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN 33305 -#define TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA 33306 -/* tag 33405 is a private tag registered to Eastman Kodak */ -#define TIFFTAG_WRITERSERIALNUMBER 33405 /* device serial number */ -/* tag 33432 is listed in the 6.0 spec w/ unknown ownership */ -#define TIFFTAG_COPYRIGHT 33432 /* copyright string */ -/* IPTC TAG from RichTIFF specifications */ -#define TIFFTAG_RICHTIFFIPTC 33723 -/* 34016-34029 are reserved for ANSI IT8 TIFF/IT */ -#define TIFFTAG_STONITS 37439 /* Sample value to Nits */ -/* tag 34929 is a private tag registered to FedEx */ -#define TIFFTAG_FEDEX_EDR 34929 /* unknown use */ -#define TIFFTAG_INTEROPERABILITYIFD 40965 /* Pointer to Interoperability private directory */ -/* Adobe Digital Negative (DNG) format tags */ -#define TIFFTAG_DNGVERSION 50706 /* &DNG version number */ -#define TIFFTAG_DNGBACKWARDVERSION 50707 /* &DNG compatibility version */ -#define TIFFTAG_UNIQUECAMERAMODEL 50708 /* &name for the camera model */ -#define TIFFTAG_LOCALIZEDCAMERAMODEL 50709 /* &localized camera model - name */ -#define TIFFTAG_CFAPLANECOLOR 50710 /* &CFAPattern->LinearRaw space - mapping */ -#define TIFFTAG_CFALAYOUT 50711 /* &spatial layout of the CFA */ -#define TIFFTAG_LINEARIZATIONTABLE 50712 /* &lookup table description */ -#define TIFFTAG_BLACKLEVELREPEATDIM 50713 /* &repeat pattern size for - the BlackLevel tag */ -#define TIFFTAG_BLACKLEVEL 50714 /* &zero light encoding level */ -#define TIFFTAG_BLACKLEVELDELTAH 50715 /* &zero light encoding level - differences (columns) */ -#define TIFFTAG_BLACKLEVELDELTAV 50716 /* &zero light encoding level - differences (rows) */ -#define TIFFTAG_WHITELEVEL 50717 /* &fully saturated encoding - level */ -#define TIFFTAG_DEFAULTSCALE 50718 /* &default scale factors */ -#define TIFFTAG_DEFAULTCROPORIGIN 50719 /* &origin of the final image - area */ -#define TIFFTAG_DEFAULTCROPSIZE 50720 /* &size of the final image - area */ -#define TIFFTAG_COLORMATRIX1 50721 /* &XYZ->reference color space - transformation matrix 1 */ -#define TIFFTAG_COLORMATRIX2 50722 /* &XYZ->reference color space - transformation matrix 2 */ -#define TIFFTAG_CAMERACALIBRATION1 50723 /* &calibration matrix 1 */ -#define TIFFTAG_CAMERACALIBRATION2 50724 /* &calibration matrix 2 */ -#define TIFFTAG_REDUCTIONMATRIX1 50725 /* &dimensionality reduction - matrix 1 */ -#define TIFFTAG_REDUCTIONMATRIX2 50726 /* &dimensionality reduction - matrix 2 */ -#define TIFFTAG_ANALOGBALANCE 50727 /* &gain applied the stored raw - values*/ -#define TIFFTAG_ASSHOTNEUTRAL 50728 /* &selected white balance in - linear reference space */ -#define TIFFTAG_ASSHOTWHITEXY 50729 /* &selected white balance in - x-y chromaticity - coordinates */ -#define TIFFTAG_BASELINEEXPOSURE 50730 /* &how much to move the zero - point */ -#define TIFFTAG_BASELINENOISE 50731 /* &relative noise level */ -#define TIFFTAG_BASELINESHARPNESS 50732 /* &relative amount of - sharpening */ -#define TIFFTAG_BAYERGREENSPLIT 50733 /* &how closely the values of - the green pixels in the - blue/green rows track the - values of the green pixels - in the red/green rows */ -#define TIFFTAG_LINEARRESPONSELIMIT 50734 /* &non-linear encoding range */ -#define TIFFTAG_CAMERASERIALNUMBER 50735 /* &camera's serial number */ -#define TIFFTAG_LENSINFO 50736 /* info about the lens */ -#define TIFFTAG_CHROMABLURRADIUS 50737 /* &chroma blur radius */ -#define TIFFTAG_ANTIALIASSTRENGTH 50738 /* &relative strength of the - camera's anti-alias filter */ -#define TIFFTAG_SHADOWSCALE 50739 /* &used by Adobe Camera Raw */ -#define TIFFTAG_DNGPRIVATEDATA 50740 /* &manufacturer's private data */ -#define TIFFTAG_MAKERNOTESAFETY 50741 /* &whether the EXIF MakerNote - tag is safe to preserve - along with the rest of the - EXIF data */ -#define TIFFTAG_CALIBRATIONILLUMINANT1 50778 /* &illuminant 1 */ -#define TIFFTAG_CALIBRATIONILLUMINANT2 50779 /* &illuminant 2 */ -#define TIFFTAG_BESTQUALITYSCALE 50780 /* &best quality multiplier */ -#define TIFFTAG_RAWDATAUNIQUEID 50781 /* &unique identifier for - the raw image data */ -#define TIFFTAG_ORIGINALRAWFILENAME 50827 /* &file name of the original - raw file */ -#define TIFFTAG_ORIGINALRAWFILEDATA 50828 /* &contents of the original - raw file */ -#define TIFFTAG_ACTIVEAREA 50829 /* &active (non-masked) pixels - of the sensor */ -#define TIFFTAG_MASKEDAREAS 50830 /* &list of coordinates - of fully masked pixels */ -#define TIFFTAG_ASSHOTICCPROFILE 50831 /* &these two tags used to */ -#define TIFFTAG_ASSHOTPREPROFILEMATRIX 50832 /* map cameras's color space - into ICC profile space */ -#define TIFFTAG_CURRENTICCPROFILE 50833 /* & */ -#define TIFFTAG_CURRENTPREPROFILEMATRIX 50834 /* & */ -/* tag 65535 is an undefined tag used by Eastman Kodak */ -#define TIFFTAG_DCSHUESHIFTVALUES 65535 /* hue shift correction data */ - -/* - * The following are ``pseudo tags'' that can be used to control - * codec-specific functionality. These tags are not written to file. - * Note that these values start at 0xffff+1 so that they'll never - * collide with Aldus-assigned tags. - * - * If you want your private pseudo tags ``registered'' (i.e. added to - * this file), please post a bug report via the tracking system at - * http://www.remotesensing.org/libtiff/bugs.html with the appropriate - * C definitions to add. - */ -#define TIFFTAG_FAXMODE 65536 /* Group 3/4 format control */ -#define FAXMODE_CLASSIC 0x0000 /* default, include RTC */ -#define FAXMODE_NORTC 0x0001 /* no RTC at end of data */ -#define FAXMODE_NOEOL 0x0002 /* no EOL code at end of row */ -#define FAXMODE_BYTEALIGN 0x0004 /* byte align row */ -#define FAXMODE_WORDALIGN 0x0008 /* word align row */ -#define FAXMODE_CLASSF FAXMODE_NORTC /* TIFF Class F */ -#define TIFFTAG_JPEGQUALITY 65537 /* Compression quality level */ -/* Note: quality level is on the IJG 0-100 scale. Default value is 75 */ -#define TIFFTAG_JPEGCOLORMODE 65538 /* Auto RGB<=>YCbCr convert? */ -#define JPEGCOLORMODE_RAW 0x0000 /* no conversion (default) */ -#define JPEGCOLORMODE_RGB 0x0001 /* do auto conversion */ -#define TIFFTAG_JPEGTABLESMODE 65539 /* What to put in JPEGTables */ -#define JPEGTABLESMODE_QUANT 0x0001 /* include quantization tbls */ -#define JPEGTABLESMODE_HUFF 0x0002 /* include Huffman tbls */ -/* Note: default is JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF */ -#define TIFFTAG_FAXFILLFUNC 65540 /* G3/G4 fill function */ -#define TIFFTAG_PIXARLOGDATAFMT 65549 /* PixarLogCodec I/O data sz */ -#define PIXARLOGDATAFMT_8BIT 0 /* regular u_char samples */ -#define PIXARLOGDATAFMT_8BITABGR 1 /* ABGR-order u_chars */ -#define PIXARLOGDATAFMT_11BITLOG 2 /* 11-bit log-encoded (raw) */ -#define PIXARLOGDATAFMT_12BITPICIO 3 /* as per PICIO (1.0==2048) */ -#define PIXARLOGDATAFMT_16BIT 4 /* signed short samples */ -#define PIXARLOGDATAFMT_FLOAT 5 /* IEEE float samples */ -/* 65550-65556 are allocated to Oceana Matrix */ -#define TIFFTAG_DCSIMAGERTYPE 65550 /* imager model & filter */ -#define DCSIMAGERMODEL_M3 0 /* M3 chip (1280 x 1024) */ -#define DCSIMAGERMODEL_M5 1 /* M5 chip (1536 x 1024) */ -#define DCSIMAGERMODEL_M6 2 /* M6 chip (3072 x 2048) */ -#define DCSIMAGERFILTER_IR 0 /* infrared filter */ -#define DCSIMAGERFILTER_MONO 1 /* monochrome filter */ -#define DCSIMAGERFILTER_CFA 2 /* color filter array */ -#define DCSIMAGERFILTER_OTHER 3 /* other filter */ -#define TIFFTAG_DCSINTERPMODE 65551 /* interpolation mode */ -#define DCSINTERPMODE_NORMAL 0x0 /* whole image, default */ -#define DCSINTERPMODE_PREVIEW 0x1 /* preview of image (384x256) */ -#define TIFFTAG_DCSBALANCEARRAY 65552 /* color balance values */ -#define TIFFTAG_DCSCORRECTMATRIX 65553 /* color correction values */ -#define TIFFTAG_DCSGAMMA 65554 /* gamma value */ -#define TIFFTAG_DCSTOESHOULDERPTS 65555 /* toe & shoulder points */ -#define TIFFTAG_DCSCALIBRATIONFD 65556 /* calibration file desc */ -/* Note: quality level is on the ZLIB 1-9 scale. Default value is -1 */ -#define TIFFTAG_ZIPQUALITY 65557 /* compression quality level */ -#define TIFFTAG_PIXARLOGQUALITY 65558 /* PixarLog uses same scale */ -/* 65559 is allocated to Oceana Matrix */ -#define TIFFTAG_DCSCLIPRECTANGLE 65559 /* area of image to acquire */ -#define TIFFTAG_SGILOGDATAFMT 65560 /* SGILog user data format */ -#define SGILOGDATAFMT_FLOAT 0 /* IEEE float samples */ -#define SGILOGDATAFMT_16BIT 1 /* 16-bit samples */ -#define SGILOGDATAFMT_RAW 2 /* uninterpreted data */ -#define SGILOGDATAFMT_8BIT 3 /* 8-bit RGB monitor values */ -#define TIFFTAG_SGILOGENCODE 65561 /* SGILog data encoding control*/ -#define SGILOGENCODE_NODITHER 0 /* do not dither encoded values*/ -#define SGILOGENCODE_RANDITHER 1 /* randomly dither encd values */ - -/* - * EXIF tags - */ -#define EXIFTAG_EXPOSURETIME 33434 /* Exposure time */ -#define EXIFTAG_FNUMBER 33437 /* F number */ -#define EXIFTAG_EXPOSUREPROGRAM 34850 /* Exposure program */ -#define EXIFTAG_SPECTRALSENSITIVITY 34852 /* Spectral sensitivity */ -#define EXIFTAG_ISOSPEEDRATINGS 34855 /* ISO speed rating */ -#define EXIFTAG_OECF 34856 /* Optoelectric conversion - factor */ -#define EXIFTAG_EXIFVERSION 36864 /* Exif version */ -#define EXIFTAG_DATETIMEORIGINAL 36867 /* Date and time of original - data generation */ -#define EXIFTAG_DATETIMEDIGITIZED 36868 /* Date and time of digital - data generation */ -#define EXIFTAG_COMPONENTSCONFIGURATION 37121 /* Meaning of each component */ -#define EXIFTAG_COMPRESSEDBITSPERPIXEL 37122 /* Image compression mode */ -#define EXIFTAG_SHUTTERSPEEDVALUE 37377 /* Shutter speed */ -#define EXIFTAG_APERTUREVALUE 37378 /* Aperture */ -#define EXIFTAG_BRIGHTNESSVALUE 37379 /* Brightness */ -#define EXIFTAG_EXPOSUREBIASVALUE 37380 /* Exposure bias */ -#define EXIFTAG_MAXAPERTUREVALUE 37381 /* Maximum lens aperture */ -#define EXIFTAG_SUBJECTDISTANCE 37382 /* Subject distance */ -#define EXIFTAG_METERINGMODE 37383 /* Metering mode */ -#define EXIFTAG_LIGHTSOURCE 37384 /* Light source */ -#define EXIFTAG_FLASH 37385 /* Flash */ -#define EXIFTAG_FOCALLENGTH 37386 /* Lens focal length */ -#define EXIFTAG_SUBJECTAREA 37396 /* Subject area */ -#define EXIFTAG_MAKERNOTE 37500 /* Manufacturer notes */ -#define EXIFTAG_USERCOMMENT 37510 /* User comments */ -#define EXIFTAG_SUBSECTIME 37520 /* DateTime subseconds */ -#define EXIFTAG_SUBSECTIMEORIGINAL 37521 /* DateTimeOriginal subseconds */ -#define EXIFTAG_SUBSECTIMEDIGITIZED 37522 /* DateTimeDigitized subseconds */ -#define EXIFTAG_FLASHPIXVERSION 40960 /* Supported Flashpix version */ -#define EXIFTAG_COLORSPACE 40961 /* Color space information */ -#define EXIFTAG_PIXELXDIMENSION 40962 /* Valid image width */ -#define EXIFTAG_PIXELYDIMENSION 40963 /* Valid image height */ -#define EXIFTAG_RELATEDSOUNDFILE 40964 /* Related audio file */ -#define EXIFTAG_FLASHENERGY 41483 /* Flash energy */ -#define EXIFTAG_SPATIALFREQUENCYRESPONSE 41484 /* Spatial frequency response */ -#define EXIFTAG_FOCALPLANEXRESOLUTION 41486 /* Focal plane X resolution */ -#define EXIFTAG_FOCALPLANEYRESOLUTION 41487 /* Focal plane Y resolution */ -#define EXIFTAG_FOCALPLANERESOLUTIONUNIT 41488 /* Focal plane resolution unit */ -#define EXIFTAG_SUBJECTLOCATION 41492 /* Subject location */ -#define EXIFTAG_EXPOSUREINDEX 41493 /* Exposure index */ -#define EXIFTAG_SENSINGMETHOD 41495 /* Sensing method */ -#define EXIFTAG_FILESOURCE 41728 /* File source */ -#define EXIFTAG_SCENETYPE 41729 /* Scene type */ -#define EXIFTAG_CFAPATTERN 41730 /* CFA pattern */ -#define EXIFTAG_CUSTOMRENDERED 41985 /* Custom image processing */ -#define EXIFTAG_EXPOSUREMODE 41986 /* Exposure mode */ -#define EXIFTAG_WHITEBALANCE 41987 /* White balance */ -#define EXIFTAG_DIGITALZOOMRATIO 41988 /* Digital zoom ratio */ -#define EXIFTAG_FOCALLENGTHIN35MMFILM 41989 /* Focal length in 35 mm film */ -#define EXIFTAG_SCENECAPTURETYPE 41990 /* Scene capture type */ -#define EXIFTAG_GAINCONTROL 41991 /* Gain control */ -#define EXIFTAG_CONTRAST 41992 /* Contrast */ -#define EXIFTAG_SATURATION 41993 /* Saturation */ -#define EXIFTAG_SHARPNESS 41994 /* Sharpness */ -#define EXIFTAG_DEVICESETTINGDESCRIPTION 41995 /* Device settings description */ -#define EXIFTAG_SUBJECTDISTANCERANGE 41996 /* Subject distance range */ -#define EXIFTAG_GAINCONTROL 41991 /* Gain control */ -#define EXIFTAG_GAINCONTROL 41991 /* Gain control */ -#define EXIFTAG_IMAGEUNIQUEID 42016 /* Unique image ID */ - -#endif /* _TIFF_ */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tiffconf.h-vms b/plugins/AdvaImg/src/LibTIFF/tiffconf.h-vms deleted file mode 100644 index de717ecb97..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tiffconf.h-vms +++ /dev/null @@ -1,99 +0,0 @@ -/* - Configuration defines for installed libtiff. - This file maintained for backward compatibility. Do not use definitions - from this file in your programs. -*/ - -#ifndef _TIFFCONF_ -#define _TIFFCONF_ - -/* Define to 1 if the system has the type `int16'. */ -//#define HAVE_INT16 - -/* Define to 1 if the system has the type `int32'. */ -//#define HAVE_INT32 - -/* Define to 1 if the system has the type `int8'. */ -//#define HAVE_INT8 - -/* The size of a `int', as computed by sizeof. */ -#define SIZEOF_INT 4 - -/* The size of a `long', as computed by sizeof. */ -#define SIZEOF_LONG 4 - -/* Compatibility stuff. */ - -/* Define as 0 or 1 according to the floating point format suported by the - machine */ -#define HAVE_IEEEFP 1 - -#define HAVE_GETOPT 1 - -/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ -#define HOST_FILLORDER FILLORDER_LSB2MSB - -/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian - (Intel) */ -#define HOST_BIGENDIAN 0 - -/* Support CCITT Group 3 & 4 algorithms */ -#define CCITT_SUPPORT 1 - -/* Support JPEG compression (requires IJG JPEG library) */ -#define JPEG_SUPPORT - -/* Support LogLuv high dynamic range encoding */ -#define LOGLUV_SUPPORT 1 - -/* Support LZW algorithm */ -#define LZW_SUPPORT 1 - -/* Support NeXT 2-bit RLE algorithm */ -#define NEXT_SUPPORT 1 - -/* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation - fails with unpatched IJG JPEG library) */ -/* #undef OJPEG_SUPPORT */ - -/* Support Macintosh PackBits algorithm */ -#define PACKBITS_SUPPORT 1 - -/* Support Pixar log-format algorithm (requires Zlib) */ -/* #undef PIXARLOG_SUPPORT */ - -/* Support ThunderScan 4-bit RLE algorithm */ -#define THUNDER_SUPPORT 1 - -/* Support Deflate compression */ -/* #undef ZIP_SUPPORT */ - -/* Support strip chopping (whether or not to convert single-strip uncompressed - images to mutiple strips of ~8Kb to reduce memory usage) */ -#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP - -/* Enable SubIFD tag (330) support */ -#define SUBIFD_SUPPORT 1 - -/* Treat extra sample as alpha (default enabled). The RGBA interface will - treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many - packages produce RGBA files but don't mark the alpha properly. */ -#define DEFAULT_EXTRASAMPLE_AS_ALPHA 1 - -/* Pick up YCbCr subsampling info from the JPEG data stream to support files - lacking the tag (default enabled). */ -#define CHECK_JPEG_YCBCR_SUBSAMPLING 1 - -/* - * Feature support definitions. - * XXX: These macros are obsoleted. Don't use them in your apps! - * Macros stays here for backward compatibility and should be always defined. - */ -#define COLORIMETRY_SUPPORT -#define YCBCR_SUPPORT -#define CMYK_SUPPORT -#define ICC_SUPPORT -#define PHOTOSHOP_SUPPORT -#define IPTC_SUPPORT - -#endif /* _TIFFCONF_ */ diff --git a/plugins/AdvaImg/src/LibTIFF/tiffconf.vc.h b/plugins/AdvaImg/src/LibTIFF/tiffconf.vc.h deleted file mode 100644 index 5d73852c41..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tiffconf.vc.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - Configuration defines for installed libtiff. - This file maintained for backward compatibility. Do not use definitions - from this file in your programs. -*/ - -#ifndef _TIFFCONF_ -#define _TIFFCONF_ - -/* Define to 1 if the system has the type `int16'. */ -/* #undef HAVE_INT16 */ - -/* Define to 1 if the system has the type `int32'. */ -/* #undef HAVE_INT32 */ - -/* Define to 1 if the system has the type `int8'. */ -/* #undef HAVE_INT8 */ - -/* The size of a `int', as computed by sizeof. */ -#define SIZEOF_INT 4 - -/* The size of a `long', as computed by sizeof. */ -#define SIZEOF_LONG 4 - -/* Signed 64-bit type formatter */ -#define TIFF_INT64_FORMAT "%I64d" - -/* Signed 64-bit type */ -#define TIFF_INT64_T signed __int64 - -/* Unsigned 64-bit type formatter */ -#define TIFF_UINT64_FORMAT "%I64u" - -/* Unsigned 64-bit type */ -#define TIFF_UINT64_T unsigned __int64 - -/* Compatibility stuff. */ - -/* Define as 0 or 1 according to the floating point format suported by the - machine */ -#define HAVE_IEEEFP 1 - -/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ -#define HOST_FILLORDER FILLORDER_LSB2MSB - -/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian - (Intel) */ -#define HOST_BIGENDIAN 0 - -/* Support CCITT Group 3 & 4 algorithms */ -#define CCITT_SUPPORT 1 - -/* Support JPEG compression (requires IJG JPEG library) */ -/* #undef JPEG_SUPPORT */ - -/* Support LogLuv high dynamic range encoding */ -#define LOGLUV_SUPPORT 1 - -/* Support LZW algorithm */ -#define LZW_SUPPORT 1 - -/* Support NeXT 2-bit RLE algorithm */ -#define NEXT_SUPPORT 1 - -/* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation - fails with unpatched IJG JPEG library) */ -/* #undef OJPEG_SUPPORT */ - -/* Support Macintosh PackBits algorithm */ -#define PACKBITS_SUPPORT 1 - -/* Support Pixar log-format algorithm (requires Zlib) */ -/* #undef PIXARLOG_SUPPORT */ - -/* Support ThunderScan 4-bit RLE algorithm */ -#define THUNDER_SUPPORT 1 - -/* Support Deflate compression */ -/* #undef ZIP_SUPPORT */ - -/* Support strip chopping (whether or not to convert single-strip uncompressed - images to mutiple strips of ~8Kb to reduce memory usage) */ -#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP - -/* Enable SubIFD tag (330) support */ -#define SUBIFD_SUPPORT 1 - -/* Treat extra sample as alpha (default enabled). The RGBA interface will - treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many - packages produce RGBA files but don't mark the alpha properly. */ -#define DEFAULT_EXTRASAMPLE_AS_ALPHA 1 - -/* Pick up YCbCr subsampling info from the JPEG data stream to support files - lacking the tag (default enabled). */ -#define CHECK_JPEG_YCBCR_SUBSAMPLING 1 - -/* - * Feature support definitions. - * XXX: These macros are obsoleted. Don't use them in your apps! - * Macros stays here for backward compatibility and should be always defined. - */ -#define COLORIMETRY_SUPPORT -#define YCBCR_SUPPORT -#define CMYK_SUPPORT -#define ICC_SUPPORT -#define PHOTOSHOP_SUPPORT -#define IPTC_SUPPORT - -#endif /* _TIFFCONF_ */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tiffio.h b/plugins/AdvaImg/src/LibTIFF/tiffio.h deleted file mode 100644 index 2b94407acd..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tiffio.h +++ /dev/null @@ -1,526 +0,0 @@ -/* $Id: tiffio.h,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFFIO_ -#define _TIFFIO_ - -/* - * TIFF I/O Library Definitions. - */ -#include "tiff.h" -#include "tiffvers.h" - -/* - * TIFF is defined as an incomplete type to hide the - * library's internal data structures from clients. - */ -typedef struct tiff TIFF; - -/* - * The following typedefs define the intrinsic size of - * data types used in the *exported* interfaces. These - * definitions depend on the proper definition of types - * in tiff.h. Note also that the varargs interface used - * to pass tag types and values uses the types defined in - * tiff.h directly. - * - * NB: ttag_t is unsigned int and not unsigned short because - * ANSI C requires that the type before the ellipsis be a - * promoted type (i.e. one of int, unsigned int, pointer, - * or double) and because we defined pseudo-tags that are - * outside the range of legal Aldus-assigned tags. - * NB: tsize_t is int32 and not uint32 because some functions - * return -1. - * NB: toff_t is not off_t for many reasons; TIFFs max out at - * 32-bit file offsets being the most important, and to ensure - * that it is unsigned, rather than signed. - */ -typedef uint32 ttag_t; /* directory tag */ -typedef uint16 tdir_t; /* directory index */ -typedef uint16 tsample_t; /* sample number */ -typedef uint32 tstrile_t; /* strip or tile number */ -typedef tstrile_t tstrip_t; /* strip number */ -typedef tstrile_t ttile_t; /* tile number */ -typedef int32 tsize_t; /* i/o size in bytes */ -typedef void* tdata_t; /* image data ref */ -typedef uint32 toff_t; /* file offset */ - -#if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32)) -#define __WIN32__ -#endif - -/* - * On windows you should define USE_WIN32_FILEIO if you are using tif_win32.c - * or AVOID_WIN32_FILEIO if you are using something else (like tif_unix.c). - * - * By default tif_unix.c is assumed. - */ - -#if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows) -# if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && !defined(USE_WIN32_FILEIO) -# define AVOID_WIN32_FILEIO -# endif -#endif - -#if defined(USE_WIN32_FILEIO) -# define VC_EXTRALEAN -# include -# ifdef __WIN32__ -DECLARE_HANDLE(thandle_t); /* Win32 file handle */ -# else -typedef HFILE thandle_t; /* client data handle */ -# endif /* __WIN32__ */ -#else -typedef void* thandle_t; /* client data handle */ -#endif /* USE_WIN32_FILEIO */ - -/* - * Flags to pass to TIFFPrintDirectory to control - * printing of data structures that are potentially - * very large. Bit-or these flags to enable printing - * multiple items. - */ -#define TIFFPRINT_NONE 0x0 /* no extra info */ -#define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ -#define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ -#define TIFFPRINT_COLORMAP 0x4 /* colormap */ -#define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ -#define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ -#define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ - -/* - * Colour conversion stuff - */ - -/* reference white */ -#define D65_X0 (95.0470F) -#define D65_Y0 (100.0F) -#define D65_Z0 (108.8827F) - -#define D50_X0 (96.4250F) -#define D50_Y0 (100.0F) -#define D50_Z0 (82.4680F) - -/* Structure for holding information about a display device. */ - -typedef unsigned char TIFFRGBValue; /* 8-bit samples */ - -typedef struct { - float d_mat[3][3]; /* XYZ -> luminance matrix */ - float d_YCR; /* Light o/p for reference white */ - float d_YCG; - float d_YCB; - uint32 d_Vrwr; /* Pixel values for ref. white */ - uint32 d_Vrwg; - uint32 d_Vrwb; - float d_Y0R; /* Residual light for black pixel */ - float d_Y0G; - float d_Y0B; - float d_gammaR; /* Gamma values for the three guns */ - float d_gammaG; - float d_gammaB; -} TIFFDisplay; - -typedef struct { /* YCbCr->RGB support */ - TIFFRGBValue* clamptab; /* range clamping table */ - int* Cr_r_tab; - int* Cb_b_tab; - int32* Cr_g_tab; - int32* Cb_g_tab; - int32* Y_tab; -} TIFFYCbCrToRGB; - -typedef struct { /* CIE Lab 1976->RGB support */ - int range; /* Size of conversion table */ -#define CIELABTORGB_TABLE_RANGE 1500 - float rstep, gstep, bstep; - float X0, Y0, Z0; /* Reference white point */ - TIFFDisplay display; - float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */ - float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */ - float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */ -} TIFFCIELabToRGB; - -/* - * RGBA-style image support. - */ -typedef struct _TIFFRGBAImage TIFFRGBAImage; -/* - * The image reading and conversion routines invoke - * ``put routines'' to copy/image/whatever tiles of - * raw image data. A default set of routines are - * provided to convert/copy raw image data to 8-bit - * packed ABGR format rasters. Applications can supply - * alternate routines that unpack the data into a - * different format or, for example, unpack the data - * and draw the unpacked raster on the display. - */ -typedef void (*tileContigRoutine) - (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, - unsigned char*); -typedef void (*tileSeparateRoutine) - (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, - unsigned char*, unsigned char*, unsigned char*, unsigned char*); -/* - * RGBA-reader state. - */ -struct _TIFFRGBAImage { - TIFF* tif; /* image handle */ - int stoponerr; /* stop on read error */ - int isContig; /* data is packed/separate */ - int alpha; /* type of alpha data present */ - uint32 width; /* image width */ - uint32 height; /* image height */ - uint16 bitspersample; /* image bits/sample */ - uint16 samplesperpixel; /* image samples/pixel */ - uint16 orientation; /* image orientation */ - uint16 req_orientation; /* requested orientation */ - uint16 photometric; /* image photometric interp */ - uint16* redcmap; /* colormap pallete */ - uint16* greencmap; - uint16* bluecmap; - /* get image data routine */ - int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32); - /* put decoded strip/tile */ - union { - void (*any)(TIFFRGBAImage*); - tileContigRoutine contig; - tileSeparateRoutine separate; - } put; - TIFFRGBValue* Map; /* sample mapping array */ - uint32** BWmap; /* black&white map */ - uint32** PALmap; /* palette image map */ - TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */ - TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */ - - int row_offset; - int col_offset; -}; - -/* - * Macros for extracting components from the - * packed ABGR form returned by TIFFReadRGBAImage. - */ -#define TIFFGetR(abgr) ((abgr) & 0xff) -#define TIFFGetG(abgr) (((abgr) >> 8) & 0xff) -#define TIFFGetB(abgr) (((abgr) >> 16) & 0xff) -#define TIFFGetA(abgr) (((abgr) >> 24) & 0xff) - -/* - * A CODEC is a software package that implements decoding, - * encoding, or decoding+encoding of a compression algorithm. - * The library provides a collection of builtin codecs. - * More codecs may be registered through calls to the library - * and/or the builtin implementations may be overridden. - */ -typedef int (*TIFFInitMethod)(TIFF*, int); -typedef struct { - char* name; - uint16 scheme; - TIFFInitMethod init; -} TIFFCodec; - -#include -#include - -/* share internal LogLuv conversion routines? */ -#ifndef LOGLUV_PUBLIC -#define LOGLUV_PUBLIC 1 -#endif - -#if !defined(__GNUC__) && !defined(__attribute__) -# define __attribute__(x) /*nothing*/ -#endif - -#if defined(c_plusplus) || defined(__cplusplus) -extern "C" { -#endif -typedef void (*TIFFErrorHandler)(const char*, const char*, va_list); -typedef void (*TIFFErrorHandlerExt)(thandle_t, const char*, const char*, va_list); -typedef tsize_t (*TIFFReadWriteProc)(thandle_t, tdata_t, tsize_t); -typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); -typedef int (*TIFFCloseProc)(thandle_t); -typedef toff_t (*TIFFSizeProc)(thandle_t); -typedef int (*TIFFMapFileProc)(thandle_t, tdata_t*, toff_t*); -typedef void (*TIFFUnmapFileProc)(thandle_t, tdata_t, toff_t); -typedef void (*TIFFExtendProc)(TIFF*); - -extern const char* TIFFGetVersion(void); - -extern const TIFFCodec* TIFFFindCODEC(uint16); -extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod); -extern void TIFFUnRegisterCODEC(TIFFCodec*); -extern int TIFFIsCODECConfigured(uint16); -extern TIFFCodec* TIFFGetConfiguredCODECs(void); - -/* - * Auxiliary functions. - */ - -extern tdata_t _TIFFmalloc(tsize_t); -extern tdata_t _TIFFrealloc(tdata_t, tsize_t); -extern void _TIFFmemset(tdata_t, int, tsize_t); -extern void _TIFFmemcpy(tdata_t, const tdata_t, tsize_t); -extern int _TIFFmemcmp(const tdata_t, const tdata_t, tsize_t); -extern void _TIFFfree(tdata_t); - -/* -** Stuff, related to tag handling and creating custom tags. -*/ -extern int TIFFGetTagListCount( TIFF * ); -extern ttag_t TIFFGetTagListEntry( TIFF *, int tag_index ); - -#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */ -#define TIFF_VARIABLE -1 /* marker for variable length tags */ -#define TIFF_SPP -2 /* marker for SamplesPerPixel tags */ -#define TIFF_VARIABLE2 -3 /* marker for uint32 var-length tags */ - -#define FIELD_CUSTOM 65 - -typedef struct { - ttag_t field_tag; /* field's tag */ - short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */ - short field_writecount; /* write count/TIFF_VARIABLE */ - TIFFDataType field_type; /* type of associated data */ - unsigned short field_bit; /* bit in fieldsset bit vector */ - unsigned char field_oktochange; /* if true, can change while writing */ - unsigned char field_passcount; /* if true, pass dir count on set */ - char *field_name; /* ASCII name */ -} TIFFFieldInfo; - -typedef struct _TIFFTagValue { - const TIFFFieldInfo *info; - int count; - void *value; -} TIFFTagValue; - -extern void TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], int); -extern const TIFFFieldInfo* TIFFFindFieldInfo(TIFF*, ttag_t, TIFFDataType); -extern const TIFFFieldInfo* TIFFFindFieldInfoByName(TIFF* , const char *, - TIFFDataType); -extern const TIFFFieldInfo* TIFFFieldWithTag(TIFF*, ttag_t); -extern const TIFFFieldInfo* TIFFFieldWithName(TIFF*, const char *); - -typedef int (*TIFFVSetMethod)(TIFF*, ttag_t, va_list); -typedef int (*TIFFVGetMethod)(TIFF*, ttag_t, va_list); -typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long); - -typedef struct { - TIFFVSetMethod vsetfield; /* tag set routine */ - TIFFVGetMethod vgetfield; /* tag get routine */ - TIFFPrintMethod printdir; /* directory print routine */ -} TIFFTagMethods; - -extern TIFFTagMethods *TIFFAccessTagMethods( TIFF * ); -extern void *TIFFGetClientInfo( TIFF *, const char * ); -extern void TIFFSetClientInfo( TIFF *, void *, const char * ); - -extern void TIFFCleanup(TIFF*); -extern void TIFFClose(TIFF*); -extern int TIFFFlush(TIFF*); -extern int TIFFFlushData(TIFF*); -extern int TIFFGetField(TIFF*, ttag_t, ...); -extern int TIFFVGetField(TIFF*, ttag_t, va_list); -extern int TIFFGetFieldDefaulted(TIFF*, ttag_t, ...); -extern int TIFFVGetFieldDefaulted(TIFF*, ttag_t, va_list); -extern int TIFFReadDirectory(TIFF*); -extern int TIFFReadCustomDirectory(TIFF*, toff_t, const TIFFFieldInfo[], - size_t); -extern int TIFFReadEXIFDirectory(TIFF*, toff_t); -extern tsize_t TIFFScanlineSize(TIFF*); -extern tsize_t TIFFOldScanlineSize(TIFF*); -extern tsize_t TIFFNewScanlineSize(TIFF*); -extern tsize_t TIFFRasterScanlineSize(TIFF*); -extern tsize_t TIFFStripSize(TIFF*); -extern tsize_t TIFFRawStripSize(TIFF*, tstrip_t); -extern tsize_t TIFFVStripSize(TIFF*, uint32); -extern tsize_t TIFFTileRowSize(TIFF*); -extern tsize_t TIFFTileSize(TIFF*); -extern tsize_t TIFFVTileSize(TIFF*, uint32); -extern uint32 TIFFDefaultStripSize(TIFF*, uint32); -extern void TIFFDefaultTileSize(TIFF*, uint32*, uint32*); -extern int TIFFFileno(TIFF*); -extern int TIFFSetFileno(TIFF*, int); -extern thandle_t TIFFClientdata(TIFF*); -extern thandle_t TIFFSetClientdata(TIFF*, thandle_t); -extern int TIFFGetMode(TIFF*); -extern int TIFFSetMode(TIFF*, int); -extern int TIFFIsTiled(TIFF*); -extern int TIFFIsByteSwapped(TIFF*); -extern int TIFFIsUpSampled(TIFF*); -extern int TIFFIsMSB2LSB(TIFF*); -extern int TIFFIsBigEndian(TIFF*); -extern TIFFReadWriteProc TIFFGetReadProc(TIFF*); -extern TIFFReadWriteProc TIFFGetWriteProc(TIFF*); -extern TIFFSeekProc TIFFGetSeekProc(TIFF*); -extern TIFFCloseProc TIFFGetCloseProc(TIFF*); -extern TIFFSizeProc TIFFGetSizeProc(TIFF*); -extern TIFFMapFileProc TIFFGetMapFileProc(TIFF*); -extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF*); -extern uint32 TIFFCurrentRow(TIFF*); -extern tdir_t TIFFCurrentDirectory(TIFF*); -extern tdir_t TIFFNumberOfDirectories(TIFF*); -extern uint32 TIFFCurrentDirOffset(TIFF*); -extern tstrip_t TIFFCurrentStrip(TIFF*); -extern ttile_t TIFFCurrentTile(TIFF*); -extern int TIFFReadBufferSetup(TIFF*, tdata_t, tsize_t); -extern int TIFFWriteBufferSetup(TIFF*, tdata_t, tsize_t); -extern int TIFFSetupStrips(TIFF *); -extern int TIFFWriteCheck(TIFF*, int, const char *); -extern void TIFFFreeDirectory(TIFF*); -extern int TIFFCreateDirectory(TIFF*); -extern int TIFFLastDirectory(TIFF*); -extern int TIFFSetDirectory(TIFF*, tdir_t); -extern int TIFFSetSubDirectory(TIFF*, uint32); -extern int TIFFUnlinkDirectory(TIFF*, tdir_t); -extern int TIFFSetField(TIFF*, ttag_t, ...); -extern int TIFFVSetField(TIFF*, ttag_t, va_list); -extern int TIFFWriteDirectory(TIFF *); -extern int TIFFCheckpointDirectory(TIFF *); -extern int TIFFRewriteDirectory(TIFF *); -extern int TIFFReassignTagToIgnore(enum TIFFIgnoreSense, int); - -#if defined(c_plusplus) || defined(__cplusplus) -extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0); -extern int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t = 0); -extern int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t = 0); -extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0); -extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, - int = ORIENTATION_BOTLEFT, int = 0); -#else -extern void TIFFPrintDirectory(TIFF*, FILE*, long); -extern int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t); -extern int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t); -extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int); -extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int); -#endif - -extern int TIFFReadRGBAStrip(TIFF*, tstrip_t, uint32 * ); -extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * ); -extern int TIFFRGBAImageOK(TIFF*, char [1024]); -extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); -extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32); -extern void TIFFRGBAImageEnd(TIFFRGBAImage*); -extern TIFF* TIFFOpen(const char*, const char*); -# ifdef __WIN32__ -extern TIFF* TIFFOpenW(const wchar_t*, const char*); -# endif /* __WIN32__ */ -extern TIFF* TIFFFdOpen(int, const char*, const char*); -extern TIFF* TIFFClientOpen(const char*, const char*, - thandle_t, - TIFFReadWriteProc, TIFFReadWriteProc, - TIFFSeekProc, TIFFCloseProc, - TIFFSizeProc, - TIFFMapFileProc, TIFFUnmapFileProc); -extern const char* TIFFFileName(TIFF*); -extern const char* TIFFSetFileName(TIFF*, const char *); -extern void TIFFError(const char*, const char*, ...) __attribute__((format (printf,2,3))); -extern void TIFFErrorExt(thandle_t, const char*, const char*, ...) __attribute__((format (printf,3,4))); -extern void TIFFWarning(const char*, const char*, ...) __attribute__((format (printf,2,3))); -extern void TIFFWarningExt(thandle_t, const char*, const char*, ...) __attribute__((format (printf,3,4))); -extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); -extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt); -extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); -extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt); -extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc); -extern ttile_t TIFFComputeTile(TIFF*, uint32, uint32, uint32, tsample_t); -extern int TIFFCheckTile(TIFF*, uint32, uint32, uint32, tsample_t); -extern ttile_t TIFFNumberOfTiles(TIFF*); -extern tsize_t TIFFReadTile(TIFF*, - tdata_t, uint32, uint32, uint32, tsample_t); -extern tsize_t TIFFWriteTile(TIFF*, - tdata_t, uint32, uint32, uint32, tsample_t); -extern tstrip_t TIFFComputeStrip(TIFF*, uint32, tsample_t); -extern tstrip_t TIFFNumberOfStrips(TIFF*); -extern tsize_t TIFFReadEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t); -extern tsize_t TIFFReadRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t); -extern tsize_t TIFFReadEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t); -extern tsize_t TIFFReadRawTile(TIFF*, ttile_t, tdata_t, tsize_t); -extern tsize_t TIFFWriteEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t); -extern tsize_t TIFFWriteRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t); -extern tsize_t TIFFWriteEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t); -extern tsize_t TIFFWriteRawTile(TIFF*, ttile_t, tdata_t, tsize_t); -extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */ -extern void TIFFSetWriteOffset(TIFF*, toff_t); -extern void TIFFSwabShort(uint16*); -extern void TIFFSwabLong(uint32*); -extern void TIFFSwabDouble(double*); -extern void TIFFSwabArrayOfShort(uint16*, unsigned long); -extern void TIFFSwabArrayOfTriples(uint8*, unsigned long); -extern void TIFFSwabArrayOfLong(uint32*, unsigned long); -extern void TIFFSwabArrayOfDouble(double*, unsigned long); -extern void TIFFReverseBits(unsigned char *, unsigned long); -extern const unsigned char* TIFFGetBitRevTable(int); - -#ifdef LOGLUV_PUBLIC -#define U_NEU 0.210526316 -#define V_NEU 0.473684211 -#define UVSCALE 410. -extern double LogL16toY(int); -extern double LogL10toY(int); -extern void XYZtoRGB24(float*, uint8*); -extern int uv_decode(double*, double*, int); -extern void LogLuv24toXYZ(uint32, float*); -extern void LogLuv32toXYZ(uint32, float*); -#if defined(c_plusplus) || defined(__cplusplus) -extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER); -extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER); -extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER); -extern uint32 LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER); -extern uint32 LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER); -#else -extern int LogL16fromY(double, int); -extern int LogL10fromY(double, int); -extern int uv_encode(double, double, int); -extern uint32 LogLuv24fromXYZ(float*, int); -extern uint32 LogLuv32fromXYZ(float*, int); -#endif -#endif /* LOGLUV_PUBLIC */ - -extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, TIFFDisplay *, float*); -extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32, - float *, float *, float *); -extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, - uint32 *, uint32 *, uint32 *); - -extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*); -extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32, - uint32 *, uint32 *, uint32 *); - -#if defined(c_plusplus) || defined(__cplusplus) -} -#endif - -#endif /* _TIFFIO_ */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tiffio.hxx b/plugins/AdvaImg/src/LibTIFF/tiffio.hxx deleted file mode 100644 index fc20d725d2..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tiffio.hxx +++ /dev/null @@ -1,49 +0,0 @@ -/* $Id: tiffio.hxx,v 1.32 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFFIO_HXX_ -#define _TIFFIO_HXX_ - -/* - * TIFF I/O library definitions which provide C++ streams API. - */ - -#include -#include "tiff.h" - -extern TIFF* TIFFStreamOpen(const char*, std::ostream *); -extern TIFF* TIFFStreamOpen(const char*, std::istream *); - -#endif /* _TIFFIO_HXX_ */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c++ - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tiffiop.h b/plugins/AdvaImg/src/LibTIFF/tiffiop.h deleted file mode 100644 index 1a64862810..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tiffiop.h +++ /dev/null @@ -1,353 +0,0 @@ -/* $Id: tiffiop.h,v 1.37 2011/04/10 17:14:09 drolon Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFFIOP_ -#define _TIFFIOP_ -/* - * ``Library-private'' definitions. - */ - -#include "tif_config.h" - -#ifdef HAVE_FCNTL_H -# include -#endif - -#ifdef HAVE_SYS_TYPES_H -# include -#endif - -#ifdef HAVE_STRING_H -# include -#endif - -#ifdef HAVE_ASSERT_H -# include -#else -# define assert(x) -#endif - -#ifdef HAVE_SEARCH_H -# include -#else -extern void *lfind(const void *, const void *, size_t *, size_t, - int (*)(const void *, const void *)); -#endif - -/* - Libtiff itself does not require a 64-bit type, but bundled TIFF - utilities may use it. -*/ - -#if !defined(__xlC__) && !defined(__xlc__) // Already defined there (#2301) -#define TIFF_INT64_T signed long long -#define TIFF_UINT64_T unsigned long long -#endif - -#include "tiffio.h" -#include "tif_dir.h" - -#ifndef STRIP_SIZE_DEFAULT -# define STRIP_SIZE_DEFAULT 8192 -#endif - -#define streq(a,b) (strcmp(a,b) == 0) - -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif - -typedef struct client_info { - struct client_info *next; - void *data; - char *name; -} TIFFClientInfoLink; - -/* - * Typedefs for ``method pointers'' used internally. - */ -typedef unsigned char tidataval_t; /* internal image data value type */ -typedef tidataval_t* tidata_t; /* reference to internal image data */ - -typedef void (*TIFFVoidMethod)(TIFF*); -typedef int (*TIFFBoolMethod)(TIFF*); -typedef int (*TIFFPreMethod)(TIFF*, tsample_t); -typedef int (*TIFFCodeMethod)(TIFF*, tidata_t, tsize_t, tsample_t); -typedef int (*TIFFSeekMethod)(TIFF*, uint32); -typedef void (*TIFFPostMethod)(TIFF*, tidata_t, tsize_t); -typedef uint32 (*TIFFStripMethod)(TIFF*, uint32); -typedef void (*TIFFTileMethod)(TIFF*, uint32*, uint32*); - -struct tiff { - char* tif_name; /* name of open file */ - int tif_fd; /* open file descriptor */ - int tif_mode; /* open mode (O_*) */ - uint32 tif_flags; -#define TIFF_FILLORDER 0x00003 /* natural bit fill order for machine */ -#define TIFF_DIRTYHEADER 0x00004 /* header must be written on close */ -#define TIFF_DIRTYDIRECT 0x00008 /* current directory must be written */ -#define TIFF_BUFFERSETUP 0x00010 /* data buffers setup */ -#define TIFF_CODERSETUP 0x00020 /* encoder/decoder setup done */ -#define TIFF_BEENWRITING 0x00040 /* written 1+ scanlines to file */ -#define TIFF_SWAB 0x00080 /* byte swap file information */ -#define TIFF_NOBITREV 0x00100 /* inhibit bit reversal logic */ -#define TIFF_MYBUFFER 0x00200 /* my raw data buffer; free on close */ -#define TIFF_ISTILED 0x00400 /* file is tile, not strip- based */ -#define TIFF_MAPPED 0x00800 /* file is mapped into memory */ -#define TIFF_POSTENCODE 0x01000 /* need call to postencode routine */ -#define TIFF_INSUBIFD 0x02000 /* currently writing a subifd */ -#define TIFF_UPSAMPLED 0x04000 /* library is doing data up-sampling */ -#define TIFF_STRIPCHOP 0x08000 /* enable strip chopping support */ -#define TIFF_HEADERONLY 0x10000 /* read header only, do not process */ - /* the first directory */ -#define TIFF_NOREADRAW 0x20000 /* skip reading of raw uncompressed */ - /* image data */ -#define TIFF_INCUSTOMIFD 0x40000 /* currently writing a custom IFD */ - toff_t tif_diroff; /* file offset of current directory */ - toff_t tif_nextdiroff; /* file offset of following directory */ - toff_t* tif_dirlist; /* list of offsets to already seen */ - /* directories to prevent IFD looping */ - tsize_t tif_dirlistsize;/* number of entires in offset list */ - uint16 tif_dirnumber; /* number of already seen directories */ - TIFFDirectory tif_dir; /* internal rep of current directory */ - TIFFDirectory tif_customdir; /* custom IFDs are separated from - the main ones */ - TIFFHeader tif_header; /* file's header block */ - const int* tif_typeshift; /* data type shift counts */ - const long* tif_typemask; /* data type masks */ - uint32 tif_row; /* current scanline */ - tdir_t tif_curdir; /* current directory (index) */ - tstrip_t tif_curstrip; /* current strip for read/write */ - toff_t tif_curoff; /* current offset for read/write */ - toff_t tif_dataoff; /* current offset for writing dir */ -/* SubIFD support */ - uint16 tif_nsubifd; /* remaining subifds to write */ - toff_t tif_subifdoff; /* offset for patching SubIFD link */ -/* tiling support */ - uint32 tif_col; /* current column (offset by row too) */ - ttile_t tif_curtile; /* current tile for read/write */ - tsize_t tif_tilesize; /* # of bytes in a tile */ -/* compression scheme hooks */ - int tif_decodestatus; - TIFFBoolMethod tif_setupdecode;/* called once before predecode */ - TIFFPreMethod tif_predecode; /* pre- row/strip/tile decoding */ - TIFFBoolMethod tif_setupencode;/* called once before preencode */ - int tif_encodestatus; - TIFFPreMethod tif_preencode; /* pre- row/strip/tile encoding */ - TIFFBoolMethod tif_postencode; /* post- row/strip/tile encoding */ - TIFFCodeMethod tif_decoderow; /* scanline decoding routine */ - TIFFCodeMethod tif_encoderow; /* scanline encoding routine */ - TIFFCodeMethod tif_decodestrip;/* strip decoding routine */ - TIFFCodeMethod tif_encodestrip;/* strip encoding routine */ - TIFFCodeMethod tif_decodetile; /* tile decoding routine */ - TIFFCodeMethod tif_encodetile; /* tile encoding routine */ - TIFFVoidMethod tif_close; /* cleanup-on-close routine */ - TIFFSeekMethod tif_seek; /* position within a strip routine */ - TIFFVoidMethod tif_cleanup; /* cleanup state routine */ - TIFFStripMethod tif_defstripsize;/* calculate/constrain strip size */ - TIFFTileMethod tif_deftilesize;/* calculate/constrain tile size */ - tidata_t tif_data; /* compression scheme private data */ -/* input/output buffering */ - tsize_t tif_scanlinesize;/* # of bytes in a scanline */ - tsize_t tif_scanlineskew;/* scanline skew for reading strips */ - tidata_t tif_rawdata; /* raw data buffer */ - tsize_t tif_rawdatasize;/* # of bytes in raw data buffer */ - tidata_t tif_rawcp; /* current spot in raw buffer */ - tsize_t tif_rawcc; /* bytes unread from raw buffer */ -/* memory-mapped file support */ - tidata_t tif_base; /* base of mapped file */ - toff_t tif_size; /* size of mapped file region (bytes) - FIXME: it should be tsize_t */ - TIFFMapFileProc tif_mapproc; /* map file method */ - TIFFUnmapFileProc tif_unmapproc;/* unmap file method */ -/* input/output callback methods */ - thandle_t tif_clientdata; /* callback parameter */ - TIFFReadWriteProc tif_readproc; /* read method */ - TIFFReadWriteProc tif_writeproc;/* write method */ - TIFFSeekProc tif_seekproc; /* lseek method */ - TIFFCloseProc tif_closeproc; /* close method */ - TIFFSizeProc tif_sizeproc; /* filesize method */ -/* post-decoding support */ - TIFFPostMethod tif_postdecode; /* post decoding routine */ -/* tag support */ - TIFFFieldInfo** tif_fieldinfo; /* sorted table of registered tags */ - size_t tif_nfields; /* # entries in registered tag table */ - const TIFFFieldInfo *tif_foundfield;/* cached pointer to already found tag */ - TIFFTagMethods tif_tagmethods; /* tag get/set/print routines */ - TIFFClientInfoLink *tif_clientinfo; /* extra client information. */ -}; - -#define isPseudoTag(t) (t > 0xffff) /* is tag value normal or pseudo */ - -#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0) -#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0) -#define isFillOrder(tif, o) (((tif)->tif_flags & (o)) != 0) -#define isUpSampled(tif) (((tif)->tif_flags & TIFF_UPSAMPLED) != 0) -#define TIFFReadFile(tif, buf, size) \ - ((*(tif)->tif_readproc)((tif)->tif_clientdata,buf,size)) -#define TIFFWriteFile(tif, buf, size) \ - ((*(tif)->tif_writeproc)((tif)->tif_clientdata,buf,size)) -#define TIFFSeekFile(tif, off, whence) \ - ((*(tif)->tif_seekproc)((tif)->tif_clientdata,(toff_t)(off),whence)) -#define TIFFCloseFile(tif) \ - ((*(tif)->tif_closeproc)((tif)->tif_clientdata)) -#define TIFFGetFileSize(tif) \ - ((*(tif)->tif_sizeproc)((tif)->tif_clientdata)) -#define TIFFMapFileContents(tif, paddr, psize) \ - ((*(tif)->tif_mapproc)((tif)->tif_clientdata,paddr,psize)) -#define TIFFUnmapFileContents(tif, addr, size) \ - ((*(tif)->tif_unmapproc)((tif)->tif_clientdata,addr,size)) - -/* - * Default Read/Seek/Write definitions. - */ -#ifndef ReadOK -#define ReadOK(tif, buf, size) \ - (TIFFReadFile(tif, (tdata_t) buf, (tsize_t)(size)) == (tsize_t)(size)) -#endif -#ifndef SeekOK -#define SeekOK(tif, off) \ - (TIFFSeekFile(tif, (toff_t) off, SEEK_SET) == (toff_t) off) -#endif -#ifndef WriteOK -#define WriteOK(tif, buf, size) \ - (TIFFWriteFile(tif, (tdata_t) buf, (tsize_t) size) == (tsize_t) size) -#endif - -/* NB: the uint32 casts are to silence certain ANSI-C compilers */ -#define TIFFhowmany(x, y) (((uint32)x < (0xffffffff - (uint32)(y-1))) ? \ - ((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y))) : \ - 0U) -#define TIFFhowmany8(x) (((x)&0x07)?((uint32)(x)>>3)+1:(uint32)(x)>>3) -#define TIFFroundup(x, y) (TIFFhowmany(x,y)*(y)) - -/* Safe multiply which returns zero if there is an integer overflow */ -#define TIFFSafeMultiply(t,v,m) ((((t)m != (t)0) && (((t)((v*m)/m)) == (t)v)) ? (t)(v*m) : (t)0) - -#define TIFFmax(A,B) ((A)>(B)?(A):(B)) -#define TIFFmin(A,B) ((A)<(B)?(A):(B)) - -#define TIFFArrayCount(a) (sizeof (a) / sizeof ((a)[0])) - -#if defined(__cplusplus) -extern "C" { -#endif -extern int _TIFFgetMode(const char*, const char*); -extern int _TIFFNoRowEncode(TIFF*, tidata_t, tsize_t, tsample_t); -extern int _TIFFNoStripEncode(TIFF*, tidata_t, tsize_t, tsample_t); -extern int _TIFFNoTileEncode(TIFF*, tidata_t, tsize_t, tsample_t); -extern int _TIFFNoRowDecode(TIFF*, tidata_t, tsize_t, tsample_t); -extern int _TIFFNoStripDecode(TIFF*, tidata_t, tsize_t, tsample_t); -extern int _TIFFNoTileDecode(TIFF*, tidata_t, tsize_t, tsample_t); -extern void _TIFFNoPostDecode(TIFF*, tidata_t, tsize_t); -extern int _TIFFNoPreCode (TIFF*, tsample_t); -extern int _TIFFNoSeek(TIFF*, uint32); -extern void _TIFFSwab16BitData(TIFF*, tidata_t, tsize_t); -extern void _TIFFSwab24BitData(TIFF*, tidata_t, tsize_t); -extern void _TIFFSwab32BitData(TIFF*, tidata_t, tsize_t); -extern void _TIFFSwab64BitData(TIFF*, tidata_t, tsize_t); -extern int TIFFFlushData1(TIFF*); -extern int TIFFDefaultDirectory(TIFF*); -extern void _TIFFSetDefaultCompressionState(TIFF*); -extern int TIFFSetCompressionScheme(TIFF*, int); -extern int TIFFSetDefaultCompressionState(TIFF*); -extern uint32 _TIFFDefaultStripSize(TIFF*, uint32); -extern void _TIFFDefaultTileSize(TIFF*, uint32*, uint32*); -extern int _TIFFDataSize(TIFFDataType); - -extern void _TIFFsetByteArray(void**, void*, uint32); -extern void _TIFFsetString(char**, char*); -extern void _TIFFsetShortArray(uint16**, uint16*, uint32); -extern void _TIFFsetLongArray(uint32**, uint32*, uint32); -extern void _TIFFsetFloatArray(float**, float*, uint32); -extern void _TIFFsetDoubleArray(double**, double*, uint32); - -extern void _TIFFprintAscii(FILE*, const char*); -extern void _TIFFprintAsciiTag(FILE*, const char*, const char*); - -extern TIFFErrorHandler _TIFFwarningHandler; -extern TIFFErrorHandler _TIFFerrorHandler; -extern TIFFErrorHandlerExt _TIFFwarningHandlerExt; -extern TIFFErrorHandlerExt _TIFFerrorHandlerExt; - -extern tdata_t _TIFFCheckMalloc(TIFF*, size_t, size_t, const char*); -extern tdata_t _TIFFCheckRealloc(TIFF*, tdata_t, size_t, size_t, const char*); - -extern int TIFFInitDumpMode(TIFF*, int); -#ifdef PACKBITS_SUPPORT -extern int TIFFInitPackBits(TIFF*, int); -#endif -#ifdef CCITT_SUPPORT -extern int TIFFInitCCITTRLE(TIFF*, int), TIFFInitCCITTRLEW(TIFF*, int); -extern int TIFFInitCCITTFax3(TIFF*, int), TIFFInitCCITTFax4(TIFF*, int); -#endif -#ifdef THUNDER_SUPPORT -extern int TIFFInitThunderScan(TIFF*, int); -#endif -#ifdef NEXT_SUPPORT -extern int TIFFInitNeXT(TIFF*, int); -#endif -#ifdef LZW_SUPPORT -extern int TIFFInitLZW(TIFF*, int); -#endif -#ifdef OJPEG_SUPPORT -extern int TIFFInitOJPEG(TIFF*, int); -#endif -#ifdef JPEG_SUPPORT -extern int TIFFInitJPEG(TIFF*, int); -#endif -#ifdef JBIG_SUPPORT -extern int TIFFInitJBIG(TIFF*, int); -#endif -#ifdef ZIP_SUPPORT -extern int TIFFInitZIP(TIFF*, int); -#endif -#ifdef PIXARLOG_SUPPORT -extern int TIFFInitPixarLog(TIFF*, int); -#endif -#ifdef LOGLUV_SUPPORT -extern int TIFFInitSGILog(TIFF*, int); -#endif -#ifdef VMS -extern const TIFFCodec _TIFFBuiltinCODECS[]; -#else -extern TIFFCodec _TIFFBuiltinCODECS[]; -#endif - -#if defined(__cplusplus) -} -#endif -#endif /* _TIFFIOP_ */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/LibTIFF/tiffvers.h b/plugins/AdvaImg/src/LibTIFF/tiffvers.h deleted file mode 100644 index 594702b566..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/tiffvers.h +++ /dev/null @@ -1,9 +0,0 @@ -#define TIFFLIB_VERSION_STR "LIBTIFF, Version 3.9.5\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." -/* - * This define can be used in code that requires - * compilation-related definitions specific to a - * version or versions of the library. Runtime - * version checking should be done based on the - * string returned by TIFFGetVersion. - */ -#define TIFFLIB_VERSION 20110409 diff --git a/plugins/AdvaImg/src/LibTIFF/uvcode.h b/plugins/AdvaImg/src/LibTIFF/uvcode.h deleted file mode 100644 index 8f22325703..0000000000 --- a/plugins/AdvaImg/src/LibTIFF/uvcode.h +++ /dev/null @@ -1,180 +0,0 @@ -/* Version 1.0 generated April 7, 1997 by Greg Ward Larson, SGI */ -#define UV_SQSIZ (float)0.003500 -#define UV_NDIVS 16289 -#define UV_VSTART (float)0.016940 -#define UV_NVS 163 -static struct { - float ustart; - short nus, ncum; -} uv_row[UV_NVS] = { - { (float)0.247663, 4, 0 }, - { (float)0.243779, 6, 4 }, - { (float)0.241684, 7, 10 }, - { (float)0.237874, 9, 17 }, - { (float)0.235906, 10, 26 }, - { (float)0.232153, 12, 36 }, - { (float)0.228352, 14, 48 }, - { (float)0.226259, 15, 62 }, - { (float)0.222371, 17, 77 }, - { (float)0.220410, 18, 94 }, - { (float)0.214710, 21, 112 }, - { (float)0.212714, 22, 133 }, - { (float)0.210721, 23, 155 }, - { (float)0.204976, 26, 178 }, - { (float)0.202986, 27, 204 }, - { (float)0.199245, 29, 231 }, - { (float)0.195525, 31, 260 }, - { (float)0.193560, 32, 291 }, - { (float)0.189878, 34, 323 }, - { (float)0.186216, 36, 357 }, - { (float)0.186216, 36, 393 }, - { (float)0.182592, 38, 429 }, - { (float)0.179003, 40, 467 }, - { (float)0.175466, 42, 507 }, - { (float)0.172001, 44, 549 }, - { (float)0.172001, 44, 593 }, - { (float)0.168612, 46, 637 }, - { (float)0.168612, 46, 683 }, - { (float)0.163575, 49, 729 }, - { (float)0.158642, 52, 778 }, - { (float)0.158642, 52, 830 }, - { (float)0.158642, 52, 882 }, - { (float)0.153815, 55, 934 }, - { (float)0.153815, 55, 989 }, - { (float)0.149097, 58, 1044 }, - { (float)0.149097, 58, 1102 }, - { (float)0.142746, 62, 1160 }, - { (float)0.142746, 62, 1222 }, - { (float)0.142746, 62, 1284 }, - { (float)0.138270, 65, 1346 }, - { (float)0.138270, 65, 1411 }, - { (float)0.138270, 65, 1476 }, - { (float)0.132166, 69, 1541 }, - { (float)0.132166, 69, 1610 }, - { (float)0.126204, 73, 1679 }, - { (float)0.126204, 73, 1752 }, - { (float)0.126204, 73, 1825 }, - { (float)0.120381, 77, 1898 }, - { (float)0.120381, 77, 1975 }, - { (float)0.120381, 77, 2052 }, - { (float)0.120381, 77, 2129 }, - { (float)0.112962, 82, 2206 }, - { (float)0.112962, 82, 2288 }, - { (float)0.112962, 82, 2370 }, - { (float)0.107450, 86, 2452 }, - { (float)0.107450, 86, 2538 }, - { (float)0.107450, 86, 2624 }, - { (float)0.107450, 86, 2710 }, - { (float)0.100343, 91, 2796 }, - { (float)0.100343, 91, 2887 }, - { (float)0.100343, 91, 2978 }, - { (float)0.095126, 95, 3069 }, - { (float)0.095126, 95, 3164 }, - { (float)0.095126, 95, 3259 }, - { (float)0.095126, 95, 3354 }, - { (float)0.088276, 100, 3449 }, - { (float)0.088276, 100, 3549 }, - { (float)0.088276, 100, 3649 }, - { (float)0.088276, 100, 3749 }, - { (float)0.081523, 105, 3849 }, - { (float)0.081523, 105, 3954 }, - { (float)0.081523, 105, 4059 }, - { (float)0.081523, 105, 4164 }, - { (float)0.074861, 110, 4269 }, - { (float)0.074861, 110, 4379 }, - { (float)0.074861, 110, 4489 }, - { (float)0.074861, 110, 4599 }, - { (float)0.068290, 115, 4709 }, - { (float)0.068290, 115, 4824 }, - { (float)0.068290, 115, 4939 }, - { (float)0.068290, 115, 5054 }, - { (float)0.063573, 119, 5169 }, - { (float)0.063573, 119, 5288 }, - { (float)0.063573, 119, 5407 }, - { (float)0.063573, 119, 5526 }, - { (float)0.057219, 124, 5645 }, - { (float)0.057219, 124, 5769 }, - { (float)0.057219, 124, 5893 }, - { (float)0.057219, 124, 6017 }, - { (float)0.050985, 129, 6141 }, - { (float)0.050985, 129, 6270 }, - { (float)0.050985, 129, 6399 }, - { (float)0.050985, 129, 6528 }, - { (float)0.050985, 129, 6657 }, - { (float)0.044859, 134, 6786 }, - { (float)0.044859, 134, 6920 }, - { (float)0.044859, 134, 7054 }, - { (float)0.044859, 134, 7188 }, - { (float)0.040571, 138, 7322 }, - { (float)0.040571, 138, 7460 }, - { (float)0.040571, 138, 7598 }, - { (float)0.040571, 138, 7736 }, - { (float)0.036339, 142, 7874 }, - { (float)0.036339, 142, 8016 }, - { (float)0.036339, 142, 8158 }, - { (float)0.036339, 142, 8300 }, - { (float)0.032139, 146, 8442 }, - { (float)0.032139, 146, 8588 }, - { (float)0.032139, 146, 8734 }, - { (float)0.032139, 146, 8880 }, - { (float)0.027947, 150, 9026 }, - { (float)0.027947, 150, 9176 }, - { (float)0.027947, 150, 9326 }, - { (float)0.023739, 154, 9476 }, - { (float)0.023739, 154, 9630 }, - { (float)0.023739, 154, 9784 }, - { (float)0.023739, 154, 9938 }, - { (float)0.019504, 158, 10092 }, - { (float)0.019504, 158, 10250 }, - { (float)0.019504, 158, 10408 }, - { (float)0.016976, 161, 10566 }, - { (float)0.016976, 161, 10727 }, - { (float)0.016976, 161, 10888 }, - { (float)0.016976, 161, 11049 }, - { (float)0.012639, 165, 11210 }, - { (float)0.012639, 165, 11375 }, - { (float)0.012639, 165, 11540 }, - { (float)0.009991, 168, 11705 }, - { (float)0.009991, 168, 11873 }, - { (float)0.009991, 168, 12041 }, - { (float)0.009016, 170, 12209 }, - { (float)0.009016, 170, 12379 }, - { (float)0.009016, 170, 12549 }, - { (float)0.006217, 173, 12719 }, - { (float)0.006217, 173, 12892 }, - { (float)0.005097, 175, 13065 }, - { (float)0.005097, 175, 13240 }, - { (float)0.005097, 175, 13415 }, - { (float)0.003909, 177, 13590 }, - { (float)0.003909, 177, 13767 }, - { (float)0.002340, 177, 13944 }, - { (float)0.002389, 170, 14121 }, - { (float)0.001068, 164, 14291 }, - { (float)0.001653, 157, 14455 }, - { (float)0.000717, 150, 14612 }, - { (float)0.001614, 143, 14762 }, - { (float)0.000270, 136, 14905 }, - { (float)0.000484, 129, 15041 }, - { (float)0.001103, 123, 15170 }, - { (float)0.001242, 115, 15293 }, - { (float)0.001188, 109, 15408 }, - { (float)0.001011, 103, 15517 }, - { (float)0.000709, 97, 15620 }, - { (float)0.000301, 89, 15717 }, - { (float)0.002416, 82, 15806 }, - { (float)0.003251, 76, 15888 }, - { (float)0.003246, 69, 15964 }, - { (float)0.004141, 62, 16033 }, - { (float)0.005963, 55, 16095 }, - { (float)0.008839, 47, 16150 }, - { (float)0.010490, 40, 16197 }, - { (float)0.016994, 31, 16237 }, - { (float)0.023659, 21, 16268 }, -}; -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/plugins/AdvaImg/src/Metadata/Exif.cpp b/plugins/AdvaImg/src/Metadata/Exif.cpp index 7d0955c5db..ed667b0974 100644 --- a/plugins/AdvaImg/src/Metadata/Exif.cpp +++ b/plugins/AdvaImg/src/Metadata/Exif.cpp @@ -69,7 +69,7 @@ static int FreeImage_strnicmp(const char *s1, const char *s2, size_t len) { unsigned char c1, c2; - if (!s1 || !s2) return -1; + if(!s1 || !s2) return -1; c1 = 0; c2 = 0; if(len) { @@ -182,7 +182,7 @@ processMakerNote(FIBITMAP *dib, char *pval, BOOL msb_order, DWORD *subdirOffset, FreeImage_GetMetadata(FIMD_EXIF_MAIN, dib, "Make", &tagMake); const char *Maker = (char*)FreeImage_GetTagValue(tagMake); - if ((memcmp("OLYMP\x00\x01", pval, 7) == 0) || (memcmp("OLYMP\x00\x02", pval, 7) == 0) || (memcmp("EPSON", pval, 5) == 0) || (memcmp("AGFA", pval, 4) == 0)) { + if((memcmp("OLYMP\x00\x01", pval, 7) == 0) || (memcmp("OLYMP\x00\x02", pval, 7) == 0) || (memcmp("EPSON", pval, 5) == 0) || (memcmp("AGFA", pval, 4) == 0)) { // Olympus Type 1 Makernote // Epson and Agfa use Olympus maker note standard, // see: http://www.ozhiker.com/electronics/pjmt/jpeg_info/ @@ -280,11 +280,11 @@ processMakerNote(FIBITMAP *dib, char *pval, BOOL msb_order, DWORD *subdirOffset, *subdirOffset = 0; } } - else if ((memcmp("SONY CAM\x20\x00\x00\x00", pval, 12) == 0) || (memcmp("SONY DSC\x20\x00\x00\x00", pval, 12) == 0)) { + else if((memcmp("SONY CAM\x20\x00\x00\x00", pval, 12) == 0) || (memcmp("SONY DSC\x20\x00\x00\x00", pval, 12) == 0)) { *md_model = TagLib::EXIF_MAKERNOTE_SONY; *subdirOffset = 12; } - else if ((memcmp("SIGMA\x00\x00\x00", pval, 8) == 0) || (memcmp("FOVEON\x00\x00", pval, 8) == 0)) { + else if((memcmp("SIGMA\x00\x00\x00", pval, 8) == 0) || (memcmp("FOVEON\x00\x00", pval, 8) == 0)) { FITAG *tagModel = NULL; FreeImage_GetMetadata(FIMD_EXIF_MAIN, dib, "Model", &tagModel); const char *Model = (char*)FreeImage_GetTagValue(tagModel); @@ -365,7 +365,7 @@ processCanonMakerNoteTag(FIBITMAP *dib, FITAG *tag) { // create a tag FITAG *canonTag = FreeImage_CreateTag(); - if (!canonTag) return FALSE; + if(!canonTag) return FALSE; // we intentionally skip the first array member (if needed) for (DWORD i = startIndex; i < FreeImage_GetTagCount(tag); i++) { @@ -560,7 +560,7 @@ jpeg_read_exif_dir(FIBITMAP *dib, const BYTE *tiffp, unsigned long offset, unsig do { // if there is anything on the stack then pop it off - if (!destack.empty()) { + if(!destack.empty()) { ifdp = ifdstack.top(); ifdstack.pop(); de = destack.top(); destack.pop(); md_model = modelstack.top(); modelstack.pop(); @@ -577,13 +577,13 @@ jpeg_read_exif_dir(FIBITMAP *dib, const BYTE *tiffp, unsigned long offset, unsig // determine how many entries there are in the current IFD nde = ReadUint16(msb_order, ifdp); - for (; de < nde; de++) { + for(; de < nde; de++) { char *pde = NULL; // pointer to the directory entry char *pval = NULL; // pointer to the tag value // create a tag FITAG *tag = FreeImage_CreateTag(); - if (!tag) return FALSE; + if(!tag) return FALSE; // point to the directory entry pde = (char*) DIR_ENTRY_ADDR(ifdp, de); @@ -592,7 +592,7 @@ jpeg_read_exif_dir(FIBITMAP *dib, const BYTE *tiffp, unsigned long offset, unsig FreeImage_SetTagID(tag, ReadUint16(msb_order, pde)); // get the tag type WORD tag_type = (WORD)ReadUint16(msb_order, pde + 2); - if ((tag_type - 1) >= EXIF_NUM_FORMATS) { + if((tag_type - 1) >= EXIF_NUM_FORMATS) { // a problem occured : delete the tag (not free'd after) FreeImage_DeleteTag(tag); // break out of the for loop @@ -658,7 +658,7 @@ jpeg_read_exif_dir(FIBITMAP *dib, const BYTE *tiffp, unsigned long offset, unsig next_ifd = (BYTE*)tiffp + sub_offset; } - if ((sub_offset < (DWORD) length) && (next_mdmodel != TagLib::UNKNOWN)) { + if((sub_offset < (DWORD) length) && (next_mdmodel != TagLib::UNKNOWN)) { // push our current directory state onto the stack ifdstack.push(ifdp); // bump to the next entry @@ -675,7 +675,7 @@ jpeg_read_exif_dir(FIBITMAP *dib, const BYTE *tiffp, unsigned long offset, unsig // select a new metadata model modelstack.push(next_mdmodel); - // delete the tag as it won't be stored nor deleted in the for () loop + // delete the tag as it won't be stored nor deleted in the for() loop FreeImage_DeleteTag(tag); break; // break out of the for loop @@ -707,7 +707,7 @@ jpeg_read_exif_dir(FIBITMAP *dib, const BYTE *tiffp, unsigned long offset, unsig const WORD entriesCount0th = ReadUint16(msb_order, ifd0th); DWORD next_offset = ReadUint32(msb_order, DIR_ENTRY_ADDR(ifd0th, entriesCount0th)); - if ((next_offset == 0) || (next_offset >= length)) { + if((next_offset == 0) || (next_offset >= length)) { return TRUE; //< no thumbnail } @@ -763,7 +763,7 @@ jpeg_read_exif_dir(FIBITMAP *dib, const BYTE *tiffp, unsigned long offset, unsig } } - if (/*thCompression != 6 ||*/ thOffset == 0 || thSize == 0) { + if(/*thCompression != 6 ||*/ thOffset == 0 || thSize == 0) { return TRUE; } diff --git a/plugins/AdvaImg/src/Metadata/FreeImageTag.cpp b/plugins/AdvaImg/src/Metadata/FreeImageTag.cpp index 84e15d0822..5d9f3034ec 100644 --- a/plugins/AdvaImg/src/Metadata/FreeImageTag.cpp +++ b/plugins/AdvaImg/src/Metadata/FreeImageTag.cpp @@ -81,11 +81,11 @@ FreeImage_DeleteTag(FITAG *tag) { FITAG * DLL_CALLCONV FreeImage_CloneTag(FITAG *tag) { - if (!tag) return NULL; + if(!tag) return NULL; // allocate a new tag FITAG *clone = FreeImage_CreateTag(); - if (!clone) return NULL; + if(!clone) return NULL; try { // copy the tag @@ -97,7 +97,7 @@ FreeImage_CloneTag(FITAG *tag) { // tag key if(src_tag->key) { dst_tag->key = (char*)malloc((strlen(src_tag->key) + 1) * sizeof(char)); - if (!dst_tag->key) { + if(!dst_tag->key) { throw FI_MSG_ERROR_MEMORY; } strcpy(dst_tag->key, src_tag->key); @@ -105,7 +105,7 @@ FreeImage_CloneTag(FITAG *tag) { // tag description if(src_tag->description) { dst_tag->description = (char*)malloc((strlen(src_tag->description) + 1) * sizeof(char)); - if (!dst_tag->description) { + if(!dst_tag->description) { throw FI_MSG_ERROR_MEMORY; } strcpy(dst_tag->description, src_tag->description); @@ -118,7 +118,7 @@ FreeImage_CloneTag(FITAG *tag) { dst_tag->length = src_tag->length; // tag value dst_tag->value = (BYTE*)malloc(src_tag->length * sizeof(BYTE)); - if (!dst_tag->value) { + if(!dst_tag->value) { throw FI_MSG_ERROR_MEMORY; } memcpy(dst_tag->value, src_tag->value, src_tag->length); @@ -253,7 +253,7 @@ FreeImage_SetTagValue(FITAG *tag, const void *value) { case FIDT_ASCII: { tag_header->value = (char*)malloc((tag_header->length + 1) * sizeof(char)); - if (!tag_header->value) { + if(!tag_header->value) { return FALSE; } char *src_data = (char*)value; @@ -267,7 +267,7 @@ FreeImage_SetTagValue(FITAG *tag, const void *value) { default: tag_header->value = malloc(tag_header->length * sizeof(BYTE)); - if (!tag_header->value) { + if(!tag_header->value) { return FALSE; } memcpy(tag_header->value, value, tag_header->length); diff --git a/plugins/AdvaImg/src/Metadata/FreeImageTag.h b/plugins/AdvaImg/src/Metadata/FreeImageTag.h index f412603e8d..4f3bffa1ce 100644 --- a/plugins/AdvaImg/src/Metadata/FreeImageTag.h +++ b/plugins/AdvaImg/src/Metadata/FreeImageTag.h @@ -312,14 +312,24 @@ typedef struct tagTagInfo { /** - Class to hold tag information (based on Meyers’ Singleton).
- - Sample usage :
- - TagLib& s = TagLib::instance(); - TagInfo *tag_info = s.getTagInfo(EXIF_MAIN, 0x0100); - - +Class to hold tag information (based on Meyers’ Singleton).
+ +Sample usage :
+ +TagLib& s = TagLib::instance(); +TagInfo *tag_info = s.getTagInfo(EXIF_MAIN, 0x0100); + + +Note on multi-threaded applications : + +The singleton pattern must be carefully constructed in multi-threaded applications. +If two threads are to execute the creation method at the same time when a singleton +does not yet exist, they both must check for an instance of the singleton and then +only one should create the new one. +The classic solution to this problem is to use mutual exclusion on the class that +indicates that the object is being instantiated. +The FreeImage solution is to instantiate the singleton before any other thread is launched, +i.e. inside the FreeImage_Initialise function (see Plugin.cpp). */ class TagLib { diff --git a/plugins/AdvaImg/src/Metadata/IPTC.cpp b/plugins/AdvaImg/src/Metadata/IPTC.cpp index 817beddf98..bde718c986 100644 --- a/plugins/AdvaImg/src/Metadata/IPTC.cpp +++ b/plugins/AdvaImg/src/Metadata/IPTC.cpp @@ -41,15 +41,27 @@ read_iptc_profile(FIBITMAP *dib, const BYTE *dataptr, unsigned int datalen) { size_t length = datalen; BYTE *profile = (BYTE*)dataptr; + const char *JPEG_AdobeCM_Tag = "Adobe_CM"; + std::string Keywords; std::string SupplementalCategory; WORD tag_id; - if (!dataptr || (datalen == 0)) { + if(!dataptr || (datalen == 0)) { return FALSE; } + if(datalen > 8) { + if(memcmp(JPEG_AdobeCM_Tag, dataptr, 8) == 0) { + // the "Adobe_CM" APP13 segment presumably contains color management information, + // but the meaning of the data is currently unknown. + // If anyone has an idea about what this means, please let me know. + return FALSE; + } + } + + // create a tag FITAG *tag = FreeImage_CreateTag(); @@ -59,7 +71,7 @@ read_iptc_profile(FIBITMAP *dib, const BYTE *dataptr, unsigned int datalen) { // find start of the BIM portion of the binary data size_t offset = 0; while(offset < length - 1) { - if ((profile[offset] == 0x1C) && (profile[offset+1] == 0x02)) + if((profile[offset] == 0x1C) && (profile[offset+1] == 0x02)) break; offset++; } @@ -88,6 +100,11 @@ read_iptc_profile(FIBITMAP *dib, const BYTE *dataptr, unsigned int datalen) { break; } + if(tagByteCount == 0) { + // go to next tag + continue; + } + // process the tag tag_id = (WORD)(tagType | (directoryType << 8)); @@ -211,7 +228,7 @@ append_iptc_tag(BYTE *profile, unsigned *profile_size, WORD id, DWORD length, co // calculate the new buffer size size_t buffer_size = (5 + *profile_size + length) * sizeof(BYTE); buffer = (BYTE*)malloc(buffer_size); - if (!buffer) + if(!buffer) return NULL; // add the header diff --git a/plugins/AdvaImg/src/Metadata/TagConversion.cpp b/plugins/AdvaImg/src/Metadata/TagConversion.cpp index 7b91598014..06a1970cd8 100644 --- a/plugins/AdvaImg/src/Metadata/TagConversion.cpp +++ b/plugins/AdvaImg/src/Metadata/TagConversion.cpp @@ -39,7 +39,7 @@ ConvertAnyTag(FITAG *tag) { static std::string buffer; DWORD i; - if (!tag) + if(!tag) return NULL; buffer.erase(); @@ -197,7 +197,7 @@ ConvertAnyTag(FITAG *tag) { case FIDT_LONG8: // N x 64-bit unsigned integer { - FIUINT64 *pvalue = (FIUINT64 *)FreeImage_GetTagValue(tag); + UINT64 *pvalue = (UINT64 *)FreeImage_GetTagValue(tag); sprintf(format, "%ld", pvalue[0]); buffer += format; @@ -210,7 +210,7 @@ ConvertAnyTag(FITAG *tag) { case FIDT_IFD8: // N x 64-bit unsigned integer (offset) { - FIUINT64 *pvalue = (FIUINT64 *)FreeImage_GetTagValue(tag); + UINT64 *pvalue = (UINT64 *)FreeImage_GetTagValue(tag); sprintf(format, "%X", pvalue[0]); buffer += format; @@ -223,7 +223,7 @@ ConvertAnyTag(FITAG *tag) { case FIDT_SLONG8: // N x 64-bit signed integer { - FIINT64 *pvalue = (FIINT64 *)FreeImage_GetTagValue(tag); + INT64 *pvalue = (INT64 *)FreeImage_GetTagValue(tag); sprintf(format, "%ld", pvalue[0]); buffer += format; @@ -259,7 +259,7 @@ ConvertExifTag(FITAG *tag) { char format[MAX_TEXT_EXTENT]; static std::string buffer; - if (!tag) + if(!tag) return NULL; buffer.erase(); @@ -993,7 +993,7 @@ ConvertExifGPSTag(FITAG *tag) { char format[MAX_TEXT_EXTENT]; static std::string buffer; - if (!tag) + if(!tag) return NULL; buffer.erase(); diff --git a/plugins/AdvaImg/src/Metadata/TagLib.cpp b/plugins/AdvaImg/src/Metadata/TagLib.cpp index eff291beab..580ad6faac 100644 --- a/plugins/AdvaImg/src/Metadata/TagLib.cpp +++ b/plugins/AdvaImg/src/Metadata/TagLib.cpp @@ -537,6 +537,7 @@ static TagInfo { 0x3015, (char *) "ColorMode", (char *) NULL}, { 0x3016, (char *) "Enhancement", (char *) NULL}, { 0x3017, (char *) "ColorFilter", (char *) NULL}, + { 0x301B, (char *) "ArtMode", (char *) NULL}, { 0x301C, (char *) "SequenceNumber", (char *) NULL}, { 0x301D, (char *) "BracketSequence", (char *) NULL}, { 0x3020, (char *) "ImageStabilization", (char *) NULL}, @@ -1478,14 +1479,14 @@ TagLib::TagLib() { BOOL TagLib::addMetadataModel(MDMODEL md_model, TagInfo *tag_table) { // check that the model doesn't already exist - if ((_table_map.find(md_model) == _table_map.end()) && (tag_table != NULL)) { + if((_table_map.find(md_model) == _table_map.end()) && (tag_table != NULL)) { // add the tag description table TAGINFO *info_map = new(std::nothrow) TAGINFO(); - if (!info_map) return FALSE; + if(!info_map) return FALSE; for(int i = 0; ; i++) { - if ((tag_table[i].tag == 0) && (tag_table[i].fieldname == NULL)) + if((tag_table[i].tag == 0) && (tag_table[i].fieldname == NULL)) break; (*info_map)[tag_table[i].tag] = &tag_table[i]; } diff --git a/plugins/AdvaImg/src/Metadata/XTIFF.cpp b/plugins/AdvaImg/src/Metadata/XTIFF.cpp index bc63cf38b2..e6f6bdd0d9 100644 --- a/plugins/AdvaImg/src/Metadata/XTIFF.cpp +++ b/plugins/AdvaImg/src/Metadata/XTIFF.cpp @@ -123,7 +123,7 @@ tiff_read_geotiff_profile(TIFF *tif, FIBITMAP *dib) { if(TIFFGetField(tif, fieldInfo->field_tag, ¶ms)) { // create a tag FITAG *tag = FreeImage_CreateTag(); - if (!tag) + if(!tag) return; WORD tag_id = (WORD)fieldInfo->field_tag; @@ -147,7 +147,7 @@ tiff_read_geotiff_profile(TIFF *tif, FIBITMAP *dib) { if(TIFFGetField(tif, fieldInfo->field_tag, &tag_count, &data)) { // create a tag FITAG *tag = FreeImage_CreateTag(); - if (!tag) + if(!tag) return; WORD tag_id = (WORD)fieldInfo->field_tag; @@ -315,7 +315,7 @@ tiff_read_exif_tag(TIFF *tif, TagLib::MDMODEL md_model, FIBITMAP *dib, TagLib& t // build FreeImage tag from Tiff Tag data we collected FITAG *fitag = FreeImage_CreateTag(); - if (!fitag) { + if(!fitag) { if(mem_alloc) { _TIFFfree(raw_data); } @@ -452,7 +452,9 @@ tiff_read_exif_tag(TIFF *tif, TagLib::MDMODEL md_model, FIBITMAP *dib, TagLib& t break; default: { - size_t length = strlen((char*)raw_data) + 1; + // remember that raw_data = _TIFFmalloc(value_size * value_count); + const int value_size = _TIFFDataSize(fip->field_type); + size_t length = value_size * value_count; FreeImage_SetTagType(fitag, FIDT_ASCII); FreeImage_SetTagLength(fitag, (DWORD)length); FreeImage_SetTagCount(fitag, (DWORD)length); @@ -514,18 +516,18 @@ tiff_read_exif_tags(TIFF *tif, TagLib::MDMODEL md_model, FIBITMAP *dib) { // test if tag value is set // (lifted directly form LibTiff _TIFFWriteDirectory) - if ( fld->field_bit == FIELD_CUSTOM ) { + if( fld->field_bit == FIELD_CUSTOM ) { int ci, is_set = FALSE; - for ( ci = 0; ci < td->td_customValueCount; ci++ ) { + for( ci = 0; ci < td->td_customValueCount; ci++ ) { is_set |= (td->td_customValues[ci].info == fld); } - if ( !is_set ) { + if( !is_set ) { continue; } - } else if (!TIFFFieldSet(tif, fld->field_bit)) { + } else if(!TIFFFieldSet(tif, fld->field_bit)) { continue; } @@ -558,6 +560,8 @@ skip_write_field(TIFF* tif, uint32 tag) { case TIFFTAG_PHOTOMETRIC: case TIFFTAG_PLANARCONFIG: case TIFFTAG_ROWSPERSTRIP: + case TIFFTAG_STRIPBYTECOUNTS: + case TIFFTAG_STRIPOFFSETS: case TIFFTAG_RESOLUTIONUNIT: case TIFFTAG_XRESOLUTION: case TIFFTAG_YRESOLUTION: @@ -639,7 +643,7 @@ tiff_write_exif_tags(TIFF *tif, TagLib::MDMODEL md_model, FIBITMAP *dib) { // check for identical formats // (enum value are the sames between FREE_IMAGE_MDTYPE and TIFFDataType types) - if ((int)tif_tag_type != (int)tag_type) { + if((int)tif_tag_type != (int)tag_type) { // skip tag or _TIFFmemcpy will fail continue; } diff --git a/plugins/AdvaImg/src/Utilities.h b/plugins/AdvaImg/src/Utilities.h index b743325129..ab0243cc41 100644 --- a/plugins/AdvaImg/src/Utilities.h +++ b/plugins/AdvaImg/src/Utilities.h @@ -96,6 +96,12 @@ Allocate a FIBITMAP of type FIT_BITMAP, with possibly no pixel data */ DLL_API FIBITMAP * DLL_CALLCONV FreeImage_AllocateHeader(BOOL header_only, int width, int height, int bpp, unsigned red_mask FI_DEFAULT(0), unsigned green_mask FI_DEFAULT(0), unsigned blue_mask FI_DEFAULT(0)); +/** +Helper for 16-bit FIT_BITMAP +@see FreeImage_GetRGBMasks +*/ +DLL_API BOOL DLL_CALLCONV FreeImage_HasRGBMasks(FIBITMAP *dib); + #if defined(__cplusplus) } #endif @@ -174,7 +180,7 @@ MAXMIN(const T* L, long n, T& max, T& min) { long k1, k2; i1 = 0; i2 = 0; min = L[0]; max = L[0]; j = 0; - if ((n % 2) != 0) j = 1; + if((n % 2) != 0) j = 1; for(i = j; i < n; i+= 2) { k1 = i; k2 = i+1; x1 = L[k1]; x2 = L[k2]; @@ -252,7 +258,7 @@ CalculateUsedBits(int bits) { inline unsigned CalculateLine(unsigned width, unsigned bitdepth) { - return (unsigned)( ((unsigned __int64)width * bitdepth + 7) / 8 ); + return (unsigned)( ((unsigned long long)width * bitdepth + 7) / 8 ); } inline unsigned @@ -456,8 +462,8 @@ A Standard Default Color Space for the Internet - sRGB. #define RGB565(b, g, r) ((((b) >> 3) << FI16_565_BLUE_SHIFT) | (((g) >> 2) << FI16_565_GREEN_SHIFT) | (((r) >> 3) << FI16_565_RED_SHIFT)) #define RGB555(b, g, r) ((((b) >> 3) << FI16_555_BLUE_SHIFT) | (((g) >> 3) << FI16_555_GREEN_SHIFT) | (((r) >> 3) << FI16_555_RED_SHIFT)) -#define FORMAT_RGB565(dib) ((FreeImage_GetRedMask(dib) == FI16_565_RED_MASK) &&(FreeImage_GetGreenMask(dib) == FI16_565_GREEN_MASK) &&(FreeImage_GetBlueMask(dib) == FI16_565_BLUE_MASK)) -#define RGBQUAD_TO_WORD(dib, color) (FORMAT_RGB565(dib) ? RGB565((color)->rgbBlue, (color)->rgbGreen, (color)->rgbRed) : RGB555((color)->rgbBlue, (color)->rgbGreen, (color)->rgbRed)) +#define IS_FORMAT_RGB565(dib) ((FreeImage_GetRedMask(dib) == FI16_565_RED_MASK) && (FreeImage_GetGreenMask(dib) == FI16_565_GREEN_MASK) && (FreeImage_GetBlueMask(dib) == FI16_565_BLUE_MASK)) +#define RGBQUAD_TO_WORD(dib, color) (IS_FORMAT_RGB565(dib) ? RGB565((color)->rgbBlue, (color)->rgbGreen, (color)->rgbRed) : RGB555((color)->rgbBlue, (color)->rgbGreen, (color)->rgbRed)) #define CREATE_GREYSCALE_PALETTE(palette, entries) \ for (unsigned i = 0, v = 0; i < entries; i++, v += 0x00FFFFFF / (entries - 1)) { \ diff --git a/plugins/AdvaImg/src/Zlib/zconf.h b/plugins/AdvaImg/src/Zlib/zconf.h index 93c1bb27e3..54b82a3ccc 100644 --- a/plugins/AdvaImg/src/Zlib/zconf.h +++ b/plugins/AdvaImg/src/Zlib/zconf.h @@ -1,468 +1,506 @@ -/* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2011 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id: zconf.h,v 1.8 2012/02/05 18:10:25 drolon Exp $ */ - -#ifndef ZCONF_H -#define ZCONF_H -/* #undef Z_PREFIX */ -/* #undef Z_HAVE_UNISTD_H */ - -/* - * If you *really* need a unique prefix for all types and library functions, - * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. - * Even better than compiling with -DZ_PREFIX would be to use configure to set - * this permanently in zconf.h using "./configure --zprefix". - */ -#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ -# define Z_PREFIX_SET - -/* all linked symbols */ -# define _dist_code z__dist_code -# define _length_code z__length_code -# define _tr_align z__tr_align -# define _tr_flush_block z__tr_flush_block -# define _tr_init z__tr_init -# define _tr_stored_block z__tr_stored_block -# define _tr_tally z__tr_tally -# define adler32 z_adler32 -# define adler32_combine z_adler32_combine -# define adler32_combine64 z_adler32_combine64 -# ifndef Z_SOLO -# define compress z_compress -# define compress2 z_compress2 -# define compressBound z_compressBound -# endif -# define crc32 z_crc32 -# define crc32_combine z_crc32_combine -# define crc32_combine64 z_crc32_combine64 -# define deflate z_deflate -# define deflateBound z_deflateBound -# define deflateCopy z_deflateCopy -# define deflateEnd z_deflateEnd -# define deflateInit2_ z_deflateInit2_ -# define deflateInit_ z_deflateInit_ -# define deflateParams z_deflateParams -# define deflatePending z_deflatePending -# define deflatePrime z_deflatePrime -# define deflateReset z_deflateReset -# define deflateResetKeep z_deflateResetKeep -# define deflateSetDictionary z_deflateSetDictionary -# define deflateSetHeader z_deflateSetHeader -# define deflateTune z_deflateTune -# define deflate_copyright z_deflate_copyright -# define get_crc_table z_get_crc_table -# ifndef Z_SOLO -# define gz_error z_gz_error -# define gz_intmax z_gz_intmax -# define gz_strwinerror z_gz_strwinerror -# define gzbuffer z_gzbuffer -# define gzclearerr z_gzclearerr -# define gzclose z_gzclose -# define gzclose_r z_gzclose_r -# define gzclose_w z_gzclose_w -# define gzdirect z_gzdirect -# define gzdopen z_gzdopen -# define gzeof z_gzeof -# define gzerror z_gzerror -# define gzflags z_gzflags -# define gzflush z_gzflush -# define gzgetc z_gzgetc -# define gzgetc_ z_gzgetc_ -# define gzgets z_gzgets -# define gzoffset z_gzoffset -# define gzoffset64 z_gzoffset64 -# define gzopen z_gzopen -# define gzopen64 z_gzopen64 -# define gzprintf z_gzprintf -# define gzputc z_gzputc -# define gzputs z_gzputs -# define gzread z_gzread -# define gzrewind z_gzrewind -# define gzseek z_gzseek -# define gzseek64 z_gzseek64 -# define gzsetparams z_gzsetparams -# define gztell z_gztell -# define gztell64 z_gztell64 -# define gzungetc z_gzungetc -# define gzwrite z_gzwrite -# endif -# define inflate z_inflate -# define inflateBack z_inflateBack -# define inflateBackEnd z_inflateBackEnd -# define inflateBackInit_ z_inflateBackInit_ -# define inflateCopy z_inflateCopy -# define inflateEnd z_inflateEnd -# define inflateGetHeader z_inflateGetHeader -# define inflateInit2_ z_inflateInit2_ -# define inflateInit_ z_inflateInit_ -# define inflateMark z_inflateMark -# define inflatePrime z_inflatePrime -# define inflateReset z_inflateReset -# define inflateReset2 z_inflateReset2 -# define inflateSetDictionary z_inflateSetDictionary -# define inflateSync z_inflateSync -# define inflateSyncPoint z_inflateSyncPoint -# define inflateUndermine z_inflateUndermine -# define inflateResetKeep z_inflateResetKeep -# define inflate_copyright z_inflate_copyright -# define inflate_fast z_inflate_fast -# define inflate_table z_inflate_table -# ifndef Z_SOLO -# define uncompress z_uncompress -# endif -# define zError z_zError -# ifndef Z_SOLO -# define zcalloc z_zcalloc -# define zcfree z_zcfree -# endif -# define zlibCompileFlags z_zlibCompileFlags -# define zlibVersion z_zlibVersion - -/* all zlib typedefs in zlib.h and zconf.h */ -# define Byte z_Byte -# define Bytef z_Bytef -# define alloc_func z_alloc_func -# define charf z_charf -# define free_func z_free_func -# ifndef Z_SOLO -# define gzFile z_gzFile -# define gz_header z_gz_header -# define gz_headerp z_gz_headerp -# endif -# define in_func z_in_func -# define intf z_intf -# define out_func z_out_func -# define uInt z_uInt -# define uIntf z_uIntf -# define uLong z_uLong -# define uLongf z_uLongf -# define voidp z_voidp -# define voidpc z_voidpc -# define voidpf z_voidpf - -/* all zlib structs in zlib.h and zconf.h */ -# ifndef Z_SOLO -# define gz_header_s z_gz_header_s -# endif -# define internal_state z_internal_state - -#endif - -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#endif -#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) -# define OS2 -#endif -#if defined(_WINDOWS) && !defined(WINDOWS) -# define WINDOWS -#endif -#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) -# ifndef WIN32 -# define WIN32 -# endif -#endif -#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) -# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) -# ifndef SYS16BIT -# define SYS16BIT -# endif -# endif -#endif - -/* - * Compile with -DMAXSEG_64K if the alloc function cannot allocate more - * than 64k bytes at a time (needed on systems with 16-bit int). - */ -#ifdef SYS16BIT -# define MAXSEG_64K -#endif -#ifdef MSDOS -# define UNALIGNED_OK -#endif - -#ifdef __STDC_VERSION__ -# ifndef STDC -# define STDC -# endif -# if __STDC_VERSION__ >= 199901L -# ifndef STDC99 -# define STDC99 -# endif -# endif -#endif -#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) -# define STDC -#endif -#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) -# define STDC -#endif -#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) -# define STDC -#endif -#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) -# define STDC -#endif - -#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ -# define STDC -#endif - -#ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const /* note: need a more gentle solution here */ -# endif -#endif - -#if defined(ZLIB_CONST) && !defined(z_const) -# define z_const const -#else -# define z_const -#endif - -/* Some Mac compilers merge all .h files incorrectly: */ -#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) -# define NO_DUMMY_DECL -#endif - -/* Maximum value for memLevel in deflateInit2 */ -#ifndef MAX_MEM_LEVEL -# ifdef MAXSEG_64K -# define MAX_MEM_LEVEL 8 -# else -# define MAX_MEM_LEVEL 9 -# endif -#endif - -/* Maximum value for windowBits in deflateInit2 and inflateInit2. - * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files - * created by gzip. (Files created by minigzip can still be extracted by - * gzip.) - */ -#ifndef MAX_WBITS -# define MAX_WBITS 15 /* 32K LZ77 window */ -#endif - -/* The memory requirements for deflate are (in bytes): - (1 << (windowBits+2)) + (1 << (memLevel+9)) - that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) - plus a few kilobytes for small objects. For example, if you want to reduce - the default memory requirements from 256K to 128K, compile with - make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" - Of course this will generally degrade compression (there's no free lunch). - - The memory requirements for inflate are (in bytes) 1 << windowBits - that is, 32K for windowBits=15 (default value) plus a few kilobytes - for small objects. -*/ - - /* Type declarations */ - -#ifndef OF /* function prototypes */ -# ifdef STDC -# define OF(args) args -# else -# define OF(args) () -# endif -#endif - -#ifndef Z_ARG /* function prototypes for stdarg */ -# if defined(STDC) || defined(Z_HAVE_STDARG_H) -# define Z_ARG(args) args -# else -# define Z_ARG(args) () -# endif -#endif - -/* The following definitions for FAR are needed only for MSDOS mixed - * model programming (small or medium model with some far allocations). - * This was tested only with MSC; for other MSDOS compilers you may have - * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, - * just define FAR to be empty. - */ -#ifdef SYS16BIT -# if defined(M_I86SM) || defined(M_I86MM) - /* MSC small or medium model */ -# define SMALL_MEDIUM -# ifdef _MSC_VER -# define FAR _far -# else -# define FAR far -# endif -# endif -# if (defined(__SMALL__) || defined(__MEDIUM__)) - /* Turbo C small or medium model */ -# define SMALL_MEDIUM -# ifdef __BORLANDC__ -# define FAR _far -# else -# define FAR far -# endif -# endif -#endif - -#if defined(WINDOWS) || defined(WIN32) - /* If building or using zlib as a DLL, define ZLIB_DLL. - * This is not mandatory, but it offers a little performance increase. - */ -# ifdef ZLIB_DLL -# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) -# ifdef ZLIB_INTERNAL -# define ZEXTERN extern __declspec(dllexport) -# else -# define ZEXTERN extern __declspec(dllimport) -# endif -# endif -# endif /* ZLIB_DLL */ - /* If building or using zlib with the WINAPI/WINAPIV calling convention, - * define ZLIB_WINAPI. - * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. - */ -# ifdef ZLIB_WINAPI -# ifdef FAR -# undef FAR -# endif -# include - /* No need for _export, use ZLIB.DEF instead. */ - /* For complete Windows compatibility, use WINAPI, not __stdcall. */ -# define ZEXPORT WINAPI -# ifdef WIN32 -# define ZEXPORTVA WINAPIV -# else -# define ZEXPORTVA FAR CDECL -# endif -# endif -#endif - -#if defined (__BEOS__) -# ifdef ZLIB_DLL -# ifdef ZLIB_INTERNAL -# define ZEXPORT __declspec(dllexport) -# define ZEXPORTVA __declspec(dllexport) -# else -# define ZEXPORT __declspec(dllimport) -# define ZEXPORTVA __declspec(dllimport) -# endif -# endif -#endif - -#ifndef ZEXTERN -# define ZEXTERN extern -#endif -#ifndef ZEXPORT -# define ZEXPORT -#endif -#ifndef ZEXPORTVA -# define ZEXPORTVA -#endif - -#ifndef FAR -# define FAR -#endif - -#if !defined(__MACTYPES__) -typedef unsigned char Byte; /* 8 bits */ -#endif -typedef unsigned int uInt; /* 16 bits or more */ -typedef unsigned long uLong; /* 32 bits or more */ - -#ifdef SMALL_MEDIUM - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ -# define Bytef Byte FAR -#else - typedef Byte FAR Bytef; -#endif -typedef char FAR charf; -typedef int FAR intf; -typedef uInt FAR uIntf; -typedef uLong FAR uLongf; - -#ifdef STDC - typedef void const *voidpc; - typedef void FAR *voidpf; - typedef void *voidp; -#else - typedef Byte const *voidpc; - typedef Byte FAR *voidpf; - typedef Byte *voidp; -#endif - -#if 0 /*#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ -# define Z_HAVE_UNISTD_H -#endif - -#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ -# define Z_HAVE_STDARG_H -#endif - -#ifdef STDC -# ifndef Z_SOLO -# include /* for off_t */ -# endif -#endif - -/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and - * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even - * though the former does not conform to the LFS document), but considering - * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as - * equivalently requesting no 64-bit operations - */ -#if -_LARGEFILE64_SOURCE - -1 == 1 -# undef _LARGEFILE64_SOURCE -#endif - -#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 -# define Z_LARGE -#endif - -#if (defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE)) && !defined(Z_SOLO) -# include /* for SEEK_* and off_t */ -# ifdef VMS -# include /* for off_t */ -# endif -# ifndef z_off_t -# define z_off_t off_t -# endif -#endif - -#if !defined(SEEK_SET) && !defined(Z_SOLO) -# define SEEK_SET 0 /* Seek from beginning of file. */ -# define SEEK_CUR 1 /* Seek from current position. */ -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ -#endif - -#ifndef z_off_t -# define z_off_t long -#endif - -#if !defined(_WIN32) && (defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0) -# define z_off64_t off64_t -#else -# if defined(_WIN32) -# define z_off64_t __int64 -# else -# define z_off64_t z_off_t -#endif -#endif - -/* MVS linker does not support external names larger than 8 bytes */ -#if defined(__MVS__) - #pragma map(deflateInit_,"DEIN") - #pragma map(deflateInit2_,"DEIN2") - #pragma map(deflateEnd,"DEEND") - #pragma map(deflateBound,"DEBND") - #pragma map(inflateInit_,"ININ") - #pragma map(inflateInit2_,"ININ2") - #pragma map(inflateEnd,"INEND") - #pragma map(inflateSync,"INSY") - #pragma map(inflateSetDictionary,"INSEDI") - #pragma map(compressBound,"CMBND") - #pragma map(inflate_table,"INTABL") - #pragma map(inflate_fast,"INFA") - #pragma map(inflate_copyright,"INCOPY") -#endif - -#endif /* ZCONF_H */ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-2012 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id: zconf.h,v 1.9 2012/05/13 12:18:39 drolon Exp $ */ + +#ifndef ZCONF_H +#define ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + * Even better than compiling with -DZ_PREFIX would be to use configure to set + * this permanently in zconf.h using "./configure --zprefix". + */ +#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ +# define Z_PREFIX_SET + +/* all linked symbols */ +# define _dist_code z__dist_code +# define _length_code z__length_code +# define _tr_align z__tr_align +# define _tr_flush_block z__tr_flush_block +# define _tr_init z__tr_init +# define _tr_stored_block z__tr_stored_block +# define _tr_tally z__tr_tally +# define adler32 z_adler32 +# define adler32_combine z_adler32_combine +# define adler32_combine64 z_adler32_combine64 +# ifndef Z_SOLO +# define compress z_compress +# define compress2 z_compress2 +# define compressBound z_compressBound +# endif +# define crc32 z_crc32 +# define crc32_combine z_crc32_combine +# define crc32_combine64 z_crc32_combine64 +# define deflate z_deflate +# define deflateBound z_deflateBound +# define deflateCopy z_deflateCopy +# define deflateEnd z_deflateEnd +# define deflateInit2_ z_deflateInit2_ +# define deflateInit_ z_deflateInit_ +# define deflateParams z_deflateParams +# define deflatePending z_deflatePending +# define deflatePrime z_deflatePrime +# define deflateReset z_deflateReset +# define deflateResetKeep z_deflateResetKeep +# define deflateSetDictionary z_deflateSetDictionary +# define deflateSetHeader z_deflateSetHeader +# define deflateTune z_deflateTune +# define deflate_copyright z_deflate_copyright +# define get_crc_table z_get_crc_table +# ifndef Z_SOLO +# define gz_error z_gz_error +# define gz_intmax z_gz_intmax +# define gz_strwinerror z_gz_strwinerror +# define gzbuffer z_gzbuffer +# define gzclearerr z_gzclearerr +# define gzclose z_gzclose +# define gzclose_r z_gzclose_r +# define gzclose_w z_gzclose_w +# define gzdirect z_gzdirect +# define gzdopen z_gzdopen +# define gzeof z_gzeof +# define gzerror z_gzerror +# define gzflush z_gzflush +# define gzgetc z_gzgetc +# define gzgetc_ z_gzgetc_ +# define gzgets z_gzgets +# define gzoffset z_gzoffset +# define gzoffset64 z_gzoffset64 +# define gzopen z_gzopen +# define gzopen64 z_gzopen64 +# ifdef _WIN32 +# define gzopen_w z_gzopen_w +# endif +# define gzprintf z_gzprintf +# define gzputc z_gzputc +# define gzputs z_gzputs +# define gzread z_gzread +# define gzrewind z_gzrewind +# define gzseek z_gzseek +# define gzseek64 z_gzseek64 +# define gzsetparams z_gzsetparams +# define gztell z_gztell +# define gztell64 z_gztell64 +# define gzungetc z_gzungetc +# define gzwrite z_gzwrite +# endif +# define inflate z_inflate +# define inflateBack z_inflateBack +# define inflateBackEnd z_inflateBackEnd +# define inflateBackInit_ z_inflateBackInit_ +# define inflateCopy z_inflateCopy +# define inflateEnd z_inflateEnd +# define inflateGetHeader z_inflateGetHeader +# define inflateInit2_ z_inflateInit2_ +# define inflateInit_ z_inflateInit_ +# define inflateMark z_inflateMark +# define inflatePrime z_inflatePrime +# define inflateReset z_inflateReset +# define inflateReset2 z_inflateReset2 +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateUndermine z_inflateUndermine +# define inflateResetKeep z_inflateResetKeep +# define inflate_copyright z_inflate_copyright +# define inflate_fast z_inflate_fast +# define inflate_table z_inflate_table +# ifndef Z_SOLO +# define uncompress z_uncompress +# endif +# define zError z_zError +# ifndef Z_SOLO +# define zcalloc z_zcalloc +# define zcfree z_zcfree +# endif +# define zlibCompileFlags z_zlibCompileFlags +# define zlibVersion z_zlibVersion + +/* all zlib typedefs in zlib.h and zconf.h */ +# define Byte z_Byte +# define Bytef z_Bytef +# define alloc_func z_alloc_func +# define charf z_charf +# define free_func z_free_func +# ifndef Z_SOLO +# define gzFile z_gzFile +# endif +# define gz_header z_gz_header +# define gz_headerp z_gz_headerp +# define in_func z_in_func +# define intf z_intf +# define out_func z_out_func +# define uInt z_uInt +# define uIntf z_uIntf +# define uLong z_uLong +# define uLongf z_uLongf +# define voidp z_voidp +# define voidpc z_voidpc +# define voidpf z_voidpf + +/* all zlib structs in zlib.h and zconf.h */ +# define gz_header_s z_gz_header_s +# define internal_state z_internal_state + +#endif + +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif +#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) +# define OS2 +#endif +#if defined(_WINDOWS) && !defined(WINDOWS) +# define WINDOWS +#endif +#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) +# ifndef WIN32 +# define WIN32 +# endif +#endif +#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) +# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) +# ifndef SYS16BIT +# define SYS16BIT +# endif +# endif +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#ifdef SYS16BIT +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#ifdef __STDC_VERSION__ +# ifndef STDC +# define STDC +# endif +# if __STDC_VERSION__ >= 199901L +# ifndef STDC99 +# define STDC99 +# endif +# endif +#endif +#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) +# define STDC +#endif +#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) +# define STDC +#endif +#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) +# define STDC +#endif +#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) +# define STDC +#endif + +#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ +# define STDC +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const /* note: need a more gentle solution here */ +# endif +#endif + +#if defined(ZLIB_CONST) && !defined(z_const) +# define z_const const +#else +# define z_const +#endif + +/* Some Mac compilers merge all .h files incorrectly: */ +#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) +# define NO_DUMMY_DECL +#endif + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus a few kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +#ifndef Z_ARG /* function prototypes for stdarg */ +# if defined(STDC) || defined(Z_HAVE_STDARG_H) +# define Z_ARG(args) args +# else +# define Z_ARG(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#ifdef SYS16BIT +# if defined(M_I86SM) || defined(M_I86MM) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +# endif +# if (defined(__SMALL__) || defined(__MEDIUM__)) + /* Turbo C small or medium model */ +# define SMALL_MEDIUM +# ifdef __BORLANDC__ +# define FAR _far +# else +# define FAR far +# endif +# endif +#endif + +#if defined(WINDOWS) || defined(WIN32) + /* If building or using zlib as a DLL, define ZLIB_DLL. + * This is not mandatory, but it offers a little performance increase. + */ +# ifdef ZLIB_DLL +# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) +# ifdef ZLIB_INTERNAL +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +# endif +# endif /* ZLIB_DLL */ + /* If building or using zlib with the WINAPI/WINAPIV calling convention, + * define ZLIB_WINAPI. + * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. + */ +# ifdef ZLIB_WINAPI +# ifdef FAR +# undef FAR +# endif +# include + /* No need for _export, use ZLIB.DEF instead. */ + /* For complete Windows compatibility, use WINAPI, not __stdcall. */ +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR CDECL +# endif +# endif +#endif + +#if defined (__BEOS__) +# ifdef ZLIB_DLL +# ifdef ZLIB_INTERNAL +# define ZEXPORT __declspec(dllexport) +# define ZEXPORTVA __declspec(dllexport) +# else +# define ZEXPORT __declspec(dllimport) +# define ZEXPORTVA __declspec(dllimport) +# endif +# endif +#endif + +#ifndef ZEXTERN +# define ZEXTERN extern +#endif +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(__MACTYPES__) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void const *voidpc; + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte const *voidpc; + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +/* ./configure may #define Z_U4 here */ + +#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) +# include +# if (UINT_MAX == 0xffffffffUL) +# define Z_U4 unsigned +# else +# if (ULONG_MAX == 0xffffffffUL) +# define Z_U4 unsigned long +# else +# if (USHRT_MAX == 0xffffffffUL) +# define Z_U4 unsigned short +# endif +# endif +# endif +#endif + +#ifdef Z_U4 + typedef Z_U4 z_crc_t; +#else + typedef unsigned long z_crc_t; +#endif + +#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ +# define Z_HAVE_UNISTD_H +#endif + +#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ +# define Z_HAVE_STDARG_H +#endif + +#ifdef STDC +# ifndef Z_SOLO +# include /* for off_t */ +# endif +#endif + +#ifdef _WIN32 +# include /* for wchar_t */ +#endif + +/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and + * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even + * though the former does not conform to the LFS document), but considering + * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as + * equivalently requesting no 64-bit operations + */ +#if defined(LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 +# undef _LARGEFILE64_SOURCE +#endif + +#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H) +# define Z_HAVE_UNISTD_H +#endif +#ifndef Z_SOLO +# if defined(Z_HAVE_UNISTD_H) || defined(LARGEFILE64_SOURCE) +# include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ +# ifdef VMS +# include /* for off_t */ +# endif +# ifndef z_off_t +# define z_off_t off_t +# endif +# endif +#endif + +#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 +# define Z_LFS64 +#endif + +#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) +# define Z_LARGE64 +#endif + +#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) +# define Z_WANT64 +#endif + +#if !defined(SEEK_SET) && !defined(Z_SOLO) +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif + +#ifndef z_off_t +# define z_off_t long +#endif + +#if !defined(_WIN32) && defined(Z_LARGE64) +# define z_off64_t off64_t +#else +# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) +# define z_off64_t __int64 +# else +# define z_off64_t z_off_t +# endif +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) + #pragma map(deflateInit_,"DEIN") + #pragma map(deflateInit2_,"DEIN2") + #pragma map(deflateEnd,"DEEND") + #pragma map(deflateBound,"DEBND") + #pragma map(inflateInit_,"ININ") + #pragma map(inflateInit2_,"ININ2") + #pragma map(inflateEnd,"INEND") + #pragma map(inflateSync,"INSY") + #pragma map(inflateSetDictionary,"INSEDI") + #pragma map(compressBound,"CMBND") + #pragma map(inflate_table,"INTABL") + #pragma map(inflate_fast,"INFA") + #pragma map(inflate_copyright,"INCOPY") +#endif + +#endif /* ZCONF_H */ diff --git a/plugins/AdvaImg/src/Zlib/zlib.h b/plugins/AdvaImg/src/Zlib/zlib.h index 79142d1172..3edf3acdb5 100644 --- a/plugins/AdvaImg/src/Zlib/zlib.h +++ b/plugins/AdvaImg/src/Zlib/zlib.h @@ -1,5 +1,5 @@ /* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.6, January 29th, 2012 + version 1.2.7, May 2nd, 2012 Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler @@ -37,11 +37,11 @@ extern "C" { #endif -#define ZLIB_VERSION "1.2.6" -#define ZLIB_VERNUM 0x1260 +#define ZLIB_VERSION "1.2.7" +#define ZLIB_VERNUM 0x1270 #define ZLIB_VER_MAJOR 1 #define ZLIB_VER_MINOR 2 -#define ZLIB_VER_REVISION 6 +#define ZLIB_VER_REVISION 7 #define ZLIB_VER_SUBREVISION 0 /* @@ -452,14 +452,17 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); error. However if all decompression is to be performed in a single step (a single call of inflate), the parameter flush should be set to Z_FINISH. In this case all pending input is processed and all pending output is flushed; - avail_out must be large enough to hold all the uncompressed data. (The size - of the uncompressed data may have been saved by the compressor for this - purpose.) The next operation on this stream must be inflateEnd to deallocate - the decompression state. The use of Z_FINISH is not required to perform an - inflation in one step. However it may be used to inform inflate that a - faster approach can be used for the single inflate() call. Z_FINISH also - informs inflate to not maintain a sliding window if the stream completes, - which reduces inflate's memory footprint. + avail_out must be large enough to hold all of the uncompressed data for the + operation to complete. (The size of the uncompressed data may have been + saved by the compressor for this purpose.) The use of Z_FINISH is not + required to perform an inflation in one step. However it may be used to + inform inflate that a faster approach can be used for the single inflate() + call. Z_FINISH also informs inflate to not maintain a sliding window if the + stream completes, which reduces inflate's memory footprint. If the stream + does not complete, either because not all of the stream is provided or not + enough output space is provided, then a sliding window will be allocated and + inflate() can be called again to continue the operation as if Z_NO_FLUSH had + been used. In this implementation, inflate() always flushes as much output as possible to the output buffer, and always uses the faster approach on the @@ -1217,7 +1220,10 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); "a" can be used instead of "w" to request that the gzip stream that will be written be appended to the file. "+" will result in an error, since - reading and writing to the same gzip file is not supported. + reading and writing to the same gzip file is not supported. The addition of + "x" when writing will create the file exclusively, which fails if the file + already exists. On systems that support it, the addition of "e" when + reading or writing will set the flag to close the file on an execve() call. These functions, as well as gzip, will read and decode a sequence of gzip streams in a file. The append function of gzopen() can be used to create @@ -1578,9 +1584,8 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); /* Update a running CRC-32 with the bytes buf[0..len-1] and return the updated CRC-32. If buf is Z_NULL, this function returns the required - initial value for the for the crc. Pre- and post-conditioning (one's - complement) is performed within this function so it shouldn't be done by the - application. + initial value for the crc. Pre- and post-conditioning (one's complement) is + performed within this function so it shouldn't be done by the application. Usage example: @@ -1650,9 +1655,15 @@ struct gzFile_s { unsigned char *next; z_off64_t pos; }; -ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); -#define gzgetc(g) \ - ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc_(g)) +ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ +#ifdef Z_PREFIX_SET +# undef z_gzgetc +# define z_gzgetc(g) \ + ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g)) +#else +# define gzgetc(g) \ + ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g)) +#endif /* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if @@ -1660,7 +1671,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); * functions are changed to 64 bits) -- in case these are set on systems * without large file support, _LFS64_LARGEFILE must also be true */ -#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 +#ifdef Z_LARGE64 ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); @@ -1669,7 +1680,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); #endif -#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0 +#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) # ifdef Z_PREFIX_SET # define z_gzopen z_gzopen64 # define z_gzseek z_gzseek64 @@ -1685,7 +1696,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); # define adler32_combine adler32_combine64 # define crc32_combine crc32_combine64 # endif -# ifndef _LARGEFILE64_SOURCE +# ifndef Z_LARGE64 ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); @@ -1717,12 +1728,13 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* undocumented functions */ ZEXTERN const char * ZEXPORT zError OF((int)); ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); -ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); +ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); -#ifndef Z_SOLO - ZEXTERN unsigned long ZEXPORT gzflags OF((void)); +#if defined(_WIN32) && !defined(Z_SOLO) +ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, + const char *mode)); #endif #ifdef __cplusplus diff --git a/plugins/AdvaImg/src/Zlib/zutil.h b/plugins/AdvaImg/src/Zlib/zutil.h index 8f33fd3e7d..9a5427578e 100644 --- a/plugins/AdvaImg/src/Zlib/zutil.h +++ b/plugins/AdvaImg/src/Zlib/zutil.h @@ -1,248 +1,252 @@ -/* zutil.h -- internal interface and configuration of the compression library - * Copyright (C) 1995-2011 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* @(#) $Id: zutil.h,v 1.8 2012/02/05 18:10:25 drolon Exp $ */ - -#ifndef ZUTIL_H -#define ZUTIL_H - -#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ) -# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) -#else -# define ZLIB_INTERNAL -#endif - -#include "zlib.h" - -#if defined(STDC) && !defined(Z_SOLO) -# if !(defined(_WIN32_WCE) && defined(_MSC_VER)) -# include -# endif -# include -# include -#endif - -#ifdef Z_SOLO - typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ -#endif - -#ifndef local -# define local static -#endif -/* compile with -Dlocal if your debugger can't find static symbols */ - -typedef unsigned char uch; -typedef uch FAR uchf; -typedef unsigned short ush; -typedef ush FAR ushf; -typedef unsigned long ulg; - -extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ -/* (size given to avoid silly warnings with Visual C++) */ - -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] - -#define ERR_RETURN(strm,err) \ - return (strm->msg = (char*)ERR_MSG(err), (err)) -/* To be used only when the state is known to be valid */ - - /* common constants */ - -#ifndef DEF_WBITS -# define DEF_WBITS MAX_WBITS -#endif -/* default windowBits for decompression. MAX_WBITS is for compression only */ - -#if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -#else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -#endif -/* default memLevel */ - -#define STORED_BLOCK 0 -#define STATIC_TREES 1 -#define DYN_TREES 2 -/* The three kinds of block type */ - -#define MIN_MATCH 3 -#define MAX_MATCH 258 -/* The minimum and maximum match lengths */ - -#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ - - /* target dependencies */ - -#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) -# define OS_CODE 0x00 -# ifndef Z_SOLO -# if defined(__TURBOC__) || defined(__BORLANDC__) -# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) - /* Allow compilation with ANSI keywords only enabled */ - void _Cdecl farfree( void *block ); - void *_Cdecl farmalloc( unsigned long nbytes ); -# else -# include -# endif -# else /* MSC or DJGPP */ -# include -# endif -# endif -#endif - -#ifdef AMIGA -# define OS_CODE 0x01 -#endif - -#if defined(VAXC) || defined(VMS) -# define OS_CODE 0x02 -# define F_OPEN(name, mode) \ - fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") -#endif - -#if defined(ATARI) || defined(atarist) -# define OS_CODE 0x05 -#endif - -#ifdef OS2 -# define OS_CODE 0x06 -# if defined(M_I86) && !defined(Z_SOLO) -# include -# endif -#endif - -#if defined(MACOS) || defined(TARGET_OS_MAC) -# define OS_CODE 0x07 -# ifndef Z_SOLO -# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include /* for fdopen */ -# else -# ifndef fdopen -# define fdopen(fd,mode) NULL /* No fdopen() */ -# endif -# endif -# endif -#endif - -#ifdef TOPS20 -# define OS_CODE 0x0a -#endif - -#ifdef WIN32 -# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ -# define OS_CODE 0x0b -# endif -#endif - -#ifdef __50SERIES /* Prime/PRIMOS */ -# define OS_CODE 0x0f -#endif - -#if defined(_BEOS_) || defined(RISCOS) -# define fdopen(fd,mode) NULL /* No fdopen() */ -#endif - -#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX -# if defined(_WIN32_WCE) -# define fdopen(fd,mode) NULL /* No fdopen() */ -# ifndef _PTRDIFF_T_DEFINED - typedef int ptrdiff_t; -# define _PTRDIFF_T_DEFINED -# endif -# else -# define fdopen(fd,type) _fdopen(fd,type) -# endif -#endif - -#if defined(__BORLANDC__) && !defined(MSDOS) - #pragma warn -8004 - #pragma warn -8008 - #pragma warn -8066 -#endif - -/* provide prototypes for these when building zlib without LFS */ -#if !defined(_WIN32) && (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); -#endif - - /* common defaults */ - -#ifndef OS_CODE -# define OS_CODE 0x03 /* assume Unix */ -#endif - -#ifndef F_OPEN -# define F_OPEN(name, mode) fopen((name), (mode)) -#endif - - /* functions */ - -#if defined(pyr) || defined(Z_SOLO) -# define NO_MEMCPY -#endif -#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) - /* Use our own functions for small and medium model with MSC <= 5.0. - * You may have to use the same strategy for Borland C (untested). - * The __SC__ check is for Symantec. - */ -# define NO_MEMCPY -#endif -#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) -# define HAVE_MEMCPY -#endif -#ifdef HAVE_MEMCPY -# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ -# define zmemcpy _fmemcpy -# define zmemcmp _fmemcmp -# define zmemzero(dest, len) _fmemset(dest, 0, len) -# else -# define zmemcpy memcpy -# define zmemcmp memcmp -# define zmemzero(dest, len) memset(dest, 0, len) -# endif -#else - void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); - int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); - void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); -#endif - -/* Diagnostic functions */ -#ifdef DEBUG -# include - extern int ZLIB_INTERNAL z_verbose; - extern void ZLIB_INTERNAL z_error OF((char *m)); -# define Assert(cond,msg) {if (!(cond)) z_error(msg);} -# define Trace(x) {if (z_verbose>=0) fprintf x ;} -# define Tracev(x) {if (z_verbose>0) fprintf x ;} -# define Tracevv(x) {if (z_verbose>1) fprintf x ;} -# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} -# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} -#else -# define Assert(cond,msg) -# define Trace(x) -# define Tracev(x) -# define Tracevv(x) -# define Tracec(c,x) -# define Tracecv(c,x) -#endif - -#ifndef Z_SOLO - voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, - unsigned size)); - void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); -#endif - -#define ZALLOC(strm, items, size) \ - (*((strm)->zalloc))((strm)->opaque, (items), (size)) -#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) -#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} - -#endif /* ZUTIL_H */ +/* zutil.h -- internal interface and configuration of the compression library + * Copyright (C) 1995-2012 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* @(#) $Id: zutil.h,v 1.9 2012/05/13 12:18:39 drolon Exp $ */ + +#ifndef ZUTIL_H +#define ZUTIL_H + +#ifdef HAVE_HIDDEN +# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) +#else +# define ZLIB_INTERNAL +#endif + +#include "zlib.h" + +#if defined(STDC) && !defined(Z_SOLO) +# if !(defined(_WIN32_WCE) && defined(_MSC_VER)) +# include +# endif +# include +# include +#endif + +#ifdef Z_SOLO + typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ +#endif + +#ifndef local +# define local static +#endif +/* compile with -Dlocal if your debugger can't find static symbols */ + +typedef unsigned char uch; +typedef uch FAR uchf; +typedef unsigned short ush; +typedef ush FAR ushf; +typedef unsigned long ulg; + +extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ +/* (size given to avoid silly warnings with Visual C++) */ + +#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] + +#define ERR_RETURN(strm,err) \ + return (strm->msg = (char*)ERR_MSG(err), (err)) +/* To be used only when the state is known to be valid */ + + /* common constants */ + +#ifndef DEF_WBITS +# define DEF_WBITS MAX_WBITS +#endif +/* default windowBits for decompression. MAX_WBITS is for compression only */ + +#if MAX_MEM_LEVEL >= 8 +# define DEF_MEM_LEVEL 8 +#else +# define DEF_MEM_LEVEL MAX_MEM_LEVEL +#endif +/* default memLevel */ + +#define STORED_BLOCK 0 +#define STATIC_TREES 1 +#define DYN_TREES 2 +/* The three kinds of block type */ + +#define MIN_MATCH 3 +#define MAX_MATCH 258 +/* The minimum and maximum match lengths */ + +#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ + + /* target dependencies */ + +#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) +# define OS_CODE 0x00 +# ifndef Z_SOLO +# if defined(__TURBOC__) || defined(__BORLANDC__) +# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) + /* Allow compilation with ANSI keywords only enabled */ + void _Cdecl farfree( void *block ); + void *_Cdecl farmalloc( unsigned long nbytes ); +# else +# include +# endif +# else /* MSC or DJGPP */ +# include +# endif +# endif +#endif + +#ifdef AMIGA +# define OS_CODE 0x01 +#endif + +#if defined(VAXC) || defined(VMS) +# define OS_CODE 0x02 +# define F_OPEN(name, mode) \ + fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") +#endif + +#if defined(ATARI) || defined(atarist) +# define OS_CODE 0x05 +#endif + +#ifdef OS2 +# define OS_CODE 0x06 +# if defined(M_I86) && !defined(Z_SOLO) +# include +# endif +#endif + +#if defined(MACOS) || defined(TARGET_OS_MAC) +# define OS_CODE 0x07 +# ifndef Z_SOLO +# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os +# include /* for fdopen */ +# else +# ifndef fdopen +# define fdopen(fd,mode) NULL /* No fdopen() */ +# endif +# endif +# endif +#endif + +#ifdef TOPS20 +# define OS_CODE 0x0a +#endif + +#ifdef WIN32 +# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ +# define OS_CODE 0x0b +# endif +#endif + +#ifdef __50SERIES /* Prime/PRIMOS */ +# define OS_CODE 0x0f +#endif + +#if defined(_BEOS_) || defined(RISCOS) +# define fdopen(fd,mode) NULL /* No fdopen() */ +#endif + +#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX +# if defined(_WIN32_WCE) +# define fdopen(fd,mode) NULL /* No fdopen() */ +# ifndef _PTRDIFF_T_DEFINED + typedef int ptrdiff_t; +# define _PTRDIFF_T_DEFINED +# endif +# else +# define fdopen(fd,type) _fdopen(fd,type) +# endif +#endif + +#if defined(__BORLANDC__) && !defined(MSDOS) + #pragma warn -8004 + #pragma warn -8008 + #pragma warn -8066 +#endif + +/* provide prototypes for these when building zlib without LFS */ +#if !defined(_WIN32) && (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); +#endif + + /* common defaults */ + +#ifndef OS_CODE +# define OS_CODE 0x03 /* assume Unix */ +#endif + +#ifndef F_OPEN +# define F_OPEN(name, mode) fopen((name), (mode)) +#endif + + /* functions */ + +#if defined(pyr) || defined(Z_SOLO) +# define NO_MEMCPY +#endif +#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) + /* Use our own functions for small and medium model with MSC <= 5.0. + * You may have to use the same strategy for Borland C (untested). + * The __SC__ check is for Symantec. + */ +# define NO_MEMCPY +#endif +#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) +# define HAVE_MEMCPY +#endif +#ifdef HAVE_MEMCPY +# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ +# define zmemcpy _fmemcpy +# define zmemcmp _fmemcmp +# define zmemzero(dest, len) _fmemset(dest, 0, len) +# else +# define zmemcpy memcpy +# define zmemcmp memcmp +# define zmemzero(dest, len) memset(dest, 0, len) +# endif +#else + void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); + int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); + void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); +#endif + +/* Diagnostic functions */ +#ifdef DEBUG +# include + extern int ZLIB_INTERNAL z_verbose; + extern void ZLIB_INTERNAL z_error OF((char *m)); +# define Assert(cond,msg) {if(!(cond)) z_error(msg);} +# define Trace(x) {if (z_verbose>=0) fprintf x ;} +# define Tracev(x) {if (z_verbose>0) fprintf x ;} +# define Tracevv(x) {if (z_verbose>1) fprintf x ;} +# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} +# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} +#else +# define Assert(cond,msg) +# define Trace(x) +# define Tracev(x) +# define Tracevv(x) +# define Tracec(c,x) +# define Tracecv(c,x) +#endif + +#ifndef Z_SOLO + voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, + unsigned size)); + void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); +#endif + +#define ZALLOC(strm, items, size) \ + (*((strm)->zalloc))((strm)->opaque, (items), (size)) +#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) +#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} + +/* Reverse the bytes in a 32-bit value */ +#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ + (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) + +#endif /* ZUTIL_H */ diff --git a/plugins/AdvaImg/src/main.cpp b/plugins/AdvaImg/src/main.cpp index a2ae903485..9418ee51ee 100644 --- a/plugins/AdvaImg/src/main.cpp +++ b/plugins/AdvaImg/src/main.cpp @@ -56,7 +56,7 @@ static const PLUGININFOEX pluginInfoEx = { __AUTHORWEB, UNICODE_AWARE, // {7C070F7C-459E-46b7-8E6D-BC6EFAA22F78} - { 0x7c070f7c, 0x459e, 0x46b7, { 0x8e, 0x6d, 0xbc, 0x6e, 0xfa, 0xa2, 0x2f, 0x78 } } + {0x7c070f7c, 0x459e, 0x46b7, {0x8e, 0x6d, 0xbc, 0x6e, 0xfa, 0xa2, 0x2f, 0x78}} }; /* diff --git a/plugins/AdvaImg/src/version.h b/plugins/AdvaImg/src/version.h index fb6dca1759..d656e8b8ed 100644 --- a/plugins/AdvaImg/src/version.h +++ b/plugins/AdvaImg/src/version.h @@ -4,17 +4,11 @@ #define __BUILD_NUM 1 #define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM -#define __FILEVERSION_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM - -#define __STRINGIFY_IMPL(x) #x -#define __STRINGIFY(x) __STRINGIFY_IMPL(x) -#define __VERSION_STRING __STRINGIFY(__FILEVERSION_DOTS) #define __PLUGIN_NAME "Miranda Image services" -#define __INTERNAL_NAME "AdvaImg" #define __FILENAME "AdvaImg.dll" #define __DESCRIPTION "Generic image services for Miranda NG." #define __AUTHOR "Nightwish, The FreeImage project (http://freeimage.sourceforge.net/)" #define __AUTHOREMAIL "" #define __AUTHORWEB "http://miranda-ng.org/" -#define __COPYRIGHT "© 2000-2012 Miranda-IM project, 2012 Miranda-NG project uses the FreeImage distribution" +#define __COPYRIGHT "© 2000-2012 Miranda-IM project, 2012-2013 Miranda NG project uses the FreeImage distribution" -- cgit v1.2.3