我已通过 NuGet 将 WriteableBitmapExtension 添加到我的 Windows Phone 8.1 WinRT 应用程序中。我具有从相机捕获图像并将其保存到图片库的功能。我在保存之前尝试旋转捕获的图像,我在这里找到了解决方案 WriteableBitmap crash program without message? . 在模拟器上一切正常,但是当我在诺基亚 Lumia 630 上运行我的应用程序时,它在没有调试器消息的情况下拍照后崩溃了几秒钟。谁能帮我解决这个问题?这是我的拍照代码:
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;
}