如何压缩gif图像文件

时间:2016-06-03 05:59:49

标签: c# image winforms

我制作了62张图片。所有图像的大小为4.24MB。一个图像大小70.1KB。我正在使用下面的代码创建gif文件,但gifimage的大小是41.1MB。如何压缩尺寸,因为我使用了非常低质量的图像。

  public void createGiffile()
        {
            string outputFilePath = @"C:\Attachment62.gif";
           string path = @"E:\saveimage\New folder";
            var images = Directory.GetFiles(path).OrderBy(c => c.Length).ToArray();

            this.progressBar1.BeginInvoke((MethodInvoker)delegate() { progressBar1.Maximum = images.Length; progressBar1.Step = 1; });         

            AnimatedGifEncoder es = new AnimatedGifEncoder();
            es.Start(outputFilePath);
            //  es.SetDelay(500);
            //-1:no repeat,0:always repeat
            es.SetRepeat(0);


            for (int i = 0, count = imageFilePaths.Length; i < count; i++)
            {
                if (i == 0)
                {
                    string ss = "";
                }
                es.AddFrame(Image.FromFile(imageFilePaths[i]));

                this.progressBar1.BeginInvoke((MethodInvoker)delegate() { progressBar1.PerformStep(); });
            }
            es.Finish();
}

0 个答案:

没有答案
相关问题