Barcode.DrawBitmap
DrawBitmap()
Bitmap TECIT.TBarCode.Barcode.DrawBitmap()Draws the barcode into a bitmap.
The width and the height of the bitmap are taken from the The BoundingRectangle. Attention: Width and height of the bounding rectangle must be given in pixels. If the bar code resolution should follow the Dpi property, set IgnoreDpiFromDC = true.
This example draws a barcode-bitmap that is 200 x 75 pixels large:
Barcode barcode = new Barcode();
...
barcode.BoundingRectangle = new Rectangle(0, 0, 200, 75);
using (Bitmap bitmap = barcode.DrawBitmap())
{
...
}
Be aware of the system limit of GDI objects: Only disposing the returned bitmap frees up consumed GDI handles immediately.
Returns
Bitmap with barcode.
DrawBitmap(int, int)
Bitmap TECIT.TBarCode.Barcode.DrawBitmap(int width, int height)Draws the barcode into a bitmap.
The parameters width and height specify the size of the whole bitmap. The BoundingRectangle specifies the size of the barcode in the bitmap. If the bar code resolution should follow the Dpi property, set IgnoreDpiFromDC = true.
This example draws a barcode-bitmap that is 200 x 75 pixels large:
Barcode barcode = new Barcode();
...
barcode.BoundingRectangle = new Rectangle(0, 0, 200, 75);
Bitmap bitmap = barcode.DrawBitmap(200, 75);
The following example draws a barcode that is centered in a bitmap. A border of 10 pixels (in background color) surrounds the barcode.
Barcode barcode = new Barcode();
...
barcode.BoundingRectangle = new Rectangle(10, 10, 180, 80);
Bitmap bitmap = barcode.DrawBitmap(200, 100);
For this method the unit of the bounding rectangle values, width and height is pixel. Be aware of the system limit of GDI objects: Dispose() the returned bitmap to free up consumed GDI handles immediately.
Parameters
| Parameter / type | Description |
|---|---|
width int |
The width of the bitmap [Pixels]. |
height int |
The height of the bitmap [Pixels]. |
Returns
Bitmap with barcode.