最新使用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#中string类型的方法分享

详解winform c#中子窗体关闭刷新父窗体的示例代码

c#生成一万以内所有不重复数字的四位数

使用c#生成pdf文件流的代码案例分享

c# 中虚方法和抽象方法

分析c#httpwebrequest访问https错误处理的方法

c#如何利用reportviewer来生成报表的示例代码分享(图)

c#的四种基本数据类型详解

详细介绍用c#描述数据结构2:array的图文代码实例

手把手教你c#中指针的使用方法

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




打赏

取消

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

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

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

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

评论

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