ZBar bar code reader . http://zbar.sourceforge.net/ ZBar is licensed under the GNU LGPL 2.1 to enable development of both open source and commercial projects.

Dependents:   GR-PEACH_Camera_in_barcode levkov_ov7670

LICENSE

The ZBar Bar Code Reader is Copyright (C) 2007-2009 Jeff Brown <spadix@users.sourceforge.net> The QR Code reader is Copyright (C) 1999-2009 Timothy B. Terriberry <tterribe@xiph.org>

You can redistribute this library and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

ISAAC is based on the public domain implementation by Robert J. Jenkins Jr., and is itself public domain.

Portions of the bit stream reader are copyright (C) The Xiph.Org Foundation 1994-2008, and are licensed under a BSD-style license.

The Reed-Solomon decoder is derived from an implementation (C) 1991-1995 Henry Minsky (hqm@ua.com, hqm@ai.mit.edu), and is licensed under the LGPL with permission.

Committer:
RyoheiHagimoto
Date:
Tue Apr 19 02:19:39 2016 +0000
Revision:
1:500d42699c34
Parent:
0:56c5742b9e2b
Add copying.txt and license.txt

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RyoheiHagimoto 0:56c5742b9e2b 1 /*------------------------------------------------------------------------
RyoheiHagimoto 0:56c5742b9e2b 2 * Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
RyoheiHagimoto 0:56c5742b9e2b 3 *
RyoheiHagimoto 0:56c5742b9e2b 4 * This file is part of the ZBar Bar Code Reader.
RyoheiHagimoto 0:56c5742b9e2b 5 *
RyoheiHagimoto 0:56c5742b9e2b 6 * The ZBar Bar Code Reader is free software; you can redistribute it
RyoheiHagimoto 0:56c5742b9e2b 7 * and/or modify it under the terms of the GNU Lesser Public License as
RyoheiHagimoto 0:56c5742b9e2b 8 * published by the Free Software Foundation; either version 2.1 of
RyoheiHagimoto 0:56c5742b9e2b 9 * the License, or (at your option) any later version.
RyoheiHagimoto 0:56c5742b9e2b 10 *
RyoheiHagimoto 0:56c5742b9e2b 11 * The ZBar Bar Code Reader is distributed in the hope that it will be
RyoheiHagimoto 0:56c5742b9e2b 12 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
RyoheiHagimoto 0:56c5742b9e2b 13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
RyoheiHagimoto 0:56c5742b9e2b 14 * GNU Lesser Public License for more details.
RyoheiHagimoto 0:56c5742b9e2b 15 *
RyoheiHagimoto 0:56c5742b9e2b 16 * You should have received a copy of the GNU Lesser Public License
RyoheiHagimoto 0:56c5742b9e2b 17 * along with the ZBar Bar Code Reader; if not, write to the Free
RyoheiHagimoto 0:56c5742b9e2b 18 * Software Foundation, Inc., 51 Franklin St, Fifth Floor,
RyoheiHagimoto 0:56c5742b9e2b 19 * Boston, MA 02110-1301 USA
RyoheiHagimoto 0:56c5742b9e2b 20 *
RyoheiHagimoto 0:56c5742b9e2b 21 * http://sourceforge.net/projects/zbar
RyoheiHagimoto 0:56c5742b9e2b 22 *------------------------------------------------------------------------*/
RyoheiHagimoto 0:56c5742b9e2b 23 #ifndef _WINDOW_H_
RyoheiHagimoto 0:56c5742b9e2b 24 #define _WINDOW_H_
RyoheiHagimoto 0:56c5742b9e2b 25
RyoheiHagimoto 0:56c5742b9e2b 26 #include <config.h>
RyoheiHagimoto 0:56c5742b9e2b 27 #ifdef HAVE_INTTYPES_H
RyoheiHagimoto 0:56c5742b9e2b 28 # include <inttypes.h>
RyoheiHagimoto 0:56c5742b9e2b 29 #endif
RyoheiHagimoto 0:56c5742b9e2b 30 #include <stdlib.h>
RyoheiHagimoto 0:56c5742b9e2b 31
RyoheiHagimoto 0:56c5742b9e2b 32 #include <zbar.h>
RyoheiHagimoto 0:56c5742b9e2b 33 #include "symbol.h"
RyoheiHagimoto 0:56c5742b9e2b 34 #include "error.h"
RyoheiHagimoto 0:56c5742b9e2b 35 #include "mutex.h"
RyoheiHagimoto 0:56c5742b9e2b 36
RyoheiHagimoto 0:56c5742b9e2b 37 typedef struct window_state_s window_state_t;
RyoheiHagimoto 0:56c5742b9e2b 38
RyoheiHagimoto 0:56c5742b9e2b 39 struct zbar_window_s {
RyoheiHagimoto 0:56c5742b9e2b 40 errinfo_t err; /* error reporting */
RyoheiHagimoto 0:56c5742b9e2b 41 zbar_image_t *image; /* last displayed image
RyoheiHagimoto 0:56c5742b9e2b 42 * NB image access must be locked!
RyoheiHagimoto 0:56c5742b9e2b 43 */
RyoheiHagimoto 0:56c5742b9e2b 44 unsigned overlay; /* user set overlay level */
RyoheiHagimoto 0:56c5742b9e2b 45
RyoheiHagimoto 0:56c5742b9e2b 46 uint32_t format; /* output format */
RyoheiHagimoto 0:56c5742b9e2b 47 unsigned width, height; /* current output size */
RyoheiHagimoto 0:56c5742b9e2b 48 unsigned max_width, max_height;
RyoheiHagimoto 0:56c5742b9e2b 49
RyoheiHagimoto 0:56c5742b9e2b 50 uint32_t src_format; /* current input format */
RyoheiHagimoto 0:56c5742b9e2b 51 unsigned src_width; /* last displayed image size */
RyoheiHagimoto 0:56c5742b9e2b 52 unsigned src_height;
RyoheiHagimoto 0:56c5742b9e2b 53
RyoheiHagimoto 0:56c5742b9e2b 54 unsigned dst_width; /* conversion target */
RyoheiHagimoto 0:56c5742b9e2b 55 unsigned dst_height;
RyoheiHagimoto 0:56c5742b9e2b 56
RyoheiHagimoto 0:56c5742b9e2b 57 unsigned scale_num; /* output scaling */
RyoheiHagimoto 0:56c5742b9e2b 58 unsigned scale_den;
RyoheiHagimoto 0:56c5742b9e2b 59
RyoheiHagimoto 0:56c5742b9e2b 60 point_t scaled_offset; /* output position and size */
RyoheiHagimoto 0:56c5742b9e2b 61 point_t scaled_size;
RyoheiHagimoto 0:56c5742b9e2b 62
RyoheiHagimoto 0:56c5742b9e2b 63 uint32_t *formats; /* supported formats (zero terminated) */
RyoheiHagimoto 0:56c5742b9e2b 64
RyoheiHagimoto 0:56c5742b9e2b 65 zbar_mutex_t imglock; /* lock displayed image */
RyoheiHagimoto 0:56c5742b9e2b 66
RyoheiHagimoto 0:56c5742b9e2b 67 void *display;
RyoheiHagimoto 0:56c5742b9e2b 68 unsigned long xwin;
RyoheiHagimoto 0:56c5742b9e2b 69 unsigned long time; /* last image display in milliseconds */
RyoheiHagimoto 0:56c5742b9e2b 70 unsigned long time_avg; /* average of inter-frame times */
RyoheiHagimoto 0:56c5742b9e2b 71
RyoheiHagimoto 0:56c5742b9e2b 72 window_state_t *state; /* platform/interface specific state */
RyoheiHagimoto 0:56c5742b9e2b 73
RyoheiHagimoto 0:56c5742b9e2b 74 /* interface dependent methods */
RyoheiHagimoto 0:56c5742b9e2b 75 int (*init)(zbar_window_t*, zbar_image_t*, int);
RyoheiHagimoto 0:56c5742b9e2b 76 int (*draw_image)(zbar_window_t*, zbar_image_t*);
RyoheiHagimoto 0:56c5742b9e2b 77 int (*cleanup)(zbar_window_t*);
RyoheiHagimoto 0:56c5742b9e2b 78 };
RyoheiHagimoto 0:56c5742b9e2b 79
RyoheiHagimoto 0:56c5742b9e2b 80 /* window.draw has to be thread safe wrt/other apis
RyoheiHagimoto 0:56c5742b9e2b 81 * FIXME should be a semaphore
RyoheiHagimoto 0:56c5742b9e2b 82 */
RyoheiHagimoto 0:56c5742b9e2b 83 static inline int window_lock (zbar_window_t *w)
RyoheiHagimoto 0:56c5742b9e2b 84 {
RyoheiHagimoto 0:56c5742b9e2b 85 int rc = 0;
RyoheiHagimoto 0:56c5742b9e2b 86 if((rc = _zbar_mutex_lock(&w->imglock))) {
RyoheiHagimoto 0:56c5742b9e2b 87 err_capture(w, SEV_FATAL, ZBAR_ERR_LOCKING, __func__,
RyoheiHagimoto 0:56c5742b9e2b 88 "unable to acquire lock");
RyoheiHagimoto 0:56c5742b9e2b 89 w->err.errnum = rc;
RyoheiHagimoto 0:56c5742b9e2b 90 return(-1);
RyoheiHagimoto 0:56c5742b9e2b 91 }
RyoheiHagimoto 0:56c5742b9e2b 92 return(0);
RyoheiHagimoto 0:56c5742b9e2b 93 }
RyoheiHagimoto 0:56c5742b9e2b 94
RyoheiHagimoto 0:56c5742b9e2b 95 static inline int window_unlock (zbar_window_t *w)
RyoheiHagimoto 0:56c5742b9e2b 96 {
RyoheiHagimoto 0:56c5742b9e2b 97 int rc = 0;
RyoheiHagimoto 0:56c5742b9e2b 98 if((rc = _zbar_mutex_unlock(&w->imglock))) {
RyoheiHagimoto 0:56c5742b9e2b 99 err_capture(w, SEV_FATAL, ZBAR_ERR_LOCKING, __func__,
RyoheiHagimoto 0:56c5742b9e2b 100 "unable to release lock");
RyoheiHagimoto 0:56c5742b9e2b 101 w->err.errnum = rc;
RyoheiHagimoto 0:56c5742b9e2b 102 return(-1);
RyoheiHagimoto 0:56c5742b9e2b 103 }
RyoheiHagimoto 0:56c5742b9e2b 104 return(0);
RyoheiHagimoto 0:56c5742b9e2b 105 }
RyoheiHagimoto 0:56c5742b9e2b 106
RyoheiHagimoto 0:56c5742b9e2b 107 static inline int _zbar_window_add_format (zbar_window_t *w,
RyoheiHagimoto 0:56c5742b9e2b 108 uint32_t fmt)
RyoheiHagimoto 0:56c5742b9e2b 109 {
RyoheiHagimoto 0:56c5742b9e2b 110 int i;
RyoheiHagimoto 0:56c5742b9e2b 111 for(i = 0; w->formats && w->formats[i]; i++)
RyoheiHagimoto 0:56c5742b9e2b 112 if(w->formats[i] == fmt)
RyoheiHagimoto 0:56c5742b9e2b 113 return(i);
RyoheiHagimoto 0:56c5742b9e2b 114
RyoheiHagimoto 0:56c5742b9e2b 115 w->formats = realloc(w->formats, (i + 2) * sizeof(uint32_t));
RyoheiHagimoto 0:56c5742b9e2b 116 w->formats[i] = fmt;
RyoheiHagimoto 0:56c5742b9e2b 117 w->formats[i + 1] = 0;
RyoheiHagimoto 0:56c5742b9e2b 118 return(i);
RyoheiHagimoto 0:56c5742b9e2b 119 }
RyoheiHagimoto 0:56c5742b9e2b 120
RyoheiHagimoto 0:56c5742b9e2b 121 static inline point_t window_scale_pt (zbar_window_t *w,
RyoheiHagimoto 0:56c5742b9e2b 122 point_t p)
RyoheiHagimoto 0:56c5742b9e2b 123 {
RyoheiHagimoto 0:56c5742b9e2b 124 p.x = ((long)p.x * w->scale_num + w->scale_den - 1) / w->scale_den;
RyoheiHagimoto 0:56c5742b9e2b 125 p.y = ((long)p.y * w->scale_num + w->scale_den - 1) / w->scale_den;
RyoheiHagimoto 0:56c5742b9e2b 126 return(p);
RyoheiHagimoto 0:56c5742b9e2b 127 }
RyoheiHagimoto 0:56c5742b9e2b 128
RyoheiHagimoto 0:56c5742b9e2b 129
RyoheiHagimoto 0:56c5742b9e2b 130 /* PAL interface */
RyoheiHagimoto 0:56c5742b9e2b 131 extern int _zbar_window_attach(zbar_window_t*, void*, unsigned long);
RyoheiHagimoto 0:56c5742b9e2b 132 extern int _zbar_window_expose(zbar_window_t*, int, int, int, int);
RyoheiHagimoto 0:56c5742b9e2b 133 extern int _zbar_window_resize(zbar_window_t*);
RyoheiHagimoto 0:56c5742b9e2b 134 extern int _zbar_window_clear(zbar_window_t*);
RyoheiHagimoto 0:56c5742b9e2b 135 extern int _zbar_window_begin(zbar_window_t*);
RyoheiHagimoto 0:56c5742b9e2b 136 extern int _zbar_window_end(zbar_window_t*);
RyoheiHagimoto 0:56c5742b9e2b 137 extern int _zbar_window_draw_marker(zbar_window_t*, uint32_t, point_t);
RyoheiHagimoto 0:56c5742b9e2b 138 extern int _zbar_window_draw_polygon(zbar_window_t*, uint32_t, const point_t*, int);
RyoheiHagimoto 0:56c5742b9e2b 139 extern int _zbar_window_draw_text(zbar_window_t*, uint32_t,
RyoheiHagimoto 0:56c5742b9e2b 140 point_t, const char*);
RyoheiHagimoto 0:56c5742b9e2b 141 extern int _zbar_window_fill_rect(zbar_window_t*, uint32_t, point_t, point_t);
RyoheiHagimoto 0:56c5742b9e2b 142 extern int _zbar_window_draw_logo(zbar_window_t*);
RyoheiHagimoto 0:56c5742b9e2b 143
RyoheiHagimoto 0:56c5742b9e2b 144 #endif
RyoheiHagimoto 0:56c5742b9e2b 145