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
);
100 //-----------------------------------------------------------------------------
102 //-----------------------------------------------------------------------------
104 class WXDLLEXPORT wxImage
: public wxObject
106 DECLARE_DYNAMIC_CLASS(wxImage
)
108 friend class WXDLLEXPORT wxImageHandler
;
113 wxImage( int width
, int height
);
114 wxImage( const wxString
& name
, long type
= wxBITMAP_TYPE_PNG
);
116 wxImage( const wxImage
& image
);
117 wxImage( const wxImage
* image
);
119 void Create( int width
, int height
);
122 virtual bool LoadFile( const wxString
& name
, long type
= wxBITMAP_TYPE_PNG
);
123 virtual bool SaveFile( const wxString
& name
, int type
);
126 int GetWidth() const;
127 int GetHeight() const;
129 char unsigned *GetData() const;
130 void SetData( char unsigned *data
);
132 void SetMaskColour( unsigned char r
, unsigned char g
, unsigned char b
);
133 unsigned char GetMaskRed() const;
134 unsigned char GetMaskGreen() const;
135 unsigned char GetMaskBlue() const;
136 void SetMask( bool mask
= TRUE
);
137 bool HasMask() const;
139 inline wxImage
& operator = (const wxImage
& image
)
140 { if (*this == image
) return (*this); Ref(image
); return *this; }
141 inline bool operator == (const wxImage
& image
)
142 { return m_refData
== image
.m_refData
; }
143 inline bool operator != (const wxImage
& image
)
144 { return m_refData
!= image
.m_refData
; }
146 static inline wxList
& GetHandlers() { return sm_handlers
; }
147 static void AddHandler( wxImageHandler
*handler
);
148 static void InsertHandler( wxImageHandler
*handler
);
149 static bool RemoveHandler( const wxString
& name
);
150 static wxImageHandler
*FindHandler( const wxString
& name
);
151 static wxImageHandler
*FindHandler( const wxString
& extension
, long imageType
);
152 static wxImageHandler
*FindHandler( long imageType
);
154 static void CleanUpHandlers();
155 static void InitStandardHandlers();
159 static wxList sm_handlers
;