@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License .
* limitations under the License .
* /
* /
/ * g l o b a l s C o l o r S p a c e , D e c o d e S t r e a m , e r r o r , i n f o , i s A r r a y , I m a g e K i n d , i s S t r e a m ,
/ * g l o b a l s a s s e r t , C o l o r S p a c e , D e c o d e S t r e a m , e r r o r , i n f o , i s A r r a y , I m a g e K i n d ,
JpegStream , JpxImage , Name , Promise , Stream , warn * /
isStream , JpegStream , JpxImage , Name , Promise , Stream , warn * /
'use strict' ;
'use strict' ;
@ -531,10 +531,11 @@ var PDFImage = (function PDFImageClosure() {
var kind ;
var kind ;
if ( this . colorSpace . name === 'DeviceGray' && bpc === 1 ) {
if ( this . colorSpace . name === 'DeviceGray' && bpc === 1 ) {
kind = ImageKind . GRAYSCALE _1BPP ;
kind = ImageKind . GRAYSCALE _1BPP ;
} else if ( this . colorSpace . name === 'DeviceRGB' && bpc === 8 ) {
} else if ( this . colorSpace . name === 'DeviceRGB' && bpc === 8 &&
! this . needsDecode ) {
kind = ImageKind . RGB _24BPP ;
kind = ImageKind . RGB _24BPP ;
}
}
if ( kind && ! this . smask && ! this . mask && ! this . needsDecode &&
if ( kind && ! this . smask && ! this . mask &&
drawWidth === originalWidth && drawHeight === originalHeight ) {
drawWidth === originalWidth && drawHeight === originalHeight ) {
imgData . kind = kind ;
imgData . kind = kind ;
@ -551,6 +552,14 @@ var PDFImage = (function PDFImageClosure() {
newArray . set ( imgArray ) ;
newArray . set ( imgArray ) ;
imgData . data = newArray ;
imgData . data = newArray ;
}
}
if ( this . needsDecode ) {
// Invert the buffer (which must be grayscale if we reached here).
assert ( kind === ImageKind . GRAYSCALE _1BPP ) ;
var buffer = imgData . data ;
for ( var i = 0 , ii = buffer . length ; i < ii ; i ++ ) {
buffer [ i ] ^= 0xff ;
}
}
return imgData ;
return imgData ;
}
}
if ( this . image instanceof JpegStream && ! this . smask && ! this . mask ) {
if ( this . image instanceof JpegStream && ! this . smask && ! this . mask ) {