tabe            Wed Mar 18 15:29:57 2009 UTC

  Added files:                 
    /php-src/ext/gd/tests       libgd00186.phpt 

  Modified files:              
    /php-src/ext/gd/libgd       gd.c 
  Log:
  Fixed libgd #186 (Tiling true colour with palette image does not work)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.118&r2=1.119&diff_format=u
Index: php-src/ext/gd/libgd/gd.c
diff -u php-src/ext/gd/libgd/gd.c:1.118 php-src/ext/gd/libgd/gd.c:1.119
--- php-src/ext/gd/libgd/gd.c:1.118     Wed Feb 11 16:30:48 2009
+++ php-src/ext/gd/libgd/gd.c   Wed Mar 18 15:29:56 2009
@@ -860,23 +860,27 @@
 
 static void gdImageTileApply (gdImagePtr im, int x, int y)
 {
+       gdImagePtr tile = im->tile;
        int srcx, srcy;
        int p;
-       if (!im->tile) {
+       if (!tile) {
                return;
        }
-       srcx = x % gdImageSX(im->tile);
-       srcy = y % gdImageSY(im->tile);
+       srcx = x % gdImageSX(tile);
+       srcy = y % gdImageSY(tile);
        if (im->trueColor) {
-               p = gdImageGetTrueColorPixel(im->tile, srcx, srcy);
-               if (p != gdImageGetTransparent (im->tile)) {
+               p = gdImageGetPixel(tile, srcx, srcy);
+               if (p != gdImageGetTransparent (tile)) {
+                       if (!tile->trueColor) {
+                               p = gdTrueColorAlpha(tile->red[p], 
tile->green[p], tile->blue[p], tile->alpha[p]);
+                       }
                        gdImageSetPixel(im, x, y, p);
                }
        } else {
-               p = gdImageGetPixel(im->tile, srcx, srcy);
+               p = gdImageGetPixel(tile, srcx, srcy);
                /* Allow for transparency */
-               if (p != gdImageGetTransparent(im->tile)) {
-                       if (im->tile->trueColor) {
+               if (p != gdImageGetTransparent(tile)) {
+                       if (tile->trueColor) {
                                /* Truecolor tile. Very slow on a palette 
destination. */
                                gdImageSetPixel(im, x, y, 
gdImageColorResolveAlpha(im,
                                                                                
        gdTrueColorGetRed(p),

http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/libgd00186.phpt?view=markup&rev=1.1
Index: php-src/ext/gd/tests/libgd00186.phpt
+++ php-src/ext/gd/tests/libgd00186.phpt
--TEST--
libgd #186 (Tiling true colour with palette image does not work)
--SKIPIF--
<?php
        if (!extension_loaded('gd')) die("skip gd extension not available\n");
?>
--FILE--
<?php
$im = imagecreatetruecolor(10,10);
$tile = imagecreate(10,10);
$red   = imagecolorallocate($tile,0xff,0,0);
$green = imagecolorallocate($tile,0,0xff,0);
$blue  = imagecolorallocate($tile,0,0,0xff);
$other = imagecolorallocate($tile,0,0,0x2);
imagefilledrectangle($tile,0,0,2,10,$red);
imagefilledrectangle($tile,3,0,4,10,$green);
imagefilledrectangle($tile,5,0,7,10,$blue);
imagefilledrectangle($tile,8,0,9,10,$other);
imagecolortransparent($tile,$blue);
imagesettile($im,$tile);
for ($i=0; $i<10; $i++) {
  imagesetpixel($im,$i,$i,IMG_COLOR_TILED);
}
$index = imagecolorat($im,9,9);
$arr = imagecolorsforindex($im, $index);
if ($arr['blue'] == 2) {
  $r = "Ok";
} else {
  $r = "Failed";
}
imagedestroy($tile);
imagedestroy($im);
echo $r;
?>
--EXPECT--
Ok



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to