From aed8e24afcad752371187e32a278104cf2addeb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A1=97=E8=A7=92=E5=B0=8F=E6=9E=97?= <1013335014@qq.com> Date: Tue, 26 Dec 2023 12:20:12 +0800 Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E6=95=B0=E9=87=8F=E8=BF=87=E5=A4=9A=EF=BC=8C=E7=94=BB?= =?UTF-8?q?=E5=B8=83=E5=B0=BA=E5=AF=B8=E8=BF=87=E5=A4=A7=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E5=AF=BC=E5=87=BApng=E5=92=8Cpdf=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/plugins/Export.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/simple-mind-map/src/plugins/Export.js b/simple-mind-map/src/plugins/Export.js index 9d6c5d40..a48f0622 100644 --- a/simple-mind-map/src/plugins/Export.js +++ b/simple-mind-map/src/plugins/Export.js @@ -106,6 +106,21 @@ class Export { ) let imgWidth = img.width let imgHeight = img.height + // 检查是否超出canvas支持的像素上限 + const maxSize = 16384 / dpr + const maxArea = maxSize * maxSize + if (imgWidth * imgHeight > maxArea) { + let newWidth = null + let newHeight = null + if (imgWidth > maxSize) { + newWidth = maxArea / imgHeight + } else if (imgHeight > maxSize) { + newHeight = maxArea / imgWidth + } + const res = resizeImgSize(imgWidth, imgHeight, newWidth, newHeight) + imgWidth = res[0] + imgHeight = res[1] + } canvas.width = imgWidth * dpr canvas.height = imgHeight * dpr canvas.style.width = imgWidth + 'px' @@ -205,6 +220,7 @@ class Export { const { str } = await this.getSvgData() const svgUrl = await this.fixSvgStrAndToBlob(str) const res = await this.svgToPng(svgUrl, transparent) + console.log(res) return res }