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
impl BitmapEncoding
Sourcepub const fn bits_per_pixel(self) -> usize
pub const fn bits_per_pixel(self) -> usize
Get the number of bits per pixel (all channels combined).
Sourcepub const fn pixels_per_block(self) -> usize
pub const fn pixels_per_block(self) -> usize
Get the number of pixels per block.
Sourcepub const fn block_size(self) -> (usize, usize)
pub const fn block_size(self) -> (usize, usize)
Get the block size.
Sourcepub const fn bytes_per_block(self) -> usize
pub const fn bytes_per_block(self) -> usize
Get the number of bytes per block.
Sourcepub const fn is_palettized(self) -> bool
pub const fn is_palettized(self) -> bool
Return true if the format is a palettization encoding.
Sourcepub const fn is_monochrome(self) -> bool
pub const fn is_monochrome(self) -> bool
Return true if the format is a monochrome encoding.
Sourcepub const fn is_block_compression(self) -> bool
pub const fn is_block_compression(self) -> bool
Return true if the format is a block compression encoding.
Sourcepub fn encode(
self,
pixels: &[ColorARGBInt],
width: usize,
height: usize,
depth: usize,
faces: usize,
mipmaps: usize,
use_dithering: bool,
) -> Vec<u8> ⓘ
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
facesas 1. - For non-3D textures, specify
depthas 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.
Sourcepub fn decode(
self,
pixels: &[u8],
width: usize,
height: usize,
depth: usize,
faces: usize,
mipmaps: usize,
) -> Vec<ColorARGBInt>
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
facesas 1. - For non-3D textures, specify
depthas 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.
Sourcepub fn calculate_size_of_texture(
self,
width: usize,
height: usize,
depth: usize,
faces: usize,
mipmaps: usize,
) -> usize
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
facesas 1. - For non-3D textures, specify
depthas 1.
Sourcepub fn calculate_effective_pixel_count(
self,
width: usize,
height: usize,
depth: usize,
faces: usize,
mipmaps: usize,
) -> usize
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
facesas 1. - For non-3D textures, specify
depthas 1.
Sourcepub fn get_block(
self,
pixels: &[ColorARGBInt],
output: &mut [ColorARGBInt],
width: usize,
height: usize,
block_x: usize,
block_y: usize,
)
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.
Sourcepub fn get_block_dimensions(self, width: usize, height: usize) -> (usize, usize)
pub fn get_block_dimensions(self, width: usize, height: usize) -> (usize, usize)
Get the width and height of the image in blocks.
Sourcepub fn supports_dithering(self) -> bool
pub fn supports_dithering(self) -> bool
Get whether or not the format supports dithering.
Trait Implementations§
Source§impl Clone for BitmapEncoding
impl Clone for BitmapEncoding
Source§fn clone(&self) -> BitmapEncoding
fn clone(&self) -> BitmapEncoding
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more