troubleshooting Question

C# WPF ImageBrush Delegate

Avatar of drewbuckley
drewbuckley asked on
.NET ProgrammingC#Microsoft Development
7 Comments1 Solution1726 ViewsLast Modified:
Hi to all,

I'm currently coding in WPF and have a Rectangle that i need to update with a bitmap from another thread.

I'm getting the ImageBrush to contain the image but it can't get past the fill part. i think because of a threading issue. Any help would be great.

Here is what i have:

using (MemoryStream ms = new MemoryStream(ea.Frame.Buffer))
    Bitmap bmp = (Bitmap)System.Drawing.Image.FromStream(ms);
    ImageBrush ibrush = new	ImageBrush(System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(bmp.GetHbitmap(),	IntPtr.Zero, Int32Rect.Empty,BitmapSizeOptions.FromEmptyOptions()));
    backRect.Fill = ibrush;
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros