Android Java: bitmap resize define height and width auto -


i setimagebitmap url imageview. want define height, , want app set width automatically, proportionally.

this code:

url imageurl = new url("url"); httpurlconnection connection = (httpurlconnection) imageurl.openconnection(); inputstream inputstream = connection.getinputstream(); bitmap = bitmapfactory.decodestream(inputstream); image_projet.setimagebitmap(bitmap); 

float aspect = bitmap.getwidth() / (float) bitmap.getheight() int newwidth = newheight * aspect; 

you can calculate new width.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -