Windows phone 7 如何将捕获的图像传递到画布?
我有一个类,它使用设备摄像头来捕捉图像。我的目标是将捕获的图像传递到另一个布局上的画布 然后,此版面将与输入文本框的便笺一起保存。我已经知道如何保存便笺和标题并允许其打开,但我不确定如何将捕获的图像传递到版面并与便笺一起保存 有没有人对我该怎么做有什么建议或指点 目前,我正试图在保存图像文件后将其读回布局,但我不确定如何将文件读入画布,因此显然此解决方案还不起作用:Windows phone 7 如何将捕获的图像传递到画布?,windows-phone-7,canvas,image-capture,Windows Phone 7,Canvas,Image Capture,我有一个类,它使用设备摄像头来捕捉图像。我的目标是将捕获的图像传递到另一个布局上的画布 然后,此版面将与输入文本框的便笺一起保存。我已经知道如何保存便笺和标题并允许其打开,但我不确定如何将捕获的图像传递到版面并与便笺一起保存 有没有人对我该怎么做有什么建议或指点 目前,我正试图在保存图像文件后将其读回布局,但我不确定如何将文件读入画布,因此显然此解决方案还不起作用: if (NavigationContext.QueryString.ContainsKey("note"))
if (NavigationContext.QueryString.ContainsKey("note"))
{
string s2 = ".jpg";
string filename = this.NavigationContext.QueryString["note"];
if (!string.IsNullOrEmpty(filename)) {
using (var store = System.IO.IsolatedStorage.IsolatedStorageFile .GetUserStoreForApplication())
using (var stream = new IsolatedStorageFileStream(filename, FileMode.Open, FileAccess.ReadWrite, store))
/*
if(filename.Contains(s2))
{
StreamReader reader = new StreamReader(stream);
this.capturedNoteCanvas = reader.ReadToEnd();
this.noteNameTb.Text = filename; reader.Close();
}
else
*/
{
StreamReader reader = new StreamReader(stream);
this.noteDataTb.Text = reader.ReadToEnd();
this.noteNameTb.Text = filename; reader.Close();
}
}
}
我的想法是这样的:
使用CameraCaptureTask和位图 //从cameracapturetask获取可写位图对象
void cameracapturetask_Completed(object sender, PhotoResult e)
{
try
{
if (e.TaskResult == TaskResult.OK)
{
BitmapImage bmp = new BitmapImage();
bmp.SetSource(e.ChosenPhoto);
WritableBitmap wb=new WritableBitmap (bmp.PixelWidth,bmp.PixelHeight);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
在存储中保存wb
using (MemoryStream stream = new MemoryStream())
{
wb.SaveJpeg(stream, (int)bmp.PixelWidth, (int)bmp.PixelHeight, 0, 100);
using (IsolatedStorageFileStream local = new IsolatedStorageFileStream(App.PageName, FileMode.Create, mystorage))
{
local.Write(stream.GetBuffer(), 0, stream.GetBuffer().Length);
}
}
//从画布获取可写位图
如果您的画布包含图像,并且该图像所属的画布具有一些高度和宽度属性,则
WritableBitmap wb= new WritableBitmap(canvascontrol,null);
获取画布并将其保存在一个可写位图对象中,然后可用于进一步的图像处理。我可以问一下您迄今为止尝试了什么吗?是的,当然我现在将在问题中发布我的解决方案。