ReMarkable.NET
ReMarkable.NET copied to clipboard
Sample code for OutputDevices.Display fails with System.TypeLoadException for Method 'EncodeAsync'
With this sample code (from https://parzivail.github.io/ReMarkable.NET/articles/intro.html):
// Create an image
var img = new Image<Rgb24>(300, 300);
// Do some image processing
img.Mutate(ctx => ctx.DrawLines(Color.Black, 3, new PointF(50, 50), new PointF(250, 250)));
// Draw the image to the screen
OutputDevices.Display.Draw(img, img.Bounds(), Point.Empty);
The following exception occurs:
Unhandled exception. System.TypeLoadException: Method 'EncodeAsync' in type 'ReMarkable.NET.Graphics.Rgb565FramebufferEncoder' from assembly 'ReMarkable.NET, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
at ReMarkable.NET.Unix.Driver.Display.Framebuffer.HardwareFramebuffer.Write[TPixel](Image`1 image, Rectangle srcArea, Point destPoint)
at ReMarkable.NET.Unix.Driver.Display.HardwareDisplayDriver.Draw(Image`1 image, Rectangle srcArea, Point destPoint, Rectangle refreshArea, WaveformMode mode)
Looking at the source, the reason is obvious.
public Task EncodeAsync<TPixel>(Image<TPixel> image, Stream stream) where TPixel : unmanaged, IPixel<TPixel>
{
throw new NotImplementedException();
}
How can it me made to work, e.g. is it possible to force it to use "Encode" instead?
Hm, it's possible there was a recent change in ImageSharp that moved from using Encode
by default to EncodeAsync
. This wasn't the case previously (thus leading to that method not being implemented). It should be as simple as properly implementing that function. I'll test it out and post back here.
Alright, can you give that commit a try? The framebuffer encoding isn't exactly designed to work asynchronously so while I don't expect it to crash, I also don't expect it to be stable -- in the end we might just need to find a way to force ImageSharp to run that encoder synchronously.
I tried it, but couldn't make it work. Then I went back to square one and referenced the exact same versions of all dependencies as you do in your csproj, together with Remarkable.NET 1.0.0.0 from NuGet.
It's different now and I'm not sure if it's better or not. Have you seen that before? Is it worth a new issue?
Unhandled exception. ReMarkable.NET.Unix.Stream.UnixException (0x80004005): EINVAL: Invalid argument (22)
at ReMarkable.NET.Unix.Driver.Display.HardwareDisplayDriver.Refresh(Rectangle rectangle, WaveformMode mode)
at ReMarkable.NET.Unix.Driver.Display.HardwareDisplayDriver.Draw(Image`1 image, Rectangle srcArea, Point destPoint, Rectangle refreshArea, WaveformMode mode)
Apologies for the delay, I misplaced the email for this issue and my uni semester took over. If you're on an rm2, 1.0.0.0 should work perfectly in conjunction with rm2fb, using it like so: https://github.com/ddvk/remarkable2-framebuffer/issues/13