QRcode size

Technical support for Spire.BarCode.

Moderator: iceblue support

QRcode size

Postby hungnd » Mon Mar 06, 2017 7:43 am

Dear all.
I want create Image QRcode with size (width=75pixel, height=75pixel).
My code:
BarcodeSettings settings = new BarcodeSettings();
settings.Type = BarCodeType.QRCode;
settings.Unit = GraphicsUnit.Pixel;
settings.ShowText = false;
settings.ResolutionType = ResolutionType.Graphics;
//input data
settings.Data = data;


settings.X = 1;
settings.BarHeight = 75;
settings.BorderWidth = 75;
settings.ImageHeight = 75;
settings.ImageWidth = 75;


//set left margin
settings.LeftMargin = 1;
//set right margin
settings.RightMargin = 1;

//set top margin
settings.TopMargin = 1;

//set bottom margin
settings.BottomMargin = 1;

settings.QRCodeECL = QRCodeECL.M;
//generate QR code
BarCodeGenerator generator = new BarCodeGenerator(settings);

Image QRbarcode = generator.GenerateImage();


But after created Image, I get size: int width=QRbarcode.width always=52 pixel, is not 75 pixel.
Please help me.
Thanks you.
hungnd
 
Posts: 6
Joined: Mon Mar 06, 2017 7:37 am

Re: QRcode size

Postby Betsy.jiang » Mon Mar 06, 2017 10:06 am

Dear hungnd,

Thanks for your inquiry.
Here is code to create the QRcode with 75x75 pixel.
Code: Select all
            BarcodeSettings settings = new BarcodeSettings();
            settings.Type = BarCodeType.QRCode;
            settings.Unit = GraphicsUnit.Pixel;
            //the property must be set as false.
            settings.AutoResize = false;
            settings.ShowText = false;
            settings.ResolutionType = ResolutionType.Graphics;
            settings.Data = "12345";       
            settings.X = 3;
            settings.ImageHeight = 74.5f;
            settings.ImageWidth = 74.5f;
            settings.QRCodeECL = QRCodeECL.M;
            BarCodeGenerator generator = new BarCodeGenerator(settings);
            Image QRbarcode = generator.GenerateImage();
            QRbarcode.Save("result3.png");

Hope this can helps, if there is any question, please let me know.

Sincerely,
Betsy
E-iceblue support team
User avatar
Betsy.jiang
 
Posts: 1894
Joined: Tue Sep 06, 2016 8:30 am

Re: QRcode size

Postby hungnd » Wed Mar 08, 2017 10:56 am

Hi support team.
Thanks you so much for reply.
Your support help me fixed problem resize image.
But now I have other following problem:
I set data:
settings.Data=
"102._PJZFWZSxTZYUzg/k1BmR0DuAIKMvJwD/fZ57Mm6dW2I=._ZE7UERiaunvO9pVXUadEZPK2LURMy4mRR4N6Y6tniX63NLa50bq0Z/m
62NAb4+eECPQXG6OcFQQTXIAPjYpTNw=="

But on Image Qrcode just print a part of that data:when I use Qrcode scanner to check, It just show
data ="102._PJZFWZSxTZYUzg/k1BmR0DuAIKMvJwD/fZ57Mm6dW2I=._ZE7UERiaunvO9pVXUadEZPK2LURMy4mRR4N6Y6tniX"


Help me please, how to fix problem lost data?
Thanks so much.
hungnd
 
Posts: 6
Joined: Mon Mar 06, 2017 7:37 am

Re: QRcode size

Postby Betsy.jiang » Thu Mar 09, 2017 6:09 am

Dear hungnd,

Thanks for your feedback.
Sorry that I didn't find the issue with the data on my side. Please provide us the entrie code you used to generate the barcode( if it is different in previous post) and the generated barcode image for testing.

Thanks,
Betsy
E-iceblue support team
User avatar
Betsy.jiang
 
Posts: 1894
Joined: Tue Sep 06, 2016 8:30 am

Re: QRcode size

Postby hungnd » Thu Mar 09, 2017 7:41 am

Hi Support Team.
Thanks for your reply.
My code is full here:
Code: Select all
       public Image CreateQRCode(string data)
        {
            BarcodeSettings.ApplyKey("2N4....");
            BarcodeSettings settings = new BarcodeSettings();
            settings.Type = BarCodeType.QRCode;
            settings.Unit = GraphicsUnit.Pixel;
            settings.ShowText = false;
            settings.ResolutionType = ResolutionType.Graphics;
            //input data
            settings.Data = data;

            settings.X = 2;
            settings.ImageHeight = 100;
            settings.ImageWidth = 100;
            settings.AutoResize = false;
            //set left margin
            settings.LeftMargin = 1;
            //set right margin
            settings.RightMargin = 1;

            //set top margin
                settings.TopMargin = 1;

            //set bottom margin
                settings.BottomMargin = 1;

            //set correction level
            {
                int correctionLevel = 1;
                switch (correctionLevel)
                {
                    case 0:
                        settings.QRCodeECL = QRCodeECL.L;
                        break;
                    case 1:
                        settings.QRCodeECL = QRCodeECL.M;
                        break;
                    case 2:
                        settings.QRCodeECL = QRCodeECL.Q;
                        break;
                    case 3:
                        settings.QRCodeECL = QRCodeECL.H;
                        break;
                }

            }
            //generate QR code
            BarCodeGenerator generator = new BarCodeGenerator(settings);
           
            Image QRbarcode = generator.GenerateImage();

            return QRbarcode;

        }


So I called function:
Code: Select all
CreateQRCode("102._PJZFWZSxTZYUzg/k1BmR0DuAIKMvJwD/fZ57Mm6dW2I=._ZE7UERiaunvO9pVXUadEZPK2LURMy4mRR4N6Y6tniX63NLa50bq0Z/m62NAb4+eECPQXG6OcFQQTXIAPjYpTNw==")

and data is loss.
Help me please.
Thanks so much!
hungnd
 
Posts: 6
Joined: Mon Mar 06, 2017 7:37 am

Re: QRcode size

Postby Betsy.jiang » Thu Mar 09, 2017 8:21 am

Dear hungnd,

Thanks for your information.
Please provide us the barcode image you generated for testing.

Sincerely,
Betsy
E-iceblue support team
User avatar
Betsy.jiang
 
Posts: 1894
Joined: Tue Sep 06, 2016 8:30 am

Re: QRcode size

Postby hungnd » Thu Mar 09, 2017 2:36 pm

Dear Support Team.
My Qrcode image is the file I has attach. Please help me fix problem.
Thanks so much!
You do not have the required permissions to view the files attached to this post.
hungnd
 
Posts: 6
Joined: Mon Mar 06, 2017 7:37 am

Re: QRcode size

Postby Betsy.jiang » Fri Mar 10, 2017 3:18 am

Dear hungnd,

Thanks for the file.
I tested two cases as below, and attached some files for checking.
1)Scan the QRCode I generated using Spire.Barcode and QRcode scanner, both can scan correctly.
2)Scan the QRCode you sent using QRcode scanner(under 100% mode in PDF Reader), it can scan correctly.
So I suppose there is something wrong in the scanner you used.

Sincerely,
Betsy
E-iceblue support team
You do not have the required permissions to view the files attached to this post.
Last edited by Betsy.jiang on Tue Mar 14, 2017 1:30 am, edited 1 time in total.
User avatar
Betsy.jiang
 
Posts: 1894
Joined: Tue Sep 06, 2016 8:30 am

Re: QRcode size

Postby hungnd » Fri Mar 10, 2017 9:29 am

Dear support team.
Thanks so much. I changed scanner and it's work perfectly.
Thanks again.
Regard HungND
hungnd
 
Posts: 6
Joined: Mon Mar 06, 2017 7:37 am

Re: QRcode size

Postby Betsy.jiang » Fri Mar 10, 2017 9:32 am

Dear hungnd,

Thanks for your feedback.
Please feel free to contact us if there is any question, we are here for help :) .

Sincerely,
Betsy
E-iceblue support team
User avatar
Betsy.jiang
 
Posts: 1894
Joined: Tue Sep 06, 2016 8:30 am

Re: QRcode size

Postby hungnd » Wed Mar 15, 2017 11:07 am

Hello support team.
Again I want to you help me fix my problem.
I have function:
Code: Select all
public Image CreateQRCode(string data, float width, float height)
        {
            BarcodeSettings.ApplyKey("2N4........");//you need a key from e-iceblue, otherwise the watermark 'E-iceblue' will be shown in barcode

            BarcodeSettings settings = new BarcodeSettings();
            settings.Type = BarCodeType.QRCode;
            settings.Unit = GraphicsUnit.Pixel;
            settings.ShowText = false;
            settings.ResolutionType = ResolutionType.Graphics;
            //input data
            settings.Data = data;

            settings.AutoResize = false;
            settings.X = 1;
            settings.ImageHeight = height;
            settings.ImageWidth = width;

            //settings.X = 1.5f;
            //settings.ImageHeight = 80;
            //settings.ImageWidth = 80;
            //settings.AutoResize = false;
            //set left margin
            settings.LeftMargin = 1;
            //set right margin
            settings.RightMargin = 1;

            //set top margin
            settings.TopMargin = 1;

            //set bottom margin
            settings.BottomMargin = 1;
            settings.QRCodeECL = QRCodeECL.M;

            }
            //generate QR code
            BarCodeGenerator generator = new BarCodeGenerator(settings);

            Image QRbarcode = generator.GenerateImage();
            return QRbarcode;

        }


When I use 2 functions to change image size:
Code: Select all
 Image qrcode1 = CreateQRCode(data, 80,80)
 Image qrcode2 = CreateQRCode(data, 200,200)

But Why sizes of qrcode1 and qrcode2 is same?
Please help me one more time.
Thanks you so much.
Best regard HungND.
hungnd
 
Posts: 6
Joined: Mon Mar 06, 2017 7:37 am

Re: QRcode size

Postby Betsy.jiang » Thu Mar 16, 2017 6:09 am

Dear HungND,

Thanks for your inquiry.
The property ImageHeight and ImageWidth is to set the image size, and settings.X is to set the barcode width in the image.
With same X value, it will have same size of barcode in image, please change the X value.

Thanks,
Betsy
E-iceblue support team
User avatar
Betsy.jiang
 
Posts: 1894
Joined: Tue Sep 06, 2016 8:30 am


Return to Spire.BarCode

Who is online

Users browsing this forum: No registered users and 0 guests