Spire.Barcode is a professional barcode library specially designed for .NET developers (C#, VB.NET, ASP.NET, .NET Core) and Java developers (J2SE and J2EE) to generate, read and scan 1D & 2D barcodes.

Thu Apr 23, 2020 7:04 am

Hi,

How can we set QR code Image height and width ?

I am setting image height width but its giving only default size of QRcode

settings.Type = BarCodeType.QRCode;
settings.Unit = GraphicsUnit.Pixel;

settings.X = Convert.ToInt64(txtHeight.Text);
settings.Y = Convert.ToInt64(txtWidth.Text);

settings.ImageHeight = Convert.ToInt64( txtHeight.Text);
settings.ImageWidth = Convert.ToInt64(txtWidth.Text);

Thanks

meenakshi
 
Posts: 8
Joined: Thu Mar 05, 2020 1:02 pm

Thu Apr 23, 2020 9:36 am

Hello,

Thanks for your inquiry.
Please set the AutoResize property to false. If there is still any question, please provide your desired output for further investigation.
Code: Select all
   settings.AutoResize = false;

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Fri Apr 24, 2020 7:11 am

Hi,
Thanks for your replay.
I need QRCode generated height and width dynamically set. Means user can set size to 4052*2034 or 200*200 its is upto the user.
For that in code i set below code, but is not working. QRcode image is not generated as expected size.

settings.Unit = GraphicsUnit.Pixel;
settings.AutoResize = false;

settings.ImageHeight = Convert.ToInt64( txtHeight.Text);
settings.ImageWidth = Convert.ToInt64(txtWidth.Text);

Thanks

meenakshi
 
Posts: 8
Joined: Thu Mar 05, 2020 1:02 pm

Fri Apr 24, 2020 8:32 am

Hello,

Thanks for your reply.
Kindly note that the property ImageHeight and ImageWidth are used to set the image size, and settings.X and settings.Y are used to set the barcode width and height in the image. If you want to control both image size and barcode bar model size, please set the BarcodeSettings like the following code. And attached is the output I got with the Free Spire.BarCode for .NET Version:2.3.
Code: Select all
    BarcodeSettings settings = new BarcodeSettings();
    settings.Data2D = "12345";
    settings.Type = BarCodeType.QRCode;
    settings.Unit = GraphicsUnit.Pixel;
    settings.AutoResize = false;
    //4052*2034
    //settings.X = 70f;
    //settings.Y = 70f;
    //settings.ImageWidth = Convert.ToInt64(4052);
    //settings.ImageHeight = Convert.ToInt64(2034);
    //200*200
    settings.X = 8f;
    settings.Y = 8f;
    settings.ImageWidth = Convert.ToInt64(200);
    settings.ImageHeight = Convert.ToInt64(200);
    BarCodeGenerator bg = new BarCodeGenerator(settings);
    bg.GenerateImage().Save("QRCode_200_200.png");


If there is still any question, please provide your output image for further investigation.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Fri Apr 24, 2020 11:02 am

Hi,

Thanks for your quick reply. It helps.

Just want to ask what is the standard size of X and Y for QR. Which is easily scan able.

and how X and Y calculated. What is 70F?

Thanks in advance

meenakshi
 
Posts: 8
Joined: Thu Mar 05, 2020 1:02 pm

Sun Apr 26, 2020 8:51 am

Hello,

Thanks for your response.
There is no standard size of X and Y, the default values set internally in our products are: X=0.6 millimeter, Y=2 millimeter. You could the appropriate X and Y values according to the size of the image. When setting 4052 for image width and 2034 for for image height, I used 70f for the measure of the narrowest bar, the effect like the attached picture. If there is still any doubt, just feel free to contact us.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.BarCode