troubleshooting Question

I need help with .Tiff images being to large when saved from my WPF vb.Net

Avatar of mainrotor
mainrotor asked on
* WPFVisual Basic.NET.NET Programming
2 Comments1 Solution64 ViewsLast Modified:
Hi Experts,
I have a WPF application with VB.Net code-behind.

When I save my document as a .tiff file to a directory, then later print the saved document it prints in normal 8 1/2 x 11 (i.e. Letter size).

When I fax that same saved document the one page is jumbo sized and takes up 6 pages.

What am I doing wrong?

Here is my code below:
    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
ASKER CERTIFIED SOLUTION
Dr. KlahnPrincipal Software Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”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.

-Mike Kapnisakis, Warner Bros