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


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sun Apr 2 2017 03:43:56