1 /* 2 Copyright 2005-2007 Adobe Systems Incorporated 3 4 Use, modification and distribution are subject to the Boost Software License, 5 Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 6 http://www.boost.org/LICENSE_1_0.txt). 7 8 See http://opensource.adobe.com/gil for most recent version including documentation. 9 */ 10 11 /*************************************************************************************************/ 12 13 #ifndef GIL_TYPEDEFS_H 14 #define GIL_TYPEDEFS_H 15 16 //////////////////////////////////////////////////////////////////////////////////////// 17 /// \file 18 /// \brief Useful typedefs 19 /// \author Lubomir Bourdev and Hailin Jin \n 20 /// Adobe Systems Incorporated 21 /// \date 2005-2007 \n Last updated on March 8, 2006 22 /// 23 //////////////////////////////////////////////////////////////////////////////////////// 24 25 #include "gil_config.hpp" 26 #include <boost/cstdint.hpp> 27 #include "gray.hpp" 28 #include "rgb.hpp" 29 #include "rgba.hpp" 30 #include "cmyk.hpp" 31 #include "device_n.hpp" 32 #include <memory> 33 34 // CS = 'bgr' LAYOUT='bgr_layout_t' 35 #define GIL_DEFINE_BASE_TYPEDEFS_INTERNAL(T,CS,LAYOUT) \ 36 template <typename, typename> struct pixel; \ 37 template <typename, typename> struct planar_pixel_reference; \ 38 template <typename, typename> struct planar_pixel_iterator; \ 39 template <typename> class memory_based_step_iterator; \ 40 template <typename> class point2; \ 41 template <typename> class memory_based_2d_locator; \ 42 template <typename> class image_view; \ 43 template <typename, bool, typename> class image; \ 44 typedef pixel<bits##T, LAYOUT > CS##T##_pixel_t; \ 45 typedef const pixel<bits##T, LAYOUT > CS##T##c_pixel_t; \ 46 typedef pixel<bits##T, LAYOUT >& CS##T##_ref_t; \ 47 typedef const pixel<bits##T, LAYOUT >& CS##T##c_ref_t; \ 48 typedef CS##T##_pixel_t* CS##T##_ptr_t; \ 49 typedef CS##T##c_pixel_t* CS##T##c_ptr_t; \ 50 typedef memory_based_step_iterator<CS##T##_ptr_t> CS##T##_step_ptr_t; \ 51 typedef memory_based_step_iterator<CS##T##c_ptr_t> CS##T##c_step_ptr_t; \ 52 typedef memory_based_2d_locator<memory_based_step_iterator<CS##T##_ptr_t> > CS##T##_loc_t; \ 53 typedef memory_based_2d_locator<memory_based_step_iterator<CS##T##c_ptr_t> > CS##T##c_loc_t; \ 54 typedef memory_based_2d_locator<memory_based_step_iterator<CS##T##_step_ptr_t> > CS##T##_step_loc_t; \ 55 typedef memory_based_2d_locator<memory_based_step_iterator<CS##T##c_step_ptr_t> > CS##T##c_step_loc_t; \ 56 typedef image_view<CS##T##_loc_t> CS##T##_view_t; \ 57 typedef image_view<CS##T##c_loc_t> CS##T##c_view_t; \ 58 typedef image_view<CS##T##_step_loc_t> CS##T##_step_view_t; \ 59 typedef image_view<CS##T##c_step_loc_t> CS##T##c_step_view_t; \ 60 typedef image<CS##T##_pixel_t,false,std::allocator<unsigned char> > CS##T##_image_t; 61 62 // CS = 'bgr' CS_FULL = 'rgb_t' LAYOUT='bgr_layout_t' 63 #define GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(T,CS,CS_FULL,LAYOUT) \ 64 GIL_DEFINE_BASE_TYPEDEFS_INTERNAL(T,CS,LAYOUT) \ 65 typedef planar_pixel_reference<bits##T&,CS_FULL > CS##T##_planar_ref_t; \ 66 typedef planar_pixel_reference<const bits##T&,CS_FULL > CS##T##c_planar_ref_t; \ 67 typedef planar_pixel_iterator<bits##T*,CS_FULL > CS##T##_planar_ptr_t; \ 68 typedef planar_pixel_iterator<const bits##T*,CS_FULL > CS##T##c_planar_ptr_t; \ 69 typedef memory_based_step_iterator<CS##T##_planar_ptr_t> CS##T##_planar_step_ptr_t; \ 70 typedef memory_based_step_iterator<CS##T##c_planar_ptr_t> CS##T##c_planar_step_ptr_t; \ 71 typedef memory_based_2d_locator<memory_based_step_iterator<CS##T##_planar_ptr_t> > CS##T##_planar_loc_t; \ 72 typedef memory_based_2d_locator<memory_based_step_iterator<CS##T##c_planar_ptr_t> > CS##T##c_planar_loc_t; \ 73 typedef memory_based_2d_locator<memory_based_step_iterator<CS##T##_planar_step_ptr_t> > CS##T##_planar_step_loc_t; \ 74 typedef memory_based_2d_locator<memory_based_step_iterator<CS##T##c_planar_step_ptr_t> > CS##T##c_planar_step_loc_t; \ 75 typedef image_view<CS##T##_planar_loc_t> CS##T##_planar_view_t; \ 76 typedef image_view<CS##T##c_planar_loc_t> CS##T##c_planar_view_t; \ 77 typedef image_view<CS##T##_planar_step_loc_t> CS##T##_planar_step_view_t; \ 78 typedef image_view<CS##T##c_planar_step_loc_t> CS##T##c_planar_step_view_t;\ 79 typedef image<CS##T##_pixel_t,true,std::allocator<unsigned char> > CS##T##_planar_image_t; 80 81 #define GIL_DEFINE_BASE_TYPEDEFS(T,CS) \ 82 GIL_DEFINE_BASE_TYPEDEFS_INTERNAL(T,CS,CS##_layout_t) 83 84 #define GIL_DEFINE_ALL_TYPEDEFS(T,CS) \ 85 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(T,CS,CS##_t,CS##_layout_t) 86 87 namespace boost { namespace gil { 88 89 // forward declarations 90 template <typename B, typename Mn, typename Mx> struct scoped_channel_value; 91 struct float_zero; 92 struct float_one; 93 typedef scoped_channel_value<float,float_zero,float_one> bits32f; 94 typedef uint8_t bits8; 95 typedef uint16_t bits16; 96 typedef uint32_t bits32; 97 typedef int8_t bits8s; 98 typedef int16_t bits16s; 99 typedef int32_t bits32s; 100 101 GIL_DEFINE_BASE_TYPEDEFS(8, gray) 102 GIL_DEFINE_BASE_TYPEDEFS(8s, gray) 103 GIL_DEFINE_BASE_TYPEDEFS(16, gray) 104 GIL_DEFINE_BASE_TYPEDEFS(16s,gray) 105 GIL_DEFINE_BASE_TYPEDEFS(32 ,gray) 106 GIL_DEFINE_BASE_TYPEDEFS(32s,gray) 107 GIL_DEFINE_BASE_TYPEDEFS(32f,gray) 108 GIL_DEFINE_BASE_TYPEDEFS(8, bgr) 109 GIL_DEFINE_BASE_TYPEDEFS(8s, bgr) 110 GIL_DEFINE_BASE_TYPEDEFS(16, bgr) 111 GIL_DEFINE_BASE_TYPEDEFS(16s,bgr) 112 GIL_DEFINE_BASE_TYPEDEFS(32 ,bgr) 113 GIL_DEFINE_BASE_TYPEDEFS(32s,bgr) 114 GIL_DEFINE_BASE_TYPEDEFS(32f,bgr) 115 GIL_DEFINE_BASE_TYPEDEFS(8, argb) 116 GIL_DEFINE_BASE_TYPEDEFS(8s, argb) 117 GIL_DEFINE_BASE_TYPEDEFS(16, argb) 118 GIL_DEFINE_BASE_TYPEDEFS(16s,argb) 119 GIL_DEFINE_BASE_TYPEDEFS(32, argb) 120 GIL_DEFINE_BASE_TYPEDEFS(32s,argb) 121 GIL_DEFINE_BASE_TYPEDEFS(32f,argb) 122 GIL_DEFINE_BASE_TYPEDEFS(8, abgr) 123 GIL_DEFINE_BASE_TYPEDEFS(8s, abgr) 124 GIL_DEFINE_BASE_TYPEDEFS(16, abgr) 125 GIL_DEFINE_BASE_TYPEDEFS(16s,abgr) 126 GIL_DEFINE_BASE_TYPEDEFS(32 ,abgr) 127 GIL_DEFINE_BASE_TYPEDEFS(32s,abgr) 128 GIL_DEFINE_BASE_TYPEDEFS(32f,abgr) 129 GIL_DEFINE_BASE_TYPEDEFS(8, bgra) 130 GIL_DEFINE_BASE_TYPEDEFS(8s, bgra) 131 GIL_DEFINE_BASE_TYPEDEFS(16, bgra) 132 GIL_DEFINE_BASE_TYPEDEFS(16s,bgra) 133 GIL_DEFINE_BASE_TYPEDEFS(32 ,bgra) 134 GIL_DEFINE_BASE_TYPEDEFS(32s,bgra) 135 GIL_DEFINE_BASE_TYPEDEFS(32f,bgra) 136 137 GIL_DEFINE_ALL_TYPEDEFS(8, rgb) 138 GIL_DEFINE_ALL_TYPEDEFS(8s, rgb) 139 GIL_DEFINE_ALL_TYPEDEFS(16, rgb) 140 GIL_DEFINE_ALL_TYPEDEFS(16s,rgb) 141 GIL_DEFINE_ALL_TYPEDEFS(32 ,rgb) 142 GIL_DEFINE_ALL_TYPEDEFS(32s,rgb) 143 GIL_DEFINE_ALL_TYPEDEFS(32f,rgb) 144 GIL_DEFINE_ALL_TYPEDEFS(8, rgba) 145 GIL_DEFINE_ALL_TYPEDEFS(8s, rgba) 146 GIL_DEFINE_ALL_TYPEDEFS(16, rgba) 147 GIL_DEFINE_ALL_TYPEDEFS(16s,rgba) 148 GIL_DEFINE_ALL_TYPEDEFS(32 ,rgba) 149 GIL_DEFINE_ALL_TYPEDEFS(32s,rgba) 150 GIL_DEFINE_ALL_TYPEDEFS(32f,rgba) 151 GIL_DEFINE_ALL_TYPEDEFS(8, cmyk) 152 GIL_DEFINE_ALL_TYPEDEFS(8s, cmyk) 153 GIL_DEFINE_ALL_TYPEDEFS(16, cmyk) 154 GIL_DEFINE_ALL_TYPEDEFS(16s,cmyk) 155 GIL_DEFINE_ALL_TYPEDEFS(32 ,cmyk) 156 GIL_DEFINE_ALL_TYPEDEFS(32s,cmyk) 157 GIL_DEFINE_ALL_TYPEDEFS(32f,cmyk) 158 159 160 template <int N> struct devicen_t; 161 template <int N> struct devicen_layout_t; 162 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8, dev2n, devicen_t<2>, devicen_layout_t<2>) 163 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8s, dev2n, devicen_t<2>, devicen_layout_t<2>) 164 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16, dev2n, devicen_t<2>, devicen_layout_t<2>) 165 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16s,dev2n, devicen_t<2>, devicen_layout_t<2>) 166 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32 ,dev2n, devicen_t<2>, devicen_layout_t<2>) 167 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32s,dev2n, devicen_t<2>, devicen_layout_t<2>) 168 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32f,dev2n, devicen_t<2>, devicen_layout_t<2>) 169 170 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8, dev3n, devicen_t<3>, devicen_layout_t<3>) 171 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8s, dev3n, devicen_t<3>, devicen_layout_t<3>) 172 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16, dev3n, devicen_t<3>, devicen_layout_t<3>) 173 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16s,dev3n, devicen_t<3>, devicen_layout_t<3>) 174 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32 ,dev3n, devicen_t<3>, devicen_layout_t<3>) 175 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32s,dev3n, devicen_t<3>, devicen_layout_t<3>) 176 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32f,dev3n, devicen_t<3>, devicen_layout_t<3>) 177 178 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8, dev4n, devicen_t<4>, devicen_layout_t<4>) 179 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8s, dev4n, devicen_t<4>, devicen_layout_t<4>) 180 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16, dev4n, devicen_t<4>, devicen_layout_t<4>) 181 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16s,dev4n, devicen_t<4>, devicen_layout_t<4>) 182 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32 ,dev4n, devicen_t<4>, devicen_layout_t<4>) 183 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32s,dev4n, devicen_t<4>, devicen_layout_t<4>) 184 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32f,dev4n, devicen_t<4>, devicen_layout_t<4>) 185 186 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8, dev5n, devicen_t<5>, devicen_layout_t<5>) 187 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8s, dev5n, devicen_t<5>, devicen_layout_t<5>) 188 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16, dev5n, devicen_t<5>, devicen_layout_t<5>) 189 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16s,dev5n, devicen_t<5>, devicen_layout_t<5>) 190 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32 ,dev5n, devicen_t<5>, devicen_layout_t<5>) 191 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32s,dev5n, devicen_t<5>, devicen_layout_t<5>) 192 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32f,dev5n, devicen_t<5>, devicen_layout_t<5>) 193 194 } } // namespace boost::gil 195 196 #endif 197