You’re attempting to convert the JPEG memory stream into PNG. That will make it corrupt – you should save the Bitmap directly to PNG.
I haven’t tried this particular task with the imagetools library, but if you see John Papa’s blog, it looks like you need to call the ToImage
extension method on your WriteableBitmap
which is provided as part of ImageTools. Then you can use the encoder to take this image and write out to your open stream.
var img = bitmap.ToImage();
var encoder = new PngEncoder();
using (var stream = new IsolatedStorageFileStream(fileName, FileMode.Create, store))
{
encoder.Encode(img, stream);
stream.Close();
}