PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Transparent GIFs and GapiSurfaces - is it a problem?

I have GIFs with transparency. Will GapiDraw recognize transparent areas and set/use the color key according to them? I tried to use such images - but no luck.. Even if I pick the pixel from the corner of the image and set it as color key the image still show garbage in transparent areas. When I make this GIF without transparensy, all works OK.
I have many such images in my java games and I would like to just use them, without any conversion. Can you suggest a solution?
Just save it as a normal Gif without transparency then use
mysurface.SetColorKey(RGB(255,255,255));

Of course you would want to use the RGB values for your actual color. I prefer 0,255,0 for perfect green, but alot of people like 255,0,255 for magenta.

Ohh, also in the bltfast or blt function you have to add the GDBLTFAST_KEYSRC command.

backbuffer.BltFast(x,y,&mysurface,&rcRect, GDBLTFAST_KEYSRC,NULL);
DillRye wrote:
Just save it as a normal Gif without transparency then use
mysurface.SetColorKey(RGB(255,255,255));

Of course you would want to use the RGB values for your actual color. I prefer 0,255,0 for perfect green, but alot of people like 255,0,255 for magenta.

Ohh, also in the bltfast or blt function you have to add the GDBLTFAST_KEYSRC command.

backbuffer.BltFast(x,y,&mysurface,&rcRect, GDBLTFAST_KEYSRC,NULL);


Yes, I did exactly as you described. Yes, it works. But I have hundreds af transparent sprites.... uuhh. I thought there is a kind of "automatic" transparency detection for GIF's - at least this GIF feature supposed to be automatically detected....
Hm. I guess I could "switch on" transparancy support in GapiDraw. Basically it will replace the transparent color in your GIF with the currently selected color key.

The reason it wasn't added in 1.02 was that until recently the color key was discarded each time the surface was created / recreated.

Since 1.03 will have an internal switch (color key is set / not set), adding proper support for transparent GIFs is simple.

Wait two days to convert all your images and download 1.03 when it's out...
Hmm. Basically it wasn't as easy as I thought. The GIF decoder built into all Pocket PCs (IMGDECMP.DLL) does not in itself decode GIFs correctly.

The way IMGDECMP works now is so that all transparent parts of a GIF image are rendered with a white color (regardless if you ask it to specifically use another color). When Pocket Internet Explorer draws a transparent GIF it simply replaces all these white pixels in the transparent GIF (including the mask background which has become white during the rendering process) with the background image.

This has the effect that if you have white pixels in your GIF image they will simply be replaced by the background. I have attached a picture below illustrating how this looks like in Internet Explorer:

Image

So, the solution to your problem is either:

(1) You could try and set the color key to RGB(255, 255, 255) and hope that you don't have any white pixels in your transparent GIFs. This way they will load correctly with GapiDraw 1.03 without having to modify them
(2) Batch convert all images into another format.

By the way.. You are aware that a license is required if you want to use GIF images in your product? It is very simple to scan your file for GIF images, and it is currently done by robots on the Internet. I would strongly suggest that noone uses GIF images for anything really, both due to the patent and now also since the GIF decoder in all Pocket PCs are corrupt.
This patent on GIF is exactly the reason why you should use imgdecmp.dll to decompress your GIF images... Microsoft as a license for it's decompression code.
Ok. I did some reading on the issue and apparantly it's ok to use and distribute GIF files freely, but not to develop an own GIF compressor/decompressor without permission. I thought commercial use of GIF images as such was forbidden..

By the way. Have you found any solution to the masking issues of IMGDECMP.DLL? Setting crTransparentOverride won't work. I also tried using a custom DC for palette in the DecompressImageInfo but it made no difference. Neither does changing the color depths...