当前位置: 首页>>代码示例>>Java>>正文


Java QRCode类代码示例

本文整理汇总了Java中net.glxn.qrgen.QRCode的典型用法代码示例。如果您正苦于以下问题:Java QRCode类的具体用法?Java QRCode怎么用?Java QRCode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


QRCode类属于net.glxn.qrgen包,在下文中一共展示了QRCode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showQRCode

import net.glxn.qrgen.QRCode; //导入依赖的package包/类
@FXML
protected void showQRCode(MouseEvent event) {
    // Serialize to PNG and back into an image. Pretty lame but it's the shortest code to write and I'm feeling
    // lazy tonight.
    final byte[] imageBytes = QRCode
            .from(uri())
            .withSize(320, 240)
            .to(ImageType.PNG)
            .stream()
            .toByteArray();
    Image qrImage = new Image(new ByteArrayInputStream(imageBytes));
    ImageView view = new ImageView(qrImage);
    view.setEffect(new DropShadow());
    // Embed the image in a pane to ensure the drop-shadow interacts with the fade nicely, otherwise it looks weird.
    // Then fix the width/height to stop it expanding to fill the parent, which would result in the image being
    // non-centered on the screen. Finally fade/blur it in.
    Pane pane = new Pane(view);
    pane.setMaxSize(qrImage.getWidth(), qrImage.getHeight());
    final Main.OverlayUI<ClickableBitcoinAddress> overlay = Main.instance.overlayUI(pane, this);
    view.setOnMouseClicked(event1 -> overlay.done());
}
 
开发者ID:creativechain,项目名称:creacoinj,代码行数:22,代码来源:ClickableBitcoinAddress.java

示例2: doGet

import net.glxn.qrgen.QRCode; //导入依赖的package包/类
protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
  TwoFactorServlet.preventCaching(response);
  String username = request.getParameter("username");
  String secret = request.getParameter("secret");

  String pic = makeTotpUrl(ISSUER, username, secret);
  ByteArrayOutputStream qrImageOutput = QRCode.from(pic).to(ImageType.PNG)
      .stream();
  response.setContentType("image/png");
  response.setContentLength(qrImageOutput.size());
  OutputStream outStream = response.getOutputStream();
  outStream.write(qrImageOutput.toByteArray());
  outStream.flush();
  outStream.close();
}
 
开发者ID:WeAreWizards,项目名称:passopolis-server,代码行数:17,代码来源:QRGenerator.java

示例3: getQrCode

import net.glxn.qrgen.QRCode; //导入依赖的package包/类
/**
 * Creates a QR code from any content.
 * 
 * @param content
 *            The content that should be presented as a QR code. This field must 
 *            not be null.
 * @return QrCode as download.
 */
@GET
@Path("/{content}")
public Response getQrCode(@PathParam("content") String content) {
	LOGGER.debug("GetQrCode called");

	// create QRCode from "content"
	ByteArrayOutputStream out = QRCode.from(content).to(ImageType.PNG).stream();

	// return QRCode as image
	ResponseBuilder response = Response.ok(out.toByteArray()); // convert to
																// byte
																// array
	response.header("Content-Disposition", "attachment; filename=test.png"); // file
																				// name
																				// of
																				// image
	return response.build();
}
 
开发者ID:InteractiveSystemsGroup,项目名称:GamificationEngine-Kinben,代码行数:27,代码来源:QrApi.java

示例4: QRCodeWindow

import net.glxn.qrgen.QRCode; //导入依赖的package包/类
public QRCodeWindow(String bitcoinURI) {
    this.bitcoinURI = bitcoinURI;
    final byte[] imageBytes = QRCode
            .from(bitcoinURI)
            .withSize(250, 250)
            .to(ImageType.PNG)
            .stream()
            .toByteArray();
    Image qrImage = new Image(new ByteArrayInputStream(imageBytes));
    qrCodeImageView = new ImageView(qrImage);

    type = Type.Information;
    width = 400;
    headLine(Res.get("qRCodeWindow.headline"));
    message(Res.get("qRCodeWindow.msg"));
}
 
开发者ID:bisq-network,项目名称:exchange,代码行数:17,代码来源:QRCodeWindow.java

示例5: displayQRImage

import net.glxn.qrgen.QRCode; //导入依赖的package包/类
/**
 * Show the QR Code for the IP
 * 
 * @param ip an IP
 */
private void displayQRImage(String ip) {
	// Dispose of the old image
	clearQRImage();
	
	// Generate QRCode
	ByteArrayOutputStream stream = new ByteArrayOutputStream();
	QRCode.from(ip).to(ImageType.PNG).withSize(250, 250).writeTo(stream);
	ByteArrayInputStream input = new ByteArrayInputStream(stream.toByteArray());
	
	// Generate Image and Show it
	if(getQRCodeLabel().getImage() != null) { getQRCodeLabel().getImage().dispose(); }
	Image img = new Image(getMainDisplay(), input);
	getQRCodeLabel().setImage(img);
	getQRCodeLabel().setToolTipText("QR for: " + ip);
	getWindowShell().pack();		
}
 
开发者ID:Kenishi,项目名称:DroidNavi,代码行数:22,代码来源:PairingWindow.java

示例6: showQRCode

import net.glxn.qrgen.QRCode; //导入依赖的package包/类
@FXML
protected void showQRCode(MouseEvent event) {
    // Serialize to PNG and back into an image. Pretty lame but it's the shortest code to write and I'm feeling
    // lazy tonight.
    final byte[] imageBytes = QRCode
            .from(uri())
            .withSize(320, 240)
            .to(ImageType.PNG)
            .stream()
            .toByteArray();
    Image qrImage = new Image(new ByteArrayInputStream(imageBytes));
    ImageView view = new ImageView(qrImage);
    view.setEffect(new DropShadow());
    // Embed the image in a pane to ensure the drop-shadow interacts with the fade nicely, otherwise it looks weird.
    // Then fix the width/height to stop it expanding to fill the parent, which would result in the image being
    // non-centered on the screen. Finally fade/blur it in.
    Pane pane = new Pane(view);
    pane.setMaxSize(qrImage.getWidth(), qrImage.getHeight());
    final Main.OverlayUI<ClickableNuBitsAddress> overlay = Main.instance.overlayUI(pane, this);
    view.setOnMouseClicked(event1 -> overlay.done());
}
 
开发者ID:Cybnate,项目名称:NuBitsj,代码行数:22,代码来源:ClickableNuBitsAddress.java

示例7: generateQrCode

import net.glxn.qrgen.QRCode; //导入依赖的package包/类
/**
 * Generates the QR code.
 */
private void generateQrCode() {
	// Get the text
	String text = this.getQRCodeContent();
	
	// Generate QR code to output stream.
	ByteArrayOutputStream output = new ByteArrayOutputStream();
	QRCode.from(text).to(ImageType.PNG).writeTo(output);
	
	// Create BufferedImage from input stream.
	byte[] data = output.toByteArray();
	ByteArrayInputStream input = new ByteArrayInputStream(data);
	BufferedImage image = null;
	try {
		image = ImageIO.read(input);
	} catch (IOException e) {
		Logger.error(e);
	}
	this.qrCode = image;
}
 
开发者ID:matthiasplappert,项目名称:Cryptographics,代码行数:23,代码来源:AbstractVisualizationInfo.java

示例8: update

import net.glxn.qrgen.QRCode; //导入依赖的package包/类
public void update () {

        PaymentRequest paymentRequest = Main.thunderContext.receivePayment(getAmount());

        try {

            byte[] payload = paymentRequest.getPayload();

            FieldAddress.setText(Tools.bytesToHex(payload));
            FieldHash.setText(Tools.bytesToHex(paymentRequest.paymentSecret.hash));

            System.out.println(Tools.bytesToHex(payload));

            final byte[] imageBytes = QRCode
                    .from(Tools.bytesToHex(payload))
                    .withSize(250, 250)
                    .to(ImageType.PNG)
                    .stream()
                    .toByteArray();

            Image qrImage = new Image(new ByteArrayInputStream(imageBytes));
            ImageQR.setImage(qrImage);
            ImageQR.setEffect(new DropShadow());

            StringSelection stringSelection = new StringSelection(Tools.bytesToHex(payload));
            Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
            clpbrd.setContents(stringSelection, null);

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
 
开发者ID:blockchain,项目名称:thunder,代码行数:34,代码来源:ReceiveMoneyRequestController.java

示例9: update

import net.glxn.qrgen.QRCode; //导入依赖的package包/类
public void update () {

        System.out.println(Tools.bytesToHex(Main.node.pubKeyServer.getPubKey()));

        if (secret == null) {
            secret = new PaymentSecret(Tools.getRandomByte(20));
            Main.dbHandler.addPaymentSecret(secret);
            System.out.println("HASH: "+Tools.bytesToHex(secret.hash));
        }

        try {

            byte[] payload = getPayload();

            FieldAddress.setText(Tools.bytesToHex(payload));
            FieldHash.setText(Tools.bytesToHex(secret.hash));

            System.out.println(Tools.bytesToHex(payload));

            final byte[] imageBytes = QRCode
                    .from(Tools.bytesToHex(payload))
                    .withSize(250, 250)
                    .to(ImageType.PNG)
                    .stream()
                    .toByteArray();

            Image qrImage = new Image(new ByteArrayInputStream(imageBytes));
            ImageQR.setImage(qrImage);
            ImageQR.setEffect(new DropShadow());

            StringSelection stringSelection = new StringSelection(Tools.bytesToHex(payload));
            Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
            clpbrd.setContents(stringSelection, null);

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
 
开发者ID:matsjj,项目名称:thundernetwork,代码行数:40,代码来源:ReceiveMoneyRequestController.java

示例10: generateAdressQRCodeImage

import net.glxn.qrgen.QRCode; //导入依赖的package包/类
/**
 * Generates a byte array representation of QRCode image for a given btc address
 * @param coinAddress
 * @return
 */
public byte[] generateAdressQRCodeImage(String coinAddress) throws OpenTipBotServiceException {
    try {
        logger.debug("Generating QR Code pic for address " + coinAddress);
        ByteArrayOutputStream out = QRCode.from(coinAddress).to(ImageType.PNG).stream();

        return out.toByteArray();

    } catch (Exception e){
        logger.error("Failed to generate QR code pic");
        throw new BitcoinServiceException(env.getProperty("opentipbot.errors.bitcoin.invalid.address"), e);
    }
}
 
开发者ID:gill3s,项目名称:opentipbot,代码行数:18,代码来源:BitcoinService.java

示例11: updateQRCode

import net.glxn.qrgen.QRCode; //导入依赖的package包/类
private void updateQRCode() {
    if (addressTextField.getAddress() != null && !addressTextField.getAddress().isEmpty()) {
        final byte[] imageBytes = QRCode
                .from(getBitcoinURI())
                .withSize(150, 150) // code has 41 elements 8 px is border with 150 we get 3x scale and min. border
                .to(ImageType.PNG)
                .stream()
                .toByteArray();
        Image qrImage = new Image(new ByteArrayInputStream(imageBytes));
        qrCodeImageView.setImage(qrImage);
    }
}
 
开发者ID:bisq-network,项目名称:exchange,代码行数:13,代码来源:DepositView.java

示例12: createQRCode

import net.glxn.qrgen.QRCode; //导入依赖的package包/类
/**
 * 
 * @param qrCodeData
 * @param qrCodeheight
 * @param qrCodewidth
 */
public byte[] createQRCode(String qrCodeData, int qrCodeheight,  int qrCodewidth) {
	byte[] imageBytes = QRCode
       .from(qrCodeData)
       .withSize(qrCodewidth, qrCodeheight)
       .to(ImageType.PNG)
       .stream()
       .toByteArray();
	return imageBytes;
}
 
开发者ID:BitcoinAuthenticator,项目名称:Wallet,代码行数:16,代码来源:PairingQRCode.java

示例13: createQRSSSImageBytes

import net.glxn.qrgen.QRCode; //导入依赖的package包/类
public byte[] createQRSSSImageBytes(Share share, long creationTime, int w, int h){
	byte[] imageBytes = null;
	imageBytes = QRCode
			        .from(generateQRDataString(share, creationTime))
			        .withSize(w, h)
			        .to(ImageType.PNG)
			        .stream()
			        .toByteArray();
       return imageBytes;
}
 
开发者ID:BitcoinAuthenticator,项目名称:Wallet,代码行数:11,代码来源:PaperSSSQR.java

示例14: createQRSeedImageBytes

import net.glxn.qrgen.QRCode; //导入依赖的package包/类
public byte[] createQRSeedImageBytes(DeterministicSeed seed, long creationTime, int w, int h){
	byte[] imageBytes = null;
	imageBytes = QRCode
			        .from(generateQRSeedDataString(seed, creationTime))
			        .withSize(w, h)
			        .to(ImageType.PNG)
			        .stream()
			        .toByteArray();
       return imageBytes;
}
 
开发者ID:BitcoinAuthenticator,项目名称:Wallet,代码行数:11,代码来源:PaperWalletQR.java

示例15: createMnemonicStringImage

import net.glxn.qrgen.QRCode; //导入依赖的package包/类
private Image createMnemonicStringImage(String mnemonic, DeterministicSeed seed){
	byte[] imageBytes = null;
	DeterministicKey mprivkey = HDKeyDerivation.createMasterPrivateKey(seed.getSecretBytes());
       DeterministicKey mpubkey = mprivkey.getPubOnly();
       imageBytes = QRCode
		        .from(mpubkey.toString())
		        .withSize(120, 120)
		        .to(ImageType.PNG)
		        .stream()
		        .toByteArray();
       Image qrMPubKey = new Image(new ByteArrayInputStream(imageBytes));
       return qrMPubKey;
}
 
开发者ID:BitcoinAuthenticator,项目名称:Wallet,代码行数:14,代码来源:PaperWalletQR.java


注:本文中的net.glxn.qrgen.QRCode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。