30 #define STB_IMAGE_WRITE_STATIC 1
31 #define STB_IMAGE_IMPLEMENTATION 1
32 #include "eng3d/stb_image.h"
33 #define STB_IMAGE_WRITE_IMPLEMENTATION 1
34 #include "eng3d/stb_image_write.h"
37 #include "eng3d/binary_image.hpp"
38 #include "eng3d/utils.hpp"
39 #include "eng3d/io.hpp"
40 #include "eng3d/state.hpp"
41 #include "eng3d/log.hpp"
63 if(tex.
bpp != this->bpp && this->bpp != 32)
69 int i_width, i_height, i_channels;
72 auto* c_buffer =
stbi_load(path.
str.c_str(), &i_width, &i_height, &i_channels, 4);
73 if(c_buffer ==
nullptr)
75 width =
static_cast<size_t>(i_width);
76 height =
static_cast<size_t>(i_height);
79 buffer = std::make_unique<uint32_t[]>(width * height);
80 std::memcpy(buffer.get(), c_buffer,
sizeof(uint32_t) * width * height);
85 int channel_count = bpp == 32 ? 4 : bpp == 16 ? 2 : bpp == 8 ? 1 : 0;
86 int stride = channel_count * width;
87 stbi_write_png(filename.c_str(), width, height, channel_count, buffer.get(), stride);
STBIDEF const char * stbi_failure_reason(void)
STBIDEF stbi_uc * stbi_load(char const *filename, int *x, int *y, int *channels_in_file, int desired_channels)
STBIWDEF int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes)
This binary image class helps load images and visual resources from the disk; the binary image IS NOT...
virtual void from_file(const Eng3D::IO::Path &path)
virtual void to_file(const std::string &filename)
std::unique_ptr< uint32_t[]> buffer
The path class abstracts away most of the burden from handling system-dependant filesystem paths.
#define CXX_THROW(class,...)