X-Git-Url: http://git.nikiroo.be/?p=nikiroo-utils.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsupported%2FBasicSupport.java;h=f16cdc7b6453ac00753bb479850ab7eb2edcafc5;hp=66ba64d621ac82e1498d009367da08cb044f0f19;hb=16a81ef7656c5c692fb831927e75edde25dd77a0;hpb=5895a95876fe63e76e726ef7fc4c97efe2ebd5b1 diff --git a/src/be/nikiroo/fanfix/supported/BasicSupport.java b/src/be/nikiroo/fanfix/supported/BasicSupport.java index 66ba64d..f16cdc7 100644 --- a/src/be/nikiroo/fanfix/supported/BasicSupport.java +++ b/src/be/nikiroo/fanfix/supported/BasicSupport.java @@ -1,6 +1,5 @@ package be.nikiroo.fanfix.supported; -import java.awt.image.BufferedImage; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.File; @@ -25,7 +24,7 @@ import be.nikiroo.fanfix.data.MetaData; import be.nikiroo.fanfix.data.Paragraph; import be.nikiroo.fanfix.data.Paragraph.ParagraphType; import be.nikiroo.fanfix.data.Story; -import be.nikiroo.utils.ImageUtils; +import be.nikiroo.utils.Image; import be.nikiroo.utils.Progress; import be.nikiroo.utils.StringUtils; @@ -750,7 +749,7 @@ public abstract class BasicSupport { * @return the {@link Paragraph} */ private Paragraph makeParagraph(URL source, String line) { - BufferedImage image = null; + Image image = null; if (line.startsWith("[") && line.endsWith("]")) { image = getImage(this, source, line.substring(1, line.length() - 1) .trim()); @@ -817,7 +816,7 @@ public abstract class BasicSupport { * * @return the cover if any, or NULL */ - static BufferedImage getDefaultCover(String subject) { + static Image getDefaultCover(String subject) { if (subject != null && !subject.isEmpty() && Instance.getCoverDir() != null) { try { @@ -860,13 +859,18 @@ public abstract class BasicSupport { * @return the image if found, or NULL * */ - static BufferedImage getImage(BasicSupport support, URL source, String line) { + static Image getImage(BasicSupport support, URL source, String line) { URL url = getImageUrl(support, source, line); if (url != null) { + if ("file".equals(url.getProtocol())) { + if (new File(url.getPath()).isDirectory()) { + return null; + } + } InputStream in = null; try { in = Instance.getCache().open(url, getSupport(url), true); - return ImageUtils.fromStream(in); + return new Image(in); } catch (IOException e) { } finally { if (in != null) { @@ -918,11 +922,14 @@ public abstract class BasicSupport { } for (String ext : getImageExt(true)) { - if (absPath != null && new File(absPath + ext).exists()) { - url = new File(absPath + ext).toURI().toURL(); - } else if (relPath != null - && new File(relPath + ext).exists()) { - url = new File(relPath + ext).toURI().toURL(); + File absFile = new File(absPath + ext); + File relFile = new File(relPath + ext); + if (absPath != null && absFile.exists() + && absFile.isFile()) { + url = absFile.toURI().toURL(); + } else if (relPath != null && relFile.exists() + && relFile.isFile()) { + url = relFile.toURI().toURL(); } } } catch (Exception e) {