summaryrefslogtreecommitdiffstats
path: root/skia/ext/skia_utils_mac.mm
diff options
context:
space:
mode:
Diffstat (limited to 'skia/ext/skia_utils_mac.mm')
-rw-r--r--skia/ext/skia_utils_mac.mm14
1 files changed, 14 insertions, 0 deletions
diff --git a/skia/ext/skia_utils_mac.mm b/skia/ext/skia_utils_mac.mm
index 463fd52..5da38df 100644
--- a/skia/ext/skia_utils_mac.mm
+++ b/skia/ext/skia_utils_mac.mm
@@ -10,6 +10,7 @@
#include "base/scoped_cftyperef.h"
#include "base/scoped_ptr.h"
#include "skia/ext/bitmap_platform_device_mac.h"
+#include "third_party/skia/include/utils/mac/SkCGUtils.h"
namespace gfx {
@@ -165,4 +166,17 @@ SkBitmap NSImageToSkBitmap(NSImage* image, NSSize size, bool is_opaque) {
return bitmap;
}
+NSImage* SkBitmapToNSImage(const SkBitmap& skiaBitmap) {
+ // First convert SkBitmap to CGImageRef.
+ CGImageRef cgimage = SkCreateCGImageRef(skiaBitmap);
+
+ // Now convert to NSImage.
+ NSBitmapImageRep* bitmap = [[[NSBitmapImageRep alloc]
+ initWithCGImage:cgimage] autorelease];
+ CFRelease(cgimage);
+ NSImage* image = [[[NSImage alloc] init] autorelease];
+ [image addRepresentation:bitmap];
+ return image;
+}
+
} // namespace gfx