2023-11-29 16:11:35 +02:00
|
|
|
#pragma once
|
|
|
|
|
2024-05-23 15:43:26 +03:00
|
|
|
#include <BAN/StringView.h>
|
2023-11-29 16:11:35 +02:00
|
|
|
#include <BAN/UniqPtr.h>
|
2024-05-23 15:43:26 +03:00
|
|
|
#include <BAN/Vector.h>
|
2023-11-29 16:11:35 +02:00
|
|
|
|
|
|
|
class Image
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct Color
|
|
|
|
{
|
|
|
|
uint8_t r;
|
|
|
|
uint8_t g;
|
|
|
|
uint8_t b;
|
|
|
|
uint8_t a;
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
static BAN::UniqPtr<Image> load_from_file(BAN::StringView path);
|
|
|
|
|
|
|
|
uint64_t width() const { return m_width; }
|
|
|
|
uint64_t height() const { return m_height; }
|
|
|
|
|
|
|
|
bool render_to_framebuffer();
|
|
|
|
|
2023-11-29 20:56:05 +02:00
|
|
|
private:
|
2023-11-29 16:11:35 +02:00
|
|
|
Image(uint64_t width, uint64_t height, BAN::Vector<Color>&& bitmap)
|
|
|
|
: m_width(width)
|
|
|
|
, m_height(height)
|
|
|
|
, m_bitmap(BAN::move(bitmap))
|
|
|
|
{ }
|
|
|
|
|
2023-11-29 20:56:05 +02:00
|
|
|
private:
|
2023-11-29 16:11:35 +02:00
|
|
|
const uint64_t m_width;
|
|
|
|
const uint64_t m_height;
|
|
|
|
const BAN::Vector<Color> m_bitmap;
|
2023-11-29 20:56:05 +02:00
|
|
|
|
|
|
|
friend class BAN::UniqPtr<Image>;
|
2023-11-29 16:11:35 +02:00
|
|
|
};
|