Hi, I was wondering if I can use some of your knowledge to decide what the best (time vs. performance) compression algorithm is for a given type of image.

I'm dealing with a 2D array of ARGB values (therefore 4 bytes per pixel). The image is a screenshot of a flash game which is using vector graphics, and has very few colours, with the colours repeating often.

Here's an example image take from a google search.

Using an inbuilt zlib algorithm I achieved high compression but it took a long time. I'm aware that I could probably compress nearly as well if I take advantage of the image having few colours which are repeated often.

My first attempt was using simple run-length encoding with the sections being 4 bytes (to account for ARGB), this was very quick but didn't compress amazingly well.

Does anyone have any ideas on what algorithms or techniques would work well with this type of image?

In the sample image (make sure you don't use JPG as an input image..!) there are regions with much more different colors than others, and due to anti-aliasing, every pixel in a sequence of N is very likely to be different. RLE is not ideal here.

My suggestion is to have a preprocessing step, analyzing NxN (8x8 or 16x16?) patches of pixels, and *removing* them from the image. You fill those square holes with the pixels in the line just above the hole.

Then you apply DzzD's pixels => line_diff => RLE, which will compress extremely well, due to the lack of the 'noisy patches'.

Then compress the 'noisy patches' with an algorithm more suitable than RLE (GZ or JPG?), and store the coordinates of the patches, so that you know where you should put them back.

I don't know how much this will save you, but it might save a fair chunk.

Hi, appreciate more people! Σ ♥ = ¾Learn how to award medals... and work your way up the social rankings!

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