如何更改QR图像尺寸?

时间:2016-09-17 15:11:39

标签: java netbeans-8

我想知道如何更改QR码图片尺寸?这是我的代码。它创建QR码但很小。

    String Cus_Name = (String) cmbCus_NameAdd.getSelectedItem();
    String Cus_Id = lblCus_IDAdd2.getText();
    String Odr_No = lblOrderNoAdd2.getText();
    String Matir = lblMeterialAdd2.getText();
    String amount = txtNoOfProductAdd.getText();
    String date = lblDateAdd2.getText();
    String time = lblTimeAdd2.getText();
    String place = (String) cmbPlaceAdd.getSelectedItem();

    String newLine = System.getProperty("line.separator");
    String Details = "Customer Name - " + Cus_Name + "" + newLine + " Customer ID - " + Cus_Id + "" + newLine + " Order No - " + Odr_No + "" + newLine + " Material - " + Matir + "" + newLine + " Amount - " + amount + "" + newLine + " Date - " + date + "" + newLine + " Time - " + time + "" + newLine + " Place - " + place + "";

    ByteArrayOutputStream out = QRCode.from(Details).to(ImageType.JPG).stream(); // this line creates QR code
    File f = new File("C:\\Users\\Pulasthi Dinusha\\Desktop\\MainGui\\lib\\QR_Generator_Libs\\" + Odr_No + ".jpg");
    FileOutputStream fos;
    try {
        fos = new FileOutputStream(f);
        fos.write(out.toByteArray());
        fos.flush();

    } catch (FileNotFoundException ex) {
        Logger.getLogger(test2.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(test2.class.getName()).log(Level.SEVERE, null, ex);
    }
    ImageIcon iconLogo = new ImageIcon("C:\\Users\\Pulasthi Dinusha\\Desktop\\MainGui\\lib\\QR_Generator_Libs\\" + Odr_No + ".jpg");
    // In init() method write this code
    lblQRcodeAdd.setIcon(iconLogo);

1 个答案:

答案 0 :(得分:0)

我的QR图像尺寸调整解决方案

#include<iostream>
#include<stdio.h>
#include<vector>
#include<utility>
using namespace std;

typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
vvii AdjList(1000);


int main()
{
    ii val;
    val.first=4,val.second=10;
    AdjList[0].push_back(val);
    cout<<AdjList[0][0].first;
    return 0;
}