1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxImage class
4 // Author: Robert Roebling
6 // Copyright: (c) Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
14 #pragma interface "image.h"
18 #include "wx/object.h"
19 #include "wx/string.h"
20 #include "wx/gdicmn.h"
22 //-----------------------------------------------------------------------------
24 //-----------------------------------------------------------------------------
26 class WXDLLEXPORT wxImageHandler
;
27 class WXDLLEXPORT wxPNGHandler
;
28 class WXDLLEXPORT wxBMPHandler
;
29 class WXDLLEXPORT wxImage
;
31 //-----------------------------------------------------------------------------
33 //-----------------------------------------------------------------------------
35 class WXDLLEXPORT wxImageHandler
: public wxObject
37 DECLARE_DYNAMIC_CLASS(wxImageHandler
)
40 wxImageHandler() { m_name
= ""; m_extension
= ""; m_type
= 0; }
42 virtual bool LoadFile( wxImage
*image
, const wxString
& name
);
43 virtual bool SaveFile( wxImage
*image
, const wxString
& name
);
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
; }
59 //-----------------------------------------------------------------------------
61 //-----------------------------------------------------------------------------
63 class WXDLLEXPORT wxPNGHandler
: public wxImageHandler
65 DECLARE_DYNAMIC_CLASS(wxPNGHandler
)
73 m_type
= wxBITMAP_TYPE_PNG
;
76 virtual bool LoadFile( wxImage
*image
, const wxString
& name
);
77 virtual bool SaveFile( wxImage
*image
, const wxString
& name
);
80 //-----------------------------------------------------------------------------
82 //-----------------------------------------------------------------------------
84 class WXDLLEXPORT wxBMPHandler
: public wxImageHandler
86 DECLARE_DYNAMIC_CLASS(wxBMPHandler
)
94 m_type
= wxBITMAP_TYPE_BMP
;
97 virtual bool LoadFile( wxImage
*image
, const wxString
& name
);
99 //-----------------------------------------------------------------------------
101 //-----------------------------------------------------------------------------
103 class WXDLLEXPORT wxImage
: public wxObject
105 DECLARE_DYNAMIC_CLASS(wxImage
)
107 friend class WXDLLEXPORT wxImageHandler
;
112 wxImage( int width
, int height
);
113 wxImage( const wxString
& name
, long type
= wxBITMAP_TYPE_PNG
);
115 wxImage( const wxImage
& image
);
116 wxImage( const wxImage
* image
);
118 void Create( int width
, int height
);
121 virtual bool LoadFile( const wxString
& name
, long type
= wxBITMAP_TYPE_PNG
);
122 virtual bool SaveFile( const wxString
& name
, int type
);
125 int GetWidth() const;
126 int GetHeight() const;
128 char unsigned *GetData() const;
129 void SetData( char unsigned *data
);
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;
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
; }
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
);
153 static void CleanUpHandlers();
157 static wxList sm_handlers
;