Bildsammanfognare Aspose.Imaging för .NET-plugin
Image Merger .NET Plugin gör det möjligt för utvecklare att enkelt kombinera flera bilder till visuellt imponerande fotokollage. Med stöd för olika layouter - inklusive horisontella, vertikala, rutnäts- och anpassningsbara arrangemang - förenklar denna plugin processen att skapa sammansatta bilder.
Huvudfunktioner
*Versatile Merging alternativ
Enkelt sammanfoga bilder i horisontella, vertikala eller rutnätslayouter, eller skapa anpassade arrangemang skräddarsydda för dina specifika behov.
*Utökad formatstöd
Kombinera bilder från ett brett utbud av Stödda format Detta gör det till ett robust val för alla projekt.
Watermark-fri utgång
Lås upp fullständig funktionalitet genom att applicera en Metered-licens, så att dina resultat är fria från vattenstämplar.
Hur det fungerar
*ansöka om en måttlig licens Konfigurera plugin genom att ge din offentliga nyckel och privat lösenord med hjälp av
SetMeteredKey()
Metoden är.Ladda upp och kombinera bilder
Ladda upp källbilder i stödda format.
Skapa en ny
Image
objekt med en vit bakgrund, matchande de kombinerade dimensionerna av källbilderna.Använd den
DrawImage()
Metoden för denGraphics
klasser för att positionera bilder i din önskade layout.Save the Merged Image Spara den slutliga sammansatta bilden i ditt valda format.
Exempel användning
Här är ett C#-exempel som visar hur man slår samman bilder med hjälp av pluginet:
//--------------------------------------------------------------------------------------- | |
// 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 | |
} |
Gratis online bild sammanslagning verktyg
Utforska egenskaperna hos WL17_ Anmäla ansökan Kombinera bilder direkt utan behov av installation eller kodning, vilket gör det till en idealisk lösning för snabba uppgifter.
slutsatser
Aspose.Imaging .NET Plugin är det bästa .NET-biblioteket för bildsammanfogning som finns, och erbjuder effektiva och högupplösta bildsammanfogningsegenskaper. Oavsett om du behöver kombinera bilder i C# för ett projekt eller kräver en dynamisk bildsammanfogningslösning, är denna plugin utformad för att möta dina behov sömlöst. För utvecklare som vill programmeringsmässigt sammanfoga bilder eller utforska avancerade funktioner, är Aspose.Imaging .NET-handboken om bildsammanfogning en utmärkt resurs.
Utnyttja C# .NET image merge plugin free trial för att komma igång idag!