GdPicture.NET.14
GdPicture14 Namespace / GdViewer Class / DisplayFromRawBits Method
Specifies the width of the defined raw bitmap, in pixels.
Specifies the height of the defined raw bitmap, in pixels.
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.
A member of the PixelFormat enumeration. Specifies the pixel format of the defined raw bitmap.
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.
Example





In This Topic
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 Width As Integer, _
   ByVal Height As Integer, _
   ByVal Stride As Integer, _
   ByVal PixelFormat As PixelFormat, _
   ByVal Bits As IntPtr _
) As GdPictureStatus
public GdPictureStatus DisplayFromRawBits( 
   int Width,
   int Height,
   int Stride,
   PixelFormat PixelFormat,
   IntPtr Bits
)
public function DisplayFromRawBits( 
    Width: Integer;
    Height: Integer;
    Stride: Integer;
    PixelFormat: PixelFormat;
    Bits: IntPtr
): GdPictureStatus; 
public function DisplayFromRawBits( 
   Width : int,
   Height : int,
   Stride : int,
   PixelFormat : PixelFormat,
   Bits : IntPtr
) : GdPictureStatus;
public: GdPictureStatus DisplayFromRawBits( 
   int Width,
   int Height,
   int Stride,
   PixelFormat PixelFormat,
   IntPtr Bits
) 
public:
GdPictureStatus DisplayFromRawBits( 
   int Width,
   int Height,
   int Stride,
   PixelFormat PixelFormat,
   IntPtr Bits
) 

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.
Remarks
Please, be aware that you need to properly allocate the specified memory and you also need to release this memory after using it as well. At the same time, do not remove the raw bitmap from the memory until you close the displayed document.

Just to remind you that both the BeforeDocumentChange and the AfterDocumentChange events are raised using this method.

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