Crates.io | sixel-image |
lib.rs | sixel-image |
version | 0.1.0 |
source | src |
created_at | 2022-07-07 08:23:18.760795 |
updated_at | 2022-07-07 08:23:18.760795 |
description | An interface for querying, manipulating and serializing/deserializing Sixel data |
homepage | |
repository | https://github.com/zellij-org/sixel-image |
max_upload_size | |
id | 621049 |
size | 31,859 |
This library provides an interface for querying, manipulating and serializing/deserializing sixel data.
There are several methods provided here to do this:
SixelImage
directlySixelDeserializer
(accompanied by the sixel-tokenizer
sister crate).use sixel_image::SixelImage;
fn main() {
let sample = "
\u{1b}Pq
\"2;1;100;200
#0;2;0;0;0#1;2;100;100;0#2;2;0;100;0
#1~~@@vv@@~~@@~~$
#2??}}GG}}??}}??-
#1!14@
\u{1b}\\
";
let bytes = sample.as_bytes();
let sixel_image = SixelImage::new(&bytes).unwrap();
let serialized = sixel_image.serialize();
println!("{:?}", serialized);
}
use sixel_tokenizer::Parser;
use sixel_image::SixelDeserializer;
fn main() {
let sample = "
\u{1b}Pq
\"2;1;100;200
#0;2;0;0;0#1;2;100;100;0#2;2;0;100;0
#1~~@@vv@@~~@@~~$
#2??}}GG}}??}}??-
#1!14@
\u{1b}\\
";
let bytes = sample.as_bytes();
let mut parser = Parser::new();
let mut sixel_deserializer = SixelDeserializer::new();
for byte in bytes {
parser.advance(&byte, |sixel_event| {
let _ = sixel_deserializer.handle_event(sixel_event);
});
}
let sixel_image = sixel_deserializer.create_image().unwrap();
let serialized = sixel_image.serialize();
println!("{:?}", serialized);
}
MIT