note 87763 added to function.imagesetpixel
| From: | (doctor3datgmail) | Date: | Sat, 20 Dec 2008 01:00:08 +0000 |
| Subject: | note 87763 added to function.imagesetpixel | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-148376@lists.php.net to get a copy of this message | ||
Re: imagecreatefromtga() .. I just did some testing with what I think are valid Targa-24 and
Targa-32 bit images, and modified the inner logic as follows:
if ($bytes_per_pixel == 2) // TARGA 16 - ARRRRRGG GGGBBBBB
{
$word = fileint($data, $pointer, 2);
$r = ($word & 0x7C00) >> 7;
$g = ($word & 0x03E0) >> 2;
$b = ($word & 0x001F) << 3;
$a = ($word & 0x8000) ? 127 : 0;
$color = imagecolorallocatealpha($image, $r, $g, $b, $a);
imagesetpixel($image, $x, $y, $color); }
else if ($bytes_per_pixel == 3) // TARGA 24 - BBBBBBBB GGGGGGGG RRRRRRRR
{
$r = fileint($data, $pointer, 1);
$b = fileint($data, $pointer+1, 1);
$g = fileint($data, $pointer+2, 1);
$color = imagecolorallocate($image, $r, $g, $b);
imagesetpixel($image, $x, $y, $color);
}
else if ($bytes_per_pixel == 4) // TARGA 32 - BBBBBBBB GGGGGGGG RRRRRRRR AAAAAAAA
{
$b = fileint($data, $pointer, 1);
$g = fileint($data, $pointer+1, 1);
$r = fileint($data, $pointer+2, 1);
$a = (255 - fileint($data, $pointer+3, 1)) >> 1;
$color = imagecolorallocatealpha($image, $r, $g, $b, $a);
imagesetpixel($image, $x, $y, $color);
}
The red and blue tint issue seems to be fixed by this...
----
Server IP: 64.71.164.2
Probable Submitter: 72.74.231.155
----
Manual Page -- http://www.php.net/manual/en/function.imagesetpixel.php
Edit -- https://master.php.net/note/edit/87763
Del: integrated -- https://master.php.net/note/delete/87763/integrated
Del: useless -- https://master.php.net/note/delete/87763/useless
Del: bad code -- https://master.php.net/note/delete/87763/bad+code
Del: spam -- https://master.php.net/note/delete/87763/spam
Del: non-english -- https://master.php.net/note/delete/87763/non-english
Del: in docs -- https://master.php.net/note/delete/87763/in+docs
Del: other reasons-- https://master.php.net/note/delete/87763
Reject -- https://master.php.net/note/reject/87763
Search -- https://master.php.net/manage/user-notes.php