GdPicture.NET Reference Guide
Encode64String Method (GdPictureImaging)
Example 





GdPicture14 Namespace > GdPictureImaging Class : Encode64String Method
The source string to encode.
Returns an encoded string using the Base64 encoding algorithm from the given source string.
Syntax
'Declaration
 
Public Function Encode64String( _
   ByVal StringToEncode As String _
) As String
public string Encode64String( 
   string StringToEncode
)
public function Encode64String( 
    StringToEncode: String
): String; 
public function Encode64String( 
   StringToEncode : String
) : String;
public: string* Encode64String( 
   string* StringToEncode
) 
public:
String^ Encode64String( 
   String^ StringToEncode
) 

Parameters

StringToEncode
The source string to encode.

Return Value

The resulting encoded string.
Remarks
You can regularly apply the GetStat method to determine if this method has been successful.
Example
How to encode and decode an image file using Base64 encoded string.
Dim caption As String = "Example: Encode64String"
Using oImage As GdPictureImaging = New GdPictureImaging()
    Dim imageID As Integer = oImage.CreateGdPictureImageFromFile("")
    If oImage.GetStat() = GdPictureStatus.OK Then
        Dim fileString As String = oImage.SaveAsString(imageID, GdPicture14.DocumentFormat.DocumentFormatPNG, 6)
        If oImage.GetStat() = GdPictureStatus.OK Then
            'Encoding the image saved in fileString.
            Dim encodedString As String = oImage.Encode64String(fileString)
            oImage.ReleaseGdPictureImage(imageID)
            'Reloading the saved file from encodedString.
            imageID = oImage.CreateGdPictureImageFromString(oImage.Decode64String(encodedString))
            If oImage.GetStat() = GdPictureStatus.OK Then
                If oImage.SaveAsPNG(imageID, "myimage.png") = GdPictureStatus.OK Then
                    MessageBox.Show("The image has been saved successfully.", caption)
                Else
                    MessageBox.Show("An error occurred when saving the image. Status: " + oImage.GetStat().ToString(), caption)
                End If
            Else
                MessageBox.Show("The CreateGdPictureImageFromString() method has failed with the status: " + oImage.GetStat().ToString(), caption)
            End If
        Else
            MessageBox.Show("The SaveAsString() method has failed with the status: " + oImage.GetStat().ToString(), caption)
        End If
        oImage.ReleaseGdPictureImage(imageID)
    Else
        MessageBox.Show("The image can't be created. Status: " + oImage.GetStat().ToString(), caption)
    End If
End Using
string caption = "Example: Encode64String";
using (GdPictureImaging oImage = new GdPictureImaging())
{
    int imageID = oImage.CreateGdPictureImageFromFile("");
    if (oImage.GetStat() == GdPictureStatus.OK)
    {
        string fileString = oImage.SaveAsString(imageID, GdPicture14.DocumentFormat.DocumentFormatPNG, 6);
        if (oImage.GetStat() == GdPictureStatus.OK)
        {
            //Encoding the image saved in fileString.
            string encodedString = oImage.Encode64String(fileString);
            oImage.ReleaseGdPictureImage(imageID);
            //Reloading the saved file from encodedString.
            imageID = oImage.CreateGdPictureImageFromString(oImage.Decode64String(encodedString));
            if (oImage.GetStat() == GdPictureStatus.OK)
            {
                if (oImage.SaveAsPNG(imageID, "myimage.png") == GdPictureStatus.OK)
                    MessageBox.Show("The image has been saved successfully.", caption);
                else
                    MessageBox.Show("An error occurred when saving the image. Status: " + oImage.GetStat().ToString(), caption);
            }
            else
                MessageBox.Show("The CreateGdPictureImageFromString() method has failed with the status: " + oImage.GetStat().ToString(), caption);
        }
        else
            MessageBox.Show("The SaveAsString() method has failed with the status: " + oImage.GetStat().ToString(), caption);
        oImage.ReleaseGdPictureImage(imageID);
    }
    else
        MessageBox.Show("The image can't be created. Status: " + oImage.GetStat().ToString(), caption);
}
See Also

Reference

GdPictureImaging Class
GdPictureImaging Members
Decode64String Method