L_PntPickColor

#include "LtPnt.h"

L_INT EXT_FUNCTION L_PntPickColor(pPaint, UserDC, nX, nY, pcrDestColor)

pPAINTHANDLE pPaint;

/* pointer to a paint handle */

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.

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:

DigitalPaint Functions: Miscellaneous

 

Filling an Area

Example

#include <stdio.h>



L_INT PcikColorTest ( HWND hWnd, pBITMAPHANDLE pBitmap, L_INT nX, L_INT nY, COLORREF *pcrDestColor ) 
{
   pPAINTHANDLE pPaint ;
   HDC          hDC ;
   HPALETTE     hPalette ; 
   RECT         rcSrc, rcDest ;
   L_TCHAR       buffer [ 80 ] ;
      

   /* Initiate the Paint toolkit */
   if ( SUCCESS != L_PntInit ( &pPaint ) )
   {
      return FAILURE ; 
   }

   /* 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 */
   L_PntSetMetrics ( pPaint, NULL, NULL, hPalette ) ;

   /* Set the bitmap painting coordinates  */
   SetRect ( &rcSrc, 0, 0, BITMAPWIDTH ( pBitmap ), BITMAPHEIGHT ( pBitmap ) ) ;

   CopyRect ( &rcDest, &rcSrc ) ;

   /* Paint the bitmap to the screen */

    L_PaintDC( hDC, pBitmap, &rcSrc, NULL, &rcDest, NULL, SRCCOPY ) ;

   /* Set the extents of the DC that we are going to pick the color from */
   L_PntSetDCExtents ( pPaint, &rcDest ) ;

   /* Get the color value */
   L_PntPickColor ( pPaint, hDC, nX, nY, pcrDestColor ) ;

   /* 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 ;
}