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的更多相关文章

  1. Asp.Net Core学习笔记:入门篇

    Asp.Net Core 学习 基于.Net Core 2.2版本的学习笔记. 常识 像Django那样自动检查代码更新,自动重载服务器(太方便了) dotnet watch run 托管设置 设置项 ...

  2. ASP.NET Core 学习笔记 第一篇 ASP.NET Core初探

    前言 因为工作原因博客断断续续更新,其实在很早以前就有想法做一套关于ASP.NET CORE整体学习度路线,整体来说国内的环境的.NET生态环境还是相对比较严峻的,但是干一行爱一行,还是希望更多人加入 ...

  3. Asp.net core 学习笔记 ( Web Api )

    asp.net core 把之前的 webapi 和 mvc 做了结合. mvc 既是 api. 但是后呢,又发现, api 确实有独到之处,所以又开了一些补助的方法. namespace Proje ...

  4. Asp.net Core学习笔记

    之前记在github上的,现在搬运过来 变化还是很大的,感觉和Nodejs有点类似,比如中间件的使用 ,努力学习ing... 优点 不依赖IIS 开源和跨平台 中间件支持 性能优化 无所不在的依赖注入 ...

  5. ASP.NET Core 学习笔记 第三篇 依赖注入框架的使用

    前言 首先感谢小可爱门的支持,写了这个系列的第二篇后,得到了好多人的鼓励,也更加坚定我把这个系列写完的决心,也能更好的督促自己的学习,分享自己的学习成果.还记得上篇文章中最后提及到,假如服务越来越多怎 ...

  6. ASP.NET Core 学习笔记 第四篇 ASP.NET Core 中的配置

    前言 说道配置文件,基本大多数软件为了扩展性.灵活性都会涉及到配置文件,比如之前常见的app.config和web.config.然后再说.NET Core,很多都发生了变化.总体的来说技术在进步,新 ...

  7. ASP.NET Core 学习笔记 第五篇 ASP.NET Core 中的选项

    前言 还记得上一篇文章中所说的配置吗?本篇文章算是上一篇的延续吧.在 .NET Core 中读取配置文件大多数会为配置选项绑定一个POCO(Plain Old CLR Object)对象,并通过依赖注 ...

  8. Asp.net core 学习笔记 ( Data protection )

    参考 : http://www.cnblogs.com/xishuai/p/aspnet-5-identity-part-one.html http://cnblogs.com/xishuai/p/a ...

  9. Asp.net core 学习笔记 SignalR

    refer : https://kimsereyblog.blogspot.com/2018/07/signalr-with-asp-net-core.html https://github.com/ ...

随机推荐

  1. Maven依赖传递

    依赖传递原则: 1.路径最短原则 2.路径相同是先申明者优先(dependency申明顺序先的优先)

  2. [题解] [BZOJ4144] 「AMPPZ2014」Petrol

    题面 怎么是权限题啊 题解 有一次考过, 但是不记得了 如果每个点都是加油站的话, 这道题就是货车运输 考虑如何转化 我们可以设

  3. Chisel-LLDB命令插件,让调试更Easy

    http://blog.cnbluebox.com/blog/2015/03/05/chisel/ LLDB 是一个有着 REPL 的特性和 C++ ,Python 插件的开源调试器.LLDB 绑定在 ...

  4. js面向对象入门

    通常我们写js以及调用: function init(){ console.log("init") } function load(){ console.log("loa ...

  5. mysql CONCAT函数

    有时候我们需要使用coacat函数拼接一些字段的生成一个字符串,比如:select concat(field1,field2,field3)  from xxx: 这时候我们就会的到一个这些字段的值拼 ...

  6. spring cloud gateway:Unable to find GatewayFilterFactory with name Hystrix

    在springcloud gateway中引用Hystrix filter 编译启动时提示 Unable to find GatewayFilterFactory with name Hystrix ...

  7. guava常用集合交集,差集,并集,补集操作

    <!-- https://mvnrepository.com/artifact/com.google.guava/guava --> <dependency> <grou ...

  8. git clone速度太慢解决方案

    原文地址:https://blog.csdn.net/hzwwpgmwy/article/details/79043251 适用各种操作系统,本次测试于ubuntu,下载速度从二十几k提高到二百多k ...

  9. 使 nodejs 代码 在后端运行(nohup)

    1.代码 nohup node server.js & 说明: nohup 命令对 server.js 进程做了三件事 (1)阻止SIGHUP信号发到这个进程. (2)关闭标准输入.该进程不再 ...

  10. SQL-W3School-高级:SQL ALTER TABLE 语句

    ylbtech-SQL-W3School-高级:SQL ALTER TABLE 语句 1.返回顶部 1. ALTER TABLE 语句 ALTER TABLE 语句用于在已有的表中添加.修改或删除列. ...