我想实现一个应用程序,该应用程序将使用相机捕获图像并将其显示在ImageView上。但是,系统会将图像分辨率调整为204x153,然后将其显示在屏幕上,但它会将图像的原始分辨率(3264x2448)保存在SD卡中。如何显示原始尺寸的相机拍摄图像?
这是我的代码。
buttonCapture.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intentCamera = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
bmpUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(),
"pic_" + String.valueOf(System.currentTimeMillis()) + ".jpg"));
try {
intentCamera.putExtra("return-data", false);
startActivityForResult(intentCamera, resultOpenCamera);
}
catch (ActivityNotFoundException e) {
e.printStackTrace();
}
}
});
和我的onActivityResult
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == resultOpenCamera && resultCode == RESULT_OK && null != data) {
setContentView(R.layout.preview);
if(data.getAction() != null){
Uri selectedImage = data.getData();
bmpUri = selectedImage;
// display image received on the view
Bundle newBundle = data.getExtras();
Bitmap theImage = (Bitmap) newBundle.get("data");
displayImage(preProcessing(theImage));
System.out.println("theImage height n width = "+theImage.getHeight()+" + "+theImage.getWidth());
}
}
}
我使用的System.out.println跟踪位图分辨率从摄像机捕获。它表明只有204x153。原始分辨率应该是3264x2448。
任何人都知道如何解决这个问题? 非常感谢。
请参考这个问题。它与此相似。 http://stackoverflow.com/questions/5991319/capture-image-from-camera-and-display-in-activity – Scorpion