刘立强
2017-07-04 11:53C# 如何从视频文件中截取图片?
我做了一个wpf程序,需要从视频文件中截取一张图片作为缩略图,不需要打开视频播放,直接截取,我在网上找了一下:
string path = System.Windows.Forms.Application.StartupPath + "\tempImages\" + ofd.SafeFileName.Substring(0,ofd.SafeFileName.LastIndexOf('.')-1) + ".png";
FileStream stream = File.Open(path, FileMode.Create);
RenderTargetBitmap bmp = new RenderTargetBitmap(300,
300, 100, 100, PixelFormats.Pbgra32);
bmp.Render(me);
PngBitmapEncoder coder = new PngBitmapEncoder();
coder.Interlace = PngInterlaceOption.Off;
coder.Frames.Add(BitmapFrame.Create(bmp));
coder.Save(stream);
stream.Close();
但是做后的图片是一张空白的图,求大侠帮忙。
- 点赞
- 回答
- 收藏
- 复制链接分享
1条回答
为你推荐
- C#+DirectShowLib截取当前播放的部分视频
- directshowlib
- c#
- 3个回答