--- parser3/src/classes/gd/Attic/gif.C 2001/04/17 19:00:32 1.5 +++ parser3/src/classes/gd/Attic/gif.C 2001/09/26 10:32:25 1.9 @@ -1,9 +1,20 @@ /** @file Parser: image manipulations impl1. + Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: gif.C,v 1.5 2001/04/17 19:00:32 paf Exp $ + $Id: gif.C,v 1.9 2001/09/26 10:32:25 parser Exp $ + + based on: gd + + Written by Tom Boutell, 5/94. + Copyright 1994, Cold Spring Harbor Labs. + Permission granted to use this code in any fashion provided + that this notice is retained and any alterations are + labeled as such. It is requested, but not required, that + you share extensions to this module with us so that we + can incorporate them into new versions. */ #include "gif.h" @@ -19,7 +30,7 @@ void gdImage::Create(int asx, int asy) { pixels = (unsigned char **) malloc(sizeof(unsigned char *) * sx); polyInts = 0; polyAllocated = 0; - styleWidth = 1; + lineWidth = 1; lineStyle=0; for (i=0; (i x2) { - x = x2; - y = y2; - ydirflag = (-1); - xend = x1; - } else { - x = x1; - y = y1; - ydirflag = 1; - xend = x2; - } - SetPixel(x, y, color); - if (((y2 - y1) * ydirflag) > 0) { - while (x < xend) { - x++; - if (d <0) { - d+=incr1; - } else { - y++; - d+=incr2; - } - SetPixel(x, y, color); - } - } else { - while (x < xend) { - x++; - if (d <0) { - d+=incr1; - } else { - y--; - d+=incr2; - } - SetPixel(x, y, color); - } - } - } else { - d = 2*dx - dy; - incr1 = 2*dx; - incr2 = 2 * (dx - dy); - if (y1 > y2) { - y = y2; - x = x2; - yend = y1; - xdirflag = (-1); - } else { - y = y1; - x = x1; - yend = y2; - xdirflag = 1; - } - SetPixel(x, y, color); - if (((x2 - x1) * xdirflag) > 0) { - while (y < yend) { - y++; - if (d <0) { - d+=incr1; - } else { - x++; - d+=incr2; - } - SetPixel(x, y, color); - } - } else { - while (y < yend) { - y++; - if (d <0) { - d+=incr1; - } else { - x--; - d+=incr2; - } - SetPixel(x, y, color); - } - } - } -} - /* As above, plus dashing */ -#define dashedSet \ +#define styledSet \ { \ - dashStep++; \ - if (dashStep == gdDashSize) { \ - dashStep = 0; \ - on = !on; \ + if (lineStyle) { \ + if(!lineStyle[styleStep]) \ + styleStep = 0; \ + on=lineStyle[styleStep++]!=' '; \ } \ if (on) { \ SetPixel(x, y, color); \ } \ } -void gdImage::DashedLine(int x1, int y1, int x2, int y2, int color) +void gdImage::Line(int x1, int y1, int x2, int y2, int color) { int dx, dy, incr1, incr2, d, x, y, xend, yend, xdirflag, ydirflag; - int dashStep = 0; + int styleStep = 0; int on = 1; dx = abs(x2-x1); dy = abs(y2-y1); @@ -268,7 +193,7 @@ void gdImage::DashedLine(int x1, int y1, ydirflag = 1; xend = x2; } - dashedSet; + styledSet; if (((y2 - y1) * ydirflag) > 0) { while (x < xend) { x++; @@ -278,7 +203,7 @@ void gdImage::DashedLine(int x1, int y1, y++; d+=incr2; } - dashedSet; + styledSet; } } else { while (x < xend) { @@ -289,7 +214,7 @@ void gdImage::DashedLine(int x1, int y1, y--; d+=incr2; } - dashedSet; + styledSet; } } } else { @@ -307,7 +232,7 @@ void gdImage::DashedLine(int x1, int y1, yend = y2; xdirflag = 1; } - dashedSet; + styledSet; if (((x2 - x1) * xdirflag) > 0) { while (y < yend) { y++; @@ -317,7 +242,7 @@ void gdImage::DashedLine(int x1, int y1, x++; d+=incr2; } - dashedSet; + styledSet; } } else { while (y < yend) { @@ -328,7 +253,7 @@ void gdImage::DashedLine(int x1, int y1, x--; d+=incr2; } - dashedSet; + styledSet; } } } @@ -587,7 +512,7 @@ static int gdGetByte(int *result, FILE * return 1; } -void gdImage::Polygon(Point *p, int n, int c) +void gdImage::Polygon(Point *p, int n, int c, bool closed) { int i; int lx, ly; @@ -596,7 +521,8 @@ void gdImage::Polygon(Point *p, int n, i } lx = p->x; ly = p->y; - Line(lx, ly, p[n-1].x, p[n-1].y, c); + if(closed) + Line(lx, ly, p[n-1].x, p[n-1].y, c); for (i=1; (i < n); i++) { p++; Line(lx, ly, p->x, p->y, c); @@ -857,8 +783,13 @@ void gdImage::SetInterlace(int interlace interlace = interlaceArg; } -void gdImage::SetStyle(int width) +void gdImage::SetLineWidth(int width) +{ + lineWidth=width; +} + +void gdImage::SetLineStyle(const char *alineStyle) { - styleWidth=width; + lineStyle=alineStyle; }