+ // 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
+