JDK-8257503 : java.awt.image.RescaleOp produces incorrect results
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 8u261
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2020-11-30
  • Updated: 2021-03-12
  • Resolved: 2020-12-15
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
8-poolResolved
Related Reports
Duplicate :  
Description
ADDITIONAL SYSTEM INFORMATION :
java version "1.8.0_271"
Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.271-b09, mixed mode)

Bug occurred on OSX as well as on CentOS.

A DESCRIPTION OF THE PROBLEM :
The java.awt.image.RescaleOp class produces incorrect results for certain PNG images.

The operation is applied only to a subset of the source image, with greyed out background where a transparent background is expected.

With Oracle JDK 1.8.0_251 the results are still as expected.

This bug occurred with a PNG encoded source image with transparent background.


REGRESSION : Last worked in JDK 1.8.0_251 

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See https://github.com/agawecki/java-rescale-op-test



EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Rescale operation applied homogeneously to source image and leaves the transparent background intact.
ACTUAL -
The rescale operation is applied to a subset of the source image and garbles the transparent background.

---------- BEGIN SOURCE ----------
package test;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.awt.image.RescaleOp;
import java.io.File;

public class Main {

  public static void main(String[] args) {
    System.out.println(System.getProperty("java.version"));

    String imageFileName = "test.png";
    try {
      File imageFile = new File(imageFileName);
      BufferedImage image = ImageIO.read(imageFile);
      rescale(image, 1.0f, 50.0f);

      File outputFile = new File(imageFile.getParent(), "rescaled-" + imageFile.getName());
      ImageIO.write(image, "png", outputFile);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  static BufferedImage rescale(BufferedImage img,
                               float factor,
                               float offset) {
    RescaleOp rescaleOp = new RescaleOp(factor, offset, null);
    return rescaleOp.filter(img, img);
  }
}

---------- END SOURCE ----------

FREQUENCY : always



Comments
Resolving this bug as a Duplicate of JDK-8177393.
12-03-2021

Checked with attached testcase in Windows 10 OS, Issue is reproducible in 8u261 and 8u271 Test result: ======== 8u271: Fail 8u261: Fail 8u251: Pass 8 : Pass 11 : Pass 11.0.9:Pass 16ea: Pass
01-12-2020