Skip to main content

Inkplate 10 – Image from microSD

To draw images from the microSD card, use the display.image.draw() function.

ℹ️
Supported formats are: JPG, BMP and PNG.
⚠️
JPG files without progressive encoding are supported.

Drawing PNG, JPG and BMP files from the microSD card​

Let's draw the example images of different formats on Inkplate, download them from the Inkplate library and place them in the root folder of the microSD card:

Let's draw image1.bmp at coordinates 0, 0 using the display.image.draw() function:

// Make sure Inkplate and then the microSD card are initialized before this
if (!display.image.draw("image1.bmp", 0, 0, 1))
{
// If is something failed (wrong filename or wrong bitmap format), write error message on the screen.
// REMEMBER! You can only use Windows Bitmap file with color depth of 1, 4, 8 or 24 bits with no
// compression! You can turn of dithering for somewhat faster image load by changing the last 1 to 0, or
// removing the 1 argument completely
display.println("Image open error");
}
display.display();

Now, let's draw image2.bmp by first loading it using the SdFat library class and then displaying it on epaper:

if (file.open("image2.bmp", O_RDONLY))
{
display.image.drawBitmapFromSd(&file, 0, 0);
}
else
{
display.println("Image open error");
}
display.display();

Lets try another file format, for example, jpg:

if (!display.image.draw("pyramid.jpg", 100, 0, true, false))
{
// If is something failed (wrong filename or wrong format), write error message on the screen.
// You can turn off dithering for somewhat faster image load by changing the fifth parameter to false, or
// removing the parameter completely
display.println("Image open error");
}
display.display();

display.image.draw()

Function draws image from char path.

Returns value: Returns true if image was successfully drawn, otherwise false.

Function parameters:

TypeNameDescription
const char*pathPath and filename of the image. Can be a URL (for web images) or a file path (on the microSD card).
intxX-coordinate of the image's upper-left corner in the framebuffer.
intyY-coordinate of the image's upper-left corner in the framebuffer.
uint8_tditherDithering mode: 0 (disabled), 1 (enabled).
boolinvertIf true, inverts colors.

Full example​

Inkplate10_microSD_Pictures.ino

This example will show you how you can read .bmp and .jpeg files (pictures) from SD card and display that image on e-paper display.