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

Images drawn at wrong location when partially covered by another window

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.2.2
    • client-libs
    • 2d
    • merlin
    • x86
    • windows_98



      Name: krT82822 Date: 02/27/2000


      27 Feb 2000, eval1127@eng -- as of kestrel build "U" on Solaris, this bug is not reproducible. However, as of build "T" on NT 4.0, the problem is reproducible if you
      block the image "from above" -- meaning, you move the "cover" frame completely over the image from the top, cover the image's full width for some percentage of
      its height. The image (as shown under 1.2.2) shifts veritically down, to draw "under" the cover. That is, it moves its (x, 0) position down to the (x, ymax) position
      of the cover box. Am filing a reference bug, just to make sure this fix is definitely in the newer kestrel win32 build.

      ========================

      [setting your PATH to include the JDK's "bin" subdir will work around this error below]
      Registry key 'Software\JavaSoft\Java Runtime Environment\CurrentVersion'
      has value '1.2', but '1.3' is required.
      Error: could not find java.dll
      Error: could not find Java 2 Runtime Environment.


      Graphics.drawImage() draws images at the wrong position when
      the repaint area is covered completely in one dimension (say vertical)
      and partially in another (say horizontal) by another window.

      I have tried virtually every Graphics/Graphics2D.drawImage()
      method, and this bug appears with each of them.

      1. Run the application class PaintingBug below.

      This app creates two frames, an Image frame and a Cover frame.
      An image will be continuously repainting in the Image frame.
       
      2. Drag the Cover frame downward over the repainting image in the
      Image frame, so that the repainting image is covered completely in the
      horizontal direction, but progressively (as you drag down) in the vertical
      direction.
       
      The image will draw incorrectly as you do this. Instead of remaining
      at its proper location the image will get pushed downward, although the
      bottom will be clipped by the clip region.

      3. Now drag the Cover frame downward over the repainting image so
      that it does not completely cover the left (or right) side of the image.

      The bug will not occur this time.

      4. Repeat steps 2 and 3 by dragging left-to-right insead of downward.
      The same results will occur.

      --------------------

      import java.awt.*;
      import java.awt.event.*;
      import java.awt.image.*;

      public class PaintingBug
        {
        // ================================== Properties

        // image - to be repeatedly painted in image frame
        static BufferedImage image;
        
        // imageFrame - continuously repaints an image
        static Frame imageFrame = new Frame()
          {
          public void paint(Graphics g)
            {
            ((Graphics2D) g).drawImage(image,null,100,100);
            repaint(100,100,50,50);
            }
          };

        // coverFrame - to be dragged over image frame to reveal bug
        static Frame coverFrame = new Frame();
        
        // applicationQuitter - performs exit when either window is closed
        static WindowListener applicationQuitter = new WindowAdapter()
          {
          public void windowClosing(WindowEvent e)
            { System.exit(0); }
          };
        
        // ================================== Main
        
        static public void main(String[] args)
      {
          // Create Image
          image = new BufferedImage(50,50,BufferedImage.TYPE_INT_ARGB);
          Graphics2D imageGraphics = (Graphics2D) image.getGraphics();
          imageGraphics.setColor(Color.darkGray);
          imageGraphics.fill(new Rectangle(0,0,50,50));
          imageGraphics.setColor(Color.red);
          imageGraphics.fill(new Rectangle(5,5,40,5));
          imageGraphics.setColor(Color.green);
          imageGraphics.fill(new Rectangle(5,40,40,4));
          imageGraphics.setColor(Color.blue);
          imageGraphics.fill(new Rectangle(5,10,5,30));
          imageGraphics.setColor(Color.yellow);
          imageGraphics.fill(new Rectangle(40,10,5,30));

          // Create Image Frame
      imageFrame.setTitle("Repainting Image");
      imageFrame.setBounds(100,250,250,250);
      imageFrame.addWindowListener(applicationQuitter);
      imageFrame.setVisible(true);

      // Create Cover Frame
      coverFrame.setTitle("Cover");
      coverFrame.setBounds(150,50,150,150);
      coverFrame.addWindowListener(applicationQuitter);
      coverFrame.setVisible(true);
          }
        }

      -------------
      (Review ID: 101755)
      ======================================================================

            flar Jim Graham
            kryansunw Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: