Some fixes: output types, libraries, remote
[fanfix.git] / src / be / nikiroo / fanfix / reader / GuiReaderBook.java
index 782481c81a8a34104d50db0fd799b08c0bedf74a..2ae04b461d13bdd43cac911e0702190439d12cca 100644 (file)
@@ -381,18 +381,22 @@ class GuiReaderBook extends JPanel {
                BufferedImage resizedImage = null;
                String id = null;
 
-               if (meta.getLuid() != null) {
-                       id = meta.getUuid() + ".thumb_" + SPINE_WIDTH + "x" + COVER_WIDTH
-                                       + "+" + SPINE_HEIGHT + "+" + COVER_HEIGHT + "@" + HOFFSET;
-                       InputStream in = Instance.getCache().getFromCache(id);
-                       if (in != null) {
-                               try {
-                                       resizedImage = ImageUtils.fromStream(in);
-                                       in.close();
-                                       in = null;
-                               } catch (IOException e) {
-                                       Instance.syserr(e);
-                               }
+               String key = meta.getUuid();
+               if (key == null) {
+                       // a fake meta (a source)
+                       key = "source_" + meta.getSource();
+               }
+
+               id = key + ".thumb_" + SPINE_WIDTH + "x" + COVER_WIDTH + "+"
+                               + SPINE_HEIGHT + "+" + COVER_HEIGHT + "@" + HOFFSET;
+               InputStream in = Instance.getCache().getFromCache(id);
+               if (in != null) {
+                       try {
+                               resizedImage = ImageUtils.fromStream(in);
+                               in.close();
+                               in = null;
+                       } catch (IOException e) {
+                               Instance.syserr(e);
                        }
                }
 
@@ -426,7 +430,7 @@ class GuiReaderBook extends JPanel {
                                        ByteArrayOutputStream out = new ByteArrayOutputStream();
                                        ImageIO.write(resizedImage, "png", out);
                                        byte[] imageBytes = out.toByteArray();
-                                       InputStream in = new ByteArrayInputStream(imageBytes);
+                                       in = new ByteArrayInputStream(imageBytes);
                                        Instance.getCache().addToCache(in, id);
                                        in.close();
                                        in = null;