Example Code

Getting RGB Pixel Value Using the Windows Interface API

Code and Documents

Attachment

Download All

Introduction

This example uses the gdi32.dll function GetPixel to return the RGB pixel value from any pixel on the screen based on an x and y position. To do this, a call was also made to the user32.dll GetDC function to get the handle to the device context (HDC) for the entire screen.

Steps to Complete

Open attached VI.

Specify the desired X and Y position.

Additional Notes

This example uses the gdi32.dll and the user32.dll. Both will need to be installed to run this example.

See

http://msdn.microsoft.com/en-us/library/dd144909(VS.85).aspx

http://msdn.microsoft.com/en-us/library/dd144871(VS.85).aspx

For a detailed description of the two functions used in this example.

Hope this helps.
-Ben

WaterlooLabs

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors