当前位置:首页 » 操作系统 » 二维码c源码

二维码c源码

发布时间: 2022-08-10 11:14:29

1. 如何用C语言实现显示二维码

intFb_QrDisp(intiPenX,intiPenY,QRcode*pQRcode)
{
T_PixelDatasg_tOriginPixelDatas;
T_PixelDatasg_tZoomPixelDatas;
//intiZoom;
inti;

g_tOriginPixelDatas.iWidth=pQRcode->width;
g_tOriginPixelDatas.iHeight=pQRcode->width;
g_tOriginPixelDatas.iLineBytes=g_tOriginPixelDatas.iWidth;
g_tOriginPixelDatas.aucPixelDatas=pQRcode->data;
/*
if(pQRcode->version<=1)
{
iZoom=2;
}
else
{
iZoom=2;

}
g_tZoomPixelDatas.iWidth=pQRcode->width*iZoom;
g_tZoomPixelDatas.iHeight=pQRcode->width*iZoom;
g_tZoomPixelDatas.iLineBytes=g_tZoomPixelDatas.iWidth;
g_tZoomPixelDatas.aucPixelDatas=malloc(g_tZoomPixelDatas.iWidth*
g_tZoomPixelDatas.iHeight);

if(g_tZoomPixelDatas.aucPixelDatas==NULL)
{
printf("g_tZoomPixelDatas->aucPixelDatasmallocfailed ");
return-1;
}

PicZoom(&g_tOriginPixelDatas,&g_tZoomPixelDatas);
#if0
printf("g_tZoomPixelDatas.iWidth=%d,g_tZoomPixelDatas.iHeight=%d ",
g_tZoomPixelDatas.iWidth,g_tZoomPixelDatas.iHeight);


for(i=0;i<(g_tZoomPixelDatas.iWidth*g_tZoomPixelDatas.iHeight);i++)
{
printf("0x%x,",g_tZoomPixelDatas.aucPixelDatas[i]);
}
printf(" ");

#endif
*/
Disp_FixelPic(iPenX,iPenY,&g_tZoomPixelDatas);
return0;
}

需要使用Qrcode

2. 谁有C语言编写的二维码的源代码

int strcpy(char *s1,const char *s2);
开辟一个缓冲区,比如
char buff[100];//假设你的字符串不超过这么多

而你的而为数组为
char **argv;
其中argv[0] = "this is the first string";
argv[1] = "this is the seconde string";

你只须调用如下
strcpy(buff,argv[0]);
strcpy(argv[0],argv[1]);
strcpy(argv[1],buff);

一下是完整代码,并测试过
#include <stdio.h>
#include <string.h>

char argv[2][100]=;
// 存储字符串的二维数组,每个字符串最长为99个字节
char buff[100];
//缓冲区
int main()
{
printf("转换前:\n");
printf("argv[0] = %s\n",argv[0]);
printf("argv[1] = %s\n",argv[1]);

strcpy(buff,argv[0]);
strcpy(argv[0],argv[1]);
strcpy(argv[1],buff);

printf("转换后:\n");
printf("argv[0] = %s\n",argv[0]);
printf("argv[1] = %s\n",argv[1]);

return 0;
}
vae.la

3. 谁有C语言或C++编写的二维码解码软件的源程序

这个程序是运行在什么平台的?
二维码的输入来自摄像头还是来自图片?

目前来看,网上有一些开源的跨平台的开发包,需要安装相应的库才能使用。不可能像你想象的那么简单给你发个源代码你就立刻能用了。

比较实用的一个开发包是Zbar,开源不收费。亲测在Win7,WinXP环境下可以成功编译运行。
http://zbar.sourceforge.net
去这里下载他的SDK,里面有相应的例程,根据你的具体运行环境和具体的需要来修改吧。
祝你好运

4. 如何用C语言实现显示二维码

下一个easyx图形函数库吧,自动安装的,带chm函数说明。

5. 如何用C代码生成二维码

自己用C/C++生成二维码是比较复杂的。
如果实在需要,也有时间,不妨看看开源的
ZXing
里面有生成二维码的算法
其中有C/C++的移植
如果是商业需要,而又没有时间去研究,不妨采购商用的二维码生成SDK
网络一下有很多。

6. C#生成二维码(QR码)

C# 二维码的代码:

using Spire.Barcode;

using System.Drawing;

namespace CreateQRCode

{

class Program

{

static void Main(string[] args)

{

//创建BarcodeSettings对象

BarcodeSettings settings = new BarcodeSettings();

//应用Key,去logo

BarcodeSettings.ApplyKey("4KRJD-1K294-JJG9Z-SNR36-3P7IU");

settings.Type = BarCodeType.QRCode;//设置条码类型为二维码

settings.Data = "123456789";//设置二维码数据

settings.Data2D = "123456789";//设置显示文本

settings.ShowText = false;//设置二维码数据文本不显示

/*settings.ShowText = true;//显示数据文本

settings.ShowTextOnBottom = true;//数据文本显示在二维码底部*/

settings.QRCodeDataMode = QRCodeDataMode.Numeric;//设置数据类型为数字

settings.QRCodeECL = QRCodeECL.H;//设置二维码错误修正级别

settings.X = 3.0f;//设置宽度

BarCodeGenerator generator = new BarCodeGenerator(settings);//实例化BarCodeGenerator类的对象

//生成二维码图片并保存为PNG格式

Image image = generator.GenerateImage();

image.Save("QRCode.png");

}

}

}

这里的实现方法借助专门的barcode生成根据spire.barcode for .net提供的类以及方法,解析二维码可以参考如下代码:

using System;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using Spire.Barcode;

namespace ScanBarcode{
public partial class Form1 : Form {
public Form1()
{
InitializeComponent();
}

private void btnLoadImage_Click(object sender, EventArgs e)
{
//加载条形码图片
Image image = Image.FromFile("Code128.png");
pictureBox1.Image = image;
}

private void btnReadData_Click(object sender, EventArgs e)
{
Bitmap bitmap = new Bitmap(pictureBox1.Image);

//识别条形码图片中的数据(BarcodeScanner类包含多个Scan重载方法,可根据自己的需求选择相应的方法)
string[] data = BarcodeScanner.Scan(bitmap, BarCodeType.Code128);

for (int i = 0; i < data.Length; i++)
{
this.textBox1.Text += data[i].ToString();
}
}
}

}


—End—

7. 二维码生成程序C语言源代码

1、二维码有很多种标准,可以控制存储数据的信息量,也可以控制容错的数据量[使得部分污损的二维码可以被正常读龋通常的做法是调用二维码设计方提供的组件,如果是自己生成二维码,应该可以生成可以看起来很像的东西。

8. 求二维码的生成算法 C语言

二维码有很多种标准,可以控制存储数据的信息量,也可以控制容错的数据量[使得部分污损的二维码可以被正常读取]

通常的做法是调用二维码设计方提供的组件,像你这个准备自己生成二维码,应该可以生成可以看起来很像的东西。

但是估计其余的读码工具都读取不出来。

9. 求二维码生成的源代码,最好是C++的开发环境的或者有接口也行。。。急求。。谢谢

希望我的回答对你有帮助,扫一下。

10. c#实现二维码编码过程

C# 生成二维码
在C#中直接引用ThoughtWorks.QRCode.dll 类,

ThoughtWorks.QRCode.Codec.QRCodeEncoder encoder = new QRCodeEncoder();
encoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;//编码方式(注意:BYTE能支持中文,ALPHA_NUMERIC扫描出来的都是数字)
encoder.QRCodeScale = 4;//大小(值越大生成的二维码图片像素越高)
encoder.QRCodeVersion = 0;//版本(注意:设置为0主要是防止编码的字符串太长时发生错误)
encoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;//错误效验、错误更正(有4个等级)
String qrdata = "二维码信息";
System.Drawing.Bitmap bp = encoder.Encode(qrdata.ToString(), Encoding.GetEncoding("GB2312"));
Image image = bp;
pictureBox1.Image = bp;
保存二维码图片:
SaveFileDialog sf = new SaveFileDialog();
sf.Title = "选择保存文件位置";
sf.Filter = "保存图片(*.jpg) |*.jpg|所有文件(*.*) |*.*";
//设置默认文件类型显示顺序
sf.FilterIndex = 1;
//保存对话框是否记忆上次打开的目录
sf.RestoreDirectory = true;
if (sf.ShowDialog() == DialogResult.OK)
{
Image im = this.pictureBox1.Image;
//获得文件路径
string localFilePath = sf.FileName.ToString();
if (sf.FileName != "")
{
string fileNameExt = localFilePath.Substring(localFilePath.LastIndexOf("\\") + 1);//获取文件名,不带路径
// newFileName = fileNameExt+DateTime.Now.ToString("yyyyMMdd") ;//给文件名后加上时间
string FilePath = localFilePath.Substring(0, localFilePath.LastIndexOf(".")); //获取文件路径,带文件名,不带后缀
string fn = sf.FileName;
pictureBox1.Image.Save(FilePath +"-"+ DateTime.Now.ToString("yyyyMMdd") + ".jpg");

}
}
//解析二维码信息
// QRCodeDecoder decoder = new QRCodeDecoder();
// String decodedString = decoder.decode(new QRCodeBitmapImage(new Bitmap(pictureBox1.Image)));
//this.label3.Text = decodedString;

2、另一种方法,引用ZXing类库。
ZXing是一个开源Java类库用于解析多种格式的1D/2D条形码。目标是能够对QR编码、Data Matrix、UPC的1D条形码进行解码。于此同时,它同样提供 cpp,ActionScript,android,iPhone,rim,j2me,j2se,jruby,C#等方式的类库。zxing类库的作用主 要是解码,是目前开源类库中解码能力比较强的(商业的另说,不过对于动辄成千上万的类库授权费用,的确很值)。

到谷歌code下载相应的代码
1.下载zxing最新的包
到zxing的主页: http://code.google.com/p/zxing/
找到其中的CSharp文件夹,在vs中打开并编译,将obj下debug中的zxing.dll复制并粘帖到你的项目中的bin文件目录下,

右击添加项目引用。将zxing.dll引用到项目中,就可以在需要的地方使用了。
源代码中有两处UTF-8的问题,会导致中文出现乱码(编译.dll之前修改)
其一:com.google.zxing.qrcode.encoder.encoder类中的
internal const System.String DEFAULT_BYTE_MODE_ENCODING = "ISO-8859-1";
此处,将ISO-8859-1改为UTF-8
其二:com.google.zxing.qrcode.decoder.DecodedBitStreamParser类的成员
private const System.String UTF8 = "UTF8";
应将UTF8改为UTF-8

生成代码:
//引用
using com.google.zxing.qrcode;
using com.google.zxing;
using com.google.zxing.common;
using ByteMatrix = com.google.zxing.common.ByteMatrix;
using EAN13Writer = com.google.zxing.oned.EAN13Writer;
using EAN8Writer = com.google.zxing.oned.EAN8Writer;
using MultiFormatWriter = com.google.zxing.MultiFormatWriter;
方法:
string content = "二维码信息";
ByteMatrix byteMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, 300, 300);
Bitmap bitmap = toBitmap(byteMatrix);
pictureBox1.Image = bitmap;
SaveFileDialog sFD = new SaveFileDialog();
sFD.Filter = "保存图片(*.png) |*.png|所有文件(*.*) |*.*";
sFD.DefaultExt = "*.png|*.png";
sFD.AddExtension = true;
if (sFD.ShowDialog() == DialogResult.OK)
{
if (sFD.FileName != "")
{
writeToFile(byteMatrix, System.Drawing.Imaging.ImageFormat.Png, sFD.FileName);
}

}
解析:
if (this.openFileDialog1.ShowDialog() != DialogResult.OK)
{
return;
}
Image img = Image.FromFile(this.openFileDialog1.FileName);
Bitmap bmap;
try
{
bmap = new Bitmap(img);
}
catch (System.IO.IOException ioe)
{
MessageBox.Show(ioe.ToString());
return;
}
if (bmap == null)
{
MessageBox.Show("Could not decode image");
return;
}
LuminanceSource source = new RGBLuminanceSource(bmap, bmap.Width, bmap.Height);
com.google.zxing.BinaryBitmap bitmap1 = new com.google.zxing.BinaryBitmap(new HybridBinarizer(source));
Result result;
try
{
result = new MultiFormatReader().decode(bitmap1);
}
catch (ReaderException re)
{
MessageBox.Show(re.ToString());
return;
}

MessageBox.Show(result.Text);

public static void writeToFile(ByteMatrix matrix, System.Drawing.Imaging.ImageFormat format, string file)
{
Bitmap bmap = toBitmap(matrix);
bmap.Save(file, format);
}

public static Bitmap toBitmap(ByteMatrix matrix)
{
int width = matrix.Width;
int height = matrix.Height;
Bitmap bmap = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
bmap.SetPixel(x, y, matrix.get_Renamed(x, y) != -1 ? ColorTranslator.FromHtml("0xFF000000") : ColorTranslator.FromHtml("0xFFFFFFFF"));
}
}
return bmap;
}

热点内容
ipad文件加密 发布:2024-05-02 08:20:30 浏览:442
粉土压缩模量 发布:2024-05-02 07:53:59 浏览:805
国都证券初始密码是多少 发布:2024-05-02 07:46:39 浏览:109
shell脚本和linux命令行 发布:2024-05-02 07:37:54 浏览:968
自己的服务器搭建微信小程序商城 发布:2024-05-02 07:36:26 浏览:426
php单行注释 发布:2024-05-02 07:36:22 浏览:958
买车哪些配置必备 发布:2024-05-02 07:30:20 浏览:52
华为手机的自带铃声文件夹 发布:2024-05-02 07:20:14 浏览:501
xp系统开机密码怎么设置 发布:2024-05-02 06:49:48 浏览:759
柱加密区公式 发布:2024-05-02 06:40:19 浏览:4