Puts a row (or part of a row) of 1-bit compressed data from a buffer to a bitmap that is maintained in its compressed format.
#include "l_bitmap.h"
L_LTKRN_API L_SSIZE_T L_PutBitmapRowColCompressed(pBitmap, pWorkBuffer, pRunBuffer, nRow, nCol, uWidth)
Pointer to the bitmap handle referencing the bitmap to be updated.
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 input buffer, which contains 1-bit compressed image data.
The number of the row to update. The first row is 0, and the last row is 1 less than the bitmap height.
The column offset within the row to update. The first column offset is 0, and the last column offset is 1 less than the bitmap width.
The number of pixels to retrieve.
Value | Meaning |
---|---|
> 0 | The number of pixels processed. |
< 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.
Win32, x64, Linux.
This example demonstrates the low-level functions for accessing
1-bit compressed bitmap data. It demonstrates the ability to get and put
partial rows, and the ability to process partial rows in buffer-to-buffer
processing. The result of the function is an inverted rectangle in the
middle of the image.
L_INT PutBitmapRowColCompressedExample(L_TCHAR* pszFilename,
HWND hWnd,
pBITMAPHANDLE pLeadBitmap)
{
L_INT nRet;
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 */
L_UCHAR* pBuffer; /* Buffer to hold the expanded row */
L_UINT16* pRunBuffer; /* Buffer to hold the compressed row */
L_UCHAR* pWorkBuffer; /* Work buffer */
HGLOBAL hBuffer; /* Handle to the pBuffer */
HGLOBAL hRunBuffer; /* Handle to the pRunBuffer */
HGLOBAL hWorkBuffer; /* Handle to the pWorkBuffer */
L_INT i, n; /* Counters */
/* Load the bitmap, at 1 bit per pixel */
if(pLeadBitmap->Flags.Allocated)
L_FreeBitmap(pLeadBitmap);
nRet = L_LoadFile( pszFilename, pLeadBitmap, sizeof(BITMAPHANDLE),1,0,
LOADFILE_COMPRESSED | LOADFILE_ALLOCATE | LOADFILE_STORE,
NULL, NULL, NULL, NULL);
if(nRet != SUCCESS)
return nRet;
/* This example does not work with rotated view perspectives */
if ( (pLeadBitmap->ViewPerspective != TOP_LEFT) || (pLeadBitmap->ViewPerspective != BOTTOM_LEFT) )
{
nRet = L_ChangeBitmapViewPerspective ( NULL, pLeadBitmap, sizeof(BITMAPHANDLE), TOP_LEFT );
if(nRet != SUCCESS)
{
L_FreeBitmap(pLeadBitmap);
return nRet;
}
}
/* Specify a rectangle in the middle right part of the displayed image */
XOffset = pLeadBitmap->Width / 3;
XSize = pLeadBitmap->Width * 2 / 3;
YOffset = pLeadBitmap->Height / 3;
YSize = pLeadBitmap->Height / 3;
/* Adjust the YOffset if the view perspective is bottom left */
if (pLeadBitmap->ViewPerspective == BOTTOM_LEFT)
{
YOffset = pLeadBitmap->Height - YOffset - YSize;
}
/* Allocate the buffers */
hBuffer = GlobalAlloc(GMEM_MOVEABLE, ( XSize + 7) / 8);
pBuffer = (L_UCHAR*)GlobalLock( hBuffer );
hRunBuffer = GlobalAlloc(GMEM_MOVEABLE, (XSize + 3) * 2);
pRunBuffer = (L_UINT16*)GlobalLock( hRunBuffer );
hWorkBuffer = GlobalAlloc(GMEM_MOVEABLE, pLeadBitmap->BytesPerLine);
pWorkBuffer = (L_UCHAR* )GlobalLock( hWorkBuffer );
/* Invert the colors of pixels in the left half of the rectangle. */
/* Notice that we get the whole rectangle, but process only half of it. */
L_AccessBitmap(pLeadBitmap);
for(i=YOffset; i < (YOffset + YSize); i++)
{
nRet = (L_INT)L_GetBitmapRowColCompressed(pLeadBitmap, pWorkBuffer,
pRunBuffer, i, XOffset, XSize);
if(nRet < 1)
{
L_FreeBitmap(pLeadBitmap);
return nRet;
}
nRet = L_ExpandRow(pRunBuffer, pBuffer, 0, XSize/2);
if(nRet != SUCCESS)
{
L_FreeBitmap(pLeadBitmap);
return nRet;
}
for(n=0; n < (XSize /16); n++)
pBuffer[n] = pBuffer[n] ^ 0xFF;
nRet = L_CompressRow(pRunBuffer, pBuffer, 0, XSize/2);
if(nRet < 1 )
{
L_FreeBitmap(pLeadBitmap);
return nRet;
}
nRet =(L_INT)L_PutBitmapRowColCompressed(pLeadBitmap, pWorkBuffer, pRunBuffer, i,
XOffset, XSize/ 2);
if(nRet < 1)
{
L_FreeBitmap(pLeadBitmap);
return nRet;
}
}
L_ReleaseBitmap(pLeadBitmap);
/* Free memory that we no longer need */
GlobalFree(hBuffer);
GlobalFree(hRunBuffer);
GlobalFree(hWorkBuffer);
/* Update the paint palette to force a repaint */
SendMessage (hWnd, WM_QUERYNEWPALETTE, 0, 0L);
return SUCCESS;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.