Convert 8-digit hex colors to rgba colors?

前端 未结 2 1575
我寻月下人不归
我寻月下人不归 2020-11-29 05:55

Everything I\'ve found on this subject simply converts the hex to rgb and then adds an alpha of 1. I want to get the intended alpha from the hex digits as well.

A c

2条回答
  •  再見小時候
    2020-11-29 06:32

    Here is a little tooltip for you :

    In this case #DCDCDC8F the DC is alpha = 220,

    Hex to Decimal [ DC ]:

    1. first place D = 13 * 16^1 = 208
    2. second place C = 12 * 16^0 = 12
    3. sum = 12 + 208 = 220

    then 220 / 255 = 0.86 opacity.

    enter image description here

    The bytes are stored in memory on a little-endian machine in the order AABBGGRR

    Check this : http://www.statman.info/conversions/hexadecimal.html

提交回复
热议问题