]> git.sur5r.net Git - glabels/blob - docs/libglbarcode/html/libglbarcode-intro.html
Imported Upstream version 3.0.0
[glabels] / docs / libglbarcode / html / libglbarcode-intro.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>Introduction</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7 <link rel="home" href="index.html" title="LibGlbarcode 3.0 Reference Manual">
8 <link rel="up" href="overview.html" title="LibGlbarcode Overview">
9 <link rel="prev" href="overview.html" title="LibGlbarcode Overview">
10 <link rel="next" href="api.html" title="API Reference">
11 <meta name="generator" content="GTK-Doc V1.17 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
13 </head>
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
16 <td><a accesskey="p" href="overview.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
17 <td><a accesskey="u" href="overview.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
18 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
19 <th width="100%" align="center">LibGlbarcode 3.0 Reference Manual</th>
20 <td><a accesskey="n" href="api.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
21 </tr></table>
22 <div class="refentry">
23 <a name="libglbarcode-intro"></a><div class="titlepage"></div>
24 <div class="refnamediv"><table width="100%"><tr>
25 <td valign="top">
26 <h2><span class="refentrytitle"><a name="libglbarcode-intro.top_of_page"></a>Introduction</span></h2>
27 <p>Introduction — 
28 Introduction to libglbarcode library
29 </p>
30 </td>
31 <td valign="top" align="right"></td>
32 </tr></table></div>
33 <div class="refsect1">
34 <a name="id2963460"></a><h2>Overview</h2>
35 <p>
36 Libglbarcode provides the core barcode functionality for <span class="application">glabels</span>.  It provides
37 an intermediate barcode format, a small set of built-in barcode back-ends, and a cairo renderer.  While
38 libglbarcode does not currently include a large set of built-in barcode back-ends or renderers, its
39 simple architecture would easily support extending its functionality beyond the needs of
40 <span class="application">glabels</span>.
41 </p>
42 </div>
43 <div class="refsect1">
44 <a name="id2963536"></a><h2>Basic Usage</h2>
45 <pre class="programlisting">
46
47 #include &lt;libglbarcode/lgl-barcode-create.h&gt;
48 #include &lt;libglbarcode/lgl-barcode-render-to-cairo.h&gt;
49
50 void
51 example (gchar   *data,
52          cairo_t *cr)
53 {
54         glBarcode *bc;
55
56         bc = lgl_barcode_create (LGL_BARCODE_TYPE_CODE39, TRUE, FALSE, 0, 0, data);
57
58         /* Render to cairo context.  Assume context has appropriate scale and translation.
59          * Scale should be such that world units are points (1 point = 1/72 inch) and that
60          * positive y values go downward.
61          */
62         lgl_barcode_render_to_cairo (bc, cr);
63
64         lgl_free (bc);
65 }
66
67 </pre>
68 </div>
69 <div class="refsect1">
70 <a name="id2963569"></a><h2>Writing Renderers</h2>
71 <p>
72 The <a class="link" href="libglbarcode-3.0-lgl-barcode.html#lglBarcode" title="lglBarcode">lglBarcode</a> structure is independent of
73 barcode type, and consists of a simple list of drawing primitives.
74 A renderer simply traverses this list translating these primitives into native
75 drawing commands for its target format or device.
76 All renderers will follow this simple pattern as illustrated in the example
77 below.
78 </p>
79 <pre class="programlisting">
80
81 #include &lt;libglbarcode/lgl-barcode.h&gt;
82 #include &lt;xxx.h&gt;
83
84 void
85 lgl_barcode_render_to_xxx (const lglBarcode  *bc)
86 {
87         GList                  *p;
88
89         lglBarcodeShape        *shape;
90         lglBarcodeShapeLine    *line;
91         lglBarcodeShapeBox     *box;
92         lglBarcodeShapeChar    *bchar;
93         lglBarcodeShapeString  *bstring;
94         lglBarcodeShapeRing    *ring;
95         lglBarcodeShapeHexagon *hexagon;
96
97
98         for (p = bc-&gt;shapes; p != NULL; p = p-&gt;next) {
99
100                 shape = (lglBarcodeShape *)p-&gt;data;
101
102                 switch (shape-&gt;type)
103                 {
104
105                 case LGL_BARCODE_SHAPE_LINE:
106                         line = (lglBarcodeShapeLine *) shape;
107
108                         xxx_plot_line (line-&gt;x, line-&gt;y,
109                                        line-&gt;x, line-&gt;y + line-&gt;length,
110                                        line-&gt;width );
111                         break;
112
113                 case LGL_BARCODE_SHAPE_BOX:
114                         box = (lglBarcodeShapeBox *) shape;
115
116                         xxx_plot_rectangle (box-&gt;x, box-&gt;y,
117                                             box-&gt;width, box-&gt;height);
118                         break;
119
120                 case LGL_BARCODE_SHAPE_CHAR:
121                         bchar = (lglBarcodeShapeChar *) shape;
122
123                         ...
124                         xxx_plot_char (...);
125                         break;
126
127                 case LGL_BARCODE_SHAPE_STRING:
128                         bstring = (lglBarcodeShapeString *) shape;
129
130                         ...
131                         xxx_plot_string (...);
132                         break;
133
134                 case LGL_BARCODE_SHAPE_RING:
135                         ring = (lglBarcodeShapeRing *) shape;
136
137                         ...
138                         xxx_plot_circle (...);
139                         break;
140
141                 case LGL_BARCODE_SHAPE_HEXAGON:
142                         hexagon = (lglBarcodeShapeHexagon *) shape;
143
144                         ...
145                         xxx_plot_polygon (...);
146                         break;
147
148                 default:
149                         g_assert_not_reached ();
150                         break;
151
152                 }
153
154         }
155
156 }
157
158
159 </pre>
160 </div>
161 </div>
162 <div class="footer">
163 <hr>
164           Generated by GTK-Doc V1.17</div>
165 </body>
166 </html>