Click here to Skip to main content
15,919,749 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all i am creating barcode from my application by using some class's,its working fine,
but i am converting my barcode into image file format, when i do so, its not reading by barcode reader,
but if my barcode is in text file, barcode reader is reading fine the same data
i don't know how to fix this issue,please let me know your thoughts and some sample code for it

this is my code for converting barcode image format;
C#
Color BackColor = Color.White;
            String FontName = "IDAutomationSC128M DEMO";
            string Fontaname1 = "ARIAL";
            int FontSize = 11;
            int fontSize1 = 8;
            int Height2 = 80;
            int Width2 = 175;
           string a,b,c;
           IDAutomationBarcodeObject = new clsBarCode();
            a = IDAutomationBarcodeObject.Code128(txtEnter.Text, true);
            b = "Some Sample Name";
            c = "Product Description";

            Bitmap bitmap = new Bitmap(Width2, Height2);
            Graphics graphics = Graphics.FromImage(bitmap);
            Color color = Color.Gray; ;
            Font font = new Font(FontName, FontSize);
            Font Font1 = new Font(Fontaname1, fontSize1);

            SolidBrush BrushBackColor = new SolidBrush(BackColor);
            Pen BorderPen = new Pen(color);

            Rectangle displayRectangle1 = new Rectangle(new Point(0, 0), new Size(Width2 - 1, Height2 - 2));

            graphics.FillRectangle(BrushBackColor, displayRectangle1);
            graphics.DrawString(b, Font1, Brushes.Black, 0, 0);
            graphics.DrawString(a, font, Brushes.Black, 4, 15);
            graphics.DrawString(c, Font1, Brushes.Black, 0, 63);

            pictureBox1.Image = bitmap;
            bitmap.Save("c:\\button11.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
Posted
Updated 7-Sep-11 1:34am
v3

Bit confused by your write up. I take it you are printing out barcodes on paper and attempting to read them with a barcode scanner. When you use a barcode font, it works ok, but when you render that font through a bitmap it doesn't. Is that correct?

If so, your problem will be lack of resolution of the bitmap. The spacing between lines is crucial, so you need a high definition bitmap to preserve that onto paper. Compare the two visibly and you should see a difference.

Fix for this would be to use a bigger bitmap. Aim for 300 dpi, and set the resolution accordingly.
 
Share this answer
 
Comments
sameertm 7-Sep-11 7:53am    
thanks for your reply,u got my issue, can u tell me how to make bigger bitmap by giving some example code ?
Rob Philpott 7-Sep-11 8:22am    
Simply increase the width and height, say 600 x 200 and try that. The picture box should scale fine, and depending on how you are printing use a call of SetResolution on the bitmap.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900