[−][src]Crate jascpal
JASC Palette file reader/writer.
Parses and stringifes palette files containing any number of colours.
JASC palette files follow a simple format:
JASC-PAL
0100
$num_colors
$rgb...
Colours are represented using the rgb
crate.
Example
use std::io::Cursor; use jascpal::{Palette, PaletteIndex, Color}; let cursor = Cursor::new(b"JASC-PAL\r\n0100\r\n2\r\n0 0 0\r\n255 255 255\r\n".to_vec()); let pal = Palette::read_from(cursor).unwrap(); assert_eq!(pal[PaletteIndex::from(0)], Color { r: 0, g: 0, b: 0 }); assert_eq!(pal[PaletteIndex::from(1)], Color { r: 255, g: 255, b: 255 }); let mut pal = pal; pal[PaletteIndex::from(1)] = Color { r: 0, g: 255, b: 255 }; pal.add(Color { r: 255, g: 0, b: 0 }); assert_eq!( pal.to_string(), "JASC-PAL\r\n0100\r\n3\r\n0 0 0\r\n0 255 255\r\n255 0 0\r\n".to_string() );
Structs
Palette | A Palette. |
PaletteIndex | A palette index. |
Enums
ReadPaletteError | An error occurred during reading. |
Type Definitions
Color | Represents an RGB colour. |