Aspose.Imaging Animation Maker 为 .NET

Aspose.Imaging Animation Maker for .NET Plugin”是一个强大的工具,允许开发人员从静态图像中创建专业动画 GIF 和APNG,这个高性能的 .NET 动画图书馆为您提供了框架长度、序列和出口设置的完整控制.

安装

创建动画在内容/docs.aspose.net/zip

下面是从图像框中创建动画GIF的例子:

const int AnimationDuration = 1000;
const int FrameDuration = 42;

GifImage gifImage = null;
try
{
  foreach (var inputFilePath in Directory.GetFiles(inputFilesPath, fileMask))
  {
    RasterImage sourceImage = (RasterImage)Image.Load(inputFilePath);
    if (gifImage == null)
    {
      GifOptions createOptions = new GifOptions
      {
        Source = new FileCreateSource(outputFilePath, false),
        BackgroundColor = Color.Transparent,
        FullFrame = true,
        LoopsCount = (int)(AnimationDuration / FrameDuration),
        Palette = ColorPaletteHelper.GetCloseImagePalette(sourceImage, 256)
      };

      gifImage = (GifImage)Image.Create(
               createOptions,
          sourceImage.Width,
          sourceImage.Height);

      gifImage.InsertBlock(0, new GifGraphicsControlBlock());
      gifImage.SetFrameTime((ushort)FrameDuration);
      if (gifImage.PageCount > 0)
      {
        gifImage.RemoveBlock((IGifBlock)gifImage.Pages[0]);
      }
    }

    gifImage.AddPage(sourceImage);
  }
}
finally
{
  if (gifImage != null)
  {
    gifImage.Save();
    gifImage.Dispose();
  }
}

在更简单的情况下,使用 GifImage.AddPage() .

主要特点

框架序列

  • 进口图像(PNG、JPEG、BMP等.).
  • 添加、插入、删除和重新订单框.
  • 检查框架属性,如尺寸和颜色深度.

时间和参数

  • 定义统一或框架延迟.
  • 调整动画包,以便顺利或多样播放.

输出格式

  • GIF - 聚合物优化, loop count, dithering.
  • APNG - 透明度和分配模式.

预处理和优化

  • 再生,种植,或 pad 框.
  • 应用 Palette Reduction 以减少文件大小.
  • 使用分数和量化以获得平衡的结果.

性能与整合

  • 轻量级充电,以提高记忆效率.
  • 平行出口的三条安全建筑.
  • 进展呼叫回复长途流程.
  • 兼容 .NET Core、NET 5+ 和 .Net Framework.
  • 使用 Aspose.Imaging 过滤器和转换.

免费在线动画制作人

立即测试功能与 Aspose.Imaging 免费在线动画制作人 . 这个基于浏览器的应用程序显示了相同的 C#动画图书馆 功能,没有安装.

提示和最佳实践

  • 在框架组合之前验证图像大小和格式.
  • 使用GIF为兼容性,APNG为透明性.
  • 避免过度使用定制板块.
  • 设置临时物体以防止记忆泄漏.
  • Leverage async 出口用于大型框架集.

结论

NET 插件的 Aspose.Imaging Animation Maker 在 C# 中简化动画创作. 从动态 GIF 到先进的 APNG,它为开发人员提供工具,以有效地添加动力图像到 .Net 应用程序.

 中文