locked
how to convert wmz files from word document to gif or jpg file RRS feed

  • Question

  • Hi,

    Currently we are processing the word documents in c# and converting the word content to html format creates few image files of type "wmz".

    We tried to decompress the wmz file and save it as wmf file and then convert the wmf file to jpeg.

    But the final gif file contains only black color instead of the image.

    The code i tried 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[128];
                do
                {
                    readCount = gzipStream.Read(data, 0, data.Length);
                    outStream.Write(data, 0, readCount);
                } while (readCount == 128);
                String imgFile = Path.GetDirectoryName(wmzFile) + "\\" + Path.GetFileNameWithoutExtension(wmzFile) + ".wmf";
                File.WriteAllBytes(imgFile, outStream.GetBuffer());
                outStream.Close();
                Image img = Image.FromFile(imgFile);
                Bitmap bmp = new Bitmap(img);
                bmp.Save("D:\\a1.jpg", ImageFormat.Jpeg);
                bmp.Dispose();
                img.Dispose();
                return imgFile;
            }

     

    How can i get the exact image in the gif or jpg format?

    • Edited by Thiyaneshwaran S Friday, August 20, 2010 7:22 AM changed filetype to jpg
    • Moved by Cindy Meister MVP Friday, August 20, 2010 1:09 PM .NET graphics, not Word-related (From:Word for Developers)
    Friday, August 20, 2010 6:10 AM

Answers

All replies