How to create Linear and Data Matrix barcodes in C# and how can i decode a linear ,Data matrix from image?

For writing 1D barcodes without any special encoding, such as 3 of 9[1], you can download the appropriate font from somewhere and then simply draw the barcode on an image:

Bitmap DrawText(string value, string fontName, float size) {
    using (var font = new Font(fontName, size, FontStyle.Regular, GraphicsUnit.Point)) {
        var image = new Bitmap(1, 1);

        using (var g = Graphics.FromImage(image))
            image = new Bitmap(image, g.MeasureString(value, font).ToSize());

        using (var g = Graphics.FromImage(image)) {
            g.DrawString(value, font, new SolidBrush(Color.Black), 0, 0);

        return image;
pictureBox1.Image = DrawText("*" + value + "*", "3 of 9 Font", size);

Unfortunately, you can't do that for 2D barcodes because there's a significant amount of work in encoding the data. Now, you could become an expert on barcode formats and image processing, then write your own code for doing this stuff manually, but that's kind of silly. A much better option is to use an existing library for reading and writing barcodes.

I'm not terribly familiar with the freely available libraries, but google will help you with that. However, if you don't mind a commercial library, I'd recommend both Atalasoft and Vintasoft.

[1] Yes, 3 of 9 uses asterisks as the start and stop character, but that's hardly what I'd call "special" encoding. What I mean by special encoding is the complex algorithms involved in a format such as PDF417.

For what its worth I use Atalasoft's barcode package and it has been OK. If you move forward their solution let me know and I may be able to provide some code. I wrote a scan-station application using TWAIN to scan in piles of paper separated by pages with a barcode that told the application a new scan job was beginning. It read the files in as high-resolution TIF images, digested the barcodes finally spitting out a set of PDFs.

I ran in to problems with phantom TIF pages, phantom barcode signatures and a few other oddities. I'm sure every imaging vendor has their quirks.

Good luck -- imaging is a lot of work :)