diff options
Diffstat (limited to 'src/GFX/Image/PPMParser.cpp')
| -rw-r--r-- | src/GFX/Image/PPMParser.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/GFX/Image/PPMParser.cpp b/src/GFX/Image/PPMParser.cpp index 1f62871..3c95bba 100644 --- a/src/GFX/Image/PPMParser.cpp +++ b/src/GFX/Image/PPMParser.cpp @@ -18,7 +18,7 @@ RawImage PPMParser::parse() { auto pixel_count = header.width * header.height; RawImage image(header.width, header.height); - for (uint64_t pixel_index = 0; pixel_index < pixel_count; pixel_index++) { + for (U64 pixel_index = 0; pixel_index < pixel_count; pixel_index++) { RawImage::Pixel pixel = parse_pixel(header.max_color); image.add(pixel); } @@ -57,7 +57,7 @@ PPMParser::PPMHeader PPMParser::parse_header() { return header; } -RawImage::Pixel PPMParser::parse_pixel(uint8_t max_color) { +RawImage::Pixel PPMParser::parse_pixel(U8 max_color) { auto r_sample = parse_sample(); auto g_sample = parse_sample(); auto b_sample = parse_sample(); @@ -66,7 +66,7 @@ RawImage::Pixel PPMParser::parse_pixel(uint8_t max_color) { throw std::runtime_error("Sample can not be greater than Maxval."); } - auto map_to_range = [=](uint64_t s) -> uint8_t { return s * 255 / max_color; }; + auto map_to_range = [=](U64 s) -> U8 { return s * 255 / max_color; }; RawImage::Pixel p{ map_to_range(r_sample), @@ -82,23 +82,23 @@ RawImage::Pixel PPMParser::parse_pixel(uint8_t max_color) { return p; } -uint64_t PPMParser::parse_sample() { +U64 PPMParser::parse_sample() { skip_whitespace(); auto sample = chomp_number(); skip_whitespace(); return sample; } -uint64_t PPMParser::chomp_number() { +U64 PPMParser::chomp_number() { auto raw = chomp_part(); - uint64_t number = 0; - for (uint8_t digit_ascii : raw) { + U64 number = 0; + for (U8 digit_ascii : raw) { if (digit_ascii < '0' || digit_ascii > '9') { throw std::runtime_error("Number contains non ASCII digits."); } - uint8_t digit = digit_ascii - '0'; + U8 digit = digit_ascii - '0'; number *= 10; number += digit; @@ -108,7 +108,7 @@ uint64_t PPMParser::chomp_number() { } std::string_view PPMParser::chomp_part() { - uint64_t length = 0; + U64 length = 0; while (!is_eof()) { auto c = m_source[m_cursor + length]; @@ -127,7 +127,7 @@ std::string_view PPMParser::chomp_part() { void PPMParser::skip_whitespace() { while (!is_eof()) { - uint8_t c = m_source[m_cursor]; + U8 c = m_source[m_cursor]; if (c == '#') { skip_comment(); continue; @@ -142,7 +142,7 @@ void PPMParser::skip_whitespace() { } void PPMParser::skip_comment() { - uint8_t c = m_source[m_cursor]; + U8 c = m_source[m_cursor]; if (c != '#') { return; } @@ -152,7 +152,7 @@ void PPMParser::skip_comment() { } } -bool PPMParser::is_eof() const { +Bool PPMParser::is_eof() const { return m_cursor >= m_source.size(); } |
