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?
You can confirm that your file has been converted by pressing edit on the image on your device from the Apple Photos app (see below) If the background turns black then transparency has been maintained. If it stays white then the image has been converted to a JPG file.
Because when you download the PNG from the Previewer Window, the PNG LOSES the transparency information.
How To Export Layer as Transparent PNG: If you want to export anything in Photoshop as a transparent PNG, instead of going to the File menu and selecting 'Export As', right-click on any layer and select 'Export As' and then choose PNG and make sure Transparent is checked.
If your PNG image is saved with a transparent background, it will appear with a black background in Brainshark. That is because transparency in images is not supported in Brainshark. As a workaround, you can either add in a plain background using an image editing program, or try to save the image as a JPG or GIF.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With