LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File freegish-png14.patch of Package freegish (Project games)

diff -Naur FrozenCow-gish-b0e9f7d.orig/video/texture.c FrozenCow-gish-b0e9f7d/video/texture.c
--- FrozenCow-gish-b0e9f7d.orig/video/texture.c	2010-06-19 19:34:08.000000000 +0200
+++ FrozenCow-gish-b0e9f7d/video/texture.c	2013-01-23 21:08:07.997671413 +0100
@@ -89,27 +89,51 @@
 						png_read_info(png_ptr, info_ptr);
 
 						/* expand paletted colors into true rgb */
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+						if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE)
+#else
 						if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
+#endif
 							png_set_expand(png_ptr);
 
 						/* expand grayscale images to the full 8 bits */
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+						if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_GRAY && png_get_bit_depth(png_ptr, info_ptr) < 8)
+#else
 						if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY && info_ptr->bit_depth < 8)
+#endif
 							png_set_expand(png_ptr);
 
 						/* expand images with transparency to full alpha channels */
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+						if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
+#else
 						if (info_ptr->valid & PNG_INFO_tRNS)
+#endif
 							png_set_expand(png_ptr);
 
 						/* tell libpng to strip 16 bit depth files down to 8 bits */
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+						if (png_get_bit_depth(png_ptr, info_ptr) == 16)
+#else
 						if (info_ptr->bit_depth == 16)
+#endif
 							png_set_strip_16(png_ptr);
 
 						/* fill upto 4 byte RGBA - we always want an alpha channel*/
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+						if (png_get_bit_depth(png_ptr, info_ptr) == 8 && png_get_color_type(png_ptr, info_ptr) != PNG_COLOR_TYPE_RGB_ALPHA)
+#else
 						if (info_ptr->bit_depth == 8 && info_ptr->color_type != PNG_COLOR_TYPE_RGB_ALPHA)
+#endif
 							png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
 
 						// XXX: is this required? we're not handling interlaced PNGs ...
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+						if (png_get_interlace_type(png_ptr, info_ptr))
+#else
 						if (info_ptr->interlace_type)
+#endif
 							number_passes = png_set_interlace_handling(png_ptr);
 						else
 							number_passes = 1;
@@ -125,8 +149,13 @@
 						else
 						{
 							int w, h, y;
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+							w = png_get_image_width(png_ptr, info_ptr);
+							h = png_get_image_height(png_ptr, info_ptr);
+#else
 							w = info_ptr->width;
 							h = info_ptr->height;
+#endif
 							*width = w;
 							*height = h;
 							*rgba = (unsigned int *) malloc(w*h*4);