10 std::ifstream in(input);
28 }
else if (!(c ==
' ' ||
46 if (magicValue ==
"P1") {
48 }
else if (magicValue ==
"P4") {
52 "Unknown magic value: '" + magicValue +
"'");
57 std::istringstream conv;
64 std::istringstream conv;
91 static const unsigned int sizeChar =
sizeof(char) * 8;
93 unsigned int numPixels = 0;
95 for (
unsigned int row = 0; row <
height_m; ++ row) {
96 for (
unsigned int col = 0; col <
width_m; ++ col) {
97 if ( col % sizeChar == 0) {
100 c = (
unsigned char) c2;
102 unsigned int k = sizeChar - 1 - (col % sizeChar);
110 for (
unsigned int i = 0; i <
height_m; ++ i) {
111 for (
unsigned int j = 0; j <
width_m; ++ j) {
113 unsigned int byte = 0;
114 for (
unsigned int k = 0; k < 8 && j + k <
width_m; ++ k) {
115 unsigned int idx =
getIdx(i, j + k);
117 byte = byte | (1 << (7 - k));
119 std::cout <<
" " << std::hex << std::setw(2) << std::setfill(
'0') << byte <<
": ";
121 unsigned int idx =
getIdx(i, j);
constexpr double c
The velocity of light in m/s.
void readImageAscii(std::istream &in)
Inform & endl(Inform &inf)
The base class for all OPAL exceptions.
void readHeader(std::istream &in)
void print(std::ostream &out) const
void readImageBinary(std::istream &in)
std::vector< bool > pixels_m
PortableBitmapReader(const std::string &input)
std::string getNextPart(std::istream &in)
unsigned int getIdx(unsigned int h, unsigned int w) const