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


The ipImportInd function: Importing graphics into applications

This function imports an image file in one of the three DaVinci supported graphics formats as either a Windows DIB, metafile or enhanced metafile.

IPERROR FAR PASCAL	ipImportInd(
LPDAVPARAMS lpDavParams);

lpDavParams LPDAVPARAMS Pointer to a DAVPARAMS structure containing the specifications of the file to be imported.

Return value

Returns 0 on success; otherwise returns an error corresponding to one of the IPE_xxxx error codes.

Remarks

Applications using this function must fill in the appropriate members of the DAVPARAMS structur before calling ipImportInd. Once the function has been called, the returned data can be retrieved from the DAVPARAMS structure.

Applications only need to fill in DAVPARAMS members required for the actual conversion. All other fields should be set to 0.

The following members must be assigned appropriate values prior to executing ipImportInd:

If successful, ipImportInd returns 0 and the application can then extract imported data from the hDIB, hMetaFile and hEnhMetaFile members of the DAVPARAMS structure.

The application is responsible for freeing the memory allocated by the returned handles by calling GlobalFree, DeleteMetaFile and DeleteEnhMetaFile respectively.

Example: File import using a file open dialog to allow user specification of filename and type.
/* FrameCMFileOpen
 *
 * Use DaVinci to import a Graphics file.
 */
void FrameCMFileOpen(HWND hWnd)
{
  char                  FileName[256];
  DAVPARAMS             DavParams;

  FileName[0]=0;

  memset(&DavParams, 0, sizeof(DavParams));
  DavParams.dwStructSize  = sizeof(DAVPARAMS);
  DavParams.dwFlags       = IPF_META | IPF_DIB | IPF_ENH | IPF_MSGBOX | IPF_FILEDIALOG; // Ask for file name, display errors, allow all data types
  DavParams.lpszFileName  = FileName;                       // Ask user for filename, but return in a variable
  DavParams.dwFileType    = IPT_SELECT;                     // Let user decide about the type of file to be imported
  if (IPE_OK == ipImportInd(&DavParams))                    // Perform import process
  {
    /* Import was successful...display new data */
    if (DavParams.hDIB)         SendMessage(hwClient, IMM_SETDIB        , (WPARAM) DavParams.hDIB     , 0);
    if (DavParams.hMetaFile)    SendMessage(hwClient, IMM_SETMETAFILE   , (WPARAM) DavParams.hMetaFile, (LPARAM)(LPSTR)&DavParams.MetaResolution);
#	ifdef __WIN32__
    if (DavParams.hEnhMetaFile) SendMessage(hwClient, IMM_SETENHMETAFILE, (WPARAM) DavParams.hEnhMetaFile, 0L);
#	endif

    /* Display new filename in title bar */
    SetWindowText(hWnd, FileName);
  }
} // FrameCMFileOpen

See also:

Þ ipImportExt

Þ ipExportInd

Þ LoadDIBFromFile