From 49d5c1eb527d7c9663556d82291eff63cc95b560 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 1 Jul 2018 12:06:09 +0200 Subject: [PATCH] only look at inner 70% to calculate overlay --- .../eu/siacs/conversations/persistance/FileBackend.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java index 510b50225..ee3d40dff 100644 --- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java @@ -71,6 +71,8 @@ public class FileBackend { private XmppConnectionService mXmppConnectionService; + private static final float IGNORE_PADDING = 0.15f; + public FileBackend(XmppConnectionService service) { this.mXmppConnectionService = service; } @@ -710,9 +712,11 @@ public class FileBackend { * https://stackoverflow.com/a/3943023/210897 */ private boolean paintOverlayBlack(final Bitmap bitmap) { + final int h = bitmap.getHeight(); + final int w = bitmap.getWidth(); int record = 0; - for (int y = 0; y < bitmap.getHeight(); ++y) { - for (int x = 0; x < bitmap.getWidth(); ++x) { + for (int y = Math.round(h * IGNORE_PADDING); y < h - Math.round(h * IGNORE_PADDING); ++y) { + for (int x = Math.round(w * IGNORE_PADDING); x < w - Math.round(w * IGNORE_PADDING); ++x) { int pixel = bitmap.getPixel(x, y); if ((Color.red(pixel) * 0.299 + Color.green(pixel) * 0.587 + Color.blue(pixel) * 0.114) > 186) { --record;