androidandroid-imageviewandroid-imageandroid-bitmap

"Bitmap too large to be uploaded into a texture"


I'm loading a bitmap into an ImageView, and seeing this error. I gather this limit relates to a size limit for OpenGL hardware textures (2048x2048). The image I need to load is a pinch-zoom image of about 4,000 pixels high.

I've tried turning off hardware acceleration in the manifest, but no joy.

    <application
        android:hardwareAccelerated="false"
        ....
        >

Is it possible to load an image larger than 2048 pixels into an ImageView?


Solution

  • All rendering is based on OpenGL, so no you can't go over this limit (GL_MAX_TEXTURE_SIZE depends on the device, but the minimum is 2048x2048, so any image lower than 2048x2048 will fit).

    With such big images, if you want to zoom in out, and in a mobile, you should setup a system similar to what you see in google maps for example. With the image split in several pieces, and several definitions.

    Or you could scale down the image before displaying it (see user1352407's answer on this question).

    And also, be careful to which folder you put the image into, Android can automatically scale up images. Have a look at Pilot_51's answer below on this question.