From da9cd9be8ec1a1a5d794846293fc10f89166a093 Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 03:04:55 +0900 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E6=9B=BF=E3=81=A8=E3=81=97=E3=81=A6St?= =?UTF-8?q?ore=E3=81=A7=E7=AE=A1=E7=90=86=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/source/file/impl/FileManagerImpl.java | 11 ++++++++++- .../java/one/nem/lacerta/utils/FeatureSwitch.java | 2 +- utils/src/main/java/one/nem/lacerta/utils/Store.java | 8 ++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/source/src/main/java/one/nem/lacerta/source/file/impl/FileManagerImpl.java b/source/src/main/java/one/nem/lacerta/source/file/impl/FileManagerImpl.java index 03f9332b..6077bf4e 100644 --- a/source/src/main/java/one/nem/lacerta/source/file/impl/FileManagerImpl.java +++ b/source/src/main/java/one/nem/lacerta/source/file/impl/FileManagerImpl.java @@ -304,7 +304,16 @@ public class FileManagerImpl implements FileManager { private void saveBitmapInternal(Bitmap bitmap, Path path) throws IOException { try { logger.debug("saveBitmapInternal", "path: " + path); - bitmap.compress(Bitmap.CompressFormat.PNG, Store.Scan.PNG_QUALITY, Files.newOutputStream(path)); + // Bitmapの長辺を1024pxにする + int width = bitmap.getWidth(); + int height = bitmap.getHeight(); + float scale = 1.0f; + if (width > height) { + scale = Store.Scan.MAX_RESOLUTION_LONG / width; + } else { + scale = Store.Scan.MAX_RESOLUTION_LONG / height; + } + bitmap.compress(new Store.Scan().COMPRESS_FORMAT, Store.Scan.QUALITY, Files.newOutputStream(path)); } catch (Exception e) { logger.error("saveBitmapInternal", e.getMessage()); throw new IOException("Failed to save bitmap"); diff --git a/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java b/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java index 718c1aa8..91aab3eb 100644 --- a/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java +++ b/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java @@ -8,7 +8,7 @@ public class FeatureSwitch { public static class FeatureMaster { public static boolean enableSearch = false; - public static boolean enableDebugMenu = false; + public static boolean enableDebugMenu = true; } public static class Vcs { diff --git a/utils/src/main/java/one/nem/lacerta/utils/Store.java b/utils/src/main/java/one/nem/lacerta/utils/Store.java index 78bc2511..e2695ee1 100644 --- a/utils/src/main/java/one/nem/lacerta/utils/Store.java +++ b/utils/src/main/java/one/nem/lacerta/utils/Store.java @@ -1,7 +1,11 @@ package one.nem.lacerta.utils; +import android.graphics.Bitmap; + public class Store { - public class Scan { - public static final int PNG_QUALITY = 60; + public static class Scan { + public Bitmap.CompressFormat COMPRESS_FORMAT = Bitmap.CompressFormat.JPEG; + public static final int QUALITY = 60; + public static final float MAX_RESOLUTION_LONG = 2048; } }