1、Load and Display(加载与显示)
Images can be loaded and displayed to the screen at their actual size or any other size.
图像可以按照其实际尺寸或任何其他尺寸加载并显示到屏幕。
PImage img; //Declare variable "a" of type PImage
voidsetup() {
size(640, 360);//The image file must be in the data folder of the current sketch//图片文件必须在当前草稿文件的同一文件夹才能加载成功。//to load successfully
img = loadImage("moonwalk.jpg"); //Load the image into the program
}voiddraw() {//Displays the image at its actual size at point (0,0)
image(img, 0, 0);//Displays the image at point (0, height/2) at half of its size
image(img, 0, height/2, img.width/2, img.height/2);
}
View Code
2、Background Image. (背景图片)
This example presents the fastest way to load a background image into Processing. To load an image as the background, it must be the same width and height as the program.
此示例介绍将加载背景图像的最快方法转换到Processing。 要加载图像作为背景,它必须与程序的宽度和高度相同。
PImage bg;inty;voidsetup() {
size(640, 360);//The bac