grabsprite transperency

Previous topic - Next topic

djtoon

hi
im grabing a sprite that has a part of in in  RGB(255,0,128)
then i grab the sprite but i dont get that part transperent

any ideas why?


code:


SETTRANSPARENCY RGB(255,0,128)

LOADSPRITE "Media/border.png",0

SETSCREEN 320,480,TRUE
ALPHAMODE -1
DRAWRECT 0, 0, 80, 80, RGB(RND(255), RND(255), RND(255))
DRAWSPRITE 0,0,0

GRABSPRITE 99,0,0,80,80
CLEARSCREEN RGB(0,0,0)
DRAWSPRITE 99,0,0
SHOWSCREEN
MOUSEWAIT




Kitty Hello

yes. The transparent pixels are not drawn when you DRAWSPRITE. If you want them to be there when you grab, simply try a DRAWRECT 0,0,999,999,RGB(225,0,128) before you drawsprite. That will draw the pink, but also fill the alpha pixels to the back buffer.

Does that work?

kamakazieturtle

On my XP computer this works fine, but on my Vista and 7 it turns the color RGB(255,0,128) into RGB(128,0,255).

Code (glbasic) Select

FOR A=0 TO 31
FOR B=0 TO 31
SETPIXEL A,B,RGB(255,0,128)
NEXT
NEXT

GRABSPRITE 1,0,0,32,32
SAVESPRITE "Temp.bmp",1
LOADSPRITE "Temp.bmp",1
DRAWSPRITE 1,0,0

SHOWSCREEN

MrTAToad

Yes, its quite possible (and does it here too) :

The color returned can differ up to 13% from the actual value for the pixel. 16 bit colored pixels are especially likely to return incorrect information. The reason for this is that some platforms have 16 bit displays - 24 bits of color information is converted down to 16 bits resulting in a loss of accuracy.

Slydog

#4
I've read about what MrTAToad is referring to, and that may be the case.
Are all three of your test systems using the same display colour depth?

But it's oddly coincidental that it returns the exact reverse of the colour?!
It's like it is referencing the colour bytes in memory in a different order, or the alpha is in the wrong location.

Here's how your original colour with a 255 alpha is stored in memory: (assuming the alpha is placed at the start!)
FF8000FF
aabbggrr

If it was read backwards it would result in what you're seeing, but I'd be surprised if this hasn't been caught before.

[Edit] To further narrow down the cause, you could instead use a colour without '255' in it, such as (192,0,128) to see if the returned 255 is the alpha or the red component.  Unless this only happens with the default transparent colour.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

MrTAToad

I suspect the XP graphics driver is essentially returning OpenGL pixel values differently to Windows 7/Vista - probably a whole lot of reasons for it unfortunately...

kamakazieturtle

I'm pretty sure it is only changing the default transparent color. See I'm storing whole images as an array of hex values. When I draw the image, every color but the transparent show up right. I'll post more later I'm going to mess with changing the transparent color to see if that doesn't help my cause.

MrTAToad

If I remember correctly, you have to use SETTRANSPARENCY before or after the GRABSPRITE

kamakazieturtle

Exactly, I just tested it on my laptop and was going to post it.