Images with the Image Converter
What this example shows
Show a picture that is compiled into the sketch. The Soldered Image Converter turns an image into a C array in a header file, image.h, which the sketch includes and draws. The example folder already holds an image.h, so the sketch runs as it is.
To use your own picture:
- Open the Image Converter at tools.soldered.com/tools/image-converter.
- Upload your image and select Inkplate 7SPECTRA as the target board.
- Choose the color mode, and adjust dithering, resize and the other options as needed.
- Save the generated header file as
image.hin the same folder as the sketch, replacing the one there.
Example code
#include "Inkplate.h" // Include the Inkplate library
#include "image.h" // Include the image header generated by the Image Converter tool
Inkplate display; // Create an Inkplate object for Inkplate 7SPECTRA
void setup() {
display.begin(); // Initialize the display hardware
display.clearDisplay(); // Clear the frame buffer (does NOT clear the physical screen)
display.image.draw(image, 0, 0, image_w, image_h); // Arguments are: array variable name, start X, start Y, size X, size Y
display.display(); // Refresh the e-paper display to show the image
}
void loop() {
// No code needed here for this example
}
Functions used
Inkplate()returns NoneCreates the Inkplate object. Inkplate 7SPECTRA has a single six-color mode, so the constructor takes no mode argument.
ReturnsConstructor; no return value.
display.begin()returns voidInitializes the library, the peripherals and the frame buffer. Call it once in setup(); later calls are ignored.
ReturnsNothing.
display.clearDisplay()returns voidFills the frame buffer with white. It does not change the panel.
ReturnsNothing.
display.image.draw(const uint8_t *buf, int x, int y, int16_t w, int16_t h, uint8_t c = 1, uint8_t bg = 0xFF)returns boolDraws an image array from memory into the frame buffer, with its top-left corner at (x, y). image_w and image_h are defined in the generated image.h.
ReturnsWhether the image was drawn.
Parameters
| Type | Name | Description |
|---|---|---|
const uint8_t * | buf | The image array, here image. |
int | x, y | Top-left corner in pixels. |
int16_t | w, h | Image width and height in pixels. |
uint8_t | c | Optional. Defaults to 1. |
uint8_t | bg | Optional. Defaults to 0xFF. |
display.display(bool _leaveOn = 0)returns voidSends the whole frame buffer to the panel and refreshes it.
ReturnsNothing.
What to expect
The converted image appears on the screen, starting at the top-left corner. The sketch prints nothing to the Serial Monitor.
🔗Open the complete example
examples/Inkplate7SPECTRA/Basic/Inkplate7SPECTRA_Image_Converter