Fix a bug and speed up graycs_getRgbBuffer.

An rgbBuffer was created which was three times as big as intended. It also
caused that the function was very slow when rendering cable.pdf. Which led
to a slow script warning dialog.

With this fix the function speeds up fifteen-fold in the firebug profile.
This commit is contained in:
Kalervo Kujala 2011-09-06 00:11:24 +03:00
parent 80304b6976
commit d4b8326496

5
pdf.js
View File

@ -5469,8 +5469,9 @@ var DeviceGrayCS = (function() {
},
getRgbBuffer: function graycs_getRgbBuffer(input, bits) {
var scale = 255 / ((1 << bits) - 1);
var rgbBuf = new Uint8Array(input.length * 3);
for (var i = 0, j = 0; i < input.length; ++i) {
var length = input.length;
var rgbBuf = new Uint8Array(length * 3);
for (var i = 0, j = 0; i < length; ++i) {
var c = (scale * input[i]) | 0;
rgbBuf[j++] = c;
rgbBuf[j++] = c;