I was looking around stackoverflow about how this can be resolved. I have come to the following conclusions:
- It is based on an invidicual devices GL_MAX_TEXTURE_SIZE as per: "Bitmap too large to be uploaded into a texture" and jptsetung's answer and the underlying comments which also point to HW accelerated activity - how to get OpenGL texture size limit? which has Romain Guy give a solid understanding.
- You need to understand what sort data your device can handle.
When you do the following code, using 2 will quarter the size of the image.
BitmapFactory.Options ops = new BitmapFactory.Options();
opts.inSampleSize = 2;
this understanding comes from the notion that it will half the width and height, and therefore quarter the size.
- If you do not want to hardcode it, like i did. You can use GL_MAX_TEXTURE_SIZE to help determine what it is.
As a final note, what i did is that i took the imageview with the bitmap, and assigned it a MATRIX and then scaled the matric by
Matrix m = new Matrix();
m.postScale(scaleX,scaleY);
which allows you to get sample of the image to make it smaller, and then scale it up so that it maintains the same size. inSampleSize is the size of both scaleX and scaleY to make it scaled up.
Possible issue: Pixelation. depending on the size of the image, it wont be too bad, but you are going to see some of that.
This is to solve the constraints of the device. I would check to see how big the images width and height is, and if it is > GL_MAX_TEXTURE_SIZE, it will do some math and make it under the balue.
and i believe the next standard things would be:
...
Profit!