1

I have to implement a function that return to me a boolean if a bitmap or canvas is empty in Android.

How I can do this ?

I have tried this solution, but it doesn't work:

Bitmap emptyBitmap = Bitmap.createBitmap(myBitmap.getWidth(), myBitmap.getHeight(), myBitmap.getConfig());
if (myBitmap.sameAs(emptyBitmap)) {
    // myBitmap is empty/blank
}

How to check if a Bitmap is empty (blank) on Android

Another solution that I have considerated is:

Fastest way to check if an image is all white or all transparent

But I can't check every pixels, I spend so much time in this operation

Community
  • 1
  • 1
Mattia
  • 1,057
  • 2
  • 17
  • 33

1 Answers1

2

Sorry it's so late apparently the best way to do this is to create a bitmap and check if it's the same so boolean Res (bitmap.sameAs())

RBT
  • 24,161
  • 21
  • 159
  • 240
Martin Seal
  • 616
  • 2
  • 14
  • 32
  • Bitmap emptyBitmap = Bitmap.createBitmap(myBitmap.getWidth(), myBitmap.getHeight(), myBitmap.getConfig()); if (myBitmap.sameAs(emptyBitmap)) { // myBitmap is empty/blank } – Martin Seal Jan 08 '17 at 21:19