2010-08-16 149 views

回答

1

感謝您的幫助。我可以解壓縮「wmz」文件並將其轉換爲wmf文件。該代碼是

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; 
} 
0

WMZ轉換爲GIF/PNG/JPG /等:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://link1.ru/image.wmz"); 
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); 
using (Stream inputStream = response.GetResponseStream()) 
{ 
    using (GZipStream gzipStream = new GZipStream(inputStream, CompressionMode.Decompress)) 
    { 
     Image i = Image.FromStream(gzipStream); 
     i.Save("1.gif", ImageFormat.Gif); 
    } 
}