SharkBait Posted November 14, 2006 Share Posted November 14, 2006 Ok, I am trying to figure this out, if I enter the HEX color of 336699 that would break down to:Red: 51Green: 102Blue: 153Correct?I would need to split the hex value into 3 values and then convert those to their decimal values right?Would I go about splitting them up every 2 characters, and then convert hex -> dec on those 3 seperate values?Or is there a better way to do this?Thanks. Link to comment https://forums.phpfreaks.com/topic/27278-converting-html-colors-to-rgb/ Share on other sites More sharing options...
Barand Posted November 14, 2006 Share Posted November 14, 2006 [code]<?php$color = 0x336699;$r = ($color >> 16) & 0xFF;$g = ($color >> 8) & 0xFF;$b = $color & 0xFF;?>[/code] Link to comment https://forums.phpfreaks.com/topic/27278-converting-html-colors-to-rgb/#findComment-124748 Share on other sites More sharing options...
SharkBait Posted November 14, 2006 Author Share Posted November 14, 2006 Can ya explain what the >> does with the hex values? Link to comment https://forums.phpfreaks.com/topic/27278-converting-html-colors-to-rgb/#findComment-124763 Share on other sites More sharing options...
Barand Posted November 14, 2006 Share Posted November 14, 2006 seehttp://www.phpfreaks.com/forums/index.php/topic,113143.msg459615.html#msg459615 Link to comment https://forums.phpfreaks.com/topic/27278-converting-html-colors-to-rgb/#findComment-124764 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.