gb-image-decoder 0.1.7 → 0.1.9

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 CHANGED
@@ -367,10 +367,11 @@ class Decoder {
367
367
  }
368
368
  renderTile(tileIndex, rawLine) {
369
369
  if (rawLine === SKIP_LINE) {
370
- return;
370
+ this.paintTile(null, tileIndex);
371
+ } else {
372
+ const tile = decodeTile(rawLine);
373
+ this.paintTile(tile, tileIndex);
371
374
  }
372
- const tile = decodeTile(rawLine);
373
- this.paintTile(tile, tileIndex);
374
375
  }
375
376
  // This paints the tile with a specified offset and pixel width
376
377
  paintTile(pixels, index) {
@@ -384,19 +385,26 @@ class Decoder {
384
385
  for (let x = 0; x < TILE_PIXEL_WIDTH; x += 1) {
385
386
  for (let y = 0; y < TILE_PIXEL_HEIGHT; y += 1) {
386
387
  const rawIndex = (pixelXOffset + x + (pixelYOffset + y) * this.tilesPerLine * TILE_PIXEL_WIDTH) * 4;
387
- const color = getRGBValue({
388
- pixels,
389
- index: y * TILE_PIXEL_WIDTH + x,
390
- tileIndex: index,
391
- handleExportFrame: ExportFrameMode.FRAMEMODE_KEEP,
392
- invertPalette: this.invertPalette,
393
- lockFrame: this.lockFrame,
394
- colorData: this.colorData
395
- });
396
- this.rawImageData[rawIndex] = color.r;
397
- this.rawImageData[rawIndex + 1] = color.g;
398
- this.rawImageData[rawIndex + 2] = color.b;
399
- this.rawImageData[rawIndex + 3] = 255;
388
+ if (pixels !== null) {
389
+ const color = getRGBValue({
390
+ pixels,
391
+ index: y * TILE_PIXEL_WIDTH + x,
392
+ tileIndex: index,
393
+ handleExportFrame: ExportFrameMode.FRAMEMODE_KEEP,
394
+ invertPalette: this.invertPalette,
395
+ lockFrame: this.lockFrame,
396
+ colorData: this.colorData
397
+ });
398
+ this.rawImageData[rawIndex] = color.r;
399
+ this.rawImageData[rawIndex + 1] = color.g;
400
+ this.rawImageData[rawIndex + 2] = color.b;
401
+ this.rawImageData[rawIndex + 3] = 255;
402
+ } else {
403
+ this.rawImageData[rawIndex] = 0;
404
+ this.rawImageData[rawIndex + 1] = 0;
405
+ this.rawImageData[rawIndex + 2] = 0;
406
+ this.rawImageData[rawIndex + 3] = 0;
407
+ }
400
408
  }
401
409
  }
402
410
  }
package/dist/index.mjs CHANGED
@@ -365,10 +365,11 @@ class Decoder {
365
365
  }
366
366
  renderTile(tileIndex, rawLine) {
367
367
  if (rawLine === SKIP_LINE) {
368
- return;
368
+ this.paintTile(null, tileIndex);
369
+ } else {
370
+ const tile = decodeTile(rawLine);
371
+ this.paintTile(tile, tileIndex);
369
372
  }
370
- const tile = decodeTile(rawLine);
371
- this.paintTile(tile, tileIndex);
372
373
  }
373
374
  // This paints the tile with a specified offset and pixel width
374
375
  paintTile(pixels, index) {
@@ -382,19 +383,26 @@ class Decoder {
382
383
  for (let x = 0; x < TILE_PIXEL_WIDTH; x += 1) {
383
384
  for (let y = 0; y < TILE_PIXEL_HEIGHT; y += 1) {
384
385
  const rawIndex = (pixelXOffset + x + (pixelYOffset + y) * this.tilesPerLine * TILE_PIXEL_WIDTH) * 4;
385
- const color = getRGBValue({
386
- pixels,
387
- index: y * TILE_PIXEL_WIDTH + x,
388
- tileIndex: index,
389
- handleExportFrame: ExportFrameMode.FRAMEMODE_KEEP,
390
- invertPalette: this.invertPalette,
391
- lockFrame: this.lockFrame,
392
- colorData: this.colorData
393
- });
394
- this.rawImageData[rawIndex] = color.r;
395
- this.rawImageData[rawIndex + 1] = color.g;
396
- this.rawImageData[rawIndex + 2] = color.b;
397
- this.rawImageData[rawIndex + 3] = 255;
386
+ if (pixels !== null) {
387
+ const color = getRGBValue({
388
+ pixels,
389
+ index: y * TILE_PIXEL_WIDTH + x,
390
+ tileIndex: index,
391
+ handleExportFrame: ExportFrameMode.FRAMEMODE_KEEP,
392
+ invertPalette: this.invertPalette,
393
+ lockFrame: this.lockFrame,
394
+ colorData: this.colorData
395
+ });
396
+ this.rawImageData[rawIndex] = color.r;
397
+ this.rawImageData[rawIndex + 1] = color.g;
398
+ this.rawImageData[rawIndex + 2] = color.b;
399
+ this.rawImageData[rawIndex + 3] = 255;
400
+ } else {
401
+ this.rawImageData[rawIndex] = 0;
402
+ this.rawImageData[rawIndex + 1] = 0;
403
+ this.rawImageData[rawIndex + 2] = 0;
404
+ this.rawImageData[rawIndex + 3] = 0;
405
+ }
398
406
  }
399
407
  }
400
408
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gb-image-decoder",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Decoder classes for GameBoy-encoded images",
5
5
  "repository": "",
6
6
  "license": "MIT",