I have two goals I am trying to achieve.
- Scale a bitmap proportionately.
- Scale the same bitmap so that its height is equal to the device's height.
When attempting this, I find that on devices with less pixels, the scaling works fine, but on devices with more pixels, the scaling forces the bitmap to reach over the 4096x4096 pixel limit:
W/OpenGLRenderer(10630): Bitmap too large to be uploaded into a texture (4476x885, max=4096x4096)
As of now, I am using Bitmap.createBitmap(Bitmap source, int x, int y, int width, int height) to scale my bitmaps:
float conversion = (float) view.getHeight() / (float) originalBitmap.getHeight();
Matrix mat = new Matrix();
mat.postScale(conversion,conversion);
Bitmap resizedBitmap =
Bitmap.createBitmap(originalBitmap,0,0,originalBitmap.getWidth(),
originalBitmap.getHeight(), mat, false);
imageView.setImageBitmap(resize);
The above code coupled with the following xml allows for the bitmap to scale the entire screen:
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:scaleType="matrix"/>
If there are any other ways to proportionality scale a bitmap to the entire screen, I would greatly appreciate those suggestions.