]> git.saurik.com Git - wxWidgets.git/blame - include/wx/image.h
removed wxITALIC/wxSLANT stuff from wxHTML (no longer neccessary, we have intelligent...
[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
23280650 7// Licence: wxWindows licence
01111366
RR
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"
23280650 21#include "wx/bitmap.h"
bf38cbff
JS
22
23#if wxUSE_STREAMS
b9943f8e 24# include "wx/stream.h"
bf38cbff 25#endif
01111366
RR
26
27//-----------------------------------------------------------------------------
28// classes
29//-----------------------------------------------------------------------------
30
31class WXDLLEXPORT wxImageHandler;
01111366
RR
32class WXDLLEXPORT wxImage;
33
34//-----------------------------------------------------------------------------
35// wxImageHandler
36//-----------------------------------------------------------------------------
37
38class WXDLLEXPORT wxImageHandler: public wxObject
39{
ac0ac824 40 DECLARE_CLASS(wxImageHandler)
23280650 41
01111366
RR
42public:
43 wxImageHandler() { m_name = ""; m_extension = ""; m_type = 0; }
44
bf38cbff 45#if wxUSE_STREAMS
700ec454 46 virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=0 );
deb2fec0 47 virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
8f177c8e 48
700ec454 49 virtual int GetImageCount( wxInputStream& stream );
0828c087 50
995612e2
VZ
51 bool CanRead( wxInputStream& stream ) { return DoCanRead(stream); }
52 bool CanRead( const wxString& name );
8f177c8e 53#endif // wxUSE_STREAMS
01111366 54
995612e2
VZ
55 void SetName(const wxString& name) { m_name = name; }
56 void SetExtension(const wxString& ext) { m_extension = ext; }
57 void SetType(long type) { m_type = type; }
58 void SetMimeType(const wxString& type) { m_mime = type; }
59 wxString GetName() const { return m_name; }
60 wxString GetExtension() const { return m_extension; }
61 long GetType() const { return m_type; }
62 wxString GetMimeType() const { return m_mime; }
9e9ee68e 63
01111366 64protected:
8f177c8e 65#if wxUSE_STREAMS
995612e2 66 virtual bool DoCanRead( wxInputStream& stream ) = 0;
8f177c8e 67#endif // wxUSE_STREAMS
995612e2 68
01111366
RR
69 wxString m_name;
70 wxString m_extension;
9e9ee68e 71 wxString m_mime;
01111366 72 long m_type;
8f177c8e
VZ
73};
74
97fdfcc9 75
01111366
RR
76//-----------------------------------------------------------------------------
77// wxImage
78//-----------------------------------------------------------------------------
79
c9d01afd
GRG
80
81// GRG: Dic/99
82class WXDLLEXPORT wxHNode
83{
84public:
85 unsigned long index;
86 unsigned long value;
87};
88
89
01111366
RR
90class WXDLLEXPORT wxImage: public wxObject
91{
92 DECLARE_DYNAMIC_CLASS(wxImage)
93
94 friend class WXDLLEXPORT wxImageHandler;
95
96public:
97
98 wxImage();
99 wxImage( int width, int height );
deb2fec0
SB
100 wxImage( const wxString& name, long type = wxBITMAP_TYPE_ANY );
101 wxImage( wxInputStream& stream, long type = wxBITMAP_TYPE_ANY );
9e9ee68e
VS
102 wxImage( const wxString& name, const wxString& mimetype );
103 wxImage( wxInputStream& stream, const wxString& mimetype );
104
01111366
RR
105 wxImage( const wxImage& image );
106 wxImage( const wxImage* image );
23280650
VZ
107
108 // these functions get implemented in /src/(platform)/bitmap.cpp
4bc67cc5 109 wxImage( const wxBitmap &bitmap );
ce9a75d2 110 operator wxBitmap() const { return ConvertToBitmap(); }
4bc67cc5 111 wxBitmap ConvertToBitmap() const;
01111366
RR
112
113 void Create( int width, int height );
114 void Destroy();
23280650 115
7b2471a0
SB
116 // return the new image with size width*height
117 wxImage GetSubImage( const wxRect& ) const;
118
ce9a75d2
VZ
119 // return the new image with size width*height
120 wxImage Scale( int width, int height ) const;
121
122 // rescales the image in place
6e807169 123 wxImage& Rescale( int width, int height ) { return *this = Scale(width, height); }
ce9a75d2 124
23280650 125 // these routines are slow but safe
ef539066
RR
126 void SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned char b );
127 unsigned char GetRed( int x, int y );
128 unsigned char GetGreen( int x, int y );
129 unsigned char GetBlue( int x, int y );
23280650 130
87202f78 131 static bool CanRead( const wxString& name );
deb2fec0 132 virtual bool LoadFile( const wxString& name, long type = wxBITMAP_TYPE_ANY );
9e9ee68e 133 virtual bool LoadFile( const wxString& name, const wxString& mimetype );
bf38cbff
JS
134
135#if wxUSE_STREAMS
87202f78 136 static bool CanRead( wxInputStream& stream );
deb2fec0 137 virtual bool LoadFile( wxInputStream& stream, long type = wxBITMAP_TYPE_ANY );
9e9ee68e 138 virtual bool LoadFile( wxInputStream& stream, const wxString& mimetype );
bf38cbff
JS
139#endif
140
01111366 141 virtual bool SaveFile( const wxString& name, int type );
9e9ee68e 142 virtual bool SaveFile( const wxString& name, const wxString& mimetype );
bf38cbff
JS
143
144#if wxUSE_STREAMS
3d05544e 145 virtual bool SaveFile( wxOutputStream& stream, int type );
9e9ee68e 146 virtual bool SaveFile( wxOutputStream& stream, const wxString& mimetype );
bf38cbff 147#endif
01111366
RR
148
149 bool Ok() const;
150 int GetWidth() const;
151 int GetHeight() const;
152
153 char unsigned *GetData() const;
154 void SetData( char unsigned *data );
23280650 155
01111366
RR
156 void SetMaskColour( unsigned char r, unsigned char g, unsigned char b );
157 unsigned char GetMaskRed() const;
158 unsigned char GetMaskGreen() const;
159 unsigned char GetMaskBlue() const;
160 void SetMask( bool mask = TRUE );
161 bool HasMask() const;
162
ce9a75d2
VZ
163 wxImage& operator = (const wxImage& image)
164 {
165 if ( (*this) != image )
ce3ed50d 166 Ref(image);
ce9a75d2
VZ
167 return *this;
168 }
ce3ed50d 169
ce9a75d2 170 bool operator == (const wxImage& image)
01111366 171 { return m_refData == image.m_refData; }
23280650 172 bool operator != (const wxImage& image)
01111366
RR
173 { return m_refData != image.m_refData; }
174
ce9a75d2 175 static wxList& GetHandlers() { return sm_handlers; }
01111366
RR
176 static void AddHandler( wxImageHandler *handler );
177 static void InsertHandler( wxImageHandler *handler );
178 static bool RemoveHandler( const wxString& name );
179 static wxImageHandler *FindHandler( const wxString& name );
180 static wxImageHandler *FindHandler( const wxString& extension, long imageType );
181 static wxImageHandler *FindHandler( long imageType );
9e9ee68e
VS
182 static wxImageHandler *FindHandlerMime( const wxString& mimetype );
183
01111366 184 static void CleanUpHandlers();
fd0eed64 185 static void InitStandardHandlers();
a091d18c 186
c9d01afd 187 // GRG: Dic/99
fb10f04c 188 unsigned long CountColours( unsigned long stopafter = (unsigned long) -1 );
c9d01afd
GRG
189 unsigned long ComputeHistogram( wxHashTable &h );
190
191
01111366
RR
192protected:
193
194 static wxList sm_handlers;
23280650 195
01111366
RR
196};
197
8f493002 198
a091d18c 199extern void WXDLLEXPORT wxInitAllImageHandlers();
b5a4a47d 200
8f493002
VS
201
202//-----------------------------------------------------------------------------
203// wxImage handlers
204//-----------------------------------------------------------------------------
205
206#include "wx/imagbmp.h"
207#include "wx/imagpng.h"
208#include "wx/imaggif.h"
209#include "wx/imagpcx.h"
210#include "wx/imagjpeg.h"
211#include "wx/imagtiff.h"
212#include "wx/imagpnm.h"
213
01111366
RR
214#endif
215 // _WX_IMAGE_H_
9e9ee68e 216