避免标记图编码重复复制像素缓冲

复用同一个 DynamicImage 完成文件保存和返回数据编码。

保持标记图内容和错误处理不变。
This commit is contained in:
2026-09-10 19:02:09 +08:00
parent ae2f5fc80b
commit f200cb4d3c
@@ -94,11 +94,12 @@ fn build_marked_image_blocking(
height,
);
}
image::DynamicImage::ImageRgba8(image.clone())
let image = image::DynamicImage::ImageRgba8(image);
image
.save_with_format(target, image::ImageFormat::Png)
.map_err(|e| format!("写入标记图失败:{e}"))?;
let mut png = Vec::new();
image::DynamicImage::ImageRgba8(image)
image
.write_to(&mut std::io::Cursor::new(&mut png), image::ImageFormat::Png)
.map_err(|e| format!("编码标记图失败:{e}"))?;
Ok(format!(