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