Struct re_viewer_context::ImageInfo
source · pub struct ImageInfo {
pub buffer_row_id: RowId,
pub buffer: Blob,
pub format: ImageFormat,
pub kind: ImageKind,
}
Expand description
Represents the contents of an Image
, SegmentationImage
or DepthImage
.
Fields§
§buffer_row_id: RowId
The row id that contained the blob.
Can be used instead of hashing Self::buffer
.
buffer: Blob
The image data, row-wise, with stride=width.
format: ImageFormat
Describes the format of Self::buffer
.
kind: ImageKind
Color, Depth, or Segmentation?
Implementations§
source§impl ImageInfo
impl ImageInfo
pub fn width(&self) -> u32
pub fn height(&self) -> u32
pub fn width_height(&self) -> [u32; 2]
sourcepub fn color_model(&self) -> ColorModel
pub fn color_model(&self) -> ColorModel
Returns ColorModel::L
for depth and segmentation images.
Currently return ColorModel::RGB
for chroma-subsampled images,
but this may change in the future when we add YUV support to ColorModel
.
sourcepub fn get_xyc(&self, x: u32, y: u32, channel: u32) -> Option<TensorElement>
pub fn get_xyc(&self, x: u32, y: u32, channel: u32) -> Option<TensorElement>
Get the value of the element at the given index.
Return None
if out-of-bounds.
sourcepub fn to_slice<T: Pod>(&self) -> Cow<'_, [T]>
pub fn to_slice<T: Pod>(&self) -> Cow<'_, [T]>
Cast the buffer to the given type.
This will never fail.
If the buffer is 5 bytes long and the target type is f32
, the last byte is just ignored.
Cheap in most cases, but if the input buffer is not aligned to the element type, this function will copy the data.
sourcepub fn to_dynamic_image(
&self,
data_range: RangeInclusive<f32>
) -> Option<DynamicImage>
pub fn to_dynamic_image( &self, data_range: RangeInclusive<f32> ) -> Option<DynamicImage>
Best-effort.
u8
and u16
images are returned as is.
Other data types are remapped from the given data_range
to the full u16
range, then rounded.
Returns None
for invalid images (if the buffer is the wrong size).
sourcepub fn to_rgba8_image(
&self,
data_range: RangeInclusive<f32>
) -> Option<RgbaImage>
pub fn to_rgba8_image( &self, data_range: RangeInclusive<f32> ) -> Option<RgbaImage>
sourcefn to_vec_u16(
&self,
datatype: ChannelDatatype,
data_range: RangeInclusive<f32>
) -> Vec<u16>
fn to_vec_u16( &self, datatype: ChannelDatatype, data_range: RangeInclusive<f32> ) -> Vec<u16>
Remaps the given data range to u16
, with rounding and clamping.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ImageInfo
impl RefUnwindSafe for ImageInfo
impl Send for ImageInfo
impl Sync for ImageInfo
impl Unpin for ImageInfo
impl UnwindSafe for ImageInfo
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request