Removed unused QrCodeGenerator
This commit is contained in:
parent
d2dd5389ea
commit
688a156f52
|
@ -65,7 +65,7 @@ kotlin {
|
||||||
|
|
||||||
val jvmMain by getting {
|
val jvmMain by getting {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("com.google.zxing:javase:3.4.1")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val jvmTest by getting {
|
val jvmTest by getting {
|
||||||
|
|
|
@ -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
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -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")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue