Reference Language | Libraries | Comparison | Changes
TFTLibrary > TFT
loadImage
Description
Loads an image file from the SD card into a named instance of PImage. The TFT library has the ability to read .bmp files off the root of a SD card and display them on the screen. Images can be smaller or larger than the screen resolution (160x128), but there is no method on the Arduino for image manipulation. The images should be sized before you put them on the SD card. The TFT library has the ability to read .bmp files off the root of a SD card and display them on the screenIt is possible to load 24 bit bmp image only.
Syntax
screen.loadImage(name);
Parameters
- name : char array, the name of the image from the SD card you wish to read
Returns
The loaded image
Example
// this example looks for a file named "logo.bmp"
// on the SD card, and renders it to the screen
#include <Esplora.h>
#include <SD.h>
#include <SPI.h>
#include <TFT.h> // Arduino TFT library
#define SD_CS 8 // Chip select line for SD card in Esplora
PImage logo;
void setup() {
// initialize the screen
EsploraTFT.begin();
// initialize the SD card
SD.begin(SD_CS);
// set the background the black
EsploraTFT.background(0, 0, 0);
// load the image into the named instance of PImage
logo = EsploraTFT.loadImage("arduino.bmp");
// if it is a valid image file, turn the Esplora's LED green
if (logo.isValid()) {
Esplora.writeGreen(255);
}
else{
// if it is not valid, turn the LED red
Esplora.writeRed(255);
}
// draw the image on the screen starting at the top left corner
EsploraTFT.image(logo, 0, 0);
}
void loop() {
}
See also
Reference Home
Corrections, suggestions, and new documentation should be posted to the Forum.
The text of the Arduino reference is licensed under a
Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.