QRCoder
QRCoder copied to clipboard
Adds Support for ImageSharp and SkiaSharp using two independent projects for maximum compatibility
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.
@codebude Is there a reason why the PR is not merged? The PR would also solve our problem.
Also interested in this, is there any news ?
@codebude awaiting merge of this branch
Would be nice to merge this
https://github.com/codebude/QRCoder/issues/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