look at only subset of pixels to check for alpha

This commit is contained in:
Daniel Gultsch 2021-01-30 01:50:03 +01:00
parent 53a038d90e
commit ca496fd39f
1 changed files with 9 additions and 4 deletions

View File

@ -18,6 +18,7 @@ import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.os.ParcelFileDescriptor;
import android.os.SystemClock;
import android.provider.MediaStore;
import android.provider.OpenableColumns;
import android.system.Os;
@ -223,8 +224,12 @@ public class FileBackend {
}
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;
}