|
Packit |
ed3af9 |
/* *****************************************************************************
|
|
Packit |
ed3af9 |
** $Id$
|
|
Packit |
ed3af9 |
** Initial file written and documented by:
|
|
Packit |
ed3af9 |
** Kevin Shepherd <kshepherd@php.net> December 2007
|
|
Packit |
ed3af9 |
** of Scarlet Line http://www.scarletline.com/
|
|
Packit |
ed3af9 |
** with contributions from Torben Nielsen.
|
|
Packit |
ed3af9 |
*******************************************************************************/
|
|
Packit |
ed3af9 |
/** \file gdpp.h
|
|
Packit |
ed3af9 |
\brief Object Oriented C++ wrappers around libgd functionality.
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
Example usage, convert png to gif:
|
|
Packit |
ed3af9 |
#include <fstream>
|
|
Packit |
ed3af9 |
#include <gdpp.h>
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
std::ifstream in("image.png", std::ios_base::in | std::ios_base::binary );
|
|
Packit |
ed3af9 |
GD::Image im(in, GD::Png_tag());
|
|
Packit |
ed3af9 |
if (im.good())
|
|
Packit |
ed3af9 |
{
|
|
Packit |
ed3af9 |
std::ofstream out("image.gif", std::ios_base::out | std::ios_base::binary );
|
|
Packit |
ed3af9 |
im.Gif(out);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
#ifdef __cplusplus
|
|
Packit |
ed3af9 |
#ifndef _gdpp_h
|
|
Packit |
ed3af9 |
#define _gdpp_h
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
ed3af9 |
#include "config.h"
|
|
Packit |
ed3af9 |
#endif
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
#include "gd_io_stream.h"
|
|
Packit |
ed3af9 |
#include <string>
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
/// namespace GD:: contains the C++ wrapper classes for libgd
|
|
Packit |
ed3af9 |
/** This namespace is primarily to avoid name clashes, and to
|
|
Packit |
ed3af9 |
contain all of the gd classes within one namespace.
|
|
Packit |
ed3af9 |
It is not recommended to use the "using namespace" directive with this namespace.
|
|
Packit |
ed3af9 |
Example usage:
|
|
Packit |
ed3af9 |
GD::Image im(64, 32, true); // Create a truecolor image 64 pixels wide by 32 pixels high
|
|
Packit |
ed3af9 |
GD::Point pt(10, 8); // The point at x=10, y=8.
|
|
Packit |
ed3af9 |
GD::Size sz(16, 8); // The size width=16, height=8.
|
|
Packit |
ed3af9 |
GD::TrueColor col(0xFF, 0, 0); // The colour red; R=255, G=0, B=0.
|
|
Packit |
ed3af9 |
im.Rectangle(pt, sz, col.Int()); // Draw a red rectangle with top left corner at pt, of size sz.
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
namespace GD
|
|
Packit |
ed3af9 |
{
|
|
Packit |
ed3af9 |
/** This class GD::Point stores a point in two dimensions, somewhere
|
|
Packit |
ed3af9 |
on the plane of an image.
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
class BGD_EXPORT_DATA_PROT Point
|
|
Packit |
ed3af9 |
{
|
|
Packit |
ed3af9 |
public:
|
|
Packit |
ed3af9 |
// Constructors
|
|
Packit |
ed3af9 |
Point(int x, int y)
|
|
Packit |
ed3af9 |
:_x(x), _y(y) {}
|
|
Packit |
ed3af9 |
Point(const Point & p)
|
|
Packit |
ed3af9 |
:_x(p._x), _y(p._y) {}
|
|
Packit |
ed3af9 |
Point()
|
|
Packit |
ed3af9 |
:_x(0), _y(0) {}
|
|
Packit |
ed3af9 |
Point & operator=(const Point & p) {
|
|
Packit |
ed3af9 |
_x = p._x;
|
|
Packit |
ed3af9 |
_y = p._y;
|
|
Packit |
ed3af9 |
return (* this);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
// Accessors
|
|
Packit |
ed3af9 |
int X() const {
|
|
Packit |
ed3af9 |
return _x;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int Y() const {
|
|
Packit |
ed3af9 |
return _y;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
// Updaters
|
|
Packit |
ed3af9 |
void X(int x) {
|
|
Packit |
ed3af9 |
_x = x;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void Y(int y) {
|
|
Packit |
ed3af9 |
_y = y;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void set(int x, int y) {
|
|
Packit |
ed3af9 |
_x = x;
|
|
Packit |
ed3af9 |
_y = y;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int & lhsX() {
|
|
Packit |
ed3af9 |
return _x;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int & lhsY() {
|
|
Packit |
ed3af9 |
return _y;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
gdPointPtr as_gdPointPtr() {
|
|
Packit |
ed3af9 |
return (gdPointPtr) this;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
protected:
|
|
Packit |
ed3af9 |
int _x, _y;
|
|
Packit |
ed3af9 |
};
|
|
Packit |
ed3af9 |
typedef Point * PointPtr;
|
|
Packit |
ed3af9 |
/** This class GD::Size stores length in two dimensions.
|
|
Packit |
ed3af9 |
Giving the size of an area as width and height.
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
class BGD_EXPORT_DATA_PROT Size
|
|
Packit |
ed3af9 |
{
|
|
Packit |
ed3af9 |
public:
|
|
Packit |
ed3af9 |
// Constructors
|
|
Packit |
ed3af9 |
Size(int w, int h)
|
|
Packit |
ed3af9 |
:_w(w), _h(h) {}
|
|
Packit |
ed3af9 |
Size(const Size & p)
|
|
Packit |
ed3af9 |
:_w(p._w), _h(p._h) {}
|
|
Packit |
ed3af9 |
Size()
|
|
Packit |
ed3af9 |
:_w(0), _h(0) {}
|
|
Packit |
ed3af9 |
Size & operator=(const Size & p) {
|
|
Packit |
ed3af9 |
_w = p._w;
|
|
Packit |
ed3af9 |
_h = p._h;
|
|
Packit |
ed3af9 |
return (* this);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
// Accessors
|
|
Packit |
ed3af9 |
int W() const {
|
|
Packit |
ed3af9 |
return _w;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int H() const {
|
|
Packit |
ed3af9 |
return _h;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
// Updaters
|
|
Packit |
ed3af9 |
void W(int w) {
|
|
Packit |
ed3af9 |
_w = w;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void H(int h) {
|
|
Packit |
ed3af9 |
_h = h;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void set(int w, int h) {
|
|
Packit |
ed3af9 |
_w = w;
|
|
Packit |
ed3af9 |
_h = h;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int & lhsW() {
|
|
Packit |
ed3af9 |
return _w;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int & lhsH() {
|
|
Packit |
ed3af9 |
return _h;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
protected:
|
|
Packit |
ed3af9 |
int _w, _h;
|
|
Packit |
ed3af9 |
};
|
|
Packit |
ed3af9 |
typedef Size * SizePtr;
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
/** This class GD::TrueColor stores a colour as an RGBA quadruplet.
|
|
Packit |
ed3af9 |
It can also be read as an integer, and in other colour formats.
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
class BGD_EXPORT_DATA_PROT TrueColor
|
|
Packit |
ed3af9 |
{
|
|
Packit |
ed3af9 |
public:
|
|
Packit |
ed3af9 |
union as_types {
|
|
Packit |
ed3af9 |
int as_int;
|
|
Packit |
ed3af9 |
struct uchars {
|
|
Packit |
ed3af9 |
unsigned char blue, green, red, alpha;
|
|
Packit |
ed3af9 |
} as_uchar;
|
|
Packit |
ed3af9 |
};
|
|
Packit |
ed3af9 |
TrueColor() {
|
|
Packit |
ed3af9 |
internal.as_int = 0;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
TrueColor(int c) {
|
|
Packit |
ed3af9 |
internal.as_int = c;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
TrueColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 0) {
|
|
Packit |
ed3af9 |
internal.as_uchar.alpha = a;
|
|
Packit |
ed3af9 |
internal.as_uchar.red = r;
|
|
Packit |
ed3af9 |
internal.as_uchar.green = g;
|
|
Packit |
ed3af9 |
internal.as_uchar.blue = b;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
// Accessors
|
|
Packit |
ed3af9 |
int Int() const {
|
|
Packit |
ed3af9 |
return internal.as_int;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
unsigned char Red() const {
|
|
Packit |
ed3af9 |
return internal.as_uchar.red;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
unsigned char Green() const {
|
|
Packit |
ed3af9 |
return internal.as_uchar.green;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
unsigned char Blue() const {
|
|
Packit |
ed3af9 |
return internal.as_uchar.blue;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
unsigned char Alpha() const {
|
|
Packit |
ed3af9 |
return internal.as_uchar.alpha;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
// Updaters
|
|
Packit |
ed3af9 |
void set(int c) {
|
|
Packit |
ed3af9 |
internal.as_int = c;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void set(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 0) {
|
|
Packit |
ed3af9 |
internal.as_uchar.alpha = a;
|
|
Packit |
ed3af9 |
internal.as_uchar.red = r;
|
|
Packit |
ed3af9 |
internal.as_uchar.green = g;
|
|
Packit |
ed3af9 |
internal.as_uchar.blue = b;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void Red(unsigned char c) {
|
|
Packit |
ed3af9 |
internal.as_uchar.red = c;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void Green(unsigned char c) {
|
|
Packit |
ed3af9 |
internal.as_uchar.green = c;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void Blue(unsigned char c) {
|
|
Packit |
ed3af9 |
internal.as_uchar.blue = c;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void Alpha(unsigned char c) {
|
|
Packit |
ed3af9 |
internal.as_uchar.alpha = c;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
protected:
|
|
Packit |
ed3af9 |
as_types internal;
|
|
Packit |
ed3af9 |
};
|
|
Packit |
ed3af9 |
/* The following tags are simply empty structures which are used
|
|
Packit |
ed3af9 |
to tell the compiler which constructor we want when we know
|
|
Packit |
ed3af9 |
the image file format.
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
struct BGD_EXPORT_DATA_PROT Png_tag {};
|
|
Packit |
ed3af9 |
struct BGD_EXPORT_DATA_PROT Gif_tag {};
|
|
Packit |
ed3af9 |
struct BGD_EXPORT_DATA_PROT WBMP_tag {};
|
|
Packit |
ed3af9 |
struct BGD_EXPORT_DATA_PROT Jpeg_tag {};
|
|
Packit |
ed3af9 |
struct BGD_EXPORT_DATA_PROT Gd_tag {};
|
|
Packit |
ed3af9 |
struct BGD_EXPORT_DATA_PROT Gd2_tag {};
|
|
Packit |
ed3af9 |
struct BGD_EXPORT_DATA_PROT Xbm_tag {};
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
/** This class GD::Image wraps all of the 'C' libgd functionality
|
|
Packit |
ed3af9 |
for the convenience of C++ users. An instance of this class
|
|
Packit |
ed3af9 |
corresponds to a single image.
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
class BGD_EXPORT_DATA_PROT Image
|
|
Packit |
ed3af9 |
{
|
|
Packit |
ed3af9 |
public:
|
|
Packit |
ed3af9 |
/** Construct a null image
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image()
|
|
Packit |
ed3af9 |
:im(0)
|
|
Packit |
ed3af9 |
{}
|
|
Packit |
ed3af9 |
/** Construct a blank image, of the given size and colour format type.
|
|
Packit |
ed3af9 |
\param[in] sx Width of the image
|
|
Packit |
ed3af9 |
\param[in] sy Height of the image
|
|
Packit |
ed3af9 |
\param[in] istruecolor Create a true colour image, defaults to false, i.e. create an indexed palette image.
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(int sx, int sy, bool istruecolor = false)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
if (istruecolor)
|
|
Packit |
ed3af9 |
CreateTrueColor(sx, sy);
|
|
Packit |
ed3af9 |
else
|
|
Packit |
ed3af9 |
Create(sx, sy);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/** Construct a blank image, of the given size and colour format type.
|
|
Packit |
ed3af9 |
\param[in] s Width and height of the image
|
|
Packit |
ed3af9 |
\param[in] istruecolor Create a true colour image, defaults to false, i.e. create an indexed palette image.
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(const Size & s, bool istruecolor = false)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
if (istruecolor)
|
|
Packit |
ed3af9 |
CreateTrueColor(s);
|
|
Packit |
ed3af9 |
else
|
|
Packit |
ed3af9 |
Create(s);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/** Construct an instance of the GD::Image class, given the internal gdImage poimter.
|
|
Packit |
ed3af9 |
Note that gdImageDestroy will be called on the image pointer in the destructor.
|
|
Packit |
ed3af9 |
\param[in] i Pointer to the internal gdImage
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(gdImagePtr i)
|
|
Packit |
ed3af9 |
:im(i) {}
|
|
Packit |
ed3af9 |
/** Copy constructor. Construct an instance of the GD::Image class,
|
|
Packit |
ed3af9 |
by making a copy of the GD::Image provided.
|
|
Packit |
ed3af9 |
\param[in] i Reference to the image to be copied
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(const GD::Image & i)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
Copy(i);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/** Construct an image by reading from \p in. This constructor
|
|
Packit |
ed3af9 |
will first attempt to determine the file format.
|
|
Packit |
ed3af9 |
\param[in] in The stream containing the image data
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(std::istream & in)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFrom(in);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/** Construct an image by reading from \p in. This constructor
|
|
Packit |
ed3af9 |
will first attempt to determine the file format.
|
|
Packit |
ed3af9 |
\param[in] in An opened FILE * handle to a file containing the image data
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(FILE * in)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFrom(in);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/** Construct an image by reading from memory block \p data. This constructor
|
|
Packit |
ed3af9 |
will first attempt to determine the image formatting.
|
|
Packit |
ed3af9 |
\param[in] size The byte count of the memory block
|
|
Packit |
ed3af9 |
\param[in] data Pointer to the memory block
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(int size, void * data)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFrom(size, data);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
#ifdef HAVE_LIBPNG
|
|
Packit |
ed3af9 |
/** Construct an image by reading from \p in.
|
|
Packit |
ed3af9 |
The tag is an empty struct which simply tells the compiler which image read function to use.
|
|
Packit |
ed3af9 |
e.g. GD::Image img(input, GD::Png_tag()); // read a png file from input
|
|
Packit |
ed3af9 |
\param[in] in The stream containing the image data
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(std::istream & in, Png_tag)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFromPng(in);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/** Construct an image by reading from \p in.
|
|
Packit |
ed3af9 |
The tag is an empty struct which simply tells the compiler which image read function to use.
|
|
Packit |
ed3af9 |
e.g. GD::Image img(input, GD::Png_tag()); // read a png file from input
|
|
Packit |
ed3af9 |
\param[in] in An opened FILE * handle to a file containing the image data
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(FILE * in, Png_tag)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFromPng(in);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/** Construct an image by reading from \p in.
|
|
Packit |
ed3af9 |
The tag is an empty struct which simply tells the compiler which image read function to use.
|
|
Packit |
ed3af9 |
e.g. GD::Image img(input, GD::Png_tag()); // read a png file from input
|
|
Packit |
ed3af9 |
\param[in] in The io context from which to read the image data
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(gdIOCtx * in, Png_tag)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFromPng(in);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/** Construct an image by reading from memory block \p data.
|
|
Packit |
ed3af9 |
The tag is an empty struct which simply tells the compiler which image read function to use.
|
|
Packit |
ed3af9 |
e.g. GD::Image img(sz, dat, GD::Png_tag()); // read a png file from dat
|
|
Packit |
ed3af9 |
\param[in] size The byte count of the memory block
|
|
Packit |
ed3af9 |
\param[in] data Pointer to the memory block
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(int size, void * data, Png_tag)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFromPng(size, data);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
#endif
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
/** Construct an image by reading from \p in.
|
|
Packit |
ed3af9 |
The tag is an empty struct which simply tells the compiler which image read function to use.
|
|
Packit |
ed3af9 |
e.g. GD::Image img(input, GD::Gif_tag()); // read a gif file from input
|
|
Packit |
ed3af9 |
\param[in] in The stream containing the image data
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(std::istream & in, Gif_tag)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFromGif(in);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/** Construct an image by reading from \p in.
|
|
Packit |
ed3af9 |
The tag is an empty struct which simply tells the compiler which image read function to use.
|
|
Packit |
ed3af9 |
e.g. GD::Image img(input, GD::Gif_tag()); // read a gif file from input
|
|
Packit |
ed3af9 |
\param[in] in An opened FILE * handle to a file containing the image data
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(FILE * in, Gif_tag)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFromGif(in);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/** Construct an image by reading from \p in.
|
|
Packit |
ed3af9 |
The tag is an empty struct which simply tells the compiler which image read function to use.
|
|
Packit |
ed3af9 |
e.g. GD::Image img(input, GD::Gif_tag()); // read a gif file from input
|
|
Packit |
ed3af9 |
\param[in] in The io context from which to read the image data
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(gdIOCtx * in, Gif_tag)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFromGif(in);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/** Construct an image by reading from memory block \p data.
|
|
Packit |
ed3af9 |
The tag is an empty struct which simply tells the compiler which image read function to use.
|
|
Packit |
ed3af9 |
e.g. GD::Image img(sz, dat, GD::Gif_tag()); // read a gif file from dat
|
|
Packit |
ed3af9 |
\param[in] size The byte count of the memory block
|
|
Packit |
ed3af9 |
\param[in] data Pointer to the memory block
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(int size, void * data, Gif_tag)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFromGif(size, data);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
/** Construct an image by reading from \p in.
|
|
Packit |
ed3af9 |
The tag is an empty struct which simply tells the compiler which image read function to use.
|
|
Packit |
ed3af9 |
e.g. GD::Image img(input, GD::WBMP_tag()); // read a monchrome WBMP file from input
|
|
Packit |
ed3af9 |
\param[in] in The stream containing the image data
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(std::istream & in, WBMP_tag)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFromWBMP(in);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/** Construct an image by reading from \p in.
|
|
Packit |
ed3af9 |
The tag is an empty struct which simply tells the compiler which image read function to use.
|
|
Packit |
ed3af9 |
e.g. GD::Image img(input, GD::WBMP_tag()); // read a monchrome WBMP file from input
|
|
Packit |
ed3af9 |
\param[in] in An opened FILE * handle to a file containing the image data
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(FILE * in, WBMP_tag)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFromWBMP(in);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/** Construct an image by reading from \p in.
|
|
Packit |
ed3af9 |
The tag is an empty struct which simply tells the compiler which image read function to use.
|
|
Packit |
ed3af9 |
e.g. GD::Image img(input, GD::WBMP_tag()); // read a monchrome WBMP file from input
|
|
Packit |
ed3af9 |
\param[in] in The io context from which to read the image data
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(gdIOCtx * in, WBMP_tag)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFromWBMP(in);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/** Construct an image by reading from memory block \p data.
|
|
Packit |
ed3af9 |
The tag is an empty struct which simply tells the compiler which image read function to use.
|
|
Packit |
ed3af9 |
e.g. GD::Image img(sz, dat, GD::WBMP_tag()); // read a monchrome WBMP file from dat
|
|
Packit |
ed3af9 |
\param[in] size The byte count of the memory block
|
|
Packit |
ed3af9 |
\param[in] data Pointer to the memory block
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(int size, void * data, WBMP_tag)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFromWBMP(size, data);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
#ifdef HAVE_LIBJPEG
|
|
Packit |
ed3af9 |
/** Construct an image by reading from \p in.
|
|
Packit |
ed3af9 |
The tag is an empty struct which simply tells the compiler which image read function to use.
|
|
Packit |
ed3af9 |
e.g. GD::Image img(input, GD::Jpeg_tag()); // read a jpeg file from input
|
|
Packit |
ed3af9 |
\param[in] in The stream containing the image data
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(std::istream & in, Jpeg_tag)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFromJpeg(in);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/** Construct an image by reading from \p in.
|
|
Packit |
ed3af9 |
The tag is an empty struct which simply tells the compiler which image read function to use.
|
|
Packit |
ed3af9 |
e.g. GD::Image img(input, GD::Jpeg_tag()); // read a jpeg file from input
|
|
Packit |
ed3af9 |
\param[in] in An opened FILE * handle to a file containing the image data
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(FILE * in, Jpeg_tag)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFromJpeg(in);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/** Construct an image by reading from \p in.
|
|
Packit |
ed3af9 |
The tag is an empty struct which simply tells the compiler which image read function to use.
|
|
Packit |
ed3af9 |
e.g. GD::Image img(input, GD::Jpeg_tag()); // read a jpeg file from input
|
|
Packit |
ed3af9 |
\param[in] in The io context from which to read the image data
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(gdIOCtx * in, Jpeg_tag)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFromJpeg(in);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/** Construct an image by reading from memory block \p data.
|
|
Packit |
ed3af9 |
The tag is an empty struct which simply tells the compiler which image read function to use.
|
|
Packit |
ed3af9 |
e.g. GD::Image img(sz, dat, GD::Jpeg_tag()); // read a jpeg file from dat
|
|
Packit |
ed3af9 |
\param[in] size The byte count of the memory block
|
|
Packit |
ed3af9 |
\param[in] data Pointer to the memory block
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(int size, void * data, Jpeg_tag)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFromJpeg(size, data);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
#endif
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
/** Construct an image by reading from \p in.
|
|
Packit |
ed3af9 |
The tag is an empty struct which simply tells the compiler which image read function to use.
|
|
Packit |
ed3af9 |
e.g. GD::Image img(input, GD::Gd_tag()); // read a gd file from input
|
|
Packit |
ed3af9 |
\param[in] in The stream containing the image data
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(std::istream & in, Gd_tag)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFromGd(in);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/** Construct an image by reading from \p in.
|
|
Packit |
ed3af9 |
The tag is an empty struct which simply tells the compiler which image read function to use.
|
|
Packit |
ed3af9 |
e.g. GD::Image img(input, GD::Gd_tag()); // read a gd file from input
|
|
Packit |
ed3af9 |
\param[in] in An opened FILE * handle to a file containing the image data
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(FILE * in, Gd_tag)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFromGd(in);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/** Construct an image by reading from \p in.
|
|
Packit |
ed3af9 |
The tag is an empty struct which simply tells the compiler which image read function to use.
|
|
Packit |
ed3af9 |
e.g. GD::Image img(input, GD::Gd_tag()); // read a gd file from input
|
|
Packit |
ed3af9 |
\param[in] in The io context from which to read the image data
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(gdIOCtx * in, Gd_tag)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFromGd(in);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/** Construct an image by reading from memory block \p data.
|
|
Packit |
ed3af9 |
The tag is an empty struct which simply tells the compiler which image read function to use.
|
|
Packit |
ed3af9 |
e.g. GD::Image img(sz, dat, GD::Gd_tag()); // read a gd file from dat
|
|
Packit |
ed3af9 |
\param[in] size The byte count of the memory block
|
|
Packit |
ed3af9 |
\param[in] data Pointer to the memory block
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(int size, void * data, Gd_tag)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFromGd(size, data);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
/** Construct an image by reading from \p in.
|
|
Packit |
ed3af9 |
The tag is an empty struct which simply tells the compiler which image read function to use.
|
|
Packit |
ed3af9 |
e.g. GD::Image img(input, GD::Gd2_tag()); // read a gd2 file from input
|
|
Packit |
ed3af9 |
\param[in] in The stream containing the image data
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(std::istream & in, Gd2_tag)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFromGd2(in);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/** Construct an image by reading from \p in.
|
|
Packit |
ed3af9 |
The tag is an empty struct which simply tells the compiler which image read function to use.
|
|
Packit |
ed3af9 |
e.g. GD::Image img(input, GD::Png_tag()); // read a png file from input
|
|
Packit |
ed3af9 |
\param[in] in An opened FILE * handle to a file containing the image data
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(FILE * in, Gd2_tag)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFromGd2(in);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/** Construct an image by reading from \p in.
|
|
Packit |
ed3af9 |
The tag is an empty struct which simply tells the compiler which image read function to use.
|
|
Packit |
ed3af9 |
e.g. GD::Image img(input, GD::Gd2_tag()); // read a gd2 file from input
|
|
Packit |
ed3af9 |
\param[in] in The io context from which to read the image data
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(gdIOCtx * in, Gd2_tag)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFromGd2(in);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/** Construct an image by reading from memory block \p data.
|
|
Packit |
ed3af9 |
The tag is an empty struct which simply tells the compiler which image read function to use.
|
|
Packit |
ed3af9 |
e.g. GD::Image img(sz, dat, GD::Gd2_tag()); // read a gd2 file from dat
|
|
Packit |
ed3af9 |
\param[in] size The byte count of the memory block
|
|
Packit |
ed3af9 |
\param[in] data Pointer to the memory block
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(int size, void * data, Gd2_tag)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFromGd2(size, data);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
/** Construct an image by reading from \p in.
|
|
Packit |
ed3af9 |
The tag is an empty struct which simply tells the compiler which image read function to use.
|
|
Packit |
ed3af9 |
e.g. GD::Image img(input, GD::Xbm_tag()); // read an xbm file from input
|
|
Packit |
ed3af9 |
\param[in] in An opened FILE * handle to a file containing the image data
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
Image(FILE * in, Xbm_tag)
|
|
Packit |
ed3af9 |
:im(0) {
|
|
Packit |
ed3af9 |
CreateFromXbm(in);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
~Image() {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
/** Assignment Operator. Make this a copy of the GD::Image provided.
|
|
Packit |
ed3af9 |
\param[in] src Reference to the image to be copied
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
GD::Image & operator=(const GD::Image & src) {
|
|
Packit |
ed3af9 |
Copy(src);
|
|
Packit |
ed3af9 |
return (* this);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/** Make this an exact copy of the GD::Image provided. Any existing iamge data is discarded.
|
|
Packit |
ed3af9 |
\param[in] src Reference to the image to be copied
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
void Copy(const GD::Image & src) {
|
|
Packit |
ed3af9 |
int w = src.Width(), h = src.Height();
|
|
Packit |
ed3af9 |
if (src.IsTrueColor())
|
|
Packit |
ed3af9 |
CreateTrueColor(w, h);
|
|
Packit |
ed3af9 |
else {
|
|
Packit |
ed3af9 |
Create(w, h);
|
|
Packit |
ed3af9 |
PaletteCopy(src);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
Copy(src, 0, 0, 0, 0, w, h);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/** Check to see if this appears to be a valid image
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
bool good() const {
|
|
Packit |
ed3af9 |
return (im != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
// Creation:
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Create a palette-based image, with no more than 256 colors.
|
|
Packit |
ed3af9 |
\param sx Width of the desired image
|
|
Packit |
ed3af9 |
\param sy Height of the desired image
|
|
Packit |
ed3af9 |
\return true if it worked, else false
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
bool Create(int sx, int sy) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
return ((im = gdImageCreate(sx, sy)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Create a truecolor image.
|
|
Packit |
ed3af9 |
\param sx Width of the desired image
|
|
Packit |
ed3af9 |
\param sy Height of the desired image
|
|
Packit |
ed3af9 |
\return true if it worked, else false
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
bool CreateTrueColor(int sx, int sy) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateTrueColor(sx, sy)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Create a palette-based image, with no more than 256 colors.
|
|
Packit |
ed3af9 |
\param s Width and height of the desired image
|
|
Packit |
ed3af9 |
\return true if it worked, else false
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
bool Create(const Size & s) {
|
|
Packit |
ed3af9 |
return Create(s.W(), s.H());
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Create a truecolor image.
|
|
Packit |
ed3af9 |
\param s Width and height of the desired image
|
|
Packit |
ed3af9 |
\return true if it worked, else false
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
bool CreateTrueColor(const Size & s) {
|
|
Packit |
ed3af9 |
return CreateTrueColor(s.W(), s.H());
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
// Create, determining the image format from the data
|
|
Packit |
ed3af9 |
/// Read an image from an open FILE * handle, after determining the image format
|
|
Packit |
ed3af9 |
bool CreateFrom(FILE * in);
|
|
Packit |
ed3af9 |
/// Read an image from an open standard library input stream, after determining the image format
|
|
Packit |
ed3af9 |
bool CreateFrom(std::istream & in);
|
|
Packit |
ed3af9 |
/// Read an image from a memory block, after determining the image format
|
|
Packit |
ed3af9 |
bool CreateFrom(int size, void * data);
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
#ifdef HAVE_LIBPNG
|
|
Packit |
ed3af9 |
// Png
|
|
Packit |
ed3af9 |
bool CreateFromPng(FILE * in) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromPng(in)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
bool CreateFromPng(gdIOCtx * in) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromPngCtx(in)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
bool CreateFromPng(int size, void * data) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromPngPtr(size, data)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
bool CreateFromPng(std::istream & in) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
istreamIOCtx _in_ctx(in);
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromPngCtx( & _in_ctx)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
#endif
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
// Gif
|
|
Packit |
ed3af9 |
bool CreateFromGif(FILE * in) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromGif(in)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
bool CreateFromGif(gdIOCtx * in) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromGifCtx(in)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
bool CreateFromGif(int size, void * data) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromGifPtr(size, data)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
bool CreateFromGif(std::istream & in) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
istreamIOCtx _in_ctx(in);
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromGifCtx( & _in_ctx)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
// WBMP
|
|
Packit |
ed3af9 |
bool CreateFromWBMP(FILE * in) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromWBMP(in)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
bool CreateFromWBMP(gdIOCtx * in) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromWBMPCtx(in)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
bool CreateFromWBMP(int size, void * data) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromWBMPPtr(size, data)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
bool CreateFromWBMP(std::istream & in) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
istreamIOCtx _in_ctx(in);
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromWBMPCtx( & _in_ctx)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
#ifdef HAVE_LIBJPEG
|
|
Packit |
ed3af9 |
// Jpeg
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Load a truecolor image from a JPEG format file.
|
|
Packit |
ed3af9 |
Invoke CreateFromJpeg with an already opened
|
|
Packit |
ed3af9 |
pointer to a file containing the desired image.
|
|
Packit |
ed3af9 |
CreateFromJpeg does not close the file.
|
|
Packit |
ed3af9 |
\return true for success, or false if unable to load the image (most often because
|
|
Packit |
ed3af9 |
the file is corrupt or does not contain a JPEG image).
|
|
Packit |
ed3af9 |
You can call Width() and Height() member functions of the image to determine its
|
|
Packit |
ed3af9 |
size. The returned image is always a truecolor image.
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
bool CreateFromJpeg(FILE * in) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromJpeg(in)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Load a truecolor image from a JPEG format file.
|
|
Packit |
ed3af9 |
Invoke CreateFromJpeg with an already opened
|
|
Packit |
ed3af9 |
pointer to a file containing the desired image.
|
|
Packit |
ed3af9 |
CreateFromJpeg does not close the file.
|
|
Packit |
ed3af9 |
\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).
|
|
Packit |
ed3af9 |
You can call Width() and Height() member functions of the image to determine its
|
|
Packit |
ed3af9 |
size. The returned image is always a truecolor image.
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
bool CreateFromJpeg(gdIOCtx * in) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromJpegCtx(in)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Load a truecolor image from a JPEG format file.
|
|
Packit |
ed3af9 |
Invoke CreateFromJpeg with an already opened
|
|
Packit |
ed3af9 |
pointer to a file containing the desired image.
|
|
Packit |
ed3af9 |
CreateFromJpeg does not close the file.
|
|
Packit |
ed3af9 |
\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).
|
|
Packit |
ed3af9 |
You can call Width() and Height() member functions of the image to determine its
|
|
Packit |
ed3af9 |
size. The returned image is always a truecolor image.
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
bool CreateFromJpeg(int size, void * data) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromJpegPtr(size, data)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Load a truecolor image from a JPEG format file.
|
|
Packit |
ed3af9 |
Invoke CreateFromJpeg with an image file in memory.
|
|
Packit |
ed3af9 |
\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).
|
|
Packit |
ed3af9 |
You can call Width() and Height() member functions of the image to determine its
|
|
Packit |
ed3af9 |
size. The returned image is always a truecolor image.
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
bool CreateFromJpeg(std::istream & in) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
istreamIOCtx _in_ctx(in);
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromJpegCtx( & _in_ctx)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
#endif
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
// Gd
|
|
Packit |
ed3af9 |
bool CreateFromGd(FILE * in) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromGd(in)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
bool CreateFromGd(gdIOCtx * in) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromGdCtx(in)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
bool CreateFromGd(int size, void * data) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromGdPtr(size, data)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
bool CreateFromGd(std::istream & in) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
istreamIOCtx _in_ctx(in);
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromGdCtx( & _in_ctx)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
// Gd2
|
|
Packit |
ed3af9 |
bool CreateFromGd2(FILE * in) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromGd2(in)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
bool CreateFromGd2(gdIOCtx * in) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromGd2Ctx(in)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
bool CreateFromGd2(int size, void * data) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromGd2Ptr(size, data)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
bool CreateFromGd2(std::istream & in) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
istreamIOCtx _in_ctx(in);
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromGd2Ctx( & _in_ctx)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
// Gd2 Part
|
|
Packit |
ed3af9 |
bool CreateFromGd2Part(FILE * in, int srcx, int srcy, int w, int h) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromGd2Part(in, srcx, srcy, w, h)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
bool CreateFromGd2Part(gdIOCtx * in, int srcx, int srcy, int w, int h) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromGd2PartCtx(in, srcx, srcy, w, h)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
bool CreateFromGd2Part(int size, void * data, int srcx, int srcy, int w, int h) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromGd2PartPtr(size, data, srcx, srcy, w, h)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
bool CreateFromGd2Part(std::istream & in, int srcx, int srcy, int w, int h) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
istreamIOCtx _in_ctx(in);
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromGd2PartCtx( & _in_ctx, srcx, srcy, w, h)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
bool CreateFromGd2Part(FILE * in, const Point & src, const Size & s) {
|
|
Packit |
ed3af9 |
return CreateFromGd2Part(in, src.X(), src.Y(), s.W(), s.H());
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
bool CreateFromGd2Part(gdIOCtx * in, const Point & src, const Size & s) {
|
|
Packit |
ed3af9 |
return CreateFromGd2Part(in, src.X(), src.Y(), s.W(), s.H());
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
bool CreateFromGd2Part(int size, void * data, const Point & src, const Size & s) {
|
|
Packit |
ed3af9 |
return CreateFromGd2Part(size, data, src.X(), src.Y(), s.W(), s.H());
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
bool CreateFromGd2Part(std::istream & in, const Point & src, const Size & s) {
|
|
Packit |
ed3af9 |
return CreateFromGd2Part(in, src.X(), src.Y(), s.W(), s.H());
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
// Xbm
|
|
Packit |
ed3af9 |
bool CreateFromXbm(FILE * in) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromXbm(in)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
// Xpm
|
|
Packit |
ed3af9 |
bool CreateFromXpm(char * filename) {
|
|
Packit |
ed3af9 |
clear();
|
|
Packit |
ed3af9 |
return ((im = gdImageCreateFromXpm(filename)) != 0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
bool CreateFromXpm(std::string & filename) {
|
|
Packit |
ed3af9 |
return CreateFromXpm((char *)(filename.c_str()));
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
// Accessors, Updaters & Methods:
|
|
Packit |
ed3af9 |
void SetPixel(int x, int y, int color) {
|
|
Packit |
ed3af9 |
gdImageSetPixel(im, x, y, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void SetPixel(const Point & p, int color) {
|
|
Packit |
ed3af9 |
SetPixel(p.X(), p.Y(), color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int GetPixel(int x, int y) const {
|
|
Packit |
ed3af9 |
return gdImageGetPixel(im, x, y);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int GetPixel(const Point & p) const {
|
|
Packit |
ed3af9 |
return GetPixel(p.X(), p.Y());
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int GetTrueColorPixel(int x, int y) const {
|
|
Packit |
ed3af9 |
return gdImageGetTrueColorPixel(im, x, y);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int GetTrueColorPixel(const Point & p) const {
|
|
Packit |
ed3af9 |
return GetTrueColorPixel(p.X(), p.Y());
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void SetPixel(int x, int y, TrueColor c) {
|
|
Packit |
ed3af9 |
SetPixel(x, y, c.Int());
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void SetPixel(const Point & p, TrueColor c) {
|
|
Packit |
ed3af9 |
SetPixel(p.X(), p.Y(), c.Int());
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void GetTrueColorPixel(TrueColor & c, int x, int y) const {
|
|
Packit |
ed3af9 |
c.set(GetTrueColorPixel(x, y));
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void GetTrueColorPixel(TrueColor & c, const Point & p) const {
|
|
Packit |
ed3af9 |
c.set(GetTrueColorPixel(p.X(), p.Y()));
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void AABlend() {
|
|
Packit |
ed3af9 |
gdImageAABlend(im);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void Line(int x1, int y1, int x2, int y2, int color) {
|
|
Packit |
ed3af9 |
gdImageLine(im, x1, y1, x2, y2, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void Line(const Point & p1, const Point & p2, int color) {
|
|
Packit |
ed3af9 |
Line(p1.X(), p1.Y(), p2.X(), p2.Y(), color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void Rectangle(int x1, int y1, int x2, int y2, int color) {
|
|
Packit |
ed3af9 |
gdImageRectangle(im, x1, y1, x2, y2, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void Rectangle(const Point & p1, const Point & p2, int color) {
|
|
Packit |
ed3af9 |
Rectangle(p1.X(), p1.Y(), p2.X(), p2.Y(), color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void Rectangle(const Point & p, const Size & s, int color) {
|
|
Packit |
ed3af9 |
Rectangle(p.X(), p.Y(), p.X() + s.W(), p.Y() + s.H(), color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void FilledRectangle(int x1, int y1, int x2, int y2, int color) {
|
|
Packit |
ed3af9 |
gdImageFilledRectangle(im, x1, y1, x2, y2, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void FilledRectangle(const Point & p1, const Point & p2, int color) {
|
|
Packit |
ed3af9 |
FilledRectangle(p1.X(), p1.Y(), p2.X(), p2.Y(), color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void FilledRectangle(const Point & p, const Size & s, int color) {
|
|
Packit |
ed3af9 |
FilledRectangle(p.X(), p.Y(), p.X() + s.W(), p.Y() + s.H(), color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void SetClip(int x1, int y1, int x2, int y2) {
|
|
Packit |
ed3af9 |
gdImageSetClip(im, x1, y1, x2, y2);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void SetClip(const Point & p1, const Point & p2) {
|
|
Packit |
ed3af9 |
SetClip(p1.X(), p1.Y(), p2.X(), p2.Y());
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void SetClip(const Point & p, const Size & s) {
|
|
Packit |
ed3af9 |
SetClip(p.X(), p.Y(), p.X() + s.W(), p.Y() + s.H());
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void GetClip(int & x1, int & y1, int & x2, int & y2) const {
|
|
Packit |
ed3af9 |
gdImageGetClip(im, & x1, & y1, & x2, & y2);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void GetClip(Point & p1, Point & p2) const {
|
|
Packit |
ed3af9 |
GetClip(p1.lhsX(), p1.lhsY(), p2.lhsX(), p2.lhsY());
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void GetClip(Point & p, Size & s) const {
|
|
Packit |
ed3af9 |
Point p2;
|
|
Packit |
ed3af9 |
GetClip(p.lhsX(), p.lhsY(), p2.lhsX(), p2.lhsY());
|
|
Packit |
ed3af9 |
s.set(p2.X() - p.X(), p2.Y() - p.Y());
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
bool BoundsSafe(int x, int y) const {
|
|
Packit |
ed3af9 |
return (gdImageBoundsSafe(im, x, y)?true:false);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
bool BoundsSafe(const Point & p) const {
|
|
Packit |
ed3af9 |
return BoundsSafe(p.X(), p.Y());
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void Char(gdFontPtr f, int x, int y, int c, int color) {
|
|
Packit |
ed3af9 |
gdImageChar(im, f, x, y, c, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void CharUp(gdFontPtr f, int x, int y, int c, int color) {
|
|
Packit |
ed3af9 |
gdImageCharUp(im, f, x, y, c, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void Char(gdFontPtr f, const Point & p, int c, int color) {
|
|
Packit |
ed3af9 |
Char(f, p.X(), p.Y(), c, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void CharUp(gdFontPtr f, const Point & p, int c, int color) {
|
|
Packit |
ed3af9 |
CharUp(f, p.X(), p.Y(), c, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void String(gdFontPtr f, int x, int y, unsigned char * s, int color) {
|
|
Packit |
ed3af9 |
gdImageString(im, f, x, y, (unsigned char *)s, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void StringUp(gdFontPtr f, int x, int y, unsigned char * s, int color) {
|
|
Packit |
ed3af9 |
gdImageStringUp(im, f, x, y, (unsigned char *)s, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void String(gdFontPtr f, int x, int y, unsigned short * s, int color) {
|
|
Packit |
ed3af9 |
gdImageString16(im, f, x, y, (unsigned short *)s, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void StringUp(gdFontPtr f, int x, int y, unsigned short * s, int color) {
|
|
Packit |
ed3af9 |
gdImageStringUp16(im, f, x, y, (unsigned short *)s, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void String(gdFontPtr f, int x, int y, char * s, int color) {
|
|
Packit |
ed3af9 |
gdImageString(im, f, x, y, (unsigned char *)s, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void StringUp(gdFontPtr f, int x, int y, char * s, int color) {
|
|
Packit |
ed3af9 |
gdImageStringUp(im, f, x, y, (unsigned char *)s, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void String(gdFontPtr f, int x, int y, const std::string & s, int color) {
|
|
Packit |
ed3af9 |
String(f, x, y, (char *)s.c_str(), color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void StringUp(gdFontPtr f, int x, int y, const std::string & s, int color) {
|
|
Packit |
ed3af9 |
StringUp(f, x, y, (char *)s.c_str(), color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void String(gdFontPtr f, const Point & p, unsigned char * s, int color) {
|
|
Packit |
ed3af9 |
String(f, p.X(), p.Y(), (unsigned char *)s, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void StringUp(gdFontPtr f, const Point & p, unsigned char * s, int color) {
|
|
Packit |
ed3af9 |
StringUp(f, p.X(), p.Y(), (unsigned char *)s, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void String(gdFontPtr f, const Point & p, unsigned short * s, int color) {
|
|
Packit |
ed3af9 |
String(f, p.X(), p.Y(), (unsigned short *)s, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void StringUp(gdFontPtr f, const Point & p, unsigned short * s, int color) {
|
|
Packit |
ed3af9 |
StringUp(f, p.X(), p.Y(), (unsigned short *)s, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void String(gdFontPtr f, const Point & p, char * s, int color) {
|
|
Packit |
ed3af9 |
String(f, p.X(), p.Y(), (unsigned char *)s, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void StringUp(gdFontPtr f, const Point & p, char * s, int color) {
|
|
Packit |
ed3af9 |
StringUp(f, p.X(), p.Y(), (unsigned char *)s, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void String(gdFontPtr f, const Point & p, const std::string & s, int color) {
|
|
Packit |
ed3af9 |
String(f, p, (char *)s.c_str(), color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void StringUp(gdFontPtr f, const Point & p, const std::string & s, int color) {
|
|
Packit |
ed3af9 |
StringUp(f, p, (char *)s.c_str(), color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle,
|
|
Packit |
ed3af9 |
int x, int y, char * string) {
|
|
Packit |
ed3af9 |
return gdImageStringFT(im, brect, fg, fontlist, ptsize, angle, x, y, string);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle,
|
|
Packit |
ed3af9 |
int x, int y, char * string, gdFTStringExtraPtr strex) {
|
|
Packit |
ed3af9 |
return gdImageStringFTEx(im, brect, fg, fontlist, ptsize, angle, x, y, string, strex);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle,
|
|
Packit |
ed3af9 |
int x, int y, const std::string & string) {
|
|
Packit |
ed3af9 |
return StringFT(brect, fg, fontlist, ptsize, angle, x, y, (char *)string.c_str());
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle,
|
|
Packit |
ed3af9 |
int x, int y, const std::string & string, gdFTStringExtraPtr strex) {
|
|
Packit |
ed3af9 |
return StringFT(brect, fg, fontlist, ptsize, angle, x, y, (char *)string.c_str(), strex);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle,
|
|
Packit |
ed3af9 |
const Point & p, char * string) {
|
|
Packit |
ed3af9 |
return StringFT(brect, fg, fontlist, ptsize, angle, p.X(), p.Y(), string);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle,
|
|
Packit |
ed3af9 |
const Point & p, char * string, gdFTStringExtraPtr strex) {
|
|
Packit |
ed3af9 |
return StringFT(brect, fg, fontlist, ptsize, angle, p.X(), p.Y(), string, strex);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle,
|
|
Packit |
ed3af9 |
const Point & p, const std::string & string) {
|
|
Packit |
ed3af9 |
return StringFT(brect, fg, fontlist, ptsize, angle, p, (char *)string.c_str());
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle,
|
|
Packit |
ed3af9 |
const Point & p, const std::string & string, gdFTStringExtraPtr strex) {
|
|
Packit |
ed3af9 |
return StringFT(brect, fg, fontlist, ptsize, angle, p, (char *)string.c_str(), strex);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void Polygon(gdPointPtr p, int n, int c) {
|
|
Packit |
ed3af9 |
gdImagePolygon(im, p, n, c);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void OpenPolygon(gdPointPtr p, int n, int c) {
|
|
Packit |
ed3af9 |
gdImageOpenPolygon(im, p, n, c);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void FilledPolygon(gdPointPtr p, int n, int c) {
|
|
Packit |
ed3af9 |
gdImageFilledPolygon(im, p, n, c);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void Polygon(PointPtr p, int n, int c) {
|
|
Packit |
ed3af9 |
Polygon(p->as_gdPointPtr(), n, c);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void OpenPolygon(PointPtr p, int n, int c) {
|
|
Packit |
ed3af9 |
OpenPolygon(p->as_gdPointPtr(), n, c);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void FilledPolygon(PointPtr p, int n, int c) {
|
|
Packit |
ed3af9 |
FilledPolygon(p->as_gdPointPtr(), n, c);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
int ColorAllocate(int r, int g, int b) {
|
|
Packit |
ed3af9 |
return gdImageColorAllocate(im, r, g, b);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int ColorAllocate(int r, int g, int b, int a) {
|
|
Packit |
ed3af9 |
return gdImageColorAllocateAlpha(im, r, g, b, a);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
int ColorClosest(int r, int g, int b) const {
|
|
Packit |
ed3af9 |
return gdImageColorClosest(im, r, g, b);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int ColorClosest(int r, int g, int b, int a) const {
|
|
Packit |
ed3af9 |
return gdImageColorClosestAlpha(im, r, g, b, a);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int ColorClosestHWB(int r, int g, int b) const {
|
|
Packit |
ed3af9 |
return gdImageColorClosestHWB(im, r, g, b);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int ColorExact(int r, int g, int b) const {
|
|
Packit |
ed3af9 |
return gdImageColorExact(im, r, g, b);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int ColorExact(int r, int g, int b, int a) const {
|
|
Packit |
ed3af9 |
return gdImageColorExactAlpha(im, r, g, b, a);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int ColorResolve(int r, int g, int b) {
|
|
Packit |
ed3af9 |
return gdImageColorResolve(im, r, g, b);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int ColorResolve(int r, int g, int b, int a) {
|
|
Packit |
ed3af9 |
return gdImageColorResolveAlpha(im, r, g, b, a);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void ColorDeallocate(int color) {
|
|
Packit |
ed3af9 |
gdImageColorDeallocate(im, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void TrueColorToPalette(int ditherFlag, int colorsWanted) {
|
|
Packit |
ed3af9 |
gdImageTrueColorToPalette(im, ditherFlag, colorsWanted);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void ColorTransparent(int color) {
|
|
Packit |
ed3af9 |
gdImageColorTransparent(im, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void PaletteCopy(gdImagePtr src) {
|
|
Packit |
ed3af9 |
gdImagePaletteCopy(im, src);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void PaletteCopy(const GD::Image & src) {
|
|
Packit |
ed3af9 |
PaletteCopy(src.im);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Write out this image in GIF file format to \p out.
|
|
Packit |
ed3af9 |
\param out A FILE * handle
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
void Gif(FILE * out) const {
|
|
Packit |
ed3af9 |
gdImageGif(im, out);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Write out this image in GIF file format to \p out.
|
|
Packit |
ed3af9 |
\param out A gdIOCtx * handle
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
void Gif(gdIOCtx * out) const {
|
|
Packit |
ed3af9 |
gdImageGifCtx(im, out);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Allocate sufficient memory, and write this image, in GIF file format, to that memory.
|
|
Packit |
ed3af9 |
\param size A pointer for the allocated memory
|
|
Packit |
ed3af9 |
\return A pointer to the allocated memory, containing the image GIF file formatted. Caller is responsible for freeing with gdFree().
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
void * Gif(int * size) const {
|
|
Packit |
ed3af9 |
return gdImageGifPtr(im, size);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Write out this image in GIF file format to \p out.
|
|
Packit |
ed3af9 |
\param out An output stream, already opened.
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
void Gif(std::ostream & out) const {
|
|
Packit |
ed3af9 |
ostreamIOCtx _out_ctx(out);
|
|
Packit |
ed3af9 |
gdImageGifCtx(im, & _out_ctx);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
#ifdef HAVE_LIBPNG
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Write out this image in PNG file format to \p out.
|
|
Packit |
ed3af9 |
\param out A FILE * handle
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
void Png(FILE * out) const {
|
|
Packit |
ed3af9 |
gdImagePng(im, out);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Write out this image in PNG file format to \p out.
|
|
Packit |
ed3af9 |
\param out A gdIOCtx * handle
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
void Png(gdIOCtx * out) const {
|
|
Packit |
ed3af9 |
gdImagePngCtx(im, out);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Allocate sufficient memory, and write this image, in PNG file format, to that memory.
|
|
Packit |
ed3af9 |
\param size A pointer for the allocated memory
|
|
Packit |
ed3af9 |
\return A pointer to the allocated memory, containing the image PNG file formatted. Caller is responsible for freeing with gdFree().
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
void * Png(int * size) const {
|
|
Packit |
ed3af9 |
return gdImagePngPtr(im, size);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Write out this image in PNG file format to \p out.
|
|
Packit |
ed3af9 |
\param out An output stream, already opened.
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
void Png(std::ostream & out) const {
|
|
Packit |
ed3af9 |
ostreamIOCtx _out_ctx(out);
|
|
Packit |
ed3af9 |
gdImagePngCtx(im, & _out_ctx);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Write out this image in PNG file format to \p out.
|
|
Packit |
ed3af9 |
\param out A FILE * handle
|
|
Packit |
ed3af9 |
\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
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
void Png(FILE * out, int level) const {
|
|
Packit |
ed3af9 |
gdImagePngEx(im, out, level);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Write out this image in PNG file format to \p out.
|
|
Packit |
ed3af9 |
\param out A gdIOCtx * handle
|
|
Packit |
ed3af9 |
\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
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
void Png(gdIOCtx * out, int level) const {
|
|
Packit |
ed3af9 |
gdImagePngCtxEx(im, out, level);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Allocate sufficient memory, and write this image, in PNG file format, to that memory.
|
|
Packit |
ed3af9 |
\param size A pointer for the allocated memory
|
|
Packit |
ed3af9 |
\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
|
|
Packit |
ed3af9 |
\return A pointer to the allocated memory, containing the image PNG file formatted. Caller is responsible for freeing with gdFree().
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
void * Png(int * size, int level) const {
|
|
Packit |
ed3af9 |
return gdImagePngPtrEx(im, size, level);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Write out this image in PNG file format to \p out.
|
|
Packit |
ed3af9 |
\param out An output stream, already opened.
|
|
Packit |
ed3af9 |
\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
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
void Png(std::ostream & out, int level) const {
|
|
Packit |
ed3af9 |
ostreamIOCtx _out_ctx(out);
|
|
Packit |
ed3af9 |
gdImagePngCtxEx(im, & _out_ctx, level);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
#endif
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Write out this image in WBMP file format ( black and white only ) to \p out.
|
|
Packit |
ed3af9 |
\param fg The color index of the foreground. All other pixels considered background.
|
|
Packit |
ed3af9 |
\param out A FILE * handle
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
void WBMP(int fg, FILE * out) const {
|
|
Packit |
ed3af9 |
gdImageWBMP(im, fg, out);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Write out this image in WBMP file format ( black and white only ) to \p out.
|
|
Packit |
ed3af9 |
\param fg The color index of the foreground. All other pixels considered background.
|
|
Packit |
ed3af9 |
\param out A gdIOCtx * handle
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
void WBMP(int fg, gdIOCtx * out) const {
|
|
Packit |
ed3af9 |
gdImageWBMPCtx(im, fg, out);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Allocate sufficient memory, and write this image, in WBMP file format ( black and white only ), to that memory.
|
|
Packit |
ed3af9 |
\param size A pointer for the allocated memory
|
|
Packit |
ed3af9 |
\param fg The color index of the foreground. All other pixels considered background.
|
|
Packit |
ed3af9 |
\return A pointer to the allocated memory, containing the image WBMP file formatted. Caller is responsible for freeing with gdFree().
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
void * WBMP(int * size, int fg) const {
|
|
Packit |
ed3af9 |
return gdImageWBMPPtr(im, size, fg);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Write out this image in WBMP file format ( black and white only ) to \p out.
|
|
Packit |
ed3af9 |
\param fg The color index of the foreground. All other pixels considered background.
|
|
Packit |
ed3af9 |
\param out An output stream, already opened.
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
void WBMP(int fg, std::ostream & out) const {
|
|
Packit |
ed3af9 |
ostreamIOCtx _out_ctx(out);
|
|
Packit |
ed3af9 |
gdImageWBMPCtx(im, fg, & _out_ctx);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
#ifdef HAVE_LIBJPEG
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Write out this image in JPEG file format to \p out.
|
|
Packit |
ed3af9 |
\param out A FILE * handle
|
|
Packit |
ed3af9 |
\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".
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
void Jpeg(FILE * out, int quality = -1) const {
|
|
Packit |
ed3af9 |
gdImageJpeg(im, out, quality);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Write out this image in JPEG file format to \p out.
|
|
Packit |
ed3af9 |
\param out A gdIOCtx * handle
|
|
Packit |
ed3af9 |
\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".
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
void Jpeg(gdIOCtx * out, int quality = -1) const {
|
|
Packit |
ed3af9 |
gdImageJpegCtx(im, out, quality);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Allocate sufficient memory, and write this image, in JPEG file format, to that memory.
|
|
Packit |
ed3af9 |
\param size A pointer for the allocated memory
|
|
Packit |
ed3af9 |
\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".
|
|
Packit |
ed3af9 |
\return A pointer to the allocated memory, containing the image JPEG file formatted. Caller is responsible for freeing with gdFree().
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
void * Jpeg(int * size, int quality = -1) const {
|
|
Packit |
ed3af9 |
return gdImageJpegPtr(im, size, quality);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Write out this image in JPEG file format to \p out.
|
|
Packit |
ed3af9 |
\param out An output stream, already opened.
|
|
Packit |
ed3af9 |
\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".
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
void Jpeg(std::ostream & out, int quality = -1) const {
|
|
Packit |
ed3af9 |
ostreamIOCtx _out_ctx(out);
|
|
Packit |
ed3af9 |
gdImageJpegCtx(im, & _out_ctx, quality);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
#endif
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void GifAnimBegin(FILE * out, int GlobalCM, int Loops) const {
|
|
Packit |
ed3af9 |
gdImageGifAnimBegin(im, out, GlobalCM, Loops);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void GifAnimAdd(FILE * out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm) const {
|
|
Packit |
ed3af9 |
gdImageGifAnimAdd(im, out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void GifAnimAdd(FILE * out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, const GD::Image & previm) const {
|
|
Packit |
ed3af9 |
GifAnimAdd(out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm.im);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
inline static void GifAnimEnd(FILE * out) {
|
|
Packit |
ed3af9 |
gdImageGifAnimEnd(out);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void GifAnimBegin(gdIOCtx * out, int GlobalCM, int Loops) const {
|
|
Packit |
ed3af9 |
gdImageGifAnimBeginCtx(im, out, GlobalCM, Loops);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void GifAnimAdd(gdIOCtx * out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm) const {
|
|
Packit |
ed3af9 |
gdImageGifAnimAddCtx(im, out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void GifAnimAdd(gdIOCtx * out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, const GD::Image & previm) const {
|
|
Packit |
ed3af9 |
GifAnimAdd(out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm.im);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
inline static void GifAnimEnd(gdIOCtx * out) {
|
|
Packit |
ed3af9 |
gdImageGifAnimEndCtx(out);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void * GifAnimBegin(int * size, int GlobalCM, int Loops) const {
|
|
Packit |
ed3af9 |
return gdImageGifAnimBeginPtr(im, size, GlobalCM, Loops);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void * GifAnimAdd(int * size, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm) const {
|
|
Packit |
ed3af9 |
return gdImageGifAnimAddPtr(im, size, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void * GifAnimAdd(int * size, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, const GD::Image & previm) const {
|
|
Packit |
ed3af9 |
return GifAnimAdd(size, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm.im);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
inline static void * GifAnimEnd(int * size) {
|
|
Packit |
ed3af9 |
return gdImageGifAnimEndPtr(size);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void Gd(FILE * out) const {
|
|
Packit |
ed3af9 |
gdImageGd(im, out);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void* Gd(int * size) const {
|
|
Packit |
ed3af9 |
return gdImageGdPtr(im, size);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void Gd2(FILE * out, int cs, int fmt) const {
|
|
Packit |
ed3af9 |
gdImageGd2(im, out, cs, fmt);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void* Gd2(int cs, int fmt, int * size) const {
|
|
Packit |
ed3af9 |
return gdImageGd2Ptr(im, cs, fmt, size);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void Ellipse(int cx, int cy, int w, int h, int color) {
|
|
Packit |
ed3af9 |
gdImageEllipse(im, cx, cy, w, h, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
/**
|
|
Packit |
ed3af9 |
Draw a partial ellipse centered at the given point, with the specified width and height in pixels.
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
void FilledArc(int cx, int cy, int w, int h, int s, int e, int color, int style) {
|
|
Packit |
ed3af9 |
gdImageFilledArc(im, cx, cy, w, h, s, e, color, style);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void Arc(int cx, int cy, int w, int h, int s, int e, int color) {
|
|
Packit |
ed3af9 |
gdImageArc(im, cx, cy, w, h, s, e, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void FilledEllipse(int cx, int cy, int w, int h, int color) {
|
|
Packit |
ed3af9 |
gdImageFilledEllipse(im, cx, cy, w, h, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void FillToBorder(int x, int y, int border, int color) {
|
|
Packit |
ed3af9 |
gdImageFillToBorder(im, x, y, border, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void Fill(int x, int y, int color) {
|
|
Packit |
ed3af9 |
gdImageFill(im, x, y, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void Ellipse(const Point & c, const Size & s, int color) {
|
|
Packit |
ed3af9 |
Ellipse(c.X(), c.Y(), s.W(), s.H(), color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void FilledArc(const Point & c, const Size & si, int s, int e, int color, int style) {
|
|
Packit |
ed3af9 |
FilledArc(c.X(), c.Y(), si.W(), si.H(), s, e, color, style);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void Arc(const Point & c, const Size & si, int s, int e, int color) {
|
|
Packit |
ed3af9 |
Arc(c.X(), c.Y(), si.W(), si.H(), s, e, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void FilledEllipse(const Point & c, const Size & s, int color) {
|
|
Packit |
ed3af9 |
FilledEllipse(c.X(), c.Y(), s.W(), s.H(), color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void FillToBorder(const Point & p, int border, int color) {
|
|
Packit |
ed3af9 |
FillToBorder(p.X(), p.Y(), border, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void Fill(const Point & p, int color) {
|
|
Packit |
ed3af9 |
Fill(p.X(), p.Y(), color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void Copy(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h) {
|
|
Packit |
ed3af9 |
gdImageCopy(im, src, dstX, dstY, srcX, srcY, w, h);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void CopyMerge(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct) {
|
|
Packit |
ed3af9 |
gdImageCopyMerge(im, src, dstX, dstY, srcX, srcY, w, h, pct);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void CopyMergeGray(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct) {
|
|
Packit |
ed3af9 |
gdImageCopyMergeGray(im, src, dstX, dstY, srcX, srcY, w, h, pct);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void CopyResized(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH) {
|
|
Packit |
ed3af9 |
gdImageCopyResized(im, src, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void CopyResampled(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH) {
|
|
Packit |
ed3af9 |
gdImageCopyResampled(im, src, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void CopyRotated(const gdImagePtr src, double dstX, double dstY, int srcX, int srcY, int srcWidth, int srcHeight, int angle) {
|
|
Packit |
ed3af9 |
gdImageCopyRotated(im, src, dstX, dstY, srcX, srcY, srcWidth, srcHeight, angle);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
Image * CopyGaussianBlurred(int radius, double sigma) {
|
|
Packit |
ed3af9 |
return new Image(gdImageCopyGaussianBlurred(im, radius, sigma));
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void Copy(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & s) {
|
|
Packit |
ed3af9 |
Copy(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H());
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void CopyMerge(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & s, int pct) {
|
|
Packit |
ed3af9 |
CopyMerge(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H(), pct);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void CopyMergeGray(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & s, int pct) {
|
|
Packit |
ed3af9 |
CopyMergeGray(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H(), pct);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void CopyResized(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & dstS, const Size & srcS) {
|
|
Packit |
ed3af9 |
CopyResized(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), dstS.W(), dstS.H(), srcS.W(), srcS.H());
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void CopyResampled(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & dstS, const Size & srcS) {
|
|
Packit |
ed3af9 |
CopyResampled(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), dstS.W(), dstS.H(), srcS.W(), srcS.H());
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void CopyRotated(const gdImagePtr src, double dstX, double dstY, const Point & srcP, const Size & srcS, int angle) {
|
|
Packit |
ed3af9 |
CopyRotated(src, dstX, dstY, srcP.X(), srcP.Y(), srcS.W(), srcS.H(), angle);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void Copy(const GD::Image & src, int dstX, int dstY, int srcX, int srcY, int w, int h) {
|
|
Packit |
ed3af9 |
Copy(src.im, dstX, dstY, srcX, srcY, w, h);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void CopyMerge(const GD::Image & src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct) {
|
|
Packit |
ed3af9 |
CopyMerge(src.im, dstX, dstY, srcX, srcY, w, h, pct);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void CopyMergeGray(const GD::Image & src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct) {
|
|
Packit |
ed3af9 |
CopyMergeGray(src.im, dstX, dstY, srcX, srcY, w, h, pct);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void CopyResized(const GD::Image & src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH) {
|
|
Packit |
ed3af9 |
CopyResized(src.im, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void CopyResampled(const GD::Image & src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH) {
|
|
Packit |
ed3af9 |
CopyResampled(src.im, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void CopyRotated(const GD::Image & src, double dstX, double dstY, int srcX, int srcY, int srcWidth, int srcHeight, int angle) {
|
|
Packit |
ed3af9 |
CopyRotated(src.im, dstX, dstY, srcX, srcY, srcWidth, srcHeight, angle);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void Copy(const GD::Image & src, const Point & dstP, const Point & srcP, const Size & s) {
|
|
Packit |
ed3af9 |
Copy(src.im, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H());
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void CopyMerge(const GD::Image & src, const Point & dstP, const Point & srcP, const Size & s, int pct) {
|
|
Packit |
ed3af9 |
CopyMerge(src.im, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H(), pct);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void CopyMergeGray(const GD::Image & src, const Point & dstP, const Point & srcP, const Size & s, int pct) {
|
|
Packit |
ed3af9 |
CopyMergeGray(src.im, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H(), pct);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void CopyResized(const GD::Image & src, const Point & dstP, const Point & srcP, const Size & dstS, const Size & srcS) {
|
|
Packit |
ed3af9 |
CopyResized(src.im, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), dstS.W(), dstS.H(), srcS.W(), srcS.H());
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void CopyResampled(const GD::Image & src, const Point & dstP, const Point & srcP, const Size & dstS, const Size & srcS) {
|
|
Packit |
ed3af9 |
CopyResampled(src.im, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), dstS.W(), dstS.H(), srcS.W(), srcS.H());
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void CopyRotated(const GD::Image & src, double dstX, double dstY, const Point & srcP, const Size & srcS, int angle) {
|
|
Packit |
ed3af9 |
CopyRotated(src.im, dstX, dstY, srcP.X(), srcP.Y(), srcS.W(), srcS.H(), angle);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
Image * Clone() {
|
|
Packit |
ed3af9 |
return new Image(gdImageClone(im));
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void SetBrush(gdImagePtr brush) {
|
|
Packit |
ed3af9 |
gdImageSetBrush(im, brush);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void SetBrush(const GD::Image & brush) {
|
|
Packit |
ed3af9 |
SetBrush(brush.im);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void SetTile(gdImagePtr tile) {
|
|
Packit |
ed3af9 |
gdImageSetTile(im, tile);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void SetTile(const GD::Image & tile) {
|
|
Packit |
ed3af9 |
SetTile(tile.im);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void SetAntiAliased(int c) {
|
|
Packit |
ed3af9 |
gdImageSetAntiAliased(im, c);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void SetAntiAliasedDontBlend(int c, int dont_blend) {
|
|
Packit |
ed3af9 |
gdImageSetAntiAliasedDontBlend(im, c, dont_blend);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void SetStyle(int * style, int noOfPixels) {
|
|
Packit |
ed3af9 |
gdImageSetStyle(im, style, noOfPixels);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void SetThickness(int thickness) {
|
|
Packit |
ed3af9 |
gdImageSetThickness(im, thickness);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void SetResolution(int res_x, int res_y) {
|
|
Packit |
ed3af9 |
gdImageSetResolution(im, res_x, res_y);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void SetInterpolationMethod(gdInterpolationMethod interpolation_method) {
|
|
Packit |
ed3af9 |
gdImageSetInterpolationMethod(im, interpolation_method);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
Image * RotateInterpolated(const float angle, int bgcolor) {
|
|
Packit |
ed3af9 |
return new Image(gdImageRotateInterpolated(im, angle, bgcolor));
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void Interlace(bool interlaceArg) {
|
|
Packit |
ed3af9 |
gdImageInterlace(im, interlaceArg?1:0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void AlphaBlending(bool alphaBlendingArg) {
|
|
Packit |
ed3af9 |
gdImageAlphaBlending(im, alphaBlendingArg?1:0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void SaveAlpha(bool saveAlphaArg) {
|
|
Packit |
ed3af9 |
gdImageSaveAlpha(im, saveAlphaArg?1:0);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
int ColorReplace(int src, int dst) {
|
|
Packit |
ed3af9 |
return gdImageColorReplace(im, src, dst);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int ColorReplaceArray(int len, int * src, int * dst) {
|
|
Packit |
ed3af9 |
return gdImageColorReplaceArray(im, len, src, dst);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int ColorReplaceCallback(gdCallbackImageColor callback) {
|
|
Packit |
ed3af9 |
return gdImageColorReplaceCallback(im, callback);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int ColorReplaceThreshold(int src, int dst, float threshold) {
|
|
Packit |
ed3af9 |
return gdImageColorReplaceThreshold(im, src, dst, threshold);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
bool Pixelate(int block_size, gdPixelateMode mode) {
|
|
Packit |
ed3af9 |
return gdImagePixelate(im, block_size, mode) == 0 ? false : true;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
Image * Scale(int new_width, int new_height) {
|
|
Packit |
ed3af9 |
return new Image(gdImageScale(im, new_width, new_height));
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
bool IsTrueColor() const {
|
|
Packit |
ed3af9 |
return (gdImageTrueColor(im)?true:false);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int SX() const {
|
|
Packit |
ed3af9 |
return gdImageSX(im);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int SY() const {
|
|
Packit |
ed3af9 |
return gdImageSY(im);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int Width() const {
|
|
Packit |
ed3af9 |
return SX();
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int Height() const {
|
|
Packit |
ed3af9 |
return SY();
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int ResX() const {
|
|
Packit |
ed3af9 |
return gdImageResolutionX(im);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int ResY() const {
|
|
Packit |
ed3af9 |
return gdImageResolutionY(im);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
void GetSize(Size & s) const {
|
|
Packit |
ed3af9 |
s.set(SX(), SY());
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int ColorsTotal() const {
|
|
Packit |
ed3af9 |
return gdImageColorsTotal(im);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int Red(int color) const {
|
|
Packit |
ed3af9 |
return gdImageRed(im, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int Green(int color) const {
|
|
Packit |
ed3af9 |
return gdImageGreen(im, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int Blue(int color) const {
|
|
Packit |
ed3af9 |
return gdImageBlue(im, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int Alpha(int color) const {
|
|
Packit |
ed3af9 |
return gdImageAlpha(im, color);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int GetTransparent() const {
|
|
Packit |
ed3af9 |
return gdImageGetTransparent(im);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int GetInterlaced() const {
|
|
Packit |
ed3af9 |
return gdImageGetInterlaced(im);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int PalettePixel(int x, int y) const {
|
|
Packit |
ed3af9 |
return gdImagePalettePixel(im, x, y);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
int TrueColorPixel(int x, int y) const {
|
|
Packit |
ed3af9 |
return gdImageTrueColorPixel(im, x, y);
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
const gdImagePtr GetPtr() const {
|
|
Packit |
ed3af9 |
return im;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
protected:
|
|
Packit |
ed3af9 |
/// Free the internal image pointer
|
|
Packit |
ed3af9 |
void clear() {
|
|
Packit |
ed3af9 |
if (im)
|
|
Packit |
ed3af9 |
gdImageDestroy(im);
|
|
Packit |
ed3af9 |
im = 0;
|
|
Packit |
ed3af9 |
}
|
|
Packit |
ed3af9 |
gdImagePtr im;
|
|
Packit |
ed3af9 |
};
|
|
Packit |
ed3af9 |
} // namespace GD
|
|
Packit |
ed3af9 |
/// Read in an image from a standard library input stream
|
|
Packit |
ed3af9 |
std::istream & operator>> (std::istream & in, GD::Image & img);
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
#endif /* _gdpp_h */
|
|
Packit |
ed3af9 |
#endif /* __cplusplus */
|