| OLD | NEW |
| 1 | 1 |
| 2 /* pngset.c - storage of image information into info struct | 2 /* pngset.c - storage of image information into info struct |
| 3 * | 3 * |
| 4 * Last changed in libpng 1.2.27 [April 29, 2008] | 4 * Last changed in libpng 1.2.30 [August 15, 2008] |
| 5 * For conditions of distribution and use, see copyright notice in png.h | 5 * For conditions of distribution and use, see copyright notice in png.h |
| 6 * Copyright (c) 1998-2008 Glenn Randers-Pehrson | 6 * Copyright (c) 1998-2008 Glenn Randers-Pehrson |
| 7 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) | 7 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) |
| 8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) | 8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) |
| 9 * | 9 * |
| 10 * The functions here are used during reads to store data from the file | 10 * The functions here are used during reads to store data from the file |
| 11 * into the info struct, and during writes to store application data | 11 * into the info struct, and during writes to store application data |
| 12 * into the info struct for writing into the file. This abstracts the | 12 * into the info struct for writing into the file. This abstracts the |
| 13 * info struct and allows us to change the structure in the future. | 13 * info struct and allows us to change the structure in the future. |
| 14 */ | 14 */ |
| 15 | 15 |
| 16 #define PNG_INTERNAL | 16 #define PNG_INTERNAL |
| 17 #include "png.h" | 17 #include "png.h" |
| 18 | |
| 19 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) | 18 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) |
| 20 | 19 |
| 21 #if defined(PNG_bKGD_SUPPORTED) | 20 #if defined(PNG_bKGD_SUPPORTED) |
| 22 void PNGAPI | 21 void PNGAPI |
| 23 png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background) | 22 png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background) |
| 24 { | 23 { |
| 25 png_debug1(1, "in %s storage function\n", "bKGD"); | 24 png_debug1(1, "in %s storage function\n", "bKGD"); |
| 26 if (png_ptr == NULL || info_ptr == NULL) | 25 if (png_ptr == NULL || info_ptr == NULL) |
| 27 return; | 26 return; |
| 28 | 27 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 if (png_ptr == NULL || info_ptr == NULL) | 160 if (png_ptr == NULL || info_ptr == NULL) |
| 162 return; | 161 return; |
| 163 | 162 |
| 164 /* Check for overflow */ | 163 /* Check for overflow */ |
| 165 if (file_gamma > 21474.83) | 164 if (file_gamma > 21474.83) |
| 166 { | 165 { |
| 167 png_warning(png_ptr, "Limiting gamma to 21474.83"); | 166 png_warning(png_ptr, "Limiting gamma to 21474.83"); |
| 168 gamma=21474.83; | 167 gamma=21474.83; |
| 169 } | 168 } |
| 170 else | 169 else |
| 171 gamma=file_gamma; | 170 gamma = file_gamma; |
| 172 info_ptr->gamma = (float)gamma; | 171 info_ptr->gamma = (float)gamma; |
| 173 #ifdef PNG_FIXED_POINT_SUPPORTED | 172 #ifdef PNG_FIXED_POINT_SUPPORTED |
| 174 info_ptr->int_gamma = (int)(gamma*100000.+.5); | 173 info_ptr->int_gamma = (int)(gamma*100000.+.5); |
| 175 #endif | 174 #endif |
| 176 info_ptr->valid |= PNG_INFO_gAMA; | 175 info_ptr->valid |= PNG_INFO_gAMA; |
| 177 if(gamma == 0.0) | 176 if (gamma == 0.0) |
| 178 png_warning(png_ptr, "Setting gamma=0"); | 177 png_warning(png_ptr, "Setting gamma=0"); |
| 179 } | 178 } |
| 180 #endif | 179 #endif |
| 181 void PNGAPI | 180 void PNGAPI |
| 182 png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point | 181 png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point |
| 183 int_gamma) | 182 int_gamma) |
| 184 { | 183 { |
| 185 png_fixed_point gamma; | 184 png_fixed_point gamma; |
| 186 | 185 |
| 187 png_debug1(1, "in %s storage function\n", "gAMA"); | 186 png_debug1(1, "in %s storage function\n", "gAMA"); |
| 188 if (png_ptr == NULL || info_ptr == NULL) | 187 if (png_ptr == NULL || info_ptr == NULL) |
| 189 return; | 188 return; |
| 190 | 189 |
| 191 if (int_gamma > (png_fixed_point) PNG_UINT_31_MAX) | 190 if (int_gamma > (png_fixed_point) PNG_UINT_31_MAX) |
| 192 { | 191 { |
| 193 png_warning(png_ptr, "Limiting gamma to 21474.83"); | 192 png_warning(png_ptr, "Limiting gamma to 21474.83"); |
| 194 gamma=PNG_UINT_31_MAX; | 193 gamma=PNG_UINT_31_MAX; |
| 195 } | 194 } |
| 196 else | 195 else |
| 197 { | 196 { |
| 198 if (int_gamma < 0) | 197 if (int_gamma < 0) |
| 199 { | 198 { |
| 200 png_warning(png_ptr, "Setting negative gamma to zero"); | 199 png_warning(png_ptr, "Setting negative gamma to zero"); |
| 201 gamma=0; | 200 gamma = 0; |
| 202 } | 201 } |
| 203 else | 202 else |
| 204 gamma=int_gamma; | 203 gamma = int_gamma; |
| 205 } | 204 } |
| 206 #ifdef PNG_FLOATING_POINT_SUPPORTED | 205 #ifdef PNG_FLOATING_POINT_SUPPORTED |
| 207 info_ptr->gamma = (float)(gamma/100000.); | 206 info_ptr->gamma = (float)(gamma/100000.); |
| 208 #endif | 207 #endif |
| 209 #ifdef PNG_FIXED_POINT_SUPPORTED | 208 #ifdef PNG_FIXED_POINT_SUPPORTED |
| 210 info_ptr->int_gamma = gamma; | 209 info_ptr->int_gamma = gamma; |
| 211 #endif | 210 #endif |
| 212 info_ptr->valid |= PNG_INFO_gAMA; | 211 info_ptr->valid |= PNG_INFO_gAMA; |
| 213 if(gamma == 0) | 212 if (gamma == 0) |
| 214 png_warning(png_ptr, "Setting gamma=0"); | 213 png_warning(png_ptr, "Setting gamma=0"); |
| 215 } | 214 } |
| 216 #endif | 215 #endif |
| 217 | 216 |
| 218 #if defined(PNG_hIST_SUPPORTED) | 217 #if defined(PNG_hIST_SUPPORTED) |
| 219 void PNGAPI | 218 void PNGAPI |
| 220 png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist) | 219 png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist) |
| 221 { | 220 { |
| 222 int i; | 221 int i; |
| 223 | 222 |
| 224 png_debug1(1, "in %s storage function\n", "hIST"); | 223 png_debug1(1, "in %s storage function\n", "hIST"); |
| 225 if (png_ptr == NULL || info_ptr == NULL) | 224 if (png_ptr == NULL || info_ptr == NULL) |
| 226 return; | 225 return; |
| 227 if (info_ptr->num_palette == 0 || info_ptr->num_palette | 226 if (info_ptr->num_palette == 0 || info_ptr->num_palette |
| 228 > PNG_MAX_PALETTE_LENGTH) | 227 > PNG_MAX_PALETTE_LENGTH) |
| 229 { | 228 { |
| 230 png_warning(png_ptr, | 229 png_warning(png_ptr, |
| 231 "Invalid palette size, hIST allocation skipped."); | 230 "Invalid palette size, hIST allocation skipped."); |
| 232 return; | 231 return; |
| 233 } | 232 } |
| 234 | 233 |
| 235 #ifdef PNG_FREE_ME_SUPPORTED | 234 #ifdef PNG_FREE_ME_SUPPORTED |
| 236 png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0); | 235 png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0); |
| 237 #endif | 236 #endif |
| 238 /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in version | 237 /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in version |
| 239 1.2.1 */ | 238 1.2.1 */ |
| 240 png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr, | 239 png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr, |
| 241 (png_uint_32)(PNG_MAX_PALETTE_LENGTH * png_sizeof (png_uint_16))); | 240 (png_uint_32)(PNG_MAX_PALETTE_LENGTH * png_sizeof(png_uint_16))); |
| 242 if (png_ptr->hist == NULL) | 241 if (png_ptr->hist == NULL) |
| 243 { | 242 { |
| 244 png_warning(png_ptr, "Insufficient memory for hIST chunk data."); | 243 png_warning(png_ptr, "Insufficient memory for hIST chunk data."); |
| 245 return; | 244 return; |
| 246 } | 245 } |
| 247 | 246 |
| 248 for (i = 0; i < info_ptr->num_palette; i++) | 247 for (i = 0; i < info_ptr->num_palette; i++) |
| 249 png_ptr->hist[i] = hist[i]; | 248 png_ptr->hist[i] = hist[i]; |
| 250 info_ptr->hist = png_ptr->hist; | 249 info_ptr->hist = png_ptr->hist; |
| 251 info_ptr->valid |= PNG_INFO_hIST; | 250 info_ptr->valid |= PNG_INFO_hIST; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 #if defined(PNG_MNG_FEATURES_SUPPORTED) | 311 #if defined(PNG_MNG_FEATURES_SUPPORTED) |
| 313 /* Accept filter_method 64 (intrapixel differencing) only if | 312 /* Accept filter_method 64 (intrapixel differencing) only if |
| 314 * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and | 313 * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and |
| 315 * 2. Libpng did not read a PNG signature (this filter_method is only | 314 * 2. Libpng did not read a PNG signature (this filter_method is only |
| 316 * used in PNG datastreams that are embedded in MNG datastreams) and | 315 * used in PNG datastreams that are embedded in MNG datastreams) and |
| 317 * 3. The application called png_permit_mng_features with a mask that | 316 * 3. The application called png_permit_mng_features with a mask that |
| 318 * included PNG_FLAG_MNG_FILTER_64 and | 317 * included PNG_FLAG_MNG_FILTER_64 and |
| 319 * 4. The filter_method is 64 and | 318 * 4. The filter_method is 64 and |
| 320 * 5. The color_type is RGB or RGBA | 319 * 5. The color_type is RGB or RGBA |
| 321 */ | 320 */ |
| 322 if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted) | 321 if ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted) |
| 323 png_warning(png_ptr,"MNG features are not allowed in a PNG datastream"); | 322 png_warning(png_ptr, "MNG features are not allowed in a PNG datastream"); |
| 324 if(filter_type != PNG_FILTER_TYPE_BASE) | 323 if (filter_type != PNG_FILTER_TYPE_BASE) |
| 325 { | 324 { |
| 326 if(!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && | 325 if (!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && |
| 327 (filter_type == PNG_INTRAPIXEL_DIFFERENCING) && | 326 (filter_type == PNG_INTRAPIXEL_DIFFERENCING) && |
| 328 ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && | 327 ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && |
| 329 (color_type == PNG_COLOR_TYPE_RGB || | 328 (color_type == PNG_COLOR_TYPE_RGB || |
| 330 color_type == PNG_COLOR_TYPE_RGB_ALPHA))) | 329 color_type == PNG_COLOR_TYPE_RGB_ALPHA))) |
| 331 png_error(png_ptr, "Unknown filter method in IHDR"); | 330 png_error(png_ptr, "Unknown filter method in IHDR"); |
| 332 if(png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) | 331 if (png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) |
| 333 png_warning(png_ptr, "Invalid filter method in IHDR"); | 332 png_warning(png_ptr, "Invalid filter method in IHDR"); |
| 334 } | 333 } |
| 335 #else | 334 #else |
| 336 if(filter_type != PNG_FILTER_TYPE_BASE) | 335 if (filter_type != PNG_FILTER_TYPE_BASE) |
| 337 png_error(png_ptr, "Unknown filter method in IHDR"); | 336 png_error(png_ptr, "Unknown filter method in IHDR"); |
| 338 #endif | 337 #endif |
| 339 | 338 |
| 340 info_ptr->width = width; | 339 info_ptr->width = width; |
| 341 info_ptr->height = height; | 340 info_ptr->height = height; |
| 342 info_ptr->bit_depth = (png_byte)bit_depth; | 341 info_ptr->bit_depth = (png_byte)bit_depth; |
| 343 info_ptr->color_type =(png_byte) color_type; | 342 info_ptr->color_type =(png_byte) color_type; |
| 344 info_ptr->compression_type = (png_byte)compression_type; | 343 info_ptr->compression_type = (png_byte)compression_type; |
| 345 info_ptr->filter_type = (png_byte)filter_type; | 344 info_ptr->filter_type = (png_byte)filter_type; |
| 346 info_ptr->interlace_type = (png_byte)interlace_type; | 345 info_ptr->interlace_type = (png_byte)interlace_type; |
| 347 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) | 346 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) |
| 348 info_ptr->channels = 1; | 347 info_ptr->channels = 1; |
| 349 else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) | 348 else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) |
| 350 info_ptr->channels = 3; | 349 info_ptr->channels = 3; |
| 351 else | 350 else |
| 352 info_ptr->channels = 1; | 351 info_ptr->channels = 1; |
| 353 if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) | 352 if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) |
| 354 info_ptr->channels++; | 353 info_ptr->channels++; |
| 355 info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth); | 354 info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth); |
| 356 | 355 |
| 357 /* check for potential overflow */ | 356 /* check for potential overflow */ |
| 358 if (width > (PNG_UINT_32_MAX | 357 if (width > (PNG_UINT_32_MAX |
| 359 >> 3) /* 8-byte RGBA pixels */ | 358 >> 3) /* 8-byte RGBA pixels */ |
| 360 - 64 /* bigrowbuf hack */ | 359 - 64 /* bigrowbuf hack */ |
| 361 - 1 /* filter byte */ | 360 - 1 /* filter byte */ |
| 362 - 7*8 /* rounding of width to multiple of 8 pixels */ | 361 - 7*8 /* rounding of width to multiple of 8 pixels */ |
| 363 - 8) /* extra max_pixel_depth pad */ | 362 - 8) /* extra max_pixel_depth pad */ |
| 364 info_ptr->rowbytes = (png_size_t)0; | 363 info_ptr->rowbytes = (png_size_t)0; |
| 365 else | 364 else |
| 366 info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,width); | 365 info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width); |
| 367 } | 366 } |
| 368 | 367 |
| 369 #if defined(PNG_oFFs_SUPPORTED) | 368 #if defined(PNG_oFFs_SUPPORTED) |
| 370 void PNGAPI | 369 void PNGAPI |
| 371 png_set_oFFs(png_structp png_ptr, png_infop info_ptr, | 370 png_set_oFFs(png_structp png_ptr, png_infop info_ptr, |
| 372 png_int_32 offset_x, png_int_32 offset_y, int unit_type) | 371 png_int_32 offset_x, png_int_32 offset_y, int unit_type) |
| 373 { | 372 { |
| 374 png_debug1(1, "in %s storage function\n", "oFFs"); | 373 png_debug1(1, "in %s storage function\n", "oFFs"); |
| 375 if (png_ptr == NULL || info_ptr == NULL) | 374 if (png_ptr == NULL || info_ptr == NULL) |
| 376 return; | 375 return; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 389 png_charp units, png_charpp params) | 388 png_charp units, png_charpp params) |
| 390 { | 389 { |
| 391 png_uint_32 length; | 390 png_uint_32 length; |
| 392 int i; | 391 int i; |
| 393 | 392 |
| 394 png_debug1(1, "in %s storage function\n", "pCAL"); | 393 png_debug1(1, "in %s storage function\n", "pCAL"); |
| 395 if (png_ptr == NULL || info_ptr == NULL) | 394 if (png_ptr == NULL || info_ptr == NULL) |
| 396 return; | 395 return; |
| 397 | 396 |
| 398 length = png_strlen(purpose) + 1; | 397 length = png_strlen(purpose) + 1; |
| 399 png_debug1(3, "allocating purpose for info (%lu bytes)\n", length); | 398 png_debug1(3, "allocating purpose for info (%lu bytes)\n", |
| 399 (unsigned long)length); |
| 400 info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length); | 400 info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length); |
| 401 if (info_ptr->pcal_purpose == NULL) | 401 if (info_ptr->pcal_purpose == NULL) |
| 402 { | 402 { |
| 403 png_warning(png_ptr, "Insufficient memory for pCAL purpose."); | 403 png_warning(png_ptr, "Insufficient memory for pCAL purpose."); |
| 404 return; | 404 return; |
| 405 } | 405 } |
| 406 png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length); | 406 png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length); |
| 407 | 407 |
| 408 png_debug(3, "storing X0, X1, type, and nparams in info\n"); | 408 png_debug(3, "storing X0, X1, type, and nparams in info\n"); |
| 409 info_ptr->pcal_X0 = X0; | 409 info_ptr->pcal_X0 = X0; |
| 410 info_ptr->pcal_X1 = X1; | 410 info_ptr->pcal_X1 = X1; |
| 411 info_ptr->pcal_type = (png_byte)type; | 411 info_ptr->pcal_type = (png_byte)type; |
| 412 info_ptr->pcal_nparams = (png_byte)nparams; | 412 info_ptr->pcal_nparams = (png_byte)nparams; |
| 413 | 413 |
| 414 length = png_strlen(units) + 1; | 414 length = png_strlen(units) + 1; |
| 415 png_debug1(3, "allocating units for info (%lu bytes)\n", length); | 415 png_debug1(3, "allocating units for info (%lu bytes)\n", |
| 416 (unsigned long)length); |
| 416 info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length); | 417 info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length); |
| 417 if (info_ptr->pcal_units == NULL) | 418 if (info_ptr->pcal_units == NULL) |
| 418 { | 419 { |
| 419 png_warning(png_ptr, "Insufficient memory for pCAL units."); | 420 png_warning(png_ptr, "Insufficient memory for pCAL units."); |
| 420 return; | 421 return; |
| 421 } | 422 } |
| 422 png_memcpy(info_ptr->pcal_units, units, (png_size_t)length); | 423 png_memcpy(info_ptr->pcal_units, units, (png_size_t)length); |
| 423 | 424 |
| 424 info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr, | 425 info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr, |
| 425 (png_uint_32)((nparams + 1) * png_sizeof(png_charp))); | 426 (png_uint_32)((nparams + 1) * png_sizeof(png_charp))); |
| 426 if (info_ptr->pcal_params == NULL) | 427 if (info_ptr->pcal_params == NULL) |
| 427 { | 428 { |
| 428 png_warning(png_ptr, "Insufficient memory for pCAL params."); | 429 png_warning(png_ptr, "Insufficient memory for pCAL params."); |
| 429 return; | 430 return; |
| 430 } | 431 } |
| 431 | 432 |
| 432 info_ptr->pcal_params[nparams] = NULL; | 433 info_ptr->pcal_params[nparams] = NULL; |
| 433 | 434 |
| 434 for (i = 0; i < nparams; i++) | 435 for (i = 0; i < nparams; i++) |
| 435 { | 436 { |
| 436 length = png_strlen(params[i]) + 1; | 437 length = png_strlen(params[i]) + 1; |
| 437 png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i, length)
; | 438 png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i, |
| 439 (unsigned long)length); |
| 438 info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length); | 440 info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length); |
| 439 if (info_ptr->pcal_params[i] == NULL) | 441 if (info_ptr->pcal_params[i] == NULL) |
| 440 { | 442 { |
| 441 png_warning(png_ptr, "Insufficient memory for pCAL parameter."); | 443 png_warning(png_ptr, "Insufficient memory for pCAL parameter."); |
| 442 return; | 444 return; |
| 443 } | 445 } |
| 444 png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length); | 446 png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length); |
| 445 } | 447 } |
| 446 | 448 |
| 447 info_ptr->valid |= PNG_INFO_pCAL; | 449 info_ptr->valid |= PNG_INFO_pCAL; |
| 448 #ifdef PNG_FREE_ME_SUPPORTED | 450 #ifdef PNG_FREE_ME_SUPPORTED |
| 449 info_ptr->free_me |= PNG_FREE_PCAL; | 451 info_ptr->free_me |= PNG_FREE_PCAL; |
| 450 #endif | 452 #endif |
| 451 } | 453 } |
| 452 #endif | 454 #endif |
| 453 | 455 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 475 { | 477 { |
| 476 png_uint_32 length; | 478 png_uint_32 length; |
| 477 | 479 |
| 478 png_debug1(1, "in %s storage function\n", "sCAL"); | 480 png_debug1(1, "in %s storage function\n", "sCAL"); |
| 479 if (png_ptr == NULL || info_ptr == NULL) | 481 if (png_ptr == NULL || info_ptr == NULL) |
| 480 return; | 482 return; |
| 481 | 483 |
| 482 info_ptr->scal_unit = (png_byte)unit; | 484 info_ptr->scal_unit = (png_byte)unit; |
| 483 | 485 |
| 484 length = png_strlen(swidth) + 1; | 486 length = png_strlen(swidth) + 1; |
| 485 png_debug1(3, "allocating unit for info (%d bytes)\n", length); | 487 png_debug1(3, "allocating unit for info (%u bytes)\n", |
| 488 (unsigned int)length); |
| 486 info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length); | 489 info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length); |
| 487 if (info_ptr->scal_s_width == NULL) | 490 if (info_ptr->scal_s_width == NULL) |
| 488 { | 491 { |
| 489 png_warning(png_ptr, | 492 png_warning(png_ptr, |
| 490 "Memory allocation failed while processing sCAL."); | 493 "Memory allocation failed while processing sCAL."); |
| 491 return; | 494 return; |
| 492 } | 495 } |
| 493 png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length); | 496 png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length); |
| 494 | 497 |
| 495 length = png_strlen(sheight) + 1; | 498 length = png_strlen(sheight) + 1; |
| 496 png_debug1(3, "allocating unit for info (%d bytes)\n", length); | 499 png_debug1(3, "allocating unit for info (%u bytes)\n", |
| 500 (unsigned int)length); |
| 497 info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, length); | 501 info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, length); |
| 498 if (info_ptr->scal_s_height == NULL) | 502 if (info_ptr->scal_s_height == NULL) |
| 499 { | 503 { |
| 500 png_free (png_ptr, info_ptr->scal_s_width); | 504 png_free (png_ptr, info_ptr->scal_s_width); |
| 505 info_ptr->scal_s_width = NULL; |
| 501 png_warning(png_ptr, | 506 png_warning(png_ptr, |
| 502 "Memory allocation failed while processing sCAL."); | 507 "Memory allocation failed while processing sCAL."); |
| 503 return; | 508 return; |
| 504 } | 509 } |
| 505 png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length); | 510 png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length); |
| 506 info_ptr->valid |= PNG_INFO_sCAL; | 511 info_ptr->valid |= PNG_INFO_sCAL; |
| 507 #ifdef PNG_FREE_ME_SUPPORTED | 512 #ifdef PNG_FREE_ME_SUPPORTED |
| 508 info_ptr->free_me |= PNG_FREE_SCAL; | 513 info_ptr->free_me |= PNG_FREE_SCAL; |
| 509 #endif | 514 #endif |
| 510 } | 515 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0); | 562 png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0); |
| 558 #endif | 563 #endif |
| 559 | 564 |
| 560 /* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead | 565 /* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead |
| 561 of num_palette entries, | 566 of num_palette entries, |
| 562 in case of an invalid PNG file that has too-large sample values. */ | 567 in case of an invalid PNG file that has too-large sample values. */ |
| 563 png_ptr->palette = (png_colorp)png_malloc(png_ptr, | 568 png_ptr->palette = (png_colorp)png_malloc(png_ptr, |
| 564 PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color)); | 569 PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color)); |
| 565 png_memset(png_ptr->palette, 0, PNG_MAX_PALETTE_LENGTH * | 570 png_memset(png_ptr->palette, 0, PNG_MAX_PALETTE_LENGTH * |
| 566 png_sizeof(png_color)); | 571 png_sizeof(png_color)); |
| 567 png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof (png_color)); | 572 png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof(png_color)); |
| 568 info_ptr->palette = png_ptr->palette; | 573 info_ptr->palette = png_ptr->palette; |
| 569 info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; | 574 info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; |
| 570 | 575 |
| 571 #ifdef PNG_FREE_ME_SUPPORTED | 576 #ifdef PNG_FREE_ME_SUPPORTED |
| 572 info_ptr->free_me |= PNG_FREE_PLTE; | 577 info_ptr->free_me |= PNG_FREE_PLTE; |
| 573 #else | 578 #else |
| 574 png_ptr->flags |= PNG_FLAG_FREE_PLTE; | 579 png_ptr->flags |= PNG_FLAG_FREE_PLTE; |
| 575 #endif | 580 #endif |
| 576 | 581 |
| 577 info_ptr->valid |= PNG_INFO_PLTE; | 582 info_ptr->valid |= PNG_INFO_PLTE; |
| 578 } | 583 } |
| 579 | 584 |
| 580 #if defined(PNG_sBIT_SUPPORTED) | 585 #if defined(PNG_sBIT_SUPPORTED) |
| 581 void PNGAPI | 586 void PNGAPI |
| 582 png_set_sBIT(png_structp png_ptr, png_infop info_ptr, | 587 png_set_sBIT(png_structp png_ptr, png_infop info_ptr, |
| 583 png_color_8p sig_bit) | 588 png_color_8p sig_bit) |
| 584 { | 589 { |
| 585 png_debug1(1, "in %s storage function\n", "sBIT"); | 590 png_debug1(1, "in %s storage function\n", "sBIT"); |
| 586 if (png_ptr == NULL || info_ptr == NULL) | 591 if (png_ptr == NULL || info_ptr == NULL) |
| 587 return; | 592 return; |
| 588 | 593 |
| 589 png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof (png_color_8)); | 594 png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof(png_color_8)); |
| 590 info_ptr->valid |= PNG_INFO_sBIT; | 595 info_ptr->valid |= PNG_INFO_sBIT; |
| 591 } | 596 } |
| 592 #endif | 597 #endif |
| 593 | 598 |
| 594 #if defined(PNG_sRGB_SUPPORTED) | 599 #if defined(PNG_sRGB_SUPPORTED) |
| 595 void PNGAPI | 600 void PNGAPI |
| 596 png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent) | 601 png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent) |
| 597 { | 602 { |
| 598 png_debug1(1, "in %s storage function\n", "sRGB"); | 603 png_debug1(1, "in %s storage function\n", "sRGB"); |
| 599 if (png_ptr == NULL || info_ptr == NULL) | 604 if (png_ptr == NULL || info_ptr == NULL) |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 if (new_iccp_name == NULL) | 698 if (new_iccp_name == NULL) |
| 694 { | 699 { |
| 695 png_warning(png_ptr, "Insufficient memory to process iCCP chunk."); | 700 png_warning(png_ptr, "Insufficient memory to process iCCP chunk."); |
| 696 return; | 701 return; |
| 697 } | 702 } |
| 698 png_memcpy(new_iccp_name, name, length); | 703 png_memcpy(new_iccp_name, name, length); |
| 699 new_iccp_profile = (png_charp)png_malloc_warn(png_ptr, proflen); | 704 new_iccp_profile = (png_charp)png_malloc_warn(png_ptr, proflen); |
| 700 if (new_iccp_profile == NULL) | 705 if (new_iccp_profile == NULL) |
| 701 { | 706 { |
| 702 png_free (png_ptr, new_iccp_name); | 707 png_free (png_ptr, new_iccp_name); |
| 703 png_warning(png_ptr, "Insufficient memory to process iCCP profile."); | 708 png_warning(png_ptr, |
| 709 "Insufficient memory to process iCCP profile."); |
| 704 return; | 710 return; |
| 705 } | 711 } |
| 706 png_memcpy(new_iccp_profile, profile, (png_size_t)proflen); | 712 png_memcpy(new_iccp_profile, profile, (png_size_t)proflen); |
| 707 | 713 |
| 708 png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0); | 714 png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0); |
| 709 | 715 |
| 710 info_ptr->iccp_proflen = proflen; | 716 info_ptr->iccp_proflen = proflen; |
| 711 info_ptr->iccp_name = new_iccp_name; | 717 info_ptr->iccp_name = new_iccp_name; |
| 712 info_ptr->iccp_profile = new_iccp_profile; | 718 info_ptr->iccp_profile = new_iccp_profile; |
| 713 /* Compression is always zero but is here so the API and info structure | 719 /* Compression is always zero but is here so the API and info structure |
| 714 * does not have to change if we introduce multiple compression types */ | 720 * does not have to change if we introduce multiple compression types */ |
| 715 info_ptr->iccp_compression = (png_byte)compression_type; | 721 info_ptr->iccp_compression = (png_byte)compression_type; |
| 716 #ifdef PNG_FREE_ME_SUPPORTED | 722 #ifdef PNG_FREE_ME_SUPPORTED |
| 717 info_ptr->free_me |= PNG_FREE_ICCP; | 723 info_ptr->free_me |= PNG_FREE_ICCP; |
| 718 #endif | 724 #endif |
| 719 info_ptr->valid |= PNG_INFO_iCCP; | 725 info_ptr->valid |= PNG_INFO_iCCP; |
| 720 } | 726 } |
| 721 #endif | 727 #endif |
| 722 | 728 |
| 723 #if defined(PNG_TEXT_SUPPORTED) | 729 #if defined(PNG_TEXT_SUPPORTED) |
| 724 void PNGAPI | 730 void PNGAPI |
| 725 png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, | 731 png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, |
| 726 int num_text) | 732 int num_text) |
| 727 { | 733 { |
| 728 int ret; | 734 int ret; |
| 729 ret=png_set_text_2(png_ptr, info_ptr, text_ptr, num_text); | 735 ret = png_set_text_2(png_ptr, info_ptr, text_ptr, num_text); |
| 730 if (ret) | 736 if (ret) |
| 731 png_error(png_ptr, "Insufficient memory to store text"); | 737 png_error(png_ptr, "Insufficient memory to store text"); |
| 732 } | 738 } |
| 733 | 739 |
| 734 int /* PRIVATE */ | 740 int /* PRIVATE */ |
| 735 png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, | 741 png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, |
| 736 int num_text) | 742 int num_text) |
| 737 { | 743 { |
| 738 int i; | 744 int i; |
| 739 | 745 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 750 { | 756 { |
| 751 if (info_ptr->text != NULL) | 757 if (info_ptr->text != NULL) |
| 752 { | 758 { |
| 753 png_textp old_text; | 759 png_textp old_text; |
| 754 int old_max; | 760 int old_max; |
| 755 | 761 |
| 756 old_max = info_ptr->max_text; | 762 old_max = info_ptr->max_text; |
| 757 info_ptr->max_text = info_ptr->num_text + num_text + 8; | 763 info_ptr->max_text = info_ptr->num_text + num_text + 8; |
| 758 old_text = info_ptr->text; | 764 old_text = info_ptr->text; |
| 759 info_ptr->text = (png_textp)png_malloc_warn(png_ptr, | 765 info_ptr->text = (png_textp)png_malloc_warn(png_ptr, |
| 760 (png_uint_32)(info_ptr->max_text * png_sizeof (png_text))); | 766 (png_uint_32)(info_ptr->max_text * png_sizeof(png_text))); |
| 761 if (info_ptr->text == NULL) | 767 if (info_ptr->text == NULL) |
| 762 { | 768 { |
| 763 png_free(png_ptr, old_text); | 769 png_free(png_ptr, old_text); |
| 764 return(1); | 770 return(1); |
| 765 } | 771 } |
| 766 png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max * | 772 png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max * |
| 767 png_sizeof(png_text))); | 773 png_sizeof(png_text))); |
| 768 png_free(png_ptr, old_text); | 774 png_free(png_ptr, old_text); |
| 769 } | 775 } |
| 770 else | 776 else |
| 771 { | 777 { |
| 772 info_ptr->max_text = num_text + 8; | 778 info_ptr->max_text = num_text + 8; |
| 773 info_ptr->num_text = 0; | 779 info_ptr->num_text = 0; |
| 774 info_ptr->text = (png_textp)png_malloc_warn(png_ptr, | 780 info_ptr->text = (png_textp)png_malloc_warn(png_ptr, |
| 775 (png_uint_32)(info_ptr->max_text * png_sizeof (png_text))); | 781 (png_uint_32)(info_ptr->max_text * png_sizeof(png_text))); |
| 776 if (info_ptr->text == NULL) | 782 if (info_ptr->text == NULL) |
| 777 return(1); | 783 return(1); |
| 778 #ifdef PNG_FREE_ME_SUPPORTED | 784 #ifdef PNG_FREE_ME_SUPPORTED |
| 779 info_ptr->free_me |= PNG_FREE_TEXT; | 785 info_ptr->free_me |= PNG_FREE_TEXT; |
| 780 #endif | 786 #endif |
| 781 } | 787 } |
| 782 png_debug1(3, "allocated %d entries for info_ptr->text\n", | 788 png_debug1(3, "allocated %d entries for info_ptr->text\n", |
| 783 info_ptr->max_text); | 789 info_ptr->max_text); |
| 784 } | 790 } |
| 785 for (i = 0; i < num_text; i++) | 791 for (i = 0; i < num_text; i++) |
| 786 { | 792 { |
| 787 png_size_t text_length,key_len; | 793 png_size_t text_length, key_len; |
| 788 png_size_t lang_len,lang_key_len; | 794 png_size_t lang_len, lang_key_len; |
| 789 png_textp textp = &(info_ptr->text[info_ptr->num_text]); | 795 png_textp textp = &(info_ptr->text[info_ptr->num_text]); |
| 790 | 796 |
| 791 if (text_ptr[i].key == NULL) | 797 if (text_ptr[i].key == NULL) |
| 792 continue; | 798 continue; |
| 793 | 799 |
| 794 key_len = png_strlen(text_ptr[i].key); | 800 key_len = png_strlen(text_ptr[i].key); |
| 795 | 801 |
| 796 if(text_ptr[i].compression <= 0) | 802 if (text_ptr[i].compression <= 0) |
| 797 { | 803 { |
| 798 lang_len = 0; | 804 lang_len = 0; |
| 799 lang_key_len = 0; | 805 lang_key_len = 0; |
| 800 } | 806 } |
| 801 else | 807 else |
| 802 #ifdef PNG_iTXt_SUPPORTED | 808 #ifdef PNG_iTXt_SUPPORTED |
| 803 { | 809 { |
| 804 /* set iTXt data */ | 810 /* set iTXt data */ |
| 805 if (text_ptr[i].lang != NULL) | 811 if (text_ptr[i].lang != NULL) |
| 806 lang_len = png_strlen(text_ptr[i].lang); | 812 lang_len = png_strlen(text_ptr[i].lang); |
| 807 else | 813 else |
| 808 lang_len = 0; | 814 lang_len = 0; |
| 809 if (text_ptr[i].lang_key != NULL) | 815 if (text_ptr[i].lang_key != NULL) |
| 810 lang_key_len = png_strlen(text_ptr[i].lang_key); | 816 lang_key_len = png_strlen(text_ptr[i].lang_key); |
| 811 else | 817 else |
| 812 lang_key_len = 0; | 818 lang_key_len = 0; |
| 813 } | 819 } |
| 814 #else | 820 #else |
| 815 { | 821 { |
| 816 png_warning(png_ptr, "iTXt chunk not supported."); | 822 png_warning(png_ptr, "iTXt chunk not supported."); |
| 817 continue; | 823 continue; |
| 818 } | 824 } |
| 819 #endif | 825 #endif |
| 820 | 826 |
| 821 if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0') | 827 if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0') |
| 822 { | 828 { |
| 823 text_length = 0; | 829 text_length = 0; |
| 824 #ifdef PNG_iTXt_SUPPORTED | 830 #ifdef PNG_iTXt_SUPPORTED |
| 825 if(text_ptr[i].compression > 0) | 831 if (text_ptr[i].compression > 0) |
| 826 textp->compression = PNG_ITXT_COMPRESSION_NONE; | 832 textp->compression = PNG_ITXT_COMPRESSION_NONE; |
| 827 else | 833 else |
| 828 #endif | 834 #endif |
| 829 textp->compression = PNG_TEXT_COMPRESSION_NONE; | 835 textp->compression = PNG_TEXT_COMPRESSION_NONE; |
| 830 } | 836 } |
| 831 else | 837 else |
| 832 { | 838 { |
| 833 text_length = png_strlen(text_ptr[i].text); | 839 text_length = png_strlen(text_ptr[i].text); |
| 834 textp->compression = text_ptr[i].compression; | 840 textp->compression = text_ptr[i].compression; |
| 835 } | 841 } |
| 836 | 842 |
| 837 textp->key = (png_charp)png_malloc_warn(png_ptr, | 843 textp->key = (png_charp)png_malloc_warn(png_ptr, |
| 838 (png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4)); | 844 (png_uint_32) |
| 845 (key_len + text_length + lang_len + lang_key_len + 4)); |
| 839 if (textp->key == NULL) | 846 if (textp->key == NULL) |
| 840 return(1); | 847 return(1); |
| 841 png_debug2(2, "Allocated %lu bytes at %x in png_set_text\n", | 848 png_debug2(2, "Allocated %lu bytes at %x in png_set_text\n", |
| 842 (png_uint_32)(key_len + lang_len + lang_key_len + text_length + 4), | 849 (png_uint_32) |
| 850 (key_len + lang_len + lang_key_len + text_length + 4), |
| 843 (int)textp->key); | 851 (int)textp->key); |
| 844 | 852 |
| 845 png_memcpy(textp->key, text_ptr[i].key, | 853 png_memcpy(textp->key, text_ptr[i].key, |
| 846 (png_size_t)(key_len)); | 854 (png_size_t)(key_len)); |
| 847 *(textp->key+key_len) = '\0'; | 855 *(textp->key + key_len) = '\0'; |
| 848 #ifdef PNG_iTXt_SUPPORTED | 856 #ifdef PNG_iTXt_SUPPORTED |
| 849 if (text_ptr[i].compression > 0) | 857 if (text_ptr[i].compression > 0) |
| 850 { | 858 { |
| 851 textp->lang=textp->key + key_len + 1; | 859 textp->lang = textp->key + key_len + 1; |
| 852 png_memcpy(textp->lang, text_ptr[i].lang, lang_len); | 860 png_memcpy(textp->lang, text_ptr[i].lang, lang_len); |
| 853 *(textp->lang+lang_len) = '\0'; | 861 *(textp->lang + lang_len) = '\0'; |
| 854 textp->lang_key=textp->lang + lang_len + 1; | 862 textp->lang_key = textp->lang + lang_len + 1; |
| 855 png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len); | 863 png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len); |
| 856 *(textp->lang_key+lang_key_len) = '\0'; | 864 *(textp->lang_key + lang_key_len) = '\0'; |
| 857 textp->text=textp->lang_key + lang_key_len + 1; | 865 textp->text = textp->lang_key + lang_key_len + 1; |
| 858 } | 866 } |
| 859 else | 867 else |
| 860 #endif | 868 #endif |
| 861 { | 869 { |
| 862 #ifdef PNG_iTXt_SUPPORTED | 870 #ifdef PNG_iTXt_SUPPORTED |
| 863 textp->lang=NULL; | 871 textp->lang=NULL; |
| 864 textp->lang_key=NULL; | 872 textp->lang_key=NULL; |
| 865 #endif | 873 #endif |
| 866 textp->text=textp->key + key_len + 1; | 874 textp->text = textp->key + key_len + 1; |
| 867 } | 875 } |
| 868 if(text_length) | 876 if (text_length) |
| 869 png_memcpy(textp->text, text_ptr[i].text, | 877 png_memcpy(textp->text, text_ptr[i].text, |
| 870 (png_size_t)(text_length)); | 878 (png_size_t)(text_length)); |
| 871 *(textp->text+text_length) = '\0'; | 879 *(textp->text + text_length) = '\0'; |
| 872 | 880 |
| 873 #ifdef PNG_iTXt_SUPPORTED | 881 #ifdef PNG_iTXt_SUPPORTED |
| 874 if(textp->compression > 0) | 882 if (textp->compression > 0) |
| 875 { | 883 { |
| 876 textp->text_length = 0; | 884 textp->text_length = 0; |
| 877 textp->itxt_length = text_length; | 885 textp->itxt_length = text_length; |
| 878 } | 886 } |
| 879 else | 887 else |
| 880 #endif | 888 #endif |
| 881 { | 889 { |
| 882 textp->text_length = text_length; | 890 textp->text_length = text_length; |
| 883 #ifdef PNG_iTXt_SUPPORTED | 891 #ifdef PNG_iTXt_SUPPORTED |
| 884 textp->itxt_length = 0; | 892 textp->itxt_length = 0; |
| 885 #endif | 893 #endif |
| 886 } | 894 } |
| 887 info_ptr->num_text++; | 895 info_ptr->num_text++; |
| 888 png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text); | 896 png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text); |
| 889 } | 897 } |
| 890 return(0); | 898 return(0); |
| 891 } | 899 } |
| 892 #endif | 900 #endif |
| 893 | 901 |
| 894 #if defined(PNG_tIME_SUPPORTED) | 902 #if defined(PNG_tIME_SUPPORTED) |
| 895 void PNGAPI | 903 void PNGAPI |
| 896 png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time) | 904 png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time) |
| 897 { | 905 { |
| 898 png_debug1(1, "in %s storage function\n", "tIME"); | 906 png_debug1(1, "in %s storage function\n", "tIME"); |
| 899 if (png_ptr == NULL || info_ptr == NULL || | 907 if (png_ptr == NULL || info_ptr == NULL || |
| 900 (png_ptr->mode & PNG_WROTE_tIME)) | 908 (png_ptr->mode & PNG_WROTE_tIME)) |
| 901 return; | 909 return; |
| 902 | 910 |
| 903 png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof (png_time)); | 911 png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof(png_time)); |
| 904 info_ptr->valid |= PNG_INFO_tIME; | 912 info_ptr->valid |= PNG_INFO_tIME; |
| 905 } | 913 } |
| 906 #endif | 914 #endif |
| 907 | 915 |
| 908 #if defined(PNG_tRNS_SUPPORTED) | 916 #if defined(PNG_tRNS_SUPPORTED) |
| 909 void PNGAPI | 917 void PNGAPI |
| 910 png_set_tRNS(png_structp png_ptr, png_infop info_ptr, | 918 png_set_tRNS(png_structp png_ptr, png_infop info_ptr, |
| 911 png_bytep trans, int num_trans, png_color_16p trans_values) | 919 png_bytep trans, int num_trans, png_color_16p trans_values) |
| 912 { | 920 { |
| 913 png_debug1(1, "in %s storage function\n", "tRNS"); | 921 png_debug1(1, "in %s storage function\n", "tRNS"); |
| 914 if (png_ptr == NULL || info_ptr == NULL) | 922 if (png_ptr == NULL || info_ptr == NULL) |
| 915 return; | 923 return; |
| 916 | 924 |
| 917 png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); | |
| 918 | |
| 919 if (trans != NULL) | 925 if (trans != NULL) |
| 920 { | 926 { |
| 921 /* | 927 /* |
| 922 * It may not actually be necessary to set png_ptr->trans here; | 928 * It may not actually be necessary to set png_ptr->trans here; |
| 923 * we do it for backward compatibility with the way the png_handle_tRNS | 929 * we do it for backward compatibility with the way the png_handle_tRNS |
| 924 * function used to do the allocation. | 930 * function used to do the allocation. |
| 925 */ | 931 */ |
| 926 | 932 |
| 933 #ifdef PNG_FREE_ME_SUPPORTED |
| 934 png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); |
| 935 #endif |
| 936 |
| 927 /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */ | 937 /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */ |
| 928 png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr, | 938 png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr, |
| 929 (png_uint_32)PNG_MAX_PALETTE_LENGTH); | 939 (png_uint_32)PNG_MAX_PALETTE_LENGTH); |
| 930 if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH) | 940 if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH) |
| 931 png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans); | 941 png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans); |
| 932 } | 942 } |
| 933 | 943 |
| 934 if (trans_values != NULL) | 944 if (trans_values != NULL) |
| 935 { | 945 { |
| 936 int sample_max = (1 << info_ptr->bit_depth); | 946 int sample_max = (1 << info_ptr->bit_depth); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 958 png_ptr->flags |= PNG_FLAG_FREE_TRNS; | 968 png_ptr->flags |= PNG_FLAG_FREE_TRNS; |
| 959 #endif | 969 #endif |
| 960 } | 970 } |
| 961 } | 971 } |
| 962 #endif | 972 #endif |
| 963 | 973 |
| 964 #if defined(PNG_sPLT_SUPPORTED) | 974 #if defined(PNG_sPLT_SUPPORTED) |
| 965 void PNGAPI | 975 void PNGAPI |
| 966 png_set_sPLT(png_structp png_ptr, | 976 png_set_sPLT(png_structp png_ptr, |
| 967 png_infop info_ptr, png_sPLT_tp entries, int nentries) | 977 png_infop info_ptr, png_sPLT_tp entries, int nentries) |
| 978 /* |
| 979 * entries - array of png_sPLT_t structures |
| 980 * to be added to the list of palettes |
| 981 * in the info structure. |
| 982 * nentries - number of palette structures to be |
| 983 * added. |
| 984 */ |
| 968 { | 985 { |
| 969 png_sPLT_tp np; | 986 png_sPLT_tp np; |
| 970 int i; | 987 int i; |
| 971 | 988 |
| 972 if (png_ptr == NULL || info_ptr == NULL) | 989 if (png_ptr == NULL || info_ptr == NULL) |
| 973 return; | 990 return; |
| 974 | 991 |
| 975 np = (png_sPLT_tp)png_malloc_warn(png_ptr, | 992 np = (png_sPLT_tp)png_malloc_warn(png_ptr, |
| 976 (info_ptr->splt_palettes_num + nentries) * png_sizeof(png_sPLT_t)); | 993 (info_ptr->splt_palettes_num + nentries) * |
| 994 (png_uint_32)png_sizeof(png_sPLT_t)); |
| 977 if (np == NULL) | 995 if (np == NULL) |
| 978 { | 996 { |
| 979 png_warning(png_ptr, "No memory for sPLT palettes."); | 997 png_warning(png_ptr, "No memory for sPLT palettes."); |
| 980 return; | 998 return; |
| 981 } | 999 } |
| 982 | 1000 |
| 983 png_memcpy(np, info_ptr->splt_palettes, | 1001 png_memcpy(np, info_ptr->splt_palettes, |
| 984 info_ptr->splt_palettes_num * png_sizeof(png_sPLT_t)); | 1002 info_ptr->splt_palettes_num * png_sizeof(png_sPLT_t)); |
| 985 png_free(png_ptr, info_ptr->splt_palettes); | 1003 png_free(png_ptr, info_ptr->splt_palettes); |
| 986 info_ptr->splt_palettes=NULL; | 1004 info_ptr->splt_palettes=NULL; |
| 987 | 1005 |
| 988 for (i = 0; i < nentries; i++) | 1006 for (i = 0; i < nentries; i++) |
| 989 { | 1007 { |
| 990 png_sPLT_tp to = np + info_ptr->splt_palettes_num + i; | 1008 png_sPLT_tp to = np + info_ptr->splt_palettes_num + i; |
| 991 png_sPLT_tp from = entries + i; | 1009 png_sPLT_tp from = entries + i; |
| 992 png_uint_32 length; | 1010 png_uint_32 length; |
| 993 | 1011 |
| 994 length = png_strlen(from->name) + 1; | 1012 length = png_strlen(from->name) + 1; |
| 995 to->name = (png_charp)png_malloc_warn(png_ptr, length); | 1013 to->name = (png_charp)png_malloc_warn(png_ptr, length); |
| 996 if (to->name == NULL) | 1014 if (to->name == NULL) |
| 997 { | 1015 { |
| 998 png_warning(png_ptr, | 1016 png_warning(png_ptr, |
| 999 "Out of memory while processing sPLT chunk"); | 1017 "Out of memory while processing sPLT chunk"); |
| 1000 continue; | 1018 continue; |
| 1001 } | 1019 } |
| 1002 png_memcpy(to->name, from->name, length); | 1020 png_memcpy(to->name, from->name, length); |
| 1003 to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr, | 1021 to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr, |
| 1004 from->nentries * png_sizeof(png_sPLT_entry)); | 1022 (png_uint_32)(from->nentries * png_sizeof(png_sPLT_entry))); |
| 1005 if (to->entries == NULL) | 1023 if (to->entries == NULL) |
| 1006 { | 1024 { |
| 1007 png_warning(png_ptr, | 1025 png_warning(png_ptr, |
| 1008 "Out of memory while processing sPLT chunk"); | 1026 "Out of memory while processing sPLT chunk"); |
| 1009 png_free(png_ptr,to->name); | 1027 png_free(png_ptr, to->name); |
| 1010 to->name = NULL; | 1028 to->name = NULL; |
| 1011 continue; | 1029 continue; |
| 1012 } | 1030 } |
| 1013 png_memcpy(to->entries, from->entries, | 1031 png_memcpy(to->entries, from->entries, |
| 1014 from->nentries * png_sizeof(png_sPLT_entry)); | 1032 from->nentries * png_sizeof(png_sPLT_entry)); |
| 1015 to->nentries = from->nentries; | 1033 to->nentries = from->nentries; |
| 1016 to->depth = from->depth; | 1034 to->depth = from->depth; |
| 1017 } | 1035 } |
| 1018 | 1036 |
| 1019 info_ptr->splt_palettes = np; | 1037 info_ptr->splt_palettes = np; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1030 png_set_unknown_chunks(png_structp png_ptr, | 1048 png_set_unknown_chunks(png_structp png_ptr, |
| 1031 png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns) | 1049 png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns) |
| 1032 { | 1050 { |
| 1033 png_unknown_chunkp np; | 1051 png_unknown_chunkp np; |
| 1034 int i; | 1052 int i; |
| 1035 | 1053 |
| 1036 if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0) | 1054 if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0) |
| 1037 return; | 1055 return; |
| 1038 | 1056 |
| 1039 np = (png_unknown_chunkp)png_malloc_warn(png_ptr, | 1057 np = (png_unknown_chunkp)png_malloc_warn(png_ptr, |
| 1040 (info_ptr->unknown_chunks_num + num_unknowns) * | 1058 (png_uint_32)((info_ptr->unknown_chunks_num + num_unknowns) * |
| 1041 png_sizeof(png_unknown_chunk)); | 1059 png_sizeof(png_unknown_chunk))); |
| 1042 if (np == NULL) | 1060 if (np == NULL) |
| 1043 { | 1061 { |
| 1044 png_warning(png_ptr, | 1062 png_warning(png_ptr, |
| 1045 "Out of memory while processing unknown chunk."); | 1063 "Out of memory while processing unknown chunk."); |
| 1046 return; | 1064 return; |
| 1047 } | 1065 } |
| 1048 | 1066 |
| 1049 png_memcpy(np, info_ptr->unknown_chunks, | 1067 png_memcpy(np, info_ptr->unknown_chunks, |
| 1050 info_ptr->unknown_chunks_num * png_sizeof(png_unknown_chunk)); | 1068 info_ptr->unknown_chunks_num * png_sizeof(png_unknown_chunk)); |
| 1051 png_free(png_ptr, info_ptr->unknown_chunks); | 1069 png_free(png_ptr, info_ptr->unknown_chunks); |
| 1052 info_ptr->unknown_chunks=NULL; | 1070 info_ptr->unknown_chunks=NULL; |
| 1053 | 1071 |
| 1054 for (i = 0; i < num_unknowns; i++) | 1072 for (i = 0; i < num_unknowns; i++) |
| 1055 { | 1073 { |
| 1056 png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i; | 1074 png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i; |
| 1057 png_unknown_chunkp from = unknowns + i; | 1075 png_unknown_chunkp from = unknowns + i; |
| 1058 | 1076 |
| 1059 png_memcpy((png_charp)to->name, | 1077 png_memcpy((png_charp)to->name, |
| 1060 (png_charp)from->name, | 1078 (png_charp)from->name, |
| 1061 png_sizeof(from->name)); | 1079 png_sizeof(from->name)); |
| 1062 to->name[png_sizeof(to->name)-1] = '\0'; | 1080 to->name[png_sizeof(to->name)-1] = '\0'; |
| 1063 to->size = from->size; | 1081 to->size = from->size; |
| 1064 /* note our location in the read or write sequence */ | 1082 /* note our location in the read or write sequence */ |
| 1065 to->location = (png_byte)(png_ptr->mode & 0xff); | 1083 to->location = (png_byte)(png_ptr->mode & 0xff); |
| 1066 | 1084 |
| 1067 if (from->size == 0) | 1085 if (from->size == 0) |
| 1068 to->data=NULL; | 1086 to->data=NULL; |
| 1069 else | 1087 else |
| 1070 { | 1088 { |
| 1071 to->data = (png_bytep)png_malloc_warn(png_ptr, from->size); | 1089 to->data = (png_bytep)png_malloc_warn(png_ptr, |
| 1090 (png_uint_32)from->size); |
| 1072 if (to->data == NULL) | 1091 if (to->data == NULL) |
| 1073 { | 1092 { |
| 1074 png_warning(png_ptr, | 1093 png_warning(png_ptr, |
| 1075 "Out of memory while processing unknown chunk."); | 1094 "Out of memory while processing unknown chunk."); |
| 1076 to->size=0; | 1095 to->size = 0; |
| 1077 } | 1096 } |
| 1078 else | 1097 else |
| 1079 png_memcpy(to->data, from->data, from->size); | 1098 png_memcpy(to->data, from->data, from->size); |
| 1080 } | 1099 } |
| 1081 } | 1100 } |
| 1082 | 1101 |
| 1083 info_ptr->unknown_chunks = np; | 1102 info_ptr->unknown_chunks = np; |
| 1084 info_ptr->unknown_chunks_num += num_unknowns; | 1103 info_ptr->unknown_chunks_num += num_unknowns; |
| 1085 #ifdef PNG_FREE_ME_SUPPORTED | 1104 #ifdef PNG_FREE_ME_SUPPORTED |
| 1086 info_ptr->free_me |= PNG_FREE_UNKN; | 1105 info_ptr->free_me |= PNG_FREE_UNKN; |
| 1087 #endif | 1106 #endif |
| 1088 } | 1107 } |
| 1089 void PNGAPI | 1108 void PNGAPI |
| 1090 png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr, | 1109 png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr, |
| 1091 int chunk, int location) | 1110 int chunk, int location) |
| 1092 { | 1111 { |
| 1093 if(png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk < | 1112 if (png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk < |
| 1094 (int)info_ptr->unknown_chunks_num) | 1113 (int)info_ptr->unknown_chunks_num) |
| 1095 info_ptr->unknown_chunks[chunk].location = (png_byte)location; | 1114 info_ptr->unknown_chunks[chunk].location = (png_byte)location; |
| 1096 } | 1115 } |
| 1097 #endif | 1116 #endif |
| 1098 | 1117 |
| 1099 #if defined(PNG_1_0_X) || defined(PNG_1_2_X) | 1118 #if defined(PNG_1_0_X) || defined(PNG_1_2_X) |
| 1100 #if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ | 1119 #if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ |
| 1101 defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) | 1120 defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) |
| 1102 void PNGAPI | 1121 void PNGAPI |
| 1103 png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted) | 1122 png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1131 void PNGAPI | 1150 void PNGAPI |
| 1132 png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep | 1151 png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep |
| 1133 chunk_list, int num_chunks) | 1152 chunk_list, int num_chunks) |
| 1134 { | 1153 { |
| 1135 png_bytep new_list, p; | 1154 png_bytep new_list, p; |
| 1136 int i, old_num_chunks; | 1155 int i, old_num_chunks; |
| 1137 if (png_ptr == NULL) | 1156 if (png_ptr == NULL) |
| 1138 return; | 1157 return; |
| 1139 if (num_chunks == 0) | 1158 if (num_chunks == 0) |
| 1140 { | 1159 { |
| 1141 if(keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE) | 1160 if (keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE) |
| 1142 png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS; | 1161 png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS; |
| 1143 else | 1162 else |
| 1144 png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS; | 1163 png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS; |
| 1145 | 1164 |
| 1146 if(keep == PNG_HANDLE_CHUNK_ALWAYS) | 1165 if (keep == PNG_HANDLE_CHUNK_ALWAYS) |
| 1147 png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS; | 1166 png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS; |
| 1148 else | 1167 else |
| 1149 png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS; | 1168 png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS; |
| 1150 return; | 1169 return; |
| 1151 } | 1170 } |
| 1152 if (chunk_list == NULL) | 1171 if (chunk_list == NULL) |
| 1153 return; | 1172 return; |
| 1154 old_num_chunks=png_ptr->num_chunk_list; | 1173 old_num_chunks = png_ptr->num_chunk_list; |
| 1155 new_list=(png_bytep)png_malloc(png_ptr, | 1174 new_list=(png_bytep)png_malloc(png_ptr, |
| 1156 (png_uint_32)(5*(num_chunks+old_num_chunks))); | 1175 (png_uint_32) |
| 1157 if(png_ptr->chunk_list != NULL) | 1176 (5*(num_chunks + old_num_chunks))); |
| 1177 if (png_ptr->chunk_list != NULL) |
| 1158 { | 1178 { |
| 1159 png_memcpy(new_list, png_ptr->chunk_list, | 1179 png_memcpy(new_list, png_ptr->chunk_list, |
| 1160 (png_size_t)(5*old_num_chunks)); | 1180 (png_size_t)(5*old_num_chunks)); |
| 1161 png_free(png_ptr, png_ptr->chunk_list); | 1181 png_free(png_ptr, png_ptr->chunk_list); |
| 1162 png_ptr->chunk_list=NULL; | 1182 png_ptr->chunk_list=NULL; |
| 1163 } | 1183 } |
| 1164 png_memcpy(new_list+5*old_num_chunks, chunk_list, | 1184 png_memcpy(new_list + 5*old_num_chunks, chunk_list, |
| 1165 (png_size_t)(5*num_chunks)); | 1185 (png_size_t)(5*num_chunks)); |
| 1166 for (p=new_list+5*old_num_chunks+4, i=0; i<num_chunks; i++, p+=5) | 1186 for (p = new_list + 5*old_num_chunks + 4, i = 0; i<num_chunks; i++, p += 5) |
| 1167 *p=(png_byte)keep; | 1187 *p=(png_byte)keep; |
| 1168 png_ptr->num_chunk_list=old_num_chunks+num_chunks; | 1188 png_ptr->num_chunk_list = old_num_chunks + num_chunks; |
| 1169 png_ptr->chunk_list=new_list; | 1189 png_ptr->chunk_list = new_list; |
| 1170 #ifdef PNG_FREE_ME_SUPPORTED | 1190 #ifdef PNG_FREE_ME_SUPPORTED |
| 1171 png_ptr->free_me |= PNG_FREE_LIST; | 1191 png_ptr->free_me |= PNG_FREE_LIST; |
| 1172 #endif | 1192 #endif |
| 1173 } | 1193 } |
| 1174 #endif | 1194 #endif |
| 1175 | 1195 |
| 1176 #if defined(PNG_READ_USER_CHUNKS_SUPPORTED) | 1196 #if defined(PNG_READ_USER_CHUNKS_SUPPORTED) |
| 1177 void PNGAPI | 1197 void PNGAPI |
| 1178 png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr, | 1198 png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr, |
| 1179 png_user_chunk_ptr read_user_chunk_fn) | 1199 png_user_chunk_ptr read_user_chunk_fn) |
| 1180 { | 1200 { |
| 1181 png_debug(1, "in png_set_read_user_chunk_fn\n"); | 1201 png_debug(1, "in png_set_read_user_chunk_fn\n"); |
| 1182 if (png_ptr == NULL) | 1202 if (png_ptr == NULL) |
| 1183 return; | 1203 return; |
| 1184 png_ptr->read_user_chunk_fn = read_user_chunk_fn; | 1204 png_ptr->read_user_chunk_fn = read_user_chunk_fn; |
| 1185 png_ptr->user_chunk_ptr = user_chunk_ptr; | 1205 png_ptr->user_chunk_ptr = user_chunk_ptr; |
| 1186 } | 1206 } |
| 1187 #endif | 1207 #endif |
| 1188 | 1208 |
| 1189 #if defined(PNG_INFO_IMAGE_SUPPORTED) | 1209 #if defined(PNG_INFO_IMAGE_SUPPORTED) |
| 1190 void PNGAPI | 1210 void PNGAPI |
| 1191 png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers) | 1211 png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers) |
| 1192 { | 1212 { |
| 1193 png_debug1(1, "in %s storage function\n", "rows"); | 1213 png_debug1(1, "in %s storage function\n", "rows"); |
| 1194 | 1214 |
| 1195 if (png_ptr == NULL || info_ptr == NULL) | 1215 if (png_ptr == NULL || info_ptr == NULL) |
| 1196 return; | 1216 return; |
| 1197 | 1217 |
| 1198 if(info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers)) | 1218 if (info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers)) |
| 1199 png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); | 1219 png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); |
| 1200 info_ptr->row_pointers = row_pointers; | 1220 info_ptr->row_pointers = row_pointers; |
| 1201 if(row_pointers) | 1221 if (row_pointers) |
| 1202 info_ptr->valid |= PNG_INFO_IDAT; | 1222 info_ptr->valid |= PNG_INFO_IDAT; |
| 1203 } | 1223 } |
| 1204 #endif | 1224 #endif |
| 1205 | 1225 |
| 1206 #ifdef PNG_WRITE_SUPPORTED | 1226 #ifdef PNG_WRITE_SUPPORTED |
| 1207 void PNGAPI | 1227 void PNGAPI |
| 1208 png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size) | 1228 png_set_compression_buffer_size(png_structp png_ptr, |
| 1229 png_uint_32 size) |
| 1209 { | 1230 { |
| 1210 if (png_ptr == NULL) | 1231 if (png_ptr == NULL) |
| 1211 return; | 1232 return; |
| 1212 png_free(png_ptr, png_ptr->zbuf); | 1233 png_free(png_ptr, png_ptr->zbuf); |
| 1213 png_ptr->zbuf_size = (png_size_t)size; | 1234 png_ptr->zbuf_size = (png_size_t)size; |
| 1214 png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size); | 1235 png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size); |
| 1215 png_ptr->zstream.next_out = png_ptr->zbuf; | 1236 png_ptr->zstream.next_out = png_ptr->zbuf; |
| 1216 png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; | 1237 png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; |
| 1217 } | 1238 } |
| 1218 #endif | 1239 #endif |
| 1219 | 1240 |
| 1220 void PNGAPI | 1241 void PNGAPI |
| 1221 png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask) | 1242 png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask) |
| 1222 { | 1243 { |
| 1223 if (png_ptr && info_ptr) | 1244 if (png_ptr && info_ptr) |
| 1224 info_ptr->valid &= ~mask; | 1245 info_ptr->valid &= ~mask; |
| 1225 } | 1246 } |
| 1226 | 1247 |
| 1227 | 1248 |
| 1228 #ifndef PNG_1_0_X | 1249 #ifndef PNG_1_0_X |
| 1229 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED | 1250 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED |
| 1230 /* function was added to libpng 1.2.0 and should always exist by default */ | 1251 /* function was added to libpng 1.2.0 and should always exist by default */ |
| 1231 void PNGAPI | 1252 void PNGAPI |
| 1232 png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags) | 1253 png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags) |
| 1233 { | 1254 { |
| 1234 /* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */ | 1255 /* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */ |
| 1235 if (png_ptr != NULL) | 1256 if (png_ptr != NULL) |
| 1236 png_ptr->asm_flags = 0; | 1257 png_ptr->asm_flags = 0; |
| 1258 asm_flags = asm_flags; /* Quiet the compiler */ |
| 1237 } | 1259 } |
| 1238 | 1260 |
| 1239 /* this function was added to libpng 1.2.0 */ | 1261 /* this function was added to libpng 1.2.0 */ |
| 1240 void PNGAPI | 1262 void PNGAPI |
| 1241 png_set_mmx_thresholds (png_structp png_ptr, | 1263 png_set_mmx_thresholds (png_structp png_ptr, |
| 1242 png_byte mmx_bitdepth_threshold, | 1264 png_byte mmx_bitdepth_threshold, |
| 1243 png_uint_32 mmx_rowbytes_threshold) | 1265 png_uint_32 mmx_rowbytes_threshold) |
| 1244 { | 1266 { |
| 1245 /* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */ | 1267 /* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */ |
| 1246 if (png_ptr == NULL) | 1268 if (png_ptr == NULL) |
| 1247 return; | 1269 return; |
| 1270 /* Quiet the compiler */ |
| 1271 mmx_bitdepth_threshold = mmx_bitdepth_threshold; |
| 1272 mmx_rowbytes_threshold = mmx_rowbytes_threshold; |
| 1248 } | 1273 } |
| 1249 #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ | 1274 #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ |
| 1250 | 1275 |
| 1251 #ifdef PNG_SET_USER_LIMITS_SUPPORTED | 1276 #ifdef PNG_SET_USER_LIMITS_SUPPORTED |
| 1252 /* this function was added to libpng 1.2.6 */ | 1277 /* this function was added to libpng 1.2.6 */ |
| 1253 void PNGAPI | 1278 void PNGAPI |
| 1254 png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max, | 1279 png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max, |
| 1255 png_uint_32 user_height_max) | 1280 png_uint_32 user_height_max) |
| 1256 { | 1281 { |
| 1257 /* Images with dimensions larger than these limits will be | 1282 /* Images with dimensions larger than these limits will be |
| 1258 * rejected by png_set_IHDR(). To accept any PNG datastream | 1283 * rejected by png_set_IHDR(). To accept any PNG datastream |
| 1259 * regardless of dimensions, set both limits to 0x7ffffffL. | 1284 * regardless of dimensions, set both limits to 0x7ffffffL. |
| 1260 */ | 1285 */ |
| 1261 if(png_ptr == NULL) return; | 1286 if (png_ptr == NULL) return; |
| 1262 png_ptr->user_width_max = user_width_max; | 1287 png_ptr->user_width_max = user_width_max; |
| 1263 png_ptr->user_height_max = user_height_max; | 1288 png_ptr->user_height_max = user_height_max; |
| 1264 } | 1289 } |
| 1265 #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ | 1290 #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ |
| 1266 | 1291 |
| 1267 #endif /* ?PNG_1_0_X */ | 1292 #endif /* ?PNG_1_0_X */ |
| 1268 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ | 1293 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ |
| OLD | NEW |