0

We have an application, running on iOS and on Android. There is a function in app, that loads images to server with specific size ( < 2 mb) So before loading images to the server I need to resize it to reduce image size to successfuly load it to the server.

Is there any solution to make photos compatible with the most part of screen sizes (I need to show full size of image on the screen), running on Android and iOs (no iPad)?

thanks

Srikar Appalaraju
  • 71,928
  • 54
  • 216
  • 264
Zakharov Roman
  • 739
  • 3
  • 13
  • 31
  • Have you checked if there is something you can use from here: http://stackoverflow.com/questions/10413659/how-to-resize-image-in-android – Araw Sep 25 '12 at 09:55
  • Are you asking how to resize images from the server to fit the screen of your device? Or are you asking how to resize images from the device to whatever size the server requires? – Caleb Sep 25 '12 at 10:06
  • I am asking of what is the best image height and width to show it full-size on whole Android devices because for example it's not right to show image 720x480 on 1024x768 screen... – Zakharov Roman Sep 25 '12 at 10:28

1 Answers1

0

try this code

private Bitmap decodeBitmapFile(File f,int size,int scal){
    try {         
        BitmapFactory.Options o = new BitmapFactory.Options();
        o.inJustDecodeBounds = true;
        BitmapFactory.decodeStream(new FileInputStream(f),null,o);         
        final int REQUIRED_SIZE=size;           
        int scale=scal;
        while(o.outWidth/scale/2>=REQUIRED_SIZE && o.outHeight/scale/2>=REQUIRED_SIZE)
            scale*=2;       
        BitmapFactory.Options o2 = new BitmapFactory.Options();
        o2.inSampleSize=scale;
        return BitmapFactory.decodeStream(new FileInputStream(f), null, o2);
    } catch (FileNotFoundException e) {}
    return null;
}
steevoo
  • 621
  • 6
  • 18