wpSetBitmapData
This method is specific to Version 4, or higher, of the OS/2 operating system.
This instance method sets the bitmap data for the image file. This method will convert the bitmap data to the appropriate format and update the actual image data file.
Syntax
_wpSetBitmapData(somSelf, pBitmapData, ulSize)
Parameters
- somSelf (WPBitmap *) - input
- Pointer to the object on which the method is being invoked.
- Points to an object of class WPBitmap.
- pBitmapData (PBYTE) - input
- Buffer containing the image data in OS/2 Bitmap format.
- ulSize (ULONG) - input
- The size of the buffer.
Returns
- rc (BOOL32) - returns
- Success indicator.
- TRUE Successful completion.
- FALSE Error occurred.
How to Override
The **wpSetBitmapData** method must be overridden in any subclass of WPImageFile.
Usage
The Workplace Shell calls the **wpSetBitmapData** method when it wants to change the contents of a WPImageFile object to contain a different image.
Remarks
This is a virtual method at the WPImageFile level. Subclasses that implement actual image file types are expected to subclass this method so they can return a bitmap representation of their data (for example, **WPBitmap** and **MMImage**). This example shows how the **WPBitmap** data class changes the contents of a bitmap file.
Example Code
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;
}