我正在开发一个代码来捕获图像,然后在预览模式下显示它。捕获图像工作正常。但是在活动中显示它时,我将图像视为模糊图像。可以请有人对可能的解决方案有所了解吗? (请参阅下面的代码)
PreviewImageActivity.java
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_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" />
activity_full_screen.xml
<ImageView
android:id="@+id/full_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/full_image_desc" />