5

I have a custom ImageView that covers the whole screen. The image is sourced from one of the drawable folders, drawable-hdpi, drawable-xhdpi, drawable-sw600dp etc. and there are separate images for each density bucket.

So far, the application works fine on xhdpi and hdpi devices, the problem occurs when I test it on a Nexus 7. The image stored in the sw600dp folder has a size of 1600x1600 and should be enough to directly draw on the screen (without scaling), however when I run the app, the screen turns out to be completely blank and I get the following warning:

03-04 16:25:46.338: W/OpenGLRenderer(25457): Bitmap too large to be uploaded into a texture (2130x2130, max=2048x2048)

For some reason the 1600x1600 bitmap is scaled to 2130x2130 although I have not manually scaled it anywhere (no matrix postscale or scaleX/scaleY applied)

Any thoughts on why this might be happening? Please provide a solution along with the explanation of why this might be happening.

Soham
  • 4,940
  • 3
  • 31
  • 48

2 Answers2

7

Since Nexus 7 is tvdpi, it scales every image to 1.33 of the original value. So 1600 becomes (1600*1.33)= ~2130. It wont display it from the sw600dp folder.

More Info:-http://developer.android.com/guide/practices/screens_support.html

You can use the same image which you are using for every other 7 inch tablet ( i.e. of resolution 1024*600 ).

Kunalxigxag
  • 728
  • 4
  • 12
  • Thanks Kunal, that was an awesome answer, I indeed put the image in the drawable-tvdpi directory and it worked fine. Thanks a lot. Lesson: drawable-sw600dp images are scaled when being displayed on a nexus 7 while a drawable-tvdpi will not. – Soham Apr 26 '13 at 19:16
0

I want to share some info about error you are getting..

According to Romain Guy (Android framework engineer):

When using hardware acceleration, there is a limit to the size of a texture. When you render a bitmap, it has to be uploaded to an OpenGL texture first. Your bitmap happens to be bigger than the maximum texture size on Xoom (2048x2048.) You need to use a smaller bitmap or split it into several bitmaps.

Other SO Links may be helpful to you : click here1, click here2

Git: click here

Update: This answer only tells why error is happening (becauseof texture size limit) sorry it's not a full answer for why 1600x1600 bitmap is scaled to 2130x2130!!

Community
  • 1
  • 1
LOG_TAG
  • 19,894
  • 12
  • 72
  • 105
  • I was aware of the limit, the question was why the 1600x1600 image is getting scaled to something above 2048x2048 – Soham Mar 11 '13 at 07:16