LoadPicture(), SavePicture()
These two functions let you manipulate graphic images in a format compatible with ActiveX controls.
Usage |
oPicture = LoadPicture( cPathAndFileName ) lSuccess = SavePicture( oPicture, cPathAndFileName ) |
Parameter |
Value |
Meaning |
cPathAndFileName |
Character |
A character expression specifying the file to load or save, respectively. |
oPicture |
Object |
An object reference to a loaded graphic resource that can be used with an ActiveX control. |
lSuccess |
.T. |
The file was saved successfully. |
.F. |
If the drive or path doesn't exist, or there's no disk in the drive, we get an error rather than a return value of .F. The only time we get a return value of .F. is when the function writes a 0 byte file; see bug, below. |
SAVEPICTURE() has a fatal flaw. Attempting to save to a completely full diskette locks VFP 6 without an error message. Fortunately, this has been fixed in VFP 7. It saves a 0-byte file onto the diskette instead, and returns .F. |
In versions prior to VFP 7, LOADPICTURE() gives an "illegal file descriptor" (VFP 5) or an "Unknown COM Status code 0x800a01e1" (VFP 6) error if you try to load a file that's included in the running APP or EXE. It does so even if the file also physically exists on disk. This is a biggie: It means you can't include image files in the EXE but must ship them as separate files. The bitmaps can be listed in the Project Manager as long as they're marked as Excluded. Fortunately, VFP 7 no longer errors if you load a file that is in the running APP or EXE and also exists on the disk. The file built into the APP or EXE is used; not the one on the user's disk. |
Property |
Value |
Meaning |
Height, Width |
Numeric |
The picture's dimensions, measured in twips. Twips are 1/20th of a point, which is 1/72nd of an inch. |
Type |
Numeric |
The source of the picture: |
hPal |
Binary Numeric |
A handle to the associated palette. |
Example |
oPicture = LOADPICTURE(HOME()+"fox.BMP") lSuccess = LOADPICTURE(oPicture, HOME()+"newfox.bmp") |
See Also |