C# Как преобразовать byte[] в Brush?
Есть такой код, он преобразует byte[] в Brush
public static Brush ByteToBrush(byte[] image)
{
ImageBrush brush = new ImageBrush();
BitmapImage bi = new BitmapImage();
using (var ms = new MemoryStream(image))
{
bi = new BitmapImage();
bi.BeginInit();
bi.CreateOptions = BitmapCreateOptions.None;
bi.CacheOption = BitmapCacheOption.OnLoad;
bi.StreamSource = ms;
bi.EndInit();
}
brush.ImageSource = bi;
return brush;
}
Как преобразовать обратно Brush в byte[]?