How to prevent Android's drawBitmap from only drawing black images?

前端 未结 2 936
Happy的楠姐
Happy的楠姐 2020-12-12 16:44

As per the original question, The end result is a rounded-rect png in an ImageView with a natural looking drop shadow.

I have the shadow wo

相关标签:
2条回答
  • 2020-12-12 17:31

    You have to draw both the shadow image and the original image. The shadow image only contains the alpha values of the original image, not the actual colored pixels.

    0 讨论(0)
  • 2020-12-12 17:32

    I commented in your last question, but here it is again.

    The problem might be that you're drawing a 32-bit image (the original) onto an 8-bit image (the extracted shadowImage). If that's the case, do something like

    Bitmap shadowImage32 = shadowImage.copy(ARGB_8888, true);
    

    after the extractAlpha call, and draw onto that guy instead of the 8-bit shadowImage.

    0 讨论(0)
提交回复
热议问题