From: Peter Webb on 30 Mar 2010 23:27 Sorry, couldn't find this on Google, at least not for C#, or in Help I am calling cards.dll which accepts a long for color from within a C# program. How to I convert (say) Color.Red into a long for the DLL? TIA
From: Peter Duniho on 31 Mar 2010 00:31 Peter Webb wrote: > Sorry, couldn't find this on Google, at least not for C#, or in Help > > I am calling cards.dll which accepts a long for color from within a C# > program. > > How to I convert (say) Color.Red into a long for the DLL? That all depends on the format of the long expected by the DLL. But, Color.ToArgb() _might_ do what you want. If you want a better answer, you need to be more specific about how the long expected by your DLL describes a specific color. Pete
From: Jeff Gaines on 31 Mar 2010 04:19 On 31/03/2010 in message <#xlMZII0KHA.3680(a)TK2MSFTNGP04.phx.gbl> Peter Webb wrote: >Sorry, couldn't find this on Google, at least not for C#, or in Help > >I am calling cards.dll which accepts a long for color from within a C# >program. > >How to I convert (say) Color.Red into a long for the DLL? > >TIA I use this: private int RGBColour(Color colTemp) { int intColour = colTemp.B * 255 * 255; intColour += colTemp.G * 255; intColour += colTemp.R; return intColour; } The long variable types should be int in C#. -- Jeff Gaines Dorset UK That's an amazing invention but who would ever want to use one of them? (President Hayes speaking to Alexander Graham Bell on the invention of the telephone)
From: Peter Webb on 31 Mar 2010 23:01 Thanks to both of you. I am elsewhere in the code at the moment; when I open this part up again I will do some testing as per the suggestions.
From: Tim Roberts on 2 Apr 2010 00:27 "Jeff Gaines" <jgaines_newsid(a)yahoo.co.uk> wrote: > >private int RGBColour(Color colTemp) >{ > int intColour = colTemp.B * 255 * 255; > intColour += colTemp.G * 255; > intColour += colTemp.R; > return intColour; >} That's not correct. The color components are integers ranging from 0 to 255. You need to multiply them by 256 to shift them into place, not by 255. More efficient yet would be: int intColor = (colTemp.B << 16) | (colTemp.G << 8) | colTemp.R; -- Tim Roberts, timr(a)probo.com Providenza & Boekelheide, Inc.
|
Next
|
Last
Pages: 1 2 3 Prev: about culture and globalization Next: FileSystemWatcher and open files |