Results 1 to 3 of 3
  1. #1
    siddanth1 is offline Member
    Join Date
    Feb 2012
    Posts
    2
    Rep Power
    0

    Default Flip Pictures on DrJava

    I am trying to flip a picture horizontaly but only half of it flips here is my code


    public void flipH() {
    for(int x=0;x<getWidth();x++){
    for(int y=0;y<getHeight()/2;y++){
    Pixel p= getPixel(x,y);
    Pixel newP= getPixel(getWidth()-1-x,getHeight()-1-y);
    p.setColor(newP.getColor());


    Please, I want basic answers that everyone knows. Plus I need flipping vertical too.
    }
    }
    }

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: Flip Pictures on DrJava

    By the time you examine pixels with a big y you have already changed the "partner" pixel with a small y. And lost its old value.

    Get yourself some tiddlywinks or small colloured pieces of paper and arrange them into a rectangular pattern. Now flip the pattern. Ask yourself how you you did it. Teh codez will be along the same lines.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default Re: Flip Pictures on DrJava

    You didn't return to the first thread you started.
    Help with Pictures in Java

    Why should we expect better behavior this time around?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 22
    Last Post: 07-25-2012, 09:51 PM
  2. coin flip program
    By chandrasekhar.melam in forum New To Java
    Replies: 5
    Last Post: 09-26-2011, 05:30 PM
  3. Having trouble with code in DrJava
    By jonstewart in forum New To Java
    Replies: 15
    Last Post: 04-07-2011, 11:34 PM
  4. DrJava Error
    By pratzy in forum Other IDEs
    Replies: 7
    Last Post: 04-26-2010, 04:16 AM
  5. help with drJava
    By aw646475 in forum New To Java
    Replies: 0
    Last Post: 03-15-2009, 07:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •