mirror of
https://forge.katzen.cafe/katzen-cafe/iowo.git
synced 2025-09-24 23:41:30 +02:00
basic conversion thing do worky!!!
This commit is contained in:
parent
f046393af8
commit
b92977d8f1
13 changed files with 680 additions and 14 deletions
30
crates/executor/src/debug/instructions/mod.rs
Normal file
30
crates/executor/src/debug/instructions/mod.rs
Normal file
|
@ -0,0 +1,30 @@
|
|||
pub mod Read {
|
||||
use image::{io::Reader as ImageReader, DynamicImage};
|
||||
use rpl::instructions::read::{Read, SourceType};
|
||||
|
||||
pub fn read(Read { source, format }: Read) -> DynamicImage {
|
||||
let mut img = ImageReader::open(match source {
|
||||
SourceType::File(path) => path,
|
||||
})
|
||||
.expect("something went wrong :(((");
|
||||
|
||||
img.decode().expect("couldn't decode image")
|
||||
}
|
||||
}
|
||||
|
||||
pub mod Write {
|
||||
use image::{io::Reader as ImageReader, DynamicImage, ImageFormat};
|
||||
use rpl::instructions::write::{TargetFormat, TargetType, Write};
|
||||
|
||||
pub fn write(Write { target, format }: Write, input_data: DynamicImage) {
|
||||
input_data.save_with_format(
|
||||
match target {
|
||||
TargetType::File(path) => path,
|
||||
},
|
||||
match format {
|
||||
TargetFormat::Jpeg => ImageFormat::Jpeg,
|
||||
TargetFormat::Png => ImageFormat::Png,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue