Windows phone 8.1 WriteableBitmapExtension使设备上的应用程序崩溃
我已经通过NuGet向我的Windows Phone 8.1 WinRT应用程序添加了一个WriteableBitmapExtension。我有从相机中捕获图像并将其保存到图片库的功能。我尝试在保存之前旋转捕获的图像,我在这里找到了解决方案 . 在emulator上一切正常,但当我在诺基亚Lumia 630上运行我的应用程序时,它会在拍照几秒钟后崩溃,而不会显示debbuger消息。有人能帮我解决这个问题吗?以下是我的拍照代码:Windows phone 8.1 WriteableBitmapExtension使设备上的应用程序崩溃,windows-phone-8.1,windows-phone-8-emulator,writeablebitmapex,Windows Phone 8.1,Windows Phone 8 Emulator,Writeablebitmapex,我已经通过NuGet向我的Windows Phone 8.1 WinRT应用程序添加了一个WriteableBitmapExtension。我有从相机中捕获图像并将其保存到图片库的功能。我尝试在保存之前旋转捕获的图像,我在这里找到了解决方案 . 在emulator上一切正常,但当我在诺基亚Lumia 630上运行我的应用程序时,它会在拍照几秒钟后崩溃,而不会显示debbuger消息。有人能帮我解决这个问题吗?以下是我的拍照代码: public WriteableBitmap Image {
public WriteableBitmap Image
{
get
{
return this.image;
}
set
{
this.image = value;
this.RaisePropertyChanged(() => this.Image);
}
}
private async void TakePhoto()
{
using (var stream = new InMemoryRandomAccessStream())
{
var imgEncodingProperties = ImageEncodingProperties.CreateJpeg();
var img = BitmapFactory.New(640, 480);
await this.MediaCapture.CapturePhotoToStreamAsync(imgEncodingProperties, stream);
stream.Seek(0);
img.SetSource(stream);
WriteableBitmapExtensions.DrawLine(img, 10, 10, 300, 300, Colors.Black);
this.Image = img.Rotate(90);
this.TurnOffCaptureMode();
}
}
private void TurnOffCaptureMode()
{
this.MediaCapture.StopPreviewAsync();
this.IsInCaptureMode = false;
}
另一种解决办法是在这里。
1打开文件纠察队使用内置摄像头拍照
var openPicker = new FileOpenPicker();
openPicker.ContinuationData["Action"] = "SendPicture";
openPicker.FileTypeFilter.Add(".jpg");
openPicker.FileTypeFilter.Add(".png");
openPicker.PickSingleFileAndContinue();
***2. In app.xaml.cs you will get captured image. as below.***
public void Continue(IContinuationActivatedEventArgs args)
{
if(args.Kind == ActivationKind.PickFileContinuation)
{
var openPickerContinuationArgs = args as FileOpenPickerContinuationEventArgs;
// Recover the "Action" info we stored in ContinuationData
string action = (string) openPickerContinuationArgs.ContinuationData["Action"];
if(openPickerContinuationArgs.Files.Count > 0)
{
// TODO: Get the files here
}
else
{
// TODO: Write code here to handle picker cancellation.
}
}
}