Page 1 of 1

PNG support

PostPosted: Dec 18, 2002 @ 8:12pm
by Viking

PostPosted: Dec 19, 2002 @ 4:29am
by adde
Well, I guess Kzinti should answer this one, but until he does, I'll try my best.

PF:s LoadImage function uses the IMGDECMP.DLL supplied by IE5 on PPC to decode either a .BMP, .GIF, .JPG, .PNG or .XBM image into an intermediate 24 bit bitmap. This bitmap is used to create a Surface object and then it's memory is deallocated. LoadImage returns a pointer to the Surface it created (which needs to be deleted before exiting PF).

Because BMP doesn't support transparency, then neither transparent GIF:s nor alpha-channel PNG:s will be transparent in PF.

To get transparent behaviour out of PF, you save your images in a non transparent format having a special color for the transparent pixels. Remember the palette index of this color and then use Surface::SetColorMask(palette_index) to make the Surface transparent. To disable transparency of a Surface, use palete_index=-1 (this is the default color mask).

Sounds simple doesn't it. But there is a catch. The palette index has to be in regards to the standard palette used by the system. And this can be more or less hard to find out. I mostly use black as the transparent color since it always has index 0 and it has worked so far. And if you need black (#000000) in your image, then use a slightly (you will not notice the difference) brighter black (#030303) since it will get its own palette index (I think).

PostPosted: Dec 20, 2002 @ 4:03am
by Kzinti

PostPosted: Dec 20, 2002 @ 4:06am
by Kzinti

PostPosted: Dec 21, 2002 @ 5:38am
by adde
OK!!! Thanks Kzinti for clearing this up. When I didn't find a palette I just asumed it used the standard palette, but this actually makes much more sense.

Memory overflow when using HUGE images...

PostPosted: Dec 21, 2002 @ 9:53pm
by Viking