Herd Software Development
DaVinci Graphics Library
DaVinci Documentation
Using DaVinci with TImageThis topic shows precisely how easy it is to import images in a wide range of formats, including vector-based formats, into a TImage using DaVinci.
{ Let the user select an image to display from all supported formats }
procedure TDavForm.ImportPictureUsingDaVinci(FileName : String);
var szFileName : Array[0..128] of char;
hdb : THandle; { handle of the imported bitmapped image }
hMetafile : THandle; { handle of imported metafile }
Resolution : METARESOLUTION; { metric size data if user picks a metafile. }
ipErr : Integer; { DaVinci - Errorcode Variable }
const WmfPointSize : TPoint = ( x:96; y:96 ); { Dimensions of metafile if user selects one }
Begin
{ initialize the variables needed by ipImportExt }
StrPCopy(szFileName, FileName);
hdb := 0;
hMetaFile := 0;
ipErr := ipImportExt(
@hdb, { pointer address of the DIB handle, NOT the handle itself }
@hMetaFile, { pointer address of metafile }
szFileName, { name of file user will select }
{ IPF_FILEDIALOG or } IPF_MSGBOX or IPF_DIB or IPF_META, { allow bitmaps AND metafiles, and show errors in messagebox }
NIL, { callback function...no progress bar used here so not needed }
IPT_SELECT, { user can pick any supported image type }
Handle, { parent window for the file dialog }
@WmfPointSize, { pointer to dimensions of a metafile if selected }
@Resolution, { metafile dimensions }
0);
if (ipErr = IPE_OK) then { Imported OK, so... }
Begin
{-------------- Change form caption -------------------------- }
Davform.Caption := 'DaVinci import demo: ' + StrPas(szFileName);
if (hdb <> 0) Then { there's a DIB handle here... }
Begin
{-------------- Place the new DIB in the Form --------------- }
ShowNewDib(hdb);
End
else
if (hMetaFile <> 0) then { we've got a metafile }
Begin
{-------------- Place the new metafile in the Form ---------- }
ShowNewMetafile(hMetaFile, @Resolution);
End
End;
End;
The GETDIB.PAS and GETTEST.PAS samples are offered for use with 16 bit applications and show how to directly access DIB data contents with more than 64 KByte of data from a Delphi 1 application as an alternative to the RWxxxx functions.