GetBitmapRowCol example for C++ Builder

void __fastcall TForm1::Button2Click(TObject *Sender)
{
   int xOffset ; // Column offset of the rectangle to process
   int xSize   ; // Pixel width of the rectangle to process
   int yOffset ; // Row offset of the rectangle to process
   int ySize   ; // Pixel height of the rectangle to process
   unsigned char * pBuf ; // Buffer to hold the row
   int i, n ; // Counters
   HGLOBAL hBuf ;

   // Load the bitmap, at 24 bits per pixel
   LEADImage->Load ("v:\\images\\11.bmp", 24, 0, 1);
   // Specify a rectangle in the top left part of the displayed image
   xOffset = ( int ) LEADImage->BitmapWidth / 8) ;
   xSize   = ( int ) LEADImage->BitmapWidth / 3;
   yOffset = ( int ) LEADImage->BitmapHeight / 8;
   ySize   = ( int ) LEADImage->BitmapHeight / 3;

   // Allocate the buffer
   hBuf = GlobalAlloc(GMEM_MOVEABLE, xSize * 3 ) ;
   pBuf = ( unsigned char * ) GlobalLock( hBuf );
   // Invert the colors of pixels in the rectangle
   for ( i = yOffset; i < (yOffset + ySize); i ++ )
  {
      LEADImage->GetBitmapRowCol( pBuf, i, xOffset, xSize * 3);
      for ( n =0; n < ( unsigned ) (xSize * 3 ); n ++ )
         pBuf[n]= (pBuf[n] ^ 0xFF);
      LEADImage->PutBitmapRowCol( pBuf, i,  xOffset, xSize* 3);
   }
   // Free memory that we no longer need
   GlobalFree(hBuf);
}