blob: db67edf6e52d3e85bf73b86c387b8aca3d3c6beb [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.
reed@google.com5a8a1312011-01-05 16:29:02 +000016 * If space is NULL, then CGColorSpaceCreateDeviceRGB() is used.
reed@android.com38669c12011-01-03 13:48:50 +000017 */
18CGImageRef SkCreateCGImageRefWithColorspace(const SkBitmap& bm,
19 CGColorSpaceRef space);
reed@android.com0d55f1e2008-12-18 19:26:11 +000020
reed@android.com38669c12011-01-03 13:48:50 +000021/**
reed@google.com5a8a1312011-01-05 16:29:02 +000022 * Create an imageref from the specified bitmap using the colorspace returned
23 * by CGColorSpaceCreateDeviceRGB()
reed@android.com38669c12011-01-03 13:48:50 +000024 */
reed@android.com4aaee0a2011-01-04 01:29:52 +000025static inline CGImageRef SkCreateCGImageRef(const SkBitmap& bm) {
reed@android.com38669c12011-01-03 13:48:50 +000026 return SkCreateCGImageRefWithColorspace(bm, NULL);
27}
28
29/**
30 * Draw the bitmap into the specified CG context. The bitmap will be converted
31 * to a CGImage using the generic RGB colorspace. (x,y) specifies the position
reed@google.com5a8a1312011-01-05 16:29:02 +000032 * of the top-left corner of the bitmap. The bitmap is converted using the
33 * colorspace returned by CGColorSpaceCreateDeviceRGB()
reed@android.com38669c12011-01-03 13:48:50 +000034 */
reed@android.comf2b98d62010-12-20 18:26:13 +000035void SkCGDrawBitmap(CGContextRef, const SkBitmap&, float x, float y);
36
reed@android.com0d55f1e2008-12-18 19:26:11 +000037#endif