sharpdx / SharpDX

SharpDX GitHub Repository
http://sharpdx.org
MIT License
1.7k stars 639 forks source link

DIrect2d Render Target to Bitmap #869

Open ghost opened 7 years ago

ghost commented 7 years ago

Hi. I'm new in DirectX and SharpDx. Now i have code that draw lines, text and points. For it I use SharpDX.Direct2D1.RenderTarget. Factory which is parent of swap chain is associated with win form. Is there a way to save render target to image whithout redraw all elements? I can't find way to get bitmap's data of target and save it by any object of wic like BitmapFrameEncode. Please, help me.

crowbar27 commented 7 years ago

You might want to create a render target drawing to a WIC bitmap in the first place: https://msdn.microsoft.com/de-de/library/windows/desktop/dd742731(v=vs.85).aspx

You can blit the pixels from there to your form. Depending on what you are trying to achieve, you could also try to use a render control and share the D3D surface: https://msdn.microsoft.com/de-de/library/windows/desktop/ee913554(v=vs.85).aspx

However, this solution is a bit difficult to get right.