Template Struct SharedPixelBuffer

Struct Documentation

template<typename Pixel>
struct SharedPixelBuffer

SharedPixelBuffer is a container for storing image data as pixels. It is internally reference counted and cheap to copy.

You can construct a new empty shared pixel buffer with its default constructor, or you can copy it from an existing contiguous buffer that you might already have, using the range constructor.

See the documentation for Image for examples how to use this type to integrate Slint with external rendering functions.

Public Functions

SharedPixelBuffer() = default

Construct an empty SharedPixelBuffer.

inline SharedPixelBuffer(uint32_t width, uint32_t height)

Construct a SharedPixelBuffer with the given width and height. The pixels are default initialized.

inline SharedPixelBuffer(uint32_t width, uint32_t height, const Pixel *data)

Construct a SharedPixelBuffer by copying the data from the data array. The array must be of size width * height .

inline uint32_t width() const

Returns the width of the buffer in pixels.

inline uint32_t height() const

Returns the height of the buffer in pixels.

inline const Pixel *begin() const

Returns a const pointer to the first pixel of this buffer.

inline const Pixel *end() const

Returns a const pointer past this buffer.

inline Pixel *begin()

Returns a pointer to the first pixel of this buffer.

inline Pixel *end()

Returns a pointer past this buffer.

inline const Pixel *cbegin() const

Returns a const pointer to the first pixel of this buffer.

inline const Pixel *cend() const

Returns a const pointer past this buffer.

bool operator==(const SharedPixelBuffer &other) const = default

Compare two SharedPixelBuffers. They are considered equal if all their pixels are equal.