Inkplate 6 – 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 example images of different formats on Inkplate. Download them from the Inkplate library and place them in the root folder of the microSD card:
#include "Inkplate.h" // Include Inkplate library to the sketch
Inkplate display(INKPLATE_3BIT); // Create an object on Inkplate library and also set library into 3 Bit mode
SdFile file; // Create SdFile object used for accessing files on SD card
void setup()
{
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
display.clearDisplay(); // Clear frame buffer of display
display.setTextColor(BLACK); // Set text color to black
display.setTextSize(3); // Set font size to 3
// Init SD card. Display if SD card is init propery or not.
if (display.sdCardInit())
{
display.println("SD Card OK! Reading image...");
display.display();
// If card is properly init, try to load image and display it on e-paper at position X=0, Y=0
// NOTE: Both drawImage methods allow for an optional fifth "invert" parameter. Setting this parameter
// to true will flip all colors on the image, making black white and white black. This may be necessary when
// exporting bitmaps from certain softwares.
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();
delay(5000);
// Now try to load image using SdFat library class (for more advanced users) and display image on epaper.
display.clearDisplay();
if (file.open("image2.bmp", O_RDONLY))
{
display.image.drawBitmapFromSd(&file, 0, 0);
}
else
{
display.println("Image open error");
}
display.display();
delay(5000);
// Now draw a JPEG
display.clearDisplay();
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();
}
else
{
// If SD card init not success, display error on screen
display.println("SD Card error!");
display.display();
}
// Turn off the MOSFET that powers the SD card
display.sdCardSleep();
}
void loop()
{
// Nothing...
}

Example image 1

Example image 2

Example image 3
display.image.draw()
The function draws an image from the given path.
Returns value: Returns true if the image was successfully drawn, otherwise false.
Function parameters:
| Type | Name | Description |
|---|---|---|
const char* | path | The path and filename of the image. Can be a URL (for web images) or a file path (on the microSD card). |
int | x | The X-coordinate of the image's upper-left corner in the framebuffer. |
int | y | The Y-coordinate of the image's upper-left corner in the framebuffer. |
bool | dither | Dithering mode: false (disabled), true (enabled). Defaults to true. |
bool | invert | If true, inverts colors. |
Full example
Inkplate6_microSD_Pictures.ino
This example shows you how to read .bmp and .jpeg files (pictures) from the SD card and display them on the e-paper display.