PHP 4.0 Bug #8137: images are converted to wbmp as a "negative"
| From: | onn at zend dot com | Date: | Wed, 06 Dec 2000 17:02:11 +0000 |
| Subject: | PHP 4.0 Bug #8137: images are converted to wbmp as a "negative" | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-40228@lists.php.net to get a copy of this message | ||
From: onn@zend.com
Operating system: linux (7.0)
PHP version: 4.0 Latest CVS (06/12/2000)
PHP Bug Type: GD related
Bug description: images are converted to wbmp as a "negative"
when saving an image as wbmp (imagewbmp) i get the following
problems
1) if i load the image and then save it again as a jpeg,
then i will get a negative of the original.
2) when viewing the wbmp file - i viewed it at
http://www.teraflops.com/wbmp/ - i get the same
"negative"
result :)
the following script demonstrates:
<?php
$im = ImageCreate(200, 200);
$black = ImageColorAllocate($im,0,0,0);
$white = ImageColorAllocate($im,255,255,255);
ImageLine($im, 0, 0, 199, 199, $white);
// create the wmbp file
ImageWbmp($im,"../tmp/tmp_ImageCreateFromWbmp1.bmp");
// load it from disk
$im2 =
ImageCreateFromWbmp("../tmp/tmp_ImageCreateFromWbmp1.bmp");
// save as jpeg and wbmp again
ImageWbmp($im2,"../tmp/tmp_ImageCreateFromWbmp2.bmp");
ImageJpeg($im2,"../tmp/tmp_ImageCreateFromWbmp3.jpeg");
ImageDestroy($im);
ImageDestroy($im2);
?>
i would expect to see white diagnol across a black
backgrouond, but what i get the opposite - black diagonal
across a white background
the problem seems to be in the function:
_php_image_output_wbmp.
the following code
if(im->pixels[y][x] == 0) c = c | (1 << (7-p));
should be (i think)
if(im->pixels[y][x] != 0) c = c | (1 << (7-p));
(a != instead of an ==)
this gets the jpeg to be displayed correctly, but the wbmp
is still backwards (therefore not a complete fix??)
ONn
--
Edit Bug report at: http://bugs.php.net/?id=8137&edit=1