Revert "Fix getting of bitmap"

This commit is contained in:
Alexander Sytnyk 2017-12-04 14:12:29 +02:00
parent be98177d83
commit 40b743aeb0

View file

@ -190,16 +190,12 @@ public class SampleUtils {
} }
public static byte[] getDrawableAsByteArray(Drawable drawable) { public static byte[] getDrawableAsByteArray(Drawable drawable) {
Bitmap bitmap;
if (drawable instanceof BitmapDrawable) { if (drawable instanceof BitmapDrawable) {
bitmap = ((BitmapDrawable) drawable).getBitmap(); Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
} else if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) {
bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
} else {
bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
}
return getBitmapAsByteArray(bitmap); return getBitmapAsByteArray(bitmap);
} }
return null;
}
public static byte[] getBitmapAsByteArray(Bitmap bitmap) { public static byte[] getBitmapAsByteArray(Bitmap bitmap) {
int size = bitmap.getRowBytes() * bitmap.getHeight(); int size = bitmap.getRowBytes() * bitmap.getHeight();