Adobe Systems, Inc.

any_image_view.hpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2005-2006 Adobe Systems Incorporated
00003     Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
00004     or a copy at http://opensource.adobe.com/licenses.html)
00005 */
00006 
00007 /*************************************************************************************************/
00008 
00009 #ifndef GIL_DYNAMICIMAGE_ANY_IMAGEVIEW_HPP
00010 #define GIL_DYNAMICIMAGE_ANY_IMAGEVIEW_HPP
00011 
00020 
00021 #include "variant.hpp"
00022 #include "../../core/image_view.hpp"
00023 #include "../../core/image.hpp"
00024 
00025 ADOBE_GIL_NAMESPACE_BEGIN
00026 
00027 namespace detail {
00028 template <typename VTYPES> struct get_dynamic_step_views;
00029 template <typename VTYPES> struct get_const_views_from_views;
00030 }
00031 
00038 template <typename IMAGE_VIEW_TYPES>
00039 class any_image_view : public variant<IMAGE_VIEW_TYPES> {
00040     typedef variant<IMAGE_VIEW_TYPES> parent_t;
00041 //  struct get_const_t { template <typename T> struct apply { typedef typename T::const_t type; }; };
00042 //  struct get_dynamic_step_t { template <typename T> struct apply { typedef typename T::dynamic_step_t type; }; };
00043 public:
00044 //  typedef any_image_view<typename boost::mpl::transform<IMAGE_VIEW_TYPES, get_const_t       >::type> const_t;
00045 //  typedef any_image_view<typename boost::mpl::transform<IMAGE_VIEW_TYPES, get_dynamic_step_t>::type> dynamic_step_t;
00046     typedef any_image_view<typename detail::get_const_views_from_views<IMAGE_VIEW_TYPES   >::type> const_t;
00047     typedef any_image_view<typename detail::get_dynamic_step_views<IMAGE_VIEW_TYPES>::type> dynamic_step_t;
00048 
00049     any_image_view()                                                          : parent_t() {}
00050     template <typename T> explicit any_image_view(const T& obj)               : parent_t(obj) {}
00051     any_image_view(const any_image_view& v)                                   : parent_t((const parent_t&)v)    {}
00052 
00053     template <typename T> any_image_view& operator=(const T& obj)             { parent_t::operator=(obj); return *this; }
00054     any_image_view&                       operator=(const any_image_view& v)  { parent_t::operator=((const parent_t&)v); return *this;}
00055 };
00056 
00057 namespace detail {
00058     struct any_type_get_num_channels {   // works for both image_view and image
00059         typedef int result_type;
00060         template <typename T> result_type operator()(const T& v) const { return get_num_channels(v); }
00061     };
00062     struct any_type_get_dimensions {    // works for both image_view and image
00063         typedef point2<std::ptrdiff_t> result_type;
00064         template <typename T> result_type operator()(const T& v) const { return v.dimensions(); }
00065     };
00066 }
00067 
00071 
00073 
00075 template <typename TYPES> GIL_FORCEINLINE
00076 int get_num_channels(const any_image_view<TYPES>& a) { return apply_operation(a, detail::any_type_get_num_channels()); }
00077 
00079 template <typename TYPES> GIL_FORCEINLINE
00080 int get_width(const any_image_view<TYPES>& a) { return apply_operation(a, detail::any_type_get_dimensions()).x; }
00081 
00083 template <typename TYPES> GIL_FORCEINLINE
00084 int get_height(const any_image_view<TYPES>& a) { return apply_operation(a, detail::any_type_get_dimensions()).y; }
00085 
00087 template <typename TYPES> GIL_FORCEINLINE
00088 point2<int> get_dimensions(const any_image_view<TYPES>& v) { return apply_operation(v, detail::any_type_get_dimensions()); }
00090 
00091 
00092 ADOBE_GIL_NAMESPACE_END
00093 
00094 #endif

Copyright © 2006 Adobe Systems Incorporated.

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

Search powered by Google