Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-16-2009, 09:26 PM
Member
 
Join Date: Apr 2009
Posts: 2
Rep Power: 0
Cain is on a distinguished road
Default Problems drawing a section of an image onto another image.
Hello,

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.setClip(32,32,16,16)
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 09:50 PM.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 04-17-2009, 01:44 AM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,483
Rep Power: 8
Fubarable is on a distinguished road
Default
cross-posted in the Swing forum.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Drawing a shape on an image Yoruichi Java 2D 2 03-29-2009 03:49 PM
Drawing on an image kratra New To Java 0 02-06-2009 09:58 PM
Need help getting java drawing match to image. kiduut New To Java 9 12-28-2008 02:55 PM
[SOLVED] Image drawing, saving Goseph Java 2D 2 12-21-2008 08:36 PM
drawing an image to an offscreen image hunterbdb Java 2D 9 10-30-2008 07:17 PM


All times are GMT +2. The time now is 04:40 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org