Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic System Architect (steve huntington)
Decrease font size
Increase font size
Topic Title: Data files to 64 base encoding
Topic Summary: I know where the files are stored, wmf files, but I want to extract them into a base 64 encoded string.
Created On: 31-Jul-2006 05:30
Status: Read Only
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 31-Jul-2006 05:30
User is offline View Users Profile Print this message


Duane Hennessy

Posts: 112
Joined: 18-May-2006

I know where the files are stored, wmf files, but I want to extract them into a base 64 encoded string for an wordprocessingML report. Using the following SQL string in SQL Server 2000:

select data from files where name = 'D0000006.wmf' FOR XML raw, binary base64

This returns a useless string. I'm hoping Dale or someone has the answer to this:

- How are the files stored within the Image field in the Files table?
- What sort of transformation returns the raw binary file so I can encode it into a string?

Thanks.

Report this to a Moderator Report this to a Moderator
 31-Jul-2006 06:24
User is offline View Users Profile Print this message


Dale Moore

Posts: 23
Joined: 29-Jun-2006

Man, talk about giving me the hard one!!!  Don't know if I'll be able to help you with this one, but I'll tell you what I did to get the usrmatrx.xml file out of the files table, and see if that helps you.  Note that I did this in vba instead of directly through SQL Server, so it may be of no use to you anyway.

Here is a portion of the code I used:

Report this to a Moderator Report this to a Moderator
 31-Jul-2006 20:29
User is offline View Users Profile Print this message


Duane Hennessy

Posts: 112
Joined: 18-May-2006

Thanks Dale. I'll check it out when I get to work.
Report this to a Moderator Report this to a Moderator
 2-Aug-2006 07:24
User is offline View Users Profile Print this message


Duane Hennessy

Posts: 112
Joined: 18-May-2006

Got the base 64 encoding working from SQL Server, but it is encoding a WMF file which is not recognised by Word 2003, especially in a WordprocessingML file. Woohoo. So here's the plan:

The file is pumped out to a WMF file. Using good old interoperatiblity, VBA creates a public PowerPoint application in the background. The WMF file is inserted into a presentation and then saved as an EMF file.

The EMF file is read back into a BLOB and retrieved as a base 64 encoded string (because I can't be bothered waiting for VBA to convert the data into base 64 code using byte manipulating functions).

The string is inserted into the WordprocessingML file and hey presto...

We have a meta-file that is scaleable within MS Word.

It's prolix in it's processes but mapped out well. I'll probably do the file conversions to EMF and hold them within a temp table in SQL Server for retrieval as base64 strings after processing the rest of the XML for the document.
Report this to a Moderator Report this to a Moderator
 4-Aug-2006 02:10
User is offline View Users Profile Print this message


Jonathan Burlingame

Posts: 52
Joined: 1-Aug-2005

Good work Duane! If you want to skip the Powerpoint step, you can convert from WMF to EMF using a win32 API call(assuming that you are on 32-bit windows, and I am assuimg that. I'm not up to snuff on the 64-bit API of windows yet. I'm also assuming you aren't on 16-bit, and you can't be because these apps don't run on 16-bit platforms!).

WMF to EMF
SetWinMetaFileBits()
http://msdn.microsoft.com/libr...gdi/metafile_1xwz.asp

EMF to WMF
GetWinMetaFileBits()
http://msdn.microsoft.com/libr.../gdi/metafile_9bzn.asp
Report this to a Moderator Report this to a Moderator
 4-Aug-2006 05:02
User is offline View Users Profile Print this message


Duane Hennessy

Posts: 112
Joined: 18-May-2006

Excellent. I forgot about API's. Thanks Jonathon . I'll check it out.
Report this to a Moderator Report this to a Moderator
 4-Sep-2006 13:50
User is offline View Users Profile Print this message


Duane Hennessy

Posts: 112
Joined: 18-May-2006

Hey Jonathon, I played around with those API's you gave me and nailed it. So far, I have to convert from a WMF file to an EMF file, but I figure with some more tweaking I should be able to just copy the bytes straight into memory and convert them from there. Code attached...
Report this to a Moderator Report this to a Moderator
 5-Sep-2006 04:42
User is offline View Users Profile Print this message


Duane Hennessy

Posts: 112
Joined: 18-May-2006

In fact, now I've looked at it. I can avoid doing anything outside of the memory:

1. Extract the WMF file's bytes, from a field within the Files table, into a Byte array.
2. Run the Byte array through the WMF to EMF conversion function.
3. Pass the new EMF Byte array to a MSXML document object and parse the array as a bin.base64 data type into a Node.
4. Read the value of the node out as text for writing to the XML document.

Cool.

Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic System Architect forum.
There are currently 0 users logged in.
The most users ever online was 16 on 30-Oct-2008 at 14:46.
There are currently 0 guests browsing this forum, which makes a total of 0 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.