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

Graphics.copyArea copies Image's incorrectly on 8 bit displays

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.3.0
    • client-libs
    • 2d
    • sparc
    • solaris_7



      Name: skT88420 Date: 08/26/99


      Run this program on an 8 plane deep (256 colour) display.
      The white background gradually fills up with junk and the text
      gradually disappears.

      This is perhaps bug 4188744 but 4188744 is meant to be fixed in
      1.2.2. There is no problem with 1.1.6 or on 24 plane displays.
      I see this problem in the following three versions of the jdk.

      java version "1.2.1"
      Solaris VM (build Solaris_JDK_1.2.1_03, native threads, sunwjit)
      java full version "Solaris_JDK_1.2.1_03"

      java version "1.2.2"
      Classic VM (build JDK-1.2.2-W, green threads, sunwjit)
      java full version "JDK-1.2.2-W"

      java version "1.3beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3beta-O)
      Java(TM) HotSpot Client VM (build 1.3beta-O-release, 1.3beta-O-release, interpreted mode)
      java full version "1.3beta-O"

      /***********/
      import java.awt.*;
      class CopyArea extends Frame
      {
      static public void main(String[] args)
      {
      new CopyArea();
      }
      CopyArea()
      {
      super("Appel");
      Can cv = new Can();
      cv.setSize(600, 600);
      add(cv, BorderLayout.CENTER);
      pack();
      show();
      }
      }

      class Can extends Canvas
      {
      private Image buffer = null;
      private Graphics buffer_gc;
      private int width;
      private int height;
      private int count = 200;
      Can()
      {
      super();
      }
      public void paint(Graphics g)
      {
      if (buffer == null)
      {
      Rectangle sz = getBounds();
      width = sz.width;
      height = sz.height;
      buffer = createImage(width, height);
      buffer_gc = buffer.getGraphics();
      buffer_gc.setFont(new Font("SansSerif", Font.BOLD, 12));
      buffer_gc.setColor(java.awt.Color.white);
      buffer_gc.fillRect(0, 0, sz.width, sz.height);
      buffer_gc.setColor(java.awt.Color.black);
      String m = "the white background gets darker with each step on a 8 plane display";
      buffer_gc.drawString(m, 2, buffer_gc.getFontMetrics().getMaxAscent() + 1);
      repaint(10);
      }
      g.drawImage(buffer, 0, 0, null);
      }
      public void update(Graphics g)
      {
      paint(g);
      buffer_gc.copyArea(0, 0, width - 1, height - 1, 1, 1);
      if (count-- > 0)
      repaint(400);
      }
      }
      (Review ID: 94452)
      ======================================================================

            tnguyensunw Thanh Nguyen (Inactive)
            skonchad Sandeep Konchady
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: