[英]How to save Image that is captured from windows phone automatically after click save button in UWP?
[英]I want to save captured image in an Object (Windows Phone App)
我正在Windows Phone 7应用程序中工作。 使用此代码,我捕获了图像并将其保存到媒体库中
myCamera.Show();
这是用于保存到媒体库
mediaLibrary.SavePicture("TestPhoto", imageBits);
我的问题是>我想将捕获的图像保存到可以直接发送到服务器的对象中
imageBits
已经是一个对象(类型为Stream
),因此您要的内容实际上没有任何意义。 大概您正在尝试将其转换为字节数组,以便将其发送到服务器。
MemoryStream ms = new MemoryStream();
//if you've manipulated stream before this call, reset position
e.ChosenPhoto.Position = 0;
e.ChosenPhoto.CopyTo(ms);
byte[] imageByteArray = ms.ToArray();
ms.Dispose();
然后, imageByteArray
将图像包含为字节数组。 或者,您可以将图像转换为Base64
编码的字符串并发送该字符串,但这取决于您的服务器是否可以对其进行解码。
string base64 = Convert.ToBase64String(imageByteArray);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.