Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Flipping a picture 180 degrees

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Flipping a picture 180 degrees

    I made code so that I can copy a smaller picture into a bigger picture which is working but I need to add code to make it flip 180 degrees and I do not know how to go about that.
    This is my code so far it picks up every pixel in the picture.
    public void copyInto(int xWhere, int yWhere, Picture flower)
      {
        for(int x = 0; x < flower.getWidth(); x++)
        {
          for(int y = 0; y < flower.getHeight(); y++)
          {
            int red;
            int green;
            int blue;
            red = flower.getPixel(x,y).getRed();
            green = flower.getPixel(x,y).getGreen();
            blue = flower.getPixel(x,y).getBlue();
            this.getPixel(xWhere + x, yWhere + y).setColor(new Color(red, green, blue) );
          }
        }
      }


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Flipping a picture 180 degrees

    Think about where the top left pixel is, and where it needs to go. Think about the next pixel and where it needs to go.
    How will you get all of the pixels from where they are to where they need to go?

Similar Threads

  1. HELP - placing picture on top of another picture in Java - JLayerPane
    By smasm in forum What's Wrong With My Code?
    Replies: 39
    Last Post: April 27th, 2012, 07:16 PM
  2. Converting a picture made up of 0s and 1s into a colored picture??
    By Kranti1992 in forum Java Theory & Questions
    Replies: 10
    Last Post: November 21st, 2011, 06:25 PM
  3. Flipping mechanism bug
    By CaliforniaCoder1984 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 28th, 2011, 09:40 AM
  4. degrees?
    By rbread80 in forum Java Theory & Questions
    Replies: 2
    Last Post: December 8th, 2010, 09:09 PM
  5. Flipping a coin
    By jimboslice in forum Loops & Control Statements
    Replies: 2
    Last Post: October 18th, 2010, 11:13 AM