X-Git-Url: https://code.delx.au/refind/blobdiff_plain/46faec0a58150d49c53d2b4d551e5c4816d39d5f..9c917ffe1970dea18cabcc2ce1f1cc6482579f55:/libeg/lodepng.h diff --git a/libeg/lodepng.h b/libeg/lodepng.h index 2119fae..42bd04b 100644 --- a/libeg/lodepng.h +++ b/libeg/lodepng.h @@ -1,18 +1,7 @@ /* - * libeg/lodepng.h - * PNG handling code - * Slightly modified from LodePNG (see below for copyright and - * original license). - * Modifications copyright (c) 2013 by Roderick W. Smith, and - * distributed under the terms of the GNU GPL v3. See - * http://lodev.org/lodepng/ for the original code. - * - */ +LodePNG version 20130415 -/* -LodePNG version 20121216 - -Copyright (c) 2005-2012 Lode Vandevenne +Copyright (c) 2005-2013 Lode Vandevenne This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -37,10 +26,12 @@ freely, subject to the following restrictions: #ifndef LODEPNG_H #define LODEPNG_H -//#include /*for size_t*/ +#include /*for size_t*/ -#include "global.h" -#define size_t UINTN +// Below two lines required for GNU-EFI (program hangs when run without them, +// and associated function in lodepng_xtra.c) +int MyStrlen(const char *InString); +#define strlen(c) MyStrlen(c) #ifdef __cplusplus #include @@ -83,12 +74,18 @@ the custom_zlib field of the compress and decompress settings*/ // #ifndef LODEPNG_NO_COMPILE_ERROR_TEXT // #define LODEPNG_COMPILE_ERROR_TEXT // #endif -/*compile the C++ version (you can disable the C++ wrapper here even when compiling for C++)*/ -// #ifdef __cplusplus -// #ifndef LODEPNG_NO_COMPILE_CPP -// #define LODEPNG_COMPILE_CPP -// #endif +/*Compile the default allocators (C's free, malloc and realloc). If you disable this, +you can define the functions lodepng_free, lodepng_malloc and lodepng_realloc in your +source files with custom allocators.*/ +// #ifndef LODEPNG_NO_COMPILE_ALLOCATORS +// #define LODEPNG_COMPILE_ALLOCATORS // #endif +/*compile the C++ version (you can disable the C++ wrapper here even when compiling for C++)*/ +#ifdef __cplusplus +#ifndef LODEPNG_NO_COMPILE_CPP +#define LODEPNG_COMPILE_CPP +#endif +#endif #ifdef LODEPNG_COMPILE_PNG /*The PNG color types (also used for raw).*/ @@ -249,7 +246,7 @@ unsigned encode(const std::string& filename, #ifdef LODEPNG_COMPILE_ERROR_TEXT /*Returns an English description of the numerical error code.*/ -const CHAR16* lodepng_error_text(unsigned code); +const char* lodepng_error_text(unsigned code); #endif /*LODEPNG_COMPILE_ERROR_TEXT*/ #ifdef LODEPNG_COMPILE_DECODER @@ -317,7 +314,6 @@ Color mode of an image. Contains all information required to decode the pixel bits to RGBA colors. This information is the same as used in the PNG file format, and is used both for PNG and raw image data in LodePNG. */ - typedef struct LodePNGColorMode { /*header (IHDR)*/ @@ -337,7 +333,7 @@ typedef struct LodePNGColorMode The palette is only supported for color type 3. */ - unsigned char* palette; /*palette in RGBARGBA... order*/ + unsigned char* palette; /*palette in RGBARGBA... order. When allocated, must be either 0, or have size 1024*/ size_t palettesize; /*palette size in number of colors (amount of bytes is 4 * palettesize)*/ /* @@ -395,7 +391,6 @@ size_t lodepng_get_raw_size(unsigned w, unsigned h, const LodePNGColorMode* colo #ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS /*The information of a Time chunk in PNG.*/ - typedef struct LodePNGTime { unsigned year; /*2 bytes used (0-65535)*/ @@ -408,7 +403,6 @@ typedef struct LodePNGTime #endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/ /*Information about the PNG image, except pixels, width and height.*/ - typedef struct LodePNGInfo { /*header (IHDR), palette (PLTE) and transparency (tRNS) chunks*/ @@ -508,11 +502,12 @@ See the reference manual at the end of this header file to see which color conve return value = LodePNG error code (0 if all went ok, an error if the conversion isn't supported) The out buffer must have size (w * h * bpp + 7) / 8, where bpp is the bits per pixel of the output color type (lodepng_get_bpp) +The fix_png value makes it ignore out of bound palette indices. Note: for 16-bit per channel colors, uses big endian format like PNG does. */ unsigned lodepng_convert(unsigned char* out, const unsigned char* in, LodePNGColorMode* mode_out, LodePNGColorMode* mode_in, - unsigned w, unsigned h); + unsigned w, unsigned h, unsigned fix_png); #ifdef LODEPNG_COMPILE_DECODER @@ -520,12 +515,12 @@ unsigned lodepng_convert(unsigned char* out, const unsigned char* in, Settings for the decoder. This contains settings for the PNG and the Zlib decoder, but not the Info settings from the Info structs. */ - typedef struct LodePNGDecoderSettings { LodePNGDecompressSettings zlibsettings; /*in here is the setting to ignore Adler32 checksums*/ unsigned ignore_crc; /*ignore CRC checksums*/ + unsigned fix_png; /*if 1, try to parse some broken PNG images, e.g. with out of bound palette.*/ unsigned color_convert; /*whether to convert the PNG to the color type you want. Default: yes*/ #ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS @@ -543,7 +538,7 @@ void lodepng_decoder_settings_init(LodePNGDecoderSettings* settings); typedef enum LodePNGFilterStrategy { /*every filter at zero*/ - LFS_ZERO, + LFS_ZERO, /*Use filter that gives minumum sum, as described in the official PNG filter heuristic.*/ LFS_MINSUM, /*Use the filter type that gives smallest Shannon entropy for this scanline. Depending @@ -555,7 +550,7 @@ typedef enum LodePNGFilterStrategy */ LFS_BRUTE_FORCE, /*use predefined_filters buffer: you specify the filter type for each scanline*/ - LFS_PREDEFINED + LFS_PREDEFINED } LodePNGFilterStrategy; /*automatically use color type with less bits per pixel if losslessly possible. Default: LAC_AUTO*/ @@ -582,7 +577,6 @@ typedef enum LodePNGAutoConvert /*Settings for the encoder.*/ - typedef struct LodePNGEncoderSettings { LodePNGCompressSettings zlibsettings; /*settings for the zlib encoder, such as window size, ...*/ @@ -620,7 +614,6 @@ void lodepng_encoder_settings_init(LodePNGEncoderSettings* settings); #if defined(LODEPNG_COMPILE_DECODER) || defined(LODEPNG_COMPILE_ENCODER) /*The settings, state and information for extended encoding and decoding.*/ - typedef struct LodePNGState { #ifdef LODEPNG_COMPILE_DECODER @@ -882,7 +875,6 @@ unsigned compress(std::vector& out, const std::vector