Use the MathClamp helper in the PDFImage.prototype.getComponents method

This commit is contained in:
Jonas Jenwald 2026-07-04 13:23:37 +02:00
parent 5b100c4509
commit be90aa4f46

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;
}