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 wxBitmap
& bmp
);
79 wxBitmap(const wxString
&filename
, wxBitmapType type
= wxBITMAP_TYPE_RESOURCE
);
80 wxBitmap(const wxImage
& image
, int depth
= -1);
82 wxBitmap
& operator = (const wxBitmap
& bmp
);
83 bool operator == (const wxBitmap
& bmp
) const;
84 bool operator != (const wxBitmap
& bmp
) const;
87 bool Create(int width
, int height
, int depth
= -1);
89 virtual int GetHeight() const;
90 virtual int GetWidth() const;
91 virtual int GetDepth() const;
93 virtual wxImage
ConvertToImage() const;
95 virtual wxMask
*GetMask() const;
96 virtual void SetMask(wxMask
*mask
);
98 virtual wxBitmap
GetSubBitmap(const wxRect
& rect
) const;
100 virtual bool SaveFile(const wxString
&name
, wxBitmapType type
, const wxPalette
*palette
= (wxPalette
*) NULL
) const;
101 virtual bool LoadFile(const wxString
&name
, wxBitmapType type
= wxBITMAP_TYPE_RESOURCE
);
103 virtual wxPalette
*GetPalette() const;
104 virtual void SetPalette(const wxPalette
& palette
);
106 // copies the contents and mask of the given (colour) icon to the bitmap
107 virtual bool CopyFromIcon(const wxIcon
& icon
);
109 static void InitStandardHandlers();
112 virtual void SetHeight(int height
);
113 virtual void SetWidth(int width
);
114 virtual void SetDepth(int depth
);
116 // get underlying native representation:
117 bitmap_t
*GetMGLbitmap_t() const;
120 bool CreateFromXpm(const char **bits
);
122 // creates temporary DC for access to bitmap's data:
123 MGLDevCtx
*CreateTmpDC() const;
124 // sets fg & bg colours for 1bit bitmaps:
125 void SetMonoPalette(const wxColour
& fg
, const wxColour
& bg
);
128 DECLARE_DYNAMIC_CLASS(wxBitmap
)
131 friend class wxMemoryDC
;
134 #endif // __WX_BITMAP_H__