Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Converting General field to BMP
Message
General information
Forum:
Visual FoxPro
Category:
Pictures and Image processing
Miscellaneous
Thread ID:
00718764
Message ID:
00719098
Views:
24
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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform