#ifndef GDPP_H #define GDPP_H 1 #ifdef __cplusplus #include "gd.h" #include "gd_io_stream.h" #include /* Example usage, convert png to gif: #include #include std::ifstream in("image.png", std::ios_base::in | std::ios_base::binary ); GD::Image im(in); if (im.good()) { std::ofstream out("image.gif", std::ios_base::out | std::ios_base::binary ); im.Gif(out); } */ namespace GD { class Point { public: // Constructors Point(int x, int y) :_x(x), _y(y) {} Point(const Point & p) :_x(p._x), _y(p._y) {} Point() :_x(0), _y(0) {} Point & operator=(const Point & p) { _x = p._x; _y = p._y; return (* this); } // Accessors int X() const { return _x; } int Y() const { return _y; } // Updaters void X(int x) { _x = x; } void Y(int y) { _y = y; } void set(int x, int y) { _x = x; _y = y; } int & lhsX() { return _x; } int & lhsY() { return _y; } gdPointPtr as_gdPointPtr() { return (gdPointPtr) this; } protected: int _x, _y; }; typedef Point * PointPtr; class Size { public: // Constructors Size(int w, int h) :_w(w), _h(h) {} Size(const Size & p) :_w(p._w), _h(p._h) {} Size() :_w(0), _h(0) {} Size & operator=(const Size & p) { _w = p._w; _h = p._h; return (* this); } // Accessors int W() const { return _w; } int H() const { return _h; } // Updaters void W(int w) { _w = w; } void H(int h) { _h = h; } void set(int w, int h) { _w = w; _h = h; } int & lhsW() { return _w; } int & lhsH() { return _h; } protected: int _w, _h; }; typedef Size * SizePtr; class TrueColor { public: union as_types { int as_int; struct uchars { unsigned char blue, green, red, alpha; } as_uchar; }; TrueColor() { internal.as_int = 0; } TrueColor(int c) { internal.as_int = c; } TrueColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 0) { internal.as_uchar.alpha = a; internal.as_uchar.red = r; internal.as_uchar.green = g; internal.as_uchar.blue = b; } // Accessors int Int() const { return internal.as_int; } unsigned char Red() const { return internal.as_uchar.red; } unsigned char Green() const { return internal.as_uchar.green; } unsigned char Blue() const { return internal.as_uchar.blue; } unsigned char Alpha() const { return internal.as_uchar.alpha; } // Updaters void set(int c) { internal.as_int = c; } void set(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 0) { internal.as_uchar.alpha = a; internal.as_uchar.red = r; internal.as_uchar.green = g; internal.as_uchar.blue = b; } void Red(unsigned char c) { internal.as_uchar.red = c; } void Green(unsigned char c) { internal.as_uchar.green = c; } void Blue(unsigned char c) { internal.as_uchar.blue = c; } void Alpha(unsigned char c) { internal.as_uchar.alpha = c; } protected: as_types internal; }; class BGD_EXPORT_DATA_IMPL Image // class Image { public: struct Png_tag {}; static Png_tag type_Png; struct Gif_tag {}; static Gif_tag type_Gif; struct WBMP_tag {}; static WBMP_tag type_WBMP; struct Jpeg_tag {}; static Jpeg_tag type_Jpeg; struct Gd_tag {}; static Gd_tag type_Gd; struct Gd2_tag {}; static Gd2_tag type_Gd2; struct Xbm_tag {}; static Xbm_tag type_Xbm; Image() :im(0) {} Image(int sx, int sy, bool istruecolor = false) :im(0) { if (istruecolor) CreateTrueColor(sx, sy); else Create(sx, sy); } Image(const Size & s, bool istruecolor = false) :im(0) { if (istruecolor) CreateTrueColor(s); else Create(s); } Image(gdImagePtr i) :im(i) {} Image(std::istream & in) :im(0) { CreateFrom(in); } Image(FILE * in) :im(0) { CreateFrom(in); } Image(std::istream & in, Png_tag) :im(0) { CreateFromPng(in); } Image(FILE * in, Png_tag) :im(0) { CreateFromPng(in); } Image(gdIOCtx * in, Png_tag) :im(0) { CreateFromPng(in); } Image(int size, void * data, Png_tag) :im(0) { CreateFromPng(size, data); } Image(std::istream & in, Gif_tag) :im(0) { CreateFromGif(in); } Image(FILE * in, Gif_tag) :im(0) { CreateFromGif(in); } Image(gdIOCtx * in, Gif_tag) :im(0) { CreateFromGif(in); } Image(int size, void * data, Gif_tag) :im(0) { CreateFromGif(size, data); } Image(std::istream & in, WBMP_tag) :im(0) { CreateFromWBMP(in); } Image(FILE * in, WBMP_tag) :im(0) { CreateFromWBMP(in); } Image(gdIOCtx * in, WBMP_tag) :im(0) { CreateFromWBMP(in); } Image(int size, void * data, WBMP_tag) :im(0) { CreateFromWBMP(size, data); } Image(std::istream & in, Jpeg_tag) :im(0) { CreateFromJpeg(in); } Image(FILE * in, Jpeg_tag) :im(0) { CreateFromJpeg(in); } Image(gdIOCtx * in, Jpeg_tag) :im(0) { CreateFromJpeg(in); } Image(int size, void * data, Jpeg_tag) :im(0) { CreateFromJpeg(size, data); } Image(std::istream & in, Gd_tag) :im(0) { CreateFromGd(in); } Image(FILE * in, Gd_tag) :im(0) { CreateFromGd(in); } Image(gdIOCtx * in, Gd_tag) :im(0) { CreateFromGd(in); } Image(int size, void * data, Gd_tag) :im(0) { CreateFromGd(size, data); } Image(std::istream & in, Gd2_tag) :im(0) { CreateFromGd2(in); } Image(FILE * in, Gd2_tag) :im(0) { CreateFromGd2(in); } Image(gdIOCtx * in, Gd2_tag) :im(0) { CreateFromGd2(in); } Image(int size, void * data, Gd2_tag) :im(0) { CreateFromGd2(size, data); } Image(FILE * in, Xbm_tag) :im(0) { CreateFromXbm(in); } ~Image() { clear(); } bool good() const { return (im != 0); } // Creation: bool Create(int sx, int sy) { clear(); return ((im = gdImageCreate(sx, sy)) != 0); } bool CreateTrueColor(int sx, int sy) { clear(); return ((im = gdImageCreateTrueColor(sx, sy)) != 0); } bool Create(const Size & s) { return Create(s.W(), s.H()); } bool CreateTrueColor(const Size & s) { return CreateTrueColor(s.W(), s.H()); } // Tagged bool CreateFrom(FILE * in, Png_tag) { return CreateFromPng(in); } bool CreateFrom(FILE * in); bool CreateFrom(std::istream & in); // Png bool CreateFromPng(FILE * in) { clear(); return ((im = gdImageCreateFromPng(in)) != 0); } bool CreateFromPng(gdIOCtx * in) { clear(); return ((im = gdImageCreateFromPngCtx(in)) != 0); } bool CreateFromPng(int size, void * data) { clear(); return ((im = gdImageCreateFromPngPtr(size, data)) != 0); } bool CreateFromPng(std::istream & in) { clear(); istreamIOCtx _in_ctx(in); return ((im = gdImageCreateFromPngCtx( & _in_ctx)) != 0); } // Gif bool CreateFromGif(FILE * in) { clear(); return ((im = gdImageCreateFromGif(in)) != 0); } bool CreateFromGif(gdIOCtx * in) { clear(); return ((im = gdImageCreateFromGifCtx(in)) != 0); } bool CreateFromGif(int size, void * data) { clear(); return ((im = gdImageCreateFromGifPtr(size, data)) != 0); } bool CreateFromGif(std::istream & in) { clear(); istreamIOCtx _in_ctx(in); return ((im = gdImageCreateFromGifCtx( & _in_ctx)) != 0); } // WBMP bool CreateFromWBMP(FILE * in) { clear(); return ((im = gdImageCreateFromWBMP(in)) != 0); } bool CreateFromWBMP(gdIOCtx * in) { clear(); return ((im = gdImageCreateFromWBMPCtx(in)) != 0); } bool CreateFromWBMP(int size, void * data) { clear(); return ((im = gdImageCreateFromWBMPPtr(size, data)) != 0); } bool CreateFromWBMP(std::istream & in) { clear(); istreamIOCtx _in_ctx(in); return ((im = gdImageCreateFromWBMPCtx( & _in_ctx)) != 0); } // Jpeg bool CreateFromJpeg(FILE * in) { clear(); return ((im = gdImageCreateFromJpeg(in)) != 0); } bool CreateFromJpeg(gdIOCtx * in) { clear(); return ((im = gdImageCreateFromJpegCtx(in)) != 0); } bool CreateFromJpeg(int size, void * data) { clear(); return ((im = gdImageCreateFromJpegPtr(size, data)) != 0); } bool CreateFromJpeg(std::istream & in) { clear(); istreamIOCtx _in_ctx(in); return ((im = gdImageCreateFromJpegCtx( & _in_ctx)) != 0); } // Gd bool CreateFromGd(FILE * in) { clear(); return ((im = gdImageCreateFromGd(in)) != 0); } bool CreateFromGd(gdIOCtx * in) { clear(); return ((im = gdImageCreateFromGdCtx(in)) != 0); } bool CreateFromGd(int size, void * data) { clear(); return ((im = gdImageCreateFromGdPtr(size, data)) != 0); } bool CreateFromGd(std::istream & in) { clear(); istreamIOCtx _in_ctx(in); return ((im = gdImageCreateFromGdCtx( & _in_ctx)) != 0); } // Gd2 bool CreateFromGd2(FILE * in) { clear(); return ((im = gdImageCreateFromGd2(in)) != 0); } bool CreateFromGd2(gdIOCtx * in) { clear(); return ((im = gdImageCreateFromGd2Ctx(in)) != 0); } bool CreateFromGd2(int size, void * data) { clear(); return ((im = gdImageCreateFromGd2Ptr(size, data)) != 0); } bool CreateFromGd2(std::istream & in) { clear(); istreamIOCtx _in_ctx(in); return ((im = gdImageCreateFromGd2Ctx( & _in_ctx)) != 0); } // Gd2 Part bool CreateFromGd2Part(FILE * in, int srcx, int srcy, int w, int h) { clear(); return ((im = gdImageCreateFromGd2Part(in, srcx, srcy, w, h)) != 0); } bool CreateFromGd2Part(gdIOCtx * in, int srcx, int srcy, int w, int h) { clear(); return ((im = gdImageCreateFromGd2PartCtx(in, srcx, srcy, w, h)) != 0); } bool CreateFromGd2Part(int size, void * data, int srcx, int srcy, int w, int h) { clear(); return ((im = gdImageCreateFromGd2PartPtr(size, data, srcx, srcy, w, h)) != 0); } bool CreateFromGd2Part(std::istream & in, int srcx, int srcy, int w, int h) { clear(); istreamIOCtx _in_ctx(in); return ((im = gdImageCreateFromGd2PartCtx( & _in_ctx, srcx, srcy, w, h)) != 0); } bool CreateFromGd2Part(FILE * in, const Point & src, const Size & s) { return CreateFromGd2Part(in, src.X(), src.Y(), s.W(), s.H()); } bool CreateFromGd2Part(gdIOCtx * in, const Point & src, const Size & s) { return CreateFromGd2Part(in, src.X(), src.Y(), s.W(), s.H()); } bool CreateFromGd2Part(int size, void * data, const Point & src, const Size & s) { return CreateFromGd2Part(size, data, src.X(), src.Y(), s.W(), s.H()); } bool CreateFromGd2Part(std::istream & in, const Point & src, const Size & s) { return CreateFromGd2Part(in, src.X(), src.Y(), s.W(), s.H()); } // Xbm bool CreateFromXbm(FILE * in) { clear(); return ((im = gdImageCreateFromXbm(in)) != 0); } // Xpm bool CreateFromXpm(char * filename) { clear(); return ((im = gdImageCreateFromXpm(filename)) != 0); } bool CreateFromXpm(const std::string & filename) { return CreateFromXpm(filename.c_str()); } // Accessors, Updaters & Methods: void SetPixel(int x, int y, int color) { gdImageSetPixel(im, x, y, color); } void SetPixel(const Point & p, int color) { SetPixel(p.X(), p.Y(), color); } int GetPixel(int x, int y) const { return gdImageGetPixel(im, x, y); } int GetPixel(const Point & p) const { return GetPixel(p.X(), p.Y()); } int GetTrueColorPixel(int x, int y) const { return gdImageGetTrueColorPixel(im, x, y); } int GetTrueColorPixel(const Point & p) const { return GetTrueColorPixel(p.X(), p.Y()); } void SetPixel(int x, int y, TrueColor c) { SetPixel(x, y, c.Int()); } void SetPixel(const Point & p, TrueColor c) { SetPixel(p.X(), p.Y(), c.Int()); } void GetTrueColorPixel(TrueColor & c, int x, int y) const { c.set(GetTrueColorPixel(x, y)); } void GetTrueColorPixel(TrueColor & c, const Point & p) const { c.set(GetTrueColorPixel(p.X(), p.Y())); } void AABlend() { gdImageAABlend(im); } void Line(int x1, int y1, int x2, int y2, int color) { gdImageLine(im, x1, y1, x2, y2, color); } void Line(const Point & p1, const Point & p2, int color) { Line(p1.X(), p1.Y(), p2.X(), p2.Y(), color); } void Rectangle(int x1, int y1, int x2, int y2, int color) { gdImageRectangle(im, x1, y1, x2, y2, color); } void Rectangle(const Point & p1, const Point & p2, int color) { Rectangle(p1.X(), p1.Y(), p2.X(), p2.Y(), color); } void Rectangle(const Point & p, const Size & s, int color) { Rectangle(p.X(), p.Y(), p.X() + s.W(), p.Y() + s.H(), color); } void FilledRectangle(int x1, int y1, int x2, int y2, int color) { gdImageFilledRectangle(im, x1, y1, x2, y2, color); } void FilledRectangle(const Point & p1, const Point & p2, int color) { FilledRectangle(p1.X(), p1.Y(), p2.X(), p2.Y(), color); } void FilledRectangle(const Point & p, const Size & s, int color) { FilledRectangle(p.X(), p.Y(), p.X() + s.W(), p.Y() + s.H(), color); } void SetClip(int x1, int y1, int x2, int y2) { gdImageSetClip(im, x1, y1, x2, y2); } void SetClip(const Point & p1, const Point & p2) { SetClip(p1.X(), p1.Y(), p2.X(), p2.Y()); } void SetClip(const Point & p, const Size & s) { SetClip(p.X(), p.Y(), p.X() + s.W(), p.Y() + s.H()); } void GetClip(int & x1, int & y1, int & x2, int & y2) const { gdImageGetClip(im, & x1, & y1, & x2, & y2); } void GetClip(Point & p1, Point & p2) const { GetClip(p1.lhsX(), p1.lhsY(), p2.lhsX(), p2.lhsY()); } void GetClip(Point & p, Size & s) const { Point p2; GetClip(p.lhsX(), p.lhsY(), p2.lhsX(), p2.lhsY()); s.set(p2.X() - p.X(), p2.Y() - p.Y()); } bool BoundsSafe(int x, int y) const { return (gdImageBoundsSafe(im, x, y)?true:false); } bool BoundsSafe(const Point & p) const { return BoundsSafe(p.X(), p.Y()); } void Char(gdFontPtr f, int x, int y, int c, int color) { gdImageChar(im, f, x, y, c, color); } void CharUp(gdFontPtr f, int x, int y, int c, int color) { gdImageCharUp(im, f, x, y, c, color); } void Char(gdFontPtr f, const Point & p, int c, int color) { Char(f, p.X(), p.Y(), c, color); } void CharUp(gdFontPtr f, const Point & p, int c, int color) { CharUp(f, p.X(), p.Y(), c, color); } void String(gdFontPtr f, int x, int y, unsigned char * s, int color) { gdImageString(im, f, x, y, (unsigned char *)s, color); } void StringUp(gdFontPtr f, int x, int y, unsigned char * s, int color) { gdImageStringUp(im, f, x, y, (unsigned char *)s, color); } void String(gdFontPtr f, int x, int y, unsigned short * s, int color) { gdImageString16(im, f, x, y, (unsigned short *)s, color); } void StringUp(gdFontPtr f, int x, int y, unsigned short * s, int color) { gdImageStringUp16(im, f, x, y, (unsigned short *)s, color); } void String(gdFontPtr f, int x, int y, char * s, int color) { gdImageString(im, f, x, y, (unsigned char *)s, color); } void StringUp(gdFontPtr f, int x, int y, char * s, int color) { gdImageStringUp(im, f, x, y, (unsigned char *)s, color); } void String(gdFontPtr f, int x, int y, const std::string & s, int color) { String(f, x, y, (char *)s.c_str(), color); } void StringUp(gdFontPtr f, int x, int y, const std::string & s, int color) { StringUp(f, x, y, (char *)s.c_str(), color); } void String(gdFontPtr f, const Point & p, unsigned char * s, int color) { String(f, p.X(), p.Y(), (unsigned char *)s, color); } void StringUp(gdFontPtr f, const Point & p, unsigned char * s, int color) { StringUp(f, p.X(), p.Y(), (unsigned char *)s, color); } void String(gdFontPtr f, const Point & p, unsigned short * s, int color) { String(f, p.X(), p.Y(), (unsigned short *)s, color); } void StringUp(gdFontPtr f, const Point & p, unsigned short * s, int color) { StringUp(f, p.X(), p.Y(), (unsigned short *)s, color); } void String(gdFontPtr f, const Point & p, char * s, int color) { String(f, p.X(), p.Y(), (unsigned char *)s, color); } void StringUp(gdFontPtr f, const Point & p, char * s, int color) { StringUp(f, p.X(), p.Y(), (unsigned char *)s, color); } void String(gdFontPtr f, const Point & p, const std::string & s, int color) { String(f, p, (char *)s.c_str(), color); } void StringUp(gdFontPtr f, const Point & p, const std::string & s, int color) { StringUp(f, p, (char *)s.c_str(), color); } char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle, int x, int y, char * string) { return gdImageStringFT(im, brect, fg, fontlist, ptsize, angle, x, y, string); } char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle, int x, int y, char * string, gdFTStringExtraPtr strex) { return gdImageStringFTEx(im, brect, fg, fontlist, ptsize, angle, x, y, string, strex); } char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle, int x, int y, const std::string & string) { return StringFT(brect, fg, fontlist, ptsize, angle, x, y, (char *)string.c_str()); } char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle, int x, int y, const std::string & string, gdFTStringExtraPtr strex) { return StringFT(brect, fg, fontlist, ptsize, angle, x, y, (char *)string.c_str(), strex); } char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle, const Point & p, char * string) { return StringFT(brect, fg, fontlist, ptsize, angle, p.X(), p.Y(), string); } char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle, const Point & p, char * string, gdFTStringExtraPtr strex) { return StringFT(brect, fg, fontlist, ptsize, angle, p.X(), p.Y(), string, strex); } char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle, const Point & p, const std::string & string) { return StringFT(brect, fg, fontlist, ptsize, angle, p, (char *)string.c_str()); } char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle, const Point & p, const std::string & string, gdFTStringExtraPtr strex) { return StringFT(brect, fg, fontlist, ptsize, angle, p, (char *)string.c_str(), strex); } void Polygon(gdPointPtr p, int n, int c) { gdImagePolygon(im, p, n, c); } void OpenPolygon(gdPointPtr p, int n, int c) { gdImageOpenPolygon(im, p, n, c); } void FilledPolygon(gdPointPtr p, int n, int c) { gdImageFilledPolygon(im, p, n, c); } void Polygon(PointPtr p, int n, int c) { Polygon(p->as_gdPointPtr(), n, c); } void OpenPolygon(PointPtr p, int n, int c) { OpenPolygon(p->as_gdPointPtr(), n, c); } void FilledPolygon(PointPtr p, int n, int c) { FilledPolygon(p->as_gdPointPtr(), n, c); } int ColorAllocate(int r, int g, int b) { return gdImageColorAllocate(im, r, g, b); } int ColorAllocate(int r, int g, int b, int a) { return gdImageColorAllocateAlpha(im, r, g, b, a); } int ColorClosest(int r, int g, int b) const { return gdImageColorClosest(im, r, g, b); } int ColorClosest(int r, int g, int b, int a) const { return gdImageColorClosestAlpha(im, r, g, b, a); } int ColorClosestHWB(int r, int g, int b) const { return gdImageColorClosestHWB(im, r, g, b); } int ColorExact(int r, int g, int b) const { return gdImageColorExact(im, r, g, b); } int ColorExact(int r, int g, int b, int a) const { return gdImageColorExactAlpha(im, r, g, b, a); } int ColorResolve(int r, int g, int b) { return gdImageColorResolve(im, r, g, b); } int ColorResolve(int r, int g, int b, int a) { return gdImageColorResolveAlpha(im, r, g, b, a); } void ColorDeallocate(int color) { gdImageColorDeallocate(im, color); } void TrueColorToPalette(int ditherFlag, int colorsWanted) { gdImageTrueColorToPalette(im, ditherFlag, colorsWanted); } void ColorTransparent(int color) { gdImageColorTransparent(im, color); } void PaletteCopy(gdImagePtr src) { gdImagePaletteCopy(im, src); } void Gif(FILE * out) const { gdImageGif(im, out); } void Gif(gdIOCtx * out) const { gdImageGifCtx(im, out); } void * Gif(int * size) const { return gdImageGifPtr(im, size); } void Gif(std::ostream & out) const { ostreamIOCtx _out_ctx(out); gdImageGifCtx(im, & _out_ctx); } void Png(FILE * out) const { gdImagePng(im, out); } void Png(gdIOCtx * out) const { gdImagePngCtx(im, out); } void * Png(int * size) const { return gdImagePngPtr(im, size); } void Png(std::ostream & out) const { ostreamIOCtx _out_ctx(out); gdImagePngCtx(im, & _out_ctx); } void Png(FILE * out, int level) const { gdImagePngEx(im, out, level); } void Png(gdIOCtx * out, int level) const { gdImagePngCtxEx(im, out, level); } void * Png(int * size, int level) const { return gdImagePngPtrEx(im, size, level); } void Png(std::ostream & out, int level) const { ostreamIOCtx _out_ctx(out); gdImagePngCtxEx(im, & _out_ctx, level); } void WBMP(int fg, FILE * out) const { gdImageWBMP(im, fg, out); } void WBMP(int fg, gdIOCtx * out) const { gdImageWBMPCtx(im, fg, out); } void * WBMP(int * size, int fg) const { return gdImageWBMPPtr(im, size, fg); } void WBMP(int fg, std::ostream & out) const { ostreamIOCtx _out_ctx(out); gdImageWBMPCtx(im, fg, & _out_ctx); } void Jpeg(FILE * out, int quality = -1) const { gdImageJpeg(im, out, quality); } void Jpeg(gdIOCtx * out, int quality = -1) const { gdImageJpegCtx(im, out, quality); } void * Jpeg(int * size, int quality = -1) const { return gdImageJpegPtr(im, size, quality); } void Jpeg(std::ostream & out, int quality = -1) const { ostreamIOCtx _out_ctx(out); gdImageJpegCtx(im, & _out_ctx, quality); } void GifAnimBegin(FILE * out, int GlobalCM, int Loops) const { gdImageGifAnimBegin(im, out, GlobalCM, Loops); } void GifAnimAdd(FILE * out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm) const { gdImageGifAnimAdd(im, out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm); } inline static void GifAnimEnd(FILE * out) { gdImageGifAnimEnd(out); } void GifAnimBegin(gdIOCtx * out, int GlobalCM, int Loops) const { gdImageGifAnimBeginCtx(im, out, GlobalCM, Loops); } void GifAnimAdd(gdIOCtx * out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm) const { gdImageGifAnimAddCtx(im, out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm); } inline static void GifAnimEnd(gdIOCtx * out) { gdImageGifAnimEndCtx(out); } void * GifAnimBegin(int * size, int GlobalCM, int Loops) const { return gdImageGifAnimBeginPtr(im, size, GlobalCM, Loops); } void * GifAnimAdd(int * size, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm) const { return gdImageGifAnimAddPtr(im, size, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm); } inline static void * GifAnimEnd(int * size) { return gdImageGifAnimEndPtr(size); } void Gd(FILE * out) const { gdImageGd(im, out); } void Gd(int * size) const { gdImageGdPtr(im, size); } void Gd2(FILE * out, int cs, int fmt) const { gdImageGd2(im, out, cs, fmt); } void Gd2(int cs, int fmt, int * size) const { gdImageGd2Ptr(im, cs, fmt, size); } void Ellipse(int cx, int cy, int w, int h, int color) { gdImageEllipse(im, cx, cy, w, h, color); } void FilledArc(int cx, int cy, int w, int h, int s, int e, int color, int style) { gdImageFilledArc(im, cx, cy, w, h, s, e, color, style); } void Arc(int cx, int cy, int w, int h, int s, int e, int color) { gdImageArc(im, cx, cy, w, h, s, e, color); } void FilledEllipse(int cx, int cy, int w, int h, int color) { gdImageFilledEllipse(im, cx, cy, w, h, color); } void FillToBorder(int x, int y, int border, int color) { gdImageFillToBorder(im, x, y, border, color); } void Fill(int x, int y, int color) { gdImageFill(im, x, y, color); } void Ellipse(const Point & c, const Size & s, int color) { Ellipse(c.X(), c.Y(), s.W(), s.H(), color); } void FilledArc(const Point & c, const Size & si, int s, int e, int color, int style) { FilledArc(c.X(), c.Y(), si.W(), si.H(), s, e, color, style); } void Arc(const Point & c, const Size & si, int s, int e, int color) { Arc(c.X(), c.Y(), si.W(), si.H(), s, e, color); } void FilledEllipse(const Point & c, const Size & s, int color) { FilledEllipse(c.X(), c.Y(), s.W(), s.H(), color); } void FillToBorder(const Point & p, int border, int color) { FillToBorder(p.X(), p.Y(), border, color); } void Fill(const Point & p, int color) { Fill(p.X(), p.Y(), color); } void Copy(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h) { gdImageCopy(im, src, dstX, dstY, srcX, srcY, w, h); } void CopyMerge(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct) { gdImageCopyMerge(im, src, dstX, dstY, srcX, srcY, w, h, pct); } void CopyMergeGray(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct) { gdImageCopyMergeGray(im, src, dstX, dstY, srcX, srcY, w, h, pct); } void CopyResized(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH) { gdImageCopyResized(im, src, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH); } void CopyResampled(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH) { gdImageCopyResampled(im, src, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH); } void CopyRotated(const gdImagePtr src, double dstX, double dstY, int srcX, int srcY, int srcWidth, int srcHeight, int angle) { gdImageCopyRotated(im, src, dstX, dstY, srcX, srcY, srcWidth, srcHeight, angle); } void Copy(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & s) { Copy(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H()); } void CopyMerge(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & s, int pct) { CopyMerge(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H(), pct); } void CopyMergeGray(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & s, int pct) { CopyMergeGray(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H(), pct); } void CopyResized(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & dstS, const Size & srcS) { CopyResized(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), dstS.W(), dstS.H(), srcS.W(), srcS.H()); } void CopyResampled(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & dstS, const Size & srcS) { CopyResampled(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), dstS.W(), dstS.H(), srcS.W(), srcS.H()); } void CopyRotated(const gdImagePtr src, double dstX, double dstY, const Point & srcP, const Size & srcS, int angle) { CopyRotated(src, dstX, dstY, srcP.X(), srcP.Y(), srcS.W(), srcS.H(), angle); } void SetBrush(gdImagePtr brush) { gdImageSetBrush(im, brush); } void SetTile(gdImagePtr tile) { gdImageSetTile(im, tile); } void SetAntiAliased(int c) { gdImageSetAntiAliased(im, c); } void SetAntiAliasedDontBlend(int c, int dont_blend) { gdImageSetAntiAliasedDontBlend(im, c, dont_blend); } void SetStyle(int * style, int noOfPixels) { gdImageSetStyle(im, style, noOfPixels); } void SetThickness(int thickness) { gdImageSetThickness(im, thickness); } void Interlace(bool interlaceArg) { gdImageInterlace(im, interlaceArg?1:0); } void AlphaBlending(bool alphaBlendingArg) { gdImageAlphaBlending(im, alphaBlendingArg?1:0); } void SaveAlpha(bool saveAlphaArg) { gdImageSaveAlpha(im, saveAlphaArg?1:0); } bool IsTrueColor() const { return (gdImageTrueColor(im)?true:false); } int SX() const { return gdImageSX(im); } int SY() const { return gdImageSY(im); } int Width() const { return SX(); } int Height() const { return SY(); } void GetSize(Size & s) const { s.set(SX(), SY()); } int ColorsTotal() const { return gdImageColorsTotal(im); } int Red(int color) const { return gdImageRed(im, color); } int Green(int color) const { return gdImageGreen(im, color); } int Blue(int color) const { return gdImageBlue(im, color); } int Alpha(int color) const { return gdImageAlpha(im, color); } int GetTransparent() const { return gdImageGetTransparent(im); } int GetInterlaced() const { return gdImageGetInterlaced(im); } int PalettePixel(int x, int y) const { return gdImagePalettePixel(im, x, y); } int TrueColorPixel(int x, int y) const { return gdImageTrueColorPixel(im, x, y); } protected: void clear() { if (im) gdImageDestroy(im); im = 0; } gdImagePtr im; }; } // namespace GD std::istream & operator>> (std::istream & in, GD::Image & img); #endif /* __cplusplus */ #endif /* GDPP_H */