将条形码转换为图像文件格式 [英] Converting barcode into image file format

查看:383
本文介绍了将条形码转换为图像文件格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在使用某些类从我的应用程序中创建条形码,它可以正常工作,
但是我将条形码转换为图像文件格式,但是这样做时条形码读取器无法读取,
但是如果我的条形码位于文本文件中,则条形码读取器可以读取相同的数据
我不知道如何解决此问题,请让我知道您的想法和一些示例代码

这是我转换条形码图像格式的代码;

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;

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);

推荐答案

您写的内容有点困惑.我认为您是在纸上打印条形码,并尝试使用条形码扫描仪读取它们.当您使用条形码字体时,它可以正常工作,但是当您通过位图呈现该字体时,它却不能.正确吗?

如果是这样,您的问题将是位图的分辨率不足.行之间的间距至关重要,因此您需要一个高清晰度的位图才能将其保存在纸上.将两者进行明显比较,您会发现有所不同.

解决此问题的方法是使用更大的位图.瞄准300 dpi,并相应地设置分辨率.
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.


不确定,但是只需检查此链接

http://www.techrepublic.com/blog/howdoi/how-do-i-generate-barcodes-using-c/173 [
Not sure, but just check this link

http://www.techrepublic.com/blog/howdoi/how-do-i-generate-barcodes-using-c/173[^]


这篇关于将条形码转换为图像文件格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆