Bitmap too large to be uploaded into a texture
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.
Android. W/OpenGLRenderer: Bitmap too large to be uploaded into a texture
It depends on both hardware and software. You can query at runtime with a valid OpenGL context (see: Get OpenGL max texture size)
int[] maxTextureSize = new int[1];
GLES10.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, maxTextureSize, 0);
Note that the supported size might be smaller, depending on the format of the texture. For example, your hardware could also have a maximum texture size, in bytes, in addition to a maximum size in pixels. To check what texture size is supported, create a proxy texture (GL_PROXY_TEXTURE_2D
target, instead of GL_TEXTURE_2D
) with the size and format you want, and then query the texture size (width or height) with glGetTexLevelParameteriv()
. If your texture is too big, the size will be set to 0.
Bitmap too large to be uploaded into a texture
an image in the /drawable/
folder without any specification is considered to be the "default", that is for 1dp = 1px that is mpdi
, then because the device you're actually running is xxhdpi
that image get's scaled up during runtime.
The original image might be 960x1440, but the conversion from mdpi
to xxhdpi
is 3 times the size, so your 960x1440 becomes (3*960)x(3*1440) = 2880x4320, which is too large of a texture to apply to the hardware accelerated views.
so to fix that is actually pretty simple, you have two choices:
- move your image to
/drawable-nodpi/
that's simple, reduces the .apk size, but lower end devices might struggle to load such a big image. - create scaled images on all densities
mdpi
,hdpi
,xhdpi
,xxhdpi
to avoid runtime over-scaling and to have smaller images on older devices.
Bitmap too large to be uploaded into a texture in some phones
Your image is probably too large to be displayed on most devices. So you have to load a scaled down version of the image. Look at Loading Large Bitmaps Efficiently to see how to do this and calculate an appropriate sample size.
If you need the display width / height (in case of a full screen image) you can use getResources().getDisplayMetrics()
.
Related Topics
How to Add "Android Design Support Library" to Eclipse with Adt-Plugin
Firebase Sort by Points Depending on Date
Gradle 0.9.+/0.9.2 Error: Unable to Load Class 'Com.Android.Builder.Testing.Api.Deviceprovider'
Handling Keepsynced() While on Background on Android and with Fcm
Android Ble Bluetoothgatt.Writedescriptor() Return Sometimes False
Cordova Platform Add Android Not Working While Listing Android Targets
Android Screen Sizes in Pixels for Ldpi, Mdpi, Hpdi
Running Emulator After Building Android from Source
Android: Autocomplete Textview Similar to the Facebook App
How to Show Text in Android System Status Bar
Single Click and Double Click of a Button in Android
How to Calculate Phone's Movement in the Vertical Direction from Rest
Onnewintent() Lifecycle and Registered Listeners