31 extern const char* LODEPNG_VERSION_STRING;
44 #ifndef LODEPNG_NO_COMPILE_ZLIB 45 #define LODEPNG_COMPILE_ZLIB 49 #ifndef LODEPNG_NO_COMPILE_PNG 50 #define LODEPNG_COMPILE_PNG 54 #ifndef LODEPNG_NO_COMPILE_DECODER 55 #define LODEPNG_COMPILE_DECODER 59 #ifndef LODEPNG_NO_COMPILE_ENCODER 60 #define LODEPNG_COMPILE_ENCODER 64 #ifndef LODEPNG_NO_COMPILE_DISK 65 #define LODEPNG_COMPILE_DISK 69 #ifndef LODEPNG_NO_COMPILE_ANCILLARY_CHUNKS 70 #define LODEPNG_COMPILE_ANCILLARY_CHUNKS 74 #ifndef LODEPNG_NO_COMPILE_ERROR_TEXT 75 #define LODEPNG_COMPILE_ERROR_TEXT 81 #ifndef LODEPNG_NO_COMPILE_ALLOCATORS 82 #define LODEPNG_COMPILE_ALLOCATORS 87 #ifndef LODEPNG_NO_COMPILE_CPP 88 #define LODEPNG_COMPILE_CPP 92 #ifdef LODEPNG_COMPILE_CPP 97 #ifdef LODEPNG_COMPILE_PNG 99 typedef enum LodePNGColorType {
107 #ifdef LODEPNG_COMPILE_DECODER 123 unsigned lodepng_decode_memory(
unsigned char** out,
unsigned* w,
unsigned* h,
124 const unsigned char* in,
size_t insize,
125 LodePNGColorType colortype,
unsigned bitdepth);
128 unsigned lodepng_decode32(
unsigned char** out,
unsigned* w,
unsigned* h,
129 const unsigned char* in,
size_t insize);
132 unsigned lodepng_decode24(
unsigned char** out,
unsigned* w,
unsigned* h,
133 const unsigned char* in,
size_t insize);
135 #ifdef LODEPNG_COMPILE_DISK 140 unsigned lodepng_decode_file(
unsigned char** out,
unsigned* w,
unsigned* h,
141 const char* filename,
142 LodePNGColorType colortype,
unsigned bitdepth);
145 unsigned lodepng_decode32_file(
unsigned char** out,
unsigned* w,
unsigned* h,
146 const char* filename);
149 unsigned lodepng_decode24_file(
unsigned char** out,
unsigned* w,
unsigned* h,
150 const char* filename);
155 #ifdef LODEPNG_COMPILE_ENCODER 172 unsigned lodepng_encode_memory(
unsigned char** out,
size_t* outsize,
173 const unsigned char* image,
unsigned w,
unsigned h,
174 LodePNGColorType colortype,
unsigned bitdepth);
177 unsigned lodepng_encode32(
unsigned char** out,
size_t* outsize,
178 const unsigned char* image,
unsigned w,
unsigned h);
181 unsigned lodepng_encode24(
unsigned char** out,
size_t* outsize,
182 const unsigned char* image,
unsigned w,
unsigned h);
184 #ifdef LODEPNG_COMPILE_DISK 190 unsigned lodepng_encode_file(
const char* filename,
191 const unsigned char* image,
unsigned w,
unsigned h,
192 LodePNGColorType colortype,
unsigned bitdepth);
195 unsigned lodepng_encode32_file(
const char* filename,
196 const unsigned char* image,
unsigned w,
unsigned h);
199 unsigned lodepng_encode24_file(
const char* filename,
200 const unsigned char* image,
unsigned w,
unsigned h);
205 #ifdef LODEPNG_COMPILE_CPP 207 #ifdef LODEPNG_COMPILE_DECODER 210 unsigned decode(std::vector<unsigned char>& out,
unsigned& w,
unsigned& h,
211 const unsigned char* in,
size_t insize,
212 LodePNGColorType colortype = LCT_RGBA,
unsigned bitdepth = 8);
213 unsigned decode(std::vector<unsigned char>& out,
unsigned& w,
unsigned& h,
214 const std::vector<unsigned char>& in,
215 LodePNGColorType colortype = LCT_RGBA,
unsigned bitdepth = 8);
216 #ifdef LODEPNG_COMPILE_DISK 221 unsigned decode(std::vector<unsigned char>& out,
unsigned& w,
unsigned& h,
222 const std::string& filename,
223 LodePNGColorType colortype = LCT_RGBA,
unsigned bitdepth = 8);
227 #ifdef LODEPNG_COMPILE_ENCODER 230 unsigned encode(std::vector<unsigned char>& out,
231 const unsigned char* in,
unsigned w,
unsigned h,
232 LodePNGColorType colortype = LCT_RGBA,
unsigned bitdepth = 8);
233 unsigned encode(std::vector<unsigned char>& out,
234 const std::vector<unsigned char>& in,
unsigned w,
unsigned h,
235 LodePNGColorType colortype = LCT_RGBA,
unsigned bitdepth = 8);
236 #ifdef LODEPNG_COMPILE_DISK 242 unsigned encode(
const std::string& filename,
243 const unsigned char* in,
unsigned w,
unsigned h,
244 LodePNGColorType colortype = LCT_RGBA,
unsigned bitdepth = 8);
245 unsigned encode(
const std::string& filename,
246 const std::vector<unsigned char>& in,
unsigned w,
unsigned h,
247 LodePNGColorType colortype = LCT_RGBA,
unsigned bitdepth = 8);
254 #ifdef LODEPNG_COMPILE_ERROR_TEXT 256 const char* lodepng_error_text(
unsigned code);
259 #ifdef LODEPNG_COMPILE_DECODER 264 unsigned ignore_adler32;
267 unsigned (*custom_zlib)(
unsigned char**,
size_t*,
268 const unsigned char*, size_t,
273 unsigned (*custom_inflate)(
unsigned char**,
size_t*,
274 const unsigned char*, size_t,
277 const void* custom_context;
284 #ifdef LODEPNG_COMPILE_ENCODER 290 struct LodePNGCompressSettings {
297 unsigned lazymatching;
300 unsigned (*custom_zlib)(
unsigned char**,
size_t*,
301 const unsigned char*, size_t,
302 const LodePNGCompressSettings*);
306 unsigned (*custom_deflate)(
unsigned char**,
size_t*,
307 const unsigned char*, size_t,
308 const LodePNGCompressSettings*);
310 const void* custom_context;
313 extern const LodePNGCompressSettings lodepng_default_compress_settings;
314 void lodepng_compress_settings_init(LodePNGCompressSettings* settings);
317 #ifdef LODEPNG_COMPILE_PNG 325 LodePNGColorType colortype;
341 unsigned char* palette;
355 unsigned key_defined;
367 LodePNGColorMode lodepng_color_mode_make(LodePNGColorType colortype,
unsigned bitdepth);
372 unsigned char r,
unsigned char g,
unsigned char b,
unsigned char a);
397 size_t lodepng_get_raw_size(
unsigned w,
unsigned h,
const LodePNGColorMode* color);
399 #ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS 414 unsigned compression_method;
415 unsigned filter_method;
416 unsigned interlace_method;
419 #ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS 443 unsigned background_defined;
444 unsigned background_r;
445 unsigned background_g;
446 unsigned background_b;
476 char** itext_langtags;
477 char** itext_transkeys;
478 char** itext_strings;
481 unsigned time_defined;
485 unsigned phys_defined;
501 unsigned gama_defined;
505 unsigned chrm_defined;
506 unsigned chrm_white_x;
507 unsigned chrm_white_y;
510 unsigned chrm_green_x;
511 unsigned chrm_green_y;
512 unsigned chrm_blue_x;
513 unsigned chrm_blue_y;
520 unsigned srgb_defined;
521 unsigned srgb_intent;
544 unsigned iccp_defined;
551 unsigned char* iccp_profile;
552 unsigned iccp_profile_size;
574 unsigned char* unknown_chunks_data[3];
575 size_t unknown_chunks_size[3];
585 #ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS 586 unsigned lodepng_add_text(
LodePNGInfo* info,
const char* key,
const char* str);
589 unsigned lodepng_add_itext(
LodePNGInfo* info,
const char* key,
const char* langtag,
590 const char* transkey,
const char* str);
594 unsigned lodepng_set_icc(
LodePNGInfo* info,
const char* name,
const unsigned char* profile,
unsigned profile_size);
609 unsigned lodepng_convert(
unsigned char* out,
const unsigned char* in,
611 unsigned w,
unsigned h);
613 #ifdef LODEPNG_COMPILE_DECODER 623 unsigned ignore_critical;
630 unsigned color_convert;
632 #ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS 633 unsigned read_text_chunks;
635 unsigned remember_unknown_chunks;
642 #ifdef LODEPNG_COMPILE_ENCODER 644 typedef enum LodePNGFilterStrategy {
659 } LodePNGFilterStrategy;
669 unsigned short key_r;
670 unsigned short key_g;
671 unsigned short key_b;
674 unsigned char palette[1024];
685 const unsigned char* image,
unsigned w,
unsigned h,
690 const unsigned char* image,
unsigned w,
unsigned h,
695 LodePNGCompressSettings zlibsettings;
697 unsigned auto_convert;
703 unsigned filter_palette_zero;
706 LodePNGFilterStrategy filter_strategy;
711 const unsigned char* predefined_filters;
715 unsigned force_palette;
716 #ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS 720 unsigned text_compression;
728 #if defined(LODEPNG_COMPILE_DECODER) || defined(LODEPNG_COMPILE_ENCODER) 731 #ifdef LODEPNG_COMPILE_DECODER 734 #ifdef LODEPNG_COMPILE_ENCODER 740 #ifdef LODEPNG_COMPILE_CPP 752 #ifdef LODEPNG_COMPILE_DECODER 757 unsigned lodepng_decode(
unsigned char** out,
unsigned* w,
unsigned* h,
759 const unsigned char* in,
size_t insize);
766 unsigned lodepng_inspect(
unsigned* w,
unsigned* h,
768 const unsigned char* in,
size_t insize);
783 unsigned lodepng_inspect_chunk(
LodePNGState* state,
size_t pos,
784 const unsigned char* in,
size_t insize);
786 #ifdef LODEPNG_COMPILE_ENCODER 788 unsigned lodepng_encode(
unsigned char** out,
size_t* outsize,
789 const unsigned char* image,
unsigned w,
unsigned h,
822 unsigned lodepng_chunk_length(
const unsigned char* chunk);
825 void lodepng_chunk_type(
char type[5],
const unsigned char* chunk);
828 unsigned char lodepng_chunk_type_equals(
const unsigned char* chunk,
const char* type);
831 unsigned char lodepng_chunk_ancillary(
const unsigned char* chunk);
834 unsigned char lodepng_chunk_private(
const unsigned char* chunk);
837 unsigned char lodepng_chunk_safetocopy(
const unsigned char* chunk);
840 unsigned char* lodepng_chunk_data(
unsigned char* chunk);
841 const unsigned char* lodepng_chunk_data_const(
const unsigned char* chunk);
844 unsigned lodepng_chunk_check_crc(
const unsigned char* chunk);
847 void lodepng_chunk_generate_crc(
unsigned char* chunk);
860 unsigned char* lodepng_chunk_next(
unsigned char* chunk);
861 const unsigned char* lodepng_chunk_next_const(
const unsigned char* chunk);
864 unsigned char* lodepng_chunk_find(
unsigned char* chunk,
const unsigned char* end,
const char type[5]);
865 const unsigned char* lodepng_chunk_find_const(
const unsigned char* chunk,
const unsigned char* end,
const char type[5]);
872 unsigned lodepng_chunk_append(
unsigned char** out,
size_t* outlength,
const unsigned char* chunk);
880 unsigned lodepng_chunk_create(
unsigned char** out,
size_t* outlength,
unsigned length,
881 const char* type,
const unsigned char* data);
885 unsigned lodepng_crc32(
const unsigned char* buf,
size_t len);
889 #ifdef LODEPNG_COMPILE_ZLIB 896 #ifdef LODEPNG_COMPILE_DECODER 898 unsigned lodepng_inflate(
unsigned char** out,
size_t* outsize,
899 const unsigned char* in,
size_t insize,
908 unsigned lodepng_zlib_decompress(
unsigned char** out,
size_t* outsize,
909 const unsigned char* in,
size_t insize,
913 #ifdef LODEPNG_COMPILE_ENCODER 921 unsigned lodepng_zlib_compress(
unsigned char** out,
size_t* outsize,
922 const unsigned char* in,
size_t insize,
923 const LodePNGCompressSettings* settings);
929 unsigned lodepng_huffman_code_lengths(
unsigned* lengths,
const unsigned* frequencies,
930 size_t numcodes,
unsigned maxbitlen);
933 unsigned lodepng_deflate(
unsigned char** out,
size_t* outsize,
934 const unsigned char* in,
size_t insize,
935 const LodePNGCompressSettings* settings);
940 #ifdef LODEPNG_COMPILE_DISK 949 unsigned lodepng_load_file(
unsigned char** out,
size_t* outsize,
const char* filename);
959 unsigned lodepng_save_file(
const unsigned char* buffer,
size_t buffersize,
const char* filename);
962 #ifdef LODEPNG_COMPILE_CPP 965 #ifdef LODEPNG_COMPILE_PNG 969 State(
const State& other);
971 State& operator=(
const State& other);
974 #ifdef LODEPNG_COMPILE_DECODER 976 unsigned decode(std::vector<unsigned char>& out,
unsigned& w,
unsigned& h,
978 const unsigned char* in,
size_t insize);
979 unsigned decode(std::vector<unsigned char>& out,
unsigned& w,
unsigned& h,
981 const std::vector<unsigned char>& in);
984 #ifdef LODEPNG_COMPILE_ENCODER 986 unsigned encode(std::vector<unsigned char>& out,
987 const unsigned char* in,
unsigned w,
unsigned h,
989 unsigned encode(std::vector<unsigned char>& out,
990 const std::vector<unsigned char>& in,
unsigned w,
unsigned h,
994 #ifdef LODEPNG_COMPILE_DISK 999 unsigned load_file(std::vector<unsigned char>& buffer,
const std::string& filename);
1005 unsigned save_file(
const std::vector<unsigned char>& buffer,
const std::string& filename);
1009 #ifdef LODEPNG_COMPILE_ZLIB 1010 #ifdef LODEPNG_COMPILE_DECODER 1012 unsigned decompress(std::vector<unsigned char>& out,
const unsigned char* in,
size_t insize,
1016 unsigned decompress(std::vector<unsigned char>& out,
const std::vector<unsigned char>& in,
1020 #ifdef LODEPNG_COMPILE_ENCODER 1022 unsigned compress(std::vector<unsigned char>& out,
const unsigned char* in,
size_t insize,
1023 const LodePNGCompressSettings& settings = lodepng_default_compress_settings);
1026 unsigned compress(std::vector<unsigned char>& out,
const std::vector<unsigned char>& in,
1027 const LodePNGCompressSettings& settings = lodepng_default_compress_settings);
Definition: lodepng.h:666
Definition: lodepng.h:730
Definition: lodepng.h:401
Definition: lodepng.h:290
Definition: lodepng.h:323
Definition: lodepng.h:412
Definition: lodepng.h:694
Definition: lodepng.h:262
Definition: lodepng.h:618