package com.cookandroid.project9_2;

import android.support.v7.app.AppCompatActivity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout;

public class MainActivity extends AppCompatActivity {

	ImageButton ibZoomin, ibZoomout, ibRotate, ibBright, ibDark, ibGray;
	MyGraphicView graphicView;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		setTitle("¹Ì´Ï Æ÷Åä¼¥");

		LinearLayout pictureLayout = (LinearLayout) findViewById(R.id.pictureLayout);
		graphicView = (MyGraphicView) new MyGraphicView(this);
		pictureLayout.addView(graphicView);

	}

	private static class MyGraphicView extends View {
		public MyGraphicView(Context context) {
			super(context);
		}

		@Override
		protected void onDraw(Canvas canvas) {
			super.onDraw(canvas);

			Bitmap picture = BitmapFactory.decodeResource(getResources(),
					R.drawable.lena256);
			int picX = (this.getWidth() - picture.getWidth()) / 2;
			int picY = (this.getHeight() - picture.getHeight()) / 2;
			canvas.drawBitmap(picture, picX, picY, null);

			picture.recycle();
		}
	}
}
