LBitmapBase::SetDataPointer

#include "l_bitmap.h"

virtual L_INT LBitmapBase::SetDataPointer(pData, dwSize)

L_CHAR L_HUGE *pData;

/* data pointer */

L_UINT32 dwSize;

/* size of the data buffer pointed to by pData */

Sets the data pointer for the bitmap to the specified data pointer pData.

Parameter

Description

pData

Data pointer used to set the bitmap’s data pointer.

dwSize

Size of the data buffer pointed to by pData.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

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.

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.

See Also

Functions:

LBitmapBase::Allocate, LBitmapBase::Create

Topics:

Raster Image Functions: Creating and Deleting Images

Example

#define BITMAP_WIDTH 256
#define BITMAP_HEIGHT 256
L_VOID Example57(HWND hWnd)
{
   HGLOBAL hGlobal1, hGlobal2;
   L_UCHAR *pBuffer1, *pBuffer2;
   LBitmapBase BitmapBase; 

   //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] = iCol; //Red 

         pBuffer2[iCounter + 0] = 0; //Blue
         pBuffer2[iCounter + 1] = iCol; //Green
         pBuffer2[iCounter + 2] = 0; //Red 

         iCounter = iCounter + 3;
      }
      // this sets the image to be pBuffer1
      BitmapBase.Create
            BITMAP_WIDTH, 
            BITMAP_HEIGHT, 
            24, 
            ORDER_BGR, 
            NULL, 
            TOP_LEFT, 
            TYPE_USER,
            (L_UCHAR L_FAR*)pBuffer1, 
            BITMAP_WIDTH * BITMAP_HEIGHT * 3);
      BitmapBase.Save(TEXT("d:\\Test1.bmp"), FILE_BMP, 24,2,0,NULL); 

      BitmapBase.SetDataPointer(pBuffer2, BITMAP_WIDTH * BITMAP_HEIGHT * 3);
      BitmapBase.Save(TEXT("d:\\Test2.bmp"), FILE_BMP, 24,2,0,NULL);
}