0

I am working on a complex UI design it is like circular wheel containing 10 icons in circular locus. i need to scale every icon as per the device resolution. Please have a look for specific code snippet:-

             if (displayWidth<=241) {
      bitmap = scaleBimtap(bitmap, 42, 39);
     }else if (displayWidth<=320) {
      bitmap = scaleBimtap(bitmap, 42, 39);
     }else if (displayWidth<=480) {
      bitmap = scaleBimtap(bitmap, 52, 44); 
     }else{
      bitmap = scaleBimtap(bitmap, 52, 44);
     }

HTC sensation is a 540X960 resolution device. So here is bitmap = scaleBimtap(bitmap, 52, 44); must be chosen in this case but this seems to be wrongly scaled and icons being displayed bigger then. What can i do for this to work.

Suresh Sharma
  • 1,826
  • 22
  • 41

1 Answers1

-1

Image from URL

imageView = new (ImageView)findViewById(R.id.myImage);

Get Image from Url

 Bitmap originalBitmap = getBitmapFromURL("http://www.chennaionline.com/home.JPG");

getBitmapFromURL method:

public static Bitmap getBitmapFromURL(String src) {
        try {
            URL url = new URL(src);
            HttpURLConnection connection = (HttpURLConnection) url
                    .openConnection();
            connection.setDoInput(true);
            connection.connect();
            InputStream input = connection.getInputStream();
            Bitmap myBitmap = BitmapFactory.decodeStream(input);
            return myBitmap;
        } catch (IOException e) {
            e.printStackTrace();
            return null;


}
}

Set bitmap

Bitmap bitmap = Bitmap.createScaledBitmap(originalBitmap, width,
                height, false);

imageView.setImageBitmap(bitmap);

Image from Resource File

Bitmap bitmap = ((BitmapDrawable)imageView.getDrawable()).getBitmap();
vinoth
  • 225
  • 3
  • 9