AeonGUI
A portable video game graphic user interface library.
Loading...
Searching...
No Matches
RasterImage.hpp
1/*
2Copyright (C) 2026 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16#ifndef AEONGUI_RASTERIMAGE_H
17#define AEONGUI_RASTERIMAGE_H
18
19#include <cstddef>
20#include <cstdint>
21#include <string>
22#include <vector>
23#include "aeongui/Platform.hpp"
24
25namespace AeonGUI
26{
33 {
34 public:
36 enum class EncodedFormat
37 {
42 };
43
45 enum class PixelFormat
46 {
49 };
50
52 DLL RasterImage();
53
58 DLL void LoadFromFile ( const std::string& aPath );
64 DLL void LoadFromMemory ( const void* aData, size_t aSize );
66 DLL void Clear();
67
71 [[nodiscard]] DLL bool IsLoaded() const;
75 [[nodiscard]] DLL EncodedFormat GetEncodedFormat() const;
79 [[nodiscard]] DLL PixelFormat GetPixelFormat() const;
83 [[nodiscard]] DLL uint32_t GetWidth() const;
87 [[nodiscard]] DLL uint32_t GetHeight() const;
91 [[nodiscard]] DLL size_t GetStride() const;
95 [[nodiscard]] DLL const uint8_t* GetPixels() const;
99 [[nodiscard]] DLL const std::vector<uint8_t>& GetPixelData() const;
100
101 private:
102 EncodedFormat mEncodedFormat;
103 PixelFormat mPixelFormat;
104 uint32_t mWidth;
105 uint32_t mHeight;
106 std::vector<uint8_t> mPixelData;
107 };
108}
109
110#endif
Platform-specific DLL import/export macros and compiler helpers.
const uint8_t * GetPixels() const
Get a pointer to the decoded pixel data.
Definition RasterImage.cpp:416
RasterImage()
Default constructor. Creates an empty (unloaded) image.
Definition RasterImage.cpp:275
uint32_t GetWidth() const
Get the image width in pixels.
Definition RasterImage.cpp:401
PixelFormat
Decoded pixel formats.
Definition RasterImage.hpp:46
@ RGBA8
8 bits per channel, RGBA.
Definition RasterImage.hpp:48
EncodedFormat GetEncodedFormat() const
Get the original encoded format of the loaded image.
Definition RasterImage.cpp:391
void LoadFromMemory(const void *aData, size_t aSize)
Load an image from a memory buffer.
Definition RasterImage.cpp:318
size_t GetStride() const
Get the stride (bytes per row) of the decoded image.
Definition RasterImage.cpp:411
EncodedFormat
Supported encoded image formats.
Definition RasterImage.hpp:37
@ PNG
PNG format.
Definition RasterImage.hpp:39
@ Unknown
Format not recognized.
Definition RasterImage.hpp:38
@ JPEG
JPEG format.
Definition RasterImage.hpp:40
@ PCX
PCX format.
Definition RasterImage.hpp:41
void LoadFromFile(const std::string &aPath)
Load an image from a file.
Definition RasterImage.cpp:283
PixelFormat GetPixelFormat() const
Get the decoded pixel format.
Definition RasterImage.cpp:396
void Clear()
Release the decoded pixel data.
Definition RasterImage.cpp:377
uint32_t GetHeight() const
Get the image height in pixels.
Definition RasterImage.cpp:406
const std::vector< uint8_t > & GetPixelData() const
Get a reference to the decoded pixel data vector.
Definition RasterImage.cpp:421
bool IsLoaded() const
Check whether an image has been loaded.
Definition RasterImage.cpp:386