Android2D Draw Image(Bitmap)
Let’s draw image on Canvas.
Android handle Image as Bitmap class
Sample
public class DrawBitmapView extends View { private Paint paint; private Bitmap img; public DrawBitmapView ( Context context ) { super(context); paint = new Paint(Paint.ANTI_ALIAS_FLAG); img = BitmapFactory.decodeResource(context.getResources(), R.drawable.mikasa); } @Override protected void onDraw ( Canvas canvas ) { canvas.drawColor(Color.BLACK); canvas.drawBitmap(img, 50, 50, paint); } }
I put misaka.png into drawable directory.
Start point is x=50, y =50. I don’t set point so, draw image as size.
What’s up to all, because I am genuinely keen of reading this blog’s post to be updated
on a regular basis. It includes fastidious stuff.