|
|
|
@ -803,29 +803,16 @@ var JpegStream = (function JpegStreamClosure() {
@@ -803,29 +803,16 @@ var JpegStream = (function JpegStreamClosure() {
|
|
|
|
|
// need to be removed
|
|
|
|
|
this.dict = dict; |
|
|
|
|
|
|
|
|
|
// Flag indicating wether the image can be natively loaded.
|
|
|
|
|
this.isNative = true; |
|
|
|
|
|
|
|
|
|
this.colorTransform = -1; |
|
|
|
|
this.isAdobeImage = false; |
|
|
|
|
this.colorTransform = dict.get('ColorTransform') || -1; |
|
|
|
|
|
|
|
|
|
if (isAdobeImage(bytes)) { |
|
|
|
|
// when bug 674619 land, let's check if browser can do
|
|
|
|
|
// normal cmyk and then we won't have to the following
|
|
|
|
|
var cs = xref.fetchIfRef(dict.get('ColorSpace')); |
|
|
|
|
|
|
|
|
|
// DeviceRGB and DeviceGray are the only Adobe images that work natively
|
|
|
|
|
if (isName(cs) && (cs.name === 'DeviceRGB' || cs.name === 'DeviceGray')) { |
|
|
|
|
bytes = fixAdobeImage(bytes); |
|
|
|
|
this.src = bytesToString(bytes); |
|
|
|
|
} else { |
|
|
|
|
this.colorTransform = dict.get('ColorTransform'); |
|
|
|
|
this.isNative = false; |
|
|
|
|
this.bytes = bytes; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
this.src = bytesToString(bytes); |
|
|
|
|
this.isAdobeImage = true; |
|
|
|
|
bytes = fixAdobeImage(bytes); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.bytes = bytes; |
|
|
|
|
|
|
|
|
|
DecodeStream.call(this); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -835,7 +822,8 @@ var JpegStream = (function JpegStreamClosure() {
@@ -835,7 +822,8 @@ var JpegStream = (function JpegStreamClosure() {
|
|
|
|
|
if (this.bufferLength) |
|
|
|
|
return; |
|
|
|
|
var jpegImage = new JpegImage(); |
|
|
|
|
jpegImage.colorTransform = this.colorTransform; |
|
|
|
|
if (this.colorTransform != -1) |
|
|
|
|
jpegImage.colorTransform = this.colorTransform; |
|
|
|
|
jpegImage.parse(this.bytes); |
|
|
|
|
var width = jpegImage.width; |
|
|
|
|
var height = jpegImage.height; |
|
|
|
@ -844,11 +832,39 @@ var JpegStream = (function JpegStreamClosure() {
@@ -844,11 +832,39 @@ var JpegStream = (function JpegStreamClosure() {
|
|
|
|
|
this.bufferLength = data.length; |
|
|
|
|
}; |
|
|
|
|
JpegStream.prototype.getIR = function jpegStreamGetIR() { |
|
|
|
|
return this.src; |
|
|
|
|
return bytesToString(this.bytes); |
|
|
|
|
}; |
|
|
|
|
JpegStream.prototype.getChar = function jpegStreamGetChar() { |
|
|
|
|
error('internal error: getChar is not valid on JpegStream'); |
|
|
|
|
}; |
|
|
|
|
/** |
|
|
|
|
* Checks if the image can be decoded and displayed by the browser without any |
|
|
|
|
* further processing such as color space conversions. |
|
|
|
|
*/ |
|
|
|
|
JpegStream.prototype.isNativelySupported = function isNativelySupported(xref, |
|
|
|
|
res) { |
|
|
|
|
var cs = ColorSpace.parse(this.dict.get('ColorSpace'), xref, res); |
|
|
|
|
// when bug 674619 lands, let's check if browser can do
|
|
|
|
|
// normal cmyk and then we won't need to decode in JS
|
|
|
|
|
if (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') |
|
|
|
|
return true; |
|
|
|
|
if (cs.name === 'DeviceCMYK' && !this.isAdobeImage && |
|
|
|
|
this.colorTransform < 1) |
|
|
|
|
return true; |
|
|
|
|
return false; |
|
|
|
|
}; |
|
|
|
|
/** |
|
|
|
|
* Checks if the image can be decoded by the browser. |
|
|
|
|
*/ |
|
|
|
|
JpegStream.prototype.isNativelyDecodable = function isNativelyDecodable(xref, |
|
|
|
|
res) { |
|
|
|
|
var cs = ColorSpace.parse(this.dict.get('ColorSpace'), xref, res); |
|
|
|
|
var numComps = cs.numComps; |
|
|
|
|
if (numComps == 1 || numComps == 3) |
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
return JpegStream; |
|
|
|
|
})(); |
|
|
|
|