• 大小: 62KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-12
  • 语言: C/C++
  • 标签:

资源简介

C语言生成二维码驱动,使用方法见:http://blog.csdn.net/qq_21475601/article/details/71480028

资源截图

代码片段和文件信息

/*
 * qrencode - QR Code encoder
 *
 * Binary sequence class.
 * Copyright (C) 2006-2011 Kentaro Fukuchi 
 *
 * This library is free software; you can redistribute it 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 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 St Fifth Floor Boston MA 02110-1301 USA
 */

#if HAVE_CONFIG_H
# include “config.h“
#endif
#include 
#include 
#include 

#include “bitstream.h“

BitStream *BitStream_new(void)
{
BitStream *bstream;

bstream = (BitStream *)malloc(sizeof(BitStream));
if(bstream == NULL) return NULL;

bstream->length = 0;
bstream->data = NULL;

return bstream;
}

static int BitStream_allocate(BitStream *bstream int length)
{
unsigned char *data;

if(bstream == NULL) {
return -1;
}

data = (unsigned char *)malloc(length);
if(data == NULL) {
return -1;
}

if(bstream->data) {
free(bstream->data);
}
bstream->length = length;
bstream->data = data;

return 0;
}

static BitStream *BitStream_newFromNum(int bits unsigned int num)
{
unsigned int mask;
int i;
unsigned char *p;
BitStream *bstream;

bstream = BitStream_new();
if(bstream == NULL) return NULL;

if(BitStream_allocate(bstream bits)) {
BitStream_free(bstream);
return NULL;
}

p = bstream->data;
mask = 1 << (bits - 1);
for(i=0; i if(num & mask) {
*p = 1;
} else {
*p = 0;
}
p++;
mask = mask >> 1;
}

return bstream;
}

static BitStream *BitStream_newFromBytes(int size unsigned char *data)
{
unsigned char mask;
int i j;
unsigned char *p;
BitStream *bstream;

bstream = BitStream_new();
if(bstream == NULL) return NULL;

if(BitStream_allocate(bstream size * 8)) {
BitStream_free(bstream);
return NULL;
}

p = bstream->data;
for(i=0; i mask = 0x80;
for(j=0; j<8; j++) {
if(data[i] & mask) {
*p = 1;
} else {
*p = 0;
}
p++;
mask = mask >> 1;
}
}

return bstream;
}

int BitStream_append(BitStream *bstream BitStream *arg)
{
unsigned char *data;

if(arg == NULL) {
return -1;
}
if(arg->length == 0) {
return 0;
}
if(bstream->length == 0) {
if(BitStream_allocate(bstream arg->length)) {
return -1;
}
memcpy(bstream->data arg->data arg->length);
return 0;
}

data = (unsigned char *)malloc(bstream->length + arg->length);
if(data == NULL) {
return -1;
}
memcpy(data bstream->data bstream->length);
memcpy(data + bstream->length arg->data arg->length);

f

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-12-11 18:05  QRCODE\
     文件        2445  2017-12-12 09:59  QRCODE\1.readme.txt
     文件        4310  2014-07-24 20:17  QRCODE\bitstream.c
     文件        1432  2014-07-24 20:17  QRCODE\bitstream.h
     文件         236  2017-12-11 16:28  QRCODE\data_type.h
     文件        7274  2015-08-10 13:32  QRCODE\mask.c
     文件        1560  2014-07-04 08:43  QRCODE\mask.h
     文件        4276  2015-08-10 13:32  QRCODE\mmask.c
     文件        1404  2014-07-04 08:43  QRCODE\mmask.h
     文件        7476  2015-08-20 11:46  QRCODE\mqrspec.c
     文件        4774  2014-07-04 08:43  QRCODE\mqrspec.h
     文件       21241  2015-08-22 09:54  QRCODE\qrencode.c
     文件       21602  2015-08-20 09:58  QRCODE\qrencode.h
     文件       40683  2015-08-20 11:53  QRCODE\qrinput.c
     文件        3811  2015-08-20 09:32  QRCODE\qrinput.h
     文件       16277  2015-08-21 09:46  QRCODE\qrspec.c
     文件        5832  2014-07-24 20:17  QRCODE\qrspec.h
     文件       60262  2017-12-11 16:21  QRCODE\QR_Encode.c
     文件        3783  2017-12-11 18:05  QRCODE\QR_Encode.h
     文件        9508  2015-08-11 12:18  QRCODE\rscode.c
     文件        1468  2014-07-24 20:17  QRCODE\rscode.h
     文件        8539  2015-08-20 11:08  QRCODE\split.c
     文件        1913  2014-07-24 20:17  QRCODE\split.h

评论

共有 条评论

相关资源