Barcodes.DataMatrix Namespace
DataMatrixControl Class
Barcodes.DataMatrix.dll assembly
|
|
About Method
Returns an about information.
Syntax
string About()
Return Value
String that specifies an about information.
|
SaveToImageFile Method
Saves the image of the barcode to a file.
Syntax
ErrorCodes SaveToImageFile(double cx, double cy, string sFileName, int lRes,
Dimensions dm)
Parameters
cx | A double that defines the barcode picture width. |
cy | A double that defines the barcode picture height. |
sFileName | A string expression defining the file name. |
lRes | A integer value that sets the picture resolution. |
dm | The Dimensions value. This value defines the units that should be used to specify cx and cy. See remarks. |
Return Value
ErrorCodes
Remarks
The format the file will be saved in depends on the extension of the file name For example, if you specify sFileName as "img1.jpg", the barcode will be saved as JPEG.
The following extensions can be used - "wmf", "emf", "bmp", "jpg", "jpeg", "gif", "tiff" and "png".
If the size of an image (cx, cy) is not specified in pixels, its actual size will be calculated using
the specified picture resolution - lRes.
Examples
/* 1. Save the image to a file of the JPEG format. The size of the image will be 200x200 pixels.*/
dataMatrixControl1.SaveToImageFile( 200, 200, "c:\\DataMatrix.jpg", 0, Barcodes.DataMatrix.Dimensions.dmPixels );
/* 2. Save the image to a file of the JPEG format. The size of the image will be 25x25 millimeters with the resolution of 300 dpi.*/
dataMatrixControl1.SaveToImageFile( 25, 25, "c:\\DataMatrix.jpg", 300, Barcodes.DataMatrix.Dimensions.dmMM ) ;
/* 3. Calculate the required matrix size. See GetMatrixSize method.*/
double w, h;
dataMatrixControl1.GetMatrixSize( 4, 96, 96, Barcodes.DataMatrix.Dimensions.dmPixels, Barcodes.DataMatrix.Dimensions.dmPixels, out w, out h );
// Save the image to a file of the JPEG format. The barcode will have the x-dimension of 4 pixels.
dataMatrixControl1.SaveToImageFile( w, h, "c:\\DataMatrix.jpg", 96, Barcodes.DataMatrix.Dimensions.dmPixels ) ;
|
DrawMatrixToSize Method
Draws the DataMatrix bar code in the device context or Graphics object. You can use either printer or screen.
Syntax
ErrorCodes DrawMatrixToSize(double x, double y, double cx, double cy, Dimensions dm, IntPtr hDC)
ErrorCodes DrawMatrixToSize(double x, double y, double cx, double cy, Dimensions dm, Graphics gr)
Parameters
X | A double value that defines the X coordinate of the barcode. |
Y | A double value that defines the Y coordinate of the barcode. |
CX | A double that defines the datamatrix width. |
CY | A double that defines the datamatrix height. |
dm | A Dimensions value. This value defines the units that should be used to specify cx and cy. |
hDC | The handle of the device context where the barcode will be drawn. |
gr |
A Graphics object. |
Return Value
ErrorCodes
Examples
// Draw a datamatrix to a screen.
Graphics gr = this.CreateGraphics();
dataMatrixControl1.DrawMatrixToSize( 0, 0, 200, 200, Barcodes.DataMatrix.Dimensions.dmPixels, gr );
// Print a datamatrix
// The OnPrintBarcodePage event is raised for each page to be printed.
private void OnPrintBarcodePage(object sender, PrintPageEventArgs ev)
{
double wMM, hMM;
dataMatrixControl1.GetMatrixSize( 0.5, (int)ev.Graphics.DpiX, (int)ev.Graphics.DpiY,
Barcodes.DataMatrix.Dimensions.dmMM, Barcodes.DataMatrix.Dimensions.dmMM, out wMM, out hMM );
// print a datamatrix barcode to X=10 mm, Y=10 mm with X-Dimension=0.5 mm
dataMatrixControl1.DrawMatrixToSize(10, 10, wMM, hMM, Barcodes.DataMatrix.Dimensions.dmMM,
ev.Graphics );
}
|
CopyToClipboard Method
Copies the image of the barcode onto the clipboard. After that you can insert this image into your
program using Ctrl+V or the Paste menu item.
Syntax
ErrorCodes CopyToClipboard(int cx, int cy)
Parameters
cx | An integer value that defines the barcode picture width |
cy | An integer value that defines the barcode picture height |
Return Value
ErrorCodes
|
GetMatrixSize Method
This method calculate the width and height that the DataMatrix must have in order to get the necessary x-dimension.
Syntax
ErrorCodes GetMatrixSize(double lModule, int xRes, int yRes, Dimensions dmIn, Dimensions dmOut, out double width, out double height)
Parameters
lModule | This double value that defines the necessary x-dimension. |
xRes | A long value that defines the resolution (in dpi) along x axis. |
yRes | A long value that defines the resolution (in dpi) along y axis. |
dmIn | A Dimensions value. This value defines the units that should be used to specify lModule. |
dmOut | A Dimensions value. This value defines the units that should be used to specify the width. |
width | Returns the necessary DataMatrix width. |
height | Returns the necessary DataMatrix height. |
Return Value
ErrorCodes
Example
double wMM, hMM;
dataMatrixControl1.GetMatrixSize( 0.5, (int)ev.Graphics.DpiX, (int)ev.Graphics.DpiY, Dimensions.dmMM, Dimensions.dmMM, out wMM, out hMM );
|