[Pkg-javascript-commits] [pdf.js] 38/56: Fix corrupted images #4649
David Prévot
taffit at moszumanska.debian.org
Thu May 15 15:17:46 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit 11f565547c760ffcd91788480376b5f617805e6f
Author: fkaelberer <o_0_o at gmx.de>
Date: Sat Apr 19 19:34:42 2014 +0200
Fix corrupted images #4649
---
src/core/image.js | 4 +++-
src/core/jpx.js | 18 +++++++++++++++---
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/src/core/image.js b/src/core/image.js
index e1a2b97..7305824 100644
--- a/src/core/image.js
+++ b/src/core/image.js
@@ -107,8 +107,10 @@ var PDFImage = (function PDFImageClosure() {
case 3:
colorSpace = Name.get('DeviceRGB');
break;
+ case 4:
+ colorSpace = Name.get('DeviceCMYK');
+ break;
default:
- // TODO: Find out how four color channels are handled. CMYK? Alpha?
error('JPX images with ' + this.numComps +
' color components not supported.');
}
diff --git a/src/core/jpx.js b/src/core/jpx.js
index 2e27f67..4c4294b 100644
--- a/src/core/jpx.js
+++ b/src/core/jpx.js
@@ -1077,11 +1077,13 @@ var JpxImage = (function JpxImageClosure() {
// Section G.2.2 Inverse multi component transform
var shift, offset, max, min;
- var pos = 0, j, jj, y0, y1, y2, r, g, b, val;
+ var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;
if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
- var y2items = transformedTiles[2].items;
- var y1items = transformedTiles[1].items;
+ var fourComponents = componentsCount === 4;
var y0items = transformedTiles[0].items;
+ var y1items = transformedTiles[1].items;
+ var y2items = transformedTiles[2].items;
+ var y3items = fourComponents ? transformedTiles[3].items : null;
// HACK: The multiple component transform formulas below assume that
// all components have the same precision. With this in mind, we
@@ -1104,6 +1106,11 @@ var JpxImage = (function JpxImageClosure() {
out[pos++] = r <= min ? 0 : r >= max ? 255 : (r + offset) >> shift;
out[pos++] = g <= min ? 0 : g >= max ? 255 : (g + offset) >> shift;
out[pos++] = b <= min ? 0 : b >= max ? 255 : (b + offset) >> shift;
+ if (fourComponents) {
+ k = y3items[j];
+ out[pos++] =
+ k <= min ? 0 : k >= max ? 255 : (k + offset) >> shift;
+ }
}
} else {
// inverse reversible multiple component transform
@@ -1117,6 +1124,11 @@ var JpxImage = (function JpxImageClosure() {
out[pos++] = r <= min ? 0 : r >= max ? 255 : (r + offset) >> shift;
out[pos++] = g <= min ? 0 : g >= max ? 255 : (g + offset) >> shift;
out[pos++] = b <= min ? 0 : b >= max ? 255 : (b + offset) >> shift;
+ if (fourComponents) {
+ k = y3items[j];
+ out[pos++] =
+ k <= min ? 0 : k >= max ? 255 : (k + offset) >> shift;
+ }
}
}
} else { // no multi-component transform
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list