|
tiny-skia-cpp
A C++20 2D rendering library (port of tiny-skia)
|
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< PremultipliedColorU8 > | pixel (std::uint32_t x, std::uint32_t y) const |
| Returns the pixel at (x, y), or nullopt if out of bounds. | |
| std::optional< Pixmap > | cloneRect (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< Pixmap > | fromSize (std::uint32_t width, std::uint32_t height) |
| Creates a zero-filled pixmap. Returns nullopt for zero dimensions. | |
| static std::optional< Pixmap > | fromVec (std::vector< std::uint8_t > data, IntSize size) |
| Creates a pixmap from existing data. Returns nullopt if size mismatches. | |
Create with Pixmap::fromSize() and obtain a MutablePixmapView via mutableView() for drawing. Call releaseDemultiplied() to extract straight-alpha bytes for PNG encoding.