image()

Description

Draws an image from the SD card to the screen at a specified location.

Syntax


screen.image(image, xPos, yPos);

Parameters

image: a named instance of PImage.
xPos: int, location on the x-axis to start drawing
yPos: int, location on the y-axis to start drawing

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

loadImage()
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.