Jump to content

Web Color To Rgba


Adele
 Share

Go to solution Solved by UEZ,

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
Link to comment
Share on other sites

  • Solution

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.

RGB to ARGB:

$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))
Br,

UEZ

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...