m_cocoaNSBitmapImageRep (fixes multiple release bug).
* Add some debug messages for unimplemented wxMask::Create overloads.
* Implement mask creation w/ key color from 8-bpp grayscale bitmap.
This makes the mask image in the drawing sample's mask page work.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47757
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
// Construct a mask from a mono bitmap (copies the bitmap).
wxMask(const wxBitmap& bitmap);
// Construct a mask from a mono bitmap (copies the bitmap).
wxMask(const wxBitmap& bitmap);
+ // Copy constructor
+ wxMask(const wxMask& src);
+
virtual ~wxMask();
bool Create(const wxBitmap& bitmap, const wxColour& colour);
virtual ~wxMask();
bool Create(const wxBitmap& bitmap, const wxColour& colour);
+// Copy constructor
+wxMask::wxMask(const wxMask& src)
+: wxObject(src)
+, m_cocoaNSBitmapImageRep([src.m_cocoaNSBitmapImageRep retain])
+{
+}
+
wxMask::~wxMask()
{
[m_cocoaNSBitmapImageRep release];
wxMask::~wxMask()
{
[m_cocoaNSBitmapImageRep release];
bool wxMask::Create(const wxBitmap& bitmap)
{
// TODO
bool wxMask::Create(const wxBitmap& bitmap)
{
// TODO
+ wxLogDebug("Cannot yet create a mask from a mono bitmap");
bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex)
{
// TODO
bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex)
{
// TODO
+ wxLogDebug("Cannot yet create a mask from a palette bitmap");
wxCHECK_MSG(wxMask_CreateFromBitmapData(pixelData, colour, dstData),
false, wxT("Unable to access raw data"));
}
wxCHECK_MSG(wxMask_CreateFromBitmapData(pixelData, colour, dstData),
false, wxT("Unable to access raw data"));
}
+ else if([srcBitmapRep bitsPerPixel]==8 && [srcBitmapRep bitsPerSample]==8 && [srcBitmapRep samplesPerPixel]==1 && [srcBitmapRep hasAlpha]==NO)
+ // 8-bpp Grayscale, no alpha
+ { // Force all RGB to access the same grayscale component
+ typedef wxPixelFormat<unsigned char,8,0,0,0> PixelFormat;
+ wxPixelData<wxBitmap,PixelFormat> pixelData(const_cast<wxBitmap&>(bitmap));
+ wxCHECK_MSG(wxMask_CreateFromBitmapData(pixelData, colour, dstData),
+ false, wxT("Unable to access raw data"));
+ }
else
{ wxCHECK_MSG(false,false,wxT("Unimplemented pixel format")); }
else
{ wxCHECK_MSG(false,false,wxT("Unimplemented pixel format")); }