使用Lumia Imaging SDK渲染图像时出现异常

时间:2015-03-10 20:57:14

标签: windows-runtime windows-phone-8.1 lumia-imaging-sdk

在我的WP8.1应用程序中,我尝试使用Lumia(以前的诺基亚)Imaging SDK裁剪图像。使用FileOpenPicker检索图像:

public async void ContinueFileOpenPicker(Windows.ApplicationModel.Activation.FileOpenPickerContinuationEventArgs args) {
    if (args.Files.Count > 0) {
        _stream = await args.Files[0].OpenAsync(Windows.Storage.FileAccessMode.Read);
        _bitmapImage = new Windows.UI.Xaml.Media.Imaging.BitmapImage();
        await _bitmapImage.SetSourceAsync(_stream);
        SelectedImage.Source = _bitmapImage;
    }
    else {
        Debug.WriteLine("Operation cancelled.");
    }
}

然后在按钮处理程序中应用过滤器(在用户选择裁剪区域之后;尺寸仅用于测试目的):

private async void GetImageAcceptButton_Click(object sender, RoutedEventArgs e) {
    await GetCroppedBitmapAsync();
}

async public Task GetCroppedBitmapAsync() {
    using (var source = new RandomAccessStreamImageSource(_stream)) {
        using (var filterEffect = new FilterEffect(source)) {
            var filter = new CropFilter(new Windows.Foundation.Rect(0, 0, 100, 100));
            filterEffect.Filters = new IFilter[] { filter };
            var target = new WriteableBitmap(50, 50);
            using (var renderer = new WriteableBitmapRenderer(filterEffect, target)) {
                await renderer.RenderAsync();
                SelectedImage.Source = target;
            }
        }
    }
}

RenderAsync()调用抛出异常:

System.Runtime.InteropServices.COMException occurred
HResult=-2147467259
Message=Error HRESULT E_FAIL has been returned from a call to a COM component.
Source=mscorlib
ErrorCode=-2147467259

应用过滤器似乎相当简单。为什么在这里失败?

1 个答案:

答案 0 :(得分:1)

您应该启用本机调试并查看“输出”窗口。您当前缺少真正的异常消息(尝试更具体)。异常消息字符串在WinRT调用边框上“走私”,只正式传递了HRESULT(此处为E_FAIL)。

这是Silverlight 8.1还是通用应用程序btw?

我对答案的猜测可能是你需要寻找/回放流。可能是该职位即将结束。