image()
描述
显示 SD 卡中的图片到萤幕上指定的位置。
语法
screen.image(image, xPos, yPos);
参数
image
:PImage
物件的名称
xPos
:图片左上角位置的 x 轴座标,型态为 int
yPos
:图片左上角位置的 y 轴座标,型态为 int
回传
无回传值
范例
// 把 SD 卡中名为 "arduino.bmp" 的图片显示在萤幕上 #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() { // 初始化 TFT 物件 screen.begin(); // 初始化 SD 卡 SD.begin(); // 设定背景色为黑色 screen.background(0, 0, 0); // 载入图片到 PImage 物件 logo = screen.loadImage("arduino.bmp"); if (!logo.isValid()) { Serial.println("error while loading arduino.bmp"); } // 从萤幕的左上角开始显示图片 screen.image(logo, 0, 0); } void loop() { }
See also
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.