X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2Fui%2FGuiReaderCoverImager.java;h=8d5aaebcc73674c27f32d4e931c9d1ebae871445;hb=d66deb8d8b30cff6b54db352eef34a3508939f84;hp=0bbf82eb47c29dcaab4a4a3fdee38cf9a995e7c3;hpb=723647dd81e7e53b5404c95322a28c54c1d635df;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/reader/ui/GuiReaderCoverImager.java b/src/be/nikiroo/fanfix/reader/ui/GuiReaderCoverImager.java index 0bbf82e..8d5aaeb 100644 --- a/src/be/nikiroo/fanfix/reader/ui/GuiReaderCoverImager.java +++ b/src/be/nikiroo/fanfix/reader/ui/GuiReaderCoverImager.java @@ -129,6 +129,24 @@ class GuiReaderCoverImager { return generateCoverIcon(lib, GuiReaderBookInfo.fromMeta(meta)); } + /** + * The width of a cover image. + * + * @return the width + */ + static public int getCoverWidth() { + return SPINE_WIDTH + COVER_WIDTH; + } + + /** + * The height of a cover image. + * + * @return the height + */ + static public int getCoverHeight() { + return COVER_HEIGHT + HOFFSET; + } + /** * Generate a cover icon based upon the given {@link GuiReaderBookInfo}. * @@ -144,23 +162,22 @@ class GuiReaderCoverImager { BufferedImage resizedImage = null; String id = getIconId(info); - InputStream in = Instance.getCache().getFromCache(id); + InputStream in = Instance.getInstance().getCache().getFromCache(id); if (in != null) { try { resizedImage = ImageUtilsAwt.fromImage(new Image(in)); in.close(); in = null; } catch (IOException e) { - Instance.getTraceHandler().error(e); + Instance.getInstance().getTraceHandler().error(e); } } if (resizedImage == null) { try { Image cover = info.getBaseImage(lib); - resizedImage = new BufferedImage(SPINE_WIDTH + COVER_WIDTH, - SPINE_HEIGHT + COVER_HEIGHT + HOFFSET, - BufferedImage.TYPE_4BYTE_ABGR); + resizedImage = new BufferedImage(getCoverWidth(), + getCoverHeight(), BufferedImage.TYPE_4BYTE_ABGR); Graphics2D g = resizedImage.createGraphics(); try { @@ -187,14 +204,14 @@ class GuiReaderCoverImager { ImageIO.write(resizedImage, "png", out); byte[] imageBytes = out.toByteArray(); in = new ByteArrayInputStream(imageBytes); - Instance.getCache().addToCache(in, id); + Instance.getInstance().getCache().addToCache(in, id); in.close(); in = null; } } catch (MalformedURLException e) { - Instance.getTraceHandler().error(e); + Instance.getInstance().getTraceHandler().error(e); } catch (IOException e) { - Instance.getTraceHandler().error(e); + Instance.getInstance().getTraceHandler().error(e); } } @@ -209,7 +226,7 @@ class GuiReaderCoverImager { */ static public void clearIcon(GuiReaderBookInfo info) { String id = getIconId(info); - Instance.getCache().removeFromCache(id); + Instance.getInstance().getCache().removeFromCache(id); } /**