LBitmapBase::GetRowCol

Summary

Copies image data from the class object's bitmap to the specified buffer. The buffer will be filled with uncompressed data.

Syntax

#include "ltwrappr.h"

virtual L_SSIZE_T LBitmapBase::GetRowCol(pLBuffer, nRow, nCol)

Parameters

LBuffer * pLBuffer

Pointer to the LBuffer object that will receive the retrieved row. You must allocate enough space in the buffer to hold the data. To get a full row, use the value returned by LBitmapBase::GetBitsPerPixel to allocate the buffer. Or, use an empty buffer to retrieve the full row.

When getting less than full row, you must consider the bits per pixel. For a 1-bit bitmap, each byte represents 8 pixels. For a 4-bit bitmap, each byte represents 2 pixels. For an 8-bit bitmap, each byte represents 1 pixel. For a 16-bit bitmap, every 2 bytes represents one pixel. For 24-bit images, every three bytes represents one pixel. For a 32-bit bitmap, every four bytes represents one pixel. For 48-bit images, every six bytes represents one pixel. For 64-bit images, every eight bytes represents one pixel.

You can use the value returned by LBitmapBase::GetBitsPerPixel with integer math to calculate the number of bytes needed for a particular number of pixels. For example:

NumberOfBytes = (Bitmap.GetBitsPerPixel() * NumberOfPixels) / 8; 
if ((Bitmap.GetBitsPerPixel() * NumberOfPixels) % 8) 
   ++NumberOfBytes; /* Round up if necessary for a 1- or 4-bit image */ 

L_INT nRow

The number of the row to retrieve. The first row is 0 and the last row is 1 less than the bitmap height.

L_INT nCol

The number of column from which to get the data. The first column offset is 0, and the last column offset is 1 less than the bitmap width.

Returns

Value Meaning
>=1 The number of bytes retrieved.
< 1 An error occurred. Refer to Return Codes.

Comments

This function copies image data from the class object's bitmap to a buffer that you specify. This function can be used to retrieve a partial row. The data is copied exactly as it is stored in the image. The bitmap memory must be locked when you use this function. Normally, you can call LBitmapBase::Access to lock the memory before starting an operation that uses this function, then call LBitmapBase::Release when the operation is finished.

Use the LBitmapBase::GetBytesPerLine() to determine the byte count of each line. Color order is determined by the LBitmapBase::GetColorOrder() function. ORDER_GRAY is only valid for 12, 16 and 32-bit grayscale images. Locking the bitmap memory will speed up the processing. If you do not lock the bitmap memory it will be locked automatically and released automatically after getting the row data, but this will slow down the processing.

Support for 12, 16 and 32-bit grayscale images is only available in the Document/Medical toolkits.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

This example uses GetRowCol and PutRowCol to invert
the colors of a rectangle in the upper left part of the displayed image.

L_INT LBitmapBase__GetRowColExample() 
{ 
   L_INT nRet; 
   LBitmapBase LeadBitmap;   /* Bitmap handle to hold the loaded image */ 
   L_INT XOffset; /* Column offset of the rectangle to process */ 
   L_INT XSize; /* Pixel width of the rectangle to process */ 
   L_INT YOffset; /* Row offset of the rectangle to process */ 
   L_INT YSize; /* Pixel height of the rectangle to process */ 
   LBuffer Buff; 
   L_UCHAR  *pBuf; /* Buffer to hold the row */ 
   int i, n; /* Counters */ 
    
   /* Load the bitmap, at 24 bits per pixel */ 
   nRet =LeadBitmap.Load (MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\Image3.cmp")), 24, ORDER_BGR); 
   if(nRet !=SUCCESS) 
      return nRet; 
   /* This example does not work with rotated view perspectives */ 
   if ( (LeadBitmap.GetViewPerspective() != TOP_LEFT) || (LeadBitmap.GetViewPerspective() != BOTTOM_LEFT) ) 
   { 
      nRet =LeadBitmap.ChangeViewPerspective(TOP_LEFT ); 
      if(nRet !=SUCCESS) 
         return nRet; 
   } 
   /* Specify a rectangle in the top left part of the displayed image */ 
   XOffset = LeadBitmap.GetWidth() / 8; 
   XSize = LeadBitmap.GetWidth() / 3; 
   YOffset = LeadBitmap.GetHeight() / 8; 
   YSize = LeadBitmap.GetHeight() / 3; 
 
   /* Adjust the YOffset if the view perspective is bottom left */ 
   if (LeadBitmap.GetViewPerspective() == BOTTOM_LEFT) 
   { 
      YOffset = LeadBitmap.GetHeight()- YOffset - YSize; 
   } 
   /* Allocate the buffer */ 
   nRet =Buff.Reallocate(XSize * 3); 
   if(nRet !=SUCCESS) 
      return nRet; 
   pBuf = (L_UCHAR  *)Buff.Lock(); 
   /* Invert the colors of pixels in the rectangle */ 
   nRet =LeadBitmap.Access(); 
   if(nRet !=SUCCESS) 
      return nRet; 
   for(i=YOffset; i < (YOffset + YSize); i++) 
   { 
      nRet =(L_INT)LeadBitmap.GetRowCol(&Buff, i, XOffset); 
      if(nRet < 1) 
         return nRet; 
      for(n=0; n < (XSize * 3); n++) 
         pBuf[n] = pBuf[n] ^ 0xFF; 
      nRet =(L_INT)LeadBitmap.PutRowCol(Buff, i,  XOffset); 
      if(nRet < 1) 
         return nRet; 
   } 
 
   nRet =LeadBitmap.Release(); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   return SUCCESS; 
} 

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.