Rerun C++ SDK
Loading...
Searching...
No Matches
rgba32.hpp
1// DO NOT EDIT! This file was auto-generated by crates/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/re_types/definitions/rerun/datatypes/rgba32.fbs".
3
4#pragma once
5
6#include "../result.hpp"
7
8#include <cstdint>
9#include <memory>
10
11namespace arrow {
12 /// \private
13 template <typename T>
14 class NumericBuilder;
15
16 class Array;
17 class DataType;
18 class UInt32Type;
19 using UInt32Builder = NumericBuilder<UInt32Type>;
20} // namespace arrow
21
22namespace rerun::datatypes {
23 /// **Datatype**: An RGBA color with unmultiplied/separate alpha, in sRGB gamma space with linear alpha.
24 ///
25 /// The color is stored as a 32-bit integer, where the most significant
26 /// byte is `R` and the least significant byte is `A`.
27 struct Rgba32 {
28 uint32_t rgba;
29
30 public:
31 // Extensions to generated type defined in 'rgba32_ext.cpp'
32
33 /// Construct Rgba32 from unmultiplied RGBA values.
34 Rgba32(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255)
35 : Rgba32(static_cast<uint32_t>((r << 24) | (g << 16) | (b << 8) | a)) {}
36
37 /// Construct Rgba32 from unmultiplied RGBA values.
38 Rgba32(const uint8_t (&_rgba)[4]) : Rgba32(_rgba[0], _rgba[1], _rgba[2], _rgba[3]) {}
39
40 /// Construct Rgba32 from RGB values, setting alpha to 255.
41 Rgba32(const uint8_t (&_rgb)[3]) : Rgba32(_rgb[0], _rgb[1], _rgb[2]) {}
42
43 uint8_t r() const {
44 return static_cast<uint8_t>((rgba >> 24) & 0xFF);
45 }
46
47 uint8_t g() const {
48 return static_cast<uint8_t>((rgba >> 16) & 0xFF);
49 }
50
51 uint8_t b() const {
52 return static_cast<uint8_t>((rgba >> 8) & 0xFF);
53 }
54
55 uint8_t a() const {
56 return static_cast<uint8_t>(rgba & 0xFF);
57 }
58
59 public:
60 Rgba32() = default;
61
62 Rgba32(uint32_t rgba_) : rgba(rgba_) {}
63
64 Rgba32& operator=(uint32_t rgba_) {
65 rgba = rgba_;
66 return *this;
67 }
68 };
69} // namespace rerun::datatypes
70
71namespace rerun {
72 template <typename T>
73 struct Loggable;
74
75 /// \private
76 template <>
77 struct Loggable<datatypes::Rgba32> {
78 static constexpr const char Name[] = "rerun.datatypes.Rgba32";
79
80 /// Returns the arrow data type this type corresponds to.
81 static const std::shared_ptr<arrow::DataType>& arrow_datatype();
82
83 /// Serializes an array of `rerun::datatypes::Rgba32` into an arrow array.
84 static Result<std::shared_ptr<arrow::Array>> to_arrow(
85 const datatypes::Rgba32* instances, size_t num_instances
86 );
87
88 /// Fills an arrow array builder with an array of this type.
89 static rerun::Error fill_arrow_array_builder(
90 arrow::UInt32Builder* builder, const datatypes::Rgba32* elements, size_t num_elements
91 );
92 };
93} // namespace rerun
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:89
All built-in datatypes. See Types in the Rerun manual.
Definition rerun.hpp:79
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:21
Datatype: An RGBA color with unmultiplied/separate alpha, in sRGB gamma space with linear alpha.
Definition rgba32.hpp:27
Rgba32(const uint8_t(&_rgb)[3])
Construct Rgba32 from RGB values, setting alpha to 255.
Definition rgba32.hpp:41
Rgba32(uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
Construct Rgba32 from unmultiplied RGBA values.
Definition rgba32.hpp:34
Rgba32(const uint8_t(&_rgba)[4])
Construct Rgba32 from unmultiplied RGBA values.
Definition rgba32.hpp:38