在android中捕获图像并在同一活动中显示-图像预览模糊
我正在开发一个代码来捕获图像,然后在预览模式下显示相同的图像。拍摄图像效果很好。但在活动中显示时,我得到的图像是模糊的。有人能解释一下可能的解决办法吗?(请参阅下面我的代码) PreviewImageActivity.java在android中捕获图像并在同一活动中显示-图像预览模糊,android,Android,我正在开发一个代码来捕获图像,然后在预览模式下显示相同的图像。拍摄图像效果很好。但在活动中显示时,我得到的图像是模糊的。有人能解释一下可能的解决办法吗?(请参阅下面我的代码) PreviewImageActivity.java protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.im
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.image_capture);
cam_button = (ImageView) findViewById(R.id.button1);
}
public void captureclick(View v) {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
// user is returning from capturing an image using the camera
if (requestCode == CAMERA_REQUEST) {
Bitmap captured = (Bitmap) data.getExtras().get("data");
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
alertDialogBuilder.setTitle("Image Details");
alertDialogBuilder.setMessage("Height: " + thePic.getHeight() + "Width: " + thePic.getWidth()).setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
}).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
setContentView(R.layout.activity_full_screen);
full_img = (ImageView) findViewById(R.id.full_image);
full_img.setImageBitmap(captured);
}
image\u capture.xml
<ImageView
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:onClick="captureclick"
android:src="@drawable/camera_icon"
android:text="@string/Click" />
<ImageView
android:id="@+id/full_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/full_image_desc" />
活动\u全屏.xml
<ImageView
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:onClick="captureclick"
android:src="@drawable/camera_icon"
android:text="@string/Click" />
<ImageView
android:id="@+id/full_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/full_image_desc" />
为设置android:adjustViewBounds=“true”imageview@BirajZalavadia:谢谢你的建议。我尝试使用该属性,但预览时图像仍然模糊。不走运。你能帮我进一步分析一下吗?如有需要,将提供更多信息。提前谢谢。