GetPixelData example for C++ Builder

/* This example uses GetPixelData and PutPixelData to swap the R and G values for a particular pixel->
This example will work only with 24, 32, 48 and 64-bit bitmaps*/

void TForm1::SwapRGBtoBGR( int nRow, int nCol)
{
   unsigned uVal;
   L_UCHAR aPixel[4] ; // make it large enough for both bitmap types
   L_UINT16 bPixel[4]; // make it large enough for both bitmap types
   void * pPixel;

   if((LEADImage1->BitmapBits == 24) ||
      (LEADImage1->BitmapBits == 32))
   {
      pPixel= &aPixel;
      LEADImage1->GetPixelData(pPixel, nRow, nCol, 4);
      // swap the R and B values
      uVal= aPixel[0]; aPixel[0] = aPixel[2]; aPixel[2] = (L_UCHAR)uVal;
      // put back the transformed pixel
      LEADImage1->PutPixelData(pPixel, nRow, nCol, sizeof(aPixel));
   }
   else
      if((LEADImage1->BitmapBits == 48) ||
         (LEADImage1->BitmapBits == 64))
      {
         pPixel= &bPixel;
         LEADImage1->GetPixelData(pPixel, nRow, nCol, 4);
         // swap the R and B values
         uVal= aPixel[0]; aPixel[0]= aPixel[2]; aPixel[2]= (L_UINT16)uVal;
         // put back the transformed pixel
         LEADImage1->PutPixelData(pPixel, nRow, nCol, sizeof(aPixel));
      }
}