wpWriteImageFile - Example Code

This example shows how the WPBitmap class writes the data to the image file.

SOM_Scope BOOL32 bmp_wpWriteImageFile(WPBitmap *somSelf)
{
    CHAR                 szPath[CCHMAXPATH];
    HFILE                hfile = NULLHANDLE;
    ULONG                ulAction, ulBytesWritten = 0, ulSize=0;
    APIRET               rc;
    PBYTE                pBitmapData;
    ULONG                ulBitmapDataSize;

    /* Get the pointer to the bitmap data and its size  */
    pBitmapData = _wpQueryBitmapData(somSelf,&ulBitmapDataSize);

    /* Find the bitmap data file  */
    _wpQueryFilename(somSelf, szPath, TRUE);

    /* Write the file from the buffer  */
    rc = DosOpen(szPath,
                 &hfile,
                 &ulAction,
                 ulSize,
                 FILE_NORMAL,
                 FILE_OPEN,
                 OPEN_ACCESS_WRITEONLY | OPEN_SHARE_DENYNONE,
                 NULL);

    if (rc == 0)
    {
       rc = DosWrite(hfile,
                     pBitmapData,
                     ulBitmapDataSize,
                     &ulBytesWritten);

       DosClose(hfile);
       hfile = NULLHANDLE;
    }
    return (!rc && (ulBytesWritten == ulBitmapDataSize));
}


[Back: wpWriteImageFile - Related Methods]
[Next: wpWriteImageFile - Topics]