protected edu.cmu.cs.stage3.alice.core.Element load(java.io.InputStream istream, String ext) throws java.io.IOException { String codecName = edu.cmu.cs.stage3.image.ImageIO.mapExtensionToCodecName(ext); if (codecName == null) { throw new IllegalArgumentException("Unsupported Extension: " + ext); } java.io.BufferedInputStream bis; if (istream instanceof java.io.BufferedInputStream) { bis = (java.io.BufferedInputStream) istream; } else { bis = new java.io.BufferedInputStream(istream); } java.awt.Image image = edu.cmu.cs.stage3.image.ImageIO.load(codecName, bis); edu.cmu.cs.stage3.alice.core.TextureMap texture = new edu.cmu.cs.stage3.alice.core.TextureMap(); if (image instanceof java.awt.image.BufferedImage) { java.awt.image.BufferedImage bi = (java.awt.image.BufferedImage) image; if (bi.getColorModel().hasAlpha()) { texture.format.set(new Integer(edu.cmu.cs.stage3.alice.scenegraph.TextureMap.RGBA)); } } texture.name.set(plainName); texture.image.set(image); return texture; }
public java.util.Map getExtensionMap() { java.util.HashMap knownCodecPrettyNames = new java.util.HashMap(); knownCodecPrettyNames.put("BMP", "Windows Bitmap"); knownCodecPrettyNames.put("GIF", "Graphic Interchange Format"); knownCodecPrettyNames.put("JPEG", "Joint Photographic Experts Group format"); knownCodecPrettyNames.put("PNG", "Portable Network Graphics format"); knownCodecPrettyNames.put("TIFF", "Tagged Image File Format"); java.util.HashMap map = new java.util.HashMap(); String[] codecNames = edu.cmu.cs.stage3.image.ImageIO.getCodecNames(); for (int i = 0; i < codecNames.length; i++) { String prettyName = (String) knownCodecPrettyNames.get(codecNames[i].toUpperCase()); if (prettyName == null) { prettyName = codecNames[i]; } String[] extensions = edu.cmu.cs.stage3.image.ImageIO.getExtensionsForCodec(codecNames[i]); for (int j = 0; j < extensions.length; j++) { map.put(extensions[j].toUpperCase(), prettyName); } } return map; }
public static void storeThumbnail(String thumbFilename, java.awt.Image toStore, long timeStamp) { if (toStore != null) { String codec = "png"; java.io.File thumbFile = GalleryViewer.createFile(thumbFilename); if (thumbFile != null) { try { java.io.FileOutputStream fos = new java.io.FileOutputStream(thumbFile); java.io.BufferedOutputStream bos = new java.io.BufferedOutputStream(fos); java.io.DataOutputStream dos = new java.io.DataOutputStream(bos); edu.cmu.cs.stage3.image.ImageIO.store(codec, dos, toStore); dos.flush(); fos.close(); thumbFile.setLastModified(timeStamp); } catch (InterruptedException ie) { } catch (java.io.IOException ioe) { } } } }