CoriEngine
Loading...
Searching...
No Matches
Image.hpp
Go to the documentation of this file.
1#pragma once
3
4namespace Cori {
5 namespace Graphics {
9 class Image : public Profiling::Trackable<Image> {
10 public:
14 void FlipVertically();
15
19 void FlipHorizontally();
20
21
26 [[nodiscard]] void* GetPixelData() const;
27
32 [[nodiscard]] uint32_t GetWidth() const;
33
38 [[nodiscard]] uint32_t GetHeight() const;
39
45 [[nodiscard]] bool HasSemiTransparency() const;
46
51 [[nodiscard]] bool GetSuccessStatus() const { return m_SuccessStatus; }
52
57 [[nodiscard]] bool IsPadded() const { return m_IsPadded; }
58
66 std::expected<void, Core::CoriError<>> AddPadding(const glm::u16vec2 spriteResolution);
67
73 [[nodiscard]] static std::shared_ptr<Image> Create(const std::filesystem::path& path);
74
75 ~Image();
76
77 private:
78 explicit Image(const std::filesystem::path& path);
79
80 bool m_HasSemiTransparency{ false };
81
82 bool m_SuccessStatus{ false };
83 bool m_IsPadded{ false };
84 void* m_Surface;
85 };
86 }
87}
Used to load an image. It can flip and image and add padding to it. Mainly used for texture loading.
Definition Image.hpp:9
bool HasSemiTransparency() const
Checks if an image has semi transparency or no.
Definition Image.cpp:95
uint32_t GetWidth() const
Gives you the image width.
Definition Image.cpp:87
void * GetPixelData() const
Gives you the pointer to the start of the pixel data, format is RGBA8888.
Definition Image.cpp:83
bool GetSuccessStatus() const
Checks if the image was loaded successfully.
Definition Image.hpp:51
bool IsPadded() const
Checks if an image is padded.
Definition Image.hpp:57
void FlipVertically()
Flips a loaded image vertically.
Definition Image.cpp:194
void FlipHorizontally()
Flips a loaded image horizontally.
Definition Image.cpp:216
static std::shared_ptr< Image > Create(const std::filesystem::path &path)
Creates an Image from the picture at the specified path.
Definition Image.cpp:189
std::expected< void, Core::CoriError<> > AddPadding(const glm::u16vec2 spriteResolution)
Adds padding to the image that will be used in a sprite atlas.
Definition Image.cpp:99
uint32_t GetHeight() const
Gives you the image height.
Definition Image.cpp:91
For InstanceMetrics to work with a type it should derive from this.
Definition Trackable.hpp:29
Almost everything connected to graphics is in this namespace.
Definition Window.hpp:7
Global engine namespace.