GdPicture.NET Reference Guide
DisplayFromByteArray Method (GdViewer)
Example 





GdPicture14.WPF Namespace > GdViewer Class : DisplayFromByteArray Method
The document data stored in the array of bytes. This object must be properly initialized and it must be disposed of by the user as well.
Loads a document from an array of bytes 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 DisplayFromByteArray( _
   ByVal Data() As Byte _
) As GdPictureStatus
public GdPictureStatus DisplayFromByteArray( 
   byte[] Data
)
public function DisplayFromByteArray( 
    Data: Bytearray of
): GdPictureStatus; 
public function DisplayFromByteArray( 
   Data : byte[]
) : GdPictureStatus;
public: GdPictureStatus DisplayFromByteArray( 
   byte[]* Data
) 
public:
GdPictureStatus DisplayFromByteArray( 
   array<byte>^ Data
) 

Parameters

Data
The document data stored in the array of bytes. This object must be properly initialized and it must be disposed of by the user as well.

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 your image from an array of bytes.
'We assume that the GdViewer1 control has been properly integrated.
Dim oFile As System.IO.FileInfo
oFile = New System.IO.FileInfo("image.gif")
Dim oFileStream As System.IO.FileStream = oFile.OpenRead()
Dim lBytes As Integer = CInt(oFileStream.Length)
If (lBytes > 0) Then
    Dim fileData(lBytes - 1) As Byte
    oFileStream.Read(fileData, 0, lBytes)
    oFileStream.Close()
    If GdViewer1.DisplayFromByteArray(fileData) = GdPictureStatus.OK Then
        'Do your stuff here.
    Else
        MessageBox.Show("This file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.DisplayFromByteArray")
    End If
End If
//We assume that the GdViewer1 control has been properly integrated.
System.IO.FileInfo oFile;
oFile = new System.IO.FileInfo("image.gif");
System.IO.FileStream oFileStream = oFile.OpenRead();
int lBytes = System.Convert.ToInt32(oFileStream.Length);
if (lBytes > 0)
{
    byte[] fileData = new byte[lBytes];
    oFileStream.Read(fileData, 0, lBytes);
    oFileStream.Close();
    if (GdViewer1.DisplayFromByteArray(fileData) == GdPictureStatus.OK)
    {
        //Do your stuff here.
    }
    else
    {
        MessageBox.Show("This file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.DisplayFromByteArray");
    }
}
See Also

Reference

GdViewer Class
GdViewer Members
DisplayFromMemory Method
DisplayFromRawBits Method
DisplayFromStream(Stream) Method