Bitmap.h

00001 # ifndef Conjecture_Bitmap_h
00002 # define Conjecture_Bitmap_h Conjecture_Bitmap_h
00003 
00004 // Insert SVN header substitution variable here
00005 // Class Champion: Bruno
00006 
00007 # include "Root.h"  // parent
00008 # include "Coord.h"
00009 # include "ImageFilter.h"
00010 
00011 namespace Conjecture {
00012 
00013     typedef unsigned char Pixel; // TODO: should this be a class?
00014 
00022     class Bitmap : public Root {
00023 
00024     public:
00025         // Constructors/Destructors
00026         Bitmap(uint32_t width, uint32_t height);
00027 
00028         Bitmap(const std::string &filename);
00029 
00030         ~Bitmap();
00031 
00032         // **************
00033         // Accessors
00034         inline const Pixel operator() (uint32_t x, uint32_t y) const {
00035             return ( (_pixels[at(x,y)] & (1 << (x & 0x07))) == 0 ? 0 : 1);
00036         }
00037 
00038         inline const Pixel mask(uint32_t x, uint32_t y) const {
00039             return ( (_mask[at(x,y)] & (1 << (x & 0x07))) == 0 ? 0 : 1);
00040         }
00041 
00042         inline const uint32_t width() const {
00043             return this->_width;
00044         }
00045 
00046         inline const uint32_t height() const {
00047             return this->_height;
00048         }
00049 
00050         // **************
00051         // Input/Output
00052 
00053         // **************
00054         // Interface
00055 
00059         Bitmap clone(void) const;
00060 
00068         const Bitmap clone(Coord a, Coord b) const;
00069 
00075         bool filter(ImageFilter &imfilter);
00076 
00086         static void test(int argc = 0, const char* argv[] = NULL);
00087 
00088     protected:
00089         // Accessors
00090 
00091         // Methods
00092 
00093     private:
00094         // Accessors
00095 
00096         // Methods
00097 
00104         inline uint32_t at(uint32_t x, uint32_t y) const {
00105             return (y * _linesize + (x >> 3));
00106         }
00107 
00108         // **************
00109         // State
00110 
00111         typedef uint32_t PixelBlock; // TODO: this should be platform dependent
00112 
00113         uint32_t        _width;
00114         uint32_t        _height;
00115         uint32_t        _linesize;
00116         PixelBlock      *_pixels;
00117         PixelBlock      *_mask;
00118 
00119     };
00120 }
00121 
00122 # endif // SomeClass_h
00123 

Generated on Thu Jun 15 19:56:09 2006 for Conjecture by  doxygen 1.4.6