Files
panopainter/engine/image.cpp

25 lines
538 B
C++

#include "pch.h"
#include "log.h"
#include "image.h"
#include "asset.h"
#include <stb/stb_image.h>
using namespace ui;
bool Image::load(std::string filename)
{
stbi_set_flip_vertically_on_load(false);
Asset file;
if (!(file.open(filename.c_str()) && file.read_all()))
{
file.close();
return false;
}
uint8_t* buffer = stbi_load_from_memory(file.m_data, file.m_len, &width, &height, nullptr, 4);
file.close();
comp = 4;
m_data = std::unique_ptr<uint8_t[]>(buffer);
return true;
}