C # generate a bar code Image

Source: Internet
Author: User

On the Internet, I can see that some people write code on the bar code for a long time, and some even sell it. So I checked the information and hoped to help you.

 

My implementation principle is:

In fact, Windows itself has a font used to display the bar code.

You only need to change the number to this font to a bar code.

 

In the windows Font Library, there are eight types of fonts that can be used to convert numbers into barcode:

Code39AzaleaNarrow1

Code39AzaleaNarrow2

Code39AzaleaNarrow3

Code39AzaleaRegular1

Code39AzaleaRegular2

Code39AzaleaWide1

Code39AzaleaWide2

Code39AzaleaWide3

 

Post the code for your reference:

Bitmap B = new Bitmap (200,200 );

Graphics g = Graphics. FromImage (B );

Font font = new Font ("Code39AzaleaRegular2", 32 );

G. DrawString ("123456", font, Brushes. Black, new PointF (100,100 ));

PictureBox1.BackgroundImage = B;

PictureBox1.BackgroundImageLayout = ImageLayout. Zoom;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.