Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Converting General field to BMP
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Photos et traitement d'images
Divers
Thread ID:
00718764
Message ID:
00719098
Vues:
28
Paul,

Here is some code that I use. It is kind of a crude technique, but it works for me most of the time.

Hope it helps,

Bo Durban
***********************************************************
** ExtractBMP
** Extracts a BMP file stored in a General field to a file.
** Parameters:
**    cGenField - Name of general field to export
**    cFileName - Name of file to store BMP
** Note - While this works most of the time it is not 100%.
***********************************************************
FUNCTION ExtractBMP
LPARAMETERS cGenField, cFileName
LOCAL cTempTable, cTempMemo, cFile, nAt

cFileName = DEFAULTEXT(cFileName,"bmp")

IF TYPE(cGenField) <> "G"
    MESSAGEBOX(cGenField+" is not a general field")
    RETURN .F.
ENDIF

** Temporary work area
cTempTable = ADDBS(SYS(2023))+SYS(2015)+".tmp"
cTempMemo = FORCEEXT(cTempTable, "fpt")

COPY TO (cTempTable) FIELDS (cGenField) NEXT 1

** Convert memo file to string
cFile = FILETOSTR(cTempMemo)
** Delete temp work area
DELETE FILE (cTempTable)
DELETE FILE (cTempMemo)

** Locate BMP start byte
nAt = AT("BM",cFile)

IF nAt > 0
    ** Truncate string
    cFile = SUBSTR(cFile, nAt)
    STRTOFILE(cFile, cFileName)
ElSE
    MESSAGEBOX("Could not locate BMP file in field")
    RETURN .F.
ENDIF

RETURN .T.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform