]>
git.saurik.com Git - wxWidgets.git/blob - src/generic/mask.cpp
d5fe5cbff7c0b41fa32639a2fe622b7ae06ac624
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/generic/mask.cpp
3 // Purpose: generic wxMask implementation
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
27 #include "wx/bitmap.h"
31 #if wxUSE_GENERIC_MASK
33 // ============================================================================
34 // wxMask implementation
35 // ============================================================================
37 IMPLEMENT_DYNAMIC_CLASS(wxMask
, wxObject
)
39 void wxMask::FreeData()
41 m_bitmap
= wxNullBitmap
;
44 bool wxMask::InitFromColour(const wxBitmap
& bitmap
, const wxColour
& colour
)
47 const wxColour
clr(bitmap
.QuantizeColour(colour
));
49 wxImage
imgSrc(bitmap
.ConvertToImage());
50 imgSrc
.SetMask(false);
51 wxImage
image(imgSrc
.ConvertToMono(clr
.Red(), clr
.Green(), clr
.Blue()));
55 m_bitmap
= wxBitmap(image
, 1);
57 return m_bitmap
.IsOk();
63 #endif // wxUSE_IMAGE/!wxUSE_IMAGE
66 bool wxMask::InitFromMonoBitmap(const wxBitmap
& bitmap
)
68 wxCHECK_MSG( bitmap
.IsOk(), false, wxT("Invalid bitmap") );
69 wxCHECK_MSG( bitmap
.GetDepth() == 1, false, wxT("Cannot create mask from colour bitmap") );
76 #endif // wxUSE_GENERIC_MASK