DisplayFromRawBits Method (GdViewer)
In This Topic
Loads an image data stored within a raw bitmap in memory area and subsequently displays the image 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 document is displayed in the GdViewer control. Both events are only raised if the document has been successfully loaded.
Syntax
'Declaration
Public Function DisplayFromRawBits( _
ByVal As Integer, _
ByVal As Integer, _
ByVal As Integer, _
ByVal As PixelFormat, _
ByVal As IntPtr _
) As GdPictureStatus
public GdPictureStatus DisplayFromRawBits(
int ,
int ,
int ,
PixelFormat ,
IntPtr
)
public function DisplayFromRawBits(
: Integer;
: Integer;
: Integer;
: PixelFormat;
: IntPtr
): GdPictureStatus;
public function DisplayFromRawBits(
: int,
: int,
: int,
: PixelFormat,
: IntPtr
) : GdPictureStatus;
public: GdPictureStatus DisplayFromRawBits(
int ,
int ,
int ,
PixelFormat ,
IntPtr
)
public:
GdPictureStatus DisplayFromRawBits(
int ,
int ,
int ,
PixelFormat ,
IntPtr
)
Parameters
- Width
- Specifies the width of the defined raw bitmap, in pixels.
- Height
- Specifies the height of the defined raw bitmap, in pixels.
- Stride
- Specifies the byte offset between the beginning of one scan line and the next scan line. This is usually (but not necessarily) the number of bytes
in the pixel format (for example, 2 for 16 bits per pixel) multiplied by the width of the bitmap. The value passed to this parameter must be a multiple of four.
- PixelFormat
- A member of the PixelFormat enumeration. Specifies the pixel format of the defined raw bitmap.
- Bits
- A pointer to an array of bytes that contains the pixel data of the source image. This pointer must be properly initialized and it must be disposed of by the user as well.
Warning: Do not remove the raw bitmap from the memory until you close the displayed document.
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.
Example
How to display your image from a raw bitmap memory area.
'We assume that the GdViewer1 control has been properly integrated.
Dim iBits As IntPtr = IntPtr.Zero
'Initialize the image pointer to proper data.
If GdViewer1.DisplayFromRawBits(200, 200, 800, System.Drawing.Imaging.PixelFormat.Format24bppRgb, iBits) = GdPictureStatus.OK Then
'Do your stuff here.
Else
MessageBox.Show("This file can't be displayed. Status: " & GdViewer1.GetStat().ToString(), "GdViewer.DisplayFromRawBits")
End If
//We assume that the GdViewer1 control has been properly integrated.
IntPtr iBits = IntPtr.Zero;
//Initialize the image pointer to proper data.
if (GdViewer1.DisplayFromRawBits(200, 200, 800, System.Drawing.Imaging.PixelFormat.Format24bppRgb, iBits) == GdPictureStatus.OK)
{
//Do your stuff here.
}
else
{
MessageBox.Show("This file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.DisplayFromRawBits");
}
Example
How to display your image from a raw bitmap memory area.
'We assume that the GdViewer1 control has been properly integrated.
Dim iBits As IntPtr = IntPtr.Zero
'Initialize the image pointer to proper data.
If GdViewer1.DisplayFromRawBits(200, 200, 800, System.Drawing.Imaging.PixelFormat.Format24bppRgb, iBits) = GdPictureStatus.OK Then
'Do your stuff here.
Else
MessageBox.Show("This file can't be displayed. Status: " & GdViewer1.GetStat().ToString(), "GdViewer.DisplayFromRawBits")
End If
//We assume that the GdViewer1 control has been properly integrated.
IntPtr iBits = IntPtr.Zero;
//Initialize the image pointer to proper data.
if (GdViewer1.DisplayFromRawBits(200, 200, 800, System.Drawing.Imaging.PixelFormat.Format24bppRgb, iBits) == GdPictureStatus.OK)
{
//Do your stuff here.
}
else
{
MessageBox.Show("This file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.DisplayFromRawBits");
}
See Also