LEADTOOLS Support
Imaging
Imaging SDK Examples
HOW TO: Merge Raster files into a single output file
#1
Posted
:
Tuesday, December 17, 2019 12:19:47 PM(UTC)
Groups: Manager, Tech Support, Administrators
Posts: 218
Was thanked: 12 time(s) in 12 post(s)
Attached is a simple .NET Core application that shows how to load and merge images into a single output image.
Here is the relevant code:
Code:static void Merge(MergeFile[] mergeFiles, string outputFile, RasterImageFormat outputFormat)
{
using RasterCodecs codecs = new RasterCodecs();
RasterImage image = null;
try
{
foreach (var mergeFile in mergeFiles)
{
if (image == null)
image = codecs.Load(mergeFile.FileName, 0, CodecsLoadByteOrder.BgrOrGray, mergeFile.FirstPage, mergeFile.LastPage);
else
image.AddPages(codecs.Load(mergeFile.FileName, 0, CodecsLoadByteOrder.BgrOrGray, mergeFile.FirstPage, mergeFile.LastPage), mergeFile.FirstPage, mergeFile.LastPage);
}
codecs.Save(image, outputFile, outputFormat, 0);
}
finally
{
image.Dispose();
}
}
Code: MergeFile mergeFile1 = new MergeFile
{
FileName = @"C:\Users\Public\Documents\LEADTOOLS Images\ocr1-4.tif",
FirstPage = 1,
LastPage = -1
};
MergeFile mergeFile2 = new MergeFile
{
FileName = @"C:\Users\Public\Documents\LEADTOOLS Images\ocr1-4.tif",
FirstPage = 1,
LastPage = -1
};
Merge(new MergeFile[] { mergeFile1, mergeFile2 }, @"C:\Temp\out.tif", RasterImageFormat.TifJpeg411);
Hadi Chami
Developer Support Manager
LEAD Technologies, Inc.
LEADTOOLS Support
Imaging
Imaging SDK Examples
HOW TO: Merge Raster files into a single output file
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.