I'm trying to find a way to access full resolution pictures from MonoDroid, after a long time of attempting to port the Java examples to MonoDroid and looking at how for others seem to have gotten, i currently have the following (Which does not work)
private const int TAKE_PICTURE = 1;
protected Uri fileUri;
private void takePhoto(object sender, EventArgs e)
{
Intent intent = new Intent(Android.Provider.MediaStore.ActionImageCapture);
string path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal),
"hqxmmc/pictures/ikbeneenplaatje.jpg");
Java.IO.File xfile = new Java.IO.File(path);
if (xfile.Exists())
{
Android.Util.Log.Warn("FILE", "file exists {0}
overwriting!", xfile.Name);
xfile.Delete();
xfile.CreateNewFile();
}
else
{
Android.Util.Log.Warn("FILE", "file does not exist {0}, creating", xfile.Name);
xfile.Mkdirs();
xfile.CreateNewFile();
}
fileUri = Android.Net.Uri.FromFile(xfile);
Android.Util.Log.WriteLine(LogPriority.Warn, "FILE", fileUri.ToString());
intent.PutExtra(Android.Provider.MediaStore.ExtraOutput, fileUri);
StartActivityForResult(intent, TAKE_PICTURE);
}
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
if (requestCode == TAKE_PICTURE)
{
Uri imageUri = null;
// Check if the result includes a thumbnail Bitmap
if (data != null)
{
if (data.HasExtra("data"))
{
var thumbnail = data.GetParcelableArrayExtra("data");
Android.Util.Log.WriteLine(LogPriority.Info, "DATA", thumbnail.ToString());
// TODO Do something with the thumbnail
var outputFileUri = data.GetParcelableArrayExtra("outputFileuri");
Android.Util.Log.WriteLine(LogPriority.Info, "DATA", outputFileUri.ToString());
// TODO Do something with the full image stored
// in outputFileUri
}
}
else
{
//todo : reload full image form fileuri
Android.Util.Log.WriteLine(LogPriority.Info, "PATH", fileUri.ToString());
}
}
}
The 'take a picture' screen is displayed, i can take a picture, but that picture is then saved to the default DCIM folder on the device, ignoring the file name and path i specified for it.
When i save the picture, OnActivityResult is called, but its Intent data
parameter contains an empty intent.
how do i get access to the full resolution picture and/or thumbnail of the picture i just shot?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…