loadImage()

Description

Loads an image file from the SD card into a named instance of PImage.

Syntax


screen.loadImage(name);

Parameters

name: char array, the name of the image from the SD card you wish to read

Returns

none

Example

// this example looks for a file named "arduino.bmp"
//  on the SD card, and renders it to the screen
#include <SPI.h>
#include <SD.h>
#include <TFT.h>

#define cs   10
#define dc   9
#define rst  8
 
TFT screen = TFT(cs, dc, rst);

PImage logo;

void setup() {
  // initialize the screen
  screen.begin();
  // initialize the SD card
  SD.begin();
  // set the background the black
  screen.background(0, 0, 0);

  // load the image into the named instance of PImage 
  logo = screen.loadImage("arduino.bmp");

   if (!logo.isValid()) {
       Serial.println("error while loading arduino.bmp");
  }

  // draw the image on the screen starting at the top left corner
  screen.image(logo, 0, 0);
}

void loop() {

}

See also

image()
PImage


Libraries Reference Home

The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.