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

PixelGrabber fails when applied to a BufferedImage

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.2.0
    • 1.2.0
    • client-libs
    • 2d
    • 1.2beta4
    • generic, x86, sparc
    • generic, solaris, windows_nt
    • Not verified



      Name: dgC58589 Date: 01/08/98


      /*
        As illustrated below, PixelGrabber applied to a BufferedImage fails with
        a NullPointerException:

        java.lang.NullPointerException:
              at java.awt.image.PixelGrabber.grabPixels(PixelGrabber.java:241)
              at java.awt.image.PixelGrabber.grabPixels(PixelGrabber.java:217)
              at bug_report4.init(bug_report4.java:35)
              at sun.applet.AppletPanel.run(AppletPanel.java:283)
              at java.lang.Thread.run(Thread.java:484)

        This bug manifests itself under at least JDK 1.2beta2 running on Win 95,
        but probably on all hardware platforms.

        The problem seems to be that BufferedImage.getSource() returns null (see
        BufferedImageSource.java line 813).
      */

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

      public class bug_report4 extends Applet {
        public void init()
          {
            BufferedImage result_image;
            int[] pixels = new int[64*64];
            PixelGrabber grabber;

            /* create a transparent in-memory image */
            result_image = GraphicsEnvironment.getLocalGraphicsEnvironment()
              .getDefaultScreenDevice().getDefaultConfiguration()
              .createCompatibleImage(64,64,Transparency.TRANSLUCENT);

            /* This is the problem (?) */
            System.out.println("result_image.getSource() = " +
              result_image.getSource());

            /* grab the pixels */
            grabber = new PixelGrabber(result_image, 0,0, 64,64, pixels, 0, 64);
            try {
              /**** This fails with a NullPointer exception ****/
              grabber.grabPixels();
            } catch (InterruptedException e) {
              System.out.println(e);
            }
            if ((grabber.getStatus() & ImageObserver.ABORT) != 0)
              System.out.println("Grabber failed");
          }
       }

      // <applet codebase="." code="bug_report4" height=100 width=100></applet>
      (Review ID: 22856)
      ======================================================================

            jehung Jeannette Hung (Inactive)
            dgrahamcsunw David Graham-cumming (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: