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

Blur effects no longer provide a side effect of using IDENTITY transform for inputs




      I've been testing out Java 8u20 Early Access, and I've found a serious issue in the way that Effects and Transforms are applied, which can hopefully be fixed before general availability, since it directly affects my company's product.

      The bug is that when you have a Node that has both a Scale transformation and a blur Effect applied to it, the Scale is ALWAYS applied FIRST now, and then the blur Effect is always applied to the scaled down result.

      This is happening even if you apply the Blur Effect to the node itself, and then apply the Scaling transform to a Group that contains the Node.

      This is a huge problem for my company, because our JavaFX product uses a BoxBlur effect as a form of anti-aliasing on images, prior to scaling them down.

      We are developing a tool that can view and edit pages in PDF files. This involves taking large image files containing text and placing them on an ImageView. We want to apply the BoxBlur effect to the ImageView and THEN scale the blurred image down. The user is able to scale the image in and out, so we adjust the Blur distance on the fly accordingly. Until Java 8u20 this worked beautifully, and made the text readable even when zoomed far out. In Java 8u20, however, it's impossible to do what we need, and the text is an unreadable mess no matter what we do.


      Here's a simple sample program that illustrates the problem:

          public void start(Stage primaryStage) {
              Text text = new Text("Here Is Some Sample Text. Here Is Some Sample Text\nHere Is Some Sample Text. Here Is Some Sample Text");
              text.setFont(Font.font("Courier New", 72));
              Image unblurredTextImage = text.snapshot(null, null);
              text.setEffect(new BoxBlur(5, 5, 1));
              Image preBlurredTextImage = text.snapshot(null, null);
              ImageView scaledOnlyImageView = new ImageView(preBlurredTextImage);
              scaledOnlyImageView.getTransforms().add(new Scale(.2, .2));
              ImageView scaledAndBlurredImageView = new ImageView(unblurredTextImage);
              scaledAndBlurredImageView.setEffect(new BoxBlur(5, 5, 1));
              scaledAndBlurredImageView.getTransforms().add(new Scale(.2, .2));
              VBox root = new VBox();
              root.getChildren().addAll(new Label("What we should see:"), new Group(scaledOnlyImageView),
                      new Label("What we actually see:"), new Group(scaledAndBlurredImageView));
              Scene scene = new Scene(root);
              primaryStage.setTitle("Transform and Effect order bug demo");


        1. BlurSideEffect.java
          2 kB
        2. EffectsTransform-8u11.png
          44 kB
        3. EffectsTransform-8u20.png
          42 kB
        4. ManualMipmapTest.java
          5 kB
        5. ManualMipmapTest3.java
          7 kB
        6. ManualMipmapTest4.java
          12 kB

          Issue Links



              flar Jim Graham
              duke J. Duke (Inactive)
              1 Vote for this issue
              6 Start watching this issue