diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..1635188 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,20 @@ +use libwebp::WebPEncodeLosslessRGBA; +use std::fs::File; +use std::io::prelude::*; +fn main() -> std::io::Result<()> { + let buf: &[u8] = &[ + 255,255,255,255, + 255,0,0,255, + 0,255,0,255, + 0,0,255,255, + 255,255,255,127, + ]; + let data = WebPEncodeLosslessRGBA(buf,5,1,8).unwrap(); + let mut file = File::create("image.webp")?; + let mut pos = 0; + while pos < data.len() { + let bytes_written = file.write(&data[pos..])?; + pos += bytes_written; + } + Ok(()) +} |