JDK-8204060 : [Canvas] Add API in GraphicsContext to control image smoothing
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: 8u131,9,openjfx11
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-05-30
  • Updated: 2021-04-29
  • Resolved: 2018-11-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 Other
8u212Fixed openjfx12Fixed
Related Reports
CSR :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
Need a mechanism to display and zoom images of type javafx.scene.image.Image at an application without smoothing.
Usage of a function: 
                  public void drawImage(Image img, double sx, double sy, double sw, double sh, double dx, double dy, double dw, double dh) 
                        of class javafx.scene.canvas.GraphicsContext 

results to a smoothing of original image when using different zoom levels. At an application it is essential to see the original content of an image. 
So, is there a way to disable that smoothing and any other filtering? 
Reloading the image should not be required. 

Comments
Changeset: 731f47bbd29a Author: arapte Date: 2018-11-30 11:08 +0530 URL: http://hg.openjdk.java.net/openjfx/jfx-dev/rt/rev/731f47bbd29a Reviewed-by: kcr, aghaisas This check-in was incomplete, test resource image files was missed while check in. It is corrected in JDK-8214508.
30-11-2018

+1 I have also reviewed the CSR. Please move the CSR to the Finalize state as soon as possible. Then, once it is Approved, you can push the code.
29-11-2018

This looks good to me. +1.
27-11-2018

Hi Kevin, here is the updated webrev: http://cr.openjdk.java.net/~arapte/fx/8204060/webrev.03/
21-11-2018

Can you please post a new webrev? I see that you have addressed my comments about the docs in the patch attached to the CSR, but it is not yet reflected in an updated webrev.
21-11-2018

As mentioned on the list, this will need a CSR. The API additions look fine and should go into the CSR along with the diffs for all of the javadoc comments. One comment on the doc changes. I see a three changes of the following form: @@ -1606,11 +1632,11 @@ * with the current fill paint attribute. * A {@code null} text value will be ignored. * <p> * This method will be affected by any of the * <a href="#comm-attr">global common</a>, - * <a href="#fill-attr">fill</a>, + * <a href="#fill-attr">fill</a> * or <a href="#text-attr">text</a> * attributes as specified in the * <a href="#attr-ops-table">Rendering Attributes Table</a>. * </p> * Please revert all three of these changes. Not only are they unrelated to the current fix, they are not desirable changes in the first place. The use of the Oxford comma was intentional and is preferred. I'll review the implementation later.
29-10-2018

Adding an automatic system test Please review the updated webrev.01: http://cr.openjdk.java.net/~arapte/fx/8204060/webrev.01/ Files modified in webrev.00 have no new changes in webrev.01. Addition: A test file "ImageSmoothingDrawTest.java" & an image file "image_smoothing_draw_test.png" The test passes on windows and mac, but fails on my Ubuntu 16.04 & 14.04 VM. Robot fails to pick correct pixel color. I suspect it is to be problem of VM and robot. Even the existing test "test.robot.javafx.scene.RobotTest" fails in color test.
25-10-2018

Please review the fix: http://cr.openjdk.java.net/~arapte/fx/8204060/webrev.00/ Issue: Images drawn using javafx.scene.canvas .GraphicsContext::drawImage() always apply filtering to the image. Solution: javafx.scene.canvas.GraphicsContext should provide an option to enable and disable smoothing. Verification: Verified build and graphics:test on Win7, Mac, Ubuntu16.04. No existing behavior should change as the default behavior is same i.e. filtering is enabled by default. A note about fix: Some part of the change is not required for fix. 1. Changes in SWPaint.java 2. PiscesRenderer.java : Line no: 284, 287, 291 3. JPiscesRenderer.c : Line no: 249, 272 => These changes are related to method PiscesRenderer.java::setTexture(). => The changes add the new boolean linearFiltering property of SWTexture along with the existing texture properties. Rest changes are required for the fix.
23-10-2018