Results 1 to 5 of 5
  1. #1
    Lionlev is offline Senior Member
    Join Date
    May 2012
    Posts
    172
    Rep Power
    3

    Default Really need help with this one.. (Clopping the image using drawImage)

    Ok so I've created a little "game" when you can move and jump, and I used the drawImage like this:
    Java Code:
    g.drawImage(myImage,(int) Window.charX,(int) Window.charY,50,50,null);
    That was a square image, no problems with that.
    But then I've decided to make some animations, basically I've made one image (png) that stores few frames of the characters, and I tried to crop it like this:
    Java Code:
    g.drawImage(myImage,(int) Window.charX,(int) Window.charY,80,120, 0, 0, 40, 60, null);
    Basically, the image gone crazy... When I jump, some part of it standing still and the other jumping (in another words, it's scaling)
    So, how exactly do I use it?
    WARNING I am Russian so it's possible that I wont understand you correctly...

  2. #2
    arieltal is offline Member
    Join Date
    Sep 2012
    Posts
    34
    Rep Power
    0

    Default Re: Really need help with this one.. (Clopping the image using drawImage)

    not sure what type of image you use, but i use BufferedImage and then -> image.getSubImage(x,y,width,height);
    this way i refer only to the frame i need

  3. #3
    Lionlev is offline Senior Member
    Join Date
    May 2012
    Posts
    172
    Rep Power
    3

    Default Re: Really need help with this one.. (Clopping the image using drawImage)

    I use BufferedImage aswell
    So that image.getSubImage(x,y,width,height); crops the image?
    WARNING I am Russian so it's possible that I wont understand you correctly...

  4. #4
    arieltal is offline Member
    Join Date
    Sep 2012
    Posts
    34
    Rep Power
    0

    Default Re: Really need help with this one.. (Clopping the image using drawImage)

    yes.

  5. #5
    Lionlev is offline Senior Member
    Join Date
    May 2012
    Posts
    172
    Rep Power
    3

    Default Re: Really need help with this one.. (Clopping the image using drawImage)

    Quote Originally Posted by arieltal View Post
    yes.
    Thanks, works like a charm!
    WARNING I am Russian so it's possible that I wont understand you correctly...

Similar Threads

  1. Problem with drawImage
    By matevos in forum AWT / Swing
    Replies: 1
    Last Post: 08-06-2012, 11:44 PM
  2. Replies: 1
    Last Post: 11-30-2011, 05:18 PM
  3. Does not recognize drawImage method...
    By Koba in forum New To Java
    Replies: 13
    Last Post: 11-21-2011, 05:06 AM
  4. DrawImage with transparency ?
    By mrhid6 in forum AWT / Swing
    Replies: 2
    Last Post: 10-02-2011, 12:58 AM
  5. drawImage im 13 plz help
    By pseudohawtcakes in forum New To Java
    Replies: 3
    Last Post: 05-17-2011, 09:07 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
  •