Page 1 of 1

WPF pixel array

Posted: 01 Nov 2017, 11:40
by alemio
Hi,
currently I have a project wrote in c# and WPF. I have to send the pixel byte array of canvas content to video card.
I'm using rendertargetbitmap to get a snapshot oh this canvas and after that I use CopyPixel to copies the bitmap pixel data into a byte array.
I do that because I need alpha channel.

Could I do that with NoesisGUI?
Thank you

Re: WPF pixel array

Posted: 01 Nov 2017, 11:57
by jsantos
Anything involving CopyPixel is extremely slow. Being NoesisGUI an API optimized for videogames and realtime we provide a faster way. You can render to your own GPU render target and just have the result directly in the GPU card without having to copy using the CPU.

Re: WPF pixel array

Posted: 01 Nov 2017, 12:53
by alemio
Thank you for the answer, I'm working with blackmagic decklink. Decklink function provides me an IntPtr where I write the byte array.
How I can do that?

Thank you

Re: WPF pixel array

Posted: 02 Nov 2017, 17:51
by jsantos
As said, Noesis renders to the active render target (a render texture, a framebuffer, etc). How to get a byte array from that GPU buffer is something not related to Noesis and it depends on the graphics API you are using: d3d, opengl, metal or the engine: unity, unreal, c++ sdk...

Are you using Unity?

Re: WPF pixel array

Posted: 03 Nov 2017, 09:54
by alemio
Thank you for the answer,
I'm not using with Unity, I'm using with WPF, XAML and c#.
Let me explain my project
In my project I have a canvas with some controls (rectangles, text...)
WPF don't give me the frame buffer, so I need to use rendertargetbitmap to get it.
I use rendertargetbitmap because I need alpha channel. if I use BitBlt or something like that I can't have alpha channel. I have same problem if I try to extract the output data from video card.

With noesisgui can I render directly in a framebuffer?

Thank you

Re: WPF pixel array

Posted: 03 Nov 2017, 11:52
by jsantos
With noesisgui can I render directly in a framebuffer?
Yes, with noesisgui you render to the current active framebuffer.

Re: WPF pixel array

Posted: 03 Nov 2017, 12:17
by alemio
Please could you give me an example how can I get this frame buffer.
What is the pixel format of this frame buffer? 8bit ARGB?

Thank you

Re: WPF pixel array

Posted: 03 Nov 2017, 12:24
by jsantos
Noesis does not create the framebuffer. That's client responsibility. For example, in our OpenGL C# sample we are using glut for the initialization:
glutInit(&myargc, myargv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL);
glutInitWindowSize(windowWidth, windowHeight);
glutInitWindowPosition(0, 0);
But you can change this and even don't use glut and use a different OpenGL helper.

Re: WPF pixel array

Posted: 03 Nov 2017, 12:34
by alemio
Ok. Please tell me where can I find the pixels frame buffer in your OpenGL C# sample

Thank you

Re: WPF pixel array

Posted: 03 Nov 2017, 13:12
by jsantos
I recommend glReadPixels. But, as said, this is a pure OpenGL problem.