    public static class BitmapConverter
    {

        public static Bitmap Bytes2Bitmap(this byte[] rawImage)
        {
            MemoryStream str = new MemoryStream(rawImage);
            return Bitmap.FromStream(str, true) as Bitmap;
        }

        public static byte[] Bitmap2Bytes(this Bitmap bitmap)
        {
            return (byte[])TypeDescriptor.GetConverter(bitmap).ConvertTo(bitmap, typeof(byte[]));
        } 
    }