Merge pull request #21537 from Snuffleupagus/getComponents-MathClamp

Use the `MathClamp` helper in the `PDFImage.prototype.getComponents` method
This commit is contained in:
Tim van der Meij 2026-07-04 14:21:54 +02:00 committed by GitHub
commit 36835d919d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -579,13 +579,7 @@ class PDFImage {
}
const remainingBits = bits - bpc;
let value = buf >> remainingBits;
if (value < 0) {
value = 0;
} else if (value > max) {
value = max;
}
output[i] = value;
output[i] = MathClamp(buf >> remainingBits, 0, max);
buf &= (1 << remainingBits) - 1;
bits = remainingBits;
}