Welcome to LEAD Support Forum Login | Register | Faq  

    LEAD Support Forum
  Resource to find answers and post technical questions about LEAD products.
Search    
   

Re: creating barcode image
Started by cheedallarajesh at 11-06-2008 16:46. Topic has 7 replies.

Print Search « Previous Thread Next Thread »
  11-06-2008, 16:46
cheedallarajesh is not online. Last active: 12/16/2008 5:25:30 PM cheedallarajesh

Not Ranked
Joined on 11-06-2008
Posts 5
creating barcode image
Reply Quote

All the examples I see doesn't show a way to create the barcode image and save the image. I don't want to provide any image upfront but just want to save by creating barcode image dynamically. How can I do that?


   Report 
  11-06-2008, 18:59
cheedallarajesh is not online. Last active: 12/16/2008 5:25:30 PM cheedallarajesh

Not Ranked
Joined on 11-06-2008
Posts 5
Re: creating barcode image
Reply Quote

I am able to create the datamatrix barcode  using copied/modified snippet, but the problem is creation of RasterImage >> Size issue. Barcode, that it generated is of small size but the rasterimage size is huge. How can I calculate the size of barcode upfront so that I can create raster image of that specific size?

Appreciate your reply.

code snippet:

//dynamically creating image... size issue

RasterImage image = new RasterImage(RasterMemoryFlags.Conventional, 500, 500, 1, RasterByteOrder.Bgr, RasterViewPerspective.TopLeft, null, IntPtr.Zero, 0);

BarcodeEngine barEngine;

try

{

// Unlock linear barcode support.

// Note that this is a sample key, which will not work in your toolkit

RasterSupport.Unlock(RasterSupportType.BarcodesDataMatrixWrite, "TestKey");

// Initialize linear barcodes

BarcodeEngine.Startup(BarcodeMajorTypeFlags.BarcodesDatamatrixWrite);

barEngine = new BarcodeEngine();

BarcodeData barcodeData = new BarcodeData();

Rectangle rc = new Rectangle(0, 0, 0, 0);

barcodeData.Unit = BarcodeUnit.ScanlinesPerPixels;

barcodeData.Location = rc;

barcodeData.SearchType = BarcodeSearchTypeFlags.DatamatrixWriteRectangle; //.DatamatrixDefault;

//string[] barcodeText;

//barcodeText = new string[1];

//barcodeText[0] = "Broad";

//barcodeData.Data = BarcodeData.ConvertFromStringArray(barcodeText);

 

string[] barcodeText = new string[1];

barcodeText[0] = "TestValue";

byte[] convData = BarcodeData.ConvertFromStringArray(barcodeText);

barcodeData.Data = new byte[convData.Length - 1];

System.Array.Copy(convData, barcodeData.Data, barcodeData.Data.Length);

//barcodeData.SearchType = BarcodeSearchTypeFlags.DatamatrixDefault;

BarcodeColor barColor = new BarcodeColor();

barColor.BarColor = Color.Black;

barColor.SpaceColor = Color.White;

BarcodeWriteDatamatrix dmax = new BarcodeWriteDatamatrix();

dmax.Justify = BarcodeJustifyFlags.None;

dmax.FileIdLow = 0;

dmax.FileIdHigh = 0;

dmax.GroupNumber = 0;

dmax.GroupTotal = 0;

dmax.XModule = 0;

barEngine.Write(image, barcodeData, barColor, BarcodeWriteFlags.None, null, null, dmax, null, Rectangle.Empty);

BarcodeEngine.Shutdown();

}

catch (BarcodeException ex)

{

MessageBox.Show(ex.Message);

}

//rasterImageViewer1.Image = image;

pictureBox1.Image = image.ConvertToGdiPlusImage();


   Report 
  11-07-2008, 17:28
GregR is not online. Last active: 1/2/2009 9:03:27 AM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,811
Re: creating barcode image
Reply Quote
Unfortunately there's not any kind of "no write" option where you can just get the size of the barcode in the .NET interface.  This is possible in the CDLL interface so I'm not sure why it doesn't exist in the .NET as well.  I will have to check with my manager to get more details regarding this and if there's no specific reason I'll submit a feature request.  I'll post back whenever I get more details (since it's the weekend, this probably won't be until Monday or Tuesday.

As a workaround, you can create an image that's definitley large enough and fill it with white, then use the AutoCropCommand to trim the image down to just the barcode.

Greg Ross
LEADTOOLS Technical Support
   Report 
  11-07-2008, 18:20
cheedallarajesh is not online. Last active: 12/16/2008 5:25:30 PM cheedallarajesh

Not Ranked
Joined on 11-06-2008
Posts 5
Re: creating barcode image
Reply Quote
Can you shed some light on how to use AutoCrop command? I mean, once I have the image (barcode in it), how to detect the place and size of barcode inside the image to crop and get the barcode image?

Thanks in advance.


   Report 
  11-11-2008, 10:28
GregR is not online. Last active: 1/2/2009 9:03:27 AM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,811
Re: creating barcode image
Reply Quote
In regards to getting the barcode rectangle, it appears this was reported a while ago with the incident number 7097IDT.  They decided to add a new function, CalculateBarcodeSize.  I will contact you whenever a patch has been made that contains this new function.

The AutoCrop command doesn't take any parameters regarding where to crop.  It will simply trim the image down the whitespace surrounding the barcode.  Therefore as long as your entire barcode fit inside of the image, then the AutoCropCommand will crop the image down to the exact size of the barcode.

Greg Ross
LEADTOOLS Technical Support
   Report 
  12-11-2008, 5:09
rwijgers is not online. Last active: 12/11/2008 10:04:23 AM rwijgers

Not Ranked
Joined on 12-11-2008
Posts 1
Re: creating barcode image
Reply Quote
Can you giva an example of how the CaklculatebarcodeSize function works.

When i use this:
Rectangle rc = barEngine.CalculateBarcodeSize(0, 0, barcodeData, null, BarcodeWriteFlags.None, bar1d, null, null, null);

i keep getting an error: the struct size is invalid. And it doesn't for every value of dpiX and dpiY i have tried.

Besides that i cant seem to find the autoCropCommand in teh assemblies. Thanks for any help in advance.

Regards,
Rob Wijgers
   Report 
  12-12-2008, 9:46
jigar is not online. Last active: 12/12/2008 5:08:42 PM jigar



Top 10 Posts
Joined on 08-22-2007
Posts 479
Re: creating barcode image
Reply Quote
That function doesn't work properly and a fix is on the way.  I'm just waiting on a new DLL to be built and I will update you when it's been released.

LEADTOOLS Technical Support
   Report 
  12-15-2008, 12:37
jigar is not online. Last active: 12/12/2008 5:08:42 PM jigar



Top 10 Posts
Joined on 08-22-2007
Posts 479
Re: creating barcode image
Reply Quote
Hello, the fixed DLL has been built.  Send us an email at support@leadtools.com and put a link to this thread we will send you the updated Leadtools.Barcode.dll file.

LEADTOOLS Technical Support
   Report 
Post
LEAD Support Fo... » LEAD/Axtel Barc... » Barcode » Re: creating barcode image

Powered by Community Server, by Telligent Systems