Introduce ImageKind constants.
This commit is contained in:
		
							parent
							
								
									4e1f92a893
								
							
						
					
					
						commit
						42cbb5b440
					
				| @ -16,7 +16,7 @@ | |||||||
|  */ |  */ | ||||||
| /* globals assert, assertWellFormed, ColorSpace, Dict, Encodings, error, | /* globals assert, assertWellFormed, ColorSpace, Dict, Encodings, error, | ||||||
|            ErrorFont, Font, FONT_IDENTITY_MATRIX, fontCharsToUnicode, FontFlags, |            ErrorFont, Font, FONT_IDENTITY_MATRIX, fontCharsToUnicode, FontFlags, | ||||||
|            info, isArray, isCmd, isDict, isEOF, isName, isNum, |            ImageKind, info, isArray, isCmd, isDict, isEOF, isName, isNum, | ||||||
|            isStream, isString, JpegStream, Lexer, Metrics, Name, Parser, |            isStream, isString, JpegStream, Lexer, Metrics, Name, Parser, | ||||||
|            Pattern, PDFImage, PDFJS, serifFonts, stdFontMap, symbolsFonts, |            Pattern, PDFImage, PDFJS, serifFonts, stdFontMap, symbolsFonts, | ||||||
|            getTilingPatternIR, warn, Util, Promise, LegacyPromise, |            getTilingPatternIR, warn, Util, Promise, LegacyPromise, | ||||||
| @ -166,8 +166,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { | |||||||
|           (w + h) < SMALL_IMAGE_DIMENSIONS) { |           (w + h) < SMALL_IMAGE_DIMENSIONS) { | ||||||
|         var imageObj = new PDFImage(this.xref, resources, image, |         var imageObj = new PDFImage(this.xref, resources, image, | ||||||
|                                     inline, null, null); |                                     inline, null, null); | ||||||
|         // We force the use of 'rgba_32bpp' images here, because we can't
 |         // We force the use of RGBA_32BPP images here, because we can't handle
 | ||||||
|         // handle any other kind.
 |         // any other kind.
 | ||||||
|         var imgData = imageObj.createImageData(/* forceRGBA = */ true); |         var imgData = imageObj.createImageData(/* forceRGBA = */ true); | ||||||
|         operatorList.addOp(OPS.paintInlineImageXObject, [imgData]); |         operatorList.addOp(OPS.paintInlineImageXObject, [imgData]); | ||||||
|         return; |         return; | ||||||
| @ -1321,7 +1321,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { | |||||||
|         // replacing queue items
 |         // replacing queue items
 | ||||||
|         squash(fnArray, j, count * 4, OPS.paintInlineImageXObjectGroup); |         squash(fnArray, j, count * 4, OPS.paintInlineImageXObjectGroup); | ||||||
|         argsArray.splice(j, count * 4, |         argsArray.splice(j, count * 4, | ||||||
|           [{width: imgWidth, height: imgHeight, kind: 'rgba_32bpp', |           [{width: imgWidth, height: imgHeight, kind: ImageKind.RGBA_32BPP, | ||||||
|             data: imgData}, map]); |             data: imgData}, map]); | ||||||
|         i = j; |         i = j; | ||||||
|         ii = argsArray.length; |         ii = argsArray.length; | ||||||
|  | |||||||
| @ -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. | ||||||
|  */ |  */ | ||||||
| /* globals ColorSpace, error, isArray, isStream, JpegStream, Name, Promise, | /* globals ColorSpace, error, isArray, ImageKind, isStream, JpegStream, Name, | ||||||
|            Stream, warn, LegacyPromise */ |            Promise, Stream, warn, LegacyPromise */ | ||||||
| 
 | 
 | ||||||
| 'use strict'; | 'use strict'; | ||||||
| 
 | 
 | ||||||
| @ -444,9 +444,9 @@ var PDFImage = (function PDFImageClosure() { | |||||||
|         // complications, we avoid expanding by 1.333x to RGBA form.
 |         // complications, we avoid expanding by 1.333x to RGBA form.
 | ||||||
|         var kind; |         var kind; | ||||||
|         if (this.colorSpace.name === 'DeviceGray' && bpc === 1) { |         if (this.colorSpace.name === 'DeviceGray' && bpc === 1) { | ||||||
|           kind = 'grayscale_1bpp'; |           kind = ImageKind.GRAYSCALE_1BPP; | ||||||
|         } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8) { |         } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8) { | ||||||
|           kind = 'rgb_24bpp'; |           kind = ImageKind.RGB_24BPP; | ||||||
|         } |         } | ||||||
|         if (kind && !this.smask && !this.mask && !this.needsDecode && |         if (kind && !this.smask && !this.mask && !this.needsDecode && | ||||||
|             drawWidth === originalWidth && drawHeight === originalHeight) { |             drawWidth === originalWidth && drawHeight === originalHeight) { | ||||||
| @ -482,7 +482,7 @@ var PDFImage = (function PDFImageClosure() { | |||||||
| 
 | 
 | ||||||
|       this.undoPreblend(rgbaBuf, drawWidth, actualHeight); |       this.undoPreblend(rgbaBuf, drawWidth, actualHeight); | ||||||
| 
 | 
 | ||||||
|       imgData.kind = 'rgba_32bpp'; |       imgData.kind = ImageKind.RGBA_32BPP; | ||||||
|       imgData.data = rgbaBuf; |       imgData.data = rgbaBuf; | ||||||
|       return imgData; |       return imgData; | ||||||
|     }, |     }, | ||||||
|  | |||||||
| @ -15,9 +15,9 @@ | |||||||
|  * limitations under the License. |  * limitations under the License. | ||||||
|  */ |  */ | ||||||
| /* globals ColorSpace, DeviceCmykCS, DeviceGrayCS, DeviceRgbCS, error, | /* globals ColorSpace, DeviceCmykCS, DeviceGrayCS, DeviceRgbCS, error, | ||||||
|            FONT_IDENTITY_MATRIX, IDENTITY_MATRIX, ImageData, isArray, isNum, |            FONT_IDENTITY_MATRIX, IDENTITY_MATRIX, ImageData, ImageKind, | ||||||
|            TilingPattern, OPS, Promise, Util, warn, assert, info, shadow, |            isArray, isNum, TilingPattern, OPS, Promise, Util, warn, assert, | ||||||
|            TextRenderingMode, getShadingPatternFromIR */ |            info, shadow, TextRenderingMode, getShadingPatternFromIR */ | ||||||
| 
 | 
 | ||||||
| 'use strict'; | 'use strict'; | ||||||
| 
 | 
 | ||||||
| @ -457,7 +457,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { | |||||||
|     // There are multiple forms in which the pixel data can be passed, and
 |     // There are multiple forms in which the pixel data can be passed, and
 | ||||||
|     // imgData.kind tells us which one this is.
 |     // imgData.kind tells us which one this is.
 | ||||||
| 
 | 
 | ||||||
|     if (imgData.kind === 'grayscale_1bpp') { |     if (imgData.kind === ImageKind.GRAYSCALE_1BPP) { | ||||||
|       // Grayscale, 1 bit per pixel (i.e. black-and-white).
 |       // Grayscale, 1 bit per pixel (i.e. black-and-white).
 | ||||||
|       var destDataLength = dest.length; |       var destDataLength = dest.length; | ||||||
|       var srcLength = src.byteLength; |       var srcLength = src.byteLength; | ||||||
| @ -505,7 +505,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { | |||||||
|         ctx.putImageData(chunkImgData, 0, i * fullChunkHeight); |         ctx.putImageData(chunkImgData, 0, i * fullChunkHeight); | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|     } else if (imgData.kind === 'rgba_32bpp') { |     } else if (imgData.kind === ImageKind.RGBA_32BPP) { | ||||||
|       // RGBA, 32-bits per pixel.
 |       // RGBA, 32-bits per pixel.
 | ||||||
|       var haveSetAndSubarray = 'set' in dest && 'subarray' in src; |       var haveSetAndSubarray = 'set' in dest && 'subarray' in src; | ||||||
| 
 | 
 | ||||||
| @ -524,7 +524,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { | |||||||
|         ctx.putImageData(chunkImgData, 0, i * fullChunkHeight); |         ctx.putImageData(chunkImgData, 0, i * fullChunkHeight); | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|     } else if (imgData.kind === 'rgb_24bpp') { |     } else if (imgData.kind === ImageKind.RGB_24BPP) { | ||||||
|       // RGB, 24-bits per pixel.
 |       // RGB, 24-bits per pixel.
 | ||||||
|       for (var i = 0; i < totalChunks; i++) { |       for (var i = 0; i < totalChunks; i++) { | ||||||
|         var thisChunkHeight = |         var thisChunkHeight = | ||||||
|  | |||||||
| @ -38,6 +38,12 @@ var TextRenderingMode = { | |||||||
|   ADD_TO_PATH_FLAG: 4 |   ADD_TO_PATH_FLAG: 4 | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | var ImageKind = { | ||||||
|  |   GRAYSCALE_1BPP: 1, | ||||||
|  |   RGB_24BPP: 2, | ||||||
|  |   RGBA_32BPP: 3 | ||||||
|  | }; | ||||||
|  | 
 | ||||||
| // The global PDFJS object exposes the API
 | // The global PDFJS object exposes the API
 | ||||||
| // In production, it will be declared outside a global wrapper
 | // In production, it will be declared outside a global wrapper
 | ||||||
| // In development, it will be declared here
 | // In development, it will be declared here
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user