Struct ImageTexture

Source
pub struct ImageTexture {
    pub name: Option<String>,
    pub usage: Option<TextureUsage>,
    pub width: u32,
    pub height: u32,
    pub depth: u32,
    pub view_dimension: ViewDimension,
    pub image_format: ImageFormat,
    pub mipmap_count: u32,
    pub image_data: Vec<u8>,
}
Expand description

A non swizzled version of an Mibl or Mtxt texture.

Fields§

§name: Option<String>

An optional name assigned to some textures. This will typically be None and can not be used for reliably identifying textures.

§usage: Option<TextureUsage>

Hints on how the texture is used. Actual usage is determined by the shader code.

§width: u32

The width of the base mip level in pixels.

§height: u32

The height of the base mip level in pixels.

§depth: u32

The depth of the base mip level in pixels.

§view_dimension: ViewDimension§image_format: ImageFormat§mipmap_count: u32

The number of mip levels or 1 if there are no mipmaps.

§image_data: Vec<u8>

The combined image surface data in a standard row-major layout. Ordered as Layer 0 Mip 0, Layer 0 Mip 1, ... Layer L-1 Mip M-1 for L layers and M mipmaps similar to DDS files.

Implementations§

Source§

impl ImageTexture

Source

pub fn from_mibl( mibl: &Mibl, name: Option<String>, usage: Option<TextureUsage>, ) -> Result<Self, CreateImageTextureError>

Deswizzle the data from mibl.

The name is not required but creates more descriptive file names and debug information. The usage improves the accuracy of texture assignments if the shader database is not specified.

Source

pub fn from_mtxt( mtxt: &Mtxt, name: Option<String>, usage: Option<TextureUsage>, ) -> Result<Self, CreateImageTextureError>

Deswizzle the data from mtxt.

The name is not required but creates more descriptive file names and debug information. The usage improves the accuracy of texture assignments if the shader database is not specified.

Source

pub fn to_image(&self) -> Result<RgbaImage, CreateImageError>

Decode the first mip level for all depth slices and array layers to RGBA8.

Source

pub fn layers(&self) -> u32

Return the number of array layers in this surface.

Source

pub fn to_surface(&self) -> Surface<&[u8]>

Create a view of all image data in this texture to use with encode or decode operations.

Source

pub fn to_dds(&self) -> Result<Dds, CreateDdsError>

Source

pub fn from_surface<T: AsRef<[u8]>>( surface: Surface<T>, name: Option<String>, usage: Option<TextureUsage>, ) -> Result<Self, CreateImageTextureError>

Source

pub fn from_dds( dds: &Dds, name: Option<String>, usage: Option<TextureUsage>, ) -> Result<Self, CreateImageTextureError>

Source

pub fn to_mibl(&self) -> Result<Mibl, CreateMiblError>

Trait Implementations§

Source§

impl Clone for ImageTexture

Source§

fn clone(&self) -> ImageTexture

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ImageTexture

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for ImageTexture

Source§

fn eq(&self, other: &ImageTexture) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ImageTexture

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.