资源简介
vs2008 c#.net (web)二维码生成系统
包含50x50logo图片加入功能,主要引用google.zxing库,在vs2008下测试没有问题

代码片段和文件信息
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Coding;
using ZXing;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
public string CHARSET = “UTF-8“;
public string CodeName
{
get
{
return ViewState[“codename“] as string;
}
set
{
ViewState[“codename“] = value;
}
}
protected void Page_Load(object sender EventArgs e)
{
}
///
/// 创ä¡ä建¡§二t维?码?并¡é保À¡ê存ä?
///
/// 编À¨¤码?内¨²容¨Y,ê?字Á?符¤?串ä?(ꡧ没?试º?过y最Á?长¡è有®D多¨¤长¡è,ê?不?能¨¹为a空?字Á?符¤?串ä?)ê?
///
protected void CreateQRCode(string content string path)
{
CodeHelper helper = new CodeHelper();
int width = 256;
int height = 256;
BarcodeFormat barcodeFormat = BarcodeFormat.QR_CODE;
//下面是影响编码的一些参数
Dictionaryject> hints = new Dictionaryject>();
hints.Add(EncodeHintType.MARGIN 1);//边距,知道HTML的话应该能理解它是什么,不能理解的话,改成4或者注释掉试试生成的效果。
hints.Add(EncodeHintType.CHARACTER_SET CHARSET);
hints.Add(EncodeHintType.ERROR_CORRECTION ZXing.QrCode.Internal.ErrorCorrectionLevel.H);//设置容错等级,不设置这个,之后加了logo图片就不能识别了。可以改变试试查看ErrorCorrectionLevel枚举应该能知道它有什么值。
helper.SaveTo(helper.encode(content width height barcodeFormat hints) path ““);
}
protected void btnEncode_Click(object sender EventArgs e)
{
string randSeedStr = “中D文ABCDEFGHIJKLKDLKDKLDLK我你他AFJhibiebubiud他何必À都id1241232341234“;
//string randSeedStr = “ABCDEFGHIJKLKDLKDKLDLKAFJhibiebubiudid1241232341234“;
string path = DateTime.Now.ToString(“yyyyMMddHHmmss“) + “.png“;
string content = GetContent();
if (string.IsNullOrEmpty(content))
{
content = GetRandomStr(randSeedStr);
}
CreateQRCode(content Server.MapPath(“~/codes/“) + path);
//==============图ª?片?中D间?加¨logo图片片?===================
System.Drawing.Image bitmap = System.Drawing.Image.FromFile(Server.MapPath(“~/codes/“) + path);
string logopath = Server.MapPath(“~/“) + “logo.png“;
if (File.Exists(logopath))
{
try
{
File.Delete(logopath);
}
catch { }
}
fileUpload.SaveAs(logopath);
System.Drawing.Image logo = System.Drawing.Image.FromFile(logopath);
Graphics g = Graphics.FromImage(bitmap);
//logo图ª?片?的Ì?大䨮小?,ê?不?要°a太¬?大䨮,ê?参?考?网ª?上¦?50*50貌2似?很¨¹好?
float logoWidth = 50;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 426496 2014-01-23 10:41 Bin\zxing.dll
文件 38 2014-09-07 16:34 Bin\zxing.dll.refresh
文件 1177088 2014-01-23 10:41 Bin\zxing.pdb
文件 529479 2014-01-23 10:41 Bin\zxing.xm
文件 6889 2014-09-07 16:54 codes\20140907165438.png
文件 6889 2014-09-07 16:54 codes\20140907165449.png
文件 6207 2014-09-07 16:57 codes\20140907165744.png
文件 7544 2014-09-07 16:57 codes\20140907165758.png
文件 7912 2014-09-07 16:58 codes\20140907165815.png
文件 7012 2014-09-07 16:58 codes\20140907165826.png
文件 7012 2014-09-07 16:58 codes\20140907165835.png
文件 7495 2014-09-07 16:58 codes\20140907165852.png
文件 10802 2014-09-07 16:58 codes\logo.png
文件 1548 2014-09-07 16:30 Default.aspx
文件 5097 2014-09-07 16:30 Default.aspx.cs
文件 5367 2014-09-07 16:58 logo.png
文件 8631 2014-09-07 16:22 web.config
文件 2878 2014-09-07 16:30 App_Code\Coding.cs
文件 5367 2014-09-07 16:56 App_Code\logo.png
文件 426496 2014-01-23 10:41 App_Code\zxing.dll
文件 1177088 2014-01-23 10:41 App_Code\zxing.pdb
文件 529479 2014-01-23 10:41 App_Code\zxing.xm
目录 0 2014-09-07 16:22 App_Data
目录 0 2014-09-07 16:34 Bin
目录 0 2014-09-07 16:58 codes
目录 0 2014-09-07 16:46 App_Code
----------- --------- ---------- ----- ----
4362814 26
相关资源
- 一款漂亮的灯光闪烁的圣诞树(C# V
- 酒店管理系统(c#.net源码)
- C#串口通信之基恩士读码器读二维码
- 汉字二维码生成及解码
- C# 斑马手持终端WINCE开发 MC32N0 vs2008
- C# 条码、二维码生成器
- C# 批量生成二维码工具
- 二维码 生成,解析
- 二维码生成解析工具源码
- 大型比赛竞赛抽签系统 可打印 c# vs
- 学校网站原代码(C#.NET)
- c# 开发与 mysql数据库实现的增删改查
- ASP.net MVC vcard名片二维码自动生成
- 基于c#.net平台的21点游戏
- C#中二维码实现源代码修正版
- C#.NET程序设计案例教程
- ERP实施方法论
- C#.net宾馆酒店管理系统
- DM二维码生成器
- C#.Net开发抠图工具
- C#利用Zxing.NET生成条形码和二维码并实
- .NET(c#)Web生成二维码
- 基于c#.net的网上书店的设计与实现
- 物料清单 bom图
- 基于C#.NET的Autocad二次开发范例
- VS2008+SQL2005开源普通三层架构项目源代
- 基于VS2008 C#编写的简单学生成绩管理
- C#.net宠物商店管理系统带数据库完整
- C# 数据库连接MySQL、SQL server并读取数
- Halcon联合C#编写的检测二维码窗体程序
评论
共有 条评论