Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Transparent Color

Author
Message
NumericFrog
13
Years of Service
User Offline
Joined: 25th Oct 2011
Location: France
Posted: 25th Oct 2011 23:07
Is there a way to use ARGB instead of plain RGB to paint a color on the screen (or bitmap) which would be say 50% transparent and let the background show?
I saw an old thread with functions that claimed to do that but didn't.(RGBA, ARGB and SetAlpha functions)
This is not a 3D matter but a simple 2D one and it seems that there is no way to use the Alpha channel in DBPro.
Please help!
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 26th Oct 2011 00:07
Make your overlay (the image/paint you want transparent) into a sprite. Then set the sprite's alpha. Works great.
If it is just a plain ol' solid colour (eg a lense tint) you can create a single sprite consisting of an RGB(255,255,255) solid block. Stretch it over the screen, set the alpha and manipulate the tint using the sprite diffuse function. Another option is to manipulate you individual sprites' diffuse (uneccessary resource consumption both for coder and machine).
Im on my mobile right now but I'll post an example tomorrow if nobody has posted one yet.

zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 26th Oct 2011 00:35 Edited at: 26th Oct 2011 00:39
if you are talking about using the 2d drawing commands combined with the INK command to set the color, you can use ARGB hex values
for example:

The channels are 0xAARRGGBB
AA=Alpha RR=Red GG=Green BB=Blue

Each component/channel has a value from 0 = 00 to 255 = FF
- There are plenty of charts of RGB colors in hex online
- Most paint apps have refs for the hex values
- Or, use windows calculator in Programmer [View] to convert Dec to Hex
- Or, use an online dec to hex converter

some basic examples:
so 100% opaque bright white is
INK 0xFFFFFFFF


100% opaque black black is
INK 0xFF000000


approx 50% transparent green is
INK 0x7F00FF00

=======

***Note: I have found that under certain circumstances the first call to INK needs to have the forground and the background color set in order for it to work.

INK 0xAA2300C7, 0xFF000000

Your signature has been erased by a mod please reduce it to 600 x 120.
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 26th Oct 2011 10:24
Try this example. Copy code and run.



NumericFrog
13
Years of Service
User Offline
Joined: 25th Oct 2011
Location: France
Posted: 26th Oct 2011 11:59
Thank you guys I'll try your options. I knew about ARGB, only it didn't want to work even with bitmap formats that supports it, but I think the first Ink call might do the trick.
Thanks again for your help, I'll let you know how I get on
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 26th Oct 2011 20:19


If you prefer not to enter your values hexadecimally


"Why do programmers get Halloween and Christmas mixed up?"
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 27th Oct 2011 15:31
Or if you'd prefer not worrying about manipulating those numbers in different ways, you can install my plug-ins which include a version of the RGB function that accepts 4 values instead of the normal 3.

It doesn't replace the existing function, it's available alongside it.

TheComet
17
Years of Service
Recently Online
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 27th Oct 2011 21:25
And if you don't want to use sprites, but use paste image, just add an extra flag to the command:

paste image ImageNum, PosX, PosY, 1



TheComet

NumericFrog
13
Years of Service
User Offline
Joined: 25th Oct 2011
Location: France
Posted: 30th Oct 2011 13:35
Hello,
Thank you for your suggestions.

NonZero Your sprite works a treat! thanks. I paint my transparent colours on a separate Bitmap and create a sprite from the image. Produces blobs of transparent colour in function of Brush size. Very good!

IanM I downloaded your Matrix1Util... Well it's mind boggling to say the least! However your function RGB (Alpha,R,g,b) doesn't want to work for me. RGBA gives the right amount of alpha, BOX works OK, but FILL won't work with or without border. I have only tried those. Is there an initialisation for the Plug-In? BTW, I've DBPro 7.6. I unzipped the Plug-in in my DBPro directory but I had to copy manually the Plug-ins User DLLs and the Keywords.

TheComet Maybe I should explain what I want to do: I want to paint a colour over another but still see the bottom colour. Not like having the "transparent" colour not drawn, like in paste image function when you use the transparency flag.

Thank you all for your help..

Login to post a reply

Server time is: 2024-11-24 00:28:23
Your offset time is: 2024-11-24 00:28:23