tags:

views:

55

answers:

2

Hi, How can i convert the "wmz" file to "gif" or "jpg" file in c#?

+2  A: 

WMZ is a compressed Windows Metafile which you could first decompress and then convert to the desired format (don't forget to dispose all those Image instances which is not done in the MSDN example).

Darin Dimitrov
Thanks for the help. I could decompress and convert to jpg file.
Thiyaneshwaran S
+1  A: 

Thanks for the help. I could decompress the "wmz" file and convert it to a wmf file. The code is

public String DeCompressWMZFile(String wmzFile)
{
    MemoryStream decompressStream = new MemoryStream(File.ReadAllBytes(wmzFile));
    GZipStream gzipStream = new GZipStream(decompressStream, CompressionMode.Decompress);
    MemoryStream outStream = new MemoryStream();
    int readCount;
    byte[] data = new byte[2048];
    do
    {
        readCount = gzipStream.Read(data, 0, data.Length);
        outStream.Write(data, 0, readCount);
    } while (readCount == 2048);
    String imgFile = Path.GetDirectoryName(wmzFile) + "\\" + Path.GetFileNameWithoutExtension(wmzFile) + ".wmf";
    File.WriteAllBytes(imgFile, outStream.GetBuffer());
    // Then add the code to create a new word document and insert 
    return imgFile;
}
Thiyaneshwaran S