Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (408)
games submitted by our members
Games in WIP (293)
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  
  Working with a collection of images... advice?  (Read 2070 times)
0 Members and 1 Guest are viewing this topic.
Offline elricscripts

Junior Newbie





« Posted 2010-08-03 11:41:05 »

In a JAR i have images that are a collection of smaller images.  For example vehicles contains 20x20 images like "tank facing forward", "facing backward", "car forward", etc.

I'm constantly accessing these and displaying them.  I'd appreciate feedback on good ways to use/manage this collection. 

Like, would it be better to separate them into files?  Is there better code than loading the whole image then only using a few of the images?  Faster methods?  Any sample code out there?

Thanks
Offline Orangy Tang

JGO Kernel


Medals: 48
Projects: 11


Monkey for a head


« Reply #1 - Posted 2010-08-03 11:47:17 »

Faster methods? 

Faster how? Faster load time? Faster image drawing speed? Or faster to work with when editing / drawing the images while developing?

Why exactly do you have multiple images in one big image in the first place? What does this gain you? What's wrong with the current method?

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Eli Delventhal
« League of Dukes »

JGO Kernel


Medals: 39
Projects: 12


Game Engineer


« Reply #2 - Posted 2010-08-03 12:48:10 »

Yeah, you want to make a sprite atlas. Google it.

See my work:
OTC Software
Games published by our own members! Check 'em out!
Try the Free Demo of Revenge of the Titans
Offline elricscripts

Junior Newbie





« Reply #3 - Posted 2010-08-03 22:56:24 »

Faster how? Faster load time? Faster image drawing speed? Or faster to work with when editing / drawing the images while developing?
At the moment, it takes a long time to load the whole image.  Once it's in memory, it's fast and easy to grab each image i need.  This is okay, but takes a moderate of memory and load time.  I just thought there might be a better way that others are dealing with thousands of source images.

Why exactly do you have multiple images in one big image in the first place? What does this gain you? What's wrong with the current method?
The only thing i gain is not having a jar filled with too many images.  I really don't gain much.  What's the current method?
Offline Eli Delventhal
« League of Dukes »

JGO Kernel


Medals: 39
Projects: 12


Game Engineer


« Reply #4 - Posted 2010-08-03 23:26:22 »

Yeah, you want to make a sprite atlas. Google it.
Wink

http://www.lmgtfy.com/?q=what+is+a+texture+atlas

Basically you make a really big image, pack a bunch of small images in it, and then store the image location data in a text file or XML file or something. Then you load that image once and store it in memory. Instead of drawing the whole thing, you just draw the portion you want. This is what professional video games do.

See my work:
OTC Software
Offline elricscripts

Junior Newbie





« Reply #5 - Posted 2010-08-04 09:26:32 »

Yeah, you want to make a sprite atlas. Google it.
Thanks for the help!  Knowing the term (texture atlas/sprite atlas) helped me to find some examples and explanations.  Like: http://rbwhitaker.wikidot.com/texture-atlases-1

I still have the issue with my map tile set of over 1000 images being a large file to load or a long list of images in the JAR.  I think i'll play around with converting BufferedImages to byte arrays and storing the images to a file.
Offline Eli Delventhal
« League of Dukes »

JGO Kernel


Medals: 39
Projects: 12


Game Engineer


« Reply #6 - Posted 2010-08-05 05:37:47 »

Thanks for the help!  Knowing the term (texture atlas/sprite atlas) helped me to find some examples and explanations.  Like: http://rbwhitaker.wikidot.com/texture-atlases-1

I still have the issue with my map tile set of over 1000 images being a large file to load or a long list of images in the JAR.  I think i'll play around with converting BufferedImages to byte arrays and storing the images to a file.
Storing it as an actual image will almost always be cheapest because they've got smart compression algorithms in there. I recommend PNG.

If you've got a lot of assets, make big atlases and a lot of them. Then just use them intelligently (don't swap between them more than you need to). There's really nothing else you can do.

See my work:
OTC Software
Offline elricscripts

Junior Newbie





« Reply #7 - Posted 2010-08-08 06:05:25 »

Storing it as an actual image will almost always be cheapest because they've got smart compression algorithms in there. I recommend PNG.
Thank you... makes allot of sense to me.  Glad i asked Smiley
Offline Eli Delventhal
« League of Dukes »

JGO Kernel


Medals: 39
Projects: 12


Game Engineer


« Reply #8 - Posted 2010-08-09 15:51:45 »

Thank you... makes allot of sense to me.  Glad i asked Smiley

And and use a utility like PNGCrush to really bring them down to size.

See my work:
OTC Software
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars and Titan!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (113 views)
2013-05-17 21:29:12

alaslipknot (123 views)
2013-05-16 21:24:48

gouessej (152 views)
2013-05-16 00:53:38

gouessej (145 views)
2013-05-16 00:17:58

theagentd (158 views)
2013-05-15 15:01:13

theagentd (142 views)
2013-05-15 15:00:54

StreetDoggy (186 views)
2013-05-14 15:56:26

kutucuk (210 views)
2013-05-12 17:10:36

kutucuk (210 views)
2013-05-12 15:36:09

UnluckyDevil (215 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.122 seconds with 20 queries.