You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
724 B
21 lines
724 B
import { applyPredictor } from '../predictor.js';
|
|
|
|
export default class BaseDecoder {
|
|
async decode(fileDirectory, buffer) {
|
|
const decoded = await this.decodeBlock(buffer);
|
|
const predictor = fileDirectory.Predictor || 1;
|
|
if (predictor !== 1) {
|
|
const isTiled = !fileDirectory.StripOffsets;
|
|
const tileWidth = isTiled ? fileDirectory.TileWidth : fileDirectory.ImageWidth;
|
|
const tileHeight = isTiled ? fileDirectory.TileLength : (
|
|
fileDirectory.RowsPerStrip || fileDirectory.ImageLength
|
|
);
|
|
return applyPredictor(
|
|
decoded, predictor, tileWidth, tileHeight, fileDirectory.BitsPerSample,
|
|
fileDirectory.PlanarConfiguration,
|
|
);
|
|
}
|
|
return decoded;
|
|
}
|
|
}
|