look at only subset of pixels to check for alpha
This commit is contained in:
		
							parent
							
								
									53a038d90e
								
							
						
					
					
						commit
						ca496fd39f
					
				|  | @ -18,6 +18,7 @@ import android.net.Uri; | ||||||
| import android.os.Build; | import android.os.Build; | ||||||
| import android.os.Environment; | import android.os.Environment; | ||||||
| import android.os.ParcelFileDescriptor; | import android.os.ParcelFileDescriptor; | ||||||
|  | import android.os.SystemClock; | ||||||
| import android.provider.MediaStore; | import android.provider.MediaStore; | ||||||
| import android.provider.OpenableColumns; | import android.provider.OpenableColumns; | ||||||
| import android.system.Os; | import android.system.Os; | ||||||
|  | @ -223,8 +224,12 @@ public class FileBackend { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private static boolean hasAlpha(final Bitmap bitmap) { |     private static boolean hasAlpha(final Bitmap bitmap) { | ||||||
|         for (int x = 0; x < bitmap.getWidth(); ++x) { |         final int w = bitmap.getWidth(); | ||||||
|             for (int y = 0; y < bitmap.getWidth(); ++y) { |         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) { |                 if (Color.alpha(bitmap.getPixel(x, y)) < 255) { | ||||||
|                     return true; |                     return true; | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Daniel Gultsch
						Daniel Gultsch