반응형

"Prepare your image"

This note deals with loading images from processing and simple manipulation.


△In order to load the image, you need an image to load. Please prepare an image format file such as jpg and png. You can load as soon as you prepare it on the path where the processing executable is located.

△Atter importing the PImage class, specify the image variable from setup() to loadimage(). After that, it is called image() from draw().

PImage photo; //Class call

void setup() {
  size(700, 500); //Execution window size
  photo = loadImage("note04_img.jpg"); //Image load
}

void draw() {
  image(photo, x, y); //Load the top left of the image to be located in the x, y coordinates.
}

△The image is loaded well to the (0, 0) coordinates. But the size of the original image is big, so I can only see a part of it.

△Image size can be adjusted by adding parameters when calling.

image(photo, x, y, w, h); //You can specify the horizontal (w), vertical (h) size of the image you want to call.

△Now I can see the whole thing clearly.

△If you change the starting point of the image from the default coordinate of 0,0 to 350,0, the starting point will change.

image(photo, 0, 0); //coordinate default position is upper left (0, 0).

△You can also call up the image twice like crop.

△It's very easy, right? In the next note, we'll cover simple and various editing functions such as image filters.

[Processing 3.5.4] #4 Image load fin.

반응형

+ Recent posts