Struct vtflib::BoundVtfFile[][src]

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

A bound vtf file ready for manipulation. Only one vtf file can be bound at a time. A bound vtf file can be either manually unbound, or automatically when it is dropped.

Implementations

impl<'a, 'b> BoundVtfFile<'a, 'b>[src]

pub fn unbind(self) -> VtfFile<'a>[src]

Unbind the image. Allows other images to be bound.

pub fn new_empty(
    &mut self,
    width: u32,
    height: u32
) -> EmptyImageBuilder<'_, '_, '_>
[src]

Build a new empty image.

pub fn from_rgba8888(
    &mut self,
    width: u32,
    height: u32
) -> Rgba8888ImageBuilder<'_, '_, '_>
[src]

Load an image from existing ImageFormat::Rgba8888 data.

pub fn destroy(&mut self)[src]

Destroy the contained image, if any.

pub fn load(&mut self, bytes: &[u8]) -> Result<()>[src]

Load a VTF image from bytes.

Errors

Returns Err if the image loading fails or if the image is too large for the length fit into u32.

pub fn load_header(&mut self, bytes: &[u8]) -> Result<()>[src]

Load a VTF image header from bytes, to save memory while only getting information from the file, for example.

Errors

Returns Err if the image loading fails or if the image is too large for the length fit into u32.

pub fn save(&self, buffer: &mut [u8]) -> Result<usize>[src]

Save the image into buffer. Returns bytes written.

Errors

Returns Err if the image saving fails or if the buffer is too large for the length fit into u32.

pub fn save_to_vec(&self) -> Result<Vec<u8>>[src]

Save the image into a Vec.

Errors

Returns Err if the image saving fails.

#[must_use]
pub fn has_image(&self) -> bool
[src]

Check if image data has been loaded. Returns false if a VTF file was loaded with header only.

#[must_use]
pub fn major_version(&self) -> u32
[src]

Returns the VTF file major version number.

#[must_use]
pub fn minor_version(&self) -> u32
[src]

Returns the VTF file minor version number.

#[must_use]
pub fn size(&self) -> usize
[src]

Returns the VTF file size in bytes.

#[must_use]
pub fn width(&self) -> u32
[src]

Returns the width of the image in pixels.

#[must_use]
pub fn height(&self) -> u32
[src]

Returns the height of the image in pixels.

#[must_use]
pub fn depth(&self) -> u32
[src]

Returns the depth of the image in pixels.

#[must_use]
pub fn frame_count(&self) -> u32
[src]

Returns the frame count of the image.

#[must_use]
pub fn face_count(&self) -> u32
[src]

Returns the face count of the image.

#[must_use]
pub fn mipmap_count(&self) -> u32
[src]

Returns the number of mip levels in the image.

#[must_use]
pub fn start_frame(&self) -> u32
[src]

Returns the start frame of the image.

#[must_use]
pub fn flags(&self) -> ImageFlags
[src]

Returns the image flags.

#[must_use]
pub fn flag(&self, flag: ImageFlags) -> bool
[src]

Check if the given flag is set.

#[must_use]
pub fn bumpmap_scale(&self) -> f32
[src]

Returns the bump scale value.

#[must_use]
pub fn format(&self) -> Option<ImageFormat>
[src]

Returns the format of the image. Returns None if the format is unknown or if an image is not loaded.

#[must_use]
pub fn has_thumbnail(&self) -> bool
[src]

Check whether the current image has a thumbnail.

#[must_use]
pub fn thumbnail_width(&self) -> u32
[src]

Returns the width the thumbnail in pixels.

#[must_use]
pub fn thumbnail_height(&self) -> u32
[src]

Returns the height the thumbnail in pixels.

#[must_use]
pub fn thumbnail_format(&self) -> Option<ImageFormat>
[src]

Returns the format of the thumbnail. Returns None if the format is unknown or if there is no thumbnail.

#[must_use]
pub fn supports_resource(&self) -> bool
[src]

Check whether the current VTF version supports resources.

#[must_use]
pub fn resource_count(&self) -> u32
[src]

Returns the number of resource contained within the VTF file.

#[must_use]
pub fn resource_type(&self, index: u32) -> Option<ResourceType>
[src]

Returns the type of the resource at the given index. Returns None if the given index doesn’t exist or if resources are not supported.

#[must_use]
pub fn has_resource(&self, resource: ResourceType) -> bool
[src]

Check whether the resource of the given type exists.

pub fn set_start_frame(&mut self, start_frame: u32)[src]

Sets the start frame of the image.

pub fn set_flags(&mut self, flags: ImageFlags)[src]

Sets the flags of the image.

pub fn set_flag(&mut self, flag: ImageFlags, state: bool)[src]

Sets the state of a specific flag in the image

pub fn set_bumpmap_scale(&mut self, scale: f32)[src]

Sets the bump scale value.

pub fn set_reflectivity(&mut self, x: f32, y: f32, z: f32)[src]

Sets the reflectivity values of the image.

#[must_use]
pub fn reflectivity(&self) -> (f32, f32, f32)
[src]

Gets the reflectivity values of the image.

#[must_use]
pub fn data(
    &self,
    frame: u32,
    face: u32,
    slice: u32,
    mipmap_level: u32
) -> Option<&[u8]>
[src]

Get a reference to the image data of a specific image. The data is in the format returned by format(). Returns None if the given values don’t exist.

#[must_use]
pub unsafe fn data_unchecked(
    &self,
    frame: u32,
    face: u32,
    slice: u32,
    mipmap_level: u32
) -> Option<&[u8]>
[src]

Get an unchecked reference to the image data of the specified image. The data is in the format returned by format().

Safety

If any parameters are invalid for the current image, undefined behaviour results.

pub fn set_data(
    &mut self,
    frame: u32,
    face: u32,
    slice: u32,
    mipmap_level: u32,
    data: &[u8]
) -> Result<()>
[src]

Sets the image data of the specified image. The data must be in the format returned by format().

Errors

Returns Err if the data length is not correct, or if the parameters are not valid.

pub unsafe fn set_data_unchecked(
    &mut self,
    frame: u32,
    face: u32,
    slice: u32,
    mipmap_level: u32,
    data: &[u8]
)
[src]

Sets the image data of the specified image. The data must be in the format returned by format().

Safety

If any parameters are invalid, or if data length is invalid, undefined behaviour results.

#[must_use]
pub fn thumbnail_data(&self) -> Option<&[u8]>
[src]

Get a reference to the thumbnail data. The data is in the format returned by thumbnail_format(). Returns None if there is no thumbnail data.

pub fn set_thumbnail_data(&mut self, data: &[u8]) -> Result<()>[src]

Sets the thumbnail image data. The data must be in the format returned by thumbnail_format().

Errors

Returns Err if the data length is not correct.

pub fn resource_data(&self, resource: ResourceType) -> Result<&[u8]>[src]

Get a reference to the given resource data.

Errors

Returns Err if the resource data cannot be get.

pub fn set_resource_data(
    &mut self,
    resource: ResourceType,
    data: &[u8]
) -> Result<()>
[src]

Sets the given resource data. This creates the resource if it doesn’t exist. Passing an empty slice deletes the resource.

Errors

Returns Err if the resource data cannot be set.

pub fn generate_mipmaps(
    &mut self,
    face: u32,
    frame: u32,
    filter: MipmapFilter,
    sharpen_filter: SharpenFilter
) -> Result<()>
[src]

Generates mipmaps for the given face and frame.

Errors

Returns Err if the mipmap generation fails, or if the parameters are invalid.

pub fn generate_all_mipmaps(
    &mut self,
    filter: MipmapFilter,
    sharpen_filter: SharpenFilter
) -> Result<()>
[src]

Generates mipmaps for all faces and frames.

Errors

Returns Err if the mipmap generation fails.

pub fn generate_thumbnail(&mut self) -> Result<()>[src]

Generates the thumbnail.

Errors

Returns Err if the thumbnail generation fails.

pub fn generate_normal_map(
    &mut self,
    frame: u32,
    kernel_filter: KernelFilter,
    height_conversion_method: HeightConversionMethod,
    normal_alpha_result: NormalAlphaResult
) -> Result<()>
[src]

Converts the image to a normal map using the data in the given frame.

Errors

Returns Err if the normal map generation fails, or if the parameters are incorrect for the current image.

pub fn generate_all_normal_maps(
    &mut self,
    kernel_filter: KernelFilter,
    height_conversion_method: HeightConversionMethod,
    normal_alpha_result: NormalAlphaResult
) -> Result<()>
[src]

Converts the image to a normal map using mip level 0 as the source.

Errors

Returns Err if the normal map generation fails.

pub fn generate_sphere_map(&mut self) -> Result<()>[src]

Generates a shere map using the 6 cubemap faces of the image.

Errors

Returns Err if the sphere map generation fails.

pub fn compute_reflectivity(&mut self) -> Result<()>[src]

Computes and sets the reflectivity values of the image based on pixels’ color averages.

Errors

Returns Err if the reflectivity can’t be computed.

Auto Trait Implementations

impl<'a, 'b> RefUnwindSafe for BoundVtfFile<'a, 'b>

impl<'a, 'b> !Send for BoundVtfFile<'a, 'b>

impl<'a, 'b> !Sync for BoundVtfFile<'a, 'b>

impl<'a, 'b> Unpin for BoundVtfFile<'a, 'b>

impl<'a, 'b> !UnwindSafe for BoundVtfFile<'a, 'b>

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.