Overview
Creation of bitmaps containing barcodes according to EAN standard.
Description
The file 'barcode.c' (written in C under LabWindows cvi) enables the generation of barcodes according to EAN convention as described at http://en.wikipedia.org/wiki/International_Article_Number_%28EAN%29 (English) or, better, at http://fr.wikipedia.org/wiki/Code-barres_EAN (in French). Codes can be either in 8-digit convention or in 13-digit one. In the first case it must be coded as an unsigned integer (unsigned int), in the second case, as a 64-bit unsigned (unsigned long long unsigned). The resulting barcodes are generated as bitmaps. They have to be released after use by calling the function DiscardBitmap().
The generated barcodes have been checked on some on-line generator (for instance http://barcode-coder.com/fr/generateur-de-code-barres-en-ligne-2.html).
Steps to Implement or Execute Code
4 functions are provided in the source file 'barcode.c' acting as a 'library' (see their prototypes below):
The functions include two parameters:
The variants '...WithKey...' generate themselves the control key normally required by the standard. When using these variants the argument given to the function must include one digit less (7 against 8 and 12 against 13 respectively) than usually so that (a) the given code is shifted on the left (x10) and (b) the least significant digit (rank zero or rightmost) is replaced by the control key.
The code ean8.c gives a simple example of application.
Requirements
Software
LabWindows CVI supporting long long int (__int64).
Hardware
None
Additional Images or Video

Typical EAN13 and EAN8 codebars generated by the code.
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
1° NOTE : the source "g_barcode.c" has been updated for correcting a mismatched value in the codea table (digit 7).
2° For adding an additionnal two-digit value to generate a EAN13+2 code, the code is added on the right side of the barcode according to the following schema :
<4-segment delimiter = 1011><MSB digit><2-segment delimiter = 01><LSB digit> (where add_value=10 x MSB + LSB)
The digits must be encoded with either tablea or tableb according to the rest of the additional value in the division by 4 :
add_value MOD 4 =0, MSB tablea, LSB tablea
add_value MOD 4 =1, MSB tablea, LSB tableb
add_value MOD 4 =2, MSB tableb, LSB tablea
add_value MOD 4 =3, MSB tableb, LSB tableb
(see the GS1 document http://www.gs1.org/docs/gsmp/barcodes/GS1_General_Specifications.pdf), section 5 "data carriers" starting page 221.
Thanks for your sharing of this EAN8/13 barcode generator.I am doing my work with barcode generation,i am just looking for this one.
Thanks, I love this sharing.I need to print bar code label with EAN 13, I don't know wether this one can creat EAN 13 in excel?
Hi micagordon,
I suggest :