36 #if defined( CINDER_COCOA_TOUCH )
37 #include <CoreGraphics/CoreGraphics.h>
39 #include <ApplicationServices/ApplicationServices.h>
41 #include <CoreFoundation/CoreFoundation.h>
42 #if defined( __OBJC__ )
43 @class NSBitmapImageRep;
47 class NSBitmapImageRep;
52 namespace cinder {
namespace cocoa {
65 operator NSString*
const() {
if( mPtr )
return mPtr.get();
else return 0; }
69 static void safeRelease( NSString *ptr );
71 std::shared_ptr<NSString> mPtr;
81 operator NSData*
const() {
if( mPtr )
return mPtr.get();
else return 0; }
84 static void safeRelease(
const NSData *ptr );
86 std::shared_ptr<NSData> mPtr;
113 #if defined( CINDER_MAC )
117 Surface8u convertNsBitmapDataRep(
const NSBitmapImageRep *rep,
bool assumeOwnership =
false );
147 inline CGSize
createCgSize(
const Vec2i &
s ) { CGSize result; result.width = s.
x; result.height = s.
y;
return result; }
149 inline CGSize
createCgSize(
const Vec2f &
s ) { CGSize result; result.width = s.
x; result.height = s.
y;
return result; }
154 #if defined( CINDER_MAC )
221 virtual SurfaceChannelOrder getChannelOrder(
bool alpha )
const;
222 virtual int32_t getRowBytes(
int requestedWidth,
const SurfaceChannelOrder &sco,
int elementSize )
const;
void safeCocoaRelease(void *nsObject)
Safely release a Cocoa object, testing for null before calling [nsObject release]. Designed to be used as the deleter of a shared_ptr.
Definition: CinderCocoa.mm:103
Base class for defining the properties of a Surface necessary to be interoperable with different APIs...
Definition: Surface.h:76
CGContextRef getWindowContext()
Returns the current CoreGraphics context for the active window. Requires the current Renderer to be a...
Definition: CinderCocoa.mm:141
CFDataRef createCfDataRef(const cinder::Buffer &buffer)
Creates a CFDataRef from a cinder::Buffer buffer. The result does not assume ownership of the data an...
Definition: CinderCocoa.mm:398
Color8u mColorTable[256]
Definition: CinderCocoa.h:179
uint16_t m16BitPackedBlueOffset
Definition: CinderCocoa.h:182
virtual void load(ImageTargetRef target)
Definition: CinderCocoa.mm:503
std::shared_ptr< class ImageTargetCgImage > ImageTargetCgImageRef
Definition: CinderCocoa.h:188
::CGImageRef createCgImage(ImageSourceRef imageSource, ImageTarget::Options=ImageTarget::Options())
Loads an ImageSource into a new CGImageRef. Release the result with ::CGImageRelease.
Definition: CinderCocoa.mm:626
ImageSourceCgImage(::CGImageRef imageRef, ImageSource::Options options)
Retains (and later releases) imageRef.
Definition: CinderCocoa.mm:410
An in-memory representation of an image. Implicitly shared object.
Definition: Surface.h:92
uint8_t * mDataPtr
Definition: CinderCocoa.h:207
GLsizei const GLchar ** string
Definition: GLee.h:2427
std::string convertCfString(CFStringRef str)
Converts a CFStringRef into std::string with UTF8 encoding.
Definition: CinderCocoa.mm:174
Area CgRectToArea(const CGRect &rect)
Converts a CGRect to a cinder::Area.
Definition: CinderCocoa.mm:308
SafeCfString createSafeCfString(const std::string &str)
Converts a std::string into an exception-safe CFString pointer. Assumes UTF8 encoding. The deleter is set to free the string when appropriate.
Definition: CinderCocoa.mm:192
CGSize createCgSize(const Vec2i &s)
Creates a Cocoa CGSize from a cinder::Vec2i.
Definition: CinderCocoa.h:147
virtual void * getRowPointer(int32_t row)
Definition: CinderCocoa.mm:612
ImageSourceCgImageRef createImageSource(::CGImageRef imageRef, ImageSource::Options=ImageSource::Options())
Definition: CinderCocoa.mm:543
T x
Definition: Vector.h:71
Represents an exception-safe Cocoa NSData which behaves like a shared_ptr but can implicitly cast its...
Definition: CinderCocoa.h:75
GLenum target
Definition: GLee.h:13607
Definition: ImageIo.h:151
CFURLRef createCfUrl(const cinder::Url &url)
Converts a cinder::URL into a CFURLRef. User must call CFRelease() to free the result.
Definition: CinderCocoa.mm:206
std::shared_ptr< struct __CFString > SafeCfString
Definition: CinderCocoa.h:54
void flipVertical(SurfaceT< T > *surface)
Definition: Flip.cpp:30
std::shared_ptr< class ImageTarget > ImageTargetRef
Definition: ImageIo.h:42
CGContextRef createCgBitmapContext(const Surface8u &surface)
Creates a CGBitmapContext that represents a cinder::Surface8u. Users must call CGContextRelease() to ...
Definition: CinderCocoa.mm:109
Specifies the in-memory ordering of the channels of a Surface.
Definition: Surface.h:42
Represents an exception-safe NSAutoreleasePool. Replaces the global NSAutoreleasePool for its lifetim...
Definition: CinderCocoa.h:91
virtual void finalize()
Definition: CinderCocoa.mm:617
CFAttributedStringRef createCfAttributedString(const std::string &str, const cinder::Font &font, const ColorA &color)
Converts a std::string to a CFAttributedStringRef with attributes set for font and color...
Definition: CinderCocoa.mm:214
GLenum GLenum GLvoid * row
Definition: GLee.h:1089
::CGBitmapInfo mBitmapInfo
Definition: CinderCocoa.h:205
::CFMutableDataRef mDataRef
Definition: CinderCocoa.h:206
Definition: ImageIo.h:159
static ImageTargetCgImageRef createRef(ImageSourceRef imageSource, ImageTarget::Options options)
Definition: CinderCocoa.mm:551
GLclampf GLclampf GLclampf alpha
Definition: GLee.h:951
Represents an instance of a font at a point size. Implicitly shared object.
Definition: Font.h:63
void safeCfRelease(const CFTypeRef cfRef)
Safely release a CoreFoundation object, testing for null before calling CFRelease. Designed to be used as the deleter of a shared_ptr.
Definition: CinderCocoa.mm:97
SafeNsString()
Definition: CinderCocoa.h:59
GLuint buffer
Definition: GLee.h:2065
::CGImageRef getCgImage() const
Definition: CinderCocoa.h:198
Definition: CinderCocoa.h:166
~ImageTargetCgImage()
Definition: CinderCocoa.mm:605
::CGImageRef mImageRef
Definition: CinderCocoa.h:203
bool mIs16BitPacked
Definition: CinderCocoa.h:178
size_t mBitsPerComponent
Definition: CinderCocoa.h:204
struct CGImage * CGImageRef
Definition: ImageSourceFileQuartz.h:30
CGColorRef createCgColor(const Color &color)
Converts a cinder::Color to CGColor. User must call CGColorRelease() to free the result.
Definition: CinderCocoa.mm:284
Optional parameters passed when creating an Image.
Definition: ImageIo.h:92
T y
Definition: Vector.h:71
SafeNsData()
Definition: CinderCocoa.h:77
size_t mRowBytes
Definition: CinderCocoa.h:204
static ImageSourceCgImageRef createRef(::CGImageRef imageRef, ImageSource::Options options=ImageSource::Options())
Retains (and later releases) imageRef.
Definition: CinderCocoa.mm:405
uint16_t m16BitPackedRedOffset
Definition: CinderCocoa.h:182
virtual ~ImageSourceCgImage()
Definition: CinderCocoa.h:170
Represents an exception-safe Cocoa NSString which behaves like a shared_ptr but can implicitly cast i...
Definition: CinderCocoa.h:57
std::shared_ptr< CGImage > mImageRef
Definition: CinderCocoa.h:180
~SafeNsAutoreleasePool()
Definition: CinderCocoa.mm:92
std::shared_ptr< class ImageSource > ImageSourceRef
Definition: Channel.h:33
size_t mBitsPerPixel
Definition: CinderCocoa.h:204
uint16_t m16BitPackedGreenOffset
Definition: CinderCocoa.h:182
bool mIsIndexed
Definition: CinderCocoa.h:178
void convertCgPath(CGPathRef cgPath, Shape2d *resultShape, bool flipVertical=true)
Converts a CGPathRef to a cinder::Shape2d. If flipVertical then the path will be flipped vertically...
Definition: CinderCocoa.mm:361
GLdouble s
Definition: GLee.h:1378
std::string convertNsString(NSString *str)
Converts a NSString into a std::string with UTF8 encoding.
Definition: CinderCocoa.mm:201
CFStringRef createCfString(const std::string &str)
Converts a std::string into a CFStringRef. Assumes UTF8 encoding. User must call CFRelease() to free ...
Definition: CinderCocoa.mm:186
std::shared_ptr< class ImageSourceCgImage > ImageSourceCgImageRef
Definition: CinderCocoa.h:164
ImageTargetCgImage(ImageSourceRef imageSource, ImageTarget::Options options)
Definition: CinderCocoa.mm:556
SafeNsAutoreleasePool()
Definition: CinderCocoa.mm:83
uint32_t CGBitmapInfo
Definition: ImageTargetFileQuartz.h:31
CGRect createCgRect(const Area &area)
Converts a cinder::Area to a CGRect.
Definition: CinderCocoa.mm:298
Definition: CinderCocoa.h:190
GLuint color
Definition: GLee.h:3198