繁体   English   中英

为什么图像视图中的图像模糊?

[英]Why the image in image view is blurry?

我正在尝试使用自己构建的应用拍摄启动相机,在图像处理过程中,图像会变得非常模糊。

无论如何,我可以获得清晰的图像吗?

    [Activity(Label = "LaunchCamera")]
public class LaunchCamera : Activity
{

    ImageView imageView;
    private const int requestCode = 20;
    protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);
        SetContentView(Resource.Layout.Camera);
        // Create your application here

        var mBtnCamera = FindViewById<Button>(Resource.Id.btnCamera);
        imageView = FindViewById<ImageView>(Resource.Id.photoView);



        mBtnCamera.Click += MBtnCamera_ClickAsync;
    }

    private void MBtnCamera_ClickAsync(object sender, EventArgs e)
    {

        Intent cameraFire = new Intent(MediaStore.ActionImageCapture);




        StartActivityForResult(cameraFire,requestCode)

    }

   protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
    {
        base.OnActivityResult(requestCode, resultCode, data);




        Bitmap bitmap = (Bitmap)data.Extras.Get("data");

        imageView.SetImageBitmap(bitmap); 



    }
}

帮帮忙。

迅速答复表示赞赏。

在Android中从相机获取图像非常简单,但是如果您需要从相机获取完整质量的图像,它将变得非常棘手。 当使用动作图像捕获启动意图时,您基本上得到的只是缩略图。 要获取高质量的原尺寸照片,您需要将高质量的照片保存在手机存储或外部存储中,然后使用Uri来获取该照片。 如果不保存照片,则无法从相机中获取高质量的照片。 不用使用默认目录存储图片,而是创建自己的目录来存储图片。

  private void CreateDirectoryForPictures ()
    {
        App._dir = new File (
            Environment.GetExternalStoragePublicDirectory (
                Environment.DirectoryPictures), "CameraAppDemo");
        if (!App._dir.Exists ())
        {
            App._dir.Mkdirs( );
        }
    }

将Uri传递给相机意图

private void TakeAPicture (object sender, EventArgs eventArgs)
{
    Intent intent = new Intent (MediaStore.ActionImageCapture);
    App._file = new File (App._dir, String.Format("myPhoto_{0}.jpg", Guid.NewGuid()));
    intent.PutExtra (MediaStore.ExtraOutput, Uri.FromFile (App._file));
    StartActivityForResult (intent, 0);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM