From 01c8b39ab8219bf30260d8a4e9dc2eb9decb59a2 Mon Sep 17 00:00:00 2001 From: Pierre Joye Date: Sat, 10 Mar 2007 01:23:42 +0000 Subject: [PATCH] - MFB: #40764, line thickness not respected for horizontal and vertical lines --- ext/gd/libgd/gd.c | 42 ++++++++++++++++++++++++-------------- ext/gd/tests/bug40764.phpt | 31 ++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 15 deletions(-) create mode 100644 ext/gd/tests/bug40764.phpt diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index 2a80faa9c8e..6cf29ba1df5 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -1032,25 +1032,37 @@ void gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color) /* Vertical */ if (x1==x2) { - if (y2 < y1) { - t = y2; - y2 = y1; - y1 = t; - } + if (thick > 1) { + int thickhalf = thick >> 1; + thickhalf = thick >> 1; + gdImageFilledRectangle(im, x1 - thickhalf, y1, x1 + thick - thickhalf - 1, y2, color); + } else { + if (y2 < y1) { + t = y2; + y2 = y1; + y1 = t; + } - for (;y1 <= y2; y1++) { - gdImageSetPixel(im, x1,y1, color); + for (;y1 <= y2; y1++) { + gdImageSetPixel(im, x1,y1, color); + } } return; - } else if (y1==y2) { /* Horizontal */ - if (x2 < x1) { - t = x2; - x2 = x1; - x1 = t; - } + } else if (y1==y2) { /* Horizontal */ + if (thick > 1) { + int thickhalf = thick >> 1; + thickhalf = thick >> 1; + gdImageFilledRectangle(im, x1, y1 - thickhalf, x2, y2 + thick - thickhalf - 1, color); + } else { + if (x2 < x1) { + t = x2; + x2 = x1; + x1 = t; + } - for (;x1 <= x2; x1++) { - gdImageSetPixel(im, x1,y1, color); + for (;x1 <= x2; x1++) { + gdImageSetPixel(im, x1,y1, color); + } } return; } diff --git a/ext/gd/tests/bug40764.phpt b/ext/gd/tests/bug40764.phpt new file mode 100644 index 00000000000..cbe262fe7a1 --- /dev/null +++ b/ext/gd/tests/bug40764.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #40764 (line thickness not respected for horizontal and vertical lines) +--SKIPIF-- + +--FILE-- + +--EXPECT-- +00