Compare commits

..

No commits in common. "4b2683ecb6bf0bc1c5e5482ac41eb22cc1cdd38c" and "9967ab4aa821fb18fcdd8fd6e47794a957c3aa3a" have entirely different histories.

View File

@ -395,9 +395,10 @@ class MeshStreamReader {
} }
readCoordinate() { readCoordinate() {
const { bitsPerCoordinate, decode } = this.context; const bitsPerCoordinate = this.context.bitsPerCoordinate;
const xi = this.readBits(bitsPerCoordinate); const xi = this.readBits(bitsPerCoordinate);
const yi = this.readBits(bitsPerCoordinate); const yi = this.readBits(bitsPerCoordinate);
const decode = this.context.decode;
const scale = const scale =
bitsPerCoordinate < 32 bitsPerCoordinate < 32
? 1 / ((1 << bitsPerCoordinate) - 1) ? 1 / ((1 << bitsPerCoordinate) - 1)
@ -409,20 +410,23 @@ class MeshStreamReader {
} }
readComponents() { readComponents() {
const { bitsPerComponent, colorFn, colorSpace, decode, numComps } = const numComps = this.context.numComps;
this.context; const bitsPerComponent = this.context.bitsPerComponent;
const scale = const scale =
bitsPerComponent < 32 bitsPerComponent < 32
? 1 / ((1 << bitsPerComponent) - 1) ? 1 / ((1 << bitsPerComponent) - 1)
: 2.3283064365386963e-10; // 2 ^ -32 : 2.3283064365386963e-10; // 2 ^ -32
const decode = this.context.decode;
const components = this.tmpCompsBuf; const components = this.tmpCompsBuf;
for (let i = 0, j = 4; i < numComps; i++, j += 2) { for (let i = 0, j = 4; i < numComps; i++, j += 2) {
const ci = this.readBits(bitsPerComponent); const ci = this.readBits(bitsPerComponent);
components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j]; components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
} }
const color = this.tmpCsCompsBuf; const color = this.tmpCsCompsBuf;
colorFn?.(components, 0, color, 0); if (this.context.colorFn) {
return colorSpace.getRgb(color, 0); this.context.colorFn(components, 0, color, 0);
}
return this.context.colorSpace.getRgb(color, 0);
} }
} }