//protected override bool StartCaptureCore() //{ // BitmapPool.Instance.Create(InterestRegion.Width, InterestRegion.Height, PixelFormat); // return playLooper.Start(); //} //protected override bool StopCaptureCore() //{ // return playLooper.Stop(); //} protected override sealed ValueResult <Bitmap> CaptureCore() { if (ConnectState != ConnectState.Connected || DispatchState != DispatchState.Established) { return(ValueResult <Bitmap> .Failed); } var bitmap = Pool.WriteLock(); var frame = reader.ReadVideoFrame(); BitmapConverter.ConvertTo(frame, bitmap); Pool.WriteUnlock(bitmap); //BitmapStorager.Save(bitmap, DateTime.Now.ToChineseLongFileName() + ".bmp"); bitmap.TimeStamps["CaptureTime"] = DateTime.Now; var result = new ValueResult <Bitmap>(bitmap); OnCaptureSuccessed(new ValueEventArgs <Bitmap>(bitmap)); return(result); }
public void Swap(Bitmap source = null) { lock (_threadLock) { if (source == null) { var sourceStamps = _backgroundBitmap.TimeStamps; var targetStamps = _foregroundBitmap.TimeStamps; //source为null时,从背景位图更新前景位图数据 if (sourceStamps["DecodeTime"] > targetStamps["DecodeTime"]) { BitmapConverter.ConvertTo(_backgroundBitmap, _foregroundBitmap); targetStamps["CaptureTime"] = sourceStamps["CaptureTime"]; targetStamps["DecodeTime"] = sourceStamps["DecodeTime"]; targetStamps["SwapTime"] = sourceStamps["SwapTime"]; } } else { var sourceStamps = source.TimeStamps; var targetStamps = _backgroundBitmap.TimeStamps; //source不为null时,从解码位图更新背景位图数据 BitmapConverter.ConvertTo(source, _backgroundBitmap); targetStamps["CaptureTime"] = sourceStamps["CaptureTime"]; targetStamps["DecodeTime"] = sourceStamps["DecodeTime"]; targetStamps["SwapTime"] = DateTime.Now; } } }
protected override void DecodeCore(Bitmap source, Bitmap target) { BitmapConverter.ConvertTo(source, target); }