feat: Logo 嵌入 — QR 码中央叠加自定义图片

- PNG 渲染:RgbaImage 上使用 imageops::overlay 叠加 logo
- SVG 渲染:base64 编码 logo 嵌入 <image> 标签
- QrCode::to_png_bytes / to_svg 新增 Option<logo_bytes> 参数
- Logo 默认占 QR 区域 25%,建议配合 H 级纠错使用
This commit is contained in:
2026-06-19 21:12:44 +08:00
parent 23ccb37b52
commit 38be82973e
10 changed files with 112 additions and 40 deletions
+2 -2
View File
@@ -50,7 +50,7 @@ fn encode_qr(text: String, level: String, margin: u8) -> Result<QrResponse, Stri
let qr = QrCode::encode(&text, config).map_err(|e| format!("编码失败: {}", e))?;
let svg = qr.to_svg();
let svg = qr.to_svg(None);
Ok(QrResponse {
svg,
@@ -84,7 +84,7 @@ fn export_png(text: String, level: String, margin: u8, module_size: u8) -> Resul
let qr = QrCode::encode(&text, config).map_err(|e| format!("编码失败: {}", e))?;
qr.to_png_bytes(module_size)
qr.to_png_bytes(module_size, None)
.map_err(|e| format!("PNG 导出失败: {}", e))
}