Back to index

plt-scheme  4.2.1
pngget.c
Go to the documentation of this file.
00001 
00002 /* pngget.c - retrieval of values from info struct
00003  *
00004  * libpng 1.2.5 - October 3, 2002
00005  * For conditions of distribution and use, see copyright notice in png.h
00006  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
00007  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
00008  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
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 /* easy access to info, added in libpng-0.99 */
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 /* PNG_pHYs_SUPPORTED */
00334 #endif  /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
00335 
00336 /* png_get_channels really belongs in here, too, but it's been around longer */
00337 
00338 #endif  /* PNG_EASY_ACCESS_SUPPORTED */
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       /* compression_type is a dummy so the API won't have to change
00498          if we introduce multiple compression types later. */
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       int pixel_depth, channels;
00544       png_uint_32 rowbytes_per_pixel;
00545 
00546       png_debug1(1, "in %s retrieval function\n", "IHDR");
00547       *width = info_ptr->width;
00548       *height = info_ptr->height;
00549       *bit_depth = info_ptr->bit_depth;
00550       if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16)
00551         png_error(png_ptr, "Invalid bit depth");
00552       *color_type = info_ptr->color_type;
00553       if (info_ptr->color_type > 6)
00554         png_error(png_ptr, "Invalid color type");
00555       if (compression_type != NULL)
00556          *compression_type = info_ptr->compression_type;
00557       if (filter_type != NULL)
00558          *filter_type = info_ptr->filter_type;
00559       if (interlace_type != NULL)
00560          *interlace_type = info_ptr->interlace_type;
00561 
00562       /* check for potential overflow of rowbytes */
00563       if (*color_type == PNG_COLOR_TYPE_PALETTE)
00564          channels = 1;
00565       else if (*color_type & PNG_COLOR_MASK_COLOR)
00566          channels = 3;
00567       else
00568          channels = 1;
00569       if (*color_type & PNG_COLOR_MASK_ALPHA)
00570          channels++;
00571       pixel_depth = *bit_depth * channels;
00572       rowbytes_per_pixel = (pixel_depth + 7) >> 3;
00573       if (width == 0 || *width > PNG_MAX_UINT)
00574         png_error(png_ptr, "Invalid image width");
00575       if (height == 0 || *height > PNG_MAX_UINT)
00576         png_error(png_ptr, "Invalid image height");
00577       if (*width > PNG_MAX_UINT/rowbytes_per_pixel - 64)
00578       {
00579          png_error(png_ptr,
00580             "Width too large for libpng to process image data.");
00581       }
00582       return (1);
00583    }
00584    return (0);
00585 }
00586 
00587 #if defined(PNG_oFFs_SUPPORTED)
00588 png_uint_32 PNGAPI
00589 png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
00590    png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
00591 {
00592    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
00593       && offset_x != NULL && offset_y != NULL && unit_type != NULL)
00594    {
00595       png_debug1(1, "in %s retrieval function\n", "oFFs");
00596       *offset_x = info_ptr->x_offset;
00597       *offset_y = info_ptr->y_offset;
00598       *unit_type = (int)info_ptr->offset_unit_type;
00599       return (PNG_INFO_oFFs);
00600    }
00601    return (0);
00602 }
00603 #endif
00604 
00605 #if defined(PNG_pCAL_SUPPORTED)
00606 png_uint_32 PNGAPI
00607 png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
00608    png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
00609    png_charp *units, png_charpp *params)
00610 {
00611    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
00612       && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
00613       nparams != NULL && units != NULL && params != NULL)
00614    {
00615       png_debug1(1, "in %s retrieval function\n", "pCAL");
00616       *purpose = info_ptr->pcal_purpose;
00617       *X0 = info_ptr->pcal_X0;
00618       *X1 = info_ptr->pcal_X1;
00619       *type = (int)info_ptr->pcal_type;
00620       *nparams = (int)info_ptr->pcal_nparams;
00621       *units = info_ptr->pcal_units;
00622       *params = info_ptr->pcal_params;
00623       return (PNG_INFO_pCAL);
00624    }
00625    return (0);
00626 }
00627 #endif
00628 
00629 #if defined(PNG_sCAL_SUPPORTED)
00630 #ifdef PNG_FLOATING_POINT_SUPPORTED
00631 png_uint_32 PNGAPI
00632 png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
00633              int *unit, double *width, double *height)
00634 {
00635     if (png_ptr != NULL && info_ptr != NULL &&
00636        (info_ptr->valid & PNG_INFO_sCAL))
00637     {
00638         *unit = info_ptr->scal_unit;
00639         *width = info_ptr->scal_pixel_width;
00640         *height = info_ptr->scal_pixel_height;
00641         return (PNG_INFO_sCAL);
00642     }
00643     return(0);
00644 }
00645 #else
00646 #ifdef PNG_FIXED_POINT_SUPPORTED
00647 png_uint_32 PNGAPI
00648 png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
00649              int *unit, png_charpp width, png_charpp height)
00650 {
00651     if (png_ptr != NULL && info_ptr != NULL &&
00652        (info_ptr->valid & PNG_INFO_sCAL))
00653     {
00654         *unit = info_ptr->scal_unit;
00655         *width = info_ptr->scal_s_width;
00656         *height = info_ptr->scal_s_height;
00657         return (PNG_INFO_sCAL);
00658     }
00659     return(0);
00660 }
00661 #endif
00662 #endif
00663 #endif
00664 
00665 #if defined(PNG_pHYs_SUPPORTED)
00666 png_uint_32 PNGAPI
00667 png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
00668    png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
00669 {
00670    png_uint_32 retval = 0;
00671 
00672    if (png_ptr != NULL && info_ptr != NULL &&
00673       (info_ptr->valid & PNG_INFO_pHYs))
00674    {
00675       png_debug1(1, "in %s retrieval function\n", "pHYs");
00676       if (res_x != NULL)
00677       {
00678          *res_x = info_ptr->x_pixels_per_unit;
00679          retval |= PNG_INFO_pHYs;
00680       }
00681       if (res_y != NULL)
00682       {
00683          *res_y = info_ptr->y_pixels_per_unit;
00684          retval |= PNG_INFO_pHYs;
00685       }
00686       if (unit_type != NULL)
00687       {
00688          *unit_type = (int)info_ptr->phys_unit_type;
00689          retval |= PNG_INFO_pHYs;
00690       }
00691    }
00692    return (retval);
00693 }
00694 #endif
00695 
00696 png_uint_32 PNGAPI
00697 png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
00698    int *num_palette)
00699 {
00700    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
00701        && palette != NULL)
00702    {
00703       png_debug1(1, "in %s retrieval function\n", "PLTE");
00704       *palette = info_ptr->palette;
00705       *num_palette = info_ptr->num_palette;
00706       png_debug1(3, "num_palette = %d\n", *num_palette);
00707       return (PNG_INFO_PLTE);
00708    }
00709    return (0);
00710 }
00711 
00712 #if defined(PNG_sBIT_SUPPORTED)
00713 png_uint_32 PNGAPI
00714 png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
00715 {
00716    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
00717       && sig_bit != NULL)
00718    {
00719       png_debug1(1, "in %s retrieval function\n", "sBIT");
00720       *sig_bit = &(info_ptr->sig_bit);
00721       return (PNG_INFO_sBIT);
00722    }
00723    return (0);
00724 }
00725 #endif
00726 
00727 #if defined(PNG_TEXT_SUPPORTED)
00728 png_uint_32 PNGAPI
00729 png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
00730    int *num_text)
00731 {
00732    if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
00733    {
00734       png_debug1(1, "in %s retrieval function\n",
00735          (png_ptr->chunk_name[0] == '\0' ? "text"
00736              : (png_const_charp)png_ptr->chunk_name));
00737       if (text_ptr != NULL)
00738          *text_ptr = info_ptr->text;
00739       if (num_text != NULL)
00740          *num_text = info_ptr->num_text;
00741       return ((png_uint_32)info_ptr->num_text);
00742    }
00743    if (num_text != NULL)
00744      *num_text = 0;
00745    return(0);
00746 }
00747 #endif
00748 
00749 #if defined(PNG_tIME_SUPPORTED)
00750 png_uint_32 PNGAPI
00751 png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
00752 {
00753    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
00754        && mod_time != NULL)
00755    {
00756       png_debug1(1, "in %s retrieval function\n", "tIME");
00757       *mod_time = &(info_ptr->mod_time);
00758       return (PNG_INFO_tIME);
00759    }
00760    return (0);
00761 }
00762 #endif
00763 
00764 #if defined(PNG_tRNS_SUPPORTED)
00765 png_uint_32 PNGAPI
00766 png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
00767    png_bytep *trans, int *num_trans, png_color_16p *trans_values)
00768 {
00769    png_uint_32 retval = 0;
00770    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
00771    {
00772       png_debug1(1, "in %s retrieval function\n", "tRNS");
00773       if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
00774       {
00775           if (trans != NULL)
00776           {
00777              *trans = info_ptr->trans;
00778              retval |= PNG_INFO_tRNS;
00779           }
00780           if (trans_values != NULL)
00781              *trans_values = &(info_ptr->trans_values);
00782       }
00783       else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
00784       {
00785           if (trans_values != NULL)
00786           {
00787              *trans_values = &(info_ptr->trans_values);
00788              retval |= PNG_INFO_tRNS;
00789           }
00790           if(trans != NULL)
00791              *trans = NULL;
00792       }
00793       if(num_trans != NULL)
00794       {
00795          *num_trans = info_ptr->num_trans;
00796          retval |= PNG_INFO_tRNS;
00797       }
00798    }
00799    return (retval);
00800 }
00801 #endif
00802 
00803 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
00804 png_uint_32 PNGAPI
00805 png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
00806              png_unknown_chunkpp unknowns)
00807 {
00808    if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
00809      *unknowns = info_ptr->unknown_chunks;
00810    return ((png_uint_32)info_ptr->unknown_chunks_num);
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 
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 
00837 
00838 #ifndef PNG_1_0_X
00839 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
00840 /* this function was added to libpng 1.2.0 and should exist by default */
00841 png_uint_32 PNGAPI
00842 png_get_asm_flags (png_structp png_ptr)
00843 {
00844     return (png_uint_32)(png_ptr? png_ptr->asm_flags : 0L);
00845 }
00846 
00847 /* this function was added to libpng 1.2.0 and should exist by default */
00848 png_uint_32 PNGAPI
00849 png_get_asm_flagmask (int flag_select)
00850 {
00851     png_uint_32 settable_asm_flags = 0;
00852 
00853     if (flag_select & PNG_SELECT_READ)
00854         settable_asm_flags |=
00855           PNG_ASM_FLAG_MMX_READ_COMBINE_ROW  |
00856           PNG_ASM_FLAG_MMX_READ_INTERLACE    |
00857           PNG_ASM_FLAG_MMX_READ_FILTER_SUB   |
00858           PNG_ASM_FLAG_MMX_READ_FILTER_UP    |
00859           PNG_ASM_FLAG_MMX_READ_FILTER_AVG   |
00860           PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
00861           /* no non-MMX flags yet */
00862 
00863 #if 0
00864     /* GRR:  no write-flags yet, either, but someday... */
00865     if (flag_select & PNG_SELECT_WRITE)
00866         settable_asm_flags |=
00867           PNG_ASM_FLAG_MMX_WRITE_ [whatever] ;
00868 #endif /* 0 */
00869 
00870     return settable_asm_flags;  /* _theoretically_ settable capabilities only */
00871 }
00872 #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
00873 
00874 
00875 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
00876     /* GRR:  could add this:   && defined(PNG_MMX_CODE_SUPPORTED) */
00877 /* this function was added to libpng 1.2.0 */
00878 png_uint_32 PNGAPI
00879 png_get_mmx_flagmask (int flag_select, int *compilerID)
00880 {
00881     png_uint_32 settable_mmx_flags = 0;
00882 
00883     if (flag_select & PNG_SELECT_READ)
00884         settable_mmx_flags |=
00885           PNG_ASM_FLAG_MMX_READ_COMBINE_ROW  |
00886           PNG_ASM_FLAG_MMX_READ_INTERLACE    |
00887           PNG_ASM_FLAG_MMX_READ_FILTER_SUB   |
00888           PNG_ASM_FLAG_MMX_READ_FILTER_UP    |
00889           PNG_ASM_FLAG_MMX_READ_FILTER_AVG   |
00890           PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
00891 #if 0
00892     /* GRR:  no MMX write support yet, but someday... */
00893     if (flag_select & PNG_SELECT_WRITE)
00894         settable_mmx_flags |=
00895           PNG_ASM_FLAG_MMX_WRITE_ [whatever] ;
00896 #endif /* 0 */
00897 
00898     if (compilerID != NULL) {
00899 #ifdef PNG_USE_PNGVCRD
00900         *compilerID = 1;    /* MSVC */
00901 #else
00902 #ifdef PNG_USE_PNGGCCRD
00903         *compilerID = 2;    /* gcc/gas */
00904 #else
00905         *compilerID = -1;   /* unknown (i.e., no asm/MMX code compiled) */
00906 #endif
00907 #endif
00908     }
00909 
00910     return settable_mmx_flags;  /* _theoretically_ settable capabilities only */
00911 }
00912 
00913 /* this function was added to libpng 1.2.0 */
00914 png_byte PNGAPI
00915 png_get_mmx_bitdepth_threshold (png_structp png_ptr)
00916 {
00917     return (png_byte)(png_ptr? png_ptr->mmx_bitdepth_threshold : 0);
00918 }
00919 
00920 /* this function was added to libpng 1.2.0 */
00921 png_uint_32 PNGAPI
00922 png_get_mmx_rowbytes_threshold (png_structp png_ptr)
00923 {
00924     return (png_uint_32)(png_ptr? png_ptr->mmx_rowbytes_threshold : 0L);
00925 }
00926 #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
00927 #endif /* PNG_1_0_X */