个性二维码开源专题<前背景>
//设置图片资源
private Image imgAgo;
public override void SetParam()
{
base.SetParam(); // 读取前背景
string _imagePath = Environment.CurrentDirectory + @"\QrCodeModel\Images\Angry_Birds\boom.png";
imgAgo = Image.FromFile(_imagePath);
}
//在生成二维码之后,加入前背景图层
//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); 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(), Backbrush);
}
else
ChangeFillShape(g, Backbrush, rect, EN_FillShape.FillRectangle, new FillShape(), Backbrush);
}
} //前背景
GraphicsPath _path = ImageFix.GetWindowRegion(image, QrCodeEncoder.QRCodeForegroundColor);
TextureBrush texture1 = new TextureBrush(new Bitmap(imgAgo, new Size(image.Width, image.Height)));
g.FillPath(texture1, _path); return image;
}

//还可以设置,LOGO,头像等等
//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); 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(), Backbrush);
}
else
ChangeFillShape(g, Backbrush, rect, EN_FillShape.FillRectangle, new FillShape(), Backbrush);
}
} //Logo
Image _logoImg = imgAgo;
g.DrawImage(_logoImg, (this.QrCodeW - this.QrCodeW / ) / , (this.QrCodeH - this.QrCodeH / ) / , this.QrCodeW / , this.QrCodeH / );//插入头像 return image;
}

//为了可印刷名片、图册,可以去色
//Logo
Image _logoImg = imgAgo;
_logoImg = ImageFix.Blocks((Bitmap)_logoImg);
_logoImg = ImageFix.ColorReplace((Bitmap)_logoImg, Color.Black, QrCodeEncoder.QRCodeForegroundColor); g.DrawImage(_logoImg, (this.QrCodeW - this.QrCodeW / ) / , (this.QrCodeH - this.QrCodeH / ) / , this.QrCodeW / , this.QrCodeH / );//插入头像 return image;

//还可以自由配色
//Logo
Image _logoImg = imgAgo;
_logoImg = ImageFix.Blocks((Bitmap)_logoImg);
_logoImg = ImageFix.ColorReplace((Bitmap)_logoImg, Color.Black, Color.Blue); g.DrawImage(_logoImg, (this.QrCodeW - this.QrCodeW / ) / , (this.QrCodeH - this.QrCodeH / ) / , this.QrCodeW / , this.QrCodeH / );//插入头像

以下是开源地址,国外github,国内oschina.net
oschina.net:
http://git.oschina.net/cheng5x/Yc.QrCode
github:
https://github.com/cheng5x/YcQrCode
码晒客讨论QQ群:
28629273
个性二维码开源专题<前背景>的更多相关文章
- 个性二维码开源专题<后背景>
//设置图片资源 private Image img1; public override void SetParam() { base.SetParam(); //读取图片 string _image ...
- 个性二维码开源专题<液化/圆角/效果>
基础方法: 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的输出效果,结果由于公司奇葩的 ...
随机推荐
- Windows 7 下如何设置机器级别的DCOM权限
Windows 7 下如何设置机器级别的DCOM权限 To grant Remote Activation permissions to the SMS Admins group From the S ...
- nginx环境下配置nagios-关于nagios配置文件nginx.conf
接上文:nginx环境下配置nagios-关于nginx.conf 配置如下: ; location ~ .*\.(php|php5)?$ { ...
- a + b + c 求和
#include <iostream> int main() { std::cout << "请输入三个数字,以空格分隔,按回车键结束:" << ...
- 循序渐进Python3(三) -- 3 -- 内置函数
上一篇我们又介绍了26个Python内置函数.现回忆一下吧: 1.all 2.any 3.ascii 4.bin 5.bool 6.bytes 7.bytearray 8.callable 9.chr ...
- java 封装httpclient 的get 和post 请求
import java.io.ByteArrayOutputStream; import java.io.UnsupportedEncodingException; import java.util. ...
- iframe自动适应高度1
js: function iFrameHeight() { var ifm= document.getElementById("iframepage"); var subWeb = ...
- 【转载】Windows自带.NET Framework版本大全
转载自:http://blogs.msdn.com/b/astebner/archive/2007/03/14/mailbag-what-version-of-the-net-framework-is ...
- nginx的特点
1.热部署 我个人觉得这个很不错.在master管理进程与worker工作进程的分离设计,使的Nginx具有热部署的功能,那么在7×24小时不间断服务的前提下,升级Nginx的可执行文件 ...
- coreseek实战(四):php接口的使用,完善php脚本代码
coreseek实战(四):php接口的使用,完善php脚本代码 在上一篇文章 coreseeek实战(三)中,已经能够正常搜索到结果,这篇文章主要是把 index.php 文件代码写得相对完整一点点 ...
- 解析Tomcat内部结构和请求过程
Tomcat Tomcat的组织结构 由Server.xml的结构看Tomcat的体系结构 Tomca的两大组件:Connecter和Container Connecter组件 Container组件 ...