[][src]Trait openexr::frame_buffer::PixelStruct

pub unsafe trait PixelStruct {
    fn channel_count() -> usize;
fn channel(i: usize) -> (PixelType, usize); fn channels() -> PixelStructChannelIter { ... } }

Types that can be inserted into a FrameBuffer as a set of channels.

This should only be implemented for types that that contain components that are bitwise- and semantically-identical to the PixelType variants.

The intended use of this is to allow e.g. a tuple or struct of RGB values to be used directly by the library to write data out to and read data in from EXR files. This avoids having to create buffers of converted values.

Examples

use openexr::PixelType;
use openexr::frame_buffer::PixelStruct;

#[repr(C)]
#[derive(Copy, Clone)]
struct RGB {
    r: f32,
    g: f32,
    b: f32,
}

unsafe impl PixelStruct for RGB {
    fn channel_count() -> usize { 3 }
    fn channel(i: usize) -> (PixelType, usize) {
        [(PixelType::FLOAT, 0),
         (PixelType::FLOAT, 4),
         (PixelType::FLOAT, 8)][i]
    }
}

Required methods

fn channel_count() -> usize

Returns the number of channels in this type

fn channel(i: usize) -> (PixelType, usize)

Returns the type and offset of channel i

Panics

Will either panic or return garbage when i >= channel_count().

Loading content...

Provided methods

fn channels() -> PixelStructChannelIter

Returns an iterator over the set of channels

Loading content...

Implementations on Foreign Types

impl<A: PixelData> PixelStruct for (A,)[src]

fn channels() -> PixelStructChannelIter[src]

impl<A, B> PixelStruct for (A, B) where
    A: PixelData,
    B: PixelData
[src]

fn channels() -> PixelStructChannelIter[src]

impl<A, B, C> PixelStruct for (A, B, C) where
    A: PixelData,
    B: PixelData,
    C: PixelData
[src]

fn channels() -> PixelStructChannelIter[src]

impl<A, B, C, D> PixelStruct for (A, B, C, D) where
    A: PixelData,
    B: PixelData,
    C: PixelData,
    D: PixelData
[src]

fn channels() -> PixelStructChannelIter[src]

impl<T: PixelData> PixelStruct for [T; 1][src]

fn channels() -> PixelStructChannelIter[src]

impl<T: PixelData> PixelStruct for [T; 2][src]

fn channels() -> PixelStructChannelIter[src]

impl<T: PixelData> PixelStruct for [T; 3][src]

fn channels() -> PixelStructChannelIter[src]

impl<T: PixelData> PixelStruct for [T; 4][src]

fn channels() -> PixelStructChannelIter[src]

Loading content...

Implementors

impl<T: PixelData> PixelStruct for T[src]

Loading content...