Bitmap Factory

All your problems with Audio, Video and Images.

Bitmap Factory

Postby pedroteixeira07 » Tue Jun 15, 2010 7:11 pm

Hello there,

I know we can use BitmapFactory to decodeStream from a InputStream and create a Bitmap.

I have this String with an URL for a picture on a service lets say ''www.whatever.com/image/whatever.png"

How can I retrieve this and turn it on a bitmap?

thank you for your help
pedroteixeira07
Experienced Developer
Experienced Developer
 
Posts: 74
Joined: Sun Oct 18, 2009 6:06 pm
Location: Funchal

Top

Re: Bitmap Factory

Postby Matt M » Thu Jun 17, 2010 12:29 am

I have not tried this myself but from all the searching I've been doing for my own purposes I've found this:

BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inSampleSize = 4; //A number > 1 will shrink image
URLConnection conn = (HttpURLConnection) new URL("your url for the image").openConnection();
conn.connect();
final BufferedInputStream bis = new BufferedInputStream(conn.getInputStream());
Bitmap b = BitmapFactory.decodeStream(bis, null, opt);

Matt.
User avatar
Matt M
Developer
Developer
 
Posts: 30
Joined: Tue Apr 27, 2010 7:35 pm

Re: Bitmap Factory

Postby pedroteixeira07 » Thu Jun 17, 2010 7:28 pm

Thank you very much Matt :D
pedroteixeira07
Experienced Developer
Experienced Developer
 
Posts: 74
Joined: Sun Oct 18, 2009 6:06 pm
Location: Funchal

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 10 guests