當前位置: 首頁>>代碼示例>>C#>>正文


C# AviWriter.Close方法代碼示例

本文整理匯總了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();
        }
開發者ID:JollySwagman,項目名稱:Super8,代碼行數:54,代碼來源:Video.cs

示例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();
        }
開發者ID:duszekmestre,項目名稱:MoN.Messenger,代碼行數:14,代碼來源:Program.cs


注:本文中的AviWriter.Close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。