mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Remove manual clamping/rounding from ColorSpace
and PDFImage
, by having their methods use Uint8ClampedArray
s
The built-in image decoders are already using `Uint8ClampedArray` when returning data, and this patch simply extends that to the rest of the image/colorspace code. As far as I can tell, the only reason for using manual clamping/rounding in the first place was because TypedArrays used to be polyfilled (using regular arrays). And trying to polyfill the native clamping/rounding would probably have been had too much overhead, but given that TypedArray support is required in PDF.js version `2.0` that's no longer a concern. *Please note:* Because of different rounding behaviour, basically `Math.round` in `Uint8ClampedArray` respectively `Math.floor` in the old code, there will be very slight movement in quite a few existing test-cases. However, the changes should be imperceivable to the naked eye, given that the absolute difference is *at most* `1` for each RGB component when comparing `master` and this patch (see also the updated expectation values in the unit-tests).
This commit is contained in:
parent
55199aa281
commit
731f2e6dfc
9 changed files with 150 additions and 157 deletions
|
@ -377,7 +377,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
var width = dict.get('Width', 'W');
|
||||
var height = dict.get('Height', 'H');
|
||||
var bitStrideLength = (width + 7) >> 3;
|
||||
var imgArray = image.getBytes(bitStrideLength * height);
|
||||
var imgArray = image.getBytes(bitStrideLength * height,
|
||||
/* forceClamped = */ true);
|
||||
var decode = dict.getArray('Decode', 'D');
|
||||
|
||||
imgData = PDFImage.createMask({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue