Android2D 画像の描画(Bitmap)
画像を入れましょう。Android ではBitmapというクラスで画像を扱います。
画像の描画に関するところは,
Techbooster
が秀逸。 いやまじTechboosterさんすごいです。いつも参考にさせていただいています。
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); } }
drawable に, mikasa.png という画像データを入れています。x50, y50のところから
描画のサイズ指定をしていないので, 画像のサイズどおり描画されます。
I am really impressed with your writing skills and also with the layout on your weblog.
Is this a paid theme or did you modify it yourself?
Anyway keep up the excellent quality writing, it is rare to
see a nice blog like this one these days.