I want to save a writableimage in Silverlight to disk.
I found this tutorial : http://kodierer.blogspot.com/2009/11/convert-encode-and-decode-silverlight.html, and have based my code on the EncodeJpeg method.
But at the:
pixelsForJpeg[0][x, y] = (byte)(color >> 16);
it throws an exception : Arithmetic operation resulted in an overflow. At close inspection the color value is -16,777,216. The pixel is black and should have been 0. When switching to a white pixel the value is -1.
I have tried to add 16,777,216 to see if there is some sort of offset, but this only works for black pixels, it crashes on a white one.