mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 10:15:37 +02:00
Always enable smoothing when rendering downscaled image
and rely on the Interpolate flag only when the image is upscaled. Fixes #16273.
This commit is contained in:
parent
d1f494d68c
commit
b511878ba7
1 changed files with 9 additions and 9 deletions
|
@ -913,6 +913,14 @@ function composeSMask(ctx, smask, layerCtx, layerBox) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getImageSmoothingEnabled(transform, interpolate) {
|
function getImageSmoothingEnabled(transform, interpolate) {
|
||||||
|
// In section 8.9.5.3 of the PDF spec, it's mentioned that the interpolate
|
||||||
|
// flag should be used when the image is upscaled.
|
||||||
|
// In Firefox, smoothing is always used when downscaling images (bug 1360415).
|
||||||
|
|
||||||
|
if (interpolate) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
const scale = Util.singularValueDecompose2dScale(transform);
|
const scale = Util.singularValueDecompose2dScale(transform);
|
||||||
// Round to a 32bit float so that `<=` check below will pass for numbers that
|
// Round to a 32bit float so that `<=` check below will pass for numbers that
|
||||||
// are very close, but not exactly the same 64bit floats.
|
// are very close, but not exactly the same 64bit floats.
|
||||||
|
@ -921,15 +929,7 @@ function getImageSmoothingEnabled(transform, interpolate) {
|
||||||
const actualScale = Math.fround(
|
const actualScale = Math.fround(
|
||||||
(globalThis.devicePixelRatio || 1) * PixelsPerInch.PDF_TO_CSS_UNITS
|
(globalThis.devicePixelRatio || 1) * PixelsPerInch.PDF_TO_CSS_UNITS
|
||||||
);
|
);
|
||||||
if (interpolate !== undefined) {
|
return scale[0] <= actualScale && scale[1] <= actualScale;
|
||||||
// If the value is explicitly set use it.
|
|
||||||
return interpolate;
|
|
||||||
} else if (scale[0] <= actualScale || scale[1] <= actualScale) {
|
|
||||||
// Smooth when downscaling.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// Don't smooth when upscaling.
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const LINE_CAP_STYLES = ["butt", "round", "square"];
|
const LINE_CAP_STYLES = ["butt", "round", "square"];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue