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