10 std::ifstream in(input);
29 }
else if (!(c ==
' ' ||
47 if (magicValue ==
"P1") {
49 }
else if (magicValue ==
"P4") {
53 "Unknown magic value: '" + magicValue +
"'");
58 std::istringstream conv;
65 std::istringstream conv;
92 static const unsigned int sizeChar =
sizeof(char) * 8;
94 unsigned int numPixels = 0;
96 for (
unsigned int row = 0; row <
height_m; ++ row) {
97 for (
unsigned int col = 0; col <
width_m; ++ col) {
98 if ( col % sizeChar == 0) {
101 c = (
unsigned char) c2;
103 unsigned int k = sizeChar - 1 - (col % sizeChar);
111 for (
unsigned int i = 0; i <
height_m; ++ i) {
112 for (
unsigned int j = 0; j <
width_m; ++ j) {
114 unsigned int byte = 0;
115 for (
unsigned int k = 0; k < 8 && j + k <
width_m; ++ k) {
116 unsigned int idx =
getIdx(i, j + k);
118 byte = byte | (1 << (7 - k));
120 std::cout <<
" " << std::hex << std::setw(2) << std::setfill(
'0') << byte <<
": ";
122 unsigned int idx =
getIdx(i, j);
PortableBitmapReader(const std::string &input)
std::vector< bool > pixels_m
std::string getNextPart(std::istream &in)
The base class for all OPAL exceptions.
void readImageAscii(std::istream &in)
constexpr double c
The velocity of light in m/s.
void readImageBinary(std::istream &in)
void readHeader(std::istream &in)
unsigned int getIdx(unsigned int h, unsigned int w) const
void print(std::ostream &out) const
Inform & endl(Inform &inf)