Fork of DMemWin by
png/png.c@2:0e2ef1edf01b, 2016-06-02 (annotated)
- Committer:
- destinyXfate
- Date:
- Thu Jun 02 04:52:54 2016 +0000
- Revision:
- 2:0e2ef1edf01b
;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
destinyXfate | 2:0e2ef1edf01b | 1 | |
destinyXfate | 2:0e2ef1edf01b | 2 | /* png.c - location for general purpose libpng functions |
destinyXfate | 2:0e2ef1edf01b | 3 | * |
destinyXfate | 2:0e2ef1edf01b | 4 | * Last changed in libpng 1.2.15 January 5, 2007 |
destinyXfate | 2:0e2ef1edf01b | 5 | * For conditions of distribution and use, see copyright notice in png.h |
destinyXfate | 2:0e2ef1edf01b | 6 | * Copyright (c) 1998-2007 Glenn Randers-Pehrson |
destinyXfate | 2:0e2ef1edf01b | 7 | * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) |
destinyXfate | 2:0e2ef1edf01b | 8 | * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) |
destinyXfate | 2:0e2ef1edf01b | 9 | */ |
destinyXfate | 2:0e2ef1edf01b | 10 | |
destinyXfate | 2:0e2ef1edf01b | 11 | #define PNG_INTERNAL |
destinyXfate | 2:0e2ef1edf01b | 12 | #define PNG_NO_EXTERN |
destinyXfate | 2:0e2ef1edf01b | 13 | #include "png.h" |
destinyXfate | 2:0e2ef1edf01b | 14 | |
destinyXfate | 2:0e2ef1edf01b | 15 | /* Generate a compiler error if there is an old png.h in the search path. */ |
destinyXfate | 2:0e2ef1edf01b | 16 | typedef version_1_2_15 Your_png_h_is_not_version_1_2_15; |
destinyXfate | 2:0e2ef1edf01b | 17 | |
destinyXfate | 2:0e2ef1edf01b | 18 | /* Version information for C files. This had better match the version |
destinyXfate | 2:0e2ef1edf01b | 19 | * string defined in png.h. */ |
destinyXfate | 2:0e2ef1edf01b | 20 | |
destinyXfate | 2:0e2ef1edf01b | 21 | #ifdef PNG_USE_GLOBAL_ARRAYS |
destinyXfate | 2:0e2ef1edf01b | 22 | /* png_libpng_ver was changed to a function in version 1.0.5c */ |
destinyXfate | 2:0e2ef1edf01b | 23 | const char png_libpng_ver[18] = PNG_LIBPNG_VER_STRING; |
destinyXfate | 2:0e2ef1edf01b | 24 | |
destinyXfate | 2:0e2ef1edf01b | 25 | #ifdef PNG_READ_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 26 | |
destinyXfate | 2:0e2ef1edf01b | 27 | /* png_sig was changed to a function in version 1.0.5c */ |
destinyXfate | 2:0e2ef1edf01b | 28 | /* Place to hold the signature string for a PNG file. */ |
destinyXfate | 2:0e2ef1edf01b | 29 | const png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; |
destinyXfate | 2:0e2ef1edf01b | 30 | #endif /* PNG_READ_SUPPORTED */ |
destinyXfate | 2:0e2ef1edf01b | 31 | |
destinyXfate | 2:0e2ef1edf01b | 32 | /* Invoke global declarations for constant strings for known chunk types */ |
destinyXfate | 2:0e2ef1edf01b | 33 | PNG_IHDR; |
destinyXfate | 2:0e2ef1edf01b | 34 | PNG_IDAT; |
destinyXfate | 2:0e2ef1edf01b | 35 | PNG_IEND; |
destinyXfate | 2:0e2ef1edf01b | 36 | PNG_PLTE; |
destinyXfate | 2:0e2ef1edf01b | 37 | PNG_bKGD; |
destinyXfate | 2:0e2ef1edf01b | 38 | PNG_cHRM; |
destinyXfate | 2:0e2ef1edf01b | 39 | PNG_gAMA; |
destinyXfate | 2:0e2ef1edf01b | 40 | PNG_hIST; |
destinyXfate | 2:0e2ef1edf01b | 41 | PNG_iCCP; |
destinyXfate | 2:0e2ef1edf01b | 42 | PNG_iTXt; |
destinyXfate | 2:0e2ef1edf01b | 43 | PNG_oFFs; |
destinyXfate | 2:0e2ef1edf01b | 44 | PNG_pCAL; |
destinyXfate | 2:0e2ef1edf01b | 45 | PNG_sCAL; |
destinyXfate | 2:0e2ef1edf01b | 46 | PNG_pHYs; |
destinyXfate | 2:0e2ef1edf01b | 47 | PNG_sBIT; |
destinyXfate | 2:0e2ef1edf01b | 48 | PNG_sPLT; |
destinyXfate | 2:0e2ef1edf01b | 49 | PNG_sRGB; |
destinyXfate | 2:0e2ef1edf01b | 50 | PNG_tEXt; |
destinyXfate | 2:0e2ef1edf01b | 51 | PNG_tIME; |
destinyXfate | 2:0e2ef1edf01b | 52 | PNG_tRNS; |
destinyXfate | 2:0e2ef1edf01b | 53 | PNG_zTXt; |
destinyXfate | 2:0e2ef1edf01b | 54 | |
destinyXfate | 2:0e2ef1edf01b | 55 | #ifdef PNG_READ_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 56 | /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ |
destinyXfate | 2:0e2ef1edf01b | 57 | |
destinyXfate | 2:0e2ef1edf01b | 58 | /* start of interlace block */ |
destinyXfate | 2:0e2ef1edf01b | 59 | const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; |
destinyXfate | 2:0e2ef1edf01b | 60 | |
destinyXfate | 2:0e2ef1edf01b | 61 | /* offset to next interlace block */ |
destinyXfate | 2:0e2ef1edf01b | 62 | const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; |
destinyXfate | 2:0e2ef1edf01b | 63 | |
destinyXfate | 2:0e2ef1edf01b | 64 | /* start of interlace block in the y direction */ |
destinyXfate | 2:0e2ef1edf01b | 65 | const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; |
destinyXfate | 2:0e2ef1edf01b | 66 | |
destinyXfate | 2:0e2ef1edf01b | 67 | /* offset to next interlace block in the y direction */ |
destinyXfate | 2:0e2ef1edf01b | 68 | const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; |
destinyXfate | 2:0e2ef1edf01b | 69 | |
destinyXfate | 2:0e2ef1edf01b | 70 | /* width of interlace block (used in assembler routines only) */ |
destinyXfate | 2:0e2ef1edf01b | 71 | #ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW |
destinyXfate | 2:0e2ef1edf01b | 72 | const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; |
destinyXfate | 2:0e2ef1edf01b | 73 | #endif |
destinyXfate | 2:0e2ef1edf01b | 74 | |
destinyXfate | 2:0e2ef1edf01b | 75 | /* Height of interlace block. This is not currently used - if you need |
destinyXfate | 2:0e2ef1edf01b | 76 | * it, uncomment it here and in png.h |
destinyXfate | 2:0e2ef1edf01b | 77 | const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; |
destinyXfate | 2:0e2ef1edf01b | 78 | */ |
destinyXfate | 2:0e2ef1edf01b | 79 | |
destinyXfate | 2:0e2ef1edf01b | 80 | /* Mask to determine which pixels are valid in a pass */ |
destinyXfate | 2:0e2ef1edf01b | 81 | const int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; |
destinyXfate | 2:0e2ef1edf01b | 82 | |
destinyXfate | 2:0e2ef1edf01b | 83 | /* Mask to determine which pixels to overwrite while displaying */ |
destinyXfate | 2:0e2ef1edf01b | 84 | const int FARDATA png_pass_dsp_mask[] |
destinyXfate | 2:0e2ef1edf01b | 85 | = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; |
destinyXfate | 2:0e2ef1edf01b | 86 | |
destinyXfate | 2:0e2ef1edf01b | 87 | #endif /* PNG_READ_SUPPORTED */ |
destinyXfate | 2:0e2ef1edf01b | 88 | #endif /* PNG_USE_GLOBAL_ARRAYS */ |
destinyXfate | 2:0e2ef1edf01b | 89 | |
destinyXfate | 2:0e2ef1edf01b | 90 | /* Tells libpng that we have already handled the first "num_bytes" bytes |
destinyXfate | 2:0e2ef1edf01b | 91 | * of the PNG file signature. If the PNG data is embedded into another |
destinyXfate | 2:0e2ef1edf01b | 92 | * stream we can set num_bytes = 8 so that libpng will not attempt to read |
destinyXfate | 2:0e2ef1edf01b | 93 | * or write any of the magic bytes before it starts on the IHDR. |
destinyXfate | 2:0e2ef1edf01b | 94 | */ |
destinyXfate | 2:0e2ef1edf01b | 95 | |
destinyXfate | 2:0e2ef1edf01b | 96 | #ifdef PNG_READ_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 97 | void PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 98 | png_set_sig_bytes(png_structp png_ptr, int num_bytes) |
destinyXfate | 2:0e2ef1edf01b | 99 | { |
destinyXfate | 2:0e2ef1edf01b | 100 | if(png_ptr == NULL) return; |
destinyXfate | 2:0e2ef1edf01b | 101 | png_debug(1, "in png_set_sig_bytes\n"); |
destinyXfate | 2:0e2ef1edf01b | 102 | if (num_bytes > 8) |
destinyXfate | 2:0e2ef1edf01b | 103 | png_error(png_ptr, "Too many bytes for PNG signature."); |
destinyXfate | 2:0e2ef1edf01b | 104 | |
destinyXfate | 2:0e2ef1edf01b | 105 | png_ptr->sig_bytes = (png_byte)(num_bytes < 0 ? 0 : num_bytes); |
destinyXfate | 2:0e2ef1edf01b | 106 | } |
destinyXfate | 2:0e2ef1edf01b | 107 | |
destinyXfate | 2:0e2ef1edf01b | 108 | /* Checks whether the supplied bytes match the PNG signature. We allow |
destinyXfate | 2:0e2ef1edf01b | 109 | * checking less than the full 8-byte signature so that those apps that |
destinyXfate | 2:0e2ef1edf01b | 110 | * already read the first few bytes of a file to determine the file type |
destinyXfate | 2:0e2ef1edf01b | 111 | * can simply check the remaining bytes for extra assurance. Returns |
destinyXfate | 2:0e2ef1edf01b | 112 | * an integer less than, equal to, or greater than zero if sig is found, |
destinyXfate | 2:0e2ef1edf01b | 113 | * respectively, to be less than, to match, or be greater than the correct |
destinyXfate | 2:0e2ef1edf01b | 114 | * PNG signature (this is the same behaviour as strcmp, memcmp, etc). |
destinyXfate | 2:0e2ef1edf01b | 115 | */ |
destinyXfate | 2:0e2ef1edf01b | 116 | int PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 117 | png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check) |
destinyXfate | 2:0e2ef1edf01b | 118 | { |
destinyXfate | 2:0e2ef1edf01b | 119 | png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; |
destinyXfate | 2:0e2ef1edf01b | 120 | if (num_to_check > 8) |
destinyXfate | 2:0e2ef1edf01b | 121 | num_to_check = 8; |
destinyXfate | 2:0e2ef1edf01b | 122 | else if (num_to_check < 1) |
destinyXfate | 2:0e2ef1edf01b | 123 | return (-1); |
destinyXfate | 2:0e2ef1edf01b | 124 | |
destinyXfate | 2:0e2ef1edf01b | 125 | if (start > 7) |
destinyXfate | 2:0e2ef1edf01b | 126 | return (-1); |
destinyXfate | 2:0e2ef1edf01b | 127 | |
destinyXfate | 2:0e2ef1edf01b | 128 | if (start + num_to_check > 8) |
destinyXfate | 2:0e2ef1edf01b | 129 | num_to_check = 8 - start; |
destinyXfate | 2:0e2ef1edf01b | 130 | |
destinyXfate | 2:0e2ef1edf01b | 131 | return ((int)(png_memcmp(&sig[start], &png_signature[start], num_to_check))); |
destinyXfate | 2:0e2ef1edf01b | 132 | } |
destinyXfate | 2:0e2ef1edf01b | 133 | |
destinyXfate | 2:0e2ef1edf01b | 134 | #if defined(PNG_1_0_X) || defined(PNG_1_2_X) |
destinyXfate | 2:0e2ef1edf01b | 135 | /* (Obsolete) function to check signature bytes. It does not allow one |
destinyXfate | 2:0e2ef1edf01b | 136 | * to check a partial signature. This function might be removed in the |
destinyXfate | 2:0e2ef1edf01b | 137 | * future - use png_sig_cmp(). Returns true (nonzero) if the file is a PNG. |
destinyXfate | 2:0e2ef1edf01b | 138 | */ |
destinyXfate | 2:0e2ef1edf01b | 139 | int PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 140 | png_check_sig(png_bytep sig, int num) |
destinyXfate | 2:0e2ef1edf01b | 141 | { |
destinyXfate | 2:0e2ef1edf01b | 142 | return ((int)!png_sig_cmp(sig, (png_size_t)0, (png_size_t)num)); |
destinyXfate | 2:0e2ef1edf01b | 143 | } |
destinyXfate | 2:0e2ef1edf01b | 144 | #endif |
destinyXfate | 2:0e2ef1edf01b | 145 | #endif /* PNG_READ_SUPPORTED */ |
destinyXfate | 2:0e2ef1edf01b | 146 | |
destinyXfate | 2:0e2ef1edf01b | 147 | #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) |
destinyXfate | 2:0e2ef1edf01b | 148 | /* Function to allocate memory for zlib and clear it to 0. */ |
destinyXfate | 2:0e2ef1edf01b | 149 | #ifdef PNG_1_0_X |
destinyXfate | 2:0e2ef1edf01b | 150 | voidpf PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 151 | #else |
destinyXfate | 2:0e2ef1edf01b | 152 | voidpf /* private */ |
destinyXfate | 2:0e2ef1edf01b | 153 | #endif |
destinyXfate | 2:0e2ef1edf01b | 154 | png_zalloc(voidpf png_ptr, uInt items, uInt size) |
destinyXfate | 2:0e2ef1edf01b | 155 | { |
destinyXfate | 2:0e2ef1edf01b | 156 | png_voidp ptr; |
destinyXfate | 2:0e2ef1edf01b | 157 | png_structp p=(png_structp)png_ptr; |
destinyXfate | 2:0e2ef1edf01b | 158 | png_uint_32 save_flags=p->flags; |
destinyXfate | 2:0e2ef1edf01b | 159 | png_uint_32 num_bytes; |
destinyXfate | 2:0e2ef1edf01b | 160 | |
destinyXfate | 2:0e2ef1edf01b | 161 | if(png_ptr == NULL) return (NULL); |
destinyXfate | 2:0e2ef1edf01b | 162 | if (items > PNG_UINT_32_MAX/size) |
destinyXfate | 2:0e2ef1edf01b | 163 | { |
destinyXfate | 2:0e2ef1edf01b | 164 | png_warning (p, "Potential overflow in png_zalloc()"); |
destinyXfate | 2:0e2ef1edf01b | 165 | return (NULL); |
destinyXfate | 2:0e2ef1edf01b | 166 | } |
destinyXfate | 2:0e2ef1edf01b | 167 | num_bytes = (png_uint_32)items * size; |
destinyXfate | 2:0e2ef1edf01b | 168 | |
destinyXfate | 2:0e2ef1edf01b | 169 | p->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; |
destinyXfate | 2:0e2ef1edf01b | 170 | ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes); |
destinyXfate | 2:0e2ef1edf01b | 171 | p->flags=save_flags; |
destinyXfate | 2:0e2ef1edf01b | 172 | |
destinyXfate | 2:0e2ef1edf01b | 173 | #if defined(PNG_1_0_X) && !defined(PNG_NO_ZALLOC_ZERO) |
destinyXfate | 2:0e2ef1edf01b | 174 | if (ptr == NULL) |
destinyXfate | 2:0e2ef1edf01b | 175 | return ((voidpf)ptr); |
destinyXfate | 2:0e2ef1edf01b | 176 | |
destinyXfate | 2:0e2ef1edf01b | 177 | if (num_bytes > (png_uint_32)0x8000L) |
destinyXfate | 2:0e2ef1edf01b | 178 | { |
destinyXfate | 2:0e2ef1edf01b | 179 | png_memset(ptr, 0, (png_size_t)0x8000L); |
destinyXfate | 2:0e2ef1edf01b | 180 | png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0, |
destinyXfate | 2:0e2ef1edf01b | 181 | (png_size_t)(num_bytes - (png_uint_32)0x8000L)); |
destinyXfate | 2:0e2ef1edf01b | 182 | } |
destinyXfate | 2:0e2ef1edf01b | 183 | else |
destinyXfate | 2:0e2ef1edf01b | 184 | { |
destinyXfate | 2:0e2ef1edf01b | 185 | png_memset(ptr, 0, (png_size_t)num_bytes); |
destinyXfate | 2:0e2ef1edf01b | 186 | } |
destinyXfate | 2:0e2ef1edf01b | 187 | #endif |
destinyXfate | 2:0e2ef1edf01b | 188 | return ((voidpf)ptr); |
destinyXfate | 2:0e2ef1edf01b | 189 | } |
destinyXfate | 2:0e2ef1edf01b | 190 | |
destinyXfate | 2:0e2ef1edf01b | 191 | /* function to free memory for zlib */ |
destinyXfate | 2:0e2ef1edf01b | 192 | #ifdef PNG_1_0_X |
destinyXfate | 2:0e2ef1edf01b | 193 | void PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 194 | #else |
destinyXfate | 2:0e2ef1edf01b | 195 | void /* private */ |
destinyXfate | 2:0e2ef1edf01b | 196 | #endif |
destinyXfate | 2:0e2ef1edf01b | 197 | png_zfree(voidpf png_ptr, voidpf ptr) |
destinyXfate | 2:0e2ef1edf01b | 198 | { |
destinyXfate | 2:0e2ef1edf01b | 199 | png_free((png_structp)png_ptr, (png_voidp)ptr); |
destinyXfate | 2:0e2ef1edf01b | 200 | } |
destinyXfate | 2:0e2ef1edf01b | 201 | |
destinyXfate | 2:0e2ef1edf01b | 202 | /* Reset the CRC variable to 32 bits of 1's. Care must be taken |
destinyXfate | 2:0e2ef1edf01b | 203 | * in case CRC is > 32 bits to leave the top bits 0. |
destinyXfate | 2:0e2ef1edf01b | 204 | */ |
destinyXfate | 2:0e2ef1edf01b | 205 | void /* PRIVATE */ |
destinyXfate | 2:0e2ef1edf01b | 206 | png_reset_crc(png_structp png_ptr) |
destinyXfate | 2:0e2ef1edf01b | 207 | { |
destinyXfate | 2:0e2ef1edf01b | 208 | png_ptr->crc = crc32(0, Z_NULL, 0); |
destinyXfate | 2:0e2ef1edf01b | 209 | } |
destinyXfate | 2:0e2ef1edf01b | 210 | |
destinyXfate | 2:0e2ef1edf01b | 211 | /* Calculate the CRC over a section of data. We can only pass as |
destinyXfate | 2:0e2ef1edf01b | 212 | * much data to this routine as the largest single buffer size. We |
destinyXfate | 2:0e2ef1edf01b | 213 | * also check that this data will actually be used before going to the |
destinyXfate | 2:0e2ef1edf01b | 214 | * trouble of calculating it. |
destinyXfate | 2:0e2ef1edf01b | 215 | */ |
destinyXfate | 2:0e2ef1edf01b | 216 | void /* PRIVATE */ |
destinyXfate | 2:0e2ef1edf01b | 217 | png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length) |
destinyXfate | 2:0e2ef1edf01b | 218 | { |
destinyXfate | 2:0e2ef1edf01b | 219 | int need_crc = 1; |
destinyXfate | 2:0e2ef1edf01b | 220 | |
destinyXfate | 2:0e2ef1edf01b | 221 | if (png_ptr->chunk_name[0] & 0x20) /* ancillary */ |
destinyXfate | 2:0e2ef1edf01b | 222 | { |
destinyXfate | 2:0e2ef1edf01b | 223 | if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == |
destinyXfate | 2:0e2ef1edf01b | 224 | (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN)) |
destinyXfate | 2:0e2ef1edf01b | 225 | need_crc = 0; |
destinyXfate | 2:0e2ef1edf01b | 226 | } |
destinyXfate | 2:0e2ef1edf01b | 227 | else /* critical */ |
destinyXfate | 2:0e2ef1edf01b | 228 | { |
destinyXfate | 2:0e2ef1edf01b | 229 | if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) |
destinyXfate | 2:0e2ef1edf01b | 230 | need_crc = 0; |
destinyXfate | 2:0e2ef1edf01b | 231 | } |
destinyXfate | 2:0e2ef1edf01b | 232 | |
destinyXfate | 2:0e2ef1edf01b | 233 | if (need_crc) |
destinyXfate | 2:0e2ef1edf01b | 234 | png_ptr->crc = crc32(png_ptr->crc, ptr, (uInt)length); |
destinyXfate | 2:0e2ef1edf01b | 235 | } |
destinyXfate | 2:0e2ef1edf01b | 236 | |
destinyXfate | 2:0e2ef1edf01b | 237 | /* Allocate the memory for an info_struct for the application. We don't |
destinyXfate | 2:0e2ef1edf01b | 238 | * really need the png_ptr, but it could potentially be useful in the |
destinyXfate | 2:0e2ef1edf01b | 239 | * future. This should be used in favour of malloc(png_sizeof(png_info)) |
destinyXfate | 2:0e2ef1edf01b | 240 | * and png_info_init() so that applications that want to use a shared |
destinyXfate | 2:0e2ef1edf01b | 241 | * libpng don't have to be recompiled if png_info changes size. |
destinyXfate | 2:0e2ef1edf01b | 242 | */ |
destinyXfate | 2:0e2ef1edf01b | 243 | png_infop PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 244 | png_create_info_struct(png_structp png_ptr) |
destinyXfate | 2:0e2ef1edf01b | 245 | { |
destinyXfate | 2:0e2ef1edf01b | 246 | png_infop info_ptr; |
destinyXfate | 2:0e2ef1edf01b | 247 | |
destinyXfate | 2:0e2ef1edf01b | 248 | png_debug(1, "in png_create_info_struct\n"); |
destinyXfate | 2:0e2ef1edf01b | 249 | if(png_ptr == NULL) return (NULL); |
destinyXfate | 2:0e2ef1edf01b | 250 | #ifdef PNG_USER_MEM_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 251 | info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO, |
destinyXfate | 2:0e2ef1edf01b | 252 | png_ptr->malloc_fn, png_ptr->mem_ptr); |
destinyXfate | 2:0e2ef1edf01b | 253 | #else |
destinyXfate | 2:0e2ef1edf01b | 254 | info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); |
destinyXfate | 2:0e2ef1edf01b | 255 | #endif |
destinyXfate | 2:0e2ef1edf01b | 256 | if (info_ptr != NULL) |
destinyXfate | 2:0e2ef1edf01b | 257 | png_info_init_3(&info_ptr, png_sizeof(png_info)); |
destinyXfate | 2:0e2ef1edf01b | 258 | |
destinyXfate | 2:0e2ef1edf01b | 259 | return (info_ptr); |
destinyXfate | 2:0e2ef1edf01b | 260 | } |
destinyXfate | 2:0e2ef1edf01b | 261 | |
destinyXfate | 2:0e2ef1edf01b | 262 | /* This function frees the memory associated with a single info struct. |
destinyXfate | 2:0e2ef1edf01b | 263 | * Normally, one would use either png_destroy_read_struct() or |
destinyXfate | 2:0e2ef1edf01b | 264 | * png_destroy_write_struct() to free an info struct, but this may be |
destinyXfate | 2:0e2ef1edf01b | 265 | * useful for some applications. |
destinyXfate | 2:0e2ef1edf01b | 266 | */ |
destinyXfate | 2:0e2ef1edf01b | 267 | void PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 268 | png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr) |
destinyXfate | 2:0e2ef1edf01b | 269 | { |
destinyXfate | 2:0e2ef1edf01b | 270 | png_infop info_ptr = NULL; |
destinyXfate | 2:0e2ef1edf01b | 271 | if(png_ptr == NULL) return; |
destinyXfate | 2:0e2ef1edf01b | 272 | |
destinyXfate | 2:0e2ef1edf01b | 273 | png_debug(1, "in png_destroy_info_struct\n"); |
destinyXfate | 2:0e2ef1edf01b | 274 | if (info_ptr_ptr != NULL) |
destinyXfate | 2:0e2ef1edf01b | 275 | info_ptr = *info_ptr_ptr; |
destinyXfate | 2:0e2ef1edf01b | 276 | |
destinyXfate | 2:0e2ef1edf01b | 277 | if (info_ptr != NULL) |
destinyXfate | 2:0e2ef1edf01b | 278 | { |
destinyXfate | 2:0e2ef1edf01b | 279 | png_info_destroy(png_ptr, info_ptr); |
destinyXfate | 2:0e2ef1edf01b | 280 | |
destinyXfate | 2:0e2ef1edf01b | 281 | #ifdef PNG_USER_MEM_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 282 | png_destroy_struct_2((png_voidp)info_ptr, png_ptr->free_fn, |
destinyXfate | 2:0e2ef1edf01b | 283 | png_ptr->mem_ptr); |
destinyXfate | 2:0e2ef1edf01b | 284 | #else |
destinyXfate | 2:0e2ef1edf01b | 285 | png_destroy_struct((png_voidp)info_ptr); |
destinyXfate | 2:0e2ef1edf01b | 286 | #endif |
destinyXfate | 2:0e2ef1edf01b | 287 | *info_ptr_ptr = NULL; |
destinyXfate | 2:0e2ef1edf01b | 288 | } |
destinyXfate | 2:0e2ef1edf01b | 289 | } |
destinyXfate | 2:0e2ef1edf01b | 290 | |
destinyXfate | 2:0e2ef1edf01b | 291 | /* Initialize the info structure. This is now an internal function (0.89) |
destinyXfate | 2:0e2ef1edf01b | 292 | * and applications using it are urged to use png_create_info_struct() |
destinyXfate | 2:0e2ef1edf01b | 293 | * instead. |
destinyXfate | 2:0e2ef1edf01b | 294 | */ |
destinyXfate | 2:0e2ef1edf01b | 295 | #if defined(PNG_1_0_X) || defined(PNG_1_2_X) |
destinyXfate | 2:0e2ef1edf01b | 296 | #undef png_info_init |
destinyXfate | 2:0e2ef1edf01b | 297 | void PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 298 | png_info_init(png_infop info_ptr) |
destinyXfate | 2:0e2ef1edf01b | 299 | { |
destinyXfate | 2:0e2ef1edf01b | 300 | /* We only come here via pre-1.0.12-compiled applications */ |
destinyXfate | 2:0e2ef1edf01b | 301 | png_info_init_3(&info_ptr, 0); |
destinyXfate | 2:0e2ef1edf01b | 302 | } |
destinyXfate | 2:0e2ef1edf01b | 303 | #endif |
destinyXfate | 2:0e2ef1edf01b | 304 | |
destinyXfate | 2:0e2ef1edf01b | 305 | void PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 306 | png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size) |
destinyXfate | 2:0e2ef1edf01b | 307 | { |
destinyXfate | 2:0e2ef1edf01b | 308 | png_infop info_ptr = *ptr_ptr; |
destinyXfate | 2:0e2ef1edf01b | 309 | |
destinyXfate | 2:0e2ef1edf01b | 310 | if(info_ptr == NULL) return; |
destinyXfate | 2:0e2ef1edf01b | 311 | |
destinyXfate | 2:0e2ef1edf01b | 312 | png_debug(1, "in png_info_init_3\n"); |
destinyXfate | 2:0e2ef1edf01b | 313 | |
destinyXfate | 2:0e2ef1edf01b | 314 | if(png_sizeof(png_info) > png_info_struct_size) |
destinyXfate | 2:0e2ef1edf01b | 315 | { |
destinyXfate | 2:0e2ef1edf01b | 316 | png_destroy_struct(info_ptr); |
destinyXfate | 2:0e2ef1edf01b | 317 | info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); |
destinyXfate | 2:0e2ef1edf01b | 318 | *ptr_ptr = info_ptr; |
destinyXfate | 2:0e2ef1edf01b | 319 | } |
destinyXfate | 2:0e2ef1edf01b | 320 | |
destinyXfate | 2:0e2ef1edf01b | 321 | /* set everything to 0 */ |
destinyXfate | 2:0e2ef1edf01b | 322 | png_memset(info_ptr, 0, png_sizeof (png_info)); |
destinyXfate | 2:0e2ef1edf01b | 323 | } |
destinyXfate | 2:0e2ef1edf01b | 324 | |
destinyXfate | 2:0e2ef1edf01b | 325 | #ifdef PNG_FREE_ME_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 326 | void PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 327 | png_data_freer(png_structp png_ptr, png_infop info_ptr, |
destinyXfate | 2:0e2ef1edf01b | 328 | int freer, png_uint_32 mask) |
destinyXfate | 2:0e2ef1edf01b | 329 | { |
destinyXfate | 2:0e2ef1edf01b | 330 | png_debug(1, "in png_data_freer\n"); |
destinyXfate | 2:0e2ef1edf01b | 331 | if (png_ptr == NULL || info_ptr == NULL) |
destinyXfate | 2:0e2ef1edf01b | 332 | return; |
destinyXfate | 2:0e2ef1edf01b | 333 | if(freer == PNG_DESTROY_WILL_FREE_DATA) |
destinyXfate | 2:0e2ef1edf01b | 334 | info_ptr->free_me |= mask; |
destinyXfate | 2:0e2ef1edf01b | 335 | else if(freer == PNG_USER_WILL_FREE_DATA) |
destinyXfate | 2:0e2ef1edf01b | 336 | info_ptr->free_me &= ~mask; |
destinyXfate | 2:0e2ef1edf01b | 337 | else |
destinyXfate | 2:0e2ef1edf01b | 338 | png_warning(png_ptr, |
destinyXfate | 2:0e2ef1edf01b | 339 | "Unknown freer parameter in png_data_freer."); |
destinyXfate | 2:0e2ef1edf01b | 340 | } |
destinyXfate | 2:0e2ef1edf01b | 341 | #endif |
destinyXfate | 2:0e2ef1edf01b | 342 | |
destinyXfate | 2:0e2ef1edf01b | 343 | void PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 344 | png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask, |
destinyXfate | 2:0e2ef1edf01b | 345 | int num) |
destinyXfate | 2:0e2ef1edf01b | 346 | { |
destinyXfate | 2:0e2ef1edf01b | 347 | png_debug(1, "in png_free_data\n"); |
destinyXfate | 2:0e2ef1edf01b | 348 | if (png_ptr == NULL || info_ptr == NULL) |
destinyXfate | 2:0e2ef1edf01b | 349 | return; |
destinyXfate | 2:0e2ef1edf01b | 350 | |
destinyXfate | 2:0e2ef1edf01b | 351 | #if defined(PNG_TEXT_SUPPORTED) |
destinyXfate | 2:0e2ef1edf01b | 352 | /* free text item num or (if num == -1) all text items */ |
destinyXfate | 2:0e2ef1edf01b | 353 | #ifdef PNG_FREE_ME_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 354 | if ((mask & PNG_FREE_TEXT) & info_ptr->free_me) |
destinyXfate | 2:0e2ef1edf01b | 355 | #else |
destinyXfate | 2:0e2ef1edf01b | 356 | if (mask & PNG_FREE_TEXT) |
destinyXfate | 2:0e2ef1edf01b | 357 | #endif |
destinyXfate | 2:0e2ef1edf01b | 358 | { |
destinyXfate | 2:0e2ef1edf01b | 359 | if (num != -1) |
destinyXfate | 2:0e2ef1edf01b | 360 | { |
destinyXfate | 2:0e2ef1edf01b | 361 | if (info_ptr->text && info_ptr->text[num].key) |
destinyXfate | 2:0e2ef1edf01b | 362 | { |
destinyXfate | 2:0e2ef1edf01b | 363 | png_free(png_ptr, info_ptr->text[num].key); |
destinyXfate | 2:0e2ef1edf01b | 364 | info_ptr->text[num].key = NULL; |
destinyXfate | 2:0e2ef1edf01b | 365 | } |
destinyXfate | 2:0e2ef1edf01b | 366 | } |
destinyXfate | 2:0e2ef1edf01b | 367 | else |
destinyXfate | 2:0e2ef1edf01b | 368 | { |
destinyXfate | 2:0e2ef1edf01b | 369 | int i; |
destinyXfate | 2:0e2ef1edf01b | 370 | for (i = 0; i < info_ptr->num_text; i++) |
destinyXfate | 2:0e2ef1edf01b | 371 | png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i); |
destinyXfate | 2:0e2ef1edf01b | 372 | png_free(png_ptr, info_ptr->text); |
destinyXfate | 2:0e2ef1edf01b | 373 | info_ptr->text = NULL; |
destinyXfate | 2:0e2ef1edf01b | 374 | info_ptr->num_text=0; |
destinyXfate | 2:0e2ef1edf01b | 375 | } |
destinyXfate | 2:0e2ef1edf01b | 376 | } |
destinyXfate | 2:0e2ef1edf01b | 377 | #endif |
destinyXfate | 2:0e2ef1edf01b | 378 | |
destinyXfate | 2:0e2ef1edf01b | 379 | #if defined(PNG_tRNS_SUPPORTED) |
destinyXfate | 2:0e2ef1edf01b | 380 | /* free any tRNS entry */ |
destinyXfate | 2:0e2ef1edf01b | 381 | #ifdef PNG_FREE_ME_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 382 | if ((mask & PNG_FREE_TRNS) & info_ptr->free_me) |
destinyXfate | 2:0e2ef1edf01b | 383 | #else |
destinyXfate | 2:0e2ef1edf01b | 384 | if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS)) |
destinyXfate | 2:0e2ef1edf01b | 385 | #endif |
destinyXfate | 2:0e2ef1edf01b | 386 | { |
destinyXfate | 2:0e2ef1edf01b | 387 | png_free(png_ptr, info_ptr->trans); |
destinyXfate | 2:0e2ef1edf01b | 388 | info_ptr->valid &= ~PNG_INFO_tRNS; |
destinyXfate | 2:0e2ef1edf01b | 389 | #ifndef PNG_FREE_ME_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 390 | png_ptr->flags &= ~PNG_FLAG_FREE_TRNS; |
destinyXfate | 2:0e2ef1edf01b | 391 | #endif |
destinyXfate | 2:0e2ef1edf01b | 392 | info_ptr->trans = NULL; |
destinyXfate | 2:0e2ef1edf01b | 393 | } |
destinyXfate | 2:0e2ef1edf01b | 394 | #endif |
destinyXfate | 2:0e2ef1edf01b | 395 | |
destinyXfate | 2:0e2ef1edf01b | 396 | #if defined(PNG_sCAL_SUPPORTED) |
destinyXfate | 2:0e2ef1edf01b | 397 | /* free any sCAL entry */ |
destinyXfate | 2:0e2ef1edf01b | 398 | #ifdef PNG_FREE_ME_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 399 | if ((mask & PNG_FREE_SCAL) & info_ptr->free_me) |
destinyXfate | 2:0e2ef1edf01b | 400 | #else |
destinyXfate | 2:0e2ef1edf01b | 401 | if (mask & PNG_FREE_SCAL) |
destinyXfate | 2:0e2ef1edf01b | 402 | #endif |
destinyXfate | 2:0e2ef1edf01b | 403 | { |
destinyXfate | 2:0e2ef1edf01b | 404 | #if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) |
destinyXfate | 2:0e2ef1edf01b | 405 | png_free(png_ptr, info_ptr->scal_s_width); |
destinyXfate | 2:0e2ef1edf01b | 406 | png_free(png_ptr, info_ptr->scal_s_height); |
destinyXfate | 2:0e2ef1edf01b | 407 | info_ptr->scal_s_width = NULL; |
destinyXfate | 2:0e2ef1edf01b | 408 | info_ptr->scal_s_height = NULL; |
destinyXfate | 2:0e2ef1edf01b | 409 | #endif |
destinyXfate | 2:0e2ef1edf01b | 410 | info_ptr->valid &= ~PNG_INFO_sCAL; |
destinyXfate | 2:0e2ef1edf01b | 411 | } |
destinyXfate | 2:0e2ef1edf01b | 412 | #endif |
destinyXfate | 2:0e2ef1edf01b | 413 | |
destinyXfate | 2:0e2ef1edf01b | 414 | #if defined(PNG_pCAL_SUPPORTED) |
destinyXfate | 2:0e2ef1edf01b | 415 | /* free any pCAL entry */ |
destinyXfate | 2:0e2ef1edf01b | 416 | #ifdef PNG_FREE_ME_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 417 | if ((mask & PNG_FREE_PCAL) & info_ptr->free_me) |
destinyXfate | 2:0e2ef1edf01b | 418 | #else |
destinyXfate | 2:0e2ef1edf01b | 419 | if (mask & PNG_FREE_PCAL) |
destinyXfate | 2:0e2ef1edf01b | 420 | #endif |
destinyXfate | 2:0e2ef1edf01b | 421 | { |
destinyXfate | 2:0e2ef1edf01b | 422 | png_free(png_ptr, info_ptr->pcal_purpose); |
destinyXfate | 2:0e2ef1edf01b | 423 | png_free(png_ptr, info_ptr->pcal_units); |
destinyXfate | 2:0e2ef1edf01b | 424 | info_ptr->pcal_purpose = NULL; |
destinyXfate | 2:0e2ef1edf01b | 425 | info_ptr->pcal_units = NULL; |
destinyXfate | 2:0e2ef1edf01b | 426 | if (info_ptr->pcal_params != NULL) |
destinyXfate | 2:0e2ef1edf01b | 427 | { |
destinyXfate | 2:0e2ef1edf01b | 428 | int i; |
destinyXfate | 2:0e2ef1edf01b | 429 | for (i = 0; i < (int)info_ptr->pcal_nparams; i++) |
destinyXfate | 2:0e2ef1edf01b | 430 | { |
destinyXfate | 2:0e2ef1edf01b | 431 | png_free(png_ptr, info_ptr->pcal_params[i]); |
destinyXfate | 2:0e2ef1edf01b | 432 | info_ptr->pcal_params[i]=NULL; |
destinyXfate | 2:0e2ef1edf01b | 433 | } |
destinyXfate | 2:0e2ef1edf01b | 434 | png_free(png_ptr, info_ptr->pcal_params); |
destinyXfate | 2:0e2ef1edf01b | 435 | info_ptr->pcal_params = NULL; |
destinyXfate | 2:0e2ef1edf01b | 436 | } |
destinyXfate | 2:0e2ef1edf01b | 437 | info_ptr->valid &= ~PNG_INFO_pCAL; |
destinyXfate | 2:0e2ef1edf01b | 438 | } |
destinyXfate | 2:0e2ef1edf01b | 439 | #endif |
destinyXfate | 2:0e2ef1edf01b | 440 | |
destinyXfate | 2:0e2ef1edf01b | 441 | #if defined(PNG_iCCP_SUPPORTED) |
destinyXfate | 2:0e2ef1edf01b | 442 | /* free any iCCP entry */ |
destinyXfate | 2:0e2ef1edf01b | 443 | #ifdef PNG_FREE_ME_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 444 | if ((mask & PNG_FREE_ICCP) & info_ptr->free_me) |
destinyXfate | 2:0e2ef1edf01b | 445 | #else |
destinyXfate | 2:0e2ef1edf01b | 446 | if (mask & PNG_FREE_ICCP) |
destinyXfate | 2:0e2ef1edf01b | 447 | #endif |
destinyXfate | 2:0e2ef1edf01b | 448 | { |
destinyXfate | 2:0e2ef1edf01b | 449 | png_free(png_ptr, info_ptr->iccp_name); |
destinyXfate | 2:0e2ef1edf01b | 450 | png_free(png_ptr, info_ptr->iccp_profile); |
destinyXfate | 2:0e2ef1edf01b | 451 | info_ptr->iccp_name = NULL; |
destinyXfate | 2:0e2ef1edf01b | 452 | info_ptr->iccp_profile = NULL; |
destinyXfate | 2:0e2ef1edf01b | 453 | info_ptr->valid &= ~PNG_INFO_iCCP; |
destinyXfate | 2:0e2ef1edf01b | 454 | } |
destinyXfate | 2:0e2ef1edf01b | 455 | #endif |
destinyXfate | 2:0e2ef1edf01b | 456 | |
destinyXfate | 2:0e2ef1edf01b | 457 | #if defined(PNG_sPLT_SUPPORTED) |
destinyXfate | 2:0e2ef1edf01b | 458 | /* free a given sPLT entry, or (if num == -1) all sPLT entries */ |
destinyXfate | 2:0e2ef1edf01b | 459 | #ifdef PNG_FREE_ME_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 460 | if ((mask & PNG_FREE_SPLT) & info_ptr->free_me) |
destinyXfate | 2:0e2ef1edf01b | 461 | #else |
destinyXfate | 2:0e2ef1edf01b | 462 | if (mask & PNG_FREE_SPLT) |
destinyXfate | 2:0e2ef1edf01b | 463 | #endif |
destinyXfate | 2:0e2ef1edf01b | 464 | { |
destinyXfate | 2:0e2ef1edf01b | 465 | if (num != -1) |
destinyXfate | 2:0e2ef1edf01b | 466 | { |
destinyXfate | 2:0e2ef1edf01b | 467 | if(info_ptr->splt_palettes) |
destinyXfate | 2:0e2ef1edf01b | 468 | { |
destinyXfate | 2:0e2ef1edf01b | 469 | png_free(png_ptr, info_ptr->splt_palettes[num].name); |
destinyXfate | 2:0e2ef1edf01b | 470 | png_free(png_ptr, info_ptr->splt_palettes[num].entries); |
destinyXfate | 2:0e2ef1edf01b | 471 | info_ptr->splt_palettes[num].name = NULL; |
destinyXfate | 2:0e2ef1edf01b | 472 | info_ptr->splt_palettes[num].entries = NULL; |
destinyXfate | 2:0e2ef1edf01b | 473 | } |
destinyXfate | 2:0e2ef1edf01b | 474 | } |
destinyXfate | 2:0e2ef1edf01b | 475 | else |
destinyXfate | 2:0e2ef1edf01b | 476 | { |
destinyXfate | 2:0e2ef1edf01b | 477 | if(info_ptr->splt_palettes_num) |
destinyXfate | 2:0e2ef1edf01b | 478 | { |
destinyXfate | 2:0e2ef1edf01b | 479 | int i; |
destinyXfate | 2:0e2ef1edf01b | 480 | for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) |
destinyXfate | 2:0e2ef1edf01b | 481 | png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, i); |
destinyXfate | 2:0e2ef1edf01b | 482 | |
destinyXfate | 2:0e2ef1edf01b | 483 | png_free(png_ptr, info_ptr->splt_palettes); |
destinyXfate | 2:0e2ef1edf01b | 484 | info_ptr->splt_palettes = NULL; |
destinyXfate | 2:0e2ef1edf01b | 485 | info_ptr->splt_palettes_num = 0; |
destinyXfate | 2:0e2ef1edf01b | 486 | } |
destinyXfate | 2:0e2ef1edf01b | 487 | info_ptr->valid &= ~PNG_INFO_sPLT; |
destinyXfate | 2:0e2ef1edf01b | 488 | } |
destinyXfate | 2:0e2ef1edf01b | 489 | } |
destinyXfate | 2:0e2ef1edf01b | 490 | #endif |
destinyXfate | 2:0e2ef1edf01b | 491 | |
destinyXfate | 2:0e2ef1edf01b | 492 | #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) |
destinyXfate | 2:0e2ef1edf01b | 493 | #ifdef PNG_FREE_ME_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 494 | if ((mask & PNG_FREE_UNKN) & info_ptr->free_me) |
destinyXfate | 2:0e2ef1edf01b | 495 | #else |
destinyXfate | 2:0e2ef1edf01b | 496 | if (mask & PNG_FREE_UNKN) |
destinyXfate | 2:0e2ef1edf01b | 497 | #endif |
destinyXfate | 2:0e2ef1edf01b | 498 | { |
destinyXfate | 2:0e2ef1edf01b | 499 | if (num != -1) |
destinyXfate | 2:0e2ef1edf01b | 500 | { |
destinyXfate | 2:0e2ef1edf01b | 501 | if(info_ptr->unknown_chunks) |
destinyXfate | 2:0e2ef1edf01b | 502 | { |
destinyXfate | 2:0e2ef1edf01b | 503 | png_free(png_ptr, info_ptr->unknown_chunks[num].data); |
destinyXfate | 2:0e2ef1edf01b | 504 | info_ptr->unknown_chunks[num].data = NULL; |
destinyXfate | 2:0e2ef1edf01b | 505 | } |
destinyXfate | 2:0e2ef1edf01b | 506 | } |
destinyXfate | 2:0e2ef1edf01b | 507 | else |
destinyXfate | 2:0e2ef1edf01b | 508 | { |
destinyXfate | 2:0e2ef1edf01b | 509 | int i; |
destinyXfate | 2:0e2ef1edf01b | 510 | |
destinyXfate | 2:0e2ef1edf01b | 511 | if(info_ptr->unknown_chunks_num) |
destinyXfate | 2:0e2ef1edf01b | 512 | { |
destinyXfate | 2:0e2ef1edf01b | 513 | for (i = 0; i < (int)info_ptr->unknown_chunks_num; i++) |
destinyXfate | 2:0e2ef1edf01b | 514 | png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i); |
destinyXfate | 2:0e2ef1edf01b | 515 | |
destinyXfate | 2:0e2ef1edf01b | 516 | png_free(png_ptr, info_ptr->unknown_chunks); |
destinyXfate | 2:0e2ef1edf01b | 517 | info_ptr->unknown_chunks = NULL; |
destinyXfate | 2:0e2ef1edf01b | 518 | info_ptr->unknown_chunks_num = 0; |
destinyXfate | 2:0e2ef1edf01b | 519 | } |
destinyXfate | 2:0e2ef1edf01b | 520 | } |
destinyXfate | 2:0e2ef1edf01b | 521 | } |
destinyXfate | 2:0e2ef1edf01b | 522 | #endif |
destinyXfate | 2:0e2ef1edf01b | 523 | |
destinyXfate | 2:0e2ef1edf01b | 524 | #if defined(PNG_hIST_SUPPORTED) |
destinyXfate | 2:0e2ef1edf01b | 525 | /* free any hIST entry */ |
destinyXfate | 2:0e2ef1edf01b | 526 | #ifdef PNG_FREE_ME_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 527 | if ((mask & PNG_FREE_HIST) & info_ptr->free_me) |
destinyXfate | 2:0e2ef1edf01b | 528 | #else |
destinyXfate | 2:0e2ef1edf01b | 529 | if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST)) |
destinyXfate | 2:0e2ef1edf01b | 530 | #endif |
destinyXfate | 2:0e2ef1edf01b | 531 | { |
destinyXfate | 2:0e2ef1edf01b | 532 | png_free(png_ptr, info_ptr->hist); |
destinyXfate | 2:0e2ef1edf01b | 533 | info_ptr->hist = NULL; |
destinyXfate | 2:0e2ef1edf01b | 534 | info_ptr->valid &= ~PNG_INFO_hIST; |
destinyXfate | 2:0e2ef1edf01b | 535 | #ifndef PNG_FREE_ME_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 536 | png_ptr->flags &= ~PNG_FLAG_FREE_HIST; |
destinyXfate | 2:0e2ef1edf01b | 537 | #endif |
destinyXfate | 2:0e2ef1edf01b | 538 | } |
destinyXfate | 2:0e2ef1edf01b | 539 | #endif |
destinyXfate | 2:0e2ef1edf01b | 540 | |
destinyXfate | 2:0e2ef1edf01b | 541 | /* free any PLTE entry that was internally allocated */ |
destinyXfate | 2:0e2ef1edf01b | 542 | #ifdef PNG_FREE_ME_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 543 | if ((mask & PNG_FREE_PLTE) & info_ptr->free_me) |
destinyXfate | 2:0e2ef1edf01b | 544 | #else |
destinyXfate | 2:0e2ef1edf01b | 545 | if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE)) |
destinyXfate | 2:0e2ef1edf01b | 546 | #endif |
destinyXfate | 2:0e2ef1edf01b | 547 | { |
destinyXfate | 2:0e2ef1edf01b | 548 | png_zfree(png_ptr, info_ptr->palette); |
destinyXfate | 2:0e2ef1edf01b | 549 | info_ptr->palette = NULL; |
destinyXfate | 2:0e2ef1edf01b | 550 | info_ptr->valid &= ~PNG_INFO_PLTE; |
destinyXfate | 2:0e2ef1edf01b | 551 | #ifndef PNG_FREE_ME_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 552 | png_ptr->flags &= ~PNG_FLAG_FREE_PLTE; |
destinyXfate | 2:0e2ef1edf01b | 553 | #endif |
destinyXfate | 2:0e2ef1edf01b | 554 | info_ptr->num_palette = 0; |
destinyXfate | 2:0e2ef1edf01b | 555 | } |
destinyXfate | 2:0e2ef1edf01b | 556 | |
destinyXfate | 2:0e2ef1edf01b | 557 | #if defined(PNG_INFO_IMAGE_SUPPORTED) |
destinyXfate | 2:0e2ef1edf01b | 558 | /* free any image bits attached to the info structure */ |
destinyXfate | 2:0e2ef1edf01b | 559 | #ifdef PNG_FREE_ME_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 560 | if ((mask & PNG_FREE_ROWS) & info_ptr->free_me) |
destinyXfate | 2:0e2ef1edf01b | 561 | #else |
destinyXfate | 2:0e2ef1edf01b | 562 | if (mask & PNG_FREE_ROWS) |
destinyXfate | 2:0e2ef1edf01b | 563 | #endif |
destinyXfate | 2:0e2ef1edf01b | 564 | { |
destinyXfate | 2:0e2ef1edf01b | 565 | if(info_ptr->row_pointers) |
destinyXfate | 2:0e2ef1edf01b | 566 | { |
destinyXfate | 2:0e2ef1edf01b | 567 | int row; |
destinyXfate | 2:0e2ef1edf01b | 568 | for (row = 0; row < (int)info_ptr->height; row++) |
destinyXfate | 2:0e2ef1edf01b | 569 | { |
destinyXfate | 2:0e2ef1edf01b | 570 | png_free(png_ptr, info_ptr->row_pointers[row]); |
destinyXfate | 2:0e2ef1edf01b | 571 | info_ptr->row_pointers[row]=NULL; |
destinyXfate | 2:0e2ef1edf01b | 572 | } |
destinyXfate | 2:0e2ef1edf01b | 573 | png_free(png_ptr, info_ptr->row_pointers); |
destinyXfate | 2:0e2ef1edf01b | 574 | info_ptr->row_pointers=NULL; |
destinyXfate | 2:0e2ef1edf01b | 575 | } |
destinyXfate | 2:0e2ef1edf01b | 576 | info_ptr->valid &= ~PNG_INFO_IDAT; |
destinyXfate | 2:0e2ef1edf01b | 577 | } |
destinyXfate | 2:0e2ef1edf01b | 578 | #endif |
destinyXfate | 2:0e2ef1edf01b | 579 | |
destinyXfate | 2:0e2ef1edf01b | 580 | #ifdef PNG_FREE_ME_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 581 | if(num == -1) |
destinyXfate | 2:0e2ef1edf01b | 582 | info_ptr->free_me &= ~mask; |
destinyXfate | 2:0e2ef1edf01b | 583 | else |
destinyXfate | 2:0e2ef1edf01b | 584 | info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL); |
destinyXfate | 2:0e2ef1edf01b | 585 | #endif |
destinyXfate | 2:0e2ef1edf01b | 586 | } |
destinyXfate | 2:0e2ef1edf01b | 587 | |
destinyXfate | 2:0e2ef1edf01b | 588 | /* This is an internal routine to free any memory that the info struct is |
destinyXfate | 2:0e2ef1edf01b | 589 | * pointing to before re-using it or freeing the struct itself. Recall |
destinyXfate | 2:0e2ef1edf01b | 590 | * that png_free() checks for NULL pointers for us. |
destinyXfate | 2:0e2ef1edf01b | 591 | */ |
destinyXfate | 2:0e2ef1edf01b | 592 | void /* PRIVATE */ |
destinyXfate | 2:0e2ef1edf01b | 593 | png_info_destroy(png_structp png_ptr, png_infop info_ptr) |
destinyXfate | 2:0e2ef1edf01b | 594 | { |
destinyXfate | 2:0e2ef1edf01b | 595 | png_debug(1, "in png_info_destroy\n"); |
destinyXfate | 2:0e2ef1edf01b | 596 | |
destinyXfate | 2:0e2ef1edf01b | 597 | png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); |
destinyXfate | 2:0e2ef1edf01b | 598 | |
destinyXfate | 2:0e2ef1edf01b | 599 | #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) |
destinyXfate | 2:0e2ef1edf01b | 600 | if (png_ptr->num_chunk_list) |
destinyXfate | 2:0e2ef1edf01b | 601 | { |
destinyXfate | 2:0e2ef1edf01b | 602 | png_free(png_ptr, png_ptr->chunk_list); |
destinyXfate | 2:0e2ef1edf01b | 603 | png_ptr->chunk_list=NULL; |
destinyXfate | 2:0e2ef1edf01b | 604 | png_ptr->num_chunk_list=0; |
destinyXfate | 2:0e2ef1edf01b | 605 | } |
destinyXfate | 2:0e2ef1edf01b | 606 | #endif |
destinyXfate | 2:0e2ef1edf01b | 607 | |
destinyXfate | 2:0e2ef1edf01b | 608 | png_info_init_3(&info_ptr, png_sizeof(png_info)); |
destinyXfate | 2:0e2ef1edf01b | 609 | } |
destinyXfate | 2:0e2ef1edf01b | 610 | #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ |
destinyXfate | 2:0e2ef1edf01b | 611 | |
destinyXfate | 2:0e2ef1edf01b | 612 | /* This function returns a pointer to the io_ptr associated with the user |
destinyXfate | 2:0e2ef1edf01b | 613 | * functions. The application should free any memory associated with this |
destinyXfate | 2:0e2ef1edf01b | 614 | * pointer before png_write_destroy() or png_read_destroy() are called. |
destinyXfate | 2:0e2ef1edf01b | 615 | */ |
destinyXfate | 2:0e2ef1edf01b | 616 | png_voidp PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 617 | png_get_io_ptr(png_structp png_ptr) |
destinyXfate | 2:0e2ef1edf01b | 618 | { |
destinyXfate | 2:0e2ef1edf01b | 619 | if(png_ptr == NULL) return (NULL); |
destinyXfate | 2:0e2ef1edf01b | 620 | return (png_ptr->io_ptr); |
destinyXfate | 2:0e2ef1edf01b | 621 | } |
destinyXfate | 2:0e2ef1edf01b | 622 | |
destinyXfate | 2:0e2ef1edf01b | 623 | #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) |
destinyXfate | 2:0e2ef1edf01b | 624 | #if !defined(PNG_NO_STDIO) |
destinyXfate | 2:0e2ef1edf01b | 625 | /* Initialize the default input/output functions for the PNG file. If you |
destinyXfate | 2:0e2ef1edf01b | 626 | * use your own read or write routines, you can call either png_set_read_fn() |
destinyXfate | 2:0e2ef1edf01b | 627 | * or png_set_write_fn() instead of png_init_io(). If you have defined |
destinyXfate | 2:0e2ef1edf01b | 628 | * PNG_NO_STDIO, you must use a function of your own because "FILE *" isn't |
destinyXfate | 2:0e2ef1edf01b | 629 | * necessarily available. |
destinyXfate | 2:0e2ef1edf01b | 630 | */ |
destinyXfate | 2:0e2ef1edf01b | 631 | void PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 632 | png_init_io(png_structp png_ptr, png_FILE_p fp) |
destinyXfate | 2:0e2ef1edf01b | 633 | { |
destinyXfate | 2:0e2ef1edf01b | 634 | png_debug(1, "in png_init_io\n"); |
destinyXfate | 2:0e2ef1edf01b | 635 | if(png_ptr == NULL) return; |
destinyXfate | 2:0e2ef1edf01b | 636 | png_ptr->io_ptr = (png_voidp)fp; |
destinyXfate | 2:0e2ef1edf01b | 637 | } |
destinyXfate | 2:0e2ef1edf01b | 638 | #endif |
destinyXfate | 2:0e2ef1edf01b | 639 | |
destinyXfate | 2:0e2ef1edf01b | 640 | #if defined(PNG_TIME_RFC1123_SUPPORTED) |
destinyXfate | 2:0e2ef1edf01b | 641 | /* Convert the supplied time into an RFC 1123 string suitable for use in |
destinyXfate | 2:0e2ef1edf01b | 642 | * a "Creation Time" or other text-based time string. |
destinyXfate | 2:0e2ef1edf01b | 643 | */ |
destinyXfate | 2:0e2ef1edf01b | 644 | png_charp PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 645 | png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime) |
destinyXfate | 2:0e2ef1edf01b | 646 | { |
destinyXfate | 2:0e2ef1edf01b | 647 | static PNG_CONST char short_months[12][4] = |
destinyXfate | 2:0e2ef1edf01b | 648 | {"Jan", "Feb", "Mar", "Apr", "May", "Jun", |
destinyXfate | 2:0e2ef1edf01b | 649 | "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; |
destinyXfate | 2:0e2ef1edf01b | 650 | |
destinyXfate | 2:0e2ef1edf01b | 651 | if(png_ptr == NULL) return (NULL); |
destinyXfate | 2:0e2ef1edf01b | 652 | if (png_ptr->time_buffer == NULL) |
destinyXfate | 2:0e2ef1edf01b | 653 | { |
destinyXfate | 2:0e2ef1edf01b | 654 | png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29* |
destinyXfate | 2:0e2ef1edf01b | 655 | png_sizeof(char))); |
destinyXfate | 2:0e2ef1edf01b | 656 | } |
destinyXfate | 2:0e2ef1edf01b | 657 | |
destinyXfate | 2:0e2ef1edf01b | 658 | #if defined(_WIN32_WCE) |
destinyXfate | 2:0e2ef1edf01b | 659 | { |
destinyXfate | 2:0e2ef1edf01b | 660 | wchar_t time_buf[29]; |
destinyXfate | 2:0e2ef1edf01b | 661 | wsprintf(time_buf, TEXT("%d %S %d %02d:%02d:%02d +0000"), |
destinyXfate | 2:0e2ef1edf01b | 662 | ptime->day % 32, short_months[(ptime->month - 1) % 12], |
destinyXfate | 2:0e2ef1edf01b | 663 | ptime->year, ptime->hour % 24, ptime->minute % 60, |
destinyXfate | 2:0e2ef1edf01b | 664 | ptime->second % 61); |
destinyXfate | 2:0e2ef1edf01b | 665 | WideCharToMultiByte(CP_ACP, 0, time_buf, -1, png_ptr->time_buffer, 29, |
destinyXfate | 2:0e2ef1edf01b | 666 | NULL, NULL); |
destinyXfate | 2:0e2ef1edf01b | 667 | } |
destinyXfate | 2:0e2ef1edf01b | 668 | #else |
destinyXfate | 2:0e2ef1edf01b | 669 | #ifdef USE_FAR_KEYWORD |
destinyXfate | 2:0e2ef1edf01b | 670 | { |
destinyXfate | 2:0e2ef1edf01b | 671 | char near_time_buf[29]; |
destinyXfate | 2:0e2ef1edf01b | 672 | sprintf(near_time_buf, "%d %s %d %02d:%02d:%02d +0000", |
destinyXfate | 2:0e2ef1edf01b | 673 | ptime->day % 32, short_months[(ptime->month - 1) % 12], |
destinyXfate | 2:0e2ef1edf01b | 674 | ptime->year, ptime->hour % 24, ptime->minute % 60, |
destinyXfate | 2:0e2ef1edf01b | 675 | ptime->second % 61); |
destinyXfate | 2:0e2ef1edf01b | 676 | png_memcpy(png_ptr->time_buffer, near_time_buf, |
destinyXfate | 2:0e2ef1edf01b | 677 | 29*png_sizeof(char)); |
destinyXfate | 2:0e2ef1edf01b | 678 | } |
destinyXfate | 2:0e2ef1edf01b | 679 | #else |
destinyXfate | 2:0e2ef1edf01b | 680 | sprintf(png_ptr->time_buffer, "%d %s %d %02d:%02d:%02d +0000", |
destinyXfate | 2:0e2ef1edf01b | 681 | ptime->day % 32, short_months[(ptime->month - 1) % 12], |
destinyXfate | 2:0e2ef1edf01b | 682 | ptime->year, ptime->hour % 24, ptime->minute % 60, |
destinyXfate | 2:0e2ef1edf01b | 683 | ptime->second % 61); |
destinyXfate | 2:0e2ef1edf01b | 684 | #endif |
destinyXfate | 2:0e2ef1edf01b | 685 | #endif /* _WIN32_WCE */ |
destinyXfate | 2:0e2ef1edf01b | 686 | return ((png_charp)png_ptr->time_buffer); |
destinyXfate | 2:0e2ef1edf01b | 687 | } |
destinyXfate | 2:0e2ef1edf01b | 688 | #endif /* PNG_TIME_RFC1123_SUPPORTED */ |
destinyXfate | 2:0e2ef1edf01b | 689 | |
destinyXfate | 2:0e2ef1edf01b | 690 | #if 0 |
destinyXfate | 2:0e2ef1edf01b | 691 | /* Signature string for a PNG file. */ |
destinyXfate | 2:0e2ef1edf01b | 692 | png_bytep PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 693 | png_sig_bytes(void) |
destinyXfate | 2:0e2ef1edf01b | 694 | { |
destinyXfate | 2:0e2ef1edf01b | 695 | return ((png_bytep)"\211\120\116\107\015\012\032\012"); |
destinyXfate | 2:0e2ef1edf01b | 696 | } |
destinyXfate | 2:0e2ef1edf01b | 697 | #endif |
destinyXfate | 2:0e2ef1edf01b | 698 | #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ |
destinyXfate | 2:0e2ef1edf01b | 699 | |
destinyXfate | 2:0e2ef1edf01b | 700 | png_charp PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 701 | png_get_copyright(png_structp png_ptr) |
destinyXfate | 2:0e2ef1edf01b | 702 | { |
destinyXfate | 2:0e2ef1edf01b | 703 | if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ |
destinyXfate | 2:0e2ef1edf01b | 704 | return ((png_charp) "\n libpng version 1.2.15 - January 5, 2007\n\ |
destinyXfate | 2:0e2ef1edf01b | 705 | Copyright (c) 1998-2007 Glenn Randers-Pehrson\n\ |
destinyXfate | 2:0e2ef1edf01b | 706 | Copyright (c) 1996-1997 Andreas Dilger\n\ |
destinyXfate | 2:0e2ef1edf01b | 707 | Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n"); |
destinyXfate | 2:0e2ef1edf01b | 708 | return ((png_charp) ""); |
destinyXfate | 2:0e2ef1edf01b | 709 | } |
destinyXfate | 2:0e2ef1edf01b | 710 | |
destinyXfate | 2:0e2ef1edf01b | 711 | /* The following return the library version as a short string in the |
destinyXfate | 2:0e2ef1edf01b | 712 | * format 1.0.0 through 99.99.99zz. To get the version of *.h files |
destinyXfate | 2:0e2ef1edf01b | 713 | * used with your application, print out PNG_LIBPNG_VER_STRING, which |
destinyXfate | 2:0e2ef1edf01b | 714 | * is defined in png.h. |
destinyXfate | 2:0e2ef1edf01b | 715 | * Note: now there is no difference between png_get_libpng_ver() and |
destinyXfate | 2:0e2ef1edf01b | 716 | * png_get_header_ver(). Due to the version_nn_nn_nn typedef guard, |
destinyXfate | 2:0e2ef1edf01b | 717 | * it is guaranteed that png.c uses the correct version of png.h. |
destinyXfate | 2:0e2ef1edf01b | 718 | */ |
destinyXfate | 2:0e2ef1edf01b | 719 | png_charp PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 720 | png_get_libpng_ver(png_structp png_ptr) |
destinyXfate | 2:0e2ef1edf01b | 721 | { |
destinyXfate | 2:0e2ef1edf01b | 722 | /* Version of *.c files used when building libpng */ |
destinyXfate | 2:0e2ef1edf01b | 723 | if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ |
destinyXfate | 2:0e2ef1edf01b | 724 | return ((png_charp) PNG_LIBPNG_VER_STRING); |
destinyXfate | 2:0e2ef1edf01b | 725 | return ((png_charp) ""); |
destinyXfate | 2:0e2ef1edf01b | 726 | } |
destinyXfate | 2:0e2ef1edf01b | 727 | |
destinyXfate | 2:0e2ef1edf01b | 728 | png_charp PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 729 | png_get_header_ver(png_structp png_ptr) |
destinyXfate | 2:0e2ef1edf01b | 730 | { |
destinyXfate | 2:0e2ef1edf01b | 731 | /* Version of *.h files used when building libpng */ |
destinyXfate | 2:0e2ef1edf01b | 732 | if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ |
destinyXfate | 2:0e2ef1edf01b | 733 | return ((png_charp) PNG_LIBPNG_VER_STRING); |
destinyXfate | 2:0e2ef1edf01b | 734 | return ((png_charp) ""); |
destinyXfate | 2:0e2ef1edf01b | 735 | } |
destinyXfate | 2:0e2ef1edf01b | 736 | |
destinyXfate | 2:0e2ef1edf01b | 737 | png_charp PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 738 | png_get_header_version(png_structp png_ptr) |
destinyXfate | 2:0e2ef1edf01b | 739 | { |
destinyXfate | 2:0e2ef1edf01b | 740 | /* Returns longer string containing both version and date */ |
destinyXfate | 2:0e2ef1edf01b | 741 | if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ |
destinyXfate | 2:0e2ef1edf01b | 742 | return ((png_charp) PNG_HEADER_VERSION_STRING); |
destinyXfate | 2:0e2ef1edf01b | 743 | return ((png_charp) ""); |
destinyXfate | 2:0e2ef1edf01b | 744 | } |
destinyXfate | 2:0e2ef1edf01b | 745 | |
destinyXfate | 2:0e2ef1edf01b | 746 | #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) |
destinyXfate | 2:0e2ef1edf01b | 747 | #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 748 | int PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 749 | png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name) |
destinyXfate | 2:0e2ef1edf01b | 750 | { |
destinyXfate | 2:0e2ef1edf01b | 751 | /* check chunk_name and return "keep" value if it's on the list, else 0 */ |
destinyXfate | 2:0e2ef1edf01b | 752 | int i; |
destinyXfate | 2:0e2ef1edf01b | 753 | png_bytep p; |
destinyXfate | 2:0e2ef1edf01b | 754 | if((png_ptr == NULL && chunk_name == NULL) || png_ptr->num_chunk_list<=0) |
destinyXfate | 2:0e2ef1edf01b | 755 | return 0; |
destinyXfate | 2:0e2ef1edf01b | 756 | p=png_ptr->chunk_list+png_ptr->num_chunk_list*5-5; |
destinyXfate | 2:0e2ef1edf01b | 757 | for (i = png_ptr->num_chunk_list; i; i--, p-=5) |
destinyXfate | 2:0e2ef1edf01b | 758 | if (!png_memcmp(chunk_name, p, 4)) |
destinyXfate | 2:0e2ef1edf01b | 759 | return ((int)*(p+4)); |
destinyXfate | 2:0e2ef1edf01b | 760 | return 0; |
destinyXfate | 2:0e2ef1edf01b | 761 | } |
destinyXfate | 2:0e2ef1edf01b | 762 | #endif |
destinyXfate | 2:0e2ef1edf01b | 763 | |
destinyXfate | 2:0e2ef1edf01b | 764 | /* This function, added to libpng-1.0.6g, is untested. */ |
destinyXfate | 2:0e2ef1edf01b | 765 | int PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 766 | png_reset_zstream(png_structp png_ptr) |
destinyXfate | 2:0e2ef1edf01b | 767 | { |
destinyXfate | 2:0e2ef1edf01b | 768 | if (png_ptr == NULL) return Z_STREAM_ERROR; |
destinyXfate | 2:0e2ef1edf01b | 769 | return (inflateReset(&png_ptr->zstream)); |
destinyXfate | 2:0e2ef1edf01b | 770 | } |
destinyXfate | 2:0e2ef1edf01b | 771 | #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ |
destinyXfate | 2:0e2ef1edf01b | 772 | |
destinyXfate | 2:0e2ef1edf01b | 773 | /* This function was added to libpng-1.0.7 */ |
destinyXfate | 2:0e2ef1edf01b | 774 | png_uint_32 PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 775 | png_access_version_number(void) |
destinyXfate | 2:0e2ef1edf01b | 776 | { |
destinyXfate | 2:0e2ef1edf01b | 777 | /* Version of *.c files used when building libpng */ |
destinyXfate | 2:0e2ef1edf01b | 778 | return((png_uint_32) PNG_LIBPNG_VER); |
destinyXfate | 2:0e2ef1edf01b | 779 | } |
destinyXfate | 2:0e2ef1edf01b | 780 | |
destinyXfate | 2:0e2ef1edf01b | 781 | |
destinyXfate | 2:0e2ef1edf01b | 782 | #if defined(PNG_READ_SUPPORTED) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) |
destinyXfate | 2:0e2ef1edf01b | 783 | #if !defined(PNG_1_0_X) |
destinyXfate | 2:0e2ef1edf01b | 784 | #if defined(PNG_MMX_CODE_SUPPORTED) |
destinyXfate | 2:0e2ef1edf01b | 785 | /* this INTERNAL function was added to libpng 1.2.0 */ |
destinyXfate | 2:0e2ef1edf01b | 786 | void /* PRIVATE */ |
destinyXfate | 2:0e2ef1edf01b | 787 | png_init_mmx_flags (png_structp png_ptr) |
destinyXfate | 2:0e2ef1edf01b | 788 | { |
destinyXfate | 2:0e2ef1edf01b | 789 | if(png_ptr == NULL) return; |
destinyXfate | 2:0e2ef1edf01b | 790 | png_ptr->mmx_rowbytes_threshold = 0; |
destinyXfate | 2:0e2ef1edf01b | 791 | png_ptr->mmx_bitdepth_threshold = 0; |
destinyXfate | 2:0e2ef1edf01b | 792 | |
destinyXfate | 2:0e2ef1edf01b | 793 | # if (defined(PNG_USE_PNGVCRD) || defined(PNG_USE_PNGGCCRD)) |
destinyXfate | 2:0e2ef1edf01b | 794 | |
destinyXfate | 2:0e2ef1edf01b | 795 | png_ptr->asm_flags |= PNG_ASM_FLAG_MMX_SUPPORT_COMPILED; |
destinyXfate | 2:0e2ef1edf01b | 796 | |
destinyXfate | 2:0e2ef1edf01b | 797 | if (png_mmx_support() > 0) { |
destinyXfate | 2:0e2ef1edf01b | 798 | png_ptr->asm_flags |= PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU |
destinyXfate | 2:0e2ef1edf01b | 799 | # ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW |
destinyXfate | 2:0e2ef1edf01b | 800 | | PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
destinyXfate | 2:0e2ef1edf01b | 801 | # endif |
destinyXfate | 2:0e2ef1edf01b | 802 | # ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE |
destinyXfate | 2:0e2ef1edf01b | 803 | | PNG_ASM_FLAG_MMX_READ_INTERLACE |
destinyXfate | 2:0e2ef1edf01b | 804 | # endif |
destinyXfate | 2:0e2ef1edf01b | 805 | # ifndef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW |
destinyXfate | 2:0e2ef1edf01b | 806 | ; |
destinyXfate | 2:0e2ef1edf01b | 807 | # else |
destinyXfate | 2:0e2ef1edf01b | 808 | | PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
destinyXfate | 2:0e2ef1edf01b | 809 | | PNG_ASM_FLAG_MMX_READ_FILTER_UP |
destinyXfate | 2:0e2ef1edf01b | 810 | | PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
destinyXfate | 2:0e2ef1edf01b | 811 | | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; |
destinyXfate | 2:0e2ef1edf01b | 812 | |
destinyXfate | 2:0e2ef1edf01b | 813 | png_ptr->mmx_rowbytes_threshold = PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT; |
destinyXfate | 2:0e2ef1edf01b | 814 | png_ptr->mmx_bitdepth_threshold = PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT; |
destinyXfate | 2:0e2ef1edf01b | 815 | # endif |
destinyXfate | 2:0e2ef1edf01b | 816 | } else { |
destinyXfate | 2:0e2ef1edf01b | 817 | png_ptr->asm_flags &= ~( PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU |
destinyXfate | 2:0e2ef1edf01b | 818 | | PNG_MMX_READ_FLAGS |
destinyXfate | 2:0e2ef1edf01b | 819 | | PNG_MMX_WRITE_FLAGS ); |
destinyXfate | 2:0e2ef1edf01b | 820 | } |
destinyXfate | 2:0e2ef1edf01b | 821 | |
destinyXfate | 2:0e2ef1edf01b | 822 | # else /* !(PNGVCRD || PNGGCCRD) */ |
destinyXfate | 2:0e2ef1edf01b | 823 | |
destinyXfate | 2:0e2ef1edf01b | 824 | /* clear all MMX flags; no support is compiled in */ |
destinyXfate | 2:0e2ef1edf01b | 825 | png_ptr->asm_flags &= ~( PNG_MMX_FLAGS ); |
destinyXfate | 2:0e2ef1edf01b | 826 | |
destinyXfate | 2:0e2ef1edf01b | 827 | # endif /* ?(PNGVCRD || PNGGCCRD) */ |
destinyXfate | 2:0e2ef1edf01b | 828 | } |
destinyXfate | 2:0e2ef1edf01b | 829 | |
destinyXfate | 2:0e2ef1edf01b | 830 | #endif /* !(PNG_MMX_CODE_SUPPORTED) */ |
destinyXfate | 2:0e2ef1edf01b | 831 | |
destinyXfate | 2:0e2ef1edf01b | 832 | /* this function was added to libpng 1.2.0 */ |
destinyXfate | 2:0e2ef1edf01b | 833 | #if !defined(PNG_USE_PNGGCCRD) && \ |
destinyXfate | 2:0e2ef1edf01b | 834 | !(defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD)) |
destinyXfate | 2:0e2ef1edf01b | 835 | int PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 836 | png_mmx_support(void) |
destinyXfate | 2:0e2ef1edf01b | 837 | { |
destinyXfate | 2:0e2ef1edf01b | 838 | return -1; |
destinyXfate | 2:0e2ef1edf01b | 839 | } |
destinyXfate | 2:0e2ef1edf01b | 840 | #endif |
destinyXfate | 2:0e2ef1edf01b | 841 | #endif /* PNG_1_0_X && PNG_ASSEMBLER_CODE_SUPPORTED */ |
destinyXfate | 2:0e2ef1edf01b | 842 | #endif /* PNG_READ_SUPPORTED */ |
destinyXfate | 2:0e2ef1edf01b | 843 | |
destinyXfate | 2:0e2ef1edf01b | 844 | #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) |
destinyXfate | 2:0e2ef1edf01b | 845 | #ifdef PNG_SIZE_T |
destinyXfate | 2:0e2ef1edf01b | 846 | /* Added at libpng version 1.2.6 */ |
destinyXfate | 2:0e2ef1edf01b | 847 | PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size)); |
destinyXfate | 2:0e2ef1edf01b | 848 | png_size_t PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 849 | png_convert_size(size_t size) |
destinyXfate | 2:0e2ef1edf01b | 850 | { |
destinyXfate | 2:0e2ef1edf01b | 851 | if (size > (png_size_t)-1) |
destinyXfate | 2:0e2ef1edf01b | 852 | PNG_ABORT(); /* We haven't got access to png_ptr, so no png_error() */ |
destinyXfate | 2:0e2ef1edf01b | 853 | return ((png_size_t)size); |
destinyXfate | 2:0e2ef1edf01b | 854 | } |
destinyXfate | 2:0e2ef1edf01b | 855 | #endif /* PNG_SIZE_T */ |
destinyXfate | 2:0e2ef1edf01b | 856 | #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ |
destinyXfate | 2:0e2ef1edf01b | 857 |