Dependencies:   emwin_lib

Fork of DMemWin by Embedded Artists

Committer:
destinyXfate
Date:
Thu Jun 02 04:55:08 2016 +0000
Revision:
4:20387dbf7ecf
Parent:
2:0e2ef1edf01b
;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
destinyXfate 2:0e2ef1edf01b 1
destinyXfate 2:0e2ef1edf01b 2 /* pngpread.c - read a png file in push mode
destinyXfate 2:0e2ef1edf01b 3 *
destinyXfate 2:0e2ef1edf01b 4 * Last changed in libpng 1.2.13 November 13, 2006
destinyXfate 2:0e2ef1edf01b 5 * For conditions of distribution and use, see copyright notice in png.h
destinyXfate 2:0e2ef1edf01b 6 * Copyright (c) 1998-2006 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 #include "png.h"
destinyXfate 2:0e2ef1edf01b 13
destinyXfate 2:0e2ef1edf01b 14 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
destinyXfate 2:0e2ef1edf01b 15
destinyXfate 2:0e2ef1edf01b 16 /* push model modes */
destinyXfate 2:0e2ef1edf01b 17 #define PNG_READ_SIG_MODE 0
destinyXfate 2:0e2ef1edf01b 18 #define PNG_READ_CHUNK_MODE 1
destinyXfate 2:0e2ef1edf01b 19 #define PNG_READ_IDAT_MODE 2
destinyXfate 2:0e2ef1edf01b 20 #define PNG_SKIP_MODE 3
destinyXfate 2:0e2ef1edf01b 21 #define PNG_READ_tEXt_MODE 4
destinyXfate 2:0e2ef1edf01b 22 #define PNG_READ_zTXt_MODE 5
destinyXfate 2:0e2ef1edf01b 23 #define PNG_READ_DONE_MODE 6
destinyXfate 2:0e2ef1edf01b 24 #define PNG_READ_iTXt_MODE 7
destinyXfate 2:0e2ef1edf01b 25 #define PNG_ERROR_MODE 8
destinyXfate 2:0e2ef1edf01b 26
destinyXfate 2:0e2ef1edf01b 27 void PNGAPI
destinyXfate 2:0e2ef1edf01b 28 png_process_data(png_structp png_ptr, png_infop info_ptr,
destinyXfate 2:0e2ef1edf01b 29 png_bytep buffer, png_size_t buffer_size)
destinyXfate 2:0e2ef1edf01b 30 {
destinyXfate 2:0e2ef1edf01b 31 if(png_ptr == NULL) return;
destinyXfate 2:0e2ef1edf01b 32 png_push_restore_buffer(png_ptr, buffer, buffer_size);
destinyXfate 2:0e2ef1edf01b 33
destinyXfate 2:0e2ef1edf01b 34 while (png_ptr->buffer_size)
destinyXfate 2:0e2ef1edf01b 35 {
destinyXfate 2:0e2ef1edf01b 36 png_process_some_data(png_ptr, info_ptr);
destinyXfate 2:0e2ef1edf01b 37 }
destinyXfate 2:0e2ef1edf01b 38 }
destinyXfate 2:0e2ef1edf01b 39
destinyXfate 2:0e2ef1edf01b 40 /* What we do with the incoming data depends on what we were previously
destinyXfate 2:0e2ef1edf01b 41 * doing before we ran out of data...
destinyXfate 2:0e2ef1edf01b 42 */
destinyXfate 2:0e2ef1edf01b 43 void /* PRIVATE */
destinyXfate 2:0e2ef1edf01b 44 png_process_some_data(png_structp png_ptr, png_infop info_ptr)
destinyXfate 2:0e2ef1edf01b 45 {
destinyXfate 2:0e2ef1edf01b 46 if(png_ptr == NULL) return;
destinyXfate 2:0e2ef1edf01b 47 switch (png_ptr->process_mode)
destinyXfate 2:0e2ef1edf01b 48 {
destinyXfate 2:0e2ef1edf01b 49 case PNG_READ_SIG_MODE:
destinyXfate 2:0e2ef1edf01b 50 {
destinyXfate 2:0e2ef1edf01b 51 png_push_read_sig(png_ptr, info_ptr);
destinyXfate 2:0e2ef1edf01b 52 break;
destinyXfate 2:0e2ef1edf01b 53 }
destinyXfate 2:0e2ef1edf01b 54 case PNG_READ_CHUNK_MODE:
destinyXfate 2:0e2ef1edf01b 55 {
destinyXfate 2:0e2ef1edf01b 56 png_push_read_chunk(png_ptr, info_ptr);
destinyXfate 2:0e2ef1edf01b 57 break;
destinyXfate 2:0e2ef1edf01b 58 }
destinyXfate 2:0e2ef1edf01b 59 case PNG_READ_IDAT_MODE:
destinyXfate 2:0e2ef1edf01b 60 {
destinyXfate 2:0e2ef1edf01b 61 png_push_read_IDAT(png_ptr);
destinyXfate 2:0e2ef1edf01b 62 break;
destinyXfate 2:0e2ef1edf01b 63 }
destinyXfate 2:0e2ef1edf01b 64 #if defined(PNG_READ_tEXt_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 65 case PNG_READ_tEXt_MODE:
destinyXfate 2:0e2ef1edf01b 66 {
destinyXfate 2:0e2ef1edf01b 67 png_push_read_tEXt(png_ptr, info_ptr);
destinyXfate 2:0e2ef1edf01b 68 break;
destinyXfate 2:0e2ef1edf01b 69 }
destinyXfate 2:0e2ef1edf01b 70 #endif
destinyXfate 2:0e2ef1edf01b 71 #if defined(PNG_READ_zTXt_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 72 case PNG_READ_zTXt_MODE:
destinyXfate 2:0e2ef1edf01b 73 {
destinyXfate 2:0e2ef1edf01b 74 png_push_read_zTXt(png_ptr, info_ptr);
destinyXfate 2:0e2ef1edf01b 75 break;
destinyXfate 2:0e2ef1edf01b 76 }
destinyXfate 2:0e2ef1edf01b 77 #endif
destinyXfate 2:0e2ef1edf01b 78 #if defined(PNG_READ_iTXt_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 79 case PNG_READ_iTXt_MODE:
destinyXfate 2:0e2ef1edf01b 80 {
destinyXfate 2:0e2ef1edf01b 81 png_push_read_iTXt(png_ptr, info_ptr);
destinyXfate 2:0e2ef1edf01b 82 break;
destinyXfate 2:0e2ef1edf01b 83 }
destinyXfate 2:0e2ef1edf01b 84 #endif
destinyXfate 2:0e2ef1edf01b 85 case PNG_SKIP_MODE:
destinyXfate 2:0e2ef1edf01b 86 {
destinyXfate 2:0e2ef1edf01b 87 png_push_crc_finish(png_ptr);
destinyXfate 2:0e2ef1edf01b 88 break;
destinyXfate 2:0e2ef1edf01b 89 }
destinyXfate 2:0e2ef1edf01b 90 default:
destinyXfate 2:0e2ef1edf01b 91 {
destinyXfate 2:0e2ef1edf01b 92 png_ptr->buffer_size = 0;
destinyXfate 2:0e2ef1edf01b 93 break;
destinyXfate 2:0e2ef1edf01b 94 }
destinyXfate 2:0e2ef1edf01b 95 }
destinyXfate 2:0e2ef1edf01b 96 }
destinyXfate 2:0e2ef1edf01b 97
destinyXfate 2:0e2ef1edf01b 98 /* Read any remaining signature bytes from the stream and compare them with
destinyXfate 2:0e2ef1edf01b 99 * the correct PNG signature. It is possible that this routine is called
destinyXfate 2:0e2ef1edf01b 100 * with bytes already read from the signature, either because they have been
destinyXfate 2:0e2ef1edf01b 101 * checked by the calling application, or because of multiple calls to this
destinyXfate 2:0e2ef1edf01b 102 * routine.
destinyXfate 2:0e2ef1edf01b 103 */
destinyXfate 2:0e2ef1edf01b 104 void /* PRIVATE */
destinyXfate 2:0e2ef1edf01b 105 png_push_read_sig(png_structp png_ptr, png_infop info_ptr)
destinyXfate 2:0e2ef1edf01b 106 {
destinyXfate 2:0e2ef1edf01b 107 png_size_t num_checked = png_ptr->sig_bytes,
destinyXfate 2:0e2ef1edf01b 108 num_to_check = 8 - num_checked;
destinyXfate 2:0e2ef1edf01b 109
destinyXfate 2:0e2ef1edf01b 110 if (png_ptr->buffer_size < num_to_check)
destinyXfate 2:0e2ef1edf01b 111 {
destinyXfate 2:0e2ef1edf01b 112 num_to_check = png_ptr->buffer_size;
destinyXfate 2:0e2ef1edf01b 113 }
destinyXfate 2:0e2ef1edf01b 114
destinyXfate 2:0e2ef1edf01b 115 png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]),
destinyXfate 2:0e2ef1edf01b 116 num_to_check);
destinyXfate 2:0e2ef1edf01b 117 png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes+num_to_check);
destinyXfate 2:0e2ef1edf01b 118
destinyXfate 2:0e2ef1edf01b 119 if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check))
destinyXfate 2:0e2ef1edf01b 120 {
destinyXfate 2:0e2ef1edf01b 121 if (num_checked < 4 &&
destinyXfate 2:0e2ef1edf01b 122 png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4))
destinyXfate 2:0e2ef1edf01b 123 png_error(png_ptr, "Not a PNG file");
destinyXfate 2:0e2ef1edf01b 124 else
destinyXfate 2:0e2ef1edf01b 125 png_error(png_ptr, "PNG file corrupted by ASCII conversion");
destinyXfate 2:0e2ef1edf01b 126 }
destinyXfate 2:0e2ef1edf01b 127 else
destinyXfate 2:0e2ef1edf01b 128 {
destinyXfate 2:0e2ef1edf01b 129 if (png_ptr->sig_bytes >= 8)
destinyXfate 2:0e2ef1edf01b 130 {
destinyXfate 2:0e2ef1edf01b 131 png_ptr->process_mode = PNG_READ_CHUNK_MODE;
destinyXfate 2:0e2ef1edf01b 132 }
destinyXfate 2:0e2ef1edf01b 133 }
destinyXfate 2:0e2ef1edf01b 134 }
destinyXfate 2:0e2ef1edf01b 135
destinyXfate 2:0e2ef1edf01b 136 void /* PRIVATE */
destinyXfate 2:0e2ef1edf01b 137 png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
destinyXfate 2:0e2ef1edf01b 138 {
destinyXfate 2:0e2ef1edf01b 139 #ifdef PNG_USE_LOCAL_ARRAYS
destinyXfate 2:0e2ef1edf01b 140 PNG_IHDR;
destinyXfate 2:0e2ef1edf01b 141 PNG_IDAT;
destinyXfate 2:0e2ef1edf01b 142 PNG_IEND;
destinyXfate 2:0e2ef1edf01b 143 PNG_PLTE;
destinyXfate 2:0e2ef1edf01b 144 #if defined(PNG_READ_bKGD_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 145 PNG_bKGD;
destinyXfate 2:0e2ef1edf01b 146 #endif
destinyXfate 2:0e2ef1edf01b 147 #if defined(PNG_READ_cHRM_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 148 PNG_cHRM;
destinyXfate 2:0e2ef1edf01b 149 #endif
destinyXfate 2:0e2ef1edf01b 150 #if defined(PNG_READ_gAMA_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 151 PNG_gAMA;
destinyXfate 2:0e2ef1edf01b 152 #endif
destinyXfate 2:0e2ef1edf01b 153 #if defined(PNG_READ_hIST_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 154 PNG_hIST;
destinyXfate 2:0e2ef1edf01b 155 #endif
destinyXfate 2:0e2ef1edf01b 156 #if defined(PNG_READ_iCCP_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 157 PNG_iCCP;
destinyXfate 2:0e2ef1edf01b 158 #endif
destinyXfate 2:0e2ef1edf01b 159 #if defined(PNG_READ_iTXt_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 160 PNG_iTXt;
destinyXfate 2:0e2ef1edf01b 161 #endif
destinyXfate 2:0e2ef1edf01b 162 #if defined(PNG_READ_oFFs_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 163 PNG_oFFs;
destinyXfate 2:0e2ef1edf01b 164 #endif
destinyXfate 2:0e2ef1edf01b 165 #if defined(PNG_READ_pCAL_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 166 PNG_pCAL;
destinyXfate 2:0e2ef1edf01b 167 #endif
destinyXfate 2:0e2ef1edf01b 168 #if defined(PNG_READ_pHYs_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 169 PNG_pHYs;
destinyXfate 2:0e2ef1edf01b 170 #endif
destinyXfate 2:0e2ef1edf01b 171 #if defined(PNG_READ_sBIT_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 172 PNG_sBIT;
destinyXfate 2:0e2ef1edf01b 173 #endif
destinyXfate 2:0e2ef1edf01b 174 #if defined(PNG_READ_sCAL_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 175 PNG_sCAL;
destinyXfate 2:0e2ef1edf01b 176 #endif
destinyXfate 2:0e2ef1edf01b 177 #if defined(PNG_READ_sRGB_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 178 PNG_sRGB;
destinyXfate 2:0e2ef1edf01b 179 #endif
destinyXfate 2:0e2ef1edf01b 180 #if defined(PNG_READ_sPLT_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 181 PNG_sPLT;
destinyXfate 2:0e2ef1edf01b 182 #endif
destinyXfate 2:0e2ef1edf01b 183 #if defined(PNG_READ_tEXt_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 184 PNG_tEXt;
destinyXfate 2:0e2ef1edf01b 185 #endif
destinyXfate 2:0e2ef1edf01b 186 #if defined(PNG_READ_tIME_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 187 PNG_tIME;
destinyXfate 2:0e2ef1edf01b 188 #endif
destinyXfate 2:0e2ef1edf01b 189 #if defined(PNG_READ_tRNS_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 190 PNG_tRNS;
destinyXfate 2:0e2ef1edf01b 191 #endif
destinyXfate 2:0e2ef1edf01b 192 #if defined(PNG_READ_zTXt_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 193 PNG_zTXt;
destinyXfate 2:0e2ef1edf01b 194 #endif
destinyXfate 2:0e2ef1edf01b 195 #endif /* PNG_USE_LOCAL_ARRAYS */
destinyXfate 2:0e2ef1edf01b 196 /* First we make sure we have enough data for the 4 byte chunk name
destinyXfate 2:0e2ef1edf01b 197 * and the 4 byte chunk length before proceeding with decoding the
destinyXfate 2:0e2ef1edf01b 198 * chunk data. To fully decode each of these chunks, we also make
destinyXfate 2:0e2ef1edf01b 199 * sure we have enough data in the buffer for the 4 byte CRC at the
destinyXfate 2:0e2ef1edf01b 200 * end of every chunk (except IDAT, which is handled separately).
destinyXfate 2:0e2ef1edf01b 201 */
destinyXfate 2:0e2ef1edf01b 202 if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
destinyXfate 2:0e2ef1edf01b 203 {
destinyXfate 2:0e2ef1edf01b 204 png_byte chunk_length[4];
destinyXfate 2:0e2ef1edf01b 205
destinyXfate 2:0e2ef1edf01b 206 if (png_ptr->buffer_size < 8)
destinyXfate 2:0e2ef1edf01b 207 {
destinyXfate 2:0e2ef1edf01b 208 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 209 return;
destinyXfate 2:0e2ef1edf01b 210 }
destinyXfate 2:0e2ef1edf01b 211
destinyXfate 2:0e2ef1edf01b 212 png_push_fill_buffer(png_ptr, chunk_length, 4);
destinyXfate 2:0e2ef1edf01b 213 png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length);
destinyXfate 2:0e2ef1edf01b 214 png_reset_crc(png_ptr);
destinyXfate 2:0e2ef1edf01b 215 png_crc_read(png_ptr, png_ptr->chunk_name, 4);
destinyXfate 2:0e2ef1edf01b 216 png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
destinyXfate 2:0e2ef1edf01b 217 }
destinyXfate 2:0e2ef1edf01b 218
destinyXfate 2:0e2ef1edf01b 219 if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4))
destinyXfate 2:0e2ef1edf01b 220 if(png_ptr->mode & PNG_AFTER_IDAT)
destinyXfate 2:0e2ef1edf01b 221 png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
destinyXfate 2:0e2ef1edf01b 222
destinyXfate 2:0e2ef1edf01b 223 if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4))
destinyXfate 2:0e2ef1edf01b 224 {
destinyXfate 2:0e2ef1edf01b 225 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
destinyXfate 2:0e2ef1edf01b 226 {
destinyXfate 2:0e2ef1edf01b 227 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 228 return;
destinyXfate 2:0e2ef1edf01b 229 }
destinyXfate 2:0e2ef1edf01b 230 png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length);
destinyXfate 2:0e2ef1edf01b 231 }
destinyXfate 2:0e2ef1edf01b 232 else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
destinyXfate 2:0e2ef1edf01b 233 {
destinyXfate 2:0e2ef1edf01b 234 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
destinyXfate 2:0e2ef1edf01b 235 {
destinyXfate 2:0e2ef1edf01b 236 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 237 return;
destinyXfate 2:0e2ef1edf01b 238 }
destinyXfate 2:0e2ef1edf01b 239 png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length);
destinyXfate 2:0e2ef1edf01b 240
destinyXfate 2:0e2ef1edf01b 241 png_ptr->process_mode = PNG_READ_DONE_MODE;
destinyXfate 2:0e2ef1edf01b 242 png_push_have_end(png_ptr, info_ptr);
destinyXfate 2:0e2ef1edf01b 243 }
destinyXfate 2:0e2ef1edf01b 244 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
destinyXfate 2:0e2ef1edf01b 245 else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name))
destinyXfate 2:0e2ef1edf01b 246 {
destinyXfate 2:0e2ef1edf01b 247 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
destinyXfate 2:0e2ef1edf01b 248 {
destinyXfate 2:0e2ef1edf01b 249 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 250 return;
destinyXfate 2:0e2ef1edf01b 251 }
destinyXfate 2:0e2ef1edf01b 252 if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
destinyXfate 2:0e2ef1edf01b 253 png_ptr->mode |= PNG_HAVE_IDAT;
destinyXfate 2:0e2ef1edf01b 254 png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length);
destinyXfate 2:0e2ef1edf01b 255 if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
destinyXfate 2:0e2ef1edf01b 256 png_ptr->mode |= PNG_HAVE_PLTE;
destinyXfate 2:0e2ef1edf01b 257 else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
destinyXfate 2:0e2ef1edf01b 258 {
destinyXfate 2:0e2ef1edf01b 259 if (!(png_ptr->mode & PNG_HAVE_IHDR))
destinyXfate 2:0e2ef1edf01b 260 png_error(png_ptr, "Missing IHDR before IDAT");
destinyXfate 2:0e2ef1edf01b 261 else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
destinyXfate 2:0e2ef1edf01b 262 !(png_ptr->mode & PNG_HAVE_PLTE))
destinyXfate 2:0e2ef1edf01b 263 png_error(png_ptr, "Missing PLTE before IDAT");
destinyXfate 2:0e2ef1edf01b 264 }
destinyXfate 2:0e2ef1edf01b 265 }
destinyXfate 2:0e2ef1edf01b 266 #endif
destinyXfate 2:0e2ef1edf01b 267 else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
destinyXfate 2:0e2ef1edf01b 268 {
destinyXfate 2:0e2ef1edf01b 269 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
destinyXfate 2:0e2ef1edf01b 270 {
destinyXfate 2:0e2ef1edf01b 271 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 272 return;
destinyXfate 2:0e2ef1edf01b 273 }
destinyXfate 2:0e2ef1edf01b 274 png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length);
destinyXfate 2:0e2ef1edf01b 275 }
destinyXfate 2:0e2ef1edf01b 276 else if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4))
destinyXfate 2:0e2ef1edf01b 277 {
destinyXfate 2:0e2ef1edf01b 278 /* If we reach an IDAT chunk, this means we have read all of the
destinyXfate 2:0e2ef1edf01b 279 * header chunks, and we can start reading the image (or if this
destinyXfate 2:0e2ef1edf01b 280 * is called after the image has been read - we have an error).
destinyXfate 2:0e2ef1edf01b 281 */
destinyXfate 2:0e2ef1edf01b 282 if (!(png_ptr->mode & PNG_HAVE_IHDR))
destinyXfate 2:0e2ef1edf01b 283 png_error(png_ptr, "Missing IHDR before IDAT");
destinyXfate 2:0e2ef1edf01b 284 else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
destinyXfate 2:0e2ef1edf01b 285 !(png_ptr->mode & PNG_HAVE_PLTE))
destinyXfate 2:0e2ef1edf01b 286 png_error(png_ptr, "Missing PLTE before IDAT");
destinyXfate 2:0e2ef1edf01b 287
destinyXfate 2:0e2ef1edf01b 288 if (png_ptr->mode & PNG_HAVE_IDAT)
destinyXfate 2:0e2ef1edf01b 289 {
destinyXfate 2:0e2ef1edf01b 290 if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
destinyXfate 2:0e2ef1edf01b 291 if (png_ptr->push_length == 0)
destinyXfate 2:0e2ef1edf01b 292 return;
destinyXfate 2:0e2ef1edf01b 293
destinyXfate 2:0e2ef1edf01b 294 if (png_ptr->mode & PNG_AFTER_IDAT)
destinyXfate 2:0e2ef1edf01b 295 png_error(png_ptr, "Too many IDAT's found");
destinyXfate 2:0e2ef1edf01b 296 }
destinyXfate 2:0e2ef1edf01b 297
destinyXfate 2:0e2ef1edf01b 298 png_ptr->idat_size = png_ptr->push_length;
destinyXfate 2:0e2ef1edf01b 299 png_ptr->mode |= PNG_HAVE_IDAT;
destinyXfate 2:0e2ef1edf01b 300 png_ptr->process_mode = PNG_READ_IDAT_MODE;
destinyXfate 2:0e2ef1edf01b 301 png_push_have_info(png_ptr, info_ptr);
destinyXfate 2:0e2ef1edf01b 302 png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes;
destinyXfate 2:0e2ef1edf01b 303 png_ptr->zstream.next_out = png_ptr->row_buf;
destinyXfate 2:0e2ef1edf01b 304 return;
destinyXfate 2:0e2ef1edf01b 305 }
destinyXfate 2:0e2ef1edf01b 306 #if defined(PNG_READ_gAMA_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 307 else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4))
destinyXfate 2:0e2ef1edf01b 308 {
destinyXfate 2:0e2ef1edf01b 309 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
destinyXfate 2:0e2ef1edf01b 310 {
destinyXfate 2:0e2ef1edf01b 311 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 312 return;
destinyXfate 2:0e2ef1edf01b 313 }
destinyXfate 2:0e2ef1edf01b 314 png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length);
destinyXfate 2:0e2ef1edf01b 315 }
destinyXfate 2:0e2ef1edf01b 316 #endif
destinyXfate 2:0e2ef1edf01b 317 #if defined(PNG_READ_sBIT_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 318 else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4))
destinyXfate 2:0e2ef1edf01b 319 {
destinyXfate 2:0e2ef1edf01b 320 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
destinyXfate 2:0e2ef1edf01b 321 {
destinyXfate 2:0e2ef1edf01b 322 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 323 return;
destinyXfate 2:0e2ef1edf01b 324 }
destinyXfate 2:0e2ef1edf01b 325 png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length);
destinyXfate 2:0e2ef1edf01b 326 }
destinyXfate 2:0e2ef1edf01b 327 #endif
destinyXfate 2:0e2ef1edf01b 328 #if defined(PNG_READ_cHRM_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 329 else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4))
destinyXfate 2:0e2ef1edf01b 330 {
destinyXfate 2:0e2ef1edf01b 331 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
destinyXfate 2:0e2ef1edf01b 332 {
destinyXfate 2:0e2ef1edf01b 333 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 334 return;
destinyXfate 2:0e2ef1edf01b 335 }
destinyXfate 2:0e2ef1edf01b 336 png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length);
destinyXfate 2:0e2ef1edf01b 337 }
destinyXfate 2:0e2ef1edf01b 338 #endif
destinyXfate 2:0e2ef1edf01b 339 #if defined(PNG_READ_sRGB_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 340 else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4))
destinyXfate 2:0e2ef1edf01b 341 {
destinyXfate 2:0e2ef1edf01b 342 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
destinyXfate 2:0e2ef1edf01b 343 {
destinyXfate 2:0e2ef1edf01b 344 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 345 return;
destinyXfate 2:0e2ef1edf01b 346 }
destinyXfate 2:0e2ef1edf01b 347 png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length);
destinyXfate 2:0e2ef1edf01b 348 }
destinyXfate 2:0e2ef1edf01b 349 #endif
destinyXfate 2:0e2ef1edf01b 350 #if defined(PNG_READ_iCCP_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 351 else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4))
destinyXfate 2:0e2ef1edf01b 352 {
destinyXfate 2:0e2ef1edf01b 353 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
destinyXfate 2:0e2ef1edf01b 354 {
destinyXfate 2:0e2ef1edf01b 355 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 356 return;
destinyXfate 2:0e2ef1edf01b 357 }
destinyXfate 2:0e2ef1edf01b 358 png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length);
destinyXfate 2:0e2ef1edf01b 359 }
destinyXfate 2:0e2ef1edf01b 360 #endif
destinyXfate 2:0e2ef1edf01b 361 #if defined(PNG_READ_sPLT_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 362 else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4))
destinyXfate 2:0e2ef1edf01b 363 {
destinyXfate 2:0e2ef1edf01b 364 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
destinyXfate 2:0e2ef1edf01b 365 {
destinyXfate 2:0e2ef1edf01b 366 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 367 return;
destinyXfate 2:0e2ef1edf01b 368 }
destinyXfate 2:0e2ef1edf01b 369 png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length);
destinyXfate 2:0e2ef1edf01b 370 }
destinyXfate 2:0e2ef1edf01b 371 #endif
destinyXfate 2:0e2ef1edf01b 372 #if defined(PNG_READ_tRNS_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 373 else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4))
destinyXfate 2:0e2ef1edf01b 374 {
destinyXfate 2:0e2ef1edf01b 375 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
destinyXfate 2:0e2ef1edf01b 376 {
destinyXfate 2:0e2ef1edf01b 377 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 378 return;
destinyXfate 2:0e2ef1edf01b 379 }
destinyXfate 2:0e2ef1edf01b 380 png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length);
destinyXfate 2:0e2ef1edf01b 381 }
destinyXfate 2:0e2ef1edf01b 382 #endif
destinyXfate 2:0e2ef1edf01b 383 #if defined(PNG_READ_bKGD_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 384 else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4))
destinyXfate 2:0e2ef1edf01b 385 {
destinyXfate 2:0e2ef1edf01b 386 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
destinyXfate 2:0e2ef1edf01b 387 {
destinyXfate 2:0e2ef1edf01b 388 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 389 return;
destinyXfate 2:0e2ef1edf01b 390 }
destinyXfate 2:0e2ef1edf01b 391 png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length);
destinyXfate 2:0e2ef1edf01b 392 }
destinyXfate 2:0e2ef1edf01b 393 #endif
destinyXfate 2:0e2ef1edf01b 394 #if defined(PNG_READ_hIST_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 395 else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4))
destinyXfate 2:0e2ef1edf01b 396 {
destinyXfate 2:0e2ef1edf01b 397 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
destinyXfate 2:0e2ef1edf01b 398 {
destinyXfate 2:0e2ef1edf01b 399 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 400 return;
destinyXfate 2:0e2ef1edf01b 401 }
destinyXfate 2:0e2ef1edf01b 402 png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length);
destinyXfate 2:0e2ef1edf01b 403 }
destinyXfate 2:0e2ef1edf01b 404 #endif
destinyXfate 2:0e2ef1edf01b 405 #if defined(PNG_READ_pHYs_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 406 else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4))
destinyXfate 2:0e2ef1edf01b 407 {
destinyXfate 2:0e2ef1edf01b 408 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
destinyXfate 2:0e2ef1edf01b 409 {
destinyXfate 2:0e2ef1edf01b 410 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 411 return;
destinyXfate 2:0e2ef1edf01b 412 }
destinyXfate 2:0e2ef1edf01b 413 png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length);
destinyXfate 2:0e2ef1edf01b 414 }
destinyXfate 2:0e2ef1edf01b 415 #endif
destinyXfate 2:0e2ef1edf01b 416 #if defined(PNG_READ_oFFs_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 417 else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4))
destinyXfate 2:0e2ef1edf01b 418 {
destinyXfate 2:0e2ef1edf01b 419 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
destinyXfate 2:0e2ef1edf01b 420 {
destinyXfate 2:0e2ef1edf01b 421 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 422 return;
destinyXfate 2:0e2ef1edf01b 423 }
destinyXfate 2:0e2ef1edf01b 424 png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length);
destinyXfate 2:0e2ef1edf01b 425 }
destinyXfate 2:0e2ef1edf01b 426 #endif
destinyXfate 2:0e2ef1edf01b 427 #if defined(PNG_READ_pCAL_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 428 else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4))
destinyXfate 2:0e2ef1edf01b 429 {
destinyXfate 2:0e2ef1edf01b 430 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
destinyXfate 2:0e2ef1edf01b 431 {
destinyXfate 2:0e2ef1edf01b 432 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 433 return;
destinyXfate 2:0e2ef1edf01b 434 }
destinyXfate 2:0e2ef1edf01b 435 png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length);
destinyXfate 2:0e2ef1edf01b 436 }
destinyXfate 2:0e2ef1edf01b 437 #endif
destinyXfate 2:0e2ef1edf01b 438 #if defined(PNG_READ_sCAL_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 439 else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4))
destinyXfate 2:0e2ef1edf01b 440 {
destinyXfate 2:0e2ef1edf01b 441 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
destinyXfate 2:0e2ef1edf01b 442 {
destinyXfate 2:0e2ef1edf01b 443 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 444 return;
destinyXfate 2:0e2ef1edf01b 445 }
destinyXfate 2:0e2ef1edf01b 446 png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length);
destinyXfate 2:0e2ef1edf01b 447 }
destinyXfate 2:0e2ef1edf01b 448 #endif
destinyXfate 2:0e2ef1edf01b 449 #if defined(PNG_READ_tIME_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 450 else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4))
destinyXfate 2:0e2ef1edf01b 451 {
destinyXfate 2:0e2ef1edf01b 452 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
destinyXfate 2:0e2ef1edf01b 453 {
destinyXfate 2:0e2ef1edf01b 454 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 455 return;
destinyXfate 2:0e2ef1edf01b 456 }
destinyXfate 2:0e2ef1edf01b 457 png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length);
destinyXfate 2:0e2ef1edf01b 458 }
destinyXfate 2:0e2ef1edf01b 459 #endif
destinyXfate 2:0e2ef1edf01b 460 #if defined(PNG_READ_tEXt_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 461 else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4))
destinyXfate 2:0e2ef1edf01b 462 {
destinyXfate 2:0e2ef1edf01b 463 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
destinyXfate 2:0e2ef1edf01b 464 {
destinyXfate 2:0e2ef1edf01b 465 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 466 return;
destinyXfate 2:0e2ef1edf01b 467 }
destinyXfate 2:0e2ef1edf01b 468 png_push_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length);
destinyXfate 2:0e2ef1edf01b 469 }
destinyXfate 2:0e2ef1edf01b 470 #endif
destinyXfate 2:0e2ef1edf01b 471 #if defined(PNG_READ_zTXt_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 472 else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4))
destinyXfate 2:0e2ef1edf01b 473 {
destinyXfate 2:0e2ef1edf01b 474 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
destinyXfate 2:0e2ef1edf01b 475 {
destinyXfate 2:0e2ef1edf01b 476 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 477 return;
destinyXfate 2:0e2ef1edf01b 478 }
destinyXfate 2:0e2ef1edf01b 479 png_push_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length);
destinyXfate 2:0e2ef1edf01b 480 }
destinyXfate 2:0e2ef1edf01b 481 #endif
destinyXfate 2:0e2ef1edf01b 482 #if defined(PNG_READ_iTXt_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 483 else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4))
destinyXfate 2:0e2ef1edf01b 484 {
destinyXfate 2:0e2ef1edf01b 485 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
destinyXfate 2:0e2ef1edf01b 486 {
destinyXfate 2:0e2ef1edf01b 487 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 488 return;
destinyXfate 2:0e2ef1edf01b 489 }
destinyXfate 2:0e2ef1edf01b 490 png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
destinyXfate 2:0e2ef1edf01b 491 }
destinyXfate 2:0e2ef1edf01b 492 #endif
destinyXfate 2:0e2ef1edf01b 493 else
destinyXfate 2:0e2ef1edf01b 494 {
destinyXfate 2:0e2ef1edf01b 495 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
destinyXfate 2:0e2ef1edf01b 496 {
destinyXfate 2:0e2ef1edf01b 497 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 498 return;
destinyXfate 2:0e2ef1edf01b 499 }
destinyXfate 2:0e2ef1edf01b 500 png_push_handle_unknown(png_ptr, info_ptr, png_ptr->push_length);
destinyXfate 2:0e2ef1edf01b 501 }
destinyXfate 2:0e2ef1edf01b 502
destinyXfate 2:0e2ef1edf01b 503 png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
destinyXfate 2:0e2ef1edf01b 504 }
destinyXfate 2:0e2ef1edf01b 505
destinyXfate 2:0e2ef1edf01b 506 void /* PRIVATE */
destinyXfate 2:0e2ef1edf01b 507 png_push_crc_skip(png_structp png_ptr, png_uint_32 skip)
destinyXfate 2:0e2ef1edf01b 508 {
destinyXfate 2:0e2ef1edf01b 509 png_ptr->process_mode = PNG_SKIP_MODE;
destinyXfate 2:0e2ef1edf01b 510 png_ptr->skip_length = skip;
destinyXfate 2:0e2ef1edf01b 511 }
destinyXfate 2:0e2ef1edf01b 512
destinyXfate 2:0e2ef1edf01b 513 void /* PRIVATE */
destinyXfate 2:0e2ef1edf01b 514 png_push_crc_finish(png_structp png_ptr)
destinyXfate 2:0e2ef1edf01b 515 {
destinyXfate 2:0e2ef1edf01b 516 if (png_ptr->skip_length && png_ptr->save_buffer_size)
destinyXfate 2:0e2ef1edf01b 517 {
destinyXfate 2:0e2ef1edf01b 518 png_size_t save_size;
destinyXfate 2:0e2ef1edf01b 519
destinyXfate 2:0e2ef1edf01b 520 if (png_ptr->skip_length < (png_uint_32)png_ptr->save_buffer_size)
destinyXfate 2:0e2ef1edf01b 521 save_size = (png_size_t)png_ptr->skip_length;
destinyXfate 2:0e2ef1edf01b 522 else
destinyXfate 2:0e2ef1edf01b 523 save_size = png_ptr->save_buffer_size;
destinyXfate 2:0e2ef1edf01b 524
destinyXfate 2:0e2ef1edf01b 525 png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size);
destinyXfate 2:0e2ef1edf01b 526
destinyXfate 2:0e2ef1edf01b 527 png_ptr->skip_length -= save_size;
destinyXfate 2:0e2ef1edf01b 528 png_ptr->buffer_size -= save_size;
destinyXfate 2:0e2ef1edf01b 529 png_ptr->save_buffer_size -= save_size;
destinyXfate 2:0e2ef1edf01b 530 png_ptr->save_buffer_ptr += save_size;
destinyXfate 2:0e2ef1edf01b 531 }
destinyXfate 2:0e2ef1edf01b 532 if (png_ptr->skip_length && png_ptr->current_buffer_size)
destinyXfate 2:0e2ef1edf01b 533 {
destinyXfate 2:0e2ef1edf01b 534 png_size_t save_size;
destinyXfate 2:0e2ef1edf01b 535
destinyXfate 2:0e2ef1edf01b 536 if (png_ptr->skip_length < (png_uint_32)png_ptr->current_buffer_size)
destinyXfate 2:0e2ef1edf01b 537 save_size = (png_size_t)png_ptr->skip_length;
destinyXfate 2:0e2ef1edf01b 538 else
destinyXfate 2:0e2ef1edf01b 539 save_size = png_ptr->current_buffer_size;
destinyXfate 2:0e2ef1edf01b 540
destinyXfate 2:0e2ef1edf01b 541 png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size);
destinyXfate 2:0e2ef1edf01b 542
destinyXfate 2:0e2ef1edf01b 543 png_ptr->skip_length -= save_size;
destinyXfate 2:0e2ef1edf01b 544 png_ptr->buffer_size -= save_size;
destinyXfate 2:0e2ef1edf01b 545 png_ptr->current_buffer_size -= save_size;
destinyXfate 2:0e2ef1edf01b 546 png_ptr->current_buffer_ptr += save_size;
destinyXfate 2:0e2ef1edf01b 547 }
destinyXfate 2:0e2ef1edf01b 548 if (!png_ptr->skip_length)
destinyXfate 2:0e2ef1edf01b 549 {
destinyXfate 2:0e2ef1edf01b 550 if (png_ptr->buffer_size < 4)
destinyXfate 2:0e2ef1edf01b 551 {
destinyXfate 2:0e2ef1edf01b 552 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 553 return;
destinyXfate 2:0e2ef1edf01b 554 }
destinyXfate 2:0e2ef1edf01b 555
destinyXfate 2:0e2ef1edf01b 556 png_crc_finish(png_ptr, 0);
destinyXfate 2:0e2ef1edf01b 557 png_ptr->process_mode = PNG_READ_CHUNK_MODE;
destinyXfate 2:0e2ef1edf01b 558 }
destinyXfate 2:0e2ef1edf01b 559 }
destinyXfate 2:0e2ef1edf01b 560
destinyXfate 2:0e2ef1edf01b 561 void PNGAPI
destinyXfate 2:0e2ef1edf01b 562 png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
destinyXfate 2:0e2ef1edf01b 563 {
destinyXfate 2:0e2ef1edf01b 564 png_bytep ptr;
destinyXfate 2:0e2ef1edf01b 565
destinyXfate 2:0e2ef1edf01b 566 if(png_ptr == NULL) return;
destinyXfate 2:0e2ef1edf01b 567 ptr = buffer;
destinyXfate 2:0e2ef1edf01b 568 if (png_ptr->save_buffer_size)
destinyXfate 2:0e2ef1edf01b 569 {
destinyXfate 2:0e2ef1edf01b 570 png_size_t save_size;
destinyXfate 2:0e2ef1edf01b 571
destinyXfate 2:0e2ef1edf01b 572 if (length < png_ptr->save_buffer_size)
destinyXfate 2:0e2ef1edf01b 573 save_size = length;
destinyXfate 2:0e2ef1edf01b 574 else
destinyXfate 2:0e2ef1edf01b 575 save_size = png_ptr->save_buffer_size;
destinyXfate 2:0e2ef1edf01b 576
destinyXfate 2:0e2ef1edf01b 577 png_memcpy(ptr, png_ptr->save_buffer_ptr, save_size);
destinyXfate 2:0e2ef1edf01b 578 length -= save_size;
destinyXfate 2:0e2ef1edf01b 579 ptr += save_size;
destinyXfate 2:0e2ef1edf01b 580 png_ptr->buffer_size -= save_size;
destinyXfate 2:0e2ef1edf01b 581 png_ptr->save_buffer_size -= save_size;
destinyXfate 2:0e2ef1edf01b 582 png_ptr->save_buffer_ptr += save_size;
destinyXfate 2:0e2ef1edf01b 583 }
destinyXfate 2:0e2ef1edf01b 584 if (length && png_ptr->current_buffer_size)
destinyXfate 2:0e2ef1edf01b 585 {
destinyXfate 2:0e2ef1edf01b 586 png_size_t save_size;
destinyXfate 2:0e2ef1edf01b 587
destinyXfate 2:0e2ef1edf01b 588 if (length < png_ptr->current_buffer_size)
destinyXfate 2:0e2ef1edf01b 589 save_size = length;
destinyXfate 2:0e2ef1edf01b 590 else
destinyXfate 2:0e2ef1edf01b 591 save_size = png_ptr->current_buffer_size;
destinyXfate 2:0e2ef1edf01b 592
destinyXfate 2:0e2ef1edf01b 593 png_memcpy(ptr, png_ptr->current_buffer_ptr, save_size);
destinyXfate 2:0e2ef1edf01b 594 png_ptr->buffer_size -= save_size;
destinyXfate 2:0e2ef1edf01b 595 png_ptr->current_buffer_size -= save_size;
destinyXfate 2:0e2ef1edf01b 596 png_ptr->current_buffer_ptr += save_size;
destinyXfate 2:0e2ef1edf01b 597 }
destinyXfate 2:0e2ef1edf01b 598 }
destinyXfate 2:0e2ef1edf01b 599
destinyXfate 2:0e2ef1edf01b 600 void /* PRIVATE */
destinyXfate 2:0e2ef1edf01b 601 png_push_save_buffer(png_structp png_ptr)
destinyXfate 2:0e2ef1edf01b 602 {
destinyXfate 2:0e2ef1edf01b 603 if (png_ptr->save_buffer_size)
destinyXfate 2:0e2ef1edf01b 604 {
destinyXfate 2:0e2ef1edf01b 605 if (png_ptr->save_buffer_ptr != png_ptr->save_buffer)
destinyXfate 2:0e2ef1edf01b 606 {
destinyXfate 2:0e2ef1edf01b 607 png_size_t i,istop;
destinyXfate 2:0e2ef1edf01b 608 png_bytep sp;
destinyXfate 2:0e2ef1edf01b 609 png_bytep dp;
destinyXfate 2:0e2ef1edf01b 610
destinyXfate 2:0e2ef1edf01b 611 istop = png_ptr->save_buffer_size;
destinyXfate 2:0e2ef1edf01b 612 for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer;
destinyXfate 2:0e2ef1edf01b 613 i < istop; i++, sp++, dp++)
destinyXfate 2:0e2ef1edf01b 614 {
destinyXfate 2:0e2ef1edf01b 615 *dp = *sp;
destinyXfate 2:0e2ef1edf01b 616 }
destinyXfate 2:0e2ef1edf01b 617 }
destinyXfate 2:0e2ef1edf01b 618 }
destinyXfate 2:0e2ef1edf01b 619 if (png_ptr->save_buffer_size + png_ptr->current_buffer_size >
destinyXfate 2:0e2ef1edf01b 620 png_ptr->save_buffer_max)
destinyXfate 2:0e2ef1edf01b 621 {
destinyXfate 2:0e2ef1edf01b 622 png_size_t new_max;
destinyXfate 2:0e2ef1edf01b 623 png_bytep old_buffer;
destinyXfate 2:0e2ef1edf01b 624
destinyXfate 2:0e2ef1edf01b 625 if (png_ptr->save_buffer_size > PNG_SIZE_MAX -
destinyXfate 2:0e2ef1edf01b 626 (png_ptr->current_buffer_size + 256))
destinyXfate 2:0e2ef1edf01b 627 {
destinyXfate 2:0e2ef1edf01b 628 png_error(png_ptr, "Potential overflow of save_buffer");
destinyXfate 2:0e2ef1edf01b 629 }
destinyXfate 2:0e2ef1edf01b 630 new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256;
destinyXfate 2:0e2ef1edf01b 631 old_buffer = png_ptr->save_buffer;
destinyXfate 2:0e2ef1edf01b 632 png_ptr->save_buffer = (png_bytep)png_malloc(png_ptr,
destinyXfate 2:0e2ef1edf01b 633 (png_uint_32)new_max);
destinyXfate 2:0e2ef1edf01b 634 png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
destinyXfate 2:0e2ef1edf01b 635 png_free(png_ptr, old_buffer);
destinyXfate 2:0e2ef1edf01b 636 png_ptr->save_buffer_max = new_max;
destinyXfate 2:0e2ef1edf01b 637 }
destinyXfate 2:0e2ef1edf01b 638 if (png_ptr->current_buffer_size)
destinyXfate 2:0e2ef1edf01b 639 {
destinyXfate 2:0e2ef1edf01b 640 png_memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size,
destinyXfate 2:0e2ef1edf01b 641 png_ptr->current_buffer_ptr, png_ptr->current_buffer_size);
destinyXfate 2:0e2ef1edf01b 642 png_ptr->save_buffer_size += png_ptr->current_buffer_size;
destinyXfate 2:0e2ef1edf01b 643 png_ptr->current_buffer_size = 0;
destinyXfate 2:0e2ef1edf01b 644 }
destinyXfate 2:0e2ef1edf01b 645 png_ptr->save_buffer_ptr = png_ptr->save_buffer;
destinyXfate 2:0e2ef1edf01b 646 png_ptr->buffer_size = 0;
destinyXfate 2:0e2ef1edf01b 647 }
destinyXfate 2:0e2ef1edf01b 648
destinyXfate 2:0e2ef1edf01b 649 void /* PRIVATE */
destinyXfate 2:0e2ef1edf01b 650 png_push_restore_buffer(png_structp png_ptr, png_bytep buffer,
destinyXfate 2:0e2ef1edf01b 651 png_size_t buffer_length)
destinyXfate 2:0e2ef1edf01b 652 {
destinyXfate 2:0e2ef1edf01b 653 png_ptr->current_buffer = buffer;
destinyXfate 2:0e2ef1edf01b 654 png_ptr->current_buffer_size = buffer_length;
destinyXfate 2:0e2ef1edf01b 655 png_ptr->buffer_size = buffer_length + png_ptr->save_buffer_size;
destinyXfate 2:0e2ef1edf01b 656 png_ptr->current_buffer_ptr = png_ptr->current_buffer;
destinyXfate 2:0e2ef1edf01b 657 }
destinyXfate 2:0e2ef1edf01b 658
destinyXfate 2:0e2ef1edf01b 659 void /* PRIVATE */
destinyXfate 2:0e2ef1edf01b 660 png_push_read_IDAT(png_structp png_ptr)
destinyXfate 2:0e2ef1edf01b 661 {
destinyXfate 2:0e2ef1edf01b 662 #ifdef PNG_USE_LOCAL_ARRAYS
destinyXfate 2:0e2ef1edf01b 663 PNG_IDAT;
destinyXfate 2:0e2ef1edf01b 664 #endif
destinyXfate 2:0e2ef1edf01b 665 if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
destinyXfate 2:0e2ef1edf01b 666 {
destinyXfate 2:0e2ef1edf01b 667 png_byte chunk_length[4];
destinyXfate 2:0e2ef1edf01b 668
destinyXfate 2:0e2ef1edf01b 669 if (png_ptr->buffer_size < 8)
destinyXfate 2:0e2ef1edf01b 670 {
destinyXfate 2:0e2ef1edf01b 671 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 672 return;
destinyXfate 2:0e2ef1edf01b 673 }
destinyXfate 2:0e2ef1edf01b 674
destinyXfate 2:0e2ef1edf01b 675 png_push_fill_buffer(png_ptr, chunk_length, 4);
destinyXfate 2:0e2ef1edf01b 676 png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length);
destinyXfate 2:0e2ef1edf01b 677 png_reset_crc(png_ptr);
destinyXfate 2:0e2ef1edf01b 678 png_crc_read(png_ptr, png_ptr->chunk_name, 4);
destinyXfate 2:0e2ef1edf01b 679 png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
destinyXfate 2:0e2ef1edf01b 680
destinyXfate 2:0e2ef1edf01b 681 if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4))
destinyXfate 2:0e2ef1edf01b 682 {
destinyXfate 2:0e2ef1edf01b 683 png_ptr->process_mode = PNG_READ_CHUNK_MODE;
destinyXfate 2:0e2ef1edf01b 684 if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
destinyXfate 2:0e2ef1edf01b 685 png_error(png_ptr, "Not enough compressed data");
destinyXfate 2:0e2ef1edf01b 686 return;
destinyXfate 2:0e2ef1edf01b 687 }
destinyXfate 2:0e2ef1edf01b 688
destinyXfate 2:0e2ef1edf01b 689 png_ptr->idat_size = png_ptr->push_length;
destinyXfate 2:0e2ef1edf01b 690 }
destinyXfate 2:0e2ef1edf01b 691 if (png_ptr->idat_size && png_ptr->save_buffer_size)
destinyXfate 2:0e2ef1edf01b 692 {
destinyXfate 2:0e2ef1edf01b 693 png_size_t save_size;
destinyXfate 2:0e2ef1edf01b 694
destinyXfate 2:0e2ef1edf01b 695 if (png_ptr->idat_size < (png_uint_32)png_ptr->save_buffer_size)
destinyXfate 2:0e2ef1edf01b 696 {
destinyXfate 2:0e2ef1edf01b 697 save_size = (png_size_t)png_ptr->idat_size;
destinyXfate 2:0e2ef1edf01b 698 /* check for overflow */
destinyXfate 2:0e2ef1edf01b 699 if((png_uint_32)save_size != png_ptr->idat_size)
destinyXfate 2:0e2ef1edf01b 700 png_error(png_ptr, "save_size overflowed in pngpread");
destinyXfate 2:0e2ef1edf01b 701 }
destinyXfate 2:0e2ef1edf01b 702 else
destinyXfate 2:0e2ef1edf01b 703 save_size = png_ptr->save_buffer_size;
destinyXfate 2:0e2ef1edf01b 704
destinyXfate 2:0e2ef1edf01b 705 png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size);
destinyXfate 2:0e2ef1edf01b 706 if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
destinyXfate 2:0e2ef1edf01b 707 png_process_IDAT_data(png_ptr, png_ptr->save_buffer_ptr, save_size);
destinyXfate 2:0e2ef1edf01b 708 png_ptr->idat_size -= save_size;
destinyXfate 2:0e2ef1edf01b 709 png_ptr->buffer_size -= save_size;
destinyXfate 2:0e2ef1edf01b 710 png_ptr->save_buffer_size -= save_size;
destinyXfate 2:0e2ef1edf01b 711 png_ptr->save_buffer_ptr += save_size;
destinyXfate 2:0e2ef1edf01b 712 }
destinyXfate 2:0e2ef1edf01b 713 if (png_ptr->idat_size && png_ptr->current_buffer_size)
destinyXfate 2:0e2ef1edf01b 714 {
destinyXfate 2:0e2ef1edf01b 715 png_size_t save_size;
destinyXfate 2:0e2ef1edf01b 716
destinyXfate 2:0e2ef1edf01b 717 if (png_ptr->idat_size < (png_uint_32)png_ptr->current_buffer_size)
destinyXfate 2:0e2ef1edf01b 718 {
destinyXfate 2:0e2ef1edf01b 719 save_size = (png_size_t)png_ptr->idat_size;
destinyXfate 2:0e2ef1edf01b 720 /* check for overflow */
destinyXfate 2:0e2ef1edf01b 721 if((png_uint_32)save_size != png_ptr->idat_size)
destinyXfate 2:0e2ef1edf01b 722 png_error(png_ptr, "save_size overflowed in pngpread");
destinyXfate 2:0e2ef1edf01b 723 }
destinyXfate 2:0e2ef1edf01b 724 else
destinyXfate 2:0e2ef1edf01b 725 save_size = png_ptr->current_buffer_size;
destinyXfate 2:0e2ef1edf01b 726
destinyXfate 2:0e2ef1edf01b 727 png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size);
destinyXfate 2:0e2ef1edf01b 728 if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
destinyXfate 2:0e2ef1edf01b 729 png_process_IDAT_data(png_ptr, png_ptr->current_buffer_ptr, save_size);
destinyXfate 2:0e2ef1edf01b 730
destinyXfate 2:0e2ef1edf01b 731 png_ptr->idat_size -= save_size;
destinyXfate 2:0e2ef1edf01b 732 png_ptr->buffer_size -= save_size;
destinyXfate 2:0e2ef1edf01b 733 png_ptr->current_buffer_size -= save_size;
destinyXfate 2:0e2ef1edf01b 734 png_ptr->current_buffer_ptr += save_size;
destinyXfate 2:0e2ef1edf01b 735 }
destinyXfate 2:0e2ef1edf01b 736 if (!png_ptr->idat_size)
destinyXfate 2:0e2ef1edf01b 737 {
destinyXfate 2:0e2ef1edf01b 738 if (png_ptr->buffer_size < 4)
destinyXfate 2:0e2ef1edf01b 739 {
destinyXfate 2:0e2ef1edf01b 740 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 741 return;
destinyXfate 2:0e2ef1edf01b 742 }
destinyXfate 2:0e2ef1edf01b 743
destinyXfate 2:0e2ef1edf01b 744 png_crc_finish(png_ptr, 0);
destinyXfate 2:0e2ef1edf01b 745 png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
destinyXfate 2:0e2ef1edf01b 746 png_ptr->mode |= PNG_AFTER_IDAT;
destinyXfate 2:0e2ef1edf01b 747 }
destinyXfate 2:0e2ef1edf01b 748 }
destinyXfate 2:0e2ef1edf01b 749
destinyXfate 2:0e2ef1edf01b 750 void /* PRIVATE */
destinyXfate 2:0e2ef1edf01b 751 png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
destinyXfate 2:0e2ef1edf01b 752 png_size_t buffer_length)
destinyXfate 2:0e2ef1edf01b 753 {
destinyXfate 2:0e2ef1edf01b 754 int ret;
destinyXfate 2:0e2ef1edf01b 755
destinyXfate 2:0e2ef1edf01b 756 if ((png_ptr->flags & PNG_FLAG_ZLIB_FINISHED) && buffer_length)
destinyXfate 2:0e2ef1edf01b 757 png_error(png_ptr, "Extra compression data");
destinyXfate 2:0e2ef1edf01b 758
destinyXfate 2:0e2ef1edf01b 759 png_ptr->zstream.next_in = buffer;
destinyXfate 2:0e2ef1edf01b 760 png_ptr->zstream.avail_in = (uInt)buffer_length;
destinyXfate 2:0e2ef1edf01b 761 for(;;)
destinyXfate 2:0e2ef1edf01b 762 {
destinyXfate 2:0e2ef1edf01b 763 ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);
destinyXfate 2:0e2ef1edf01b 764 if (ret != Z_OK)
destinyXfate 2:0e2ef1edf01b 765 {
destinyXfate 2:0e2ef1edf01b 766 if (ret == Z_STREAM_END)
destinyXfate 2:0e2ef1edf01b 767 {
destinyXfate 2:0e2ef1edf01b 768 if (png_ptr->zstream.avail_in)
destinyXfate 2:0e2ef1edf01b 769 png_error(png_ptr, "Extra compressed data");
destinyXfate 2:0e2ef1edf01b 770 if (!(png_ptr->zstream.avail_out))
destinyXfate 2:0e2ef1edf01b 771 {
destinyXfate 2:0e2ef1edf01b 772 png_push_process_row(png_ptr);
destinyXfate 2:0e2ef1edf01b 773 }
destinyXfate 2:0e2ef1edf01b 774
destinyXfate 2:0e2ef1edf01b 775 png_ptr->mode |= PNG_AFTER_IDAT;
destinyXfate 2:0e2ef1edf01b 776 png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
destinyXfate 2:0e2ef1edf01b 777 break;
destinyXfate 2:0e2ef1edf01b 778 }
destinyXfate 2:0e2ef1edf01b 779 else if (ret == Z_BUF_ERROR)
destinyXfate 2:0e2ef1edf01b 780 break;
destinyXfate 2:0e2ef1edf01b 781 else
destinyXfate 2:0e2ef1edf01b 782 png_error(png_ptr, "Decompression Error");
destinyXfate 2:0e2ef1edf01b 783 }
destinyXfate 2:0e2ef1edf01b 784 if (!(png_ptr->zstream.avail_out))
destinyXfate 2:0e2ef1edf01b 785 {
destinyXfate 2:0e2ef1edf01b 786 if ((
destinyXfate 2:0e2ef1edf01b 787 #if defined(PNG_READ_INTERLACING_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 788 png_ptr->interlaced && png_ptr->pass > 6) ||
destinyXfate 2:0e2ef1edf01b 789 (!png_ptr->interlaced &&
destinyXfate 2:0e2ef1edf01b 790 #endif
destinyXfate 2:0e2ef1edf01b 791 png_ptr->row_number == png_ptr->num_rows))
destinyXfate 2:0e2ef1edf01b 792 {
destinyXfate 2:0e2ef1edf01b 793 if (png_ptr->zstream.avail_in)
destinyXfate 2:0e2ef1edf01b 794 png_warning(png_ptr, "Too much data in IDAT chunks");
destinyXfate 2:0e2ef1edf01b 795 png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
destinyXfate 2:0e2ef1edf01b 796 break;
destinyXfate 2:0e2ef1edf01b 797 }
destinyXfate 2:0e2ef1edf01b 798 png_push_process_row(png_ptr);
destinyXfate 2:0e2ef1edf01b 799 png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes;
destinyXfate 2:0e2ef1edf01b 800 png_ptr->zstream.next_out = png_ptr->row_buf;
destinyXfate 2:0e2ef1edf01b 801 }
destinyXfate 2:0e2ef1edf01b 802 else
destinyXfate 2:0e2ef1edf01b 803 break;
destinyXfate 2:0e2ef1edf01b 804 }
destinyXfate 2:0e2ef1edf01b 805 }
destinyXfate 2:0e2ef1edf01b 806
destinyXfate 2:0e2ef1edf01b 807 void /* PRIVATE */
destinyXfate 2:0e2ef1edf01b 808 png_push_process_row(png_structp png_ptr)
destinyXfate 2:0e2ef1edf01b 809 {
destinyXfate 2:0e2ef1edf01b 810 png_ptr->row_info.color_type = png_ptr->color_type;
destinyXfate 2:0e2ef1edf01b 811 png_ptr->row_info.width = png_ptr->iwidth;
destinyXfate 2:0e2ef1edf01b 812 png_ptr->row_info.channels = png_ptr->channels;
destinyXfate 2:0e2ef1edf01b 813 png_ptr->row_info.bit_depth = png_ptr->bit_depth;
destinyXfate 2:0e2ef1edf01b 814 png_ptr->row_info.pixel_depth = png_ptr->pixel_depth;
destinyXfate 2:0e2ef1edf01b 815
destinyXfate 2:0e2ef1edf01b 816 png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth,
destinyXfate 2:0e2ef1edf01b 817 png_ptr->row_info.width);
destinyXfate 2:0e2ef1edf01b 818
destinyXfate 2:0e2ef1edf01b 819 png_read_filter_row(png_ptr, &(png_ptr->row_info),
destinyXfate 2:0e2ef1edf01b 820 png_ptr->row_buf + 1, png_ptr->prev_row + 1,
destinyXfate 2:0e2ef1edf01b 821 (int)(png_ptr->row_buf[0]));
destinyXfate 2:0e2ef1edf01b 822
destinyXfate 2:0e2ef1edf01b 823 png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf,
destinyXfate 2:0e2ef1edf01b 824 png_ptr->rowbytes + 1);
destinyXfate 2:0e2ef1edf01b 825
destinyXfate 2:0e2ef1edf01b 826 if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA))
destinyXfate 2:0e2ef1edf01b 827 png_do_read_transformations(png_ptr);
destinyXfate 2:0e2ef1edf01b 828
destinyXfate 2:0e2ef1edf01b 829 #if defined(PNG_READ_INTERLACING_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 830 /* blow up interlaced rows to full size */
destinyXfate 2:0e2ef1edf01b 831 if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))
destinyXfate 2:0e2ef1edf01b 832 {
destinyXfate 2:0e2ef1edf01b 833 if (png_ptr->pass < 6)
destinyXfate 2:0e2ef1edf01b 834 /* old interface (pre-1.0.9):
destinyXfate 2:0e2ef1edf01b 835 png_do_read_interlace(&(png_ptr->row_info),
destinyXfate 2:0e2ef1edf01b 836 png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations);
destinyXfate 2:0e2ef1edf01b 837 */
destinyXfate 2:0e2ef1edf01b 838 png_do_read_interlace(png_ptr);
destinyXfate 2:0e2ef1edf01b 839
destinyXfate 2:0e2ef1edf01b 840 switch (png_ptr->pass)
destinyXfate 2:0e2ef1edf01b 841 {
destinyXfate 2:0e2ef1edf01b 842 case 0:
destinyXfate 2:0e2ef1edf01b 843 {
destinyXfate 2:0e2ef1edf01b 844 int i;
destinyXfate 2:0e2ef1edf01b 845 for (i = 0; i < 8 && png_ptr->pass == 0; i++)
destinyXfate 2:0e2ef1edf01b 846 {
destinyXfate 2:0e2ef1edf01b 847 png_push_have_row(png_ptr, png_ptr->row_buf + 1);
destinyXfate 2:0e2ef1edf01b 848 png_read_push_finish_row(png_ptr); /* updates png_ptr->pass */
destinyXfate 2:0e2ef1edf01b 849 }
destinyXfate 2:0e2ef1edf01b 850 if (png_ptr->pass == 2) /* pass 1 might be empty */
destinyXfate 2:0e2ef1edf01b 851 {
destinyXfate 2:0e2ef1edf01b 852 for (i = 0; i < 4 && png_ptr->pass == 2; i++)
destinyXfate 2:0e2ef1edf01b 853 {
destinyXfate 2:0e2ef1edf01b 854 png_push_have_row(png_ptr, png_bytep_NULL);
destinyXfate 2:0e2ef1edf01b 855 png_read_push_finish_row(png_ptr);
destinyXfate 2:0e2ef1edf01b 856 }
destinyXfate 2:0e2ef1edf01b 857 }
destinyXfate 2:0e2ef1edf01b 858 if (png_ptr->pass == 4 && png_ptr->height <= 4)
destinyXfate 2:0e2ef1edf01b 859 {
destinyXfate 2:0e2ef1edf01b 860 for (i = 0; i < 2 && png_ptr->pass == 4; i++)
destinyXfate 2:0e2ef1edf01b 861 {
destinyXfate 2:0e2ef1edf01b 862 png_push_have_row(png_ptr, png_bytep_NULL);
destinyXfate 2:0e2ef1edf01b 863 png_read_push_finish_row(png_ptr);
destinyXfate 2:0e2ef1edf01b 864 }
destinyXfate 2:0e2ef1edf01b 865 }
destinyXfate 2:0e2ef1edf01b 866 if (png_ptr->pass == 6 && png_ptr->height <= 4)
destinyXfate 2:0e2ef1edf01b 867 {
destinyXfate 2:0e2ef1edf01b 868 png_push_have_row(png_ptr, png_bytep_NULL);
destinyXfate 2:0e2ef1edf01b 869 png_read_push_finish_row(png_ptr);
destinyXfate 2:0e2ef1edf01b 870 }
destinyXfate 2:0e2ef1edf01b 871 break;
destinyXfate 2:0e2ef1edf01b 872 }
destinyXfate 2:0e2ef1edf01b 873 case 1:
destinyXfate 2:0e2ef1edf01b 874 {
destinyXfate 2:0e2ef1edf01b 875 int i;
destinyXfate 2:0e2ef1edf01b 876 for (i = 0; i < 8 && png_ptr->pass == 1; i++)
destinyXfate 2:0e2ef1edf01b 877 {
destinyXfate 2:0e2ef1edf01b 878 png_push_have_row(png_ptr, png_ptr->row_buf + 1);
destinyXfate 2:0e2ef1edf01b 879 png_read_push_finish_row(png_ptr);
destinyXfate 2:0e2ef1edf01b 880 }
destinyXfate 2:0e2ef1edf01b 881 if (png_ptr->pass == 2) /* skip top 4 generated rows */
destinyXfate 2:0e2ef1edf01b 882 {
destinyXfate 2:0e2ef1edf01b 883 for (i = 0; i < 4 && png_ptr->pass == 2; i++)
destinyXfate 2:0e2ef1edf01b 884 {
destinyXfate 2:0e2ef1edf01b 885 png_push_have_row(png_ptr, png_bytep_NULL);
destinyXfate 2:0e2ef1edf01b 886 png_read_push_finish_row(png_ptr);
destinyXfate 2:0e2ef1edf01b 887 }
destinyXfate 2:0e2ef1edf01b 888 }
destinyXfate 2:0e2ef1edf01b 889 break;
destinyXfate 2:0e2ef1edf01b 890 }
destinyXfate 2:0e2ef1edf01b 891 case 2:
destinyXfate 2:0e2ef1edf01b 892 {
destinyXfate 2:0e2ef1edf01b 893 int i;
destinyXfate 2:0e2ef1edf01b 894 for (i = 0; i < 4 && png_ptr->pass == 2; i++)
destinyXfate 2:0e2ef1edf01b 895 {
destinyXfate 2:0e2ef1edf01b 896 png_push_have_row(png_ptr, png_ptr->row_buf + 1);
destinyXfate 2:0e2ef1edf01b 897 png_read_push_finish_row(png_ptr);
destinyXfate 2:0e2ef1edf01b 898 }
destinyXfate 2:0e2ef1edf01b 899 for (i = 0; i < 4 && png_ptr->pass == 2; i++)
destinyXfate 2:0e2ef1edf01b 900 {
destinyXfate 2:0e2ef1edf01b 901 png_push_have_row(png_ptr, png_bytep_NULL);
destinyXfate 2:0e2ef1edf01b 902 png_read_push_finish_row(png_ptr);
destinyXfate 2:0e2ef1edf01b 903 }
destinyXfate 2:0e2ef1edf01b 904 if (png_ptr->pass == 4) /* pass 3 might be empty */
destinyXfate 2:0e2ef1edf01b 905 {
destinyXfate 2:0e2ef1edf01b 906 for (i = 0; i < 2 && png_ptr->pass == 4; i++)
destinyXfate 2:0e2ef1edf01b 907 {
destinyXfate 2:0e2ef1edf01b 908 png_push_have_row(png_ptr, png_bytep_NULL);
destinyXfate 2:0e2ef1edf01b 909 png_read_push_finish_row(png_ptr);
destinyXfate 2:0e2ef1edf01b 910 }
destinyXfate 2:0e2ef1edf01b 911 }
destinyXfate 2:0e2ef1edf01b 912 break;
destinyXfate 2:0e2ef1edf01b 913 }
destinyXfate 2:0e2ef1edf01b 914 case 3:
destinyXfate 2:0e2ef1edf01b 915 {
destinyXfate 2:0e2ef1edf01b 916 int i;
destinyXfate 2:0e2ef1edf01b 917 for (i = 0; i < 4 && png_ptr->pass == 3; i++)
destinyXfate 2:0e2ef1edf01b 918 {
destinyXfate 2:0e2ef1edf01b 919 png_push_have_row(png_ptr, png_ptr->row_buf + 1);
destinyXfate 2:0e2ef1edf01b 920 png_read_push_finish_row(png_ptr);
destinyXfate 2:0e2ef1edf01b 921 }
destinyXfate 2:0e2ef1edf01b 922 if (png_ptr->pass == 4) /* skip top two generated rows */
destinyXfate 2:0e2ef1edf01b 923 {
destinyXfate 2:0e2ef1edf01b 924 for (i = 0; i < 2 && png_ptr->pass == 4; i++)
destinyXfate 2:0e2ef1edf01b 925 {
destinyXfate 2:0e2ef1edf01b 926 png_push_have_row(png_ptr, png_bytep_NULL);
destinyXfate 2:0e2ef1edf01b 927 png_read_push_finish_row(png_ptr);
destinyXfate 2:0e2ef1edf01b 928 }
destinyXfate 2:0e2ef1edf01b 929 }
destinyXfate 2:0e2ef1edf01b 930 break;
destinyXfate 2:0e2ef1edf01b 931 }
destinyXfate 2:0e2ef1edf01b 932 case 4:
destinyXfate 2:0e2ef1edf01b 933 {
destinyXfate 2:0e2ef1edf01b 934 int i;
destinyXfate 2:0e2ef1edf01b 935 for (i = 0; i < 2 && png_ptr->pass == 4; i++)
destinyXfate 2:0e2ef1edf01b 936 {
destinyXfate 2:0e2ef1edf01b 937 png_push_have_row(png_ptr, png_ptr->row_buf + 1);
destinyXfate 2:0e2ef1edf01b 938 png_read_push_finish_row(png_ptr);
destinyXfate 2:0e2ef1edf01b 939 }
destinyXfate 2:0e2ef1edf01b 940 for (i = 0; i < 2 && png_ptr->pass == 4; i++)
destinyXfate 2:0e2ef1edf01b 941 {
destinyXfate 2:0e2ef1edf01b 942 png_push_have_row(png_ptr, png_bytep_NULL);
destinyXfate 2:0e2ef1edf01b 943 png_read_push_finish_row(png_ptr);
destinyXfate 2:0e2ef1edf01b 944 }
destinyXfate 2:0e2ef1edf01b 945 if (png_ptr->pass == 6) /* pass 5 might be empty */
destinyXfate 2:0e2ef1edf01b 946 {
destinyXfate 2:0e2ef1edf01b 947 png_push_have_row(png_ptr, png_bytep_NULL);
destinyXfate 2:0e2ef1edf01b 948 png_read_push_finish_row(png_ptr);
destinyXfate 2:0e2ef1edf01b 949 }
destinyXfate 2:0e2ef1edf01b 950 break;
destinyXfate 2:0e2ef1edf01b 951 }
destinyXfate 2:0e2ef1edf01b 952 case 5:
destinyXfate 2:0e2ef1edf01b 953 {
destinyXfate 2:0e2ef1edf01b 954 int i;
destinyXfate 2:0e2ef1edf01b 955 for (i = 0; i < 2 && png_ptr->pass == 5; i++)
destinyXfate 2:0e2ef1edf01b 956 {
destinyXfate 2:0e2ef1edf01b 957 png_push_have_row(png_ptr, png_ptr->row_buf + 1);
destinyXfate 2:0e2ef1edf01b 958 png_read_push_finish_row(png_ptr);
destinyXfate 2:0e2ef1edf01b 959 }
destinyXfate 2:0e2ef1edf01b 960 if (png_ptr->pass == 6) /* skip top generated row */
destinyXfate 2:0e2ef1edf01b 961 {
destinyXfate 2:0e2ef1edf01b 962 png_push_have_row(png_ptr, png_bytep_NULL);
destinyXfate 2:0e2ef1edf01b 963 png_read_push_finish_row(png_ptr);
destinyXfate 2:0e2ef1edf01b 964 }
destinyXfate 2:0e2ef1edf01b 965 break;
destinyXfate 2:0e2ef1edf01b 966 }
destinyXfate 2:0e2ef1edf01b 967 case 6:
destinyXfate 2:0e2ef1edf01b 968 {
destinyXfate 2:0e2ef1edf01b 969 png_push_have_row(png_ptr, png_ptr->row_buf + 1);
destinyXfate 2:0e2ef1edf01b 970 png_read_push_finish_row(png_ptr);
destinyXfate 2:0e2ef1edf01b 971 if (png_ptr->pass != 6)
destinyXfate 2:0e2ef1edf01b 972 break;
destinyXfate 2:0e2ef1edf01b 973 png_push_have_row(png_ptr, png_bytep_NULL);
destinyXfate 2:0e2ef1edf01b 974 png_read_push_finish_row(png_ptr);
destinyXfate 2:0e2ef1edf01b 975 }
destinyXfate 2:0e2ef1edf01b 976 }
destinyXfate 2:0e2ef1edf01b 977 }
destinyXfate 2:0e2ef1edf01b 978 else
destinyXfate 2:0e2ef1edf01b 979 #endif
destinyXfate 2:0e2ef1edf01b 980 {
destinyXfate 2:0e2ef1edf01b 981 png_push_have_row(png_ptr, png_ptr->row_buf + 1);
destinyXfate 2:0e2ef1edf01b 982 png_read_push_finish_row(png_ptr);
destinyXfate 2:0e2ef1edf01b 983 }
destinyXfate 2:0e2ef1edf01b 984 }
destinyXfate 2:0e2ef1edf01b 985
destinyXfate 2:0e2ef1edf01b 986 void /* PRIVATE */
destinyXfate 2:0e2ef1edf01b 987 png_read_push_finish_row(png_structp png_ptr)
destinyXfate 2:0e2ef1edf01b 988 {
destinyXfate 2:0e2ef1edf01b 989 #ifdef PNG_USE_LOCAL_ARRAYS
destinyXfate 2:0e2ef1edf01b 990 /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
destinyXfate 2:0e2ef1edf01b 991
destinyXfate 2:0e2ef1edf01b 992 /* start of interlace block */
destinyXfate 2:0e2ef1edf01b 993 const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
destinyXfate 2:0e2ef1edf01b 994
destinyXfate 2:0e2ef1edf01b 995 /* offset to next interlace block */
destinyXfate 2:0e2ef1edf01b 996 const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
destinyXfate 2:0e2ef1edf01b 997
destinyXfate 2:0e2ef1edf01b 998 /* start of interlace block in the y direction */
destinyXfate 2:0e2ef1edf01b 999 const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
destinyXfate 2:0e2ef1edf01b 1000
destinyXfate 2:0e2ef1edf01b 1001 /* offset to next interlace block in the y direction */
destinyXfate 2:0e2ef1edf01b 1002 const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
destinyXfate 2:0e2ef1edf01b 1003
destinyXfate 2:0e2ef1edf01b 1004 /* Width of interlace block. This is not currently used - if you need
destinyXfate 2:0e2ef1edf01b 1005 * it, uncomment it here and in png.h
destinyXfate 2:0e2ef1edf01b 1006 const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1};
destinyXfate 2:0e2ef1edf01b 1007 */
destinyXfate 2:0e2ef1edf01b 1008
destinyXfate 2:0e2ef1edf01b 1009 /* Height of interlace block. This is not currently used - if you need
destinyXfate 2:0e2ef1edf01b 1010 * it, uncomment it here and in png.h
destinyXfate 2:0e2ef1edf01b 1011 const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
destinyXfate 2:0e2ef1edf01b 1012 */
destinyXfate 2:0e2ef1edf01b 1013 #endif
destinyXfate 2:0e2ef1edf01b 1014
destinyXfate 2:0e2ef1edf01b 1015 png_ptr->row_number++;
destinyXfate 2:0e2ef1edf01b 1016 if (png_ptr->row_number < png_ptr->num_rows)
destinyXfate 2:0e2ef1edf01b 1017 return;
destinyXfate 2:0e2ef1edf01b 1018
destinyXfate 2:0e2ef1edf01b 1019 if (png_ptr->interlaced)
destinyXfate 2:0e2ef1edf01b 1020 {
destinyXfate 2:0e2ef1edf01b 1021 png_ptr->row_number = 0;
destinyXfate 2:0e2ef1edf01b 1022 png_memset_check(png_ptr, png_ptr->prev_row, 0,
destinyXfate 2:0e2ef1edf01b 1023 png_ptr->rowbytes + 1);
destinyXfate 2:0e2ef1edf01b 1024 do
destinyXfate 2:0e2ef1edf01b 1025 {
destinyXfate 2:0e2ef1edf01b 1026 png_ptr->pass++;
destinyXfate 2:0e2ef1edf01b 1027 if ((png_ptr->pass == 1 && png_ptr->width < 5) ||
destinyXfate 2:0e2ef1edf01b 1028 (png_ptr->pass == 3 && png_ptr->width < 3) ||
destinyXfate 2:0e2ef1edf01b 1029 (png_ptr->pass == 5 && png_ptr->width < 2))
destinyXfate 2:0e2ef1edf01b 1030 png_ptr->pass++;
destinyXfate 2:0e2ef1edf01b 1031
destinyXfate 2:0e2ef1edf01b 1032 if (png_ptr->pass > 7)
destinyXfate 2:0e2ef1edf01b 1033 png_ptr->pass--;
destinyXfate 2:0e2ef1edf01b 1034 if (png_ptr->pass >= 7)
destinyXfate 2:0e2ef1edf01b 1035 break;
destinyXfate 2:0e2ef1edf01b 1036
destinyXfate 2:0e2ef1edf01b 1037 png_ptr->iwidth = (png_ptr->width +
destinyXfate 2:0e2ef1edf01b 1038 png_pass_inc[png_ptr->pass] - 1 -
destinyXfate 2:0e2ef1edf01b 1039 png_pass_start[png_ptr->pass]) /
destinyXfate 2:0e2ef1edf01b 1040 png_pass_inc[png_ptr->pass];
destinyXfate 2:0e2ef1edf01b 1041
destinyXfate 2:0e2ef1edf01b 1042 png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,
destinyXfate 2:0e2ef1edf01b 1043 png_ptr->iwidth) + 1;
destinyXfate 2:0e2ef1edf01b 1044
destinyXfate 2:0e2ef1edf01b 1045 if (png_ptr->transformations & PNG_INTERLACE)
destinyXfate 2:0e2ef1edf01b 1046 break;
destinyXfate 2:0e2ef1edf01b 1047
destinyXfate 2:0e2ef1edf01b 1048 png_ptr->num_rows = (png_ptr->height +
destinyXfate 2:0e2ef1edf01b 1049 png_pass_yinc[png_ptr->pass] - 1 -
destinyXfate 2:0e2ef1edf01b 1050 png_pass_ystart[png_ptr->pass]) /
destinyXfate 2:0e2ef1edf01b 1051 png_pass_yinc[png_ptr->pass];
destinyXfate 2:0e2ef1edf01b 1052
destinyXfate 2:0e2ef1edf01b 1053 } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0);
destinyXfate 2:0e2ef1edf01b 1054 }
destinyXfate 2:0e2ef1edf01b 1055 }
destinyXfate 2:0e2ef1edf01b 1056
destinyXfate 2:0e2ef1edf01b 1057 #if defined(PNG_READ_tEXt_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 1058 void /* PRIVATE */
destinyXfate 2:0e2ef1edf01b 1059 png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
destinyXfate 2:0e2ef1edf01b 1060 length)
destinyXfate 2:0e2ef1edf01b 1061 {
destinyXfate 2:0e2ef1edf01b 1062 if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
destinyXfate 2:0e2ef1edf01b 1063 {
destinyXfate 2:0e2ef1edf01b 1064 png_error(png_ptr, "Out of place tEXt");
destinyXfate 2:0e2ef1edf01b 1065 /* to quiet some compiler warnings */
destinyXfate 2:0e2ef1edf01b 1066 if(info_ptr == NULL) return;
destinyXfate 2:0e2ef1edf01b 1067 }
destinyXfate 2:0e2ef1edf01b 1068
destinyXfate 2:0e2ef1edf01b 1069 #ifdef PNG_MAX_MALLOC_64K
destinyXfate 2:0e2ef1edf01b 1070 png_ptr->skip_length = 0; /* This may not be necessary */
destinyXfate 2:0e2ef1edf01b 1071
destinyXfate 2:0e2ef1edf01b 1072 if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */
destinyXfate 2:0e2ef1edf01b 1073 {
destinyXfate 2:0e2ef1edf01b 1074 png_warning(png_ptr, "tEXt chunk too large to fit in memory");
destinyXfate 2:0e2ef1edf01b 1075 png_ptr->skip_length = length - (png_uint_32)65535L;
destinyXfate 2:0e2ef1edf01b 1076 length = (png_uint_32)65535L;
destinyXfate 2:0e2ef1edf01b 1077 }
destinyXfate 2:0e2ef1edf01b 1078 #endif
destinyXfate 2:0e2ef1edf01b 1079
destinyXfate 2:0e2ef1edf01b 1080 png_ptr->current_text = (png_charp)png_malloc(png_ptr,
destinyXfate 2:0e2ef1edf01b 1081 (png_uint_32)(length+1));
destinyXfate 2:0e2ef1edf01b 1082 png_ptr->current_text[length] = '\0';
destinyXfate 2:0e2ef1edf01b 1083 png_ptr->current_text_ptr = png_ptr->current_text;
destinyXfate 2:0e2ef1edf01b 1084 png_ptr->current_text_size = (png_size_t)length;
destinyXfate 2:0e2ef1edf01b 1085 png_ptr->current_text_left = (png_size_t)length;
destinyXfate 2:0e2ef1edf01b 1086 png_ptr->process_mode = PNG_READ_tEXt_MODE;
destinyXfate 2:0e2ef1edf01b 1087 }
destinyXfate 2:0e2ef1edf01b 1088
destinyXfate 2:0e2ef1edf01b 1089 void /* PRIVATE */
destinyXfate 2:0e2ef1edf01b 1090 png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
destinyXfate 2:0e2ef1edf01b 1091 {
destinyXfate 2:0e2ef1edf01b 1092 if (png_ptr->buffer_size && png_ptr->current_text_left)
destinyXfate 2:0e2ef1edf01b 1093 {
destinyXfate 2:0e2ef1edf01b 1094 png_size_t text_size;
destinyXfate 2:0e2ef1edf01b 1095
destinyXfate 2:0e2ef1edf01b 1096 if (png_ptr->buffer_size < png_ptr->current_text_left)
destinyXfate 2:0e2ef1edf01b 1097 text_size = png_ptr->buffer_size;
destinyXfate 2:0e2ef1edf01b 1098 else
destinyXfate 2:0e2ef1edf01b 1099 text_size = png_ptr->current_text_left;
destinyXfate 2:0e2ef1edf01b 1100 png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size);
destinyXfate 2:0e2ef1edf01b 1101 png_ptr->current_text_left -= text_size;
destinyXfate 2:0e2ef1edf01b 1102 png_ptr->current_text_ptr += text_size;
destinyXfate 2:0e2ef1edf01b 1103 }
destinyXfate 2:0e2ef1edf01b 1104 if (!(png_ptr->current_text_left))
destinyXfate 2:0e2ef1edf01b 1105 {
destinyXfate 2:0e2ef1edf01b 1106 png_textp text_ptr;
destinyXfate 2:0e2ef1edf01b 1107 png_charp text;
destinyXfate 2:0e2ef1edf01b 1108 png_charp key;
destinyXfate 2:0e2ef1edf01b 1109 int ret;
destinyXfate 2:0e2ef1edf01b 1110
destinyXfate 2:0e2ef1edf01b 1111 if (png_ptr->buffer_size < 4)
destinyXfate 2:0e2ef1edf01b 1112 {
destinyXfate 2:0e2ef1edf01b 1113 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 1114 return;
destinyXfate 2:0e2ef1edf01b 1115 }
destinyXfate 2:0e2ef1edf01b 1116
destinyXfate 2:0e2ef1edf01b 1117 png_push_crc_finish(png_ptr);
destinyXfate 2:0e2ef1edf01b 1118
destinyXfate 2:0e2ef1edf01b 1119 #if defined(PNG_MAX_MALLOC_64K)
destinyXfate 2:0e2ef1edf01b 1120 if (png_ptr->skip_length)
destinyXfate 2:0e2ef1edf01b 1121 return;
destinyXfate 2:0e2ef1edf01b 1122 #endif
destinyXfate 2:0e2ef1edf01b 1123
destinyXfate 2:0e2ef1edf01b 1124 key = png_ptr->current_text;
destinyXfate 2:0e2ef1edf01b 1125
destinyXfate 2:0e2ef1edf01b 1126 for (text = key; *text; text++)
destinyXfate 2:0e2ef1edf01b 1127 /* empty loop */ ;
destinyXfate 2:0e2ef1edf01b 1128
destinyXfate 2:0e2ef1edf01b 1129 if (text != key + png_ptr->current_text_size)
destinyXfate 2:0e2ef1edf01b 1130 text++;
destinyXfate 2:0e2ef1edf01b 1131
destinyXfate 2:0e2ef1edf01b 1132 text_ptr = (png_textp)png_malloc(png_ptr,
destinyXfate 2:0e2ef1edf01b 1133 (png_uint_32)png_sizeof(png_text));
destinyXfate 2:0e2ef1edf01b 1134 text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
destinyXfate 2:0e2ef1edf01b 1135 text_ptr->key = key;
destinyXfate 2:0e2ef1edf01b 1136 #ifdef PNG_iTXt_SUPPORTED
destinyXfate 2:0e2ef1edf01b 1137 text_ptr->lang = NULL;
destinyXfate 2:0e2ef1edf01b 1138 text_ptr->lang_key = NULL;
destinyXfate 2:0e2ef1edf01b 1139 #endif
destinyXfate 2:0e2ef1edf01b 1140 text_ptr->text = text;
destinyXfate 2:0e2ef1edf01b 1141
destinyXfate 2:0e2ef1edf01b 1142 ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
destinyXfate 2:0e2ef1edf01b 1143
destinyXfate 2:0e2ef1edf01b 1144 png_free(png_ptr, key);
destinyXfate 2:0e2ef1edf01b 1145 png_free(png_ptr, text_ptr);
destinyXfate 2:0e2ef1edf01b 1146 png_ptr->current_text = NULL;
destinyXfate 2:0e2ef1edf01b 1147
destinyXfate 2:0e2ef1edf01b 1148 if (ret)
destinyXfate 2:0e2ef1edf01b 1149 png_warning(png_ptr, "Insufficient memory to store text chunk.");
destinyXfate 2:0e2ef1edf01b 1150 }
destinyXfate 2:0e2ef1edf01b 1151 }
destinyXfate 2:0e2ef1edf01b 1152 #endif
destinyXfate 2:0e2ef1edf01b 1153
destinyXfate 2:0e2ef1edf01b 1154 #if defined(PNG_READ_zTXt_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 1155 void /* PRIVATE */
destinyXfate 2:0e2ef1edf01b 1156 png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
destinyXfate 2:0e2ef1edf01b 1157 length)
destinyXfate 2:0e2ef1edf01b 1158 {
destinyXfate 2:0e2ef1edf01b 1159 if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
destinyXfate 2:0e2ef1edf01b 1160 {
destinyXfate 2:0e2ef1edf01b 1161 png_error(png_ptr, "Out of place zTXt");
destinyXfate 2:0e2ef1edf01b 1162 /* to quiet some compiler warnings */
destinyXfate 2:0e2ef1edf01b 1163 if(info_ptr == NULL) return;
destinyXfate 2:0e2ef1edf01b 1164 }
destinyXfate 2:0e2ef1edf01b 1165
destinyXfate 2:0e2ef1edf01b 1166 #ifdef PNG_MAX_MALLOC_64K
destinyXfate 2:0e2ef1edf01b 1167 /* We can't handle zTXt chunks > 64K, since we don't have enough space
destinyXfate 2:0e2ef1edf01b 1168 * to be able to store the uncompressed data. Actually, the threshold
destinyXfate 2:0e2ef1edf01b 1169 * is probably around 32K, but it isn't as definite as 64K is.
destinyXfate 2:0e2ef1edf01b 1170 */
destinyXfate 2:0e2ef1edf01b 1171 if (length > (png_uint_32)65535L)
destinyXfate 2:0e2ef1edf01b 1172 {
destinyXfate 2:0e2ef1edf01b 1173 png_warning(png_ptr, "zTXt chunk too large to fit in memory");
destinyXfate 2:0e2ef1edf01b 1174 png_push_crc_skip(png_ptr, length);
destinyXfate 2:0e2ef1edf01b 1175 return;
destinyXfate 2:0e2ef1edf01b 1176 }
destinyXfate 2:0e2ef1edf01b 1177 #endif
destinyXfate 2:0e2ef1edf01b 1178
destinyXfate 2:0e2ef1edf01b 1179 png_ptr->current_text = (png_charp)png_malloc(png_ptr,
destinyXfate 2:0e2ef1edf01b 1180 (png_uint_32)(length+1));
destinyXfate 2:0e2ef1edf01b 1181 png_ptr->current_text[length] = '\0';
destinyXfate 2:0e2ef1edf01b 1182 png_ptr->current_text_ptr = png_ptr->current_text;
destinyXfate 2:0e2ef1edf01b 1183 png_ptr->current_text_size = (png_size_t)length;
destinyXfate 2:0e2ef1edf01b 1184 png_ptr->current_text_left = (png_size_t)length;
destinyXfate 2:0e2ef1edf01b 1185 png_ptr->process_mode = PNG_READ_zTXt_MODE;
destinyXfate 2:0e2ef1edf01b 1186 }
destinyXfate 2:0e2ef1edf01b 1187
destinyXfate 2:0e2ef1edf01b 1188 void /* PRIVATE */
destinyXfate 2:0e2ef1edf01b 1189 png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
destinyXfate 2:0e2ef1edf01b 1190 {
destinyXfate 2:0e2ef1edf01b 1191 if (png_ptr->buffer_size && png_ptr->current_text_left)
destinyXfate 2:0e2ef1edf01b 1192 {
destinyXfate 2:0e2ef1edf01b 1193 png_size_t text_size;
destinyXfate 2:0e2ef1edf01b 1194
destinyXfate 2:0e2ef1edf01b 1195 if (png_ptr->buffer_size < (png_uint_32)png_ptr->current_text_left)
destinyXfate 2:0e2ef1edf01b 1196 text_size = png_ptr->buffer_size;
destinyXfate 2:0e2ef1edf01b 1197 else
destinyXfate 2:0e2ef1edf01b 1198 text_size = png_ptr->current_text_left;
destinyXfate 2:0e2ef1edf01b 1199 png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size);
destinyXfate 2:0e2ef1edf01b 1200 png_ptr->current_text_left -= text_size;
destinyXfate 2:0e2ef1edf01b 1201 png_ptr->current_text_ptr += text_size;
destinyXfate 2:0e2ef1edf01b 1202 }
destinyXfate 2:0e2ef1edf01b 1203 if (!(png_ptr->current_text_left))
destinyXfate 2:0e2ef1edf01b 1204 {
destinyXfate 2:0e2ef1edf01b 1205 png_textp text_ptr;
destinyXfate 2:0e2ef1edf01b 1206 png_charp text;
destinyXfate 2:0e2ef1edf01b 1207 png_charp key;
destinyXfate 2:0e2ef1edf01b 1208 int ret;
destinyXfate 2:0e2ef1edf01b 1209 png_size_t text_size, key_size;
destinyXfate 2:0e2ef1edf01b 1210
destinyXfate 2:0e2ef1edf01b 1211 if (png_ptr->buffer_size < 4)
destinyXfate 2:0e2ef1edf01b 1212 {
destinyXfate 2:0e2ef1edf01b 1213 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 1214 return;
destinyXfate 2:0e2ef1edf01b 1215 }
destinyXfate 2:0e2ef1edf01b 1216
destinyXfate 2:0e2ef1edf01b 1217 png_push_crc_finish(png_ptr);
destinyXfate 2:0e2ef1edf01b 1218
destinyXfate 2:0e2ef1edf01b 1219 key = png_ptr->current_text;
destinyXfate 2:0e2ef1edf01b 1220
destinyXfate 2:0e2ef1edf01b 1221 for (text = key; *text; text++)
destinyXfate 2:0e2ef1edf01b 1222 /* empty loop */ ;
destinyXfate 2:0e2ef1edf01b 1223
destinyXfate 2:0e2ef1edf01b 1224 /* zTXt can't have zero text */
destinyXfate 2:0e2ef1edf01b 1225 if (text == key + png_ptr->current_text_size)
destinyXfate 2:0e2ef1edf01b 1226 {
destinyXfate 2:0e2ef1edf01b 1227 png_ptr->current_text = NULL;
destinyXfate 2:0e2ef1edf01b 1228 png_free(png_ptr, key);
destinyXfate 2:0e2ef1edf01b 1229 return;
destinyXfate 2:0e2ef1edf01b 1230 }
destinyXfate 2:0e2ef1edf01b 1231
destinyXfate 2:0e2ef1edf01b 1232 text++;
destinyXfate 2:0e2ef1edf01b 1233
destinyXfate 2:0e2ef1edf01b 1234 if (*text != PNG_TEXT_COMPRESSION_zTXt) /* check compression byte */
destinyXfate 2:0e2ef1edf01b 1235 {
destinyXfate 2:0e2ef1edf01b 1236 png_ptr->current_text = NULL;
destinyXfate 2:0e2ef1edf01b 1237 png_free(png_ptr, key);
destinyXfate 2:0e2ef1edf01b 1238 return;
destinyXfate 2:0e2ef1edf01b 1239 }
destinyXfate 2:0e2ef1edf01b 1240
destinyXfate 2:0e2ef1edf01b 1241 text++;
destinyXfate 2:0e2ef1edf01b 1242
destinyXfate 2:0e2ef1edf01b 1243 png_ptr->zstream.next_in = (png_bytep )text;
destinyXfate 2:0e2ef1edf01b 1244 png_ptr->zstream.avail_in = (uInt)(png_ptr->current_text_size -
destinyXfate 2:0e2ef1edf01b 1245 (text - key));
destinyXfate 2:0e2ef1edf01b 1246 png_ptr->zstream.next_out = png_ptr->zbuf;
destinyXfate 2:0e2ef1edf01b 1247 png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
destinyXfate 2:0e2ef1edf01b 1248
destinyXfate 2:0e2ef1edf01b 1249 key_size = text - key;
destinyXfate 2:0e2ef1edf01b 1250 text_size = 0;
destinyXfate 2:0e2ef1edf01b 1251 text = NULL;
destinyXfate 2:0e2ef1edf01b 1252 ret = Z_STREAM_END;
destinyXfate 2:0e2ef1edf01b 1253
destinyXfate 2:0e2ef1edf01b 1254 while (png_ptr->zstream.avail_in)
destinyXfate 2:0e2ef1edf01b 1255 {
destinyXfate 2:0e2ef1edf01b 1256 ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);
destinyXfate 2:0e2ef1edf01b 1257 if (ret != Z_OK && ret != Z_STREAM_END)
destinyXfate 2:0e2ef1edf01b 1258 {
destinyXfate 2:0e2ef1edf01b 1259 inflateReset(&png_ptr->zstream);
destinyXfate 2:0e2ef1edf01b 1260 png_ptr->zstream.avail_in = 0;
destinyXfate 2:0e2ef1edf01b 1261 png_ptr->current_text = NULL;
destinyXfate 2:0e2ef1edf01b 1262 png_free(png_ptr, key);
destinyXfate 2:0e2ef1edf01b 1263 png_free(png_ptr, text);
destinyXfate 2:0e2ef1edf01b 1264 return;
destinyXfate 2:0e2ef1edf01b 1265 }
destinyXfate 2:0e2ef1edf01b 1266 if (!(png_ptr->zstream.avail_out) || ret == Z_STREAM_END)
destinyXfate 2:0e2ef1edf01b 1267 {
destinyXfate 2:0e2ef1edf01b 1268 if (text == NULL)
destinyXfate 2:0e2ef1edf01b 1269 {
destinyXfate 2:0e2ef1edf01b 1270 text = (png_charp)png_malloc(png_ptr,
destinyXfate 2:0e2ef1edf01b 1271 (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out
destinyXfate 2:0e2ef1edf01b 1272 + key_size + 1));
destinyXfate 2:0e2ef1edf01b 1273 png_memcpy(text + key_size, png_ptr->zbuf,
destinyXfate 2:0e2ef1edf01b 1274 png_ptr->zbuf_size - png_ptr->zstream.avail_out);
destinyXfate 2:0e2ef1edf01b 1275 png_memcpy(text, key, key_size);
destinyXfate 2:0e2ef1edf01b 1276 text_size = key_size + png_ptr->zbuf_size -
destinyXfate 2:0e2ef1edf01b 1277 png_ptr->zstream.avail_out;
destinyXfate 2:0e2ef1edf01b 1278 *(text + text_size) = '\0';
destinyXfate 2:0e2ef1edf01b 1279 }
destinyXfate 2:0e2ef1edf01b 1280 else
destinyXfate 2:0e2ef1edf01b 1281 {
destinyXfate 2:0e2ef1edf01b 1282 png_charp tmp;
destinyXfate 2:0e2ef1edf01b 1283
destinyXfate 2:0e2ef1edf01b 1284 tmp = text;
destinyXfate 2:0e2ef1edf01b 1285 text = (png_charp)png_malloc(png_ptr, text_size +
destinyXfate 2:0e2ef1edf01b 1286 (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out
destinyXfate 2:0e2ef1edf01b 1287 + 1));
destinyXfate 2:0e2ef1edf01b 1288 png_memcpy(text, tmp, text_size);
destinyXfate 2:0e2ef1edf01b 1289 png_free(png_ptr, tmp);
destinyXfate 2:0e2ef1edf01b 1290 png_memcpy(text + text_size, png_ptr->zbuf,
destinyXfate 2:0e2ef1edf01b 1291 png_ptr->zbuf_size - png_ptr->zstream.avail_out);
destinyXfate 2:0e2ef1edf01b 1292 text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out;
destinyXfate 2:0e2ef1edf01b 1293 *(text + text_size) = '\0';
destinyXfate 2:0e2ef1edf01b 1294 }
destinyXfate 2:0e2ef1edf01b 1295 if (ret != Z_STREAM_END)
destinyXfate 2:0e2ef1edf01b 1296 {
destinyXfate 2:0e2ef1edf01b 1297 png_ptr->zstream.next_out = png_ptr->zbuf;
destinyXfate 2:0e2ef1edf01b 1298 png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
destinyXfate 2:0e2ef1edf01b 1299 }
destinyXfate 2:0e2ef1edf01b 1300 }
destinyXfate 2:0e2ef1edf01b 1301 else
destinyXfate 2:0e2ef1edf01b 1302 {
destinyXfate 2:0e2ef1edf01b 1303 break;
destinyXfate 2:0e2ef1edf01b 1304 }
destinyXfate 2:0e2ef1edf01b 1305
destinyXfate 2:0e2ef1edf01b 1306 if (ret == Z_STREAM_END)
destinyXfate 2:0e2ef1edf01b 1307 break;
destinyXfate 2:0e2ef1edf01b 1308 }
destinyXfate 2:0e2ef1edf01b 1309
destinyXfate 2:0e2ef1edf01b 1310 inflateReset(&png_ptr->zstream);
destinyXfate 2:0e2ef1edf01b 1311 png_ptr->zstream.avail_in = 0;
destinyXfate 2:0e2ef1edf01b 1312
destinyXfate 2:0e2ef1edf01b 1313 if (ret != Z_STREAM_END)
destinyXfate 2:0e2ef1edf01b 1314 {
destinyXfate 2:0e2ef1edf01b 1315 png_ptr->current_text = NULL;
destinyXfate 2:0e2ef1edf01b 1316 png_free(png_ptr, key);
destinyXfate 2:0e2ef1edf01b 1317 png_free(png_ptr, text);
destinyXfate 2:0e2ef1edf01b 1318 return;
destinyXfate 2:0e2ef1edf01b 1319 }
destinyXfate 2:0e2ef1edf01b 1320
destinyXfate 2:0e2ef1edf01b 1321 png_ptr->current_text = NULL;
destinyXfate 2:0e2ef1edf01b 1322 png_free(png_ptr, key);
destinyXfate 2:0e2ef1edf01b 1323 key = text;
destinyXfate 2:0e2ef1edf01b 1324 text += key_size;
destinyXfate 2:0e2ef1edf01b 1325
destinyXfate 2:0e2ef1edf01b 1326 text_ptr = (png_textp)png_malloc(png_ptr,
destinyXfate 2:0e2ef1edf01b 1327 (png_uint_32)png_sizeof(png_text));
destinyXfate 2:0e2ef1edf01b 1328 text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt;
destinyXfate 2:0e2ef1edf01b 1329 text_ptr->key = key;
destinyXfate 2:0e2ef1edf01b 1330 #ifdef PNG_iTXt_SUPPORTED
destinyXfate 2:0e2ef1edf01b 1331 text_ptr->lang = NULL;
destinyXfate 2:0e2ef1edf01b 1332 text_ptr->lang_key = NULL;
destinyXfate 2:0e2ef1edf01b 1333 #endif
destinyXfate 2:0e2ef1edf01b 1334 text_ptr->text = text;
destinyXfate 2:0e2ef1edf01b 1335
destinyXfate 2:0e2ef1edf01b 1336 ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
destinyXfate 2:0e2ef1edf01b 1337
destinyXfate 2:0e2ef1edf01b 1338 png_free(png_ptr, key);
destinyXfate 2:0e2ef1edf01b 1339 png_free(png_ptr, text_ptr);
destinyXfate 2:0e2ef1edf01b 1340
destinyXfate 2:0e2ef1edf01b 1341 if (ret)
destinyXfate 2:0e2ef1edf01b 1342 png_warning(png_ptr, "Insufficient memory to store text chunk.");
destinyXfate 2:0e2ef1edf01b 1343 }
destinyXfate 2:0e2ef1edf01b 1344 }
destinyXfate 2:0e2ef1edf01b 1345 #endif
destinyXfate 2:0e2ef1edf01b 1346
destinyXfate 2:0e2ef1edf01b 1347 #if defined(PNG_READ_iTXt_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 1348 void /* PRIVATE */
destinyXfate 2:0e2ef1edf01b 1349 png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
destinyXfate 2:0e2ef1edf01b 1350 length)
destinyXfate 2:0e2ef1edf01b 1351 {
destinyXfate 2:0e2ef1edf01b 1352 if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
destinyXfate 2:0e2ef1edf01b 1353 {
destinyXfate 2:0e2ef1edf01b 1354 png_error(png_ptr, "Out of place iTXt");
destinyXfate 2:0e2ef1edf01b 1355 /* to quiet some compiler warnings */
destinyXfate 2:0e2ef1edf01b 1356 if(info_ptr == NULL) return;
destinyXfate 2:0e2ef1edf01b 1357 }
destinyXfate 2:0e2ef1edf01b 1358
destinyXfate 2:0e2ef1edf01b 1359 #ifdef PNG_MAX_MALLOC_64K
destinyXfate 2:0e2ef1edf01b 1360 png_ptr->skip_length = 0; /* This may not be necessary */
destinyXfate 2:0e2ef1edf01b 1361
destinyXfate 2:0e2ef1edf01b 1362 if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */
destinyXfate 2:0e2ef1edf01b 1363 {
destinyXfate 2:0e2ef1edf01b 1364 png_warning(png_ptr, "iTXt chunk too large to fit in memory");
destinyXfate 2:0e2ef1edf01b 1365 png_ptr->skip_length = length - (png_uint_32)65535L;
destinyXfate 2:0e2ef1edf01b 1366 length = (png_uint_32)65535L;
destinyXfate 2:0e2ef1edf01b 1367 }
destinyXfate 2:0e2ef1edf01b 1368 #endif
destinyXfate 2:0e2ef1edf01b 1369
destinyXfate 2:0e2ef1edf01b 1370 png_ptr->current_text = (png_charp)png_malloc(png_ptr,
destinyXfate 2:0e2ef1edf01b 1371 (png_uint_32)(length+1));
destinyXfate 2:0e2ef1edf01b 1372 png_ptr->current_text[length] = '\0';
destinyXfate 2:0e2ef1edf01b 1373 png_ptr->current_text_ptr = png_ptr->current_text;
destinyXfate 2:0e2ef1edf01b 1374 png_ptr->current_text_size = (png_size_t)length;
destinyXfate 2:0e2ef1edf01b 1375 png_ptr->current_text_left = (png_size_t)length;
destinyXfate 2:0e2ef1edf01b 1376 png_ptr->process_mode = PNG_READ_iTXt_MODE;
destinyXfate 2:0e2ef1edf01b 1377 }
destinyXfate 2:0e2ef1edf01b 1378
destinyXfate 2:0e2ef1edf01b 1379 void /* PRIVATE */
destinyXfate 2:0e2ef1edf01b 1380 png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
destinyXfate 2:0e2ef1edf01b 1381 {
destinyXfate 2:0e2ef1edf01b 1382
destinyXfate 2:0e2ef1edf01b 1383 if (png_ptr->buffer_size && png_ptr->current_text_left)
destinyXfate 2:0e2ef1edf01b 1384 {
destinyXfate 2:0e2ef1edf01b 1385 png_size_t text_size;
destinyXfate 2:0e2ef1edf01b 1386
destinyXfate 2:0e2ef1edf01b 1387 if (png_ptr->buffer_size < png_ptr->current_text_left)
destinyXfate 2:0e2ef1edf01b 1388 text_size = png_ptr->buffer_size;
destinyXfate 2:0e2ef1edf01b 1389 else
destinyXfate 2:0e2ef1edf01b 1390 text_size = png_ptr->current_text_left;
destinyXfate 2:0e2ef1edf01b 1391 png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size);
destinyXfate 2:0e2ef1edf01b 1392 png_ptr->current_text_left -= text_size;
destinyXfate 2:0e2ef1edf01b 1393 png_ptr->current_text_ptr += text_size;
destinyXfate 2:0e2ef1edf01b 1394 }
destinyXfate 2:0e2ef1edf01b 1395 if (!(png_ptr->current_text_left))
destinyXfate 2:0e2ef1edf01b 1396 {
destinyXfate 2:0e2ef1edf01b 1397 png_textp text_ptr;
destinyXfate 2:0e2ef1edf01b 1398 png_charp key;
destinyXfate 2:0e2ef1edf01b 1399 int comp_flag;
destinyXfate 2:0e2ef1edf01b 1400 png_charp lang;
destinyXfate 2:0e2ef1edf01b 1401 png_charp lang_key;
destinyXfate 2:0e2ef1edf01b 1402 png_charp text;
destinyXfate 2:0e2ef1edf01b 1403 int ret;
destinyXfate 2:0e2ef1edf01b 1404
destinyXfate 2:0e2ef1edf01b 1405 if (png_ptr->buffer_size < 4)
destinyXfate 2:0e2ef1edf01b 1406 {
destinyXfate 2:0e2ef1edf01b 1407 png_push_save_buffer(png_ptr);
destinyXfate 2:0e2ef1edf01b 1408 return;
destinyXfate 2:0e2ef1edf01b 1409 }
destinyXfate 2:0e2ef1edf01b 1410
destinyXfate 2:0e2ef1edf01b 1411 png_push_crc_finish(png_ptr);
destinyXfate 2:0e2ef1edf01b 1412
destinyXfate 2:0e2ef1edf01b 1413 #if defined(PNG_MAX_MALLOC_64K)
destinyXfate 2:0e2ef1edf01b 1414 if (png_ptr->skip_length)
destinyXfate 2:0e2ef1edf01b 1415 return;
destinyXfate 2:0e2ef1edf01b 1416 #endif
destinyXfate 2:0e2ef1edf01b 1417
destinyXfate 2:0e2ef1edf01b 1418 key = png_ptr->current_text;
destinyXfate 2:0e2ef1edf01b 1419
destinyXfate 2:0e2ef1edf01b 1420 for (lang = key; *lang; lang++)
destinyXfate 2:0e2ef1edf01b 1421 /* empty loop */ ;
destinyXfate 2:0e2ef1edf01b 1422
destinyXfate 2:0e2ef1edf01b 1423 if (lang != key + png_ptr->current_text_size)
destinyXfate 2:0e2ef1edf01b 1424 lang++;
destinyXfate 2:0e2ef1edf01b 1425
destinyXfate 2:0e2ef1edf01b 1426 comp_flag = *lang++;
destinyXfate 2:0e2ef1edf01b 1427 lang++; /* skip comp_type, always zero */
destinyXfate 2:0e2ef1edf01b 1428
destinyXfate 2:0e2ef1edf01b 1429 for (lang_key = lang; *lang_key; lang_key++)
destinyXfate 2:0e2ef1edf01b 1430 /* empty loop */ ;
destinyXfate 2:0e2ef1edf01b 1431 lang_key++; /* skip NUL separator */
destinyXfate 2:0e2ef1edf01b 1432
destinyXfate 2:0e2ef1edf01b 1433 for (text = lang_key; *text; text++)
destinyXfate 2:0e2ef1edf01b 1434 /* empty loop */ ;
destinyXfate 2:0e2ef1edf01b 1435
destinyXfate 2:0e2ef1edf01b 1436 if (text != key + png_ptr->current_text_size)
destinyXfate 2:0e2ef1edf01b 1437 text++;
destinyXfate 2:0e2ef1edf01b 1438
destinyXfate 2:0e2ef1edf01b 1439 text_ptr = (png_textp)png_malloc(png_ptr,
destinyXfate 2:0e2ef1edf01b 1440 (png_uint_32)png_sizeof(png_text));
destinyXfate 2:0e2ef1edf01b 1441 text_ptr->compression = comp_flag + 2;
destinyXfate 2:0e2ef1edf01b 1442 text_ptr->key = key;
destinyXfate 2:0e2ef1edf01b 1443 text_ptr->lang = lang;
destinyXfate 2:0e2ef1edf01b 1444 text_ptr->lang_key = lang_key;
destinyXfate 2:0e2ef1edf01b 1445 text_ptr->text = text;
destinyXfate 2:0e2ef1edf01b 1446 text_ptr->text_length = 0;
destinyXfate 2:0e2ef1edf01b 1447 text_ptr->itxt_length = png_strlen(text);
destinyXfate 2:0e2ef1edf01b 1448
destinyXfate 2:0e2ef1edf01b 1449 ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
destinyXfate 2:0e2ef1edf01b 1450
destinyXfate 2:0e2ef1edf01b 1451 png_ptr->current_text = NULL;
destinyXfate 2:0e2ef1edf01b 1452
destinyXfate 2:0e2ef1edf01b 1453 png_free(png_ptr, text_ptr);
destinyXfate 2:0e2ef1edf01b 1454 if (ret)
destinyXfate 2:0e2ef1edf01b 1455 png_warning(png_ptr, "Insufficient memory to store iTXt chunk.");
destinyXfate 2:0e2ef1edf01b 1456 }
destinyXfate 2:0e2ef1edf01b 1457 }
destinyXfate 2:0e2ef1edf01b 1458 #endif
destinyXfate 2:0e2ef1edf01b 1459
destinyXfate 2:0e2ef1edf01b 1460 /* This function is called when we haven't found a handler for this
destinyXfate 2:0e2ef1edf01b 1461 * chunk. If there isn't a problem with the chunk itself (ie a bad chunk
destinyXfate 2:0e2ef1edf01b 1462 * name or a critical chunk), the chunk is (currently) silently ignored.
destinyXfate 2:0e2ef1edf01b 1463 */
destinyXfate 2:0e2ef1edf01b 1464 void /* PRIVATE */
destinyXfate 2:0e2ef1edf01b 1465 png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32
destinyXfate 2:0e2ef1edf01b 1466 length)
destinyXfate 2:0e2ef1edf01b 1467 {
destinyXfate 2:0e2ef1edf01b 1468 png_uint_32 skip=0;
destinyXfate 2:0e2ef1edf01b 1469 png_check_chunk_name(png_ptr, png_ptr->chunk_name);
destinyXfate 2:0e2ef1edf01b 1470
destinyXfate 2:0e2ef1edf01b 1471 if (!(png_ptr->chunk_name[0] & 0x20))
destinyXfate 2:0e2ef1edf01b 1472 {
destinyXfate 2:0e2ef1edf01b 1473 #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 1474 if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
destinyXfate 2:0e2ef1edf01b 1475 PNG_HANDLE_CHUNK_ALWAYS
destinyXfate 2:0e2ef1edf01b 1476 #if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 1477 && png_ptr->read_user_chunk_fn == NULL
destinyXfate 2:0e2ef1edf01b 1478 #endif
destinyXfate 2:0e2ef1edf01b 1479 )
destinyXfate 2:0e2ef1edf01b 1480 #endif
destinyXfate 2:0e2ef1edf01b 1481 png_chunk_error(png_ptr, "unknown critical chunk");
destinyXfate 2:0e2ef1edf01b 1482
destinyXfate 2:0e2ef1edf01b 1483 /* to quiet compiler warnings about unused info_ptr */
destinyXfate 2:0e2ef1edf01b 1484 if (info_ptr == NULL)
destinyXfate 2:0e2ef1edf01b 1485 return;
destinyXfate 2:0e2ef1edf01b 1486 }
destinyXfate 2:0e2ef1edf01b 1487
destinyXfate 2:0e2ef1edf01b 1488 #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 1489 if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS)
destinyXfate 2:0e2ef1edf01b 1490 {
destinyXfate 2:0e2ef1edf01b 1491 png_unknown_chunk chunk;
destinyXfate 2:0e2ef1edf01b 1492
destinyXfate 2:0e2ef1edf01b 1493 #ifdef PNG_MAX_MALLOC_64K
destinyXfate 2:0e2ef1edf01b 1494 if (length > (png_uint_32)65535L)
destinyXfate 2:0e2ef1edf01b 1495 {
destinyXfate 2:0e2ef1edf01b 1496 png_warning(png_ptr, "unknown chunk too large to fit in memory");
destinyXfate 2:0e2ef1edf01b 1497 skip = length - (png_uint_32)65535L;
destinyXfate 2:0e2ef1edf01b 1498 length = (png_uint_32)65535L;
destinyXfate 2:0e2ef1edf01b 1499 }
destinyXfate 2:0e2ef1edf01b 1500 #endif
destinyXfate 2:0e2ef1edf01b 1501
destinyXfate 2:0e2ef1edf01b 1502 png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name);
destinyXfate 2:0e2ef1edf01b 1503 chunk.data = (png_bytep)png_malloc(png_ptr, length);
destinyXfate 2:0e2ef1edf01b 1504 png_crc_read(png_ptr, chunk.data, length);
destinyXfate 2:0e2ef1edf01b 1505 chunk.size = length;
destinyXfate 2:0e2ef1edf01b 1506 #if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
destinyXfate 2:0e2ef1edf01b 1507 if(png_ptr->read_user_chunk_fn != NULL)
destinyXfate 2:0e2ef1edf01b 1508 {
destinyXfate 2:0e2ef1edf01b 1509 /* callback to user unknown chunk handler */
destinyXfate 2:0e2ef1edf01b 1510 if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0)
destinyXfate 2:0e2ef1edf01b 1511 {
destinyXfate 2:0e2ef1edf01b 1512 if (!(png_ptr->chunk_name[0] & 0x20))
destinyXfate 2:0e2ef1edf01b 1513 if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
destinyXfate 2:0e2ef1edf01b 1514 PNG_HANDLE_CHUNK_ALWAYS)
destinyXfate 2:0e2ef1edf01b 1515 png_chunk_error(png_ptr, "unknown critical chunk");
destinyXfate 2:0e2ef1edf01b 1516 }
destinyXfate 2:0e2ef1edf01b 1517 png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
destinyXfate 2:0e2ef1edf01b 1518 }
destinyXfate 2:0e2ef1edf01b 1519 else
destinyXfate 2:0e2ef1edf01b 1520 #endif
destinyXfate 2:0e2ef1edf01b 1521 png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
destinyXfate 2:0e2ef1edf01b 1522 png_free(png_ptr, chunk.data);
destinyXfate 2:0e2ef1edf01b 1523 }
destinyXfate 2:0e2ef1edf01b 1524 else
destinyXfate 2:0e2ef1edf01b 1525 #endif
destinyXfate 2:0e2ef1edf01b 1526 skip=length;
destinyXfate 2:0e2ef1edf01b 1527 png_push_crc_skip(png_ptr, skip);
destinyXfate 2:0e2ef1edf01b 1528 }
destinyXfate 2:0e2ef1edf01b 1529
destinyXfate 2:0e2ef1edf01b 1530 void /* PRIVATE */
destinyXfate 2:0e2ef1edf01b 1531 png_push_have_info(png_structp png_ptr, png_infop info_ptr)
destinyXfate 2:0e2ef1edf01b 1532 {
destinyXfate 2:0e2ef1edf01b 1533 if (png_ptr->info_fn != NULL)
destinyXfate 2:0e2ef1edf01b 1534 (*(png_ptr->info_fn))(png_ptr, info_ptr);
destinyXfate 2:0e2ef1edf01b 1535 }
destinyXfate 2:0e2ef1edf01b 1536
destinyXfate 2:0e2ef1edf01b 1537 void /* PRIVATE */
destinyXfate 2:0e2ef1edf01b 1538 png_push_have_end(png_structp png_ptr, png_infop info_ptr)
destinyXfate 2:0e2ef1edf01b 1539 {
destinyXfate 2:0e2ef1edf01b 1540 if (png_ptr->end_fn != NULL)
destinyXfate 2:0e2ef1edf01b 1541 (*(png_ptr->end_fn))(png_ptr, info_ptr);
destinyXfate 2:0e2ef1edf01b 1542 }
destinyXfate 2:0e2ef1edf01b 1543
destinyXfate 2:0e2ef1edf01b 1544 void /* PRIVATE */
destinyXfate 2:0e2ef1edf01b 1545 png_push_have_row(png_structp png_ptr, png_bytep row)
destinyXfate 2:0e2ef1edf01b 1546 {
destinyXfate 2:0e2ef1edf01b 1547 if (png_ptr->row_fn != NULL)
destinyXfate 2:0e2ef1edf01b 1548 (*(png_ptr->row_fn))(png_ptr, row, png_ptr->row_number,
destinyXfate 2:0e2ef1edf01b 1549 (int)png_ptr->pass);
destinyXfate 2:0e2ef1edf01b 1550 }
destinyXfate 2:0e2ef1edf01b 1551
destinyXfate 2:0e2ef1edf01b 1552 void PNGAPI
destinyXfate 2:0e2ef1edf01b 1553 png_progressive_combine_row (png_structp png_ptr,
destinyXfate 2:0e2ef1edf01b 1554 png_bytep old_row, png_bytep new_row)
destinyXfate 2:0e2ef1edf01b 1555 {
destinyXfate 2:0e2ef1edf01b 1556 if(png_ptr == NULL) return;
destinyXfate 2:0e2ef1edf01b 1557 #ifdef PNG_USE_LOCAL_ARRAYS
destinyXfate 2:0e2ef1edf01b 1558 const int FARDATA png_pass_dsp_mask[7] =
destinyXfate 2:0e2ef1edf01b 1559 {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
destinyXfate 2:0e2ef1edf01b 1560 #endif
destinyXfate 2:0e2ef1edf01b 1561 if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */
destinyXfate 2:0e2ef1edf01b 1562 png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]);
destinyXfate 2:0e2ef1edf01b 1563 }
destinyXfate 2:0e2ef1edf01b 1564
destinyXfate 2:0e2ef1edf01b 1565 void PNGAPI
destinyXfate 2:0e2ef1edf01b 1566 png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr,
destinyXfate 2:0e2ef1edf01b 1567 png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
destinyXfate 2:0e2ef1edf01b 1568 png_progressive_end_ptr end_fn)
destinyXfate 2:0e2ef1edf01b 1569 {
destinyXfate 2:0e2ef1edf01b 1570 if(png_ptr == NULL) return;
destinyXfate 2:0e2ef1edf01b 1571 png_ptr->info_fn = info_fn;
destinyXfate 2:0e2ef1edf01b 1572 png_ptr->row_fn = row_fn;
destinyXfate 2:0e2ef1edf01b 1573 png_ptr->end_fn = end_fn;
destinyXfate 2:0e2ef1edf01b 1574
destinyXfate 2:0e2ef1edf01b 1575 png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer);
destinyXfate 2:0e2ef1edf01b 1576 }
destinyXfate 2:0e2ef1edf01b 1577
destinyXfate 2:0e2ef1edf01b 1578 png_voidp PNGAPI
destinyXfate 2:0e2ef1edf01b 1579 png_get_progressive_ptr(png_structp png_ptr)
destinyXfate 2:0e2ef1edf01b 1580 {
destinyXfate 2:0e2ef1edf01b 1581 if(png_ptr == NULL) return (NULL);
destinyXfate 2:0e2ef1edf01b 1582 return png_ptr->io_ptr;
destinyXfate 2:0e2ef1edf01b 1583 }
destinyXfate 2:0e2ef1edf01b 1584 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
destinyXfate 2:0e2ef1edf01b 1585