Thursday, January 29, 2009

WPF - Is it my preferred choice for graphics ?

Hi guys!

I want to share with you some experience with WPF
Recently, I started doing a very simple Graphics project and encountered some difficulties. I wanted to share with you the thing which frustrated me mostly.

What is the most simple thing we should do when using Graphics?
For me, this is to load a simple image and manipulate it. This was pretty easy with GDI+ and System.Drawing classes like Image and Bitmap. You had everything needed - you could load a Bitmap simple like this Image.FromImage(path_to_file) and you could as easily manipulate the Bitmap's pixels - Bitmap.SetPixel(x, y, color). I of course wanted to use the same 'tricks' in WPF, but couldn't do it. After some research, I figured out why:

"GDI+ was a bit different in the sense that the Bitmap object was always cached in memory, so having a SetPixel method made sense. However, this may not be the case in WPF. For applications that do not wish to load the entire image in memory, WPF provides a way to load the image such that it is read from disk on a per-demand basis. In this case, a SetPixel equivalent does not make much sense and would not work. Thus we have chosen to not include this functionality for V1 and will consider such an API for future version."

In Conclusion
Firstly, I couldn't believe this. I could have gone with using Windows Forms Project from the very beginning, but was excited to try the WPF.
I wonder if WPF is grown enough to be used in real projects... ? I will appreciate any professional opinions on the theme.

No comments: