1 /////////////////////////////////////////////////////////////////////////////
3 // Author: Vaclav Slavik
5 // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
10 #ifndef __WX_BITMAP_H__
11 #define __WX_BITMAP_H__
18 #include "wx/object.h"
19 #include "wx/string.h"
20 #include "wx/palette.h"
21 #include "wx/gdiobj.h"
24 //-----------------------------------------------------------------------------
26 //-----------------------------------------------------------------------------
28 class WXDLLEXPORT wxMask
;
29 class WXDLLEXPORT wxBitmap
;
30 class WXDLLEXPORT wxImage
;
31 class WXDLLEXPORT wxDC
;
32 class WXDLLEXPORT wxMemoryDC
;
37 //-----------------------------------------------------------------------------
39 //-----------------------------------------------------------------------------
41 class WXDLLEXPORT wxMask
: public wxObject
45 wxMask(const wxBitmap
& bitmap
, const wxColour
& colour
);
46 wxMask(const wxBitmap
& bitmap
, int paletteIndex
);
47 wxMask(const wxBitmap
& bitmap
);
50 bool Create(const wxBitmap
& bitmap
, const wxColour
& colour
);
51 bool Create(const wxBitmap
& bitmap
, int paletteIndex
);
52 bool Create(const wxBitmap
& bitmap
);
57 wxBitmap
*GetBitmap() const { return m_bitmap
; }
60 DECLARE_DYNAMIC_CLASS(wxMask
)
63 //-----------------------------------------------------------------------------
65 //-----------------------------------------------------------------------------
67 class WXDLLEXPORT wxBitmapHandler
: public wxBitmapHandlerBase
70 wxBitmapHandler() : wxBitmapHandlerBase() {}
72 DECLARE_DYNAMIC_CLASS(wxBitmapHandler
)
75 class WXDLLEXPORT wxBitmap
: public wxBitmapBase
79 wxBitmap(int width
, int height
, int depth
= -1);
80 wxBitmap(const char bits
[], int width
, int height
, int depth
= 1);
81 wxBitmap(const char **bits
) { CreateFromXpm(bits
); }
82 wxBitmap(char **bits
) { CreateFromXpm((const char **)bits
); }
83 wxBitmap(const wxBitmap
& bmp
);
84 wxBitmap(const wxString
&filename
, wxBitmapType type
= wxBITMAP_TYPE_RESOURCE
);
85 wxBitmap(const wxImage
& image
, int depth
= -1);
87 wxBitmap
& operator = (const wxBitmap
& bmp
);
88 bool operator == (const wxBitmap
& bmp
) const;
89 bool operator != (const wxBitmap
& bmp
) const;
92 bool Create(int width
, int height
, int depth
= -1);
94 virtual int GetHeight() const;
95 virtual int GetWidth() const;
96 virtual int GetDepth() const;
98 virtual wxImage
ConvertToImage() const;
100 virtual wxMask
*GetMask() const;
101 virtual void SetMask(wxMask
*mask
);
103 virtual wxBitmap
GetSubBitmap(const wxRect
& rect
) const;
105 virtual bool SaveFile(const wxString
&name
, wxBitmapType type
, const wxPalette
*palette
= (wxPalette
*) NULL
) const;
106 virtual bool LoadFile(const wxString
&name
, wxBitmapType type
= wxBITMAP_TYPE_RESOURCE
);
108 virtual wxPalette
*GetPalette() const;
109 virtual void SetPalette(const wxPalette
& palette
);
111 // copies the contents and mask of the given (colour) icon to the bitmap
112 virtual bool CopyFromIcon(const wxIcon
& icon
);
114 static void InitStandardHandlers();
117 virtual void SetHeight(int height
);
118 virtual void SetWidth(int width
);
119 virtual void SetDepth(int depth
);
121 // get underlying native representation:
122 bitmap_t
*GetMGLbitmap_t() const;
125 bool CreateFromXpm(const char **bits
);
127 // creates temporary DC for access to bitmap's data:
128 MGLDevCtx
*CreateTmpDC() const;
129 // sets fg & bg colours for 1bit bitmaps:
130 void SetMonoPalette(const wxColour
& fg
, const wxColour
& bg
);
133 DECLARE_DYNAMIC_CLASS(wxBitmap
)
136 friend class wxMemoryDC
;
139 #endif // __WX_BITMAP_H__