Commit a50849ef authored by alice.liu@apple.com's avatar alice.liu@apple.com

Provide API for creating WKImage from CGImageRef

https://bugs.webkit.org/show_bug.cgi?id=56159

Reviewed by Sam Weinig.

Add function for creating a WKImage from CGImage data.
* Shared/API/c/cg/WKImageCG.cpp:
(WKImageCreateFromCGImage): Added. Creates a graphics context for the bitmap-backed image and draws into it. 
* Shared/API/c/cg/WKImageCG.h:



git-svn-id: svn://svn.chromium.org/blink/trunk@81087 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 03752250
2011-03-14 Alice Liu <alice.liu@apple.com>
Reviewed by Sam Weinig.
Provide API for creating WKImage from CGImageRef
https://bugs.webkit.org/show_bug.cgi?id=56159
Add function for creating a WKImage from CGImage data.
* Shared/API/c/cg/WKImageCG.cpp:
(WKImageCreateFromCGImage): Added. Creates a graphics context for the bitmap-backed image and draws into it.
* Shared/API/c/cg/WKImageCG.h:
2011-03-14 Balazs Kelemen <kbalazs@webkit.org>
Reviewed by Adam Roben.
......
......@@ -39,3 +39,12 @@ CGImageRef WKImageCreateCGImage(WKImageRef imageRef)
OwnPtr<GraphicsContext> sourceContext = toImpl(imageRef)->bitmap()->createGraphicsContext();
return CGBitmapContextCreateImage(sourceContext->platformContext());
}
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());
}
......@@ -28,6 +28,7 @@
#include <CoreGraphics/CGImage.h>
#include <WebKit2/WKBase.h>
#include <WebKit2/WKImage.h>
#ifdef __cplusplus
extern "C" {
......@@ -35,6 +36,8 @@ extern "C" {
WK_EXPORT CGImageRef WKImageCreateCGImage(WKImageRef image);
WK_EXPORT WKImageRef WKImageCreateFromCGImage(CGImageRef imageRef, WKImageOptions options);
#ifdef __cplusplus
}
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment