Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Somebody told me that when a png image is stored in swf, it's separated to several layer, hence the alpha channel can be compressed better. Is it true? Or, once png image is imported into a swf, it's format is changed, e.g converted into bitmap data, and than compressed by swf's compress algorithm. That's, it is not in png format anymore.
I don't know how swf packing its resource, please tell me if you know.

share|improve this question
    
As a note, the compression algorithm used by PNG is actually zlib. png might include some filtering that causes zlib to compress better than just zipping up the raw bitmap though. –  Jari Komppa Jan 13 '11 at 14:06
add comment

1 Answer

up vote 3 down vote accepted

If you add a PNG image in the Flash IDE, you can choose JPEG compression for it. The interesting part about this is, that it will preserve alpha transparency.

So what internally happens is exactly as you describe. The alpha channel and the color information get separated and compressed individually. AFAIK the alpha will always be JPEG compressed whereas I'm not so sure about the image. I suspect that there is some analyzing going on and the algorithm then chooses either PNG or JPEG compression for the color data.

This only applies for the Flash IDE though (eg. Flash CS 5, Flash CS 4, etc.). In Flex, images aren't treated that way. However there's a tool that can do that with any existing SWF. It's called "reducer" and can be found here: http://blog.joa-ebert.com/2009/08/08/reducer/

Actually I encountered some weird behavior using Flex Builder a while back, where I compressed PNG game-assets using ImageOptim but the resulting SWF didn't decrease in filesize like I would have expected. This lead to this question on stackoverflow which isn't answered till today :)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.