1
我在使用ACTION_IMAGE_CAPTURE捕獲圖片後出現了保存圖片的問題意圖圖片變得非常小,它的分辨率是27X44我使用1.5 android模擬器,這是代碼和我感謝所有幫助:小尺寸圖片問題
myImageButton02.setOnClickListener
(
new OnClickListener()
{
@Override
public void onClick(View v)
{
// create camera intent
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
//Grant permission to the camera activity to write the photo.
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
//saving if there is EXTRA_OUTPUT
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File
(Environment.getExternalStorageDirectory(), "testExtra" + String.valueOf
(System.currentTimeMillis()) + ".jpg")));
// 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
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
if (requestCode == 1 && resultCode == RESULT_OK)
{
String timestamp = Long.toString(System.currentTimeMillis());
// get the picture
Bitmap mPicture = (Bitmap) data.getExtras().get("data");
// save image to gallery
MediaStore.Images.Media.insertImage(getContentResolver(), mPicture, timestamp, timestamp);
}
}
}
@Haya,請妥善縮進代碼,以便它是可讀 – 2010-03-09 16:37:54
大評論,哈雅。你的代碼現在也更容易閱讀。對不起,雖然我沒有答案,但希望有人能夠儘快提供幫助。 – 2010-03-09 18:34:32