diff options
author | Pierre Joye <pajoye@php.net> | 2009-01-14 10:16:15 +0000 |
---|---|---|
committer | Pierre Joye <pajoye@php.net> | 2009-01-14 10:16:15 +0000 |
commit | 9880d8dbe7a7ce7be8dd6285ae1fe8058175f466 (patch) | |
tree | ddb107a9df1b1018d16b629dd952fa1dd3a41615 /ext/gd | |
parent | 84f13ab73afca8411afd0e86cb0b2b97ccdadf01 (diff) | |
download | php-git-9880d8dbe7a7ce7be8dd6285ae1fe8058175f466.tar.gz |
- [DOC] support for PNG gray levels+ alpha image, loaded as truecolor
Diffstat (limited to 'ext/gd')
-rw-r--r-- | ext/gd/libgd/gd_png.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/ext/gd/libgd/gd_png.c b/ext/gd/libgd/gd_png.c index e15ede73cc..506958106c 100644 --- a/ext/gd/libgd/gd_png.c +++ b/ext/gd/libgd/gd_png.c @@ -189,7 +189,8 @@ gdImagePtr gdImageCreateFromPngCtx (gdIOCtx * infile) 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); @@ -225,7 +226,6 @@ gdImagePtr gdImageCreateFromPngCtx (gdIOCtx * infile) } #endif - switch (color_type) { case PNG_COLOR_TYPE_PALETTE: png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette); @@ -251,7 +251,6 @@ gdImagePtr gdImageCreateFromPngCtx (gdIOCtx * infile) } 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 +292,9 @@ gdImagePtr gdImageCreateFromPngCtx (gdIOCtx * infile) } 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 +367,7 @@ gdImagePtr gdImageCreateFromPngCtx (gdIOCtx * infile) } break; + case PNG_COLOR_TYPE_GRAY_ALPHA: case PNG_COLOR_TYPE_RGB_ALPHA: for (h = 0; h < height; h++) { int boffset = 0; |