3 #define STB_IMAGE_IMPLEMENTATION
10 stbi_image_free(image);
14 Image::Image(std::string identifier_,
bool vFlip)
16 , verticalFlip(vFlip) {}
18 void Image::compile(
const byte buffer[], std::size_t bufferLen) {
20 this->image = Image::getUncompressedImage(buffer,
static_cast<int>(bufferLen) - 1, &w, &h, &bd, 0, this->isVerticallyFlipped());
26 byte* Image::getUncompressedImage(
const byte buffer[],
int bufferLen,
int* width,
int* height,
int* fileChannels,
int desiredChannels,
bool vflip) {
27 stbi_set_flip_vertically_on_load(vflip);
28 return stbi_load_from_memory(buffer, bufferLen, width, height, fileChannels, desiredChannels);
31 byte* Image::getUncompressedImage(
const byte buffer[],
int bufferLen,
int desiredChannels,
bool vflip) {
32 int width, height, fileChannels;
33 return Image::getUncompressedImage(buffer, bufferLen, &width, &height, &fileChannels, desiredChannels, vflip);
36 byte* Image::getUncompressedImage(std::string_view filepath,
int* width,
int* height,
int* fileChannels,
int desiredChannels,
bool vflip) {
37 stbi_set_flip_vertically_on_load(vflip);
38 return stbi_load(filepath.data(), width, height, fileChannels, desiredChannels);
41 byte* Image::getUncompressedImage(std::string_view filepath,
int desiredChannels,
bool vflip) {
42 int width, height, fileChannels;
43 return Image::getUncompressedImage(filepath, &width, &height, &fileChannels, desiredChannels, vflip);
46 void Image::deleteUncompressedImage(
byte* image) {
48 stbi_image_free(image);
A chunk of data, usually a file. Is typically cached and shared.