PImage()
Description
The base class for drawing a bitmap image from the SD card onscreen. You must include the SD library to use PImage
.
Syntax
PImage image;
Parameters
image
: the name of the PImage
object. You’ll refer to this when drawing images on screen.
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
- loadImage()
- isValid()
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.