Add custom image or text to QR code generated by ZXing.Net

前端 未结 2 2035
有刺的猬
有刺的猬 2021-02-03 10:57

I use ZXing.Net library to generate a QR code image -

\"app

At the top of my class:

         


        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-03 11:36

    Since you get a bitmap out of ZXing you can use standard C# techniques to draw text. See this answer for more info:

    c# write text on bitmap

    For posterity here's some shamelessly copied code:

    Bitmap bmp = //from ZXing;
    
    RectangleF rectf = new RectangleF(70, 90, 90, 50);
    
    Graphics g = Graphics.FromImage(bmp);
    
    g.SmoothingMode = SmoothingMode.AntiAlias;
    g.InterpolationMode = InterpolationMode.HighQualityBicubic;
    g.PixelOffsetMode = PixelOffsetMode.HighQuality;
    g.DrawString("yourText", new Font("Tahoma",8), Brushes.Black, rectf);
    
    g.Flush();
    

提交回复
热议问题