pub struct SampleInformation {
pub bit_offset: u16,
pub bit_length: NonZeroU8,
pub channel_type: u8,
pub channel_type_qualifiers: ChannelTypeQualifiers,
pub sample_positions: [u8; 4],
pub lower: u32,
pub upper: u32,
}Expand description
Information about each “sample” within an image.
A “sample” consisting of a single channel of data and with a single corresponding “position” within the texel block.
See the DFD specification for more extremely verbose information.
Fields§
§bit_offset: u16Offset from the beginning of the texel block in bits.
bit_length: NonZeroU8The length of this sample in bits.
channel_type: u8The type of channel this sample represents. This varies by ColorModel.
channel_type_qualifiers: ChannelTypeQualifiersQualifiers modifying the channel type.
sample_positions: [u8; 4]The position in texels of this sample relative to the 0,0,0,0 texel in the 4D texel block.
lower: u32The sample value that maps to the format’s logical minimum — typically 0 for unsigned
formats, -1 for signed formats, or -0.5 for chroma channels in color difference models
(e.g. Y′CbCr).
Together with upper, this defines how raw sample values are converted to
their conceptual numeric interpretation. Values are not guaranteed to fall within this
range — for example, HDR formats may define 1.0 as a nominal level well below the actual
maximum. When samples should be interpreted directly as integers (unnormalized), set
upper to 1 and lower to 0 (unsigned) or -1 (signed).
For integer formats, this is stored as a 32-bit integer (signed or unsigned matching the
channel encoding). For floating-point formats, it is stored as a 32-bit float. For formats
wider than 32 bits (e.g. 64-bit), integer values are expanded by preserving the sign bit
and replicating the top non-sign bit, and float values are converted to the native
representation (e.g. f32 to f64).
§Examples
| Format | lower | upper | Effect |
|---|---|---|---|
| R8 unorm | 0 | 255 | Maps 0–255 to 0.0–1.0 |
| R8 snorm | -127 (0xFFFFFF81) | 127 | Maps -127–127 to -1.0–1.0 |
| R8 uint | 0 | 1 | Integer value used directly |
| R16 sfloat | 0xBF800000 (-1.0f) | 0x3F800000 (1.0f) | Float range -1.0–1.0 |
| R64 uint | 0 | 1 | Expands to 64-bit 0 and 1 |
| R64 uint norm | 0 | 0xFFFFFFFF | Expands to u64::MAX, maps to 0.0–1.0 |
| BT.709 Y′ (8-bit) | 16 | 235 | Maps 16–235 to 0.0–1.0 |
For a very long and confusing explanation of this, please see the DFD specification
upper: u32The sample value that maps to 1.0 (the white point), or 0.5 for chroma channels in
color difference models (e.g. Y′CbCr).
See lower for more details on interpretation and encoding and examples.
Implementations§
Trait Implementations§
Source§impl Clone for SampleInformation
impl Clone for SampleInformation
Source§fn clone(&self) -> SampleInformation
fn clone(&self) -> SampleInformation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for SampleInformation
Source§impl Debug for SampleInformation
impl Debug for SampleInformation
impl Eq for SampleInformation
Source§impl PartialEq for SampleInformation
impl PartialEq for SampleInformation
Source§fn eq(&self, other: &SampleInformation) -> bool
fn eq(&self, other: &SampleInformation) -> bool
self and other values to be equal, and is used by ==.