Create QR code image of same size

Yugank Narula 0 Reputation points
2024-03-01T13:41:45.8566667+00:00

Hi,

I have qr code data of different size & qr code versions are also different respective of data size.

Is it possible to print/create all QR code image of same size(height & width)?

I tried setting height & width in encoding options but it's not working.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,369 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,237 questions
{count} votes

1 answer

Sort by: Most helpful
  1. hossein jalilian 2,370 Reputation points
    2024-03-03T02:39:30.13+00:00

    Thanks for posting your question in the Microsoft Q&A forum.

    You can use libraries like ZXing.Net to generate QR codes.

     static Bitmap GenerateQRCode(string data, int width, int height)
        {
            BarcodeWriter barcodeWriter = new BarcodeWriter();         
    		BarcodeWriter.Format = BarcodeFormat.QR_CODE; 
    
            BarcodeWriter.Options = new ZXing.Common.EncodingOptions
            {
                Width = width,
                Height = height,
                Margin = 0 
             };
    
            ZXing.Common.BitMatrix bitMatrix = barcodeWriter.Encode(data);
            Bitmap qrCodeBitmap = barcodeWriter.Write(bitMatrix); 
    
            Bitmap resizedBitmap = new Bitmap(qrCodeBitmap, new Size(width, height));
            return resizedBitmap;
        }
    
    

    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful

    0 comments No comments