Openize.Animated-GIF-SDK for .NET
Openize.Animated-GIF を使用して .NET で GIF アニメーションを作成および編集
フレーム、色、再生設定を正確に制御して GIF アニメーションを生成およびデコードするための C# の軽量ライブラリ。
Openize.Animated-GIF for .NET は、GIF アニメーションを作成および処理するために設計された .NET 用の軽量でオープンソースのライブラリです。この人気のある animated-gif-lib-for-java の C# バージョンは、高度な色量子化、透明性の制御、フレーム管理などの機能を備えた GIF のエンコードとデコードを強力にサポートします。
NuGet を介したインストールは簡単で、開発者は GIF の作成および処理機能を .NET アプリケーションに簡単に統合できます。Openize.Animated-GIF は、画像シーケンスから GIF アニメーションを生成し、既存の GIF からフレームとメタデータを抽出し、フレーム遅延、ループ回数、削除方法などのアニメーションパラメータを調整するために必要なツールを開発者に提供します。
このオープンソース SDK を改善するために、貢献、改善提案、または GitHub リポジトリの探索を行ってください: https://github.com/openize-com/openize-animated-gif-net
Openize.Animated-GIF for .NET の使い方
Openize.Animated-GIF for .NET をインストールする推奨方法は NuGet を使用することです。以下のコマンドを使用してスムーズにインストールしてください。
インストール
dotnet add package Openize.Animated.GIF
または NuGet パッケージ マネージャーを使用:
Install-Package Openize.Animated.GIF
クイックスタート
以下のコードスニペットは、Openize.Animated-GIF for .NET を使用して GIF アニメーションを作成および読み取る方法を示しています。
.NET SDK を使用して GIF アニメーションを作成
using Openize.Animated-GIF; using System.Drawing;
// Initialize the encoder
var encoder = new AnimatedGifEncoder();
encoder.Start("output.gif");
// Configure animation settings
encoder.SetDelay(500); // 500ms between frames
encoder.SetRepeat(0); // Loop infinitely
// Add frames
encoder.AddFrame(new Bitmap("frame1.png"));
encoder.AddFrame(new Bitmap("frame2.png"));
// Finish encoding
encoder.Finish();
GIF アニメーションを読み取る
// Initialize the decoder
var decoder = new GifDecoder();
decoder.Read("input.gif");
// Get information
int frameCount = decoder.GetFrameCount();
int loopCount = decoder.GetLoopCount(); // 0 = infinite
// Extract frames
for (int i = 0; i < frameCount; i++)
{
Bitmap frame = decoder.GetFrame(i);
frame.Save($"frame_{i}.png");
}
高度なオプション
// Configure transparency
encoder.SetTransparent(Color.White, true); // Exact match
// Set specific background color
encoder.SetBackground(Color.Black);
// Custom size (for oversized images)
encoder.SetSize(800, 600);