Merged 47990 and 47991 from trunk:
Add wxBitmap constructors and Create methods to allow creating a wxBitmap from an NSBitmapImageRep or NSImage instance. Copyright 2007 Software 2000 Ltd. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@47992 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -125,6 +125,16 @@ wxBitmap::wxBitmap(int w, int h, int d)
|
||||
(void)Create(w, h, d);
|
||||
}
|
||||
|
||||
wxBitmap::wxBitmap(NSImage* cocoaNSImage)
|
||||
{
|
||||
(void) Create(cocoaNSImage);
|
||||
}
|
||||
|
||||
wxBitmap::wxBitmap(NSBitmapImageRep* cocoaNSBitmapImageRep)
|
||||
{
|
||||
(void) Create(cocoaNSBitmapImageRep);
|
||||
}
|
||||
|
||||
wxBitmap::wxBitmap(const void* data, wxBitmapType type, int width, int height, int depth)
|
||||
{
|
||||
(void) Create(data, type, width, height, depth);
|
||||
@@ -348,6 +358,33 @@ bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxBitmap::Create(NSImage* cocoaNSImage)
|
||||
{
|
||||
wxAutoNSAutoreleasePool pool;
|
||||
NSBitmapImageRep *bitmapImageRep = [NSBitmapImageRep imageRepWithData:[cocoaNSImage TIFFRepresentation]];
|
||||
return Create(bitmapImageRep);
|
||||
}
|
||||
|
||||
bool wxBitmap::Create(NSBitmapImageRep *imageRep)
|
||||
{
|
||||
UnRef();
|
||||
m_refData = new wxBitmapRefData;
|
||||
if(imageRep != nil)
|
||||
{
|
||||
M_BITMAPDATA->m_width = [imageRep pixelsWide];
|
||||
M_BITMAPDATA->m_height = [imageRep pixelsHigh];
|
||||
M_BITMAPDATA->m_depth = [imageRep bitsPerPixel];
|
||||
M_BITMAPDATA->m_ok = true;
|
||||
M_BITMAPDATA->m_numColors = 0;
|
||||
M_BITMAPDATA->m_quality = 0;
|
||||
M_BITMAPDATA->m_cocoaNSBitmapImageRep = [imageRep retain];
|
||||
M_BITMAPDATA->m_bitmapMask = NULL;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxBitmap::Create(const void* data, wxBitmapType type, int width, int height, int depth)
|
||||
{
|
||||
UnRef();
|
||||
|
Reference in New Issue
Block a user