1 <refentry id="libglbarcode-intro" revision="07 Nov 2010">
3 <refentrytitle role="top_of_page" id="libglbarcode-intro.top_of_page">Introduction</refentrytitle>
4 <manvolnum>3</manvolnum>
6 LIBGLBARCODE-3.0 Library
11 <refname>Introduction</refname>
13 Introduction to libglbarcode library
19 <title>Overview</title>
22 Libglbarcode provides the core barcode functionality for <application>glabels</application>. It provides
23 an intermediate barcode format, a small set of built-in barcode back-ends, and a cairo renderer. While
24 libglbarcode does not currently include a large set of built-in barcode back-ends or renderers, its
25 simple architecture would easily support extending its functionality beyond the needs of
26 <application>glabels</application>.
33 <title>Basic Usage</title>
37 #include <libglbarcode/lgl-barcode-create.h>
38 #include <libglbarcode/lgl-barcode-render-to-cairo.h>
46 bc = lgl_barcode_create (LGL_BARCODE_TYPE_CODE39, TRUE, FALSE, 0, 0, data);
48 /* Render to cairo context. Assume context has appropriate scale and translation.
49 * Scale should be such that world units are points (1 point = 1/72 inch) and that
50 * positive y values go downward.
52 lgl_barcode_render_to_cairo (bc, cr);
64 <title>Writing Renderers</title>
67 The <link linkend="lglBarcode">lglBarcode</link> structure is independent of
68 barcode type, and consists of a simple list of drawing primitives.
69 A renderer simply traverses this list translating these primitives into native
70 drawing commands for its target format or device.
71 All renderers will follow this simple pattern as illustrated in the example
77 #include <libglbarcode/lgl-barcode.h>
78 #include <xxx.h>
81 lgl_barcode_render_to_xxx (const lglBarcode *bc)
85 lglBarcodeShape *shape;
86 lglBarcodeShapeLine *line;
87 lglBarcodeShapeBox *box;
88 lglBarcodeShapeChar *bchar;
89 lglBarcodeShapeString *bstring;
90 lglBarcodeShapeRing *ring;
91 lglBarcodeShapeHexagon *hexagon;
94 for (p = bc->shapes; p != NULL; p = p->next) {
96 shape = (lglBarcodeShape *)p->data;
101 case LGL_BARCODE_SHAPE_LINE:
102 line = (lglBarcodeShapeLine *) shape;
104 xxx_plot_line (line->x, line->y,
105 line->x, line->y + line->length,
109 case LGL_BARCODE_SHAPE_BOX:
110 box = (lglBarcodeShapeBox *) shape;
112 xxx_plot_rectangle (box->x, box->y,
113 box->width, box->height);
116 case LGL_BARCODE_SHAPE_CHAR:
117 bchar = (lglBarcodeShapeChar *) shape;
123 case LGL_BARCODE_SHAPE_STRING:
124 bstring = (lglBarcodeShapeString *) shape;
127 xxx_plot_string (...);
130 case LGL_BARCODE_SHAPE_RING:
131 ring = (lglBarcodeShapeRing *) shape;
134 xxx_plot_circle (...);
137 case LGL_BARCODE_SHAPE_HEXAGON:
138 hexagon = (lglBarcodeShapeHexagon *) shape;
141 xxx_plot_polygon (...);
145 g_assert_not_reached ();