summaryrefslogtreecommitdiffstats
path: root/Source/WebKit2/Shared/API/c/cg/WKImageCG.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/Shared/API/c/cg/WKImageCG.cpp')
-rw-r--r--Source/WebKit2/Shared/API/c/cg/WKImageCG.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/Source/WebKit2/Shared/API/c/cg/WKImageCG.cpp b/Source/WebKit2/Shared/API/c/cg/WKImageCG.cpp
index 61b5f17..7af747e 100644
--- a/Source/WebKit2/Shared/API/c/cg/WKImageCG.cpp
+++ b/Source/WebKit2/Shared/API/c/cg/WKImageCG.cpp
@@ -36,6 +36,14 @@ using namespace WebCore;
CGImageRef WKImageCreateCGImage(WKImageRef imageRef)
{
- OwnPtr<GraphicsContext> sourceContext = toImpl(imageRef)->bitmap()->createGraphicsContext();
- return CGBitmapContextCreateImage(sourceContext->platformContext());
+ return toImpl(imageRef)->bitmap()->makeCGImageCopy().leakRef();
+}
+
+WKImageRef WKImageCreateFromCGImage(CGImageRef imageRef, WKImageOptions options)
+{
+ IntSize imageSize(CGImageGetWidth(imageRef), CGImageGetHeight(imageRef));
+ RefPtr<WebImage> webImage = WebImage::create(imageSize, toImageOptions(options));
+ OwnPtr<GraphicsContext> graphicsContext = webImage->bitmap()->createGraphicsContext();
+ CGContextDrawImage(graphicsContext->platformContext(), CGRectMake(0, 0, imageSize.width(), imageSize.height()), imageRef);
+ return toAPI(webImage.release().leakRef());
}