gb-image-decoder 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/index.cjs +10 -8
- package/dist/index.mjs +10 -8
- package/package.json +2 -2
package/LICENSE
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -572,14 +572,6 @@ class RGBNDecoder {
|
|
|
572
572
|
}
|
|
573
573
|
getScaledCanvas(scaleFactor, handleExportFrame = ExportFrameMode.FRAMEMODE_KEEP) {
|
|
574
574
|
const canvas = document.createElement("canvas");
|
|
575
|
-
const handleFrameMode = this.maxTiles() === 360 ? handleExportFrame : ExportFrameMode.FRAMEMODE_KEEP;
|
|
576
|
-
const { initialHeight, initialWidth } = Decoder.getScaledCanvasSize(handleFrameMode, this.getHeight());
|
|
577
|
-
canvas.width = initialWidth * scaleFactor;
|
|
578
|
-
canvas.height = initialHeight * scaleFactor;
|
|
579
|
-
const context = canvas.getContext("2d");
|
|
580
|
-
if (!context) {
|
|
581
|
-
throw new Error("no canvas context");
|
|
582
|
-
}
|
|
583
575
|
const canvases = channels.reduce((acc, key) => {
|
|
584
576
|
const channel = this.channels[key];
|
|
585
577
|
const channelCanvas = channel.decoder.getScaledCanvas(scaleFactor, handleExportFrame);
|
|
@@ -588,6 +580,16 @@ class RGBNDecoder {
|
|
|
588
580
|
[key]: channelCanvas
|
|
589
581
|
};
|
|
590
582
|
}, {});
|
|
583
|
+
const { width, height } = Object.values(canvases).reduce((acc, current) => ({
|
|
584
|
+
width: Math.max(current.width, acc.width),
|
|
585
|
+
height: Math.max(current.width, acc.height)
|
|
586
|
+
}), { width: 0, height: 0 });
|
|
587
|
+
canvas.width = width;
|
|
588
|
+
canvas.height = height;
|
|
589
|
+
const context = canvas.getContext("2d");
|
|
590
|
+
if (!context) {
|
|
591
|
+
throw new Error("no canvas context");
|
|
592
|
+
}
|
|
591
593
|
this.blendCanvases(context, canvases);
|
|
592
594
|
return canvas;
|
|
593
595
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -570,14 +570,6 @@ class RGBNDecoder {
|
|
|
570
570
|
}
|
|
571
571
|
getScaledCanvas(scaleFactor, handleExportFrame = ExportFrameMode.FRAMEMODE_KEEP) {
|
|
572
572
|
const canvas = document.createElement("canvas");
|
|
573
|
-
const handleFrameMode = this.maxTiles() === 360 ? handleExportFrame : ExportFrameMode.FRAMEMODE_KEEP;
|
|
574
|
-
const { initialHeight, initialWidth } = Decoder.getScaledCanvasSize(handleFrameMode, this.getHeight());
|
|
575
|
-
canvas.width = initialWidth * scaleFactor;
|
|
576
|
-
canvas.height = initialHeight * scaleFactor;
|
|
577
|
-
const context = canvas.getContext("2d");
|
|
578
|
-
if (!context) {
|
|
579
|
-
throw new Error("no canvas context");
|
|
580
|
-
}
|
|
581
573
|
const canvases = channels.reduce((acc, key) => {
|
|
582
574
|
const channel = this.channels[key];
|
|
583
575
|
const channelCanvas = channel.decoder.getScaledCanvas(scaleFactor, handleExportFrame);
|
|
@@ -586,6 +578,16 @@ class RGBNDecoder {
|
|
|
586
578
|
[key]: channelCanvas
|
|
587
579
|
};
|
|
588
580
|
}, {});
|
|
581
|
+
const { width, height } = Object.values(canvases).reduce((acc, current) => ({
|
|
582
|
+
width: Math.max(current.width, acc.width),
|
|
583
|
+
height: Math.max(current.width, acc.height)
|
|
584
|
+
}), { width: 0, height: 0 });
|
|
585
|
+
canvas.width = width;
|
|
586
|
+
canvas.height = height;
|
|
587
|
+
const context = canvas.getContext("2d");
|
|
588
|
+
if (!context) {
|
|
589
|
+
throw new Error("no canvas context");
|
|
590
|
+
}
|
|
589
591
|
this.blendCanvases(context, canvases);
|
|
590
592
|
return canvas;
|
|
591
593
|
}
|
package/package.json
CHANGED