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

Graphics.drawImage() does not notify ImageObserver

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 5.0
    • 1.4.0, 5.0
    • docs
    • b26
    • generic, sparc
    • generic, solaris_7
    • Verified

      Name: atR10191 Date: 01/03/2002


      specifications for methods
      public abstract boolean drawImage(Image img, ... ,ImageObserver observer)
      of class Graphics states
      "...
      If the image has not yet been completely loaded, then drawImage returns false.
      As more of the image becomes available, the process that draws the image
      notifies the specified image observer".
      The example below shows that after first call of drawImage(), following
      calls of the method do not cause observer to be notified, when Image
      is animated image.
      ============ Test56.java ==============================================
      import java.awt.*;
      import java.awt.image.*;

      public class Test56 {
          public static void main(String argv[]) {
              Test56 test = new Test56();
              test.testRun();
              System.out.println("OKAY");
              System.exit(0);
          }
          void testRun(){
              Frame frm = new Frame();
              frm.show();
       
              frm.setSize(300, 300);
              Graphics g = frm.getGraphics();

              int w = 50;
              int h = 50;
              int size = w * h;
              int[] pix = new int[size];

              int value = frm.getBackground().getRGB();
              for (int i = 0; i <size; i++) {
                  pix[i] = value;
              }

              MemoryImageSource src = new MemoryImageSource(w, h, pix, 0, w);
              src.setAnimated(true);

              Image img = frm.createImage(src);
              MediaTracker tracker = new MediaTracker(frm);

              tracker.addImage(img, 0);
              MyImageObserver observer = new MyImageObserver();

              g.drawImage(img, 0, 0, new Container());

              if (!g.drawImage(img, 1, 1, observer)) {
                  try {
                      tracker.waitForAll();
                  } catch (InterruptedException e) {
                       System.out.println("unable to load image");
                       System.exit(1);
                  }
                  if (!observer.bImageUpdateWasCalled) {
                       System.out.println("ImageObserver was not notified " +
                           "by time when image was completely loaded");
                       System.exit(1);
                  }
              }
          }
      }

      class MyImageObserver extends Container {
          boolean bImageUpdateWasCalled = false;

          public boolean imageUpdate(Image img, int infoflags, int x,
                                     int y, int width, int height) {
              bImageUpdateWasCalled = true;
              return super.imageUpdate(img, infoflags, x, y, width, height);
          }
      }
      ======== end of Test56.java ==========================================
      ======== output of Test56 ==========================================
      ImageObserver was not notified by time when image was completely loaded
      ======== end of output of Test56 ==========================================
      ======================================================================</TEXTAREA>
      </td>
                          </tr>
                          <TR>
                            <TD colspan="2" bgcolor="#BFBFBF"> </td>
                          </tr>

      <a name="comments"></a>
                          <!-- COMMENTS -->
                          <TR>
                            <TD bgcolor="#BFBFBF" align="left" valign="bottom" height="24">
      <img src="https://central.sun.net/https%3A//swbtres.central.sun.com%3A443/bugz/images/dot.gif" width="10">Comments
      </td>
                            <TD bgcolor="#BFBFBF" align="left" valign="bottom" height="24">
      <!-- BEGIN:TBR Mohan
        <A href="javascript:doDateStampSubmit(document.editbug_general, 'comments');"><font size="-1">[ Date Stamp ]</font></A>
      <img src="https://central.sun.net/https%3A//swbtres.central.sun.com%3A443/bugz/images/dot.gif" width="18">
      END:TBR -->
      <A href="javascript:doFullPageSubmit(document.editbug_general, 'comments');"><font size="-1">[ Full Page ]</font></a>
      <img src="https://central.sun.net/https%3A//swbtres.central.sun.com%3A443/bugz/images/dot.gif" width="22">
      <FONT size="-1" color="darkblue">--- Enter SUN Proprietary data here ---</font>
      </td>
                          </tr>

                          <TR>
                            <TD bgcolor="#BFBFBF" colspan="2" nowrap align="left">
      <img src="https://central.sun.net/https%3A//swbtres.central.sun.com%3A443/bugz/images/dot.gif" width="5">
                              <TEXTAREA rows="6" cols="95" wrap="virtual" name="comments" align="left" bgcolor="white">

      Name: iaR10016 Date: 07/15/2003


      JCK1.5 test api/java_awt/Graphics/index.html#DrawImage[Graphics2025_14] fails with JDK1.5.0-b10 due to this bug.
      ======================================================================

      Name: iaR10016 Date: 11/05/2003


      JCK1.5-runtime (b07) api/java_awt/Graphics/index.html#DrawImage[Graphics2025_14] test
      is in the latest JCK1.5 known failure list because of this bug.
      Graphics class API Specification was changed in the latest tiger builds, so the test
      should be updated to meet new Specification requirenments.
      I have filed bug 4949095 about this issue.
      ###@###.###
      ======================================================================

      Name: yd153349 Date: 09/10/2004

      Remove ###@###.### jck


      ======================================================================
      ###@###.### 2004-09-10

            kwalrathsunw Kathy Walrath (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: