Jump to content

MCI_SETIMAGEBUFFER

From EDM2

This message writes data to the image capture buffer. The fields in the MCI_IMAGE_PARMS structure are used to interpret the data. Using this message invalidates or resets the current element name or element HMMIO handle, as the data provided by the application replaces the current element.

Syntax

param1
ULONG ulParam1; /* Message flags. */

param2
PMCI_IMAGE_PARMS pParam2; /* Pointer to the MCI_IMAGE_PARMS structure. */

Parameters

ulParam1 (ULONG) - input
The following flags can be used:
  • MCI_NOTIFY Posts a notification message when the action completes.
  • MCI_WAIT Does not return control until the action is completed.
  • MCI_CONVERT Specifies that image format conversion will be performed. The source data is assumed to be in the OS/2 uncompressed bitmap format and will be converted to the device-specific format.
pParam2 (PMCI_IMAGE_PARMS) - input
A pointer to the MCI_IMAGE_PARMS data structure.

Returns

rc (ULONG) - returns
  • MCIERR_SUCCESS MMPM/2 command completed successfully.
  • MCIERR_INVALID_DEVICE_ID Invalid device ID.
  • MCIERR_INSTANCE_INACTIVE Instance is inactive.
  • MCIERR_MISSING_PARAMETER A required parameter is missing.
  • MCIERR_INVALID_FLAG Invalid flag specified.
  • MCIERR_UNSUPPORTED_FLAG Flag not supported by this driver.
  • MCIERR_OUT_OF_MEMORY System out of memory.
  • MCIERR_FILE_NOT_FOUND File not found.
  • MCIERR_TARGET_DEVICE_FULL Target device (or temporary storage) is full.

Remarks

The format of the image data is defined by the `ulPelFormat` and `usBitCount` fields in the parameter structure.

  • **With MCI_CONVERT:** Data must be in OS/2 bitmap format. The driver expects a `BITMAPINFOHEADER2` structure at the beginning of the buffer, followed by palette data and then the pixel (pel) data.
  • **Without MCI_CONVERT:** Data is placed directly into the device element buffer without modification.
  • **Format Conflicts:** If the current bits-per-pel, pixel-format, or `MCI_CONVERT` values conflict, the message will fail.
  • **YUV Conversion:** Conversion from OS/2 bitmap to YUVB format may use an I/O procedure requiring temporary disk space; if disk space is insufficient, `MCIERR_TARGET_DEVICE_FULL` is returned.

Example Code

The following code illustrates how to write data to the image capture buffer using both RGB (converted) and YUV formats.

  USHORT  usUserParm = 0;
  ULONG   ulReturn;
  BITMAPINFOHEADER2 *pbmphdr;
  MMOTIONHEADER *pmmothdr;
  MCI_IMAGE_PARMS mciImageParms;

  memset (&mciImageParms, 0x00, sizeof (MCI_IMAGE_PARMS));
  mciImageParms.hwndCallback = hwndNotify;

  /* Example logic for setting from a buffer */
  if (ulFlags & MCI_CONVERT)
  {
     /* RGB BITMAP data buffer */
     mciImageParms.ulPelFormat = MCI_IMG_RGB;
     mciImageParms.usBitCount = 24;
     mciImageParms.ulImageCompression = MCI_IMG_COMP_NONE;
     mciImageParms.ulPelBufferWidth  = 200;
     mciImageParms.ulPelBufferHeight = 100;
     mciImageParms.ulBufLen = ((200 * 3) * 100) + sizeof(BITMAPINFOHEADER2);

     DosAllocMem (&mciImageParms.pPelBuffer,
                  mciImageParms.ulBufLen,
                  PAG_COMMIT | PAG_WRITE | PAG_READ);

     /* Setup BITMAP HEADER */
     pbmphdr = (BITMAPINFOHEADER2 *)mciImageParms.pPelBuffer;
     pbmphdr->cbFix     = sizeof (BITMAPINFOHEADER2);
     pbmphdr->cx        = mciImageParms.ulPelBufferWidth;
     pbmphdr->cy        = mciImageParms.ulPelBufferHeight;
     pbmphdr->cPlanes   = 1;
     pbmphdr->cBitCount = mciImageParms.usBitCount;

     /* Fill data section with white */
     memset ((PVOID)((ULONG)mciImageParms.pPelBuffer + sizeof(BITMAPINFOHEADER2)),
             0xFF, mciImageParms.ulBufLen - sizeof(BITMAPINFOHEADER2));
  }
  else
  {
     /* M-Motion YUV data buffer */
     mciImageParms.ulPelFormat = MCI_IMG_YUV;
     mciImageParms.usBitCount = 12;
     mciImageParms.ulImageCompression = MCI_IMG_COMP_NONE;
     mciImageParms.ulPelBufferWidth  = 200;
     mciImageParms.ulPelBufferHeight = 100;
     mciImageParms.ulBufLen = (200 * 100) + ((200 * 100) >> 1) + sizeof(MMOTIONHEADER);

     DosAllocMem (&mciImageParms.pPelBuffer,
                  mciImageParms.ulBufLen,
                  PAG_COMMIT | PAG_WRITE | PAG_READ);

     pmmothdr = (MMOTIONHEADER *)mciImageParms.pPelBuffer;
     strncpy (pmmothdr->mmID, "YUV12C", 6);
     pmmothdr->mmXlen = mciImageParms.ulPelBufferWidth;
     pmmothdr->mmYlen = mciImageParms.ulPelBufferHeight;
  }

  ulReturn = mciSendCommand(usDeviceID, MCI_SETIMAGEBUFFER,
                            MCI_WAIT | ulFlags,
                            (PVOID)&mciImageParms,
                            usUserParm);

Related Messages