我的应用分析在台式机和手机上显示此例外:
STOWED_EXCEPTION_System.Exception_88982f50_KNFB-Reader_Windows10.dll!$ 0_MyApp_Windows10 :: MyCamera :: _ GetRotatedIBuffer_d__27.MoveNext
有人可以向我解释下面的代码有什么问题吗?
这是堆栈跟踪:
public async Task<IBuffer> TakePhotoAsync()
{
Debug.WriteLine("taking picture...");
using (var stream = new InMemoryRandomAccessStream())
{
try
{
await mediaCapture.CapturePhotoToStreamAsync(ImageEncodingProperties.CreateJpeg(), stream);
Debug.WriteLine("captured to stream");
}
catch (Exception e)
{
ExceptionHandler.Instance.HandleException(e);
}
//rotate img
return await GetRotatedIBuffer(stream);
}
}
public async Task<IBuffer> GetRotatedIBuffer(IRandomAccessStream stream)
{
//rotate img
using (var imageStream = new InMemoryRandomAccessStream())
{
BitmapDecoder dec = await BitmapDecoder.CreateAsync(stream);
BitmapEncoder enc = await BitmapEncoder.CreateForTranscodingAsync(imageStream, dec);
BitmapRotation rotation = BitmapRotation.None;
switch (KNFBSettings.Instance.DefaultCamera.Rotation)
{
case VideoRotation.Clockwise180Degrees:
rotation = BitmapRotation.Clockwise180Degrees;
break;
case VideoRotation.Clockwise270Degrees:
rotation = BitmapRotation.Clockwise270Degrees;
break;
case VideoRotation.Clockwise90Degrees:
rotation = BitmapRotation.Clockwise90Degrees;
break;
}
enc.BitmapTransform.Rotation = rotation;
await enc.FlushAsync();
return await StreamHelpers.StreamToIBuffer(imageStream);
}
}