diff --git a/src/core/image.js b/src/core/image.js index 8aa2ae280..8861461d2 100644 --- a/src/core/image.js +++ b/src/core/image.js @@ -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; }