]> git.saurik.com Git - wxWidgets.git/blame - include/wx/image.h
Added wxPGProperty::SetDefaultValue(v), as a shortcut for SetAttribute(DefaultValue, v)
[wxWidgets.git] / include / wx / image.h
CommitLineData
01111366 1/////////////////////////////////////////////////////////////////////////////
155ecd4c 2// Name: wx/image.h
01111366
RR
3// Purpose: wxImage class
4// Author: Robert Roebling
5// RCS-ID: $Id$
6// Copyright: (c) Robert Roebling
65571936 7// Licence: wxWindows licence
01111366
RR
8/////////////////////////////////////////////////////////////////////////////
9
10#ifndef _WX_IMAGE_H_
11#define _WX_IMAGE_H_
12
2ecf902b 13#include "wx/defs.h"
155ecd4c
WS
14
15#if wxUSE_IMAGE
16
01111366
RR
17#include "wx/object.h"
18#include "wx/string.h"
19#include "wx/gdicmn.h"
952ae1e8 20#include "wx/hashmap.h"
bf38cbff
JS
21
22#if wxUSE_STREAMS
b9943f8e 23# include "wx/stream.h"
bf38cbff 24#endif
01111366 25
66f21994
VZ
26// on some systems (Unixware 7.x) index is defined as a macro in the headers
27// which breaks the compilation below
28#undef index
29
1fe7a7c7 30#define wxIMAGE_OPTION_QUALITY wxString(_T("quality"))
fd94e8aa
VS
31#define wxIMAGE_OPTION_FILENAME wxString(_T("FileName"))
32
fe9308c6
VZ
33#define wxIMAGE_OPTION_RESOLUTION wxString(_T("Resolution"))
34#define wxIMAGE_OPTION_RESOLUTIONX wxString(_T("ResolutionX"))
35#define wxIMAGE_OPTION_RESOLUTIONY wxString(_T("ResolutionY"))
36
37#define wxIMAGE_OPTION_RESOLUTIONUNIT wxString(_T("ResolutionUnit"))
38
36abe9d4
VZ
39#define wxIMAGE_OPTION_MAX_WIDTH wxString(_T("MaxWidth"))
40#define wxIMAGE_OPTION_MAX_HEIGHT wxString(_T("MaxHeight"))
41
fe9308c6 42// constants used with wxIMAGE_OPTION_RESOLUTIONUNIT
361f4288
VZ
43//
44// NB: don't change these values, they correspond to libjpeg constants
45enum wxImageResolution
fe9308c6 46{
361f4288
VZ
47 // Resolution not specified
48 wxIMAGE_RESOLUTION_NONE = 0,
49
50 // Resolution specified in inches
fe9308c6 51 wxIMAGE_RESOLUTION_INCHES = 1,
361f4288
VZ
52
53 // Resolution specified in centimeters
fe9308c6
VZ
54 wxIMAGE_RESOLUTION_CM = 2
55};
56
07aaa1a4
RR
57// Constants for wxImage::Scale() for determining the level of quality
58enum
59{
60 wxIMAGE_QUALITY_NORMAL = 0,
61 wxIMAGE_QUALITY_HIGH = 1
62};
63
21dc4be5
VZ
64// alpha channel values: fully transparent, default threshold separating
65// transparent pixels from opaque for a few functions dealing with alpha and
66// fully opaque
67const unsigned char wxIMAGE_ALPHA_TRANSPARENT = 0;
68const unsigned char wxIMAGE_ALPHA_THRESHOLD = 0x80;
69const unsigned char wxIMAGE_ALPHA_OPAQUE = 0xff;
70
01111366
RR
71//-----------------------------------------------------------------------------
72// classes
73//-----------------------------------------------------------------------------
74
b5dbe15d
VS
75class WXDLLIMPEXP_FWD_CORE wxImageHandler;
76class WXDLLIMPEXP_FWD_CORE wxImage;
77class WXDLLIMPEXP_FWD_CORE wxPalette;
01111366 78
6f5d7825
RR
79//-----------------------------------------------------------------------------
80// wxVariant support
81//-----------------------------------------------------------------------------
82
83#if wxUSE_VARIANT
84#include "wx/variant.h"
53a2db12 85DECLARE_VARIANT_OBJECT_EXPORTED(wxImage,WXDLLIMPEXP_CORE)
6f5d7825
RR
86#endif
87
01111366
RR
88//-----------------------------------------------------------------------------
89// wxImageHandler
90//-----------------------------------------------------------------------------
91
53a2db12 92class WXDLLIMPEXP_CORE wxImageHandler: public wxObject
01111366 93{
01111366 94public:
d84afea9 95 wxImageHandler()
e98e625c 96 : m_name(wxEmptyString), m_extension(wxEmptyString), m_mime(), m_type(wxBITMAP_TYPE_INVALID)
d84afea9 97 { }
01111366 98
bf38cbff 99#if wxUSE_STREAMS
7beb59f3
WS
100 virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1 );
101 virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=true );
8f177c8e 102
649d13e8 103 virtual int GetImageCount( wxInputStream& stream );
0828c087 104
39d16996 105 bool CanRead( wxInputStream& stream ) { return CallDoCanRead(stream); }
be25e480 106 bool CanRead( const wxString& name );
8f177c8e 107#endif // wxUSE_STREAMS
01111366 108
be25e480
RR
109 void SetName(const wxString& name) { m_name = name; }
110 void SetExtension(const wxString& ext) { m_extension = ext; }
099c2c7d 111 void SetAltExtensions(const wxArrayString& exts) { m_altExtensions = exts; }
e98e625c 112 void SetType(wxBitmapType type) { m_type = type; }
be25e480 113 void SetMimeType(const wxString& type) { m_mime = type; }
452418c4
PC
114 const wxString& GetName() const { return m_name; }
115 const wxString& GetExtension() const { return m_extension; }
ba4800d3 116 const wxArrayString& GetAltExtensions() const { return m_altExtensions; }
e98e625c 117 wxBitmapType GetType() const { return m_type; }
452418c4 118 const wxString& GetMimeType() const { return m_mime; }
9e9ee68e 119
831b64f3 120#if WXWIN_COMPATIBILITY_2_8
0ddec397
VZ
121 wxDEPRECATED(
122 void SetType(long type) { SetType((wxBitmapType)type); }
123 )
124#endif // WXWIN_COMPATIBILITY_2_8
125
01111366 126protected:
8f177c8e 127#if wxUSE_STREAMS
be25e480 128 virtual bool DoCanRead( wxInputStream& stream ) = 0;
995612e2 129
39d16996
VZ
130 // save the stream position, call DoCanRead() and restore the position
131 bool CallDoCanRead(wxInputStream& stream);
55472691 132#endif // wxUSE_STREAMS
39d16996 133
361f4288
VZ
134 // helper for the derived classes SaveFile() implementations: returns the
135 // values of x- and y-resolution options specified as the image options if
136 // any
137 static wxImageResolution
138 GetResolutionFromOptions(const wxImage& image, int *x, int *y);
139
140
be25e480
RR
141 wxString m_name;
142 wxString m_extension;
ba4800d3 143 wxArrayString m_altExtensions;
be25e480 144 wxString m_mime;
e98e625c 145 wxBitmapType m_type;
aaf46fd6 146
be25e480
RR
147private:
148 DECLARE_CLASS(wxImageHandler)
8f177c8e
VZ
149};
150
01111366 151//-----------------------------------------------------------------------------
952ae1e8 152// wxImageHistogram
01111366
RR
153//-----------------------------------------------------------------------------
154
53a2db12 155class WXDLLIMPEXP_CORE wxImageHistogramEntry
c9d01afd
GRG
156{
157public:
66f21994 158 wxImageHistogramEntry() { index = value = 0; }
c9d01afd
GRG
159 unsigned long index;
160 unsigned long value;
161};
162
952ae1e8
VS
163WX_DECLARE_EXPORTED_HASH_MAP(unsigned long, wxImageHistogramEntry,
164 wxIntegerHash, wxIntegerEqual,
3f5c62f9 165 wxImageHistogramBase);
487659e0 166
53a2db12 167class WXDLLIMPEXP_CORE wxImageHistogram : public wxImageHistogramBase
487659e0
VZ
168{
169public:
170 wxImageHistogram() : wxImageHistogramBase(256) { }
171
172 // get the key in the histogram for the given RGB values
173 static unsigned long MakeKey(unsigned char r,
174 unsigned char g,
175 unsigned char b)
176 {
177 return (r << 16) | (g << 8) | b;
178 }
179
180 // find first colour that is not used in the image and has higher
181 // RGB values than RGB(startR, startG, startB)
182 //
183 // returns true and puts this colour in r, g, b (each of which may be NULL)
184 // on success or returns false if there are no more free colours
185 bool FindFirstUnusedColour(unsigned char *r,
186 unsigned char *g,
187 unsigned char *b,
188 unsigned char startR = 1,
189 unsigned char startG = 0,
190 unsigned char startB = 0 ) const;
191};
952ae1e8
VS
192
193//-----------------------------------------------------------------------------
194// wxImage
195//-----------------------------------------------------------------------------
196
53a2db12 197class WXDLLIMPEXP_CORE wxImage: public wxObject
01111366 198{
01111366 199public:
978d3d36
VZ
200 // red, green and blue are 8 bit unsigned integers in the range of 0..255
201 // We use the identifier RGBValue instead of RGB, since RGB is #defined
202 class RGBValue
203 {
204 public:
205 RGBValue(unsigned char r=0, unsigned char g=0, unsigned char b=0)
206 : red(r), green(g), blue(b) {}
ec85956a 207 unsigned char red;
978d3d36
VZ
208 unsigned char green;
209 unsigned char blue;
210 };
211
212 // hue, saturation and value are doubles in the range 0.0..1.0
213 class HSVValue
214 {
215 public:
216 HSVValue(double h=0.0, double s=0.0, double v=0.0)
217 : hue(h), saturation(s), value(v) {}
ec85956a 218 double hue;
978d3d36
VZ
219 double saturation;
220 double value;
221 };
978d3d36 222
e98e625c 223 wxImage() {}
72a9034b
FM
224 wxImage( int width, int height, bool clear = true )
225 { Create( width, height, clear ); }
226 wxImage( int width, int height, unsigned char* data, bool static_data = false )
227 { Create( width, height, data, static_data ); }
228 wxImage( int width, int height, unsigned char* data, unsigned char* alpha, bool static_data = false )
229 { Create( width, height, data, alpha, static_data ); }
230
231 // ctor variants using wxSize:
232 wxImage( const wxSize& sz, bool clear = true )
233 { Create( sz, clear ); }
234 wxImage( const wxSize& sz, unsigned char* data, bool static_data = false )
235 { Create( sz, data, static_data ); }
236 wxImage( const wxSize& sz, unsigned char* data, unsigned char* alpha, bool static_data = false )
237 { Create( sz, data, alpha, static_data ); }
238
239 wxImage( const wxString& name, wxBitmapType type = wxBITMAP_TYPE_ANY, int index = -1 )
240 { LoadFile( name, type, index ); }
241 wxImage( const wxString& name, const wxString& mimetype, int index = -1 )
242 { LoadFile( name, mimetype, index ); }
243 wxImage( const char* const* xpmData )
244 { Create(xpmData); }
aaf46fd6
VZ
245
246#if wxUSE_STREAMS
72a9034b
FM
247 wxImage( wxInputStream& stream, wxBitmapType type = wxBITMAP_TYPE_ANY, int index = -1 )
248 { LoadFile( stream, type, index ); }
249 wxImage( wxInputStream& stream, const wxString& mimetype, int index = -1 )
250 { LoadFile( stream, mimetype, index ); }
aaf46fd6 251#endif // wxUSE_STREAMS
01111366 252
452418c4 253 bool Create( const char* const* xpmData );
29b7b6ca
PC
254#ifdef __BORLANDC__
255 // needed for Borland 5.5
5c33522f
VZ
256 wxImage( char** xpmData ) { Create(const_cast<const char* const*>(xpmData)); }
257 bool Create( char** xpmData ) { return Create(const_cast<const char* const*>(xpmData)); }
29b7b6ca 258#endif
72a9034b
FM
259
260 bool Create( int width, int height, bool clear = true );
261 bool Create( int width, int height, unsigned char* data, bool static_data = false );
262 bool Create( int width, int height, unsigned char* data, unsigned char* alpha, bool static_data = false );
263
264 // Create() variants using wxSize:
265 bool Create( const wxSize& sz, bool clear = true )
266 { return Create(sz.GetWidth(), sz.GetHeight(), clear); }
267 bool Create( const wxSize& sz, unsigned char* data, bool static_data = false )
268 { return Create(sz.GetWidth(), sz.GetHeight(), data, static_data); }
269 bool Create( const wxSize& sz, unsigned char* data, unsigned char* alpha, bool static_data = false )
270 { return Create(sz.GetWidth(), sz.GetHeight(), data, alpha, static_data); }
271
be25e480 272 void Destroy();
fc3762b5
FM
273
274 // initialize the image data with zeroes
275 void Clear(unsigned char value = 0);
01111366 276
f6bcfd97
BP
277 // creates an identical copy of the image (the = operator
278 // just raises the ref count)
279 wxImage Copy() const;
aaf46fd6 280
be25e480 281 // return the new image with size width*height
b737ad10
RR
282 wxImage GetSubImage( const wxRect& rect) const;
283
284 // Paste the image or part of this image into an image of the given size at the pos
285 // any newly exposed areas will be filled with the rgb colour
2ecf902b 286 // by default if r = g = b = -1 then fill with this image's mask colour or find and
b737ad10 287 // set a suitable mask colour
2ecf902b 288 wxImage Size( const wxSize& size, const wxPoint& pos,
b737ad10 289 int r = -1, int g = -1, int b = -1 ) const;
aaf46fd6 290
f6bcfd97
BP
291 // pastes image into this instance and takes care of
292 // the mask colour and out of bounds problems
aaf46fd6 293 void Paste( const wxImage &image, int x, int y );
23280650 294
be25e480 295 // return the new image with size width*height
07aaa1a4
RR
296 wxImage Scale( int width, int height, int quality = wxIMAGE_QUALITY_NORMAL ) const;
297
298 // box averager and bicubic filters for up/down sampling
299 wxImage ResampleBox(int width, int height) const;
300 wxImage ResampleBicubic(int width, int height) const;
301
302 // blur the image according to the specified pixel radius
24904055
VZ
303 wxImage Blur(int radius) const;
304 wxImage BlurHorizontal(int radius) const;
305 wxImage BlurVertical(int radius) const;
bf78c81c 306
534f0312 307 wxImage ShrinkBy( int xFactor , int yFactor ) const ;
7b2471a0 308
be25e480 309 // rescales the image in place
07aaa1a4 310 wxImage& Rescale( int width, int height, int quality = wxIMAGE_QUALITY_NORMAL ) { return *this = Scale(width, height, quality); }
ce9a75d2 311
b737ad10 312 // resizes the image in place
2ecf902b 313 wxImage& Resize( const wxSize& size, const wxPoint& pos,
b737ad10
RR
314 int r = -1, int g = -1, int b = -1 ) { return *this = Size(size, pos, r, g, b); }
315
7a632f10
JS
316 // Rotates the image about the given point, 'angle' radians.
317 // Returns the rotated image, leaving this image intact.
318 wxImage Rotate(double angle, const wxPoint & centre_of_rotation,
d3b9f782 319 bool interpolating = true, wxPoint * offset_after_rotation = NULL) const;
f6bcfd97 320
7beb59f3
WS
321 wxImage Rotate90( bool clockwise = true ) const;
322 wxImage Mirror( bool horizontally = true ) const;
7a632f10 323
be25e480
RR
324 // replace one colour with another
325 void Replace( unsigned char r1, unsigned char g1, unsigned char b1,
326 unsigned char r2, unsigned char g2, unsigned char b2 );
aaf46fd6 327
ec85956a
JS
328 // Convert to greyscale image. Uses the luminance component (Y) of the image.
329 // The luma value (YUV) is calculated using (R * lr) + (G * lg) + (B * lb), defaults to ITU-T BT.601
330 wxImage ConvertToGreyscale( double lr = 0.299, double lg = 0.587, double lb = 0.114 ) const;
331
ff5ad794
VS
332 // convert to monochrome image (<r,g,b> will be replaced by white,
333 // everything else by black)
f515c25a 334 wxImage ConvertToMono( unsigned char r, unsigned char g, unsigned char b ) const;
ce9a75d2 335
be25e480
RR
336 // these routines are slow but safe
337 void SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned char b );
b737ad10 338 void SetRGB( const wxRect& rect, unsigned char r, unsigned char g, unsigned char b );
f6bcfd97
BP
339 unsigned char GetRed( int x, int y ) const;
340 unsigned char GetGreen( int x, int y ) const;
341 unsigned char GetBlue( int x, int y ) const;
23280650 342
487659e0 343 void SetAlpha(int x, int y, unsigned char alpha);
d30ee785 344 unsigned char GetAlpha(int x, int y) const;
487659e0 345
1f5b2017
VS
346 // find first colour that is not used in the image and has higher
347 // RGB values than <startR,startG,startB>
348 bool FindFirstUnusedColour( unsigned char *r, unsigned char *g, unsigned char *b,
aaf46fd6 349 unsigned char startR = 1, unsigned char startG = 0,
e0a76d8d 350 unsigned char startB = 0 ) const;
1f5b2017 351 // Set image's mask to the area of 'mask' that has <r,g,b> colour
aaf46fd6 352 bool SetMaskFromImage(const wxImage & mask,
1f5b2017 353 unsigned char mr, unsigned char mg, unsigned char mb);
52b64b0a 354
c1099d92
VZ
355 // converts image's alpha channel to mask (choosing mask colour
356 // automatically or using the specified colour for the mask), if it has
357 // any, does nothing otherwise:
21dc4be5 358 bool ConvertAlphaToMask(unsigned char threshold = wxIMAGE_ALPHA_THRESHOLD);
c1099d92
VZ
359 void ConvertAlphaToMask(unsigned char mr, unsigned char mg, unsigned char mb,
360 unsigned char threshold = wxIMAGE_ALPHA_THRESHOLD);
361
ff5ad794 362
6408deed
RR
363 // This method converts an image where the original alpha
364 // information is only available as a shades of a colour
365 // (actually shades of grey) typically when you draw anti-
366 // aliased text into a bitmap. The DC drawinf routines
367 // draw grey values on the black background although they
368 // actually mean to draw white with differnt alpha values.
369 // This method reverses it, assuming a black (!) background
16cba29d 370 // and white text (actually only the red channel is read).
6408deed
RR
371 // The method will then fill up the whole image with the
372 // colour given.
16cba29d 373 bool ConvertColourToAlpha( unsigned char r, unsigned char g, unsigned char b );
6408deed 374
be25e480 375 static bool CanRead( const wxString& name );
e98e625c
VZ
376 static int GetImageCount( const wxString& name, wxBitmapType type = wxBITMAP_TYPE_ANY );
377 virtual bool LoadFile( const wxString& name, wxBitmapType type = wxBITMAP_TYPE_ANY, int index = -1 );
60d43ad8 378 virtual bool LoadFile( const wxString& name, const wxString& mimetype, int index = -1 );
bf38cbff
JS
379
380#if wxUSE_STREAMS
be25e480 381 static bool CanRead( wxInputStream& stream );
e98e625c
VZ
382 static int GetImageCount( wxInputStream& stream, wxBitmapType type = wxBITMAP_TYPE_ANY );
383 virtual bool LoadFile( wxInputStream& stream, wxBitmapType type = wxBITMAP_TYPE_ANY, int index = -1 );
60d43ad8 384 virtual bool LoadFile( wxInputStream& stream, const wxString& mimetype, int index = -1 );
bf38cbff
JS
385#endif
386
45647dcf 387 virtual bool SaveFile( const wxString& name ) const;
e98e625c 388 virtual bool SaveFile( const wxString& name, wxBitmapType type ) const;
e0a76d8d 389 virtual bool SaveFile( const wxString& name, const wxString& mimetype ) const;
bf38cbff
JS
390
391#if wxUSE_STREAMS
e98e625c 392 virtual bool SaveFile( wxOutputStream& stream, wxBitmapType type ) const;
e0a76d8d 393 virtual bool SaveFile( wxOutputStream& stream, const wxString& mimetype ) const;
bf38cbff 394#endif
01111366 395
b7cacb43
VZ
396 bool Ok() const { return IsOk(); }
397 bool IsOk() const;
be25e480
RR
398 int GetWidth() const;
399 int GetHeight() const;
400
c74b07ac
FM
401 wxSize GetSize() const
402 { return wxSize(GetWidth(), GetHeight()); }
403
591d3fa2
VZ
404 // Gets the type of image found by LoadFile or specified with SaveFile
405 wxBitmapType GetType() const;
406
9d1c7e84
VZ
407 // Set the image type, this is normally only called if the image is being
408 // created from data in the given format but not using LoadFile() (e.g.
409 // wxGIFDecoder uses this)
410 void SetType(wxBitmapType type);
411
487659e0
VZ
412 // these functions provide fastest access to wxImage data but should be
413 // used carefully as no checks are done
414 unsigned char *GetData() const;
4013de12
RD
415 void SetData( unsigned char *data, bool static_data=false );
416 void SetData( unsigned char *data, int new_width, int new_height, bool static_data=false );
487659e0
VZ
417
418 unsigned char *GetAlpha() const; // may return NULL!
419 bool HasAlpha() const { return GetAlpha() != NULL; }
4013de12 420 void SetAlpha(unsigned char *alpha = NULL, bool static_data=false);
828f0936 421 void InitAlpha();
5e5437e0 422
21dc4be5
VZ
423 // return true if this pixel is masked or has alpha less than specified
424 // threshold
425 bool IsTransparent(int x, int y,
426 unsigned char threshold = wxIMAGE_ALPHA_THRESHOLD) const;
427
5e5437e0 428 // Mask functions
be25e480 429 void SetMaskColour( unsigned char r, unsigned char g, unsigned char b );
b737ad10
RR
430 // Get the current mask colour or find a suitable colour
431 // returns true if using current mask colour
432 bool GetOrFindMaskColour( unsigned char *r, unsigned char *g, unsigned char *b ) const;
be25e480
RR
433 unsigned char GetMaskRed() const;
434 unsigned char GetMaskGreen() const;
435 unsigned char GetMaskBlue() const;
7beb59f3 436 void SetMask( bool mask = true );
be25e480
RR
437 bool HasMask() const;
438
d275c7eb 439#if wxUSE_PALETTE
5e5437e0
JS
440 // Palette functions
441 bool HasPalette() const;
442 const wxPalette& GetPalette() const;
443 void SetPalette(const wxPalette& palette);
d275c7eb 444#endif // wxUSE_PALETTE
5e5437e0
JS
445
446 // Option functions (arbitrary name/value mapping)
447 void SetOption(const wxString& name, const wxString& value);
448 void SetOption(const wxString& name, int value);
449 wxString GetOption(const wxString& name) const;
450 int GetOptionInt(const wxString& name) const;
451 bool HasOption(const wxString& name) const;
3f4fc796 452
e0a76d8d 453 unsigned long CountColours( unsigned long stopafter = (unsigned long) -1 ) const;
952ae1e8
VS
454
455 // Computes the histogram of the image and fills a hash table, indexed
456 // with integer keys built as 0xRRGGBB, containing wxImageHistogramEntry
bf78c81c
RD
457 // objects. Each of them contains an 'index' (useful to build a palette
458 // with the image colours) and a 'value', which is the number of pixels
952ae1e8
VS
459 // in the image with that colour.
460 // Returned value: # of entries in the histogram
e0a76d8d 461 unsigned long ComputeHistogram( wxImageHistogram &h ) const;
be25e480 462
978d3d36
VZ
463 // Rotates the hue of each pixel of the image. angle is a double in the range
464 // -1.0..1.0 where -1.0 is -360 degrees and 1.0 is 360 degrees
465 void RotateHue(double angle);
978d3d36 466
be25e480
RR
467 static wxList& GetHandlers() { return sm_handlers; }
468 static void AddHandler( wxImageHandler *handler );
469 static void InsertHandler( wxImageHandler *handler );
470 static bool RemoveHandler( const wxString& name );
471 static wxImageHandler *FindHandler( const wxString& name );
e98e625c
VZ
472 static wxImageHandler *FindHandler( const wxString& extension, wxBitmapType imageType );
473 static wxImageHandler *FindHandler( wxBitmapType imageType );
9e0560c1 474
be25e480
RR
475 static wxImageHandler *FindHandlerMime( const wxString& mimetype );
476
939fadc8
JS
477 static wxString GetImageExtWildcard();
478
be25e480
RR
479 static void CleanUpHandlers();
480 static void InitStandardHandlers();
c9d01afd 481
978d3d36
VZ
482 static HSVValue RGBtoHSV(const RGBValue& rgb);
483 static RGBValue HSVtoRGB(const HSVValue& hsv);
978d3d36 484
831b64f3 485#if WXWIN_COMPATIBILITY_2_8
70bf3295
SC
486 wxDEPRECATED_CONSTRUCTOR(
487 wxImage(const wxString& name, long type, int index = -1)
0ddec397
VZ
488 {
489 LoadFile(name, (wxBitmapType)type, index);
490 }
491 )
492
493#if wxUSE_STREAMS
70bf3295
SC
494 wxDEPRECATED_CONSTRUCTOR(
495 wxImage(wxInputStream& stream, long type, int index = -1)
0ddec397
VZ
496 {
497 LoadFile(stream, (wxBitmapType)type, index);
498 }
499 )
500
501 wxDEPRECATED(
502 bool LoadFile(wxInputStream& stream, long type, int index = -1)
503 {
504 return LoadFile(stream, (wxBitmapType)type, index);
505 }
506 )
507
508 wxDEPRECATED(
509 bool SaveFile(wxOutputStream& stream, long type) const
510 {
511 return SaveFile(stream, (wxBitmapType)type);
512 }
513 )
514#endif // wxUSE_STREAMS
515
9e0560c1
VZ
516 wxDEPRECATED(
517 bool LoadFile(const wxString& name, long type, int index = -1)
518 {
519 return LoadFile(name, (wxBitmapType)type, index);
520 }
521 )
522
0ddec397
VZ
523 wxDEPRECATED(
524 bool SaveFile(const wxString& name, long type) const
525 {
526 return SaveFile(name, (wxBitmapType)type);
527 }
528 )
529
530 wxDEPRECATED(
531 static wxImageHandler *FindHandler(const wxString& ext, long type)
532 {
533 return FindHandler(ext, (wxBitmapType)type);
534 }
535 )
536
9e0560c1
VZ
537 wxDEPRECATED(
538 static wxImageHandler *FindHandler(long imageType)
539 {
540 return FindHandler((wxBitmapType)imageType);
541 }
542 )
543#endif // WXWIN_COMPATIBILITY_2_8
978d3d36 544
01111366 545protected:
5e5437e0 546 static wxList sm_handlers;
01111366 547
5644ac46
VZ
548 // return the index of the point with the given coordinates or -1 if the
549 // image is invalid of the coordinates are out of range
550 //
551 // note that index must be multiplied by 3 when using it with RGB array
552 long XYToIndex(int x, int y) const;
553
a0f81e9f
PC
554 virtual wxObjectRefData* CreateRefData() const;
555 virtual wxObjectRefData* CloneRefData(const wxObjectRefData* data) const;
556
be25e480 557private:
b5dbe15d 558 friend class WXDLLIMPEXP_FWD_CORE wxImageHandler;
23280650 559
591d3fa2
VZ
560#if wxUSE_STREAMS
561 // read the image from the specified stream updating image type if
562 // successful
563 bool DoLoad(wxImageHandler& handler, wxInputStream& stream, int index);
564
565 // write the image to the specified stream and also update the image type
566 // if successful
567 bool DoSave(wxImageHandler& handler, wxOutputStream& stream) const;
568#endif // wxUSE_STREAMS
569
be25e480 570 DECLARE_DYNAMIC_CLASS(wxImage)
01111366
RR
571};
572
8f493002 573
53a2db12 574extern void WXDLLIMPEXP_CORE wxInitAllImageHandlers();
b5a4a47d 575
53a2db12 576extern WXDLLIMPEXP_DATA_CORE(wxImage) wxNullImage;
8f493002
VS
577
578//-----------------------------------------------------------------------------
579// wxImage handlers
580//-----------------------------------------------------------------------------
581
582#include "wx/imagbmp.h"
583#include "wx/imagpng.h"
584#include "wx/imaggif.h"
585#include "wx/imagpcx.h"
586#include "wx/imagjpeg.h"
3af706cc 587#include "wx/imagtga.h"
8f493002
VS
588#include "wx/imagtiff.h"
589#include "wx/imagpnm.h"
775c6f0c 590#include "wx/imagxpm.h"
4b6b4dfc 591#include "wx/imagiff.h"
775c6f0c
VS
592
593#endif // wxUSE_IMAGE
8f493002 594
01111366
RR
595#endif
596 // _WX_IMAGE_H_