我做了一个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();
但是做后的图片是一张空白的图,求大侠帮忙。