Author |
Topic: semi-transparent sprite (Read 1731 times) |
|
tsh73
Guest
|
 |
Re: semi-transparent sprite
« Reply #6 on: Feb 20th, 2012, 07:25am » |
|
Quote:| The norm in Windows is for sprites/icons to have a pre-multiplied foreground; that is, the sprite's foreground should be multiplied by the alpha value (transparency). You are not doing that in your program, |
|
I was never aware of it. Looks really interesting. Thanks for the info. I will do some tinkering with that, when time permits.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: semi-transparent sprite
« Reply #7 on: Feb 20th, 2012, 09:17am » |
|
on Feb 20th, 2012, 07:25am, Guest-tsh73 wrote:| I will do some tinkering with that, when time permits. |
|
In your slide rule program you could usefully change this line:
Code:to Code: Since the 'transparency' value for the line is set to 192 (lightgray) the amplitude of the 'foreground' shouldn't exceed 63, so that when it is superimposed on a white background it doesn't clip.
You probably won't see any difference, but this change would give a slightly more realistic 'semi-transparent' line if it was superimposed on a more complex background.
Richard.
|
|
Logged
|
|
|
|
tsh73
Guest
|
 |
Re: semi-transparent sprite
« Reply #8 on: Feb 20th, 2012, 10:11am » |
|
Quote:| You probably won't see any difference |
|
Exactly. But it always nice to know "why".
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: semi-transparent sprite
« Reply #9 on: Feb 25th, 2012, 5:40pm » |
|
on Feb 18th, 2012, 5:06pm, Richard Russell wrote:| I take it back: it's not LB misbehaving |
|
I know I keep changing my mind, but LB definitely isn't exhibiting true transparency. Try running this program under both LB (4.04) and LBB (1.80):
Code:'LB vs LBB difference
nomainwin
WindowWidth = 600
WindowHeight = 300
open "test" for graphics_nsb as #gr
#gr "trapclose [quit]"
#gr "down"
loadbmp "bg", "C:\progra~1\libert~1.04\sprites\bg1.bmp"
#gr "background bg"
d=130
for i = 0 to 255
c$=i;" ";i;" ";i
#gr "color ";c$
#gr "line ";i;" ";0;" ";i;" ";d
#gr "color black "
#gr "line ";i;" ";d;" ";i;" ";2*d
next
#gr "Getbmp sprite 0 0 256 ";2*d
#gr "Addsprite sprite sprite"
#gr "Spritexy sprite 0 0"
#gr "SpriteScale sprite 234"
#gr, "Drawsprites"
wait
[quit]
close #gr
unloadbmp "sprite"
unloadbmp "bg"
end Under LBB the transparency works as you would expect, with the sprite being fully opaque on the left and fully transparent on the right, with a gradual transition.
But under LB the sky and the clouds behave as they do in LBB, but the mountains and the rest of the background behave as though the sprite is fully opaque in the left half and fully transparent in the right half:

In other words, depending on the background colour the sprite exhibits both linear transparency (like LBB does now) and binary transparency (like LBB did previously). My mind is boggling at this result - it appears to make no sense at all!
Richard.
|
|
Logged
|
|
|
|
|