tiny-skia-cpp
A C++20 2D rendering library (port of tiny-skia)
Loading...
Searching...
No Matches
tiny_skia::Pixmap Class Reference

Owned RGBA pixel buffer. Always premultiplied alpha internally. More...

#include <tiny_skia/Pixmap.h>

Public Member Functions

PixmapView view () const
 Immutable view.
 
MutablePixmapView mutableView ()
 Mutable view — the primary drawing target.
 
std::span< const std::uint8_t > data () const
 Raw byte data (premultiplied RGBA), const.
 
std::span< std::uint8_t > data ()
 Raw byte data (premultiplied RGBA), mutable.
 
std::optional< PremultipliedColorU8pixel (std::uint32_t x, std::uint32_t y) const
 Returns the pixel at (x, y), or nullopt if out of bounds.
 
std::optional< PixmapcloneRect (const IntRect &rect) const
 Clones a rectangular region into a new Pixmap.
 
void fill (const Color &color)
 Fills the entire pixmap with a color (premultiplied internally).
 
std::vector< std::uint8_t > release ()
 Releases the raw byte buffer (premultiplied alpha).
 
std::vector< std::uint8_t > releaseDemultiplied ()
 Releases the byte buffer after converting to straight (non-premultiplied) alpha. Use this for PNG encoding.
 

Static Public Member Functions

static std::optional< PixmapfromSize (std::uint32_t width, std::uint32_t height)
 Creates a zero-filled pixmap. Returns nullopt for zero dimensions.
 
static std::optional< PixmapfromVec (std::vector< std::uint8_t > data, IntSize size)
 Creates a pixmap from existing data. Returns nullopt if size mismatches.
 

Detailed Description

Create with Pixmap::fromSize() and obtain a MutablePixmapView via mutableView() for drawing. Call releaseDemultiplied() to extract straight-alpha bytes for PNG encoding.


The documentation for this class was generated from the following file: