none
关于uwp用win2d DrawImage的问题 RRS feed

  • 问题

  • 我按照例子写了一段,但是到了DrawImage的时候总是报错,错误是
    An exception of type 'System.ObjectDisposedException' occurred in test.exe but was not handled in user code

    Additional information: 该对象已关闭。 (Exception from HRESULT: 0x80000013)

    private async void cc_Draw(CanvasControl sender, CanvasDrawEventArgs args)
    {
                Rect rect = new Rect(0, 0, 1024, 768);
                FileOpenPicker filePicker = new FileOpenPicker();
                filePicker.ViewMode = PickerViewMode.Thumbnail;
                filePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
                filePicker.FileTypeFilter.Add("*");
                StorageFile file = await filePicker.PickSingleFileAsync();
                var stream = await file.OpenAsync(FileAccessMode.ReadWrite);
                var b = await CanvasBitmap.LoadAsync(sender, stream);             
                args.DrawingSession.DrawImage(b, rect);
    }

    b已经被赋值,而且是正确的,就是我打开了了一张1024*768图片,但是一执行args.DrawingSession.DrawImage(b, rect);
    就会报错

    2016年8月31日 13:13

答案

全部回复