如何以编程方式从Windows Phone 8中选择照片以及如何将该照片保存到手机中。请帮我。提前谢谢。
答案 0 :(得分:2)
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207050(v=vs.105).aspx
以上链接:捕获Windows Phone的照片
答案 1 :(得分:2)
内置发射器& WP7 / WP8中的选择器体验允许轻松捕获照片或从手机的图像库中检索照片。使用内置照片选择器是获得默认用户体验的最简单方法。
您可以阅读有关允许在MSDN @ How to use the camera capture task for Windows Phone上快速捕获图像的CameraCaptureTask
您可以阅读有关允许从MSDN @ How to use the photo chooser task for Windows Phone上的手机照片库中检索图像的PhotChooserTask
如果您想构建更复杂的图像处理和相机捕捉应用程序,您可以在诺基亚的Advanced photo capturing文章中了解新的WP8 API。
答案 2 :(得分:2)
// Try the following steps
private readonly CameraCaptureTask _cameraCaptureTask; // Declare CameraCaptureTask
if (null == _cameraCaptureTask) _cameraCaptureTask = new CameraCaptureTask();
_cameraCaptureTask.Completed += PhotoSelectionTaskCompleted;
// In the completed event
void PhotoSelectionTaskCompleted(object sender, PhotoResult e)
{
if (null != e.ChosenPhoto && e.TaskResult == TaskResult.OK)
{
var image = new BitmapImage();
image.SetSource(e.ChosenPhoto);
SaveImageToIsolatedStorage(image,"Image1.jpg");
}
}
public void SaveImageToIsolatedStorage(BitmapImage image, string fileName)
{
using (var isolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
if (isolatedStorage.FileExists(fileName))
isolatedStorage.DeleteFile(fileName);
var fileStream = isolatedStorage.CreateFile(fileName);
if (image != null)
{
var wb = new WriteableBitmap(image);
wb.SaveJpeg(fileStream, wb.PixelWidth, wb.PixelHeight, 0, 100);
}
fileStream.Close();
}
}
答案 3 :(得分:0)