Comments (9)
Try this accompanist library to convert drawable to compose painter
from custom-qr-generator.
I try it before write this issue it doesn't work, but i doesnt test it without logo
from custom-qr-generator.
Can you share the image you use for a logo?
from custom-qr-generator.
Cant find svg, xml:
from custom-qr-generator.
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="1000dp" android:height="1000dp" android:viewportWidth="1000" android:viewportHeight="1000"> <path android:pathData="M293.11,553.42h-7.36c-4.49,0 -7.32,-2.16 -8.5,-6.47l-20.31,-73.99c-0.68,-2.62 -0.42,-4.7 0.76,-6.22c1.18,-1.52 3.13,-2.28 5.84,-2.28h8.76c4.48,0 7.28,2.2 8.38,6.6l11.68,46.32l12.18,-46.45c1.18,-4.31 3.98,-6.47 8.38,-6.47h7.23c4.48,0 7.32,2.16 8.5,6.47l12.44,45.82l11.93,-45.69c1.1,-4.4 3.89,-6.6 8.38,-6.6h3.55c2.71,0 4.63,0.76 5.77,2.28c1.14,1.52 1.37,3.6 0.7,6.22l-20.56,73.99c-1.1,4.32 -3.93,6.47 -8.5,6.47h-7.61c-4.57,0 -7.4,-2.16 -8.5,-6.47l-12.44,-45.69l-12.18,45.69C300.51,551.26 297.68,553.42 293.11,553.42z" android:fillColor="#FFFFFF"/> <path android:pathData="M400.35,553.42h-9.52c-5.08,0 -7.61,-2.54 -7.61,-7.61V472.2c0,-5.08 2.54,-7.61 7.61,-7.61h9.52c5.08,0 7.61,2.54 7.61,7.61v73.61C407.96,550.88 405.43,553.42 400.35,553.42z" android:fillColor="#FFFFFF"/> <path android:pathData="M458.85,553.42h-25.76c-5.08,0 -7.61,-2.54 -7.61,-7.61V472.2c0,-5.08 2.54,-7.61 7.61,-7.61h25.76c10.24,0 18.57,2.07 25,6.22c5.84,3.81 10.32,8.99 13.45,15.55c3.13,6.56 4.7,13.98 4.7,22.27c0,18.11 -5.88,31.01 -17.64,38.71C477.85,551.39 469.34,553.42 458.85,553.42zM450.22,482.6v53.18h8.63c6.09,0 10.28,-1.52 12.56,-4.57c3.13,-3.98 4.7,-11.51 4.7,-22.59c0,-10.49 -1.74,-17.85 -5.2,-22.08c-2.37,-2.62 -6.39,-3.93 -12.06,-3.93H450.22z" android:fillColor="#FFFFFF"/> <path android:pathData="M551.75,554.94c-13.12,0 -23.18,-4.14 -30.2,-12.44c-6.94,-8.29 -10.41,-19.59 -10.41,-33.89c0,-13.11 3.68,-23.99 11.04,-32.62c7.53,-8.63 17.39,-12.95 29.57,-12.95c7.61,0 14.4,1.78 20.37,5.33c5.97,3.55 10.43,8.17 13.39,13.83c1.27,2.46 1.27,4.49 0,6.09c-1.27,1.61 -3.34,2.41 -6.22,2.41h-9.14c-1.69,0 -3.05,-0.34 -4.06,-1.02c-1.01,-0.68 -2.28,-1.99 -3.81,-3.93l-0.63,-0.76c-2.37,-2.62 -5.67,-3.93 -9.9,-3.93c-9.82,0 -14.72,9.18 -14.72,27.54c0,8.12 0.84,14.72 2.54,19.8c2.11,5.92 6.18,8.88 12.18,8.88c6.77,0 12.1,-1.9 15.99,-5.71v-9.26h-8.38c-4.57,0 -7.32,-2.24 -8.25,-6.73l-0.76,-3.43c-0.51,-2.62 -0.17,-4.67 1.02,-6.16c1.18,-1.48 3.13,-2.22 5.84,-2.22h24.75c5.08,0 7.62,2.54 7.62,7.61v21.19c0,3.72 -0.63,6.3 -1.9,7.74c-3.72,4.4 -8.72,7.93 -14.98,10.6C566.43,553.61 559.45,554.94 551.75,554.94z" android:fillColor="#FFFFFF"/> <path android:pathData="M661.28,553.42h-50.76c-5.08,0 -7.61,-2.54 -7.61,-7.61V472.2c0,-5.08 2.54,-7.61 7.61,-7.61h48.86c2.62,0 4.53,0.74 5.71,2.22c1.18,1.48 1.52,3.53 1.02,6.16l-0.63,3.3c-0.93,4.49 -3.72,6.73 -8.38,6.73h-29.44v15.99h17.89c5.08,0 7.61,2.54 7.61,7.61v3.43c0,5.08 -2.54,7.61 -7.61,7.61h-17.89v17.26h33.63c5.08,0 7.61,2.54 7.61,7.61v3.3C668.89,550.88 666.35,553.42 661.28,553.42z" android:fillColor="#FFFFFF"/> <path android:pathData="M712.55,553.42h-9.52c-5.08,0 -7.61,-2.54 -7.61,-7.61v-63.58h-16.37c-5.08,0 -7.61,-2.54 -7.61,-7.61v-2.41c0,-5.08 2.54,-7.61 7.61,-7.61h57.36c2.71,0 4.65,0.74 5.84,2.22c1.18,1.48 1.48,3.53 0.89,6.16l-0.51,2.54c-1.02,4.49 -3.81,6.73 -8.38,6.73h-14.09v63.58C720.16,550.88 717.62,553.42 712.55,553.42z" android:fillColor="#FFFFFF"/> <path android:pathData="M415.82,353.71c0,-16.51 -4.21,-28.99 -12.63,-37.44c-8.42,-8.44 -19.73,-12.67 -33.94,-12.67c-13.66,0 -24.83,4.32 -33.53,12.94c-8.7,8.62 -13.04,20.99 -13.04,37.11v84.78h93.14V353.71z" android:fillColor="#FFFFFF"/> <path android:pathData="M677.32,353.65c0,-16.49 -4.21,-28.95 -12.63,-37.39c-8.42,-8.44 -19.73,-12.66 -33.94,-12.66c-13.84,0 -25.06,4.32 -33.66,12.95c-8.6,8.64 -12.91,21.02 -12.91,37.16v84.72h93.14V353.65z" android:fillColor="#FFFFFF"/> <path android:pathData="M559.77,617.53c-16.28,15.21 -36.29,22.8 -60.05,22.8c-24.13,0 -43.87,-7.32 -59.21,-21.96c-11.47,-10.99 -18.94,-24.57 -22.42,-40.75h-94.26c4.3,43.22 20.65,78.58 49.06,106.1c31.98,31.12 74.25,46.67 126.82,46.67c52.93,0 95.76,-15.83 128.49,-47.51c27.93,-27.03 43.94,-62.12 48.04,-105.26h-94.34C578.47,593.65 571.09,606.95 559.77,617.53z" android:fillColor="#FFFFFF"/> </vector>
from custom-qr-generator.
doesnt work with rememberDrawablePainter, image is empty in card
code:
@composable
fun ShowQRJoinCode() {
val context = LocalContext.current
val data = QrData.Text(curSchedule?.JoinCode.toString())
val options = QrVectorOptions.Builder()
.setErrorCorrectionLevel(QrErrorCorrectionLevel.High)
.setColors(
QrVectorColors(
dark = QrVectorColor.Solid(MaterialTheme.colors.secondary.toStandardColor()),
ball = QrVectorColor.Solid(MaterialTheme.colors.secondary.toStandardColor()),
frame = QrVectorColor.Solid(MaterialTheme.colors.primary.toStandardColor())
)
)
.setBackground(QrVectorBackground())
.setShapes(
QrVectorShapes(
darkPixel = QrVectorPixelShape
.RoundCorners(.5f),
ball = QrVectorBallShape.Circle(1f),
frame = QrVectorFrameShape
.RoundCorners(.25f),
)
)
.build()
val qrDrawable = QrCodeDrawable(context, data, options)
Card(
shape = RoundedCornerShape(15.dp),
contentColor = MaterialTheme.colors.background,
backgroundColor = MaterialTheme.colors.background,
border = BorderStroke(1.dp, MaterialTheme.colors.primary),
modifier = Modifier.padding(horizontal = 30.dp, vertical = 0.dp)
) {
Column() {
Image(
painter = rememberDrawablePainter(drawable = qrDrawable),
contentDescription = "qrCode",
modifier = Modifier.padding(30.dp)
)
}
}
}
from custom-qr-generator.
doesnt work with rememberDrawablePainter, image is empty in card
code:
You didn't set up a logo in your last code example
Works as expected with rememberDrawablePainter
.
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
from custom-qr-generator.
If you still have issues with rememberDrawablePainter
you can use AndroidView
AndroidView(
factory = {
ImageView(it)
},
update = {
it.setImageDrawable(code)
}
)
from custom-qr-generator.
From 1.5.5 Drawable
QR codes can be safely converted to Bitmap
and used as Compose ImageBitmap
from custom-qr-generator.
Related Issues (20)
- Add QrVectorPixelShape.Square(size) shape modifier HOT 3
- How to use your library draw QR codes with 3 vertices and circles? Looking forward to your reply HOT 5
- Support the different standard encodings HOT 7
- Expose reserved areas HOT 15
- Customizing QR code after generation HOT 4
- Is the size of the positioning markings adjustable? HOT 4
- How to remove icon and background after choose them HOT 2
- How to custom gradient color and select background, logo from devices HOT 6
- Highlight anchor elements for better recognition seems break in Library version 2.0.0-alpha01 HOT 8
- add jetpack compose support to the library HOT 5
- Any Java samples? HOT 3
- Generated QR not scan-able HOT 6
- I run the app module of this project, and input "123" ,but it can't be scanned by other qr scanner. HOT 4
- [BUG] Documentation and Source Code is not published
- Publish apks on GitHub HOT 2
- [BUG] The code in example is invalid
- overlay image on qrCode HOT 8
- Change background and dots
- Help Implementing HOT 4
- how to store in room database HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from custom-qr-generator.