GdPicture.NET.14
GdPicture14 Namespace / GdViewer Class / DisplayFromGdPictureImage Method
A unique image identifier of the image resource to display, represented by the GdPictureImage object.

You are able to obtain this identifier using methods of the GdPictureImaging class when creating the image resource and you need to release the image resource after being used as well.

Example





In This Topic
DisplayFromGdPictureImage Method (GdViewer)
In This Topic
Loads an image represented by the unique image identifier referring to an associated GdPictureImage object and subsequently displays it in the GdViewer control. The document previously displayed in the control will automatically close.

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

Syntax
'Declaration
 
Public Function DisplayFromGdPictureImage( _
   ByVal ImageID As Integer _
) As GdPictureStatus
public GdPictureStatus DisplayFromGdPictureImage( 
   int ImageID
)
public function DisplayFromGdPictureImage( 
    ImageID: Integer
): GdPictureStatus; 
public function DisplayFromGdPictureImage( 
   ImageID : int
) : GdPictureStatus;
public: GdPictureStatus DisplayFromGdPictureImage( 
   int ImageID
) 
public:
GdPictureStatus DisplayFromGdPictureImage( 
   int ImageID
) 

Parameters

ImageID
A unique image identifier of the image resource to display, represented by the GdPictureImage object.

You are able to obtain this identifier using methods of the GdPictureImaging class when creating the image resource and you need to release the image resource after being used 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
Be aware that you need to release the image resource after being used, for example using the ReleaseGdPictureImage method.

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 image resource using the GdPictureImaging class.
'We assume that the GdViewer1 control has been properly integrated.
Using image As GdPictureImaging = New GdPictureImaging()
    'The File Open dialog box will pop up to select a file.
    Dim imageID As Integer = image.CreateGdPictureImageFromFile("")
    If image.GetStat() = GdPictureStatus.OK Then
        If GdViewer1.DisplayFromGdPictureImage(imageID) = GdPictureStatus.OK Then
            'Do your stuff here.
        Else
            MessageBox.Show("This file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.DisplayFromGdPictureImage")
        End If
        GdViewer1.CloseDocument()
        image.ReleaseGdPictureImage(imageID)
    Else
        MessageBox.Show("The image can't be loaded. Status: " + image.GetStat().ToString(), "GdViewer.DisplayFromGdPictureImage")
    End If
End Using
//We assume that the GdViewer1 control has been properly integrated.
using (GdPictureImaging image = new GdPictureImaging())
{
    //The File Open dialog box will pop up to select a file.
    int imageID = image.CreateGdPictureImageFromFile("");
    if (image.GetStat() == GdPictureStatus.OK)
    {
        if (GdViewer1.DisplayFromGdPictureImage(imageID) == GdPictureStatus.OK)
        {
            //Do your stuff here.
        }
        else
        {
            MessageBox.Show("This file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.DisplayFromGdPictureImage");
        }
        GdViewer1.CloseDocument();
        image.ReleaseGdPictureImage(imageID);
    }
    else
        MessageBox.Show("The image can't be loaded. Status: " + image.GetStat().ToString(), "GdViewer.DisplayFromGdPictureImage");
}
See Also