]>
Commit | Line | Data |
---|---|---|
01111366 RR |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: image.h | |
3 | // Purpose: wxImage class | |
4 | // Author: Robert Roebling | |
5 | // RCS-ID: $Id$ | |
6 | // Copyright: (c) Robert Roebling | |
7 | // Licence: wxWindows licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | #ifndef _WX_IMAGE_H_ | |
11 | #define _WX_IMAGE_H_ | |
12 | ||
13 | #ifdef __GNUG__ | |
14 | #pragma interface "image.h" | |
15 | #endif | |
16 | ||
17 | #include "wx/setup.h" | |
18 | #include "wx/object.h" | |
19 | #include "wx/string.h" | |
20 | #include "wx/gdicmn.h" | |
21 | ||
22 | //----------------------------------------------------------------------------- | |
23 | // classes | |
24 | //----------------------------------------------------------------------------- | |
25 | ||
26 | class WXDLLEXPORT wxImageHandler; | |
27 | class WXDLLEXPORT wxPNGHandler; | |
28 | class WXDLLEXPORT wxBMPHandler; | |
29 | class WXDLLEXPORT wxImage; | |
30 | ||
31 | //----------------------------------------------------------------------------- | |
32 | // wxImageHandler | |
33 | //----------------------------------------------------------------------------- | |
34 | ||
35 | class WXDLLEXPORT wxImageHandler: public wxObject | |
36 | { | |
37 | DECLARE_DYNAMIC_CLASS(wxImageHandler) | |
38 | ||
39 | public: | |
40 | wxImageHandler() { m_name = ""; m_extension = ""; m_type = 0; } | |
41 | ||
42 | virtual bool LoadFile( wxImage *image, const wxString& name ); | |
43 | virtual bool SaveFile( wxImage *image, const wxString& name ); | |
44 | ||
45 | inline void SetName(const wxString& name) { m_name = name; } | |
46 | inline void SetExtension(const wxString& ext) { m_extension = ext; } | |
47 | inline void SetType(long type) { m_type = type; } | |
48 | inline wxString GetName() const { return m_name; } | |
49 | inline wxString GetExtension() const { return m_extension; } | |
50 | inline long GetType() const { return m_type; } | |
51 | ||
52 | protected: | |
53 | wxString m_name; | |
54 | wxString m_extension; | |
55 | long m_type; | |
56 | ||
57 | }; | |
58 | ||
59 | //----------------------------------------------------------------------------- | |
60 | // wxPNGHandler | |
61 | //----------------------------------------------------------------------------- | |
62 | ||
63 | class WXDLLEXPORT wxPNGHandler: public wxImageHandler | |
64 | { | |
65 | DECLARE_DYNAMIC_CLASS(wxPNGHandler) | |
66 | ||
67 | public: | |
68 | ||
69 | inline wxPNGHandler() | |
70 | { | |
71 | m_name = "PNG file"; | |
72 | m_extension = "png"; | |
73 | m_type = wxBITMAP_TYPE_PNG; | |
74 | }; | |
75 | ||
76 | virtual bool LoadFile( wxImage *image, const wxString& name ); | |
77 | virtual bool SaveFile( wxImage *image, const wxString& name ); | |
78 | }; | |
79 | ||
80 | //----------------------------------------------------------------------------- | |
81 | // wxBMPHandler | |
82 | //----------------------------------------------------------------------------- | |
83 | ||
84 | class WXDLLEXPORT wxBMPHandler: public wxImageHandler | |
85 | { | |
86 | DECLARE_DYNAMIC_CLASS(wxBMPHandler) | |
87 | ||
88 | public: | |
89 | ||
90 | inline wxBMPHandler() | |
91 | { | |
92 | m_name = "BMP file"; | |
93 | m_extension = "bmp"; | |
94 | m_type = wxBITMAP_TYPE_BMP; | |
95 | }; | |
96 | ||
97 | virtual bool LoadFile( wxImage *image, const wxString& name ); | |
98 | }; | |
99 | //----------------------------------------------------------------------------- | |
100 | // wxImage | |
101 | //----------------------------------------------------------------------------- | |
102 | ||
103 | class WXDLLEXPORT wxImage: public wxObject | |
104 | { | |
105 | DECLARE_DYNAMIC_CLASS(wxImage) | |
106 | ||
107 | friend class WXDLLEXPORT wxImageHandler; | |
108 | ||
109 | public: | |
110 | ||
111 | wxImage(); | |
112 | wxImage( int width, int height ); | |
113 | wxImage( const wxString& name, long type = wxBITMAP_TYPE_PNG ); | |
114 | ||
115 | wxImage( const wxImage& image ); | |
116 | wxImage( const wxImage* image ); | |
117 | ||
118 | void Create( int width, int height ); | |
119 | void Destroy(); | |
120 | ||
121 | virtual bool LoadFile( const wxString& name, long type = wxBITMAP_TYPE_PNG ); | |
122 | virtual bool SaveFile( const wxString& name, int type ); | |
123 | ||
124 | bool Ok() const; | |
125 | int GetWidth() const; | |
126 | int GetHeight() const; | |
127 | ||
128 | char unsigned *GetData() const; | |
129 | void SetData( char unsigned *data ); | |
130 | ||
131 | void SetMaskColour( unsigned char r, unsigned char g, unsigned char b ); | |
132 | unsigned char GetMaskRed() const; | |
133 | unsigned char GetMaskGreen() const; | |
134 | unsigned char GetMaskBlue() const; | |
135 | void SetMask( bool mask = TRUE ); | |
136 | bool HasMask() const; | |
137 | ||
138 | inline wxImage& operator = (const wxImage& image) | |
139 | { if (*this == image) return (*this); Ref(image); return *this; } | |
140 | inline bool operator == (const wxImage& image) | |
141 | { return m_refData == image.m_refData; } | |
142 | inline bool operator != (const wxImage& image) | |
143 | { return m_refData != image.m_refData; } | |
144 | ||
145 | static inline wxList& GetHandlers() { return sm_handlers; } | |
146 | static void AddHandler( wxImageHandler *handler ); | |
147 | static void InsertHandler( wxImageHandler *handler ); | |
148 | static bool RemoveHandler( const wxString& name ); | |
149 | static wxImageHandler *FindHandler( const wxString& name ); | |
150 | static wxImageHandler *FindHandler( const wxString& extension, long imageType ); | |
151 | static wxImageHandler *FindHandler( long imageType ); | |
152 | ||
153 | static void CleanUpHandlers(); | |
154 | ||
155 | protected: | |
156 | ||
157 | static wxList sm_handlers; | |
158 | ||
159 | }; | |
160 | ||
161 | #endif | |
162 | // _WX_IMAGE_H_ |