LBitmapBase::GetRow

#include "ltwrappr.h"

virtual L_INT32 LBitmapBase::GetRow(pLBuffer, nRow)

LBuffer L_FAR * pLBuffer;

/* pointer to an LBuffer object */

L_INT nRow;

/* the number of the row to retrieve */

Copies image data from the class object's bitmap to the specified buffer.

Parameter

Description

pLBuffer

Pointer to an 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 */ 

nRow

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

Returns

>=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. 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. 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.

Required DLLs and Libraries

LTDIS
LTFIL

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

Elements:

LBitmapBase::PutRow, LBitmapBase::PutRowCol, LBitmapBase::PutRowCompressed, LBitmapBase::GetRow, LBitmapBase::PutRowColCompressed, LBitmapBase::GetRowCol, LBitmapBase::GetRowColCompressed, Class Members

Topics:

Raster Image Functions: Getting and Setting Pixel Values

Example

/* Load the bitmap, at 24 bits per pixel */
LBitmapBase LeadBitmap;
LBuffer Buffer;
L_CHAR L_FAR * pBuff;

LeadBitmap.Load (TEXT("IMAGE3.CMP"));

/* get row number 5 of the bitmap */
LeadBitmap.Access();
LeadBitmap.GetRow(&Buffer,5) ;
/*process the row data*/

if(Buffer.GetSize())
{
pBuff=(L_CHAR L_FAR*)Buffer.Lock();

for(L_INT uByte = 0; uByte < LeadBitmap.GetBytesPerLine(); uByte++)
  pBuff[uByte] ^= 0xFF;

Buffer.Unlock();
/*restore the row*/
LeadBitmap.PutRow(Buffer, 5);
LeadBitmap.Release();
}