Reputation: 1174
I use setImageResource() to set background image to ImageView.
My device resolution is 1920x2246 480dpi, so I find a image which resolution is the same as the device. But I got this warning:
BitmapLimit: over bitmap size limit:android.graphics.Bitmap@6aad1ab, w = 1080, h = 2246, size = 9702752
Then I crop this image to 1920x923, but I still got this warning
BitmapLimit: over bitmap size limit:android.graphics.Bitmap@6aad1ab, w = 923, h = 1920, size = 7088672
I cannot google any information about this warning.
My image is put at drawable/xxhdip and I use android studio plugin "Android Drawable Import" to import and crop hdip, mdip and xhdip automatic.
I will be grateful if anyone can give me some advices!
Upvotes: 0
Views: 1070
Reputation: 273
I think its about size of image not height and width. You can compress this image to solve this problem
Bitmap original = BitmapFactory.decodeStream(getAssets().open("1024x768.jpg"));
ByteArrayOutputStream out = new ByteArrayOutputStream();
original.compress(Bitmap.CompressFormat.PNG, 100, out);
Bitmap decoded = BitmapFactory.decodeStream(new ByteArrayInputStream(out.toByteArray()));
Log.e("Original dimensions", original.getWidth()+" "+original.getHeight());
Log.e("Compressed dimensions", decoded.getWidth()+" "+decoded.getHeight());
Hope this helps
Upvotes: 1