GifRecorder/Encoding/ImageUtil.cs

(开头部分) 46KB

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

using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using ScreenToGif.Capture;
using ScreenToGif.Pages;

namespace ScreenToGif.Encoding
{
    /// <summary>
    /// Holds several image algorithms used by the program.
    /// </summary>
    public static class ImageUtil
    {
        #region Resize

        /// <summary>
        /// Resizes a List of Bitmaps.
        /// </summary>
        /// <param name="listFrames">The List of Bitmap to be resized.</param>
        /// <param name="nWidth">The desired Width</param>
        /// <param name="nHeight">The desired Height</param>
        /// <returns>The resized List of Bitmap</returns>
        public static List<Bitmap> ResizeBitmap(List<Bitmap> listFrames, int nWidth, int nHeight)
        {
            var listResize = new List<Bitmap>();

            foreach (var listFrame in listFrames)
            {
                var result = new Bitmap(nWidth, nHeight);
                using (var g = Graphics.FromImage(result))
                    g.DrawImage(listFrame, 0, 0, nWidth, nHeight);
                listResize.Add(result);
            }
            listFrames.Clear();
            GC.Collect();
            return listResize;
        }

        /// <summary>
        /// Resizes a List of Bitmaps from the disk.
        /// </summary>
        /// <param name="listFrames">The List of Bitmap to be resized.</param>
        /// <param name="nWidth">The desired Width</param>
        /// <param name="nHeight">The desired Height</param>
        /// <returns>The resized List of Bitmap</returns>
        public static void ResizeBitmap(List<string> listFrames, int nWidth, int nHeight)
        {
            foreach (var frame in listFrames)
            {
                var bitmapAux = new Bitmap(frame);
                var result = new Bitmap(nWidth, nHeight);

                using (var g = Graphics.FromImage(result))
                    g.DrawImage(bitmapAux, 0, 0, nWidth, nHeight);

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

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

AI 解读

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

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