cae  0.0.0
Cross-API graphics engine
Loading...
Searching...
No Matches
image.cpp
Go to the documentation of this file.
1#include "Utils/Image.hpp"
2
3#define STB_IMAGE_IMPLEMENTATION
4#include <stb_image.h>
5
6#include <stdexcept>
7
8utl::Image::Image(const std::filesystem::path &path, const bool flip)
9{
10 if (flip)
11 {
12 stbi_set_flip_vertically_on_load(1);
13 }
14 pixels = stbi_load(path.string().c_str(), &width, &height, &channels, STBI_rgb_alpha);
15 if (pixels == nullptr)
16 {
17 throw std::runtime_error("Failed to load image: " + path.string());
18 }
19}
20
21utl::Image::~Image() { stbi_image_free(pixels); }
This file contains image struct.
Image(const std::filesystem::path &path, bool flip=false)
Load an image from a file.
Definition image.cpp:8
int height
Definition Image.hpp:34
pixel pixels
Definition Image.hpp:32
int width
Definition Image.hpp:33
int channels
Definition Image.hpp:35