mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-21 15:18:12 +08:00
Add MemoizeImpure node and cache image base64 in graph (#1595)
* Cache base64 representation of images when converting to graphic group * Fix build * Fix build again * Actually fix it this time --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
8fa46ba63a
commit
349ec5da72
@@ -159,7 +159,19 @@ async fn construct_artboard<Fut: Future<Output = GraphicGroup>>(
|
||||
}
|
||||
|
||||
impl From<ImageFrame<Color>> for GraphicElement {
|
||||
fn from(image_frame: ImageFrame<Color>) -> Self {
|
||||
fn from(mut image_frame: ImageFrame<Color>) -> Self {
|
||||
use base64::Engine;
|
||||
|
||||
let image = &image_frame.image;
|
||||
if !image.data.is_empty() {
|
||||
let output = image.to_png();
|
||||
let preamble = "data:image/png;base64,";
|
||||
let mut base64_string = String::with_capacity(preamble.len() + output.len() * 4);
|
||||
base64_string.push_str(preamble);
|
||||
base64::engine::general_purpose::STANDARD.encode_string(output, &mut base64_string);
|
||||
image_frame.image.base64_string = Some(base64_string);
|
||||
}
|
||||
|
||||
GraphicElement::ImageFrame(image_frame)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user