Issue with 'GRABSPRITE'.

Previous topic - Next topic

PJBonoVox

Hi all,

I'm using GRABSPRITE in my program to do clipping of sprites that are behind hills and suchlike. I draw the sprite off the edge of the screen onto an RGB(255,0,128) rectangle, grab back the part I need and then draw it back into the game.

The problem is the transparency for these sprites isn't working. It's drawing back onto the screen with the RGB(255,0,128) pixels included.

Any ideas why this would be? The sprites that are drawn directly to the screen respect the transparent colour with no issues.

[ screenshot attached ]

[attachment deleted by admin]

MrTAToad

Might need to use SETTRANSPARENCY just before pasting back/

PJBonoVox

#2
Quote from: MrTAToad on 2011-Dec-24
Might need to use SETTRANSPARENCY just before pasting back/

Thanks for the suggestion. I tried that and no change.

I found a much easier way to do it, which was to set the viewport to the drawing area, draw the sprite and then return it to it's original size.

But this is still an issue I think. Should I log it as bug report Gernot?

MrTAToad

You could also try settransparency before grabbing the graphic - you usually needed to use it, but I can't remember when...

PJBonoVox

Quote from: MrTAToad on 2011-Dec-24
You could also try settransparency before grabbing the graphic - you usually needed to use it, but I can't remember when...

That failed too, but I've found a way round it.

Either way, if you have to use SETTRANSPARENCY then it's a bug. The manual states that default transparent for both LOADSPRITE and GRABSPRITE is RGB(255,0,128).

Ruidesco

State SMOOTHSHADING FALSE before doing anything graphical, or just after your SHOWSCREEN since both SHOWSCREEN and XMAKE_2D reset it to TRUE.

PJBonoVox

Quote from: Ruidesco on 2011-Dec-24
State SMOOTHSHADING FALSE before doing anything graphical, or just after your SHOWSCREEN since both SHOWSCREEN and XMAKE_2D reset it to TRUE.

I need SMOOTHSHADING for these particular sprites. Are you asking me to test it? It's certainly not a permanent solution.

matchy

Seem to be working fine for me. I've also noticed that DRAWRECT magenta then SETTRANSPARENCY magenta, then GRABSPRITE works. CLEARSCREEN magenta or SETPIXEL magenta may not. An alternative is to SAVESPRITE then  SETTRANSPARENCY, LOADSPRITE. Definately turn SMOOTHSHADING on afterwards as there's no reason to have it on initially.

PJBonoVox, please post some test code to avoid disputes!

Ruidesco

Yes, test it at least. This sounds like you are scaling/rotating your sprites and the borders of the sprite proper are mixing with the 0xFF0080 background.
One solution might be making the backgrounds of your source image files really transparent, in which case scaling/rotating would result in half-transparent pixels on the borders as it should.