From a09ef2bb5fa29d0749e1942bdb2d45262ace72bd Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Sun, 10 Mar 2019 17:22:05 +0100 Subject: [PATCH] fix cover issue --- .../nikiroo/fanfix/library/LocalLibrary.java | 25 +++++++++++-------- .../fanfix/reader/ui/GuiReaderBook.java | 3 +-- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/be/nikiroo/fanfix/library/LocalLibrary.java b/src/be/nikiroo/fanfix/library/LocalLibrary.java index 584fa1ed..50f9ac01 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 72af3f1f..dc275950 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 { -- 2.27.0