cvs: gd /libgd/src gd.c /libgd/tests CMakeLists.txt Makefile.am /libgd/tests/gdimagesetpixel CMakeLists.txt Makefile.am bug00186.c

[email protected] ("Takeshi Abe") Tue, 17 Mar 2009 17:29:29 -0000
Newsgroups php.gd.cvs
Message-ID <cvstabe1237310969@cvsserver>
tabe		Tue Mar 17 17:29:29 2009 UTC

  Added files:                 
    /gd/libgd/tests/gdimagesetpixel	CMakeLists.txt Makefile.am 
                                   	bug00186.c 

  Modified files:              
    /gd/libgd/src	gd.c 
    /gd/libgd/tests	CMakeLists.txt Makefile.am 
  Log:
  fixed FS#186
  
http://cvs.php.net/viewvc.cgi/gd/libgd/src/gd.c?r1=1.82&r2=1.83&diff_format=u
Index: gd/libgd/src/gd.c
diff -u gd/libgd/src/gd.c:1.82 gd/libgd/src/gd.c:1.83
--- gd/libgd/src/gd.c:1.82	Mon Mar  9 15:10:53 2009
+++ gd/libgd/src/gd.c	Tue Mar 17 17:29:28 2009
@@ -1,4 +1,4 @@
-/* $Id: gd.c,v 1.82 2009/03/09 15:10:53 tabe Exp $ */
+/* $Id: gd.c,v 1.83 2009/03/17 17:29:28 tabe Exp $ */
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -1098,28 +1098,32 @@
 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)) {
-	      gdImageSetPixel (im, x, y, p);
-			}
+      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 (p != gdImageGetTransparent (tile))
 	{
-	  if (im->tile->trueColor)
+	  if (tile->trueColor)
 	    {
 	      /* Truecolor tile. Very slow
 	         on a palette destination. */
http://cvs.php.net/viewvc.cgi/gd/libgd/tests/CMakeLists.txt?r1=1.10&r2=1.11&diff_format=u
Index: gd/libgd/tests/CMakeLists.txt
diff -u gd/libgd/tests/CMakeLists.txt:1.10 gd/libgd/tests/CMakeLists.txt:1.11
--- gd/libgd/tests/CMakeLists.txt:1.10	Sun Dec 21 09:08:11 2008
+++ gd/libgd/tests/CMakeLists.txt	Tue Mar 17 17:29:28 2009
@@ -36,6 +36,7 @@
 		gdimagecopyrotated
 		gdtiled
 		gdimagerectangle
+		gdimagesetpixel
 		gdimagefilledrectangle
 		gd2
 		gif
http://cvs.php.net/viewvc.cgi/gd/libgd/tests/Makefile.am?r1=1.4&r2=1.5&diff_format=u
Index: gd/libgd/tests/Makefile.am
diff -u gd/libgd/tests/Makefile.am:1.4 gd/libgd/tests/Makefile.am:1.5
--- gd/libgd/tests/Makefile.am:1.4	Sun Dec 21 09:08:11 2008
+++ gd/libgd/tests/Makefile.am	Tue Mar 17 17:29:28 2009
@@ -1,7 +1,7 @@
 ## Process this file with automake to produce Makefile.in -*-Makefile-*-
 AUTOMAKE_OPTIONS = foreign 1.7
 
-SUBDIRS = gd2 gdimagecolordeallocate gdimagecolortransparent gdimagefill gdimagefilltoborder gdtest jpeg gdimagearc gdimagecolorexact gdimagecopy gdimagefilledellipse gdimageline gdimagepixelate gdtiled freetype gdimagecolorclosest gdimagecolorreplace gdimagecolorresolve gdimagecopyrotated gdimagefilledrectangle gdimagerectangle gif png xpm
+SUBDIRS = gd2 gdimagecolordeallocate gdimagecolortransparent gdimagefill gdimagefilltoborder gdtest jpeg gdimagearc gdimagecolorexact gdimagecopy gdimagefilledellipse gdimageline gdimagepixelate gdtiled freetype gdimagecolorclosest gdimagecolorreplace gdimagecolorresolve gdimagecopyrotated gdimagefilledrectangle gdimagerectangle gdimagesetpixel gif png xpm
 
 EXTRA_DIST = CMakeLists.txt
 

http://cvs.php.net/viewvc.cgi/gd/libgd/tests/gdimagesetpixel/CMakeLists.txt?view=markup&rev=1.1
Index: gd/libgd/tests/gdimagesetpixel/CMakeLists.txt
+++ gd/libgd/tests/gdimagesetpixel/CMakeLists.txt
SET(TESTS_FILES
	bug00186
)

FOREACH(test_name ${TESTS_FILES})
	add_executable(${test_name} "${test_name}.c")
	target_link_libraries (${test_name} ${GDTESTS_TARGET_LINK})
	get_target_property(test_path ${test_name} LOCATION)
	ADD_TEST(${test_name} ${test_path})
ENDFOREACH(test_name)

http://cvs.php.net/viewvc.cgi/gd/libgd/tests/gdimagesetpixel/Makefile.am?view=markup&rev=1.1
Index: gd/libgd/tests/gdimagesetpixel/Makefile.am
+++ gd/libgd/tests/gdimagesetpixel/Makefile.am
## Process this file with automake to produce Makefile.in -*-Makefile-*-

EXTRA_DIST = CMakeLists.txt bug00186.c

http://cvs.php.net/viewvc.cgi/gd/libgd/tests/gdimagesetpixel/bug00186.c?view=markup&rev=1.1
Index: gd/libgd/tests/gdimagesetpixel/bug00186.c
+++ gd/libgd/tests/gdimagesetpixel/bug00186.c
#include "gd.h"
#include "gdtest.h"

int main()
{
	gdImagePtr im;
	gdImagePtr tile;
	int red, green, blue, other;
	int i, r = 0;

	im = gdImageCreateTrueColor(100, 100);
	tile = gdImageCreate(10, 10);
	red   = gdImageColorAllocate(tile, 0xFF, 0, 0);
	green = gdImageColorAllocate(tile, 0, 0xFF, 0);
	blue  = gdImageColorAllocate(tile, 0, 0, 0xFF);
	other = gdImageColorAllocate(tile, 0, 0, 0x2);
	gdImageFilledRectangle(tile, 0, 0, 2, 10, red);
	gdImageFilledRectangle(tile, 3, 0, 4, 10, green);
	gdImageFilledRectangle(tile, 5, 0, 7, 10, blue);
	gdImageFilledRectangle(tile, 8, 0, 9, 10, other);
	gdImageColorTransparent(tile, blue);
	gdImageSetTile(im, tile);
	for (i=0; i<100; i++) {
		gdImageSetPixel(im, i, i, gdTiled);
	}
	if (gdTrueColorGetBlue(gdImageGetPixel(im, 9, 9)) != 0x2) {
		r = 1;
	}
	gdImageDestroy(tile);
	gdImageDestroy(im);
	return r;
}