fixed FS#186

master
tabe 2009-03-17 17:29:29 +00:00
parent 15753f0446
commit 79f661f2f1
6 changed files with 61 additions and 11 deletions

View File

@ -1098,28 +1098,32 @@ gdImageBrushApply (gdImagePtr im, int x, int y)
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. */

View File

@ -36,6 +36,7 @@ if (BUILD_TEST)
gdimagecopyrotated
gdtiled
gdimagerectangle
gdimagesetpixel
gdimagefilledrectangle
gd2
gif

View File

@ -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

View File

@ -0,0 +1,10 @@
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)

View File

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

View File

@ -0,0 +1,32 @@
#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;
}