#include "l_bitmap.h"
L_LTKRN_API L_INT L_SetBitmapDataPointer(pBitmap, pData, dwSize)
Sets the data pointer for the specified bitmap to the specified data pointer pData
.
Pointer to the bitmap handle that references the bitmap whose data pointer will be set.
Data pointer used to set the specified bitmaps data pointer.
Size of the data buffer pointed to by pData.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
This function can be used to change the data pointer of a bitmap that was created by L_CreateBitmap, or allocated by L_AllocateBitmap, with memory type TYPE_USER. The data pointer to of the bitmap is set to the data pointer passed in through pData
.
You are responsible for managing the image data. L_FreeBitmap will not free pData.
The memory buffer pointed to by pData must be valid when the bitmap is being used. If you free a memory buffer that is referenced by a bitmap, you will get access violations when you try to use that bitmap.
If you pass NULL for pData, the bitmap has no bitmap data. You should not try to use a bitmap that has no data pointer.
Note: To calculate the correct size for a single row of image data:
Windows: (((Width * BitsPerPixel) + 31) >> 3)) &~3
Linux: (((Width * BitsPerPixel) + 7) / 8)
Required DLLs and Libraries
Win32, x64, Linux.
Please note that you need to free the memory allocated for the bitmap and the bitmap data using the following:
L_INT SetBitmapDataPointerExample(pBITMAPHANDLE pBitmap)
{
// allocate a buffer large enough to hold two copies of the image
L_UCHAR* pBuffer = (L_UCHAR*)GlobalAllocPtr(GMEM_MOVEABLE, pBitmap->Size * 2);
L_INT i;
L_INT nRet;
// lock the bitmap
L_AccessBitmap(pBitmap);
// loop and get the flipped and normal versions of the image into pBuffer
for(i = 0; i < pBitmap->Height; i++)
{
nRet =(L_INT) L_GetBitmapRow(pBitmap,
pBuffer + i * pBitmap->BytesPerLine,
pBitmap->ViewPerspective == TOP_LEFT ? pBitmap->Height - i - 1 : i,
pBitmap->BytesPerLine);
if(nRet < 1)
return nRet;
memcpy( pBuffer + pBitmap->Size + (pBitmap->Height - i - 1) * pBitmap->BytesPerLine,
pBuffer + i * pBitmap->BytesPerLine,
pBitmap->BytesPerLine);
}
//unlock the bitmap
L_ReleaseBitmap(pBitmap);
// free the original image. Note that it is assumed that the image was 24 bit
// for simplicity, so that it is not necessary to pass an array of palette entries to L_CreateBitmap
// For color images, you would have to get the palette entries and pass them instead of NULL
L_FreeBitmap(pBitmap);
// this sets the image to be the flipped version
if((nRet = L_CreateBitmap(pBitmap, sizeof(BITMAPHANDLE),
TYPE_USER,
pBitmap->Width, pBitmap->Height, pBitmap->BitsPerPixel,
pBitmap->Order, NULL,
TOP_LEFT,
pBuffer, pBitmap->Size)) == SUCCESS)
{
MessageBox( NULL, TEXT("The image is flipped"), TEXT(""), MB_OK);
// this sets the image to be the non-flipped version
return L_SetBitmapDataPointer(pBitmap, pBuffer + pBitmap->Size, pBitmap->Size);
}
return nRet;
}
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