6#include "../collection.hpp"
7#include "../component_batch.hpp"
8#include "../component_column.hpp"
9#include "../components/draw_order.hpp"
10#include "../components/image_buffer.hpp"
11#include "../components/image_format.hpp"
12#include "../components/opacity.hpp"
13#include "../image_utils.hpp"
14#include "../result.hpp"
193 ErrorCode::InvalidTensorDimension,
194 "Image buffer has the wrong size. Got " + std::to_string(bytes.
size()) +
195 " bytes, expected " + std::to_string(format_.image_format.
num_bytes())
199 *
this = std::move(*this).with_buffer(bytes).with_format(format_);
213 :
Image{std::move(bytes), datatypes::ImageFormat{resolution, pixel_format}} {}
228 :
Image(std::move(bytes), datatypes::ImageFormat(resolution, color_model, datatype)) {}
240 template <
typename T>
242 :
Image(elements.to_uint8(), resolution, color_model, get_datatype(elements.data())) {}
253 template <
typename T>
257 reinterpret_cast<const uint8_t*>(elements),
260 resolution, color_model, get_datatype(elements)
335 Image& operator=(
const Image& other) =
default;
349 return std::move(*
this);
358 return std::move(*
this);
364 return std::move(*
this);
373 return std::move(*
this);
381 return std::move(*
this);
390 return std::move(*
this);
400 return std::move(*
this);
410 return std::move(*
this);
434 template <
typename T>
439 struct AsComponents<archetypes::
Image> {
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
size_t size() const
Returns the number of instances in this collection.
Definition collection.hpp:291
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:99
void handle() const
Handle this error based on the set log handler.
A class for representing either a usable value, or an error.
Definition result.hpp:14
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:76
PixelFormat
Datatype: Specifieds a particular format of an archetypes::Image.
Definition pixel_format.hpp:34
ColorModel
Datatype: Specified what color components are present in an archetypes::Image.
Definition color_model.hpp:26
@ L
Grayscale luminance intencity/brightness/value, sometimes called Y
@ RGBA
Red, Green, Blue, Alpha.
ChannelDatatype
Datatype: The innermost datatype of an image.
Definition channel_datatype.hpp:26
@ U8
8-bit unsigned integer.
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
size_t color_model_channel_count(datatypes::ColorModel color_model)
Returns the number of channels for a given color model.
Definition image_utils.hpp:139
Collection< TElement > borrow(const TElement *data, size_t num_instances=1)
Borrows binary data into a Collection from a pointer.
Definition collection.hpp:462
static Result< ComponentBatch > from_loggable(const rerun::Collection< T > &components, const ComponentDescriptor &descriptor)
Creates a new component batch from a collection of component instances.
Definition component_batch.hpp:46
A ComponentDescriptor fully describes the semantics of a column of data.
Definition component_descriptor.hpp:16
The Loggable trait is used by all built-in implementation of rerun::AsComponents to serialize a colle...
Definition loggable.hpp:11
The width and height of an image.
Definition image_utils.hpp:13
Archetype: A monochrome or color image.
Definition image.hpp:143
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
Image with_draw_order(const rerun::components::DrawOrder &_draw_order) &&
An optional floating point value that specifies the 2D drawing order.
Definition image.hpp:397
static constexpr auto Descriptor_opacity
ComponentDescriptor for the opacity field.
Definition image.hpp:174
Image with_many_format(const Collection< rerun::components::ImageFormat > &_format) &&
This method makes it possible to pack multiple format in a single component batch.
Definition image.hpp:371
Image with_format(const rerun::components::ImageFormat &_format) &&
The format of the image.
Definition image.hpp:362
Image with_buffer(const rerun::components::ImageBuffer &_buffer) &&
The raw image data.
Definition image.hpp:347
static constexpr auto Descriptor_buffer
ComponentDescriptor for the buffer field.
Definition image.hpp:166
static Image from_greyscale8(Collection< uint8_t > bytes, WidthHeight resolution)
Assumes single channel grayscale/luminance with 8-bit per value.
Definition image.hpp:286
Image(Collection< uint8_t > bytes, components::ImageFormat format_)
Construct an image from bytes and image format.
Definition image.hpp:190
Image with_many_opacity(const Collection< rerun::components::Opacity > &_opacity) &&
This method makes it possible to pack multiple opacity in a single component batch.
Definition image.hpp:388
static constexpr auto Descriptor_draw_order
ComponentDescriptor for the draw_order field.
Definition image.hpp:178
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
static constexpr auto Descriptor_format
ComponentDescriptor for the format field.
Definition image.hpp:170
Image(Collection< T > elements, WidthHeight resolution, datatypes::ColorModel color_model)
Construct an image from resolution, color model and elements, inferring the channel datatype from the...
Definition image.hpp:241
static Image clear_fields()
Clear all the fields of a Image.
Image(Collection< uint8_t > bytes, WidthHeight resolution, datatypes::PixelFormat pixel_format)
Construct an image from resolution, pixel format and bytes.
Definition image.hpp:210
Image(const T *elements, WidthHeight resolution, datatypes::ColorModel color_model)
Construct an image from resolution, color model and element pointer, inferring the channel datatype f...
Definition image.hpp:254
std::optional< ComponentBatch > format
The format of the image.
Definition image.hpp:148
Image with_opacity(const rerun::components::Opacity &_opacity) &&
Opacity of the image, useful for layering several images.
Definition image.hpp:379
Image(Collection< uint8_t > bytes, WidthHeight resolution, datatypes::ColorModel color_model, datatypes::ChannelDatatype datatype)
Construct an image from resolution, color model, channel datatype and bytes.
Definition image.hpp:224
Image with_many_draw_order(const Collection< rerun::components::DrawOrder > &_draw_order) &&
This method makes it possible to pack multiple draw_order in a single component batch.
Definition image.hpp:407
static Image update_fields()
Update only some specific fields of a Image.
Definition image.hpp:339
std::optional< ComponentBatch > draw_order
An optional floating point value that specifies the 2D drawing order.
Definition image.hpp:159
std::optional< ComponentBatch > buffer
The raw image data.
Definition image.hpp:145
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition image.hpp:163
static Image from_grayscale8(Collection< uint8_t > bytes, WidthHeight resolution)
Assumes single channel grayscale/luminance with 8-bit per value.
Definition image.hpp:270
std::optional< ComponentBatch > opacity
Opacity of the image, useful for layering several images.
Definition image.hpp:153
static Image from_rgba32(Collection< uint8_t > bytes, WidthHeight resolution)
Assumes RGBA, 8-bit per channel, with separate alpha.
Definition image.hpp:320
static Image from_rgb24(Collection< uint8_t > bytes, WidthHeight resolution)
Assumes RGB, 8-bit per channel, packed as RGBRGBRGB….
Definition image.hpp:304
Image with_many_buffer(const Collection< rerun::components::ImageBuffer > &_buffer) &&
This method makes it possible to pack multiple buffer in a single component batch.
Definition image.hpp:356
Component: Draw order of 2D elements.
Definition draw_order.hpp:19
Component: A buffer that is known to store image data.
Definition image_buffer.hpp:18
Component: Degree of transparency ranging from 0.0 (fully transparent) to 1.0 (fully opaque).
Definition opacity.hpp:17