No announcement yet.

Getting Pixel Color In VB

  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting Pixel Color In VB

    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,

  • #2
    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).
    Learn by teaching
    Take responsibility for learning


    • #3
      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...


      • #4
        Is there nothing she doesn't know about?
        Learn by teaching
        Take responsibility for learning