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

 Page 1 of 1 [ 4 post ]

Relevant Pages