Closed pastre closed 2 years ago
For international readers, the question is if it is possible to generate a Bitmap right away instead of writing to a file first. I'll translate the answer at the end as well :)
Opa! Tem sim! Por coincidência eu estava implementando justamente um exemplo com isso em mente!
Dá uma olhada nesse exemplo aqui: https://github.com/g0dkar/qrcode-kotlin/blob/main/examples/android/src/main/java/io/github/g0dkar/qrcode/QRCodeData.kt#L11
Basicamente, o objeto que é retornado quando você chama QRCode(data).render()
, internamente, já tem um Bitmap
(no caso do Android) pronto e você consegue acessar diretamente ele chamando o método nativeImage()
Estou finalizando um app Android de exemplo bem simples que mantém uma lista de QRCodes e os gera dinamicamente, sem salvar arquivos nem nada :)
Hey! There is! As a coincidence I was implementing exactly an example with this in mind!
Take a look at this example here: https://github.com/g0dkar/qrcode-kotlin/blob/main/examples/android/src/main/java/io/github/g0dkar/qrcode/QRCodeData.kt#L11
Basically, the object that is returned when you call QRCode(data).render()
, internally, holds a Bitmap
(in the case of Android) and you can access it directly by calling the nativeImage()
method.
I'm finishing a really simple example Android app that keeps a list of QRCodes and generates the images dynamically, without saving files or anything :)
Updated for international readers
Cool, thanks!
it is possible to generate a Bitmap right away instead of writing to a file first