如何正确设置二维码大小?

问题描述 投票:0回答:0

我在pictureBox1.Image中创建了一个QrCode。但是,我创建的这个二维码打印页面显示已损坏。

那是我的代码:

private void Create_Click(object sender, EventArgs e)
{
    //Zen.Barcode.Code128BarcodeDraw barcode = Zen.Barcode.BarcodeDrawFactory.Code128WithChecksum;
    //pictureBox1.Image = barcode.Draw(textBox1.Text, 50);

    Zen.Barcode.CodeQrBarcodeDraw QrCode = Zen.Barcode.BarcodeDrawFactory.CodeQr;
    pictureBox1.Image = QrCode.Draw(textBox1.Text, 50);
}

我在哪里设置条形码的大小:

        /* BARKOD */
        Bitmap bmp = new Bitmap(38, 38); // new Bitmap(pictureBox1.Width, pictureBox1.Height);
        bmp.SetResolution(203, 203);
        pictureBox1.DrawToBitmap(bmp, new Rectangle(0, 0, 50, 50)); // (bmp, new Rectangle(0, 0, pictureBox1.Width, pictureBox1.Height)); 
        e.Graphics.DrawImage(bmp, 80, 35);
        e.HasMorePages = false;
        bmp.Dispose();
        /* BARKOD */

我根据标签打印机的分辨率做了SetResolution,但是没有解决。我哪里做错了?

c# printing qr-code barcode
© www.soinside.com 2019 - 2024. All rights reserved.