Skip to content
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

Adds Support for ImageSharp and SkiaSharp using two independent projects for maximum compatibility #407

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

emorell96
Copy link

@emorell96 emorell96 commented Jun 23, 2022

Summary

This PR brings support for ImageSharp and SkiaSharp in two different packages: QrCoder.ImageSharp and QrCoder.SkiaSharp

It brings three new classes: ImageSharpQrCode ArtQrCode (but for ImageSharp), and SkiaSharpQrCode.

Each of them adds support for their respective rendering libraries, and you can then use said libraries to save the qr code as a png or further manipulations since both ImageSharpQrCode and SkiaSharpQrCode return a native Image object from either library.

I've created a few extension methods for SkiaSharpQrCode that allows easy saving into a stream or directly into a file.

I am open to discussion on how more features could be added or the packages be structured.

This PR fixes/implements the following bugs/features:

  • Adds support for ImageSharp
  • Adds support for SkiaSharp
  • Adds support for logo images being drawn on top of the QR codes and custom colors for both renders.
  • Ports ArtQrCode to ImageSharp.
  • No Breaking changes since they are an additional module not necessarily to be packed with the original.

What existing problem does the pull request solve?**

The lack of customization of the QR codes in other platforms other than Windows. Indeed modern .NET6 depends a lot of other imaging libraries like SkiaSharp and ImageSharp to do any complex drawings since System.Drawing is lacking in a lot of other platforms other than Windows.

To solve this I have coded expansions of QRCoder that allow drawing of QR codes using said libraries. Thanks to these libraries image manipulation is abstracted and I can easily add things like custom colors for the QR code, logo images in the center of the QR code or on the bottom right, or I can port the ArtQrCode which used to depend on System.Drawing and made it unavailable in many platforms.

Test plan

I added to new tests projects and placed them under a Solution folder called Tests. Each for each package. They allow generation of the QR codes and you can scan them with your phone to check that they scan properly.

Closing issues

Fixes #397
Contributes towards #242

Feel free to add ideas/proposals to further improve each package to get closer to a leaner QrCoder with more modern renderers.

Finally, I haven't fully tested below NET5.0 since I do not have older frameworks on my dev machine. I've tested the new modules on NET6 and NET5.

@gutzi
Copy link

gutzi commented Feb 8, 2023

@codebude Is there a reason why the PR is not merged? The PR would also solve our problem.

@adrien-constant
Copy link

Also interested in this, is there any news ?

@osaleem303
Copy link

@codebude awaiting merge of this branch

@danielgindi
Copy link

Would be nice to merge this

@aligneddev
Copy link

#361 mentions ImageSharp as a way to run in Linux.

If this works, it would be nice to have it checked on Linux and merged in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Logo insert after QRCode unable to scan
6 participants