I am a high school student. I want to mirror an image horizontally. I have figured out the method to mirror it vertically but I have no idea how to start this task.
I copy and pasted the code from the previous method and was looking for something to edit but have had no luck so far.
public void mirrorHorizontal()
{
Pixel[][] pixels = this.getPixels2D();
Pixel leftPixel = null;
Pixel rightPixel = null;
int width = pixels[0].length;
for (int row = 0; row < pixels.length; row++)
{
for (int col = 0; col < width / 2; col++)
{
leftPixel = pixels[row][col];
rightPixel = pixels[row][width - 1 - col];
leftPixel.setColor(rightPixel.getColor());
}
}
}
How can I change this code to mirror the image horizontally?
Aucun commentaire:
Enregistrer un commentaire