fltk 1.3.0rc3
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Release candidate.
  SfR Fresh Dox: fltk-1.3.0rc3-source.tar.gz ("inofficial" and yet experimental doxygen-generated source code documentation)  

pngget.c

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