Welcome Guest! To enable all features, please Login or Register.



Last Go to last post Unread Go to first unread post
#1 Posted : Thursday, November 16, 2017 9:08:19 AM(UTC)


Groups: Tech Support, Administrators
Posts: 342

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)

Attached is a small .NET Core application written in C# using the LEADTOOLS 20 Barcode (.NET Standard) nuget package. This simple application generates an image with a QR code, outputs the image to a memory stream, and then reads the resulting MemoryStream to easily verify the encoding was done correctly.

The following sample code illustrates how a simple services could be written to process barcodes. Here's code illustrating barcode writing:

// Figure out how big to make the image
barcodeEngineInstance.Writer.CalculateBarcodeDataBounds(LeadRect.Empty, imageResolution, imageResolution, qrData, qrWriteOptions);
imageHeight = qrData.Bounds.Height;
imageWidth = qrData.Bounds.Width;

// Create an empty image
barcodeImage = new RasterImage(RasterMemoryFlags.Conventional, imageWidth, imageHeight, bitsPerPixel, RasterByteOrder.Rgb,
                               RasterViewPerspective.TopLeft, palette, IntPtr.Zero, userDataLength);

// Make the image all white
FillCommand fillCmd = new FillCommand(RasterColor.White);
// Write the barcode
barcodeEngineInstance.Writer.WriteBarcode(barcodeImage, qrData, qrWriteOptions); 

// Save the results
codecs.Save(barcodeImage, barcodeOutputStream, RasterImageFormat.CcittGroup4, bitsPerPixel); 

And here's code illustrating barcode reading:

// Decode the stream
barcodeImage = codecs.Load(inputStream, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1);

// Check for barcodes
dataArray = barcodeEngineInstance.Reader.ReadBarcodes(barcodeImage, LeadRect.Empty, 0, null);

// Get the barcode data to output
StringBuilder sb = new StringBuilder();
sb.AppendFormat("{0} barcode(s) found", dataArray.Length);

for (int i = 0; i < dataArray.Length; i++)
   BarcodeData data = dataArray[i];

   sb.AppendFormat("Symbology: {0}, Location: {1}, Data: {2}", data.Symbology.ToString(), data.Bounds.ToString(), data.Value);

Before running this application, please update the DEVELOPER_LIC and DEVELOPER_KEY class members to point to your license files.
File Attachment(s):
CS_DotNetStd_WriteQRBarcode.zip (5kb) downloaded 14 time(s).

Edited by moderator Thursday, November 16, 2017 4:18:44 PM(UTC)  | Reason: Not specified

Walter Bates
Senior Support Engineer
LEAD Technologies, Inc.

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2018, Yet Another Forum.NET
This page was generated in 0.142 seconds.