diff options
| author | Pierre Joye <pajoye@php.net> | 2006-11-04 14:27:07 +0000 |
|---|---|---|
| committer | Pierre Joye <pajoye@php.net> | 2006-11-04 14:27:07 +0000 |
| commit | 29242cfab91fbdc4336d2d37a1c0512e07bb2a68 (patch) | |
| tree | d8bb722ab0be52ad23de4712081185d0433ec2af /ext | |
| parent | 7b15d02b992190339b67c2d21e1dba4286eaa677 (diff) | |
| download | php-git-29242cfab91fbdc4336d2d37a1c0512e07bb2a68.tar.gz | |
- MFH: optimize horizontal and vertical lines
Diffstat (limited to 'ext')
| -rw-r--r-- | ext/gd/libgd/gd.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index bd6c984614..1d8de43615 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -1019,6 +1019,7 @@ void gdImageAABlend (gdImagePtr im) /* Bresenham as presented in Foley & Van Dam */ void gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color) { + int t; int dx, dy, incr1, incr2, d, x, y, xend, yend, xdirflag, ydirflag; int wid; int w, wstart; @@ -1029,6 +1030,31 @@ void gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color) return; } + /* Vertical */ + if (x1==x2) { + if (y2 < y1) { + t = y2; + y2 = y1; + y1 = t; + } + + for (;y1 <= y2; y1++) { + gdImageSetPixel(im, x1,y1, color); + } + return; + } else if (y1==y2) { /* Horizontal */ + if (x2 < x1) { + t = x2; + x2 = x1; + x1 = t; + } + + for (;x1 <= x2; x1++) { + gdImageSetPixel(im, x1,y1, color); + } + return; + } + /* gdAntiAliased passed as color: set anti-aliased line (AAL) global vars. */ if (color == gdAntiAliased) { im->AAL_x1 = x1; |
