From 1e534604266081f011786dfe9b27874bc3d030d4 Mon Sep 17 00:00:00 2001 From: ulrich <not disclosed> Date: Sat, 11 Mar 2017 15:52:02 +0000 Subject: [PATCH] Bildausgabe Miniaturansicht --- src/de/uhilger/wbx/Bild.java | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/de/uhilger/wbx/Bild.java b/src/de/uhilger/wbx/Bild.java index 6765204..d53b8ad 100644 --- a/src/de/uhilger/wbx/Bild.java +++ b/src/de/uhilger/wbx/Bild.java @@ -27,6 +27,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.io.OutputStream; import java.net.FileNameMap; import java.net.URLConnection; import javax.imageio.ImageIO; @@ -44,27 +45,33 @@ public static final String[] GRNAME = {"-w", "-k", "-m", "-g"}; public static final int[] GR = {120, 240, 700, 1200}; + public void writeImageStream(Image image, int gr, String mimeType, OutputStream out) throws InterruptedException, IOException { + ImageIO.write(getReducedImage(image, gr, mimeType), imgType(mimeType), out); + } + /** * * @param image * @param gr * @param mimeType - * @param oName Name der Originaldatei * @param vName Name der verkleinerten Datei * @throws InterruptedException * @throws IOException */ - public void writeImageFile(Image image, int gr, String mimeType, String oName, String vName) throws InterruptedException, IOException { + public void writeImageFile(Image image, int gr, String mimeType, String vName) throws InterruptedException, IOException { + ImageIO.write(getReducedImage(image, gr, mimeType), imgType(mimeType), new File(vName)); + } + + private BufferedImage getReducedImage(Image image, int gr, String mimeType) throws InterruptedException, IOException { + BufferedImage img; int q = 90; float sh = 0.f; - //String mimeType = photo.getMimetype(); - BufferedImage img; if(mimeType.contains("jpeg")) { img = getReducedImage(image, gr, gr, q, sh, false); } else { img = getReducedImage(image, gr, gr, q, sh, true); } - ImageIO.write(img, imgType(mimeType), new File(vName)); + return img; } /** -- Gitblit v1.9.3