C# 为什么图像视图中的图像模糊?
我试着用我自己开发的应用程序拍摄LaunchCamera,在图像处理过程中,图像变得非常模糊 有没有我可以得到清晰的图像C# 为什么图像视图中的图像模糊?,c#,android,xamarin.android,C#,Android,Xamarin.android,我试着用我自己开发的应用程序拍摄LaunchCamera,在图像处理过程中,图像变得非常模糊 有没有我可以得到清晰的图像 [Activity(Label = "LaunchCamera")] public class LaunchCamera : Activity { ImageView imageView; private const int requestCode = 20; protected override void OnCreate(Bundle s
[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);
}
}
[活动(Label=“LaunchCamera”)]
公开课启动摄影机:活动
{
图像视图图像视图;
private const int requestCode=20;
创建时受保护的覆盖无效(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.Camera);
//在此处创建应用程序
var mBtnCamera=findviewbyd(Resource.Id.btnCamera);
imageView=findviewbyd(Resource.Id.photoView);
mBtnCamera.Click+=mBtnCamera\u ClickAsync;
}
私有void MBtnCamera\u ClickAsync(对象发送方,事件参数e)
{
Intent cameraFire=新的Intent(MediaStore.ActionImageCapture);
StartActivityForResult(cameraFire,请求代码)
}
受保护的覆盖void OnActivityResult(int请求代码、[GeneratedEnum]结果代码、意图数据)
{
base.OnActivityResult(请求代码、结果代码、数据);
位图位图=(位图)data.Extras.Get(“数据”);
设置图像位图(位图);
}
}
帮帮忙
感谢您的及时回复。在安卓系统中从摄像头获取图像非常简单,但是如果您需要从摄像头获取全质量图像,这将非常棘手。当您启动intent with action image capture时,基本上得到的只是缩略图。要获取高质量的全尺寸照片,您需要将高质量照片保存在手机存储器或外部存储器中,然后使用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);
}
在安卓系统中,从相机获取图像非常简单,但是如果你需要从相机获取全质量图像,这会变得非常棘手。当您启动intent with action image capture时,基本上得到的只是缩略图。要获取高质量的全尺寸照片,您需要将高质量照片保存在手机存储器或外部存储器中,然后使用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);
}
这里有一件事是可能的,您的imageView大小是大的,而u r尝试在imageView上设置小图像尝试使用不同的相机或尝试使imageView变小。这里有一件事是可能的,您的imageView大小是大的,而u r尝试在imageView上设置小图像尝试使用不同的相机或尝试使imageView变小。