• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef SkCGUtils_DEFINED
2 #define SkCGUtils_DEFINED
3 
4 #include "SkTypes.h"
5 
6 #ifdef SK_BUILD_FOR_MAC
7     #include <Carbon/Carbon.h>
8 #else
9     #include <CoreGraphics/CoreGraphics.h>
10 #endif
11 
12 class SkBitmap;
13 
14 /**
15  *  Create an imageref from the specified bitmap using the specified colorspace.
16  *  If space is NULL, then CGColorSpaceCreateDeviceRGB() is used.
17  */
18 CGImageRef SkCreateCGImageRefWithColorspace(const SkBitmap& bm,
19                                             CGColorSpaceRef space);
20 
21 /**
22  *  Create an imageref from the specified bitmap using the colorspace returned
23  *  by CGColorSpaceCreateDeviceRGB()
24  */
SkCreateCGImageRef(const SkBitmap & bm)25 static inline CGImageRef SkCreateCGImageRef(const SkBitmap& bm) {
26     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
32  *  of the top-left corner of the bitmap. The bitmap is converted using the
33  *  colorspace returned by CGColorSpaceCreateDeviceRGB()
34  */
35 void SkCGDrawBitmap(CGContextRef, const SkBitmap&, float x, float y);
36 
37 #endif
38