PocketMatrix forums

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

Opacity with Color Key

Hi all,

I'm stuck with an annoying problem:
I'm blitting a surface with color key, as many others, but I'm trying to do a fade-out effect. By the docs, you could do that simply with a blit with GDBLT_KEYSRC | GDBLT_OPACITY flags, which should do the effect.
My problem is that it seems that GapiDraw is doing the operations in the reverse order: ie. instead of applying opacity AFTER keysrc, it's applying opacity BEFORE keysrc which makes the undesired effect of having the sprite tend to the transparent color (255, 0, 255 in my case, which makes the sprite progressively becoming a pink rectangle) instend of blend with the BG.

Has anyone got any ideas?
Thx in advance.

Ricardo
hum looks strange because I use it quite often and I had no problem with it.
Post the source code (the surface creation and blitting parts), there must be a mistake. Or maybe the actual color key of your image isn't 255,0,255
The SetColorKey's where in init methods and are working well without the, but I've tried to concentrate the code in one block just to be sure, with the same result. The code is of the uttermost simplicy and should work, so here goes:

RECT clip;
clip.bottom = 100;
clip.left = 0;
clip.right = 10;
clip.top = 0;

GDBLTFX flags;
surface.CreateSurface(GDSURFACE_CLEAR, "test.png");
surface.SetColorKey(RGB(255,0,255));
dst->SetColorKey(RGB(255,0,255));
flags.dwOpacity = 128;

dst->Blt(&clip;, &surface;, NULL, GDBLT_KEYSRC | GDBLT_OPACITY, &flags;);


What I get is the a pink colorized sprite instead of a half opaque key-colored sprite.
Thank you for the attention!
What is dst? Is that your backbuffer, why are you setting its color key?

That maynot have anything to do with your problem, but it looked suspect to me.
Yes, dst is the backbuffer. And you're right, that line isn't doing anything there, I just created the example to put it here with all the init the system does, and that one wasn't necessary, but I doesn't get in the way (it behaves the same commented, as it should since I'm not bliting the backbuffer anywhere, of course).
So, it's not that one. I've tried a black rectangle instead of a surface and I get the same behaviour - a pinker rectangle. Thx!
You might take a look at the jojosoft demo as it does alot of blend effects. While it was based on GD1.04, the methodology is the same.