00001 /*00002 Copyright 2005-2007 Adobe Systems Incorporated00003 00004 Use, modification and distribution are subject to the Boost Software License,00005 Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at00006 http://www.boost.org/LICENSE_1_0.txt).00007
00008 See http://stlab.adobe.com/gil for most recent version including documentation.00009 */00010
00011 /*************************************************************************************************/00012
00013 #ifndef GIL_PLANAR_REF_H00014 #define GIL_PLANAR_REF_H00015
00024
00025 #include <boost/mpl/range_c.hpp>00026 #include "gil_config.hpp"00027 #include "gil_concept.hpp"00028 #include "color_base.hpp"00029 #include "channel.hpp"00030 #include "pixel.hpp"00031 #include "planar_pixel_iterator.hpp"00032
00033 namespace boost { namespace gil {
00034
00039
00043
00044
00050 template <typename ChannelReference, typename ColorSpace> // ChannelReference is a channel reference (const or mutable)00051struct planar_pixel_reference00052 : public detail::homogeneous_color_base<ChannelReference,layout<ColorSpace>,mpl::size<ColorSpace>::value> {
00053 typedef detail::homogeneous_color_base<ChannelReference,layout<ColorSpace>,mpl::size<ColorSpace>::value> parent_t;
00054 private:
00055 // These three are only defined for homogeneous pixels00056 typedeftypenamechannel_traits<ChannelReference>::value_type channel_t;
00057 typedeftypenamechannel_traits<ChannelReference>::const_reference channel_const_reference;
00058 public:
00059 BOOST_STATIC_CONSTANT(bool, is_mutable = channel_traits<ChannelReference>::is_mutable);
00060 typedefpixel<channel_t,layout<ColorSpace> > value_type;
00061 typedefplanar_pixel_referencereference;
00062 typedefplanar_pixel_reference<channel_const_reference,ColorSpace>const_reference;
00063
00064 planar_pixel_reference(ChannelReference v0, ChannelReference v1) : parent_t(v0,v1) {}
00065 planar_pixel_reference(ChannelReference v0, ChannelReference v1, ChannelReference v2) : parent_t(v0,v1,v2) {}
00066 planar_pixel_reference(ChannelReference v0, ChannelReference v1, ChannelReference v2, ChannelReference v3) : parent_t(v0,v1,v2,v3) {}
00067 planar_pixel_reference(ChannelReference v0, ChannelReference v1, ChannelReference v2, ChannelReference v3, ChannelReference v4) : parent_t(v0,v1,v2,v3,v4) {}
00068 planar_pixel_reference(ChannelReference v0, ChannelReference v1, ChannelReference v2, ChannelReference v3, ChannelReference v4, ChannelReference v5) : parent_t(v0,v1,v2,v3,v4,v5) {}
00069
00070 template <typename P> planar_pixel_reference(const P& p) : parent_t(p) { check_compatible<P>();}
00071
00072 // PERFORMANCE_CHECK: Is this constructor necessary?00073 template <typename ChannelV, typename Mapping>
00074 planar_pixel_reference(pixel<ChannelV,layout<ColorSpace,Mapping> >& p) : parent_t(p) { check_compatible<pixel<ChannelV,layout<ColorSpace,Mapping> > >();}
00075
00076 // Construct at offset from a given location00077 template <typename ChannelPtr> planar_pixel_reference(constplanar_pixel_iterator<ChannelPtr,ColorSpace>& p, std::ptrdiff_t diff) : parent_t(p,diff) {}
00078
00079 constplanar_pixel_reference& operator=(constplanar_pixel_reference& p) const { static_copy(p,*this); return *this; }
00080 template <typename P> constplanar_pixel_reference& operator=(const P& p) const { check_compatible<P>(); static_copy(p,*this); return *this; }
00081
00082 // This overload is necessary for a compiler implementing Core Issue 57400083 // to prevent generation of an implicit copy assignment operator (the reason00084 // for generating implicit copy assignment operator is that according to00085 // Core Issue 574, a cv-qualified assignment operator is not considered00086 // "copy assignment operator").00087 // EDG implemented Core Issue 574 starting with EDG Version 3.8. I'm not00088 // sure why they did it for a template member function as well.00089 #if BOOST_WORKAROUND(__HP_aCC, >= 61700) || BOOST_WORKAROUND(__INTEL_COMPILER, >= 1000)00090 constplanar_pixel_reference& operator=(constplanar_pixel_reference& p) { static_copy(p,*this); return *this; }
00091 template <typename P> constplanar_pixel_reference& operator=(const P& p) { check_compatible<P>(); static_copy(p,*this); return *this; }
00092 #endif00093
00094 template <typename P> bool operator==(const P& p) const { check_compatible<P>(); return static_equal(*this,p); }
00095 template <typename P> bool operator!=(const P& p) const { return !(*this==p); }
00096
00097 ChannelReference operator[](std::size_t i) const { return this->at_c_dynamic(i); }
00098
00099 constplanar_pixel_reference* operator->() const { returnthis; }
00100 private:
00101 template <typename Pixel> staticvoid check_compatible() { gil_function_requires<PixelsCompatibleConcept<Pixel,planar_pixel_reference> >(); }
00102 };
00103
00105 // ColorBasedConcept00107
00108 template <typename ChannelReference, typename ColorSpace, int K>
00109 struct kth_element_type<planar_pixel_reference<ChannelReference,ColorSpace>, K> {
00110 typedef ChannelReference type;
00111 };
00112
00113 template <typename ChannelReference, typename ColorSpace, int K>
00114 struct kth_element_reference_type<planar_pixel_reference<ChannelReference,ColorSpace>, K> {
00115 typedef ChannelReference type;
00116 };
00117
00118 template <typename ChannelReference, typename ColorSpace, int K>
00119 struct kth_element_const_reference_type<planar_pixel_reference<ChannelReference,ColorSpace>, K>
00120 : public add_reference<typename add_const<ChannelReference>::type>
00121 {
00122 // typedef typename channel_traits<ChannelReference>::const_reference type;00123 };
00124
00126 // PixelConcept00128
00131 template <typename ChannelReference, typename ColorSpace>
00132struct is_pixel< planar_pixel_reference<ChannelReference,ColorSpace> > : public mpl::true_{};
00133
00135 // HomogeneousPixelBasedConcept00137
00140 template <typename ChannelReference, typename ColorSpace>
00141struct color_space_type<planar_pixel_reference<ChannelReference,ColorSpace> > {
00142 typedef ColorSpace type;
00143 };
00144
00147 template <typename ChannelReference, typename ColorSpace>
00148struct channel_mapping_type<planar_pixel_reference<ChannelReference,ColorSpace> > {
00149 typedeftypenamelayout<ColorSpace>::channel_mapping_t type;
00150 };
00151
00154 template <typename ChannelReference, typename ColorSpace>
00155struct is_planar<planar_pixel_reference<ChannelReference,ColorSpace> > : mpl::true_ {};
00156
00159 template <typename ChannelReference, typename ColorSpace>
00160struct channel_type<planar_pixel_reference<ChannelReference,ColorSpace> > {
00161 typedeftypenamechannel_traits<ChannelReference>::value_type type;
00162 };
00163
00164 } } // namespace boost::gil00165
00166 namespace std {
00167 // We are forced to define swap inside std namespace because on some platforms (Visual Studio 8) STL calls swap qualified.00168 // swap with 'left bias': 00169 // - swap between proxy and anything00170 // - swap between value type and proxy00171 // - swap between proxy and proxy00172 // Having three overloads allows us to swap between different (but compatible) models of PixelConcept00173
00176 template <typename CR, typename CS, typename R> inline00177void swap(constboost::gil::planar_pixel_reference<CR,CS> x, R& y) {
00178 boost::gil::swap_proxy<typename boost::gil::planar_pixel_reference<CR,CS>::value_type>(x,y);
00179 }
00180
00181
00184 template <typename CR, typename CS> inline00185void swap(typenameboost::gil::planar_pixel_reference<CR,CS>::value_type& x, constboost::gil::planar_pixel_reference<CR,CS> y) {
00186 boost::gil::swap_proxy<typename boost::gil::planar_pixel_reference<CR,CS>::value_type>(x,y);
00187 }
00188
00189
00192 template <typename CR, typename CS> inline00193void swap(constboost::gil::planar_pixel_reference<CR,CS> x, constboost::gil::planar_pixel_reference<CR,CS> y) {
00194 boost::gil::swap_proxy<typename boost::gil::planar_pixel_reference<CR,CS>::value_type>(x,y);
00195 }
00196 } // namespace std00197
00198 #endif
Generated on Sat May 2 13:50:14 2009 for Generic Image Library by
1.5.6
Статья Generic Image Library: planar_pixel_reference.hpp Source File раздела может быть полезна для разработчиков на c++ и boost.
Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.