Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have one problem with color in windows forms application.

Where is the problem?

When I convert color to int with ColorTranslator.ToWin32 everything is ok.

But now I would like to convert back from ColorTranslator.FromWin32().

But here is the problem beacuse ColorTranslator.FromWin32() accepts parameter int, not Int64.
ColorTranslator.ToWin32(Color.Orange); //Orange has int --> 4227327
So How can get the number 4227327 is Orange, with which methods?


thanks

What I have tried:

ColorTranslator.ToWin32(Color.Orange); //Orange has int --> 4227327
So How can I get the number 4227327 is Orange, with which methods?
Posted
Updated 22-Dec-16 20:38pm
v2
Comments
Dave Kreskowiak 22-Dec-16 19:28pm    
OK, so where are you getting a 64-bit color value from?

Hi teddddddddddd,

Your problem is not fully clear. Also Orange is not 4227327 as you mentioned; I get 42495.
C#
int Col = ColorTranslator.ToWin32(Color.Orange); //Orange has int --> 42495, not 4227327
FromWin32 accepts int, not Int64 - this is right. But you are not passing any Int64 to it, are you? You can simply retrieve back the orange color like below.
C#
Color Col2 = ColorTranslator.FromWin32(Col);
Or
C#
Color Col2 = ColorTranslator.FromWin32(42495);
 
Share this answer
 
Hi,

Can you pick up Orange from colorDialog1 ?

br
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900