reed@android.com | 0d55f1e | 2008-12-18 19:26:11 +0000 | [diff] [blame] | 1 | #ifndef SkCGUtils_DEFINED |
| 2 | #define SkCGUtils_DEFINED |
| 3 | |
reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame] | 4 | #include "SkTypes.h" |
| 5 | |
| 6 | #ifdef SK_BUILD_FOR_MAC |
yangsu@google.com | ccb74ea | 2011-06-21 13:09:32 +0000 | [diff] [blame] | 7 | #include <ApplicationServices/ApplicationServices.h> |
reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame] | 8 | #endif |
reed@android.com | 0d55f1e | 2008-12-18 19:26:11 +0000 | [diff] [blame] | 9 | |
yangsu@google.com | c134f39 | 2011-06-23 22:27:30 +0000 | [diff] [blame^] | 10 | #ifdef SK_BUILD_FOR_IOS |
| 11 | #include <CoreGraphics/CoreGraphics.h> |
| 12 | #endif |
| 13 | |
reed@android.com | 0d55f1e | 2008-12-18 19:26:11 +0000 | [diff] [blame] | 14 | class SkBitmap; |
| 15 | |
reed@android.com | 38669c1 | 2011-01-03 13:48:50 +0000 | [diff] [blame] | 16 | /** |
| 17 | * Create an imageref from the specified bitmap using the specified colorspace. |
reed@google.com | 5a8a131 | 2011-01-05 16:29:02 +0000 | [diff] [blame] | 18 | * If space is NULL, then CGColorSpaceCreateDeviceRGB() is used. |
reed@android.com | 38669c1 | 2011-01-03 13:48:50 +0000 | [diff] [blame] | 19 | */ |
| 20 | CGImageRef SkCreateCGImageRefWithColorspace(const SkBitmap& bm, |
| 21 | CGColorSpaceRef space); |
reed@android.com | 0d55f1e | 2008-12-18 19:26:11 +0000 | [diff] [blame] | 22 | |
reed@android.com | 38669c1 | 2011-01-03 13:48:50 +0000 | [diff] [blame] | 23 | /** |
reed@google.com | 5a8a131 | 2011-01-05 16:29:02 +0000 | [diff] [blame] | 24 | * Create an imageref from the specified bitmap using the colorspace returned |
| 25 | * by CGColorSpaceCreateDeviceRGB() |
reed@android.com | 38669c1 | 2011-01-03 13:48:50 +0000 | [diff] [blame] | 26 | */ |
reed@android.com | 4aaee0a | 2011-01-04 01:29:52 +0000 | [diff] [blame] | 27 | static inline CGImageRef SkCreateCGImageRef(const SkBitmap& bm) { |
reed@android.com | 38669c1 | 2011-01-03 13:48:50 +0000 | [diff] [blame] | 28 | return SkCreateCGImageRefWithColorspace(bm, NULL); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Draw the bitmap into the specified CG context. The bitmap will be converted |
| 33 | * to a CGImage using the generic RGB colorspace. (x,y) specifies the position |
reed@google.com | 5a8a131 | 2011-01-05 16:29:02 +0000 | [diff] [blame] | 34 | * of the top-left corner of the bitmap. The bitmap is converted using the |
| 35 | * colorspace returned by CGColorSpaceCreateDeviceRGB() |
reed@android.com | 38669c1 | 2011-01-03 13:48:50 +0000 | [diff] [blame] | 36 | */ |
reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame] | 37 | void SkCGDrawBitmap(CGContextRef, const SkBitmap&, float x, float y); |
| 38 | |
reed@android.com | 0d55f1e | 2008-12-18 19:26:11 +0000 | [diff] [blame] | 39 | #endif |