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