Summary
Provide APIs in GraphicsContext to enable/disable image smoothing when an image is drawn using GraphicsContext.drawImage(all forms)
Problem
When an image is drawn using any of GraphicsContext.drawImage(all forms), the image is always drawn smooth by applying bi-linear interpolation. Currently this is default behavior, and a Programmer has no control of the image smoothing behavior.
Solution
- Provide APIs to control image smoothing behavior.
- Add an image attribute for image smoothing state and,
- Two APIs to control the state.
- IsImageSmoothing() : getter API
- setImageSmoothing(boolean) : setter API
- Webrevs under review : http://cr.openjdk.java.net/~arapte/fx/8204060/webrev.03
- Fix review discussion : https://bugs.openjdk.java.net/browse/JDK-8204060
- Fix proposal discussion : http://mail.openjdk.java.net/pipermail/openjfx-dev/2018-October/022689.html
Specification
Two APIs added to javafx.scene.canvas.GraphicsContext:
/**
* Sets the image smoothing state.
* Image smoothing is an <a href="#image-attr">Image attribute</a>
* used to enable or disable image smoothing for
* {@link #drawImage(javafx.scene.image.Image, double, double) drawImage(all forms)}
* as specified in the <a href="#attr-ops-table">Rendering Attributes Table</a>.<br>
* 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.<br>
* 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
*/
public void setImageSmoothing(boolean imageSmoothing) {
}
/**
* Gets the current image smoothing state.
*
* @defaultValue {@code true}
* @return image smoothing state
* @since 12
*/
public boolean isImageSmoothing() {
}
- The image smoothing attribute is added to the table "List of Rendering Attributes"
- Reference to existing doc: https://openjfx.io/javadoc/11/javafx.graphics/javafx/scene/canvas/GraphicsContext.html
- This doc change alters the rendering attributes table size, hence providing the doc change in GraphicsContext as attachment: 8204060_GraphicsContext_Doc.patch
- Entire fix is at webrev.03 : http://cr.openjdk.java.net/~arapte/fx/8204060/webrev.03
- csr of
-
JDK-8204060 [Canvas] Add API in GraphicsContext to control image smoothing
-
- Resolved
-