blob: 77f1cec555180e77ef98de84ed94ff6fe2749bc5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#pragma once
#include "../../Common/Sizes.hpp"
#include <string_view>
#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;
};
}
|