Blitting transparency troubles

Started by Cowbox, November 23, 2012, 03:59:20 PM

Previous topic - Next topic

Cowbox

:D Me again,

I've got a HUD on my game at the moment that uses blitting of bitmap images as textures to put images on the display.

I'm slightly confused as to the behavior I'm seeing though.

The documentation (and just, the way the methods seem to suggest they work) implies that something like this:
buffer.blit(btn1,0,0,0,0,32,32,32,32,[b]0[/b],false);
would render the image with all areas of 0,0,0 as transparent.

However, it renders all areas with colours values less than 16,16,16 (so 15,15,15; 14,14,14; 13,13,13; etc.) as transparent. D:

Is there a way to stop this? (I've checked what colour depth I've been using, and switched variables around: none of it seems to make any difference.)

The other thing in conjunction with this is that it'd be nice if there was a way to set a particular colour to be used as transparent rather than 0,0,0 -> 16,16,16 - I mean, if I used 255,0,255 (a colour I'm not using) for transparency , then all black values would be available.

I keep looking through the documentation for a method along the lines of:
setTransparentColor(int r,int g,int b)
or something. :(

Please enlighten me :D! There has to be something I'm doing wrong. xD

KittenKoder

The transparency key values have a variance due to JPEG inaccuracies, try using pngs if you want perfect. ;)
When life throws you lemons, make lemon juice, then drop life into a pile of razors and pour the lemon juice over it.

EgonOlsen

Yes, that's the engine's default way to compensate for compression artifacts. If you need more control, create an image with an alpha channel, save it as PNG and load it via the constructors that have the useAlpha attribute.

Cowbox

Ah yes!

I knew I was being a retard xD

I had them saved as .png images already, I just wasn't loading with the transparency flag turned on.

Now everything works nice and awesomely. :D

KittenKoder

Quote from: Cowbox on November 23, 2012, 08:27:16 PM
Ah yes!

I knew I was being a retard xD

I had them saved as .png images already, I just wasn't loading with the transparency flag turned on.

Now everything works nice and awesomely. :D

Not retarded, you just made a typo from the sound of it. Typos happen, it's the reason we test things. Yes, PNG is a great format for images, in spite of it being a slightly larger file, you can make per pixel translucency, a wonderful format.
When life throws you lemons, make lemon juice, then drop life into a pile of razors and pour the lemon juice over it.