OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
PortableBitmapReader.h
Go to the documentation of this file.
1#ifndef PORTABLEBITMAPRREADER_H
2#define PORTABLEBITMAPRREADER_H
3
5
6#include <istream>
7#include <string>
8#include <vector>
9
11public:
12 PortableBitmapReader(const std::string& input);
13
14 unsigned int getWidth() const;
15 unsigned int getHeight() const;
16
17 bool isBlack(unsigned int i, unsigned int j) const;
18 std::vector<bool> getPixels() const;
19 void print(std::ostream& out) const;
20
21private:
22 void readHeader(std::istream& in);
23 void readImageAscii(std::istream& in);
24 void readImageBinary(std::istream& in);
25 std::string getNextPart(std::istream& in);
26
27 unsigned int getIdx(unsigned int h, unsigned int w) const;
28
29 unsigned int width_m;
30 unsigned int height_m;
31
33
35
36 std::vector<bool> pixels_m;
37};
38
39inline unsigned int PortableBitmapReader::getWidth() const { return width_m; }
40
41inline unsigned int PortableBitmapReader::getHeight() const { return height_m; }
42
43inline bool PortableBitmapReader::isBlack(unsigned int i, unsigned int j) const {
44 return pixels_m[getIdx(i, j)];
45}
46
47inline std::vector<bool> PortableBitmapReader::getPixels() const { return pixels_m; }
48
49inline unsigned int PortableBitmapReader::getIdx(unsigned int h, unsigned int w) const {
50 if (h >= height_m || w >= width_m)
51 throw OpalException("PortableBitmapReader::getIdx", "Pixel number out of bounds");
52 return h * width_m + w;
53}
54
55#endif
std::vector< bool > pixels_m
void readImageAscii(std::istream &in)
unsigned int getIdx(unsigned int h, unsigned int w) const
std::vector< bool > getPixels() const
bool isBlack(unsigned int i, unsigned int j) const
void print(std::ostream &out) const
void readImageBinary(std::istream &in)
std::string getNextPart(std::istream &in)
void readHeader(std::istream &in)
unsigned int getWidth() const
unsigned int getHeight() const