Upload a problem with a large image size to an image. The bitmap is too large to be loaded into the texture

I have 270 x 2693 pixel images in a picture folder. When I try to set this image in imagview, I got a Bitmap too large to be loaded into the texture warning .

Images are perfectly installed on an android, 4.0 device, but do not install> 4.0.

Please help me solve this problem.

code

<ImageView android:id="@+id/imageView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:scaleType="fitXY" android:contentDescription="@string/name" android:src="@drawable/hindi" /> 

Here, Hindi is an image in a folder with the ability to move and is 270 x 2693 pixels in size.

+6
source share
3 answers

Problem

This problem is usually associated with either the maximum OpenGL texture size or the device’s memory. The complete error you get is probably something like

W / OpenGLRenderer (12681): the bitmap is too large to load into the texture (270x2693, max = 2048x2048)

Memory is usually a problem with a large-scale image, but in your case 270x2693 - 727110 pixels. If you are in RGBA, this is 4 bytes per pixel, so 727110 * 4 = 2908440 bytes, which is approximately 2.7 megabytes. This should fit any device.

So your problem is probably related to OpenGL. What can happen is that the Android device> 4.0 that you are testing discovers that your image is too large for OpenGL and resizes it for you, while older devices do not.

Edit:

In my case, the problem is that my image with a clearance of 640x1136 seems to automatically convert to an image size of 1280x2272 to fit my device with a huge screen. Which also causes the error message you have.

If this error is more included, it is related to the dpi resolution that is used to download the image. As you will find in the Android help system, the device will download an image relative to their dpi, which can change the size of the image loaded into memory.

Decision

  • You have no choice but to determine the size of the device, upload the image correctly.

    See how to load a large bitmap into memory .

  • You can also use different image sizes for different input points, which can be automatically selected from the “Suitable” folder on Android.

    See How to Maintain Screens for a description of how to configure the folder.

  • As indicated in others, use a smaller image or reduce its size.

Additional Information

I suggest you look there if you need multi-screen support .

Android also collects data that is updated every 7 days by the size of the screens among their users.

Also check out this interesting answer that points out a good website to understand the size of the image in memory.

Finally, if you are already using OpenGL in your application, take a look at this answer, which shows how to determine the maximum size of OpenGL texture .

+4
source

Why not reduce image size? If you do not want to do this, instead of specifying a bitmap image in XML, load it from the program code and scale it to fit the display. For more information on loading large bitmaps, see this guide .

+2
source

try using this code

 int[] maxTextureSize = new int[1]; GLES10.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, maxTextureSize, 0); 

maxTextureSize preserves the size limit for a decoded image such as 4096x4096, 8192x8192. Remember to run this piece of code in MainThread , or you will get zero.

0
source

All Articles