--- parser3/src/classes/gd/Attic/gif.h 2001/09/24 14:34:25 1.13 +++ parser3/src/classes/gd/Attic/gif.h 2003/03/24 14:53:56 1.23.2.5.2.2 @@ -1,10 +1,8 @@ /** @file Parser: image manipulations decls. - Author: Alexander Petrosyan (http://design.ru/paf) - - $Id: gif.h,v 1.13 2001/09/24 14:34:25 parser Exp $ - + Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) + Author: Alexandr Petrosian (http://paf.design.ru) based on: gd.h: declarations file for the gifdraw module. @@ -18,35 +16,48 @@ */ #ifndef GIF_H -#define GIF_H 1 +#define GIF_H + +static const char* IDENT_GIF_H="$Date: 2003/03/24 14:53:56 $"; #include "pa_config_includes.h" -#include "pa_pool.h" -#include "pa_string.h" + +#include "pa_memory.h" + +extern "C" { +#include "ec.h" +} #define gdMaxColors 0x100 #define HSIZE 5003 /* 80% occupancy */ +struct gdBuf { + void *ptr; + size_t size; + + gdBuf(void *aptr, size_t asize): ptr(aptr), size(asize) {} +}; + + /** Image type. See functions below; you will not need to change the elements directly. Use the provided macros to access sx, sy, the color table, and colorsTotal for read-only purposes. */ -class gdImage : public Pooled { +class gdImage: public PA_Object { public: //@{ /// @name Functions to manipulate images - gdImage(Pool& pool) : Pooled(pool) {} void Create(int asx, int asy); bool CreateFromGif(FILE *fd); void SetPixel(int x, int y, int color); int GetPixel(int x, int y); void Line(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 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 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); @@ -62,7 +73,7 @@ public: void FilledPolygonReplaceColor(Point *p, int n, int a, 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 ColorRGB(int r, int g, int b); int Color(unsigned int rgb); @@ -72,14 +83,15 @@ public: int BoundsSafe(int x, int y); 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 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 Fill(int x, int y, int color); 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 SetLineWidth(int width); - void SetLineStyle(const char *aLineStyle); + void SetLineStyle(const char* aLineStyle); void SetInterlace(int interlaceArg); /* On or off(1 or 0) */ public: @@ -109,7 +121,7 @@ private: int transparent; int *polyInts; int polyAllocated; - int lineWidth; const char *lineStyle; + int lineWidth; const char* lineStyle; int interlace; private: // read gif @@ -127,10 +139,10 @@ private: // read gif }; /// used by gdImage::Gif to produce buffer with bytes in GIF format -class gdGifEncoder : public Pooled { +class gdGifEncoder: public PA_Object { public: - gdGifEncoder(Pool& pool, gdImage& aim, String& afp); + gdGifEncoder(gdImage& aim, CORD_ec& afp); void encode( int GWidth, int GHeight, @@ -169,7 +181,7 @@ private: private: gdImage& im; - String& fp; + CORD_ec& fp; int Width, Height; int curx, cury; @@ -226,5 +238,6 @@ inline int gdImage::BoundsSafe(int x, in inline /*paf int*/void gdImage::DoSetPixel(int x, int y, int color){ if(BoundsSafe(x, y)) pixels[x][y] = color; } +DECLARE_OBJECT_PTR(gdGifEncoder); #endif