Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Display photo held in general field
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Network:
Windows 2003 Server
Miscellaneous
Thread ID:
01418119
Message ID:
01418154
Views:
50
Hi Dorris,

Jonathan Finch wrote a program called GenToFil.prg years ago to extract the image from a general field:
FUNCTION GENTOFILE
*--Extracts a .BMP,.DOC,.GIF, or .JPG file embedded in a .DBF General field
*--via the APPEND GENERAL command, which adds header and trailer which
*--must be stripped off during extraction 
PARAMETERS lcFieldname,lcFilename
LOCAL lcCompatible,lcExtension,liTopOffset,liEndOffset,;
lcTempfile,liHandelin,liHandleout,liSize,llSuccess
lcCompatible=SET("COMPATIBLE")		&& Store "Compatible" Setting
SET COMPATIBLE ON
lcExtension=UPPER(RIGHT(TRIM(lcFilename),3))
DO CASE
	CASE lcExtension="BMP"
		liTopOffset=599
		liEndOffset=83

	CASE lcExtension="DOC"
		liTopOffset=610
		liEndOffset=2654

	CASE lcExtension="GIF"
		liTopOffset=663
		liEndOffset=3780

	CASE lcExtension="JPG"
		liTopOffset=648
		liEndOffset=3779

ENDCASE
lcTempfile=SYS(3)								&& Assign temporary file name
COPY TO (lcTempfile) FIELDS (lcFieldname) NEXT 1&& Copy General field data to it  
liHandlein=FOPEN(lcTempfile+".FPT")				&& Open its .FPT 
liSize=FSIZE(lcTempfile+".FPT")-(liTopoffset+liEndOffset) && Determine data size
=FSEEK(liHandlein,liTopoffset) 					&& Move pointer past Top Offset
liHandleout=FCREATE(lcFilename)					&& Create output file
=FWRITE(liHandleout,FREAD(liHandlein,liSize))	&& Copy data to it
=FCLOSE(liHandlein)								&& Close the temporary .FPT..
=FCLOSE(liHandleout)							&& ...and the output file
lcTempfile=lcTempfile+".*"						&& Erase temporary .DBF/.FPT
ERASE (m.lcTempfile)						
SET COMPATIBLE &lcCompatible					&& Reset "Compatible"
IF FILE(lcFilename)
	llSuccess=.T.
ENDIF
RETURN llSuccess
There's a similar program on the Fox Wiki:

http://fox.wikis.com/wc.dll?Wiki~ImageData~VFP
--
Christof
Previous
Reply
Map
View

Click here to load this message in the networking platform