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