GR-PEACH barcode reader. This program uses ZBar bar code reader. ZBar is licensed under the GNU LGPL 2.1 to enable development of both open source and commercial projects.

Dependencies:   GR-PEACH_video mbed zbar_010

Fork of GR-PEACH_Camera_in by Renesas

How to use

  1. Push USER_BUTTON0, then output the result to terminal.

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.

know how

please see this page.

Committer:
RyoheiHagimoto
Date:
Tue Apr 19 02:20:12 2016 +0000
Revision:
4:acf2a0fc3f27
Parent:
0:2f1caf4ce924
Add copying.txt and license.txt

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dkato 0:2f1caf4ce924 1 /** @file bitmap.h */
dkato 0:2f1caf4ce924 2 #include "mbed.h"
dkato 0:2f1caf4ce924 3
dkato 0:2f1caf4ce924 4 /** A class to communicate a bitmap
dkato 0:2f1caf4ce924 5 *
dkato 0:2f1caf4ce924 6 */
dkato 0:2f1caf4ce924 7 class bitmap {
dkato 0:2f1caf4ce924 8 public:
dkato 0:2f1caf4ce924 9
dkato 0:2f1caf4ce924 10 /** convert RGB888 to bitmap
dkato 0:2f1caf4ce924 11 *
dkato 0:2f1caf4ce924 12 * @param file_name save file name
dkato 0:2f1caf4ce924 13 * @param buf data buffer address
dkato 0:2f1caf4ce924 14 * @param pic_width picture width
dkato 0:2f1caf4ce924 15 * @param pic_height picture height
dkato 0:2f1caf4ce924 16 * @return save data size
dkato 0:2f1caf4ce924 17 */
dkato 0:2f1caf4ce924 18 int Rgb888ToBmp(char * file_name, uint8_t * buf, unsigned long pic_width, unsigned long pic_height) {
dkato 0:2f1caf4ce924 19 unsigned long offset_size = 54;
dkato 0:2f1caf4ce924 20 unsigned long buf_stride = (((pic_width * 4u) + 31u) & ~31u);
dkato 0:2f1caf4ce924 21 unsigned long pic_size = buf_stride * pic_height;
dkato 0:2f1caf4ce924 22 unsigned long file_size = 0;
dkato 0:2f1caf4ce924 23 int save_file_size = 0;
dkato 0:2f1caf4ce924 24 int write_index = (buf_stride * pic_height) - buf_stride;
dkato 0:2f1caf4ce924 25 unsigned long cnt;
dkato 0:2f1caf4ce924 26 uint8_t wk_bitmap_buf[16];
dkato 0:2f1caf4ce924 27 FILE * fp = fopen(file_name, "w");
dkato 0:2f1caf4ce924 28
dkato 0:2f1caf4ce924 29 if (fp != NULL) {
dkato 0:2f1caf4ce924 30 file_size = pic_size + offset_size;
dkato 0:2f1caf4ce924 31
dkato 0:2f1caf4ce924 32 /* BITMAPFILEHEADER */
dkato 0:2f1caf4ce924 33 wk_bitmap_buf[0] = 'B';
dkato 0:2f1caf4ce924 34 wk_bitmap_buf[1] = 'M';
dkato 0:2f1caf4ce924 35 wk_bitmap_buf[2] = (unsigned char)(file_size >> 0); /* bfSize */
dkato 0:2f1caf4ce924 36 wk_bitmap_buf[3] = (unsigned char)(file_size >> 8); /* bfSize */
dkato 0:2f1caf4ce924 37 wk_bitmap_buf[4] = (unsigned char)(file_size >> 16); /* bfSize */
dkato 0:2f1caf4ce924 38 wk_bitmap_buf[5] = (unsigned char)(file_size >> 24); /* bfSize */
dkato 0:2f1caf4ce924 39 wk_bitmap_buf[6] = 0; /* bfReserved1 */
dkato 0:2f1caf4ce924 40 wk_bitmap_buf[7] = 0; /* bfReserved1 */
dkato 0:2f1caf4ce924 41 wk_bitmap_buf[8] = 0; /* bfReserved2 */
dkato 0:2f1caf4ce924 42 wk_bitmap_buf[9] = 0; /* bfReserved2 */
dkato 0:2f1caf4ce924 43 wk_bitmap_buf[10] = (unsigned char)(offset_size >> 0); /* bfOffBits */
dkato 0:2f1caf4ce924 44 wk_bitmap_buf[11] = (unsigned char)(offset_size >> 8); /* bfOffBits */
dkato 0:2f1caf4ce924 45 wk_bitmap_buf[12] = (unsigned char)(offset_size >> 16); /* bfOffBits */
dkato 0:2f1caf4ce924 46 wk_bitmap_buf[13] = (unsigned char)(offset_size >> 24); /* bfOffBits */
dkato 0:2f1caf4ce924 47 fwrite(wk_bitmap_buf, sizeof(char), 14, fp);
dkato 0:2f1caf4ce924 48
dkato 0:2f1caf4ce924 49 /* BITMAPINFOHEADER */
dkato 0:2f1caf4ce924 50 wk_bitmap_buf[0] = 40; /* biSize */
dkato 0:2f1caf4ce924 51 wk_bitmap_buf[1] = 0; /* biSize */
dkato 0:2f1caf4ce924 52 wk_bitmap_buf[2] = 0; /* biSize */
dkato 0:2f1caf4ce924 53 wk_bitmap_buf[3] = 0; /* biSize */
dkato 0:2f1caf4ce924 54 wk_bitmap_buf[4] = (unsigned char)(pic_width >> 0); /* biWidth */
dkato 0:2f1caf4ce924 55 wk_bitmap_buf[5] = (unsigned char)(pic_width >> 8); /* biWidth */
dkato 0:2f1caf4ce924 56 wk_bitmap_buf[6] = (unsigned char)(pic_width >> 16); /* biWidth */
dkato 0:2f1caf4ce924 57 wk_bitmap_buf[7] = (unsigned char)(pic_width >> 24); /* biWidth */
dkato 0:2f1caf4ce924 58 wk_bitmap_buf[8] = (unsigned char)(pic_height >> 0); /* biHeight */
dkato 0:2f1caf4ce924 59 wk_bitmap_buf[9] = (unsigned char)(pic_height >> 8); /* biHeight */
dkato 0:2f1caf4ce924 60 wk_bitmap_buf[10] = (unsigned char)(pic_height >> 16); /* biHeight */
dkato 0:2f1caf4ce924 61 wk_bitmap_buf[11] = (unsigned char)(pic_height >> 24); /* biHeight */
dkato 0:2f1caf4ce924 62 wk_bitmap_buf[12] = 1; /* biPlanes */
dkato 0:2f1caf4ce924 63 wk_bitmap_buf[13] = 0; /* biPlanes */
dkato 0:2f1caf4ce924 64 wk_bitmap_buf[14] = 32; /* biBitCount */
dkato 0:2f1caf4ce924 65 wk_bitmap_buf[15] = 0; /* biBitCount */
dkato 0:2f1caf4ce924 66 fwrite(wk_bitmap_buf, sizeof(char), 16, fp);
dkato 0:2f1caf4ce924 67
dkato 0:2f1caf4ce924 68 wk_bitmap_buf[0] = 0; /* biCopmression */
dkato 0:2f1caf4ce924 69 wk_bitmap_buf[1] = 0; /* biCopmression */
dkato 0:2f1caf4ce924 70 wk_bitmap_buf[2] = 0; /* biCopmression */
dkato 0:2f1caf4ce924 71 wk_bitmap_buf[3] = 0; /* biCopmression */
dkato 0:2f1caf4ce924 72 wk_bitmap_buf[4] = (unsigned char)(pic_size >> 0); /* biSizeImage */
dkato 0:2f1caf4ce924 73 wk_bitmap_buf[5] = (unsigned char)(pic_size >> 8); /* biSizeImage */
dkato 0:2f1caf4ce924 74 wk_bitmap_buf[6] = (unsigned char)(pic_size >> 16); /* biSizeImage */
dkato 0:2f1caf4ce924 75 wk_bitmap_buf[7] = (unsigned char)(pic_size >> 24); /* biSizeImage */
dkato 0:2f1caf4ce924 76 wk_bitmap_buf[8] = 0; /* biXPixPerMeter */
dkato 0:2f1caf4ce924 77 wk_bitmap_buf[9] = 0; /* biXPixPerMeter */
dkato 0:2f1caf4ce924 78 wk_bitmap_buf[10] = 0; /* biXPixPerMeter */
dkato 0:2f1caf4ce924 79 wk_bitmap_buf[11] = 0; /* biXPixPerMeter */
dkato 0:2f1caf4ce924 80 wk_bitmap_buf[12] = 0; /* biYPixPerMeter */
dkato 0:2f1caf4ce924 81 wk_bitmap_buf[13] = 0; /* biYPixPerMeter */
dkato 0:2f1caf4ce924 82 wk_bitmap_buf[14] = 0; /* biYPixPerMeter */
dkato 0:2f1caf4ce924 83 wk_bitmap_buf[15] = 0; /* biYPixPerMeter */
dkato 0:2f1caf4ce924 84 fwrite(wk_bitmap_buf, sizeof(char), 16, fp);
dkato 0:2f1caf4ce924 85
dkato 0:2f1caf4ce924 86 wk_bitmap_buf[0] = 0; /* biClrUsed */
dkato 0:2f1caf4ce924 87 wk_bitmap_buf[1] = 0; /* biClrUsed */
dkato 0:2f1caf4ce924 88 wk_bitmap_buf[2] = 0; /* biClrUsed */
dkato 0:2f1caf4ce924 89 wk_bitmap_buf[3] = 0; /* biClrUsed */
dkato 0:2f1caf4ce924 90 wk_bitmap_buf[4] = 0; /* biCirImportant */
dkato 0:2f1caf4ce924 91 wk_bitmap_buf[5] = 0; /* biCirImportant */
dkato 0:2f1caf4ce924 92 wk_bitmap_buf[6] = 0; /* biCirImportant */
dkato 0:2f1caf4ce924 93 wk_bitmap_buf[7] = 0; /* biCirImportant */
dkato 0:2f1caf4ce924 94 fwrite(wk_bitmap_buf, sizeof(char), 8, fp);
dkato 0:2f1caf4ce924 95
dkato 0:2f1caf4ce924 96 save_file_size = 54;
dkato 0:2f1caf4ce924 97 for (cnt = 0; cnt < pic_height; cnt ++) {
dkato 0:2f1caf4ce924 98 save_file_size += fwrite(&buf[write_index], sizeof(char), buf_stride, fp);
dkato 0:2f1caf4ce924 99 write_index -= buf_stride;
dkato 0:2f1caf4ce924 100 }
dkato 0:2f1caf4ce924 101 fclose(fp);
dkato 0:2f1caf4ce924 102 }
dkato 0:2f1caf4ce924 103
dkato 0:2f1caf4ce924 104 return (int)save_file_size;
dkato 0:2f1caf4ce924 105 };
dkato 0:2f1caf4ce924 106 };