Sprite on screen transparency problem ...

Just starting out? Need help? Post your questions and find answers here.
marc_256
Enthusiast
Enthusiast
Posts: 749
Joined: Thu May 06, 2010 10:16 am
Location: Belgium
Contact:

Sprite on screen transparency problem ...

Post by marc_256 »

Hi,

for my new CAD/CAM program I use a lot of sprites,

1) Create windowed screen
2) I create sprites
3) Draw all the stuff on it, also some images in .PNG (icons) with Alpha channel.
4) I display the toolbars on the screen
5) on the screen I add the cross cursor (mouse posX and mouse posY)

All works fine if I do the follow:

1) DisplayTransparentSprite(ToolBar1, 100, 100, 80)
2) DisplayTransparentSprite(ToolBar2, 100, 150, 80)
3) DisplayTransparentSprite(ToolBar3, 100, 200, 80)

4) DisplaySprite(Mouse1, MouseX, MouseY)


Image


If mouse is on a toolbar (example toolbar2)

2) DisplayTransparentSprite(ToolBar2, 100, 150, 255)

to highlight the toolbar and change the cross cursor in pointer cursor.

works fine if I use

4) DisplaySprite(Mouse2, MouseX, MouseY)

Image

If I use:

4) DisplayTransparentSprite(Mouse2, MouseX, MouseY, 255)

I have the following problem
the cursor is no more alpha blended on the screen
is it OR alpha blended
OR transparent

Image

What must I do to make the cursor transparent and alpha blended ?

Thanks,
marco
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Sprite on screen transparency problem ...

Post by #NULL »

difficult to say without some code, but here are some points:

Code: Select all

4) DisplaySprite(Mouse2, MouseX, MouseY)
you are probaly using TransparentSpriteColor() for that sprite to have the transparency working?
but on mouseover you are using DisplayTransparentSprite(), which needs the sprite to be created with the #PB_Sprite_AlphaBlending flag and the alpha channel to be prepared correctly. I had some problems once if used TransparentSpriteColor() in combination with an alpha channel. try the following:
- always create the sprite with the #PB_Sprite_AlphaBlending flag
- don't use TransparentSpriteColor() on the sprite
- before drawing on the sprite clear the alpha channel:

Code: Select all

DrawingMode(#PB_2DDrawing_AllChannels)
Box(0, 0, w, h, $00000000)
DrawingMode(#PB_2DDrawing_AlphaBlend)
...
- always display the sprite using DisplayTransparentSprite(..., alpha).
marc_256
Enthusiast
Enthusiast
Posts: 749
Joined: Thu May 06, 2010 10:16 am
Location: Belgium
Contact:

Re: Sprite on screen transparency problem ...

Post by marc_256 »

Hi #NULL,

I did al kinds of tests with DrawingMode() and mixing these modes.
with the same results.
So, I do my png drawings with GIMP.
end export these to png with alpha channel.

I go to look this side ...
maybe the alpha channel is not correct ?

thanks,
Marc
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8433
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Sprite on screen transparency problem ...

Post by netmaestro »

What would help the most is if you could post a working snippet and a couple of images used by it that shows the problem. If you can do that someone will find a way to solve it pretty quick. As it is your request is too vague to get results imho.
BERESHEIT
Post Reply