aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/mac
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2016-12-21 12:01:12 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-12-21 17:38:18 +0000
commit463c848f3b63b52e3834e405ff11fd1e653ed271 (patch)
tree7b1b0e7f829f1f3d838f3c42307e6eed2ed3c6d0 /src/utils/mac
parentbde428513ff3bd98a3d4f1c66ac779411233f817 (diff)
helper to convert CGImage -> SkImage
BUG=skia: Change-Id: I07e0b8fe510d34ab541de7572cb6775478527624 Reviewed-on: https://skia-review.googlesource.com/6386 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'src/utils/mac')
-rw-r--r--src/utils/mac/SkCreateCGImageRef.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/utils/mac/SkCreateCGImageRef.cpp b/src/utils/mac/SkCreateCGImageRef.cpp
index d9cdb86e49..1b7e12bde5 100644
--- a/src/utils/mac/SkCreateCGImageRef.cpp
+++ b/src/utils/mac/SkCreateCGImageRef.cpp
@@ -212,9 +212,9 @@ SK_API bool SkCopyPixelsFromCGImage(const SkImageInfo& info, size_t rowBytes, vo
return true;
}
-bool SkCreateBitmapFromCGImage(SkBitmap* dst, CGImageRef image, SkISize* scaleToFit) {
- const int width = scaleToFit ? scaleToFit->width() : SkToInt(CGImageGetWidth(image));
- const int height = scaleToFit ? scaleToFit->height() : SkToInt(CGImageGetHeight(image));
+bool SkCreateBitmapFromCGImage(SkBitmap* dst, CGImageRef image) {
+ const int width = SkToInt(CGImageGetWidth(image));
+ const int height = SkToInt(CGImageGetHeight(image));
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
SkBitmap tmp;
@@ -245,4 +245,14 @@ bool SkCreateBitmapFromCGImage(SkBitmap* dst, CGImageRef image, SkISize* scaleTo
return true;
}
+sk_sp<SkImage> SkMakeImageFromCGImage(CGImageRef src) {
+ SkBitmap bm;
+ if (!SkCreateBitmapFromCGImage(&bm, src)) {
+ return nullptr;
+ }
+
+ bm.setImmutable();
+ return SkImage::MakeFromBitmap(bm);
+}
+
#endif//defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)