• Advertisement
Sign in to follow this  

Java - Image Blitting Function

This topic is 4347 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all, I am writing a 2D tile game in C++ using SDL. So for my tiles, I have a few image files that have several tiles per image. I use SDL_Rects and blit the tile I need off that image and onto the main screen. For my map editor, I want to use Java and Swing because that's what we are working with in my classes. I was just wondering if Java has anyway of being able to take part of an image and cutting it out and placing it inside another Panel. My idea was the load the tileset image, then on the left hand side have a series of JPanels, one for each tile. When you click one of the JPanels, it would set the "ink" to that tile, then on the right side is where you draw the map. When you click a tile on the map it will draw it with whatever tile you have selected as the "ink." I'd like the user to be able to see what they are doing, so it'd be nice to be able to show them the exact tile they are drawing. I'd like to use the same tile sheets for the real game and the editor. Any ideas are welcome. Thanks, Chris

Share this post


Link to post
Share on other sites
Advertisement
I think the getSubimage() method in the BufferedImage class is what you're looking for.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement