final Picture p = ret;
if (!ret.isLoaded && callback != null)
new java.lang.Thread() { public void run() {
+ // get the InputStream for the image
+ InputStream in = null;
+ try { in = r.getInputStream(); }
+ catch (IOException 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" };
+ for (int i=0; i < exts.length && in == null; i++) {
+ newr = ref.addExtension(exts[i]);
+ try { in = newr.getInputStream(); }
+ catch (IOException f) { in = null; }
+ }
+ }
+ }
+
+ if (in == null) return; // could not find image
+
try {
- PushbackInputStream pbis = new PushbackInputStream(r.getInputStream());
+ PushbackInputStream pbis = new PushbackInputStream(in);
int firstByte = pbis.read();
if (firstByte == -1) throw new JSExn("empty stream reading image");
pbis.unread(firstByte);
Log.log(this, e);
}
} }.start();
+
return ret;
}
}