look at only subset of pixels to check for alpha

(cherry picked from commit ca496fd39fcc1ca11b66961d57212a76805160e0)

# Conflicts:
#	src/main/java/eu/siacs/conversations/persistance/FileBackend.java
This commit is contained in:
Daniel Gultsch 2021-01-30 01:50:03 +01:00 committed by Christian Schneppe
parent 7fc54e4cc9
commit d8a7d87a12

View file

@ -866,10 +866,13 @@ public class FileBackend {
return getUriForFile(mXmppConnectionService, file);
}
private static boolean hasAlpha(final Bitmap bitmap) {
for (int x = 0; x < bitmap.getWidth(); ++x) {
for (int y = 0; y < bitmap.getWidth(); ++y) {
final int w = bitmap.getWidth();
final int h = bitmap.getHeight();
final int yStep = Math.max(1, w / 100);
final int xStep = Math.max(1, h / 100);
for (int x = 0; x < w; x += xStep) {
for (int y = 0; y < h; y += yStep) {
if (Color.alpha(bitmap.getPixel(x, y)) < 255) {
return true;
}