Skip to content

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

Closed
emorell96 wants to merge 4 commits into
Shane32:masterfrom
StockDrops:master
Closed

Adds Support for ImageSharp and SkiaSharp using two independent projects for maximum compatibility#407
emorell96 wants to merge 4 commits into
Shane32:masterfrom
StockDrops:master

Conversation

@emorell96

@emorell96 emorell96 commented Jun 23, 2022

Copy link
Copy Markdown

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

gutzi commented Feb 8, 2023

Copy link
Copy Markdown

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

@adrien-constant

Copy link
Copy Markdown

Also interested in this, is there any news ?

@osaleem303

Copy link
Copy Markdown

@codebude awaiting merge of this branch

@danielgindi

Copy link
Copy Markdown

Would be nice to merge this

@aligneddev

Copy link
Copy Markdown

#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

@nzhuravel

Copy link
Copy Markdown

I hope it will be merged, would be nice to get support of SkiaSharp. As it does not require license and can be used in commercial projects.

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

8 participants