You must draw rectangles with spaced and corresponding dimensions for the barcode symbology that you are going to use.
Here is a list of symbols:
http://en.wikipedia.org/wiki/Barcode#Linear_barcodes
If you are implementing this from scratch, I would suggest 2 out of 5 or Code 39, as they have the simplest structure.
source share