How to efficiently find out if a PNG only contains white and transparent pixels? My input pictures are largely transparent with a bit of handwritten notes on them. Recognition has to be very reliable. My current code loops all pixels once the bitmap is loaded, but it takes too long to execute. I'm looking for a better/faster solution.
public static boolean isEmpty(Bitmap bmp)
{
int[] pixels = new int[bmp.getWidth() * bmp.getHeight()];
bmp.getPixels(pixels, 0, bmp.getWidth(), 0, 0, bmp.getWidth(), bmp.getHeight());
for (int i : pixels)
{
if (!(Color.alpha(i) == 0 || (Color.blue(i) == 255 && Color.red(i) == 255 && Color.green(i) == 255)))
return false;
}
return true;
}