CSI Chap 5 Codes

CSI Chap 5 Codes - public void copyKatiesFace() cfw_ String...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 public void copyKatiesFace() { String sourceFile = FileChooser.getMediaPath("KatieFancy.jpg") Picture sourcePicture = new Picture(sourceFile) Pixel sourcePixel = null Pixel targetPixel = null // loop through the columns for(int sourceX = 70, targetX = 100 { // loop through the rows for (int sourceY = 3, targetY = 100 { // set the target pixel color to the source pixel color sourcePixel = sourcePicture.getPixel(sourceX,sourceY) targetPixel = this.getPixel(targetX,targetY) targetPixel.setColor(sourcePixel.getColor()) } } } public void copy(Picture sourcePicture, int startX, int startY, int endX, int endY, int targetStartX, int targetStartY) { Pixel sourcePixel = null Pixel targetPixel = null // loop through the x values for(int x = startX, tx = targetStartX x < endX x++, tx++) { // loop through the y values for(int y = startY, ty = targetStartY y < endY y++, ty++) { // set the target pixel color to the source pixel color sourcePixel = sourcePicture.getPixel(sourceX,sourceY)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/07/2011 for the course CSI 201 taught by Professor Doanne during the Spring '08 term at SUNY Albany.

Page1 / 6

CSI Chap 5 Codes - public void copyKatiesFace() cfw_ String...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online