最新使用C#生成二维码方案,详解及实例 ( QRCoder )


当前第2页 返回上一页

g.png

2.代码

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

using System;

using System.Drawing;

using System.Windows.Forms;

 

namespace chestnut_form

{

    public partial class frm_qrcode : Form

    {

        public frm_qrcode()

        {

            InitializeComponent();

        }

 

        // 窗体加载

        private void frm_qrcode_Load(object sender, EventArgs e)

        {

            cb_version.SelectedIndex = 1;

 

            cb_pixel.SelectedIndex = 0;

 

            cb_icon_size.SelectedIndex = 0;

 

            cb_icon_border.SelectedIndex = 1;

        }

 

        // 编码

        private void btn_encode_Click(object sender, EventArgs e)

        {

            int version = Convert.ToInt16(cb_version.Text);

 

            int pixel = Convert.ToInt16(cb_pixel.Text);

 

            string str_msg = tb_msg.Text;

 

            int int_icon_size = Convert.ToInt16(cb_icon_size.Text);

 

            int int_icon_border = Convert.ToInt16(cb_icon_border.Text);

 

            bool b_we = rb_we_y.Checked ? true : false;

 

            Bitmap bmp = chestnut_qrcode.Encoder.code(str_msg, version, pixel, "E:/seaconch/git/1.jpg", int_icon_size, int_icon_border, b_we);

 

            pb_qrcode.Image = bmp;

        }

 

        // 保存

        private void btn_save_Click(object sender, EventArgs e)

        {

            if (pb_qrcode.Image != null)

 

                using (SaveFileDialog sfd = new SaveFileDialog())

                {

                    sfd.Filter = "(*.png)|*.png|(*.bmp)|*.bmp";

 

                    if (sfd.ShowDialog() == DialogResult.OK) pb_qrcode.Image.Save(sfd.FileName);

 

                }

        }

    }

}

看下C#二维码生成效果

h.png

相关文章:

【c#教程】C# 数据类型

相关视频:

极客学院C#视频教程

以上就是最新使用C#生成二维码方案,详解及实例 ( QRCoder )的详细内容!

返回前面的内容

相关阅读 >>

c#基础入门-常量详解

c#静态分析工具 roslynator.analyzers 将方法数量提高了 500 多

简单介绍c#表达式树expression简单类型比较demo的示例代码

深入理解c#rx的主要接口

c#动态对象dynamic实现方法和属性动态代码详解

【c#教程】c# 多态性

具体详解c#中三个关键字(params,ref,out)

分享125个基本的c#面试问答

c#中guid生成格式的四种方法的示例代码分享

详解c#接口在派生类和外部类中的调用方法示例

更多相关阅读请进入《二维码》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...