23struct MutableSubPixmapView;
31 static std::optional<PixmapView>
fromBytes(std::span<const std::uint8_t>
data, std::uint32_t width,
32 std::uint32_t height);
34 [[nodiscard]] std::uint32_t width()
const {
return size_.width(); }
35 [[nodiscard]] std::uint32_t height()
const {
return size_.height(); }
36 [[nodiscard]] IntSize size()
const {
return size_; }
39 [[nodiscard]] std::span<const std::uint8_t>
data()
const {
40 return std::span<const std::uint8_t>(data_, len_);
44 [[nodiscard]] std::span<const PremultipliedColorU8>
pixels()
const;
47 [[nodiscard]] std::optional<PremultipliedColorU8>
pixel(std::uint32_t x, std::uint32_t y)
const;
56 : data_(
data), len_(len), size_(size) {}
58 const std::uint8_t* data_ =
nullptr;
69 : data_(
data), len_(len), size_(size) {}
72 static std::optional<MutablePixmapView>
fromBytes(std::span<std::uint8_t>
data, std::uint32_t width,
73 std::uint32_t height);
75 [[nodiscard]] std::uint32_t width()
const {
return size_.width(); }
76 [[nodiscard]] std::uint32_t height()
const {
return size_.height(); }
77 [[nodiscard]] IntSize size()
const {
return size_; }
80 [[nodiscard]] std::span<std::uint8_t>
data()
const {
81 return std::span<std::uint8_t>(data_, len_);
85 [[nodiscard]] std::span<PremultipliedColorU8>
pixels()
const;
88 [[nodiscard]] MutableSubPixmapView
subpixmap()
const;
91 [[nodiscard]] std::optional<MutableSubPixmapView>
subpixmap(
const IntRect& rect)
const;
94 std::uint8_t* data_ =
nullptr;
101struct MutableSubPixmapView {
103 std::size_t realWidth = 0;
104 std::uint8_t* data =
nullptr;
106 [[nodiscard]] std::size_t width()
const {
return size.width(); }
107 [[nodiscard]] std::size_t height()
const {
return size.height(); }
108 [[nodiscard]] std::span<std::uint8_t> dataSpan()
const;
121 static std::optional<Pixmap>
fromSize(std::uint32_t width, std::uint32_t height);
132 [[nodiscard]] std::uint32_t width()
const {
return size_.width(); }
133 [[nodiscard]] std::uint32_t height()
const {
return size_.height(); }
134 [[nodiscard]] IntSize size()
const {
return size_; }
137 [[nodiscard]] std::span<const std::uint8_t>
data()
const {
138 return std::span<const std::uint8_t>(data_.data(), data_.size());
142 [[nodiscard]] std::span<std::uint8_t>
data() {
143 return std::span<std::uint8_t>(data_.data(), data_.size());
146 [[nodiscard]] std::span<const PremultipliedColorU8> pixels()
const;
147 [[nodiscard]] std::span<PremultipliedColorU8> pixels();
150 [[nodiscard]] std::optional<PremultipliedColorU8>
pixel(std::uint32_t x, std::uint32_t y)
const;
159 [[nodiscard]] std::vector<std::uint8_t>
release();
167 : data_(std::move(
data)), size_(size) {}
169 std::vector<std::uint8_t> data_;
Color types (8-bit and floating-point, straight and premultiplied).
Geometric primitives: Rect, IntRect, ScreenIntRect, IntSize.
constexpr std::size_t kBytesPerPixel
Bytes per pixel (always 4: RGBA premultiplied).
Definition Pixmap.h:20
Floating-point RGBA color [0,1] (straight alpha).
Definition Color.h:88
Signed integer rectangle (x, y, width, height).
Definition Geom.h:85
Non-zero integer dimensions (width x height).
Definition Geom.h:18
Mutable view into RGBA pixel data. Does not own memory. Primary drawing target for all rendering oper...
Definition Pixmap.h:65
std::span< PremultipliedColorU8 > pixels() const
Pixel data as mutable PremultipliedColorU8 span.
std::optional< MutableSubPixmapView > subpixmap(const IntRect &rect) const
Returns a sub-view for the given rectangle, or nullopt if out of bounds.
std::span< std::uint8_t > data() const
Raw mutable byte data (premultiplied RGBA).
Definition Pixmap.h:80
MutableSubPixmapView subpixmap() const
Returns a sub-view covering the full pixmap.
static std::optional< MutablePixmapView > fromBytes(std::span< std::uint8_t > data, std::uint32_t width, std::uint32_t height)
Creates a mutable view from raw byte data. Returns nullopt if size mismatches.
Immutable view into RGBA pixel data. Does not own memory.
Definition Pixmap.h:26
static std::optional< PixmapView > fromBytes(std::span< const std::uint8_t > data, std::uint32_t width, std::uint32_t height)
Creates a view from raw byte data. Returns nullopt if size mismatches.
std::span< const std::uint8_t > data() const
Raw byte data (premultiplied RGBA).
Definition Pixmap.h:39
std::span< const PremultipliedColorU8 > pixels() const
Pixel data as PremultipliedColorU8 span.
std::optional< Pixmap > cloneRect(const IntRect &rect) const
Clones a rectangular region into a new Pixmap.
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.
Owned RGBA pixel buffer. Always premultiplied alpha internally.
Definition Pixmap.h:116
MutablePixmapView mutableView()
Mutable view — the primary drawing target.
Definition Pixmap.h:130
std::vector< std::uint8_t > releaseDemultiplied()
Releases the byte buffer after converting to straight (non-premultiplied) alpha. Use this for PNG enc...
void fill(const Color &color)
Fills the entire pixmap with a color (premultiplied internally).
PixmapView view() const
Immutable view.
Definition Pixmap.h:127
static std::optional< Pixmap > fromVec(std::vector< std::uint8_t > data, IntSize size)
Creates a pixmap from existing data. Returns nullopt if size mismatches.
std::optional< Pixmap > cloneRect(const IntRect &rect) const
Clones a rectangular region into a new Pixmap.
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::vector< std::uint8_t > release()
Releases the raw byte buffer (premultiplied alpha).
std::span< const std::uint8_t > data() const
Raw byte data (premultiplied RGBA), const.
Definition Pixmap.h:137
std::span< std::uint8_t > data()
Raw byte data (premultiplied RGBA), mutable.
Definition Pixmap.h:142
static std::optional< Pixmap > fromSize(std::uint32_t width, std::uint32_t height)
Creates a zero-filled pixmap. Returns nullopt for zero dimensions.