25. images i
TRANSCRIPT
From last time…
• translate(), rotateX(), rotateY(), rotateZ()
• scale(), pushMatrix(), popMatrix()
Demo!Directional Light
Demo!MovieMaker
CAP 3032
Images I
Processing ClassesPShape
PFont
PVector
PGraphics
PImage
PImage Class• A subclass of PGraphics
• We declare and initialize a PImage just like any other class:!
PImage img;
img = loadImage(“filename.png”);
PImage img = loadImage(“filename.png”);
loadImage()• loadImage() calls the constructor for us!
• createImage() creates a blank image (all 0’s)!
• Don’t use it in the draw loop (use it in setup)!
• Like any other class, you can store many images in a PImage[]
• You must provide a filename or URL
Demo!loadImage()
tint()• tint() changes the brightness and opacity of
pixels in an image!
tint(155); // affects overall brightness
tint(155, 132); // affects brightness & opacity
tint(0, 25, 255); // affects RGB brightness
tint(0, 25, 255, 132); // affects RGB & opacity
Demo!tint()
The pixels[] Array• We can load the pixels array of our sketch
window with loadPixels()
• We can load the pixels of any image with img.loadPixels()
• We can manipulate those pixels, and then save them with updatePixels() img.updatePixels()
Demo!The pixels[] Array
Locating Pixels
• Linear pixel location:!
int location = X + Y * WIDTH;
• This can be used to get or set pixels
Demo!Locating Pixels
For next time…
• Read Shiffman, pp. 264–274 (Images II)!
• Homework 4, due Monday (Mathematics, Translation, & Rotation) This may be tough—start early!