Merge pull request #569 from notmasteryet/cmyk-inv

Mark all 'Adobe' images with 'EMBED'
This commit is contained in:
Andreas Gal 2011-09-30 19:17:45 -07:00
commit 846fc1755c

12
pdf.js
View File

@ -904,16 +904,16 @@ var PredictorStream = (function predictorStream() {
// A JpegStream can't be read directly. We use the platform to render
// the underlying JPEG data for us.
var JpegStream = (function jpegStream() {
function isYcckImage(bytes) {
function isAdobeImage(bytes) {
var maxBytesScanned = Math.max(bytes.length - 16, 1024);
// Looking for APP14, 'Adobe' and transform = 2
// Looking for APP14, 'Adobe'
for (var i = 0; i < maxBytesScanned; ++i) {
if (bytes[i] == 0xFF && bytes[i + 1] == 0xEE &&
bytes[i + 2] == 0x00 && bytes[i + 3] == 0x0E &&
bytes[i + 4] == 0x41 && bytes[i + 5] == 0x64 &&
bytes[i + 6] == 0x6F && bytes[i + 7] == 0x62 &&
bytes[i + 8] == 0x65 && bytes[i + 9] == 0x00)
return bytes[i + 15] == 0x02;
return true;
// scanning until frame tag
if (bytes[i] == 0xFF && bytes[i + 1] == 0xC0)
break;
@ -921,7 +921,7 @@ var JpegStream = (function jpegStream() {
return false;
}
function fixYcckImage(bytes) {
function fixAdobeImage(bytes) {
// Inserting 'EMBED' marker after JPEG signature
var embedMarker = new Uint8Array([0xFF, 0xEC, 0, 8, 0x45, 0x4D, 0x42, 0x45,
0x44, 0]);
@ -939,8 +939,8 @@ var JpegStream = (function jpegStream() {
// need to be removed
this.dict = dict;
if (isYcckImage(bytes))
bytes = fixYcckImage(bytes);
if (isAdobeImage(bytes))
bytes = fixAdobeImage(bytes);
// create DOM image
var img = new Image();