Go to the documentation of this file.00001 #ifndef ColorImageRGB8a_H
00002 #define ColorImageRGB8a_H
00003
00004 #include "ImageSuperClasses.h"
00005 #include "SingleElementImage.h"
00006 #include "MultiElementImage.h"
00007
00008 namespace puma2 {
00009
00010 typedef unsigned char byte;
00011
00012 struct RGBa8 {
00013 union {
00014 struct {
00015 unsigned int r:8;
00016 unsigned int g:8;
00017 unsigned int b:8;
00018 unsigned int a:8;
00019 };
00020 unsigned int u;
00021 byte w[4];
00022 };
00023 RGBa8 & operator=(const RGBa8 o) { u = o.u; return *this; }
00024 void operator= (int v) { u = v; }
00025 byte & operator[] (int i) { return w[i]; }
00026 byte operator[] (int i) const { return w[i]; }
00027 void assign(int v, int n) { w[n] = v; }
00028 typedef byte B4[4];
00029 };
00030
00031 template <> inline void Vector<RGBa8::B4>::copy(const RGBa8::B4& f, RGBa8::B4& t)
00032 { t[0] = f[0];
00033 t[1] = f[1];
00034 t[2] = f[2];
00035 t[3] = f[3]; }
00036 template <> inline void Vector<RGBa8>::copy(const RGBa8& f, RGBa8& t) { t.u = f.u; }
00037
00063 class ColorImageRGBa8 :
00064 public SingleElementImage<RGBa8>
00065 {
00066 public:
00067 ColorImageRGBa8(int x = 0, int y = 0);
00068
00069 ColorImageRGBa8(int x, int y, ColorImageRGBa8 * m, int xo, int yo);
00070
00078 void assign(int i, int j, int n, int v);
00079
00080
00081 MultiElementImage<byte,4> & asMultiElementImage();
00082
00083 static int numberOfChannels();
00084
00086 double getElementTypeMinimum() const { return 0; };
00087
00089 double getElementTypeMaximum() const { return 255; };
00090
00092 void readFromFile(const char * fileName);
00094 void writeToFile(const char * fileName) const;
00095
00096 private:
00108 MultiElementImage<byte,4> alt;
00109 };
00110
00111 }
00112
00113 #endif