Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/deck.gl-geotiff/src/geotiff/render-pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
CreateTexture,
cieLabToRGB,
FilterNoDataVal,
YCbCrToRGB,
} from "@developmentseed/deck.gl-raster/gpu-modules";
import type { GeoTIFF, Overview } from "@developmentseed/geotiff";
import type { Device, SamplerProps, Texture } from "@luma.gl/core";
Expand Down Expand Up @@ -212,9 +211,10 @@ function photometricInterpretationToRGB(
module: CMYKToRGB,
};
case Photometric.Ycbcr:
return {
module: YCbCrToRGB,
};
// @developmentseed/geotiff currently uses canvas to parse JPEG-compressed
// YCbCr images, which means the YCbCr->RGB conversion is already done by
// the browser's image decoder
return null;
case Photometric.Cielab:
return {
module: cieLabToRGB,
Expand Down
5 changes: 3 additions & 2 deletions packages/geotiff/src/codecs/canvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export async function decode(
ctx.drawImage(imageBitmap, 0, 0);
imageBitmap.close();

const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
const { width, height } = canvas;
const imageData = ctx.getImageData(0, 0, width, height);
const rgba = imageData.data;

const samplesPerPixel = metadata.samplesPerPixel;
Expand All @@ -26,7 +27,7 @@ export async function decode(
}

if (samplesPerPixel === 3) {
const pixelCount = imageBitmap.width * imageBitmap.height;
const pixelCount = width * height;
const rgb = new Uint8ClampedArray(pixelCount * 3);
for (let i = 0, j = 0; i < rgb.length; i += 3, j += 4) {
rgb[i] = rgba[j]!;
Expand Down