X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Fui%2FImageUtilsAwt.java;h=3acbe55f9c23ad482d9ecc533bcd0e138fa8c92d;hb=8d56ee50bae2bde706e6481ee9022a2a5162371e;hp=e1fcac7bd053e8b67d87a8ff5e95edb972bfffd0;hpb=805005449dacb1e7b825db63836bf100e472ddd0;p=nikiroo-utils.git diff --git a/src/be/nikiroo/utils/ui/ImageUtilsAwt.java b/src/be/nikiroo/utils/ui/ImageUtilsAwt.java index e1fcac7..3acbe55 100644 --- a/src/be/nikiroo/utils/ui/ImageUtilsAwt.java +++ b/src/be/nikiroo/utils/ui/ImageUtilsAwt.java @@ -23,7 +23,7 @@ public class ImageUtilsAwt extends ImageUtils { public void saveAsImage(Image img, File target, String format) throws IOException { try { - BufferedImage image = ImageUtilsAwt.fromImage(img); + BufferedImage image = fromImage(img); boolean ok = false; try { @@ -34,9 +34,16 @@ public class ImageUtilsAwt extends ImageUtils { } // Some formats are not reliable - // Second change: PNG + // Second chance: PNG if (!ok && !format.equals("png")) { - ok = ImageIO.write(image, "png", target); + try { + ok = ImageIO.write(image, "png", target); + } catch (IllegalArgumentException e) { + throw e; + } catch (Exception e) { + throw new IOException("Undocumented exception occured, " + + "converting to IOException", e); + } } if (!ok) { @@ -61,7 +68,7 @@ public class ImageUtilsAwt extends ImageUtils { * @throws IOException * in case of IO error */ - static public BufferedImage fromImage(Image img) throws IOException { + public static BufferedImage fromImage(Image img) throws IOException { InputStream in = new ByteArrayInputStream(img.getData()); int orientation;