This project has moved and is read-only. For the latest updates, please go here.

Handle DrawingImage as source

Mar 5, 2010 at 7:36 AM

Hey Alexey,

Verry nice feature that we have had a lot of benefit from.

However, we are extensively using XAML based image resources an to handle that we have introduced the following code in the SetSources method:

if (Source is DrawingImage)
{
  RenderTargetBitmap targetBitmap = new RenderTargetBitmap((int)Width, (int)Height, 96, 96, PixelFormats.Default);
  DrawingVisual drawingVisual = new DrawingVisual();
  DrawingContext drawingDC = drawingVisual.RenderOpen();
  drawingDC.DrawImage(Source, new Rect(new Size(Height, Width)));
  drawingDC.Close();
  targetBitmap.Render(drawingVisual);
  _SourceG = new FormatConvertedBitmap(targetBitmap, PixelFormats.Gray8, null, 0);
}

This makes it possible to specify a XAML based DrawingImage to the Source property and still make it greyable.

You may consider incorporating it into your project.

 

Regards

Morten Schou

Mar 5, 2010 at 10:58 AM

Hi Morten,

Thanks a lot for the code, I've added it to the project.

 

regards,

Alex.