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