00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #define PNG_INTERNAL
00012 #include "png.h"
00013
00014 png_uint_32 PNGAPI
00015 png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
00016 {
00017 if (png_ptr != NULL && info_ptr != NULL)
00018 return(info_ptr->valid & flag);
00019 else
00020 return(0);
00021 }
00022
00023 png_uint_32 PNGAPI
00024 png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
00025 {
00026 if (png_ptr != NULL && info_ptr != NULL)
00027 return(info_ptr->rowbytes);
00028 else
00029 return(0);
00030 }
00031
00032 #if defined(PNG_INFO_IMAGE_SUPPORTED)
00033 png_bytepp PNGAPI
00034 png_get_rows(png_structp png_ptr, png_infop info_ptr)
00035 {
00036 if (png_ptr != NULL && info_ptr != NULL)
00037 return(info_ptr->row_pointers);
00038 else
00039 return(0);
00040 }
00041 #endif
00042
00043 #ifdef PNG_EASY_ACCESS_SUPPORTED
00044
00045 png_uint_32 PNGAPI
00046 png_get_image_width(png_structp png_ptr, png_infop info_ptr)
00047 {
00048 if (png_ptr != NULL && info_ptr != NULL)
00049 {
00050 return info_ptr->width;
00051 }
00052 return (0);
00053 }
00054
00055 png_uint_32 PNGAPI
00056 png_get_image_height(png_structp png_ptr, png_infop info_ptr)
00057 {
00058 if (png_ptr != NULL && info_ptr != NULL)
00059 {
00060 return info_ptr->height;
00061 }
00062 return (0);
00063 }
00064
00065 png_byte PNGAPI
00066 png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
00067 {
00068 if (png_ptr != NULL && info_ptr != NULL)
00069 {
00070 return info_ptr->bit_depth;
00071 }
00072 return (0);
00073 }
00074
00075 png_byte PNGAPI
00076 png_get_color_type(png_structp png_ptr, png_infop info_ptr)
00077 {
00078 if (png_ptr != NULL && info_ptr != NULL)
00079 {
00080 return info_ptr->color_type;
00081 }
00082 return (0);
00083 }
00084
00085 png_byte PNGAPI
00086 png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
00087 {
00088 if (png_ptr != NULL && info_ptr != NULL)
00089 {
00090 return info_ptr->filter_type;
00091 }
00092 return (0);
00093 }
00094
00095 png_byte PNGAPI
00096 png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
00097 {
00098 if (png_ptr != NULL && info_ptr != NULL)
00099 {
00100 return info_ptr->interlace_type;
00101 }
00102 return (0);
00103 }
00104
00105 png_byte PNGAPI
00106 png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
00107 {
00108 if (png_ptr != NULL && info_ptr != NULL)
00109 {
00110 return info_ptr->compression_type;
00111 }
00112 return (0);
00113 }
00114
00115 png_uint_32 PNGAPI
00116 png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
00117 {
00118 if (png_ptr != NULL && info_ptr != NULL)
00119 #if defined(PNG_pHYs_SUPPORTED)
00120 if (info_ptr->valid & PNG_INFO_pHYs)
00121 {
00122 png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter");
00123 if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
00124 return (0);
00125 else return (info_ptr->x_pixels_per_unit);
00126 }
00127 #else
00128 return (0);
00129 #endif
00130 return (0);
00131 }
00132
00133 png_uint_32 PNGAPI
00134 png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
00135 {
00136 if (png_ptr != NULL && info_ptr != NULL)
00137 #if defined(PNG_pHYs_SUPPORTED)
00138 if (info_ptr->valid & PNG_INFO_pHYs)
00139 {
00140 png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter");
00141 if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
00142 return (0);
00143 else return (info_ptr->y_pixels_per_unit);
00144 }
00145 #else
00146 return (0);
00147 #endif
00148 return (0);
00149 }
00150
00151 png_uint_32 PNGAPI
00152 png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
00153 {
00154 if (png_ptr != NULL && info_ptr != NULL)
00155 #if defined(PNG_pHYs_SUPPORTED)
00156 if (info_ptr->valid & PNG_INFO_pHYs)
00157 {
00158 png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter");
00159 if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
00160 info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit)
00161 return (0);
00162 else return (info_ptr->x_pixels_per_unit);
00163 }
00164 #else
00165 return (0);
00166 #endif
00167 return (0);
00168 }
00169
00170 #ifdef PNG_FLOATING_POINT_SUPPORTED
00171 float PNGAPI
00172 png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
00173 {
00174 if (png_ptr != NULL && info_ptr != NULL)
00175 #if defined(PNG_pHYs_SUPPORTED)
00176 if (info_ptr->valid & PNG_INFO_pHYs)
00177 {
00178 png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio");
00179 if (info_ptr->x_pixels_per_unit == 0)
00180 return ((float)0.0);
00181 else
00182 return ((float)((float)info_ptr->y_pixels_per_unit
00183 /(float)info_ptr->x_pixels_per_unit));
00184 }
00185 #else
00186 return (0.0);
00187 #endif
00188 return ((float)0.0);
00189 }
00190 #endif
00191
00192 png_int_32 PNGAPI
00193 png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
00194 {
00195 if (png_ptr != NULL && info_ptr != NULL)
00196 #if defined(PNG_oFFs_SUPPORTED)
00197 if (info_ptr->valid & PNG_INFO_oFFs)
00198 {
00199 png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
00200 if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
00201 return (0);
00202 else return (info_ptr->x_offset);
00203 }
00204 #else
00205 return (0);
00206 #endif
00207 return (0);
00208 }
00209
00210 png_int_32 PNGAPI
00211 png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
00212 {
00213 if (png_ptr != NULL && info_ptr != NULL)
00214 #if defined(PNG_oFFs_SUPPORTED)
00215 if (info_ptr->valid & PNG_INFO_oFFs)
00216 {
00217 png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
00218 if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
00219 return (0);
00220 else return (info_ptr->y_offset);
00221 }
00222 #else
00223 return (0);
00224 #endif
00225 return (0);
00226 }
00227
00228 png_int_32 PNGAPI
00229 png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
00230 {
00231 if (png_ptr != NULL && info_ptr != NULL)
00232 #if defined(PNG_oFFs_SUPPORTED)
00233 if (info_ptr->valid & PNG_INFO_oFFs)
00234 {
00235 png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
00236 if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
00237 return (0);
00238 else return (info_ptr->x_offset);
00239 }
00240 #else
00241 return (0);
00242 #endif
00243 return (0);
00244 }
00245
00246 png_int_32 PNGAPI
00247 png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
00248 {
00249 if (png_ptr != NULL && info_ptr != NULL)
00250 #if defined(PNG_oFFs_SUPPORTED)
00251 if (info_ptr->valid & PNG_INFO_oFFs)
00252 {
00253 png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
00254 if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
00255 return (0);
00256 else return (info_ptr->y_offset);
00257 }
00258 #else
00259 return (0);
00260 #endif
00261 return (0);
00262 }
00263
00264 #if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
00265 png_uint_32 PNGAPI
00266 png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
00267 {
00268 return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr)
00269 *.0254 +.5));
00270 }
00271
00272 png_uint_32 PNGAPI
00273 png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
00274 {
00275 return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr)
00276 *.0254 +.5));
00277 }
00278
00279 png_uint_32 PNGAPI
00280 png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
00281 {
00282 return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr)
00283 *.0254 +.5));
00284 }
00285
00286 float PNGAPI
00287 png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr)
00288 {
00289 return ((float)png_get_x_offset_microns(png_ptr, info_ptr)
00290 *.00003937);
00291 }
00292
00293 float PNGAPI
00294 png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
00295 {
00296 return ((float)png_get_y_offset_microns(png_ptr, info_ptr)
00297 *.00003937);
00298 }
00299
00300 #if defined(PNG_pHYs_SUPPORTED)
00301 png_uint_32 PNGAPI
00302 png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
00303 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
00304 {
00305 png_uint_32 retval = 0;
00306
00307 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
00308 {
00309 png_debug1(1, "in %s retrieval function\n", "pHYs");
00310 if (res_x != NULL)
00311 {
00312 *res_x = info_ptr->x_pixels_per_unit;
00313 retval |= PNG_INFO_pHYs;
00314 }
00315 if (res_y != NULL)
00316 {
00317 *res_y = info_ptr->y_pixels_per_unit;
00318 retval |= PNG_INFO_pHYs;
00319 }
00320 if (unit_type != NULL)
00321 {
00322 *unit_type = (int)info_ptr->phys_unit_type;
00323 retval |= PNG_INFO_pHYs;
00324 if(*unit_type == 1)
00325 {
00326 if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
00327 if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);
00328 }
00329 }
00330 }
00331 return (retval);
00332 }
00333 #endif
00334 #endif
00335
00336
00337
00338 #endif
00339
00340 png_byte PNGAPI
00341 png_get_channels(png_structp png_ptr, png_infop info_ptr)
00342 {
00343 if (png_ptr != NULL && info_ptr != NULL)
00344 return(info_ptr->channels);
00345 else
00346 return (0);
00347 }
00348
00349 png_bytep PNGAPI
00350 png_get_signature(png_structp png_ptr, png_infop info_ptr)
00351 {
00352 if (png_ptr != NULL && info_ptr != NULL)
00353 return(info_ptr->signature);
00354 else
00355 return (NULL);
00356 }
00357
00358 #if defined(PNG_bKGD_SUPPORTED)
00359 png_uint_32 PNGAPI
00360 png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
00361 png_color_16p *background)
00362 {
00363 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
00364 && background != NULL)
00365 {
00366 png_debug1(1, "in %s retrieval function\n", "bKGD");
00367 *background = &(info_ptr->background);
00368 return (PNG_INFO_bKGD);
00369 }
00370 return (0);
00371 }
00372 #endif
00373
00374 #if defined(PNG_cHRM_SUPPORTED)
00375 #ifdef PNG_FLOATING_POINT_SUPPORTED
00376 png_uint_32 PNGAPI
00377 png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
00378 double *white_x, double *white_y, double *red_x, double *red_y,
00379 double *green_x, double *green_y, double *blue_x, double *blue_y)
00380 {
00381 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
00382 {
00383 png_debug1(1, "in %s retrieval function\n", "cHRM");
00384 if (white_x != NULL)
00385 *white_x = (double)info_ptr->x_white;
00386 if (white_y != NULL)
00387 *white_y = (double)info_ptr->y_white;
00388 if (red_x != NULL)
00389 *red_x = (double)info_ptr->x_red;
00390 if (red_y != NULL)
00391 *red_y = (double)info_ptr->y_red;
00392 if (green_x != NULL)
00393 *green_x = (double)info_ptr->x_green;
00394 if (green_y != NULL)
00395 *green_y = (double)info_ptr->y_green;
00396 if (blue_x != NULL)
00397 *blue_x = (double)info_ptr->x_blue;
00398 if (blue_y != NULL)
00399 *blue_y = (double)info_ptr->y_blue;
00400 return (PNG_INFO_cHRM);
00401 }
00402 return (0);
00403 }
00404 #endif
00405 #ifdef PNG_FIXED_POINT_SUPPORTED
00406 png_uint_32 PNGAPI
00407 png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
00408 png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
00409 png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
00410 png_fixed_point *blue_x, png_fixed_point *blue_y)
00411 {
00412 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
00413 {
00414 png_debug1(1, "in %s retrieval function\n", "cHRM");
00415 if (white_x != NULL)
00416 *white_x = info_ptr->int_x_white;
00417 if (white_y != NULL)
00418 *white_y = info_ptr->int_y_white;
00419 if (red_x != NULL)
00420 *red_x = info_ptr->int_x_red;
00421 if (red_y != NULL)
00422 *red_y = info_ptr->int_y_red;
00423 if (green_x != NULL)
00424 *green_x = info_ptr->int_x_green;
00425 if (green_y != NULL)
00426 *green_y = info_ptr->int_y_green;
00427 if (blue_x != NULL)
00428 *blue_x = info_ptr->int_x_blue;
00429 if (blue_y != NULL)
00430 *blue_y = info_ptr->int_y_blue;
00431 return (PNG_INFO_cHRM);
00432 }
00433 return (0);
00434 }
00435 #endif
00436 #endif
00437
00438 #if defined(PNG_gAMA_SUPPORTED)
00439 #ifdef PNG_FLOATING_POINT_SUPPORTED
00440 png_uint_32 PNGAPI
00441 png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
00442 {
00443 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
00444 && file_gamma != NULL)
00445 {
00446 png_debug1(1, "in %s retrieval function\n", "gAMA");
00447 *file_gamma = (double)info_ptr->gamma;
00448 return (PNG_INFO_gAMA);
00449 }
00450 return (0);
00451 }
00452 #endif
00453 #ifdef PNG_FIXED_POINT_SUPPORTED
00454 png_uint_32 PNGAPI
00455 png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
00456 png_fixed_point *int_file_gamma)
00457 {
00458 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
00459 && int_file_gamma != NULL)
00460 {
00461 png_debug1(1, "in %s retrieval function\n", "gAMA");
00462 *int_file_gamma = info_ptr->int_gamma;
00463 return (PNG_INFO_gAMA);
00464 }
00465 return (0);
00466 }
00467 #endif
00468 #endif
00469
00470 #if defined(PNG_sRGB_SUPPORTED)
00471 png_uint_32 PNGAPI
00472 png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
00473 {
00474 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
00475 && file_srgb_intent != NULL)
00476 {
00477 png_debug1(1, "in %s retrieval function\n", "sRGB");
00478 *file_srgb_intent = (int)info_ptr->srgb_intent;
00479 return (PNG_INFO_sRGB);
00480 }
00481 return (0);
00482 }
00483 #endif
00484
00485 #if defined(PNG_iCCP_SUPPORTED)
00486 png_uint_32 PNGAPI
00487 png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
00488 png_charpp name, int *compression_type,
00489 png_charpp profile, png_uint_32 *proflen)
00490 {
00491 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
00492 && name != NULL && profile != NULL && proflen != NULL)
00493 {
00494 png_debug1(1, "in %s retrieval function\n", "iCCP");
00495 *name = info_ptr->iccp_name;
00496 *profile = info_ptr->iccp_profile;
00497
00498
00499 *proflen = (int)info_ptr->iccp_proflen;
00500 *compression_type = (int)info_ptr->iccp_compression;
00501 return (PNG_INFO_iCCP);
00502 }
00503 return (0);
00504 }
00505 #endif
00506
00507 #if defined(PNG_sPLT_SUPPORTED)
00508 png_uint_32 PNGAPI
00509 png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
00510 png_sPLT_tpp spalettes)
00511 {
00512 if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
00513 *spalettes = info_ptr->splt_palettes;
00514 return ((png_uint_32)info_ptr->splt_palettes_num);
00515 }
00516 #endif
00517
00518 #if defined(PNG_hIST_SUPPORTED)
00519 png_uint_32 PNGAPI
00520 png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
00521 {
00522 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
00523 && hist != NULL)
00524 {
00525 png_debug1(1, "in %s retrieval function\n", "hIST");
00526 *hist = info_ptr->hist;
00527 return (PNG_INFO_hIST);
00528 }
00529 return (0);
00530 }
00531 #endif
00532
00533 png_uint_32 PNGAPI
00534 png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
00535 png_uint_32 *width, png_uint_32 *height, int *bit_depth,
00536 int *color_type, int *interlace_type, int *compression_type,
00537 int *filter_type)
00538
00539 {
00540 if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL &&
00541 bit_depth != NULL && color_type != NULL)
00542 {
00543 png_debug1(1, "in %s retrieval function\n", "IHDR");
00544 *width = info_ptr->width;
00545 *height = info_ptr->height;
00546 *bit_depth = info_ptr->bit_depth;
00547 if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16)
00548 png_error(png_ptr, "Invalid bit depth");
00549 *color_type = info_ptr->color_type;
00550 if (info_ptr->color_type > 6)
00551 png_error(png_ptr, "Invalid color type");
00552 if (compression_type != NULL)
00553 *compression_type = info_ptr->compression_type;
00554 if (filter_type != NULL)
00555 *filter_type = info_ptr->filter_type;
00556 if (interlace_type != NULL)
00557 *interlace_type = info_ptr->interlace_type;
00558
00559
00560 if (*width == 0 || *width > PNG_UINT_31_MAX)
00561 png_error(png_ptr, "Invalid image width");
00562 if (*height == 0 || *height > PNG_UINT_31_MAX)
00563 png_error(png_ptr, "Invalid image height");
00564 if (info_ptr->width > (PNG_UINT_32_MAX
00565 >> 3)
00566 - 64
00567 - 1
00568 - 7*8
00569 - 8)
00570 {
00571 png_warning(png_ptr,
00572 "Width too large for libpng to process image data.");
00573 }
00574 return (1);
00575 }
00576 return (0);
00577 }
00578
00579 #if defined(PNG_oFFs_SUPPORTED)
00580 png_uint_32 PNGAPI
00581 png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
00582 png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
00583 {
00584 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
00585 && offset_x != NULL && offset_y != NULL && unit_type != NULL)
00586 {
00587 png_debug1(1, "in %s retrieval function\n", "oFFs");
00588 *offset_x = info_ptr->x_offset;
00589 *offset_y = info_ptr->y_offset;
00590 *unit_type = (int)info_ptr->offset_unit_type;
00591 return (PNG_INFO_oFFs);
00592 }
00593 return (0);
00594 }
00595 #endif
00596
00597 #if defined(PNG_pCAL_SUPPORTED)
00598 png_uint_32 PNGAPI
00599 png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
00600 png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
00601 png_charp *units, png_charpp *params)
00602 {
00603 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
00604 && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
00605 nparams != NULL && units != NULL && params != NULL)
00606 {
00607 png_debug1(1, "in %s retrieval function\n", "pCAL");
00608 *purpose = info_ptr->pcal_purpose;
00609 *X0 = info_ptr->pcal_X0;
00610 *X1 = info_ptr->pcal_X1;
00611 *type = (int)info_ptr->pcal_type;
00612 *nparams = (int)info_ptr->pcal_nparams;
00613 *units = info_ptr->pcal_units;
00614 *params = info_ptr->pcal_params;
00615 return (PNG_INFO_pCAL);
00616 }
00617 return (0);
00618 }
00619 #endif
00620
00621 #if defined(PNG_sCAL_SUPPORTED)
00622 #ifdef PNG_FLOATING_POINT_SUPPORTED
00623 png_uint_32 PNGAPI
00624 png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
00625 int *unit, double *width, double *height)
00626 {
00627 if (png_ptr != NULL && info_ptr != NULL &&
00628 (info_ptr->valid & PNG_INFO_sCAL))
00629 {
00630 *unit = info_ptr->scal_unit;
00631 *width = info_ptr->scal_pixel_width;
00632 *height = info_ptr->scal_pixel_height;
00633 return (PNG_INFO_sCAL);
00634 }
00635 return(0);
00636 }
00637 #else
00638 #ifdef PNG_FIXED_POINT_SUPPORTED
00639 png_uint_32 PNGAPI
00640 png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
00641 int *unit, png_charpp width, png_charpp height)
00642 {
00643 if (png_ptr != NULL && info_ptr != NULL &&
00644 (info_ptr->valid & PNG_INFO_sCAL))
00645 {
00646 *unit = info_ptr->scal_unit;
00647 *width = info_ptr->scal_s_width;
00648 *height = info_ptr->scal_s_height;
00649 return (PNG_INFO_sCAL);
00650 }
00651 return(0);
00652 }
00653 #endif
00654 #endif
00655 #endif
00656
00657 #if defined(PNG_pHYs_SUPPORTED)
00658 png_uint_32 PNGAPI
00659 png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
00660 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
00661 {
00662 png_uint_32 retval = 0;
00663
00664 if (png_ptr != NULL && info_ptr != NULL &&
00665 (info_ptr->valid & PNG_INFO_pHYs))
00666 {
00667 png_debug1(1, "in %s retrieval function\n", "pHYs");
00668 if (res_x != NULL)
00669 {
00670 *res_x = info_ptr->x_pixels_per_unit;
00671 retval |= PNG_INFO_pHYs;
00672 }
00673 if (res_y != NULL)
00674 {
00675 *res_y = info_ptr->y_pixels_per_unit;
00676 retval |= PNG_INFO_pHYs;
00677 }
00678 if (unit_type != NULL)
00679 {
00680 *unit_type = (int)info_ptr->phys_unit_type;
00681 retval |= PNG_INFO_pHYs;
00682 }
00683 }
00684 return (retval);
00685 }
00686 #endif
00687
00688 png_uint_32 PNGAPI
00689 png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
00690 int *num_palette)
00691 {
00692 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
00693 && palette != NULL)
00694 {
00695 png_debug1(1, "in %s retrieval function\n", "PLTE");
00696 *palette = info_ptr->palette;
00697 *num_palette = info_ptr->num_palette;
00698 png_debug1(3, "num_palette = %d\n", *num_palette);
00699 return (PNG_INFO_PLTE);
00700 }
00701 return (0);
00702 }
00703
00704 #if defined(PNG_sBIT_SUPPORTED)
00705 png_uint_32 PNGAPI
00706 png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
00707 {
00708 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
00709 && sig_bit != NULL)
00710 {
00711 png_debug1(1, "in %s retrieval function\n", "sBIT");
00712 *sig_bit = &(info_ptr->sig_bit);
00713 return (PNG_INFO_sBIT);
00714 }
00715 return (0);
00716 }
00717 #endif
00718
00719 #if defined(PNG_TEXT_SUPPORTED)
00720 png_uint_32 PNGAPI
00721 png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
00722 int *num_text)
00723 {
00724 if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
00725 {
00726 png_debug1(1, "in %s retrieval function\n",
00727 (png_ptr->chunk_name[0] == '\0' ? "text"
00728 : (png_const_charp)png_ptr->chunk_name));
00729 if (text_ptr != NULL)
00730 *text_ptr = info_ptr->text;
00731 if (num_text != NULL)
00732 *num_text = info_ptr->num_text;
00733 return ((png_uint_32)info_ptr->num_text);
00734 }
00735 if (num_text != NULL)
00736 *num_text = 0;
00737 return(0);
00738 }
00739 #endif
00740
00741 #if defined(PNG_tIME_SUPPORTED)
00742 png_uint_32 PNGAPI
00743 png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
00744 {
00745 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
00746 && mod_time != NULL)
00747 {
00748 png_debug1(1, "in %s retrieval function\n", "tIME");
00749 *mod_time = &(info_ptr->mod_time);
00750 return (PNG_INFO_tIME);
00751 }
00752 return (0);
00753 }
00754 #endif
00755
00756 #if defined(PNG_tRNS_SUPPORTED)
00757 png_uint_32 PNGAPI
00758 png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
00759 png_bytep *trans, int *num_trans, png_color_16p *trans_values)
00760 {
00761 png_uint_32 retval = 0;
00762 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
00763 {
00764 png_debug1(1, "in %s retrieval function\n", "tRNS");
00765 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
00766 {
00767 if (trans != NULL)
00768 {
00769 *trans = info_ptr->trans;
00770 retval |= PNG_INFO_tRNS;
00771 }
00772 if (trans_values != NULL)
00773 *trans_values = &(info_ptr->trans_values);
00774 }
00775 else
00776 {
00777 if (trans_values != NULL)
00778 {
00779 *trans_values = &(info_ptr->trans_values);
00780 retval |= PNG_INFO_tRNS;
00781 }
00782 if(trans != NULL)
00783 *trans = NULL;
00784 }
00785 if(num_trans != NULL)
00786 {
00787 *num_trans = info_ptr->num_trans;
00788 retval |= PNG_INFO_tRNS;
00789 }
00790 }
00791 return (retval);
00792 }
00793 #endif
00794
00795 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
00796 png_uint_32 PNGAPI
00797 png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
00798 png_unknown_chunkpp unknowns)
00799 {
00800 if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
00801 *unknowns = info_ptr->unknown_chunks;
00802 return ((png_uint_32)info_ptr->unknown_chunks_num);
00803 }
00804 #endif
00805
00806 #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
00807 png_byte PNGAPI
00808 png_get_rgb_to_gray_status (png_structp png_ptr)
00809 {
00810 return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0);
00811 }
00812 #endif
00813
00814 #if defined(PNG_USER_CHUNKS_SUPPORTED)
00815 png_voidp PNGAPI
00816 png_get_user_chunk_ptr(png_structp png_ptr)
00817 {
00818 return (png_ptr? png_ptr->user_chunk_ptr : NULL);
00819 }
00820 #endif
00821
00822 #ifdef PNG_WRITE_SUPPORTED
00823 png_uint_32 PNGAPI
00824 png_get_compression_buffer_size(png_structp png_ptr)
00825 {
00826 return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L);
00827 }
00828 #endif
00829
00830 #ifndef PNG_1_0_X
00831 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
00832
00833 png_uint_32 PNGAPI
00834 png_get_asm_flags (png_structp png_ptr)
00835 {
00836 return (png_uint_32)(png_ptr? png_ptr->asm_flags : 0L);
00837 }
00838
00839
00840 png_uint_32 PNGAPI
00841 png_get_asm_flagmask (int flag_select)
00842 {
00843 png_uint_32 settable_asm_flags = 0;
00844
00845 if (flag_select & PNG_SELECT_READ)
00846 settable_asm_flags |=
00847 PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
00848 PNG_ASM_FLAG_MMX_READ_INTERLACE |
00849 PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
00850 PNG_ASM_FLAG_MMX_READ_FILTER_UP |
00851 PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
00852 PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
00853
00854
00855 #if 0
00856
00857 if (flag_select & PNG_SELECT_WRITE)
00858 settable_asm_flags |=
00859 PNG_ASM_FLAG_MMX_WRITE_ [whatever] ;
00860 #endif
00861
00862 return settable_asm_flags;
00863 }
00864 #endif
00865
00866
00867 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
00868
00869
00870 png_uint_32 PNGAPI
00871 png_get_mmx_flagmask (int flag_select, int *compilerID)
00872 {
00873 png_uint_32 settable_mmx_flags = 0;
00874
00875 if (flag_select & PNG_SELECT_READ)
00876 settable_mmx_flags |=
00877 PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
00878 PNG_ASM_FLAG_MMX_READ_INTERLACE |
00879 PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
00880 PNG_ASM_FLAG_MMX_READ_FILTER_UP |
00881 PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
00882 PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
00883 #if 0
00884
00885 if (flag_select & PNG_SELECT_WRITE)
00886 settable_mmx_flags |=
00887 PNG_ASM_FLAG_MMX_WRITE_ [whatever] ;
00888 #endif
00889
00890 if (compilerID != NULL) {
00891 #ifdef PNG_USE_PNGVCRD
00892 *compilerID = 1;
00893 #else
00894 #ifdef PNG_USE_PNGGCCRD
00895 *compilerID = 2;
00896 #else
00897 *compilerID = -1;
00898 #endif
00899 #endif
00900 }
00901
00902 return settable_mmx_flags;
00903 }
00904
00905
00906 png_byte PNGAPI
00907 png_get_mmx_bitdepth_threshold (png_structp png_ptr)
00908 {
00909 return (png_byte)(png_ptr? png_ptr->mmx_bitdepth_threshold : 0);
00910 }
00911
00912
00913 png_uint_32 PNGAPI
00914 png_get_mmx_rowbytes_threshold (png_structp png_ptr)
00915 {
00916 return (png_uint_32)(png_ptr? png_ptr->mmx_rowbytes_threshold : 0L);
00917 }
00918 #endif
00919
00920 #ifdef PNG_SET_USER_LIMITS_SUPPORTED
00921
00922 png_uint_32 PNGAPI
00923 png_get_user_width_max (png_structp png_ptr)
00924 {
00925 return (png_ptr? png_ptr->user_width_max : 0);
00926 }
00927 png_uint_32 PNGAPI
00928 png_get_user_height_max (png_structp png_ptr)
00929 {
00930 return (png_ptr? png_ptr->user_height_max : 0);
00931 }
00932 #endif
00933
00934 #endif