Friday, September 19, 2008

WIN 32 API -GetPixel

GetPixel Function

Declaration

Declare Function GetPixel Lib "gdi32.dll" (ByVal hdc As Long, ByVal nXPos As Long, ByVal nYPos As Long) As Long

Platforms

  • Windows 95: Supported.
  • Windows 98: Supported.
  • Windows NT: Requires Windows NT 3.1 or later.
  • Windows 2000: Supported.
  • Windows CE: Requires Windows CE 1.0 or later.

Description & Usage

GetPixel determines the color of a specific pixel on a device. The function finds the RGB value of the pixel which is checked.

Return Value

If an error occured, the function returns &HFFFF. If successful, the function returns the RGB value of the pixel which was checked.

Visual Basic-Specific Issues

None.

Parameters

hdc
A handle to a device context to the device to check a pixel of.
nXPos
The x-coordinate of the pixel to determine the color of.
nYPos
The y-coordinate of the pixel to determine the color of.

Example(VB 6.0)

 Fill all of window Form1 with the color which is located at
' coordinate (75,100)
Dim rgbVal As Long ' RGB color of the pixel


' Determine the color of the pixel on Form1 at (75,100).
rgbVal = GetPixel(Form1.hDC, 75, 100)

No comments:

Just Answer


JustAnswer.com