private void capGrabber_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
Dispatcher.Invoke(DispatcherPriority.DataBind, (SendOrPostCallback) delegate
{
try
{
if ((CapGrabber.Width != default(int)) && (CapGrabber.Height != default(int)))
{
// Get the pixel count
uint pcount = (uint) (CapGrabber.Width*CapGrabber.Height*PixelFormats.Bgr32.BitsPerPixel/8);
// Create a file mapping
Section = CreateFileMapping(new IntPtr(-1), IntPtr.Zero, 0x04, 0, pcount, null);
Map = MapViewOfFile(Section, 0xF001F, 0, 0, pcount);
// Get the bitmap
BitmapSource = Imaging.CreateBitmapSourceFromMemorySection(Section, CapGrabber.Width,
CapGrabber.Height, PixelFormats.Bgr32, CapGrabber.Width*PixelFormats.Bgr32.BitsPerPixel/8, 0)
as InteropBitmap;
CapGrabber.Map = Map;
// Invoke event
if (NewBitmapReady != null)
{
NewBitmapReady(this, null);
}
}
}
catch (Exception ex)
{
// Trace
Trace.TraceError(ex.Message);
}
}, null);
}