1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
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.18 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
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>
22 <div class="refentry">
23 <a name="libglbarcode-intro"></a><div class="titlepage"></div>
24 <div class="refnamediv"><table width="100%"><tr>
26 <h2><span class="refentrytitle"><a name="libglbarcode-intro.top_of_page"></a>Introduction</span></h2>
28 Introduction to libglbarcode library
31 <td valign="top" align="right"></td>
33 <div class="refsect1">
34 <a name="idp3821008"></a><h2>Overview</h2>
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>.
43 <div class="refsect1">
44 <a name="idp1632160"></a><h2>Basic Usage</h2>
45 <pre class="programlisting">
47 #include <libglbarcode/lgl-barcode-create.h>
48 #include <libglbarcode/lgl-barcode-render-to-cairo.h>
56 bc = lgl_barcode_create (LGL_BARCODE_TYPE_CODE39, TRUE, FALSE, 0, 0, data);
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.
62 lgl_barcode_render_to_cairo (bc, cr);
69 <div class="refsect1">
70 <a name="idp4202448"></a><h2>Writing Renderers</h2>
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
79 <pre class="programlisting">
81 #include <libglbarcode/lgl-barcode.h>
82 #include <xxx.h>
85 lgl_barcode_render_to_xxx (const lglBarcode *bc)
89 lglBarcodeShape *shape;
90 lglBarcodeShapeLine *line;
91 lglBarcodeShapeBox *box;
92 lglBarcodeShapeChar *bchar;
93 lglBarcodeShapeString *bstring;
94 lglBarcodeShapeRing *ring;
95 lglBarcodeShapeHexagon *hexagon;
98 for (p = bc->shapes; p != NULL; p = p->next) {
100 shape = (lglBarcodeShape *)p->data;
102 switch (shape->type)
105 case LGL_BARCODE_SHAPE_LINE:
106 line = (lglBarcodeShapeLine *) shape;
108 xxx_plot_line (line->x, line->y,
109 line->x, line->y + line->length,
113 case LGL_BARCODE_SHAPE_BOX:
114 box = (lglBarcodeShapeBox *) shape;
116 xxx_plot_rectangle (box->x, box->y,
117 box->width, box->height);
120 case LGL_BARCODE_SHAPE_CHAR:
121 bchar = (lglBarcodeShapeChar *) shape;
127 case LGL_BARCODE_SHAPE_STRING:
128 bstring = (lglBarcodeShapeString *) shape;
131 xxx_plot_string (...);
134 case LGL_BARCODE_SHAPE_RING:
135 ring = (lglBarcodeShapeRing *) shape;
138 xxx_plot_circle (...);
141 case LGL_BARCODE_SHAPE_HEXAGON:
142 hexagon = (lglBarcodeShapeHexagon *) shape;
145 xxx_plot_polygon (...);
149 g_assert_not_reached ();
164 Generated by GTK-Doc V1.18</div>