JDK-8089202 : Image scaled down by more than 50% is not smooth
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: fx2.0
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2011-05-10
  • Updated: 2018-09-05
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.
Other
tbdUnresolved
Related Reports
Relates :  
Description
I have a company logo which is shown in several places in our app. In one place it is shown at approximately 30% size. Even though I have tried logo.setSmooth(true), the logo is shown with very jagged edges. I have experimented with image caching and a smooth caching hint as well.

When scaling down the logo to 30% size in Photoshop i get a perfectly smooth logo, but when loading a smooth PNG from Java FX and showing it scaled, it is clearly jagged.

The logo contains the letters "fe". I have attached images showing the original "fe" scaled down using a tool as well as the scaled result i get with Java FX.

Note that the logo is exported as a PNG with a transparent background to ensure the logo will blend correctly on top of the different backgrounds of the app. This means the logo contains semitransparent pixels at the edges of each letter - could this be what confuses your scaling algorithm?

The code I use to display the image is

		logoImage = Images.load("logo.png");
		logo = new ImageView(logoImage);
		logo.setX(2852);
		logo.setY(23);
		logo.setSmooth(true);
		logo.setCache(true);
		logo.setCacheHint(CacheHint.QUALITY);
		double logoScale = 0.29920051;
		logo.setScaleX(logoScale);
		logo.setScaleY(logoScale);
		getChildren().add(logo);
Comments
The following webrev is a brute force approach to simply enable mipmaps for all ImageView images - building on the mipmap support added for Mesh textures in RT-26108. http://cr.openjdk.java.net/~flar/RT-13296/webrev.prototype.00/ Unfortunately, it has a few issues which make it "not ready for prime time": - It only generates mipmaps for images under the "tiling limit" (4k x 4k by default) - It only smooths scaling on the hw pipelines (no support in sw and j2d) - It always generates mipmaps even if the image is never downscaled - No attempt to share textures when one use creates a mipmap version and another doesn't need it I'm publishing the prototype webrev/patch only for testing and investigative purposes.
25-11-2014

This same issue was perhaps the reason that some developers came up with a technique of combining a blur and a scale that unfortunately exploited an implementation detail in the Blur effects as reported in RT-38131.
05-08-2014

The primary problem here is that we only provide a Bilinear interpolation algorithm. More sophisticated algorithms can provide better results for "do it once and then reuse the results" types of situations which is the luxury that Photoshop has over the code in our SG renderer that is geared more towards "on the fly" techniques. Perhaps the best advancement we can make here and still provide decent "on the fly" results would be to add support for Mipmapping which is hardware accelerated in most cases and can maintain smoothness over a variety of "down-scale" factors.
05-08-2014

A work around which has worked for us is to export the logo from PhotoShop CS3 as a fxz file using the Java FX productivity suite and then loading it using the FXDLoader. This only works for graphics which are vector based, however. For image graphics this bug report still holds.
12-05-2011