//WriteableBitmap to ARGB byte array
public static byte[] ToByteArray(this WriteableBitmap bmp)
{
int[] p = bmp.Pixels;
int len = p.Length * ;
byte[] result = new byte[len]; // ARGB
Buffer.BlockCopy(p, , result, , len);
return result;
} //Copy ARGB byte array into WriteableBitmap
public static void FromByteArray(this WriteableBitmap bmp, byte[] buffer)
{
Buffer.BlockCopy(buffer, , bmp.Pixels, , buffer.Length);
}