eXoCooLd / Waveshare.EPaperDisplay

.Net Core Library to show images on Waveshare E-Paper Displays
MIT License
30 stars 13 forks source link

System.Imaging #8

Closed thecaptncode closed 3 years ago

thecaptncode commented 3 years ago

I thought I'd open up an issue just for this.

According to https://github.com/dotnet/iot/issues/1403 the .NET IoT guys are planning a move away from System.Imaging since it has been deprecated. The link to a Microsoft doc in that issue lists three alternatives. I can explore the conversion of this project to one of them if you wish.

I have moved the local copy of my IoTDisplay project (not pushed to GitHub yet) from System.Imaging to SkiaSharp and it is working well. The same could be done with the Waveshare driver and still remain compatible with existing code.

What are your thoughts? Greg

eXoCooLd commented 3 years ago

I have a idea to move all System.Imaging logic into a decorator, to get a flexible solution. Skia should be the fastest lib, if we move away from System.Imaging.

thecaptncode commented 3 years ago

I am very interested in hearing more. Delegates are another alternative as well and are mockable. How do you see decorators working?

eXoCooLd commented 3 years ago

Our internals don't need the Imaging, we just need the bytes / IntPtr to the Byte Array. The Decorater could load the image and than call the SendBitmapToDevice with the Pointer.

I will try to refactor it for this idea :-)

thecaptncode commented 3 years ago

Sounds like a good idea. There are a couple things to keep in mind.

SkiaSharp requires the access to be within an unsafe { } block. Which, in retrospect I'm surprised System.Imaging doesn't. SkiaSharp returns 4 bytes per pixel, one of them for the Alpha channel, which I don't see us ever needing to manipulate.

Here is an example: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/graphics/skiasharp/bitmaps/pixel-bits

Greg

eXoCooLd commented 3 years ago

Dis a test with SkiaSharp on the develop branch. But looks like the installation of the required lib for linux is a pain in the ass on the pi and test pipeline on github

thecaptncode commented 3 years ago

Which SkiaSharp NuGet packages did you use? I have been using SkiaSharp and SkiaSharp.NativeAssets.Linux,

eXoCooLd commented 3 years ago

Thanks for the Hint, i only used the Main NuGet Package. It's working in the GitHub Action now and i dont need to compile it on the Pi any more :-)

thecaptncode commented 3 years ago

Oh that;s good. I'm glad I could help.

eXoCooLd commented 3 years ago

Moved Imaging logic out of the devices (on develop branch), it can be replaced if the IoT Team is moving to a other library.