1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 17:48:07 +02:00

Decompress when it's possible images in using DecompressionStream

Getting images is already asynchronous, so we can use this opportunity
to use DecompressStream (which is async too) to decompress images.
This commit is contained in:
Calixte Denizet 2024-05-24 23:26:02 +02:00
parent 53dfb5a6ba
commit 9654ad570a
7 changed files with 149 additions and 30 deletions

View file

@ -99,6 +99,14 @@ class DecodeStream extends BaseStream {
return this.buffer.subarray(pos, end);
}
async getImageData(length, ignoreColorSpace = false) {
if (!this.canAsyncDecodeImageFromBuffer) {
return this.getBytes(length, ignoreColorSpace);
}
const data = await this.stream.asyncGetBytes();
return this.decodeImage(data, ignoreColorSpace);
}
reset() {
this.pos = 0;
}