summaryrefslogtreecommitdiff
path: root/ext/gd/libgd/gd_png.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/gd/libgd/gd_png.c')
-rw-r--r--ext/gd/libgd/gd_png.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/ext/gd/libgd/gd_png.c b/ext/gd/libgd/gd_png.c
index adc9b46c57..97eb1fccc9 100644
--- a/ext/gd/libgd/gd_png.c
+++ b/ext/gd/libgd/gd_png.c
@@ -7,7 +7,6 @@
/* JCE: Arrange HAVE_LIBPNG so that it can be set in gd.h */
#ifdef HAVE_LIBPNG
-
#include "png.h" /* includes zlib.h and setjmp.h */
#include "gdhelpers.h"
@@ -128,7 +127,6 @@ gdImageCreateFromPngCtx (gdIOCtx * infile)
png_bytepp row_pointers = NULL;
gdImagePtr im = NULL;
int i, j, *open = NULL;
- png_uint_32 ui, uj;
volatile int transparent = -1;
volatile int palette_allocated = FALSE;
@@ -228,7 +226,7 @@ gdImageCreateFromPngCtx (gdIOCtx * infile)
im->alpha[i] = gdAlphaMax - (trans[i] >> 1);
if ((trans[i] == 0) && (firstZero))
{
- transparent = i;
+ transparent = i;
firstZero = 0;
}
}
@@ -321,9 +319,9 @@ gdImageCreateFromPngCtx (gdIOCtx * infile)
}
/* set the individual row_pointers to point at the correct offsets */
- for (uj = 0; uj < height; ++uj)
+ for (j = 0; j < height; ++j)
{
- row_pointers[uj] = image_data + uj * rowbytes;
+ row_pointers[j] = image_data + j * rowbytes;
}
png_read_image (png_ptr, row_pointers); /* read whole image... */
@@ -354,44 +352,44 @@ gdImageCreateFromPngCtx (gdIOCtx * infile)
switch (color_type)
{
case PNG_COLOR_TYPE_RGB:
- for (uj = 0; uj < height; uj++)
+ for (j = 0; j < height; j++)
{
int boffset = 0;
- for (ui = 0; ui < width; ui++)
+ for (i = 0; i < width; i++)
{
- register png_byte r = row_pointers[uj][boffset++];
- register png_byte g = row_pointers[uj][boffset++];
- register png_byte b = row_pointers[uj][boffset++];
- im->tpixels[uj][ui] = gdTrueColor (r, g, b);
+ register png_byte r = row_pointers[j][boffset++];
+ register png_byte g = row_pointers[j][boffset++];
+ register png_byte b = row_pointers[j][boffset++];
+ im->tpixels[j][i] = gdTrueColor (r, g, b);
}
}
break;
case PNG_COLOR_TYPE_RGB_ALPHA:
- for (uj = 0; uj < height; uj++)
+ for (j = 0; j < height; j++)
{
int boffset = 0;
- for (ui = 0; ui < width; ui++)
+ for (i = 0; i < width; i++)
{
- register png_byte r = row_pointers[uj][boffset++];
- register png_byte g = row_pointers[uj][boffset++];
- register png_byte b = row_pointers[uj][boffset++];
+ register png_byte r = row_pointers[j][boffset++];
+ register png_byte g = row_pointers[j][boffset++];
+ register png_byte b = row_pointers[j][boffset++];
/* gd has only 7 bits of alpha channel resolution, and
127 is transparent, 0 opaque. A moment of convenience,
a lifetime of compatibility. */
register png_byte a = gdAlphaMax -
- (row_pointers[uj][boffset++] >> 1);
- im->tpixels[uj][ui] = gdTrueColorAlpha (r, g, b, a);
+ (row_pointers[j][boffset++] >> 1);
+ im->tpixels[j][i] = gdTrueColorAlpha (r, g, b, a);
}
}
break;
default:
/* Palette image, or something coerced to be one */
- for (uj = 0; uj < height; ++uj)
+ for (j = 0; j < height; ++j)
{
- for (ui = 0; ui < width; ++ui)
+ for (i = 0; i < width; ++i)
{
- register png_byte idx = row_pointers[uj][ui];
- im->pixels[uj][ui] = idx;
+ register png_byte idx = row_pointers[j][i];
+ im->pixels[j][i] = idx;
open[idx] = 0;
}
}
@@ -597,7 +595,7 @@ gdImagePngCtx (gdImagePtr im, gdIOCtx * outfile)
{
trans_values[i] = 255 -
((im->alpha[i] << 1) +
- (im->alpha[i] >> 7));
+ (im->alpha[i] >> 6));
}
png_set_tRNS (png_ptr, info_ptr, trans_values, 256, NULL);
#endif
@@ -616,9 +614,10 @@ gdImagePngCtx (gdImagePtr im, gdIOCtx * outfile)
{
if (im->alpha[i] != gdAlphaOpaque)
{
+ /* Andrew Hull: >> 6, not >> 7! (gd 2.0.5) */
trans_values[j] = 255 -
((im->alpha[i] << 1) +
- (im->alpha[i] >> 7));
+ (im->alpha[i] >> 6));
mapping[i] = j++;
}
else
@@ -699,7 +698,8 @@ gdImagePngCtx (gdImagePtr im, gdIOCtx * outfile)
127 maps to 255. We also have to invert to match
PNG's convention in which 255 is opaque. */
a = gdTrueColorGetAlpha (im->tpixels[j][i]);
- row_pointers[j][bo++] = 255 - ((a << 1) + (a >> 7));
+ /* Andrew Hull: >> 6, not >> 7! (gd 2.0.5) */
+ row_pointers[j][bo++] = 255 - ((a << 1) + (a >> 6));
}
}
}