optimizations
This commit is contained in:
parent
bf6793e41d
commit
16c10a5c4a
3 changed files with 8 additions and 7 deletions
|
|
@ -34,7 +34,7 @@ ImageElement::ImageElement() : RenderingElement() {
|
|||
|
||||
}
|
||||
|
||||
ImageElement::ImageElement(const std::string_view imagePath, std::int_fast32_t anchorX, std::int_fast32_t anchorY, std::uint_fast32_t relativeWidth, std::uint_fast32_t relativeHeight, std::int_fast32_t anchorOffsetX, std::int_fast32_t anchorOffsetY, std::int_fast32_t z, bool ignoreScaling) : RenderingElement(anchorX, anchorY, relativeWidth, relativeHeight, anchorOffsetX, anchorOffsetY, z, ignoreScaling) {
|
||||
ImageElement::ImageElement(const std::string_view imagePath, std::int_fast32_t anchorX, std::int_fast32_t anchorY, std::uint_fast32_t relativeWidth, std::uint_fast32_t relativeHeight, std::int_fast32_t anchorOffsetX, std::int_fast32_t anchorOffsetY, std::int_fast32_t z, bool ignoreScaling) : RenderingElement(false, anchorX, anchorY, relativeWidth, relativeHeight, anchorOffsetX, anchorOffsetY, z, ignoreScaling) {
|
||||
RenderImage(imagePath);
|
||||
}
|
||||
|
||||
|
|
@ -42,7 +42,8 @@ void ImageElement::RenderImage(const std::string_view path) {
|
|||
std::filesystem::path abs = std::filesystem::absolute(path);
|
||||
int xSize;
|
||||
int ySize;
|
||||
unsigned char* bgData = stbi_load(abs.string().c_str(), &xSize, &ySize, nullptr, 4);
|
||||
int channels;
|
||||
unsigned char* bgData = stbi_load(abs.string().c_str(), &xSize, &ySize, &channels, 4);
|
||||
|
||||
ResizeBuffer(xSize, ySize);
|
||||
|
||||
|
|
@ -55,4 +56,8 @@ void ImageElement::RenderImage(const std::string_view path) {
|
|||
buffer[x*ySize+y].a = bgData[idx+3];
|
||||
}
|
||||
}
|
||||
|
||||
if(channels != 4) {
|
||||
opaque = true;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue