00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #define PNG_INTERNAL
00017 #include "png.h"
00018
00019 #if defined(PNG_bKGD_SUPPORTED)
00020 void PNGAPI
00021 png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background)
00022 {
00023 png_debug1(1, "in %s storage function\n", "bKGD");
00024 if (png_ptr == NULL || info_ptr == NULL)
00025 return;
00026
00027 png_memcpy(&(info_ptr->background), background, png_sizeof(png_color_16));
00028 info_ptr->valid |= PNG_INFO_bKGD;
00029 }
00030 #endif
00031
00032 #if defined(PNG_cHRM_SUPPORTED)
00033 #ifdef PNG_FLOATING_POINT_SUPPORTED
00034 void PNGAPI
00035 png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
00036 double white_x, double white_y, double red_x, double red_y,
00037 double green_x, double green_y, double blue_x, double blue_y)
00038 {
00039 png_debug1(1, "in %s storage function\n", "cHRM");
00040 if (png_ptr == NULL || info_ptr == NULL)
00041 return;
00042
00043 if (white_x < 0.0 || white_y < 0.0 ||
00044 red_x < 0.0 || red_y < 0.0 ||
00045 green_x < 0.0 || green_y < 0.0 ||
00046 blue_x < 0.0 || blue_y < 0.0)
00047 {
00048 png_warning(png_ptr,
00049 "Ignoring attempt to set negative chromaticity value");
00050 return;
00051 }
00052 if (white_x > 21474.83 || white_y > 21474.83 ||
00053 red_x > 21474.83 || red_y > 21474.83 ||
00054 green_x > 21474.83 || green_y > 21474.83 ||
00055 blue_x > 21474.83 || blue_y > 21474.83)
00056 {
00057 png_warning(png_ptr,
00058 "Ignoring attempt to set chromaticity value exceeding 21474.83");
00059 return;
00060 }
00061
00062 info_ptr->x_white = (float)white_x;
00063 info_ptr->y_white = (float)white_y;
00064 info_ptr->x_red = (float)red_x;
00065 info_ptr->y_red = (float)red_y;
00066 info_ptr->x_green = (float)green_x;
00067 info_ptr->y_green = (float)green_y;
00068 info_ptr->x_blue = (float)blue_x;
00069 info_ptr->y_blue = (float)blue_y;
00070 #ifdef PNG_FIXED_POINT_SUPPORTED
00071 info_ptr->int_x_white = (png_fixed_point)(white_x*100000.+0.5);
00072 info_ptr->int_y_white = (png_fixed_point)(white_y*100000.+0.5);
00073 info_ptr->int_x_red = (png_fixed_point)( red_x*100000.+0.5);
00074 info_ptr->int_y_red = (png_fixed_point)( red_y*100000.+0.5);
00075 info_ptr->int_x_green = (png_fixed_point)(green_x*100000.+0.5);
00076 info_ptr->int_y_green = (png_fixed_point)(green_y*100000.+0.5);
00077 info_ptr->int_x_blue = (png_fixed_point)( blue_x*100000.+0.5);
00078 info_ptr->int_y_blue = (png_fixed_point)( blue_y*100000.+0.5);
00079 #endif
00080 info_ptr->valid |= PNG_INFO_cHRM;
00081 }
00082 #endif
00083 #ifdef PNG_FIXED_POINT_SUPPORTED
00084 void PNGAPI
00085 png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
00086 png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x,
00087 png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y,
00088 png_fixed_point blue_x, png_fixed_point blue_y)
00089 {
00090 png_debug1(1, "in %s storage function\n", "cHRM");
00091 if (png_ptr == NULL || info_ptr == NULL)
00092 return;
00093
00094 if (white_x < 0 || white_y < 0 ||
00095 red_x < 0 || red_y < 0 ||
00096 green_x < 0 || green_y < 0 ||
00097 blue_x < 0 || blue_y < 0)
00098 {
00099 png_warning(png_ptr,
00100 "Ignoring attempt to set negative chromaticity value");
00101 return;
00102 }
00103 if (white_x > (double) PNG_UINT_31_MAX ||
00104 white_y > (double) PNG_UINT_31_MAX ||
00105 red_x > (double) PNG_UINT_31_MAX ||
00106 red_y > (double) PNG_UINT_31_MAX ||
00107 green_x > (double) PNG_UINT_31_MAX ||
00108 green_y > (double) PNG_UINT_31_MAX ||
00109 blue_x > (double) PNG_UINT_31_MAX ||
00110 blue_y > (double) PNG_UINT_31_MAX)
00111 {
00112 png_warning(png_ptr,
00113 "Ignoring attempt to set chromaticity value exceeding 21474.83");
00114 return;
00115 }
00116 info_ptr->int_x_white = white_x;
00117 info_ptr->int_y_white = white_y;
00118 info_ptr->int_x_red = red_x;
00119 info_ptr->int_y_red = red_y;
00120 info_ptr->int_x_green = green_x;
00121 info_ptr->int_y_green = green_y;
00122 info_ptr->int_x_blue = blue_x;
00123 info_ptr->int_y_blue = blue_y;
00124 #ifdef PNG_FLOATING_POINT_SUPPORTED
00125 info_ptr->x_white = (float)(white_x/100000.);
00126 info_ptr->y_white = (float)(white_y/100000.);
00127 info_ptr->x_red = (float)( red_x/100000.);
00128 info_ptr->y_red = (float)( red_y/100000.);
00129 info_ptr->x_green = (float)(green_x/100000.);
00130 info_ptr->y_green = (float)(green_y/100000.);
00131 info_ptr->x_blue = (float)( blue_x/100000.);
00132 info_ptr->y_blue = (float)( blue_y/100000.);
00133 #endif
00134 info_ptr->valid |= PNG_INFO_cHRM;
00135 }
00136 #endif
00137 #endif
00138
00139 #if defined(PNG_gAMA_SUPPORTED)
00140 #ifdef PNG_FLOATING_POINT_SUPPORTED
00141 void PNGAPI
00142 png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
00143 {
00144 double gamma;
00145 png_debug1(1, "in %s storage function\n", "gAMA");
00146 if (png_ptr == NULL || info_ptr == NULL)
00147 return;
00148
00149
00150 if (file_gamma > 21474.83)
00151 {
00152 png_warning(png_ptr, "Limiting gamma to 21474.83");
00153 gamma=21474.83;
00154 }
00155 else
00156 gamma=file_gamma;
00157 info_ptr->gamma = (float)gamma;
00158 #ifdef PNG_FIXED_POINT_SUPPORTED
00159 info_ptr->int_gamma = (int)(gamma*100000.+.5);
00160 #endif
00161 info_ptr->valid |= PNG_INFO_gAMA;
00162 if(gamma == 0.0)
00163 png_warning(png_ptr, "Setting gamma=0");
00164 }
00165 #endif
00166 void PNGAPI
00167 png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
00168 int_gamma)
00169 {
00170 png_fixed_point gamma;
00171
00172 png_debug1(1, "in %s storage function\n", "gAMA");
00173 if (png_ptr == NULL || info_ptr == NULL)
00174 return;
00175
00176 if (int_gamma > (png_fixed_point) PNG_UINT_31_MAX)
00177 {
00178 png_warning(png_ptr, "Limiting gamma to 21474.83");
00179 gamma=PNG_UINT_31_MAX;
00180 }
00181 else
00182 {
00183 if (int_gamma < 0)
00184 {
00185 png_warning(png_ptr, "Setting negative gamma to zero");
00186 gamma=0;
00187 }
00188 else
00189 gamma=int_gamma;
00190 }
00191 #ifdef PNG_FLOATING_POINT_SUPPORTED
00192 info_ptr->gamma = (float)(gamma/100000.);
00193 #endif
00194 #ifdef PNG_FIXED_POINT_SUPPORTED
00195 info_ptr->int_gamma = gamma;
00196 #endif
00197 info_ptr->valid |= PNG_INFO_gAMA;
00198 if(gamma == 0)
00199 png_warning(png_ptr, "Setting gamma=0");
00200 }
00201 #endif
00202
00203 #if defined(PNG_hIST_SUPPORTED)
00204 void PNGAPI
00205 png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
00206 {
00207 int i;
00208
00209 png_debug1(1, "in %s storage function\n", "hIST");
00210 if (png_ptr == NULL || info_ptr == NULL)
00211 return;
00212 if (info_ptr->num_palette == 0)
00213 {
00214 png_warning(png_ptr,
00215 "Palette size 0, hIST allocation skipped.");
00216 return;
00217 }
00218
00219 #ifdef PNG_FREE_ME_SUPPORTED
00220 png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0);
00221 #endif
00222
00223 png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr,
00224 (png_uint_32)(256 * png_sizeof (png_uint_16)));
00225 if (png_ptr->hist == NULL)
00226 {
00227 png_warning(png_ptr, "Insufficient memory for hIST chunk data.");
00228 return;
00229 }
00230
00231 for (i = 0; i < info_ptr->num_palette; i++)
00232 png_ptr->hist[i] = hist[i];
00233 info_ptr->hist = png_ptr->hist;
00234 info_ptr->valid |= PNG_INFO_hIST;
00235
00236 #ifdef PNG_FREE_ME_SUPPORTED
00237 info_ptr->free_me |= PNG_FREE_HIST;
00238 #else
00239 png_ptr->flags |= PNG_FLAG_FREE_HIST;
00240 #endif
00241 }
00242 #endif
00243
00244 void PNGAPI
00245 png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
00246 png_uint_32 width, png_uint_32 height, int bit_depth,
00247 int color_type, int interlace_type, int compression_type,
00248 int filter_type)
00249 {
00250 png_debug1(1, "in %s storage function\n", "IHDR");
00251 if (png_ptr == NULL || info_ptr == NULL)
00252 return;
00253
00254
00255 if (width == 0 || height == 0)
00256 png_error(png_ptr, "Image width or height is zero in IHDR");
00257 #ifdef PNG_SET_USER_LIMITS_SUPPORTED
00258 if (width > png_ptr->user_width_max || height > png_ptr->user_height_max)
00259 png_error(png_ptr, "image size exceeds user limits in IHDR");
00260 #else
00261 if (width > PNG_USER_WIDTH_MAX || height > PNG_USER_HEIGHT_MAX)
00262 png_error(png_ptr, "image size exceeds user limits in IHDR");
00263 #endif
00264 if (width > PNG_UINT_31_MAX || height > PNG_UINT_31_MAX)
00265 png_error(png_ptr, "Invalid image size in IHDR");
00266 if ( width > (PNG_UINT_32_MAX
00267 >> 3)
00268 - 64
00269 - 1
00270 - 7*8
00271 - 8)
00272 png_warning(png_ptr, "Width is too large for libpng to process pixels");
00273
00274
00275 if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 &&
00276 bit_depth != 8 && bit_depth != 16)
00277 png_error(png_ptr, "Invalid bit depth in IHDR");
00278
00279 if (color_type < 0 || color_type == 1 ||
00280 color_type == 5 || color_type > 6)
00281 png_error(png_ptr, "Invalid color type in IHDR");
00282
00283 if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) ||
00284 ((color_type == PNG_COLOR_TYPE_RGB ||
00285 color_type == PNG_COLOR_TYPE_GRAY_ALPHA ||
00286 color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8))
00287 png_error(png_ptr, "Invalid color type/bit depth combination in IHDR");
00288
00289 if (interlace_type >= PNG_INTERLACE_LAST)
00290 png_error(png_ptr, "Unknown interlace method in IHDR");
00291
00292 if (compression_type != PNG_COMPRESSION_TYPE_BASE)
00293 png_error(png_ptr, "Unknown compression method in IHDR");
00294
00295 #if defined(PNG_MNG_FEATURES_SUPPORTED)
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305 if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted)
00306 png_warning(png_ptr,"MNG features are not allowed in a PNG datastream\n");
00307 if(filter_type != PNG_FILTER_TYPE_BASE)
00308 {
00309 if(!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
00310 (filter_type == PNG_INTRAPIXEL_DIFFERENCING) &&
00311 ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) &&
00312 (color_type == PNG_COLOR_TYPE_RGB ||
00313 color_type == PNG_COLOR_TYPE_RGB_ALPHA)))
00314 png_error(png_ptr, "Unknown filter method in IHDR");
00315 if(png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)
00316 png_warning(png_ptr, "Invalid filter method in IHDR");
00317 }
00318 #else
00319 if(filter_type != PNG_FILTER_TYPE_BASE)
00320 png_error(png_ptr, "Unknown filter method in IHDR");
00321 #endif
00322
00323 info_ptr->width = width;
00324 info_ptr->height = height;
00325 info_ptr->bit_depth = (png_byte)bit_depth;
00326 info_ptr->color_type =(png_byte) color_type;
00327 info_ptr->compression_type = (png_byte)compression_type;
00328 info_ptr->filter_type = (png_byte)filter_type;
00329 info_ptr->interlace_type = (png_byte)interlace_type;
00330 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
00331 info_ptr->channels = 1;
00332 else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)
00333 info_ptr->channels = 3;
00334 else
00335 info_ptr->channels = 1;
00336 if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
00337 info_ptr->channels++;
00338 info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
00339
00340
00341 if ( width > (PNG_UINT_32_MAX
00342 >> 3)
00343 - 64
00344 - 1
00345 - 7*8
00346 - 8)
00347 info_ptr->rowbytes = (png_size_t)0;
00348 else
00349 info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,width);
00350 }
00351
00352 #if defined(PNG_oFFs_SUPPORTED)
00353 void PNGAPI
00354 png_set_oFFs(png_structp png_ptr, png_infop info_ptr,
00355 png_int_32 offset_x, png_int_32 offset_y, int unit_type)
00356 {
00357 png_debug1(1, "in %s storage function\n", "oFFs");
00358 if (png_ptr == NULL || info_ptr == NULL)
00359 return;
00360
00361 info_ptr->x_offset = offset_x;
00362 info_ptr->y_offset = offset_y;
00363 info_ptr->offset_unit_type = (png_byte)unit_type;
00364 info_ptr->valid |= PNG_INFO_oFFs;
00365 }
00366 #endif
00367
00368 #if defined(PNG_pCAL_SUPPORTED)
00369 void PNGAPI
00370 png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
00371 png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams,
00372 png_charp units, png_charpp params)
00373 {
00374 png_uint_32 length;
00375 int i;
00376
00377 png_debug1(1, "in %s storage function\n", "pCAL");
00378 if (png_ptr == NULL || info_ptr == NULL)
00379 return;
00380
00381 length = png_strlen(purpose) + 1;
00382 png_debug1(3, "allocating purpose for info (%lu bytes)\n", length);
00383 info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length);
00384 if (info_ptr->pcal_purpose == NULL)
00385 {
00386 png_warning(png_ptr, "Insufficient memory for pCAL purpose.");
00387 return;
00388 }
00389 png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length);
00390
00391 png_debug(3, "storing X0, X1, type, and nparams in info\n");
00392 info_ptr->pcal_X0 = X0;
00393 info_ptr->pcal_X1 = X1;
00394 info_ptr->pcal_type = (png_byte)type;
00395 info_ptr->pcal_nparams = (png_byte)nparams;
00396
00397 length = png_strlen(units) + 1;
00398 png_debug1(3, "allocating units for info (%lu bytes)\n", length);
00399 info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length);
00400 if (info_ptr->pcal_units == NULL)
00401 {
00402 png_warning(png_ptr, "Insufficient memory for pCAL units.");
00403 return;
00404 }
00405 png_memcpy(info_ptr->pcal_units, units, (png_size_t)length);
00406
00407 info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr,
00408 (png_uint_32)((nparams + 1) * png_sizeof(png_charp)));
00409 if (info_ptr->pcal_params == NULL)
00410 {
00411 png_warning(png_ptr, "Insufficient memory for pCAL params.");
00412 return;
00413 }
00414
00415 info_ptr->pcal_params[nparams] = NULL;
00416
00417 for (i = 0; i < nparams; i++)
00418 {
00419 length = png_strlen(params[i]) + 1;
00420 png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i, length);
00421 info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length);
00422 if (info_ptr->pcal_params[i] == NULL)
00423 {
00424 png_warning(png_ptr, "Insufficient memory for pCAL parameter.");
00425 return;
00426 }
00427 png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length);
00428 }
00429
00430 info_ptr->valid |= PNG_INFO_pCAL;
00431 #ifdef PNG_FREE_ME_SUPPORTED
00432 info_ptr->free_me |= PNG_FREE_PCAL;
00433 #endif
00434 }
00435 #endif
00436
00437 #if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED)
00438 #ifdef PNG_FLOATING_POINT_SUPPORTED
00439 void PNGAPI
00440 png_set_sCAL(png_structp png_ptr, png_infop info_ptr,
00441 int unit, double width, double height)
00442 {
00443 png_debug1(1, "in %s storage function\n", "sCAL");
00444 if (png_ptr == NULL || info_ptr == NULL)
00445 return;
00446
00447 info_ptr->scal_unit = (png_byte)unit;
00448 info_ptr->scal_pixel_width = width;
00449 info_ptr->scal_pixel_height = height;
00450
00451 info_ptr->valid |= PNG_INFO_sCAL;
00452 }
00453 #else
00454 #ifdef PNG_FIXED_POINT_SUPPORTED
00455 void PNGAPI
00456 png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
00457 int unit, png_charp swidth, png_charp sheight)
00458 {
00459 png_uint_32 length;
00460
00461 png_debug1(1, "in %s storage function\n", "sCAL");
00462 if (png_ptr == NULL || info_ptr == NULL)
00463 return;
00464
00465 info_ptr->scal_unit = (png_byte)unit;
00466
00467 length = png_strlen(swidth) + 1;
00468 png_debug1(3, "allocating unit for info (%d bytes)\n", length);
00469 info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length);
00470 if (info_ptr->scal_s_width == NULL)
00471 {
00472 png_warning(png_ptr, "Memory allocation failed while processing sCAL.");
00473 }
00474 png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length);
00475
00476 length = png_strlen(sheight) + 1;
00477 png_debug1(3, "allocating unit for info (%d bytes)\n", length);
00478 info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, length);
00479 if (info_ptr->scal_s_height == NULL)
00480 {
00481 png_free (png_ptr, info_ptr->scal_s_width);
00482 png_warning(png_ptr, "Memory allocation failed while processing sCAL.");
00483 }
00484 png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length);
00485
00486 info_ptr->valid |= PNG_INFO_sCAL;
00487 #ifdef PNG_FREE_ME_SUPPORTED
00488 info_ptr->free_me |= PNG_FREE_SCAL;
00489 #endif
00490 }
00491 #endif
00492 #endif
00493 #endif
00494
00495 #if defined(PNG_pHYs_SUPPORTED)
00496 void PNGAPI
00497 png_set_pHYs(png_structp png_ptr, png_infop info_ptr,
00498 png_uint_32 res_x, png_uint_32 res_y, int unit_type)
00499 {
00500 png_debug1(1, "in %s storage function\n", "pHYs");
00501 if (png_ptr == NULL || info_ptr == NULL)
00502 return;
00503
00504 info_ptr->x_pixels_per_unit = res_x;
00505 info_ptr->y_pixels_per_unit = res_y;
00506 info_ptr->phys_unit_type = (png_byte)unit_type;
00507 info_ptr->valid |= PNG_INFO_pHYs;
00508 }
00509 #endif
00510
00511 void PNGAPI
00512 png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
00513 png_colorp palette, int num_palette)
00514 {
00515
00516 png_debug1(1, "in %s storage function\n", "PLTE");
00517 if (png_ptr == NULL || info_ptr == NULL)
00518 return;
00519
00520
00521
00522
00523
00524
00525 #ifdef PNG_FREE_ME_SUPPORTED
00526 png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0);
00527 #endif
00528
00529
00530
00531 png_ptr->palette = (png_colorp)png_malloc(png_ptr,
00532 256 * png_sizeof(png_color));
00533 png_memset(png_ptr->palette, 0, 256 * png_sizeof(png_color));
00534 png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof (png_color));
00535 info_ptr->palette = png_ptr->palette;
00536 info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
00537
00538 #ifdef PNG_FREE_ME_SUPPORTED
00539 info_ptr->free_me |= PNG_FREE_PLTE;
00540 #else
00541 png_ptr->flags |= PNG_FLAG_FREE_PLTE;
00542 #endif
00543
00544 info_ptr->valid |= PNG_INFO_PLTE;
00545 }
00546
00547 #if defined(PNG_sBIT_SUPPORTED)
00548 void PNGAPI
00549 png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
00550 png_color_8p sig_bit)
00551 {
00552 png_debug1(1, "in %s storage function\n", "sBIT");
00553 if (png_ptr == NULL || info_ptr == NULL)
00554 return;
00555
00556 png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof (png_color_8));
00557 info_ptr->valid |= PNG_INFO_sBIT;
00558 }
00559 #endif
00560
00561 #if defined(PNG_sRGB_SUPPORTED)
00562 void PNGAPI
00563 png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent)
00564 {
00565 png_debug1(1, "in %s storage function\n", "sRGB");
00566 if (png_ptr == NULL || info_ptr == NULL)
00567 return;
00568
00569 info_ptr->srgb_intent = (png_byte)intent;
00570 info_ptr->valid |= PNG_INFO_sRGB;
00571 }
00572
00573 void PNGAPI
00574 png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
00575 int intent)
00576 {
00577 #if defined(PNG_gAMA_SUPPORTED)
00578 #ifdef PNG_FLOATING_POINT_SUPPORTED
00579 float file_gamma;
00580 #endif
00581 #ifdef PNG_FIXED_POINT_SUPPORTED
00582 png_fixed_point int_file_gamma;
00583 #endif
00584 #endif
00585 #if defined(PNG_cHRM_SUPPORTED)
00586 #ifdef PNG_FLOATING_POINT_SUPPORTED
00587 float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y;
00588 #endif
00589 #ifdef PNG_FIXED_POINT_SUPPORTED
00590 png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, int_green_x,
00591 int_green_y, int_blue_x, int_blue_y;
00592 #endif
00593 #endif
00594 png_debug1(1, "in %s storage function\n", "sRGB_gAMA_and_cHRM");
00595 if (png_ptr == NULL || info_ptr == NULL)
00596 return;
00597
00598 png_set_sRGB(png_ptr, info_ptr, intent);
00599
00600 #if defined(PNG_gAMA_SUPPORTED)
00601 #ifdef PNG_FLOATING_POINT_SUPPORTED
00602 file_gamma = (float).45455;
00603 png_set_gAMA(png_ptr, info_ptr, file_gamma);
00604 #endif
00605 #ifdef PNG_FIXED_POINT_SUPPORTED
00606 int_file_gamma = 45455L;
00607 png_set_gAMA_fixed(png_ptr, info_ptr, int_file_gamma);
00608 #endif
00609 #endif
00610
00611 #if defined(PNG_cHRM_SUPPORTED)
00612 #ifdef PNG_FIXED_POINT_SUPPORTED
00613 int_white_x = 31270L;
00614 int_white_y = 32900L;
00615 int_red_x = 64000L;
00616 int_red_y = 33000L;
00617 int_green_x = 30000L;
00618 int_green_y = 60000L;
00619 int_blue_x = 15000L;
00620 int_blue_y = 6000L;
00621
00622 png_set_cHRM_fixed(png_ptr, info_ptr,
00623 int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y,
00624 int_blue_x, int_blue_y);
00625 #endif
00626 #ifdef PNG_FLOATING_POINT_SUPPORTED
00627 white_x = (float).3127;
00628 white_y = (float).3290;
00629 red_x = (float).64;
00630 red_y = (float).33;
00631 green_x = (float).30;
00632 green_y = (float).60;
00633 blue_x = (float).15;
00634 blue_y = (float).06;
00635
00636 png_set_cHRM(png_ptr, info_ptr,
00637 white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y);
00638 #endif
00639 #endif
00640 }
00641 #endif
00642
00643
00644 #if defined(PNG_iCCP_SUPPORTED)
00645 void PNGAPI
00646 png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
00647 png_charp name, int compression_type,
00648 png_charp profile, png_uint_32 proflen)
00649 {
00650 png_charp new_iccp_name;
00651 png_charp new_iccp_profile;
00652
00653 png_debug1(1, "in %s storage function\n", "iCCP");
00654 if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL)
00655 return;
00656
00657 new_iccp_name = (png_charp)png_malloc_warn(png_ptr, png_strlen(name)+1);
00658 if (new_iccp_name == NULL)
00659 {
00660 png_warning(png_ptr, "Insufficient memory to process iCCP chunk.");
00661 return;
00662 }
00663 png_strcpy(new_iccp_name, name);
00664 new_iccp_profile = (png_charp)png_malloc_warn(png_ptr, proflen);
00665 if (new_iccp_profile == NULL)
00666 {
00667 png_free (png_ptr, new_iccp_name);
00668 png_warning(png_ptr, "Insufficient memory to process iCCP profile.");
00669 return;
00670 }
00671 png_memcpy(new_iccp_profile, profile, (png_size_t)proflen);
00672
00673 png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0);
00674
00675 info_ptr->iccp_proflen = proflen;
00676 info_ptr->iccp_name = new_iccp_name;
00677 info_ptr->iccp_profile = new_iccp_profile;
00678
00679
00680 info_ptr->iccp_compression = (png_byte)compression_type;
00681 #ifdef PNG_FREE_ME_SUPPORTED
00682 info_ptr->free_me |= PNG_FREE_ICCP;
00683 #endif
00684 info_ptr->valid |= PNG_INFO_iCCP;
00685 }
00686 #endif
00687
00688 #if defined(PNG_TEXT_SUPPORTED)
00689 void PNGAPI
00690 png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
00691 int num_text)
00692 {
00693 int ret;
00694 ret=png_set_text_2(png_ptr, info_ptr, text_ptr, num_text);
00695 if (ret)
00696 png_error(png_ptr, "Insufficient memory to store text");
00697 }
00698
00699 int
00700 png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
00701 int num_text)
00702 {
00703 int i;
00704
00705 png_debug1(1, "in %s storage function\n", (png_ptr->chunk_name[0] == '\0' ?
00706 "text" : (png_const_charp)png_ptr->chunk_name));
00707
00708 if (png_ptr == NULL || info_ptr == NULL || num_text == 0)
00709 return(0);
00710
00711
00712
00713
00714 if (info_ptr->num_text + num_text > info_ptr->max_text)
00715 {
00716 if (info_ptr->text != NULL)
00717 {
00718 png_textp old_text;
00719 int old_max;
00720
00721 old_max = info_ptr->max_text;
00722 info_ptr->max_text = info_ptr->num_text + num_text + 8;
00723 old_text = info_ptr->text;
00724 info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
00725 (png_uint_32)(info_ptr->max_text * png_sizeof (png_text)));
00726 if (info_ptr->text == NULL)
00727 {
00728 png_free(png_ptr, old_text);
00729 return(1);
00730 }
00731 png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max *
00732 png_sizeof(png_text)));
00733 png_free(png_ptr, old_text);
00734 }
00735 else
00736 {
00737 info_ptr->max_text = num_text + 8;
00738 info_ptr->num_text = 0;
00739 info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
00740 (png_uint_32)(info_ptr->max_text * png_sizeof (png_text)));
00741 if (info_ptr->text == NULL)
00742 return(1);
00743 #ifdef PNG_FREE_ME_SUPPORTED
00744 info_ptr->free_me |= PNG_FREE_TEXT;
00745 #endif
00746 }
00747 png_debug1(3, "allocated %d entries for info_ptr->text\n",
00748 info_ptr->max_text);
00749 }
00750 for (i = 0; i < num_text; i++)
00751 {
00752 png_size_t text_length,key_len;
00753 png_size_t lang_len,lang_key_len;
00754 png_textp textp = &(info_ptr->text[info_ptr->num_text]);
00755
00756 if (text_ptr[i].key == NULL)
00757 continue;
00758
00759 key_len = png_strlen(text_ptr[i].key);
00760
00761 if(text_ptr[i].compression <= 0)
00762 {
00763 lang_len = 0;
00764 lang_key_len = 0;
00765 }
00766 else
00767 #ifdef PNG_iTXt_SUPPORTED
00768 {
00769
00770 if (text_ptr[i].lang != NULL)
00771 lang_len = png_strlen(text_ptr[i].lang);
00772 else
00773 lang_len = 0;
00774 if (text_ptr[i].lang_key != NULL)
00775 lang_key_len = png_strlen(text_ptr[i].lang_key);
00776 else
00777 lang_key_len = 0;
00778 }
00779 #else
00780 {
00781 png_warning(png_ptr, "iTXt chunk not supported.");
00782 continue;
00783 }
00784 #endif
00785
00786 if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0')
00787 {
00788 text_length = 0;
00789 #ifdef PNG_iTXt_SUPPORTED
00790 if(text_ptr[i].compression > 0)
00791 textp->compression = PNG_ITXT_COMPRESSION_NONE;
00792 else
00793 #endif
00794 textp->compression = PNG_TEXT_COMPRESSION_NONE;
00795 }
00796 else
00797 {
00798 text_length = png_strlen(text_ptr[i].text);
00799 textp->compression = text_ptr[i].compression;
00800 }
00801
00802 textp->key = (png_charp)png_malloc_warn(png_ptr,
00803 (png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4));
00804 if (textp->key == NULL)
00805 return(1);
00806 png_debug2(2, "Allocated %lu bytes at %x in png_set_text\n",
00807 (png_uint_32)(key_len + lang_len + lang_key_len + text_length + 4),
00808 (int)textp->key);
00809
00810 png_memcpy(textp->key, text_ptr[i].key,
00811 (png_size_t)(key_len));
00812 *(textp->key+key_len) = '\0';
00813 #ifdef PNG_iTXt_SUPPORTED
00814 if (text_ptr[i].compression > 0)
00815 {
00816 textp->lang=textp->key + key_len + 1;
00817 png_memcpy(textp->lang, text_ptr[i].lang, lang_len);
00818 *(textp->lang+lang_len) = '\0';
00819 textp->lang_key=textp->lang + lang_len + 1;
00820 png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len);
00821 *(textp->lang_key+lang_key_len) = '\0';
00822 textp->text=textp->lang_key + lang_key_len + 1;
00823 }
00824 else
00825 #endif
00826 {
00827 #ifdef PNG_iTXt_SUPPORTED
00828 textp->lang=NULL;
00829 textp->lang_key=NULL;
00830 #endif
00831 textp->text=textp->key + key_len + 1;
00832 }
00833 if(text_length)
00834 png_memcpy(textp->text, text_ptr[i].text,
00835 (png_size_t)(text_length));
00836 *(textp->text+text_length) = '\0';
00837
00838 #ifdef PNG_iTXt_SUPPORTED
00839 if(textp->compression > 0)
00840 {
00841 textp->text_length = 0;
00842 textp->itxt_length = text_length;
00843 }
00844 else
00845 #endif
00846 {
00847 textp->text_length = text_length;
00848 #ifdef PNG_iTXt_SUPPORTED
00849 textp->itxt_length = 0;
00850 #endif
00851 }
00852 info_ptr->text[info_ptr->num_text]= *textp;
00853 info_ptr->num_text++;
00854 png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text);
00855 }
00856 return(0);
00857 }
00858 #endif
00859
00860 #if defined(PNG_tIME_SUPPORTED)
00861 void PNGAPI
00862 png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time)
00863 {
00864 png_debug1(1, "in %s storage function\n", "tIME");
00865 if (png_ptr == NULL || info_ptr == NULL ||
00866 (png_ptr->mode & PNG_WROTE_tIME))
00867 return;
00868
00869 png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof (png_time));
00870 info_ptr->valid |= PNG_INFO_tIME;
00871 }
00872 #endif
00873
00874 #if defined(PNG_tRNS_SUPPORTED)
00875 void PNGAPI
00876 png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
00877 png_bytep trans, int num_trans, png_color_16p trans_values)
00878 {
00879 png_debug1(1, "in %s storage function\n", "tRNS");
00880 if (png_ptr == NULL || info_ptr == NULL)
00881 return;
00882
00883 if (trans != NULL)
00884 {
00885
00886
00887
00888
00889
00890 #ifdef PNG_FREE_ME_SUPPORTED
00891 png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
00892 #endif
00893
00894 png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr,
00895 (png_uint_32)256);
00896 png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans);
00897 #ifdef PNG_FREE_ME_SUPPORTED
00898 info_ptr->free_me |= PNG_FREE_TRNS;
00899 #else
00900 png_ptr->flags |= PNG_FLAG_FREE_TRNS;
00901 #endif
00902 }
00903
00904 if (trans_values != NULL)
00905 {
00906 png_memcpy(&(info_ptr->trans_values), trans_values,
00907 png_sizeof(png_color_16));
00908 if (num_trans == 0)
00909 num_trans = 1;
00910 }
00911 info_ptr->num_trans = (png_uint_16)num_trans;
00912 info_ptr->valid |= PNG_INFO_tRNS;
00913 }
00914 #endif
00915
00916 #if defined(PNG_sPLT_SUPPORTED)
00917 void PNGAPI
00918 png_set_sPLT(png_structp png_ptr,
00919 png_infop info_ptr, png_sPLT_tp entries, int nentries)
00920 {
00921 png_sPLT_tp np;
00922 int i;
00923
00924 np = (png_sPLT_tp)png_malloc_warn(png_ptr,
00925 (info_ptr->splt_palettes_num + nentries) * png_sizeof(png_sPLT_t));
00926 if (np == NULL)
00927 {
00928 png_warning(png_ptr, "No memory for sPLT palettes.");
00929 return;
00930 }
00931
00932 png_memcpy(np, info_ptr->splt_palettes,
00933 info_ptr->splt_palettes_num * png_sizeof(png_sPLT_t));
00934 png_free(png_ptr, info_ptr->splt_palettes);
00935 info_ptr->splt_palettes=NULL;
00936
00937 for (i = 0; i < nentries; i++)
00938 {
00939 png_sPLT_tp to = np + info_ptr->splt_palettes_num + i;
00940 png_sPLT_tp from = entries + i;
00941
00942 to->name = (png_charp)png_malloc(png_ptr,
00943 png_strlen(from->name) + 1);
00944
00945 png_strcpy(to->name, from->name);
00946 to->entries = (png_sPLT_entryp)png_malloc(png_ptr,
00947 from->nentries * png_sizeof(png_sPLT_t));
00948
00949 png_memcpy(to->entries, from->entries,
00950 from->nentries * png_sizeof(png_sPLT_t));
00951 to->nentries = from->nentries;
00952 to->depth = from->depth;
00953 }
00954
00955 info_ptr->splt_palettes = np;
00956 info_ptr->splt_palettes_num += nentries;
00957 info_ptr->valid |= PNG_INFO_sPLT;
00958 #ifdef PNG_FREE_ME_SUPPORTED
00959 info_ptr->free_me |= PNG_FREE_SPLT;
00960 #endif
00961 }
00962 #endif
00963
00964 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
00965 void PNGAPI
00966 png_set_unknown_chunks(png_structp png_ptr,
00967 png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)
00968 {
00969 png_unknown_chunkp np;
00970 int i;
00971
00972 if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0)
00973 return;
00974
00975 np = (png_unknown_chunkp)png_malloc_warn(png_ptr,
00976 (info_ptr->unknown_chunks_num + num_unknowns) *
00977 png_sizeof(png_unknown_chunk));
00978 if (np == NULL)
00979 {
00980 png_warning(png_ptr, "Out of memory while processing unknown chunk.");
00981 return;
00982 }
00983
00984 png_memcpy(np, info_ptr->unknown_chunks,
00985 info_ptr->unknown_chunks_num * png_sizeof(png_unknown_chunk));
00986 png_free(png_ptr, info_ptr->unknown_chunks);
00987 info_ptr->unknown_chunks=NULL;
00988
00989 for (i = 0; i < num_unknowns; i++)
00990 {
00991 png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i;
00992 png_unknown_chunkp from = unknowns + i;
00993
00994 png_strncpy((png_charp)to->name, (png_charp)from->name, 5);
00995 to->data = (png_bytep)png_malloc_warn(png_ptr, from->size);
00996 if (to->data == NULL)
00997 {
00998 png_warning(png_ptr, "Out of memory processing unknown chunk.");
00999 }
01000 else
01001 {
01002 png_memcpy(to->data, from->data, from->size);
01003 to->size = from->size;
01004
01005
01006 to->location = (png_byte)(png_ptr->mode & 0xff);
01007 }
01008 }
01009
01010 info_ptr->unknown_chunks = np;
01011 info_ptr->unknown_chunks_num += num_unknowns;
01012 #ifdef PNG_FREE_ME_SUPPORTED
01013 info_ptr->free_me |= PNG_FREE_UNKN;
01014 #endif
01015 }
01016 void PNGAPI
01017 png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr,
01018 int chunk, int location)
01019 {
01020 if(png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk <
01021 (int)info_ptr->unknown_chunks_num)
01022 info_ptr->unknown_chunks[chunk].location = (png_byte)location;
01023 }
01024 #endif
01025
01026 #if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
01027 defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
01028 void PNGAPI
01029 png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted)
01030 {
01031
01032
01033 png_debug(1, "in png_permit_empty_plte, DEPRECATED.\n");
01034 if (png_ptr == NULL)
01035 return;
01036 png_ptr->mng_features_permitted = (png_byte)
01037 ((png_ptr->mng_features_permitted & (~(PNG_FLAG_MNG_EMPTY_PLTE))) |
01038 ((empty_plte_permitted & PNG_FLAG_MNG_EMPTY_PLTE)));
01039 }
01040 #endif
01041
01042 #if defined(PNG_MNG_FEATURES_SUPPORTED)
01043 png_uint_32 PNGAPI
01044 png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features)
01045 {
01046 png_debug(1, "in png_permit_mng_features\n");
01047 if (png_ptr == NULL)
01048 return (png_uint_32)0;
01049 png_ptr->mng_features_permitted =
01050 (png_byte)(mng_features & PNG_ALL_MNG_FEATURES);
01051 return (png_uint_32)png_ptr->mng_features_permitted;
01052 }
01053 #endif
01054
01055 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
01056 void PNGAPI
01057 png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep
01058 chunk_list, int num_chunks)
01059 {
01060 png_bytep new_list, p;
01061 int i, old_num_chunks;
01062 if (num_chunks == 0)
01063 {
01064 if(keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE)
01065 png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS;
01066 else
01067 png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS;
01068
01069 if(keep == PNG_HANDLE_CHUNK_ALWAYS)
01070 png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS;
01071 else
01072 png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS;
01073 return;
01074 }
01075 if (chunk_list == NULL)
01076 return;
01077 old_num_chunks=png_ptr->num_chunk_list;
01078 new_list=(png_bytep)png_malloc(png_ptr,
01079 (png_uint_32)(5*(num_chunks+old_num_chunks)));
01080 if(png_ptr->chunk_list != NULL)
01081 {
01082 png_memcpy(new_list, png_ptr->chunk_list,
01083 (png_size_t)(5*old_num_chunks));
01084 png_free(png_ptr, png_ptr->chunk_list);
01085 png_ptr->chunk_list=NULL;
01086 }
01087 png_memcpy(new_list+5*old_num_chunks, chunk_list,
01088 (png_size_t)(5*num_chunks));
01089 for (p=new_list+5*old_num_chunks+4, i=0; i<num_chunks; i++, p+=5)
01090 *p=(png_byte)keep;
01091 png_ptr->num_chunk_list=old_num_chunks+num_chunks;
01092 png_ptr->chunk_list=new_list;
01093 #ifdef PNG_FREE_ME_SUPPORTED
01094 png_ptr->free_me |= PNG_FREE_LIST;
01095 #endif
01096 }
01097 #endif
01098
01099 #if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
01100 void PNGAPI
01101 png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr,
01102 png_user_chunk_ptr read_user_chunk_fn)
01103 {
01104 png_debug(1, "in png_set_read_user_chunk_fn\n");
01105 png_ptr->read_user_chunk_fn = read_user_chunk_fn;
01106 png_ptr->user_chunk_ptr = user_chunk_ptr;
01107 }
01108 #endif
01109
01110 #if defined(PNG_INFO_IMAGE_SUPPORTED)
01111 void PNGAPI
01112 png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers)
01113 {
01114 png_debug1(1, "in %s storage function\n", "rows");
01115
01116 if (png_ptr == NULL || info_ptr == NULL)
01117 return;
01118
01119 if(info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers))
01120 png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);
01121 info_ptr->row_pointers = row_pointers;
01122 if(row_pointers)
01123 info_ptr->valid |= PNG_INFO_IDAT;
01124 }
01125 #endif
01126
01127 #ifdef PNG_WRITE_SUPPORTED
01128 void PNGAPI
01129 png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size)
01130 {
01131 if(png_ptr->zbuf)
01132 png_free(png_ptr, png_ptr->zbuf);
01133 png_ptr->zbuf_size = (png_size_t)size;
01134 png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size);
01135 png_ptr->zstream.next_out = png_ptr->zbuf;
01136 png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
01137 }
01138 #endif
01139
01140 void PNGAPI
01141 png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask)
01142 {
01143 if (png_ptr && info_ptr)
01144 info_ptr->valid &= ~(mask);
01145 }
01146
01147
01148 #ifndef PNG_1_0_X
01149 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
01150
01151 void PNGAPI
01152 png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags)
01153 {
01154 png_uint_32 settable_asm_flags;
01155 png_uint_32 settable_mmx_flags;
01156
01157 settable_mmx_flags =
01158 #ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
01159 PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
01160 #endif
01161 #ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE
01162 PNG_ASM_FLAG_MMX_READ_INTERLACE |
01163 #endif
01164 #ifdef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
01165 PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
01166 PNG_ASM_FLAG_MMX_READ_FILTER_UP |
01167 PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
01168 PNG_ASM_FLAG_MMX_READ_FILTER_PAETH |
01169 #endif
01170 0;
01171
01172
01173 settable_asm_flags = settable_mmx_flags;
01174
01175 if (!(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_COMPILED) ||
01176 !(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU))
01177 {
01178
01179 settable_asm_flags &= ~settable_mmx_flags;
01180 png_ptr->asm_flags &= ~settable_mmx_flags;
01181 }
01182
01183
01184
01185
01186
01187 png_ptr->asm_flags &= ~settable_asm_flags;
01188 png_ptr->asm_flags |= (asm_flags & settable_asm_flags);
01189 }
01190 #endif
01191
01192 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
01193
01194 void PNGAPI
01195 png_set_mmx_thresholds (png_structp png_ptr,
01196 png_byte mmx_bitdepth_threshold,
01197 png_uint_32 mmx_rowbytes_threshold)
01198 {
01199 png_ptr->mmx_bitdepth_threshold = mmx_bitdepth_threshold;
01200 png_ptr->mmx_rowbytes_threshold = mmx_rowbytes_threshold;
01201 }
01202 #endif
01203
01204 #ifdef PNG_SET_USER_LIMITS_SUPPORTED
01205
01206 void PNGAPI
01207 png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max,
01208 png_uint_32 user_height_max)
01209 {
01210
01211
01212
01213
01214 png_ptr->user_width_max = user_width_max;
01215 png_ptr->user_height_max = user_height_max;
01216 }
01217 #endif
01218
01219 #endif