L_IsPtInBitmapRgn

#include "l_bitmap.h"

L_BOOL EXT_FUNCTION L_IsPtInBitmapRgn(pBitmap, nRow, nCol)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

L_INT nRow;

/* row number of the pixel */

L_INT nCol;

/* column number of the pixel */

Determines whether the specified pixel is in the bitmap region.

Parameter

Description

pBitmap

Pointer to the bitmap handle referencing the bitmap that has the region.

nRow

The row number of the pixel.

nCol

The column number of the pixel.

Returns

TRUE

The specified pixel is in the region.

FALSE

The specified pixel is outside the region.

Comments

This function uses bitmap coordinates to specify the pixel. Therefore, you must account for the view perspective of the bitmap. For more information, refer to Accounting for View Perspective.

Required DLLs and Libraries

LTDIS

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Windows 95 / 98 / Me, Windows 2000 / XP.

See Also

Functions:

L_FrameBitmapRgn, L_BitmapHasRgn, L_FreeBitmapRgn, L_GetBitmapRgnArea

Topics:

Raster Image Functions: Creating and Using a Region

 

Raster Image Functions: Region Processing

 

Defining and Using a Bitmap Region

Example

For complete sample code, refer to the DRAW example.

/****************************************************************************************
This example tests whether the current mouse position is in the bitmap region. 
The example includes sections from a program’s message-processing function. 
The sample code uses the following global variables: */
BITMAPHANDLE LeadBitmap;   /* Bitmap handle to hold the loaded image. */
L_INT DisplayWidth, DisplayHeight; /* Dimensions of the displayed image */
L_INT DisplayLeft, DisplayTop; /* Origin of the displayed image */
/* TestFunction(), which is used in this example, can be copied from the example for L_SetBitmapRgnEllipse.
*****************************************************************************************/
L_INT32 EXT_FUNCTION MainWndProc (HWND hWnd, L_UINT Message, WPARAM wParam,
                                   LPARAM lParam)
{

   L_INT BitmapX, BitmapY; /* Mouse position in bitmap coordinates */
   switch (Message)
   {
   case WM_CREATE:
      /* Load the bitmap and create the region */
      TestFunction(hWnd);

 

   case WM_RBUTTONDOWN:
       /* Translate mouse positions to bitmap coordinates */
       BitmapX = LOWORD(lParam) * BITMAPWIDTH(&LeadBitmap) / (DisplayWidth - DisplayLeft);
       BitmapY = HIWORD(lParam) * BITMAPHEIGHT(&LeadBitmap) / (DisplayHeight - DisplayTop);
       /* Adjust for view perspective */
       L_PointToBitmap ( &LeadBitmap, TOP_LEFT, &BitmapX, &BitmapY );
       /* Display a message if the point is in the region */
       if (L_IsPtInBitmapRgn(&LeadBitmap, BitmapY, BitmapX))
          MessageBox (NULL, TEXT("Point is in region"), TEXT("Notice"), MB_OK);

    }
        return (0);

 }