#[non_exhaustive]pub enum Format {
Show 73 variants
R8G8B8_UNORM,
B8G8R8_UNORM,
R8G8B8A8_UNORM,
R8G8B8A8_SNORM,
B8G8R8A8_UNORM,
B8G8R8X8_UNORM,
B5G6R5_UNORM,
B5G5R5A1_UNORM,
B4G4R4A4_UNORM,
A4B4G4R4_UNORM,
R8_SNORM,
R8_UNORM,
R8G8_UNORM,
R8G8_SNORM,
A8_UNORM,
R16_UNORM,
R16_SNORM,
R16G16_UNORM,
R16G16_SNORM,
R16G16B16A16_UNORM,
R16G16B16A16_SNORM,
R10G10B10A2_UNORM,
R11G11B10_FLOAT,
R9G9B9E5_SHAREDEXP,
R16_FLOAT,
R16G16_FLOAT,
R16G16B16A16_FLOAT,
R32_FLOAT,
R32G32_FLOAT,
R32G32B32_FLOAT,
R32G32B32A32_FLOAT,
R10G10B10_XR_BIAS_A2_UNORM,
AYUV,
Y410,
Y416,
R1_UNORM,
R8G8_B8G8_UNORM,
G8R8_G8B8_UNORM,
UYVY,
YUY2,
Y210,
Y216,
NV12,
P010,
P016,
BC1_UNORM,
BC2_UNORM,
BC2_UNORM_PREMULTIPLIED_ALPHA,
BC3_UNORM,
BC3_UNORM_PREMULTIPLIED_ALPHA,
BC4_UNORM,
BC4_SNORM,
BC5_UNORM,
BC5_SNORM,
BC6H_UF16,
BC6H_SF16,
BC7_UNORM,
ASTC_4X4_UNORM,
ASTC_5X4_UNORM,
ASTC_5X5_UNORM,
ASTC_6X5_UNORM,
ASTC_6X6_UNORM,
ASTC_8X5_UNORM,
ASTC_8X6_UNORM,
ASTC_8X8_UNORM,
ASTC_10X5_UNORM,
ASTC_10X6_UNORM,
ASTC_10X8_UNORM,
ASTC_10X10_UNORM,
ASTC_12X10_UNORM,
ASTC_12X12_UNORM,
BC3_UNORM_RXGB,
BC3_UNORM_NORMAL,
}Expand description
The format of the pixel data of a surface.
This enumeration is modelled after the DXGI_FORMAT enumeration and has the same semantics and naming conventions.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
R8G8B8_UNORM
B8G8R8_UNORM
R8G8B8A8_UNORM
R8G8B8A8_SNORM
B8G8R8A8_UNORM
B8G8R8X8_UNORM
B5G6R5_UNORM
B5G5R5A1_UNORM
B4G4R4A4_UNORM
A4B4G4R4_UNORM
R8_SNORM
R8_UNORM
R8G8_UNORM
R8G8_SNORM
A8_UNORM
R16_UNORM
R16_SNORM
R16G16_UNORM
R16G16_SNORM
R16G16B16A16_UNORM
R16G16B16A16_SNORM
R10G10B10A2_UNORM
R11G11B10_FLOAT
R9G9B9E5_SHAREDEXP
R16_FLOAT
R16G16_FLOAT
R16G16B16A16_FLOAT
R32_FLOAT
R32G32_FLOAT
R32G32B32_FLOAT
R32G32B32A32_FLOAT
R10G10B10_XR_BIAS_A2_UNORM
AYUV
Y410
Y416
R1_UNORM
R8G8_B8G8_UNORM
G8R8_G8B8_UNORM
UYVY
YUY2
Y210
Y216
NV12
P010
P016
BC1_UNORM
BC2_UNORM
BC2_UNORM_PREMULTIPLIED_ALPHA
BC3_UNORM
BC3_UNORM_PREMULTIPLIED_ALPHA
BC4_UNORM
BC4_SNORM
BC5_UNORM
BC5_SNORM
BC6H_UF16
BC6H_SF16
BC7_UNORM
ASTC_4X4_UNORM
ASTC_5X4_UNORM
ASTC_5X5_UNORM
ASTC_6X5_UNORM
ASTC_6X6_UNORM
ASTC_8X5_UNORM
ASTC_8X6_UNORM
ASTC_8X8_UNORM
ASTC_10X5_UNORM
ASTC_10X6_UNORM
ASTC_10X8_UNORM
ASTC_10X10_UNORM
ASTC_12X10_UNORM
ASTC_12X12_UNORM
BC3_UNORM_RXGB
This is just Format::BC3_UNORM, but with the R channel stored in alpha.
BC3 stores the A channel with a much higher precision than the other (color) channels. RXGB uses this by storing the R channel of the image in the BC3 A channel, effectively increasing the precision of not just the R channel, but also the G and B channels.
Note that this is an RGB format. The BC3-encoded R channel is commonly set to 0 to improve the quality of G and B.
BC3_UNORM_NORMAL
This format is also called DXT5n, DXT5nm, or BC3n. It’s intended
for storing normal maps.
Similar to Format::BC3_UNORM_RXGB, this format stores the R channel
in alpha. The B channel is discarded when encoding (set to 0), and
reconstructed when decoding using the following formula:
B = 0.5 * sqrt(1 - (2*R - 1)^2 - (2*G - 1)^2) + 0.5This format does not have a specified DXGI format or FourCC code.
As such, it cannot be detected from a DDS header. This makes it the
user’s to detect this format. When creating a header, this format
will be represented by DxgiFormat::BC3_UNORM.
Note: This format is only supported for completeness. Don’t actually use it. BC7 and BC5 offer superior quality for the same compression ratio.
Implementations§
Source§impl Format
impl Format
Sourcepub fn from_header(header: &Header) -> Result<Format, FormatError>
pub fn from_header(header: &Header) -> Result<Format, FormatError>
Returns the format of the surfaces from a DDS header.
Sourcepub const fn from_dxgi(dxgi: DxgiFormat) -> Option<Format>
pub const fn from_dxgi(dxgi: DxgiFormat) -> Option<Format>
Returns the format of a surface from a DXGI format.
None if the DXGI format is not supported for decoding.
Sourcepub const fn from_four_cc(four_cc: FourCC) -> Option<Format>
pub const fn from_four_cc(four_cc: FourCC) -> Option<Format>
Returns the format of a surface from a FourCC code.
None if the FourCC code is not supported for decoding.
Sourcepub const fn channels(&self) -> Channels
pub const fn channels(&self) -> Channels
The number and type of (color) channels in the surface.
If the channels of a format cannot be accurately described by
Channels, the next larger type is used. For example, a format with
only R and G channels will be described as Channels::Rgb.
Sourcepub const fn precision(&self) -> Precision
pub const fn precision(&self) -> Precision
The precision/bit depth closest to the values in the surface.
DDS supports formats with various precisions and ranges, and not all of
them can be represented exactly by the Precision enum. The closest
precision is chosen based on the format’s range and encoded bit depth.
It is typically larger than the encoded bit depth.
E.g. the format B5G6R5_UNORM is a 5/6-bit per channel format and the
closest precision is Precision::U8. While U8 can closely
approximate all B5G6R5_UNORM values, it is not exact. E.g. a 5-bit
UNORM value of 11 is 90.48 as an 8-bit UNORM value exactly but will be
rounded to 90.
Sourcepub const fn color(&self) -> ColorFormat
pub const fn color(&self) -> ColorFormat
The native color format of the surface.
This is simply Self::channels and Self::precision combined.
Sourcepub const fn encoding_support(self) -> Option<EncodingSupport>
pub const fn encoding_support(self) -> Option<EncodingSupport>
Returns information about the encoding support of this format.
If the format does not support encoding, None is returned.
Trait Implementations§
Source§impl TryFrom<Format> for Dx9PixelFormat
impl TryFrom<Format> for Dx9PixelFormat
Source§impl TryFrom<Format> for DxgiFormat
impl TryFrom<Format> for DxgiFormat
Source§impl TryFrom<Format> for MaskPixelFormat
impl TryFrom<Format> for MaskPixelFormat
impl Copy for Format
impl Eq for Format
impl StructuralPartialEq for Format
Auto Trait Implementations§
impl Freeze for Format
impl RefUnwindSafe for Format
impl Send for Format
impl Sync for Format
impl Unpin for Format
impl UnwindSafe for Format
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more