mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-19 02:48:12 +08:00
Instance tables refactor part 1: wrap graphical data in the new Instances<T> struct (#2230)
* Port VectorData to Instances<VectorData> * Port ImageFrame<P> and TextureFrame to Instances<ImageFrame<P>> and Instances<TextureFrame> * Avoid mutation with the TransformMut trait * Port GraphicGroup to Instances<GraphicGroup> * It compiles! * Organize debugging * Document upgrading * Fix Brush node * Restore TransformMut in lieu of TransformSet trait * Fix tests * Final code review
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use graph_craft::proto::types::Percentage;
|
||||
use graphene_core::raster::{Image, ImageFrame};
|
||||
use graphene_core::raster::image::{ImageFrame, ImageFrameTable};
|
||||
use graphene_core::raster::Image;
|
||||
use graphene_core::transform::Footprint;
|
||||
use graphene_core::Color;
|
||||
|
||||
@@ -15,18 +16,19 @@ async fn dehaze<F: 'n + Send + Sync>(
|
||||
)]
|
||||
footprint: F,
|
||||
#[implementations(
|
||||
() -> ImageFrame<Color>,
|
||||
Footprint -> ImageFrame<Color>,
|
||||
() -> ImageFrameTable<Color>,
|
||||
Footprint -> ImageFrameTable<Color>,
|
||||
)]
|
||||
image_frame: impl Node<F, Output = ImageFrame<Color>>,
|
||||
image_frame: impl Node<F, Output = ImageFrameTable<Color>>,
|
||||
strength: Percentage,
|
||||
) -> ImageFrame<Color> {
|
||||
) -> ImageFrameTable<Color> {
|
||||
let image_frame = image_frame.eval(footprint).await;
|
||||
let image_frame = image_frame.one_item();
|
||||
|
||||
// Prepare the image data for processing
|
||||
let image = image_frame.image;
|
||||
let image_data = bytemuck::cast_vec(image.data);
|
||||
let image_buffer = image::Rgba32FImage::from_raw(image.width, image.height, image_data).expect("Failed to convert internal ImageFrame into image-rs data type.");
|
||||
let image = &image_frame.image;
|
||||
let image_data = bytemuck::cast_vec(image.data.clone());
|
||||
let image_buffer = image::Rgba32FImage::from_raw(image.width, image.height, image_data).expect("Failed to convert internal image format into image-rs data type.");
|
||||
let dynamic_image: image::DynamicImage = image_buffer.into();
|
||||
|
||||
// Run the dehaze algorithm
|
||||
@@ -42,11 +44,13 @@ async fn dehaze<F: 'n + Send + Sync>(
|
||||
base64_string: None,
|
||||
};
|
||||
|
||||
ImageFrame {
|
||||
let result = ImageFrame {
|
||||
image: dehazed_image,
|
||||
transform: image_frame.transform,
|
||||
alpha_blending: image_frame.alpha_blending,
|
||||
}
|
||||
};
|
||||
|
||||
ImageFrameTable::new(result)
|
||||
}
|
||||
|
||||
// There is no real point in modifying these values because they do not change the final result all that much.
|
||||
|
||||
Reference in New Issue
Block a user