refactor Brush to be used in shared_ptr

This commit is contained in:
2019-01-22 22:49:43 +01:00
parent 9e76cf3194
commit e26fcf1163
22 changed files with 254 additions and 197 deletions

View File

@@ -7,18 +7,25 @@
bool Image::load(std::string filename)
{
stbi_set_flip_vertically_on_load(false);
Asset file;
if (!(file.open(filename.c_str()) && file.read_all()))
if (Asset::is_asset(filename))
{
Asset file;
if (!(file.open(filename.c_str()) && file.read_all()))
{
file.close();
return false;
}
stbi_set_flip_vertically_on_load(false);
uint8_t* buffer = stbi_load_from_memory(file.m_data, file.m_len, &width, &height, nullptr, 4);
file.close();
return false;
comp = 4;
m_data = std::unique_ptr<uint8_t[]>(buffer);
return true;
}
else
{
return load_file(filename);
}
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;
}
bool Image::load_file(std::string filename)