I'm wondering what is the best way to render a polygon to WPF-compatable BitmapSource using DirectX (preferably SharpDX)?
I have to render tens of thousands of polygons like this offscreen to BitmapSource then include in a WPF applicatoin and need the fastest possible way to do it. The rendering must be performed off-screen for later showing in a WPF Image OR exporting to file.
(not actual size. Polygon size ranges from 16x16 to 24x24 pixels)
Any suggestions welcome!
WPF has its own ability to render shapes and does so using DirectX as DirectX is the underlying technology behind WPF. Here is a link to some some sample code for using SharpDX in WPF.
http://directx4wpf.codeplex.com/
Related
This is not really language-specific (although I am most comfortable in C#). I am basically trying to create an application that would display basic 2D graphics over an OpenGL application (specifically FlightGear). There would be no need to have mouse-interaction (e.g. clicks) with the overlay - it would be for informational purposes only.
What is the simplest way of going about this?
If I understand your question correctly, you just have to render your scene and after that you can change your camera transformation to a parallel projection, with the size of your viewport. You can now render simple rectangles with your 2D graphics as textures on it.
I just have a question:
I need to draw some WPF geometries in a canvas, and each geometry's surface is a complicate Texture2D in Direct3D 11. I'm using SharpDX and just convert the Texture2D into a MemoryStream then Convert to a WPF ImageSource, because I'm using Compute Shader, the Format.Bgra isn't supported with UAV texture, so I can't use a D3DImage. Since there're performance issue, how can I bind a Texture2D to a WPF Geometry directly? Thanks.
For performance reasons, you should perform the whole rendering with SharpDX and not using WPF Geometries, only D3DImage to synchronize the result of rendering with WPF. If you need to convert a texture from one format to another to match WPF formats, you can simply render a full quad with a simple shader copying the texture. If you are doing this with SharpDX Toolkit, it is fairly easy to develop it as it is providing a WPF control.
Short answer is you can't, WPF 3D is still in its infancy and custom shader support is available for 2D effects only. Best advice I can offer at the moment is to render your geometry onto an XNA surface and display it in an AirspacePopup with your WPF controls on top.
I'm making a Windows Store Application that display really big images in a ScrollViewer.
The source image is very big and the rendering with the Image is bad (because the Image is really smaller than the source image, so the scaling make the result ugly).
I want to use direct2D to have a better rendering (the project is in c#).
I'm really new to this, so I don't really know how to do... I've found those links that seems interesting:
XAML SurfaceImageSource DirectX interop sample (Windows 8.1)
How to Draw a BitmapSource Using Direct2D
The SurfaceImageSource sample is good, but only shows how to render sharpes...
And I don't know how to use the second links with SurfaceImageSource.
Is there anybody who have a good example about this? Thanks!
I think you can try VirtualSurfaceImageSource.It can render large image.
Learn more:
http://msdn.microsoft.com/en-us/library/windows/apps/hh825871.aspx
I’m looking for an advanced noncommercial drawing library for C# with WPF.
My goal is to create a drawing application. Not vector graphic support is needed, only bitmap.
The most advanced non-commercial API's for drawing are going to be DirectX and OpenGL. They are both complex, but you will be able to make them do almost anything you would want. You could also roll your own design that uses an Image and just changes the various pixels manually. You can then draw the image to your window when changes occur. Here is a code example below.
http://msdn.microsoft.com/en-us/library/0t3sakh9.aspx
Is there a specific reason why you can't utilize GDI+? GDI+ is an object-oriented vector-based graphics library built into the .NET Framework. It can perform most trivial drawing tasks, including loading, drawing, and saving bitmaps (BMP, PNG, GIF, JPEG, and others), transforms, color matrix manipulation, and blending. It can also render primitives such as lines, rectangles, circles, and n-sided polygons.
It also has support for render operations, and alpha transparency. You can also draw primitives and other graphical constructs using brushes and patterns, like with GDI.
You can find more information about the classes available to you by looking at the System.Drawing namespace, where most of the GDI+ classes are contained:
http://msdn.microsoft.com/en-us/library/system.drawing.aspx
Your question is not specific, however Graphic Classes in C# has many methods and features to accomplish any Trivial and some non trivial task.. if you need any thing more than that then you have DirectX.
I am currently developing a little application with a highly-dynamic GUI which needs a lot of refreshing and drawing. To archive this, I am using managed DirectX.
I successfully painted a little string in a specific font to specific coordinates, but I have no idea on how I could rotate the drawn text...
Any ideas?
Thanks!
Okay, I found no native method to archive my goal.
So I painted the Font on a bitmap, created a texture and used sprites to draw my font texture.