FileStream stream = File.Open("bear.png", FileMode.Create);
RenderTargetBitmap bmp = new RenderTargetBitmap((int)this.video.ActualWidth,
(int)this.video.ActualHeight, 96, 96, PixelFormats.Pbgra32);
bmp.Render(this.video);
PngBitmapEncoder coder = new PngBitmapEncoder();
coder.Interlace = PngInterlaceOption.Off;
coder.Frames.Add(BitmapFrame.Create(bmp));
coder.Save(stream);
stream.Close();
RenderTargetBitmap bmp = new RenderTargetBitmap((int)this.video.ActualWidth,
(int)this.video.ActualHeight, 96, 96, PixelFormats.Pbgra32);
bmp.Render(this.video);
PngBitmapEncoder coder = new PngBitmapEncoder();
coder.Interlace = PngInterlaceOption.Off;
coder.Frames.Add(BitmapFrame.Create(bmp));
coder.Save(stream);
stream.Close();
<MediaElement Source="foo.wmv"
MediaOpened="videoElement_MediaOpened"
LoadedBehavior="Pause" ScrubbingEnabled="True" />
本文介绍了一种使用WPF从视频中捕获当前帧并将其保存为PNG图片的方法。通过创建RenderTargetBitmap并设置适当的尺寸和分辨率,可以将视频元素的内容渲染到此位图中。之后,使用PngBitmapEncoder将位图编码并保存到文件。
274

被折叠的 条评论
为什么被折叠?



