blob: 4b3e341f4ca3ac4b154f6f5afcdee24d84632a93 [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
yangsu@google.comccb74ea2011-06-21 13:09:32 +00007#include <ApplicationServices/ApplicationServices.h>
reed@android.comf2b98d62010-12-20 18:26:13 +00008#endif
reed@android.com0d55f1e2008-12-18 19:26:11 +00009
yangsu@google.comc134f392011-06-23 22:27:30 +000010#ifdef SK_BUILD_FOR_IOS
11#include <CoreGraphics/CoreGraphics.h>
12#endif
13
reed@android.com0d55f1e2008-12-18 19:26:11 +000014class SkBitmap;
reed@google.com292ade62011-06-28 20:54:03 +000015class SkStream;
reed@android.com0d55f1e2008-12-18 19:26:11 +000016
reed@android.com38669c12011-01-03 13:48:50 +000017/**
18 * Create an imageref from the specified bitmap using the specified colorspace.
reed@google.com5a8a1312011-01-05 16:29:02 +000019 * If space is NULL, then CGColorSpaceCreateDeviceRGB() is used.
reed@android.com38669c12011-01-03 13:48:50 +000020 */
21CGImageRef SkCreateCGImageRefWithColorspace(const SkBitmap& bm,
22 CGColorSpaceRef space);
reed@android.com0d55f1e2008-12-18 19:26:11 +000023
reed@android.com38669c12011-01-03 13:48:50 +000024/**
reed@google.com5a8a1312011-01-05 16:29:02 +000025 * Create an imageref from the specified bitmap using the colorspace returned
26 * by CGColorSpaceCreateDeviceRGB()
reed@android.com38669c12011-01-03 13:48:50 +000027 */
reed@android.com4aaee0a2011-01-04 01:29:52 +000028static inline CGImageRef SkCreateCGImageRef(const SkBitmap& bm) {
reed@android.com38669c12011-01-03 13:48:50 +000029 return SkCreateCGImageRefWithColorspace(bm, NULL);
30}
31
32/**
33 * Draw the bitmap into the specified CG context. The bitmap will be converted
34 * to a CGImage using the generic RGB colorspace. (x,y) specifies the position
reed@google.com5a8a1312011-01-05 16:29:02 +000035 * of the top-left corner of the bitmap. The bitmap is converted using the
36 * colorspace returned by CGColorSpaceCreateDeviceRGB()
reed@android.com38669c12011-01-03 13:48:50 +000037 */
reed@android.comf2b98d62010-12-20 18:26:13 +000038void SkCGDrawBitmap(CGContextRef, const SkBitmap&, float x, float y);
39
reed@google.com292ade62011-06-28 20:54:03 +000040bool SkPDFDocumentToBitmap(SkStream* stream, SkBitmap* output);
41
reed@android.com0d55f1e2008-12-18 19:26:11 +000042#endif