//设置图片资源

        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

官方网站:
http://original-ad.com

码晒客讨论QQ群:
28629273

个性二维码开源专题<前背景>的更多相关文章

  1. 个性二维码开源专题<后背景>

    //设置图片资源 private Image img1; public override void SetParam() { base.SetParam(); //读取图片 string _image ...

  2. 个性二维码开源专题<液化/圆角/效果>

    基础方法: ChangeFillShape //修改填充形状 ChangeFillShape(...) // 摘要: // 修改填充形状 // // 参数: // g: // 图形画板 // // F ...

  3. 个性二维码开源专题<替换元素点>

    基础方法:ChangeFillShape //修改填充形状 ChangeFillShape(...) // 摘要: // 修改填充形状 // // 参数: // g: // 图形画板 // // Fo ...

  4. 个性二维码开源专题<替换定位点>

    基础方法: ChangeFillShape //修改填充形状 ChangeFillShape(...) // 摘要: // 修改填充形状 // // 参数: // g: // 图形画板 // // F ...

  5. 个性二维码开源专题<介绍篇>

    由C#编写的个性二维码底层,已应用到 码晒客/疯狂创意二维码等项目上,并获得多项软件著作专利. 疯狂创意二维码 疯狂创意二维码是可用于生成风格独特的个性化二维码生成器,用户可以将目标信息输入到二维码生 ...

  6. 个性二维码开源专题<基础篇>

    二维码原理介绍: 二维码为什么是黑白相间的?黑色表示二进制的“1”,白色表示二进制的“0” “我们之所以对二维码进行扫描能读出那么多信息,就是因为这些信息被编入了二维码之中.”黄海平说,“制作二维码输 ...

  7. Android二维码开源项目zxing用例简化和生成二维码、条形码

    上一篇讲到:Android二维码开源项目zxing编译,编译出来后有一个自带的測试程序:CaptureActivity比較复杂,我仅仅要是把一些不用的东西去掉,用看起来更方便,二维码和条形码的流行性自 ...

  8. 你只要5行代码,拥有你的个性二维码,用Python生成动态二维码

    如果想了解更多关于python的应用,可以私信我,或者点击下方链接自行获取,里面到资料都是免费的(http://t.cn/A6Zvjdun) 二维码满天飞,但是有没有想过Python也能制作出专属于自 ...

  9. 二维码开源库ZBar-吐槽篇

    前不久在网上看到一篇文章<QR-Decoder-OV5640 二维码识别> ,是某开发板的教程.记得对应的开发板以前购买过,当初只是为了看OV5640的JPG的输出效果,结果由于公司奇葩的 ...

随机推荐

  1. 在Egret实现二维码长按识别

      Egret中二维码图片,是在canvas上,无法在微信上长按扫描识别. 由于微信长按识别二维码是截屏扫描原理,所以只要长按当前屏幕任意一张图片,都能够识别当前屏幕上的二维码. 这里把二维码放在ex ...

  2. WinExec

    WinAPI: WinExec - 运行外部程序 //声明 WinExec(   lpCmdLine: LPCSTR; {文件名和参数; 如没指定路径会按以下顺序查找: 程序目录/当前目录/Syste ...

  3. css兼容各个浏览器的三角形图标

    css兼容各个浏览器的三角形图标 在当前流行的的网站上,我们经常会看到一些小三角形的下拉提示(微博顶部的下拉菜单),简单的方式可以使用一张图片代替,但是随着前端技术的发展,以及开发者对于前端性能的“吹 ...

  4. IE内嵌google chrome frame解决浏览器兼容问题

    IE内嵌google chrome frame解决浏览器兼容问题  http://www.cnblogs.com/xwdreamer/archive/2013/12/17/3477776.html 参 ...

  5. (转)iOS sqlite :truncate/delete/drop区分

    转自:http://blog.sina.com.cn/s/blog_6755689f0101fofb.html 相同点: 1.truncate和不带where子句的delete.以及drop都会删除表 ...

  6. 【BZOJ3504】危桥(最大流)

    题意:见题面 思路:http://www.cnblogs.com/chenyushuo/p/5139556.html 必须交换b1,b2做第二次最大流的原因: 假如一个a1到b2的一个流和b1到a2的 ...

  7. 第二节 初识 python

    Python的由来 在1989年12月时,吉多·范罗苏姆——龟叔,想寻找一门“课余”编程项目来打发圣诞节前后的时间.Guido决定为当时正构思的一个新的脚本语言写一个解释器,它是ABC语言(教学语言. ...

  8. VS调试在Win7(vista系列)操作系统下 HttpListener拒绝访问解决办法

    一. VS调试在Win7(vista系列)操作系统下 HttpListener无法绑定多个 指定IP.端口问题 来自:http://www.cnblogs.com/ryhan/p/4195693.ht ...

  9. CSS从大图片上截取小图标的操作以及三角形的画法

    #name{ background:url(images/name.png) no-repeat 2px 2px; background-position: -2px -70px;//其中这个是定位图 ...

  10. 获取datagrid选择行

    var rows = $('#dg').datagrid('getChecked');     var ids = '';  for (var i = 0; i < rows.length; i ...