Embed project images in route-D previews and PDFs

This commit is contained in:
GloamXun committed 2026-10-24 23:29:15 +08:00
1 parent ae69eba64d
commit 0f8aff7290
8 files changed
+407 -18

No files matched your search

+27
View File
@@ -79,6 +79,14 @@ pub enum DisplayItem {
Special(String),
}
/// A raster image carried by a vertical item, with its pixel data.
#[derive(Clone, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
pub struct RasterImage {
pub width: u32,
pub height: u32,
pub rgb: Vec<u8>,
}
/// A raw RGB image that can be painted as a PDF XObject.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct PdfImage {
@@ -471,6 +479,25 @@ impl Page {
VerticalItem::Box(box_) => {
y += box_.height;
}
VerticalItem::Image {
width,
height,
image,
} => {
let index = list.add_image(PdfImage {
width: (*width).max(0) as u32,
height: (*height).max(0) as u32,
rgb: image.rgb.clone(),
});
list.push(DisplayItem::Image {
x: 0,
y,
width: *width,
height: *height,
index,
});
y += *height;
}
VerticalItem::Rule { width, height } => {
list.push(DisplayItem::Rule {
x: 0,