I have to mirror a piece of the picture right to left.
Here is what I have:
My picture stays the same everytime I run the code.
I even switch my for loops to see if it would make a difference
but it doesn't. My picture just stays the same.

public void mirrorTemple()
  {
    int mirrorPoint =276;
    //int mirrorPoint = getWidth() / 2;
    Pixel leftPixel = null;
    Pixel rightPixel = null;
    int count =0;
    for(int y = 37; y < 86; y++)
    {
      for(int x = 535; x < mirrorPoint; x++)
      {
        rightPixel = getPixel(x,y);
        leftPixel = getPixel(x, (mirrorPoint + (mirrorPoint - y))); 
        leftPixel.setColor(rightPixel.getColor());
        count = count + 1;
      }
    }
    System.out.println("We copied " + count + " pixels.");
  }

What packages are you using? I don't find the Pixel class in the Java Se API doc.

Have you printed out the x,y locations of the source and target pixels to see if their values are correct?

Here is my entire code.
End yes I tried that but I do not know why its not printing it out.
I keep looking through the code I typed up to mirror a specific area of a picture from left to right.
To mirror a picture right to left would have the same idea right?

import java.awt.*;
import java.awt.font.*;
import java.awt.geom.*;
import java.awt.image.BufferedImage;
import java.text.*;
import java.util.*;
import java.util.List; // resolves problem with java.awt.List and java.util.List

/**
 * A class that represents a picture.  This class inherits from 
 * SimplePicture and allows the student to add functionality to
 * the Picture class.  
 * 
 * Copyright Georgia Institute of Technology 2004-2005
 * @author Barbara Ericson ericson@cc.gatech.edu
 */
public class Picture extends SimplePicture 
{
  ///////////////////// constructors //////////////////////////////////

  /**
   * Constructor that takes no arguments 
   */
  public Picture ()
  {
    /* not needed but use it to show students the implicit call to super()
     * child constructors always call a parent constructor 
     */
    super();  
  }

  /**
   * Constructor that takes a file name and creates the picture 
   * @param fileName the name of the file to create the picture from
   */
  public Picture(String fileName)
  {
    // let the parent class handle this fileName
    super(fileName);
  }

  /**
   * Constructor that takes the width and height
   * @param width the width of the desired picture
   * @param height the height of the desired picture
   */
  public Picture(int width, int height)
  {
    // let the parent class handle this width and height
    super(width,height);
  }

  /**
   * Constructor that takes a picture and creates a 
   * copy of that picture
   */
  public Picture(Picture copyPicture)
  {
    // let the parent class do the copy
    super(copyPicture);
  }

  /**
   * Constructor that takes a buffered image
   * @param image the buffered image to use
   */
  public Picture(BufferedImage image)
  {
    //super(image);
  }

  ////////////////////// methods ///////////////////////////////////////

  /**
   * Method to return a string with information about this picture.
   * @return a string with information about the picture such as fileName,
   * height and width.
   */
  public String toString()
  {
    String output = "Picture, filename " + getFileName() + 
      " height " + getHeight() 
      + " width " + getWidth();
    return output;

  }

  public void mirrorTemple()
  {
    int mirrorPoint =276;

    Pixel leftPixel = null;
    Pixel rightPixel = null;
    int count =0;
    for(int y = 37; y < 86; y++)
    {
      for(int x = 535; x < mirrorPoint; x++)
      {
        rightPixel = getPixel(x,y);
        leftPixel = getPixel(x, (mirrorPoint ( mirorrPoint - y))); 
        leftPixel.setColor(rightPixel.getColor());
        count = count + 1;
        System.out.println("X location " + x);
        System.out.println("Y location " +  y);
      }
    }
    System.out.println("We copied " + count + " pixels.");
  }

  public static void main(String[] args) 
  {
     String fileName = FileChooser.pickAFile();
     Picture pictObj = new Picture(fileName);
     pictObj.mirrorTemple();
     pictObj.explore();
   }

The code you posted does not compile without errors. The first error is the ending } for the class. Adding an ending } then gets many more errors.

The code does not print the y value for the left pixel that is used below:
leftPixel = getPixel(x, (mirrorPoint ( mirorrPoint - y)));

What is the value of: (mirrorPoint ( mirorrPoint - y)

I didn't have an error with compiling the program, I just forgot to copy the bracket into the post.
I would've figure adding this --> (x, (mirrorPoint ( mirorrPoint - y))) would mirror it right to left
Mirroring Left to right is -->((mirrorPoint(mirrorPoint - x)), y)
I do not know what else to do.
I am trying to use my text book as a guide but only explains mirroring from left to right.

I didn't have an error with compiling the program

Where is the class: SimplePicture defined? I get an error there.

What is the value of: (mirrorPoint ( mirorrPoint - y)?
Add a println() that prints out its value so you can see.

Where is the variable: mirorrPoint defined? I get an error there.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.