Giter Club home page Giter Club logo

qrcode-kotlin's Introduction

QRCode-Kotlin

License Maven Central

💚 Disponível em Português (Brasil) 💛

QRCode Kotlin Logo

Creating QRCodes in Kotlin (and Java) is harder than it should be. QRCode-Kotlin aims to bring a simple, straightforward and customizable way to create QRCodes, especially in the backend.

It is with this mission in mind that we keep doing our best to learn how developers use this library and their goals so that we can provide a better library/API for them. Please, feel free to share if and how you're using this project ^^

  • Pure Kotlin: Rewritten on pure Kotlin from a reference implementation of the QRCode spec by Kazuhiko Arase
  • Lightweight: No dependencies, ~115KB and it does what it says on the tin.
  • Easy to use: Quickly and easily implement QRCodes with few lines of code.
  • Good-looking: Many developers don't have time and sometimes knowledge to implement the perfect QRCode, so this library tries to generate good-looking QRCodes by default.
  • Server friendly: The JVM version is mainly focused on a personal use-case where I needed to generate QRCodes on the backend, but all libraries I found were either complex or huge, usually both.
  • Multiplatform: This is a KMP library with support to Java, JavaScript, Android, iOS and tvOS.

Table of Contents

1. Installation

The library is available from Maven Central and NPM JS, so you can add it to your project as a dependency like any other:

Gradle:

// Use this for both Android and JVM
implementation("io.github.g0dkar:qrcode-kotlin:4.1.1")

Maven - JVM:

<dependency>
    <groupId>io.github.g0dkar</groupId>
    <artifactId>qrcode-kotlin-jvm</artifactId>
    <version>4.1.1</version>
</dependency>

Maven - Android:

<dependency>
    <groupId>io.github.g0dkar</groupId>
    <artifactId>qrcode-kotlin-android</artifactId>
    <version>4.1.1</version>
</dependency>

NodeJS:

npm install [email protected]

Browser:

<script src="https://cdn.jsdelivr.net/gh/g0dkar/qrcode-kotlin@main/release/qrcode-kotlin.min.js" type="application/javascript"></script>

Usage

To create QRCodes, the main class that should be used is the qrcode.render.QRCode class. It has static methods to help you create a QRCode the way you want:

// Use one of these:

val squares = QRCode.ofSquares()

val circles = QRCode.ofCircles()

val roundedSquares = QRCode.ofRoundedSquares()

With that, you'll have a QRCodeBuilder instance. It has methods to adjust colors, size, spacing, add a logo and more! Also, make sure to check the Colors class as well.

Here's a code to get you started:

val helloWorld = QRCode.ofSquares()
    .withColor(Colors.DEEP_SKY_BLUE) // Default is Colors.BLACK
    .withSize(10) // Default is 25
    .build("Hello world!")

// By default, QRCodes are rendered as PNGs.
val pngBytes = helloWorld.render()

FileOutputStream("hello-world.png").use { it.write(pngBytes) }

We highly recommend that you check out some examples:

The examples show pretty much all that can be done with the library! Even how to extend it so that it can create SVG QRCodes ;)

You can mix and match all those together. Try generating the library logo and banner with gradients and all in SVG ;)

Spring Framework and/or Spring Boot

As said earlier, one of the main reasons I developed this library was to use it on a backend application. So it is only natural to show how to do that :)

This Spring Framework/Boot controller method can generate QRCodes of a given content:

import org.springframework.core.io.ByteArrayResource
import org.springframework.http.HttpHeaders.CONTENT_DISPOSITION
import org.springframework.http.MediaType.IMAGE_PNG_VALUE

@GetMapping("/qrcode")
fun generateQrCode(content: String): ResponseEntity<ByteArrayResource> {
    val pngData = QRCode().ofSquares()
        .build(content)
        .render()
    val resource = ByteArrayResource(pngData, IMAGE_PNG_VALUE)

    return ResponseEntity.ok()
        .header(CONTENT_DISPOSITION, "attachment; filename=\"qrcode.png\"")
        .body(resource)
}

Changes from v3

The main changes coming from v3.3.0 are:

  1. The main package of the classes was changed from io.github.g0dkar.qrcode to simply qrcode
    • The old name doesn't help languages that don't have the "package" concept, and other Kotlin libraries already name their main package this way.
  2. The old QRCode class was rewritten to be easier to create better looking QRCodes . The previous QRCode class was renamed to QRCodeProcessor, with very minor API changes.
    • For most of the simple cases, the new QRCode class is compatible with the old one!
  3. A bunch of optimizations on how the QRCode is drawn. Previously, we'd had a canvas for each square, which would then be copied into the QRCode. This was changed to have just one large canvas where each square will be individually drawn directly.
  4. iOS and tvOS Support: Starting from v4.0.7 an initial implementation of the QRCodeGraphics so that iOS and tvOS are now supported. Any and all feedback are very welcome! - Thanks a lot to ruicanas for all his contributions to this feature :D

License

Copyright since 2021 Rafael M. Lins, Licensed under the MIT License.

QR Code is trademarked by Denso Wave, Inc.

Thanks and Acknowledgements

  • Kazuhiko Arase: For his reference implementation!
  • Paul Varry: for opening the first few issues on the repo and helping to make the library even better for everyone! 😁
  • Renan Lukas: For his friendship, patience and help with Android, Gradle and a bunch of other stuff during the development of v2.0.0 and v3.0.0!
  • Doomsdayrs: For pointing out how the library could be improved using Kotlin Multiplatform, and helping out implementing it into the project.
  • An awesome, furry friend for all the support through all these years :)
  • ruicanas: For not only pointing out some issues with the iOS implementation, but also fixing them! Thank you so much ^^

Support and Links

If you enjoyed the library and want to get me some coffee, use the buttons below 🤟

Buy me a coffee over at Ko-fi!

Buy me a coffee over at PayPal!

qrcode-kotlin's People

Contributors

g0dkar avatar rafaellins-swile avatar renovate[bot] avatar ruicanas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

qrcode-kotlin's Issues

Android minimum version requirement

I tried to update my project's gradle file to use qrcode-kotlin 4.0.3, but now it won't build because my Android minSdk is 23 and this library wants 24 or newer. I'd like to keep supporting 23 because it makes about a 5% difference to the number of supported devices. Would it be possible for you to restore support for Android API 23 in version 4?

Cannot build the project - missing dependency on

Describe the bug

Build file '/Users/fedmest/Projects/qrcode-kotlin/build.gradle.kts' line: 15

Plugin [id: 'com.android.library', artifact: 'com.android.tools.build:gradle:4.1.2'] was not found in any of the following sources:

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

To Reproduce

  1. I checked out the source code from github
  2. Opened the project in IntelliJ
  3. It fails when it configures the project

I also tried building the project from the command line with gradle

  1. I checked out the source code from github
  2. CD'd into the project folder
  3. Ran gradle build
    • Gradle version 7.5

Qrcode Version

Hi :-)

I'm very interested in your library. But for the same string, the QRcode generated by your library is in version 10 (= 57 columns/lines) although the old library I've been currently using (AwesomeQRCode) generates a version 7 (= 45 columns/lines).

I wonder why this difference ? is it a question of EC level used ?
If yes, would it be possible to make this level configurable in your library ?

Thank you for your answer

Error correction level not taken into account with large piece of data

Describe the bug
version: 3.3.0

I'm playing with this library to render very QR codes for very long urls (900 characters) and setting the ErrorCorrectionLevel doesn't change anything.
Digging a bit more, the error correction level is respected until 858 bytes of data, for example:

myapp://aa/bbbbb?code1=wXtvQ0CZz49wonPSL94ZzsBOHDmlvOIx9iNB1GnobhIZ6qqu4Xbdj11jX3MztHslmNhoPSHoTCNNNJJWdftBoHtfhuczuu2uycQZKLkWy9tlaj0MpUa80hHxUi1aFJ5OuD9To0cuAdzyIg4HIiTeuJrWi38dsg71jOyslAgembgJ0Pc70SxRHKTDovKNy7sTylvXAFKUzKexXIjU7Bs64qFC2wMG1mLMobAPqcaZHiqjhTvHP82RuaV9rz8p0ubLQzM7GtEf2AyCALBc66xVchUYPQAFkYphuSw8l3ZTeB04vePHU84hwfsQfCxutcHXizixUIvnm7NN2NjniqeqYpMnIC4utspDxbjGRH2LlAVgHjY4xZ1iwAJrkw6wjHcHw7VC9kscyn8LF8p4LOHVbv7VzO1A9JNGtzFgvFJJfzPqgGTRdsrskGZa5QQUFiKrM2PqJSSLDchMF18nBVt33MEtWUpubpSqYfucnE5gCju4RMdg03fvV6MQMWfkB23pvjYvmlrN8yTfo1i2iOdMdkWLnhoOxiXC0G2fOX5QmuX0kFDTQ9hDPw3CTVCYeia0ui3N9LNkiZlB6aqrVdVgJe3vpuOJVmE2hWt7EZSlwGHUUQLypD0xry2LGdZXogJsxH6CSfDJDVwNz9VdTlfVwNp1IQNTzGENjjIxgfnYRq3sNgWz5Ht9FlyFuzXBaZMltYBDbmadwnQlwb46UeCptWybw1CizfMrFHxkpM9XfohXzqfLDQgasrwlqsK7YhCztu9SYtb6iEv0dONZewEZVz67Ay5xnb580yTiTOqW7yr5k7NBfGLpd7ki0aJhI22Ofba

image

Passed that threshold, setting the error correction level has no effect:

myapp://aa/bbbbb?code1=wXtvQ0CZz49wonPSL94ZzsBOHDmlvOIx9iNB1GnobhIZ6qqu4Xbdj11jX3MztHslmNhoPSHoTCNNNJJWdftBoHtfhuczuu2uycQZKLkWy9tlaj0MpUa80hHxUi1aFJ5OuD9To0cuAdzyIg4HIiTeuJrWi38dsg71jOyslAgembgJ0Pc70SxRHKTDovKNy7sTylvXAFKUzKexXIjU7Bs64qFC2wMG1mLMobAPqcaZHiqjhTvHP82RuaV9rz8p0ubLQzM7GtEf2AyCALBc66xVchUYPQAFkYphuSw8l3ZTeB04vePHU84hwfsQfCxutcHXizixUIvnm7NN2NjniqeqYpMnIC4utspDxbjGRH2LlAVgHjY4xZ1iwAJrkw6wjHcHw7VC9kscyn8LF8p4LOHVbv7VzO1A9JNGtzFgvFJJfzPqgGTRdsrskGZa5QQUFiKrM2PqJSSLDchMF18nBVt33MEtWUpubpSqYfucnE5gCju4RMdg03fvV6MQMWfkB23pvjYvmlrN8yTfo1i2iOdMdkWLnhoOxiXC0G2fOX5QmuX0kFDTQ9hDPw3CTVCYeia0ui3N9LNkiZlB6aqrVdVgJe3vpuOJVmE2hWt7EZSlwGHUUQLypD0xry2LGdZXogJsxH6CSfDJDVwNz9VdTlfVwNp1IQNTzGENjjIxgfnYRq3sNgWz5Ht9FlyFuzXBaZMltYBDbmadwnQlwb46UeCptWybw1CizfMrFHxkpM9XfohXzqfLDQgasrwlqsK7YhCztu9SYtb6iEv0dONZewEZVz67Ay5xnb580yTiTOqW7yr5k7NBfGLpd7ki0aJhI22Ofbab

image

To Reproduce
Steps to reproduce the behavior. For example:

  1. Create a QRCode instance with a 859 characters like the second one posted above
  2. Invoke render() with a low error correction level
  3. See result

Expected behavior

Error correction level would be respected no matter the size of the data

How To Decode QR

Is there any chance with this library to decode the QR that has been generated with this library using a camera or import image?

Circle QR code not recognized

Describe the bug
I created a QR code with the following code
val circleQRCode = QRCode.ofCircles().build("https://sample/alphaskfhdbfebwhnewnew/sdjnbchbwdhvbewhbvhuew") val circlePngData = circleQRCode.render()

To save image on .png format I use the following code (it will be works for android 13 and newest version)
internal class SavePhotoTask(private val context: Context) : AsyncTask<ByteArray?, String?, String?>() { protected override fun doInBackground(vararg jpeg: ByteArray?): String? { val photo = File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).toString(), "photo.png") if (photo.exists()) { photo.delete() } try { val fos = FileOutputStream(photo.path) fos.write(jpeg[0]) fos.close() } catch (e: IOException) { Log.e("PictureDemo", "Exception in photoCallback", e) } return null } }

Note: No problem with scanning if I generate rectangle QR instead of circle , also your QR with name example01-circles.png was scanned perfectly but I do not now why since i used same code

Generated following QR
photo

Additional context

Finally, I accept that the generated image is not detected fast, for example, I use Google Scanner, the default application scanner but there are not working perfectly, freeze

I use for testing following devices:
Google pixel 7 (android 14)
Redmi not 9s (android 12)

Issue when compiling for iosArm64

Hello community!

Describe the bug
So I'm having an issue while trying to compile my KMM project with this library. The error is the following:

e: Could not find "org.jetbrains.kotlin.native.platform.Symbols" in [/Users/my-user/Documents/X/my-project, /Users/my-user/.konan/klib, /Users/my-user/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.10/klib/common, /Users/my-user/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.10/klib/platform/ios_arm64]

To Reproduce
Easily reproducible by trying to use the linkDebugFrameworkIosArm64.

Expected behavior
To be able to generate the binaries for the Arm64 architecture.

Additional context
As you can tell by the error, I'm already using Kotlin 1.9.10 and I have a Mac with a M2 chip. Feel free to ask for additional info! 😃

Internet Required

I'm sorry, maybe I have misunderstood this. But does your library require an internet connection in order to be used?

`BufferedImage` class not found

Describe the bug
I'm looking to use this library in my app but am encountering this error when generating QR codes

FATAL EXCEPTION: main
Process: , PID: 30803
java.lang.NoClassDefFoundError: Failed resolution of: Ljava/awt/image/BufferedImage;
at qrcode.render.QRCodeGraphics.createImage(QRCodeGraphics.jvm.kt:27)
at qrcode.render.QRCodeGraphics.createImage$default(QRCodeGraphics.jvm.kt:25)
at qrcode.render.QRCodeGraphics.createGraphics(QRCodeGraphics.jvm.kt:33)
at qrcode.render.QRCodeGraphics.draw(QRCodeGraphics.jvm.kt:41)
at qrcode.render.QRCodeGraphics.draw$default(QRCodeGraphics.jvm.kt:39)
at qrcode.render.QRCodeGraphics.fillRect(QRCodeGraphics.jvm.kt:130)
at qrcode.render.QRCodeGraphics.fill(QRCodeGraphics.jvm.kt:135)
at qrcode.shape.DefaultShapeFunction.renderSquare(DefaultShapeFunction.kt:34)
at qrcode.QRCode$draw$1.invoke(QRCode.kt:140)
at qrcode.QRCode$draw$1.invoke(QRCode.kt:121)...

To Reproduce
I'm able to run the sample app in this repo no issue.
I'm able to generate QR codes after creating an empty project and copying files over.
I'm unable to generate QR codes from an existing project.

Anyone have suggestions on how to troubleshoot error for an existing app?

Expected behavior

QR codes should be generated from the existing app like it is generated in the sample or empty project app.

Screenshots or other QRCodes rendered with other tools

Additional context

Tag releases

Is your feature request related to a problem?

Releases are not tagged, so there is no way to easily checkout to a specific release without having to go through logs, simultaneously there is no release history that one can look through.

Describe the solution you'd like
Tag releases and include change logs.

QRCode class docs are still the same as v1 😅

Describe the bug
Yeah... as the title says. My bad :')

To Reproduce
Steps to reproduce the behavior. For example:

  1. Open the javadocs
  2. Read the javadocs
  3. ???
  4. Me dumb, sorry!

Expected behavior

An actual, working docs with cool examples! hahaha ^^

Screenshots or other QRCodes rendered with other tools

Additional context

[iOS] Missing target for iOSX64 for 4.1.0

Describe the bug
It's not possible to download the library for projects containing the target iOSX64

To Reproduce
Try to update the library with the 4.1.0 version.

Logs 🪵

Caused by: org.gradle.internal.component.NoMatchingConfigurationSelectionException: No matching variant of io.github.g0dkar:qrcode-kotlin:4.1.0 was found. The consumer was configured to find a library for use during 'kotlin-metadata', preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native', attribute 'org.jetbrains.kotlin.native.target' with value 'ios_x64' but:

  • Variant 'iosArm64ApiElements-published' capability io.github.g0dkar:qrcode-kotlin:4.1.0 declares a library for use during 'kotlin-api', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
    • Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_x64'
    • Other compatible attribute:
      • Doesn't say anything about its target Java environment (preferred optimized for non-jvm)

Additional context
This might be related with the last changes made on build.gradle.kts, given that the iOSX64 target was deleted and not added again to the list.

Thanks!

[Android] Blank QR code squares with compose

Describe the bug
4.0.2-3

I'm updating a hobby project from v3.3.0 to 4.0.+ and it seems I am unable to render a QR code through Jetpack compose.

I am using landscapist as my image loading library and QR codes were working fine throughout v3, but now they are just blank solid colored squares moving to v4

I have tried using render(), render("bmp"), and renderToGraphics().nativeImage() to no avail. nativeImage() was my working way last major version.

render() seems to actually produce an inner square but, and rounded only shows rounded corners along the right side.

Correction: Top left corner is square while the other corners show a rounded corner

To Reproduce
Steps to reproduce the behavior. For example:

  1. Create a android sample project with compose
  2. Implement landscapist and qrcode-kotlin
  3. Create a sample screen with some test cases
  4. See error

Expected behavior
Rendered QR codes using Jetpack compose. Maybe a quick sample showing it off would help newcomers too!

Screenshots or other QRCodes rendered with other tools

qr1
qr2

Additional context

Quick sample code

                  LazyColumn(
                        modifier = Modifier.fillMaxSize(),
                        verticalArrangement = Arrangement.Top,
                        horizontalAlignment = Alignment.CenterHorizontally
                    ) {
                        item {
                            Text(text = "QR Examples!")
                            val qr1 = QRCode.ofSquares()
                                .withColor(Color.BLUE)
                                .withBackgroundColor(Color.RED)
                                .build("Hello QR 1!")
                            CoilImage(imageModel = { qr1.render() })
                            Spacer(modifier = Modifier.height(6.dp))
                        }

                        item {
                            val qr2 = QRCode.ofCircles()
                                .withColor(Color.BLUE)
                                .withBackgroundColor(Color.RED)
                                .build("Hello QR 2!")
                            CoilImage(imageModel = { qr2.render("bmp") })
                            Spacer(modifier = Modifier.height(6.dp))
                        }

                        item {
                            val qr3 = QRCode.ofCircles()
                                .withColor(Color.BLUE)
                                .withBackgroundColor(Color.RED)
                                .build("Hello QR 3!")
                            CoilImage(imageModel = { qr3.renderToGraphics().nativeImage() })
                            Spacer(modifier = Modifier.height(6.dp))
                        }
                    }

Crash on QrCode with number only

Hello, first thanks for this library, it's nice to see light Kotlin code 👍

Describe the bug
A got the flowing crash running this :

QRCode("20333").encode()
    java.lang.StringIndexOutOfBoundsException: length=5; index=6
        at java.lang.String.substring(String.java:2060)
        at kotlin.text.StringsKt__StringsKt.substring(Strings.kt:393)
        at io.github.g0dkar.qrcode.internals.QRNumber.write(QRData.kt:137)
        at io.github.g0dkar.qrcode.QRCode.createData(QRCode.kt:353)
        at io.github.g0dkar.qrcode.QRCode.encode(QRCode.kt:250)
        at io.github.g0dkar.qrcode.QRCode.encode$default(QRCode.kt:231)

To Reproduce
Steps to reproduce the behavior. For example:

Simply run the Kotlin code.

Additional context
I tested this on a physical device (Google Pixel XL) and on a emulator (Pixel 4 API 30), and on both I got this crash.

If I run the folowing Kotlin code I didn't get the crash, but the QrCode is not what I want

QRCode("20333 ").encode()

Strange encoding with number

Describe the bug
When a create a QrCode with only number, it's encode content as byte array and some very common tools can't display content.

To Reproduce

QRCode("123456").render()
QRCode("123456b").render()

When I encode :

  • 123456 -> the content is undetectable as String, only tools supporting byte decoding can display content
  • 123456b -> the content detected by other tools is 4R6T8VY
  • 123456 gg -> work correcly

PS: I used https://zxing.org/w/decode.jspx to decode QrCode

Expected behavior

To generate a QrCode with correct String encoded and be able to decode it with most tools.

The solution can be to create a other constructor who can receive a Byte Array and use the current one only for String OR to add a parameter to specify input type.

Unable to compile my Android app with java.awt

This issue is less important then #1, but I still reported to you.

Describe the bug

I got a very strange issue, I'm unable to compile my Android application with the lib. I got this compilation error :

e: xxx/QrCode.kt: (55, 37): Cannot access class 'java.awt.image.BufferedImage'. Check your module classpath for missing or conflicting dependencies
e: xxx/QrCode.kt: (55, 37): Cannot access class 'java.awt.Color'. Check your module classpath for missing or conflicting dependencies

I looked in my "gradles" files and compared to yours and I didn't found anything.

To Reproduce

  1. I added the lib on my project

  2. Write the flowing code :

QRCode("20333 ").render()
  1. Compile the project

Additional context

I search on Google and I found that java.awt is not compatible with Android. To temporarily fix this I created a custom render.

Library broken

This library randomly produces invalid QR-Codes that can't be scanned.

Native target support for KMM project

Hi @g0dkar!

Are you planning on adding native target support for this project to be able to use it in a KMM project (more specifically Android & iOS KMM project)?

We've found that using the kotlin-only dependency (io.github.g0dkar:qrcode-kotlin:3.2.0) in our project results in the following error:

No matching variant of io.github.g0dkar:qrcode-kotlin:3.2.0 was found. The consumer was configured to find a usage of 'kotlin-api' of a library, preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native', attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64' but:
          - Variant 'jvmApiElements-published' capability io.github.g0dkar:qrcode-kotlin:3.2.0 declares an API of a library:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_arm64')

Thank you in advance!

QR codes not being generated properly for iOS

Describe the bug
The method getBytes() from QRCodeGraphics is not giving the correct data to generate a QRCode.

To Reproduce

  1. Instantiate any type of QRCode and try to use getBytes() method.
  2. Try to use the ByteArray generated in an iOS app.

Expected behavior
Expected the QRCode to be shown correctly once I pass the ByteArray to NSData, and then from NSData to UIImage.

Additional context
I actually have a fix for this issue and I opened a PR for this. I have found another issue regarding the logos with a background color different than Colors.TRANSPARENT that only occurs in iOS. I don't know if this could be also a good place to talk about it.

some typos in installation and usage guide (alguns erros de Digitação nos guias de instalação e uso)

Describe the bug
A clear and concise description of what the bug is.
From https://github.com/g0dkar/qrcode-kotlin
In installation:
Screenshot from 2024-01-13 20-47-37

Repo qrcode-kotline:4.1.1 not found
Execution failed for task ':compileKotlin'.

Could not resolve all files for configuration ':compileClasspath'.
Could not find io.github.g0dkar:qrcode-kotlin:4.1.1.
Searched in the following locations:
https://repo.maven.apache.org/maven2/io/github/g0dkar/qrcode-kotlin/4.1.1/qrcode-kotlin-4.1.1.pom

In usage:
Screenshot from 2024-01-13 20-46-47

val pngBytes = helloWorld.render() // return error None of the following functions can be called with the arguments supplied.
write(ByteArray!) defined in java.io.FileOutputStream
write(Int) defined in java.io.FileOutputStream

All issues was solved by changing :
Todos os problemas foram resolvidos alterando

  1. // Use this for both Android and JVM
    implementation("io.github.g0dkar:qrcode-kotlin:4.1.1")

To

implementation("io.github.g0dkar:qrcode-kotlin:4.1.0")

// By default, QRCodes are rendered as PNGs.
val pngBytes = helloWorld.render()
FileOutputStream("hello-world.png").use { it.write(pngBytes) }

To

// By default, QRCodes are rendered as PNGs.
val pngBytes = helloWorld.renderToBytes()
FileOutputStream("hello-world.png").use { it.write(pngBytes) }

[v4.0.1] iOS and tvOS Feedback

Hello everyone!

Feel free to leave any and all feedback of the iOS and tvOS support now available at v4.0.1

Thank you all so much for using, and hopefully enjoying, this project ^^

Duplicate class conflicts

Describe the bug
I import QRCode library and build in Android Studio
Gradle detect a lot of duplicate classes on library com.android.tools.external.com-intellij:intellij-core:30.1.2
full-output: https://pastebin.mozilla.org/upNGVtqc

After that I checking dependency tree using ./gradlew app:dependencies
It seems that com.android.tools.external.com-intellij:intellij-core is imported by com.android.tools.lint:lint-gradle

Am I use this library in the wrong way?

To Reproduce
Steps to reproduce the behavior. For example:

  1. import this library using implementation 'io.github.g0dkar:qrcode-kotlin-android:3.1.0'
  2. invoke gradle sync
  3. Make project
  4. error

Expected behavior

build sucessfully

Screenshots or other QRCodes rendered with other tools

Additional context

my app:build.gradle

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'org.jetbrains.kotlin.plugin.serialization'
    id 'kotlin-kapt'
    id 'dagger.hilt.android.plugin'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "at.mikuc.fcuassistant"
        minSdk 26
        targetSdk 32
        versionCode 1
        versionName "0.1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion compose_version
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.8.0'
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.material:material-icons-extended:$compose_version"
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
    
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
    implementation 'androidx.activity:activity-compose:1.5.0'

    implementation "androidx.navigation:navigation-compose:$nav_version"
    api "androidx.navigation:navigation-fragment-ktx:$nav_version"

    implementation 'com.google.dagger:hilt-android:2.38.1'
    kapt 'com.google.dagger:hilt-compiler:2.38.1'
    implementation 'androidx.hilt:hilt-navigation-compose:1.0.0'

    implementation 'androidx.datastore:datastore-preferences:1.0.0'

    implementation 'org.burnoutcrew.composereorderable:reorderable:0.9.2'

    implementation 'io.github.g0dkar:qrcode-kotlin-android:3.1.0'

    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.3")
    implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.3")
    implementation("io.ktor:ktor-client-core:$ktor_version")
    implementation("io.ktor:ktor-client-cio:$ktor_version")
    implementation("io.ktor:ktor-client-content-negotiation:$ktor_version")
    implementation("io.ktor:ktor-serialization-kotlinx-json:$ktor_version")

    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
    debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
    debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
}

QRCode in fixed size?

I need for a mini IoT project that the qrcode must have a fixed resolution for example 320X320, is that possible ?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update dependency com.google.android.material:material to v1.12.0
  • Update dependency io.github.gradle-nexus.publish-plugin to v2
  • 🔐 Create all rate-limited PRs at once 🔐

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/dokka-update.yml
  • actions/checkout v4@b4ffde65f46336ab88eb53be808477a3936bae11
  • actions/setup-java v4@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
  • gradle/gradle-build-action v2@982da8e78c05368c70dac0351bb82647a9e9a5d2
  • EndBug/add-and-commit v9@1bad3abcf0d6ec49a5857d124b0bfb52dc7bb081
.github/workflows/run-tests.yml
  • actions/checkout v4@b4ffde65f46336ab88eb53be808477a3936bae11
  • actions/setup-java v4@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
  • gradle/gradle-build-action v2@982da8e78c05368c70dac0351bb82647a9e9a5d2
gradle
gradle.properties
settings.gradle.kts
build.gradle.kts
gradle/libs.versions.toml
  • org.jetbrains.kotlin:kotlin-gradle-plugin 1.9.22
  • org.jetbrains.kotlinx:kotlinx-coroutines-core 1.8.21
  • io.kotest:kotest-assertions-core 5.8.0
  • io.kotest:kotest-framework-engine 5.8.0
  • io.kotest:kotest-runner-junit5 5.8.0
  • androidx.core:core-ktx 1.12.0
  • junit:junit 4.13.2
  • androidx.test.ext:junit 1.1.5
  • androidx.test.espresso:espresso-core 3.5.1
  • androidx.appcompat:appcompat 1.6.1
  • com.google.android.material:material 1.11.0
  • androidx.constraintlayout:constraintlayout 2.1.4
  • androidx.navigation:navigation-fragment-ktx 2.7.7
  • androidx.navigation:navigation-ui-ktx 2.7.6
  • com.diffplug.spotless 6.23.3
  • org.jetbrains.dokka 1.9.20
  • org.jetbrains.kotlin.multiplatform 1.9.22
  • io.kotest.multiplatform 5.8.0
  • com.android.library 8.2.0
  • io.github.gradle-nexus.publish-plugin 1.3.0
  • dev.petuska.npm.publish 3.4.2
  • com.android.application 8.2.0
  • org.jetbrains.kotlin.android 1.9.22
gradle-wrapper
gradle/wrapper/gradle-wrapper.properties
  • gradle 8.7
npm
package.json

  • Check this box to trigger a request for Renovate to run again on this repository

Use custom color function to color each square of the position probe independently

Hi,

Since each position probe is rendered with the renderControlSquare, it is not possible to use a custom color function to color each square with a different color because they will all use the color of the parent square.

For now, I overwrote renderControlSquare in my custom shape function to produce the result I wanted but I was wondering if it was possible in a next version to only use a custom color function to do this (for example, by using renderSquare for all the squares)?

Thank you in advance for your answer and thanks for all the work you did so far on the library.

can't find the documentation

Describe the bug
The link to the documentation page is broken
image

To Reproduce
Steps to reproduce the behavior. For example:

  1. Click the link in the README.md
  2. 404-page
  3. See error in screenshot

Expected behavior
I expected to find documentation. I can't really use the library without.

[iOS] Other shapes than squares

Describe the bug
Hello, when I try to use other shapes than squares on iOS generated library than the QR code is not visible at all. I tried to change parameters like color and sizes but the result is always the same. It works perfectly on Android (with same parameters).

To Reproduce
Steps to reproduce:

  1. Add .ofCircles() to QRCode builder
  2. Observe

Screenshots or other QRCodes rendered with other tools

Screenshot 2024-03-10 at 17 50 34 Simulator Screenshot - iPhone 15 - 2024-03-10 at 17 50 40

Additional context
Xcode 15.2

Result is same on physical device and Simulator

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.