pub struct ImageDesc { /* private fields */ }Expand description
Declarative image-allocation request — the full-featured front door
for image tensors (TensorDyn::image_desc and the image crate’s
ImageProcessor::create_image_desc).
The classic constructors (image, create_image) cover the common
cases; the desc carries the optional requests — today the
Compression request — without another constructor-parameter
sweep. Fields are private and the builders consume/return by value,
so future options are non-breaking.
use edgefirst_tensor::{Compression, CpuAccess, DType, ImageDesc, PixelFormat};
let desc = ImageDesc::new(640, 640, PixelFormat::Rgba, DType::U8)
.with_access(CpuAccess::None)
.with_compression(Compression::Any);Implementations§
Source§impl ImageDesc
impl ImageDesc
Sourcepub fn new(
width: usize,
height: usize,
format: PixelFormat,
dtype: DType,
) -> Self
pub fn new( width: usize, height: usize, format: PixelFormat, dtype: DType, ) -> Self
A new image request: auto-selected memory, CpuAccess::ReadWrite,
no compression request.
Sourcepub fn with_memory(self, memory: Option<TensorMemory>) -> Self
pub fn with_memory(self, memory: Option<TensorMemory>) -> Self
Request a specific memory backing (None = auto-select).
Sourcepub fn with_access(self, access: CpuAccess) -> Self
pub fn with_access(self, access: CpuAccess) -> Self
Declare the CPU access (see CpuAccess). Any declaration other
than None makes a compression request invalid, so a compression
request must also call with_access(CpuAccess::None).
Sourcepub fn with_compression(self, compression: Compression) -> Self
pub fn with_compression(self, compression: Compression) -> Self
Request a tile-compressed layout (see Compression).
Sourcepub fn with_contiguous(self, contiguous: bool) -> Self
pub fn with_contiguous(self, contiguous: bool) -> Self
Require physically contiguous memory (see Contiguity).
The image is allocated from the Linux CMA DMA heap only. Allocation
fails, naming the heap, when there is no CMA heap or it cannot fit
the image, instead of falling back to the system heap or to another
kind of memory. Memory must be auto-selected or
TensorMemory::DmaBuf. Other platforms return
Error::NotImplemented.
Sourcepub fn format(&self) -> PixelFormat
pub fn format(&self) -> PixelFormat
Requested pixel format.
Sourcepub fn memory(&self) -> Option<TensorMemory>
pub fn memory(&self) -> Option<TensorMemory>
Requested memory backing (None = auto-select).
Sourcepub fn compression(&self) -> Option<Compression>
pub fn compression(&self) -> Option<Compression>
The compression request, if any.
Sourcepub fn contiguous(&self) -> bool
pub fn contiguous(&self) -> bool
Whether physically contiguous memory is required.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ImageDesc
impl RefUnwindSafe for ImageDesc
impl Send for ImageDesc
impl Sync for ImageDesc
impl Unpin for ImageDesc
impl UnsafeUnpin for ImageDesc
impl UnwindSafe for ImageDesc
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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 more