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

Regression: java.awt.image.ConvolveOp throws java.awt.image.ImagingOpException

    XMLWordPrintable

Details

    • 2d
    • b102
    • windows_7
    • Verified

    Backports

      Description

        FULL PRODUCT VERSION :
        java version " 1.7.0_25 "
        Java(TM) SE Runtime Environment (build 1.7.0_25-b16)
        Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)


        ADDITIONAL OS VERSION INFORMATION :
        Windows 7
        Windows XP
        Mac OS X 10.8.4

        A DESCRIPTION OF THE PROBLEM :
        Invoking java.awt.image.ConvolveOp#filter(java.awt.image.BufferedImage, java.awt.image.BufferedImage) with the source image a locally created image (i.e. new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB)) and the target image a device configuration compatible image (i.e. deviceConfiguration.createCompatibleImage(w, h, Transparency.TRANSLUCENT)) results in java.awt.image.ImagingOpException: Unable to convolve src image.

        This is a regression as this code works up to JDK 1.7.0_21! (Unfortunately, it does not seem possible to select that version in the regression field below.)

        Only Windows and Mac OS X JDKs seem to be affected.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run the attached test case.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        No output on system err.
        ACTUAL -
        A stacktrace is printed to system err.

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        java.awt.image.ImagingOpException: Unable to convolve src image
        at java.awt.image.ConvolveOp.filter(Unknown Source)
        at ConvolveOpTest$TestComponent.paintComponent(ConvolveOpTest.java:61)
        at javax.swing.JComponent.paint(Unknown Source)
        at javax.swing.JComponent.paintChildren(Unknown Source)
        at javax.swing.JComponent.paint(Unknown Source)
        at javax.swing.JComponent.paintChildren(Unknown Source)
        at javax.swing.JComponent.paint(Unknown Source)
        at javax.swing.JLayeredPane.paint(Unknown Source)
        at javax.swing.JComponent.paintChildren(Unknown Source)
        at javax.swing.JComponent.paintToOffscreen(Unknown Source)
        at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source)
        at javax.swing.RepaintManager$PaintManager.paint(Unknown Source)
        at javax.swing.RepaintManager.paint(Unknown Source)
        at javax.swing.JComponent.paint(Unknown Source)
        at java.awt.GraphicsCallback$PaintCallback.run(Unknown Source)
        at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
        at sun.awt.SunGraphicsCallback.runComponents(Unknown Source)
        at java.awt.Container.paint(Unknown Source)
        at java.awt.Window.paint(Unknown Source)
        at javax.swing.RepaintManager$3.run(Unknown Source)
        at javax.swing.RepaintManager$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
        at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
        at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
        at javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source)
        at javax.swing.RepaintManager.access$1000(Unknown Source)
        at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$200(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.awt.Color;
        import java.awt.Dimension;
        import java.awt.EventQueue;
        import java.awt.Graphics;
        import java.awt.Graphics2D;
        import java.awt.GraphicsConfiguration;
        import java.awt.Transparency;
        import java.awt.image.BufferedImage;
        import java.awt.image.ConvolveOp;
        import java.awt.image.ImagingOpException;
        import java.awt.image.Kernel;
        import javax.swing.JComponent;
        import javax.swing.JFrame;

        /**
         * Demonstrates java.awt.image.ImagingOpException: Unable to convolve src image
         * in JDK 1.7.0_25.
         */
        public class ConvolveOpTest {
          private void start() {
            final JFrame frame = new JFrame(ConvolveOpTest.class.getName());
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.getContentPane().add(new TestComponent());
            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
          }

          public static void main( String[] args ) {
            EventQueue.invokeLater(new Runnable() {
              public void run() {
                (new ConvolveOpTest()).start();
              }
            });
          }

          private static final class TestComponent extends JComponent {
            TestComponent() {
              setPreferredSize(new Dimension(480, 320));
            }

            protected void paintComponent( final Graphics g ) {
              super.paintComponent(g);

              float[] data = {1, 1, 1,};
              Kernel kernel = new Kernel(1, data.length, data);
              ConvolveOp convolveOp = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null);

              int size = 96;

              BufferedImage src = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
              Graphics2D gfx = src.createGraphics();
              gfx.setColor(Color.WHITE);
              gfx.fillRect(0, 0, size, size);
              gfx.dispose();

              GraphicsConfiguration gc = ((Graphics2D) g).getDeviceConfiguration();
              BufferedImage dst = gc.createCompatibleImage(size, size, Transparency.TRANSLUCENT);

              try {
                convolveOp.filter(src, dst);
              } catch (ImagingOpException e) {
                e.printStackTrace();
              }
            }
          }
        }

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

        CUSTOMER SUBMITTED WORKAROUND :
        Instead of using a locally created and a device compatible image either use two locally created or two device compatible images.

        Attachments

          Issue Links

            Activity

              People

                bae Andrew Brygin
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: