add unit tests

png-branch
an 2019-02-05 00:12:10 -05:00
parent 0a4e32c794
commit 4c590a0dc2
14 changed files with 393 additions and 85 deletions

View File

@ -17,4 +17,10 @@ pub fn crc32(b: &[u8], s: u32) -> u32
!b.iter().fold(s, |a, &o| {a >> 8 ^ t[(a & 0xff ^ o as u32) as usize]})
}
#[test]
fn crc32_lorem_ipsum()
{
assert_eq!(crc32(b"Lorem ipsum dolor sit amet", !0), 0x5F29D461);
}
// EOF

View File

@ -6,52 +6,44 @@ impl Fx32
{
const FRACBITS: u32 = 16;
const FRACMASK: u32 = 0xFFFF;
const ONE: i32 = 1 << Fx32::FRACBITS;
const ONE: i32 = 1 << Fx32::FRACBITS;
pub fn to_bits(&self) -> u32 {self.0 as u32}
pub fn set_bits(&mut self, bits: u32) {self.0 = bits as i32}
pub fn from_bits(bits: u32) -> Fx32 {Fx32(bits as i32)}
pub fn integ(&self) -> i16 {(self.0 >> 16) as i16}
pub fn to_bits(&self) -> u32 {self.0 as u32}
pub fn set_bits(&mut self, bits: u32) {self.0 = bits as i32}
pub fn from_bits(bits: u32) -> Fx32 {Fx32(bits as i32)}
pub fn integ(&self) -> i16 {(self.0 >> Fx32::FRACBITS) as i16}
pub fn fract(&self) -> u16 {(self.0 as u32 & Fx32::FRACMASK) as u16}
pub fn mul_i(&self, n: i32) -> Fx32 {Fx32(self.0 * n)}
pub fn div_i(&self, n: i32) -> Fx32 {Fx32(self.0 / n)}
}
impl From<i32> for Fx32 {fn from(n: i32) -> Fx32 {Fx32(n << Fx32::FRACBITS)}}
impl ops::Add for Fx32
{
type Output = Fx32;
fn add(self, other: Fx32) -> Fx32 {Fx32(self.0 + other.0)}
}
{type Output = Fx32; fn add(self, o: Fx32) -> Fx32 {Fx32(self.0 + o.0)}}
impl ops::Sub for Fx32
{
type Output = Fx32;
fn sub(self, other: Fx32) -> Fx32 {Fx32(self.0 - other.0)}
}
{type Output = Fx32; fn sub(self, o: Fx32) -> Fx32 {Fx32(self.0 - o.0)}}
impl ops::Mul for Fx32
{
type Output = Fx32;
fn mul(self, other: Fx32) -> Fx32
{Fx32((self.0 as i64 * other.0 as i64 / Fx32::ONE as i64) as i32)}
fn mul(self, o: Fx32) -> Fx32
{Fx32((self.0 as i64 * o.0 as i64 / Fx32::ONE as i64) as i32)}
}
impl ops::Div for Fx32
{
type Output = Fx32;
fn div(self, other: Fx32) -> Fx32
{Fx32((self.0 as i64 * Fx32::ONE as i64 / other.0 as i64) as i32)}
fn div(self, o: Fx32) -> Fx32
{Fx32((self.0 as i64 * Fx32::ONE as i64 / o.0 as i64) as i32)}
}
impl ops::Neg for Fx32
{
type Output = Fx32;
fn neg(self) -> Fx32 {Fx32(-self.0)}
}
{type Output = Fx32; fn neg(self) -> Fx32 {Fx32(-self.0)}}
impl ops::Not for Fx32
{
type Output = Fx32;
fn not(self) -> Fx32 {Fx32(!self.0)}
}
{type Output = Fx32; fn not(self) -> Fx32 {Fx32(!self.0)}}
impl fmt::Display for Fx32
{
@ -77,22 +69,35 @@ impl fmt::Display for Fx32
impl fmt::Debug for Fx32
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result
{
let prec = f.precision().unwrap_or(1);
let widt = f.width().unwrap_or(0);
write!(f, "{:widt$}.", self.integ(), widt = widt)?;
{fmt::Display::fmt(self, f)}
}
let mut k = self.to_bits();
for _ in 0..prec {
k &= Fx32::FRACMASK;
k *= 10;
let d = k >> Fx32::FRACBITS;
let d = d % 10;
f.write_char((d as u8 + b'0') as char)?;
}
#[test]
fn fx32_basic_ops()
{
let seven_div_2 = 3 << Fx32::FRACBITS | Fx32::FRACMASK / 2 + 1;
assert_eq!((Fx32::from(1) + 1.into()).to_bits(), 2 << Fx32::FRACBITS);
assert_eq!((Fx32::from(2) - 1.into()).to_bits(), 1 << Fx32::FRACBITS);
assert_eq!((Fx32::from(6) * 2.into()).to_bits(), 12 << Fx32::FRACBITS);
assert_eq!((Fx32::from(6).mul_i(2) ).to_bits(), 12 << Fx32::FRACBITS);
assert_eq!((Fx32::from(7) / 2.into()).to_bits(), seven_div_2);
assert_eq!((Fx32::from(7).div_i(2) ).to_bits(), seven_div_2);
}
Ok(())
}
#[test]
#[should_panic]
#[allow(unused_must_use)]
fn fx32_overflow()
{
Fx32::from(32767) + 1.into();
}
#[test]
fn fx32_printing()
{
assert_eq!(format!("{}", Fx32::from(6)), "6.0");
assert_eq!(format!("{}", Fx32::from(7).div_i(2)), "3.5");
assert_eq!(format!("{:7.7}", Fx32::from_bits(0xDEAD_BEEF)), " -8531.7458343");
}
// EOF

View File

@ -3,7 +3,7 @@
use std::ops::{Index, IndexMut};
/// RGBA8 color.
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq)]
pub struct Color
{
pub r: u8,

View File

@ -5,29 +5,33 @@ use crate::durandal::bin::*;
/// Checks for an AppleSingle header. Returns offset to the resource fork.
pub fn check_apple_single(b: &[u8]) -> Option<usize>
{
if b.o_u32b(0)? != 0x51600 || b.o_u32b(4)? != 0x20000 {return None;}
// check magic numbers
if b[0..8] != [0, 5, 22, 0, 0, 2, 0, 0] {return None;}
// get the resource fork (entity 1)
let num = b.o_u16b(24)? as usize;
for i in 0..num {
let p = 26 + (12 * i);
let fid = b.o_u32b(p )?;
let p = 26 + 12 * i;
let ent = b.o_u32b(p )?;
let ofs = b.o_u32b(p+4)? as usize;
let len = b.o_u32b(p+8)? as usize;
if fid == 1 {return if ofs + len > b.len() {None} else {Some(ofs)};}
if ent == 1 {return if ofs + len > b.len() {None} else {Some(ofs)};}
}
// no resource fork
None
}
/// Checks for a MacBin header. Returns offset to the resource fork.
pub fn check_mac_bin(b: &[u8]) -> Option<usize>
/// Checks for a MacBinary II header. Returns offset to the resource fork.
pub fn check_macbin(b: &[u8]) -> Option<usize>
{
if b[0] != 0 || b[1] > 63 || b[74] != 0 || b[123] > 0x81 {return None;}
// check legacy version, length, zero fill, and macbin2 version
if b[0] != 0 || b[1] > 63 || b[74] != 0 || b[123] > 129 {return None;}
let mut crc = 0;
// check header crc
for i in 0..124 {
for j in 8..16 {
let d = b[i] as (u16) << j;
@ -36,6 +40,7 @@ pub fn check_mac_bin(b: &[u8]) -> Option<usize>
}
}
// if ok, resource fork follows
if crc == b.o_u16b(124)? {Some(128)} else {None}
}
@ -43,8 +48,8 @@ pub fn check_mac_bin(b: &[u8]) -> Option<usize>
/// offset from the start of the header to the resource fork (if one is found.)
pub fn try_mac_header(b: &[u8]) -> usize
{
let ofs = check_mac_bin(b).unwrap_or(0);
if ofs != 0 {ofs} else {check_apple_single(b).unwrap_or(0)}
if let Some(ofs) = check_macbin(b) {ofs}
else {check_apple_single(b).unwrap_or(0)}
}
// EOF

View File

@ -8,7 +8,6 @@ pub mod err;
pub mod fx32;
pub mod image;
pub mod machead;
pub mod pict;
pub mod text;
/// Creates an enumeration and function for converting a representation into

View File

@ -1,26 +1,23 @@
//! Text conversion utilities.
/// Dumps a slice of memory as text to stdout.
/// Dumps a slice of memory as text to stderr.
pub fn dump_mem(b: &[u8])
{
let mut p = 0;
for &c in b {
if p + 3 > 79 {
println!("");
eprintln!("");
p = 0;
}
if c.is_ascii_graphic() {
print!(" {} ", c as char);
} else {
print!("{:02X} ", c);
}
if c.is_ascii_graphic() {eprint!(" {} ", c as char);}
else {eprint!("{:02X} ", c);}
p += 3;
}
println!("");
eprintln!("");
}
/// Formats a binary size string for any given number.
@ -32,7 +29,7 @@ pub fn to_binsize(n: u64) -> String
if n == 0 {return String::from("empty");}
// terabytes, gigabytes, megabytes, kilobytes
for i in 4..=1 {
for i in (1..=4).rev() {
if n >= 1000u64.pow(i) {
let x = n as f64 / 1000f64.powi(i as i32);
return format!("{:1}{}", x, NAMES[i as usize - 1])
@ -106,4 +103,28 @@ const TR: [char; 128] = [
'\u{00b8}', '\u{02dd}', '\u{02db}', '\u{02c7}'
];
#[test]
fn to_binsize_integrals()
{
assert_eq!(to_binsize(0), "empty");
assert_eq!(to_binsize(1), "1 byte");
assert_eq!(to_binsize(2), "2 bytes");
assert_eq!(to_binsize(999), "999 bytes");
assert_eq!(to_binsize(1000), "1kB");
assert_eq!(to_binsize(1000 * 7), "7kB");
assert_eq!(to_binsize(1000 * 1000), "1MB");
assert_eq!(to_binsize(1000 * 1000 * 7), "7MB");
assert_eq!(to_binsize(1000 * 1000 * 1000), "1GB");
assert_eq!(to_binsize(1000 * 1000 * 1000 * 7), "7GB");
assert_eq!(to_binsize(1000 * 1000 * 1000 * 1000), "1TB");
assert_eq!(to_binsize(1000 * 1000 * 1000 * 1000 * 7), "7TB");
}
#[test]
fn mac_roman_conv_basic_marathon_stuff()
{
assert_eq!(mac_roman_conv(b"p\x8cth"), "påth");
assert_eq!(mac_roman_conv(b"I\xd5ve"), "Ive");
}
// EOF

5
src/lib.rs Normal file
View File

@ -0,0 +1,5 @@
#[macro_use]
pub mod durandal;
pub mod marathon;
// EOF

View File

@ -1,9 +1,5 @@
#[macro_use]
pub mod durandal;
pub mod marathon;
use crate::durandal::{chunk::*, err::*, image::Image, pict::load_pict};
use crate::marathon::{map, wad, term};
use maraiah::durandal::{chunk::*, err::*, image::Image};
use maraiah::marathon::{map, pict, term, wad};
use memmap::Mmap;
use std::{io, io::Write, fs, env};
@ -35,7 +31,7 @@ fn main() -> ResultS<()>
for (id, ent) in wad.entries {
if let Some(b) = ent.chunks.get(b"PICT") {
let im = load_pict(b)?;
let im = pict::load_pict(b)?;
println!("entry {} has PICT {}x{}", id, im.w(), im.h());
write_ppm(&format!("out_{}.ppm", id), &im)?;
}

View File

@ -23,8 +23,7 @@ impl Chunked<Endpoint> for Endpoint
let flags = b.c_u16b(0)?;
let adj_hi = b.c_i16b(2)?;
let adj_lo = b.c_i16b(4)?;
let pos = Point::read(&b[ 6..10])?;
// xform = Point::read(&b[10..14])?;
let pos = Point::read(&b[6..10])?;
let support = b.c_u16b(14)?;
let flags = EndpointFlags::from_bits_truncate(flags);
Ok(Endpoint{flags, adj_hi, adj_lo, pos, support})
@ -87,7 +86,7 @@ impl Chunked<Side> for Side
} else {
None
};
let shade = Fx32::from_bits(shade);
let shade = Fx32::from_bits(shade);
Ok(Side{stype, flags, tex_pri, tex_sec, tex_tra, ex_tleft, ex_trigh,
ex_bleft, ex_brigh, paneltyp, paneldat, xfer_pri, xfer_sec,
xfer_tra, shade})

View File

@ -1,6 +1,7 @@
//! Library for Marathon data formats.
//! Library for file data formats.
pub mod map;
pub mod pict;
pub mod term;
pub mod wad;

View File

@ -10,7 +10,7 @@ const PACK_RLE16 : u16 = 3;
const PACK_RLE32 : u16 = 4;
/// Process a CopyBits operation.
fn read_bitmap_area(mut im: Image, b: &[u8], packed: bool, clip: bool) -> ResultS<Image>
pub fn read_bitmap_area(mut im: Image, b: &[u8], packed: bool, clip: bool) -> ResultS<Image>
{
let mut p = if !packed {4} else {0};
@ -146,7 +146,7 @@ fn read_bitmap_area(mut im: Image, b: &[u8], packed: bool, clip: bool) -> Result
}
/// Process a CompressedQuickTime operation.
fn read_quicktime_c(_im: Image, _b: &[u8]) -> ResultS<Image>
pub fn read_quicktime_c(_im: Image, _b: &[u8]) -> ResultS<Image>
{
err_msg("compressed quicktime format not implemented")
}
@ -230,25 +230,25 @@ pub fn load_pict(b: &[u8]) -> ResultS<Image>
}
/// Read a colorTable structure.
fn get_clut(b: &[u8]) -> ResultS<(Vec<Color>, usize)>
pub fn get_clut(b: &[u8]) -> ResultS<(Vec<Color>, usize)>
{
// sed = b.c_u32b(0)?;
let dev = b.c_u16b(4)? & 0x8000 != 0;
let num = b.c_u16b(6)? as usize + 1;
let mut p = 8;
let mut clut = Vec::with_capacity(num);
clut.resize(num, Color{r: 0, g: 0, b: 0, a: 0});
let mut clut = vec![Color{r: 0, g: 0, b: 0, a: 0}; num];
for i in 0..num {
// with device mapping, we ignore the index entirely
let n = if !dev {(b.c_u16b(p )? & 0xff) as usize} else {i};
let r = (b.c_u16b(p+2)? >> 8) as u8;
let g = (b.c_u16b(p+4)? >> 8) as u8;
let b = (b.c_u16b(p+6)? >> 8) as u8;
let n = if !dev {b[p + 1] as usize} else {i};
let r = b[p+2];
let g = b[p+4];
let b = b[p+6];
if n >= clut.len() {return err_msg("bad clut index");}
clut[n] = Color{r, g, b, a: 255};
p += 8;
}
@ -256,7 +256,7 @@ fn get_clut(b: &[u8]) -> ResultS<(Vec<Color>, usize)>
}
/// Read run-length encoded data.
fn read_rle(b: &[u8], pitch: usize, ln: bool) -> ResultS<(Vec<u8>, usize)>
pub fn read_rle(b: &[u8], pitch: usize, ln: bool) -> ResultS<(Vec<u8>, usize)>
{
let mut p = 0;
let mut o = Vec::with_capacity(pitch);
@ -292,7 +292,7 @@ fn read_rle_data<F, N>(cmp: bool, len: usize, out: &mut Vec<u8>, mut read: F)
}
/// Expand packed pixel data based on bit depth.
fn expand_data(b: Vec<u8>, depth: u16) -> ResultS<Vec<u8>>
pub fn expand_data(b: Vec<u8>, depth: u16) -> ResultS<Vec<u8>>
{
let mut o = Vec::with_capacity(match depth {
4 => b.len() * 2,

BIN
tests/clut.in Normal file

Binary file not shown.

258
tests/clut.out Normal file
View File

@ -0,0 +1,258 @@
[
Color{r: 255, g: 255, b: 255, a: 255},
Color{r: 7, g: 9, b: 19, a: 255},
Color{r: 7, g: 18, b: 42, a: 255},
Color{r: 61, g: 66, b: 20, a: 255},
Color{r: 39, g: 12, b: 18, a: 255},
Color{r: 28, g: 35, b: 47, a: 255},
Color{r: 52, g: 52, b: 62, a: 255},
Color{r: 14, g: 5, b: 6, a: 255},
Color{r: 48, g: 61, b: 79, a: 255},
Color{r: 44, g: 21, b: 32, a: 255},
Color{r: 220, g: 220, b: 1, a: 255},
Color{r: 16, g: 19, b: 28, a: 255},
Color{r: 29, g: 41, b: 59, a: 255},
Color{r: 70, g: 82, b: 94, a: 255},
Color{r: 240, g: 241, b: 242, a: 255},
Color{r: 138, g: 141, b: 149, a: 255},
Color{r: 211, g: 212, b: 213, a: 255},
Color{r: 130, g: 129, b: 132, a: 255},
Color{r: 73, g: 74, b: 82, a: 255},
Color{r: 94, g: 97, b: 102, a: 255},
Color{r: 28, g: 23, b: 40, a: 255},
Color{r: 72, g: 52, b: 61, a: 255},
Color{r: 149, g: 151, b: 156, a: 255},
Color{r: 85, g: 83, b: 2, a: 255},
Color{r: 111, g: 111, b: 3, a: 255},
Color{r: 224, g: 225, b: 225, a: 255},
Color{r: 52, g: 26, b: 39, a: 255},
Color{r: 57, g: 18, b: 19, a: 255},
Color{r: 97, g: 98, b: 3, a: 255},
Color{r: 23, g: 10, b: 17, a: 255},
Color{r: 137, g: 137, b: 1, a: 255},
Color{r: 56, g: 55, b: 1, a: 255},
Color{r: 194, g: 193, b: 3, a: 255},
Color{r: 160, g: 160, b: 160, a: 255},
Color{r: 173, g: 172, b: 11, a: 255},
Color{r: 151, g: 155, b: 24, a: 255},
Color{r: 195, g: 193, b: 194, a: 255},
Color{r: 41, g: 49, b: 73, a: 255},
Color{r: 202, g: 203, b: 205, a: 255},
Color{r: 137, g: 126, b: 21, a: 255},
Color{r: 123, g: 122, b: 17, a: 255},
Color{r: 71, g: 75, b: 28, a: 255},
Color{r: 66, g: 63, b: 64, a: 255},
Color{r: 30, g: 30, b: 6, a: 255},
Color{r: 166, g: 166, b: 6, a: 255},
Color{r: 64, g: 39, b: 48, a: 255},
Color{r: 46, g: 33, b: 41, a: 255},
Color{r: 56, g: 37, b: 77, a: 255},
Color{r: 50, g: 41, b: 51, a: 255},
Color{r: 111, g: 112, b: 116, a: 255},
Color{r: 110, g: 117, b: 63, a: 255},
Color{r: 72, g: 25, b: 29, a: 255},
Color{r: 98, g: 105, b: 85, a: 255},
Color{r: 71, g: 60, b: 5, a: 255},
Color{r: 185, g: 183, b: 6, a: 255},
Color{r: 31, g: 15, b: 24, a: 255},
Color{r: 150, g: 154, b: 48, a: 255},
Color{r: 45, g: 41, b: 7, a: 255},
Color{r: 84, g: 92, b: 103, a: 255},
Color{r: 124, g: 129, b: 26, a: 255},
Color{r: 35, g: 29, b: 61, a: 255},
Color{r: 57, g: 70, b: 87, a: 255},
Color{r: 116, g: 119, b: 130, a: 255},
Color{r: 51, g: 45, b: 26, a: 255},
Color{r: 69, g: 62, b: 95, a: 255},
Color{r: 86, g: 90, b: 43, a: 255},
Color{r: 125, g: 119, b: 5, a: 255},
Color{r: 95, g: 99, b: 25, a: 255},
Color{r: 135, g: 135, b: 139, a: 255},
Color{r: 54, g: 61, b: 34, a: 255},
Color{r: 66, g: 71, b: 36, a: 255},
Color{r: 144, g: 145, b: 12, a: 255},
Color{r: 87, g: 71, b: 23, a: 255},
Color{r: 163, g: 168, b: 35, a: 255},
Color{r: 206, g: 207, b: 3, a: 255},
Color{r: 186, g: 189, b: 23, a: 255},
Color{r: 97, g: 96, b: 49, a: 255},
Color{r: 29, g: 42, b: 32, a: 255},
Color{r: 136, g: 141, b: 36, a: 255},
Color{r: 96, g: 104, b: 115, a: 255},
Color{r: 110, g: 115, b: 26, a: 255},
Color{r: 113, g: 81, b: 82, a: 255},
Color{r: 88, g: 71, b: 71, a: 255},
Color{r: 83, g: 46, b: 47, a: 255},
Color{r: 87, g: 89, b: 15, a: 255},
Color{r: 172, g: 176, b: 181, a: 255},
Color{r: 91, g: 77, b: 84, a: 255},
Color{r: 231, g: 232, b: 235, a: 255},
Color{r: 255, g: 127, b: 255, a: 255},
Color{r: 4, g: 3, b: 4, a: 255},
Color{r: 4, g: 9, b: 21, a: 255},
Color{r: 1, g: 4, b: 10, a: 255},
Color{r: 1, g: 2, b: 3, a: 255},
Color{r: 141, g: 144, b: 16, a: 255},
Color{r: 1, g: 0, b: 0, a: 255},
Color{r: 25, g: 30, b: 40, a: 255},
Color{r: 14, g: 17, b: 27, a: 255},
Color{r: 152, g: 155, b: 162, a: 255},
Color{r: 0, g: 3, b: 7, a: 255},
Color{r: 27, g: 33, b: 43, a: 255},
Color{r: 4, g: 4, b: 7, a: 255},
Color{r: 5, g: 1, b: 2, a: 255},
Color{r: 3, g: 12, b: 32, a: 255},
Color{r: 0, g: 0, b: 1, a: 255},
Color{r: 17, g: 17, b: 19, a: 255},
Color{r: 69, g: 66, b: 71, a: 255},
Color{r: 0, g: 1, b: 5, a: 255},
Color{r: 6, g: 7, b: 15, a: 255},
Color{r: 1, g: 0, b: 2, a: 255},
Color{r: 3, g: 2, b: 8, a: 255},
Color{r: 0, g: 1, b: 1, a: 255},
Color{r: 20, g: 25, b: 36, a: 255},
Color{r: 24, g: 7, b: 10, a: 255},
Color{r: 7, g: 8, b: 18, a: 255},
Color{r: 32, g: 46, b: 65, a: 255},
Color{r: 17, g: 15, b: 29, a: 255},
Color{r: 10, g: 12, b: 23, a: 255},
Color{r: 6, g: 10, b: 23, a: 255},
Color{r: 23, g: 16, b: 25, a: 255},
Color{r: 0, g: 1, b: 2, a: 255},
Color{r: 1, g: 6, b: 15, a: 255},
Color{r: 3, g: 4, b: 12, a: 255},
Color{r: 1, g: 1, b: 2, a: 255},
Color{r: 66, g: 75, b: 87, a: 255},
Color{r: 161, g: 163, b: 170, a: 255},
Color{r: 20, g: 6, b: 6, a: 255},
Color{r: 1, g: 2, b: 8, a: 255},
Color{r: 2, g: 4, b: 8, a: 255},
Color{r: 6, g: 7, b: 16, a: 255},
Color{r: 2, g: 5, b: 13, a: 255},
Color{r: 1, g: 13, b: 32, a: 255},
Color{r: 17, g: 22, b: 35, a: 255},
Color{r: 0, g: 0, b: 4, a: 255},
Color{r: 39, g: 24, b: 37, a: 255},
Color{r: 24, g: 35, b: 56, a: 255},
Color{r: 5, g: 4, b: 11, a: 255},
Color{r: 5, g: 6, b: 15, a: 255},
Color{r: 5, g: 10, b: 27, a: 255},
Color{r: 2, g: 5, b: 10, a: 255},
Color{r: 37, g: 50, b: 69, a: 255},
Color{r: 1, g: 4, b: 14, a: 255},
Color{r: 1, g: 1, b: 1, a: 255},
Color{r: 16, g: 24, b: 48, a: 255},
Color{r: 2, g: 1, b: 4, a: 255},
Color{r: 14, g: 19, b: 40, a: 255},
Color{r: 0, g: 5, b: 12, a: 255},
Color{r: 0, g: 1, b: 4, a: 255},
Color{r: 7, g: 3, b: 3, a: 255},
Color{r: 41, g: 55, b: 71, a: 255},
Color{r: 2, g: 0, b: 0, a: 255},
Color{r: 35, g: 11, b: 11, a: 255},
Color{r: 11, g: 14, b: 27, a: 255},
Color{r: 0, g: 1, b: 3, a: 255},
Color{r: 1, g: 13, b: 30, a: 255},
Color{r: 6, g: 18, b: 39, a: 255},
Color{r: 196, g: 196, b: 7, a: 255},
Color{r: 1, g: 1, b: 7, a: 255},
Color{r: 2, g: 11, b: 28, a: 255},
Color{r: 3, g: 1, b: 3, a: 255},
Color{r: 5, g: 17, b: 39, a: 255},
Color{r: 4, g: 6, b: 14, a: 255},
Color{r: 19, g: 17, b: 36, a: 255},
Color{r: 2, g: 7, b: 15, a: 255},
Color{r: 0, g: 3, b: 8, a: 255},
Color{r: 13, g: 10, b: 19, a: 255},
Color{r: 143, g: 149, b: 157, a: 255},
Color{r: 10, g: 4, b: 5, a: 255},
Color{r: 8, g: 6, b: 14, a: 255},
Color{r: 32, g: 21, b: 35, a: 255},
Color{r: 17, g: 7, b: 13, a: 255},
Color{r: 45, g: 56, b: 79, a: 255},
Color{r: 3, g: 10, b: 25, a: 255},
Color{r: 2, g: 3, b: 6, a: 255},
Color{r: 34, g: 42, b: 68, a: 255},
Color{r: 2, g: 15, b: 34, a: 255},
Color{r: 10, g: 21, b: 43, a: 255},
Color{r: 0, g: 2, b: 5, a: 255},
Color{r: 15, g: 17, b: 27, a: 255},
Color{r: 7, g: 3, b: 6, a: 255},
Color{r: 2, g: 10, b: 23, a: 255},
Color{r: 22, g: 19, b: 32, a: 255},
Color{r: 58, g: 59, b: 7, a: 255},
Color{r: 8, g: 3, b: 9, a: 255},
Color{r: 6, g: 3, b: 8, a: 255},
Color{r: 4, g: 14, b: 30, a: 255},
Color{r: 2, g: 2, b: 4, a: 255},
Color{r: 0, g: 3, b: 9, a: 255},
Color{r: 51, g: 64, b: 82, a: 255},
Color{r: 2, g: 3, b: 10, a: 255},
Color{r: 4, g: 12, b: 29, a: 255},
Color{r: 18, g: 22, b: 31, a: 255},
Color{r: 2, g: 4, b: 13, a: 255},
Color{r: 192, g: 192, b: 193, a: 255},
Color{r: 3, g: 0, b: 0, a: 255},
Color{r: 5, g: 6, b: 14, a: 255},
Color{r: 2, g: 2, b: 9, a: 255},
Color{r: 51, g: 63, b: 74, a: 255},
Color{r: 13, g: 16, b: 33, a: 255},
Color{r: 5, g: 8, b: 19, a: 255},
Color{r: 23, g: 27, b: 38, a: 255},
Color{r: 23, g: 28, b: 54, a: 255},
Color{r: 1, g: 4, b: 11, a: 255},
Color{r: 33, g: 40, b: 49, a: 255},
Color{r: 48, g: 59, b: 71, a: 255},
Color{r: 64, g: 26, b: 36, a: 255},
Color{r: 116, g: 121, b: 19, a: 255},
Color{r: 13, g: 16, b: 26, a: 255},
Color{r: 3, g: 6, b: 11, a: 255},
Color{r: 5, g: 2, b: 2, a: 255},
Color{r: 7, g: 9, b: 18, a: 255},
Color{r: 11, g: 7, b: 16, a: 255},
Color{r: 0, g: 2, b: 6, a: 255},
Color{r: 3, g: 3, b: 3, a: 255},
Color{r: 2, g: 6, b: 16, a: 255},
Color{r: 13, g: 12, b: 13, a: 255},
Color{r: 6, g: 8, b: 18, a: 255},
Color{r: 1, g: 11, b: 25, a: 255},
Color{r: 18, g: 13, b: 24, a: 255},
Color{r: 1, g: 0, b: 1, a: 255},
Color{r: 0, g: 0, b: 3, a: 255},
Color{r: 20, g: 27, b: 41, a: 255},
Color{r: 7, g: 15, b: 35, a: 255},
Color{r: 129, g: 135, b: 145, a: 255},
Color{r: 1, g: 11, b: 26, a: 255},
Color{r: 9, g: 10, b: 20, a: 255},
Color{r: 1, g: 2, b: 4, a: 255},
Color{r: 5, g: 5, b: 15, a: 255},
Color{r: 8, g: 9, b: 9, a: 255},
Color{r: 16, g: 6, b: 10, a: 255},
Color{r: 7, g: 6, b: 17, a: 255},
Color{r: 33, g: 41, b: 28, a: 255},
Color{r: 15, g: 19, b: 31, a: 255},
Color{r: 2, g: 1, b: 1, a: 255},
Color{r: 13, g: 13, b: 24, a: 255},
Color{r: 59, g: 70, b: 81, a: 255},
Color{r: 33, g: 33, b: 39, a: 255},
Color{r: 1, g: 8, b: 18, a: 255},
Color{r: 8, g: 10, b: 20, a: 255},
Color{r: 3, g: 5, b: 16, a: 255},
Color{r: 114, g: 116, b: 10, a: 255},
Color{r: 23, g: 32, b: 47, a: 255},
Color{r: 147, g: 145, b: 150, a: 255},
Color{r: 2, g: 8, b: 20, a: 255},
Color{r: 1, g: 5, b: 11, a: 255},
Color{r: 42, g: 52, b: 63, a: 255},
Color{r: 13, g: 6, b: 11, a: 255},
Color{r: 79, g: 83, b: 93, a: 255},
Color{r: 195, g: 195, b: 198, a: 255},
Color{r: 66, g: 21, b: 24, a: 255},
Color{r: 7, g: 13, b: 29, a: 255},
Color{r: 11, g: 14, b: 23, a: 255},
Color{r: 12, g: 5, b: 8, a: 255},
Color{r: 39, g: 47, b: 58, a: 255},
Color{r: 1, g: 9, b: 22, a: 255},
Color{r: 7, g: 6, b: 10, a: 255},
Color{r: 0, g: 0, b: 0, a: 255}
]

13
tests/clut.rs Normal file
View File

@ -0,0 +1,13 @@
use maraiah::durandal::image::Color;
use maraiah::marathon::pict::get_clut;
#[test]
fn get_clut_must_process_this()
{
assert_eq!(get_clut(INPUT).unwrap(), (OUTPUT.to_vec(), 2056));
}
const INPUT: &'static [u8] = include_bytes!("clut.in");
const OUTPUT: [Color; 256] = include!("clut.out");
// EOF