Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Picture from a memo field to individual bmp files 1

Status
Not open for further replies.

kate

Programmer
Nov 19, 2001
51
0
0
US
I need to take pictures from a memo field and store them on the hard drive as a .bmp file or a jpeg file either one will be helpful. Can it be done if so how?
 
Kate,

Sad I can't help you there. It is something that I have thought about. Why isn't there a function to copy a picture from a disk file into a General Field and the reverse. I am waiting with you to get some comments on the subject.

 
kate

Are refering to a binary memo field or a general field?

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
i'm working with kate on this. we are using a general field.
 
Maybe I'm missing something here, but I copy images back and forth from file to memo fields using the :
COPY MEMO <tablename.fieldname> TO <filepathname.ext>
and
APPEND MEMO <tablename.fieldname> FROM <filepathname.ext>

Does that not work for you?
 
steveschmidt

Yes u r missing some'. We are taking here off PICTURES being stored in a General, not MEMO field, to be saved as a bitmap or jpg file that can be viewed in any Photo Editing Software.

 
Kate

Here try this.
Code:
SELECT myTable
Copy To c:\temp Fields pic  && Or whatever your fieldname is
inComing=Fopen(&quot;c:\temp.fpt&quot;) && Open the memo field it created
p_result=Fcreate(&quot;c:\myPicture.bmp&quot;)
findEnd = Fseek(inComing, 0, 2)  && Find the end
findTop = Fseek(inComing, 0)  && Find the top
lcString = Fread(inComing, findEnd) && Copy the whole thing to a string
lcString2=Right(lcString,Len(lcString)-599) && Offset some bytes
=Fwrite(p_result,lcString2) && Write the results to a file
=Fclose(inComing) && Close 
=Fclose(p_result)  && Close

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Thanks to everyone for your help. Mike you procedure would work if I could open the .fpt.

inComing=Fopen(&quot;filename.fpt&quot;) I get a -1.

thank you
Kate
 
Kate,
Since low-level IO opens files &quot;exclusive&quot;, you need to make sure the table is closed before trying to extract this data.

Rick
 
kate

yes, as Rick said ;-)


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
I answered this question a few days back in thread184-656728 my solution is similar to the one Mike posted here, but avoids the low level calls by using filetostr() and strtofile() in both solutions the trick is to get rid of the first 599 bytes which hold all the extra garbage general fields keep with the actual file.

LOCAL cFileString
SELECT &quot;yourtable&quot;
COPY TO tmpTable FIELDS GenField NEXT 1
cFileString=FILETOSTR(&quot;tmpTable.fpt&quot;)
ERASE &quot;tmpTable.fpt&quot;
ERASE &quot;tmpTable.dbf&quot;
cFileString = RIGHT(cFileString,LEN(cFileString) - 599)
=STRTOFILE(cFileString, &quot;MyExport.bmp&quot;)


Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
Thank you 'Slighthaze' that did the job. Thank you all for your input.

Kate
 
Mike, slighthaze

'cFileString = RIGHT(cFileString,LEN(cFileString) - 599)'

What happens if the graphics file has been appended to the general field without the LINK argument, that is to say where the Windows associated graphics editor has been appended as well?



FAQ184-2483 - the answer to getting answered.​
Chris [pc2]
 
how do u copy from general field if you don't initially know what the file type of the contents?

the contents has the readable filename.ext embedded as well, so this can probably be solved if there's a way to extract that filename.ext. anyone of you who have an idea?
 
If the slighthaze code above was in a function make_image and the Memo field was called thumb how would you call this in a report for the thumb memo field of each record.

I have successfully created a jpg from each thumb by themselves-the memo is in jpg format

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top