25. images i

16

Click here to load reader

Upload: joseph-murphy

Post on 03-Jul-2015

40 views

Category:

Education


3 download

TRANSCRIPT

Page 1: 25. Images I

From last time…

• translate(), rotateX(), rotateY(), rotateZ()

• scale(), pushMatrix(), popMatrix()

Page 2: 25. Images I
Page 3: 25. Images I

Demo!Directional Light

Page 4: 25. Images I

Demo!MovieMaker

Page 5: 25. Images I

CAP 3032

Images I

Page 6: 25. Images I

Processing ClassesPShape

PFont

PVector

PGraphics

PImage

Page 7: 25. Images I

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”);

Page 8: 25. Images I

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

Page 9: 25. Images I

Demo!loadImage()

Page 10: 25. Images I

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

Page 11: 25. Images I

Demo!tint()

Page 12: 25. Images I

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()

Page 13: 25. Images I

Demo!The pixels[] Array

Page 14: 25. Images I

Locating Pixels

• Linear pixel location:!

int location = X + Y * WIDTH;

• This can be used to get or set pixels

Page 15: 25. Images I

Demo!Locating Pixels

Page 16: 25. Images I

For next time…

• Read Shiffman, pp. 264–274 (Images II)!

• Homework 4, due Monday (Mathematics, Translation, & Rotation) This may be tough—start early!