1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-21 15:48:06 +02:00

Make the getBytes/peekBytes methods of Stream/DecodeStream/ChunkedStream able to return Uint8ClampedArrays

The built-in image decoders are already returning data as `Uint8ClampedArray`, and subsequently the JPEG/JBIG2/JPX streams are as well. However, for general streams we obviously don't want to force the use of `Uint8ClampedArray` unless an "Image" is actually being decoded.
Hence this patch, which adds a parameter that allows the caller of the `getBytes`/`peekBytes` methods to force a `Uint8ClampedArray` (rather than a `Uint8Array`) to be returned.
This commit is contained in:
Jonas Jenwald 2018-06-11 17:25:30 +02:00
parent 2030d1718f
commit 32367c5968
3 changed files with 32 additions and 18 deletions

View file

@ -59,6 +59,11 @@ describe('stream', function() {
expect(result).toMatchTypedArray(
new Uint8Array([100, 3, 101, 2, 102, 1])
);
predictor.reset();
let clampedResult = predictor.getBytes(6, /* forceClamped = */ true);
expect(clampedResult).toEqual(
new Uint8ClampedArray([100, 3, 101, 2, 102, 1]));
});
});
});