Hi
need a help urgent !!
I'm done with saving the image after capturing it
but I face another problem that the image is very small
and when i try to capatalize it , it become not clear
the code:
@Override
startActivityForResult(intent,1);
}
});
---------------------------------
thanks
need a help urgent !!
I'm done with saving the image after capturing it
but I face another problem that the image is very small
and when i try to capatalize it , it become not clear
the code:
myImageButton02
.setOnClickListener(new OnClickListener() {
@Override
public
void onClick(View v)
{
// create camera intent
{
// create camera intent
Intent intent =
new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
//Grant permission to the camera activity to write the photo.
//Grant permission to the camera activity to write the photo.
intent.addFlags(Intent.
FLAG_GRANT_WRITE_URI_PERMISSION);
// start the camera intent and return the image
// start the camera intent and return the image
startActivityForResult(intent,1);
}
});
---------------------------------
@Override
protected void onActivityResult(int requestCode, int
resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
// if Activity was canceled, display a Toast message
resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
// if Activity was canceled, display a Toast message
if (resultCode == RESULT_CANCELED) {
Toast toast = Toast.makeText(this,"camera cancelled", 10000);
toast.show();
return;
}
// lets check if we are really dealing with a picture
Toast toast = Toast.makeText(this,"camera cancelled", 10000);
toast.show();
return;
}
// lets check if we are really dealing with a picture
if (requestCode == 1 && resultCode == RESULT_OK)
{
String timestamp = Long.toString(System.currentTimeMillis());
// get the picture
{
String timestamp = Long.toString(System.currentTimeMillis());
// get the picture
Bitmap mPicture = (Bitmap) data.getExtras().get(
"data");
int width = mPicture.getWidth();
int height = mPicture.getHeight();
int newWidth = 500;
int newHeight = 80;
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
Bitmap resizedBitmap = Bitmap.createBitmap(mPicture, 0, 0, width,
height, matrix, true);
// save image to gallery
int width = mPicture.getWidth();
int height = mPicture.getHeight();
int newWidth = 500;
int newHeight = 80;
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
Bitmap resizedBitmap = Bitmap.createBitmap(mPicture, 0, 0, width,
height, matrix, true);
// save image to gallery
MediaStore.Images.Media.insertImage(getContentResolver(), resizedBitmap, timestamp, timestamp);
}
}}
thanks