|
-
Sep 6th, 2011, 09:16 PM
#1
Thread Starter
Junior Member
How can I find the 32 bit number of a color?
For example, black is 0, how can I find out what number other colors are?
-
Sep 6th, 2011, 09:33 PM
#2
Re: How can I find the 32 bit number of a color?
The Color structure has a ToArgb method that returns an Integer, i.e. 32-bit number. You can use the BitConverter class to break that into its alpha, red, green and blue components if desired. There is also a FromArgb method that will accept a single 32-bit value or four 8-bit values.
-
Sep 6th, 2011, 10:10 PM
#3
Thread Starter
Junior Member
Re: How can I find the 32 bit number of a color?
 Originally Posted by jmcilhinney
The Color structure has a ToArgb method that returns an Integer, i.e. 32-bit number. You can use the BitConverter class to break that into its alpha, red, green and blue components if desired. There is also a FromArgb method that will accept a single 32-bit value or four 8-bit values.
Now, can you repeat that to someone that's retarded?
-
Sep 6th, 2011, 10:28 PM
#4
Re: How can I find the 32 bit number of a color?
I don't consider forums to be the place to learn the basics of programming. There are plenty of beginner tutorials for that. When people post questions on forums I assume that they have already done the work required to cover the basics so, if I say "set this property", "call this method" or "handle this event", they know how set a property, call a method or handle an event. If you don't know how to do those things then I suggest that you start with a beginners tutorial and cover the basics first. Here's a good one:
http://www.homeandlearn.co.uk/net/vbnet.html
Assuming you know how to do those basics things, either now or after reading that, you can use the advice I've already provided, which is basically to call the ToArgb method on your Color value. That's how you get a 32-bit number that represents a colour. If that doesn't cover your particular situation then you will need to explain your particular situation, so that we can provide advice specific to that situation.
-
Sep 7th, 2011, 02:12 PM
#5
Re: How can I find the 32 bit number of a color?
 Originally Posted by jmcilhinney
The Color structure has a ToArgb method that returns an Integer, i.e. 32-bit number. You can use the BitConverter class to break that into its alpha, red, green and blue components if desired. There is also a FromArgb method that will accept a single 32-bit value or four 8-bit values.
The Color structure also has A, R, G, + B properties that represent the alpha, red, green and blue components
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Sep 7th, 2011, 10:42 PM
#6
Thread Starter
Junior Member
Re: How can I find the 32 bit number of a color?
I did a google search and followed this tutorial
http://www.youtube.com/watch?v=7lO0JMWwa2Q
I still don't know how to find the 32bit value of a color i put my mouse over =/
-
Sep 7th, 2011, 10:56 PM
#7
Re: How can I find the 32 bit number of a color?
 Originally Posted by Dgameman1
You didn't say anything about putting your mouse over anything in any previous post. We can't read minds so you have to provide us with all the relevant information. I've explained how to get a 32-bit numerical representation of a Color value. I had no idea that that Color value had to be created based on where your mouse pointer was currently located. I could suggest one way that I know would work but I doubt that it's the most efficient, so I'll leave it up to someone else.
Please provide a FULL and CLEAR description of EXACTLY what you want in future and you'll save us and yourself a lot of time.
-
Sep 7th, 2011, 10:58 PM
#8
Thread Starter
Junior Member
Re: How can I find the 32 bit number of a color?
 Originally Posted by jmcilhinney
You didn't say anything about putting your mouse over anything in any previous post. We can't read minds so you have to provide us with all the relevant information. I've explained how to get a 32-bit numerical representation of a Color value. I had no idea that that Color value had to be created based on where your mouse pointer was currently located. I could suggest one way that I know would work but I doubt that it's the most efficient, so I'll leave it up to someone else.
Please provide a FULL and CLEAR description of EXACTLY what you want in future and you'll save us and yourself a lot of time.
Sorry about that.
Could you tell me the way you know? =D
-
Sep 7th, 2011, 11:08 PM
#9
Re: How can I find the 32 bit number of a color?
1. Use the Screen class to get the size of the desktop on the primary screen.
2. Create a Bitmap of that size.
3. Create a Graphics object from the Bitmap.
4. Call CopyFromScreen to copy the desktop to the Bitmap.
5. Use the Cursor class to get the current mouse pointer location.
6. Call GetPixel on the Bitmap to get the Color at that location.
-
Sep 7th, 2011, 11:28 PM
#10
Re: How can I find the 32 bit number of a color?
 Originally Posted by jmcilhinney
1. Use the Screen class to get the size of the desktop on the primary screen.
Couldn't you just get the pixel under the mouse pointer, maybe something like...
Code:
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
Using bmp As New Bitmap(1, 1)
Using g As Graphics = Graphics.FromImage(bmp)
g.CopyFromScreen(MousePosition, Point.Empty, bmp.Size)
Dim c As Color = bmp.GetPixel(0, 0)
Debug.WriteLine(c)
End Using
End Using
End Sub
-
Sep 7th, 2011, 11:40 PM
#11
Thread Starter
Junior Member
Re: How can I find the 32 bit number of a color?
 Originally Posted by Edgemeal
Couldn't you just get the pixel under the mouse pointer, maybe something like...
Code:
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
Using bmp As New Bitmap(1, 1)
Using g As Graphics = Graphics.FromImage(bmp)
g.CopyFromScreen(MousePosition, Point.Empty, bmp.Size)
Dim c As Color = bmp.GetPixel(0, 0)
Debug.WriteLine(c)
End Using
End Using
End Sub
I don't see where it says the color tho =/
-
Sep 7th, 2011, 11:54 PM
#12
Re: How can I find the 32 bit number of a color?
 Originally Posted by Dgameman1
I don't see where it says the color tho =/
I'm not familar with using Color in .NET, maybe use c.ToArgb ?
I've seen people ask how to get a color value in hex and the answer was something like,...
Me.Text = c.ToArgb.ToString("X")
-
Sep 7th, 2011, 11:58 PM
#13
Thread Starter
Junior Member
Re: How can I find the 32 bit number of a color?
 Originally Posted by Edgemeal
I'm not familar with using Color in .NET, maybe use c.ToArgb ?
I've seen people ask how to get a color value in hex and the answer was something like,...
Me.Text = c.ToArgb.ToString("X")
Ok, it worked and the number it gave me was
FFD4D0C8
Now, What is a code where when I press button5, the mouse looks for a color in a certain area, then clicks that color and when it presses that color is goes and finds a different color in a different area and then clicks that color. How can I do that?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|