Raised This Month: $ Target: $400
 0% 

RGB, RGBA, Hex


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 07-07-2013 , 05:43   Re: RGB, RGBA, Hex
Reply With Quote #13

Quote:
Originally Posted by StrikerMan780 View Post
Could one explain how to do this if the Hex color is a string?

I want to convert... say... String:Color[7]="FF0000";

to

r = 255;
g = 0;
b = 0;

StringToIntEx

This work with hex-triplet (FF0000) , but give wrong results with hex-quadruple (FF000000)...
PHP Code:
    new String:ColorString[]="FF0000";
    new 
ColorHexrgb;

    
StringToIntEx(ColorStringColorHex16); // <- Numerical base "16", hexadecimal

    
= ((ColorHex >> 16) & 255);
    
= ((ColorHex >> 8) & 255);
    
= ((ColorHex >> 0) & 255);
    
PrintToServer("%s\n%02X\nr = %i, g = %i, b = %i"ColorStringColorHexrgb); 
And remember, lower case letters give different results than upper case letters, ff != FF *false info

some crappy thing
__________________
Do not Private Message @me

Last edited by Bacardi; 07-07-2013 at 08:45.
Bacardi is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:24.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode