anticafe
anticafe

Reputation: 6892

How to display big image in Android

I see in this app: https://play.google.com/store/apps/details?id=com.appvl.haivl Sometimes it shows a big image with height larger than 2048px, such as: http://s4.haivl.com/data/photos2/20130623/ce07dcc8255b49b4a55a9cd265db9872/medium-571180dcb6e34226960556476e87483c-400.jpg (exactly 400x2645px, but its size is small - 211KB).

But when I make a demo to show this image, I always get "Bitmap too large to be uploaded into a texture" exception.

I'm sure there is way to show this image, because in the above app, it's possible.

Can anyone suggest how can I display such image without need to scale down it?

I'll appreciate much.

Upvotes: 2

Views: 6090

Answers (2)

anticafe
anticafe

Reputation: 6892

Thank you @MichaelShrestha for his link. Finally I found a way to display big image in Android by using BitmapRegionDecoder. Check this link for the sample code: https://stackoverflow.com/a/12161993/190309

Upvotes: 0

Zapek
Zapek

Reputation: 486

Turn off Hardware Acceleration.

Either on the Activity from the AndroidManifest.xml:

<activity ... />
<activity android:hardwareAccelerated="false" />

Or on the View displaying the image:

yourView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

Upvotes: 4

Related Questions