Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (511)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (577)
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  
  Compressing PNG's  (Read 4745 times)
0 Members and 1 Guest are viewing this topic.
Offline caseyd

Senior Newbie





« Posted 2009-02-21 21: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 Knight


Medals: 13


falling into the abyss of reality


« Reply #1 - Posted 2009-02-21 21: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)

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline caseyd

Senior Newbie





« Reply #2 - Posted 2009-02-21 21: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! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Cero
« Reply #3 - Posted 2009-02-21 21:45:28 »

you may try "pngquant"
command line software

Offline caseyd

Senior Newbie





« Reply #4 - Posted 2009-02-21 22: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 Wizard


Medals: 16
Projects: 19


Mojang Specifications


« Reply #5 - Posted 2009-02-21 22: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

Senior Newbie





« Reply #6 - Posted 2009-02-21 22: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 Knight


Medals: 13
Projects: 6
Exp: 10 years


Java games rock!


« Reply #7 - Posted 2009-02-21 22: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 Knight


Medals: 13
Projects: 6
Exp: 10 years


Java games rock!


« Reply #8 - Posted 2009-02-21 22: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

Senior Newbie





« Reply #9 - Posted 2009-02-21 22:49:30 »

moogie: Thanks for the links. I will try these out very soon!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #10 - Posted 2009-02-24 05: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
Offline OverKill

Junior Duke




Java games rock!


« Reply #11 - Posted 2009-02-24 08: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 Knight


Medals: 13


falling into the abyss of reality


« Reply #12 - Posted 2009-02-24 11: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....

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
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.

Longarmx (50 views)
2014-10-17 03:59:02

Norakomi (40 views)
2014-10-16 15:22:06

Norakomi (31 views)
2014-10-16 15:20:20

lcass (36 views)
2014-10-15 16:18:58

TehJavaDev (67 views)
2014-10-14 00:39:48

TehJavaDev (65 views)
2014-10-14 00:35:47

TehJavaDev (58 views)
2014-10-14 00:32:37

BurntPizza (72 views)
2014-10-11 23:24:42

BurntPizza (44 views)
2014-10-11 23:10:45

BurntPizza (84 views)
2014-10-11 22:30:10
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

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!