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

fp.bugs 3646 ImageConsumer implementation gives GPF in Win32

XMLWordPrintable

    • 1.0.2
    • sparc
    • solaris_2.5
    • Not verified

         From: tmb
      This does not look like form output to me.


      Well, maybe I don't entirely understand how ImageConsumer is supposed
      to work (comments/corrections appreciated), but the code below
      actually causes a GPF under Windows95 and also returns an illegal
      index for an IndexColorModel, neither of which should happen.

      For our applications, this bug is extremely serious. So, a workaround
      or fix would be appreciated.

      Thomas.

      // This little program demonstrates several bugs in JDK-1.0:
      //
      // -- under 8bpp, Windows95, there is an exception from deep within Windows at (1)
      // -- under 16bpp or 32bpp, Windows95, this simply crashes with an "illegal operation"
      // -- under 8bpp, X11/Linux, it works and seems to do the right thing

      import java.lang.*;
      import java.awt.*;
      import java.awt.image.*;
      import java.util.Hashtable;

      class Printit implements ImageConsumer {
          boolean done = false;

          Printit(ImageProducer source) {
              source.startProduction(this);
              while(true) {
                  try Thread.currentThread().sleep(200); catch (Throwable e);
                  if(this.done) break;
              }
          }

          public void setProperties(java.util.Hashtable dummy) {}
          public void setColorModel(ColorModel dummy) {}
          public void setHints(int dummy) {}
          public void imageComplete(int dummy) {done = true;}
          public void setDimensions(int w,int h) {
              System.out.println("w,h: "+w+" "+h);
          }
          public void setPixels(int x,int y,int w,int h,
              ColorModel model,byte pixels[],int off,int scansize) {
              boolean is_index = (model instanceof IndexColorModel);
              for(int j=0;j<h;j++) {
                  int pp = off + scansize * j;
                  for(int i=0;i<w;i++) {
                      int pixel = pixels[pp++];
                      int rgb = model.getRGB(pixel); // (1)
                      System.out.println("byte "+(i+x)+" "+(j+y)+" "+Integer.toString(rgb,16));
                  }
              }
          }
          public void setPixels(int x,int y,int w,int h,
              ColorModel model,int pixels[],int off,int scansize) {
              for(int j=0;j<h;j++) {
                  int pp = off + scansize * j;
                  for(int i=0;i<w;i++) {
                      int pixel = pixels[pp++];
                      int rgb = model.getRGB(pixel);
                      System.out.println("int "+(i+x)+" "+(j+y)+" "+Integer.toString(rgb,16));
                  }
              }
          }
      }

      public class Bug1 extends Canvas {
          public void paint(Graphics g) {
              Image image = createImage(5,5);
              Graphics ig = image.getGraphics();
              ig.setColor(Color.white);
              ig.fillRect(0,0,1000,1000);
              ImageConsumer c = new Printit(image.getSource());
          }

          public static void main(String args[]) {
              Frame f = new Frame("Test");
              Bug1 c = new Bug1();
              c.resize(256,256);
              f.add("Center",c);
              f.pack();
              f.show();
          }
      }

            flar Jim Graham
            bhagen Benjamin Hagen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: