gif图像分解、gif图像制作
来源:互联网 发布:淘宝捉猫猫时装碎片 编辑:程序博客网 时间:2024/05/17 22:46
1、gif图像分解:
gifTool.exe 工具下载
2、gif图像制作:
3、工具核心源码:
点击下载
using Gif.Components;using System;using System.Collections.Generic;using System.Drawing;using System.Drawing.Imaging;using System.Linq;using System.Text;using System.Threading.Tasks;namespace Tool{ /// <summary> /// gif图像处理类 /// /// gif图像分解: SaveSubImage() /// 合并为gif图像: SaveToGif() /// </summary> public class GifTools { /// <summary> /// 自动处理函数; /// 获取所有gif图像的子图; /// 或合并所有图像为单个gif图像; /// </summary> public static void AutoProcess(string[] files) { List<string> gifList = new List<string>(); List<string> picList = new List<string>(); foreach (string file in files) { if(file.ToLower().EndsWith(".gif")) gifList.Add(file); else picList.Add(file); } // 获取所有gif的子图像 foreach (string gif in gifList) GifTools.SaveSubImage(gif); // 合并所有图像为单个gif图像 GifTools.SaveToGif(picList.ToArray()); } /// <summary> /// 获取gif图像的所有子图像,保存到gifPath所在路径 /// </summary> public static void SaveSubImage(string gifPath) { Image imgGif = Image.FromFile(gifPath, true); SaveSubImage(imgGif, gifPath); imgGif.Dispose(); } /// <summary> /// 获取imgGif的所有子图像,保存到savePath对应的路径 /// </summary> public static void SaveSubImage(Image imgGif, string savePath) { //Create a new FrameDimension object from this image var ImgFrmDim = new FrameDimension(imgGif.FrameDimensionsList[0]); //Determine the number of frames in the image //Note that all images contain at least 1 frame, //but an animated GIF will contain more than 1 frame. int n = imgGif.GetFrameCount(ImgFrmDim); // 获取子图像数目 // Save every frame into png format file for (int i = 0; i < n; i++) { imgGif.SelectActiveFrame(ImgFrmDim, i); // 选择子图 string newName = savePath; if (newName.Contains(".")) newName = newName.Substring(0, newName.LastIndexOf(".")); newName = newName + "_" + i + ".png"; imgGif.Save(newName, ImageFormat.Png); // 保存 } } /// <summary> /// 保存多张图像为单张gif图像 /// </summary> public static void SaveToGif(string[] imagePaths, string outputFilePath="", int ms = 100, bool repet = true) { List<Image> list = new List<Image>(); foreach (string path in imagePaths) { list.Add(Image.FromFile(path)); } if (outputFilePath.Equals("")) { // 设置输出文件名 outputFilePath = imagePaths[0]; if (outputFilePath.Contains(".")) outputFilePath = outputFilePath.Substring(0, outputFilePath.LastIndexOf(".")); outputFilePath = outputFilePath + ".gif"; } SaveToGif(list.ToArray(), outputFilePath, ms, repet); foreach (Image image in list) image.Dispose(); } /// <summary> /// 保存多张图像为单张gif图像 /// </summary> public static void SaveToGif(Image[] images, string outputFilePath, int ms = 100, bool repet = true) { AnimatedGifEncoder encoder = new AnimatedGifEncoder(); encoder.Start(outputFilePath); // 输出gif文件路径 encoder.SetDelay(ms); // 帧间隔 encoder.SetRepeat(repet ? 0 : -1); // 0:循环 -1:不循环 for (int i = 0, count = images.Length; i < count; i++) { encoder.AddFrame(images[i]); // 添加图像 } encoder.Finish(); } }}
阅读全文
0 0
- gif图像分解、gif图像制作
- ImageMagick 制作 GIF 图像
- 如何分解和合成Gif图像
- GIF图像结构
- 显示GIF图像
- GIF图像动画
- WPF显示GIF图像
- 桌面录制gif图像
- python爬取多页gif图像
- 自定义控件显示GIF图像
- 加速ImageMagick gif图像处理
- Android 解码播放GIF图像
- GIF图像转Ascall文字图像
- Gilde加载圆形图像、加载gif图像
- BMP、JPG、GIF图像的显示
- 如何在symbian下绘制Gif图像
- VC显示JPEG和GIF图像
- VC下显示JPEG、GIF图像
- 【MySQL】MySQL各个版本区别及官网下载地址
- Android平台移植FFmpeg
- ionic综合+首页右上角点击进入包含一个轮播+进入后显示选项左上角有一个后退按钮每个选项包含内容
- Windows搭建Python开发环境
- koa之处理器模块化
- gif图像分解、gif图像制作
- MVP 模式简单易懂的介绍方式
- 直接选择排序
- fastdfs分布式文件系统之JAVA client工具类封装
- 两个栈实现队列
- Atitit 人工智能目前的进展与未来 包含的技术 v2 r99.docx
- Weex的环境搭建及集成到Android Studio和趟过的坑
- Atitit 常用数据校验规则
- Android 启动活动的最佳写法