First, let me express my gratitude and congratulations to the blackdown
porting team.  Great job!

Second, I have run into a bug/issue regarding the createImage(int, int)
function in java.awt.component.  I call this function to create an
off-screen image to be used for double-buffering.  I get the following
exception:

Exception occurred during event dispatching:
java.lang.IllegalArgumentException: Raster IntegerInterleavedRaster:
width = 300 height = 200 #Bands = 3 #DataElements 1 xOff = 0 yOff = 0
dataOffset[0] 0 is incompatible with ColorModel DirectColorModel:
rmask=ff0000 gmask=ff00 bmask=ff amask=0
        at sun.awt.motif.MComponentPeer.createImage(Compiled Code)
        at java.awt.Component.createImage(Compiled Code)
        at ImageTest.update(Compiled Code)
        at sun.awt.motif.MComponentPeer.handleEvent(Compiled Code)
        at java.awt.Component.dispatchEventImpl(Compiled Code)
        at java.awt.Container.dispatchEventImpl(Compiled Code)
        at java.awt.Component.dispatchEvent(Compiled Code)
        at java.awt.EventQueue.dispatchEvent(Compiled Code)
        at java.awt.EventDispatchThread.run(Compiled Code)

I also get the following exception whenever I try to use a swing
component.  This particular one was from the SampleTree demo app
included in the jdk1.2:

Error loading L&F: java.lang.IllegalArgumentException: Raster
IntegerInterleavedRaster: width = 64 height = 64 #Bands = 3
#DataElements 1 xOff = 0 yOff = 0 dataOffset[0] 0 is incompatible with
ColorModel DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0
Exception in thread "main" java.lang.NullPointerException
        at java.util.Hashtable.get(Compiled Code)
        at javax.swing.UIDefaults.get(Compiled Code)
        at javax.swing.MultiUIDefaults.get(Compiled Code)
        at javax.swing.UIDefaults.getUIClass(Compiled Code)
        at javax.swing.UIDefaults.getUI(Compiled Code)
        at javax.swing.UIManager.getUI(Compiled Code)
        at javax.swing.JMenuBar.updateUI(Compiled Code)
        at javax.swing.JMenuBar.<init>(Compiled Code)
        at SampleTree.constructMenuBar(Compiled Code)
        at SampleTree.<init>(Compiled Code)
        at SampleTree.main(Compiled Code)

All of the code that generates these exceptions works just fine using
java 1.1 or java 1.2 on both the Win32 and Solaris versions of the jdk.
I am running Debian 2.0, with some libraries upgraded to 2.1 (slink).
My only thought is that I am running in 32bpp mode in X windows and that
may be causing problems with the offscreen images being incompatible
with the DirectColorModel used to decode the pixels (which assumes 24bpp
color and 8b of alpha).  Also, despite the exceptions, the image still
loads.  This, however, is not true for the swing exception, which kills
whichever thread is creating the swing component.  I have tried in 24bpp
mode, but I just get a jvm crash whenever it loads the image.  I have
attached my test program which creates a simple double-buffered panel
with an image painted on it.  Does anyone have any thoughts?  Is this a
bug in the java classes or in the jvm?  Should I report it to sun?
Thanks.

-Dave Green


import java.awt.*;
import java.awt.event.*;
import pong.common.ImageServer;
import honors.frame.ImagePanel;

public class ImageTest extends Panel {

  private Image myImage = null;
  private Image buffer = null;
  private Graphics pad = null;
  private boolean buffered = true;
   
  public ImageTest(String filename) {
    try {
      int n = Integer.parseInt(filename);
      myImage = ImageServer.getImage(n);
    } catch (Exception x) {
      myImage = Toolkit.getDefaultToolkit().getImage(filename);
    }
  }
  
  public void update(Graphics g) {
                if (buffered) {
      if (buffer == null) {
                        buffer = this.createImage(this.getSize().width, 
this.getSize().height);
                        pad = buffer.getGraphics();
                }
                paint(pad);
                  g.drawImage(buffer, 0, 0, this);
    } else {
      paint(g);
    }
        }
  
  public void paint(Graphics g) {
    g.setColor(Color.gray);
    g.fillRect(0, 0, 300, 200);
    g.drawImage(myImage, 0, 0, this);
  }
  
  public Dimension getPreferredSize() {
    return new Dimension(300, 200);
  }
  
  public static void main(String[] args) {
    if (args.length < 1) {
      System.out.println("please provide a file name");
      return;
    } 
    Frame f = new Frame("ImageTest");
    f.add(new ImageTest(args[0]));
    f.addWindowListener( new WindowAdapter() {
      public void windowClosing (WindowEvent w) { System.exit(0); } });
    f.pack();
    f.setVisible(true);
    f.repaint();
  }
  
}

Reply via email to