Use ctx.filter unconditionally in the src/display/canvas.js file
It seems that the `@napi-rs/canvas` dependency has *basic* canvas-filter support, whereas the "old" `canvas` dependency didn't, hence we no longer need the Node.js-specific checks in the `src/display/canvas.js` file. Note that I've successfully tested the [`pdf2png` example](https://github.com/mozilla/pdf.js/tree/master/examples/node/pdf2png) with this patch applied and things appear to work as before.
This commit is contained in:
parent
a45f961a1c
commit
0c78b46184
@ -20,7 +20,6 @@ import {
|
||||
IDENTITY_MATRIX,
|
||||
ImageKind,
|
||||
info,
|
||||
isNodeJS,
|
||||
OPS,
|
||||
shadow,
|
||||
TextRenderingMode,
|
||||
@ -598,14 +597,9 @@ function resetCtxToDefault(ctx) {
|
||||
ctx.setLineDash([]);
|
||||
ctx.lineDashOffset = 0;
|
||||
}
|
||||
if (
|
||||
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
|
||||
!isNodeJS
|
||||
) {
|
||||
const { filter } = ctx;
|
||||
if (filter !== "none" && filter !== "") {
|
||||
ctx.filter = "none";
|
||||
}
|
||||
const { filter } = ctx;
|
||||
if (filter !== "none" && filter !== "") {
|
||||
ctx.filter = "none";
|
||||
}
|
||||
}
|
||||
|
||||
@ -2732,18 +2726,13 @@ class CanvasGraphics {
|
||||
|
||||
this.save();
|
||||
|
||||
if (
|
||||
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
|
||||
!isNodeJS
|
||||
) {
|
||||
// The filter, if any, will be applied in applyTransferMapsToBitmap.
|
||||
// It must be applied to the image before rescaling else some artifacts
|
||||
// could appear.
|
||||
// The final restore will reset it to its value.
|
||||
const { filter } = ctx;
|
||||
if (filter !== "none" && filter !== "") {
|
||||
ctx.filter = "none";
|
||||
}
|
||||
// The filter, if any, will be applied in applyTransferMapsToBitmap.
|
||||
// It must be applied to the image before rescaling else some artifacts
|
||||
// could appear.
|
||||
// The final restore will reset it to its value.
|
||||
const { filter } = ctx;
|
||||
if (filter !== "none" && filter !== "") {
|
||||
ctx.filter = "none";
|
||||
}
|
||||
|
||||
// scale the image to the unit square
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user