本文整理汇总了Java中net.glxn.qrgen.javase.QRCode类的典型用法代码示例。如果您正苦于以下问题:Java QRCode类的具体用法?Java QRCode怎么用?Java QRCode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QRCode类属于net.glxn.qrgen.javase包,在下文中一共展示了QRCode类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: generateQrCode
import net.glxn.qrgen.javase.QRCode; //导入依赖的package包/类
public void generateQrCode() {
if (mResourceLocation != null) {
return;
}
BufferedImage bufferedImage = null;
File imageFile = QRCode.from(mIpAddress).to(ImageType.PNG).withSize(256, 256).file();
try {
bufferedImage = ImageIO.read(imageFile);
} catch (IOException e) {
e.printStackTrace();
}
mResourceLocation = Minecraft.getMinecraft().renderEngine.getDynamicTextureLocation(imageFile.getName(), new DynamicTexture(bufferedImage));
}
开发者ID:RemotecraftProject,项目名称:RemotecraftMod,代码行数:17,代码来源:QrCodeManager.java
示例2: getQrCode
import net.glxn.qrgen.javase.QRCode; //导入依赖的package包/类
public void getQrCode(Consumer<String> callback) {
executor.submit(new Runnable() {
@Override
public void run() {
try {
logger.debug("Creating QR code for provisioning");
temporaryPassword = SecretUtil.getSecret(18);
temporaryIdentity = KeyHelper.generateIdentityKeyPair();
accountManager = new SignalServiceAccountManager(SignalConstants.URL, new ResourceTrustStore(),
null, temporaryPassword, SignalConstants.USER_AGENT);
String uuid = accountManager.getNewDeviceUuid();
String publicKey = Base64.encodeBytesWithoutPadding(temporaryIdentity.getPublicKey().serialize());
String qrString = "tsdevice:/?uuid=" + URLEncoder.encode(uuid, "UTF-8") + "&pub_key="
+ URLEncoder.encode(publicKey, "UTF-8");
logger.debug("Content of qr code: {}", qrString);
String qrCode = QRCode.from(qrString).file().getAbsolutePath();
callback.accept(qrCode);
} catch (IOException | TimeoutException e) {
throw new RuntimeException("Networking error while creating provisioning QR code!", e);
}
}
});
}
开发者ID:Turakar,项目名称:Signal-JDesktop,代码行数:26,代码来源:SignalAccountHelper.java
示例3: makeQRs
import net.glxn.qrgen.javase.QRCode; //导入依赖的package包/类
private QrHolder[] makeQRs(Device[] devices, int dashId, boolean onlyFirst) throws Exception {
QrHolder[] qrHolders;
if (onlyFirst) {
qrHolders = new QrHolder[1];
} else {
qrHolders = new QrHolder[devices.length];
}
List<FlashedToken> flashedTokens = getAllTokens();
int i = 0;
for (Device device : devices) {
if (onlyFirst && i > 0) {
break;
}
String newToken = flashedTokens.get(i).token;
qrHolders[i] = new QrHolder(dashId, device.id, device.name, newToken, QRCode.from(newToken).to(ImageType.JPG).stream().toByteArray());
i++;
}
return qrHolders;
}
开发者ID:blynkkk,项目名称:blynk-server,代码行数:23,代码来源:PublishingPreviewFlow.java
示例4: getQR
import net.glxn.qrgen.javase.QRCode; //导入依赖的package包/类
@GET
@Path("{token}/qr")
@Metric(HTTP_QR)
public Response getQR(@PathParam("token") String token) {
TokenValue tokenValue = tokenManager.getTokenValueByToken(token);
if (tokenValue == null) {
log.debug("Requested token {} not found.", token);
return badRequest("Invalid token.");
}
DashBoard dashBoard = tokenValue.dash;
try {
byte[] compressed = JsonParser.gzipDashRestrictive(dashBoard);
String qrData = "bp1" + Base64.getEncoder().encodeToString(compressed);
byte[] qrDataBinary = QRCode.from(qrData).to(ImageType.PNG).withSize(500, 500).stream().toByteArray();
return ok(qrDataBinary, "image/png");
} catch (Throwable e) {
log.error("Error generating QR. Reason : {}", e.getMessage());
return badRequest("Error generating QR.");
}
}
开发者ID:blynkkk,项目名称:blynk-server,代码行数:24,代码来源:HttpAPILogic.java
示例5: makeQRs
import net.glxn.qrgen.javase.QRCode; //导入依赖的package包/类
private QrHolder[] makeQRs(String username, String appId, DashBoard dash, boolean onlyFirst) throws Exception {
int tokensCount = onlyFirst ? 1 : dash.devices.length;
QrHolder[] qrHolders = new QrHolder[tokensCount];
FlashedToken[] flashedTokens = new FlashedToken[tokensCount];
int i = 0;
for (Device device : dash.devices) {
String newToken = TokenGeneratorUtil.generateNewToken();
qrHolders[i] = new QrHolder(dash.id, device.id, device.name, newToken,
QRCode.from(newToken).to(ImageType.JPG).stream().toByteArray());
flashedTokens[i] = new FlashedToken(username, newToken, appId, dash.id, device.id);
if (onlyFirst) {
break;
}
i++;
}
if (!dbManager.insertFlashedTokens(flashedTokens)) {
throw new Exception("App Publishing Preview requires enabled DB.");
}
return qrHolders;
}
开发者ID:blynkkk,项目名称:blynk-server,代码行数:24,代码来源:MailQRsLogic.java
示例6: main
import net.glxn.qrgen.javase.QRCode; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
String build = new QRSCT()
.serviceTag(QRSCTServiceTagEnum.DEFAULT)
.version(QRSCTVersionEnum.DEFAULT)
.characterSet(QRSCTCharacterSetEnum.DEFAULT)
.bic("BHBLDEHHXXX") //$NON-NLS-1$
.name("Franz Mustermaennchen") //$NON-NLS-1$
.iban("DE71110220330123456789123456789876") //$NON-NLS-1$
.amount(CurrencyCode.EUR, 999999999.11)
.purpose(QRSCTPurposeEnum.DEFAULT)
.reference("egon 123 test : dankeschoen").hint("kein Hinweis") //$NON-NLS-1$ //$NON-NLS-2$
.build();
FileOutputStream fileOutputStream = new FileOutputStream(new File(
"C:/Temp/test.png"));
QRCode.from(build).to(ImageType.PNG).withCharset("UTF-8") //$NON-NLS-1$
.withErrorCorrection(ErrorCorrectionLevel.M)
.writeTo(fileOutputStream); //$NON-NLS-1$
fileOutputStream.close();
}
开发者ID:deltatree,项目名称:qrsct,代码行数:22,代码来源:Example.java
示例7: create
import net.glxn.qrgen.javase.QRCode; //导入依赖的package包/类
public OutputEvent create(InputEvent event) throws MalformedURLException, UnsupportedEncodingException {
ImageType type = getFormat(event.getQueryParameters().get("format").orElse(defaultFormat));
System.err.println("Default format: " + type.toString());
String contents = event.getQueryParameters().get("contents").orElseThrow(() -> new RuntimeException("Contents must be provided to the QR code"));
ByteArrayOutputStream stream = QRCode.from(contents).to(type).stream();
System.err.println("Generated QR Code for contents: " + contents);
return OutputEvent.fromBytes(stream.toByteArray(), OutputEvent.SUCCESS, getMimeType(type));
}
开发者ID:fnproject,项目名称:fdk-java,代码行数:11,代码来源:QRGen.java
示例8: test
import net.glxn.qrgen.javase.QRCode; //导入依赖的package包/类
@Test
public void test() {
try {
FileOutputStream fos = new FileOutputStream(new File("D:\\code.png"));
QRCode.from("weixin://wxpay/bizpayurl?pr=WGFHCgc").to(ImageType.PNG).withSize(500, 500).writeTo(fos);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
开发者ID:laohans,项目名称:swallow-core,代码行数:10,代码来源:QRCodeTest.java
示例9: patch_detail
import net.glxn.qrgen.javase.QRCode; //导入依赖的package包/类
@RequestMapping(value = "/patch",method = RequestMethod.GET)
public ModelAndView patch_detail(HttpServletRequest req,Integer id,String appUid) {
RestResponse restR = new RestResponse();
BizAssert.notNull(id,"参数不能为空");
PatchInfo patchInfo = patchService.findByIdAndAppUid(id,appUid);
if (patchInfo == null) {
throw new BizException("参数不正确");
}
if (patchInfo.getStatus() == PatchInfo.STATUS_UNPUBLISHED) {
String tags = testerService.getAllTags(appUid);
if (!StringUtils.isEmpty(tags)) {
restR.getData().put("tags",tags + ";");
}
}
AppInfo appInfo = appService.findByUid(patchInfo.getAppUid());
VersionInfo versionInfo = appService.findVersionByUidAndVersionName(appInfo,patchInfo.getVersionName());
if (versionInfo == null) {
throw new BizException("该版本未找到: " + patchInfo.getVersionName());
}
BasicUser basicUser = (BasicUser) req.getSession().getAttribute(Constants.SESSION_LOGIN_USER);
List<AppInfo> appInfoList = appService.findAllAppInfoByUser(basicUser);
restR.getData().put("user",basicUser);
restR.getData().put("appInfoList",appInfoList);
restR.getData().put("appInfo",appInfo);
restR.getData().put("versionInfo",versionInfo);
restR.getData().put("patchInfo",patchInfo);
if (StringUtils.isNotBlank(appInfo.getPackageName())) {
ByteArrayOutputStream bos = QRCode.from("ldpv1;" + appInfo.getPackageName() + ";" + versionInfo.getVersionName() + ";" + patchInfo.getPatchVersion() + ";" + patchInfo.getDownloadUrl()).withSize(180, 180).stream();
restR.getData().put("qrcodeImg","data:image/jpeg;base64," + Base64Utils.encodeToString(bos.toByteArray()));
}
return new ModelAndView("patch","restR",restR);
}
开发者ID:baidao,项目名称:tinker-manager,代码行数:34,代码来源:ManagerController.java
示例10: qrCodeAsPng
import net.glxn.qrgen.javase.QRCode; //导入依赖的package包/类
private byte[] qrCodeAsPng(final String baseUrl, final String nickname, final String suffix) {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
QRCode.from(baseUrl + "/devices/" + nickname + suffix).withSize(500, 500).to(ImageType.PNG).writeTo(baos);
final byte[] imageData = baos.toByteArray();
return imageData;
}
开发者ID:PaperCutSoftware,项目名称:dust-api,代码行数:7,代码来源:DeviceResource.java
示例11: createQrGen
import net.glxn.qrgen.javase.QRCode; //导入依赖的package包/类
public static ByteArrayOutputStream createQrGen(String url) throws IOException {
//如果有中文,可以使用withCharset("UTF-8")方法
return QRCode.from(url).withSize(270,270).to(ImageType.JPG).stream();
}
开发者ID:SnackMen,项目名称:DanmuChat,代码行数:6,代码来源:QrGenUtil.java
示例12: generateQR
import net.glxn.qrgen.javase.QRCode; //导入依赖的package包/类
private static void generateQR(String text, Path outputFile) throws Exception {
try (OutputStream out = Files.newOutputStream(outputFile)) {
QRCode.from(text).to(ImageType.JPG).writeTo(out);
}
}
开发者ID:blynkkk,项目名称:blynk-server,代码行数:6,代码来源:FlahsedTokenGenerator.java
示例13: sendMailForStaticProvisioning
import net.glxn.qrgen.javase.QRCode; //导入依赖的package包/类
@Test
@Ignore
public void sendMailForStaticProvisioning() throws Exception {
String body =
"Hi there,<br>\n" +
"<br>\n" +
"Nice app you made with Blynk!<br>\n" +
"<br>\n" +
"Here is what's next:\n" +
"\n" +
"<ul>\n" +
" <li>For Static Provisioning you need to upload Auth Tokens provided in this email to your devices. Tokens are in the attachment.</li>\n" +
"\n" +
" <li>During the provisioning process, device will be connected to your network. You need to scan provided QRs in order to connect your app to devices. Learn <a href=\"http://help.blynk.cc/publishing-apps-made-with-blynk/1240196-provisioning-products-with-auth-tokens/static-auth-token-provisioning\">how Static Device Provisioning works</a>.</li>\n" +
"</ul>\n" +
"\n" +
"<b>If you would like to publish your app to App Store and Google Play, check out our <a href=\"https://www.blynk.io/plans/\">plans</a> and send a request.</b><br>\n" +
"<br>\n" +
"Let’s build a connected world together!<br>\n" +
"<br>\n" +
"--<br>\n" +
"<br>\n" +
"Blynk Team<br>\n" +
"<br>\n" +
"<a href=\"https://www.blynk.io\">blynk.io</a>\n" +
"<br>\n" +
"<a href=\"https://www.blynk.cc\">blynk.cc</a>";
QrHolder[] qrHolders = new QrHolder[] {
new QrHolder(1, 0, "My device", "12345678901", QRCode.from("21321321").to(ImageType.JPG).stream().toByteArray()),
new QrHolder(1, 1, "My device2", "12345678902", QRCode.from("21321321").to(ImageType.JPG).stream().toByteArray())
};
Properties properties = new Properties();
try (InputStream classPath = MailWrapperTest.class.getResourceAsStream("/mail.properties")) {
if (classPath != null) {
properties.load(classPath);
}
}
MailWrapper mailWrapper = new MailWrapper(properties);
mailWrapper.sendWithAttachment("[email protected]", "yo", body, qrHolders);
}
开发者ID:blynkkk,项目名称:blynk-server,代码行数:43,代码来源:MailWrapperTest.java
注:本文中的net.glxn.qrgen.javase.QRCode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论