This code is used to split the multipage Tiff image into single single image using VB.net. First imports system.drawing.imaging for example: the tif file path is: "C:\test.tif" You can pass the file path in below function
Imports system.drawing.imaging
Private Sub SplitImages(ByVal files As String) 'Dim FileSubString As String = System.IO.Path.GetFileNameWithoutExtension(files) Dim pagecount, ImagePageCount As Integer Dim oimage As System.Drawing.Image = Nothing Dim fImage As Bitmap = Nothing Dim pageLoad As Boolean = False Dim docPath As String = "C:\" Try fImage = New Bitmap(files, False) oimage = fImage pagecount = oimage.GetFrameCount(FrameDimension.Page) pageLoad = True Catch ex As Exception pageLoad = False MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try If pageLoad = True Then If pagecount <> 0 Then For ImagePageCount = 0 To pagecount - 1 Dim strScanKey As String = System.Guid.NewGuid.ToString oimage.SelectActiveFrame(FrameDimension.Page, ImagePageCount) Dim img1 As Drawing.Bitmap = CType(oimage.Clone, Drawing.Bitmap) Dim documentPath As String = docPath & strScanKey & ".Tiff" img1.Save(documentPath) Next End If oimage.Dispose() fImage.Dispose() End If End Sub
|
No responses found. Be the first to respond and make money from revenue sharing program.
|