chore: rename executor -> evaluator and integrate into app
This commit is contained in:
parent
de9ca81b65
commit
3c529c3a1a
16 changed files with 229 additions and 115 deletions
44
crates/eval/src/kind/debug/instr/mod.rs
Normal file
44
crates/eval/src/kind/debug/instr/mod.rs
Normal file
|
@ -0,0 +1,44 @@
|
|||
pub mod read {
|
||||
use image::{io::Reader as ImageReader, DynamicImage};
|
||||
use ir::instruction::read::{Read, SourceType};
|
||||
|
||||
pub fn read(Read { source, .. }: Read) -> DynamicImage {
|
||||
// TODO: actual error handling
|
||||
let 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::{DynamicImage, ImageFormat};
|
||||
use ir::instruction::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,
|
||||
},
|
||||
)
|
||||
.expect("couldn't save file — come back later and handle me properly please uwu");
|
||||
}
|
||||
}
|
||||
|
||||
pub mod filters {
|
||||
pub mod invert {
|
||||
use image::DynamicImage;
|
||||
|
||||
pub fn invert(mut input_data: DynamicImage) -> DynamicImage {
|
||||
input_data.invert();
|
||||
input_data
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue