private void TakeSnapshot() { DisplayThreadDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { if (_snapshotContext != null) { _snapshotContext.Save(this, this.VideoSource); _snapshotContext = null; } })); }
private void TakeSnapshot() { DisplayThreadDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { if (_snapshotContext == null) { return; } _snapshotContext.GetName(this); switch (_snapshotContext.Format) { case SnapshotFormat.BMP: var bmpE = new BmpBitmapEncoder(); bmpE.Frames.Add(BitmapFrame.Create(VideoSource)); using ( Stream stream = File.Create(String.Format("{0}\\{1}.bmp", _snapshotContext.Path, _snapshotContext.Name)) ) { bmpE.Save(stream); } break; case SnapshotFormat.JPG: var jpgE = new JpegBitmapEncoder(); jpgE.Frames.Add(BitmapFrame.Create(VideoSource)); using ( Stream stream = File.Create(String.Format("{0}\\{1}.jpg", _snapshotContext.Path, _snapshotContext.Name)) ) { jpgE.QualityLevel = _snapshotContext.Quality; jpgE.Save(stream); } break; case SnapshotFormat.PNG: var pngE = new PngBitmapEncoder(); pngE.Frames.Add(BitmapFrame.Create(VideoSource)); using ( Stream stream = File.Create(String.Format("{0}\\{1}.png", _snapshotContext.Path, _snapshotContext.Name)) ) { pngE.Save(stream); } break; } _snapshotContext = null; })); }
private IntPtr VideoLockCallback(IntPtr opaque, ref IntPtr planes) { if (VlcMediaPlayer.Volume != Volume) { VlcMediaPlayer.Volume = Volume; } if (!_context.IsAspectRatioChecked) { var tracks = VlcMediaPlayer.Media.GetTracks(); var videoMediaTracks = tracks.OfType <VideoTrack>().ToList(); var videoTrack = videoMediaTracks.FirstOrDefault(); if (videoTrack != null) { _context.CheckDisplaySize(videoTrack); var scale = GetScaleTransform(); if (Math.Abs(scale.Width - 1.0) + Math.Abs(scale.Height - 1.0) > 0.0000001) { _context.IsAspectRatioChecked = true; Debug.WriteLine(String.Format("Scale:{0}x{1}", scale.Width, scale.Height)); Debug.WriteLine(String.Format("Resize Image to {0}x{1}", _context.DisplayWidth, _context.DisplayHeight)); } else { _checkCount++; if (_checkCount > 5) { _context.IsAspectRatioChecked = true; } } if (DisplayThreadDispatcher != null) { DisplayThreadDispatcher.BeginInvoke( new Action(() => { ScaleTransform = new ScaleTransform(scale.Width, scale.Height); })); } } } return(planes = _context.MapView); }
protected virtual void OnPropertyChanged <T>(Expression <Func <T> > expr) { if (_disposing) { return; } if (_isStopping) { return; } if (PropertyChanged != null) { var bodyExpr = expr.Body as MemberExpression; var propInfo = bodyExpr.Member as PropertyInfo; var propName = propInfo.Name; if (DisplayThreadDispatcher != null) { DisplayThreadDispatcher.BeginInvoke( new Action(() => { PropertyChanged(this, new PropertyChangedEventArgs(propName)); })); } } }
private void CheckAspectRatio() { if (!_context.IsAspectRatioChecked) { var tracks = VlcMediaPlayer.Media.GetTrackInfo(); var videoMediaTracks = tracks.OfType <VideoTrack>().ToList(); var videoTrack = videoMediaTracks.FirstOrDefault(); if (videoTrack != null) { _context.CheckDisplaySize(videoTrack); var scale = GetScaleTransform(); if (Math.Abs(scale.Width - 1.0) + Math.Abs(scale.Height - 1.0) > 0.0000001) { _context.IsAspectRatioChecked = true; Debug.WriteLine($"Scale:{scale.Width}x{scale.Height}"); Debug.WriteLine($"Resize Image to {_context.DisplayWidth}x{_context.DisplayHeight}"); } else { _checkCount++; if (_checkCount > 5) { _context.IsAspectRatioChecked = true; } } if (DisplayThreadDispatcher != null) { DisplayThreadDispatcher.BeginInvoke( new Action(() => { ScaleTransform = new ScaleTransform(scale.Width, scale.Height); })); } } } }