55 lines
975 B
C++
55 lines
975 B
C++
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <filesystem>
|
|
#include <span>
|
|
#include <vector>
|
|
|
|
struct Color
|
|
{
|
|
uint8_t l{};
|
|
};
|
|
|
|
class Bitmap
|
|
{
|
|
public:
|
|
Bitmap(size_t width, size_t height, const Color& clearColor)
|
|
: m_width(width), m_height(height), m_data(width * height, clearColor)
|
|
{
|
|
}
|
|
|
|
// std::span<Color> operator[](size_t row)
|
|
// {
|
|
// return {&m_data[row * m_width], m_width};
|
|
// };
|
|
|
|
// std::span<const Color> operator[](size_t row) const
|
|
// {
|
|
// return {&m_data[row * m_width], m_width};
|
|
// };
|
|
|
|
Color* operator[](size_t row)
|
|
{
|
|
return &m_data[row * m_width];
|
|
};
|
|
|
|
const Color* operator[](size_t row) const
|
|
{
|
|
return &m_data[row * m_width];
|
|
};
|
|
|
|
size_t GetWidth() const
|
|
{
|
|
return m_width;
|
|
}
|
|
|
|
size_t GetHeight() const
|
|
{
|
|
return m_height;
|
|
}
|
|
|
|
private:
|
|
size_t m_width, m_height;
|
|
std::vector<Color> m_data;
|
|
}; |