L_GetBitmapRowCompressed
#include "l_bitmap.h"
L_LTKRN_API L_INT L_GetBitmapRowCompressed(pBitmap, pWorkBuffer, pRunBuffer, nRow, nLines)
pBITMAPHANDLE pBitmap; |
/* 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.
Parameter |
Description |
pBitmap |
Pointer to the bitmap handle referencing the bitmap to get the data from. |
pWorkBuffer |
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. |
pRunBuffer |
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). |
nRow |
Number of the first row to retrieve. |
nLines |
Number of rows to retrieve. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
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
LTKRN For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
Platforms
Win32, x64, Mobile.
See Also
Functions: |
L_ExpandRow, L_CompressRow, L_GetBitmapRowColCompressed, L_PutBitmapRowColCompressed, L_PutBitmapRowCompressed |
Topics: |
Example
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) { UNREFERENCED_PARAMETER(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, LOADFILE_COMPRESSED | LOADFILE_ALLOCATE | LOADFILE_STORE, 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 */ L_AccessBitmap(&LeadBitmap); /* 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; L_ReleaseBitmap(&LeadBitmap); /* Free memory that we no longer need */ GlobalFree(hBuffer); GlobalFree(hRunBuffer); L_FreeBitmap(&LeadBitmap); return SUCCESS; }