#include "l_bitmap.h"

L_LTKRN_API L_INT L_GetBitmapRowCompressed(pBitmap, pWorkBuffer, pRunBuffer, nRow, nLines)


pointer to the bitmap handle

L_UCHAR* pWorkBuffer;

pointer to a work buffer

L_UINT16* pRunBuffer;

pointer to the target buffer

L_UINT nRow;

number of the first row to retrieve

L_UINT nLines;

number of the rows to retrieve

Retrieves one or more rows of 1-bit compressed data from a bitmap that has been loaded in its compressed format.




Pointer to the bitmap handle referencing the bitmap to get the data from.


NULL or a pointer to an optional work buffer. Allocating the work buffer speeds processing if you call this function more than once, because if you do not allocate a work buffer, the function allocates and frees a temporary buffer each time it is called. The size of this buffer should be the same as the bitmap handle's BytesPerLine field.


Pointer to the output buffer, which will be filled with 1-bit compressed image data. Calculate the required size of this buffer as follows: bytes required = nLines * ((bitmap width + 3) * 2).


Number of the first row to retrieve.


Number of rows to retrieve.



The function was successful.

< 1

An error occurred. Refer to Return Codes.


This function is useful for working with 1-bit images that are loaded in their compressed formats for faster loading and display. For more information, refer to Speeding Up 1-Bit Documents.

Required DLLs and Libraries


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


Win32, x64, Linux.

See Also


L_ExpandRow, L_CompressRow, L_GetBitmapRowColCompressed, L_PutBitmapRowColCompressed, L_PutBitmapRowCompressed


Speeding Up 1-Bit Documents


The following example is designed to work with bitmaps that have a bottom-left or top-left view perspective: This example demonstrates the low-level functions for accessing 1-bit compressed bitmap data. It demonstrates the ability to get and put rows, and the ability to process rows in buffer-to-buffer processing. The result of the function is an the first 50 lines are inverted.

L_INT GetBitmapRowCompressedExample(L_TCHAR*  pszFilename,HWND  hWnd) 
   BITMAPHANDLE   LeadBitmap;  /* Bitmap handle for the image */ 
   L_UCHAR*       pBuffer;     /* Buffer to hold the expanded row */ 
   L_UINT16*      pRunBuffer;  /* Buffer to hold the compressed row */ 
   HGLOBAL        hBuffer;     /* Handle to the pBuffer */ 
   HGLOBAL        hRunBuffer;  /* Handle to the pRunBuffer */ 
   L_INT          n;           /* Counters */ 
   L_INT          nRow = 0;    /* first row to get */ 
   L_INT          nYSize = 50; /* # of rows to get */ 
   L_INT          nRet; 
   /* Load the bitmap, as compressed */ 
   nRet = L_LoadFile(pszFilename,&LeadBitmap, sizeof(BITMAPHANDLE),1,0, 
               NULL, NULL, NULL, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
   /* if the ViewPerspective is not TOP_LEFT or BOTTOM_LEFT, make it TOP_LEFT */ 
   /* Get/PutRow functions only work with TOP_LEFT or BOTTOM_LEFT */ 
   if ( (LeadBitmap.ViewPerspective != TOP_LEFT) 
      || (LeadBitmap.ViewPerspective != BOTTOM_LEFT) ) 
      L_ChangeBitmapViewPerspective ( NULL, &LeadBitmap, sizeof(BITMAPHANDLE), TOP_LEFT ); 
   if (LeadBitmap.ViewPerspective == BOTTOM_LEFT) 
      nRow = LeadBitmap.Height - nRow - nYSize; 
   /* Allocate the buffers */ 
   hBuffer = GlobalAlloc(GMEM_MOVEABLE, (((LeadBitmap.Width + 31) &~31)/ 8) * nYSize); 
   pBuffer = (L_UCHAR*)GlobalLock( hBuffer ); 
   hRunBuffer = GlobalAlloc (GMEM_MOVEABLE, (L_UINT32)((LeadBitmap.Width + 3) * 2) * nYSize); 
   pRunBuffer = (L_UINT16*)GlobalLock (hRunBuffer); 
   /* Access the bitmap */ 
   /* Get the top nRow lines */ 
   nRet = L_GetBitmapRowCompressed ( &LeadBitmap, NULL, pRunBuffer, nRow, nYSize ); 
   if(nRet != SUCCESS) 
      return nRet; 
   /* Expand the compressed data */ 
   nRet = L_ExpandRows( pRunBuffer, pBuffer, LeadBitmap.Width, nYSize); 
   if(nRet != SUCCESS) 
      return nRet; 
   /* Invert the data */ 
   for(n=0; n < (L_INT)LeadBitmap.BytesPerLine * nYSize; n++) 
      pBuffer[n] = pBuffer[n] ^ 0xFF; 
   /* Compress the inverted data */ 
   nRet = L_CompressRows( pRunBuffer, pBuffer, LeadBitmap.Width, nYSize); 
   if(nRet != SUCCESS) 
      return nRet; 
   /* Put the inverted, compressed data back into the bitmap */ 
   nRet = L_PutBitmapRowCompressed ( &LeadBitmap, NULL, pRunBuffer, nRow, nYSize );  
   if(nRet != SUCCESS) 
      return nRet; 
   /* Free memory that we no longer need */ 
   return SUCCESS; 

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

LEADTOOLS Raster Imaging C API Help