Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use in a Console app with net5.0-windows10.0.19041.0 #822

Open
jdluzen opened this issue Apr 9, 2021 · 2 comments
Open

How to use in a Console app with net5.0-windows10.0.19041.0 #822

jdluzen opened this issue Apr 9, 2021 · 2 comments

Comments

@jdluzen
Copy link

jdluzen commented Apr 9, 2021

I'm attempting to use Win2D because I need something that implements IDirect3DSurface so that I can process video frames written to it. (Related question here https://stackoverflow.com/questions/67011957/how-to-get-decoded-video-frames-using-winrt-in-net5)

I've tried to use the following which is directly taken from a test in this repo:

            var device = new CanvasDevice();
            var rt = new CanvasRenderTarget(device, 16, 16, 96);

But I get the following exception: Specified cast is not valid.

   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
   at WinRT.IObjectReference.As[T](Guid iid)
   at WinRT.IObjectReference.As(Guid iid)
   at Microsoft.UI.Xaml.DependencyObject..ctor(IObjectReference objRef)
   at Microsoft.Graphics.Canvas.CanvasBitmap..ctor(IObjectReference objRef)
   at Microsoft.Graphics.Canvas.CanvasRenderTarget..ctor(IObjectReference objRef)
   at Microsoft.Graphics.Canvas.CanvasRenderTarget..ctor(ICanvasResourceCreator resourceCreator, Single width, Single height, Single dpi)
   at <my app>.FrameAvailable(MediaPlayer sender, Object args) in <my console app>\WmfFrameSource.cs:line 87

#813 is likely related.
I have tried #707 (comment), Microsoft.Graphics.Win2D, and #735 (comment).

@getrou
Copy link
Member

getrou commented Apr 9, 2021

I believe it is an issue with cswinrt that prevents CanvasBitmap and CanvasRenderTarget from working in net5.0 right now.
The issue tracking this is here: microsoft/CsWinRT#779

Once this issue is fixed CanvasBitmap and CanvasRenderTarget should start working.

@selastingeorge
Copy link

Is this issue fixed or still there, currently i was using win2d for WinUI but it also does not support anything related to CanvasGraphicsDevice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants