BitmapEncoding

Enum BitmapEncoding 

Source
pub enum BitmapEncoding {
Show 14 variants A8R8G8B8, A8B8G8R8, X8R8G8B8, R5G6B5, A1R5G5B5, A4R4G4B4, A8, Y8, AY8, A8Y8, P8HCE, BC1, BC2, BC3,
}
Expand description

Bitmap formats supported.

Variants§

§

A8R8G8B8

8-bit alpha, red, green, blue

§

A8B8G8R8

§

X8R8G8B8

8-bit red, green, blue aligned to 32 bits

§

R5G6B5

5-bit red, 6-bit green, 5-bit alpha

§

A1R5G5B5

1-bit alpha, 5-bit red, green, blue

§

A4R4G4B4

4-bit alpha, red, green, blue

§

A8

8-bit alpha

§

Y8

8-bit luminescence

§

AY8

8-bit alpha-luminescence

§

A8Y8

8-bit alpha and luminescence

§

P8HCE

8-bit bump palletization for Halo: Combat Evolved

§

BC1

DXT1 block compression

§

BC2

DXT3 block compression

§

BC3

DXT5 block compression

Implementations§

Source§

impl BitmapEncoding

Source

pub const fn bits_per_pixel(self) -> usize

Get the number of bits per pixel (all channels combined).

Source

pub const fn pixels_per_block(self) -> usize

Get the number of pixels per block.

Source

pub const fn block_size(self) -> (usize, usize)

Get the block size.

Source

pub const fn bytes_per_block(self) -> usize

Get the number of bytes per block.

Source

pub const fn is_palettized(self) -> bool

Return true if the format is a palettization encoding.

Source

pub const fn is_monochrome(self) -> bool

Return true if the format is a monochrome encoding.

Source

pub const fn is_block_compression(self) -> bool

Return true if the format is a block compression encoding.

Source

pub fn encode( self, pixels: &[ColorARGBInt], width: usize, height: usize, depth: usize, faces: usize, mipmaps: usize, use_dithering: bool, ) -> Vec<u8>

Encode the input bitmap into a format.

  • For non-cubemaps, specify faces as 1.
  • For non-3D textures, specify depth as 1.
§Panics

This will panic if pixels is too small. On debug builds, it will also panic if pixels is too large. Take care that you pass a correct buffer size and the correct dimensions.

Source

pub fn decode( self, pixels: &[u8], width: usize, height: usize, depth: usize, faces: usize, mipmaps: usize, ) -> Vec<ColorARGBInt>

Decode the input bitmap data.

  • For non-cubemaps, specify faces as 1.
  • For non-3D textures, specify depth as 1.
§Panics

This will panic if pixels is too small. On debug builds, it will also panic if pixels is too large. Take care that you pass a correct buffer size and the correct dimensions.

Source

pub fn calculate_size_of_texture( self, width: usize, height: usize, depth: usize, faces: usize, mipmaps: usize, ) -> usize

Calculate the number of bytes required to hold a texture.

  • For non-cubemaps, specify faces as 1.
  • For non-3D textures, specify depth as 1.
Source

pub fn calculate_effective_pixel_count( self, width: usize, height: usize, depth: usize, faces: usize, mipmaps: usize, ) -> usize

Calculate the effective number of pixels.

For block compression, this will include account pixels that are “cropped” out even if they are still stored.

  • For non-cubemaps, specify faces as 1.
  • For non-3D textures, specify depth as 1.
Source

pub fn get_block( self, pixels: &[ColorARGBInt], output: &mut [ColorARGBInt], width: usize, height: usize, block_x: usize, block_y: usize, )

Get the pixels of the block at the x and y coordinates.

Source

pub fn get_block_dimensions(self, width: usize, height: usize) -> (usize, usize)

Get the width and height of the image in blocks.

Source

pub fn supports_dithering(self) -> bool

Get whether or not the format supports dithering.

Trait Implementations§

Source§

impl Clone for BitmapEncoding

Source§

fn clone(&self) -> BitmapEncoding

Returns a duplicate 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 BitmapEncoding

Source§

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

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

impl Default for BitmapEncoding

Source§

fn default() -> BitmapEncoding

Returns the “default value” for a type. Read more
Source§

impl PartialEq for BitmapEncoding

Source§

fn eq(&self, other: &BitmapEncoding) -> 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 TryFrom<BitmapEncoding> for BitmapDataFormat

Source§

type Error = ErrorMessage

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

fn try_from(value: BitmapEncoding) -> Result<Self, ErrorMessage>

Performs the conversion.
Source§

impl Copy for BitmapEncoding

Source§

impl StructuralPartialEq for BitmapEncoding

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> 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.