Jump to content

wpWriteImageFile

From EDM2
Revision as of 04:17, 17 November 2025 by Martini (talk | contribs) (Created page with "{{DISPLAYTITLE:wpWriteImageFile}} This method is specific to Version 4, or higher, of the OS/2 operating system. This instance method writes the image data for the image file from the instance data. ==Syntax== _wpWriteImageFile(somSelf) ==Parameters== ;''somSelf'' (WPBitmap *) - input :Pointer to the object on which the method is being invoked. :Points to an object of class WPBitmap. ==Returns== ;''rc'' (BOOL32) - returns :Success indicator. :* '''TRUE''...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This method is specific to Version 4, or higher, of the OS/2 operating system.

This instance method writes the image data for the image file from the instance data.

Syntax

_wpWriteImageFile(somSelf)

Parameters

somSelf (WPBitmap *) - input
Pointer to the object on which the method is being invoked.
Points to an object of class WPBitmap.

Returns

rc (BOOL32) - returns
Success indicator.
  • TRUE Successful completion.
  • FALSE Error occurred.

How to Override

This method must be overridden by any subclass of **WPImageFile**.

Usage

Various WPImageFile methods call the **wpWriteImageFile** method to change the contents of an image file. This method converts the image data stored in the instance data from OS/2 Bitmap format to the format appropriate to the image class and writes it to the image data file.

Example Code

#define INCL_WINWORKPLACE
#include <os2.h>

WPBitmap *somSelf; /* Pointer to the object on which the method is being invoked. */
BOOL32 rc; /* Success indicator. */

rc = _wpWriteImageFile(somSelf);

Remarks

In the implementation of the **WPBitmap** class in the Workplace Shell, the **wpWriteImageFile** method writes the current bitmap to the image file. For any other image type, the **wpWriteImageFile** method should convert the bitmap data to the appropriate image format and write the data out to the image file.

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));
}

Related Methods