Barcodegolf: Generate a number's UPC Just about every store nowadays uses Universal Product Code (UPC) barcodes to simplify the checking out process. If the name doesn't mean anything to you, you will surely recognize what they look like:



Format

The most common system is UPC-A, which uses 12 digits to represent each specific product. Each digit is encoded into a series of black and white stripes to allow machines to read the code, a length of seven bits. There are a total of 11 bits worth of patterns that indicate the beginning, middle, and end of the barcode. This comes to a total barcode length of 12 &times; 7 + 11 = 95 bits. (From now on, when binary is used to refer to the color of each bit, 0 is white and 1 is black.)

The beginning and end both have a pattern of 101. The digits are then divided into 2 groups of 6 and encoded as shown below, with a pattern 01010 between the left and right groups. This table lists the pattern for each number. Note that the pattern is different depending on if the digit is on the right or left side (This allows the barcode to be scanned upside down). However, the pattern for the right is the opposite (swap black for white and vice versa) of that of the left.



If you can't see the image above, this is each number's binary equivalent.

#   Left    Right
0   0001101 1110010
1   0011001 1100110
2   0010011 1101100
3   0111101 1000010
4   0100011 1011100
5   0110001 1001110
6   0101111 1010000
7   0111011 1000100
8   0110111 1001000
9   0001011 1110100


Example

Say you have the UPC 022000 125033. (Those aren't random numbers. Leave a comment if you figure out their significance.) You start with this boilerplate that is the same in every barcode:

101xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx01010xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx101


For the digits, you replace each one with the corresponding encoding for the side (left or right) it's on. If you're still confused, see the image below.



Here is the output in binary with | pipes separating the parts.

101|0001101|0010011|0010011|0001101|0001101|0001101|01010|1100110|1101100|1001110|1110010|1000010|1000010|101


Challenge

Write a program that outputs the UPC-A barcode for the user input. The image's dimensions should be 95 &times; 30 pixels, with each "bit" being one pixel wide and 30 pixels tall. Black stripes are in rgb(0, 0, 0) and white stripes are consistently transparent or rgb(255, 255, 255).

Notes


Take input from stdin or the command line, or write a function that takes a string or integer (note that input can have leading zeroes, and most languages remove them or convert the number to octal).
Output the image in one of the following ways:


Save it to a file with a name and format (PNG, PBM, etc.) of your choice.
Display it on the screen.
Output its file data to stdout.

You may not use libraries or builtins that generate barcodes (I'm looking at you, Mathematica), although you may use image or graphics libraries.
The last digit of a UPC is usually a check digit, but for these purposes you don't have to worry about it.


Examples

Here are some more examples to test your code with. The binary output is also given for convenience.

Input: 012345678910

Output:


10100011010011001001001101111010100011011000101010101000010001001001000111010011001101110010101


Input: 777777222222

Output:


10101110110111011011101101110110111011011101101010110110011011001101100110110011011001101100101


Scoring

This is code golf, so the shortest submission (in bytes wins). Tiebreaker goes to the earliest post.
Rev 1 BBC BASIC, 155 ascii chars, tokenised filesize 132 bytes
INPUTn$
FORi=91TO185p=i MOD2j=i MOD47IFj&lt;42j+=i DIV141*42p=(j&gt;41EORASC(MID$(&quot;XLd^bFznvh&quot;,VAL(MID$(n$,j/7+1,1))+1)))&gt;&gt;(j MOD7)AND1
IFp LINEi*2,60,i*2,0
NEXT

saved a few bytes by incorporating the offset of 43 into the i loop. In order to avoid breaking the MOD2 an additional 47 had to be added for a total of 90.
This moves the barcode further from the origin, as shown, if that is acceptable:

Rev 0 BBC BASIC, 157 ascii chars, tokenised filesize 137 bytes
INPUTn$
FORi=1TO95p=i MOD2j=(i+43)MOD47IFj&lt;42j+=i DIV51*42p=(i&gt;50EORASC(MID$(&quot;XLd^bFznvh&quot;,VAL(MID$(n$,j/7+1,1))+1)))&gt;&gt;(j MOD7)AND1
IFp LINEi*2,0,i*2,60
NEXT

Download interpreter at http://www.bbcbasic.co.uk/bbcwin/bbcwin.html
The default screen mode is black text on a white background. This differs from original BBC BASC.
Ungolfed version with test printing
Calculation of a data bar depends on IF j&lt;42 and must all be done on one line. In the ungolfed version it is done in three steps. In the golfed version the last two steps are combined into a single huge expression p=...
I had to reverse the order of the bitmaps, because I use &gt;&gt;(j MOD 7) to access the bits, which means I access the least significant bit first. Once this is done, all the left bitmaps are conveniently in the ASCII range.
  INPUTn$
  FOR i=1TO95                            :REM iterate through 95 bars
    p=i MOD2                             :REM calculate colour of format bar 1=black
    j=(i+43)MOD47                        :REM repetition is 42 data bars + 5 format bars. offset and modulo. if j&lt;42 it is a data bar and we must change p.
    
    REM if i DIV 51=1 we are in the second half, so add 42 to j. Find the bitmap for left hand value, from character j/7 of the input.
    REM i&gt;50 evaluates to false=0 true=-1. XOR this with p to invert bitmap for right hand side. Shift and AND with 1.  
    IF j&lt;42 j+=i DIV51*42:p=ASC(MID$(&quot;XLd^bFznvh&quot;,  VAL(MID$(n$,j/7+1,1))+1  )) :p=(i&gt;50EORp)&gt;&gt;(j MOD7) AND 1

    IF j MOD 7 = 0 PRINT                  :REM format test output
    PRINT ;p;                             :REM print test output
    IF p LINEi*2-2,0,i*2-2,60             :REM if p=1 plot bar. there are 2 logical units for each pixel.
  NEXT

Typical output, ungolfed version, with test output