-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmap8.rs
30 lines (26 loc) · 1008 Bytes
/
map8.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
mod _shared;
use icy_sixel::{
sixel_string, DiffusionMethod, MethodForLargest, MethodForRep, PixelFormat, Quality,
};
fn main() {
// Load and decode the PNG file
let (img_rgb888, width, height) = _shared::load_png_as_rgb888("examples/map8.png");
// Encode as SIXEL data
let sixel_data = sixel_string(
&img_rgb888,
width as i32,
height as i32,
PixelFormat::RGB888,
DiffusionMethod::None,
MethodForLargest::Auto,
MethodForRep::Auto,
Quality::AUTO,
)
.expect("Failed to encode image to SIXEL format");
// Save to file and output to terminal
_shared::save_sixel_to_file(&sixel_data, "examples/map8.six");
print!("Sixel data output (if your terminal supports it):\n{sixel_data}");
// Compare with reference SIXEL data
let reference_sixel = _shared::load_reference_sixel("examples/map8_libsixel.six");
print!("Compared with the same map8 image converted using libsixel:\n{reference_sixel}");
}