Private Sub cmdSave_Click(sender As Object, e As RoutedEventArgs) Handles cmdSave.Click
If ListToLoadX Is Nothing Then
MessageBox.Show("There are no image(s) to save.")
Exit Sub
End If
Try
Me.Cursor = Cursors.Wait
Dim SaveFileDialog = New SaveFileDialog
SaveFileDialog.Title = "Export Image As..."
SaveFileDialog.Filter = "Image Files (*.tif)|*.tif"
Dim ImageArr As New ArrayList
For Each XYA As ToLoadImages In ListToLoadX
ImageArr.Add(XYA.ImageX)
Next
Dim MasterBitMap As Bitmap = BitMapImage2BitMap(ImageArr.Item(0))
ExportSaved = ""
'Select the image encoder
Dim enc As Encoder = Encoder.SaveFlag
Dim info As ImageCodecInfo = Nothing
Dim ice As ImageCodecInfo
For Each ice In ImageCodecInfo.GetImageEncoders()
If ice.MimeType = "image/tiff" Then
info = ice
End If
Next ice
Dim ep As New EncoderParameters(1)
ep.Param(0) = New EncoderParameter(enc, CLng(EncoderValue.MultiFrame))
If SaveFileDialog.ShowDialog Then
Dim fileName As String = SaveFileDialog.FileName
MasterBitMap.Save(fileName, info, ep)
ep.Param(0) = New EncoderParameter(enc, CLng(EncoderValue.FrameDimensionPage))
'add all images from index 1 to n
Dim i As Integer
For i = 1 To (ImageArr.Count) - 1
MasterBitMap.SaveAdd(BitMapImage2BitMap(ImageArr.Item(i)), ep)
Next i
ep.Param(0) = New EncoderParameter(enc, CLng(EncoderValue.Flush))
MasterBitMap.SaveAdd(ep)
'Return True
MsgBox("File was saved successfully.")
ExportSaved = fileName 'True
End If
Me.Cursor = Cursors.Arrow
Me.Close()
Catch ee As System.Exception
ExportSaved = False
Me.Cursor = Cursors.Arrow
Throw New Exception(ee.Message & "Error in saving as multipage")
End Try
End Sub
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.