rename engine to src
This commit is contained in:
32
src/image.h
Normal file
32
src/image.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
namespace ui {
|
||||
|
||||
class Image
|
||||
{
|
||||
public:
|
||||
std::unique_ptr<uint8_t[]> m_data;
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
int comp = 4;
|
||||
bool load(std::string filename);
|
||||
bool load_file(std::string filename);
|
||||
const uint8_t* data() const { return m_data.get(); }
|
||||
int size() const { return width * height * comp; }
|
||||
void create(int w, int h)
|
||||
{
|
||||
width = w;
|
||||
height = h;
|
||||
comp = 4;
|
||||
m_data = std::make_unique<uint8_t[]>(size());
|
||||
}
|
||||
void copy_from(const uint8_t* data)
|
||||
{
|
||||
std::copy(data, data + size(), m_data.get());
|
||||
}
|
||||
void flip();
|
||||
void create() { m_data = std::make_unique<uint8_t[]>(size()); }
|
||||
Image resize(int w, int h);
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user