PImage.height()

名称

PImage.height()

説明

PImageオブジェクトの高さを調べる。

書式

int PImage::height();

引数

なし。

戻り値

イメージの高さ(ピクセル単位)。

使用例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// 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);
  }


}

void loop() {
  // randomly draw the image on screen
  int x = random(EsploraTFT.width() - logo.width());
  int y = random(EsploraTFT.height() - logo.height());
  EsploraTFT.image(logo, x, y);
  delay(1500);

}

オリジナルのページ

https://www.arduino.cc/reference/en/libraries/tft/pimage.height/

最終更新日

January 8, 2024

inserted by FC2 system