Welcome to LEAD Support Forum Login | Register | Faq  

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

Re: All black barcode
Started by JimHaas at 11-06-2008 12:19. Topic has 4 replies.

Print Search « Previous Thread Next Thread »
  11-06-2008, 12:19
JimHaas is not online. Last active: 11/6/2008 5:13:26 PM JimHaas

Not Ranked
Joined on 11-06-2008
Posts 3
All black barcode
Reply Quote
Using the following snippet of code (which is almost identical to the sample), all I get is a black rectangle.

m_BarcodeEngine = new BarcodeEngine();
RasterSupport.Unlock(RasterSupportType.Barcodes1D, "");

BarcodeEngine.Startup(BarcodeMajorTypeFlags.Barcodes1d);
RasterCodecs.Startup();

Guid ID = Guid.Empty();
Rectangle BarcodeArea = new Rectangle(0,0,800,600);
RasterImage barcodeImage = new RasterImage(RasterMemoryFlags.Conventional, BarcodeArea.Width, BarcodeArea.Height, 1, RasterByteOrder.Bgr, RasterViewPerspective.TopLeft, null, IntPtr.Zero, 0);

BarcodeData barcodeData = new BarcodeData();
barcodeData.Unit = BarcodeUnit.ScanlinesPerPixels;
barcodeData.Location = new Rectangle(0, 0, BarcodeArea.Width, BarcodeArea.Height);
barcodeData.SearchType = BarcodeSearchTypeFlags.Barcode1dCode128;
barcodeData.Data = ID.ToByteArray();

BarcodeColor barcodeColor = new BarcodeColor();
barcodeColor.BarColor = Color.Black;
barcodeColor.SpaceColor = Color.White;

Barcode1d barcode = new Barcode1d();
barcode.Direction = BarcodeDirectionFlags.LeftToRight;

BarcodeWritePdf dummy1 = new BarcodeWritePdf();
BarcodeWriteDatamatrix dummy2 = new BarcodeWriteDatamatrix();
BarcodeWriteQr dummy3 = new BarcodeWriteQr();

m_BarcodeEngine.Write(barcodeImage, barcodeData, barcodeColor, BarcodeWriteFlags.UseColors | BarcodeWriteFlags.Transparent | BarcodeWriteFlags.InitializationReader | BarcodeWriteFlags.DisableCompression, barcode, dummy1, dummy2, dummy3, barcodeData.Location);
Image convertedImage = barcodeImage.ConvertToGdiPlusImage();
Form testForm = new Form();
testForm.Size = new Size(BarcodeArea.Width + 15, BarcodeArea.Height + 40);
PictureBox pic = new PictureBox();
testForm.Controls.Add(pic);
pic.Location = new Point(5, 5);
pic.Size = BarcodeArea.Size;
pic.Image = convertedImage;
testForm.ShowDialog();

Any idea what might be the cause? Thanks in advance.

Jim
   Report 
  11-06-2008, 16:27
JimHaas is not online. Last active: 11/6/2008 5:13:26 PM JimHaas

Not Ranked
Joined on 11-06-2008
Posts 3
Re: All black barcode
Reply Quote
I can get the barcode displaying now using the following code:

RasterSupport.Unlock(RasterSupportType.Barcodes1D, "");
BarcodeEngine.Startup(BarcodeMajorTypeFlags.Barcodes1d);
RasterCodecs.Startup();

BarcodeEngine m_BarcodeEngine = new BarcodeEngine();
Point location = new Point(1, 1);
Size size = new Size(1200, 300);
Guid ID = Guid.NewGuid();

RasterImage barcodeImage = new RasterImage(RasterMemoryFlags.Conventional, size.Width, size.Height, 1, RasterByteOrder.Bgr, RasterViewPerspective.TopLeft, null, IntPtr.Zero, 0);

BarcodeData barcodeData = new BarcodeData();
barcodeData.Unit = BarcodeUnit.ScanlinesPerPixels;
barcodeData.Location = new Rectangle(location, Size.Empty);
barcodeData.SearchType = BarcodeSearchTypeFlags.Barcode1dCode128;
string[] barcodeText;
barcodeText = new string[1];
barcodeText[0] = Guid.NewGuid().ToString();
barcodeData.Data = BarcodeData.ConvertFromStringArray(barcodeText);
//barcodeData.Data = ID.ToByteArray();

BarcodeColor barcodeColor = new BarcodeColor();
barcodeColor.BarColor = Color.Black;
barcodeColor.SpaceColor = Color.White;

Barcode1d barcode = new Barcode1d();
barcode.OutShowText = true;
barcode.Direction = BarcodeDirectionFlags.LeftToRight;

BarcodeWritePdf dumb1 = new BarcodeWritePdf();
BarcodeWriteDatamatrix dumb2 = new BarcodeWriteDatamatrix();
BarcodeWriteQr dumb3 = new BarcodeWriteQr();

m_BarcodeEngine.Write(barcodeImage, barcodeData, barcodeColor, BarcodeWriteFlags.UseColors | BarcodeWriteFlags.Transparent | BarcodeWriteFlags.InitializationReader | BarcodeWriteFlags.DisableCompression, barcode, dumb1, dumb2, dumb3, Rectangle.Empty);
Image convertedImage = barcodeImage.ConvertToGdiPlusImage();
Form testForm = new Form();
testForm.Size = new Size(size.Width + 15, size.Height + 40);
PictureBox pic = new PictureBox();
testForm.Controls.Add(pic);
pic.Location = new Point(5, 5);
pic.Size = size;
pic.Image = convertedImage;
testForm.ShowDialog();

HOWEVER, if I use the Guid.ToByteArray() method, I get a BarcodeException with the message, "Invalid Barcode Width". Any suggestions?

Thanks!
Jim
   Report 
  11-07-2008, 13:52
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: All black barcode
Reply Quote
What is the file version of Leadtools.dll that you are using?

Greg Ross
LEADTOOLS Technical Support
   Report 
  11-10-2008, 10:00
JimHaas is not online. Last active: 11/6/2008 5:13:26 PM JimHaas

Not Ranked
Joined on 11-06-2008
Posts 3
Re: All black barcode
Reply Quote
I am using version 16. It appears, though, that my problem was instantiating my BarcodeEngine class before unlocking the library. I can generate barcodes now.

However, a new problem I am having is that there seems to be a maximum render size for the barcode. It seems that no matter what number I plug in for the width of the barcode, it maxes out at around 1000 pixels. When printed, this is too dense (as you can see, I am trying to encode a Guid as a string) and I know that it will not scan well for recognition.

Am I correct that there are no 1d barcodes for binary data? Am I also correct that Code128 is the most efficient for storing long alphanumeric data?

Thanks!
Jim
   Report 
  11-11-2008, 10:38
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: All black barcode
Reply Quote
I wasn't able to reproduce this using our demos.  Please send a small sample project (NOT your entire application) that isolates this problem so I can try to reproduce it here.

NOTE: If you are attaching a project or file to the forums...
1.) Zip the file(s) up.
2.) Make sure it is less than 5 MB.  If it is larger, please send an email to support@leadtools.com and we'll send you FTP instructions.
3.) Remove ANY AND ALL unlock codes and LEADTOOLS DLLs.
4.) Do not click the preview button, the attachment will not show up when you post it.

If you do not wish to post your file(s) on the forum since they are publically viewable, please send an email to support@leadtools.com and make sure that you include a link to this forum post.

Greg Ross
LEADTOOLS Technical Support
   Report 
Post
LEAD Support Fo... » LEAD/Axtel Barc... » Barcode » Re: All black barcode

Powered by Community Server, by Telligent Systems