Crate rgb [] [src]

Basic struct for RGB and RGBA pixels. Packed, with red first, alpha last.

This crate is intended to be the lowest common denominator for sharing RGB/RGBA bitmaps between other crates.

The crate includes convenience functions for converting between the struct and bytes, and overloaded operators that work on all channels at once.

This crate intentionally doesn't implement color management and other colorspaces.

Structs

RGB

This is it. The component type can be u8 (aliased as RGB8), u16 (aliased as RGB16), or any other type (but simple copyable types are recommended.)

RGBA

This is it. The component type can be u8 (aliased as RGBA8), u16 (aliased as RGBA16), or any other type (but simple copyable types are recommended.)

Traits

ByteSlice

Cast array of structs into array of raw bytes (so that [0] is R, [1] is G, [2] is B, etc.)

ComponentBytes

Casting the struct to slices/bytes of its components

ComponentMap

Applying operation to every component

Type Definitions

RGB8

8-bit RGB. The colorspace is techincally undefined, but generally sRGB is assumed.

RGB16

16-bit RGB in machine's native endian. Be careful to perform byte-swapping when reading from files.

RGBA8

Alpha is last. The crate doesn't impose which value represents transparency, but usually it's 0 = transparent, 255 = opaque.

RGBA16

16-bit RGB in machine's native endian. Alpha is last.