CanvasGetPixel
int CanvasGetPixel (int panelHandle, int controlID, Point point, int *pixelColor);
Purpose
Obtains the color of a single pixel on a canvas control.
![]() |
Note The canvas control maintains an internal bitmap reflecting all of the drawing operations (except for drawing operations made while the ATTR_DRAW_POLICY attribute is VAL_DIRECT_TO_SCREEN). Sometimes the internal bitmap contains the result of recent drawing operations that have not yet been reflected on the screen. CanvasGetPixel obtains the pixel colors from the internal bitmap, not from the screen. |
Supported Controls
You can use CanvasGetPixel with canvas controls.
Parameters
Input | ||
Name | Type | Description |
panelHandle | int | Specifier for a particular panel that is currently in memory. You can obtain this handle from functions such as LoadPanel and NewPanel. |
controlID | int | The defined constant, located in the .uir header file, that you assigned to the control in the User Interface Editor, or the ID returned by functions such as NewCtrl and DuplicateCtrl. |
point | Point | Point structure that indicates the location of a pixel. The location is in terms of unscaled pixel coordinates. The origin (0,0) is the upper left corner of the canvas control. The Point structure is defined as follows. typedef struct { int x; int y; } Point; You can create a Point without having to declare a variable by using the following function: Point MakePoint (int x, int y); ExampleCanvasGetPixel (panelHandle, controlID, MakePoint (20, 30), &pixelColor); |
Output | ||
Name | Type | Description |
pixelColor | int | RGB color value of the pixel at the specified point. |
Return Value
Name | Type | Description |
status | int | Return value indicating whether the function was successful. A negative number indicates that an error occurred. |
Additional Information
Library: User Interface Library
Include file: userint.h
LabWindows/CVI compatibility: LabWindows/CVI 4.0 and later