View Full Version : Getting Pixel Color In VB


dell8092
05-20-2004, 09:16 AM
Could someone please tell me how to get the individual pixel color of a document in Photoshop using VB? I have tried it multiple ways and the only way I can truly get it is through the histogram. However, that is extremely slow!

Any help would be appreciated!

Thanks in advance,
Mike

Doug Nelson
05-20-2004, 01:21 PM
I can't find anything that simply reads the color, but there is ForegroundColor that can read the foreground color, and there are methods to read CMYK color values (but nothing for RGB).

So you could conceivably set the foreground color using whatever technique is appropriate, then read it and then reset the foreground to default (or you could even read what it is before, set it, read the setting, and restore what it was before).

Leah
05-20-2004, 01:33 PM
I don't know anything about the Photoshop <-> VB interface, but in pure VB (at least up to VB6) there is a Point method Point (x, y) that will return the color of the specified pixel as a long integer. From that you can calculate the RGB values as follows:

r = color And &HFF&
g = (color And &HFF00&) \ &H100&
b = (color And &HFF0000) \ &H10000

Hope this may be of some use...

Doug Nelson
05-20-2004, 04:17 PM
Is there nothing she doesn't know about? :)