9 std::ifstream in(input);
27 }
else if (!(c ==
' ' || c ==
'\t' || c ==
'\n' || c ==
'\r')) {
42 if (magicValue ==
"P1") {
44 }
else if (magicValue ==
"P4") {
48 "PortableBitmapReader::readHeader",
"Unknown magic value: '" + magicValue +
"'");
53 std::istringstream conv;
60 std::istringstream conv;
76 if (!(c ==
' ' || c ==
'\n' || c ==
'\t' || c ==
'\r')) {
84 static const unsigned int sizeChar =
sizeof(char) * 8;
86 unsigned int numPixels = 0;
88 for (
unsigned int row = 0; row <
height_m; ++row) {
89 for (
unsigned int col = 0; col <
width_m; ++col) {
90 if (col % sizeChar == 0) {
93 c = (
unsigned char)c2;
95 unsigned int k = sizeChar - 1 - (col % sizeChar);
103 for (
unsigned int i = 0; i <
height_m; ++i) {
104 for (
unsigned int j = 0; j <
width_m; ++j) {
106 unsigned int byte = 0;
107 for (
unsigned int k = 0; k < 8 && j + k <
width_m; ++k) {
108 unsigned int idx =
getIdx(i, j + k);
109 if (
pixels_m[idx])
byte =
byte | (1 << (7 - k));
111 std::cout <<
" " << std::hex << std::setw(2) << std::setfill(
'0') <<
byte <<
": ";
113 unsigned int idx =
getIdx(i, j);
116 std::cout << std::endl;
std::vector< bool > pixels_m
void readImageAscii(std::istream &in)
unsigned int getIdx(unsigned int h, unsigned int w) const
PortableBitmapReader(const std::string &input)
void print(std::ostream &out) const
void readImageBinary(std::istream &in)
std::string getNextPart(std::istream &in)
void readHeader(std::istream &in)