vil_pixel_format.h
Go to the documentation of this file.
1 // This is core/vil/vil_pixel_format.h
2 #ifndef vil_pixel_format_h_
3 #define vil_pixel_format_h_
4 //:
5 // \file
6 // \author Ian Scott.
7 // Note that a std::complex<float> is thought of as a scalar
8 // pixel type for vil's purposes.
9 //
10 // \verbatim
11 // Modifications
12 // 23 Oct.2003 - Peter Vanroose - Added support for 64-bit int pixels
13 // \endverbatim
14 
15 #include <iosfwd>
16 #include <complex>
17 #include <vil/vil_rgb.h>
18 #include <vil/vil_rgba.h>
19 #include <vxl_config.h> // for vxl_uint_32 etc.
20 #ifdef _MSC_VER
21 # include <vcl_msvc_warnings.h>
22 #endif
23 
24 //: Describes the type of the concrete data.
26 {
28 
29 #if VXL_HAS_INT_64
30  VIL_PIXEL_FORMAT_UINT_64 = 1,
31  VIL_PIXEL_FORMAT_INT_64 = 2,
32 #endif
41 // VIL_PIXEL_FORMAT_LONG_DOUBLE = 11,
43 
44 #if VXL_HAS_INT_64
45  VIL_PIXEL_FORMAT_RGB_UINT_64 = 13,
46  VIL_PIXEL_FORMAT_RGB_INT_64 = 14,
47 #endif
56 // VIL_PIXEL_FORMAT_RGB_LONG_DOUBLE = 23,
57 
58 #if VXL_HAS_INT_64
59  VIL_PIXEL_FORMAT_RGBA_UINT_64 = 24,
60  VIL_PIXEL_FORMAT_RGBA_INT_64 = 25,
61 #endif
70 // VIL_PIXEL_FORMAT_RGBA_LONG_DOUBLE = 34,
71 
72 //: std::complex<float> is a scalar for vil's purposes.
74 //: std::complex<double> is a scalar for vil's purposes.
76 
77 // Add values here and be careful to keep values in vil_pixel_format.cxx in sync
78 // Don't forget to increase the end value. Also add to vil_convert_cast in vil_convert.h
79 
81 };
82 
83 
84 //: The pixel format enumeration corresponding to the C++ type.
85 //
86 template <class T>
88 
89 
90 //: The C++ type corresponding to an invalid pixel format
91 //
92 // See vil_pixel_format_type_of.
93 //
95 
96 //: The C++ type corresponding to a pixel format enumeration.
97 // Use like
98 // \code
99 // typedef vil_pixel_format_type_of<VIL_PIXEL_FORMAT_BYTE>::type byte_type;
100 // \endcode
101 // This is specialized for each pixel type enumeration for which a C++
102 // type exists.
103 //
104 // If the resulting type is vil_pixel_format_invalid_type, then the
105 // pixel format enumeration is not valid.
106 //
107 template <vil_pixel_format pix_type>
109 {
112 };
113 
114 
115 //: Get the vil_pixel_format value for a given type.
116 #define vil_pixel_format_macro(T,C,V)\
117 template <> inline vil_pixel_format vil_pixel_format_of(T /*dummy*/) { return V; }\
118 template <> struct vil_pixel_format_type_of<V> { typedef T type; typedef C component_type; }
119 
120 #if VXL_HAS_INT_64
121 vil_pixel_format_macro(vxl_uint_64, vxl_uint_64, VIL_PIXEL_FORMAT_UINT_64);
122 vil_pixel_format_macro(vxl_int_64, vxl_int_64, VIL_PIXEL_FORMAT_INT_64);
123 #endif
124 vil_pixel_format_macro(vxl_uint_32, vxl_uint_32, VIL_PIXEL_FORMAT_UINT_32);
125 vil_pixel_format_macro(vxl_int_32, vxl_int_32, VIL_PIXEL_FORMAT_INT_32);
126 vil_pixel_format_macro(vxl_uint_16, vxl_uint_16, VIL_PIXEL_FORMAT_UINT_16);
127 vil_pixel_format_macro(vxl_int_16, vxl_int_16, VIL_PIXEL_FORMAT_INT_16);
128 vil_pixel_format_macro(vxl_byte, vxl_byte, VIL_PIXEL_FORMAT_BYTE);
129 vil_pixel_format_macro(vxl_sbyte, vxl_sbyte, VIL_PIXEL_FORMAT_SBYTE);
133 
134 #if VXL_HAS_INT_64
135 vil_pixel_format_macro(vil_rgb<vxl_uint_64>, vxl_uint_64, VIL_PIXEL_FORMAT_RGB_UINT_64);
136 vil_pixel_format_macro(vil_rgb<vxl_int_64>, vxl_int_64, VIL_PIXEL_FORMAT_RGB_INT_64);
137 #endif
146 
147 #if VXL_HAS_INT_64
148 vil_pixel_format_macro(vil_rgba<vxl_uint_64>, vxl_uint_64, VIL_PIXEL_FORMAT_RGBA_UINT_64);
149 vil_pixel_format_macro(vil_rgba<vxl_int_64>, vxl_int_64, VIL_PIXEL_FORMAT_RGBA_INT_64);
150 #endif
159 
160 vil_pixel_format_macro(std::complex<float>, std::complex<float>, VIL_PIXEL_FORMAT_COMPLEX_FLOAT);
161 vil_pixel_format_macro(std::complex<double>,std::complex<double>,VIL_PIXEL_FORMAT_COMPLEX_DOUBLE);
162 
163 #undef vil_pixel_format_macro
164 
165 //: Return the number of bytes used by each component of pixel format f
167 
168 //: Return the number of components in pixel format f
170 
171 //: Return the format of each component of pixel format f
173 
174 //: Output a pretty string representing the pixel format.
175 std::ostream & operator << (std::ostream &os, vil_pixel_format f);
176 
177 //: Convert a string into a pixel format.
178 // This uses the same encoding as operator<<.
180 
181 #endif // vil_pixel_format_h_
vil_pixel_format
Describes the type of the concrete data.
std::complex<float> is a scalar for vil's purposes.
Pixel type for 24 bit images.
vil_pixel_format vil_pixel_format_from_string(const char *s)
Convert a string into a pixel format.
vil_pixel_format vil_pixel_format_component_format(enum vil_pixel_format f)
Return the format of each component of pixel format f.
std::ostream & operator<<(std::ostream &os, vil_pixel_format f)
Output a pretty string representing the pixel format.
vil_pixel_format_invalid_type type
#define vil_pixel_format_macro(T, C, V)
Get the vil_pixel_format value for a given type.
This is the appropriate pixel type for RGBA colour images.
Definition: vil_fwd.h:15
unsigned vil_pixel_format_sizeof_components(enum vil_pixel_format f)
Return the number of bytes used by each component of pixel format f.
void * vil_pixel_format_invalid_type
The C++ type corresponding to an invalid pixel format.
Templated four-value colour cell.
unsigned vil_pixel_format_num_components(enum vil_pixel_format f)
Return the number of components in pixel format f.
The C++ type corresponding to a pixel format enumeration.
vil_pixel_format_invalid_type component_type
vil_pixel_format vil_pixel_format_of(T)
The pixel format enumeration corresponding to the C++ type.
std::complex<double> is a scalar for vil's purposes.
This is the appropriate pixel type for 24-bit colour images.
Definition: vil_fwd.h:14