1. libgd
  2. Untitled project
  3. gd-libgd

Commits

Pierre Joye  committed 7a47a24 Merge

Merge branch 'master' of bitbucket.org:libgd/gd-libgd

  • Participants
  • Parent commits 1d523f6, 3ba6e6c
  • Branches master

Comments (0)

Files changed (7)

File .gitignore

View file
 /tests/php_bug_64898.c_55_diff.png
 /tests/php_bug_64898.c_55_out.png
 /tests/gdimagerotate/bug00067
+/tests/gdimageline/gdImageAALine_thickness
+/tests/gdimageline/gdimageline_bug5

File configure.ac

View file
 m4_define([gd_MAJOR],[2])dnl
 m4_define([gd_MINOR],[1])dnl
 m4_define([gd_REVISION],[0])dnl
-m4_define([gd_EXTRA],[rc1])dnl
+m4_define([gd_EXTRA],[rc2])dnl
 
 m4_ifdef([gd_EXTRA],
   [m4_define([gd_PKG_VERSION],[gd_MAJOR.gd_MINOR.gd_REVISION-gd_EXTRA])],
 FEATURES="GD_GIF GD_GIFANIM GD_OPENPOLYGON"
 AC_SUBST(FEATURES)
 
-AM_INIT_AUTOMAKE([foreign -Wall -Werror])
+AM_INIT_AUTOMAKE([foreign dist-bzip2 dist-xz -Wall -Werror])
 AC_CONFIG_HEADERS([src/config.h:src/config.hin])
 
 dnl newer automake wants this, but we still want to work with older

File src/gd.c

View file
 	/* keep them as 32bits */
 	long x, y, inc;
 	long dx, dy,tmp;
+	int w, wid, wstart; 
+	int thick = im->thick; 
 
 	if (!im->trueColor) {
 		/* TBB: don't crash when the image is of the wrong type */
 		/* TBB: allow setting points */
 		gdImageSetAAPixelColor(im, x1, y1, col, 0xFF);
 		return;
+	} else {
+		double ag;
+		ag = (abs(dy) < abs(dx)) ? cos(atan2(dy, dx)) : sin(atan2(dy, dx));
+		if (ag != 0) {
+			wid = abs(thick / ag);
+		} else {
+			wid = 1;
+		}
+		if (wid == 0) {
+			wid = 1;
+		}
 	}
 
 	/* Axis aligned lines */
 		inc = (dy * 65536) / dx;
 		/* TBB: set the last pixel for consistency (<=) */
 		while ((x >> 16) <= x2) {
-			gdImageSetAAPixelColor(im, x >> 16, y >> 16, col, (y >> 8) & 0xFF);
-			gdImageSetAAPixelColor(im, x >> 16, (y >> 16) + 1, col, (~y >> 8) & 0xFF);
+			wstart = (y >> 16) - wid / 2;
+			for (w = wstart; w < wstart + wid; w++) {
+			    gdImageSetAAPixelColor(im, (x >> 16) , w , col , (y >> 8) & 0xFF);
+			    gdImageSetAAPixelColor(im, (x >> 16) , w + 1 , col, (~y >> 8) & 0xFF);
+			}
 			x += (1 << 16);
 			y += inc;
 		}
 		inc = (dx * 65536) / dy;
 		/* TBB: set the last pixel for consistency (<=) */
 		while ((y >> 16) <= y2) {
-			gdImageSetAAPixelColor(im, x >> 16, y >> 16, col, (x >> 8) & 0xFF);
-			gdImageSetAAPixelColor(im, (x >> 16) + 1, (y >> 16), col, (~x >> 8) & 0xFF);
+			wstart = (x >> 16) - wid / 2;
+			for (w = wstart; w < wstart + wid; w++) {
+			    gdImageSetAAPixelColor(im, w , y >> 16  , col, (x >> 8) & 0xFF);
+			    gdImageSetAAPixelColor(im, w + 1, y >> 16, col, (~x >> 8) & 0xFF);
+			}
 			x += inc;
 			y += (1 << 16);
 		}

File tests/Makefile.am

View file
 	gdimageline/bug00072 \
 	gdimageline/bug00077 \
 	gdimageline/bug00111 \
+	gdimageline/gdimageline_bug5 \
+	gdimageline/gdImageAALine_thickness \
 	gdimageopenpolygon/gdimageopenpolygon2 \
 	gdimageopenpolygon/gdimageopenpolygon1 \
 	gdimageopenpolygon/gdimageopenpolygon0 \
 	gdimageline/bug00072 \
 	gdimageline/bug00077 \
 	gdimageline/bug00111 \
+	gdimageline/gdimageline_bug5 \
+	gdimageline/gdImageAALine_thickness \
 	gdimageopenpolygon/gdimageopenpolygon2 \
 	gdimageopenpolygon/gdimageopenpolygon1 \
 	gdimageopenpolygon/gdimageopenpolygon0 \
 	gdimagerotate/php_bug_64898.png \
 	gdimagerotate/php_bug_64898_exp.png \
 	gdimagerotate/remirh128.jpg \
-	gdimagerotate/php_bug_64898_000_exp.png \
-	gdimagerotate/php_bug_64898_015_exp.png \
-	gdimagerotate/php_bug_64898_030_exp.png \
-	gdimagerotate/php_bug_64898_045_exp.png \
-	gdimagerotate/php_bug_64898_060_exp.png \
-	gdimagerotate/php_bug_64898_075_exp.png \
-	gdimagerotate/php_bug_64898_090_exp.png \
-	gdimagerotate/php_bug_64898_105_exp.png \
-	gdimagerotate/php_bug_64898_120_exp.png \
-	gdimagerotate/php_bug_64898_135_exp.png \
-	gdimagerotate/php_bug_64898_150_exp.png \
-	gdimagerotate/php_bug_64898_165_exp.png \
-	gdimagerotate/php_bug_64898_180_exp.png
+	gdimagerotate/bug00067_000_exp.png \
+	gdimagerotate/bug00067_015_exp.png \
+	gdimagerotate/bug00067_030_exp.png \
+	gdimagerotate/bug00067_045_exp.png \
+	gdimagerotate/bug00067_060_exp.png \
+	gdimagerotate/bug00067_075_exp.png \
+	gdimagerotate/bug00067_090_exp.png \
+	gdimagerotate/bug00067_105_exp.png \
+	gdimagerotate/bug00067_120_exp.png \
+	gdimagerotate/bug00067_135_exp.png \
+	gdimagerotate/bug00067_150_exp.png \
+	gdimagerotate/bug00067_165_exp.png \
+	gdimagerotate/bug00067_180_exp.png \
+	gdimageline/gdImageAALine_thickness_exp.png
 
 CLEANFILES = \
 	a.png \

File tests/gdimageline/gdImageAALine_thickness.c

View file
+#include <stdio.h>
+#include "gd.h"
+#include "gdtest.h"
+
+int main(int argc, char **argv)
+{
+	gdImagePtr im;
+	char path[2048];
+	const char *file_exp = "gdimageline/gdImageAALine_thickness_exp.png";
+
+	im = gdImageCreateTrueColor(100, 100);
+	gdImageFilledRectangle(im, 0, 0, 99, 99,
+			       gdImageColorExactAlpha(im, 255, 255, 255, 0));
+
+	gdImageSetThickness(im, 5);
+	gdImageSetAntiAliased(im, gdImageColorExactAlpha(im, 0, 0, 0, 0));
+	gdImageLine(im, 0,0, 99, 99, gdAntiAliased);
+
+	sprintf(path, "%s/%s", GDTEST_TOP_DIR, file_exp);
+
+	if (!gdAssertImageEqualsToFile(path, im)) {
+		printf("comparing rotated image to %s failed.\n", path);
+		gdImageDestroy(im);
+		return 1;
+	}
+
+	gdImageDestroy(im);
+}

File tests/gdimageline/gdImageAALine_thickness_exp.png

Added
New image

File tests/gdimageline/gdimageline_bug5.c

View file
+#include <stdio.h>
+#include "gd.h"
+#include "gdtest.h"
+
+int main() {
+	/* Declare the image */
+	gdImagePtr im;
+
+	/* Declare output files */
+	/* FILE *pngout; */
+	int black, white;
+
+	im = gdImageCreateTrueColor(63318, 771);
+
+	/* Allocate the color white (red, green and blue all maximum). */
+	white = gdImageColorAllocate(im, 255, 255, 255);
+	/* Allocate the color white (red, green and blue all maximum). */
+	black = gdImageColorAllocate(im, 0, 0, 0);
+
+	/* white background */
+	gdImageFill(im, 1, 1, white);
+
+	gdImageSetAntiAliased(im, black);
+
+	/* This line fails! */
+	gdImageLine(im, 28562, 631, 34266, 750, gdAntiAliased);
+
+	/* Open a file for writing. "wb" means "write binary", important under MSDOS, harmless under Unix. */
+	/* pngout = fopen("test.png", "wb"); */
+
+	/* Output the image to the disk file in PNG format. */
+	/* gdImagePng(im, pngout); */
+
+	/* Close the files. */
+	/* fclose(pngout); */
+
+	/* Destroy the image in memory. */
+	gdImageDestroy(im);
+}