gb-image-decoder 0.1.6 → 0.1.8
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/dist/index.cjs +21 -13
- package/dist/index.d.cts +2 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +21 -14
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -384,19 +384,26 @@ class Decoder {
|
|
|
384
384
|
for (let x = 0; x < TILE_PIXEL_WIDTH; x += 1) {
|
|
385
385
|
for (let y = 0; y < TILE_PIXEL_HEIGHT; y += 1) {
|
|
386
386
|
const rawIndex = (pixelXOffset + x + (pixelYOffset + y) * this.tilesPerLine * TILE_PIXEL_WIDTH) * 4;
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
387
|
+
if (pixels !== null) {
|
|
388
|
+
const color = getRGBValue({
|
|
389
|
+
pixels,
|
|
390
|
+
index: y * TILE_PIXEL_WIDTH + x,
|
|
391
|
+
tileIndex: index,
|
|
392
|
+
handleExportFrame: ExportFrameMode.FRAMEMODE_KEEP,
|
|
393
|
+
invertPalette: this.invertPalette,
|
|
394
|
+
lockFrame: this.lockFrame,
|
|
395
|
+
colorData: this.colorData
|
|
396
|
+
});
|
|
397
|
+
this.rawImageData[rawIndex] = color.r;
|
|
398
|
+
this.rawImageData[rawIndex + 1] = color.g;
|
|
399
|
+
this.rawImageData[rawIndex + 2] = color.b;
|
|
400
|
+
this.rawImageData[rawIndex + 3] = 255;
|
|
401
|
+
} else {
|
|
402
|
+
this.rawImageData[rawIndex] = 0;
|
|
403
|
+
this.rawImageData[rawIndex + 1] = 0;
|
|
404
|
+
this.rawImageData[rawIndex + 2] = 0;
|
|
405
|
+
this.rawImageData[rawIndex + 3] = 0;
|
|
406
|
+
}
|
|
400
407
|
}
|
|
401
408
|
}
|
|
402
409
|
}
|
|
@@ -619,6 +626,7 @@ exports.BlendMode = BlendMode;
|
|
|
619
626
|
exports.Decoder = Decoder;
|
|
620
627
|
exports.ExportFrameMode = ExportFrameMode;
|
|
621
628
|
exports.RGBNDecoder = RGBNDecoder;
|
|
629
|
+
exports.SKIP_LINE = SKIP_LINE;
|
|
622
630
|
exports.blendModeNewName = blendModeNewName;
|
|
623
631
|
exports.decodeTile = decodeTile;
|
|
624
632
|
exports.getRGBValue = getRGBValue;
|
package/dist/index.d.cts
CHANGED
|
@@ -135,6 +135,7 @@ declare const tileIndexIsPartOfFrame: (tileIndex: number, handleExportFrame?: Ex
|
|
|
135
135
|
|
|
136
136
|
declare const maxTiles: (rgbnTiles: RGBNTiles) => number;
|
|
137
137
|
|
|
138
|
+
declare const SKIP_LINE = "skip";
|
|
138
139
|
declare const BW_PALETTE: number[];
|
|
139
140
|
|
|
140
|
-
export { type BWPalette, BW_PALETTE, BlendMode, type ChangedTile, type Channel, type Channels, Decoder, ExportFrameMode, type IndexedTilePixels, RGBNDecoder, type RGBNPalette, type RGBNTiles, type RGBValue, type ScaledCanvasSize, type SourceCanvases, blendModeNewName, decodeTile, getRGBValue, maxTiles, tileIndexIsPartOfFrame };
|
|
141
|
+
export { type BWPalette, BW_PALETTE, BlendMode, type ChangedTile, type Channel, type Channels, Decoder, ExportFrameMode, type IndexedTilePixels, RGBNDecoder, type RGBNPalette, type RGBNTiles, type RGBValue, SKIP_LINE, type ScaledCanvasSize, type SourceCanvases, blendModeNewName, decodeTile, getRGBValue, maxTiles, tileIndexIsPartOfFrame };
|
package/dist/index.d.mts
CHANGED
|
@@ -135,6 +135,7 @@ declare const tileIndexIsPartOfFrame: (tileIndex: number, handleExportFrame?: Ex
|
|
|
135
135
|
|
|
136
136
|
declare const maxTiles: (rgbnTiles: RGBNTiles) => number;
|
|
137
137
|
|
|
138
|
+
declare const SKIP_LINE = "skip";
|
|
138
139
|
declare const BW_PALETTE: number[];
|
|
139
140
|
|
|
140
|
-
export { type BWPalette, BW_PALETTE, BlendMode, type ChangedTile, type Channel, type Channels, Decoder, ExportFrameMode, type IndexedTilePixels, RGBNDecoder, type RGBNPalette, type RGBNTiles, type RGBValue, type ScaledCanvasSize, type SourceCanvases, blendModeNewName, decodeTile, getRGBValue, maxTiles, tileIndexIsPartOfFrame };
|
|
141
|
+
export { type BWPalette, BW_PALETTE, BlendMode, type ChangedTile, type Channel, type Channels, Decoder, ExportFrameMode, type IndexedTilePixels, RGBNDecoder, type RGBNPalette, type RGBNTiles, type RGBValue, SKIP_LINE, type ScaledCanvasSize, type SourceCanvases, blendModeNewName, decodeTile, getRGBValue, maxTiles, tileIndexIsPartOfFrame };
|
package/dist/index.d.ts
CHANGED
|
@@ -135,6 +135,7 @@ declare const tileIndexIsPartOfFrame: (tileIndex: number, handleExportFrame?: Ex
|
|
|
135
135
|
|
|
136
136
|
declare const maxTiles: (rgbnTiles: RGBNTiles) => number;
|
|
137
137
|
|
|
138
|
+
declare const SKIP_LINE = "skip";
|
|
138
139
|
declare const BW_PALETTE: number[];
|
|
139
140
|
|
|
140
|
-
export { type BWPalette, BW_PALETTE, BlendMode, type ChangedTile, type Channel, type Channels, Decoder, ExportFrameMode, type IndexedTilePixels, RGBNDecoder, type RGBNPalette, type RGBNTiles, type RGBValue, type ScaledCanvasSize, type SourceCanvases, blendModeNewName, decodeTile, getRGBValue, maxTiles, tileIndexIsPartOfFrame };
|
|
141
|
+
export { type BWPalette, BW_PALETTE, BlendMode, type ChangedTile, type Channel, type Channels, Decoder, ExportFrameMode, type IndexedTilePixels, RGBNDecoder, type RGBNPalette, type RGBNTiles, type RGBValue, SKIP_LINE, type ScaledCanvasSize, type SourceCanvases, blendModeNewName, decodeTile, getRGBValue, maxTiles, tileIndexIsPartOfFrame };
|
package/dist/index.mjs
CHANGED
|
@@ -382,19 +382,26 @@ class Decoder {
|
|
|
382
382
|
for (let x = 0; x < TILE_PIXEL_WIDTH; x += 1) {
|
|
383
383
|
for (let y = 0; y < TILE_PIXEL_HEIGHT; y += 1) {
|
|
384
384
|
const rawIndex = (pixelXOffset + x + (pixelYOffset + y) * this.tilesPerLine * TILE_PIXEL_WIDTH) * 4;
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
385
|
+
if (pixels !== null) {
|
|
386
|
+
const color = getRGBValue({
|
|
387
|
+
pixels,
|
|
388
|
+
index: y * TILE_PIXEL_WIDTH + x,
|
|
389
|
+
tileIndex: index,
|
|
390
|
+
handleExportFrame: ExportFrameMode.FRAMEMODE_KEEP,
|
|
391
|
+
invertPalette: this.invertPalette,
|
|
392
|
+
lockFrame: this.lockFrame,
|
|
393
|
+
colorData: this.colorData
|
|
394
|
+
});
|
|
395
|
+
this.rawImageData[rawIndex] = color.r;
|
|
396
|
+
this.rawImageData[rawIndex + 1] = color.g;
|
|
397
|
+
this.rawImageData[rawIndex + 2] = color.b;
|
|
398
|
+
this.rawImageData[rawIndex + 3] = 255;
|
|
399
|
+
} else {
|
|
400
|
+
this.rawImageData[rawIndex] = 0;
|
|
401
|
+
this.rawImageData[rawIndex + 1] = 0;
|
|
402
|
+
this.rawImageData[rawIndex + 2] = 0;
|
|
403
|
+
this.rawImageData[rawIndex + 3] = 0;
|
|
404
|
+
}
|
|
398
405
|
}
|
|
399
406
|
}
|
|
400
407
|
}
|
|
@@ -612,4 +619,4 @@ class RGBNDecoder {
|
|
|
612
619
|
|
|
613
620
|
const maxTiles = (rgbnTiles) => Math.max(...channels.map((key) => rgbnTiles[key]?.length || 0));
|
|
614
621
|
|
|
615
|
-
export { BW_PALETTE, BlendMode, Decoder, ExportFrameMode, RGBNDecoder, blendModeNewName, decodeTile, getRGBValue, maxTiles, tileIndexIsPartOfFrame };
|
|
622
|
+
export { BW_PALETTE, BlendMode, Decoder, ExportFrameMode, RGBNDecoder, SKIP_LINE, blendModeNewName, decodeTile, getRGBValue, maxTiles, tileIndexIsPartOfFrame };
|