vilhelm.heiberg
10/14/2004 1:26:00 PM
Hello all,
I have a problem with Metafiles and streams in the .NET framework.
I see that it has been discussed somewhat earlier in ths group but not
exactly my problem.
I have a bunch of EMF files serialized in one big file. It has been
created using Visual C++ 6.0, which seems to me that have more support
for EMF files than .NET.
Anyway, I want to read these files into my C# program, manipulate them
a little and save them again to a file. Since there are many
metafiles that shall be one file on the disk I use streaming.
I can't figure out how to do store a metafile object to a stream.
Since EMF encoding is not supported in .NET.
Maybe an alternative way is to write a DLL using C++ and link it to my
program and send windows handles over the .NET-Win32 boundary somehow?
Here is a code fragment that illustrates the straight forward way
(that doesn't work) of what I want to do.
<CODE>
Stream stream = new FileStream(datafilename, FileMode.Open,
FileAccess.Read, FileShare.Read);
BinaryReader reader = new BinaryReader(stream,
System.Text.Encoding.UTF7);
uint buffersize;
Metafile metafile;
// START A LOOP HERE, TO READ SEVERAL METAFILES FROM THE STREAM
// Read a metafile from the stream.
buffersize = reader.ReadUInt32();
metafile = new Metafile(reader.BaseStream); // This seems to work.
... // Do something with the metafile
...
// Write the metafile to another stream
metafile.Save(outstream,ImageFormat.Emf); // This doesn't work
// but illustrates
// what I want to do.
// END LOOP
reader.Close();
stream.Close();
outstream.Close();
</CODE>
Sincerely,
Vilhelm Heiberg
Norway.