Results 1 to 2 of 2
  1. #1
    Cain is offline Member
    Join Date
    Apr 2009
    Rep Power

    Default Problems drawing a section of an image onto another image.


    I seem to be having some difficulty copying part of one image to another image.

    BufferedImage source // 160 pixels x 224 pixels
    BufferedImage dest // 16 pixels by 16 pixels

    What I want to do is copy a 16x16 tile from source into dest. Lets say I want to copy tile 2,2 (pixels 32-48, 32-48)

    example :

    Graphics g = dest.getGraphics();
    g.drawImage(source, 0, 0, 16, 16, 32, 32, 16, 16, null);

    This bit of code doesn't work because it seems to try to squish the entire source image into the destination image. Then I found some code that says use Graphics.setClip():

    Graphics g = dest.getGraphics();
    g.drawImage(source, 0, 0, null)

    But that doesn't work either.

    I must be missing something simple because it can't be that hard to pick out a 16 x 16 tile from an image thats 160 x 224 pixels big.

    EDIT: I'm a retard but I managed to fix the problem. It seems as though the problem is between the chair and the keyboard on this one.
    Last edited by Cain; 04-16-2009 at 08:50 PM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

Similar Threads

  1. Drawing a shape on an image
    By Yoruichi in forum Java 2D
    Replies: 2
    Last Post: 03-29-2009, 02:49 PM
  2. Drawing on an image
    By kratra in forum New To Java
    Replies: 0
    Last Post: 02-06-2009, 09:58 PM
  3. Need help getting java drawing match to image.
    By kiduut in forum New To Java
    Replies: 9
    Last Post: 12-28-2008, 02:55 PM
  4. [SOLVED] Image drawing, saving
    By Goseph in forum Java 2D
    Replies: 2
    Last Post: 12-21-2008, 08:36 PM
  5. drawing an image to an offscreen image
    By hunterbdb in forum Java 2D
    Replies: 9
    Last Post: 10-30-2008, 07:17 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