C# .Net 使用zxing.dll生成二维码,条形码
{
BarcodeWriter writer = null;
Bitmap bitmap = null;
string strbase64 = string.Empty;
writer = new BarcodeWriter();
if (format == "QR_CODE")
{
EncodingOptions options = new QrCodeEncodingOptions
{
DisableECI = true,
CharacterSet = "UTF-8",
Width = width == null ? 500 : Convert.ToInt32(width),
Height = height == null ? 500 : Convert.ToInt32(height)
};
writer.Options = options;
writer.Format = BarcodeFormat.QR_CODE;
bitmap = writer.Write(value);
}
else if (format == "CODE_39")
{
/*
* 1.支持数字,字母,-,$,空格
* 2.产生的条码大
* 3.常用于许多用途
*/
writer.Format = BarcodeFormat.CODE_39;
MultiFormatWriter mutiWriter = new MultiFormatWriter();
BitMatrix bm = mutiWriter.encode(value, BarcodeFormat.CODE_39, (width == null ? 500 : Convert.ToInt32(width)), (height == null ? 150 : Convert.ToInt32(height)), null);
bitmap = new BarcodeWriter().Write(bm);
}
else if (format == "CODE_128")
{
/*
* 1.支持字母或者数字所有字符
* 2.包含3个表格更好的数据进行编码
*/
writer.Format = BarcodeFormat.CODE_128;
MultiFormatWriter mutiWriter = new MultiFormatWriter();
BitMatrix bm = mutiWriter.encode(value, BarcodeFormat.CODE_128, (width == null ? 500 : Convert.ToInt32(width)), (height == null ? 150 : Convert.ToInt32(height)), null);
bitmap = new BarcodeWriter().Write(bm);
}
else if (format == "ITF")
{
EncodingOptions options = new QrCodeEncodingOptions
{
DisableECI = true,
CharacterSet = "UTF-8",
Width = width == null ? 500 : Convert.ToInt32(width),
Height = height == null ? 150 : Convert.ToInt32(height)
};
writer.Options = options;
writer.Format = BarcodeFormat.ITF;
bitmap = writer.Write(value);
}
using (MemoryStream ms = new MemoryStream())
{
bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] arr = new byte[ms.Length];
ms.Position = 0;
ms.Read(arr, 0, (int)ms.Length);
strbase64 = Convert.ToBase64String(arr);
}
return strbase64;
}
C# .Net 使用zxing.dll生成二维码,条形码的更多相关文章
- ZXing.dll 生成二维码 C# winform net4.5
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- C#MVC用ZXing.Net生成二维码/条形码
开篇:zxing.net是.net平台下编解条形码和二维码的工具. 首先创建新项目 选择MVC模板 添加一个控制器 在项目引用中的引用ZXing 进行联网下载 控制器需要引用 后台控制器 pu ...
- C# ZXing.Net生成二维码、识别二维码、生成带Logo的二维码(二)
1.使用ZXint.Net生成带logo的二维码 /// <summary> /// 生成带Logo的二维码 /// </summary> /// <param name ...
- 基于Asp.Net Core,利用ZXing来生成二维码的一般流程
本文主要介绍如何在.net环境下,基于Asp.Net Core,利用ZXing来生成二维码的一般操作.对二维码工作原理了解,详情见:https://blog.csdn.net/weixin_36191 ...
- Java使用ZXing生成二维码条形码
一.下载Zxingjar包 本实例使用的是 zxing3.2.0的版本 下载地址 http://pan.baidu.com/s/1gdH7PzP 说明:本实例使用的3.2.0版本已经使用的java7 ...
- 【VB.NET】利用 ZXing.Net 生成二维码(支持自定义LOGO)
有任何疑问请去我的新博客提出 https://blog.clso.fun/posts/2019-03-03/vb-net-zxing-net-qr-maker.html ZXing .NET 的项目主 ...
- Java中使用google.zxing快捷生成二维码(附工具类源码)
移动互联网时代,基于手机端的各种活动扫码和收付款码层出不穷:那我们如何在Java中生成自己想要的二维码呢?下面就来讲讲在Java开发中使用 google.zxing 生成二维码. 一般情况下,Java ...
- 使用python调用zxing库生成二维码图片
(1) 安装Jpype 用python调用jar包须要安装jpype扩展,在Ubuntu上能够直接使用apt-get安装jpype扩展 $ sudo apt-get install pytho ...
- 利用Spring Boot+zxing,生成二维码还能这么简单
在网站开发中,经常会遇到要生成二维码的情况,比如要使用微信支付.网页登录等,本文分享一个Spring Boot生成二维码的例子,这里用到了google的zxing工具类. 本文目录 一.二维码简介二. ...
随机推荐
- 使用Jenkins来构建Docker容器
使用Jenkins来构建Docker容器(Ubuntu 14.04) 当开发更新了代码,提交到Gitlab上,然后由测试人员触发Jenkins,于是一个应用的新版本就被构建了.听起来貌似很简单,dua ...
- Android Bluetooth Stack: Bluedroid(五岁以下儿童):The analysis of A2DP Source
1. A2DP Introduction The Advanced Audio Distribution Profile (A2DP) defines the protocols and proced ...
- Windows系统服务的编写。
实验资源下载地址:点击打开链接 只是不知道能不能从服务向桌面进程传递消息,,就像两个桌面进程之间用Sendmessage似的..希望有知道的大神可以指点一下..不胜感激.. 因为微软在Vista之后, ...
- CGI编程学习----查询2000W开房数据
原文:CGI编程学习----查询2000W开房数据 0x01:什么是CGI编程? CGI:Common Gateway Interface CGI代表Common Gateway Interface( ...
- 小言HTTP Authentication
什么是Authentication? 首先解释两个长的非常像.easy混淆的单词,Authentication(鉴定.认证)和Authorization(授权). Authentication就是要证 ...
- 原生态纯JavaScript 100大技巧大收集---你值得拥有
1.原生JavaScript实现字符串长度截取 function cutstr(str, len) { var temp; var icount = 0; var patrn = /[^\x00-\x ...
- 权限设计实现(MVC4+Bootstrap+ PetaPoco+Spring.Net)
权限设计实现(MVC4+Bootstrap+ PetaPoco+Spring.Net) 一.前言 至毕业后一直在做企业Web开发,做过的项目也有不少,每个项目的框架设计都不是一样,但是每个项目的权限模 ...
- LINUX下getsockopt和setsockopt函数
这两个函数仅用于套接字. 函数原型: #include <sys/socket.h> #include <sys/types.h> int getsockopt(int soc ...
- Android在WebView上构建Web应用程序
原文链接:http://developer.android.com/guide/webapps/webview.html reference:http://developer.android.com/ ...
- a:focus{outline: none;} 如何去掉点击链接时周围的虚线框outline属性
1. CSS方式 在IE下是使用html属性:hideFoucs,在HTML标签中加上hidefocus=”true”属性即可,但这个属性是IE私有的,Firefox是不认的. 加了hidefocus ...