packages: doomsday/doomsday-libpng15.patch (NEW)=?UTF-8?Q?=20?=- new

adamg adamg at pld-linux.org
Sun Feb 12 19:32:28 CET 2012


Author: adamg                        Date: Sun Feb 12 18:32:28 2012 GMT
Module: packages                      Tag: HEAD
---- Log message:
- new

---- Files affected:
packages/doomsday:
   doomsday-libpng15.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: packages/doomsday/doomsday-libpng15.patch
diff -u /dev/null packages/doomsday/doomsday-libpng15.patch:1.1
--- /dev/null	Sun Feb 12 19:32:28 2012
+++ packages/doomsday/doomsday-libpng15.patch	Sun Feb 12 19:32:23 2012
@@ -0,0 +1,95 @@
+--- deng-1.9.0-beta6.9/doomsday/engine/portable/src/gl_png.c~	2010-04-07 22:52:50.000000000 +0200
++++ deng-1.9.0-beta6.9/doomsday/engine/portable/src/gl_png.c	2012-02-12 19:29:04.632968012 +0100
+@@ -89,8 +89,9 @@
+     png_structp png_ptr = 0;
+     png_infop   png_info = 0, end_info = 0;
+     png_bytep  *rows, pixel;
++    png_colorp  png_palette;
+     unsigned char *retbuf = 0;  // The return buffer.
+-    int         i, k, off;
++    int         i, k, off, num_palette;
+ 
+     if((file = F_Open(fileName, "rb")) == NULL)
+         return NULL;
+@@ -119,18 +120,18 @@
+ 
+                     // Check if it can be used.
+                     canLoad = true;
+-                    if(png_info->bit_depth != 8)
++                    if(png_get_bit_depth(png_ptr, png_info) != 8)
+                     {
+                         Con_Message("PNG_Load: \"%s\": Bit depth must be 8.\n", fileName);
+                         canLoad = false;
+                     }
+-                    else if(!png_info->width || !png_info->height)
++                    else if(!png_get_image_width(png_ptr, png_info) || !png_get_image_height(png_ptr, png_info))
+                     {
+                         Con_Message("PNG_Load: \"%s\": Bad file? Size is zero.\n", fileName);
+                         canLoad = false;
+                     }
+-                    else if(png_info->channels <= 2 && 
+-                            png_info->color_type == PNG_COLOR_TYPE_PALETTE &&
++                    else if(png_get_channels(png_ptr, png_info) <= 2 && 
++                            png_get_color_type(png_ptr, png_info) == PNG_COLOR_TYPE_PALETTE &&
+                             !png_get_valid(png_ptr, png_info, PNG_INFO_PLTE))
+                     {
+                         Con_Message("PNG_Load: \"%s\": Palette is invalid.\n", fileName);
+@@ -140,9 +141,9 @@
+                     if(canLoad)
+                     {
+                         // Information about the image.
+-                        *width = png_info->width;
+-                        *height = png_info->height;
+-                        *pixelSize = png_info->channels;
++                        *width = png_get_image_width(png_ptr, png_info);
++                        *height = png_get_image_height(png_ptr, png_info);
++                        *pixelSize = png_get_channels(png_ptr, png_info);
+ 
+                         // Paletted images have three color components
+                         // per pixel.
+@@ -154,33 +155,34 @@
+                         // OK, let's copy it into Doomsday's buffer.
+                         // \fixme Why not load directly into it?
+                         retbuf =
+-                            M_Malloc(4 * png_info->width * png_info->height);
++                            M_Malloc(4 * png_get_image_width(png_ptr, png_info) * png_get_image_height(png_ptr, png_info));
+                         rows = png_get_rows(png_ptr, png_info);
++			png_get_PLTE(png_ptr, png_info, &png_palette, &num_palette);
+                         for(i = 0; i < *height; ++i)
+                         {
+-                            if(png_info->channels >= 3)
++                            if(png_get_channels(png_ptr, png_info) >= 3)
+                             {
+-                                memcpy(retbuf + i * (*pixelSize) * png_info->width,
+-                                       rows[i], (*pixelSize) * png_info->width);
++                                memcpy(retbuf + i * (*pixelSize) * png_get_image_width(png_ptr, png_info),
++                                       rows[i], (*pixelSize) * png_get_image_width(png_ptr, png_info));
+                             }
+                             else // Paletted image.
+                             {
+                                 for(k = 0; k < *width; ++k)
+                                 {
+-                                    pixel = retbuf + ((*pixelSize) * (i * png_info->width + k));
+-                                    off = k * png_info->channels;
+-                                    if(png_info->color_type == PNG_COLOR_TYPE_PALETTE)
++                                    pixel = retbuf + ((*pixelSize) * (i * png_get_image_width(png_ptr, png_info) + k));
++                                    off = k * png_get_channels(png_ptr, png_info);
++                                    if(png_get_color_type(png_ptr, png_info) == PNG_COLOR_TYPE_PALETTE)
+                                     {
+-                                        pixel[0] = png_info->palette[rows[i][off]].red;
+-                                        pixel[1] = png_info->palette[rows[i][off]].green;
+-                                        pixel[2] = png_info->palette[rows[i][off]].blue;
++                                        pixel[0] = png_palette[rows[i][off]].red;
++                                        pixel[1] = png_palette[rows[i][off]].green;
++                                        pixel[2] = png_palette[rows[i][off]].blue;
+                                     }
+                                     else
+                                     {
+                                         // Grayscale.
+                                         pixel[0] = pixel[1] = pixel[2] = rows[i][off];
+                                     }
+-                                    if(png_info->channels == 2) // Alpha data.
++                                    if(png_get_channels(png_ptr, png_info) == 2) // Alpha data.
+                                     {
+                                         pixel[3] = rows[i][off + 1];
+                                     }
================================================================


More information about the pld-cvs-commit mailing list