============================== EXERCISE: reduce an image > Picture p = new Picture( "/Users/wallingf/Desktop/wallingf-umpr2006.jpg" ); > p.show(); > p.getWidth() 2000 > p.getHeight() 2625 * how can we reduce the image? * write a method to do it... > Picture q = p.reduce(); > q.getWidth() 1000 > q.getHeight() 1312 > q.show(); * still too large, so... > Picture r = q.reduce(); > r.getWidth() 500 > r.getHeight() 656 > r.show(); > Picture s = r.reduce(); > s Picture, filename null height 328 width 250 > s.show(); > r.write( "/Users/wallingf/Desktop/wallingf-500x656.jpg" ); > s.write( "/Users/wallingf/Desktop/wallingf-250x328.jpg" ); * q - 1/4, r - 1/16, s - 1/64! * look at the image sizes... ============================== SLIDES: Media Operations, Nested Loops ============================== EXERCISE: copy a triangle > Picture p = new Picture( "/Users/wallingf/Desktop/sundial.jpg" ); > p.explore(); > Picture q = p.copyRightTriangle( 70, 10, 185 ); > q.show(); * design step by step: rows of pixels * design questions: where to increment lineLength? * alternate design: assume a method! simplifies your code... ============================== SLIDES: Generalizing on Regions ============================== HOMEWORK 1: demo fun drawBorder() methods > Picture p = new Picture( "/Users/wallingf/Desktop/mountain.jpg" ); > p.drawPictureFrame(); > Picture p = new Picture( "/Users/wallingf/Desktop/mountain.jpg" ); > p.border( 20 ); > p.show(); > p.fancyBorder( 20 ); > p.repaint(); > Picture p = new Picture( "/Users/wallingf/Desktop/mountain.jpg" ); > p.drawBorder(); > p.show(); ============================== HOMEWORK 2: demo the images; discuss > Picture mainImage=new Picture("/Users/wallingf/Desktop/wallingf-500x656.jpg"); > mainImage.show(); > Picture imageToEmbed = new Picture( "/Users/wallingf/Desktop/insano.jpg" ); > imageToEmbed.show(); > imageToEmbed Picture, filename /Users/wallingf/Desktop/insano.jpg height 231 width 239 > mainImage.embedImage( imageToEmbed, 5, 5, 220 ); > mainImage.repaint(); * what are the high-level operations? * design: create empty methods, and design the operations one at a time