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

drawImage() doesn't draw byte indexed images into each other on win32.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.3.0
    • 1.2.0, 1.2.1, 1.2.2
    • client-libs
    • 2d
    • 1.3
    • generic, x86
    • generic, windows_nt



      Name: gsC80088 Date: 02/23/99


      The Graphics2D.drawImage() does not draw one
      BufferedImage.TYPE_BYTE_INDEXED image into another. It just
      fills an area on the destination image with the background
      color of the source image. If the
      images used are BufferedImage.TYPE_INT_RGB then drawImage()
      works correctly. The images have the same ColorModel.
      This seriously impacts our program, as we will be forced to
      use true-color images, which take up much more memory and
      disk space, if there is not a fix to this. I have only tried
      this on NT.

      Here is a program that will show the problem:
      <CODE>
      <PRE>
      import java.awt.*;
      import java.awt.image.*;

      public class ImageTest
      {
      private static final int IMAGE_TYPE = BufferedImage.TYPE_BYTE_INDEXED;
      public static void main(String argv[])
      {
      //Inner Image
      BufferedImage ii = new BufferedImage(100, 100, IMAGE_TYPE);
      //Outer Image
      BufferedImage oi = new BufferedImage(100, 100, IMAGE_TYPE);
      //Inner Graphics
      Graphics iig = ii.getGraphics();
      //Outer Graphics
      Graphics oig = oi.getGraphics();

      //Draw something on the inner image
      iig.drawLine(0, 0, 100, 100);
      iig.setColor(Color.blue);
      iig.drawRect(0, 0, 50, 50);
      //Draw the inner image onto the outer image.
      oig.drawImage(ii, 0, 0, null);
      //Do it again, just to show it doesn't work.
      oig.drawImage(ii, 0, 0, null);

      Frame f = new Frame();
      f.setTitle("Outer Image");
      f.setSize(200, 200);
      f.add(new ImageCanvas(oi));
      f.show();

      f = new Frame();
      f.setTitle("Inner Image");
      f.setSize(200, 200);
      f.add(new ImageCanvas(ii));
      f.show();
      } // main()
      } // class ImageTest

      /**
       * Shows an image.
       */
      class ImageCanvas extends Canvas
      {
      private Image m_i = null;

      public ImageCanvas(Image i)
      {
      m_i = i;
      }

      public void paint(Graphics g)
      {
      g.drawImage(m_i, 0, 0, null);
      }
      } // class ImageCanvas
      </PRE>
      </CODE>
      (Review ID: 54622)
      ======================================================================

            tdv Dmitri Trembovetski (Inactive)
            gstone Greg Stone
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: