conversion problem!
-
how can i convert color form a hex format to a byte format? in other words how to convert from hex to argb thx
-
how can i convert color form a hex format to a byte format? in other words how to convert from hex to argb thx
You mean if you have 0xFFFFFF, how to turn that into argb ? Something like this int color = 0xFFFFFF; byte alpha = (byte)((color && 0xFF000000) << 24); byte red = (byte)((color && 0xFF0000) << 16); byte green = (byte)((color && 0xFF00) << 8); byte blue = (byte)((color && 0xFF))); Something like that. Use the && to strip the other bits, and a bit shift to move it down to be just a byte.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
how can i convert color form a hex format to a byte format? in other words how to convert from hex to argb thx
If you have it as a string use ColorTranslator.FromHtml.
-
You mean if you have 0xFFFFFF, how to turn that into argb ? Something like this int color = 0xFFFFFF; byte alpha = (byte)((color && 0xFF000000) << 24); byte red = (byte)((color && 0xFF0000) << 16); byte green = (byte)((color && 0xFF00) << 8); byte blue = (byte)((color && 0xFF))); Something like that. Use the && to strip the other bits, and a bit shift to move it down to be just a byte.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
so how can i get a value from a textbox and then convert it
-
so how can i get a value from a textbox and then convert it
Get the .Text string and then apply Christian's code to it.
Deja View - the feeling that you've seen this post before.
-
so how can i get a value from a textbox and then convert it
Please, please, please buy a beginners book and read it.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
Please, please, please buy a beginners book and read it.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
well here is the way i got it to work
int Color; Color = int.Parse(TextBox1.Text, NumberStyles.HexNumber);
-
well here is the way i got it to work
int Color; Color = int.Parse(TextBox1.Text, NumberStyles.HexNumber);
OK, what this does is not what you asked for. This gives you a a single number, no color information at all.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )