QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: random1 on September 27, 2021, 02:20:02 pm
-
Hi all
I load a image and then want to print some text over the image, the problem is that I need
to set the background color so that the text prints transparently over the image. I have tried
matching using the color dialog box with no luck. I was thinking there was a way to get the
color of a pixel. I could make a transparent image of the text and then lay that over the image
but wanted to know if there is a easier way.
Thanks
R1
-
_PRINTMODE _KEEPBACKGROUND
Try that for transparent printing.
-
I need
to set the background color so that the text prints transparently over the image.
What Cobalt says or when you set color for text to print, set background color to transparent eg
color &hffffffff
, &h00000000
' white fore color on transparent background
OR
-
_PRINTMODE _KEEPBACKGROUND
PRINT "Some text"
_PRINTMODE _FILLBACKGROUND
-
To get a pixel color use:
pixelColor~&
= Point(x
,y
) 'unsigned long is best type for colors
-
'_keepbackground'? Cool Tha'ts good to know... I had cobbled together a work-a-round. I defined a variable 'trans' and gave it the colour _rgba32(0,0,0,0) (fully transparent black). Then when printing text... Color foreground, trans. So much for that idea. Keepbackground is obviously a time saver... Cool. I am curious also... How does keepbackground detect the colour of the background?
-
. I am curious also... How does keepbackground detect the colour of the background?
It doesn't. Without _KeepBackground, both characters and bg are drawn pixel by pixel. With _KeepBackground only letters are drawn, so it literally keeps the BG untouched.
You can also draw transparent letters and opaque BG with _PrintMode _OnlyBackground
-
Cool... Looks like I need to do some more 'help' surfing... lol
Thank you.
J
-
My trick for no background is usually just:
COLOR , 0
0, in 32-bit mode, is 0 alpha, 0 red, 0 green, 0 blue — it’s transparent nothing!
Another quick trick is the polar opposite of that: COLOR -1
-1, in 32-bit mode, because of overflow calculations, is 255 alpha, 255 red, 255 green, 255 blue — it’s solid white!
-1 = bright white.
0 = transparent. (Not to be confused with black, which has 255 alpha and not 0.)
Two quick values to easily pop in when are where needs.
-
Thanks for all the replies.
_PRINTMODE _KEEPBACKGROUND
and
_PRINTMODE _FILLBACKGROUND
Work perfect for my needs, I need to get out more. 0 = transparent, have to try that one.
R1