Skip to content

Commit ae14e04

Browse files
feat(ecl-auto): New QRCodeGraphicsFactory implementations and examples
1 parent 0e30b4d commit ae14e04

32 files changed

+22
-13
lines changed

examples/android/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ android {
3636
}
3737

3838
dependencies {
39-
implementation("io.github.g0dkar:qrcode-kotlin:4.3.0")
39+
implementation("io.github.g0dkar:qrcode-kotlin:4.4.0")
4040
implementation(libs.core.ktx)
4141
implementation(libs.appcompat)
4242
implementation(libs.material)

examples/java/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ repositories {
88
}
99

1010
dependencies {
11-
implementation("io.github.g0dkar:qrcode-kotlin:4.3.0")
11+
implementation("io.github.g0dkar:qrcode-kotlin:4.4.0")
1212
implementation("org.jfree:org.jfree.svg:5.0.5")
1313
}

examples/java/example01-circles.png

-23.9 KB
Loading
-16.8 KB
Loading

examples/java/example01-custom.png

-27.7 KB
Loading
-25 KB
Loading

examples/java/example01-squares.png

-25.5 KB
Loading

examples/java/example02-color.png

-37.8 KB
Loading

examples/java/example02-dark-mode.png

-27.5 KB
Loading

examples/java/example02-gradient.png

-8.8 KB
Loading

examples/java/example03-circles.svg

+1-1
Loading

examples/java/example03-rounded-squares.svg

+1-1
Loading

examples/java/example03-squares.svg

+1-1
Loading

examples/kotlin/example01-circles.png

-23.9 KB
Loading
-16.8 KB
Loading

examples/kotlin/example01-custom.png

-27.7 KB
Loading
-25 KB
Loading

examples/kotlin/example01-squares.png

-25.5 KB
Loading

examples/kotlin/example02-color.png

-37.8 KB
Loading
-27.5 KB
Loading
-8.8 KB
Loading
-23.4 KB
Loading

examples/kotlin/example03-logo.png

-23.4 KB
Loading

examples/kotlin/example04-circles.svg

+1-1
Loading

examples/kotlin/example04-rounded-squares.svg

+1-1
Loading

examples/kotlin/example04-squares.svg

+1-1
Loading
-28.3 KB
Loading

examples/kotlin/example06-dense.png

904 KB
Loading

examples/kotlin/project-banner.png

-30.3 KB
Loading

examples/kotlin/project-logo.png

-50.9 KB
Loading

examples/kotlin/src/main/kotlin/Example06-ECL.kt

+13-4
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,30 @@ fun main() {
1414

1515
val eclLowQRCode = QRCode.ofSquares()
1616
.withErrorCorrectionLevel(ErrorCorrectionLevel.LOW) // <- See Here
17-
.withInformationDensity(1) // <- Setting this will make the code NOT compute a value
17+
.withInformationDensity(1) // <- Setting this to >= 1 will make the code NOT compute a value
1818
.build(qrCodeData)
1919
.also { println("[Low] ECL: ${it.errorCorrectionLevel}, Information Density: ${it.informationDensity}") }
2020
val eclLowPngData = eclLowQRCode.renderToBytes()
2121

2222
val eclMediumQRCode = QRCode.ofSquares()
2323
.withErrorCorrectionLevel(ErrorCorrectionLevel.MEDIUM) // <- See Here
24-
.withInformationDensity(1) // <- Setting this will make the code NOT compute a value
24+
.withInformationDensity(1) // <- Setting this to >= 1 will make the code NOT compute a value
2525
.build(qrCodeData)
2626
.also { println("[Medium] ECL: ${it.errorCorrectionLevel}, Information Density: ${it.informationDensity}") }
2727
val eclMediumPngData = eclMediumQRCode.renderToBytes()
2828

2929
// ECL High: we need to add +1 to the information density because of the extra data added by the ECL
3030
val eclHighQRCode = QRCode.ofSquares()
3131
.withErrorCorrectionLevel(ErrorCorrectionLevel.HIGH) // <- See Here
32-
.withInformationDensity(2) // <- Setting this will make the code NOT compute a value
32+
.withInformationDensity(2) // <- Setting this to >= 1 will make the code NOT compute a value
3333
.build(qrCodeData)
3434
.also { println("[High] ECL: ${it.errorCorrectionLevel}, Information Density: ${it.informationDensity}") }
3535
val eclHighPngData = eclHighQRCode.renderToBytes()
3636

3737
// ECL Very High: we need to add +1 to the information density because of the extra data added by the ECL
3838
val eclVeryHighQRCode = QRCode.ofSquares()
3939
.withErrorCorrectionLevel(ErrorCorrectionLevel.VERY_HIGH) // <- See Here
40-
.withInformationDensity(2) // <- Setting this will make the code NOT compute a value
40+
.withInformationDensity(2) // <- Setting this to >= 1 will make the code NOT compute a value
4141
.build(qrCodeData)
4242
.also { println("[Very High] ECL: ${it.errorCorrectionLevel}, Information Density: ${it.informationDensity}") }
4343
val eclVeryHighPngData = eclVeryHighQRCode.renderToBytes()
@@ -56,6 +56,14 @@ fun main() {
5656
.also { println("[Default - ECL High] ECL: ${it.errorCorrectionLevel}, Information Density (computed): ${it.informationDensity}") }
5757
val eclDefaultLowPngData = eclDefaultLowQRCode.renderToBytes()
5858

59+
// ECL Very High + Info Density: Using the maximum values to showcase how the QRCode grows given these parameters
60+
val denseQRCode = QRCode.ofSquares()
61+
.withErrorCorrectionLevel(ErrorCorrectionLevel.VERY_HIGH) // <- See Here
62+
.withInformationDensity(40) // <- Maximum value
63+
.build(qrCodeData)
64+
.also { println("[Dense] ECL: ${it.errorCorrectionLevel}, Information Density: ${it.informationDensity}") }
65+
val densePngData = denseQRCode.renderToBytes()
66+
5967
// -----------------------
6068
// JVM-only code (saves the PNG Bytes to a file)
6169
FileOutputStream("examples/kotlin/example06-ecl-low.png").use { it.write(eclLowPngData) }
@@ -64,4 +72,5 @@ fun main() {
6472
FileOutputStream("examples/kotlin/example06-ecl-very-high.png").use { it.write(eclVeryHighPngData) }
6573
FileOutputStream("examples/kotlin/example06-ecl-default.png").use { it.write(eclDefaultPngData) }
6674
FileOutputStream("examples/kotlin/example06-ecl-default-high.png").use { it.write(eclDefaultLowPngData) }
75+
FileOutputStream("examples/kotlin/example06-dense.png").use { it.write(densePngData) }
6776
}

examples/spring-web/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ dependencies {
3232
implementation("org.springframework.boot:spring-boot-starter-actuator")
3333

3434
// QRCode-Kotlin
35-
implementation("io.github.g0dkar:qrcode-kotlin:4.3.0")
35+
implementation("io.github.g0dkar:qrcode-kotlin:4.4.0")
3636

3737
// Tests
3838
// testImplementation("org.springframework.boot:spring-boot-starter-test")

0 commit comments

Comments
 (0)