Pixmap
-
class Pixmap
Owning or non-owning pixel buffer.
Use Alloc() to create an owned buffer, or Wrap() to reference external memory.
Public Functions
-
Pixmap() = default
-
Pixmap(const Pixmap&) = delete
-
Pixmap(Pixmap &&other) noexcept
-
~Pixmap()
-
inline void *addr()
Get raw pixel pointer (mutable).
-
inline const void *addr() const
Get raw pixel pointer (const).
-
inline u32 *addr32()
Get pixel pointer as u32* (mutable).
-
inline const u32 *addr32() const
Get pixel pointer as u32* (const).
-
inline u8 *addr8()
Get pixel pointer as u8* (mutable).
-
inline const u8 *addr8() const
Get pixel pointer as u8* (const).
-
void clear(Color c)
Fill the entire buffer with a color.
- Parameters:
c – The fill color.
-
inline PixelFormat format() const
Get pixel format.
-
inline i32 height() const
Get height in pixels.
-
inline const PixmapInfo &info() const
Get the pixmap info descriptor.
-
void reallocate(const PixmapInfo &info)
Reallocate the buffer with new dimensions/format.
- Parameters:
info – New pixmap descriptor.
-
void reset()
Release pixel data and reset to empty state.
-
inline void *rowAddr(i32 y)
Get pointer to the start of a specific row (mutable).
- Parameters:
y – Row index.
-
inline const void *rowAddr(i32 y) const
Get pointer to the start of a specific row (const).
- Parameters:
y – Row index.
-
inline i32 stride() const
Get row stride in bytes.
-
inline bool valid() const
Check if the pixmap has valid pixel data.
- Returns:
True if pixels are non-null and dimensions are positive.
-
inline i32 width() const
Get width in pixels.
Public Static Functions
-
static Pixmap Alloc(const PixmapInfo &info)
Allocate a new pixel buffer described by info.
- Parameters:
info – Dimensions, stride, and format of the buffer.
- Returns:
A new Pixmap that owns its pixel data.
-
static Pixmap Wrap(const PixmapInfo &info, void *pixels)
Wrap existing pixel memory (caller keeps ownership).
- Parameters:
info – Dimensions, stride, and format of the buffer.
pixels – Pointer to the external pixel data.
- Returns:
A non-owning Pixmap.
-
Pixmap() = default
-
struct PixmapInfo
Descriptor for pixel buffer dimensions, stride, and format.
Public Functions
-
inline i32 bytesPerPixel() const
Get bytes per pixel (always 4 for current formats).
- Returns:
Bytes per pixel.
-
inline i32 computeByteSize() const
Compute total byte size of the pixel buffer.
- Returns:
stride × height.
Public Members
-
PixelFormat format = PixelFormat::RGBA8888
Pixel format.
-
i32 height = 0
Height in pixels.
-
i32 stride = 0
Bytes per row.
-
i32 width = 0
Width in pixels.
Public Static Functions
-
static inline PixmapInfo Make(i32 w, i32 h, PixelFormat fmt)
Create a PixmapInfo with the given dimensions and format.
- Parameters:
w – Width in pixels.
h – Height in pixels.
fmt – Pixel format.
- Returns:
A new PixmapInfo.
-
static inline PixmapInfo MakeBGRA(i32 w, i32 h)
Create a PixmapInfo with BGRA8888 format.
- Parameters:
w – Width in pixels.
h – Height in pixels.
- Returns:
A new PixmapInfo with BGRA8888 format.
-
static inline PixmapInfo MakeRGBA(i32 w, i32 h)
Create a PixmapInfo with RGBA8888 format.
- Parameters:
w – Width in pixels.
h – Height in pixels.
- Returns:
A new PixmapInfo with RGBA8888 format.
-
inline i32 bytesPerPixel() const
-
enum class ink::PixelFormat
Pixel format enumeration.
Values:
-
enumerator RGBA8888
Red-Green-Blue-Alpha, 8 bits each.
-
enumerator BGRA8888
Blue-Green-Red-Alpha, 8 bits each (native on many platforms).
-
enumerator RGBA8888