TIFF: Как объединить TIFF файлы?
В этом разделе
Вот C#/VB.NET код, который демонстрирует, как добавить страницы одного TIFF файла в другой TIFF файл:
namespace UserGuide.Programming.Tiff
{
class MergeTIFF
{
public void MergeTiffFiles(System.IO.Stream firstStream, System.IO.Stream secondStream)
{
// open the first TIFF file
using (Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile firstTiff =
new Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile(firstStream))
{
// open the second TIFF file
using (Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile secondTiff =
new Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile(secondStream))
{
// for each page in the second TIFF file
for (int i = 0; i < secondTiff.Pages.Count; i++)
{
// add page of the second TIFF file to the first TIFF file
firstTiff.Pages.Add(secondTiff.Pages[i]);
// save changes to the first TIFF file
firstTiff.SaveChanges();
}
}
}
}
}
}
Namespace UserGuide.Programming.Tiff
Class MergeTIFF
Public Sub MergeTiffFiles(firstStream As System.IO.Stream, secondStream As System.IO.Stream)
' open the first TIFF file
Using firstTiff As New Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile(firstStream)
' open the second TIFF file
Using secondTiff As New Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile(secondStream)
' for each page in the second TIFF file
For i As Integer = 0 To secondTiff.Pages.Count - 1
' add page of the second TIFF file to the first TIFF file
firstTiff.Pages.Add(secondTiff.Pages(i))
' save changes to the first TIFF file
firstTiff.SaveChanges()
Next
End Using
End Using
End Sub
End Class
End Namespace