Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

25. Images I

154 views

Published on

Published in: Education
  • Be the first to comment

  • Be the first to like this

25. Images I

  1. 1. From last time… • translate(), rotateX(), rotateY(), rotateZ() • scale(), pushMatrix(), popMatrix()
  2. 2. Demo! Directional Light
  3. 3. Demo! MovieMaker
  4. 4. CAP Images I
  5. 5. Processing Classes PShape PFont PVector PGraphics PImage
  6. 6. 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”);
  7. 7. 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
  8. 8. Demo! loadImage()
  9. 9. 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
  10. 10. Demo! tint()
  11. 11. 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()
  12. 12. Demo! The pixels[] Array
  13. 13. Locating Pixels • Linear pixel location:! int location = X + Y * WIDTH; • This can be used to get or set pixels
  14. 14. Demo! Locating Pixels
  15. 15. For next time… • Read Shiffman, pp. 264–274 (Images II)! • Homework 4, due Monday (Mathematics, Translation, & Rotation) This may be tough—start early!

×