Sets the data pointer for the bitmap to the specified data pointer pData.
virtual L_INT LBitmapBase::SetDataPointer(pData, dwSize)
Data pointer used to set the bitmaps data pointer.
Size of the data buffer pointed to by pData.
|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 LBitmapBase::CreateBitmap, or allocated by LBitmapBase::Allocate, 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. LBitmapBase::Free 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:
(((Width * BitsPerPixel) + 31) >> 3)) &~3
#define BITMAP_WIDTH 256
#define BITMAP_HEIGHT 256
L_INT LBitmapBase__SetDataPointerExample(HWND hWnd)
HGLOBAL hGlobal1, hGlobal2;
L_UCHAR *pBuffer1, *pBuffer2;
//pBuffer1 points to raw data with 256 shades of red
//pBuffer2 points to raw data with 256 shades of green
hGlobal1 = GlobalAlloc(GMEM_MOVEABLE, BITMAP_WIDTH * BITMAP_HEIGHT * 3);
pBuffer1 = (L_UCHAR*)GlobalLock(hGlobal1);
hGlobal2 = GlobalAlloc(GMEM_MOVEABLE, BITMAP_WIDTH * BITMAP_HEIGHT * 3);
pBuffer2 = (L_UCHAR*)GlobalLock(hGlobal2);
L_INT iCol, iRow, iCounter;
iCounter = 0;
for(iCol = 0; iCol < BITMAP_WIDTH; iCol++)
for (iRow=0; iRow < BITMAP_HEIGHT; iRow++)
pBuffer1[iCounter + 0] = 0; //Blue
pBuffer1[iCounter + 1] = 0; //Green
pBuffer1[iCounter + 2] = (L_UCHAR)iCol; //Red
pBuffer2[iCounter + 0] = 0; //Blue
pBuffer2[iCounter + 1] = (L_UCHAR) iCol; //Green
pBuffer2[iCounter + 2] = 0; //Red
iCounter = iCounter + 3;
// this sets the image to be pBuffer1
BITMAP_WIDTH * BITMAP_HEIGHT * 3);
nRet =BitmapBase.Save(MAKE_IMAGE_PATH(TEXT("Test1.bmp")), FILE_BMP, 24,2,0,NULL);
nRet =BitmapBase.SetDataPointer(pBuffer2, BITMAP_WIDTH * BITMAP_HEIGHT * 3);
nRet =BitmapBase.Save(MAKE_IMAGE_PATH(TEXT("Test2.bmp")), FILE_BMP, 24,2,0,NULL);
Medical Web Viewer .NET
.NET, Java, Android, and iOS/macOS Assemblies
C API/C++ Class Libraries