46 operator u32()
const {
return (
a << 24) | (
b << 16) | (
g << 8) |
r; }
98 void Resize(
unsigned int new_width,
unsigned int new_height);
108 [[nodiscard]]
static STexture Import(
const std::filesystem::path& path,
bool flip =
false);
139 void ExportPNG(
const std::filesystem::path& path,
bool flip =
false)
const;
Contains macros and definitions for fixed-width types.
std::uint32_t u32
32-bit unsigned integer
Definition fixed_type.hpp:60
std::uint8_t u8
8-bit unsigned integer
Definition fixed_type.hpp:64
std::vector< SPixel > bitmap
Pixel data of the texture.
Definition stexture.hpp:88
STextureFilter min_filter
Texture sampling filter.
Definition stexture.hpp:84
void QuantizeAlpha(unsigned int levels=256)
Reduces alpha channel precision to the specified number of levels.
void FlipV()
Flips the texture vertically.
unsigned int height
Height of the texture in pixels.
Definition stexture.hpp:82
STextureFilter mag_filter
Texture sampling filter.
Definition stexture.hpp:86
u8 b
Blue channel [0, 255].
Definition stexture.hpp:39
u8 g
Green channel [0, 255].
Definition stexture.hpp:38
SValue extras
Any additional custom data.
Definition stexture.hpp:90
Buffer ExportPNG(bool flip=false) const
Exports the texture to a PNG file.
static STexture Import(BufferView buffer, bool flip=false)
Constructs a texture from the specified buffer.
void Resize(unsigned int new_width, unsigned int new_height)
Resizes the texture.
void AlignWidth()
Aligns the width to the next power of 2.
void AlignHeight()
Aligns the height to the next power of 2.
static STexture GenerateChessPattern(unsigned int width=128, unsigned int height=128)
Creates a chessboard pattern texture.
unsigned int width
Width of the texture in pixels.
Definition stexture.hpp:80
std::string name
An optional name for the texture.
Definition stexture.hpp:78
u8 r
Red channel [0, 255].
Definition stexture.hpp:37
static STexture Import(const std::filesystem::path &path, bool flip=false)
Constructs a texture from the specified file path.
u8 a
Alpha channel [0, 255].
Definition stexture.hpp:40
bool HasAlpha() const
Checks if the texture contains any transparent pixels.
void ExportPNG(const std::filesystem::path &path, bool flip=false) const
Exports the texture to a PNG file.
Represents a pixel with red, green, blue, and alpha color channels.
Definition stexture.hpp:36
Represents a simple texture.
Definition stexture.hpp:77
STextureFilter
Specifies the filtering methods used for texture sampling.
Definition stexture.hpp:55
@ kLinear
Linear filtering.
Definition stexture.hpp:57
@ kLinearMipmapLinear
Linear filtering with mipmap selection.
Definition stexture.hpp:61
@ kNearestMipmapNearest
Nearest filtering with mipmap selection.
Definition stexture.hpp:58
@ kNearest
Nearest-neighbor filtering.
Definition stexture.hpp:56
@ kLinearMipmapNearest
Linear filtering with mipmap selection.
Definition stexture.hpp:59
@ kNearestMipmapLinear
Nearest filtering with mipmap selection.
Definition stexture.hpp:60
A class representing JSON-like values (null, bool, numbers, strings, arrays, or objects)
Definition svalue.hpp:41
Provides classes for reading and writing binary data to and from various sources.
Definition exception.hpp:56
Provides a class for representing "extras" fields for custom metadata.