1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Fix decoding of JPX images having an alpha channel

When an image has a non-zero SMaskInData it means that the image
has an alpha channel.
With JPX images, the colorspace isn't required (by spec) so when we
don't have it, the JPX decoder will handle the conversion in RGBA
format.
This commit is contained in:
Calixte Denizet 2024-06-03 16:09:26 +02:00
parent 5c51d56223
commit 196affd8e0
12 changed files with 126 additions and 39 deletions

View file

@ -41,16 +41,16 @@ class JpxStream extends DecodeStream {
// directly insert all of its data into `this.buffer`.
}
readBlock(ignoreColorSpace) {
this.decodeImage(null, ignoreColorSpace);
readBlock(decoderOptions) {
this.decodeImage(null, decoderOptions);
}
decodeImage(bytes, ignoreColorSpace) {
decodeImage(bytes, decoderOptions) {
if (this.eof) {
return this.buffer;
}
bytes ||= this.bytes;
this.buffer = JpxImage.decode(bytes, ignoreColorSpace);
this.buffer = JpxImage.decode(bytes, decoderOptions);
this.bufferLength = this.buffer.length;
this.eof = true;