/** loads the image described by string str, possibly blocking for a network load */
static ImageDecoder getImage(String str, final Function callback) {
- boolean ispng = false;
if (str.indexOf(':') == -1) {
String s = str;
byte[] b = Resources.getResource(Resources.resolve(s + ".png", null));
- if (b == null) return null;
- return PNG.decode(new ByteArrayInputStream(b), str);
+ if (b != null) return PNG.decode(new ByteArrayInputStream(b), str);
+ b = Resources.getResource(Resources.resolve(s + ".jpeg", null));
+ if (b != null) return Platform.decodeJPEG(new ByteArrayInputStream(b), str);
+ return null;
} else {
Thread thread = Thread.currentThread();
mythread.setPriority(Thread.MIN_PRIORITY);
mythread.done.release();
try {
- // FIXME use mime types here, not extensions
- if (str.endsWith(".jpeg") || str.endsWith(".jpg"))
- str = "http://xmlrpc.xwt.org/jpeg2png/" + str.substring(str.indexOf("//") + 2);
-
HTTP http = new HTTP(str);
final HTTP.HTTPInputStream in = http.GET();
final int contentLength = in.getContentLength();
return ret;
}
};
-
+
if (str.endsWith(".gif")) return GIF.decode(is, str);
- else return PNG.decode(is, str);
+ else if (str.endsWith(".jpeg") || str.endsWith(".jpg")) return Platform.decodeJPEG(is, str);
+ else return PNG.decode(is, str);
} catch (IOException e) {
if (Log.on) Log.log(Box.class, "error while trying to load an image from " + str);
if (Log.on) Log.log(Box.class, "unable to load image " + s + " at " +
Context.enter().interpreterSourceFile + ":" + Context.enter().interpreterLine);
return;
- }
+ }
if (sizetoimage) syncSizeToImage();
dirty();
}