Commits

Anonymous committed 598769e

MFH: fixed FS#186

Comments (0)

Files changed (6)

 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. */

tests/CMakeLists.txt

 		gdimagecopyrotated
 		gdtiled
 		gdimagerectangle
+		gdimagesetpixel
 		gdimagefilledrectangle
 		gd2
 		gif

tests/Makefile.am

 ## 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 gdtiled freetype gdimagecolorclosest gdimagecolorresolve gdimagecopyrotated gdimagefilledrectangle gdimagerectangle gif png xpm
+SUBDIRS = gd2 gdimagecolordeallocate gdimagecolortransparent gdimagefill gdimagefilltoborder gdtest jpeg gdimagearc gdimagecolorexact gdimagecopy gdimagefilledellipse gdimageline gdtiled freetype gdimagecolorclosest gdimagecolorresolve gdimagecopyrotated gdimagefilledrectangle gdimagerectangle gdimagesetpixel gif png xpm
 
 EXTRA_DIST = CMakeLists.txt
 

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)

tests/gdimagesetpixel/Makefile.am

+## Process this file with automake to produce Makefile.in -*-Makefile-*-
+
+EXTRA_DIST = CMakeLists.txt bug00186.c

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;
+}