INNER CODE UNIT · C++
buffer
symphony-of-empires/symphony-of-empires · eng3d/eng3d/binary_image.cpp:55
buffer = std::make_unique<uint8_t[]>(width * height);*/
}
Eng3D::BinaryImage::BinaryImage(const Eng3D::BinaryImage& tex)
: Eng3D::BinaryImage(tex.width, tex.height, tex.bpp)
{
if(tex.bpp != this->bpp && this->bpp != 32)
CXX_THROW(BinaryImageException, "internal", "Can't do 16-bit/8-bit copies");
std::memcpy(buffer.get(), tex.buffer.get(), sizeof(uint32_t) * (width * height));
}
void Eng3D::BinaryImage::from_file(const Eng3D::IO::Path& path) {
// stbi can do the conversion to RGBA for us ;)
int i_width, i_height, i_channels;
auto* c_buffer = stbi_load(path.str.c_str(), &i_width, &i_height, &i_channels, 4);
if(c_buffer == nullptr)
CXX_THROW(BinaryImageException, path.str, stbi_failure_reason());
width = static_cast<size_t>(i_width);