pixelBGRA.h
Go to the documentation of this file.00001
00015 #ifndef _DLRCOMPUTERVISION_PIXELBGRA_H_
00016 #define _DLRCOMPUTERVISION_PIXELBGRA_H_
00017
00018 #include <dlrCommon/types.h>
00019
00020 namespace dlr {
00021
00022 namespace computerVision {
00023
00024 template<class TYPE>
00025 struct PixelBGRA
00026 {
00027 public:
00028
00033 PixelBGRA()
00034 : blue(), green(), red(), alpha() {}
00035
00036
00048 PixelBGRA(const TYPE& blue, const TYPE& green, const TYPE& red,
00049 const TYPE& alpha)
00050 : blue(blue), green(green), red(red), alpha(alpha) {}
00051
00052
00056 ~PixelBGRA() {}
00057
00058
00070 template<class Iter>
00071 inline Iter&
00072 copyFromIterator(Iter& iter);
00073
00074
00086 template<class Iter>
00087 inline Iter&
00088 copyToIterator(Iter& iter);
00089
00090
00091
00092
00093 TYPE blue;
00094 TYPE green;
00095 TYPE red;
00096 TYPE alpha;
00097
00098
00099
00100
00109 static inline bool
00110 isContiguous();
00111
00112 };
00113
00114
00115 typedef PixelBGRA<UnsignedInt8> PixelBGRA8;
00116 typedef PixelBGRA<UnsignedInt16> PixelBGRA16;
00117 typedef PixelBGRA<Int16> PixelBGRASigned16;
00118 typedef PixelBGRA<Int32> PixelBGRASigned32;
00119 typedef PixelBGRA<Float32> PixelBGRAFloat32;
00120 typedef PixelBGRA<Float64> PixelBGRAFloat64;
00121
00122
00137 template<class TYPE>
00138 inline PixelBGRA<TYPE>
00139 operator-(const PixelBGRA<TYPE>& pixel0, const PixelBGRA<TYPE>& pixel1);
00140
00141
00153 template<class TYPE>
00154 inline bool
00155 operator==(const PixelBGRA<TYPE>& pixel0, const PixelBGRA<TYPE>& pixel1);
00156
00157 }
00158
00159 }
00160
00161
00162
00163
00164 namespace dlr {
00165
00166 namespace computerVision {
00167
00168
00169
00170
00171 template<class TYPE>
00172 template<class Iter>
00173 inline Iter&
00174 PixelBGRA<TYPE>::
00175 copyFromIterator(Iter& iter)
00176 {
00177 blue = *(iter++);
00178 green = *(iter++);
00179 red = *(iter++);
00180 alpha = *(iter++);
00181 return iter;
00182 }
00183
00184
00185
00186
00187
00188 template<class TYPE>
00189 template<class Iter>
00190 inline Iter&
00191 PixelBGRA<TYPE>::
00192 copyToIterator(Iter& iter)
00193 {
00194 *(iter++) = blue;
00195 *(iter++) = green;
00196 *(iter++) = red;
00197 *(iter++) = alpha;
00198 return iter;
00199 }
00200
00201
00202
00203
00204
00205 template<class TYPE>
00206 inline bool
00207 PixelBGRA<TYPE>::
00208 isContiguous()
00209 {
00210 TYPE dummy;
00211 TYPE* typePtr = &dummy;
00212 PixelBGRA<TYPE>* pixelPtr = reinterpret_cast<PixelBGRA<TYPE>*>(typePtr);
00213 PixelBGRA<TYPE>* pixelPtr2 = pixelPtr + 1;
00214 return
00215 ((reinterpret_cast<TYPE*>(&(pixelPtr2->blue)) == &(typePtr[4]))
00216 && (reinterpret_cast<TYPE*>(&(pixelPtr2->green)) == &(typePtr[5]))
00217 && (reinterpret_cast<TYPE*>(&(pixelPtr2->red)) == &(typePtr[6]))
00218 && (reinterpret_cast<TYPE*>(&(pixelPtr2->alpha)) == &(typePtr[7])));
00219 }
00220
00221
00222
00223
00224 template<class TYPE>
00225 inline PixelBGRA<TYPE>
00226 operator-(const PixelBGRA<TYPE>& pixel0, const PixelBGRA<TYPE>& pixel1)
00227 {
00228 return PixelBGRA<TYPE>(
00229 pixel0.blue - pixel1.blue,
00230 pixel0.green - pixel1.green,
00231 pixel0.red - pixel1.red,
00232 pixel0.alpha - pixel1.alpha);
00233 }
00234
00235
00236
00237
00238 template<class TYPE>
00239 inline bool
00240 operator==(const PixelBGRA<TYPE>& pixel0, const PixelBGRA<TYPE>& pixel1)
00241 {
00242 return (pixel0.blue == pixel1.blue
00243 && pixel0.green == pixel1.green
00244 && pixel0.red == pixel1.red
00245 && pixel0.alpha == pixel1.alpha);
00246 }
00247
00248 }
00249
00250 }
00251
00252 #endif