Add wxBitmap::GetNSImage() which creates an autoreleased NSImage either
with or without the bitmap mask applied. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24874 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -148,6 +148,7 @@ public:
|
||||
// wxCocoa
|
||||
WX_NSBitmapImageRep GetNSBitmapImageRep();
|
||||
void SetNSBitmapImageRep(WX_NSBitmapImageRep bitmapImageRep);
|
||||
WX_NSImage GetNSImage(bool useMask) const;
|
||||
|
||||
static void InitStandardHandlers() { }
|
||||
static void CleanUpHandlers() { }
|
||||
|
@@ -27,6 +27,7 @@
|
||||
|
||||
#import <AppKit/NSBitmapImageRep.h>
|
||||
#import <AppKit/NSGraphics.h>
|
||||
#import <AppKit/NSImage.h>
|
||||
|
||||
// ========================================================================
|
||||
// wxBitmapRefData
|
||||
@@ -145,6 +146,27 @@ WX_NSBitmapImageRep wxBitmap::GetNSBitmapImageRep()
|
||||
return M_BITMAPDATA->m_cocoaNSBitmapImageRep;
|
||||
}
|
||||
|
||||
WX_NSImage wxBitmap::GetNSImage(bool useMask) const
|
||||
{
|
||||
if(!Ok())
|
||||
return nil;
|
||||
NSImage *nsimage = [[[NSImage alloc]
|
||||
initWithSize:NSMakeSize(GetWidth(), GetHeight())] autorelease];
|
||||
if(!nsimage)
|
||||
return nil;
|
||||
[nsimage addRepresentation: M_BITMAPDATA->m_cocoaNSBitmapImageRep];
|
||||
if(useMask && GetMask())
|
||||
{
|
||||
NSImage *maskImage = [[NSImage alloc]
|
||||
initWithSize:NSMakeSize(GetWidth(), GetHeight())];
|
||||
[maskImage addRepresentation: GetMask()->GetNSBitmapImageRep()];
|
||||
[nsimage lockFocus];
|
||||
[maskImage compositeToPoint:NSZeroPoint operation:NSCompositeDestinationIn];
|
||||
[nsimage unlockFocus];
|
||||
}
|
||||
return nsimage;
|
||||
}
|
||||
|
||||
void wxBitmap::SetNSBitmapImageRep(WX_NSBitmapImageRep bitmapImageRep)
|
||||
{
|
||||
if(!M_BITMAPDATA)
|
||||
|
Reference in New Issue
Block a user