fastdo  0.6.8
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 private:
60 public:
61  GdInit();
62  ~GdInit();
64 };
65 
66 class Image;
67 
70 {
71 private:
72  Image * _im;
74 
75 public:
76  Color( Image & im );
77 
85  Color( Image & im, int red, int green, int blue, winux::Mixed const & mixed = winux::Mixed() );
86 
87  ~Color();
88 
95  Color & alloc( int red, int green, int blue, winux::Mixed const & mixed = winux::Mixed() );
96 
98  Color & transparent( int red, int green, int blue )
99  {
100  return this->alloc( red, green, blue, true );
101  }
102 
104  Color & alpha( int red, int green, int blue, int alpha = 0 )
105  {
106  return this->alloc( red, green, blue, alpha );
107  }
108 
109  void dealloc();
110 
111  Color( Color const & other );
112 
113  Color & operator = ( Color const & other );
114 
115  friend class Graphics;
116 };
117 
120 {
121 private:
123 
124 public:
126  Image();
127 
129  Image( int width, int height, bool isTrueColor = true );
130 
132  Image( winux::String const & filename );
133 
134  ~Image();
135 
137  void create( int width, int height );
138 
140  void createTrueColor( int width, int height );
141 
143  void createFromFile( winux::String const & filename );
144 
148  bool output( winux::String const & filename, winux::String const & type = "" );
149 
153  bool output( winux::Buffer * buf, winux::String const & type = "" );
154 
156  void destroy();
157 
159  void copy( Image & srcImg, int srcX, int srcY, int srcWidth, int srcHeight, int x, int y );
160 
162  void copyResized( Image & srcImg, int srcX, int srcY, int srcWidth, int srcHeight, int x, int y, int width, int height );
163 
165  void copyResampled( Image & srcImg, int srcX, int srcY, int srcWidth, int srcHeight, int x, int y, int width, int height );
166 
167  void debug();
168 
170  Color color( int red, int green, int blue, winux::Mixed const & mixed = winux::Mixed() );
171 
172  // attributes
173 
175  int getWidth() const;
176 
178  int getHeight() const;
179 
181  winux::String getType() const;
182 
186  void setJpegQuality( long quality );
187 
191  void saveAlpha( bool isSave );
192 
194  void alphaBlending( bool isBlend );
195 
197  int colorAt( int x, int y ) const;
198 
200  int colorsForIndex( int index ) const;
201 
203  int colorsTotal() const;
204 
206 
207  friend class Color;
208  friend class Graphics;
209 };
210 
212 class EIENGD_DLL Graphics
213 {
214 private:
215  Image * _im;
217 
218 public:
219  Graphics( Image & im );
220 
221  ~Graphics();
222 
228  void fill( int x, int y, Color const & color );
229 
231  void filledRectangle( int x, int y, int width, int height, Color const & color );
232 
234  void filledEllipse( int centerX, int centerY, int width, int height, Color const & color );
235 
237  void arc( int centerX, int centerY, int width, int height, int start, int end, Color const & color );
238 
240  void line( int x1, int y1, int x2, int y2, Color const & color );
241 
243  void rectangle( int x, int y, int width, int height, Color const & color );
244 
246  void ellipse( int centerX, int centerY, int width, int height, Color const & color );
247 
258  void ttfTextOut(
259  double size,
260  double angle,
261  int x,
262  int y,
263  Color const & color,
264  winux::String const & fontFile,
265  winux::String const & text,
266  Point * boxOut = NULL
267  );
268 
272  void ttfBBox( double size, double angle, winux::String const & fontFile, winux::String const & text, Point boxOut[4] ) const;
273 
275  void stringOut( int fontInx, int x, int y, winux::String const & str, Color const & color );
276 
283  Color color( int red, int green, int blue, winux::Mixed const & mixed = winux::Mixed() );
284 
285  DISABLE_OBJECT_COPY(Graphics)
286 };
287 
289 EIENGD_FUNC_DECL(winux::Buffer) EncryptDataToPng( void const * data, winux::uint size );
298 
299 }
300 
301 #endif //__EIENGD_HPP__
XString< char > AnsiString
Definition: utilities.hpp:212
绘画类
Definition: eiengd.hpp:212
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:216
颜色类
Definition: eiengd.hpp:69
GdError(int errNo, winux::AnsiString const &err)
Definition: eiengd.hpp:42
Color & transparent(int red, int green, int blue)
分配透明色
Definition: eiengd.hpp:98
图片类
Definition: eiengd.hpp:119
#define DISABLE_OBJECT_COPY(clsname)
Definition: utilities.hpp:81
#define EIENGD_FUNC_DECL(ret)
Definition: eiengd.hpp:28
图形库,提供简单的图片操作和绘图功能
Definition: eiengd.hpp:7
缓冲区,表示内存中一块二进制数据(利用malloc/realloc进行内存分配)
Definition: utilities.hpp:528
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:104
unsigned int uint
Definition: utilities.hpp:170
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:750
#define EIENGD_DLL
Definition: eiengd.hpp:24
错误类
Definition: utilities.hpp:505