Diff for /parser3/src/classes/gd/Attic/gif.h between versions 1.4 and 1.24

version 1.4, 2001/04/11 18:07:17 version 1.24, 2003/07/24 11:31:20
Line 1 Line 1
 /** @file  /** @file
         Parser: image manipulations decls.          Parser: image manipulations decls.
   
         Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)          Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com)
           Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
         $Id$  
   
   
         based on:          based on:
         gd.h: declarations file for the gifdraw module.          gd.h: declarations file for the gifdraw module.
   
Line 19 Line 16
 */  */
   
 #ifndef GIF_H  #ifndef GIF_H
 #define GIF_H 1  #define GIF_H
   
   static const char* IDENT_GIF_H="$Date$";
   
   #include "pa_config_includes.h"
   
 #include "pa_pool.h"  
 #include "pa_string.h"  
   
 #include <stdio.h>  #include "pa_memory.h"
 #include <string.h>  
 #define gdMaxColors 0x100  #define gdMaxColors 0x100
 #define HSIZE  5003            /* 80% occupancy */  #define HSIZE  5003            /* 80% occupancy */
   
 /* For backwards compatibility only. Use gdImageSetStyle() for MUCH more flexible line drawing. Also see gdImageSetBrush(). */  struct gdBuf {
 #define gdDashSize 4          void *ptr;
           size_t size;
   
           gdBuf(void *aptr, size_t asize): ptr(aptr), size(asize) {}
   };
   
   class gdGrowingBuf: PA_Object {
           unsigned char *fptr;
           size_t fallocated;
           size_t fused;
   
           void expand(size_t delta) {
                   size_t new_allocated=fallocated+delta;
                   fptr=(unsigned char*)realloc(fptr, new_allocated);
                   fallocated=new_allocated;
           }
   public:
           operator gdBuf() { return gdBuf(fptr, fused); }
   
           gdGrowingBuf(): fptr(0), fallocated(0), fused(0) {}
   
           void append(unsigned char *abuf, size_t asize) {
                   ssize_t delta=asize-(fallocated-fused);
                   if(delta>0)
                           expand(delta+100);
   
                   memcpy(&fptr[fused], abuf, asize);
                   fused+=asize;
           }
   };
   
 /** Image type.   /** Image type. 
         See functions below; you will not need to change          See functions below; you will not need to change
Line 39 Line 66
         access sx, sy, the color table, and colorsTotal for           access sx, sy, the color table, and colorsTotal for 
         read-only purposes.           read-only purposes. 
 */  */
 class gdImage : public Pooled {  class gdImage: public PA_Object {
   
 public: /* Functions to manipulate images. */  
   
         gdImage(Pool& pool) : Pooled(pool) {}  public: 
           
           //@{
           /// @name Functions to manipulate images
         void Create(int asx, int asy);          void Create(int asx, int asy);
         bool CreateFromGif(FILE *fd);          bool CreateFromGif(FILE *fd);
         void SetPixel(int x, int y, int color);          void SetPixel(int x, int y, int color);
         int GetPixel(int x, int y);          int GetPixel(int x, int y);
         void Line(int x1, int y1, int x2, int y2, int color);          void Line(int x1, int y1, int x2, int y2, int color);
         void DashedLine(int x1, int y1, int x2, int y2, int color);          void StyledLine(int x1, int y1, int x2, int y2, int color, const char* lineStyle);
         void Rectangle(int x1, int y1, int x2, int y2, int color);          void Rectangle(int x1, int y1, int x2, int y2, int color);
         void LineReplaceColor(int x1, int y1, int x2, int y2, int a, int b);          void LineReplaceColor(int x1, int y1, int x2, int y2, int a, int b);
         void FilledRectangle(int x1, int y1, int x2, int y2, int color);          void FilledRectangle(int x1, int y1, int x2, int y2, int color);
           //@}
   
         /* Point type for use in polygon drawing. */          /// Point type for use in polygon drawing.
           
         struct Point {          struct Point {
                 int x, y;                  int x, y;
         };          };
                   
         void Polygon(Point *p, int n, int c);          void Polygon(Point *p, int n, int c, bool closed=true);
         void FilledPolygon(Point *p, int n, int c);          void FilledPolygon(Point *p, int n, int c);
         void FilledPolygonReplaceColor(Point *p, int n, int a, int b);          void FilledPolygonReplaceColor(Point *p, int n, int a, int b);
   
         int ColorAllocate(int r, int g, int b);          int ColorAllocate(int r, int g, int b);
         int ColorClosest(int r, int g, int b);          int ColorClosest(int r, int g, int b, int tolerance=0);
         int ColorExact(int r, int g, int b);          int ColorExact(int r, int g, int b);
         int ColorRGB(int r, int g, int b);          int ColorRGB(int r, int g, int b);
         int Color(unsigned int rgb);          int Color(unsigned int rgb);
Line 75  public: /* Functions to manipulate image Line 103  public: /* Functions to manipulate image
         int BoundsSafe(int x, int y);          int BoundsSafe(int x, int y);
         void DoSetPixel(int x, int y, int color);          void DoSetPixel(int x, int y, int color);
                   
         void Gif(String& out);          gdBuf Gif();
         void Arc(int cx, int cy, int w, int h, int s, int e, int color);          void Arc(int cx, int cy, int w, int h, int s, int e, int color);
           void Sector(int cx, int cy, int w, int h, int s, int e, int color);
         void FillToBorder(int x, int y, int border, int color);          void FillToBorder(int x, int y, int border, int color);
         void Fill(int x, int y, int color);          void Fill(int x, int y, int color);
         void Copy(gdImage& dst, int dstX, int dstY, int srcX, int srcY, int w, int h);          void Copy(gdImage& dst, int dstX, int dstY, int srcX, int srcY, int w, int h);
         void CopyResized(gdImage& dst, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH);          void CopyResampled(gdImage& dst, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH, int tolerance);
         void SetStyle(int width);          void SetLineWidth(int width);
           void SetLineStyle(const char* aLineStyle);
         void SetInterlace(int interlaceArg); /* On or off(1 or 0) */          void SetInterlace(int interlaceArg); /* On or off(1 or 0) */
                   
 public: /* information about image. READ ONLY */  public: 
   
           //@{
           /// @name information about image. READ ONLY
         int SX() { return sx; }          int SX() { return sx; }
         int SY() { return sy; }          int SY() { return sy; }
         int ColorsTotal() { return colorsTotal; }          int ColorsTotal() { return colorsTotal; }
Line 94  public: /* information about image. READ Line 126  public: /* information about image. READ
         int Blue(int c) { return blue[c]; }          int Blue(int c) { return blue[c]; }
         int GetTransparent() { return transparent; }          int GetTransparent() { return transparent; }
         int GetInterlaced() { return interlace; }          int GetInterlaced() { return interlace; }
           //@}
   
 private:  private:
   
Line 108  private: Line 141  private:
         int transparent;          int transparent;
         int *polyInts;          int *polyInts;
         int polyAllocated;          int polyAllocated;
         int styleWidth;          int lineWidth; const char* lineStyle;
         int interlace;          int interlace;
   
 private: // read gif  private: // read gif
Line 125  private: // read gif Line 158  private: // read gif
                   
 };  };
   
 class gdGifEncoder : public Pooled {  ///     used by gdImage::Gif to produce buffer with bytes in GIF format
   class gdGifEncoder: public PA_Object {
 public:  public:
   
         gdGifEncoder(Pool& pool, gdImage& aim, String& afp);          gdGifEncoder(gdImage& aim);
   
         void encode(           gdBuf encode( 
                 int GWidth, int GHeight,                   int GWidth, int GHeight, 
                 int GInterlace, int Background,                   int GInterlace, int Background, 
                 int Transparent, int BitsPerPixel,                   int Transparent, int BitsPerPixel, 
Line 138  public: Line 172  public:
   
 private:  private:
   
         /*          /// a code_int must be able to hold 2**GIFBITS values of type int, and also -1
          * a code_int must be able to hold 2**GIFBITS values of type int, and also -1  
          */  
         typedef int             code_int;          typedef int             code_int;
         #ifdef SIGNED_COMPARE_SLOW  #ifdef SIGNED_COMPARE_SLOW
         typedef unsigned long int count_int;          typedef unsigned long int count_int;
         typedef unsigned short int count_short;          typedef unsigned short int count_short;
         #else /*SIGNED_COMPARE_SLOW*/  #else
         typedef long int          count_int;          typedef long int          count_int;
         #endif /*SIGNED_COMPARE_SLOW*/  #endif
   
 private:  private:
   
         void Putbyte(int c);          void Putbyte(unsigned char c);
         void Putword(int w);          void Putword(int w);
         void Write(void *buf, size_t size);          void Write(void *buf, size_t size);
   
Line 169  private: Line 201  private:
 private:  private:
                   
         gdImage& im;          gdImage& im;
         String& fp;          gdGrowingBuf buf;
   
         int Width, Height;          int Width, Height;
         int curx, cury;          int curx, cury;
Line 227  inline /*paf int*/void gdImage::DoSetPix Line 259  inline /*paf int*/void gdImage::DoSetPix
     if(BoundsSafe(x, y)) pixels[x][y] = color;      if(BoundsSafe(x, y)) pixels[x][y] = color;
 }  }
   
   
   
 #endif  #endif

Removed from v.1.4  
changed lines
  Added in v.1.24


E-mail: