blob: 2d0853fc08a50989ae55587337d65b1f7129f295 [file] [log] [blame]
reed@android.com0d55f1e2008-12-18 19:26:11 +00001#ifndef SkCGUtils_DEFINED
2#define SkCGUtils_DEFINED
3
reed@android.comf2b98d62010-12-20 18:26:13 +00004#include "SkTypes.h"
5
6#ifdef SK_BUILD_FOR_MAC
7 #include <Carbon/Carbon.h>
8#else
9 #include <CoreGraphics/CoreGraphics.h>
10#endif
reed@android.com0d55f1e2008-12-18 19:26:11 +000011
12class SkBitmap;
13
reed@android.com38669c12011-01-03 13:48:50 +000014/**
15 * Create an imageref from the specified bitmap using the specified colorspace.
16 */
17CGImageRef SkCreateCGImageRefWithColorspace(const SkBitmap& bm,
18 CGColorSpaceRef space);
reed@android.com0d55f1e2008-12-18 19:26:11 +000019
reed@android.com38669c12011-01-03 13:48:50 +000020/**
21 * Create an imageref from the specified bitmap using the colorspace
22 * kCGColorSpaceGenericRGB
23 */
reed@android.comad789ee2011-01-03 19:52:17 +000024static CGImageRef SkCreateCGImageRef(const SkBitmap& bm) {
reed@android.com38669c12011-01-03 13:48:50 +000025 return SkCreateCGImageRefWithColorspace(bm, NULL);
26}
27
28/**
29 * Draw the bitmap into the specified CG context. The bitmap will be converted
30 * to a CGImage using the generic RGB colorspace. (x,y) specifies the position
31 * of the top-left corner of the bitmap.
32 */
reed@android.comf2b98d62010-12-20 18:26:13 +000033void SkCGDrawBitmap(CGContextRef, const SkBitmap&, float x, float y);
34
reed@android.com0d55f1e2008-12-18 19:26:11 +000035#endif