Changeset 81087 in webkit


Ignore:
Timestamp:
Mar 14, 2011, 5:48:45 PM (14 years ago)
Author:
alice.liu@apple.com
Message:

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:
Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r81084 r81087  
     12011-03-14  Alice Liu  <alice.liu@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Provide API for creating WKImage from CGImageRef
     6        https://bugs.webkit.org/show_bug.cgi?id=56159
     7
     8        Add function for creating a WKImage from CGImage data.
     9        * Shared/API/c/cg/WKImageCG.cpp:
     10        (WKImageCreateFromCGImage): Added. Creates a graphics context for the bitmap-backed image and draws into it.
     11        * Shared/API/c/cg/WKImageCG.h:
     12
    1132011-03-14  Balazs Kelemen  <kbalazs@webkit.org>
    214
  • trunk/Source/WebKit2/Shared/API/c/cg/WKImageCG.cpp

    r76916 r81087  
    4040    return CGBitmapContextCreateImage(sourceContext->platformContext());
    4141}
     42
     43WKImageRef WKImageCreateFromCGImage(CGImageRef imageRef, WKImageOptions options)
     44{
     45    IntSize imageSize(CGImageGetWidth(imageRef), CGImageGetHeight(imageRef));
     46    RefPtr<WebImage> webImage = WebImage::create(imageSize, toImageOptions(options));
     47    OwnPtr<GraphicsContext> graphicsContext = webImage->bitmap()->createGraphicsContext();
     48    CGContextDrawImage(graphicsContext->platformContext(), CGRectMake(0, 0, imageSize.width(), imageSize.height()), imageRef);
     49    return toAPI(webImage.release().leakRef());
     50}
  • trunk/Source/WebKit2/Shared/API/c/cg/WKImageCG.h

    r74698 r81087  
    2929#include <CoreGraphics/CGImage.h>
    3030#include <WebKit2/WKBase.h>
     31#include <WebKit2/WKImage.h>
    3132
    3233#ifdef __cplusplus
     
    3637WK_EXPORT CGImageRef WKImageCreateCGImage(WKImageRef image);
    3738
     39WK_EXPORT WKImageRef WKImageCreateFromCGImage(CGImageRef imageRef, WKImageOptions options);
     40
    3841#ifdef __cplusplus
    3942}
Note: See TracChangeset for help on using the changeset viewer.