4418N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4418N/A * This code is free software; you can redistribute it and/or modify it 4418N/A * under the terms of the GNU General Public License version 2 only, as 4418N/A * published by the Free Software Foundation. Oracle designates this 4418N/A * particular file as subject to the "Classpath" exception as provided 4418N/A * by Oracle in the LICENSE file that accompanied this code. 4418N/A * This code is distributed in the hope that it will be useful, but WITHOUT 4418N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 4418N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 4418N/A * version 2 for more details (a copy is included in the LICENSE file that 4418N/A * You should have received a copy of the GNU General Public License version 4418N/A * 2 along with this work; if not, write to the Free Software Foundation, 4418N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 4418N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 4418N/A * This file is available under and governed by the GNU General Public 4418N/A * License version 2 only, as published by the Free Software Foundation. 4418N/A * However, the following notice accompanied the original version of this 4418N/A * file and, per its terms, should not be removed: 4418N/A * For conditions of distribution and use, see copyright notice in png.h 4418N/A * Copyright (c) 1998-2011 Glenn Randers-Pehrson 4418N/A * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 4418N/A * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 4418N/A * Last changed in libpng 1.5.4 [July 7, 2011] 4418N/A * This code is released under the libpng license. 4418N/A * For conditions of distribution and use, see the disclaimer 4418N/A/* The symbols declared in this file (including the functions declared 4418N/A * as PNG_EXTERN) are PRIVATE. They are not part of the libpng public 4418N/A * interface, and are not recommended for use by regular applications. 4418N/A * Some of them may become public in the future; others may stay private, 4418N/A * change in an incompatible way, or even disappear. 4418N/A * Although the libpng users are not forbidden to include this header, 4418N/A * they should be well aware of the issues that may arise from doing so. 4418N/A/* Feature Test Macros. The following are defined here to ensure that correctly 4418N/A * implemented libraries reveal the APIs libpng needs to build and hide those 4418N/A * that are not needed and potentially damaging to the compilation. 4418N/A * Feature Test Macros must be defined before any system header is included (see 4418N/A * POSIX 1003.1 2.8.2 "POSIX Symbols." 4418N/A * These macros only have an effect if the operating system supports either 4418N/A * POSIX 1003.1 or C99, or both. On other operating systems (particularly 4418N/A * still required (as of 2011-05-02.) 4418N/A/* This is required for the definition of abort(), used as a last ditch 4418N/A * error handler when all else fails. 4418N/A/* This is used for 16 bit gamma tables - only the top level pointers are const, 4418N/A/* config.h is created by and PNG_CONFIGURE_LIBPNG is set by the "configure" 4418N/A * script. We may need it here to get the correct configuration on things 4418N/A/* NOTE: some of these may have been used in external applications as 4418N/A/* If you are running on a machine where you cannot allocate more 4418N/A * than 64K of memory at once, uncomment this. While libpng will not 4418N/A * normally need that much memory in a chunk (unless you load up a very 4418N/A * large file), zlib needs to know how big of a chunk it can use, and 4418N/A * libpng thus makes sure to check any memory allocation to verify it 4418N/A * zlib provides 'MAXSEG_64K' which, if defined, indicates the 4418N/A * if certain operating systems are detected. 4418N/A/* Unused formal parameter warnings are silenced using the following macro 4418N/A * which is expected to have no bad effects on performance (optimizing 4418N/A * compilers will probably remove it entirely). Note that if you replace 4418N/A * it with something other than whitespace, you must include the terminating 4418N/A/* Just a little check that someone hasn't tried to define something 4418N/A/* PNG_STATIC is used to mark internal file scope functions if they need to be 4418N/A * accessed for implementation tests (see the code in tests/?*). 4418N/A/* If warnings or errors are turned off the code is disabled or redirected here. 4418N/A * From 1.5.4 functions have been added to allow very limited formatting of 4418N/A * error and warning messages - this code will also be disabled here. 4418N/A/* The functions exported by PNG_EXTERN are internal functions, which 4418N/A * aren't usually used outside the library (as far as I know), so it is 4418N/A * debatable if they should be exported at all. In the future, when it 4418N/A * is possible to have run-time registry of chunk-handling functions, 4418N/A * some of these might be made available again. 4418N/A/* Some fixed point APIs are still required even if not exported because 4418N/A * they get used by the corresponding floating point APIs. This magic 4418N/A/* Other defines specific to compilers can go here. Try to keep 4418N/A /* png.c requires the following ANSI-C constants if the conversion of 4418N/A * floating point to ASCII is implemented therein: 4418N/A * DBL_DIG Maximum number of decimal digits (can be set to any constant) 4418N/A * DBL_MIN Smallest normalized fp number (can be set to an arbitrary value) 4418N/A * DBL_MAX Maximum floating point number (can be set to an arbitrary value) 4418N/A /* We need to check that <math.h> hasn't already been included earlier 4418N/A * as it seems it doesn't agree with <fp.h>, yet we should really use 4418N/A /* Amiga SAS/C: We must include builtin FPU functions when compiling using 4418N/A/* This provides the non-ANSI (far) memory allocation routines. */ 4418N/A/* Users may want to use these so they are not private. Any library 4418N/A * functions that are passed far data must be model-independent. 4418N/A/* Use this to make far-to-near assignments */ 4418N/A/* CONSTANTS and UTILITY MACROS 4418N/A * These are used internally by libpng and not exposed in the API 4418N/A/* Various modes of operation. Note that after an init, mode is set to 4418N/A * zero automatically when the structure is created. Three of these 4418N/A * are defined in png.h because they need to be visible to applications 4418N/A * that call png_set_unknown_chunk(). 4418N/A/* Flags for the transformations the PNG library does on the image data */ 4418N/A/* Flags for png_create_struct */ 4418N/A/* Scaling factor for filter heuristic weighting calculations */ 4418N/A/* Flags for the png_ptr->flags rather than declaring a byte for each one */ 4418N/A/* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib 4418N/A * can handle at once. This type need be no larger than 16 bits (so maximum of 4418N/A * 65535), this define allows us to discover how big it is, but limited by the 4418N/A * maximuum for png_size_t. The value can be overriden in a library build 4418N/A * (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably 4418N/A * lower value (e.g. 255 works). A lower value may help memory usage (slightly) 4418N/A * and may even improve performance on some systems (and degrade it on others.) 4418N/A/* Save typing and make code easier to understand */ 4418N/A/* Added to libpng-1.2.6 JB */ 4418N/A/* PNG_OUT_OF_RANGE returns true if value is outside the range 4418N/A * ideal-delta..ideal+delta. Each argument is evaluated twice. 4418N/A * "ideal" and "delta" should be constants, normally simple 4418N/A * integers, "value" a variable. Added to libpng-1.2.6 JB 4418N/A/* Conversions between fixed and floating point, only defined if 4418N/A * required (to make sure the code doesn't accidentally use float 4418N/A * when it is supposedly disabled.) 4418N/A/* The floating point conversion can't overflow, though it can and 4418N/A * does lose accuracy relative to the original fixed point value. 4418N/A * In practice this doesn't matter because png_fixed_point only 4418N/A * stores numbers with very low precision. The png_ptr and s 4418N/A * arguments are unused by default but are there in case error 4418N/A * checking becomes a requirement. 4418N/A/* The fixed point conversion performs range checking and evaluates 4418N/A * its argument multiple times, so must be used with care. The 4418N/A * range checking uses the PNG specification values for a signed 4418N/A * 32 bit fixed point value except that the values are deliberately 4418N/A * rounded-to-zero to an integral value - 21474 (21474.83 is roughly 4418N/A * (2^31-1) * 100000). 's' is a string that describes the value being 4418N/A * NOTE: this macro will raise a png_error if the range check fails, 4418N/A * therefore it is normally only appropriate to use this on values 4418N/A * that come from API calls or other sources where an out of range 4418N/A * error indicates a programming error, not a data error! 4418N/A * NOTE: by default this is off - the macro is not used - because the 4418N/A * function call saves a lot of code. 4418N/A/* Constant strings for known chunk types. If you need to add a chunk, 4418N/A * define the name here, and add an invocation of the macro wherever it's 4418N/A/* Gamma values (new at libpng-1.5.4): */ 4418N/A/* Inhibit C++ name-mangling for libpng functions but not for system calls. */ 4418N/A/* These functions are used internally in the code. They generally 4418N/A * shouldn't be used unless you are writing code to add or replace some 4418N/A * functionality in libpng. More information about most functions can 4418N/A * be found in the files where the functions are located. 4418N/A/* Check the user version string for compatibility, returns false if the version 4418N/A * numbers aren't compatible. 4418N/A/* Allocate memory for an internal libpng struct */ 4418N/A/* Free memory from internal libpng struct */ 4418N/A/* Free any memory that info_ptr points to and reset struct. */ 4418N/A/* Function to allocate memory for zlib. PNGAPI is disallowed. */ 4418N/A/* Function to free memory for zlib. PNGAPI is disallowed. */ 4418N/A/* Next four functions are used internally as callbacks. PNGCBAPI is required 4418N/A * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3, changed to 4418N/A/* Reset the CRC variable */ 4418N/A/* Write the "data" buffer to whatever output you are using */ 4418N/A/* Read and check the PNG file signature */ 4418N/A/* Read the chunk header (length + type name) */ 4418N/A/* Read data from whatever input you are using into the "data" buffer */ 4418N/A/* Read bytes into buf, and update png_ptr->crc */ 4418N/A/* Decompress data in a chunk that uses compression */ 4418N/A/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */ 4418N/A/* Read the CRC from the file and compare it to the libpng calculated CRC */ 4418N/A/* Calculate the CRC over a section of data. Note that we are only 4418N/A * passing a maximum of 64K on systems that have this as a memory limit, 4418N/A * since this is the maximum buffer size we can specify. 4418N/A/* Write the IHDR chunk, and update the png_struct with the necessary 4418N/A /* Note to maintainer: profile should be png_bytep */ 4418N/A/* Chunks that have keywords */ 4418N/A/* Called when finished processing a row of data */ 4418N/A/* Internal use only. Called before first row of data */ 4418N/A/* Combine a row of data, dealing with alpha, etc. if requested */ 4418N/A/* Expand an interlaced row */ 4418N/APNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info, 4418N/A png_bytep row, int pass, png_uint_32 transformations)); 4418N/A/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */ 4418N/A/* Grab pixels out of a row for an interlaced pass */ 4418N/A/* Choose the best filter to use and filter the row data */ 4418N/A/* Finish a row while reading, dealing with interlacing passes, etc. */ 4418N/A/* Initialize the row buffers, etc. */ 4418N/A/* Optional call to update the users info structure */ 4418N/A/* These are the functions that do the transformations */ 4418N/A/* The following decodes the appropriate chunks, and does error correction, 4418N/A * then calls the appropriate callback for the chunk if it is valid. 4418N/A#
endif /* PNG_READ_iCCP_SUPPORTED */ 4418N/A#
endif /* PNG_READ_sPLT_SUPPORTED */ 4418N/A/* Handle the transformations for reading and writing */ 4418N/A#
endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ 4418N/A/* Added at libpng version 1.4.0 */ 4418N/A/* Added at libpng version 1.2.34 and 1.4.0 */ 4418N/A/* Currently only used by png_check_cHRM_fixed */ 4418N/A/* Added at libpng version 1.4.0 */ 4418N/A/* Free all memory used by the read (old method - NOT DLL EXPORTED) */ 4418N/A/* Free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */ 4418N/A#
endif /* USE_FAR_KEYWORD */ 4418N/A/* Puts 'string' into 'buffer' at buffer[pos], taking care never to overwrite 4418N/A * the end. Always leaves the buffer nul terminated. Never errors out (and 4418N/A/* Various internal functions to handle formatted warning messages, currently 4418N/A * only implemented for warnings. 4418N/A/* Utility to dump an unsigned value into a buffer, given a start pointer and 4418N/A * and end pointer (which should point just *beyond* the end of the buffer!) 4418N/A * Returns the pointer to the start of the formatted string. This utility only 4418N/A/* Convenience macro that takes an array: */ 4418N/A/* Suggested size for a number buffer (enough for 64 bits and a sign!) */ 4418N/A/* These are the integer formats currently supported, the name is formed from 4418N/A * the standard printf(3) format string. 4418N/A/* New defines and members adding in libpng-1.5.4 */ 4418N/A/* An l-value of this type has to be passed to the APIs below to cache the 4418N/A * values of the parameters to a formatted warning message. 4418N/A /* Parameters are limited in size to PNG_WARNING_PARAMETER_SIZE characters, 4418N/A * including the trailing '\0'. 4418N/A /* Use png_alloc_size_t because it is an unsigned type as big as any we 4418N/A * need to output. Use the following for a signed value. 4418N/A /* 'message' follows the X/Open approach of using @1, @2 to insert 4418N/A * parameters previously supplied using the above functions. Errors in 4418N/A * specifying the paramters will simple result in garbage substitutions. 4418N/A/* ASCII to FP interfaces, currently only implemented if sCAL 4418N/A/* MAX_DIGITS is actually the maximum number of characters in an sCAL 4418N/A * width or height, derived from the precision (number of significant 4418N/A * digits - a build time settable option) and assumpitions about the 4418N/A * maximum ridiculous exponent. 4418N/A/* An internal API to validate the format of a floating point number. 4418N/A * The result is the index of the next character. If the number is 4418N/A * not valid it will be the index of a character in the supposed number. 4418N/A * The format of a number is defined in the PNG extensions specification 4418N/A * and this API is strictly conformant to that spec, not anyone elses! 4418N/A * The format as a regular expression is: 4418N/A * [+-]?[0-9]+.?([Ee][+-]?[0-9]+)? 4418N/A * [+-]?.[0-9]+(.[0-9]+)?([Ee][+-]?[0-9]+)? 4418N/A * The complexity is that either integer or fraction must be present and the 4418N/A * fraction is permitted to have no digits only if the integer is present. 4418N/A * NOTE: The dangling E problem. 4418N/A * There is a PNG valid floating point number in the following: 4418N/A * PNG floating point numb1.ers are not greedy. 4418N/A * Working this out requires *TWO* character lookahead (because of the 4418N/A * sign), the parser does not do this - it will fail at the 'r' - this 4418N/A * doesn't matter for PNG sCAL chunk values, but it requires more care 4418N/A * if the value were ever to be embedded in something more complex. Use 4418N/A * ANSI-C strtod if you need the lookahead. 4418N/A/* State table for the parser. */ 4418N/A/* These three values don't affect the parser. They are set but not used. 4418N/A/* This is available for the caller to store in 'state' if required. Do not 4418N/A * call the parser after setting it (the parser sometimes clears it.) 4418N/A/* Result codes for the parser (boolean - true meants ok, false means 4418N/A/* Tests on the sticky non-zero and negative flags. To pass these checks 4418N/A * the state must also indicate that the whole number is valid - this is 4418N/A * achieved by testing PNG_FP_SAW_DIGIT (see the implementation for why this 4418N/A * is equivalent to PNG_FP_OK above.) 4418N/A /* NZ_MASK: the string is valid and a non-zero negative value */ 4418N/A /* Z MASK: the string is valid and a non-zero value. */ 4418N/A /* PNG_FP_SAW_DIGIT: the string is valid. */ 4418N/A/* The actual parser. This can be called repeatedly, it updates 4418N/A * the index into the string and the state variable (which must 4418N/A * be initialzed to 0). It returns a result code, as above. There 4418N/A * is no point calling the parser any more if it fails to advance to 4418N/A * the end of the string - it is stuck on an invalid character (or 4418N/A * Note that the pointer will consume an E or even an E+ then leave 4418N/A * a 'maybe' state even though a preceding integer.fraction is valid. 4418N/A * The PNG_FP_WAS_VALID flag indicates that a preceding substring was 4418N/A * a valid number. It's possible to recover from this by calling 4418N/A * the parser again (from the start, with state 0) but with a string 4418N/A * that omits the last character (i.e. set the size to the index of 4418N/A * the problem character.) This has not been tested within libpng. 4418N/A/* This is the same but it checks a complete string and returns true 4418N/A * only if it just contains a floating point number. As of 1.5.4 this 4418N/A * function also returns the state at the end of parsing the number if 4418N/A * it was valid (otherwise it returns 0.) This can be used for testing 4418N/A * for negative or zero values using the sticky flag. 4418N/A/* Added at libpng version 1.5.0 */ 4418N/A * if there is an overflow. The result is a boolean - false (0) 4418N/A * for overflow, true (1) if no overflow, in which case *res 4418N/A/* Same deal, but issue a warning on overflow and return 0. */ 4418N/A/* Calculate a reciprocal - used for gamma values. This returns 4418N/A * 0 if the argument is 0 in order to maintain an undefined value, 4418N/A/* The same but gives a reciprocal of the product of two fixed point 4418N/A * values. Accuracy is suitable for gamma calculations but this is 4418N/A * not exact - use png_muldiv for that. 4418N/A/* Internal fixed point gamma correction. These APIs are called as 4418N/A * required to convert single values - they don't need to be fast, 4418N/A * they are not used when processing image pixel values. 4418N/A * While the input is an 'unsigned' value it must actually be the 4418N/A * correct bit value - 0..255 or 0..65535 as required. 4418N/A/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */