[DEVENUM]
[reactos.git] / reactos / dll / 3rdparty / libpng / pngget.c
index b5e5798..c9a663f 100644 (file)
@@ -1,7 +1,7 @@
 
 /* pngget.c - retrieval of values from info struct
  *
- * Last changed in libpng 1.5.1 [February 3, 2011]
+ * Last changed in libpng 1.5.14 [January 24, 2013]
  * Copyright (c) 1998-2011 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -175,6 +175,9 @@ png_get_pixel_aspect_ratio(png_const_structp png_ptr, png_const_infop info_ptr)
          return ((float)((float)info_ptr->y_pixels_per_unit
              /(float)info_ptr->x_pixels_per_unit));
    }
+#else
+   PNG_UNUSED(png_ptr)
+   PNG_UNUSED(info_ptr)
 #endif
 
    return ((float)0.0);
@@ -203,6 +206,9 @@ png_get_pixel_aspect_ratio_fixed(png_const_structp png_ptr,
           (png_int_32)info_ptr->x_pixels_per_unit))
          return res;
    }
+#else
+   PNG_UNUSED(png_ptr)
+   PNG_UNUSED(info_ptr)
 #endif
 
    return 0;
@@ -459,6 +465,65 @@ png_get_bKGD(png_const_structp png_ptr, png_infop info_ptr,
 #endif
 
 #ifdef PNG_cHRM_SUPPORTED
+/* The XYZ APIs were added in 1.5.5 to take advantage of the code added at the
+ * same time to correct the rgb grayscale coefficient defaults obtained from the
+ * cHRM chunk in 1.5.4
+ */
+png_uint_32 PNGFAPI
+png_get_cHRM_XYZ_fixed(png_structp png_ptr, png_const_infop info_ptr,
+    png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
+    png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
+    png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
+    png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
+    png_fixed_point *int_blue_Z)
+{
+   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
+   {
+      png_xy xy;
+      png_XYZ XYZ;
+
+      png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
+
+      xy.whitex = info_ptr->x_white;
+      xy.whitey = info_ptr->y_white;
+      xy.redx = info_ptr->x_red;
+      xy.redy = info_ptr->y_red;
+      xy.greenx = info_ptr->x_green;
+      xy.greeny = info_ptr->y_green;
+      xy.bluex = info_ptr->x_blue;
+      xy.bluey = info_ptr->y_blue;
+
+      /* The *_checked function handles error reporting, so just return 0 if
+       * there is a failure here.
+       */
+      if (png_XYZ_from_xy_checked(png_ptr, &XYZ, xy))
+      {
+         if (int_red_X != NULL)
+            *int_red_X = XYZ.redX;
+         if (int_red_Y != NULL)
+            *int_red_Y = XYZ.redY;
+         if (int_red_Z != NULL)
+            *int_red_Z = XYZ.redZ;
+         if (int_green_X != NULL)
+            *int_green_X = XYZ.greenX;
+         if (int_green_Y != NULL)
+            *int_green_Y = XYZ.greenY;
+         if (int_green_Z != NULL)
+            *int_green_Z = XYZ.greenZ;
+         if (int_blue_X != NULL)
+            *int_blue_X = XYZ.blueX;
+         if (int_blue_Y != NULL)
+            *int_blue_Y = XYZ.blueY;
+         if (int_blue_Z != NULL)
+            *int_blue_Z = XYZ.blueZ;
+
+         return (PNG_INFO_cHRM);
+      }
+   }
+
+   return (0);
+}
+
 #  ifdef PNG_FLOATING_POINT_SUPPORTED
 png_uint_32 PNGAPI
 png_get_cHRM(png_const_structp png_ptr, png_const_infop info_ptr,
@@ -490,6 +555,42 @@ png_get_cHRM(png_const_structp png_ptr, png_const_infop info_ptr,
 
    return (0);
 }
+
+png_uint_32 PNGAPI
+png_get_cHRM_XYZ(png_structp png_ptr, png_const_infop info_ptr,
+   double *red_X, double *red_Y, double *red_Z, double *green_X,
+   double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
+   double *blue_Z)
+{
+   png_XYZ XYZ;
+
+   if (png_get_cHRM_XYZ_fixed(png_ptr, info_ptr,
+      &XYZ.redX, &XYZ.redY, &XYZ.redZ, &XYZ.greenX, &XYZ.greenY, &XYZ.greenZ,
+      &XYZ.blueX, &XYZ.blueY, &XYZ.blueZ) & PNG_INFO_cHRM)
+   {
+      if (red_X != NULL)
+         *red_X = png_float(png_ptr, XYZ.redX, "cHRM red X");
+      if (red_Y != NULL)
+         *red_Y = png_float(png_ptr, XYZ.redY, "cHRM red Y");
+      if (red_Z != NULL)
+         *red_Z = png_float(png_ptr, XYZ.redZ, "cHRM red Z");
+      if (green_X != NULL)
+         *green_X = png_float(png_ptr, XYZ.greenX, "cHRM green X");
+      if (green_Y != NULL)
+         *green_Y = png_float(png_ptr, XYZ.greenY, "cHRM green Y");
+      if (green_Z != NULL)
+         *green_Z = png_float(png_ptr, XYZ.greenZ, "cHRM green Z");
+      if (blue_X != NULL)
+         *blue_X = png_float(png_ptr, XYZ.blueX, "cHRM blue X");
+      if (blue_Y != NULL)
+         *blue_Y = png_float(png_ptr, XYZ.blueY, "cHRM blue Y");
+      if (blue_Z != NULL)
+         *blue_Z = png_float(png_ptr, XYZ.blueZ, "cHRM blue Z");
+      return (PNG_INFO_cHRM);
+   }
+
+   return (0);
+}
 #  endif
 
 #  ifdef PNG_FIXED_POINT_SUPPORTED
@@ -587,15 +688,16 @@ png_get_iCCP(png_const_structp png_ptr, png_const_infop info_ptr,
    png_debug1(1, "in %s retrieval function", "iCCP");
 
    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
-       && name != NULL && profile != NULL && proflen != NULL)
+       && name != NULL && compression_type != NULL && profile != NULL &&
+                proflen != NULL)
    {
       *name = info_ptr->iccp_name;
       *profile = info_ptr->iccp_profile;
       /* Compression_type is a dummy so the API won't have to change
        * if we introduce multiple compression types later.
        */
-      *proflen = (int)info_ptr->iccp_proflen;
-      *compression_type = (int)info_ptr->iccp_compression;
+      *proflen = info_ptr->iccp_proflen;
+      *compression_type = info_ptr->iccp_compression;
       return (PNG_INFO_iCCP);
    }
 
@@ -855,9 +957,8 @@ png_get_text(png_const_structp png_ptr, png_const_infop info_ptr,
 {
    if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
    {
-      png_debug1(1, "in %s retrieval function",
-          (png_ptr->chunk_name[0] == '\0' ? "text" :
-          (png_const_charp)png_ptr->chunk_name));
+      png_debug1(1, "in 0x%lx retrieval function",
+         (unsigned long)png_ptr->chunk_name);
 
       if (text_ptr != NULL)
          *text_ptr = info_ptr->text;
@@ -971,10 +1072,9 @@ png_get_user_chunk_ptr(png_const_structp png_ptr)
 png_size_t PNGAPI
 png_get_compression_buffer_size(png_const_structp png_ptr)
 {
-   return (png_ptr ? png_ptr->zbuf_size : 0L);
+   return (png_ptr ? png_ptr->zbuf_size : 0);
 }
 
-
 #ifdef PNG_SET_USER_LIMITS_SUPPORTED
 /* These functions were added to libpng 1.2.6 and were enabled
  * by default in libpng-1.4.0 */
@@ -1016,16 +1116,14 @@ png_get_io_state (png_structp png_ptr)
 png_uint_32 PNGAPI
 png_get_io_chunk_type (png_const_structp png_ptr)
 {
-   return ((png_ptr->chunk_name[0] << 24) +
-           (png_ptr->chunk_name[1] << 16) +
-           (png_ptr->chunk_name[2] <<  8) +
-           (png_ptr->chunk_name[3]));
+   return png_ptr->chunk_name;
 }
 
 png_const_bytep PNGAPI
 png_get_io_chunk_name (png_structp png_ptr)
 {
-   return png_ptr->chunk_name;
+   PNG_CSTRING_FROM_CHUNK(png_ptr->io_chunk_string, png_ptr->chunk_name);
+   return png_ptr->io_chunk_string;
 }
 #endif /* ?PNG_IO_STATE_SUPPORTED */