Question
This method below currently sets the color of all of the pixels in the given Picture to black. It needs to only sets the pixels
This method below currently sets the color of all of the pixels in the given Picture to black. It needs to only sets the pixels on the left half of the image to black. In other words, all pixels with an x coordinate less than half the width should be set to black. What should be changed in the for loops below so that the method does what is needed
public void setLeftHalfOfPicture(Picture pic)
{
for (int x = 0; x < pic.getWidth(); x++)
{
for (int y = 0; y < pic.getHeight(); y++)
{
pic.getPixel(x, y).setColor(Color.BLACK);
}
}
}
Step by Step Solution
3.38 Rating (151 Votes )
There are 3 Steps involved in it
Step: 1
public void setLeftHalfOfPicturePicture pic int ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started