cvs: gd /libgd/src gd_png.c /libgd/tests/png CMakeLists.txt bug00088.c bug00088_1.png bug00088_1_exp.png bug00088_2.png bug00088_2_exp.png
[email protected] ("Pierre-Alain Joye") Sun, 18 Nov 2007 14:46:45 -0000
| Newsgroups | php.gd.cvs |
|---|---|
| Message-ID | <cvspajoye1195397205@cvsserver> |
pajoye Sun Nov 18 14:46:45 2007 UTC
Added files:
/gd/libgd/tests/png bug00088.c bug00088_1.png bug00088_1_exp.png
bug00088_2.png bug00088_2_exp.png
Modified files:
/gd/libgd/src gd_png.c
/gd/libgd/tests/png CMakeLists.txt
Log:
- #88, MFB: Bug loading png images in grayscale + alpha
- add test
http://cvs.php.net/viewvc.cgi/gd/libgd/src/gd_png.c?r1=1.25&r2=1.26&diff_format=u
Index: gd/libgd/src/gd_png.c
diff -u gd/libgd/src/gd_png.c:1.25 gd/libgd/src/gd_png.c:1.26
--- gd/libgd/src/gd_png.c:1.25 Sat Nov 17 21:44:37 2007
+++ gd/libgd/src/gd_png.c Sun Nov 18 14:46:45 2007
@@ -1,4 +1,4 @@
-/* $Id: gd_png.c,v 1.25 2007/11/17 21:44:37 pajoye Exp $ */
+/* $Id: gd_png.c,v 1.26 2007/11/18 14:46:45 pajoye Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -195,7 +195,8 @@
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 +259,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 +298,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 +399,8 @@
}
}
break;
+
+ case PNG_COLOR_TYPE_GRAY_ALPHA:
case PNG_COLOR_TYPE_RGB_ALPHA:
for (h = 0; h < height; h++) {
int boffset = 0;
http://cvs.php.net/viewvc.cgi/gd/libgd/tests/png/CMakeLists.txt?r1=1.1&r2=1.2&diff_format=u
Index: gd/libgd/tests/png/CMakeLists.txt
diff -u gd/libgd/tests/png/CMakeLists.txt:1.1 gd/libgd/tests/png/CMakeLists.txt:1.2
--- gd/libgd/tests/png/CMakeLists.txt:1.1 Tue Oct 2 09:01:53 2007
+++ gd/libgd/tests/png/CMakeLists.txt Sun Nov 18 14:46:45 2007
@@ -3,6 +3,7 @@
bug00011
bug00033
bug00086
+ bug00088
)
FOREACH(test_name ${TESTS_FILES})
http://cvs.php.net/viewvc.cgi/gd/libgd/tests/png/bug00088.c?view=markup&rev=1.1
Index: gd/libgd/tests/png/bug00088.c
+++ gd/libgd/tests/png/bug00088.c
/* $Id: bug00088.c,v 1.1 2007/11/18 14:46:45 pajoye Exp $ */
#include "gd.h"
#include <stdio.h>
#include <stdlib.h>
#include "gdtest.h"
int main()
{
int error;
gdImagePtr im;
FILE *fp;
char path[1024];
const char * files[2] = {"bug00088_1.png", "bug00088_2.png"};
const char * files_exp[2] = {"bug00088_1_exp.png", "bug00088_2_exp.png"};
int i, cnt = 2;
error = 0;
for (i = 0; i < cnt; i++) {
sprintf(path, "%s/png/%s", GDTEST_TOP_DIR, files[i]);
fp = fopen(path, "rb");
if (!fp) {
printf("failed, cannot open file <%s>\n", path);
return 1;
}
im = gdImageCreateFromPng(fp);
fclose(fp);
if (!im) {
error |= 1;
continue;
}
sprintf(path, "%s/png/%s", GDTEST_TOP_DIR, files_exp[i]);
if (!gdAssertImageEqualsToFile(path, im)) {
error |= 1;
}
gdImageDestroy(im);
}
return error;
}