a question for smart people 
Author Message
 a question for smart people

hey you VB guru,

Here is a question:
I am using the windows API to get
the the color of a pixel:

var123 = GetPixel(Pic1.hdc, x1, y1)

the problem is that GetPixel return
the color of the pixel as a long.
I however need to change this long
to a RBG value.

the number I get for var123, are anywhere
from 0 (black) to about 16,000,000. I need
to change this number to red, green, blue.

What is the algorithm for doing it?

Many thanks,
Tigran



Wed, 01 May 2002 03:00:00 GMT  
 a question for smart people
A: Use the Hex function
e.g. rgbVal = Hex(GetPixel(Form1.hdc, 75, 100))

Quote:

> hey you VB guru,

> Here is a question:
> I am using the windows API to get
> the the color of a pixel:

> var123 = GetPixel(Pic1.hdc, x1, y1)

> the problem is that GetPixel return
> the color of the pixel as a long.
> I however need to change this long
> to a RBG value.

> the number I get for var123, are anywhere
> from 0 (black) to about 16,000,000. I need
> to change this number to red, green, blue.

> What is the algorithm for doing it?

> Many thanks,
> Tigran



Wed, 01 May 2002 03:00:00 GMT  
 a question for smart people
Here's a post from the ng:

Subject:  RGB function - getting original values?
Date:     Thu, 23 Apr 1998 00:27:00 -0500

Org:      The Zipsters

Hello, Once I've got the Long value returned from the RGB
function, is it possible
to convert back somehow and get the original R, G, and B values?

The RGB values are stored as 00BBGGRR. To extract them use the
following:
R = C And &hff
G = (C \ &h100) And &hff
B = (C \ &h10000) And &hff
C is the long value.
Regards
Stanley Peck

Quote:

> hey you VB guru,

> Here is a question:
> I am using the windows API to get
> the the color of a pixel:

> var123 = GetPixel(Pic1.hdc, x1, y1)

> the problem is that GetPixel return
> the color of the pixel as a long.
> I however need to change this long
> to a RBG value.

> the number I get for var123, are anywhere
> from 0 (black) to about 16,000,000. I need
> to change this number to red, green, blue.

> What is the algorithm for doing it?

> Many thanks,
> Tigran



Wed, 01 May 2002 03:00:00 GMT  
 a question for smart people
RedValue = (ColorValue And vbRed)
GreenValue = (ColorValue And vbGreen) / &H100
BlueValue = (ColorValue and vbBlue) / &H10000

Kenny Acock
<><

Quote:
> I however need to change this long
> to a RBG value.

> the number I get for var123, are anywhere
> from 0 (black) to about 16,000,000. I need
> to change this number to red, green, blue.

> What is the algorithm for doing it?



Wed, 01 May 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. For you smart people...

2. IRC, #Visualbasic, RippDogg and People Helping People

3. Smart Delete Files And Smart Delete Folders Routines?

4. Please MS people: Question on Web Services and Custom Exception

5. THIS IS NOT A STUPID QUESTION - obviously I like to insult other people

6. Yet another question for you wonderful people

7. A question for win3.1 people..

8. Question (How smart are you?)

9. Question (how smart are you?)

10. Crystal Smart Viewer Question

11. Smart Newbie??? - Question

12. Smart Newbie???- Question

 

 
Powered by phpBB® Forum Software