vlastný qr kód, android, android štúdio
fun getQrCodeBitmap(ssid: String, password: String): Bitmap {
val size = 512 //pixels
val qrCodeContent = "WIFI:S:$ssid;T:WPA;P:$password;;"
val hints = hashMapOf<EncodeHintType, Int>().also { it[EncodeHintType.MARGIN] = 1 } // Make the QR code buffer border narrower
val bits = QRCodeWriter().encode(qrCodeContent, BarcodeFormat.QR_CODE, size, size)
return Bitmap.createBitmap(size, size, Bitmap.Config.RGB_565).also {
for (x in 0 until size) {
for (y in 0 until size) {
it.setPixel(x, y, if (bits[x, y]) Color.BLACK else Color.WHITE)
}
}
}
}