src/3rdparty/libpng/pngget.c
changeset 30 5dc02b23752f
parent 0 1918ee327afb
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
     1 
     1 
     2 /* pngget.c - retrieval of values from info struct
     2 /* pngget.c - retrieval of values from info struct
     3  *
     3  *
     4  * Last changed in libpng 1.2.37 [June 4, 2009]
     4  * Last changed in libpng 1.4.0 [January 3, 2010]
     5  * Copyright (c) 1998-2009 Glenn Randers-Pehrson
     5  * Copyright (c) 1998-2010 Glenn Randers-Pehrson
     6  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
     6  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
     7  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
     7  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
     8  *
     8  *
     9  * This code is released under the libpng license.
     9  * This code is released under the libpng license.
    10  * For conditions of distribution and use, see the disclaimer
    10  * For conditions of distribution and use, see the disclaimer
    11  * and license in png.h
    11  * and license in png.h
    12  *
    12  *
    13  */
    13  */
    14 
    14 
    15 #define PNG_INTERNAL
    15 #define PNG_NO_PEDANTIC_WARNINGS
    16 #include "png.h"
    16 #include "png.h"
    17 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
    17 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
       
    18 #include "pngpriv.h"
    18 
    19 
    19 png_uint_32 PNGAPI
    20 png_uint_32 PNGAPI
    20 png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
    21 png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
    21 {
    22 {
    22    if (png_ptr != NULL && info_ptr != NULL)
    23    if (png_ptr != NULL && info_ptr != NULL)
    24 
    25 
    25    else
    26    else
    26       return(0);
    27       return(0);
    27 }
    28 }
    28 
    29 
    29 png_uint_32 PNGAPI
    30 png_size_t PNGAPI
    30 png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
    31 png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
    31 {
    32 {
    32    if (png_ptr != NULL && info_ptr != NULL)
    33    if (png_ptr != NULL && info_ptr != NULL)
    33       return(info_ptr->rowbytes);
    34       return(info_ptr->rowbytes);
    34 
    35 
    35    else
    36    else
    36       return(0);
    37       return(0);
    37 }
    38 }
    38 
    39 
    39 #if defined(PNG_INFO_IMAGE_SUPPORTED)
    40 #ifdef PNG_INFO_IMAGE_SUPPORTED
    40 png_bytepp PNGAPI
    41 png_bytepp PNGAPI
    41 png_get_rows(png_structp png_ptr, png_infop info_ptr)
    42 png_get_rows(png_structp png_ptr, png_infop info_ptr)
    42 {
    43 {
    43    if (png_ptr != NULL && info_ptr != NULL)
    44    if (png_ptr != NULL && info_ptr != NULL)
    44       return(info_ptr->row_pointers);
    45       return(info_ptr->row_pointers);
   115 
   116 
   116 png_uint_32 PNGAPI
   117 png_uint_32 PNGAPI
   117 png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
   118 png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
   118 {
   119 {
   119    if (png_ptr != NULL && info_ptr != NULL)
   120    if (png_ptr != NULL && info_ptr != NULL)
   120 #if defined(PNG_pHYs_SUPPORTED)
   121 #ifdef PNG_pHYs_SUPPORTED
   121    if (info_ptr->valid & PNG_INFO_pHYs)
   122    if (info_ptr->valid & PNG_INFO_pHYs)
   122    {
   123    {
   123       png_debug1(1, "in %s retrieval function", "png_get_x_pixels_per_meter");
   124       png_debug1(1, "in %s retrieval function", "png_get_x_pixels_per_meter");
   124 
   125 
   125       if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
   126       if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
   136 
   137 
   137 png_uint_32 PNGAPI
   138 png_uint_32 PNGAPI
   138 png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
   139 png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
   139 {
   140 {
   140    if (png_ptr != NULL && info_ptr != NULL)
   141    if (png_ptr != NULL && info_ptr != NULL)
   141 #if defined(PNG_pHYs_SUPPORTED)
   142 #ifdef PNG_pHYs_SUPPORTED
   142    if (info_ptr->valid & PNG_INFO_pHYs)
   143    if (info_ptr->valid & PNG_INFO_pHYs)
   143    {
   144    {
   144       png_debug1(1, "in %s retrieval function", "png_get_y_pixels_per_meter");
   145       png_debug1(1, "in %s retrieval function", "png_get_y_pixels_per_meter");
   145 
   146 
   146       if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
   147       if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
   157 
   158 
   158 png_uint_32 PNGAPI
   159 png_uint_32 PNGAPI
   159 png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
   160 png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
   160 {
   161 {
   161    if (png_ptr != NULL && info_ptr != NULL)
   162    if (png_ptr != NULL && info_ptr != NULL)
   162 #if defined(PNG_pHYs_SUPPORTED)
   163 #ifdef PNG_pHYs_SUPPORTED
   163    if (info_ptr->valid & PNG_INFO_pHYs)
   164    if (info_ptr->valid & PNG_INFO_pHYs)
   164    {
   165    {
   165       png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
   166       png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
   166 
   167 
   167       if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
   168       if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
   180 #ifdef PNG_FLOATING_POINT_SUPPORTED
   181 #ifdef PNG_FLOATING_POINT_SUPPORTED
   181 float PNGAPI
   182 float PNGAPI
   182 png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
   183 png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
   183    {
   184    {
   184    if (png_ptr != NULL && info_ptr != NULL)
   185    if (png_ptr != NULL && info_ptr != NULL)
   185 #if defined(PNG_pHYs_SUPPORTED)
   186 #ifdef PNG_pHYs_SUPPORTED
   186 
   187 
   187    if (info_ptr->valid & PNG_INFO_pHYs)
   188    if (info_ptr->valid & PNG_INFO_pHYs)
   188    {
   189    {
   189       png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
   190       png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
       
   191 
   190       if (info_ptr->x_pixels_per_unit == 0)
   192       if (info_ptr->x_pixels_per_unit == 0)
   191          return ((float)0.0);
   193          return ((float)0.0);
       
   194 
   192       else
   195       else
   193          return ((float)((float)info_ptr->y_pixels_per_unit
   196          return ((float)((float)info_ptr->y_pixels_per_unit
   194             /(float)info_ptr->x_pixels_per_unit));
   197             /(float)info_ptr->x_pixels_per_unit));
   195    }
   198    }
   196 #else
   199 #else
   202 
   205 
   203 png_int_32 PNGAPI
   206 png_int_32 PNGAPI
   204 png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
   207 png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
   205 {
   208 {
   206    if (png_ptr != NULL && info_ptr != NULL)
   209    if (png_ptr != NULL && info_ptr != NULL)
   207 #if defined(PNG_oFFs_SUPPORTED)
   210 #ifdef PNG_oFFs_SUPPORTED
   208 
   211 
   209    if (info_ptr->valid & PNG_INFO_oFFs)
   212    if (info_ptr->valid & PNG_INFO_oFFs)
   210    {
   213    {
   211       png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
   214       png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
   212 
   215 
   225 png_int_32 PNGAPI
   228 png_int_32 PNGAPI
   226 png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
   229 png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
   227 {
   230 {
   228    if (png_ptr != NULL && info_ptr != NULL)
   231    if (png_ptr != NULL && info_ptr != NULL)
   229 
   232 
   230 #if defined(PNG_oFFs_SUPPORTED)
   233 #ifdef PNG_oFFs_SUPPORTED
   231    if (info_ptr->valid & PNG_INFO_oFFs)
   234    if (info_ptr->valid & PNG_INFO_oFFs)
   232    {
   235    {
   233       png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
   236       png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
   234 
   237 
   235       if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
   238       if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
   247 png_int_32 PNGAPI
   250 png_int_32 PNGAPI
   248 png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
   251 png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
   249 {
   252 {
   250    if (png_ptr != NULL && info_ptr != NULL)
   253    if (png_ptr != NULL && info_ptr != NULL)
   251 
   254 
   252 #if defined(PNG_oFFs_SUPPORTED)
   255 #ifdef PNG_oFFs_SUPPORTED
   253    if (info_ptr->valid & PNG_INFO_oFFs)
   256    if (info_ptr->valid & PNG_INFO_oFFs)
   254    {
   257    {
   255       png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
   258       png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
   256 
   259 
   257       if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
   260       if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
   269 png_int_32 PNGAPI
   272 png_int_32 PNGAPI
   270 png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
   273 png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
   271 {
   274 {
   272    if (png_ptr != NULL && info_ptr != NULL)
   275    if (png_ptr != NULL && info_ptr != NULL)
   273 
   276 
   274 #if defined(PNG_oFFs_SUPPORTED)
   277 #ifdef PNG_oFFs_SUPPORTED
   275    if (info_ptr->valid & PNG_INFO_oFFs)
   278    if (info_ptr->valid & PNG_INFO_oFFs)
   276    {
   279    {
   277       png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
   280       png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
   278 
   281 
   279       if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
   282       if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
   322 {
   325 {
   323    return ((float)png_get_y_offset_microns(png_ptr, info_ptr)
   326    return ((float)png_get_y_offset_microns(png_ptr, info_ptr)
   324      *.00003937);
   327      *.00003937);
   325 }
   328 }
   326 
   329 
   327 #if defined(PNG_pHYs_SUPPORTED)
   330 #ifdef PNG_pHYs_SUPPORTED
   328 png_uint_32 PNGAPI
   331 png_uint_32 PNGAPI
   329 png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
   332 png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
   330    png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
   333    png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
   331 {
   334 {
   332    png_uint_32 retval = 0;
   335    png_uint_32 retval = 0;
   333 
   336 
   334    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
   337    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
   335    {
   338    {
   336       png_debug1(1, "in %s retrieval function", "pHYs");
   339       png_debug1(1, "in %s retrieval function", "pHYs");
       
   340 
   337       if (res_x != NULL)
   341       if (res_x != NULL)
   338       {
   342       {
   339          *res_x = info_ptr->x_pixels_per_unit;
   343          *res_x = info_ptr->x_pixels_per_unit;
   340          retval |= PNG_INFO_pHYs;
   344          retval |= PNG_INFO_pHYs;
   341       }
   345       }
   380       return(info_ptr->signature);
   384       return(info_ptr->signature);
   381    else
   385    else
   382       return (NULL);
   386       return (NULL);
   383 }
   387 }
   384 
   388 
   385 #if defined(PNG_bKGD_SUPPORTED)
   389 #ifdef PNG_bKGD_SUPPORTED
   386 png_uint_32 PNGAPI
   390 png_uint_32 PNGAPI
   387 png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
   391 png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
   388    png_color_16p *background)
   392    png_color_16p *background)
   389 {
   393 {
   390    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
   394    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
   391       && background != NULL)
   395       && background != NULL)
   392    {
   396    {
   393       png_debug1(1, "in %s retrieval function", "bKGD");
   397       png_debug1(1, "in %s retrieval function", "bKGD");
       
   398 
   394       *background = &(info_ptr->background);
   399       *background = &(info_ptr->background);
   395       return (PNG_INFO_bKGD);
   400       return (PNG_INFO_bKGD);
   396    }
   401    }
   397    return (0);
   402    return (0);
   398 }
   403 }
   399 #endif
   404 #endif
   400 
   405 
   401 #if defined(PNG_cHRM_SUPPORTED)
   406 #ifdef PNG_cHRM_SUPPORTED
   402 #ifdef PNG_FLOATING_POINT_SUPPORTED
   407 #ifdef PNG_FLOATING_POINT_SUPPORTED
   403 png_uint_32 PNGAPI
   408 png_uint_32 PNGAPI
   404 png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
   409 png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
   405    double *white_x, double *white_y, double *red_x, double *red_y,
   410    double *white_x, double *white_y, double *red_x, double *red_y,
   406    double *green_x, double *green_y, double *blue_x, double *blue_y)
   411    double *green_x, double *green_y, double *blue_x, double *blue_y)
   407 {
   412 {
   408    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
   413    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
   409    {
   414    {
   410       png_debug1(1, "in %s retrieval function", "cHRM");
   415       png_debug1(1, "in %s retrieval function", "cHRM");
       
   416 
   411       if (white_x != NULL)
   417       if (white_x != NULL)
   412          *white_x = (double)info_ptr->x_white;
   418          *white_x = (double)info_ptr->x_white;
   413       if (white_y != NULL)
   419       if (white_y != NULL)
   414          *white_y = (double)info_ptr->y_white;
   420          *white_y = (double)info_ptr->y_white;
   415       if (red_x != NULL)
   421       if (red_x != NULL)
   434 png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
   440 png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
   435    png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
   441    png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
   436    png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
   442    png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
   437    png_fixed_point *blue_x, png_fixed_point *blue_y)
   443    png_fixed_point *blue_x, png_fixed_point *blue_y)
   438 {
   444 {
       
   445    png_debug1(1, "in %s retrieval function", "cHRM");
       
   446 
   439    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
   447    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
   440    {
   448    {
   441       png_debug1(1, "in %s retrieval function", "cHRM");
       
   442       if (white_x != NULL)
   449       if (white_x != NULL)
   443          *white_x = info_ptr->int_x_white;
   450          *white_x = info_ptr->int_x_white;
   444       if (white_y != NULL)
   451       if (white_y != NULL)
   445          *white_y = info_ptr->int_y_white;
   452          *white_y = info_ptr->int_y_white;
   446       if (red_x != NULL)
   453       if (red_x != NULL)
   460    return (0);
   467    return (0);
   461 }
   468 }
   462 #endif
   469 #endif
   463 #endif
   470 #endif
   464 
   471 
   465 #if defined(PNG_gAMA_SUPPORTED)
   472 #ifdef PNG_gAMA_SUPPORTED
   466 #ifdef PNG_FLOATING_POINT_SUPPORTED
   473 #ifdef PNG_FLOATING_POINT_SUPPORTED
   467 png_uint_32 PNGAPI
   474 png_uint_32 PNGAPI
   468 png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
   475 png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
   469 {
   476 {
       
   477    png_debug1(1, "in %s retrieval function", "gAMA");
       
   478 
   470    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
   479    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
   471       && file_gamma != NULL)
   480       && file_gamma != NULL)
   472    {
   481    {
   473       png_debug1(1, "in %s retrieval function", "gAMA");
       
   474       *file_gamma = (double)info_ptr->gamma;
   482       *file_gamma = (double)info_ptr->gamma;
   475       return (PNG_INFO_gAMA);
   483       return (PNG_INFO_gAMA);
   476    }
   484    }
   477    return (0);
   485    return (0);
   478 }
   486 }
   480 #ifdef PNG_FIXED_POINT_SUPPORTED
   488 #ifdef PNG_FIXED_POINT_SUPPORTED
   481 png_uint_32 PNGAPI
   489 png_uint_32 PNGAPI
   482 png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
   490 png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
   483     png_fixed_point *int_file_gamma)
   491     png_fixed_point *int_file_gamma)
   484 {
   492 {
       
   493    png_debug1(1, "in %s retrieval function", "gAMA");
       
   494 
   485    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
   495    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
   486       && int_file_gamma != NULL)
   496       && int_file_gamma != NULL)
   487    {
   497    {
   488       png_debug1(1, "in %s retrieval function", "gAMA");
       
   489       *int_file_gamma = info_ptr->int_gamma;
   498       *int_file_gamma = info_ptr->int_gamma;
   490       return (PNG_INFO_gAMA);
   499       return (PNG_INFO_gAMA);
   491    }
   500    }
   492    return (0);
   501    return (0);
   493 }
   502 }
   494 #endif
   503 #endif
   495 #endif
   504 #endif
   496 
   505 
   497 #if defined(PNG_sRGB_SUPPORTED)
   506 #ifdef PNG_sRGB_SUPPORTED
   498 png_uint_32 PNGAPI
   507 png_uint_32 PNGAPI
   499 png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
   508 png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
   500 {
   509 {
       
   510    png_debug1(1, "in %s retrieval function", "sRGB");
       
   511 
   501    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
   512    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
   502       && file_srgb_intent != NULL)
   513       && file_srgb_intent != NULL)
   503    {
   514    {
   504       png_debug1(1, "in %s retrieval function", "sRGB");
       
   505       *file_srgb_intent = (int)info_ptr->srgb_intent;
   515       *file_srgb_intent = (int)info_ptr->srgb_intent;
   506       return (PNG_INFO_sRGB);
   516       return (PNG_INFO_sRGB);
   507    }
   517    }
   508    return (0);
   518    return (0);
   509 }
   519 }
   510 #endif
   520 #endif
   511 
   521 
   512 #if defined(PNG_iCCP_SUPPORTED)
   522 #ifdef PNG_iCCP_SUPPORTED
   513 png_uint_32 PNGAPI
   523 png_uint_32 PNGAPI
   514 png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
   524 png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
   515              png_charpp name, int *compression_type,
   525              png_charpp name, int *compression_type,
   516              png_charpp profile, png_uint_32 *proflen)
   526              png_charpp profile, png_uint_32 *proflen)
   517 {
   527 {
       
   528    png_debug1(1, "in %s retrieval function", "iCCP");
       
   529 
   518    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
   530    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
   519       && name != NULL && profile != NULL && proflen != NULL)
   531       && name != NULL && profile != NULL && proflen != NULL)
   520    {
   532    {
   521       png_debug1(1, "in %s retrieval function", "iCCP");
       
   522       *name = info_ptr->iccp_name;
   533       *name = info_ptr->iccp_name;
   523       *profile = info_ptr->iccp_profile;
   534       *profile = info_ptr->iccp_profile;
   524       /* Compression_type is a dummy so the API won't have to change
   535       /* Compression_type is a dummy so the API won't have to change
   525        * if we introduce multiple compression types later.
   536        * if we introduce multiple compression types later.
   526        */
   537        */
   530    }
   541    }
   531    return (0);
   542    return (0);
   532 }
   543 }
   533 #endif
   544 #endif
   534 
   545 
   535 #if defined(PNG_sPLT_SUPPORTED)
   546 #ifdef PNG_sPLT_SUPPORTED
   536 png_uint_32 PNGAPI
   547 png_uint_32 PNGAPI
   537 png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
   548 png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
   538              png_sPLT_tpp spalettes)
   549              png_sPLT_tpp spalettes)
   539 {
   550 {
   540    if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
   551    if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
   544    }
   555    }
   545    return (0);
   556    return (0);
   546 }
   557 }
   547 #endif
   558 #endif
   548 
   559 
   549 #if defined(PNG_hIST_SUPPORTED)
   560 #ifdef PNG_hIST_SUPPORTED
   550 png_uint_32 PNGAPI
   561 png_uint_32 PNGAPI
   551 png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
   562 png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
   552 {
   563 {
       
   564    png_debug1(1, "in %s retrieval function", "hIST");
       
   565 
   553    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
   566    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
   554       && hist != NULL)
   567       && hist != NULL)
   555    {
   568    {
   556       png_debug1(1, "in %s retrieval function", "hIST");
       
   557       *hist = info_ptr->hist;
   569       *hist = info_ptr->hist;
   558       return (PNG_INFO_hIST);
   570       return (PNG_INFO_hIST);
   559    }
   571    }
   560    return (0);
   572    return (0);
   561 }
   573 }
   566    png_uint_32 *width, png_uint_32 *height, int *bit_depth,
   578    png_uint_32 *width, png_uint_32 *height, int *bit_depth,
   567    int *color_type, int *interlace_type, int *compression_type,
   579    int *color_type, int *interlace_type, int *compression_type,
   568    int *filter_type)
   580    int *filter_type)
   569 
   581 
   570 {
   582 {
   571    if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL &&
   583    png_debug1(1, "in %s retrieval function", "IHDR");
   572       bit_depth != NULL && color_type != NULL)
   584 
   573    {
   585    if (png_ptr == NULL || info_ptr == NULL || width == NULL ||
   574       png_debug1(1, "in %s retrieval function", "IHDR");
   586        height == NULL || bit_depth == NULL || color_type == NULL)
   575       *width = info_ptr->width;
   587       return (0);
   576       *height = info_ptr->height;
   588 
   577       *bit_depth = info_ptr->bit_depth;
   589    *width = info_ptr->width;
   578       if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16)
   590    *height = info_ptr->height;
   579          png_error(png_ptr, "Invalid bit depth");
   591    *bit_depth = info_ptr->bit_depth;
   580 
   592    *color_type = info_ptr->color_type;
   581       *color_type = info_ptr->color_type;
   593 
   582 
   594    if (compression_type != NULL)
   583       if (info_ptr->color_type > 6)
   595       *compression_type = info_ptr->compression_type;
   584          png_error(png_ptr, "Invalid color type");
   596 
   585 
   597    if (filter_type != NULL)
   586       if (compression_type != NULL)
   598       *filter_type = info_ptr->filter_type;
   587          *compression_type = info_ptr->compression_type;
   599 
   588 
   600    if (interlace_type != NULL)
   589       if (filter_type != NULL)
   601       *interlace_type = info_ptr->interlace_type;
   590          *filter_type = info_ptr->filter_type;
   602 
   591 
   603    /* This is redundant if we can be sure that the info_ptr values were all
   592       if (interlace_type != NULL)
   604     * assigned in png_set_IHDR().  We do the check anyhow in case an
   593          *interlace_type = info_ptr->interlace_type;
   605     * application has ignored our advice not to mess with the members
   594 
   606     * of info_ptr directly.
   595       /* Check for potential overflow of rowbytes */
   607     */
   596       if (*width == 0 || *width > PNG_UINT_31_MAX)
   608    png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height,
   597         png_error(png_ptr, "Invalid image width");
   609        info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,
   598 
   610        info_ptr->compression_type, info_ptr->filter_type);
   599       if (*height == 0 || *height > PNG_UINT_31_MAX)
   611 
   600         png_error(png_ptr, "Invalid image height");
   612    return (1);
   601 
   613 }
   602       if (info_ptr->width > (PNG_UINT_32_MAX
   614 
   603                  >> 3)      /* 8-byte RGBA pixels */
   615 #ifdef PNG_oFFs_SUPPORTED
   604                  - 64       /* bigrowbuf hack */
       
   605                  - 1        /* filter byte */
       
   606                  - 7*8      /* rounding of width to multiple of 8 pixels */
       
   607                  - 8)       /* extra max_pixel_depth pad */
       
   608       {
       
   609          png_warning(png_ptr,
       
   610             "Width too large for libpng to process image data.");
       
   611       }
       
   612 
       
   613       return (1);
       
   614    }
       
   615    return (0);
       
   616 }
       
   617 
       
   618 #if defined(PNG_oFFs_SUPPORTED)
       
   619 png_uint_32 PNGAPI
   616 png_uint_32 PNGAPI
   620 png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
   617 png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
   621    png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
   618    png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
   622 {
   619 {
       
   620    png_debug1(1, "in %s retrieval function", "oFFs");
       
   621 
   623    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
   622    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
   624       && offset_x != NULL && offset_y != NULL && unit_type != NULL)
   623       && offset_x != NULL && offset_y != NULL && unit_type != NULL)
   625    {
   624    {
   626       png_debug1(1, "in %s retrieval function", "oFFs");
       
   627       *offset_x = info_ptr->x_offset;
   625       *offset_x = info_ptr->x_offset;
   628       *offset_y = info_ptr->y_offset;
   626       *offset_y = info_ptr->y_offset;
   629       *unit_type = (int)info_ptr->offset_unit_type;
   627       *unit_type = (int)info_ptr->offset_unit_type;
   630       return (PNG_INFO_oFFs);
   628       return (PNG_INFO_oFFs);
   631    }
   629    }
   632    return (0);
   630    return (0);
   633 }
   631 }
   634 #endif
   632 #endif
   635 
   633 
   636 #if defined(PNG_pCAL_SUPPORTED)
   634 #ifdef PNG_pCAL_SUPPORTED
   637 png_uint_32 PNGAPI
   635 png_uint_32 PNGAPI
   638 png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
   636 png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
   639    png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
   637    png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
   640    png_charp *units, png_charpp *params)
   638    png_charp *units, png_charpp *params)
   641 {
   639 {
       
   640    png_debug1(1, "in %s retrieval function", "pCAL");
       
   641 
   642    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
   642    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
   643        && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
   643        && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
   644        nparams != NULL && units != NULL && params != NULL)
   644        nparams != NULL && units != NULL && params != NULL)
   645    {
   645    {
   646       png_debug1(1, "in %s retrieval function", "pCAL");
       
   647       *purpose = info_ptr->pcal_purpose;
   646       *purpose = info_ptr->pcal_purpose;
   648       *X0 = info_ptr->pcal_X0;
   647       *X0 = info_ptr->pcal_X0;
   649       *X1 = info_ptr->pcal_X1;
   648       *X1 = info_ptr->pcal_X1;
   650       *type = (int)info_ptr->pcal_type;
   649       *type = (int)info_ptr->pcal_type;
   651       *nparams = (int)info_ptr->pcal_nparams;
   650       *nparams = (int)info_ptr->pcal_nparams;
   655    }
   654    }
   656    return (0);
   655    return (0);
   657 }
   656 }
   658 #endif
   657 #endif
   659 
   658 
   660 #if defined(PNG_sCAL_SUPPORTED)
   659 #ifdef PNG_sCAL_SUPPORTED
   661 #ifdef PNG_FLOATING_POINT_SUPPORTED
   660 #ifdef PNG_FLOATING_POINT_SUPPORTED
   662 png_uint_32 PNGAPI
   661 png_uint_32 PNGAPI
   663 png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
   662 png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
   664              int *unit, double *width, double *height)
   663              int *unit, double *width, double *height)
   665 {
   664 {
   691 }
   690 }
   692 #endif
   691 #endif
   693 #endif
   692 #endif
   694 #endif
   693 #endif
   695 
   694 
   696 #if defined(PNG_pHYs_SUPPORTED)
   695 #ifdef PNG_pHYs_SUPPORTED
   697 png_uint_32 PNGAPI
   696 png_uint_32 PNGAPI
   698 png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
   697 png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
   699    png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
   698    png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
   700 {
   699 {
   701    png_uint_32 retval = 0;
   700    png_uint_32 retval = 0;
   702 
   701 
       
   702    png_debug1(1, "in %s retrieval function", "pHYs");
       
   703 
   703    if (png_ptr != NULL && info_ptr != NULL &&
   704    if (png_ptr != NULL && info_ptr != NULL &&
   704       (info_ptr->valid & PNG_INFO_pHYs))
   705       (info_ptr->valid & PNG_INFO_pHYs))
   705    {
   706    {
   706       png_debug1(1, "in %s retrieval function", "pHYs");
       
   707 
       
   708       if (res_x != NULL)
   707       if (res_x != NULL)
   709       {
   708       {
   710          *res_x = info_ptr->x_pixels_per_unit;
   709          *res_x = info_ptr->x_pixels_per_unit;
   711          retval |= PNG_INFO_pHYs;
   710          retval |= PNG_INFO_pHYs;
   712       }
   711       }
   729 
   728 
   730 png_uint_32 PNGAPI
   729 png_uint_32 PNGAPI
   731 png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
   730 png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
   732    int *num_palette)
   731    int *num_palette)
   733 {
   732 {
       
   733    png_debug1(1, "in %s retrieval function", "PLTE");
       
   734 
   734    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
   735    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
   735        && palette != NULL)
   736        && palette != NULL)
   736    {
   737    {
   737       png_debug1(1, "in %s retrieval function", "PLTE");
       
   738       *palette = info_ptr->palette;
   738       *palette = info_ptr->palette;
   739       *num_palette = info_ptr->num_palette;
   739       *num_palette = info_ptr->num_palette;
   740       png_debug1(3, "num_palette = %d", *num_palette);
   740       png_debug1(3, "num_palette = %d", *num_palette);
   741       return (PNG_INFO_PLTE);
   741       return (PNG_INFO_PLTE);
   742    }
   742    }
   743    return (0);
   743    return (0);
   744 }
   744 }
   745 
   745 
   746 #if defined(PNG_sBIT_SUPPORTED)
   746 #ifdef PNG_sBIT_SUPPORTED
   747 png_uint_32 PNGAPI
   747 png_uint_32 PNGAPI
   748 png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
   748 png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
   749 {
   749 {
       
   750    png_debug1(1, "in %s retrieval function", "sBIT");
       
   751 
   750    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
   752    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
   751       && sig_bit != NULL)
   753       && sig_bit != NULL)
   752    {
   754    {
   753       png_debug1(1, "in %s retrieval function", "sBIT");
       
   754       *sig_bit = &(info_ptr->sig_bit);
   755       *sig_bit = &(info_ptr->sig_bit);
   755       return (PNG_INFO_sBIT);
   756       return (PNG_INFO_sBIT);
   756    }
   757    }
   757    return (0);
   758    return (0);
   758 }
   759 }
   759 #endif
   760 #endif
   760 
   761 
   761 #if defined(PNG_TEXT_SUPPORTED)
   762 #ifdef PNG_TEXT_SUPPORTED
   762 png_uint_32 PNGAPI
   763 png_uint_32 PNGAPI
   763 png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
   764 png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
   764    int *num_text)
   765    int *num_text)
   765 {
   766 {
   766    if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
   767    if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
   781      *num_text = 0;
   782      *num_text = 0;
   782    return(0);
   783    return(0);
   783 }
   784 }
   784 #endif
   785 #endif
   785 
   786 
   786 #if defined(PNG_tIME_SUPPORTED)
   787 #ifdef PNG_tIME_SUPPORTED
   787 png_uint_32 PNGAPI
   788 png_uint_32 PNGAPI
   788 png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
   789 png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
   789 {
   790 {
       
   791    png_debug1(1, "in %s retrieval function", "tIME");
       
   792 
   790    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
   793    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
   791        && mod_time != NULL)
   794        && mod_time != NULL)
   792    {
   795    {
   793       png_debug1(1, "in %s retrieval function", "tIME");
       
   794       *mod_time = &(info_ptr->mod_time);
   796       *mod_time = &(info_ptr->mod_time);
   795       return (PNG_INFO_tIME);
   797       return (PNG_INFO_tIME);
   796    }
   798    }
   797    return (0);
   799    return (0);
   798 }
   800 }
   799 #endif
   801 #endif
   800 
   802 
   801 #if defined(PNG_tRNS_SUPPORTED)
   803 #ifdef PNG_tRNS_SUPPORTED
   802 png_uint_32 PNGAPI
   804 png_uint_32 PNGAPI
   803 png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
   805 png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
   804    png_bytep *trans, int *num_trans, png_color_16p *trans_values)
   806    png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
   805 {
   807 {
   806    png_uint_32 retval = 0;
   808    png_uint_32 retval = 0;
   807    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
   809    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
   808    {
   810    {
   809       png_debug1(1, "in %s retrieval function", "tRNS");
   811       png_debug1(1, "in %s retrieval function", "tRNS");
       
   812 
   810       if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
   813       if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
   811       {
   814       {
   812           if (trans != NULL)
   815           if (trans_alpha != NULL)
   813           {
   816           {
   814              *trans = info_ptr->trans;
   817              *trans_alpha = info_ptr->trans_alpha;
   815              retval |= PNG_INFO_tRNS;
   818              retval |= PNG_INFO_tRNS;
   816           }
   819           }
   817 
   820 
   818           if (trans_values != NULL)
   821           if (trans_color != NULL)
   819              *trans_values = &(info_ptr->trans_values);
   822              *trans_color = &(info_ptr->trans_color);
   820       }
   823       }
   821       else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
   824       else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
   822       {
   825       {
   823           if (trans_values != NULL)
   826           if (trans_color != NULL)
   824           {
   827           {
   825              *trans_values = &(info_ptr->trans_values);
   828              *trans_color = &(info_ptr->trans_color);
   826              retval |= PNG_INFO_tRNS;
   829              retval |= PNG_INFO_tRNS;
   827           }
   830           }
   828 
   831 
   829           if (trans != NULL)
   832           if (trans_alpha != NULL)
   830              *trans = NULL;
   833              *trans_alpha = NULL;
   831       }
   834       }
   832       if (num_trans != NULL)
   835       if (num_trans != NULL)
   833       {
   836       {
   834          *num_trans = info_ptr->num_trans;
   837          *num_trans = info_ptr->num_trans;
   835          retval |= PNG_INFO_tRNS;
   838          retval |= PNG_INFO_tRNS;
   837    }
   840    }
   838    return (retval);
   841    return (retval);
   839 }
   842 }
   840 #endif
   843 #endif
   841 
   844 
   842 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
   845 #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
   843 png_uint_32 PNGAPI
   846 png_uint_32 PNGAPI
   844 png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
   847 png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
   845              png_unknown_chunkpp unknowns)
   848              png_unknown_chunkpp unknowns)
   846 {
   849 {
   847    if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
   850    if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
   851    }
   854    }
   852    return (0);
   855    return (0);
   853 }
   856 }
   854 #endif
   857 #endif
   855 
   858 
   856 #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
   859 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
   857 png_byte PNGAPI
   860 png_byte PNGAPI
   858 png_get_rgb_to_gray_status (png_structp png_ptr)
   861 png_get_rgb_to_gray_status (png_structp png_ptr)
   859 {
   862 {
   860    return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0);
   863    return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0);
   861 }
   864 }
   862 #endif
   865 #endif
   863 
   866 
   864 #if defined(PNG_USER_CHUNKS_SUPPORTED)
   867 #ifdef PNG_USER_CHUNKS_SUPPORTED
   865 png_voidp PNGAPI
   868 png_voidp PNGAPI
   866 png_get_user_chunk_ptr(png_structp png_ptr)
   869 png_get_user_chunk_ptr(png_structp png_ptr)
   867 {
   870 {
   868    return (png_ptr? png_ptr->user_chunk_ptr : NULL);
   871    return (png_ptr? png_ptr->user_chunk_ptr : NULL);
   869 }
   872 }
   870 #endif
   873 #endif
   871 
   874 
   872 #ifdef PNG_WRITE_SUPPORTED
   875 #ifdef PNG_WRITE_SUPPORTED
   873 png_uint_32 PNGAPI
   876 png_size_t PNGAPI
   874 png_get_compression_buffer_size(png_structp png_ptr)
   877 png_get_compression_buffer_size(png_structp png_ptr)
   875 {
   878 {
   876    return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L);
   879    return (png_ptr ? png_ptr->zbuf_size : 0L);
   877 }
   880 }
   878 #endif
   881 #endif
   879 
   882 
   880 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
       
   881 #ifndef PNG_1_0_X
       
   882 /* This function was added to libpng 1.2.0 and should exist by default */
       
   883 png_uint_32 PNGAPI
       
   884 png_get_asm_flags (png_structp png_ptr)
       
   885 {
       
   886     /* Obsolete, to be removed from libpng-1.4.0 */
       
   887     return (png_ptr? 0L: 0L);
       
   888 }
       
   889 
       
   890 /* This function was added to libpng 1.2.0 and should exist by default */
       
   891 png_uint_32 PNGAPI
       
   892 png_get_asm_flagmask (int flag_select)
       
   893 {
       
   894     /* Obsolete, to be removed from libpng-1.4.0 */
       
   895     flag_select=flag_select;
       
   896     return 0L;
       
   897 }
       
   898 
       
   899     /* GRR:  could add this:   && defined(PNG_MMX_CODE_SUPPORTED) */
       
   900 /* This function was added to libpng 1.2.0 */
       
   901 png_uint_32 PNGAPI
       
   902 png_get_mmx_flagmask (int flag_select, int *compilerID)
       
   903 {
       
   904     /* Obsolete, to be removed from libpng-1.4.0 */
       
   905     flag_select=flag_select;
       
   906     *compilerID = -1;   /* unknown (i.e., no asm/MMX code compiled) */
       
   907     return 0L;
       
   908 }
       
   909 
       
   910 /* This function was added to libpng 1.2.0 */
       
   911 png_byte PNGAPI
       
   912 png_get_mmx_bitdepth_threshold (png_structp png_ptr)
       
   913 {
       
   914     /* Obsolete, to be removed from libpng-1.4.0 */
       
   915     return (png_ptr? 0: 0);
       
   916 }
       
   917 
       
   918 /* This function was added to libpng 1.2.0 */
       
   919 png_uint_32 PNGAPI
       
   920 png_get_mmx_rowbytes_threshold (png_structp png_ptr)
       
   921 {
       
   922     /* Obsolete, to be removed from libpng-1.4.0 */
       
   923     return (png_ptr? 0L: 0L);
       
   924 }
       
   925 #endif /* ?PNG_1_0_X */
       
   926 #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
       
   927 
   883 
   928 #ifdef PNG_SET_USER_LIMITS_SUPPORTED
   884 #ifdef PNG_SET_USER_LIMITS_SUPPORTED
   929 /* These functions were added to libpng 1.2.6 */
   885 /* These functions were added to libpng 1.2.6 */
   930 png_uint_32 PNGAPI
   886 png_uint_32 PNGAPI
   931 png_get_user_width_max (png_structp png_ptr)
   887 png_get_user_width_max (png_structp png_ptr)
   935 png_uint_32 PNGAPI
   891 png_uint_32 PNGAPI
   936 png_get_user_height_max (png_structp png_ptr)
   892 png_get_user_height_max (png_structp png_ptr)
   937 {
   893 {
   938     return (png_ptr? png_ptr->user_height_max : 0);
   894     return (png_ptr? png_ptr->user_height_max : 0);
   939 }
   895 }
       
   896 /* This function was added to libpng 1.4.0 */
       
   897 png_uint_32 PNGAPI
       
   898 png_get_chunk_cache_max (png_structp png_ptr)
       
   899 {
       
   900     return (png_ptr? png_ptr->user_chunk_cache_max? 0x7fffffffL :
       
   901        png_ptr->user_chunk_cache_max - 1 : 0);
       
   902 }
   940 #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
   903 #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
   941 
   904 
       
   905 #ifdef PNG_IO_STATE_SUPPORTED
       
   906 png_uint_32 PNGAPI
       
   907 png_get_io_state (png_structp png_ptr)
       
   908 {
       
   909     return png_ptr->io_state;
       
   910 }
       
   911 
       
   912 png_bytep PNGAPI
       
   913 png_get_io_chunk_name (png_structp png_ptr)
       
   914 {
       
   915    return png_ptr->chunk_name;
       
   916 }
       
   917 #endif /* ?PNG_IO_STATE_SUPPORTED */
   942 
   918 
   943 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
   919 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */