Direct NSImage drawing
This commit is contained in:
committed by
Vadim Zeitlin
parent
ee8132fea9
commit
3370b76318
@@ -32,6 +32,10 @@ OSStatus WXDLLIMPEXP_CORE wxMacDrawCGImage(
|
|||||||
CGContextRef inContext,
|
CGContextRef inContext,
|
||||||
const CGRect * inBounds,
|
const CGRect * inBounds,
|
||||||
CGImageRef inImage) ;
|
CGImageRef inImage) ;
|
||||||
|
void WXDLLIMPEXP_CORE wxOSXDrawNSImage(
|
||||||
|
CGContextRef inContext,
|
||||||
|
const CGRect * inBounds,
|
||||||
|
WX_NSImage inImage) ;
|
||||||
WX_NSImage WXDLLIMPEXP_CORE wxOSXGetSystemImage(const wxString& name);
|
WX_NSImage WXDLLIMPEXP_CORE wxOSXGetSystemImage(const wxString& name);
|
||||||
WX_NSImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromCGImage( CGImageRef image, double scale = 1.0, bool isTemplate = false);
|
WX_NSImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromCGImage( CGImageRef image, double scale = 1.0, bool isTemplate = false);
|
||||||
WX_NSImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromIconRef( WXHICON iconref );
|
WX_NSImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromIconRef( WXHICON iconref );
|
||||||
|
@@ -280,6 +280,30 @@ CGContextRef WXDLLIMPEXP_CORE wxOSXCreateBitmapContextFromNSImage( WX_NSImage ns
|
|||||||
return hbitmap;
|
return hbitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WXDLLIMPEXP_CORE wxOSXDrawNSImage(
|
||||||
|
CGContextRef inContext,
|
||||||
|
const CGRect * inBounds,
|
||||||
|
WX_NSImage inImage)
|
||||||
|
{
|
||||||
|
if (inImage != nil)
|
||||||
|
{
|
||||||
|
CGContextSaveGState(inContext);
|
||||||
|
CGContextTranslateCTM(inContext, inBounds->origin.x, inBounds->origin.y + inBounds->size.height);
|
||||||
|
CGRect r = *inBounds;
|
||||||
|
r.origin.x = r.origin.y = 0;
|
||||||
|
CGContextScaleCTM(inContext, 1, -1);
|
||||||
|
|
||||||
|
NSGraphicsContext *previousContext = [NSGraphicsContext currentContext];
|
||||||
|
NSGraphicsContext *nsGraphicsContext = [NSGraphicsContext graphicsContextWithGraphicsPort:inContext flipped:NO];
|
||||||
|
[NSGraphicsContext setCurrentContext:nsGraphicsContext];
|
||||||
|
[inImage drawInRect:NSRectFromCGRect(r) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
|
||||||
|
[NSGraphicsContext setCurrentContext:previousContext];
|
||||||
|
|
||||||
|
CGContextRestoreGState(inContext);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
double wxOSXGetMainScreenContentScaleFactor()
|
double wxOSXGetMainScreenContentScaleFactor()
|
||||||
{
|
{
|
||||||
return [[NSScreen mainScreen] backingScaleFactor];
|
return [[NSScreen mainScreen] backingScaleFactor];
|
||||||
|
Reference in New Issue
Block a user