by Marco Turco » Wed Jun 21, 2006 2:52 pm
Ecco la funzione di conversione che utilizza gfl.
Devi passargli il file origine, il nome del file destinazione ed il formato da adottare per il nuovo file. Non fare caso al nome dei parametri, io utilizzo questa funzione unicamente per convertire un file bmp generato da scanner in formato jpg ma puoi convertirlo in una moltitudine di formati ed anche utilizzare file di input di formato diverso da bmp.
Considera che la libreria in questione non è utilizzabile a fini commerciali. Per utilizzarla a fini di lucro devi acquistare la versione commerciale (che comunque se ricordo bene ho pagato un centinaio di euro).
Saluti
Marco
PS. Se la tua è solo una necessità di preview, puoi risolverla comunque più agevolmente con Easypreview che prevede tra l'altro anche l'export in pdf. Mentre per l'export in RTF/DOC puoi utilizzare la dll di Amyuni Tecnologies specifica per la conversione EMF->RTF.
#include "Fivewin.ch"
STATIC hLib
FUNCTION convertfile( cWmf, cJpg, cFormatName )
LOCAL oGflLoadParams := OGFLLOADPARAMS()
LOCAL oGflSaveParams := OGFLSAVEPARAMS()
LOCAL oGflFileInfo := OGFLFILEINFO()
LOCAL nGflBitmap := 0
LOCAL nRet
if .not. file(cWmf)
return
endif
hLib = LOADLIB32( "libgfl.dll" )
GFLLIBINIT()
GFLENABLELZW( 1 )
GFLGETDEFPARAMS( oGflLoadParams:cBuffer )
nRet = GFLLOADBMP( cWmf, @nGflBitmap, oGflLoadParams:cBuffer, oGflFileInfo:cBuffer )
GFLFREEFILEINFO( oGflFileInfo:cBuffer )
oGflSaveParams:nFmtIndex = GFLFMTINDEX( cFormatName )
oGflSaveParams:nQuality = 100
oGflSaveParams:nProgress = 1
nRet = GFLSAVEBMP( cJpg, nGflBitmap, oGflSaveParams:cBuffer )
GFLLIBEXIT()
FREELIB32( hLib )
ferase(cWmf)
RETURN NIL
#include "Struct.ch"
STATIC FUNCTION OGFLBITMAP()
LOCAL oGflBitmap
STRUCT oGflBitmap
MEMBER nType AS WORD
MEMBER nOrigin AS WORD
MEMBER nWidth AS LONG
MEMBER nHeight AS LONG
MEMBER nBytesPL AS DWORD
MEMBER nLinePad AS WORD
MEMBER nReserved AS WORD
MEMBER nBytesPP AS BYTE
MEMBER nBitsPC AS BYTE
MEMBER nXDpi AS WORD
MEMBER nYDpi AS WORD
MEMBER nTranspInd AS WORD
MEMBER nClrUsed AS LONG
MEMBER nClrMap AS LONG
MEMBER nData AS LONG
ENDSTRUCT
RETURN oGflBitmap
STATIC FUNCTION OGFLLOADPARAMS()
LOCAL oGflLoadParams
STRUCT oGflLoadParams
MEMBER nFlags AS DWORD
MEMBER nFormatInd AS LONG
MEMBER nImgWant AS LONG
MEMBER nOrigin AS WORD
MEMBER nClrModel AS WORD
MEMBER nLinePad AS DWORD
MEMBER nDefAlpha AS BYTE
MEMBER nReserved1 AS BYTE
MEMBER nReserved2 AS WORD
MEMBER nWidth AS LONG
MEMBER nHeight AS LONG
MEMBER nOffset AS DWORD
MEMBER nChanOrder AS WORD
MEMBER nChanType AS WORD
MEMBER nPcdBase AS WORD
MEMBER nEpsDpi AS WORD
MEMBER nEpsWidth AS LONG
MEMBER nEpsHeight AS LONG
MEMBER nRead AS DWORD
MEMBER nTell AS DWORD
MEMBER nSeek AS DWORD
MEMBER nAlloc AS DWORD
MEMBER nFree AS DWORD
MEMBER nAllocParm AS DWORD
ENDSTRUCT
RETURN oGflLoadParams
STATIC FUNCTION OGFLSAVEPARAMS()
LOCAL oGflSaveParams
STRUCT oGflSaveParams
MEMBER nFlags AS DWORD
MEMBER nFmtIndex AS LONG
MEMBER nCompress AS WORD
MEMBER nQuality AS WORD
MEMBER nCmpLevel AS WORD
MEMBER nInterlacd AS BYTE
MEMBER nProgress AS BYTE
MEMBER nOffset AS DWORD
MEMBER nChanOrder AS WORD
MEMBER nChanType AS WORD
MEMBER nWrite AS DWORD
MEMBER nTell AS DWORD
MEMBER nSeek AS DWORD
MEMBER nAlloc AS DWORD
MEMBER nFree AS DWORD
MEMBER nAllocParm AS DWORD
ENDSTRUCT
RETURN oGflSaveParams
STATIC FUNCTION OGFLFILEINFO()
LOCAL oGflFileInfo
STRUCT oGflFileInfo
MEMBER nType AS WORD
MEMBER nOrigin AS WORD
MEMBER nWidth AS LONG
MEMBER nHeight AS LONG
MEMBER nFormatInd AS LONG
MEMBER cFormtName AS STRING LEN 8
MEMBER cDescriptn AS STRING LEN 64
MEMBER nXDpi AS WORD
MEMBER nYDpi AS WORD
MEMBER nBitsPP AS WORD
MEMBER nPlanes AS WORD
MEMBER nBytesPP AS DWORD
MEMBER nImages AS LONG
MEMBER nFileSize AS DWORD
MEMBER nClrModel AS WORD
MEMBER nCompressn AS WORD
MEMBER cCmpDescrp AS STRING LEN 64
MEMBER nComment AS WORD
MEMBER nReserved AS WORD
MEMBER nComments AS LONG
ENDSTRUCT
RETURN oGflFileInfo
DLL32 FUNCTION GFLLIBINIT() AS LONG;
PASCAL FROM "gflLibraryInit" LIB hLib
DLL32 FUNCTION GFLLIBEXIT() AS VOID;
PASCAL FROM "gflLibraryExit" LIB hLib
DLL32 FUNCTION GFLENABLELZW( nEnable AS LONG ) AS VOID;
PASCAL FROM "gflEnableLZW" LIB hLib
DLL32 FUNCTION GFLGETDEFPARAMS( cLoadParams AS LPSTR ) AS VOID;
PASCAL FROM "gflGetDefaultLoadParams" LIB hLib
DLL32 FUNCTION GFLFREEFILEINFO( cFileInfo AS LPSTR ) AS VOID;
PASCAL FROM "gflFreeFileInformation" LIB hLib
DLL32 FUNCTION GFLLOADBMP( cFileName AS LPSTR, @nBitmap AS PTR, cLoadParams AS LPSTR, cInformation AS LPSTR ) AS LONG;
PASCAL FROM "gflLoadBitmap" LIB hLib
DLL32 FUNCTION GFLSAVEBMP( cFileName AS LPSTR, nBitmap AS LONG, cSaveParams AS LPSTR ) AS LONG;
PASCAL FROM "gflSaveBitmap" LIB hLib
DLL32 FUNCTION GFLFMTINDEX( cFormat AS LPSTR ) AS LONG;
PASCAL FROM "gflGetFormatIndexByName" LIB hLib