OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
PortableGraymapReader.h
Go to the documentation of this file.
1#ifndef PORTABLEGRAYMAPRREADER_H
2#define PORTABLEGRAYMAPRREADER_H
3
5
6#include <istream>
7#include <string>
8#include <vector>
9
11public:
12 PortableGraymapReader(const std::string& input);
13
14 unsigned int getWidth() const;
15 unsigned int getHeight() const;
16
17 unsigned short getPixel(unsigned int i, unsigned int j) const;
18 std::vector<unsigned short> 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 unsigned short depth_m;
32
34
36
37 std::vector<unsigned short> pixels_m;
38};
39
40inline unsigned int PortableGraymapReader::getWidth() const { return width_m; }
41
42inline unsigned int PortableGraymapReader::getHeight() const { return height_m; }
43
44inline unsigned short PortableGraymapReader::getPixel(unsigned int i, unsigned int j) const {
45 return pixels_m[getIdx(i, j)];
46}
47
48inline std::vector<unsigned short> PortableGraymapReader::getPixels() const { return pixels_m; }
49
50inline unsigned int PortableGraymapReader::getIdx(unsigned int h, unsigned int w) const {
51 if (h >= height_m || w >= width_m)
52 throw OpalException("PortableGraymapReader::getIdx", "Pixel number out of bounds");
53 return h * width_m + w;
54}
55
56#endif
std::vector< unsigned short > pixels_m
std::string getNextPart(std::istream &in)
void print(std::ostream &out) const
void readImageBinary(std::istream &in)
unsigned int getWidth() const
unsigned int getIdx(unsigned int h, unsigned int w) const
unsigned int getHeight() const
unsigned short getPixel(unsigned int i, unsigned int j) const
std::vector< unsigned short > getPixels() const
void readHeader(std::istream &in)
void readImageAscii(std::istream &in)