Convert BitmapImage to System.Windows.Media.Brush

How would I convert a BitmapImage to a System.Windows.Media.Brush?

I have a BitmapImage imaginatively called bitmap, and I have a Canvas (also imaginatively titled) canvas.

How would I set the value of canvas to the value of bitmap?

I've tried canvas.Background = bitmap;, but that didn't work: image.Source = bitmap; works for images, but not Canvases: and

ImageSourceConverter imgs = new ImageSourceConverter(); canvas.SetValue(Image.SourceProperty, imgs.ConvertFromString(bitmap.ToString()));

didn't work either.

All of these worked with images, however.

Maybe something with bitmap.ToString() would work?


Create an ImageBrush and use that as the background:

 ImageBrush ib = new ImageBrush();
 ib.ImageSource = bitmap;
 canvas.Background = ib;

Need Your Help

HighCharts column unknown number of series

javascript highcharts asp-classic

I'm trying to populate a HighCharts dataset with results from SQL Server in Classic ASP.

How do I create test and train samples from one dataframe with pandas?

python python-2.7 pandas dataframes

I have a fairly large dataset in the form of a dataframe and I was wondering how I would be able to split the dataframe into two random samples (80% and 20%) for training and testing.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.