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

D3D: Image not rendered correctly in applet after raster accessed [ATI Mobility Radeon Xpress 200]

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 6u10
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
      2d
    • Introduced In Version:
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0_10"
      Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
      Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]


      A DESCRIPTION OF THE PROBLEM :
      On Windows XP painting a component within an applet by copying a BufferedImage produces incorrect results if the image's raster has been accessed. The problem doesn't appear to occur on Windows Vista.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Compile the given applet source code.
      2. On Windows XP use the given HTML to view the applet in a browser (The problem is browser independent. I can reproduce it in IE6, Firefox 3 and Google Chrome.) The brower will display two instances of the test applet. The only difference between the two is that a parameter causes the second instance to access, but not alter, the BufferedImage raster.
      3. Drag another application window over the browser so as to cause the applet instances to repaint. Observe that the first instance paints correctly while the second doesn't.
      4. The source code also includes a main method so that it can be run as an application rather than an applet. No problem is exhibited when it is run as an application.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Both applet instances should paint a clean red square outline. I'd expect accessing the raster would make painting slower but not incorrect.
      ACTUAL -
      The lower left corner of the second applet instance isn't painted correctly.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.BorderLayout;
      import java.awt.Color;
      import java.awt.Dimension;
      import java.awt.Graphics;
      import java.awt.Rectangle;
      import java.awt.image.BufferedImage;
      import java.awt.image.DataBufferInt;

      import javax.swing.JApplet;
      import javax.swing.JFrame;
      import javax.swing.JPanel;

      public class BufferedImageTest extends JApplet
      {
          BufferedImage bufferedImage;
          boolean accessRaster;
          
          @Override
          public void init() {
              String param = getParameter("accessRaster");
              accessRaster = param != null && param.equalsIgnoreCase("true");
              setContentPane(createMainPanel(getWidth(), getHeight()));
          }
          
          private JPanel createMainPanel(int width, int height) {
              bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
              
              Rectangle rect = new Rectangle(0, 0, width, height);
              Graphics g = bufferedImage.createGraphics();
              g.setColor(Color.white);
              g.fillRect(rect.x, rect.y, rect.width, rect.height);
              g.setColor(Color.red);
              rect.grow(-5, -5);
              g.drawRect(rect.x, rect.y, rect.width, rect.height);
              g.dispose();

              if (accessRaster) {
                  DataBufferInt buffer = (DataBufferInt) bufferedImage.getRaster ().getDataBuffer();
                  int[] pixel = buffer.getData();
              }
              
              return new JPanel() {
                  public void paintComponent(Graphics g) {
                      g.drawImage(bufferedImage, 0, 0, null);
                  }
              };
          }
          
          @Override
          public String getAppletInfo() {
            return "Buffered Image Test";
          }

          public static void main(String[] args) {
              JFrame frame = new JFrame("Buffered Image Test");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              
              BufferedImageTest test = new BufferedImageTest();
              test.accessRaster = true;
              JPanel panel = test.createMainPanel(400, 400);
              panel.setPreferredSize(new Dimension(400, 400));
              frame.getContentPane().add(panel, BorderLayout.CENTER);
              frame.pack();
              frame.setVisible(true);
          }
      }

      /* HTML for displaying:
      <html>
      <body>
      <applet code="BufferedImageTest.class" width="400" height="400">
         <param name="accessRaster" value="false">
      </applet>
      <applet code="BufferedImageTest.class" width="400" height="400">
         <param name="accessRaster" value="true">
      </applet>
      </body>
      </html>

      */
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      The problem can be avoided by copying the BufferedImage whose raster has been accessed to another BufferedImage and using the latter image to paint the component.

        Attachments

          Activity

            People

            • Assignee:
              tdv Dmitri Trembovetski (Inactive)
              Reporter:
              ndcosta Nelson Dcosta (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: