Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CinderCocoaTouch.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2010, The Barbarian Group
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without modification, are permitted provided that
6  the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice, this list of conditions and
9  the following disclaimer.
10  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
11  the following disclaimer in the documentation and/or other materials provided with the distribution.
12 
13  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
14  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
15  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
16  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
17  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
18  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
19  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
20  POSSIBILITY OF SUCH DAMAGE.
21 */
22 
23 #pragma once
24 
25 #include "cinder/Cinder.h"
26 #include "cinder/Surface.h"
27 
28 #include <CoreGraphics/CoreGraphics.h>
29 #include <CoreFoundation/CoreFoundation.h>
30 
31 #if defined( __OBJC__ )
32  @class UIImage;
33 #else
34  class UIImage;
35 #endif
36 
37 namespace cinder { namespace cocoa {
38 
41 Surface8u convertUiImage( UIImage *uiImage, bool assumeOwnership = false );
42 
44 class SafeUiImage {
45  public:
47  SafeUiImage( UIImage *uiImage, CGImageRef imageRef );
48 
49  operator UIImage*() const { if( mObj ) return mObj->first; else return 0; }
50 
51  private:
52  static void destroy( std::pair<UIImage*,CGImageRef> *data );
53 
54  std::shared_ptr<std::pair<UIImage*,CGImageRef> > mObj;
55 };
56 
58 SafeUiImage createUiImage( const ImageSourceRef imageSource );
59 
61 void writeToSavedPhotosAlbum( const ImageSourceRef imageSource );
62 
63 } } // namespace cinder::cocoa
64 
SafeUiImage()
Definition: CinderCocoaTouch.h:46
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: GLee.h:1011
struct CGImage * CGImageRef
Definition: ImageSourceFileQuartz.h:30
SurfaceT< uint8_t > Surface8u
8-bit image
Definition: Surface.h:493
A class which encapsulate a UIImage and an associated CGImageRef in order to work around memory owner...
Definition: CinderCocoaTouch.h:44
std::shared_ptr< class ImageSource > ImageSourceRef
Definition: Channel.h:33
SafeUiImage createUiImage(const ImageSourceRef imageSource)
Definition: CinderCocoaTouch.mm:78
void writeToSavedPhotosAlbum(const ImageSourceRef imageSource)
Writes an image to the device's Photo Album.
Definition: CinderCocoaTouch.mm:91
Surface8u convertUiImage(UIImage *uiImage, bool assumeOwnership=false)
Converts a UIImage* into a cinder::Surface8u If assumeOwnership the result will increment the retain ...
Definition: CinderCocoaTouch.mm:43