Avatar of mainrotor
mainrotor
 asked on

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

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

Open in new window

* WPFVisual Basic.NET.NET Programming

Avatar of undefined
Last Comment
mainrotor

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Dr. Klahn

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
mainrotor

ASKER
Dr. Klahn,
Are you suggesting that I set the size of my image to 204x98 DPI or 204x196 DPI?
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck