Copy Bitmap contents of one ImageView to anoher

后端 未结 1 606
天命终不由人
天命终不由人 2021-02-03 13:46

This has me baffled. I need to copy the Bitmap from one ImageView into another. I do not want to simply copy one ImageView to another because I need to do some changes to the

1条回答
  •  不思量自难忘°
    2021-02-03 14:17

    Not used the drawing cache, but wouldn't you need to call buildDrawingCache() ?

    The way I'd do it:

    Bitmap bmSrc1 = ((BitmapDrawable)ivSrc.getDrawable()).getBitmap();
    Bitmap bmSrc2 = bmSrc1.copy(bmSrc1.getConfig(), true);
    

    Note that bmSrc2 is mutable, i.e. you can stick it in a Canvas and do whatever you like with it before drawing it somewhere.

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