]> git.saurik.com Git - wxWidgets.git/blame - include/wx/image.h
_MSC_VER => __VISUALC__ change
[wxWidgets.git] / include / wx / image.h
CommitLineData
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"
bf38cbff
JS
21
22#if wxUSE_STREAMS
3d05544e 23#include "wx/stream.h"
bf38cbff 24#endif
01111366
RR
25
26//-----------------------------------------------------------------------------
27// classes
28//-----------------------------------------------------------------------------
29
30class WXDLLEXPORT wxImageHandler;
9838df2c 31#if wxUSE_LIBPNG
01111366 32class WXDLLEXPORT wxPNGHandler;
ac57418f 33#endif
56b9c741
VS
34#if wxUSE_LIBJPEG
35class WXDLLEXPORT wxJPEGHandler;
36#endif
01111366
RR
37class WXDLLEXPORT wxBMPHandler;
38class WXDLLEXPORT wxImage;
39
4bc67cc5
RR
40class WXDLLEXPORT wxBitmap;
41
01111366
RR
42//-----------------------------------------------------------------------------
43// wxImageHandler
44//-----------------------------------------------------------------------------
45
46class WXDLLEXPORT wxImageHandler: public wxObject
47{
48 DECLARE_DYNAMIC_CLASS(wxImageHandler)
49
50public:
51 wxImageHandler() { m_name = ""; m_extension = ""; m_type = 0; }
52
bf38cbff 53#if wxUSE_STREAMS
3d05544e
JS
54 virtual bool LoadFile( wxImage *image, wxInputStream& stream );
55 virtual bool SaveFile( wxImage *image, wxOutputStream& stream );
bf38cbff 56#endif
01111366
RR
57
58 inline void SetName(const wxString& name) { m_name = name; }
59 inline void SetExtension(const wxString& ext) { m_extension = ext; }
60 inline void SetType(long type) { m_type = type; }
61 inline wxString GetName() const { return m_name; }
62 inline wxString GetExtension() const { return m_extension; }
63 inline long GetType() const { return m_type; }
64
65protected:
66 wxString m_name;
67 wxString m_extension;
68 long m_type;
69
70};
71
72//-----------------------------------------------------------------------------
73// wxPNGHandler
74//-----------------------------------------------------------------------------
75
9838df2c 76#if wxUSE_LIBPNG
01111366
RR
77class WXDLLEXPORT wxPNGHandler: public wxImageHandler
78{
79 DECLARE_DYNAMIC_CLASS(wxPNGHandler)
80
81public:
82
fd0eed64
RR
83 inline wxPNGHandler()
84 {
85 m_name = "PNG file";
86 m_extension = "png";
87 m_type = wxBITMAP_TYPE_PNG;
88 };
89
bf38cbff 90#if wxUSE_STREAMS
3d05544e
JS
91 virtual bool LoadFile( wxImage *image, wxInputStream& stream );
92 virtual bool SaveFile( wxImage *image, wxOutputStream& stream );
bf38cbff
JS
93#endif
94
01111366 95};
ac57418f 96#endif
01111366 97
56b9c741
VS
98//-----------------------------------------------------------------------------
99// wxJPEGHandler
100//-----------------------------------------------------------------------------
101
102#ifdef wxUSE_LIBJPEG
103class WXDLLEXPORT wxJPEGHandler: public wxImageHandler
104{
105 DECLARE_DYNAMIC_CLASS(wxJPEGHandler)
106
107public:
108
109 inline wxJPEGHandler()
110 {
111 m_name = "JPEG file";
112 m_extension = "jpg";
113 m_type = wxBITMAP_TYPE_JPEG;
114 };
115
116 virtual bool LoadFile( wxImage *image, wxInputStream& stream );
117 virtual bool SaveFile( wxImage *image, wxOutputStream& stream );
118};
119#endif
120
01111366
RR
121//-----------------------------------------------------------------------------
122// wxBMPHandler
123//-----------------------------------------------------------------------------
124
125class WXDLLEXPORT wxBMPHandler: public wxImageHandler
126{
127 DECLARE_DYNAMIC_CLASS(wxBMPHandler)
128
129public:
130
fd0eed64
RR
131 inline wxBMPHandler()
132 {
133 m_name = "BMP file";
134 m_extension = "bmp";
135 m_type = wxBITMAP_TYPE_BMP;
136 };
01111366 137
bf38cbff 138#if wxUSE_STREAMS
3d05544e 139 virtual bool LoadFile( wxImage *image, wxInputStream& stream );
bf38cbff 140#endif
01111366 141};
fd0eed64 142
01111366
RR
143//-----------------------------------------------------------------------------
144// wxImage
145//-----------------------------------------------------------------------------
146
147class WXDLLEXPORT wxImage: public wxObject
148{
149 DECLARE_DYNAMIC_CLASS(wxImage)
150
151 friend class WXDLLEXPORT wxImageHandler;
152
153public:
154
155 wxImage();
156 wxImage( int width, int height );
157 wxImage( const wxString& name, long type = wxBITMAP_TYPE_PNG );
3d05544e 158 wxImage( wxInputStream& stream, long type = wxBITMAP_TYPE_PNG );
01111366
RR
159
160 wxImage( const wxImage& image );
161 wxImage( const wxImage* image );
4bc67cc5
RR
162
163 // these functions get implemented in /src/(platform)/bitmap.cpp
164 wxImage( const wxBitmap &bitmap );
165 wxBitmap ConvertToBitmap() const;
01111366
RR
166
167 void Create( int width, int height );
168 void Destroy();
169
4bc67cc5
RR
170 wxImage Scale( int width, int height );
171
ef539066
RR
172 // these routines are slow but safe
173 void SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned char b );
174 unsigned char GetRed( int x, int y );
175 unsigned char GetGreen( int x, int y );
176 unsigned char GetBlue( int x, int y );
177
01111366 178 virtual bool LoadFile( const wxString& name, long type = wxBITMAP_TYPE_PNG );
bf38cbff
JS
179
180#if wxUSE_STREAMS
3d05544e 181 virtual bool LoadFile( wxInputStream& stream, long type = wxBITMAP_TYPE_PNG );
bf38cbff
JS
182#endif
183
01111366 184 virtual bool SaveFile( const wxString& name, int type );
bf38cbff
JS
185
186#if wxUSE_STREAMS
3d05544e 187 virtual bool SaveFile( wxOutputStream& stream, int type );
bf38cbff 188#endif
01111366
RR
189
190 bool Ok() const;
191 int GetWidth() const;
192 int GetHeight() const;
193
194 char unsigned *GetData() const;
195 void SetData( char unsigned *data );
196
197 void SetMaskColour( unsigned char r, unsigned char g, unsigned char b );
198 unsigned char GetMaskRed() const;
199 unsigned char GetMaskGreen() const;
200 unsigned char GetMaskBlue() const;
201 void SetMask( bool mask = TRUE );
202 bool HasMask() const;
203
a3ef5bf5 204 inline wxImage& operator = (const wxImage& image)
ce3ed50d
JS
205 { if ((*this) == image)
206 return (*this);
207 Ref(image);
208 return *this; }
209
a3ef5bf5 210 inline bool operator == (const wxImage& image)
01111366
RR
211 { return m_refData == image.m_refData; }
212 inline bool operator != (const wxImage& image)
213 { return m_refData != image.m_refData; }
214
215 static inline wxList& GetHandlers() { return sm_handlers; }
216 static void AddHandler( wxImageHandler *handler );
217 static void InsertHandler( wxImageHandler *handler );
218 static bool RemoveHandler( const wxString& name );
219 static wxImageHandler *FindHandler( const wxString& name );
220 static wxImageHandler *FindHandler( const wxString& extension, long imageType );
221 static wxImageHandler *FindHandler( long imageType );
222
223 static void CleanUpHandlers();
fd0eed64 224 static void InitStandardHandlers();
01111366
RR
225
226protected:
227
228 static wxList sm_handlers;
229
230};
231
232#endif
233 // _WX_IMAGE_H_