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

PixelGrabber problems

XMLWordPrintable

    • 1.0.2
    • x86, sparc
    • solaris_2.5, windows_95
    • Verified


      Customer bug report from ###@###.###:

      In trying to implement transparent objects, we enountered the following bugs
      in JDK Beta 2.0

          - PixelGrabber hangs occasionally
          - IndexColorMap has a bug in it. Try the following experiment: create
            an offscreen image, draw a white (255, 255, 255) rectangle into it.
            Then use PixelGrabber to get its pixels: they'll all be blue. Similarly,
            red pixels (255, 0, 0) have a similar problem (I don't remember the
            new color)
          - PixelGrabber does not work for framebuffers > 8-bit wide. Get mostly
            black pixels, occasionally, random colored pixels

      _____fp.bugs 3272_____: PixelGrabber hang
      This hang occurs under Solaris as well. Just get an imagefile for this applet. Contact hagen@eng for a ready-made html and image file.
      I would not be surprised if this bug had something to do with 1235466 or 1234421.
      /*
       *
       * Bug: When running this applet with the appletviewer application
       * using 'Version 1.0 Beta 2: Java(tm) Developers Kit' for Windows 95,
       * I can get a hang in PixelGrabber.grabPixels().
       *
       *
       * David Lipscomb
       * ###@###.###
       * 415 778-0931
       * mBED Software
       */

      import java.awt.image.*;
      import java.awt.*;
      import java.net.*;
      import java.applet.*;

      /**
       * Bug Class.
       */
      public class Bug extends Applet implements Runnable
      {
      Thread fRunner;
      Image fImage;

      static String IMAGEFILE = "imagefile";
      static final int SLEEPTIME = 20 /* miliseconds */;

      public void init()
      {
      fRunner = null;
      fImage = null;
      } /* init */

      public String getAppletInfo()
      {
      return new String("Pixel Grabber Test");
      } /* getAppletInfo */

      public void start()
      {
      fRunner = new Thread(this);
      fRunner.start();
      } /* start */

      public void stop()
      {
      fRunner.stop();
      } /* stop */

      public void run()
      {
      // Load up the image. And guarantee that it's in memory

      fImage = getImage(getDocumentBase(), getParameter(IMAGEFILE));
      prepareImage(fImage,this);
      while ((checkImage(fImage, this) & ImageObserver.ALLBITS) == 0)
      doSleep();

      // Loop forever
      while (true)
      {
      System.gc();
      doSleep();
      }

      } /* run */

      synchronized public boolean mouseDown(Event evt, int x, int y)
      {

      int width = fImage.getWidth(this);
      int height = fImage.getHeight(this);
      int pixels[] = new int[width*height];
      PixelGrabber pg = new
      PixelGrabber(fImage,0,0,width,height,pixels,0,width);

      try
      {
      while (true)
      {
      System.out.println("GRABBING STARTED");
      pg.grabPixels(); // *** HANGS HERE EVENTUALLY ***
      System.out.println("GRABBING COMPLETE");
      System.out.println("");
      /*
      if (pg.status() == 0)
      {
      System.out.println("Grab failed - retrying");
      pg = null;
      System.gc();
      doSleep();
      pg = new
      PixelGrabber(fImage,0,0,width,height,pixels,0,width);
      }
      else
      */
      break;
      }
      }
      catch (Exception e)
      System.out.println(e.toString());


      return super.mouseDown(evt, x, y);
      } /* mouseDown */

      synchronized public void paint(Graphics g)
      {
      g.drawString(getAppletInfo(), 10, 10);
      if (fImage != null)
      g.drawImage(fImage, 10, 10, this);

      } /* paint */


      private void doSleep()
      {
      try
      Thread.currentThread().sleep(SLEEPTIME);
      catch (InterruptedException e)
      ;
      } /* doSleep */


      } /* class Bug */

            flar Jim Graham
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: