Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bitmap too large to be uploaded into a texture in some phones

I have image with 543*6423 resolution, I want to display it in all devices. It is displaying in few of android phones which allows the high resolution. I tried with

android:hardwareAccelerated="false"

This is my java code for android client

File storagePath =Environment.getExternalStoragePublicDirectory(
                    Environment.DIRECTORY_DOWNLOADS+
                    "abc.png");
            InputStream is = this.getContentResolver().openInputStream(Uri.fromFile(storagePath)); 
            Bitmap b = BitmapFactory.decodeStream(is, null, null); 
            is.close(); 
            image.setImageBitmap(b);

This worked in my mobile (sony xperia) but few other phones are not displaying it. Please help me how can I display this image independent of screen resolution.

Thanks, Aman

like image 240
Amandeep Singh Avatar asked Mar 03 '13 04:03

Amandeep Singh


2 Answers

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().

like image 155
FahneImWind Avatar answered Oct 17 '22 08:10

FahneImWind


try with

android:hardwareAccelerated="false" 
android:largeHeap="true"
like image 37
NgSon Avatar answered Oct 17 '22 08:10

NgSon