Remove the special handling, used when creating Indexed ColorSpaces, for the case where the lookup
-data is a Stream
This special-case was added in PR 1992, however it became unnecessary with the changes in PR 4824 since all of the ColorSpace parsing is now done on the worker-thread (with only RGB-data being sent to the main-thread).
This commit is contained in:
parent
ea6a0e4435
commit
d18cf47419
@ -17,7 +17,6 @@ import {
|
|||||||
assert,
|
assert,
|
||||||
FormatError,
|
FormatError,
|
||||||
info,
|
info,
|
||||||
isString,
|
|
||||||
shadow,
|
shadow,
|
||||||
unreachable,
|
unreachable,
|
||||||
warn,
|
warn,
|
||||||
@ -472,10 +471,7 @@ class ColorSpace {
|
|||||||
case "I":
|
case "I":
|
||||||
baseCS = this._parse(cs[1], xref, resources, pdfFunctionFactory);
|
baseCS = this._parse(cs[1], xref, resources, pdfFunctionFactory);
|
||||||
const hiVal = xref.fetchIfRef(cs[2]) + 1;
|
const hiVal = xref.fetchIfRef(cs[2]) + 1;
|
||||||
let lookup = xref.fetchIfRef(cs[3]);
|
const lookup = xref.fetchIfRef(cs[3]);
|
||||||
if (isStream(lookup)) {
|
|
||||||
lookup = lookup.getBytes();
|
|
||||||
}
|
|
||||||
return new IndexedCS(baseCS, hiVal, lookup);
|
return new IndexedCS(baseCS, hiVal, lookup);
|
||||||
case "Separation":
|
case "Separation":
|
||||||
case "DeviceN":
|
case "DeviceN":
|
||||||
@ -643,22 +639,18 @@ class IndexedCS extends ColorSpace {
|
|||||||
this.base = base;
|
this.base = base;
|
||||||
this.highVal = highVal;
|
this.highVal = highVal;
|
||||||
|
|
||||||
const baseNumComps = base.numComps;
|
const length = base.numComps * highVal;
|
||||||
const length = baseNumComps * highVal;
|
this.lookup = new Uint8Array(length);
|
||||||
|
|
||||||
if (isStream(lookup)) {
|
if (isStream(lookup)) {
|
||||||
this.lookup = new Uint8Array(length);
|
|
||||||
const bytes = lookup.getBytes(length);
|
const bytes = lookup.getBytes(length);
|
||||||
this.lookup.set(bytes);
|
this.lookup.set(bytes);
|
||||||
} else if (isString(lookup)) {
|
} else if (typeof lookup === "string") {
|
||||||
this.lookup = new Uint8Array(length);
|
|
||||||
for (let i = 0; i < length; ++i) {
|
for (let i = 0; i < length; ++i) {
|
||||||
this.lookup[i] = lookup.charCodeAt(i);
|
this.lookup[i] = lookup.charCodeAt(i) & 0xff;
|
||||||
}
|
}
|
||||||
} else if (lookup instanceof Uint8Array) {
|
|
||||||
this.lookup = lookup;
|
|
||||||
} else {
|
} else {
|
||||||
throw new FormatError(`Unrecognized lookup table: ${lookup}`);
|
throw new FormatError(`IndexedCS - unrecognized lookup table: ${lookup}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -679,11 +679,13 @@ describe("colorspace", function () {
|
|||||||
describe("IndexedCS", function () {
|
describe("IndexedCS", function () {
|
||||||
it("should handle the case when cs is an array", function () {
|
it("should handle the case when cs is an array", function () {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
const lookup = new Uint8Array([
|
const lookup = new Stream(
|
||||||
23, 155, 35,
|
new Uint8Array([
|
||||||
147, 69, 93,
|
23, 155, 35,
|
||||||
255, 109, 70
|
147, 69, 93,
|
||||||
]);
|
255, 109, 70
|
||||||
|
])
|
||||||
|
);
|
||||||
const cs = [Name.get("Indexed"), Name.get("DeviceRGB"), 2, lookup];
|
const cs = [Name.get("Indexed"), Name.get("DeviceRGB"), 2, lookup];
|
||||||
const xref = new XRefMock([
|
const xref = new XRefMock([
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user