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:
parent
53dfb5a6ba
commit
9654ad570a
7 changed files with 149 additions and 30 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue