I have a XAML drawing brush. I want it to show in the PictureBox on a report. But the report only takes an image from System.Drawing and not System.Windows.Media. Any ideas anyone?
// Grab the XAML DrawingBrush
// Grab the XAML DrawingBrush
DrawingBrush db = (DrawingBrush)App.Current.Resources["BugIcon"]; // Create an image (wrong kind of Image though)
Image i = new Image()
{
Source = new DrawingImage(db.Drawing),
Height = 300,
Width = 300
};
// Need to convert Image to System.Drawing.Image.
RenderTargetBitmap renderBmp = new RenderTargetBitmap(300, 300, 96, 96, PixelFormats.Pbgra32);
renderBmp.Render(i);
PngBitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(renderBmp));
using (MemoryStream stream = new MemoryStream())
{
encoder.Save(stream);
System.Drawing.Image i2 = System.Drawing.Image.FromStream(stream);
// This is the Telerik report, and the pb1/pb2 are PictureBox controls
((Telerik.Reporting.PictureBox)sr.Items["header"].Items["pb1"]).Value = i2;
((Telerik.Reporting.PictureBox)sr.Items["header"].Items["pb2"]).Value = i2;
}