Adobe Systems, Inc.

gray.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_GRAY_H
00010 #define GIL_GRAY_H
00011 
00019 
00020 #include "gil_config.hpp"
00021 #include <boost/type_traits.hpp>
00022 
00023 ADOBE_GIL_NAMESPACE_BEGIN
00024 
00025 //forward declarations for pixel and color_base
00026 template <typename T, typename C> struct pixel;
00027 namespace detail { template <typename T, typename C> struct color_base; }
00028 
00032 
00035 struct gray_t { 
00036     typedef gray_t base;
00037     BOOST_STATIC_CONSTANT(int, num_channels=1);
00038 };
00039 
00040 namespace detail {
00048     template <typename T>
00049     struct color_base<T,gray_t> : public homogeneous_color_base<T> {
00050         T gray;
00051         color_base() {}
00052         color_base(T v0) : gray(v0) {}
00053         template <typename T1, typename C1> color_base(const color_base<T1,C1>& c) : gray(c.gray) {}
00054 
00055         // grayscale pixel values are convertible to channel type
00056         operator T () const { return gray; }
00057     };
00058 
00059     template <typename CS,int N> struct channel_accessor;
00060 
00062     template <>
00063     struct channel_accessor<gray_t,0> {
00064         template <typename P> typename P::template kth_element_t<0>::reference       operator()(      P& p) const {return p.gray;}
00065         template <typename P> typename P::template kth_element_t<0>::const_reference operator()(const P& p) const {return p.gray;}
00066     };
00067 } // namespace detail
00068 
00069 ADOBE_GIL_NAMESPACE_END
00070 
00071 #endif
00072 

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