I am creating Paint-like application in WPF. I would like to have layers, history, effects optins etc. there. However, I think standard approach with Canvas/InkCanvas would be too slow for complex images. I consider creating XNA project and embed it into WPF application to use power of modern GPUs (xna project would be like drawing canvas space). Isn’t it bad idea? Is it possible to communicate between WPF and XNA in one project?
I am creating Paint-like application in WPF. I would like to have layers, history,
Share
This is a bad idea. Several reasons:
WPF has its own built-in hardware acceleration (see here). You don’t need to use XNA to get hardware acceleration.
XNA is designed for real-time 3D rendering. Pixel operations are its weak point – you will lose most of its performance advantages by reading/writing pixels directly. Note that you would find it difficult to avoid doing expensive pixel reads, as XNA’s render targets can be “lost“.
XNA will give you a performance increase for compositing layers (but you could also use WPF for this). It will give you a performance increase for applying large, full-image effects – however there are some kinds of full-image effects that can only reasonably be done on the CPU.
XNA imposes limitations on things like maximum texture size, and the hardware capabilities of your target platform.
You probably don’t need as much performance as you think. You use XNA for a game running at a continuous 60 frames-per-second. An image editor doesn’t need to be nearly that fast. Full-image effect operations can afford to take a relatively long time. Interactive painting operations don’t have to update the entire image at once – so will be fast even on the CPU.
To answer your last question – yes you can embed XNA in WPF. Although it is tricky – the trivial approaches involve a very slow buffer copy from XNA to WPF. Here is a project that claims to do it the fast way.