pajoye          Wed Jan 14 10:16:42 2009 UTC

  Modified files:              
    /php-src/ext/gd/libgd       gd_png.c 
  Log:
  - [DOC] support for PNG gray levels+ alpha  image, loaded as truecolor
  
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd_png.c?r1=1.26&r2=1.27&diff_format=u
Index: php-src/ext/gd/libgd/gd_png.c
diff -u php-src/ext/gd/libgd/gd_png.c:1.26 php-src/ext/gd/libgd/gd_png.c:1.27
--- php-src/ext/gd/libgd/gd_png.c:1.26  Thu Nov  6 10:23:52 2008
+++ php-src/ext/gd/libgd/gd_png.c       Wed Jan 14 10:16:42 2009
@@ -189,7 +189,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);
@@ -251,7 +252,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) {
                                php_gd_error("gd-png error: cannot allocate 
gray palette");
@@ -293,6 +293,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
@@ -365,6 +368,7 @@
                        }
                        break;
 
+               case PNG_COLOR_TYPE_GRAY_ALPHA:
                case PNG_COLOR_TYPE_RGB_ALPHA:
                        for (h = 0; h < height; h++) {
                                int boffset = 0;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to