Encode and Decode Images (Base64)

Discussions about image processing and document imaging.
Post Reply
gtoledo
Posts: 46
Joined: Thu May 28, 2009 7:30 pm

Encode and Decode Images (Base64)

Post by gtoledo » Fri May 06, 2016 1:09 am

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

Cedric
Posts: 269
Joined: Sun Sep 02, 2012 7:30 pm

Re: Encode and Decode Images (Base64)

Post by Cedric » Fri May 06, 2016 2:48 pm

Hello,

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

gtoledo
Posts: 46
Joined: Thu May 28, 2009 7:30 pm

Re: Encode and Decode Images (Base64)

Post by gtoledo » Fri May 06, 2016 3:54 pm

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.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest