Paint p = new Paint() Bitmap bitmap = null Canvas bitmapCanvas = null protected void onDraw(Canvas canvas) Note: I've initialized the Bitmap in the onDraw method which is not a great idea, however it makes reading the code snippets easier. If we need to persist the drawn image or you need to draw transparent pixels, it is a good idea to draw your shape on a Bitmap first and then draw that Bitmap on Canvas. Drawing a shape on a Bitmap, then draw the bitmap on Canvas When I discuss how anti-aliasing works below, you’ll see why this bit of information is important. This works because each time onDraw is called, the canvas is cleared and everything has to be redrawn. As you c an see, anti-alias produces a smooth edge.
0 Comments
Leave a Reply. |