To capture screen, you can check out GDIPlux at http://www.codeplex.com/VF
VFP files have a limit of 2GB. Because of that, I prefer to save the graphics file on the disk and save the filename of the graphics file in the table. If you use that method, remember that having too many files in a folder slows it down, and so create sub folder every time the number of files becomes large.
There is now a pictureval property for images so you can do
YourImage.PictureVal=FILET
Main Topics
Browse All Topics





by: CarlWarnerPosted on 2008-10-31 at 08:44:35ID: 22851281
Here is a tip with code on using a Binary Memo field from the December 2003 free (nothing to buy) VFUG Online newsletter at http://www.vfug.org/ :
---------- ---------- ---------- ---------- ----- wind\readm e2.jpg]))
********** ********** ****
eName, PICTURES.MemBin)
.FileName, PICTURES.MemBin)
.FileName, PICTURES.MemBin)
********** ********** ****
Image Storage
Wondering how to store all those images and link them into records and reports? Trevor Hancock (from Microsoft) suggested a way to avoid the dreaded 'General Field'.
I would personally recommend avoiding a general field for image storage. You are at the mercy of the registered OLE viewer on each client machine for .BMP files. As such, you may get an icon only on some systems and the full pic on others.
I recommend using a memo binary field to store pictures, and a UDF to write them to disk before usage on a report or on a form. You use a base Fox IMAGE control on the form (rather than an OLE BOUND) and simply read the file from disk. You still need the OLE BOUND on the report of course. This way, you are guaranteed to not run into the icon-issue.
Here're some samples....
REPORT
---------------
By using the MEMO BINARY field type and a UDF(), we can store .JPG files in a table field yet when the report
runs have them read from DISK. Here's how:
(1) Create a table or cursor with a structure like this (plus any added fields as necessary)
FileName C (150) MemBin MEMO(BINARY)
The command would be CREATE TABLE GENDBF (FileName c(150), MemoBin M NOCPTRANS)
(2) Append .JPG/BMP files into the MEMO(Binary) field using FILETOSTR() and set the filename field accordingly. For instance:
INSERT INTO CURSORNAME VALUES("ToothBrush.JPG", FILETOSTR(<PathToFile>))
(3) The FoxPro report will still need an OLEBOUND control on it to print pictures, but instead of pointing the OLEBOUND to a general field, point it FILE and use this as the expression:
MYUDF(FileName, MemoBin)
Where MyUDF is in some program made available via SET PROC and reads
thusly:
PROCEDURE MYUDF(lpFileName, lpMemoBinFld)
LOCAL lcTemp as String
lcTemp = ADDBS(SYS(2023)) + "JPGTEMP\"
IF !DIRECTORY(lcTemp)
MD (lcTemp)
ENDIF
SET SAFETY OFF
STRTOFILE(lpMemoBinFld, lcTemp + lpFileName)
SET SAFETY ON
RETURN lcTemp + lpFileName
(4) Finally, preview/print the report. You may also want to fire some
lines
like this to clean up afterward:
ERASE ADDBS(SYS(2023)) + "JPGTEMP\*.jpg"
RD ADDBS(SYS(2023)) + "JPGTEMP"
--------------------------
===FORM (code assumes full install of VFP8)===
CREATE CURSOR PICTURES (FileName c(150), MemBin M NOCPTRANS)
INSERT INTO PICTURES VALUES([FOX.bmp], FILETOSTR(ADDBS(HOME()) ;
+ [FOX.BMP]))
INSERT INTO PICTURES VALUES([Bandrpt.bmp], FILETOSTR(ADDBS(HOME()) ;
+ [Wizards\Bandrpt.bmp]))
INSERT INTO PICTURES VALUES([readme2.jpg], FILETOSTR(ADDBS(HOME()) ;
+ [samples\webservices\north
LOCATE
PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.SHOW
RETURN
**************************
DEFINE CLASS form1 AS FORM
TOP = 71
LEFT = 48
HEIGHT = 310
WIDTH = 504
CAPTION = "Fox Image Demo"
NAME = "Form1"
ADD OBJECT image1 AS IMAGE WITH ;
HEIGHT = 296, ;
LEFT = 3, ;
TOP = 8, ;
WIDTH = 381, ;
NAME = "Image1"
ADD OBJECT cmdPrevious AS COMMANDBUTTON WITH ;
TOP = 27, ;
LEFT = 422, ;
HEIGHT = 27, ;
WIDTH = 24, ;
CAPTION = "<", ;
NAME = "cmdPrevious"
ADD OBJECT cmdNext AS COMMANDBUTTON WITH ;
TOP = 27, ;
LEFT = 446, ;
HEIGHT = 27, ;
WIDTH = 24, ;
CAPTION = "", ;
NAME = "cmdNext"
ADD OBJECT cmdQuit AS COMMANDBUTTON WITH ;
TOP = 72, ;
LEFT = 405, ;
HEIGHT = 27, ;
WIDTH = 84, ;
CAPTION = "Quit", ;
NAME = "cmdQuit"
PROCEDURE getimage
LPARAMETERS lpFileName, lpMemoBinFld
LOCAL lcTemp AS STRING
lcTemp = ADDBS(SYS(2023)) + "JPGTEMP\"
IF !DIRECTORY(lcTemp)
MD (lcTemp)
ENDIF
SET SAFETY OFF
STRTOFILE(lpMemoBinFld, lcTemp + lpFileName)
SET SAFETY ON
RETURN lcTemp + lpFileName
ENDPROC
PROCEDURE DESTROY
USE IN SELECT([PICTURES])
ERASE ADDBS(SYS(2023)) + [JPGTEMP\*.jpg]
ERASE ADDBS(SYS(2023)) + [JPGTEMP\*.bmp]
RD ADDBS(SYS(2023)) + [JPGTEMP]
ENDPROC
PROCEDURE INIT
THISFORM.image1.PICTURE = ;
THIS.getimage(PICTURES.Fil
ENDPROC
PROCEDURE cmdPrevious.CLICK
IF RECNO() < 1
SKIP -1
THISFORM.image1.PICTURE = ;
THISFORM.getimage(PICTURES
THISFORM.REFRESH
ENDIF
ENDPROC
PROCEDURE cmdNext.CLICK
IF RECCOUNT() < RECNO() AND !EOF()
SKIP
THISFORM.image1.PICTURE = ;
THISFORM.getimage(PICTURES
THISFORM.REFRESH
ENDIF
ENDPROC
PROCEDURE cmdQuit.CLICK
THISFORM.RELEASE
ENDPROC
ENDDEFINE
**************************
Respectfully,
Trevor Hancock, MCSD
Microsoft Developer Support - FoxPro