From f52e9f2618280c15e7c8fa6a54e9d75f58fcf571 Mon Sep 17 00:00:00 2001 From: Zhukj <3262118957> Date: Mon, 20 Apr 2026 17:14:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=94=BB=E5=B8=83=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E8=A7=84=E6=A0=BC=E6=94=B9=E4=B8=BA1080=C3=971920=E9=AB=98?= =?UTF-8?q?=E6=B8=85PNG=EF=BC=8C=E6=8F=90=E5=8D=87=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=E5=88=86=E8=BE=A8=E7=8E=87=EF=BC=8C=E8=A7=A3=E5=86=B3=E5=9B=BE?= =?UTF-8?q?=E6=96=87=E6=A8=A1=E7=B3=8A=E9=94=AF=E9=BD=BF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/script.js | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/js/script.js b/js/script.js index 2f284e6..b03d5ff 100644 --- a/js/script.js +++ b/js/script.js @@ -1952,39 +1952,38 @@ } } - // 生成画布(所见即所得 - 使用显示尺寸) + // 生成画布(固定分辨率 1080×1920 高清无损) async function generateCanvas() { const canvas = exportCanvas; const ctx = canvas.getContext('2d'); const container = imageContainer; - // 高清渲染倍数 - const scaleFactor = 2; + // 固定高清分辨率 1080×1920 + const TARGET_WIDTH = 1080; + const TARGET_HEIGHT = 1920; - // 显示尺寸 + // 显示尺寸(用于计算缩放比例) const displayWidth = container.clientWidth; const displayHeight = container.clientHeight; - // 高清画布尺寸(2倍) - const width = displayWidth * scaleFactor; - const height = displayHeight * scaleFactor; + // 设置画布为固定高清分辨率 + canvas.width = TARGET_WIDTH; + canvas.height = TARGET_HEIGHT; - canvas.width = width; - canvas.height = height; - - // 启用高清渲染 + // 启用最高质量渲染 ctx.imageSmoothingEnabled = true; ctx.imageSmoothingQuality = 'high'; + // 白色背景 ctx.fillStyle = '#fff'; - ctx.fillRect(0, 0, width, height); + ctx.fillRect(0, 0, TARGET_WIDTH, TARGET_HEIGHT); - // 计算缩放比例 - const scaleX = width / displayWidth; - const scaleY = height / displayHeight; + // 计算从显示尺寸到目标分辨率的缩放比例 + const scaleX = TARGET_WIDTH / displayWidth; + const scaleY = TARGET_HEIGHT / displayHeight; if (currentImage) { - drawBgImageOnCanvasHD(ctx, currentImage, width, height, scaleX, scaleY); + drawBgImageOnCanvasHD(ctx, currentImage, TARGET_WIDTH, TARGET_HEIGHT, scaleX, scaleY); } await drawOverlayImagesHD(ctx, scaleX, scaleY);