ScreenToGif/FileWriters/AviWriter.cs

(开头部分) 23KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Media.Imaging;
using ScreenToGif.Util;
using PixelFormat = System.Drawing.Imaging.PixelFormat;

namespace ScreenToGif.FileWriters
{
    /// <summary>
    /// Wrapper for the Win32 AVIFile library.
    /// </summary>
    public class AviWriter : IDisposable
    {
        #region Variables

        /// <summary>Handle to the AVI file.</summary>
        private IntPtr _aviFile;
        /// <summary>Handle to the AVI stream.</summary>
        private IntPtr _aviStream;
        /// <summary>Handle to the compressed AVI stream.</summary>
        private IntPtr _compStream;
        /// <summary>Number of frames written to the AVI file.</summary>
        private int _frameCount;
        /// <summary>The width of the video.</summary>
        private readonly int _width;
        /// <summary>The height of the video.</summary>
        private readonly int _height;
        /// <summary>The stride of the video.</summary>
        private readonly uint _stride;
        /// <summary>Whether this AviFile has been disposed.</summary>
        private bool _disposed;

        #endregion

        /// <summary>Initialize the AviFile.</summary>
        /// <param name="path">The path to the output file.</param>
        /// <param name="frameRate">The frame rate for the video.</param>
        /// <param name="width">The width of the video.</param>
        /// <param name="height">The height of the video.</param>
        /// <param name="quality">Video quality 0 to 10000.</param>
        public AviWriter(string path, int frameRate, int width, int height, uint quality = 10000)
        {
            #region Validation

            if (path == null)
                throw new ArgumentNullException(nameof(path));

            if (frameRate <= 0)
                throw new ArgumentOutOfRangeException(nameof(frameRate), frameRate, "The frame rate must be at least 1 frame per second.");

            if (width <= 0)
                throw new ArgumentOutOfRangeException(nameof(width), width, "The width must be at least 1.");

            if (height <= 0)
                throw new ArgumentOutOfRangeException(nameof(height), height, "The height must be at least 1.");

后面还有 487 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。