26 #ifdef XEMU_USE_LODEPNG
32 extern const char* LODEPNG_VERSION_STRING;
43 #define LODEPNG_COMPILE_ZLIB
45 #define LODEPNG_COMPILE_PNG
47 #define LODEPNG_COMPILE_DECODER_OFF
49 #define LODEPNG_COMPILE_ENCODER
51 #define LODEPNG_COMPILE_DISK
53 #define LODEPNG_COMPILE_ANCILLARY_CHUNKS_OFF
55 #define LODEPNG_COMPILE_ERROR_TEXT_OFF
59 #define LODEPNG_COMPILE_ALLOCATORS
62 #ifdef LODEPNG_COMPILE_PNG
64 typedef enum LodePNGColorType
73 #ifdef LODEPNG_COMPILE_DECODER
89 unsigned lodepng_decode_memory(
unsigned char** out,
unsigned* w,
unsigned* h,
90 const unsigned char* in,
size_t insize,
91 LodePNGColorType colortype,
unsigned bitdepth);
94 unsigned lodepng_decode32(
unsigned char** out,
unsigned* w,
unsigned* h,
95 const unsigned char* in,
size_t insize);
98 unsigned lodepng_decode24(
unsigned char** out,
unsigned* w,
unsigned* h,
99 const unsigned char* in,
size_t insize);
101 #ifdef LODEPNG_COMPILE_DISK
106 unsigned lodepng_decode_file(
unsigned char** out,
unsigned* w,
unsigned* h,
107 const char* filename,
108 LodePNGColorType colortype,
unsigned bitdepth);
111 unsigned lodepng_decode32_file(
unsigned char** out,
unsigned* w,
unsigned* h,
112 const char* filename);
115 unsigned lodepng_decode24_file(
unsigned char** out,
unsigned* w,
unsigned* h,
116 const char* filename);
121 #ifdef LODEPNG_COMPILE_ENCODER
138 unsigned lodepng_encode_memory(
unsigned char** out,
size_t* outsize,
139 const unsigned char* image,
unsigned w,
unsigned h,
140 LodePNGColorType colortype,
unsigned bitdepth);
143 unsigned lodepng_encode32(
unsigned char** out,
size_t* outsize,
144 const unsigned char* image,
unsigned w,
unsigned h);
147 unsigned lodepng_encode24(
unsigned char** out,
size_t* outsize,
148 const unsigned char* image,
unsigned w,
unsigned h);
150 #ifdef LODEPNG_COMPILE_DISK
156 unsigned lodepng_encode_file(
const char* filename,
157 const unsigned char* image,
unsigned w,
unsigned h,
158 LodePNGColorType colortype,
unsigned bitdepth);
161 unsigned lodepng_encode32_file(
const char* filename,
162 const unsigned char* image,
unsigned w,
unsigned h);
165 unsigned lodepng_encode24_file(
const char* filename,
166 const unsigned char* image,
unsigned w,
unsigned h);
173 #ifdef LODEPNG_COMPILE_ERROR_TEXT
175 const char* lodepng_error_text(
unsigned code);
178 #ifdef LODEPNG_COMPILE_DECODER
180 typedef struct LodePNGDecompressSettings LodePNGDecompressSettings;
181 struct LodePNGDecompressSettings
183 unsigned ignore_adler32;
186 unsigned (*custom_zlib)(
unsigned char**,
size_t*,
187 const unsigned char*, size_t,
188 const LodePNGDecompressSettings*);
192 unsigned (*custom_inflate)(
unsigned char**,
size_t*,
193 const unsigned char*, size_t,
194 const LodePNGDecompressSettings*);
196 const void* custom_context;
199 extern const LodePNGDecompressSettings lodepng_default_decompress_settings;
200 void lodepng_decompress_settings_init(LodePNGDecompressSettings* settings);
203 #ifdef LODEPNG_COMPILE_ENCODER
208 typedef struct LodePNGCompressSettings LodePNGCompressSettings;
209 struct LodePNGCompressSettings
217 unsigned lazymatching;
220 unsigned (*custom_zlib)(
unsigned char**,
size_t*,
221 const unsigned char*, size_t,
222 const LodePNGCompressSettings*);
226 unsigned (*custom_deflate)(
unsigned char**,
size_t*,
227 const unsigned char*, size_t,
228 const LodePNGCompressSettings*);
230 const void* custom_context;
233 extern const LodePNGCompressSettings lodepng_default_compress_settings;
234 void lodepng_compress_settings_init(LodePNGCompressSettings* settings);
237 #ifdef LODEPNG_COMPILE_PNG
243 typedef struct LodePNGColorMode
246 LodePNGColorType colortype;
276 unsigned key_defined;
283 void lodepng_color_mode_init(LodePNGColorMode* info);
284 void lodepng_color_mode_cleanup(LodePNGColorMode* info);
286 unsigned lodepng_color_mode_copy(LodePNGColorMode* dest,
const LodePNGColorMode* source);
288 void lodepng_palette_clear(LodePNGColorMode* info);
290 unsigned lodepng_palette_add(LodePNGColorMode* info,
291 unsigned char r,
unsigned char g,
unsigned char b,
unsigned char a);
294 unsigned lodepng_get_bpp(
const LodePNGColorMode* info);
297 unsigned lodepng_get_channels(
const LodePNGColorMode* info);
299 unsigned lodepng_is_greyscale_type(
const LodePNGColorMode* info);
301 unsigned lodepng_is_alpha_type(
const LodePNGColorMode* info);
303 unsigned lodepng_is_palette_type(
const LodePNGColorMode* info);
306 unsigned lodepng_has_palette_alpha(
const LodePNGColorMode* info);
314 unsigned lodepng_can_have_alpha(
const LodePNGColorMode* info);
316 size_t lodepng_get_raw_size(
unsigned w,
unsigned h,
const LodePNGColorMode* color);
318 #ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
320 typedef struct LodePNGTime
332 typedef struct LodePNGInfo
335 unsigned compression_method;
336 unsigned filter_method;
337 unsigned interlace_method;
338 LodePNGColorMode color;
340 #ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
352 unsigned background_defined;
353 unsigned background_r;
354 unsigned background_g;
355 unsigned background_b;
381 char** itext_langtags;
382 char** itext_transkeys;
383 char** itext_strings;
386 unsigned time_defined;
390 unsigned phys_defined;
404 unsigned char* unknown_chunks_data[3];
405 size_t unknown_chunks_size[3];
410 void lodepng_info_init(LodePNGInfo* info);
411 void lodepng_info_cleanup(LodePNGInfo* info);
413 unsigned lodepng_info_copy(LodePNGInfo* dest,
const LodePNGInfo* source);
415 #ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
416 void lodepng_clear_text(LodePNGInfo* info);
417 unsigned lodepng_add_text(LodePNGInfo* info,
const char* key,
const char* str);
419 void lodepng_clear_itext(LodePNGInfo* info);
420 unsigned lodepng_add_itext(LodePNGInfo* info,
const char* key,
const char* langtag,
421 const char* transkey,
const char* str);
435 unsigned lodepng_convert(
unsigned char* out,
const unsigned char* in,
436 LodePNGColorMode* mode_out,
const LodePNGColorMode* mode_in,
437 unsigned w,
unsigned h);
439 #ifdef LODEPNG_COMPILE_DECODER
444 typedef struct LodePNGDecoderSettings
446 LodePNGDecompressSettings zlibsettings;
450 unsigned color_convert;
452 #ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
453 unsigned read_text_chunks;
455 unsigned remember_unknown_chunks;
457 } LodePNGDecoderSettings;
459 void lodepng_decoder_settings_init(LodePNGDecoderSettings* settings);
462 #ifdef LODEPNG_COMPILE_ENCODER
464 typedef enum LodePNGFilterStrategy
480 } LodePNGFilterStrategy;
484 typedef struct LodePNGColorProfile
488 unsigned short key_r;
489 unsigned short key_g;
490 unsigned short key_b;
495 } LodePNGColorProfile;
497 void lodepng_color_profile_init(LodePNGColorProfile* profile);
500 unsigned lodepng_get_color_profile(LodePNGColorProfile* profile,
501 const unsigned char* image,
unsigned w,
unsigned h,
502 const LodePNGColorMode* mode_in);
505 unsigned lodepng_auto_choose_color(LodePNGColorMode* mode_out,
506 const unsigned char* image,
unsigned w,
unsigned h,
507 const LodePNGColorMode* mode_in);
510 typedef struct LodePNGEncoderSettings
512 LodePNGCompressSettings zlibsettings;
514 unsigned auto_convert;
520 unsigned filter_palette_zero;
523 LodePNGFilterStrategy filter_strategy;
528 const unsigned char* predefined_filters;
532 unsigned force_palette;
533 #ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
537 unsigned text_compression;
539 } LodePNGEncoderSettings;
541 void lodepng_encoder_settings_init(LodePNGEncoderSettings* settings);
545 #if defined(LODEPNG_COMPILE_DECODER) || defined(LODEPNG_COMPILE_ENCODER)
547 typedef struct LodePNGState
549 #ifdef LODEPNG_COMPILE_DECODER
550 LodePNGDecoderSettings decoder;
552 #ifdef LODEPNG_COMPILE_ENCODER
553 LodePNGEncoderSettings encoder;
555 LodePNGColorMode info_raw;
556 LodePNGInfo info_png;
561 void lodepng_state_init(LodePNGState* state);
562 void lodepng_state_cleanup(LodePNGState* state);
563 void lodepng_state_copy(LodePNGState* dest,
const LodePNGState* source);
566 #ifdef LODEPNG_COMPILE_DECODER
571 unsigned lodepng_decode(
unsigned char** out,
unsigned* w,
unsigned* h,
573 const unsigned char* in,
size_t insize);
580 unsigned lodepng_inspect(
unsigned* w,
unsigned* h,
582 const unsigned char* in,
size_t insize);
586 #ifdef LODEPNG_COMPILE_ENCODER
588 unsigned lodepng_encode(
unsigned char** out,
size_t* outsize,
589 const unsigned char* image,
unsigned w,
unsigned h,
590 LodePNGState* state);
610 unsigned lodepng_chunk_length(
const unsigned char* chunk);
613 void lodepng_chunk_type(
char type[5],
const unsigned char* chunk);
616 unsigned char lodepng_chunk_type_equals(
const unsigned char* chunk,
const char* type);
619 unsigned char lodepng_chunk_ancillary(
const unsigned char* chunk);
622 unsigned char lodepng_chunk_private(
const unsigned char* chunk);
625 unsigned char lodepng_chunk_safetocopy(
const unsigned char* chunk);
628 unsigned char* lodepng_chunk_data(
unsigned char* chunk);
629 const unsigned char* lodepng_chunk_data_const(
const unsigned char* chunk);
632 unsigned lodepng_chunk_check_crc(
const unsigned char* chunk);
635 void lodepng_chunk_generate_crc(
unsigned char* chunk);
638 unsigned char* lodepng_chunk_next(
unsigned char* chunk);
639 const unsigned char* lodepng_chunk_next_const(
const unsigned char* chunk);
646 unsigned lodepng_chunk_append(
unsigned char** out,
size_t* outlength,
const unsigned char* chunk);
654 unsigned lodepng_chunk_create(
unsigned char** out,
size_t* outlength,
unsigned length,
655 const char* type,
const unsigned char*
data);
659 unsigned lodepng_crc32(
const unsigned char*
buf,
size_t len);
663 #ifdef LODEPNG_COMPILE_ZLIB
670 #ifdef LODEPNG_COMPILE_DECODER
672 unsigned lodepng_inflate(
unsigned char** out,
size_t* outsize,
673 const unsigned char* in,
size_t insize,
674 const LodePNGDecompressSettings* settings);
682 unsigned lodepng_zlib_decompress(
unsigned char** out,
size_t* outsize,
683 const unsigned char* in,
size_t insize,
684 const LodePNGDecompressSettings* settings);
687 #ifdef LODEPNG_COMPILE_ENCODER
695 unsigned lodepng_zlib_compress(
unsigned char** out,
size_t* outsize,
696 const unsigned char* in,
size_t insize,
697 const LodePNGCompressSettings* settings);
703 unsigned lodepng_huffman_code_lengths(
unsigned* lengths,
const unsigned* frequencies,
704 size_t numcodes,
unsigned maxbitlen);
707 unsigned lodepng_deflate(
unsigned char** out,
size_t* outsize,
708 const unsigned char* in,
size_t insize,
709 const LodePNGCompressSettings* settings);
714 #ifdef LODEPNG_COMPILE_DISK
723 unsigned lodepng_load_file(
unsigned char** out,
size_t* outsize,
const char* filename);
733 unsigned lodepng_save_file(
const unsigned char* buffer,
size_t buffersize,
const char* filename);