Created
August 6, 2019 13:27
-
-
Save nimzo6689/83fbd4ad4c24276fe0e8ea24e9ffe6f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'java' | |
group 'com.qiita.nimzo6689' | |
version '1.0-SNAPSHOT' | |
sourceCompatibility = 1.12 | |
compileJava.options.encoding = 'UTF-8' | |
repositories { | |
mavenCentral() | |
maven { | |
url "https://jitpack.io" | |
} | |
} | |
dependencies { | |
compile 'com.github.kenglxn.QRGen:javase:2.6.0' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.qiita.nimzo6689.snippet.qrgen.schema; | |
import net.glxn.qrgen.core.scheme.EMail; | |
import net.glxn.qrgen.javase.QRCode; | |
import java.io.File; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.nio.file.StandardCopyOption; | |
public class QRGenForEmail { | |
public static void main(String[] args) throws Exception { | |
EMail email = EMail.parse("mailto:taro.sato@example.com"); | |
File qrCode = QRCode.from(email).file(); | |
Files.copy(qrCode.toPath(), Paths.get("qrcode.png"), StandardCopyOption.REPLACE_EXISTING); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.qiita.nimzo6689.snippet.qrgen.schema; | |
import net.glxn.qrgen.core.scheme.GeoInfo; | |
import net.glxn.qrgen.javase.QRCode; | |
import java.io.File; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.nio.file.StandardCopyOption; | |
public class QRGenForGeoInfo { | |
public static void main(String[] args) throws Exception { | |
GeoInfo geoInfo = GeoInfo.parse("geo:35.6706094,139.7662781"); | |
File qrCode = QRCode.from(geoInfo).file(); | |
Files.copy(qrCode.toPath(), Paths.get("qrcode.png"), StandardCopyOption.REPLACE_EXISTING); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.qiita.nimzo6689.snippet.qrgen.schema; | |
import net.glxn.qrgen.core.scheme.Url; | |
import net.glxn.qrgen.javase.QRCode; | |
import java.io.File; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.nio.file.StandardCopyOption; | |
public class QRGenForUrl { | |
public static void main(String[] args) throws Exception { | |
Url url = Url.parse("https://qiita.com/nimzo6689"); | |
File qrCode = QRCode.from(url).file(); | |
Files.copy(qrCode.toPath(), Paths.get("qrcode.png"), StandardCopyOption.REPLACE_EXISTING); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.qiita.nimzo6689.snippet.qrgen; | |
import net.glxn.qrgen.javase.QRCode; | |
import java.io.ByteArrayOutputStream; | |
import java.io.OutputStream; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
public class QRGenToBaos { | |
public static void main(String[] args) throws Exception { | |
try (ByteArrayOutputStream qrCode = QRCode.from("https://qiita.com/nimzo6689").stream(); | |
OutputStream outputStream = Files.newOutputStream(Paths.get("qrcode.png"))) { | |
qrCode.writeTo(outputStream); | |
qrCode.flush(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.qiita.nimzo6689.snippet.qrgen; | |
import net.glxn.qrgen.javase.QRCode; | |
import java.io.OutputStream; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
public class QRGenToExistingOs { | |
public static void main(String[] args) throws Exception { | |
try (OutputStream os = Files.newOutputStream(Paths.get("qrcode.png"))) { | |
QRCode.from("https://qiita.com/nimzo6689").writeTo(os); | |
os.flush(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.qiita.nimzo6689.snippet.qrgen; | |
import net.glxn.qrgen.javase.QRCode; | |
import java.io.File; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.nio.file.StandardCopyOption; | |
public class QRGenToFile { | |
public static void main(String[] args) throws Exception { | |
File qrCode = QRCode.from("https://qiita.com/nimzo6689").file(); | |
Files.copy(qrCode.toPath(), Paths.get("qrcode.png"), StandardCopyOption.REPLACE_EXISTING); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.qiita.nimzo6689.snippet.qrgen; | |
import net.glxn.qrgen.javase.QRCode; | |
import java.io.File; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.nio.file.StandardCopyOption; | |
public class QRGenToSvg { | |
public static void main(String[] args) throws Exception { | |
File qrCode = QRCode.from("https://qiita.com/nimzo6689").svg(); | |
Files.copy(qrCode.toPath(), Paths.get("qrcode.svg"), StandardCopyOption.REPLACE_EXISTING); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.qiita.nimzo6689.snippet.qrgen; | |
import com.google.zxing.EncodeHintType; | |
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; | |
import net.glxn.qrgen.core.image.ImageType; | |
import net.glxn.qrgen.javase.QRCode; | |
import java.io.File; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.nio.file.StandardCopyOption; | |
public class QRGenWithHint { | |
public static void main(String[] args) throws Exception { | |
File qrCode = QRCode.from("https://qiita.com/nimzo6689") | |
.to(ImageType.GIF) | |
.withSize(320, 320) | |
.withColor(0xFF6876B4, 0xFFF7F4F7) | |
.withCharset("UTF-8") | |
.withErrorCorrection(ErrorCorrectionLevel.L) | |
.withHint(EncodeHintType.MARGIN, 2) | |
.file(); | |
Files.copy(qrCode.toPath(), Paths.get("qrcode.gif"), StandardCopyOption.REPLACE_EXISTING); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment