
Lightweight, flexible barcode generation library supporting multiple formats like QR, UPC, and EAN. Offers high customization, scalable vector graphics, and export to PNG, JPEG, and WEBP formats.
Barcode generation library for Compose Multiplatform
Why QRose?
compose.ui;QR, UPC, EAN, Code 128/93/39, Codabar, ITF.dependencies {
// For QR codes
implementation("io.github.alexzhirkevich:qrose:<latest_version>")
// For single-dimension barcodes (UPC,EAN, Code128, ...)
implementation("io.github.alexzhirkevich:qrose-oned:<latest_version>")
}You can create code right in composition using rememberQrCodePainter, rememberBarcodePainter.
Or use QrCodePainter, BarcodePainter to create it outside of Compose.
Image(
painter = rememberQrCodePainter("https://example.com"),
contentDescription = "QR code referring to the example.com website"
)
Image(
painter = rememberBarcodePainter("9780201379624", BarcodeType.EAN13),
contentDescription = "EAN barcode for some product"
)QR codes have flexible styling options, for example:
val qrcodePainter = rememberQrCodePainter(
data = "https://example.com",
ballShape = QrBallShape.circle(),
darkPixelShape = QrPixelShape.roundCorners(),
frameShape = QrFrameShape.roundCorners(.25f),
darkBrush = QrBrush.brush {
Brush.linearGradient(
0f to Color.Red,
1f to Color.Blue,
end = Offset(it, it)
)
},
frameBrush = QrBrush.solid(Color.Black),
logoPainter = rememberQrCodePainter("123"),
logoPadding = QrLogoPadding.Natural(.1f),
logoShape = QrLogoShape.circle(),
logoSize = 0.2f,
)Or with DSL constructor:
val logoPainter : Painter = painterResource("logo.png")
val qrcodePainter : Painter = rememberQrCodePainter("https://example.com") {
logo {
painter = logoPainter
padding = QrLogoPadding.Natural(.1f)
shape = QrLogoShape.circle()
size = 0.2f
}
shapes {
ball = QrBallShape.circle()
darkPixel = QrPixelShape.roundCorners()
frame = QrFrameShape.roundCorners(.25f)
}
colors {
dark = QrBrush.brush {
Brush.linearGradient(
0f to Color.Red,
1f to Color.Blue,
end = Offset(it, it)
)
}
frame = QrBrush.solid(Color.Black)
}
}You can create your own shapes for each QR code part, for example:
class MyCircleBallShape : QrBallShape {
override fun Path.path(size: Float, neighbors: Neighbors): Path = apply {
addOval(Rect(0f,0f, size, size))
}
}Note A path here uses
PathFillType.EvenOddthat cannot be changed.
QR codes can hold various payload types: Text, Wi-Fi, E-mail, vCard, etc.
QrData object can be used to perform such encodings, for example:
val wifiData : String = QrData.wifi(ssid = "My Network", psk = "12345678")
val wifiCode = rememberQrCodePainter(wifiData)QR codes can be exported to PNG, JPEG and WEBP formats using toByteArray function:
val painter : Painter = QrCodePainter(
data = "https://example.com",
options = QrOptions {
colors {
//...
}
}
)
val bytes : ByteArray = painter.toByteArray(1024, 1024, ImageFormat.PNG)Barcode generation library for Compose Multiplatform
Why QRose?
compose.ui;QR, UPC, EAN, Code 128/93/39, Codabar, ITF.dependencies {
// For QR codes
implementation("io.github.alexzhirkevich:qrose:<latest_version>")
// For single-dimension barcodes (UPC,EAN, Code128, ...)
implementation("io.github.alexzhirkevich:qrose-oned:<latest_version>")
}You can create code right in composition using rememberQrCodePainter, rememberBarcodePainter.
Or use QrCodePainter, BarcodePainter to create it outside of Compose.
Image(
painter = rememberQrCodePainter("https://example.com"),
contentDescription = "QR code referring to the example.com website"
)
Image(
painter = rememberBarcodePainter("9780201379624", BarcodeType.EAN13),
contentDescription = "EAN barcode for some product"
)QR codes have flexible styling options, for example:
val qrcodePainter = rememberQrCodePainter(
data = "https://example.com",
ballShape = QrBallShape.circle(),
darkPixelShape = QrPixelShape.roundCorners(),
frameShape = QrFrameShape.roundCorners(.25f),
darkBrush = QrBrush.brush {
Brush.linearGradient(
0f to Color.Red,
1f to Color.Blue,
end = Offset(it, it)
)
},
frameBrush = QrBrush.solid(Color.Black),
logoPainter = rememberQrCodePainter("123"),
logoPadding = QrLogoPadding.Natural(.1f),
logoShape = QrLogoShape.circle(),
logoSize = 0.2f,
)Or with DSL constructor:
val logoPainter : Painter = painterResource("logo.png")
val qrcodePainter : Painter = rememberQrCodePainter("https://example.com") {
logo {
painter = logoPainter
padding = QrLogoPadding.Natural(.1f)
shape = QrLogoShape.circle()
size = 0.2f
}
shapes {
ball = QrBallShape.circle()
darkPixel = QrPixelShape.roundCorners()
frame = QrFrameShape.roundCorners(.25f)
}
colors {
dark = QrBrush.brush {
Brush.linearGradient(
0f to Color.Red,
1f to Color.Blue,
end = Offset(it, it)
)
}
frame = QrBrush.solid(Color.Black)
}
}You can create your own shapes for each QR code part, for example:
class MyCircleBallShape : QrBallShape {
override fun Path.path(size: Float, neighbors: Neighbors): Path = apply {
addOval(Rect(0f,0f, size, size))
}
}Note A path here uses
PathFillType.EvenOddthat cannot be changed.
QR codes can hold various payload types: Text, Wi-Fi, E-mail, vCard, etc.
QrData object can be used to perform such encodings, for example:
val wifiData : String = QrData.wifi(ssid = "My Network", psk = "12345678")
val wifiCode = rememberQrCodePainter(wifiData)QR codes can be exported to PNG, JPEG and WEBP formats using toByteArray function:
val painter : Painter = QrCodePainter(
data = "https://example.com",
options = QrOptions {
colors {
//...
}
}
)
val bytes : ByteArray = painter.toByteArray(1024, 1024, ImageFormat.PNG)