Merge pull request #4892 from yurydelendik/issue4890

Fixes masked JPEG image
This commit is contained in:
Yury Delendik 2014-06-10 09:16:12 -05:00
commit cff2c3afc1
3 changed files with 13 additions and 11 deletions

View File

@ -536,12 +536,12 @@ var PDFImage = (function PDFImageClosure() {
} }
return imgData; return imgData;
} }
} if (this.image instanceof JpegStream && !this.smask && !this.mask) {
if (this.image instanceof JpegStream) { imgData.kind = ImageKind.RGB_24BPP;
imgData.kind = ImageKind.RGB_24BPP; imgData.data = this.getImageBytes(originalHeight * rowBytes,
imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
drawWidth, drawHeight); return imgData;
return imgData; }
} }
imgArray = this.getImageBytes(originalHeight * rowBytes); imgArray = this.getImageBytes(originalHeight * rowBytes);
@ -629,10 +629,12 @@ var PDFImage = (function PDFImageClosure() {
}, },
getImageBytes: function PDFImage_getImageBytes(length, getImageBytes: function PDFImage_getImageBytes(length,
drawWidth, drawHeight) { drawWidth, drawHeight,
forceRGB) {
this.image.reset(); this.image.reset();
this.image.drawWidth = drawWidth; this.image.drawWidth = drawWidth || this.width;
this.image.drawHeight = drawHeight; this.image.drawHeight = drawHeight || this.height;
this.image.forceRGB = !!forceRGB;
return this.image.getBytes(length); return this.image.getBytes(length);
} }
}; };

View File

@ -1011,7 +1011,7 @@ var JpegImage = (function jpegImage() {
} else { } else {
return this._convertYcckToCmyk(data); return this._convertYcckToCmyk(data);
} }
} else { } else if (forceRGBoutput) {
return this._convertCmykToRgb(data); return this._convertCmykToRgb(data);
} }
} }

View File

@ -903,7 +903,7 @@ var JpegStream = (function JpegStreamClosure() {
jpegImage.parse(this.bytes); jpegImage.parse(this.bytes);
var data = jpegImage.getData(this.drawWidth, this.drawHeight, var data = jpegImage.getData(this.drawWidth, this.drawHeight,
/* forceRGBoutput = */true); this.forceRGB);
this.buffer = data; this.buffer = data;
this.bufferLength = data.length; this.bufferLength = data.length;
this.eof = true; this.eof = true;