Marblecore Imaging Library Documentation

Documentation Introduction
Documentation / Marblecore Imaging / Methods / SaveToHBitmap

SaveToHBitmap method

Returns a HBITMAP for the current image which can be used to draw the image with high speed to a canvas like a Windows Form. This method is not available in the ATL version of the image component.

Syntax

HBITMAP SaveToHBitmap(nLeft As Number, nTop As Number, nWidth As Number, nHeight As Number)

Return value

Returns a HBITMAP if the function succeeded or NULL if the function failed.

Parameters

ParameterTypeRequiredDescription
nLeftNumberNoOptional parameter which specifies the left coordinate of the rectangle to return.
nTopNumberNoOptional parameter which specifies the top coordinate of the rectangle to return.
nWidthNumberNoOptional parameter which specifies the width of the rectangle to return.
nHeightNumberNoOptional parameter which specifies the height of the rectangle to return.

Example

The SaveToHBitmap method can be used to display an image in a .NET PictureBox or to create a System.Drawing.Bitmap of the image. In the example below we convert the image to a .NET bitmap and display it in a PictureBox with name pictureBox1. The example is written in C#.
 
1 // Create a new image class
2 MarblecoreImaging Imaging = new MarblecoreImaging();
3 
4 // Create a new image and draw a red rectangle on it
5 if (Imaging.Create(200, 200))
6 {
7     Imaging.DrawRectangleFilled(0, 0, 200, 200, Imaging.GetColorFromHTML("#ff0000"));
8 
9     // Create a bitmap of the image and attach it to the PictureBox
10    pictureBox1.Image = Image.FromHbitmap(Imaging.SaveToHBitmap());
11 }

Category

Basic operations

See also

Create | Deserialize | LoadFromBase64 | LoadFromFile | LoadFromSerializedStream | LoadFromStream | LoadFromURL | Reset | SaveToBase64 | SaveToFile | SaveToHBitmapPreMultiplied | SaveToStream | Serialize