Use Uint8ClampedArray when returning image data in src/core/jbig2.js and src/core/jpg.js

This commit is contained in:
Jonas Jenwald 2017-08-15 16:06:55 +02:00
parent 74ad90cb8f
commit f6636d6b19
3 changed files with 3 additions and 3 deletions

View File

@ -955,7 +955,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
this.currentPageInfo = info;
var rowSize = (info.width + 7) >> 3;
var buffer = new Uint8Array(rowSize * info.height);
var buffer = new Uint8ClampedArray(rowSize * info.height);
// The contents of ArrayBuffers are initialized to 0.
// Fill the buffer with 0xFF only if info.defaultPixelValue is set
if (info.defaultPixelValue) {

View File

@ -1386,7 +1386,7 @@ var JpxImage = (function JpxImageClosure() {
transformedTiles[c] = transformTile(context, tile, c);
}
var tile0 = transformedTiles[0];
var out = new Uint8Array(tile0.items.length * componentsCount);
var out = new Uint8ClampedArray(tile0.items.length * componentsCount);
var result = {
left: tile0.left,
top: tile0.top,

View File

@ -991,7 +991,7 @@ var JpxStream = (function JpxStreamClosure() {
if (tileCount === 1) {
this.buffer = jpxImage.tiles[0].items;
} else {
var data = new Uint8Array(width * height * componentsCount);
var data = new Uint8ClampedArray(width * height * componentsCount);
for (var k = 0; k < tileCount; k++) {
var tileComponents = jpxImage.tiles[k];