This example shows how the WPBitmap data class changes the contents of a bitmap file.
SOM_Scope BOOL32 bmp_wpSetBitmapData(WPImageFile *somSelf,
PBYTE pBitmapData,
ULONG ulSize)
{
PBITMAPFILEHEADER pbfh;
BOOL bResult;
/* Make sure this is really a bitmap definition */
pbfh = (PBITMAPFILEHEADER) pBitmapData;
if (pbfh->usType != BFT_BITMAPARRAY &&
pbfh->usType != BFT_BMAP)
{
return FALSE;
}
/* Free the old data buffer */
if(_pBitmapData)
{
_wpFreeMem(somSelf,_pBitmapData);
_pBitmapData = NULL;
_ulBitmapDataSize = 0;
}
/* Update the bitmap data file */
_pBitmapData = pBitmapData;
_ulBitmapDataSize = ulSize;
bResult = _wpWriteImageFile(somSelf);
_pBitmapData = NULL;
_ulBitmapDataSize = 0;
/* If the file was written successfully, read the data back from the file
* Note: This ensures that only the current resolution bitmap is
* kept in memory */
if(bResult)
{
bResult = _wpReadImageFile(somSelf);
}
return bResult;
}