feat:优化图片生产质量,减少打印耗时

This commit is contained in:
R524809
2026-03-24 10:05:57 +08:00
parent cbf07faf27
commit a34311d35e
5 changed files with 1675 additions and 3 deletions
+3
View File
@@ -149,6 +149,9 @@ export function getRandomUniqueNumberColors(count: number): string[] {
return Array.from(selectedColors);
}
/** A4 打印导出尺寸:150 DPI,兼顾清晰度与文件体积/打印速度 */
export const A4_EXPORT_SIZE_150DPI = { width: 1240, height: 1754 };
export const PAPER_SIZE = {
A4: {
// width: 2480,
+11 -3
View File
@@ -1,8 +1,16 @@
import { A4_EXPORT_SIZE_150DPI } from '../constants/colors';
/**
* 导出为固定打印分辨率(A4 150 DPI),避免高 DPR 设备导出过大图导致打印慢、文件大
*/
const doSaveImage = (canvas: Canvas) => {
const { width: destWidth, height: destHeight } = A4_EXPORT_SIZE_150DPI;
wx.canvasToTempFilePath({
canvas: canvas,
fileType: 'png',
quality: 1,
canvas,
fileType: 'jpg',
quality: 0.9,
destWidth,
destHeight,
success: (res) => {
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath,