指数
0
Watch 68 Star 100 Fork 60

cheng5x / Yc.QrCodeC#GPL-2.0

加入码云
与超过 300 万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
码晒客/疯狂创意二维码,底层 ,模版制作开源 展开 收起

克隆/下载
cheng5x 最后提交于 cheng5x
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README.md

YcQrCode

码晒客/疯狂创意二维码,底层 ,模版制作开源

    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(0, 0, image.Width, image.Height));

        for (int i = 0; i < matrix.Length; i++)
        {
            for (int j = 0; 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);
            }
        }
        return image;
    }

blog: http://www.cnblogs.com/cheng5x

码晒客讨论QQ群: 28629273

点评 ( 0 )

你可以在登录后,发表评论

搜索帮助