个性二维码开源专题<后背景>
//设置图片资源
private Image img1;
public override void SetParam()
{
base.SetParam(); //读取图片
string _imagePath1 = Environment.CurrentDirectory + @"\image\point2.jpg";
img1 = Image.FromFile(_imagePath1);
}
//首先设置背景透明
//SolidBrush Backbrush = new SolidBrush(QrCodeEncoder.QRCodeBackgroundColor);
SolidBrush Backbrush = new SolidBrush(Color.Transparent);//背景透明
SolidBrush Forebrush = new SolidBrush(QrCodeEncoder.QRCodeForegroundColor);
//先插入背景图,后生成二维码
//TODO:一系列个性二维码生成方案
public override Bitmap Encode(string content)
{
try
{
matrix = QrCodeEncoder.calQrcode(EnCoding.GetBytes(content));
}
catch { throw new Exception("内容超出范围,请选择更高版本或者降低容错率"); } this.SetParam(); //SolidBrush Backbrush = new SolidBrush(QrCodeEncoder.QRCodeBackgroundColor);
SolidBrush Backbrush = new SolidBrush(Color.Transparent);//背景透明
SolidBrush Forebrush = new SolidBrush(QrCodeEncoder.QRCodeForegroundColor); Bitmap image = new Bitmap(this.QrCodeW, this.QrCodeH);
Graphics g = Graphics.FromImage(image); //后背景
g.DrawImage(img1, 0, 0, this.QrCodeW, this.QrCodeH);
Rectangle rect = new Rectangle(); g.FillRectangle(Backbrush, new Rectangle(, , image.Width, image.Height)); for (int i = ; i < matrix.Length; i++)
{
for (int j = ; j < matrix.Length; j++)
{
rect = new Rectangle((j + this.SpacingW) * QrCodeEncoder.QRCodeScale, (i + this.SpacingH) * QrCodeEncoder.QRCodeScale, QrCodeEncoder.QRCodeScale, QrCodeEncoder.QRCodeScale);
if (matrix[j][i])
{
ChangeFillShape(g, Forebrush, rect, EN_FillShape.FillRectangle, new FillShape(), Forebrush);
}
else
{
ChangeFillShape(g, Backbrush, rect, EN_FillShape.FillRectangle, new FillShape(), Backbrush);
}
}
}
return image;
}

//当然,还可以使用一些图片处理效果,例如:平铺
//TODO:一系列个性二维码生成方案
public override Bitmap Encode(string content)
{
try
{
matrix = QrCodeEncoder.calQrcode(EnCoding.GetBytes(content));
}
catch { throw new Exception("内容超出范围,请选择更高版本或者降低容错率"); } this.SetParam(); //SolidBrush Backbrush = new SolidBrush(QrCodeEncoder.QRCodeBackgroundColor);
SolidBrush Backbrush = new SolidBrush(Color.Transparent);//背景透明
SolidBrush Forebrush = new SolidBrush(QrCodeEncoder.QRCodeForegroundColor); Bitmap image = new Bitmap(this.QrCodeW, this.QrCodeH);
Graphics g = Graphics.FromImage(image); //平铺
GraphicsPath _path = ImageFix.GetWindowRegion(image, QrCodeEncoder.QRCodeForegroundColor);
TextureBrush texture1 = new TextureBrush(img1);
g.FillPath(texture1, _path); Rectangle rect = new Rectangle(); g.FillRectangle(Backbrush, new Rectangle(, , image.Width, image.Height)); for (int i = ; i < matrix.Length; i++)
{
for (int j = ; j < matrix.Length; j++)
{
rect = new Rectangle((j + this.SpacingW) * QrCodeEncoder.QRCodeScale, (i + this.SpacingH) * QrCodeEncoder.QRCodeScale, QrCodeEncoder.QRCodeScale, QrCodeEncoder.QRCodeScale);
if (matrix[j][i])
{
ChangeFillShape(g, Forebrush, rect, EN_FillShape.FillRectangle, new FillShape(), Forebrush);
}
else
{
ChangeFillShape(g, Backbrush, rect, EN_FillShape.FillRectangle, new FillShape(), Backbrush);
}
}
}
return image;
}

以下是开源地址,国外github,国内oschina.net
oschina.net:
http://git.oschina.net/cheng5x/Yc.QrCode
github:
https://github.com/cheng5x/YcQrCode
码晒客讨论QQ群:
28629273
个性二维码开源专题<后背景>的更多相关文章
- 个性二维码开源专题<前背景>
//设置图片资源 private Image imgAgo; public override void SetParam() { base.SetParam(); // 读取前背景 string _i ...
- 个性二维码开源专题<液化/圆角/效果>
基础方法: ChangeFillShape //修改填充形状 ChangeFillShape(...) // 摘要: // 修改填充形状 // // 参数: // g: // 图形画板 // // F ...
- 个性二维码开源专题<替换元素点>
基础方法:ChangeFillShape //修改填充形状 ChangeFillShape(...) // 摘要: // 修改填充形状 // // 参数: // g: // 图形画板 // // Fo ...
- 个性二维码开源专题<替换定位点>
基础方法: ChangeFillShape //修改填充形状 ChangeFillShape(...) // 摘要: // 修改填充形状 // // 参数: // g: // 图形画板 // // F ...
- 个性二维码开源专题<介绍篇>
由C#编写的个性二维码底层,已应用到 码晒客/疯狂创意二维码等项目上,并获得多项软件著作专利. 疯狂创意二维码 疯狂创意二维码是可用于生成风格独特的个性化二维码生成器,用户可以将目标信息输入到二维码生 ...
- 个性二维码开源专题<基础篇>
二维码原理介绍: 二维码为什么是黑白相间的?黑色表示二进制的“1”,白色表示二进制的“0” “我们之所以对二维码进行扫描能读出那么多信息,就是因为这些信息被编入了二维码之中.”黄海平说,“制作二维码输 ...
- Android二维码开源项目zxing用例简化和生成二维码、条形码
上一篇讲到:Android二维码开源项目zxing编译,编译出来后有一个自带的測试程序:CaptureActivity比較复杂,我仅仅要是把一些不用的东西去掉,用看起来更方便,二维码和条形码的流行性自 ...
- 你只要5行代码,拥有你的个性二维码,用Python生成动态二维码
如果想了解更多关于python的应用,可以私信我,或者点击下方链接自行获取,里面到资料都是免费的(http://t.cn/A6Zvjdun) 二维码满天飞,但是有没有想过Python也能制作出专属于自 ...
- 二维码开源库ZBar-吐槽篇
前不久在网上看到一篇文章<QR-Decoder-OV5640 二维码识别> ,是某开发板的教程.记得对应的开发板以前购买过,当初只是为了看OV5640的JPG的输出效果,结果由于公司奇葩的 ...
随机推荐
- Hibernate day02笔记
对象状态与一级缓存 状态介绍 hibernate 规定三种状态:瞬时态.持久态.脱管态 状态 瞬时态:transient,session没有缓存对象,数据库也没有对应记录. ...
- CentOS6 vsftpd 安装及优化方法
我在每次配置ftp的时候都会一头雾水,一直也没总结一份特别完整有效的方法出来,这次特别记录一下,以备以后使用 1.安装vsftpd yum -y install vsftpd chkconfig vs ...
- 主机名链接数据库,无法生成 SSPI 上下文
两台Server,环境一样,都使用同一域账号. 1的SQL Server可以通过Windows认证连接到2,但2通过Windows认证连接1时报如下错误: 目标主体名称不正确,无法生成 SSPI 上下 ...
- cursor
BeginWaitCursor(); // display the hourglass cursor // do some lengthy processing Sleep(3000); EndWai ...
- C#模拟浏览器发get,post请求
调用: JArray ja = (JArray)JsonConvert.DeserializeObject("["+GetDataPost()+"]"); Re ...
- solr入门命令
#####################shell命令############################# 导入文档: sh bin/post -c gettingstarted docs/i ...
- iOS真机调试问题-App installation failed,The maximum number of apps for free development profiles has been reached.
The maximum number of apps for free development profiles has been reached. 源引:http://www.jianshu.com ...
- PHP各种缓存
缓存类型PHP缓存包括PHP变异缓存和PHP数据缓存两种:PHP编译缓存: PHP数据缓存: 对数据库数据进行缓存 对PHP模板数据缓存 js数据缓存
- Android 操作SQLite基本用法
一.SQLite的介绍 1.SQLite简介 SQLite是一款轻型的数据库,是遵守ACID的关联式数据库管理系统,它的设计目标是嵌入 式的,而且目前已经在很多嵌入式产品中使用了它,它占用资源非常的 ...
- Java 技术体系图
Java 程序员 高级特性 反射.泛型.注释符.自动装箱和拆箱.枚举类.可变 参数.可变返回类型.增强循环.静态导入 核心编程 IO.多线程.实体类. 集合类.正则表达式. XML 和属性文件 图形编 ...