Skip to main content

PixelFormat

Trait PixelFormat 

Source
pub trait PixelFormat:
    Sealed
    + Copy
    + 'static {
    type Sample: Sample;

    const CHANNELS: Channels;
    const COLOR_SPACE: ColorSpace;
    const BIT_DEPTH: BitDepth;
}
Expand description

A compile-time description of how an Image’s pixels are laid out and interpreted.

Every implementor is a zero-sized marker type. Because Image is generic over this trait, the color space, channel layout, and bit depth of an image all live in its type, so a metric can reject mismatched inputs at compile time.

This trait is sealed; the crate defines every valid format, so downstream code cannot introduce nonsensical combinations.

Required Associated Constants§

Source

const CHANNELS: Channels

Channel layout.

Source

const COLOR_SPACE: ColorSpace

Color space the samples are encoded in.

Source

const BIT_DEPTH: BitDepth

Bits per sample (mirrors Sample::BIT_DEPTH for convenience).

Required Associated Types§

Source

type Sample: Sample

The storage sample type, u8 or u16.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl PixelFormat for Gray8

Source§

const CHANNELS: Channels = Channels::Gray

Source§

const COLOR_SPACE: ColorSpace = ColorSpace::Grayscale

Source§

const BIT_DEPTH: BitDepth = <u8 as Sample>::BIT_DEPTH

Source§

type Sample = u8

Source§

impl PixelFormat for Gray16

Source§

const CHANNELS: Channels = Channels::Gray

Source§

const COLOR_SPACE: ColorSpace = ColorSpace::Grayscale

Source§

const BIT_DEPTH: BitDepth = <u16 as Sample>::BIT_DEPTH

Source§

type Sample = u16

Source§

impl PixelFormat for Rgba8

Source§

const CHANNELS: Channels = Channels::Rgba

Source§

const COLOR_SPACE: ColorSpace = ColorSpace::Srgb

Source§

const BIT_DEPTH: BitDepth = <u8 as Sample>::BIT_DEPTH

Source§

type Sample = u8

Source§

impl PixelFormat for Rgba16

Source§

const CHANNELS: Channels = Channels::Rgba

Source§

const COLOR_SPACE: ColorSpace = ColorSpace::Srgb

Source§

const BIT_DEPTH: BitDepth = <u16 as Sample>::BIT_DEPTH

Source§

type Sample = u16

Source§

impl PixelFormat for Srgb8

Source§

const CHANNELS: Channels = Channels::Rgb

Source§

const COLOR_SPACE: ColorSpace = ColorSpace::Srgb

Source§

const BIT_DEPTH: BitDepth = <u8 as Sample>::BIT_DEPTH

Source§

type Sample = u8

Source§

impl PixelFormat for Srgb16

Source§

const CHANNELS: Channels = Channels::Rgb

Source§

const COLOR_SPACE: ColorSpace = ColorSpace::Srgb

Source§

const BIT_DEPTH: BitDepth = <u16 as Sample>::BIT_DEPTH

Source§

type Sample = u16