Tiling a Bitmap on a Canvas

后端 未结 2 1657
鱼传尺愫
鱼传尺愫 2021-02-08 05:36

I would like to create a \'graph paper\' look to the Bitmap I am drawing via a Canvas, and trying to figure out the best way to do this.

I can\'t pass a source Bitmap co

2条回答
  •  伪装坚强ぢ
    2021-02-08 05:48

    You have two easy solutions:

    • Either use a BitmapDrawable, but instead of extracting the Bitmap, just call BitmapDrawable.draw(Canvas). Don't forget to set the drawable's bounds to fill your drawing area.
    • Create a Paint with a BitmapShader and draw a rectangle with it (this is basically what BitmapDrawable does).

提交回复
热议问题