Note that there are some explanatory texts on larger screens.

plurals
  1. POIncrease image sizes get from cache android
    primarykey
    data
    text
    <p>Hi I download images from url &amp; save them in cache. Then load those images from cache into carousel view.</p> <p>but the problem is when phone resolution(720X1124) is high image size become small.</p> <p>Here I give the code of images save &amp; show them from cach...</p> <pre><code> private Bitmap getBitmap(String url) { File f=fileCache.getFile(url); //from SD cache Bitmap b = decodeFile(f); if(b!=null) return b; //from web try { Bitmap bitmap=null; URL imageUrl = new URL(url); HttpURLConnection conn = (HttpURLConnection)imageUrl.openConnection(); conn.setConnectTimeout(300000000); conn.setReadTimeout(300000000); conn.setInstanceFollowRedirects(true); InputStream inputstream=conn.getInputStream(); OutputStream outputstream = new FileOutputStream(f); Utils.CopyStream(inputstream, outputstream); outputstream.close(); conn.disconnect(); bitmap = decodeFile(f); return bitmap; } catch (Throwable ex){ ex.printStackTrace(); if(ex instanceof OutOfMemoryError) memoryCache.clear(); return null; } } public void getDimension(int width,int height){ widthScreen=width; heightScreen=height; } //decodes image and scales it to reduce memory consumption private Bitmap decodeFile(File f){ try { //decode image size final int IMAGE_MAX_SIZE = 120000000; // 1.2MP BitmapFactory.Options scaleOptions = new BitmapFactory.Options(); scaleOptions.inJustDecodeBounds = true; FileInputStream stream1=new FileInputStream(f); BitmapFactory.decodeStream(stream1,null,scaleOptions); stream1.close(); // find the correct scale value as a power of 2. int scale = 1; while (scaleOptions.outWidth / scale / 2 &gt;= widthScreen &amp;&amp; scaleOptions.outHeight / scale / 2 &gt;= heightScreen) { scale *= 2; } Bitmap bitmap = null; if (scale &gt; 1) { scale--; // scale to max possible inSampleSize that still yields an image // larger than target scaleOptions = new BitmapFactory.Options(); scaleOptions.inSampleSize = scale; bitmap = BitmapFactory.decodeStream(stream1, null, scaleOptions); int width=widthScreen; int height=heightScreen; double y=height; double x=width; Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, (int) x, (int) y, true); bitmap.recycle(); bitmap = scaledBitmap; System.gc(); } else { bitmap = BitmapFactory.decodeStream(stream1); } if((widthScreen&gt;=450)&amp;&amp; (heightScreen&gt;=750) ) { sample=1; } else{ sample=2; } //decode with inSampleSize BitmapFactory.Options scalOption = new BitmapFactory.Options(); scalOption.inSampleSize=sample; FileInputStream stream2=new FileInputStream(f); Bitmap bitMap=BitmapFactory.decodeStream(stream2, null, scalOption); stream2.close(); return bitMap; } catch (FileNotFoundException e) { } catch (IOException e) { e.printStackTrace(); } return null; } </code></pre> <p>how to increase the image sizes according phone resolution. I have tired more days to overcome this problem. But it doesn't work. So give me right instruction....... thanks............</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload