GdPicture.NET.14
GdPicture14 Namespace / GdViewer Class / DisplayFromString Method
A string which contains data of the file to display.
Example





In This Topic
DisplayFromString Method (GdViewer)
In This Topic
Loads a document from a file, which data are stored within a string using Encoding 1252 and subsequently displays it in the GdViewer control. The document previously displayed in the control will automatically close.

All document formats currently supported by the toolkit are listed here.

The BeforeDocumentChange and the AfterDocumentChange events are raised just before and right after the document is displayed in the GdViewer control. Both events are only raised if the document has been successfully loaded.

Syntax
'Declaration
 
Public Function DisplayFromString( _
   ByVal Data As String _
) As GdPictureStatus
public GdPictureStatus DisplayFromString( 
   string Data
)
public function DisplayFromString( 
    Data: String
): GdPictureStatus; 
public function DisplayFromString( 
   Data : String
) : GdPictureStatus;
public: GdPictureStatus DisplayFromString( 
   string* Data
) 
public:
GdPictureStatus DisplayFromString( 
   String^ Data
) 

Parameters

Data
A string which contains data of the file to display.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK. We strongly recommend always checking this status first.
Remarks
Just to remind you that both the BeforeDocumentChange and the AfterDocumentChange events are raised using this method.
Example
How to display the image using the well-formatted string.
'We assume that the GdViewer1 control has been properly integrated.
Using oGdPictureImaging As GdPictureImaging = New GdPictureImaging()
    'The File Open dialog box will pop up to select a file.
    Dim imageID As Integer = oGdPictureImaging.CreateGdPictureImageFromFile("")
    If oGdPictureImaging.GetStat() = GdPictureStatus.OK Then
        Dim fileString As String = oGdPictureImaging.Encode64String(oGdPictureImaging.SaveAsString(imageID, GdPicture14.DocumentFormat.DocumentFormatTIFF, 65536))
        oGdPictureImaging.ReleaseGdPictureImage(imageID)
        If oGdPictureImaging.GetStat() = GdPictureStatus.OK Then
            If GdViewer1.DisplayFromString(oGdPictureImaging.Decode64String(fileString)) = GdPictureStatus.OK Then
                'Do your stuff here.
            Else
                MessageBox.Show("This file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.DisplayFromString")
            End If
        Else
            MessageBox.Show("This file can't be transformed. Status: " + oGdPictureImaging.GetStat().ToString(), "GdViewer.DisplayFromString")
        End If
    Else
        MessageBox.Show("This file can't be loaded. Status: " + oGdPictureImaging.GetStat().ToString(), "GdViewer.DisplayFromString")
    End If
End Using
//We assume that the GdViewer1 control has been properly integrated.
using (GdPictureImaging oGdPictureImaging = new GdPictureImaging())
{
    //The File Open dialog box will pop up to select a file.
    int imageID = oGdPictureImaging.CreateGdPictureImageFromFile("");
    if (oGdPictureImaging.GetStat() == GdPictureStatus.OK)
    {
        string fileString = oGdPictureImaging.Encode64String(oGdPictureImaging.SaveAsString(imageID, GdPicture14.DocumentFormat.DocumentFormatTIFF, 65536));
        oGdPictureImaging.ReleaseGdPictureImage(imageID);
        if (oGdPictureImaging.GetStat() == GdPictureStatus.OK)
        {
            if (GdViewer1.DisplayFromString(oGdPictureImaging.Decode64String(fileString)) == GdPictureStatus.OK)
            {
                //Do your stuff here.
            }
            else
                MessageBox.Show("This file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.DisplayFromString");
        }
        else
            MessageBox.Show("This file can't be transformed. Status: " + oGdPictureImaging.GetStat().ToString(), "GdViewer.DisplayFromString");
    }
    else
        MessageBox.Show("This file can't be loaded. Status: " + oGdPictureImaging.GetStat().ToString(), "GdViewer.DisplayFromString");
}
See Also