Drawing Images with MicroGraphics
Drawing images on a display is pretty much table-stakes for any sort of display-based application, and embedded software is no exception. Meadow Foundation‘s MicroGraphics Library is our go-to for drawing things like lines, shapes and text, but it wasn’t terribly friendly for drawing images. Sure, you could send it in a byte array of pixel data and it would display that just fine, and in fact we have a sample that decodes and uses JPG files, but it’s not inherently a simple task.
In an effort to make things more user-friendly, we’ve added a new class called Image
that now inherently knows how to decode BMP files, anything from 1-bit to 32-bit color, and MicroGraphics has added DrawImage()
methods that allow you to draw the Image
right to the display buffer. It’s a much friendlier API. For example, if you have a BMP file as an embedded resource, you can display it with just a few lines of code:
var image = Image.LoadFromResource($"my_image.bmp");
graphics.Clear();
graphics.DrawImage(image, 0, 0);
graphics.Show();
This feature will be in the next Meadow Foundation release, but if you want to try it out now and provide feedback, it’s available today in the develop
branch on GitHub.