Results 1 to 8 of 8
  1. #1
    sgthale is offline Member
    Join Date
    Apr 2011
    Posts
    48
    Rep Power
    0

    Thumbs up Best type of image to use?

    So I am making a game and the land and items are small .gif images (non-animated). All images are preloaded at the beginning of the game. Are .gifs the best choice to use for the game in terms of performance? .png? .jpg? Or does it even matter at all?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default

    I don't think there is a difference in their usage once they are loaded into an image object.

  3. #3
    David M. is offline Member
    Join Date
    Apr 2011
    Location
    Kansas
    Posts
    26
    Rep Power
    0

    Default

    If you have transparency you'll probably want gif or png. Just throwing that out there.

  4. #4
    kammce's Avatar
    kammce is offline Senior Member
    Join Date
    Dec 2010
    Location
    California
    Posts
    194
    Rep Power
    4

    Default

    Which ever one you like. I like to use pngs but that is my prerogative. They have the richest looks but you sacrifice memory ( both long term [hard drive] and short term [RAM] memory). A good way to use pngs with your game is to optimize it. If you really want to keep the file sizes small, use gif files. This is just my opinion though.
    My API:
    Java Code:
    cat > a.out || cat > main.class

  5. #5
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    I'm no expert, but don't pngs offer better transparency (proper alpha) *and* better compression than gifs?

    Of course your code should be written in such way as to be format agnostic. Onnly code that wants to get dirty with the source file's bytes should even be aware of the format - an image is an image not a gif or a png or etc. That being the case you should be able to swap one format for another, measure the difference, and post back with The Answer.

  6. #6
    kammce's Avatar
    kammce is offline Senior Member
    Join Date
    Dec 2010
    Location
    California
    Posts
    194
    Rep Power
    4

    Default

    Quote Originally Posted by pbrockway2 View Post
    I'm no expert, but don't pngs offer better transparency (proper alpha) *and* better compression than gifs?

    Of course your code should be written in such way as to be format agnostic. Onnly code that wants to get dirty with the source file's bytes should even be aware of the format - an image is an image not a gif or a png or etc. That being the case you should be able to swap one format for another, measure the difference, and post back with The Answer.
    Oh yes! Pngs are much better with alpha channels than GIFs. Alpha channels are not existent in JPEGs. And since PNGs, gifs, and JPEGs are the most popular, I choose from them most often. BMPs could be used but I never use them. Hey! maybe I am missing out.

    What I meant by, a sacrifice in memory, is that PNGs can be full of clutter, so using optimization tools like PNGCrusher and OptiPNG could decrease their size which would optimize your game. Flash and Gimp have a knack for making their PNGs very large in file size.

    But besides the initial size of the program itself, once you have loaded the images, it really does not matter. Java is really good with getting all the images ready to be painted to the GUI at any given time.
    My API:
    Java Code:
    cat > a.out || cat > main.class

  7. #7
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    Ah, I didn't know about pngs being liable to bloat. It doesn't surprise me - I looked over the spec a couple of times and it did seem quite "feature rich". The answer in that case, as you suggest, is to use external tools to make the image data files lean and mean.

    Depending on circumstances load time might make a difference. (Although I - speaking with the authority of total ignorance - would suspect that loading across the internet, eg, would depend on how *many* connections had to be made. Go jar!)

  8. #8
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    Ah, I didn't know about pngs being liable to bloat. It doesn't surprise me - I looked over the spec a couple of times and it did seem quite "feature rich". The answer in that case, as you suggest, is to use external tools to make the image data files lean and mean.

    Depending on circumstances load time might make a difference. (Although I - speaking with the authority of total ignorance - would suspect that loading across the internet, eg, would depend on how *many* connections had to be made. Go jar!)

    -------

    [Edit] Also Norm's point above is good.
    Last edited by pbrockway2; 08-15-2011 at 08:20 AM.

Similar Threads

  1. Replies: 4
    Last Post: 08-01-2011, 10:29 AM
  2. How save Image BMP Binary type?
    By shakall in forum SWT / JFace
    Replies: 3
    Last Post: 12-22-2009, 01:50 PM
  3. using instanceof to get Object type and parent type?
    By xcallmejudasx in forum New To Java
    Replies: 2
    Last Post: 11-06-2008, 06:24 PM
  4. [SOLVED] Cast string type to int type
    By GilaMonster in forum New To Java
    Replies: 9
    Last Post: 09-17-2008, 10:43 AM
  5. Replies: 0
    Last Post: 06-23-2008, 11:25 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •