X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FBox.java;h=caa7c8ac305f556f64af8ab20453dfa4efac1d59;hb=4f7f0b92b26b48cd88f534c5ca29b5bce98929b2;hp=4cefc9e1937ab5189471334c921e96a8d4b5f431;hpb=9a5deead77ca4a9c25ba063cd88d4a7852465899;p=org.ibex.core.git diff --git a/src/org/xwt/Box.java b/src/org/xwt/Box.java index 4cefc9e..caa7c8a 100644 --- a/src/org/xwt/Box.java +++ b/src/org/xwt/Box.java @@ -408,13 +408,14 @@ public final class Box extends JSObject { /** 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(); @@ -427,10 +428,6 @@ public final class Box extends JSObject { 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(); @@ -461,9 +458,10 @@ public final class Box extends JSObject { 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); @@ -504,7 +502,7 @@ public final class Box extends JSObject { if (Log.on) Log.log(Box.class, "unable to load image " + s + " at " + Context.enter().interpreterSourceFile + ":" + Context.enter().interpreterLine); return; - } + } if (sizetoimage) syncSizeToImage(); dirty(); }