Embed raster images in the SVG preview
The SVG preview painted every DisplayItem::Image as a grey rectangle. Encode the raw RGB image as a PNG (zlib via flate2, CRC32, base64) and emit an SVG <image> data URI; keep the grey fallback for images above four megapixels. The article preview now contains the real 480x240 plot and the framed rule figure is visible while editing. Test count stays 1074.
This commit is contained in:
1 parent
fc328a56c6
commit
2ef5e29329
4 files changed
+107
-11
No files matched your search
+3
-3
@@ -2322,7 +2322,7 @@ fn project_preview_and_pdf_embed_images() {
|
||||
);
|
||||
assert_eq!(preview.status, 200, "{}", preview.text());
|
||||
let svg = preview.text();
|
||||
assert!(svg.contains(r##"fill=\"#cccccc\""##), "preview: {svg}");
|
||||
assert!(svg.contains("data:image/png;base64"), "preview: {svg}");
|
||||
assert!(svg.contains(">P</text>"), "preview: {svg}");
|
||||
|
||||
let pdf = server.request(
|
||||
@@ -2416,7 +2416,7 @@ fn project_images_degrade_to_placeholders() {
|
||||
);
|
||||
assert_eq!(preview.status, 200, "{}", preview.text());
|
||||
assert!(
|
||||
preview.text().contains(r##"fill=\"#cccccc\""##),
|
||||
preview.text().contains("data:image/png;base64"),
|
||||
"{}",
|
||||
preview.text()
|
||||
);
|
||||
@@ -2450,7 +2450,7 @@ fn project_images_resolve_through_graphicspath() {
|
||||
);
|
||||
assert_eq!(preview.status, 200, "{}", preview.text());
|
||||
let svg = preview.text();
|
||||
assert!(svg.contains(r##"fill=\"#cccccc\""##), "preview: {svg}");
|
||||
assert!(svg.contains("data:image/png;base64"), "preview: {svg}");
|
||||
assert!(svg.contains(">P</text>"), "preview: {svg}");
|
||||
assert!(!svg.contains("graphicspath"), "preview: {svg}");
|
||||
|
||||
|
||||
Reference in new issue
Block a user