From: pikeman at pikeman dot sytes dot net
Operating system: redhat 9
PHP version: 5.0.0RC2
PHP Bug Type: GD related
Bug description: bug in gd_topal.c
Description:
------------
in gd_topal.c in function pass2_no_dither line 1321
transparency detection code, the pointer is off by one causing a
nontransparent band in the transparent region in the resulting picture.
The inptr pointer has already been incremented to the next pixel at the
transparency check. should be changed to (inptr-1) to check the correct
pixel.
Reproduce code:
---------------
bad code:
r = gdTrueColorGetRed (*inptr);
g = gdTrueColorGetGreen (*inptr);
b = gdTrueColorGetBlue (*inptr++);
/* If the pixel is transparent, we assign it the palette index that
* will later be added at the end of the palette as the transparent
* index. */
if ((im->transparent >= 0) && (im->transparent == *inptr))
{
*outptr++ = im->colorsTotal;
continue;
}
Expected result:
----------------
*** gd_topal_original.c 2004-05-07 18:26:49.000000000 +0800
--- gd_topal.c 2004-05-07 17:30:29.000000000 +0800
***************
*** 1318,1324 ****
/* If the pixel is transparent, we assign it the palette index
that
* will later be added at the end of the palette as the
transparent
* index. */
! if ((im->transparent >= 0) && (im->transparent == *inptr))
{
*outptr++ = im->colorsTotal;
continue;
--- 1318,1324 ----
/* If the pixel is transparent, we assign it the palette index
that
* will later be added at the end of the palette as the
transparent
* index. */
! if ((im->transparent >= 0) && (im->transparent == *(inptr-1)))
{
*outptr++ = im->colorsTotal;
continue;
Actual result:
--------------
a bad picture.
--
Edit bug report at http://bugs.php.net/?id=28311&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=28311&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=28311&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=28311&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=28311&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=28311&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=28311&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=28311&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=28311&r=support
Expected behavior: http://bugs.php.net/fix.php?id=28311&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=28311&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=28311&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=28311&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28311&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=28311&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=28311&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=28311&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28311&r=float