fastdo  0.6.16
eiengd.hpp
浏览该文件的文档.
1 #ifndef __EIENGD_HPP__
2 #define __EIENGD_HPP__
3 
4 #include "winux.hpp"
5 
7 namespace eiengd
8 {
9 #ifdef EIENGD_DLL_USE
10  #if defined(_MSC_VER) || defined(WIN32)
11  #pragma warning( disable: 4251 )
12  #ifdef EIENGD_DLL_EXPORTS
13  #define EIENGD_DLL __declspec(dllexport)
14  #else
15  #define EIENGD_DLL __declspec(dllimport)
16  #endif
17 
18  #define EIENGD_API __stdcall
19  #else
20  #define EIENGD_DLL
21  #define EIENGD_API
22  #endif
23 #else
24  #define EIENGD_DLL
25  #define EIENGD_API
26 #endif
27 
28 #define EIENGD_FUNC_DECL(ret) EIENGD_DLL ret EIENGD_API
29 #define EIENGD_FUNC_IMPL(ret) ret EIENGD_API
30 
33 {
34 public:
35  enum
36  {
39  gdeUnsupportedType
40  };
41 
42  GdError( int errNo, winux::AnsiString const & err ) throw() : winux::Error( errNo, err ) { }
43 };
44 
45 struct Point
46 {
47  int x;
48  int y;
49 
50  Point( int x = 0, int y = 0 ): x(x), y(y)
51  {
52  }
53 };
54 
57 {
58 public:
59  GdInit();
60  ~GdInit();
61 
62 private:
64 
66 };
67 
68 class Image;
69 
72 {
73 public:
74  Color( Image & im );
75 
83  Color( Image & im, int red, int green, int blue, winux::Mixed const & mixed = winux::mxNull );
84 
85  ~Color();
86 
93  Color & alloc( int red, int green, int blue, winux::Mixed const & mixed = winux::mxNull );
94 
96  Color & transparent( int red, int green, int blue )
97  {
98  return this->alloc( red, green, blue, true );
99  }
100 
102  Color & alpha( int red, int green, int blue, int alpha = 0 )
103  {
104  return this->alloc( red, green, blue, alpha );
105  }
106 
107  void dealloc();
108 
109  Color( Color const & other );
110 
111  Color & operator = ( Color const & other );
112 
113 private:
114  Image * _im;
116 
117  friend class Graphics;
118 };
119 
122 {
123 public:
125  Image();
126 
128  Image( int width, int height, bool isTrueColor = true );
129 
131  Image( winux::String const & filename );
132 
133  ~Image();
134 
136  void create( int width, int height );
137 
139  void createTrueColor( int width, int height );
140 
142  void createFromFile( winux::String const & filename );
143 
147  bool output( winux::String const & filename, winux::String const & type = "" );
148 
152  bool output( winux::Buffer * buf, winux::String const & type = "" );
153 
155  void destroy();
156 
158  void copy( Image & srcImg, int srcX, int srcY, int srcWidth, int srcHeight, int x, int y );
159 
161  void copyResized( Image & srcImg, int srcX, int srcY, int srcWidth, int srcHeight, int x, int y, int width, int height );
162 
164  void copyResampled( Image & srcImg, int srcX, int srcY, int srcWidth, int srcHeight, int x, int y, int width, int height );
165 
166  void debug();
167 
169  Color color( int red, int green, int blue, winux::Mixed const & mixed = winux::mxNull );
170 
171  // attributes
172 
174  int getWidth() const;
175 
177  int getHeight() const;
178 
180  winux::String getType() const;
181 
185  void setJpegQuality( long quality );
186 
190  void saveAlpha( bool isSave );
191 
193  void alphaBlending( bool isBlend );
194 
196  int colorAt( int x, int y ) const;
197 
199  int colorsForIndex( int index ) const;
200 
202  int colorsTotal() const;
203 
204 private:
206 
208 
209  friend class Color;
210  friend class Graphics;
211 };
212 
214 class EIENGD_DLL Graphics
215 {
216 public:
217  Graphics( Image & im );
218 
219  ~Graphics();
220 
226  void fill( int x, int y, Color const & color );
227 
229  void filledRectangle( int x, int y, int width, int height, Color const & color );
230 
232  void filledEllipse( int centerX, int centerY, int width, int height, Color const & color );
233 
235  void arc( int centerX, int centerY, int width, int height, int start, int end, Color const & color );
236 
238  void line( int x1, int y1, int x2, int y2, Color const & color );
239 
241  void rectangle( int x, int y, int width, int height, Color const & color );
242 
244  void ellipse( int centerX, int centerY, int width, int height, Color const & color );
245 
256  void ttfTextOut(
257  double size,
258  double angle,
259  int x,
260  int y,
261  Color const & color,
262  winux::String const & fontFile,
263  winux::String const & text,
264  Point * boxOut = NULL
265  );
266 
270  void ttfBBox( double size, double angle, winux::String const & fontFile, winux::String const & text, Point boxOut[4] ) const;
271 
273  void stringOut( int fontInx, int x, int y, winux::String const & str, Color const & color );
274 
281  Color color( int red, int green, int blue, winux::Mixed const & mixed = winux::mxNull );
282 
283 private:
284  Image * _im;
286 
287  DISABLE_OBJECT_COPY(Graphics)
288 };
289 
291 EIENGD_FUNC_DECL(winux::Buffer) EncryptDataToPng( void const * data, winux::uint size );
300 
301 }
302 
303 #endif //__EIENGD_HPP__
XString< char > AnsiString
Definition: utilities.hpp:257
绘画类
Definition: eiengd.hpp:214
Mixed const mxNull
Mixed(MT_NULL)常量对象
winux::Buffer EncryptAnsiToPng(winux::AnsiString const &data)
加密数据成一个PNG图片
winux::Buffer EncryptBufferToPng(winux::Buffer const &data)
加密数据成一个PNG图片
winux::Buffer DecryptPngToBuffer(winux::Buffer const &pngData)
解密PNG图片为数据
GD错误
Definition: eiengd.hpp:32
XString< tchar > String
Definition: utilities.hpp:261
颜色类
Definition: eiengd.hpp:71
GdError(int errNo, winux::AnsiString const &err)
Definition: eiengd.hpp:42
Color & transparent(int red, int green, int blue)
分配透明色
Definition: eiengd.hpp:96
图片类
Definition: eiengd.hpp:121
#define DISABLE_OBJECT_COPY(clsname)
Definition: utilities.hpp:85
#define EIENGD_FUNC_DECL(ret)
Definition: eiengd.hpp:28
图形库,提供简单的图片操作和绘图功能
Definition: eiengd.hpp:7
缓冲区,表示内存中一块二进制数据(利用malloc/realloc进行内存分配)
Definition: utilities.hpp:906
Point(int x=0, int y=0)
Definition: eiengd.hpp:50
Color & alpha(int red, int green, int blue, int alpha=0)
分配带alpha通道的颜色
Definition: eiengd.hpp:102
unsigned int uint
Definition: utilities.hpp:215
winux::AnsiString DecryptPngToAnsi(winux::Buffer const &pngData)
解密PNG图片为数据
winux::Buffer EncryptDataToPng(void const *data, winux::uint size)
加密数据成一个PNG图片
GD初始化
Definition: eiengd.hpp:56
混合体,能表示多种类型的值
Definition: utilities.hpp:1440
#define EIENGD_DLL
Definition: eiengd.hpp:24
错误类
Definition: utilities.hpp:838