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学习笔记:入门篇
Asp.Net Core 学习 基于.Net Core 2.2版本的学习笔记. 常识 像Django那样自动检查代码更新,自动重载服务器(太方便了) dotnet watch run 托管设置 设置项 ...
- ASP.NET Core 学习笔记 第一篇 ASP.NET Core初探
前言 因为工作原因博客断断续续更新,其实在很早以前就有想法做一套关于ASP.NET CORE整体学习度路线,整体来说国内的环境的.NET生态环境还是相对比较严峻的,但是干一行爱一行,还是希望更多人加入 ...
- 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 学习笔记 第三篇 依赖注入框架的使用
前言 首先感谢小可爱门的支持,写了这个系列的第二篇后,得到了好多人的鼓励,也更加坚定我把这个系列写完的决心,也能更好的督促自己的学习,分享自己的学习成果.还记得上篇文章中最后提及到,假如服务越来越多怎 ...
- ASP.NET Core 学习笔记 第四篇 ASP.NET Core 中的配置
前言 说道配置文件,基本大多数软件为了扩展性.灵活性都会涉及到配置文件,比如之前常见的app.config和web.config.然后再说.NET Core,很多都发生了变化.总体的来说技术在进步,新 ...
- ASP.NET Core 学习笔记 第五篇 ASP.NET Core 中的选项
前言 还记得上一篇文章中所说的配置吗?本篇文章算是上一篇的延续吧.在 .NET Core 中读取配置文件大多数会为配置选项绑定一个POCO(Plain Old CLR Object)对象,并通过依赖注 ...
- 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/ ...
随机推荐
- Linux下 Java 读取文件路径
一般文件路径在windows中用 \ 表示,但是在其他系统平台下比如linux中就不是 \ 所以java给我们提供了一个与平台无关的表示路径的常量 File.separator在windows中则表示 ...
- java课后实验性问题7
1.异常处理 import javax.swing.*; class AboutException { public static void main(String[] a) { int i = 1, ...
- --thunder-lock is available since uWSGI 1.4.6 but never got documentation (of any kind)
--thunder-lock is available since uWSGI 1.4.6 but never got documentation (of any kind) Serializing ...
- UML期末复习题——2.2:UML Activity Diagram.
第二题:活动图 重要概念: 活动图:一种有助于使工作流和业务过程可视化的图. 绘制要点: 具体方法见:http://www.cnblogs.com/xiaolongbao-lzh/p/4591953. ...
- v-if与v-show的区别?
v-if的显示和隐藏实在dom里创建和消除dom节点 v-show是用css样式的display来控制dom节点的显示和隐藏 相比之下,v-show 就简单得多——不管初始条件是什么,元素总是会被渲染 ...
- Swift 基本语法
如果创建的是 OS X playground 需要引入 Cocoa : import Cocoa /* 我的第一个 Swift 程序 */ var myString = "Hello, Wo ...
- centos7 搭建FTP
通过yum安装vsftpd yum install -y vsftpd 修改vsftpd的配置文件 vim /etc/vsftpd/vsftpd.conf 修改配置文件如下: 1.不允许匿名访问 an ...
- VBA 格式化excel数据表 (数据分列)
Sub ImportData() ' ' Copy Data from one workbook to the Current Workbook ' Place the macro file in t ...
- 阶段5 3.微服务项目【学成在线】_day04 页面静态化_07-freemarker基础-if指令
<td <#if stu.name=="小明">style="background-color:cornflowerblue"</#if ...
- linux---学习3
1.free命令可以显示当前系统未使用的和已使用的内存数目,还可以显示被内核使用的内存缓冲区. //-m:以MB为单位显示内存使用情况: free -m 2.vmstat命令的含义为显示虚拟内存状态, ...