| Herd Software Development
DaVinci Graphics Library
DaVinci Documentation Home Search Order

Data sources and "data sinks" (streams)

Using DaVinci as a compression tool

In addition toDaVinci's capabilities as a format converter, it can also act as an image compressor. JPEG is particularly well-suited to compressing detailed renderings and photographic scans, although the lossy nature of JPEG makes archival storage of the original non-compressed bitmap essential for repeated processing. TIFF's G3 and G4 compression schemes, designed primarily for use with fax transmissions, are especially good performers where compact mass storage of monochrome images is required.

Streaming: an alternative to file I/O

DaVinci's primary purpose, as the documentation suggests, is for use with file-based image data. But it also supports an efficient streaming technology which can allow for such things as image databasing and direct data transfer within and between applications.

MMSYSTEM.DLL/WINMM.DLL: DaVinci's helpers in streaming

DaVinci uses the internal functions of MMSYSTEM.DLL (16 bit OS') and WINMM.DLL (32 bit OS') to assist its streaming technology. These modules add the following interesting and useful technologies to the programmer's toolkit. While these functions were developed primarily for multimedia streaming, they can be used for virtually any purpose where streaming is required using API functions.

Memory files

MMSYSTEM's API permits opening a memory block as an HMMIO file. The mmioOpen function must be called with a prepared MMIOINFO structure before the memory block is available and usable as a file. (See also Performing Memory File I/O/O in the WIN32 API

To read (import) from main memory
Any memory area can be used for import.
#include <mmsystem.h>

MMIOINFO mmioInfo;
memset(&mmioInfo, 0, sizeof(MMIOINFO));

   mmioInfo.pchBuffer = lpBuffer;
   mmioInfo.cchBuffer = dwBufferLength;
   mmioInfo.fccIOProc = FOURCC_MEM;
   if (NULL!=(hmmioMem = mmioOpen(NULL, &mmioInfo, MMIO_READWRITE)))
      lpDavParams->hmmio = hmmioMem;

      // ....insert DaVinci import process here...

      mmioClose(hmmioMem, 0);
      lpDavParams->hmmio = NULL;
To write (export) to main memory
Writing to memory in this fashion could become considerably more complicated if the filesize of the exported data is not known.
MMIOINFO mmioInfo;
memset(&mmioInfo, 0, sizeof(MMIOINFO));

   mmioInfo.adwInfo   = 0x20000L;
   mmioInfo.fccIOProc = FOURCC_MEM;
   if (NULL!=(hmmioMem = mmioOpen(NULL, &mmioInfo, MMIO_READWRITE)))
      lpDavParams->hmmio = hmmioMem;

      // ....DaVinci export process...

      mmioGetInfo(lpDavParams->hmmio, &mmioInfo, 0);

      //.... Pointer and size of memory block are now available in mmioInfo

      mmioClose(hmmioMem, 0);
      lpDavParams->hmmio = NULL;

Streaming with a callback

When a callback is required, an application needs to register a file system with MMSYSTEM by calling mmioInstallIOProc. This is usually done when the application is opened. The file system is characterized by a four-character code and a callback function, usually assigned a one-character function name. Here's an example.
extern "C"
LRESULT CALLBACK _export mmioProc(

    LPSTR  lpmmioinfo,	// address of structure with file information
    UINT  uMsg,	// specifies sent message
    LONG  lParam1,	// application-defined parameter
    LONG  lParam2	// application-defined parameter
{ return 0;
  mmioInstallIOProc(mmioFOURCC('D','G','X',' '), &mmioProc, MMIO_INSTALLPROC);

In this case, DGX is only used as an example. You can specify any "FOURCC" (four-character code) you like. Your installed I/O procedure is being used when a file of the following naming convention is being opened by a call to mmioOpen:


The base filename defines the name of an existing DOS file (PFADNAME\DATEINAME.DGX) matching the FOURCC installed I/O procedure. Subsequent follows a + - character and the name of the graphicwithin the file.

DaVinci uses the file name transferred in the case of the call of the DaVinci function ipImportInd in the case of a call of the function mmioOpen of the MMSYSTEM.DLL. This recognizes that an installed file system is available for this name and calls in a provided manner to callback-Routine that from the application with the message MMIOM_OPEN.

The application can now take the data to be processed here from the data base.

It is not necessary for the DOS file name to identify an existing file, it is sufficient, if the file name extension is ".DGX".


Visual C++ programs must link WINMM.LIB in order to call functions from the WINMM.DLL.