イメージマージャー Aspose.Imaging for .NET プラグイン
Image Merger .NET Pluginは、開発者が複数の画像を視覚的に美しいフォトコラージュに簡単に組み合わせることを可能にします。水平、垂直、タイル、カスタマイズ可能な配置を含むさまざまなレイアウトをサポートしており、このプラグインは合成画像を作成するプロセスを効率化します。
主な特徴
*バージョン・オプション
画像を水平、垂直、またはタイル状のレイアウトで簡単に結合するか、特定のニーズに合わせたカスタム配置を作成します。
拡張フォーマットサポート
幅広い範囲の画像を組み合わせる サポートされたフォーマット それは、あらゆるプロジェクトのための強力な選択です。
Watermark フリー出力
メーターライセンスを適用して完全な機能をアンロックし、結果がウォーターマークなしになることを保証します。
どのように機能するか
測定ライセンスを申請する プラグインを設定して、公共のキーとプライベートパスワードを提供します。
SetMeteredKey()
メソッド画像をアップロードして組み合わせる
ソース画像をサポートされたフォーマットにアップロードします。
新しいものを作る
Image
白い背景を持つオブジェクトは、ソース画像の組み合わせサイズと一致します。利用する →
DrawImage()
メソッドのTheGraphics
あなたの望ましいレイアウトに画像を置くクラス。画像を保存する 選択した形式で最終的な合成画像を保存してください。
例使用
C#の例として、プラグインを使用して画像をマージする方法を示します:
//--------------------------------------------------------------------------------------- | |
// Image merge plug-in use examples | |
//--------------------------------------------------------------------------------------- | |
using Aspose.Imaging; | |
using Aspose.Imaging.FileFormats.Emf; | |
using Aspose.Imaging.FileFormats.Png; | |
using Aspose.Imaging.FileFormats.Tiff; | |
using Aspose.Imaging.FileFormats.Tiff.Enums; | |
using Aspose.Imaging.ImageOptions; | |
using Aspose.Imaging.Sources; | |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
string templatesFolder = @"c:\Users\USER\Downloads\templates\"; | |
string dataDir = templatesFolder; | |
Run4(); | |
void Run4() | |
{ | |
// Valid image merge license use example | |
Metered license = new Metered(); | |
// Only metered plug-in license is supported | |
license.SetMeteredKey("<your public key>", "<your private key>"); | |
string OutputDirectory = templatesFolder; | |
var images = new List<Image>(); | |
int maxWidth = 0; | |
int maxHeight = 0; | |
int totalWidth = 0; | |
int totalHeight = 0; | |
string[] imagePaths = new string[] { "template.png", "template.jpg", "template.bmp" }; | |
foreach (string fileName in imagePaths) | |
{ | |
var image = Image.Load(Path.Combine(templatesFolder, fileName)); | |
totalWidth += image.Width; | |
if (image.Width > maxWidth) | |
{ | |
maxWidth = image.Width; | |
} | |
totalHeight += image.Height; | |
if (image.Height > maxHeight) | |
{ | |
maxHeight = image.Height; | |
} | |
images.Add(image); | |
} | |
try | |
{ | |
var outputPath = Path.Combine(OutputDirectory, "licensed_merge_horizontal.jpg"); | |
MergeImages(images, MergeDirection.Horizontal, totalWidth, maxHeight, outputPath); | |
File.Delete(outputPath); | |
outputPath = Path.Combine(OutputDirectory, "licensed_merge_vertical.jpg"); | |
MergeImages(images, MergeDirection.Vertical, totalHeight, maxWidth, outputPath); | |
File.Delete(outputPath); | |
// Unlicensed crop with merge plug-in license | |
outputPath = Path.Combine(OutputDirectory, "trial_merge_vertical.jpg"); | |
MergeImages(images, MergeDirection.Vertical, totalHeight, maxWidth, outputPath, | |
(image) => | |
{ | |
var rasterImage = image as RasterImage; | |
if (rasterImage == null) | |
{ | |
return false; | |
} | |
rasterImage.Crop(new Rectangle(0, 0, image.Width >> 1, image.Height >> 1)); | |
return true; | |
} | |
); | |
File.Delete(outputPath); | |
} | |
finally | |
{ | |
images.ForEach(image => image.Dispose()); | |
} | |
} | |
void MergeImages(List<Image> images, MergeDirection direction, int totalSize, int maxSize, string outputPath, Func<Image, bool> callback = null) | |
{ | |
int targetWidth, targetHeight; | |
switch (direction) | |
{ | |
case MergeDirection.Horizontal: | |
{ | |
targetWidth = totalSize; | |
targetHeight = maxSize; | |
break; | |
} | |
case MergeDirection.Vertical: | |
{ | |
targetWidth = maxSize; | |
targetHeight = totalSize; | |
break; | |
} | |
default: | |
throw new ArgumentException("Unexpected merge direction"); | |
} | |
var pngOptions = new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha }; | |
using (Stream stream = new MemoryStream()) | |
{ | |
pngOptions.Source = new StreamSource(stream); | |
using (var image = Image.Create(pngOptions, targetWidth, targetHeight)) | |
{ | |
image.BackgroundColor = Color.White; | |
var graphics = new Graphics(image); | |
float x = 0, y = 0; | |
images.ForEach(image => | |
{ | |
graphics.DrawImage(image, new RectangleF(x, y, image.Width, image.Height)); | |
if (direction == MergeDirection.Horizontal) | |
{ | |
x += image.Width; | |
} | |
if (direction == MergeDirection.Vertical) | |
{ | |
y += image.Height; | |
} | |
}); | |
if (callback != null) | |
{ | |
callback(image); | |
} | |
image.Save(outputPath); | |
} | |
} | |
} | |
enum MergeDirection | |
{ | |
Horizontal = 0, | |
Vertical = 1 | |
} |
無料オンライン画像合併ツール
特性を調べる → ASPOSE.Imaging 合併アプリケーション 無料オンラインデモを通じて、インストールやコーディングの必要性なしに直接画像を組み合わせ、迅速な作業のための理想的なソリューションとなります。
結論
Aspose.Imaging .NET プラグインは、効率的で高解像度の画像結合機能を提供する最高の .NET 画像結合ライブラリです。プロジェクトのために C# で画像を結合する必要がある場合でも、動的な画像結合ソリューションが必要な場合でも、このプラグインはあなたのニーズにシームレスに応えるように設計されています。プログラムで画像を結合することを考えている開発者や、先進的な機能を探求したい開発者にとっては、画像結合に関する Aspose.Imaging .NET チュートリアルが素晴らしいリソースです。
C# .NET画像マージプラグインの無料トライアルを利用して、今日は始めましょう!