Page 1 of 1

Encode and Decode Images (Base64)

Posted: Fri May 06, 2016 1:09 am
by gtoledo
Hi,

I'm working with multipage TIF images, same as I have coded in Base64 string and then decode them.

The problem is when I apply decoding only one file is created with the first image.

Regards.

Code: Select all

 Private Sub btnCodifica_Click(sender As Object, e As EventArgs) Handles btnCodifica.Click
        Try
            If Not String.IsNullOrEmpty(txtPathFIle.Text) Then
                Dim imageID As Integer = oGdPictureImaging.CreateGdPictureImageFromFile(txtPathFIle.Text)

                If oGdPictureImaging.GetStat = GdPictureStatus.OK Then
                    Dim fileString As String = oGdPictureImaging.Encode64String(oGdPictureImaging.SaveAsString(imageID, DocumentFormat.DocumentFormatTIFF, 65536))
                    oGdPictureImaging.ReleaseGdPictureImage(imageID)

                    txtBase64.Text = fileString
                End If
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Error...", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try

    End Sub

    Private Sub btnDecodifica_Click(sender As Object, e As EventArgs) Handles btnDecodifica.Click
        Try
            If Not String.IsNullOrEmpty(txtBase64.Text) Then

                Dim imageID As Integer = oGdPictureImaging.CreateGdPictureImageFromString(oGdPictureImaging.Decode64String(txtBase64.Text))
                If oGdPictureImaging.GetStat = GdPictureStatus.OK Then

                    Dim sPathOut As String = "C:\ImageDecode.tif"

                    oGdPictureImaging.SaveAsPNG(imageID, sPathOut)
                    oGdPictureImaging.ReleaseGdPictureImage(imageID)
                End If
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Error...", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

Re: Encode and Decode Images (Base64)

Posted: Fri May 06, 2016 2:48 pm
by Cedric
Hello,

I don't understand your issue, the source code you provide saves the first page to a PNG file, is this correct?

Re: Encode and Decode Images (Base64)

Posted: Fri May 06, 2016 3:54 pm
by gtoledo
Ok, these are the details, we are developing an application that allows us to encoding and decoding multipage TIFF file. We have with successfully image coding and Base64 string is stored in a TXT file, then this file is decoded, but the problem is that only throws a page, being that this should be multipage.