WIllJBD
WIllJBD

Reputation: 6164

android png from url has its transparency showing as black

I have tried loading a png-8 from a url to an imageview, but the transparency is lost and turns black. So i tried a png-24 and same problem.

Here is the kicker, if I copy the image from the url, and paste it into Photoshop, the transparency is also black!

However on the web, it shows just fine, on iOS, it shows perfectly.

I set my decoder options, and even tried setting my window too in onCreate().

getWindow().getAttributes().format = android.graphics.PixelFormat.RGBA_8888;

then tried this separately

BitmapFactory.Options decOpt = new Options();       
decOpt.inPreferredConfig = Bitmap.Config.ARGB_8888;

then tried them together. These were all the solutions I could find on the web.

this too, doesn't work.

getWindow().getAttributes().format = android.graphics.PixelFormat.TRANSPARENT;

Nothing is working! Any ideas?

Edit:

Here is a url of an image I just randomly tried to see if it was only my image, and no this one has same problem.

http://img260.imageshack.us/img260/1124/girlag8.png

and this one as well

http://images.vectorimagesfree.com/2011/09/world-series-logo-famous-sports-icon-transparent-png0.png

So if you can get that one to display correctly in android it would likely fix my problem as well.

Upvotes: 0

Views: 1342

Answers (1)

petey
petey

Reputation: 17140

Maybe setting the window format will help, in your activity override onAttachedToWindow and set a better pixel format.

@Override
public void onAttachedToWindow() {
    super.onAttachedToWindow();
    Window window = getWindow();
    window.setFormat(PixelFormat.RGBA_8888);
}

Upvotes: 1

Related Questions