mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 01:58:06 +02:00
Implement Decode entry in Indexed images
This commit is contained in:
parent
f26129de26
commit
26121177ab
7 changed files with 37 additions and 14 deletions
|
@ -169,18 +169,21 @@ var PDFImage = (function PDFImageClosure() {
|
|||
this.decode = dict.getArray('Decode', 'D');
|
||||
this.needsDecode = false;
|
||||
if (this.decode &&
|
||||
((this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode)) ||
|
||||
((this.colorSpace &&
|
||||
!this.colorSpace.isDefaultDecode(this.decode, bitsPerComponent)) ||
|
||||
(isMask && !ColorSpace.isDefaultDecode(this.decode, 1)))) {
|
||||
this.needsDecode = true;
|
||||
// Do some preprocessing to avoid more math.
|
||||
var max = (1 << bitsPerComponent) - 1;
|
||||
this.decodeCoefficients = [];
|
||||
this.decodeAddends = [];
|
||||
const isIndexed = this.colorSpace && this.colorSpace.name === 'Indexed';
|
||||
for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
|
||||
var dmin = this.decode[i];
|
||||
var dmax = this.decode[i + 1];
|
||||
this.decodeCoefficients[j] = dmax - dmin;
|
||||
this.decodeAddends[j] = max * dmin;
|
||||
this.decodeCoefficients[j] = isIndexed ? ((dmax - dmin) / max) :
|
||||
(dmax - dmin);
|
||||
this.decodeAddends[j] = isIndexed ? dmin : (max * dmin);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue