Struct vtflib::VtfFile[][src]

#[must_use]
pub struct VtfFile<'a> { /* fields omitted */ }
Expand description

A VTF file. Must be bound before it can be worked on.

Implementations

impl<'a> VtfFile<'a>[src]

pub fn bind(self, _guard: &mut VtfGuard) -> BoundVtfFile<'a, '_>[src]

Bind the VTF file to work on it. Only one VTF file can be bound at a time. This is a limitation of the underlying library’s C API. Mutably borrows the VtfGuard obtained from library initialization to enforce this.

Panics

Panics if the binding fails. This should not happen.

#[must_use]
pub fn compute_image_size(
    width: u32,
    height: u32,
    depth: u32,
    mipmaps: u32,
    format: ImageFormat
) -> u32
[src]

Compute how much memory a specified image needs in bytes.

#[must_use]
pub fn compute_mipmap_count(width: u32, height: u32, depth: u32) -> u32
[src]

Compute the number of mip levels needed for an image of given dimensions. The number includes the original image, and counts mipmaps down to 1x1 pixels.

#[must_use]
pub fn compute_mipmap_dimensions(
    width: u32,
    height: u32,
    depth: u32,
    mipmap_level: u32
) -> (u32, u32, u32)
[src]

Compute the dimensions of a given mip level for an image of given dimensions.

#[must_use]
pub fn compute_mipmap_size(
    width: u32,
    height: u32,
    depth: u32,
    mipmap_level: u32,
    format: ImageFormat
) -> u32
[src]

Compute how much memory a given mipmap level needs in bytes.

pub fn convert_image_to_rgba8888(
    source: &[u8],
    width: u32,
    height: u32,
    source_format: ImageFormat
) -> Result<Vec<u8>>
[src]

Convert an image stored in a given format to ImageFormat::Rgba8888.

Errors

Returns Err if source has invalid length or if the conversion fails.

pub fn convert_image_from_rgba8888(
    source: &[u8],
    width: u32,
    height: u32,
    dest_format: ImageFormat
) -> Result<Vec<u8>>
[src]

Convert an image stored in ImageFormat::Rgba8888 to a given format.

Errors

Returns Err if source has invalid length or if the conversion fails.

pub fn convert_image(
    source: &[u8],
    width: u32,
    height: u32,
    source_format: ImageFormat,
    dest_format: ImageFormat
) -> Result<Vec<u8>>
[src]

Convert between supported image formats.

Errors

Returns Err if source has invalid length or if the conversion fails.

pub fn convert_image_to_normal_map(
    source: &[u8],
    width: u32,
    height: u32,
    settings: &NormalMapConversionSettings
) -> Result<Vec<u8>>
[src]

Convert an image stored in ImageFormat::Rgba8888 to a normal map.

Errors

Returns Err if source has invalid length or if the conversion fails.

pub fn resize_image(
    source: &[u8],
    source_width: u32,
    source_height: u32,
    target_width: u32,
    target_height: u32,
    resize_filter: MipmapFilter,
    sharpen_filter: SharpenFilter
) -> Result<Vec<u8>>
[src]

Resize an image stored in ImageFormat::Rgba8888 to the given dimensions.

Errors

Returns Err if source has invalid length or if the resize fails.

pub fn correct_image_gamma(
    data: &mut [u8],
    width: u32,
    height: u32,
    gamma_correction: f32
) -> Result<()>
[src]

Apply gamma correction to an image stored in ImageFormat::Rgba8888.

Errors

Returns Err if data has invalid length.

pub fn compute_image_reflectivity(
    data: &[u8],
    width: u32,
    height: u32
) -> Result<(f32, f32, f32)>
[src]

Compute the reflectivity of an image stored in ImageFormat::Rgba8888.

Errors

Returns Err if data has invalid length.

pub fn flip_image(data: &mut [u8], width: u32, height: u32) -> Result<()>[src]

Flip an image stored in ImageFormat::Rgba8888 vertically along its X-axis.

Errors

Returns Err if data has invalid length.

pub fn mirror_image(data: &mut [u8], width: u32, height: u32) -> Result<()>[src]

Flip an image stored in ImageFormat::Rgba8888 horizontally along its Y-axis.

Errors

Returns Err if data has invalid length.

Trait Implementations

impl<'a> Debug for VtfFile<'a>[src]

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

Formats the value using the given formatter. Read more

impl<'a> Drop for VtfFile<'a>[src]

fn drop(&mut self)[src]

Executes the destructor for this type. Read more

Auto Trait Implementations

impl<'a> RefUnwindSafe for VtfFile<'a>

impl<'a> !Send for VtfFile<'a>

impl<'a> !Sync for VtfFile<'a>

impl<'a> Unpin for VtfFile<'a>

impl<'a> UnwindSafe for VtfFile<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.