Search code examples
.netawesomium

Convert awesomium screenshot to Stream


Here is how I make awesomium screenshot:

webView2.Render().SaveToPng("filePath");

The problem is that I now need not to save bytes to file but get them inmemory. How can I achieve that?


Solution

  • The documentation states that Render() returns an instance of RenderBuffer, which has a property called Buffer, that returns the raw pixel data (as an IntPtr). If you still need a byte array, you could use Marshal.Copy to copy the data into a byte array. This way, you can do it without the need of a temporary file.