Results 1 to 5 of 5

Thread: Getting Pixel Color

  1. #1

    Thread Starter
    Lively Member *Super Sniper*'s Avatar
    Join Date
    Jan 2000
    Location
    Portland, OR
    Posts
    81

    Post

    How do you get the color of a pixel?

    I would like some sorce code. Thanks in advance

    ------------------
    Website

  2. #2
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    Post

    The easiest way is using Point which is supported by picture boxes:

    -
    Color=Picture1.Point (10,10)
    -

    But ya can also use the *much* faster API command. (You need the DC of the picture box):

    -
    'In module
    Declare Function GetPixel Lib "gdi32" Alias "GetPixel" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long

    'Anywhere
    Dim DC as Long
    Dim Color as Long

    DC = Picture1.hDC
    Color = GetPixel( DC, 10, 20 )
    -

    i think that's enough

    ------------------
    [email protected]
    ...
    Every program can be reduced to one instruction which doesn't work.


  3. #3

    Thread Starter
    Lively Member *Super Sniper*'s Avatar
    Join Date
    Jan 2000
    Location
    Portland, OR
    Posts
    81

    Post

    Thanks again.
    Also will this work if the picture's on a form?

    ------------------
    Website

    [This message has been edited by *Super Sniper* (edited 02-17-2000).]

  4. #4
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    Post

    Yes, Forms and Pictures are nearly the same.

  5. #5

    Thread Starter
    Lively Member *Super Sniper*'s Avatar
    Join Date
    Jan 2000
    Location
    Portland, OR
    Posts
    81

    Post

    It doesn't work.

    ------------------
    Website

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width