Microsoft KB Archive/161832

= How To Export an Embedded .bmp Image into a File =

Article ID: 161832

Article Last Modified on 7/1/2004

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft FoxPro 2.5b for Macintosh
 * Microsoft Visual FoxPro 2.5c for Macintosh
 * Microsoft FoxPro 2.6a Professional Edition for Macintosh
 * Microsoft Visual FoxPro 3.0b for Macintosh

-



This article was previously published under Q161832



SUMMARY
The command "APPEND GENERAL  FROM .bmp" imports a BMP image from a file and places it into a general field. But there is no reverse command like "Copy General To," which can export an embedded BMP image into a .bmp file. The following steps offer a workaround specially designed for embedded .bmp files only, other data formats can be easily exported if the storage structure of an OLE object is recognizable.



MORE INFORMATION
The following steps and sample program can be used to save an embedded bitmap file to a physical file on disk:

 Go to the record number of a table that you would like the associated BMP image exported to.  Copy the general field (Name "Picture") of the record to a temporary file (Name "Temp"). So the newly created Temp.dbf file contains one general field "Picture" and one record only. The syntax for this follows: COPY TO temp FIELDS picture NEXT 1   Execute the following code, assuming the file name for the output BMP image is "Test.Bmp": *** Open two files, "temp.fpt" contains the physical BMP data. *** and Create a file handle for the output file "Test.Bmp" handlein=FOPEN("temp.fpt") handleout=FCREATE("test.bmp")

*** To determine the length of the Input file "Temp.fpt" gnEnd = FSEEK(handlein, 0, 2) gnTop = FSEEK(handlein, 0)

*** Store the whole file into a string "str1" str1 = FREAD(handlein, gnEnd)

*** Offset 599 bytes from Str1 and save it to "str2" str2=RIGHT(str1,LEN(str1)-599)

*** Write "Str2" into the BMP file "Test.BMP" n=FWRITE(handleout,str2)

*** Close both opened files =FCLOSE(handlein) =FCLOSE(handleout) 

NOTE: If the BMP is placed into a General field by Edit/Paste from Clipboard, the data stored in general field is 599 bytes of header bytes plus the actual BMP data.

If the .bmp file is embedded in a general field by "Insert Object" or "Append General," then FoxPro creates presentation data plus the actual .bmp file data into the general field, which may result in the size of the FTP file being twice as big as the original .bmp data and if this is the case, 599 may not be the correct offset.

Keywords: kbhowto KB161832

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.