package org.example;
import org.ydbook.R;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
public class Test_CL extends Activity implements OnClickListener,
		OnItemClickListener {
	GridView Gd;
	Gallery Gy;
	ImageAdapterShow myAdapterGd, myAdapterGy;
	Matrix matrix = new Matrix();
	LinearLayout viewerContainer;
	ImageDisplayView displayView;
	ImageDataInput myImageData = new ImageDataInput();
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		Gd = (GridView) findViewById(R.id.grid_view);
		myAdapterGd = new ImageAdapterShow(this, 1);
		Gd.setAdapter(myAdapterGd);
		Gd.setOnItemClickListener(this);
		Gy = (Gallery) findViewById(R.id.gallery_view);
		myAdapterGy = new ImageAdapterShow(this, 2);
		Gy.setAdapter(myAdapterGy);
		Gy.setOnItemClickListener(this);
		findViewById(R.id.grid_txt_go).setOnClickListener(this);
		findViewById(R.id.gallery_txt_go).setOnClickListener(this);
		init();
	}
	private void init() {
		viewerContainer = (LinearLayout) findViewById(R.id.gallery_page);
//		Matrix m = this.getMatrix(); // 매트릭스 생성
		Bitmap sourceBitmap = loadImage(); // 비트맵 불러오기
//		mygrid_Img.setScaleType(ScaleType.MATRIX); // 이미지 뷰에 적용
//		mygrid_Img.setImageMatrix(m);
//		mygrid_Img.setImageBitmap(sourceBitmap); // 비트맵 붙이기
		if (sourceBitmap != null) {
			displayView = new ImageDisplayView(this);
			displayView.setImageData(sourceBitmap);
			LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
					LinearLayout.LayoutParams.FILL_PARENT,
					LinearLayout.LayoutParams.FILL_PARENT);
			viewerContainer.addView(displayView, params);
		}
	}
	public Bitmap loadImage() {
		// Resources res = getResources();
		//
		// Bitmap bitmap = BitmapFactory.decodeResource(res,
		// myImageData.img[0]);
		BitmapDrawable back = (BitmapDrawable) this.getResources().getDrawable(
				myImageData.img[0]);
		Bitmap bitmap = back.getBitmap();
		return bitmap;
	}
	public void onClick(View v) {
		View gridPage = findViewById(R.id.grid_page);
		View galleryPage = findViewById(R.id.gallery_page);
		switch (v.getId()) {
		case R.id.grid_txt_go:
			galleryPage.setVisibility(View.INVISIBLE);
			gridPage.setVisibility(View.VISIBLE);
			// matrix.postScale(posX1, posY1, posX2, posY2);
			break;
		case R.id.gallery_txt_go:
			gridPage.setVisibility(View.INVISIBLE);
			galleryPage.setVisibility(View.VISIBLE);
			// matrix.postScale(posX1, posY1, posX2, posY2);
			break;
		}
	}
	/*private Matrix getMatrix() {    //이 부분은 일단 주석입니다.
		Matrix m = new Matrix();
		return m;
	}*/
	public void onItemClick(AdapterView<?> Adapter, View view, int position,
			long id) {
		ImageView mygrid_Img = (ImageView) findViewById(R.id.grid_img);
		ImageView mygallery_Img = (ImageView) findViewById(R.id.gallery_img);
		TextView my_gridTxt = (TextView) findViewById(R.id.grid_cnt);
		TextView my_galleryTxt = (TextView) findViewById(R.id.galley_cnt);
		int allCnt = Adapter.getCount();
		String printCnt = String.format("%d / %d ", position + 1, allCnt);
		switch (Adapter.getId()) {
		case R.id.grid_view:
			mygrid_Img.setImageResource(myImageData.img[position]);
			my_gridTxt.setText(printCnt);
			break;
		case R.id.gallery_view:
			mygallery_Img.setImageResource(myImageData.img[position]);
			my_galleryTxt.setText(printCnt);
			break;
		}
	}
}
class ImageAdapterShow extends BaseAdapter {
	private Context imgContext;
	int sw;
	int grid_x = 30, grid_y = 40;
	int gallery_x = 70, gallery_y = 80;
	ImageDataInput myImageData = new ImageDataInput();
	public ImageAdapterShow(Context c, int sw) {
		imgContext = c;
		this.sw = sw;
	}
	public ImageAdapterShow() {
	}
	public int getCount() {
		return myImageData.img.length;
	}
	public Object getItem(int position) {
		return myImageData.img[position];
	}
	public long getItemId(int position) {
		return position;
	}
	public View getView(int position, View convertView, ViewGroup parent) {
		ImageView my_ImageShow;
		my_ImageShow = new ImageView(imgContext);
		my_ImageShow.setScaleType(ImageView.ScaleType.CENTER_CROP);
		if (this.sw == 1)
			my_ImageShow.setLayoutParams(new GridView.LayoutParams(grid_x,
					grid_y));
		if (this.sw == 2)
			my_ImageShow.setLayoutParams(new Gallery.LayoutParams(gallery_x,
					gallery_y));
		my_ImageShow.setPadding(0, 0, 0, 0);
		my_ImageShow.setImageResource(myImageData.img[position]);
		return my_ImageShow;
	}
} package org.example;
import org.ydbook.R;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
public class Test_CL extends Activity implements OnClickListener,
		OnItemClickListener {
	GridView Gd;
	Gallery Gy;
	ImageAdapterShow myAdapterGd, myAdapterGy;
	Matrix matrix = new Matrix();
	LinearLayout viewerContainer;
	ImageDisplayView displayView;
	ImageDataInput myImageData = new ImageDataInput();
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		Gd = (GridView) findViewById(R.id.grid_view);
		myAdapterGd = new ImageAdapterShow(this, 1);
		Gd.setAdapter(myAdapterGd);
		Gd.setOnItemClickListener(this);
		Gy = (Gallery) findViewById(R.id.gallery_view);
		myAdapterGy = new ImageAdapterShow(this, 2);
		Gy.setAdapter(myAdapterGy);
		Gy.setOnItemClickListener(this);
		findViewById(R.id.grid_txt_go).setOnClickListener(this);
		findViewById(R.id.gallery_txt_go).setOnClickListener(this);
		init();
	}
	private void init() {
		viewerContainer = (LinearLayout) findViewById(R.id.gallery_page);
//		Matrix m = this.getMatrix(); // 매트릭스 생성
		Bitmap sourceBitmap = loadImage(); // 비트맵 불러오기
//		mygrid_Img.setScaleType(ScaleType.MATRIX); // 이미지 뷰에 적용
//		mygrid_Img.setImageMatrix(m);
//		mygrid_Img.setImageBitmap(sourceBitmap); // 비트맵 붙이기
		if (sourceBitmap != null) {
			displayView = new ImageDisplayView(this);
			displayView.setImageData(sourceBitmap);
			LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
					LinearLayout.LayoutParams.FILL_PARENT,
					LinearLayout.LayoutParams.FILL_PARENT);
			viewerContainer.addView(displayView, params);
		}
	}
	public Bitmap loadImage() {
		// Resources res = getResources();
		//
		// Bitmap bitmap = BitmapFactory.decodeResource(res,
		// myImageData.img[0]);
		BitmapDrawable back = (BitmapDrawable) this.getResources().getDrawable(
				myImageData.img[0]);
		Bitmap bitmap = back.getBitmap();
		return bitmap;
	}
	public void onClick(View v) {
		View gridPage = findViewById(R.id.grid_page);
		View galleryPage = findViewById(R.id.gallery_page);
		switch (v.getId()) {
		case R.id.grid_txt_go:
			galleryPage.setVisibility(View.INVISIBLE);
			gridPage.setVisibility(View.VISIBLE);
			// matrix.postScale(posX1, posY1, posX2, posY2);
			break;
		case R.id.gallery_txt_go:
			gridPage.setVisibility(View.INVISIBLE);
			galleryPage.setVisibility(View.VISIBLE);
			// matrix.postScale(posX1, posY1, posX2, posY2);
			break;
		}
	}
	/*private Matrix getMatrix() {    //이 부분은 일단 주석입니다.
		Matrix m = new Matrix();
		return m;
	}*/
	public void onItemClick(AdapterView<?> Adapter, View view, int position,
			long id) {
		ImageView mygrid_Img = (ImageView) findViewById(R.id.grid_img);
		ImageView mygallery_Img = (ImageView) findViewById(R.id.gallery_img);
		TextView my_gridTxt = (TextView) findViewById(R.id.grid_cnt);
		TextView my_galleryTxt = (TextView) findViewById(R.id.galley_cnt);
		int allCnt = Adapter.getCount();
		String printCnt = String.format("%d / %d ", position + 1, allCnt);
		switch (Adapter.getId()) {
		case R.id.grid_view:
			mygrid_Img.setImageResource(myImageData.img[position]);
			my_gridTxt.setText(printCnt);
			break;
		case R.id.gallery_view:
			mygallery_Img.setImageResource(myImageData.img[position]);
			my_galleryTxt.setText(printCnt);
			break;
		}
	}
}
class ImageAdapterShow extends BaseAdapter {
	private Context imgContext;
	int sw;
	int grid_x = 30, grid_y = 40;
	int gallery_x = 70, gallery_y = 80;
	ImageDataInput myImageData = new ImageDataInput();
	public ImageAdapterShow(Context c, int sw) {
		imgContext = c;
		this.sw = sw;
	}
	public ImageAdapterShow() {
	}
	public int getCount() {
		return myImageData.img.length;
	}
	public Object getItem(int position) {
		return myImageData.img[position];
	}
	public long getItemId(int position) {
		return position;
	}
	public View getView(int position, View convertView, ViewGroup parent) {
		ImageView my_ImageShow;
		my_ImageShow = new ImageView(imgContext);
		my_ImageShow.setScaleType(ImageView.ScaleType.CENTER_CROP);
		if (this.sw == 1)
			my_ImageShow.setLayoutParams(new GridView.LayoutParams(grid_x,
					grid_y));
		if (this.sw == 2)
			my_ImageShow.setLayoutParams(new Gallery.LayoutParams(gallery_x,
					gallery_y));
		my_ImageShow.setPadding(0, 0, 0, 0);
		my_ImageShow.setImageResource(myImageData.img[position]);
		return my_ImageShow;
	}
}
그리드뷰 와 갤러리뷰로 쓰는것은
VISIBLE / INVISIBLE로 처리해서 구현했구요
이게 멀티터치가 그냥 비트맵에 이미지파일 하나 임의로 입력해서 하는것은 되는데
그리드뷰와 갤러리뷰에 저장시켜서 제가 불러올 이미지는 적용이안되네요 ㅠ
1. 그리드뷰와 갤리러뷰에서 제가 선택한 이미지를 비트맵에 저장시키는 법
2. 저장된 비트맵을 멀티터치로 구현

이렇게 2가지 정도 궁금한 점이 있습니다. 코드는 전체 코드이구요 멀티터치 구현할 자바파일은 따로 구현되어 있고 여기엔 적지 않았습니다. 도와주세요 ㅠㅠ