PImage.isValid()

Description

Checks if a named instance of PImage references a valid bitmap file.

Syntax


image.isValid();

Parameters

none

Returns

boolean

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( )
PImage.width( )
PImage.height( )


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.