<?xml version="1.0"?>
<!--Copyright Brian Starkey 2012-->
<page title="Barcode Generator" dir="software/barcode" filename="barcode" type="windowpage" root="/xml_95">

<window title="Barcode Generator">
	<menu>		
		<menu-item name="File">
			<!--<pdf-subitem name="Get PDF"/>-->
			<home-subitem name="Home" href="{/page/@root}"/>
			<menu-subitem name="XML" href="barcode.xml"/>
		</menu-item>
		<!--include common menu items (dynamically generated)-->
		<autogen type='category' category='all'/>
	</menu>
	<substance>
	<locations name="{/page/@title}">
		<folder name="Documentation">
			<!--<leaf class="pdfleaf" name="proj.pdf" href="proj.pdf" />-->
			<!-- img="/images/pdf_icon.gif" -->
			<leaf class="sectionleaf" name="Description" href="#Description"/>
			<leaf class="sectionleaf" name="Implementation" href="#Implementation"/>
        </folder>
		<folder name="Code">
			<leaf class="zipleaf" name="barcode.zip" href="code/barcode.zip"/>
			<leaf class='codeleaf' name="makefile" href="code/makefile"/>
			<leaf class='codeleaf' name="cairo_barcode.c" href="code/cairo_barcode.c"/>
			<leaf class='imgleaf' name="charset.png" href="code/charset.png"/>
		</folder>
	</locations>
	<window-contents>
		<row>
			<image src="images/0743219551221.png">Scan Me!</image>
			<section-title name="Description"/>
			<section-content>
			This simple little utility uses the <link href="http://cairographics.org/">Cairo</link> 2D graphics library to generate 8-digit or 13-digit UPC codes.<br/>
            <raw-html>
<pre>
<b>Usage:</b> barcode [code]
code is required (8 or 13 digits)
Generates a PNG file with the filename '[code].png'
</pre>
            </raw-html>
            </section-content>
		</row>
		<row>
			<section-title name="Implementation"/>
            <image src="code/charset.png" style="width: 100px;">Character set</image>
			<section-content>
            Actually generating barcodes is pretty simple. The <link href="http://en.wikipedia.org/wiki/International_Article_Number_(EAN)">Wikipedia article</link> on EAN codes gives
            you all the information you need. All you need to do is take the input numbers and generate a binary code from them, the rest is figuring out how to display it.<br/>
            The image size is decided based on the length of the barcode number, and then the guard bands either side and in the middle drawn.
            The 'i' loops in main then go through the encoded barcode number, and decide whether to draw a vertical black line or not depending on each bit. <br/>
            Most of the complexity in my code comes from printing the numbers along the bottom of the barcode. <i>objcopy</i> is used to embed the <i>charset.png</i> image into the binary
            file, and then the functions readPNGFromStream(), streamReader() and buildCharset() create an array of cairo surfaces containing the characters. Once this is done, the approprite
            numbers are painted onto the barcode in the correct places<br/>
            Finally, the whole image is written to file.
			</section-content>
		</row>
        
        <comments/>
        
	</window-contents>
	</substance>
</window>

</page>


