个性二维码开源专题<前背景>
//设置图片资源
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的输出效果,结果由于公司奇葩的 ...
随机推荐
- 2.openssl rsa/pkey
分别是RSA密钥的处理工具和通用非对称密钥处理工具.它们用法基本一致,所以只介绍openssl rsa. [root@xuexi tmp]# man rsa NAME rsa - RSA key pr ...
- 开启telnet的几种方法
开启telnet方法一:需要VTY的密码和进入超级权限的密码(VTY虚拟终端,一种网络设备的连接方式) [R1]int g0/0/0[R1-GigabitEthernet0/0/0]ip add 19 ...
- MySQL_财务统计各产品品类各城市上周收入毛利表_20161202
注:财务需要统计各产品品类各城市上周毛利情况 下面这样的表是沟通后展现的形式.数据展现形式我认为的大都是行列转 列转行的转置 从财务角度这样展现形式比较适合. 由于黄色部分为汇总项目,因此我拆分成9个 ...
- js中~~的用法
~~(Math.random()*(1<<24))).toString(16) ~~的作用相当于parseInt
- [转]LIBSVM-3.18在python环境下的使用
http://blog.csdn.net/lj695242104/article/details/39500039 1)安装Python,直接去官方网站 2)运行“cmd”,直接输入python,查看 ...
- Echarts tooltip文字没有左对齐
tooltip : { trigger: 'axis', axisPointer : { // 坐标轴指示器,坐标轴触发有效 type : 'shadow' // 默认为直线,可选为:'line' | ...
- 【BootStrap】 基础
[BootStrap] 基础 一. 自适应(针对不同设备如手机平板笔电,使页面的宽度适应设备宽度) <meta name="viewport" content="w ...
- access数据库连接问题
使用Visual Studio连接access数据库(数据库后缀.accdb)时连接不上(access数据库提示未在本地计算机上注册“Microsoft.ACE.OLEDB.12.0”提供程序)解决办 ...
- PHP 数组函数整理
如果你已经使用了一段时间PHP的话,那么,你应该已经对它的数组比较熟悉了——这种数据结构允许你在单个变量中存储多个值,并且可以把它们作为一个集合进行操作. 经常,开发人员发现在PHP中使用这种数据结构 ...
- DP总结
最长回文子序列 int lpsDp(char * str,int n){ int dp[n][n], tmp; memset(dp,0,sizeof(dp)); for(int i=0; i<n ...