Losing transparent background when downloading an external PNG image
Asked Answered
K

1

6

I'm displaying an external image in an image view by fist downloading it like this:

bitmap = BitmapFactory.decodeStream((InputStream)new URL(url).getContent());

Then setting this bitmap to the ImageView like this:

imageView.setImageBitmap(bitmap);

This works all good except that one of the images is a PNG and I lose the transparent background when using the BitmapFactory.

Can anyone tell me how I can keep the transparent background?

Karbala answered 22/2, 2012 at 0:38 Comment(1)
Did you find any solution i will face as like same problem. Have you any idea.Kizer
N
2

not sure if this will help, but try following this advice and adding Options to make sure that your image is pulled in as ARGB_8888

http://developer.android.com/reference/android/graphics/BitmapFactory.html#decodeFile(java.lang.String, android.graphics.BitmapFactory.Options)

Nathalienathan answered 22/2, 2012 at 0:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.