add background color #7
idrisalshikh
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
You can create a wrapper painter with bg color for exporting class WrapperPainter(
private val painter: Painter,
private val background : Color,
) : Painter() {
override val intrinsicSize: Size
get() = painter.intrinsicSize
override fun DrawScope.onDraw() {
drawRect(background)
painter.run {
draw(size)
}
}
} I will add background option for convenience in the next version. Follow #8 for updates |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've tried to change the background color without success, and I believe this is very important. By default, the QR code color is black, and the background color is determined by the surface where the QR image is displayed. If our design uses a black background, the generated image will be entirely black, making the QR code invisible.
In our application, we can resolve this by changing the background of our container that displays the image. However, the real issue arises when we need to share or save the image as a JPEG. In JPEG format, there is no transparency, so the generated image will have a black background. Since the default QR code color is black, we end up with an all-black image again.
When saving the image in PNG format, I encountered a problem when trying to share the image on WhatsApp; it still appears as a black image. Even if I change the QR code colors to:
colors {
dark = QrBrush.solid(Color.Blue)
frame = QrBrush.solid(Color.Blue)
light = QrBrush.solid(Color.Red)
ball = QrBrush.solid(Color.Blue)
}
The image still shows a white background (which represents my application's background color). When I share this image, it looks different because the background changes.
As a result, it would be beneficial if we could control the background color of the QR image directly and add an outer border to ensure consistency across different platforms and formats.
Beta Was this translation helpful? Give feedback.
All reactions