From fcefa8f990f3cb00e9a3efcad94693c2d120a799 Mon Sep 17 00:00:00 2001 From: Bruno Salmon Date: Tue, 20 Aug 2024 12:29:08 +0100 Subject: [PATCH] Added GraphicsContext imageSmoothing support --- .../javafx/scene/canvas/GraphicsContext.java | 28 +++++++++++++++++++ .../gwtj2cl/html/HtmlGraphicsContext.java | 9 ++++++ 2 files changed, 37 insertions(+) diff --git a/webfx-kit/webfx-kit-javafxgraphics-emul/src/main/java/javafx/scene/canvas/GraphicsContext.java b/webfx-kit/webfx-kit-javafxgraphics-emul/src/main/java/javafx/scene/canvas/GraphicsContext.java index ac5860b6a9..4c8840ff19 100644 --- a/webfx-kit/webfx-kit-javafxgraphics-emul/src/main/java/javafx/scene/canvas/GraphicsContext.java +++ b/webfx-kit/webfx-kit-javafxgraphics-emul/src/main/java/javafx/scene/canvas/GraphicsContext.java @@ -1263,4 +1263,32 @@ void drawImage(Image img, */ void applyEffect(Effect e); + /** + * Sets the image smoothing state. + * Image smoothing is an Image attribute + * used to enable or disable image smoothing for + * {@link #drawImage(javafx.scene.image.Image, double, double) drawImage(all forms)} + * as specified in the Rendering Attributes Table.
+ * If image smoothing is {@code true}, images will be scaled using a higher + * quality filtering when transforming or scaling the source image to fit + * in the destination rectangle.
+ * If image smoothing is {@code false}, images will be scaled without filtering + * (or by using a lower quality filtering) when transforming or scaling the + * source image to fit in the destination rectangle. + * + * @defaultValue {@code true} + * @param imageSmoothing {@code true} to enable or {@code false} to disable smoothing + * @since 12 + */ + void setImageSmoothing(boolean imageSmoothing); + + /** + * Gets the current image smoothing state. + * + * @defaultValue {@code true} + * @return image smoothing state + * @since 12 + */ + boolean isImageSmoothing(); + } diff --git a/webfx-kit/webfx-kit-javafxgraphics-peers-gwt-j2cl/src/main/java/dev/webfx/kit/mapper/peers/javafxgraphics/gwtj2cl/html/HtmlGraphicsContext.java b/webfx-kit/webfx-kit-javafxgraphics-peers-gwt-j2cl/src/main/java/dev/webfx/kit/mapper/peers/javafxgraphics/gwtj2cl/html/HtmlGraphicsContext.java index 1b2622350b..ddb7d111ce 100644 --- a/webfx-kit/webfx-kit-javafxgraphics-peers-gwt-j2cl/src/main/java/dev/webfx/kit/mapper/peers/javafxgraphics/gwtj2cl/html/HtmlGraphicsContext.java +++ b/webfx-kit/webfx-kit-javafxgraphics-peers-gwt-j2cl/src/main/java/dev/webfx/kit/mapper/peers/javafxgraphics/gwtj2cl/html/HtmlGraphicsContext.java @@ -767,4 +767,13 @@ public void applyEffect(Effect e) { Console.log("WARNING: HtmlGraphicsContext.applyEffect() not implemented"); } + @Override + public void setImageSmoothing(boolean imageSmoothing) { + ctx.imageSmoothingEnabled = imageSmoothing; + } + + @Override + public boolean isImageSmoothing() { + return ctx.imageSmoothingEnabled; + } }