L_PntPickColor
#include "LtPnt.h"
L_LTPNT_API L_INT L_PntPickColor(pPaint, UserDC, nX, nY, pcrDestColor)
pPAINTHANDLE pPaint; |
/* pointer to a paint handle */ |
L_HDC UserDC; |
/* handle to the device context */ |
L_INT nX; |
/* x-coordinate */ |
L_INT nY; |
/* y-coordinate */ |
COLORREF * pcrDestColor; |
/* pointer to a color */ |
Gets the color at the specified position.
Parameter |
Description |
pPaint |
Pointer to a paint handle. |
UserDC |
Handle to a device context, such as a screen, to use as a display surface. This parameter can also be NULL. . The mapping mode of the device context must be MM_TEXT. |
nX |
X-coordinate of the position to get its color. |
nY |
Y-coordinate of the position to get its color. |
pcrDestColor |
Pointer to a COLORREF value to be updated with the color at the specified position. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
If the user has set a bitmap in the toolkit, using the function L_PntSetMetrics, then the toolkit will get the color at the specified position of the bitmap. Otherwise, the toolkit will get the color from the specified position of the specified device context.
If the UserDC is not NULL, the user should set the DC boundaries before calling this function, by calling L_PntSetDCExtents.
Required DLLs and Libraries
LTPNT For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application |
See Also
Functions: |
L_PntSetTransformation, L_PntSetDCExtents, L_PntGetTransformation, L_PntGetDCExtents, L_PntFillBorder, L_PntFillColorReplace, L_PntFillSurface |
Topics: |
|
|
Example
L_INT PntPickColorExample(HWND hWnd, pBITMAPHANDLE pBitmap, L_INT nX, L_INT nY, COLORREF* pcrDestColor) { L_INT nRet; pPAINTHANDLE pPaint ; HDC hDC ; HPALETTE hPalette ; RECT rcSrc, rcDest ; L_TCHAR buffer [ 80 ] ; /* Initiate the Paint toolkit */ nRet = L_PntInit ( &pPaint ); if ( SUCCESS != nRet) { return nRet; } /* Get device context */ hDC = GetDC ( hWnd ) ; /* Create restriction palette (if needed) */ hPalette = L_CreatePaintPalette ( hDC, pBitmap ) ; /* Select the bitmap and the restriction palette into the toolkit */ nRet = L_PntSetMetrics ( pPaint, NULL, NULL, hPalette ) ; if(nRet != SUCCESS) return nRet; /* Set the bitmap painting coordinates */ SetRect ( &rcSrc, 0, 0, BITMAPWIDTH ( pBitmap ), BITMAPHEIGHT ( pBitmap ) ) ; CopyRect ( &rcDest, &rcSrc ) ; /* Paint the bitmap to the screen */ nRet = L_PaintDC ( hDC, pBitmap, &rcSrc, NULL, &rcDest, NULL, SRCCOPY ) ; if(nRet != SUCCESS) return nRet; /* Set the extents of the DC that we are going to pick the color from */ nRet = L_PntSetDCExtents ( pPaint, &rcDest ) ; if(nRet != SUCCESS) return nRet; /* Get the color value */ nRet = L_PntPickColor ( pPaint, hDC, nX, nY, pcrDestColor ) ; if(nRet != SUCCESS) return nRet; /* Display the results */ wsprintf ( buffer, TEXT("R:%d G:%d B:%d"), GetRValue ( *pcrDestColor ), GetGValue ( *pcrDestColor ), GetBValue ( *pcrDestColor ) ) ; SetWindowText ( hWnd, buffer ) ; /* Release the DC */ ReleaseDC ( hWnd, hDC ) ; /* Delete the font object */ DeleteObject ( (HPALETTE ) hPalette ) ; /* Free the paint tools handle */ L_PntFree ( pPaint ) ; return SUCCESS ; }