cinder::cocoa Namespace Reference

Classes

class  SafeNsString
 Represents an exception-safe Cocoa NSString which behaves like a shared_ptr but can implicitly cast itself to NSString*. More...
class  SafeNsData
 Represents an exception-safe Cocoa NSData which behaves like a shared_ptr but can implicitly cast itself to NSData*. More...
class  ImageSourceCgImage
class  ImageTargetCgImage
class  SafeUiImage
 A class which encapsulate a UIImage and an associated CGImageRef in order to work around memory ownership ambiguities in Cocoa Touch. More...

Typedefs

typedef shared_ptr< const
struct __CFString > 
SafeCfString
typedef shared_ptr< class
ImageSourceCgImage
ImageSourceCgImageRef
typedef shared_ptr< class
ImageTargetCgImage
ImageTargetCgImageRef

Functions

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.
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.
CGContextRef createCgBitmapContext (const Surface8u &surface)
 Creates a CGBitmapContext that represents a cinder::Surface8u. Users must call CGContextRelease() to free the result.
Surface8u convertNsBitmapDataRep (const NSBitmapImageRep *rep, bool assumeOwnership=false)
 Converts an NSBitmapImageRep into a cinder::Surface8u If assumeOwnership the result will take ownership of rep and will destroy it upon the Surface's own destruction automatically.
std::string convertCfString (CFStringRef str)
 Converts a CFStringRef into std::string with UTF8 encoding.
CFStringRef createCfString (const std::string &str)
 Converts a std::string into a CFStringRef. Assumes UTF8 encoding. User must call CFRelease() to free the result.
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.
std::string convertNsString (NSString *str)
 Converts a NSString into a std::string with UTF8 encoding.
CFURLRef createCfUrl (const cinder::Url &url)
 Converts a cinder::URL into a CFURLRef. User mus call CFRelease() to free the result.
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. Assumes UTF8 encoding. User must call CFRelease() to free the result.
CGColorRef createCgColor (const Color &color)
 Converts a cinder::Color to CGColor. User must call CGColorRelease() to free the result.
CGColorRef createCgColor (const ColorA &color)
 Converts a cinder::ColorA to CGColor. User must call CGColorRelease() to free the result.
CGRect createCgRect (const Area &area)
 Converts a cinder::Area to a CGRect.
Area CgRectToArea (const CGRect &rect)
 Converts a CGRect to a cinder::Area.
CGSize createCgSize (const Vec2i &s)
 Creates a Cocoa CGSize from a cinder::Vec2i.
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.
int getCvPixelFormatTypeFromSurfaceChannelOrder (const SurfaceChannelOrder &sco)
 Translates a cinder::SurfaceChannelOrder into the pixel formats of a CoreVideo buffer.
CFDataRef createCfDataRef (const cinder::Buffer &buffer)
 Creates a CFDataRef from a cinder::Buffer buffer. The result does not assume ownership of the data and should be freed using CFRelease().
ImageSourceCgImageRef createImageSource (::CGImageRef imageRef)
::CGImageRef createCgImage (ImageSourceRef imageSource)
 Loads an ImageSource into a new CGImageRef. Release the result with CGImageRelease.
Surface8u convertUiImage (UIImage *uiImage, bool assumeOwnership=false)
 Converts a UIImage* into a cinder::Surface8u If assumeOwnership the result will increment the retain count on construction and decrement it upon the its own destruction.
SafeUiImage createUiImage (const ImageSourceRef imageSource)
void writeToSavedPhotosAlbum (const ImageSourceRef imageSource)
 Writes an image to the device's Photo Album.

Typedef Documentation

typedef shared_ptr<const struct __CFString> cinder::cocoa::SafeCfString

Function Documentation

void cinder::cocoa::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.

void cinder::cocoa::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.

CGContextRef cinder::cocoa::createCgBitmapContext ( const Surface8u &  surface  ) 

Creates a CGBitmapContext that represents a cinder::Surface8u. Users must call CGContextRelease() to free the result.

Note:
CGBitmapContexts only support premultiplied alpha
Surface8u cinder::cocoa::convertNsBitmapDataRep ( const NSBitmapImageRep *  rep,
bool  assumeOwnership = false 
)

Converts an NSBitmapImageRep into a cinder::Surface8u If assumeOwnership the result will take ownership of rep and will destroy it upon the Surface's own destruction automatically.

Returns:
a Surface8u which wraps the NSBitmapImageRep but does not own the data.
std::string cinder::cocoa::convertCfString ( CFStringRef  str  ) 

Converts a CFStringRef into std::string with UTF8 encoding.

CFStringRef cinder::cocoa::createCfString ( const std::string &  str  ) 

Converts a std::string into a CFStringRef. Assumes UTF8 encoding. User must call CFRelease() to free the result.

SafeCfString cinder::cocoa::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.

std::string cinder::cocoa::convertNsString ( NSString *  str  ) 

Converts a NSString into a std::string with UTF8 encoding.

CFURLRef cinder::cocoa::createCfUrl ( const cinder::Url url  ) 

Converts a cinder::URL into a CFURLRef. User mus call CFRelease() to free the result.

CFAttributedStringRef cinder::cocoa::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. Assumes UTF8 encoding. User must call CFRelease() to free the result.

CGColorRef cinder::cocoa::createCgColor ( const Color &  color  ) 

Converts a cinder::Color to CGColor. User must call CGColorRelease() to free the result.

CGColorRef cinder::cocoa::createCgColor ( const ColorA &  color  ) 

Converts a cinder::ColorA to CGColor. User must call CGColorRelease() to free the result.

CGRect cinder::cocoa::createCgRect ( const Area &  area  ) 

Converts a cinder::Area to a CGRect.

Area cinder::cocoa::CgRectToArea ( const CGRect &  rect  ) 

Converts a CGRect to a cinder::Area.

CGSize cinder::cocoa::createCgSize ( const Vec2i &  s  ) 

Creates a Cocoa CGSize from a cinder::Vec2i.

Creates a Cocoa CGSize from a cinder::Vec2f.

void cinder::cocoa::convertCgPath ( CGPathRef  cgPath,
cinder::Shape2d resultShape,
bool  flipVertical = true 
)

Converts a CGPathRef to a cinder::Shape2d. If flipVertical then the path will be flipped vertically.

int cinder::cocoa::getCvPixelFormatTypeFromSurfaceChannelOrder ( const SurfaceChannelOrder &  sco  ) 

Translates a cinder::SurfaceChannelOrder into the pixel formats of a CoreVideo buffer.

Returns:
-1 on failure, else a constant as defined in <CoreVideo/CVPixelBuffer.h>
CFDataRef cinder::cocoa::createCfDataRef ( const cinder::Buffer buffer  ) 

Creates a CFDataRef from a cinder::Buffer buffer. The result does not assume ownership of the data and should be freed using CFRelease().

ImageSourceCgImageRef cinder::cocoa::createImageSource ( ::CGImageRef  imageRef  ) 
CGImageRef cinder::cocoa::createCgImage ( ImageSourceRef  imageSource  ) 

Loads an ImageSource into a new CGImageRef. Release the result with CGImageRelease.

Surface8u cinder::cocoa::convertUiImage ( UIImage *  uiImage,
bool  assumeOwnership = false 
)

Converts a UIImage* into a cinder::Surface8u If assumeOwnership the result will increment the retain count on construction and decrement it upon the its own destruction.

SafeUiImage cinder::cocoa::createUiImage ( const ImageSourceRef  imageSource  ) 

Loads an ImageSourceRef imageSource into a SafeUiImage, which acts like a shared_ptr but can cast itself to UIImage* automatically

void cinder::cocoa::writeToSavedPhotosAlbum ( const ImageSourceRef  imageSource  ) 

Writes an image to the device's Photo Album.