Results 1 to 4 of 4
  1. #1
    Join Date
    May 2011
    Posts
    2
    Rep Power
    0

    Default drawImage im 13 plz help

    I've searched Google now and all the links are purple.

    I'm only 13 so sorry.

    Don't understand this part.

    boolean Graphics.drawImage(Image img,
    int dstx1, int dsty1, int dstx2, int dsty2,
    int srcx1, int srcy1, int srcx2, int srcy2,
    ImageObserver observer);

    The overloads for this method are exactly what I need but not sure how to use them.

    I want to cut up a sprite sheet to animate. Lots of tutorials online but they all seem to skip over the overload parameters.

    Or the code they use as examples is heavily tied to other part of their program.

    Playing with the different parameters results in very confusing results of scaling and shifting.

    I have a sprite sheet about 64x16. This divides into 4 squares 16 in height.

    I don't need to know how to make the frames etc, animation etc.

    Just how to crop a 16x16 image from that sprite sheet and draw it.

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

    Default

    You're barking up the wrong tree :) Check out BufferedImage.getSubimage(...).

    db

  3. #3
    Join Date
    May 2011
    Posts
    2
    Rep Power
    0

    Default

    That worked perfect!

    Is this the fastest way to render cropped images from a sprite sheet?

    Also what are accelerated images?

    This helped me allot by the way! :):):)

  4. #4
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    13 huh? Good for you, I didn't start programming until college. I have a feeling you'll go far in life :D

    Accelerated images can use your graphics card for hardware accelerated drawing... (if your JRE supports it). Sadly, this is pretty much only true in windows.

    Being a Mac user, I have since turned to other means of cross platform hardware acceleration in java - JOGL and more recently LWJGL. Both provide OpenGL mappings for java - LWJGL even adds OpenAL for audio, and some other nifty things (OpenCL).

    I would stay away from those things for now, but write them down somewhere, and do a little research once you feel you've hit the limits of Java2D. For many many applications (games, simple animations, etc...) java2D is just fine!

Posting Permissions

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