Asp.net core 学习笔记 QR code and Barcode
QR code 和 Barcode 经常会使用到。
Java 阵营有著名的 zxing
https://github.com/zxing/zxing
.Net 有对接它的 port
https://github.com/micjahn/ZXing.Net
调用很简单
var qrWriter = new BarcodeWriterPixelData
{
Format = BarcodeFormat.QR_CODE,
Options = new EncodingOptions { Height = , Width = , Margin = }
};
var pixelData = qrWriter.Write("i love you");
using (var bitmap = new Bitmap(pixelData.Width, pixelData.Height, System.Drawing.Imaging.PixelFormat.Format32bppRgb))
using (var ms = new MemoryStream())
{
// lock the data area for fast access
var bitmapData = bitmap.LockBits(new Rectangle(, , pixelData.Width, pixelData.Height),
System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
try
{
// we assume that the row stride of the bitmap is aligned to 4 byte multiplied by the width of the image
System.Runtime.InteropServices.Marshal.Copy(pixelData.Pixels, , bitmapData.Scan0,
pixelData.Pixels.Length);
}
finally
{
bitmap.UnlockBits(bitmapData);
}
// save to stream as PNG
//bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
bitmap.Save(@"C:\keatkeat\my projects\asp.net core\2.2\html-to-pdf\Project\123.png", System.Drawing.Imaging.ImageFormat.Png);
}
Barcode Format 有很多种,可以自己选。
这里用到了 bitmap, 是从官网的 demo 里抄来的.
早期 core 不支持 system draw, 所以 demo 里说依赖 CoreCompat.System.Drawing,
但后来 .net core 推出了 System.Drawing.Common 所以是跨平台的了.
demo : https://github.com/micjahn/ZXing.Net/tree/master/Clients/ASP.NetCoreDemo
Asp.net core 学习笔记 QR code and Barcode的更多相关文章
- Asp.net core 学习笔记 ( Web Api )
asp.net core 把之前的 webapi 和 mvc 做了结合. mvc 既是 api. 但是后呢,又发现, api 确实有独到之处,所以又开了一些补助的方法. namespace Proje ...
- Asp.net Core学习笔记
之前记在github上的,现在搬运过来 变化还是很大的,感觉和Nodejs有点类似,比如中间件的使用 ,努力学习ing... 优点 不依赖IIS 开源和跨平台 中间件支持 性能优化 无所不在的依赖注入 ...
- Asp.net core 学习笔记 ( Data protection )
参考 : http://www.cnblogs.com/xishuai/p/aspnet-5-identity-part-one.html http://cnblogs.com/xishuai/p/a ...
- Asp.net core 学习笔记 SignalR
refer : https://kimsereyblog.blogspot.com/2018/07/signalr-with-asp-net-core.html https://github.com/ ...
- Asp.net core (学习笔记 路由和语言 route &; language)
https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/routing?view=aspnetcore-2.1 https://doc ...
- Asp.net core 学习笔记 (授权)
更新 : 2018-11-24 记入一些思考 asp.net core + identity 的权限是这样的 user = 1 个登入账号 role = 1 个角色 (类似于公司里的一个职位) cla ...
- Asp.net core 学习笔记 ( identity server 4 JWT Part )
更新 : id4 使用这个 DbContext 哦 dotnet ef migrations add identity-server-init --context PersistedGrantDbCo ...
- Asp.net core 学习笔记 ( IIS, static file 性能优化 )
更新 : 2019-02-06 最后还是把 rewrite 给替换掉了. 所以 rewrite url 也不依赖 iis 了咯. refer : https://docs.microsoft.com/ ...
- Asp.net core 学习笔记 Fluent Validation
之前就有在 .net 时代介绍过了. 这个 dll 也支持 .net core 而且一直有人维护. 对比 data annotation 的 validation, 我越来越觉得这个 fluent 好 ...
随机推荐
- HTML5-属性
点击图片打开详细介绍页面
- Topcoder SRM583 DIV 2 250
#include <string> #include <iostream> using namespace std; class SwappingDigits { public ...
- maven初试2
1.1.建立Hello项目 1.首先建立Hello项目,同时建立Maven约定的目录结构和pom.xml文件 Hello | --src | -----main | ----------java | ...
- centos crontab 定时任务详解
安装crontab: yum install crontabs 说明: /sbin/service crond start //启动服务 /sbin/service crond stop //关闭服务 ...
- HDU-4879-ZCC loves march(map+set+并查集)
Description On a m*m land stationed n troops, numbered from 1 to n. The i-th troop's position can be ...
- OD: ActiveX Vulnerabilities
通过一个精心构造的页面 exploit 第三方软件中的 ActiveX 已经成为一种惯用攻击手段,众多知名软件公司都曾被发现其注册的 ActiveX 中存在严重的缓冲区溢出漏洞,一个被广泛使用的第三方 ...
- beego任务定时执行,延迟执行
import ( "github.com/astaxie/beego" "github.com/astaxie/beego/toolbox") cronExpr ...
- Swift ->; Let &; Var 背后编程模式 探讨
简介 Swift中有两种声明“变量”的方式,这两种方式分别使用let和var这两个关键字.这应该是借鉴了Scala,因为它们和Scala的val和var有相同的作用.let被用于声明不变量,var被用 ...
- 微端启动器LAUNCHER的制作之MFC版二(下载)
用了C#再回来用C++写真的有一种我已经不属于这个世界的感觉.C++的下载就没有C#那么方便了,我用的是libcurl.dll,官网上下载的源码自己cmake出来编译的,c++的库引用有debug和r ...
- android studio学习(一)
关于布局绝大部分使用线性布局和相对布局LinearLayout线性布局android:id 标识,找到空间"@+id/"android:layout_width 宽度android ...