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. Spring Boot 中 Druid 的监控页面配置

    Druid的性能相比HikariCp等其他数据库连接池有一定的差距,但是数据库的相关属性的监控,别的连接池可能还追不上,如图: 今天写一下 Spring Boot 中监控页面的配置,我是直接将seat ...

  2. 通过JDBC API访问数据库的基本步骤

    1.获取要访问的数据库的JDBC驱动程序的类库文件,把它放到classpath中. 2.在程序中加载并注册JDBC驱动程序.例如,以下代码用于加载并注册MySQL驱动程序: //加载MySQL Dri ...

  3. Flutter控制某个TextField获取焦点及失去焦点

    在项目中有时需要点击某个地方的时候让一个文本框获取焦点以弹起键盘~~比如前端经常使用的input.focus(),但是在flutter中没有.focus()这个方法~~不过我们可以通过FocusSco ...

  4. Truffle Smart Contract Error: Invalid number of parameter

      I followed the tutorial of quorum with truffle: https://truffleframework.com/tutorials/building-da ...

  5. The first one spawns an additional process forwarding requests to a series of workers (think about it as a form of shield, at the same level of apache or nginx), while the second one sets workers to n

    Things to know (best practices and “issues”) READ IT !!! — uWSGI 2.0 documentationhttps://uwsgi-docs ...

  6. LC 984. String Without AAA or BBB

    Given two integers A and B, return any string S such that: S has length A + B and contains exactly A ...

  7. LC 988. Smallest String Starting From Leaf

    Given the root of a binary tree, each node has a value from 0 to 25 representing the letters 'a' to  ...

  8. 阶段5 3.微服务项目【学成在线】_day02 CMS前端开发_13-webpack研究-webpack入门程序

    创建webpack测试的目录 定义webpack的入口文件 mdel01必须导出,main里面才能导入 导出多个 数组的写法 main是入口文件,里面已经引入了vue.min和model01.js   ...

  9. eclipse、MyEclipse 修改字符集和JDK

    eclipse 中UTF-8设置 1.windows->Preferences   打开"首选项"对话框: 2.然后,general->Workspace,右 侧Tex ...

  10. Python之操作RabbitMQ

    RabbitMQ是一个在AMQP基础上完整的,可复用的企业消息系统.他遵循Mozilla Public License开源协议. MQ全称为Message Queue, 消息队列(MQ)是一种应用程序 ...