! : changed
+ : added
+January 2, 2011
+* [antonin] bug fixes to enable cmake compilation on WIN32 platform
+ - fixed getopt bug in jpwl/CMakeLists.txt
+ - added png, zlib and lcms win32 libraries to libs directory
+ - updated libs/libtiff library
+ - moved j2k_dump_{image,cp} to j2k_dump.c to remain consistent with API interface
+ - changed mj2 cmake compilation method: as long as mj2 binaries do not strictly use the API interface, libopenjpeg source files are directly included in mj2 executables compilation.
+! [antonin] small update to xcode project
+
December 14, 2010
! [szukw000] adapted Makefile.am/Makefile.nix to build
choice: shared xor static
${OPENJPEG_SOURCE_DIR}/libs/png ${OPENJPEG_SOURCE_DIR}/libs/lcms2
C:/WINDOWS/system32/user )
SET(CMAKE_LIBRARY_PATH ${OPENJPEG_SOURCE_DIR}/libs/libtiff
+ ${OPENJPEG_SOURCE_DIR}/libs/png ${OPENJPEG_SOURCE_DIR}/libs/lcms2
C:/WINDOWS/system32/user )
ENDIF()
#
SET(common_SRCS
convert.c
index.c
- ${PROJECT_SOURCE_DIR}/common/color.c
+ ${OPENJPEG_SOURCE_DIR}/common/color.c
)
# If not getopt was found then add it to the lib:
IF(DONT_HAVE_GETOPT)
SET(common_SRCS
${common_SRCS}
- ${PROJECT_SOURCE_DIR}/common/getopt.c
+ ${OPENJPEG_SOURCE_DIR}/common/getopt.c
)
ENDIF(DONT_HAVE_GETOPT)
INCLUDE_DIRECTORIES(${TIFF_INCLUDE_DIR})
ENDIF(TIFF_FOUND)
+IF(WIN32)
+ IF(BUILD_SHARED_LIBS)
+ ADD_DEFINITIONS(-DOPJ_EXPORTS)
+ ELSE(BUILD_SHARED_LIBS)
+ ADD_DEFINITIONS(-DOPJ_STATIC)
+ ENDIF(BUILD_SHARED_LIBS)
+ENDIF(WIN32)
+
# Loop over all executables:
FOREACH(exe j2k_to_image image_to_j2k j2k_dump)
ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS})
}
/* -------------------------------------------------------------------------- */
+static void j2k_dump_image(FILE *fd, opj_image_t * img);
+static void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp);
int get_num_images(char *imgdirpath){
DIR *dir;
return EXIT_SUCCESS;
}
+
+
+static void j2k_dump_image(FILE *fd, opj_image_t * img) {
+ int compno;
+ fprintf(fd, "image {\n");
+ fprintf(fd, " x0=%d, y0=%d, x1=%d, y1=%d\n", img->x0, img->y0, img->x1, img->y1);
+ fprintf(fd, " numcomps=%d\n", img->numcomps);
+ for (compno = 0; compno < img->numcomps; compno++) {
+ opj_image_comp_t *comp = &img->comps[compno];
+ fprintf(fd, " comp %d {\n", compno);
+ fprintf(fd, " dx=%d, dy=%d\n", comp->dx, comp->dy);
+ fprintf(fd, " prec=%d\n", comp->prec);
+ //fprintf(fd, " bpp=%d\n", comp->bpp);
+ fprintf(fd, " sgnd=%d\n", comp->sgnd);
+ fprintf(fd, " }\n");
+ }
+ fprintf(fd, "}\n");
+}
+
+static void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp) {
+ int tileno, compno, layno, bandno, resno, numbands;
+ fprintf(fd, "coding parameters {\n");
+ fprintf(fd, " tx0=%d, ty0=%d\n", cp->tx0, cp->ty0);
+ fprintf(fd, " tdx=%d, tdy=%d\n", cp->tdx, cp->tdy);
+ fprintf(fd, " tw=%d, th=%d\n", cp->tw, cp->th);
+ for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
+ opj_tcp_t *tcp = &cp->tcps[tileno];
+ fprintf(fd, " tile %d {\n", tileno);
+ fprintf(fd, " csty=%x\n", tcp->csty);
+ fprintf(fd, " prg=%d\n", tcp->prg);
+ fprintf(fd, " numlayers=%d\n", tcp->numlayers);
+ fprintf(fd, " mct=%d\n", tcp->mct);
+ fprintf(fd, " rates=");
+ for (layno = 0; layno < tcp->numlayers; layno++) {
+ fprintf(fd, "%.1f ", tcp->rates[layno]);
+ }
+ fprintf(fd, "\n");
+ for (compno = 0; compno < img->numcomps; compno++) {
+ opj_tccp_t *tccp = &tcp->tccps[compno];
+ fprintf(fd, " comp %d {\n", compno);
+ fprintf(fd, " csty=%x\n", tccp->csty);
+ fprintf(fd, " numresolutions=%d\n", tccp->numresolutions);
+ fprintf(fd, " cblkw=%d\n", tccp->cblkw);
+ fprintf(fd, " cblkh=%d\n", tccp->cblkh);
+ fprintf(fd, " cblksty=%x\n", tccp->cblksty);
+ fprintf(fd, " qmfbid=%d\n", tccp->qmfbid);
+ fprintf(fd, " qntsty=%d\n", tccp->qntsty);
+ fprintf(fd, " numgbits=%d\n", tccp->numgbits);
+ fprintf(fd, " roishift=%d\n", tccp->roishift);
+ fprintf(fd, " stepsizes=");
+ numbands = tccp->qntsty == J2K_CCP_QNTSTY_SIQNT ? 1 : tccp->numresolutions * 3 - 2;
+ for (bandno = 0; bandno < numbands; bandno++) {
+ fprintf(fd, "(%d,%d) ", tccp->stepsizes[bandno].mant,
+ tccp->stepsizes[bandno].expn);
+ }
+ fprintf(fd, "\n");
+
+ if (tccp->csty & J2K_CCP_CSTY_PRT) {
+ fprintf(fd, " prcw=");
+ for (resno = 0; resno < tccp->numresolutions; resno++) {
+ fprintf(fd, "%d ", tccp->prcw[resno]);
+ }
+ fprintf(fd, "\n");
+ fprintf(fd, " prch=");
+ for (resno = 0; resno < tccp->numresolutions; resno++) {
+ fprintf(fd, "%d ", tccp->prch[resno]);
+ }
+ fprintf(fd, "\n");
+ }
+ fprintf(fd, " }\n");
+ }
+ fprintf(fd, " }\n");
+ }
+ fprintf(fd, "}\n");
+}
+
)
ENDIF(DONT_HAVE_GETOPT)
+IF(WIN32)
+ IF(BUILD_SHARED_LIBS)
+ ADD_DEFINITIONS(-DOPJ_EXPORTS)
+ ELSE(BUILD_SHARED_LIBS)
+ ADD_DEFINITIONS(-DOPJ_STATIC)
+ ENDIF(BUILD_SHARED_LIBS)
+ENDIF(WIN32)
+
# Loop over all executables:
FOREACH(exe jp3d_to_volume volume_to_jp3d)
ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS})
)
SET(JPWL_SRCS crc.c jpwl.c jpwl_lib.c rs.c)
+SET(common_SRCS "")
# If not getopt was found then add it to the lib:
IF(DONT_HAVE_GETOPT)
- SET(OPJ_SRCS
- ${OPJ_SRCS}
- ../common/getopt.c
- )
+ SET(common_SRCS ${OPENJPEG_SOURCE_DIR}/common/getopt.c)
ENDIF(DONT_HAVE_GETOPT)
# Build the library
../codec/j2k_to_image.c
../codec/convert.c
../codec/index.c
-../common/color.c
+${OPENJPEG_SOURCE_DIR}/common/color.c
+${common_SRCS}
)
+
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image ${OPENJPEG_LIBRARY_NAME}_JPWL ${LCMS_LIB})
IF(PNG_FOUND)
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image ${PNG_LIBRARIES})
../codec/convert.c
../codec/index.c
../codec/image_to_j2k.c
+${common_SRCS}
)
+
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k ${OPENJPEG_LIBRARY_NAME}_JPWL ${LCMS_LIB})
IF(PNG_FOUND)
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k ${PNG_LIBRARIES})
return po->str_prog;
}
-void j2k_dump_image(FILE *fd, opj_image_t * img) {
- int compno;
- fprintf(fd, "image {\n");
- fprintf(fd, " x0=%d, y0=%d, x1=%d, y1=%d\n", img->x0, img->y0, img->x1, img->y1);
- fprintf(fd, " numcomps=%d\n", img->numcomps);
- for (compno = 0; compno < img->numcomps; compno++) {
- opj_image_comp_t *comp = &img->comps[compno];
- fprintf(fd, " comp %d {\n", compno);
- fprintf(fd, " dx=%d, dy=%d\n", comp->dx, comp->dy);
- fprintf(fd, " prec=%d\n", comp->prec);
- //fprintf(fd, " bpp=%d\n", comp->bpp);
- fprintf(fd, " sgnd=%d\n", comp->sgnd);
- fprintf(fd, " }\n");
- }
- fprintf(fd, "}\n");
-}
-
-void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp) {
- int tileno, compno, layno, bandno, resno, numbands;
- fprintf(fd, "coding parameters {\n");
- fprintf(fd, " tx0=%d, ty0=%d\n", cp->tx0, cp->ty0);
- fprintf(fd, " tdx=%d, tdy=%d\n", cp->tdx, cp->tdy);
- fprintf(fd, " tw=%d, th=%d\n", cp->tw, cp->th);
- for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
- opj_tcp_t *tcp = &cp->tcps[tileno];
- fprintf(fd, " tile %d {\n", tileno);
- fprintf(fd, " csty=%x\n", tcp->csty);
- fprintf(fd, " prg=%d\n", tcp->prg);
- fprintf(fd, " numlayers=%d\n", tcp->numlayers);
- fprintf(fd, " mct=%d\n", tcp->mct);
- fprintf(fd, " rates=");
- for (layno = 0; layno < tcp->numlayers; layno++) {
- fprintf(fd, "%.1f ", tcp->rates[layno]);
- }
- fprintf(fd, "\n");
- for (compno = 0; compno < img->numcomps; compno++) {
- opj_tccp_t *tccp = &tcp->tccps[compno];
- fprintf(fd, " comp %d {\n", compno);
- fprintf(fd, " csty=%x\n", tccp->csty);
- fprintf(fd, " numresolutions=%d\n", tccp->numresolutions);
- fprintf(fd, " cblkw=%d\n", tccp->cblkw);
- fprintf(fd, " cblkh=%d\n", tccp->cblkh);
- fprintf(fd, " cblksty=%x\n", tccp->cblksty);
- fprintf(fd, " qmfbid=%d\n", tccp->qmfbid);
- fprintf(fd, " qntsty=%d\n", tccp->qntsty);
- fprintf(fd, " numgbits=%d\n", tccp->numgbits);
- fprintf(fd, " roishift=%d\n", tccp->roishift);
- fprintf(fd, " stepsizes=");
- numbands = tccp->qntsty == J2K_CCP_QNTSTY_SIQNT ? 1 : tccp->numresolutions * 3 - 2;
- for (bandno = 0; bandno < numbands; bandno++) {
- fprintf(fd, "(%d,%d) ", tccp->stepsizes[bandno].mant,
- tccp->stepsizes[bandno].expn);
- }
- fprintf(fd, "\n");
-
- if (tccp->csty & J2K_CCP_CSTY_PRT) {
- fprintf(fd, " prcw=");
- for (resno = 0; resno < tccp->numresolutions; resno++) {
- fprintf(fd, "%d ", tccp->prcw[resno]);
- }
- fprintf(fd, "\n");
- fprintf(fd, " prch=");
- for (resno = 0; resno < tccp->numresolutions; resno++) {
- fprintf(fd, "%d ", tccp->prch[resno]);
- }
- fprintf(fd, "\n");
- }
- fprintf(fd, " }\n");
- }
- fprintf(fd, " }\n");
- }
- fprintf(fd, "}\n");
-}
-
/* ----------------------------------------------------------------------- */
static int j2k_get_num_tp(opj_cp_t *cp,int pino,int tileno){
char *prog;
cp = j2k->cp;
- /* j2k_dump_cp(stdout, image, cp); */
-
/* INDEX >> */
j2k->cstr_info = cstr_info;
if (cstr_info) {
*/
bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
-void j2k_dump_image(FILE *fd, opj_image_t * img);
-void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp);
/* ----------------------------------------------------------------------- */
/*@}*/
--- /dev/null
+//---------------------------------------------------------------------------------
+//
+// Little Color Management System
+// Copyright (c) 1998-2010 Marti Maria Saguer
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the Software
+// is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+//---------------------------------------------------------------------------------
+//
+// Version 2.0
+//
+
+#ifndef _lcms2_H
+
+// ********** Configuration toggles ****************************************
+
+// Uncomment this one if you are using big endian machines
+// #define CMS_USE_BIG_ENDIAN 1
+
+// Uncomment this one if your compiler/machine does NOT support the
+// "long long" type.
+// #define CMS_DONT_USE_INT64 1
+
+// Uncomment this if your compiler doesn't work with fast floor function
+// #define CMS_DONT_USE_FAST_FLOOR 1
+
+// Uncomment this line if your system does not support multithreading
+#define CMS_DONT_USE_PTHREADS 1
+
+// Uncomment this line if you want lcms to use the black point tag in profile,
+// if commented, lcms will compute the black point by its own.
+// It is safer to leave it commented out
+// #define CMS_USE_PROFILE_BLACK_POINT_TAG 1
+
+// Uncomment this line if you are compiling as C++ and want a C++ API
+// #define CMS_USE_CPP_API
+
+// Uncomment this line if you need strict CGATS syntax. Makes CGATS files to
+// require "KEYWORD" on undefined identifiers, keep it comented out unless needed
+// #define CMS_STRICT_CGATS 1
+
+// ********** End of configuration toggles ******************************
+
+// Needed for streams
+#include <stdio.h>
+
+// Needed for portability (C99 per 7.1.2)
+#include <limits.h>
+#include <time.h>
+#include <stddef.h>
+
+#ifndef CMS_USE_CPP_API
+# ifdef __cplusplus
+extern "C" {
+# endif
+#endif
+
+// Version/release
+#define LCMS_VERSION 2000
+
+// I will give the chance of redefining basic types for compilers that are not fully C99 compliant
+#ifndef CMS_BASIC_TYPES_ALREADY_DEFINED
+
+// Base types
+typedef unsigned char cmsUInt8Number; // That is guaranteed by the C99 spec
+typedef signed char cmsInt8Number; // That is guaranteed by the C99 spec
+
+// IEEE float storage numbers
+typedef float cmsFloat32Number;
+typedef double cmsFloat64Number;
+
+// 16-bit base types
+#if (USHRT_MAX == 65535U)
+ typedef unsigned short cmsUInt16Number;
+#elif (UINT_MAX == 65535U)
+ typedef unsigned int cmsUInt16Number;
+#else
+# error "Unable to find 16 bits unsigned type, unsupported compiler"
+#endif
+
+#if (SHRT_MAX == 32767)
+ typedef short cmsInt16Number;
+#elif (INT_MAX == 32767)
+ typedef int cmsInt16Number;
+#else
+# error "Unable to find 16 bits signed type, unsupported compiler"
+#endif
+
+// 32-bit base type
+#if (UINT_MAX == 4294967295U)
+ typedef unsigned int cmsUInt32Number;
+#elif (ULONG_MAX == 4294967295U)
+ typedef unsigned long cmsUInt32Number;
+#else
+# error "Unable to find 32 bit unsigned type, unsupported compiler"
+#endif
+
+#if (INT_MAX == +2147483647)
+ typedef int cmsInt32Number;
+#elif (LONG_MAX == +2147483647)
+ typedef long cmsInt32Number;
+#else
+# error "Unable to find 32 bit signed type, unsupported compiler"
+#endif
+
+// 64-bit base types
+#ifndef CMS_DONT_USE_INT64
+# if (ULONG_MAX == 18446744073709551615U)
+ typedef unsigned long cmsUInt64Number;
+# elif (ULLONG_MAX == 18446744073709551615U)
+ typedef unsigned long long cmsUInt64Number;
+# else
+# define CMS_DONT_USE_INT64 1
+# endif
+# if (LONG_MAX == +9223372036854775807)
+ typedef long cmsInt64Number;
+# elif (LLONG_MAX == +9223372036854775807)
+ typedef long long cmsInt64Number;
+# else
+# define CMS_DONT_USE_INT64 1
+# endif
+#endif
+#endif
+
+// In the case 64 bit numbers are not supported by the compiler
+#ifdef CMS_DONT_USE_INT64
+ typedef cmsUInt32Number cmsUInt64Number[2];
+ typedef cmsInt32Number cmsInt64Number[2];
+#endif
+
+// Derivative types
+typedef cmsUInt32Number cmsSignature;
+typedef cmsUInt16Number cmsU8Fixed8Number;
+typedef cmsInt32Number cmsS15Fixed16Number;
+typedef cmsUInt32Number cmsU16Fixed16Number;
+
+// Boolean type, which will be using the native integer
+typedef int cmsBool;
+
+// Try to detect windows
+#if defined (_WIN32) || defined(_WIN64) || defined(WIN32) || defined(_WIN32_)
+# define CMS_IS_WINDOWS_ 1
+#endif
+
+#ifdef _MSC_VER
+# define CMS_IS_WINDOWS_ 1
+#endif
+
+#ifdef __BORLANDC__
+# define CMS_IS_WINDOWS_ 1
+#endif
+
+// Try to detect big endian platforms. This list can be endless, so only some checks are performed over here.
+// you can pass this toggle to the compiler by using -DCMS_USE_BIG_ENDIAN or something similar
+
+#if defined(_HOST_BIG_ENDIAN) || defined(__BIG_ENDIAN__) || defined(WORDS_BIGENDIAN)
+# define CMS_USE_BIG_ENDIAN 1
+#endif
+
+#if defined(__sgi__) || defined(__sgi) || defined(__powerpc__) || defined(sparc)
+# define CMS_USE_BIG_ENDIAN 1
+#endif
+
+#if defined(__ppc__) || defined(__s390__) || defined(__s390x__)
+# define CMS_USE_BIG_ENDIAN 1
+#endif
+
+#ifdef TARGET_CPU_PPC
+# define CMS_USE_BIG_ENDIAN 1
+#endif
+
+#ifdef macintosh
+# ifndef __LITTLE_ENDIAN__
+# define CMS_USE_BIG_ENDIAN 1
+# endif
+#endif
+
+// Calling convention -- this is hardly platform and compiler dependent
+#ifdef CMS_IS_WINDOWS_
+# if defined(CMS_DLL) || defined(CMS_DLL_BUILD)
+# ifdef __BORLANDC__
+# define CMSEXPORT __stdcall _export
+# define CMSAPI
+# else
+# define CMSEXPORT _stdcall
+# ifdef CMS_DLL_BUILD
+# define CMSAPI __declspec(dllexport)
+# else
+# define CMSAPI __declspec(dllimport)
+# endif
+# endif
+# else
+# define CMSEXPORT
+# define CMSAPI
+# endif
+#else
+# define CMSEXPORT
+# define CMSAPI
+#endif
+
+// Some common definitions
+#define cmsMAX_PATH 256
+
+#ifndef FALSE
+# define FALSE 0
+#endif
+#ifndef TRUE
+# define TRUE 1
+#endif
+
+// D50 XYZ normalized to Y=1.0
+#define cmsD50X 0.9642
+#define cmsD50Y 1.0
+#define cmsD50Z 0.8249
+
+// V4 perceptual black
+#define cmsPERCEPTUAL_BLACK_X 0.00336
+#define cmsPERCEPTUAL_BLACK_Y 0.0034731
+#define cmsPERCEPTUAL_BLACK_Z 0.00287
+
+// Definitions in ICC spec
+#define cmsMagicNumber 0x61637370 // 'acsp'
+#define lcmsSignature 0x6c636d73 // 'lcms'
+
+
+// Base ICC type definitions
+typedef enum {
+ cmsSigChromaticityType = 0x6368726D, // 'chrm'
+ cmsSigColorantOrderType = 0x636C726F, // 'clro'
+ cmsSigColorantTableType = 0x636C7274, // 'clrt'
+ cmsSigCrdInfoType = 0x63726469, // 'crdi'
+ cmsSigCurveType = 0x63757276, // 'curv'
+ cmsSigDataType = 0x64617461, // 'data'
+ cmsSigDateTimeType = 0x6474696D, // 'dtim'
+ cmsSigDeviceSettingsType = 0x64657673, // 'devs'
+ cmsSigLut16Type = 0x6d667432, // 'mft2'
+ cmsSigLut8Type = 0x6d667431, // 'mft1'
+ cmsSigLutAtoBType = 0x6d414220, // 'mAB '
+ cmsSigLutBtoAType = 0x6d424120, // 'mBA '
+ cmsSigMeasurementType = 0x6D656173, // 'meas'
+ cmsSigMultiLocalizedUnicodeType = 0x6D6C7563, // 'mluc'
+ cmsSigMultiProcessElementType = 0x6D706574, // 'mpet'
+ cmsSigNamedColorType = 0x6E636f6C, // 'ncol' -- DEPRECATED!
+ cmsSigNamedColor2Type = 0x6E636C32, // 'ncl2'
+ cmsSigParametricCurveType = 0x70617261, // 'para'
+ cmsSigProfileSequenceDescType = 0x70736571, // 'pseq'
+ cmsSigProfileSequenceIdType = 0x70736964, // 'psid'
+ cmsSigResponseCurveSet16Type = 0x72637332, // 'rcs2'
+ cmsSigS15Fixed16ArrayType = 0x73663332, // 'sf32'
+ cmsSigScreeningType = 0x7363726E, // 'scrn'
+ cmsSigSignatureType = 0x73696720, // 'sig '
+ cmsSigTextType = 0x74657874, // 'text'
+ cmsSigTextDescriptionType = 0x64657363, // 'desc'
+ cmsSigU16Fixed16ArrayType = 0x75663332, // 'uf32'
+ cmsSigUcrBgType = 0x62666420, // 'bfd '
+ cmsSigUInt16ArrayType = 0x75693136, // 'ui16'
+ cmsSigUInt32ArrayType = 0x75693332, // 'ui32'
+ cmsSigUInt64ArrayType = 0x75693634, // 'ui64'
+ cmsSigUInt8ArrayType = 0x75693038, // 'ui08'
+ cmsSigViewingConditionsType = 0x76696577, // 'view'
+ cmsSigXYZType = 0x58595A20, // 'XYZ '
+ cmsSigVcgtType = 0x76636774 // 'vcgt'
+
+} cmsTagTypeSignature;
+
+// Base ICC tag definitions
+typedef enum {
+ cmsSigAToB0Tag = 0x41324230, // 'A2B0'
+ cmsSigAToB1Tag = 0x41324231, // 'A2B1'
+ cmsSigAToB2Tag = 0x41324232, // 'A2B2'
+ cmsSigBlueColorantTag = 0x6258595A, // 'bXYZ'
+ cmsSigBlueMatrixColumnTag = 0x6258595A, // 'bXYZ'
+ cmsSigBlueTRCTag = 0x62545243, // 'bTRC'
+ cmsSigBToA0Tag = 0x42324130, // 'B2A0'
+ cmsSigBToA1Tag = 0x42324131, // 'B2A1'
+ cmsSigBToA2Tag = 0x42324132, // 'B2A2'
+ cmsSigCalibrationDateTimeTag = 0x63616C74, // 'calt'
+ cmsSigCharTargetTag = 0x74617267, // 'targ'
+ cmsSigChromaticAdaptationTag = 0x63686164, // 'chad'
+ cmsSigChromaticityTag = 0x6368726D, // 'chrm'
+ cmsSigColorantOrderTag = 0x636C726F, // 'clro'
+ cmsSigColorantTableTag = 0x636C7274, // 'clrt'
+ cmsSigColorantTableOutTag = 0x636C6F74, // 'clot'
+ cmsSigColorimetricIntentImageStateTag = 0x63696973, // 'ciis'
+ cmsSigCopyrightTag = 0x63707274, // 'cprt'
+ cmsSigCrdInfoTag = 0x63726469, // 'crdi'
+ cmsSigDataTag = 0x64617461, // 'data'
+ cmsSigDateTimeTag = 0x6474696D, // 'dtim'
+ cmsSigDeviceMfgDescTag = 0x646D6E64, // 'dmnd'
+ cmsSigDeviceModelDescTag = 0x646D6464, // 'dmdd'
+ cmsSigDeviceSettingsTag = 0x64657673, // 'devs'
+ cmsSigDToB0Tag = 0x44324230, // 'D2B0'
+ cmsSigDToB1Tag = 0x44324231, // 'D2B1'
+ cmsSigDToB2Tag = 0x44324232, // 'D2B2'
+ cmsSigDToB3Tag = 0x44324233, // 'D2B3'
+ cmsSigBToD0Tag = 0x42324430, // 'B2D0'
+ cmsSigBToD1Tag = 0x42324431, // 'B2D1'
+ cmsSigBToD2Tag = 0x42324432, // 'B2D2'
+ cmsSigBToD3Tag = 0x42324433, // 'B2D3'
+ cmsSigGamutTag = 0x67616D74, // 'gamt'
+ cmsSigGrayTRCTag = 0x6b545243, // 'kTRC'
+ cmsSigGreenColorantTag = 0x6758595A, // 'gXYZ'
+ cmsSigGreenMatrixColumnTag = 0x6758595A, // 'gXYZ'
+ cmsSigGreenTRCTag = 0x67545243, // 'gTRC'
+ cmsSigLuminanceTag = 0x6C756d69, // 'lumi'
+ cmsSigMeasurementTag = 0x6D656173, // 'meas'
+ cmsSigMediaBlackPointTag = 0x626B7074, // 'bkpt'
+ cmsSigMediaWhitePointTag = 0x77747074, // 'wtpt'
+ cmsSigNamedColorTag = 0x6E636f6C, // 'ncol' // Deprecated by the ICC
+ cmsSigNamedColor2Tag = 0x6E636C32, // 'ncl2'
+ cmsSigOutputResponseTag = 0x72657370, // 'resp'
+ cmsSigPerceptualRenderingIntentGamutTag = 0x72696730, // 'rig0'
+ cmsSigPreview0Tag = 0x70726530, // 'pre0'
+ cmsSigPreview1Tag = 0x70726531, // 'pre1'
+ cmsSigPreview2Tag = 0x70726532, // 'pre2'
+ cmsSigProfileDescriptionTag = 0x64657363, // 'desc'
+ cmsSigProfileSequenceDescTag = 0x70736571, // 'pseq'
+ cmsSigProfileSequenceIdTag = 0x70736964, // 'psid'
+ cmsSigPs2CRD0Tag = 0x70736430, // 'psd0'
+ cmsSigPs2CRD1Tag = 0x70736431, // 'psd1'
+ cmsSigPs2CRD2Tag = 0x70736432, // 'psd2'
+ cmsSigPs2CRD3Tag = 0x70736433, // 'psd3'
+ cmsSigPs2CSATag = 0x70733273, // 'ps2s'
+ cmsSigPs2RenderingIntentTag = 0x70733269, // 'ps2i'
+ cmsSigRedColorantTag = 0x7258595A, // 'rXYZ'
+ cmsSigRedMatrixColumnTag = 0x7258595A, // 'rXYZ'
+ cmsSigRedTRCTag = 0x72545243, // 'rTRC'
+ cmsSigSaturationRenderingIntentGamutTag = 0x72696732, // 'rig2'
+ cmsSigScreeningDescTag = 0x73637264, // 'scrd'
+ cmsSigScreeningTag = 0x7363726E, // 'scrn'
+ cmsSigTechnologyTag = 0x74656368, // 'tech'
+ cmsSigUcrBgTag = 0x62666420, // 'bfd '
+ cmsSigViewingCondDescTag = 0x76756564, // 'vued'
+ cmsSigViewingConditionsTag = 0x76696577, // 'view'
+ cmsSigVcgtTag = 0x76636774 // 'vcgt'
+
+} cmsTagSignature;
+
+
+// ICC Technology tag
+typedef enum {
+ cmsSigDigitalCamera = 0x6463616D, // 'dcam'
+ cmsSigFilmScanner = 0x6673636E, // 'fscn'
+ cmsSigReflectiveScanner = 0x7273636E, // 'rscn'
+ cmsSigInkJetPrinter = 0x696A6574, // 'ijet'
+ cmsSigThermalWaxPrinter = 0x74776178, // 'twax'
+ cmsSigElectrophotographicPrinter = 0x6570686F, // 'epho'
+ cmsSigElectrostaticPrinter = 0x65737461, // 'esta'
+ cmsSigDyeSublimationPrinter = 0x64737562, // 'dsub'
+ cmsSigPhotographicPaperPrinter = 0x7270686F, // 'rpho'
+ cmsSigFilmWriter = 0x6670726E, // 'fprn'
+ cmsSigVideoMonitor = 0x7669646D, // 'vidm'
+ cmsSigVideoCamera = 0x76696463, // 'vidc'
+ cmsSigProjectionTelevision = 0x706A7476, // 'pjtv'
+ cmsSigCRTDisplay = 0x43525420, // 'CRT '
+ cmsSigPMDisplay = 0x504D4420, // 'PMD '
+ cmsSigAMDisplay = 0x414D4420, // 'AMD '
+ cmsSigPhotoCD = 0x4B504344, // 'KPCD'
+ cmsSigPhotoImageSetter = 0x696D6773, // 'imgs'
+ cmsSigGravure = 0x67726176, // 'grav'
+ cmsSigOffsetLithography = 0x6F666673, // 'offs'
+ cmsSigSilkscreen = 0x73696C6B, // 'silk'
+ cmsSigFlexography = 0x666C6578, // 'flex'
+ cmsSigMotionPictureFilmScanner = 0x6D706673, // 'mpfs'
+ cmsSigMotionPictureFilmRecorder = 0x6D706672, // 'mpfr'
+ cmsSigDigitalMotionPictureCamera = 0x646D7063, // 'dmpc'
+ cmsSigDigitalCinemaProjector = 0x64636A70, // 'dcpj'
+
+} cmsTechnologySignature;
+
+
+// ICC Color spaces
+typedef enum {
+ cmsSigXYZData = 0x58595A20, // 'XYZ '
+ cmsSigLabData = 0x4C616220, // 'Lab '
+ cmsSigLuvData = 0x4C757620, // 'Luv '
+ cmsSigYCbCrData = 0x59436272, // 'YCbr'
+ cmsSigYxyData = 0x59787920, // 'Yxy '
+ cmsSigRgbData = 0x52474220, // 'RGB '
+ cmsSigGrayData = 0x47524159, // 'GRAY'
+ cmsSigHsvData = 0x48535620, // 'HSV '
+ cmsSigHlsData = 0x484C5320, // 'HLS '
+ cmsSigCmykData = 0x434D594B, // 'CMYK'
+ cmsSigCmyData = 0x434D5920, // 'CMY '
+ cmsSigMCH1Data = 0x4D434831, // 'MCH1'
+ cmsSigMCH2Data = 0x4D434832, // 'MCH2'
+ cmsSigMCH3Data = 0x4D434833, // 'MCH3'
+ cmsSigMCH4Data = 0x4D434834, // 'MCH4'
+ cmsSigMCH5Data = 0x4D434835, // 'MCH5'
+ cmsSigMCH6Data = 0x4D434836, // 'MCH6'
+ cmsSigMCH7Data = 0x4D434837, // 'MCH7'
+ cmsSigMCH8Data = 0x4D434838, // 'MCH8'
+ cmsSigMCH9Data = 0x4D434839, // 'MCH9'
+ cmsSigMCHAData = 0x4D43483A, // 'MCHA'
+ cmsSigMCHBData = 0x4D43483B, // 'MCHB'
+ cmsSigMCHCData = 0x4D43483C, // 'MCHC'
+ cmsSigMCHDData = 0x4D43483D, // 'MCHD'
+ cmsSigMCHEData = 0x4D43483E, // 'MCHE'
+ cmsSigMCHFData = 0x4D43483F, // 'MCHF'
+ cmsSigNamedData = 0x6e6d636c, // 'nmcl'
+ cmsSig1colorData = 0x31434C52, // '1CLR'
+ cmsSig2colorData = 0x32434C52, // '2CLR'
+ cmsSig3colorData = 0x33434C52, // '3CLR'
+ cmsSig4colorData = 0x34434C52, // '4CLR'
+ cmsSig5colorData = 0x35434C52, // '5CLR'
+ cmsSig6colorData = 0x36434C52, // '6CLR'
+ cmsSig7colorData = 0x37434C52, // '7CLR'
+ cmsSig8colorData = 0x38434C52, // '8CLR'
+ cmsSig9colorData = 0x39434C52, // '9CLR'
+ cmsSig10colorData = 0x41434C52, // 'ACLR'
+ cmsSig11colorData = 0x42434C52, // 'BCLR'
+ cmsSig12colorData = 0x43434C52, // 'CCLR'
+ cmsSig13colorData = 0x44434C52, // 'DCLR'
+ cmsSig14colorData = 0x45434C52, // 'ECLR'
+ cmsSig15colorData = 0x46434C52, // 'FCLR'
+ cmsSigLuvKData = 0x4C75764B // 'LuvK'
+
+} cmsColorSpaceSignature;
+
+// ICC Profile Class
+typedef enum {
+ cmsSigInputClass = 0x73636E72, // 'scnr'
+ cmsSigDisplayClass = 0x6D6E7472, // 'mntr'
+ cmsSigOutputClass = 0x70727472, // 'prtr'
+ cmsSigLinkClass = 0x6C696E6B, // 'link'
+ cmsSigAbstractClass = 0x61627374, // 'abst'
+ cmsSigColorSpaceClass = 0x73706163, // 'spac'
+ cmsSigNamedColorClass = 0x6e6d636c, // 'nmcl'
+
+} cmsProfileClassSignature;
+
+// ICC Platforms
+typedef enum {
+ cmsSigMacintosh = 0x4150504C, // 'APPL'
+ cmsSigMicrosoft = 0x4D534654, // 'MSFT'
+ cmsSigSolaris = 0x53554E57, // 'SUNW'
+ cmsSigSGI = 0x53474920, // 'SGI '
+ cmsSigTaligent = 0x54474E54, // 'TGNT'
+ cmsSigUnices = 0x2A6E6978 // '*nix' // From argyll -- Not official
+
+} cmsPlatformSignature;
+
+// Reference gamut
+#define cmsSigPerceptualReferenceMediumGamut 0x70726d67 //'prmg'
+
+// For cmsSigColorimetricIntentImageStateTag
+#define cmsSigSceneColorimetryEstimates 0x73636F65 //'scoe'
+#define cmsSigSceneAppearanceEstimates 0x73617065 //'sape'
+#define cmsSigFocalPlaneColorimetryEstimates 0x66706365 //'fpce'
+#define cmsSigReflectionHardcopyOriginalColorimetry 0x72686F63 //'rhoc'
+#define cmsSigReflectionPrintOutputColorimetry 0x72706F63 //'rpoc'
+
+// Multi process elements types
+typedef enum {
+ cmsSigCurveSetElemType = 0x63767374, //'cvst'
+ cmsSigMatrixElemType = 0x6D617466, //'matf'
+ cmsSigCLutElemType = 0x636C7574, //'clut'
+
+ cmsSigBAcsElemType = 0x62414353, // 'bACS'
+ cmsSigEAcsElemType = 0x65414353, // 'eACS'
+
+ // Custom from here, not in the ICC Spec
+ cmsSigXYZ2LabElemType = 0x6C327820, // 'l2x '
+ cmsSigLab2XYZElemType = 0x78326C20, // 'x2l '
+ cmsSigNamedColorElemType = 0x6E636C20, // 'ncl '
+ cmsSigLabV2toV4 = 0x32203420, // '2 4 '
+ cmsSigLabV4toV2 = 0x34203220, // '4 2 '
+
+ // Identities
+ cmsSigIdentityElemType = 0x69646E20 // 'idn '
+
+} cmsStageSignature;
+
+// Types of CurveElements
+typedef enum {
+
+ cmsSigFormulaCurveSeg = 0x70617266, // 'parf'
+ cmsSigSampledCurveSeg = 0x73616D66, // 'samf'
+ cmsSigSegmentedCurve = 0x63757266 // 'curf'
+
+} cmsCurveSegSignature;
+
+// Used in ResponseCurveType
+#define cmsSigStatusA 0x53746141 //'StaA'
+#define cmsSigStatusE 0x53746145 //'StaE'
+#define cmsSigStatusI 0x53746149 //'StaI'
+#define cmsSigStatusT 0x53746154 //'StaT'
+#define cmsSigStatusM 0x5374614D //'StaM'
+#define cmsSigDN 0x444E2020 //'DN '
+#define cmsSigDNP 0x444E2050 //'DN P'
+#define cmsSigDNN 0x444E4E20 //'DNN '
+#define cmsSigDNNP 0x444E4E50 //'DNNP'
+
+// Device attributes, currently defined values correspond to the low 4 bytes
+// of the 8 byte attribute quantity
+#define cmsReflective 0
+#define cmsTransparency 1
+#define cmsGlossy 0
+#define cmsMatte 2
+
+// Common structures in ICC tags
+typedef struct {
+ cmsUInt32Number len;
+ cmsUInt32Number flag;
+ cmsUInt8Number data[1];
+
+} cmsICCData;
+
+// ICC date time
+typedef struct {
+ cmsUInt16Number year;
+ cmsUInt16Number month;
+ cmsUInt16Number day;
+ cmsUInt16Number hours;
+ cmsUInt16Number minutes;
+ cmsUInt16Number seconds;
+
+} cmsDateTimeNumber;
+
+// ICC XYZ
+typedef struct {
+ cmsS15Fixed16Number X;
+ cmsS15Fixed16Number Y;
+ cmsS15Fixed16Number Z;
+
+} cmsEncodedXYZNumber;
+
+
+// Profile ID as computed by MD5 algorithm
+typedef union {
+ cmsUInt8Number ID8[16];
+ cmsUInt16Number ID16[8];
+ cmsUInt32Number ID32[4];
+
+} cmsProfileID;
+
+
+// ----------------------------------------------------------------------------------------------
+// ICC profile internal base types. Strictly, shouldn't be declared in this header, but maybe
+// somebody want to use this info for accessing profile header directly, so here it is.
+
+// Profile header -- it is 32-bit aligned, so no issues are expected on alignment
+typedef struct {
+ cmsUInt32Number size; // Profile size in bytes
+ cmsSignature cmmId; // CMM for this profile
+ cmsUInt32Number version; // Format version number
+ cmsProfileClassSignature deviceClass; // Type of profile
+ cmsColorSpaceSignature colorSpace; // Color space of data
+ cmsColorSpaceSignature pcs; // PCS, XYZ or Lab only
+ cmsDateTimeNumber date; // Date profile was created
+ cmsSignature magic; // Magic Number to identify an ICC profile
+ cmsPlatformSignature platform; // Primary Platform
+ cmsUInt32Number flags; // Various bit settings
+ cmsSignature manufacturer; // Device manufacturer
+ cmsUInt32Number model; // Device model number
+ cmsUInt64Number attributes; // Device attributes
+ cmsUInt32Number renderingIntent;// Rendering intent
+ cmsEncodedXYZNumber illuminant; // Profile illuminant
+ cmsSignature creator; // Profile creator
+ cmsProfileID profileID; // Profile ID using MD5
+ cmsInt8Number reserved[28]; // Reserved for future use
+
+} cmsICCHeader;
+
+// ICC base tag
+typedef struct {
+ cmsTagTypeSignature sig;
+ cmsInt8Number reserved[4];
+
+} cmsTagBase;
+
+// A tag entry in directory
+typedef struct {
+ cmsTagSignature sig; // The tag signature
+ cmsUInt32Number offset; // Start of tag
+ cmsUInt32Number size; // Size in bytes
+
+} cmsTagEntry;
+
+// ----------------------------------------------------------------------------------------------
+
+// Little CMS specific typedefs
+
+typedef void* cmsContext; // Context identifier for multithreaded environments
+typedef void* cmsHANDLE ; // Generic handle
+typedef void* cmsHPROFILE; // Opaque typedefs to hide internals
+typedef void* cmsHTRANSFORM;
+
+#define cmsMAXCHANNELS 16 // Maximum number of channels in ICC profiles
+
+// Format of pixel is defined by one cmsUInt32Number, using bit fields as follows
+//
+// A O TTTTT U Y F P X S EEE CCCC BBB
+//
+// A: Floating point -- With this flag we can differentiate 16 bits as float and as int
+// O: Optimized -- previous optimization already returns the final 8-bit value
+// T: Pixeltype
+// F: Flavor 0=MinIsBlack(Chocolate) 1=MinIsWhite(Vanilla)
+// P: Planar? 0=Chunky, 1=Planar
+// X: swap 16 bps endianess?
+// S: Do swap? ie, BGR, KYMC
+// E: Extra samples
+// C: Channels (Samples per pixel)
+// B: bytes per sample
+// Y: Swap first - changes ABGR to BGRA and KCMY to CMYK
+
+#define FLOAT_SH(a) ((a) << 22)
+#define OPTIMIZED_SH(s) ((s) << 21)
+#define COLORSPACE_SH(s) ((s) << 16)
+#define SWAPFIRST_SH(s) ((s) << 14)
+#define FLAVOR_SH(s) ((s) << 13)
+#define PLANAR_SH(p) ((p) << 12)
+#define ENDIAN16_SH(e) ((e) << 11)
+#define DOSWAP_SH(e) ((e) << 10)
+#define EXTRA_SH(e) ((e) << 7)
+#define CHANNELS_SH(c) ((c) << 3)
+#define BYTES_SH(b) (b)
+
+// These macros unpack format specifiers into integers
+#define T_FLOAT(a) (((a)>>22)&1)
+#define T_OPTIMIZED(o) (((o)>>21)&1)
+#define T_COLORSPACE(s) (((s)>>16)&31)
+#define T_SWAPFIRST(s) (((s)>>14)&1)
+#define T_FLAVOR(s) (((s)>>13)&1)
+#define T_PLANAR(p) (((p)>>12)&1)
+#define T_ENDIAN16(e) (((e)>>11)&1)
+#define T_DOSWAP(e) (((e)>>10)&1)
+#define T_EXTRA(e) (((e)>>7)&7)
+#define T_CHANNELS(c) (((c)>>3)&15)
+#define T_BYTES(b) ((b)&7)
+
+
+// Pixel types
+#define PT_ANY 0 // Don't check colorspace
+ // 1 & 2 are reserved
+#define PT_GRAY 3
+#define PT_RGB 4
+#define PT_CMY 5
+#define PT_CMYK 6
+#define PT_YCbCr 7
+#define PT_YUV 8 // Lu'v'
+#define PT_XYZ 9
+#define PT_Lab 10
+#define PT_YUVK 11 // Lu'v'K
+#define PT_HSV 12
+#define PT_HLS 13
+#define PT_Yxy 14
+
+#define PT_MCH1 15
+#define PT_MCH2 16
+#define PT_MCH3 17
+#define PT_MCH4 18
+#define PT_MCH5 19
+#define PT_MCH6 20
+#define PT_MCH7 21
+#define PT_MCH8 22
+#define PT_MCH9 23
+#define PT_MCH10 24
+#define PT_MCH11 25
+#define PT_MCH12 26
+#define PT_MCH13 27
+#define PT_MCH14 28
+#define PT_MCH15 29
+
+#define PT_LabV2 30 // Identical to PT_Lab, but using the V2 old encoding
+
+// Some (not all!) representations
+
+#ifndef TYPE_RGB_8 // TYPE_RGB_8 is a very common identifier, so don't include ours
+ // if user has it already defined.
+
+#define TYPE_GRAY_8 (COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(1))
+#define TYPE_GRAY_8_REV (COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(1)|FLAVOR_SH(1))
+#define TYPE_GRAY_16 (COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(2))
+#define TYPE_GRAY_16_REV (COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(2)|FLAVOR_SH(1))
+#define TYPE_GRAY_16_SE (COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(2)|ENDIAN16_SH(1))
+#define TYPE_GRAYA_8 (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(1))
+#define TYPE_GRAYA_16 (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(2))
+#define TYPE_GRAYA_16_SE (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(2)|ENDIAN16_SH(1))
+#define TYPE_GRAYA_8_PLANAR (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(1)|PLANAR_SH(1))
+#define TYPE_GRAYA_16_PLANAR (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(2)|PLANAR_SH(1))
+
+#define TYPE_RGB_8 (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(1))
+#define TYPE_RGB_8_PLANAR (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
+#define TYPE_BGR_8 (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1))
+#define TYPE_BGR_8_PLANAR (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|PLANAR_SH(1))
+#define TYPE_RGB_16 (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2))
+#define TYPE_RGB_16_PLANAR (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
+#define TYPE_RGB_16_SE (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
+#define TYPE_BGR_16 (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1))
+#define TYPE_BGR_16_PLANAR (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|PLANAR_SH(1))
+#define TYPE_BGR_16_SE (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
+
+#define TYPE_RGBA_8 (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1))
+#define TYPE_RGBA_8_PLANAR (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
+#define TYPE_RGBA_16 (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2))
+#define TYPE_RGBA_16_PLANAR (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
+#define TYPE_RGBA_16_SE (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
+
+#define TYPE_ARGB_8 (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|SWAPFIRST_SH(1))
+#define TYPE_ARGB_16 (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|SWAPFIRST_SH(1))
+
+#define TYPE_ABGR_8 (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1))
+#define TYPE_ABGR_16 (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1))
+#define TYPE_ABGR_16_PLANAR (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|PLANAR_SH(1))
+#define TYPE_ABGR_16_SE (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
+
+#define TYPE_BGRA_8 (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1))
+#define TYPE_BGRA_16 (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|SWAPFIRST_SH(1))
+#define TYPE_BGRA_16_SE (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1)|SWAPFIRST_SH(1))
+
+#define TYPE_CMY_8 (COLORSPACE_SH(PT_CMY)|CHANNELS_SH(3)|BYTES_SH(1))
+#define TYPE_CMY_8_PLANAR (COLORSPACE_SH(PT_CMY)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
+#define TYPE_CMY_16 (COLORSPACE_SH(PT_CMY)|CHANNELS_SH(3)|BYTES_SH(2))
+#define TYPE_CMY_16_PLANAR (COLORSPACE_SH(PT_CMY)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
+#define TYPE_CMY_16_SE (COLORSPACE_SH(PT_CMY)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
+
+#define TYPE_CMYK_8 (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(1))
+#define TYPE_CMYKA_8 (COLORSPACE_SH(PT_CMYK)|EXTRA_SH(1)|CHANNELS_SH(4)|BYTES_SH(1))
+#define TYPE_CMYK_8_REV (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(1)|FLAVOR_SH(1))
+#define TYPE_YUVK_8 TYPE_CMYK_8_REV
+#define TYPE_CMYK_8_PLANAR (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(1)|PLANAR_SH(1))
+#define TYPE_CMYK_16 (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2))
+#define TYPE_CMYK_16_REV (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|FLAVOR_SH(1))
+#define TYPE_YUVK_16 TYPE_CMYK_16_REV
+#define TYPE_CMYK_16_PLANAR (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|PLANAR_SH(1))
+#define TYPE_CMYK_16_SE (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|ENDIAN16_SH(1))
+
+#define TYPE_KYMC_8 (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(1)|DOSWAP_SH(1))
+#define TYPE_KYMC_16 (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|DOSWAP_SH(1))
+#define TYPE_KYMC_16_SE (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
+
+#define TYPE_KCMY_8 (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(1)|SWAPFIRST_SH(1))
+#define TYPE_KCMY_8_REV (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(1)|FLAVOR_SH(1)|SWAPFIRST_SH(1))
+#define TYPE_KCMY_16 (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|SWAPFIRST_SH(1))
+#define TYPE_KCMY_16_REV (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|FLAVOR_SH(1)|SWAPFIRST_SH(1))
+#define TYPE_KCMY_16_SE (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|ENDIAN16_SH(1)|SWAPFIRST_SH(1))
+
+#define TYPE_CMYK5_8 (COLORSPACE_SH(PT_MCH5)|CHANNELS_SH(5)|BYTES_SH(1))
+#define TYPE_CMYK5_16 (COLORSPACE_SH(PT_MCH5)|CHANNELS_SH(5)|BYTES_SH(2))
+#define TYPE_CMYK5_16_SE (COLORSPACE_SH(PT_MCH5)|CHANNELS_SH(5)|BYTES_SH(2)|ENDIAN16_SH(1))
+#define TYPE_KYMC5_8 (COLORSPACE_SH(PT_MCH5)|CHANNELS_SH(5)|BYTES_SH(1)|DOSWAP_SH(1))
+#define TYPE_KYMC5_16 (COLORSPACE_SH(PT_MCH5)|CHANNELS_SH(5)|BYTES_SH(2)|DOSWAP_SH(1))
+#define TYPE_KYMC5_16_SE (COLORSPACE_SH(PT_MCH5)|CHANNELS_SH(5)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
+#define TYPE_CMYK6_8 (COLORSPACE_SH(PT_MCH6)|CHANNELS_SH(6)|BYTES_SH(1))
+#define TYPE_CMYK6_8_PLANAR (COLORSPACE_SH(PT_MCH6)|CHANNELS_SH(6)|BYTES_SH(1)|PLANAR_SH(1))
+#define TYPE_CMYK6_16 (COLORSPACE_SH(PT_MCH6)|CHANNELS_SH(6)|BYTES_SH(2))
+#define TYPE_CMYK6_16_PLANAR (COLORSPACE_SH(PT_MCH6)|CHANNELS_SH(6)|BYTES_SH(2)|PLANAR_SH(1))
+#define TYPE_CMYK6_16_SE (COLORSPACE_SH(PT_MCH6)|CHANNELS_SH(6)|BYTES_SH(2)|ENDIAN16_SH(1))
+#define TYPE_CMYK7_8 (COLORSPACE_SH(PT_MCH7)|CHANNELS_SH(7)|BYTES_SH(1))
+#define TYPE_CMYK7_16 (COLORSPACE_SH(PT_MCH7)|CHANNELS_SH(7)|BYTES_SH(2))
+#define TYPE_CMYK7_16_SE (COLORSPACE_SH(PT_MCH7)|CHANNELS_SH(7)|BYTES_SH(2)|ENDIAN16_SH(1))
+#define TYPE_KYMC7_8 (COLORSPACE_SH(PT_MCH7)|CHANNELS_SH(7)|BYTES_SH(1)|DOSWAP_SH(1))
+#define TYPE_KYMC7_16 (COLORSPACE_SH(PT_MCH7)|CHANNELS_SH(7)|BYTES_SH(2)|DOSWAP_SH(1))
+#define TYPE_KYMC7_16_SE (COLORSPACE_SH(PT_MCH7)|CHANNELS_SH(7)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
+#define TYPE_CMYK8_8 (COLORSPACE_SH(PT_MCH8)|CHANNELS_SH(8)|BYTES_SH(1))
+#define TYPE_CMYK8_16 (COLORSPACE_SH(PT_MCH8)|CHANNELS_SH(8)|BYTES_SH(2))
+#define TYPE_CMYK8_16_SE (COLORSPACE_SH(PT_MCH8)|CHANNELS_SH(8)|BYTES_SH(2)|ENDIAN16_SH(1))
+#define TYPE_KYMC8_8 (COLORSPACE_SH(PT_MCH8)|CHANNELS_SH(8)|BYTES_SH(1)|DOSWAP_SH(1))
+#define TYPE_KYMC8_16 (COLORSPACE_SH(PT_MCH8)|CHANNELS_SH(8)|BYTES_SH(2)|DOSWAP_SH(1))
+#define TYPE_KYMC8_16_SE (COLORSPACE_SH(PT_MCH8)|CHANNELS_SH(8)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
+#define TYPE_CMYK9_8 (COLORSPACE_SH(PT_MCH9)|CHANNELS_SH(9)|BYTES_SH(1))
+#define TYPE_CMYK9_16 (COLORSPACE_SH(PT_MCH9)|CHANNELS_SH(9)|BYTES_SH(2))
+#define TYPE_CMYK9_16_SE (COLORSPACE_SH(PT_MCH9)|CHANNELS_SH(9)|BYTES_SH(2)|ENDIAN16_SH(1))
+#define TYPE_KYMC9_8 (COLORSPACE_SH(PT_MCH9)|CHANNELS_SH(9)|BYTES_SH(1)|DOSWAP_SH(1))
+#define TYPE_KYMC9_16 (COLORSPACE_SH(PT_MCH9)|CHANNELS_SH(9)|BYTES_SH(2)|DOSWAP_SH(1))
+#define TYPE_KYMC9_16_SE (COLORSPACE_SH(PT_MCH9)|CHANNELS_SH(9)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
+#define TYPE_CMYK10_8 (COLORSPACE_SH(PT_MCH10)|CHANNELS_SH(10)|BYTES_SH(1))
+#define TYPE_CMYK10_16 (COLORSPACE_SH(PT_MCH10)|CHANNELS_SH(10)|BYTES_SH(2))
+#define TYPE_CMYK10_16_SE (COLORSPACE_SH(PT_MCH10)|CHANNELS_SH(10)|BYTES_SH(2)|ENDIAN16_SH(1))
+#define TYPE_KYMC10_8 (COLORSPACE_SH(PT_MCH10)|CHANNELS_SH(10)|BYTES_SH(1)|DOSWAP_SH(1))
+#define TYPE_KYMC10_16 (COLORSPACE_SH(PT_MCH10)|CHANNELS_SH(10)|BYTES_SH(2)|DOSWAP_SH(1))
+#define TYPE_KYMC10_16_SE (COLORSPACE_SH(PT_MCH10)|CHANNELS_SH(10)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
+#define TYPE_CMYK11_8 (COLORSPACE_SH(PT_MCH11)|CHANNELS_SH(11)|BYTES_SH(1))
+#define TYPE_CMYK11_16 (COLORSPACE_SH(PT_MCH11)|CHANNELS_SH(11)|BYTES_SH(2))
+#define TYPE_CMYK11_16_SE (COLORSPACE_SH(PT_MCH11)|CHANNELS_SH(11)|BYTES_SH(2)|ENDIAN16_SH(1))
+#define TYPE_KYMC11_8 (COLORSPACE_SH(PT_MCH11)|CHANNELS_SH(11)|BYTES_SH(1)|DOSWAP_SH(1))
+#define TYPE_KYMC11_16 (COLORSPACE_SH(PT_MCH11)|CHANNELS_SH(11)|BYTES_SH(2)|DOSWAP_SH(1))
+#define TYPE_KYMC11_16_SE (COLORSPACE_SH(PT_MCH11)|CHANNELS_SH(11)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
+#define TYPE_CMYK12_8 (COLORSPACE_SH(PT_MCH12)|CHANNELS_SH(12)|BYTES_SH(1))
+#define TYPE_CMYK12_16 (COLORSPACE_SH(PT_MCH12)|CHANNELS_SH(12)|BYTES_SH(2))
+#define TYPE_CMYK12_16_SE (COLORSPACE_SH(PT_MCH12)|CHANNELS_SH(12)|BYTES_SH(2)|ENDIAN16_SH(1))
+#define TYPE_KYMC12_8 (COLORSPACE_SH(PT_MCH12)|CHANNELS_SH(12)|BYTES_SH(1)|DOSWAP_SH(1))
+#define TYPE_KYMC12_16 (COLORSPACE_SH(PT_MCH12)|CHANNELS_SH(12)|BYTES_SH(2)|DOSWAP_SH(1))
+#define TYPE_KYMC12_16_SE (COLORSPACE_SH(PT_MCH12)|CHANNELS_SH(12)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
+
+// Colorimetric
+#define TYPE_XYZ_16 (COLORSPACE_SH(PT_XYZ)|CHANNELS_SH(3)|BYTES_SH(2))
+#define TYPE_Lab_8 (COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(1))
+#define TYPE_LabV2_8 (COLORSPACE_SH(PT_LabV2)|CHANNELS_SH(3)|BYTES_SH(1))
+
+#define TYPE_ALab_8 (COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(1)|EXTRA_SH(1)|DOSWAP_SH(1))
+#define TYPE_ALabV2_8 (COLORSPACE_SH(PT_LabV2)|CHANNELS_SH(3)|BYTES_SH(1)|EXTRA_SH(1)|DOSWAP_SH(1))
+#define TYPE_Lab_16 (COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(2))
+#define TYPE_LabV2_16 (COLORSPACE_SH(PT_LabV2)|CHANNELS_SH(3)|BYTES_SH(2))
+#define TYPE_Yxy_16 (COLORSPACE_SH(PT_Yxy)|CHANNELS_SH(3)|BYTES_SH(2))
+
+// YCbCr
+#define TYPE_YCbCr_8 (COLORSPACE_SH(PT_YCbCr)|CHANNELS_SH(3)|BYTES_SH(1))
+#define TYPE_YCbCr_8_PLANAR (COLORSPACE_SH(PT_YCbCr)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
+#define TYPE_YCbCr_16 (COLORSPACE_SH(PT_YCbCr)|CHANNELS_SH(3)|BYTES_SH(2))
+#define TYPE_YCbCr_16_PLANAR (COLORSPACE_SH(PT_YCbCr)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
+#define TYPE_YCbCr_16_SE (COLORSPACE_SH(PT_YCbCr)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
+
+// YUV
+#define TYPE_YUV_8 (COLORSPACE_SH(PT_YUV)|CHANNELS_SH(3)|BYTES_SH(1))
+#define TYPE_YUV_8_PLANAR (COLORSPACE_SH(PT_YUV)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
+#define TYPE_YUV_16 (COLORSPACE_SH(PT_YUV)|CHANNELS_SH(3)|BYTES_SH(2))
+#define TYPE_YUV_16_PLANAR (COLORSPACE_SH(PT_YUV)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
+#define TYPE_YUV_16_SE (COLORSPACE_SH(PT_YUV)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
+
+// HLS
+#define TYPE_HLS_8 (COLORSPACE_SH(PT_HLS)|CHANNELS_SH(3)|BYTES_SH(1))
+#define TYPE_HLS_8_PLANAR (COLORSPACE_SH(PT_HLS)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
+#define TYPE_HLS_16 (COLORSPACE_SH(PT_HLS)|CHANNELS_SH(3)|BYTES_SH(2))
+#define TYPE_HLS_16_PLANAR (COLORSPACE_SH(PT_HLS)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
+#define TYPE_HLS_16_SE (COLORSPACE_SH(PT_HLS)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
+
+// HSV
+#define TYPE_HSV_8 (COLORSPACE_SH(PT_HSV)|CHANNELS_SH(3)|BYTES_SH(1))
+#define TYPE_HSV_8_PLANAR (COLORSPACE_SH(PT_HSV)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
+#define TYPE_HSV_16 (COLORSPACE_SH(PT_HSV)|CHANNELS_SH(3)|BYTES_SH(2))
+#define TYPE_HSV_16_PLANAR (COLORSPACE_SH(PT_HSV)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
+#define TYPE_HSV_16_SE (COLORSPACE_SH(PT_HSV)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
+
+// Named color index. Only 16 bits allowed (don't check colorspace)
+#define TYPE_NAMED_COLOR_INDEX (CHANNELS_SH(1)|BYTES_SH(2))
+
+// Float formatters.
+#define TYPE_XYZ_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_XYZ)|CHANNELS_SH(3)|BYTES_SH(4))
+#define TYPE_Lab_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(4))
+#define TYPE_GRAY_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(4))
+#define TYPE_RGB_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(4))
+#define TYPE_CMYK_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(4))
+
+// Floating point formatters.
+// NOTE THAT 'BYTES' FIELD IS SET TO ZERO ON DLB because 8 bytes overflows the bitfield
+#define TYPE_XYZ_DBL (FLOAT_SH(1)|COLORSPACE_SH(PT_XYZ)|CHANNELS_SH(3)|BYTES_SH(0))
+#define TYPE_Lab_DBL (FLOAT_SH(1)|COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(0))
+#define TYPE_GRAY_DBL (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(0))
+#define TYPE_RGB_DBL (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(0))
+#define TYPE_CMYK_DBL (FLOAT_SH(1)|COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(0))
+
+#endif
+
+// Colorspaces
+typedef struct {
+ cmsFloat64Number X;
+ cmsFloat64Number Y;
+ cmsFloat64Number Z;
+
+ } cmsCIEXYZ;
+
+typedef struct {
+ cmsFloat64Number x;
+ cmsFloat64Number y;
+ cmsFloat64Number Y;
+
+ } cmsCIExyY;
+
+typedef struct {
+ cmsFloat64Number L;
+ cmsFloat64Number a;
+ cmsFloat64Number b;
+
+ } cmsCIELab;
+
+typedef struct {
+ cmsFloat64Number L;
+ cmsFloat64Number C;
+ cmsFloat64Number h;
+
+ } cmsCIELCh;
+
+typedef struct {
+ cmsFloat64Number J;
+ cmsFloat64Number C;
+ cmsFloat64Number h;
+
+ } cmsJCh;
+
+typedef struct {
+ cmsCIEXYZ Red;
+ cmsCIEXYZ Green;
+ cmsCIEXYZ Blue;
+
+ } cmsCIEXYZTRIPLE;
+
+typedef struct {
+ cmsCIExyY Red;
+ cmsCIExyY Green;
+ cmsCIExyY Blue;
+
+ } cmsCIExyYTRIPLE;
+
+// Illuminant types for structs below
+#define cmsILLUMINANT_TYPE_UNKNOWN 0x0000000
+#define cmsILLUMINANT_TYPE_D50 0x0000001
+#define cmsILLUMINANT_TYPE_D65 0x0000002
+#define cmsILLUMINANT_TYPE_D93 0x0000003
+#define cmsILLUMINANT_TYPE_F2 0x0000004
+#define cmsILLUMINANT_TYPE_D55 0x0000005
+#define cmsILLUMINANT_TYPE_A 0x0000006
+#define cmsILLUMINANT_TYPE_E 0x0000007
+#define cmsILLUMINANT_TYPE_F8 0x0000008
+
+typedef struct {
+ cmsUInt32Number Observer; // 0 = unknown, 1=CIE 1931, 2=CIE 1964
+ cmsCIEXYZ Backing; // Value of backing
+ cmsUInt32Number Geometry; // 0=unknown, 1=45/0, 0/45 2=0d, d/0
+ cmsFloat64Number Flare; // 0..1.0
+ cmsUInt32Number IlluminantType;
+
+ } cmsICCMeasurementConditions;
+
+typedef struct {
+ cmsCIEXYZ IlluminantXYZ; // Not the same struct as CAM02,
+ cmsCIEXYZ SurroundXYZ; // This is for storing the tag
+ cmsUInt32Number IlluminantType; // viewing condition
+
+ } cmsICCViewingConditions;
+
+// Support of non-standard functions --------------------------------------------------------------------------------------
+
+CMSAPI int CMSEXPORT cmsstrcasecmp(const char* s1, const char* s2);
+CMSAPI long int CMSEXPORT cmsfilelength(FILE* f);
+
+// Plug-In registering ---------------------------------------------------------------------------------------------------
+
+CMSAPI cmsBool CMSEXPORT cmsPlugin(void* Plugin);
+CMSAPI void CMSEXPORT cmsUnregisterPlugins(void);
+
+// Error logging ----------------------------------------------------------------------------------------------------------
+
+// There is no error handling at all. When a function fails, it returns proper value.
+// For example, all create functions does return NULL on failure. Other may return FALSE.
+// It may be interesting, for the developer, to know why the function is failing.
+// for that reason, lcms2 does offer a logging function. This function will get
+// an ENGLISH string with some clues on what is going wrong. You can show this
+// info to the end user if you wish, or just create some sort of log on disk.
+// The logging function should NOT terminate the program, as this obviously can leave
+// unfreed resources. It is the programmer's responsibility to check each function
+// return code to make sure it didn't fail.
+
+#define cmsERROR_UNDEFINED 0
+#define cmsERROR_FILE 1
+#define cmsERROR_RANGE 2
+#define cmsERROR_INTERNAL 3
+#define cmsERROR_NULL 4
+#define cmsERROR_READ 5
+#define cmsERROR_SEEK 6
+#define cmsERROR_WRITE 7
+#define cmsERROR_UNKNOWN_EXTENSION 8
+#define cmsERROR_COLORSPACE_CHECK 9
+#define cmsERROR_ALREADY_DEFINED 10
+#define cmsERROR_BAD_SIGNATURE 11
+#define cmsERROR_CORRUPTION_DETECTED 12
+#define cmsERROR_NOT_SUITABLE 13
+
+// Error logger is called with the ContextID when a message is raised. This gives the
+// chance to know which thread is responsible of the warning and any environment associated
+// with it. Non-multithreading applications may safely ignore this parameter.
+// Note that under certain special circumstances, ContextID may be NULL.
+typedef void (* cmsLogErrorHandlerFunction)(cmsContext ContextID, cmsUInt32Number ErrorCode, const char *Text);
+
+// Allows user to set any specific logger
+CMSAPI void CMSEXPORT cmsSetLogErrorHandler(cmsLogErrorHandlerFunction Fn);
+
+// Conversions --------------------------------------------------------------------------------------------------------------
+
+// Returns pointers to constant structs
+CMSAPI const cmsCIEXYZ* CMSEXPORT cmsD50_XYZ(void);
+CMSAPI const cmsCIExyY* CMSEXPORT cmsD50_xyY(void);
+
+// Colorimetric space conversions
+CMSAPI void CMSEXPORT cmsXYZ2xyY(cmsCIExyY* Dest, const cmsCIEXYZ* Source);
+CMSAPI void CMSEXPORT cmsxyY2XYZ(cmsCIEXYZ* Dest, const cmsCIExyY* Source);
+CMSAPI void CMSEXPORT cmsXYZ2Lab(const cmsCIEXYZ* WhitePoint, cmsCIELab* Lab, const cmsCIEXYZ* xyz);
+CMSAPI void CMSEXPORT cmsLab2XYZ(const cmsCIEXYZ* WhitePoint, cmsCIEXYZ* xyz, const cmsCIELab* Lab);
+CMSAPI void CMSEXPORT cmsLab2LCh(cmsCIELCh*LCh, const cmsCIELab* Lab);
+CMSAPI void CMSEXPORT cmsLCh2Lab(cmsCIELab* Lab, const cmsCIELCh* LCh);
+
+// Encoding /Decoding on PCS
+CMSAPI void CMSEXPORT cmsLabEncoded2Float(cmsCIELab* Lab, const cmsUInt16Number wLab[3]);
+CMSAPI void CMSEXPORT cmsLabEncoded2FloatV2(cmsCIELab* Lab, const cmsUInt16Number wLab[3]);
+CMSAPI void CMSEXPORT cmsFloat2LabEncoded(cmsUInt16Number wLab[3], const cmsCIELab* Lab);
+CMSAPI void CMSEXPORT cmsFloat2LabEncodedV2(cmsUInt16Number wLab[3], const cmsCIELab* Lab);
+CMSAPI void CMSEXPORT cmsXYZEncoded2Float(cmsCIEXYZ* fxyz, const cmsUInt16Number XYZ[3]);
+CMSAPI void CMSEXPORT cmsFloat2XYZEncoded(cmsUInt16Number XYZ[3], const cmsCIEXYZ* fXYZ);
+
+// DeltaE metrics
+CMSAPI cmsFloat64Number CMSEXPORT cmsDeltaE(const cmsCIELab* Lab1, const cmsCIELab* Lab2);
+CMSAPI cmsFloat64Number CMSEXPORT cmsCIE94DeltaE(const cmsCIELab* Lab1, const cmsCIELab* Lab2);
+CMSAPI cmsFloat64Number CMSEXPORT cmsBFDdeltaE(const cmsCIELab* Lab1, const cmsCIELab* Lab2);
+CMSAPI cmsFloat64Number CMSEXPORT cmsCMCdeltaE(const cmsCIELab* Lab1, const cmsCIELab* Lab2, cmsFloat64Number l, cmsFloat64Number c);
+CMSAPI cmsFloat64Number CMSEXPORT cmsCIE2000DeltaE(const cmsCIELab* Lab1, const cmsCIELab* Lab2, cmsFloat64Number Kl, cmsFloat64Number Kc, cmsFloat64Number Kh);
+
+// Temperature <-> Chromaticity (Black body)
+CMSAPI cmsBool CMSEXPORT cmsWhitePointFromTemp(cmsCIExyY* WhitePoint, cmsFloat64Number TempK);
+CMSAPI cmsBool CMSEXPORT cmsTempFromWhitePoint(cmsFloat64Number* TempK, const cmsCIExyY* WhitePoint);
+
+// Chromatic adaptation
+CMSAPI cmsBool CMSEXPORT cmsAdaptToIlluminant(cmsCIEXYZ* Result, const cmsCIEXYZ* SourceWhitePt,
+ const cmsCIEXYZ* Illuminant,
+ const cmsCIEXYZ* Value);
+
+// CIECAM02 ---------------------------------------------------------------------------------------------------
+
+// Viewing conditions. Please note those are CAM model viewing conditions, and not the ICC tag viewing
+// conditions, which I'm naming cmsICCViewingConditions to make differences evident. Unfortunately, the tag
+// cannot deal with surround La, Yb and D value so is basically useless to store CAM02 viewing conditions.
+
+
+#define AVG_SURROUND 1
+#define DIM_SURROUND 2
+#define DARK_SURROUND 3
+#define CUTSHEET_SURROUND 4
+
+#define D_CALCULATE (-1)
+
+typedef struct {
+ cmsCIEXYZ whitePoint;
+ cmsFloat64Number Yb;
+ cmsFloat64Number La;
+ int surround;
+ cmsFloat64Number D_value;
+
+ } cmsViewingConditions;
+
+CMSAPI cmsHANDLE CMSEXPORT cmsCIECAM02Init(cmsContext ContextID, const cmsViewingConditions* pVC);
+CMSAPI void CMSEXPORT cmsCIECAM02Done(cmsHANDLE hModel);
+CMSAPI void CMSEXPORT cmsCIECAM02Forward(cmsHANDLE hModel, const cmsCIEXYZ* pIn, cmsJCh* pOut);
+CMSAPI void CMSEXPORT cmsCIECAM02Reverse(cmsHANDLE hModel, const cmsJCh* pIn, cmsCIEXYZ* pOut);
+
+
+// Tone curves -----------------------------------------------------------------------------------------
+
+// This describes a curve segment. For a table of supported types, see the manual. User can increase the number of
+// available types by using a proper plug-in. Parametric segments allow 10 parameters at most
+
+typedef struct {
+ cmsFloat32Number x0, x1; // Domain; for x0 < x <= x1
+ cmsInt32Number Type; // Parametric type, Type == 0 means sampled segment. Negative values are reserved
+ cmsFloat64Number Params[10]; // Parameters if Type != 0
+ cmsUInt32Number nGridPoints; // Number of grid points if Type == 0
+ cmsFloat32Number* SampledPoints; // Points to an array of floats if Type == 0
+
+} cmsCurveSegment;
+
+// The internal representation is none of your business.
+typedef struct _cms_curve_struct cmsToneCurve;
+
+CMSAPI cmsToneCurve* CMSEXPORT cmsBuildSegmentedToneCurve(cmsContext ContextID, cmsInt32Number nSegments, const cmsCurveSegment Segments[]);
+CMSAPI cmsToneCurve* CMSEXPORT cmsBuildParametricToneCurve(cmsContext ContextID, cmsInt32Number Type, const cmsFloat64Number Params[]);
+CMSAPI cmsToneCurve* CMSEXPORT cmsBuildGamma(cmsContext ContextID, cmsFloat64Number Gamma);
+CMSAPI cmsToneCurve* CMSEXPORT cmsBuildTabulatedToneCurve16(cmsContext ContextID, cmsInt32Number nEntries, const cmsUInt16Number values[]);
+CMSAPI cmsToneCurve* CMSEXPORT cmsBuildTabulatedToneCurveFloat(cmsContext ContextID, cmsUInt32Number nEntries, const cmsFloat32Number values[]);
+CMSAPI void CMSEXPORT cmsFreeToneCurve(cmsToneCurve* Curve);
+CMSAPI void CMSEXPORT cmsFreeToneCurveTriple(cmsToneCurve* Curve[3]);
+CMSAPI cmsToneCurve* CMSEXPORT cmsDupToneCurve(const cmsToneCurve* Src);
+CMSAPI cmsToneCurve* CMSEXPORT cmsReverseToneCurve(const cmsToneCurve* InGamma);
+CMSAPI cmsToneCurve* CMSEXPORT cmsReverseToneCurveEx(cmsInt32Number nResultSamples, const cmsToneCurve* InGamma);
+CMSAPI cmsToneCurve* CMSEXPORT cmsJoinToneCurve(cmsContext ContextID, const cmsToneCurve* X, const cmsToneCurve* Y, cmsUInt32Number nPoints);
+CMSAPI cmsBool CMSEXPORT cmsSmoothToneCurve(cmsToneCurve* Tab, cmsFloat64Number lambda);
+CMSAPI cmsFloat32Number CMSEXPORT cmsEvalToneCurveFloat(const cmsToneCurve* Curve, cmsFloat32Number v);
+CMSAPI cmsUInt16Number CMSEXPORT cmsEvalToneCurve16(const cmsToneCurve* Curve, cmsUInt16Number v);
+CMSAPI cmsBool CMSEXPORT cmsIsToneCurveMultisegment(const cmsToneCurve* InGamma);
+CMSAPI cmsBool CMSEXPORT cmsIsToneCurveLinear(const cmsToneCurve* Curve);
+CMSAPI cmsBool CMSEXPORT cmsIsToneCurveMonotonic(const cmsToneCurve* t);
+CMSAPI cmsBool CMSEXPORT cmsIsToneCurveDescending(const cmsToneCurve* t);
+CMSAPI cmsInt32Number CMSEXPORT cmsGetToneCurveParametricType(const cmsToneCurve* t);
+CMSAPI cmsFloat64Number CMSEXPORT cmsEstimateGamma(const cmsToneCurve* t, cmsFloat64Number Precision);
+
+
+// Implements pipelines of multi-processing elements -------------------------------------------------------------
+
+// Nothing to see here, move along
+typedef struct _cmsPipeline_struct cmsPipeline;
+typedef struct _cmsStage_struct cmsStage;
+
+// Those are hi-level pipelines
+CMSAPI cmsPipeline* CMSEXPORT cmsPipelineAlloc(cmsContext ContextID, cmsUInt32Number InputChannels, cmsUInt32Number OutputChannels);
+CMSAPI void CMSEXPORT cmsPipelineFree(cmsPipeline* lut);
+CMSAPI cmsPipeline* CMSEXPORT cmsPipelineDup(const cmsPipeline* Orig);
+
+CMSAPI cmsUInt32Number CMSEXPORT cmsPipelineInputChannels(const cmsPipeline* lut);
+CMSAPI cmsUInt32Number CMSEXPORT cmsPipelineOutputChannels(const cmsPipeline* lut);
+
+CMSAPI cmsUInt32Number CMSEXPORT cmsPipelineStageCount(const cmsPipeline* lut);
+CMSAPI cmsStage* CMSEXPORT cmsPipelineGetPtrToFirstStage(const cmsPipeline* lut);
+CMSAPI cmsStage* CMSEXPORT cmsPipelineGetPtrToLastStage(const cmsPipeline* lut);
+
+CMSAPI void CMSEXPORT cmsPipelineEval16(const cmsUInt16Number In[], cmsUInt16Number Out[], const cmsPipeline* lut);
+CMSAPI void CMSEXPORT cmsPipelineEvalFloat(const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsPipeline* lut);
+CMSAPI cmsBool CMSEXPORT cmsPipelineEvalReverseFloat(cmsFloat32Number Target[], cmsFloat32Number Result[], cmsFloat32Number Hint[], const cmsPipeline* lut);
+CMSAPI cmsBool CMSEXPORT cmsPipelineCat(cmsPipeline* l1, const cmsPipeline* l2);
+CMSAPI cmsBool CMSEXPORT cmsPipelineSetSaveAs8bitsFlag(cmsPipeline* lut, cmsBool On);
+
+// Where to place/locate the stages in the pipeline chain
+typedef enum { cmsAT_BEGIN, cmsAT_END } cmsStageLoc;
+
+CMSAPI void CMSEXPORT cmsPipelineInsertStage(cmsPipeline* lut, cmsStageLoc loc, cmsStage* mpe);
+CMSAPI void CMSEXPORT cmsPipelineUnlinkStage(cmsPipeline* lut, cmsStageLoc loc, cmsStage** mpe);
+
+// This function is quite useful to analyze the structure of a Pipeline and retrieve the Stage elements
+// that conform the Pipeline. It should be called with the Pipeline, the number of expected elements and
+// then a list of expected types followed with a list of double pointers to Stage elements. If
+// the function founds a match with current pipeline, it fills the pointers and returns TRUE
+// if not, returns FALSE without touching anything.
+CMSAPI cmsBool CMSEXPORT cmsPipelineCheckAndRetreiveStages(const cmsPipeline* Lut, cmsUInt32Number n, ...);
+
+// Matrix has double precision and CLUT has only float precision. That is because an ICC profile can encode
+// matrices with far more precision that CLUTS
+CMSAPI cmsStage* CMSEXPORT cmsStageAllocIdentity(cmsContext ContextID, cmsUInt32Number nChannels);
+CMSAPI cmsStage* CMSEXPORT cmsStageAllocToneCurves(cmsContext ContextID, cmsUInt32Number nChannels, cmsToneCurve* const Curves[]);
+CMSAPI cmsStage* CMSEXPORT cmsStageAllocMatrix(cmsContext ContextID, cmsUInt32Number Rows, cmsUInt32Number Cols, const cmsFloat64Number* Matrix, const cmsFloat64Number* Offset);
+
+CMSAPI cmsStage* CMSEXPORT cmsStageAllocCLut16bit(cmsContext ContextID, cmsUInt32Number nGridPoints, cmsUInt32Number inputChan, cmsUInt32Number outputChan, const cmsUInt16Number* Table);
+CMSAPI cmsStage* CMSEXPORT cmsStageAllocCLutFloat(cmsContext ContextID, cmsUInt32Number nGridPoints, cmsUInt32Number inputChan, cmsUInt32Number outputChan, const cmsFloat32Number* Table);
+
+CMSAPI cmsStage* CMSEXPORT cmsStageAllocCLut16bitGranular(cmsContext ContextID, const cmsUInt32Number clutPoints[], cmsUInt32Number inputChan, cmsUInt32Number outputChan, const cmsUInt16Number* Table);
+CMSAPI cmsStage* CMSEXPORT cmsStageAllocCLutFloatGranular(cmsContext ContextID, const cmsUInt32Number clutPoints[], cmsUInt32Number inputChan, cmsUInt32Number outputChan, const cmsFloat32Number* Table);
+
+CMSAPI cmsStage* CMSEXPORT cmsStageDup(cmsStage* mpe);
+CMSAPI void CMSEXPORT cmsStageFree(cmsStage* mpe);
+CMSAPI cmsStage* CMSEXPORT cmsStageNext(const cmsStage* mpe);
+
+CMSAPI cmsUInt32Number CMSEXPORT cmsStageInputChannels(const cmsStage* mpe);
+CMSAPI cmsUInt32Number CMSEXPORT cmsStageOutputChannels(const cmsStage* mpe);
+CMSAPI cmsStageSignature CMSEXPORT cmsStageType(const cmsStage* mpe);
+CMSAPI void* CMSEXPORT cmsStageData(const cmsStage* mpe);
+
+// Sampling
+typedef cmsInt32Number (* cmsSAMPLER16) (register const cmsUInt16Number In[],
+ register cmsUInt16Number Out[],
+ register void * Cargo);
+
+typedef cmsInt32Number (* cmsSAMPLERFLOAT)(register const cmsFloat32Number In[],
+ register cmsFloat32Number Out[],
+ register void * Cargo);
+
+// Use this flag to prevent changes being written to destination
+#define SAMPLER_INSPECT 0x01000000
+
+// For CLUT only
+CMSAPI cmsBool CMSEXPORT cmsStageSampleCLut16bit(cmsStage* mpe, cmsSAMPLER16 Sampler, void* Cargo, cmsUInt32Number dwFlags);
+CMSAPI cmsBool CMSEXPORT cmsStageSampleCLutFloat(cmsStage* mpe, cmsSAMPLERFLOAT Sampler, void* Cargo, cmsUInt32Number dwFlags);
+
+
+// Slicers
+CMSAPI cmsBool CMSEXPORT cmsSliceSpace16(cmsUInt32Number nInputs, const cmsUInt32Number clutPoints[],
+ cmsSAMPLER16 Sampler, void * Cargo);
+
+CMSAPI cmsBool CMSEXPORT cmsSliceSpaceFloat(cmsUInt32Number nInputs, const cmsUInt32Number clutPoints[],
+ cmsSAMPLERFLOAT Sampler, void * Cargo);
+
+// Multilocalized Unicode management ---------------------------------------------------------------------------------------
+
+typedef struct _cms_MLU_struct cmsMLU;
+
+#define cmsNoLanguage "\0\0"
+#define cmsNoCountry "\0\0"
+
+CMSAPI cmsMLU* CMSEXPORT cmsMLUalloc(cmsContext ContextID, cmsUInt32Number nItems);
+CMSAPI void CMSEXPORT cmsMLUfree(cmsMLU* mlu);
+CMSAPI cmsMLU* CMSEXPORT cmsMLUdup(const cmsMLU* mlu);
+
+CMSAPI cmsBool CMSEXPORT cmsMLUsetASCII(cmsMLU* mlu,
+ const char LanguageCode[3], const char CountryCode[3],
+ const char* ASCIIString);
+CMSAPI cmsBool CMSEXPORT cmsMLUsetWide(cmsMLU* mlu,
+ const char LanguageCode[3], const char CountryCode[3],
+ const wchar_t* WideString);
+
+CMSAPI cmsUInt32Number CMSEXPORT cmsMLUgetASCII(const cmsMLU* mlu,
+ const char LanguageCode[3], const char CountryCode[3],
+ char* Buffer, cmsUInt32Number BufferSize);
+
+CMSAPI cmsUInt32Number CMSEXPORT cmsMLUgetWide(const cmsMLU* mlu,
+ const char LanguageCode[3], const char CountryCode[3],
+ wchar_t* Buffer, cmsUInt32Number BufferSize);
+
+CMSAPI cmsBool CMSEXPORT cmsMLUgetTranslation(const cmsMLU* mlu,
+ const char LanguageCode[3], const char CountryCode[3],
+ char ObtainedLanguage[3], char ObtainedCountry[3]);
+
+// Undercolorremoval & black generation -------------------------------------------------------------------------------------
+
+typedef struct {
+ cmsToneCurve* Ucr;
+ cmsToneCurve* Bg;
+ cmsMLU* Desc;
+
+} cmsUcrBg;
+
+// Screening ----------------------------------------------------------------------------------------------------------------
+
+#define cmsPRINTER_DEFAULT_SCREENS 0x0001
+#define cmsFREQUENCE_UNITS_LINES_CM 0x0000
+#define cmsFREQUENCE_UNITS_LINES_INCH 0x0002
+
+#define cmsSPOT_UNKNOWN 0
+#define cmsSPOT_PRINTER_DEFAULT 1
+#define cmsSPOT_ROUND 2
+#define cmsSPOT_DIAMOND 3
+#define cmsSPOT_ELLIPSE 4
+#define cmsSPOT_LINE 5
+#define cmsSPOT_SQUARE 6
+#define cmsSPOT_CROSS 7
+
+typedef struct {
+ cmsFloat64Number Frequency;
+ cmsFloat64Number ScreenAngle;
+ cmsUInt32Number SpotShape;
+
+} cmsScreeningChannel;
+
+typedef struct {
+ cmsUInt32Number Flag;
+ cmsUInt32Number nChannels;
+ cmsScreeningChannel Channels[cmsMAXCHANNELS];
+
+} cmsScreening;
+
+
+// Named color -----------------------------------------------------------------------------------------------------------------
+
+typedef struct _cms_NAMEDCOLORLIST_struct cmsNAMEDCOLORLIST;
+
+CMSAPI cmsNAMEDCOLORLIST* CMSEXPORT cmsAllocNamedColorList(cmsContext ContextID,
+ cmsUInt32Number n,
+ cmsUInt32Number ColorantCount,
+ const char* Prefix, const char* Suffix);
+
+CMSAPI void CMSEXPORT cmsFreeNamedColorList(cmsNAMEDCOLORLIST* v);
+CMSAPI cmsNAMEDCOLORLIST* CMSEXPORT cmsDupNamedColorList(const cmsNAMEDCOLORLIST* v);
+CMSAPI cmsBool CMSEXPORT cmsAppendNamedColor(cmsNAMEDCOLORLIST* v, const char* Name,
+ cmsUInt16Number PCS[3],
+ cmsUInt16Number Colorant[cmsMAXCHANNELS]);
+
+CMSAPI cmsUInt32Number CMSEXPORT cmsNamedColorCount(const cmsNAMEDCOLORLIST* v);
+CMSAPI cmsInt32Number CMSEXPORT cmsNamedColorIndex(const cmsNAMEDCOLORLIST* v, const char* Name);
+
+CMSAPI cmsBool CMSEXPORT cmsNamedColorInfo(const cmsNAMEDCOLORLIST* NamedColorList, cmsUInt32Number nColor,
+ char* Name,
+ char* Prefix,
+ char* Suffix,
+ cmsUInt16Number* PCS,
+ cmsUInt16Number* Colorant);
+
+// Retrieve named color list from transform
+CMSAPI cmsNAMEDCOLORLIST* CMSEXPORT cmsGetNamedColorList(cmsHTRANSFORM xform);
+
+// Profile sequence -----------------------------------------------------------------------------------------------------
+
+// Profile sequence descriptor. Some fields come from profile sequence descriptor tag, others
+// come from Profile Sequence Identifier Tag
+typedef struct {
+ cmsSignature deviceMfg;
+ cmsSignature deviceModel;
+ cmsUInt64Number attributes;
+ cmsTechnologySignature technology;
+ cmsProfileID ProfileID;
+ cmsMLU* Manufacturer;
+ cmsMLU* Model;
+ cmsMLU* Description;
+
+} cmsPSEQDESC;
+
+typedef struct {
+
+ cmsUInt32Number n;
+ cmsContext ContextID;
+ cmsPSEQDESC* seq;
+
+} cmsSEQ;
+
+CMSAPI cmsSEQ* CMSEXPORT cmsAllocProfileSequenceDescription(cmsContext ContextID, cmsUInt32Number n);
+CMSAPI cmsSEQ* CMSEXPORT cmsDupProfileSequenceDescription(const cmsSEQ* pseq);
+CMSAPI void CMSEXPORT cmsFreeProfileSequenceDescription(cmsSEQ* pseq);
+
+// Access to Profile data ----------------------------------------------------------------------------------------------
+CMSAPI cmsHPROFILE CMSEXPORT cmsCreateProfilePlaceholder(cmsContext ContextID);
+
+CMSAPI cmsContext CMSEXPORT cmsGetProfileContextID(cmsHPROFILE hProfile);
+CMSAPI cmsInt32Number CMSEXPORT cmsGetTagCount(cmsHPROFILE hProfile);
+CMSAPI cmsTagSignature CMSEXPORT cmsGetTagSignature(cmsHPROFILE hProfile, cmsUInt32Number n);
+CMSAPI cmsBool CMSEXPORT cmsIsTag(cmsHPROFILE hProfile, cmsTagSignature sig);
+
+// Read and write pre-formatted data
+CMSAPI void* CMSEXPORT cmsReadTag(cmsHPROFILE hProfile, cmsTagSignature sig);
+CMSAPI cmsBool CMSEXPORT cmsWriteTag(cmsHPROFILE hProfile, cmsTagSignature sig, const void* data);
+CMSAPI cmsBool CMSEXPORT cmsLinkTag(cmsHPROFILE hProfile, cmsTagSignature sig, cmsTagSignature dest);
+
+// Read and write raw data
+CMSAPI cmsInt32Number CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature sig, void* Buffer, cmsUInt32Number BufferSize);
+CMSAPI cmsBool CMSEXPORT cmsWriteRawTag(cmsHPROFILE hProfile, cmsTagSignature sig, const void* data, cmsUInt32Number Size);
+
+// Access header data
+CMSAPI cmsUInt32Number CMSEXPORT cmsGetHeaderFlags(cmsHPROFILE hProfile);
+CMSAPI void CMSEXPORT cmsGetHeaderAttributes(cmsHPROFILE hProfile, cmsUInt64Number* Flags);
+CMSAPI void CMSEXPORT cmsGetHeaderProfileID(cmsHPROFILE hProfile, cmsUInt8Number* ProfileID);
+CMSAPI cmsBool CMSEXPORT cmsGetHeaderCreationDateTime(cmsHPROFILE hProfile, struct tm *Dest);
+CMSAPI cmsUInt32Number CMSEXPORT cmsGetHeaderRenderingIntent(cmsHPROFILE hProfile);
+
+CMSAPI void CMSEXPORT cmsSetHeaderFlags(cmsHPROFILE hProfile, cmsUInt32Number Flags);
+CMSAPI cmsUInt32Number CMSEXPORT cmsGetHeaderManufacturer(cmsHPROFILE hProfile);
+CMSAPI void CMSEXPORT cmsSetHeaderManufacturer(cmsHPROFILE hProfile, cmsUInt32Number manufacturer);
+CMSAPI cmsUInt32Number CMSEXPORT cmsGetHeaderModel(cmsHPROFILE hProfile);
+CMSAPI void CMSEXPORT cmsSetHeaderModel(cmsHPROFILE hProfile, cmsUInt32Number model);
+CMSAPI void CMSEXPORT cmsSetHeaderAttributes(cmsHPROFILE hProfile, cmsUInt64Number Flags);
+CMSAPI void CMSEXPORT cmsSetHeaderProfileID(cmsHPROFILE hProfile, cmsUInt8Number* ProfileID);
+CMSAPI void CMSEXPORT cmsSetHeaderRenderingIntent(cmsHPROFILE hProfile, cmsUInt32Number RenderingIntent);
+
+CMSAPI cmsColorSpaceSignature
+ CMSEXPORT cmsGetPCS(cmsHPROFILE hProfile);
+CMSAPI void CMSEXPORT cmsSetPCS(cmsHPROFILE hProfile, cmsColorSpaceSignature pcs);
+CMSAPI cmsColorSpaceSignature
+ CMSEXPORT cmsGetColorSpace(cmsHPROFILE hProfile);
+CMSAPI void CMSEXPORT cmsSetColorSpace(cmsHPROFILE hProfile, cmsColorSpaceSignature sig);
+CMSAPI cmsProfileClassSignature
+ CMSEXPORT cmsGetDeviceClass(cmsHPROFILE hProfile);
+CMSAPI void CMSEXPORT cmsSetDeviceClass(cmsHPROFILE hProfile, cmsProfileClassSignature sig);
+CMSAPI void CMSEXPORT cmsSetProfileVersion(cmsHPROFILE hProfile, cmsFloat64Number Version);
+CMSAPI cmsFloat64Number CMSEXPORT cmsGetProfileVersion(cmsHPROFILE hProfile);
+
+CMSAPI cmsUInt32Number CMSEXPORT cmsGetEncodedICCversion(cmsHPROFILE hProfile);
+CMSAPI void CMSEXPORT cmsSetEncodedICCversion(cmsHPROFILE hProfile, cmsUInt32Number Version);
+
+// How profiles may be used
+#define LCMS_USED_AS_INPUT 0
+#define LCMS_USED_AS_OUTPUT 1
+#define LCMS_USED_AS_PROOF 2
+
+CMSAPI cmsBool CMSEXPORT cmsIsIntentSupported(cmsHPROFILE hProfile, cmsUInt32Number Intent, int UsedDirection);
+CMSAPI cmsBool CMSEXPORT cmsIsMatrixShaper(cmsHPROFILE hProfile);
+CMSAPI cmsBool CMSEXPORT cmsIsCLUT(cmsHPROFILE hProfile, cmsUInt32Number Intent, int UsedDirection);
+
+// Translate form/to our notation to ICC
+CMSAPI cmsColorSpaceSignature CMSEXPORT _cmsICCcolorSpace(int OurNotation);
+CMSAPI int CMSEXPORT _cmsLCMScolorSpace(cmsColorSpaceSignature ProfileSpace);
+
+CMSAPI cmsUInt32Number CMSEXPORT cmsChannelsOf(cmsColorSpaceSignature ColorSpace);
+
+// Build a suitable formatter for the colorspace of this profile
+CMSAPI cmsUInt32Number CMSEXPORT cmsFormatterForColorspaceOfProfile(cmsHPROFILE hProfile, cmsUInt32Number nBytes, cmsBool lIsFloat);
+CMSAPI cmsUInt32Number CMSEXPORT cmsFormatterForPCSOfProfile(cmsHPROFILE hProfile, cmsUInt32Number nBytes, cmsBool lIsFloat);
+
+
+// Localized info
+typedef enum {
+ cmsInfoDescription = 0,
+ cmsInfoManufacturer = 1,
+ cmsInfoModel = 2,
+ cmsInfoCopyright = 3
+} cmsInfoType;
+
+CMSAPI cmsUInt32Number CMSEXPORT cmsGetProfileInfo(cmsHPROFILE hProfile, cmsInfoType Info,
+ const char LanguageCode[3], const char CountryCode[3],
+ wchar_t* Buffer, cmsUInt32Number BufferSize);
+
+CMSAPI cmsUInt32Number CMSEXPORT cmsGetProfileInfoASCII(cmsHPROFILE hProfile, cmsInfoType Info,
+ const char LanguageCode[3], const char CountryCode[3],
+ char* Buffer, cmsUInt32Number BufferSize);
+
+// IO handlers ----------------------------------------------------------------------------------------------------------
+
+typedef struct _cms_io_handler cmsIOHANDLER;
+
+CMSAPI cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromFile(cmsContext ContextID, const char* FileName, const char* AccessMode);
+CMSAPI cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromStream(cmsContext ContextID, FILE* Stream);
+CMSAPI cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromMem(cmsContext ContextID, void *Buffer, cmsUInt32Number size, const char* AccessMode);
+CMSAPI cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromNULL(cmsContext ContextID);
+CMSAPI cmsBool CMSEXPORT cmsCloseIOhandler(cmsIOHANDLER* io);
+
+// MD5 message digest --------------------------------------------------------------------------------------------------
+
+CMSAPI cmsBool CMSEXPORT cmsMD5computeID(cmsHPROFILE hProfile);
+
+// Profile high level funtions ------------------------------------------------------------------------------------------
+
+CMSAPI cmsHPROFILE CMSEXPORT cmsOpenProfileFromFile(const char *ICCProfile, const char *sAccess);
+CMSAPI cmsHPROFILE CMSEXPORT cmsOpenProfileFromFileTHR(cmsContext ContextID, const char *ICCProfile, const char *sAccess);
+CMSAPI cmsHPROFILE CMSEXPORT cmsOpenProfileFromStream(FILE* ICCProfile, const char* sAccess);
+CMSAPI cmsHPROFILE CMSEXPORT cmsOpenProfileFromStreamTHR(cmsContext ContextID, FILE* ICCProfile, const char* sAccess);
+CMSAPI cmsHPROFILE CMSEXPORT cmsOpenProfileFromMem(const void * MemPtr, cmsUInt32Number dwSize);
+CMSAPI cmsHPROFILE CMSEXPORT cmsOpenProfileFromMemTHR(cmsContext ContextID, const void * MemPtr, cmsUInt32Number dwSize);
+CMSAPI cmsHPROFILE CMSEXPORT cmsOpenProfileFromIOhandlerTHR(cmsContext ContextID, cmsIOHANDLER* io);
+CMSAPI cmsBool CMSEXPORT cmsCloseProfile(cmsHPROFILE hProfile);
+
+CMSAPI cmsBool CMSEXPORT cmsSaveProfileToFile(cmsHPROFILE hProfile, const char* FileName);
+CMSAPI cmsBool CMSEXPORT cmsSaveProfileToStream(cmsHPROFILE hProfile, FILE* Stream);
+CMSAPI cmsBool CMSEXPORT cmsSaveProfileToMem(cmsHPROFILE hProfile, void *MemPtr, cmsUInt32Number* BytesNeeded);
+CMSAPI cmsUInt32Number CMSEXPORT cmsSaveProfileToIOhandler(cmsHPROFILE hProfile, cmsIOHANDLER* io);
+
+// Predefined virtual profiles ------------------------------------------------------------------------------------------
+
+CMSAPI cmsHPROFILE CMSEXPORT cmsCreateRGBProfileTHR(cmsContext ContextID,
+ const cmsCIExyY* WhitePoint,
+ const cmsCIExyYTRIPLE* Primaries,
+ cmsToneCurve* const TransferFunction[3]);
+
+CMSAPI cmsHPROFILE CMSEXPORT cmsCreateRGBProfile(const cmsCIExyY* WhitePoint,
+ const cmsCIExyYTRIPLE* Primaries,
+ cmsToneCurve* const TransferFunction[3]);
+
+CMSAPI cmsHPROFILE CMSEXPORT cmsCreateGrayProfileTHR(cmsContext ContextID,
+ const cmsCIExyY* WhitePoint,
+ const cmsToneCurve* TransferFunction);
+
+CMSAPI cmsHPROFILE CMSEXPORT cmsCreateGrayProfile(const cmsCIExyY* WhitePoint,
+ const cmsToneCurve* TransferFunction);
+
+CMSAPI cmsHPROFILE CMSEXPORT cmsCreateLinearizationDeviceLinkTHR(cmsContext ContextID,
+ cmsColorSpaceSignature ColorSpace,
+ cmsToneCurve* const TransferFunctions[]);
+
+CMSAPI cmsHPROFILE CMSEXPORT cmsCreateLinearizationDeviceLink(cmsColorSpaceSignature ColorSpace,
+ cmsToneCurve* const TransferFunctions[]);
+
+CMSAPI cmsHPROFILE CMSEXPORT cmsCreateInkLimitingDeviceLinkTHR(cmsContext ContextID,
+ cmsColorSpaceSignature ColorSpace, cmsFloat64Number Limit);
+
+CMSAPI cmsHPROFILE CMSEXPORT cmsCreateInkLimitingDeviceLink(cmsColorSpaceSignature ColorSpace, cmsFloat64Number Limit);
+
+
+CMSAPI cmsHPROFILE CMSEXPORT cmsCreateLab2ProfileTHR(cmsContext ContextID, const cmsCIExyY* WhitePoint);
+CMSAPI cmsHPROFILE CMSEXPORT cmsCreateLab2Profile(const cmsCIExyY* WhitePoint);
+CMSAPI cmsHPROFILE CMSEXPORT cmsCreateLab4ProfileTHR(cmsContext ContextID, const cmsCIExyY* WhitePoint);
+CMSAPI cmsHPROFILE CMSEXPORT cmsCreateLab4Profile(const cmsCIExyY* WhitePoint);
+
+CMSAPI cmsHPROFILE CMSEXPORT cmsCreateXYZProfileTHR(cmsContext ContextID);
+CMSAPI cmsHPROFILE CMSEXPORT cmsCreateXYZProfile(void);
+
+CMSAPI cmsHPROFILE CMSEXPORT cmsCreate_sRGBProfileTHR(cmsContext ContextID);
+CMSAPI cmsHPROFILE CMSEXPORT cmsCreate_sRGBProfile(void);
+
+CMSAPI cmsHPROFILE CMSEXPORT cmsCreateBCHSWabstractProfileTHR(cmsContext ContextID,
+ int nLUTPoints,
+ cmsFloat64Number Bright,
+ cmsFloat64Number Contrast,
+ cmsFloat64Number Hue,
+ cmsFloat64Number Saturation,
+ int TempSrc,
+ int TempDest);
+
+CMSAPI cmsHPROFILE CMSEXPORT cmsCreateBCHSWabstractProfile(int nLUTPoints,
+ cmsFloat64Number Bright,
+ cmsFloat64Number Contrast,
+ cmsFloat64Number Hue,
+ cmsFloat64Number Saturation,
+ int TempSrc,
+ int TempDest);
+
+CMSAPI cmsHPROFILE CMSEXPORT cmsCreateNULLProfileTHR(cmsContext ContextID);
+CMSAPI cmsHPROFILE CMSEXPORT cmsCreateNULLProfile(void);
+
+// Converts a transform to a devicelink profile
+CMSAPI cmsHPROFILE CMSEXPORT cmsTransform2DeviceLink(cmsHTRANSFORM hTransform, cmsFloat64Number Version, cmsUInt32Number dwFlags);
+
+// Intents ----------------------------------------------------------------------------------------------
+
+// ICC Intents
+#define INTENT_PERCEPTUAL 0
+#define INTENT_RELATIVE_COLORIMETRIC 1
+#define INTENT_SATURATION 2
+#define INTENT_ABSOLUTE_COLORIMETRIC 3
+
+// Non-ICC intents
+#define INTENT_PRESERVE_K_ONLY_PERCEPTUAL 10
+#define INTENT_PRESERVE_K_ONLY_RELATIVE_COLORIMETRIC 11
+#define INTENT_PRESERVE_K_ONLY_SATURATION 12
+#define INTENT_PRESERVE_K_PLANE_PERCEPTUAL 13
+#define INTENT_PRESERVE_K_PLANE_RELATIVE_COLORIMETRIC 14
+#define INTENT_PRESERVE_K_PLANE_SATURATION 15
+
+// Call with NULL as parameters to get the intent count
+CMSAPI cmsUInt32Number CMSEXPORT cmsGetSupportedIntents(cmsUInt32Number nMax, cmsUInt32Number* Codes, char** Descriptions);
+
+// Flags
+
+#define cmsFLAGS_NOCACHE 0x0040 // Inhibit 1-pixel cache
+#define cmsFLAGS_NOOPTIMIZE 0x0100 // Inhibit optimizations
+#define cmsFLAGS_NULLTRANSFORM 0x0200 // Don't transform anyway
+
+
+// Proofing flags
+#define cmsFLAGS_GAMUTCHECK 0x1000 // Out of Gamut alarm
+#define cmsFLAGS_SOFTPROOFING 0x4000 // Do softproofing
+
+// Misc
+#define cmsFLAGS_BLACKPOINTCOMPENSATION 0x2000
+#define cmsFLAGS_NOWHITEONWHITEFIXUP 0x0004 // Don't fix scum dot
+#define cmsFLAGS_HIGHRESPRECALC 0x0400 // Use more memory to give better accurancy
+#define cmsFLAGS_LOWRESPRECALC 0x0800 // Use less memory to minimize resouces
+
+// For devicelink creation
+#define cmsFLAGS_8BITS_DEVICELINK 0x0008 // Create 8 bits devicelinks
+#define cmsFLAGS_GUESSDEVICECLASS 0x0020 // Guess device class (for transform2devicelink)
+#define cmsFLAGS_KEEP_SEQUENCE 0x0080 // Keep profile sequence for devicelink creation
+
+// Specific to a particular optimizations
+#define cmsFLAGS_FORCE_CLUT 0x0002 // Force CLUT optimization
+#define cmsFLAGS_CLUT_POST_LINEARIZATION 0x0001 // create postlinearization tables if possible
+#define cmsFLAGS_CLUT_PRE_LINEARIZATION 0x0010 // create prelinearization tables if possible
+
+// Fine-tune control over number of gridpoints
+#define cmsFLAGS_GRIDPOINTS(n) (((n) & 0xFF) << 16)
+
+// CRD special
+#define cmsFLAGS_NODEFAULTRESOURCEDEF 0x01000000
+
+// Transforms ---------------------------------------------------------------------------------------------------
+
+CMSAPI cmsHTRANSFORM CMSEXPORT cmsCreateTransformTHR(cmsContext ContextID,
+ cmsHPROFILE Input,
+ cmsUInt32Number InputFormat,
+ cmsHPROFILE Output,
+ cmsUInt32Number OutputFormat,
+ cmsUInt32Number Intent,
+ cmsUInt32Number dwFlags);
+
+CMSAPI cmsHTRANSFORM CMSEXPORT cmsCreateTransform(cmsHPROFILE Input,
+ cmsUInt32Number InputFormat,
+ cmsHPROFILE Output,
+ cmsUInt32Number OutputFormat,
+ cmsUInt32Number Intent,
+ cmsUInt32Number dwFlags);
+
+CMSAPI cmsHTRANSFORM CMSEXPORT cmsCreateProofingTransformTHR(cmsContext ContextID,
+ cmsHPROFILE Input,
+ cmsUInt32Number InputFormat,
+ cmsHPROFILE Output,
+ cmsUInt32Number OutputFormat,
+ cmsHPROFILE Proofing,
+ cmsUInt32Number Intent,
+ cmsUInt32Number ProofingIntent,
+ cmsUInt32Number dwFlags);
+
+CMSAPI cmsHTRANSFORM CMSEXPORT cmsCreateProofingTransform(cmsHPROFILE Input,
+ cmsUInt32Number InputFormat,
+ cmsHPROFILE Output,
+ cmsUInt32Number OutputFormat,
+ cmsHPROFILE Proofing,
+ cmsUInt32Number Intent,
+ cmsUInt32Number ProofingIntent,
+ cmsUInt32Number dwFlags);
+
+CMSAPI cmsHTRANSFORM CMSEXPORT cmsCreateMultiprofileTransformTHR(cmsContext ContextID,
+ cmsHPROFILE hProfiles[],
+ cmsUInt32Number nProfiles,
+ cmsUInt32Number InputFormat,
+ cmsUInt32Number OutputFormat,
+ cmsUInt32Number Intent,
+ cmsUInt32Number dwFlags);
+
+
+CMSAPI cmsHTRANSFORM CMSEXPORT cmsCreateMultiprofileTransform(cmsHPROFILE hProfiles[],
+ cmsUInt32Number nProfiles,
+ cmsUInt32Number InputFormat,
+ cmsUInt32Number OutputFormat,
+ cmsUInt32Number Intent,
+ cmsUInt32Number dwFlags);
+
+
+CMSAPI cmsHTRANSFORM CMSEXPORT cmsCreateExtendedTransform(cmsContext ContextID,
+ cmsUInt32Number nProfiles, cmsHPROFILE hProfiles[],
+ cmsBool BPC[],
+ cmsUInt32Number Intents[],
+ cmsFloat64Number AdaptationStates[],
+ cmsHPROFILE hGamutProfile,
+ cmsUInt32Number nGamutPCSposition,
+ cmsUInt32Number InputFormat,
+ cmsUInt32Number OutputFormat,
+ cmsUInt32Number dwFlags);
+
+CMSAPI void CMSEXPORT cmsDeleteTransform(cmsHTRANSFORM hTransform);
+
+CMSAPI void CMSEXPORT cmsDoTransform(cmsHTRANSFORM Transform,
+ const void * InputBuffer,
+ void * OutputBuffer,
+ cmsUInt32Number Size);
+
+CMSAPI void CMSEXPORT cmsSetAlarmCodes(cmsUInt16Number NewAlarm[cmsMAXCHANNELS]);
+CMSAPI void CMSEXPORT cmsGetAlarmCodes(cmsUInt16Number NewAlarm[cmsMAXCHANNELS]);
+
+// Adaptation state for absolute colorimetric intent
+CMSAPI cmsFloat64Number CMSEXPORT cmsSetAdaptationState(cmsFloat64Number d);
+
+CMSAPI cmsContext CMSEXPORT cmsGetTransformContextID(cmsHTRANSFORM hTransform);
+
+
+// PostScript ColorRenderingDictionary and ColorSpaceArray ----------------------------------------------------
+
+typedef enum { cmsPS_RESOURCE_CSA, cmsPS_RESOURCE_CRD } cmsPSResourceType;
+
+// lcms2 unified method to access postscript color resources
+CMSAPI cmsUInt32Number CMSEXPORT cmsGetPostScriptColorResource(cmsContext ContextID,
+ cmsPSResourceType Type,
+ cmsHPROFILE hProfile,
+ cmsUInt32Number Intent,
+ cmsUInt32Number dwFlags,
+ cmsIOHANDLER* io);
+
+CMSAPI cmsUInt32Number CMSEXPORT cmsGetPostScriptCSA(cmsContext ContextID, cmsHPROFILE hProfile, cmsUInt32Number Intent, cmsUInt32Number dwFlags, void* Buffer, cmsUInt32Number dwBufferLen);
+CMSAPI cmsUInt32Number CMSEXPORT cmsGetPostScriptCRD(cmsContext ContextID, cmsHPROFILE hProfile, cmsUInt32Number Intent, cmsUInt32Number dwFlags, void* Buffer, cmsUInt32Number dwBufferLen);
+
+
+// IT8.7 / CGATS.17-200x handling -----------------------------------------------------------------------------
+
+CMSAPI cmsHANDLE CMSEXPORT cmsIT8Alloc(cmsContext ContextID);
+CMSAPI void CMSEXPORT cmsIT8Free(cmsHANDLE hIT8);
+
+// Tables
+CMSAPI cmsUInt32Number CMSEXPORT cmsIT8TableCount(cmsHANDLE hIT8);
+CMSAPI cmsInt32Number CMSEXPORT cmsIT8SetTable(cmsHANDLE hIT8, cmsUInt32Number nTable);
+
+// Persistence
+CMSAPI cmsHANDLE CMSEXPORT cmsIT8LoadFromFile(cmsContext ContextID, const char* cFileName);
+CMSAPI cmsHANDLE CMSEXPORT cmsIT8LoadFromMem(cmsContext ContextID, void *Ptr, cmsUInt32Number len);
+// CMSAPI cmsHANDLE CMSEXPORT cmsIT8LoadFromIOhandler(cmsContext ContextID, cmsIOHANDLER* io);
+
+CMSAPI cmsBool CMSEXPORT cmsIT8SaveToFile(cmsHANDLE hIT8, const char* cFileName);
+CMSAPI cmsBool CMSEXPORT cmsIT8SaveToMem(cmsHANDLE hIT8, void *MemPtr, cmsUInt32Number* BytesNeeded);
+
+// Properties
+CMSAPI const char* CMSEXPORT cmsIT8GetSheetType(cmsHANDLE hIT8);
+CMSAPI cmsBool CMSEXPORT cmsIT8SetSheetType(cmsHANDLE hIT8, const char* Type);
+
+CMSAPI cmsBool CMSEXPORT cmsIT8SetComment(cmsHANDLE hIT8, const char* cComment);
+
+CMSAPI cmsBool CMSEXPORT cmsIT8SetPropertyStr(cmsHANDLE hIT8, const char* cProp, const char *Str);
+CMSAPI cmsBool CMSEXPORT cmsIT8SetPropertyDbl(cmsHANDLE hIT8, const char* cProp, cmsFloat64Number Val);
+CMSAPI cmsBool CMSEXPORT cmsIT8SetPropertyHex(cmsHANDLE hIT8, const char* cProp, cmsUInt32Number Val);
+CMSAPI cmsBool CMSEXPORT cmsIT8SetPropertyUncooked(cmsHANDLE hIT8, const char* Key, const char* Buffer);
+
+
+CMSAPI const char* CMSEXPORT cmsIT8GetProperty(cmsHANDLE hIT8, const char* cProp);
+CMSAPI cmsFloat64Number CMSEXPORT cmsIT8GetPropertyDbl(cmsHANDLE hIT8, const char* cProp);
+CMSAPI cmsUInt32Number CMSEXPORT cmsIT8EnumProperties(cmsHANDLE hIT8, char ***PropertyNames);
+
+// Datasets
+CMSAPI const char* CMSEXPORT cmsIT8GetDataRowCol(cmsHANDLE hIT8, int row, int col);
+CMSAPI cmsFloat64Number CMSEXPORT cmsIT8GetDataRowColDbl(cmsHANDLE hIT8, int row, int col);
+
+CMSAPI cmsBool CMSEXPORT cmsIT8SetDataRowCol(cmsHANDLE hIT8, int row, int col,
+ const char* Val);
+
+CMSAPI cmsBool CMSEXPORT cmsIT8SetDataRowColDbl(cmsHANDLE hIT8, int row, int col,
+ cmsFloat64Number Val);
+
+CMSAPI const char* CMSEXPORT cmsIT8GetData(cmsHANDLE hIT8, const char* cPatch, const char* cSample);
+
+
+CMSAPI cmsFloat64Number CMSEXPORT cmsIT8GetDataDbl(cmsHANDLE hIT8, const char* cPatch, const char* cSample);
+
+CMSAPI cmsBool CMSEXPORT cmsIT8SetData(cmsHANDLE hIT8, const char* cPatch,
+ const char* cSample,
+ const char *Val);
+
+CMSAPI cmsBool CMSEXPORT cmsIT8SetDataDbl(cmsHANDLE hIT8, const char* cPatch,
+ const char* cSample,
+ cmsFloat64Number Val);
+
+CMSAPI int CMSEXPORT cmsIT8FindDataFormat(cmsHANDLE hIT8, const char* cSample);
+CMSAPI cmsBool CMSEXPORT cmsIT8SetDataFormat(cmsHANDLE hIT8, int n, const char *Sample);
+CMSAPI int CMSEXPORT cmsIT8EnumDataFormat(cmsHANDLE hIT8, char ***SampleNames);
+
+CMSAPI const char* CMSEXPORT cmsIT8GetPatchName(cmsHANDLE hIT8, int nPatch, char* buffer);
+
+// The LABEL extension
+CMSAPI int CMSEXPORT cmsIT8SetTableByLabel(cmsHANDLE hIT8, const char* cSet, const char* cField, const char* ExpectedType);
+
+// Formatter for double
+CMSAPI void CMSEXPORT cmsIT8DefineDblFormat(cmsHANDLE hIT8, const char* Formatter);
+
+// Gamut boundary description routines ------------------------------------------------------------------------------
+
+CMSAPI cmsHANDLE CMSEXPORT cmsGBDAlloc(cmsContext ContextID);
+CMSAPI void CMSEXPORT cmsGBDFree(cmsHANDLE hGBD);
+CMSAPI cmsBool CMSEXPORT cmsGDBAddPoint(cmsHANDLE hGBD, const cmsCIELab* Lab);
+CMSAPI cmsBool CMSEXPORT cmsGDBCompute(cmsHANDLE hGDB, cmsUInt32Number dwFlags);
+CMSAPI cmsBool CMSEXPORT cmsGDBCheckPoint(cmsHANDLE hGBD, const cmsCIELab* Lab);
+
+// Feature detection ----------------------------------------------------------------------------------------------
+
+// Estimate the black point
+CMSAPI cmsBool CMSEXPORT cmsDetectBlackPoint(cmsCIEXYZ* BlackPoint, cmsHPROFILE hProfile, cmsUInt32Number Intent, cmsUInt32Number dwFlags);
+
+// Estimate total area coverage
+CMSAPI cmsFloat64Number CMSEXPORT cmsDetectTAC(cmsHPROFILE hProfile);
+
+
+// Poor man's gamut mapping
+CMSAPI cmsBool CMSEXPORT cmsDesaturateLab(cmsCIELab* Lab,
+ double amax, double amin,
+ double bmax, double bmin);
+
+#ifndef CMS_USE_CPP_API
+# ifdef __cplusplus
+ }
+# endif
+#endif
+
+#define _lcms2_H
+#endif
--- /dev/null
+//---------------------------------------------------------------------------------
+//
+// Little Color Management System
+// Copyright (c) 1998-2010 Marti Maria Saguer
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the Software
+// is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+//---------------------------------------------------------------------------------
+//
+// This is the plug-in header file. Normal LittleCMS clients should not use it.
+// It is provided for plug-in writters that may want to access the support
+// functions to do low level operations. All plug-in related structures
+// are defined here. Including this file forces to include the standard API too.
+
+#ifndef _lcms_plugin_H
+
+// Deal with Microsoft's attempt at deprecating C standard runtime functions
+#ifdef _MSC_VER
+# if (_MSC_VER >= 1400)
+# ifndef _CRT_SECURE_NO_DEPRECATE
+# define _CRT_SECURE_NO_DEPRECATE
+# endif
+# ifndef _CRT_SECURE_NO_WARNINGS
+# define _CRT_SECURE_NO_WARNINGS
+# endif
+# endif
+#endif
+
+#ifndef _lcms2_H
+#include "lcms2.h"
+#endif
+
+// We need some standard C functions.
+#include <stdlib.h>
+#include <math.h>
+#include <stdarg.h>
+#include <memory.h>
+#include <string.h>
+
+
+#ifndef CMS_USE_CPP_API
+# ifdef __cplusplus
+extern "C" {
+# endif
+#endif
+
+// Vector & Matrix operations -----------------------------------------------------------------------
+
+// Axis of the matrix/array. No specific meaning at all.
+#define VX 0
+#define VY 1
+#define VZ 2
+
+// Vectors
+typedef struct {
+ cmsFloat64Number n[3];
+
+ } cmsVEC3;
+
+// 3x3 Matrix
+typedef struct {
+ cmsVEC3 v[3];
+
+ } cmsMAT3;
+
+CMSAPI void CMSEXPORT _cmsVEC3init(cmsVEC3* r, cmsFloat64Number x, cmsFloat64Number y, cmsFloat64Number z);
+CMSAPI void CMSEXPORT _cmsVEC3minus(cmsVEC3* r, const cmsVEC3* a, const cmsVEC3* b);
+CMSAPI void CMSEXPORT _cmsVEC3cross(cmsVEC3* r, const cmsVEC3* u, const cmsVEC3* v);
+CMSAPI cmsFloat64Number CMSEXPORT _cmsVEC3dot(const cmsVEC3* u, const cmsVEC3* v);
+CMSAPI cmsFloat64Number CMSEXPORT _cmsVEC3length(const cmsVEC3* a);
+CMSAPI cmsFloat64Number CMSEXPORT _cmsVEC3distance(const cmsVEC3* a, const cmsVEC3* b);
+
+CMSAPI void CMSEXPORT _cmsMAT3identity(cmsMAT3* a);
+CMSAPI cmsBool CMSEXPORT _cmsMAT3isIdentity(const cmsMAT3* a);
+CMSAPI void CMSEXPORT _cmsMAT3per(cmsMAT3* r, const cmsMAT3* a, const cmsMAT3* b);
+CMSAPI cmsBool CMSEXPORT _cmsMAT3inverse(const cmsMAT3* a, cmsMAT3* b);
+CMSAPI cmsBool CMSEXPORT _cmsMAT3solve(cmsVEC3* x, cmsMAT3* a, cmsVEC3* b);
+CMSAPI void CMSEXPORT _cmsMAT3eval(cmsVEC3* r, const cmsMAT3* a, const cmsVEC3* v);
+
+
+// Error logging -------------------------------------------------------------------------------------
+
+CMSAPI void CMSEXPORT cmsSignalError(cmsContext ContextID, cmsUInt32Number ErrorCode, const char *ErrorText, ...);
+
+// Memory management ----------------------------------------------------------------------------------
+
+CMSAPI void* CMSEXPORT _cmsMalloc(cmsContext ContextID, cmsUInt32Number size);
+CMSAPI void* CMSEXPORT _cmsMallocZero(cmsContext ContextID, cmsUInt32Number size);
+CMSAPI void* CMSEXPORT _cmsCalloc(cmsContext ContextID, cmsUInt32Number num, cmsUInt32Number size);
+CMSAPI void* CMSEXPORT _cmsRealloc(cmsContext ContextID, void* Ptr, cmsUInt32Number NewSize);
+CMSAPI void CMSEXPORT _cmsFree(cmsContext ContextID, void* Ptr);
+CMSAPI void* CMSEXPORT _cmsDupMem(cmsContext ContextID, const void* Org, cmsUInt32Number size);
+
+// I/O handler ----------------------------------------------------------------------------------
+
+struct _cms_io_handler {
+
+ void* stream; // Associated stream, which is implemented differently depending on media.
+
+ cmsContext ContextID;
+ cmsUInt32Number UsedSpace;
+ char PhysicalFile[cmsMAX_PATH];
+
+ cmsUInt32Number (* Read)(struct _cms_io_handler* iohandler, void *Buffer,
+ cmsUInt32Number size,
+ cmsUInt32Number count);
+ cmsBool (* Seek)(struct _cms_io_handler* iohandler, cmsUInt32Number offset);
+ cmsBool (* Close)(struct _cms_io_handler* iohandler);
+ cmsUInt32Number (* Tell)(struct _cms_io_handler* iohandler);
+ cmsBool (* Write)(struct _cms_io_handler* iohandler, cmsUInt32Number size,
+ const void* Buffer);
+};
+
+// Endianess adjust functions
+CMSAPI cmsUInt16Number CMSEXPORT _cmsAdjustEndianess16(cmsUInt16Number Word);
+CMSAPI cmsUInt32Number CMSEXPORT _cmsAdjustEndianess32(cmsUInt32Number Value);
+CMSAPI void CMSEXPORT _cmsAdjustEndianess64(cmsUInt64Number* Result, cmsUInt64Number QWord);
+
+// Helper IO functions
+CMSAPI cmsBool CMSEXPORT _cmsReadUInt8Number(cmsIOHANDLER* io, cmsUInt8Number* n);
+CMSAPI cmsBool CMSEXPORT _cmsReadUInt16Number(cmsIOHANDLER* io, cmsUInt16Number* n);
+CMSAPI cmsBool CMSEXPORT _cmsReadUInt32Number(cmsIOHANDLER* io, cmsUInt32Number* n);
+CMSAPI cmsBool CMSEXPORT _cmsReadFloat32Number(cmsIOHANDLER* io, cmsFloat32Number* n);
+CMSAPI cmsBool CMSEXPORT _cmsReadUInt64Number(cmsIOHANDLER* io, cmsUInt64Number* n);
+CMSAPI cmsBool CMSEXPORT _cmsRead15Fixed16Number(cmsIOHANDLER* io, cmsFloat64Number* n);
+CMSAPI cmsBool CMSEXPORT _cmsReadXYZNumber(cmsIOHANDLER* io, cmsCIEXYZ* XYZ);
+CMSAPI cmsBool CMSEXPORT _cmsReadUInt16Array(cmsIOHANDLER* io, cmsUInt32Number n, cmsUInt16Number* Array);
+
+CMSAPI cmsBool CMSEXPORT _cmsWriteUInt8Number(cmsIOHANDLER* io, cmsUInt8Number n);
+CMSAPI cmsBool CMSEXPORT _cmsWriteUInt16Number(cmsIOHANDLER* io, cmsUInt16Number n);
+CMSAPI cmsBool CMSEXPORT _cmsWriteUInt32Number(cmsIOHANDLER* io, cmsUInt32Number n);
+CMSAPI cmsBool CMSEXPORT _cmsWriteFloat32Number(cmsIOHANDLER* io, cmsFloat32Number n);
+CMSAPI cmsBool CMSEXPORT _cmsWriteUInt64Number(cmsIOHANDLER* io, cmsUInt64Number n);
+CMSAPI cmsBool CMSEXPORT _cmsWrite15Fixed16Number(cmsIOHANDLER* io, cmsFloat64Number n);
+CMSAPI cmsBool CMSEXPORT _cmsWriteXYZNumber(cmsIOHANDLER* io, const cmsCIEXYZ* XYZ);
+CMSAPI cmsBool CMSEXPORT _cmsWriteUInt16Array(cmsIOHANDLER* io, cmsUInt32Number n, const cmsUInt16Number* Array);
+
+// ICC base tag
+typedef struct {
+ cmsTagTypeSignature sig;
+ cmsInt8Number reserved[4];
+
+} _cmsTagBase;
+
+// Type base helper functions
+CMSAPI cmsTagTypeSignature CMSEXPORT _cmsReadTypeBase(cmsIOHANDLER* io);
+CMSAPI cmsBool CMSEXPORT _cmsWriteTypeBase(cmsIOHANDLER* io, cmsTagTypeSignature sig);
+
+// Alignment functions
+CMSAPI cmsBool CMSEXPORT _cmsReadAlignment(cmsIOHANDLER* io);
+CMSAPI cmsBool CMSEXPORT _cmsWriteAlignment(cmsIOHANDLER* io);
+
+// To deal with text streams. 2K at most
+CMSAPI cmsBool CMSEXPORT _cmsIOPrintf(cmsIOHANDLER* io, const char* frm, ...);
+
+// Fixed point helper functions
+CMSAPI cmsFloat64Number CMSEXPORT _cms8Fixed8toDouble(cmsUInt16Number fixed8);
+CMSAPI cmsUInt16Number CMSEXPORT _cmsDoubleTo8Fixed8(cmsFloat64Number val);
+
+CMSAPI cmsFloat64Number CMSEXPORT _cms15Fixed16toDouble(cmsS15Fixed16Number fix32);
+CMSAPI cmsS15Fixed16Number CMSEXPORT _cmsDoubleTo15Fixed16(cmsFloat64Number v);
+
+// Date/time helper functions
+CMSAPI void CMSEXPORT _cmsEncodeDateTimeNumber(cmsDateTimeNumber *Dest, const struct tm *Source);
+CMSAPI void CMSEXPORT _cmsDecodeDateTimeNumber(const cmsDateTimeNumber *Source, struct tm *Dest);
+
+
+//----------------------------------------------------------------------------------------------------------
+
+// Plug-in foundation
+#define cmsPluginMagicNumber 0x61637070 // 'acpp'
+
+#define cmsPluginMemHandlerSig 0x6D656D48 // 'memH'
+#define cmsPluginInterpolationSig 0x696E7048 // 'inpH'
+#define cmsPluginParametricCurveSig 0x70617248 // 'parH'
+#define cmsPluginFormattersSig 0x66726D48 // 'frmH
+#define cmsPluginTagTypeSig 0x74797048 // 'typH'
+#define cmsPluginTagSig 0x74616748 // 'tagH'
+#define cmsPluginRenderingIntentSig 0x696E7448 // 'intH'
+#define cmsPluginMultiProcessElementSig 0x6D706548 // 'mpeH'
+#define cmsPluginOptimizationSig 0x6F707448 // 'optH'
+
+typedef struct _cmsPluginBaseStruct {
+
+ cmsUInt32Number Magic; // 'acpp' signature
+ cmsUInt32Number ExpectedVersion; // Expected version of LittleCMS
+ cmsUInt32Number Type; // Type of plug-in
+ struct _cmsPluginBaseStruct* Next; // For multiple plugin definition. NULL for end of list.
+
+} cmsPluginBase;
+
+// Maximum number of types in a plugin array
+#define MAX_TYPES_IN_LCMS_PLUGIN 20
+
+//----------------------------------------------------------------------------------------------------------
+
+// Memory handler. Each new plug-in type replaces current behaviour
+typedef struct {
+
+ cmsPluginBase base;
+
+ // Required
+ void * (* MallocPtr)(cmsContext ContextID, cmsUInt32Number size);
+ void (* FreePtr)(cmsContext ContextID, void *Ptr);
+ void * (* ReallocPtr)(cmsContext ContextID, void* Ptr, cmsUInt32Number NewSize);
+
+ // Optional
+ void * (* MallocZeroPtr)(cmsContext ContextID, cmsUInt32Number size);
+ void * (* CallocPtr)(cmsContext ContextID, cmsUInt32Number num, cmsUInt32Number size);
+ void * (* DupPtr)(cmsContext ContextID, const void* Org, cmsUInt32Number size);
+
+} cmsPluginMemHandler;
+
+
+// ------------------------------------------------------------------------------------------------------------------
+
+// Interpolation. 16 bits and floating point versions.
+struct _cms_interp_struc;
+
+// Interpolation callbacks
+
+// 16 bits forward interpolation. This function performs precision-limited linear interpolation
+// and is supposed to be quite fast. Implementation may be tetrahedral or trilinear, and plug-ins may
+// choose to implement any other interpolation algorithm.
+typedef void (* _cmsInterpFn16)(register const cmsUInt16Number Input[],
+ register cmsUInt16Number Output[],
+ register const struct _cms_interp_struc* p);
+
+// Floating point forward interpolation. Full precision interpolation using floats. This is not a
+// time critical function. Implementation may be tetrahedral or trilinear, and plug-ins may
+// choose to implement any other interpolation algorithm.
+typedef void (* _cmsInterpFnFloat)(cmsFloat32Number const Input[],
+ cmsFloat32Number Output[],
+ const struct _cms_interp_struc* p);
+
+
+
+// This type holds a pointer to an interpolator that can be either 16 bits or float
+typedef union {
+ _cmsInterpFn16 Lerp16; // Forward interpolation in 16 bits
+ _cmsInterpFnFloat LerpFloat; // Forward interpolation in floating point
+} cmsInterpFunction;
+
+// Flags for interpolator selection
+#define CMS_LERP_FLAGS_16BITS 0x0000 // The default
+#define CMS_LERP_FLAGS_FLOAT 0x0001 // Requires different implementation
+#define CMS_LERP_FLAGS_TRILINEAR 0x0100 // Hint only
+
+
+#define MAX_INPUT_DIMENSIONS 8
+
+typedef struct _cms_interp_struc { // Used on all interpolations. Supplied by lcms2 when calling the interpolation function
+
+ cmsContext ContextID; // The calling thread
+
+ cmsUInt32Number dwFlags; // Keep original flags
+ cmsUInt32Number nInputs; // != 1 only in 3D interpolation
+ cmsUInt32Number nOutputs; // != 1 only in 3D interpolation
+
+ cmsUInt32Number nSamples[MAX_INPUT_DIMENSIONS]; // Valid on all kinds of tables
+ cmsUInt32Number Domain[MAX_INPUT_DIMENSIONS]; // Domain = nSamples - 1
+
+ cmsUInt32Number opta[MAX_INPUT_DIMENSIONS]; // Optimization for 3D CLUT. This is the number of nodes premultiplied for each
+ // dimension. For example, in 7 nodes, 7, 7^2 , 7^3, 7^4, etc. On non-regular
+ // Samplings may vary according of the number of nodes for each dimension.
+
+ const void *Table; // Points to the actual interpolation table
+ cmsInterpFunction Interpolation; // Points to the function to do the interpolation
+
+ } cmsInterpParams;
+
+// Interpolators factory
+typedef cmsInterpFunction (* cmsInterpFnFactory)(cmsUInt32Number nInputChannels, cmsUInt32Number nOutputChannels, cmsUInt32Number dwFlags);
+
+// The plug-in
+typedef struct {
+ cmsPluginBase base;
+
+ // Points to a user-supplied function which implements the factory
+ cmsInterpFnFactory InterpolatorsFactory;
+
+} cmsPluginInterpolation;
+
+//----------------------------------------------------------------------------------------------------------
+
+// Parametric curves. A negative type means same function but analytically inverted. Max. number of params is 10
+
+// Evaluator callback for user-suplied parametric curves. May implement more than one type
+typedef cmsFloat64Number (* cmsParametricCurveEvaluator)(cmsInt32Number Type, const cmsFloat64Number Params[10], cmsFloat64Number R);
+
+// Plug-in may implement an arbitrary number of parametric curves
+typedef struct {
+ cmsPluginBase base;
+
+ cmsUInt32Number nFunctions; // Number of supported functions
+ cmsUInt32Number FunctionTypes[MAX_TYPES_IN_LCMS_PLUGIN]; // The identification types
+ cmsUInt32Number ParameterCount[MAX_TYPES_IN_LCMS_PLUGIN]; // Number of parameters for each function
+
+ cmsParametricCurveEvaluator Evaluator; // The evaluator
+
+} cmsPluginParametricCurves;
+//----------------------------------------------------------------------------------------------------------
+
+// Formatters. This plug-in adds new handlers, replacing them if they already exist. Formatters dealing with
+// cmsFloat32Number (bps = 4) or double (bps = 0) types are requested via FormatterFloat callback. Others come across
+// Formatter16 callback
+
+struct _cmstransform_struct;
+
+typedef cmsUInt8Number* (* cmsFormatter16)(register struct _cmstransform_struct* CMMcargo,
+ register cmsUInt16Number Values[],
+ register cmsUInt8Number* Buffer,
+ register cmsUInt32Number Stride);
+
+typedef cmsUInt8Number* (* cmsFormatterFloat)(struct _cmstransform_struct* CMMcargo,
+ cmsFloat32Number Values[],
+ cmsUInt8Number* Buffer,
+ cmsUInt32Number Stride);
+
+// This type holds a pointer to a formatter that can be either 16 bits or cmsFloat32Number
+typedef union {
+ cmsFormatter16 Fmt16;
+ cmsFormatterFloat FmtFloat;
+
+} cmsFormatter;
+
+#define CMS_PACK_FLAGS_16BITS 0x0000
+#define CMS_PACK_FLAGS_FLOAT 0x0001
+
+typedef enum { cmsFormatterInput=0, cmsFormatterOutput=1 } cmsFormatterDirection;
+
+typedef cmsFormatter (* cmsFormatterFactory)(cmsUInt32Number Type, // Specific type, i.e. TYPE_RGB_8
+ cmsFormatterDirection Dir,
+ cmsUInt32Number dwFlags); // precision
+
+// Plug-in may implement an arbitrary number of formatters
+typedef struct {
+ cmsPluginBase base;
+ cmsFormatterFactory FormattersFactory;
+
+} cmsPluginFormatters;
+
+//----------------------------------------------------------------------------------------------------------
+
+// Tag type handler. Each type is free to return anything it wants, and it is up to the caller to
+// know in advance what is the type contained in the tag.
+typedef struct _cms_typehandler_struct {
+
+ cmsTagTypeSignature Signature; // The signature of the type
+
+ // Allocates and reads items
+ void * (* ReadPtr)(struct _cms_typehandler_struct* self,
+ cmsIOHANDLER* io,
+ cmsUInt32Number* nItems,
+ cmsUInt32Number SizeOfTag);
+
+ // Writes n Items
+ cmsBool (* WritePtr)(struct _cms_typehandler_struct* self,
+ cmsIOHANDLER* io,
+ void* Ptr,
+ cmsUInt32Number nItems);
+
+ // Duplicate an item or array of items
+ void* (* DupPtr)(struct _cms_typehandler_struct* self,
+ const void *Ptr,
+ cmsUInt32Number n);
+
+ // Free all resources
+ void (* FreePtr)(struct _cms_typehandler_struct* self,
+ void *Ptr);
+
+ // The calling thread
+ cmsContext ContextID;
+
+} cmsTagTypeHandler;
+
+// Each plug-in implements a single type
+typedef struct {
+ cmsPluginBase base;
+ cmsTagTypeHandler Handler;
+
+} cmsPluginTagType;
+
+//----------------------------------------------------------------------------------------------------------
+
+// This is the tag plugin, which identifies tags. For writing, a pointer to function is provided.
+// This function should return the desired type for this tag, given the version of profile
+// and the data being serialized.
+typedef struct {
+
+ cmsUInt32Number ElemCount; // If this tag needs an array, how many elements should keep
+
+ // For reading.
+ cmsUInt32Number nSupportedTypes; // In how many types this tag can come (MAX_TYPES_IN_LCMS_PLUGIN maximum)
+ cmsTagTypeSignature SupportedTypes[MAX_TYPES_IN_LCMS_PLUGIN];
+
+ // For writting
+ cmsTagTypeSignature (* DecideType)(cmsFloat64Number ICCVersion, const void *Data);
+
+} cmsTagDescriptor;
+
+// Plug-in implements a single tag
+typedef struct {
+ cmsPluginBase base;
+
+ cmsTagSignature Signature;
+ cmsTagDescriptor Descriptor;
+
+} cmsPluginTag;
+
+//----------------------------------------------------------------------------------------------------------
+
+// Custom intents. This function should join all profiles specified in the array in
+// a single LUT. Any custom intent in the chain redirects to custom function. If more than
+// one custom intent is found, the one located first is invoked. Usually users should use only one
+// custom intent, so mixing custom intents in same multiprofile transform is not supported.
+
+typedef cmsPipeline* (* cmsIntentFn)( cmsContext ContextID,
+ cmsUInt32Number nProfiles,
+ cmsUInt32Number Intents[],
+ cmsHPROFILE hProfiles[],
+ cmsBool BPC[],
+ cmsFloat64Number AdaptationStates[],
+ cmsUInt32Number dwFlags);
+
+
+// Each plug-in defines a single intent number.
+typedef struct {
+ cmsPluginBase base;
+ cmsUInt32Number Intent;
+ cmsIntentFn Link;
+ char Description[256];
+
+} cmsPluginRenderingIntent;
+
+
+// The default ICC intents (perceptual, saturation, rel.col and abs.col)
+CMSAPI cmsPipeline* CMSEXPORT _cmsDefaultICCintents(cmsContext ContextID,
+ cmsUInt32Number nProfiles,
+ cmsUInt32Number Intents[],
+ cmsHPROFILE hProfiles[],
+ cmsBool BPC[],
+ cmsFloat64Number AdaptationStates[],
+ cmsUInt32Number dwFlags);
+
+
+//----------------------------------------------------------------------------------------------------------
+
+// Pipelines, Multi Process Elements.
+
+typedef void (* _cmsStageEvalFn) (const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsStage* mpe);
+typedef void*(* _cmsStageDupElemFn) (cmsStage* mpe);
+typedef void (* _cmsStageFreeElemFn) (cmsStage* mpe);
+
+
+// This function allocates a generic MPE
+CMSAPI cmsStage* CMSEXPORT _cmsStageAllocPlaceholder(cmsContext ContextID,
+ cmsStageSignature Type,
+ cmsUInt32Number InputChannels,
+ cmsUInt32Number OutputChannels,
+ _cmsStageEvalFn EvalPtr, // Points to fn that evaluates the element (always in floating point)
+ _cmsStageDupElemFn DupElemPtr, // Points to a fn that duplicates the stage
+ _cmsStageFreeElemFn FreePtr, // Points to a fn that sets the element free
+ void* Data); // A generic pointer to whatever memory needed by the element
+typedef struct {
+ cmsPluginBase base;
+ cmsTagTypeHandler Handler;
+
+} cmsPluginMultiProcessElement;
+
+//----------------------------------------------------------------------------------------------------------
+// Optimization. Using this plug-in, additional optimization strategies may be implemented.
+// The function should return TRUE if any optimization is done on the LUT, this terminates
+// the optimization search. Or FALSE if it is unable to optimize and want to give a chance
+// to the rest of optimizers.
+
+typedef void (* _cmsOPTeval16Fn)(register const cmsUInt16Number In[],
+ register cmsUInt16Number Out[],
+ register const void* Data);
+
+typedef void (* _cmsOPTfreeDataFn)(cmsContext ContextID, void* Data);
+typedef void* (* _cmsOPTdupDataFn)(cmsContext ContextID, const void* Data);
+
+
+typedef cmsBool (* _cmsOPToptimizeFn)(cmsPipeline** Lut,
+ cmsUInt32Number Intent,
+ cmsUInt32Number* InputFormat,
+ cmsUInt32Number* OutputFormat,
+ cmsUInt32Number* dwFlags);
+
+// This function may be used to set the optional evaluator and a block of private data. If private data is being used, an optional
+// duplicator and free functions should also be specified in order to duplicate the LUT construct. Use NULL to inhibit such functionality.
+
+CMSAPI void CMSEXPORT _cmsPipelineSetOptimizationParameters(cmsPipeline* Lut,
+ _cmsOPTeval16Fn Eval16,
+ void* PrivateData,
+ _cmsOPTfreeDataFn FreePrivateDataFn,
+ _cmsOPTdupDataFn DupPrivateDataFn);
+
+typedef struct {
+ cmsPluginBase base;
+
+ // Optimize entry point
+ _cmsOPToptimizeFn OptimizePtr;
+
+} cmsPluginOptimization;
+
+//----------------------------------------------------------------------------------------------------------
+
+#ifndef CMS_USE_CPP_API
+# ifdef __cplusplus
+ }
+# endif
+#endif
+
+#define _lcms_plugin_H
+#endif
-/* $Id: tiff.h,v 1.42 2005/12/23 15:10:45 dron Exp $ */
+/* $Id: tiff.h,v 1.65 2010-03-10 18:56:49 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
* 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://gdal.maptools.org/twiki/bin/view/libtiff/BigTIFFDesign
+ * For BigTIFF design notes see the following links
+ * http://www.remotesensing.org/libtiff/bigtiffdesign.html
+ * http://www.awaresystems.be/imaging/tiff/bigtiff.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
+#define TIFF_VERSION_CLASSIC 42
+#define TIFF_VERSION_BIG 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*
+ * 8-bit quantities int8/uint8
+ * 16-bit quantities int16/uint16
+ * 32-bit quantities int32/uint32
+ * 64-bit quantities int64/uint64
+ * 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
+typedef TIFF_INT8_T int8;
+typedef TIFF_UINT8_T uint8;
-/* For TIFFReassignTagToIgnore */
-enum TIFFIgnoreSense /* IGNORE tag table */
-{
- TIS_STORE,
- TIS_EXTRACT,
- TIS_EMPTY
-};
+typedef TIFF_INT16_T int16;
+typedef TIFF_UINT16_T uint16;
+
+typedef TIFF_INT32_T int32;
+typedef TIFF_UINT32_T uint32;
+
+typedef TIFF_INT64_T int64;
+typedef TIFF_UINT64_T uint64;
/*
- * TIFF header.
+ * Some types as promoted in a variable argument list
+ * We use uint16_vap rather then directly using int, because this way
+ * we document the type we actually want to pass through, conceptually,
+ * rather then confusing the issue by merely stating the type it gets
+ * promoted to
*/
-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;
+typedef int uint16_vap;
/*
- * 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.
+ * TIFF header.
*/
-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;
+typedef struct {
+ uint16 tiff_magic; /* magic number (defines byte order) */
+ uint16 tiff_version; /* TIFF version number */
+} TIFFHeaderCommon;
+typedef struct {
+ uint16 tiff_magic; /* magic number (defines byte order) */
+ uint16 tiff_version; /* TIFF version number */
+ uint32 tiff_diroff; /* byte offset to first directory */
+} TIFFHeaderClassic;
+typedef struct {
+ uint16 tiff_magic; /* magic number (defines byte order) */
+ uint16 tiff_version; /* TIFF version number */
+ uint16 tiff_offsetsize; /* size of offsets, should be 8 */
+ uint16 tiff_unused; /* unused word, should be 0 */
+ uint64 tiff_diroff; /* byte offset to first directory */
+} TIFFHeaderBig;
+
/*
* NB: In the comments below,
*
* 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) */
+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) */
+ TIFF_LONG8 = 16, /* BigTIFF 64-bit unsigned integer */
+ TIFF_SLONG8 = 17, /* BigTIFF 64-bit signed integer */
+ TIFF_IFD8 = 18 /* BigTIFF 64-bit unsigned integer (offset) */
} TIFFDataType;
/*
#endif /* _TIFF_ */
/* vim: set ts=8 sts=8 sw=8 noet: */
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 8
+ * fill-column: 78
+ * End:
+ */
-/* libtiff/tiffconf.h. Generated by configure. */
+/* libtiff/tiffconf.h. Generated from tiffconf.h.in by configure. */
/*
Configuration defines for installed libtiff.
This file maintained for backward compatibility. Do not use definitions
#ifndef _TIFFCONF_
#define _TIFFCONF_
+/* Signed 16-bit type */
+#define TIFF_INT16_T signed short
+
+/* Signed 32-bit type */
+#define TIFF_INT32_T signed int
+
+/* Signed 64-bit type */
+#define TIFF_INT64_T signed long long
+
+/* Signed 8-bit type */
+#define TIFF_INT8_T signed char
+
+/* Unsigned 16-bit type */
+#define TIFF_UINT16_T unsigned short
+
+/* Unsigned 32-bit type */
+#define TIFF_UINT32_T unsigned int
+
+/* Unsigned 64-bit type */
+#define TIFF_UINT64_T unsigned long long
+
+/* Unsigned 8-bit type */
+#define TIFF_UINT8_T unsigned char
+
+/* Signed size type */
+#define TIFF_SSIZE_T signed long
+
+/* Pointer difference type */
+#define TIFF_PTRDIFF_T ptrdiff_t
+
/* Define to 1 if the system has the type `int16'. */
/* #undef HAVE_INT16 */
/* 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
-
/* Compatibility stuff. */
/* Define as 0 or 1 according to the floating point format suported by the
#define CCITT_SUPPORT 1
/* Support JPEG compression (requires IJG JPEG library) */
-#undef JPEG_SUPPORT
+#define JPEG_SUPPORT 1
+
+/* Support JBIG compression (requires JBIG-KIT library) */
+#define JBIG_SUPPORT 1
/* Support LogLuv high dynamic range encoding */
#define LOGLUV_SUPPORT 1
/* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation
fails with unpatched IJG JPEG library) */
-/* #undef OJPEG_SUPPORT */
+#define OJPEG_SUPPORT 1
/* Support Macintosh PackBits algorithm */
#define PACKBITS_SUPPORT 1
-/* $Id: tiffio.h,v 1.50 2006/03/21 16:37:51 dron Exp $ */
+/* $Id: tiffio.h,v 1.86 2010-03-10 18:56:49 bfriesen 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
+ * 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.
- *
+ *
+ * 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,
* TIFF is defined as an incomplete type to hide the
* library's internal data structures from clients.
*/
-typedef struct tiff TIFF;
+typedef struct tiff TIFF;
/*
* The following typedefs define the intrinsic size of
* 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.
+ * 32-bit file offsets, and BigTIFF maxes out at 64-bit
+ * offsets being the most important, and to ensure use of
+ * a consistently unsigned type across architectures.
+ * Prior to libtiff 4.0, this was an unsigned 32 bit type.
*/
-typedef uint32 ttag_t; /* directory tag */
-typedef uint16 tdir_t; /* directory index */
-typedef uint16 tsample_t; /* sample number */
-typedef uint32 tstrip_t; /* strip number */
-typedef uint32 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 */
+/*
+ * this is the machine addressing size type, only it's signed, so make it
+ * int32 on 32bit machines, int64 on 64bit machines
+ */
+typedef TIFF_SSIZE_T tmsize_t;
+typedef uint64 toff_t; /* file offset */
+/* the following are deprecated and should be replaced by their defining
+ counterparts */
+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 tmsize_t tsize_t; /* i/o size in bytes */
+typedef void* tdata_t; /* image data ref */
#if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32))
#define __WIN32__
# define VC_EXTRALEAN
# include <windows.h>
# ifdef __WIN32__
-DECLARE_HANDLE(thandle_t); /* Win32 file handle */
+DECLARE_HANDLE(thandle_t); /* Win32 file handle */
# else
-typedef HFILE thandle_t; /* client data handle */
+typedef HFILE thandle_t; /* client data handle */
# endif /* __WIN32__ */
#else
-typedef void* thandle_t; /* client data handle */
+typedef void* thandle_t; /* client data handle */
#endif /* USE_WIN32_FILEIO */
-#ifndef NULL
-# define NULL (void *)0
-#endif
-
/*
* 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 */
+#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
/* Structure for holding information about a display device. */
-typedef unsigned char TIFFRGBValue; /* 8-bit samples */
+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_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_Vrwr; /* Pixel values for ref. white */
uint32 d_Vrwg;
uint32 d_Vrwb;
- float d_Y0R; /* Residual light for black pixel */
+ 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_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;
+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 */
+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 */
+ 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 */
+ 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-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);
+ 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; /* put decoded strip/tile */
- 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;
+ 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 */
+
+ uint8* UaToAa; /* Unassociated alpha to associated alpha convertion LUT */
+ uint8* Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */
+
+ 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)
+#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,
* More codecs may be registered through calls to the library
* and/or the builtin implementations may be overridden.
*/
-typedef int (*TIFFInitMethod)(TIFF*, int);
+typedef int (*TIFFInitMethod)(TIFF*, int);
typedef struct {
- char* name;
- uint16 scheme;
- TIFFInitMethod init;
+ char* name;
+ uint16 scheme;
+ TIFFInitMethod init;
} TIFFCodec;
#include <stdio.h>
/* share internal LogLuv conversion routines? */
#ifndef LOGLUV_PUBLIC
-#define LOGLUV_PUBLIC 1
+#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);
+typedef void (*TIFFErrorHandler)(const char*, const char*, va_list);
+typedef void (*TIFFErrorHandlerExt)(thandle_t, const char*, const char*, va_list);
+typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void*, tmsize_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, void** base, toff_t* size);
+typedef void (*TIFFUnmapFileProc)(thandle_t, void* base, toff_t size);
+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);
+extern void* _TIFFmalloc(tmsize_t s);
+extern void* _TIFFrealloc(void* p, tmsize_t s);
+extern void _TIFFmemset(void* p, int v, tmsize_t c);
+extern void _TIFFmemcpy(void* d, const void* s, tmsize_t c);
+extern int _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c);
+extern void _TIFFfree(void* p);
/*
** Stuff, related to tag handling and creating custom tags.
*/
-extern int TIFFGetTagListCount( TIFF * );
-extern ttag_t TIFFGetTagListEntry( TIFF *, int tag_index );
+extern int TIFFGetTagListCount( TIFF * );
+extern uint32 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 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
+#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 _TIFFField TIFFField;
+typedef struct _TIFFFieldArray TIFFFieldArray;
+
+extern const TIFFField* TIFFFindField(TIFF *, uint32, TIFFDataType);
+extern const TIFFField* TIFFFieldWithTag(TIFF*, uint32);
+extern const TIFFField* TIFFFieldWithName(TIFF*, const char *);
+
+typedef int (*TIFFVSetMethod)(TIFF*, uint32, va_list);
+typedef int (*TIFFVGetMethod)(TIFF*, uint32, va_list);
+typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long);
-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 */
+ 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 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);
+
+extern TIFFTagMethods *TIFFAccessTagMethods(TIFF *);
+extern void *TIFFGetClientInfo(TIFF *, const char *);
+extern void TIFFSetClientInfo(TIFF *, void *, const char *);
+
+extern void TIFFCleanup(TIFF* tif);
+extern void TIFFClose(TIFF* tif);
+extern int TIFFFlush(TIFF* tif);
+extern int TIFFFlushData(TIFF* tif);
+extern int TIFFGetField(TIFF* tif, uint32 tag, ...);
+extern int TIFFVGetField(TIFF* tif, uint32 tag, va_list ap);
+extern int TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...);
+extern int TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap);
+extern int TIFFReadDirectory(TIFF* tif);
+extern int TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, const TIFFFieldArray* infoarray);
+extern int TIFFReadEXIFDirectory(TIFF* tif, toff_t diroff);
+extern uint64 TIFFScanlineSize64(TIFF* tif);
+extern tmsize_t TIFFScanlineSize(TIFF* tif);
+extern uint64 TIFFRasterScanlineSize64(TIFF* tif);
+extern tmsize_t TIFFRasterScanlineSize(TIFF* tif);
+extern uint64 TIFFStripSize64(TIFF* tif);
+extern tmsize_t TIFFStripSize(TIFF* tif);
+extern uint64 TIFFRawStripSize64(TIFF* tif, uint32 strip);
+extern tmsize_t TIFFRawStripSize(TIFF* tif, uint32 strip);
+extern uint64 TIFFVStripSize64(TIFF* tif, uint32 nrows);
+extern tmsize_t TIFFVStripSize(TIFF* tif, uint32 nrows);
+extern uint64 TIFFTileRowSize64(TIFF* tif);
+extern tmsize_t TIFFTileRowSize(TIFF* tif);
+extern uint64 TIFFTileSize64(TIFF* tif);
+extern tmsize_t TIFFTileSize(TIFF* tif);
+extern uint64 TIFFVTileSize64(TIFF* tif, uint32 nrows);
+extern tmsize_t TIFFVTileSize(TIFF* tif, uint32 nrows);
+extern uint32 TIFFDefaultStripSize(TIFF* tif, uint32 request);
+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 uint16 TIFFCurrentDirectory(TIFF*);
+extern uint16 TIFFNumberOfDirectories(TIFF*);
+extern uint64 TIFFCurrentDirOffset(TIFF*);
+extern uint32 TIFFCurrentStrip(TIFF*);
+extern uint32 TIFFCurrentTile(TIFF* tif);
+extern int TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size);
+extern int TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size);
+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*, uint16);
+extern int TIFFSetSubDirectory(TIFF*, uint64);
+extern int TIFFUnlinkDirectory(TIFF*, uint16);
+extern int TIFFSetField(TIFF*, uint32, ...);
+extern int TIFFVSetField(TIFF*, uint32, va_list);
+extern int TIFFUnsetField(TIFF*, uint32);
+extern int TIFFWriteDirectory(TIFF *);
+extern int TIFFCheckpointDirectory(TIFF *);
+extern int TIFFRewriteDirectory(TIFF *);
#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);
+extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0);
+extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0);
+extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 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);
+extern void TIFFPrintDirectory(TIFF*, FILE*, long);
+extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample);
+extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample);
+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*);
+extern int TIFFReadRGBAStrip(TIFF*, uint32, 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*);
+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*,
+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*, ...);
-extern void TIFFErrorExt(thandle_t, const char*, const char*, ...);
-extern void TIFFWarning(const char*, const char*, ...);
-extern void TIFFWarningExt(thandle_t, const char*, const char*, ...);
-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);
+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 uint32 TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s);
+extern int TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s);
+extern uint32 TIFFNumberOfTiles(TIFF*);
+extern tmsize_t TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s);
+extern tmsize_t TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s);
+extern uint32 TIFFComputeStrip(TIFF*, uint32, uint16);
+extern uint32 TIFFNumberOfStrips(TIFF*);
+extern tmsize_t TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size);
+extern tmsize_t TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size);
+extern tmsize_t TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size);
+extern tmsize_t TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size);
+extern tmsize_t TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc);
+extern tmsize_t TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc);
+extern tmsize_t TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc);
+extern tmsize_t TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc);
+extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */
+extern void TIFFSetWriteOffset(TIFF* tif, toff_t off);
+extern void TIFFSwabShort(uint16*);
+extern void TIFFSwabLong(uint32*);
+extern void TIFFSwabLong8(uint64*);
+extern void TIFFSwabFloat(float*);
+extern void TIFFSwabDouble(double*);
+extern void TIFFSwabArrayOfShort(uint16* wp, tmsize_t n);
+extern void TIFFSwabArrayOfTriples(uint8* tp, tmsize_t n);
+extern void TIFFSwabArrayOfLong(uint32* lp, tmsize_t n);
+extern void TIFFSwabArrayOfLong8(uint64* lp, tmsize_t n);
+extern void TIFFSwabArrayOfFloat(float* fp, tmsize_t n);
+extern void TIFFSwabArrayOfDouble(double* dp, tmsize_t n);
+extern void TIFFReverseBits(uint8* cp, tmsize_t n);
+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*);
+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);
+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);
+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 int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, const TIFFDisplay *, float*);
extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32,
- float *, float *, float *);
+ float *, float *, float *);
extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float,
- uint32 *, uint32 *, uint32 *);
+ uint32 *, uint32 *, uint32 *);
extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*);
extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32,
- uint32 *, uint32 *, uint32 *);
+ uint32 *, uint32 *, uint32 *);
+
+/****************************************************************************
+ * O B S O L E T E D I N T E R F A C E S
+ *
+ * Don't use this stuff in your applications, it may be removed in the future
+ * libtiff versions.
+ ****************************************************************************/
+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;
+
+extern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32);
+extern const TIFFFieldInfo* TIFFFindFieldInfo(TIFF*, uint32, TIFFDataType);
+extern const TIFFFieldInfo* TIFFFindFieldInfoByName(TIFF* , const char *,
+ TIFFDataType);
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif /* _TIFFIO_ */
/* vim: set ts=8 sts=8 sw=8 noet: */
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 8
+ * fill-column: 78
+ * End:
+ */
--- /dev/null
+/* $Id: tiffio.hxx,v 1.3 2010-06-08 18:55:15 bfriesen 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 <iostream>
+#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:
+ */
-#define TIFFLIB_VERSION_STR "LIBTIFF, Version 3.8.2\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
+#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.0beta6\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 checking should be done based on the
* string returned by TIFFGetVersion.
*/
-#define TIFFLIB_VERSION 20060323
+#define TIFFLIB_VERSION 20100611
--- /dev/null
+
+/* png.h - header file for PNG reference library
+ *
+ * libpng version 1.4.4 - September 23, 2010
+ * Copyright (c) 1998-2010 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.)
+ *
+ * This code is released under the libpng license (See LICENSE, below)
+ *
+ * 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.4.4 - September 23, 2010: Glenn
+ * See also "Contributing Authors", below.
+ *
+ * Note about libpng version numbers:
+ *
+ * Due to various miscommunications, unforeseen code incompatibilities
+ * and occasional factors outside the authors' control, version numbering
+ * on the library has not always been consistent and straightforward.
+ * The following table summarizes matters since version 0.89c, which was
+ * the first widely used release:
+ *
+ * source png.h png.h shared-lib
+ * version string int version
+ * ------- ------ ----- ----------
+ * 0.89c "1.0 beta 3" 0.89 89 1.0.89
+ * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90]
+ * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95]
+ * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96]
+ * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97]
+ * 0.97c 0.97 97 2.0.97
+ * 0.98 0.98 98 2.0.98
+ * 0.99 0.99 98 2.0.99
+ * 0.99a-m 0.99 99 2.0.99
+ * 1.00 1.00 100 2.1.0 [100 should be 10000]
+ * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000]
+ * 1.0.1 png.h string is 10001 2.1.0
+ * 1.0.1a-e identical to the 10002 from here on, the shared library
+ * 1.0.2 source version) 10002 is 2.V where V is the source code
+ * 1.0.2a-b 10003 version, except as noted.
+ * 1.0.3 10003
+ * 1.0.3a-d 10004
+ * 1.0.4 10004
+ * 1.0.4a-f 10005
+ * 1.0.5 (+ 2 patches) 10005
+ * 1.0.5a-d 10006
+ * 1.0.5e-r 10100 (not source compatible)
+ * 1.0.5s-v 10006 (not binary compatible)
+ * 1.0.6 (+ 3 patches) 10006 (still binary incompatible)
+ * 1.0.6d-f 10007 (still binary incompatible)
+ * 1.0.6g 10007
+ * 1.0.6h 10007 10.6h (testing xy.z so-numbering)
+ * 1.0.6i 10007 10.6i
+ * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0)
+ * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible)
+ * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible)
+ * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible)
+ * 1.0.7 1 10007 (still compatible)
+ * 1.0.8beta1-4 1 10008 2.1.0.8beta1-4
+ * 1.0.8rc1 1 10008 2.1.0.8rc1
+ * 1.0.8 1 10008 2.1.0.8
+ * 1.0.9beta1-6 1 10009 2.1.0.9beta1-6
+ * 1.0.9rc1 1 10009 2.1.0.9rc1
+ * 1.0.9beta7-10 1 10009 2.1.0.9beta7-10
+ * 1.0.9rc2 1 10009 2.1.0.9rc2
+ * 1.0.9 1 10009 2.1.0.9
+ * 1.0.10beta1 1 10010 2.1.0.10beta1
+ * 1.0.10rc1 1 10010 2.1.0.10rc1
+ * 1.0.10 1 10010 2.1.0.10
+ * 1.0.11beta1-3 1 10011 2.1.0.11beta1-3
+ * 1.0.11rc1 1 10011 2.1.0.11rc1
+ * 1.0.11 1 10011 2.1.0.11
+ * 1.0.12beta1-2 2 10012 2.1.0.12beta1-2
+ * 1.0.12rc1 2 10012 2.1.0.12rc1
+ * 1.0.12 2 10012 2.1.0.12
+ * 1.1.0a-f - 10100 2.1.1.0a-f (branch abandoned)
+ * 1.2.0beta1-2 2 10200 2.1.2.0beta1-2
+ * 1.2.0beta3-5 3 10200 3.1.2.0beta3-5
+ * 1.2.0rc1 3 10200 3.1.2.0rc1
+ * 1.2.0 3 10200 3.1.2.0
+ * 1.2.1beta1-4 3 10201 3.1.2.1beta1-4
+ * 1.2.1rc1-2 3 10201 3.1.2.1rc1-2
+ * 1.2.1 3 10201 3.1.2.1
+ * 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6
+ * 1.0.13beta1 10 10013 10.so.0.1.0.13beta1
+ * 1.0.13rc1 10 10013 10.so.0.1.0.13rc1
+ * 1.2.2rc1 12 10202 12.so.0.1.2.2rc1
+ * 1.0.13 10 10013 10.so.0.1.0.13
+ * 1.2.2 12 10202 12.so.0.1.2.2
+ * 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6
+ * 1.2.3 12 10203 12.so.0.1.2.3
+ * 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3
+ * 1.0.14rc1 13 10014 10.so.0.1.0.14rc1
+ * 1.2.4rc1 13 10204 12.so.0.1.2.4rc1
+ * 1.0.14 10 10014 10.so.0.1.0.14
+ * 1.2.4 13 10204 12.so.0.1.2.4
+ * 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2
+ * 1.0.15rc1-3 10 10015 10.so.0.1.0.15rc1-3
+ * 1.2.5rc1-3 13 10205 12.so.0.1.2.5rc1-3
+ * 1.0.15 10 10015 10.so.0.1.0.15
+ * 1.2.5 13 10205 12.so.0.1.2.5
+ * 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4
+ * 1.0.16 10 10016 10.so.0.1.0.16
+ * 1.2.6 13 10206 12.so.0.1.2.6
+ * 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2
+ * 1.0.17rc1 10 10017 12.so.0.1.0.17rc1
+ * 1.2.7rc1 13 10207 12.so.0.1.2.7rc1
+ * 1.0.17 10 10017 12.so.0.1.0.17
+ * 1.2.7 13 10207 12.so.0.1.2.7
+ * 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5
+ * 1.0.18rc1-5 10 10018 12.so.0.1.0.18rc1-5
+ * 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5
+ * 1.0.18 10 10018 12.so.0.1.0.18
+ * 1.2.8 13 10208 12.so.0.1.2.8
+ * 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3
+ * 1.2.9beta4-11 13 10209 12.so.0.9[.0]
+ * 1.2.9rc1 13 10209 12.so.0.9[.0]
+ * 1.2.9 13 10209 12.so.0.9[.0]
+ * 1.2.10beta1-7 13 10210 12.so.0.10[.0]
+ * 1.2.10rc1-2 13 10210 12.so.0.10[.0]
+ * 1.2.10 13 10210 12.so.0.10[.0]
+ * 1.4.0beta1-5 14 10400 14.so.0.0[.0]
+ * 1.2.11beta1-4 13 10211 12.so.0.11[.0]
+ * 1.4.0beta7-8 14 10400 14.so.0.0[.0]
+ * 1.2.11 13 10211 12.so.0.11[.0]
+ * 1.2.12 13 10212 12.so.0.12[.0]
+ * 1.4.0beta9-14 14 10400 14.so.0.0[.0]
+ * 1.2.13 13 10213 12.so.0.13[.0]
+ * 1.4.0beta15-36 14 10400 14.so.0.0[.0]
+ * 1.4.0beta37-87 14 10400 14.so.14.0[.0]
+ * 1.4.0rc01 14 10400 14.so.14.0[.0]
+ * 1.4.0beta88-109 14 10400 14.so.14.0[.0]
+ * 1.4.0rc02-08 14 10400 14.so.14.0[.0]
+ * 1.4.0 14 10400 14.so.14.0[.0]
+ * 1.4.1beta01-03 14 10401 14.so.14.1[.0]
+ * 1.4.1rc01 14 10401 14.so.14.1[.0]
+ * 1.4.1beta04-12 14 10401 14.so.14.1[.0]
+ * 1.4.1rc02-04 14 10401 14.so.14.1[.0]
+ * 1.4.1 14 10401 14.so.14.1[.0]
+ * 1.4.2beta01 14 10402 14.so.14.2[.0]
+ * 1.4.2rc02-06 14 10402 14.so.14.2[.0]
+ * 1.4.2 14 10402 14.so.14.2[.0]
+ * 1.4.3beta01-05 14 10403 14.so.14.3[.0]
+ * 1.4.3rc01-03 14 10403 14.so.14.3[.0]
+ * 1.4.3 14 10403 14.so.14.3[.0]
+ * 1.4.4beta01-08 14 10404 14.so.14.4[.0]
+ * 1.4.4rc01-06 14 10404 14.so.14.4[.0]
+ *
+ * Henceforth the source version will match the shared-library major
+ * and minor numbers; the shared-library major version number will be
+ * used for changes in backward compatibility, as it is intended. The
+ * PNG_LIBPNG_VER macro, which is not used within libpng but is available
+ * for applications, is an unsigned integer of the form xyyzz corresponding
+ * 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".
+ *
+ * Binary incompatibility exists only when applications make direct access
+ * to the info_ptr or png_ptr members through png.h, and the compiled
+ * application is loaded with a different version of the library.
+ *
+ * DLLNUM will change each time there are forward or backward changes
+ * in binary compatibility (e.g., when a new feature is added).
+ *
+ * See libpng.txt or libpng.3 for more information. The PNG specification
+ * is available as a W3C Recommendation and as an ISO Specification,
+ * <http://www.w3.org/TR/2003/REC-PNG-20031110/
+ */
+
+/*
+ * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
+ *
+ * If you modify libpng you may insert additional notices immediately following
+ * this sentence.
+ *
+ * This code is released under the libpng license.
+ *
+ * libpng versions 1.2.6, August 15, 2004, through 1.4.4, September 23, 2010, are
+ * Copyright (c) 2004, 2006-2010 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:
+ *
+ * Cosmin Truta
+ *
+ * libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are
+ * Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
+ * distributed according to the same disclaimer and license as libpng-1.0.6
+ * with the following individuals added to the list of Contributing Authors:
+ *
+ * Simon-Pierre Cadieux
+ * Eric S. Raymond
+ * Gilles Vollant
+ *
+ * and with the following additions to the disclaimer:
+ *
+ * There is no warranty against interference with your enjoyment of the
+ * library or against infringement. There is no warranty that our
+ * efforts or the library will fulfill any of your particular purposes
+ * or needs. This library is provided with all faults, and the entire
+ * risk of satisfactory quality, performance, accuracy, and effort is with
+ * the user.
+ *
+ * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
+ * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson, and are
+ * distributed according to the same disclaimer and license as libpng-0.96,
+ * with the following individuals added to the list of Contributing Authors:
+ *
+ * Tom Lane
+ * Glenn Randers-Pehrson
+ * Willem van Schaik
+ *
+ * libpng versions 0.89, June 1996, through 0.96, May 1997, are
+ * Copyright (c) 1996, 1997 Andreas Dilger
+ * Distributed according to the same disclaimer and license as libpng-0.88,
+ * with the following individuals added to the list of Contributing Authors:
+ *
+ * John Bowler
+ * Kevin Bracey
+ * Sam Bushell
+ * Magnus Holmgren
+ * Greg Roelofs
+ * Tom Tanner
+ *
+ * libpng versions 0.5, May 1995, through 0.88, January 1996, are
+ * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
+ *
+ * For the purposes of this copyright and license, "Contributing Authors"
+ * is defined as the following set of individuals:
+ *
+ * Andreas Dilger
+ * Dave Martindale
+ * Guy Eric Schalnat
+ * Paul Schmidt
+ * Tim Wegner
+ *
+ * The PNG Reference Library is supplied "AS IS". The Contributing Authors
+ * and Group 42, Inc. disclaim all warranties, expressed or implied,
+ * including, without limitation, the warranties of merchantability and of
+ * fitness for any purpose. The Contributing Authors and Group 42, Inc.
+ * assume no liability for direct, indirect, incidental, special, exemplary,
+ * or consequential damages, which may result from the use of the PNG
+ * Reference 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.
+ *
+ * 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 and Group 42, Inc. specifically permit, without
+ * fee, and encourage the use of this source code as a component to
+ * supporting the PNG file format in commercial products. If you use this
+ * source code in a product, acknowledgment is not required but would be
+ * appreciated.
+ */
+
+/*
+ * A "png_get_copyright" function is available, for convenient use in "about"
+ * boxes and the like:
+ *
+ * printf("%s",png_get_copyright(NULL));
+ *
+ * Also, the PNG logo (in PNG format, of course) is supplied in the
+ * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
+ */
+
+/*
+ * Libpng is OSI Certified Open Source Software. OSI Certified is a
+ * certification mark of the Open Source Initiative.
+ */
+
+/*
+ * The contributing authors would like to thank all those who helped
+ * with testing, bug fixes, and patience. This wouldn't have been
+ * possible without all of you.
+ *
+ * Thanks to Frank J. T. Wojcik for helping with the documentation.
+ */
+
+/*
+ * Y2K compliance in libpng:
+ * =========================
+ *
+ * September 23, 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.4 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.c: 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 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
+ */
+
+#ifndef PNG_H
+#define PNG_H
+
+/* This is not the place to learn how to use libpng. The file libpng.txt
+ * describes how to use libpng, and the file example.c summarizes it
+ * with some code on which to build. This file is useful for looking
+ * at the actual function definitions and structure components.
+ */
+
+/* Version information for png.h - this should match the version in png.c */
+#define PNG_LIBPNG_VER_STRING "1.4.4"
+#define PNG_HEADER_VERSION_STRING \
+ " libpng version 1.4.4 - September 23, 2010\n"
+
+#define PNG_LIBPNG_VER_SONUM 14
+#define PNG_LIBPNG_VER_DLLNUM 14
+
+/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
+#define PNG_LIBPNG_VER_MAJOR 1
+#define PNG_LIBPNG_VER_MINOR 4
+#define PNG_LIBPNG_VER_RELEASE 4
+/* This should match the numeric part of the final component of
+ * PNG_LIBPNG_VER_STRING, omitting any leading zero:
+ */
+
+#define PNG_LIBPNG_VER_BUILD 0
+
+/* Release Status */
+#define PNG_LIBPNG_BUILD_ALPHA 1
+#define PNG_LIBPNG_BUILD_BETA 2
+#define PNG_LIBPNG_BUILD_RC 3
+#define PNG_LIBPNG_BUILD_STABLE 4
+#define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7
+
+/* Release-Specific Flags */
+#define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with
+ PNG_LIBPNG_BUILD_STABLE only */
+#define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with
+ PNG_LIBPNG_BUILD_SPECIAL */
+#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
+
+/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
+ * We must not include leading zeros.
+ * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
+ * 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 10404 /* 1.4.4 */
+
+#ifndef PNG_VERSION_INFO_ONLY
+/* Include the compression library's header */
+#include "zlib.h"
+#endif
+
+/* Include all user configurable info, including optional assembler routines */
+#include "pngconf.h"
+
+/*
+ * Added at libpng-1.2.8
+ *
+ * Ref MSDN: Private as priority over Special
+ * VS_FF_PRIVATEBUILD File *was not* built using standard release
+ * procedures. If this value is given, the StringFileInfo block must
+ * contain a PrivateBuild string.
+ *
+ * VS_FF_SPECIALBUILD File *was* built by the original company using
+ * standard release procedures but is a variation of the standard
+ * file of the same version number. If this value is given, the
+ * StringFileInfo block must contain a SpecialBuild string.
+ */
+
+#ifdef PNG_USER_PRIVATEBUILD
+# define PNG_LIBPNG_BUILD_TYPE \
+ (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE)
+#else
+# ifdef PNG_LIBPNG_SPECIALBUILD
+# define PNG_LIBPNG_BUILD_TYPE \
+ (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL)
+# else
+# define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE)
+# endif
+#endif
+
+#ifndef PNG_VERSION_INFO_ONLY
+
+/* Inhibit C++ name-mangling for libpng functions but not for system calls. */
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* This file is arranged in several sections. The first section contains
+ * structure and type definitions. The second section contains the external
+ * library functions, while the third has the internal library functions,
+ * which applications aren't expected to use directly.
+ */
+
+/* Variables declared in png.c - only it needs to define PNG_NO_EXTERN */
+#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
+/* Version information for C files, stored in png.c. This had better match
+ * the version above.
+ */
+#define png_libpng_ver png_get_header_ver(NULL)
+
+#endif /* PNG_NO_EXTERN */
+
+/* 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
+ * be png_byte or png_uint_16 (as defined below).
+ */
+typedef struct png_color_struct
+{
+ png_byte red;
+ png_byte green;
+ png_byte blue;
+} png_color;
+typedef png_color FAR * png_colorp;
+typedef png_color FAR * FAR * png_colorpp;
+
+typedef struct png_color_16_struct
+{
+ png_byte index; /* used for palette files */
+ png_uint_16 red; /* for use in red green blue files */
+ png_uint_16 green;
+ png_uint_16 blue;
+ png_uint_16 gray; /* for use in grayscale files */
+} png_color_16;
+typedef png_color_16 FAR * png_color_16p;
+typedef png_color_16 FAR * FAR * png_color_16pp;
+
+typedef struct png_color_8_struct
+{
+ png_byte red; /* for use in red green blue files */
+ png_byte green;
+ png_byte blue;
+ png_byte gray; /* for use in grayscale files */
+ png_byte alpha; /* for alpha channel files */
+} png_color_8;
+typedef png_color_8 FAR * png_color_8p;
+typedef png_color_8 FAR * FAR * png_color_8pp;
+
+/*
+ * The following two structures are used for the in-core representation
+ * of sPLT chunks.
+ */
+typedef struct png_sPLT_entry_struct
+{
+ png_uint_16 red;
+ png_uint_16 green;
+ png_uint_16 blue;
+ png_uint_16 alpha;
+ png_uint_16 frequency;
+} png_sPLT_entry;
+typedef png_sPLT_entry FAR * png_sPLT_entryp;
+typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp;
+
+/* When the depth of the sPLT palette is 8 bits, the color and alpha samples
+ * occupy the LSB of their respective members, and the MSB of each member
+ * is zero-filled. The frequency member always occupies the full 16 bits.
+ */
+
+typedef struct png_sPLT_struct
+{
+ png_charp name; /* palette name */
+ png_byte depth; /* depth of palette samples */
+ png_sPLT_entryp entries; /* palette entries */
+ png_int_32 nentries; /* number of palette entries */
+} png_sPLT_t;
+typedef png_sPLT_t FAR * png_sPLT_tp;
+typedef png_sPLT_t FAR * FAR * png_sPLT_tpp;
+
+#ifdef PNG_TEXT_SUPPORTED
+/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file,
+ * and whether that contents is compressed or not. The "key" field
+ * points to a regular zero-terminated C string. The "text", "lang", and
+ * "lang_key" fields can be regular C strings, empty strings, or NULL pointers.
+ * However, the * structure returned by png_get_text() will always contain
+ * regular zero-terminated C strings (possibly empty), never NULL pointers,
+ * so they can be safely used in printf() and other string-handling functions.
+ */
+typedef struct png_text_struct
+{
+ int compression; /* compression value:
+ -1: tEXt, none
+ 0: zTXt, deflate
+ 1: iTXt, none
+ 2: iTXt, deflate */
+ png_charp key; /* keyword, 1-79 character description of "text" */
+ png_charp text; /* comment, may be an empty string (ie "")
+ or a NULL pointer */
+ png_size_t text_length; /* length of the text string */
+#ifdef PNG_iTXt_SUPPORTED
+ png_size_t itxt_length; /* length of the itxt string */
+ png_charp lang; /* language code, 0-79 characters
+ or a NULL pointer */
+ png_charp lang_key; /* keyword translated UTF-8 string, 0 or more
+ chars or a NULL pointer */
+#endif
+} png_text;
+typedef png_text FAR * png_textp;
+typedef png_text FAR * FAR * png_textpp;
+#endif
+
+/* Supported compression types for text in PNG files (tEXt, and zTXt).
+ * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */
+#define PNG_TEXT_COMPRESSION_NONE_WR -3
+#define PNG_TEXT_COMPRESSION_zTXt_WR -2
+#define PNG_TEXT_COMPRESSION_NONE -1
+#define PNG_TEXT_COMPRESSION_zTXt 0
+#define PNG_ITXT_COMPRESSION_NONE 1
+#define PNG_ITXT_COMPRESSION_zTXt 2
+#define PNG_TEXT_COMPRESSION_LAST 3 /* Not a valid value */
+
+/* png_time is a way to hold the time in an machine independent way.
+ * Two conversions are provided, both from time_t and struct tm. There
+ * is no portable way to convert to either of these structures, as far
+ * as I know. If you know of a portable way, send it to me. As a side
+ * note - PNG has always been Year 2000 compliant!
+ */
+typedef struct png_time_struct
+{
+ png_uint_16 year; /* full year, as in, 1995 */
+ png_byte month; /* month of year, 1 - 12 */
+ png_byte day; /* day of month, 1 - 31 */
+ png_byte hour; /* hour of day, 0 - 23 */
+ png_byte minute; /* minute of hour, 0 - 59 */
+ png_byte second; /* second of minute, 0 - 60 (for leap seconds) */
+} png_time;
+typedef png_time FAR * png_timep;
+typedef png_time FAR * FAR * png_timepp;
+
+#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \
+ defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
+/* png_unknown_chunk is a structure to hold queued chunks for which there is
+ * no specific support. The idea is that we can use this to queue
+ * up private chunks for output even though the library doesn't actually
+ * know about their semantics.
+ */
+typedef struct png_unknown_chunk_t
+{
+ png_byte name[5];
+ png_byte *data;
+ png_size_t size;
+
+ /* libpng-using applications should NOT directly modify this byte. */
+ png_byte location; /* mode of operation at read time */
+}
+png_unknown_chunk;
+typedef png_unknown_chunk FAR * png_unknown_chunkp;
+typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp;
+#endif
+
+/* png_info is a structure that holds the information in a PNG file so
+ * that the application can find out the characteristics of the image.
+ * If you are reading the file, this structure will tell you what is
+ * in the PNG file. If you are writing the file, fill in the information
+ * you want to put into the PNG file, then call png_write_info().
+ * The names chosen should be very close to the PNG specification, so
+ * consult that document for information about the meaning of each field.
+ *
+ * With libpng < 0.95, it was only possible to directly set and read the
+ * the values in the png_info_struct, which meant that the contents and
+ * order of the values had to remain fixed. With libpng 0.95 and later,
+ * however, there are now functions that abstract the contents of
+ * png_info_struct from the application, so this makes it easier to use
+ * libpng with dynamic libraries, and even makes it possible to use
+ * libraries that don't have all of the libpng ancillary chunk-handing
+ * functionality.
+ *
+ * In any case, the order of the parameters in png_info_struct should NOT
+ * be changed for as long as possible to keep compatibility with applications
+ * that use the old direct-access method with png_info_struct.
+ *
+ * The following members may have allocated storage attached that should be
+ * cleaned up before the structure is discarded: palette, trans, text,
+ * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,
+ * splt_palettes, scal_unit, row_pointers, and unknowns. By default, these
+ * are automatically freed when the info structure is deallocated, if they were
+ * allocated internally by libpng. This behavior can be changed by means
+ * of the png_data_freer() function.
+ *
+ * More allocation details: all the chunk-reading functions that
+ * change these members go through the corresponding png_set_*
+ * functions. A function to clear these members is available: see
+ * png_free_data(). The png_set_* functions do not depend on being
+ * able to point info structure members to any of the storage they are
+ * passed (they make their own copies), EXCEPT that the png_set_text
+ * functions use the same storage passed to them in the text_ptr or
+ * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns
+ * functions do not make their own copies.
+ */
+typedef struct png_info_struct
+{
+ /* the following are necessary for every PNG file */
+ png_uint_32 width PNG_DEPSTRUCT; /* width of image in pixels (from IHDR) */
+ png_uint_32 height PNG_DEPSTRUCT; /* height of image in pixels (from IHDR) */
+ png_uint_32 valid PNG_DEPSTRUCT; /* valid chunk data (see PNG_INFO_
+ below) */
+ png_size_t rowbytes PNG_DEPSTRUCT; /* bytes needed to hold an untransformed
+ row */
+ png_colorp palette PNG_DEPSTRUCT; /* array of color values
+ (valid & PNG_INFO_PLTE) */
+ png_uint_16 num_palette PNG_DEPSTRUCT; /* number of color entries in
+ "palette" (PLTE) */
+ png_uint_16 num_trans PNG_DEPSTRUCT; /* number of transparent palette
+ color (tRNS) */
+ png_byte bit_depth PNG_DEPSTRUCT; /* 1, 2, 4, 8, or 16 bits/channel
+ (from IHDR) */
+ png_byte color_type PNG_DEPSTRUCT; /* see PNG_COLOR_TYPE_ below
+ (from IHDR) */
+ /* The following three should have been named *_method not *_type */
+ png_byte compression_type PNG_DEPSTRUCT; /* must be
+ PNG_COMPRESSION_TYPE_BASE (IHDR) */
+ png_byte filter_type PNG_DEPSTRUCT; /* must be PNG_FILTER_TYPE_BASE
+ (from IHDR) */
+ png_byte interlace_type PNG_DEPSTRUCT; /* One of PNG_INTERLACE_NONE,
+ PNG_INTERLACE_ADAM7 */
+
+ /* The following is informational only on read, and not used on writes. */
+ png_byte channels PNG_DEPSTRUCT; /* number of data channels per
+ pixel (1, 2, 3, 4) */
+ png_byte pixel_depth PNG_DEPSTRUCT; /* number of bits per pixel */
+ png_byte spare_byte PNG_DEPSTRUCT; /* to align the data, and for
+ future use */
+ png_byte signature[8] PNG_DEPSTRUCT; /* magic bytes read by libpng
+ from start of file */
+
+ /* The rest of the data is optional. If you are reading, check the
+ * valid field to see if the information in these are valid. If you
+ * are writing, set the valid field to those chunks you want written,
+ * and initialize the appropriate fields below.
+ */
+
+#if defined(PNG_gAMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
+ /* The gAMA chunk describes the gamma characteristics of the system
+ * on which the image was created, normally in the range [1.0, 2.5].
+ * Data is valid if (valid & PNG_INFO_gAMA) is non-zero.
+ */
+ float gamma PNG_DEPSTRUCT; /* gamma value of image,
+ if (valid & PNG_INFO_gAMA) */
+#endif
+
+#ifdef PNG_sRGB_SUPPORTED
+ /* GR-P, 0.96a */
+ /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */
+ png_byte srgb_intent PNG_DEPSTRUCT; /* sRGB rendering intent
+ [0, 1, 2, or 3] */
+#endif
+
+#ifdef PNG_TEXT_SUPPORTED
+ /* The tEXt, and zTXt chunks contain human-readable textual data in
+ * uncompressed, compressed, and optionally compressed forms, respectively.
+ * The data in "text" is an array of pointers to uncompressed,
+ * null-terminated C strings. Each chunk has a keyword that describes the
+ * textual data contained in that chunk. Keywords are not required to be
+ * unique, and the text string may be empty. Any number of text chunks may
+ * be in an image.
+ */
+ int num_text PNG_DEPSTRUCT; /* number of comments read/to write */
+ int max_text PNG_DEPSTRUCT; /* current size of text array */
+ png_textp text PNG_DEPSTRUCT; /* array of comments read/to write */
+#endif /* PNG_TEXT_SUPPORTED */
+
+#ifdef PNG_tIME_SUPPORTED
+ /* The tIME chunk holds the last time the displayed image data was
+ * modified. See the png_time struct for the contents of this struct.
+ */
+ png_time mod_time PNG_DEPSTRUCT;
+#endif
+
+#ifdef PNG_sBIT_SUPPORTED
+ /* The sBIT chunk specifies the number of significant high-order bits
+ * in the pixel data. Values are in the range [1, bit_depth], and are
+ * only specified for the channels in the pixel data. The contents of
+ * the low-order bits is not specified. Data is valid if
+ * (valid & PNG_INFO_sBIT) is non-zero.
+ */
+ png_color_8 sig_bit PNG_DEPSTRUCT; /* significant bits in color channels */
+#endif
+
+#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \
+defined(PNG_READ_BACKGROUND_SUPPORTED)
+ /* The tRNS chunk supplies transparency data for paletted images and
+ * other image types that don't need a full alpha channel. There are
+ * "num_trans" transparency values for a paletted image, stored in the
+ * same order as the palette colors, starting from index 0. Values
+ * for the data are in the range [0, 255], ranging from fully transparent
+ * to fully opaque, respectively. For non-paletted images, there is a
+ * single color specified that should be treated as fully transparent.
+ * Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
+ */
+ png_bytep trans_alpha PNG_DEPSTRUCT; /* alpha values for paletted
+ image */
+ png_color_16 trans_color PNG_DEPSTRUCT; /* transparent color for
+ non-palette image */
+#endif
+
+#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
+ /* The bKGD chunk gives the suggested image background color if the
+ * display program does not have its own background color and the image
+ * is needs to composited onto a background before display. The colors
+ * in "background" are normally in the same color space/depth as the
+ * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero.
+ */
+ png_color_16 background PNG_DEPSTRUCT;
+#endif
+
+#ifdef PNG_oFFs_SUPPORTED
+ /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards
+ * and downwards from the top-left corner of the display, page, or other
+ * application-specific co-ordinate space. See the PNG_OFFSET_ defines
+ * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero.
+ */
+ png_int_32 x_offset PNG_DEPSTRUCT; /* x offset on page */
+ png_int_32 y_offset PNG_DEPSTRUCT; /* y offset on page */
+ png_byte offset_unit_type PNG_DEPSTRUCT; /* offset units type */
+#endif
+
+#ifdef PNG_pHYs_SUPPORTED
+ /* The pHYs chunk gives the physical pixel density of the image for
+ * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_
+ * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero.
+ */
+ png_uint_32 x_pixels_per_unit PNG_DEPSTRUCT; /* horizontal pixel density */
+ png_uint_32 y_pixels_per_unit PNG_DEPSTRUCT; /* vertical pixel density */
+ png_byte phys_unit_type PNG_DEPSTRUCT; /* resolution type (see
+ PNG_RESOLUTION_ below) */
+#endif
+
+#ifdef PNG_hIST_SUPPORTED
+ /* The hIST chunk contains the relative frequency or importance of the
+ * various palette entries, so that a viewer can intelligently select a
+ * reduced-color palette, if required. Data is an array of "num_palette"
+ * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)
+ * is non-zero.
+ */
+ png_uint_16p hist PNG_DEPSTRUCT;
+#endif
+
+#ifdef PNG_cHRM_SUPPORTED
+ /* The cHRM chunk describes the CIE color characteristics of the monitor
+ * on which the PNG was created. This data allows the viewer to do gamut
+ * mapping of the input image to ensure that the viewer sees the same
+ * colors in the image as the creator. Values are in the range
+ * [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero.
+ */
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+ float x_white PNG_DEPSTRUCT;
+ float y_white PNG_DEPSTRUCT;
+ float x_red PNG_DEPSTRUCT;
+ float y_red PNG_DEPSTRUCT;
+ float x_green PNG_DEPSTRUCT;
+ float y_green PNG_DEPSTRUCT;
+ float x_blue PNG_DEPSTRUCT;
+ float y_blue PNG_DEPSTRUCT;
+#endif
+#endif
+
+#ifdef PNG_pCAL_SUPPORTED
+ /* The pCAL chunk describes a transformation between the stored pixel
+ * values and original physical data values used to create the image.
+ * The integer range [0, 2^bit_depth - 1] maps to the floating-point
+ * range given by [pcal_X0, pcal_X1], and are further transformed by a
+ * (possibly non-linear) transformation function given by "pcal_type"
+ * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_
+ * defines below, and the PNG-Group's PNG extensions document for a
+ * complete description of the transformations and how they should be
+ * implemented, and for a description of the ASCII parameter strings.
+ * Data values are valid if (valid & PNG_INFO_pCAL) non-zero.
+ */
+ png_charp pcal_purpose PNG_DEPSTRUCT; /* pCAL chunk description string */
+ png_int_32 pcal_X0 PNG_DEPSTRUCT; /* minimum value */
+ png_int_32 pcal_X1 PNG_DEPSTRUCT; /* maximum value */
+ png_charp pcal_units PNG_DEPSTRUCT; /* Latin-1 string giving physical
+ units */
+ png_charpp pcal_params PNG_DEPSTRUCT; /* ASCII strings containing
+ parameter values */
+ png_byte pcal_type PNG_DEPSTRUCT; /* equation type
+ (see PNG_EQUATION_ below) */
+ png_byte pcal_nparams PNG_DEPSTRUCT; /* number of parameters given
+ in pcal_params */
+#endif
+
+/* New members added in libpng-1.0.6 */
+ png_uint_32 free_me PNG_DEPSTRUCT; /* flags items libpng is
+ responsible for freeing */
+
+#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \
+ defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
+ /* Storage for unknown chunks that the library doesn't recognize. */
+ png_unknown_chunkp unknown_chunks PNG_DEPSTRUCT;
+ png_size_t unknown_chunks_num PNG_DEPSTRUCT;
+#endif
+
+#ifdef PNG_iCCP_SUPPORTED
+ /* iCCP chunk data. */
+ png_charp iccp_name PNG_DEPSTRUCT; /* profile name */
+ png_charp iccp_profile PNG_DEPSTRUCT; /* International Color Consortium
+ profile data */
+ /* Note to maintainer: should be png_bytep */
+ png_uint_32 iccp_proflen PNG_DEPSTRUCT; /* ICC profile data length */
+ png_byte iccp_compression PNG_DEPSTRUCT; /* Always zero */
+#endif
+
+#ifdef PNG_sPLT_SUPPORTED
+ /* Data on sPLT chunks (there may be more than one). */
+ png_sPLT_tp splt_palettes PNG_DEPSTRUCT;
+ png_uint_32 splt_palettes_num PNG_DEPSTRUCT;
+#endif
+
+#ifdef PNG_sCAL_SUPPORTED
+ /* The sCAL chunk describes the actual physical dimensions of the
+ * subject matter of the graphic. The chunk contains a unit specification
+ * a byte value, and two ASCII strings representing floating-point
+ * values. The values are width and height corresponsing to one pixel
+ * in the image. This external representation is converted to double
+ * here. Data values are valid if (valid & PNG_INFO_sCAL) is non-zero.
+ */
+ png_byte scal_unit PNG_DEPSTRUCT; /* unit of physical scale */
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+ double scal_pixel_width PNG_DEPSTRUCT; /* width of one pixel */
+ double scal_pixel_height PNG_DEPSTRUCT; /* height of one pixel */
+#endif
+#ifdef PNG_FIXED_POINT_SUPPORTED
+ png_charp scal_s_width PNG_DEPSTRUCT; /* string containing height */
+ png_charp scal_s_height PNG_DEPSTRUCT; /* string containing width */
+#endif
+#endif
+
+#ifdef PNG_INFO_IMAGE_SUPPORTED
+ /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS)
+ non-zero */
+ /* Data valid if (valid & PNG_INFO_IDAT) non-zero */
+ png_bytepp row_pointers PNG_DEPSTRUCT; /* the image bits */
+#endif
+
+#if defined(PNG_FIXED_POINT_SUPPORTED) && defined(PNG_gAMA_SUPPORTED)
+ png_fixed_point int_gamma PNG_DEPSTRUCT; /* gamma of image,
+ if (valid & PNG_INFO_gAMA) */
+#endif
+
+#if defined(PNG_cHRM_SUPPORTED) && defined(PNG_FIXED_POINT_SUPPORTED)
+ png_fixed_point int_x_white PNG_DEPSTRUCT;
+ png_fixed_point int_y_white PNG_DEPSTRUCT;
+ png_fixed_point int_x_red PNG_DEPSTRUCT;
+ png_fixed_point int_y_red PNG_DEPSTRUCT;
+ png_fixed_point int_x_green PNG_DEPSTRUCT;
+ png_fixed_point int_y_green PNG_DEPSTRUCT;
+ png_fixed_point int_x_blue PNG_DEPSTRUCT;
+ png_fixed_point int_y_blue PNG_DEPSTRUCT;
+#endif
+
+} png_info;
+
+typedef png_info FAR * png_infop;
+typedef png_info FAR * FAR * png_infopp;
+
+/* Maximum positive integer used in PNG is (2^31)-1 */
+#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL)
+#define PNG_UINT_32_MAX ((png_uint_32)(-1))
+#define PNG_SIZE_MAX ((png_size_t)(-1))
+
+/* These describe the color_type field in png_info. */
+/* color type masks */
+#define PNG_COLOR_MASK_PALETTE 1
+#define PNG_COLOR_MASK_COLOR 2
+#define PNG_COLOR_MASK_ALPHA 4
+
+/* color types. Note that not all combinations are legal */
+#define PNG_COLOR_TYPE_GRAY 0
+#define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
+#define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR)
+#define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
+#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
+/* aliases */
+#define PNG_COLOR_TYPE_RGBA PNG_COLOR_TYPE_RGB_ALPHA
+#define PNG_COLOR_TYPE_GA PNG_COLOR_TYPE_GRAY_ALPHA
+
+/* This is for compression type. PNG 1.0-1.2 only define the single type. */
+#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */
+#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE
+
+/* This is for filter type. PNG 1.0-1.2 only define the single type. */
+#define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */
+#define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */
+#define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE
+
+/* These are for the interlacing type. These values should NOT be changed. */
+#define PNG_INTERLACE_NONE 0 /* Non-interlaced image */
+#define PNG_INTERLACE_ADAM7 1 /* Adam7 interlacing */
+#define PNG_INTERLACE_LAST 2 /* Not a valid value */
+
+/* These are for the oFFs chunk. These values should NOT be changed. */
+#define PNG_OFFSET_PIXEL 0 /* Offset in pixels */
+#define PNG_OFFSET_MICROMETER 1 /* Offset in micrometers (1/10^6 meter) */
+#define PNG_OFFSET_LAST 2 /* Not a valid value */
+
+/* These are for the pCAL chunk. These values should NOT be changed. */
+#define PNG_EQUATION_LINEAR 0 /* Linear transformation */
+#define PNG_EQUATION_BASE_E 1 /* Exponential base e transform */
+#define PNG_EQUATION_ARBITRARY 2 /* Arbitrary base exponential transform */
+#define PNG_EQUATION_HYPERBOLIC 3 /* Hyperbolic sine transformation */
+#define PNG_EQUATION_LAST 4 /* Not a valid value */
+
+/* These are for the sCAL chunk. These values should NOT be changed. */
+#define PNG_SCALE_UNKNOWN 0 /* unknown unit (image scale) */
+#define PNG_SCALE_METER 1 /* meters per pixel */
+#define PNG_SCALE_RADIAN 2 /* radians per pixel */
+#define PNG_SCALE_LAST 3 /* Not a valid value */
+
+/* These are for the pHYs chunk. These values should NOT be changed. */
+#define PNG_RESOLUTION_UNKNOWN 0 /* pixels/unknown unit (aspect ratio) */
+#define PNG_RESOLUTION_METER 1 /* pixels/meter */
+#define PNG_RESOLUTION_LAST 2 /* Not a valid value */
+
+/* These are for the sRGB chunk. These values should NOT be changed. */
+#define PNG_sRGB_INTENT_PERCEPTUAL 0
+#define PNG_sRGB_INTENT_RELATIVE 1
+#define PNG_sRGB_INTENT_SATURATION 2
+#define PNG_sRGB_INTENT_ABSOLUTE 3
+#define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */
+
+/* This is for text chunks */
+#define PNG_KEYWORD_MAX_LENGTH 79
+
+/* Maximum number of entries in PLTE/sPLT/tRNS arrays */
+#define PNG_MAX_PALETTE_LENGTH 256
+
+/* These determine if an ancillary chunk's data has been successfully read
+ * from the PNG header, or if the application has filled in the corresponding
+ * data in the info_struct to be written into the output file. The values
+ * of the PNG_INFO_<chunk> defines should NOT be changed.
+ */
+#define PNG_INFO_gAMA 0x0001
+#define PNG_INFO_sBIT 0x0002
+#define PNG_INFO_cHRM 0x0004
+#define PNG_INFO_PLTE 0x0008
+#define PNG_INFO_tRNS 0x0010
+#define PNG_INFO_bKGD 0x0020
+#define PNG_INFO_hIST 0x0040
+#define PNG_INFO_pHYs 0x0080
+#define PNG_INFO_oFFs 0x0100
+#define PNG_INFO_tIME 0x0200
+#define PNG_INFO_pCAL 0x0400
+#define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */
+#define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */
+#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */
+#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */
+#define PNG_INFO_IDAT 0x8000L /* ESR, 1.0.6 */
+
+/* This is used for the transformation routines, as some of them
+ * change these values for the row. It also should enable using
+ * the routines for other purposes.
+ */
+typedef struct png_row_info_struct
+{
+ png_uint_32 width; /* width of row */
+ png_size_t rowbytes; /* number of bytes in row */
+ png_byte color_type; /* color type of row */
+ png_byte bit_depth; /* bit depth of row */
+ png_byte channels; /* number of channels (1, 2, 3, or 4) */
+ png_byte pixel_depth; /* bits per pixel (depth * channels) */
+} png_row_info;
+
+typedef png_row_info FAR * png_row_infop;
+typedef png_row_info FAR * FAR * png_row_infopp;
+
+/* These are the function types for the I/O functions and for the functions
+ * that allow the user to override the default I/O functions with his or her
+ * own. The png_error_ptr type should match that of user-supplied warning
+ * and error functions, while the png_rw_ptr type should match that of the
+ * user read/write data functions.
+ */
+typedef struct png_struct_def png_struct;
+typedef png_struct FAR * png_structp;
+
+typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp));
+typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t));
+typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp));
+typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32,
+ int));
+typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32,
+ int));
+
+#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
+typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp,
+ png_infop));
+typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop));
+typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep,
+ png_uint_32, int));
+#endif
+
+#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
+ defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
+typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp,
+ png_row_infop, png_bytep));
+#endif
+
+#ifdef PNG_USER_CHUNKS_SUPPORTED
+typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp,
+ png_unknown_chunkp));
+#endif
+#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
+typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp));
+#endif
+#ifdef PNG_SETJMP_SUPPORTED
+/* This must match the function definition in <setjmp.h>, and the
+ * application must include this before png.h to obtain the definition
+ * of jmp_buf.
+ */
+typedef void (PNGAPI *png_longjmp_ptr) PNGARG((jmp_buf, int));
+#endif
+
+/* Transform masks for the high-level interface */
+#define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */
+#define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */
+#define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */
+#define PNG_TRANSFORM_PACKING 0x0004 /* read and write */
+#define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */
+#define PNG_TRANSFORM_EXPAND 0x0010 /* read only */
+#define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */
+#define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */
+#define PNG_TRANSFORM_BGR 0x0080 /* read and write */
+#define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */
+#define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */
+#define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */
+#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* write only */
+/* Added to libpng-1.2.34 */
+#define PNG_TRANSFORM_STRIP_FILLER_BEFORE PNG_TRANSFORM_STRIP_FILLER
+#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */
+/* Added to libpng-1.4.0 */
+#define PNG_TRANSFORM_GRAY_TO_RGB 0x2000 /* read only */
+
+/* Flags for MNG supported features */
+#define PNG_FLAG_MNG_EMPTY_PLTE 0x01
+#define PNG_FLAG_MNG_FILTER_64 0x04
+#define PNG_ALL_MNG_FEATURES 0x05
+
+typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_alloc_size_t));
+typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp));
+
+/* The structure that holds the information to read and write PNG files.
+ * The only people who need to care about what is inside of this are the
+ * people who will be modifying the library for their own special needs.
+ * It should NOT be accessed directly by an application, except to store
+ * the jmp_buf.
+ */
+
+struct png_struct_def
+{
+#ifdef PNG_SETJMP_SUPPORTED
+ jmp_buf jmpbuf PNG_DEPSTRUCT; /* used in png_error */
+ png_longjmp_ptr longjmp_fn PNG_DEPSTRUCT;/* setjmp non-local goto
+ function. */
+#endif
+ png_error_ptr error_fn PNG_DEPSTRUCT; /* function for printing
+ errors and aborting */
+ png_error_ptr warning_fn PNG_DEPSTRUCT; /* function for printing
+ warnings */
+ png_voidp error_ptr PNG_DEPSTRUCT; /* user supplied struct for
+ error functions */
+ png_rw_ptr write_data_fn PNG_DEPSTRUCT; /* function for writing
+ output data */
+ png_rw_ptr read_data_fn PNG_DEPSTRUCT; /* function for reading
+ input data */
+ png_voidp io_ptr PNG_DEPSTRUCT; /* ptr to application struct
+ for I/O functions */
+
+#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
+ png_user_transform_ptr read_user_transform_fn PNG_DEPSTRUCT; /* user read
+ transform */
+#endif
+
+#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
+ png_user_transform_ptr write_user_transform_fn PNG_DEPSTRUCT; /* user write
+ transform */
+#endif
+
+/* These were added in libpng-1.0.2 */
+#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
+#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
+ defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
+ png_voidp user_transform_ptr PNG_DEPSTRUCT; /* user supplied struct
+ for user transform */
+ png_byte user_transform_depth PNG_DEPSTRUCT; /* bit depth of user
+ transformed pixels */
+ png_byte user_transform_channels PNG_DEPSTRUCT; /* channels in user
+ transformed pixels */
+#endif
+#endif
+
+ png_uint_32 mode PNG_DEPSTRUCT; /* tells us where we are in
+ the PNG file */
+ png_uint_32 flags PNG_DEPSTRUCT; /* flags indicating various
+ things to libpng */
+ png_uint_32 transformations PNG_DEPSTRUCT; /* which transformations
+ to perform */
+
+ z_stream zstream PNG_DEPSTRUCT; /* pointer to decompression
+ structure (below) */
+ png_bytep zbuf PNG_DEPSTRUCT; /* buffer for zlib */
+ png_size_t zbuf_size PNG_DEPSTRUCT; /* size of zbuf */
+ int zlib_level PNG_DEPSTRUCT; /* holds zlib compression level */
+ int zlib_method PNG_DEPSTRUCT; /* holds zlib compression method */
+ int zlib_window_bits PNG_DEPSTRUCT; /* holds zlib compression window
+ bits */
+ int zlib_mem_level PNG_DEPSTRUCT; /* holds zlib compression memory
+ level */
+ int zlib_strategy PNG_DEPSTRUCT; /* holds zlib compression
+ strategy */
+
+ png_uint_32 width PNG_DEPSTRUCT; /* width of image in pixels */
+ png_uint_32 height PNG_DEPSTRUCT; /* height of image in pixels */
+ png_uint_32 num_rows PNG_DEPSTRUCT; /* number of rows in current pass */
+ png_uint_32 usr_width PNG_DEPSTRUCT; /* width of row at start of write */
+ png_size_t rowbytes PNG_DEPSTRUCT; /* size of row in bytes */
+#if 0 /* Replaced with the following in libpng-1.4.1 */
+ png_size_t irowbytes PNG_DEPSTRUCT;
+#endif
+/* Added in libpng-1.4.1 */
+#ifdef PNG_USER_LIMITS_SUPPORTED
+ /* Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk
+ * can occupy when decompressed. 0 means unlimited.
+ * We will change the typedef from png_size_t to png_alloc_size_t
+ * in libpng-1.6.0
+ */
+ png_alloc_size_t user_chunk_malloc_max PNG_DEPSTRUCT;
+#endif
+ png_uint_32 iwidth PNG_DEPSTRUCT; /* width of current interlaced
+ row in pixels */
+ png_uint_32 row_number PNG_DEPSTRUCT; /* current row in interlace pass */
+ png_bytep prev_row PNG_DEPSTRUCT; /* buffer to save previous
+ (unfiltered) row */
+ png_bytep row_buf PNG_DEPSTRUCT; /* buffer to save current
+ (unfiltered) row */
+ png_bytep sub_row PNG_DEPSTRUCT; /* buffer to save "sub" row
+ when filtering */
+ png_bytep up_row PNG_DEPSTRUCT; /* buffer to save "up" row
+ when filtering */
+ png_bytep avg_row PNG_DEPSTRUCT; /* buffer to save "avg" row
+ when filtering */
+ png_bytep paeth_row PNG_DEPSTRUCT; /* buffer to save "Paeth" row
+ when filtering */
+ png_row_info row_info PNG_DEPSTRUCT; /* used for transformation
+ routines */
+
+ png_uint_32 idat_size PNG_DEPSTRUCT; /* current IDAT size for read */
+ png_uint_32 crc PNG_DEPSTRUCT; /* current chunk CRC value */
+ png_colorp palette PNG_DEPSTRUCT; /* palette from the input file */
+ png_uint_16 num_palette PNG_DEPSTRUCT; /* number of color entries in
+ palette */
+ png_uint_16 num_trans PNG_DEPSTRUCT; /* number of transparency values */
+ png_byte chunk_name[5] PNG_DEPSTRUCT; /* null-terminated name of current
+ chunk */
+ png_byte compression PNG_DEPSTRUCT; /* file compression type
+ (always 0) */
+ png_byte filter PNG_DEPSTRUCT; /* file filter type (always 0) */
+ png_byte interlaced PNG_DEPSTRUCT; /* PNG_INTERLACE_NONE,
+ PNG_INTERLACE_ADAM7 */
+ png_byte pass PNG_DEPSTRUCT; /* current interlace pass (0 - 6) */
+ png_byte do_filter PNG_DEPSTRUCT; /* row filter flags (see
+ PNG_FILTER_ below ) */
+ png_byte color_type PNG_DEPSTRUCT; /* color type of file */
+ png_byte bit_depth PNG_DEPSTRUCT; /* bit depth of file */
+ png_byte usr_bit_depth PNG_DEPSTRUCT; /* bit depth of users row */
+ png_byte pixel_depth PNG_DEPSTRUCT; /* number of bits per pixel */
+ png_byte channels PNG_DEPSTRUCT; /* number of channels in file */
+ png_byte usr_channels PNG_DEPSTRUCT; /* channels at start of write */
+ png_byte sig_bytes PNG_DEPSTRUCT; /* magic bytes read/written from
+ start of file */
+
+#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
+ png_uint_16 filler PNG_DEPSTRUCT; /* filler bytes for pixel
+ expansion */
+#endif
+
+#ifdef PNG_bKGD_SUPPORTED
+ png_byte background_gamma_type PNG_DEPSTRUCT;
+# ifdef PNG_FLOATING_POINT_SUPPORTED
+ float background_gamma PNG_DEPSTRUCT;
+# endif
+ png_color_16 background PNG_DEPSTRUCT; /* background color in
+ screen gamma space */
+#ifdef PNG_READ_GAMMA_SUPPORTED
+ png_color_16 background_1 PNG_DEPSTRUCT; /* background normalized
+ to gamma 1.0 */
+#endif
+#endif /* PNG_bKGD_SUPPORTED */
+
+#ifdef PNG_WRITE_FLUSH_SUPPORTED
+ png_flush_ptr output_flush_fn PNG_DEPSTRUCT; /* Function for flushing
+ output */
+ png_uint_32 flush_dist PNG_DEPSTRUCT; /* how many rows apart to flush,
+ 0 - no flush */
+ png_uint_32 flush_rows PNG_DEPSTRUCT; /* number of rows written since
+ last flush */
+#endif
+
+#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
+ int gamma_shift PNG_DEPSTRUCT; /* number of "insignificant" bits
+ 16-bit gamma */
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+ float gamma PNG_DEPSTRUCT; /* file gamma value */
+ float screen_gamma PNG_DEPSTRUCT; /* screen gamma value
+ (display_exponent) */
+#endif
+#endif
+
+#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
+ png_bytep gamma_table PNG_DEPSTRUCT; /* gamma table for 8-bit
+ depth files */
+ png_bytep gamma_from_1 PNG_DEPSTRUCT; /* converts from 1.0 to screen */
+ png_bytep gamma_to_1 PNG_DEPSTRUCT; /* converts from file to 1.0 */
+ png_uint_16pp gamma_16_table PNG_DEPSTRUCT; /* gamma table for 16-bit
+ depth files */
+ png_uint_16pp gamma_16_from_1 PNG_DEPSTRUCT; /* converts from 1.0 to
+ screen */
+ png_uint_16pp gamma_16_to_1 PNG_DEPSTRUCT; /* converts from file to 1.0 */
+#endif
+
+#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)
+ png_color_8 sig_bit PNG_DEPSTRUCT; /* significant bits in each
+ available channel */
+#endif
+
+#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
+ png_color_8 shift PNG_DEPSTRUCT; /* shift for significant bit
+ tranformation */
+#endif
+
+#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \
+ || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
+ png_bytep trans_alpha PNG_DEPSTRUCT; /* alpha values for
+ paletted files */
+ png_color_16 trans_color PNG_DEPSTRUCT; /* transparent color for
+ non-paletted files */
+#endif
+
+ png_read_status_ptr read_row_fn PNG_DEPSTRUCT; /* called after each
+ row is decoded */
+ png_write_status_ptr write_row_fn PNG_DEPSTRUCT; /* called after each
+ row is encoded */
+#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
+ png_progressive_info_ptr info_fn PNG_DEPSTRUCT; /* called after header
+ data fully read */
+ png_progressive_row_ptr row_fn PNG_DEPSTRUCT; /* called after each
+ prog. row is decoded */
+ png_progressive_end_ptr end_fn PNG_DEPSTRUCT; /* called after image
+ is complete */
+ png_bytep save_buffer_ptr PNG_DEPSTRUCT; /* current location in
+ save_buffer */
+ png_bytep save_buffer PNG_DEPSTRUCT; /* buffer for previously
+ read data */
+ png_bytep current_buffer_ptr PNG_DEPSTRUCT; /* current location in
+ current_buffer */
+ png_bytep current_buffer PNG_DEPSTRUCT; /* buffer for recently
+ used data */
+ png_uint_32 push_length PNG_DEPSTRUCT; /* size of current input
+ chunk */
+ png_uint_32 skip_length PNG_DEPSTRUCT; /* bytes to skip in
+ input data */
+ png_size_t save_buffer_size PNG_DEPSTRUCT; /* amount of data now
+ in save_buffer */
+ png_size_t save_buffer_max PNG_DEPSTRUCT; /* total size of
+ save_buffer */
+ png_size_t buffer_size PNG_DEPSTRUCT; /* total amount of
+ available input data */
+ png_size_t current_buffer_size PNG_DEPSTRUCT; /* amount of data now
+ in current_buffer */
+ int process_mode PNG_DEPSTRUCT; /* what push library
+ is currently doing */
+ int cur_palette PNG_DEPSTRUCT; /* current push library
+ palette index */
+
+# ifdef PNG_TEXT_SUPPORTED
+ png_size_t current_text_size PNG_DEPSTRUCT; /* current size of
+ text input data */
+ png_size_t current_text_left PNG_DEPSTRUCT; /* how much text left
+ to read in input */
+ png_charp current_text PNG_DEPSTRUCT; /* current text chunk
+ buffer */
+ png_charp current_text_ptr PNG_DEPSTRUCT; /* 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__)
+/* For the Borland special 64K segment handler */
+ png_bytepp offset_table_ptr PNG_DEPSTRUCT;
+ png_bytep offset_table PNG_DEPSTRUCT;
+ png_uint_16 offset_table_number PNG_DEPSTRUCT;
+ png_uint_16 offset_table_count PNG_DEPSTRUCT;
+ png_uint_16 offset_table_count_free PNG_DEPSTRUCT;
+#endif
+
+#ifdef PNG_READ_QUANTIZE_SUPPORTED
+ png_bytep palette_lookup PNG_DEPSTRUCT; /* lookup table for quantizing */
+ png_bytep quantize_index PNG_DEPSTRUCT; /* index translation for palette
+ files */
+#endif
+
+#if defined(PNG_READ_QUANTIZE_SUPPORTED) || defined(PNG_hIST_SUPPORTED)
+ png_uint_16p hist PNG_DEPSTRUCT; /* histogram */
+#endif
+
+#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
+ png_byte heuristic_method PNG_DEPSTRUCT; /* heuristic for row
+ filter selection */
+ png_byte num_prev_filters PNG_DEPSTRUCT; /* number of weights
+ for previous rows */
+ png_bytep prev_filters PNG_DEPSTRUCT; /* filter type(s) of
+ previous row(s) */
+ png_uint_16p filter_weights PNG_DEPSTRUCT; /* weight(s) for previous
+ line(s) */
+ png_uint_16p inv_filter_weights PNG_DEPSTRUCT; /* 1/weight(s) for
+ previous line(s) */
+ png_uint_16p filter_costs PNG_DEPSTRUCT; /* relative filter
+ calculation cost */
+ png_uint_16p inv_filter_costs PNG_DEPSTRUCT; /* 1/relative filter
+ calculation cost */
+#endif
+
+#ifdef PNG_TIME_RFC1123_SUPPORTED
+ png_charp time_buffer PNG_DEPSTRUCT; /* String to hold RFC 1123 time text */
+#endif
+
+/* New members added in libpng-1.0.6 */
+
+ png_uint_32 free_me PNG_DEPSTRUCT; /* flags items libpng is
+ responsible for freeing */
+
+#ifdef PNG_USER_CHUNKS_SUPPORTED
+ png_voidp user_chunk_ptr PNG_DEPSTRUCT;
+ png_user_chunk_ptr read_user_chunk_fn PNG_DEPSTRUCT; /* user read
+ chunk handler */
+#endif
+
+#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
+ int num_chunk_list PNG_DEPSTRUCT;
+ png_bytep chunk_list PNG_DEPSTRUCT;
+#endif
+
+/* New members added in libpng-1.0.3 */
+#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
+ png_byte rgb_to_gray_status PNG_DEPSTRUCT;
+ /* These were changed from png_byte in libpng-1.0.6 */
+ png_uint_16 rgb_to_gray_red_coeff PNG_DEPSTRUCT;
+ png_uint_16 rgb_to_gray_green_coeff PNG_DEPSTRUCT;
+ png_uint_16 rgb_to_gray_blue_coeff PNG_DEPSTRUCT;
+#endif
+
+/* New member added in libpng-1.0.4 (renamed in 1.0.9) */
+#if defined(PNG_MNG_FEATURES_SUPPORTED) || \
+ defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
+ defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
+/* Changed from png_byte to png_uint_32 at version 1.2.0 */
+ png_uint_32 mng_features_permitted PNG_DEPSTRUCT;
+#endif
+
+/* New member added in libpng-1.0.7 */
+#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
+ png_fixed_point int_gamma PNG_DEPSTRUCT;
+#endif
+
+/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */
+#ifdef PNG_MNG_FEATURES_SUPPORTED
+ png_byte filter_type PNG_DEPSTRUCT;
+#endif
+
+/* New members added in libpng-1.2.0 */
+
+/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */
+#ifdef PNG_USER_MEM_SUPPORTED
+ png_voidp mem_ptr PNG_DEPSTRUCT; /* user supplied struct for
+ mem functions */
+ png_malloc_ptr malloc_fn PNG_DEPSTRUCT; /* function for
+ allocating memory */
+ png_free_ptr free_fn PNG_DEPSTRUCT; /* function for
+ freeing memory */
+#endif
+
+/* New member added in libpng-1.0.13 and 1.2.0 */
+ png_bytep big_row_buf PNG_DEPSTRUCT; /* buffer to save current
+ (unfiltered) row */
+
+#ifdef PNG_READ_QUANTIZE_SUPPORTED
+/* The following three members were added at version 1.0.14 and 1.2.4 */
+ png_bytep quantize_sort PNG_DEPSTRUCT; /* working sort array */
+ png_bytep index_to_palette PNG_DEPSTRUCT; /* where the original
+ index currently is
+ in the palette */
+ png_bytep palette_to_index PNG_DEPSTRUCT; /* which original index
+ points to this
+ palette color */
+#endif
+
+/* New members added in libpng-1.0.16 and 1.2.6 */
+ png_byte compression_type PNG_DEPSTRUCT;
+
+#ifdef PNG_USER_LIMITS_SUPPORTED
+ png_uint_32 user_width_max PNG_DEPSTRUCT;
+ png_uint_32 user_height_max PNG_DEPSTRUCT;
+ /* Added in libpng-1.4.0: Total number of sPLT, text, and unknown
+ * chunks that can be stored (0 means unlimited).
+ */
+ png_uint_32 user_chunk_cache_max PNG_DEPSTRUCT;
+#endif
+
+/* New member added in libpng-1.0.25 and 1.2.17 */
+#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
+ /* Storage for unknown chunk that the library doesn't recognize. */
+ png_unknown_chunk unknown_chunk PNG_DEPSTRUCT;
+#endif
+
+/* New members added in libpng-1.2.26 */
+ png_uint_32 old_big_row_buf_size PNG_DEPSTRUCT;
+ png_uint_32 old_prev_row_size PNG_DEPSTRUCT;
+
+/* New member added in libpng-1.2.30 */
+ png_charp chunkdata PNG_DEPSTRUCT; /* buffer for reading chunk data */
+
+#ifdef PNG_IO_STATE_SUPPORTED
+/* New member added in libpng-1.4.0 */
+ png_uint_32 io_state PNG_DEPSTRUCT;
+#endif
+};
+
+
+/* This triggers a compiler error in png.c, if png.c and png.h
+ * do not agree upon the version number.
+ */
+typedef png_structp version_1_4_4;
+
+typedef png_struct FAR * FAR * png_structpp;
+
+/* Here are the function definitions most commonly used. This is not
+ * the place to find out how to use libpng. See libpng.txt for the
+ * full explanation, see example.c for the summary. This just provides
+ * a simple one line description of the use of each function.
+ */
+
+/* Returns the version number of the library */
+PNG_EXPORT(png_uint_32,png_access_version_number) PNGARG((void));
+
+/* Tell lib we have already handled the first <num_bytes> magic bytes.
+ * Handling more than 8 bytes from the beginning of the file is an error.
+ */
+PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr,
+ int num_bytes));
+
+/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a
+ * PNG file. Returns zero if the supplied bytes match the 8-byte PNG
+ * signature, and non-zero otherwise. Having num_to_check == 0 or
+ * start > 7 will always fail (ie return non-zero).
+ */
+PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start,
+ png_size_t num_to_check));
+
+/* Simple signature checking function. This is the same as calling
+ * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).
+ */
+#define png_check_sig(sig,n) !png_sig_cmp((sig), 0, (n))
+
+/* Allocate and initialize png_ptr struct for reading, and any other memory. */
+PNG_EXPORT(png_structp,png_create_read_struct)
+ PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
+ png_error_ptr error_fn, png_error_ptr warn_fn)) PNG_ALLOCATED;
+
+/* Allocate and initialize png_ptr struct for writing, and any other memory */
+PNG_EXPORT(png_structp,png_create_write_struct)
+ PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
+ png_error_ptr error_fn, png_error_ptr warn_fn)) PNG_ALLOCATED;
+
+PNG_EXPORT(png_size_t,png_get_compression_buffer_size)
+ PNGARG((png_structp png_ptr));
+
+PNG_EXPORT(void,png_set_compression_buffer_size)
+ PNGARG((png_structp png_ptr, png_size_t size));
+
+/* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp
+ * match up.
+ */
+#ifdef PNG_SETJMP_SUPPORTED
+/* This function returns the jmp_buf built in to *png_ptr. It must be
+ * supplied with an appropriate 'longjmp' function to use on that jmp_buf
+ * unless the default error function is overridden in which case NULL is
+ * acceptable. The size of the jmp_buf is checked against the actual size
+ * allocated by the library - the call will return NULL on a mismatch
+ * indicating an ABI mismatch.
+ */
+PNG_EXPORT(jmp_buf*, png_set_longjmp_fn)
+ PNGARG((png_structp png_ptr, png_longjmp_ptr longjmp_fn, size_t
+ jmp_buf_size));
+# define png_jmpbuf(png_ptr) \
+ (*png_set_longjmp_fn((png_ptr), longjmp, sizeof (jmp_buf)))
+#else
+# define png_jmpbuf(png_ptr) \
+ (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP)
+#endif
+
+#ifdef PNG_READ_SUPPORTED
+/* Reset the compression stream */
+PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr));
+#endif
+
+/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */
+#ifdef PNG_USER_MEM_SUPPORTED
+PNG_EXPORT(png_structp,png_create_read_struct_2)
+ PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
+ png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
+ png_malloc_ptr malloc_fn, png_free_ptr free_fn)) PNG_ALLOCATED;
+PNG_EXPORT(png_structp,png_create_write_struct_2)
+ PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
+ png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
+ png_malloc_ptr malloc_fn, png_free_ptr free_fn)) PNG_ALLOCATED;
+#endif
+
+/* Write the PNG file signature. */
+PNG_EXPORT(void,png_write_sig) PNGARG((png_structp png_ptr));
+
+/* Write a PNG chunk - size, type, (optional) data, CRC. */
+PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr,
+ png_bytep chunk_name, png_bytep data, png_size_t length));
+
+/* Write the start of a PNG chunk - length and chunk name. */
+PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr,
+ png_bytep chunk_name, png_uint_32 length));
+
+/* Write the data of a PNG chunk started with png_write_chunk_start(). */
+PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr,
+ png_bytep data, png_size_t length));
+
+/* Finish a chunk started with png_write_chunk_start() (includes CRC). */
+PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr));
+
+/* Allocate and initialize the info structure */
+PNG_EXPORT(png_infop,png_create_info_struct)
+ PNGARG((png_structp png_ptr)) PNG_ALLOCATED;
+
+PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr,
+ png_size_t png_info_struct_size));
+
+/* Writes all the PNG information before the image. */
+PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr,
+ png_infop info_ptr));
+PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr,
+ png_infop info_ptr));
+
+#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
+/* Read the information before the actual image data. */
+PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr,
+ png_infop info_ptr));
+#endif
+
+#ifdef PNG_TIME_RFC1123_SUPPORTED
+PNG_EXPORT(png_charp,png_convert_to_rfc1123)
+ PNGARG((png_structp png_ptr, png_timep ptime));
+#endif
+
+#ifdef PNG_CONVERT_tIME_SUPPORTED
+/* Convert from a struct tm to png_time */
+PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime,
+ struct tm FAR * ttime));
+
+/* Convert from time_t to png_time. Uses gmtime() */
+PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime,
+ time_t ttime));
+#endif /* PNG_CONVERT_tIME_SUPPORTED */
+
+#ifdef PNG_READ_EXPAND_SUPPORTED
+/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */
+PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr));
+PNG_EXPORT(void,png_set_expand_gray_1_2_4_to_8) PNGARG((png_structp
+ png_ptr));
+PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr));
+PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr));
+#endif
+
+#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
+/* Use blue, green, red order for pixels. */
+PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr));
+#endif
+
+#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
+/* Expand the grayscale to 24-bit RGB if necessary. */
+PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr));
+#endif
+
+#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
+/* Reduce RGB to grayscale. */
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr,
+ int error_action, double red, double green ));
+#endif
+PNG_EXPORT(void,png_set_rgb_to_gray_fixed) PNGARG((png_structp png_ptr,
+ int error_action, png_fixed_point red, png_fixed_point green ));
+PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp
+ png_ptr));
+#endif
+
+PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth,
+ png_colorp palette));
+
+#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
+PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr));
+#endif
+
+#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
+ defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
+PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr));
+#endif
+
+#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
+ defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
+PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr));
+#endif
+
+#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
+/* Add a filler byte to 8-bit Gray or 24-bit RGB images. */
+PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr,
+ png_uint_32 filler, int flags));
+/* The values of the PNG_FILLER_ defines should NOT be changed */
+#define PNG_FILLER_BEFORE 0
+#define PNG_FILLER_AFTER 1
+/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */
+PNG_EXPORT(void,png_set_add_alpha) PNGARG((png_structp png_ptr,
+ png_uint_32 filler, int flags));
+#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */
+
+#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
+/* Swap bytes in 16-bit depth files. */
+PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr));
+#endif
+
+#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
+/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */
+PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr));
+#endif
+
+#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \
+ defined(PNG_WRITE_PACKSWAP_SUPPORTED)
+/* Swap packing order of pixels in bytes. */
+PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr));
+#endif
+
+#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
+/* Converts files to legal bit depths. */
+PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr,
+ png_color_8p true_bits));
+#endif
+
+#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
+ defined(PNG_WRITE_INTERLACING_SUPPORTED)
+/* Have the code handle the interlacing. Returns the number of passes. */
+PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr));
+#endif
+
+#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
+/* Invert monochrome files */
+PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr));
+#endif
+
+#ifdef PNG_READ_BACKGROUND_SUPPORTED
+/* Handle alpha and tRNS by replacing with a background color. */
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr,
+ png_color_16p background_color, int background_gamma_code,
+ int need_expand, double background_gamma));
+#endif
+#define PNG_BACKGROUND_GAMMA_UNKNOWN 0
+#define PNG_BACKGROUND_GAMMA_SCREEN 1
+#define PNG_BACKGROUND_GAMMA_FILE 2
+#define PNG_BACKGROUND_GAMMA_UNIQUE 3
+#endif
+
+#ifdef PNG_READ_16_TO_8_SUPPORTED
+/* Strip the second byte of information from a 16-bit depth file. */
+PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr));
+#endif
+
+#ifdef PNG_READ_QUANTIZE_SUPPORTED
+/* Turn on quantizing, and reduce the palette to the number of colors
+ * available. Prior to libpng-1.4.2, this was png_set_dither().
+ */
+PNG_EXPORT(void,png_set_quantize) PNGARG((png_structp png_ptr,
+ png_colorp palette, int num_palette, int maximum_colors,
+ png_uint_16p histogram, int full_quantize));
+#endif
+/* This migration aid will be removed from libpng-1.5.0 */
+#define png_set_dither png_set_quantize
+
+#ifdef PNG_READ_GAMMA_SUPPORTED
+/* Handle gamma correction. Screen_gamma=(display_exponent) */
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr,
+ double screen_gamma, double default_file_gamma));
+#endif
+#endif
+
+
+#ifdef PNG_WRITE_FLUSH_SUPPORTED
+/* Set how many lines between output flushes - 0 for no flushing */
+PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows));
+/* Flush the current PNG output buffer */
+PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr));
+#endif
+
+/* Optional update palette with requested transformations */
+PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr));
+
+/* Optional call to update the users info structure */
+PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr,
+ png_infop info_ptr));
+
+#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
+/* Read one or more rows of image data. */
+PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr,
+ png_bytepp row, png_bytepp display_row, png_uint_32 num_rows));
+#endif
+
+#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
+/* Read a row of data. */
+PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr,
+ png_bytep row,
+ png_bytep display_row));
+#endif
+
+#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
+/* Read the whole image into memory at once. */
+PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr,
+ png_bytepp image));
+#endif
+
+/* Write a row of image data */
+PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr,
+ png_bytep row));
+
+/* Write a few rows of image data */
+PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr,
+ png_bytepp row, png_uint_32 num_rows));
+
+/* Write the image data */
+PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr,
+ png_bytepp image));
+
+/* Write the end of the PNG file. */
+PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr,
+ png_infop info_ptr));
+
+#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
+/* Read the end of the PNG file. */
+PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr,
+ png_infop info_ptr));
+#endif
+
+/* Free any memory associated with the png_info_struct */
+PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr,
+ png_infopp info_ptr_ptr));
+
+/* Free any memory associated with the png_struct and the png_info_structs */
+PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp
+ png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr));
+
+/* Free any memory associated with the png_struct and the png_info_structs */
+PNG_EXPORT(void,png_destroy_write_struct)
+ PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr));
+
+/* Set the libpng method of handling chunk CRC errors */
+PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr,
+ int crit_action, int ancil_action));
+
+/* Values for png_set_crc_action() to say how 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. For versions prior to 0.90, the action was always error/quit,
+ * whereas in version 0.90 and later, the action for CRC errors in ancillary
+ * chunks is warn/discard. These values should NOT be changed.
+ *
+ * value action:critical action:ancillary
+ */
+#define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */
+#define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */
+#define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */
+#define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */
+#define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */
+#define PNG_CRC_NO_CHANGE 5 /* use current value use current value */
+
+/* These functions give the user control over the scan-line filtering in
+ * libpng and the compression methods used by zlib. These functions are
+ * mainly useful for testing, as the defaults should work with most users.
+ * Those users who are tight on memory or want faster performance at the
+ * expense of compression can modify them. See the compression library
+ * header file (zlib.h) for an explination of the compression functions.
+ */
+
+/* Set the filtering method(s) used by libpng. Currently, the only valid
+ * value for "method" is 0.
+ */
+PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method,
+ int filters));
+
+/* Flags for png_set_filter() to say which filters to use. The flags
+ * are chosen so that they don't conflict with real filter types
+ * below, in case they are supplied instead of the #defined constants.
+ * These values should NOT be changed.
+ */
+#define PNG_NO_FILTERS 0x00
+#define PNG_FILTER_NONE 0x08
+#define PNG_FILTER_SUB 0x10
+#define PNG_FILTER_UP 0x20
+#define PNG_FILTER_AVG 0x40
+#define PNG_FILTER_PAETH 0x80
+#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \
+ PNG_FILTER_AVG | PNG_FILTER_PAETH)
+
+/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
+ * These defines should NOT be changed.
+ */
+#define PNG_FILTER_VALUE_NONE 0
+#define PNG_FILTER_VALUE_SUB 1
+#define PNG_FILTER_VALUE_UP 2
+#define PNG_FILTER_VALUE_AVG 3
+#define PNG_FILTER_VALUE_PAETH 4
+#define PNG_FILTER_VALUE_LAST 5
+
+#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* EXPERIMENTAL */
+/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_
+ * defines, either the default (minimum-sum-of-absolute-differences), or
+ * the experimental method (weighted-minimum-sum-of-absolute-differences).
+ *
+ * Weights are factors >= 1.0, indicating how important it is to keep the
+ * filter type consistent between rows. Larger numbers mean the current
+ * filter is that many times as likely to be the same as the "num_weights"
+ * previous filters. This is cumulative for each previous row with a weight.
+ * There needs to be "num_weights" values in "filter_weights", or it can be
+ * NULL if the weights aren't being specified. Weights have no influence on
+ * the selection of the first row filter. Well chosen weights can (in theory)
+ * improve the compression for a given image.
+ *
+ * Costs are factors >= 1.0 indicating the relative decoding costs of a
+ * filter type. Higher costs indicate more decoding expense, and are
+ * therefore less likely to be selected over a filter with lower computational
+ * costs. There needs to be a value in "filter_costs" for each valid filter
+ * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't
+ * setting the costs. Costs try to improve the speed of decompression without
+ * unduly increasing the compressed image size.
+ *
+ * A negative weight or cost indicates the default value is to be used, and
+ * values in the range [0.0, 1.0) indicate the value is to remain unchanged.
+ * The default values for both weights and costs are currently 1.0, but may
+ * change if good general weighting/cost heuristics can be found. If both
+ * the weights and costs are set to 1.0, this degenerates the WEIGHTED method
+ * to the UNWEIGHTED method, but with added encoding time/computation.
+ */
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr,
+ int heuristic_method, int num_weights, png_doublep filter_weights,
+ png_doublep filter_costs));
+#endif
+#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
+
+/* Heuristic used for row filter selection. These defines should NOT be
+ * changed.
+ */
+#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */
+#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */
+#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */
+#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */
+
+/* Set the library compression level. Currently, valid values range from
+ * 0 - 9, corresponding directly to the zlib compression levels 0 - 9
+ * (0 - no compression, 9 - "maximal" compression). Note that tests have
+ * shown that zlib compression levels 3-6 usually perform as well as level 9
+ * for PNG images, and do considerably fewer caclulations. In the future,
+ * these values may not correspond directly to the zlib compression levels.
+ */
+PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr,
+ int level));
+
+PNG_EXPORT(void,png_set_compression_mem_level)
+ PNGARG((png_structp png_ptr, int mem_level));
+
+PNG_EXPORT(void,png_set_compression_strategy)
+ PNGARG((png_structp png_ptr, int strategy));
+
+PNG_EXPORT(void,png_set_compression_window_bits)
+ PNGARG((png_structp png_ptr, int window_bits));
+
+PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr,
+ int method));
+
+/* These next functions are called for input/output, memory, and error
+ * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c,
+ * and call standard C I/O routines such as fread(), fwrite(), and
+ * fprintf(). These functions can be made to use other I/O routines
+ * at run time for those applications that need to handle I/O in a
+ * different manner by calling png_set_???_fn(). See libpng.txt for
+ * more information.
+ */
+
+#ifdef PNG_STDIO_SUPPORTED
+/* Initialize the input/output for the PNG file to the default functions. */
+PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr,
+ png_FILE_p fp));
+#endif
+
+/* Replace the (error and abort), and warning functions with user
+ * supplied functions. If no messages are to be printed you must still
+ * write and use replacement functions. The replacement error_fn should
+ * still do a longjmp to the last setjmp location if you are using this
+ * method of error handling. If error_fn or warning_fn is NULL, the
+ * default function will be used.
+ */
+
+PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr,
+ png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn));
+
+/* Return the user pointer associated with the error functions */
+PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr));
+
+/* Replace the default data output functions with a user supplied one(s).
+ * If buffered output is not used, then output_flush_fn can be set to NULL.
+ * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time
+ * output_flush_fn will be ignored (and thus can be NULL).
+ * It is probably a mistake to use NULL for output_flush_fn if
+ * write_data_fn is not also NULL unless you have built libpng with
+ * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's
+ * default flush function, which uses the standard *FILE structure, will
+ * be used.
+ */
+PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr,
+ png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn));
+
+/* Replace the default data input function with a user supplied one. */
+PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr,
+ png_voidp io_ptr, png_rw_ptr read_data_fn));
+
+/* Return the user pointer associated with the I/O functions */
+PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr));
+
+PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr,
+ png_read_status_ptr read_row_fn));
+
+PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr,
+ png_write_status_ptr write_row_fn));
+
+#ifdef PNG_USER_MEM_SUPPORTED
+/* Replace the default memory allocation functions with user supplied one(s). */
+PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr,
+ png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn));
+/* Return the user pointer associated with the memory functions */
+PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr));
+#endif
+
+#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
+PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp
+ png_ptr, png_user_transform_ptr read_user_transform_fn));
+#endif
+
+#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
+PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp
+ png_ptr, png_user_transform_ptr write_user_transform_fn));
+#endif
+
+#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
+ defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
+PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp
+ png_ptr, png_voidp user_transform_ptr, int user_transform_depth,
+ int user_transform_channels));
+/* Return the user pointer associated with the user transform functions */
+PNG_EXPORT(png_voidp,png_get_user_transform_ptr)
+ PNGARG((png_structp png_ptr));
+#endif
+
+#ifdef PNG_USER_CHUNKS_SUPPORTED
+PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr,
+ png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn));
+PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp
+ png_ptr));
+#endif
+
+#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
+/* Sets the function callbacks for the push reader, and a pointer to a
+ * user-defined structure available to the callback functions.
+ */
+PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr,
+ png_voidp progressive_ptr,
+ png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
+ png_progressive_end_ptr end_fn));
+
+/* Returns the user pointer associated with the push read functions */
+PNG_EXPORT(png_voidp,png_get_progressive_ptr)
+ PNGARG((png_structp png_ptr));
+
+/* Function to be called when data becomes available */
+PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_bytep buffer, png_size_t buffer_size));
+
+/* Function that combines rows. Not very much different than the
+ * png_combine_row() call. Is this even used?????
+ */
+PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr,
+ png_bytep old_row, png_bytep new_row));
+#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
+
+PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr,
+ png_alloc_size_t size)) PNG_ALLOCATED;
+/* Added at libpng version 1.4.0 */
+PNG_EXPORT(png_voidp,png_calloc) PNGARG((png_structp png_ptr,
+ png_alloc_size_t size)) PNG_ALLOCATED;
+
+/* Added at libpng version 1.2.4 */
+PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr,
+ png_alloc_size_t size)) PNG_ALLOCATED;
+
+/* Frees a pointer allocated by png_malloc() */
+PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr));
+
+/* Free data that was allocated internally */
+PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_uint_32 free_me, int num));
+/* Reassign responsibility for freeing existing data, whether allocated
+ * by libpng or by the application */
+PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, int freer, png_uint_32 mask));
+/* Assignments for png_data_freer */
+#define PNG_DESTROY_WILL_FREE_DATA 1
+#define PNG_SET_WILL_FREE_DATA 1
+#define PNG_USER_WILL_FREE_DATA 2
+/* Flags for png_ptr->free_me and info_ptr->free_me */
+#define PNG_FREE_HIST 0x0008
+#define PNG_FREE_ICCP 0x0010
+#define PNG_FREE_SPLT 0x0020
+#define PNG_FREE_ROWS 0x0040
+#define PNG_FREE_PCAL 0x0080
+#define PNG_FREE_SCAL 0x0100
+#define PNG_FREE_UNKN 0x0200
+#define PNG_FREE_LIST 0x0400
+#define PNG_FREE_PLTE 0x1000
+#define PNG_FREE_TRNS 0x2000
+#define PNG_FREE_TEXT 0x4000
+#define PNG_FREE_ALL 0x7fff
+#define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
+
+#ifdef PNG_USER_MEM_SUPPORTED
+PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr,
+ png_alloc_size_t size)) PNG_ALLOCATED;
+PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr,
+ png_voidp ptr));
+#endif
+
+#ifndef PNG_NO_ERROR_TEXT
+/* Fatal error in PNG image of libpng - can't continue */
+PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr,
+ png_const_charp error_message)) PNG_NORETURN;
+
+/* The same, but the chunk name is prepended to the error string. */
+PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr,
+ png_const_charp error_message)) PNG_NORETURN;
+
+#else
+/* Fatal error in PNG image of libpng - can't continue */
+PNG_EXPORT(void,png_err) PNGARG((png_structp png_ptr)) PNG_NORETURN;
+#endif
+
+/* Non-fatal error in libpng. Can continue, but may have a problem. */
+PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr,
+ png_const_charp warning_message));
+
+/* Non-fatal error in libpng, chunk name is prepended to message. */
+PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr,
+ png_const_charp warning_message));
+
+#ifdef PNG_BENIGN_ERRORS_SUPPORTED
+/* Benign error in libpng. Can continue, but may have a problem.
+ * User can choose whether to handle as a fatal error or as a warning. */
+PNG_EXPORT(void,png_benign_error) PNGARG((png_structp png_ptr,
+ png_const_charp warning_message));
+
+/* Same, chunk name is prepended to message. */
+PNG_EXPORT(void,png_chunk_benign_error) PNGARG((png_structp png_ptr,
+ png_const_charp warning_message));
+
+PNG_EXPORT(void,png_set_benign_errors) PNGARG((png_structp
+ png_ptr, int allowed));
+#endif
+
+/* The png_set_<chunk> functions are for storing values in the png_info_struct.
+ * Similarly, the png_get_<chunk> calls are used to read values from the
+ * png_info_struct, either storing the parameters in the passed variables, or
+ * setting pointers into the png_info_struct where the data is stored. The
+ * png_get_<chunk> functions return a non-zero value if the data was available
+ * in info_ptr, or return zero and do not change any of the parameters if the
+ * data was not available.
+ *
+ * These functions should be used instead of directly accessing png_info
+ * to avoid problems with future changes in the size and internal layout of
+ * png_info_struct.
+ */
+/* Returns "flag" if chunk data is valid in info_ptr. */
+PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr,
+png_infop info_ptr, png_uint_32 flag));
+
+/* Returns number of bytes needed to hold a transformed row. */
+PNG_EXPORT(png_size_t,png_get_rowbytes) PNGARG((png_structp png_ptr,
+png_infop info_ptr));
+
+#ifdef PNG_INFO_IMAGE_SUPPORTED
+/* Returns row_pointers, which is an array of pointers to scanlines that was
+ * returned from png_read_png().
+ */
+PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr,
+png_infop info_ptr));
+/* Set row_pointers, which is an array of pointers to scanlines for use
+ * by png_write_png().
+ */
+PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_bytepp row_pointers));
+#endif
+
+/* Returns number of color channels in image. */
+PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr,
+png_infop info_ptr));
+
+#ifdef PNG_EASY_ACCESS_SUPPORTED
+/* Returns image width in pixels. */
+PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp
+png_ptr, png_infop info_ptr));
+
+/* Returns image height in pixels. */
+PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp
+png_ptr, png_infop info_ptr));
+
+/* Returns image bit_depth. */
+PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp
+png_ptr, png_infop info_ptr));
+
+/* Returns image color_type. */
+PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp
+png_ptr, png_infop info_ptr));
+
+/* Returns image filter_type. */
+PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp
+png_ptr, png_infop info_ptr));
+
+/* Returns image interlace_type. */
+PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp
+png_ptr, png_infop info_ptr));
+
+/* Returns image compression_type. */
+PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp
+png_ptr, png_infop info_ptr));
+
+/* Returns image resolution in pixels per meter, from pHYs chunk data. */
+PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp
+png_ptr, png_infop info_ptr));
+PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp
+png_ptr, png_infop info_ptr));
+PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp
+png_ptr, png_infop info_ptr));
+
+/* Returns pixel aspect ratio, computed from pHYs chunk data. */
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp
+png_ptr, png_infop info_ptr));
+#endif
+
+/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */
+PNG_EXPORT(png_int_32, png_get_x_offset_pixels) PNGARG((png_structp
+png_ptr, png_infop info_ptr));
+PNG_EXPORT(png_int_32, png_get_y_offset_pixels) PNGARG((png_structp
+png_ptr, png_infop info_ptr));
+PNG_EXPORT(png_int_32, png_get_x_offset_microns) PNGARG((png_structp
+png_ptr, png_infop info_ptr));
+PNG_EXPORT(png_int_32, png_get_y_offset_microns) PNGARG((png_structp
+png_ptr, png_infop info_ptr));
+
+#endif /* PNG_EASY_ACCESS_SUPPORTED */
+
+/* Returns pointer to signature string read from PNG header */
+PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr,
+png_infop info_ptr));
+
+#ifdef PNG_bKGD_SUPPORTED
+PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_color_16p *background));
+#endif
+
+#ifdef PNG_bKGD_SUPPORTED
+PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_color_16p background));
+#endif
+
+#ifdef PNG_cHRM_SUPPORTED
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((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));
+#endif
+#ifdef PNG_FIXED_POINT_SUPPORTED
+PNG_EXPORT(png_uint_32,png_get_cHRM_fixed) PNGARG((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));
+#endif
+#endif
+
+#ifdef PNG_cHRM_SUPPORTED
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+PNG_EXPORT(void,png_set_cHRM) PNGARG((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));
+#endif
+#ifdef PNG_FIXED_POINT_SUPPORTED
+PNG_EXPORT(void,png_set_cHRM_fixed) PNGARG((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));
+#endif
+#endif
+
+#ifdef PNG_gAMA_SUPPORTED
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, double *file_gamma));
+#endif
+PNG_EXPORT(png_uint_32,png_get_gAMA_fixed) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_fixed_point *int_file_gamma));
+#endif
+
+#ifdef PNG_gAMA_SUPPORTED
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, double file_gamma));
+#endif
+PNG_EXPORT(void,png_set_gAMA_fixed) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_fixed_point int_file_gamma));
+#endif
+
+#ifdef PNG_hIST_SUPPORTED
+PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_uint_16p *hist));
+#endif
+
+#ifdef PNG_hIST_SUPPORTED
+PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_uint_16p hist));
+#endif
+
+PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_uint_32 *width, png_uint_32 *height,
+ int *bit_depth, int *color_type, int *interlace_method,
+ int *compression_method, int *filter_method));
+
+PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth,
+ int color_type, int interlace_method, int compression_method,
+ int filter_method));
+
+#ifdef PNG_oFFs_SUPPORTED
+PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y,
+ int *unit_type));
+#endif
+
+#ifdef PNG_oFFs_SUPPORTED
+PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y,
+ int unit_type));
+#endif
+
+#ifdef PNG_pCAL_SUPPORTED
+PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1,
+ int *type, int *nparams, png_charp *units, png_charpp *params));
+#endif
+
+#ifdef PNG_pCAL_SUPPORTED
+PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1,
+ int type, int nparams, png_charp units, png_charpp params));
+#endif
+
+#ifdef PNG_pHYs_SUPPORTED
+PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
+#endif
+
+#ifdef PNG_pHYs_SUPPORTED
+PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type));
+#endif
+
+PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_colorp *palette, int *num_palette));
+
+PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_colorp palette, int num_palette));
+
+#ifdef PNG_sBIT_SUPPORTED
+PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_color_8p *sig_bit));
+#endif
+
+#ifdef PNG_sBIT_SUPPORTED
+PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_color_8p sig_bit));
+#endif
+
+#ifdef PNG_sRGB_SUPPORTED
+PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, int *intent));
+#endif
+
+#ifdef PNG_sRGB_SUPPORTED
+PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, int intent));
+PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, int intent));
+#endif
+
+#ifdef PNG_iCCP_SUPPORTED
+PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_charpp name, int *compression_type,
+ png_charpp profile, png_uint_32 *proflen));
+ /* Note to maintainer: profile should be png_bytepp */
+#endif
+
+#ifdef PNG_iCCP_SUPPORTED
+PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_charp name, int compression_type,
+ png_charp profile, png_uint_32 proflen));
+ /* Note to maintainer: profile should be png_bytep */
+#endif
+
+#ifdef PNG_sPLT_SUPPORTED
+PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_sPLT_tpp entries));
+#endif
+
+#ifdef PNG_sPLT_SUPPORTED
+PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_sPLT_tp entries, int nentries));
+#endif
+
+#ifdef PNG_TEXT_SUPPORTED
+/* png_get_text also returns the number of text chunks in *num_text */
+PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_textp *text_ptr, int *num_text));
+#endif
+
+/* Note while png_set_text() will accept a structure whose text,
+ * language, and translated keywords are 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.
+ */
+
+#ifdef PNG_TEXT_SUPPORTED
+PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_textp text_ptr, int num_text));
+#endif
+
+#ifdef PNG_tIME_SUPPORTED
+PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_timep *mod_time));
+#endif
+
+#ifdef PNG_tIME_SUPPORTED
+PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_timep mod_time));
+#endif
+
+#ifdef PNG_tRNS_SUPPORTED
+PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_bytep *trans_alpha, int *num_trans,
+ png_color_16p *trans_color));
+#endif
+
+#ifdef PNG_tRNS_SUPPORTED
+PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_bytep trans_alpha, int num_trans,
+ png_color_16p trans_color));
+#endif
+
+#ifdef PNG_tRNS_SUPPORTED
+#endif
+
+#ifdef PNG_sCAL_SUPPORTED
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, int *unit, double *width, double *height));
+#else
+#ifdef PNG_FIXED_POINT_SUPPORTED
+PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight));
+#endif
+#endif
+#endif /* PNG_sCAL_SUPPORTED */
+
+#ifdef PNG_sCAL_SUPPORTED
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, int unit, double width, double height));
+#else
+#ifdef PNG_FIXED_POINT_SUPPORTED
+PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, int unit, png_charp swidth, png_charp sheight));
+#endif
+#endif
+#endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */
+
+#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
+/* Provide a list of chunks and how they are to be handled, if the built-in
+ handling or default unknown chunk handling is not desired. Any chunks not
+ listed will be handled in the default manner. The IHDR and IEND chunks
+ must not be listed.
+ keep = 0: follow default behaviour
+ = 1: do not keep
+ = 2: keep only if safe-to-copy
+ = 3: keep even if unsafe-to-copy
+*/
+PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp
+ png_ptr, int keep, png_bytep chunk_list, int num_chunks));
+PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep
+ chunk_name));
+#endif
+#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
+PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns));
+PNG_EXPORT(void, png_set_unknown_chunk_location)
+ PNGARG((png_structp png_ptr, png_infop info_ptr, int chunk, int location));
+PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp
+ png_ptr, png_infop info_ptr, png_unknown_chunkpp entries));
+#endif
+
+/* Png_free_data() will turn off the "valid" flag for anything it frees.
+ * If you need to turn it off for a chunk that your application has freed,
+ * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK);
+ */
+PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, int mask));
+
+#ifdef PNG_INFO_IMAGE_SUPPORTED
+/* The "params" pointer is currently not used and is for future expansion. */
+PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr,
+ png_infop info_ptr,
+ int transforms,
+ png_voidp params));
+PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr,
+ png_infop info_ptr,
+ int transforms,
+ png_voidp params));
+#endif
+
+PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr));
+PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr));
+PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp
+ png_ptr));
+PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr));
+
+#ifdef PNG_MNG_FEATURES_SUPPORTED
+PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp
+ png_ptr, png_uint_32 mng_features_permitted));
+#endif
+
+/* For use in png_set_keep_unknown, added to version 1.2.6 */
+#define PNG_HANDLE_CHUNK_AS_DEFAULT 0
+#define PNG_HANDLE_CHUNK_NEVER 1
+#define PNG_HANDLE_CHUNK_IF_SAFE 2
+#define PNG_HANDLE_CHUNK_ALWAYS 3
+
+/* Strip the prepended error numbers ("#nnn ") from error and warning
+ * messages before passing them to the error or warning handler.
+ */
+#ifdef PNG_ERROR_NUMBERS_SUPPORTED
+PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp
+ png_ptr, png_uint_32 strip_mode));
+#endif
+
+/* Added in libpng-1.2.6 */
+#ifdef PNG_SET_USER_LIMITS_SUPPORTED
+PNG_EXPORT(void,png_set_user_limits) PNGARG((png_structp
+ png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max));
+PNG_EXPORT(png_uint_32,png_get_user_width_max) PNGARG((png_structp
+ png_ptr));
+PNG_EXPORT(png_uint_32,png_get_user_height_max) PNGARG((png_structp
+ png_ptr));
+/* Added in libpng-1.4.0 */
+PNG_EXPORT(void,png_set_chunk_cache_max) PNGARG((png_structp
+ png_ptr, png_uint_32 user_chunk_cache_max));
+PNG_EXPORT(png_uint_32,png_get_chunk_cache_max)
+ PNGARG((png_structp png_ptr));
+/* Added in libpng-1.4.1 */
+PNG_EXPORT(void,png_set_chunk_malloc_max) PNGARG((png_structp
+ png_ptr, png_alloc_size_t user_chunk_cache_max));
+PNG_EXPORT(png_alloc_size_t,png_get_chunk_malloc_max)
+ PNGARG((png_structp png_ptr));
+#endif
+
+#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
+PNG_EXPORT(png_uint_32,png_get_pixels_per_inch) PNGARG((png_structp png_ptr,
+png_infop info_ptr));
+
+PNG_EXPORT(png_uint_32,png_get_x_pixels_per_inch) PNGARG((png_structp png_ptr,
+png_infop info_ptr));
+
+PNG_EXPORT(png_uint_32,png_get_y_pixels_per_inch) PNGARG((png_structp png_ptr,
+png_infop info_ptr));
+
+PNG_EXPORT(float,png_get_x_offset_inches) PNGARG((png_structp png_ptr,
+png_infop info_ptr));
+
+PNG_EXPORT(float,png_get_y_offset_inches) PNGARG((png_structp png_ptr,
+png_infop info_ptr));
+
+#ifdef PNG_pHYs_SUPPORTED
+PNG_EXPORT(png_uint_32,png_get_pHYs_dpi) PNGARG((png_structp png_ptr,
+png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
+#endif /* PNG_pHYs_SUPPORTED */
+#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
+
+/* Added in libpng-1.4.0 */
+#ifdef PNG_IO_STATE_SUPPORTED
+PNG_EXPORT(png_uint_32,png_get_io_state) PNGARG((png_structp png_ptr));
+
+PNG_EXPORT(png_bytep,png_get_io_chunk_name)
+ PNGARG((png_structp png_ptr));
+
+/* The flags returned by png_get_io_state() are the following: */
+#define PNG_IO_NONE 0x0000 /* no I/O at this moment */
+#define PNG_IO_READING 0x0001 /* currently reading */
+#define PNG_IO_WRITING 0x0002 /* currently writing */
+#define PNG_IO_SIGNATURE 0x0010 /* currently at the file signature */
+#define PNG_IO_CHUNK_HDR 0x0020 /* currently at the chunk header */
+#define PNG_IO_CHUNK_DATA 0x0040 /* currently at the chunk data */
+#define PNG_IO_CHUNK_CRC 0x0080 /* currently at the chunk crc */
+#define PNG_IO_MASK_OP 0x000f /* current operation: reading/writing */
+#define PNG_IO_MASK_LOC 0x00f0 /* current location: sig/hdr/data/crc */
+#endif /* ?PNG_IO_STATE_SUPPORTED */
+
+/* Maintainer: Put new public prototypes here ^, in libpng.3, and project
+ * defs
+ */
+
+#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
+/* With these routines we avoid an integer divide, which will be slower on
+ * most machines. However, it does take more operations than the corresponding
+ * divide method, so it may be slower on a few RISC systems. There are two
+ * shifts (by 8 or 16 bits) and an addition, versus a single integer divide.
+ *
+ * Note that the rounding factors are NOT supposed to be the same! 128 and
+ * 32768 are correct for the NODIV code; 127 and 32767 are correct for the
+ * standard method.
+ *
+ * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]
+ */
+
+ /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */
+
+# define png_composite(composite, fg, alpha, bg) \
+ { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \
+ * (png_uint_16)(alpha) \
+ + (png_uint_16)(bg)*(png_uint_16)(255 \
+ - (png_uint_16)(alpha)) + (png_uint_16)128); \
+ (composite) = (png_byte)((temp + (temp >> 8)) >> 8); }
+
+# define png_composite_16(composite, fg, alpha, bg) \
+ { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \
+ * (png_uint_32)(alpha) \
+ + (png_uint_32)(bg)*(png_uint_32)(65535L \
+ - (png_uint_32)(alpha)) + (png_uint_32)32768L); \
+ (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }
+
+#else /* Standard method using integer division */
+
+# define png_composite(composite, fg, alpha, bg) \
+ (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \
+ (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \
+ (png_uint_16)127) / 255)
+
+# define png_composite_16(composite, fg, alpha, bg) \
+ (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \
+ (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \
+ (png_uint_32)32767) / (png_uint_32)65535L)
+#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
+
+#ifdef PNG_USE_READ_MACROS
+/* Inline macros to do direct reads of bytes from the input buffer.
+ * The png_get_int_32() routine assumes we are using two's complement
+ * format for negative values, which is almost certainly true.
+ */
+# define png_get_uint_32(buf) \
+ (((png_uint_32)(*(buf)) << 24) + \
+ ((png_uint_32)(*((buf) + 1)) << 16) + \
+ ((png_uint_32)(*((buf) + 2)) << 8) + \
+ ((png_uint_32)(*((buf) + 3))))
+# define png_get_uint_16(buf) \
+ (((png_uint_32)(*(buf)) << 8) + \
+ ((png_uint_32)(*((buf) + 1))))
+# define png_get_int_32(buf) \
+ ((png_int_32)((*(buf) & 0x80) \
+ ? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffff)+1)) \
+ : (png_int_32)png_get_uint_32(buf)))
+#else
+PNG_EXPORT(png_uint_32,png_get_uint_32) PNGARG((png_bytep buf));
+PNG_EXPORT(png_uint_16,png_get_uint_16) PNGARG((png_bytep buf));
+#ifdef PNG_GET_INT_32_SUPPORTED
+PNG_EXPORT(png_int_32,png_get_int_32) PNGARG((png_bytep buf));
+#endif
+#endif
+PNG_EXPORT(png_uint_32,png_get_uint_31)
+ PNGARG((png_structp png_ptr, png_bytep buf));
+/* No png_get_int_16 -- may be added if there's a real need for it. */
+
+/* Place a 32-bit number into a buffer in PNG byte order (big-endian). */
+PNG_EXPORT(void,png_save_uint_32)
+ PNGARG((png_bytep buf, png_uint_32 i));
+PNG_EXPORT(void,png_save_int_32)
+ PNGARG((png_bytep buf, png_int_32 i));
+
+/* Place a 16-bit number into a buffer in PNG byte order.
+ * The parameter is declared unsigned int, not png_uint_16,
+ * just to avoid potential problems on pre-ANSI C compilers.
+ */
+PNG_EXPORT(void,png_save_uint_16)
+ PNGARG((png_bytep buf, unsigned int i));
+/* No png_save_int_16 -- may be added if there's a real need for it. */
+
+/* ************************************************************************* */
+
+/* Various modes of operation. Note that after an init, mode is set to
+ * zero automatically when the structure is created.
+ */
+#define PNG_HAVE_IHDR 0x01
+#define PNG_HAVE_PLTE 0x02
+#define PNG_HAVE_IDAT 0x04
+#define PNG_AFTER_IDAT 0x08 /* Have complete zlib datastream */
+#define PNG_HAVE_IEND 0x10
+#define PNG_HAVE_gAMA 0x20
+#define PNG_HAVE_cHRM 0x40
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* PNG_VERSION_INFO_ONLY */
+/* Do not put anything past this line */
+#endif /* PNG_H */
--- /dev/null
+
+/* pngconf.h - machine configurable file for libpng
+ *
+ * libpng version 1.4.4 - September 23, 2010
+ * For conditions of distribution and use, see copyright notice in png.h
+ * Copyright (c) 1998-2010 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.)
+ *
+ * This code is released under the libpng license.
+ * For conditions of distribution and use, see the disclaimer
+ * and license in png.h
+ *
+ */
+
+/* Any machine specific code is near the front of this file, so if you
+ * are configuring libpng for a machine, you may want to read the section
+ * starting here down to where it starts to typedef png_color, png_text,
+ * and png_info.
+ */
+
+#ifndef PNGCONF_H
+#define PNGCONF_H
+
+#ifndef PNG_NO_LIMITS_H
+# include <limits.h>
+#endif
+
+/* Added at libpng-1.2.9 */
+
+/* config.h is created by and PNG_CONFIGURE_LIBPNG is set by the "configure"
+ * script.
+ */
+#ifdef PNG_CONFIGURE_LIBPNG
+# ifdef HAVE_CONFIG_H
+# include "config.h"
+# endif
+#endif
+
+/*
+ * Added at libpng-1.2.8
+ *
+ * PNG_USER_CONFIG has to be defined on the compiler command line. This
+ * includes the resource compiler for Windows DLL configurations.
+ */
+#ifdef PNG_USER_CONFIG
+# include "pngusr.h"
+# ifndef PNG_USER_PRIVATEBUILD
+# define PNG_USER_PRIVATEBUILD
+# endif
+#endif
+
+/*
+ * If you create a private DLL you should define in "pngusr.h" the following:
+ * #define PNG_USER_PRIVATEBUILD <Describes by whom and why this version of
+ * the DLL was built>
+ * e.g. #define PNG_USER_PRIVATEBUILD "Build by MyCompany for xyz reasons."
+ * #define PNG_USER_DLLFNAME_POSTFIX <two-letter postfix that serve to
+ * distinguish your DLL from those of the official release. These
+ * correspond to the trailing letters that come after the version
+ * number and must match your private DLL name>
+ * e.g. // private DLL "libpng14gx.dll"
+ * #define PNG_USER_DLLFNAME_POSTFIX "gx"
+ *
+ * The following macros are also at your disposal if you want to complete the
+ * DLL VERSIONINFO structure.
+ * - PNG_USER_VERSIONINFO_COMMENTS
+ * - PNG_USER_VERSIONINFO_COMPANYNAME
+ * - PNG_USER_VERSIONINFO_LEGALTRADEMARKS
+ */
+
+#ifdef __STDC__
+# ifdef SPECIALBUILD
+# pragma message("PNG_LIBPNG_SPECIALBUILD (and deprecated SPECIALBUILD)\
+ are now LIBPNG reserved macros. Use PNG_USER_PRIVATEBUILD instead.")
+# endif
+
+# ifdef PRIVATEBUILD
+# pragma message("PRIVATEBUILD is deprecated.\
+ Use PNG_USER_PRIVATEBUILD instead.")
+# define PNG_USER_PRIVATEBUILD PRIVATEBUILD
+# endif
+#endif /* __STDC__ */
+
+/* End of material added to libpng-1.2.8 */
+
+#ifndef PNG_VERSION_INFO_ONLY
+
+/* This is the size of the compression buffer, and thus the size of
+ * an IDAT chunk. Make this whatever size you feel is best for your
+ * machine. One of these will be allocated per png_struct. When this
+ * is full, it writes the data to the disk, and does some other
+ * calculations. Making this an extremely small size will slow
+ * the library down, but you may want to experiment to determine
+ * where it becomes significant, if you are concerned with memory
+ * usage. Note that zlib allocates at least 32Kb also. For readers,
+ * this describes the size of the buffer available to read the data in.
+ * Unless this gets smaller than the size of a row (compressed),
+ * it should not make much difference how big this is.
+ */
+
+#ifndef PNG_ZBUF_SIZE
+# define PNG_ZBUF_SIZE 8192
+#endif
+
+/* Enable if you want a write-only libpng */
+
+#ifndef PNG_NO_READ_SUPPORTED
+# define PNG_READ_SUPPORTED
+#endif
+
+/* Enable if you want a read-only libpng */
+
+#ifndef PNG_NO_WRITE_SUPPORTED
+# define PNG_WRITE_SUPPORTED
+#endif
+
+/* Enabled in 1.4.0. */
+#ifdef PNG_ALLOW_BENIGN_ERRORS
+# define png_benign_error png_warning
+# define png_chunk_benign_error png_chunk_warning
+#else
+# ifndef PNG_BENIGN_ERRORS_SUPPORTED
+# define png_benign_error png_error
+# define png_chunk_benign_error png_chunk_error
+# endif
+#endif
+
+/* Added at libpng version 1.4.0 */
+#if !defined(PNG_NO_WARNINGS) && !defined(PNG_WARNINGS_SUPPORTED)
+# define PNG_WARNINGS_SUPPORTED
+#endif
+
+/* Added at libpng version 1.4.0 */
+#if !defined(PNG_NO_ERROR_TEXT) && !defined(PNG_ERROR_TEXT_SUPPORTED)
+# define PNG_ERROR_TEXT_SUPPORTED
+#endif
+
+/* Added at libpng version 1.4.0 */
+#if !defined(PNG_NO_CHECK_cHRM) && !defined(PNG_CHECK_cHRM_SUPPORTED)
+# define PNG_CHECK_cHRM_SUPPORTED
+#endif
+
+/* Added at libpng version 1.4.0 */
+#if !defined(PNG_NO_ALIGNED_MEMORY) && !defined(PNG_ALIGNED_MEMORY_SUPPORTED)
+# define PNG_ALIGNED_MEMORY_SUPPORTED
+#endif
+
+/* Enabled by default in 1.2.0. You can disable this if you don't need to
+ support PNGs that are embedded in MNG datastreams */
+#ifndef PNG_NO_MNG_FEATURES
+# ifndef PNG_MNG_FEATURES_SUPPORTED
+# define PNG_MNG_FEATURES_SUPPORTED
+# endif
+#endif
+
+/* Added at libpng version 1.4.0 */
+#ifndef PNG_NO_FLOATING_POINT_SUPPORTED
+# ifndef PNG_FLOATING_POINT_SUPPORTED
+# define PNG_FLOATING_POINT_SUPPORTED
+# endif
+#endif
+
+/* Added at libpng-1.4.0beta49 for testing (this test is no longer used
+ in libpng and png_calloc() is always present)
+ */
+#define PNG_CALLOC_SUPPORTED
+
+/* If you are running on a machine where you cannot allocate more
+ * than 64K of memory at once, uncomment this. While libpng will not
+ * normally need that much memory in a chunk (unless you load up a very
+ * large file), zlib needs to know how big of a chunk it can use, and
+ * libpng thus makes sure to check any memory allocation to verify it
+ * will fit into memory.
+#define PNG_MAX_MALLOC_64K
+ */
+#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
+# define PNG_MAX_MALLOC_64K
+#endif
+
+/* Special munging to support doing things the 'cygwin' way:
+ * 'Normal' png-on-win32 defines/defaults:
+ * PNG_BUILD_DLL -- building dll
+ * PNG_USE_DLL -- building an application, linking to dll
+ * (no define) -- building static library, or building an
+ * application and linking to the static lib
+ * 'Cygwin' defines/defaults:
+ * PNG_BUILD_DLL -- (ignored) building the dll
+ * (no define) -- (ignored) building an application, linking to the dll
+ * PNG_STATIC -- (ignored) building the static lib, or building an
+ * application that links to the static lib.
+ * ALL_STATIC -- (ignored) building various static libs, or building an
+ * application that links to the static libs.
+ * Thus,
+ * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and
+ * this bit of #ifdefs will define the 'correct' config variables based on
+ * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but
+ * unnecessary.
+ *
+ * Also, the precedence order is:
+ * ALL_STATIC (since we can't #undef something outside our namespace)
+ * PNG_BUILD_DLL
+ * PNG_STATIC
+ * (nothing) == PNG_USE_DLL
+ *
+ * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent
+ * of auto-import in binutils, we no longer need to worry about
+ * __declspec(dllexport) / __declspec(dllimport) and friends. Therefore,
+ * we don't need to worry about PNG_STATIC or ALL_STATIC when it comes
+ * to __declspec() stuff. However, we DO need to worry about
+ * PNG_BUILD_DLL and PNG_STATIC because those change some defaults
+ * such as CONSOLE_IO.
+ */
+#ifdef __CYGWIN__
+# ifdef ALL_STATIC
+# ifdef PNG_BUILD_DLL
+# undef PNG_BUILD_DLL
+# endif
+# ifdef PNG_USE_DLL
+# undef PNG_USE_DLL
+# endif
+# ifdef PNG_DLL
+# undef PNG_DLL
+# endif
+# ifndef PNG_STATIC
+# define PNG_STATIC
+# endif
+# else
+# ifdef PNG_BUILD_DLL
+# ifdef PNG_STATIC
+# undef PNG_STATIC
+# endif
+# ifdef PNG_USE_DLL
+# undef PNG_USE_DLL
+# endif
+# ifndef PNG_DLL
+# define PNG_DLL
+# endif
+# else
+# ifdef PNG_STATIC
+# ifdef PNG_USE_DLL
+# undef PNG_USE_DLL
+# endif
+# ifdef PNG_DLL
+# undef PNG_DLL
+# endif
+# else
+# ifndef PNG_USE_DLL
+# define PNG_USE_DLL
+# endif
+# ifndef PNG_DLL
+# define PNG_DLL
+# endif
+# endif
+# endif
+# endif
+#endif
+
+/* This protects us against compilers that run on a windowing system
+ * and thus don't have or would rather us not use the stdio types:
+ * stdin, stdout, and stderr. The only one currently used is stderr
+ * in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will
+ * prevent these from being compiled and used. #defining PNG_NO_STDIO
+ * will also prevent these, plus will prevent the entire set of stdio
+ * macros and functions (FILE *, printf, etc.) from being compiled and used,
+ * unless (PNG_DEBUG > 0) has been #defined.
+ *
+ * #define PNG_NO_CONSOLE_IO
+ * #define PNG_NO_STDIO
+ */
+
+#ifdef _WIN32_WCE
+# define PNG_NO_CONSOLE_IO
+# define PNG_NO_STDIO
+# define PNG_NO_TIME_RFC1123
+# ifdef PNG_DEBUG
+# undef PNG_DEBUG
+# endif
+#endif
+
+#if !defined(PNG_NO_STDIO) && !defined(PNG_STDIO_SUPPORTED)
+# define PNG_STDIO_SUPPORTED
+#endif
+
+#ifdef PNG_BUILD_DLL
+# if !defined(PNG_CONSOLE_IO_SUPPORTED) && !defined(PNG_NO_CONSOLE_IO)
+# define PNG_NO_CONSOLE_IO
+# endif
+#endif
+
+# ifdef PNG_NO_STDIO
+# ifndef PNG_NO_CONSOLE_IO
+# define PNG_NO_CONSOLE_IO
+# endif
+# ifdef PNG_DEBUG
+# if (PNG_DEBUG > 0)
+# include <stdio.h>
+# endif
+# endif
+# else
+# include <stdio.h>
+# endif
+
+#if !(defined PNG_NO_CONSOLE_IO) && !defined(PNG_CONSOLE_IO_SUPPORTED)
+# define PNG_CONSOLE_IO_SUPPORTED
+#endif
+
+/* This macro protects us against machines that don't have function
+ * prototypes (ie K&R style headers). If your compiler does not handle
+ * function prototypes, define this macro and use the included ansi2knr.
+ * I've always been able to use _NO_PROTO as the indicator, but you may
+ * need to drag the empty declaration out in front of here, or change the
+ * ifdef to suit your own needs.
+ */
+#ifndef PNGARG
+
+#ifdef OF /* zlib prototype munger */
+# define PNGARG(arglist) OF(arglist)
+#else
+
+#ifdef _NO_PROTO
+# define PNGARG(arglist) ()
+#else
+# define PNGARG(arglist) arglist
+#endif /* _NO_PROTO */
+
+#endif /* OF */
+
+#endif /* PNGARG */
+
+/* Try to determine if we are compiling on a Mac. Note that testing for
+ * just __MWERKS__ is not good enough, because the Codewarrior is now used
+ * on non-Mac platforms.
+ */
+#ifndef MACOS
+# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
+ defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
+# define MACOS
+# endif
+#endif
+
+/* Enough people need this for various reasons to include it here */
+#if !defined(MACOS) && !defined(RISCOS)
+# include <sys/types.h>
+#endif
+
+/* PNG_SETJMP_NOT_SUPPORTED and PNG_NO_SETJMP_SUPPORTED are deprecated. */
+#if !defined(PNG_NO_SETJMP) && \
+ !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED)
+# define PNG_SETJMP_SUPPORTED
+#endif
+
+#ifdef PNG_SETJMP_SUPPORTED
+/* This is an attempt to force a single setjmp behaviour on Linux. If
+ * the X config stuff didn't define _BSD_SOURCE we wouldn't need this.
+ *
+ * You can bypass this test if you know that your application uses exactly
+ * the same setjmp.h that was included when libpng was built. Only define
+ * PNG_SKIP_SETJMP_CHECK while building your application, prior to the
+ * application's '#include "png.h"'. Don't define PNG_SKIP_SETJMP_CHECK
+ * while building a separate libpng library for general use.
+ */
+
+# ifndef PNG_SKIP_SETJMP_CHECK
+# ifdef __linux__
+# ifdef _BSD_SOURCE
+# define PNG_SAVE_BSD_SOURCE
+# undef _BSD_SOURCE
+# endif
+# ifdef _SETJMP_H
+ /* If you encounter a compiler error here, see the explanation
+ * near the end of INSTALL.
+ */
+ __pngconf.h__ in libpng already includes setjmp.h;
+ __dont__ include it again.;
+# endif
+# endif /* __linux__ */
+# endif /* PNG_SKIP_SETJMP_CHECK */
+
+ /* Include setjmp.h for error handling */
+# include <setjmp.h>
+
+# ifdef __linux__
+# ifdef PNG_SAVE_BSD_SOURCE
+# ifdef _BSD_SOURCE
+# undef _BSD_SOURCE
+# endif
+# define _BSD_SOURCE
+# undef PNG_SAVE_BSD_SOURCE
+# endif
+# endif /* __linux__ */
+#endif /* PNG_SETJMP_SUPPORTED */
+
+#ifdef BSD
+# include <strings.h>
+#else
+# include <string.h>
+#endif
+
+/* Other defines for things like memory and the like can go here. */
+
+/* This controls how fine the quantizing gets. As this allocates
+ * a largish chunk of memory (32K), those who are not as concerned
+ * with quantizing quality can decrease some or all of these.
+ */
+
+/* Prior to libpng-1.4.2, these were PNG_DITHER_*_BITS
+ * These migration aids will be removed from libpng-1.5.0.
+ */
+#ifdef PNG_DITHER_RED_BITS
+# define PNG_QUANTIZE_RED_BITS PNG_DITHER_RED_BITS
+#endif
+#ifdef PNG_DITHER_GREEN_BITS
+# define PNG_QUANTIZE_GREEN_BITS PNG_DITHER_GREEN_BITS
+#endif
+#ifdef PNG_DITHER_BLUE_BITS
+# define PNG_QUANTIZE_BLUE_BITS PNG_DITHER_BLUE_BITS
+#endif
+
+#ifndef PNG_QUANTIZE_RED_BITS
+# define PNG_QUANTIZE_RED_BITS 5
+#endif
+#ifndef PNG_QUANTIZE_GREEN_BITS
+# define PNG_QUANTIZE_GREEN_BITS 5
+#endif
+#ifndef PNG_QUANTIZE_BLUE_BITS
+# define PNG_QUANTIZE_BLUE_BITS 5
+#endif
+
+/* This controls how fine the gamma correction becomes when you
+ * are only interested in 8 bits anyway. Increasing this value
+ * results in more memory being used, and more pow() functions
+ * being called to fill in the gamma tables. Don't set this value
+ * less then 8, and even that may not work (I haven't tested it).
+ */
+
+#ifndef PNG_MAX_GAMMA_8
+# define PNG_MAX_GAMMA_8 11
+#endif
+
+/* This controls how much a difference in gamma we can tolerate before
+ * we actually start doing gamma conversion.
+ */
+#ifndef PNG_GAMMA_THRESHOLD
+# define PNG_GAMMA_THRESHOLD 0.05
+#endif
+
+/* The following uses const char * instead of char * for error
+ * and warning message functions, so some compilers won't complain.
+ * If you do not want to use const, define PNG_NO_CONST.
+ */
+
+#ifndef PNG_CONST
+# ifndef PNG_NO_CONST
+# define PNG_CONST const
+# else
+# define PNG_CONST
+# endif
+#endif
+
+/* The following defines give you the ability to remove code from the
+ * library that you will not be using. I wish I could figure out how to
+ * automate this, but I can't do that without making it seriously hard
+ * on the users. So if you are not using an ability, change the #define
+ * to an #undef, or pass in PNG_NO_feature and that part of the library
+ * will not be compiled.
+
+ * If your linker can't find a function, you may want to make sure the
+ * ability is defined here. Some of these depend upon some others being
+ * defined. I haven't figured out all the interactions here, so you may
+ * have to experiment awhile to get everything to compile. If you are
+ * creating or using a shared library, you probably shouldn't touch this,
+ * as it will affect the size of the structures, and this will cause bad
+ * things to happen if the library and/or application ever change.
+ */
+
+/* Any features you will not be using can be undef'ed here */
+
+/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user
+ * to turn it off with PNG_NO_READ|WRITE_TRANSFORMS on the compile line,
+ * then pick and choose which ones to define without having to edit this
+ * file. It is safe to use the PNG_NO_READ|WRITE_TRANSFORMS
+ * if you only want to have a png-compliant reader/writer but don't need
+ * any of the extra transformations. This saves about 80 kbytes in a
+ * typical installation of the library. (PNG_NO_* form added in version
+ * 1.0.1c, for consistency; PNG_*_TRANSFORMS_NOT_SUPPORTED deprecated in
+ * 1.4.0)
+ */
+
+/* Ignore attempt to turn off both floating and fixed point support */
+#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \
+ !defined(PNG_NO_FIXED_POINT_SUPPORTED)
+# define PNG_FIXED_POINT_SUPPORTED
+#endif
+
+#ifdef PNG_READ_SUPPORTED
+
+/* PNG_READ_TRANSFORMS_NOT_SUPPORTED is deprecated. */
+#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \
+ !defined(PNG_NO_READ_TRANSFORMS)
+# define PNG_READ_TRANSFORMS_SUPPORTED
+#endif
+
+#ifdef PNG_READ_TRANSFORMS_SUPPORTED
+# ifndef PNG_NO_READ_EXPAND
+# define PNG_READ_EXPAND_SUPPORTED
+# endif
+# ifndef PNG_NO_READ_SHIFT
+# define PNG_READ_SHIFT_SUPPORTED
+# endif
+# ifndef PNG_NO_READ_PACK
+# define PNG_READ_PACK_SUPPORTED
+# endif
+# ifndef PNG_NO_READ_BGR
+# define PNG_READ_BGR_SUPPORTED
+# endif
+# ifndef PNG_NO_READ_SWAP
+# define PNG_READ_SWAP_SUPPORTED
+# endif
+# ifndef PNG_NO_READ_PACKSWAP
+# define PNG_READ_PACKSWAP_SUPPORTED
+# endif
+# ifndef PNG_NO_READ_INVERT
+# define PNG_READ_INVERT_SUPPORTED
+# endif
+# ifndef PNG_NO_READ_QUANTIZE
+ /* Prior to libpng-1.4.0 this was PNG_READ_DITHER_SUPPORTED */
+# ifndef PNG_NO_READ_DITHER /* This migration aid will be removed */
+# define PNG_READ_QUANTIZE_SUPPORTED
+# endif
+# endif
+# ifndef PNG_NO_READ_BACKGROUND
+# define PNG_READ_BACKGROUND_SUPPORTED
+# endif
+# ifndef PNG_NO_READ_16_TO_8
+# define PNG_READ_16_TO_8_SUPPORTED
+# endif
+# ifndef PNG_NO_READ_FILLER
+# define PNG_READ_FILLER_SUPPORTED
+# endif
+# ifndef PNG_NO_READ_GAMMA
+# define PNG_READ_GAMMA_SUPPORTED
+# endif
+# ifndef PNG_NO_READ_GRAY_TO_RGB
+# define PNG_READ_GRAY_TO_RGB_SUPPORTED
+# endif
+# ifndef PNG_NO_READ_SWAP_ALPHA
+# define PNG_READ_SWAP_ALPHA_SUPPORTED
+# endif
+# ifndef PNG_NO_READ_INVERT_ALPHA
+# define PNG_READ_INVERT_ALPHA_SUPPORTED
+# endif
+# ifndef PNG_NO_READ_STRIP_ALPHA
+# define PNG_READ_STRIP_ALPHA_SUPPORTED
+# endif
+# ifndef PNG_NO_READ_USER_TRANSFORM
+# define PNG_READ_USER_TRANSFORM_SUPPORTED
+# endif
+# ifndef PNG_NO_READ_RGB_TO_GRAY
+# define PNG_READ_RGB_TO_GRAY_SUPPORTED
+# endif
+#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
+
+/* PNG_PROGRESSIVE_READ_NOT_SUPPORTED is deprecated. */
+#if !defined(PNG_NO_PROGRESSIVE_READ) && \
+ !defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */
+# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */
+#endif /* about interlacing capability! You'll */
+ /* still have interlacing unless you change the following define: */
+
+#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */
+
+/* PNG_NO_SEQUENTIAL_READ_SUPPORTED is deprecated. */
+#if !defined(PNG_NO_SEQUENTIAL_READ) && \
+ !defined(PNG_SEQUENTIAL_READ_SUPPORTED) && \
+ !defined(PNG_NO_SEQUENTIAL_READ_SUPPORTED)
+# define PNG_SEQUENTIAL_READ_SUPPORTED
+#endif
+
+#ifndef PNG_NO_READ_COMPOSITE_NODIV
+# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */
+# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */
+# endif
+#endif
+
+#if !defined(PNG_NO_GET_INT_32) || defined(PNG_READ_oFFS_SUPPORTED) || \
+ defined(PNG_READ_pCAL_SUPPORTED)
+# ifndef PNG_GET_INT_32_SUPPORTED
+# define PNG_GET_INT_32_SUPPORTED
+# endif
+#endif
+
+#endif /* PNG_READ_SUPPORTED */
+
+#ifdef PNG_WRITE_SUPPORTED
+
+/* PNG_WRITE_TRANSFORMS_NOT_SUPPORTED is deprecated. */
+#if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \
+ !defined(PNG_NO_WRITE_TRANSFORMS)
+# define PNG_WRITE_TRANSFORMS_SUPPORTED
+#endif
+
+#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
+# ifndef PNG_NO_WRITE_SHIFT
+# define PNG_WRITE_SHIFT_SUPPORTED
+# endif
+# ifndef PNG_NO_WRITE_PACK
+# define PNG_WRITE_PACK_SUPPORTED
+# endif
+# ifndef PNG_NO_WRITE_BGR
+# define PNG_WRITE_BGR_SUPPORTED
+# endif
+# ifndef PNG_NO_WRITE_SWAP
+# define PNG_WRITE_SWAP_SUPPORTED
+# endif
+# ifndef PNG_NO_WRITE_PACKSWAP
+# define PNG_WRITE_PACKSWAP_SUPPORTED
+# endif
+# ifndef PNG_NO_WRITE_INVERT
+# define PNG_WRITE_INVERT_SUPPORTED
+# endif
+# ifndef PNG_NO_WRITE_FILLER
+# define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */
+# endif
+# ifndef PNG_NO_WRITE_SWAP_ALPHA
+# define PNG_WRITE_SWAP_ALPHA_SUPPORTED
+# endif
+# ifndef PNG_NO_WRITE_INVERT_ALPHA
+# define PNG_WRITE_INVERT_ALPHA_SUPPORTED
+# endif
+# ifndef PNG_NO_WRITE_USER_TRANSFORM
+# define PNG_WRITE_USER_TRANSFORM_SUPPORTED
+# endif
+#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
+
+#if !defined(PNG_NO_WRITE_INTERLACING_SUPPORTED) && \
+ !defined(PNG_WRITE_INTERLACING_SUPPORTED)
+ /* This is not required for PNG-compliant encoders, but can cause
+ * trouble if left undefined
+ */
+# define PNG_WRITE_INTERLACING_SUPPORTED
+#endif
+
+#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \
+ !defined(PNG_WRITE_WEIGHTED_FILTER) && \
+ defined(PNG_FLOATING_POINT_SUPPORTED)
+# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
+#endif
+
+#ifndef PNG_NO_WRITE_FLUSH
+# define PNG_WRITE_FLUSH_SUPPORTED
+#endif
+
+#if !defined(PNG_NO_SAVE_INT_32) || defined(PNG_WRITE_oFFS_SUPPORTED) || \
+ defined(PNG_WRITE_pCAL_SUPPORTED)
+# ifndef PNG_SAVE_INT_32_SUPPORTED
+# define PNG_SAVE_INT_32_SUPPORTED
+# endif
+#endif
+
+#endif /* PNG_WRITE_SUPPORTED */
+
+#define PNG_NO_ERROR_NUMBERS
+
+#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
+ defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
+# ifndef PNG_NO_USER_TRANSFORM_PTR
+# define PNG_USER_TRANSFORM_PTR_SUPPORTED
+# endif
+#endif
+
+#if defined(PNG_STDIO_SUPPORTED) && !defined(PNG_TIME_RFC1123_SUPPORTED)
+# define PNG_TIME_RFC1123_SUPPORTED
+#endif
+
+/* This adds extra functions in pngget.c for accessing data from the
+ * info pointer (added in version 0.99)
+ * png_get_image_width()
+ * png_get_image_height()
+ * png_get_bit_depth()
+ * png_get_color_type()
+ * png_get_compression_type()
+ * png_get_filter_type()
+ * png_get_interlace_type()
+ * png_get_pixel_aspect_ratio()
+ * png_get_pixels_per_meter()
+ * png_get_x_offset_pixels()
+ * png_get_y_offset_pixels()
+ * png_get_x_offset_microns()
+ * png_get_y_offset_microns()
+ */
+#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED)
+# define PNG_EASY_ACCESS_SUPPORTED
+#endif
+
+/* Added at libpng-1.2.0 */
+#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED)
+# define PNG_USER_MEM_SUPPORTED
+#endif
+
+/* Added at libpng-1.2.6 */
+#ifndef PNG_NO_SET_USER_LIMITS
+# ifndef PNG_SET_USER_LIMITS_SUPPORTED
+# define PNG_SET_USER_LIMITS_SUPPORTED
+# endif
+ /* Feature added at libpng-1.4.0, this flag added at 1.4.1 */
+# ifndef PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED
+# define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED
+# endif
+ /* Feature added at libpng-1.4.1, this flag added at 1.4.1 */
+# ifndef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
+# define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
+# endif
+#endif
+
+/* Added at libpng-1.2.43 */
+#ifndef PNG_USER_LIMITS_SUPPORTED
+# ifndef PNG_NO_USER_LIMITS
+# define PNG_USER_LIMITS_SUPPORTED
+# endif
+#endif
+
+/* Added at libpng-1.0.16 and 1.2.6. To accept all valid PNGs no matter
+ * how large, set these two limits to 0x7fffffffL
+ */
+#ifndef PNG_USER_WIDTH_MAX
+# define PNG_USER_WIDTH_MAX 1000000L
+#endif
+#ifndef PNG_USER_HEIGHT_MAX
+# define PNG_USER_HEIGHT_MAX 1000000L
+#endif
+
+/* Added at libpng-1.2.43. To accept all valid PNGs no matter
+ * how large, set these two limits to 0.
+ */
+#ifndef PNG_USER_CHUNK_CACHE_MAX
+# define PNG_USER_CHUNK_CACHE_MAX 0
+#endif
+
+/* Added at libpng-1.2.43 */
+#ifndef PNG_USER_CHUNK_MALLOC_MAX
+# define PNG_USER_CHUNK_MALLOC_MAX 0
+#endif
+
+/* Added at libpng-1.4.0 */
+#if !defined(PNG_NO_IO_STATE) && !defined(PNG_IO_STATE_SUPPORTED)
+# define PNG_IO_STATE_SUPPORTED
+#endif
+
+#ifndef PNG_LITERAL_SHARP
+# define PNG_LITERAL_SHARP 0x23
+#endif
+#ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET
+# define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b
+#endif
+#ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET
+# define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d
+#endif
+#ifndef PNG_STRING_NEWLINE
+#define PNG_STRING_NEWLINE "\n"
+#endif
+
+/* These are currently experimental features, define them if you want */
+
+/* Very little testing */
+/*
+#ifdef PNG_READ_SUPPORTED
+# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
+# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
+# endif
+#endif
+*/
+
+/* This is only for PowerPC big-endian and 680x0 systems */
+/* some testing */
+/*
+#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED
+# define PNG_READ_BIG_ENDIAN_SUPPORTED
+#endif
+*/
+
+#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS)
+# define PNG_USE_READ_MACROS
+#endif
+
+/* Buggy compilers (e.g., gcc 2.7.2.2) need PNG_NO_POINTER_INDEXING */
+
+#if !defined(PNG_NO_POINTER_INDEXING) && \
+ !defined(PNG_POINTER_INDEXING_SUPPORTED)
+# define PNG_POINTER_INDEXING_SUPPORTED
+#endif
+
+
+/* Any chunks you are not interested in, you can undef here. The
+ * ones that allocate memory may be expecially important (hIST,
+ * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info
+ * a bit smaller.
+ */
+
+/* The size of the png_text structure changed in libpng-1.0.6 when
+ * iTXt support was added. iTXt support was turned off by default through
+ * libpng-1.2.x, to support old apps that malloc the png_text structure
+ * instead of calling png_set_text() and letting libpng malloc it. It
+ * was turned on by default in libpng-1.4.0.
+ */
+
+/* PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED is deprecated. */
+#if defined(PNG_READ_SUPPORTED) && \
+ !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
+ !defined(PNG_NO_READ_ANCILLARY_CHUNKS)
+# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
+#endif
+
+/* PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED is deprecated. */
+#if defined(PNG_WRITE_SUPPORTED) && \
+ !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
+ !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS)
+# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
+#endif
+
+#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
+
+#ifdef PNG_NO_READ_TEXT
+# define PNG_NO_READ_iTXt
+# define PNG_NO_READ_tEXt
+# define PNG_NO_READ_zTXt
+#endif
+
+#ifndef PNG_NO_READ_bKGD
+# define PNG_READ_bKGD_SUPPORTED
+# define PNG_bKGD_SUPPORTED
+#endif
+#ifndef PNG_NO_READ_cHRM
+# define PNG_READ_cHRM_SUPPORTED
+# define PNG_cHRM_SUPPORTED
+#endif
+#ifndef PNG_NO_READ_gAMA
+# define PNG_READ_gAMA_SUPPORTED
+# define PNG_gAMA_SUPPORTED
+#endif
+#ifndef PNG_NO_READ_hIST
+# define PNG_READ_hIST_SUPPORTED
+# define PNG_hIST_SUPPORTED
+#endif
+#ifndef PNG_NO_READ_iCCP
+# define PNG_READ_iCCP_SUPPORTED
+# define PNG_iCCP_SUPPORTED
+#endif
+#ifndef PNG_NO_READ_iTXt
+# ifndef PNG_READ_iTXt_SUPPORTED
+# define PNG_READ_iTXt_SUPPORTED
+# endif
+# ifndef PNG_iTXt_SUPPORTED
+# define PNG_iTXt_SUPPORTED
+# endif
+#endif
+#ifndef PNG_NO_READ_oFFs
+# define PNG_READ_oFFs_SUPPORTED
+# define PNG_oFFs_SUPPORTED
+#endif
+#ifndef PNG_NO_READ_pCAL
+# define PNG_READ_pCAL_SUPPORTED
+# define PNG_pCAL_SUPPORTED
+#endif
+#ifndef PNG_NO_READ_sCAL
+# define PNG_READ_sCAL_SUPPORTED
+# define PNG_sCAL_SUPPORTED
+#endif
+#ifndef PNG_NO_READ_pHYs
+# define PNG_READ_pHYs_SUPPORTED
+# define PNG_pHYs_SUPPORTED
+#endif
+#ifndef PNG_NO_READ_sBIT
+# define PNG_READ_sBIT_SUPPORTED
+# define PNG_sBIT_SUPPORTED
+#endif
+#ifndef PNG_NO_READ_sPLT
+# define PNG_READ_sPLT_SUPPORTED
+# define PNG_sPLT_SUPPORTED
+#endif
+#ifndef PNG_NO_READ_sRGB
+# define PNG_READ_sRGB_SUPPORTED
+# define PNG_sRGB_SUPPORTED
+#endif
+#ifndef PNG_NO_READ_tEXt
+# define PNG_READ_tEXt_SUPPORTED
+# define PNG_tEXt_SUPPORTED
+#endif
+#ifndef PNG_NO_READ_tIME
+# define PNG_READ_tIME_SUPPORTED
+# define PNG_tIME_SUPPORTED
+#endif
+#ifndef PNG_NO_READ_tRNS
+# define PNG_READ_tRNS_SUPPORTED
+# define PNG_tRNS_SUPPORTED
+#endif
+#ifndef PNG_NO_READ_zTXt
+# define PNG_READ_zTXt_SUPPORTED
+# define PNG_zTXt_SUPPORTED
+#endif
+#ifndef PNG_NO_READ_OPT_PLTE
+# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */
+#endif /* optional PLTE chunk in RGB and RGBA images */
+#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \
+ defined(PNG_READ_zTXt_SUPPORTED)
+# define PNG_READ_TEXT_SUPPORTED
+# define PNG_TEXT_SUPPORTED
+#endif
+
+#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */
+
+#ifndef PNG_NO_READ_UNKNOWN_CHUNKS
+# ifndef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
+# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
+# endif
+# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
+# define PNG_UNKNOWN_CHUNKS_SUPPORTED
+# endif
+# ifndef PNG_READ_USER_CHUNKS_SUPPORTED
+# define PNG_READ_USER_CHUNKS_SUPPORTED
+# endif
+#endif
+#ifndef PNG_NO_READ_USER_CHUNKS
+# ifndef PNG_READ_USER_CHUNKS_SUPPORTED
+# define PNG_READ_USER_CHUNKS_SUPPORTED
+# endif
+# ifndef PNG_USER_CHUNKS_SUPPORTED
+# define PNG_USER_CHUNKS_SUPPORTED
+# endif
+#endif
+#ifndef PNG_NO_HANDLE_AS_UNKNOWN
+# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
+# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
+# endif
+#endif
+
+#ifdef PNG_WRITE_SUPPORTED
+#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
+
+#ifdef PNG_NO_WRITE_TEXT
+# define PNG_NO_WRITE_iTXt
+# define PNG_NO_WRITE_tEXt
+# define PNG_NO_WRITE_zTXt
+#endif
+#ifndef PNG_NO_WRITE_bKGD
+# define PNG_WRITE_bKGD_SUPPORTED
+# ifndef PNG_bKGD_SUPPORTED
+# define PNG_bKGD_SUPPORTED
+# endif
+#endif
+#ifndef PNG_NO_WRITE_cHRM
+# define PNG_WRITE_cHRM_SUPPORTED
+# ifndef PNG_cHRM_SUPPORTED
+# define PNG_cHRM_SUPPORTED
+# endif
+#endif
+#ifndef PNG_NO_WRITE_gAMA
+# define PNG_WRITE_gAMA_SUPPORTED
+# ifndef PNG_gAMA_SUPPORTED
+# define PNG_gAMA_SUPPORTED
+# endif
+#endif
+#ifndef PNG_NO_WRITE_hIST
+# define PNG_WRITE_hIST_SUPPORTED
+# ifndef PNG_hIST_SUPPORTED
+# define PNG_hIST_SUPPORTED
+# endif
+#endif
+#ifndef PNG_NO_WRITE_iCCP
+# define PNG_WRITE_iCCP_SUPPORTED
+# ifndef PNG_iCCP_SUPPORTED
+# define PNG_iCCP_SUPPORTED
+# endif
+#endif
+#ifndef PNG_NO_WRITE_iTXt
+# ifndef PNG_WRITE_iTXt_SUPPORTED
+# define PNG_WRITE_iTXt_SUPPORTED
+# endif
+# ifndef PNG_iTXt_SUPPORTED
+# define PNG_iTXt_SUPPORTED
+# endif
+#endif
+#ifndef PNG_NO_WRITE_oFFs
+# define PNG_WRITE_oFFs_SUPPORTED
+# ifndef PNG_oFFs_SUPPORTED
+# define PNG_oFFs_SUPPORTED
+# endif
+#endif
+#ifndef PNG_NO_WRITE_pCAL
+# define PNG_WRITE_pCAL_SUPPORTED
+# ifndef PNG_pCAL_SUPPORTED
+# define PNG_pCAL_SUPPORTED
+# endif
+#endif
+#ifndef PNG_NO_WRITE_sCAL
+# define PNG_WRITE_sCAL_SUPPORTED
+# ifndef PNG_sCAL_SUPPORTED
+# define PNG_sCAL_SUPPORTED
+# endif
+#endif
+#ifndef PNG_NO_WRITE_pHYs
+# define PNG_WRITE_pHYs_SUPPORTED
+# ifndef PNG_pHYs_SUPPORTED
+# define PNG_pHYs_SUPPORTED
+# endif
+#endif
+#ifndef PNG_NO_WRITE_sBIT
+# define PNG_WRITE_sBIT_SUPPORTED
+# ifndef PNG_sBIT_SUPPORTED
+# define PNG_sBIT_SUPPORTED
+# endif
+#endif
+#ifndef PNG_NO_WRITE_sPLT
+# define PNG_WRITE_sPLT_SUPPORTED
+# ifndef PNG_sPLT_SUPPORTED
+# define PNG_sPLT_SUPPORTED
+# endif
+#endif
+#ifndef PNG_NO_WRITE_sRGB
+# define PNG_WRITE_sRGB_SUPPORTED
+# ifndef PNG_sRGB_SUPPORTED
+# define PNG_sRGB_SUPPORTED
+# endif
+#endif
+#ifndef PNG_NO_WRITE_tEXt
+# define PNG_WRITE_tEXt_SUPPORTED
+# ifndef PNG_tEXt_SUPPORTED
+# define PNG_tEXt_SUPPORTED
+# endif
+#endif
+#ifndef PNG_NO_WRITE_tIME
+# define PNG_WRITE_tIME_SUPPORTED
+# ifndef PNG_tIME_SUPPORTED
+# define PNG_tIME_SUPPORTED
+# endif
+#endif
+#ifndef PNG_NO_WRITE_tRNS
+# define PNG_WRITE_tRNS_SUPPORTED
+# ifndef PNG_tRNS_SUPPORTED
+# define PNG_tRNS_SUPPORTED
+# endif
+#endif
+#ifndef PNG_NO_WRITE_zTXt
+# define PNG_WRITE_zTXt_SUPPORTED
+# ifndef PNG_zTXt_SUPPORTED
+# define PNG_zTXt_SUPPORTED
+# endif
+#endif
+#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
+ defined(PNG_WRITE_zTXt_SUPPORTED)
+# define PNG_WRITE_TEXT_SUPPORTED
+# ifndef PNG_TEXT_SUPPORTED
+# define PNG_TEXT_SUPPORTED
+# endif
+#endif
+
+#ifdef PNG_WRITE_tIME_SUPPORTED
+# ifndef PNG_NO_CONVERT_tIME
+# ifndef _WIN32_WCE
+/* The "tm" structure is not supported on WindowsCE */
+# ifndef PNG_CONVERT_tIME_SUPPORTED
+# define PNG_CONVERT_tIME_SUPPORTED
+# endif
+# endif
+# endif
+#endif
+
+#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */
+
+#ifndef PNG_NO_WRITE_FILTER
+# ifndef PNG_WRITE_FILTER_SUPPORTED
+# define PNG_WRITE_FILTER_SUPPORTED
+# endif
+#endif
+
+#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS
+# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
+# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
+# define PNG_UNKNOWN_CHUNKS_SUPPORTED
+# endif
+#endif
+#ifndef PNG_NO_HANDLE_AS_UNKNOWN
+# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
+# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
+# endif
+#endif
+#endif /* PNG_WRITE_SUPPORTED */
+
+/* Turn this off to disable png_read_png() and
+ * png_write_png() and leave the row_pointers member
+ * out of the info structure.
+ */
+#ifndef PNG_NO_INFO_IMAGE
+# define PNG_INFO_IMAGE_SUPPORTED
+#endif
+
+/* Need the time information for converting tIME chunks */
+#ifdef PNG_CONVERT_tIME_SUPPORTED
+ /* "time.h" functions are not supported on WindowsCE */
+# include <time.h>
+#endif
+
+/* Some typedefs to get us started. These should be safe on most of the
+ * common platforms. The typedefs should be at least as large as the
+ * numbers suggest (a png_uint_32 must be at least 32 bits long), but they
+ * don't have to be exactly that size. Some compilers dislike passing
+ * unsigned shorts as function parameters, so you may be better off using
+ * unsigned int for png_uint_16.
+ */
+
+#if defined(INT_MAX) && (INT_MAX > 0x7ffffffeL)
+typedef unsigned int png_uint_32;
+typedef int png_int_32;
+#else
+typedef unsigned long png_uint_32;
+typedef long png_int_32;
+#endif
+typedef unsigned short png_uint_16;
+typedef short png_int_16;
+typedef unsigned char png_byte;
+
+#ifdef PNG_NO_SIZE_T
+ typedef unsigned int png_size_t;
+#else
+ typedef size_t png_size_t;
+#endif
+#define png_sizeof(x) (sizeof (x))
+
+/* The following is needed for medium model support. It cannot be in the
+ * pngpriv.h header. Needs modification for other compilers besides
+ * MSC. Model independent support declares all arrays and pointers to be
+ * large using the far keyword. The zlib version used must also support
+ * model independent data. As of version zlib 1.0.4, the necessary changes
+ * have been made in zlib. The USE_FAR_KEYWORD define triggers other
+ * changes that are needed. (Tim Wegner)
+ */
+
+/* Separate compiler dependencies (problem here is that zlib.h always
+ * defines FAR. (SJT)
+ */
+#ifdef __BORLANDC__
+# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
+# define LDATA 1
+# else
+# define LDATA 0
+# endif
+ /* GRR: why is Cygwin in here? Cygwin is not Borland C... */
+# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__)
+# define PNG_MAX_MALLOC_64K
+# if (LDATA != 1)
+# ifndef FAR
+# define FAR __far
+# endif
+# define USE_FAR_KEYWORD
+# endif /* LDATA != 1 */
+ /* Possibly useful for moving data out of default segment.
+ * Uncomment it if you want. Could also define FARDATA as
+ * const if your compiler supports it. (SJT)
+# define FARDATA FAR
+ */
+# endif /* __WIN32__, __FLAT__, __CYGWIN__ */
+#endif /* __BORLANDC__ */
+
+
+/* Suggest testing for specific compiler first before testing for
+ * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM,
+ * making reliance oncertain keywords suspect. (SJT)
+ */
+
+/* MSC Medium model */
+#ifdef FAR
+# ifdef M_I86MM
+# define USE_FAR_KEYWORD
+# define FARDATA FAR
+# include <dos.h>
+# endif
+#endif
+
+/* SJT: default case */
+#ifndef FAR
+# define FAR
+#endif
+
+/* At this point FAR is always defined */
+#ifndef FARDATA
+# define FARDATA
+#endif
+
+/* Typedef for floating-point numbers that are converted
+ to fixed-point with a multiple of 100,000, e.g., int_gamma */
+typedef png_int_32 png_fixed_point;
+
+/* Add typedefs for pointers */
+typedef void FAR * png_voidp;
+typedef png_byte FAR * png_bytep;
+typedef png_uint_32 FAR * png_uint_32p;
+typedef png_int_32 FAR * png_int_32p;
+typedef png_uint_16 FAR * png_uint_16p;
+typedef png_int_16 FAR * png_int_16p;
+typedef PNG_CONST char FAR * png_const_charp;
+typedef char FAR * png_charp;
+typedef png_fixed_point FAR * png_fixed_point_p;
+
+#ifndef PNG_NO_STDIO
+typedef FILE * png_FILE_p;
+#endif
+
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+typedef double FAR * png_doublep;
+#endif
+
+/* Pointers to pointers; i.e. arrays */
+typedef png_byte FAR * FAR * png_bytepp;
+typedef png_uint_32 FAR * FAR * png_uint_32pp;
+typedef png_int_32 FAR * FAR * png_int_32pp;
+typedef png_uint_16 FAR * FAR * png_uint_16pp;
+typedef png_int_16 FAR * FAR * png_int_16pp;
+typedef PNG_CONST char FAR * FAR * png_const_charpp;
+typedef char FAR * FAR * png_charpp;
+typedef png_fixed_point FAR * FAR * png_fixed_point_pp;
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+typedef double FAR * FAR * png_doublepp;
+#endif
+
+/* Pointers to pointers to pointers; i.e., pointer to array */
+typedef char FAR * FAR * FAR * png_charppp;
+
+/* Define PNG_BUILD_DLL if the module being built is a Windows
+ * LIBPNG DLL.
+ *
+ * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL.
+ * It is equivalent to Microsoft predefined macro _DLL that is
+ * automatically defined when you compile using the share
+ * version of the CRT (C Run-Time library)
+ *
+ * The cygwin mods make this behavior a little different:
+ * Define PNG_BUILD_DLL if you are building a dll for use with cygwin
+ * Define PNG_STATIC if you are building a static library for use with cygwin,
+ * -or- if you are building an application that you want to link to the
+ * static library.
+ * PNG_USE_DLL is defined by default (no user action needed) unless one of
+ * the other flags is defined.
+ */
+
+#if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL))
+# define PNG_DLL
+#endif
+
+/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall",
+ * you may get warnings regarding the linkage of png_zalloc and png_zfree.
+ * Don't ignore those warnings; you must also reset the default calling
+ * convention in your compiler to match your PNGAPI, and you must build
+ * zlib and your applications the same way you build libpng.
+ */
+
+#ifdef __CYGWIN__
+# undef PNGAPI
+# define PNGAPI __cdecl
+# undef PNG_IMPEXP
+# define PNG_IMPEXP
+#endif
+
+#ifdef __WATCOMC__
+# ifndef PNGAPI
+# define PNGAPI
+# endif
+#endif
+
+#if defined(__MINGW32__) && !defined(PNG_MODULEDEF)
+# ifndef PNG_NO_MODULEDEF
+# define PNG_NO_MODULEDEF
+# endif
+#endif
+
+#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF)
+# define PNG_IMPEXP
+#endif
+
+#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \
+ (( defined(_Windows) || defined(_WINDOWS) || \
+ defined(WIN32) || defined(_WIN32) || defined(__WIN32__) ))
+
+# ifndef PNGAPI
+# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
+# define PNGAPI __cdecl
+# else
+# define PNGAPI _cdecl
+# endif
+# endif
+
+# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \
+ 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */)
+# define PNG_IMPEXP
+# endif
+
+# ifndef PNG_IMPEXP
+
+# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol
+# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol
+
+ /* Borland/Microsoft */
+# if defined(_MSC_VER) || defined(__BORLANDC__)
+# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500)
+# define PNG_EXPORT PNG_EXPORT_TYPE1
+# else
+# define PNG_EXPORT PNG_EXPORT_TYPE2
+# ifdef PNG_BUILD_DLL
+# define PNG_IMPEXP __export
+# else
+# define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in VC++ */
+# endif /* Exists in Borland C++ for
+ C++ classes (== huge) */
+# endif
+# endif
+
+# ifndef PNG_IMPEXP
+# ifdef PNG_BUILD_DLL
+# define PNG_IMPEXP __declspec(dllexport)
+# else
+# define PNG_IMPEXP __declspec(dllimport)
+# endif
+# endif
+# endif /* PNG_IMPEXP */
+#else /* !(DLL || non-cygwin WINDOWS) */
+# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
+# ifndef PNGAPI
+# define PNGAPI _System
+# endif
+# else
+# if 0 /* ... other platforms, with other meanings */
+# endif
+# endif
+#endif
+
+#ifndef PNGAPI
+# define PNGAPI
+#endif
+#ifndef PNG_IMPEXP
+# define PNG_IMPEXP
+#endif
+
+#ifdef PNG_BUILDSYMS
+# ifndef PNG_EXPORT
+# define PNG_EXPORT(type,symbol) PNG_FUNCTION_EXPORT symbol END
+# endif
+#endif
+
+#ifndef PNG_EXPORT
+# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol
+#endif
+
+#define PNG_USE_LOCAL_ARRAYS /* Not used in libpng, defined for legacy apps */
+
+/* Support for compiler specific function attributes. These are used
+ * so that where compiler support is available incorrect use of API
+ * functions in png.h will generate compiler warnings.
+ *
+ * Added at libpng-1.2.41.
+ */
+
+#ifndef PNG_NO_PEDANTIC_WARNINGS
+# ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED
+# define PNG_PEDANTIC_WARNINGS_SUPPORTED
+# endif
+#endif
+
+#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED
+/* Support for compiler specific function attributes. These are used
+ * so that where compiler support is available incorrect use of API
+ * functions in png.h will generate compiler warnings. Added at libpng
+ * version 1.2.41.
+ */
+# ifdef __GNUC__
+# ifndef PNG_USE_RESULT
+# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
+# endif
+# ifndef PNG_NORETURN
+# define PNG_NORETURN __attribute__((__noreturn__))
+# endif
+# ifndef PNG_ALLOCATED
+# define PNG_ALLOCATED __attribute__((__malloc__))
+# endif
+
+ /* This specifically protects structure members that should only be
+ * accessed from within the library, therefore should be empty during
+ * a library build.
+ */
+# ifndef PNG_DEPRECATED
+# define PNG_DEPRECATED __attribute__((__deprecated__))
+# endif
+# ifndef PNG_DEPSTRUCT
+# define PNG_DEPSTRUCT __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 /* PNG_PRIVATE */
+# endif /* __GNUC__ */
+#endif /* PNG_PEDANTIC_WARNINGS */
+
+#ifndef PNG_DEPRECATED
+# define PNG_DEPRECATED /* Use of this function is deprecated */
+#endif
+#ifndef PNG_USE_RESULT
+# define PNG_USE_RESULT /* The result of this function must be checked */
+#endif
+#ifndef PNG_NORETURN
+# define PNG_NORETURN /* This function does not return */
+#endif
+#ifndef PNG_ALLOCATED
+# define PNG_ALLOCATED /* The result of the function is new memory */
+#endif
+#ifndef PNG_DEPSTRUCT
+# define PNG_DEPSTRUCT /* Access to this struct member is deprecated */
+#endif
+#ifndef PNG_PRIVATE
+# define PNG_PRIVATE /* This is a private libpng function */
+#endif
+
+/* Users may want to use these so they are not private. Any library
+ * functions that are passed far data must be model-independent.
+ */
+
+/* memory model/platform independent fns */
+#ifndef PNG_ABORT
+# if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_))
+# define PNG_ABORT() ExitProcess(0)
+# else
+# define PNG_ABORT() abort()
+# endif
+#endif
+
+#ifdef USE_FAR_KEYWORD
+/* Use this to make far-to-near assignments */
+# define CHECK 1
+# define NOCHECK 0
+# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))
+# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
+# define png_strcpy _fstrcpy
+# define png_strncpy _fstrncpy /* Added to v 1.2.6 */
+# define png_strlen _fstrlen
+# define png_memcmp _fmemcmp /* SJT: added */
+# define png_memcpy _fmemcpy
+# define png_memset _fmemset
+# define png_sprintf sprintf
+#else
+# if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_))
+# /* Favor Windows over C runtime fns */
+# define CVT_PTR(ptr) (ptr)
+# define CVT_PTR_NOCHECK(ptr) (ptr)
+# define png_strcpy lstrcpyA
+# define png_strncpy lstrcpynA
+# define png_strlen lstrlenA
+# define png_memcmp memcmp
+# define png_memcpy CopyMemory
+# define png_memset memset
+# define png_sprintf wsprintfA
+# else
+# define CVT_PTR(ptr) (ptr)
+# define CVT_PTR_NOCHECK(ptr) (ptr)
+# define png_strcpy strcpy
+# define png_strncpy strncpy /* Added to v 1.2.6 */
+# define png_strlen strlen
+# define png_memcmp memcmp /* SJT: added */
+# define png_memcpy memcpy
+# define png_memset memset
+# define png_sprintf sprintf
+# endif
+#endif
+
+#ifndef PNG_NO_SNPRINTF
+# ifdef _MSC_VER
+# define png_snprintf _snprintf /* Added to v 1.2.19 */
+# define png_snprintf2 _snprintf
+# define png_snprintf6 _snprintf
+# else
+# define png_snprintf snprintf /* Added to v 1.2.19 */
+# define png_snprintf2 snprintf
+# define png_snprintf6 snprintf
+# endif
+#else
+ /* You don't have or don't want to use snprintf(). Caution: Using
+ * sprintf instead of snprintf exposes your application to accidental
+ * or malevolent buffer overflows. If you don't have snprintf()
+ * as a general rule you should provide one (you can get one from
+ * Portable OpenSSH).
+ */
+# define png_snprintf(s1,n,fmt,x1) png_sprintf(s1,fmt,x1)
+# define png_snprintf2(s1,n,fmt,x1,x2) png_sprintf(s1,fmt,x1,x2)
+# define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \
+ png_sprintf(s1,fmt,x1,x2,x3,x4,x5,x6)
+#endif
+
+/* png_alloc_size_t is guaranteed to be no smaller than png_size_t,
+ * and no smaller than png_uint_32. Casts from png_size_t or png_uint_32
+ * to png_alloc_size_t are not necessary; in fact, it is recommended
+ * not to use them at all so that the compiler can complain when something
+ * turns out to be problematic.
+ * Casts in the other direction (from png_alloc_size_t to png_size_t or
+ * png_uint_32) should be explicitly applied; however, we do not expect
+ * to encounter practical situations that require such conversions.
+ */
+#if defined(__TURBOC__) && !defined(__FLAT__)
+ typedef unsigned long png_alloc_size_t;
+#else
+# if defined(_MSC_VER) && defined(MAXSEG_64K)
+ typedef unsigned long png_alloc_size_t;
+# else
+ /* This is an attempt to detect an old Windows system where (int) is
+ * actually 16 bits, in that case png_malloc must have an argument with a
+ * bigger size to accomodate the requirements of the library.
+ */
+# if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_)) && \
+ (!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL)
+ typedef DWORD png_alloc_size_t;
+# else
+ typedef png_size_t png_alloc_size_t;
+# endif
+# endif
+#endif
+/* End of memory model/platform independent support */
+
+/* Just a little check that someone hasn't tried to define something
+ * contradictory.
+ */
+#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K)
+# undef PNG_ZBUF_SIZE
+# define PNG_ZBUF_SIZE 65536L
+#endif
+
+
+/* Added at libpng-1.2.8 */
+#endif /* PNG_VERSION_INFO_ONLY */
+
+#endif /* PNGCONF_H */
--- /dev/null
+/* zconf.h -- configuration of the zlib compression library\r
+ * Copyright (C) 1995-2005 Jean-loup Gailly.\r
+ * For conditions of distribution and use, see copyright notice in zlib.h\r
+ */\r
+\r
+/* @(#) $Id$ */\r
+\r
+#ifndef ZCONF_H\r
+#define ZCONF_H\r
+\r
+/*\r
+ * If you *really* need a unique prefix for all types and library functions,\r
+ * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.\r
+ */\r
+#ifdef Z_PREFIX\r
+# define deflateInit_ z_deflateInit_\r
+# define deflate z_deflate\r
+# define deflateEnd z_deflateEnd\r
+# define inflateInit_ z_inflateInit_\r
+# define inflate z_inflate\r
+# define inflateEnd z_inflateEnd\r
+# define deflateInit2_ z_deflateInit2_\r
+# define deflateSetDictionary z_deflateSetDictionary\r
+# define deflateCopy z_deflateCopy\r
+# define deflateReset z_deflateReset\r
+# define deflateParams z_deflateParams\r
+# define deflateBound z_deflateBound\r
+# define deflatePrime z_deflatePrime\r
+# define inflateInit2_ z_inflateInit2_\r
+# define inflateSetDictionary z_inflateSetDictionary\r
+# define inflateSync z_inflateSync\r
+# define inflateSyncPoint z_inflateSyncPoint\r
+# define inflateCopy z_inflateCopy\r
+# define inflateReset z_inflateReset\r
+# define inflateBack z_inflateBack\r
+# define inflateBackEnd z_inflateBackEnd\r
+# define compress z_compress\r
+# define compress2 z_compress2\r
+# define compressBound z_compressBound\r
+# define uncompress z_uncompress\r
+# define adler32 z_adler32\r
+# define crc32 z_crc32\r
+# define get_crc_table z_get_crc_table\r
+# define zError z_zError\r
+\r
+# define alloc_func z_alloc_func\r
+# define free_func z_free_func\r
+# define in_func z_in_func\r
+# define out_func z_out_func\r
+# define Byte z_Byte\r
+# define uInt z_uInt\r
+# define uLong z_uLong\r
+# define Bytef z_Bytef\r
+# define charf z_charf\r
+# define intf z_intf\r
+# define uIntf z_uIntf\r
+# define uLongf z_uLongf\r
+# define voidpf z_voidpf\r
+# define voidp z_voidp\r
+#endif\r
+\r
+#if defined(__MSDOS__) && !defined(MSDOS)\r
+# define MSDOS\r
+#endif\r
+#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)\r
+# define OS2\r
+#endif\r
+#if defined(_WINDOWS) && !defined(WINDOWS)\r
+# define WINDOWS\r
+#endif\r
+#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)\r
+# ifndef WIN32\r
+# define WIN32\r
+# endif\r
+#endif\r
+#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)\r
+# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)\r
+# ifndef SYS16BIT\r
+# define SYS16BIT\r
+# endif\r
+# endif\r
+#endif\r
+\r
+/*\r
+ * Compile with -DMAXSEG_64K if the alloc function cannot allocate more\r
+ * than 64k bytes at a time (needed on systems with 16-bit int).\r
+ */\r
+#ifdef SYS16BIT\r
+# define MAXSEG_64K\r
+#endif\r
+#ifdef MSDOS\r
+# define UNALIGNED_OK\r
+#endif\r
+\r
+#ifdef __STDC_VERSION__\r
+# ifndef STDC\r
+# define STDC\r
+# endif\r
+# if __STDC_VERSION__ >= 199901L\r
+# ifndef STDC99\r
+# define STDC99\r
+# endif\r
+# endif\r
+#endif\r
+#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))\r
+# define STDC\r
+#endif\r
+#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))\r
+# define STDC\r
+#endif\r
+#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))\r
+# define STDC\r
+#endif\r
+#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))\r
+# define STDC\r
+#endif\r
+\r
+#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */\r
+# define STDC\r
+#endif\r
+\r
+#ifndef STDC\r
+# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */\r
+# define const /* note: need a more gentle solution here */\r
+# endif\r
+#endif\r
+\r
+/* Some Mac compilers merge all .h files incorrectly: */\r
+#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)\r
+# define NO_DUMMY_DECL\r
+#endif\r
+\r
+/* Maximum value for memLevel in deflateInit2 */\r
+#ifndef MAX_MEM_LEVEL\r
+# ifdef MAXSEG_64K\r
+# define MAX_MEM_LEVEL 8\r
+# else\r
+# define MAX_MEM_LEVEL 9\r
+# endif\r
+#endif\r
+\r
+/* Maximum value for windowBits in deflateInit2 and inflateInit2.\r
+ * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files\r
+ * created by gzip. (Files created by minigzip can still be extracted by\r
+ * gzip.)\r
+ */\r
+#ifndef MAX_WBITS\r
+# define MAX_WBITS 15 /* 32K LZ77 window */\r
+#endif\r
+\r
+/* The memory requirements for deflate are (in bytes):\r
+ (1 << (windowBits+2)) + (1 << (memLevel+9))\r
+ that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)\r
+ plus a few kilobytes for small objects. For example, if you want to reduce\r
+ the default memory requirements from 256K to 128K, compile with\r
+ make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"\r
+ Of course this will generally degrade compression (there's no free lunch).\r
+\r
+ The memory requirements for inflate are (in bytes) 1 << windowBits\r
+ that is, 32K for windowBits=15 (default value) plus a few kilobytes\r
+ for small objects.\r
+*/\r
+\r
+ /* Type declarations */\r
+\r
+#ifndef OF /* function prototypes */\r
+# ifdef STDC\r
+# define OF(args) args\r
+# else\r
+# define OF(args) ()\r
+# endif\r
+#endif\r
+\r
+/* The following definitions for FAR are needed only for MSDOS mixed\r
+ * model programming (small or medium model with some far allocations).\r
+ * This was tested only with MSC; for other MSDOS compilers you may have\r
+ * to define NO_MEMCPY in zutil.h. If you don't need the mixed model,\r
+ * just define FAR to be empty.\r
+ */\r
+#ifdef SYS16BIT\r
+# if defined(M_I86SM) || defined(M_I86MM)\r
+ /* MSC small or medium model */\r
+# define SMALL_MEDIUM\r
+# ifdef _MSC_VER\r
+# define FAR _far\r
+# else\r
+# define FAR far\r
+# endif\r
+# endif\r
+# if (defined(__SMALL__) || defined(__MEDIUM__))\r
+ /* Turbo C small or medium model */\r
+# define SMALL_MEDIUM\r
+# ifdef __BORLANDC__\r
+# define FAR _far\r
+# else\r
+# define FAR far\r
+# endif\r
+# endif\r
+#endif\r
+\r
+#if defined(WINDOWS) || defined(WIN32)\r
+ /* If building or using zlib as a DLL, define ZLIB_DLL.\r
+ * This is not mandatory, but it offers a little performance increase.\r
+ */\r
+# ifdef ZLIB_DLL\r
+# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))\r
+# ifdef ZLIB_INTERNAL\r
+# define ZEXTERN extern __declspec(dllexport)\r
+# else\r
+# define ZEXTERN extern __declspec(dllimport)\r
+# endif\r
+# endif\r
+# endif /* ZLIB_DLL */\r
+ /* If building or using zlib with the WINAPI/WINAPIV calling convention,\r
+ * define ZLIB_WINAPI.\r
+ * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.\r
+ */\r
+# ifdef ZLIB_WINAPI\r
+# ifdef FAR\r
+# undef FAR\r
+# endif\r
+# include <windows.h>\r
+ /* No need for _export, use ZLIB.DEF instead. */\r
+ /* For complete Windows compatibility, use WINAPI, not __stdcall. */\r
+# define ZEXPORT WINAPI\r
+# ifdef WIN32\r
+# define ZEXPORTVA WINAPIV\r
+# else\r
+# define ZEXPORTVA FAR CDECL\r
+# endif\r
+# endif\r
+#endif\r
+\r
+#if defined (__BEOS__)\r
+# ifdef ZLIB_DLL\r
+# ifdef ZLIB_INTERNAL\r
+# define ZEXPORT __declspec(dllexport)\r
+# define ZEXPORTVA __declspec(dllexport)\r
+# else\r
+# define ZEXPORT __declspec(dllimport)\r
+# define ZEXPORTVA __declspec(dllimport)\r
+# endif\r
+# endif\r
+#endif\r
+\r
+#ifndef ZEXTERN\r
+# define ZEXTERN extern\r
+#endif\r
+#ifndef ZEXPORT\r
+# define ZEXPORT\r
+#endif\r
+#ifndef ZEXPORTVA\r
+# define ZEXPORTVA\r
+#endif\r
+\r
+#ifndef FAR\r
+# define FAR\r
+#endif\r
+\r
+#if !defined(__MACTYPES__)\r
+typedef unsigned char Byte; /* 8 bits */\r
+#endif\r
+typedef unsigned int uInt; /* 16 bits or more */\r
+typedef unsigned long uLong; /* 32 bits or more */\r
+\r
+#ifdef SMALL_MEDIUM\r
+ /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */\r
+# define Bytef Byte FAR\r
+#else\r
+ typedef Byte FAR Bytef;\r
+#endif\r
+typedef char FAR charf;\r
+typedef int FAR intf;\r
+typedef uInt FAR uIntf;\r
+typedef uLong FAR uLongf;\r
+\r
+#ifdef STDC\r
+ typedef void const *voidpc;\r
+ typedef void FAR *voidpf;\r
+ typedef void *voidp;\r
+#else\r
+ typedef Byte const *voidpc;\r
+ typedef Byte FAR *voidpf;\r
+ typedef Byte *voidp;\r
+#endif\r
+\r
+#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */\r
+# include <sys/types.h> /* for off_t */\r
+# include <unistd.h> /* for SEEK_* and off_t */\r
+# ifdef VMS\r
+# include <unixio.h> /* for off_t */\r
+# endif\r
+# define z_off_t off_t\r
+#endif\r
+#ifndef SEEK_SET\r
+# define SEEK_SET 0 /* Seek from beginning of file. */\r
+# define SEEK_CUR 1 /* Seek from current position. */\r
+# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */\r
+#endif\r
+#ifndef z_off_t\r
+# define z_off_t long\r
+#endif\r
+\r
+#if defined(__OS400__)\r
+# define NO_vsnprintf\r
+#endif\r
+\r
+#if defined(__MVS__)\r
+# define NO_vsnprintf\r
+# ifdef FAR\r
+# undef FAR\r
+# endif\r
+#endif\r
+\r
+/* MVS linker does not support external names larger than 8 bytes */\r
+#if defined(__MVS__)\r
+# pragma map(deflateInit_,"DEIN")\r
+# pragma map(deflateInit2_,"DEIN2")\r
+# pragma map(deflateEnd,"DEEND")\r
+# pragma map(deflateBound,"DEBND")\r
+# pragma map(inflateInit_,"ININ")\r
+# pragma map(inflateInit2_,"ININ2")\r
+# pragma map(inflateEnd,"INEND")\r
+# pragma map(inflateSync,"INSY")\r
+# pragma map(inflateSetDictionary,"INSEDI")\r
+# pragma map(compressBound,"CMBND")\r
+# pragma map(inflate_table,"INTABL")\r
+# pragma map(inflate_fast,"INFA")\r
+# pragma map(inflate_copyright,"INCOPY")\r
+#endif\r
+\r
+#endif /* ZCONF_H */\r
--- /dev/null
+/* zlib.h -- interface of the 'zlib' general purpose compression library\r
+ version 1.2.3, July 18th, 2005\r
+\r
+ Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler\r
+\r
+ This software is provided 'as-is', without any express or implied\r
+ warranty. In no event will the authors be held liable for any damages\r
+ arising from the use of this software.\r
+\r
+ Permission is granted to anyone to use this software for any purpose,\r
+ including commercial applications, and to alter it and redistribute it\r
+ freely, subject to the following restrictions:\r
+\r
+ 1. The origin of this software must not be misrepresented; you must not\r
+ claim that you wrote the original software. If you use this software\r
+ in a product, an acknowledgment in the product documentation would be\r
+ appreciated but is not required.\r
+ 2. Altered source versions must be plainly marked as such, and must not be\r
+ misrepresented as being the original software.\r
+ 3. This notice may not be removed or altered from any source distribution.\r
+\r
+ Jean-loup Gailly Mark Adler\r
+ jloup@gzip.org madler@alumni.caltech.edu\r
+\r
+\r
+ The data format used by the zlib library is described by RFCs (Request for\r
+ Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt\r
+ (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).\r
+*/\r
+\r
+#ifndef ZLIB_H\r
+#define ZLIB_H\r
+\r
+#include "zconf.h"\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+#define ZLIB_VERSION "1.2.3"\r
+#define ZLIB_VERNUM 0x1230\r
+\r
+/*\r
+ The 'zlib' compression library provides in-memory compression and\r
+ decompression functions, including integrity checks of the uncompressed\r
+ data. This version of the library supports only one compression method\r
+ (deflation) but other algorithms will be added later and will have the same\r
+ stream interface.\r
+\r
+ Compression can be done in a single step if the buffers are large\r
+ enough (for example if an input file is mmap'ed), or can be done by\r
+ repeated calls of the compression function. In the latter case, the\r
+ application must provide more input and/or consume the output\r
+ (providing more output space) before each call.\r
+\r
+ The compressed data format used by default by the in-memory functions is\r
+ the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped\r
+ around a deflate stream, which is itself documented in RFC 1951.\r
+\r
+ The library also supports reading and writing files in gzip (.gz) format\r
+ with an interface similar to that of stdio using the functions that start\r
+ with "gz". The gzip format is different from the zlib format. gzip is a\r
+ gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.\r
+\r
+ This library can optionally read and write gzip streams in memory as well.\r
+\r
+ The zlib format was designed to be compact and fast for use in memory\r
+ and on communications channels. The gzip format was designed for single-\r
+ file compression on file systems, has a larger header than zlib to maintain\r
+ directory information, and uses a different, slower check method than zlib.\r
+\r
+ The library does not install any signal handler. The decoder checks\r
+ the consistency of the compressed data, so the library should never\r
+ crash even in case of corrupted input.\r
+*/\r
+\r
+typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));\r
+typedef void (*free_func) OF((voidpf opaque, voidpf address));\r
+\r
+struct internal_state;\r
+\r
+typedef struct z_stream_s {\r
+ Bytef *next_in; /* next input byte */\r
+ uInt avail_in; /* number of bytes available at next_in */\r
+ uLong total_in; /* total nb of input bytes read so far */\r
+\r
+ Bytef *next_out; /* next output byte should be put there */\r
+ uInt avail_out; /* remaining free space at next_out */\r
+ uLong total_out; /* total nb of bytes output so far */\r
+\r
+ char *msg; /* last error message, NULL if no error */\r
+ struct internal_state FAR *state; /* not visible by applications */\r
+\r
+ alloc_func zalloc; /* used to allocate the internal state */\r
+ free_func zfree; /* used to free the internal state */\r
+ voidpf opaque; /* private data object passed to zalloc and zfree */\r
+\r
+ int data_type; /* best guess about the data type: binary or text */\r
+ uLong adler; /* adler32 value of the uncompressed data */\r
+ uLong reserved; /* reserved for future use */\r
+} z_stream;\r
+\r
+typedef z_stream FAR *z_streamp;\r
+\r
+/*\r
+ gzip header information passed to and from zlib routines. See RFC 1952\r
+ for more details on the meanings of these fields.\r
+*/\r
+typedef struct gz_header_s {\r
+ int text; /* true if compressed data believed to be text */\r
+ uLong time; /* modification time */\r
+ int xflags; /* extra flags (not used when writing a gzip file) */\r
+ int os; /* operating system */\r
+ Bytef *extra; /* pointer to extra field or Z_NULL if none */\r
+ uInt extra_len; /* extra field length (valid if extra != Z_NULL) */\r
+ uInt extra_max; /* space at extra (only when reading header) */\r
+ Bytef *name; /* pointer to zero-terminated file name or Z_NULL */\r
+ uInt name_max; /* space at name (only when reading header) */\r
+ Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */\r
+ uInt comm_max; /* space at comment (only when reading header) */\r
+ int hcrc; /* true if there was or will be a header crc */\r
+ int done; /* true when done reading gzip header (not used\r
+ when writing a gzip file) */\r
+} gz_header;\r
+\r
+typedef gz_header FAR *gz_headerp;\r
+\r
+/*\r
+ The application must update next_in and avail_in when avail_in has\r
+ dropped to zero. It must update next_out and avail_out when avail_out\r
+ has dropped to zero. The application must initialize zalloc, zfree and\r
+ opaque before calling the init function. All other fields are set by the\r
+ compression library and must not be updated by the application.\r
+\r
+ The opaque value provided by the application will be passed as the first\r
+ parameter for calls of zalloc and zfree. This can be useful for custom\r
+ memory management. The compression library attaches no meaning to the\r
+ opaque value.\r
+\r
+ zalloc must return Z_NULL if there is not enough memory for the object.\r
+ If zlib is used in a multi-threaded application, zalloc and zfree must be\r
+ thread safe.\r
+\r
+ On 16-bit systems, the functions zalloc and zfree must be able to allocate\r
+ exactly 65536 bytes, but will not be required to allocate more than this\r
+ if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,\r
+ pointers returned by zalloc for objects of exactly 65536 bytes *must*\r
+ have their offset normalized to zero. The default allocation function\r
+ provided by this library ensures this (see zutil.c). To reduce memory\r
+ requirements and avoid any allocation of 64K objects, at the expense of\r
+ compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).\r
+\r
+ The fields total_in and total_out can be used for statistics or\r
+ progress reports. After compression, total_in holds the total size of\r
+ the uncompressed data and may be saved for use in the decompressor\r
+ (particularly if the decompressor wants to decompress everything in\r
+ a single step).\r
+*/\r
+\r
+ /* constants */\r
+\r
+#define Z_NO_FLUSH 0\r
+#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */\r
+#define Z_SYNC_FLUSH 2\r
+#define Z_FULL_FLUSH 3\r
+#define Z_FINISH 4\r
+#define Z_BLOCK 5\r
+/* Allowed flush values; see deflate() and inflate() below for details */\r
+\r
+#define Z_OK 0\r
+#define Z_STREAM_END 1\r
+#define Z_NEED_DICT 2\r
+#define Z_ERRNO (-1)\r
+#define Z_STREAM_ERROR (-2)\r
+#define Z_DATA_ERROR (-3)\r
+#define Z_MEM_ERROR (-4)\r
+#define Z_BUF_ERROR (-5)\r
+#define Z_VERSION_ERROR (-6)\r
+/* Return codes for the compression/decompression functions. Negative\r
+ * values are errors, positive values are used for special but normal events.\r
+ */\r
+\r
+#define Z_NO_COMPRESSION 0\r
+#define Z_BEST_SPEED 1\r
+#define Z_BEST_COMPRESSION 9\r
+#define Z_DEFAULT_COMPRESSION (-1)\r
+/* compression levels */\r
+\r
+#define Z_FILTERED 1\r
+#define Z_HUFFMAN_ONLY 2\r
+#define Z_RLE 3\r
+#define Z_FIXED 4\r
+#define Z_DEFAULT_STRATEGY 0\r
+/* compression strategy; see deflateInit2() below for details */\r
+\r
+#define Z_BINARY 0\r
+#define Z_TEXT 1\r
+#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */\r
+#define Z_UNKNOWN 2\r
+/* Possible values of the data_type field (though see inflate()) */\r
+\r
+#define Z_DEFLATED 8\r
+/* The deflate compression method (the only one supported in this version) */\r
+\r
+#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */\r
+\r
+#define zlib_version zlibVersion()\r
+/* for compatibility with versions < 1.0.2 */\r
+\r
+ /* basic functions */\r
+\r
+ZEXTERN const char * ZEXPORT zlibVersion OF((void));\r
+/* The application can compare zlibVersion and ZLIB_VERSION for consistency.\r
+ If the first character differs, the library code actually used is\r
+ not compatible with the zlib.h header file used by the application.\r
+ This check is automatically made by deflateInit and inflateInit.\r
+ */\r
+\r
+/*\r
+ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));\r
+\r
+ Initializes the internal stream state for compression. The fields\r
+ zalloc, zfree and opaque must be initialized before by the caller.\r
+ If zalloc and zfree are set to Z_NULL, deflateInit updates them to\r
+ use default allocation functions.\r
+\r
+ The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:\r
+ 1 gives best speed, 9 gives best compression, 0 gives no compression at\r
+ all (the input data is simply copied a block at a time).\r
+ Z_DEFAULT_COMPRESSION requests a default compromise between speed and\r
+ compression (currently equivalent to level 6).\r
+\r
+ deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not\r
+ enough memory, Z_STREAM_ERROR if level is not a valid compression level,\r
+ Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible\r
+ with the version assumed by the caller (ZLIB_VERSION).\r
+ msg is set to null if there is no error message. deflateInit does not\r
+ perform any compression: this will be done by deflate().\r
+*/\r
+\r
+\r
+ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));\r
+/*\r
+ deflate compresses as much data as possible, and stops when the input\r
+ buffer becomes empty or the output buffer becomes full. It may introduce some\r
+ output latency (reading input without producing any output) except when\r
+ forced to flush.\r
+\r
+ The detailed semantics are as follows. deflate performs one or both of the\r
+ following actions:\r
+\r
+ - Compress more input starting at next_in and update next_in and avail_in\r
+ accordingly. If not all input can be processed (because there is not\r
+ enough room in the output buffer), next_in and avail_in are updated and\r
+ processing will resume at this point for the next call of deflate().\r
+\r
+ - Provide more output starting at next_out and update next_out and avail_out\r
+ accordingly. This action is forced if the parameter flush is non zero.\r
+ Forcing flush frequently degrades the compression ratio, so this parameter\r
+ should be set only when necessary (in interactive applications).\r
+ Some output may be provided even if flush is not set.\r
+\r
+ Before the call of deflate(), the application should ensure that at least\r
+ one of the actions is possible, by providing more input and/or consuming\r
+ more output, and updating avail_in or avail_out accordingly; avail_out\r
+ should never be zero before the call. The application can consume the\r
+ compressed output when it wants, for example when the output buffer is full\r
+ (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK\r
+ and with zero avail_out, it must be called again after making room in the\r
+ output buffer because there might be more output pending.\r
+\r
+ Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to\r
+ decide how much data to accumualte before producing output, in order to\r
+ maximize compression.\r
+\r
+ If the parameter flush is set to Z_SYNC_FLUSH, all pending output is\r
+ flushed to the output buffer and the output is aligned on a byte boundary, so\r
+ that the decompressor can get all input data available so far. (In particular\r
+ avail_in is zero after the call if enough output space has been provided\r
+ before the call.) Flushing may degrade compression for some compression\r
+ algorithms and so it should be used only when necessary.\r
+\r
+ If flush is set to Z_FULL_FLUSH, all output is flushed as with\r
+ Z_SYNC_FLUSH, and the compression state is reset so that decompression can\r
+ restart from this point if previous compressed data has been damaged or if\r
+ random access is desired. Using Z_FULL_FLUSH too often can seriously degrade\r
+ compression.\r
+\r
+ If deflate returns with avail_out == 0, this function must be called again\r
+ with the same value of the flush parameter and more output space (updated\r
+ avail_out), until the flush is complete (deflate returns with non-zero\r
+ avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that\r
+ avail_out is greater than six to avoid repeated flush markers due to\r
+ avail_out == 0 on return.\r
+\r
+ If the parameter flush is set to Z_FINISH, pending input is processed,\r
+ pending output is flushed and deflate returns with Z_STREAM_END if there\r
+ was enough output space; if deflate returns with Z_OK, this function must be\r
+ called again with Z_FINISH and more output space (updated avail_out) but no\r
+ more input data, until it returns with Z_STREAM_END or an error. After\r
+ deflate has returned Z_STREAM_END, the only possible operations on the\r
+ stream are deflateReset or deflateEnd.\r
+\r
+ Z_FINISH can be used immediately after deflateInit if all the compression\r
+ is to be done in a single step. In this case, avail_out must be at least\r
+ the value returned by deflateBound (see below). If deflate does not return\r
+ Z_STREAM_END, then it must be called again as described above.\r
+\r
+ deflate() sets strm->adler to the adler32 checksum of all input read\r
+ so far (that is, total_in bytes).\r
+\r
+ deflate() may update strm->data_type if it can make a good guess about\r
+ the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered\r
+ binary. This field is only for information purposes and does not affect\r
+ the compression algorithm in any manner.\r
+\r
+ deflate() returns Z_OK if some progress has been made (more input\r
+ processed or more output produced), Z_STREAM_END if all input has been\r
+ consumed and all output has been produced (only when flush is set to\r
+ Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example\r
+ if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible\r
+ (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not\r
+ fatal, and deflate() can be called again with more input and more output\r
+ space to continue compressing.\r
+*/\r
+\r
+\r
+ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));\r
+/*\r
+ All dynamically allocated data structures for this stream are freed.\r
+ This function discards any unprocessed input and does not flush any\r
+ pending output.\r
+\r
+ deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the\r
+ stream state was inconsistent, Z_DATA_ERROR if the stream was freed\r
+ prematurely (some input or output was discarded). In the error case,\r
+ msg may be set but then points to a static string (which must not be\r
+ deallocated).\r
+*/\r
+\r
+\r
+/*\r
+ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));\r
+\r
+ Initializes the internal stream state for decompression. The fields\r
+ next_in, avail_in, zalloc, zfree and opaque must be initialized before by\r
+ the caller. If next_in is not Z_NULL and avail_in is large enough (the exact\r
+ value depends on the compression method), inflateInit determines the\r
+ compression method from the zlib header and allocates all data structures\r
+ accordingly; otherwise the allocation will be deferred to the first call of\r
+ inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to\r
+ use default allocation functions.\r
+\r
+ inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough\r
+ memory, Z_VERSION_ERROR if the zlib library version is incompatible with the\r
+ version assumed by the caller. msg is set to null if there is no error\r
+ message. inflateInit does not perform any decompression apart from reading\r
+ the zlib header if present: this will be done by inflate(). (So next_in and\r
+ avail_in may be modified, but next_out and avail_out are unchanged.)\r
+*/\r
+\r
+\r
+ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));\r
+/*\r
+ inflate decompresses as much data as possible, and stops when the input\r
+ buffer becomes empty or the output buffer becomes full. It may introduce\r
+ some output latency (reading input without producing any output) except when\r
+ forced to flush.\r
+\r
+ The detailed semantics are as follows. inflate performs one or both of the\r
+ following actions:\r
+\r
+ - Decompress more input starting at next_in and update next_in and avail_in\r
+ accordingly. If not all input can be processed (because there is not\r
+ enough room in the output buffer), next_in is updated and processing\r
+ will resume at this point for the next call of inflate().\r
+\r
+ - Provide more output starting at next_out and update next_out and avail_out\r
+ accordingly. inflate() provides as much output as possible, until there\r
+ is no more input data or no more space in the output buffer (see below\r
+ about the flush parameter).\r
+\r
+ Before the call of inflate(), the application should ensure that at least\r
+ one of the actions is possible, by providing more input and/or consuming\r
+ more output, and updating the next_* and avail_* values accordingly.\r
+ The application can consume the uncompressed output when it wants, for\r
+ example when the output buffer is full (avail_out == 0), or after each\r
+ call of inflate(). If inflate returns Z_OK and with zero avail_out, it\r
+ must be called again after making room in the output buffer because there\r
+ might be more output pending.\r
+\r
+ The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH,\r
+ Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much\r
+ output as possible to the output buffer. Z_BLOCK requests that inflate() stop\r
+ if and when it gets to the next deflate block boundary. When decoding the\r
+ zlib or gzip format, this will cause inflate() to return immediately after\r
+ the header and before the first block. When doing a raw inflate, inflate()\r
+ will go ahead and process the first block, and will return when it gets to\r
+ the end of that block, or when it runs out of data.\r
+\r
+ The Z_BLOCK option assists in appending to or combining deflate streams.\r
+ Also to assist in this, on return inflate() will set strm->data_type to the\r
+ number of unused bits in the last byte taken from strm->next_in, plus 64\r
+ if inflate() is currently decoding the last block in the deflate stream,\r
+ plus 128 if inflate() returned immediately after decoding an end-of-block\r
+ code or decoding the complete header up to just before the first byte of the\r
+ deflate stream. The end-of-block will not be indicated until all of the\r
+ uncompressed data from that block has been written to strm->next_out. The\r
+ number of unused bits may in general be greater than seven, except when\r
+ bit 7 of data_type is set, in which case the number of unused bits will be\r
+ less than eight.\r
+\r
+ inflate() should normally be called until it returns Z_STREAM_END or an\r
+ error. However if all decompression is to be performed in a single step\r
+ (a single call of inflate), the parameter flush should be set to\r
+ Z_FINISH. In this case all pending input is processed and all pending\r
+ output is flushed; avail_out must be large enough to hold all the\r
+ uncompressed data. (The size of the uncompressed data may have been saved\r
+ by the compressor for this purpose.) The next operation on this stream must\r
+ be inflateEnd to deallocate the decompression state. The use of Z_FINISH\r
+ is never required, but can be used to inform inflate that a faster approach\r
+ may be used for the single inflate() call.\r
+\r
+ In this implementation, inflate() always flushes as much output as\r
+ possible to the output buffer, and always uses the faster approach on the\r
+ first call. So the only effect of the flush parameter in this implementation\r
+ is on the return value of inflate(), as noted below, or when it returns early\r
+ because Z_BLOCK is used.\r
+\r
+ If a preset dictionary is needed after this call (see inflateSetDictionary\r
+ below), inflate sets strm->adler to the adler32 checksum of the dictionary\r
+ chosen by the compressor and returns Z_NEED_DICT; otherwise it sets\r
+ strm->adler to the adler32 checksum of all output produced so far (that is,\r
+ total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described\r
+ below. At the end of the stream, inflate() checks that its computed adler32\r
+ checksum is equal to that saved by the compressor and returns Z_STREAM_END\r
+ only if the checksum is correct.\r
+\r
+ inflate() will decompress and check either zlib-wrapped or gzip-wrapped\r
+ deflate data. The header type is detected automatically. Any information\r
+ contained in the gzip header is not retained, so applications that need that\r
+ information should instead use raw inflate, see inflateInit2() below, or\r
+ inflateBack() and perform their own processing of the gzip header and\r
+ trailer.\r
+\r
+ inflate() returns Z_OK if some progress has been made (more input processed\r
+ or more output produced), Z_STREAM_END if the end of the compressed data has\r
+ been reached and all uncompressed output has been produced, Z_NEED_DICT if a\r
+ preset dictionary is needed at this point, Z_DATA_ERROR if the input data was\r
+ corrupted (input stream not conforming to the zlib format or incorrect check\r
+ value), Z_STREAM_ERROR if the stream structure was inconsistent (for example\r
+ if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory,\r
+ Z_BUF_ERROR if no progress is possible or if there was not enough room in the\r
+ output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and\r
+ inflate() can be called again with more input and more output space to\r
+ continue decompressing. If Z_DATA_ERROR is returned, the application may then\r
+ call inflateSync() to look for a good compression block if a partial recovery\r
+ of the data is desired.\r
+*/\r
+\r
+\r
+ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));\r
+/*\r
+ All dynamically allocated data structures for this stream are freed.\r
+ This function discards any unprocessed input and does not flush any\r
+ pending output.\r
+\r
+ inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state\r
+ was inconsistent. In the error case, msg may be set but then points to a\r
+ static string (which must not be deallocated).\r
+*/\r
+\r
+ /* Advanced functions */\r
+\r
+/*\r
+ The following functions are needed only in some special applications.\r
+*/\r
+\r
+/*\r
+ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,\r
+ int level,\r
+ int method,\r
+ int windowBits,\r
+ int memLevel,\r
+ int strategy));\r
+\r
+ This is another version of deflateInit with more compression options. The\r
+ fields next_in, zalloc, zfree and opaque must be initialized before by\r
+ the caller.\r
+\r
+ The method parameter is the compression method. It must be Z_DEFLATED in\r
+ this version of the library.\r
+\r
+ The windowBits parameter is the base two logarithm of the window size\r
+ (the size of the history buffer). It should be in the range 8..15 for this\r
+ version of the library. Larger values of this parameter result in better\r
+ compression at the expense of memory usage. The default value is 15 if\r
+ deflateInit is used instead.\r
+\r
+ windowBits can also be -8..-15 for raw deflate. In this case, -windowBits\r
+ determines the window size. deflate() will then generate raw deflate data\r
+ with no zlib header or trailer, and will not compute an adler32 check value.\r
+\r
+ windowBits can also be greater than 15 for optional gzip encoding. Add\r
+ 16 to windowBits to write a simple gzip header and trailer around the\r
+ compressed data instead of a zlib wrapper. The gzip header will have no\r
+ file name, no extra data, no comment, no modification time (set to zero),\r
+ no header crc, and the operating system will be set to 255 (unknown). If a\r
+ gzip stream is being written, strm->adler is a crc32 instead of an adler32.\r
+\r
+ The memLevel parameter specifies how much memory should be allocated\r
+ for the internal compression state. memLevel=1 uses minimum memory but\r
+ is slow and reduces compression ratio; memLevel=9 uses maximum memory\r
+ for optimal speed. The default value is 8. See zconf.h for total memory\r
+ usage as a function of windowBits and memLevel.\r
+\r
+ The strategy parameter is used to tune the compression algorithm. Use the\r
+ value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a\r
+ filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no\r
+ string match), or Z_RLE to limit match distances to one (run-length\r
+ encoding). Filtered data consists mostly of small values with a somewhat\r
+ random distribution. In this case, the compression algorithm is tuned to\r
+ compress them better. The effect of Z_FILTERED is to force more Huffman\r
+ coding and less string matching; it is somewhat intermediate between\r
+ Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as\r
+ Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy\r
+ parameter only affects the compression ratio but not the correctness of the\r
+ compressed output even if it is not set appropriately. Z_FIXED prevents the\r
+ use of dynamic Huffman codes, allowing for a simpler decoder for special\r
+ applications.\r
+\r
+ deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\r
+ memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid\r
+ method). msg is set to null if there is no error message. deflateInit2 does\r
+ not perform any compression: this will be done by deflate().\r
+*/\r
+\r
+ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,\r
+ const Bytef *dictionary,\r
+ uInt dictLength));\r
+/*\r
+ Initializes the compression dictionary from the given byte sequence\r
+ without producing any compressed output. This function must be called\r
+ immediately after deflateInit, deflateInit2 or deflateReset, before any\r
+ call of deflate. The compressor and decompressor must use exactly the same\r
+ dictionary (see inflateSetDictionary).\r
+\r
+ The dictionary should consist of strings (byte sequences) that are likely\r
+ to be encountered later in the data to be compressed, with the most commonly\r
+ used strings preferably put towards the end of the dictionary. Using a\r
+ dictionary is most useful when the data to be compressed is short and can be\r
+ predicted with good accuracy; the data can then be compressed better than\r
+ with the default empty dictionary.\r
+\r
+ Depending on the size of the compression data structures selected by\r
+ deflateInit or deflateInit2, a part of the dictionary may in effect be\r
+ discarded, for example if the dictionary is larger than the window size in\r
+ deflate or deflate2. Thus the strings most likely to be useful should be\r
+ put at the end of the dictionary, not at the front. In addition, the\r
+ current implementation of deflate will use at most the window size minus\r
+ 262 bytes of the provided dictionary.\r
+\r
+ Upon return of this function, strm->adler is set to the adler32 value\r
+ of the dictionary; the decompressor may later use this value to determine\r
+ which dictionary has been used by the compressor. (The adler32 value\r
+ applies to the whole dictionary even if only a subset of the dictionary is\r
+ actually used by the compressor.) If a raw deflate was requested, then the\r
+ adler32 value is not computed and strm->adler is not set.\r
+\r
+ deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a\r
+ parameter is invalid (such as NULL dictionary) or the stream state is\r
+ inconsistent (for example if deflate has already been called for this stream\r
+ or if the compression method is bsort). deflateSetDictionary does not\r
+ perform any compression: this will be done by deflate().\r
+*/\r
+\r
+ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,\r
+ z_streamp source));\r
+/*\r
+ Sets the destination stream as a complete copy of the source stream.\r
+\r
+ This function can be useful when several compression strategies will be\r
+ tried, for example when there are several ways of pre-processing the input\r
+ data with a filter. The streams that will be discarded should then be freed\r
+ by calling deflateEnd. Note that deflateCopy duplicates the internal\r
+ compression state which can be quite large, so this strategy is slow and\r
+ can consume lots of memory.\r
+\r
+ deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not\r
+ enough memory, Z_STREAM_ERROR if the source stream state was inconsistent\r
+ (such as zalloc being NULL). msg is left unchanged in both source and\r
+ destination.\r
+*/\r
+\r
+ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));\r
+/*\r
+ This function is equivalent to deflateEnd followed by deflateInit,\r
+ but does not free and reallocate all the internal compression state.\r
+ The stream will keep the same compression level and any other attributes\r
+ that may have been set by deflateInit2.\r
+\r
+ deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\r
+ stream state was inconsistent (such as zalloc or state being NULL).\r
+*/\r
+\r
+ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,\r
+ int level,\r
+ int strategy));\r
+/*\r
+ Dynamically update the compression level and compression strategy. The\r
+ interpretation of level and strategy is as in deflateInit2. This can be\r
+ used to switch between compression and straight copy of the input data, or\r
+ to switch to a different kind of input data requiring a different\r
+ strategy. If the compression level is changed, the input available so far\r
+ is compressed with the old level (and may be flushed); the new level will\r
+ take effect only at the next call of deflate().\r
+\r
+ Before the call of deflateParams, the stream state must be set as for\r
+ a call of deflate(), since the currently available input may have to\r
+ be compressed and flushed. In particular, strm->avail_out must be non-zero.\r
+\r
+ deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source\r
+ stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR\r
+ if strm->avail_out was zero.\r
+*/\r
+\r
+ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,\r
+ int good_length,\r
+ int max_lazy,\r
+ int nice_length,\r
+ int max_chain));\r
+/*\r
+ Fine tune deflate's internal compression parameters. This should only be\r
+ used by someone who understands the algorithm used by zlib's deflate for\r
+ searching for the best matching string, and even then only by the most\r
+ fanatic optimizer trying to squeeze out the last compressed bit for their\r
+ specific input data. Read the deflate.c source code for the meaning of the\r
+ max_lazy, good_length, nice_length, and max_chain parameters.\r
+\r
+ deflateTune() can be called after deflateInit() or deflateInit2(), and\r
+ returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.\r
+ */\r
+\r
+ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,\r
+ uLong sourceLen));\r
+/*\r
+ deflateBound() returns an upper bound on the compressed size after\r
+ deflation of sourceLen bytes. It must be called after deflateInit()\r
+ or deflateInit2(). This would be used to allocate an output buffer\r
+ for deflation in a single pass, and so would be called before deflate().\r
+*/\r
+\r
+ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,\r
+ int bits,\r
+ int value));\r
+/*\r
+ deflatePrime() inserts bits in the deflate output stream. The intent\r
+ is that this function is used to start off the deflate output with the\r
+ bits leftover from a previous deflate stream when appending to it. As such,\r
+ this function can only be used for raw deflate, and must be used before the\r
+ first deflate() call after a deflateInit2() or deflateReset(). bits must be\r
+ less than or equal to 16, and that many of the least significant bits of\r
+ value will be inserted in the output.\r
+\r
+ deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source\r
+ stream state was inconsistent.\r
+*/\r
+\r
+ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,\r
+ gz_headerp head));\r
+/*\r
+ deflateSetHeader() provides gzip header information for when a gzip\r
+ stream is requested by deflateInit2(). deflateSetHeader() may be called\r
+ after deflateInit2() or deflateReset() and before the first call of\r
+ deflate(). The text, time, os, extra field, name, and comment information\r
+ in the provided gz_header structure are written to the gzip header (xflag is\r
+ ignored -- the extra flags are set according to the compression level). The\r
+ caller must assure that, if not Z_NULL, name and comment are terminated with\r
+ a zero byte, and that if extra is not Z_NULL, that extra_len bytes are\r
+ available there. If hcrc is true, a gzip header crc is included. Note that\r
+ the current versions of the command-line version of gzip (up through version\r
+ 1.3.x) do not support header crc's, and will report that it is a "multi-part\r
+ gzip file" and give up.\r
+\r
+ If deflateSetHeader is not used, the default gzip header has text false,\r
+ the time set to zero, and os set to 255, with no extra, name, or comment\r
+ fields. The gzip header is returned to the default state by deflateReset().\r
+\r
+ deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source\r
+ stream state was inconsistent.\r
+*/\r
+\r
+/*\r
+ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,\r
+ int windowBits));\r
+\r
+ This is another version of inflateInit with an extra parameter. The\r
+ fields next_in, avail_in, zalloc, zfree and opaque must be initialized\r
+ before by the caller.\r
+\r
+ The windowBits parameter is the base two logarithm of the maximum window\r
+ size (the size of the history buffer). It should be in the range 8..15 for\r
+ this version of the library. The default value is 15 if inflateInit is used\r
+ instead. windowBits must be greater than or equal to the windowBits value\r
+ provided to deflateInit2() while compressing, or it must be equal to 15 if\r
+ deflateInit2() was not used. If a compressed stream with a larger window\r
+ size is given as input, inflate() will return with the error code\r
+ Z_DATA_ERROR instead of trying to allocate a larger window.\r
+\r
+ windowBits can also be -8..-15 for raw inflate. In this case, -windowBits\r
+ determines the window size. inflate() will then process raw deflate data,\r
+ not looking for a zlib or gzip header, not generating a check value, and not\r
+ looking for any check values for comparison at the end of the stream. This\r
+ is for use with other formats that use the deflate compressed data format\r
+ such as zip. Those formats provide their own check values. If a custom\r
+ format is developed using the raw deflate format for compressed data, it is\r
+ recommended that a check value such as an adler32 or a crc32 be applied to\r
+ the uncompressed data as is done in the zlib, gzip, and zip formats. For\r
+ most applications, the zlib format should be used as is. Note that comments\r
+ above on the use in deflateInit2() applies to the magnitude of windowBits.\r
+\r
+ windowBits can also be greater than 15 for optional gzip decoding. Add\r
+ 32 to windowBits to enable zlib and gzip decoding with automatic header\r
+ detection, or add 16 to decode only the gzip format (the zlib format will\r
+ return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is\r
+ a crc32 instead of an adler32.\r
+\r
+ inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\r
+ memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg\r
+ is set to null if there is no error message. inflateInit2 does not perform\r
+ any decompression apart from reading the zlib header if present: this will\r
+ be done by inflate(). (So next_in and avail_in may be modified, but next_out\r
+ and avail_out are unchanged.)\r
+*/\r
+\r
+ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,\r
+ const Bytef *dictionary,\r
+ uInt dictLength));\r
+/*\r
+ Initializes the decompression dictionary from the given uncompressed byte\r
+ sequence. This function must be called immediately after a call of inflate,\r
+ if that call returned Z_NEED_DICT. The dictionary chosen by the compressor\r
+ can be determined from the adler32 value returned by that call of inflate.\r
+ The compressor and decompressor must use exactly the same dictionary (see\r
+ deflateSetDictionary). For raw inflate, this function can be called\r
+ immediately after inflateInit2() or inflateReset() and before any call of\r
+ inflate() to set the dictionary. The application must insure that the\r
+ dictionary that was used for compression is provided.\r
+\r
+ inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a\r
+ parameter is invalid (such as NULL dictionary) or the stream state is\r
+ inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the\r
+ expected one (incorrect adler32 value). inflateSetDictionary does not\r
+ perform any decompression: this will be done by subsequent calls of\r
+ inflate().\r
+*/\r
+\r
+ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));\r
+/*\r
+ Skips invalid compressed data until a full flush point (see above the\r
+ description of deflate with Z_FULL_FLUSH) can be found, or until all\r
+ available input is skipped. No output is provided.\r
+\r
+ inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR\r
+ if no more input was provided, Z_DATA_ERROR if no flush point has been found,\r
+ or Z_STREAM_ERROR if the stream structure was inconsistent. In the success\r
+ case, the application may save the current current value of total_in which\r
+ indicates where valid compressed data was found. In the error case, the\r
+ application may repeatedly call inflateSync, providing more input each time,\r
+ until success or end of the input data.\r
+*/\r
+\r
+ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,\r
+ z_streamp source));\r
+/*\r
+ Sets the destination stream as a complete copy of the source stream.\r
+\r
+ This function can be useful when randomly accessing a large stream. The\r
+ first pass through the stream can periodically record the inflate state,\r
+ allowing restarting inflate at those points when randomly accessing the\r
+ stream.\r
+\r
+ inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not\r
+ enough memory, Z_STREAM_ERROR if the source stream state was inconsistent\r
+ (such as zalloc being NULL). msg is left unchanged in both source and\r
+ destination.\r
+*/\r
+\r
+ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));\r
+/*\r
+ This function is equivalent to inflateEnd followed by inflateInit,\r
+ but does not free and reallocate all the internal decompression state.\r
+ The stream will keep attributes that may have been set by inflateInit2.\r
+\r
+ inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\r
+ stream state was inconsistent (such as zalloc or state being NULL).\r
+*/\r
+\r
+ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,\r
+ int bits,\r
+ int value));\r
+/*\r
+ This function inserts bits in the inflate input stream. The intent is\r
+ that this function is used to start inflating at a bit position in the\r
+ middle of a byte. The provided bits will be used before any bytes are used\r
+ from next_in. This function should only be used with raw inflate, and\r
+ should be used before the first inflate() call after inflateInit2() or\r
+ inflateReset(). bits must be less than or equal to 16, and that many of the\r
+ least significant bits of value will be inserted in the input.\r
+\r
+ inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source\r
+ stream state was inconsistent.\r
+*/\r
+\r
+ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,\r
+ gz_headerp head));\r
+/*\r
+ inflateGetHeader() requests that gzip header information be stored in the\r
+ provided gz_header structure. inflateGetHeader() may be called after\r
+ inflateInit2() or inflateReset(), and before the first call of inflate().\r
+ As inflate() processes the gzip stream, head->done is zero until the header\r
+ is completed, at which time head->done is set to one. If a zlib stream is\r
+ being decoded, then head->done is set to -1 to indicate that there will be\r
+ no gzip header information forthcoming. Note that Z_BLOCK can be used to\r
+ force inflate() to return immediately after header processing is complete\r
+ and before any actual data is decompressed.\r
+\r
+ The text, time, xflags, and os fields are filled in with the gzip header\r
+ contents. hcrc is set to true if there is a header CRC. (The header CRC\r
+ was valid if done is set to one.) If extra is not Z_NULL, then extra_max\r
+ contains the maximum number of bytes to write to extra. Once done is true,\r
+ extra_len contains the actual extra field length, and extra contains the\r
+ extra field, or that field truncated if extra_max is less than extra_len.\r
+ If name is not Z_NULL, then up to name_max characters are written there,\r
+ terminated with a zero unless the length is greater than name_max. If\r
+ comment is not Z_NULL, then up to comm_max characters are written there,\r
+ terminated with a zero unless the length is greater than comm_max. When\r
+ any of extra, name, or comment are not Z_NULL and the respective field is\r
+ not present in the header, then that field is set to Z_NULL to signal its\r
+ absence. This allows the use of deflateSetHeader() with the returned\r
+ structure to duplicate the header. However if those fields are set to\r
+ allocated memory, then the application will need to save those pointers\r
+ elsewhere so that they can be eventually freed.\r
+\r
+ If inflateGetHeader is not used, then the header information is simply\r
+ discarded. The header is always checked for validity, including the header\r
+ CRC if present. inflateReset() will reset the process to discard the header\r
+ information. The application would need to call inflateGetHeader() again to\r
+ retrieve the header from the next gzip stream.\r
+\r
+ inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source\r
+ stream state was inconsistent.\r
+*/\r
+\r
+/*\r
+ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,\r
+ unsigned char FAR *window));\r
+\r
+ Initialize the internal stream state for decompression using inflateBack()\r
+ calls. The fields zalloc, zfree and opaque in strm must be initialized\r
+ before the call. If zalloc and zfree are Z_NULL, then the default library-\r
+ derived memory allocation routines are used. windowBits is the base two\r
+ logarithm of the window size, in the range 8..15. window is a caller\r
+ supplied buffer of that size. Except for special applications where it is\r
+ assured that deflate was used with small window sizes, windowBits must be 15\r
+ and a 32K byte window must be supplied to be able to decompress general\r
+ deflate streams.\r
+\r
+ See inflateBack() for the usage of these routines.\r
+\r
+ inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of\r
+ the paramaters are invalid, Z_MEM_ERROR if the internal state could not\r
+ be allocated, or Z_VERSION_ERROR if the version of the library does not\r
+ match the version of the header file.\r
+*/\r
+\r
+typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *));\r
+typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));\r
+\r
+ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,\r
+ in_func in, void FAR *in_desc,\r
+ out_func out, void FAR *out_desc));\r
+/*\r
+ inflateBack() does a raw inflate with a single call using a call-back\r
+ interface for input and output. This is more efficient than inflate() for\r
+ file i/o applications in that it avoids copying between the output and the\r
+ sliding window by simply making the window itself the output buffer. This\r
+ function trusts the application to not change the output buffer passed by\r
+ the output function, at least until inflateBack() returns.\r
+\r
+ inflateBackInit() must be called first to allocate the internal state\r
+ and to initialize the state with the user-provided window buffer.\r
+ inflateBack() may then be used multiple times to inflate a complete, raw\r
+ deflate stream with each call. inflateBackEnd() is then called to free\r
+ the allocated state.\r
+\r
+ A raw deflate stream is one with no zlib or gzip header or trailer.\r
+ This routine would normally be used in a utility that reads zip or gzip\r
+ files and writes out uncompressed files. The utility would decode the\r
+ header and process the trailer on its own, hence this routine expects\r
+ only the raw deflate stream to decompress. This is different from the\r
+ normal behavior of inflate(), which expects either a zlib or gzip header and\r
+ trailer around the deflate stream.\r
+\r
+ inflateBack() uses two subroutines supplied by the caller that are then\r
+ called by inflateBack() for input and output. inflateBack() calls those\r
+ routines until it reads a complete deflate stream and writes out all of the\r
+ uncompressed data, or until it encounters an error. The function's\r
+ parameters and return types are defined above in the in_func and out_func\r
+ typedefs. inflateBack() will call in(in_desc, &buf) which should return the\r
+ number of bytes of provided input, and a pointer to that input in buf. If\r
+ there is no input available, in() must return zero--buf is ignored in that\r
+ case--and inflateBack() will return a buffer error. inflateBack() will call\r
+ out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out()\r
+ should return zero on success, or non-zero on failure. If out() returns\r
+ non-zero, inflateBack() will return with an error. Neither in() nor out()\r
+ are permitted to change the contents of the window provided to\r
+ inflateBackInit(), which is also the buffer that out() uses to write from.\r
+ The length written by out() will be at most the window size. Any non-zero\r
+ amount of input may be provided by in().\r
+\r
+ For convenience, inflateBack() can be provided input on the first call by\r
+ setting strm->next_in and strm->avail_in. If that input is exhausted, then\r
+ in() will be called. Therefore strm->next_in must be initialized before\r
+ calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called\r
+ immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in\r
+ must also be initialized, and then if strm->avail_in is not zero, input will\r
+ initially be taken from strm->next_in[0 .. strm->avail_in - 1].\r
+\r
+ The in_desc and out_desc parameters of inflateBack() is passed as the\r
+ first parameter of in() and out() respectively when they are called. These\r
+ descriptors can be optionally used to pass any information that the caller-\r
+ supplied in() and out() functions need to do their job.\r
+\r
+ On return, inflateBack() will set strm->next_in and strm->avail_in to\r
+ pass back any unused input that was provided by the last in() call. The\r
+ return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR\r
+ if in() or out() returned an error, Z_DATA_ERROR if there was a format\r
+ error in the deflate stream (in which case strm->msg is set to indicate the\r
+ nature of the error), or Z_STREAM_ERROR if the stream was not properly\r
+ initialized. In the case of Z_BUF_ERROR, an input or output error can be\r
+ distinguished using strm->next_in which will be Z_NULL only if in() returned\r
+ an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to\r
+ out() returning non-zero. (in() will always be called before out(), so\r
+ strm->next_in is assured to be defined if out() returns non-zero.) Note\r
+ that inflateBack() cannot return Z_OK.\r
+*/\r
+\r
+ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));\r
+/*\r
+ All memory allocated by inflateBackInit() is freed.\r
+\r
+ inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream\r
+ state was inconsistent.\r
+*/\r
+\r
+ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));\r
+/* Return flags indicating compile-time options.\r
+\r
+ Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:\r
+ 1.0: size of uInt\r
+ 3.2: size of uLong\r
+ 5.4: size of voidpf (pointer)\r
+ 7.6: size of z_off_t\r
+\r
+ Compiler, assembler, and debug options:\r
+ 8: DEBUG\r
+ 9: ASMV or ASMINF -- use ASM code\r
+ 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention\r
+ 11: 0 (reserved)\r
+\r
+ One-time table building (smaller code, but not thread-safe if true):\r
+ 12: BUILDFIXED -- build static block decoding tables when needed\r
+ 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed\r
+ 14,15: 0 (reserved)\r
+\r
+ Library content (indicates missing functionality):\r
+ 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking\r
+ deflate code when not needed)\r
+ 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect\r
+ and decode gzip streams (to avoid linking crc code)\r
+ 18-19: 0 (reserved)\r
+\r
+ Operation variations (changes in library functionality):\r
+ 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate\r
+ 21: FASTEST -- deflate algorithm with only one, lowest compression level\r
+ 22,23: 0 (reserved)\r
+\r
+ The sprintf variant used by gzprintf (zero is best):\r
+ 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format\r
+ 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!\r
+ 26: 0 = returns value, 1 = void -- 1 means inferred string length returned\r
+\r
+ Remainder:\r
+ 27-31: 0 (reserved)\r
+ */\r
+\r
+\r
+ /* utility functions */\r
+\r
+/*\r
+ The following utility functions are implemented on top of the\r
+ basic stream-oriented functions. To simplify the interface, some\r
+ default options are assumed (compression level and memory usage,\r
+ standard memory allocation functions). The source code of these\r
+ utility functions can easily be modified if you need special options.\r
+*/\r
+\r
+ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,\r
+ const Bytef *source, uLong sourceLen));\r
+/*\r
+ Compresses the source buffer into the destination buffer. sourceLen is\r
+ the byte length of the source buffer. Upon entry, destLen is the total\r
+ size of the destination buffer, which must be at least the value returned\r
+ by compressBound(sourceLen). Upon exit, destLen is the actual size of the\r
+ compressed buffer.\r
+ This function can be used to compress a whole file at once if the\r
+ input file is mmap'ed.\r
+ compress returns Z_OK if success, Z_MEM_ERROR if there was not\r
+ enough memory, Z_BUF_ERROR if there was not enough room in the output\r
+ buffer.\r
+*/\r
+\r
+ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,\r
+ const Bytef *source, uLong sourceLen,\r
+ int level));\r
+/*\r
+ Compresses the source buffer into the destination buffer. The level\r
+ parameter has the same meaning as in deflateInit. sourceLen is the byte\r
+ length of the source buffer. Upon entry, destLen is the total size of the\r
+ destination buffer, which must be at least the value returned by\r
+ compressBound(sourceLen). Upon exit, destLen is the actual size of the\r
+ compressed buffer.\r
+\r
+ compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\r
+ memory, Z_BUF_ERROR if there was not enough room in the output buffer,\r
+ Z_STREAM_ERROR if the level parameter is invalid.\r
+*/\r
+\r
+ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));\r
+/*\r
+ compressBound() returns an upper bound on the compressed size after\r
+ compress() or compress2() on sourceLen bytes. It would be used before\r
+ a compress() or compress2() call to allocate the destination buffer.\r
+*/\r
+\r
+ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,\r
+ const Bytef *source, uLong sourceLen));\r
+/*\r
+ Decompresses the source buffer into the destination buffer. sourceLen is\r
+ the byte length of the source buffer. Upon entry, destLen is the total\r
+ size of the destination buffer, which must be large enough to hold the\r
+ entire uncompressed data. (The size of the uncompressed data must have\r
+ been saved previously by the compressor and transmitted to the decompressor\r
+ by some mechanism outside the scope of this compression library.)\r
+ Upon exit, destLen is the actual size of the compressed buffer.\r
+ This function can be used to decompress a whole file at once if the\r
+ input file is mmap'ed.\r
+\r
+ uncompress returns Z_OK if success, Z_MEM_ERROR if there was not\r
+ enough memory, Z_BUF_ERROR if there was not enough room in the output\r
+ buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.\r
+*/\r
+\r
+\r
+typedef voidp gzFile;\r
+\r
+ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));\r
+/*\r
+ Opens a gzip (.gz) file for reading or writing. The mode parameter\r
+ is as in fopen ("rb" or "wb") but can also include a compression level\r
+ ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for\r
+ Huffman only compression as in "wb1h", or 'R' for run-length encoding\r
+ as in "wb1R". (See the description of deflateInit2 for more information\r
+ about the strategy parameter.)\r
+\r
+ gzopen can be used to read a file which is not in gzip format; in this\r
+ case gzread will directly read from the file without decompression.\r
+\r
+ gzopen returns NULL if the file could not be opened or if there was\r
+ insufficient memory to allocate the (de)compression state; errno\r
+ can be checked to distinguish the two cases (if errno is zero, the\r
+ zlib error is Z_MEM_ERROR). */\r
+\r
+ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));\r
+/*\r
+ gzdopen() associates a gzFile with the file descriptor fd. File\r
+ descriptors are obtained from calls like open, dup, creat, pipe or\r
+ fileno (in the file has been previously opened with fopen).\r
+ The mode parameter is as in gzopen.\r
+ The next call of gzclose on the returned gzFile will also close the\r
+ file descriptor fd, just like fclose(fdopen(fd), mode) closes the file\r
+ descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).\r
+ gzdopen returns NULL if there was insufficient memory to allocate\r
+ the (de)compression state.\r
+*/\r
+\r
+ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));\r
+/*\r
+ Dynamically update the compression level or strategy. See the description\r
+ of deflateInit2 for the meaning of these parameters.\r
+ gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not\r
+ opened for writing.\r
+*/\r
+\r
+ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));\r
+/*\r
+ Reads the given number of uncompressed bytes from the compressed file.\r
+ If the input file was not in gzip format, gzread copies the given number\r
+ of bytes into the buffer.\r
+ gzread returns the number of uncompressed bytes actually read (0 for\r
+ end of file, -1 for error). */\r
+\r
+ZEXTERN int ZEXPORT gzwrite OF((gzFile file,\r
+ voidpc buf, unsigned len));\r
+/*\r
+ Writes the given number of uncompressed bytes into the compressed file.\r
+ gzwrite returns the number of uncompressed bytes actually written\r
+ (0 in case of error).\r
+*/\r
+\r
+ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));\r
+/*\r
+ Converts, formats, and writes the args to the compressed file under\r
+ control of the format string, as in fprintf. gzprintf returns the number of\r
+ uncompressed bytes actually written (0 in case of error). The number of\r
+ uncompressed bytes written is limited to 4095. The caller should assure that\r
+ this limit is not exceeded. If it is exceeded, then gzprintf() will return\r
+ return an error (0) with nothing written. In this case, there may also be a\r
+ buffer overflow with unpredictable consequences, which is possible only if\r
+ zlib was compiled with the insecure functions sprintf() or vsprintf()\r
+ because the secure snprintf() or vsnprintf() functions were not available.\r
+*/\r
+\r
+ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));\r
+/*\r
+ Writes the given null-terminated string to the compressed file, excluding\r
+ the terminating null character.\r
+ gzputs returns the number of characters written, or -1 in case of error.\r
+*/\r
+\r
+ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));\r
+/*\r
+ Reads bytes from the compressed file until len-1 characters are read, or\r
+ a newline character is read and transferred to buf, or an end-of-file\r
+ condition is encountered. The string is then terminated with a null\r
+ character.\r
+ gzgets returns buf, or Z_NULL in case of error.\r
+*/\r
+\r
+ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));\r
+/*\r
+ Writes c, converted to an unsigned char, into the compressed file.\r
+ gzputc returns the value that was written, or -1 in case of error.\r
+*/\r
+\r
+ZEXTERN int ZEXPORT gzgetc OF((gzFile file));\r
+/*\r
+ Reads one byte from the compressed file. gzgetc returns this byte\r
+ or -1 in case of end of file or error.\r
+*/\r
+\r
+ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));\r
+/*\r
+ Push one character back onto the stream to be read again later.\r
+ Only one character of push-back is allowed. gzungetc() returns the\r
+ character pushed, or -1 on failure. gzungetc() will fail if a\r
+ character has been pushed but not read yet, or if c is -1. The pushed\r
+ character will be discarded if the stream is repositioned with gzseek()\r
+ or gzrewind().\r
+*/\r
+\r
+ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));\r
+/*\r
+ Flushes all pending output into the compressed file. The parameter\r
+ flush is as in the deflate() function. The return value is the zlib\r
+ error number (see function gzerror below). gzflush returns Z_OK if\r
+ the flush parameter is Z_FINISH and all output could be flushed.\r
+ gzflush should be called only when strictly necessary because it can\r
+ degrade compression.\r
+*/\r
+\r
+ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,\r
+ z_off_t offset, int whence));\r
+/*\r
+ Sets the starting position for the next gzread or gzwrite on the\r
+ given compressed file. The offset represents a number of bytes in the\r
+ uncompressed data stream. The whence parameter is defined as in lseek(2);\r
+ the value SEEK_END is not supported.\r
+ If the file is opened for reading, this function is emulated but can be\r
+ extremely slow. If the file is opened for writing, only forward seeks are\r
+ supported; gzseek then compresses a sequence of zeroes up to the new\r
+ starting position.\r
+\r
+ gzseek returns the resulting offset location as measured in bytes from\r
+ the beginning of the uncompressed stream, or -1 in case of error, in\r
+ particular if the file is opened for writing and the new starting position\r
+ would be before the current position.\r
+*/\r
+\r
+ZEXTERN int ZEXPORT gzrewind OF((gzFile file));\r
+/*\r
+ Rewinds the given file. This function is supported only for reading.\r
+\r
+ gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)\r
+*/\r
+\r
+ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));\r
+/*\r
+ Returns the starting position for the next gzread or gzwrite on the\r
+ given compressed file. This position represents a number of bytes in the\r
+ uncompressed data stream.\r
+\r
+ gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)\r
+*/\r
+\r
+ZEXTERN int ZEXPORT gzeof OF((gzFile file));\r
+/*\r
+ Returns 1 when EOF has previously been detected reading the given\r
+ input stream, otherwise zero.\r
+*/\r
+\r
+ZEXTERN int ZEXPORT gzdirect OF((gzFile file));\r
+/*\r
+ Returns 1 if file is being read directly without decompression, otherwise\r
+ zero.\r
+*/\r
+\r
+ZEXTERN int ZEXPORT gzclose OF((gzFile file));\r
+/*\r
+ Flushes all pending output if necessary, closes the compressed file\r
+ and deallocates all the (de)compression state. The return value is the zlib\r
+ error number (see function gzerror below).\r
+*/\r
+\r
+ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));\r
+/*\r
+ Returns the error message for the last error which occurred on the\r
+ given compressed file. errnum is set to zlib error number. If an\r
+ error occurred in the file system and not in the compression library,\r
+ errnum is set to Z_ERRNO and the application may consult errno\r
+ to get the exact error code.\r
+*/\r
+\r
+ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));\r
+/*\r
+ Clears the error and end-of-file flags for file. This is analogous to the\r
+ clearerr() function in stdio. This is useful for continuing to read a gzip\r
+ file that is being written concurrently.\r
+*/\r
+\r
+ /* checksum functions */\r
+\r
+/*\r
+ These functions are not related to compression but are exported\r
+ anyway because they might be useful in applications using the\r
+ compression library.\r
+*/\r
+\r
+ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));\r
+/*\r
+ Update a running Adler-32 checksum with the bytes buf[0..len-1] and\r
+ return the updated checksum. If buf is NULL, this function returns\r
+ the required initial value for the checksum.\r
+ An Adler-32 checksum is almost as reliable as a CRC32 but can be computed\r
+ much faster. Usage example:\r
+\r
+ uLong adler = adler32(0L, Z_NULL, 0);\r
+\r
+ while (read_buffer(buffer, length) != EOF) {\r
+ adler = adler32(adler, buffer, length);\r
+ }\r
+ if (adler != original_adler) error();\r
+*/\r
+\r
+ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,\r
+ z_off_t len2));\r
+/*\r
+ Combine two Adler-32 checksums into one. For two sequences of bytes, seq1\r
+ and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for\r
+ each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of\r
+ seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.\r
+*/\r
+\r
+ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));\r
+/*\r
+ Update a running CRC-32 with the bytes buf[0..len-1] and return the\r
+ updated CRC-32. If buf is NULL, this function returns the required initial\r
+ value for the for the crc. Pre- and post-conditioning (one's complement) is\r
+ performed within this function so it shouldn't be done by the application.\r
+ Usage example:\r
+\r
+ uLong crc = crc32(0L, Z_NULL, 0);\r
+\r
+ while (read_buffer(buffer, length) != EOF) {\r
+ crc = crc32(crc, buffer, length);\r
+ }\r
+ if (crc != original_crc) error();\r
+*/\r
+\r
+ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));\r
+\r
+/*\r
+ Combine two CRC-32 check values into one. For two sequences of bytes,\r
+ seq1 and seq2 with lengths len1 and len2, CRC-32 check values were\r
+ calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32\r
+ check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and\r
+ len2.\r
+*/\r
+\r
+\r
+ /* various hacks, don't look :) */\r
+\r
+/* deflateInit and inflateInit are macros to allow checking the zlib version\r
+ * and the compiler's view of z_stream:\r
+ */\r
+ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,\r
+ const char *version, int stream_size));\r
+ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,\r
+ const char *version, int stream_size));\r
+ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,\r
+ int windowBits, int memLevel,\r
+ int strategy, const char *version,\r
+ int stream_size));\r
+ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,\r
+ const char *version, int stream_size));\r
+ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,\r
+ unsigned char FAR *window,\r
+ const char *version,\r
+ int stream_size));\r
+#define deflateInit(strm, level) \\r
+ deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))\r
+#define inflateInit(strm) \\r
+ inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))\r
+#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \\r
+ deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\\r
+ (strategy), ZLIB_VERSION, sizeof(z_stream))\r
+#define inflateInit2(strm, windowBits) \\r
+ inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))\r
+#define inflateBackInit(strm, windowBits, window) \\r
+ inflateBackInit_((strm), (windowBits), (window), \\r
+ ZLIB_VERSION, sizeof(z_stream))\r
+\r
+\r
+#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)\r
+ struct internal_state {int dummy;}; /* hack for buggy compilers */\r
+#endif\r
+\r
+ZEXTERN const char * ZEXPORT zError OF((int));\r
+ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z));\r
+ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* ZLIB_H */\r
# Makefile for the MJ2 codecs of the OpenJPEG library: frames_to_mj2, mj2_to_frames, extract_j2k_from_mj2 and wrap_j2k_in_mj2
+SET(common_SRCS "")
+IF(DONT_HAVE_GETOPT)
+ SET(common_SRCS ${OPENJPEG_SOURCE_DIR}/common/getopt.c)
+ENDIF(DONT_HAVE_GETOPT)
+
+# While mj2 executables do not use the API correctly, we do not link with the library but rather compile the sources files.
+SET(OPJ_SRCS
+${OPENJPEG_SOURCE_DIR}/libopenjpeg/bio.c
+${OPENJPEG_SOURCE_DIR}/libopenjpeg/cio.c
+${OPENJPEG_SOURCE_DIR}/libopenjpeg/dwt.c
+${OPENJPEG_SOURCE_DIR}/libopenjpeg/event.c
+${OPENJPEG_SOURCE_DIR}/libopenjpeg/image.c
+${OPENJPEG_SOURCE_DIR}/libopenjpeg/j2k.c
+${OPENJPEG_SOURCE_DIR}/libopenjpeg/j2k_lib.c
+${OPENJPEG_SOURCE_DIR}/libopenjpeg/jp2.c
+${OPENJPEG_SOURCE_DIR}/libopenjpeg/jpt.c
+${OPENJPEG_SOURCE_DIR}/libopenjpeg/mct.c
+${OPENJPEG_SOURCE_DIR}/libopenjpeg/mqc.c
+${OPENJPEG_SOURCE_DIR}/libopenjpeg/openjpeg.c
+${OPENJPEG_SOURCE_DIR}/libopenjpeg/pi.c
+${OPENJPEG_SOURCE_DIR}/libopenjpeg/raw.c
+${OPENJPEG_SOURCE_DIR}/libopenjpeg/t1.c
+${OPENJPEG_SOURCE_DIR}/libopenjpeg/t2.c
+${OPENJPEG_SOURCE_DIR}/libopenjpeg/tcd.c
+${OPENJPEG_SOURCE_DIR}/libopenjpeg/tgt.c
+)
+
+SET(MJ2_SRCS mj2.c mj2_convert.c)
+
+IF(WIN32)
+ ADD_DEFINITIONS(-DOPJ_STATIC)
+ENDIF(WIN32)
+
# Headers file are located here:
INCLUDE_DIRECTORIES(
${OPENJPEG_SOURCE_DIR}/libopenjpeg
ADD_EXECUTABLE(frames_to_mj2
frames_to_mj2.c
- ${PROJECT_SOURCE_DIR}/common/getopt.c
- mj2_convert.c
- mj2.c
+ ${common_SRCS}
+ ${OPJ_SRCS}
+ ${MJ2_SRCS}
)
-TARGET_LINK_LIBRARIES(frames_to_mj2 ${OPENJPEG_LIBRARY_NAME} ${LCMS_LIB})
+TARGET_LINK_LIBRARIES(frames_to_mj2 ${LCMS_LIB})
IF(UNIX)
TARGET_LINK_LIBRARIES(frames_to_mj2 m)
ENDIF(UNIX)
ADD_EXECUTABLE(mj2_to_frames
mj2_to_frames.c
- ${PROJECT_SOURCE_DIR}/common/getopt.c
- mj2_convert.c
- mj2.c
- ${PROJECT_SOURCE_DIR}/common/color.c
+ ${common_SRCS}
+ ${OPJ_SRCS}
+ ${MJ2_SRCS}
+ ${OPENJPEG_SOURCE_DIR}/common/color.c
)
-TARGET_LINK_LIBRARIES(mj2_to_frames ${OPENJPEG_LIBRARY_NAME} ${LCMS_LIB})
+TARGET_LINK_LIBRARIES(mj2_to_frames ${LCMS_LIB})
IF(UNIX)
TARGET_LINK_LIBRARIES(mj2_to_frames m)
ENDIF(UNIX)
ADD_EXECUTABLE(extract_j2k_from_mj2
extract_j2k_from_mj2.c
- mj2.c )
-TARGET_LINK_LIBRARIES(extract_j2k_from_mj2 ${OPENJPEG_LIBRARY_NAME} ${LCMS_LIB})
+ ${OPJ_SRCS}
+ ${MJ2_SRCS}
+ )
+TARGET_LINK_LIBRARIES(extract_j2k_from_mj2 ${LCMS_LIB})
IF(UNIX)
TARGET_LINK_LIBRARIES(extract_j2k_from_mj2 m)
ENDIF(UNIX)
ADD_EXECUTABLE(wrap_j2k_in_mj2
wrap_j2k_in_mj2.c
- mj2.c )
-TARGET_LINK_LIBRARIES(wrap_j2k_in_mj2 ${OPENJPEG_LIBRARY_NAME} ${LCMS_LIB})
+ ${OPJ_SRCS}
+ ${MJ2_SRCS}
+ )
+TARGET_LINK_LIBRARIES(wrap_j2k_in_mj2 ${LCMS_LIB})
IF(UNIX)
TARGET_LINK_LIBRARIES(wrap_j2k_in_mj2 m)
ENDIF(UNIX)