Why Bitmap to Base64 String showing black background on webview in android?

后端 未结 1 1387
鱼传尺愫
鱼传尺愫 2020-12-03 11:37

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 b

相关标签:
1条回答
  • 2020-12-03 12:12

    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 = "<img src='data:image/png;base64," + imgToString               
        + "' align='left' bgcolor='ff0000'/>";   
    
    0 讨论(0)
提交回复
热议问题