* Implement the wxMask copy constructor to retain the source object's

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
This commit is contained in:
David Elliott
2007-07-27 20:57:50 +00:00
parent 77c1fa98ce
commit 319fe1034c
2 changed files with 20 additions and 0 deletions

View File

@@ -43,6 +43,9 @@ public:
// 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);

View File

@@ -519,6 +519,13 @@ wxMask::wxMask(const wxBitmap& bitmap)
Create(bitmap);
}
// Copy constructor
wxMask::wxMask(const wxMask& src)
: wxObject(src)
, m_cocoaNSBitmapImageRep([src.m_cocoaNSBitmapImageRep retain])
{
}
wxMask::~wxMask()
{
[m_cocoaNSBitmapImageRep release];
@@ -528,6 +535,7 @@ wxMask::~wxMask()
bool wxMask::Create(const wxBitmap& bitmap)
{
// TODO
wxLogDebug("Cannot yet create a mask from a mono bitmap");
return FALSE;
}
@@ -536,6 +544,7 @@ bool wxMask::Create(const wxBitmap& bitmap)
bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex)
{
// TODO
wxLogDebug("Cannot yet create a mask from a palette bitmap");
return FALSE;
}
@@ -642,6 +651,14 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
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")); }