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