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

python - Creating a new virtualenv gives a permissions error -

go - Idiomatic way to handle template errors in golang -

c# - What is a NullReferenceException, and how do I fix it? -