Diff for /parser3/src/classes/gd/Attic/gif.C between versions 1.5.8.1 and 1.9

version 1.5.8.1, 2001/09/15 15:42:08 version 1.9, 2001/09/26 10:32:25
Line 1 Line 1
 /** @file  /** @file
         Parser: image manipulations impl1.          Parser: image manipulations impl1.
   
           Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
         Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)          Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
   
         $Id$          $Id$
   
           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"  #include "gif.h"
Line 19  void gdImage::Create(int asx, int asy) { Line 30  void gdImage::Create(int asx, int asy) {
         pixels = (unsigned char **) malloc(sizeof(unsigned char *) * sx);          pixels = (unsigned char **) malloc(sizeof(unsigned char *) * sx);
         polyInts = 0;          polyInts = 0;
         polyAllocated = 0;          polyAllocated = 0;
         lineWidth = 1;          lineWidth = 1;  lineStyle=0;
         for (i=0; (i<asx); i++)          for (i=0; (i<asx); i++)
                 pixels[i] = (unsigned char *) calloc(asy);                  pixels[i] = (unsigned char *) calloc(asy);
         colorsTotal = 0;          colorsTotal = 0;
Line 146  int gdImage::GetPixel(int x, int y) Line 157  int gdImage::GetPixel(int x, int y)
   
 /* Bresenham as presented in Foley & Van Dam */  /* Bresenham as presented in Foley & Van Dam */
   
 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;  
         dx = abs(x2-x1);  
         dy = abs(y2-y1);  
         if (dy <= dx) {  
                 d = 2*dy - dx;  
                 incr1 = 2*dy;  
                 incr2 = 2 * (dy - dx);  
                 if (x1 > 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 */  /* As above, plus dashing */
   
 #define styledSet \  #define styledSet \
Line 246  void gdImage::Line(int x1, int y1, int x Line 171  void gdImage::Line(int x1, int y1, int x
                 } \                  } \
         }          }
   
 void gdImage::StyledLine(int x1, int y1, int x2, int y2, int color, const char *lineStyle)  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 dx, dy, incr1, incr2, d, x, y, xend, yend, xdirflag, ydirflag;
         int styleStep = 0;          int styleStep = 0;
Line 587  static int gdGetByte(int *result, FILE * Line 512  static int gdGetByte(int *result, FILE *
         return 1;          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 i;
         int lx, ly;          int lx, ly;
Line 596  void gdImage::Polygon(Point *p, int n, i Line 521  void gdImage::Polygon(Point *p, int n, i
         }          }
         lx = p->x;          lx = p->x;
         ly = p->y;          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++) {          for (i=1; (i < n); i++) {
                 p++;                  p++;
                 Line(lx, ly, p->x, p->y, c);                  Line(lx, ly, p->x, p->y, c);
Line 861  void gdImage::SetLineWidth(int width) Line 787  void gdImage::SetLineWidth(int width)
 {  {
         lineWidth=width;          lineWidth=width;
 }  }
   
   void gdImage::SetLineStyle(const char *alineStyle)
   {
           lineStyle=alineStyle;
   }
   

Removed from v.1.5.8.1  
changed lines
  Added in v.1.9


E-mail: