Changeset 561 for trunk/src/3rdparty/libpng/pngset.c
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/3rdparty/libpng/pngset.c
r2 r561 2 2 /* pngset.c - storage of image information into info struct 3 3 * 4 * Last changed in libpng 1.2.27 [April 29, 2008] 5 * For conditions of distribution and use, see copyright notice in png.h 6 * Copyright (c) 1998-2008 Glenn Randers-Pehrson 4 * Last changed in libpng 1.2.40 [September 10, 2009] 5 * Copyright (c) 1998-2009 Glenn Randers-Pehrson 7 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 8 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 8 * 9 * This code is released under the libpng license. 10 * For conditions of distribution and use, see the disclaimer 11 * and license in png.h 9 12 * 10 13 * The functions here are used during reads to store data from the file … … 16 19 #define PNG_INTERNAL 17 20 #include "png.h" 18 19 21 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 20 22 … … 23 25 png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background) 24 26 { 25 png_debug1(1, "in %s storage function\n", "bKGD"); 27 png_debug1(1, "in %s storage function", "bKGD"); 28 26 29 if (png_ptr == NULL || info_ptr == NULL) 27 30 return; … … 39 42 double green_x, double green_y, double blue_x, double blue_y) 40 43 { 41 png_debug1(1, "in %s storage function\n", "cHRM"); 42 if (png_ptr == NULL || info_ptr == NULL) 43 return; 44 if (!(white_x || white_y || red_x || red_y || green_x || green_y || 45 blue_x || blue_y)) 46 { 47 png_warning(png_ptr, 48 "Ignoring attempt to set all-zero chromaticity values"); 49 return; 50 } 51 if (white_x < 0.0 || white_y < 0.0 || 52 red_x < 0.0 || red_y < 0.0 || 53 green_x < 0.0 || green_y < 0.0 || 54 blue_x < 0.0 || blue_y < 0.0) 55 { 56 png_warning(png_ptr, 57 "Ignoring attempt to set negative chromaticity value"); 58 return; 59 } 60 if (white_x > 21474.83 || white_y > 21474.83 || 61 red_x > 21474.83 || red_y > 21474.83 || 62 green_x > 21474.83 || green_y > 21474.83 || 63 blue_x > 21474.83 || blue_y > 21474.83) 64 { 65 png_warning(png_ptr, 66 "Ignoring attempt to set chromaticity value exceeding 21474.83"); 67 return; 68 } 44 png_debug1(1, "in %s storage function", "cHRM"); 45 46 if (png_ptr == NULL || info_ptr == NULL) 47 return; 69 48 70 49 info_ptr->x_white = (float)white_x; … … 88 67 info_ptr->valid |= PNG_INFO_cHRM; 89 68 } 90 #endif 69 #endif /* PNG_FLOATING_POINT_SUPPORTED */ 70 91 71 #ifdef PNG_FIXED_POINT_SUPPORTED 92 72 void PNGAPI … … 96 76 png_fixed_point blue_x, png_fixed_point blue_y) 97 77 { 98 png_debug1(1, "in %s storage function\n", "cHRM"); 99 if (png_ptr == NULL || info_ptr == NULL) 100 return; 101 102 if (!(white_x || white_y || red_x || red_y || green_x || green_y || 103 blue_x || blue_y)) 104 { 105 png_warning(png_ptr, 106 "Ignoring attempt to set all-zero chromaticity values"); 107 return; 108 } 109 if (white_x < 0 || white_y < 0 || 110 red_x < 0 || red_y < 0 || 111 green_x < 0 || green_y < 0 || 112 blue_x < 0 || blue_y < 0) 113 { 114 png_warning(png_ptr, 115 "Ignoring attempt to set negative chromaticity value"); 116 return; 117 } 118 if (white_x > (png_fixed_point) PNG_UINT_31_MAX || 119 white_y > (png_fixed_point) PNG_UINT_31_MAX || 120 red_x > (png_fixed_point) PNG_UINT_31_MAX || 121 red_y > (png_fixed_point) PNG_UINT_31_MAX || 122 green_x > (png_fixed_point) PNG_UINT_31_MAX || 123 green_y > (png_fixed_point) PNG_UINT_31_MAX || 124 blue_x > (png_fixed_point) PNG_UINT_31_MAX || 125 blue_y > (png_fixed_point) PNG_UINT_31_MAX ) 126 { 127 png_warning(png_ptr, 128 "Ignoring attempt to set chromaticity value exceeding 21474.83"); 129 return; 130 } 131 info_ptr->int_x_white = white_x; 132 info_ptr->int_y_white = white_y; 133 info_ptr->int_x_red = red_x; 134 info_ptr->int_y_red = red_y; 135 info_ptr->int_x_green = green_x; 136 info_ptr->int_y_green = green_y; 137 info_ptr->int_x_blue = blue_x; 138 info_ptr->int_y_blue = blue_y; 139 #ifdef PNG_FLOATING_POINT_SUPPORTED 140 info_ptr->x_white = (float)(white_x/100000.); 141 info_ptr->y_white = (float)(white_y/100000.); 142 info_ptr->x_red = (float)( red_x/100000.); 143 info_ptr->y_red = (float)( red_y/100000.); 144 info_ptr->x_green = (float)(green_x/100000.); 145 info_ptr->y_green = (float)(green_y/100000.); 146 info_ptr->x_blue = (float)( blue_x/100000.); 147 info_ptr->y_blue = (float)( blue_y/100000.); 148 #endif 149 info_ptr->valid |= PNG_INFO_cHRM; 150 } 151 #endif 152 #endif 78 png_debug1(1, "in %s storage function", "cHRM fixed"); 79 80 if (png_ptr == NULL || info_ptr == NULL) 81 return; 82 83 #if !defined(PNG_NO_CHECK_cHRM) 84 if (png_check_cHRM_fixed(png_ptr, 85 white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y)) 86 #endif 87 { 88 info_ptr->int_x_white = white_x; 89 info_ptr->int_y_white = white_y; 90 info_ptr->int_x_red = red_x; 91 info_ptr->int_y_red = red_y; 92 info_ptr->int_x_green = green_x; 93 info_ptr->int_y_green = green_y; 94 info_ptr->int_x_blue = blue_x; 95 info_ptr->int_y_blue = blue_y; 96 #ifdef PNG_FLOATING_POINT_SUPPORTED 97 info_ptr->x_white = (float)(white_x/100000.); 98 info_ptr->y_white = (float)(white_y/100000.); 99 info_ptr->x_red = (float)( red_x/100000.); 100 info_ptr->y_red = (float)( red_y/100000.); 101 info_ptr->x_green = (float)(green_x/100000.); 102 info_ptr->y_green = (float)(green_y/100000.); 103 info_ptr->x_blue = (float)( blue_x/100000.); 104 info_ptr->y_blue = (float)( blue_y/100000.); 105 #endif 106 info_ptr->valid |= PNG_INFO_cHRM; 107 } 108 } 109 #endif /* PNG_FIXED_POINT_SUPPORTED */ 110 #endif /* PNG_cHRM_SUPPORTED */ 153 111 154 112 #if defined(PNG_gAMA_SUPPORTED) … … 157 115 png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma) 158 116 { 159 double gamma; 160 png_debug1(1, "in %s storage function\n", "gAMA"); 117 double png_gamma; 118 119 png_debug1(1, "in %s storage function", "gAMA"); 120 161 121 if (png_ptr == NULL || info_ptr == NULL) 162 122 return; … … 166 126 { 167 127 png_warning(png_ptr, "Limiting gamma to 21474.83"); 168 gamma=21474.83;128 png_gamma=21474.83; 169 129 } 170 130 else 171 gamma=file_gamma;172 info_ptr->gamma = (float) gamma;131 png_gamma = file_gamma; 132 info_ptr->gamma = (float)png_gamma; 173 133 #ifdef PNG_FIXED_POINT_SUPPORTED 174 info_ptr->int_gamma = (int)( gamma*100000.+.5);134 info_ptr->int_gamma = (int)(png_gamma*100000.+.5); 175 135 #endif 176 136 info_ptr->valid |= PNG_INFO_gAMA; 177 if (gamma == 0.0)137 if (png_gamma == 0.0) 178 138 png_warning(png_ptr, "Setting gamma=0"); 179 139 } … … 183 143 int_gamma) 184 144 { 185 png_fixed_point gamma; 186 187 png_debug1(1, "in %s storage function\n", "gAMA"); 188 if (png_ptr == NULL || info_ptr == NULL) 189 return; 190 191 if (int_gamma > (png_fixed_point) PNG_UINT_31_MAX) 192 { 193 png_warning(png_ptr, "Limiting gamma to 21474.83"); 194 gamma=PNG_UINT_31_MAX; 145 png_fixed_point png_gamma; 146 147 png_debug1(1, "in %s storage function", "gAMA"); 148 149 if (png_ptr == NULL || info_ptr == NULL) 150 return; 151 152 if (int_gamma > (png_fixed_point)PNG_UINT_31_MAX) 153 { 154 png_warning(png_ptr, "Limiting gamma to 21474.83"); 155 png_gamma=PNG_UINT_31_MAX; 195 156 } 196 157 else 197 158 { 198 if (int_gamma < 0)199 {200 png_warning(png_ptr, "Setting negative gamma to zero");201 gamma=0;202 }203 else204 gamma=int_gamma;159 if (int_gamma < 0) 160 { 161 png_warning(png_ptr, "Setting negative gamma to zero"); 162 png_gamma = 0; 163 } 164 else 165 png_gamma = int_gamma; 205 166 } 206 167 #ifdef PNG_FLOATING_POINT_SUPPORTED 207 info_ptr->gamma = (float)( gamma/100000.);168 info_ptr->gamma = (float)(png_gamma/100000.); 208 169 #endif 209 170 #ifdef PNG_FIXED_POINT_SUPPORTED 210 info_ptr->int_gamma = gamma;171 info_ptr->int_gamma = png_gamma; 211 172 #endif 212 173 info_ptr->valid |= PNG_INFO_gAMA; 213 if (gamma == 0)174 if (png_gamma == 0) 214 175 png_warning(png_ptr, "Setting gamma=0"); 215 176 } … … 222 183 int i; 223 184 224 png_debug1(1, "in %s storage function\n", "hIST"); 225 if (png_ptr == NULL || info_ptr == NULL) 226 return; 185 png_debug1(1, "in %s storage function", "hIST"); 186 187 if (png_ptr == NULL || info_ptr == NULL) 188 return; 189 227 190 if (info_ptr->num_palette == 0 || info_ptr->num_palette 228 191 > PNG_MAX_PALETTE_LENGTH) 229 192 { 230 231 232 193 png_warning(png_ptr, 194 "Invalid palette size, hIST allocation skipped."); 195 return; 233 196 } 234 197 … … 236 199 png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0); 237 200 #endif 238 /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in version 239 1.2.1 */ 201 /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in 202 * version 1.2.1 203 */ 240 204 png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr, 241 (png_uint_32)(PNG_MAX_PALETTE_LENGTH * png_sizeof 205 (png_uint_32)(PNG_MAX_PALETTE_LENGTH * png_sizeof(png_uint_16))); 242 206 if (png_ptr->hist == NULL) 243 244 245 246 207 { 208 png_warning(png_ptr, "Insufficient memory for hIST chunk data."); 209 return; 210 } 247 211 248 212 for (i = 0; i < info_ptr->num_palette; i++) 249 213 png_ptr->hist[i] = hist[i]; 250 214 info_ptr->hist = png_ptr->hist; 251 215 info_ptr->valid |= PNG_INFO_hIST; … … 265 229 int filter_type) 266 230 { 267 png_debug1(1, "in %s storage function\n", "IHDR"); 268 if (png_ptr == NULL || info_ptr == NULL) 269 return; 270 271 /* check for width and height valid values */ 231 png_debug1(1, "in %s storage function", "IHDR"); 232 233 if (png_ptr == NULL || info_ptr == NULL) 234 return; 235 236 /* Check for width and height valid values */ 272 237 if (width == 0 || height == 0) 273 238 png_error(png_ptr, "Image width or height is zero in IHDR"); … … 289 254 png_warning(png_ptr, "Width is too large for libpng to process pixels"); 290 255 291 /* check other values */256 /* Check other values */ 292 257 if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 && 293 bit_depth != 8 && bit_depth != 16)258 bit_depth != 8 && bit_depth != 16) 294 259 png_error(png_ptr, "Invalid bit depth in IHDR"); 295 260 296 261 if (color_type < 0 || color_type == 1 || 297 color_type == 5 || color_type > 6)262 color_type == 5 || color_type > 6) 298 263 png_error(png_ptr, "Invalid color type in IHDR"); 299 264 … … 320 285 * 5. The color_type is RGB or RGBA 321 286 */ 322 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");324 if (filter_type != PNG_FILTER_TYPE_BASE)325 { 326 if (!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&327 (filter_type == PNG_INTRAPIXEL_DIFFERENCING) &&328 ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) &&329 (color_type == PNG_COLOR_TYPE_RGB ||287 if ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted) 288 png_warning(png_ptr, "MNG features are not allowed in a PNG datastream"); 289 if (filter_type != PNG_FILTER_TYPE_BASE) 290 { 291 if (!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && 292 (filter_type == PNG_INTRAPIXEL_DIFFERENCING) && 293 ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && 294 (color_type == PNG_COLOR_TYPE_RGB || 330 295 color_type == PNG_COLOR_TYPE_RGB_ALPHA))) 331 296 png_error(png_ptr, "Unknown filter method in IHDR"); 332 if (png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)297 if (png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) 333 298 png_warning(png_ptr, "Invalid filter method in IHDR"); 334 299 } 335 300 #else 336 if (filter_type != PNG_FILTER_TYPE_BASE)301 if (filter_type != PNG_FILTER_TYPE_BASE) 337 302 png_error(png_ptr, "Unknown filter method in IHDR"); 338 303 #endif … … 355 320 info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth); 356 321 357 /* check for potential overflow */322 /* Check for potential overflow */ 358 323 if (width > (PNG_UINT_32_MAX 359 324 >> 3) /* 8-byte RGBA pixels */ … … 364 329 info_ptr->rowbytes = (png_size_t)0; 365 330 else 366 info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width);331 info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width); 367 332 } 368 333 … … 372 337 png_int_32 offset_x, png_int_32 offset_y, int unit_type) 373 338 { 374 png_debug1(1, "in %s storage function\n", "oFFs"); 339 png_debug1(1, "in %s storage function", "oFFs"); 340 375 341 if (png_ptr == NULL || info_ptr == NULL) 376 342 return; … … 392 358 int i; 393 359 394 png_debug1(1, "in %s storage function\n", "pCAL"); 360 png_debug1(1, "in %s storage function", "pCAL"); 361 395 362 if (png_ptr == NULL || info_ptr == NULL) 396 363 return; 397 364 398 365 length = png_strlen(purpose) + 1; 399 png_debug1(3, "allocating purpose for info (%lu bytes)\n", length); 366 png_debug1(3, "allocating purpose for info (%lu bytes)", 367 (unsigned long)length); 400 368 info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length); 401 369 if (info_ptr->pcal_purpose == NULL) 402 403 404 405 370 { 371 png_warning(png_ptr, "Insufficient memory for pCAL purpose."); 372 return; 373 } 406 374 png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length); 407 375 408 png_debug(3, "storing X0, X1, type, and nparams in info \n");376 png_debug(3, "storing X0, X1, type, and nparams in info"); 409 377 info_ptr->pcal_X0 = X0; 410 378 info_ptr->pcal_X1 = X1; … … 413 381 414 382 length = png_strlen(units) + 1; 415 png_debug1(3, "allocating units for info (%lu bytes)\n", length); 383 png_debug1(3, "allocating units for info (%lu bytes)", 384 (unsigned long)length); 416 385 info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length); 417 386 if (info_ptr->pcal_units == NULL) 418 419 420 421 387 { 388 png_warning(png_ptr, "Insufficient memory for pCAL units."); 389 return; 390 } 422 391 png_memcpy(info_ptr->pcal_units, units, (png_size_t)length); 423 392 … … 425 394 (png_uint_32)((nparams + 1) * png_sizeof(png_charp))); 426 395 if (info_ptr->pcal_params == NULL) 427 428 429 430 431 432 info_ptr->pcal_params[nparams] = NULL;396 { 397 png_warning(png_ptr, "Insufficient memory for pCAL params."); 398 return; 399 } 400 401 png_memset(info_ptr->pcal_params, 0, (nparams + 1) * png_sizeof(png_charp)); 433 402 434 403 for (i = 0; i < nparams; i++) 435 404 { 436 405 length = png_strlen(params[i]) + 1; 437 png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i, length); 406 png_debug2(3, "allocating parameter %d for info (%lu bytes)", i, 407 (unsigned long)length); 438 408 info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length); 439 409 if (info_ptr->pcal_params[i] == NULL) 440 441 442 443 410 { 411 png_warning(png_ptr, "Insufficient memory for pCAL parameter."); 412 return; 413 } 444 414 png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length); 445 415 } … … 458 428 int unit, double width, double height) 459 429 { 460 png_debug1(1, "in %s storage function\n", "sCAL"); 430 png_debug1(1, "in %s storage function", "sCAL"); 431 461 432 if (png_ptr == NULL || info_ptr == NULL) 462 433 return; … … 476 447 png_uint_32 length; 477 448 478 png_debug1(1, "in %s storage function\n", "sCAL"); 449 png_debug1(1, "in %s storage function", "sCAL"); 450 479 451 if (png_ptr == NULL || info_ptr == NULL) 480 452 return; … … 483 455 484 456 length = png_strlen(swidth) + 1; 485 png_debug1(3, "allocating unit for info (%d bytes)\n", length); 457 png_debug1(3, "allocating unit for info (%u bytes)", 458 (unsigned int)length); 486 459 info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length); 487 460 if (info_ptr->scal_s_width == NULL) … … 494 467 495 468 length = png_strlen(sheight) + 1; 496 png_debug1(3, "allocating unit for info (%d bytes)\n", length); 469 png_debug1(3, "allocating unit for info (%u bytes)", 470 (unsigned int)length); 497 471 info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, length); 498 472 if (info_ptr->scal_s_height == NULL) 499 473 { 500 474 png_free (png_ptr, info_ptr->scal_s_width); 475 info_ptr->scal_s_width = NULL; 501 476 png_warning(png_ptr, 502 477 "Memory allocation failed while processing sCAL."); … … 518 493 png_uint_32 res_x, png_uint_32 res_y, int unit_type) 519 494 { 520 png_debug1(1, "in %s storage function\n", "pHYs"); 495 png_debug1(1, "in %s storage function", "pHYs"); 496 521 497 if (png_ptr == NULL || info_ptr == NULL) 522 498 return; … … 534 510 { 535 511 536 png_debug1(1, "in %s storage function\n", "PLTE"); 512 png_debug1(1, "in %s storage function", "PLTE"); 513 537 514 if (png_ptr == NULL || info_ptr == NULL) 538 515 return; 539 516 540 517 if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH) 541 542 518 { 519 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) 543 520 png_error(png_ptr, "Invalid palette length"); 544 545 521 else 522 { 546 523 png_warning(png_ptr, "Invalid palette length"); 547 524 return; 548 549 525 } 526 } 550 527 551 528 /* … … 559 536 560 537 /* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead 561 of num_palette entries, 562 in case of an invalid PNG file that has too-large sample values. */ 538 * of num_palette entries, in case of an invalid PNG file that has 539 * too-large sample values. 540 */ 563 541 png_ptr->palette = (png_colorp)png_malloc(png_ptr, 564 542 PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color)); 565 543 png_memset(png_ptr->palette, 0, PNG_MAX_PALETTE_LENGTH * 566 544 png_sizeof(png_color)); 567 png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof 545 png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof(png_color)); 568 546 info_ptr->palette = png_ptr->palette; 569 547 info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; … … 583 561 png_color_8p sig_bit) 584 562 { 585 png_debug1(1, "in %s storage function\n", "sBIT"); 586 if (png_ptr == NULL || info_ptr == NULL) 587 return; 588 589 png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof (png_color_8)); 563 png_debug1(1, "in %s storage function", "sBIT"); 564 565 if (png_ptr == NULL || info_ptr == NULL) 566 return; 567 568 png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof(png_color_8)); 590 569 info_ptr->valid |= PNG_INFO_sBIT; 591 570 } … … 596 575 png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent) 597 576 { 598 png_debug1(1, "in %s storage function\n", "sRGB"); 577 png_debug1(1, "in %s storage function", "sRGB"); 578 599 579 if (png_ptr == NULL || info_ptr == NULL) 600 580 return; … … 620 600 float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; 621 601 #endif 622 #ifdef PNG_FIXED_POINT_SUPPORTED623 602 png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, 624 603 int_green_y, int_blue_x, int_blue_y; 625 604 #endif 626 #endif 627 png_debug1(1, "in %s storage function\n", "sRGB_gAMA_and_cHRM"); 605 png_debug1(1, "in %s storage function", "sRGB_gAMA_and_cHRM"); 606 628 607 if (png_ptr == NULL || info_ptr == NULL) 629 608 return; … … 643 622 644 623 #if defined(PNG_cHRM_SUPPORTED) 645 #ifdef PNG_FIXED_POINT_SUPPORTED646 624 int_white_x = 31270L; 647 625 int_white_y = 32900L; … … 653 631 int_blue_y = 6000L; 654 632 655 png_set_cHRM_fixed(png_ptr, info_ptr,656 int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y,657 int_blue_x, int_blue_y);658 #endif659 633 #ifdef PNG_FLOATING_POINT_SUPPORTED 660 634 white_x = (float).3127; … … 666 640 blue_x = (float).15; 667 641 blue_y = (float).06; 668 669 png_set_cHRM(png_ptr, info_ptr, 670 white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); 671 #endif 672 #endif 673 } 674 #endif 642 #endif 643 644 #if !defined(PNG_NO_CHECK_cHRM) 645 if (png_check_cHRM_fixed(png_ptr, 646 int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, 647 int_green_y, int_blue_x, int_blue_y)) 648 #endif 649 { 650 #ifdef PNG_FIXED_POINT_SUPPORTED 651 png_set_cHRM_fixed(png_ptr, info_ptr, 652 int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, 653 int_green_y, int_blue_x, int_blue_y); 654 #endif 655 #ifdef PNG_FLOATING_POINT_SUPPORTED 656 png_set_cHRM(png_ptr, info_ptr, 657 white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); 658 #endif 659 } 660 #endif /* cHRM */ 661 } 662 #endif /* sRGB */ 675 663 676 664 … … 685 673 png_uint_32 length; 686 674 687 png_debug1(1, "in %s storage function\n", "iCCP"); 675 png_debug1(1, "in %s storage function", "iCCP"); 676 688 677 if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL) 689 678 return; … … 701 690 { 702 691 png_free (png_ptr, new_iccp_name); 703 png_warning(png_ptr, "Insufficient memory to process iCCP profile."); 692 png_warning(png_ptr, 693 "Insufficient memory to process iCCP profile."); 704 694 return; 705 695 } … … 724 714 void PNGAPI 725 715 png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, 726 int num_text)716 int num_text) 727 717 { 728 718 int ret; 729 ret =png_set_text_2(png_ptr, info_ptr, text_ptr, num_text);719 ret = png_set_text_2(png_ptr, info_ptr, text_ptr, num_text); 730 720 if (ret) 731 png_error(png_ptr, "Insufficient memory to store text");721 png_error(png_ptr, "Insufficient memory to store text"); 732 722 } 733 723 734 724 int /* PRIVATE */ 735 725 png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, 736 int num_text)726 int num_text) 737 727 { 738 728 int i; 739 729 740 png_debug1(1, "in %s storage function\n", (png_ptr->chunk_name[0] == '\0' ? 730 png_debug1(1, "in %s storage function", ((png_ptr == NULL || 731 png_ptr->chunk_name[0] == '\0') ? 741 732 "text" : (png_const_charp)png_ptr->chunk_name)); 742 733 … … 758 749 old_text = info_ptr->text; 759 750 info_ptr->text = (png_textp)png_malloc_warn(png_ptr, 760 (png_uint_32)(info_ptr->max_text * png_sizeof 751 (png_uint_32)(info_ptr->max_text * png_sizeof(png_text))); 761 752 if (info_ptr->text == NULL) 762 763 764 765 753 { 754 png_free(png_ptr, old_text); 755 return(1); 756 } 766 757 png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max * 767 758 png_sizeof(png_text))); … … 773 764 info_ptr->num_text = 0; 774 765 info_ptr->text = (png_textp)png_malloc_warn(png_ptr, 775 (png_uint_32)(info_ptr->max_text * png_sizeof 766 (png_uint_32)(info_ptr->max_text * png_sizeof(png_text))); 776 767 if (info_ptr->text == NULL) 777 return(1);768 return(1); 778 769 #ifdef PNG_FREE_ME_SUPPORTED 779 770 info_ptr->free_me |= PNG_FREE_TEXT; 780 771 #endif 781 772 } 782 png_debug1(3, "allocated %d entries for info_ptr->text \n",773 png_debug1(3, "allocated %d entries for info_ptr->text", 783 774 info_ptr->max_text); 784 775 } 785 776 for (i = 0; i < num_text; i++) 786 777 { 787 png_size_t text_length, key_len;788 png_size_t lang_len, lang_key_len;778 png_size_t text_length, key_len; 779 png_size_t lang_len, lang_key_len; 789 780 png_textp textp = &(info_ptr->text[info_ptr->num_text]); 790 781 … … 794 785 key_len = png_strlen(text_ptr[i].key); 795 786 796 if (text_ptr[i].compression <= 0)797 { 798 lang_len = 0;799 lang_key_len = 0;787 if (text_ptr[i].compression <= 0) 788 { 789 lang_len = 0; 790 lang_key_len = 0; 800 791 } 801 792 else 802 793 #ifdef PNG_iTXt_SUPPORTED 803 794 { 804 /* set iTXt data */805 if (text_ptr[i].lang != NULL)806 lang_len = png_strlen(text_ptr[i].lang);807 else808 lang_len = 0;809 if (text_ptr[i].lang_key != NULL)810 lang_key_len = png_strlen(text_ptr[i].lang_key);811 else812 lang_key_len = 0;795 /* Set iTXt data */ 796 if (text_ptr[i].lang != NULL) 797 lang_len = png_strlen(text_ptr[i].lang); 798 else 799 lang_len = 0; 800 if (text_ptr[i].lang_key != NULL) 801 lang_key_len = png_strlen(text_ptr[i].lang_key); 802 else 803 lang_key_len = 0; 813 804 } 814 805 #else 815 806 { 816 png_warning(png_ptr, "iTXt chunk not supported.");817 continue;807 png_warning(png_ptr, "iTXt chunk not supported."); 808 continue; 818 809 } 819 810 #endif … … 823 814 text_length = 0; 824 815 #ifdef PNG_iTXt_SUPPORTED 825 if (text_ptr[i].compression > 0)816 if (text_ptr[i].compression > 0) 826 817 textp->compression = PNG_ITXT_COMPRESSION_NONE; 827 818 else … … 836 827 837 828 textp->key = (png_charp)png_malloc_warn(png_ptr, 838 (png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4)); 829 (png_uint_32) 830 (key_len + text_length + lang_len + lang_key_len + 4)); 839 831 if (textp->key == NULL) 840 return(1);841 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),843 (int)textp->key);844 845 png_memcpy(textp->key, text_ptr[i].key, 846 847 *(textp->key +key_len) = '\0';832 return(1); 833 png_debug2(2, "Allocated %lu bytes at %x in png_set_text", 834 (png_uint_32) 835 (key_len + lang_len + lang_key_len + text_length + 4), 836 (int)textp->key); 837 838 png_memcpy(textp->key, text_ptr[i].key,(png_size_t)(key_len)); 839 *(textp->key + key_len) = '\0'; 848 840 #ifdef PNG_iTXt_SUPPORTED 849 841 if (text_ptr[i].compression > 0) 850 842 { 851 textp->lang =textp->key + key_len + 1;843 textp->lang = textp->key + key_len + 1; 852 844 png_memcpy(textp->lang, text_ptr[i].lang, lang_len); 853 *(textp->lang +lang_len) = '\0';854 textp->lang_key =textp->lang + lang_len + 1;845 *(textp->lang + lang_len) = '\0'; 846 textp->lang_key = textp->lang + lang_len + 1; 855 847 png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len); 856 *(textp->lang_key +lang_key_len) = '\0';857 textp->text =textp->lang_key + lang_key_len + 1;848 *(textp->lang_key + lang_key_len) = '\0'; 849 textp->text = textp->lang_key + lang_key_len + 1; 858 850 } 859 851 else … … 864 856 textp->lang_key=NULL; 865 857 #endif 866 textp->text =textp->key + key_len + 1;867 } 868 if (text_length)858 textp->text = textp->key + key_len + 1; 859 } 860 if (text_length) 869 861 png_memcpy(textp->text, text_ptr[i].text, 870 862 (png_size_t)(text_length)); 871 *(textp->text +text_length) = '\0';863 *(textp->text + text_length) = '\0'; 872 864 873 865 #ifdef PNG_iTXt_SUPPORTED 874 if (textp->compression > 0)866 if (textp->compression > 0) 875 867 { 876 868 textp->text_length = 0; … … 886 878 } 887 879 info_ptr->num_text++; 888 png_debug1(3, "transferred text chunk %d \n", info_ptr->num_text);880 png_debug1(3, "transferred text chunk %d", info_ptr->num_text); 889 881 } 890 882 return(0); … … 896 888 png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time) 897 889 { 898 png_debug1(1, "in %s storage function\n", "tIME"); 890 png_debug1(1, "in %s storage function", "tIME"); 891 899 892 if (png_ptr == NULL || info_ptr == NULL || 900 893 (png_ptr->mode & PNG_WROTE_tIME)) 901 894 return; 902 895 903 png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof 896 png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof(png_time)); 904 897 info_ptr->valid |= PNG_INFO_tIME; 905 898 } … … 911 904 png_bytep trans, int num_trans, png_color_16p trans_values) 912 905 { 913 png_debug1(1, "in %s storage function\n", "tRNS"); 914 if (png_ptr == NULL || info_ptr == NULL) 915 return; 916 917 png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); 906 png_debug1(1, "in %s storage function", "tRNS"); 907 908 if (png_ptr == NULL || info_ptr == NULL) 909 return; 918 910 919 911 if (trans != NULL) … … 925 917 */ 926 918 919 #ifdef PNG_FREE_ME_SUPPORTED 920 png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); 921 #endif 922 927 923 /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */ 928 924 png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr, 929 925 (png_uint_32)PNG_MAX_PALETTE_LENGTH); 930 926 if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH) 931 png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans);927 png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans); 932 928 } 933 929 … … 941 937 (int)trans_values->green > sample_max || 942 938 (int)trans_values->blue > sample_max))) 943 png_warning(png_ptr,944 "tRNS chunk has out-of-range samples for bit_depth");939 png_warning(png_ptr, 940 "tRNS chunk has out-of-range samples for bit_depth"); 945 941 png_memcpy(&(info_ptr->trans_values), trans_values, 946 942 png_sizeof(png_color_16)); 947 943 if (num_trans == 0) 948 num_trans = 1;944 num_trans = 1; 949 945 } 950 946 … … 966 962 png_set_sPLT(png_structp png_ptr, 967 963 png_infop info_ptr, png_sPLT_tp entries, int nentries) 968 { 969 png_sPLT_tp np; 970 int i; 971 972 if (png_ptr == NULL || info_ptr == NULL) 973 return; 974 975 np = (png_sPLT_tp)png_malloc_warn(png_ptr, 976 (info_ptr->splt_palettes_num + nentries) * png_sizeof(png_sPLT_t)); 977 if (np == NULL) 978 { 964 /* 965 * entries - array of png_sPLT_t structures 966 * to be added to the list of palettes 967 * in the info structure. 968 * nentries - number of palette structures to be 969 * added. 970 */ 971 { 972 png_sPLT_tp np; 973 int i; 974 975 if (png_ptr == NULL || info_ptr == NULL) 976 return; 977 978 np = (png_sPLT_tp)png_malloc_warn(png_ptr, 979 (info_ptr->splt_palettes_num + nentries) * 980 (png_uint_32)png_sizeof(png_sPLT_t)); 981 if (np == NULL) 982 { 979 983 png_warning(png_ptr, "No memory for sPLT palettes."); 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 984 return; 985 } 986 987 png_memcpy(np, info_ptr->splt_palettes, 988 info_ptr->splt_palettes_num * png_sizeof(png_sPLT_t)); 989 png_free(png_ptr, info_ptr->splt_palettes); 990 info_ptr->splt_palettes=NULL; 991 992 for (i = 0; i < nentries; i++) 993 { 994 png_sPLT_tp to = np + info_ptr->splt_palettes_num + i; 995 png_sPLT_tp from = entries + i; 996 png_uint_32 length; 997 998 length = png_strlen(from->name) + 1; 995 999 to->name = (png_charp)png_malloc_warn(png_ptr, length); 996 997 998 999 1000 1001 1002 1003 1004 from->nentries * png_sizeof(png_sPLT_entry));1005 1006 1007 1008 1009 png_free(png_ptr,to->name);1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1000 if (to->name == NULL) 1001 { 1002 png_warning(png_ptr, 1003 "Out of memory while processing sPLT chunk"); 1004 continue; 1005 } 1006 png_memcpy(to->name, from->name, length); 1007 to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr, 1008 (png_uint_32)(from->nentries * png_sizeof(png_sPLT_entry))); 1009 if (to->entries == NULL) 1010 { 1011 png_warning(png_ptr, 1012 "Out of memory while processing sPLT chunk"); 1013 png_free(png_ptr, to->name); 1014 to->name = NULL; 1015 continue; 1016 } 1017 png_memcpy(to->entries, from->entries, 1018 from->nentries * png_sizeof(png_sPLT_entry)); 1019 to->nentries = from->nentries; 1020 to->depth = from->depth; 1021 } 1022 1023 info_ptr->splt_palettes = np; 1024 info_ptr->splt_palettes_num += nentries; 1025 info_ptr->valid |= PNG_INFO_sPLT; 1022 1026 #ifdef PNG_FREE_ME_SUPPORTED 1023 1027 info_ptr->free_me |= PNG_FREE_SPLT; 1024 1028 #endif 1025 1029 } 1026 1030 #endif /* PNG_sPLT_SUPPORTED */ 1027 1031 1028 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)1032 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED 1029 1033 void PNGAPI 1030 1034 png_set_unknown_chunks(png_structp png_ptr, 1031 1035 png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns) 1032 1036 { 1033 png_unknown_chunkp np; 1034 int i; 1035 1036 if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0) 1037 return; 1038 1039 np = (png_unknown_chunkp)png_malloc_warn(png_ptr, 1040 (info_ptr->unknown_chunks_num + num_unknowns) * 1041 png_sizeof(png_unknown_chunk)); 1042 if (np == NULL) 1043 { 1044 png_warning(png_ptr, 1045 "Out of memory while processing unknown chunk."); 1046 return; 1047 } 1048 1049 png_memcpy(np, info_ptr->unknown_chunks, 1050 info_ptr->unknown_chunks_num * png_sizeof(png_unknown_chunk)); 1051 png_free(png_ptr, info_ptr->unknown_chunks); 1052 info_ptr->unknown_chunks=NULL; 1053 1054 for (i = 0; i < num_unknowns; i++) 1055 { 1056 png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i; 1057 png_unknown_chunkp from = unknowns + i; 1058 1059 png_memcpy((png_charp)to->name, 1060 (png_charp)from->name, 1061 png_sizeof(from->name)); 1062 to->name[png_sizeof(to->name)-1] = '\0'; 1063 to->size = from->size; 1064 /* note our location in the read or write sequence */ 1065 to->location = (png_byte)(png_ptr->mode & 0xff); 1066 1067 if (from->size == 0) 1068 to->data=NULL; 1069 else 1070 { 1071 to->data = (png_bytep)png_malloc_warn(png_ptr, from->size); 1072 if (to->data == NULL) 1073 { 1074 png_warning(png_ptr, 1075 "Out of memory while processing unknown chunk."); 1076 to->size=0; 1077 } 1078 else 1079 png_memcpy(to->data, from->data, from->size); 1080 } 1081 } 1082 1083 info_ptr->unknown_chunks = np; 1084 info_ptr->unknown_chunks_num += num_unknowns; 1037 png_unknown_chunkp np; 1038 int i; 1039 1040 if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0) 1041 return; 1042 1043 np = (png_unknown_chunkp)png_malloc_warn(png_ptr, 1044 (png_uint_32)((info_ptr->unknown_chunks_num + num_unknowns) * 1045 png_sizeof(png_unknown_chunk))); 1046 if (np == NULL) 1047 { 1048 png_warning(png_ptr, 1049 "Out of memory while processing unknown chunk."); 1050 return; 1051 } 1052 1053 png_memcpy(np, info_ptr->unknown_chunks, 1054 info_ptr->unknown_chunks_num * png_sizeof(png_unknown_chunk)); 1055 png_free(png_ptr, info_ptr->unknown_chunks); 1056 info_ptr->unknown_chunks=NULL; 1057 1058 for (i = 0; i < num_unknowns; i++) 1059 { 1060 png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i; 1061 png_unknown_chunkp from = unknowns + i; 1062 1063 png_memcpy((png_charp)to->name, 1064 (png_charp)from->name, 1065 png_sizeof(from->name)); 1066 to->name[png_sizeof(to->name)-1] = '\0'; 1067 to->size = from->size; 1068 /* Note our location in the read or write sequence */ 1069 to->location = (png_byte)(png_ptr->mode & 0xff); 1070 1071 if (from->size == 0) 1072 to->data=NULL; 1073 else 1074 { 1075 to->data = (png_bytep)png_malloc_warn(png_ptr, 1076 (png_uint_32)from->size); 1077 if (to->data == NULL) 1078 { 1079 png_warning(png_ptr, 1080 "Out of memory while processing unknown chunk."); 1081 to->size = 0; 1082 } 1083 else 1084 png_memcpy(to->data, from->data, from->size); 1085 } 1086 } 1087 1088 info_ptr->unknown_chunks = np; 1089 info_ptr->unknown_chunks_num += num_unknowns; 1085 1090 #ifdef PNG_FREE_ME_SUPPORTED 1086 1091 info_ptr->free_me |= PNG_FREE_UNKN; 1087 1092 #endif 1088 1093 } … … 1091 1096 int chunk, int location) 1092 1097 { 1093 if (png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk <1098 if (png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk < 1094 1099 (int)info_ptr->unknown_chunks_num) 1095 1100 info_ptr->unknown_chunks[chunk].location = (png_byte)location; … … 1105 1110 /* This function is deprecated in favor of png_permit_mng_features() 1106 1111 and will be removed from libpng-1.3.0 */ 1107 png_debug(1, "in png_permit_empty_plte, DEPRECATED.\n"); 1112 1113 png_debug(1, "in png_permit_empty_plte, DEPRECATED."); 1114 1108 1115 if (png_ptr == NULL) 1109 1116 return; … … 1119 1126 png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features) 1120 1127 { 1121 png_debug(1, "in png_permit_mng_features\n"); 1128 png_debug(1, "in png_permit_mng_features"); 1129 1122 1130 if (png_ptr == NULL) 1123 1131 return (png_uint_32)0; … … 1133 1141 chunk_list, int num_chunks) 1134 1142 { 1135 1136 1137 1138 1139 1140 1141 if (keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE)1142 png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS;1143 png_bytep new_list, p; 1144 int i, old_num_chunks; 1145 if (png_ptr == NULL) 1146 return; 1147 if (num_chunks == 0) 1148 { 1149 if (keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE) 1150 png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS; 1143 1151 else 1144 png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS;1145 1146 if (keep == PNG_HANDLE_CHUNK_ALWAYS)1147 png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS;1152 png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS; 1153 1154 if (keep == PNG_HANDLE_CHUNK_ALWAYS) 1155 png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS; 1148 1156 else 1149 png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS; 1150 return; 1151 } 1152 if (chunk_list == NULL) 1153 return; 1154 old_num_chunks=png_ptr->num_chunk_list; 1155 new_list=(png_bytep)png_malloc(png_ptr, 1156 (png_uint_32)(5*(num_chunks+old_num_chunks))); 1157 if(png_ptr->chunk_list != NULL) 1158 { 1159 png_memcpy(new_list, png_ptr->chunk_list, 1160 (png_size_t)(5*old_num_chunks)); 1161 png_free(png_ptr, png_ptr->chunk_list); 1162 png_ptr->chunk_list=NULL; 1163 } 1164 png_memcpy(new_list+5*old_num_chunks, chunk_list, 1165 (png_size_t)(5*num_chunks)); 1166 for (p=new_list+5*old_num_chunks+4, i=0; i<num_chunks; i++, p+=5) 1167 *p=(png_byte)keep; 1168 png_ptr->num_chunk_list=old_num_chunks+num_chunks; 1169 png_ptr->chunk_list=new_list; 1157 png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS; 1158 return; 1159 } 1160 if (chunk_list == NULL) 1161 return; 1162 old_num_chunks = png_ptr->num_chunk_list; 1163 new_list=(png_bytep)png_malloc(png_ptr, 1164 (png_uint_32) 1165 (5*(num_chunks + old_num_chunks))); 1166 if (png_ptr->chunk_list != NULL) 1167 { 1168 png_memcpy(new_list, png_ptr->chunk_list, 1169 (png_size_t)(5*old_num_chunks)); 1170 png_free(png_ptr, png_ptr->chunk_list); 1171 png_ptr->chunk_list=NULL; 1172 } 1173 png_memcpy(new_list + 5*old_num_chunks, chunk_list, 1174 (png_size_t)(5*num_chunks)); 1175 for (p = new_list + 5*old_num_chunks + 4, i = 0; i<num_chunks; i++, p += 5) 1176 *p=(png_byte)keep; 1177 png_ptr->num_chunk_list = old_num_chunks + num_chunks; 1178 png_ptr->chunk_list = new_list; 1170 1179 #ifdef PNG_FREE_ME_SUPPORTED 1171 1180 png_ptr->free_me |= PNG_FREE_LIST; 1172 1181 #endif 1173 1182 } … … 1179 1188 png_user_chunk_ptr read_user_chunk_fn) 1180 1189 { 1181 png_debug(1, "in png_set_read_user_chunk_fn\n"); 1190 png_debug(1, "in png_set_read_user_chunk_fn"); 1191 1182 1192 if (png_ptr == NULL) 1183 1193 return; 1194 1184 1195 png_ptr->read_user_chunk_fn = read_user_chunk_fn; 1185 1196 png_ptr->user_chunk_ptr = user_chunk_ptr; … … 1191 1202 png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers) 1192 1203 { 1193 png_debug1(1, "in %s storage function \n", "rows");1194 1195 if (png_ptr == NULL || info_ptr == NULL) 1196 return; 1197 1198 if (info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers))1204 png_debug1(1, "in %s storage function", "rows"); 1205 1206 if (png_ptr == NULL || info_ptr == NULL) 1207 return; 1208 1209 if (info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers)) 1199 1210 png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); 1200 1211 info_ptr->row_pointers = row_pointers; 1201 if (row_pointers)1212 if (row_pointers) 1202 1213 info_ptr->valid |= PNG_INFO_IDAT; 1203 1214 } … … 1206 1217 #ifdef PNG_WRITE_SUPPORTED 1207 1218 void PNGAPI 1208 png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size) 1219 png_set_compression_buffer_size(png_structp png_ptr, 1220 png_uint_32 size) 1209 1221 { 1210 1222 if (png_ptr == NULL) … … 1228 1240 #ifndef PNG_1_0_X 1229 1241 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED 1230 /* function was added to libpng 1.2.0 and should always exist by default */1242 /* Function was added to libpng 1.2.0 and should always exist by default */ 1231 1243 void PNGAPI 1232 1244 png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags) … … 1235 1247 if (png_ptr != NULL) 1236 1248 png_ptr->asm_flags = 0; 1237 } 1238 1239 /* this function was added to libpng 1.2.0 */ 1249 asm_flags = asm_flags; /* Quiet the compiler */ 1250 } 1251 1252 /* This function was added to libpng 1.2.0 */ 1240 1253 void PNGAPI 1241 1254 png_set_mmx_thresholds (png_structp png_ptr, … … 1246 1259 if (png_ptr == NULL) 1247 1260 return; 1261 /* Quiet the compiler */ 1262 mmx_bitdepth_threshold = mmx_bitdepth_threshold; 1263 mmx_rowbytes_threshold = mmx_rowbytes_threshold; 1248 1264 } 1249 1265 #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ 1250 1266 1251 1267 #ifdef PNG_SET_USER_LIMITS_SUPPORTED 1252 /* this function was added to libpng 1.2.6 */1268 /* This function was added to libpng 1.2.6 */ 1253 1269 void PNGAPI 1254 1270 png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max, 1255 1271 png_uint_32 user_height_max) 1256 1272 { 1257 /* Images with dimensions larger than these limits will be 1258 * rejected by png_set_IHDR(). To accept any PNG datastream 1259 * regardless of dimensions, set both limits to 0x7ffffffL. 1260 */ 1261 if(png_ptr == NULL) return; 1262 png_ptr->user_width_max = user_width_max; 1263 png_ptr->user_height_max = user_height_max; 1273 /* Images with dimensions larger than these limits will be 1274 * rejected by png_set_IHDR(). To accept any PNG datastream 1275 * regardless of dimensions, set both limits to 0x7ffffffL. 1276 */ 1277 if (png_ptr == NULL) 1278 return; 1279 png_ptr->user_width_max = user_width_max; 1280 png_ptr->user_height_max = user_height_max; 1264 1281 } 1265 1282 #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
Note:
See TracChangeset
for help on using the changeset viewer.