pub struct Surface<T> {
pub width: u32,
pub height: u32,
pub depth: u32,
pub layers: u32,
pub mipmaps: u32,
pub image_format: ImageFormat,
pub data: T,
}
Expand description
A surface with an image format known at runtime.
Fields§
§width: u32
The width of the surface in pixels.
height: u32
The height of the surface in pixels.
depth: u32
The depth of the surface in pixels.
This should be 1
for 2D surfaces.
layers: u32
The number of array layers in the surface.
This should be 1
for most surfaces and 6
for cube maps.
mipmaps: u32
The number of mipmaps in the surface.
This should be 1
if the surface has only the base mip level.
All array layers are assumed to have the same number of mipmaps.
image_format: ImageFormat
The format of the bytes in data.
data: T
The combined image data ordered by layer and then mipmap without additional padding.
A surface with L layers and M mipmaps would have the following layout: Layer 0 Mip 0, Layer 0 Mip 1, …, Layer L-1 Mip M-1
Implementations§
Source§impl<T: AsRef<[u8]>> Surface<T>
impl<T: AsRef<[u8]>> Surface<T>
Sourcepub fn get(&self, layer: u32, depth_level: u32, mipmap: u32) -> Option<&[u8]>
pub fn get(&self, layer: u32, depth_level: u32, mipmap: u32) -> Option<&[u8]>
Get the range of image data corresponding to the specified layer
, depth_level
, and mipmap
.
The dimensions of the returned data should be calculated using mip_dimension. Returns None if the expected range is not fully contained within the buffer.
Source§impl<T: AsRef<[u8]>> Surface<T>
impl<T: AsRef<[u8]>> Surface<T>
Sourcepub fn decode_rgba8(&self) -> Result<SurfaceRgba8<Vec<u8>>, SurfaceError>
pub fn decode_rgba8(&self) -> Result<SurfaceRgba8<Vec<u8>>, SurfaceError>
Decode all layers and mipmaps from surface
to RGBA8.
Sourcepub fn decode_layers_mipmaps_rgba8(
&self,
layers: Range<u32>,
mipmaps: Range<u32>,
) -> Result<SurfaceRgba8<Vec<u8>>, SurfaceError>
pub fn decode_layers_mipmaps_rgba8( &self, layers: Range<u32>, mipmaps: Range<u32>, ) -> Result<SurfaceRgba8<Vec<u8>>, SurfaceError>
Decode a specific range of layers and mipmaps from surface
to RGBA8.
Sourcepub fn decode_rgbaf32(
&self,
) -> Result<SurfaceRgba32Float<Vec<f32>>, SurfaceError>
pub fn decode_rgbaf32( &self, ) -> Result<SurfaceRgba32Float<Vec<f32>>, SurfaceError>
Decode all layers and mipmaps from surface
to RGBAF32.
Non floating point formats are normalized to the range 0.0
to 1.0
.
Sourcepub fn decode_layers_mipmaps_rgbaf32(
&self,
layers: Range<u32>,
mipmaps: Range<u32>,
) -> Result<SurfaceRgba32Float<Vec<f32>>, SurfaceError>
pub fn decode_layers_mipmaps_rgbaf32( &self, layers: Range<u32>, mipmaps: Range<u32>, ) -> Result<SurfaceRgba32Float<Vec<f32>>, SurfaceError>
Decode a specific range of layers and mipmaps from surface
to RGBAF32.
Non floating point formats are normalized to the range 0.0
to 1.0
.
Source§impl<T: AsRef<[u8]>> Surface<T>
impl<T: AsRef<[u8]>> Surface<T>
Sourcepub fn encode(
&self,
format: ImageFormat,
quality: Quality,
mipmaps: Mipmaps,
) -> Result<Surface<Vec<u8>>, SurfaceError>
pub fn encode( &self, format: ImageFormat, quality: Quality, mipmaps: Mipmaps, ) -> Result<Surface<Vec<u8>>, SurfaceError>
Encode a surface to the given format
.
The number of mipmaps generated depends on the mipmaps
parameter.