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;