本文整理汇总了Java中net.glxn.qrgen.image.ImageType类的典型用法代码示例。如果您正苦于以下问题:Java ImageType类的具体用法?Java ImageType怎么用?Java ImageType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImageType类属于net.glxn.qrgen.image包,在下文中一共展示了ImageType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showQRCode
import net.glxn.qrgen.image.ImageType; //导入依赖的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());
}
示例2: doGet
import net.glxn.qrgen.image.ImageType; //导入依赖的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();
}
示例3: getQrCode
import net.glxn.qrgen.image.ImageType; //导入依赖的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();
}
示例4: QRCodeWindow
import net.glxn.qrgen.image.ImageType; //导入依赖的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"));
}
示例5: displayQRImage
import net.glxn.qrgen.image.ImageType; //导入依赖的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();
}
示例6: showQRCode
import net.glxn.qrgen.image.ImageType; //导入依赖的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());
}
示例7: generateQrCode
import net.glxn.qrgen.image.ImageType; //导入依赖的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;
}
示例8: update
import net.glxn.qrgen.image.ImageType; //导入依赖的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();
}
}
示例9: update
import net.glxn.qrgen.image.ImageType; //导入依赖的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();
}
}
示例10: generateAdressQRCodeImage
import net.glxn.qrgen.image.ImageType; //导入依赖的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);
}
}
示例11: updateQRCode
import net.glxn.qrgen.image.ImageType; //导入依赖的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);
}
}
示例12: createQRCode
import net.glxn.qrgen.image.ImageType; //导入依赖的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;
}
示例13: createQRSSSImageBytes
import net.glxn.qrgen.image.ImageType; //导入依赖的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;
}
示例14: createQRSeedImageBytes
import net.glxn.qrgen.image.ImageType; //导入依赖的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;
}
示例15: createMnemonicStringImage
import net.glxn.qrgen.image.ImageType; //导入依赖的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;
}