I need a faster way to draw images and render them
I am working on an application that allows you to draw images. With every brush step, the images are drawn towards my canvas. I basically have a canvas with a collection of Image controls. Performance is not as good when the number of images increases.
Also, rendering the canvas with RenderTargetBitmap.Render sometimes causes out of memory depending on the number of images in my canvas and the dimensions of my canvas and the images I draw with.
Is there a solution? I can rasterize after every brush stroke, rendering all of these images on my canvas, clearing the canvas, and then painting the re-processed image onto the canvas. It will probably take too long, but has to wait between each brush stroke, doesn't sound too good.
So what are my options? Can I do it all with WriteableBitmap? Is it possible to add multiple images to one WriteableBitmap, and fast? Or is there any library I can use to draw and manipulate (scale, translate, rotate) images?
Here's what I am currently doing by creating canvas image controls:
Edit : I went ahead and implemented this rasterization method described above. It's actually not that bad.
256x256 canvas: http://i.minus.com/iFXnyYg3N3qjx.gif
2048x2048 canvas: http://i.minus.com/i5GId8iM8hU28.gif
The demo was tested on a fairly old PC and I'm aiming for the minimum requirement. I also tested it on a newer PC and it runs quite smoothly even at 2048x2048. I would still like it to be faster. I thought I could render the canvas on a background thread, but I'll have to figure out a way to paint the images while the canvas is rendering. Another option I was thinking about is rendering the canvas piece by piece on different threads in parallel (if possible in C #). So, for example, a 2048x2048 canvas could be displayed as four 512x512 sections at the same time. It was also suggested to learn OpenGL and start from scratch. Can't you do gui in WPF for openGL app?
source to share
No one has answered this question yet
Check out similar questions: