GdPicture.NET是目前市场上最完整的一款图片处理类SDK,该控件包含了成千上万个功能,可以浏览处理图片,也可以对文档类图片进行浏览处理,还可以进行条码的识别、图片的扫描、PDF文档处理,OCR以及OMR等多种常用功能,并且可以用于ActiveX、WInform,asp.net以及WPF等平台下,下面的代码主要讲述了如何利用该控件进行一维条形码的识别,具体如下:
GdPictureImaging oGdPictureImaging = new GdPictureImaging();
int imageId = oGdPictureImaging.CreateGdPictureImageFromFile("input.jpg");
if (imageId == 0)
{
MessageBox.Show("Image Could Not Be Loaded! " + oGdPictureImaging.GetStat().ToString());
}
else
{
//Specifying 1D barcode search types to be Code39 and Code128
Barcode1DReaderType barcodeType = Barcode1DReaderType.Barcode1DReaderCode39 | Barcode1DReaderType.Barcode1DReaderCode128;
//Start barcode scanning process
if (oGdPictureImaging.Barcode1DReaderDoScan(imageId, Barcode1DReaderScanMode.BestQuality, barcodeType, false, 1) == GdPictureStatus.OK)
{
//obtaining the number of barcodes found
int barcodeCount = oGdPictureImaging.Barcode1DReaderGetBarcodeCount();
//if barcodes were found
if (barcodeCount > 0)
{
//for each barcode display number, value and angle it is drawn at
for (int i = 1; i <= barcodeCount; i++)
{
MessageBox.Show("Barcode No: " + i.ToString());
MessageBox.Show("Value: " + oGdPictureImaging.Barcode1DReaderGetBarcodeValue(i).ToString());
MessageBox.Show("Angle: " + oGdPictureImaging.Barcode1DReaderGetBarcodeSkewAngle(i).ToString());
}
}
else
{
MessageBox.Show("No barcode detected !");
}
//Release detection info from memory
oGdPictureImaging.Barcode1DReaderClear();
}
//Release the image
oGdPictureImaging.ReleaseGdPictureImage(imageId);
}