Closed swimfish09 closed 2 years ago
Please enter a general description for the issue. Delete sections that are not relevant and provide additional sections if necessary.
4.4.350
capture a image
<MainWindow> <Image x:Name="duplicated" Margin="0"/> </MainWindow>
private WriteableBitmap Wb; [DllImport("kernel32.dll", EntryPoint = nameof(CopyMemory), SetLastError = false)] private static extern void CopyMemory(IntPtr dest, IntPtr src, uint count); private void Media_RenderingVideo(object sender, RenderingVideoEventArgs e) { if (Wb == null || Wb.BackBufferStride != e.Bitmap.Stride || Wb.PixelHeight != e.Bitmap.PixelHeight) { Wb = new WriteableBitmap(e.Bitmap.PixelWidth, e.Bitmap.PixelHeight, e.Bitmap.DpiX, e.Bitmap.DpiY, PixelFormats.Bgr32, null); VideoPlayerZoomAndPanControl.duplicated.Source = Wb; } Wb.Lock(); CopyMemory(Wb.BackBuffer, e.Bitmap.Scan0, (uint)(e.Bitmap.Stride * e.Bitmap.PixelHeight)); Wb.AddDirtyRect(e.Bitmap.UpdateRect); Wb.Unlock(); } if (!IsPlaying || !Media.IsPlaying) return; var image = await Media.CaptureBitmapAsync(); var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ImageDefaultSavePath); if (!Directory.Exists(path)) Directory.CreateDirectory(path); var file = Path.Combine(path, $"{(Info.Parent == null ? "" : Info.Parent.Label + "_")}{Info.Label}_{System.DateTime.Now:yyyy_MM_dd_HH_mm_ss}.png"); image?.Save(file, ImageFormat.Png);
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.
System.Runtime.InteropServices.ExternalException
Please enter a general description for the issue. Delete sections that are not relevant and provide additional sections if necessary.
Version Information
4.4.350
Steps to Reproduce
capture a image
Sample Code
XAML
C