Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (601)
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 2458 times)
0 Members and 1 Guest are viewing this topic.
Offline elricscripts

Junior Newbie





« Posted 2010-08-03 09: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: 56
Projects: 11


Monkey for a head


« Reply #1 - Posted 2010-08-03 09: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

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #2 - Posted 2010-08-03 10: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!
Legends of Yore - The Casual Retro Roguelike
Offline elricscripts

Junior Newbie





« Reply #3 - Posted 2010-08-03 20: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

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #4 - Posted 2010-08-03 21: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 07: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

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #6 - Posted 2010-08-05 03: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 04: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

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #8 - Posted 2010-08-09 13: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.

 

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

The first screenshot will be displayed as a thumbnail.

rwatson462 (30 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (42 views)
2014-12-09 22:41:13

BurntPizza (76 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (51 views)
2014-12-03 16:27:13

CopyableCougar4 (48 views)
2014-11-29 21:32:03

toopeicgaming1999 (115 views)
2014-11-26 15:22:04

toopeicgaming1999 (103 views)
2014-11-26 15:20:36

toopeicgaming1999 (30 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!