【问题标题】:wmz file to gif or jpgwmz 文件转为 gif 或 jpg
【发布时间】:2011-03-30 08:12:51
【问题描述】:

如何在 c# 中将“wmz”文件转换为“gif”或“jpg”文件?

【问题讨论】:

    标签: c# gif jpeg


    【解决方案1】:

    WMZ 是一个compressed Windows Metafile,您可以先解压缩它,然后再解压缩convert to the desired format(不要忘记处理所有这些Image 实例,这在MSDN 示例中没有完成)。

    【讨论】:

    • 感谢您的帮助。我可以解压缩并转换为 jpg 文件。
    【解决方案2】:

    感谢您的帮助。我可以解压缩“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;
    }
    

    【讨论】:

      【解决方案3】:

      将 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);
          }
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-09-15
        • 1970-01-01
        • 2011-05-11
        • 1970-01-01
        • 2011-04-01
        • 2011-03-12
        • 2012-05-03
        • 2012-01-25
        相关资源
        最近更新 更多