/[H9]/trunk/tntnet/dynamic/gd-cpp/gdpp.h
ViewVC logotype

Annotation of /trunk/tntnet/dynamic/gd-cpp/gdpp.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 115 - (hide annotations) (download)
Sat Dec 1 19:28:31 2007 UTC (16 years, 6 months ago) by torben
File MIME type: text/plain
File size: 28869 byte(s)
Small modification to the C++  libgd wrapper

1 torben 68 #ifndef GDPP_H
2     #define GDPP_H 1
3     #ifdef __cplusplus
4    
5     #include "gd.h"
6     #include "gd_io_stream.h"
7     #include <string>
8    
9     /* Example usage, convert png to gif:
10     #include <fstream>
11     #include <gdpp.h>
12    
13     std::ifstream in("image.png", std::ios_base::in | std::ios_base::binary );
14     GD::Image im(in);
15     if (im.good())
16     {
17     std::ofstream out("image.gif", std::ios_base::out | std::ios_base::binary );
18     im.Gif(out);
19     }
20     */
21    
22     namespace GD
23     {
24     class Point
25     {
26     public:
27     // Constructors
28     Point(int x, int y)
29     :_x(x), _y(y) {}
30     Point(const Point & p)
31     :_x(p._x), _y(p._y) {}
32     Point()
33     :_x(0), _y(0) {}
34     Point & operator=(const Point & p)
35     {
36     _x = p._x;
37     _y = p._y;
38     return (* this);
39     }
40     // Accessors
41     int X() const
42     { return _x; }
43     int Y() const
44     { return _y; }
45     // Updaters
46     void X(int x)
47     { _x = x; }
48     void Y(int y)
49     { _y = y; }
50     void set(int x, int y)
51     { _x = x; _y = y; }
52     int & lhsX()
53     { return _x; }
54     int & lhsY()
55     { return _y; }
56    
57     gdPointPtr as_gdPointPtr()
58     { return (gdPointPtr) this; }
59     protected:
60     int _x, _y;
61     };
62     typedef Point * PointPtr;
63     class Size
64     {
65     public:
66     // Constructors
67     Size(int w, int h)
68     :_w(w), _h(h) {}
69     Size(const Size & p)
70     :_w(p._w), _h(p._h) {}
71     Size()
72     :_w(0), _h(0) {}
73     Size & operator=(const Size & p)
74     {
75     _w = p._w;
76     _h = p._h;
77     return (* this);
78     }
79     // Accessors
80     int W() const
81     { return _w; }
82     int H() const
83     { return _h; }
84     // Updaters
85     void W(int w)
86     { _w = w; }
87     void H(int h)
88     { _h = h; }
89     void set(int w, int h)
90     { _w = w; _h = h; }
91     int & lhsW()
92     { return _w; }
93     int & lhsH()
94     { return _h; }
95     protected:
96     int _w, _h;
97     };
98     typedef Size * SizePtr;
99    
100     class TrueColor
101     {
102     public:
103     union as_types
104     {
105     int as_int;
106     struct uchars
107     {
108     unsigned char blue, green, red, alpha;
109     } as_uchar;
110     };
111     TrueColor()
112     { internal.as_int = 0; }
113     TrueColor(int c)
114     { internal.as_int = c; }
115     TrueColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 0)
116     {
117     internal.as_uchar.alpha = a;
118     internal.as_uchar.red = r;
119     internal.as_uchar.green = g;
120     internal.as_uchar.blue = b;
121     }
122     // Accessors
123     int Int() const
124     { return internal.as_int; }
125     unsigned char Red() const
126     { return internal.as_uchar.red; }
127     unsigned char Green() const
128     { return internal.as_uchar.green; }
129     unsigned char Blue() const
130     { return internal.as_uchar.blue; }
131     unsigned char Alpha() const
132     { return internal.as_uchar.alpha; }
133     // Updaters
134     void set(int c)
135     { internal.as_int = c; }
136     void set(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 0)
137     {
138     internal.as_uchar.alpha = a;
139     internal.as_uchar.red = r;
140     internal.as_uchar.green = g;
141     internal.as_uchar.blue = b;
142     }
143     void Red(unsigned char c)
144     { internal.as_uchar.red = c; }
145     void Green(unsigned char c)
146     { internal.as_uchar.green = c; }
147     void Blue(unsigned char c)
148     { internal.as_uchar.blue = c; }
149     void Alpha(unsigned char c)
150     { internal.as_uchar.alpha = c; }
151     protected:
152     as_types internal;
153     };
154    
155     class BGD_EXPORT_DATA_IMPL Image
156     // class Image
157     {
158     public:
159     struct Png_tag {};
160     static Png_tag type_Png;
161     struct Gif_tag {};
162     static Gif_tag type_Gif;
163     struct WBMP_tag {};
164     static WBMP_tag type_WBMP;
165     struct Jpeg_tag {};
166     static Jpeg_tag type_Jpeg;
167     struct Gd_tag {};
168     static Gd_tag type_Gd;
169     struct Gd2_tag {};
170     static Gd2_tag type_Gd2;
171     struct Xbm_tag {};
172     static Xbm_tag type_Xbm;
173    
174     Image()
175     :im(0)
176     {}
177    
178     Image(int sx, int sy, bool istruecolor = false)
179     :im(0)
180     {
181     if (istruecolor)
182     CreateTrueColor(sx, sy);
183     else
184     Create(sx, sy);
185     }
186     Image(const Size & s, bool istruecolor = false)
187     :im(0)
188     {
189     if (istruecolor)
190     CreateTrueColor(s);
191     else
192     Create(s);
193     }
194    
195     Image(gdImagePtr i)
196     :im(i) {}
197    
198     Image(std::istream & in)
199     :im(0) { CreateFrom(in); }
200     Image(FILE * in)
201     :im(0) { CreateFrom(in); }
202    
203     Image(std::istream & in, Png_tag)
204     :im(0) { CreateFromPng(in); }
205     Image(FILE * in, Png_tag)
206     :im(0) { CreateFromPng(in); }
207     Image(gdIOCtx * in, Png_tag)
208     :im(0) { CreateFromPng(in); }
209     Image(int size, void * data, Png_tag)
210     :im(0) { CreateFromPng(size, data); }
211    
212     Image(std::istream & in, Gif_tag)
213     :im(0) { CreateFromGif(in); }
214     Image(FILE * in, Gif_tag)
215     :im(0) { CreateFromGif(in); }
216     Image(gdIOCtx * in, Gif_tag)
217     :im(0) { CreateFromGif(in); }
218     Image(int size, void * data, Gif_tag)
219     :im(0) { CreateFromGif(size, data); }
220    
221     Image(std::istream & in, WBMP_tag)
222     :im(0) { CreateFromWBMP(in); }
223     Image(FILE * in, WBMP_tag)
224     :im(0) { CreateFromWBMP(in); }
225     Image(gdIOCtx * in, WBMP_tag)
226     :im(0) { CreateFromWBMP(in); }
227     Image(int size, void * data, WBMP_tag)
228     :im(0) { CreateFromWBMP(size, data); }
229    
230     Image(std::istream & in, Jpeg_tag)
231     :im(0) { CreateFromJpeg(in); }
232     Image(FILE * in, Jpeg_tag)
233     :im(0) { CreateFromJpeg(in); }
234     Image(gdIOCtx * in, Jpeg_tag)
235     :im(0) { CreateFromJpeg(in); }
236     Image(int size, void * data, Jpeg_tag)
237     :im(0) { CreateFromJpeg(size, data); }
238    
239     Image(std::istream & in, Gd_tag)
240     :im(0) { CreateFromGd(in); }
241     Image(FILE * in, Gd_tag)
242     :im(0) { CreateFromGd(in); }
243     Image(gdIOCtx * in, Gd_tag)
244     :im(0) { CreateFromGd(in); }
245     Image(int size, void * data, Gd_tag)
246     :im(0) { CreateFromGd(size, data); }
247    
248     Image(std::istream & in, Gd2_tag)
249     :im(0) { CreateFromGd2(in); }
250     Image(FILE * in, Gd2_tag)
251     :im(0) { CreateFromGd2(in); }
252     Image(gdIOCtx * in, Gd2_tag)
253     :im(0) { CreateFromGd2(in); }
254     Image(int size, void * data, Gd2_tag)
255     :im(0) { CreateFromGd2(size, data); }
256    
257     Image(FILE * in, Xbm_tag)
258     :im(0) { CreateFromXbm(in); }
259    
260     ~Image()
261     { clear(); }
262    
263     bool good() const
264     { return (im != 0); }
265     // Creation:
266     bool Create(int sx, int sy)
267     {
268     clear();
269     return ((im = gdImageCreate(sx, sy)) != 0);
270     }
271     bool CreateTrueColor(int sx, int sy)
272     {
273     clear();
274     return ((im = gdImageCreateTrueColor(sx, sy)) != 0);
275     }
276     bool Create(const Size & s)
277     { return Create(s.W(), s.H()); }
278     bool CreateTrueColor(const Size & s)
279     { return CreateTrueColor(s.W(), s.H()); }
280     // Tagged
281     bool CreateFrom(FILE * in, Png_tag)
282     { return CreateFromPng(in); }
283     bool CreateFrom(FILE * in);
284     bool CreateFrom(std::istream & in);
285     // Png
286     bool CreateFromPng(FILE * in)
287     {
288     clear();
289     return ((im = gdImageCreateFromPng(in)) != 0);
290     }
291     bool CreateFromPng(gdIOCtx * in)
292     {
293     clear();
294     return ((im = gdImageCreateFromPngCtx(in)) != 0);
295     }
296     bool CreateFromPng(int size, void * data)
297     {
298     clear();
299     return ((im = gdImageCreateFromPngPtr(size, data)) != 0);
300     }
301     bool CreateFromPng(std::istream & in)
302     {
303     clear();
304     istreamIOCtx _in_ctx(in);
305     return ((im = gdImageCreateFromPngCtx( & _in_ctx)) != 0);
306     }
307     // Gif
308     bool CreateFromGif(FILE * in)
309     {
310     clear();
311     return ((im = gdImageCreateFromGif(in)) != 0);
312     }
313     bool CreateFromGif(gdIOCtx * in)
314     {
315     clear();
316     return ((im = gdImageCreateFromGifCtx(in)) != 0);
317     }
318     bool CreateFromGif(int size, void * data)
319     {
320     clear();
321     return ((im = gdImageCreateFromGifPtr(size, data)) != 0);
322     }
323     bool CreateFromGif(std::istream & in)
324     {
325     clear();
326     istreamIOCtx _in_ctx(in);
327     return ((im = gdImageCreateFromGifCtx( & _in_ctx)) != 0);
328     }
329     // WBMP
330     bool CreateFromWBMP(FILE * in)
331     {
332     clear();
333     return ((im = gdImageCreateFromWBMP(in)) != 0);
334     }
335     bool CreateFromWBMP(gdIOCtx * in)
336     {
337     clear();
338     return ((im = gdImageCreateFromWBMPCtx(in)) != 0);
339     }
340     bool CreateFromWBMP(int size, void * data)
341     {
342     clear();
343     return ((im = gdImageCreateFromWBMPPtr(size, data)) != 0);
344     }
345     bool CreateFromWBMP(std::istream & in)
346     {
347     clear();
348     istreamIOCtx _in_ctx(in);
349     return ((im = gdImageCreateFromWBMPCtx( & _in_ctx)) != 0);
350     }
351     // Jpeg
352     bool CreateFromJpeg(FILE * in)
353     {
354     clear();
355     return ((im = gdImageCreateFromJpeg(in)) != 0);
356     }
357     bool CreateFromJpeg(gdIOCtx * in)
358     {
359     clear();
360     return ((im = gdImageCreateFromJpegCtx(in)) != 0);
361     }
362     bool CreateFromJpeg(int size, void * data)
363     {
364     clear();
365     return ((im = gdImageCreateFromJpegPtr(size, data)) != 0);
366     }
367     bool CreateFromJpeg(std::istream & in)
368     {
369     clear();
370     istreamIOCtx _in_ctx(in);
371     return ((im = gdImageCreateFromJpegCtx( & _in_ctx)) != 0);
372     }
373     // Gd
374     bool CreateFromGd(FILE * in)
375     {
376     clear();
377     return ((im = gdImageCreateFromGd(in)) != 0);
378     }
379     bool CreateFromGd(gdIOCtx * in)
380     {
381     clear();
382     return ((im = gdImageCreateFromGdCtx(in)) != 0);
383     }
384     bool CreateFromGd(int size, void * data)
385     {
386     clear();
387     return ((im = gdImageCreateFromGdPtr(size, data)) != 0);
388     }
389     bool CreateFromGd(std::istream & in)
390     {
391     clear();
392     istreamIOCtx _in_ctx(in);
393     return ((im = gdImageCreateFromGdCtx( & _in_ctx)) != 0);
394     }
395     // Gd2
396     bool CreateFromGd2(FILE * in)
397     {
398     clear();
399     return ((im = gdImageCreateFromGd2(in)) != 0);
400     }
401     bool CreateFromGd2(gdIOCtx * in)
402     {
403     clear();
404     return ((im = gdImageCreateFromGd2Ctx(in)) != 0);
405     }
406     bool CreateFromGd2(int size, void * data)
407     {
408     clear();
409     return ((im = gdImageCreateFromGd2Ptr(size, data)) != 0);
410     }
411     bool CreateFromGd2(std::istream & in)
412     {
413     clear();
414     istreamIOCtx _in_ctx(in);
415     return ((im = gdImageCreateFromGd2Ctx( & _in_ctx)) != 0);
416     }
417     // Gd2 Part
418     bool CreateFromGd2Part(FILE * in, int srcx, int srcy, int w, int h)
419     {
420     clear();
421     return ((im = gdImageCreateFromGd2Part(in, srcx, srcy, w, h)) != 0);
422     }
423     bool CreateFromGd2Part(gdIOCtx * in, int srcx, int srcy, int w, int h)
424     {
425     clear();
426     return ((im = gdImageCreateFromGd2PartCtx(in, srcx, srcy, w, h)) != 0);
427     }
428     bool CreateFromGd2Part(int size, void * data, int srcx, int srcy, int w, int h)
429     {
430     clear();
431     return ((im = gdImageCreateFromGd2PartPtr(size, data, srcx, srcy, w, h)) != 0);
432     }
433     bool CreateFromGd2Part(std::istream & in, int srcx, int srcy, int w, int h)
434     {
435     clear();
436     istreamIOCtx _in_ctx(in);
437     return ((im = gdImageCreateFromGd2PartCtx( & _in_ctx, srcx, srcy, w, h)) != 0);
438     }
439     bool CreateFromGd2Part(FILE * in, const Point & src, const Size & s)
440     { return CreateFromGd2Part(in, src.X(), src.Y(), s.W(), s.H()); }
441     bool CreateFromGd2Part(gdIOCtx * in, const Point & src, const Size & s)
442     { return CreateFromGd2Part(in, src.X(), src.Y(), s.W(), s.H()); }
443     bool CreateFromGd2Part(int size, void * data, const Point & src, const Size & s)
444     { return CreateFromGd2Part(size, data, src.X(), src.Y(), s.W(), s.H()); }
445     bool CreateFromGd2Part(std::istream & in, const Point & src, const Size & s)
446     { return CreateFromGd2Part(in, src.X(), src.Y(), s.W(), s.H()); }
447     // Xbm
448     bool CreateFromXbm(FILE * in)
449     {
450     clear();
451     return ((im = gdImageCreateFromXbm(in)) != 0);
452     }
453     // Xpm
454     bool CreateFromXpm(char * filename)
455     {
456     clear();
457     return ((im = gdImageCreateFromXpm(filename)) != 0);
458     }
459     bool CreateFromXpm(const std::string & filename)
460     { return CreateFromXpm(filename.c_str()); }
461    
462     // Accessors, Updaters & Methods:
463     void SetPixel(int x, int y, int color)
464     { gdImageSetPixel(im, x, y, color); }
465     void SetPixel(const Point & p, int color)
466     { SetPixel(p.X(), p.Y(), color); }
467     int GetPixel(int x, int y) const
468     { return gdImageGetPixel(im, x, y); }
469     int GetPixel(const Point & p) const
470     { return GetPixel(p.X(), p.Y()); }
471     int GetTrueColorPixel(int x, int y) const
472     { return gdImageGetTrueColorPixel(im, x, y); }
473     int GetTrueColorPixel(const Point & p) const
474     { return GetTrueColorPixel(p.X(), p.Y()); }
475    
476     void SetPixel(int x, int y, TrueColor c)
477     { SetPixel(x, y, c.Int()); }
478     void SetPixel(const Point & p, TrueColor c)
479     { SetPixel(p.X(), p.Y(), c.Int()); }
480     void GetTrueColorPixel(TrueColor & c, int x, int y) const
481     { c.set(GetTrueColorPixel(x, y)); }
482     void GetTrueColorPixel(TrueColor & c, const Point & p) const
483     { c.set(GetTrueColorPixel(p.X(), p.Y())); }
484    
485     void AABlend()
486     { gdImageAABlend(im); }
487    
488     void Line(int x1, int y1, int x2, int y2, int color)
489     { gdImageLine(im, x1, y1, x2, y2, color); }
490     void Line(const Point & p1, const Point & p2, int color)
491     { Line(p1.X(), p1.Y(), p2.X(), p2.Y(), color); }
492     void Rectangle(int x1, int y1, int x2, int y2, int color)
493     { gdImageRectangle(im, x1, y1, x2, y2, color); }
494     void Rectangle(const Point & p1, const Point & p2, int color)
495     { Rectangle(p1.X(), p1.Y(), p2.X(), p2.Y(), color); }
496     void Rectangle(const Point & p, const Size & s, int color)
497     { Rectangle(p.X(), p.Y(), p.X() + s.W(), p.Y() + s.H(), color); }
498     void FilledRectangle(int x1, int y1, int x2, int y2, int color)
499     { gdImageFilledRectangle(im, x1, y1, x2, y2, color); }
500     void FilledRectangle(const Point & p1, const Point & p2, int color)
501     { FilledRectangle(p1.X(), p1.Y(), p2.X(), p2.Y(), color); }
502     void FilledRectangle(const Point & p, const Size & s, int color)
503     { FilledRectangle(p.X(), p.Y(), p.X() + s.W(), p.Y() + s.H(), color); }
504    
505     void SetClip(int x1, int y1, int x2, int y2)
506     { gdImageSetClip(im, x1, y1, x2, y2); }
507     void SetClip(const Point & p1, const Point & p2)
508     { SetClip(p1.X(), p1.Y(), p2.X(), p2.Y()); }
509     void SetClip(const Point & p, const Size & s)
510     { SetClip(p.X(), p.Y(), p.X() + s.W(), p.Y() + s.H()); }
511     void GetClip(int & x1, int & y1, int & x2, int & y2) const
512     { gdImageGetClip(im, & x1, & y1, & x2, & y2); }
513     void GetClip(Point & p1, Point & p2) const
514     { GetClip(p1.lhsX(), p1.lhsY(), p2.lhsX(), p2.lhsY()); }
515     void GetClip(Point & p, Size & s) const
516     {
517     Point p2;
518     GetClip(p.lhsX(), p.lhsY(), p2.lhsX(), p2.lhsY());
519     s.set(p2.X() - p.X(), p2.Y() - p.Y());
520     }
521    
522     bool BoundsSafe(int x, int y) const
523     { return (gdImageBoundsSafe(im, x, y)?true:false); }
524     bool BoundsSafe(const Point & p) const
525     { return BoundsSafe(p.X(), p.Y()); }
526    
527     void Char(gdFontPtr f, int x, int y, int c, int color)
528     { gdImageChar(im, f, x, y, c, color); }
529     void CharUp(gdFontPtr f, int x, int y, int c, int color)
530     { gdImageCharUp(im, f, x, y, c, color); }
531    
532     void Char(gdFontPtr f, const Point & p, int c, int color)
533     { Char(f, p.X(), p.Y(), c, color); }
534     void CharUp(gdFontPtr f, const Point & p, int c, int color)
535     { CharUp(f, p.X(), p.Y(), c, color); }
536    
537     void String(gdFontPtr f, int x, int y, unsigned char * s, int color)
538     { gdImageString(im, f, x, y, (unsigned char *)s, color); }
539     void StringUp(gdFontPtr f, int x, int y, unsigned char * s, int color)
540     { gdImageStringUp(im, f, x, y, (unsigned char *)s, color); }
541     void String(gdFontPtr f, int x, int y, unsigned short * s, int color)
542     { gdImageString16(im, f, x, y, (unsigned short *)s, color); }
543     void StringUp(gdFontPtr f, int x, int y, unsigned short * s, int color)
544     { gdImageStringUp16(im, f, x, y, (unsigned short *)s, color); }
545     void String(gdFontPtr f, int x, int y, char * s, int color)
546     { gdImageString(im, f, x, y, (unsigned char *)s, color); }
547     void StringUp(gdFontPtr f, int x, int y, char * s, int color)
548     { gdImageStringUp(im, f, x, y, (unsigned char *)s, color); }
549     void String(gdFontPtr f, int x, int y, const std::string & s, int color)
550     { String(f, x, y, (char *)s.c_str(), color); }
551     void StringUp(gdFontPtr f, int x, int y, const std::string & s, int color)
552     { StringUp(f, x, y, (char *)s.c_str(), color); }
553    
554     void String(gdFontPtr f, const Point & p, unsigned char * s, int color)
555     { String(f, p.X(), p.Y(), (unsigned char *)s, color); }
556     void StringUp(gdFontPtr f, const Point & p, unsigned char * s, int color)
557     { StringUp(f, p.X(), p.Y(), (unsigned char *)s, color); }
558     void String(gdFontPtr f, const Point & p, unsigned short * s, int color)
559     { String(f, p.X(), p.Y(), (unsigned short *)s, color); }
560     void StringUp(gdFontPtr f, const Point & p, unsigned short * s, int color)
561     { StringUp(f, p.X(), p.Y(), (unsigned short *)s, color); }
562     void String(gdFontPtr f, const Point & p, char * s, int color)
563     { String(f, p.X(), p.Y(), (unsigned char *)s, color); }
564     void StringUp(gdFontPtr f, const Point & p, char * s, int color)
565     { StringUp(f, p.X(), p.Y(), (unsigned char *)s, color); }
566     void String(gdFontPtr f, const Point & p, const std::string & s, int color)
567     { String(f, p, (char *)s.c_str(), color); }
568     void StringUp(gdFontPtr f, const Point & p, const std::string & s, int color)
569     { StringUp(f, p, (char *)s.c_str(), color); }
570    
571     char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle,
572     int x, int y, char * string)
573     { return gdImageStringFT(im, brect, fg, fontlist, ptsize, angle, x, y, string); }
574     char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle,
575     int x, int y, char * string, gdFTStringExtraPtr strex)
576     { return gdImageStringFTEx(im, brect, fg, fontlist, ptsize, angle, x, y, string, strex); }
577     char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle,
578     int x, int y, const std::string & string)
579     { return StringFT(brect, fg, fontlist, ptsize, angle, x, y, (char *)string.c_str()); }
580     char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle,
581     int x, int y, const std::string & string, gdFTStringExtraPtr strex)
582     { return StringFT(brect, fg, fontlist, ptsize, angle, x, y, (char *)string.c_str(), strex); }
583    
584     char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle,
585     const Point & p, char * string)
586     { return StringFT(brect, fg, fontlist, ptsize, angle, p.X(), p.Y(), string); }
587     char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle,
588     const Point & p, char * string, gdFTStringExtraPtr strex)
589     { return StringFT(brect, fg, fontlist, ptsize, angle, p.X(), p.Y(), string, strex); }
590     char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle,
591     const Point & p, const std::string & string)
592     { return StringFT(brect, fg, fontlist, ptsize, angle, p, (char *)string.c_str()); }
593     char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle,
594     const Point & p, const std::string & string, gdFTStringExtraPtr strex)
595     { return StringFT(brect, fg, fontlist, ptsize, angle, p, (char *)string.c_str(), strex); }
596    
597     void Polygon(gdPointPtr p, int n, int c)
598     { gdImagePolygon(im, p, n, c); }
599     void OpenPolygon(gdPointPtr p, int n, int c)
600     { gdImageOpenPolygon(im, p, n, c); }
601     void FilledPolygon(gdPointPtr p, int n, int c)
602     { gdImageFilledPolygon(im, p, n, c); }
603    
604     void Polygon(PointPtr p, int n, int c)
605     { Polygon(p->as_gdPointPtr(), n, c); }
606     void OpenPolygon(PointPtr p, int n, int c)
607     { OpenPolygon(p->as_gdPointPtr(), n, c); }
608     void FilledPolygon(PointPtr p, int n, int c)
609     { FilledPolygon(p->as_gdPointPtr(), n, c); }
610    
611     int ColorAllocate(int r, int g, int b)
612     { return gdImageColorAllocate(im, r, g, b); }
613     int ColorAllocate(int r, int g, int b, int a)
614     { return gdImageColorAllocateAlpha(im, r, g, b, a); }
615    
616     int ColorClosest(int r, int g, int b) const
617     { return gdImageColorClosest(im, r, g, b); }
618     int ColorClosest(int r, int g, int b, int a) const
619     { return gdImageColorClosestAlpha(im, r, g, b, a); }
620     int ColorClosestHWB(int r, int g, int b) const
621     { return gdImageColorClosestHWB(im, r, g, b); }
622     int ColorExact(int r, int g, int b) const
623     { return gdImageColorExact(im, r, g, b); }
624     int ColorExact(int r, int g, int b, int a) const
625     { return gdImageColorExactAlpha(im, r, g, b, a); }
626     int ColorResolve(int r, int g, int b)
627     { return gdImageColorResolve(im, r, g, b); }
628     int ColorResolve(int r, int g, int b, int a)
629     { return gdImageColorResolveAlpha(im, r, g, b, a); }
630    
631     void ColorDeallocate(int color)
632     { gdImageColorDeallocate(im, color); }
633    
634     void TrueColorToPalette(int ditherFlag, int colorsWanted)
635     { gdImageTrueColorToPalette(im, ditherFlag, colorsWanted); }
636    
637     void ColorTransparent(int color)
638     { gdImageColorTransparent(im, color); }
639    
640     void PaletteCopy(gdImagePtr src)
641     { gdImagePaletteCopy(im, src); }
642    
643     void Gif(FILE * out) const
644     { gdImageGif(im, out); }
645     void Gif(gdIOCtx * out) const
646     { gdImageGifCtx(im, out); }
647     void * Gif(int * size) const
648     { return gdImageGifPtr(im, size); }
649     void Gif(std::ostream & out) const
650     {
651     ostreamIOCtx _out_ctx(out);
652     gdImageGifCtx(im, & _out_ctx);
653     }
654    
655     void Png(FILE * out) const
656     { gdImagePng(im, out); }
657     void Png(gdIOCtx * out) const
658     { gdImagePngCtx(im, out); }
659     void * Png(int * size) const
660     { return gdImagePngPtr(im, size); }
661     void Png(std::ostream & out) const
662     {
663     ostreamIOCtx _out_ctx(out);
664     gdImagePngCtx(im, & _out_ctx);
665     }
666     void Png(FILE * out, int level) const
667     { gdImagePngEx(im, out, level); }
668     void Png(gdIOCtx * out, int level) const
669     { gdImagePngCtxEx(im, out, level); }
670     void * Png(int * size, int level) const
671     { return gdImagePngPtrEx(im, size, level); }
672     void Png(std::ostream & out, int level) const
673     {
674     ostreamIOCtx _out_ctx(out);
675     gdImagePngCtxEx(im, & _out_ctx, level);
676     }
677    
678     void WBMP(int fg, FILE * out) const
679     { gdImageWBMP(im, fg, out); }
680     void WBMP(int fg, gdIOCtx * out) const
681     { gdImageWBMPCtx(im, fg, out); }
682     void * WBMP(int * size, int fg) const
683     { return gdImageWBMPPtr(im, size, fg); }
684     void WBMP(int fg, std::ostream & out) const
685     {
686     ostreamIOCtx _out_ctx(out);
687     gdImageWBMPCtx(im, fg, & _out_ctx);
688     }
689    
690     void Jpeg(FILE * out, int quality = -1) const
691     { gdImageJpeg(im, out, quality); }
692     void Jpeg(gdIOCtx * out, int quality = -1) const
693     { gdImageJpegCtx(im, out, quality); }
694     void * Jpeg(int * size, int quality = -1) const
695     { return gdImageJpegPtr(im, size, quality); }
696     void Jpeg(std::ostream & out, int quality = -1) const
697     {
698     ostreamIOCtx _out_ctx(out);
699     gdImageJpegCtx(im, & _out_ctx, quality);
700     }
701    
702     void GifAnimBegin(FILE * out, int GlobalCM, int Loops) const
703     { gdImageGifAnimBegin(im, out, GlobalCM, Loops); }
704     void GifAnimAdd(FILE * out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm) const
705     { gdImageGifAnimAdd(im, out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm); }
706     inline static void GifAnimEnd(FILE * out)
707     { gdImageGifAnimEnd(out); }
708     void GifAnimBegin(gdIOCtx * out, int GlobalCM, int Loops) const
709     { gdImageGifAnimBeginCtx(im, out, GlobalCM, Loops); }
710     void GifAnimAdd(gdIOCtx * out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm) const
711     { gdImageGifAnimAddCtx(im, out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm); }
712     inline static void GifAnimEnd(gdIOCtx * out)
713     { gdImageGifAnimEndCtx(out); }
714     void * GifAnimBegin(int * size, int GlobalCM, int Loops) const
715     { return gdImageGifAnimBeginPtr(im, size, GlobalCM, Loops); }
716     void * GifAnimAdd(int * size, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm) const
717     { return gdImageGifAnimAddPtr(im, size, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm); }
718     inline static void * GifAnimEnd(int * size)
719     { return gdImageGifAnimEndPtr(size); }
720    
721     void Gd(FILE * out) const
722     { gdImageGd(im, out); }
723     void Gd(int * size) const
724     { gdImageGdPtr(im, size); }
725     void Gd2(FILE * out, int cs, int fmt) const
726     { gdImageGd2(im, out, cs, fmt); }
727     void Gd2(int cs, int fmt, int * size) const
728     { gdImageGd2Ptr(im, cs, fmt, size); }
729    
730     void Ellipse(int cx, int cy, int w, int h, int color)
731     { gdImageEllipse(im, cx, cy, w, h, color); }
732     void FilledArc(int cx, int cy, int w, int h, int s, int e, int color, int style)
733     { gdImageFilledArc(im, cx, cy, w, h, s, e, color, style); }
734     void Arc(int cx, int cy, int w, int h, int s, int e, int color)
735     { gdImageArc(im, cx, cy, w, h, s, e, color); }
736     void FilledEllipse(int cx, int cy, int w, int h, int color)
737     { gdImageFilledEllipse(im, cx, cy, w, h, color); }
738     void FillToBorder(int x, int y, int border, int color)
739     { gdImageFillToBorder(im, x, y, border, color); }
740     void Fill(int x, int y, int color)
741     { gdImageFill(im, x, y, color); }
742    
743     void Ellipse(const Point & c, const Size & s, int color)
744     { Ellipse(c.X(), c.Y(), s.W(), s.H(), color); }
745     void FilledArc(const Point & c, const Size & si, int s, int e, int color, int style)
746     { FilledArc(c.X(), c.Y(), si.W(), si.H(), s, e, color, style); }
747     void Arc(const Point & c, const Size & si, int s, int e, int color)
748     { Arc(c.X(), c.Y(), si.W(), si.H(), s, e, color); }
749     void FilledEllipse(const Point & c, const Size & s, int color)
750     { FilledEllipse(c.X(), c.Y(), s.W(), s.H(), color); }
751     void FillToBorder(const Point & p, int border, int color)
752     { FillToBorder(p.X(), p.Y(), border, color); }
753     void Fill(const Point & p, int color)
754     { Fill(p.X(), p.Y(), color); }
755    
756     void Copy(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h)
757     { gdImageCopy(im, src, dstX, dstY, srcX, srcY, w, h); }
758     void CopyMerge(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct)
759     { gdImageCopyMerge(im, src, dstX, dstY, srcX, srcY, w, h, pct); }
760     void CopyMergeGray(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct)
761     { gdImageCopyMergeGray(im, src, dstX, dstY, srcX, srcY, w, h, pct); }
762    
763     void CopyResized(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH)
764     { gdImageCopyResized(im, src, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH); }
765 torben 115 void CopyResampled(const Image& src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH)
766     { gdImageCopyResampled(im, src.im, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH); }
767 torben 68 void CopyRotated(const gdImagePtr src, double dstX, double dstY, int srcX, int srcY, int srcWidth, int srcHeight, int angle)
768     { gdImageCopyRotated(im, src, dstX, dstY, srcX, srcY, srcWidth, srcHeight, angle); }
769    
770     void Copy(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & s)
771     { Copy(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H()); }
772     void CopyMerge(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & s, int pct)
773     { CopyMerge(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H(), pct); }
774     void CopyMergeGray(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & s, int pct)
775     { CopyMergeGray(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H(), pct); }
776    
777     void CopyResized(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & dstS, const Size & srcS)
778     { CopyResized(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), dstS.W(), dstS.H(), srcS.W(), srcS.H()); }
779 torben 115 void CopyResampled(const Image& src, const Point & dstP, const Point & srcP, const Size & dstS, const Size & srcS)
780 torben 68 { CopyResampled(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), dstS.W(), dstS.H(), srcS.W(), srcS.H()); }
781     void CopyRotated(const gdImagePtr src, double dstX, double dstY, const Point & srcP, const Size & srcS, int angle)
782     { CopyRotated(src, dstX, dstY, srcP.X(), srcP.Y(), srcS.W(), srcS.H(), angle); }
783    
784     void SetBrush(gdImagePtr brush)
785     { gdImageSetBrush(im, brush); }
786     void SetTile(gdImagePtr tile)
787     { gdImageSetTile(im, tile); }
788     void SetAntiAliased(int c)
789     { gdImageSetAntiAliased(im, c); }
790     void SetAntiAliasedDontBlend(int c, int dont_blend)
791     { gdImageSetAntiAliasedDontBlend(im, c, dont_blend); }
792     void SetStyle(int * style, int noOfPixels)
793     { gdImageSetStyle(im, style, noOfPixels); }
794     void SetThickness(int thickness)
795     { gdImageSetThickness(im, thickness); }
796    
797     void Interlace(bool interlaceArg)
798     { gdImageInterlace(im, interlaceArg?1:0); }
799     void AlphaBlending(bool alphaBlendingArg)
800     { gdImageAlphaBlending(im, alphaBlendingArg?1:0); }
801     void SaveAlpha(bool saveAlphaArg)
802     { gdImageSaveAlpha(im, saveAlphaArg?1:0); }
803    
804     bool IsTrueColor() const
805     { return (gdImageTrueColor(im)?true:false); }
806     int SX() const
807     { return gdImageSX(im); }
808     int SY() const
809     { return gdImageSY(im); }
810     int Width() const
811     { return SX(); }
812     int Height() const
813     { return SY(); }
814     void GetSize(Size & s) const
815     { s.set(SX(), SY()); }
816     int ColorsTotal() const
817     { return gdImageColorsTotal(im); }
818     int Red(int color) const
819     { return gdImageRed(im, color); }
820     int Green(int color) const
821     { return gdImageGreen(im, color); }
822     int Blue(int color) const
823     { return gdImageBlue(im, color); }
824     int Alpha(int color) const
825     { return gdImageAlpha(im, color); }
826     int GetTransparent() const
827     { return gdImageGetTransparent(im); }
828     int GetInterlaced() const
829     { return gdImageGetInterlaced(im); }
830     int PalettePixel(int x, int y) const
831     { return gdImagePalettePixel(im, x, y); }
832     int TrueColorPixel(int x, int y) const
833     { return gdImageTrueColorPixel(im, x, y); }
834    
835    
836     protected:
837     void clear()
838     {
839     if (im)
840     gdImageDestroy(im);
841     im = 0;
842     }
843     gdImagePtr im;
844     };
845     } // namespace GD
846     std::istream & operator>> (std::istream & in, GD::Image & img);
847    
848     #endif /* __cplusplus */
849     #endif /* GDPP_H */

  ViewVC Help
Powered by ViewVC 1.1.20