New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error if set logo #10
Comments
Try this accompanist library to convert drawable to compose painter |
I try it before write this issue it doesn't work, but i doesnt test it without logo |
Can you share the image you use for a logo? |
Cant find svg, xml: |
|
doesnt work with rememberDrawablePainter, image is empty in card code: @composable |
You didn't set up a logo in your last code example Works as expected with val code = QrCodeDrawable(
context,
{ "Hello world" },
createQrVectorOptions {
background {
color = QrVectorColor.Solid(Color.GRAY)
}
errorCorrectionLevel = QrErrorCorrectionLevel.High
logo {
size = .25f
shape = QrVectorLogoShape.Circle
padding = QrVectorLogoPadding.Natural(.05f)
drawable = DrawableSource.Resource(R.drawable.img)
}
}
) Box(modifier = Modifier.fillMaxSize()) {
Image(
modifier = Modifier.size(300.dp)
.align(Alignment.Center),
painter = rememberDrawablePainter (code),
contentDescription = ""
)
} Your logo is white and invisible on white background |
If you still have issues with AndroidView(
factory = {
ImageView(it)
},
update = {
it.setImageDrawable(code)
}
) |
From 1.5.5 |
If i set logo from DrawableSource.Resource it crash my app, if i set DrawableSource.Empty all ok
I convert drawable to bitmap and it throw me error if i set logo
Logs:
java.lang.IllegalArgumentException: width and height must be > 0
at android.graphics.Bitmap.createBitmap(Bitmap.java:1111)
at android.graphics.Bitmap.createBitmap(Bitmap.java:1078)
at android.graphics.Bitmap.createBitmap(Bitmap.java:1028)
at android.graphics.Bitmap.createBitmap(Bitmap.java:989)
at androidx.core.graphics.drawable.DrawableKt.toBitmap(Drawable.kt:68)
at com.github.alexzhirkevich.customqrgenerator.style.BitmapScale$FitXY.scale(BitmapScale.kt:33)
at com.github.alexzhirkevich.customqrgenerator.vector.QrCodeDrawableImpl.resize(QrCodeDrawableImpl.kt:369)
at com.github.alexzhirkevich.customqrgenerator.vector.QrCodeDrawableImpl.setBounds(QrCodeDrawableImpl.kt:128)
at androidx.core.graphics.drawable.DrawableKt.toBitmap(Drawable.kt:72)
at androidx.core.graphics.drawable.DrawableKt.toBitmap$default(Drawable.kt:46)
Code(Jetpack Compose used):
val data = QrData.Text(curSchedule?.JoinCode.toString())
val options = QrVectorOptions.Builder()
.setPadding(.3f)
.setErrorCorrectionLevel(QrErrorCorrectionLevel.High)
.setLogo(
QrVectorLogo(
drawable =drawable,
)
)
.setShapes(
QrVectorShapes(
darkPixel = QrVectorPixelShape
.RoundCorners(.5f),
ball = QrVectorBallShape
.RoundCorners(.25f),
frame = QrVectorFrameShape
.RoundCorners(.25f),
)
)
.build()
val drawable = QrCodeDrawable(context, data, options)
Image(
bitmap = drawable.toBitmap(1024, 1024).asImageBitmap(),
contentDescription = "qrCode",
modifier = Modifier
.fillMaxSize()
)
The text was updated successfully, but these errors were encountered: