PocketMatrix forums

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

Need help: losing transparent color on 2 color images

I need a little help from an experienced GAPIDraw user.

I have an offscreen bitmap I use to cache image data (tiles). Some of the tiles contain a transparent color set as RGB(1,1,1). The data that is stored on the cache comes from PNG files that are loaded as needed. The PNG files are 256 color indexed images, and are initially loaded into their own surface and then a portion is blit and cached on the caching surface.

The caching bitmap has the color key set to RGB(1,1,1) for use as a source blit surface. The images I load do not have their color key set, and when I blit them to the cache image I do not set the blit flags to 0.

The problem I'm seeing is that in some cases, the blit from the PNG surface to the cache is not replicating the the RGB(1,1,1) transparent color stored in the original png files.

The problem appears to only be on images that contain 2 colors. I have tile set images that contain mask data, and this mask data is either RGB(0,0,0) or RGB(1,1,1). So the images have only 2 colors. On these images, the RGB(0,0,0) is not getting rendered, nor is the mask color RGB(1,1,1). It appears to treat the entire image as transparent RGB(1,1,1).

If I turn off the GDBLTFAST_KEYSRC parameter, the entire tile renders as RGB(0,0,0) (if I do a screen grab an examine the pixels) However, 0,0,0 is not set to transparent in any of my code.

The palette has RGB(0,0,0) as palette index 0, and RGB(1,1,1) as palette index 1.

I use the same RGB(1,1,1) color in other tiles that have more colors and it appears to work just fine as the transparent pixels are not drawn.

I assume this is a problem with my PNG file, or an issue with GAPIDraw thinking that palette index 0 is always transparent, which is not true.

Could anyone give me some suggestions on how to get around this issue? I'm thinking about just storing the 2 colors PNG's as 16 bit images instead of paletted images and see if that works, but of course I'm trying to save space when they are decompressed and 8 bit palettes are the way to go for this.

I'm using NETPBM utils with a perl script to convert/scale the original artwork to PNG's from BMP's and so far it has worked well.

Also, I'm doing my testing/debugging on a Windows XP PC.

If you know of this problem and a solution, a response would be much appreciated.

Thanks,
Byron
Pejo Software - Per · 19 Sep 2004, 07:22 UTC
Altough I have not used GapiDraw for a while I think I know what your problem is. The RGB macro works with 24-bit color and for example on a Pocket PC the color depth is only 16 bits. This means that RGB(1,1,1) will be the same color as RGB(0,0,0).
However I see that you are testing your work on a PC and I am not sure what color depth GapiDraw uses there. GapiDraw can very well be using 16 bit color representation there also to allow optimizations.
Thanks for the reponse.

The netpbm tools made it easy enough to test a theory. I remapped all RGB(1,1,1) to rgb(255,0,255) and changed my color key and the black masks started working.

The oddity I see is that this only seemed to affect my 2 color images. I used 1,1,1 with other images that had more colors and the masking worked fine, and many of the images contained color 0,0,0 as well, which stayed intact. But when I use those 2 in a 2 color image, the file that loaded had its 1,1,1 pixels converted to 0,0,0.

There is something not quite right in the loading of 2 color images.

Byron