git://git.nikiroo.be
/
fanfix.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Version 4.6.2
[fanfix.git]
/
src
/
be
/
nikiroo
/
utils
/
ui
/
ImageUtilsAwt.java
diff --git
a/src/be/nikiroo/utils/ui/ImageUtilsAwt.java
b/src/be/nikiroo/utils/ui/ImageUtilsAwt.java
index e1fcac7bd053e8b67d87a8ff5e95edb972bfffd0..148f8f57451141805c508de08e8254b0f3e2d407 100644
(file)
--- 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 {
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 {
boolean ok = false;
try {
@@
-34,9
+34,16
@@
public class ImageUtilsAwt extends ImageUtils {
}
// Some formats are not reliable
}
// Some formats are not reliable
- // Second chan
g
e: PNG
+ // Second chan
c
e: PNG
if (!ok && !format.equals("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) {
}
if (!ok) {
@@
-61,7
+68,7
@@
public class ImageUtilsAwt extends ImageUtils {
* @throws IOException
* in case of IO error
*/
* @throws IOException
* in case of IO error
*/
-
static publ
ic BufferedImage fromImage(Image img) throws IOException {
+
public stat
ic BufferedImage fromImage(Image img) throws IOException {
InputStream in = new ByteArrayInputStream(img.getData());
int orientation;
InputStream in = new ByteArrayInputStream(img.getData());
int orientation;
@@
-73,7
+80,15
@@
public class ImageUtilsAwt extends ImageUtils {
}
in.reset();
}
in.reset();
- BufferedImage image = ImageIO.read(in);
+ BufferedImage image;
+ try {
+ image = ImageIO.read(in);
+ } catch (IllegalArgumentException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new IOException("Undocumented exception occured, "
+ + "converting to IOException", e);
+ }
if (image == null) {
throw new IOException("Failed to convert input to image");
if (image == null) {
throw new IOException("Failed to convert input to image");