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
8
utl::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
21
utl::Image::~Image
() { stbi_image_free(pixels); }
Image.hpp
This file contains image struct.
utl::Image::~Image
~Image()
Definition
image.cpp:21
utl::Image::Image
Image(const std::filesystem::path &path, bool flip=false)
Load an image from a file.
Definition
image.cpp:8
utl::Image::height
int height
Definition
Image.hpp:34
utl::Image::pixels
pixel pixels
Definition
Image.hpp:32
utl::Image::width
int width
Definition
Image.hpp:33
utl::Image::channels
int channels
Definition
Image.hpp:35
modules
Utils
src
image.cpp
Generated by
1.11.0