1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| private void capGrabber_NewFrameArrived(object sender, EventArgs e)
{
//this.BitmapSource.Invalidate();
}
//InteropBitmap BitmapSource { get; set; }
private void capGrabber_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
try
{
if ((_capGrabber.Width != default(int)) && (_capGrabber.Height != default(int)))
{
uint pcount = (uint)(_capGrabber.Width * _capGrabber.Height * PixelFormats.Bgr32.BitsPerPixel / 8);
_section = CreateFileMapping(new IntPtr(-1), IntPtr.Zero, 0x04, 0, pcount, null);
_map = MapViewOfFile(_section, 0xF001F, 0, 0, pcount);
//this.BitmapSource = Imaging.CreateBitmapSourceFromMemorySection(_section, _capGrabber.Width,
_capGrabber.Height, PixelFormats.Bgr32, _capGrabber.Width * PixelFormats.Bgr32.BitsPerPixel / 8, 0) as InteropBitmap;
_capGrabber.Map = _map;
if (NewBitmapReady != null)
NewBitmapReady(this, null);
}
}
catch { }
} |
Partager