blip  0.1
ImageDecoder.hpp
Go to the documentation of this file.
1 #ifndef __blip_ImageDecoder_hpp
2 #define __blip_ImageDecoder_hpp
3 
4 #include <blip/Blip.hpp>
5 #include <blip/Size.hpp>
6 
7 CCXX_FWD_DECL(DataReader);
8 
9 namespace blip {
10 
11 class Pixmap;
12 
29 {
30  public:
31 
35  ImageDecoder(ccxx::DataReader* reader);
36 
38  virtual ~ImageDecoder();
39 
45  void decodeMetadata();
46 
54  void decodeImage(Pixmap* pixmap);
55 
59  inline Size getSize() const
60  { return(_size); }
61 
62  protected:
63 
69  virtual void readMetadata(ccxx::DataReader* reader) = 0;
70 
78  virtual void readPixmap(ccxx::DataReader* reader, Pixmap* pixmap) = 0;
79 
83  inline void setSize(const Size& size)
84  { _size = size; }
85 
86  private:
87 
88  ccxx::DataReader* _reader;
89  Size _size;
90  bool _metadataRead;
91  bool _pixmapRead;
92 
93  CCXX_COPY_DECLS(ImageDecoder);
94 };
95 
96 } // namespace blip
97 
98 #endif // __blip_ImageDecoder_hpp
An abstract base class for image decoders.
Definition: ImageDecoder.hpp:28
A rectangular size that has a width and a height.
Definition: Size.hpp:13
void decodeMetadata()
Decode the metadata for the image.
Definition: ImageDecoder.cpp:33
void setSize(const Size &size)
This method should be called from readMetadata() to store the image size, once it has been determined...
Definition: ImageDecoder.hpp:83
ImageDecoder(ccxx::DataReader *reader)
Construct a new ImageDecoder that will read an image from the given DataReader.
Definition: ImageDecoder.cpp:16
CCXX_FWD_DECL(DataReader)
void decodeImage(Pixmap *pixmap)
Decode the image itself.
Definition: ImageDecoder.cpp:45
WAV file format details at: https://ccrma.stanford.edu/courses/422/projects/WaveFormat/.
Definition: AccelerometerSensorEvent.cpp:3
virtual void readMetadata(ccxx::DataReader *reader)=0
This method must be implemented to perform the image metadata decoding.
Size getSize() const
Get the size of the image, in pixels.
Definition: ImageDecoder.hpp:59
virtual void readPixmap(ccxx::DataReader *reader, Pixmap *pixmap)=0
This method must be implemented to perform the image data decoding.
A buffer for two-dimensional pixel data, stored in inverted row order (bottom row first...
Definition: Pixmap.hpp:58
virtual ~ImageDecoder()
Destructor.
Definition: ImageDecoder.cpp:26