#pragma once #include "../../Common/Sizes.hpp" #include #include "RawImage.hpp" namespace MC::GFX::Image { class PPMParser { public: explicit PPMParser(std::string_view source) : m_source(source) {} RawImage parse(); private: enum PPMType { None, P3, P6 }; struct PPMHeader { PPMType type; U32 width; U32 height; U8 max_color; }; PPMHeader parse_header(); RawImage::Pixel parse_pixel(U8 max_color); U64 parse_sample(); U64 chomp_number(); std::string_view chomp_part(); void skip_whitespace(); void skip_comment(); Bool is_eof() const; static constexpr RawImage::Pixel alpha_color{192, 0, 255}; std::string_view m_source; U64 m_cursor = 0; }; }