Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8139192

Custom ImageFilters return blank images in Java 8(.45) while working in 7

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • P3
    • Resolution: Fixed
    • 8u45, 9
    • 9
    • client-libs
    • b124
    • x86
    • linux_ubuntu

    Description

      FULL PRODUCT VERSION :
      1.8.0_45-b14, build 25.45.-b02, mixed mode

      ADDITIONAL OS VERSION INFORMATION :
      Ubuntu 15.04, Linux 3.19.0-15-generic, i686
      also Debian Wheezy

      A DESCRIPTION OF THE PROBLEM :
      Self-developed awt.image.ImageFilters are broken by Java8

      REGRESSION. Last worked in version 7u80

      ADDITIONAL REGRESSION INFORMATION:
      1.7.0_80-b15, build 24.80-b11, mixed mode

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      run mvn test with pom.xml:
      <?xml version="1.0"?>
      -<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"><modelVersion>4.0.0</modelVersion><groupId>de.mclassen</groupId><artifactId>imagefilterbug</artifactId><version>0.0.1-SNAPSHOT</version>-<dependencies>-<dependency><groupId>jhlabs</groupId><artifactId>imaging</artifactId><version>1.1</version></dependency>-<dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.11</version><scope>test</scope></dependency></dependencies></project>
      ACTUAL -
      empty image returned as filter result

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package imagefilterbug;

      import java.awt.Image;
      import java.awt.Toolkit;
      import java.awt.image.BufferedImage;
      import java.awt.image.FilteredImageSource;
      import java.awt.image.ImageFilter;
      import java.io.File;
      import java.io.IOException;

      import javax.imageio.ImageIO;
      import javax.swing.GrayFilter;

      import org.junit.Test;

      import com.jhlabs.image.WaterFilter;

      public class TestImageFilterBug {

          @Test
          public void testGrayFilter() throws IOException {
              Image image = ImageIO.read(new File("target/test-classes/flower.jpg"));
              ImageFilter grayFilter = new GrayFilter(true, 50);
              FilteredImageSource filtered = new FilteredImageSource(
                      image.getSource(), grayFilter);
              Image img = Toolkit.getDefaultToolkit().createImage(filtered);
              BufferedImage bufferedImage = new BufferedImage(img.getWidth(null),
                      img.getHeight(null), BufferedImage.TYPE_INT_ARGB);
              bufferedImage.getGraphics().drawImage(img, 0, 0, null);
              ImageIO.write(bufferedImage, "png", new File(
                      "target/test-classes/grayflower.png"));
          }

          @Test
          public void testWaterFilter() throws IOException {
              Image image = ImageIO.read(new File("target/test-classes/flower.jpg"));
              ImageFilter waterFilter = new WaterFilter();
              FilteredImageSource filtered = new FilteredImageSource(
                      image.getSource(), waterFilter);
              Image img = Toolkit.getDefaultToolkit().createImage(filtered);
              BufferedImage bufferedImage = new BufferedImage(img.getWidth(null),
                      img.getHeight(null), BufferedImage.TYPE_INT_ARGB);
              bufferedImage.getGraphics().drawImage(img, 0, 0, null);
              ImageIO.write(bufferedImage, "png", new File(
                      "target/test-classes/wateredflower.png"));
          }
      }

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

      Attachments

        Issue Links

          Activity

            People

              aghaisas Ajit Ghaisas
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: