Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Combining Images  (Read 1315 times)
0 Members and 1 Guest are viewing this topic.
Offline wutalife

Junior Newbie




Java games rock!


« Posted 2005-01-17 15:53:26 »

Hello everyone. I'm working on a tile-based game, but it is running extremely slowly. I'm hoping you all can help me out with speeding it up.

Right now, the background is made up of dozens of invididual tile images that are read from a file. I create a BufferedImage called background and then draw all the tiles onto the BufferedImage using g.drawImage. Since the background never changes after it is first created, I then just draw the background onto the screen whenever it updates.

However, I found the program ran faster if I drew the individual tiles to the screen for each update rather than the background BufferedImage. I'm assuming I did something wrong, because it doesn't make sense that a lot of small images would be drawn faster than one big image.

Is there a problem with the way I created the background BufferedImage? I appreciate any help anyone can give.
Offline Ceranith

Senior Newbie





« Reply #1 - Posted 2005-01-17 16:52:15 »

I don't know how you're creating your images, but images greater than 256x256 aren't going to be accelerated anyway. So it being slower is to be expected.
Offline gamehacer2000

Senior Newbie




Me? I'm no one; yet, i'm somebody.


« Reply #2 - Posted 2005-01-17 16:52:39 »

Actually drawing several small images is faster. The memory consumption per image is width*height*depth. A 640x480  image at 16-bit depth takes up 600 KB of space. Add in the amount of space for your tiles and a huge chunk of ram is being taken up. Also, the BufferedImage probably is not being accelerated (It's being created in System Ram). My advice is either draw onto a VolatileImage which so long as you have a mediocre graphics card will be accelerated or get rid of the background image all together.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline wutalife

Junior Newbie




Java games rock!


« Reply #3 - Posted 2005-01-17 21:48:24 »

Thanks for the help. I kept the tiles as BufferedImages and drew them onto a VolatileImage, which I then display. This made things a lot faster.

But now I'm running into another problem. I want to display semi-transparent images on top of the background image, so it would give one of the tiles a reddish or bluish tint, but it displays the semi-transparent BufferedImage as opaque. This didn't happen when the background was  BufferedImage. Is it possible to display a semi-transparent BufferedImage on a VolatileImage?
Offline gamehacer2000

Senior Newbie




Me? I'm no one; yet, i'm somebody.


« Reply #4 - Posted 2005-01-17 22:34:47 »

It should be possible to draw semi-transparent tiles onto a VolatileImage. However, the VolatileImage you are drawing onto can not be transparent unless you want to lose hardware accleration (Support for hardware acceleration of translucent and transparent VolatileImages is not completed yet.) Hopefully with Mustang, Sun will have complete support for hardware accleration of images.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (37 views)
2014-09-24 16:13:29

Pippogeek (29 views)
2014-09-24 16:12:22

Pippogeek (18 views)
2014-09-24 16:12:06

Grunnt (42 views)
2014-09-23 14:38:19

radar3301 (24 views)
2014-09-21 23:33:17

BurntPizza (61 views)
2014-09-21 02:42:18

BurntPizza (30 views)
2014-09-21 01:30:30

moogie (36 views)
2014-09-21 00:26:15

UprightPath (49 views)
2014-09-20 20:14:06

BurntPizza (52 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!