Before looking at the code, I would advise you through out this code, because you are doing it all wrong, from the very beginning.
You are not really using writeable capabilities of
as you don't write anything, only reading. The only writing part is
which defeats the purpose of this class completely. Performance of
is always prohibitively bad (unless you want to write very few pixels).
Look at the code sample of the class documentation: http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.writeablebitmap.aspx
How could you possibly miss the main idea of this class? You call
, directly manipulate memory, and then call
. This is the main idea. That's why it give good performance. (It it similar to
Now, I cannot see how you algorithm can sharpen anything. I don't think it can. I know at least two methods of sharpening: one is unsharp mask, another one simply perform the image convolution with a fixed core (matrix) and is very simple and fast. Are you familiar with convolution operations? In discrete objects, they are pretty easy.
You can find good example of convolutions of the image with a 5x5 convolution matrix
demonstrating sharpening, blur, edge enhance, edge detect and emboss here:
Isn't that amazing? Just one operation for such different and striking effects! You can easily implement it using
, can you?
I found an open-source library which should do it for Silverlight, WPF and more: http://writeablebitmapex.codeplex.com/
You can try to find more: http://bit.ly/WKz4pj