本文整理汇总了C#中AviWriter.Close方法的典型用法代码示例。如果您正苦于以下问题:C# AviWriter.Close方法的具体用法?C# AviWriter.Close怎么用?C# AviWriter.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AviWriter
的用法示例。
在下文中一共展示了AviWriter.Close方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateVideo
public static void CreateVideo(List<Frame> frames, string outputFile)
{
var writer = new AviWriter(outputFile)
{
FramesPerSecond = 30,
// Emitting AVI v1 index in addition to OpenDML index (AVI v2)
// improves compatibility with some software, including
// standard Windows programs like Media Player and File Explorer
EmitIndex1 = true
};
// returns IAviVideoStream
var stream = writer.AddVideoStream();
// set standard VGA resolution
stream.Width = 640;
stream.Height = 480;
// class SharpAvi.KnownFourCCs.Codecs contains FOURCCs for several well-known codecs
// Uncompressed is the default value, just set it for clarity
stream.Codec = KnownFourCCs.Codecs.Uncompressed;
// Uncompressed format requires to also specify bits per pixel
stream.BitsPerPixel = BitsPerPixel.Bpp32;
var frameData = new byte[stream.Width * stream.Height * 4];
foreach (var item in frames)
{
// Say, you have a System.Drawing.Bitmap
Bitmap bitmap = (Bitmap)item.Image;
// and buffer of appropriate size for storing its bits
var buffer = new byte[stream.Width * stream.Height * 4];
var pixelFormat = PixelFormat.Format32bppRgb;
// Now copy bits from bitmap to buffer
var bits = bitmap.LockBits(new Rectangle(0, 0, stream.Width, stream.Height), ImageLockMode.ReadOnly, pixelFormat);
//Marshal.Copy(bits.Scan0, buffer, 0, buffer.Length);
Marshal.Copy(bits.Scan0, buffer, 0, buffer.Length);
bitmap.UnlockBits(bits);
// and flush buffer to encoding stream
stream.WriteFrame(true, buffer, 0, buffer.Length);
}
writer.Close();
}
示例2: Main
private static void Main(string[] args)
{
var firstFrame = CaptureScreen(null);
var aviWriter = new AviWriter();
var bitmap = aviWriter.Open("test.avi", 10, firstFrame.Width, firstFrame.Height);
for (var i = 0; i < 25*5; i++)
{
CaptureScreen(bitmap);
aviWriter.AddFrame();
}
aviWriter.Close();
}