style fixes and fix bug in numComps calculation (missing break)
This commit is contained in:
parent
4f63d8503f
commit
2069f3f241
34
pdf.js
34
pdf.js
@ -553,8 +553,7 @@ var JpegStream = (function() {
|
|||||||
|
|
||||||
var PredictorStream = (function() {
|
var PredictorStream = (function() {
|
||||||
function constructor(stream, params) {
|
function constructor(stream, params) {
|
||||||
var predictor = params.get("Predictor") || 1;
|
var predictor = this.predictor = params.get("Predictor") || 1;
|
||||||
this.predictor = predictor;
|
|
||||||
|
|
||||||
if (predictor <= 1)
|
if (predictor <= 1)
|
||||||
return stream; // no prediction
|
return stream; // no prediction
|
||||||
@ -571,18 +570,13 @@ var PredictorStream = (function() {
|
|||||||
if (params.has("EarlyChange")) {
|
if (params.has("EarlyChange")) {
|
||||||
error("EarlyChange predictor parameter is not supported");
|
error("EarlyChange predictor parameter is not supported");
|
||||||
}
|
}
|
||||||
var colors = params.get("Colors") || 1;
|
var colors = this.colors = params.get("Colors") || 1;
|
||||||
this.colors = colors;
|
var bits = this.bits = params.get("BitsPerComponent") || 8;
|
||||||
var bits = params.get("BitsPerComponent") || 8;
|
var columns = this.columns = params.get("Columns") || 1;
|
||||||
this.bits = bits;
|
|
||||||
var columns = params.get("Columns") || 1;
|
|
||||||
this.columns = columns;
|
|
||||||
|
|
||||||
var pixBytes = (colors * bits + 7) >> 3;
|
var pixBytes = this.pixBytes = (colors * bits + 7) >> 3;
|
||||||
this.pixBytes = pixBytes;
|
|
||||||
// add an extra pixByte to represent the pixel left of column 0
|
// add an extra pixByte to represent the pixel left of column 0
|
||||||
var rowBytes = ((columns * colors * bits + 7) >> 3) + pixBytes;
|
var rowBytes = this.rowBytes = ((columns * colors * bits + 7) >> 3) + pixBytes;
|
||||||
this.rowBytes = rowBytes;
|
|
||||||
|
|
||||||
this.currentRow = new Uint8Array(rowBytes);
|
this.currentRow = new Uint8Array(rowBytes);
|
||||||
this.bufferLength = rowBytes;
|
this.bufferLength = rowBytes;
|
||||||
@ -626,8 +620,8 @@ var PredictorStream = (function() {
|
|||||||
inbuf = (inbuf << 8) | (rawBytes[j++] & 0xFF);
|
inbuf = (inbuf << 8) | (rawBytes[j++] & 0xFF);
|
||||||
inbits += 8;
|
inbits += 8;
|
||||||
}
|
}
|
||||||
compArray[kk] = (compArray[kk] + (inbuf >>
|
compArray[kk] = (compArray[kk] +
|
||||||
(inbits - bits))) & bitMask;
|
(inbuf >> (inbits - bits))) & bitMask;
|
||||||
inbits -= bits;
|
inbits -= bits;
|
||||||
outbuf = (outbuf << bits) | compArray[kk];
|
outbuf = (outbuf << bits) | compArray[kk];
|
||||||
outbits += bits;
|
outbits += bits;
|
||||||
@ -639,7 +633,7 @@ var PredictorStream = (function() {
|
|||||||
}
|
}
|
||||||
if (outbits > 0) {
|
if (outbits > 0) {
|
||||||
currentRow[k++] = (outbuf << (8 - outbits)) +
|
currentRow[k++] = (outbuf << (8 - outbits)) +
|
||||||
(inbuf & ((1 << (8 - outbits)) - 1))
|
(inbuf & ((1 << (8 - outbits)) - 1))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.pos = pixBytes;
|
this.pos = pixBytes;
|
||||||
@ -707,18 +701,16 @@ var PredictorStream = (function() {
|
|||||||
this.pos = pixBytes;
|
this.pos = pixBytes;
|
||||||
},
|
},
|
||||||
getByte : function() {
|
getByte : function() {
|
||||||
if (this.pos >= this.bufferLength) {
|
if (this.pos >= this.bufferLength)
|
||||||
this.readRow();
|
this.readRow();
|
||||||
}
|
|
||||||
return this.currentRow[this.pos++];
|
return this.currentRow[this.pos++];
|
||||||
},
|
},
|
||||||
getBytes : function(n) {
|
getBytes : function(n) {
|
||||||
var i, bytes;
|
var i, bytes;
|
||||||
bytes = new Uint8Array(n);
|
bytes = new Uint8Array(n);
|
||||||
for (i = 0; i < n; ++i) {
|
for (i = 0; i < n; ++i) {
|
||||||
if (this.pos >= this.bufferLength) {
|
if (this.pos >= this.bufferLength)
|
||||||
this.readRow();
|
this.readRow();
|
||||||
}
|
|
||||||
bytes[i] = this.currentRow[this.pos++];
|
bytes[i] = this.currentRow[this.pos++];
|
||||||
}
|
}
|
||||||
return bytes;
|
return bytes;
|
||||||
@ -727,9 +719,8 @@ var PredictorStream = (function() {
|
|||||||
return String.formCharCode(this.getByte());
|
return String.formCharCode(this.getByte());
|
||||||
},
|
},
|
||||||
lookChar : function() {
|
lookChar : function() {
|
||||||
if (this.pos >= this.bufferLength) {
|
if (this.pos >= this.bufferLength)
|
||||||
this.readRow();
|
this.readRow();
|
||||||
}
|
|
||||||
return String.formCharCode(this.currentRow[this.pos]);
|
return String.formCharCode(this.currentRow[this.pos]);
|
||||||
},
|
},
|
||||||
skip : function(n) {
|
skip : function(n) {
|
||||||
@ -3288,6 +3279,7 @@ var ColorSpace = (function() {
|
|||||||
case "DeviceGray":
|
case "DeviceGray":
|
||||||
case "G":
|
case "G":
|
||||||
this.numComps = 1;
|
this.numComps = 1;
|
||||||
|
break;
|
||||||
case "DeviceRGB":
|
case "DeviceRGB":
|
||||||
this.numComps = 3;
|
this.numComps = 3;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user