I have an imageview with a touch listener, and I am able to capture all touch inputs into a matrix, and apply that matrix to the imageview where the image pans and zooms appropriately.
My problem: I'd now like to CROP the image in such a way that it ALWAYS ends up the same size of what image i choose in the gallery.
In other words, suppose I have a 512x512 square in the middle of my screen, a user pans and zooms an image until an item of interest fits into that square, and click "done". I would like to have a resulting image that has cropped the photo which contained in the imageview.
this is my Code:
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.customizeimage);
// imagview = (ImageView) findViewById(R.id.imageView1);
button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
// To open up a gallery browser
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(
Intent.createChooser(intent, "Select Picture"), 1);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
if (requestCode == 1) {
//this is where the image pan and zoom
final ImageView imageView = (ImageView) findViewById(R.id.imageGet);
imageView.setOnTouchListener(new OnTouch());
// currImageURI is the global variable I'm using to hold the
// content:// URI of the image
currImageURI = data.getData();
// String selectedImagePath=getRealPathFromURI(currImageURI);
imageView.setImageURI(currImageURI);
Log.e("" + getRealPathFromURI(GalleryImage.this, currImageURI),
"" + getImagePath(currImageURI));
}
}
}