A simple Bitmap class that loads and writes images using stb.
More...
#include <Bitmap.hpp>
|
| | Bitmap ()=default |
| | Default constructor.
|
| |
| | Bitmap (const VirtualPath &assetPath) |
| | Constructs a bitmap from an asset path.
|
| |
| | Bitmap (const glm::uvec2 &size, uint32_t bytesPerPixel=4) |
| | Constructs an empty bitmap of the given size.
|
| |
| | Bitmap (const std::vector< uint8_t > &data, const glm::uvec2 &size, uint32_t bytesPerPixel=4) |
| | Constructs a bitmap with preloaded image data.
|
| |
| bool | Load (const VirtualPath &assetPath) |
| | Loads an image from the given asset path. This function uses stb_image to load an image from memory. The asset path should have been resolved already (via your asset system).
|
| |
| bool | Write (const VirtualPath &assetPath) const |
| | Writes the bitmap as a PNG to the given asset path.
|
| |
| | operator bool () const noexcept |
| | Implicit conversion to bool. Returns true if the bitmap contains valid data.
|
| |
| uint32_t | GetLength () const |
| | Returns the total number of bytes in the image.
|
| |
|
void | Clear () |
| |
|
const std::string & | GetFilename () const |
| |
|
void | SetFilename (const std::string &f) |
| |
|
const std::vector< uint8_t > & | GetData () const |
| |
|
std::vector< uint8_t > & | GetData () |
| |
|
void | SetData (const std::vector< uint8_t > &d) |
| |
|
void | SetData (std::vector< uint8_t > &&d) |
| |
|
const glm::uvec2 & | GetSize () const |
| |
|
void | SetSize (const glm::uvec2 &s) |
| |
|
uint32_t | GetBytesPerPixel () const |
| |
|
void | SetBytesPerPixel (uint32_t bpp) |
| |
A simple Bitmap class that loads and writes images using stb.
◆ Bitmap() [1/4]
| PixelBullet::Bitmap::Bitmap |
( |
| ) |
|
|
default |
◆ Bitmap() [2/4]
| PixelBullet::Bitmap::Bitmap |
( |
const VirtualPath & | assetPath | ) |
|
|
inlineexplicit |
Constructs a bitmap from an asset path.
- Parameters
-
| assetPath | A fully resolved path to the image asset. |
◆ Bitmap() [3/4]
| PixelBullet::Bitmap::Bitmap |
( |
const glm::uvec2 & | size, |
|
|
uint32_t | bytesPerPixel = 4 ) |
|
inline |
Constructs an empty bitmap of the given size.
- Parameters
-
| size | The image dimensions. |
| bytesPerPixel | The number of bytes per pixel (default is 4 for RGBA). |
◆ Bitmap() [4/4]
| PixelBullet::Bitmap::Bitmap |
( |
const std::vector< uint8_t > & | data, |
|
|
const glm::uvec2 & | size, |
|
|
uint32_t | bytesPerPixel = 4 ) |
|
inline |
Constructs a bitmap with preloaded image data.
- Parameters
-
| data | The raw image data. |
| size | The image dimensions. |
| bytesPerPixel | The number of bytes per pixel. |
◆ GetLength()
| uint32_t PixelBullet::Bitmap::GetLength |
( |
| ) |
const |
Returns the total number of bytes in the image.
◆ Load()
| bool PixelBullet::Bitmap::Load |
( |
const VirtualPath & | assetPath | ) |
|
Loads an image from the given asset path. This function uses stb_image to load an image from memory. The asset path should have been resolved already (via your asset system).
- Parameters
-
| assetPath | The path to the image file. |
- Returns
- True on success, false otherwise.
◆ operator bool()
| PixelBullet::Bitmap::operator bool |
( |
| ) |
const |
|
inlineexplicitnoexcept |
Implicit conversion to bool. Returns true if the bitmap contains valid data.
◆ Write()
| bool PixelBullet::Bitmap::Write |
( |
const VirtualPath & | assetPath | ) |
const |
Writes the bitmap as a PNG to the given asset path.
- Parameters
-
| assetPath | The output path (directories will be created if needed). |
- Returns
- True on success, false otherwise.
The documentation for this class was generated from the following files:
- engine/src/PixelBullet/Assets/Bitmap.hpp
- engine/src/PixelBullet/Assets/Bitmap.cpp