Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenpngset.c
Go to the documentation of this file.
00001 00002 /* pngset.c - storage of image information into info struct 00003 * 00004 * Last changed in libpng 1.5.7 [December 15, 2011] 00005 * Copyright (c) 1998-2011 Glenn Randers-Pehrson 00006 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 00007 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 00008 * 00009 * This code is released under the libpng license. 00010 * For conditions of distribution and use, see the disclaimer 00011 * and license in png.h 00012 * 00013 * The functions here are used during reads to store data from the file 00014 * into the info struct, and during writes to store application data 00015 * into the info struct for writing into the file. This abstracts the 00016 * info struct and allows us to change the structure in the future. 00017 */ 00018 00019 #include "pngpriv.h" 00020 00021 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 00022 00023 #ifdef PNG_bKGD_SUPPORTED 00024 void PNGAPI 00025 png_set_bKGD(png_structp png_ptr, png_infop info_ptr, 00026 png_const_color_16p background) 00027 { 00028 png_debug1(1, "in %s storage function", "bKGD"); 00029 00030 if (png_ptr == NULL || info_ptr == NULL) 00031 return; 00032 00033 png_memcpy(&(info_ptr->background), background, png_sizeof(png_color_16)); 00034 info_ptr->valid |= PNG_INFO_bKGD; 00035 } 00036 #endif 00037 00038 #ifdef PNG_cHRM_SUPPORTED 00039 void PNGFAPI 00040 png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, 00041 png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, 00042 png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, 00043 png_fixed_point blue_x, png_fixed_point blue_y) 00044 { 00045 png_debug1(1, "in %s storage function", "cHRM fixed"); 00046 00047 if (png_ptr == NULL || info_ptr == NULL) 00048 return; 00049 00050 # ifdef PNG_CHECK_cHRM_SUPPORTED 00051 if (png_check_cHRM_fixed(png_ptr, 00052 white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y)) 00053 # endif 00054 { 00055 info_ptr->x_white = white_x; 00056 info_ptr->y_white = white_y; 00057 info_ptr->x_red = red_x; 00058 info_ptr->y_red = red_y; 00059 info_ptr->x_green = green_x; 00060 info_ptr->y_green = green_y; 00061 info_ptr->x_blue = blue_x; 00062 info_ptr->y_blue = blue_y; 00063 info_ptr->valid |= PNG_INFO_cHRM; 00064 } 00065 } 00066 00067 void PNGFAPI 00068 png_set_cHRM_XYZ_fixed(png_structp png_ptr, png_infop info_ptr, 00069 png_fixed_point int_red_X, png_fixed_point int_red_Y, 00070 png_fixed_point int_red_Z, png_fixed_point int_green_X, 00071 png_fixed_point int_green_Y, png_fixed_point int_green_Z, 00072 png_fixed_point int_blue_X, png_fixed_point int_blue_Y, 00073 png_fixed_point int_blue_Z) 00074 { 00075 png_XYZ XYZ; 00076 png_xy xy; 00077 00078 png_debug1(1, "in %s storage function", "cHRM XYZ fixed"); 00079 00080 if (png_ptr == NULL || info_ptr == NULL) 00081 return; 00082 00083 XYZ.redX = int_red_X; 00084 XYZ.redY = int_red_Y; 00085 XYZ.redZ = int_red_Z; 00086 XYZ.greenX = int_green_X; 00087 XYZ.greenY = int_green_Y; 00088 XYZ.greenZ = int_green_Z; 00089 XYZ.blueX = int_blue_X; 00090 XYZ.blueY = int_blue_Y; 00091 XYZ.blueZ = int_blue_Z; 00092 00093 if (png_xy_from_XYZ(&xy, XYZ)) 00094 png_error(png_ptr, "XYZ values out of representable range"); 00095 00096 png_set_cHRM_fixed(png_ptr, info_ptr, xy.whitex, xy.whitey, xy.redx, xy.redy, 00097 xy.greenx, xy.greeny, xy.bluex, xy.bluey); 00098 } 00099 00100 # ifdef PNG_FLOATING_POINT_SUPPORTED 00101 void PNGAPI 00102 png_set_cHRM(png_structp png_ptr, png_infop info_ptr, 00103 double white_x, double white_y, double red_x, double red_y, 00104 double green_x, double green_y, double blue_x, double blue_y) 00105 { 00106 png_set_cHRM_fixed(png_ptr, info_ptr, 00107 png_fixed(png_ptr, white_x, "cHRM White X"), 00108 png_fixed(png_ptr, white_y, "cHRM White Y"), 00109 png_fixed(png_ptr, red_x, "cHRM Red X"), 00110 png_fixed(png_ptr, red_y, "cHRM Red Y"), 00111 png_fixed(png_ptr, green_x, "cHRM Green X"), 00112 png_fixed(png_ptr, green_y, "cHRM Green Y"), 00113 png_fixed(png_ptr, blue_x, "cHRM Blue X"), 00114 png_fixed(png_ptr, blue_y, "cHRM Blue Y")); 00115 } 00116 00117 void PNGAPI 00118 png_set_cHRM_XYZ(png_structp png_ptr, png_infop info_ptr, double red_X, 00119 double red_Y, double red_Z, double green_X, double green_Y, double green_Z, 00120 double blue_X, double blue_Y, double blue_Z) 00121 { 00122 png_set_cHRM_XYZ_fixed(png_ptr, info_ptr, 00123 png_fixed(png_ptr, red_X, "cHRM Red X"), 00124 png_fixed(png_ptr, red_Y, "cHRM Red Y"), 00125 png_fixed(png_ptr, red_Z, "cHRM Red Z"), 00126 png_fixed(png_ptr, green_X, "cHRM Red X"), 00127 png_fixed(png_ptr, green_Y, "cHRM Red Y"), 00128 png_fixed(png_ptr, green_Z, "cHRM Red Z"), 00129 png_fixed(png_ptr, blue_X, "cHRM Red X"), 00130 png_fixed(png_ptr, blue_Y, "cHRM Red Y"), 00131 png_fixed(png_ptr, blue_Z, "cHRM Red Z")); 00132 } 00133 # endif /* PNG_FLOATING_POINT_SUPPORTED */ 00134 00135 #endif /* PNG_cHRM_SUPPORTED */ 00136 00137 #ifdef PNG_gAMA_SUPPORTED 00138 void PNGFAPI 00139 png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point 00140 file_gamma) 00141 { 00142 png_debug1(1, "in %s storage function", "gAMA"); 00143 00144 if (png_ptr == NULL || info_ptr == NULL) 00145 return; 00146 00147 /* Changed in libpng-1.5.4 to limit the values to ensure overflow can't 00148 * occur. Since the fixed point representation is assymetrical it is 00149 * possible for 1/gamma to overflow the limit of 21474 and this means the 00150 * gamma value must be at least 5/100000 and hence at most 20000.0. For 00151 * safety the limits here are a little narrower. The values are 0.00016 to 00152 * 6250.0, which are truly ridiculous gammma values (and will produce 00153 * displays that are all black or all white.) 00154 */ 00155 if (file_gamma < 16 || file_gamma > 625000000) 00156 png_warning(png_ptr, "Out of range gamma value ignored"); 00157 00158 else 00159 { 00160 info_ptr->gamma = file_gamma; 00161 info_ptr->valid |= PNG_INFO_gAMA; 00162 } 00163 } 00164 00165 # ifdef PNG_FLOATING_POINT_SUPPORTED 00166 void PNGAPI 00167 png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma) 00168 { 00169 png_set_gAMA_fixed(png_ptr, info_ptr, png_fixed(png_ptr, file_gamma, 00170 "png_set_gAMA")); 00171 } 00172 # endif 00173 #endif 00174 00175 #ifdef PNG_hIST_SUPPORTED 00176 void PNGAPI 00177 png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_const_uint_16p hist) 00178 { 00179 int i; 00180 00181 png_debug1(1, "in %s storage function", "hIST"); 00182 00183 if (png_ptr == NULL || info_ptr == NULL) 00184 return; 00185 00186 if (info_ptr->num_palette == 0 || info_ptr->num_palette 00187 > PNG_MAX_PALETTE_LENGTH) 00188 { 00189 png_warning(png_ptr, 00190 "Invalid palette size, hIST allocation skipped"); 00191 00192 return; 00193 } 00194 00195 png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0); 00196 00197 /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in 00198 * version 1.2.1 00199 */ 00200 png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr, 00201 PNG_MAX_PALETTE_LENGTH * png_sizeof(png_uint_16)); 00202 00203 if (png_ptr->hist == NULL) 00204 { 00205 png_warning(png_ptr, "Insufficient memory for hIST chunk data"); 00206 return; 00207 } 00208 00209 for (i = 0; i < info_ptr->num_palette; i++) 00210 png_ptr->hist[i] = hist[i]; 00211 00212 info_ptr->hist = png_ptr->hist; 00213 info_ptr->valid |= PNG_INFO_hIST; 00214 info_ptr->free_me |= PNG_FREE_HIST; 00215 } 00216 #endif 00217 00218 void PNGAPI 00219 png_set_IHDR(png_structp png_ptr, png_infop info_ptr, 00220 png_uint_32 width, png_uint_32 height, int bit_depth, 00221 int color_type, int interlace_type, int compression_type, 00222 int filter_type) 00223 { 00224 png_debug1(1, "in %s storage function", "IHDR"); 00225 00226 if (png_ptr == NULL || info_ptr == NULL) 00227 return; 00228 00229 info_ptr->width = width; 00230 info_ptr->height = height; 00231 info_ptr->bit_depth = (png_byte)bit_depth; 00232 info_ptr->color_type = (png_byte)color_type; 00233 info_ptr->compression_type = (png_byte)compression_type; 00234 info_ptr->filter_type = (png_byte)filter_type; 00235 info_ptr->interlace_type = (png_byte)interlace_type; 00236 00237 png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height, 00238 info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type, 00239 info_ptr->compression_type, info_ptr->filter_type); 00240 00241 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) 00242 info_ptr->channels = 1; 00243 00244 else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) 00245 info_ptr->channels = 3; 00246 00247 else 00248 info_ptr->channels = 1; 00249 00250 if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) 00251 info_ptr->channels++; 00252 00253 info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth); 00254 00255 /* Check for potential overflow */ 00256 if (width > 00257 (PNG_UINT_32_MAX >> 3) /* 8-byte RRGGBBAA pixels */ 00258 - 48 /* bigrowbuf hack */ 00259 - 1 /* filter byte */ 00260 - 7*8 /* rounding of width to multiple of 8 pixels */ 00261 - 8) /* extra max_pixel_depth pad */ 00262 info_ptr->rowbytes = 0; 00263 else 00264 info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width); 00265 } 00266 00267 #ifdef PNG_oFFs_SUPPORTED 00268 void PNGAPI 00269 png_set_oFFs(png_structp png_ptr, png_infop info_ptr, 00270 png_int_32 offset_x, png_int_32 offset_y, int unit_type) 00271 { 00272 png_debug1(1, "in %s storage function", "oFFs"); 00273 00274 if (png_ptr == NULL || info_ptr == NULL) 00275 return; 00276 00277 info_ptr->x_offset = offset_x; 00278 info_ptr->y_offset = offset_y; 00279 info_ptr->offset_unit_type = (png_byte)unit_type; 00280 info_ptr->valid |= PNG_INFO_oFFs; 00281 } 00282 #endif 00283 00284 #ifdef PNG_pCAL_SUPPORTED 00285 void PNGAPI 00286 png_set_pCAL(png_structp png_ptr, png_infop info_ptr, 00287 png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type, 00288 int nparams, png_const_charp units, png_charpp params) 00289 { 00290 png_size_t length; 00291 int i; 00292 00293 png_debug1(1, "in %s storage function", "pCAL"); 00294 00295 if (png_ptr == NULL || info_ptr == NULL) 00296 return; 00297 00298 length = png_strlen(purpose) + 1; 00299 png_debug1(3, "allocating purpose for info (%lu bytes)", 00300 (unsigned long)length); 00301 00302 /* TODO: validate format of calibration name and unit name */ 00303 00304 /* Check that the type matches the specification. */ 00305 if (type < 0 || type > 3) 00306 png_error(png_ptr, "Invalid pCAL equation type"); 00307 00308 /* Validate params[nparams] */ 00309 for (i=0; i<nparams; ++i) 00310 if (!png_check_fp_string(params[i], png_strlen(params[i]))) 00311 png_error(png_ptr, "Invalid format for pCAL parameter"); 00312 00313 info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length); 00314 00315 if (info_ptr->pcal_purpose == NULL) 00316 { 00317 png_warning(png_ptr, "Insufficient memory for pCAL purpose"); 00318 return; 00319 } 00320 00321 png_memcpy(info_ptr->pcal_purpose, purpose, length); 00322 00323 png_debug(3, "storing X0, X1, type, and nparams in info"); 00324 info_ptr->pcal_X0 = X0; 00325 info_ptr->pcal_X1 = X1; 00326 info_ptr->pcal_type = (png_byte)type; 00327 info_ptr->pcal_nparams = (png_byte)nparams; 00328 00329 length = png_strlen(units) + 1; 00330 png_debug1(3, "allocating units for info (%lu bytes)", 00331 (unsigned long)length); 00332 00333 info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length); 00334 00335 if (info_ptr->pcal_units == NULL) 00336 { 00337 png_warning(png_ptr, "Insufficient memory for pCAL units"); 00338 return; 00339 } 00340 00341 png_memcpy(info_ptr->pcal_units, units, length); 00342 00343 info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr, 00344 (png_size_t)((nparams + 1) * png_sizeof(png_charp))); 00345 00346 if (info_ptr->pcal_params == NULL) 00347 { 00348 png_warning(png_ptr, "Insufficient memory for pCAL params"); 00349 return; 00350 } 00351 00352 png_memset(info_ptr->pcal_params, 0, (nparams + 1) * png_sizeof(png_charp)); 00353 00354 for (i = 0; i < nparams; i++) 00355 { 00356 length = png_strlen(params[i]) + 1; 00357 png_debug2(3, "allocating parameter %d for info (%lu bytes)", i, 00358 (unsigned long)length); 00359 00360 info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length); 00361 00362 if (info_ptr->pcal_params[i] == NULL) 00363 { 00364 png_warning(png_ptr, "Insufficient memory for pCAL parameter"); 00365 return; 00366 } 00367 00368 png_memcpy(info_ptr->pcal_params[i], params[i], length); 00369 } 00370 00371 info_ptr->valid |= PNG_INFO_pCAL; 00372 info_ptr->free_me |= PNG_FREE_PCAL; 00373 } 00374 #endif 00375 00376 #ifdef PNG_sCAL_SUPPORTED 00377 void PNGAPI 00378 png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr, 00379 int unit, png_const_charp swidth, png_const_charp sheight) 00380 { 00381 png_size_t lengthw = 0, lengthh = 0; 00382 00383 png_debug1(1, "in %s storage function", "sCAL"); 00384 00385 if (png_ptr == NULL || info_ptr == NULL) 00386 return; 00387 00388 /* Double check the unit (should never get here with an invalid 00389 * unit unless this is an API call.) 00390 */ 00391 if (unit != 1 && unit != 2) 00392 png_error(png_ptr, "Invalid sCAL unit"); 00393 00394 if (swidth == NULL || (lengthw = png_strlen(swidth)) == 0 || 00395 swidth[0] == 45 /* '-' */ || !png_check_fp_string(swidth, lengthw)) 00396 png_error(png_ptr, "Invalid sCAL width"); 00397 00398 if (sheight == NULL || (lengthh = png_strlen(sheight)) == 0 || 00399 sheight[0] == 45 /* '-' */ || !png_check_fp_string(sheight, lengthh)) 00400 png_error(png_ptr, "Invalid sCAL height"); 00401 00402 info_ptr->scal_unit = (png_byte)unit; 00403 00404 ++lengthw; 00405 00406 png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthw); 00407 00408 info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, lengthw); 00409 00410 if (info_ptr->scal_s_width == NULL) 00411 { 00412 png_warning(png_ptr, "Memory allocation failed while processing sCAL"); 00413 return; 00414 } 00415 00416 png_memcpy(info_ptr->scal_s_width, swidth, lengthw); 00417 00418 ++lengthh; 00419 00420 png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthh); 00421 00422 info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, lengthh); 00423 00424 if (info_ptr->scal_s_height == NULL) 00425 { 00426 png_free (png_ptr, info_ptr->scal_s_width); 00427 info_ptr->scal_s_width = NULL; 00428 00429 png_warning(png_ptr, "Memory allocation failed while processing sCAL"); 00430 return; 00431 } 00432 00433 png_memcpy(info_ptr->scal_s_height, sheight, lengthh); 00434 00435 info_ptr->valid |= PNG_INFO_sCAL; 00436 info_ptr->free_me |= PNG_FREE_SCAL; 00437 } 00438 00439 # ifdef PNG_FLOATING_POINT_SUPPORTED 00440 void PNGAPI 00441 png_set_sCAL(png_structp png_ptr, png_infop info_ptr, int unit, double width, 00442 double height) 00443 { 00444 png_debug1(1, "in %s storage function", "sCAL"); 00445 00446 /* Check the arguments. */ 00447 if (width <= 0) 00448 png_warning(png_ptr, "Invalid sCAL width ignored"); 00449 00450 else if (height <= 0) 00451 png_warning(png_ptr, "Invalid sCAL height ignored"); 00452 00453 else 00454 { 00455 /* Convert 'width' and 'height' to ASCII. */ 00456 char swidth[PNG_sCAL_MAX_DIGITS+1]; 00457 char sheight[PNG_sCAL_MAX_DIGITS+1]; 00458 00459 png_ascii_from_fp(png_ptr, swidth, sizeof swidth, width, 00460 PNG_sCAL_PRECISION); 00461 png_ascii_from_fp(png_ptr, sheight, sizeof sheight, height, 00462 PNG_sCAL_PRECISION); 00463 00464 png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight); 00465 } 00466 } 00467 # endif 00468 00469 # ifdef PNG_FIXED_POINT_SUPPORTED 00470 void PNGAPI 00471 png_set_sCAL_fixed(png_structp png_ptr, png_infop info_ptr, int unit, 00472 png_fixed_point width, png_fixed_point height) 00473 { 00474 png_debug1(1, "in %s storage function", "sCAL"); 00475 00476 /* Check the arguments. */ 00477 if (width <= 0) 00478 png_warning(png_ptr, "Invalid sCAL width ignored"); 00479 00480 else if (height <= 0) 00481 png_warning(png_ptr, "Invalid sCAL height ignored"); 00482 00483 else 00484 { 00485 /* Convert 'width' and 'height' to ASCII. */ 00486 char swidth[PNG_sCAL_MAX_DIGITS+1]; 00487 char sheight[PNG_sCAL_MAX_DIGITS+1]; 00488 00489 png_ascii_from_fixed(png_ptr, swidth, sizeof swidth, width); 00490 png_ascii_from_fixed(png_ptr, sheight, sizeof sheight, height); 00491 00492 png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight); 00493 } 00494 } 00495 # endif 00496 #endif 00497 00498 #ifdef PNG_pHYs_SUPPORTED 00499 void PNGAPI 00500 png_set_pHYs(png_structp png_ptr, png_infop info_ptr, 00501 png_uint_32 res_x, png_uint_32 res_y, int unit_type) 00502 { 00503 png_debug1(1, "in %s storage function", "pHYs"); 00504 00505 if (png_ptr == NULL || info_ptr == NULL) 00506 return; 00507 00508 info_ptr->x_pixels_per_unit = res_x; 00509 info_ptr->y_pixels_per_unit = res_y; 00510 info_ptr->phys_unit_type = (png_byte)unit_type; 00511 info_ptr->valid |= PNG_INFO_pHYs; 00512 } 00513 #endif 00514 00515 void PNGAPI 00516 png_set_PLTE(png_structp png_ptr, png_infop info_ptr, 00517 png_const_colorp palette, int num_palette) 00518 { 00519 00520 png_debug1(1, "in %s storage function", "PLTE"); 00521 00522 if (png_ptr == NULL || info_ptr == NULL) 00523 return; 00524 00525 if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH) 00526 { 00527 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) 00528 png_error(png_ptr, "Invalid palette length"); 00529 00530 else 00531 { 00532 png_warning(png_ptr, "Invalid palette length"); 00533 return; 00534 } 00535 } 00536 00537 /* It may not actually be necessary to set png_ptr->palette here; 00538 * we do it for backward compatibility with the way the png_handle_tRNS 00539 * function used to do the allocation. 00540 */ 00541 png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0); 00542 00543 /* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead 00544 * of num_palette entries, in case of an invalid PNG file that has 00545 * too-large sample values. 00546 */ 00547 png_ptr->palette = (png_colorp)png_calloc(png_ptr, 00548 PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color)); 00549 00550 png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof(png_color)); 00551 info_ptr->palette = png_ptr->palette; 00552 info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; 00553 00554 info_ptr->free_me |= PNG_FREE_PLTE; 00555 00556 info_ptr->valid |= PNG_INFO_PLTE; 00557 } 00558 00559 #ifdef PNG_sBIT_SUPPORTED 00560 void PNGAPI 00561 png_set_sBIT(png_structp png_ptr, png_infop info_ptr, 00562 png_const_color_8p sig_bit) 00563 { 00564 png_debug1(1, "in %s storage function", "sBIT"); 00565 00566 if (png_ptr == NULL || info_ptr == NULL) 00567 return; 00568 00569 png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof(png_color_8)); 00570 info_ptr->valid |= PNG_INFO_sBIT; 00571 } 00572 #endif 00573 00574 #ifdef PNG_sRGB_SUPPORTED 00575 void PNGAPI 00576 png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int srgb_intent) 00577 { 00578 png_debug1(1, "in %s storage function", "sRGB"); 00579 00580 if (png_ptr == NULL || info_ptr == NULL) 00581 return; 00582 00583 info_ptr->srgb_intent = (png_byte)srgb_intent; 00584 info_ptr->valid |= PNG_INFO_sRGB; 00585 } 00586 00587 void PNGAPI 00588 png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr, 00589 int srgb_intent) 00590 { 00591 png_debug1(1, "in %s storage function", "sRGB_gAMA_and_cHRM"); 00592 00593 if (png_ptr == NULL || info_ptr == NULL) 00594 return; 00595 00596 png_set_sRGB(png_ptr, info_ptr, srgb_intent); 00597 00598 # ifdef PNG_gAMA_SUPPORTED 00599 png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_sRGB_INVERSE); 00600 # endif 00601 00602 # ifdef PNG_cHRM_SUPPORTED 00603 png_set_cHRM_fixed(png_ptr, info_ptr, 00604 /* color x y */ 00605 /* white */ 31270, 32900, 00606 /* red */ 64000, 33000, 00607 /* green */ 30000, 60000, 00608 /* blue */ 15000, 6000 00609 ); 00610 # endif /* cHRM */ 00611 } 00612 #endif /* sRGB */ 00613 00614 00615 #ifdef PNG_iCCP_SUPPORTED 00616 void PNGAPI 00617 png_set_iCCP(png_structp png_ptr, png_infop info_ptr, 00618 png_const_charp name, int compression_type, 00619 png_const_bytep profile, png_uint_32 proflen) 00620 { 00621 png_charp new_iccp_name; 00622 png_bytep new_iccp_profile; 00623 png_size_t length; 00624 00625 png_debug1(1, "in %s storage function", "iCCP"); 00626 00627 if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL) 00628 return; 00629 00630 length = png_strlen(name)+1; 00631 new_iccp_name = (png_charp)png_malloc_warn(png_ptr, length); 00632 00633 if (new_iccp_name == NULL) 00634 { 00635 png_warning(png_ptr, "Insufficient memory to process iCCP chunk"); 00636 return; 00637 } 00638 00639 png_memcpy(new_iccp_name, name, length); 00640 new_iccp_profile = (png_bytep)png_malloc_warn(png_ptr, proflen); 00641 00642 if (new_iccp_profile == NULL) 00643 { 00644 png_free (png_ptr, new_iccp_name); 00645 png_warning(png_ptr, 00646 "Insufficient memory to process iCCP profile"); 00647 return; 00648 } 00649 00650 png_memcpy(new_iccp_profile, profile, (png_size_t)proflen); 00651 00652 png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0); 00653 00654 info_ptr->iccp_proflen = proflen; 00655 info_ptr->iccp_name = new_iccp_name; 00656 info_ptr->iccp_profile = new_iccp_profile; 00657 /* Compression is always zero but is here so the API and info structure 00658 * does not have to change if we introduce multiple compression types 00659 */ 00660 info_ptr->iccp_compression = (png_byte)compression_type; 00661 info_ptr->free_me |= PNG_FREE_ICCP; 00662 info_ptr->valid |= PNG_INFO_iCCP; 00663 } 00664 #endif 00665 00666 #ifdef PNG_TEXT_SUPPORTED 00667 void PNGAPI 00668 png_set_text(png_structp png_ptr, png_infop info_ptr, png_const_textp text_ptr, 00669 int num_text) 00670 { 00671 int ret; 00672 ret = png_set_text_2(png_ptr, info_ptr, text_ptr, num_text); 00673 00674 if (ret) 00675 png_error(png_ptr, "Insufficient memory to store text"); 00676 } 00677 00678 int /* PRIVATE */ 00679 png_set_text_2(png_structp png_ptr, png_infop info_ptr, 00680 png_const_textp text_ptr, int num_text) 00681 { 00682 int i; 00683 00684 png_debug1(1, "in %lx storage function", png_ptr == NULL ? "unexpected" : 00685 (unsigned long)png_ptr->chunk_name); 00686 00687 if (png_ptr == NULL || info_ptr == NULL || num_text == 0) 00688 return(0); 00689 00690 /* Make sure we have enough space in the "text" array in info_struct 00691 * to hold all of the incoming text_ptr objects. 00692 */ 00693 if (info_ptr->num_text + num_text > info_ptr->max_text) 00694 { 00695 if (info_ptr->text != NULL) 00696 { 00697 png_textp old_text; 00698 int old_max; 00699 00700 old_max = info_ptr->max_text; 00701 info_ptr->max_text = info_ptr->num_text + num_text + 8; 00702 old_text = info_ptr->text; 00703 info_ptr->text = (png_textp)png_malloc_warn(png_ptr, 00704 (png_size_t)(info_ptr->max_text * png_sizeof(png_text))); 00705 00706 if (info_ptr->text == NULL) 00707 { 00708 png_free(png_ptr, old_text); 00709 return(1); 00710 } 00711 00712 png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max * 00713 png_sizeof(png_text))); 00714 png_free(png_ptr, old_text); 00715 } 00716 00717 else 00718 { 00719 info_ptr->max_text = num_text + 8; 00720 info_ptr->num_text = 0; 00721 info_ptr->text = (png_textp)png_malloc_warn(png_ptr, 00722 (png_size_t)(info_ptr->max_text * png_sizeof(png_text))); 00723 if (info_ptr->text == NULL) 00724 return(1); 00725 info_ptr->free_me |= PNG_FREE_TEXT; 00726 } 00727 00728 png_debug1(3, "allocated %d entries for info_ptr->text", 00729 info_ptr->max_text); 00730 } 00731 for (i = 0; i < num_text; i++) 00732 { 00733 png_size_t text_length, key_len; 00734 png_size_t lang_len, lang_key_len; 00735 png_textp textp = &(info_ptr->text[info_ptr->num_text]); 00736 00737 if (text_ptr[i].key == NULL) 00738 continue; 00739 00740 if (text_ptr[i].compression < PNG_TEXT_COMPRESSION_NONE || 00741 text_ptr[i].compression >= PNG_TEXT_COMPRESSION_LAST) 00742 { 00743 png_warning(png_ptr, "text compression mode is out of range"); 00744 continue; 00745 } 00746 00747 key_len = png_strlen(text_ptr[i].key); 00748 00749 if (text_ptr[i].compression <= 0) 00750 { 00751 lang_len = 0; 00752 lang_key_len = 0; 00753 } 00754 00755 else 00756 # ifdef PNG_iTXt_SUPPORTED 00757 { 00758 /* Set iTXt data */ 00759 00760 if (text_ptr[i].lang != NULL) 00761 lang_len = png_strlen(text_ptr[i].lang); 00762 00763 else 00764 lang_len = 0; 00765 00766 if (text_ptr[i].lang_key != NULL) 00767 lang_key_len = png_strlen(text_ptr[i].lang_key); 00768 00769 else 00770 lang_key_len = 0; 00771 } 00772 # else /* PNG_iTXt_SUPPORTED */ 00773 { 00774 png_warning(png_ptr, "iTXt chunk not supported"); 00775 continue; 00776 } 00777 # endif 00778 00779 if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0') 00780 { 00781 text_length = 0; 00782 # ifdef PNG_iTXt_SUPPORTED 00783 if (text_ptr[i].compression > 0) 00784 textp->compression = PNG_ITXT_COMPRESSION_NONE; 00785 00786 else 00787 # endif 00788 textp->compression = PNG_TEXT_COMPRESSION_NONE; 00789 } 00790 00791 else 00792 { 00793 text_length = png_strlen(text_ptr[i].text); 00794 textp->compression = text_ptr[i].compression; 00795 } 00796 00797 textp->key = (png_charp)png_malloc_warn(png_ptr, 00798 (png_size_t) 00799 (key_len + text_length + lang_len + lang_key_len + 4)); 00800 00801 if (textp->key == NULL) 00802 return(1); 00803 00804 png_debug2(2, "Allocated %lu bytes at %p in png_set_text", 00805 (unsigned long)(png_uint_32) 00806 (key_len + lang_len + lang_key_len + text_length + 4), 00807 textp->key); 00808 00809 png_memcpy(textp->key, text_ptr[i].key,(png_size_t)(key_len)); 00810 *(textp->key + key_len) = '\0'; 00811 00812 if (text_ptr[i].compression > 0) 00813 { 00814 textp->lang = textp->key + key_len + 1; 00815 png_memcpy(textp->lang, text_ptr[i].lang, lang_len); 00816 *(textp->lang + lang_len) = '\0'; 00817 textp->lang_key = textp->lang + lang_len + 1; 00818 png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len); 00819 *(textp->lang_key + lang_key_len) = '\0'; 00820 textp->text = textp->lang_key + lang_key_len + 1; 00821 } 00822 00823 else 00824 { 00825 textp->lang=NULL; 00826 textp->lang_key=NULL; 00827 textp->text = textp->key + key_len + 1; 00828 } 00829 00830 if (text_length) 00831 png_memcpy(textp->text, text_ptr[i].text, 00832 (png_size_t)(text_length)); 00833 00834 *(textp->text + text_length) = '\0'; 00835 00836 # ifdef PNG_iTXt_SUPPORTED 00837 if (textp->compression > 0) 00838 { 00839 textp->text_length = 0; 00840 textp->itxt_length = text_length; 00841 } 00842 00843 else 00844 # endif 00845 { 00846 textp->text_length = text_length; 00847 textp->itxt_length = 0; 00848 } 00849 00850 info_ptr->num_text++; 00851 png_debug1(3, "transferred text chunk %d", info_ptr->num_text); 00852 } 00853 return(0); 00854 } 00855 #endif 00856 00857 #ifdef PNG_tIME_SUPPORTED 00858 void PNGAPI 00859 png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_const_timep mod_time) 00860 { 00861 png_debug1(1, "in %s storage function", "tIME"); 00862 00863 if (png_ptr == NULL || info_ptr == NULL || 00864 (png_ptr->mode & PNG_WROTE_tIME)) 00865 return; 00866 00867 if (mod_time->month == 0 || mod_time->month > 12 || 00868 mod_time->day == 0 || mod_time->day > 31 || 00869 mod_time->hour > 23 || mod_time->minute > 59 || 00870 mod_time->second > 60) 00871 { 00872 png_warning(png_ptr, "Ignoring invalid time value"); 00873 return; 00874 } 00875 00876 png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof(png_time)); 00877 info_ptr->valid |= PNG_INFO_tIME; 00878 } 00879 #endif 00880 00881 #ifdef PNG_tRNS_SUPPORTED 00882 void PNGAPI 00883 png_set_tRNS(png_structp png_ptr, png_infop info_ptr, 00884 png_const_bytep trans_alpha, int num_trans, png_const_color_16p trans_color) 00885 { 00886 png_debug1(1, "in %s storage function", "tRNS"); 00887 00888 if (png_ptr == NULL || info_ptr == NULL) 00889 return; 00890 00891 if (trans_alpha != NULL) 00892 { 00893 /* It may not actually be necessary to set png_ptr->trans_alpha here; 00894 * we do it for backward compatibility with the way the png_handle_tRNS 00895 * function used to do the allocation. 00896 */ 00897 00898 png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); 00899 00900 /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */ 00901 png_ptr->trans_alpha = info_ptr->trans_alpha = 00902 (png_bytep)png_malloc(png_ptr, (png_size_t)PNG_MAX_PALETTE_LENGTH); 00903 00904 if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH) 00905 png_memcpy(info_ptr->trans_alpha, trans_alpha, (png_size_t)num_trans); 00906 } 00907 00908 if (trans_color != NULL) 00909 { 00910 int sample_max = (1 << info_ptr->bit_depth); 00911 00912 if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY && 00913 (int)trans_color->gray > sample_max) || 00914 (info_ptr->color_type == PNG_COLOR_TYPE_RGB && 00915 ((int)trans_color->red > sample_max || 00916 (int)trans_color->green > sample_max || 00917 (int)trans_color->blue > sample_max))) 00918 png_warning(png_ptr, 00919 "tRNS chunk has out-of-range samples for bit_depth"); 00920 00921 png_memcpy(&(info_ptr->trans_color), trans_color, 00922 png_sizeof(png_color_16)); 00923 00924 if (num_trans == 0) 00925 num_trans = 1; 00926 } 00927 00928 info_ptr->num_trans = (png_uint_16)num_trans; 00929 00930 if (num_trans != 0) 00931 { 00932 info_ptr->valid |= PNG_INFO_tRNS; 00933 info_ptr->free_me |= PNG_FREE_TRNS; 00934 } 00935 } 00936 #endif 00937 00938 #ifdef PNG_sPLT_SUPPORTED 00939 void PNGAPI 00940 png_set_sPLT(png_structp png_ptr, 00941 png_infop info_ptr, png_const_sPLT_tp entries, int nentries) 00942 /* 00943 * entries - array of png_sPLT_t structures 00944 * to be added to the list of palettes 00945 * in the info structure. 00946 * 00947 * nentries - number of palette structures to be 00948 * added. 00949 */ 00950 { 00951 png_sPLT_tp np; 00952 int i; 00953 00954 if (png_ptr == NULL || info_ptr == NULL) 00955 return; 00956 00957 np = (png_sPLT_tp)png_malloc_warn(png_ptr, 00958 (info_ptr->splt_palettes_num + nentries) * 00959 (png_size_t)png_sizeof(png_sPLT_t)); 00960 00961 if (np == NULL) 00962 { 00963 png_warning(png_ptr, "No memory for sPLT palettes"); 00964 return; 00965 } 00966 00967 png_memcpy(np, info_ptr->splt_palettes, 00968 info_ptr->splt_palettes_num * png_sizeof(png_sPLT_t)); 00969 00970 png_free(png_ptr, info_ptr->splt_palettes); 00971 info_ptr->splt_palettes=NULL; 00972 00973 for (i = 0; i < nentries; i++) 00974 { 00975 png_sPLT_tp to = np + info_ptr->splt_palettes_num + i; 00976 png_const_sPLT_tp from = entries + i; 00977 png_size_t length; 00978 00979 length = png_strlen(from->name) + 1; 00980 to->name = (png_charp)png_malloc_warn(png_ptr, length); 00981 00982 if (to->name == NULL) 00983 { 00984 png_warning(png_ptr, 00985 "Out of memory while processing sPLT chunk"); 00986 continue; 00987 } 00988 00989 png_memcpy(to->name, from->name, length); 00990 to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr, 00991 from->nentries * png_sizeof(png_sPLT_entry)); 00992 00993 if (to->entries == NULL) 00994 { 00995 png_warning(png_ptr, 00996 "Out of memory while processing sPLT chunk"); 00997 png_free(png_ptr, to->name); 00998 to->name = NULL; 00999 continue; 01000 } 01001 01002 png_memcpy(to->entries, from->entries, 01003 from->nentries * png_sizeof(png_sPLT_entry)); 01004 01005 to->nentries = from->nentries; 01006 to->depth = from->depth; 01007 } 01008 01009 info_ptr->splt_palettes = np; 01010 info_ptr->splt_palettes_num += nentries; 01011 info_ptr->valid |= PNG_INFO_sPLT; 01012 info_ptr->free_me |= PNG_FREE_SPLT; 01013 } 01014 #endif /* PNG_sPLT_SUPPORTED */ 01015 01016 #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED 01017 void PNGAPI 01018 png_set_unknown_chunks(png_structp png_ptr, 01019 png_infop info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns) 01020 { 01021 png_unknown_chunkp np; 01022 int i; 01023 01024 if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0) 01025 return; 01026 01027 np = (png_unknown_chunkp)png_malloc_warn(png_ptr, 01028 (png_size_t)(info_ptr->unknown_chunks_num + num_unknowns) * 01029 png_sizeof(png_unknown_chunk)); 01030 01031 if (np == NULL) 01032 { 01033 png_warning(png_ptr, 01034 "Out of memory while processing unknown chunk"); 01035 return; 01036 } 01037 01038 png_memcpy(np, info_ptr->unknown_chunks, 01039 (png_size_t)info_ptr->unknown_chunks_num * 01040 png_sizeof(png_unknown_chunk)); 01041 01042 png_free(png_ptr, info_ptr->unknown_chunks); 01043 info_ptr->unknown_chunks = NULL; 01044 01045 for (i = 0; i < num_unknowns; i++) 01046 { 01047 png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i; 01048 png_const_unknown_chunkp from = unknowns + i; 01049 01050 png_memcpy(to->name, from->name, png_sizeof(from->name)); 01051 to->name[png_sizeof(to->name)-1] = '\0'; 01052 to->size = from->size; 01053 01054 /* Note our location in the read or write sequence */ 01055 to->location = (png_byte)(png_ptr->mode & 0xff); 01056 01057 if (from->size == 0) 01058 to->data=NULL; 01059 01060 else 01061 { 01062 to->data = (png_bytep)png_malloc_warn(png_ptr, 01063 (png_size_t)from->size); 01064 01065 if (to->data == NULL) 01066 { 01067 png_warning(png_ptr, 01068 "Out of memory while processing unknown chunk"); 01069 to->size = 0; 01070 } 01071 01072 else 01073 png_memcpy(to->data, from->data, from->size); 01074 } 01075 } 01076 01077 info_ptr->unknown_chunks = np; 01078 info_ptr->unknown_chunks_num += num_unknowns; 01079 info_ptr->free_me |= PNG_FREE_UNKN; 01080 } 01081 01082 void PNGAPI 01083 png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr, 01084 int chunk, int location) 01085 { 01086 if (png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk < 01087 info_ptr->unknown_chunks_num) 01088 info_ptr->unknown_chunks[chunk].location = (png_byte)location; 01089 } 01090 #endif 01091 01092 01093 #ifdef PNG_MNG_FEATURES_SUPPORTED 01094 png_uint_32 PNGAPI 01095 png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features) 01096 { 01097 png_debug(1, "in png_permit_mng_features"); 01098 01099 if (png_ptr == NULL) 01100 return (png_uint_32)0; 01101 01102 png_ptr->mng_features_permitted = 01103 (png_byte)(mng_features & PNG_ALL_MNG_FEATURES); 01104 01105 return (png_uint_32)png_ptr->mng_features_permitted; 01106 } 01107 #endif 01108 01109 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED 01110 void PNGAPI 01111 png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_const_bytep 01112 chunk_list, int num_chunks) 01113 { 01114 png_bytep new_list, p; 01115 int i, old_num_chunks; 01116 if (png_ptr == NULL) 01117 return; 01118 01119 if (num_chunks == 0) 01120 { 01121 if (keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE) 01122 png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS; 01123 01124 else 01125 png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS; 01126 01127 if (keep == PNG_HANDLE_CHUNK_ALWAYS) 01128 png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS; 01129 01130 else 01131 png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS; 01132 01133 return; 01134 } 01135 01136 if (chunk_list == NULL) 01137 return; 01138 01139 old_num_chunks = png_ptr->num_chunk_list; 01140 new_list=(png_bytep)png_malloc(png_ptr, 01141 (png_size_t)(5*(num_chunks + old_num_chunks))); 01142 01143 if (png_ptr->chunk_list != NULL) 01144 { 01145 png_memcpy(new_list, png_ptr->chunk_list, 01146 (png_size_t)(5*old_num_chunks)); 01147 png_free(png_ptr, png_ptr->chunk_list); 01148 png_ptr->chunk_list=NULL; 01149 } 01150 01151 png_memcpy(new_list + 5*old_num_chunks, chunk_list, 01152 (png_size_t)(5*num_chunks)); 01153 01154 for (p = new_list + 5*old_num_chunks + 4, i = 0; i<num_chunks; i++, p += 5) 01155 *p=(png_byte)keep; 01156 01157 png_ptr->num_chunk_list = old_num_chunks + num_chunks; 01158 png_ptr->chunk_list = new_list; 01159 png_ptr->free_me |= PNG_FREE_LIST; 01160 } 01161 #endif 01162 01163 #ifdef PNG_READ_USER_CHUNKS_SUPPORTED 01164 void PNGAPI 01165 png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr, 01166 png_user_chunk_ptr read_user_chunk_fn) 01167 { 01168 png_debug(1, "in png_set_read_user_chunk_fn"); 01169 01170 if (png_ptr == NULL) 01171 return; 01172 01173 png_ptr->read_user_chunk_fn = read_user_chunk_fn; 01174 png_ptr->user_chunk_ptr = user_chunk_ptr; 01175 } 01176 #endif 01177 01178 #ifdef PNG_INFO_IMAGE_SUPPORTED 01179 void PNGAPI 01180 png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers) 01181 { 01182 png_debug1(1, "in %s storage function", "rows"); 01183 01184 if (png_ptr == NULL || info_ptr == NULL) 01185 return; 01186 01187 if (info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers)) 01188 png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); 01189 01190 info_ptr->row_pointers = row_pointers; 01191 01192 if (row_pointers) 01193 info_ptr->valid |= PNG_INFO_IDAT; 01194 } 01195 #endif 01196 01197 void PNGAPI 01198 png_set_compression_buffer_size(png_structp png_ptr, png_size_t size) 01199 { 01200 if (png_ptr == NULL) 01201 return; 01202 01203 png_free(png_ptr, png_ptr->zbuf); 01204 01205 if (size > ZLIB_IO_MAX) 01206 { 01207 png_warning(png_ptr, "Attempt to set buffer size beyond max ignored"); 01208 png_ptr->zbuf_size = ZLIB_IO_MAX; 01209 size = ZLIB_IO_MAX; /* must fit */ 01210 } 01211 01212 else 01213 png_ptr->zbuf_size = (uInt)size; 01214 01215 png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size); 01216 01217 /* The following ensures a relatively safe failure if this gets called while 01218 * the buffer is actually in use. 01219 */ 01220 png_ptr->zstream.next_out = png_ptr->zbuf; 01221 png_ptr->zstream.avail_out = 0; 01222 png_ptr->zstream.avail_in = 0; 01223 } 01224 01225 void PNGAPI 01226 png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask) 01227 { 01228 if (png_ptr && info_ptr) 01229 info_ptr->valid &= ~mask; 01230 } 01231 01232 01233 01234 #ifdef PNG_SET_USER_LIMITS_SUPPORTED 01235 /* This function was added to libpng 1.2.6 */ 01236 void PNGAPI 01237 png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max, 01238 png_uint_32 user_height_max) 01239 { 01240 /* Images with dimensions larger than these limits will be 01241 * rejected by png_set_IHDR(). To accept any PNG datastream 01242 * regardless of dimensions, set both limits to 0x7ffffffL. 01243 */ 01244 if (png_ptr == NULL) 01245 return; 01246 01247 png_ptr->user_width_max = user_width_max; 01248 png_ptr->user_height_max = user_height_max; 01249 } 01250 01251 /* This function was added to libpng 1.4.0 */ 01252 void PNGAPI 01253 png_set_chunk_cache_max (png_structp png_ptr, 01254 png_uint_32 user_chunk_cache_max) 01255 { 01256 if (png_ptr) 01257 png_ptr->user_chunk_cache_max = user_chunk_cache_max; 01258 } 01259 01260 /* This function was added to libpng 1.4.1 */ 01261 void PNGAPI 01262 png_set_chunk_malloc_max (png_structp png_ptr, 01263 png_alloc_size_t user_chunk_malloc_max) 01264 { 01265 if (png_ptr) 01266 png_ptr->user_chunk_malloc_max = user_chunk_malloc_max; 01267 } 01268 #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ 01269 01270 01271 #ifdef PNG_BENIGN_ERRORS_SUPPORTED 01272 void PNGAPI 01273 png_set_benign_errors(png_structp png_ptr, int allowed) 01274 { 01275 png_debug(1, "in png_set_benign_errors"); 01276 01277 if (allowed) 01278 png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN; 01279 01280 else 01281 png_ptr->flags &= ~PNG_FLAG_BENIGN_ERRORS_WARN; 01282 } 01283 #endif /* PNG_BENIGN_ERRORS_SUPPORTED */ 01284 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ Generated on Sun May 27 2012 04:19:31 for ReactOS by
1.7.6.1
|