1 /////////////////////////////////////////////////////////////////////////////
3 // Author: Vaclav Slavik
5 // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
9 #ifndef __WX_BITMAP_H__
10 #define __WX_BITMAP_H__
13 #include "wx/object.h"
14 #include "wx/string.h"
15 #include "wx/palette.h"
16 #include "wx/gdiobj.h"
19 //-----------------------------------------------------------------------------
21 //-----------------------------------------------------------------------------
23 class WXDLLEXPORT wxMask
;
24 class WXDLLEXPORT wxBitmap
;
25 class WXDLLEXPORT wxImage
;
26 class WXDLLEXPORT wxDC
;
27 class WXDLLEXPORT wxMemoryDC
;
32 //-----------------------------------------------------------------------------
34 //-----------------------------------------------------------------------------
36 class WXDLLEXPORT wxMask
: public wxObject
40 wxMask(const wxBitmap
& bitmap
, const wxColour
& colour
);
41 wxMask(const wxBitmap
& bitmap
, int paletteIndex
);
42 wxMask(const wxBitmap
& bitmap
);
45 bool Create(const wxBitmap
& bitmap
, const wxColour
& colour
);
46 bool Create(const wxBitmap
& bitmap
, int paletteIndex
);
47 bool Create(const wxBitmap
& bitmap
);
52 wxBitmap
*GetBitmap() const { return m_bitmap
; }
55 DECLARE_DYNAMIC_CLASS(wxMask
)
58 //-----------------------------------------------------------------------------
60 //-----------------------------------------------------------------------------
62 class WXDLLEXPORT wxBitmapHandler
: public wxBitmapHandlerBase
65 wxBitmapHandler() : wxBitmapHandlerBase() {}
67 DECLARE_DYNAMIC_CLASS(wxBitmapHandler
)
70 class WXDLLEXPORT wxBitmap
: public wxBitmapBase
74 wxBitmap(int width
, int height
, int depth
= -1);
75 wxBitmap(const char bits
[], int width
, int height
, int depth
= 1);
76 wxBitmap(const char **bits
) { CreateFromXpm(bits
); }
77 wxBitmap(char **bits
) { CreateFromXpm((const char **)bits
); }
78 wxBitmap(const wxString
&filename
, wxBitmapType type
= wxBITMAP_TYPE_RESOURCE
);
79 wxBitmap(const wxImage
& image
, int depth
= -1);
81 bool operator == (const wxBitmap
& bmp
) const;
82 bool operator != (const wxBitmap
& bmp
) const;
85 bool Create(int width
, int height
, int depth
= -1);
87 virtual int GetHeight() const;
88 virtual int GetWidth() const;
89 virtual int GetDepth() const;
91 virtual wxImage
ConvertToImage() const;
93 virtual wxMask
*GetMask() const;
94 virtual void SetMask(wxMask
*mask
);
96 virtual wxBitmap
GetSubBitmap(const wxRect
& rect
) const;
98 virtual bool SaveFile(const wxString
&name
, wxBitmapType type
, const wxPalette
*palette
= (wxPalette
*) NULL
) const;
99 virtual bool LoadFile(const wxString
&name
, wxBitmapType type
= wxBITMAP_TYPE_RESOURCE
);
101 virtual wxPalette
*GetPalette() const;
102 virtual void SetPalette(const wxPalette
& palette
);
104 // copies the contents and mask of the given (colour) icon to the bitmap
105 virtual bool CopyFromIcon(const wxIcon
& icon
);
107 static void InitStandardHandlers();
110 virtual void SetHeight(int height
);
111 virtual void SetWidth(int width
);
112 virtual void SetDepth(int depth
);
114 // get underlying native representation:
115 bitmap_t
*GetMGLbitmap_t() const;
118 bool CreateFromXpm(const char **bits
);
120 // creates temporary DC for access to bitmap's data:
121 MGLDevCtx
*CreateTmpDC() const;
122 // sets fg & bg colours for 1bit bitmaps:
123 void SetMonoPalette(const wxColour
& fg
, const wxColour
& bg
);
126 DECLARE_DYNAMIC_CLASS(wxBitmap
)
129 friend class wxMemoryDC
;
132 #endif // __WX_BITMAP_H__