






Mrs. Yvonne Rountree
Here is my copyKatie method.
public void copyKatie()
{
String sourceFile =
FileChooser.pickAFile();
Picture sourcePicture = new Picture(sourceFile);
Pixel sourcePixel = null;
Pixel targetPixel = null;
// loop through the columns
for (int sourceX = 0, targetX = 0;
sourceX sourcePicture.getWidth();
sourceX=sourceX+4, targetX++)
// loop through the rows
for (int sourceY = 0, targetY = 0;
sourceY sourcePicture.getHeight();
sourceY=sourceY+4, targetY++)
{
// set the target pixel color to the source pixel color
sourcePixel = sourcePicture.getPixel(sourceX,sourceY);
targetPixel = this.getPixel(targetX,targetY);
targetPixel.setColor(sourcePixel.getColor());
}
}



Link to this Page