blob: 9f156b874df5dbcc73ab751d9256c891059b9371 (
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
|
#include "RawImage.hpp"
#include <sstream>
namespace MC::GFX::Image {
void RawImage::add(Pixel pixel) {
m_pixels.push_back(pixel);
}
USize RawImage::size() const {
return m_pixels.size();
}
U8* RawImage::raw() const {
return (U8*)m_pixels.data();
}
U32 RawImage::width() const {
return m_width;
}
U32 RawImage::height() const {
return m_height;
}
std::string RawImage::string() const {
std::stringstream str{};
Bool comma = false;
str << "[";
for (const auto [r, g, b, a] : m_pixels) {
if (comma) { str << ", "; }
str << "{r=" << (UInt)r << ", g=" << (UInt)g << ", b=" << (UInt)b << ", a=" << (UInt)a << "}";
comma = true;
}
str << "]";
return str.str();
}
}
|