Java Lab7 - targetY)...

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

View Full Document Right Arrow Icon
Sheet1 Page 1 public void modPic() { Pixel{}pixelArray = this.getPixels() Pixel pixel = null for(int index = 0 { pixel = pixelArray[index] pixel.setGreen(pixel.getRed()) pixel.setBlue(pixel.getGreen()) } } public Picture scaleUp(int numTimes) { Picture targetPicture = new Picture(this.getWidth() * numTimes, this.getHeight() * numTimes) Pixel sourcePixel = null Pixel targetPixel = null int targetX = 0 int targetY = 0 //loop through the source picture columns for (int sourceX = 0 sourceX < this.getWidth() sourceX++) { //loop through the sorce picture rows for (int sourceY = 0 sourceY < this.getHeight() sourceY++) { //get the source pixel sourcePixel = this.getPixel(sourceX, sourceY) //loop copying to the target y for (int indexY = 0 { //loop copying to the target x for (int indexX = 0 { targetX = sourceX * numTimes + indexX targetY = sourceY * numTimes + indexY targetPixel = targetPicture.getPixel(targetX,
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

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

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: targetY) targetPixel.setColor(sourcePixel.getColor()) } } } } return targetPicture Sheet1 Page 2 } Assignment 3 public Picture frame(int frameSize, Color frameColor) { public Picture mirror() { int width= this.getWidth() int mirrorPoint = width / 2 Pixel leftPixel = null Pixel rightPixel = null for (int y = 0 { for (int x = 0 { leftPixel = getPixel(x, y) rightPixel = getPixel(width - 1 - x, y) rightPixel.setColor(leftPixel.getColor()) } } return targetPicture } Color tempColor = rightPixel.getColor() rightPixel.setColor(leftPixel.getColor()) leftPixel.setColor(tempColor) Sheet1 Page 3 index < pixelArray.length index++) indexY < numTimes indexY++) indexX < numtimes indexX++) Sheet1 Page 4 y < getHeight() y++) x < mirrorPoint x++) // not sure about the Color type here -- check that...
View Full 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 / 4

Java Lab7 - targetY)...

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

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