瀏覽代碼

fix: preview size when maxWidthOrHeight is hit

Arnošt Pleskot 2 年之前
父節點
當前提交
a76aa5f7a1
共有 2 個文件被更改,包括 15 次插入5 次删除
  1. 1 5
      src/components/ImageExportDialog.tsx
  2. 14 0
      src/packages/utils.ts

+ 1 - 5
src/components/ImageExportDialog.tsx

@@ -186,11 +186,7 @@ const ImageExportModal = ({
       appState,
       files,
       exportPadding: DEFAULT_EXPORT_PADDING,
-      maxWidthOrHeight: !(
-        exportBackgroundImage !== "solid" && exportWithBackground
-      )
-        ? maxWidthOrHeight
-        : undefined,
+      maxWidthOrHeight,
     })
       .then((canvas) => {
         setRenderError(null);

+ 14 - 0
src/packages/utils.ts

@@ -70,6 +70,20 @@ export const exportToCanvas = ({
     (width: number, height: number) => {
       const canvas = document.createElement("canvas");
 
+      if (
+        appState?.exportBackground &&
+        appState?.fancyBackgroundImageKey !== "solid"
+      ) {
+        const scale = appState?.exportScale ?? 1;
+        canvas.width = width * scale;
+        canvas.height = height * scale;
+
+        return {
+          canvas,
+          scale,
+        };
+      }
+
       if (maxWidthOrHeight) {
         if (typeof getDimensions === "function") {
           console.warn(