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 "../indicator_component.hpp"
15#include "../result.hpp"
162 static constexpr const char IndicatorComponentName[] =
"rerun.components.ImageIndicator";
201 ErrorCode::InvalidTensorDimension,
202 "Image buffer has the wrong size. Got " + std::to_string(bytes.
size()) +
203 " bytes, expected " + std::to_string(format_.image_format.
num_bytes())
207 *
this = std::move(*this).with_buffer(bytes).with_format(format_);
221 :
Image{std::move(bytes), datatypes::ImageFormat{resolution, pixel_format}} {}
236 :
Image(std::move(bytes), datatypes::ImageFormat(resolution, color_model, datatype)) {}
248 template <
typename T>
250 :
Image(elements.to_uint8(), resolution, color_model, get_datatype(elements.data())) {}
261 template <
typename T>
265 reinterpret_cast<const uint8_t*>(elements),
268 resolution, color_model, get_datatype(elements)
325 Image& operator=(
const Image& other) =
default;
339 return std::move(*
this);
348 return std::move(*
this);
354 return std::move(*
this);
363 return std::move(*
this);
371 return std::move(*
this);
380 return std::move(*
this);
389 return std::move(*
this);
399 return std::move(*
this);
423 template <
typename T>
428 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:96
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:35
ColorModel
Datatype: Specified what color components are present in an archetypes::Image.
Definition color_model.hpp:27
@ 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:27
@ 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=rerun::Loggable< T >::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:14
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:144
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:386
static constexpr auto Descriptor_opacity
ComponentDescriptor for the opacity field.
Definition image.hpp:180
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:361
Image with_format(const rerun::components::ImageFormat &_format) &&
The format of the image.
Definition image.hpp:352
Image with_buffer(const rerun::components::ImageBuffer &_buffer) &&
The raw image data.
Definition image.hpp:337
static constexpr auto Descriptor_buffer
ComponentDescriptor for the buffer field.
Definition image.hpp:170
static Image from_greyscale8(Collection< uint8_t > bytes, WidthHeight resolution)
Assumes single channel greyscale/luminance with 8-bit per value.
Definition image.hpp:278
Image(Collection< uint8_t > bytes, components::ImageFormat format_)
Construct an image from bytes and image format.
Definition image.hpp:198
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:378
static constexpr auto Descriptor_draw_order
ComponentDescriptor for the draw_order field.
Definition image.hpp:185
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:175
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:249
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:218
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:262
std::optional< ComponentBatch > format
The format of the image.
Definition image.hpp:149
Image with_opacity(const rerun::components::Opacity &_opacity) &&
Opacity of the image, useful for layering several images.
Definition image.hpp:369
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:232
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:396
static Image update_fields()
Update only some specific fields of a Image.
Definition image.hpp:329
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:146
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition image.hpp:167
std::optional< ComponentBatch > opacity
Opacity of the image, useful for layering several images.
Definition image.hpp:154
static Image from_rgba32(Collection< uint8_t > bytes, WidthHeight resolution)
Assumes RGBA, 8-bit per channel, with separate alpha.
Definition image.hpp:310
static Image from_rgb24(Collection< uint8_t > bytes, WidthHeight resolution)
Assumes RGB, 8-bit per channel, packed as RGBRGBRGB….
Definition image.hpp:294
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:346
Component: Draw order of 2D elements.
Definition draw_order.hpp:20
Component: A buffer that is known to store image data.
Definition image_buffer.hpp:19
Indicator component used by archetypes when converting them to component lists.
Definition indicator_component.hpp:32
Component: Degree of transparency ranging from 0.0 (fully transparent) to 1.0 (fully opaque).
Definition opacity.hpp:18