3 * Copyright (C) 2010 Jim Evins <evins@snaught.com>.
5 * This file is part of libglbarcode.
7 * libglbarcode is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * libglbarcode is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with libglbarcode. If not, see <http://www.gnu.org/licenses/>.
23 #include "lgl-barcode-create.h"
25 #include "lgl-barcode-postnet.h"
26 #include "lgl-barcode-onecode.h"
27 #include "lgl-barcode-code39.h"
30 /*===========================================*/
31 /* Private macros and constants. */
32 /*===========================================*/
35 /*===========================================*/
37 /*===========================================*/
39 typedef lglBarcode *(*BarcodeNewFunc) (lglBarcodeType type,
41 gboolean checksum_flag,
47 /*===========================================*/
49 /*===========================================*/
51 BarcodeNewFunc create_func[LGL_BARCODE_N_TYPES] = {
53 /* LGL_BARCODE_TYPE_POSTNET */ lgl_barcode_postnet_new,
54 /* LGL_BARCODE_TYPE_POSTNET_5 */ lgl_barcode_postnet_new,
55 /* LGL_BARCODE_TYPE_POSTNET_9 */ lgl_barcode_postnet_new,
56 /* LGL_BARCODE_TYPE_POSTNET_11 */ lgl_barcode_postnet_new,
57 /* LGL_BARCODE_TYPE_CEPNET */ lgl_barcode_postnet_new,
59 /* LGL_BARCODE_TYPE_ONECODE */ lgl_barcode_onecode_new,
61 /* LGL_BARCODE_TYPE_CODE39 */ lgl_barcode_code39_new,
62 /* LGL_BARCODE_TYPE_CODE39_EXT */ lgl_barcode_code39_new,
65 /*===========================================*/
66 /* Local function prototypes */
67 /*===========================================*/
70 /****************************************************************************/
73 * @type: Barcode type selection (#lglBarcodeType)
74 * @text_flag: %TRUE to show text, if supported by barcode type
75 * @checksum_flag: %TRUE to include checksum, if supported or optional for barcode type
76 * @w: Suggested width of barcode
77 * @h: Suggested height of barcode
78 * @data: Data to encode into barcode
80 * Create a new barcode structure, encoding @data with selected barcode type and
83 * Barcode dimensions (@w and @h) are in points ( 1 point = 1/72 inch ).
84 * If either @w or @h are zero, the barcode will be rendered in a nominal size
85 * appropriate for the barcode type and data. The actual size of the resulting
86 * barcode may also be limited by required tolerances of line sizes and spacing
87 * for the given barcode type.
90 * Returns: A newly allocated #lglBarcode structure. Use lgl_barcode_free() to
94 lgl_barcode_create (lglBarcodeType type,
96 gboolean checksum_flag,
101 if ( (type < 0) || (type >= LGL_BARCODE_N_TYPES) )
103 g_message ("Invalid barcode type.");
107 return create_func[type] (type, text_flag, checksum_flag, w, h, data);
113 * Local Variables: -- emacs
115 * c-basic-offset: 8 -- emacs
116 * tab-width: 8 -- emacs
117 * indent-tabs-mode: nil -- emacs