views:

222

answers:

4

Hi everbody,

I am writing a barcode generator in C# I can generate barcodes as bitmaps and can show them in a Picturebox(WindowsForms). On the other hand I could not save my barcode as a gif or jpeg file. My barcode is a bitmap file and here is my code

        Bitmap barCode = CreateBarCode("*"+txtBarCodeStr.Text+"*");
        barCode.Save(@"C:\barcode.gif", ImageFormat.gif);
        picBox.Image = barCode;            
        MessageBox.Show("Created");

I get the following exception; A generic error occurred in GDI+.

A: 

Gif is an indexed pallete format.

Save it in a compatible format what was used to create the Bitmap instance.

leppie
+1  A: 

Another approach that you could take is to use a barcode Font. There are many out there, some better than others. A search with your favourite search engine will help you find the right one.

Daniel Dyson
A: 

your problem is permissions. allow network service full access to the path you are saving the file and see if that helps

good luck!

Ugene
+1  A: 

you can try the another approach which is available on the below link: Generate Bar Code

Vijjendra