1 |
#ifndef GDPP_H |
/* ***************************************************************************** |
2 |
#define GDPP_H 1 |
** $Id: gdpp.h,v 1.2 2007/12/16 21:31:27 kshepherd Exp $ |
3 |
#ifdef __cplusplus |
** Initial file written and documented by: |
4 |
|
** Kevin Shepherd <kshepherd@php.net> December 2007 |
5 |
#include "gd.h" |
** of Scarlet Line http://www.scarletline.com/ |
6 |
#include "gd_io_stream.h" |
** with contributions from Torben Nielsen. |
7 |
#include <string> |
*******************************************************************************/ |
8 |
|
/** \file gdpp.h |
9 |
/* Example usage, convert png to gif: |
\brief Object Oriented C++ wrappers around libgd functionality. |
10 |
|
|
11 |
|
Example usage, convert png to gif: |
12 |
#include <fstream> |
#include <fstream> |
13 |
#include <gdpp.h> |
#include <gdpp.h> |
14 |
|
|
15 |
std::ifstream in("image.png", std::ios_base::in | std::ios_base::binary ); |
std::ifstream in("image.png", std::ios_base::in | std::ios_base::binary ); |
16 |
GD::Image im(in); |
GD::Image im(in, GD::Png_tag()); |
17 |
if (im.good()) |
if (im.good()) |
18 |
{ |
{ |
19 |
std::ofstream out("image.gif", std::ios_base::out | std::ios_base::binary ); |
std::ofstream out("image.gif", std::ios_base::out | std::ios_base::binary ); |
20 |
im.Gif(out); |
im.Gif(out); |
21 |
} |
} |
22 |
*/ |
*/ |
23 |
|
#ifdef __cplusplus |
24 |
|
#ifndef _gdpp_h |
25 |
|
#define _gdpp_h |
26 |
|
|
27 |
|
#include "gd_io_stream.h" |
28 |
|
#include <string> |
29 |
|
|
30 |
|
/// namespace GD:: contains the C++ wrapper classes for libgd |
31 |
|
/** This namespace is primarily to avoid name clashes, and to |
32 |
|
contain all of the gd classes within one namespace. |
33 |
|
It is not recommended to use the "using namespace" directive with this namespace. |
34 |
|
Example usage: |
35 |
|
GD::Image im(64, 32, true); // Create a truecolor image 64 pixels wide by 32 pixels high |
36 |
|
GD::Point pt(10, 8); // The point at x=10, y=8. |
37 |
|
GD::Size sz(16, 8); // The size width=16, height=8. |
38 |
|
GD::TrueColor col(0xFF, 0, 0); // The colour red; R=255, G=0, B=0. |
39 |
|
im.Rectangle(pt, sz, col.Int()); // Draw a red rectangle with top left corner at pt, of size sz. |
40 |
|
*/ |
41 |
namespace GD |
namespace GD |
42 |
{ |
{ |
43 |
|
/** This class GD::Point stores a point in two dimensions, somewhere |
44 |
|
on the plane of an image. |
45 |
|
*/ |
46 |
class Point |
class Point |
47 |
{ |
{ |
48 |
public: |
public: |
82 |
int _x, _y; |
int _x, _y; |
83 |
}; |
}; |
84 |
typedef Point * PointPtr; |
typedef Point * PointPtr; |
85 |
|
/** This class GD::Size stores length in two dimensions. |
86 |
|
Giving the size of an area as width and height. |
87 |
|
*/ |
88 |
class Size |
class Size |
89 |
{ |
{ |
90 |
public: |
public: |
122 |
}; |
}; |
123 |
typedef Size * SizePtr; |
typedef Size * SizePtr; |
124 |
|
|
125 |
|
/** This class GD::TrueColor stores a colour as an RGBA quadruplet. |
126 |
|
It can also be read as an integer, and in other colour formats. |
127 |
|
*/ |
128 |
class TrueColor |
class TrueColor |
129 |
{ |
{ |
130 |
public: |
public: |
179 |
protected: |
protected: |
180 |
as_types internal; |
as_types internal; |
181 |
}; |
}; |
182 |
|
/* The following tags are simply empty structures which are used |
183 |
|
to tell the compiler which constructor we want when we know |
184 |
|
the image file format. |
185 |
|
*/ |
186 |
|
struct Png_tag {}; |
187 |
|
struct Gif_tag {}; |
188 |
|
struct WBMP_tag {}; |
189 |
|
struct Jpeg_tag {}; |
190 |
|
struct Gd_tag {}; |
191 |
|
struct Gd2_tag {}; |
192 |
|
struct Xbm_tag {}; |
193 |
|
|
194 |
|
/** This class GD::Image wraps all of the 'C' libgd functionality |
195 |
|
for the convenience of C++ users. An instance of this class |
196 |
|
corresponds to a single image. |
197 |
|
*/ |
198 |
class BGD_EXPORT_DATA_IMPL Image |
class BGD_EXPORT_DATA_IMPL Image |
|
// class Image |
|
199 |
{ |
{ |
200 |
public: |
public: |
201 |
struct Png_tag {}; |
/** Construct a null image |
202 |
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; |
|
|
|
|
203 |
Image() |
Image() |
204 |
:im(0) |
:im(0) |
205 |
{} |
{} |
206 |
|
/** Construct a blank image, of the given size and colour format type. |
207 |
|
\param[in] sx Width of the image |
208 |
|
\param[in] sy Height of the image |
209 |
|
\param[in] istruecolor Create a true colour image, defaults to false, i.e. create an indexed palette image. |
210 |
|
*/ |
211 |
Image(int sx, int sy, bool istruecolor = false) |
Image(int sx, int sy, bool istruecolor = false) |
212 |
:im(0) |
:im(0) |
213 |
{ |
{ |
216 |
else |
else |
217 |
Create(sx, sy); |
Create(sx, sy); |
218 |
} |
} |
219 |
|
/** Construct a blank image, of the given size and colour format type. |
220 |
|
\param[in] s Width and height of the image |
221 |
|
\param[in] istruecolor Create a true colour image, defaults to false, i.e. create an indexed palette image. |
222 |
|
*/ |
223 |
Image(const Size & s, bool istruecolor = false) |
Image(const Size & s, bool istruecolor = false) |
224 |
:im(0) |
:im(0) |
225 |
{ |
{ |
228 |
else |
else |
229 |
Create(s); |
Create(s); |
230 |
} |
} |
231 |
|
/** Construct an instance of the GD::Image class, given the internal gdImage poimter. |
232 |
|
Note that gdImageDestroy will be called on the image pointer in the destructor. |
233 |
|
\param[in] i Pointer to the internal gdImage |
234 |
|
*/ |
235 |
Image(gdImagePtr i) |
Image(gdImagePtr i) |
236 |
:im(i) {} |
:im(i) {} |
237 |
|
/** Copy constructor. Construct an instance of the GD::Image class, |
238 |
|
by making a copy of the GD::Image provided. |
239 |
|
\param[in] i Reference to the image to be copied |
240 |
|
*/ |
241 |
|
Image(const GD::Image & i) |
242 |
|
:im(0) |
243 |
|
{ |
244 |
|
Copy(i); |
245 |
|
} |
246 |
|
/** Construct an image by reading from \p in. This constructor |
247 |
|
will first attempt to determine the file format. |
248 |
|
\param[in] in The stream containing the image data |
249 |
|
*/ |
250 |
Image(std::istream & in) |
Image(std::istream & in) |
251 |
:im(0) { CreateFrom(in); } |
:im(0) { CreateFrom(in); } |
252 |
|
/** Construct an image by reading from \p in. This constructor |
253 |
|
will first attempt to determine the file format. |
254 |
|
\param[in] in An opened FILE * handle to a file containing the image data |
255 |
|
*/ |
256 |
Image(FILE * in) |
Image(FILE * in) |
257 |
:im(0) { CreateFrom(in); } |
:im(0) { CreateFrom(in); } |
258 |
|
/** Construct an image by reading from memory block \p data. This constructor |
259 |
|
will first attempt to determine the image formatting. |
260 |
|
\param[in] size The byte count of the memory block |
261 |
|
\param[in] data Pointer to the memory block |
262 |
|
*/ |
263 |
|
Image(int size, void * data) |
264 |
|
:im(0) { CreateFrom(size, data); } |
265 |
|
|
266 |
|
/** Construct an image by reading from \p in. |
267 |
|
The tag is an empty struct which simply tells the compiler which image read function to use. |
268 |
|
e.g. GD::Image img(input, GD::Png_tag()); // read a png file from input |
269 |
|
\param[in] in The stream containing the image data |
270 |
|
*/ |
271 |
Image(std::istream & in, Png_tag) |
Image(std::istream & in, Png_tag) |
272 |
:im(0) { CreateFromPng(in); } |
:im(0) { CreateFromPng(in); } |
273 |
|
/** Construct an image by reading from \p in. |
274 |
|
The tag is an empty struct which simply tells the compiler which image read function to use. |
275 |
|
e.g. GD::Image img(input, GD::Png_tag()); // read a png file from input |
276 |
|
\param[in] in An opened FILE * handle to a file containing the image data |
277 |
|
*/ |
278 |
Image(FILE * in, Png_tag) |
Image(FILE * in, Png_tag) |
279 |
:im(0) { CreateFromPng(in); } |
:im(0) { CreateFromPng(in); } |
280 |
|
/** Construct an image by reading from \p in. |
281 |
|
The tag is an empty struct which simply tells the compiler which image read function to use. |
282 |
|
e.g. GD::Image img(input, GD::Png_tag()); // read a png file from input |
283 |
|
\param[in] in The io context from which to read the image data |
284 |
|
*/ |
285 |
Image(gdIOCtx * in, Png_tag) |
Image(gdIOCtx * in, Png_tag) |
286 |
:im(0) { CreateFromPng(in); } |
:im(0) { CreateFromPng(in); } |
287 |
|
/** Construct an image by reading from memory block \p data. |
288 |
|
The tag is an empty struct which simply tells the compiler which image read function to use. |
289 |
|
e.g. GD::Image img(sz, dat, GD::Png_tag()); // read a png file from dat |
290 |
|
\param[in] size The byte count of the memory block |
291 |
|
\param[in] data Pointer to the memory block |
292 |
|
*/ |
293 |
Image(int size, void * data, Png_tag) |
Image(int size, void * data, Png_tag) |
294 |
:im(0) { CreateFromPng(size, data); } |
:im(0) { CreateFromPng(size, data); } |
295 |
|
|
296 |
|
/** Construct an image by reading from \p in. |
297 |
|
The tag is an empty struct which simply tells the compiler which image read function to use. |
298 |
|
e.g. GD::Image img(input, GD::Gif_tag()); // read a gif file from input |
299 |
|
\param[in] in The stream containing the image data |
300 |
|
*/ |
301 |
Image(std::istream & in, Gif_tag) |
Image(std::istream & in, Gif_tag) |
302 |
:im(0) { CreateFromGif(in); } |
:im(0) { CreateFromGif(in); } |
303 |
|
/** Construct an image by reading from \p in. |
304 |
|
The tag is an empty struct which simply tells the compiler which image read function to use. |
305 |
|
e.g. GD::Image img(input, GD::Gif_tag()); // read a gif file from input |
306 |
|
\param[in] in An opened FILE * handle to a file containing the image data |
307 |
|
*/ |
308 |
Image(FILE * in, Gif_tag) |
Image(FILE * in, Gif_tag) |
309 |
:im(0) { CreateFromGif(in); } |
:im(0) { CreateFromGif(in); } |
310 |
|
/** Construct an image by reading from \p in. |
311 |
|
The tag is an empty struct which simply tells the compiler which image read function to use. |
312 |
|
e.g. GD::Image img(input, GD::Gif_tag()); // read a gif file from input |
313 |
|
\param[in] in The io context from which to read the image data |
314 |
|
*/ |
315 |
Image(gdIOCtx * in, Gif_tag) |
Image(gdIOCtx * in, Gif_tag) |
316 |
:im(0) { CreateFromGif(in); } |
:im(0) { CreateFromGif(in); } |
317 |
|
/** Construct an image by reading from memory block \p data. |
318 |
|
The tag is an empty struct which simply tells the compiler which image read function to use. |
319 |
|
e.g. GD::Image img(sz, dat, GD::Gif_tag()); // read a gif file from dat |
320 |
|
\param[in] size The byte count of the memory block |
321 |
|
\param[in] data Pointer to the memory block |
322 |
|
*/ |
323 |
Image(int size, void * data, Gif_tag) |
Image(int size, void * data, Gif_tag) |
324 |
:im(0) { CreateFromGif(size, data); } |
:im(0) { CreateFromGif(size, data); } |
325 |
|
|
326 |
|
/** Construct an image by reading from \p in. |
327 |
|
The tag is an empty struct which simply tells the compiler which image read function to use. |
328 |
|
e.g. GD::Image img(input, GD::WBMP_tag()); // read a monchrome WBMP file from input |
329 |
|
\param[in] in The stream containing the image data |
330 |
|
*/ |
331 |
Image(std::istream & in, WBMP_tag) |
Image(std::istream & in, WBMP_tag) |
332 |
:im(0) { CreateFromWBMP(in); } |
:im(0) { CreateFromWBMP(in); } |
333 |
|
/** Construct an image by reading from \p in. |
334 |
|
The tag is an empty struct which simply tells the compiler which image read function to use. |
335 |
|
e.g. GD::Image img(input, GD::WBMP_tag()); // read a monchrome WBMP file from input |
336 |
|
\param[in] in An opened FILE * handle to a file containing the image data |
337 |
|
*/ |
338 |
Image(FILE * in, WBMP_tag) |
Image(FILE * in, WBMP_tag) |
339 |
:im(0) { CreateFromWBMP(in); } |
:im(0) { CreateFromWBMP(in); } |
340 |
|
/** Construct an image by reading from \p in. |
341 |
|
The tag is an empty struct which simply tells the compiler which image read function to use. |
342 |
|
e.g. GD::Image img(input, GD::WBMP_tag()); // read a monchrome WBMP file from input |
343 |
|
\param[in] in The io context from which to read the image data |
344 |
|
*/ |
345 |
Image(gdIOCtx * in, WBMP_tag) |
Image(gdIOCtx * in, WBMP_tag) |
346 |
:im(0) { CreateFromWBMP(in); } |
:im(0) { CreateFromWBMP(in); } |
347 |
|
/** Construct an image by reading from memory block \p data. |
348 |
|
The tag is an empty struct which simply tells the compiler which image read function to use. |
349 |
|
e.g. GD::Image img(sz, dat, GD::WBMP_tag()); // read a monchrome WBMP file from dat |
350 |
|
\param[in] size The byte count of the memory block |
351 |
|
\param[in] data Pointer to the memory block |
352 |
|
*/ |
353 |
Image(int size, void * data, WBMP_tag) |
Image(int size, void * data, WBMP_tag) |
354 |
:im(0) { CreateFromWBMP(size, data); } |
:im(0) { CreateFromWBMP(size, data); } |
355 |
|
|
356 |
|
/** Construct an image by reading from \p in. |
357 |
|
The tag is an empty struct which simply tells the compiler which image read function to use. |
358 |
|
e.g. GD::Image img(input, GD::Jpeg_tag()); // read a jpeg file from input |
359 |
|
\param[in] in The stream containing the image data |
360 |
|
*/ |
361 |
Image(std::istream & in, Jpeg_tag) |
Image(std::istream & in, Jpeg_tag) |
362 |
:im(0) { CreateFromJpeg(in); } |
:im(0) { CreateFromJpeg(in); } |
363 |
|
/** Construct an image by reading from \p in. |
364 |
|
The tag is an empty struct which simply tells the compiler which image read function to use. |
365 |
|
e.g. GD::Image img(input, GD::Jpeg_tag()); // read a jpeg file from input |
366 |
|
\param[in] in An opened FILE * handle to a file containing the image data |
367 |
|
*/ |
368 |
Image(FILE * in, Jpeg_tag) |
Image(FILE * in, Jpeg_tag) |
369 |
:im(0) { CreateFromJpeg(in); } |
:im(0) { CreateFromJpeg(in); } |
370 |
|
/** Construct an image by reading from \p in. |
371 |
|
The tag is an empty struct which simply tells the compiler which image read function to use. |
372 |
|
e.g. GD::Image img(input, GD::Jpeg_tag()); // read a jpeg file from input |
373 |
|
\param[in] in The io context from which to read the image data |
374 |
|
*/ |
375 |
Image(gdIOCtx * in, Jpeg_tag) |
Image(gdIOCtx * in, Jpeg_tag) |
376 |
:im(0) { CreateFromJpeg(in); } |
:im(0) { CreateFromJpeg(in); } |
377 |
|
/** Construct an image by reading from memory block \p data. |
378 |
|
The tag is an empty struct which simply tells the compiler which image read function to use. |
379 |
|
e.g. GD::Image img(sz, dat, GD::Jpeg_tag()); // read a jpeg file from dat |
380 |
|
\param[in] size The byte count of the memory block |
381 |
|
\param[in] data Pointer to the memory block |
382 |
|
*/ |
383 |
Image(int size, void * data, Jpeg_tag) |
Image(int size, void * data, Jpeg_tag) |
384 |
:im(0) { CreateFromJpeg(size, data); } |
:im(0) { CreateFromJpeg(size, data); } |
385 |
|
|
386 |
|
/** Construct an image by reading from \p in. |
387 |
|
The tag is an empty struct which simply tells the compiler which image read function to use. |
388 |
|
e.g. GD::Image img(input, GD::Gd_tag()); // read a gd file from input |
389 |
|
\param[in] in The stream containing the image data |
390 |
|
*/ |
391 |
Image(std::istream & in, Gd_tag) |
Image(std::istream & in, Gd_tag) |
392 |
:im(0) { CreateFromGd(in); } |
:im(0) { CreateFromGd(in); } |
393 |
|
/** Construct an image by reading from \p in. |
394 |
|
The tag is an empty struct which simply tells the compiler which image read function to use. |
395 |
|
e.g. GD::Image img(input, GD::Gd_tag()); // read a gd file from input |
396 |
|
\param[in] in An opened FILE * handle to a file containing the image data |
397 |
|
*/ |
398 |
Image(FILE * in, Gd_tag) |
Image(FILE * in, Gd_tag) |
399 |
:im(0) { CreateFromGd(in); } |
:im(0) { CreateFromGd(in); } |
400 |
|
/** Construct an image by reading from \p in. |
401 |
|
The tag is an empty struct which simply tells the compiler which image read function to use. |
402 |
|
e.g. GD::Image img(input, GD::Gd_tag()); // read a gd file from input |
403 |
|
\param[in] in The io context from which to read the image data |
404 |
|
*/ |
405 |
Image(gdIOCtx * in, Gd_tag) |
Image(gdIOCtx * in, Gd_tag) |
406 |
:im(0) { CreateFromGd(in); } |
:im(0) { CreateFromGd(in); } |
407 |
|
/** Construct an image by reading from memory block \p data. |
408 |
|
The tag is an empty struct which simply tells the compiler which image read function to use. |
409 |
|
e.g. GD::Image img(sz, dat, GD::Gd_tag()); // read a gd file from dat |
410 |
|
\param[in] size The byte count of the memory block |
411 |
|
\param[in] data Pointer to the memory block |
412 |
|
*/ |
413 |
Image(int size, void * data, Gd_tag) |
Image(int size, void * data, Gd_tag) |
414 |
:im(0) { CreateFromGd(size, data); } |
:im(0) { CreateFromGd(size, data); } |
415 |
|
|
416 |
|
/** Construct an image by reading from \p in. |
417 |
|
The tag is an empty struct which simply tells the compiler which image read function to use. |
418 |
|
e.g. GD::Image img(input, GD::Gd2_tag()); // read a gd2 file from input |
419 |
|
\param[in] in The stream containing the image data |
420 |
|
*/ |
421 |
Image(std::istream & in, Gd2_tag) |
Image(std::istream & in, Gd2_tag) |
422 |
:im(0) { CreateFromGd2(in); } |
:im(0) { CreateFromGd2(in); } |
423 |
|
/** Construct an image by reading from \p in. |
424 |
|
The tag is an empty struct which simply tells the compiler which image read function to use. |
425 |
|
e.g. GD::Image img(input, GD::Png_tag()); // read a png file from input |
426 |
|
\param[in] in An opened FILE * handle to a file containing the image data |
427 |
|
*/ |
428 |
Image(FILE * in, Gd2_tag) |
Image(FILE * in, Gd2_tag) |
429 |
:im(0) { CreateFromGd2(in); } |
:im(0) { CreateFromGd2(in); } |
430 |
|
/** Construct an image by reading from \p in. |
431 |
|
The tag is an empty struct which simply tells the compiler which image read function to use. |
432 |
|
e.g. GD::Image img(input, GD::Gd2_tag()); // read a gd2 file from input |
433 |
|
\param[in] in The io context from which to read the image data |
434 |
|
*/ |
435 |
Image(gdIOCtx * in, Gd2_tag) |
Image(gdIOCtx * in, Gd2_tag) |
436 |
:im(0) { CreateFromGd2(in); } |
:im(0) { CreateFromGd2(in); } |
437 |
|
/** Construct an image by reading from memory block \p data. |
438 |
|
The tag is an empty struct which simply tells the compiler which image read function to use. |
439 |
|
e.g. GD::Image img(sz, dat, GD::Gd2_tag()); // read a gd2 file from dat |
440 |
|
\param[in] size The byte count of the memory block |
441 |
|
\param[in] data Pointer to the memory block |
442 |
|
*/ |
443 |
Image(int size, void * data, Gd2_tag) |
Image(int size, void * data, Gd2_tag) |
444 |
:im(0) { CreateFromGd2(size, data); } |
:im(0) { CreateFromGd2(size, data); } |
445 |
|
|
446 |
|
/** Construct an image by reading from \p in. |
447 |
|
The tag is an empty struct which simply tells the compiler which image read function to use. |
448 |
|
e.g. GD::Image img(input, GD::Xbm_tag()); // read an xbm file from input |
449 |
|
\param[in] in An opened FILE * handle to a file containing the image data |
450 |
|
*/ |
451 |
Image(FILE * in, Xbm_tag) |
Image(FILE * in, Xbm_tag) |
452 |
:im(0) { CreateFromXbm(in); } |
:im(0) { CreateFromXbm(in); } |
453 |
|
|
454 |
~Image() |
~Image() |
455 |
{ clear(); } |
{ clear(); } |
456 |
|
|
457 |
|
/** Assignment Operator. Make this a copy of the GD::Image provided. |
458 |
|
\param[in] src Reference to the image to be copied |
459 |
|
*/ |
460 |
|
GD::Image & operator=(const GD::Image & src) |
461 |
|
{ |
462 |
|
Copy(src); |
463 |
|
return (* this); |
464 |
|
} |
465 |
|
/** Make this an exact copy of the GD::Image provided. Any existing iamge data is discarded. |
466 |
|
\param[in] src Reference to the image to be copied |
467 |
|
*/ |
468 |
|
void Copy(const GD::Image & src) |
469 |
|
{ |
470 |
|
int w = src.Width(), h = src.Height(); |
471 |
|
if (src.IsTrueColor()) |
472 |
|
CreateTrueColor(w, h); |
473 |
|
else |
474 |
|
{ |
475 |
|
Create(w, h); |
476 |
|
PaletteCopy(src); |
477 |
|
} |
478 |
|
Copy(src, 0, 0, 0, 0, w, h); |
479 |
|
} |
480 |
|
/** Check to see if this appears to be a valid image |
481 |
|
*/ |
482 |
bool good() const |
bool good() const |
483 |
{ return (im != 0); } |
{ return (im != 0); } |
484 |
// Creation: |
// Creation: |
485 |
|
/** |
486 |
|
Create a palette-based image, with no more than 256 colors. |
487 |
|
\param sx Width of the desired image |
488 |
|
\param sy Height of the desired image |
489 |
|
\return true if it worked, else false |
490 |
|
*/ |
491 |
bool Create(int sx, int sy) |
bool Create(int sx, int sy) |
492 |
{ |
{ |
493 |
clear(); |
clear(); |
494 |
return ((im = gdImageCreate(sx, sy)) != 0); |
return ((im = gdImageCreate(sx, sy)) != 0); |
495 |
} |
} |
496 |
|
/** |
497 |
|
Create a truecolor image. |
498 |
|
\param sx Width of the desired image |
499 |
|
\param sy Height of the desired image |
500 |
|
\return true if it worked, else false |
501 |
|
*/ |
502 |
bool CreateTrueColor(int sx, int sy) |
bool CreateTrueColor(int sx, int sy) |
503 |
{ |
{ |
504 |
clear(); |
clear(); |
505 |
return ((im = gdImageCreateTrueColor(sx, sy)) != 0); |
return ((im = gdImageCreateTrueColor(sx, sy)) != 0); |
506 |
} |
} |
507 |
|
/** |
508 |
|
Create a palette-based image, with no more than 256 colors. |
509 |
|
\param s Width and height of the desired image |
510 |
|
\return true if it worked, else false |
511 |
|
*/ |
512 |
bool Create(const Size & s) |
bool Create(const Size & s) |
513 |
{ return Create(s.W(), s.H()); } |
{ return Create(s.W(), s.H()); } |
514 |
|
/** |
515 |
|
Create a truecolor image. |
516 |
|
\param s Width and height of the desired image |
517 |
|
\return true if it worked, else false |
518 |
|
*/ |
519 |
bool CreateTrueColor(const Size & s) |
bool CreateTrueColor(const Size & s) |
520 |
{ return CreateTrueColor(s.W(), s.H()); } |
{ return CreateTrueColor(s.W(), s.H()); } |
521 |
// Tagged |
// Create, determining the image format from the data |
522 |
bool CreateFrom(FILE * in, Png_tag) |
/// Read an image from an open FILE * handle, after determining the image format |
|
{ return CreateFromPng(in); } |
|
523 |
bool CreateFrom(FILE * in); |
bool CreateFrom(FILE * in); |
524 |
|
/// Read an image from an open standard library input stream, after determining the image format |
525 |
bool CreateFrom(std::istream & in); |
bool CreateFrom(std::istream & in); |
526 |
|
/// Read an image from a memory block, after determining the image format |
527 |
|
bool CreateFrom(int size, void * data); |
528 |
// Png |
// Png |
529 |
bool CreateFromPng(FILE * in) |
bool CreateFromPng(FILE * in) |
530 |
{ |
{ |
592 |
return ((im = gdImageCreateFromWBMPCtx( & _in_ctx)) != 0); |
return ((im = gdImageCreateFromWBMPCtx( & _in_ctx)) != 0); |
593 |
} |
} |
594 |
// Jpeg |
// Jpeg |
595 |
|
/** |
596 |
|
Load a truecolor image from a JPEG format file. |
597 |
|
Invoke CreateFromJpeg with an already opened |
598 |
|
pointer to a file containing the desired image. |
599 |
|
CreateFromJpeg does not close the file. |
600 |
|
\return true for success, or false if unable to load the image (most often because |
601 |
|
the file is corrupt or does not contain a JPEG image). |
602 |
|
You can call Width() and Height() member functions of the image to determine its |
603 |
|
size. The returned image is always a truecolor image. |
604 |
|
*/ |
605 |
bool CreateFromJpeg(FILE * in) |
bool CreateFromJpeg(FILE * in) |
606 |
{ |
{ |
607 |
clear(); |
clear(); |
608 |
return ((im = gdImageCreateFromJpeg(in)) != 0); |
return ((im = gdImageCreateFromJpeg(in)) != 0); |
609 |
} |
} |
610 |
|
/** |
611 |
|
Load a truecolor image from a JPEG format file. |
612 |
|
Invoke CreateFromJpeg with an already opened |
613 |
|
pointer to a file containing the desired image. |
614 |
|
CreateFromJpeg does not close the file. |
615 |
|
\return true for success, or false if unable to load the image (most often because the file is corrupt or does not contain a JPEG image). |
616 |
|
You can call Width() and Height() member functions of the image to determine its |
617 |
|
size. The returned image is always a truecolor image. |
618 |
|
*/ |
619 |
bool CreateFromJpeg(gdIOCtx * in) |
bool CreateFromJpeg(gdIOCtx * in) |
620 |
{ |
{ |
621 |
clear(); |
clear(); |
622 |
return ((im = gdImageCreateFromJpegCtx(in)) != 0); |
return ((im = gdImageCreateFromJpegCtx(in)) != 0); |
623 |
} |
} |
624 |
|
/** |
625 |
|
Load a truecolor image from a JPEG format file. |
626 |
|
Invoke CreateFromJpeg with an already opened |
627 |
|
pointer to a file containing the desired image. |
628 |
|
CreateFromJpeg does not close the file. |
629 |
|
\return true for success, or false if unable to load the image (most often because the file is corrupt or does not contain a JPEG image). |
630 |
|
You can call Width() and Height() member functions of the image to determine its |
631 |
|
size. The returned image is always a truecolor image. |
632 |
|
*/ |
633 |
bool CreateFromJpeg(int size, void * data) |
bool CreateFromJpeg(int size, void * data) |
634 |
{ |
{ |
635 |
clear(); |
clear(); |
636 |
return ((im = gdImageCreateFromJpegPtr(size, data)) != 0); |
return ((im = gdImageCreateFromJpegPtr(size, data)) != 0); |
637 |
} |
} |
638 |
|
/** |
639 |
|
Load a truecolor image from a JPEG format file. |
640 |
|
Invoke CreateFromJpeg with an image file in memory. |
641 |
|
\return true for success, or false if unable to load the image (most often because the format is corrupt or does not contain a JPEG image). |
642 |
|
You can call Width() and Height() member functions of the image to determine its |
643 |
|
size. The returned image is always a truecolor image. |
644 |
|
*/ |
645 |
bool CreateFromJpeg(std::istream & in) |
bool CreateFromJpeg(std::istream & in) |
646 |
{ |
{ |
647 |
clear(); |
clear(); |
734 |
clear(); |
clear(); |
735 |
return ((im = gdImageCreateFromXpm(filename)) != 0); |
return ((im = gdImageCreateFromXpm(filename)) != 0); |
736 |
} |
} |
737 |
bool CreateFromXpm(const std::string & filename) |
bool CreateFromXpm(std::string & filename) |
738 |
{ return CreateFromXpm(filename.c_str()); } |
{ return CreateFromXpm((char *)(filename.c_str())); } |
739 |
|
|
740 |
// Accessors, Updaters & Methods: |
// Accessors, Updaters & Methods: |
741 |
void SetPixel(int x, int y, int color) |
void SetPixel(int x, int y, int color) |
917 |
|
|
918 |
void PaletteCopy(gdImagePtr src) |
void PaletteCopy(gdImagePtr src) |
919 |
{ gdImagePaletteCopy(im, src); } |
{ gdImagePaletteCopy(im, src); } |
920 |
|
void PaletteCopy(const GD::Image & src) |
921 |
|
{ PaletteCopy(src.im); } |
922 |
|
|
923 |
|
/** |
924 |
|
Write out this image in GIF file format to \p out. |
925 |
|
\param out A FILE * handle |
926 |
|
*/ |
927 |
void Gif(FILE * out) const |
void Gif(FILE * out) const |
928 |
{ gdImageGif(im, out); } |
{ gdImageGif(im, out); } |
929 |
|
/** |
930 |
|
Write out this image in GIF file format to \p out. |
931 |
|
\param out A gdIOCtx * handle |
932 |
|
*/ |
933 |
void Gif(gdIOCtx * out) const |
void Gif(gdIOCtx * out) const |
934 |
{ gdImageGifCtx(im, out); } |
{ gdImageGifCtx(im, out); } |
935 |
|
/** |
936 |
|
Allocate sufficient memory, and write this image, in GIF file format, to that memory. |
937 |
|
\param size A pointer for the allocated memory |
938 |
|
\return A pointer to the allocated memory, containing the image GIF file formatted. Caller is responsible for freeing with gdFree(). |
939 |
|
*/ |
940 |
void * Gif(int * size) const |
void * Gif(int * size) const |
941 |
{ return gdImageGifPtr(im, size); } |
{ return gdImageGifPtr(im, size); } |
942 |
|
/** |
943 |
|
Write out this image in GIF file format to \p out. |
944 |
|
\param out An output stream, already opened. |
945 |
|
*/ |
946 |
void Gif(std::ostream & out) const |
void Gif(std::ostream & out) const |
947 |
{ |
{ |
948 |
ostreamIOCtx _out_ctx(out); |
ostreamIOCtx _out_ctx(out); |
949 |
gdImageGifCtx(im, & _out_ctx); |
gdImageGifCtx(im, & _out_ctx); |
950 |
} |
} |
951 |
|
|
952 |
|
/** |
953 |
|
Write out this image in PNG file format to \p out. |
954 |
|
\param out A FILE * handle |
955 |
|
*/ |
956 |
void Png(FILE * out) const |
void Png(FILE * out) const |
957 |
{ gdImagePng(im, out); } |
{ gdImagePng(im, out); } |
958 |
|
/** |
959 |
|
Write out this image in PNG file format to \p out. |
960 |
|
\param out A gdIOCtx * handle |
961 |
|
*/ |
962 |
void Png(gdIOCtx * out) const |
void Png(gdIOCtx * out) const |
963 |
{ gdImagePngCtx(im, out); } |
{ gdImagePngCtx(im, out); } |
964 |
|
/** |
965 |
|
Allocate sufficient memory, and write this image, in PNG file format, to that memory. |
966 |
|
\param size A pointer for the allocated memory |
967 |
|
\return A pointer to the allocated memory, containing the image PNG file formatted. Caller is responsible for freeing with gdFree(). |
968 |
|
*/ |
969 |
void * Png(int * size) const |
void * Png(int * size) const |
970 |
{ return gdImagePngPtr(im, size); } |
{ return gdImagePngPtr(im, size); } |
971 |
|
/** |
972 |
|
Write out this image in PNG file format to \p out. |
973 |
|
\param out An output stream, already opened. |
974 |
|
*/ |
975 |
void Png(std::ostream & out) const |
void Png(std::ostream & out) const |
976 |
{ |
{ |
977 |
ostreamIOCtx _out_ctx(out); |
ostreamIOCtx _out_ctx(out); |
978 |
gdImagePngCtx(im, & _out_ctx); |
gdImagePngCtx(im, & _out_ctx); |
979 |
} |
} |
980 |
|
/** |
981 |
|
Write out this image in PNG file format to \p out. |
982 |
|
\param out A FILE * handle |
983 |
|
\param level The level of compression: 0 == "no compression", 1 == "compressed as quickly as possible" --> 9 == "compressed as much as possible", -1 == zlib default compression level |
984 |
|
*/ |
985 |
void Png(FILE * out, int level) const |
void Png(FILE * out, int level) const |
986 |
{ gdImagePngEx(im, out, level); } |
{ gdImagePngEx(im, out, level); } |
987 |
|
/** |
988 |
|
Write out this image in PNG file format to \p out. |
989 |
|
\param out A gdIOCtx * handle |
990 |
|
\param level The level of compression: 0 == "no compression", 1 == "compressed as quickly as possible" --> 9 == "compressed as much as possible", -1 == zlib default compression level |
991 |
|
*/ |
992 |
void Png(gdIOCtx * out, int level) const |
void Png(gdIOCtx * out, int level) const |
993 |
{ gdImagePngCtxEx(im, out, level); } |
{ gdImagePngCtxEx(im, out, level); } |
994 |
|
/** |
995 |
|
Allocate sufficient memory, and write this image, in PNG file format, to that memory. |
996 |
|
\param size A pointer for the allocated memory |
997 |
|
\param level The level of compression: 0 == "no compression", 1 == "compressed as quickly as possible" --> 9 == "compressed as much as possible", -1 == zlib default compression level |
998 |
|
\return A pointer to the allocated memory, containing the image PNG file formatted. Caller is responsible for freeing with gdFree(). |
999 |
|
*/ |
1000 |
void * Png(int * size, int level) const |
void * Png(int * size, int level) const |
1001 |
{ return gdImagePngPtrEx(im, size, level); } |
{ return gdImagePngPtrEx(im, size, level); } |
1002 |
|
/** |
1003 |
|
Write out this image in PNG file format to \p out. |
1004 |
|
\param out An output stream, already opened. |
1005 |
|
\param level The level of compression: 0 == "no compression", 1 == "compressed as quickly as possible" --> 9 == "compressed as much as possible", -1 == zlib default compression level |
1006 |
|
*/ |
1007 |
void Png(std::ostream & out, int level) const |
void Png(std::ostream & out, int level) const |
1008 |
{ |
{ |
1009 |
ostreamIOCtx _out_ctx(out); |
ostreamIOCtx _out_ctx(out); |
1010 |
gdImagePngCtxEx(im, & _out_ctx, level); |
gdImagePngCtxEx(im, & _out_ctx, level); |
1011 |
} |
} |
1012 |
|
|
1013 |
|
/** |
1014 |
|
Write out this image in WBMP file format ( black and white only ) to \p out. |
1015 |
|
\param fg The color index of the foreground. All other pixels considered background. |
1016 |
|
\param out A FILE * handle |
1017 |
|
*/ |
1018 |
void WBMP(int fg, FILE * out) const |
void WBMP(int fg, FILE * out) const |
1019 |
{ gdImageWBMP(im, fg, out); } |
{ gdImageWBMP(im, fg, out); } |
1020 |
|
/** |
1021 |
|
Write out this image in WBMP file format ( black and white only ) to \p out. |
1022 |
|
\param fg The color index of the foreground. All other pixels considered background. |
1023 |
|
\param out A gdIOCtx * handle |
1024 |
|
*/ |
1025 |
void WBMP(int fg, gdIOCtx * out) const |
void WBMP(int fg, gdIOCtx * out) const |
1026 |
{ gdImageWBMPCtx(im, fg, out); } |
{ gdImageWBMPCtx(im, fg, out); } |
1027 |
|
/** |
1028 |
|
Allocate sufficient memory, and write this image, in WBMP file format ( black and white only ), to that memory. |
1029 |
|
\param size A pointer for the allocated memory |
1030 |
|
\param fg The color index of the foreground. All other pixels considered background. |
1031 |
|
\return A pointer to the allocated memory, containing the image WBMP file formatted. Caller is responsible for freeing with gdFree(). |
1032 |
|
*/ |
1033 |
void * WBMP(int * size, int fg) const |
void * WBMP(int * size, int fg) const |
1034 |
{ return gdImageWBMPPtr(im, size, fg); } |
{ return gdImageWBMPPtr(im, size, fg); } |
1035 |
|
/** |
1036 |
|
Write out this image in WBMP file format ( black and white only ) to \p out. |
1037 |
|
\param fg The color index of the foreground. All other pixels considered background. |
1038 |
|
\param out An output stream, already opened. |
1039 |
|
*/ |
1040 |
void WBMP(int fg, std::ostream & out) const |
void WBMP(int fg, std::ostream & out) const |
1041 |
{ |
{ |
1042 |
ostreamIOCtx _out_ctx(out); |
ostreamIOCtx _out_ctx(out); |
1043 |
gdImageWBMPCtx(im, fg, & _out_ctx); |
gdImageWBMPCtx(im, fg, & _out_ctx); |
1044 |
} |
} |
1045 |
|
|
1046 |
|
/** |
1047 |
|
Write out this image in JPEG file format to \p out. |
1048 |
|
\param out A FILE * handle |
1049 |
|
\param quality Should be a value in the range 0-95, higher numbers imply both higher quality and larger image size. Default value is -1, indicating "use a sensible default value". |
1050 |
|
*/ |
1051 |
void Jpeg(FILE * out, int quality = -1) const |
void Jpeg(FILE * out, int quality = -1) const |
1052 |
{ gdImageJpeg(im, out, quality); } |
{ gdImageJpeg(im, out, quality); } |
1053 |
|
/** |
1054 |
|
Write out this image in JPEG file format to \p out. |
1055 |
|
\param out A gdIOCtx * handle |
1056 |
|
\param quality Should be a value in the range 0-95, higher numbers imply both higher quality and larger image size. Default value is -1, indicating "use a sensible default value". |
1057 |
|
*/ |
1058 |
void Jpeg(gdIOCtx * out, int quality = -1) const |
void Jpeg(gdIOCtx * out, int quality = -1) const |
1059 |
{ gdImageJpegCtx(im, out, quality); } |
{ gdImageJpegCtx(im, out, quality); } |
1060 |
|
/** |
1061 |
|
Allocate sufficient memory, and write this image, in JPEG file format, to that memory. |
1062 |
|
\param size A pointer for the allocated memory |
1063 |
|
\param quality Should be a value in the range 0-95, higher numbers imply both higher quality and larger image size. Default value is -1, indicating "use a sensible default value". |
1064 |
|
\return A pointer to the allocated memory, containing the image JPEG file formatted. Caller is responsible for freeing with gdFree(). |
1065 |
|
*/ |
1066 |
void * Jpeg(int * size, int quality = -1) const |
void * Jpeg(int * size, int quality = -1) const |
1067 |
{ return gdImageJpegPtr(im, size, quality); } |
{ return gdImageJpegPtr(im, size, quality); } |
1068 |
|
/** |
1069 |
|
Write out this image in JPEG file format to \p out. |
1070 |
|
\param out An output stream, already opened. |
1071 |
|
\param quality Should be a value in the range 0-95, higher numbers imply both higher quality and larger image size. Default value is -1, indicating "use a sensible default value". |
1072 |
|
*/ |
1073 |
void Jpeg(std::ostream & out, int quality = -1) const |
void Jpeg(std::ostream & out, int quality = -1) const |
1074 |
{ |
{ |
1075 |
ostreamIOCtx _out_ctx(out); |
ostreamIOCtx _out_ctx(out); |
1080 |
{ gdImageGifAnimBegin(im, out, GlobalCM, Loops); } |
{ gdImageGifAnimBegin(im, out, GlobalCM, Loops); } |
1081 |
void GifAnimAdd(FILE * out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm) const |
void GifAnimAdd(FILE * out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm) const |
1082 |
{ gdImageGifAnimAdd(im, out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm); } |
{ gdImageGifAnimAdd(im, out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm); } |
1083 |
|
void GifAnimAdd(FILE * out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, const GD::Image & previm) const |
1084 |
|
{ GifAnimAdd(out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm.im); } |
1085 |
inline static void GifAnimEnd(FILE * out) |
inline static void GifAnimEnd(FILE * out) |
1086 |
{ gdImageGifAnimEnd(out); } |
{ gdImageGifAnimEnd(out); } |
1087 |
void GifAnimBegin(gdIOCtx * out, int GlobalCM, int Loops) const |
void GifAnimBegin(gdIOCtx * out, int GlobalCM, int Loops) const |
1088 |
{ gdImageGifAnimBeginCtx(im, out, GlobalCM, Loops); } |
{ gdImageGifAnimBeginCtx(im, out, GlobalCM, Loops); } |
1089 |
void GifAnimAdd(gdIOCtx * out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm) const |
void GifAnimAdd(gdIOCtx * out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm) const |
1090 |
{ gdImageGifAnimAddCtx(im, out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm); } |
{ gdImageGifAnimAddCtx(im, out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm); } |
1091 |
|
void GifAnimAdd(gdIOCtx * out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, const GD::Image & previm) const |
1092 |
|
{ GifAnimAdd(out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm.im); } |
1093 |
inline static void GifAnimEnd(gdIOCtx * out) |
inline static void GifAnimEnd(gdIOCtx * out) |
1094 |
{ gdImageGifAnimEndCtx(out); } |
{ gdImageGifAnimEndCtx(out); } |
1095 |
void * GifAnimBegin(int * size, int GlobalCM, int Loops) const |
void * GifAnimBegin(int * size, int GlobalCM, int Loops) const |
1096 |
{ return gdImageGifAnimBeginPtr(im, size, GlobalCM, Loops); } |
{ return gdImageGifAnimBeginPtr(im, size, GlobalCM, Loops); } |
1097 |
void * GifAnimAdd(int * size, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm) const |
void * GifAnimAdd(int * size, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm) const |
1098 |
{ return gdImageGifAnimAddPtr(im, size, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm); } |
{ return gdImageGifAnimAddPtr(im, size, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm); } |
1099 |
|
void * GifAnimAdd(int * size, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, const GD::Image & previm) const |
1100 |
|
{ return GifAnimAdd(size, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm.im); } |
1101 |
inline static void * GifAnimEnd(int * size) |
inline static void * GifAnimEnd(int * size) |
1102 |
{ return gdImageGifAnimEndPtr(size); } |
{ return gdImageGifAnimEndPtr(size); } |
1103 |
|
|
1112 |
|
|
1113 |
void Ellipse(int cx, int cy, int w, int h, int color) |
void Ellipse(int cx, int cy, int w, int h, int color) |
1114 |
{ gdImageEllipse(im, cx, cy, w, h, color); } |
{ gdImageEllipse(im, cx, cy, w, h, color); } |
1115 |
|
/** |
1116 |
|
Draw a partial ellipse centered at the given point, with the specified width and height in pixels. |
1117 |
|
*/ |
1118 |
void FilledArc(int cx, int cy, int w, int h, int s, int e, int color, int style) |
void FilledArc(int cx, int cy, int w, int h, int s, int e, int color, int style) |
1119 |
{ gdImageFilledArc(im, cx, cy, w, h, s, e, color, style); } |
{ gdImageFilledArc(im, cx, cy, w, h, s, e, color, style); } |
1120 |
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) |
1148 |
|
|
1149 |
void CopyResized(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH) |
void CopyResized(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH) |
1150 |
{ gdImageCopyResized(im, src, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH); } |
{ gdImageCopyResized(im, src, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH); } |
1151 |
void CopyResampled(const Image& src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH) |
void CopyResampled(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH) |
1152 |
{ gdImageCopyResampled(im, src.im, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH); } |
{ gdImageCopyResampled(im, src, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH); } |
1153 |
void CopyRotated(const gdImagePtr src, double dstX, double dstY, int srcX, int srcY, int srcWidth, int srcHeight, int angle) |
void CopyRotated(const gdImagePtr src, double dstX, double dstY, int srcX, int srcY, int srcWidth, int srcHeight, int angle) |
1154 |
{ gdImageCopyRotated(im, src, dstX, dstY, srcX, srcY, srcWidth, srcHeight, angle); } |
{ gdImageCopyRotated(im, src, dstX, dstY, srcX, srcY, srcWidth, srcHeight, angle); } |
1155 |
|
|
1162 |
|
|
1163 |
void CopyResized(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & dstS, const Size & srcS) |
void CopyResized(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & dstS, const Size & srcS) |
1164 |
{ CopyResized(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), dstS.W(), dstS.H(), srcS.W(), srcS.H()); } |
{ CopyResized(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), dstS.W(), dstS.H(), srcS.W(), srcS.H()); } |
1165 |
void CopyResampled(const Image& src, const Point & dstP, const Point & srcP, const Size & dstS, const Size & srcS) |
void CopyResampled(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & dstS, const Size & srcS) |
1166 |
{ CopyResampled(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), dstS.W(), dstS.H(), srcS.W(), srcS.H()); } |
{ CopyResampled(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), dstS.W(), dstS.H(), srcS.W(), srcS.H()); } |
1167 |
void CopyRotated(const gdImagePtr src, double dstX, double dstY, const Point & srcP, const Size & srcS, int angle) |
void CopyRotated(const gdImagePtr src, double dstX, double dstY, const Point & srcP, const Size & srcS, int angle) |
1168 |
{ CopyRotated(src, dstX, dstY, srcP.X(), srcP.Y(), srcS.W(), srcS.H(), angle); } |
{ CopyRotated(src, dstX, dstY, srcP.X(), srcP.Y(), srcS.W(), srcS.H(), angle); } |
1169 |
|
|
1170 |
|
void Copy(const GD::Image & src, int dstX, int dstY, int srcX, int srcY, int w, int h) |
1171 |
|
{ Copy(src.im, dstX, dstY, srcX, srcY, w, h); } |
1172 |
|
void CopyMerge(const GD::Image & src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct) |
1173 |
|
{ CopyMerge(src.im, dstX, dstY, srcX, srcY, w, h, pct); } |
1174 |
|
void CopyMergeGray(const GD::Image & src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct) |
1175 |
|
{ CopyMergeGray(src.im, dstX, dstY, srcX, srcY, w, h, pct); } |
1176 |
|
|
1177 |
|
void CopyResized(const GD::Image & src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH) |
1178 |
|
{ CopyResized(src.im, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH); } |
1179 |
|
void CopyResampled(const GD::Image & src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH) |
1180 |
|
{ CopyResampled(src.im, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH); } |
1181 |
|
void CopyRotated(const GD::Image & src, double dstX, double dstY, int srcX, int srcY, int srcWidth, int srcHeight, int angle) |
1182 |
|
{ CopyRotated(src.im, dstX, dstY, srcX, srcY, srcWidth, srcHeight, angle); } |
1183 |
|
|
1184 |
|
void Copy(const GD::Image & src, const Point & dstP, const Point & srcP, const Size & s) |
1185 |
|
{ Copy(src.im, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H()); } |
1186 |
|
void CopyMerge(const GD::Image & src, const Point & dstP, const Point & srcP, const Size & s, int pct) |
1187 |
|
{ CopyMerge(src.im, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H(), pct); } |
1188 |
|
void CopyMergeGray(const GD::Image & src, const Point & dstP, const Point & srcP, const Size & s, int pct) |
1189 |
|
{ CopyMergeGray(src.im, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H(), pct); } |
1190 |
|
|
1191 |
|
void CopyResized(const GD::Image & src, const Point & dstP, const Point & srcP, const Size & dstS, const Size & srcS) |
1192 |
|
{ CopyResized(src.im, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), dstS.W(), dstS.H(), srcS.W(), srcS.H()); } |
1193 |
|
void CopyResampled(const GD::Image & src, const Point & dstP, const Point & srcP, const Size & dstS, const Size & srcS) |
1194 |
|
{ CopyResampled(src.im, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), dstS.W(), dstS.H(), srcS.W(), srcS.H()); } |
1195 |
|
void CopyRotated(const GD::Image & src, double dstX, double dstY, const Point & srcP, const Size & srcS, int angle) |
1196 |
|
{ CopyRotated(src.im, dstX, dstY, srcP.X(), srcP.Y(), srcS.W(), srcS.H(), angle); } |
1197 |
|
|
1198 |
void SetBrush(gdImagePtr brush) |
void SetBrush(gdImagePtr brush) |
1199 |
{ gdImageSetBrush(im, brush); } |
{ gdImageSetBrush(im, brush); } |
1200 |
|
void SetBrush(const GD::Image & brush) |
1201 |
|
{ SetBrush(brush.im); } |
1202 |
void SetTile(gdImagePtr tile) |
void SetTile(gdImagePtr tile) |
1203 |
{ gdImageSetTile(im, tile); } |
{ gdImageSetTile(im, tile); } |
1204 |
|
void SetTile(const GD::Image & tile) |
1205 |
|
{ SetTile(tile.im); } |
1206 |
void SetAntiAliased(int c) |
void SetAntiAliased(int c) |
1207 |
{ gdImageSetAntiAliased(im, c); } |
{ gdImageSetAntiAliased(im, c); } |
1208 |
void SetAntiAliasedDontBlend(int c, int dont_blend) |
void SetAntiAliasedDontBlend(int c, int dont_blend) |
1250 |
int TrueColorPixel(int x, int y) const |
int TrueColorPixel(int x, int y) const |
1251 |
{ return gdImageTrueColorPixel(im, x, y); } |
{ return gdImageTrueColorPixel(im, x, y); } |
1252 |
|
|
1253 |
|
const gdImagePtr GetPtr() const |
1254 |
|
{ return im; } |
1255 |
|
|
1256 |
protected: |
protected: |
1257 |
|
/// Free the internal image pointer |
1258 |
void clear() |
void clear() |
1259 |
{ |
{ |
1260 |
if (im) |
if (im) |
1264 |
gdImagePtr im; |
gdImagePtr im; |
1265 |
}; |
}; |
1266 |
} // namespace GD |
} // namespace GD |
1267 |
|
/// Read in an image from a standard library input stream |
1268 |
std::istream & operator>> (std::istream & in, GD::Image & img); |
std::istream & operator>> (std::istream & in, GD::Image & img); |
1269 |
|
|
1270 |
|
#endif /* _gdpp_h */ |
1271 |
#endif /* __cplusplus */ |
#endif /* __cplusplus */ |
|
#endif /* GDPP_H */ |
|