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 3 of 3

Thread: how to flip image vertically

  1. #1
    Member
    Join Date
    Oct 2012
    Posts
    133
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default how to flip image vertically

    lets say i am print a image on screen. with (x1,y1,x2,y2,sx1,xy1,sx2,sy2)

    g.drawImage(player_image, x, y, x+width, y+height
    0, 0, 30, 20 ,Sprite_Sheet.m1);

    so how would i flip this image vertically is there a forumla that i can use?
    for ex to scale image i have to do 2*x and 2*y.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,332
    Thanks
    181
    Thanked 829 Times in 772 Posts
    Blog Entries
    5

    Default Re: how to flip image vertically

    Did you try and rotate the image around its center axis? This requires to translate to the center, rotate a particular angle (in this case 180 degrees), draw the image, then reverse the initial translation.

  3. The Following User Says Thank You to copeg For This Useful Post:

    hwoarang69 (November 7th, 2012)

  4. #3
    Member
    Join Date
    Oct 2012
    Posts
    133
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default Re: how to flip image vertically

    ah ic.
    i just want to make sure if i have the step right.

    AffineTransform tx = AffineTransform.getScaleInstance(1, -1);

    tx.translate(0, 0); //translate to center

    //roate image here
    g2d.drawImage(...);

    //undo roate image here

Similar Threads

  1. How tp printing array elements vertically through loop.
    By bikes_28 in forum Loops & Control Statements
    Replies: 1
    Last Post: November 6th, 2012, 12:51 PM
  2. [SOLVED] Please help me with the Coin flip rogram.
    By nikhilrudrangi in forum Java Theory & Questions
    Replies: 1
    Last Post: October 7th, 2012, 10:10 PM
  3. Replies: 1
    Last Post: August 5th, 2012, 09:28 PM
  4. Replies: 2
    Last Post: February 14th, 2011, 04:36 PM
  5. How to create a coin flip program
    By mrsaucy in forum Java Theory & Questions
    Replies: 1
    Last Post: December 20th, 2010, 04:31 AM