Struct nutexb::NutexbFile
source · pub struct NutexbFile {
pub data: Vec<u8>,
pub layer_mipmaps: Vec<LayerMipmaps>,
pub footer: NutexbFooter,
}
Expand description
The data stored in a nutexb file like "def_001_col.nutexb"
.
Fields§
§data: Vec<u8>
Combined image data for all array layer and mipmap levels.
layer_mipmaps: Vec<LayerMipmaps>
The size of the mipmaps for each array layer.
Most nutexb files use swizzled image data, so these sizes won’t add up to the length of data.
Information about the image stored in data.
Implementations§
source§impl NutexbFile
impl NutexbFile
sourcepub fn read<R: Read + Seek>(reader: &mut R) -> BinResult<Self>
pub fn read<R: Read + Seek>(reader: &mut R) -> BinResult<Self>
Reads the NutexbFile from the specified reader
.
sourcepub fn read_from_file<P: AsRef<Path>>(path: P) -> Result<NutexbFile, Error>
pub fn read_from_file<P: AsRef<Path>>(path: P) -> Result<NutexbFile, Error>
Reads the NutexbFile from the specified path
.
The entire file is buffered to improve performance.
sourcepub fn write<W: Write + Seek>(&self, writer: &mut W) -> Result<(), Error>
pub fn write<W: Write + Seek>(&self, writer: &mut W) -> Result<(), Error>
Writes the NutexbFile to the specified writer
.
sourcepub fn write_to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), Error>
pub fn write_to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), Error>
Writes the NutexbFile to the specified path
.
The entire file is buffered to improve performance.
sourcepub fn deswizzled_data(&self) -> Result<Vec<u8>, SwizzleError>
pub fn deswizzled_data(&self) -> Result<Vec<u8>, SwizzleError>
Deswizzles all the layers and mipmaps in data.
sourcepub fn from_surface<T: AsRef<[u8]>, S: Into<String>>(
image: Surface<T>,
name: S
) -> Result<Self, SwizzleError>
pub fn from_surface<T: AsRef<[u8]>, S: Into<String>>( image: Surface<T>, name: S ) -> Result<Self, SwizzleError>
Creates a NutexbFile from image
with the nutexb string set to name
.
The data in image
is swizzled according to the specified dimensions and format.
sourcepub fn from_surface_unswizzled<T: AsRef<[u8]>, S: Into<String>>(
surface: &Surface<T>,
name: S
) -> Self
pub fn from_surface_unswizzled<T: AsRef<[u8]>, S: Into<String>>( surface: &Surface<T>, name: S ) -> Self
Creates a NutexbFile from surface
with the nutexb string set to name
without any swizzling.
This assumes no layers or mipmaps for image
.
Prefer NutexbFile::from_surface for better memory access performance in most cases.
Textures created with NutexbFile::from_surface use a memory layout optimized for the Tegra X1 with better access performance in the general case. This function exists for the rare case where swizzling the image data is not desired for performance or compatibility reasons.
sourcepub fn from_dds<S: Into<String>>(
dds: &Dds,
name: S
) -> Result<Self, ReadDdsError>
pub fn from_dds<S: Into<String>>( dds: &Dds, name: S ) -> Result<Self, ReadDdsError>
Creates a swizzled NutexbFile from dds
with the Nutexb string set to name
.
DDS supports all Nutexb image formats as well as array layers, mipmaps, cube maps, and 3D volume textures.
sourcepub fn to_dds(&self) -> Result<Dds, SwizzleError>
pub fn to_dds(&self) -> Result<Dds, SwizzleError>
Deswizzle the surface data to DDS while preserving the layers, mipmaps, and image format.
sourcepub fn from_image<S: Into<String>>(
image: &RgbaImage,
name: S
) -> Result<Self, SwizzleError>
pub fn from_image<S: Into<String>>( image: &RgbaImage, name: S ) -> Result<Self, SwizzleError>
Creates a swizzled 2D NutexbFile from image
with the Nutexb string set to name
and without mipmaps.
sourcepub fn optimize_size(&mut self)
pub fn optimize_size(&mut self)
Resizes the image data to the expected size based on the footer information by truncating or padding with zeros.
Calling this method is unnecessary for nutexbs created with NutexbFile::from_surface or NutexbFile::from_surface_unswizzled. These methods already calculate the appropriate image data size.
Trait Implementations§
source§impl BinRead for NutexbFile
impl BinRead for NutexbFile
source§fn read_options<R: Read + Seek>(
reader: &mut R,
_endian: Endian,
_args: Self::Args<'_>
) -> BinResult<Self>
fn read_options<R: Read + Seek>( reader: &mut R, _endian: Endian, _args: Self::Args<'_> ) -> BinResult<Self>
source§fn read_be<R>(reader: &mut R) -> Result<Self, Error>
fn read_be<R>(reader: &mut R) -> Result<Self, Error>
Self
from the reader using default arguments and assuming
big-endian byte order. Read moresource§fn read_le<R>(reader: &mut R) -> Result<Self, Error>
fn read_le<R>(reader: &mut R) -> Result<Self, Error>
Self
from the reader using default arguments and assuming
little-endian byte order. Read moresource§fn read_ne<R>(reader: &mut R) -> Result<Self, Error>
fn read_ne<R>(reader: &mut R) -> Result<Self, Error>
T
from the reader assuming native-endian byte order. Read moresource§fn read_be_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
fn read_be_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
Self
from the reader, assuming big-endian byte order, using the
given arguments. Read moresource§impl BinWrite for NutexbFile
impl BinWrite for NutexbFile
source§fn write_options<W: Write + Seek>(
&self,
__binrw_generated_var_writer: &mut W,
__binrw_generated_var_endian: Endian,
__binrw_generated_var_arguments: Self::Args<'_>
) -> BinResult<()>
fn write_options<W: Write + Seek>( &self, __binrw_generated_var_writer: &mut W, __binrw_generated_var_endian: Endian, __binrw_generated_var_arguments: Self::Args<'_> ) -> BinResult<()>
source§fn write_be<W>(&self, writer: &mut W) -> Result<(), Error>
fn write_be<W>(&self, writer: &mut W) -> Result<(), Error>
Self
to the writer assuming big-endian byte order. Read moresource§fn write_le<W>(&self, writer: &mut W) -> Result<(), Error>
fn write_le<W>(&self, writer: &mut W) -> Result<(), Error>
Self
to the writer assuming little-endian byte order. Read moresource§impl Clone for NutexbFile
impl Clone for NutexbFile
source§fn clone(&self) -> NutexbFile
fn clone(&self) -> NutexbFile
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more