Skip to content Skip to sidebar Skip to footer

Why Bitmap To Base64 String Showing Black Background On Webview In Android?

I am using a code that combine to images into 1 by using canvas . I show that image to ImageView it looks fine. But when I try to show that into WebView it show background black to

Solution 1:

The JPEG format does not support alpha transparency, which is why the transparent background becomes black when you convert your original image to JPEG.

Use the PNG format instead:

 map1.compress(Bitmap.CompressFormat.PNG, 100, baos); 

and

String imgTag = "<imgsrc='data:image/png;base64," + imgToString               
    + "'align='left'bgcolor='ff0000'/>";   

Post a Comment for "Why Bitmap To Base64 String Showing Black Background On Webview In Android?"