Add option to create ImageSource directly from ImageSharp image #231
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.
If you already have a loaded ImageSharp image (maybe to apply some effects) this image currently cannot be supplied to PdfSharp Core. Instead the image needs to be encoded to a byte array and this can then be used to create an ImageSource (decoding it to a ImageSharp image again).
This pull-request enables the user to supply a ImageSharp image directly, without encoding and decoding it. This should be an obvious performance win. (I did not create any formal benchmarks)
It is not super straight forward how to use this, because I wanted to change as little code as possible, but I added a test that shows how to use this feature. I didn't add a convenience method to ImageSource or XImage to keep those independent of ImageSharp.
I hope people will find this useful and look forward to your feedback.
(This PR also runs the tests under .Net 6.0 as .Net 5.0 is EOL now.)