istereo

diff libs/libpng/pngget.c @ 26:862a3329a8f0

wohooo, added a shitload of code from zlib/libpng/libjpeg. When the good lord was raining shared libraries the iphone held a fucking umbrella...
author John Tsiombikas <nuclear@mutantstargoat.com>
date Thu, 08 Sep 2011 06:28:38 +0300
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/libpng/pngget.c	Thu Sep 08 06:28:38 2011 +0300
     1.3 @@ -0,0 +1,900 @@
     1.4 +
     1.5 +/* pngget.c - retrieval of values from info struct
     1.6 + *
     1.7 + * Last changed in libpng 1.2.30 [August 15, 2008]
     1.8 + * For conditions of distribution and use, see copyright notice in png.h
     1.9 + * Copyright (c) 1998-2008 Glenn Randers-Pehrson
    1.10 + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    1.11 + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
    1.12 + */
    1.13 +
    1.14 +#define PNG_INTERNAL
    1.15 +#include "png.h"
    1.16 +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
    1.17 +
    1.18 +png_uint_32 PNGAPI
    1.19 +png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
    1.20 +{
    1.21 +   if (png_ptr != NULL && info_ptr != NULL)
    1.22 +      return(info_ptr->valid & flag);
    1.23 +   else
    1.24 +      return(0);
    1.25 +}
    1.26 +
    1.27 +png_uint_32 PNGAPI
    1.28 +png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
    1.29 +{
    1.30 +   if (png_ptr != NULL && info_ptr != NULL)
    1.31 +      return(info_ptr->rowbytes);
    1.32 +   else
    1.33 +      return(0);
    1.34 +}
    1.35 +
    1.36 +#if defined(PNG_INFO_IMAGE_SUPPORTED)
    1.37 +png_bytepp PNGAPI
    1.38 +png_get_rows(png_structp png_ptr, png_infop info_ptr)
    1.39 +{
    1.40 +   if (png_ptr != NULL && info_ptr != NULL)
    1.41 +      return(info_ptr->row_pointers);
    1.42 +   else
    1.43 +      return(0);
    1.44 +}
    1.45 +#endif
    1.46 +
    1.47 +#ifdef PNG_EASY_ACCESS_SUPPORTED
    1.48 +/* easy access to info, added in libpng-0.99 */
    1.49 +png_uint_32 PNGAPI
    1.50 +png_get_image_width(png_structp png_ptr, png_infop info_ptr)
    1.51 +{
    1.52 +   if (png_ptr != NULL && info_ptr != NULL)
    1.53 +   {
    1.54 +      return info_ptr->width;
    1.55 +   }
    1.56 +   return (0);
    1.57 +}
    1.58 +
    1.59 +png_uint_32 PNGAPI
    1.60 +png_get_image_height(png_structp png_ptr, png_infop info_ptr)
    1.61 +{
    1.62 +   if (png_ptr != NULL && info_ptr != NULL)
    1.63 +   {
    1.64 +      return info_ptr->height;
    1.65 +   }
    1.66 +   return (0);
    1.67 +}
    1.68 +
    1.69 +png_byte PNGAPI
    1.70 +png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
    1.71 +{
    1.72 +   if (png_ptr != NULL && info_ptr != NULL)
    1.73 +   {
    1.74 +      return info_ptr->bit_depth;
    1.75 +   }
    1.76 +   return (0);
    1.77 +}
    1.78 +
    1.79 +png_byte PNGAPI
    1.80 +png_get_color_type(png_structp png_ptr, png_infop info_ptr)
    1.81 +{
    1.82 +   if (png_ptr != NULL && info_ptr != NULL)
    1.83 +   {
    1.84 +      return info_ptr->color_type;
    1.85 +   }
    1.86 +   return (0);
    1.87 +}
    1.88 +
    1.89 +png_byte PNGAPI
    1.90 +png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
    1.91 +{
    1.92 +   if (png_ptr != NULL && info_ptr != NULL)
    1.93 +   {
    1.94 +      return info_ptr->filter_type;
    1.95 +   }
    1.96 +   return (0);
    1.97 +}
    1.98 +
    1.99 +png_byte PNGAPI
   1.100 +png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
   1.101 +{
   1.102 +   if (png_ptr != NULL && info_ptr != NULL)
   1.103 +   {
   1.104 +      return info_ptr->interlace_type;
   1.105 +   }
   1.106 +   return (0);
   1.107 +}
   1.108 +
   1.109 +png_byte PNGAPI
   1.110 +png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
   1.111 +{
   1.112 +   if (png_ptr != NULL && info_ptr != NULL)
   1.113 +   {
   1.114 +      return info_ptr->compression_type;
   1.115 +   }
   1.116 +   return (0);
   1.117 +}
   1.118 +
   1.119 +png_uint_32 PNGAPI
   1.120 +png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
   1.121 +{
   1.122 +   if (png_ptr != NULL && info_ptr != NULL)
   1.123 +#if defined(PNG_pHYs_SUPPORTED)
   1.124 +   if (info_ptr->valid & PNG_INFO_pHYs)
   1.125 +   {
   1.126 +      png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter");
   1.127 +      if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
   1.128 +          return (0);
   1.129 +      else return (info_ptr->x_pixels_per_unit);
   1.130 +   }
   1.131 +#else
   1.132 +   return (0);
   1.133 +#endif
   1.134 +   return (0);
   1.135 +}
   1.136 +
   1.137 +png_uint_32 PNGAPI
   1.138 +png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
   1.139 +{
   1.140 +   if (png_ptr != NULL && info_ptr != NULL)
   1.141 +#if defined(PNG_pHYs_SUPPORTED)
   1.142 +   if (info_ptr->valid & PNG_INFO_pHYs)
   1.143 +   {
   1.144 +      png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter");
   1.145 +      if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
   1.146 +          return (0);
   1.147 +      else return (info_ptr->y_pixels_per_unit);
   1.148 +   }
   1.149 +#else
   1.150 +   return (0);
   1.151 +#endif
   1.152 +   return (0);
   1.153 +}
   1.154 +
   1.155 +png_uint_32 PNGAPI
   1.156 +png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
   1.157 +{
   1.158 +   if (png_ptr != NULL && info_ptr != NULL)
   1.159 +#if defined(PNG_pHYs_SUPPORTED)
   1.160 +   if (info_ptr->valid & PNG_INFO_pHYs)
   1.161 +   {
   1.162 +      png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter");
   1.163 +      if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
   1.164 +         info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit)
   1.165 +          return (0);
   1.166 +      else return (info_ptr->x_pixels_per_unit);
   1.167 +   }
   1.168 +#else
   1.169 +   return (0);
   1.170 +#endif
   1.171 +   return (0);
   1.172 +}
   1.173 +
   1.174 +#ifdef PNG_FLOATING_POINT_SUPPORTED
   1.175 +float PNGAPI
   1.176 +png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
   1.177 +   {
   1.178 +   if (png_ptr != NULL && info_ptr != NULL)
   1.179 +#if defined(PNG_pHYs_SUPPORTED)
   1.180 +   if (info_ptr->valid & PNG_INFO_pHYs)
   1.181 +   {
   1.182 +      png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio");
   1.183 +      if (info_ptr->x_pixels_per_unit == 0)
   1.184 +         return ((float)0.0);
   1.185 +      else
   1.186 +         return ((float)((float)info_ptr->y_pixels_per_unit
   1.187 +            /(float)info_ptr->x_pixels_per_unit));
   1.188 +   }
   1.189 +#else
   1.190 +   return (0.0);
   1.191 +#endif
   1.192 +   return ((float)0.0);
   1.193 +}
   1.194 +#endif
   1.195 +
   1.196 +png_int_32 PNGAPI
   1.197 +png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
   1.198 +{
   1.199 +   if (png_ptr != NULL && info_ptr != NULL)
   1.200 +#if defined(PNG_oFFs_SUPPORTED)
   1.201 +   if (info_ptr->valid & PNG_INFO_oFFs)
   1.202 +   {
   1.203 +      png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
   1.204 +      if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
   1.205 +          return (0);
   1.206 +      else return (info_ptr->x_offset);
   1.207 +   }
   1.208 +#else
   1.209 +   return (0);
   1.210 +#endif
   1.211 +   return (0);
   1.212 +}
   1.213 +
   1.214 +png_int_32 PNGAPI
   1.215 +png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
   1.216 +{
   1.217 +   if (png_ptr != NULL && info_ptr != NULL)
   1.218 +#if defined(PNG_oFFs_SUPPORTED)
   1.219 +   if (info_ptr->valid & PNG_INFO_oFFs)
   1.220 +   {
   1.221 +      png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
   1.222 +      if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
   1.223 +          return (0);
   1.224 +      else return (info_ptr->y_offset);
   1.225 +   }
   1.226 +#else
   1.227 +   return (0);
   1.228 +#endif
   1.229 +   return (0);
   1.230 +}
   1.231 +
   1.232 +png_int_32 PNGAPI
   1.233 +png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
   1.234 +{
   1.235 +   if (png_ptr != NULL && info_ptr != NULL)
   1.236 +#if defined(PNG_oFFs_SUPPORTED)
   1.237 +   if (info_ptr->valid & PNG_INFO_oFFs)
   1.238 +   {
   1.239 +      png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
   1.240 +      if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
   1.241 +          return (0);
   1.242 +      else return (info_ptr->x_offset);
   1.243 +   }
   1.244 +#else
   1.245 +   return (0);
   1.246 +#endif
   1.247 +   return (0);
   1.248 +}
   1.249 +
   1.250 +png_int_32 PNGAPI
   1.251 +png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
   1.252 +{
   1.253 +   if (png_ptr != NULL && info_ptr != NULL)
   1.254 +#if defined(PNG_oFFs_SUPPORTED)
   1.255 +   if (info_ptr->valid & PNG_INFO_oFFs)
   1.256 +   {
   1.257 +      png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
   1.258 +      if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
   1.259 +          return (0);
   1.260 +      else return (info_ptr->y_offset);
   1.261 +   }
   1.262 +#else
   1.263 +   return (0);
   1.264 +#endif
   1.265 +   return (0);
   1.266 +}
   1.267 +
   1.268 +#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
   1.269 +png_uint_32 PNGAPI
   1.270 +png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
   1.271 +{
   1.272 +   return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr)
   1.273 +     *.0254 +.5));
   1.274 +}
   1.275 +
   1.276 +png_uint_32 PNGAPI
   1.277 +png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
   1.278 +{
   1.279 +   return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr)
   1.280 +     *.0254 +.5));
   1.281 +}
   1.282 +
   1.283 +png_uint_32 PNGAPI
   1.284 +png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
   1.285 +{
   1.286 +   return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr)
   1.287 +     *.0254 +.5));
   1.288 +}
   1.289 +
   1.290 +float PNGAPI
   1.291 +png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr)
   1.292 +{
   1.293 +   return ((float)png_get_x_offset_microns(png_ptr, info_ptr)
   1.294 +     *.00003937);
   1.295 +}
   1.296 +
   1.297 +float PNGAPI
   1.298 +png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
   1.299 +{
   1.300 +   return ((float)png_get_y_offset_microns(png_ptr, info_ptr)
   1.301 +     *.00003937);
   1.302 +}
   1.303 +
   1.304 +#if defined(PNG_pHYs_SUPPORTED)
   1.305 +png_uint_32 PNGAPI
   1.306 +png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
   1.307 +   png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
   1.308 +{
   1.309 +   png_uint_32 retval = 0;
   1.310 +
   1.311 +   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
   1.312 +   {
   1.313 +      png_debug1(1, "in %s retrieval function\n", "pHYs");
   1.314 +      if (res_x != NULL)
   1.315 +      {
   1.316 +         *res_x = info_ptr->x_pixels_per_unit;
   1.317 +         retval |= PNG_INFO_pHYs;
   1.318 +      }
   1.319 +      if (res_y != NULL)
   1.320 +      {
   1.321 +         *res_y = info_ptr->y_pixels_per_unit;
   1.322 +         retval |= PNG_INFO_pHYs;
   1.323 +      }
   1.324 +      if (unit_type != NULL)
   1.325 +      {
   1.326 +         *unit_type = (int)info_ptr->phys_unit_type;
   1.327 +         retval |= PNG_INFO_pHYs;
   1.328 +         if (*unit_type == 1)
   1.329 +         {
   1.330 +            if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
   1.331 +            if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);
   1.332 +         }
   1.333 +      }
   1.334 +   }
   1.335 +   return (retval);
   1.336 +}
   1.337 +#endif /* PNG_pHYs_SUPPORTED */
   1.338 +#endif  /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
   1.339 +
   1.340 +/* png_get_channels really belongs in here, too, but it's been around longer */
   1.341 +
   1.342 +#endif  /* PNG_EASY_ACCESS_SUPPORTED */
   1.343 +
   1.344 +png_byte PNGAPI
   1.345 +png_get_channels(png_structp png_ptr, png_infop info_ptr)
   1.346 +{
   1.347 +   if (png_ptr != NULL && info_ptr != NULL)
   1.348 +      return(info_ptr->channels);
   1.349 +   else
   1.350 +      return (0);
   1.351 +}
   1.352 +
   1.353 +png_bytep PNGAPI
   1.354 +png_get_signature(png_structp png_ptr, png_infop info_ptr)
   1.355 +{
   1.356 +   if (png_ptr != NULL && info_ptr != NULL)
   1.357 +      return(info_ptr->signature);
   1.358 +   else
   1.359 +      return (NULL);
   1.360 +}
   1.361 +
   1.362 +#if defined(PNG_bKGD_SUPPORTED)
   1.363 +png_uint_32 PNGAPI
   1.364 +png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
   1.365 +   png_color_16p *background)
   1.366 +{
   1.367 +   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
   1.368 +      && background != NULL)
   1.369 +   {
   1.370 +      png_debug1(1, "in %s retrieval function\n", "bKGD");
   1.371 +      *background = &(info_ptr->background);
   1.372 +      return (PNG_INFO_bKGD);
   1.373 +   }
   1.374 +   return (0);
   1.375 +}
   1.376 +#endif
   1.377 +
   1.378 +#if defined(PNG_cHRM_SUPPORTED)
   1.379 +#ifdef PNG_FLOATING_POINT_SUPPORTED
   1.380 +png_uint_32 PNGAPI
   1.381 +png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
   1.382 +   double *white_x, double *white_y, double *red_x, double *red_y,
   1.383 +   double *green_x, double *green_y, double *blue_x, double *blue_y)
   1.384 +{
   1.385 +   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
   1.386 +   {
   1.387 +      png_debug1(1, "in %s retrieval function\n", "cHRM");
   1.388 +      if (white_x != NULL)
   1.389 +         *white_x = (double)info_ptr->x_white;
   1.390 +      if (white_y != NULL)
   1.391 +         *white_y = (double)info_ptr->y_white;
   1.392 +      if (red_x != NULL)
   1.393 +         *red_x = (double)info_ptr->x_red;
   1.394 +      if (red_y != NULL)
   1.395 +         *red_y = (double)info_ptr->y_red;
   1.396 +      if (green_x != NULL)
   1.397 +         *green_x = (double)info_ptr->x_green;
   1.398 +      if (green_y != NULL)
   1.399 +         *green_y = (double)info_ptr->y_green;
   1.400 +      if (blue_x != NULL)
   1.401 +         *blue_x = (double)info_ptr->x_blue;
   1.402 +      if (blue_y != NULL)
   1.403 +         *blue_y = (double)info_ptr->y_blue;
   1.404 +      return (PNG_INFO_cHRM);
   1.405 +   }
   1.406 +   return (0);
   1.407 +}
   1.408 +#endif
   1.409 +#ifdef PNG_FIXED_POINT_SUPPORTED
   1.410 +png_uint_32 PNGAPI
   1.411 +png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
   1.412 +   png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
   1.413 +   png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
   1.414 +   png_fixed_point *blue_x, png_fixed_point *blue_y)
   1.415 +{
   1.416 +   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
   1.417 +   {
   1.418 +      png_debug1(1, "in %s retrieval function\n", "cHRM");
   1.419 +      if (white_x != NULL)
   1.420 +         *white_x = info_ptr->int_x_white;
   1.421 +      if (white_y != NULL)
   1.422 +         *white_y = info_ptr->int_y_white;
   1.423 +      if (red_x != NULL)
   1.424 +         *red_x = info_ptr->int_x_red;
   1.425 +      if (red_y != NULL)
   1.426 +         *red_y = info_ptr->int_y_red;
   1.427 +      if (green_x != NULL)
   1.428 +         *green_x = info_ptr->int_x_green;
   1.429 +      if (green_y != NULL)
   1.430 +         *green_y = info_ptr->int_y_green;
   1.431 +      if (blue_x != NULL)
   1.432 +         *blue_x = info_ptr->int_x_blue;
   1.433 +      if (blue_y != NULL)
   1.434 +         *blue_y = info_ptr->int_y_blue;
   1.435 +      return (PNG_INFO_cHRM);
   1.436 +   }
   1.437 +   return (0);
   1.438 +}
   1.439 +#endif
   1.440 +#endif
   1.441 +
   1.442 +#if defined(PNG_gAMA_SUPPORTED)
   1.443 +#ifdef PNG_FLOATING_POINT_SUPPORTED
   1.444 +png_uint_32 PNGAPI
   1.445 +png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
   1.446 +{
   1.447 +   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
   1.448 +      && file_gamma != NULL)
   1.449 +   {
   1.450 +      png_debug1(1, "in %s retrieval function\n", "gAMA");
   1.451 +      *file_gamma = (double)info_ptr->gamma;
   1.452 +      return (PNG_INFO_gAMA);
   1.453 +   }
   1.454 +   return (0);
   1.455 +}
   1.456 +#endif
   1.457 +#ifdef PNG_FIXED_POINT_SUPPORTED
   1.458 +png_uint_32 PNGAPI
   1.459 +png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
   1.460 +    png_fixed_point *int_file_gamma)
   1.461 +{
   1.462 +   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
   1.463 +      && int_file_gamma != NULL)
   1.464 +   {
   1.465 +      png_debug1(1, "in %s retrieval function\n", "gAMA");
   1.466 +      *int_file_gamma = info_ptr->int_gamma;
   1.467 +      return (PNG_INFO_gAMA);
   1.468 +   }
   1.469 +   return (0);
   1.470 +}
   1.471 +#endif
   1.472 +#endif
   1.473 +
   1.474 +#if defined(PNG_sRGB_SUPPORTED)
   1.475 +png_uint_32 PNGAPI
   1.476 +png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
   1.477 +{
   1.478 +   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
   1.479 +      && file_srgb_intent != NULL)
   1.480 +   {
   1.481 +      png_debug1(1, "in %s retrieval function\n", "sRGB");
   1.482 +      *file_srgb_intent = (int)info_ptr->srgb_intent;
   1.483 +      return (PNG_INFO_sRGB);
   1.484 +   }
   1.485 +   return (0);
   1.486 +}
   1.487 +#endif
   1.488 +
   1.489 +#if defined(PNG_iCCP_SUPPORTED)
   1.490 +png_uint_32 PNGAPI
   1.491 +png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
   1.492 +             png_charpp name, int *compression_type,
   1.493 +             png_charpp profile, png_uint_32 *proflen)
   1.494 +{
   1.495 +   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
   1.496 +      && name != NULL && profile != NULL && proflen != NULL)
   1.497 +   {
   1.498 +      png_debug1(1, "in %s retrieval function\n", "iCCP");
   1.499 +      *name = info_ptr->iccp_name;
   1.500 +      *profile = info_ptr->iccp_profile;
   1.501 +      /* compression_type is a dummy so the API won't have to change
   1.502 +         if we introduce multiple compression types later. */
   1.503 +      *proflen = (int)info_ptr->iccp_proflen;
   1.504 +      *compression_type = (int)info_ptr->iccp_compression;
   1.505 +      return (PNG_INFO_iCCP);
   1.506 +   }
   1.507 +   return (0);
   1.508 +}
   1.509 +#endif
   1.510 +
   1.511 +#if defined(PNG_sPLT_SUPPORTED)
   1.512 +png_uint_32 PNGAPI
   1.513 +png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
   1.514 +             png_sPLT_tpp spalettes)
   1.515 +{
   1.516 +   if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
   1.517 +   {
   1.518 +     *spalettes = info_ptr->splt_palettes;
   1.519 +     return ((png_uint_32)info_ptr->splt_palettes_num);
   1.520 +   }
   1.521 +   return (0);
   1.522 +}
   1.523 +#endif
   1.524 +
   1.525 +#if defined(PNG_hIST_SUPPORTED)
   1.526 +png_uint_32 PNGAPI
   1.527 +png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
   1.528 +{
   1.529 +   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
   1.530 +      && hist != NULL)
   1.531 +   {
   1.532 +      png_debug1(1, "in %s retrieval function\n", "hIST");
   1.533 +      *hist = info_ptr->hist;
   1.534 +      return (PNG_INFO_hIST);
   1.535 +   }
   1.536 +   return (0);
   1.537 +}
   1.538 +#endif
   1.539 +
   1.540 +png_uint_32 PNGAPI
   1.541 +png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
   1.542 +   png_uint_32 *width, png_uint_32 *height, int *bit_depth,
   1.543 +   int *color_type, int *interlace_type, int *compression_type,
   1.544 +   int *filter_type)
   1.545 +
   1.546 +{
   1.547 +   if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL &&
   1.548 +      bit_depth != NULL && color_type != NULL)
   1.549 +   {
   1.550 +      png_debug1(1, "in %s retrieval function\n", "IHDR");
   1.551 +      *width = info_ptr->width;
   1.552 +      *height = info_ptr->height;
   1.553 +      *bit_depth = info_ptr->bit_depth;
   1.554 +      if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16)
   1.555 +        png_error(png_ptr, "Invalid bit depth");
   1.556 +      *color_type = info_ptr->color_type;
   1.557 +      if (info_ptr->color_type > 6)
   1.558 +        png_error(png_ptr, "Invalid color type");
   1.559 +      if (compression_type != NULL)
   1.560 +         *compression_type = info_ptr->compression_type;
   1.561 +      if (filter_type != NULL)
   1.562 +         *filter_type = info_ptr->filter_type;
   1.563 +      if (interlace_type != NULL)
   1.564 +         *interlace_type = info_ptr->interlace_type;
   1.565 +
   1.566 +      /* check for potential overflow of rowbytes */
   1.567 +      if (*width == 0 || *width > PNG_UINT_31_MAX)
   1.568 +        png_error(png_ptr, "Invalid image width");
   1.569 +      if (*height == 0 || *height > PNG_UINT_31_MAX)
   1.570 +        png_error(png_ptr, "Invalid image height");
   1.571 +      if (info_ptr->width > (PNG_UINT_32_MAX
   1.572 +                 >> 3)      /* 8-byte RGBA pixels */
   1.573 +                 - 64       /* bigrowbuf hack */
   1.574 +                 - 1        /* filter byte */
   1.575 +                 - 7*8      /* rounding of width to multiple of 8 pixels */
   1.576 +                 - 8)       /* extra max_pixel_depth pad */
   1.577 +      {
   1.578 +         png_warning(png_ptr,
   1.579 +            "Width too large for libpng to process image data.");
   1.580 +      }
   1.581 +      return (1);
   1.582 +   }
   1.583 +   return (0);
   1.584 +}
   1.585 +
   1.586 +#if defined(PNG_oFFs_SUPPORTED)
   1.587 +png_uint_32 PNGAPI
   1.588 +png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
   1.589 +   png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
   1.590 +{
   1.591 +   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
   1.592 +      && offset_x != NULL && offset_y != NULL && unit_type != NULL)
   1.593 +   {
   1.594 +      png_debug1(1, "in %s retrieval function\n", "oFFs");
   1.595 +      *offset_x = info_ptr->x_offset;
   1.596 +      *offset_y = info_ptr->y_offset;
   1.597 +      *unit_type = (int)info_ptr->offset_unit_type;
   1.598 +      return (PNG_INFO_oFFs);
   1.599 +   }
   1.600 +   return (0);
   1.601 +}
   1.602 +#endif
   1.603 +
   1.604 +#if defined(PNG_pCAL_SUPPORTED)
   1.605 +png_uint_32 PNGAPI
   1.606 +png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
   1.607 +   png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
   1.608 +   png_charp *units, png_charpp *params)
   1.609 +{
   1.610 +   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
   1.611 +      && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
   1.612 +      nparams != NULL && units != NULL && params != NULL)
   1.613 +   {
   1.614 +      png_debug1(1, "in %s retrieval function\n", "pCAL");
   1.615 +      *purpose = info_ptr->pcal_purpose;
   1.616 +      *X0 = info_ptr->pcal_X0;
   1.617 +      *X1 = info_ptr->pcal_X1;
   1.618 +      *type = (int)info_ptr->pcal_type;
   1.619 +      *nparams = (int)info_ptr->pcal_nparams;
   1.620 +      *units = info_ptr->pcal_units;
   1.621 +      *params = info_ptr->pcal_params;
   1.622 +      return (PNG_INFO_pCAL);
   1.623 +   }
   1.624 +   return (0);
   1.625 +}
   1.626 +#endif
   1.627 +
   1.628 +#if defined(PNG_sCAL_SUPPORTED)
   1.629 +#ifdef PNG_FLOATING_POINT_SUPPORTED
   1.630 +png_uint_32 PNGAPI
   1.631 +png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
   1.632 +             int *unit, double *width, double *height)
   1.633 +{
   1.634 +    if (png_ptr != NULL && info_ptr != NULL &&
   1.635 +       (info_ptr->valid & PNG_INFO_sCAL))
   1.636 +    {
   1.637 +        *unit = info_ptr->scal_unit;
   1.638 +        *width = info_ptr->scal_pixel_width;
   1.639 +        *height = info_ptr->scal_pixel_height;
   1.640 +        return (PNG_INFO_sCAL);
   1.641 +    }
   1.642 +    return(0);
   1.643 +}
   1.644 +#else
   1.645 +#ifdef PNG_FIXED_POINT_SUPPORTED
   1.646 +png_uint_32 PNGAPI
   1.647 +png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
   1.648 +             int *unit, png_charpp width, png_charpp height)
   1.649 +{
   1.650 +    if (png_ptr != NULL && info_ptr != NULL &&
   1.651 +       (info_ptr->valid & PNG_INFO_sCAL))
   1.652 +    {
   1.653 +        *unit = info_ptr->scal_unit;
   1.654 +        *width = info_ptr->scal_s_width;
   1.655 +        *height = info_ptr->scal_s_height;
   1.656 +        return (PNG_INFO_sCAL);
   1.657 +    }
   1.658 +    return(0);
   1.659 +}
   1.660 +#endif
   1.661 +#endif
   1.662 +#endif
   1.663 +
   1.664 +#if defined(PNG_pHYs_SUPPORTED)
   1.665 +png_uint_32 PNGAPI
   1.666 +png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
   1.667 +   png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
   1.668 +{
   1.669 +   png_uint_32 retval = 0;
   1.670 +
   1.671 +   if (png_ptr != NULL && info_ptr != NULL &&
   1.672 +      (info_ptr->valid & PNG_INFO_pHYs))
   1.673 +   {
   1.674 +      png_debug1(1, "in %s retrieval function\n", "pHYs");
   1.675 +      if (res_x != NULL)
   1.676 +      {
   1.677 +         *res_x = info_ptr->x_pixels_per_unit;
   1.678 +         retval |= PNG_INFO_pHYs;
   1.679 +      }
   1.680 +      if (res_y != NULL)
   1.681 +      {
   1.682 +         *res_y = info_ptr->y_pixels_per_unit;
   1.683 +         retval |= PNG_INFO_pHYs;
   1.684 +      }
   1.685 +      if (unit_type != NULL)
   1.686 +      {
   1.687 +         *unit_type = (int)info_ptr->phys_unit_type;
   1.688 +         retval |= PNG_INFO_pHYs;
   1.689 +      }
   1.690 +   }
   1.691 +   return (retval);
   1.692 +}
   1.693 +#endif
   1.694 +
   1.695 +png_uint_32 PNGAPI
   1.696 +png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
   1.697 +   int *num_palette)
   1.698 +{
   1.699 +   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
   1.700 +       && palette != NULL)
   1.701 +   {
   1.702 +      png_debug1(1, "in %s retrieval function\n", "PLTE");
   1.703 +      *palette = info_ptr->palette;
   1.704 +      *num_palette = info_ptr->num_palette;
   1.705 +      png_debug1(3, "num_palette = %d\n", *num_palette);
   1.706 +      return (PNG_INFO_PLTE);
   1.707 +   }
   1.708 +   return (0);
   1.709 +}
   1.710 +
   1.711 +#if defined(PNG_sBIT_SUPPORTED)
   1.712 +png_uint_32 PNGAPI
   1.713 +png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
   1.714 +{
   1.715 +   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
   1.716 +      && sig_bit != NULL)
   1.717 +   {
   1.718 +      png_debug1(1, "in %s retrieval function\n", "sBIT");
   1.719 +      *sig_bit = &(info_ptr->sig_bit);
   1.720 +      return (PNG_INFO_sBIT);
   1.721 +   }
   1.722 +   return (0);
   1.723 +}
   1.724 +#endif
   1.725 +
   1.726 +#if defined(PNG_TEXT_SUPPORTED)
   1.727 +png_uint_32 PNGAPI
   1.728 +png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
   1.729 +   int *num_text)
   1.730 +{
   1.731 +   if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
   1.732 +   {
   1.733 +      png_debug1(1, "in %s retrieval function\n",
   1.734 +         (png_ptr->chunk_name[0] == '\0' ? "text"
   1.735 +             : (png_const_charp)png_ptr->chunk_name));
   1.736 +      if (text_ptr != NULL)
   1.737 +         *text_ptr = info_ptr->text;
   1.738 +      if (num_text != NULL)
   1.739 +         *num_text = info_ptr->num_text;
   1.740 +      return ((png_uint_32)info_ptr->num_text);
   1.741 +   }
   1.742 +   if (num_text != NULL)
   1.743 +     *num_text = 0;
   1.744 +   return(0);
   1.745 +}
   1.746 +#endif
   1.747 +
   1.748 +#if defined(PNG_tIME_SUPPORTED)
   1.749 +png_uint_32 PNGAPI
   1.750 +png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
   1.751 +{
   1.752 +   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
   1.753 +       && mod_time != NULL)
   1.754 +   {
   1.755 +      png_debug1(1, "in %s retrieval function\n", "tIME");
   1.756 +      *mod_time = &(info_ptr->mod_time);
   1.757 +      return (PNG_INFO_tIME);
   1.758 +   }
   1.759 +   return (0);
   1.760 +}
   1.761 +#endif
   1.762 +
   1.763 +#if defined(PNG_tRNS_SUPPORTED)
   1.764 +png_uint_32 PNGAPI
   1.765 +png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
   1.766 +   png_bytep *trans, int *num_trans, png_color_16p *trans_values)
   1.767 +{
   1.768 +   png_uint_32 retval = 0;
   1.769 +   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
   1.770 +   {
   1.771 +      png_debug1(1, "in %s retrieval function\n", "tRNS");
   1.772 +      if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
   1.773 +      {
   1.774 +          if (trans != NULL)
   1.775 +          {
   1.776 +             *trans = info_ptr->trans;
   1.777 +             retval |= PNG_INFO_tRNS;
   1.778 +          }
   1.779 +          if (trans_values != NULL)
   1.780 +             *trans_values = &(info_ptr->trans_values);
   1.781 +      }
   1.782 +      else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
   1.783 +      {
   1.784 +          if (trans_values != NULL)
   1.785 +          {
   1.786 +             *trans_values = &(info_ptr->trans_values);
   1.787 +             retval |= PNG_INFO_tRNS;
   1.788 +          }
   1.789 +          if (trans != NULL)
   1.790 +             *trans = NULL;
   1.791 +      }
   1.792 +      if (num_trans != NULL)
   1.793 +      {
   1.794 +         *num_trans = info_ptr->num_trans;
   1.795 +         retval |= PNG_INFO_tRNS;
   1.796 +      }
   1.797 +   }
   1.798 +   return (retval);
   1.799 +}
   1.800 +#endif
   1.801 +
   1.802 +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
   1.803 +png_uint_32 PNGAPI
   1.804 +png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
   1.805 +             png_unknown_chunkpp unknowns)
   1.806 +{
   1.807 +   if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
   1.808 +   {
   1.809 +     *unknowns = info_ptr->unknown_chunks;
   1.810 +     return ((png_uint_32)info_ptr->unknown_chunks_num);
   1.811 +   }
   1.812 +   return (0);
   1.813 +}
   1.814 +#endif
   1.815 +
   1.816 +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
   1.817 +png_byte PNGAPI
   1.818 +png_get_rgb_to_gray_status (png_structp png_ptr)
   1.819 +{
   1.820 +   return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0);
   1.821 +}
   1.822 +#endif
   1.823 +
   1.824 +#if defined(PNG_USER_CHUNKS_SUPPORTED)
   1.825 +png_voidp PNGAPI
   1.826 +png_get_user_chunk_ptr(png_structp png_ptr)
   1.827 +{
   1.828 +   return (png_ptr? png_ptr->user_chunk_ptr : NULL);
   1.829 +}
   1.830 +#endif
   1.831 +
   1.832 +#ifdef PNG_WRITE_SUPPORTED
   1.833 +png_uint_32 PNGAPI
   1.834 +png_get_compression_buffer_size(png_structp png_ptr)
   1.835 +{
   1.836 +   return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L);
   1.837 +}
   1.838 +#endif
   1.839 +
   1.840 +#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
   1.841 +#ifndef PNG_1_0_X
   1.842 +/* this function was added to libpng 1.2.0 and should exist by default */
   1.843 +png_uint_32 PNGAPI
   1.844 +png_get_asm_flags (png_structp png_ptr)
   1.845 +{
   1.846 +    /* obsolete, to be removed from libpng-1.4.0 */
   1.847 +    return (png_ptr? 0L: 0L);
   1.848 +}
   1.849 +
   1.850 +/* this function was added to libpng 1.2.0 and should exist by default */
   1.851 +png_uint_32 PNGAPI
   1.852 +png_get_asm_flagmask (int flag_select)
   1.853 +{
   1.854 +    /* obsolete, to be removed from libpng-1.4.0 */
   1.855 +    flag_select=flag_select;
   1.856 +    return 0L;
   1.857 +}
   1.858 +
   1.859 +    /* GRR:  could add this:   && defined(PNG_MMX_CODE_SUPPORTED) */
   1.860 +/* this function was added to libpng 1.2.0 */
   1.861 +png_uint_32 PNGAPI
   1.862 +png_get_mmx_flagmask (int flag_select, int *compilerID)
   1.863 +{
   1.864 +    /* obsolete, to be removed from libpng-1.4.0 */
   1.865 +    flag_select=flag_select;
   1.866 +    *compilerID = -1;   /* unknown (i.e., no asm/MMX code compiled) */
   1.867 +    return 0L;
   1.868 +}
   1.869 +
   1.870 +/* this function was added to libpng 1.2.0 */
   1.871 +png_byte PNGAPI
   1.872 +png_get_mmx_bitdepth_threshold (png_structp png_ptr)
   1.873 +{
   1.874 +    /* obsolete, to be removed from libpng-1.4.0 */
   1.875 +    return (png_ptr? 0: 0);
   1.876 +}
   1.877 +
   1.878 +/* this function was added to libpng 1.2.0 */
   1.879 +png_uint_32 PNGAPI
   1.880 +png_get_mmx_rowbytes_threshold (png_structp png_ptr)
   1.881 +{
   1.882 +    /* obsolete, to be removed from libpng-1.4.0 */
   1.883 +    return (png_ptr? 0L: 0L);
   1.884 +}
   1.885 +#endif /* ?PNG_1_0_X */
   1.886 +#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
   1.887 +
   1.888 +#ifdef PNG_SET_USER_LIMITS_SUPPORTED
   1.889 +/* these functions were added to libpng 1.2.6 */
   1.890 +png_uint_32 PNGAPI
   1.891 +png_get_user_width_max (png_structp png_ptr)
   1.892 +{
   1.893 +    return (png_ptr? png_ptr->user_width_max : 0);
   1.894 +}
   1.895 +png_uint_32 PNGAPI
   1.896 +png_get_user_height_max (png_structp png_ptr)
   1.897 +{
   1.898 +    return (png_ptr? png_ptr->user_height_max : 0);
   1.899 +}
   1.900 +#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
   1.901 + 
   1.902 +
   1.903 +#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */