QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: SMcNeill on December 16, 2019, 02:41:02 pm
-
The command in question: https://www.qb64.org/wiki/DONTBLEND
And the statement in question: Use CLS or _DONTBLEND to make a new surface background _ALPHA 255 or opaque.
And my enquiry: How do we use _DONTBLEND to make a new surface background _ALPHA 255??
From my experience, _DONTBLEND doesn't change alpha levels at all. All it does is let us set a color to exactly what we specify it to be, without blending it into the existing background.
A little test code to showcase the difference in _DONTBLEND and CLS, in regards to opaque backgrounds:
DONTBLEND never changed the background alpha levels, whereas CLS does. Is this a case where the wiki is giving us a wrong bit of information, or am I using the command wrong, or just interpreting something wrong? Exactly how does it "make a new surface background _ALPHA 255 or opaque"?
-
Question 2: WTH is up with the sample code provided?
'CLS
LINE (100, 100)-(500, 500), _RGB32(255, 255, 0), BF
b& = SaveBackground&
PRINT "This is just test junk" PRINT "Hit any key and the text should disappear, leaving us our pretty yellow box." RestoreBackground b&
Exactly what the heck is this supposed to be doing?
"Hit any key and the text should disappear, leaving us our pretty yellow box."...
...Except the text doesn't go anywhere..
I'm completely lost by this wiki entry!
-
I think this is what the wiki code is trying to demonstrate:
'CLS
LINE (100, 100)-(500, 500), _RGB32(255, 255, 0), BF
b& = SaveBackground&
PRINT "This is just test junk" PRINT "Hit any key and the text should disappear, leaving us our pretty yellow box." RestoreBackground b&
At first glance, it appears as if the demo is doing as the original premise states -- it's making the new image opaque, but it's not true. A quick little change can highlight this fact, indisputably:
'CLS
LINE (100, 100)-(500, 500), _RGB32(255, 255, 0), BF
b& = SaveBackground&
PRINT "This is just test junk" PRINT "Hit any key and the text should disappear, leaving us our pretty yellow box." RestoreBackground b&
Notice where I have it print the hex value of point (0,0)? It's NOT FF000000; instead, it's just 0. No red, no blue, no green, no alpha... It's still completely transparent!
So why are we seeing the difference in results that we're getting??
Because we have _DONTBLEND set and that pure transparent color is simply overwriting the white of the text. With blend on, we blend transparent and white, get white, and the text remains...
_DONTBLEND didn't make the new screen opaque, or set it to have 255 alpha. It simply changed our main screen so we didn't blend the transparent color out with the existing color...
Here's a perfect example to prove that: 'CLS
LINE (100, 100)-(500, 500), _RGB32(255, 255, 0), BF
b& = SaveBackground&
PRINT "This is just test junk" PRINT "Hit any key and the text should disappear, leaving us our pretty yellow box."
_BLEND b&
'set the copied image attribute to blend _BLEND 0 'set the current page attribute to blend RestoreBackground b&
If _dontblend had actually changed the background to having 255 alpha, we couldn't just turn blending back on and have it perform with 0 alpha levels as we're seeing.
Unless someone knows something about this command that I don't, I'm inclined to say the wiki is completely off here with what it's documenting for us.
Or am I just missing something obvious here?
-
Here's what I'd suggest changing in the entry:
- If imageHandle& is not valid, an Invalid handle error will occur.
- _DONTBLEND is faster than the default _BLEND. You may want to disable it, unless you really need to use it in 32 bit.
- 32 bit screen surface backgrounds (black) have zero _ALPHA so that they are transparent when placed over other surfaces.
- Use CLS
or _DONTBLEND to make a new surface background _ALPHA 255 or opaque. - Both _SOURCE and _DEST must have _BLEND enabled, or else colors will NOT blend.
And the examples would probably need to be rewritten so they reflect the actual behavior of the command for us. ;)
-
Are you editing it?