pajoye Fri Mar 9 01:18:40 2007 UTC
Modified files: (Branch: PHP_5_2)
/php-src/ext/gd/libgd gd.c
Log:
- #40764, line thickness not respected for horizontal and vertical lines
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.90.2.1.2.9&r2=1.90.2.1.2.10&diff_format=u
Index: php-src/ext/gd/libgd/gd.c
diff -u php-src/ext/gd/libgd/gd.c:1.90.2.1.2.9
php-src/ext/gd/libgd/gd.c:1.90.2.1.2.10
--- php-src/ext/gd/libgd/gd.c:1.90.2.1.2.9 Fri Jan 19 15:03:56 2007
+++ php-src/ext/gd/libgd/gd.c Fri Mar 9 01:18:40 2007
@@ -847,7 +847,9 @@
srcy = y % gdImageSY(im->tile);
if (im->trueColor) {
p = gdImageGetTrueColorPixel(im->tile, srcx, srcy);
- gdImageSetPixel(im, x, y, p);
+ if (p != gdImageGetTransparent (im->tile)) {
+ gdImageSetPixel(im, x, y, p);
+ }
} else {
p = gdImageGetPixel(im->tile, srcx, srcy);
/* Allow for transparency */
@@ -1032,25 +1034,37 @@
/* 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;
- }
+ 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;
}
@@ -3398,7 +3412,7 @@
}
int
-gdAlphaBlend (int dst, int src)
+gdAlphaBlendOld (int dst, int src)
{
/* 2.0.12: TBB: alpha in the destination should be a
* component of the result. Thanks to Frank Warmerdam for
@@ -3420,6 +3434,51 @@
gdTrueColorGetBlue (dst)) / gdAlphaMax));
}
+int gdAlphaBlend (int dst, int src) {
+ int src_alpha = gdTrueColorGetAlpha(src);
+ int dst_alpha, alpha, red, green, blue;
+ int src_weight, dst_weight, tot_weight;
+
+/* -------------------------------------------------------------------- */
+/* Simple cases we want to handle fast. */
+/* -------------------------------------------------------------------- */
+ if( src_alpha == gdAlphaOpaque )
+ return src;
+
+ dst_alpha = gdTrueColorGetAlpha(dst);
+ if( src_alpha == gdAlphaTransparent )
+ return dst;
+ if( dst_alpha == gdAlphaTransparent )
+ return src;
+
+/* -------------------------------------------------------------------- */
+/* What will the source and destination alphas be? Note that */
+/* the destination weighting is substantially reduced as the */
+/* overlay becomes quite opaque. */
+/* -------------------------------------------------------------------- */
+ src_weight = gdAlphaTransparent - src_alpha;
+ dst_weight = (gdAlphaTransparent - dst_alpha) * src_alpha / gdAlphaMax;
+ tot_weight = src_weight + dst_weight;
+
+/* -------------------------------------------------------------------- */
+/* What red, green and blue result values will we use? */
+/* -------------------------------------------------------------------- */
+ alpha = src_alpha * dst_alpha / gdAlphaMax;
+
+ red = (gdTrueColorGetRed(src) * src_weight
+ + gdTrueColorGetRed(dst) * dst_weight) / tot_weight;
+ green = (gdTrueColorGetGreen(src) * src_weight
+ + gdTrueColorGetGreen(dst) * dst_weight) / tot_weight;
+ blue = (gdTrueColorGetBlue(src) * src_weight
+ + gdTrueColorGetBlue(dst) * dst_weight) / tot_weight;
+
+/* -------------------------------------------------------------------- */
+/* Return merged result. */
+/* -------------------------------------------------------------------- */
+ return ((alpha << 24) + (red << 16) + (green << 8) + blue);
+
+}
+
void gdImageAlphaBlending (gdImagePtr im, int alphaBlendingArg)
{
im->alphaBlendingFlag = alphaBlendingArg;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php