Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Greetings,

I'm creating a barcode application and when I google to know about barcode I found something that I did not understand and it is the odd left, even left and right digits for example the EAN-13 barcode includes the following



C#
OddLeft = new String[] { "0001101", "0011001", "0010011",    "0111101", "0100011", "0110001", "0101111", "0111011", "0110111", "0001011" };


C#
EvenLeft = new String[] { "0100111", "0110011", "0011011", "0100001", "0011101", "0111001", "0000101", "0010001", "0001001", "0010111" };


C#
Right = new String[] { "1110010", "1100110", "1101100", "1000010",
                                           "1011100", "1001110", "1010000","1000100",
                                           "1001000", "1110100" };


Where every string within the string array represents a number from 0 to 9.
How can decimal 0 equals "0001101" in odd left or "0100111" in even left or "1110010" in right. How did they calculate it?
I know the binary representation of decimal 0 and none of the 3 representations above represents a binary represetation of decimal 0.
I read about parity bits too and I found the none of the 3 representations above represents odd or even parity bits of decimal 0.

Is those representations above are standard fixed representation? or there is a way or a calcuation performed to obtain such representation?
Posted
Comments
[no name] 8-Feb-15 10:39am    
Amr Mohammad 8-Feb-15 11:48am    
I read the article before and I read it again because I might be did not understand or forgot something but the article talking about the EAN and its components and how is the EAN-13 barcode is calculated. My question was not about how the EAN-13 barcode is generated, but my question is about how decimal 0 = 0001101 in left odd parity! how did they got it? I know that decimal 0 = 00000000 in binary representation and when I read about parity bit I understood how numbers are represented too and none of them binary or parity bit of decimal 0 equals 0001101, 0100111, or 1110010 I hope that my question is clearly understood :).
[no name] 8-Feb-15 12:16pm    
ok give me some time, it seems I have to read all about this also more carefully ;)

These codes are not the binary representation of their respective numeric values, but the layout of the vertical bar representing the number.
You have to print in white the pixels=0 and mark dark the pixels=1. This way you'll get the correct space-light image for the symbol you want printout.
The barcode is composed by odd encoded, even encoded or single set. The sequence is well described in the link that Bruno gave you. Read it carefully and you'll get all you need to go on.
If your trouble is how to link the digit from readable string to graph encoded representation simply use the binary value of the digit as index in the arrays of encoded graph layout (that you have coded), than use them to print the lines.
On the reverse get the raw data read from scanner, make a search in that array and the index of corresponding mask of light/dark is your binary number.
Be carefull about odd/even/single layout for the code.
Good luck.
 
Share this answer
 
v2
Comments
Amr Mohammad 8-Feb-15 13:43pm    
Thanks in the first place. My question again is how 0 is equal to 0001101 in the OddLeft array. In other words, for example, lets take the first array the OddLeft array 0 represents 0001101, 1 represents 0011001, 2 represents 0010011, 3 represents 0111101, 4 represents 0100011, 5 represents 0110001, 6 represents 0101111, 7 represents 0111011, 8 represents 0110111, and 9 represents 0001011. I understand that and I also understand if I have a number such as 01234 and I want to generate its barcode then the 0 will be lets say 0001101 and 1 will be lets say 0110011 from the values in the above arrays. My question is why 0 have such representation 0001101, 0100111, and 1110010 respectively on the OddLeft, EvenLeft, and Right arrays respectively why 0, for example, not represented as 10011101100 in the OddLeft array? I hope you understand my question
Frankie-C 8-Feb-15 14:37pm    
Ok, I'll try to be more clear:
Get a piece of paper with squares, count 7 of them horizontally, now get the the representation for 0=0001101, from left to right make blak (fill the squares) corresponding to 1's in the mask 0001101, leave white the places corresponding to bits=0.
Now repeat the pattern for say 10 lines vertically. You'll get something like:
| xx x|
| xx x|
| xx x|
| xx x|
| xx x|
| xx x|
Look at it, now can you see the verical bars for the zero symbol?
This is what you get printed vertical bars spaced that define the symbol. It is rappresentation of the graphic not of a cipher.
This type of rappresentation has been choosed because of some geometric properties of the bar layout that allows in a simple way, with high efficency, to identify a bar code start and end even for reverse of displaced scanning of images.
Is it more clear now?
The basic rule is that there is a certain pattern of 1s and 0s for each digit, which is not a binary value. And that pattern varies according to the position of the digit in the final barcode. This is to help in scanning from both directions, as the scanner can tell whether a digit is valid from its position. There are many papers on the subject including http://en.wikipedia.org/wiki/European_Article_Number[^] (not a beginner article), and http://www.computalabel.com/aboutean.htm[^].
 
Share this answer
 
Comments
Amr Mohammad 8-Feb-15 14:04pm    
Thanks in the first place. My question again is how 0 is equal to 0001101 in the OddLeft array. In other words, for example, lets take the first array the OddLeft array 0 represents 0001101, 1 represents 0011001, 2 represents 0010011, 3 represents 0111101, 4 represents 0100011, 5 represents 0110001, 6 represents 0101111, 7 represents 0111011, 8 represents 0110111, and 9 represents 0001011. I understand that and I also understand if I have a number such as 01234 and I want to generate its barcode then the 0 will be lets say 0001101 and 1 will be lets say 0110011 from the values in the above arrays. My question is why 0 have such representation 0001101, 0100111, and 1110010 respectively on the OddLeft, EvenLeft, and Right arrays respectively why 0, for example, not represented as 10011101100 in the OddLeft array? I hope you understand my question
Richard MacCutchan 8-Feb-15 14:15pm    
The values are not 'equal' to the numbers they represent. They are just patterns which will represent those numbers, also depending on their postion in the barcode. Barcodes are not simple one to one correspondences with numbers, as that would be far too prone to errors. It is only because of the mix of patterns and positioning that they work as well as they do. For example a zero may be represented by either 0001101, 0100111 or 1110010, depending on its position in the number, and the value of the first digit.

Assuming you are working on an application to print barcodes you really need to study those papers in detail to understand how each character is created.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900