+ 2
Can anybody taught me how to convert rgb values into hexadecimal value.
4 Antworten
+ 3
learn to convert decimal to hexadecimal conversion that's all it is..
for example u have seen for white color
rgb is (255,255,255)
its equivalent hexcode is #ffffff;
as per the the decimal to hexadecimal conversion rule f stands for 15 in decimal
and ff stands for 255
and the conversion process is as follows:
ff= 15*16+15*1= 255
here 16 is the base value
+ 1
the explanation behind my code:
rgb values are base 10 numbers between 0 and 255. hexadecimal numbers are base 16 numbers between 0 and F where A=10 B=11....F=15 in base 10.
if you think of it in a base 2 manner (binary) every value or rgb is coded on 8 bits between 0000 0000 and 1111 1111.
and every hexadecimal number is coded on 4 bits. so each value of rgb is equivalent to 2 values of hexadecimal.
now in order to convert from rgb to hexadecimal, you need to get the modulus (remainder of a division) of every value by 16 (ex 255 % 16) and then divide it by 16. if your rgb value is 15 or below, remember to put a 0 before the second number.
for example: 20 % 16 = 4. 20/16 = 1. 1%16 = 1. so result from rgb value 20 in hex would be 14
0
i also made a site using html css and javascript which can be used to help
https://code.sololearn.com/WQ07xmADJTl5/?ref=app
0
hope im not too late
https://code.sololearn.com/W1JcAy8XtCoj/?ref=app