2003/12/25 08:52:13
[org.ibex.core.git] / src / org / xwt / Picture.java
index 2bffb65..8538d39 100644 (file)
@@ -35,15 +35,19 @@ public class Picture {
             new java.lang.Thread() { public void run() {
                 // get the InputStream for the image
                 InputStream in = null;
-                try { in = r.getInputStream(); }
-                catch (IOException e) {
+                try {
+                    in = r.getInputStream();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                    Log.log(Picture.class, e);
+                    
                     in = null;
                     if (r instanceof Res.Ref) {
                         // add extensions to the resource, looking for the image
                         Res.Ref ref = (Res.Ref)r;
                         Res newr;
 
-                        String[] exts = new String[] { ".png", ".jpg", ".jpeg", ".gif" };
+                        String[] exts = new String[] { ".png", ".jpeg", ".gif" };
                         for (int i=0; i < exts.length && in == null; i++) {
                             newr = ref.addExtension(exts[i]);
                             try { in = newr.getInputStream(); }
@@ -51,8 +55,9 @@ public class Picture {
                         }
                     }
                 }
-
-                if (in == null) return; // could not find image
+        
+                // could not find image
+                if (in == null) { Log.log(Picture.class, "couldn't load image for resource " + r); return; }
 
                 try {
                     PushbackInputStream pbis = new PushbackInputStream(in);
@@ -63,6 +68,7 @@ public class Picture {
                     else if ((firstByte & 0xff) == 137)  PNG.load(pbis, p);
                     else if ((firstByte & 0xff) == 0xff) Platform.decodeJPEG(pbis, p);
                     else throw new JSExn("couldn't figure out image type from first byte");
+                    p.isLoaded = true;
                     Scheduler.add(callback);
                 } catch (Exception e) {
                     Log.log(this, "exception while loading image");