Browse Source

Reduce math for color key mask.

Brendan Dahl 13 years ago
parent
commit
d26ecff294
  1. 9
      src/image.js

9
src/image.js

@ -320,11 +320,14 @@ var PDFImage = (function PDFImageClosure() {
// Color key mask: if any of the compontents are outside the range // Color key mask: if any of the compontents are outside the range
// then they should be painted. // then they should be painted.
buf = new Uint8Array(width * height); buf = new Uint8Array(width * height);
var numComps = this.numComps;
for (var i = 0, ii = width * height; i < ii; ++i) { for (var i = 0, ii = width * height; i < ii; ++i) {
var opacity = 0; var opacity = 0;
for (var j = 0; j < this.numComps; ++j) { var imageOffset = i * numComps;
var color = image[i * this.numComps + j]; for (var j = 0; j < numComps; ++j) {
if (color < mask[j * 2] || color > mask[j * 2 + 1]) { var color = image[imageOffset + j];
var maskOffset = j * 2;
if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
opacity = 255; opacity = 255;
break; break;
} }

Loading…
Cancel
Save