Removed unused QrCodeGenerator

This commit is contained in:
dankito 2022-03-13 23:45:13 +01:00
parent d2dd5389ea
commit 688a156f52
3 changed files with 1 additions and 51 deletions

View File

@ -65,7 +65,7 @@ kotlin {
val jvmMain by getting {
dependencies {
implementation("com.google.zxing:javase:3.4.1")
}
}
val jvmTest by getting {

View File

@ -1,16 +0,0 @@
package net.codinux.banking.epcqrcode
open class EncodeToQrCodeConfig(
open val width: Int = DefaultWidth,
open val height: Int = DefaultHeight,
open val format: ImageFormat = ImageFormat.PNG,
open val encoding: EpcQrCodeCharacterSet = EpcQrCodeCharacterSet.UTF_8
) {
companion object {
const val DefaultWidth = 350
const val DefaultHeight = 350
}
}

View File

@ -1,34 +0,0 @@
package net.codinux.banking.epcqrcode
import com.google.zxing.BarcodeFormat
import com.google.zxing.EncodeHintType
import com.google.zxing.client.j2se.MatrixToImageWriter
import com.google.zxing.qrcode.QRCodeWriter
import java.io.ByteArrayOutputStream
class QrCodeGenerator {
fun generateQrCode(informationToEncode: String, config: EncodeToQrCodeConfig = EncodeToQrCodeConfig()): ByteArray {
val hints = mutableMapOf<EncodeHintType, Any>()
hints[EncodeHintType.CHARACTER_SET] = map(config.encoding)
val bitMatrix = QRCodeWriter().encode(informationToEncode, BarcodeFormat.QR_CODE, config.width, config.height, hints)
val outputStream = ByteArrayOutputStream()
MatrixToImageWriter.writeToStream(bitMatrix, config.format.name, outputStream)
outputStream.flush()
return outputStream.toByteArray()
}
private fun map(encoding: EpcQrCodeCharacterSet): String {
return when (encoding) {
EpcQrCodeCharacterSet.UTF_8 -> "UTF8"
else -> encoding.name.replace("ISO_8859", "ISO8859")
}
}
}