Jump to content
Sign in to follow this  

Web Color To Rgba

Recommended Posts

Hi. I want to convert web color to rgba. I have tried this code but it hasn't work correct. For example, web code of red is #FF0000. I want to convert it to RGBA being Binary.

Thank you in advance.

$dGreen = 0xFF0000
$dBlue = BitAND($dColor, 0xFF)
$dGreen = BitAND(BitShift($dColor, 8), 0xFF)
$dRed = BitAND(BitShift($dColor, 16), 0xFF)
$dColorRGBA = StringToBinary($dRed & $dGreen & $dBlue)
Edited by Adele

Share this post

Link to post
Share on other sites

I think you are mixing up the color formats!


Afaik the web color is in format RGB and you need to convert it to ARGB format. Sometimes you can code the web color in format #09C which is the same as #0099CC.


$color_hex_rgb = 0x1188AA
    $Blue = BitAND($color_hex_rgb, 0xFF)
    $Green = BitAND(BitShift($color_hex_rgb, 8), 0xFF)
    $Red = BitAND(BitShift($color_hex_rgb, 16), 0xFF)
    $color_argb = 0xFF000000 + $Red * 0x10000 + $Green * 0x100 + $Blue
    MsgBox(0, "Test", Hex($color_argb, 8))


Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...