X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=docs%2Flibglbarcode%2Fhtml%2Flibglbarcode-intro.html;fp=docs%2Flibglbarcode%2Fhtml%2Flibglbarcode-intro.html;h=8261dfc088d4a22f733be2e8034e256b62690c78;hb=cbc5b369069a355c3fa9715c059271d45dbb33e0;hp=0000000000000000000000000000000000000000;hpb=b13649a65b7dfa46ba1ed7fe9e8afa4aaef70f79;p=glabels diff --git a/docs/libglbarcode/html/libglbarcode-intro.html b/docs/libglbarcode/html/libglbarcode-intro.html new file mode 100644 index 00000000..8261dfc0 --- /dev/null +++ b/docs/libglbarcode/html/libglbarcode-intro.html @@ -0,0 +1,166 @@ + + + + +Introduction + + + + + + + + + + + + + + + + +
+
+
+ + +
+

Introduction

+

Introduction — +Introduction to libglbarcode library +

+
+
+

Overview

+

+Libglbarcode provides the core barcode functionality for glabels. It provides +an intermediate barcode format, a small set of built-in barcode back-ends, and a cairo renderer. While +libglbarcode does not currently include a large set of built-in barcode back-ends or renderers, its +simple architecture would easily support extending its functionality beyond the needs of +glabels. +

+
+
+

Basic Usage

+
+
+#include <libglbarcode/lgl-barcode-create.h>
+#include <libglbarcode/lgl-barcode-render-to-cairo.h>
+
+void
+example (gchar   *data,
+         cairo_t *cr)
+{
+        glBarcode *bc;
+
+        bc = lgl_barcode_create (LGL_BARCODE_TYPE_CODE39, TRUE, FALSE, 0, 0, data);
+
+        /* Render to cairo context.  Assume context has appropriate scale and translation.
+         * Scale should be such that world units are points (1 point = 1/72 inch) and that
+         * positive y values go downward.
+         */
+        lgl_barcode_render_to_cairo (bc, cr);
+
+        lgl_free (bc);
+}
+
+
+
+
+

Writing Renderers

+

+The lglBarcode structure is independent of +barcode type, and consists of a simple list of drawing primitives. +A renderer simply traverses this list translating these primitives into native +drawing commands for its target format or device. +All renderers will follow this simple pattern as illustrated in the example +below. +

+
+
+#include <libglbarcode/lgl-barcode.h>
+#include <xxx.h>
+
+void
+lgl_barcode_render_to_xxx (const lglBarcode  *bc)
+{
+        GList                  *p;
+
+        lglBarcodeShape        *shape;
+        lglBarcodeShapeLine    *line;
+        lglBarcodeShapeBox     *box;
+        lglBarcodeShapeChar    *bchar;
+        lglBarcodeShapeString  *bstring;
+        lglBarcodeShapeRing    *ring;
+        lglBarcodeShapeHexagon *hexagon;
+
+
+        for (p = bc->shapes; p != NULL; p = p->next) {
+
+                shape = (lglBarcodeShape *)p->data;
+
+                switch (shape->type)
+                {
+
+                case LGL_BARCODE_SHAPE_LINE:
+                        line = (lglBarcodeShapeLine *) shape;
+
+                        xxx_plot_line (line->x, line->y,
+                                       line->x, line->y + line->length,
+                                       line->width );
+                        break;
+
+                case LGL_BARCODE_SHAPE_BOX:
+                        box = (lglBarcodeShapeBox *) shape;
+
+                        xxx_plot_rectangle (box->x, box->y,
+                                            box->width, box->height);
+                        break;
+
+                case LGL_BARCODE_SHAPE_CHAR:
+                        bchar = (lglBarcodeShapeChar *) shape;
+
+                        ...
+                        xxx_plot_char (...);
+                        break;
+
+                case LGL_BARCODE_SHAPE_STRING:
+                        bstring = (lglBarcodeShapeString *) shape;
+
+                        ...
+                        xxx_plot_string (...);
+                        break;
+
+                case LGL_BARCODE_SHAPE_RING:
+                        ring = (lglBarcodeShapeRing *) shape;
+
+                        ...
+                        xxx_plot_circle (...);
+                        break;
+
+                case LGL_BARCODE_SHAPE_HEXAGON:
+                        hexagon = (lglBarcodeShapeHexagon *) shape;
+
+                        ...
+                        xxx_plot_polygon (...);
+                        break;
+
+                default:
+                        g_assert_not_reached ();
+                        break;
+
+                }
+
+        }
+
+}
+
+
+
+
+
+ + + \ No newline at end of file