Used to load an image. It can flip and image and add padding to it. Mainly used for texture loading.
More...
#include <Image.hpp>
|
| void | FlipVertically () |
| | Flips a loaded image vertically.
|
| void | FlipHorizontally () |
| | Flips a loaded image horizontally.
|
| void * | GetPixelData () const |
| | Gives you the pointer to the start of the pixel data, format is RGBA8888.
|
| uint32_t | GetWidth () const |
| | Gives you the image width.
|
| uint32_t | GetHeight () const |
| | Gives you the image height.
|
| bool | HasSemiTransparency () const |
| | Checks if an image has semi transparency or no.
|
| bool | GetSuccessStatus () const |
| | Checks if the image was loaded successfully.
|
| bool | IsPadded () const |
| | Checks if an image is padded.
|
| std::expected< void, Core::CoriError<> > | AddPadding (const glm::u16vec2 spriteResolution) |
| | Adds padding to the image that will be used in a sprite atlas.
|
| | ~Image () |
|
| static std::shared_ptr< Image > | Create (const std::filesystem::path &path) |
| | Creates an Image from the picture at the specified path.
|
Used to load an image. It can flip and image and add padding to it. Mainly used for texture loading.
Definition at line 9 of file Image.hpp.
◆ ~Image()
| Cori::Graphics::Image::~Image |
( |
| ) |
|
◆ AddPadding()
| std::expected< void, Core::CoriError<> > Cori::Graphics::Image::AddPadding |
( |
const glm::u16vec2 | spriteResolution | ) |
|
Adds padding to the image that will be used in a sprite atlas.
It is needed to avoid the GPU from sampling a wrong texel in an event of floating point error. Prevents texel bleeding, or some call it sprite atlas/sheet bleeding. SpriteAtlas does this automatically, so no need to call this manually before giving the Image to the SpriteAtlas.
- Parameters
-
| spriteResolution | Resolution of one Sprite in a SpriteAtlas. |
- Returns
- Expected object with void on success or CoriError<> on failure.
Definition at line 99 of file Image.cpp.
◆ Create()
| std::shared_ptr< Image > Cori::Graphics::Image::Create |
( |
const std::filesystem::path & | path | ) |
|
|
staticnodiscard |
Creates an Image from the picture at the specified path.
- Parameters
-
- Returns
- Shared pointer to the created Image object.
Definition at line 189 of file Image.cpp.
◆ FlipHorizontally()
| void Cori::Graphics::Image::FlipHorizontally |
( |
| ) |
|
Flips a loaded image horizontally.
Definition at line 216 of file Image.cpp.
◆ FlipVertically()
| void Cori::Graphics::Image::FlipVertically |
( |
| ) |
|
Flips a loaded image vertically.
Definition at line 194 of file Image.cpp.
◆ GetHeight()
| uint32_t Cori::Graphics::Image::GetHeight |
( |
| ) |
const |
|
nodiscard |
Gives you the image height.
- Returns
- Image height.
Definition at line 91 of file Image.cpp.
◆ GetPixelData()
| void * Cori::Graphics::Image::GetPixelData |
( |
| ) |
const |
|
nodiscard |
Gives you the pointer to the start of the pixel data, format is RGBA8888.
- Returns
- Void pointer to the pixel data.
Definition at line 83 of file Image.cpp.
◆ GetSuccessStatus()
| bool Cori::Graphics::Image::GetSuccessStatus |
( |
| ) |
const |
|
inlinenodiscard |
Checks if the image was loaded successfully.
- Returns
- True means image was loaded successful, false means image loading failed and the image contains a placeholder.
Definition at line 51 of file Image.hpp.
◆ GetWidth()
| uint32_t Cori::Graphics::Image::GetWidth |
( |
| ) |
const |
|
nodiscard |
Gives you the image width.
- Returns
- Image width.
Definition at line 87 of file Image.cpp.
◆ HasSemiTransparency()
| bool Cori::Graphics::Image::HasSemiTransparency |
( |
| ) |
const |
|
nodiscard |
Checks if an image has semi transparency or no.
Image is considered semi transparent if at least one Alpha chanel Byte is not 0x00 or not 0xFF.
- Returns
- True if semi transparent, false otherwise.
Definition at line 95 of file Image.cpp.
◆ IsPadded()
| bool Cori::Graphics::Image::IsPadded |
( |
| ) |
const |
|
inlinenodiscard |
Checks if an image is padded.
- Returns
- True if is padded, false otherwise.
Definition at line 57 of file Image.hpp.
The documentation for this class was generated from the following files: