From: Niki Roo Date: Sun, 10 Mar 2019 16:22:05 +0000 (+0100) Subject: fix cover issue X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=a09ef2bb5fa29d0749e1942bdb2d45262ace72bd;p=fanfix-jexer.git fix cover issue --- diff --git a/src/be/nikiroo/fanfix/library/LocalLibrary.java b/src/be/nikiroo/fanfix/library/LocalLibrary.java index 584fa1e..50f9ac0 100644 --- a/src/be/nikiroo/fanfix/library/LocalLibrary.java +++ b/src/be/nikiroo/fanfix/library/LocalLibrary.java @@ -224,18 +224,23 @@ public class LocalLibrary extends BasicLibrary { File coverDir = new File(baseDir, source); if (coverDir.isDirectory()) { File cover = new File(coverDir, ".cover.png"); - InputStream in; - try { - in = new FileInputStream(cover); + if (cover.exists()) { + InputStream in; try { - sourceCovers.put(source, new Image(in)); - } finally { - in.close(); + in = new FileInputStream(cover); + try { + sourceCovers.put(source, new Image(in)); + } finally { + in.close(); + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + Instance.getTraceHandler().error( + new IOException( + "Cannot load the existing custom source cover: " + + cover, e)); } - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); } } diff --git a/src/be/nikiroo/fanfix/reader/ui/GuiReaderBook.java b/src/be/nikiroo/fanfix/reader/ui/GuiReaderBook.java index 72af3f1..dc27595 100644 --- a/src/be/nikiroo/fanfix/reader/ui/GuiReaderBook.java +++ b/src/be/nikiroo/fanfix/reader/ui/GuiReaderBook.java @@ -401,8 +401,6 @@ class GuiReaderBook extends JPanel { .getSourceCover(meta.getSource()); } - BufferedImage coverb = ImageUtilsAwt.fromImage(cover); - resizedImage = new BufferedImage(SPINE_WIDTH + COVER_WIDTH, SPINE_HEIGHT + COVER_HEIGHT + HOFFSET, BufferedImage.TYPE_4BYTE_ABGR); @@ -410,6 +408,7 @@ class GuiReaderBook extends JPanel { g.setColor(Color.white); g.fillRect(0, HOFFSET, COVER_WIDTH, COVER_HEIGHT); if (cover != null) { + BufferedImage coverb = ImageUtilsAwt.fromImage(cover); g.drawImage(coverb, 0, HOFFSET, COVER_WIDTH, COVER_HEIGHT, null); } else {