Adds Support for ImageSharp and SkiaSharp using two independent projects for maximum compatibility #407
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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), andSkiaSharpQrCode
.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:
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.