Custom background compression

Started by UpperKEES, April 22, 2010, 12:26:07 AM

Previous topic - Next topic

UpperKEES

I've been playing around with custom backgrounds for my maps and have a few questions for Virgil regarding this:

1. When I compose a custom image, I always resize it to 700 x 480 pixels, the size of a CW map. Then I save it as a .png file, because these have a better quality than .jpg images. I noticed that the map editor compresses my backgrounds anyway, probably because of the file size. A bit of a shame, as I try to keep the quality as good as possible, but I understand you like to reduce network traffic and download times. What file size is optimal (and won't get compressed any further)? Compressing one time will probably give much better results than doing this in 2 steps.

2. To my surprise I noticed that some .jpg files showed a better quality than the same image saved as .png. Is this because you have to compress the latter even more, or do you use a better compression algorithm for .jpg files? What do you recommend me to use?

3. Do you have any other recommendations regarding file size, format, color depth, resolution and so on? (I'm not referring to contrast and use of colors, as I realize that it's more important for a map to be playable than look nice; I hate it when I can't see what I'm doing).

Thanks in advance! :)
My CW1 maps: downloads - overview
My CW2 maps: downloads - overview

knucracker

The file format for the background image you start with doesn't really matter that much.  I take the image, load it, and set it as a Bitmap object.  When the map is saved, I take the bitmapData from the Bitmap object, JpgEncoder(85) it, then encode it in the encrypted save game file.
If the image is too large (or small) it gets scaled to 700x480 when it is loaded into the Bitmap.

So in terms of quality, the better the image you start with the better off you will be.  The file size of the original image doesn't really matter.  The only way to improve final quality is for me to change the hard coded JPG compression ratio, or to use images that jpg compress well (images with less noise).

Now I could easily change the JPG compression ratio, but probably no so much that it will make too much of a difference (not without ending up with maps that could be over a meg big)


UpperKEES

Thanks for your explanation.

When I like to compose a custom background that really fits the map format, I'm forced to crop and resize to 700x480 first, to make certain parts match the block size, so I end up with a rather small image anyway.

After using it in the map editor, I am sometimes disappointed by the remaining quality of the used textures. Would it be possible to use the JpgEncoder only when the bitmap object is above a certain size, like 500 KB? And maybe improve the compression from 85 to 90%?

If you would consider this, please let me know the chosen size threshold....
My CW1 maps: downloads - overview
My CW2 maps: downloads - overview

UpperKEES

Romkyns has been so kind to describe how he used Photoshop to create a very nice custom background for a gorge map, see here for a quick tutorial.

Unfortunately the quality of the image when loaded into the game was disappointing; that's why he never bothered to do it again, so I really hope less (or different) compression will be used for custom backgrounds in game 2.
My CW1 maps: downloads - overview
My CW2 maps: downloads - overview

knucracker

There will be less compression in game 2 as well as the upcoming final patch for CW1.  I'm less phobic about big custom map files than I used to be now that I know how the custom games get used and played.  So quality of the background image is worth paying for.

UpperKEES

My CW1 maps: downloads - overview
My CW2 maps: downloads - overview