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;
|
||||
}
|
||||
}
|
||||
|
|
@ -18,10 +18,6 @@ License along with this library; if not, write to the Free Software
|
|||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
module;
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "../lib/stb_image.h"
|
||||
#include "../lib/stb_truetype.h"
|
||||
module Crafter.Graphics:RenderingElement_impl;
|
||||
import :RenderingElement;
|
||||
import :Window;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ TextElement::TextElement() : RenderingElement() {
|
|||
|
||||
}
|
||||
|
||||
TextElement::TextElement(const std::string_view text, float size, Pixel_BU8_GU8_RU8_AU8 pixel, Font& font, 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) {
|
||||
TextElement::TextElement(const std::string_view text, float size, Pixel_BU8_GU8_RU8_AU8 pixel, Font& font, 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) {
|
||||
RenderText(text, size, pixel, font);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue