Skip to main content

Images and the Image Converter

What this example shows​

Showing a picture on the panel. The Soldered Image Converter turns an image into a header file with a byte array, and the sketch draws that array with display.image.draw().

Example code​

The listing is the library example without its header comment and board-check lines. The sketch also needs the generated header image.h, which in the library example holds a 1200 × 825 pixel, 1 bit per pixel image. Open the source link to get both files.

To make your own image.h, follow the steps in the example header:

  1. Open the Image Converter.
  2. Upload your image and select Inkplate 10 as the target board.
  3. Choose the display mode: 1-bit (black and white) for the fastest refresh and highest contrast, or 3-bit (grayscale) for 8 shades of gray. For 3-bit, also change the sketch to INKPLATE_3BIT.
  4. Adjust dithering, size and the other options as needed.
  5. Save the generated image.h in the same folder as the sketch. It defines image_w and image_h for you.
Select Board
Inkplate10_Image_Converter.ino
#include "Inkplate.h" // Include the Inkplate library
#include "image.h" // Include the image header generated by the Image Converter tool

Inkplate display(INKPLATE_1BIT); // 1-bit mode (black & white)
//Inkplate display(INKPLATE_3BIT); // Uncomment for 3-bit mode (grayscale, 8 shades)

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(uint8_t mode)returns None

Creates the Inkplate object. The mode decides how many bits describe each pixel: `INKPLATE_1BIT` for black and white, `INKPLATE_3BIT` for grayscale.

ReturnsConstructor; no return value.

Parameters

TypeNameDescription
uint8_tmodeDisplay mode, INKPLATE_1BIT or INKPLATE_3BIT.
display.begin()returns void

Initializes the display hardware. Call it once in `setup()` before you draw anything.

ReturnsNothing.

display.clearDisplay()returns void

Clears the frame buffer in the ESP32 memory. It does not change what the panel currently shows; call `display()` for that.

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 bool

Draws a bitmap stored in an array, such as the header file produced by the Soldered Image Converter.

ReturnsTrue if the image was drawn, otherwise false.

Parameters

TypeNameDescription
const uint8_t *bufThe bitmap array.
intxLeft edge in pixels.
intyTop edge in pixels.
int16_twBitmap width in pixels.
int16_thBitmap height in pixels.
uint8_tcDrawing color. Defaults to 1.
uint8_tbgBackground value. Defaults to 0xFF.
display.display(bool _leaveOn = 0)returns void

Sends the frame buffer to the panel with a full refresh.

ReturnsNothing.

Parameters

TypeNameDescription
bool_leaveOnOptional. When true, the panel supply stays on after the refresh. Defaults to false.

What to expect​

The panel shows the picture from image.h filling the screen after one full refresh. The example prints nothing to the Serial Monitor.