Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  Compressing PNG's  (Read 2859 times)
0 Members and 2 Guests are viewing this topic.
Offline caseyd

JGO n00b
*

Posts: 9



« on: 2009-02-21 16:00:35 »

Hey, I am working on two entries right now for the contest, but am having trouble bringing the size of one my PNG's down. Any advice?
I was thinking about trying out SuperPackME but can't find it anywhere, the original site seems down and has been for about a week or two now.

Any ideas/suggestions would be most appreciated. Thanks.

- Casey
Offline Abuse

JGO Kernel
*****

Posts: 1866
Medals: 5


falling into the abyss of reality


« Reply #1 on: 2009-02-21 16:12:15 »

The best way to store images very much depends on what they look like.

Obviously the most efficient solution is to not need them at all.
So, could they be replaced with primitives?
Or, could you generate them programmatically?

If not, how many images are there?
For one/few image(s) the overhead of a custom packing implementation can be prohibitively expensive.
If however you have many images that have common palettes and/or few colours, SuperPackME or the like can give big savings.

As you should never have more than 1 file inside the jar, are you already combining these 2 png's into a single combined image?
(and then embedding this combined image inside the class file as a UTF8 encoded String or custom class attribute)
Offline caseyd

JGO n00b
*

Posts: 9



« Reply #2 on: 2009-02-21 16:35:22 »

My current PNG is 256x32 pixels, saved as 8bit that contains 8 32x32 sprites.

Quote
As you should never have more than 1 file inside the jar, are you already combining these 2 png's into a single combined image?
(and then embedding this combined image inside the class file as a UTF8 encoded String or custom class attribute)

I currently have a single PNG, my class file and the manifest.  How do I embed this image inside the class file? Do you mean breaking it down into a hex array of bytes and building this image off of that?
Games published by our own members! Go get 'em!
Offline Cero

JGO Neuromancer
****

Posts: 1050
Medals: 18



« Reply #3 on: 2009-02-21 16:45:28 »

you may try "pngquant"
command line software

Offline caseyd

JGO n00b
*

Posts: 9



« Reply #4 on: 2009-02-21 17:06:16 »

I will give that a shot. I like that is command line since I can automate it easier than a gui program.
Offline Markus_Persson

JGO Kernel
*****

Posts: 2092
Medals: 10


Mojang Specifications


« Reply #5 on: 2009-02-21 17:07:32 »

My current PNG is 256x32 pixels, saved as 8bit that contains 8 32x32 sprites.

That's 32kb of raw data!

Play Minecraft!
Offline caseyd

JGO n00b
*

Posts: 9



« Reply #6 on: 2009-02-21 17:15:29 »

Yeah, I know. But there must be a way, because Kevin Glasses 4k Hack game used just about as many images and he was loading from a file based on his source code. I must be doing something wrong during the compression phase.

On a side note I am using 7zip to compress the original files, than running the jar through ProGuard and have been using JoGA on the result from that. JoGA has been having problems with my jar's for some reason lately saying that it has detected the use of the reflection API, which I am not using...
Offline moogie

JGO Strike Force
***

Posts: 775
Medals: 5


Java games rock!


« Reply #7 on: 2009-02-21 17:31:51 »

I had developed an image compression technique similar to SuperPackMe for my 2007 4k entry.

http://www.java-gaming.org/topics/sprite-compression-tool/17876/view.html

Offline moogie

JGO Strike Force
***

Posts: 775
Medals: 5


Java games rock!


« Reply #8 on: 2009-02-21 17:42:28 »

I have found a version of superpackME on my computer... it is not original so i am not sure whether it is in a working state:

http://javaunlimited.net/hosted/moogie/SuperPackME.zip
Offline caseyd

JGO n00b
*

Posts: 9



« Reply #9 on: 2009-02-21 17:49:30 »

moogie: Thanks for the links. I will try these out very soon!
Games published by our own members! Go get 'em!
Offline Eli Delventhal
« League of Dukes »

JGO Kernel
*****

Posts: 3573
Medals: 44


Game Engineer


« Reply #10 on: 2009-02-24 00:11:25 »

Here's what I did:

1) Make the image that I wanted.
2) Go to "Save Optimized As..." in Adobe Photoshop.
3) Select PNG 8 bit.
4) Drop the colors down to something like 8.
5) Notice what happens to my image. Decide on what colors should be used in place of others.
6) Edit my image so things come out looking nice with just those 8 colors.

This usually takes my sprite sheet down to about 500 bytes.

See my work:
OTC Software
<br />
Currently Working On:
Secret project...
Quote from: _Riven
I edit JGO in production, because I simply don't waste time writing bugs
Offline OverKill

Sr. Member
**

Posts: 336


Java games rock!


« Reply #11 on: 2009-02-24 03:26:21 »

Been a while but try these:
* prefer 'full transparency' over alpha (if that was what it was called, it just reduced the amount of data)
* use (reduced) palette

recommended software:
pngcrush (do brute force all methods, strip out unneeded headers)
pngtrans (but watch out, can break the pngs)

Other optimisations:
* metatiles :
Split up a larger image into sections and look for duplicates.
Can help with images that contain a lot of 'plain space'.

Drawback is that you would have to recompose the image or render each tile individually (so don't choose a too small tile size)

* group up textures that contain the same palette:
better compression

* pak zem up together
Even if you are stuck with multiple single files, it might be better to simply dump them all into one file that is then used in the jar.
This is kinda what tar.gz does because the compression of one single larger file is often better then the sum of multiple smaller ones.
Actually smaller files can result in larger packed archives. (nicely visible by zip UI progs such as the one by 7zip)

Offline Abuse

JGO Kernel
*****

Posts: 1866
Medals: 5


falling into the abyss of reality


« Reply #12 on: 2009-02-24 06:08:45 »

If you are sticking with a seperate image in the jar, then you should take a look at pngout.

You should also try changing to Gif, as inside a jar file 8bpp gifs tend to compress better than the equivalent optimised png.

This is mostly due to both zip(jar) & png using the same zlib compression algorithm (deflate).
Gif on the other hand uses lzw compression, allowing for a degree of synergy when it is recompressed by the jar files zlib.

Don't get me started on the 'brilliance' of making Java's standard image format & container format the same compression algorithm....
Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.094 seconds with 21 queries.