#import <AppKit/NSImage.h>
#import <AppKit/NSColor.h>
+IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandler, wxBitmapHandlerBase)
+
// ========================================================================
// wxBitmapRefData
// ========================================================================
(void)Create(w, h, d);
}
-wxBitmap::wxBitmap(void *data, wxBitmapType type, int width, int height, int depth)
+wxBitmap::wxBitmap(const void* data, wxBitmapType type, int width, int height, int depth)
{
(void) Create(data, type, width, height, depth);
}
M_BITMAPDATA->m_bitmapMask = mask ;
}
-bool wxBitmap::Ok() const
+bool wxBitmap::IsOk() const
{
return m_refData && M_BITMAPDATA->m_ok;
}
return true;
}
-bool wxBitmap::Create(void *data, wxBitmapType type, int width, int height, int depth)
+bool wxBitmap::Create(const void* data, wxBitmapType type, int width, int height, int depth)
{
UnRef();
return newImage;
}
-bool wxBitmap::CreateFromXpm(const char **xpm)
-{
-#if wxUSE_IMAGE && wxUSE_XPM
- UnRef();
-
- wxCHECK_MSG( xpm, false, wxT("invalid XPM data") );
-
- wxXPMDecoder decoder;
- wxImage img = decoder.ReadData(xpm);
- wxCHECK_MSG( img.Ok(), false, wxT("invalid XPM data") );
-
- *this = wxBitmap(img);
- return true;
-#else
- return false;
-#endif
-}
-
bool wxBitmap::CreateFromImage(const wxImage& image, int depth)
{
UnRef();
{ // TODO
}
-void wxBitmap::UseAlpha()
-{ // TODO
-}
-
// ========================================================================
// wxMask
// ========================================================================
Create(bitmap);
}
+// Copy constructor
+wxMask::wxMask(const wxMask& src)
+: wxObject(src)
+, m_cocoaNSBitmapImageRep([src.m_cocoaNSBitmapImageRep retain])
+{
+}
+
wxMask::~wxMask()
{
[m_cocoaNSBitmapImageRep release];
bool wxMask::Create(const wxBitmap& bitmap)
{
// TODO
+ wxLogDebug("Cannot yet create a mask from a mono bitmap");
return FALSE;
}
bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex)
{
// TODO
+ wxLogDebug("Cannot yet create a mask from a palette bitmap");
return FALSE;
}
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")); }