cvs: gd(GD_2_0) /libgd/src gd_png.c
[email protected] ("Pierre-Alain Joye") Sat, 17 Nov 2007 21:55:24 -0000
| Newsgroups | php.gd.cvs |
|---|---|
| Message-ID | <cvspajoye1195336524@cvsserver> |
pajoye Sat Nov 17 21:55:24 2007 UTC
Modified files: (Branch: GD_2_0)
/gd/libgd/src gd_png.c
Log:
- #88, Fix loading of grayscale png image with alpha
http://cvs.php.net/viewvc.cgi/gd/libgd/src/gd_png.c?r1=1.21.2.3&r2=1.21.2.4&diff_format=u
Index: gd/libgd/src/gd_png.c
diff -u gd/libgd/src/gd_png.c:1.21.2.3 gd/libgd/src/gd_png.c:1.21.2.4
--- gd/libgd/src/gd_png.c:1.21.2.3 Tue Aug 7 19:50:39 2007
+++ gd/libgd/src/gd_png.c Sat Nov 17 21:55:24 2007
@@ -1,4 +1,4 @@
-/* $Id: gd_png.c,v 1.21.2.3 2007/08/07 19:50:39 mattias Exp $ */
+/* $Id: gd_png.c,v 1.21.2.4 2007/11/17 21:55:24 pajoye Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -195,7 +195,9 @@
png_read_info (png_ptr, info_ptr); /* read all PNG info up to image data */
png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, NULL, NULL);
- if ((color_type == PNG_COLOR_TYPE_RGB) || (color_type == PNG_COLOR_TYPE_RGB_ALPHA)) {
+
+ if ((color_type == PNG_COLOR_TYPE_RGB) || (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
+ || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
im = gdImageCreateTrueColor ((int) width, (int) height);
} else {
im = gdImageCreate ((int) width, (int) height);
@@ -258,7 +260,6 @@
break;
case PNG_COLOR_TYPE_GRAY:
- case PNG_COLOR_TYPE_GRAY_ALPHA:
/* create a fake palette and check for single-shade transparency */
if ((palette = (png_colorp) gdMalloc (256 * sizeof (png_color))) == NULL) {
fprintf (stderr, "gd-png error: cannot allocate gray palette\n");
@@ -298,6 +299,9 @@
}
break;
+ case PNG_COLOR_TYPE_GRAY_ALPHA:
+ png_set_gray_to_rgb(png_ptr);
+
case PNG_COLOR_TYPE_RGB:
case PNG_COLOR_TYPE_RGB_ALPHA:
/* gd 2.0: we now support truecolor. See the comment above
@@ -396,6 +400,8 @@
}
}
break;
+
+ case PNG_COLOR_TYPE_GRAY_ALPHA:
case PNG_COLOR_TYPE_RGB_ALPHA:
for (h = 0; h < height; h++) {
int boffset = 0;