stlab.adobe.com Adobe Systems Incorporated

macintosh_graphic_utils.hpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2005-2007 Adobe Systems Incorporated
00003     Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
00004     or a copy at http://stlab.adobe.com/licenses.html)
00005 */
00006 
00007 /****************************************************************************************************/
00008 
00009 #ifndef ADOBE_MACINTOSH_GRAPHIC_UTILS_HPP
00010 #define ADOBE_MACINTOSH_GRAPHIC_UTILS_HPP
00011 
00012 /****************************************************************************************************/
00013 
00014 #include <adobe/macintosh_carbon_safe.hpp>
00015 #include <adobe/macintosh_memory.hpp>
00016 #include <boost/gil/gil_all.hpp>
00017 
00018 /****************************************************************************************************/
00019 
00020 namespace adobe {
00021 
00022 /****************************************************************************************************/
00023 
00024 // Unfortunately, there are several functions and other support state variables we need to retain
00025 // in order to feed a CGImageRef with the information it needs. Sadly, while all this is handled
00026 // internally for the client, they'll need to interact with the system via a wrapped type.
00027 
00028 /*
00029     WARNING (fbrereto) : Due to the way Mac OS X reference counts (in this case) CGImageRef objects,
00030                          it is possible to abuse this mechanism by retaining a CGImageRef and then
00031                          trying to delete the cg_image_t. The issue here is the state information
00032                          that is needed by the OS to construct the CGImageRef is not guaranteed to
00033                          be used immediately -- it's possible that the implementation may do a
00034                          lazy copy of the image data well after the CGImageRef has been created. If
00035                          this is the case, the scope of the cg_image_t must meet or exceed that of
00036                          the CGImageRef that it creates, otherwise you'll be diving off a bad
00037                          pointer.
00038 */
00039 
00040 typedef struct __lame_cg_image_wrapper_t* cg_image_t;
00041 
00042 cg_image_t   make_cg_image(const boost::gil::rgba8_image_t& image);
00043 void         destroy_cg_image(cg_image_t image);
00044 
00045 ::CGImageRef to_CGImageRef(cg_image_t image);
00046 
00047 /****************************************************************************************************/
00048 
00049 // delete_ptr specialization for the cg_image_t wrapped type so it can be used with auto_resource
00050 
00051 ADOBE_DELETE_PTR_SPECIALIZATION(cg_image_t, destroy_cg_image)
00052 
00053 /****************************************************************************************************/
00054 
00055 void paint_control_with_image(::HIViewRef control, const boost::gil::rgba8_image_t& image);
00056 
00057 /****************************************************************************************************/
00058 
00059 } // namespace adobe
00060 
00061 /****************************************************************************************************/
00062 
00063 // ADOBE_MACINTOSH_GRAPHIC_UTILS_HPP
00064 #endif
00065 
00066 /****************************************************************************************************/

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google