You must Sign In to post a response.
  • Category: .NET

    How to put image logo within generated qr code

    Problem
    How to put logo inside my generated bar code ?
    I make windows application to generate c# qr code

    I success to do that but i need to put image in center of generated bar code

    But How to do that this is actually my question ?

    I work in visual studio 2015 windows form applications

    i using messagetoolkitqrcode

    My code generated qr code by c# as following :

    private void button1_Click(object sender, EventArgs e)
    {
    using (SaveFileDialog sv = new SaveFileDialog() { Filter = "JPEG|*.jpg", ValidateNames = true })
    {
    if (sv.ShowDialog()==DialogResult.OK)
    {
    MessagingToolkit.QRCode.Codec.QRCodeEncoder encoder = new MessagingToolkit.QRCode.Codec.QRCodeEncoder();
    encoder.QRCodeScale = 8;
    Bitmap bmp = encoder.Encode(textBox1.Text);
    pictureBox1.Image = bmp;
    bmp.Save(sv.FileName, ImageFormat.Jpeg);
    }

    }


    }

    How to put logo inside my generated bare code as following image

    my logo i need to put inside qr bar code is NASA logo when i generate it as following :

    AND logo found in path

    c/nasa.jpg
  • #768555

    Delete Attachment

  • #768592
    You can use given code snippet for create a QR Code
    namespace CodeCreator
    {
    public partial class _default : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void CreateCode_OnClick(object sender, EventArgs e)
    {
    string path = "c:\\code\\projects\\CodeCreator\\CodeCreator\\";
    QRCodeEncoder encoder = new QRCodeEncoder();

    encoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.H; // 30%
    encoder.QRCodeScale = 10;

    Bitmap img = encoder.Encode(URL.Text);
    LogoUpload.SaveAs(path + LogoUpload.FileName);

    System.Drawing.Image logo = System.Drawing.Image.FromFile(path + LogoUpload.FileName);

    int left = (img.Width / 2) - (logo.Width / 2);
    int top = (img.Height / 2) - (logo.Height / 2);

    Graphics g = Graphics.FromImage(img);

    g.DrawImage(logo, new Point(left, top));

    img.Save(path + "img.jpg", ImageFormat.Jpeg);

    QRImage.ImageUrl = "img.jpg";
    }
    }
    }


Sign In to post your comments