Go to the documentation of this file.00001 #ifndef gevd_bufferxy_h_
00002 #define gevd_bufferxy_h_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "gevd_memory_mixin.h"
00028 #include <vcl_iostream.h>
00029 #include <vil1/vil1_image.h>
00030 #include <vil/vil_image_resource.h>
00031
00032 class gevd_bufferxy : public gevd_memory_mixin
00033 {
00034
00035 int B;
00036 int X;
00037 int Y;
00038
00039
00040 unsigned char** yra;
00041 unsigned int* xra;
00042
00043 protected:
00044 void Init(int X, int Y, int B);
00045 gevd_bufferxy();
00046
00047
00048 inline void SetBitsPixel(int d) { B = d; }
00049 inline void SetBytesPixel(int d) { B = 8*d; }
00050 inline void SetSizeX(int x) { X = x; }
00051 inline void SetSizeY(int y) { Y = y; }
00052
00053 public:
00054
00055 gevd_bufferxy(int X, int Y, int B);
00056 gevd_bufferxy(int X, int Y, int B, void* memptr);
00057 gevd_bufferxy(vil1_image const &img);
00058 gevd_bufferxy(vil_image_resource_sptr const& img);
00059 ~gevd_bufferxy();
00060 gevd_bufferxy(gevd_bufferxy const&);
00061
00062
00063 inline int GetBitsPixel() const { return B; }
00064 inline int GetBytesPixel() const { return (B+7)/8; }
00065 inline int GetSizeX() const { return X; }
00066 inline int GetSizeY() const { return Y; }
00067 inline int GetArea() const { return GetSizeX()*GetSizeY(); }
00068 inline int GetSize() const { return GetArea()*GetBytesPixel(); }
00069
00070
00071 inline void* GetBuffer() { return GetBufferPtr(); }
00072 inline const void* GetBuffer() const { return GetBufferPtr(); }
00073 inline void* GetElementAddr(int x, int y) { return xra[x]+yra[y]; }
00074 inline const void* GetElementAddr(int x,int y)const{ return xra[x]+yra[y]; }
00075
00076
00077 void dump(const char* filename);
00078 gevd_bufferxy(const char* filename);
00079
00080 friend vcl_ostream& operator<<(vcl_ostream& os, gevd_bufferxy const& b) {
00081 return os << "gevd_bufferxy(width=" << b.GetSizeX() << ",height="
00082 << b.GetSizeY() << ",bits_per_pixel=" << b.GetBitsPixel() << ")";
00083 }
00084 };
00085
00086 #endif // gevd_bufferxy_h_